From c389e6030ce1843c87e84d5011b7c637571fc440 Mon Sep 17 00:00:00 2001 From: jekkos-t520 Date: Fri, 20 Feb 2015 17:36:03 +0100 Subject: [PATCH] Fix pagination for all modules (links updated for index+search through AJAX) --- application/controllers/customers.php | 28 +++-- application/controllers/employees.php | 28 +++-- application/controllers/giftcards.php | 26 ++-- application/controllers/item_kits.php | 30 ++--- application/controllers/items.php | 34 +++-- application/controllers/secure_area.php | 18 +++ application/controllers/suppliers.php | 24 ++-- application/language/en/sales_lang.php | 1 + application/language/es/sales_lang.php | 5 +- application/language/fr/sales_lang.php | 9 +- application/language/id/sales_lang.php | 3 +- application/language/nl-BE/config_lang.php | 4 +- application/language/nl-BE/sales_lang.php | 7 +- application/language/ru/sales_lang.php | 11 +- application/language/th/sales_lang.php | 11 +- application/language/tr/sales_lang.php | 11 +- application/language/zh/sales_lang.php | 11 +- application/models/customer.php | 33 ++++- application/models/employee.php | 23 +++- application/models/giftcard.php | 26 +++- application/models/item.php | 138 +++++++++++---------- application/models/item_kit.php | 25 +++- application/models/supplier.php | 28 ++++- application/views/giftcards/manage.php | 2 +- application/views/items/manage.php | 2 +- application/views/people/manage.php | 2 +- application/views/suppliers/manage.php | 2 +- translations/config_lang.csv | 4 +- translations/sales_lang.csv | 11 +- 29 files changed, 354 insertions(+), 203 deletions(-) diff --git a/application/controllers/customers.php b/application/controllers/customers.php index d8cb101bb..d7ca3cc34 100644 --- a/application/controllers/customers.php +++ b/application/controllers/customers.php @@ -7,28 +7,30 @@ class Customers extends Person_controller parent::__construct('customers'); } - function index() + function index($limit_from=0) { - $config['base_url'] = site_url('/customers/index'); - $config['total_rows'] = $this->Customer->count_all(); - $config['per_page'] = '20'; - $config['uri_segment'] = 3; - $this->pagination->initialize($config); - - $data['controller_name']=strtolower(get_class()); + $data['controller_name']=$this->get_controller_name(); $data['form_width']=$this->get_form_width(); - $data['manage_table']=get_people_manage_table( $this->Customer->get_all( $config['per_page'], $this->uri->segment( $config['uri_segment'] ) ), $this ); + $lines_per_page = $this->Appconfig->get('lines_per_page'); + $customers = $this->Customer->get_all($lines_per_page,$limit_from); + $data['links'] = $this->_initialize_pagination($this->Customer,$lines_per_page,$limit_from); + $data['manage_table']=get_people_manage_table($customers,$this); $this->load->view('people/manage',$data); } /* - Returns customer table data rows. This will be called with AJAX. + Returns customer table data rows. This will be called with AJAX. */ function search() { - $search=$this->input->post('search'); - $data_rows=get_people_manage_table_data_rows($this->Customer->search($search),$this); - echo $data_rows; + $search = $this->input->post('search'); + $limit_from = $this->input->post('limit_from'); + $lines_per_page = $this->Appconfig->get('lines_per_page'); + $customers = $this->Customer->search($search, $lines_per_page, $limit_from); + $total_rows = $this->Customer->get_found_rows($search); + $links = $this->_initialize_pagination($this->Customer,$lines_per_page, $limit_from, $total_rows); + $data_rows=get_people_manage_table_data_rows($customers,$this); + echo json_encode(array('total_rows' => $total_rows, 'rows' => $data_rows, 'pagination' => $links)); } /* diff --git a/application/controllers/employees.php b/application/controllers/employees.php index 42abae926..d9da8e255 100644 --- a/application/controllers/employees.php +++ b/application/controllers/employees.php @@ -7,18 +7,15 @@ class Employees extends Person_controller parent::__construct('employees'); } - function index() + function index($limit_from=0) { - $config['base_url'] = site_url('/employees/index'); - $config['total_rows'] = $this->Employee->count_all(); - $config['per_page'] = '20'; - $config['uri_segment'] = 3; - $this->pagination->initialize($config); - - $data['controller_name']=strtolower(get_class()); + $data['controller_name']=$this->get_controller_name(); $data['form_width']=$this->get_form_width(); - $data['manage_table']=get_people_manage_table( $this->Employee->get_all( $config['per_page'], $this->uri->segment( $config['uri_segment'] ) ), $this ); - $this->load->view('people/manage',$data); + $lines_per_page = $this->Appconfig->get('lines_per_page'); + $suppliers = $this->Employee->get_all($lines_per_page,$limit_from); + $data['links'] = $this->_initialize_pagination($this->Employee,$lines_per_page,$limit_from); + $data['manage_table']=get_people_manage_table($suppliers,$this); + $this->load->view('suppliers/manage',$data); } /* @@ -26,9 +23,14 @@ class Employees extends Person_controller */ function search() { - $search=$this->input->post('search'); - $data_rows=get_people_manage_table_data_rows($this->Employee->search($search),$this); - echo $data_rows; + $search = $this->input->post('search'); + $limit_from = $this->input->post('limit_from'); + $lines_per_page = $this->Appconfig->get('lines_per_page'); + $employees = $this->Employee->search($search, $limit_from, $lines_per_page); + $total_rows = $this->Employee->get_found_rows($search); + $links = $this->_initialize_pagination($this->Employee, $lines_per_page, $limit_from, $total_rows); + $data_rows=get_people_manage_table_data_rows($employees,$this); + echo json_encode(array('rows' => $data_rows, 'pagination' => $links)); } /* diff --git a/application/controllers/giftcards.php b/application/controllers/giftcards.php index 017101d2b..9215180d5 100644 --- a/application/controllers/giftcards.php +++ b/application/controllers/giftcards.php @@ -8,25 +8,27 @@ class Giftcards extends Secure_area implements iData_controller parent::__construct('giftcards'); } - function index() + function index($limit_from=0) { - $config['base_url'] = site_url('/giftcards/index'); - $config['total_rows'] = $this->Giftcard->count_all(); - $config['per_page'] = '20'; - $config['uri_segment'] = 3; - $this->pagination->initialize($config); - - $data['controller_name']=strtolower(get_class()); + $data['controller_name']=$this->get_controller_name(); $data['form_width']=$this->get_form_width(); - $data['manage_table']=get_giftcards_manage_table( $this->Giftcard->get_all( $config['per_page'], $this->uri->segment( $config['uri_segment'] ) ), $this ); + $lines_per_page = $this->Appconfig->get('lines_per_page'); + $giftcards = $this->Giftcard->get_all($lines_per_page,$limit_from); + $data['links'] = $this->_initialize_pagination($this->Giftcard,$lines_per_page,$limit_from); + $data['manage_table']=get_giftcards_manage_table($giftcards,$this); $this->load->view('giftcards/manage',$data); } function search() { - $search=$this->input->post('search'); - $data_rows=get_giftcards_manage_table_data_rows($this->Giftcard->search($search),$this); - echo $data_rows; + $search = $this->input->post('search'); + $limit_from = $this->input->post('limit_from'); + $lines_per_page = $this->Appconfig->get('lines_per_page'); + $giftcards = $this->Giftcard->search($search, $lines_per_page, $limit_from); + $total_rows = $this->Giftcard->get_found_rows($search); + $links = $this->_initialize_pagination($this->Giftcard,$lines_per_page, $limit_from, $total_rows); + $data_rows=get_giftcards_manage_table_data_rows($giftcards,$this); + echo json_encode(array('total_rows' => $total_rows, 'rows' => $data_rows, 'pagination' => $links)); } /* diff --git a/application/controllers/item_kits.php b/application/controllers/item_kits.php index ea41aa847..66b928df6 100644 --- a/application/controllers/item_kits.php +++ b/application/controllers/item_kits.php @@ -7,26 +7,28 @@ class Item_kits extends Secure_area implements iData_controller { parent::__construct('item_kits'); } - - function index() + + function index($limit_from=0) { - $config['base_url'] = site_url('/item_kits/index'); - $config['total_rows'] = $this->Item_kit->count_all(); - $config['per_page'] = '20'; - $config['uri_segment'] = 3; - $this->pagination->initialize($config); - - $data['controller_name']=strtolower(get_class()); + $data['controller_name']=$this->get_controller_name(); $data['form_width']=$this->get_form_width(); - $data['manage_table']=get_item_kits_manage_table( $this->Item_kit->get_all( $config['per_page'], $this->uri->segment( $config['uri_segment'] ) ), $this ); + $lines_per_page = $this->Appconfig->get('lines_per_page'); + $item_kits = $this->Item_kit->get_all($lines_per_page,$limit_from); + $data['links'] = $this->_initialize_pagination($this->Item_kit,$lines_per_page,$limit_from); + $data['manage_table']=get_item_kits_manage_table($item_kits,$this); $this->load->view('item_kits/manage',$data); } - + function search() { - $search=$this->input->post('search'); - $data_rows=get_item_kits_manage_table_data_rows($this->Item_kit->search($search),$this); - echo $data_rows; + $search = $this->input->post('search'); + $limit_from = $this->input->post('limit_from'); + $lines_per_page = $this->Appconfig->get('lines_per_page'); + $customers = $this->Item_kit->search($search, $lines_per_page, $limit_from); + $total_rows = $this->Item_kit->get_found_rows($search); + $links = $this->_initialize_pagination($this->Item_kit,$lines_per_page, $limit_from, $total_rows); + $data_rows=get_item_kits_manage_table_data_rows($customers,$this); + echo json_encode(array('total_rows' => $total_rows, 'rows' => $data_rows, 'pagination' => $links)); } /* diff --git a/application/controllers/items.php b/application/controllers/items.php index 404f49ffe..5e71977cb 100644 --- a/application/controllers/items.php +++ b/application/controllers/items.php @@ -8,22 +8,20 @@ class Items extends Secure_area implements iData_controller parent::__construct('items'); $this->load->library('item_lib'); } - - function index() + + function index($limit_from=0) { - $config['base_url'] = site_url('/items/index'); - $config['total_rows'] = $this->Item->count_all(); - $config['per_page'] = '20'; - $config['uri_segment'] = 3; - $this->pagination->initialize($config); + $data['controller_name']=$this->get_controller_name(); + $data['form_width']=$this->get_form_width(); + $lines_per_page = $this->Appconfig->get('lines_per_page'); + $items = $this->Item->get_all($lines_per_page,$limit_from); + $data['links'] = $this->_initialize_pagination($this->Item,$lines_per_page,$limit_from); $stock_location=$this->item_lib->get_item_location(); $stock_locations=$this->Stock_locations->get_allowed_locations(); $data['stock_location']=$stock_location; $data['stock_locations']=$stock_locations; - $data['controller_name']=strtolower(get_class()); - $data['form_width']=$this->get_form_width(); - $data['manage_table']=get_items_manage_table( $this->Item->get_all( $stock_location, $config['per_page'], $this->uri->segment( $config['uri_segment'] ) ), $this ); + $data['manage_table']=get_items_manage_table( $this->Item->get_all( $stock_location, $lines_per_page, $limit_from), $this ); $this->load->view('items/manage',$data); $this->_remove_duplicate_cookies(); } @@ -61,10 +59,20 @@ class Items extends Secure_area implements iData_controller function search() { - $search=$this->input->post('search'); + $search = $this->input->post('search'); $stock_location=$this->item_lib->get_item_location(); - $data_rows=get_items_manage_table_data_rows($this->Item->search($search,$stock_location),$this); - echo $data_rows; + $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'); + $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,$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); + $links = $this->_initialize_pagination($this->Item, $lines_per_page, $limit_from, $total_rows); + $data_rows=get_items_manage_table_data_rows($items,$this); + echo json_encode(array('total_rows' => $total_rows, 'rows' => $data_rows, 'pagination' => $links)); $this->_remove_duplicate_cookies(); } diff --git a/application/controllers/secure_area.php b/application/controllers/secure_area.php index ebbe6416a..3f2acb161 100644 --- a/application/controllers/secure_area.php +++ b/application/controllers/secure_area.php @@ -41,6 +41,24 @@ class Secure_area extends CI_Controller return strtolower($this->controller_name); } + function _initialize_pagination($object, $lines_per_page, $limit_from = 0, $total_rows = -1) + { + $this->load->library('pagination'); + $config['base_url'] = site_url($this->get_controller_name() . '/index/'); + $config['total_rows'] = $total_rows > -1 ? $total_rows : call_user_func(array($object, 'get_total_rows')); + $config['per_page'] = $lines_per_page; + $config['num_links'] = 2; + $config['last_link'] = $this->lang->line('common_last_page'); + $config['first_link'] = $this->lang->line('common_first_page'); + // page is calculated here instead of in pagination lib + $config['cur_page'] = $limit_from > 0 ? $limit_from : 0; + $config['page_query_string'] = FALSE; + $config['uri_segment'] = 0; + $this->pagination->initialize($config); + return $this->pagination->create_links(); + } + + function _remove_duplicate_cookies () { //php < 5.3 doesn't have header remove so this function will fatal error otherwise diff --git a/application/controllers/suppliers.php b/application/controllers/suppliers.php index ba8ebf57b..f7f2e6e95 100644 --- a/application/controllers/suppliers.php +++ b/application/controllers/suppliers.php @@ -9,15 +9,12 @@ class Suppliers extends Person_controller function index() { - $config['base_url'] = site_url('/suppliers/index'); - $config['total_rows'] = $this->Supplier->count_all(); - $config['per_page'] = '20'; - $config['uri_segment'] = 3; - $this->pagination->initialize($config); - - $data['controller_name']=strtolower(get_class()); + $data['controller_name']=$this->get_controller_name(); $data['form_width']=$this->get_form_width(); - $data['manage_table']=get_supplier_manage_table( $this->Supplier->get_all( $config['per_page'], $this->uri->segment( $config['uri_segment'] ) ), $this ); + $lines_per_page = $this->Appconfig->get('lines_per_page'); + $suppliers = $this->Supplier->get_all($lines_per_page); + $data['links'] = $this->_initialize_pagination($this->Supplier,$lines_per_page); + $data['manage_table']=get_suppliers_manage_table($suppliers,$this); $this->load->view('suppliers/manage',$data); } @@ -26,9 +23,14 @@ class Suppliers extends Person_controller */ function search() { - $search=$this->input->post('search'); - $data_rows=get_supplier_manage_table_data_rows($this->Supplier->search($search),$this); - echo $data_rows; + $search = $this->input->post('search'); + $limit_from = $this->input->post('limit_from'); + $lines_per_page = $this->Appconfig->get('lines_per_page'); + $suppliers = $this->Supplier->search($search, $lines_per_page, $limit_from); + $total_rows = $this->Supplier->get_found_rows($search); + $links = $this->_initialize_pagination($lines_per_page, $limit_from, $total_rows); + $data_rows=get_suppliers_manage_table_data_rows($suppliers,$this); + echo json_encode(array('total_rows' => $total_rows, 'rows' => $data_rows, 'pagination' => $links)); } /* diff --git a/application/language/en/sales_lang.php b/application/language/en/sales_lang.php index 11b9b4901..b0fddb643 100644 --- a/application/language/en/sales_lang.php +++ b/application/language/en/sales_lang.php @@ -108,3 +108,4 @@ $lang["sales_invoice_filter"] = "Filter sales for "; $lang["sales_overview"] = "Overview"; $lang["sales_update"] = "Edit Sale"; $lang["sales_confirm_delete"] = "Are you sure you want to delete the selected sales?"; +$lang["sales_no_description"] = "None"; diff --git a/application/language/es/sales_lang.php b/application/language/es/sales_lang.php index 075af16e7..d99564a47 100644 --- a/application/language/es/sales_lang.php +++ b/application/language/es/sales_lang.php @@ -17,7 +17,7 @@ $lang["sales_confirm_suspend_sale"] = "¿Estás seguro(a) de querer suspender es $lang["sales_credit"] = "Tarjeta de Crédito"; $lang["sales_customer"] = "cliente"; $lang["sales_date"] = "Fecha"; -$lang["sales_date_required"] = ""; +$lang["sales_date_required"] = "A correct date needs to be filled in"; $lang["sales_date_type"] = ""; $lang["sales_debit"] = "Tarjeta de Débito"; $lang["sales_delete_confirmation"] = "¿Estás seguro(a) de querer borrar esta venta? Esta acción no se puede deshacer."; @@ -38,7 +38,7 @@ $lang["sales_find_or_scan_item_or_receipt"] = "Encontrar/Escanear Artículo o En $lang["sales_giftcard"] = "Tarjeta de Regalo"; $lang["sales_giftcard_number"] = "Número de Tarjeta de Regalo"; $lang["sales_id"] = "ID de Venta"; -$lang["sales_invoice_enable"] = ""; +$lang["sales_invoice_enable"] = "Create Invoice"; $lang["sales_invoice_number"] = "Invoice #"; $lang["sales_invoice_number_duplicate"] = "Please enter an unique invoice number"; $lang["sales_item_insufficient_of_stock"] = "Hay un número insuficiente de Artículos en existencia"; @@ -108,3 +108,4 @@ $lang["sales_invoice_filter"] = "Filter sales for "; $lang["sales_overview"] = "Overview"; $lang["sales_update"] = "Edit Sale"; $lang["sales_confirm_delete"] = "Are you sure you want to delete the selected sales?"; +$lang["sales_no_description"] = "None"; diff --git a/application/language/fr/sales_lang.php b/application/language/fr/sales_lang.php index e9ee395f0..c8594da48 100644 --- a/application/language/fr/sales_lang.php +++ b/application/language/fr/sales_lang.php @@ -17,8 +17,8 @@ $lang["sales_confirm_suspend_sale"] = "Etes vous sûr(e) de vouloir suspendre ce $lang["sales_credit"] = "Carte de Crédit"; $lang["sales_customer"] = "Client"; $lang["sales_date"] = "Date de Vente"; -$lang["sales_date_required"] = ""; -$lang["sales_date_type"] = ""; +$lang["sales_date_required"] = "A correct date needs to be filled in"; +$lang["sales_date_type"] = "Date field is required"; $lang["sales_debit"] = "Carte Débit"; $lang["sales_delete_confirmation"] = "Etes vous sûr(e) de vouloir supprimer cette vente? Cette opération est irréversible."; $lang["sales_delete_entire_sale"] = "Supprimer Vente"; @@ -38,9 +38,9 @@ $lang["sales_find_or_scan_item_or_receipt"] = "Trouver/Scanner Item OU Recu"; $lang["sales_giftcard"] = "Carte Cadeau"; $lang["sales_giftcard_number"] = "Numéro de Carte cadeau"; $lang["sales_id"] = "ID Vente"; -$lang["sales_invoice_enable"] = ""; +$lang["sales_invoice_enable"] = "Create Invoice"; $lang["sales_invoice_number"] = "Invoice #"; -$lang["sales_invoice_number_duplicate"] = ""; +$lang["sales_invoice_number_duplicate"] = "Please enter an unique invoice number"; $lang["sales_item_insufficient_of_stock"] = "Stock top faible"; $lang["sales_item_name"] = "Nom"; $lang["sales_item_number"] = "# Item"; @@ -108,3 +108,4 @@ $lang["sales_invoice_filter"] = "Filter sales for "; $lang["sales_overview"] = "Overview"; $lang["sales_update"] = "Edit Sale"; $lang["sales_confirm_delete"] = "Are you sure you want to delete the selected sales?"; +$lang["sales_no_description"] = "None"; diff --git a/application/language/id/sales_lang.php b/application/language/id/sales_lang.php index 73e2824d9..d9b76e157 100644 --- a/application/language/id/sales_lang.php +++ b/application/language/id/sales_lang.php @@ -38,7 +38,7 @@ $lang["sales_find_or_scan_item_or_receipt"] = "Cari/Scan Item ATAU Faktur"; $lang["sales_giftcard"] = "Gift Card"; $lang["sales_giftcard_number"] = "Nomor Gift Card"; $lang["sales_id"] = "ID Penjualan"; -$lang["sales_invoice_enable"] = ""; +$lang["sales_invoice_enable"] = "Create Invoice"; $lang["sales_invoice_number"] = "Nomor Nota"; $lang["sales_invoice_number_duplicate"] = "Nomor Nota Double"; $lang["sales_item_insufficient_of_stock"] = "Stok Item tidak mencukupi"; @@ -108,3 +108,4 @@ $lang["sales_invoice_filter"] = "Filter sales for "; $lang["sales_overview"] = "Overview"; $lang["sales_update"] = "Edit Sale"; $lang["sales_confirm_delete"] = "Are you sure you want to delete the selected sales?"; +$lang["sales_no_description"] = "None"; diff --git a/application/language/nl-BE/config_lang.php b/application/language/nl-BE/config_lang.php index e595abc59..60184cb14 100755 --- a/application/language/nl-BE/config_lang.php +++ b/application/language/nl-BE/config_lang.php @@ -61,9 +61,9 @@ $lang["config_info"] = "Systeeminstellingen"; $lang["config_language"] = "Taal"; $lang["config_phone"] = "Telefoon"; $lang["config_phone_required"] = "De telefoonnummer van het bedrijf moet ingevuld worden"; -$lang["config_recv_invoice_format"] = ""; +$lang["config_recv_invoice_format"] = "Formattering Order #"; $lang["config_return_policy_required"] = "De retourvoorwaarden moeten ingevuld worden"; -$lang["config_sales_invoice_format"] = ""; +$lang["config_sales_invoice_format"] = "Formattering Aankoop #"; $lang["config_saved_successfully"] = "Configuratie werd bewaard"; $lang["config_saved_unsuccessfully"] = "Configuratie kon niet worden bewaard"; $lang["config_stock_location"] = "Stock locatie"; diff --git a/application/language/nl-BE/sales_lang.php b/application/language/nl-BE/sales_lang.php index 123452277..f933d4d18 100755 --- a/application/language/nl-BE/sales_lang.php +++ b/application/language/nl-BE/sales_lang.php @@ -17,8 +17,8 @@ $lang["sales_confirm_suspend_sale"] = "Bent u zeker dat u deze aankoop wil bewar $lang["sales_credit"] = "Kredietkaart"; $lang["sales_customer"] = "Klant"; $lang["sales_date"] = "Datum"; -$lang["sales_date_required"] = ""; -$lang["sales_date_type"] = ""; +$lang["sales_date_required"] = "Gelieve een correcte datum in te vullen"; +$lang["sales_date_type"] = "Er moet een correcte datum ingevuld worden"; $lang["sales_debit"] = "Bancontact"; $lang["sales_delete_confirmation"] = "Bent u zeker dat u deze aankoop wil verwijderen?"; $lang["sales_delete_entire_sale"] = "Verwijder"; @@ -39,7 +39,7 @@ $lang["sales_giftcard"] = "Cadeaubon"; $lang["sales_giftcard_number"] = "Cadeaubon nummer"; $lang["sales_id"] = "Nummer Verkoop "; $lang["sales_invoice_enable"] = "Maak Factuur"; -$lang["sales_invoice_number"] = ""; +$lang["sales_invoice_number"] = "Factuur #"; $lang["sales_invoice_number_duplicate"] = "Vul een unieke nummer in"; $lang["sales_item_insufficient_of_stock"] = "Product is niet meer in voorraad"; $lang["sales_item_name"] = "Naam"; @@ -108,3 +108,4 @@ $lang["sales_invoice_filter"] = "Filter tickets op "; $lang["sales_overview"] = "Overzicht"; $lang["sales_update"] = "Bewerk Ticket"; $lang["sales_confirm_delete"] = "Bent u zeker dat u de geselecteerde aankopen wil verwijderen?"; +$lang["sales_no_description"] = "Geen"; diff --git a/application/language/ru/sales_lang.php b/application/language/ru/sales_lang.php index 2e208dc0e..ac04037f3 100644 --- a/application/language/ru/sales_lang.php +++ b/application/language/ru/sales_lang.php @@ -17,8 +17,8 @@ $lang["sales_confirm_suspend_sale"] = "Вы уверены, что хотите $lang["sales_credit"] = "кредитная карта"; $lang["sales_customer"] = "клиент"; $lang["sales_date"] = "Число"; -$lang["sales_date_required"] = ""; -$lang["sales_date_type"] = ""; +$lang["sales_date_required"] = "A correct date needs to be filled in"; +$lang["sales_date_type"] = "Date field is required"; $lang["sales_debit"] = "Дебетовая карта"; $lang["sales_delete_confirmation"] = "Вы уверены, что хотите удалить эту продажу, это действие не может быть отменено"; $lang["sales_delete_entire_sale"] = "Удалить всего продажи"; @@ -38,9 +38,9 @@ $lang["sales_find_or_scan_item_or_receipt"] = "Найти/Сканировать $lang["sales_giftcard"] = "Подарочная карта"; $lang["sales_giftcard_number"] = "Номер подарочных карт"; $lang["sales_id"] = "Номер Продажы"; -$lang["sales_invoice_enable"] = ""; -$lang["sales_invoice_number"] = ""; -$lang["sales_invoice_number_duplicate"] = ""; +$lang["sales_invoice_enable"] = "Create Invoice"; +$lang["sales_invoice_number"] = "Invoice #"; +$lang["sales_invoice_number_duplicate"] = "Please enter an unique invoice number"; $lang["sales_item_insufficient_of_stock"] = "Товар недостаточно на складе"; $lang["sales_item_name"] = "Название товара"; $lang["sales_item_number"] = "Номер товара"; @@ -108,3 +108,4 @@ $lang["sales_invoice_filter"] = "Filter sales for "; $lang["sales_overview"] = "Overview"; $lang["sales_update"] = "Edit Sale"; $lang["sales_confirm_delete"] = "Are you sure you want to delete the selected sales?"; +$lang["sales_no_description"] = "None"; diff --git a/application/language/th/sales_lang.php b/application/language/th/sales_lang.php index 3294932f7..3f0215489 100644 --- a/application/language/th/sales_lang.php +++ b/application/language/th/sales_lang.php @@ -17,8 +17,8 @@ $lang["sales_confirm_suspend_sale"] = "แน่ใจหรือไม่ท $lang["sales_credit"] = "เครดิทการ์ด"; $lang["sales_customer"] = "ลูกค้า"; $lang["sales_date"] = "วันที่ขาย"; -$lang["sales_date_required"] = ""; -$lang["sales_date_type"] = ""; +$lang["sales_date_required"] = "A correct date needs to be filled in"; +$lang["sales_date_type"] = "Date field is required"; $lang["sales_debit"] = "เดบิทการ์ด"; $lang["sales_delete_confirmation"] = "แน่ใจหรือไม่ที่จะลบรายการขายนี้, ลบแล้วไม่สามารถเรียกกลับคืนใด้"; $lang["sales_delete_entire_sale"] = "ลบการขายทั้งหมด"; @@ -38,9 +38,9 @@ $lang["sales_find_or_scan_item_or_receipt"] = "ค้นหาสินค้า $lang["sales_giftcard"] = "Gift Card"; $lang["sales_giftcard_number"] = "เลขที่ Gift Card"; $lang["sales_id"] = "เลขที่ขาย"; -$lang["sales_invoice_enable"] = ""; -$lang["sales_invoice_number"] = ""; -$lang["sales_invoice_number_duplicate"] = ""; +$lang["sales_invoice_enable"] = "Create Invoice"; +$lang["sales_invoice_number"] = "Invoice #"; +$lang["sales_invoice_number_duplicate"] = "Please enter an unique invoice number"; $lang["sales_item_insufficient_of_stock"] = "จำนวนสินค้าไม่เพียงพอ"; $lang["sales_item_name"] = "ชื่อสินค้า"; $lang["sales_item_number"] = "สินค้า #"; @@ -108,3 +108,4 @@ $lang["sales_invoice_filter"] = "Filter sales for "; $lang["sales_overview"] = "Overview"; $lang["sales_update"] = "Edit Sale"; $lang["sales_confirm_delete"] = "Are you sure you want to delete the selected sales?"; +$lang["sales_no_description"] = "None"; diff --git a/application/language/tr/sales_lang.php b/application/language/tr/sales_lang.php index 590fab234..ed4bccaf7 100644 --- a/application/language/tr/sales_lang.php +++ b/application/language/tr/sales_lang.php @@ -17,8 +17,8 @@ $lang["sales_confirm_suspend_sale"] = "Bu satışı askıya almak istiyor musunu $lang["sales_credit"] = "Kredi Kartı"; $lang["sales_customer"] = "Müşteri"; $lang["sales_date"] = "Satış Tarihi"; -$lang["sales_date_required"] = ""; -$lang["sales_date_type"] = ""; +$lang["sales_date_required"] = "A correct date needs to be filled in"; +$lang["sales_date_type"] = "Date field is required"; $lang["sales_debit"] = "Banka Kartı"; $lang["sales_delete_confirmation"] = "Satışı silmek istediğinize emin misiniz, bu işlem geri alınamaz"; $lang["sales_delete_entire_sale"] = "Satışın tamamını sil"; @@ -38,9 +38,9 @@ $lang["sales_find_or_scan_item_or_receipt"] = "Ürün yada Fatura Bul/Oku"; $lang["sales_giftcard"] = "Hediye Çeki"; $lang["sales_giftcard_number"] = "Hediye Çeki No"; $lang["sales_id"] = "Satış No"; -$lang["sales_invoice_enable"] = ""; -$lang["sales_invoice_number"] = ""; -$lang["sales_invoice_number_duplicate"] = ""; +$lang["sales_invoice_enable"] = "Create Invoice"; +$lang["sales_invoice_number"] = "Invoice #"; +$lang["sales_invoice_number_duplicate"] = "Please enter an unique invoice number"; $lang["sales_item_insufficient_of_stock"] = "Ürün Stoğu Yetersiz"; $lang["sales_item_name"] = "Ürün Adı"; $lang["sales_item_number"] = "Ürün No"; @@ -108,3 +108,4 @@ $lang["sales_invoice_filter"] = "Filter sales for "; $lang["sales_overview"] = "Overview"; $lang["sales_update"] = "Edit Sale"; $lang["sales_confirm_delete"] = "Are you sure you want to delete the selected sales?"; +$lang["sales_no_description"] = "None"; diff --git a/application/language/zh/sales_lang.php b/application/language/zh/sales_lang.php index f36ad537b..35bd948ab 100755 --- a/application/language/zh/sales_lang.php +++ b/application/language/zh/sales_lang.php @@ -17,8 +17,8 @@ $lang["sales_confirm_suspend_sale"] = "你確定要暫停銷售?"; $lang["sales_credit"] = "信用卡"; $lang["sales_customer"] = "客戶"; $lang["sales_date"] = "日期"; -$lang["sales_date_required"] = ""; -$lang["sales_date_type"] = ""; +$lang["sales_date_required"] = "A correct date needs to be filled in"; +$lang["sales_date_type"] = "Date field is required"; $lang["sales_debit"] = "簽帳卡"; $lang["sales_delete_confirmation"] = "你確定要刪除此銷售資料,這個動作不能撤消"; $lang["sales_delete_entire_sale"] = "刪除全部銷售資料"; @@ -38,9 +38,9 @@ $lang["sales_find_or_scan_item_or_receipt"] = "查找/掃描產品或收貨單"; $lang["sales_giftcard"] = "禮金券"; $lang["sales_giftcard_number"] = "禮金券編號"; $lang["sales_id"] = "銷售編號"; -$lang["sales_invoice_enable"] = ""; -$lang["sales_invoice_number"] = ""; -$lang["sales_invoice_number_duplicate"] = ""; +$lang["sales_invoice_enable"] = "Create Invoice"; +$lang["sales_invoice_number"] = "Invoice #"; +$lang["sales_invoice_number_duplicate"] = "Please enter an unique invoice number"; $lang["sales_item_insufficient_of_stock"] = "產品庫存不足"; $lang["sales_item_name"] = "產品名稱"; $lang["sales_item_number"] = "產品 #"; @@ -108,3 +108,4 @@ $lang["sales_invoice_filter"] = "Filter sales for "; $lang["sales_overview"] = "Overview"; $lang["sales_update"] = "Edit Sale"; $lang["sales_confirm_delete"] = "Are you sure you want to delete the selected sales?"; +$lang["sales_no_description"] = "None"; diff --git a/application/models/customer.php b/application/models/customer.php index 1b686c25a..f88ca5998 100644 --- a/application/models/customer.php +++ b/application/models/customer.php @@ -26,18 +26,23 @@ class Customer extends Person return ($query->num_rows()==1); } + function get_total_rows() + { + return $this->db->count_all('customers'); + } /* Returns all the customers */ - function get_all($limit=10000, $offset=0) - { + function get_all($rows = 0, $limit_from = 0) + { $this->db->from('customers'); $this->db->join('people','customers.person_id=people.person_id'); $this->db->where('deleted',0); $this->db->order_by("last_name", "asc"); - $this->db->limit($limit); - $this->db->offset($offset); + if ($rows > 0) { + $this->db->limit($rows, $limit_from); + } return $this->db->get(); } @@ -236,10 +241,24 @@ class Customer extends Person return $suggestions; } + + function get_found_rows($search) + { + $this->db->from('customers'); + $this->db->join('people','customers.person_id=people.person_id'); + $this->db->where("(first_name LIKE '%".$this->db->escape_like_str($search)."%' or + last_name LIKE '%".$this->db->escape_like_str($search)."%' or + email LIKE '%".$this->db->escape_like_str($search)."%' or + phone_number LIKE '%".$this->db->escape_like_str($search)."%' or + account_number LIKE '%".$this->db->escape_like_str($search)."%' or + CONCAT(`first_name`,' ',`last_name`) LIKE '%".$this->db->escape_like_str($search)."%') and deleted=0"); + return $this->db->get()->num_rows(); + } + /* Preform a search on customers */ - function search($search) + function search($search, $rows = 0, $limit_from = 0) { $this->db->from('customers'); $this->db->join('people','customers.person_id=people.person_id'); @@ -250,7 +269,9 @@ class Customer extends Person account_number LIKE '%".$this->db->escape_like_str($search)."%' or CONCAT(`first_name`,' ',`last_name`) LIKE '%".$this->db->escape_like_str($search)."%') and deleted=0"); $this->db->order_by("last_name", "asc"); - + if ($rows > 0) { + $this->db->limit($rows, $limit_from); + } return $this->db->get(); } diff --git a/application/models/employee.php b/application/models/employee.php index e67f303f5..c47a87c05 100644 --- a/application/models/employee.php +++ b/application/models/employee.php @@ -14,6 +14,10 @@ class Employee extends Person return ($query->num_rows()==1); } + function get_total_rows() + { + return $this->db->count_all('customers'); + } /* Returns all the employees */ @@ -240,10 +244,23 @@ class Employee extends Person } + function get_found_rows($search) + { + $this->db->from('employees'); + $this->db->join('people','employees.person_id=people.person_id'); + $this->db->where("(first_name LIKE '%".$this->db->escape_like_str($search)."%' or + last_name LIKE '%".$this->db->escape_like_str($search)."%' or + email LIKE '%".$this->db->escape_like_str($search)."%' or + phone_number LIKE '%".$this->db->escape_like_str($search)."%' or + username LIKE '%".$this->db->escape_like_str($search)."%' or + CONCAT(`first_name`,' ',`last_name`) LIKE '%".$this->db->escape_like_str($search)."%') and deleted=0"); + return $this->db->get()->num_rows(); + } + /* Preform a search on employees */ - function search($search) + function search($search, $rows = 0, $limit_from = 0) { $this->db->from('employees'); $this->db->join('people','employees.person_id=people.person_id'); @@ -254,7 +271,9 @@ class Employee extends Person username LIKE '%".$this->db->escape_like_str($search)."%' or CONCAT(`first_name`,' ',`last_name`) LIKE '%".$this->db->escape_like_str($search)."%') and deleted=0"); $this->db->order_by("last_name", "asc"); - + if ($rows > 0) { + $this->db->limit($rows, $limit_from); + } return $this->db->get(); } diff --git a/application/models/giftcard.php b/application/models/giftcard.php index c4bf3c450..017065427 100644 --- a/application/models/giftcard.php +++ b/application/models/giftcard.php @@ -20,7 +20,11 @@ class Giftcard extends CI_Model $query = $this->db->get('giftcards'); return $query->row(); } - + + function get_total_rows() + { + return $this->db->count_all('giftcards'); + } /* Returns all the giftcards */ @@ -230,7 +234,7 @@ class Giftcard extends CI_Model /* Preform a search on giftcards */ - function search($search) + function search($search, $rows = 0, $limit_from = 0) { $this->db->from('giftcards'); $this->db->join('people','giftcards.person_id=people.person_id'); @@ -240,10 +244,26 @@ class Giftcard extends CI_Model $this->db->or_like("giftcard_number",$this->db->escape_like_str($search)); $this->db->or_like("giftcards.person_id",$this->db->escape_like_str($search)); $this->db->where('deleted',$this->db->escape('0')); - $this->db->order_by("giftcard_number", "asc"); + $this->db->order_by("giftcard_number", "asc"); + if ($rows > 0) { + $this->db->limit($rows, $limit_from); + } return $this->db->get(); } + function get_found_rows($search) + { + $this->db->from('giftcards'); + $this->db->join('people','giftcards.person_id=people.person_id'); + $this->db->like("first_name",$this->db->escape_like_str($search)); + $this->db->or_like("last_name",$this->db->escape_like_str($search)); + $this->db->or_like("CONCAT(`first_name`,' ',`last_name`)",$this->db->escape_like_str($search)); + $this->db->or_like("giftcard_number",$this->db->escape_like_str($search)); + $this->db->or_like("giftcards.person_id",$this->db->escape_like_str($search)); + $this->db->where('deleted',$this->db->escape('0')); + return $this->db->get()->num_rows(); + } + public function get_giftcard_value( $giftcard_number ) { if ( !$this->exists( $this->get_giftcard_id($giftcard_number))) diff --git a/application/models/item.php b/application/models/item.php index 06740eaa9..2a7b06e9f 100644 --- a/application/models/item.php +++ b/application/models/item.php @@ -23,12 +23,48 @@ class Item extends CI_Model } $query=$this->db->get(); return ($query->num_rows()==1); - } + } + + function get_total_rows() + { + return $this->db->count_all('items'); + } + + function get_found_rows($search,$stock_location_id=-1,$low_inventory=0,$is_serialized=0,$no_description) + { + + $this->db->from("items"); + 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); + } + // open parentheses + $this->db->where("(name LIKE '%" . $search . "%' OR " . + "item_number LIKE '" . $search . "%' OR " . + $this->db->dbprefix('items').".item_id LIKE '" . $search . "%' OR " . + "category LIKE '%" . $search . "%')"); + // close parentheses + $this->db->where('deleted', 0); + if ($low_inventory !=0 ) + { + $this->db->where('quantity <=', 'reorder_level'); + } + if ($is_serialized !=0 ) + { + $this->db->where('serialized', 1); + } + if ($no_description!=0 ) + { + $this->db->where('description',''); + } + return $this->db->get()->num_rows(); + } /* Returns all the items */ - function get_all($stock_location_id=-1,$limit=10000,$offset=0) + function get_all($stock_location_id=-1, $rows = 0, $limit_from = 0) { $this->db->from('items'); if ($stock_location_id > -1) @@ -38,8 +74,9 @@ class Item extends CI_Model } $this->db->where('deleted',0); $this->db->order_by("name","asc"); - $this->db->limit($limit); - $this->db->offset($offset); + if ($rows > 0) { + $this->db->limit($rows, $limit_from); + } return $this->db->get(); } @@ -50,42 +87,6 @@ class Item extends CI_Model return $this->db->count_all_results(); } - function get_all_filtered($stock_location_id,$is_serialized=0,$no_description,$search_custom,$is_deleted)/**GARRISON MODIFIED 4/21/2013, Parq 131215 **/ - { - $this->db->from('items'); - $this->db->join('item_quantities','item_quantities.item_id=items.item_id'); - $this->db->where('location_id',$stock_location_id); - if ($is_serialized !=0 ) - { - $this->db->where('is_serialized',1); - } - if ($no_description!=0 ) - { - $this->db->where('description',''); - } - - -/**GARRISON SECTION ADDED 4/21/2013**/ -/** - if ($search_custom!=0 ) - { - $this->db->like('custom1',$search); - $this->db->or_like('custom2',$search); - $this->db->or_like('custom3',$search); - $this->db->or_like('custom4',$search); - $this->db->or_like('custom5',$search); - $this->db->or_like('custom6',$search); - $this->db->or_like('custom7',$search); - $this->db->or_like('custom8',$search); - $this->db->or_like('custom9',$search); - $this->db->or_like('custom10',$search); - } -**/ - $this->db->where('deleted',$is_deleted); - $this->db->order_by("name", "asc"); - return $this->db->get(); - } - /* Gets information about a particular item */ @@ -558,33 +559,42 @@ class Item extends CI_Model return $suggestions; } /** END GARRISON ADDED **/ + /* - Preform a search on items + Persform a search on items */ - function search($search,$stock_location_id) + function search($search,$stock_location_id=-1,$low_inventory=0,$is_serialized=0,$no_description,$rows = 0,$limit_from = 0) { - $this->db->from('items'); - $this->db->join('item_quantities','item_quantities.item_id=items.item_id'); - $this->db->where('location_id',$stock_location_id); - - $this->db->where("( - name LIKE '%".$this->db->escape_like_str($search)."%' or - item_number LIKE '%".$this->db->escape_like_str($search)."%' or - description LIKE '%".$this->db->escape_like_str($search)."%' or/**GARRISON ADDED 4/21/2013**/ - custom1 LIKE '%".$this->db->escape_like_str($search)."%' or/**GARRISON ADDED 4/22/2013**/ - custom2 LIKE '%".$this->db->escape_like_str($search)."%' or/**GARRISON ADDED 4/22/2013**/ - custom3 LIKE '%".$this->db->escape_like_str($search)."%' or/**GARRISON ADDED 4/22/2013**/ - custom4 LIKE '%".$this->db->escape_like_str($search)."%' or/**GARRISON ADDED 4/22/2013**/ - custom5 LIKE '%".$this->db->escape_like_str($search)."%' or/**GARRISON ADDED 4/22/2013**/ - custom6 LIKE '%".$this->db->escape_like_str($search)."%' or/**GARRISON ADDED 4/22/2013**/ - custom7 LIKE '%".$this->db->escape_like_str($search)."%' or/**GARRISON ADDED 4/22/2013**/ - custom8 LIKE '%".$this->db->escape_like_str($search)."%' or/**GARRISON ADDED 4/22/2013**/ - custom9 LIKE '%".$this->db->escape_like_str($search)."%' or/**GARRISON ADDED 4/22/2013**/ - custom10 LIKE '%".$this->db->escape_like_str($search)."%' or/**GARRISON ADDED 4/22/2013**/ - category LIKE '%".$this->db->escape_like_str($search)."%') and - deleted=0"); - $this->db->order_by("name", "asc"); - return $this->db->get(); + $this->db->from("items"); + 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); + } + // open parentheses + $this->db->where("(name LIKE '%" . $search . "%' OR " . + "item_number LIKE '" . $search . "%' OR " . + $this->db->dbprefix("items").".item_id LIKE '" . $search . "%' OR " . + "category LIKE '%" . $search . "%')"); + // close parentheses + $this->db->where('deleted', 0); + if ($low_inventory !=0 ) + { + $this->db->where('quantity <=', 'reorder_level'); + } + if ($is_serialized !=0 ) + { + $this->db->where('serialized', 1); + } + if ($no_description!=0 ) + { + $this->db->where('description',''); + } + $this->db->order_by('name', "asc"); + if ($rows > 0) { + $this->db->limit($rows, $limit_from); + } + return $this->db->get(); } function get_categories() diff --git a/application/models/item_kit.php b/application/models/item_kit.php index 84fcc7807..e808986e1 100644 --- a/application/models/item_kit.php +++ b/application/models/item_kit.php @@ -16,15 +16,21 @@ class Item_kit extends CI_Model /* Returns all the item kits */ - function get_all($limit=10000, $offset=0) + function get_all($rows = 0, $limit_from = 0) { $this->db->from('item_kits'); $this->db->order_by("name", "asc"); - $this->db->limit($limit); - $this->db->offset($offset); + if ($rows > 0) { + $this->db->limit($rows, $limit_from); + } return $this->db->get(); } + function get_total_rows() + { + return $this->db->count_all('item_kits'); + } + function count_all() { $this->db->from('item_kits'); @@ -159,13 +165,24 @@ class Item_kit extends CI_Model /* Preform a search on items */ - function search($search) + function search($search, $rows = 0, $limit_from = 0) { $this->db->from('item_kits'); $this->db->where("name LIKE '%".$this->db->escape_like_str($search)."%' or description LIKE '%".$this->db->escape_like_str($search)."%'"); $this->db->order_by("name", "asc"); + if ($rows > 0) { + $this->db->limit($rows, $limit_from); + } return $this->db->get(); } + + function get_found_rows($search) + { + $this->db->from('item_kits'); + $this->db->where("name LIKE '%".$this->db->escape_like_str($search)."%' or + description LIKE '%".$this->db->escape_like_str($search)."%'"); + return $this->db->get()->num_rows(); + } } ?> \ No newline at end of file diff --git a/application/models/supplier.php b/application/models/supplier.php index f3b356d95..8ffab1608 100644 --- a/application/models/supplier.php +++ b/application/models/supplier.php @@ -17,14 +17,15 @@ class Supplier extends Person /* Returns all the suppliers */ - function get_all($limit=10000, $offset=0) + function get_all($limit_from = 0, $rows = 0) { $this->db->from('suppliers'); $this->db->join('people','suppliers.person_id=people.person_id'); $this->db->where('deleted', 0); $this->db->order_by("last_name", "asc"); - $this->db->limit($limit); - $this->db->offset($offset); + if ($rows > 0) { + $this->db->limit($rows, $limit_from); + } return $this->db->get(); } @@ -237,10 +238,25 @@ class Supplier extends Person return $suggestions; } + + function get_found_rows($search) + { + $this->db->from('suppliers'); + $this->db->join('people','suppliers.person_id=people.person_id'); + $this->db->where("(first_name LIKE '%".$this->db->escape_like_str($search)."%' or + last_name LIKE '%".$this->db->escape_like_str($search)."%' or + company_name LIKE '%".$this->db->escape_like_str($search)."%' or + email LIKE '%".$this->db->escape_like_str($search)."%' or + phone_number LIKE '%".$this->db->escape_like_str($search)."%' or + account_number LIKE '%".$this->db->escape_like_str($search)."%' or + CONCAT(`first_name`,' ',`last_name`) LIKE '%".$this->db->escape_like_str($search)."%') and deleted=0"); + return $this->db->get()->num_rows(); + } + /* Perform a search on suppliers */ - function search($search) + function search($search, $rows = 0, $limit_from = 0) { $this->db->from('suppliers'); $this->db->join('people','suppliers.person_id=people.person_id'); @@ -252,7 +268,9 @@ class Supplier extends Person account_number LIKE '%".$this->db->escape_like_str($search)."%' or CONCAT(`first_name`,' ',`last_name`) LIKE '%".$this->db->escape_like_str($search)."%') and deleted=0"); $this->db->order_by("last_name", "asc"); - + if ($rows > 0) { + $this->db->limit($rows, $limit_from); + } return $this->db->get(); } diff --git a/application/views/giftcards/manage.php b/application/views/giftcards/manage.php index 0a3d49fe8..c1932935b 100644 --- a/application/views/giftcards/manage.php +++ b/application/views/giftcards/manage.php @@ -66,7 +66,7 @@ function post_giftcard_form_submit(response) ?> -pagination->create_links();?> +
-pagination->create_links();?> +
-pagination->create_links();?> +
-pagination->create_links();?> +