diff --git a/application/controllers/Customers.php b/application/controllers/Customers.php
index b7c4e0192..3df05c9f8 100644
--- a/application/controllers/Customers.php
+++ b/application/controllers/Customers.php
@@ -23,13 +23,10 @@ class Customers extends Person_controller
$search = $this->input->get('search');
$limit = $this->input->get('limit');
$offset = $this->input->get('offset');
- $lines_per_page = $this->Appconfig->get('lines_per_page');
- $customers = $this->Customer->search($search, $lines_per_page, $offset);
+ $customers = $this->Customer->search($search, $limit, $offset);
$total_rows = $this->Customer->get_found_rows($search);
- // updat pagination manually??
- $links = $this->_initialize_pagination($this->Customer,$lines_per_page, $limit, $total_rows);
$data_rows = array();
foreach($customers->result() as $person)
{
diff --git a/application/controllers/Employees.php b/application/controllers/Employees.php
index 1ec740b45..532eeb0e3 100644
--- a/application/controllers/Employees.php
+++ b/application/controllers/Employees.php
@@ -23,11 +23,9 @@ class Employees extends Person_controller
$search = $this->input->get('search');
$limit = $this->input->get('limit');
$offset = $this->input->get('offset');
- $lines_per_page = $this->Appconfig->get('lines_per_page');
$employees = $this->Employee->search($search, $offset, $limit);
$total_rows = $this->Employee->get_found_rows($search);
- $links = $this->_initialize_pagination($this->Employee, $lines_per_page, $limit, $total_rows);
$data_rows = array();
foreach($employees->result() as $person)
{
diff --git a/application/controllers/Giftcards.php b/application/controllers/Giftcards.php
index 1d9d314f8..42edd2a92 100644
--- a/application/controllers/Giftcards.php
+++ b/application/controllers/Giftcards.php
@@ -26,12 +26,10 @@ class Giftcards extends Secure_area implements iData_controller
$search = $this->input->get('search');
$limit = $this->input->get('limit');
$offset = $this->input->get('offset');
- $lines_per_page = $this->Appconfig->get('lines_per_page');
$giftcards = $this->Giftcard->search($search, $offset, $limit);
$total_rows = $this->Giftcard->get_found_rows($search);
- $links = $this->_initialize_pagination($this->Giftcard, $lines_per_page, $limit, $total_rows);
$data_rows = array();
foreach($giftcards->result() as $giftcard)
{
diff --git a/application/controllers/Items.php b/application/controllers/Items.php
index 9ada70169..78e975771 100644
--- a/application/controllers/Items.php
+++ b/application/controllers/Items.php
@@ -10,27 +10,24 @@ class Items extends Secure_area implements iData_controller
$this->load->library('item_lib');
}
- function index($limit_from=0)
+ function index()
{
$stock_location = $this->item_lib->get_item_location();
$stock_locations = $this->Stock_location->get_allowed_locations();
-
$data['controller_name'] = $this->get_controller_name();
- $lines_per_page = $this->Appconfig->get('lines_per_page');
- $items = $this->Item->get_all($stock_location, $lines_per_page, $limit_from);
- $data['links'] = $this->_initialize_pagination($this->Item, $lines_per_page, $limit_from);
// filters that will be loaded in the multiselect dropdown
$data['filters'] = array('empty_upc' => $this->lang->line('items_empty_upc_items'),
- 'low_inventory' => $this->lang->line('items_low_inventory_items'),
- 'is_serialized' => $this->lang->line('items_serialized_items'),
- 'no_description' => $this->lang->line('items_no_description_items'),
- 'search_custom' => $this->lang->line('items_search_custom_items'),
- 'is_deleted' => $this->lang->line('items_is_deleted'));
+ 'low_inventory' => $this->lang->line('items_low_inventory_items'),
+ 'is_serialized' => $this->lang->line('items_serialized_items'),
+ 'no_description' => $this->lang->line('items_no_description_items'),
+ 'search_custom' => $this->lang->line('items_search_custom_items'),
+ 'is_deleted' => $this->lang->line('items_is_deleted'));
$data['stock_location'] = $stock_location;
$data['stock_locations'] = $stock_locations;
- $data['manage_table'] = get_items_manage_table( $this->Item->get_all($stock_location, $lines_per_page, $limit_from), $this );
+
+ $data['table_headers'] = get_items_manage_table_headers();
$this->load->view('items/manage', $data);
}
@@ -40,13 +37,14 @@ class Items extends Secure_area implements iData_controller
*/
function search()
{
- $search = $this->input->post('search') != '' ? $this->input->post('search') : null;
- $limit_from = $this->input->post('limit_from');
- $lines_per_page = $this->Appconfig->get('lines_per_page');
- $this->item_lib->set_item_location($this->input->post('stock_location'));
+ $search = $this->input->get('search');
+ $limit = $this->input->get('limit');
+ $offset = $this->input->get('offset');
- $filters = array('start_date' => $this->input->post('start_date'),
- 'end_date' => $this->input->post('end_date'),
+ $this->item_lib->set_item_location($this->input->get('stock_location'));
+
+ $filters = array('start_date' => $this->input->get('start_date'),
+ 'end_date' => $this->input->get('end_date'),
'stock_location_id' => $this->item_lib->get_item_location(),
'empty_upc' => FALSE,
'low_inventory' => FALSE,
@@ -56,21 +54,17 @@ class Items extends Secure_area implements iData_controller
'is_deleted' => FALSE);
// check if any filter is set in the multiselect dropdown
- if( $this->input->post('filters') != null )
- {
- foreach($this->input->post('filters') as $key)
- {
- $filters[$key] = TRUE;
- }
- }
-
- $items = $this->Item->search($search, $filters, $lines_per_page, $limit_from);
- $data_rows = get_items_manage_table_data_rows($items, $this);
- $total_rows = $this->Item->get_found_rows($search, $filters);
- $links = $this->_initialize_pagination($this->Item, $lines_per_page, $limit_from, $total_rows, 'search');
- $data_rows = get_items_manage_table_data_rows($items, $this);
+ $filters = array_merge($filters, $this->input->get('filters'));
- echo json_encode(array('total_rows' => $total_rows, 'rows' => $data_rows, 'pagination' => $links));
+ $items = $this->Item->search($search, $filters, $offset, $limit);
+ $total_rows = $this->Item->get_found_rows($search, $filters);
+
+ $data_rows = array();
+ foreach($items->result() as $item)
+ {
+ $data_rows[] = get_item_data_row($item, $this);
+ }
+ echo json_encode(array('total' => $total_rows, 'rows' => $data_rows));
}
function pic_thumb($pic_id)
@@ -369,7 +363,7 @@ class Items extends Secure_area implements iData_controller
foreach($stock_locations as $location_data)
{
$updated_quantity = $this->input->post('quantity_' . $location_data['location_id']);
- $location_detail = array('item_id'=>$item_id,
+ $location_detail = array('id'=>$item_id,
'location_id'=>$location_data['location_id'],
'quantity'=>$updated_quantity);
$item_quantity = $this->Item_quantity->get_item_quantity($item_id, $location_data['location_id']);
@@ -393,7 +387,7 @@ class Items extends Secure_area implements iData_controller
{
$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));
+ echo json_encode(array('success'=>true, 'message'=>$success_message, 'id'=>$item_id));
}
else
{
@@ -401,7 +395,7 @@ class Items extends Secure_area implements iData_controller
$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));
+ echo json_encode(array('success'=>false, 'message'=>$error_message, 'id'=>$item_id));
}
}
else//failure
diff --git a/application/controllers/Suppliers.php b/application/controllers/Suppliers.php
index 38f82b6b6..474503e83 100644
--- a/application/controllers/Suppliers.php
+++ b/application/controllers/Suppliers.php
@@ -23,11 +23,9 @@ class Suppliers extends Person_controller
$search = $this->input->get('search');
$limit = $this->input->get('limit');
$offset = $this->input->get('offset');
- $lines_per_page = $this->Appconfig->get('lines_per_page');
$suppliers = $this->Supplier->search($search, $offset, $limit);
$total_rows = $this->Supplier->get_found_rows($search);
- $links = $this->_initialize_pagination($this->Employee, $lines_per_page, $limit, $total_rows);
$data_rows = array();
foreach($suppliers->result() as $supplier)
{
diff --git a/application/helpers/table_helper.php b/application/helpers/table_helper.php
index 000b72054..4ace37020 100644
--- a/application/helpers/table_helper.php
+++ b/application/helpers/table_helper.php
@@ -234,64 +234,32 @@ function get_supplier_data_row($supplier, $controller) {
));
}
-/*
-Gets the html table to manage items.
-*/
-function get_items_manage_table($items,$controller)
+function get_items_manage_table_headers()
{
$CI =& get_instance();
- $table='
';
-
- $headers = array('',
- $CI->lang->line('items_item_number'),
- $CI->lang->line('items_name'),
- $CI->lang->line('items_category'),
- $CI->lang->line('suppliers_company_name'),
- $CI->lang->line('items_cost_price'),
- $CI->lang->line('items_unit_price'),
- $CI->lang->line('items_quantity'),
- $CI->lang->line('items_tax_percents'),
- $CI->lang->line('items_image'),
- ' ',
- ' ',
- ' '
+
+ $headers = array(
+ array('checkbox' => 'select'),
+ array('id' => $CI->lang->line('common_id')),
+ array('item_number' => $CI->lang->line('items_item_number')),
+ array('item_name' => $CI->lang->line('items_name')),
+ array('item_category' => $CI->lang->line('items_category')),
+ array('company_name' => $CI->lang->line('suppliers_company_name')),
+ array('cost_price' => $CI->lang->line('items_cost_price')),
+ array('unit_price' => $CI->lang->line('items_unit_price')),
+ array('quantity' => $CI->lang->line('items_quantity')),
+ array('tax_percents' => $CI->lang->line('items_tax_percents')),
+ array('item_pic' => $CI->lang->line('items_image')),
+ array('inventory' => ''),
+ array('stock' => ''),
+ array('edit' => '')
);
-
- $table.='';
- foreach($headers as $header)
- {
- $table.="| $header | ";
- }
- $table.='
';
- $table.=get_items_manage_table_data_rows($items,$controller);
- $table.='
';
- return $table;
+ return transform_headers($headers);
}
-/*
-Gets the html data rows for the items.
-*/
-function get_items_manage_table_data_rows($items,$controller)
-{
- $CI =& get_instance();
- $table_data_rows='';
-
- foreach($items->result() as $item)
- {
- $table_data_rows.=get_item_data_row($item,$controller);
- }
-
- if($items->num_rows()==0)
- {
- $table_data_rows.="".$CI->lang->line('items_no_items_to_display')." |
";
- }
-
- return $table_data_rows;
-}
+function get_item_data_row($item, $controller) {
-function get_item_data_row($item,$controller)
-{
$CI =& get_instance();
$item_tax_info=$CI->Item_taxes->get_info($item->item_id);
$tax_percents = '';
@@ -303,34 +271,35 @@ function get_item_data_row($item,$controller)
$tax_percents=substr($tax_percents, 0, -2);
$controller_name=strtolower(get_class($CI));
- $item_quantity='';
-
- $table_data_row='';
- $table_data_row.=" | ";
- $table_data_row.=''.$item->item_number.' | ';
- $table_data_row.=''.$item->name.' | ';
- $table_data_row.=''.$item->category.' | ';
- $table_data_row.=''.$item->company_name.' | ';
- $table_data_row.=''.to_currency($item->cost_price).' | ';
- $table_data_row.=''.to_currency($item->unit_price).' | ';
- $table_data_row.=''.to_quantity_decimals($item->quantity).' | ';
- $table_data_row.=''.$tax_percents.' | ';
$image = '';
if (!empty($item->pic_id))
{
$images = glob("uploads/item_pics/" . $item->pic_id . ".*");
if (sizeof($images) > 0)
{
- $image.='
';
+ $image .= '
';
}
}
- $table_data_row.='' . $image . ' | ';
- $table_data_row.=''.anchor($controller_name."/view/$item->item_id", '', array('class'=>"modal-dlg modal-btn-new modal-btn-submit",'title'=>$CI->lang->line($controller_name.'_update'))).' | ';
- $table_data_row.=''.anchor($controller_name."/inventory/$item->item_id", '', array('class'=>"modal-dlg modal-btn-submit",'title'=>$CI->lang->line($controller_name.'_count'))).' | ';//inventory count
- $table_data_row.=''.anchor($controller_name."/count_details/$item->item_id", '', array('class'=>"modal-dlg",'title'=>$CI->lang->line($controller_name.'_details_count'))).' | ';//inventory details
- $table_data_row.='
';
- return $table_data_row;
+ return array (
+ 'id' => $item->item_id,
+ 'item_number' => $item->item_number,
+ 'item_name' => character_limiter($item->name,13),
+ 'item_category' => character_limiter($item->category,13),
+ 'cost_price' => to_currency($item->cost_price),
+ 'unit_price' => to_currency($item->unit_price),
+ 'quantity' => to_quantity_decimals($item->quantity),
+ 'tax_percents' => $tax_percents,
+ 'item_pic' => $image,
+ 'inventory' => anchor($controller_name."/inventory/$item->person_id", '',
+ array('class' => "modal-dlg modal-btn-submit", 'title' => $CI->lang->line($controller_name.'_count'))
+ ),
+ 'stock' => anchor($controller_name."/count_details/$item->person_id", '',
+ array('class' => "modal-dlg modal-btn-submit", 'title' => $CI->lang->line($controller_name.'_details_count'))
+ ),
+ 'edit' => anchor($controller_name."/view/$item->person_id", '',
+ array('class' => "modal-dlg modal-btn-submit", 'title' => $CI->lang->line($controller_name.'_update'))
+ ));
}
function get_giftcards_manage_table_headers()
diff --git a/application/models/Giftcard.php b/application/models/Giftcard.php
index dd9a923e4..35c0d6b2a 100644
--- a/application/models/Giftcard.php
+++ b/application/models/Giftcard.php
@@ -26,24 +26,6 @@ class Giftcard extends CI_Model
return $this->db->count_all('giftcards');
}
- /*
- Returns all the giftcards
- */
- function get_all($rows=0, $limit_from=0)
- {
- $this->db->from('giftcards');
- $this->db->join('people', 'people.person_id=giftcards.person_id', 'left');
- $this->db->where('deleted', 0);
- $this->db->order_by('giftcard_number');
-
- if ($rows > 0)
- {
- $this->db->limit($rows, $limit_from);
- }
-
- return $this->db->get();
- }
-
function count_all()
{
$this->db->from('giftcards');
diff --git a/application/models/Item.php b/application/models/Item.php
index 0b8efbf18..9e2f4d5b5 100644
--- a/application/models/Item.php
+++ b/application/models/Item.php
@@ -118,33 +118,6 @@ class Item extends CI_Model
return $this->db->get();
}
- /*
- Returns all the items
- */
- public function get_all($stock_location_id=-1, $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->where('items.deleted', 0);
-
- // order by name of item
- $this->db->order_by('items.name', 'asc');
-
- if ($rows > 0)
- {
- $this->db->limit($rows, $limit_from);
- }
-
- return $this->db->get();
- }
-
/*
Gets information about a particular item
*/
diff --git a/application/models/Item_kit.php b/application/models/Item_kit.php
index bb11ad8af..91de99cf4 100644
--- a/application/models/Item_kit.php
+++ b/application/models/Item_kit.php
@@ -11,22 +11,6 @@ class Item_kit extends CI_Model
return ($this->db->get()->num_rows()==1);
}
-
- /*
- Returns all the item kits
- */
- function get_all($rows=0, $limit_from=0)
- {
- $this->db->from('item_kits');
- $this->db->order_by('name', 'asc');
-
- if ($rows > 0)
- {
- $this->db->limit($rows, $limit_from);
- }
-
- return $this->db->get();
- }
function get_total_rows()
{
diff --git a/application/views/items/form.php b/application/views/items/form.php
index 9d7db0ef9..5f231b99a 100644
--- a/application/views/items/form.php
+++ b/application/views/items/form.php
@@ -346,7 +346,7 @@
{
dialog_support.hide();
}
- post_item_form_submit(response, stay_open);
+ table_support.handle_submit(response, stay_open);
},
dataType: 'json'
});
diff --git a/application/views/items/form_excel_import.php b/application/views/items/form_excel_import.php
index cbf3bc5f7..10e89a10a 100644
--- a/application/views/items/form_excel_import.php
+++ b/application/views/items/form_excel_import.php
@@ -31,7 +31,7 @@ $(document).ready(function()
success:function(response)
{
dialog_support.hide();
- post_item_form_submit(response);
+ table_support.handle_submit(response);
},
dataType:'json'
});
diff --git a/application/views/items/form_inventory.php b/application/views/items/form_inventory.php
index 91074367e..b7bc24305 100644
--- a/application/views/items/form_inventory.php
+++ b/application/views/items/form_inventory.php
@@ -104,7 +104,7 @@ $(document).ready(function()
success:function(response)
{
dialog_support.hide();
- post_item_form_submit(response);
+ table_support.handle_submit('', response);
},
dataType:'json'
});
diff --git a/application/views/items/manage.php b/application/views/items/manage.php
index 24c21f34d..0ec095042 100644
--- a/application/views/items/manage.php
+++ b/application/views/items/manage.php
@@ -3,12 +3,7 @@
-
-
+
- " . $this->lang->line('common_import_excel') . "
",
- array('class'=>'modal-dlg modal-btn-submit none', 'title'=>$this->lang->line('items_import_items_excel'))); ?>
+
+
+
-
" . $this->lang->line($controller_name . '_new') . " ",
- array('class'=>'modal-dlg modal-btn-new modal-btn-submit', 'title'=>$this->lang->line($controller_name . '_new'))); ?>
-'search_form', 'class'=>'form-horizontal')); ?>
-