Пример #1
0
 public function get_supplier($facility_code = NULL)
 {
     //Get Supplier Based on Facility
     $facility = Facilities::getSupplier($facility_code);
     return strtolower($facility->supplier->name);
 }
Пример #2
0
 public function view_order($type = "cdrr", $id)
 {
     if ($type == "cdrr") {
         $cdrr_array = array();
         $sql = "SELECT c.*,ci.*,f.*,co.county as county_name,d.name as district_name,IF(c.code='D-CDRR',CONCAT('D-CDRR#',c.id),CONCAT('F-CDRR#',c.id)) as cdrr_label,c.status as status_name,sf.name as facility_name,ci.id as item_id,sf.code as facility_code\n\t\t\t\tFROM cdrr c\n\t\t\t\tLEFT JOIN cdrr_item ci ON ci.cdrr_id=c.id\n\t\t\t\tLEFT JOIN sync_facility sf ON sf.id=c.facility_id\n\t\t\t\tLEFT JOIN facilities f ON f.facilitycode=sf.code\n\t\t\t\tLEFT JOIN counties co ON co.id=f.county\n\t\t\t\tLEFT JOIN district d ON d.id=f.district\n\t\t\t\tWHERE c.id='{$id}'";
         $query = $this->db->query($sql);
         $cdrr_array = $query->result_array();
         $data['cdrr_array'] = $cdrr_array;
         $data['options'] = "view";
         //echo "<pre>"; print_r($cdrr_array); die;
         if ($cdrr_array[0]['code'] == "D-CDRR") {
             $code = 0;
         } else {
             if ($cdrr_array[0]['code'] == "F-CDRR_units") {
                 $facility_code = $this->session->userdata("facility");
                 if ($cdrr_array[0]['facility_code'] == $facility_code) {
                     $code = 1;
                 } else {
                     $code = 2;
                 }
             } else {
                 if ($cdrr_array[0]['code'] == "F-CDRR_packs") {
                     $code = 3;
                 }
             }
         }
         $this->create_order($type, $code, $data);
     } else {
         if ($type == "maps") {
             //
             $facility_code = $this->session->userdata('facility');
             $facility = Facilities::getSupplier($facility_code);
             $supplier = $facility->supplier->name;
             $facility_table = 'sync_facility';
             $fmaps_array = array();
             $sql = "SELECT m.*,mi.*,ml.*,f.*,co.county as county_name,d.name as district_name,IF(m.code='D-MAPS',CONCAT('D-MAPS#',m.id),CONCAT('F-MAPS#',m.id)) as maps_id,m.status as status_name,sf.name as facility_name,m.id as map_id,sf.code as facility_code\n\t\t\t \tFROM maps m\n\t\t\t \tLEFT JOIN maps_item mi ON mi.maps_id=m.id\n\t\t\t \tLEFT JOIN maps_log ml ON ml.maps_id=m.id\n\t\t\t \tLEFT JOIN {$facility_table} sf ON sf.id=m.facility_id\n\t\t\t\tLEFT JOIN facilities f ON f.facilitycode=sf.code\n\t\t\t \tLEFT JOIN counties co ON co.id=f.county\n\t\t\t\tLEFT JOIN district d ON d.id=f.district\n\t\t\t\tWHERE m.id='{$id}'";
             $query = $this->db->query($sql);
             $fmaps_array = $query->result_array();
             $data['fmaps_array'] = $fmaps_array;
             $data['options'] = "view";
             if ($fmaps_array[0]['code'] == "D-MAPS") {
                 $code = 0;
             } else {
                 if ($fmaps_array[0]['code'] == "F-MAPS") {
                     $facility_code = $this->session->userdata("facility");
                     $facility_type = Facilities::getType($facility_code);
                     if ($facility_type == 1) {
                         $code = 3;
                     } else {
                         if ($facility_type == 0) {
                             $code = 2;
                         } else {
                             $code = 1;
                         }
                     }
                 }
             }
             $this->create_order($type, $code, $data);
         }
     }
 }