mirror of
https://github.com/opensourcepos/opensourcepos.git
synced 2026-05-24 08:20:54 -04:00
Fixes for item kits (new, update) (#507)
Fixes for takings overview (pagination, sorting) (#293) Fixes for item tax bulk update (#507) Table rows are highlighted again before delete (#507)
This commit is contained in:
@@ -24,7 +24,7 @@ class Customers extends Person_controller
|
||||
$limit = $this->input->get('limit');
|
||||
$offset = $this->input->get('offset');
|
||||
|
||||
$customers = $this->Customer->search($search, $limit, $offset);
|
||||
$customers = $this->Customer->search($search, $offset, $limit);
|
||||
$total_rows = $this->Customer->get_found_rows($search);
|
||||
|
||||
$data_rows = array();
|
||||
|
||||
@@ -24,7 +24,7 @@ class Employees extends Person_controller
|
||||
$limit = $this->input->get('limit');
|
||||
$offset = $this->input->get('offset');
|
||||
|
||||
$employees = $this->Employee->search($search, $offset, $limit);
|
||||
$employees = $this->Employee->search($search, $limit, $offset);
|
||||
$total_rows = $this->Employee->get_found_rows($search);
|
||||
$data_rows = array();
|
||||
foreach($employees->result() as $person)
|
||||
|
||||
@@ -27,7 +27,7 @@ class Giftcards extends Secure_area implements iData_controller
|
||||
$limit = $this->input->get('limit');
|
||||
$offset = $this->input->get('offset');
|
||||
|
||||
$giftcards = $this->Giftcard->search($search, $offset, $limit);
|
||||
$giftcards = $this->Giftcard->search($search, $limit, $offset);
|
||||
$total_rows = $this->Giftcard->get_found_rows($search);
|
||||
|
||||
$data_rows = array();
|
||||
|
||||
@@ -44,7 +44,7 @@ class Item_kits extends Secure_area implements iData_controller
|
||||
$offset = $this->input->get('offset');
|
||||
$lines_per_page = $this->Appconfig->get('lines_per_page');
|
||||
|
||||
$item_kits = $this->Item_kit->search($search, $offset, $limit);
|
||||
$item_kits = $this->Item_kit->search($search, $limit, $offset);
|
||||
$total_rows = $this->Item_kit->get_found_rows($search);
|
||||
//$links = $this->_initialize_pagination($this->Item_kit, $lines_per_page, $limit, $total_rows, 'search');
|
||||
$data_rows = array();
|
||||
@@ -67,7 +67,7 @@ class Item_kits extends Secure_area implements iData_controller
|
||||
function get_row($row_id)
|
||||
{
|
||||
// calculate the total cost and retail price of the Kit so it can be added to the table refresh
|
||||
$item_kit = $this->add_totals_to_item_kit($this->Item_kit->get_info($item_kit_id));
|
||||
$item_kit = $this->add_totals_to_item_kit($this->Item_kit->get_info($row_id));
|
||||
|
||||
echo json_encode(get_item_kit_data_row($item_kit, $this));
|
||||
}
|
||||
@@ -88,21 +88,10 @@ class Item_kits extends Secure_area implements iData_controller
|
||||
if ($this->Item_kit->save($item_kit_data, $item_kit_id))
|
||||
{
|
||||
//New item kit
|
||||
if ($item_kit_id==-1)
|
||||
{
|
||||
if ($item_kit_id==-1) {
|
||||
$item_kit_id = $item_kit_data['item_kit_id'];
|
||||
|
||||
echo json_encode(array('success'=>true,
|
||||
'message'=>$this->lang->line('item_kits_successful_adding').' '.$item_kit_data['name'],
|
||||
'id'=>$item_kit_id));
|
||||
}
|
||||
else //previous item
|
||||
{
|
||||
echo json_encode(array('success'=>true,
|
||||
'message'=>$this->lang->line('item_kits_successful_updating').' '.$item_kit_data['name'],
|
||||
'id'=>$item_kit_id));
|
||||
}
|
||||
|
||||
|
||||
if ( $this->input->post('item_kit_item') != null )
|
||||
{
|
||||
$item_kit_items = array();
|
||||
@@ -113,9 +102,12 @@ class Item_kits extends Secure_area implements iData_controller
|
||||
'quantity' => $quantity
|
||||
);
|
||||
}
|
||||
|
||||
$this->Item_kit_items->save($item_kit_items, $item_kit_id);
|
||||
|
||||
$success = $this->Item_kit_items->save($item_kit_items, $item_kit_id);
|
||||
}
|
||||
echo json_encode(array('success'=>$success,
|
||||
'message'=>$this->lang->line('item_kits_successful_adding').' '.$item_kit_data['name'],
|
||||
'id'=>$item_kit_id));
|
||||
}
|
||||
else//failure
|
||||
{
|
||||
|
||||
@@ -57,7 +57,7 @@ class Items extends Secure_area implements iData_controller
|
||||
$filledup = array_fill_keys($this->input->get('filters'), true);
|
||||
$filters = array_merge($filters, $filledup);
|
||||
|
||||
$items = $this->Item->search($search, $filters, $offset, $limit);
|
||||
$items = $this->Item->search($search, $filters, $limit, $offset);
|
||||
$total_rows = $this->Item->get_found_rows($search, $filters);
|
||||
|
||||
$data_rows = array();
|
||||
@@ -492,8 +492,7 @@ class Items extends Secure_area implements iData_controller
|
||||
}
|
||||
|
||||
//Item data could be empty if tax information is being updated
|
||||
$item_ids = explode(",", $items_to_update);
|
||||
if(empty($item_data) || $this->Item->update_multiple($item_data, $item_ids))
|
||||
if(empty($item_data) || $this->Item->update_multiple($item_data, $items_to_update))
|
||||
{
|
||||
$items_taxes_data = array();
|
||||
$tax_names = $this->input->post('tax_names');
|
||||
@@ -515,7 +514,7 @@ class Items extends Secure_area implements iData_controller
|
||||
$this->Item_taxes->save_multiple($items_taxes_data, $items_to_update);
|
||||
}
|
||||
|
||||
echo json_encode(array('success'=>true,'message'=>$this->lang->line('items_successful_bulk_edit'), 'id'=>$item_ids));
|
||||
echo json_encode(array('success'=>true,'message'=>$this->lang->line('items_successful_bulk_edit'), 'id'=>$items_to_update));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -75,7 +75,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, $offset, $limit);
|
||||
$sales = $this->Sale->search($search, $filters, $limit, $offset);
|
||||
$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);
|
||||
|
||||
@@ -24,7 +24,7 @@ class Suppliers extends Person_controller
|
||||
$limit = $this->input->get('limit');
|
||||
$offset = $this->input->get('offset');
|
||||
|
||||
$suppliers = $this->Supplier->search($search, $offset, $limit);
|
||||
$suppliers = $this->Supplier->search($search, $limit, $offset);
|
||||
$total_rows = $this->Supplier->get_found_rows($search);
|
||||
$data_rows = array();
|
||||
foreach($suppliers->result() as $supplier)
|
||||
|
||||
@@ -42,6 +42,7 @@ function get_sale_data_last_row($sales, $controller)
|
||||
}
|
||||
|
||||
return array(
|
||||
'id' => '-',
|
||||
'receipt_number' => '<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>'
|
||||
@@ -97,7 +98,7 @@ function get_sales_manage_payments_summary($payments, $sales, $controller)
|
||||
// therefore we remove from the total cash amount any change due
|
||||
if( $payment['payment_type'] == $CI->lang->line('sales_cash') )
|
||||
{
|
||||
foreach($sales as $key=>$sale)
|
||||
foreach($sales->result_array() as $key=>$sale)
|
||||
{
|
||||
$amount -= $sale['change_due'];
|
||||
}
|
||||
@@ -324,7 +325,7 @@ function get_item_kit_data_row($item_kit, $controller) {
|
||||
$controller_name=strtolower(get_class($CI));
|
||||
|
||||
return array (
|
||||
'id' => 'KIT '.$item_kit->item_kit_id,
|
||||
'id' => $item_kit->item_kit_id,
|
||||
'kit_name' => character_limiter($item_kit->name,13),
|
||||
'kit_description' => character_limiter($item_kit->description,13),
|
||||
'cost_price' => character_limiter($item_kit->total_cost_price,13),
|
||||
|
||||
@@ -237,7 +237,7 @@ class Item extends CI_Model
|
||||
*/
|
||||
public function update_multiple($item_data, $item_ids)
|
||||
{
|
||||
$this->db->where_in('item_id', explode(',', $item_ids[0]));
|
||||
$this->db->where_in('item_id', explode(',', $item_ids));
|
||||
|
||||
return $this->db->update('items', $item_data);
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ class Item_taxes extends CI_Model
|
||||
|
||||
function save_multiple(&$items_taxes_data, $item_ids)
|
||||
{
|
||||
foreach($item_ids as $item_id)
|
||||
foreach(explode(",", $item_ids) as $item_id)
|
||||
{
|
||||
$this->save($items_taxes_data, $item_id);
|
||||
}
|
||||
|
||||
@@ -83,7 +83,7 @@ class Sale extends CI_Model
|
||||
}
|
||||
|
||||
$this->db->group_by('sale_id');
|
||||
$this->db->order_by('sale_date', 'asc');
|
||||
$this->db->order_by('sale_date', 'desc');
|
||||
|
||||
if ($rows > 0)
|
||||
{
|
||||
|
||||
@@ -177,13 +177,16 @@ $(document).ready(function()
|
||||
{
|
||||
if(!confirm_message || confirm(confirm_message))
|
||||
{
|
||||
$('<input>').attr({
|
||||
/* $('<input>').attr({
|
||||
type: 'hidden',
|
||||
name: 'item_ids[]',
|
||||
value: table_support.selected_ids().join(",")
|
||||
name: 'item_ids',
|
||||
value: $(table_support.selected_ids())
|
||||
}).appendTo(form);
|
||||
|
||||
*/
|
||||
$(form).ajaxSubmit({
|
||||
beforeSubmit: function(arr, $form, options) {
|
||||
arr.push({name: 'item_ids', value: table_support.selected_ids()});
|
||||
},
|
||||
success:function(response)
|
||||
{
|
||||
dialog_support.hide();
|
||||
|
||||
@@ -64,7 +64,7 @@
|
||||
<link rel="stylesheet" type="text/css" href="dist/opensourcepos.min.css?rel=52c16a3504"/>
|
||||
<!-- end mincss template tags -->
|
||||
<!-- start minjs template tags -->
|
||||
<script type="text/javascript" src="dist/opensourcepos.min.js?rel=57782f0295" language="javascript"></script>
|
||||
<script type="text/javascript" src="dist/opensourcepos.min.js?rel=539c3f5252" language="javascript"></script>
|
||||
<!-- end minjs template tags -->
|
||||
<?php endif; ?>
|
||||
|
||||
|
||||
74
dist/opensourcepos.js
vendored
74
dist/opensourcepos.js
vendored
@@ -49355,7 +49355,6 @@ $.tablesorter.addWidget({
|
||||
})
|
||||
}, buttons.call(this, event)));
|
||||
|
||||
//event.stopPropagation();
|
||||
return false;
|
||||
});
|
||||
});
|
||||
@@ -49404,13 +49403,24 @@ $.tablesorter.addWidget({
|
||||
return $("#table input:checkbox:checked").parents("tr");
|
||||
};
|
||||
|
||||
var highlight_rows = function (id, color) {
|
||||
var original = $("tr.selected").css('backgroundColor');
|
||||
var selector = ((id && "tr[data-uniqueid='" + id + "']")) || "tr.selected";
|
||||
$(selector).removeClass("selected").animate({backgroundColor: color || '#e1ffdd'}, "slow", "linear")
|
||||
var row_selector = function(id) {
|
||||
return "tr[data-uniqueid='" + id + "']";
|
||||
};
|
||||
|
||||
var rows_selector = function(ids) {
|
||||
var selectors = [];
|
||||
ids = ids instanceof Array ? ids : ("" + ids).split(",");
|
||||
$.each(ids, function(index, element) {
|
||||
selectors.push(row_selector(element));
|
||||
});
|
||||
return selectors;;
|
||||
};
|
||||
|
||||
var highlight_row = function (id, color) {
|
||||
var original = $(row_selector(id,true)).css('backgroundColor');
|
||||
$(row_selector(id)).find("td").animate({backgroundColor: color || '#e1ffdd'}, "slow", "linear")
|
||||
.animate({backgroundColor: color || '#e1ffdd'}, 5000)
|
||||
.animate({backgroundColor: original}, "slow", "linear");
|
||||
$("tr input:checkbox:checked").prop("checked", false);
|
||||
};
|
||||
|
||||
var do_delete = function () {
|
||||
@@ -49418,24 +49428,21 @@ $.tablesorter.addWidget({
|
||||
$.post(options.resource + '/delete', {'ids[]': selected_ids()}, function (response) {
|
||||
//delete was successful, remove checkbox rows
|
||||
if (response.success) {
|
||||
table().remove({
|
||||
field: 'id',
|
||||
values: selected_ids()
|
||||
$(selected_rows()).each(function (index, element) {
|
||||
$(this).find("td").animate({backgroundColor: "green"}, 1200, "linear")
|
||||
.end().animate({opacity: 0}, 1200, "linear", function () {
|
||||
table().remove({
|
||||
field: 'id',
|
||||
values: selected_ids()
|
||||
});
|
||||
//refresh();
|
||||
enable_actions();
|
||||
});
|
||||
});
|
||||
|
||||
// animated delete below
|
||||
/*$(selected_rows()).each(function (index, dom) {
|
||||
/*$(this).find("td").animate({backgroundColor: "green"}, 1200, "linear")
|
||||
.end().animate({opacity: 0}, 1200, "linear", function () {
|
||||
$(this).remove();
|
||||
});
|
||||
});*/
|
||||
set_feedback(response.message, 'alert alert-dismissible alert-success', false);
|
||||
} else {
|
||||
set_feedback(response.message, 'alert alert-dismissible alert-danger', true);
|
||||
}
|
||||
refresh();
|
||||
enable_actions();
|
||||
}, "json");
|
||||
} else {
|
||||
return false;
|
||||
@@ -49445,7 +49452,7 @@ $.tablesorter.addWidget({
|
||||
var load_success = function(callback) {
|
||||
return function(response) {
|
||||
typeof options.load_callback == 'function' && options.load_callback();
|
||||
load_callback = undefined;
|
||||
options.load_callback = undefined;
|
||||
dialog_support.init("a.modal-dlg, button.modal-dlg");
|
||||
typeof callback == 'function' && callback.call(this, response);
|
||||
}
|
||||
@@ -49472,7 +49479,8 @@ $.tablesorter.addWidget({
|
||||
onUncheckAll: enable_actions,
|
||||
onLoadSuccess: load_success(options.onLoadSuccess),
|
||||
queryParamsType: 'limit',
|
||||
iconSize: 'sm'
|
||||
iconSize: 'sm',
|
||||
silentSort: true
|
||||
}));
|
||||
enable_actions();
|
||||
init_delete();
|
||||
@@ -49495,30 +49503,32 @@ $.tablesorter.addWidget({
|
||||
set_feedback(response.message, 'alert alert-dismissible alert-danger', true);
|
||||
} else {
|
||||
var message = response.message;
|
||||
|
||||
if (selected_ids().length > 0) {
|
||||
$.each(selected_ids(), function(element, id) {
|
||||
var selector = rows_selector(response.id);
|
||||
if ($(selector.join(",")).length > 0) {
|
||||
$.each(selector, function(index, element) {
|
||||
var id = $(element).data('uniqueid');
|
||||
$.get({
|
||||
url: resource + '/get_row/' + id,
|
||||
success: function (response) {
|
||||
table().updateByUniqueId({id: response.id, row: response});
|
||||
dialog_support.init("tr.selected a.modal-dlg");
|
||||
highlight_rows();
|
||||
set_feedback(message, 'alert alert-dismissible alert-success', false);
|
||||
table().updateByUniqueId({id: id, row: response});
|
||||
|
||||
dialog_support.init("a.modal-dlg");
|
||||
enable_actions();
|
||||
highlight_row(id);
|
||||
},
|
||||
dataType: 'json'
|
||||
});
|
||||
});
|
||||
} else {
|
||||
// call hightlight function once after refresh
|
||||
load_callback = function() {
|
||||
highlight_rows(id);
|
||||
options.load_callback = function() {
|
||||
enable_actions();
|
||||
highlight_row(id);
|
||||
};
|
||||
refresh();
|
||||
set_feedback(message, 'alert alert-dismissible alert-success', false);
|
||||
}
|
||||
set_feedback(message, 'alert alert-dismissible alert-success', false);
|
||||
}
|
||||
enable_actions();
|
||||
};
|
||||
|
||||
$.extend(table_support, {
|
||||
|
||||
4
dist/opensourcepos.min.js
vendored
4
dist/opensourcepos.min.js
vendored
File diff suppressed because one or more lines are too long
@@ -76,7 +76,6 @@
|
||||
})
|
||||
}, buttons.call(this, event)));
|
||||
|
||||
//event.stopPropagation();
|
||||
return false;
|
||||
});
|
||||
});
|
||||
@@ -125,13 +124,24 @@
|
||||
return $("#table input:checkbox:checked").parents("tr");
|
||||
};
|
||||
|
||||
var highlight_rows = function (id, color) {
|
||||
var original = $("tr.selected").css('backgroundColor');
|
||||
var selector = ((id && "tr[data-uniqueid='" + id + "']")) || "tr.selected";
|
||||
$(selector).removeClass("selected").animate({backgroundColor: color || '#e1ffdd'}, "slow", "linear")
|
||||
var row_selector = function(id) {
|
||||
return "tr[data-uniqueid='" + id + "']";
|
||||
};
|
||||
|
||||
var rows_selector = function(ids) {
|
||||
var selectors = [];
|
||||
ids = ids instanceof Array ? ids : ("" + ids).split(",");
|
||||
$.each(ids, function(index, element) {
|
||||
selectors.push(row_selector(element));
|
||||
});
|
||||
return selectors;;
|
||||
};
|
||||
|
||||
var highlight_row = function (id, color) {
|
||||
var original = $(row_selector(id,true)).css('backgroundColor');
|
||||
$(row_selector(id)).find("td").animate({backgroundColor: color || '#e1ffdd'}, "slow", "linear")
|
||||
.animate({backgroundColor: color || '#e1ffdd'}, 5000)
|
||||
.animate({backgroundColor: original}, "slow", "linear");
|
||||
$("tr input:checkbox:checked").prop("checked", false);
|
||||
};
|
||||
|
||||
var do_delete = function () {
|
||||
@@ -139,24 +149,21 @@
|
||||
$.post(options.resource + '/delete', {'ids[]': selected_ids()}, function (response) {
|
||||
//delete was successful, remove checkbox rows
|
||||
if (response.success) {
|
||||
table().remove({
|
||||
field: 'id',
|
||||
values: selected_ids()
|
||||
$(selected_rows()).each(function (index, element) {
|
||||
$(this).find("td").animate({backgroundColor: "green"}, 1200, "linear")
|
||||
.end().animate({opacity: 0}, 1200, "linear", function () {
|
||||
table().remove({
|
||||
field: 'id',
|
||||
values: selected_ids()
|
||||
});
|
||||
//refresh();
|
||||
enable_actions();
|
||||
});
|
||||
});
|
||||
|
||||
// animated delete below
|
||||
/*$(selected_rows()).each(function (index, dom) {
|
||||
/*$(this).find("td").animate({backgroundColor: "green"}, 1200, "linear")
|
||||
.end().animate({opacity: 0}, 1200, "linear", function () {
|
||||
$(this).remove();
|
||||
});
|
||||
});*/
|
||||
set_feedback(response.message, 'alert alert-dismissible alert-success', false);
|
||||
} else {
|
||||
set_feedback(response.message, 'alert alert-dismissible alert-danger', true);
|
||||
}
|
||||
refresh();
|
||||
enable_actions();
|
||||
}, "json");
|
||||
} else {
|
||||
return false;
|
||||
@@ -166,7 +173,7 @@
|
||||
var load_success = function(callback) {
|
||||
return function(response) {
|
||||
typeof options.load_callback == 'function' && options.load_callback();
|
||||
load_callback = undefined;
|
||||
options.load_callback = undefined;
|
||||
dialog_support.init("a.modal-dlg, button.modal-dlg");
|
||||
typeof callback == 'function' && callback.call(this, response);
|
||||
}
|
||||
@@ -193,7 +200,9 @@
|
||||
onUncheckAll: enable_actions,
|
||||
onLoadSuccess: load_success(options.onLoadSuccess),
|
||||
queryParamsType: 'limit',
|
||||
iconSize: 'sm'
|
||||
iconSize: 'sm',
|
||||
silentSort: true,
|
||||
paginationVAlign: 'bottom'
|
||||
}));
|
||||
enable_actions();
|
||||
init_delete();
|
||||
@@ -216,30 +225,32 @@
|
||||
set_feedback(response.message, 'alert alert-dismissible alert-danger', true);
|
||||
} else {
|
||||
var message = response.message;
|
||||
|
||||
if (selected_ids().length > 0) {
|
||||
$.each(selected_ids(), function(element, id) {
|
||||
var selector = rows_selector(response.id);
|
||||
if ($(selector.join(",")).length > 0) {
|
||||
$.each(selector, function(index, element) {
|
||||
var id = $(element).data('uniqueid');
|
||||
$.get({
|
||||
url: resource + '/get_row/' + id,
|
||||
success: function (response) {
|
||||
table().updateByUniqueId({id: response.id, row: response});
|
||||
dialog_support.init("tr.selected a.modal-dlg");
|
||||
highlight_rows();
|
||||
set_feedback(message, 'alert alert-dismissible alert-success', false);
|
||||
table().updateByUniqueId({id: id, row: response});
|
||||
|
||||
dialog_support.init("a.modal-dlg");
|
||||
enable_actions();
|
||||
highlight_row(id);
|
||||
},
|
||||
dataType: 'json'
|
||||
});
|
||||
});
|
||||
} else {
|
||||
// call hightlight function once after refresh
|
||||
load_callback = function() {
|
||||
highlight_rows(id);
|
||||
options.load_callback = function() {
|
||||
enable_actions();
|
||||
highlight_row(id);
|
||||
};
|
||||
refresh();
|
||||
set_feedback(message, 'alert alert-dismissible alert-success', false);
|
||||
}
|
||||
set_feedback(message, 'alert alert-dismissible alert-success', false);
|
||||
}
|
||||
enable_actions();
|
||||
};
|
||||
|
||||
$.extend(table_support, {
|
||||
|
||||
@@ -65,7 +65,7 @@
|
||||
<!-- end mincss template tags -->
|
||||
<link rel="stylesheet" type="text/css" href="templates/spacelab/css/style.css"/>
|
||||
<!-- start minjs template tags -->
|
||||
<script type="text/javascript" src="dist/opensourcepos.min.js?rel=57782f0295" language="javascript"></script>
|
||||
<script type="text/javascript" src="dist/opensourcepos.min.js?rel=539c3f5252" language="javascript"></script>
|
||||
<!-- end minjs template tags -->
|
||||
<?php endif; ?>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user