Beispiel #1
0
 public function generate_barcodes($item_ids)
 {
     $this->load->library('barcode_lib');
     $item_ids = explode(':', $item_ids);
     $result = $this->Item->get_multiple_info($item_ids, $this->item_lib->get_item_location())->result_array();
     $config = $this->barcode_lib->get_barcode_config();
     $data['barcode_config'] = $config;
     // check the list of items to see if any item_number field is empty
     foreach ($result as &$item) {
         $item = $this->xss_clean($item);
         // update the UPC/EAN/ISBN field if empty / NULL with the newly generated barcode
         if (empty($item['item_number']) && $this->Appconfig->get('barcode_generate_if_empty')) {
             // get the newly generated barcode
             $barcode_instance = Barcode_lib::barcode_instance($item, $config);
             $item['item_number'] = $barcode_instance->getData();
             $save_item = array('item_number' => $item['item_number']);
             // update the item in the database in order to save the UPC/EAN/ISBN field
             $this->Item->save($save_item, $item['item_id']);
         }
     }
     $data['items'] = $result;
     // display barcodes
     $this->load->view('barcodes/barcode_sheet', $data);
 }
Beispiel #2
0
 function generate_barcodes($item_ids)
 {
     $this->load->library('barcode_lib');
     $result = array();
     $item_ids = explode(':', $item_ids);
     $result = $this->Item->get_multiple_info($item_ids)->result_array();
     $config = $this->barcode_lib->get_barcode_config();
     $data['barcode_config'] = $config;
     // check the list of items to see if any item_number field is empty
     foreach ($result as &$item) {
         // update the UPC/EAN/ISBN field if empty / null with the newly generated barcode
         if (empty($item['item_number']) && $this->Appconfig->get('barcode_generate_if_empty')) {
             // get the newly generated barcode
             $barcode_instance = Barcode_lib::barcode_instance($item, $config);
             $item['item_number'] = $barcode_instance->getData();
             // remove from item any suppliers table info to avoid save failure because of unknown fields
             // WARNING: if suppliers table is changed this list needs to be upgraded, which makes the matter a bit tricky to maintain
             unset($item['person_id']);
             unset($item['company_name']);
             unset($item['account_number']);
             unset($item['agency_name']);
             // update the item in the database in order to save the UPC/EAN/ISBN field
             $this->Item->save($item, $item['item_id']);
         }
     }
     $data['items'] = $result;
     // display barcodes
     $this->load->view("barcode_sheet", $data);
 }
Beispiel #3
0
 private function generate_barcode($item, $barcode_config)
 {
     try {
         $barcode_instance = Barcode_lib::barcode_instance($item, $barcode_config);
         $barcode_instance->setQuality($barcode_config['barcode_quality']);
         $barcode_instance->setDimensions($barcode_config['barcode_width'], $barcode_config['barcode_height']);
         $barcode_instance->draw();
         return $barcode_instance->base64();
     } catch (Exception $e) {
         echo 'Caught exception: ', $e->getMessage(), "\n";
     }
 }