diff --git a/.gitignore b/.gitignore index 1ce5a940a..e321dc105 100644 --- a/.gitignore +++ b/.gitignore @@ -12,3 +12,4 @@ git-svn-diff.py *.rej *.orig *~ +uploads/ diff --git a/application/controllers/items.php b/application/controllers/items.php index 0aec46ebc..32706233c 100644 --- a/application/controllers/items.php +++ b/application/controllers/items.php @@ -305,6 +305,8 @@ class Items extends Secure_area implements iData_controller function save($item_id=-1) { + $upload_success = $this->_handle_image_upload(); + $upload_data = $this->upload->data(); //Save item data $item_data = array( 'name'=>$this->input->post('name'), @@ -318,6 +320,7 @@ class Items extends Secure_area implements iData_controller 'receiving_quantity'=>$this->input->post('receiving_quantity'), 'allow_alt_description'=>$this->input->post('allow_alt_description'), 'is_serialized'=>$this->input->post('is_serialized'), + 'pic_id'=>$upload_data['raw_name'], 'deleted'=>$this->input->post('is_deleted'), /** Parq 131215 **/ 'custom1'=>$this->input->post('custom1'), /**GARRISON ADDED 4/21/2013**/ 'custom2'=>$this->input->post('custom2'),/**GARRISON ADDED 4/21/2013**/ @@ -334,22 +337,16 @@ class Items extends Secure_area implements iData_controller $employee_id=$this->Employee->get_logged_in_employee_info()->person_id; $cur_item_info = $this->Item->get_info($item_id); - $new_item = FALSE; if($this->Item->save($item_data,$item_id)) { + $success = TRUE; + $new_item = FALSE; //New item if($item_id==-1) { - echo json_encode(array('success'=>true,'message'=>$this->lang->line('items_successful_adding').' '. - $item_data['name'],'item_id'=>$item_data['item_id'])); $item_id = $item_data['item_id']; $new_item = TRUE; } - else //previous item - { - echo json_encode(array('success'=>true,'message'=>$this->lang->line('items_successful_updating').' '. - $item_data['name'],'item_id'=>$item_id)); - } $items_taxes_data = array(); $tax_names = $this->input->post('tax_names'); @@ -361,7 +358,7 @@ class Items extends Secure_area implements iData_controller $items_taxes_data[] = array('name'=>$tax_names[$k], 'percent'=>$tax_percents[$k] ); } } - $this->Item_taxes->save($items_taxes_data, $item_id); + $success &= $this->Item_taxes->save($items_taxes_data, $item_id); //Save item quantity @@ -375,7 +372,7 @@ class Items extends Secure_area implements iData_controller $item_quantity = $this->Item_quantities->get_item_quantity($item_id, $location_data['location_id']); if ($item_quantity->quantity != $updated_quantity || $new_item) { - $this->Item_quantities->save($location_detail, $item_id, $location_data['location_id']); + $success &= $this->Item_quantities->save($location_detail, $item_id, $location_data['location_id']); $inv_data = array ( @@ -386,18 +383,50 @@ class Items extends Secure_area implements iData_controller 'trans_comment'=>$this->lang->line('items_manually_editing_of_quantity'), 'trans_inventory'=>$updated_quantity - $item_quantity->quantity ); - $this->Inventory->insert($inv_data); + $success &= $this->Inventory->insert($inv_data); } } + + if ($success && $upload_success) + { + $success_message = $this->lang->line('items_successful_' . ($new_item ? 'adding' : 'updating')) .' '. $item_data['name']; + echo json_encode(array('success'=>true,'message'=>$success_message,'item_id'=>$item_id)); + } + else + { + $error_message = $upload_success ? + $this->lang->line('items_error_adding_updating') .' '. $item_data['name'] : + $this->upload->display_errors(); + echo json_encode(array('success'=>false,'message'=>$error_message,'item_id'=>$item_id)); + } + } else//failure { echo json_encode(array('success'=>false,'message'=>$this->lang->line('items_error_adding_updating').' '. - $item_data['name'],'item_id'=>-1)); + $item_data['name'],'item_id'=>-1)); } } + function _handle_image_upload() + { + $this->load->helper('directory'); + $map = directory_map('./uploads/item_pics/', 1); + // load upload library + $config = array('upload_path' => './uploads/item_pics/', + 'allowed_types' => 'gif|jpg|png', + 'max_size' => '100', + 'max_width' => '1024', + 'max_height' => '768', + 'file_name' => sizeof($map)); + $this->load->library('upload', $config); + $this->upload->do_upload('item_image'); + return strlen($this->upload->display_errors()) == 0 || + !strcmp($this->upload->display_errors(), + '

'.$this->lang->line('upload_no_file_selected').'

'); + } + //Ramel Inventory Tracking function save_inventory($item_id=-1) { @@ -671,7 +700,7 @@ class Items extends Secure_area implements iData_controller */ function get_form_width() { - return 360; + return 400; } function item_number_check($item_number) diff --git a/application/helpers/table_helper.php b/application/helpers/table_helper.php index 6ecb80354..29c13929f 100644 --- a/application/helpers/table_helper.php +++ b/application/helpers/table_helper.php @@ -162,7 +162,8 @@ function get_items_manage_table($items,$controller) $CI->lang->line('items_quantity'), $CI->lang->line('items_tax_percents'), ' ', - $CI->lang->line('items_inventory') + ' ', + ' ' ); $table.=''; @@ -191,7 +192,7 @@ function get_items_manage_table_data_rows($items,$controller) if($items->num_rows()==0) { - $table_data_rows.="
".$CI->lang->line('items_no_items_to_display')."
"; + $table_data_rows.="
".$CI->lang->line('items_no_items_to_display')."
"; } return $table_data_rows; @@ -220,7 +221,17 @@ function get_item_data_row($item,$controller) $table_data_row.=''.to_currency($item->cost_price).''; $table_data_row.=''.to_currency($item->unit_price).''; $table_data_row.=''.$item->quantity.''; - $table_data_row.=''.$tax_percents.''; + $table_data_row.=''.$tax_percents.''; + $image = ''; + if (!empty($item->pic_id)) + { + $images = glob ("uploads/item_pics/" . $item->pic_id . ".*"); + if (sizeof($images) > 0) + { + $image.=''; + } + } + $table_data_row.='' . $image . ''; $table_data_row.=''.anchor($controller_name."/view/$item->item_id/width:$width", $CI->lang->line('common_edit'),array('class'=>'thickbox','title'=>$CI->lang->line($controller_name.'_update'))).''; //Ramel Inventory Tracking diff --git a/application/language/en/items_lang.php b/application/language/en/items_lang.php index fd8c6473d..cd740d9fd 100644 --- a/application/language/en/items_lang.php +++ b/application/language/en/items_lang.php @@ -79,3 +79,4 @@ $lang["items_unit_price_required"] = "Retail Price is a required field"; $lang["items_upc_database"] = "UPC Database"; $lang["items_update"] = "Update Item"; $lang["items_use_inventory_menu"] = "Use Inv. Menu"; +$lang["items_image"] = "Avatar"; diff --git a/application/language/es/items_lang.php b/application/language/es/items_lang.php index 0a0b51f8b..52724bfb2 100644 --- a/application/language/es/items_lang.php +++ b/application/language/es/items_lang.php @@ -79,3 +79,4 @@ $lang["items_unit_price_required"] = "Precio de Venta es requerido"; $lang["items_upc_database"] = "Base de datos UPC"; $lang["items_update"] = "Actualizar Artículo"; $lang["items_use_inventory_menu"] = "Usar Menú de Inventario"; +$lang["items_image"] = ""; diff --git a/application/language/fr/items_lang.php b/application/language/fr/items_lang.php index fc0ab0cfb..959b5b265 100644 --- a/application/language/fr/items_lang.php +++ b/application/language/fr/items_lang.php @@ -79,3 +79,4 @@ $lang["items_unit_price_required"] = "Le Prix de revente est requis"; $lang["items_upc_database"] = "Base de Données UPC"; $lang["items_update"] = "Éditer Item"; $lang["items_use_inventory_menu"] = "Utiliser Menu Inv."; +$lang["items_image"] = ""; diff --git a/application/language/id/items_lang.php b/application/language/id/items_lang.php index ac3483448..b0142902b 100644 --- a/application/language/id/items_lang.php +++ b/application/language/id/items_lang.php @@ -79,3 +79,4 @@ $lang["items_unit_price_required"] = "Harga Jual wajib diisi"; $lang["items_upc_database"] = "Database UPC"; $lang["items_update"] = "Ubah"; $lang["items_use_inventory_menu"] = "Gunakan Inv. Menu"; +$lang["items_image"] = ""; diff --git a/application/language/nl-BE/items_lang.php b/application/language/nl-BE/items_lang.php index 5297919e9..7ddf9778f 100755 --- a/application/language/nl-BE/items_lang.php +++ b/application/language/nl-BE/items_lang.php @@ -79,3 +79,4 @@ $lang["items_unit_price_required"] = "Verkoopprijs moet ingevuld worden"; $lang["items_upc_database"] = "UPC Database"; $lang["items_update"] = "Bewerk Product"; $lang["items_use_inventory_menu"] = "Use Inv. Menu"; +$lang["items_image"] = "Afbeelding"; diff --git a/application/language/ru/items_lang.php b/application/language/ru/items_lang.php index 4f2e32216..eba522d8a 100644 --- a/application/language/ru/items_lang.php +++ b/application/language/ru/items_lang.php @@ -79,3 +79,4 @@ $lang["items_unit_price_required"] = "Розничная цена обязате $lang["items_upc_database"] = "UPC база данных"; $lang["items_update"] = "Обновить Товар"; $lang["items_use_inventory_menu"] = "Используйте меню инвентаря"; +$lang["items_image"] = ""; diff --git a/application/language/th/items_lang.php b/application/language/th/items_lang.php index 4fe7187b9..f4b3332ac 100644 --- a/application/language/th/items_lang.php +++ b/application/language/th/items_lang.php @@ -79,3 +79,4 @@ $lang["items_unit_price_required"] = "ราคาต่อหน่วยต้ $lang["items_upc_database"] = "UPC ฐานข้อมูล"; $lang["items_update"] = "ปรับแต่งสินค้า"; $lang["items_use_inventory_menu"] = "ใช้เมนูสินค้าคงเหลือ"; +$lang["items_image"] = ""; diff --git a/application/language/tr/items_lang.php b/application/language/tr/items_lang.php index f6e4d36e5..87830bd27 100644 --- a/application/language/tr/items_lang.php +++ b/application/language/tr/items_lang.php @@ -79,3 +79,4 @@ $lang["items_unit_price_required"] = "Satış Fiyatı zorunlu alandır"; $lang["items_upc_database"] = "UPC Veritabanı"; $lang["items_update"] = "Ürün Güncelle"; $lang["items_use_inventory_menu"] = "Stok Menüsünü Kullan"; +$lang["items_image"] = ""; diff --git a/application/language/zh/items_lang.php b/application/language/zh/items_lang.php index 0298041ab..f3ad71888 100755 --- a/application/language/zh/items_lang.php +++ b/application/language/zh/items_lang.php @@ -79,3 +79,4 @@ $lang["items_unit_price_required"] = "單價為必填欄位"; $lang["items_upc_database"] = "UPC Database"; $lang["items_update"] = "更新產品"; $lang["items_use_inventory_menu"] = "使用庫存清單"; +$lang["items_image"] = ""; diff --git a/application/models/item_taxes.php b/application/models/item_taxes.php index 18033baa7..badc43b7a 100644 --- a/application/models/item_taxes.php +++ b/application/models/item_taxes.php @@ -21,15 +21,15 @@ class Item_taxes extends CI_Model $this->db->trans_start(); $this->delete($item_id); - + $result = TRUE; foreach ($items_taxes_data as $row) { $row['item_id'] = $item_id; - $this->db->insert('items_taxes',$row); + $result &= $this->db->insert('items_taxes',$row); } $this->db->trans_complete(); - return true; + return $result; } function save_multiple(&$items_taxes_data, $item_ids) diff --git a/application/views/items/form.php b/application/views/items/form.php index 4ae726a77..a66336bb4 100644 --- a/application/views/items/form.php +++ b/application/views/items/form.php @@ -1,7 +1,7 @@
lang->line('common_fields_required_message'); ?>
item_id,array('id'=>'item_form')); +echo form_open('items/save/'.$item_info->item_id,array('id'=>'item_form', 'enctype'=>'multipart/form-data')); ?>
lang->line("items_basic_information"); ?> @@ -170,6 +170,13 @@ foreach($stock_locations as $key=>$location_detail) +
+lang->line('items_image').':', 'item_image',array('class'=>'wide')); ?> +
+ +
+
+
lang->line('items_allow_alt_description').':', 'allow_alt_description',array('class'=>'wide')); ?>
@@ -365,8 +372,8 @@ if($this->config->item('custom10_name') != NULL) 'submit', - 'id'=>'submit', + 'name'=>'submit_form', + 'id'=>'submit_form', 'value'=>$this->lang->line('common_submit'), 'class'=>'submit_button float_right') ); diff --git a/database/2.3.1_to_2.3.2.sql b/database/2.3.1_to_2.3.2.sql index 9c381a4df..35c26c62e 100644 --- a/database/2.3.1_to_2.3.2.sql +++ b/database/2.3.1_to_2.3.2.sql @@ -13,3 +13,7 @@ INSERT INTO `ospos_permissions` (permission_id, module_id, location_id) INSERT INTO `ospos_permissions` (permission_id, module_id, location_id) (SELECT CONCAT('receivings_', location_name), 'receivings', location_id FROM ospos_stock_locations); +-- add item_pic column to items table +ALTER TABLE `ospos_items` + ADD COLUMN `item_pic` int(10) DEFAULT NULL; + diff --git a/database/database.sql b/database/database.sql index a5d8f414d..77a5a0841 100644 --- a/database/database.sql +++ b/database/database.sql @@ -155,6 +155,7 @@ CREATE TABLE `ospos_items` ( `reorder_level` decimal(15,2) NOT NULL DEFAULT '0', `receiving_quantity` int(11) NOT NULL DEFAULT '1', `item_id` int(10) NOT NULL AUTO_INCREMENT, + `pic_id` int(10) DEFAULT NULL, `allow_alt_description` tinyint(1) NOT NULL, `is_serialized` tinyint(1) NOT NULL, `deleted` int(1) NOT NULL DEFAULT '0', diff --git a/system/language/en/upload_lang.php b/system/language/en/upload_lang.php index 4de9e9e74..49119df86 100644 --- a/system/language/en/upload_lang.php +++ b/system/language/en/upload_lang.php @@ -10,7 +10,7 @@ $lang['upload_stopped_by_extension'] = "The file upload was stopped by extension $lang['upload_no_file_selected'] = "You did not select a file to upload."; $lang['upload_invalid_filetype'] = "The filetype you are attempting to upload is not allowed."; $lang['upload_invalid_filesize'] = "The file you are attempting to upload is larger than the permitted size."; -$lang['upload_invalid_dimensions'] = "The image you are attempting to upload exceedes the maximum height or width."; +$lang['upload_invalid_dimensions'] = "The image you are attempting to upload exceeds the maximum height or width."; $lang['upload_destination_error'] = "A problem was encountered while attempting to move the uploaded file to the final destination."; $lang['upload_no_filepath'] = "The upload path does not appear to be valid."; $lang['upload_no_file_types'] = "You have not specified any allowed file types."; diff --git a/translations/items_lang.csv b/translations/items_lang.csv index 0c32eb3a4..1fa9f79d6 100644 --- a/translations/items_lang.csv +++ b/translations/items_lang.csv @@ -78,3 +78,4 @@ items_unit_price_required,Verkoopprijs moet ingevuld worden,Precio de Venta es r items_upc_database,UPC Database,Base de datos UPC,UPC Database,Base de Données UPC,UPC Database,UPC база данных,UPC ฐานข้อมูล,UPC Veritabanı,Database UPC items_update,Bewerk Product,Actualizar Artículo,Update Item,Éditer Item,更新產品,Обновить Товар,ปรับแต่งสินค้า,Ürün Güncelle,Ubah items_use_inventory_menu,Use Inv. Menu,Usar Menú de Inventario,Use Inv. Menu,Utiliser Menu Inv.,使用庫存清單,Используйте меню инвентаря,ใช้เมนูสินค้าคงเหลือ,Stok Menüsünü Kullan,Gunakan Inv. Menu +items_image,Afbeelding,,Avatar,,,,,,