167 lines
5.2 KiB
PHP
167 lines
5.2 KiB
PHP
<?php
|
|
class Auto_count extends MY_Controller
|
|
{
|
|
var $db_onedev;
|
|
public function index()
|
|
{
|
|
echo "Patient API";
|
|
}
|
|
public function __construct()
|
|
{
|
|
parent::__construct();
|
|
$this->db_onedev = $this->load->database("onedev", true);
|
|
}
|
|
|
|
public function add_notes($orderid){
|
|
}
|
|
function autotrial(){
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$prm = $this->sys_input;
|
|
$sdate = $prm['sdate'];
|
|
$tipe = $prm['tipe'];
|
|
$sql = $this->db_onedev->query("SELECT M_BranchIPAddress as branch_ip_address FROM m_branch WHERE M_BranchIsDefault = 'Y'")->row();
|
|
$branch_ip_address = $sql->branch_ip_address;
|
|
$page = file_get_contents("http://ngagel.bisone.pramitalab.id/one-api/keu/auto_count/$tipe/$sdate/csv");
|
|
echo "<pre>$page</pre>";
|
|
}
|
|
public function autopost()
|
|
{
|
|
try {
|
|
//# cek token valid
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
|
|
//# ambil parameter input
|
|
$prm = $this->sys_input;
|
|
$userid = $this->sys_user["M_UserID"];
|
|
$tipe = $prm['tipe'];
|
|
$sdate = $prm['sdate'];
|
|
|
|
$query = "SELECT COUNT(*) as exist FROM auto_count_posting WHERE AutoCountPostingIsActive = 'Y' AND AutoCountPostingType = '{$tipe}' AND AutoCountPostingDate = '{$sdate}'";
|
|
$exist_name = $this->db_onedev->query($query)->row()->exist;
|
|
|
|
if($exist_name == 0){
|
|
$sql = "INSERT INTO auto_count_posting(AutoCountPostingType,
|
|
AutoCountPostingDate,
|
|
AutoCountPostingUserID)
|
|
VALUES(?,?,?)";
|
|
|
|
$query = $this->db_onedev->query($sql,
|
|
array(
|
|
$prm['tipe'],
|
|
$prm['sdate'],
|
|
$userid));
|
|
if (!$query) {
|
|
$this->sys_error_db("auto_count_posting add");
|
|
exit;
|
|
}
|
|
$result = array ("total" => 1, "records" => array("xid" => 0), "pesan" => "Data berhasil diposting");
|
|
$this->sys_ok($result);
|
|
}else{
|
|
$errors = array();
|
|
$query = "SELECT CONCAT('Telah diposting sebelumnya oleh ', M_UserUsername, ' pada tanggal ', DATE_FORMAT(AutoCountPostingCreated,'%d-%m-%Y %h:%i:%s')) as pesan
|
|
FROM auto_count_posting
|
|
LEFT JOIN m_user ON M_UserID = AutoCountPostingUserID WHERE AutoCountPostingIsActive = 'Y' AND AutoCountPostingType = '{$tipe}' AND AutoCountPostingDate = '{$sdate}'";
|
|
$pesan = $this->db_onedev->query($query)->row()->pesan;
|
|
$result = array ("total" => -1,"errors" => $errors, "records" => 0, "pesan" => $pesan);
|
|
$this->sys_ok($result);
|
|
}
|
|
} catch(Exception $exc) {
|
|
$message = $exc->getMessage();
|
|
$this->sys_error($message);
|
|
}
|
|
}
|
|
function getdataselect(){
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$rows = [];
|
|
|
|
$query ="
|
|
SELECT 'ar' as M_BranchID, 'AR' as M_BranchName
|
|
UNION
|
|
SELECT 'jurnal' as M_BranchID, 'Jurnal' as M_BranchName";
|
|
//echo $query;
|
|
$rows['branchs'] = $this->db_onedev->query($query)->result_array();
|
|
|
|
$query = "SELECT '01' as M_MonthID, 'Januari' as M_MonthName
|
|
UNION SELECT '02' as M_MonthID, 'Februari' as M_MonthName
|
|
UNION SELECT '03' as M_MonthID, 'Maret' as M_MonthName
|
|
UNION SELECT '04' as M_MonthID, 'April' as M_MonthName
|
|
UNION SELECT '05' as M_MonthID, 'Mei' as M_MonthName
|
|
UNION SELECT '06' as M_MonthID, 'Juni' as M_MonthName
|
|
UNION SELECT '07' as M_MonthID, 'Juli' as M_MonthName
|
|
UNION SELECT '08' as M_MonthID, 'Agustus' as M_MonthName
|
|
UNION SELECT '09' as M_MonthID, 'September' as M_MonthName
|
|
UNION SELECT '10' as M_MonthID, 'Oktober' as M_MonthName
|
|
UNION SELECT '11' as M_MonthID, 'November' as M_MonthName
|
|
UNION SELECT '12' as M_MonthID, 'Desember' as M_MonthName ";
|
|
//echo $query;
|
|
$rows['months'] = $this->db_onedev->query($query)->result_array();
|
|
|
|
$sql = $this->db_onedev->query("SELECT MONTH(now()) as id")->row();
|
|
$id = $sql->id;
|
|
|
|
if($id == 1){
|
|
$idmonth = '01';
|
|
$namemonth = 'Januari';
|
|
}elseif($id == 2){
|
|
$idmonth = '02';
|
|
$namemonth = 'Februari';
|
|
}elseif($id == 3){
|
|
$idmonth = '03';
|
|
$namemonth = 'Maret';
|
|
}elseif($id == 4){
|
|
$idmonth = '04';
|
|
$namemonth = 'April';
|
|
}elseif($id == 5){
|
|
$idmonth = '05';
|
|
$namemonth = 'Mei';
|
|
}elseif($id == 6){
|
|
$idmonth = '06';
|
|
$namemonth = 'Juni';
|
|
}elseif($id == 7){
|
|
$idmonth = '07';
|
|
$namemonth = 'Juli';
|
|
}elseif($id == 8){
|
|
$idmonth = '08';
|
|
$namemonth = 'Agustus';
|
|
}elseif($id == 9){
|
|
$idmonth = '09';
|
|
$namemonth = 'September';
|
|
}elseif($id == 10){
|
|
$idmonth = '10';
|
|
$namemonth = 'Oktober';
|
|
}elseif($id == 11){
|
|
$idmonth = '11';
|
|
$namemonth = 'November';
|
|
}elseif($id == 12){
|
|
$idmonth = '12';
|
|
$namemonth = 'Desember';
|
|
}
|
|
|
|
|
|
|
|
$query = "SELECT 1 as M_YearID , YEAR(now()) as M_YearName
|
|
UNION SELECT 2 as M_YearID , (YEAR(now()) - 1) as M_YearName";
|
|
//echo $query;
|
|
$rows['years'] = $this->db_onedev->query($query)->result_array();
|
|
$syear = $sqlyear->id;
|
|
$result = array(
|
|
"total" => count($rows) ,
|
|
"idmonth" => $idmonth,
|
|
"namemonth" => $namemonth,
|
|
"records" => $rows,
|
|
);
|
|
$this->sys_ok($result);
|
|
exit;
|
|
}
|
|
|
|
}
|