Ejemplo n.º 1
0
 public function delete_item($item_id)
 {
     $deliveries_repo = new Deliveries_Repository($this->db);
     if ($deliveries_repo->is_item_already_delivered($item_id)) {
         return false;
     } else {
         $this->db->delete('items', array('id' => $item_id));
         return true;
     }
 }
 public function generate_delivery_data_post()
 {
     $file_path = $this->input->post('filePath');
     // e:\sample_path.json
     $delivery_id = $this->input->post('deliveryId');
     $deliveries_repo = new Deliveries_Repository($this->base_model->get_db_instance());
     $delivery_data = $deliveries_repo->to_delivery_json($delivery_id);
     $enc = new Encryption();
     $file_size = file_put_contents($file_path, $enc->encrypt($delivery_data));
     if ($file_size >= 1) {
         $deliveries_repo->update_delivery_status($delivery_id, Delivery_Status::Success);
     } else {
         $deliveries_repo->update_delivery_status($delivery_id, Delivery_Status::Failed);
     }
     echo $file_size;
     // if >= 1, write is successful
 }
Ejemplo n.º 3
0
 public function is_transaction_valid_post()
 {
     $main_id = $this->input->post('mainId');
     $branch_id = $this->input->post('branchId');
     $delivery_id_from_main = $this->input->post('deliveryIdFromMain');
     $transaction = $this->input->post('transaction');
     $settings_repo = new Settings_Repository($this->base_model->get_db_instance());
     $deliveries_repo = new Deliveries_Repository($this->base_model->get_db_instance());
     if ($transaction == Transaction_Type::Deliver_Items) {
         if ($settings_repo->get_settings()->main_id != $main_id) {
             echo -2;
         } else {
             if ($settings_repo->get_settings()->app_id != $branch_id) {
                 echo -1;
             } else {
                 if ($deliveries_repo->delivery_exists_via_delivery_id_from_main($delivery_id_from_main)) {
                     echo 0;
                 } else {
                     echo 2;
                 }
             }
         }
         // valid delivery
     } else {
         echo 1;
         // invalid transaction
     }
 }
Ejemplo n.º 4
0
 public function get_all_items_from_this_delivery_post()
 {
     $deliveries_repo = new Deliveries_Repository($this->base_model->get_db_instance());
     $delivered_items = $deliveries_repo->get_all_items_from_delivery($this->input->post('deliveryId'));
     $data = array();
     foreach ($delivered_items as $delivered_item) {
         $items_repo = new Items_Repository($this->base_model->get_db_instance());
         $item = $items_repo->get_item($delivered_item->item_id);
         array_push($data, array('id' => $delivered_item->id, 'delivery_id' => $delivered_item->delivery_id, 'item_id' => $delivered_item->item_id, 'description' => $item->description, 'quantity' => $delivered_item->quantity));
     }
     echo json_encode($data);
 }