mirror of
https://github.com/opensourcepos/opensourcepos.git
synced 2026-04-26 01:53:16 -04:00
Bootstrap-tables integration for sales module (WIP) (#293)
Refactor manage_tables, remove public function identifiers
This commit is contained in:
@@ -47,10 +47,10 @@ class Sales extends Secure_area
|
||||
{
|
||||
$this->Sale->create_sales_items_temp_table();
|
||||
|
||||
$sale_info = $this->Sale->get_info($row_id)->result_array();
|
||||
$data_row = get_sales_manage_sale_data_row($sale_info[0], $this);
|
||||
$sale_info = $this->Sale->get_info($row_id)->row();
|
||||
$data_row = get_sale_data_row($sale_info, $this);
|
||||
|
||||
echo $data_row;
|
||||
echo json_encode($data_row);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -66,7 +66,7 @@ function get_sale_data_row($sale, $controller)
|
||||
'customer' => 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->chang_due),
|
||||
'change_due' => to_currency($sale->change_due),
|
||||
'payment_type' => $sale->payment_type,
|
||||
'invoice_number' => $sale->invoice_number,
|
||||
'receipt' => anchor($controller_name."/receipt/$sale->sale_id", '<span class="glyphicon glyphicon-print"></span>',
|
||||
|
||||
@@ -106,7 +106,7 @@ class Sale extends CI_Model
|
||||
|
||||
if (empty($search))
|
||||
{
|
||||
$this->db->where('sale_time BETWEEN '. $this->db->escape($filters['start_date']). ' AND '. $this->db->escape($filters['end_date']));
|
||||
//$this->db->where('sale_time BETWEEN '. $this->db->escape($filters['start_date']). ' AND '. $this->db->escape($filters['end_date']));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -2,8 +2,9 @@
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function()
|
||||
{
|
||||
table_support.init('<?php echo site_url($controller_name);?>', <?php echo $table_headers; ?>);
|
||||
table_support.init_delete('<?php echo $this->lang->line($controller_name."_confirm_delete")?>');
|
||||
table_support.init('<?php echo site_url($controller_name);?>', <?php echo $table_headers; ?>, {
|
||||
confirmDeteleMessage : '<?php echo $this->lang->line($controller_name."_confirm_delete")?>'
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
@@ -3,8 +3,9 @@
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function()
|
||||
{
|
||||
table_support.init('<?php echo site_url($controller_name);?>', <?php echo $table_headers; ?>);
|
||||
table_support.init_delete('<?php echo $this->lang->line($controller_name."_confirm_delete")?>');
|
||||
table_support.init('<?php echo site_url($controller_name);?>', <?php echo $table_headers; ?>, {
|
||||
confirmDeteleMessage: '<?php echo $this->lang->line($controller_name."_confirm_delete")?>'
|
||||
});
|
||||
|
||||
$('#generate_barcodes').click(function()
|
||||
{
|
||||
|
||||
@@ -3,8 +3,10 @@
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function()
|
||||
{
|
||||
table_support.init('<?php echo site_url($controller_name);?>', <?php echo $table_headers; ?>);
|
||||
table_support.init_delete('<?php echo $this->lang->line($controller_name."_confirm_delete")?>');
|
||||
table_support.init('<?php echo site_url($controller_name);?>', <?php echo $table_headers; ?>, {
|
||||
confirmDeleteMessage : '<?php echo $this->lang->line($controller_name."_confirm_delete")?>',
|
||||
enableActions: function() { }
|
||||
});
|
||||
|
||||
$("#email").click(function(evvent)
|
||||
{
|
||||
@@ -19,14 +21,7 @@ $(document).ready(function()
|
||||
});
|
||||
location.href = "mailto:" + recipients.join(",");
|
||||
};
|
||||
// TODO override enable_actions to enable/disable email HERE
|
||||
var enable_actions = table_support.enable_actions;
|
||||
/* table_support.enable_actions = function ()
|
||||
{
|
||||
enable_actions();
|
||||
|
||||
}
|
||||
*/
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
@@ -106,7 +106,7 @@ $(document).ready(function()
|
||||
$.get('<?php echo site_url() . "/sales/send_invoice/" . $sale_info['sale_id']; ?>',
|
||||
function(response) {
|
||||
dialog_support.hide();
|
||||
post_form_submit(response);
|
||||
table_support.handle_submit('<?php echo site_url('sales'); ?>', response);
|
||||
}, "json"
|
||||
);
|
||||
}
|
||||
@@ -166,11 +166,11 @@ $(document).ready(function()
|
||||
success: function(response)
|
||||
{
|
||||
dialog_support.hide();
|
||||
post_form_submit(response);
|
||||
table_support.handle_submit('<?php echo site_url('sales'); ?>', response);
|
||||
},
|
||||
error: function(jqXHR, textStatus, errorThrown)
|
||||
{
|
||||
post_form_submit({message: errorThrown});
|
||||
table_support.handle_submit('<?php echo site_url('sales'); ?>', { message : errorThrown, success: false });;
|
||||
},
|
||||
dataType: 'json'
|
||||
});
|
||||
@@ -217,14 +217,9 @@ $(document).ready(function()
|
||||
{
|
||||
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();
|
||||
table().remove({
|
||||
field: 'id',
|
||||
values: [id]
|
||||
});
|
||||
},
|
||||
error: function(jqXHR, textStatus, errorThrown) {
|
||||
|
||||
@@ -3,12 +3,6 @@
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function()
|
||||
{
|
||||
// refresh payment summaries at page bottom when a search complete takes place
|
||||
var on_complete = function(response)
|
||||
{
|
||||
$("#payment_summary").html(response.payment_summary);
|
||||
};
|
||||
|
||||
// when any filter is clicked and the dropdown window is closed
|
||||
$('#filters').on('hidan.bs.select', function(e)
|
||||
{
|
||||
@@ -26,14 +20,22 @@ $(document).ready(function()
|
||||
table_support.refresh();
|
||||
});
|
||||
|
||||
table_support.init('<?php echo site_url($controller_name);?>', <?php echo $table_headers; ?>, function() {
|
||||
return $.extend(arguments[0], {
|
||||
start_date: start_date,
|
||||
end_date: end_date,
|
||||
filters: $("#filters").val() || [""]
|
||||
});
|
||||
table_support.init('<?php echo site_url($controller_name);?>', <?php echo $table_headers; ?>, {
|
||||
|
||||
confirmDeleteMessage : '<?php echo $this->lang->line($controller_name."_confirm_delete")?>',
|
||||
|
||||
loadSuccess: function(response) {
|
||||
$("#payment_summary").html(response.payment_summary);
|
||||
},
|
||||
|
||||
queryParams: function() {
|
||||
return $.extend(arguments[0], {
|
||||
start_date: start_date,
|
||||
end_date: end_date,
|
||||
filters: $("#filters").val() || [""]
|
||||
});
|
||||
}
|
||||
});
|
||||
table_support.init_delete('<?php echo $this->lang->line($controller_name."_confirm_delete")?>');
|
||||
|
||||
});
|
||||
|
||||
@@ -66,7 +68,6 @@ $(document).ready(function()
|
||||
</div>
|
||||
|
||||
<div id="payment_summary">
|
||||
<?php //echo $payments_summary; ?>
|
||||
</div>
|
||||
|
||||
<?php $this->load->view("partial/footer"); ?>
|
||||
|
||||
27
dist/opensourcepos.js
vendored
27
dist/opensourcepos.js
vendored
@@ -49412,9 +49412,10 @@ $.tablesorter.addWidget({
|
||||
});
|
||||
};
|
||||
|
||||
var enable_actions = function() {
|
||||
var enable_actions = function(callback) {
|
||||
var selection_empty = selected_rows().length == 0;
|
||||
$("#toolbar button:not(.dropdown-toggle)").attr('disabled', selection_empty);
|
||||
typeof callback == 'function' && callback();
|
||||
};
|
||||
|
||||
var table = function() {
|
||||
@@ -49466,13 +49467,16 @@ $.tablesorter.addWidget({
|
||||
|
||||
var load_callback;
|
||||
|
||||
var load_success = function() {
|
||||
typeof load_callback == 'function' && load_callback();
|
||||
load_callback = undefined;
|
||||
dialog_support.init("a.modal-dlg, button.modal-dlg");
|
||||
var load_success = function(callback) {
|
||||
return function(response) {
|
||||
typeof load_callback == 'function' && load_callback();
|
||||
load_callback = undefined;
|
||||
dialog_support.init("a.modal-dlg, button.modal-dlg");
|
||||
typeof callback == 'function' && callback.call(this, response);
|
||||
}
|
||||
};
|
||||
|
||||
var init = function (resource, headers, queryParams) {
|
||||
var init = function (resource, headers, options) {
|
||||
$('#table').bootstrapTable({
|
||||
columns: headers,
|
||||
url: resource + '/search',
|
||||
@@ -49488,11 +49492,12 @@ $.tablesorter.addWidget({
|
||||
onUncheck: enable_actions,
|
||||
onCheckAll: enable_actions,
|
||||
onUncheckAll: enable_actions,
|
||||
onLoadSuccess: load_success,
|
||||
queryParams: queryParams,
|
||||
onLoadSuccess: load_success(options.onLoadSuccess),
|
||||
queryParams: options.queryParams,
|
||||
queryParamsType: 'limit'
|
||||
});
|
||||
table_support.enable_actions();
|
||||
enable_actions();
|
||||
init_delete(options.confirmDeleteMessage)
|
||||
};
|
||||
|
||||
var init_delete = function (confirm_message) {
|
||||
@@ -49542,11 +49547,9 @@ $.tablesorter.addWidget({
|
||||
|
||||
$.extend(table_support, {
|
||||
handle_submit: handle_submit,
|
||||
init_delete: init_delete,
|
||||
init: init,
|
||||
refresh : refresh,
|
||||
selected_ids : selected_ids,
|
||||
enable_actions : enable_actions
|
||||
selected_ids : selected_ids
|
||||
});
|
||||
|
||||
})(window.table_support = window.table_support || {}, jQuery);;(function($) {
|
||||
|
||||
@@ -133,9 +133,10 @@
|
||||
});
|
||||
};
|
||||
|
||||
var enable_actions = function() {
|
||||
var enable_actions = function(callback) {
|
||||
var selection_empty = selected_rows().length == 0;
|
||||
$("#toolbar button:not(.dropdown-toggle)").attr('disabled', selection_empty);
|
||||
typeof callback == 'function' && callback();
|
||||
};
|
||||
|
||||
var table = function() {
|
||||
@@ -187,13 +188,16 @@
|
||||
|
||||
var load_callback;
|
||||
|
||||
var load_success = function() {
|
||||
typeof load_callback == 'function' && load_callback();
|
||||
load_callback = undefined;
|
||||
dialog_support.init("a.modal-dlg, button.modal-dlg");
|
||||
var load_success = function(callback) {
|
||||
return function(response) {
|
||||
typeof load_callback == 'function' && load_callback();
|
||||
load_callback = undefined;
|
||||
dialog_support.init("a.modal-dlg, button.modal-dlg");
|
||||
typeof callback == 'function' && callback.call(this, response);
|
||||
}
|
||||
};
|
||||
|
||||
var init = function (resource, headers, queryParams) {
|
||||
var init = function (resource, headers, options) {
|
||||
$('#table').bootstrapTable({
|
||||
columns: headers,
|
||||
url: resource + '/search',
|
||||
@@ -209,11 +213,12 @@
|
||||
onUncheck: enable_actions,
|
||||
onCheckAll: enable_actions,
|
||||
onUncheckAll: enable_actions,
|
||||
onLoadSuccess: load_success,
|
||||
queryParams: queryParams,
|
||||
onLoadSuccess: load_success(options.onLoadSuccess),
|
||||
queryParams: options.queryParams,
|
||||
queryParamsType: 'limit'
|
||||
});
|
||||
table_support.enable_actions();
|
||||
enable_actions();
|
||||
init_delete(options.confirmDeleteMessage)
|
||||
};
|
||||
|
||||
var init_delete = function (confirm_message) {
|
||||
@@ -263,11 +268,9 @@
|
||||
|
||||
$.extend(table_support, {
|
||||
handle_submit: handle_submit,
|
||||
init_delete: init_delete,
|
||||
init: init,
|
||||
refresh : refresh,
|
||||
selected_ids : selected_ids,
|
||||
enable_actions : enable_actions
|
||||
selected_ids : selected_ids
|
||||
});
|
||||
|
||||
})(window.table_support = window.table_support || {}, jQuery);
|
||||
Reference in New Issue
Block a user