db_onedev = $this->load->database("onedev", true); } public function add_notes($orderid){ } public function search() { //# cek token valid if (! $this->isLogin) { $this->sys_error("Invalid Token"); exit; } $prm = $this->sys_input; $startdate = $prm['startdate'] . " 00:00:01"; $enddate = $prm['enddate'] . " 23:59:59"; $search = $prm["search"]; $status = $prm["status"]; $number_limit = 10; $number_offset = ($prm['current_page'] - 1) * $number_limit ; $where = " ( F_PaymentKasirDate BETWEEN '{$startdate}' AND '{$enddate}' ) AND "; if($search != '') $where = "( F_PaymentKasirNumber LIKE '%{$search}%') AND "; $sql = " SELECT count(*) as total FROM f_payment_kasir WHERE $where ( ('{$status}' = 'N' AND (F_PaymentKasirIsReceived = 'N' )) OR ('{$status}' = 'Y' AND F_PaymentKasirIsReceived = 'Y') )"; $query = $this->db_onedev->query($sql, $sql_param); $tot_count = 0; $tot_page = 0; if ($query) { $tot_count = $query->result_array()[0]["total"]; $tot_page = ceil($tot_count/$number_limit); } else { $this->sys_error_db("t_samplestorage count", $this->db_onedev); exit; } $sql = "SELECT F_PaymentKasirID , F_PaymentKasirNumber , date_format(F_PaymentKasirDate,'%d-%m-%Y %T') as F_PaymentKasirDate , F_PaymentKasirCreated , F_PaymentKasirLastUpdated ,M_StaffName, if(F_PaymentKasirIsReceived = 'N','Belum Diterima' ,'Sudah diterima') as F_PaymentKasirIsReceived , F_PaymentKasirIsActive FROM f_payment_kasir JOIN m_user on F_PaymentKasirUserID = M_UserID join m_staff on M_UserM_StaffID = M_StaffID WHERE $where ( ('{$status}' = 'N' AND (F_PaymentKasirIsReceived = 'N' )) OR ('{$status}' = 'Y' AND F_PaymentKasirIsReceived = 'Y') ) ORDER BY F_PaymentKasirID asc limit $number_limit offset $number_offset"; //echo $sql; $query = $this->db_onedev->query($sql, $sql_param); $rows = $query->result_array(); if($rows){ foreach($rows as $k => $v){ $rows[$k]['notes'] = $this->add_notes($v['F_PaymentKasirID']); } } $result = array("total" => $tot_page, "records" => $rows, "sql"=> $this->db_onedev->last_query()); $this->sys_ok($result); exit; } public function save() { //# ambil parameter input $prm = $this->sys_input; $puserid = $prm['pUserID']; $sql = "CALL sp_fo_send_to_cashier({$puserid})"; $query = $this->db_onedev->query($sql); if ($query) { $result = array(); $this->sys_ok($result); } else { $this->sys_error_db("payment save rows", $this->db_onedev); exit; } } public function savetutup() { //# ambil parameter input $prm = $this->sys_input; $ppaymentkasirid = $prm['pPaymentKasirID']; $puserid = $prm['pUserID']; $sql = "CALL sp_fo_received_cashier('{$ppaymentkasirid}','{$puserid}')"; //$sql = "CALL sp_fo_send_to_cashier({$puserid})"; $query = $this->db_onedev->query($sql); if ($query) { $result = array(); $this->sys_ok($result); } else { $this->sys_error_db("payment savetutup rows", $this->db_onedev); exit; } } }