70 lines
2.8 KiB
PHP
70 lines
2.8 KiB
PHP
<?php
|
|
class Downloadfromcenterrequestreceive 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 mutasitransitdetail WHERE MutasiTransitDetailOldID = ? LIMIT 1";
|
|
$qry = $this->db_inventory->query([$v['MutasiTransitDetailID']]);
|
|
//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['MutasiTransitDetailID']);
|
|
$arr_insert_mutation_transit_detail['MutasiTransitDetailIsSend'] = 'Y';
|
|
$arr_insert_mutation_transit_detail['MutasiTransitDetailOldID'] = $v['MutasiTransitDetailID'];
|
|
$arr_insert_mutation_transit_detail['MutasiTransitDetailCreated'] = date("Y-m-d H:i:s");
|
|
$arr_insert_mutation_transit_detail['MutasiTransitDetailLastUpdated'] = date("Y-m-d H:i:s");
|
|
$arr_insert_mutation_transit_detail['MutasiTransitDetailUserID'] = 100000;
|
|
|
|
$qry = $this->db_inventory->insert('mutasitransitdetail', $arr_insert_mutation_transit_detail);
|
|
if(!$qry){
|
|
echo $this->db_inventory->last_query();
|
|
exit;
|
|
}
|
|
|
|
//$arr_inserted = $v;
|
|
}
|
|
|
|
array_push($arr_inserted,$v['MutasiTransitDetailID']);
|
|
|
|
}
|
|
$this->db_inventory->trans_complete();
|
|
$result = array( "records" => $arr_inserted);
|
|
$this->sys_ok($result);
|
|
}
|
|
|
|
|
|
|
|
} catch (Exception $exc) {
|
|
$message = $exc->getMessage();
|
|
$this->sys_error($message);
|
|
}
|
|
}
|
|
|
|
}
|