Files
shopee-apps/application/controllers/notused/ManageDaftarHarga.php
T
2026-06-13 16:02:07 +10:00

101 lines
2.5 KiB
PHP

<?php
defined('BASEPATH') or exit('No direct script access allowed');
class ManageDaftarHarga extends CI_Controller
{
function __construct()
{
parent::__construct();
$this->load->model('ModelDaftarHarga', 'Daftarharga');
$this->load->library(['datatables', 'form_validation']);
$this->form_validation->set_error_delimiters('', '');
}
public function output_json($data, $encode = true)
{
if ($encode) $data = json_encode($data);
$this->output->set_content_type('application/json')->set_output($data);
}
public function index()
{
$datDaftarHarga = $this->Daftarharga->getData_DaftarHarga_forAdmin();
$set = 1;
$data = [
'sidebar' => "master data",
'navChild' => "",
'dh' => $datDaftarHarga,
'set' => $set
];
$this->load->view('master/DaftarHarga', $data);
}
public function dataDaftarHarga()
{
$datDaftarHarga = $this->Daftarharga->getData_DaftarHarga_forView();
$set = 0;
$data = [
'sidebar' => "master data",
'navChild' => "",
'dh' => $datDaftarHarga,
'set' => $set
];
$this->load->view('master/DaftarHarga', $data);
}
public function view()
{
$method = $this->input->post('method');
$id_barang = $this->input->post('id_barang');
$dealer_hsrp = $this->input->post('dealer_hsrp');
$user_hsrp = $this->input->post('user_hsrp');
$ket_barang = $this->input->post('ket_barang');
$tgl = date('Y-m-d');
$check_nilai = is_numeric($dealer_hsrp);
if ($check_nilai==FALSE) {
$dealer_hsrp = 0;
}
$check_nilai = is_numeric($user_hsrp);
if ($check_nilai==FALSE) {
$user_hsrp = 0;
}
if ($dealer_hsrp <= 0 or $user_hsrp <= 0) {
$this->session->set_flashdata('not_zero_negative', 'error');
redirect($_SERVER['HTTP_REFERER']);
}
if ($ket_barang == "") {
$ket_barang = NULL;
}
$datSrp = $this->Daftarharga->getData_HargaSrp_byBARANG($id_barang);
$index = count($datSrp);
if ($datSrp[$index - 1]['DEALER_HSRP'] != $dealer_hsrp or $datSrp[$index - 1]['USER_HSRP'] != $user_hsrp) {
$input = [
'DEALER_HSRP' => $dealer_hsrp,
'USER_HSRP' => $user_hsrp,
'TGL_HSRP' => $tgl,
'BARANG_ID' => $id_barang
];
$action = $this->Daftarharga->create('harga_srp', $input);
}
$update = [
'KET_BARANG' => $ket_barang
];
$action = $this->Daftarharga->update('barang', $update, 'ID_BARANG', $id_barang);
if ($action) {
$this->session->set_flashdata('success', 'diperbaruhi');
redirect($_SERVER['HTTP_REFERER']);
} else {
$this->session->set_flashdata('failed', 'diperbaruhi');
redirect($_SERVER['HTTP_REFERER']);
}
}
}