db_onedev = $this->load->database("onedev", true); } function lookuplogkiri(){ try { //# cek token valid if (! $this->isLogin) { $this->sys_error("Invalid Token"); exit; } $prm = $this->sys_input; $pgbank = $prm['branch']; $all = $prm['all']; $limit = ''; if($all == 'N'){ $limit = ' LIMIT 10'; } $number_limit = 10; $number_offset = ($prm['current_page'] - 1) * $number_limit ; $sql = "select COUNT(*) as total from pg_bank JOIN m_bank_account ON M_BankAccountID = pgBankM_BankAccountID JOIN nat_bank ON Nat_BankID = M_BankAccountNat_BankID JOIN m_paymenttype ON M_PaymentTypeID = pgBankM_PaymentTypeID WHERE (M_BankAccountNo LIKE CONCAT('%','{$pgbank}','%') OR Nat_BankName LIKE CONCAT('%','{$pgbank}','%')) AND pgBankIsActive = 'Y'"; // $total = $this->db_onedev->query($sql,$sql_param)->row()->total; $query = $this->db_onedev->query($sql); // echo $this->db_onedev->last_query(); $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("pg_bank count", $this->db_onedev); exit; } $sql = "select pgBankID as id, M_BankAccountID, CONCAT(Nat_BankName,' [',M_BankAccountNo,'] ') M_BankAccountNo, Nat_BankName, M_PaymentTypeID, M_PaymentTypeName, pg_bank.* from pg_bank JOIN m_bank_account ON M_BankAccountID = pgBankM_BankAccountID JOIN nat_bank ON Nat_BankID = M_BankAccountNat_BankID JOIN m_paymenttype ON M_PaymentTypeID = pgBankM_PaymentTypeID WHERE (M_BankAccountNo LIKE CONCAT('%','{$pgbank}','%') OR Nat_BankName LIKE CONCAT('%','{$pgbank}','%')) AND pgBankIsActive = 'Y' GROUP BY pgBankID ORDER BY Nat_BankName ASC limit $number_limit offset $number_offset"; $sql_param = array($search); $query = $this->db_onedev->query($sql); //echo $this->db_onedev->last_query(); if ($query) { $rows = $query->result_array(); } else { $this->sys_error_db("pg_bank select"); exit; } $result = array ("total" => $tot_page, "total_filter"=>count($rows),"records" => $rows); $this->sys_ok($result); } catch(Exception $exc) { $message = $exc->getMessage(); $this->sys_error($message); } } function lookupkanan(){ try { //# cek token valid if (! $this->isLogin) { $this->sys_error("Invalid Token"); exit; } $prm = $this->sys_input; $pgbank = $prm['branch']; $all = $prm['all']; $limit = ''; if($all == 'N'){ $limit = ' LIMIT 10'; } $number_limit = 10; $number_offset = ($prm['current_page'] - 1) * $number_limit ; $sql = "select COUNT(*) as total from pg_bank JOIN m_bank_account ON M_BankAccountID = pgBankM_BankAccountID JOIN nat_bank ON Nat_BankID = M_BankAccountNat_BankID JOIN m_paymenttype ON M_PaymentTypeID = pgBankM_PaymentTypeID WHERE (M_BankAccountNo LIKE CONCAT('%','{$pgbank}','%') OR Nat_BankName LIKE CONCAT('%','{$pgbank}','%')) AND pgBankIsActive = 'Y'"; // $total = $this->db_onedev->query($sql,$sql_param)->row()->total; $query = $this->db_onedev->query($sql); // echo $this->db_onedev->last_query(); $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("pg_bank count", $this->db_onedev); exit; } $sql = "select pgBankID as id, M_BankAccountID, CONCAT(Nat_BankName,' [',M_BankAccountNo,'] ') M_BankAccountNo, Nat_BankName, M_PaymentTypeID, M_PaymentTypeName, pg_bank.* from pg_bank JOIN m_bank_account ON M_BankAccountID = pgBankM_BankAccountID JOIN nat_bank ON Nat_BankID = M_BankAccountNat_BankID JOIN m_paymenttype ON M_PaymentTypeID = pgBankM_PaymentTypeID WHERE (M_BankAccountNo LIKE CONCAT('%','{$pgbank}','%') OR Nat_BankName LIKE CONCAT('%','{$pgbank}','%')) AND pgBankIsActive = 'Y' GROUP BY pgBankID ORDER BY Nat_BankName ASC limit $number_limit offset $number_offset"; $sql_param = array($search); $query = $this->db_onedev->query($sql); //echo $this->db_onedev->last_query(); if ($query) { $rows = $query->result_array(); } else { $this->sys_error_db("pg_bank select"); exit; } $result = array ("total" => $tot_page, "total_filter"=>count($rows),"records" => $rows); $this->sys_ok($result); } catch(Exception $exc) { $message = $exc->getMessage(); $this->sys_error($message); } } }