mirror of
https://github.com/opensourcepos/opensourcepos.git
synced 2026-05-24 08:20:54 -04:00
Enable sorting in takings (with static row below the table) (#293, #507)
This commit is contained in:
@@ -26,8 +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');
|
||||
$sort = $this->input->get('sort');
|
||||
$order = $this->input->get('order');
|
||||
|
||||
$giftcards = $this->Giftcard->search($search, $limit, $offset);
|
||||
$giftcards = $this->Giftcard->search($search, $limit, $offset, $sort, $order);
|
||||
$total_rows = $this->Giftcard->get_found_rows($search);
|
||||
|
||||
$data_rows = array();
|
||||
|
||||
@@ -60,6 +60,8 @@ class Sales extends Secure_area
|
||||
$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');
|
||||
|
||||
$is_valid_receipt = isset($search) ? $this->sale_lib->is_valid_receipt($search) : FALSE;
|
||||
|
||||
@@ -75,7 +77,7 @@ class Sales extends Secure_area
|
||||
$filledup = array_fill_keys($this->input->get('filters'), TRUE);
|
||||
$filters = array_merge($filters, $filledup);
|
||||
|
||||
$sales = $this->Sale->search($search, $filters, $limit, $offset);
|
||||
$sales = $this->Sale->search($search, $filters, $limit, $offset, $sort, $order);
|
||||
$total_rows = $this->Sale->get_found_rows($search, $filters);
|
||||
$payments = $this->Sale->get_payments_summary($search, $filters);
|
||||
$payment_summary = get_sales_manage_payments_summary($payments, $sales, $this);
|
||||
|
||||
@@ -6,9 +6,8 @@ function get_sales_manage_table_headers()
|
||||
|
||||
$headers = array(
|
||||
array('sale_id' => $CI->lang->line('common_id')),
|
||||
array('receipt_number' => $CI->lang->line('sales_receipt_number')),
|
||||
array('sale_time' => $CI->lang->line('sales_sale_time')),
|
||||
array('customer' => $CI->lang->line('customers_customer')),
|
||||
array('customer_name' => $CI->lang->line('customers_customer')),
|
||||
array('amount_tendered' => $CI->lang->line('sales_amount_tendered')),
|
||||
array('amount_due' => $CI->lang->line('sales_amount_due')),
|
||||
array('change_due' => $CI->lang->line('sales_change_due')),
|
||||
@@ -18,10 +17,10 @@ function get_sales_manage_table_headers()
|
||||
if($CI->config->item('invoice_enable') == TRUE)
|
||||
{
|
||||
$headers[] = array('invoice_number' => $CI->lang->line('sales_invoice_number'));
|
||||
$headers[] = array('invoice' => ' ');
|
||||
$headers[] = array('invoice' => ' ', 'sortable' => FALSE);
|
||||
}
|
||||
|
||||
return transform_headers(array_merge($headers, array(array( 'receipt' => ' ' ))));
|
||||
return transform_headers(array_merge($headers, array(array( 'receipt' => ' ', 'sortable' => FALSE ))));
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -44,7 +43,7 @@ function get_sale_data_last_row($sales, $controller)
|
||||
|
||||
return array(
|
||||
'sale_id' => '-',
|
||||
'receipt_number' => '<b>'.$CI->lang->line('sales_total').'</b>',
|
||||
'sale_time' => '<b>'.$CI->lang->line('sales_total').'</b>',
|
||||
'amount_tendered' => '<b>'. to_currency($sum_amount_tendered).'</b>',
|
||||
'amount_due' => '<b>'.to_currency($sum_change_due).'</b>'
|
||||
);
|
||||
@@ -57,9 +56,8 @@ function get_sale_data_row($sale, $controller)
|
||||
|
||||
$row = array (
|
||||
'sale_id' => $sale->sale_id,
|
||||
'receipt_number' => 'POS ' . $sale->sale_id,
|
||||
'sale_time' => date( $CI->config->item('dateformat') . ' ' . $CI->config->item('timeformat'), strtotime($sale->sale_time) ),
|
||||
'customer' => character_limiter( $sale->customer_name, 25),
|
||||
'customer_name' => character_limiter( $sale->customer_name, 25),
|
||||
'amount_tendered' => to_currency( $sale->amount_tendered ),
|
||||
'amount_due' => to_currency($sale->amount_due),
|
||||
'change_due' => to_currency($sale->change_due),
|
||||
@@ -124,10 +122,19 @@ function transform_headers_readonly($array)
|
||||
|
||||
function transform_headers($array)
|
||||
{
|
||||
return json_encode(array_map(function($v) {
|
||||
return array('field' => key($v), 'title' => current($v), 'checkbox' => (key($v) == 'checkbox'), 'sortable' => current($v) != ''
|
||||
&& current($v) != 'select' && key($v) != 'item_pic' && current($v) != ' ');
|
||||
}, array_merge(array(array('checkbox' => 'select')), $array, array(array('edit' => '')))));
|
||||
$result = array();
|
||||
$array = array_merge(array(array('checkbox' => 'select', 'sortable' => FALSE)),
|
||||
$array, array(array('edit' => '')));
|
||||
foreach($array as $element)
|
||||
{
|
||||
$result[] = array('field' => key($element),
|
||||
'title' => current($element),
|
||||
'sortable' => isset($element['sortable']) ?
|
||||
$element['sortable'] : current($element) != '',
|
||||
'checkbox' => isset($element['checkbox']) ?
|
||||
$element['checkbox'] : FALSE);
|
||||
}
|
||||
return json_encode($result);
|
||||
}
|
||||
|
||||
function get_people_manage_table_headers()
|
||||
@@ -144,7 +151,7 @@ function get_people_manage_table_headers()
|
||||
|
||||
if($CI->Employee->has_grant('messages', $CI->session->userdata('person_id')))
|
||||
{
|
||||
$headers[] = array('messages' => '');
|
||||
$headers[] = array('messages' => '', 'sortable' => FALSE);
|
||||
}
|
||||
|
||||
return transform_headers($headers);
|
||||
@@ -223,8 +230,8 @@ function get_items_manage_table_headers()
|
||||
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('tax_percents' => $CI->lang->line('items_tax_percents'), 'sortable' => FALSE),
|
||||
array('item_pic' => $CI->lang->line('items_image'), 'sortable' => FALSE),
|
||||
array('inventory' => ''),
|
||||
array('stock' => '')
|
||||
);
|
||||
@@ -286,7 +293,7 @@ function get_giftcards_manage_table_headers()
|
||||
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')),
|
||||
array('giftcard_value' => $CI->lang->line('giftcards_card_value'))
|
||||
array('value' => $CI->lang->line('giftcards_card_value'))
|
||||
);
|
||||
|
||||
return transform_headers($headers);
|
||||
@@ -302,7 +309,7 @@ function get_giftcard_data_row($giftcard, $controller)
|
||||
'last_name' => character_limiter($giftcard->last_name,13),
|
||||
'first_name' => character_limiter($giftcard->first_name,13),
|
||||
'giftcard_number' => $giftcard->giftcard_number,
|
||||
'giftcard_value' => to_currency($giftcard->value),
|
||||
'value' => to_currency($giftcard->value),
|
||||
'edit' => anchor($controller_name."/view/$giftcard->giftcard_id", '<span class="glyphicon glyphicon-edit"></span>',
|
||||
array('class'=>"modal-dlg modal-btn-submit", 'title'=>$CI->lang->line($controller_name.'_update'))
|
||||
));
|
||||
@@ -316,8 +323,8 @@ function get_item_kits_manage_table_headers()
|
||||
array('item_kit_id' => $CI->lang->line('item_kits_kit')),
|
||||
array('name' => $CI->lang->line('item_kits_name')),
|
||||
array('description' => $CI->lang->line('item_kits_description')),
|
||||
array('cost_price' => $CI->lang->line('items_cost_price')),
|
||||
array('unit_price' => $CI->lang->line('items_unit_price'))
|
||||
array('cost_price' => $CI->lang->line('items_cost_price'), 'sortable' => FALSE),
|
||||
array('unit_price' => $CI->lang->line('items_unit_price'), 'sortable' => FALSE)
|
||||
);
|
||||
|
||||
return transform_headers($headers);
|
||||
|
||||
@@ -195,7 +195,7 @@ class Giftcard extends CI_Model
|
||||
/*
|
||||
Preform a search on giftcards
|
||||
*/
|
||||
function search($search, $rows = 0, $limit_from = 0)
|
||||
function search($search, $rows = 0, $limit_from = 0, $sort = 'giftcard_number', $order = 'asc')
|
||||
{
|
||||
$this->db->from('giftcards');
|
||||
$this->db->join('people', 'giftcards.person_id=people.person_id', 'left');
|
||||
@@ -207,7 +207,7 @@ class Giftcard extends CI_Model
|
||||
$this->db->or_like('giftcards.person_id', $this->db->escape_like_str($search));
|
||||
$this->db->group_end();
|
||||
$this->db->where('giftcards.deleted', 0);
|
||||
$this->db->order_by('giftcard_number', 'asc');
|
||||
$this->db->order_by($sort, $order);
|
||||
|
||||
if ($rows > 0)
|
||||
{
|
||||
|
||||
@@ -28,7 +28,7 @@ class Sale extends CI_Model
|
||||
/*
|
||||
Get the sales data for the takings (sales/manage) view
|
||||
*/
|
||||
public function search($search, $filters, $rows=0, $limit_from=0)
|
||||
public function search($search, $filters, $rows = 0, $limit_from = 0, $sort = 'sale_date', $order = 'desc')
|
||||
{
|
||||
$this->db->select('sale_id, sale_date, sale_time, SUM(quantity_purchased) AS items_purchased,
|
||||
CONCAT(customer.first_name, " ", customer.last_name) AS customer_name,
|
||||
@@ -83,7 +83,7 @@ class Sale extends CI_Model
|
||||
}
|
||||
|
||||
$this->db->group_by('sale_id');
|
||||
$this->db->order_by('sale_date', 'desc');
|
||||
$this->db->order_by($sort, $order);
|
||||
|
||||
if ($rows > 0)
|
||||
{
|
||||
|
||||
@@ -7,6 +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',
|
||||
confirmDeleteMessage : '<?php echo $this->lang->line($controller_name."_confirm_delete")?>'
|
||||
});
|
||||
});
|
||||
|
||||
@@ -9,6 +9,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: 'item_kit_id',
|
||||
confirmDeleteMessage: '<?php echo $this->lang->line($controller_name."_confirm_delete")?>'
|
||||
});
|
||||
|
||||
|
||||
@@ -37,6 +37,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: 'items.item_id',
|
||||
confirmDeleteMessage : '<?php echo $this->lang->line($controller_name."_confirm_delete")?>',
|
||||
queryParams: function() {
|
||||
return $.extend(arguments[0], {
|
||||
|
||||
@@ -9,6 +9,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: 'person_id',
|
||||
confirmDeleteMessage : '<?php echo $this->lang->line($controller_name."_confirm_delete")?>',
|
||||
enableActions: function()
|
||||
{
|
||||
|
||||
@@ -54,10 +54,6 @@
|
||||
</fieldset>
|
||||
<?php echo form_close(); ?>
|
||||
|
||||
<?php echo form_open("receivings/delete/".$receiving_info['receiving_id'], array('id'=>'recvs_delete_form')); ?>
|
||||
<?php echo form_hidden('receiving_id', $receiving_info['receiving_id']);?>
|
||||
<?php echo form_close(); ?>
|
||||
|
||||
<script type="text/javascript" language="javascript">
|
||||
$(document).ready(function()
|
||||
{
|
||||
@@ -165,34 +161,10 @@ $(document).ready(function()
|
||||
?>
|
||||
}
|
||||
}, dialog_support.error));
|
||||
|
||||
$('#recvs_delete_form').submit(function()
|
||||
{
|
||||
if (confirm('<?php echo $this->lang->line("recvs_delete_confirmation"); ?>'))
|
||||
{
|
||||
var id = $("input[name='receiving_id']").val();
|
||||
$(this).ajaxSubmit({
|
||||
success: function(response)
|
||||
{
|
||||
dialog_support.hide();
|
||||
set_feedback(response.message, 'alert alert-dismissible alert-success', false);
|
||||
var $element = get_table_row(id).parent().parent();
|
||||
$element.find("td").animate({backgroundColor:"green"},1200,"linear")
|
||||
.end().animate({opacity:0},1200,"linear",function()
|
||||
{
|
||||
$element.next().remove();
|
||||
$(this).remove();
|
||||
//Re-init sortable table as we removed a row
|
||||
update_sortable_table();
|
||||
});
|
||||
},
|
||||
error: function(jqXHR, textStatus, errorThrown) {
|
||||
set_feedback(textStatus, 'alert alert-dismissible alert-danger', true);
|
||||
},
|
||||
dataType:'json'
|
||||
});
|
||||
}
|
||||
return false;
|
||||
|
||||
$('button#delete').click(function() {
|
||||
dialog_support.hide();
|
||||
table_support.do_delete('<?php echo site_url('receivings'); ?>', <?php echo $receiving_info['receiving_id']; ?>);
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
@@ -158,7 +158,7 @@ $(document).ready(function()
|
||||
|
||||
$('button#delete').click(function() {
|
||||
dialog_support.hide();
|
||||
table_support.do_delete();
|
||||
table_support.do_delete('<?php echo site_url('sales'); ?>', <?php echo $sale_info['sale_id']; ?>);
|
||||
});
|
||||
|
||||
var submit_form = function()
|
||||
|
||||
@@ -22,6 +22,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: 'sale_id',
|
||||
confirmDeleteMessage : '<?php echo $this->lang->line($controller_name."_confirm_delete")?>',
|
||||
onLoadSuccess: function(response) {
|
||||
$("#payment_summary").html(response.payment_summary);
|
||||
|
||||
@@ -118,7 +118,7 @@
|
||||
|
||||
var selected_ids = function () {
|
||||
return $.map(table().getSelections(), function (element) {
|
||||
return element.id;
|
||||
return element[options.uniqueId];
|
||||
});
|
||||
};
|
||||
|
||||
@@ -146,9 +146,9 @@
|
||||
.animate({backgroundColor: original}, "slow", "linear");
|
||||
};
|
||||
|
||||
var do_delete = function () {
|
||||
var do_delete = function (url, ids) {
|
||||
if (confirm(options.confirmDeleteMessage)) {
|
||||
$.post(options.resource + '/delete', {'ids[]': selected_ids()}, function (response) {
|
||||
$.post((url || options.resource) + '/delete', {'ids[]': ids || selected_ids()}, function (response) {
|
||||
//delete was successful, remove checkbox rows
|
||||
if (response.success) {
|
||||
$(selected_rows()).each(function (index, element) {
|
||||
@@ -196,7 +196,7 @@
|
||||
showColumns: true,
|
||||
clickToSelect: true,
|
||||
toolbar: '#toolbar',
|
||||
uniqueId: 'id',
|
||||
uniqueId: options.uniqueId || 'id',
|
||||
onCheck: enable_actions,
|
||||
onUncheck: enable_actions,
|
||||
onCheckAll: enable_actions,
|
||||
|
||||
Reference in New Issue
Block a user