Batch 6a: application controllers base
This commit is contained in:
65
application/controllers/nasacom/Downloaddata.php
Normal file
65
application/controllers/nasacom/Downloaddata.php
Normal file
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
class Downloaddata extends MY_Controller
|
||||
{
|
||||
var $db;
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_onedev = $this->load->database("nasional", true);
|
||||
|
||||
}
|
||||
|
||||
function downloadfromnational()
|
||||
{
|
||||
try {
|
||||
header("Content-Type:application/json");
|
||||
$datas = json_decode(file_get_contents('php://input'), true);
|
||||
|
||||
//print_r($datas);
|
||||
if($datas){
|
||||
$this->db_onedev->trans_start();
|
||||
$this->db_onedev->trans_strict(FALSE);
|
||||
|
||||
|
||||
|
||||
$nat_mou_data = $datas;
|
||||
unset($nat_mou_data['Nat_CompanyNumber']);
|
||||
unset($nat_mou_data['prices']);
|
||||
unset($nat_mou_data['packets']);
|
||||
unset($nat_mou_data['packetdetails']);
|
||||
$this->db_onedev->insert('nas_nat_mou', $nat_mou_data);
|
||||
//echo $this->db_onedev->last_query();
|
||||
$prices = $datas['prices'];
|
||||
//print_r($prices);
|
||||
foreach ($prices as $k_price => $v_price) {
|
||||
$this->db_onedev->insert('nas_t_price', $v_price);
|
||||
//echo $this->db_onedev->last_query();
|
||||
}
|
||||
|
||||
$packets = $datas['packets'];
|
||||
foreach ($packets as $k_packet => $v_packet) {
|
||||
$this->db_onedev->insert('nas_t_packet', $v_packet);
|
||||
}
|
||||
|
||||
$packetdetails = $datas['packetdetails'];
|
||||
foreach ($packetdetails as $k_packetdetails => $v_packetdetail) {
|
||||
$this->db_onedev->insert('nas_t_packetdetail', $v_packetdetail);
|
||||
}
|
||||
|
||||
|
||||
array_push($arr_inserted,$v['MutasiTransitDetailID']);
|
||||
|
||||
$this->db_onedev->trans_complete();
|
||||
$result = array( "records" => $nat_mou_data);
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
|
||||
|
||||
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user