1321 lines
54 KiB
PHP
1321 lines
54 KiB
PHP
<?php
|
|
class Billissuepusat extends MY_Controller
|
|
{
|
|
var $db_onedev;
|
|
public function index()
|
|
{
|
|
echo "Register API";
|
|
}
|
|
|
|
public function __construct()
|
|
{
|
|
parent::__construct();
|
|
$this->db_onedev = $this->load->database("onedev", true);
|
|
}
|
|
|
|
public function search()
|
|
|
|
{
|
|
$prm = $this->sys_input;
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$norm = $prm["snorm"];
|
|
$nama = $prm["nama"];
|
|
$status = $prm["status"];
|
|
|
|
$sql_where = "WHERE F_BillIssuePusatIsActive = 'Y' AND F_BillIssuePusatIsLunas = '{$status}'";
|
|
$sql_param = array();
|
|
if ($nama != "") {
|
|
if ($sql_where != "") {
|
|
$sql_where .=" and ";
|
|
}
|
|
$sql_where .= " CONCAT(M_CompanyName, ' [',M_CompanyNumber,']') like ? ";
|
|
$sql_param[] = "%$nama%";
|
|
}
|
|
if ($norm != "") {
|
|
if ($sql_where != "") {
|
|
$sql_where .=" and ";
|
|
}
|
|
$sql_where .= "F_BillIssuePusatRefNumber like ? ";
|
|
$sql_param[] = "%$norm%";
|
|
}
|
|
|
|
|
|
$sql = " SELECT count(*) as total
|
|
FROM f_bill_issue_pusat
|
|
left join m_company on F_BillIssuePusatM_CompanyID = M_CompanyID
|
|
LEFT JOIN m_mou ON F_BillIssuePusatM_MouID = M_MouID
|
|
$sql_where
|
|
";
|
|
$query = $this->db_onedev->query($sql, $sql_param);
|
|
//echo $this->db_onedev->last_query();
|
|
$tot_count = 0;
|
|
if ($query) {
|
|
$tot_count = $query->result_array()[0]["total"];
|
|
} else {
|
|
$this->sys_error_db("f_bill count", $this->db_onedev);
|
|
exit;
|
|
}
|
|
|
|
$sql = "SELECT
|
|
f_bill_issue_pusat.*,
|
|
M_MouID,
|
|
M_MouName,
|
|
F_BillIssuePusatAgingDay,
|
|
DATE_FORMAT(F_BillIssuePusatDueDate,'%d-%m-%Y') as F_BillDueDate ,
|
|
DATE_FORMAT(F_BillIssuePusatDueDate,'%Y-%m-%d') as sdate,
|
|
DATE_FORMAT(F_BillIssuePusatCreated,'%d-%m-%Y') as F_BillCreated,
|
|
DATE_FORMAT(F_BillIssuePusatReceiveDate,'%d-%m-%Y') as penerimaan,
|
|
M_CompanyID,
|
|
CONCAT(M_CompanyName, ' [',M_CompanyNumber,']') as M_CompanyName,
|
|
IF(F_BillIssuePusatIsAllMou = 'Y', 'Semua',CONCAT(M_MouName, ' | Exp: ', DATE_FORMAT(M_MouEndDate,'%d-%m-%Y'))) as descmou,
|
|
CONCAT(M_MouName, ' | Exp: ', DATE_FORMAT(M_MouEndDate,'%d-%m-%Y')) as M_MouDesc,
|
|
M_MouAgingDay,
|
|
DATE_FORMAT(F_BillIssuePusatReceiveDate,'%d-%m-%Y %H:%i') as F_BillIssuePusatReceiveDate,
|
|
DATE_FORMAT(F_BillIssuePusatReceiveDate,'%d-%m-%Y %H:%i') as receive_date,
|
|
DATE_FORMAT(F_BillIssuePusatSendDate,'%d-%m-%Y %H:%i') as send_date,
|
|
M_BankAccountID,
|
|
CONCAT(Nat_BankName, ' [ ',M_BankAccountNo,' | ',IFNULL(M_BankAccountName,''),' ]') as M_BankAccountName
|
|
|
|
FROM f_bill_issue_pusat
|
|
left join m_company on F_BillIssuePusatM_CompanyID = M_CompanyID
|
|
LEFT JOIN m_mou ON F_BillIssuePusatM_MouID = M_MouID
|
|
LEFT JOIN m_bank_account ON M_BankAccountID = F_BillIssuePusatM_BankAccountID
|
|
LEFT join nat_bank on Nat_BankID = M_BankAccountNat_BankID
|
|
$sql_where
|
|
ORDER BY F_BillIssuePusatID DESC
|
|
limit 0,$tot_count ";
|
|
|
|
$query = $this->db_onedev->query($sql, $sql_param);
|
|
|
|
$rows = $query->result_array();
|
|
if($rows){
|
|
foreach($rows as $k => $v){
|
|
if($v['F_BillIssuePusatImg']){
|
|
$rows[$k]['F_BillIssuePusatImg'] = "/one-media/one-photo/" . $v['F_BillIssuePusatImg']. "?d=" . date("YmdHis");
|
|
}
|
|
if($v['F_BillIssuePusatImgSend']){
|
|
$rows[$k]['F_BillIssuePusatImgSend'] = "/one-media/one-photo/" . $v['F_BillIssuePusatImgSend']. "?d=" . date("YmdHis");
|
|
}
|
|
|
|
$x = $this->db_onedev->query("
|
|
select count(*) as tot
|
|
FROM f_bill_issue_pusat_detail
|
|
where F_BillIssuePusatDetailF_BillIssuePusatID = '{$v['F_BillIssuePusatID']}'")->row();
|
|
if($x->tot == 0 ) {
|
|
$mouID = $v['F_BillIssuePusatM_MouID'];
|
|
$rows[$k]['haveDetail'] = "N";
|
|
$rows[$k]['startdate'] = "";
|
|
} else {
|
|
$rows[$k]['haveDetail'] = "Y";
|
|
$rows[$k]['startdate'] = "";
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
$result = array("total" => $tot_count, "records" => $rows, "sql"=> $this->db_onedev->last_query());
|
|
$this->sys_ok($result);
|
|
exit;
|
|
|
|
}
|
|
function searchbank(){
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$prm = $this->sys_input;
|
|
|
|
$max_rst = 12;
|
|
$tot_count =0;
|
|
|
|
$q = [
|
|
'search' => '%'
|
|
];
|
|
|
|
if ($prm['search'] != '')
|
|
{
|
|
$q['search'] = "%{$prm['search']}%";
|
|
}
|
|
|
|
// QUERY TOTAL
|
|
$sql = "SELECT count(*) as total
|
|
FROM m_bank_account
|
|
join nat_bank on Nat_BankID = M_BankAccountNat_BankID
|
|
WHERE
|
|
CONCAT(Nat_BankName, ' [ ',M_BankAccountNo,' | ',IFNULL(M_BankAccountName,''),' ]') like ?
|
|
AND M_BankAccountIsActive = 'Y'";
|
|
$query = $this->db_onedev->query($sql,$q['search']);
|
|
//echo $query;
|
|
if ($query) {
|
|
$tot_count = $query->result_array()[0]["total"];
|
|
}
|
|
else {
|
|
$this->sys_error_db("m_bank_account count",$this->db_onedev);
|
|
exit;
|
|
}
|
|
|
|
$sql = "
|
|
SELECT *, CONCAT(Nat_BankName, ' [ ',M_BankAccountNo,' | ',IFNULL(M_BankAccountName,''),' ]') as M_BankAccountName
|
|
FROM m_bank_account
|
|
join nat_bank on Nat_BankID = M_BankAccountNat_BankID
|
|
WHERE
|
|
CONCAT(Nat_BankName, ' [ ',M_BankAccountNo,' | ',IFNULL(M_BankAccountName,''),' ]') like ?
|
|
AND M_BankAccountIsActive = 'Y'
|
|
ORDER BY M_BankAccountIsDefault desc, Nat_BankName asc
|
|
";
|
|
$query = $this->db_onedev->query($sql, array($q['search']));
|
|
|
|
if ($query) {
|
|
$rows = $query->result_array();
|
|
//echo $this->db_onedev->last_query();
|
|
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows));
|
|
$this->sys_ok($result);
|
|
}
|
|
else {
|
|
$this->sys_error_db("m_bank_account rows",$this->db_onedev);
|
|
exit;
|
|
}
|
|
}
|
|
function searchcompany(){
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$prm = $this->sys_input;
|
|
|
|
$max_rst = 12;
|
|
$tot_count =0;
|
|
|
|
$q = [
|
|
'search' => '%'
|
|
];
|
|
|
|
if ($prm['search'] != '')
|
|
{
|
|
$q['search'] = "%{$prm['search']}%";
|
|
}
|
|
|
|
// QUERY TOTAL
|
|
$sql = "SELECT count(*) as total
|
|
FROM m_company
|
|
WHERE
|
|
CONCAT(M_CompanyName, ' [',M_CompanyNumber,']') like ?
|
|
AND M_CompanyIsActive = 'Y'";
|
|
$query = $this->db_onedev->query($sql,$q['search']);
|
|
//echo $query;
|
|
if ($query) {
|
|
$tot_count = $query->result_array()[0]["total"];
|
|
}
|
|
else {
|
|
$this->sys_error_db("m_company count",$this->db_onedev);
|
|
exit;
|
|
}
|
|
|
|
$sql = "
|
|
SELECT *, CONCAT(M_CompanyName, ' [',M_CompanyNumber,']') as M_CompanyName
|
|
FROM m_company
|
|
WHERE
|
|
CONCAT(M_CompanyName, ' [',M_CompanyNumber,']') like ?
|
|
AND M_CompanyIsActive = 'Y'
|
|
ORDER BY M_CompanyName DESC
|
|
";
|
|
$query = $this->db_onedev->query($sql, array($q['search']));
|
|
|
|
if ($query) {
|
|
$rows = $query->result_array();
|
|
//echo $this->db_onedev->last_query();
|
|
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows));
|
|
$this->sys_ok($result);
|
|
}
|
|
else {
|
|
$this->sys_error_db("m_company rows",$this->db_onedev);
|
|
exit;
|
|
}
|
|
}
|
|
function getmou(){
|
|
$prm = $this->sys_input;
|
|
$bquery = "SELECT M_BranchID as branchid FROM m_branch WHERE M_BranchIsActive = 'Y' AND M_BranchIsDefault = 'Y'";
|
|
$branchid = $this->db_onedev->query($bquery)->row()->branchid;
|
|
$query ="SELECT M_MouID,
|
|
M_MouName,
|
|
CONCAT(M_MouName, ' | Exp: ', DATE_FORMAT(M_MouEndDate,'%d-%m-%Y'), ' | ' , M_MouAgingDay) as M_MouDesc,
|
|
M_MouAgingDay,
|
|
M_MouPicBillName,
|
|
M_MouPicBillHandphone,
|
|
M_MouPicBillEmail,
|
|
CONCAT(M_MouPicBillName,' , ', M_MouFinanceName) as M_MouFinanceName,
|
|
CONCAT(M_MouPicBillHandphone,' , ', M_MouFinanceHandphone) as M_MouFinanceHandphone,
|
|
CONCAT(M_MouPicBillEmail,' , ', M_MouFinanceEmail) as M_MouFinanceEmail
|
|
FROM m_mou
|
|
WHERE
|
|
M_MouIsActive <> 'N' AND M_MouM_CompanyID = ?
|
|
AND M_MouIsAgingOnHold = 'Y' AND M_MouAgingDay > 0
|
|
AND M_MouM_BillTypeID = 2
|
|
AND M_MouM_BranchBillID = $branchid
|
|
";
|
|
//echo $query;
|
|
$rows = $this->db_onedev->query($query,array($prm['id']))->result_array();
|
|
|
|
$result = array(
|
|
"total" => count($rows) ,
|
|
"records" => $rows,
|
|
);
|
|
$this->sys_ok($result);
|
|
exit;
|
|
}
|
|
function listmou(){
|
|
$bquery = "SELECT M_BranchID as branchid FROM m_branch WHERE M_BranchIsActive = 'Y' AND M_BranchIsDefault = 'Y'";
|
|
$branchid = $this->db_onedev->query($bquery)->row()->branchid;
|
|
$prm = $this->sys_input;
|
|
$query ="SELECT M_MouID,
|
|
M_MouName,
|
|
CONCAT(M_MouName, ' | Exp: ', DATE_FORMAT(M_MouEndDate,'%d-%m-%Y')) as M_MouDesc,
|
|
M_MouAgingDay,
|
|
M_MouPicBillName,
|
|
M_MouPicBillHandphone,
|
|
M_MouPicBillEmail,
|
|
CONCAT(M_MouPicBillName,' , ', M_MouFinanceName) as M_MouFinanceName,
|
|
CONCAT(M_MouPicBillHandphone,' , ', M_MouFinanceHandphone) as M_MouFinanceHandphone,
|
|
CONCAT(M_MouPicBillEmail,' , ', M_MouFinanceEmail) as M_MouFinanceEmail,
|
|
DATE_FORMAT(DATE_ADD(date(now()), INTERVAL M_MouAgingDay DAY),'%d-%m-%Y') as duedateina,
|
|
DATE_FORMAT(DATE_ADD(date(now()), INTERVAL M_MouAgingDay DAY),'%Y-%m-%d') as duedate
|
|
FROM m_mou
|
|
WHERE
|
|
M_MouIsActive <> 'N' AND M_MouM_CompanyID = ?
|
|
AND M_MouIsAgingOnHold = 'Y' AND M_MouAgingDay > 0
|
|
AND M_MouM_BillTypeID = 2
|
|
AND M_MouM_BranchBillID = $branchid
|
|
";
|
|
//echo $query;
|
|
$rows = $this->db_onedev->query($query,array($prm['id']))->result_array();
|
|
|
|
$result = array(
|
|
"total" => count($rows) ,
|
|
"records" => $rows,
|
|
);
|
|
$this->sys_ok($result);
|
|
exit;
|
|
}
|
|
function getnomor(){
|
|
$prm = $this->sys_input;
|
|
$query ="SELECT M_No_FormRev
|
|
FROM m_no_form
|
|
WHERE
|
|
M_No_FormIsActive = 'Y' AND M_No_FormName = 'BILL'";
|
|
//echo $query;
|
|
$rows = $this->db_onedev->query($query)->result_array()[0]["M_No_FormRev"];
|
|
|
|
$result = array(
|
|
"total" => count($rows) ,
|
|
"records" => $rows,
|
|
);
|
|
$this->sys_ok($result);
|
|
exit;
|
|
}
|
|
function getsexreg(){
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$rows = [];
|
|
$query =" SELECT *
|
|
FROM m_sex
|
|
WHERE
|
|
M_SexIsActive = 'Y'
|
|
";
|
|
//echo $query;
|
|
$rows['sexes'] = $this->db_onedev->query($query)->result_array();
|
|
|
|
$query =" SELECT *, CONCAT(R_ReportCode,' | ',R_ReportName) as rname
|
|
FROM r_report
|
|
WHERE
|
|
R_ReportCode IN('KEU09','KEU10','KEU11','KEU12','KEU13','KEU14','KEU15','KEU16','KEU17') AND `R_ReportIsActive` = 'Y'
|
|
ORDER BY R_ReportCode ASC
|
|
";
|
|
//echo $query;
|
|
$rows['reports'] = $this->db_onedev->query($query)->result_array();
|
|
|
|
$query ="SELECT '/birt/run?__report=report/one/fo/rpt_tagihan_002.rptdesign' as t_url, 'PENAGIHAN (SEMUA CABANG)' as t_name
|
|
UNION SELECT '/birt/run?__report=report/one/fo/rpt_tagihan_002_cabang.rptdesign' as t_url, 'PENAGIHAN (GROUP CABANG)' as t_name
|
|
UNION SELECT '/birt/run?__report=report/one/fo/rpt_bill_issue_inv_pusat.rptdesign' as t_url, 'LAMPIRAN TAGIHAN (PERIODE BULAN)' as t_name
|
|
UNION SELECT '/birt/run?__report=report/one/fo/rpt_bill_issue_inv_tanggal_pusat.rptdesign' as t_url, 'LAMPIRAN TAGIHAN (PERIODE TANGGAL)' as t_name
|
|
UNION SELECT '/birt/run?__report=report/one/fo/rpt_bill_issue_kwitansi_pusat.rptdesign' as t_url, 'KWITANSI (PERIODE BULAN)' as t_name
|
|
UNION SELECT '/birt/run?__report=report/one/fo/rpt_bill_issue_kwitansi_tanggal_pusat.rptdesign' as t_url, 'KWITANSI (PERIODE TANGGAL)' as t_name
|
|
UNION SELECT '/birt/run?__report=report/one/fo/rpt_bill_issue_tandaterima_pusat.rptdesign' as t_url, 'TANDA TERIMA (PERIODE BULAN)' as t_name
|
|
UNION SELECT '/birt/run?__report=report/one/fo/rpt_bill_issue_tandaterima_tanggal_pusat.rptdesign' as t_url, 'TANDA TERIMA (PERIODE TANGGAL)' as t_name
|
|
";
|
|
//echo $query;
|
|
$rows['cetaks'] = $this->db_onedev->query($query)->result_array();
|
|
|
|
|
|
$result = array(
|
|
"total" => count($rows) ,
|
|
"records" => $rows,
|
|
);
|
|
$this->sys_ok($result);
|
|
exit;
|
|
}
|
|
|
|
function save(){
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$prm = $this->sys_input;
|
|
$pdob = date('Y-m-d',strtotime($prm['M_PatientDOB']));
|
|
$query ="UPDATE m_patient SET
|
|
M_PatientM_TitleID = '{$prm['M_PatientM_TitleID']}',
|
|
M_PatientName = '{$prm['M_PatientName']}',
|
|
M_PatientDOB = '{$pdob}',
|
|
M_PatientM_SexID = '{$prm['M_PatientM_SexID']}',
|
|
M_PatientM_ReligionID = '{$prm['M_PatientM_ReligionID']}',
|
|
M_PatientEmail = '{$prm['M_PatientEmail']}',
|
|
M_PatientHP = '{$prm['M_PatientHP']}',
|
|
M_PatientPhone = '{$prm['M_PatientPhone']}',
|
|
M_PatientM_IdTypeID = '{$prm['M_PatientM_IdTypeID']}',
|
|
M_PatientIDNumber = '{$prm['M_PatientIDNumber']}',
|
|
M_PatientNote = '{$prm['M_PatientNote']}'
|
|
WHERE
|
|
M_PatientID = '{$prm['M_PatientID']}'
|
|
";
|
|
//echo $query;
|
|
$rows = $this->db_onedev->query($query);
|
|
|
|
$result = array(
|
|
"total" => 1 ,
|
|
"records" => array('status'=>'OK')
|
|
);
|
|
$this->sys_ok($result);
|
|
exit;
|
|
}
|
|
|
|
function newreceivereference(){
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$prm = $this->sys_input;
|
|
$pdate = date('Y-m-d',strtotime($prm['sdate']));
|
|
$userid = $this->sys_user["M_UserID"];
|
|
|
|
$bquery = "SELECT M_BranchCode as branchcode FROM m_branch WHERE M_BranchIsActive = 'Y' AND M_BranchIsDefault = 'Y'";
|
|
$branchcode = $this->db_onedev->query($bquery)->row()->branchcode;
|
|
$query = "SELECT COUNT(*) as exist FROM f_bill_issue_pusat WHERE F_BillIssuePusatIsActive = 'Y' AND F_BillIssuePusatRefNumber = '{$prm['noref']}'";
|
|
$exist_name = $this->db_onedev->query($query)->row()->exist;
|
|
if($exist_name == 0){
|
|
$queryissue ="INSERT INTO f_bill_issue_pusat (
|
|
F_BillIssuePusatNumber,
|
|
F_BillIssuePusatDate,
|
|
F_BillIssuePusatPIC,
|
|
F_BillIssuePusatPICHP,
|
|
F_BillIssuePusatPICEmail,
|
|
F_BillIssuePusatM_CompanyID,
|
|
F_BillIssuePusatM_MouID,
|
|
F_BillIssuePusatAgingDay,
|
|
F_BillIssuePusatRefNumber,
|
|
F_BillIssuePusatUserID,
|
|
F_BillIssuePusatM_BankAccountID,
|
|
F_BillIssuePusatIsAllMou,
|
|
F_BillIssuePusatCreated,
|
|
F_BillIssuePusatDueDate,
|
|
F_BillIssuePusatNote
|
|
)
|
|
VALUES(
|
|
CONCAT('{$branchcode}','-',`fn_numbering`('BT')),
|
|
date(now()),
|
|
'{$prm['picname']}',
|
|
'{$prm['pichp']}',
|
|
'{$prm['picemail']}',
|
|
'{$prm['companyid']}',
|
|
'{$prm['mouid']}',
|
|
'{$prm['day']}',
|
|
'{$prm['noref']}',
|
|
'{$userid}',
|
|
'{$prm['bankid']}',
|
|
'{$prm['isallmou']}',
|
|
NOW(),
|
|
'{$pdate}',
|
|
'{$prm['note']}'
|
|
)
|
|
";
|
|
//echo $queryissue;
|
|
$rowsissue = $this->db_onedev->query($queryissue);
|
|
//echo $this->db_onedev->last_query();
|
|
$lastissue_id = $this->db_onedev->insert_id();
|
|
|
|
$querylog ="
|
|
|
|
";
|
|
if ($prm['img'] !== "") {
|
|
$this->uploadnew($prm['img'],$prm['rtanggal'],$last_id,$lastissue_id,$pdate);
|
|
}
|
|
|
|
|
|
$insert_new_log = $this->db_onedev->query($querylog);
|
|
$result = array(
|
|
"total" => 1 ,
|
|
"records" => array('status'=>'OK'),
|
|
"id" => $last_id
|
|
);
|
|
$this->sys_ok($result);
|
|
exit;
|
|
}else{
|
|
$errors = array();
|
|
if($exist_name != 0){
|
|
array_push($errors,array('field'=>'name','msg'=>'Nomor sudah ada yang pakai dong'));
|
|
}
|
|
|
|
$result = array ("total" => -1,"errors" => $errors, "records" => array('status'=>'ERROR'));
|
|
$this->sys_ok($result);
|
|
}
|
|
}
|
|
public function uploadnew($img,$tanggal,$idbill,$idissue,$sdate)
|
|
{
|
|
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$userid = $this->sys_user["M_UserID"];
|
|
$home_dir = "/home/one/project/one/";
|
|
$target_dir = $home_dir . "one-media/one-photo/";
|
|
|
|
$sqlsum = "select F_BillNo as billNo from f_bill
|
|
where F_BillIssuePusatID = $idbill";
|
|
$billNo = $this->db_onedev->query($sqlsum)->row()->billNo;
|
|
|
|
if (!file_exists($target_dir)) {
|
|
mkdir($target_dir, 0755, true);
|
|
}
|
|
$filename = date("YmdHis")."_".$billNo . ".jpg";
|
|
$target_path = $target_dir . $filename;
|
|
$this->base64_to_jpeg($img, $target_path);
|
|
$sql = "UPDATE f_bill_issue_pusat SET F_BillIssuePusatImg = '{$filename}',
|
|
F_BillIssuePusatIsReceive = 'Y',
|
|
F_BillIssuePusatReceiveDate = '{$tanggal}',
|
|
F_BillIssuePusatReceiveUserID = {$userid}
|
|
WHERE F_BillIssuePusatID = {$idissue}";
|
|
//echo $sql;
|
|
$save = $this->db_onedev->query($sql);
|
|
|
|
$sqlbill = "UPDATE f_bill SET F_BillDueDate = '{$sdate}'
|
|
WHERE F_BillIssuePusatID = {$idbill}";
|
|
//echo $sqlbill;
|
|
$savebill = $this->db_onedev->query($sqlbill);
|
|
|
|
$result = array("url" => "http://" . $_SERVER['SERVER_NAME'] . "/one-media/one-photo/" . $filename. "?d=" . date("YmdHis"));
|
|
$this->sys_ok($result);
|
|
exit;
|
|
}
|
|
function editbill(){
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$prm = $this->sys_input;
|
|
$pdate = date('Y-m-d',strtotime($prm['sdate']));
|
|
$userid = $this->sys_user["M_UserID"];
|
|
$query ="UPDATE f_bill_issue_pusat SET
|
|
F_BillIssuePusatM_BankAccountID = '{$prm['bankid']}',
|
|
F_BillIssuePusatUserID = '{$userid}'
|
|
WHERE F_BillIssuePusatID = '{$prm['id']}'
|
|
";
|
|
// echo $query;
|
|
$rows = $this->db_onedev->query($query);
|
|
$last_id = $prm['id'];
|
|
$query ="UPDATE f_bill SET
|
|
F_BillNote = '{$prm['note']}',
|
|
F_BillUserID = '{$userid}'
|
|
WHERE F_BillIssuePusatID = '{$prm['id']}'
|
|
";
|
|
// echo $query;
|
|
$rows = $this->db_onedev->query($query);
|
|
|
|
$querylog ="
|
|
|
|
";
|
|
$insert_new_log = $this->db_onedev->query($querylog);
|
|
$result = array(
|
|
"total" => 1 ,
|
|
"records" => array('status'=>'OK'),
|
|
"id" => $last_id
|
|
);
|
|
$this->sys_ok($result);
|
|
exit;
|
|
}
|
|
function sendorder(){
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$prm = $this->sys_input;
|
|
$userid = $this->sys_user["M_UserID"];
|
|
|
|
$query ="UPDATE t_receivereferenceheader SET
|
|
T_ReceiveReferenceHeaderIsSent = 'Y',
|
|
T_ReceiveReferenceHeaderSentDate = now(),
|
|
T_ReceiveReferenceHeaderUserID = '{$userid}'
|
|
WHERE
|
|
T_ReceiveReferenceHeaderID = '{$prm['T_ReceiveReferenceHeaderID']}'
|
|
";
|
|
//echo $query;
|
|
$rows = $this->db_onedev->query($query);
|
|
|
|
$rows = $this->db_onedev->query($query);
|
|
|
|
$querylog ="INSERT INTO g_receivereferenceheaderstatuslog (
|
|
G_ReceiveReferenceHeaderStatusLogDate,
|
|
G_ReceiveReferenceHeaderStatusLogT_ReceiveReferenceHeaderID,
|
|
G_ReceiveReferenceHeaderStatusLogM_StatusReferenceID,
|
|
G_ReceiveReferenceHeaderStatusLogM_UserID,
|
|
G_ReceiveReferenceHeaderStatusLogUserID,
|
|
G_ReceiveReferenceHeaderStatusLogCreated,
|
|
G_ReceiveReferenceHeaderStatusLogLastUpdated
|
|
)
|
|
VALUES(
|
|
NOW(),
|
|
'{$prm['T_ReceiveReferenceHeaderID']}',
|
|
'2',
|
|
'{$userid}',
|
|
'{$userid}',
|
|
NOW(),
|
|
NOW()
|
|
)";
|
|
//echo $querylog;
|
|
$insert_new_log = $this->db_onedev->query($querylog);
|
|
$result = array(
|
|
"total" => 1 ,
|
|
"records" => array('status'=>'OK')
|
|
);
|
|
$this->sys_ok($result);
|
|
exit;
|
|
}
|
|
function save_patient() {
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$prm = $this->sys_input;
|
|
$sql = "insert into f_bill_issue_pusat_detail(F_BillIssuePusatDetailF_BillIssuePusatID, F_BillIssuePusatDetailM_BranchID,
|
|
F_BillIssuePusatDetailTotal, F_BillIssuePusatDetailUnpaid) values(?,?,?,?)";
|
|
$billID = $prm["billID"];
|
|
// print_r($prm);
|
|
exit;
|
|
foreach($prm["patients"] as $p) {
|
|
$orderID = $p["T_OrderHeaderID"];
|
|
$total = $p["total"];
|
|
$this->db_onedev->query($sql,array($billID, $orderID, $total, $total));
|
|
}
|
|
$result = "Pasien saved";
|
|
$this->sys_ok($result);
|
|
}
|
|
function saveall_tempbill(){
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$prm = $this->sys_input;
|
|
$billid = $prm['billID'];
|
|
$status = $prm['status'];
|
|
$userid = $this->sys_user["M_UserID"];
|
|
foreach($prm['patients'] as $k=>$v){
|
|
$id = $v['Temp_BillPusatID'];
|
|
if($status == 'Y' && $id == '0'){
|
|
|
|
$sql = "insert into temp_bill_pusat(
|
|
Temp_BillPusatF_BillIssuePusatID,
|
|
Temp_BillPusatF_BillID,
|
|
Temp_BillPusatM_BranchID,
|
|
Temp_BillPusatUserID,
|
|
Temp_BillPusatTotal,
|
|
Temp_BillPusatCreated,
|
|
Temp_BillPusatLastUpdated)
|
|
values(?,?,?,?,?,now(),now())";
|
|
$query = $this->db_onedev->query($sql,
|
|
array($billid,
|
|
$v['F_BillID'],
|
|
$v['M_BranchID'],
|
|
$userid,
|
|
$v['total'],)
|
|
);
|
|
if (!$query) {
|
|
$this->sys_error_db("temp_bill_pusat insert",$this->db_onedev);
|
|
exit;
|
|
}
|
|
|
|
}elseif($status == 'N' && $id != '0'){
|
|
$sql = "UPDATE temp_bill_pusat SET
|
|
Temp_BillPusatIsActive = 'N',
|
|
Temp_BillPusatUserID = ?
|
|
WHERE Temp_BillPusatID = ?";
|
|
$query = $this->db_onedev->query($sql,
|
|
array($userid,
|
|
$id
|
|
)
|
|
);
|
|
if (!$query) {
|
|
$this->sys_error_db("temp_bill_pusat update",$this->db_onedev);
|
|
exit;
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
$sqlsum = "select format(sum(IFNULL(Temp_BillPusatTotal,0)),0) sumtot, count(Temp_BillPusatID) as ctot from temp_bill_pusat
|
|
LEFT JOIN f_bill_issue_pusat_detail ON F_BillIssuePusatDetailM_BranchID = Temp_BillPusatM_BranchID AND F_BillIssuePusatDetailIsActive = 'Y'
|
|
LEFT JOIN f_bill_issue_pusat ON F_BillIssuePusatID=F_BillIssuePusatDetailF_BillIssuePusatID AND F_BillIssuePusatIsActive = 'Y'
|
|
where Temp_BillPusatF_BillIssuePusatID=? AND Temp_BillPusatIsActive = 'Y' AND F_BillIssuePusatDetailID is null";
|
|
$rstsum = $this->db_onedev->query($sqlsum,array($billid))->row();
|
|
$sumtotal = $rstsum->sumtot;
|
|
$ctotal = $rstsum->ctot;
|
|
|
|
$result = array ("total" => 1, "ctotal" => $ctotal,"sumtotal" => $sumtotal,"records" => array("xid" => 0));
|
|
$this->sys_ok($result);
|
|
}
|
|
|
|
function save_tempbill(){
|
|
try {
|
|
//# cek token valid
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
|
|
//# ambil parameter input
|
|
$prm = $this->sys_input;
|
|
$id = $prm['id'];
|
|
$companyid = $prm['companyid'];
|
|
$billtitipid = $prm['billtitipid'];
|
|
$billid = $prm['billid'];
|
|
$branchid = $prm['branchid'];
|
|
$status = $prm['checx'];
|
|
$total = $prm['total'];
|
|
$userid = $this->sys_user["M_UserID"];
|
|
|
|
|
|
if($status == 'Y' && $id == '0'){
|
|
$sql = "insert into temp_bill_pusat(
|
|
Temp_BillPusatF_BillIssuePusatID,
|
|
Temp_BillPusatF_BillID,
|
|
Temp_BillPusatM_BranchID,
|
|
Temp_BillPusatUserID,
|
|
Temp_BillPusatTotal,
|
|
Temp_BillPusatCreated,
|
|
Temp_BillPusatLastUpdated)
|
|
values(?,?,?,?,?,now(),now())";
|
|
$query = $this->db_onedev->query($sql,
|
|
array($billid,
|
|
$billtitipid,
|
|
$branchid,
|
|
$userid,
|
|
$total)
|
|
);
|
|
if (!$query) {
|
|
$this->sys_error_db("temp_bill_pusat insert",$this->db_onedev);
|
|
exit;
|
|
}
|
|
$last_id = $this->db_onedev->insert_id();
|
|
$sqlsum = "select format(sum(IFNULL(Temp_BillPusatTotal,0)),0) sumtot, count(Temp_BillPusatID) as ctot from temp_bill_pusat
|
|
LEFT JOIN f_bill_issue_pusat_detail ON F_BillIssuePusatDetailM_BranchID = Temp_BillPusatM_BranchID AND F_BillIssuePusatDetailIsActive = 'Y'
|
|
LEFT JOIN f_bill_issue_pusat ON F_BillIssuePusatID=F_BillIssuePusatDetailF_BillIssuePusatID AND F_BillIssuePusatIsActive = 'Y'
|
|
where Temp_BillPusatF_BillIssuePusatID=? AND Temp_BillPusatIsActive = 'Y' AND F_BillIssuePusatDetailID is null";
|
|
$rstsum = $this->db_onedev->query($sqlsum,array($billid))->row();
|
|
// echo $this->db_onedev->last_query();
|
|
$sumtotal = $rstsum->sumtot;
|
|
$ctotal = $rstsum->ctot;
|
|
|
|
$result = array ("total" => 1, "ctotal" => $ctotal,"sumtotal" => $sumtotal,"records" => array("xid" => 0));
|
|
$this->sys_ok($result);
|
|
|
|
}elseif($status == 'N' && $id != '0'){
|
|
$sql = "UPDATE temp_bill_pusat SET
|
|
Temp_BillPusatIsActive = 'N',
|
|
Temp_BillPusatUserID = ?
|
|
WHERE Temp_BillPusatID = ?";
|
|
$query = $this->db_onedev->query($sql,
|
|
array($userid,
|
|
$id
|
|
)
|
|
);
|
|
if (!$query) {
|
|
$this->sys_error_db("temp_bill_pusat update",$this->db_onedev);
|
|
exit;
|
|
}
|
|
$last_id = $this->db_onedev->insert_id();
|
|
$sqlsum = "select format(sum(IFNULL(Temp_BillPusatTotal,0)),0) sumtot, count(Temp_BillPusatID) as ctot from temp_bill_pusat
|
|
LEFT JOIN f_bill_issue_pusat_detail ON F_BillIssuePusatDetailM_BranchID = Temp_BillPusatM_BranchID AND F_BillIssuePusatDetailIsActive = 'Y'
|
|
LEFT JOIN f_bill_issue_pusat ON F_BillIssuePusatID=F_BillIssuePusatDetailF_BillIssuePusatID AND F_BillIssuePusatIsActive = 'Y'
|
|
where Temp_BillPusatF_BillIssuePusatID=? AND Temp_BillPusatIsActive = 'Y' AND F_BillIssuePusatDetailID is null";
|
|
$rstsum = $this->db_onedev->query($sqlsum,array($billid))->row();
|
|
$sumtotal = $rstsum->sumtot;
|
|
$ctotal = $rstsum->ctot;
|
|
|
|
$result = array ("total" => 1, "ctotal" => $ctotal,"records" => array("xid" => 0));
|
|
$this->sys_ok($result);
|
|
}
|
|
|
|
|
|
|
|
} catch(Exception $exc) {
|
|
$message = $exc->getMessage();
|
|
$this->sys_error($message);
|
|
}
|
|
}
|
|
function getpatient(){
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
|
|
$prm = $this->sys_input;
|
|
$billID = $prm["id"];
|
|
$mouID = $prm["mouid"];
|
|
$companyID = $prm["companyid"];
|
|
$startdate = $prm["startdate"];
|
|
$enddate = $prm["enddate"];
|
|
$search = $prm["search"];
|
|
$sql = "select count(*) tot from f_bill_issue_pusat_detail where F_BillIssuePusatDetailF_BillIssuePusatID=?";
|
|
$rst = $this->db_onedev->query($sql,array($billID))->row();
|
|
|
|
|
|
|
|
if ($rst->tot > 0 ) {
|
|
$sql = "select
|
|
b.M_BranchID,
|
|
b.M_BranchCode,
|
|
b.M_BranchName,
|
|
F_BillID,
|
|
F_BillNo,
|
|
F_BillTotal,
|
|
F_BillTotal as total,
|
|
DATE_FORMAT(F_BillCreated,'%d-%m-%Y') as billdate,
|
|
'xxx' as tests,
|
|
'' as action,
|
|
F_BillIssuePusatDetailID
|
|
FROM f_bill_issue_pusat_detail a
|
|
join m_branch b ON F_BillIssuePusatDetailM_BranchID = b.M_BranchID
|
|
join f_bill_titip c ON c.M_BranchID = F_BillIssuePusatDetailM_BranchID AND F_BillIssuePusatDetailF_BillID = F_BillID
|
|
WHERE
|
|
F_BillIssuePusatDetailIsActive = 'Y' and F_BillIssuePusatDetailF_BillIssuePusatID = '{$billID}'
|
|
GROUP BY F_BillIssuePusatDetailID
|
|
ORDER BY F_BillCreated ASC";
|
|
} else {
|
|
$sql = "SELECT b.M_BranchID,
|
|
b.M_BranchCode,
|
|
b.M_BranchName,
|
|
F_BillID,
|
|
F_BillNo,
|
|
F_BillTotal,
|
|
F_BillTotal as total,
|
|
DATE_FORMAT(F_BillCreated,'%d-%m-%Y') as billdate,
|
|
F_BillIsUsed as isbill,
|
|
F_BillIssuePusatRefNumber,
|
|
IF(Temp_BillPusatID = 0 or Temp_BillPusatID IS NULL,'N','Y') as checx,
|
|
IF(Temp_BillPusatID = 0 or Temp_BillPusatID IS NULL,'false','true') as chex ,
|
|
'' as tes,
|
|
'xxx' as tests,
|
|
'' as action,
|
|
IFNULL(Temp_BillPusatID,0) as Temp_BillPusatID
|
|
FROM f_bill_titip a
|
|
LEFT JOIN temp_bill_pusat ON Temp_BillPusatF_BillIssuePusatID = '{$billID}' AND
|
|
Temp_BillPusatF_BillID = F_BillID AND Temp_BillPusatM_BranchID = a.M_BranchID AND Temp_BillPusatIsActive = 'Y'
|
|
LEFT JOIN f_bill_issue_pusat ON F_BillIssuePusatID = '{$billID}'
|
|
JOIN m_branch b ON a.M_BranchID = b.M_BranchID
|
|
WHERE F_BillIsConfirm = 'Y' AND F_BillIsUsed = 'N' AND F_BillM_CompanyID = '{$companyID}'";
|
|
}
|
|
//echo $sql;
|
|
$qry = $this->db_onedev->query($sql);
|
|
//echo $this->db_onedev->last_query();
|
|
$rows = array();
|
|
if ($qry) {
|
|
$rows = $qry->result_array();
|
|
}
|
|
$sqlsum = "select format(sum(IFNULL(Temp_BillPusatTotal,0)),0) sumtot, count(Temp_BillPusatID) as ctot
|
|
from temp_bill_pusat
|
|
LEFT JOIN f_bill_issue_pusat_detail ON F_BillIssuePusatDetailM_BranchID = Temp_BillPusatM_BranchID
|
|
AND Temp_BillPusatF_BillIssuePusatID = F_BillIssuePusatDetailF_BillIssuePusatID
|
|
AND Temp_BillPusatF_BillID = F_BillIssuePusatDetailF_BillID AND F_BillIssuePusatDetailIsActive = 'Y'
|
|
LEFT JOIN f_bill_issue_pusat ON F_BillIssuePusatID=F_BillIssuePusatDetailF_BillIssuePusatID AND F_BillIssuePusatIsActive = 'Y'
|
|
where Temp_BillPusatF_BillIssuePusatID=? AND Temp_BillPusatIsActive = 'Y' AND F_BillIssuePusatDetailID is null";
|
|
$rstsum = $this->db_onedev->query($sqlsum,array($billID))->row();
|
|
$sumtotal = $rstsum->sumtot;
|
|
$ctotal = $rstsum->ctot;
|
|
$result = array(
|
|
"total" => count($rows) ,
|
|
"records" => $rows,
|
|
"sumtotal" => $sumtotal,
|
|
"ctotal" => $ctotal
|
|
);
|
|
$this->sys_ok($result);
|
|
exit;
|
|
}
|
|
function add_test($orderid){
|
|
$query =" SELECT t_receivereferencetest.*, t_test.*,'Y' as editable, T_ReceiveReferenceTestT_TestID as xid,
|
|
T_ReceiveReferenceTestT_TestPrice as T_PriceAmount,
|
|
T_ReceiveReferenceTestT_TestDisc as T_PriceDisc,
|
|
T_ReceiveReferenceTestT_TestDiscRp as T_PriceDiscRp,
|
|
T_ReceiveReferenceTestT_TestTotal as total
|
|
FROM t_receivereferencetest
|
|
JOIN t_receivereferencepatient ON T_ReceiveReferenceTestT_ReceiveReferencePatientID = T_ReceiveReferencePatientID
|
|
JOIN t_receivereferenceheader ON T_ReceiveReferencePatientT_ReceiveReferenceHeaderID = T_ReceiveReferenceHeaderID
|
|
JOIN t_test ON T_ReceiveReferenceTestT_TestID = T_TestID
|
|
WHERE
|
|
T_ReceiveReferenceTestT_ReceiveReferencePatientID = {$orderid} AND T_ReceiveReferenceTestIsActive = 'Y'
|
|
GROUP BY T_ReceiveReferenceTestID";
|
|
//echo $query;
|
|
$rows = $this->db_onedev->query($query)->result_array();
|
|
if(!$rows)
|
|
$rows = array();
|
|
return $rows;
|
|
}
|
|
|
|
function savenewpatient(){
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$prm = $this->sys_input;
|
|
$billID = $prm['billID'];
|
|
$userid = $this->sys_user["M_UserID"];
|
|
foreach($prm['patients'] as $k=>$v){
|
|
$query = "INSERT INTO f_bill_issue_pusat_detail
|
|
(F_BillIssuePusatDetailF_BillIssuePusatID,
|
|
F_BillIssuePusatDetailF_BillID,
|
|
F_BillIssuePusatDetailM_BranchID,
|
|
F_BillIssuePusatDetailTotal,
|
|
F_BillIssuePusatDetailUnpaid,
|
|
F_BillIssuePusatDetailUserID,
|
|
F_BillIssuePusatDetailCreated,
|
|
F_BillIssuePusatDetailLastUpdated)
|
|
VALUE(
|
|
?,?,?,?,?,?,now(),now()
|
|
)";
|
|
$insert_new_test = $this->db_onedev->query($query,array(
|
|
$billID,
|
|
$v['F_BillID'],
|
|
$v['M_BranchID'],
|
|
$v['total'],
|
|
$v['total'],
|
|
$userid
|
|
));
|
|
// echo $this->db_onedev->last_query();
|
|
$querymou = "UPDATE f_bill_titip SET F_BillIsUsed = 'Y' WHERE M_BranchID = ? AND F_BillID = ?";
|
|
$insert_mou = $this->db_onedev->query($querymou,array(
|
|
$v['M_BranchID'],
|
|
$v['F_BillID']
|
|
));
|
|
|
|
$querytemp = "UPDATE temp_bill_pusat SET Temp_BillPusatIsActive = 'N' WHERE Temp_BillPusatM_BranchID = ? AND Temp_BillPusatF_BillID = ?
|
|
AND Temp_BillPusatF_BillIssuePusatID <> ?";
|
|
$insert_temp = $this->db_onedev->query($querytemp,array(
|
|
$v['M_BranchID'],
|
|
$v['F_BillID'],
|
|
$billID
|
|
));
|
|
|
|
}
|
|
$result = array(
|
|
"total" => 1 ,
|
|
"records" => array('status'=>'OK')
|
|
);
|
|
$this->sys_ok($result);
|
|
exit;
|
|
}
|
|
function savebillmou(){
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$prm = $this->sys_input;
|
|
$billID = $prm['billID'];
|
|
$userid = $this->sys_user["M_UserID"];
|
|
foreach($prm['patients'] as $k=>$v){
|
|
$query = "INSERT INTO f_bill_mou
|
|
(F_BillIssuePusatMouF_BillIssuePusatID,
|
|
F_BillIssuePusatMouM_MouID,
|
|
F_BillIssuePusatMouUserID,
|
|
F_BillIssuePusatMouCreated,
|
|
F_BillIssuePusatMouLastUpdated)
|
|
VALUE(
|
|
?,?,?,?,?,now(),now()
|
|
)";
|
|
$insert_new_test = $this->db_onedev->query($query,array(
|
|
$billID,
|
|
$v['M_MouID'],
|
|
$userid
|
|
));
|
|
|
|
}
|
|
$result = array(
|
|
"total" => 1 ,
|
|
"records" => array('status'=>'OK')
|
|
);
|
|
$this->sys_ok($result);
|
|
exit;
|
|
}
|
|
function saveeditpatient(){
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$prm = $this->sys_input;
|
|
$order_id = $prm['T_ReceiveReferencePatientID'];
|
|
$pdob = date('Y-m-d',strtotime($prm['T_ReceiveReferencePatientDOB']));
|
|
$userid = $this->sys_user["M_UserID"];
|
|
$query ="UPDATE t_receivereferencepatient SET
|
|
T_ReceiveReferencePatientT_ReceiveReferenceHeaderID = '{$prm['T_ReceiveReferencePatientT_ReceiveReferenceHeaderID']}',
|
|
T_ReceiveReferencePatientNoRef = '{$prm['T_ReceiveReferencePatientNoRef']}',
|
|
T_ReceiveReferencePatientName = '{$prm['T_ReceiveReferencePatientName']}',
|
|
T_ReceiveReferencePatientDOB = '{$pdob}',
|
|
T_ReceiveReferencePatientM_SexID = '{$prm['T_ReceiveReferencePatientM_SexID']}',
|
|
T_ReceiveReferencePatientTotal = '{$prm['T_ReceiveReferencePatientTotal']}',
|
|
T_ReceiveReferencePatientDPPercent = '{$prm['T_ReceiveReferencePatientDPPercent']}',
|
|
T_ReceiveReferencePatientDPAmount = '{$prm['T_ReceiveReferencePatientDPAmount']}',
|
|
T_ReceiveReferencePatientUserID = '{$userid}'
|
|
WHERE
|
|
T_ReceiveReferencePatientID = '{$prm['T_ReceiveReferencePatientID']}'
|
|
";
|
|
//echo $query;
|
|
$rows = $this->db_onedev->query($query);
|
|
|
|
foreach($prm['ordertests'] as $k=>$v){
|
|
if($v['xid'] == 0 || $v['xid'] == '0'){
|
|
$query = "INSERT INTO t_receivereferencetest (
|
|
T_ReceiveReferenceTestT_ReceiveReferencePatientID,
|
|
T_ReceiveReferenceTestT_TestID,
|
|
T_ReceiveReferenceTestT_TestCode,
|
|
T_ReceiveReferenceTestT_TestName,
|
|
T_ReceiveReferenceTestT_TestPrice,
|
|
T_ReceiveReferenceTestUserID,
|
|
T_ReceiveReferenceTestCreated,
|
|
T_ReceiveReferenceTestLastUpdated
|
|
)
|
|
VALUE(
|
|
?,?,?,?,?,?,now(),now()
|
|
)";
|
|
$insert_new_test = $this->db_onedev->query($query,array(
|
|
$order_id,
|
|
$v['T_TestID'],
|
|
$v['T_TestCode'],
|
|
$v['T_TestName'],
|
|
$v['total'],
|
|
$userid
|
|
));
|
|
}
|
|
|
|
}
|
|
|
|
if(isset($prm['deleted_ordertests'])){
|
|
foreach($prm['deleted_ordertests'] as $i=>$del){
|
|
|
|
$query = "UPDATE t_receivereferencetest SET
|
|
T_ReceiveReferenceTestIsActive = 'N',
|
|
T_ReceiveReferenceTestUserID = '{$userid}',
|
|
T_ReceiveReferenceTestLastUpdated = now()
|
|
WHERE
|
|
T_ReceiveReferenceTestID = ?
|
|
";
|
|
$delete_exist_test = $this->db_onedev->query($query,array($del['T_ReceiveReferenceTestID'],));
|
|
}
|
|
}
|
|
$result = array(
|
|
"total" => 1 ,
|
|
"records" => array('status'=>'OK')
|
|
);
|
|
$this->sys_ok($result);
|
|
exit;
|
|
}
|
|
function deletebill(){
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$prm = $this->sys_input;
|
|
$userid = $this->sys_user["M_UserID"];
|
|
$query ="UPDATE f_bill_issue_pusat SET
|
|
F_BillIssuePusatIsActive = 'N',
|
|
F_BillIssuePusatUserID = '{$userid}'
|
|
WHERE
|
|
F_BillIssuePusatID = '{$prm['id']}'";
|
|
|
|
//echo $query;
|
|
$rows = $this->db_onedev->query($query);
|
|
$query ="UPDATE f_bill_issue_pusat_detail SET
|
|
F_BillIssuePusatDetailIsActive = 'N',
|
|
F_BillIssuePusatDetailUserID = '{$userid}'
|
|
WHERE
|
|
F_BillIssuePusatDetailF_BillIssuePusatID = '{$prm['id']}'";
|
|
|
|
//echo $query;
|
|
$rows = $this->db_onedev->query($query);
|
|
|
|
$sqldet = "SELECT
|
|
F_BillIssuePusatDetailF_BillID,
|
|
F_BillIssuePusatDetailM_BranchID
|
|
FROM f_bill_issue_pusat_detail
|
|
WHERE F_BillIssuePusatDetailF_BillIssuePusatID = '{$prm['id']}'";
|
|
|
|
$querydet = $this->db_onedev->query($sqldet);
|
|
$rows = $querydet->result_array();
|
|
if($rows){
|
|
foreach($rows as $k => $v){
|
|
$branchID = $v['F_BillIssuePusatDetailM_BranchID'];
|
|
$billID = $v['F_BillIssuePusatDetailF_BillID'];
|
|
$querytitip ="UPDATE f_bill_titip SET
|
|
F_BillIsUsed = 'N'
|
|
WHERE
|
|
F_BillID = $billID AND M_BranchID = $branchID";
|
|
$rowstitip = $this->db_onedev->query($querytitip);
|
|
}
|
|
}
|
|
|
|
$result = array(
|
|
"total" => 1 ,
|
|
"records" => array('status'=>'OK')
|
|
);
|
|
$this->sys_ok($result);
|
|
exit;
|
|
}
|
|
function notifbill(){
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$prm = $this->sys_input;
|
|
$userid = $this->sys_user["M_UserID"];
|
|
$query ="UPDATE f_bill_issue_pusat SET
|
|
F_BillIssuePusatIsNotif = 'Y',
|
|
F_BillIssuePusatNotifUserID = '{$userid}',
|
|
F_BillIssuePusatNotifDate = now()
|
|
WHERE
|
|
F_BillIssuePusatID = '{$prm['id']}'";
|
|
|
|
// echo $query;
|
|
$rows = $this->db_onedev->query($query);
|
|
|
|
$result = array(
|
|
"total" => 1 ,
|
|
"records" => array('status'=>'OK')
|
|
);
|
|
$this->sys_ok($result);
|
|
exit;
|
|
}
|
|
function sendbill(){
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$prm = $this->sys_input;
|
|
$userid = $this->sys_user["M_UserID"];
|
|
$query ="UPDATE f_bill_issue_pusat SET
|
|
F_BillIssuePusatIsSend = 'Y',
|
|
F_BillIssuePusatSendUserID = '{$userid}',
|
|
F_BillIssuePusatSendDate = now()
|
|
WHERE
|
|
F_BillIssuePusatID = '{$prm['id']}'";
|
|
|
|
// echo $query;
|
|
$rows = $this->db_onedev->query($query);
|
|
|
|
$result = array(
|
|
"total" => 1 ,
|
|
"records" => array('status'=>'OK')
|
|
);
|
|
$this->sys_ok($result);
|
|
exit;
|
|
}
|
|
function deletepatient(){
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$prm = $this->sys_input;
|
|
$userid = $this->sys_user["M_UserID"];
|
|
$query ="UPDATE f_bill_issue_pusat_detail SET
|
|
F_BillIssuePusatDetailIsActive = 'N',
|
|
F_BillIssuePusatDetailUserID = '{$userid}'
|
|
WHERE
|
|
F_BillIssuePusatDetailID = '{$prm['F_BillIssuePusatDetailID']}'
|
|
";
|
|
//echo $query;
|
|
$rows = $this->db_onedev->query($query);
|
|
|
|
//echo $query;
|
|
$rows = $this->db_onedev->query($query);
|
|
|
|
$result = array(
|
|
"total" => 1 ,
|
|
"records" => array('status'=>'OK')
|
|
);
|
|
$this->sys_ok($result);
|
|
exit;
|
|
}
|
|
function searchtest(){
|
|
$prm = $this->sys_input;
|
|
|
|
$max_rst = 12;
|
|
$tot_count = 0;
|
|
|
|
$q = [
|
|
'search' => '%'
|
|
];
|
|
|
|
if ($prm['search'] != '')
|
|
{
|
|
$q['search'] = "%{$prm['search']}%";
|
|
}
|
|
|
|
$mou_id = $prm['mouid'];
|
|
// QUERY TOTAL
|
|
$sql = "SELECT count(*) as total
|
|
FROM t_test
|
|
JOIN t_price ON T_PriceT_TestID = T_TestID AND T_PriceIsCito = 'N' AND T_PriceM_MouID = '{$mou_id}'
|
|
WHERE
|
|
T_TestName like ? AND
|
|
T_TestIsActive = 'Y'
|
|
ORDER BY T_TestName ASC";
|
|
$query = $this->db_onedev->query($sql,$q['search']);
|
|
//echo $query;
|
|
if ($query) {
|
|
$tot_count = $query->result_array()[0]["total"];
|
|
}
|
|
else {
|
|
$this->sys_error_db("test count",$this->db_onedev);
|
|
exit;
|
|
}
|
|
|
|
$sql = "
|
|
SELECT 'Y' as editable,
|
|
0 as xid,
|
|
T_TestID,
|
|
T_TestCode,
|
|
T_TestName, T_PriceAmount, T_PriceDisc, T_PriceDiscRp, T_PriceAmount - ((T_PriceDisc/100) * T_PriceAmount) - T_PriceDiscRp as total,
|
|
M_CompanyID,'N' as M_CompanyIsBill, 0 as M_CompanyMinDP
|
|
FROM one.t_test
|
|
JOIN one.t_price ON T_PriceT_TestID = T_TestID AND T_PriceIsCito = 'N' AND T_PriceM_MouID = '{$mou_id}'
|
|
JOIN one.m_mou ON M_MouID = '{$mou_id}'
|
|
JOIN one.m_company ON M_MouM_CompanyID = M_CompanyID
|
|
WHERE
|
|
T_TestName like ? AND
|
|
T_TestIsActive = 'Y'
|
|
ORDER BY T_TestName ASC
|
|
";
|
|
$query = $this->db_onedev->query($sql, array($q['search']));
|
|
|
|
if ($query) {
|
|
$rows = $query->result_array();
|
|
//echo $this->db_onedev->last_query();
|
|
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows));
|
|
$this->sys_ok($result);
|
|
}
|
|
else {
|
|
$this->sys_error_db("test rows",$this->db_onedev);
|
|
exit;
|
|
}
|
|
}
|
|
|
|
public function upload()
|
|
{
|
|
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$inp = $this->sys_input;
|
|
$userid = $this->sys_user["M_UserID"];
|
|
$receive_date = date('Y-m-d H:i:s',strtotime($prm['rdate']));
|
|
$home_dir = "/home/one/project/one/";
|
|
$target_dir = $home_dir . "one-media/one-photo/";
|
|
|
|
if (!file_exists($target_dir)) {
|
|
mkdir($target_dir, 0755, true);
|
|
}
|
|
$filename = date("YmdHis")."_".$inp['billNo'] . ".jpg";
|
|
$target_path = $target_dir . $filename;
|
|
$this->base64_to_jpeg($inp['img'], $target_path);
|
|
$sql = "UPDATE f_bill_issue_pusat SET F_BillIssuePusatImg = '{$filename}',
|
|
F_BillIssuePusatIsReceive = 'Y',
|
|
F_BillIssuePusatReceiveDate = '{$inp['rtanggal']}',
|
|
F_BillIssuePusatReceiveUserID = {$userid},
|
|
F_BillIssuePusatDueDate = '{$inp['sdate']}'
|
|
WHERE F_BillIssuePusatID = {$inp['idx']}";
|
|
//echo $sql;
|
|
$save = $this->db_onedev->query($sql);
|
|
|
|
/* $sqlbill = "UPDATE f_bill SET F_BillDueDate = '{$inp['sdate']}'
|
|
WHERE F_BillIssuePusatID = {$inp['idbill']}";
|
|
//echo $sqlbill;
|
|
$savebill = $this->db_onedev->query($sqlbill); */
|
|
|
|
$sqllog = "INSERT INTO f_bill_receive_log (F_BillReceiveLogF_BillIssuePusatID,
|
|
F_BillReceiveLogDate,
|
|
F_BillReceiveLogImg,
|
|
F_BillReceiveLogUserID,
|
|
F_BillReceiveLogCreated,
|
|
F_BillReceiveLogLastUpdated)
|
|
VALUES
|
|
({$inp['idx']},
|
|
'{$inp['rtanggal']}',
|
|
'{$filename}',
|
|
{$userid},
|
|
now(),
|
|
now())";
|
|
//echo $sqllog;
|
|
$savelog = $this->db_onedev->query($sqllog);
|
|
|
|
$result = array("url" => "http://" . $_SERVER['SERVER_NAME'] . "/one-media/one-photo/" . $filename. "?d=" . date("YmdHis"));
|
|
$this->sys_ok($result);
|
|
exit;
|
|
}
|
|
public function uploadsend()
|
|
{
|
|
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$inp = $this->sys_input;
|
|
$userid = $this->sys_user["M_UserID"];
|
|
$receive_date = date('Y-m-d H:i:s',strtotime($prm['rdate']));
|
|
$home_dir = "/home/one/project/one/";
|
|
$target_dir = $home_dir . "one-media/one-photo/";
|
|
|
|
if (!file_exists($target_dir)) {
|
|
mkdir($target_dir, 0755, true);
|
|
}
|
|
$filename = date("YmdHis")."_".$inp['billNo'] . "_send.jpg";
|
|
$target_path = $target_dir . $filename;
|
|
$this->base64_to_jpeg($inp['img'], $target_path);
|
|
$sql = "UPDATE f_bill_issue_pusat SET F_BillIssuePusatImgSend = '{$filename}',
|
|
F_BillIssuePusatSendUserID = {$userid}
|
|
WHERE F_BillIssuePusatID = {$inp['idx']}";
|
|
//echo $sql;
|
|
$save = $this->db_onedev->query($sql);
|
|
|
|
$result = array("url" => "http://" . $_SERVER['SERVER_NAME'] . "/one-media/one-photo/" . $filename. "?d=" . date("YmdHis"));
|
|
$this->sys_ok($result);
|
|
exit;
|
|
}
|
|
function base64_to_jpeg($base64_string, $output_file) {
|
|
// open the output file for writing
|
|
$ifp = fopen( $output_file, 'wb' );
|
|
|
|
// split the string on commas
|
|
// $data[ 0 ] == "data:image/png;base64"
|
|
// $data[ 1 ] == <actual base64 string>
|
|
$data = explode( ',', $base64_string );
|
|
|
|
// we could add validation here with ensuring count( $data ) > 1
|
|
fwrite( $ifp, base64_decode( $data[ 1 ] ) );
|
|
|
|
// clean up the file resource
|
|
fclose( $ifp );
|
|
|
|
return $output_file;
|
|
}
|
|
|
|
}
|