|
|
@@ -1,6 +1,6 @@
|
|
|
<%= form_for(AvailableProduct.new, :html => {:class=>"form-horizontal", :id=> "available_products_form"}) do |f| %>
|
|
|
<div class="portlet-body form">
|
|
|
- <div id="error_explanation"></div>
|
|
|
+ <div id="error_explanation"></div>
|
|
|
<table class="table table-striped table-bordered table-hover tableadvancedprintableAjax" id="pointsale_stock" data-source="<%= stock_by_pointsale_path(format: "json") %>" >
|
|
|
<thead>
|
|
|
<tr>
|
|
|
@@ -18,7 +18,7 @@
|
|
|
<th>Precio</th>
|
|
|
</tr>
|
|
|
</thead>
|
|
|
- <tbody>
|
|
|
+ <tbody>
|
|
|
</tbody>
|
|
|
</table>
|
|
|
</div>
|
|
|
@@ -31,26 +31,23 @@
|
|
|
table = $('#pointsale_stock').DataTable();
|
|
|
if($('#pointsale').val()) {
|
|
|
$('#pointsale').trigger("change");
|
|
|
- }
|
|
|
+ }
|
|
|
});
|
|
|
|
|
|
$('body').barcodeListener().on('barcode.valid', function(e, code) {
|
|
|
$('input[type=search]').val(code);
|
|
|
- $('#pointsale_stock input').unbind();
|
|
|
+ $('#pointsale_stock input').unbind();
|
|
|
$('#pointsale_stock').dataTable().fnFilter(code);
|
|
|
- });
|
|
|
-
|
|
|
- $('#pointsale').on('change', function(e) {
|
|
|
- getTotalProducts();
|
|
|
});
|
|
|
|
|
|
$('#category, #sub_category, #pointsale').on('change', function(e) {
|
|
|
table.draw();
|
|
|
getTotalProducts();
|
|
|
+ getTotalInvested();
|
|
|
});
|
|
|
|
|
|
function getSub_categories() {
|
|
|
- $('#sub_category').attr('disabled', true);
|
|
|
+ $('#sub_category').attr('disabled', true);
|
|
|
category = $('#category').val() ? $('#category').val() : 0;
|
|
|
$.ajax({
|
|
|
type: "get",
|
|
|
@@ -63,13 +60,13 @@
|
|
|
value: data[i].id,
|
|
|
text : data[i].category
|
|
|
}));
|
|
|
-
|
|
|
- }
|
|
|
- $('#sub_category').select2({ allowClear: true, placeholder: 'Todas'});
|
|
|
- $('#sub_category').attr('disabled', false);
|
|
|
- $('#sub_category').select2('val', null);
|
|
|
+
|
|
|
+ }
|
|
|
+ $('#sub_category').select2({ allowClear: true, placeholder: 'Todas'});
|
|
|
+ $('#sub_category').attr('disabled', false);
|
|
|
+ $('#sub_category').select2('val', null);
|
|
|
}
|
|
|
- });
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
function getTotalProducts() {
|
|
|
@@ -90,10 +87,42 @@
|
|
|
url: '/total_products_by_pointsale?' + uri,
|
|
|
dataType: 'json',
|
|
|
success: function(data) {
|
|
|
- App.unblockUI($("#container_total_prods"));
|
|
|
+ App.unblockUI($("#container_total_prods"));
|
|
|
$('#total_prods').html(Math.round(data));
|
|
|
}
|
|
|
- });
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ function getTotalInvested() {
|
|
|
+ var location = $('#pointsale').val();
|
|
|
+ var category = $('#category').val();
|
|
|
+ var sub_category = $('#sub_category').val();
|
|
|
+ var uri = 'location=' + location;
|
|
|
+ if (category) { uri += '&category=' + category; }
|
|
|
+ if (sub_category) { uri += '&sub_category=' + sub_category; }
|
|
|
+
|
|
|
+ App.blockUI({
|
|
|
+ target: $("#container_total_invested"),
|
|
|
+ animate: true
|
|
|
+ });
|
|
|
+
|
|
|
+ App.blockUI({
|
|
|
+ target: $("#container_total_invested_dlls"),
|
|
|
+ animate: true
|
|
|
+ });
|
|
|
+
|
|
|
+ $.ajax({
|
|
|
+ type: "get",
|
|
|
+ url: '/total_invested_in_pointsale?' + uri,
|
|
|
+ dataType: 'json',
|
|
|
+ success: function(data) {
|
|
|
+ App.unblockUI($("#container_total_invested"));
|
|
|
+ App.unblockUI($("#container_total_invested_dlls"));
|
|
|
+
|
|
|
+ $('#total_invested').html(accounting.formatMoney(data.invested_in_pesos) + ' MXN');
|
|
|
+ $('#total_invested_dlls').html(accounting.formatMoney(data.invested_in_dollars) + ' USD');
|
|
|
+ }
|
|
|
+ });
|
|
|
}
|
|
|
</script>
|
|
|
|