mirror of
https://github.com/opensourcepos/opensourcepos.git
synced 2026-05-14 02:33:56 -04:00
Basic image upload working now
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -12,3 +12,4 @@ git-svn-diff.py
|
||||
*.rej
|
||||
*.orig
|
||||
*~
|
||||
uploads/
|
||||
|
||||
@@ -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(),
|
||||
'<p>'.$this->lang->line('upload_no_file_selected').'</p>');
|
||||
}
|
||||
|
||||
//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)
|
||||
|
||||
@@ -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.='<thead><tr>';
|
||||
@@ -191,7 +192,7 @@ function get_items_manage_table_data_rows($items,$controller)
|
||||
|
||||
if($items->num_rows()==0)
|
||||
{
|
||||
$table_data_rows.="<tr><td colspan='11'><div class='warning_message' style='padding:7px;'>".$CI->lang->line('items_no_items_to_display')."</div></tr></tr>";
|
||||
$table_data_rows.="<tr><td colspan='12'><div class='warning_message' style='padding:7px;'>".$CI->lang->line('items_no_items_to_display')."</div></tr></tr>";
|
||||
}
|
||||
|
||||
return $table_data_rows;
|
||||
@@ -220,7 +221,17 @@ function get_item_data_row($item,$controller)
|
||||
$table_data_row.='<td width="14%">'.to_currency($item->cost_price).'</td>';
|
||||
$table_data_row.='<td width="14%">'.to_currency($item->unit_price).'</td>';
|
||||
$table_data_row.='<td width="14%">'.$item->quantity.'</td>';
|
||||
$table_data_row.='<td width="14%">'.$tax_percents.'</td>';
|
||||
$table_data_row.='<td width="14%">'.$tax_percents.'</td>';
|
||||
$image = '';
|
||||
if (!empty($item->pic_id))
|
||||
{
|
||||
$images = glob ("uploads/item_pics/" . $item->pic_id . ".*");
|
||||
if (sizeof($images) > 0)
|
||||
{
|
||||
$image.='<a class="rollover" href="'. $images[0] .'"><img src="'.base_url($images[0]).'"></a>';
|
||||
}
|
||||
}
|
||||
$table_data_row.='<td align="center" width="55px">' . $image . '</td>';
|
||||
$table_data_row.='<td width="5%">'.anchor($controller_name."/view/$item->item_id/width:$width", $CI->lang->line('common_edit'),array('class'=>'thickbox','title'=>$CI->lang->line($controller_name.'_update'))).'</td>';
|
||||
|
||||
//Ramel Inventory Tracking
|
||||
|
||||
@@ -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";
|
||||
|
||||
@@ -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"] = "";
|
||||
|
||||
@@ -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"] = "";
|
||||
|
||||
@@ -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"] = "";
|
||||
|
||||
@@ -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";
|
||||
|
||||
@@ -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"] = "";
|
||||
|
||||
@@ -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"] = "";
|
||||
|
||||
@@ -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"] = "";
|
||||
|
||||
@@ -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"] = "";
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<div id="required_fields_message"><?php echo $this->lang->line('common_fields_required_message'); ?></div>
|
||||
<ul id="error_message_box"></ul>
|
||||
<?php
|
||||
echo form_open('items/save/'.$item_info->item_id,array('id'=>'item_form'));
|
||||
echo form_open('items/save/'.$item_info->item_id,array('id'=>'item_form', 'enctype'=>'multipart/form-data'));
|
||||
?>
|
||||
<fieldset id="item_basic_info">
|
||||
<legend><?php echo $this->lang->line("items_basic_information"); ?></legend>
|
||||
@@ -170,6 +170,13 @@ foreach($stock_locations as $key=>$location_detail)
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="field_row clearfix">
|
||||
<?php echo form_label($this->lang->line('items_image').':', 'item_image',array('class'=>'wide')); ?>
|
||||
<div class='form_field'>
|
||||
<?php echo form_upload('item_image');?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="field_row clearfix">
|
||||
<?php echo form_label($this->lang->line('items_allow_alt_description').':', 'allow_alt_description',array('class'=>'wide')); ?>
|
||||
<div class='form_field'>
|
||||
@@ -365,8 +372,8 @@ if($this->config->item('custom10_name') != NULL)
|
||||
|
||||
<?php
|
||||
echo form_submit(array(
|
||||
'name'=>'submit',
|
||||
'id'=>'submit',
|
||||
'name'=>'submit_form',
|
||||
'id'=>'submit_form',
|
||||
'value'=>$this->lang->line('common_submit'),
|
||||
'class'=>'submit_button float_right')
|
||||
);
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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',
|
||||
|
||||
@@ -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.";
|
||||
|
||||
@@ -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,,,,,,
|
||||
|
||||
|
Reference in New Issue
Block a user