Enable sorting for employees, giftcards and suppliers (#555)

This commit is contained in:
jekkos committed 2016-05-12 21:29:27 +02:00
1 parent 139100db35
commit 7e8f0e1dc1
6 files changed
+14 -10

No files matched your search

+3 -1
View File
@@ -23,8 +23,10 @@ class Employees extends Person_controller
$search = $this->input->get('search');
$limit = $this->input->get('limit');
$offset = $this->input->get('offset');
$sort = $this->input->get('sort');
$order = $this->input->get('order');
$employees = $this->Employee->search($search, $limit, $offset);
$employees = $this->Employee->search($search, $limit, $offset, $sort, $order);
$total_rows = $this->Employee->get_found_rows($search);
$data_rows = array();
foreach($employees->result() as $person)
+3 -1
View File
@@ -23,8 +23,10 @@ class Suppliers extends Person_controller
$search = $this->input->get('search');
$limit = $this->input->get('limit');
$offset = $this->input->get('offset');
$sort = $this->input->get('sort');
$order = $this->input->get('order');
$suppliers = $this->Supplier->search($search, $limit, $offset);
$suppliers = $this->Supplier->search($search, $limit, $offset, $sort, $order);
$total_rows = $this->Supplier->get_found_rows($search);
$data_rows = array();
foreach($suppliers->result() as $supplier)
+2 -2
View File
@@ -291,7 +291,7 @@ function get_giftcards_manage_table_headers()
$CI =& get_instance();
$headers = array(
array('id' => $CI->lang->line('common_id')),
array('giftcard_id' => $CI->lang->line('common_id')),
array('last_name' => $CI->lang->line('common_last_name')),
array('first_name' => $CI->lang->line('common_first_name')),
array('giftcard_number' => $CI->lang->line('giftcards_giftcard_number')),
@@ -307,7 +307,7 @@ function get_giftcard_data_row($giftcard, $controller)
$controller_name=strtolower(get_class($CI));
return array (
'id' => $giftcard->giftcard_id,
'giftcard_id' => $giftcard->giftcard_id,
'last_name' => character_limiter($giftcard->last_name,13),
'first_name' => character_limiter($giftcard->first_name,13),
'giftcard_number' => $giftcard->giftcard_number,
+2 -2
View File
@@ -255,7 +255,7 @@ class Employee extends Person
/*
Preform a search on employees
*/
function search($search, $rows = 0, $limit_from = 0)
function search($search, $rows = 0, $limit_from = 0, $sort = "last_name", $order = "asc")
{
$this->db->from('employees');
$this->db->join('people','employees.person_id=people.person_id');
@@ -265,7 +265,7 @@ class Employee extends Person
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");
$this->db->order_by("last_name", "asc");
$this->db->order_by($sort, $order);
if ($rows > 0) {
$this->db->limit($rows, $limit_from);
}
+3 -3
View File
@@ -236,7 +236,7 @@ class Supplier extends Person
/*
Perform a search on suppliers
*/
function search($search, $rows = 0, $limit_from = 0)
function search($search, $rows = 0, $limit_from = 0, $sort = "last_name", $order = "asc")
{
$this->db->from('suppliers');
$this->db->join('people','suppliers.person_id=people.person_id');
@@ -248,11 +248,11 @@ class Supplier extends Person
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");
$this->db->order_by("last_name", "asc");
$this->db->order_by($sort, $order);
if ($rows > 0) {
$this->db->limit($rows, $limit_from);
}
return $this->db->get();
return $this->db->get();
}
}
+1 -1
View File
@@ -7,7 +7,7 @@ $(document).ready(function()
resource: '<?php echo site_url($controller_name);?>',
headers: <?php echo $table_headers; ?>,
pageSize: <?php echo $this->config->item('lines_per_page'); ?>,
uniqueId: 'id'
uniqueId: 'giftcard_id'
});
});
</script>