Enbable inventory, count_details in items (#293)

This commit is contained in:
jekkos
2016-04-21 08:48:40 +02:00
parent 48c49ddb74
commit 4c55da7229
11 changed files with 130 additions and 163 deletions

View File

@@ -153,9 +153,8 @@ class Items extends Secure_area implements iData_controller
echo json_encode($suggestions);
}
function get_row()
function get_row($item_id)
{
$item_id = $this->input->post('row_id');
$item_info = $this->Item->get_info($item_id);
$stock_location = $this->item_lib->get_item_location();
$item_quantity = $this->Item_quantity->get_item_quantity($item_id,$stock_location);
@@ -401,7 +400,7 @@ class Items extends Secure_area implements iData_controller
}
else//failure
{
echo json_encode(array('success'=>false, 'message'=>$this->lang->line('items_error_adding_updating').' '.$item_data['name'], 'item_id'=>-1));
echo json_encode(array('success'=>false, 'message'=>$this->lang->line('items_error_adding_updating').' '.$item_data['name'], 'id'=>-1));
}
}
@@ -465,12 +464,12 @@ class Items extends Secure_area implements iData_controller
if($this->Item_quantity->save($item_quantity_data,$item_id,$location_id))
{
echo json_encode(array('success'=>true,'message'=>$this->lang->line('items_successful_updating').' '.
$cur_item_info->name,'item_id'=>$item_id));
$cur_item_info->name,'id'=>$item_id));
}
else//failure
{
echo json_encode(array('success'=>false,'message'=>$this->lang->line('items_error_adding_updating').' '.
$cur_item_info->name,'item_id'=>-1));
$cur_item_info->name,'id'=>-1));
}
}

View File

@@ -346,7 +346,7 @@
{
dialog_support.hide();
}
table_support.handle_submit(response, stay_open);
table_support.handle_submit('<?php echo site_url('item_kits'); ?>', response, stay_open);
},
dataType: 'json'
});

View File

@@ -3,19 +3,12 @@
<script type="text/javascript">
$(document).ready(function()
{
/*enable_search({suggest_url: '<?php echo site_url("$controller_name/suggest_search")?>',
confirm_search_message: "<?php echo $this->lang->line("common_confirm_search")?>",
extra_params: {
'is_deleted' : function () {
// the comparison is split in two parts: find the index of the selected and check the index against the index in the listed strings of the multiselect menu
return $("#multi_filter li.selected").attr("data-original-index") == $("#filters option[value='is_deleted']").index() ? 1 : 0;
}
}
});*/
$('#generate_barcodes').click(function()
{
$(this).attr('href','index.php/items/generate_barcodes/'+selected.join(':'));
window.open(
'index.php/items/generate_barcodes/'+table_support.selected_ids().join(':'),
'_blank' // <- This is what makes it open in a new window.
);
});
// when any filter is clicked and the dropdown window is closed
@@ -43,30 +36,11 @@ $(document).ready(function()
});
table_support.init_delete('<?php echo $this->lang->line($controller_name."_confirm_delete")?>');
resize_thumbs();
var resize_thumbs = function() {
$('a.rollover').imgPreview();
};
});
function resize_thumbs()
{
$('a.rollover').imgPreview();
}
function post_bulk_form_submit(response)
{
if(!response.success)
{
set_feedback(response.message, 'alert alert-dismissible alert-danger', true);
}
else
{
var selected_item_ids=get_selected_values();
for(k=0;k<selected_item_ids.length;k++)
{
update_row(selected_item_ids[k],'<?php echo site_url("$controller_name/get_row")?>',resize_thumbs);
}
set_feedback(response.message, 'alert alert-dismissible alert-success', false);
}
}
</script>
<div id="title_bar" class="btn-toolbar">
@@ -89,7 +63,7 @@ function post_bulk_form_submit(response)
<span class="glyphicon glyphicon-trash"></span>
<?php echo $this->lang->line("common_delete");?>
</button>
<button id="bulk_edit" class="btn btn-default btn-sm" data-href='<?php echo site_url($controller_name."/bulk_edit"); ?>' title='<?php $this->lang->line('items_edit_multiple_items');?>'>
<button id="bulk_edit" class="btn btn-default btn-sm model-dlg modal-btn-submit" data-href='<?php echo site_url($controller_name."/bulk_edit"); ?>' title='<?php $this->lang->line('items_edit_multiple_items');?>'>
<span class="glyphicon glyphicon-edit"></span>
<?php echo $this->lang->line("items_bulk_edit"); ?>
</button>

View File

@@ -61,7 +61,7 @@
<!-- start mincss template tags -->
<link rel="stylesheet" type="text/css" href="dist/bootstrap.min.css?rel=9ed20b1ee8"/>
<link rel="stylesheet" type="text/css" href="dist/jquery-ui.css"/>
<link rel="stylesheet" type="text/css" href="dist/opensourcepos.min.css?rel=eb3fd6cbfa"/>
<link rel="stylesheet" type="text/css" href="dist/opensourcepos.min.css?rel=208d2df00e"/>
<!-- end mincss template tags -->
<!-- start minjs template tags -->
<script type="text/javascript" src="dist/opensourcepos.min.js?rel=3d8bf015a8" language="javascript"></script>

View File

@@ -5,6 +5,28 @@ $(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")?>');
$("#email").click(function(evvent)
{
do_email();
});
var do_email = function()
{
var recipients = $.map($("tr.selected a[href^='mailto:']"), function(element)
{
return $(element).attr('href').replace(/^mailto:/, '');
});
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>

View File

@@ -443,32 +443,32 @@ $(document).ready(function()
$('#finish_receiving_form').submit();
}
});
table_support.handle_submit = function(resource, response, stay_open)
{
if(response.success)
{
if (resource.match(/customers$/).length > 0)
{
$("#item").attr("value",response.id);
if (stay_open)
{
$("#add_item_form").ajaxSubmit();
}
else
{
$("#add_item_form").submit();
}
}
else
{
$("#supplier").attr("value",response.id);
$("#select_supplier_form").submit();
}
}
}
});
function post_item_form_submit(response, stay_open)
{
if(response.success)
{
$("#item").attr("value",response.item_id);
if (stay_open)
{
$("#add_item_form").ajaxSubmit();
}
else
{
$("#add_item_form").submit();
}
}
}
function post_person_form_submit(response)
{
if(response.success)
{
$("#supplier").attr("value",response.person_id);
$("#select_supplier_form").submit();
}
}
</script>
<?php $this->load->view("partial/footer"); ?>

View File

@@ -644,35 +644,33 @@ $(document).ready(function()
$('#finish_sale_form').submit();
}
});
table_support.handle_submit = function(resource, response, stay_open)
{
if(response.success) {
if (resource.match(/customers$/).length > 0)
{
$("#customer").val(response.id);
$("#select_customer_form").submit();
}
else
{
var $stock_location = $("select[name='stock_location']").val();
$("#item_location").val($stock_location);
$("#item").val(response.id);
if (stay_open)
{
$("#add_item_form").ajaxSubmit();
}
else
{
$("#add_item_form").submit();
}
}
}
}
});
function post_item_form_submit(response, stay_open)
{
if(response.success)
{
var $stock_location = $("select[name='stock_location']").val();
$("#item_location").val($stock_location);
$("#item").val(response.item_id);
if (stay_open)
{
$("#add_item_form").ajaxSubmit();
}
else
{
$("#add_item_form").submit();
}
}
}
function post_person_form_submit(response)
{
if(response.success)
{
$("#customer").val(response.person_id);
$("#select_customer_form").submit();
}
}
function check_payment_type_giftcard()
{
if ($("#payment_types").val() == "<?php echo $this->lang->line('sales_giftcard'); ?>")

55
dist/opensourcepos.js vendored
View File

@@ -49412,6 +49412,11 @@ $.tablesorter.addWidget({
});
};
var enable_actions = function() {
var selection_empty = selected_rows().length == 0;
$("#toolbar button").attr('disabled', selection_empty);
};
var table = function() {
return $("#table").data('bootstrap.table');
}
@@ -49450,13 +49455,6 @@ $.tablesorter.addWidget({
}, "json");
};
var do_email = function() {
var recipients = $.map($("tr.selected a[href^='mailto:']"), function(element) {
return $(element).attr('href').replace(/^mailto:/, '');
});
location.href = "mailto:" + recipients.join(",");
};
var highlight_rows = function (id, color) {
var original = $("tr.selected").css('backgroundColor');
var selector = ((id && "tr[data-uniqueid='" + id + "']")) || "tr.selected";
@@ -49466,19 +49464,6 @@ $.tablesorter.addWidget({
$("tr input:checkbox:checked").prop("checked", false);
};
var init_email = function() {
$("#email").click(function(evvent) {
do_email();
});
};
var enable_actions = function() {
var selection_empty = selected_rows().length == 0;
$("#toolbar .btn-toolbar button").attr('disabled', selection_empty);
var email_disabled = $("tr.selected a[href^='mailto:']").length == 0;
$("#email").attr('disabled', email_disabled);
};
var load_callback;
var load_success = function() {
@@ -49505,8 +49490,7 @@ $.tablesorter.addWidget({
queryParams: queryParams,
queryParamsType: 'limit'
});
init_email();
enable_actions();
table_support.enable_actions();
};
var init_delete = function (confirm_message) {
@@ -49529,17 +49513,19 @@ $.tablesorter.addWidget({
if (!response.success) {
set_feedback(response.message, 'alert alert-dismissible alert-danger', true);
} else {
//This is an update, just update one row
var message = response.message;
if (jQuery.inArray(id, selected_ids()) != -1) {
$.get({
url: resource + '/get_row/' + id,
success: function (response) {
table().updateByUniqueId({id: response.id, row: response});
highlight_rows();
set_feedback(message, 'alert alert-dismissible alert-success', false);
},
dataType: 'json'
if (selected_ids().length > 0) {
selected_ids().each(function(id) {
$.get({
url: resource + '/get_row/' + id,
success: function (response) {
table().updateByUniqueId({id: response.id, row: response});
highlight_rows();s
set_feedback(message, 'alert alert-dismissible alert-success', false);
},
dataType: 'json'
});
});
} else {
// call hightlight function once after refresh
@@ -49554,8 +49540,9 @@ $.tablesorter.addWidget({
handle_submit: handle_submit,
init_delete: init_delete,
init: init,
init_email: init_email,
refresh : refresh
refresh : refresh,
selected_ids : selected_ids,
enable_actions : enable_actions
});
})(window.table_support = window.table_support || {}, jQuery);;(function($) {

View File

File diff suppressed because one or more lines are too long

View File

@@ -133,6 +133,11 @@
});
};
var enable_actions = function() {
var selection_empty = selected_rows().length == 0;
$("#toolbar button").attr('disabled', selection_empty);
};
var table = function() {
return $("#table").data('bootstrap.table');
}
@@ -171,13 +176,6 @@
}, "json");
};
var do_email = function() {
var recipients = $.map($("tr.selected a[href^='mailto:']"), function(element) {
return $(element).attr('href').replace(/^mailto:/, '');
});
location.href = "mailto:" + recipients.join(",");
};
var highlight_rows = function (id, color) {
var original = $("tr.selected").css('backgroundColor');
var selector = ((id && "tr[data-uniqueid='" + id + "']")) || "tr.selected";
@@ -187,19 +185,6 @@
$("tr input:checkbox:checked").prop("checked", false);
};
var init_email = function() {
$("#email").click(function(evvent) {
do_email();
});
};
var enable_actions = function() {
var selection_empty = selected_rows().length == 0;
$("#toolbar .btn-toolbar button").attr('disabled', selection_empty);
var email_disabled = $("tr.selected a[href^='mailto:']").length == 0;
$("#email").attr('disabled', email_disabled);
};
var load_callback;
var load_success = function() {
@@ -226,8 +211,7 @@
queryParams: queryParams,
queryParamsType: 'limit'
});
init_email();
enable_actions();
table_support.enable_actions();
};
var init_delete = function (confirm_message) {
@@ -250,17 +234,19 @@
if (!response.success) {
set_feedback(response.message, 'alert alert-dismissible alert-danger', true);
} else {
//This is an update, just update one row
var message = response.message;
if (jQuery.inArray(id, selected_ids()) != -1) {
$.get({
url: resource + '/get_row/' + id,
success: function (response) {
table().updateByUniqueId({id: response.id, row: response});
highlight_rows();
set_feedback(message, 'alert alert-dismissible alert-success', false);
},
dataType: 'json'
if (selected_ids().length > 0) {
selected_ids().each(function(id) {
$.get({
url: resource + '/get_row/' + id,
success: function (response) {
table().updateByUniqueId({id: response.id, row: response});
highlight_rows();s
set_feedback(message, 'alert alert-dismissible alert-success', false);
},
dataType: 'json'
});
});
} else {
// call hightlight function once after refresh
@@ -275,8 +261,9 @@
handle_submit: handle_submit,
init_delete: init_delete,
init: init,
init_email: init_email,
refresh : refresh
refresh : refresh,
selected_ids : selected_ids,
enable_actions : enable_actions
});
})(window.table_support = window.table_support || {}, jQuery);

View File

@@ -61,7 +61,7 @@
<link rel="stylesheet" type="text/css" href="templates/spacelab/css/bootstrap.min.css?rel=9ed20b1ee8"/>
<!-- start mincss template tags -->
<link rel="stylesheet" type="text/css" href="dist/jquery-ui.css"/>
<link rel="stylesheet" type="text/css" href="dist/opensourcepos.min.css?rel=eb3fd6cbfa"/>
<link rel="stylesheet" type="text/css" href="dist/opensourcepos.min.css?rel=208d2df00e"/>
<!-- end mincss template tags -->
<link rel="stylesheet" type="text/css" href="templates/spacelab/css/style.css"/>
<!-- start minjs template tags -->