1209 lines
50 KiB
PHP
1209 lines
50 KiB
PHP
<?php
|
|
class Paymentterms extends MY_Controller
|
|
{
|
|
function __construct()
|
|
{
|
|
parent::__construct();
|
|
$this->db_inventory = $this->load->database("inventory", true);
|
|
$this->db_inventory_log = $this->load->database('inventory_log', true);
|
|
$this->db_onex = 'one_aditya';
|
|
}
|
|
|
|
function search()
|
|
{
|
|
try {
|
|
if (!$this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$prm = $this->sys_input;
|
|
|
|
$search = "%%";
|
|
if (isset($prm['search']) && trim($prm["search"]) != '') {
|
|
$search = trim($prm["search"]);
|
|
$search = '%' . $prm['search'] . '%';
|
|
}
|
|
$start_date = date("Y-m-d");
|
|
if (isset($prm['start_date'])) {
|
|
$start_date = $prm["start_date"];
|
|
}
|
|
$end_date = date("Y-m-d");
|
|
if (isset($prm['end_date'])) {
|
|
$end_date = $prm["end_date"];
|
|
}
|
|
$filter_supplier = '';
|
|
$filter_sql_supplier = "";
|
|
if (isset($prm['supplier_id']) && intval($prm['supplier_id']) > 0) {
|
|
$filter_supplier = ' AND SupplierID = '.$prm['supplier_id'];
|
|
$filter_sql_supplier = ' AND SupplierPaymentTermsSupplierID = '.$prm['supplier_id'];
|
|
}
|
|
$order_by = "SupplierPaymentTermsCode";
|
|
if (isset($prm['order_by'])) {
|
|
$order_by = trim($prm["order_by"]);
|
|
}
|
|
$order_type = "asc";
|
|
if (isset($prm['order_type'])) {
|
|
$order_type = trim($prm["order_type"]);
|
|
}
|
|
$order = $order_by.' '.$order_type;
|
|
$perpage = 10;
|
|
$offset = ($prm['current_page'] - 1) * $perpage;
|
|
|
|
$sql = "SELECT COUNT(*) as total FROM
|
|
(
|
|
SELECT SupplierPaymentTermsID
|
|
FROM `supplierpaymentterms`
|
|
JOIN `supplier`
|
|
ON SupplierPaymentTermsSupplierID = SupplierID $filter_supplier
|
|
AND SupplierIsActive = 'Y'
|
|
LEFT JOIN $this->db_onex.m_user
|
|
ON SupplierPaymentTermsConfirmBy = M_UserID
|
|
AND M_UserIsActive = 'Y'
|
|
WHERE
|
|
SupplierPaymentTermsIsActive = 'Y'
|
|
AND ( SupplierPaymentTermsStartDate <= ?
|
|
AND SupplierPaymentTermsEndDate >= ? )
|
|
AND ( SupplierPaymentTermsCode like ? OR SupplierPaymentTermsName like ?)
|
|
$filter_sql_supplier
|
|
) x";
|
|
$qry = $this->db_inventory->query($sql,array($end_date, $start_date, $search, $search));
|
|
$tot_count = 0;
|
|
$tot_page = 0;
|
|
if ($qry) {
|
|
$tot_count = $qry->row()->total;
|
|
$tot_page = ceil($tot_count/$perpage);
|
|
} else {
|
|
echo $this->db_inventory->last_query();
|
|
$this->sys_error_db("payment terms order count error", $this->db_inventory->last_query());
|
|
exit;
|
|
}
|
|
|
|
$rows = array();
|
|
|
|
$sql = "SELECT SupplierPaymentTermsID as id,
|
|
SupplierPaymentTermsName as name,
|
|
SupplierPaymentTermsCode as code,
|
|
SupplierPaymentTermsName,
|
|
SupplierPaymentTermsName as term_name,
|
|
SupplierPaymentTermsSupplierID as supplier_id,
|
|
SupplierName as supplier_name,
|
|
SupplierName,
|
|
SupplierPaymentTermsIsConfirm,
|
|
SupplierPaymentTermsIsConfirm as term_confirm,
|
|
SupplierPaymentTermsConfirmDatetime,
|
|
SupplierPaymentTermsDescription,
|
|
SupplierPaymentTermsStartDate,
|
|
SupplierPaymentTermsEndDate,
|
|
DATE_FORMAT(SupplierPaymentTermsStartDate, '%d-%m-%Y') as tgl_awal,
|
|
DATE_FORMAT(SupplierPaymentTermsEndDate, '%d-%m-%Y') as tgl_akhir,
|
|
'' as details
|
|
FROM supplierpaymentterms
|
|
JOIN supplier
|
|
ON SupplierPaymentTermsSupplierID = SupplierID
|
|
AND SupplierIsActive = 'Y'
|
|
LEFT JOIN $this->db_onex.m_user
|
|
ON SupplierPaymentTermsConfirmBy = M_UserID
|
|
AND M_UserIsActive = 'Y'
|
|
WHERE SupplierPaymentTermsIsActive = 'Y'
|
|
AND ( SupplierPaymentTermsStartDate <= ?
|
|
AND SupplierPaymentTermsEndDate >= ? )
|
|
AND ( SupplierPaymentTermsCode like ? OR SupplierPaymentTermsName like ?)
|
|
$filter_sql_supplier
|
|
ORDER BY ?
|
|
LIMIT ? OFFSET ?";
|
|
$qry = $this->db_inventory->query($sql, array($end_date, $start_date, $search, $search, $order, $perpage, $offset));
|
|
//echo $this->db_inventory->last_query();
|
|
if($qry){
|
|
$rows = $qry->result_array();
|
|
if(count($rows) > 0){
|
|
foreach ($rows as $key => $value) {
|
|
|
|
$sql = "SELECT SupplierPaymentTermsDetailID as id,
|
|
SupplierPaymentTermsDetailItemID as item_id,
|
|
ItemName as item_name,
|
|
SupplierPaymentTermsDetailPrice as price,
|
|
SupplierPaymentTermsDetailPrice as harga,
|
|
SupplierPaymentTermsDetailDiscount as discount_percent,
|
|
SupplierPaymentTermsDetailDiscountRp as discount_rp,
|
|
if(SupplierPaymentTermsDetailDiscount = 0,SupplierPaymentTermsDetailDiscountRp,SupplierPaymentTermsDetailDiscount) as diskon,
|
|
SupplierPaymentTermsDetailTotal as total,
|
|
if(SupplierPaymentTermsDetailDiscount = 0,'rupiah','persen') as tipe_diskon,
|
|
ItemUnitMapItemUnitID as item_unit_map_id
|
|
from supplierpaymenttermsdetail
|
|
LEFT JOIN item
|
|
ON SupplierPaymentTermsDetailItemID = ItemID
|
|
AND ItemIsActive = 'Y'
|
|
JOIN itemunitmap
|
|
ON ItemUnitMapItemID = ItemID
|
|
AND ItemUnitMapIsPurchase = 'Y'
|
|
where SupplierPaymentTermsSupplierPaymentTermsID = ?
|
|
AND SupplierPaymentTermsDetailIsActive = 'Y'";
|
|
|
|
$qry = $this->db_inventory->query($sql, array($value['id']));
|
|
if($qry){
|
|
$rows[$key]['details'] = $qry->result_array();
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
}else {
|
|
//echo $this->db_inventory->last_query();
|
|
$this->sys_error_db("payment terms data error", $this->db_inventory->last_query());
|
|
exit;
|
|
}
|
|
|
|
|
|
$result = array("total_page" => $tot_page, "records" => $rows);
|
|
$this->sys_ok($result);
|
|
exit;
|
|
|
|
} catch (Exception $exc) {
|
|
$message = $exc->getMessage();
|
|
$this->sys_error($message);
|
|
}
|
|
}
|
|
|
|
function search_by_id()
|
|
{
|
|
try {
|
|
if (!$this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$prm = $this->sys_input;
|
|
|
|
// $search = "";
|
|
// if (isset($prm['search']) && trim($prm["search"]) != '') {
|
|
// $search = trim($prm["search"]);
|
|
// $search = '%' . $prm['search'] . '%';
|
|
// }
|
|
$start_date = date("Y-m-d");
|
|
if (isset($prm['start_date'])) {
|
|
$start_date = $prm["start_date"];
|
|
}
|
|
$end_date = date("Y-m-d");
|
|
if (isset($prm['end_date'])) {
|
|
$end_date = $prm["end_date"];
|
|
}
|
|
$filter_supplier = '';
|
|
if (isset($prm['supplier_id']) && intval($prm['supplier_id']) > 0) {
|
|
$filter_supplier = ' AND SupplierID = '.$prm['supplier_id'];
|
|
}
|
|
$order_by = "SupplierPaymentTermsCode";
|
|
if (isset($prm['order_by'])) {
|
|
$order_by = trim($prm["order_by"]);
|
|
}
|
|
$order_type = "asc";
|
|
if (isset($prm['order_type'])) {
|
|
$order_type = trim($prm["order_type"]);
|
|
}
|
|
$order = $order_by.' '.$order_type;
|
|
$perpage = 10;
|
|
$offset = ($prm['current_page'] - 1) * $perpage;
|
|
|
|
$sql = "SELECT COUNT(*) as total FROM
|
|
(
|
|
SELECT SupplierPaymentTermsID
|
|
FROM `supplierpaymentterms`
|
|
JOIN `supplier`
|
|
ON SupplierPaymentTermsSupplierID = SupplierID $filter_supplier
|
|
AND SupplierIsActive = 'Y'
|
|
LEFT JOIN $this->db_onex.m_user
|
|
ON SupplierPaymentTermsConfirmBy = M_UserID
|
|
AND M_UserIsActive = 'Y'
|
|
WHERE
|
|
SupplierPaymentTermsIsActive = 'Y'
|
|
AND ( SupplierPaymentTermsStartDate <= ?
|
|
AND SupplierPaymentTermsEndDate >= ? )
|
|
AND ( SupplierPaymentTermsID = ? )
|
|
) x";
|
|
$qry = $this->db_inventory->query($sql,array($end_date, $start_date, $prm['SupplierPaymentTermsSupplierPaymentTermsID']));
|
|
$tot_count = 0;
|
|
$tot_page = 0;
|
|
if ($qry) {
|
|
$tot_count = $qry->row()->total;
|
|
$tot_page = ceil($tot_count/$perpage);
|
|
} else {
|
|
echo $this->db_inventory->last_query();
|
|
$this->sys_error_db("payment terms order count error", $this->db_inventory->last_query());
|
|
exit;
|
|
}
|
|
|
|
$rows = array();
|
|
|
|
$sql = "SELECT SupplierPaymentTermsID as id,
|
|
SupplierPaymentTermsName as name,
|
|
SupplierPaymentTermsCode as code,
|
|
SupplierPaymentTermsName,
|
|
SupplierPaymentTermsName as term_name,
|
|
SupplierPaymentTermsSupplierID as supplier_id,
|
|
SupplierName as supplier_name,
|
|
SupplierName,
|
|
SupplierPaymentTermsIsConfirm,
|
|
SupplierPaymentTermsIsConfirm as term_confirm,
|
|
SupplierPaymentTermsConfirmDatetime,
|
|
SupplierPaymentTermsDescription,
|
|
SupplierPaymentTermsStartDate,
|
|
SupplierPaymentTermsEndDate,
|
|
DATE_FORMAT(SupplierPaymentTermsStartDate, '%d-%m-%Y') as tgl_awal,
|
|
DATE_FORMAT(SupplierPaymentTermsEndDate, '%d-%m-%Y') as tgl_akhir,
|
|
'' as details
|
|
FROM supplierpaymentterms
|
|
JOIN supplier
|
|
ON SupplierPaymentTermsSupplierID = SupplierID
|
|
AND SupplierIsActive = 'Y'
|
|
LEFT JOIN $this->db_onex.m_user
|
|
ON SupplierPaymentTermsConfirmBy = M_UserID
|
|
AND M_UserIsActive = 'Y'
|
|
WHERE SupplierPaymentTermsIsActive = 'Y'
|
|
AND ( SupplierPaymentTermsStartDate <= ?
|
|
AND SupplierPaymentTermsEndDate >= ? )
|
|
AND ( SupplierPaymentTermsID = ? )
|
|
ORDER BY ?
|
|
LIMIT ? OFFSET ?";
|
|
$qry = $this->db_inventory->query($sql, array($end_date, $start_date, $prm['SupplierPaymentTermsSupplierPaymentTermsID'],
|
|
$order, $perpage, $offset));
|
|
//echo $this->db_inventory->last_query();
|
|
if($qry){
|
|
$rows = $qry->result_array();
|
|
if(count($rows) > 0){
|
|
foreach ($rows as $key => $value) {
|
|
|
|
$sql = "SELECT SupplierPaymentTermsDetailID as id,
|
|
SupplierPaymentTermsDetailItemID as item_id,
|
|
ItemName as item_name,
|
|
SupplierPaymentTermsDetailPrice as price,
|
|
SupplierPaymentTermsDetailPrice as harga,
|
|
SupplierPaymentTermsDetailDiscount as discount_percent,
|
|
SupplierPaymentTermsDetailDiscountRp as discount_rp,
|
|
if(SupplierPaymentTermsDetailDiscount = 0,SupplierPaymentTermsDetailDiscountRp,SupplierPaymentTermsDetailDiscount) as diskon,
|
|
SupplierPaymentTermsDetailTotal as total,
|
|
if(SupplierPaymentTermsDetailDiscount = 0,'rupiah','persen') as tipe_diskon,
|
|
ItemUnitMapItemUnitID as item_unit_map_id
|
|
from supplierpaymenttermsdetail
|
|
LEFT JOIN item
|
|
ON SupplierPaymentTermsDetailItemID = ItemID
|
|
AND ItemIsActive = 'Y'
|
|
JOIN itemunitmap
|
|
ON ItemUnitMapItemID = ItemID
|
|
AND ItemUnitMapIsPurchase = 'Y'
|
|
where SupplierPaymentTermsSupplierPaymentTermsID = ?
|
|
AND SupplierPaymentTermsDetailIsActive = 'Y'";
|
|
|
|
$qry = $this->db_inventory->query($sql, array($value['id']));
|
|
if($qry){
|
|
$rows[$key]['details'] = $qry->result_array();
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
}else {
|
|
//echo $this->db_inventory->last_query();
|
|
$this->sys_error_db("payment terms data error", $this->db_inventory->last_query());
|
|
exit;
|
|
}
|
|
|
|
|
|
$result = array("total_page" => $tot_page, "records" => $rows);
|
|
$this->sys_ok($result);
|
|
exit;
|
|
|
|
} catch (Exception $exc) {
|
|
$message = $exc->getMessage();
|
|
$this->sys_error($message);
|
|
}
|
|
}
|
|
|
|
function search_supplier()
|
|
{
|
|
try {
|
|
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 supplier
|
|
WHERE
|
|
SupplierName like ?
|
|
AND SupplierIsActive = 'Y'";
|
|
$query = $this->db_inventory->query($sql,$q['search']);
|
|
//echo $query;
|
|
if ($query) {
|
|
$tot_count = $query->result_array()[0]["total"];
|
|
}
|
|
else {
|
|
$this->sys_error_db("m_city count",$this->db_inventory);
|
|
exit;
|
|
}
|
|
$rows = array('id'=>0,'name'=>'Semua');
|
|
$sql = "
|
|
SELECT SupplierID as id, SupplierName as name
|
|
FROM supplier
|
|
WHERE
|
|
SupplierName like ?
|
|
AND SupplierIsActive = 'Y'
|
|
ORDER BY SupplierName DESC
|
|
";
|
|
$query = $this->db_inventory->query($sql, array($q['search']));
|
|
|
|
if ($query) {
|
|
$rows = $query->result_array();
|
|
array_push($rows,array('id'=>0,'name'=>'Semua'));
|
|
//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("supplier rows",$this->db_inventory);
|
|
exit;
|
|
}
|
|
} catch (Exception $exc) {
|
|
$message = $exc->getMessage();
|
|
$this->sys_error($message);
|
|
}
|
|
}
|
|
|
|
function search_supplier_form(){
|
|
try {
|
|
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 supplier
|
|
WHERE
|
|
SupplierName like ?
|
|
AND SupplierIsActive = 'Y'";
|
|
$query = $this->db_inventory->query($sql,$q['search']);
|
|
//echo $query;
|
|
if ($query) {
|
|
$tot_count = $query->result_array()[0]["total"];
|
|
}
|
|
else {
|
|
$this->sys_error_db("m_city count",$this->db_inventory);
|
|
exit;
|
|
}
|
|
$rows = array('id'=>0,'name'=>'Semua');
|
|
$sql = "
|
|
SELECT SupplierID as id, SupplierName as name
|
|
FROM supplier
|
|
WHERE
|
|
SupplierName like ?
|
|
AND SupplierIsActive = 'Y'
|
|
ORDER BY SupplierName DESC
|
|
";
|
|
$query = $this->db_inventory->query($sql, array($q['search']));
|
|
|
|
if ($query) {
|
|
$rows = $query->result_array();
|
|
//array_push($rows,array('id'=>0,'name'=>'Pilih Supplier'));
|
|
//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("supplier rows",$this->db_inventory);
|
|
exit;
|
|
}
|
|
} catch (Exception $exc) {
|
|
$message = $exc->getMessage();
|
|
$this->sys_error($message);
|
|
}
|
|
}
|
|
|
|
function search_item()
|
|
{
|
|
try {
|
|
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 item
|
|
JOIN itemunitmap
|
|
ON ItemUnitMapItemID = ItemID
|
|
AND ItemUnitMapIsPurchase = 'Y'
|
|
WHERE ItemName like ?
|
|
AND ItemIsActive = 'Y'";
|
|
$query = $this->db_inventory->query($sql,$q['search']);
|
|
//echo $query;
|
|
if ($query) {
|
|
$tot_count = $query->result_array()[0]["total"];
|
|
}
|
|
else {
|
|
$this->sys_error_db("item count",$this->db_inventory);
|
|
exit;
|
|
}
|
|
$rows = array('id'=>0,'name'=>'Semua');
|
|
$sql = "
|
|
SELECT
|
|
ItemID as id,
|
|
ItemName as name,
|
|
ItemUnitMapItemUnitID as item_unit_map_id
|
|
FROM item
|
|
JOIN itemunitmap
|
|
ON ItemUnitMapItemID = ItemID
|
|
AND ItemUnitMapIsPurchase = 'Y'
|
|
WHERE ItemName like ?
|
|
AND ItemIsActive = 'Y'
|
|
ORDER BY ItemName DESC
|
|
";
|
|
$query = $this->db_inventory->query($sql, array($q['search']));
|
|
|
|
if ($query) {
|
|
$rows = $query->result_array();
|
|
// array_push($rows,array('id'=>0,'name'=>'Semua'));
|
|
//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("item rows",$this->db_inventory);
|
|
exit;
|
|
}
|
|
} catch (Exception $exc) {
|
|
$message = $exc->getMessage();
|
|
$this->sys_error($message);
|
|
}
|
|
}
|
|
|
|
function delete()
|
|
{
|
|
try {
|
|
if (!$this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$userid = $this->sys_user['M_UserID'];
|
|
$param = $this->sys_input;
|
|
$id = "";
|
|
if (isset($param['id'])) {
|
|
$id = intval($param["id"]);
|
|
}
|
|
if ($id == "" || !$id) {
|
|
$error = array(
|
|
"message" => "id is mandatory",
|
|
);
|
|
$this->sys_error_db($error);
|
|
exit;
|
|
}
|
|
|
|
$this->db_inventory->trans_start();
|
|
$this->db_inventory->trans_strict(FALSE);
|
|
|
|
$sql = "UPDATE supplierpaymentterms
|
|
SET SupplierPaymentTermsIsActive = 'N',
|
|
SupplierPaymentTermsUpdated = now(),
|
|
SupplierPaymentTermsUserID = ?
|
|
WHERE SupplierPaymentTermsID = ?
|
|
";
|
|
$qry = $this->db_inventory->query($sql, [$userid,$id]);
|
|
if(!$qry){
|
|
$this->db_inventory->trans_rollback();
|
|
$this->sys_error_db("delete supplier payment terms error", $this->db_inventory->last_query());
|
|
exit;
|
|
}else{
|
|
$sql = "UPDATE supplierpaymenttermsdetail
|
|
SET SupplierPaymentTermsDetailIsActive = 'N',
|
|
SupplierPaymentTermsDetailLastUpdated = now(),
|
|
SupplierPaymentTermsDetailUserID = ?
|
|
WHERE
|
|
SupplierPaymentTermsSupplierPaymentTermsID = ?
|
|
";
|
|
$qry = $this->db_inventory->query($sql, [$userid,$id]);
|
|
if(!$qry){
|
|
$this->db_inventory->trans_rollback();
|
|
$this->sys_error_db("delete supplier payment term detail error", $this->db_inventory->last_query());
|
|
exit;
|
|
}
|
|
}
|
|
|
|
$this->db_inventory->trans_complete();
|
|
|
|
$sql = "SELECT supplierpaymentterms.*, '' as address
|
|
FROM supplierpaymentterms
|
|
WHERE SupplierPaymentTermsID = ? ";
|
|
$qry = $this->db_inventory->query($sql, array($id));
|
|
//echo $this->db_inventory->last_query();
|
|
if(!$qry){
|
|
$this->db_inventory->trans_rollback();
|
|
$this->sys_error_db("select supplier payment terms error", $this->db_inventory->last_query());
|
|
exit;
|
|
}
|
|
$row_after = $qry->row_array();
|
|
$sql = "SELECT *
|
|
FROM `supplierpaymenttermsdetail`
|
|
WHERE
|
|
SupplierPaymentTermsSupplierPaymentTermsID = ? AND
|
|
SupplierPaymentTermsDetailIsActive = 'Y'";
|
|
$qry = $this->db_inventory->query($sql, array($id));
|
|
if($qry){
|
|
$row_after['address'] = $qry->result_array();
|
|
}else{
|
|
$this->db_inventory->trans_rollback();
|
|
$this->sys_error_db("select supplier payment terms detail error", $this->db_inventory->last_query());
|
|
exit;
|
|
}
|
|
|
|
$data_log_after = $row_after;
|
|
|
|
$sql = "INSERT INTO supplierpaymentterms_log (
|
|
SupplierPaymentTermsLogSupplierPaymentTermsID,
|
|
SupplierPaymentTermsLogStatus,
|
|
SupplierPaymentTermsLogJSONBefore,
|
|
SupplierPaymentTermsLogJSONAfter,
|
|
SupplierPaymentTermsLogUserID,
|
|
SupplierPaymentTermsLogCreated
|
|
)
|
|
VALUES(
|
|
?,?,?,?,?,NOW()
|
|
)";
|
|
$qry = $this->db_inventory_log->query($sql, array($id,'DELETE',NULL,json_encode($data_log_after),$userid));
|
|
if(!$qry){
|
|
$this->db_inventory_log->trans_rollback();
|
|
$this->sys_error_db("insert log error", $this->db_inventory_log->last_query());
|
|
exit;
|
|
}
|
|
|
|
$result = array(
|
|
"message" => ''
|
|
);
|
|
$this->sys_ok($result);
|
|
} catch (Exception $exc) {
|
|
$message = $exc->getMessage();
|
|
$this->sys_error($message);
|
|
}
|
|
}
|
|
|
|
function edit()
|
|
{
|
|
try {
|
|
if (!$this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$userid = $this->sys_user['M_UserID'];
|
|
$prm = $this->sys_input;
|
|
|
|
// var_dump($prm);
|
|
|
|
$SupplierPaymentTermsSupplierID = "";
|
|
if(isset($prm['SupplierPaymentTermsSupplierID'])){
|
|
$SupplierPaymentTermsSupplierID = trim($prm['SupplierPaymentTermsSupplierID']);
|
|
}
|
|
|
|
$SupplierPaymentTermsName = "";
|
|
if (isset($prm['SupplierPaymentTermsName'])) {
|
|
$SupplierPaymentTermsName = trim($prm["SupplierPaymentTermsName"]);
|
|
}
|
|
|
|
$SupplierPaymentTermsStartDate = "";
|
|
if (isset($prm['SupplierPaymentTermsStartDate'])) {
|
|
$SupplierPaymentTermsStartDate = trim($prm["SupplierPaymentTermsStartDate"]);
|
|
}
|
|
|
|
$SupplierPaymentTermsEndDate = "";
|
|
if (isset($prm['SupplierPaymentTermsEndDate'])) {
|
|
$SupplierPaymentTermsEndDate = trim($prm["SupplierPaymentTermsEndDate"]);
|
|
}
|
|
|
|
$SupplierPaymentTermsDescription = "";
|
|
if (isset($prm['SupplierPaymentTermsDescription'])) {
|
|
$SupplierPaymentTermsDescription = trim($prm["SupplierPaymentTermsDescription"]);
|
|
}
|
|
|
|
$id = $prm['id'];
|
|
|
|
$sql = "SELECT supplierpaymentterms.*, '' as address
|
|
FROM supplierpaymentterms
|
|
WHERE SupplierPaymentTermsID = ? ";
|
|
$qry = $this->db_inventory->query($sql, array($id));
|
|
//echo $this->db_inventory->last_query();
|
|
if(!$qry){
|
|
$this->db_inventory->trans_rollback();
|
|
$this->sys_error_db("select supplier payment terms error", $this->db_inventory->last_query());
|
|
exit;
|
|
}
|
|
$row = $qry->row_array();
|
|
$sql = "SELECT *
|
|
FROM `supplierpaymenttermsdetail`
|
|
WHERE
|
|
SupplierPaymentTermsSupplierPaymentTermsID = ? AND
|
|
SupplierPaymentTermsDetailIsActive = 'Y'";
|
|
$qry = $this->db_inventory->query($sql, array($id));
|
|
if($qry){
|
|
$row['address'] = $qry->result_array();
|
|
}else{
|
|
$this->db_inventory->trans_rollback();
|
|
$this->sys_error_db("select supplier payment term detail error", $this->db_inventory->last_query());
|
|
exit;
|
|
}
|
|
|
|
$data_log_before = $row;
|
|
|
|
$this->db_inventory->trans_start();
|
|
$this->db_inventory->trans_strict(FALSE);
|
|
|
|
$last_id = 0;
|
|
$sql = "UPDATE supplierpaymentterms SET
|
|
SupplierPaymentTermsSupplierID = ?,
|
|
SupplierPaymentTermsName = ?,
|
|
SupplierPaymentTermsUserID = ?,
|
|
SupplierPaymentTermsDescription = ?,
|
|
SupplierPaymentTermsStartDate = ?,
|
|
SupplierPaymentTermsEndDate = ?,
|
|
SupplierPaymentTermsUpdated = NOW()
|
|
WHERE
|
|
SupplierPaymentTermsID = ?";
|
|
$qry = $this->db_inventory->query($sql,
|
|
array(
|
|
$SupplierPaymentTermsSupplierID,
|
|
$SupplierPaymentTermsName,
|
|
$userid,
|
|
$SupplierPaymentTermsDescription,
|
|
$SupplierPaymentTermsStartDate,
|
|
$SupplierPaymentTermsEndDate,
|
|
$prm['id']
|
|
));
|
|
if(!$qry){
|
|
// echo $this->db_inventory->last_query();
|
|
$this->db_inventory->trans_rollback();
|
|
$this->sys_error_db("edit suplier payment terms error", $this->db_inventory->last_query());
|
|
exit;
|
|
}
|
|
|
|
$sql = "UPDATE supplierpaymenttermsdetail
|
|
SET SupplierPaymentTermsDetailIsActive = 'N'
|
|
WHERE SupplierPaymentTermsSupplierPaymentTermsID = ?";
|
|
$qry = $this->db_inventory->query($sql, array($id));
|
|
if(!$qry){
|
|
//echo $this->db_inventory->last_query();
|
|
$this->db_inventory->trans_rollback();
|
|
$this->sys_error_db("update N supplier payment term detail error", $this->db_inventory->last_query());
|
|
exit;
|
|
}
|
|
|
|
if(count($prm['address'])>0){
|
|
foreach ($prm['address'] as $key => $value) {
|
|
// $postcode = trim($value['postcode']);
|
|
// $description = trim($value['description']);
|
|
// $label = trim($value['label']);
|
|
// $kelurahan_id = trim($value['M_KelurahanID']);
|
|
|
|
if(intval($value['id']) > 0){
|
|
|
|
$SupplierPaymentTermsDetailItemID = trim($value['item_id']);
|
|
$SupplierPaymentTermsDetailPrice = trim($value['harga']);
|
|
$diskon_rp = "";
|
|
$diskon_persen = "";
|
|
|
|
if($value['tipe_diskon'] == "persen"){
|
|
$diskon_rp = 0;
|
|
$diskon_persen = intval($value['diskon']);
|
|
}else{
|
|
if($value['tipe_diskon'] == "rupiah"){
|
|
$diskon_rp = intval($value['diskon']);
|
|
$diskon_persen = 0;
|
|
}
|
|
}
|
|
|
|
$SupplierPaymentTermsDetailTotal = trim($value['total']);
|
|
|
|
$sql = "UPDATE supplierpaymenttermsdetail SET
|
|
SupplierPaymentTermsDetailItemID = ?,
|
|
SupplierPaymentTermsDetailItemUnitID = ?,
|
|
SupplierPaymentTermsDetailPrice = ?,
|
|
SupplierPaymentTermsDetailDiscount = ?,
|
|
SupplierPaymentTermsDetailDiscountRp = ?,
|
|
SupplierPaymentTermsDetailTotal = ?,
|
|
SupplierPaymentTermsDetailUserID = ?,
|
|
SupplierPaymentTermsDetailIsActive = 'Y',
|
|
SupplierPaymentTermsDetailLastUpdated = NOW()
|
|
WHERE
|
|
SupplierPaymentTermsDetailID = ?";
|
|
$qry = $this->db_inventory->query($sql,
|
|
array(
|
|
$SupplierPaymentTermsDetailItemID,
|
|
$value['item_unit_map_id'],
|
|
$SupplierPaymentTermsDetailPrice,
|
|
$diskon_persen,
|
|
$diskon_rp,
|
|
$SupplierPaymentTermsDetailTotal,
|
|
$userid,
|
|
$value['id']
|
|
));
|
|
if(!$qry){
|
|
// echo $this->db_inventory->last_query();
|
|
$this->db_inventory->trans_rollback();
|
|
$this->sys_error_db("edit supplier detail terms error", $this->db_inventory->last_query());
|
|
exit;
|
|
}
|
|
}else{
|
|
$SupplierPaymentTermsDetailItemID = trim($value['item_id']);
|
|
$SupplierPaymentTermsDetailPrice = trim($value['harga']);
|
|
$diskon_rp = "";
|
|
$diskon_persen = "";
|
|
|
|
if($value['tipe_diskon'] == "persen"){
|
|
$diskon_rp = 0;
|
|
$diskon_persen = intval($value['diskon']);
|
|
}else{
|
|
if($value['tipe_diskon'] == "rupiah"){
|
|
$diskon_rp = intval($value['diskon']);
|
|
$diskon_persen = 0;
|
|
}
|
|
}
|
|
|
|
$SupplierPaymentTermsDetailTotal = trim($value['total']);
|
|
|
|
$sql = "INSERT INTO supplierpaymenttermsdetail(
|
|
SupplierPaymentTermsSupplierPaymentTermsID,
|
|
SupplierPaymentTermsDetailItemID,
|
|
SupplierPaymentTermsDetailItemUnitID,
|
|
SupplierPaymentTermsDetailPrice,
|
|
SupplierPaymentTermsDetailDiscount,
|
|
SupplierPaymentTermsDetailDiscountRp,
|
|
SupplierPaymentTermsDetailTotal,
|
|
SupplierPaymentTermsDetailUserID,
|
|
SupplierPaymentTermsDetailCreated,
|
|
SupplierPaymentTermsDetailLastUpdated
|
|
)
|
|
VALUES(
|
|
?,?,?,?,?,?,?,?
|
|
,NOW(),NOW()
|
|
)";
|
|
$qry = $this->db_inventory->query($sql,
|
|
array(
|
|
$prm['id'],
|
|
$SupplierPaymentTermsDetailItemID,
|
|
$value['item_unit_map_id'],
|
|
intval($SupplierPaymentTermsDetailPrice),
|
|
$diskon_persen,
|
|
$diskon_rp,
|
|
intval($SupplierPaymentTermsDetailTotal),
|
|
$userid
|
|
));
|
|
if(!$qry){
|
|
// echo $this->db_inventory->last_query();
|
|
$this->db_inventory->trans_rollback();
|
|
$this->sys_error_db("add supplier payment terms details error", $this->db_inventory->last_query());
|
|
exit;
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
$this->db_inventory->trans_complete();
|
|
|
|
$sql = "SELECT supplierpaymentterms.*, '' as address
|
|
FROM supplierpaymentterms
|
|
WHERE SupplierPaymentTermsID = ? ";
|
|
$qry = $this->db_inventory->query($sql, array($id));
|
|
// echo $this->db_inventory->last_query();
|
|
if(!$qry){
|
|
$this->db_inventory->trans_rollback();
|
|
$this->sys_error_db("select supplier terms error", $this->db_inventory->last_query());
|
|
exit;
|
|
}
|
|
$row_after = $qry->row_array();
|
|
$sql = "SELECT *
|
|
FROM `supplierpaymenttermsdetail`
|
|
WHERE
|
|
SupplierPaymentTermsSupplierPaymentTermsID = ? AND
|
|
SupplierPaymentTermsDetailIsActive = 'Y'";
|
|
$qry = $this->db_inventory->query($sql, array($id));
|
|
if($qry){
|
|
$row_after['address'] = $qry->result_array();
|
|
}else{
|
|
$this->db_inventory->trans_rollback();
|
|
$this->sys_error_db("select supplier term detail error", $this->db_inventory->last_query());
|
|
exit;
|
|
}
|
|
|
|
$data_log_after = $row_after;
|
|
|
|
$sql = "INSERT INTO supplierpaymentterms_log (
|
|
SupplierPaymentTermsLogSupplierPaymentTermsID,
|
|
SupplierPaymentTermsLogStatus,
|
|
SupplierPaymentTermsLogJSONBefore,
|
|
SupplierPaymentTermsLogJSONAfter,
|
|
SupplierPaymentTermsLogUserID,
|
|
SupplierPaymentTermsLogCreated
|
|
)
|
|
VALUES(
|
|
?,?,?,?,?,NOW()
|
|
)";
|
|
$qry = $this->db_inventory_log->query($sql, array($id,'EDIT',json_encode($data_log_before),json_encode($data_log_after),$userid));
|
|
if(!$qry){
|
|
$this->db_inventory_log->trans_rollback();
|
|
$this->sys_error_db("insert log error", $this->db_inventory_log->last_query());
|
|
exit;
|
|
}
|
|
|
|
$result = array(
|
|
"message" => ''
|
|
);
|
|
$this->sys_ok($result);
|
|
|
|
|
|
} catch (Exception $exc) {
|
|
$message = $exc->getMessage();
|
|
$this->sys_error($message);
|
|
}
|
|
}
|
|
|
|
function save()
|
|
{
|
|
try {
|
|
if (!$this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$userid = $this->sys_user['M_UserID'];
|
|
$prm = $this->sys_input;
|
|
|
|
// var_dump($prm);
|
|
|
|
$SupplierPaymentTermsSupplierID = "";
|
|
if(isset($prm['SupplierPaymentTermsSupplierID'])){
|
|
$SupplierPaymentTermsSupplierID = trim($prm['SupplierPaymentTermsSupplierID']);
|
|
}
|
|
|
|
$SupplierPaymentTermsName = "";
|
|
if (isset($prm['SupplierPaymentTermsName'])) {
|
|
$SupplierPaymentTermsName = trim($prm["SupplierPaymentTermsName"]);
|
|
}
|
|
|
|
$SupplierPaymentTermsStartDate = "";
|
|
if (isset($prm['SupplierPaymentTermsStartDate'])) {
|
|
$SupplierPaymentTermsStartDate = trim($prm["SupplierPaymentTermsStartDate"]);
|
|
}
|
|
|
|
$SupplierPaymentTermsEndDate = "";
|
|
if (isset($prm['SupplierPaymentTermsEndDate'])) {
|
|
$SupplierPaymentTermsEndDate = trim($prm["SupplierPaymentTermsEndDate"]);
|
|
}
|
|
|
|
$SupplierPaymentTermsDescription = "";
|
|
if (isset($prm['SupplierPaymentTermsDescription'])) {
|
|
$SupplierPaymentTermsDescription = trim($prm["SupplierPaymentTermsDescription"]);
|
|
}
|
|
|
|
$this->db_inventory->trans_start();
|
|
$this->db_inventory->trans_strict(FALSE);
|
|
|
|
$numbering = '';
|
|
$sql = "SELECT `fn_numbering`('PaymentTerm') as numbering";
|
|
$qry = $this->db_inventory->query($sql);
|
|
if($qry){
|
|
$numbering = $qry->row()->numbering;
|
|
}
|
|
else{
|
|
$this->db_inventory->trans_rollback();
|
|
$this->sys_error_db("get numbering error", $this->db_inventory->last_query());
|
|
exit;
|
|
}
|
|
|
|
$last_id = 0;
|
|
$sql = "INSERT INTO supplierpaymentterms(
|
|
SupplierPaymentTermsSupplierID,
|
|
SupplierPaymentTermsCode,
|
|
SupplierPaymentTermsName,
|
|
SupplierPaymentTermsUserID,
|
|
SupplierPaymentTermsConfirmBy,
|
|
SupplierPaymentTermsDescription,
|
|
SupplierPaymentTermsStartDate,
|
|
SupplierPaymentTermsEndDate,
|
|
SupplierPaymentTermsConfirmDatetime,
|
|
SupplierPaymentTermsCreated,
|
|
SupplierPaymentTermsUpdated
|
|
)
|
|
VALUES(
|
|
?, ?, ?, ?, ?, ?, ?, ?, NOW(),NOW(),NOW()
|
|
)";
|
|
$qry = $this->db_inventory->query($sql,
|
|
array(
|
|
$SupplierPaymentTermsSupplierID,
|
|
$numbering,
|
|
$SupplierPaymentTermsName,
|
|
$userid,
|
|
$userid,
|
|
$SupplierPaymentTermsDescription,
|
|
$SupplierPaymentTermsStartDate,
|
|
$SupplierPaymentTermsEndDate
|
|
));
|
|
if($qry){
|
|
$last_id = $this->db_inventory->insert_id();
|
|
}
|
|
else{
|
|
// echo $this->db_inventory->last_query();
|
|
$this->db_inventory->trans_rollback();
|
|
$this->sys_error_db("add supplier payment terms error", $this->db_inventory->last_query());
|
|
exit;
|
|
}
|
|
|
|
if(count($prm['address'])>0){
|
|
foreach ($prm['address'] as $key => $value) {
|
|
|
|
// item_id: this.selected_item_form.id,
|
|
// item_name: this.selected_item_form.name,
|
|
// harga: this.detail_harga,
|
|
// tipe_diskon: this.detail_tipe_diskon,
|
|
// diskon: this.detail_diskon,
|
|
// total: hitungTotal,
|
|
|
|
$SupplierPaymentTermsDetailItemID = trim($value['item_id']);
|
|
$SupplierPaymentTermsDetailPrice = trim($value['harga']);
|
|
$diskon_rp = "";
|
|
$diskon_persen = "";
|
|
|
|
if($value['tipe_diskon'] == "persen"){
|
|
$diskon_rp = 0;
|
|
$diskon_persen = intval($value['diskon']);
|
|
}else{
|
|
if($value['tipe_diskon'] == "rupiah"){
|
|
$diskon_rp = intval($value['diskon']);
|
|
$diskon_persen = 0;
|
|
}
|
|
}
|
|
|
|
$SupplierPaymentTermsDetailTotal = trim($value['total']);
|
|
|
|
$sql = "INSERT INTO supplierpaymenttermsdetail(
|
|
SupplierPaymentTermsSupplierPaymentTermsID,
|
|
SupplierPaymentTermsDetailItemID,
|
|
SupplierPaymentTermsDetailItemUnitID,
|
|
SupplierPaymentTermsDetailPrice,
|
|
SupplierPaymentTermsDetailDiscount,
|
|
SupplierPaymentTermsDetailDiscountRp,
|
|
SupplierPaymentTermsDetailTotal,
|
|
SupplierPaymentTermsDetailUserID,
|
|
SupplierPaymentTermsDetailCreated,
|
|
SupplierPaymentTermsDetailLastUpdated
|
|
)
|
|
VALUES(
|
|
?,?,?,?,?,?,?,?
|
|
,NOW(),NOW()
|
|
)";
|
|
$qry = $this->db_inventory->query($sql,
|
|
array(
|
|
$last_id,
|
|
$SupplierPaymentTermsDetailItemID,
|
|
$value['item_unit_map_id'],
|
|
intval($SupplierPaymentTermsDetailPrice),
|
|
$diskon_persen,
|
|
$diskon_rp,
|
|
intval($SupplierPaymentTermsDetailTotal),
|
|
$userid
|
|
));
|
|
if(!$qry){
|
|
// echo $this->db_inventory->last_query();
|
|
$this->db_inventory->trans_rollback();
|
|
$this->sys_error_db("add supplier payment terms details error", $this->db_inventory->last_query());
|
|
exit;
|
|
}
|
|
}
|
|
}
|
|
|
|
$this->db_inventory->trans_complete();
|
|
|
|
$id = $last_id;
|
|
$sql = "SELECT supplierpaymentterms.*, '' as address
|
|
FROM supplierpaymentterms
|
|
WHERE SupplierPaymentTermsID = ? ";
|
|
$qry = $this->db_inventory->query($sql, array($id));
|
|
//echo $this->db_inventory->last_query();
|
|
if(!$qry){
|
|
// echo $this->db_inventory->last_query();
|
|
$this->db_inventory->trans_rollback();
|
|
$this->sys_error_db("select supplier payment terms error", $this->db_inventory->last_query());
|
|
exit;
|
|
}
|
|
$row_after = $qry->row_array();
|
|
$sql = "SELECT *
|
|
FROM `supplierpaymenttermsdetail`
|
|
WHERE
|
|
SupplierPaymentTermsSupplierPaymentTermsID = ? AND
|
|
SupplierPaymentTermsDetailIsActive = 'Y'";
|
|
$qry = $this->db_inventory->query($sql, array($id));
|
|
if($qry){
|
|
$row_after['address'] = $qry->result_array();
|
|
}else{
|
|
//echo $this->db_inventory->last_query();
|
|
$this->db_inventory->trans_rollback();
|
|
$this->sys_error_db("select supplier payment terms error", $this->db_inventory->last_query());
|
|
exit;
|
|
}
|
|
|
|
$data_log_after = $row_after;
|
|
|
|
$sql = "INSERT INTO supplierpaymentterms_log (
|
|
SupplierPaymentTermsLogSupplierPaymentTermsID,
|
|
SupplierPaymentTermsLogStatus,
|
|
SupplierPaymentTermsLogJSONBefore,
|
|
SupplierPaymentTermsLogJSONAfter,
|
|
SupplierPaymentTermsLogUserID,
|
|
SupplierPaymentTermsLogCreated
|
|
)
|
|
VALUES(
|
|
?,?,?,?,?,NOW()
|
|
)";
|
|
$qry = $this->db_inventory_log->query($sql, array($id,'ADD',NULL,json_encode($data_log_after),$userid));
|
|
if(!$qry){
|
|
$this->db_inventory_log->trans_rollback();
|
|
$this->sys_error_db("insert log error", $this->db_inventory_log->last_query());
|
|
exit;
|
|
}
|
|
|
|
$result = array(
|
|
"message" => ''
|
|
);
|
|
$this->sys_ok($result);
|
|
} catch (Exception $exc) {
|
|
$message = $exc->getMessage();
|
|
$this->sys_error($message);
|
|
}
|
|
}
|
|
|
|
function saveconfirm()
|
|
{
|
|
try {
|
|
if (!$this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$userid = $this->sys_user['M_UserID'];
|
|
$prm = $this->sys_input;
|
|
|
|
// var_dump($prm);
|
|
|
|
$id = "";
|
|
if(isset($prm['id'])){
|
|
$id = trim($prm['id']);
|
|
}
|
|
|
|
|
|
$this->db_inventory->trans_start();
|
|
$this->db_inventory->trans_strict(FALSE);
|
|
|
|
$sql = "UPDATE supplierpaymentterms
|
|
set SupplierPaymentTermsIsConfirm = 'Y',
|
|
SupplierPaymentTermsConfirmDatetime = NOW(),
|
|
SupplierPaymentTermsUpdated = NOW(),
|
|
SupplierPaymentTermsConfirmBy = ?
|
|
WHERE SupplierPaymentTermsID = ?";
|
|
|
|
$qry = $this->db_inventory->query($sql, array($userid, $id));
|
|
if(!qry){
|
|
$this->db_inventory->trans_rollback();
|
|
$this->sys_error_db("update confirm error", $this->db_inventory_log->last_query());
|
|
exit;
|
|
}
|
|
|
|
// log confirm
|
|
$sql = "SELECT supplierpaymentterms.*, '' as details
|
|
FROM supplierpaymentterms
|
|
WHERE SupplierPaymentTermsID = ? ";
|
|
$qry = $this->db_inventory->query($sql, array($id));
|
|
//echo $this->db_inventory->last_query();
|
|
if(!$qry){
|
|
$this->db_inventory->trans_rollback();
|
|
$this->sys_error_db("select supplier payment terms detail error", $this->db_inventory->last_query());
|
|
exit;
|
|
}
|
|
|
|
$row_after = $qry->row_array();
|
|
$sql = "SELECT *
|
|
FROM `supplierpaymenttermsdetail`
|
|
WHERE
|
|
SupplierPaymentTermsSupplierPaymentTermsID = ? AND
|
|
SupplierPaymentTermsDetailIsActive = 'Y'";
|
|
$qry = $this->db_inventory->query($sql, array($id));
|
|
if($qry){
|
|
$row_after['details'] = $qry->result_array();
|
|
}else{
|
|
$this->db_inventory->trans_rollback();
|
|
$this->sys_error_db("select supplier payment terms detail error", $this->db_inventory->last_query());
|
|
exit;
|
|
}
|
|
|
|
$data_log_after = $row_after;
|
|
|
|
$sql = "INSERT INTO supplierpaymentterms_log (
|
|
SupplierPaymentTermsLogSupplierPaymentTermsID,
|
|
SupplierPaymentTermsLogStatus,
|
|
SupplierPaymentTermsLogJSONBefore,
|
|
SupplierPaymentTermsLogJSONAfter,
|
|
SupplierPaymentTermsLogUserID,
|
|
SupplierPaymentTermsLogCreated
|
|
)
|
|
VALUES(
|
|
?,?,?,?,?,NOW()
|
|
)";
|
|
$qry = $this->db_inventory_log->query($sql, array($id,'CONFIRM',json_decode($data_log_before),json_encode($data_log_after),$userid));
|
|
if(!$qry){
|
|
$this->db_inventory_log->trans_rollback();
|
|
$this->sys_error_db("insert confirm log error", $this->db_inventory_log->last_query());
|
|
exit;
|
|
}
|
|
|
|
$this->db_inventory->trans_complete();
|
|
|
|
$result = array(
|
|
"message" => ''
|
|
);
|
|
$this->sys_ok($result);
|
|
} catch (Exception $exc) {
|
|
$message = $exc->getMessage();
|
|
$this->sys_error($message);
|
|
}
|
|
}
|
|
} |