step 1 : download one api pettycash
This commit is contained in:
111
pettycash/Report.php
Normal file
111
pettycash/Report.php
Normal file
@@ -0,0 +1,111 @@
|
||||
<?php
|
||||
|
||||
class History extends MY_Controller
|
||||
{
|
||||
var $db_onedev;
|
||||
public function index()
|
||||
{
|
||||
echo "BRANCH API";
|
||||
}
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_onedev = $this->load->database("onedev", true);
|
||||
}
|
||||
function list_total(){
|
||||
try {
|
||||
//# cek token valid
|
||||
/* if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
*/
|
||||
$prm = $this->sys_input;
|
||||
$startdate = $prm['startdate'];
|
||||
$enddate = $prm['enddate'];
|
||||
$kategoriid = $prm['kategoriid'];
|
||||
$companyid = $prm['companyid'];
|
||||
|
||||
$debit = 'Rp.';
|
||||
$debit_rows = 0 ;
|
||||
IF($kategoriid !== 0){
|
||||
$sql_debit = "SELECT SUM(T_TransactionAmount) as total_debit
|
||||
FROM t_transaction WHERE T_TransactionType = 'DEBIT'
|
||||
AND T_TransactionIsActive = 'Y'
|
||||
AND T_TransactionM_CompanyID = $companyid
|
||||
AND T_TransactionDate BETWEEN '{$startdate}' AND '{$enddate}'
|
||||
AND T_TransactionM_CategoryID = $kategoriid";
|
||||
$query_debit = $this->db_onedev->query($sql_debit);
|
||||
//echo $this->db_onedev->last_query();
|
||||
if ($query_debit) {
|
||||
$debit_rows = $query_debit->row()->total_debit;
|
||||
} else {
|
||||
$this->sys_error_db("Debit select");
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$total = 'Rp '.number_format($debit_rows,2,',','.');
|
||||
|
||||
$result = array("total_all"=>$total);
|
||||
$this->sys_ok($result);
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
function list_transaction(){
|
||||
try {
|
||||
//# cek token valid
|
||||
/* if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
*/
|
||||
$prm = $this->sys_input;
|
||||
$startdate = $prm['startdate'];
|
||||
$enddate = $prm['enddate'];
|
||||
$kategoriid = $prm['kategoriid'];
|
||||
$companyid = $prm['companyid'];
|
||||
$sql = "SELECT T_TransactionID as id,
|
||||
DATE_FORMAT(T_TransactionDate,'%d-%m-%Y') as tanggaltransaksi,
|
||||
T_TransactionType as tipe,
|
||||
IFNULL(M_CategoryID,0) as kategoriid,
|
||||
IFNULL(M_CategoryName,'Saldo') as kategoriname,
|
||||
T_TransactionNote as note,
|
||||
CONCAT(REPLACE(CONCAT('Rp ',format(T_TransactionAmount,0)),',','.'),',00') as amount,
|
||||
T_TransactionSender as sender,
|
||||
T_TransactionImg as imgurl,
|
||||
T_TransactionIsConfirm as isconfirm,
|
||||
IFNULL(DATE_FORMAT(T_TransactionConfirmDate,'%d-%m-%Y'),'-') as tanggalconfirm,
|
||||
a.M_UserUsername as usertransaksi,
|
||||
IFNULL(b.M_UserUsername,'') as userconfirm,
|
||||
IFNULL(DATE_FORMAT(T_TransactionCreated,'%d-%m-%Y %H:%i:%s'),'-') as tanggalcreated
|
||||
|
||||
FROM t_transaction
|
||||
LEFT JOIN m_user a ON a.M_UserID = T_TransactionUserID
|
||||
LEFT JOIN m_user b ON b.M_UserID = T_TransactionConfirmUserID
|
||||
LEFT JOIN m_category ON M_CategoryID = T_TransactionM_CategoryID
|
||||
WHERE T_TransactionIsActive = 'Y'
|
||||
AND T_TransactionM_CompanyID = $companyid
|
||||
AND T_TransactionDate BETWEEN '{$startdate}' AND '{$enddate}'
|
||||
AND ($kategoriid = 0 OR($kategoriid > 0 AND T_TransactionM_CategoryID = $kategoriid))
|
||||
ORDER BY T_TransactionID DESC";
|
||||
$query = $this->db_onedev->query($sql);
|
||||
//echo $this->db_onedev->last_query();
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("Transaksi select");
|
||||
exit;
|
||||
}
|
||||
$this->sys_ok($rows);
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user