80 lines
3.4 KiB
PHP
80 lines
3.4 KiB
PHP
<?php
|
|
class Downloadresponstatus extends MY_Controller
|
|
{
|
|
var $db;
|
|
function __construct()
|
|
{
|
|
parent::__construct();
|
|
$this->db_inventory = $this->load->database("inventory", true);
|
|
$this->db_inventory_log = $this->load->database('inventory_log', true);
|
|
|
|
}
|
|
|
|
function download_data()
|
|
{
|
|
try {
|
|
header("Content-Type:application/json");
|
|
$datas = json_decode(file_get_contents('php://input'), true);
|
|
|
|
//print_r($datas);
|
|
if($datas){
|
|
$this->db_inventory->trans_start();
|
|
$this->db_inventory->trans_strict(FALSE);
|
|
$arr_inserted = array();
|
|
foreach ($datas as $k => $v) {
|
|
$sql ="SELECT * FROM requeststatusrespon WHERE RequestStatusResponOldID = ? LIMIT 1";
|
|
$qry = $this->db_inventory->query($sql,[$v['RequestStatusResponID']]);
|
|
//echo $this->db_inventory->last_query();
|
|
if(!$qry){
|
|
echo $this->db_inventory->last_query();
|
|
exit;
|
|
}
|
|
|
|
//print_r($qry->row_array());
|
|
if(!$qry->row_array()){
|
|
$arr_insert_mutation_transit_detail = $v;
|
|
unset($arr_insert_mutation_transit_detail['branch_ip']);
|
|
unset($arr_insert_mutation_transit_detail['RequestStatusResponID']);
|
|
$arr_insert_mutation_transit_detail['RequestStatusResponIsUploaded'] = 'Y';
|
|
$arr_insert_mutation_transit_detail['RequestStatusResponOldID'] = $v['RequestStatusResponID'];
|
|
$arr_insert_mutation_transit_detail['RequestStatusResponCreated'] = date("Y-m-d H:i:s");
|
|
$arr_insert_mutation_transit_detail['RequestStatusResponSentTime'] = date("Y-m-d H:i:s");
|
|
$arr_insert_mutation_transit_detail['RequestStatusResponUsername'] = $v['RequestStatusResponUsername'];
|
|
|
|
$qry = $this->db_inventory->insert('requeststatusrespon', $arr_insert_mutation_transit_detail);
|
|
if(!$qry){
|
|
echo $this->db_inventory->last_query();
|
|
exit;
|
|
}
|
|
|
|
$sql = "UPDATE mutasirequestdetail SET MutasiRequestDetailStatus = ?
|
|
WHERE
|
|
MutasiRequestDetailID = ?";
|
|
$qry = $this->db_inventory->query($sql,array(
|
|
$v['RequestStatusResponStatus'],
|
|
$v['RequestStatusResponMutasiRequestDetailID']
|
|
));
|
|
if(!$qry){
|
|
echo $this->db_inventory->last_query();
|
|
exit;
|
|
}
|
|
}
|
|
|
|
array_push($arr_inserted,$v['RequestStatusResponID']);
|
|
|
|
}
|
|
$this->db_inventory->trans_complete();
|
|
$result = array( "records" => $arr_inserted);
|
|
$this->sys_ok($result);
|
|
}
|
|
|
|
|
|
|
|
} catch (Exception $exc) {
|
|
$message = $exc->getMessage();
|
|
$this->sys_error($message);
|
|
}
|
|
}
|
|
|
|
}
|