ceklogin(); $this->load->model('ModelBrgsv', 'Brgsv'); $this->load->model('ModelPelanggan', 'Pelanggan'); $this->load->model('ModelSetData', 'Setdata'); $this->load->model('ModelService', 'Service'); $this->load->model('ModelDashboard', 'Dashboard'); } public function output_json($data, $encode = true) { if ($encode) $data = json_encode($data); $this->output->set_content_type('application/json')->set_output($data); } private function ceklogin() { $username = $this->session->userdata('username'); if ($username == null) { redirect("login"); } } public function index() { $id_setdata = $this->Setdata->getIDSETDATA(); $id_setdata = $id_setdata[0]['ID_SETDATA']; $jabatan = $this->session->userdata('jabatan'); $datPelanggan = $this->Pelanggan->getData_Pelanggan(); $datBrgsv = $this->Brgsv->getData_Brgsv(); $tgl = date('Y-m-d'); $count1 = $this->Service->getCount_CetakDokumen_Service(); $count2 = $this->Service->getCount_Service_0(); $count3 = $this->Service->getCount_KlaimService_0_2(); $count4 = $this->Service->getCount_OrderService_NonDATANG(); $data = array( 'sidebar' => "menu service", 'navChild' => "", 'id' => $id_setdata, 'jabatan' => $jabatan, 'tgl' => $tgl, 'pelanggan' => $datPelanggan, 'brgsv' => $datBrgsv, 'count1' => $count1, 'count2' => $count2, 'count3' => $count3, 'count4' => $count4 ); $this->load->view('menu/Service', $data); } public function get_count() { $count1 = $this->Service->getCount_CetakDokumen_Service(); $count2 = $this->Service->getCount_Service_0(); $count3 = $this->Service->getCount_KlaimService_0_2(); $count4 = $this->Service->getCount_OrderService_NonDATANG(); $data = array( 'count1' => $count1, 'count2' => $count2, 'count3' => $count3, 'count4' => $count4 ); $this->output_json($data); } public function kodeService() { $kk = $this->Setdata->getKode_Service(); if (is_array($kk) || is_object($kk)) { foreach ($kk as $row) { if ($row['KODE'] == null) { return "SRV-000001"; } else { $str = (string) $row['KODE']; $panjang = 6; $data = substr($str, 4, $panjang); $ko = (int) $data + 1; $str = (string) $ko; $panjang = 10 - strlen($str); $data = "SRV-000000"; $data = substr($data, 0, $panjang) . $str; return $data; } } } } public function tambahservice_SvA1() { $id_service = $this->input->post('id'); $id_pelanggan = $this->input->post('id_pelanggan'); $tgl_service = $this->input->post('tgl_service'); $id_brgsv = $this->input->post('id_brgsv'); $nama_sns = $this->input->post('nama_sns'); $kel_sns = $this->input->post('kel_sns'); $ket_sns = $this->input->post('ket_sns'); $id_karyawan = $this->session->userdata('id_karyawan'); $kode_service = $this->kodeService(); $tgl = date('Y-m-d'); if (strtotime($tgl_service)>strtotime($tgl)) { $this->session->set_flashdata('date_error', 'error'); redirect($_SERVER['HTTP_REFERER']); } $nama_sns = strtoupper($nama_sns); $input = [ 'TGL_SERVICE' => $tgl_service, 'KODE_SERVICE' => $kode_service, 'PELANGGAN_ID' => $id_pelanggan, 'JENIS_SERVICE' => '1', 'PENERIMA_ID' => $id_karyawan, 'STATUS_SERVICE'=> '0' ]; $action = $this->Setdata->create('service', $input); $id_service = $this->Setdata->getID_ServiceMax(); $id_service = $id_service[0]['ID_SERVICE']; $input = [ 'SERVICE_ID' => $id_service, 'BRGSV_ID' => $id_brgsv, 'NAMA_SNS' => $nama_sns, 'KEL_SNS' => $kel_sns, 'KET_SNS' => $ket_sns ]; $action = $this->Setdata->create('sn_service', $input); $input = [ 'SERVICE_ID' => $id_service, 'KODE_BUKTI' => $kode_service, 'SJ_INV' => '0' ]; $action = $this->Setdata->create('cetak_dokumen', $input); if ($action) { $this->session->set_flashdata('success', 'ditambah'); redirect($_SERVER['HTTP_REFERER']); } else { $this->session->set_flashdata('failed', 'ditambah'); redirect($_SERVER['HTTP_REFERER']); } } }