load->model('AkunModel', 'AkunM'); $this->load->model('LevelModel', 'LevelM'); $this->load->model('Kueri'); //digunakan status checker $this->load->model('SOModel', 'SOM'); $this->load->model('BarangModel', 'BarangM'); $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() { $ID_USER = $this->session->userdata('id_user'); $level = $this->session->userdata('level'); $username = $this->session->userdata('username'); if ($username == null) { redirect("Action"); } if ($level != "GUDANG" && $level != "OPERATOR") { $histori = $this->SOM->getDataHistori($ID_USER, $level); } if ($level == "ADMIN") { $data = array( 'sidebar' => "so", 'navChild' => "", // 'status_checker' => $this->SOM->lihat_status(), 'inbox' => $this->SOM->getDataInbox($ID_USER, $level), 'cekread' => $this->SOM->getCekRead(), 'hstr' => $histori, 'pesanan' => $this->SOM->getDataPesananBarang(), 'tkns' => $this->SOM->getDataChecker() ); $this->load->view('report/admin-so', $data); } else { $data = array( 'sidebar' => "so", 'navChild' => "", // 'status_checker' => $this->SOM->lihat_status(), 'inbox' => $this->SOM->getDataInbox($ID_USER, $level), 'cekread' => $this->SOM->getCekRead(), 'tkns' => $this->SOM->getDataChecker() ); $this->load->view('so-center', $data); } } public function add() { $method = $this->input->post('method'); $spesifikasi = $this->input->post('spesifikasi'); $id_barang = $this->input->post('id_barang'); $jumlah_unit = $this->input->post('jumlah_unit'); $kondisi = $this->input->post('kondisi'); $username = $this->session->userdata('username'); $level = $this->session->userdata('level'); if ($username == null) { redirect("Action"); } $datSales = $this->SOM->getDataSales(); $datChecker = $this->SOM->getDataChecker(); $datPelanggan = $this->SOM->getDataPelanggan(); $datBarang = $this->BarangM->getDataBarang(); $datPesanan = $this->SOM->getDataPesananK($level); if ($method == null) { $data = [ 'sidebar' => "so", 'navChild' => "", 'sales' => $datSales, 'checker' => $datChecker, 'pelanggan' => $datPelanggan, 'barang' => $datBarang, 'pesanan' => $datPesanan, ]; $this->load->view('tambah-so', $data); } else if ($method === 'add') { // var_dump($id_barang.'-'.$spesifikasi.'-'.$kondisi.'-'.$jumlah_unit); $this->form_validation->set_rules('id_barang', 'Barang', 'required'); $this->form_validation->set_rules('jumlah_unit', 'Jumlah Unit', 'required'); $this->form_validation->set_rules('kondisi', 'Kondisi', 'required'); if ($this->form_validation->run() == FALSE) { $data = [ 'status' => false, 'errors' => [ 'id_barang' => form_error('id_barang'), 'jumlah_unit' => form_error('jumlah_unit'), 'kondisi' => form_error('kondisi') ] ]; $this->output_json($data); } else { if ($this->session->userdata('level') == "ADMIN") { $aa = 0; } else { $aa = 1; } $method = null; $input = [ 'BARANG_ID' => $id_barang, 'JUMLAH' => $jumlah_unit, 'KONDISI' => $kondisi, 'SPESIFIKASI_PESANAN' => $spesifikasi, 'STATUS_PESANAN' => $aa ]; $action = $this->SOM->create('pesanan', $input); if ($action) { $this->output_json(['status' => true]); } else { $this->output_json(['status' => false]); } } // $datPesanan1 = $this->SOM->getDataPesananK(); // $data = [ // 'sales' => $datSales, // 'checker' => $datChecker, // 'pelanggan' => $datPelanggan, // 'barang' => $datBar // ];ang, // 'pesanan' => $datPesanan1 // $this->load->view('tambah-so', $data); } // $datLevel = $this->LevelM->getDataLevel(); // $data = [ // 'level' => $datLevel // ]; } public function edit() { $id_pesanan = $this->input->post('id_pesanan'); $spesifikasi = $this->input->post('spesifikasied'); $id_barang = $this->input->post('id_baranged'); $jumlah_unit = $this->input->post('jumlah_united'); $kondisi = $this->input->post('kondisied'); $method = $this->input->post('method'); $input = [ 'BARANG_ID' => $id_barang, 'JUMLAH' => $jumlah_unit, 'KONDISI' => $kondisi, 'SPESIFIKASI_PESANAN' => $spesifikasi ]; $action = $this->SOM->update('pesanan', $input, 'ID_PESANAN', $id_pesanan); if ($action) { $this->session->set_flashdata('flash_so_pes', 'diubah'); redirect('ManageSO/add'); } else { $this->session->set_flashdata('flashgagal', 'diubah'); redirect('ManageSO/add'); } // $datSales = $this->SOM->getDataSales(); // $datChecker = $this->SOM->getDataChecker(); // $datPelanggan = $this->SOM->getDataPelanggan(); // $datBarang = $this->BarangM->getDataBarang(); // $datPesanan1 = $this->SOM->getDataPesananK(); // $data = [ // 'sales' => $datSales, // 'checker' => $datChecker, // 'pelanggan' => $datPelanggan, // 'barang' => $datBarang, // 'pesanan' => $datPesanan1 // ]; // $this->load->view('tambah-so', $data); } public function history() { $ID_USER = $this->session->userdata('id_user'); $username = $this->session->userdata('username'); if ($username == null) { redirect("Action"); } $level = $this->session->userdata('level'); if ($level === 'ADMIN') { $histori = $this->SOM->getDataHistori($ID_USER, $level); $data = [ 'sidebar' => "so", 'navChild' => "", 'hstr' => $histori ]; $this->load->view('table-admin-so', $data); } elseif ($level === 'TEKNISI') { $histori = $this->SOM->getDataHistori($ID_USER, $level); $progress = $this->SOM->getDataProgress($ID_USER, $level); $data = [ 'sidebar' => "so", 'navChild' => "", 'hstr' => $histori, 'progress' => $progress ]; $this->load->view('table-myhistory', $data); } elseif ($level === 'SALES') { $histori = $this->SOM->getDataHistori($ID_USER, $level); $progress = $this->SOM->getDataProgress($ID_USER, $level); $data = [ 'sidebar' => "so", 'navChild' => "", 'hstr' => $histori, 'progress' => $progress, 'tkns' => $this->SOM->getDataChecker() ]; $this->load->view('table-sales-order', $data); } elseif ($level === 'OPERATOR' || $level === 'GUDANG') { $histori = $this->SOM->getDataHistori($ID_USER, $level); $progress = $this->SOM->getDataProgress($ID_USER, $level); $data = [ 'sidebar' => "so", 'navChild' => "", 'hstr' => $histori, 'tkns' => $this->SOM->getDataChecker(), 'progress' => $progress ]; $this->load->view('table-so', $data); } } public function hapus() { $id_pesanan = $this->input->post('id'); if ($this->SOM->delete('pesanan', $id_pesanan, 'ID_PESANAN')) { $this->session->set_flashdata('flash_so_pes', 'dihapus'); redirect('ManageSO/add'); } } public function save() { $id_pelanggan = $this->input->post('id_pelanggan'); $kode_po = $this->input->post('kode_po'); $kode_so = $this->input->post('kode_so'); $id_user_sales = $this->input->post('id_user_sales'); // $id_user_checker = $this->input->post('id_user_checker'); // $data = $id_pelanggan.'-'.$kode_po.'-'.$kode_so.'-'.$id_user_sales.'-'.$id_user_checker; $tgl = date('Y-m-d'); $inputso = [ 'PELANGGAN_ID' => $id_pelanggan, 'USER_CHECKER_ID' => null, 'USER_SALES_ID' => $id_user_sales, 'KODE_SO' => $kode_so, 'TANGGAL_SO' => $tgl, 'KODE_PO' => $kode_po ]; // var_dump($inputso); $actionso = $this->SOM->create('so', $inputso); if ($actionso) { $cariso = $this->SOM->getIDSO($kode_so, $kode_po); $caripesanan = $this->SOM->getDataPesanan(); if (is_array($caripesanan) || is_object($caripesanan)) { foreach ($caripesanan as $key) { $up = [ 'SO_ID' => $cariso[0]['ID_SO'], 'STATUS_PESANAN' => null ]; $uppel = $this->SOM->update('pesanan', $up, 'ID_PESANAN', $key['ID_PESANAN']); } } if ($uppel) { $this->session->set_flashdata('flash_so_pes', 'ditambah'); redirect('ManageSO/add'); // $this->output_json(['status' => true]); } else { $this->session->set_flashdata('flashgagal', 'ditambah'); redirect('ManageSO/add'); // $this->output_json(['status' => false, 'msg' => 'gagal']); } // $this->session->set_flashdata('flash_so', 'ditambah'); // $this->output_json(['status' => true, 'dat' => $caripesanan]); } else { $this->session->set_flashdata('flashgagal', 'ditambah'); redirect('ManageSO/add'); // $this->output_json(['status' => false, 'msg' => 'gagal']); } } public function detailSO($id) { $username = $this->session->userdata('username'); if ($username == null) { redirect("Action"); } $datSO = $this->SOM->getDataViewSO($id); if ($this->session->userdata('level') == "OPERATOR") { $datPesanan = $this->SOM->getDataViewPesanan2($id); } else { $datPesanan = $this->SOM->getDataViewPesanan($id); } // var_dump($datPesanan); $data = [ 'sidebar' => "so", 'navChild' => "", 'so' => $datSO, 'pesanan' => $datPesanan, 'status_checker' => $this->SOM->lihat_status() ]; $this->load->view('view-so', $data); } public function savepesanan($id) { $idPesanan = $this->input->post('id_pesanan'); $KETERANGAN = $this->input->post('KETERANGAN'); $tgl_selesai = date('Y-m-d'); $status = 'OK'; $input = [ 'KETERANGAN' => $KETERANGAN, 'STATUS_PESANAN' => $status ]; $action = $this->SOM->update('pesanan', $input, 'ID_PESANAN', $idPesanan); if ($action) { $this->session->set_flashdata('flash', 'diambil'); redirect('ManageSO/detailSO/' . $id); } else { $this->session->set_flashdata('flash_gagal', 'diambil'); redirect('ManageSO/detailSO/' . $id); } } public function savepesananoperator($id) { $idPesanan = $this->input->post('id_pesanan'); // $KETERANGAN = $this->input->post('KETERANGAN'); $tgl_selesai = date('Y-m-d'); $status = 'SELESAI'; $input = [ // 'KETERANGAN' => $KETERANGAN, 'TANGGAL_SELESAI' => $tgl_selesai, 'STATUS_PESANAN' => $status ]; $action = $this->SOM->update('pesanan', $input, 'ID_PESANAN', $idPesanan); if ($action) { $this->session->set_flashdata('flashselesai', 'selesai'); redirect('ManageSO/detailSO/' . $id); } else { $this->session->set_flashdata('flash_gagal', 'diambil'); redirect('ManageSO/detailSO/' . $id); } } public function ubahStatus($id) { $username = $this->session->userdata('username'); if ($username == null) { redirect("Action"); } $datSO = $this->SOM->getDataViewSO($id); $datPesanan = $this->SOM->getDataUbahPesanan($id); $data = [ 'sidebar' => "so", 'navChild' => "", 'so' => $datSO, 'pesanan' => $datPesanan, 'status_checker' => $this->SOM->lihat_status() ]; $this->load->view('ubah-so', $data); } public function savestatus($idPesanan, $idSo) { // $idPesanan = $this->input->post('id_pesanan'); //$KETERANGAN = $this->input->post('KETERANGAN'); //$tgl_selesai = date('Y-m-d'); $status = 'PROSES'; $input = [ // 'KETERANGAN' => $KETERANGAN, //'TANGGAL_SELESAI' => $tgl_selesai, 'STATUS_PESANAN' => $status ]; $action = $this->SOM->update('pesanan', $input, 'ID_PESANAN', $idPesanan); if ($action) { // $this->output_json(['status' => true]); $this->session->set_flashdata('flash', 'diproses'); redirect("ManageSO/ubahStatus/" . $idSo); } } public function laporan() { $username = $this->session->userdata('username'); if ($username == null) { redirect("Action"); } $datlaporan = $this->SOM->getDataLaporan(); $data = [ 'sidebar' => "laporan", 'navChild' => "", 'lprn' => $datlaporan ]; $this->load->view('report/table-laporan', $data); } public function cetaklaporan() { $bulan = $this->input->post('bulan'); $tahun = $this->input->post('tahun'); if ($tahun == null) { $tahun = date("Y"); } $bln = ""; if ($bulan == "01") { $bln = "Januari"; } elseif ($bulan == "02") { $bln = "Februari"; } elseif ($bulan == "03") { $bln = "Maret"; } elseif ($bulan == "04") { $bln = "April"; } elseif ($bulan == "05") { $bln = "Mei"; } elseif ($bulan == "06") { $bln = "Juni"; } elseif ($bulan == "07") { $bln = "Juli"; } elseif ($bulan == "08") { $bln = "Agustus"; } elseif ($bulan == "09") { $bln = "September"; } elseif ($bulan == "10") { $bln = "Oktober"; } elseif ($bulan == "11") { $bln = "November"; } elseif ($bulan == "12") { $bln = "Desember"; } // var_dump($tahun); $lap = $this->SOM->getCetak($bulan, $tahun); $data = [ 'lap' => $lap, 'bln' => $bln, 'tahun' => $tahun, 'pass' => $this->session->userdata('password') ]; // var_dump($lap); $this->load->view('report/excel', $data); } public function table_sales_order() { $ID_USER = $this->session->userdata('id_user'); $level = $this->session->userdata('level'); $histori = $this->SOM->getDataHistori($ID_USER, $level); $data = [ 'sidebar' => "so", 'hstr' => $histori, 'tkns' => $this->SOM->getDataChecker() ]; $this->load->view('table-sales-order', $data); } public function belumDatang($idPesanan, $idSo) { $status = 'BELUM DATANG'; $input = [ 'STATUS_PESANAN' => $status ]; $action = $this->SOM->update('pesanan', $input, 'ID_PESANAN', $idPesanan); if ($action) { // $this->output_json(['status' => true]); $this->session->set_flashdata('flash', 'diproses'); redirect("ManageSO/ubahStatus/" . $idSo); } } public function edit_so($kode_so = null, $id_pesanan = null) { $level = $this->session->userdata('level'); $username = $this->session->userdata('username'); if ($username == null) { redirect("Action"); } if ($level != "ADMIN") { redirect("Action"); } $pesanan = $this->SOM->getPesananByKode($kode_so, $id_pesanan); $pelanggan = $this->SOM->getDataPelanggan(); $qc = $this->SOM->getDataChecker(); $barang = $this->SOM->getDataBarang(); $data = [ 'sidebar' => "so", 'navChild' => "", 'pesanan' => $pesanan, 'pelanggan' => $pelanggan, 'qc' => $qc, 'barang' => $barang ]; $this->load->view('edit-so', $data); } public function editso() { $method = $this->input->post('method'); $id_pesanan = $this->input->post('id_pesanan'); $kode_so = $this->input->post('kode_so'); $pelanggan = $this->input->post('pelanggan'); $qc = $this->input->post('qc'); $kode_po = $this->input->post('kode_po'); $tanggal_so = $this->input->post('tanggal_so'); /////// $barang = $this->input->post('barang'); $id_pes = $this->input->post('id_pes'); $jumlah = $this->input->post('jumlah'); $kondisi = $this->input->post('kondisi'); $tanggal_selesai = $this->input->post('tanggal_selesai'); $status = $this->input->post('status'); $spesifikasi = $this->input->post('spesifikasi'); $keterangan = $this->input->post('keterangan'); $k_s = $this->input->post('k_s'); if ($method === 'editso') { if ($qc == null) { $input = [ 'PELANGGAN_ID' => $pelanggan, // 'USER_CHECKER_ID' => $qc, 'TANGGAL_SO' => $tanggal_so, 'KODE_PO' => $kode_po ]; } else { $input = [ 'PELANGGAN_ID' => $pelanggan, 'USER_CHECKER_ID' => $qc, 'TANGGAL_SO' => $tanggal_so, 'KODE_PO' => $kode_po ]; } // $action = ; if ($this->SOM->update('so', $input, 'KODE_SO', $kode_so)) { $this->session->set_flashdata('flashedit', 'diubah'); // redirect('ManageSO'); $this->output_json(['status' => true, 'kode' => $kode_so, 'id' => $id_pesanan]); } else { $this->session->set_flashdata('flashedit', 'gagal'); $this->output_json(['status' => false, 'msg' => 'gagal', 'kode' => $kode_so, 'id' => $id_pesanan]); } // $dat = $kode_so . '--' . $pelanggan . '--' . $qc . '--' . $kode_po . '--' . $tanggal_so; // $this->session->set_flashdata('flashedit', $dat); // $this->output_json(['status' => true, 'kode' => $kode_so, 'id' => $id_pesanan]); } else if ($method === 'editpes') { if ($tanggal_selesai == null) { $tanggal_selesai = null; } if ($keterangan == null) { $keterangan = null; } $input = [ 'BARANG_ID' => $barang, 'JUMLAH' => $jumlah, 'KONDISI' => $kondisi, 'TANGGAL_SELESAI' => $tanggal_selesai, 'SPESIFIKASI_PESANAN' => $spesifikasi, 'KETERANGAN' => $keterangan, 'STATUS_PESANAN' => $status ]; $action = $this->SOM->update('pesanan', $input, 'ID_PESANAN', $id_pes); if ($action) { $this->session->set_flashdata('flashedit', 'diubah'); $this->output_json(['status' => true, 'kode' => $k_s, 'id' => $id_pes]); } else { $this->session->set_flashdata('flashedit', 'gagal'); $this->output_json(['status' => false, 'msg' => 'gagal', 'kode' => $k_s, 'id' => $id_pes]); } // var_dump($barang . '//' . $id_pes . '//' . $jumlah . '//' . $kondisi . '//' . $tanggal_selesai . '//' . $status . '//' . $spesifikasi . '//' . $k_s); } } public function hapus_so() { $id_pesanan = $this->input->post('id'); if ($this->SOM->delete('pesanan', $id_pesanan, 'ID_PESANAN')) { $this->session->set_flashdata('flash_so_pes', 'dihapus'); redirect('ManageSO'); } } public function ambilPesanan($id_user, $id_so) { $input = [ 'USER_CHECKER_ID' => $id_user ]; if ($this->SOM->update('so', $input, 'ID_SO', $id_so)) { $this->session->set_flashdata('flash', 'diambil'); redirect('ManageSO/detailSO/' . $id_so); } else { $this->session->set_flashdata('flash_gagal', 'diambil'); redirect('ManageSO/detailSO/' . $id_so); } } public function detail_history($id) { $username = $this->session->userdata('username'); if ($username == null) { redirect("Action"); } $datSO = $this->SOM->getDataViewSO($id); $datPesanan = $this->SOM->getDataUbahPesanan($id); $data = [ 'sidebar' => "so", 'navChild' => "", 'so' => $datSO, 'pesanan' => $datPesanan, 'status_checker' => $this->SOM->lihat_status() ]; $this->load->view('detail-history', $data); } }