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); echo $this->db_onedev->last_query(); if ($query) { $result = array(); $this->sys_ok($result); } else { $this->sys_error_db("payment save rows", $this->db_onedev); exit; } } public function search_test() { $prm = $this->sys_input; $search = '%'.$prm['search'].'%'; $max_rst = 12; // QUERY TOTAL $sql = "select count(DISTINCT Nat_TestID) total from nat_test where Nat_TestIsActive = 'Y' and Nat_TestName LIKE ? order by Nat_TestName ASC"; $query = $this->db_onedev->query($sql, $search); if ($query) { $tot_count = $query->result_array()[0]["total"]; } else { $this->sys_error_db("price test count", $this->db_onedev); exit; } $sql = "select Nat_TestID, CONCAT(Nat_TestName, ' | ', Nat_TestCode) as Nat_TestName from nat_test where Nat_TestIsActive = 'Y' and Nat_TestName LIKE ? group by nat_testid order by Nat_TestName ASC limit 0, {$max_rst}"; $query = $this->db_onedev->query($sql, $search); if ($query) { $rows = $query->result_array(); foreach ($rows as $k => $v) $rows[$k]['mou'] = json_decode($v['mou']); $result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows), "q" => $this->db_onedev->last_query()); $this->sys_ok($result); } else { $this->sys_error_db("price test rows", $this->db_onedev); exit; } } public function search_mou() { $prm = $this->sys_input; $max_rst = 12; $search = '%' . $prm["search"] . '%'; $test = $prm["test_id"]; // QUERY TOTAL $sql = "select count(*) total from m_mou where M_MouIsActive = 'Y' and M_MouNat_TestID = ? and M_MouName LIKE ? order by M_MouName ASC"; $query = $this->db_onedev->query($sql, $test, $search); if ($query) { $tot_count = $query->result_array()[0]["total"]; } else { $this->sys_error_db("price mou count", $this->db_onedev); exit; } $sql = "select M_MouID, M_MouName, M_MouStartDate, M_MouEndDate from m_mou where M_MouIsActive = 'Y' and M_MouNat_TestID = ? and M_MouName LIKE ? order by M_MouName ASC limit 0, {$max_rst}"; $query = $this->db_onedev->query($sql, $test, $search); if ($query) { $rows = $query->result_array(); $result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows), "q" => $this->db_onedev->last_query()); $this->sys_ok($result); } else { $this->sys_error_db("price mou 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; } } }