Files
sx-fc/app/assets/javascripts/OQS.js
2017-06-02 18:26:44 +06:30

84 lines
3.1 KiB
JavaScript

// This is a manifest file that'll be compiled into application.js, which will include all the files
// listed below.
//
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
// or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
//
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// compiled file. JavaScript code in this file should be added after the last require_* statement.
//
// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
// about supported directives.
//
//= require jquery
//= require bootstrap
//= require jquery_ujs
//= require turbolinks
//= require cable
$(document).ready(function(){
$('.queue_station').on('click',function(){
var orderZone=$(this).children().children().children('.order-zone').text();
var orderItem=$(this).children().children().children('.order-item').text();
var orderQty=$(this).children().children().children('.order-qty').text();
var orderBy=$(this).children().children().children().children('.order-by').text();
var orderAt=$(this).children().children().children().children('.order-at').text();
var orderCustomer=$(this).children().children('.order-customer').text();
$('#order-title').text("ORDER DETAILS - " + orderZone);
$('#order-by').text(orderBy);
$('#order-at').text(orderAt);
$('#order-customer').text(orderCustomer);
$('#order-from').text(orderZone);
$('#order-items').text(orderItem);
$('#order-qty').text(orderQty);
$('.queue_station').removeClass('selected-item');
$(this).addClass('selected-item');
});
// complete for queue item
$('.order-complete').on('click',function(){
var _self= $(this);
var assigned_item_id=$(this).attr('id').substr(15);
var params = { 'id':assigned_item_id };
var station=$(this).parent().parent(".queue_station").parent().parent().attr('id');
$.ajax({
type: 'POST',
url: '/oqs/update_delivery',
data: params,
dataType: 'json',
success: function(data){
var queue_station=_self.parent().parent(".queue_station");
// Remove a queue card from current station
queue_station.remove();
// Remove a queue card from current station
queue_station.children('.card-footer').remove();
// Add removed queue card from station to completed
$("#completed").children('.card-columns').append(queue_station);
// update queue item count in station
$("#"+station+"_count").text(parseInt($("#"+station+"_count").text())-1);
$("#completed_count").text(parseInt($("#completed_count").text())+1);
alert("updated!");
}
});
});
$('#print_order_item').on('click',function(){
var assigned_item_id=$('.selected-item').children('.card-block').children('.assigned-order-item').text();
var params = { 'id':assigned_item_id };
$.ajax({
type: 'GET',
url: '/oqs/print/print/'+assigned_item_id,
success: function(data){ }
});
});
});