Merge branch 'master' of bitbucket.org:code2lab/sxrestaurant into ui_ux_changes

This commit is contained in:
yemin
2018-10-10 10:10:45 +06:30
148 changed files with 5743 additions and 1810 deletions

View File

@@ -160,7 +160,7 @@ GEM
railties (>= 3.1)
multi_json (1.12.2)
multi_xml (0.6.0)
mysql2 (0.4.9)
mysql2 (0.4.10)
nested_form (0.3.2)
net-scp (1.2.1)
net-ssh (>= 2.6.5)
@@ -368,4 +368,4 @@ RUBY VERSION
ruby 2.4.1p111
BUNDLED WITH
1.16.1
1.16.4

View File

@@ -193,6 +193,7 @@ For MoveTablePdf in print settings
1) settings/lookups => { type:tax_profiles, name: Cashier, value:cashier }
2) settings/lookups => { type:tax_profiles, name: Quick Service, value: quick_service }
3) settings/lookups => { type:tax_profiles, name: Doemal, value: doemal }
4) settings/lookups => { type:tax_profiles, name: Food Court, value: food_court }
/* Tax Profile Group Types in lookups */
/*Receipt Pdf View in lookups */
@@ -257,6 +258,17 @@ For TaxProfiles On/Off
For Add Kitchen Role
1) settings/lookups => {type:employee_roles, name:Kitchen, value:kitchen}
For Food Court Settings On/Off
** '0' means can not use food court and '1' means can use food court **
=> settings/lookups => { type:food_court, name: FoodCourt, value:'{0 or 1}' }
/* Customer Types in lookups */
1) settings/lookups => { type:customer_type, name: Dinein, value:Dinein }
2) settings/lookups => { type:customer_type, name: Takeaway, value: Takeaway }
3) settings/lookups => { type:customer_type, name: Doemal, value: Doemal }
4) settings/lookups => { type:customer_type, name: FoodCourt, value: FoodCourt }
/* Tax Profile Group Types in lookups */
* ToDo list
1. Migration

View File

@@ -64,16 +64,19 @@ $(document).on('turbolinks:load', function() {
for (i = 0; i < list.length; i++) {
table_id.push(list[i].value);
}
$('#table_id').val(table_id);
console.log(table_id)
$('#table').val(table_id);
oqs_id = $("#oqs_id").val();
if (table_id){
status = $("#status").val();
if (table_id.length>0){
var table = table_id
}else{
var table = null
}
if (oqs_id > 0) {
if (oqs_id > 0 || status != "All" || table != null) {
$(".oqs_click").removeClass('oqs_active');
$(".queue_station").removeClass('queue_station_box');
$("#completed").addClass('hide');
@@ -83,8 +86,8 @@ $(document).on('turbolinks:load', function() {
// oqs_id = $(this).find(".oqs-id").text();
$("#oqs_active").attr('data-id',oqs_id);
var url = 'oqs/get_items/'+oqs_id;
show_details(url,table);
show_details(url,table,status);
}else{
$("#completed").removeClass('hide')
$(".oqs_append").addClass('hide')
@@ -94,6 +97,7 @@ $(document).on('turbolinks:load', function() {
// $(".oqs_click").on("click", function(){
$(document).on('click', '.oqs_click', function(event){
oqs_id = $(this).val();
status = $("#status").val();
var table_id = $('#table_id').val();
if (table_id){
var table = table_id
@@ -101,7 +105,7 @@ $(document).on('turbolinks:load', function() {
var table = null
}
if (oqs_id > 0) {
if (oqs_id > 0 || status != "All" || table_id != null) {
$(".oqs_click").removeClass('oqs_active');
$(".queue_station").removeClass('queue_station_box');
$("#completed").addClass('hide');
@@ -112,16 +116,45 @@ $(document).on('turbolinks:load', function() {
$("#oqs_active").attr('data-id',oqs_id);
var url = 'oqs/get_items/'+oqs_id;
show_details(url,table);
show_details(url,table,status);
}else{
$("#completed").removeClass('hide')
$(".oqs_append").addClass('hide')
}
}); //End Click
// $(".oqs_click").on("click", function(){
$(document).on('click', '.status_click', function(event){
oqs_id = $("#oqs_id").val();
status = $(this).val();
var table_id = $('#table_id').val();
if (table_id){
var table = table_id
}else{
var table = null
}
if (oqs_id > 0 || status != "All" || table != null) {
$(".oqs_click").removeClass('oqs_active');
$(".queue_station").removeClass('queue_station_box');
$("#completed").addClass('hide');
$(".oqs_append").removeClass('hide');
$("#oqs_active").addClass('oqs_active');
$(".queue_station").addClass('queue_station_box');
// oqs_id = $(this).find(".oqs-id").text();
$("#oqs_active").attr('data-id',oqs_id);
var url = 'oqs/get_items/'+oqs_id;
show_details(url,table,status);
}else{
$("#completed").removeClass('hide')
$(".oqs_append").addClass('hide')
}
}); //End Click
function show_details(url,table_id){
function show_details(url,table_id,status){
console.log(table_id)
var oqs_append = $('.oqs_append');
oqs_append.empty();
var filter = $('.filter').text();
@@ -130,7 +163,7 @@ $(document).on('turbolinks:load', function() {
$.ajax({
type: "GET",
url: url,
data: {'filter':filter,'table_id':table_id},
data: {'filter':filter,'table_id':table_id,'status':status},
dataType: "json",
success: function(data) {
for(var field in data) {
@@ -162,6 +195,10 @@ $(document).on('turbolinks:load', function() {
table_type = "No Table"
}
var delivery_status = ''
if (data[field]["delivery_status"] == true) {
delivery_status = "hidden"
}
row ='<div class="card queue_station animated " data-order-no="'+data[field]["order_id"]+'">'
+'<div class="card-block">'
@@ -191,9 +228,11 @@ $(document).on('turbolinks:load', function() {
+'<p class="hidden assigned-order-item">'+ data[field]["assigned_order_item_id"] +'</p> '
+'</div>'
+'<div class="card-footer">'
+'<button id="edit_'+ data[field]["assigned_order_item_id"] + '" data-no-turbolink="true" class="btn btn-warning order-item order-item-edit">EDIT</button>'
+' <button id="assigned_queue_' + data[field]["assigned_order_item_id"] +'" class="btn btn-primary order-item order-complete">COMPLETE</button>'
+'<div class="card-footer ">'
+'<span class="'+delivery_status+'">'
+'<button id="edit_'+ data[field]["assigned_order_item_id"] + '" data-no-turbolink="true" class="oqs-btn btn-warning order-item order-item-edit">EDIT</button>'
+' <button id="assigned_queue_' + data[field]["assigned_order_item_id"] +'" class="oqs-btn btn-primary order-item order-complete">COMPLETE</button>'
+'</span>'
+'</div>'
+'</div>';
@@ -365,7 +404,9 @@ $(document).on('turbolinks:load', function() {
success: function(result){
// For Server Print - from jade
if ($("#server_mode").val() == "cloud") {
code2lab.printFile(result.filepath.substr(6), result.printer_url);
if(typeof code2lab != 'undefined'){
code2lab.printFile(result.filepath.substr(6), result.printer_url);
}
}
location.reload();
@@ -389,7 +430,9 @@ $(document).on('turbolinks:load', function() {
success: function(result){
// For Server Print - from jade
if ($("#server_mode").val() == "cloud") {
code2lab.printFile(result.filepath.substr(6), result.printer_url);
if(typeof code2lab != 'undefined'){
code2lab.printFile(result.filepath.substr(6), result.printer_url);
}
}
location.reload();
}

View File

@@ -2,7 +2,7 @@ $(function() {
var role = $('#role').val();
var second_display_lookup = $("#display_type");
console.log(second_display_lookup)
type = window.location.href.indexOf("quick_service");
type = window.location.href.indexOf("quick_service") || window.location.href.indexOf("food_court");
modify_order = window.location.href.indexOf("modify_order");
//click menu sidebar menu category
@@ -146,7 +146,7 @@ $(function() {
}
}else{
type = window.location.href.indexOf("quick_service");
type = window.location.href.indexOf("quick_service") || window.location.href.indexOf("food_court");
modify_order = window.location.href.indexOf("modify_order");
if (type != -1 && modify_order != -1) {
@@ -155,7 +155,7 @@ $(function() {
url_item = 'addorders/'+url_item;
}
if (type ==-1 && modify_order == -1){
url_item = url_item
url_item = url_item;
}
//Start Ajax
@@ -241,7 +241,7 @@ $(function() {
}
}
}else{
type = window.location.href.indexOf("quick_service");
type = window.location.href.indexOf("quick_service") || window.location.href.indexOf("food_court");
modify_order = window.location.href.indexOf("modify_order");
if (type != -1 && modify_order != -1) {
url = '../../../addorders/get_item_instance/'+value[i]["id"];
@@ -848,17 +848,18 @@ $(function() {
$(this).attr('disabled', 'disabled');
e.preventDefault();
$("#oqs_loading_wrapper").show();
var cashier_type = $("#link_type").val();
quick_service = window.location.href.indexOf("quick_service");
if (quick_service != -1) {
type = 'quick_service'
food_court = window.location.href.indexOf("food_court");
if (quick_service != -1 || food_court != -1) {
type = cashier_type;
var table_type = $('#table_type').text();
var table_id = $('#table_id').val();
var customer_id = $('#customer_id').val();
var booking_id = $('#booking_id').text();
var ajax_url = 'addorders/create';
}else{
type = 'cashier'
type = 'cashier';
var table_type = $('#table_type').text();
var table_id = $('#table_id').text();
var customer_id = $('#customer_id').text();
@@ -886,14 +887,14 @@ $(function() {
data: params,
dataType: "json",
success:function(result){
if (type == "quick_service") {
window.location.href = "/origami/quick_service"
if (type == "quick_service" || type=="food_court") {
window.location.href = "/origami/"+type;
}else{
if(table_type == "Table"){
window.location.href = "/origami/table/" + table_id
window.location.href = "/origami/table/" + table_id;
}
else {
window.location.href = "/origami/room/" + table_id
window.location.href = "/origami/room/" + table_id;
}
}
if ($('#server_mode').val() != "cloud" && second_display_lookup == 2){
@@ -914,11 +915,11 @@ $(function() {
$("#create_pay_order").on('click', function(e){
$(this).attr('disabled', 'disabled');
e.preventDefault();
type = "quick_service"
type = $("#link_type").val();
modify_order = window.location.href.indexOf("modify_order");
$("#oqs_loading_wrapper").show();
if (modify_order !=-1) {
var ajax_url = '../../../quick_service/update_modify_order';
var ajax_url = '../../../'+type+'/update_modify_order';
var table_type = $('#table_type').text();
var table_id = $('#table_id').text();
var customer_id = $('#customer_id').text();
@@ -962,13 +963,13 @@ $(function() {
confirmButtonText: "Ok",
closeOnConfirm: false
}, function () {
window.location.href = '/origami/quick_service/pending_order/' + $('#sale_id').text();
window.location.href = '/origami/'+type+'/pending_order/' + $('#sale_id').text();
});
}else if(result.data == 'OK'){
window.location.href = '/origami/quick_service/pending_order/' + $('#sale_id').text();
window.location.href = '/origami/'+type+'/pending_order/' + $('#sale_id').text();
}else{
window.location.href = "/origami/sale/"+result.data["sale_id"]+"/"+type+"/payment"
window.location.href = "/origami/sale/"+result.data["sale_id"]+"/"+type+"/payment";
}
}
}
@@ -1096,13 +1097,14 @@ $(function() {
$("#back").on("click", function(){
var table_id = $('#table_id').text();
var table_type = $('#table_type').text();
type = window.location.href.includes("quick_service");
var cashier_type = $("#link_type").val();
type = window.location.href.includes("quick_service") || window.location.href.includes("food_court");
if (type == true) {
var table_type = $('#table_id').find("option:selected").data('type');
var table_id = $('#table_id').val();
if(window.location.href.includes("modify_order")){
var link_url = window.location.href.split("/");
window.location.href = "/origami/quick_service/pending_order/"+link_url[link_url.length - 1];
window.location.href = "/origami/"+cashier_type+"/pending_order/"+link_url[link_url.length - 1];
}else{
window.location.href = "/origami/dashboard";
}

View File

@@ -9,16 +9,18 @@ App.order = App.cable.subscriptions.create('BillChannel', {
var hostname = location.hostname.trim();
if(data.from == "" || hostname == data.from)
{
if($('.table_'+data.table.id).hasClass('blue')){
$('.table_'+data.table.id).removeClass('blue');
$('.table_'+data.table.id).removeClass('green');
$('.table_'+data.table.id).addClass('red');
}else{
$('.table_'+data.table.id).removeClass('orange');
$('.table_'+data.table.id).addClass('red');
}
$('.new_text_'+data.table.id).removeClass('hide');
$('.new_text_'+data.table.id).text('billed');
if(data.table != undefined && data.table != null && data.table!=""){
if($('.table_'+data.table.id).hasClass('blue')){
$('.table_'+data.table.id).removeClass('blue');
$('.table_'+data.table.id).removeClass('green');
$('.table_'+data.table.id).addClass('red');
}else{
$('.table_'+data.table.id).removeClass('orange');
$('.table_'+data.table.id).addClass('red');
}
$('.new_text_'+data.table.id).removeClass('hide');
$('.new_text_'+data.table.id).text('billed');
}
}
}
});

View File

@@ -68,8 +68,8 @@ App.order_queue_station = App.cable.subscriptions.create('OrderQueueStationChann
+'</div>'
+'<div class="card-footer">'
+'<button id="edit_'+ items[field]["assigned_order_item_id"]+'" class="btn btn-warning order-item order-item-edit">EDIT</button>'
+' <button id="assigned_queue_' + items[field]["assigned_order_item_id"] +'" class="btn btn-primary order-item order-complete">COMPLETE</button>'
+'<button id="edit_'+ items[field]["assigned_order_item_id"]+'" class="oqs-btn btn-warning order-item order-item-edit">EDIT</button>'
+' <button id="assigned_queue_' + items[field]["assigned_order_item_id"] +'" class="oqs-btn btn-primary order-item order-complete">COMPLETE</button>'
+'</div>'
+'</div>';
$('.oqs_append').append(row);

View File

@@ -101,6 +101,36 @@ $(document).ready(function() {
railBorderRadius: '0',
touchScrollStep : 50
});
$('#make-reservation-slimscroll').slimScroll({
height: height-$('#make-reservation-slimscroll').attr('data-height'),
size: '5px',
color: 'rgba(0,0,0,0.5)',
alwaysVisible: false,
borderRadius: '0',
railBorderRadius: '0',
touchScrollStep : 50
});
$('#process-reservation-slimscroll').slimScroll({
height: height-$('#process-reservation-slimscroll').attr('data-height'),
size: '5px',
color: 'rgba(0,0,0,0.5)',
alwaysVisible: false,
borderRadius: '0',
railBorderRadius: '0',
touchScrollStep : 50
});
$('#reservation-info-slimscroll').slimScroll({
height: height-$('#reservation-info-slimscroll').attr('data-height'),
size: '5px',
color: 'rgba(0,0,0,0.5)',
alwaysVisible: false,
borderRadius: '0',
railBorderRadius: '0',
touchScrollStep : 50
});
// $('.delete').click(function(){
// var method = $(this).attr('data-method');
// var url = $(this).attr('data-ref');
@@ -198,6 +228,7 @@ function getOnlineOrderCount(){
url: "/origami/get_order_info",
dataType: "json",
success: function(data){
console.log(data);
if(parseInt(data) > 0){
count = parseInt(data);
}

View File

@@ -8,6 +8,9 @@ $(function() {
$(".tbl_customer").hide();
$(".order_close_cashier").hide();
$(".order_payment_type").hide();
$(".accepted_time").hide();
$(".kitchen_time").hide();
$(".ready_time").hide();
$(function() {
$('.first-1').click();
});
@@ -290,7 +293,36 @@ function show_order_detail(url,sr_no){
var delivery = data["delivery"];
var items = data["order_items"];
var item_list = $('.summary-items');
var action_times = "";
$("#accepted_time").html("");
$("#send_kitchen_time").html("");
$("#ready_delivery_time").html("");
if((data["action_times"]!=undefined) && (data["action_times"]!=null)){
action_times = JSON.parse(data["action_times"]);
if((action_times.accepted_time!=undefined) && (action_times.accepted_time!="")){
$(".accepted_time").show();
var acceptedDate = new Date(action_times.accepted_time);
var acceptedTime = timeFormat(acceptedDate);
var accepted_time = getOrderMonth(acceptedDate.getMonth()) +' '+ (acceptedDate.getDate() >= 10? acceptedDate.getDate() : '0' + acceptedDate.getDate()) +', '+acceptedDate.getFullYear()+'('+getOrderDay(acceptedDate.getDay())+')'+' '+acceptedTime;
$("#accepted_time").html(accepted_time);
}
if((action_times.kitchen_time!=undefined) && (action_times.kitchen_time!="")){
$(".kitchen_time").show();
var kitchenDate = new Date(action_times.kitchen_time);
var kitchenTime = timeFormat(kitchenDate);
var kitchen_time = getOrderMonth(kitchenDate.getMonth()) +' '+ (kitchenDate.getDate() >= 10? kitchenDate.getDate() : '0' + kitchenDate.getDate()) +', '+kitchenDate.getFullYear()+'('+getOrderDay(kitchenDate.getDay())+')'+' '+kitchenTime;
$("#send_kitchen_time").html(kitchen_time);
}
if((action_times.ready_time!=undefined) && (action_times.ready_time!="")){
$(".ready_time").show();
var readyDate = new Date(action_times.ready_time);
var readyTime = timeFormat(readyDate);
var ready_time = getOrderMonth(readyDate.getMonth()) +' '+ (readyDate.getDate() >= 10? readyDate.getDate() : '0' + readyDate.getDate()) +', '+readyDate.getFullYear()+'('+getOrderDay(readyDate.getDay())+')'+' '+readyTime;
$("#ready_delivery_time").html(ready_time);
}
}
var newDate = new Date(data.requested_time);
var time = timeFormat(newDate);
// var requested_date = newDate.getFullYear() + '-' + (newDate.getMonth() >= 10? newDate.getMonth() : '0' + (newDate.getMonth() + 1)) +'-'+ (newDate.getDate() >= 10? newDate.getDate() : '0' + newDate.getDate()) +' '+time;

View File

@@ -0,0 +1,64 @@
//= require custom.js
$(function(){
$(".room_type").hide();
/*new customer UI func:*/
//Initialize tooltips
$('.nav-tabs > li a[title]').tooltip();
//Wizard
$('a[data-toggle="tab"]').on('show.bs.tab', function (e) {
var $target = $(e.target);
if ($target.parent().hasClass('disabled')) {
return false;
}
});
$(".next-step").click(function (e) {
var $active = $('.wizard .nav-tabs li a.active');
$active.parent().next().removeClass('disabled');
nextTab($active);
$('.wizard .nav-tabs li.active .connecting-line').css({"border-bottom-left-radius": 0, "border-top-left-radius": 0});
});
$(".prev-step").click(function (e) {
var $active = $('.wizard .nav-tabs li a.active');
prevTab($active);
});
/*new customer UI func:*/
$(".reservation_type").on("click", function(){
if($(this).val() == "Dine-in"){
$(".dining_type").show();
$(".room_type").hide();
}else{
$(".dining_type").hide();
$(".room_type").show();
}
});
$(".number_limit").on("click", function(){
if(parseInt($(this).val()) <= 0){
if($(this).attr("data-type") == "room"){
$("#room_count").val(1);
}else if($(this).attr("data-type") == "adult"){
$("#adult_count").val(1);
}else{
$("#child_count").val(1);
}
}
});
});
/*customer UI tab btn*/
function nextTab(elem) {
$(elem).parent().next().find('a[data-toggle="tab"]').click();
}
function prevTab(elem) {
$(elem).parent().prev().find('a[data-toggle="tab"]').click();
}
/*customer UI tab btn*/

View File

@@ -157,4 +157,115 @@ nav.pagination .page a:hover,
i.logout_icon{
position: relative;
top: 5px;
}
}
/*customer modal UI */
.wizard {
background: #f1f1f1;
padding: 10px;
}
.wizard .nav-tabs {
position: relative;
border: 0px;
}
.wizard > div.wizard-inner {
position: relative;
margin: 0 0 0 145px !important;
}
.connecting-line{
height:12px;
background: #e0e0e0;
position: absolute;
width: 105%;
margin: 0 auto;
left: 0;
right: 0;
top:38%;
z-index: 1;
border-radius: 15px;
}
.active-line{
height:12px;
background: #e0e0e0;
position: absolute;
width: 5%;
margin: 0 auto;
left: 0;
right: 0;
top:61%;
z-index: 1;
border-radius: 15px !important;
}
.connecting-line a.active{
background-color: #2ED4E0;
}
.border-right{
border-radius: 15px 0 0 15px;
}
.border-left{
border-radius: 0;
}
.wizard .nav-tabs > li {
margin-bottom: -20px;
}
.wizard .nav-tabs > li > a.active > a, .wizard .nav-tabs > li > a.active > a:hover, .wizard .nav-tabs > li > a.active > a:focus {
cursor: default;
border: 0;
color:#2ED4E0;
border-bottom-color: transparent;
}
.nav-tabs li p{
padding-top:40px;
font-size: 14px;
text-align: center;
}
.list-inline{
text-align: center;
}
span.round-tab {
width: 28px;
height: 28px;
line-height: 28px;
display: inline-block;
border-radius: 100px;
background:#DFE3E4;
border: 2px solid #fff;
z-index:1;
position:absolute;
text-align: center;
font-size: 16px;
}
.wizard li > a.active span.round-tab{
background:#2196F3;
color:white;
border: 1px solid #fff;
}
span.round-tab:hover{
color: white;
border: 1px solid #fff;
background-color:#2196F3;
}
.wizard .nav-tabs > li {
width: 25%;
}
.wizard .nav-tabs > li a{
width: 28px;
height: 28px;
margin: 18px auto;
border-radius: 100%;
padding: 0;
color: #777;
}
.wizard .tab-pane {
position: relative;
padding-top: 5px;
border-top: 1px solid #fff;
margin-top: 20px;
}
.next-step:hover, .next-step, .prev-step:hover, .prev-step{
position: relative;
background-color: #2196F3;
font-size: 14px;
color: #FFFFFF;
}
/*customer modal UI */

View File

@@ -107,4 +107,21 @@ i.logout_icon{
.float_right{
float : right;
}
.selected-payment {
color: #fff !important;
background-color: blue !important;
}
.payment_btn {
white-space: normal !important;
margin-bottom: 15px;
margin-right: 15px;
color:#fff !important;
# background-color: green !important;
}
.payment-btn-box {
width: 130px;
height: 50px;
}

View File

@@ -82,19 +82,24 @@
}
.p-card{
margin: 20px 0;
margin: 20px -8px;
text-align: center;
}
.p-name{
padding-left: 6px;
padding-right: 6px;
padding-bottom: 20px;
font-size: 14px;
weight : 30px;
height : 48px;
}
.style_image{
height : 138px;
height : 137.5px;
padding : 20px 0 20px 0;
width : 70%;
opacity: 0.7;
}
.style_icon{
@@ -108,4 +113,8 @@
font-size: 21px;
font-weight: bold;
margin : 0 0 20px 0;
}
.box {
margin : 0 -60px 0 -60px;
}

View File

@@ -524,4 +524,138 @@ nav.pagination .page a:hover,
background-color:#ffab51;
color:#fff;
}
/*----chane font_size (Amount Due && Balance)----*/
#balance{
height: 50%;
font-size: 20px;
}
.amount_balance{
height: 50%;
font-size: 20px;
}
#amount_due{
height: 50%;
font-size: 20px;
}
/*customer modal UI */
.wizard {
background: #f1f1f1;
padding: 10px;
}
.wizard .nav-tabs {
position: relative;
border: 0px;
}
.wizard > div.wizard-inner {
position: relative;
margin: 0 0 0 145px !important;
}
.connecting-line{
height:12px;
background: #e0e0e0;
position: absolute;
width: 110%;
margin: 0 auto;
left: 0;
right: 0;
top:38%;
z-index: 1;
border-radius: 15px;
}
.active-line{
height:12px;
background: #e0e0e0;
position: absolute;
width: 5%;
margin: 0 auto;
left: 0;
right: 0;
top:61%;
z-index: 1;
border-radius: 15px !important;
}
.connecting-line a.active{
background-color: #2ED4E0;
}
.border-right{
border-radius: 15px 0 0 15px;
}
.border-left{
border-radius: 0;
}
.wizard .nav-tabs > li {
margin-bottom: -20px;
}
.wizard .nav-tabs > li > a.active > a, .wizard .nav-tabs > li > a.active > a:hover, .wizard .nav-tabs > li > a.active > a:focus {
cursor: default;
border: 0;
color:#2ED4E0;
border-bottom-color: transparent;
}
.wizard .nav-tabs li p{
padding-top:40px;
font-size: 14px;
text-align: center;
}
.list-inline{
text-align: center;
}
span.round-tab {
width: 28px;
height: 28px;
line-height: 28px;
display: inline-block;
border-radius: 100px;
background:#DFE3E4;
border: 2px solid #fff;
z-index:1;
position:absolute;
text-align: center;
font-size: 16px;
}
.wizard li > a.active span.round-tab{
background:#2196F3;
color:white;
border: 1px solid #fff;
}
span.round-tab:hover{
color: white;
border: 1px solid #fff;
background-color:#2196F3;
}
.wizard .nav-tabs > li {
width: 25%;
}
.wizard .nav-tabs > li a{
width: 28px;
height: 28px;
margin: 18px auto;
border-radius: 100%;
padding: 0;
color: #777;
}
.wizard .tab-pane {
position: relative;
padding-top: 5px;
border-top: 1px solid #fff;
margin-top: 20px;
}
.next-step:hover, .next-step, .prev-step:hover, .prev-step{
position: relative;
background-color: #2196F3;
font-size: 14px;
color: #FFFFFF;
}
/*customer modal UI */
.payment-btn-box {
width: 130px;
height: 50px;
}

View File

@@ -0,0 +1,110 @@
/*customer modal UI */
.wizard {
background: #f1f1f1;
padding: 10px;
}
.wizard .nav-tabs {
position: relative;
border: 0px;
}
.wizard > div.wizard-inner {
position: relative;
margin: 0 0 0 80px !important;
}
.connecting-line{
height:12px;
background: #e0e0e0;
position: absolute;
width: 115%;
margin: 0 auto;
left: 0;
right: 0;
top:38%;
z-index: 1;
border-radius: 15px;
}
.active-line{
height:12px;
background: #e0e0e0;
position: absolute;
width: 5%;
margin: 0 auto;
left: 0;
right: 0;
top:61%;
z-index: 1;
border-radius: 15px !important;
}
.connecting-line a.active{
background-color: #2ED4E0;
}
.border-right{
border-radius: 15px 0 0 15px;
}
.border-left{
border-radius: 0;
}
.wizard .nav-tabs > li {
margin-bottom: -20px;
}
.wizard .nav-tabs > li > a.active > a, .wizard .nav-tabs > li > a.active > a:hover, .wizard .nav-tabs > li > a.active > a:focus {
cursor: default;
border: 0;
color:#2ED4E0;
border-bottom-color: transparent;
}
.nav-tabs li p{
padding-top:40px;
font-size: 14px;
text-align: center;
}
.list-inline{
text-align: center;
}
span.round-tab {
width: 28px;
height: 28px;
line-height: 28px;
display: inline-block;
border-radius: 100px;
background:#DFE3E4;
border: 2px solid #fff;
z-index:1;
position:absolute;
text-align: center;
font-size: 16px;
}
.wizard li > a.active span.round-tab{
background:#2196F3;
color:white;
border: 1px solid #fff;
}
span.round-tab:hover{
color: white;
border: 1px solid #fff;
background-color:#2196F3;
}
.wizard .nav-tabs > li {
width: 25%;
}
.wizard .nav-tabs > li a{
width: 28px;
height: 28px;
margin: 18px auto;
border-radius: 100%;
padding: 0;
color: #777;
}
.wizard .tab-pane {
position: relative;
padding-top: 5px;
border-top: 1px solid #fff;
margin-top: 20px;
}
.next-step:hover, .next-step, .prev-step:hover, .prev-step{
position: relative;
background-color: #2196F3;
font-size: 14px;
color: #FFFFFF;
}
/*customer modal UI */

View File

@@ -286,13 +286,13 @@ section.content {
/* shop name margin */
.shop-name-margin {
margin-left : 20%;
margin-left : 10%;
}
/* shop name margin */
/* online order margin */
.online-order-margin {
margin-left : 22%;
margin-left : 10%;
margin-bottom : 9.9999px;
}
/* online order margin */

View File

@@ -118,21 +118,21 @@ class Api::OrderReserve::OrderReservationController < Api::ApiController
if status == 'REMOVE'
if order_reservation.status == "new" || order_reservation.status == "accepted"
OrderReservation.update_order_reservation(order_reservation_id, nil, "rejected",nil,remark)
OrderReservation.update_order_reservation(order_reservation_id, nil, "rejected",nil,remark, nil, current_login_employee)
result = {:status=> true, :message => "rejected" }
else
result = {:status=> false, :message => "Status :: "+order_reservation.status+" cann't remove!" }
end
elsif status == 'FOC'
if order_reservation.status == "new" || order_reservation.status == "accepted" || order_reservation.status == "send_to_kitchen"
OrderReservation.update_order_reservation(order_reservation_id, nil, nil,nil,reason)
OrderReservation.update_order_reservation(order_reservation_id, nil, 'foc',nil,reason, nil, current_login_employee)
result = {:status=> true, :message => "FOC successfully" }
else
result = {:status=> false, :message => "Status :: "+order_reservation.status+" cann't get FOC!" }
end
elsif status == 'VOID'
if order_reservation.status == "ready_to_delivery"
OrderReservation.update_order_reservation(order_reservation_id, nil, nil,nil,reason)
if order_reservation.status == "ready_to_delivery" || order_reservation.status == "delivered"
OrderReservation.update_order_reservation(order_reservation_id, nil, 'void',nil,reason, nil, current_login_employee)
result = {:status=> true, :message => "VOID successfully" }
else
result = {:status=> false, :message => "Status :: "+order_reservation.status+" cann't VOID!" }

View File

@@ -3,7 +3,7 @@ module LoginVerification
included do
before_action :authenticate_session_token
helper_method :current_company, :current_login_employee, :current_user, :get_cashier, :order_reservation, :bank_integration
helper_method :current_company,:current_shop, :current_login_employee, :current_user, :get_cashier, :order_reservation, :bank_integration
end
#this is base api base controller to need to inherit.
@@ -17,6 +17,14 @@ module LoginVerification
end
end
def current_shop
begin
return Shop.first
rescue
return nil
end
end
def current_login_employee
@employee = Employee.find_by_token_session(session[:session_token])
end

View File

@@ -70,8 +70,8 @@ class Crm::CustomersController < BaseCrmController
# GET /crm/customers/1
# GET /crm/customers/1.json
def show
@orders = Order.where("customer_id=?", params[:id])
@sales = Sale.where("customer_id=?", params[:id])
@orders = Order.where("customer_id=?", params[:id]).limit(20)
@sales = Sale.where("customer_id=?", params[:id]).limit(20)
if @orders
@order_items = []
@@ -86,6 +86,10 @@ class Crm::CustomersController < BaseCrmController
end
end
params[:type] = nil
params[:customer_id] = params[:id]
@credit_sales = SalePayment.get_credit_sales(params)
#get customer amount
@customer = Customer.find(params[:id])
@response = Customer.get_membership_transactions(@customer)

View File

@@ -184,6 +184,15 @@ class HomeController < ApplicationController
render :json => {:status=> "Success", :url => root_path }.to_json
end
def run_teamviewer
if File.directory?("/opt/teamviewer")
output = IO.popen('/opt/teamviewer/tv_bin/script/teamviewer')
render :json => {:status=> true}
else
render :json => {:status=> false}
end
end
private
# Never trust parameters from the scary internet, only allow the white list through.

View File

@@ -1,24 +1,13 @@
class Inventory::InventoryController < BaseInventoryController
load_and_authorize_resource
def index
least_stock = "SELECT (CASE WHEN stock_journals.remark != 'out of stock'
THEN (SELECT balance FROM stock_journals
WHERE item_code = inventory_definitions.item_code AND remark != 'out of stock'
ORDER BY created_at DESC LIMIT 1) ELSE 0 END)
FROM stock_journals
WHERE stock_journals.item_code = inventory_definitions.item_code
ORDER BY stock_journals.created_at DESC LIMIT 1"
@inventory_definitions = InventoryDefinition.select("inventory_definitions.*,
(CASE WHEN sj.credit IS NULL THEN 0 ELSE sj.credit END) as credit,
(CASE WHEN sj.debit IS NULL THEN 0 ELSE sj.debit END) as debit,
(#{least_stock}) as balance")
.joins(" LEFT JOIN stock_journals sj ON sj.inventory_definition_id=inventory_definitions.id")
.group("inventory_definitions.item_code")
.order("balance ASC")
filter = params[:filter]
@inventory_definitions = InventoryDefinition.get_by_category(filter)
end
def show
inventory_definition_id = params[:inventory_definition_id]
inventory = InventoryDefinition.find(inventory_definition_id)

View File

@@ -14,6 +14,8 @@ class Inventory::InventoryDefinitionsController < BaseInventoryController
# GET /inventory_definitions/new
def new
@menus = Menu.all
@menu = MenuCategory.active.where("menu_id =#{@menus[0].id}").order('order_by asc')
@inventory_definition = InventoryDefinition.new
end
@@ -24,24 +26,44 @@ class Inventory::InventoryDefinitionsController < BaseInventoryController
# POST /inventory_definitions
# POST /inventory_definitions.json
def create
inventory = InventoryDefinition.find_by_item_code(inventory_definition_params[:item_code])
inventory = InventoryDefinition.find_by_item_code(params[:item_code])
if inventory.nil?
@inventory_definition = InventoryDefinition.new(inventory_definition_params)
@inventory_definition = InventoryDefinition.new
@inventory_definition.item_code = params[:item_code]
@inventory_definition.min_order_level = params[:min_order_level]
@inventory_definition.max_stock_level = params[:max_stock_level]
@inventory_definition.save
else
@inventory_definition = InventoryDefinition.find(inventory.id)
@inventory_definition.min_order_level = inventory_definition_params[:min_order_level]
@inventory_definition.max_stock_level = inventory.max_stock_level.to_i + inventory_definition_params[:max_stock_level].to_i
@inventory_definition.min_order_level = params[:min_order_level]
@inventory_definition.max_stock_level = inventory.max_stock_level.to_i + params[:max_stock_level].to_i
end
@inventory_definition.created_by = current_user.id
respond_to do |format|
if @inventory_definition.save
format.html { redirect_to inventory_path, notice: 'Inventory definition was successfully created.' }
format.json { render :show, status: :created, location: @inventory_definition }
else
format.html { render :new }
format.json { render json: @inventory_definition.errors, status: :unprocessable_entity }
end
if @inventory_definition.save
result = {:status=> true, :message => "Inventory definition was created successfully",:data=> @inventory_definition}
else
result = {:status=> false, :message => "Inventory definition was created successfully",:data=> @inventory_definition}
end
render :json => result.to_json
# inventory = InventoryDefinition.find_by_item_code(inventory_definition_params[:item_code])
# if inventory.nil?
# @inventory_definition = InventoryDefinition.new(inventory_definition_params)
# else
# @inventory_definition = InventoryDefinition.find(inventory.id)
# @inventory_definition.min_order_level = inventory_definition_params[:min_order_level]
# @inventory_definition.max_stock_level = inventory.max_stock_level.to_i + inventory_definition_params[:max_stock_level].to_i
# end
# @inventory_definition.created_by = current_user.id
# respond_to do |format|
# if @inventory_definition.save
# format.html { redirect_to inventory_path, notice: 'Inventory definition was successfully created.' }
# format.json { render :show, status: :created, location: @inventory_definition }
# else
# format.html { render :new }
# format.json { render json: @inventory_definition.errors, status: :unprocessable_entity }
# end
# end
end
# PATCH/PUT /inventory_definitions/1

View File

@@ -1,7 +1,15 @@
class Inventory::StockChecksController < BaseInventoryController
def index
@check = StockCheck.new
@inventory_definitions = InventoryDefinition.active.all
# @inventory_definitions1 = InventoryDefinition.active.all
@category = InventoryDefinition.select("inventory_definitions.*,"+
"mc.name as name,mc.id as id ")
.joins("JOIN menu_item_instances mii ON mii.item_instance_code = inventory_definitions.item_code" +
" JOIN menu_items mi ON mi.id = mii.menu_item_id" +
" JOIN menu_categories mc ON mc.id = mi.menu_category_id ")
.group("mi.menu_category_id")
.order("mi.menu_category_id desc")
end
def create
@@ -12,7 +20,10 @@ class Inventory::StockChecksController < BaseInventoryController
end
def show
@check = StockCheck.find(params[:id])
@check = StockCheck.find(params[:id])
@stock_check_items = StockCheckItem.get_items_with_category(params[:id])
end
def save_to_journal
@@ -30,7 +41,7 @@ class Inventory::StockChecksController < BaseInventoryController
member_info = nil
unique_code = 'StockCheckPdf'
shop_details = Shop.find(1)
shop_details = current_shop
checker = Employee.find(stockcheck.check_by)
print_settings = PrintSetting.find_by_unique_code(unique_code)
if !print_settings.nil?
@@ -39,10 +50,23 @@ class Inventory::StockChecksController < BaseInventoryController
end
end
def get_menu_category ()
if (params[:id])
#Pull this menu
@menu_category = InventoryDefinition.search_by_category(params[:id])
puts @menu_category.to_json
# puts @menu.menu_items[1].item_attributes.to_json
return @menu_category
else
MenuCategory.current_menu
end
end
#Shop Name in Navbor
helper_method :shop_detail
def shop_detail
@shop = Shop.first
@shop = current_shop
end
# before_action :set_stock_check, only: [:show, :edit, :update, :destroy]

View File

@@ -36,7 +36,7 @@ class Oqs::EditController < BaseOqsController
order_item.remark = remarks
order_item.save
if ENV["SERVER_MODE"] != "cloud" && order.source == 'cashier' #no print in cloud server
if ENV["SERVER_MODE"] != "cloud" #&& order.source == 'cashier' #no print in cloud server
# print
assigned_item = AssignedOrderItem.find_by_instance_code_and_order_id(order_item.item_instance_code, order_item.order_id)
assigned_items = nil

View File

@@ -13,7 +13,8 @@ class Oqs::HomeController < BaseOqsController
@queue_stations = OrderQueueStation.active
@queue_completed_item = completed_order(@filter)
# @queue_completed_item = completed_order(@filter)
@queue_completed_item = all_order(@filter)
if !@queue_completed_item.empty?
@queue_completed_item.each do |queue_item|
if !queue_item.set_menu_items.nil?
@@ -114,10 +115,11 @@ class Oqs::HomeController < BaseOqsController
oqs_id = params[:id]
filter = params[:filter]
table_id = params[:table_id]
puts params
puts table_id
puts "sssssssssssss"
items = queue_items_query(false,oqs_id,filter,table_id)
status = params[:status]
items = queue_items_query(false,oqs_id,filter,table_id,status)
puts "items0"
puts items.to_json
if !items.empty?
items.each do |item|
if !item.set_menu_items.nil?
@@ -155,13 +157,20 @@ class Oqs::HomeController < BaseOqsController
# Query for OQS with delivery status
def queue_items_query(status,oqs_id=nil,filter,table_id)
if oqs_id == nil
oqs = ''
def queue_items_query(status,oqs_id=nil,filter,table_id,delivery_status)
if oqs_id != "0"
oqs = "and assigned_order_items.order_queue_station_id = '#{oqs_id}' "
else
oqs = "and assigned_order_items.order_queue_station_id = '#{oqs_id}' "
oqs = ''
end
if delivery_status == "All"
queue_status = ''
elsif delivery_status == "Processed"
queue_status = "and assigned_order_items.delivery_status = true "
else
queue_status = "and assigned_order_items.delivery_status = false "
end
if !table_id.empty?
tableId = table_id.to_a.map{|h| h}.join(",")
table = "and df.id IN (#{tableId})"
@@ -175,7 +184,8 @@ class Oqs::HomeController < BaseOqsController
df.name as zone, df.type as table_type,
odt.order_id, odt.item_code, odt.item_name,
odt.price, odt.qty, odt.item_order_by, odt.options, odt.set_menu_items,
cus.name as customer_name, odt.created_at")
cus.name as customer_name, odt.created_at,
assigned_order_items.delivery_status")
.joins(" left join order_queue_stations as oqs on oqs.id = assigned_order_items.order_queue_station_id
left join order_queue_process_by_zones as oqpz on oqpz.order_queue_station_id = oqs.id
left join orders as od ON od.order_id = assigned_order_items.order_id
@@ -184,7 +194,7 @@ class Oqs::HomeController < BaseOqsController
left join booking_orders as bo on bo.order_id = assigned_order_items.order_id
left join bookings as bk on bk.booking_id = bo.booking_id
left join dining_facilities as df on df.id = bk.dining_facility_id")
.where("assigned_order_items.delivery_status = #{status} AND assigned_order_items.created_at >= '#{Time.now.beginning_of_day.utc}' #{oqs} #{table}")
.where("assigned_order_items.created_at >= '#{Time.now.beginning_of_day.utc}' #{oqs} #{table} #{queue_status}")
query = query.where("df.name LIKE ? OR odt.order_id LIKE ? OR odt.item_name LIKE ? OR cus.name = '#{filter}'","%#{filter}%","%#{filter}%","%#{filter}%",)
.order("assigned_order_items.assigned_order_item_id desc")
.group("odt.order_items_id")
@@ -193,7 +203,7 @@ class Oqs::HomeController < BaseOqsController
# Completed Order
def completed_order(filter)
query = AssignedOrderItem.select("assigned_order_items.assigned_order_item_id, oqs.id as station_id, oqs.station_name, oqs.is_active, oqpz.zone_id, df.name as zone, df.type, odt.order_id, odt.item_code, odt.item_name, odt.price, odt.qty, odt.item_order_by, odt.options, odt.set_menu_items, cus.name as customer_name, odt.created_at")
query = AssignedOrderItem.select("assigned_order_items.assigned_order_item_id, oqs.id as station_id, oqs.station_name, oqs.is_active, oqpz.zone_id, df.name as zone, df.type, odt.order_id, odt.item_code, odt.item_name, odt.price, odt.qty, odt.item_order_by, odt.options, odt.set_menu_items, cus.name as customer_name, odt.created_at,assigned_order_items.delivery_status")
.joins(" left join order_queue_stations as oqs on oqs.id = assigned_order_items.order_queue_station_id
left join order_queue_process_by_zones as oqpz on oqpz.order_queue_station_id = oqs.id
left join orders as od ON od.order_id = assigned_order_items.order_id
@@ -205,8 +215,28 @@ class Oqs::HomeController < BaseOqsController
.where("assigned_order_items.delivery_status = true AND assigned_order_items.created_at between '#{Time.now.beginning_of_day.utc}' and '#{Time.now.end_of_day.utc}'")
query = query.where("df.name LIKE ? OR odt.order_id LIKE ? OR odt.item_name LIKE ? OR cus.name = '#{filter}'","%#{filter}%","%#{filter}%","%#{filter}%",)
.group("assigned_order_items.order_id")
.limit(20)
.order("assigned_order_items.created_at")
.limit(50)
.order("assigned_order_items.created_at desc")
# completed_order = AssignedOrderItem.group(:order_id).where('delivery_status=true');
end
# all Order
def all_order(filter)
query = AssignedOrderItem.select("assigned_order_items.assigned_order_item_id, oqs.id as station_id, oqs.station_name, oqs.is_active, oqpz.zone_id, df.name as zone, df.type, odt.order_id, odt.item_code, odt.item_name, odt.price, odt.qty, odt.item_order_by, odt.options, odt.set_menu_items, cus.name as customer_name, odt.created_at,assigned_order_items.delivery_status")
.joins(" left join order_queue_stations as oqs on oqs.id = assigned_order_items.order_queue_station_id
left join order_queue_process_by_zones as oqpz on oqpz.order_queue_station_id = oqs.id
left join orders as od ON od.order_id = assigned_order_items.order_id
left join order_items as odt ON odt.item_instance_code = assigned_order_items.instance_code AND odt.order_id = assigned_order_items.order_id
left join customers as cus ON cus.customer_id = od.customer_id
left join booking_orders as bo on bo.order_id = assigned_order_items.order_id
left join bookings as bk on bk.booking_id = bo.booking_id
left join dining_facilities as df on df.id = bk.dining_facility_id")
.where("assigned_order_items.created_at between '#{Time.now.beginning_of_day.utc}' and '#{Time.now.end_of_day.utc}'")
query = query.where("df.name LIKE ? OR odt.order_id LIKE ? OR odt.item_name LIKE ? OR cus.name = '#{filter}'","%#{filter}%","%#{filter}%","%#{filter}%",)
.group("odt.order_items_id")
.order("assigned_order_items.created_at desc")
# completed_order = AssignedOrderItem.group(:order_id).where('delivery_status=true');

View File

@@ -14,6 +14,7 @@ class Origami::AddordersController < BaseOrigamiController
end
def detail
@cashier_type = params[:type]
@webview = false
if check_mobile
@webview = true
@@ -194,7 +195,7 @@ class Origami::AddordersController < BaseOrigamiController
end
if params[:order_source] != "quick_service"
if params[:order_source] != "quick_service" && params[:order_source] != "food_court"
process_order_queue(@order.order_id,@order.table_id,@order.source)
end
end
@@ -202,13 +203,16 @@ class Origami::AddordersController < BaseOrigamiController
# Order.send_customer_view(@booking)
if current_user.role != "waiter" && params[:create_type] == "create_pay"
if @status && @booking && @order.source == 'quick_service'
if @status && @booking && (@order.source == 'quick_service') || (@order.source == 'food_court')
@status, @sale = Sale.request_bill(@order,current_user,current_login_employee)
# for second display
from = getCloudDomain #get sub domain in cloud mode
ActionCable.server.broadcast "second_display_channel",data: @sale,status:"sale",from:from
#end
if @order.source == 'quick_service'
from = getCloudDomain #get sub domain in cloud mode
ActionCable.server.broadcast "second_display_channel",data: @sale,status:"sale",from:from
end
#end
result = {:status=> @status, :data => @sale }
render :json => result.to_json
end

View File

@@ -48,4 +48,30 @@ class Origami::CreditPaymentsController < BaseOrigamiController
end
end
def create_credit_payment
arr_sale = JSON.parse(params[:data])
if !ShiftSale.current_shift.nil?
if !arr_sale.nil?
arr_sale.each do |arr_sale|
arr_sale.each do |sale|
if(Sale.exists?(sale[0]))
saleObj = Sale.find(sale[0])
remark = "credit note payment for Receipt No #{saleObj.receipt_no}"
sale_payment = SalePayment.new
@status, @sale = sale_payment.process_payment(saleObj, current_user, sale[1], "cash", remark, true)
end
end
end
end
if @status
render :json => {status: true}
else
render :json => {status: false, message: 'Some error occurred!'}
end
else
render :json => {status: false, message: 'No current shift open for this employee!'}
end
end
end

View File

@@ -76,7 +76,6 @@ class Origami::CustomersController < BaseOrigamiController
filter = params[:filter]
if filter.nil?
puts params[:page]
@crm_customers = Customer.order("customer_id") #.page(params[:page])
#@products = Product.order("name").page(params[:page]).per(5)
else

View File

@@ -59,6 +59,16 @@ class Origami::DashboardController < BaseOrigamiController
if !quick_service[0].nil?
@quick_service = quick_service[0][1]
end
#fourt court
food_court = Lookup.collection_of('food_court')
@food_court = 0
@food_court_name = nil
if !food_court[0].nil?
@food_court = food_court[0][1]
@food_court_name = food_court[0][0]
end
#order reservation
order_reservation = Lookup.collection_of('order_reservation')
@order_reservation = 0
@@ -80,6 +90,17 @@ class Origami::DashboardController < BaseOrigamiController
end
end
end
#reservation
reservation = Lookup.collection_of('reservation')
@reservation = 0
if !reservation.empty?
reservation.each do |reserve|
if reserve[0] == 'Reservation'
@reservation = reserve[1]
end
end
end
end
def get_all_menu

View File

@@ -7,13 +7,13 @@ class Origami::DingaController < BaseOrigamiController
@sale_data = Sale.find_by_sale_id(@sale_id)
@receipt_no = @sale_data.receipt_no
@shop = Shop.first
# if @shop.is_rounding_adj
# new_total = Sale.get_rounding_adjustment(@sale_data.grand_total)
# else
# new_total = @sale_data.grand_total
# end
# @rounding_adj = new_total-@sale_data.grand_total
@rounding_adj = @sale_data.rounding_adjustment
if @shop.is_rounding_adj
new_total = Sale.get_rounding_adjustment(@sale_data.grand_total)
else
new_total = @sale_data.grand_total
end
@rounding_adj = new_total-@sale_data.grand_total
# @rounding_adj = @sale_data.rounding_adjustment
@payparcount = 0
others = 0
@@ -35,12 +35,13 @@ class Origami::DingaController < BaseOrigamiController
if !@membership_id.nil?
membership_setting = MembershipSetting.find_by_membership_type("paypar_url")
if membership_setting.gateway_url
member_actions =MembershipAction.find_by_membership_type("get_account_balance")
if member_actions.gateway_url
# payment_data =MembershipAction.find_by_membership_type("get_account_balance")
payment_data = PaymentMethodSetting.find_by_payment_method("DINGA")
if payment_data.gateway_url
@campaign_type_id = nil
url = membership_setting.gateway_url.to_s + member_actions.gateway_url.to_s
merchant_uid= member_actions.merchant_account_id
auth_token = member_actions.auth_token.to_s
url = membership_setting.gateway_url.to_s + payment_data.gateway_url.to_s
merchant_uid= payment_data.merchant_account_id
auth_token = payment_data.auth_token.to_s
membership_data = SalePayment.get_paypar_account(url,membership_setting.auth_token,@membership_id,@campaign_type_id,merchant_uid,auth_token)
if membership_data["status"]==true
@membership_rebate_balance=membership_data["balance"]

View File

@@ -0,0 +1,262 @@
class Origami::FoodCourtController < ApplicationController
# before_action :set_dining, only: [:detail]
before_action :check_user
def check_user
if current_user.nil?
redirect_to root_path
end
end
def index
today = DateTime.now
day = Date.today.wday
# if params[:menu] == "true"
@menus = []
@menu = []
# else
# @menus = Menu.all
# @menu = MenuCategory.active.where("menu_id =#{@menus[0].id}").order('order_by asc')
# end
@zone = Zone.all
@customer = Customer.all
@tables = Table.all.active.order('status desc')
@rooms = Room.all.active.order('status desc')
@cashier_type = "food_court"
#checked quick_service only
@quick_service_only = true
lookup_dine_in = Lookup.collection_of('dinein_cashier')
if !lookup_dine_in.empty?
lookup_dine_in.each do |dine_in|
if dine_in[0].downcase == "dineincashier"
if dine_in[1] == '1'
@quick_service_only = false
end
end
end
end
render "origami/addorders/detail"
end
def modify_order
@cashier_type = "food_court"
today = DateTime.now
day = Date.today.wday
# if params[:menu] == "true"
@menus = []
@menu = []
# else
# @menus = Menu.all
# @menu = MenuCategory.active.where("menu_id =#{@menus[0].id}").order('order_by asc')
# end
if(params[:id][0,3] == "BKI")
@table_id = nil
@table = nil
@booking = Booking.find(params[:id])
else
@table_id = params[:id]
@table = DiningFacility.find(@table_id)
@booking = @table.get_booking
end
@sale_id = params[:sale_id]
if @booking
@booking_id = @booking.booking_id
@order_items = Array.new
@booking.booking_orders.each do |booking_order|
order = Order.find(booking_order.order_id)
if (order.status == "new")
@obj_order = order
@customer = order.customer
@date = order.created_at
order.order_items.each do |item|
@order_items.push(item)
end
end
end
else
@booking = nil
end
render "origami/addorders/detail"
end
def update_modify_order
Rails.logger.debug "Order Source - " + params[:order_source].to_s
Rails.logger.debug "Table ID - " + params[:table_id].to_s
is_extra_time = false
extra_time = ''
@cashier_type = "food_court"
items_arr = []
JSON.parse(params[:order_items]).each { |i|
i["item_instance_code"] = i["item_instance_code"].downcase.to_s
if i["item_instance_code"].include? "ext"
is_extra_time = true
arr_exts = i["item_instance_code"].split("_")
if arr_exts[1].match(/^(\d)+$/)
time = arr_exts[1].to_i*60*i["quantity"].to_i
extra_time = Time.at(time)
end
end
if i["parent_order_item_id"]
items = {"order_item_id": i["order_item_id"],"item_instance_code": i["item_instance_code"],"quantity": i["quantity"],"parent_order_item_id": i["parent_order_item_id"],"options": i["options"]}
else
items = {"order_item_id": i["order_item_id"],"item_instance_code": i["item_instance_code"],"quantity": i["quantity"],"options": i["options"]}
end
items_arr.push(items)
}
# begin
@order = Order.new
@order.source = params[:order_source]
@order.order_type = params[:order_type]
@order.customer_id = params[:customer_id] == ""? "CUS-000000000001" : params[:customer_id] # for no customer id from mobile
@order.items = items_arr
@order.guest = params[:guest_info]
@order.table_id = params[:table_id] # this is dining facilities's id
@order.new_booking = true
@order.waiters = current_login_employee.name
@order.employee_name = current_login_employee.name
@order.is_extra_time = is_extra_time
@order.extra_time = extra_time
#Create Table Booking or Room Booking
if !params["booking_id"].nil?
# check booking id is already completed.
booking = Booking.find(params[:booking_id])
if params[:table_id].to_i > 0
table_status = booking.dining_facility_id.to_i == params[:table_id].to_i
else
table_status = true
end
if booking
if table_status && booking.booking_status != 'moved'
if !booking.sale_id.nil?
sale_status = check_order_with_booking(booking)
if sale_status
return return_json_status_with_code(400, "bill requested")
end
else
@order.new_booking = false
@order.booking_id = params[:booking_id]
end
else
if params[:table_id].to_i > 0
sale_status = check_order_with_table(params[:table_id])
if sale_status
return return_json_status_with_code(400, "bill requested")
end
end
end
end #booking exists
else
if params[:table_id].to_i > 0
sale_status = check_order_with_table(params[:table_id])
if sale_status
# return false , @message = "bill requested"
return return_json_status_with_code(400, "bill requested")
end
end
end
@status, @booking = @order.generate
if(params[:sale_id][0,3] == "SAL")
if @status && @booking && (@order.source == 'quick_service' || @order.source == 'food_court')
if params[:sale_id]
@sale = Sale.find(params[:sale_id])
if @order.table_id.to_i > 0
@table_id = @order.table_id
else
@table_id = nil
end
update = Sale.add_to_existing_pending_invoice(@table_id,params[:sale_id],@booking)
end
result = {:status=> true, :data => @sale }
render :json => result.to_json
end
elsif (params[:sale_id][0,3] == "BKI")
result = {:status=> true, :data => 'OK' }
render :json => result.to_json
else
result = {:status=> true, :data => nil }
render :json => result.to_json
end
end
def get_menu_category ()
if (params[:id])
puts params[:id]
#Pull this menu
@menu = MenuCategory.find_by_id(params[:id])
# puts @menu.menu_items[1].item_attributes.to_json
return @menu
else
MenuCategory.current_menu
end
end
def get_menu_sub_category ()
id = params[:id]
if (id)
#Pull this menu
@sub_menu = MenuCategory.where("menu_category_id = #{id}").active
# puts @menu.menu_items[1].item_attributes.to_json
return @sub_menu
end
end
def get_all_product()
@product = Product.all
end
# render json for http status code
def return_json_status_with_code(code, msg)
render status: code, json: {
message: msg,
booking_id: booking_id
}.to_json
end
def check_order_with_table(table_id)
table = DiningFacility.find(table_id)
if table
booking = table.get_current_booking
# puts booking
if booking
if !booking.sale_id.nil?
if booking.sale.sale_status == "completed" || booking.sale.sale_status == "new"
@order.new_booking = true
return false
end
else
@order.new_booking = false
@order.booking_id = booking.booking_id
return false
end
end
end
end
def check_user
if current_user.nil?
redirect_to root_path
end
end
# this can always true
def check_order_with_booking(booking)
if booking.sale.sale_status == "completed" || booking.sale.sale_status == "new"
@order.new_booking = true
return false
else
@order.new_booking = false
@order.booking_id = params[:booking_id]
return false
end
end
end

View File

@@ -97,7 +97,7 @@ class Origami::OrderReservationController < BaseOrigamiController
end
def get_order_info
order_reservation = OrderReservation.where("status = 'new' OR status='accepted' OR status='send_to_kitchen' OR status = 'ready_to_delivery'").count()
order_reservation = OrderReservation.where("status = 'new'").count()
render :json => order_reservation
end

View File

@@ -1,68 +1,66 @@
class Origami::PaymalController < BaseOrigamiController
def index
@sale_id = params[:sale_id]
payment_method = params[:payment_method]
@cashier_type = params[:type]
@membership_rebate_balance=0
sale_data = Sale.find_by_sale_id(@sale_id)
@receipt_no = sale_data.receipt_no
@shop = Shop.first
# if @shop.is_rounding_adj
# new_total = Sale.get_rounding_adjustment(sale_data.grand_total)
# else
# new_total = sale_data.grand_total
# end
# @rounding_adj = new_total-sale_data.grand_total
@rounding_adj = sale_data.rounding_adjustment
@sale_id = params[:sale_id]
payment_method = params[:payment_method]
@cashier_type = params[:type]
@membership_rebate_balance=0
sale_data = Sale.find_by_sale_id(@sale_id)
@receipt_no = sale_data.receipt_no
@shop = Shop.first
if @shop.is_rounding_adj
new_total = Sale.get_rounding_adjustment(sale_data.grand_total)
else
new_total = sale_data.grand_total
end
@rounding_adj = new_total-sale_data.grand_total
# @rounding_adj = sale_data.rounding_adjustment
@payparcount = 0
others = 0
sale_data.sale_payments.each do |sale_payment|
if sale_payment.payment_method == "paypar"
@payparcount = @payparcount + sale_payment.payment_amount
@payparcount = 0
others = 0
sale_data.sale_payments.each do |sale_payment|
if sale_payment.payment_method == "paypar"
@payparcount = @payparcount + sale_payment.payment_amount
else
others = others + sale_payment.payment_amount
end
end
@payment_prices = sale_data.grand_total - @payparcount -others
if sale_data
if sale_data.customer_id
customer_data= Customer.find_by_customer_id(sale_data.customer_id)
if customer_data
@membership_id = customer_data.membership_id
if !@membership_id.nil?
membership_setting = MembershipSetting.find_by_membership_type("paypar_url")
if membership_setting.gateway_url
member_actions =MembershipAction.find_by_membership_type("get_account_balance")
if member_actions.gateway_url
@campaign_type_id = nil
url = membership_setting.gateway_url.to_s + member_actions.gateway_url.to_s
merchant_uid= member_actions.merchant_account_id
auth_token = member_actions.auth_token.to_s
membership_data = SalePayment.get_paypar_account(url,membership_setting.auth_token,@membership_id,@campaign_type_id,merchant_uid,auth_token)
if membership_data["status"]==true
@membership_rebate_balance=membership_data["balance"]
@out = true, @membership_rebate_balance,@membership_id
end
else
others = others + sale_payment.payment_amount
@out =false,0
end
end
@payment_prices = sale_data.grand_total - @payparcount -others
if sale_data
if sale_data.customer_id
customer_data= Customer.find_by_customer_id(sale_data.customer_id)
if customer_data
@membership_id = customer_data.membership_id
if !@membership_id.nil?
membership_setting = MembershipSetting.find_by_membership_type("paypar_url")
if membership_setting.gateway_url
member_actions =MembershipAction.find_by_membership_type("get_account_balance")
if member_actions.gateway_url
@campaign_type_id = nil
url = membership_setting.gateway_url.to_s + member_actions.gateway_url.to_s
merchant_uid= member_actions.merchant_account_id
auth_token = member_actions.auth_token.to_s
membership_data = SalePayment.get_paypar_account(url,membership_setting.auth_token,@membership_id,@campaign_type_id,merchant_uid,auth_token)
if membership_data["status"]==true
@membership_rebate_balance=membership_data["balance"]
@out = true, @membership_rebate_balance,@membership_id
end
else
@out =false,0
end
else
else
@out = false,0
end
else
@out = false, 0
end
else
@out = false, 0
end
else
@out = false, 0
end
else
@out = false, 0
end
else
@out = false, 0
end
else
@out = false, 0
end

View File

@@ -91,7 +91,7 @@ class Origami::PaymentsController < BaseOrigamiController
printer = Printer::ReceiptPrinter.new(print_settings)
filename, receipt_no, cashier_printer = printer.print_receipt_bill(print_settings,cashier_terminal,sale_items,sale_data,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info, shop_detail, "Frt",current_balance,nil,other_amount,nil)
filename, receipt_no, cashier_printer = printer.print_receipt_bill(print_settings,cashier_terminal,sale_items,sale_data,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info, shop_detail, "Frt",current_balance,nil,other_amount,nil,nil)
result = {
:filepath => filename,
@@ -234,6 +234,9 @@ class Origami::PaymentsController < BaseOrigamiController
card_data.push({'res_date' => card_res_date, 'res_time' => card_res_time, 'batch_no' => cash_sale_trans.batch_no, 'trace' => cash_sale_trans.trace, 'pan' => card_no, 'app' => cash_sale_trans.app, 'tid' => cash_sale_trans.terminal_id, 'app_code' => cash_sale_trans.app_code, 'ref_no' => cash_sale_trans.ref_no, 'mid' => cash_sale_trans.merchant_id})
end
end
#card_balance amount for Paymal payment
card_balance_amount = SaleAudit.getCardBalanceAmount(sale_id)
# get printer info
print_settings=PrintSetting.find_by_unique_code(unique_code)
@@ -243,7 +246,7 @@ class Origami::PaymentsController < BaseOrigamiController
other_amount = SaleItem.calculate_other_charges(sale_items)
printer = Printer::ReceiptPrinter.new(print_settings)
filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings,cashier_terminal,sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_detail, "Paid",current_balance,card_data,other_amount,latest_order_no)
filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings,cashier_terminal,sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_detail, "Paid",current_balance,card_data,other_amount,latest_order_no,card_balance_amount)
render json: JSON.generate({:status => saleObj.rebate_status, :message => "Can't Rebate coz of Sever Error ", :filename => filename, :receipt_no => sale_receipt_no, :printer_name => printer_name})
@@ -255,13 +258,21 @@ class Origami::PaymentsController < BaseOrigamiController
def show
path = request.fullpath
sale_id = params[:sale_id]
@cashier_type = params[:type]
@trans_flag = true
if params[:type] == "transaction"
@trans_flag = false
@cashier_type = "cashier"
else
@cashier_type = params[:type]
end
if path.include? ("credit_payment")
@sale_payment = SalePayment.get_credit_amount_due_left(sale_id)
end
@member_discount = MembershipSetting.find_by_discount(1)
@membership_rebate_balance=0
if Sale.exists?(sale_id)
@cash = 0.0
@other = 0.0
@@ -389,6 +400,8 @@ class Origami::PaymentsController < BaseOrigamiController
#end customer amount
#paymal payment
@sale_data.bookings.each do |sbk|
if sbk.dining_facility_id.to_i >0
df = DiningFacility.find(sbk.dining_facility_id)
@@ -517,6 +530,10 @@ class Origami::PaymentsController < BaseOrigamiController
card_data.push({'res_date' => card_res_date, 'res_time' => card_res_time, 'batch_no' => cash_sale_trans.batch_no, 'trace' => cash_sale_trans.trace, 'pan' => card_no, 'app' => cash_sale_trans.app, 'tid' => cash_sale_trans.terminal_id, 'app_code' => cash_sale_trans.app_code, 'ref_no' => cash_sale_trans.ref_no, 'mid' => cash_sale_trans.merchant_id})
end
end
#card_balance amount for Paymal payment
card_balance_amount = SaleAudit.getCardBalanceAmount(sale_id)
# get printer info
print_settings=PrintSetting.find_by_unique_code(unique_code)
@@ -526,7 +543,7 @@ class Origami::PaymentsController < BaseOrigamiController
other_amount = SaleItem.calculate_other_charges(saleObj.sale_items)
printer = Printer::ReceiptPrinter.new(print_settings)
filename, receipt_no, cashier_printer = printer.print_receipt_bill(print_settings,cashier_terminal,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_detail, "Re-print",current_balance,card_data,other_amount,latest_order_no)
filename, receipt_no, cashier_printer = printer.print_receipt_bill(print_settings,cashier_terminal,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_detail, "Re-print",current_balance,card_data,other_amount,latest_order_no,card_balance_amount)
result = {
:status => true,
@@ -612,7 +629,7 @@ class Origami::PaymentsController < BaseOrigamiController
printer = Printer::ReceiptPrinter.new(print_settings)
filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings,cashier_terminal,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_detail, "FOC",nil,nil,other_amount,nil)
filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings,cashier_terminal,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_detail, "FOC",nil,nil,other_amount,nil,nil)
result = {
:status => true,
:filepath => filename,

View File

@@ -2,17 +2,21 @@ class Origami::PendingOrderController < BaseOrigamiController
def index
# @dining= DiningFacility.where("status = 'occupied'")
# @order = Order.where("DATE_FORMAT(date,'%Y-%m-%d') = ? and status = 'billed' and source = 'quick_service'",DateTime.now.strftime('%Y-%m-%d'))
@sale = Sale.pending_sale
@order = Sale.pending_order
@completed = Sale.completed_sale("quick_service")
@cashier_type = params[:type]
@sale = Sale.pending_sale(@cashier_type)
@order = Sale.pending_order(@cashier_type)
@completed = Sale.completed_sale(@cashier_type)
@customers = Customer.pluck("customer_id, name")
@occupied_table = @sale.count.length + @order.count.length
end
def show
@sales = Sale.pending_sale
@orders = Sale.pending_order
@completed = Sale.completed_sale("quick_service")
@cashier_type = params[:type]
@sales = Sale.pending_sale(@cashier_type)
@orders = Sale.pending_order(@cashier_type)
@completed = Sale.completed_sale(@cashier_type)
@customers = Customer.pluck("customer_id, name")
@occupied_table = @sales.count.length + @orders.count.length
@@ -51,9 +55,10 @@ class Origami::PendingOrderController < BaseOrigamiController
end
def completed_sale
@sales = Sale.pending_sale
@orders = Sale.pending_order
@completed = Sale.completed_sale("quick_service")
@cashier_type = params[:type]
@sales = Sale.pending_sale(@cashier_type)
@orders = Sale.pending_order(@cashier_type)
@completed = Sale.completed_sale(@cashier_type)
@customers = Customer.pluck("customer_id, name")
@occupied_table = @sales.count.length + @orders.count.length
@@ -76,16 +81,19 @@ class Origami::PendingOrderController < BaseOrigamiController
end
def cash_ins
@cashier_type = params[:type]
render "origami/cash_ins/new"
end
def cash_outs
@cashier_type = params[:type]
render "origami/cash_outs/new"
end
def credit_sale
@sales = Sale.pending_sale
@orders = Sale.pending_order
@completed = Sale.completed_sale("quick_service")
@cashier_type = params[:type]
@sales = Sale.pending_sale(@cashier_type)
@orders = Sale.pending_order(@cashier_type)
@completed = Sale.completed_sale(@cashier_type)
@occupied_table = @sales.count.length + @orders.count.length

View File

@@ -21,10 +21,25 @@ class Origami::QuickServiceController < ApplicationController
@customer = Customer.all
@tables = Table.all.active.order('status desc')
@rooms = Room.all.active.order('status desc')
@cashier_type = "quick_service"
#checked quick_service only
@quick_service_only = true
lookup_dine_in = Lookup.collection_of('dinein_cashier')
if !lookup_dine_in.empty?
lookup_dine_in.each do |dine_in|
if dine_in[0].downcase == "dineincashier"
if dine_in[1] == '1'
@quick_service_only = false
end
end
end
end
render "origami/addorders/detail"
end
def modify_order
@cashier_type = "quick_service"
today = DateTime.now
day = Date.today.wday
# if params[:menu] == "true"
@@ -71,6 +86,7 @@ class Origami::QuickServiceController < ApplicationController
Rails.logger.debug "Table ID - " + params[:table_id].to_s
is_extra_time = false
extra_time = ''
@cashier_type = "quick_service"
items_arr = []
JSON.parse(params[:order_items]).each { |i|

View File

@@ -7,13 +7,13 @@ class Origami::RedeemPaymentsController < BaseOrigamiController
sale_data = Sale.find_by_sale_id(@sale_id)
@shop = Shop.first
# if @shop.is_rounding_adj
# new_total = Sale.get_rounding_adjustment(sale_data.grand_total)
# else
# new_total = sale_data.grand_total
# end
# @rounding_adj = new_total-sale_data.grand_total
@rounding_adj = sale_data.rounding_adjustment
if @shop.is_rounding_adj
new_total = Sale.get_rounding_adjustment(sale_data.grand_total)
else
new_total = sale_data.grand_total
end
@rounding_adj = new_total-sale_data.grand_total
# @rounding_adj = sale_data.rounding_adjustment
@payparcount = 0
others = 0

View File

@@ -62,10 +62,12 @@ class Origami::RequestBillsController < ApplicationController
from = ""
end
ActionCable.server.broadcast "bill_channel",table: table, from: from
if order.source == "quick_service"
if order.source == "cashier" || order.source == "quick_service"
ActionCable.server.broadcast "bill_channel",table: table, from: from
end
if order.source == "quick_service" || order.source == "food_court"
result = {:status=> @status, :data => @sale.sale_id }
render :json => result.to_json
render :json => result.to_json
else
#check checkInOut pdf print
check_booking = Booking.find_by_sale_id(@sale_id)

View File

@@ -0,0 +1,45 @@
class Origami::ReservationController < BaseOrigamiController
def index
@reservations = Reservation.all
end
def show
end
def new
end
def edit
end
def create
end
def update
end
# DELETE /crm/customers/1
# DELETE /crm/customers/1.json
def destroy
@reservation.destroy
respond_to do |format|
format.html { redirect_to origami_reservation_url, notice: 'Reservation was successfully destroyed.' }
format.json { head :no_content }
end
end
private
# Use callbacks to share common setup or constraints between actions.
def set_origami_reservation
@reservation = Reservation.find(params[:reservation_id])
end
# Never trust parameters from the scary internet, only allow the white list through.
def customer_params
params.require(:reservation).permit(:reservation_id)
end
end

View File

@@ -33,7 +33,7 @@ class Origami::SurveysController < BaseOrigamiController
@table_type = @dining_facility.type
@receipt_no = nil
@grand_total = nil
@survey_data = Survey.find_by_dining_name_and_receipt_no(@dining_facility.name,"")
@survey_data = Survey.find_by_dining_name_and_receipt_no(@dining_facility.name,nil)
end
end
@@ -64,7 +64,7 @@ class Origami::SurveysController < BaseOrigamiController
shift_by_terminal = ShiftSale.find_by_cashier_terminal_id_and_shift_closed_at(shift.cashier_terminal_id,nil)
end
if @type == "quick_service"
if @type == "quick_service" || @type == "food_court"
@url = "/origami/sale/"+@sale_id+"/"+@type+"/payment"
else
@url = "/origami/"+@dining_facility.type.downcase+"/"+params[:table_id]

View File

@@ -109,7 +109,7 @@ class Origami::VoidController < BaseOrigamiController
customer= Customer.find(sale.customer_id)
#shop detail
shop_details = Shop.find(1)
shop_details = current_shop
# get member information
rebate = MembershipSetting.find_by_rebate(1)
if customer.membership_id != nil && rebate
@@ -126,7 +126,7 @@ class Origami::VoidController < BaseOrigamiController
discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(sale.sale_items)
other_amount = SaleItem.calculate_other_charges(sale.sale_items)
printer = Printer::ReceiptPrinter.new(print_settings)
filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings,cashier_terminal,sale.sale_items,sale,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details, "VOID",current_balance,nil,other_amount,nil)
filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings,cashier_terminal,sale.sale_items,sale,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details, "VOID",current_balance,nil,other_amount,nil,nil)
result = {
:filepath => filename,
:printer_model => print_settings.brand_name,

View File

@@ -1,7 +1,7 @@
class Origami::VoucherController < BaseOrigamiController
def index
@sale_id = params[:sale_id]
@cashier_type = params[:type]
# limit voucher_amount
sale_data = Sale.find_by_sale_id(@sale_id)
total = sale_data.grand_total
@@ -37,12 +37,13 @@ class Origami::VoucherController < BaseOrigamiController
membership_id = customer_data.membership_id
membership_setting = MembershipSetting.find_by_membership_type("paypar_url")
if membership_setting.gateway_url
member_actions =MembershipAction.find_by_membership_type("get_account_balance") #need to modify here
if member_actions.gateway_url
campaign_type_id = member_actions.additional_parameter["campaign_type_id"]
url = membership_setting.gateway_url.to_s + member_actions.gateway_url.to_s
merchant_uid= member_actions.merchant_account_id
auth_token = member_actions.auth_token.to_s
# payment_data =MembershipAction.find_by_membership_type("get_account_balance") #need to modify here
payment_data = PaymentMethodSetting.find_by_payment_method("Voucher")
if payment_data.gateway_url
campaign_type_id = payment_data.additional_parameters["campaign_type_id"]
url = membership_setting.gateway_url.to_s + payment_data.gateway_url.to_s
merchant_uid= payment_data.merchant_account_id
auth_token = payment_data.auth_token.to_s
# membership_data = SalePayment.get_paypar_account(url,membership_setting.auth_token,@membership_id,@campaign_type_id,merchant_uid,auth_token)
# if membership_data["status"]==true
# app_token: token,membership_id:membership_id,

View File

@@ -90,7 +90,7 @@ class Origami::WasteSpoileController < BaseOrigamiController
customer= Customer.find(sale.customer_id)
#shop detail
shop_details = Shop.find(1)
shop_details = current_shop
# get member information
rebate = MembershipSetting.find_by_rebate(1)
if customer.membership_id != nil && rebate
@@ -107,7 +107,7 @@ class Origami::WasteSpoileController < BaseOrigamiController
discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(sale.sale_items)
other_amount = SaleItem.calculate_other_charges(sale.sale_items)
printer = Printer::ReceiptPrinter.new(print_settings)
filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings,cashier_terminal,sale.sale_items,sale,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details, remark,current_balance,nil,other_amount,nil)
filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings,cashier_terminal,sale.sale_items,sale,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details, remark,current_balance,nil,other_amount,nil,nil)
result = {
:filepath => filename,
:printer_model => print_settings.brand_name,

View File

@@ -2,6 +2,7 @@ class Reports::CreditPaymentController < BaseReportController
authorize_resource :class => false
def index
@filter_for_credit = [['All',''],['Paid','paid'],['Unpaid','unpaid']]
@sources = [["All",''], ["Cashier","cashier"],["Quick Service","quick_service"],["Online Order","doemal_order"]]
from, to = get_date_range_from_params
@shift_sale_range = Sale.get_by_shift_sale_by_item(from,to,Sale::SALE_STATUS_COMPLETED)
@@ -18,7 +19,8 @@ authorize_resource :class => false
end
@filter = params[:filter_check]
@sale_data = Sale.get_by_shift_sale_credit_payment(@shift_sale_range,@shift,from,to,@filter)
@order_source = params[:order_source]
@sale_data = Sale.get_by_shift_sale_credit_payment(@shift_sale_range,@shift,from,to,@filter,@order_source)
@from = from
@to = to

View File

@@ -72,6 +72,6 @@ class Settings::MembershipActionsController < ApplicationController
# Never trust parameters from the scary internet, only allow the white list through.
def settings_membership_action_params
params.require(:membership_action).permit(:membership_type, :is_active, :gateway_communication_type, :gateway_url, :auth_token, :merchant_account_id, :created_by)
params.require(:membership_action).permit(:membership_type, :is_active, :gateway_communication_type, :gateway_url, :auth_token, :merchant_account_id, :created_by,:additional_parameters)
end
end

View File

@@ -5,7 +5,7 @@ class Settings::MenusController < ApplicationController
# GET /settings/menus
# GET /settings/menus.json
def index
@settings_menus = Menu.all.page(params[:page]).per(10)
@settings_menus = Menu.unscoped.all.page(params[:page]).per(10)
respond_to do |format|
format.html
format.xlsx
@@ -95,8 +95,8 @@ class Settings::MenusController < ApplicationController
:header_text => true}
# Menu Sheet
wb.add_worksheet(name: menu.name) do |sheet|
sheet.add_row ["Name",menu.name], :style=>title
wb.add_worksheet(name: menu.name,is_ordering: menu.is_ordering) do |sheet|
sheet.add_row ["Name",menu.name,"is_ordering",menu.is_ordering], :style=>title
sheet.add_row
sheet.add_row ["Category Code", "Category Name", "Item Code", "Item Name", "Account", "Item AltName", "Taxable", "Attributes", "Options", "Instance Code", "Instance Name", "Instance Attribute", "Price", "Is Default", "Image Path"], :style=>header_text

View File

@@ -41,6 +41,7 @@ class Settings::PaymentMethodSettingsController < ApplicationController
# PATCH/PUT /settings/payment_method_settings/1
# PATCH/PUT /settings/payment_method_settings/1.json
def update
puts settings_payment_method_setting_params
respond_to do |format|
if @settings_payment_method_setting.update(settings_payment_method_setting_params)
format.html { redirect_to settings_payment_method_setting_path(@settings_payment_method_setting), notice: 'Payment method setting was successfully updated.' }

View File

@@ -59,11 +59,11 @@ class Settings::ShopsController < ApplicationController
File.delete(delete_path)
end
end
save_path = Rails.root.join("public/#{Shop.find(1).shop_code}_#{a.original_filename}")
save_path = Rails.root.join("public/#{current_shop.shop_code}_#{a.original_filename}")
File.open(save_path, 'wb') do |f|
f.write a.read
end
audio_name = "#{Shop.find(1).shop_code}_#{a.original_filename}"
audio_name = "#{current_shop.shop_code}_#{a.original_filename}"
@settings_shop.display_images.where(:name => "order_audio").destroy_all
@display_image = @settings_shop.display_images.create!(:shop_id => @shop.id, :name => "order_audio", :image => audio_name)
else

View File

@@ -35,7 +35,7 @@ class Transactions::BookingsController < ApplicationController
def show
@booking = Booking.find(params[:id])
@order = nil
@order_items = []
@booking.booking_orders.each do |booking_order|
@order = Order.find(booking_order.order_id)
@@ -53,6 +53,19 @@ class Transactions::BookingsController < ApplicationController
end
end
def update_status
data = Booking.where("sale_id IS NULL AND booking_status='assign' AND booking_id = ?", params[:booking_id])
if !data.nil?
booking = Booking.find(params[:booking_id])
booking.booking_status = 'moved'
booking.save!
render :json => {:status => true, :message => "Update status successfully."}
else
render :json => {:status => false, :error_message => "Can't update status!"}
end
end
private
# Use callbacks to share common setup or constraints between actions.
def set_transactions_booking

View File

@@ -6,27 +6,34 @@ class Transactions::CreditNotesController < ApplicationController
# GET /transactions/sales
# GET /transactions/sales.json
def index
@sources = [["All",''], ["Cashier","cashier"],["Quick Service","quick_service"],["Online Order","doemal_order"]]
@customers = Customer.all
filter = params[:filter]
customer = params[:customer]
from = params[:from]
to = params[:to]
if filter.nil? && from.nil? && to.nil? && customer.nil?
@credit_notes = Sale.where('payment_status = ?', Sale::SALE_STATUS_OUTSTANDING)
@credit_notes = Kaminari.paginate_array(@credit_notes).page(params[:page]).per(20)
else
sale = Sale.search_credit_sales(customer,filter,from,to)
if sale.count > 0
@credit_notes = sale
@credit_notes = Kaminari.paginate_array(@credit_notes).page(params[:page]).per(20)
else
@credit_notes = 0
end
end
filter = params[:filter]
customer = params[:customer]
from = params[:from]
to = params[:to]
order_source = params[:order_source]
if filter.nil? && from.nil? && to.nil? && customer.nil? && order_source.nil?
@credit_notes = Sale.select("sales.*, orders.source")
.joins("JOIN sale_payments sp on sp.sale_id = sales.sale_id")
.where("(CASE WHEN (sales.grand_total + sales.amount_changed)=(select SUM(sale_payments.payment_amount)
FROM sale_payments WHERE sale_payments.sale_id=sales.sale_id AND sale_payments.payment_method!='creditnote')
THEN NULL ELSE payment_method='creditnote' END)")
.joins(" JOIN bookings ON bookings.sale_id=sales.sale_id")
.joins(" JOIN booking_orders ON booking_orders.booking_id=bookings.booking_id")
.joins(" JOIN orders ON orders.order_id=booking_orders.order_id")
@credit_notes = Kaminari.paginate_array(@credit_notes).page(params[:page]).per(20)
else
sale = Sale.search_credit_sales(customer,filter,from,to,order_source)
if !sale.nil?
@credit_notes = sale
@credit_notes = Kaminari.paginate_array(@credit_notes).page(params[:page]).per(20)
else
@credit_notes = 0
end
end
respond_to do |format|
format.html # index.html.erb
format.json { render json: @credit_notes }

View File

@@ -89,7 +89,8 @@ class Transactions::SalesController < ApplicationController
# GET /transactions/sales/1
# GET /transactions/sales/1.json
def show
@membership = MembershipSetting::MembershipSetting
@payment_methods = PaymentMethodSetting.where("is_active='1'")
@sale = Sale.find(params[:id])
@order_items = []
@@ -363,7 +364,7 @@ class Transactions::SalesController < ApplicationController
other_amount = SaleItem.calculate_other_charges(sale.sale_items) #other charges
printer = Printer::ReceiptPrinter.new(print_settings)
filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings,cashier_terminal,sale.sale_items,sale,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details, "VOID",current_balance,nil,other_amount,nil)
filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings,cashier_terminal,sale.sale_items,sale,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details, "VOID",current_balance,nil,other_amount,nil,nil)
result = {
:filepath => filename,
:printer_model => print_settings.brand_name,

View File

@@ -46,16 +46,18 @@ class Booking < ApplicationRecord
if filter.blank?
keyword = ''
else
keyword = "booking_id LIKE ? OR checkin_by LIKE ? OR booking_status LIKE? OR checkout_by LIKE? OR sale_id ='#{filter}'","%#{filter}%","%#{filter}%","%#{filter}%","%#{filter}%"
keyword = "booking_id LIKE ? OR checkin_by LIKE ? OR booking_status LIKE? OR checkout_by LIKE? OR sale_id ='#{filter}' OR df.name LIKE ?","%#{filter}%","%#{filter}%","%#{filter}%","%#{filter}%","%#{filter}%"
end
if from.present? && to.present?
booking = Booking.where("DATE_FORMAT(created_at,'%d-%m-%Y') >= ?" + " AND DATE_FORMAT(created_at,'%d-%m-%Y') <= ? and NOT booking_status = 'void' ", from,to)
booking = Booking.joins(" LEFT JOIN dining_facilities df ON df.id=bookings.dining_facility_id")
.where("DATE_FORMAT(bookings.created_at,'%d-%m-%Y') >= ?" + " AND DATE_FORMAT(bookings.created_at,'%d-%m-%Y') <= ? and NOT bookings.booking_status = 'void' ", from,to)
query = booking.where(keyword)
else
where("booking_id LIKE ? OR checkin_by LIKE ? OR booking_status LIKE? OR checkout_by LIKE? OR sale_id ='#{filter}'","%#{filter}%","%#{filter}%","%#{filter}%","%#{filter}%")
joins(" LEFT JOIN dining_facilities df ON df.id=bookings.dining_facility_id")
.where("booking_id LIKE ? OR checkin_by LIKE ? OR booking_status LIKE? OR checkout_by LIKE? OR sale_id ='#{filter}' OR df.name LIKE ?","%#{filter}%","%#{filter}%","%#{filter}%","%#{filter}%","%#{filter}%")
end
.order("sale_id DESC")
end
private

View File

@@ -336,7 +336,7 @@ class Customer < ApplicationRecord
def self.search(search)
if search
# find(:all, :conditions => ['name LIKE ? OR contact_no LIKE ?', "%#{search}%", "%#{search}%"])
where("name LIKE ? OR contact_no LIKE ? OR card_no LIKE ? OR paypar_account_no ='#{search}'", "%#{search}%", "%#{search}%", "%#{search}%",)
where("name LIKE ? OR customer_type OR contact_no LIKE ? OR card_no LIKE ? OR DATE_FORMAT(date_of_birth,'%Y-%m-%d') LIKE ? OR nrc_no LIKE ? OR gender LIKE ? OR paypar_account_no ='#{search}'", "%#{search}%", "%#{search}%", "%#{search}%", "%#{search}%", "%#{search}%", "%#{search}%", "%#{search}%")
else
find(:all)
end

View File

@@ -61,4 +61,48 @@ class InventoryDefinition < ApplicationRecord
end
end
end
def self.search_by_category(cat_id)
@inventory_definitions = InventoryDefinition.select("inventory_definitions.*,
mi.name as item_name,mii.item_instance_name as instance_name," +
"mi.item_code as item_code,mii.item_instance_code as instance_code," +
"mc.name as menu_category_name,mc.id as menu_category_id ")
.joins("JOIN menu_item_instances mii ON mii.item_instance_code = inventory_definitions.item_code" +
" JOIN menu_items mi ON mi.id = mii.menu_item_id" +
" JOIN menu_categories mc ON mc.id = mi.menu_category_id ")
.where("mc.id=#{cat_id}")
.group("mi.menu_category_id,inventory_definitions.item_code")
.order("mi.menu_category_id desc")
end
def self.get_by_category(filter)
least_stock = "SELECT (CASE WHEN stock_journals.remark != 'out of stock'
THEN (SELECT balance FROM stock_journals
WHERE item_code = inventory_definitions.item_code AND remark != 'out of stock'
ORDER BY created_at DESC LIMIT 1) ELSE 0 END)
FROM stock_journals
WHERE stock_journals.item_code = inventory_definitions.item_code
ORDER BY stock_journals.created_at DESC LIMIT 1"
@inventory_definitions = InventoryDefinition.select("inventory_definitions.*,
(CASE WHEN sj.credit IS NULL THEN 0 ELSE sj.credit END) as credit,
(CASE WHEN sj.debit IS NULL THEN 0 ELSE sj.debit END) as debit,
(#{least_stock}) as balance,"+
"acc.title as account_name,mi.name as item_name,
mii.item_instance_name as instance_name," +
"mc.name as menu_category_name,mc.id as menu_category_id "
)
.joins(" LEFT JOIN stock_journals sj ON sj.inventory_definition_id=inventory_definitions.id")
.joins("JOIN menu_item_instances mii ON mii.item_instance_code = inventory_definitions.item_code" +
" JOIN menu_items mi ON mi.id = mii.menu_item_id" +
" JOIN menu_categories mc ON mc.id = mi.menu_category_id ")
.joins(" JOIN accounts acc ON acc.id = mi.account_id")
.where("inventory_definitions.item_code LIKE ? OR inventory_definitions.min_order_level LIKE ?
OR inventory_definitions.max_stock_level LIKE ? OR sj.balance LIKE ? OR mi.name LIKE ?
OR mii.item_instance_name LIKE ? OR mc.name LIKE ?","%#{filter}%","%#{filter}%","%#{filter}%",
"%#{filter}%","%#{filter}%","%#{filter}%","%#{filter}%")
.group("mi.menu_category_id,inventory_definitions.item_code")
.order("acc.title desc,mi.menu_category_id desc,balance ASC")
end
end

View File

@@ -91,9 +91,9 @@ class Menu < ApplicationRecord
elsif sheet_name == "Menu"
menu = Menu.find_by_id(row["id"])
if menu
Menu.create(name: row["name"], is_active: row["is_active"], valid_days: row["valid_days"],valid_time_from: row["valid_time_from"], valid_time_to: row["valid_time_to"], created_by: row["created_by"])
Menu.create(name: row["name"], is_active: row["is_active"], is_ordering: row["is_ordering"], valid_days: row["valid_days"],valid_time_from: row["valid_time_from"], valid_time_to: row["valid_time_to"], created_by: row["created_by"])
else
Menu.create(id:row["id"], name: row["name"], is_active: row["is_active"], valid_days: row["valid_days"],valid_time_from: row["valid_time_from"], valid_time_to: row["valid_time_to"], created_by: row["created_by"])
Menu.create(id:row["id"], name: row["name"], is_active: row["is_active"], is_ordering: row["is_ordering"], valid_days: row["valid_days"],valid_time_from: row["valid_time_from"], valid_time_to: row["valid_time_to"], created_by: row["created_by"])
end
elsif sheet_name == "Menu Category"
# MenuCategory.create(id:row["id"], menu_id: row["menu_id"], code: row["code"], name: row["name"], alt_name: row["alt_name"], order_by: row["order_by"], created_by: row["created_by"], menu_category_id: row["menu_category_id"], is_available: row["is_available"])
@@ -150,7 +150,9 @@ class Menu < ApplicationRecord
sheet = spreadsheet.sheet(0)
menu = sheet.row(1)[1]
imported_menu = Menu.create({name: menu, is_active: true, valid_days: "1,2,3,4,5,6,7",valid_time_from: "00:00:00", valid_time_to: "23:59:59", created_by: created_by})
is_ordering = sheet.row(1)[3]?sheet.row(1)[3]:0
imported_menu = Menu.create({name: menu, is_active: true, is_ordering: is_ordering, valid_days: "1,2,3,4,5,6,7",valid_time_from: "00:00:00", valid_time_to: "23:59:59", created_by: created_by})
(4..sheet.last_row).each do |ii|
row = Hash[[sheet.row(3),sheet.row(ii)].transpose]

View File

@@ -48,7 +48,9 @@ class OrderQueueStation < ApplicationRecord
# else
if (order_item.qty > 0)
AssignedOrderItem.assigned_order_item(order, order_item.item_code, order_item.item_instance_code, oqs)
if pdf_status.nil?
AssignedOrderItem.assigned_order_item(order, order_item.item_code, order_item.item_instance_code, oqs)
end
oqs_order_items.push(order_item)
end
# end
@@ -87,7 +89,9 @@ class OrderQueueStation < ApplicationRecord
# else
if (order_item.qty > 0)
AssignedOrderItem.assigned_order_item(order, order_item.item_code, order_item.item_instance_code, oqs)
if pdf_status.nil?
AssignedOrderItem.assigned_order_item(order, order_item.item_code, order_item.item_instance_code, oqs)
end
oqs_order_items.push(order_item)
end
# end
@@ -233,14 +237,12 @@ class OrderQueueStation < ApplicationRecord
print_settings=PrintSetting.find_by_unique_code(unique_code)
order_queue_printer= Printer::OrderQueuePrinter.new(print_settings)
order_queue_printer.print_order_summary(print_settings, oqs,order.order_id, order_items, print_status="")
assigned =AssignedOrderItem.where("order_id = '#{ order.order_id }'").pluck(:assigned_order_item_id)
AssignedOrderItem.where('assigned_order_item_id IN (?)', assigned).update_all(print_status: true)
else
move_print_pdf(change_to,current_user,table_id,order_items)
move_print_pdf(change_to,current_user,table_id,order_items,oqs)
end
assigned =AssignedOrderItem.where("order_id = '#{ order.order_id }'").pluck(:assigned_order_item_id)
AssignedOrderItem.where('assigned_order_item_id IN (?)', assigned).update_all(print_status: true)
end
#Print order_item in 1 slip per item
@@ -277,16 +279,15 @@ class OrderQueueStation < ApplicationRecord
order_queue_printer.print_order_item(print_settings, oqs,order_item.order_id, order_item.order_items_id, print_status="" )
end
end
assigned =AssignedOrderItem.where("order_id = '#{ order.order_id }'").pluck(:assigned_order_item_id)
AssignedOrderItem.where('assigned_order_item_id IN (?)', assigned).update_all(print_status: true)
else
move_print_pdf(change_to,current_user,table_id,assigned_items)
move_print_pdf(change_to,current_user,table_id,assigned_items,oqs)
end
assigned =AssignedOrderItem.where("order_id = '#{ order.order_id }'").pluck(:assigned_order_item_id)
AssignedOrderItem.where('assigned_order_item_id IN (?)', assigned).update_all(print_status: true)
end
def move_print_pdf(change_to,current_user,change_from,order_items)
def move_print_pdf(change_to,current_user,change_from,order_items,oqs)
if ENV["SERVER_MODE"] != "cloud" #no print in cloud server
# get printer info
@from = (DiningFacility.find(change_from)).name
@@ -296,18 +297,18 @@ class OrderQueueStation < ApplicationRecord
@date = DateTime.now
@shop = Shop.first
unique_code = "MoveTablePdf"
pdf_no = PrintSetting.where(:unique_code => unique_code).count
#print_settings = PrintSetting.find_by_unique_code(unique_code)
printer_array = []
printer_array = PrintSetting.where(:unique_code => unique_code)
# pdf_no = PrintSetting.where(:unique_code => unique_code).count
print_settings = PrintSetting.find_by_unique_code(unique_code)
# printer_array = []
# printer_array = PrintSetting.where(:unique_code => unique_code)
for i in 0..pdf_no
if i != pdf_no
print_settings = printer_array[i]
# for i in 0..pdf_no
# if i != pdf_no
# print_settings = printer_array[i]
printer = Printer::ReceiptPrinter.new(print_settings)
printer.print_move_table(print_settings,@to,@from ,@shop,@date,@type,@moved_by,order_items)
end
end
printer.print_move_table(print_settings,@to,@from ,@shop,@date,@type,@moved_by,order_items,oqs)
# end
# end
end
end
end

View File

@@ -11,7 +11,7 @@ class OrderReservation < ApplicationRecord
scope :latest_order, -> { order("order_reservation_id desc, created_at desc") }
SEND_TO_KITCHEN = "send_to_kitchen"
READY_TO_DELIVERY = "ready_to_deliver"
READY_TO_DELIVERY = "ready_to_delivery"
DELIVERED = "delivered"
COMPLETED = "completed"
@@ -134,7 +134,7 @@ class OrderReservation < ApplicationRecord
#order status send to doemal
callback_response = send_status_to_ordering(order.callback_url,order.transaction_ref,SEND_TO_KITCHEN)
#order reservation status updated
# order reservation status updated
update_order_reservation(order.id, @sale.sale_id, SEND_TO_KITCHEN)
result = {:status=> @status, :data => @sale, :message => "send to kitchen" }
@@ -164,8 +164,12 @@ class OrderReservation < ApplicationRecord
#end rounding adjustment
sale_payment = SalePayment.new
sale_payment.process_payment(saleObj, current_user, saleObj.grand_total, "cash")
if(order.payment_type == "COD")
sale_payment.process_payment(saleObj, current_user, saleObj.grand_total, "cash")
else
remark = "credit payment for Receipt No #{saleObj.receipt_no}"
@status, @sale = sale_payment.process_payment(saleObj, current_user, saleObj.grand_total, "creditnote", remark)
end
#order status send to doemal
callback_response = send_status_to_ordering(order.callback_url,order.transaction_ref,DELIVERED)
#order reservation status updated
@@ -237,6 +241,7 @@ class OrderReservation < ApplicationRecord
def self.update_order_reservation(id, sale_id, status, expected_waiting_time=nil, remark=nil, access_code=nil, current_user=nil)
order_reservation = OrderReservation.find(id)
action_times = {}
if sale_id.present?
order_reservation.sale_id = sale_id
end
@@ -251,12 +256,34 @@ class OrderReservation < ApplicationRecord
end
if status == "delivered"
order_reservation.payment_status = "paid"
elsif status == 'foc'
order_reservation.payment_status = "paid"
elsif status == 'void'
order_reservation.payment_status = "void"
end
if status == "accepted"
action_times = {"accepted_time" => DateTime.now.utc, "kitchen_time" => "", "ready_time" => ""}
order_reservation.action_times = action_times.to_json
elsif status == SEND_TO_KITCHEN
if !order_reservation.action_times.nil?
action_data = JSON.parse(order_reservation.action_times)
action_data["kitchen_time"] = DateTime.now.utc
order_reservation.action_times = action_data.to_json
end
elsif status == READY_TO_DELIVERY
if !order_reservation.action_times.nil?
action_data = JSON.parse(order_reservation.action_times)
action_data["ready_time"] = DateTime.now.utc
order_reservation.action_times = action_data.to_json
end
end
order_reservation.save
# if !order_reservation.sale_id.nil? && status == "rejected"
# void_doemal_payment(order_reservation.sale_id, remark, access_code, current_user)
# end
if !order_reservation.sale_id.nil? && (status == "rejected" || status == "void")
void_doemal_payment(order_reservation.sale_id, remark, access_code, current_user)
end
end
def self.void_doemal_payment(sale_id, remark, access_code, current_user)
@@ -281,11 +308,22 @@ class OrderReservation < ApplicationRecord
sale.sale_status = 'void'
sale.save
# FOr Sale Audit
action_by = current_user.name
# For Sale Audit
if !current_user.nil?
action_by = current_user.name
else
action_by = "doemal"
end
approved_name = nil
approved_by = Employee.find_by_emp_id(access_code)
if !approved_by.nil?
approved_name = approved_by.name
end
cashier_name = Employee.where("id=?",sale.cashier_id).name
# remark = "Void Sale ID #{sale_id} | Receipt No #{sale.receipt_no} | Receipt No #{sale.receipt_no} | Table ->#{table.name}"
sale_audit = SaleAudit.record_audit_for_edit(sale_id,sale.cashier_id, approved_by.name,remark,"SALEVOID" )
sale_audit = SaleAudit.record_audit_for_edit(sale_id,cashier_name, approved_name,remark,"SALEVOID" )
# update complete order items in oqs
SaleOrder.where("sale_id = '#{ sale_id }'").find_each do |sodr|
@@ -386,7 +424,7 @@ class OrderReservation < ApplicationRecord
end
end
query = OrderReservation.select("order_reservations.*, sales.receipt_date, deliveries.provider, deliveries.delivery_fee, customers.name, customers.email")
query = OrderReservation.select("order_reservations.*, sales.receipt_date, sales.receipt_no, deliveries.provider, deliveries.delivery_fee, customers.name, customers.email")
.joins(" JOIN deliveries on deliveries.order_reservation_id = order_reservations.order_reservation_id")
.joins(" JOIN customers on customers.customer_id = order_reservations.customer_id")
.joins(" JOIN sales on sales.sale_id = order_reservations.sale_id")

View File

@@ -1,4 +1,4 @@
class PaymentMethodSetting < ApplicationRecord
# validations
validates_presence_of :payment_method #, :gateway_communication_type, :gateway_url, :auth_token, :merchant_account_id
validates_presence_of :payment_method , :gateway_communication_type #, :gateway_url, :auth_token, :merchant_account_id
end

View File

@@ -188,19 +188,19 @@ class Printer::ReceiptPrinter < Printer::PrinterWorker
end
#Bill Receipt Print
def print_receipt_bill(printer_settings,cashier_terminal,sale_items,sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info = nil,rebate_amount=nil,shop_details, printed_status,balance,card_data,other_amount,latest_order_no)
def print_receipt_bill(printer_settings,cashier_terminal,sale_items,sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info = nil,rebate_amount=nil,shop_details, printed_status,balance,card_data,other_amount,latest_order_no,card_balance_amount)
#Use CUPS service
#Generate PDF
#Print
pdf = ReceiptBillPdf.new(printer_settings, sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details,printed_status,balance,card_data,other_amount,latest_order_no)
pdf = ReceiptBillPdf.new(printer_settings, sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details,printed_status,balance,card_data,other_amount,latest_order_no,card_balance_amount)
receipt_bill_a5_pdf = Lookup.collection_of("print_settings") #print_settings with name:ReceiptBillA5Pdf
if !receipt_bill_a5_pdf.empty?
receipt_bill_a5_pdf.each do |receipt_bilA5|
if receipt_bilA5[0] == 'ReceiptBillA5Pdf'
if receipt_bilA5[1] == '1'
pdf = ReceiptBillA5Pdf.new(printer_settings, sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details,printed_status,balance,card_data,other_amount,latest_order_no)
pdf = ReceiptBillA5Pdf.new(printer_settings, sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details,printed_status,balance,card_data,other_amount,latest_order_no,card_balance_amount)
else
pdf = ReceiptBillPdf.new(printer_settings, sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details,printed_status,balance,card_data,other_amount,latest_order_no)
pdf = ReceiptBillPdf.new(printer_settings, sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details,printed_status,balance,card_data,other_amount,latest_order_no,card_balance_amount)
end
end
end
@@ -266,13 +266,22 @@ class Printer::ReceiptPrinter < Printer::PrinterWorker
end
#Move Table Print
def print_move_table(printer_settings,to,from,shop_detail,date,type,moved_by,order_items)
def print_move_table(printer_settings,to,from,shop_detail,date,type,moved_by,order_items,oqs)
#Use CUPS service
#Generate PDF
#Print
pdf = MoveTablePdf.new(printer_settings,to,from,shop_detail,date,type,moved_by,order_items)
pdf.render_file "tmp/print_move_table.pdf"
self.print("tmp/print_move_table.pdf")
if oqs.print_copy
self.print("tmp/print_move_table.pdf",oqs.printer_name)
else
print_settings.print_copies = 1
print_settings.save!
#no print in cloud server
self.print("tmp/print_move_table.pdf", oqs.printer_name)
end
end
#Bill Receipt Print

15
app/models/reservation.rb Normal file
View File

@@ -0,0 +1,15 @@
class Reservation < ApplicationRecord
self.primary_key = "reservation_id"
#primary key - need to be unique generated for multiple shops
before_create :generate_custom_id
has_many :reservation_items
scope :active, -> { where("created_at BETWEEN '#{DateTime.now.utc.beginning_of_day}' AND '#{DateTime.now.utc.end_of_day}'") }
private
def generate_custom_id
self.order_reservation_id = SeedGenerator.generate_id(self.class.name, "RS")
end
end

View File

@@ -0,0 +1,13 @@
class ReservationItem < ApplicationRecord
self.primary_key = "reservation_items_id"
#primary key - need to be unique
before_create :generate_custom_id
belongs_to :reservation, autosave: true
private
def generate_custom_id
self.reservation_items_id = SeedGenerator.generate_id(self.class.name, "RSI")
end
end

View File

@@ -734,10 +734,10 @@ class Sale < ApplicationRecord
where("receipt_no LIKE ? OR cashier_name LIKE ? OR sale_status ='#{filter}' and shift_sale_id = ?","%#{filter}%","%#{filter}%",shift.id)
end
end
.order("sale_id DESC")
end
def self.search_credit_sales(customer,filter,from,to)
def self.search_credit_sales(customer,filter,from,to,order_source="")
if filter.blank?
keyword = ''
else
@@ -750,12 +750,30 @@ class Sale < ApplicationRecord
custo = "and customer_id = '#{customer}'"
end
if from.present? && to.present?
sale = Sale.all.joins("JOIN sale_payments sp on sp.sale_id = sales.sale_id")
.where("DATE_FORMAT(receipt_date,'%d-%m-%Y') >= ?" + " AND DATE_FORMAT(receipt_date,'%d-%m-%Y') <= ? and sp.payment_method = 'creditnote' #{keyword} #{custo}", from,to)
if order_source.blank?
source = ""
else
sale = Sale.all.joins("JOIN sale_payments sp on sp.sale_id = sales.sale_id")
.where("sp.payment_method ='creditnote' #{keyword} #{custo}")
if order_source == "cashier"
source = "and orders.source='cashier' or orders.source='emenu'"
else
source = "and orders.source='#{order_source}'"
end
end
if from.present? && to.present?
sale = Sale.select("sales.*,orders.source").joins("JOIN sale_payments sp on sp.sale_id = sales.sale_id")
.joins(" JOIN bookings ON bookings.sale_id=sales.sale_id")
.joins(" JOIN booking_orders ON booking_orders.booking_id=bookings.booking_id")
.joins(" JOIN orders ON orders.order_id=booking_orders.order_id")
.where("DATE_FORMAT(receipt_date,'%d-%m-%Y') >= ?" + " AND DATE_FORMAT(receipt_date,'%d-%m-%Y') <= ? and (CASE WHEN (sales.grand_total + sales.amount_changed)=(select SUM(sale_payments.payment_amount)
FROM sale_payments WHERE sale_payments.sale_id=sales.sale_id AND sale_payments.payment_method!='creditnote') THEN NULL ELSE payment_method='creditnote' END) #{keyword} #{custo} #{source}", from,to)
else
sale = Sale.select("sales.*,orders.source").joins(" JOIN sale_payments sp on sp.sale_id = sales.sale_id")
.joins(" JOIN bookings ON bookings.sale_id=sales.sale_id")
.joins(" JOIN booking_orders ON booking_orders.booking_id=bookings.booking_id")
.joins(" JOIN orders ON orders.order_id=booking_orders.order_id")
.where("(CASE WHEN (sales.grand_total + sales.amount_changed)=(select SUM(sale_payments.payment_amount)
FROM sale_payments WHERE sale_payments.sale_id=sales.sale_id AND sale_payments.payment_method!='creditnote') THEN NULL ELSE payment_method='creditnote' END) #{keyword} #{custo} #{source}")
end
end
@@ -1186,7 +1204,7 @@ def self.get_shift_sales_by_receipt_no_detail(shift_sale_range,shift,from,to,pay
return query
end
def self.get_by_shift_sale_credit_payment(shift_sale_range,shift,from,to,filter)
def self.get_by_shift_sale_credit_payment(shift_sale_range,shift,from,to,filter,order_source)
sub_query = "SELECT (CASE WHEN SUM(payment_amount) > 0
THEN DATE_FORMAT(CONVERT_TZ(sale_payments.created_at,'+00:00','+06:30'),'%d %b %y %h:%i%p') ELSE '-' END)
FROM `sale_payments`
@@ -1205,7 +1223,7 @@ def self.get_by_shift_sale_credit_payment(shift_sale_range,shift,from,to,filter)
FROM shift_sales
WHERE shift_sales.id = s.shift_sale_id"
sub_query3 = "SELECT (CASE WHEN shift_closed_at IS NOT NULL AND credit_payment > 0
sub_query3 = "SELECT (CASE WHEN shift_closed_at IS NOT NULL OR shift_closed_at IS NULL AND credit_payment > 0
THEN employees.name ELSE '-' END)
FROM shift_sales
INNER JOIN employees ON employees.id=shift_sales.employee_id
@@ -1223,10 +1241,19 @@ def self.get_by_shift_sale_credit_payment(shift_sale_range,shift,from,to,filter)
INNER JOIN sale_audits ON SUBSTRING_INDEX(sale_audits.remark,'||',1)=sale_payments.sale_payment_id
WHERE sale_audits.sale_id = s.sale_id) = 0"
end
if order_source.blank?
source = ""
else
if order_source == "cashier"
source = "and orders.source='cashier' or orders.source='emenu'"
else
source = "and orders.source='#{order_source}'"
end
end
query = SalePayment.select("s.receipt_no, sale_payments.*,
SUM(sale_payments.payment_amount) as payment_amount,
s.receipt_date as sale_date,
orders.source as order_source,
s.cashier_name as cashier_name,
(#{sub_query}) as credit_payment_receipt_date,
(#{sub_query1}) as credit_payment,
@@ -1234,13 +1261,16 @@ def self.get_by_shift_sale_credit_payment(shift_sale_range,shift,from,to,filter)
(#{sub_query2}) as credit_payment_shift_name")
.joins("INNER JOIN sales s ON s.sale_id = sale_payments.sale_id")
.joins("INNER JOIN shift_sales ss ON ss.id = s.shift_sale_id")
.joins("INNER JOIN bookings ON bookings.sale_id=s.sale_id")
.joins("INNER JOIN booking_orders ON booking_orders.booking_id=bookings.booking_id")
.joins("INNER JOIN orders ON orders.order_id=booking_orders.order_id")
if shift.present?
query = query.where("sale_payments.payment_method= 'creditnote' and s.sale_status = 'completed' #{filter_check} and s.shift_sale_id in (?)",shift.to_a)
query = query.where("sale_payments.payment_method= 'creditnote' and s.sale_status = 'completed' #{filter_check} and s.shift_sale_id in (?) #{source}",shift.to_a)
elsif shift_sale_range.present?
query = query.where("sale_payments.payment_method='creditnote' and s.sale_status = 'completed' #{filter_check} and s.shift_sale_id in (?)",shift_sale_range.to_a)
query = query.where("sale_payments.payment_method='creditnote' and s.sale_status = 'completed' #{filter_check} and s.shift_sale_id in (?) #{source}",shift_sale_range.to_a)
else
query = query.where("sale_payments.payment_method='creditnote' and s.sale_status = 'completed' #{filter_check} and s.receipt_date between ? and ? ",from,to)
query = query.where("sale_payments.payment_method='creditnote' and s.sale_status = 'completed' #{filter_check} and s.receipt_date between ? and ? #{source}",from,to)
end
query = query.group("s.sale_id")
end
@@ -2859,25 +2889,30 @@ end
end
end
def self.pending_sale
def self.pending_sale(type)
query = Sale.all
query = query.joins("join sale_orders as sale_orders on sale_orders.sale_id = sales.sale_id")
.joins("join orders as orders on orders.order_id = sale_orders.order_id")
query = query.where("sales.sale_status = 'new' AND orders.status = 'billed' AND orders.source =? ","quick_service")
query = query.where("sales.sale_status = 'new' AND orders.status = 'billed' AND orders.source =? ","#{type}")
.group("sales.sale_id")
end
def self.pending_order
def self.pending_order(type)
query = Booking.all
query = query.joins("join booking_orders as booking_orders on booking_orders.booking_id = bookings.booking_id")
.joins("join orders as orders on orders.order_id = booking_orders.order_id")
query = query.where("bookings.booking_status = 'assign' AND orders.status = 'new' AND orders.source =? ","quick_service")
query = query.where("bookings.booking_status = 'assign' AND orders.status = 'new' AND orders.source =? ","#{type}")
.group("bookings.booking_id")
end
def self.completed_sale(type)
if type == "cashier"
type = "and orders.source = 'emenu' or orders.source = 'cashier'"
else
type = "and orders.source = '#{type}'"
end
query = Sale.all
query = query.joins("join sale_orders as sale_orders on sale_orders.sale_id = sales.sale_id")
.joins("join orders as orders on orders.order_id = sale_orders.order_id")
query = query.where("sales.sale_status != 'new' AND orders.status = 'billed' AND orders.source =? ","#{type}")
query = query.where("sales.sale_status != 'new' AND orders.status = 'billed' #{type}")
query = query.where("DATE_FORMAT(sales.receipt_date,'%Y-%m-%d') = ? ",DateTime.now.strftime('%Y-%m-%d'))
.group("sales.sale_id")
end

View File

@@ -119,8 +119,36 @@ class SaleAudit < ApplicationRecord
end
private
def generate_custom_id
self.sale_audit_id = SeedGenerator.generate_id(self.class.name, "SAI")
def self.getCardBalanceAmount(sale_id)
card_balance_amount = 0
sale_audits = SaleAudit.where("sale_id='#{sale_id}' AND action='PAYMAL'")
if !sale_audits.nil?
sale_audits.each do |sale_audit|
if sale_audit.remark.split('}')[0]
if self.valid_json('['+ sale_audit.remark.split('}')[0] + '}]')
remark = JSON.parse(('['+ sale_audit.remark.split('}')[0] + '}]'))
if remark[0]
if remark[0]["status"]
card_balance_amount = remark[0]["card_balance_amount"]
end
end
end
end
end
end
return card_balance_amount
end
def self.valid_json(json)
JSON.parse(json)
return true
rescue JSON::ParserError => e
return false
end
private
def generate_custom_id
self.sale_audit_id = SeedGenerator.generate_id(self.class.name, "SAI")
end
end

View File

@@ -169,14 +169,15 @@ class SalePayment < ApplicationRecord
end
def self.redeem(paypar_url,token,membership_id,received_amount,sale_id)
membership_actions_data = MembershipAction.find_by_membership_type("redeem");
# membership_actions_data = MembershipAction.find_by_membership_type("redeem");
membership_actions_data = PaymentMethodSetting.find_by_payment_method("Redeem")
if !membership_actions_data.nil?
url = paypar_url.to_s + membership_actions_data.gateway_url.to_s
merchant_uid = membership_actions_data.merchant_account_id
auth_token = membership_actions_data.auth_token
campaign_type_id = membership_actions_data.additional_parameter["campaign_type_id"]
campaign_type_id = membership_actions_data.additional_parameters["campaign_type_id"]
sale_data = Sale.find_by_sale_id(sale_id)
if sale_data
@@ -227,8 +228,9 @@ class SalePayment < ApplicationRecord
end
def self.create_payment(paypar_url,token,membership_id,received_amount,sale_id)
membership_actions_data = MembershipAction.find_by_membership_type("create_payment");
def self.create_payment(paypar_url,payment_type,membership_id,received_amount,sale_id)
# membership_actions_data = MembershipAction.find_by_membership_type("create_payment");
membership_actions_data = PaymentMethodSetting.find_by_payment_method(payment_type)
sale_data = Sale.find_by_sale_id(sale_id)
customer_data = Customer.find_by_customer_id(sale_data.customer_id)
if !membership_actions_data.nil?
@@ -236,7 +238,6 @@ class SalePayment < ApplicationRecord
url = paypar_url.to_s + membership_actions_data.gateway_url.to_s
merchant_uid = membership_actions_data.merchant_account_id
auth_token = membership_actions_data.auth_token
if sale_data
others = 0
@@ -260,7 +261,7 @@ class SalePayment < ApplicationRecord
auth_token:auth_token}.to_json
end
puts params
# Control for Paypar Cloud
begin
response = HTTParty.post(url,
@@ -457,7 +458,7 @@ class SalePayment < ApplicationRecord
# account_no = customer_data.membership_id
# end
membership_setting = MembershipSetting.find_by_membership_type("paypar_url")
membership_data = SalePayment.create_payment(membership_setting.gateway_url,membership_setting.auth_token,account_no,self.received_amount,self.sale.sale_id)
membership_data = SalePayment.create_payment(membership_setting.gateway_url,"PAYMAL",account_no,self.received_amount,self.sale.sale_id)
#record an payment in sale-audit
remark = "#{membership_data} PayMal Payment- for Customer #{self.sale.customer_id} Sale Id [#{self.sale.sale_id}]| pay amount -> #{self.received_amount} "
@@ -507,7 +508,7 @@ class SalePayment < ApplicationRecord
# end
membership_setting = MembershipSetting.find_by_membership_type("paypar_url")
membership_data = SalePayment.create_payment(membership_setting.gateway_url,membership_setting.auth_token,account_no,self.received_amount,self.sale.sale_id)
membership_data = SalePayment.create_payment(membership_setting.gateway_url,"DINGA",account_no,self.received_amount,self.sale.sale_id)
#record an payment in sale-audit
remark = "#{membership_data} Dinga Payment- for Customer #{self.sale.customer_id} Sale Id [#{self.sale.sale_id}]| pay amount -> #{self.received_amount} "
@@ -876,8 +877,10 @@ class SalePayment < ApplicationRecord
.joins("INNER JOIN customers c ON c.customer_id = s.customer_id")
.joins("INNER JOIN sale_orders so ON so.sale_id = s.sale_id")
.joins("INNER JOIN orders o ON o.order_id = so.order_id")
if params[:type] == "cashier"
if params[:type].nil?
query = query.where("(CASE WHEN (s.grand_total + s.amount_changed)=(select SUM(payment_amount) FROM sale_payments WHERE sale_id=s.sale_id AND payment_method!='creditnote') THEN NULL ELSE payment_method='creditnote' END) and s.sale_status = 'completed' and s.payment_status='paid' #{receipt_no} #{customer}")
elsif params[:type] == "cashier"
query = query.where("(CASE WHEN (s.grand_total + s.amount_changed)=(select SUM(payment_amount) FROM sale_payments WHERE sale_id=s.sale_id AND payment_method!='creditnote') THEN NULL ELSE payment_method='creditnote' AND o.source='#{params[:type]}' OR o.source='emenu' END) and s.sale_status = 'completed' and s.payment_status='paid' #{receipt_no} #{customer}")
else
query = query.where("(CASE WHEN (s.grand_total + s.amount_changed)=(select SUM(payment_amount) FROM sale_payments WHERE sale_id=s.sale_id AND payment_method!='creditnote') THEN NULL ELSE payment_method='creditnote' AND o.source='#{params[:type]}' END) and s.sale_status = 'completed' and s.payment_status='paid' #{receipt_no} #{customer}")

View File

@@ -43,4 +43,19 @@ class StockCheckItem < ApplicationRecord
end
transaction
end
def self.get_items_with_category(id)
query = StockCheckItem.select("stock_check_items.*,acc.title as account_name,
mi.name as item_name,
mii.item_instance_name as instance_name," +
"mc.name as menu_category_name,mc.id as menu_category_id ")
.joins("JOIN menu_item_instances mii ON mii.item_instance_code = stock_check_items.item_code" +
" JOIN menu_items mi ON mi.id = mii.menu_item_id" +
" JOIN menu_categories mc ON mc.id = mi.menu_category_id ")
.joins(" JOIN accounts acc ON acc.id = mi.account_id")
.where("stock_check_items.stock_check_id=#{id}")
.group("mi.menu_category_id,stock_check_items.item_code")
.order("acc.title desc,mi.menu_category_id desc")
return query
end
end

View File

@@ -52,6 +52,15 @@ class OrderItemCustomisePdf < Prawn::Document
# Write Order Information to PDF
def order_info(order_no, order_by, order_at)
#booking ID
booking_id = get_booking_id(order_no)
y_position = cursor
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
text "Booking: #{booking_id}", :size => self.item_font_size,:align => :left
end
move_down 1
y_position = cursor
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
text "OrderNo: #{order_no} ", :size => self.order_no_font_size,:align => :left
@@ -142,4 +151,12 @@ class OrderItemCustomisePdf < Prawn::Document
end
end
def get_booking_id(order_no)
booking = Booking.joins(" JOIN booking_orders bo ON bo.booking_id = bookings.booking_id")
.joins(" JOIN orders o ON o.order_id=bo.order_id")
.where("o.order_id='#{order_no}'")
.first()
return booking.booking_id
end
end

View File

@@ -50,7 +50,16 @@ class OrderItemPdf < Prawn::Document
end
# Write Order Information to PDF
def order_info(order_no, order_by, order_at)
def order_info(order_no, order_by, order_at)
#booking ID
booking_id = get_booking_id(order_no)
y_position = cursor
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
text "Booking: #{booking_id}", :size => self.item_font_size,:align => :left
end
move_down 2
y_position = cursor
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
text "OrderNo: #{order_no}", :size => self.item_font_size,:align => :left
@@ -141,4 +150,12 @@ class OrderItemPdf < Prawn::Document
end
end
def get_booking_id(order_no)
booking = Order.joins(" JOIN booking_orders bo ON bo.order_id = orders.order_id")
.joins(" JOIN bookings b ON b.booking_id=bo.booking_id")
.where("orders.order_id='#{order_no}'")
.first()
return booking.booking_id
end
end

View File

@@ -52,6 +52,15 @@ class OrderItemSlimCustomisePdf < Prawn::Document
# Write Order Information to PDF
def order_info(order_no, order_by, order_at)
#booking ID
booking_id = get_booking_id(order_no)
y_position = cursor
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
text "Booking: #{booking_id}", :size => self.item_font_size,:align => :left
end
move_down 1
y_position = cursor
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
text "OrderNo: #{order_no} ", :size => self.item_slim_font_size,:align => :left
@@ -141,4 +150,13 @@ class OrderItemSlimCustomisePdf < Prawn::Document
end
end
end
def get_booking_id(order_no)
booking = Booking.joins(" JOIN booking_orders bo ON bo.booking_id = bookings.booking_id")
.joins(" JOIN orders o ON o.order_id=bo.order_id")
.where("o.order_id='#{order_no}'")
.first()
return booking.booking_id
end
end

View File

@@ -51,6 +51,15 @@ class OrderItemSlimPdf < Prawn::Document
# Write Order Information to PDF
def order_info(order_no, order_by, order_at)
#booking ID
booking_id = get_booking_id(order_no)
y_position = cursor
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
text "Booking: #{booking_id}", :size => self.item_font_size,:align => :left
end
move_down 1
y_position = cursor
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
text "OrderNo: #{order_no} ", :size => self.item_font_size,:align => :left
@@ -140,4 +149,13 @@ class OrderItemSlimPdf < Prawn::Document
end
end
def get_booking_id(order_no)
booking = Booking.joins(" JOIN booking_orders bo ON bo.booking_id = bookings.booking_id")
.joins(" JOIN orders o ON o.order_id=bo.order_id")
.where("o.order_id='#{order_no}'")
.first()
return booking.booking_id
end
end

View File

@@ -51,6 +51,15 @@ class OrderSetItemCustomisePdf < Prawn::Document
# Write Order Information to PDF
def order_info(order_no, order_by, order_at)
#booking ID
booking_id = get_booking_id(order_no)
y_position = cursor
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
text "Booking: #{booking_id}", :size => self.item_font_size,:align => :left
end
move_down 1
y_position = cursor
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
text "OrderNo: #{order_no} ", :size => self.order_no_font_size,:align => :left
@@ -157,4 +166,13 @@ class OrderSetItemCustomisePdf < Prawn::Document
end
end
def get_booking_id(order_no)
booking = Booking.joins(" JOIN booking_orders bo ON bo.booking_id = bookings.booking_id")
.joins(" JOIN orders o ON o.order_id=bo.order_id")
.where("o.order_id='#{order_no}'")
.first()
return booking.booking_id
end
end

View File

@@ -50,6 +50,15 @@ class OrderSetItemPdf < Prawn::Document
# Write Order Information to PDF
def order_info(order_no, order_by, order_at)
#booking ID
booking_id = get_booking_id(order_no)
y_position = cursor
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
text "Booking: #{booking_id}", :size => self.item_font_size,:align => :left
end
move_down 2
y_position = cursor
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
text "OrderNo: #{order_no} ", :size => self.item_font_size,:align => :left
@@ -143,17 +152,26 @@ class OrderSetItemPdf < Prawn::Document
end
#add updated qty text
def add_updated_qty_text(before_updated_qty, updated_qty, precision)
if before_updated_qty.to_i > 0 && !before_updated_qty.nil?
move_down 5
#add updated qty text
def add_updated_qty_text(before_updated_qty, updated_qty, precision)
if before_updated_qty.to_i > 0 && !before_updated_qty.nil?
move_down 5
# add option
y_position = cursor
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
text "* Change quantity [#{number_with_precision(before_updated_qty.to_i, :precision => precision.to_i)}] to [#{number_with_precision(updated_qty.to_i, :precision => precision.to_i)}]", :size => self.item_font_size,:align => :left
# add option
y_position = cursor
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
text "* Change quantity [#{number_with_precision(before_updated_qty.to_i, :precision => precision.to_i)}] to [#{number_with_precision(updated_qty.to_i, :precision => precision.to_i)}]", :size => self.item_font_size,:align => :left
end
end
end
end
def get_booking_id(order_no)
booking = Booking.joins(" JOIN booking_orders bo ON bo.booking_id = bookings.booking_id")
.joins(" JOIN orders o ON o.order_id=bo.order_id")
.where("o.order_id='#{order_no}'")
.first()
return booking.booking_id
end
end

View File

@@ -55,7 +55,16 @@ class OrderSummaryCustomisePdf < Prawn::Document
end
# Write Order Information to PDF
def order_info(order_no, order_by, order_at)
def order_info(order_no, order_by, order_at)
#booking ID
booking_id = get_booking_id(order_no)
y_position = cursor
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
text "Booking: #{booking_id}", :size => self.item_font_size,:align => :left
end
move_down 1
y_position = cursor
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
text "OrderNo: #{order_no} ", :size => self.order_no_font_size,:align => :left
@@ -144,4 +153,13 @@ class OrderSummaryCustomisePdf < Prawn::Document
# end
end
end
def get_booking_id(order_no)
booking = Booking.joins(" JOIN booking_orders bo ON bo.booking_id = bookings.booking_id")
.joins(" JOIN orders o ON o.order_id=bo.order_id")
.where("o.order_id='#{order_no}'")
.first()
return booking.booking_id
end
end

View File

@@ -54,7 +54,16 @@ class OrderSummaryPdf < Prawn::Document
end
# Write Order Information to PDF
def order_info(order_no, order_by, order_at)
def order_info(order_no, order_by, order_at)
#booking ID
booking_id = get_booking_id(order_no)
y_position = cursor
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
text "Booking: #{booking_id}", :size => self.item_font_size,:align => :left
end
move_down 5
y_position = cursor
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
text "OrderNo: #{order_no} ", :size => self.item_font_size,:align => :left
@@ -154,4 +163,13 @@ class OrderSummaryPdf < Prawn::Document
# end
end
end
def get_booking_id(order_no)
booking = Booking.joins(" JOIN booking_orders bo ON bo.booking_id = bookings.booking_id")
.joins(" JOIN orders o ON o.order_id=bo.order_id")
.where("o.order_id='#{order_no}'")
.first()
return booking.booking_id
end
end

View File

@@ -55,6 +55,15 @@ class OrderSummarySetCustomisePdf < Prawn::Document
# Write Order Information to PDF
def order_info(order_no, order_by, order_at)
#booking ID
booking_id = get_booking_id(order_no)
y_position = cursor
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
text "Booking: #{booking_id}", :size => self.item_font_size,:align => :left
end
move_down 1
y_position = cursor
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
text "OrderNo: #{order_no} ", :size => self.order_no_font_size,:align => :left
@@ -159,4 +168,13 @@ class OrderSummarySetCustomisePdf < Prawn::Document
# end
end
end
def get_booking_id(order_no)
booking = Booking.joins(" JOIN booking_orders bo ON bo.booking_id = bookings.booking_id")
.joins(" JOIN orders o ON o.order_id=bo.order_id")
.where("o.order_id='#{order_no}'")
.first()
return booking.booking_id
end
end

View File

@@ -54,6 +54,15 @@ class OrderSummarySetPdf < Prawn::Document
# Write Order Information to PDF
def order_info(order_no, order_by, order_at)
#booking ID
booking_id = get_booking_id(order_no)
y_position = cursor
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
text "Booking: #{booking_id}", :size => self.item_font_size,:align => :left
end
move_down 5
y_position = cursor
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
text "OrderNo: #{order_no} ", :size => self.item_font_size,:align => :left
@@ -169,4 +178,13 @@ class OrderSummarySetPdf < Prawn::Document
# end
end
end
def get_booking_id(order_no)
booking = Booking.joins(" JOIN booking_orders bo ON bo.booking_id = bookings.booking_id")
.joins(" JOIN orders o ON o.order_id=bo.order_id")
.where("o.order_id='#{order_no}'")
.first()
return booking.booking_id
end
end

View File

@@ -54,7 +54,16 @@ class OrderSummarySlimCustomisePdf < Prawn::Document
end
# Write Order Information to PDF
def order_info(order_no, order_by, order_at)
def order_info(order_no, order_by, order_at)
#booking ID
booking_id = get_booking_id(order_no)
y_position = cursor
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
text "Booking: #{booking_id}", :size => self.item_font_size,:align => :left
end
move_down 1
y_position = cursor
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
text "OrderNo: #{order_no} ", :size => self.item_slim_font_size,:align => :left
@@ -145,4 +154,13 @@ class OrderSummarySlimCustomisePdf < Prawn::Document
# end
end
end
def get_booking_id(order_no)
booking = Booking.joins(" JOIN booking_orders bo ON bo.booking_id = bookings.booking_id")
.joins(" JOIN orders o ON o.order_id=bo.order_id")
.where("o.order_id='#{order_no}'")
.first()
return booking.booking_id
end
end

View File

@@ -54,6 +54,15 @@ class OrderSummarySlimPdf < Prawn::Document
# Write Order Information to PDF
def order_info(order_no, order_by, order_at)
#booking ID
booking_id = get_booking_id(order_no)
y_position = cursor
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
text "Booking: #{booking_id}", :size => self.item_font_size,:align => :left
end
move_down 1
y_position = cursor
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
text "OrderNo: #{order_no} ", :size => self.item_font_size,:align => :left
@@ -152,4 +161,13 @@ class OrderSummarySlimPdf < Prawn::Document
# end
end
end
def get_booking_id(order_no)
booking = Booking.joins(" JOIN booking_orders bo ON bo.booking_id = bookings.booking_id")
.joins(" JOIN orders o ON o.order_id=bo.order_id")
.where("o.order_id='#{order_no}'")
.first()
return booking.booking_id
end
end

View File

@@ -2,7 +2,7 @@ class ReceiptBillA5Pdf < Prawn::Document
include ActionView::Helpers::NumberHelper
attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width, :description_width, :price_num_width, :line_move
def initialize(printer_settings, sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info = nil,rebate_amount = nil,shop_details, printed_status,current_balance,card_data,other_charges_amount,latest_order_no)
def initialize(printer_settings, sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info = nil,rebate_amount = nil,shop_details, printed_status,current_balance,card_data,other_charges_amount,latest_order_no,card_balance_amount)
self.page_width = printer_settings.page_width
self.page_height = printer_settings.page_height
self.header_font_size = printer_settings.header_font_size.to_i
@@ -72,7 +72,12 @@ class ReceiptBillA5Pdf < Prawn::Document
card_sale_data(card_data)
end
#end card sale trans data
#start card blanace amount
if !card_balance_amount.nil?
card_balance_data(card_balance_amount)
end
#end card blanace amount
if discount_price_by_accounts.length > 0 && shop_details.show_account_info
discount_account(discount_price_by_accounts,printer_settings.precision,delimiter)
end
@@ -113,12 +118,17 @@ class ReceiptBillA5Pdf < Prawn::Document
end
def cashier_info(sale_data, customer_name, latest_order_no)
move_down line_move
text "Booking : #{ sale_data.bookings[0].booking_id }", :size => self.header_font_size+5,:align => :left
move_down line_move
move_down line_move
if !latest_order_no.nil?
move_down line_move
text "OrderNo : #{ latest_order_no }", :size => self.header_font_size,:align => :left
text "OrderNo : #{ latest_order_no }", :size => self.header_font_size+2,:align => :left
end
move_down line_move
# move_down 2
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do
@@ -707,6 +717,23 @@ class ReceiptBillA5Pdf < Prawn::Document
end
end
#start card balance data
def card_balance_data(card_balance_amount)
if card_balance_amount > 0
move_down line_move
stroke_horizontal_rule
move_down line_move
y_position = cursor
bounding_box([0, y_position], :width =>self.label_width) do
text "Card Balance: ",:style => :bold, :size => header_font_size,:align => :left
end
bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
text "#{card_balance_amount}" , :size => self.item_font_size,:align => :right
end
end
end
#check ReceiptBillAltName included
def show_alt_name
bill_alt_name = Lookup.collection_of("print_settings") #print_settings with name:ReceiptBillA5Pdf

View File

@@ -3,7 +3,7 @@ class ReceiptBillPdf < Prawn::Document
attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width, :description_width, :price_num_width, :line_move
def initialize(printer_settings, sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info = nil,rebate_amount = nil,shop_details, printed_status,current_balance,card_data,other_charges_amount,latest_order_no)
def initialize(printer_settings, sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info = nil,rebate_amount = nil,shop_details, printed_status,current_balance,card_data,other_charges_amount,latest_order_no,card_balance_amount)
self.page_width = printer_settings.page_width
self.page_height = printer_settings.page_height
self.header_font_size = printer_settings.header_font_size.to_i
@@ -73,6 +73,11 @@ class ReceiptBillPdf < Prawn::Document
card_sale_data(card_data)
end
#end card sale trans data
#start card blanace amount
if !card_balance_amount.nil?
card_balance_data(card_balance_amount)
end
#end card blanace amount
if discount_price_by_accounts.length > 0 && shop_details.show_account_info
discount_account(discount_price_by_accounts,printer_settings.precision,delimiter)
@@ -113,12 +118,17 @@ class ReceiptBillPdf < Prawn::Document
end
def cashier_info(sale_data, customer_name, latest_order_no)
move_down line_move
text "Booking : #{ sale_data.bookings[0].booking_id }", :size => self.header_font_size+2,:align => :left
move_down line_move
move_down line_move
if !latest_order_no.nil?
move_down line_move
text "OrderNo : #{ latest_order_no }", :size => self.header_font_size,:align => :left
text "OrderNo : #{ latest_order_no }", :size => self.header_font_size+2,:align => :left
end
move_down line_move
# move_down 2
y_position = cursor
bounding_box([0,y_position], :width =>self.description_width + self.price_num_width, :height => self.item_height) do
@@ -509,9 +519,9 @@ class ReceiptBillPdf < Prawn::Document
bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do
text "Total Balance", :size => self.item_font_size,:align => :left
end
bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
text "#{number_with_precision(total_balance, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
text "#{number_with_precision(total_balance, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right
end
end
end
@@ -707,6 +717,23 @@ class ReceiptBillPdf < Prawn::Document
end
end
#start card balance data
def card_balance_data(card_balance_amount)
if card_balance_amount > 0
move_down line_move
stroke_horizontal_rule
move_down line_move
y_position = cursor
bounding_box([0, y_position], :width =>self.label_width) do
text "Card Balance: ",:style => :bold, :size => header_font_size,:align => :left
end
bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
text "#{card_balance_amount}" , :size => self.item_font_size,:align => :right
end
end
end
#check ReceiptBillAltName included
def show_alt_name
bill_alt_name = Lookup.collection_of("print_settings") #print_settings with name:ReceiptBillA5Pdf

View File

@@ -20,10 +20,10 @@ class CommissionerImageUploader < CarrierWave::Uploader::Base
end
def filename
if Shop.find(1).shop_code.nil?
if Shop.first.shop_code.nil?
"#{original_filename}" if original_filename.present?
else
"#{Shop.find(1).shop_code}_#{original_filename}" if original_filename.present?
"#{Shop.first.shop_code}_#{original_filename}" if original_filename.present?
end
end

View File

@@ -20,10 +20,10 @@ class CustomerImageUploader < CarrierWave::Uploader::Base
end
def filename
if Shop.find(1).shop_code.nil?
if Shop.first.shop_code.nil?
"#{original_filename}" if original_filename.present?
else
"#{Shop.find(1).shop_code}_#{original_filename}" if original_filename.present?
"#{Shop.first.shop_code}_#{original_filename}" if original_filename.present?
end
end

View File

@@ -20,10 +20,10 @@ class EmployeeImageUploader < CarrierWave::Uploader::Base
end
def filename
if Shop.find(1).shop_code.nil?
if Shop.first.shop_code.nil?
"#{original_filename}" if original_filename.present?
else
"#{Shop.find(1).shop_code}_#{original_filename}" if original_filename.present?
"#{Shop.first.shop_code}_#{original_filename}" if original_filename.present?
end
end

View File

@@ -15,15 +15,15 @@ class MenuItemImageUploader < CarrierWave::Uploader::Base
# Override the directory where uploaded files will be stored.
# This is a sensible default for uploaders that are meant to be mounted:
def store_dir
"image/menu_images/#{Shop.find(1).shop_code}"
"image/menu_images/#{current_shop.shop_code}"
# "uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
end
def filename
if Shop.find(1).shop_code.nil?
if Shop.first.shop_code.nil?
"#{original_filename}" if original_filename.present?
else
"#{Shop.find(1).shop_code}_#{original_filename}" if original_filename.present?
"#{Shop.first.shop_code}_#{original_filename}" if original_filename.present?
end
end

View File

@@ -20,10 +20,10 @@ class ProductImageUploader < CarrierWave::Uploader::Base
end
def filename
if Shop.find(1).shop_code.nil?
if Shop.first.shop_code.nil?
"#{original_filename}" if original_filename.present?
else
"#{Shop.find(1).shop_code}_#{original_filename}" if original_filename.present?
"#{Shop.first.shop_code}_#{original_filename}" if original_filename.present?
end
end

View File

@@ -20,10 +20,10 @@ class ShopImageUploader < CarrierWave::Uploader::Base
end
def filename
if Shop.find(1).shop_code.nil?
if Shop.first.shop_code.nil?
"#{original_filename}" if original_filename.present?
else
"#{Shop.find(1).shop_code}_#{original_filename}" if original_filename.present?
"#{Shop.first.shop_code}_#{original_filename}" if original_filename.present?
end
end

View File

@@ -1,6 +1,7 @@
json.id menu.id
json.name menu.name
json.is_active menu.is_active
json.is_ordering menu.is_ordering
json.valid_time_from menu.valid_time_from.strftime("%H:%M")
json.valid_time_to menu.valid_time_to.strftime("%H:%M")

View File

@@ -1,6 +1,8 @@
menu_json = json.array! @menus do |menu|
json.id menu.id
json.name menu.name
json.is_active menu.is_active
json.is_ordering menu.is_ordering
json.valid_days menu.valid_days
json.valid_time_from menu.valid_time_from.strftime("%H:%M")
json.valid_time_to menu.valid_time_to.strftime("%H:%M")

View File

@@ -1,163 +1,225 @@
<section>
<div class="wizard">
<div class="wizard-inner">
<div class="active-line"></div>
<ul class="nav nav-tabs" role="tablist">
<li role="presentation" class="nav-item">
<div class="connecting-line border-right"></div>
<a href="#step1" class="nav-link active" data-toggle="tab" aria-controls="step1" role="tab" title="Step 1">
<span class="round-tab">
1
</span>
</a>
</li>
<li role="presentation" class="nav-item disabled">
<div class="connecting-line"></div>
<a href="#complete" class="nav-link disable" data-toggle="tab" aria-controls="complete" role="tab" title="Complete">
<span class="round-tab">
2
</span>
</a>
</li>
</ul>
</div>
<%= simple_form_for @crm_customer,:url => crm_customers_path, :method => :post do |f| %>
<span class="patch_method"></span>
<%= f.hidden_field :id, :class => "form-control " %>
<div class="tab-content">
<div class="tab-pane active" role="tabpanel" id="step1">
<!-- <h4>Step 1</h4> -->
<div class="form-group">
<div class="col-sm-12 col-md-12 col-lg-12">
<label><%= t("views.right_panel.detail.sr_no") %></label>
<div class="form-line disabled">
<input type="text" name="" value="<%=@count_customer%>" class="form-control" disabled="" >
</div>
</div>
</div>
<%= simple_form_for @crm_customer,:url => crm_customers_path, :method => :post do |f| %>
<span class="patch_method"></span>
<%= f.hidden_field :id, :class => "form-control " %>
<div class="form-group">
<div class="col-sm-12 col-md-12 col-lg-12">
<label for="customer[salutation]" class="control-label"> <%= t("views.right_panel.detail.salutation") %> :</label><br>
<label class="font-12 radio-inline">
<%= f.radio_button :salutation,"Mr", :class => "salutation mr with-gap radio-col-indigo", :value=>"Mr"%><%= t("views.right_panel.detail.mr") %>
</label>&nbsp;
<label class="font-12 radio-inline">
<%= f.radio_button :salutation,"Mrs", :class => "salutation mrs with-gap radio-col-indigo", :value=>"Mrs"%><%= t("views.right_panel.detail.miss") %>
</label>&nbsp;
<label class="font-12 radio-inline">
<%= f.radio_button :salutation,"Miss", :class => "salutation miss with-gap radio-col-indigo", :value=>"Miss"%><%= t("views.right_panel.detail.mrs") %>
</label>&nbsp;
<label class="font-12 radio-inline">
<%= f.radio_button :salutation,"Mdm", :class => "salutation mdm with-gap radio-col-indigo", :value=>"Mdm"%><%= t("views.right_panel.detail.mdm") %>
</label>
</div>
</div>
<div class="form-group <%= (flash["errors"]) ? "error" : "" %>">
<div class="col-sm-12 col-md-12 col-lg-12">
<%= f.input :name, :class => "form-control name", :required => true %>
<% flash.each do |test, msg| %>
<%
str="[\"#{msg['name']}\"]"
str.gsub!('["', '')
str.gsub!('"]', '') %>
<lable class="error col-red m-t--10" style="margin-top:-6px"><%= str %></lable>
<% end -%>
</div>
</div>
<div class="form-group <%= (flash["errors"]) ? "error" : "" %>">
<div class="col-sm-12 col-md-12 col-lg-12">
<%= f.input :contact_no, :class => "form-control contact_no" ,:required => true%>
<div class="form-group">
<label> <%= t("views.right_panel.detail.salutation") %> :</label><br>
<label class="font-15"><%= t("views.right_panel.detail.mr") %>
<%= f.radio_button :salutation,"Mr", :class => "salutation mr with-gap radio-col-indigo", :value=>"Mr", :style=>"width: 30px"%>
</label>&nbsp;
<label class="font-15"><%= t("views.right_panel.detail.miss") %>
<%= f.radio_button :salutation,"Mrs", :class => "salutation mrs with-gap radio-col-indigo", :value=>"Mrs", :style=>"width: 30px"%>
</label>&nbsp;
<label class="font-15"><%= t("views.right_panel.detail.mrs") %>
<%= f.radio_button :salutation,"Miss", :class => "salutation miss with-gap radio-col-indigo", :value=>"Miss", :style=>"width: 30px"%>
</label>&nbsp;
<label class="font-15">
<%= t("views.right_panel.detail.mdm") %>
<%= f.radio_button :salutation,"Mdm", :class => "salutation mdm with-gap radio-col-indigo", :value=>"Mdm", :style=>"width: 30px"%>
</label>
</div>
<% flash.each do |name, msg| %>
<% str="[\"#{msg['contact_no']}\"]"
str.gsub!('["', '')
str.gsub!('"]', '') %>
<lable class="error col-red m-t-10" style="margin-top:-6px"><%= str %></lable>
<% end %>
</div>
</div>
<div class="form-group <%= (flash["errors"]) ? "error" : "" %>">
<%= f.input :name, :class => "form-control col-md-6 name", :required => true %>
<% flash.each do |test, msg| %>
<%
str="[\"#{msg['name']}\"]"
str.gsub!('["', '')
str.gsub!('"]', '') %>
<lable class="error col-red m-t--10" style="margin-top:-6px"><%= str %></lable>
<% end -%>
</div>
<div class="form-group <%= (flash["errors"]) ? "error" : "" %>">
<div class="col-sm-12 col-md-12 col-lg-12">
<%= f.input :email, :class => "form-control email" ,:required => true%>
<div class="form-group">
<label><%= t("views.right_panel.detail.gender") %> :</label><br>
<label><%= t("views.right_panel.detail.male") %>
<%= f.radio_button :gender,"Male", :class => "gender male", :value=>"Male", :style=>"width: 30px"%></label>
<label><%= t("views.right_panel.detail.female") %>
<%= f.radio_button :gender,"Female", :class => "gender female", :value=>"Female", :style=>"width: 30px"%></label>
</div>
<% flash.each do |name, msg| %>
<% str="[\"#{msg['email']}\"]"
str.gsub!('["', '')
str.gsub!('"]', '') %>
<lable class="error col-red m-t-10" style="margin-top:-6px"><%= str %></lable>
<% end %>
</div>
</div>
<div class="form-group">
<%= f.input :nrc_no,:label => "NRC No", :class => "form-control nrc_no" %>
</div>
<div class="form-group">
<div class="col-sm-12 col-md-12 col-lg-12" align="right">
<button type="button" class="btn btn-md bg-blue btn-info-full next-step">Next</button>
</div>
</div>
</div>
<div class="tab-pane" role="tabpanel" id="complete">
<!-- <h4>Step 2</h4> -->
<div class="form-group">
<div class="col-sm-12 col-md-12 col-lg-12">
<label><%= t("views.right_panel.detail.customer_photo") %></label>
<div class="panel padding-10">
<div class="menu-item-img">
<% if f.object.image_path? %>
<p><%= f.object.name %></p>
<%= image_tag f.object.image_path.url, :class => "img-thumbnail" %>
<% else %>
<%= image_tag "/image/menu_images/default.png", :class => "img-thumbnail" %>
<% end %>
</div>
<%= f.file_field :image_path, :class => "img-thumbnail" %>
</div>
</div>
</div>
<div class="form-group">
<div class="col-sm-12 col-md-12 col-lg-12">
<label for="customer[gender]" class="control-label"><%= t("views.right_panel.detail.gender") %> :</label><br>
<label class="font-12 radio-inline">
<%= f.radio_button :gender,"Male", :class => "gender male", :value=>"Male"%><%= t("views.right_panel.detail.male") %></label>
<label class="font-12 radio-inline">
<%= f.radio_button :gender,"Female", :class => "gender female", :value=>"Female"%><%= t("views.right_panel.detail.female") %></label>
</div>
</div>
<div class="form-group">
<div class="col-sm-12 col-md-12 col-lg-12">
<%= f.input :nrc_no,:label => "NRC No", :class => "form-control nrc_no" %>
</div>
</div>
<div class="form-group">
<div class="col-sm-12 col-md-12 col-lg-12">
<%= f.input :company, :class => "form-control col-md-6 company"%>
<div class="form-group">
<%= f.input :company, :class => "form-control col-md-6 company"%>
<% flash.each do |name, msg| %>
<% str="[\"#{msg['company']}\"]"
str.gsub!('["', '')
str.gsub!('"]', '') %>
<lable class="error col-red m-t-10" style="margin-top:-6px"><%= str %></lable>
<% end -%>
</div>
</div>
<div class="form-group">
<div class="col-sm-12 col-md-12 col-lg-12">
<label class="control-label"><%= t("views.right_panel.detail.date_of_birth") %></label>
<%= f.text_field :date_of_birth, :value=>"01-01-1990",:class=>"datepicker form-control col-md-12"%>
</div>
</div>
<div class="form-group">
<div class="col-sm-12 col-md-12 col-lg-12">
<%= f.input :address, :class => "form-control address" %>
</div>
</div>
<div class="form-group">
<div class="col-sm-12 col-md-12 col-lg-12">
<label><%= t("views.right_panel.detail.select_customer_type") %></label>
<select class="form-control col-md-12 selectpicker show-tick" id="customer_type" name="customer[customer_type]" style="height: " >
<% Lookup.where("lookup_type = ?", "customer_type" ).each do |ct| %>
<option value="<%= ct.value %>">
<%= ct.name %></option>
<%end %>
</select>
</div>
</div>
<% flash.each do |name, msg| %>
<% str="[\"#{msg['company']}\"]"
str.gsub!('["', '')
str.gsub!('"]', '') %>
<lable class="error col-red m-t-10" style="margin-top:-6px"><%= str %></lable>
<% end -%>
</div>
<div class="form-group <%= (flash["errors"]) ? "error" : "" %>">
<%= f.input :contact_no, :class => "form-control col-md-6 contact_no" ,:required => true%>
<div class="form-group">
<div class="col-sm-12 col-md-12 col-lg-12">
<%= f.input :tax_profiles, :collection => @taxes, :input_html => { :multiple => true }, :class => "form-control tax_profiles" %>
</div>
</div>
<% flash.each do |name, msg| %>
<% str="[\"#{msg['contact_no']}\"]"
str.gsub!('["', '')
str.gsub!('"]', '') %>
<lable class="error col-red m-t-10" style="margin-top:-6px"><%= str %></lable>
<% end %>
</div>
<div class="form-group <%= (flash["errors"]) ? "error" : "" %>">
<div class="col-sm-12 col-md-12 col-lg-12">
<%= f.input :card_no, :class => "form-control card_no"%>
<% flash.each do |name, msg| %>
<% str="[\"#{msg['card_no']}\"]"
str.gsub!('["', '')
str.gsub!('"]', '') %>
<lable class="error col-red m-t-10" style="margin-top:-6px"><%= str %></lable>
<% end %>
</div>
</div>
<div class="form-group <%= (flash["errors"]) ? "error" : "" %>">
<%= f.input :email, :class => "form-control col-md-6 email" ,:required => true%>
<div class="form-group">
<div class="col-sm-12 col-md-12 col-lg-12">
<label class="control-label"><%= t("views.right_panel.detail.paypar_account_no") %>:</label>
<div class="-group">
<input type="text" class="form-control" id="paypar_account_no" name="customer[paypar_account_no]" readonly/>
<div class="input-group-addon"><span class="fa fa-credit-card"></span></div>
</div>
</div>
</div>
<% flash.each do |name, msg| %>
<% str="[\"#{msg['email']}\"]"
str.gsub!('["', '')
str.gsub!('"]', '') %>
<lable class="error col-red m-t-10" style="margin-top:-6px"><%= str %></lable>
<% end %>
</div>
<div class="form-group">
<%= f.input :address, :class => "form-control col-md-6 address" %>
</div>
<div class="form-group">
<label><%= t("views.right_panel.detail.sr_no") %></label>
<div class="form-line disabled">
<input type="text" name="" value="<%=@count_customer%>" class="form-control" disabled="" >
<div class="form-group">
<div class="col-sm-12 col-md-12 col-lg-12">
<label class="control-label"><%= t("views.right_panel.detail.select_membership_group") %></label>
<select class="form-control col-md-12 selectpicker show-tick" name="member_group_id" style="height: " >
<option value=""><%= t("views.right_panel.detail.select_membership_group") %></option>
<% Lookup.where("lookup_type = ?", "member_group_type" ).each do |member| %>
<option value="<%= member.value %>">
<%= member.name %></option>
<%end %>
</select>
</div>
</div>
<div class="form-group">
<div class="col-sm-12 col-md-12 col-lg-12" align="right">
<button type="button" class="btn btn-md bg-blue prev-step">Prev</button>
<!-- <%= f.submit "Submit",:class => 'btn btn-primary ', :id => 'submit_customer' %>
<%= f.submit "Update",:class => 'btn btn-info ', :disabled =>'', :id => 'update_customer' %> -->
<button type="submit" class="btn btn-primary" id="submit_customer"><%= t("views.btn.submit") %></button>
<button type="submit" class="btn btn-info" disabled id="update_customer"><%= t("views.btn.update") %></button>
<button type="button" class="btn btn-danger" id="reset"><%= t("views.btn.reset") %></button>
</div>
</div>
</div>
<div class="clearfix"></div>
</div>
<%end%>
</div>
</div>
<div class="form-group">
<label><%= t("views.right_panel.detail.date_of_birth") %></label>
<%= f.text_field :date_of_birth, :value=>"01-01-1990",:class=>"datepicker form-control col-md-12"%>
</div>
<div class="form-group">
<label><%= t("views.right_panel.detail.customer_photo") %></label>
<div class="panel padding-10">
<div class="menu-item-img">
<% if f.object.image_path? %>
<p><%= f.object.name %></p>
<%= image_tag f.object.image_path.url, :class => "img-thumbnail" %>
<% else %>
<%= image_tag "/image/menu_images/default.png", :class => "img-thumbnail" %>
<% end %>
</div>
<%= f.file_field :image_path, :class => "img-thumbnail" %>
</div>
</div>
<div class="form-group">
<label><%= t("views.right_panel.detail.select_customer_type") %></label>
<select class="form-control col-md-12 selectpicker show-tick" id="customer_type" name="customer[customer_type]" style="height: " >
<% Lookup.where("lookup_type = ?", "customer_type" ).each do |ct| %>
<option value="<%= ct.value %>">
<%= ct.name %></option>
<%end %>
</select>
</div>
<div class="form-group">
<%= f.input :tax_profiles, :collection => @taxes, :input_html => { :multiple => true }, :class => "form-control col-md-6 tax_profiles" %>
</div>
<div class="form-group <%= (flash["errors"]) ? "error" : "" %>">
<%= f.input :card_no, :class => "form-control col-md-6 card_no"%>
<% flash.each do |name, msg| %>
<% str="[\"#{msg['card_no']}\"]"
str.gsub!('["', '')
str.gsub!('"]', '') %>
<lable class="error col-red m-t-10" style="margin-top:-6px"><%= str %></lable>
<% end %>
</div>
<div class="form-group">
<label><%= t("views.right_panel.detail.paypar_account_no") %>:</label>
<div class="-group">
<input type="text" class="form-control" id="paypar_account_no" name="customer[paypar_account_no]" readonly/>
<div class="input-group-addon"><span class="fa fa-credit-card"></span></div>
</div>
</div>
<div class="form-group">
<label><%= t("views.right_panel.detail.select_membership_group") %></label>
<select class="form-control col-md-12 selectpicker show-tick" name="member_group_id" style="height: " >
<option value=""><%= t("views.right_panel.detail.select_membership_group") %></option>
<% Lookup.where("lookup_type = ?", "member_group_type" ).each do |member| %>
<option value="<%= member.value %>">
<%= member.name %></option>
<%end %>
</select>
</div>
<div class="form-group">
<!-- <%= f.submit "Submit",:class => 'btn btn-primary ', :id => 'submit_customer' %>
<%= f.submit "Update",:class => 'btn btn-info ', :disabled =>'', :id => 'update_customer' %> -->
<button type="submit" class="btn btn-primary" id="submit_customer"><%= t("views.btn.submit") %></button>
<button type="submit" class="btn btn-info" disabled id="update_customer"><%= t("views.btn.update") %></button>
<button type="button" class="btn btn-danger" id="reset"><%= t("views.btn.reset") %></button>
</div>
<%end%>
</section>
<div id="sxModal">

View File

@@ -1,38 +1,41 @@
<div class="page-header">
<!-- <div class="page-header">
<ul class="breadcrumb">
<li class="breadcrumb-item"><a href="<%= dashboard_path %>"><%= t("views.right_panel.button.home") %></a></li>
<li class="breadcrumb-item active"><%= t :crm %></li>
<li class="breadcrumb-item active"><%= t :crm %></li> -->
<!-- <li class="breadcrumb-item"><a href="<%= dashboard_path %>">Home</a></li> -->
<span class="float-right">
<!-- <span class="float-right">
<%= link_to 'Back', dashboard_path %>
</span>
</ul>
</div>
</div> -->
<div class="row clearfix">
<div class="<%= @create_flag ? 'col-lg-8 col-md-8 col-sm-8' : 'col-lg-12 col-md-12 col-sm-12' %>">
<div class="col-lg-12 col-md-12 col-sm-12">
<div class="card">
<div class="body">
<div class="row p-l-20 p-t-20">
<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
<%= form_tag crm_customers_path, :id => "filter_form", :method => :get do %>
<div class="row clearfix">
<div class="col-lg-5 col-md-5 col-sm-5 col-xs-12">
<input type="text" name="filter" style="margin-right:10px" placeholder="Search" id="search" class="form-control">
<input type="hidden" name="type" id="type" value="">
<div class="col-sm-5 col-md-5 col-lg-5">
<input type="text" name="filter" style="margin-right:10px" placeholder="Search" id="search" class="form-control">
<input type="hidden" name="type" id="type" value="">
</div>
<!-- <div class="col-lg-2 col-md-2 col-sm-2 col-xs-12"> -->
<button type="submit" class="btn btn-sm bg-blue waves-effect" style="height: 30%;margin-right: 10px;"><%= t("views.btn.search") %></button>
<div class="col-sm-4 col-md-4 col-lg-4">
<!-- <div class="col-lg-2 col-md-2 col-sm-2 col-xs-12"> -->
<button type="submit" class="btn btn-sm bg-blue waves-effect"><%= t("views.btn.search") %></button>
<!-- </div> -->
<button type="button" id="member_acc_no" class="btn bg-green btn-sm waves-effect" style="height: 30%;margin-right: 10px;"><%= t("views.btn.memeber_card") %></button>
<button type="button" id="qr_code" class="btn bg-green btn-sm waves-effect" style="height: 30%;margin-right: 10px;"><%= t("views.btn.qr_code") %></button>
<button type="button" id="member_acc_no" class="btn bg-green btn-sm waves-effect"><%= t("views.btn.memeber_card") %></button>
<button type="button" id="qr_code" class="btn bg-green btn-sm waves-effect"><%= t("views.btn.qr_code") %></button>
</div>
</div>
<% end %>
</div>
</div>
<div class="row">
<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
<div class="col-lg-8 col-md-8 col-sm-8 col-xs-8">
<%= paginate @crm_customers %>
<div class="table-responsive">
<table class="table table-hover table-striped" style="width:100%">
<!-- <div class="table-responsive">
@@ -50,11 +53,12 @@
<tr>
<th></th>
<th><%= t("views.right_panel.detail.sr_no") %></th>
<th><%= t :customer %> <%= t("views.right_panel.detail.type") %></th>
<th><%= t("views.right_panel.detail.name") %></th>
<th><%= t("views.right_panel.detail.card_no") %></th>
<th><%= t("views.right_panel.detail.membership_type") %></th>
<th style="width:20%"><%= t("views.right_panel.detail.contact_no") %></th>
<th style="width:20%"><%= t("views.right_panel.detail.email") %></th>
<th style="width:20%"><%= t("views.right_panel.detail.contact_no") %></th>
<th><%= t("views.right_panel.detail.membership_type") %></th>
<th><%= t("views.right_panel.detail.card_no") %></th>
<th><%= t("views.right_panel.detail.action") %></th>
</tr>
</thead>
@@ -74,8 +78,10 @@
-
<% end %>
</td>
<td><%= crm_customer.customer_type rescue '-' %></td>
<td><%= crm_customer.name %></td>
<td><%= crm_customer.card_no rescue '-' %></td>
<td style="width:20px%;word-break: break-all;"><%= crm_customer.email %></td>
<td style="width:20px%;word-break: break-all;"><%= crm_customer.contact_no %></td>
<td>
<% if !@membership_types.nil? %>
<% @membership_types.each do |member_type| %>
@@ -85,9 +91,10 @@
<% end %>
<% end %>
</td>
<td style="width:20px%;word-break: break-all;"><%= crm_customer.contact_no %></td>
<td style="width:20px%;word-break: break-all;"><%= crm_customer.email %></td>
<td><%= link_to t("views.btn.show"), crm_customer_path(crm_customer) %></td>
<td><%= crm_customer.card_no rescue '-' %></td>
<td>
<%= link_to t("views.btn.show"), crm_customer_path(crm_customer), :class => "btn btn-md bg-blue waves-effect" %>
</td>
</tr>
<% end %>
<% else %>
@@ -95,36 +102,24 @@
<% end %>
</tbody>
</table>
<br>
<%= paginate @crm_customers %>
</div>
</div>
</div>
<% if @create_flag %>
<div class="col-sm-4 col-md-4 col-lg-4">
<!-- .row-form-input -->
<%= render 'new_form', crm_customer: @crm_customer, taxes: @taxes %>
<!-- .row-form-input -->
</div>
<% end %>
</div> <!-- .end-of-row -->
</div>
</div>
</div>
<% if @create_flag %>
<div class="col-lg-4 col-md-4 col-sm-4">
<div class="card">
<div class="body" id="custom-slimscroll">
<%= render 'new_form', crm_customer: @crm_customer, taxes: @taxes %>
</div>
</div>
<!-- <div class="col-lg-1 col-md-1 col-sm-1 ">
<br>
<a href="<%= dashboard_path%>" class="btn btn-primary">
<i class="fa fa-arrow-left fa-lg"></i> Back
</a>
</div> -->
</div>
<% end %>
</div>
<script type="text/javascript">
$(function() {
$(document).ready(function () {
/*$('.datepicker').datepicker({
format : 'dd-mm-yyyy',
autoclose: true
@@ -163,91 +158,127 @@ $(function() {
$("#search").val(code);
}
});
/*new customer UI func:*/
//Initialize tooltips
$('.nav-tabs > li a[title]').tooltip();
//Wizard
$('a[data-toggle="tab"]').on('show.bs.tab', function (e) {
$(document).on('click',".customer_tr",function(){
// if(this.checked){
$(this).closest('tr').find('.checkbox_check').prop( "checked", true );
//$( "#checkbox_check" ).prop( "checked", true );
var sale_id = $("#sale_id").val() || 0;
var customer_id = $(this).attr('data-ref');
var $target = $(e.target);
if ($target.parent().hasClass('disabled')) {
return false;
}
});
if(sale_id != 0){
// var url = "/"+customer_id;
update_sale(customer_id,sale_id);
}else{
$(".next-step").click(function (e) {
var $active = $('.wizard .nav-tabs li a.active');
$active.parent().next().removeClass('disabled');
nextTab($active);
$('.wizard .nav-tabs li.active .connecting-line').css({"border-bottom-left-radius": 0, "border-top-left-radius": 0});
});
$(".prev-step").click(function (e) {
var url = "customers/" + customer_id + "/edit";
}
var $active = $('.wizard .nav-tabs li a.active');
prevTab($active);
$("#customer_tax_profiles").children().removeAttr("selected").css({'color':'#000','background':'none'});
});
/*new customer UI func:*/
});
$.ajax({
type: "GET",
url: url,
data: {},
dataType: "json",
success: function(data) {
// Selected for Taxes
var taxes = JSON.stringify(data.tax_profiles);
var parse_taxes = JSON.parse(taxes);
$.each(parse_taxes, function(i, value){
$("#customer_tax_profiles option[value='" + value + "']").attr("selected","selected").css({'color':'#fff','background':'#215d9c'});
});
/*customer UI tab btn*/
function nextTab(elem) {
$(elem).parent().next().find('a[data-toggle="tab"]').click();
}
function prevTab(elem) {
$(elem).parent().prev().find('a[data-toggle="tab"]').click();
}
/*customer UI tab btn*/
$('#customer_id').val(data.id);
$('#customer_name').val(data.name);
$('#customer_company').val(data.company);
$('#customer_contact_no').val(data.contact_no);
$('#customer_email').val(data.email);
$('#customer_salutation').val(data.salutation);
$('#customer_nrc_no').val(data.nrc_no);
$('#customer_card_no').val(data.card_no);
$('#customer_type').val(data.customer_type);
$('#paypar_account_no').val(data.paypar_account_no);
$('#customer_address').val(data.address);
$('#customer_date_of_birth').val(data.date_of_birth);
if(data.image_path.url!=undefined && data.image_path.url!=null){
$('.menu-item-img .img-thumbnail').attr('src',data.image_path.url);
}
$('#customer_membership_type').val(data.membership_type);
$('.selectpicker > option[value="'+data.membership_type+'"]').attr('selected','selected');
if (data.gender == 'Male') {
$('.male').prop( "checked", true )
}else{
$('.female').prop( "checked", true )
}
$(document).on('click',".customer_tr",function(){
// if(this.checked){
$(this).closest('tr').find('.checkbox_check').prop( "checked", true );
//$( "#checkbox_check" ).prop( "checked", true );
var sale_id = $("#sale_id").val() || 0;
var customer_id = $(this).attr('data-ref');
if(data.salutation == 'Mr') {
$('.mr').prop( "checked", true )
}else if(data.salutation == 'Miss') {
$('.miss').prop( "checked", true )
}else if(data.salutation == 'Mrs'){
$('.mrs').prop( "checked", true )
}else{
$('.mdm').prop( "checked", true )
}
if(sale_id != 0){
// var url = "/"+customer_id;
update_sale(customer_id,sale_id);
}else{
$('.membership_authentication_code').val(data.membership_authentication_code);
var url = "customers/" + customer_id + "/edit";
}
$('#update_customer').removeAttr('disabled').val('');
$('#update_customer').attr('value', 'Update');
$('#submit_customer').attr('disabled','disabled');
$("#customer_tax_profiles").children().removeAttr("selected").css({'color':'#000','background':'none'});
$("#new_customer").attr('class', 'simple_form edit_customer');
var id = "edit_customer_"+customer_id;
$("#new_customer").attr('id', id);
$.ajax({
type: "GET",
url: url,
data: {},
dataType: "json",
success: function(data) {
// Selected for Taxes
var taxes = JSON.stringify(data.tax_profiles);
var parse_taxes = JSON.parse(taxes);
$.each(parse_taxes, function(i, value){
$("#customer_tax_profiles option[value='" + value + "']").attr("selected","selected").css({'color':'#fff','background':'#215d9c'});
});
$(".edit_customer").attr('id', id);
$(".edit_customer").attr('action', '/crm/customers/' + $('#customer_id').val());
$(".edit_customer").attr('action', '/crm/customers/' + $('#customer_id').val());
$(".patch_method").html('<input type="hidden" name="_method" value="patch">');
//$(".edit_customer").attr('method', 'PATCH');
}
});
// }else{
$('#customer_id').val(data.id);
$('#customer_name').val(data.name);
$('#customer_company').val(data.company);
$('#customer_contact_no').val(data.contact_no);
$('#customer_email').val(data.email);
$('#customer_salutation').val(data.salutation);
$('#customer_nrc_no').val(data.nrc_no);
$('#customer_card_no').val(data.card_no);
$('#customer_type').val(data.customer_type);
$('#paypar_account_no').val(data.paypar_account_no);
$('#customer_address').val(data.address);
$('#customer_date_of_birth').val(data.date_of_birth);
if(data.image_path.url!=undefined && data.image_path.url!=null){
$('.menu-item-img .img-thumbnail').attr('src',data.image_path.url);
}
$('#customer_membership_type').val(data.membership_type);
$('.selectpicker > option[value="'+data.membership_type+'"]').attr('selected','selected');
if (data.gender == 'Male') {
$('.male').prop( "checked", true )
}else{
$('.female').prop( "checked", true )
}
// }
if(data.salutation == 'Mr') {
$('.mr').prop( "checked", true )
}else if(data.salutation == 'Miss') {
$('.miss').prop( "checked", true )
}else if(data.salutation == 'Mrs'){
$('.mrs').prop( "checked", true )
}else{
$('.mdm').prop( "checked", true )
}
$('.membership_authentication_code').val(data.membership_authentication_code);
$('#update_customer').removeAttr('disabled').val('');
$('#update_customer').attr('value', 'Update');
$('#submit_customer').attr('disabled','disabled');
$("#new_customer").attr('class', 'simple_form edit_customer');
var id = "edit_customer_"+customer_id;
$("#new_customer").attr('id', id);
$(".edit_customer").attr('id', id);
$(".edit_customer").attr('action', '/crm/customers/' + $('#customer_id').val());
$(".edit_customer").attr('action', '/crm/customers/' + $('#customer_id').val());
$(".patch_method").html('<input type="hidden" name="_method" value="patch">');
//$(".edit_customer").attr('method', 'PATCH');
}
});
// }else{
// }
})
function update_sale(customer_id,sale_id) {
@@ -289,5 +320,4 @@ $(document).on('click',".customer_tr",function(){
$("#sxModal .btn_cancel").on('click',function(){
$("#sxModal").hide();
});
</script>

View File

@@ -1,5 +1,17 @@
<div class="container-fluid">
<div class="page-header">
<ul class="breadcrumb">
<li class="breadcrumb-item"><a href="<%= dashboard_path %>">Home</a></li>
<li class="breadcrumb-item active">CRM</li>
<!-- <li class="breadcrumb-item"><a href="<%= dashboard_path %>">Home</a></li> -->
<span class="float-right">
<%= link_to 'Back', crm_customers_path %>
</span>
</ul>
</div>
<div class="row">
<div class="col-lg-11 col-md-11 col-sm-11">
<div class="col-lg-12 col-md-12 col-sm-12">
<!-- Column One -->
<!-- Nav tabs -->
<ul class="nav nav-tabs tab-nav-right" role="tablist">
@@ -13,12 +25,16 @@
<li role="presentation" class="nav-item" >
<a class="nav-link" data-toggle="tab" href="#sale" ><%= t :sale_details %></a>
</li>
<li role="presentation" class="nav-item" >
<a class="nav-link" data-toggle="tab" href="#credit" ><%= t :credit %> <%= t :details %></a>
</li>
</ul>
<!-- Nav tabs - End -->
<div class="tab-content" style="min-height:670px; max-height:670px; ">
<div class="tab-pane active" id="customer" role="tabpanel" style="min-height:670px; max-height:670px; ">
<h5><%= t :customer_details %></h5>
<div class="table-responsive">
<br><br>
<table class="table table-striped">
@@ -63,6 +79,7 @@
</div>
<div class="table-responsive">
<h6><%= t("views.right_panel.detail.paymal_transactions ") %></h6>
<table class="table table-striped">
<thead>
<tr>
@@ -148,50 +165,68 @@
<div class="tab-pane" id="sale" role="tabpanel" style="min-height:670px; max-height:670px; ">
<h5><%= t :sale_details %></h5>
<div class="table-responsive">
<table class="table table-striped">
<thead>
<tr>
<th><%= t("views.right_panel.detail.sale_id") %></th>
<th><%= t("views.right_panel.detail.receipt_no") %></th>
<th><%= t("views.right_panel.detail.total_discount") %></th>
<th><%= t("views.right_panel.detail.tax_amount") %></th>
<th><%= t("views.right_panel.detail.sub_total") %></th>
<th><%= t("views.right_panel.detail.grand_total") %></th>
<th><%= t :cashier %></th>
<th><%= t("views.right_panel.detail.sales_status") %></th>
<th><%= t("views.right_panel.detail.receipt_date") %></th>
</tr>
</thead>
<div class="table-responsive">
<table class="table table-striped">
<thead>
<tr>
<th><%= t("views.right_panel.detail.sale_id") %></th>
<th><%= t("views.right_panel.detail.receipt_no") %></th>
<th><%= t("views.right_panel.detail.total_discount") %></th>
<th><%= t("views.right_panel.detail.tax_amount") %></th>
<th><%= t("views.right_panel.detail.sub_total") %></th>
<th><%= t("views.right_panel.detail.grand_total") %></th>
<th><%= t :cashier %></th>
<th><%= t("views.right_panel.detail.sales_status") %></th>
<th><%= t("views.right_panel.detail.receipt_date") %></th>
</tr>
</thead>
<tbody>
<% @sales.each do |sale| %>
<tr>
<td><%= link_to sale.sale_id, transactions_sale_path(sale) %></td>
<td><%= sale.receipt_no %></td>
<td><%= sale.total_discount %></td>
<td><%= sale.total_tax %></td>
<td><%= sale.total_amount %></td>
<td><%= sale.grand_total rescue '-' %></td>
<td><%= sale.cashier_name rescue '-' %></td>
<td> <%= sale.sale_status %> </td>
<td> <%= sale.receipt_date.utc.getlocal.strftime("%d-%m-%Y %I:%M %p") %> </td>
</tr>
<% end %>
</tbody>
</table>
</div>
</div>
<tbody>
<% @sales.each do |sale| %>
<tr>
<td><%= link_to sale.sale_id, transactions_sale_path(sale) %></td>
<td><%= sale.receipt_no %></td>
<td><%= sale.total_discount %></td>
<td><%= sale.total_tax %></td>
<td><%= sale.total_amount %></td>
<td><%= sale.grand_total rescue '-' %></td>
<td><%= sale.cashier_name rescue '-' %></td>
<td> <%= sale.sale_status %> </td>
<td> <%= sale.receipt_date.utc.getlocal.strftime("%d-%m-%Y %I:%M %p") %> </td>
</tr>
<% end %>
</tbody>
</table>
</div>
</div>
<div class="tab-pane" id="credit" role="tabpanel" style="min-height:670px; max-height:670px; ">
<h5><%= t :credit %> <%= t :details %></h5>
<table class="table table-responsive tbl_credit_lists">
<thead>
<th><%= t :credit %> <%= t :sale %> <%= t("views.right_panel.detail.date") %></th>
<th><%= t("views.right_panel.detail.receipt_no") %></th>
<th> <%= t :cashier %> <%= t("views.right_panel.detail.name") %></th>
<th> <%= t("views.right_panel.detail.credit_amount") %> </th>
</thead>
<tbody>
<% if !@credit_sales.nil? %>
<% @credit_sales.each do |credit| %>
<tr>
<td><%= credit.sale_date.utc.getlocal.strftime("%e %b %Y %I:%M%p") %></td>
<td><%= credit.receipt_no %></td>
<td><%= credit.cashier_name %></td>
<td><%= credit.payment_amount %></td>
</tr>
<% end %>
<% end %>
</tbody>
</table>
</div>
</div>
</div>
</div>
<div class="col-lg-1 col-md-1 col-sm-1">
<a href="<%= crm_customers_path%>" class="btn btn-default btn-sm">
<i class="material-icons">reply</i><%= t("views.btn.back") %>
</a>
</div>
</div>

View File

@@ -1,7 +1,7 @@
<table class="table table-striped">
<tr>
<th>#</th>
<th><%= t("views.right_panel.header.menu_category") %></th>
<th><%= t("views.right_panel.detail.product") %></th>
<th><%= t("views.right_panel.detail.min_order") %></th>
<th><%= t("views.right_panel.detail.max_stock") %></th>
@@ -10,12 +10,36 @@
<!-- <th><%= t("views.right_panel.detail.created_by") %></th>
<th><%= t("views.right_panel.detail.created_time") %></th> -->
</tr>
<% cate_arr = Array.new %>
<%
count = 0
@inventory_definitions.each do |item|
count += 1
%>
<tr>
<% if !cate_arr.include?(item.menu_category_id) %>
<td><%= item.menu_category_name %></td>
<% cate_arr.push(item.menu_category_id) %>
<% else %>
<td>&nbsp;</td>
<% end %>
<td><%= item.item_name rescue '-' %> - <%= item.instance_name%></td>
<td><%= item.min_order_level %></td>
<td><%= item.max_stock_level %></td>
<td>
<% if item.balance.nil? %>
0
<% else %>
<%= item.balance rescue 0 %>
<% end %>
</td>
<td>
<button type="button" data-value="<%= item.id %>" class="btn bg-blue waves-effect btn-link show_track"> <%= t("views.right_panel.detail.stock_ledger") %></button>
</td>
</tr>
<!-- <tr>
<td><%= count %></td>
<td>
<% menu_item = MenuItemInstance.find_by_item_instance_code(item.item_code)%>
@@ -38,16 +62,14 @@
<td>
<button type="button" data-value="<%= item.id %>" class="btn bg-blue waves-effect btn-link show_track"><%= t("views.btn.show") %> <%= t("views.right_panel.detail.stock_check") %></button>
</td>
<!-- <td><%= Employee.find(item.created_by).name rescue '-' %></td>
<td><%= item.created_at.utc.getlocal.strftime("%e %b %Y %I:%M %p") rescue '-' %></td> -->
</tr>
</tr> -->
<% end %>
</table>
</table>
<script>
$('.show_track').on('click', function () {
var ID = $(this).attr("data-value");
window.location.href = '/inventory/'+ID+'/show';
});
<script>
$('.show_track').on('click', function () {
var ID = $(this).attr("data-value");
window.location.href = '/inventory/'+ID+'/show';
});
</script>
</script>

View File

@@ -7,22 +7,36 @@
</span>
</ol>
</div>
<%= form_tag inventory_path, :id => "filter_form", :method => :get do %>
<div class="row">
<div class="col-xs-12 col-sm-12 col-md-9 col-lg-9">
<div class="col-lg-4 col-md-4 col-sm-4">
<label class="font-14"><%= t("views.right_panel.detail.product") %></label>
<input type="text" class="form-control" name="filter" id="Product" type="text" placeholder="" style="height: 32px;">
</div>
<div class="col-lg-2 col-md-2 col-sm-2 text-">
<br>
<input type="submit" value="Filter" class='btn btn-primary'>
</div>
</div>
<% end %>
<div class="row">
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
<div class="m-b-10 clearfix">
<!-- <button id="stock_check_report" type="button" class="btn bg-blue float-right waves-effect" style='margin-left:5px;'> <%= t("views.btn.stock_check_report") %>
</button> -->
<button id="stock_taking" type="button" class="btn bg-blue float-right waves-effect" style='margin-left:5px;'> <%= t("views.btn.stock_taking") %></button>
<button id='new_inventory_product' class='btn btn-primary float-right waves-effect' style='margin-left:5px;'><%= (t :track) +" "+ t("views.btn.new") + " " + (t :inventory) %>
<button id='new_inventory_product' class='btn btn-primary float-right waves-effect' style='margin-left:5px;'><%= (t :track) +" "+ t("views.btn.new") + " " %> <%= t("views.right_panel.detail.item") %>
</button>
</div>
<div class="card">
<%= render 'inventory_list' %>
</div>
</div>
<div class="col-xs-12 col-sm-12 col-md-3 col-lg-3">
<!-- <div class="col-xs-12 col-sm-12 col-md-3 col-lg-3">
<div class="card">
<div class="body">
<h5><i class="material-icons md-18">list <%= t("views.right_panel.header.button_lists") %></i> </h5>
@@ -32,9 +46,9 @@
<p>
2) <%= t("views.right_panel.detail.stock_taking") %> - <%= t("views.right_panel.detail.create_btn_txt") %> <%= t("views.right_panel.detail.stock_taking_txt") %> <br>
</p>
<!-- <p>
<<p>
3) <%= t("views.right_panel.detail.stock_check_report") %> - <%= t("views.right_panel.detail.back_txt") %> <%= t("views.right_panel.detail.stock_check_report_txt") %> <br>
</p> -->
</p>
<h5><i class="material-icons md-18">list <%= t("views.right_panel.header.link_lists") %></i> </h5>
<p>
1) <%= t("views.right_panel.button.home") %> - <%= t("views.right_panel.detail.home_txt") %> <br>
@@ -42,7 +56,7 @@
</p>
</div>
</div>
</div>
</div> -->
</div>

View File

@@ -0,0 +1,119 @@
<div class="row">
<div class="col-xs-12 col-sm-12 col-md-8 col-lg-8">
<div class="card">
<div class="body">
<div class="p-l-10">
<%= simple_form_for([:inventory, @inventory_definition]) do |f| %>
<%= f.error_notification %>
<div class="form-inputs">
<div class="row">
<% arr = MenuItem.active.order("name desc").pluck(:name, :item_code) %>
<% Product.order("name desc").pluck(:name, :item_code).each do |p| %>
<% arr.push(p) %>
<% end %>
<div class="col-md-4 ">
<div class="form-group">
<label class="control-label"><abbr title="required">*</abbr>Select Item</label>
<select class="form-control item_code_place" id="item">
<% if !@inventory_definition.item_code.nil? %>
<% menuiteminstance = MenuItemInstance.find_by_item_instance_code(@inventory_definition.item_code) %>
<% if menuiteminstance.nil? %>
<% code = @inventory_definition.item_code %>
<% else %>
<% code = menuiteminstance.menu_item.item_code %>
<% end %>
<% end %>
<option value=""></option>
<% arr.each do |a| %>
<% if a[1] == code %>
<option value="<%= a[1] %>" selected><%= a[0] %></option>
<% else %>
<option value="<%= a[1] %>"><%= a[0] %></option>
<% end %>
<% end %>
</select>
</div>
</div>
<% sample = [] %>
<% if @inventory_definition.item_code.nil? %>
<% if !MenuItemInstance.find_by_item_instance_code(@inventory_definition.item_code).nil? %>
<% sample = MenuItemInstance.where("item_instance_code=?", @inventory_definition.item_code).pluck(:item_instance_name, :item_instance_code) %>
<% else %>
<% sample = Product.where("item_code=?", @inventory_definition.item_code).pluck(:name, :item_code) %>
<% end %>
<% end %>
<div class="col-md-3"><%= f.input :item_code, collection: sample %></div>
</div>
<%= f.input :min_order_level %>
<%= f.input :max_stock_level %>
</div>
<div class="form-actions">
<%= f.submit t("views.btn.submit"), class: 'btn bg-blue waves-effect' %>
</div>
<% end %>
</div>
</div>
</div>
</div>
<div class="col-xs-12 col-sm-12 col-md-4 col-lg-4">
<div class="card">
<div class="body">
<h5><i class="material-icons md-18">view_headline <%= t("views.right_panel.header.page_detail") %></i> </h5>
<p>
1) <%= t("views.right_panel.detail.select_item") %> - <%= t("views.right_panel.detail.select_txt") %> <%= t("views.right_panel.detail.item_txt") %> <br>
2) <%= t("views.right_panel.detail.item_code") %> - <%= t("views.right_panel.detail.write_txt") %> <%= t("views.right_panel.detail.item_code_txt2") %> <br>
3) <%= t("views.right_panel.detail.min_order") %> <%= t("views.right_panel.detail.level") %> - <%= t("views.right_panel.detail.write_txt") %> <%= t("views.right_panel.detail.min_order_level_txt") %> <br>
4) <%= t("views.right_panel.detail.max_stock") %> <%= t("views.right_panel.detail.level") %> - <%= t("views.right_panel.detail.write_txt") %><%= t("views.right_panel.detail.max_stock_level_txt") %><br>
</p>
<h5><i class="material-icons md-18">list <%= t("views.right_panel.header.button_lists") %></i> </h5>
<p>
1) <%= t("views.btn.submit") %> - <%= t("views.right_panel.detail.create_btn_txt") %> <%= t("views.right_panel.detail.inventory") %> <br>
</p>
<h5><i class="material-icons md-18">list <%= t("views.right_panel.header.link_lists") %></i> </h5>
<p>
1) <%= t("views.right_panel.button.home") %> - <%= t("views.right_panel.detail.home_txt") %> <br>
2) <%= t("views.right_panel.button.back") %> - <%= t("views.right_panel.detail.back_txt") %> <%= t("views.right_panel.detail.home_txt") %> <br>
</p>
</div>
</div>
</div>
</div>
<script>
$(document).ready(function () {
// $(".item_code_place").select2({
// placeholder: 'Select Item'
// });
// $("select#inventory_definition_item_code").select2();
$(".item_code_place").on('change', function (event) {
var ajax_url = "<%= settings_find_item_instance_path %>";
var item_code = this.value;
$.ajax({
type: "GET",
url: ajax_url,
data: 'item_code=' + item_code,
success: function (result) {
$("#inventory_definition_item_code").empty();
var itemlist;
for (var i = 0; i < result.length; i++) {
itemlist = "<option value ='" + result[i][1] + "'>" + result[i][0] + "</option>";
$("select#inventory_definition_item_code").append(itemlist);
}
// $("select#inventory_definition_item_code").append(itemlist);
// $("select#inventory_definition_item_code").select2();
}
});
});
});
</script>

718
app/views/inventory/inventory_definitions/_form.html.erb Executable file → Normal file
View File

@@ -1,119 +1,637 @@
<div class="row">
<div class="col-xs-12 col-sm-12 col-md-8 col-lg-8">
<div class="card">
<div class="body">
<div class="p-l-10">
<%= simple_form_for([:inventory, @inventory_definition]) do |f| %>
<%= f.error_notification %>
<%= stylesheet_link_tag 'addorder', media: 'all', 'data-turbolinks-track': 'reload' %>
<div class="form-inputs">
<div class="row">
<% arr = MenuItem.active.order("name desc").pluck(:name, :item_code) %>
<% Product.order("name desc").pluck(:name, :item_code).each do |p| %>
<% arr.push(p) %>
<% end %>
<div class="col-md-4 ">
<div class="form-group">
<label class="control-label"><abbr title="required">*</abbr>Select Item</label>
<select class="form-control item_code_place" id="item">
<% if !@inventory_definition.item_code.nil? %>
<% menuiteminstance = MenuItemInstance.find_by_item_instance_code(@inventory_definition.item_code) %>
<% if menuiteminstance.nil? %>
<% code = @inventory_definition.item_code %>
<% else %>
<% code = menuiteminstance.menu_item.item_code %>
<% end %>
<% end %>
<option value=""></option>
<% arr.each do |a| %>
<% if a[1] == code %>
<option value="<%= a[1] %>" selected><%= a[0] %></option>
<% else %>
<option value="<%= a[1] %>"><%= a[0] %></option>
<% end %>
<% end %>
</select>
<div class="container-fluid " style="padding:0px 3px 0px 3px;">
<div id="oqs_loading_wrapper" style="display:none;">
<div id="oqs_loading"></div>
</div>
<div class="row m-t--20">
<div class="col-lg-2 col-md-2 col-sm-2 hidden" id="menu_data">
<li class="list-menu">
<a href="javascript:void(0);" class="menu-toggle dropdown-toggle toggled my-toggle " style="">
<span class="main_menu" id="main_menu menu_name" >
<%if @menu.present? %>
<%=@menus[0].name%>
<% end%>
</span>
</a>
<ul class="ml-menu menu_list aria-hidden " style="border-top: 1px solid #fff">
<% @menus.each do |menu| %>
<li class="nav-item menu_click" data-name="<%=menu.name%>" data-id="<%=menu.id%>" style="">
<a class="nav-link" data-toggle="tab" href="" role="tab" style="text-transform: lowercase;"><%=menu.name%></a>
</li>
<%end%>
</ul>
</li>
<div id="menu1-slimscroll" data-height="0">
<ul class="nav nav-tabs flex-column category_list" role="tablist" id="ul-navbar">
<li class="nav-item product" data-ref="<%= origami_get_all_product_path %>">
<a class="nav-link" data-toggle="tab" href="" role="tab">Products</a>
</li>
<% @menu.each do |menu| %>
<% if !menu.valid_time.nil? %>
<% if menu.menu_category_id.nil? %>
<!--if type quick_service or cashier for table -->
<% if !menu.code.include? "SPL" %>
<li class="nav-item ">
<p class="hidden menu-id"><%= menu.id %></p>
<a class="nav-link menu_category sub_click first_<%=menu.id%>" data-toggle="tab" href="" role="tab" data-id="<%=menu.id%>" data-sub-id="<%=menu.get_sub_category%>"> <%= menu.name%>
</a>
<ul class=" sub_category_list hidden fadeInTop animated" id="sub_category_list"></ul>
</li>
<% end%>
<% end%>
<% end %>
<%end %>
</ul>
</div>
</div>
<div class="col-lg-2 col-md-2 col-sm-2 hidden" id="menu_cache">
<li class="list-menu">
<a href="javascript:void(0);" class="menu-toggle dropdown-toggle toggled my-toggle " style="">
<span class="main_menu menu_cache_name" id="main_menu menu_cache_name"></span>
</a>
<ul class="ml-menu menu_list aria-hidden menu_cache_list" style="border-top: 1px solid #fff">
</ul>
</li>
<div id="menu-slimscroll" data-height="0">
<ul class="nav nav-tabs flex-column category_list category_cache_list" role="tablist" id="ul-navbar">
<li class="nav-item product" data-ref="<%= origami_get_all_product_path %>">
<a class="nav-link" data-toggle="tab" href="" role="tab">Products</a>
</li>
</ul>
</div>
</div>
<div class="col-md-7 col-lg-7 col-sm-7 m-t-10" >
<div class="card">
<div class="card-block" style="">
<div class="card-text" id="custom-slimscroll">
<div class="row menu_items_list" style="margin:0px 1px 0px 1px ;">
<!-- append data -->
</div>
</div>
<% sample = [] %>
<% if @inventory_definition.item_code.nil? %>
<% if !MenuItemInstance.find_by_item_instance_code(@inventory_definition.item_code).nil? %>
<% sample = MenuItemInstance.where("item_instance_code=?", @inventory_definition.item_code).pluck(:item_instance_name, :item_instance_code) %>
<% else %>
<% sample = Product.where("item_code=?", @inventory_definition.item_code).pluck(:name, :item_code) %>
<% end %>
<% end %>
<div class="col-md-3"><%= f.input :item_code, collection: sample %></div>
</div>
<%= f.input :min_order_level %>
<%= f.input :max_stock_level %>
</div>
<div class="form-actions">
<%= f.submit t("views.btn.submit"), class: 'btn bg-blue waves-effect' %>
</div>
<% end %>
</div>
<div class="col-lg-3 col-md-3 col-sm-3" >
<button type="button" class="btn btn-lg btn-block btn-default waves-effect m-t-5" id='back'>
<i class="material-icons">reply</i>Back
</button>
<div class="card-block">
<div class="card-text" id="order-detail-slimscroll" data-height="140">
<table class="table table-striped summary-items" id="order-items-table" >
<thead>
<tr>
<th>#</th>
<th class="item-name">Items</th>
<th class="item-qty">Min Qty</th>
<th class="item-attr">Max Qty</th>
</tr>
</thead>
<tbody class="font-13" >
</tbody>
</table>
</div>
</div>
<div class="card-footer">
<button type="button" class="btn btn-lg btn-block btn-primary waves-effect m-t-5" id='stock_taking'>Stock Taking
</button>
</div>
</div>
</div>
</div>
</div>
<div class="col-xs-12 col-sm-12 col-md-4 col-lg-4">
<div class="card">
<div class="body">
<h5><i class="material-icons md-18">view_headline <%= t("views.right_panel.header.page_detail") %></i> </h5>
<p>
1) <%= t("views.right_panel.detail.select_item") %> - <%= t("views.right_panel.detail.select_txt") %> <%= t("views.right_panel.detail.item_txt") %> <br>
2) <%= t("views.right_panel.detail.item_code") %> - <%= t("views.right_panel.detail.write_txt") %> <%= t("views.right_panel.detail.item_code_txt2") %> <br>
3) <%= t("views.right_panel.detail.min_order") %> <%= t("views.right_panel.detail.level") %> - <%= t("views.right_panel.detail.write_txt") %> <%= t("views.right_panel.detail.min_order_level_txt") %> <br>
4) <%= t("views.right_panel.detail.max_stock") %> <%= t("views.right_panel.detail.level") %> - <%= t("views.right_panel.detail.write_txt") %><%= t("views.right_panel.detail.max_stock_level_txt") %><br>
</p>
<h5><i class="material-icons md-18">list <%= t("views.right_panel.header.button_lists") %></i> </h5>
<p>
1) <%= t("views.btn.submit") %> - <%= t("views.right_panel.detail.create_btn_txt") %> <%= t("views.right_panel.detail.inventory") %> <br>
</p>
<h5><i class="material-icons md-18">list <%= t("views.right_panel.header.link_lists") %></i> </h5>
<p>
1) <%= t("views.right_panel.button.home") %> - <%= t("views.right_panel.detail.home_txt") %> <br>
2) <%= t("views.right_panel.button.back") %> - <%= t("views.right_panel.detail.back_txt") %> <%= t("views.right_panel.detail.home_txt") %> <br>
</p>
</div>
</div>
</div>
</div>
<div class="item-modal modal sx_item_detailModal" id="sx_item_detailModal" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="true">
<div class="modal-dialog custom-modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header" style="background-color: #54A5AF;padding-top:10px !important;">
<h4 class="modal-title" style="color:#fff;" id="title_name"></h4>
<button type="button" class="close" id="close" data-dismiss="modal" aria-hidden="true" style="font-size: 20px;color:#fff;">&times;</button>
</div>
<div class="modal-body">
<div class="form-inputs">
<div class="form-group">
<div class="form-group">
<label class="control-label" for="attribute">Menu Item</label>
<input class="form-control col-md-6" type="text" value="" id="item_name" readonly="true">
</div>
<input type="hidden" name="item_code" id="instance_code">
<div class="form-group">
<label class="control-label" for="attribute">Instances</label>
<div class="attributes-list col-md-6"></div>
</div>
<div class="form-group">
<label class="control-label" for="attribute">Min Order Level</label>
<input type="text" name="min_order_level" id="min_qty" value="1" class="col-md-5 form-control">
</div>
<div class="form-group">
<label class="control-label" for="attribute">Max Order Level</label>
<input type="text" name="max_order_level" id="max_qty" value="1" class="col-md-5 form-control">
</div>
</div>
</div>
</div>
<div class="modal-footer">
<div class="row">
<div class="col-md-4">
<button type="button" class="btn btn-default " data-dismiss="modal" id="close">Close</button>
</div>
<div class="col-md-6">
<button type="button" class="btn btn-primary submit " data-dismiss="modal" id="submit">Submit</button>
</div>
</div>
</div>
</div>
</div>
<style type="text/css">
.fadeInRight{
-webkit-animation-duration: 350ms !important;
}
</style>
<script>
var cashier_type = $('#cashier_type').val();
jQuery(function(){
var menus = JSON.parse(localStorage.getItem("menus"));
if (menus != null) {
var id = menus[0]["categories"][0]["id"];
// console.log(id);
}else{
var id = 1;
}
jQuery('.first_'+id).click();
});
$(document).ready(function () {
// $(".item_code_place").select2({
// placeholder: 'Select Item'
// });
// $("select#inventory_definition_item_code").select2();
var menus = JSON.parse(localStorage.getItem("menus"));;
if (menus != null) {
menu_cache_append(menus);
}else{
$("#menu_data").removeClass("hidden");
}
$(".item_code_place").on('change', function (event) {
var ajax_url = "<%= settings_find_item_instance_path %>";
var item_code = this.value;
$.ajax({
type: "GET",
url: ajax_url,
data: 'item_code=' + item_code,
success: function (result) {
$("#inventory_definition_item_code").empty();
var itemlist;
for (var i = 0; i < result.length; i++) {
itemlist = "<option value ='" + result[i][1] + "'>" + result[i][0] + "</option>";
$("select#inventory_definition_item_code").append(itemlist);
}
// $("select#inventory_definition_item_code").append(itemlist);
// $("select#inventory_definition_item_code").select2();
function menu_cache_append(menus){
$("#menu_cache").removeClass("hidden");
$(".menu_cache_name").text(menus[0]["name"])
for(var i in menus) {
menu_list_template(menus[i]);
}
var category = menus[0]["categories"];
for(var ii in category) {
if (category[ii]["is_available"]== true){
if (category[ii]["valid_time"]== true){
if (category[ii]["parent_id"] == null ){
if (category[ii]["code"].includes("SPL") != true) {
category_list_template(category[ii]);
}
}
}
}
}
}
$(document).on('click', '.menu_click', function(event){
$('.my-toggle').removeClass('toggled');
$('.menu_list').css('display', 'none');
var menu_id = $(this).attr("data-id");
var name = $(this).attr("data-name");
var menus = JSON.parse(localStorage.getItem("menus"));;
if (menus != null) {
console.log("hi")
menu_click_cache_append(name,menus,menu_id);
}else{
console.log("sssdfdf")
var url = "/origami/addorders/get_menu/"+menu_id;
show_menu_cat_list(name, url);
}
});
//End menu category Click
function menu_click_cache_append(name,menus,menu_id) {
var menu_list = $('.menu_items_list');
menu_list.empty();
var menu_cat = $('.category_list');
menu_cat.empty();
$(".main_menu").text(name);
for(var i in menus) {
if (menu_id == menus[i]["id"] && menus[i]["is_active"] == true) {
// menu_list_template(menus[i]);
var category = menus[i]["categories"];
for(var ii in category) {
if (category[ii]["is_available"]== true){
if (category[ii]["valid_time"]== true){
if (category[ii]["parent_id"] == null ){
if (category[ii]["code"].includes("SPL") != true) {
category_list_template(category[ii]);
}
}
}
});
});
}
}
}
}
}
function category_list_template(menu) {
row = '<li class="nav-item">'
+'<p class="hidden menu-id">'+menu.id+'</p> '
+'<a class="nav-link menu_category sub_click first_'+menu.id+'" '
+'data-toggle="tab" href="" role="tab" data-id="'+menu.id+'" '
+'data-sub-id="'+menu.sub_category+'">'+menu.name+''
+'</a>'
+'<ul class="sub_category_list hidden fadeInTop animated" '
+'id="sub_category_list">'
+'</ul>'
+' </li>';
$(".category_cache_list").append(row);
}
function menu_list_template(menu) {
row = '<li class="nav-item menu_click" data-name="'+menu.name+'" '
+' data-id="'+menu.id+'" style="">'
+' <a class="nav-link" data-toggle="tab" href="" role="tab"'
+' style="text-transform: lowercase;">'+menu.name+'</a>'
+'</li>';
$(".menu_cache_list").append(row);
}
//show menu item list when click menu category
function show_menu_cat_list(name, url_item){
var menu_list = $('.menu_items_list');
menu_list.empty();
var menu_cat = $('.category_list');
menu_cat.empty();
$(".main_menu").text(name);
//Start Ajax
$.ajax({
type: "GET",
url: url_item,
data: {},
dataType: "json",
success: function(data) {
for(var i in data) {
if (data[i].is_available == true) {
list = '<li class="nav-item menu_category sub_click" data-id="'+ data[i].id +'">'
+'<p class="hidden menu-id">'+ data[i].id +'</p> '
+'<a class="nav-link" data-toggle="tab" href="" role="tab"> '+ data[i].name +''
+'<ul class=" sub_category_list hidden fadeInTop animated"'
+'id="sub_category_list">'
+'</ul>'
+'</a>'
+'</li>';
$('.category_list').append(list);
}
}
}
});
//end Ajax
}
//end show list function
//click menu sidebar menu category
$(document).on('click', '.menu_category', function(e){
e.preventDefault();
$('.sub_category_list').addClass("hidden");
var menu_id = $(this).attr("data-id");
var url = "get_menu_category/"+menu_id;
show_menu_item_list(url,menu_id);
var sub_id = $(this).attr("data-sub-id");
if (sub_id == "true") {
var sub_url = "get_menu_sub_category/"+menu_id;
sub_category = $(this).siblings('.sub_category_list');
show_sub_category_list(sub_url,sub_category,menu_id);
}
});
//End menu category Click
//click menu sidebar menu category
$(document).on('click', '.menu_sub_category', function(event){
// event.preventDefault();
// $(".menu_sub_category").on("click", function(){
$('.sub_category_list').addClass("hidden");
var menu_id = $(this).attr("data-id");
var url = "get_menu_category/"+menu_id;
show_menu_item_list(url,menu_id);
});
//End menu category Click
//show menu item list when click menu category
function show_menu_item_list(url_item,menu_id){
var menu_list = $('.menu_items_list');
menu_list.empty();
menus = JSON.parse(localStorage.getItem("menus"));
if (menus != null) {
for(var i in menus) {
var categories = menus[i]["categories"];
for(var ii in categories) {
if (categories[ii]["id"] == menu_id) {
var menu_items = categories[ii]["items"];
show_menu_list(menu_items);
}
}
}
}else{
//Start Ajax
$.ajax({
type: "GET",
url: url_item,
data: {},
dataType: "json",
success: function(data) {
var menu_items_list = $('.menu_items_list');
menu_items_list.empty();
menu_items = data.menu_items;
show_menu_list(menu_items);
}
});
//end Ajax
}
}
//end show list function
function show_menu_list(menu_items) {
var menu_list = $('.menu_items_list');
menu_list.empty();
for(var field in menu_items) {
if (menu_items[field].is_sub_item == false) {
instances = menu_items[field].instances ;
if (!instances.length > 0) {
swal("Hello Please Check!","Does not have instance item in this menu items ("+ menu_items[field].name+")","warning");
}
if (instances.length > 0) {
qty = 1;
options = [];
price = 0;
fa_plus = 'material-icons';
add = 'view_list'
menu_item_box = 'menu_item_box';
data_target = 'sx_item_detailModal';
data_modal = ''
add_icon = "add_icon"
$(instances).each(function(i){
if (instances[i].is_default === true) {
code = instances[i].code;
name = instances[i].name;
price = parseFloat(instances[i].price).toFixed(2);
is_available = instances[i].is_available ;
is_on_promotion = instances[i].is_on_promotion;
item_attributes = instances[i].values;
promotion_price = instances[i].promotion_price;
code = instances[i].code;
}
});
if (menu_items[field].image) {
image_path = menu_items[field].image;
}else{
image_path = "image/logo.png";
}
row = '<div class="col-md-3">'
+'<div class="card custom-card testimonial-card fadeInRight card-box"'
+'data-toggle="modal" data-target=".'+data_target+'" '
+'style="height:100%;background-image:url(../../'+image_path+');background-repeat: no-repeat;">'
+'<div class="custom-card-head card-head row" style="line-height:14px;margin:0px;" style="">'
+'<div class="col-md-10 " style="padding:0px !important;">'+ menu_items[field].name +'</div>'
+"<div class='col-md-2 "+menu_item_box+" ' data-item-code='"
+ menu_items[field].code +"' data-instance = '"
+JSON.stringify(menu_items[field].instances)+"' data-id = '"
+JSON.stringify(menu_items[field].attributes)+"' data-item = '"
+JSON.stringify(item_attributes)+"' data-option = '"
+JSON.stringify(menu_items[field].options)+"'data-opt = '"
+JSON.stringify(menu_items[field].options)+"' data-item-sets = '"
+JSON.stringify(menu_items[field].item_sets)+"' data-toggle='modal' data-target='."+data_target+"' style='padding:0px 5px 0px 5px'>"
+"<i class='m-l--5 fa "+fa_plus+" '>"
+add+ '</i>'
+'</div>'
+'</div>'
+"<div class='"+add_icon+" p-t-65 m-r-' data-item-code='"
+ menu_items[field].code +"' data-name='"
+ menu_items[field].name +"' data-qty = '"+ qty +"' data-price = '"
+ price +"' data-instance-code = '"+ code +"' data-instance = '"
+ name +"' data-promotion-price = '"+ promotion_price +"' data-attributes = '"
+ JSON.stringify(item_attributes) +"' data-options = '"
+ JSON.stringify(menu_items[field].options) +"' data-opt = '"
+ JSON.stringify(menu_items[field].options) +"' data-image='"+image_path+"' data-toggle='"
+data_modal+"' data-target='."+data_target+"' data-item-sets = '"
+JSON.stringify(menu_items[field].item_sets)+"'data-instances = '"
+JSON.stringify(menu_items[field].instances)+"'>"
// +"<div class='card-block custom-card-block'>"
// +"<img id='logo' height='' src='"+image_path+"'>"
// +"</div>"
+'</div>'
+'</div>'; ;
$('.menu_items_list').append(row);
}
//end instances in menu-items alest 1 instance
}
//end is_sub_item false
}
}
//click item row for add order
$(document).on('click', '.card-box', function(event){
item_data = $(this).children().siblings('.add_icon');
$('#item_code').val(item_data.attr('data-item-code'));
$('#item_name').val(item_data.attr('data-name'));
$('#instance_code').val(item_data.attr('data-instance-code'));
$('.attributes-list').empty();
data = $(this).children().children('.menu_item_box');
// data = $(this).parent().siblings('.add_icon');
attributes = $(data).data('id');
selected_item = $(data).data('item');
instances = $(data).data('instance');
instance_attributes = []
for(var field in instances) {
value = instances[field].values;
$(value).each(function(i){
options = value[i];
instance_attributes.push(options);
});
}
for(var field in attributes) {
value = attributes[field]["values"];
type = attributes[field]["type"]
row = "";
$(value).each(function(i){
disabled = ""
status ="";
if(parseInt(jQuery.inArray(value[i], selected_item)) !== -1){
status = "selected-attribute";
}
if(parseInt(jQuery.inArray(value[i], instance_attributes)) == -1){
disabled = "disabled";
}
row +="<button type='button' id='selected-attribute' data-instances='"+JSON.stringify(instances)+"' data-type='"
+type+"' data-value='"+value[i]+"' class='btn btn- waves-effect attribute_btn "
+ status +" "+ type +" '"+ disabled +" >"
+value[i]
+"</button>";
});
$(".attributes-list").append(row);
}
});
</script>
// click select option icon for add
$(document).on('click', '.attribute_btn', function(event){
// $('.change_qty').val(1);
value = $(this).data('value');
type = $(this).data('type');
instances = $(this).data('instances');
attributes = $(".attribute_btn");
$(attributes).each(function(i){
if ($(attributes[i]).attr('data-type')==type){
$('.'+type).removeClass("selected-attribute");
}
});
$(this).addClass('selected-attribute');
var selected_attr = get_selected_attributes('selected-attribute');
for(var field in instances) {
item_attr = instances[field].values;
if(JSON.stringify(item_attr) == JSON.stringify(selected_attr)){
$('#instance_code').val(instances[field].code);
}
}
}); //End selecct attribute buttom
// Get Selected Class
function get_selected_attributes(selected_class) {
var item_row = $('.'+selected_class);
var attribute_arr = [];
$(item_row).each(function(i){
value = $(item_row[i]).attr('data-value');
str = value;
attribute_arr.push(str);
});
return attribute_arr;
}
$(document).on('click', '.cashier_number', function(event){
if(event.handled !== true) {
var original_value;
original_value = $('#modal-qty').attr('data-value');
original_qty = $('#modal-qty').val();
var input_type = $(this).attr("data-type");
switch (input_type) {
case 'num':
var input_value = $(this).attr("data-value");
if (original_value == "0"){
$('#modal-qty').val(input_value);
$('#modal-qty').attr('data-value',input_value);
// update_total_amount();
}else{
$('#modal-qty').val(original_qty + input_value);
$('#modal-qty').attr('data-value',original_qty + input_value);
// update_total_amount();
}
break;
case 'add':
case 'del' :
case 'clr':
$('#modal-qty').val(1);
$('#modal-qty').attr('data-value',0);
// update_total_amount();
break;
}
event.handled = true;
} else {
return false;
}
});
// click select option icon for add
$(document).on('click', '.submit', function(event){
var item_code = $("#instance_code").val();
var min_qty = $("#min_qty").val();
var max_qty = $("#max_qty").val();
var item_name = $("#item_name").val();
console.log(item_code);
console.log(min_qty);
console.log(max_qty);
var params = {'item_code': item_code,
'min_order_level': min_qty,
'max_stock_level': max_qty};
var ajax_url = '<%=inventory_inventory_definitions_path%>';
$.ajax({
type: "POST",
url: ajax_url,
data: params,
dataType: "json",
success:function(result){
if (result.status) {
var rowCount = $('.summary-items tbody tr').length+1;
row ="<tr class=''>"
+'<td class="">'+rowCount+'</td>'
+'<td class="">' + item_name +'</td>'
+'<td class="">' + min_qty + '</td>'
+'<td class="">' + max_qty + '</td>'
+'</tr>';
$(".summary-items tbody").append(row);
swal("Success",result.message,"success");
}else{
swal("Opps",result.message,"warning");
}
}
});
});
$('#back').on('click', function () {
window.location.href = '/inventory';
});
$('#stock_taking').on('click', function () {
window.location.href = '/inventory/stock_checks';
});
});
</script>

View File

@@ -1,4 +1,4 @@
<div class="page-header">
<!-- <div class="page-header">
<ol class="breadcrumb">
<li class="breadcrumb-item"><a href="<%= dashboard_path %>"><%= t("views.right_panel.button.home") %></a></li>
<li class="breadcrumb-item"><a href="<%= inventory_path %>"><%= t :inventory %></a></li>
@@ -7,6 +7,6 @@
<%= link_to t('.back', :default => t("views.btn.back")), inventory_path %>
</span>
</ol>
</div>
</div> -->
<br>
<%= render 'form', inventory: @inventory_definition %>

View File

@@ -0,0 +1,163 @@
<div class="page-header">
<ol class="breadcrumb">
<li class="breadcrumb-item"><a href="<%= dashboard_path %>"><%= t("views.right_panel.button.home") %></a></li>
<li class="breadcrumb-item active"><%= t("views.right_panel.detail.stock_check") %></li>
<span class="float-right">
<%= link_to t('.back', :default => t("views.btn.back")), inventory_path %>
</span>
</ol>
</div>
<div class="row">
<div class="col-xs-12 col-sm-12 col-md-9 col-lg-9">
<!-- <div class="m-b-10 clearfix">
<%= link_to t("views.btn.new"),new_settings_account_path,:class => 'btn btn-primary btn-lg float-right waves-effect"' %>
</div -->
<div class="card">
<div class="p-l-15 p-r-15 p-t-10">
<div class="row">
<div class="col-md-6">
<div class="form-group">
<div class="col-lg-10 col-md-10 col-sm-8 col-xs-7">
<!-- <label for="remark">Remark</label> -->
<input type='text' id='stock_check_reason' class='form-control' placeholder="Set Stock Check Reason" value=''/>
</div>
</div>
<div class="form-group">
<div class="col-lg-10 col-md-10 col-sm-8 col-xs-7">
<!-- <label for="password_2">Item</label> -->
<select class='form-control' id='product_sku'>
<option value="">Select Product</option>
<% @inventory_definitions.each do |id| %>
<option value="<%= id.item_code %>">
<% menu_item = MenuItemInstance.find_by_item_instance_code(id.item_code) %>
<% if menu_item.nil? %>
<%= Product.find_by_item_code(id.item_code).name rescue "-" %>
<% else %>
<%= menu_item.menu_item.name rescue '-' %> - <%= menu_item.item_instance_name rescue '-' %>
<% end %>
</option>
<% end %>
</select>
</div>
</div>
<div class="form-group">
<div class="col-lg-10 col-md-10 col-sm-8 col-xs-7">
<!-- <label for="email_address_2">Qty</label> -->
<input type='text' class='form-control' placeholder="Qty" id='product_qty' value=''/>
</div>
</div>
<div class="form-group">
<div class="col-md-4">
<button class="btn btn-primary form-control" id='save_to_stock_check'> Save</button>
</div>
</div>
</div>
<div class="col-md-6">
<table class="table table-striped" id='stock_item'>
<tr>
<!--<th>#</th>-->
<th><%= t("views.right_panel.detail.product") %></th>
<th><%= t("views.right_panel.detail.balance") %></th>
<th><button class="btn btn-primary pull-right form-control" style='margin-bottom:2px;' id='finish'> <%= t("views.btn.finish") %></button></th>
</tr>
<!-- <tr>
<td colspan="3">
<button class="btn btn-primary pull-right form-control" style='margin-bottom:2px;' id='finish'> Finish</button></td>
</tr> -->
</table>
</div>
</div>
</div>
</div>
</div>
<div class="col-xs-12 col-sm-12 col-md-3 col-lg-3">
<div class="card">
<div class="body">
<h5><i class="material-icons md-18">view_headline <%= t("views.right_panel.header.page_detail") %></i> </h5>
<p>
1) <%= t("views.right_panel.detail.set_stock_check_reason") %> - <%= t("views.right_panel.detail.write_txt") %> <%= t("views.right_panel.detail.stock_check_reason_txt") %> <br>
2) <%= t("views.right_panel.detail.select") +" "+ t("views.right_panel.detail.product") %> - <%= t("views.right_panel.detail.select_txt") %> <%= t("views.right_panel.detail.product_txt") %> <br>
3) <%= t("views.right_panel.detail.qty") %> - <%= t("views.right_panel.detail.write_txt") %> <%= t("views.right_panel.detail.qty_txt") %> <br>
</p>
<h5><i class="material-icons md-18">list <%= t("views.right_panel.header.button_lists") %></i> </h5>
<p>
1) <%= t("views.btn.save") %> - <%= t("views.right_panel.detail.create_btn_txt") %> <%= t("views.right_panel.detail.stock_check_txt") %> <br>
2) <%= t("views.btn.finish") %> - <%= t("views.right_panel.detail.back_txt") %> <%= t("views.right_panel.detail.stock_check_txt") +" "+ t("views.right_panel.detail.detail_txt") %> <br>
</p>
<h5><i class="material-icons md-18">list <%= t("views.right_panel.header.link_lists") %></i> </h5>
<p>
1) <%= t("views.right_panel.button.home") %> - <%= t("views.right_panel.detail.home_txt") %> <br>
2) <%= t("views.right_panel.button.back") %> - <%= t("views.right_panel.detail.back_txt") %> <%= t("views.right_panel.detail.home_txt") %> <br>
</p>
</div>
</div>
</div>
</div>
<script>
var count = 0;
$(document).ready(function(){
clearFormData();
});
function clearFormData(){
$('#stock_check_reason').val("");
$('#product_qty').val("");
$('#product_sku').val("");
}
$('#save_to_stock_check').on('click', function () {
count += 1;
product_sku = $('#product_sku').val();
product_qty = $('#product_qty').val();
product_name = $("#product_sku").find("option:selected").text();
// clearFormData();
var tr = '<tr>'
//+ '<td>' + count + '</td>'
+ '<td><input type=hidden value="' + product_sku + '" id="item_sku_' + count + '" name=' + count + '/>'
+ product_name + '</td>'
+ '<td><input type=text value="' + product_qty + '" class="form-control col-md-9" id="item_qty_' + count + '" name=' + count + '/></td>'
+ '<td><input type=button value="X" class="btn btn-danger p-l-15 p-r-15" id="item_remove_' + count + '" name=' + count + ' onclick="remove_row('+ count +')"/></td>'
+ '</tr>';
$('#stock_item').append(tr);
// $('#product_sku').val('');
$('#product_qty').val('');
});
$('#finish').on('click', function () {
var reason = $('#stock_check_reason').val();
var arr = [];
var jsonStr = '';
for (var i = 1; i <= count; i++) {
itemname = $('#item_sku_' + i).val();
itemqty = $('#item_qty_' + i).val();
if(itemname !== undefined){
arr.push({sku: itemname, qty: itemqty});
}
jsonStr = JSON.stringify(arr);
}
console.log(jsonStr);
$.ajax({
type: 'Post',
url: '<%= inventory_stock_check_save_path %>',
data: 'stock_item=' + jsonStr + '&reason=' + reason,
success: function (data) {
window.location.href = '/inventory/stock_checks/' + data['stock_id'];
}
})
});
function remove_row(row) {
$("#item_remove_"+row).parent().parent().remove();
}
</script>

View File

@@ -0,0 +1,11 @@
if @menu_category
json.menu_items @menu_category do |item|
json.id item.id
json.item_code item.item_code
json.item_name item.item_name
json.instance_name item.instance_name
json.instance_code item.instance_code
json.category_name item.menu_category_name
json.category_id item.menu_category_id
end
end

566
app/views/inventory/stock_checks/index.html.erb Executable file → Normal file
View File

@@ -1,163 +1,465 @@
<div class="page-header">
<ol class="breadcrumb">
<li class="breadcrumb-item"><a href="<%= dashboard_path %>"><%= t("views.right_panel.button.home") %></a></li>
<li class="breadcrumb-item active"><%= t("views.right_panel.detail.stock_check") %></li>
<span class="float-right">
<%= link_to t('.back', :default => t("views.btn.back")), inventory_path %>
</span>
</ol>
</div>
<%= stylesheet_link_tag 'addorder', media: 'all', 'data-turbolinks-track': 'reload' %>
<div class="container-fluid " style="padding:0px 3px 0px 3px;">
<div id="oqs_loading_wrapper" style="display:none;">
<div id="oqs_loading"></div>
</div>
<div class="row m-t">
<div class="col-lg-2 col-md-2 col-sm-2" id="">
<div id="menu1-slimscroll" data-height="0">
<ul class="nav nav-tabs flex-column category_list m-t-10" role="tablist" id="ul-navbar">
<% @category.each do |cat| %>
<li class="nav-item ">
<p class="hidden cat-id"><%= cat.id %></p>
<a class="nav-link menu_category sub_click first_46" data-toggle="tab" href="" role="tab" data-id="<%=cat.id%>" ><%= cat.name%>
</a>
</li>
<%end %>
</ul>
</div>
</div>
<div class="row">
<div class="col-xs-12 col-sm-12 col-md-9 col-lg-9">
<!-- <div class="m-b-10 clearfix">
<%= link_to t("views.btn.new"),new_settings_account_path,:class => 'btn btn-primary btn-lg float-right waves-effect"' %>
</div -->
<div class="card">
<div class="p-l-15 p-r-15 p-t-10">
<div class="row">
<div class="col-md-6">
<div class="form-group">
<div class="col-lg-10 col-md-10 col-sm-8 col-xs-7">
<!-- <label for="remark">Remark</label> -->
<input type='text' id='stock_check_reason' class='form-control' placeholder="Set Stock Check Reason" value=''/>
</div>
</div>
<div class="form-group">
<div class="col-lg-10 col-md-10 col-sm-8 col-xs-7">
<!-- <label for="password_2">Item</label> -->
<select class='form-control' id='product_sku'>
<option value="">Select Product</option>
<% @inventory_definitions.each do |id| %>
<option value="<%= id.item_code %>">
<% menu_item = MenuItemInstance.find_by_item_instance_code(id.item_code) %>
<% if menu_item.nil? %>
<%= Product.find_by_item_code(id.item_code).name rescue "-" %>
<% else %>
<%= menu_item.menu_item.name rescue '-' %> - <%= menu_item.item_instance_name rescue '-' %>
<% end %>
</option>
<% end %>
</select>
</div>
</div>
<div class="form-group">
<div class="col-lg-10 col-md-10 col-sm-8 col-xs-7">
<!-- <label for="email_address_2">Qty</label> -->
<input type='text' class='form-control' placeholder="Qty" id='product_qty' value=''/>
</div>
</div>
<div class="col-md-7 col-lg-7 col-sm-7 m-t-10" >
<div class="card">
<div class="card-block" style="">
<div class="card-text" id="custom-slimscroll">
<div class="row menu_items_list" style="margin:0px 1px 0px 1px ;">
<!-- append data -->
</div>
</div>
</div>
</div>
</div>
<div class="col-md-3 col-lg-3 col-sm-3">
<button type="button" class="btn btn-lg btn-block btn-default waves-effect m-t-5" id='back'>
<i class="material-icons">reply</i>Back
</button>
<br>
<div class="card-block">
<div class="card-text" id="order-detail-slimscroll" data-height="140">
<table class="table table-striped summary-items" id="order-items-table" >
<thead>
<tr>
<th>#</th>
<th class="item-name">Items</th>
<th class="item-qty">QTY</th>
<th class="item-attr"></th>
</tr>
</thead>
<tbody class="font-13" >
</tbody>
</table>
</div>
</div>
<div class="card-footer">
<button type="button" class="btn btn-lg btn-block btn-primary waves-effect m-t-5" id='finish'>Finish
</button>
</div>
</div>
</div>
</div>
<div class="item-modal modal sx_item_detailModal" id="sx_item_detailModal" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="true">
<div class="modal-dialog custom-modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header" style="background-color: #54A5AF;padding-top:10px !important;">
<h4 class="modal-title" style="color:#fff;" id="title_name"></h4>
<button type="button" class="close" id="close" data-dismiss="modal" aria-hidden="true" style="font-size: 20px;color:#fff;">&times;</button>
</div>
<div class="modal-body">
<div class="form-group">
<div class="form-group">
<div class="col-md-4">
<button class="btn btn-primary form-control" id='save_to_stock_check'> Save</button>
</div>
<label class="control-label" for="attribute">Item</label>
<input type='text' id='item' class='form-control' readonly="true" value=''/>
</div>
<div class="form-group">
<label class="control-label" for="attribute">Qty</label>
<input type='text' class='form-control keypress_qty' placeholder="Qty" id='product_qty' value="1" />
</div>
<input type="hidden" id="instance_code" value="">
<input type="hidden" id="item_code" value="">
<input type="hidden" id="item_name" value="">
<input type="hidden" id="instance_name" value="">
<div class="form-group">
<label class="control-label" for="attribute">Stock Check Reason</label>
<input type='text' id='stock_check_reason' class='form-control' placeholder="Set Stock Check Reason" value=''/>
</div>
<div class="form-actions">
<button type="button" class="btn btn-primary" data-dismiss="modal" id="save_to_stock_check">Save</button>
<!-- <button type="button" class="btn btn-primary add_to_order " data-dismiss="modal" id="add_to_order">Add to Order<div class="ripple-container"></div></button> -->
</div>
</div>
</div>
</div>
</div>
</div>
<!-- Modal -->
<div class=" modal" id="sx_itemModal" tabindex="-1" role="dialog" aria-labelledby="sx_itemModalLabel" aria-hidden="true" style="">
<div class="modal-dialog custom-modal-dialog" role="document">
<div class="modal-content">
<div class="modal-body">
<table width="100%" class="table table-striped">
<thead>
<tr>
<th style="">Item Name</th>
<th style="">Quantity</th>
<th></th>
</tr>
</thead>
<tbody>
<tr>
<td class="item_name" id="modal-item-name"></td>
<td>
<input type="number" name="qty" class="form-control col-md-12 input-number" data-value="0" id="modal-qty" value="" min="1" max="10000">
</td>
<td>
<button type="button" id="remove" class="btn btn-danger" data-dismiss="modal">Remove</button>
</td>
</tr>
</tbody>
</table>
<div class="row bottom p-l-15 p-r-15 m-t-10">
<div class="col-md-3 cashier_number border-top border-left" data-value="1" data-type="num">1</div>
<div class="col-md-3 cashier_number border-top border-left" data-value="2" data-type="num">2</div>
<div class="col-md-3 cashier_number border-top border-left" data-value="3" data-type="num">3</div>
<div class="col-md-3 cashier_number border-top border-left" data-value="4" data-type="num">4</div>
</div>
<div class="row bottom p-l-15 p-r-15">
<div class="col-md-3 cashier_number border-top border-left" data-value="5" data-type="num">5</div>
<div class="col-md-3 cashier_number border-top border-left" data-value="6" data-type="num">6</div>
<div class="col-md-3 cashier_number border-top border-left" data-value="7" data-type="num">7</div>
<div class="col-md-3 cashier_number border-top border-left" data-value="8" data-type="num">8</div>
</div>
<div class="row bottom p-l-15 p-r-15">
<div class="col-md-3 cashier_number border-top border-left" data-value="9" data-type="num">9</div>
<div class="col-md-3 cashier_number border-top border-left" data-value="0" data-type="num">0</div>
<div class="col-md-3 cashier_number border-top border-left" data-value="00" data-type="num">00</div>
<div class="col-md-3 cashier_number border-top border-left bg-orange" data-type="clr">Clr</div>
</div>
</div>
<div class="modal-footer">
<div class="row">
<div class="col-md-5">
<button type="button" class="btn btn-default" data-dismiss="modal" id="close">Close</button>
</div>
<div class="col-md-5">
<button type="button" class="btn btn-primary " data-dismiss="modal" id="save">Update</button>
</div>
</div>
<div class="col-md-6">
<table class="table table-striped" id='stock_item'>
<tr>
<!--<th>#</th>-->
<th><%= t("views.right_panel.detail.product") %></th>
<th><%= t("views.right_panel.detail.balance") %></th>
<th><button class="btn btn-primary pull-right form-control" style='margin-bottom:2px;' id='finish'> <%= t("views.btn.finish") %></button></th>
</tr>
<!-- <tr>
<td colspan="3">
<button class="btn btn-primary pull-right form-control" style='margin-bottom:2px;' id='finish'> Finish</button></td>
</tr> -->
</table>
</div>
</div>
</div>
</div>
</div>
<div class="col-xs-12 col-sm-12 col-md-3 col-lg-3">
<div class="card">
<div class="body">
<h5><i class="material-icons md-18">view_headline <%= t("views.right_panel.header.page_detail") %></i> </h5>
<p>
1) <%= t("views.right_panel.detail.set_stock_check_reason") %> - <%= t("views.right_panel.detail.write_txt") %> <%= t("views.right_panel.detail.stock_check_reason_txt") %> <br>
2) <%= t("views.right_panel.detail.select") +" "+ t("views.right_panel.detail.product") %> - <%= t("views.right_panel.detail.select_txt") %> <%= t("views.right_panel.detail.product_txt") %> <br>
3) <%= t("views.right_panel.detail.qty") %> - <%= t("views.right_panel.detail.write_txt") %> <%= t("views.right_panel.detail.qty_txt") %> <br>
</p>
<h5><i class="material-icons md-18">list <%= t("views.right_panel.header.button_lists") %></i> </h5>
<p>
1) <%= t("views.btn.save") %> - <%= t("views.right_panel.detail.create_btn_txt") %> <%= t("views.right_panel.detail.stock_check_txt") %> <br>
2) <%= t("views.btn.finish") %> - <%= t("views.right_panel.detail.back_txt") %> <%= t("views.right_panel.detail.stock_check_txt") +" "+ t("views.right_panel.detail.detail_txt") %> <br>
</p>
<h5><i class="material-icons md-18">list <%= t("views.right_panel.header.link_lists") %></i> </h5>
<p>
1) <%= t("views.right_panel.button.home") %> - <%= t("views.right_panel.detail.home_txt") %> <br>
2) <%= t("views.right_panel.button.back") %> - <%= t("views.right_panel.detail.back_txt") %> <%= t("views.right_panel.detail.home_txt") %> <br>
</p>
</div>
</div>
</div>
</div>
<!-- Menu Item modal -->
<style type="text/css">
.fadeInRight{
-webkit-animation-duration: 350ms !important;
}
</style>
<script>
jQuery(function(){
id = "<%=@category[0].id%>";
console.log(id)
jQuery('.first_46').click();
});
$(document).ready(function () {
var count = 0;
$(document).ready(function(){
clearFormData();
//click menu sidebar menu category
$(document).on('click', '.menu_category', function(e){
e.preventDefault();
$('.sub_category_list').addClass("hidden");
var menu_id = $(this).attr("data-id");
var url = "/inventory/get_menu_category/"+menu_id;
show_menu_item_list(url,menu_id);
});
//End menu category Click
//show menu item list when click menu category
function show_menu_item_list(url_item,menu_id){
var menu_list = $('.menu_items_list');
menu_list.empty();
//Start Ajax
$.ajax({
type: "GET",
url: url_item,
data: {},
dataType: "json",
success: function(data) {
var menu_items_list = $('.menu_items_list');
menu_items_list.empty();
menu_items = data.menu_items;
console.log(menu_items)
show_menu_list(menu_items);
}
});
//end Ajax
}
//end show list function
function show_menu_list(items) {
var menu_list = $('.menu_items_list');
menu_list.empty();
for(var i in items) {
fa_plus = 'material-icons';
add = 'view_list'
menu_item_box = 'menu_item_box';
data_target = 'sx_item_detailModal';
data_modal = ''
add_icon = "add_icon"
if (items[i].image) {
image_path = items[i].image;
}else{
image_path = "image/logo.png";
}
row = '<div class="col-md-3">'
+'<div class="card custom-card testimonial-card fadeInRight card-box"'
+'item_name="'+items[i]["item_name"]+'"'
+'item_code="'+items[i]["item_code"]+'"'
+'instance_name="'+items[i]["instance_name"]+'" '
+'instance_code="'+items[i]["instance_code"]+'"'
+'data-toggle="modal" data-target=".'+data_target+'" '
+'style="height:100%;background-image:url(../../'+image_path+');background-repeat: no-repeat;">'
+'<div class="custom-card-head card-head row" style="line-height:14px;margin:0px;" style="">'
+'<div class="col-md-10 " style="padding:0px !important;">'+ items[i]["item_name"] +"-" +items[i]["instance_name"]+'</div>'
+"<div class='col-md-2 "+menu_item_box+" ' style='padding:0px 5px 0px 5px'>"
+"<i class='m-l--5 fa "+fa_plus+" '>"
+add+ '</i>'
+'</div>'
+'</div>'
+"<div class='"+add_icon+" p-t-65 m-r-' >"
+'</div>'
+'</div>';
$('.menu_items_list').append(row);
}
}
//click item row for add order
$(document).on('click', '.card-box', function(event){
$("#product_qty").val(1);
$('#product_qty').empty();
$("#stock_check_reason").val('');
$('#item_code').val($(this).attr('item_code'));
$('#instance_code').val($(this).attr('instance_code'));
$('#item').val($(this).attr('item_name')+"-"+$(this).attr('instance_name'));
$('#instance_name').val($(this).attr('instance_name'));
$('#item_name').val($(this).attr('item_name'));
});
function clearFormData(){
$('#stock_check_reason').val("");
$('#product_qty').val("");
$('#product_sku').val("");
}
$('#save_to_stock_check').on('click', function () {
count += 1;
product_sku = $('#product_sku').val();
product_qty = $('#product_qty').val();
product_name = $("#product_sku").find("option:selected").text();
if ($("#product_qty").val()>0) {
item_name = $('#item_name').val();
instance_name = $('#instance_name').val();
product_qty = $('#product_qty').val();
product_name = $("#item").val();
// clearFormData();
item_code = $("#item_code").val();
instance_code = $("#instance_code").val();
var tr = '<tr>'
//+ '<td>' + count + '</td>'
+ '<td><input type=hidden value="' + product_sku + '" id="item_sku_' + count + '" name=' + count + '/>'
+ product_name + '</td>'
+ '<td><input type=text value="' + product_qty + '" class="form-control col-md-9" id="item_qty_' + count + '" name=' + count + '/></td>'
+ '<td><input type=button value="X" class="btn btn-danger p-l-15 p-r-15" id="item_remove_' + count + '" name=' + count + ' onclick="remove_row('+ count +')"/></td>'
+ '</tr>';
$('#stock_item').append(tr);
// $('#product_sku').val('');
$('#product_qty').val('');
reason = $("#stock_check_reason").val();
var rowCount = $('.summary-items tbody tr').length+1;
row ="<tr class='item_box' data-toggle='modal' data-target='#sx_itemModal' 'data-code ='"
+item_code+ "' data-instance-code='"+instance_code+"' data-row ='"+rowCount+ "' data-reason ='"+reason+ "'>"
+'<td class="item-cell-no">'+rowCount+'</td>'
+'<td class="item-cell-name" id="item_name" >' + item_name+ ' ' + instance_name +'</td>'
+'<td class="item-cell-qty" id="item_qty">' + product_qty + '</td>'
+'<td class="" id="remove"><i class="material-icons" id="remove_row" style="cursor:pointer;">delete_forever</i></td>'
+'</tr>';
$(".summary-items tbody").append(row);
}else{
swal("Opps", "Please enter number for qty ","warning");
}
});
//click item row for update qty
$('.summary-items').on('click', '.item_box', function(){
$(this).attr('data-active',true);
name = $(this).children('#item_name').text();
qty = $(this).children('#item_qty').text();
$('#modal-item-name').text(name);
$('#modal-qty').val(qty);
});
//click remove buttom in modal box
$('#sx_itemModal').on('click','#remove', function(){
$('.summary-items tr').filter(function(){
if ($(this).attr('data-active') == 'true'){
$(this).remove();
}
});
});
//click close
$('#sx_itemModal').on('click','#close', function(){
$(".item_box").removeAttr("data-active");
});
//click save buttom after change qty
$('#sx_itemModal').on('click','#save', function(){
if ($('#modal-qty').val()>0) {
summary_items_filter();
}else{
swal("Opps", "Please enter number for qty ","warning");
}
});
// $(document).on('click', '#remove_row', function(event){
// console.log( $(this).parent().parent())
// $($(this).parent().parent()).attr('data-active',true);
// $('.summary-items tr').filter(function(){
// if ($(this).attr('data-active') == 'true'){
// $(this).remove();
// }
// });
// });
$(".keypress_qty").on('keyup change', function (){
value = $(this).val();
if ($.isNumeric(value)) {
$('#product_qty').val(value);
}else{
swal("Opps","Please enter number for qty","warning");
}
});
$('#finish').on('click', function () {
var reason = $('#stock_check_reason').val();
var arr = [];
var jsonStr = '';
for (var i = 1; i <= count; i++) {
itemname = $('#item_sku_' + i).val();
itemqty = $('#item_qty_' + i).val();
if(itemname !== undefined){
arr.push({sku: itemname, qty: itemqty});
}
jsonStr = JSON.stringify(arr);
}
var jsonStr = JSON.stringify(get_order_item_rows());
console.log(jsonStr);
$.ajax({
type: 'Post',
url: '<%= inventory_stock_check_save_path %>',
data: 'stock_item=' + jsonStr + '&reason=' + reason,
success: function (data) {
window.location.href = '/inventory/stock_checks/' + data['stock_id'];
}
})
if (jsonStr) {
$.ajax({
type: 'Post',
url: '<%= inventory_stock_check_save_path %>',
data: 'stock_item=' + jsonStr + '&reason=' + reason,
success: function (data) {
if (data['stock_id']) {
check_id = data['stock_id'];
$.ajax({
type: 'post',
url: '<%= inventory_save_to_journal_path %>',
data: 'data=' + check_id,
success: function () {
swal({
title: "Information!",
text: "Successfully saved to journal",
html: true,
closeOnConfirm: false,
closeOnCancel: false,
allowOutsideClick: false
}, function () {
// window.location.href = '/inventory';
window.location.href = '/inventory/stock_checks/' + check_id;
});
}
})
// window.location.href = '/inventory/stock_checks/' + data['stock_id'];
}
}
})
}else{
swal("Opps","Please add item ","warning");
}
});
function remove_row(row) {
$("#item_remove_"+row).parent().parent().remove();
$(document).on('click', '.cashier_number', function(event){
if(event.handled !== true) {
var original_value;
original_value = $('#modal-qty').attr('data-value');
original_qty = $('#modal-qty').val();
var input_type = $(this).attr("data-type");
switch (input_type) {
case 'num':
var input_value = $(this).attr("data-value");
if (original_value == "0"){
$('#modal-qty').val(input_value);
$('#modal-qty').attr('data-value',input_value);
// update_total_amount();
}else{
$('#modal-qty').val(original_qty + input_value);
$('#modal-qty').attr('data-value',original_qty + input_value);
// update_total_amount();
}
break;
case 'add':
case 'del' :
case 'clr':
$('#modal-qty').val(1);
$('#modal-qty').attr('data-value',0);
// update_total_amount();
break;
}
event.handled = true;
} else {
return false;
}
});
$("#back").on("click", function(){
window.location.href = "/inventory";
});
function summary_items_filter(){
$('.summary-items tr').filter(function(){
if ($(this).attr('data-active') == 'true'){
qty = $('#modal-qty').val();
price = parseFloat($(this).attr('data-price'));
total_price = parseFloat(price*qty).toFixed(2);
$(this).find('#item_qty').text(qty);
$(this).find('.item-cell-price').text(total_price);
$(this).removeAttr('data-active');
}
});
}
</script>
/* Get Item rows */
function get_order_item_rows(){
var items = [];
var item_row = $('.summary-items tbody tr');
$(item_row).each(function(i){
var item_list = {};
item_list.remark = $(item_row[i]).attr('data-reason');
item_list.sku = $(item_row[i]).attr('data-instance-code');
item_list.qty = $(item_row[i]).children('#item_qty').text();
items.push(item_list);
});
return items;
}
});
</script>

View File

@@ -44,28 +44,28 @@
<table class="table table-striped col-md-12">
<tr>
<th>#</th>
<th><%= t("views.right_panel.header.menu_category") %></th>
<th><%= t("views.right_panel.detail.product") %></th>
<th><%= t("views.right_panel.detail.stock_count") %></th>
<th><%= t("views.right_panel.detail.stock_balance") %></th>
<th><%= t("views.right_panel.detail.different") %></th>
<th><%= t("views.right_panel.detail.remark") %></th>
</tr>
<% cate_arr = Array.new %>
<%
count = 0
@check.stock_check_items.each do |item|
@stock_check_items.each do |item|
count += 1
%>
<tr>
<td><%= count %></td>
<td>
<% menu_item = MenuItemInstance.find_by_item_instance_code(item.item_code)%>
<% if menu_item.nil? %>
<%= Product.find_by_item_code(item.item_code).name rescue "-" %>
<% else %>
<%= menu_item.menu_item.name rescue "-" %>
- <%= menu_item.item_instance_name rescue "-" %>
<% end %>
</td>
<% if !cate_arr.include?(item.menu_category_id) %>
<td><%= item.menu_category_name %></td>
<% cate_arr.push(item.menu_category_id) %>
<% else %>
<td>&nbsp;</td>
<% end %>
<td><%= item.item_name rescue '-' %> - <%= item.instance_name%></td>
<td><%= item.stock_count %></td>
<td><%= item.stock_balance %></td>
<td><%= item.different %></td>
@@ -79,7 +79,7 @@
<div class="col-xs-12 col-sm-12 col-md-2 col-lg-2">
<div class="body">
<button id="save_to_journal" type="button" class="btn btn-block btn-primary"> <%= t("views.right_panel.button.save_to_journal") %></button>
<!-- <button id="save_to_journal" type="button" class="btn btn-block btn-primary"> <%= t("views.right_panel.button.save_to_journal") %></button> -->
<button id="print" type="button" class="btn btn-block btn-primary"> <%= t :print %></button>
</div>

View File

@@ -70,6 +70,12 @@
</p>
</li>
<% end %>
<li>
<p class="waves-effect waves-block p-l-30 m-b-5 team_viewer">
<i class="material-icons font-7 logout_icon shopinfo">touch_app</i>
<span class="font-15 shopinfo" >Team Viewer</span>
</p>
</li>
<li>
<!-- <p class="delete waves-effect waves-block p-l-30 m-b-5" data-ref="<%=logout_path%>" data-method="delete">
<i class="material-icons font-10 logout_icon">exit_to_app</i>
@@ -130,6 +136,22 @@
$('.order_no').addClass("order-badge");
$('.order_no').html(parseInt(getOnlineOrderCount()));
}
$(".team_viewer").on('click',function(){
// /opt/teamviewer/tv_bin/script/teamviewer
$.ajax({
type: "POST",
data: {},
dataType: 'json',
url: "/run_teamviewer",
success: function(data){
if(!data.status){
window.open('https://www.teamviewer.com', '_blank');
return false;
}
}
});
});
});
</script>

View File

@@ -72,7 +72,7 @@
</div>
</div>
</div>
<div class="row bg-white">
<div class="row bg-white box">
<div class="col-xs-6 col-sm-6 col-md-6 col-lg-6 p-t-20 p-l-10 p-r-10 p-b-50 bg-white">
<div class="row justify-content-center form-group">
<input type="text" class="form-control col-4" id="emp_id" placeholder="Employee ID">
@@ -129,7 +129,7 @@
<div class="tab-pane" id="<%=role%>" role="tabpanel" style="max-height:; overflow:auto">
<% @employees.each do |employee| %>
<%if employee.role == role %>
<div class="col-xs-4 col-sm-4 col-md-4 col-lg-4 empBtn" data-formid="#form_<%= employee.emp_id %>" style="float: left;">
<div class="col-xs-3 col-sm-3 col-md-3 col-lg-3 empBtn" data-formid="#form_<%= employee.emp_id %>" style="float: left;">
<form id="form_<%= employee.emp_id %>" action="<%= emp_login_path(employee.emp_id) %>" method="PATCH">
</form>
<%if employee.image_path.present? %>

Some files were not shown because too many files have changed in this diff Show More