133 lines
4.0 KiB
PHP
133 lines
4.0 KiB
PHP
<?php
|
|
|
|
class Bank extends MY_Controller
|
|
{
|
|
var $db_smartone;
|
|
public function index()
|
|
{
|
|
echo "Bank API";
|
|
}
|
|
|
|
public function __construct()
|
|
{
|
|
parent::__construct();
|
|
$this->db_smartone = $this->load->database("onedev", true);
|
|
}
|
|
|
|
|
|
public function search()
|
|
{
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$prm = $this->sys_input;
|
|
|
|
if (isset($prm['card']))
|
|
{
|
|
$sql = "SELECT Nat_BankID, Nat_BankName
|
|
FROM nat_bank WHERE Nat_BankIsCard = 'Y' AND Nat_BankIsActive = 'Y' ORDER BY Nat_BankName ASC";
|
|
$query = $this->db_smartone->query($sql);
|
|
}
|
|
else if (isset($prm['edc']))
|
|
{
|
|
$sql = "SELECT Nat_BankID, Nat_BankName
|
|
FROM nat_bank WHERE Nat_BankIsEDC = 'Y' AND Nat_BankIsActive = 'Y' ORDER BY Nat_BankName ASC";
|
|
$query = $this->db_smartone->query($sql);
|
|
}
|
|
else
|
|
{
|
|
$sql = "SELECT Nat_BankID, Nat_BankName
|
|
FROM nat_bank WHERE Nat_BankIsActive = 'Y' ORDER BY Nat_BankName ASC";
|
|
$query = $this->db_smartone->query($sql);
|
|
}
|
|
|
|
// $sql = "select Nat_BankID, Nat_BankName
|
|
// from nat_bank
|
|
// where Nat_BankIsActive = 'Y'
|
|
// ORDER BY Nat_BankName";
|
|
$query = $this->db_smartone->query($sql);
|
|
|
|
if ($query) {
|
|
$rows = $query->result_array();
|
|
|
|
$result = array("total" => 0, "records" => $rows, "total_display" => sizeof($rows));
|
|
$this->sys_ok($result);
|
|
}
|
|
else {
|
|
$this->sys_error_db("BANK rows",$this->db_smartone);
|
|
exit;
|
|
}
|
|
}
|
|
|
|
public function search_account()
|
|
{
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$prm = $this->sys_input;
|
|
$EDC = 'X';
|
|
|
|
if ($prm['edc'] == 'Y') {
|
|
$EDC = 'N';
|
|
} else if ($prm['edc'] == 'N') {
|
|
$EDC = 'Y';
|
|
}
|
|
|
|
$sql = "SELECT M_BankAccountID, CONCAT(Nat_BankCode, ' no ', M_BankAccountNo) M_BankAccountNo
|
|
FROM nat_bank
|
|
JOIN m_bank_account ON M_BankAccountNat_BankID = Nat_BankID AND M_BankAccountIsActive = 'Y'
|
|
WHERE Nat_BankIsActive = 'Y'
|
|
AND Nat_BankIsEDC <> ?
|
|
ORDER BY Nat_BankName";
|
|
$query = $this->db_smartone->query($sql, $EDC);
|
|
|
|
if ($query) {
|
|
$rows = $query->result_array();
|
|
|
|
$result = array("total" => 0, "records" => $rows, "total_display" => sizeof($rows));
|
|
$this->sys_ok($result);
|
|
}
|
|
else {
|
|
$this->sys_error_db("BANK rows",$this->db_smartone);
|
|
exit;
|
|
}
|
|
}
|
|
|
|
public function search_account_err()
|
|
{
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$prm = $this->sys_input;
|
|
$EDC = 'X';
|
|
|
|
if ($prm['edc'] == 'Y') {
|
|
$EDC = 'N';
|
|
} else if ($prm['edc'] == 'N') {
|
|
$EDC = 'Y';
|
|
}
|
|
|
|
$sql = "SELECT M_BankAccountID, CONCAT(Nat_BankCode, ' no ', M_BankAccountNo) M_BankAccountNo
|
|
FROM nat_bank
|
|
JOIN m_bank_account ON M_BankAccountNat_BankID = Nat_BankID AND M_BankAccountIsActive = 'Y'
|
|
WHERE Nat_BankIsActive = 'Y'
|
|
AND Nat_BankIsED <> ?
|
|
ORDER BY Nat_BankName";
|
|
$query = $this->db_smartone->query($sql, $EDC);
|
|
|
|
if ($query) {
|
|
$rows = $query->result_array();
|
|
|
|
$result = array("total" => 0, "records" => $rows, "total_display" => sizeof($rows));
|
|
$this->sys_ok($result);
|
|
}
|
|
else {
|
|
$this->sys_error_db("BANK rows",$this->db_smartone);
|
|
exit;
|
|
}
|
|
}
|
|
}
|