diff --git a/application/controllers/items.php b/application/controllers/items.php index 529777a73..5506fd526 100644 --- a/application/controllers/items.php +++ b/application/controllers/items.php @@ -37,20 +37,21 @@ class Items extends Secure_area implements iData_controller { $search = $this->input->post('search'); $this->item_lib->set_item_location($this->input->post('stock_location')); - $stock_location=$this->item_lib->get_item_location(); + $stock_location = $this->item_lib->get_item_location(); $data['search_section_state'] = $this->input->post('search_section_state'); - $low_inventory=$this->input->post('low_inventory'); - $is_serialized=$this->input->post('is_serialized'); - $no_description=$this->input->post('no_description'); - $search_custom=$this->input->post('search_custom'); - $is_deleted=$this->input->post('is_deleted'); // Parq 131215 + $empty_upc = $this->input->post('empty_upc'); + $low_inventory = $this->input->post('low_inventory'); + $is_serialized = $this->input->post('is_serialized'); + $no_description = $this->input->post('no_description'); + $search_custom = $this->input->post('search_custom'); + $is_deleted = $this->input->post('is_deleted'); // Parq 131215 $limit_from = $this->input->post('limit_from'); $lines_per_page = $this->Appconfig->get('lines_per_page'); - $items = $this->Item->search($search,$stock_location,$low_inventory,$is_serialized,$no_description,$search_custom,$is_deleted,$lines_per_page,$limit_from); - $data_rows=get_items_manage_table_data_rows($items,$this); - $total_rows = $this->Item->get_found_rows($search,$stock_location,$low_inventory,$is_serialized,$no_description,$search_custom,$is_deleted); + $items = $this->Item->search($search,$stock_location,$empty_upc,$low_inventory,$is_serialized,$no_description,$search_custom,$is_deleted,$lines_per_page,$limit_from); + $data_rows = get_items_manage_table_data_rows($items,$this); + $total_rows = $this->Item->get_found_rows($search,$stock_location,$empty_upc,$low_inventory,$is_serialized,$no_description,$search_custom,$is_deleted); $links = $this->_initialize_pagination($this->Item, $lines_per_page, $limit_from, $total_rows, 'search'); - $data_rows=get_items_manage_table_data_rows($items,$this); + $data_rows = get_items_manage_table_data_rows($items,$this); $this->_remove_duplicate_cookies(); echo json_encode(array('total_rows' => $total_rows, 'rows' => $data_rows, 'pagination' => $links)); } @@ -242,8 +243,7 @@ class Items extends Secure_area implements iData_controller { $quantity = $this->Item_quantities->get_item_quantity($item_id,$location['location_id'])->quantity; $quantity = ($item_id == -1) ? null: $quantity; - $location_array[$location['location_id']] = array('location_name'=>$location['location_name'], - 'quantity'=>$quantity); + $location_array[$location['location_id']] = array('location_name'=>$location['location_name'], 'quantity'=>$quantity); $data['stock_locations']= $location_array; } $this->load->view("items/form",$data); @@ -298,8 +298,8 @@ class Items extends Secure_area implements iData_controller // 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 with the newly generated barcode - if ($item['item_number'] == '') + // update the UPC/EAN/ISBN field if empty / null with the newly generated barcode + if ($item['item_number'] == '' || $item['item_number'] == null) { // get the newly generated barcode $item['item_number'] = $this->barcode_lib->get_barcode($item, $config); @@ -371,7 +371,7 @@ class Items extends Secure_area implements iData_controller 'allow_alt_description'=>$this->input->post('allow_alt_description'), 'is_serialized'=>$this->input->post('is_serialized'), 'deleted'=>$this->input->post('is_deleted'), /** Parq 131215 **/ - 'custom1'=>$this->input->post('custom1'), /**GARRISON ADDED 4/21/2013**/ + 'custom1'=>$this->input->post('custom1'),/**GARRISON ADDED 4/21/2013**/ 'custom2'=>$this->input->post('custom2'),/**GARRISON ADDED 4/21/2013**/ 'custom3'=>$this->input->post('custom3'),/**GARRISON ADDED 4/21/2013**/ 'custom4'=>$this->input->post('custom4'),/**GARRISON ADDED 4/21/2013**/ diff --git a/application/language/en/items_lang.php b/application/language/en/items_lang.php index c96a7f072..6a23dc8f5 100644 --- a/application/language/en/items_lang.php +++ b/application/language/en/items_lang.php @@ -41,6 +41,7 @@ $lang["items_item"] = "Item"; $lang["items_item_number"] = "UPC/EAN/ISBN"; $lang["items_item_number_duplicate"] = "The item number is already present in the database"; $lang["items_location"] = "Location"; +$lang["items_empty_upc_items"] = "Empty UPC Items"; $lang["items_low_inventory_items"] = "Out Of Stock Items"; $lang["items_manually_editing_of_quantity"] = "Manual Edit of Quantity"; $lang["items_must_select_item_for_barcode"] = "You must select at least 1 item to generate barcodes"; diff --git a/application/language/es/items_lang.php b/application/language/es/items_lang.php index 705cee4ef..a467d17b3 100644 --- a/application/language/es/items_lang.php +++ b/application/language/es/items_lang.php @@ -41,6 +41,7 @@ $lang["items_item"] = "Artículo"; $lang["items_item_number"] = "UPC/EAN/ISBN"; $lang["items_item_number_duplicate"] = "El número de artículo ya esta presente en la base de datos"; $lang["items_location"] = "Ubicación"; +$lang["items_empty_upc_items"] = "Empty UPC Items"; $lang["items_low_inventory_items"] = "Artículos de Inventario Escaso"; $lang["items_manually_editing_of_quantity"] = "Edición Manual de Cantidad"; $lang["items_must_select_item_for_barcode"] = "Debes seleccionar al menos 1 artículo para generar códigos de barras"; diff --git a/application/language/fr/items_lang.php b/application/language/fr/items_lang.php index 3906fbd9c..150462379 100644 --- a/application/language/fr/items_lang.php +++ b/application/language/fr/items_lang.php @@ -41,6 +41,7 @@ $lang["items_item"] = "Item"; $lang["items_item_number"] = "UPC/EAN/ISBN"; $lang["items_item_number_duplicate"] = "The item number is already present in the database"; $lang["items_location"] = "Location"; +$lang["items_empty_upc_items"] = "Empty UPC Items"; $lang["items_low_inventory_items"] = "Items à Stock Faible"; $lang["items_manually_editing_of_quantity"] = "Édition Manuelle de Quantité"; $lang["items_must_select_item_for_barcode"] = "Vous devez sélectionner au moins un item"; diff --git a/application/language/id/items_lang.php b/application/language/id/items_lang.php index 2c8198a33..c7b9d0ca2 100644 --- a/application/language/id/items_lang.php +++ b/application/language/id/items_lang.php @@ -41,6 +41,7 @@ $lang["items_item"] = "Item"; $lang["items_item_number"] = "Kode Barang"; $lang["items_item_number_duplicate"] = "The item number is already present in the database"; $lang["items_location"] = "Lokasi Barang"; +$lang["items_empty_upc_items"] = "Empty UPC Items"; $lang["items_low_inventory_items"] = "Daftar Stock Rendah"; $lang["items_manually_editing_of_quantity"] = "Perubahan jumlah Stok secara manual"; $lang["items_must_select_item_for_barcode"] = "Anda harus memilih minimal 1 item untuk membuat barcode"; diff --git a/application/language/nl-BE/items_lang.php b/application/language/nl-BE/items_lang.php index 37818982a..8b70ae8e8 100755 --- a/application/language/nl-BE/items_lang.php +++ b/application/language/nl-BE/items_lang.php @@ -41,6 +41,7 @@ $lang["items_item"] = "Product"; $lang["items_item_number"] = "UPC/EAN/ISBN"; $lang["items_item_number_duplicate"] = "De barcode nummer is reeds aanwezig in de database"; $lang["items_location"] = "Locatie"; +$lang["items_empty_upc_items"] = "Empty UPC Items"; $lang["items_low_inventory_items"] = "Producten niet in stock"; $lang["items_manually_editing_of_quantity"] = "Manuele aanpassing hoeveelheid"; $lang["items_must_select_item_for_barcode"] = "U moet ten minste 1 product selecteren om een barcode te genereren"; diff --git a/application/language/ru/items_lang.php b/application/language/ru/items_lang.php index 98d10cd2a..3aefe81fe 100644 --- a/application/language/ru/items_lang.php +++ b/application/language/ru/items_lang.php @@ -41,6 +41,7 @@ $lang["items_item"] = "Товар"; $lang["items_item_number"] = "UPC/EAN/ISBN"; $lang["items_item_number_duplicate"] = "The item number is already present in the database"; $lang["items_location"] = "место"; +$lang["items_empty_upc_items"] = "Empty UPC Items"; $lang["items_low_inventory_items"] = "Низкий инвентаризации товары"; $lang["items_manually_editing_of_quantity"] = "Руководство Изменить количество"; $lang["items_must_select_item_for_barcode"] = "Вы должны выбрать хотя бы 1 товар для создания штрих-кодов"; diff --git a/application/language/th/items_lang.php b/application/language/th/items_lang.php index ec3a7437d..f075e590d 100644 --- a/application/language/th/items_lang.php +++ b/application/language/th/items_lang.php @@ -41,6 +41,7 @@ $lang["items_item"] = "สินค้า"; $lang["items_item_number"] = "โค๊ด"; $lang["items_item_number_duplicate"] = "The item number is already present in the database"; $lang["items_location"] = "ที่ตั้ง"; +$lang["items_empty_upc_items"] = "Empty UPC Items"; $lang["items_low_inventory_items"] = "สินค้าคงเหลือน้อย"; $lang["items_manually_editing_of_quantity"] = "แก้ไขจำนวน"; $lang["items_must_select_item_for_barcode"] = "คุต้องเลือกสินค้าอย่างน้อยหนึ่งอย่างเพื่อจะสร้างบาร์โค๊ด"; diff --git a/application/language/tr/items_lang.php b/application/language/tr/items_lang.php index ec7dd485c..e3ae89279 100644 --- a/application/language/tr/items_lang.php +++ b/application/language/tr/items_lang.php @@ -41,6 +41,7 @@ $lang["items_item"] = "Ürün"; $lang["items_item_number"] = "UPC/EAN/ISBN"; $lang["items_item_number_duplicate"] = "The item number is already present in the database"; $lang["items_location"] = "Yer"; +$lang["items_empty_upc_items"] = "Empty UPC Items"; $lang["items_low_inventory_items"] = ""; $lang["items_manually_editing_of_quantity"] = "Elle adet düzeltme"; $lang["items_must_select_item_for_barcode"] = "Barkod üretmek için en az bir ürün seçmelisiniz"; diff --git a/application/language/zh/items_lang.php b/application/language/zh/items_lang.php index 426a8fd8c..b938c985e 100755 --- a/application/language/zh/items_lang.php +++ b/application/language/zh/items_lang.php @@ -41,6 +41,7 @@ $lang["items_item"] = "產品"; $lang["items_item_number"] = "UPC/EAN/ISBN"; $lang["items_item_number_duplicate"] = "The item number is already present in the database"; $lang["items_location"] = "位置"; +$lang["items_empty_upc_items"] = "Empty UPC Items"; $lang["items_low_inventory_items"] = "低庫存產品"; $lang["items_manually_editing_of_quantity"] = "手動編輯數量"; $lang["items_must_select_item_for_barcode"] = "您必須至少選擇一個產品生才能產生條碼"; diff --git a/application/libraries/Barcode_lib.php b/application/libraries/Barcode_lib.php index c9c9b6962..e62c3b4a6 100644 --- a/application/libraries/Barcode_lib.php +++ b/application/libraries/Barcode_lib.php @@ -42,7 +42,7 @@ class Barcode_lib return $data; } - private function _get_barcode_instance($barcode_type) + private function get_barcode_instance($barcode_type) { switch($barcode_type) { @@ -69,7 +69,7 @@ class Barcode_lib { try { - $barcode = $this->_get_barcode_instance($barcode_config['barcode_type']); + $barcode = $this->get_barcode_instance($barcode_config['barcode_type']); $barcode_content = $barcode_config['barcode_content'] !== "id" && isset($item['item_number']) ? $item['item_number'] : $item['item_id']; $barcode->setData($barcode_content); @@ -90,12 +90,20 @@ class Barcode_lib { try { - $barcode = $this->_get_barcode_instance($barcode_config['barcode_type']); + $barcode = $this->get_barcode_instance($barcode_config['barcode_type']); $barcode_content = $barcode_config['barcode_content'] !== "id" && isset($item['item_number']) ? $item['item_number'] : $item['item_id']; $barcode->setData($barcode_content); - return $barcode->getData(); + $code = $barcode->getData(); + + // in case no new code is generated like in Code39 and Code128 return an empty string because we don't want to override it with a pure item_id + if( $code == $item['item_id'] ) + { + $code = null; + } + + return $code; } catch(Exception $e) { diff --git a/application/models/item.php b/application/models/item.php index 40e43646f..bf4b0b150 100644 --- a/application/models/item.php +++ b/application/models/item.php @@ -7,13 +7,13 @@ class Item extends CI_Model function exists($item_id) { $this->db->from('items'); - $this->db->where('item_id',$item_id); + $this->db->where('item_id', $item_id); $query = $this->db->get(); return ($query->num_rows()==1); } - function item_number_exists($item_number,$item_id='') + function item_number_exists($item_number, $item_id='') { $this->db->from('items'); $this->db->where('item_number', $item_number); @@ -32,7 +32,7 @@ class Item extends CI_Model return $this->db->count_all_results(); } - function get_found_rows($search,$stock_location_id=-1,$low_inventory=0,$is_serialized=0,$no_description=0,$search_custom=0,$is_deleted=0) + function get_found_rows($search, $stock_location_id=-1, $empty_upc=0, $low_inventory=0, $is_serialized=0, $no_description=0, $search_custom=0, $is_deleted=0) { $this->db->from("items"); $this->db->join('suppliers', 'suppliers.person_id = items.supplier_id', 'left'); @@ -66,17 +66,21 @@ class Item extends CI_Model } } $this->db->where('items.deleted', $is_deleted); - if ($low_inventory !=0 ) + if ($empty_upc !=0) + { + $this->db->where('item_number', null); + } + if ($low_inventory !=0) { $this->db->where('quantity <=', 'reorder_level'); } - if ($is_serialized !=0 ) + if ($is_serialized !=0) { $this->db->where('is_serialized', 1); } - if ($no_description!=0 ) + if ($no_description!=0) { - $this->db->where('items.description',''); + $this->db->where('items.description', ''); } return $this->db->get()->num_rows(); } @@ -110,7 +114,7 @@ class Item extends CI_Model $this->db->select('suppliers.company_name'); $this->db->from('items'); $this->db->join('suppliers', 'suppliers.person_id = items.supplier_id', 'left'); - $this->db->where('item_id',$item_id); + $this->db->where('item_id', $item_id); $query = $this->db->get(); @@ -142,8 +146,8 @@ class Item extends CI_Model { $this->db->from('items'); $this->db->join('suppliers', 'suppliers.person_id = items.supplier_id', 'left'); - $this->db->where('item_number',$item_number); - $this->db->where('items.deleted',0); // Parq 131226 + $this->db->where('item_number', $item_number); + $this->db->where('items.deleted', 0); // Parq 131226 $query = $this->db->get(); @@ -611,14 +615,14 @@ class Item extends CI_Model /* Persform a search on items */ - function search($search,$stock_location_id=-1,$low_inventory=0,$is_serialized=0,$no_description=0,$search_custom=0,$deleted=0,$rows = 0,$limit_from = 0) + function search($search, $stock_location_id=-1, $empty_upc=0, $low_inventory=0, $is_serialized=0, $no_description=0, $search_custom=0, $deleted=0, $rows = 0, $limit_from = 0) { $this->db->from("items"); $this->db->join('suppliers', 'suppliers.person_id = items.supplier_id', 'left'); if ($stock_location_id > -1) { - $this->db->join('item_quantities','item_quantities.item_id=items.item_id'); - $this->db->where('location_id',$stock_location_id); + $this->db->join('item_quantities', 'item_quantities.item_id=items.item_id'); + $this->db->where('location_id', $stock_location_id); } if (!empty($search)) { @@ -645,17 +649,21 @@ class Item extends CI_Model } } $this->db->where('items.deleted', $deleted); - if ($low_inventory !=0 ) + if ($empty_upc !=0) + { + $this->db->where('item_number', null); + } + if ($low_inventory !=0) { $this->db->where('quantity <=', 'reorder_level'); } - if ($is_serialized !=0 ) + if ($is_serialized !=0) { $this->db->where('is_serialized', 1); } - if ($no_description!=0 ) + if ($no_description!=0) { - $this->db->where('items.description',''); + $this->db->where('items.description', ''); } $this->db->order_by('items.name', "asc"); if ($rows > 0) { diff --git a/application/views/items/manage.php b/application/views/items/manage.php index 027115721..241cd3707 100644 --- a/application/views/items/manage.php +++ b/application/views/items/manage.php @@ -153,6 +153,8 @@ function show_hide_search_filter(search_filter_section, switchImgTag) { 'search_form')); ?>