Esempio n. 1
0
 public function read_order($type = "cdrr", $id)
 {
     $main_array = array();
     $status = 'deleted';
     $log_array = array();
     if ($type == "cdrr") {
         $results = Cdrr::getCdrr($id);
         $main_array = $results[0];
         $main_array["ownCdrr_item"] = Cdrr_Item::getItems($id);
         $logs = Cdrr_Log::getHydratedLogs($id);
         $log_array['id'] = "";
         $log_array['description'] = $status;
         $log_array['created'] = date('Y-m-d H:i:s');
         $log_array['user_id'] = $this->session->userdata("user_id");
         $log_array['cdrr_id'] = $id;
         $logs[] = $log_array;
         $main_array['ownCdrr_log'] = $logs;
     } else {
         if ($type == "maps") {
             $results = Maps::getMap($id);
             $main_array = $results[0];
             $main_array["ownMaps_item"] = Maps_Item::getItems($id);
             $logs = Maps_Log::getHydratedLogs($id);
             $log_array['id'] = "";
             $log_array['description'] = $status;
             $log_array['created'] = date('Y-m-d H:i:s');
             $log_array['user_id'] = $this->session->userdata("user_id");
             $log_array['maps_id'] = $id;
             $logs[] = $log_array;
             $main_array['ownMaps_log'] = $logs;
         }
     }
     $main_array['status'] = $status;
     $main_array = array($main_array);
     $id = $this->extract_order($type, $main_array, $id);
     $this->session->set_flashdata('order_delete', "Your " . strtoupper($type) . " data was successfully " . $status . " !");
     redirect("order");
 }
Esempio n. 2
0
 public function read_order($type = "cdrr", $id)
 {
     $main_array = array();
     $status = 'deleted';
     $log_array = array();
     if ($type == "cdrr") {
         $results = Cdrr::getCdrr($id);
         $main_array = $results[0];
         $main_array["ownCdrr_item"] = Cdrr_Item::getItems($id);
         $logs = Cdrr_Log::getHydratedLogs($id);
         $log_array['id'] = "";
         $log_array['description'] = $status;
         $log_array['created'] = date('Y-m-d H:i:s');
         $log_array['user_id'] = $this->session->userdata("api_id");
         $log_array['cdrr_id'] = $id;
         $logs[] = $log_array;
         $main_array['ownCdrr_log'] = $logs;
     } else {
         if ($type == "maps") {
             $results = Maps::getMap($id);
             $main_array = $results[0];
             $main_array["ownMaps_item"] = Maps_Item::getItems($id);
             $logs = Maps_Log::getHydratedLogs($id);
             $log_array['id'] = "";
             $log_array['description'] = $status;
             $log_array['created'] = date('Y-m-d H:i:s');
             $log_array['user_id'] = $this->session->userdata("api_id");
             $log_array['maps_id'] = $id;
             $logs[] = $log_array;
             $main_array['ownMaps_log'] = $logs;
         }
     }
     $main_array['status'] = $status;
     $main_array = array($main_array);
     //format to json
     $json_data = json_encode($main_array, JSON_PRETTY_PRINT);
     //get supplier
     $facility_code = $this->session->userdata("facility");
     $supplier = $this->get_supplier($facility_code);
     //save links
     if ($supplier != "KEMSA") {
         //Go to escm
         $url = $this->esm_url . $type . "/" . $id;
         $responses = $this->put_order($url, $json_data);
     } else {
         //Go to nascop
         $target_url = "sync/save/nascop/" . $type . "/" . $id;
         $url = $this->nascop_url . $target_url;
         $responses = $this->post_order($url, $json_data, $supplier);
     }
     $responses = json_decode($responses, TRUE);
     if (is_array($responses)) {
         if (!empty($responses)) {
             $id = $this->extract_order($type, $responses, $id);
             $this->session->set_flashdata('order_delete', "Your " . strtoupper($type) . " data was successfully " . $status . " !");
         } else {
             $this->session->set_flashdata('order_delete', "Your " . strtoupper($type) . " data was empty cannot be " . $status . " !");
         }
     } else {
         $this->session->set_flashdata('order_delete', "Your " . strtoupper($type) . " cannot be deleted!");
     }
     redirect("order");
 }