update add order

This commit is contained in:
Aung Myo
2017-08-17 09:54:19 +06:30
202 changed files with 7514 additions and 2844 deletions

3
.gitignore vendored
View File

@@ -51,3 +51,6 @@ dump.rdb
# Fonts
public/fonts/*
# Ruby-Mine IDE folder
/.idea

2
.idea/.generators generated
View File

@@ -5,4 +5,4 @@ You are allowed to:
2. Remove generators
3. Add installed generators
To add new installed generators automatically delete this file and reload the project.
--><GeneratorsGroup><Generator name="active_record:migration" /><Generator name="active_record:model" /><Generator name="active_record:observer" /><Generator name="active_record:session_migration" /><Generator name="controller" /><Generator name="erb:controller" /><Generator name="erb:mailer" /><Generator name="erb:scaffold" /><Generator name="generator" /><Generator name="helper" /><Generator name="integration_test" /><Generator name="mailer" /><Generator name="metal" /><Generator name="migration" /><Generator name="model" /><Generator name="model_subclass" /><Generator name="observer" /><Generator name="performance_test" /><Generator name="plugin" /><Generator name="resource" /><Generator name="scaffold" /><Generator name="scaffold_controller" /><Generator name="session_migration" /><Generator name="stylesheets" /><Generator name="test_unit:controller" /><Generator name="test_unit:helper" /><Generator name="test_unit:integration" /><Generator name="test_unit:mailer" /><Generator name="test_unit:model" /><Generator name="test_unit:observer" /><Generator name="test_unit:performance" /><Generator name="test_unit:plugin" /><Generator name="test_unit:scaffold" /></GeneratorsGroup></Settings>
--><GeneratorsGroup><Generator name="assets" /><Generator name="cancan:ability" /><Generator name="channel" /><Generator name="coffee:assets" /><Generator name="controller" /><Generator name="factory_girl:model" /><Generator name="generator" /><Generator name="helper" /><Generator name="integration_test" /><Generator name="jbuilder" /><Generator name="job" /><Generator name="js:assets" /><Generator name="kaminari:config" /><Generator name="kaminari:views" /><Generator name="mailer" /><Generator name="migration" /><Generator name="model" /><Generator name="resource" /><Generator name="rspec:controller" /><Generator name="rspec:feature" /><Generator name="rspec:helper" /><Generator name="rspec:install" /><Generator name="rspec:integration" /><Generator name="rspec:job" /><Generator name="rspec:mailer" /><Generator name="rspec:model" /><Generator name="rspec:observer" /><Generator name="rspec:request" /><Generator name="rspec:scaffold" /><Generator name="rspec:view" /><Generator name="scaffold" /><Generator name="scaffold_controller" /><Generator name="sidekiq:worker" /><Generator name="simple_form:install" /><Generator name="system_test" /><Generator name="task" /><Generator name="test_unit:controller" /><Generator name="test_unit:generator" /><Generator name="test_unit:helper" /><Generator name="test_unit:integration" /><Generator name="test_unit:job" /><Generator name="test_unit:mailer" /><Generator name="test_unit:model" /><Generator name="test_unit:plugin" /><Generator name="test_unit:scaffold" /><Generator name="test_unit:system" /></GeneratorsGroup></Settings>

2
.idea/.rakeTasks generated

File diff suppressed because one or more lines are too long

28
.idea/sxrestaurant.iml generated
View File

@@ -124,14 +124,14 @@
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" scope="PROVIDED" name="actioncable (v5.1.1, rbenv: 2.3.3) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="actionmailer (v5.1.1, rbenv: 2.3.3) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="actionpack (v5.1.1, rbenv: 2.3.3) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="actionview (v5.1.1, rbenv: 2.3.3) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="activejob (v5.1.1, rbenv: 2.3.3) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="activemodel (v5.1.1, rbenv: 2.3.3) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="activerecord (v5.1.1, rbenv: 2.3.3) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="activesupport (v5.1.1, rbenv: 2.3.3) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="actioncable (v5.1.3, rbenv: 2.3.3) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="actionmailer (v5.1.3, rbenv: 2.3.3) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="actionpack (v5.1.3, rbenv: 2.3.3) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="actionview (v5.1.3, rbenv: 2.3.3) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="activejob (v5.1.3, rbenv: 2.3.3) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="activemodel (v5.1.3, rbenv: 2.3.3) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="activerecord (v5.1.3, rbenv: 2.3.3) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="activesupport (v5.1.3, rbenv: 2.3.3) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="arel (v8.0.0, rbenv: 2.3.3) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="autoprefixer-rails (v7.1.1.2, rbenv: 2.3.3) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="bcrypt (v3.1.11, rbenv: 2.3.3) [gem]" level="application" />
@@ -142,6 +142,7 @@
<orderEntry type="library" scope="PROVIDED" name="bundler (v1.14.6, rbenv: 2.3.3) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="byebug (v9.0.6, rbenv: 2.3.3) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="cancancan (v1.17.0, rbenv: 2.3.3) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="chronic (v0.10.2, rbenv: 2.3.3) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="coffee-rails (v4.2.2, rbenv: 2.3.3) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="coffee-script (v2.4.1, rbenv: 2.3.3) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="coffee-script-source (v1.12.2, rbenv: 2.3.3) [gem]" level="application" />
@@ -150,7 +151,7 @@
<orderEntry type="library" scope="PROVIDED" name="cups (v0.0.7, rbenv: 2.3.3) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="database_cleaner (v1.6.1, rbenv: 2.3.3) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="diff-lcs (v1.3, rbenv: 2.3.3) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="erubi (v1.6.0, rbenv: 2.3.3) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="erubi (v1.6.1, rbenv: 2.3.3) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="execjs (v2.7.0, rbenv: 2.3.3) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="factory_girl (v4.8.0, rbenv: 2.3.3) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="factory_girl_rails (v4.8.0, rbenv: 2.3.3) [gem]" level="application" />
@@ -160,7 +161,7 @@
<orderEntry type="library" scope="PROVIDED" name="font-awesome-rails (v4.7.0.2, rbenv: 2.3.3) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="globalid (v0.4.0, rbenv: 2.3.3) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="httparty (v0.15.5, rbenv: 2.3.3) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="i18n (v0.8.4, rbenv: 2.3.3) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="i18n (v0.8.6, rbenv: 2.3.3) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="jbuilder (v2.7.0, rbenv: 2.3.3) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="jquery-rails (v4.3.1, rbenv: 2.3.3) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="jquery-ui-rails (v6.0.1, rbenv: 2.3.3) [gem]" level="application" />
@@ -175,7 +176,7 @@
<orderEntry type="library" scope="PROVIDED" name="mime-types (v3.1, rbenv: 2.3.3) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="mime-types-data (v3.2016.0521, rbenv: 2.3.3) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="mini_portile2 (v2.2.0, rbenv: 2.3.3) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="minitest (v5.10.2, rbenv: 2.3.3) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="minitest (v5.10.3, rbenv: 2.3.3) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="multi_json (v1.12.1, rbenv: 2.3.3) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="multi_xml (v0.6.0, rbenv: 2.3.3) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="mysql2 (v0.4.6, rbenv: 2.3.3) [gem]" level="application" />
@@ -190,10 +191,10 @@
<orderEntry type="library" scope="PROVIDED" name="rack-cors (v0.4.1, rbenv: 2.3.3) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="rack-protection (v2.0.0, rbenv: 2.3.3) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="rack-test (v0.6.3, rbenv: 2.3.3) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="rails (v5.1.1, rbenv: 2.3.3) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="rails (v5.1.3, rbenv: 2.3.3) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="rails-dom-testing (v2.0.3, rbenv: 2.3.3) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="rails-html-sanitizer (v1.0.3, rbenv: 2.3.3) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="railties (v5.1.1, rbenv: 2.3.3) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="railties (v5.1.3, rbenv: 2.3.3) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="rake (v12.0.0, rbenv: 2.3.3) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="rb-fsevent (v0.9.8, rbenv: 2.3.3) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="rb-inotify (v0.9.10, rbenv: 2.3.3) [gem]" level="application" />
@@ -228,6 +229,7 @@
<orderEntry type="library" scope="PROVIDED" name="web-console (v3.5.1, rbenv: 2.3.3) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="websocket-driver (v0.6.5, rbenv: 2.3.3) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="websocket-extensions (v0.1.2, rbenv: 2.3.3) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="whenever (v0.9.7, rbenv: 2.3.3) [gem]" level="application" />
</component>
<component name="RModuleSettingsStorage">
<LOAD_PATH number="0" />

900
.idea/workspace.xml generated

File diff suppressed because it is too large Load Diff

View File

@@ -36,6 +36,9 @@ gem 'tether-rails'
gem "font-awesome-rails"
gem 'rack-cors'
# image upload
gem 'carrierwave', '~> 1.0'
#Report and Printing gems
gem 'cups', '~> 0.0.7'
gem 'prawn'

View File

@@ -1,39 +1,39 @@
GEM
remote: https://rubygems.org/
specs:
actioncable (5.1.1)
actionpack (= 5.1.1)
actioncable (5.1.3)
actionpack (= 5.1.3)
nio4r (~> 2.0)
websocket-driver (~> 0.6.1)
actionmailer (5.1.1)
actionpack (= 5.1.1)
actionview (= 5.1.1)
activejob (= 5.1.1)
actionmailer (5.1.3)
actionpack (= 5.1.3)
actionview (= 5.1.3)
activejob (= 5.1.3)
mail (~> 2.5, >= 2.5.4)
rails-dom-testing (~> 2.0)
actionpack (5.1.1)
actionview (= 5.1.1)
activesupport (= 5.1.1)
actionpack (5.1.3)
actionview (= 5.1.3)
activesupport (= 5.1.3)
rack (~> 2.0)
rack-test (~> 0.6.3)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.2)
actionview (5.1.1)
activesupport (= 5.1.1)
actionview (5.1.3)
activesupport (= 5.1.3)
builder (~> 3.1)
erubi (~> 1.4)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.3)
activejob (5.1.1)
activesupport (= 5.1.1)
activejob (5.1.3)
activesupport (= 5.1.3)
globalid (>= 0.3.6)
activemodel (5.1.1)
activesupport (= 5.1.1)
activerecord (5.1.1)
activemodel (= 5.1.1)
activesupport (= 5.1.1)
activemodel (5.1.3)
activesupport (= 5.1.3)
activerecord (5.1.3)
activemodel (= 5.1.3)
activesupport (= 5.1.3)
arel (~> 8.0)
activesupport (5.1.1)
activesupport (5.1.3)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (~> 0.7)
minitest (~> 5.1)
@@ -51,6 +51,10 @@ GEM
builder (3.2.3)
byebug (9.0.6)
cancancan (1.17.0)
carrierwave (1.1.0)
activemodel (>= 4.0.0)
activesupport (>= 4.0.0)
mime-types (>= 1.16)
chronic (0.10.2)
coffee-rails (4.2.2)
coffee-script (>= 2.2.0)
@@ -64,7 +68,7 @@ GEM
cups (0.0.7)
database_cleaner (1.6.1)
diff-lcs (1.3)
erubi (1.6.0)
erubi (1.6.1)
execjs (2.7.0)
factory_girl (4.8.0)
activesupport (>= 3.0.0)
@@ -81,7 +85,7 @@ GEM
activesupport (>= 4.2.0)
httparty (0.15.5)
multi_xml (>= 0.5.2)
i18n (0.8.4)
i18n (0.8.6)
jbuilder (2.7.0)
activesupport (>= 4.2.0)
multi_json (>= 1.2)
@@ -115,7 +119,7 @@ GEM
mime-types-data (~> 3.2015)
mime-types-data (3.2016.0521)
mini_portile2 (2.2.0)
minitest (5.10.2)
minitest (5.10.3)
multi_json (1.12.1)
multi_xml (0.6.0)
mysql2 (0.4.6)
@@ -136,26 +140,26 @@ GEM
rack
rack-test (0.6.3)
rack (>= 1.0)
rails (5.1.1)
actioncable (= 5.1.1)
actionmailer (= 5.1.1)
actionpack (= 5.1.1)
actionview (= 5.1.1)
activejob (= 5.1.1)
activemodel (= 5.1.1)
activerecord (= 5.1.1)
activesupport (= 5.1.1)
bundler (>= 1.3.0, < 2.0)
railties (= 5.1.1)
rails (5.1.3)
actioncable (= 5.1.3)
actionmailer (= 5.1.3)
actionpack (= 5.1.3)
actionview (= 5.1.3)
activejob (= 5.1.3)
activemodel (= 5.1.3)
activerecord (= 5.1.3)
activesupport (= 5.1.3)
bundler (>= 1.3.0)
railties (= 5.1.3)
sprockets-rails (>= 2.0.0)
rails-dom-testing (2.0.3)
activesupport (>= 4.2.0)
nokogiri (>= 1.6)
rails-html-sanitizer (1.0.3)
loofah (~> 2.0)
railties (5.1.1)
actionpack (= 5.1.1)
activesupport (= 5.1.1)
railties (5.1.3)
actionpack (= 5.1.3)
activesupport (= 5.1.3)
method_source
rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0)
@@ -250,6 +254,7 @@ DEPENDENCIES
bootstrap-datepicker-rails
byebug
cancancan (~> 1.10)
carrierwave (~> 1.0)
coffee-rails (~> 4.2)
cups (~> 0.0.7)
database_cleaner
@@ -288,4 +293,4 @@ DEPENDENCIES
whenever
BUNDLED WITH
1.15.1
1.15.3

View File

@@ -23,8 +23,90 @@ $(document).ready(function(){
// setTimeout(function(){
// window.location.reload(1);
// }, 10000);
$(".nav-completed").on("click", function(){
$("#completed").removeClass('hide')
$(".oqs_append").addClass('hide')
});
$('.queue_station').on('click',function(){
$(".oqs_click").on("click", function(){
$("#completed").addClass('hide')
$(".oqs_append").removeClass('hide')
var oqs_id = $(this).find(".oqs-id").text();
var url = 'oqs/get_items/'+oqs_id;
show_details(url);
}); //End Click
function show_details(url){
var oqs_append = $('.oqs_append');
oqs_append.empty();
var filter = $('.filter').text();
//Start Ajax
$.ajax({
type: "GET",
url: url,
data: {'filter':filter},
dataType: "json",
success: function(data) {
for(var field in data) {
var price = parseFloat(data[field].price).toFixed(2);
if (data[field]["options"] == "[]") {
var options = "";
}else{
var options = data.options;
}
var date = new Date(data[field]["created_at"]);
var show_date = date.getDate() + "-" + date.getMonth() + "-" + date.getFullYear() + ' ' + date.getHours()+ ':' + date.getMinutes();
row ='<div class="card queue_station">'
+'<div class="card-block">'
+'<h4 class="card-title">'
+'<span class="order-zone-type">'+data[field]["table_type"]+'- </span>'
+'<span class="order-zone">'+ data[field]["zone"] +'</span>'
+'<small class="pull-right">'+ data[field]["order_id"] +'- </small>'
+'</h4>'
+'<h4>'
+'<span class="order-item">'+ data[field]["item_name"] +'- </span>'
+'<span class="order-qty">'+ data[field]["qty"] +'- </span>'
+'</h4>'
+'<p class="card-text item-options">'+ options +'</p>'
+'<p class="card-text">'
+'<small class="text-muted">Order at'
+'<span class="order-at">'+ show_date +'</span> - '
+'<span class="order-by">'+ data[field]["item_order_by"] +'</span> '
+'</small> '
+'</p>'
+'<p class="hidden order-customer">'+ data[field]["customer_name"] +'</p> '
+'<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"]+'" 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>'
+'</div>';
$('.oqs_append').append(row);
}
}
});
//end Ajax
}
$(document).on('click', '.queue_station', function(event){
var orderZone=$(this).children().children().children('.order-zone').text().trim();
// var orderItem=$(this).children().children().children('.order-item').text();
var assigned_item_id = $(this).children().find(".assigned-order-item").text();
@@ -41,7 +123,6 @@ $(document).ready(function(){
$('#order-from').text(orderZone);
// clear order items
$("#oqs-order-details-table").children("tbody").empty();
// Call get_order_items() for Order Items by dining
$.ajax({
type: 'GET',
@@ -68,19 +149,20 @@ $(document).ready(function(){
$(this).addClass('selected-item');
});
$(".order-item-edit").on('click', function(){
$(document).on('click', '.order-item-edit', function(event){
var _self = $(this); // To know in ajax return
var assigned_item_id=$(this).attr('id').substr(5);
window.location.href = '/oqs/'+ assigned_item_id + "/edit"
});
// complete for queue item
$('.order-complete').on('click',function(e){
$(document).on('click', '.order-complete', function(event){
//e.preventDefault();
var _self = $(this); // To know in ajax return
var assigned_item_id=$(this).attr('id').substr(15);
var params = { 'id':assigned_item_id };
// Call update_delivery_status() for changed delivery and move to delivery
$.ajax({
type: 'POST',
@@ -117,10 +199,11 @@ $(document).ready(function(){
});
// Print Order Item
$('#print_order_item').on('click',function(){
$(document).on('click', '#print_order_item', function(event){
var assigned_item_id = $('.selected-item').children('.card-block').children('.assigned-order-item').text();
var options = $('.selected-item').children('.card-block').find('.item-options').text();
var params = { 'options':options };
$.ajax({
type: 'GET',
url: '/oqs/print/print/'+assigned_item_id,
@@ -129,7 +212,8 @@ $(document).ready(function(){
});
// Print Order Summary
$('#print_order_summary').on('click',function(){
// $('#print_order_summary').on('click',function(){
$(document).on('click', '#print_order_summary', function(event){
var table_name=$('.selected-item').children().children().children('.order-zone').text().trim();
var assigned_item_id=$('.selected-item').children('.card-block').children('.assigned-order-item').text();
var params = { 'table_name':table_name };

View File

@@ -20,13 +20,47 @@
//= require jquery-ui
//= require bootstrap-datepicker
$(document).on("focus", "[data-behaviour~='datepicker']", function(e){
$(document).on('turbolinks:load', function() {
$('.datepicker').datepicker({
format : 'dd-mm-yyyy',
autoclose: true
});
$('.datepicker').attr('ReadOnly','true');
$('.datepicker').css('cursor','pointer');
// Image Upload
$("#simple_menu_item_image_path").fileinput({
previewFileType: "image",
allowedFileExtensions: ["jpg", "gif", "png"],
browseClass: "btn btn-success",
browseLabel: "Pick Image",
browseIcon: "<i class=\"fa fa-image\"></i> ",
removeClass: "btn btn-danger",
removeLabel: "Delete",
removeIcon: "<i class=\"fa fa-trash\"></i> ",
showUpload: false,
// uploadClass: "btn btn-info",
// uploadLabel: "Upload",
// uploadIcon: "<i class=\"fa fa-upload\"></i> ",
previewTemplates: {
image: '<div class="file-preview-frame" id="{previewId}" data-fileindex="{fileindex}">\n' +
' <img src="{data}" class="file-preview-image" title="{caption}" alt="{caption}" style="width: 200px;height: 200px;">\n' +
'</div>\n',
}
});
});
$(document).on("focus", "[data-behaviour~='datepicker']", function(e){
$(this).datepicker({"format": "yyyy-M-dd", "weekStart": 1, "autoclose": true});
$('.dropdown-toggle').dropdown();
$('.dropdown-toggle').dropdown();
});
function export_to(path)
{
var form_params = $("#frm_report").serialize();
window.location = path+"?"+ form_params;
var form_params = $("#frm_report").serialize();
window.location = path+"?"+ form_params;
}

View File

@@ -0,0 +1,3 @@
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://coffeescript.org/

12
app/assets/javascripts/fileinput.min.js vendored Executable file

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,3 @@
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://coffeescript.org/

View File

@@ -0,0 +1,3 @@
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://coffeescript.org/

View File

@@ -76,3 +76,5 @@ select.form-control {
}
/*--- Reset --- */

View File

@@ -0,0 +1,3 @@
// Place all the styles related to the dining_charges controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/

12
app/assets/stylesheets/fileinput.min.css vendored Executable file

File diff suppressed because one or more lines are too long

View File

@@ -26,7 +26,34 @@ ul.dropdown-menu li a{
background-color: transparent !important;
margin-bottom: 0px !important;
}
.page-header{
border-bottom :0px solid #000 !important;
margin :0px !important;
}
}
.center-text {
text-align:center;
background-color:#ddd;
}
.footer {
position: fixed;
bottom: 0;
left: 0;
height: auto;
background-color: #ef404a;
width: 100%;
}
.footer-header {
color : #ef404a;
font-weight:bold;
font-style:italic;
margin-bottom:0px;
}
.menu-item-img {
margin: 10px;
text-align: center;
}

View File

@@ -0,0 +1,3 @@
// Place all the styles related to the Settings/ItemSets controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/

View File

@@ -0,0 +1,3 @@
// Place all the styles related to the Settings/Menu_item_sets controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/

View File

@@ -17,6 +17,8 @@ class Crm::CustomersController < BaseCrmController
@crm_customer = Customer.new
@count_customer = Customer.count_customer
@taxes = TaxProfile.all.order("order_by asc")
# if flash["errors"]
# @crm_customer.valid?
# end
@@ -63,16 +65,21 @@ class Crm::CustomersController < BaseCrmController
# GET /crm/customers/1/edit
def edit
@customer = Customer.find(params[:id])
end
# POST /crm/customers
# POST /crm/customers.json
def create
def create
# Remove "" default first
params[:customer][:tax_profiles].delete_at(0)
@crm_customers = Customer.new(customer_params)
respond_to do |format|
if @crm_customers.save
# update tax profile
customer = Customer.find(@crm_customers.customer_id)
customer.update_attributes(tax_profiles: params[:customer][:tax_profiles])
name = customer_params[:name]
phone = customer_params[:contact_no]
email = customer_params[:email]
@@ -81,7 +88,7 @@ class Crm::CustomersController < BaseCrmController
nrc = customer_params[:nrc_no]
card_no = customer_params[:card_no]
paypar_account_no = customer_params[:paypar_account_no]
member_group_id = params[:member_group_id]
member_group_id = params[:member_group_id]
if member_group_id.present?
membership = MembershipSetting.find_by_membership_type("paypar_url")
@@ -90,13 +97,24 @@ class Crm::CustomersController < BaseCrmController
auth_token = memberaction.auth_token.to_s
url = membership.gateway_url.to_s + memberaction.gateway_url.to_s
member_params = { name: name,phone: phone,email: email,
dob: dob,address: address,nrc:nrc,card_no:card_no,
member_group_id: member_group_id,
merchant_uid:merchant_uid,auth_token:auth_token}.to_json
# Check for paypar account exists
# if paypar_account_no != nil || paypar_account_no != ''
if paypar_account_no.present?
member_params = { name: name,phone: phone,email: email,
dob: dob,address: address,nrc:nrc,card_no:card_no,
paypar_account_no: paypar_account_no,
member_group_id: member_group_id,
merchant_uid:merchant_uid,auth_token:auth_token}.to_json
end
begin
response = HTTParty.post(url,
:body => {name: name,phone: phone,email: email,
dob: dob,address: address,nrc:nrc,card_no:card_no,
paypar_account_no: paypar_account_no,
member_group_id: member_group_id,
merchant_uid:merchant_uid,auth_token:auth_token}.to_json,
:body => member_params,
:headers => {
'Content-Type' => 'application/json',
'Accept' => 'application/json'
@@ -128,8 +146,25 @@ class Crm::CustomersController < BaseCrmController
end
# format.json { render :index, status: :created, location: @crm_customers }
else
customer = Customer.find(@crm_customers.customer_id)
status = customer.update_attributes(membership_type:member_group_id )
customer = Customer.find(@crm_customers.customer_id)
# Check membership id and bind to user
if response["membership_id"] != nil
status = customer.update_attributes(membership_id: response["membership_id"],membership_type:member_group_id )
else
status = customer.update_attributes(membership_type:member_group_id)
end
# When paypar account no not exist in paypar
if response["message"] == "Account has not exist."
customer.destroy
if params[:sale_id]
format.html { redirect_to '/origami/'+params[:sale_id]+'/customers', notice: 'Customer cannot created.' + response["message"]}
else
format.html { redirect_to crm_customers_path, notice: 'Customer cannot created.' + response["message"] }
end
end
if params[:sale_id]
format.html { redirect_to '/origami/'+params[:sale_id]+'/customers', notice: 'Customer was successfully created.' + response["message"]}
else
@@ -161,10 +196,12 @@ end
# PATCH/PUT /crm/customers/1
# PATCH/PUT /crm/customers/1.json
def update
# Remove "" default first
params[:customer][:tax_profiles].delete_at(0)
respond_to do |format|
if @crm_customer.update(customer_params)
# update tax profile
@crm_customer.update_attributes(tax_profiles: params[:customer][:tax_profiles])
name = customer_params[:name]
phone = customer_params[:contact_no]
email = customer_params[:email]
@@ -174,23 +211,33 @@ end
card_no = customer_params[:card_no]
paypar_account_no = customer_params[:paypar_account_no]
id = @crm_customer.membership_id
member_group_id = params[:member_group_id]
member_group_id = params[:member_group_id]
if id.nil? && !member_group_id.nil?
membership = MembershipSetting.find_by_membership_type("paypar_url")
memberaction = MembershipAction.find_by_membership_type("create_membership_customer")
merchant_uid = memberaction.merchant_account_id.to_s
auth_token = memberaction.auth_token.to_s
url = membership.gateway_url.to_s + memberaction.gateway_url.to_s
member_params = { name: name,phone: phone,email: email,
dob: dob,address: address,nrc:nrc,card_no:card_no,
member_group_id: member_group_id,
merchant_uid:merchant_uid,auth_token:auth_token}.to_json
# Check for paypar account exists
# if paypar_account_no != nil || paypar_account_no != ''
if paypar_account_no.present?
member_params = { name: name,phone: phone,email: email,
dob: dob,address: address,nrc:nrc,card_no:card_no,
paypar_account_no: paypar_account_no,
member_group_id: member_group_id,
merchant_uid:merchant_uid,auth_token:auth_token}.to_json
end
begin
response = HTTParty.post(url,
:body => { name: name,phone: phone,email: email,
dob: dob,address: address,nrc:nrc,
paypar_account_no: paypar_account_no,
card_no:card_no,member_group_id: member_group_id,
merchant_uid:merchant_uid,auth_token:auth_token}.to_json,
:body => member_params,
:headers => {
'Content-Type' => 'application/json',
'Accept' => 'application/json'
@@ -207,34 +254,47 @@ end
response = { status: false}
end
if response["status"] == true
customer = Customer.find(@crm_customer.customer_id)
customer = Customer.find(@crm_customer.customer_id)
if response["status"] == true
status = customer.update_attributes(membership_id: response["customer_datas"]["id"],membership_type:member_group_id )
format.html { redirect_to crm_customers_path, notice: 'Customer was successfully updated'}
else
customer = Customer.find(@crm_customer.customer_id)
status = customer.update_attributes(membership_type:member_group_id )
# Check membership id and bind to user
if response["membership_id"] != nil
status = customer.update_attributes(membership_id: response["membership_id"],membership_type:member_group_id )
else
status = customer.update_attributes(membership_type:member_group_id)
end
format.html { redirect_to crm_customers_path, notice: response["error"] }
end
else
membership = MembershipSetting.find_by_membership_type("paypar_url")
memberaction = MembershipAction.find_by_membership_type("update_membership_customer")
merchant_uid = memberaction.merchant_account_id.to_s
auth_token = memberaction.auth_token.to_s
url = membership.gateway_url.to_s + memberaction.gateway_url.to_s
member_params = { name: name,phone: phone,email: email,
dob: dob,address: address,nrc:nrc,card_no:card_no,
member_group_id: member_group_id,
merchant_uid:merchant_uid,auth_token:auth_token}.to_json
# Check for paypar account exists
if paypar_account_no.present?
member_params = { name: name,phone: phone,email: email,
dob: dob,address: address,nrc:nrc,card_no:card_no,
paypar_account_no: paypar_account_no,
member_group_id: member_group_id,
merchant_uid:merchant_uid,auth_token:auth_token}.to_json
end
begin
response = HTTParty.post(url,
:body => {name: name,phone: phone,email: email,
dob: dob,address: address,nrc:nrc,card_no:card_no,
paypar_account_no: paypar_account_no,
id: id,member_group_id:member_group_id,merchant_uid:merchant_uid,auth_token:auth_token}.to_json,
:body => member_params,
:headers => {
'Content-Type' => 'application/json',
'Accept' => 'application/json'
@@ -255,6 +315,13 @@ end
format.html { redirect_to crm_customers_path, notice: 'Customer was successfully updated.' }
format.json { render :show, status: :ok, location: @crm_customer }
else
customer = Customer.find(@crm_customer.customer_id)
# Check membership id and bind to user
if response["membership_id"] != nil
status = customer.update_attributes(membership_id: response["membership_id"],membership_type:member_group_id )
else
status = customer.update_attributes(membership_type:member_group_id )
end
format.html { redirect_to crm_customers_path, notice: response["message"] }
end
@@ -289,7 +356,7 @@ end
# Never trust parameters from the scary internet, only allow the white list through.
def customer_params
params.require(:customer).permit(:name, :company, :contact_no, :email,
:date_of_birth,:salutation,:gender,:nrc_no,:address,:card_no, :paypar_account_no)
params.require(:customer).permit(:id, :name, :company, :contact_no, :email,
:date_of_birth,:salutation,:gender,:nrc_no,:address,:card_no, :paypar_account_no, :customer_type)
end
end

View File

@@ -0,0 +1,126 @@
class Oqs::HomeController < BaseOqsController
def index
queue_stations=OrderQueueStation.all
# Query for OQS with delivery status false
@queue_items_details = queue_items_query(false)
# Query for OQS with delivery status true
@queue_completed_item = completed_order
@queue_stations_items=Array.new
# Calculate Count for each station tab
queue_stations.each do |que|
i = 0
zone_id = 0
@queue_items_details.each do |qid|
dining = DiningFacility.find_by_name(qid.zone)
que.order_queue_process_by_zones.each do |qz|
if qid.station_id == qz.order_queue_station_id && qid.zone_id == qz.zone_id
zone_id = qid.zone_id
i=i+1
end
end
end
@queue_stations_items.push({:zone_id => zone_id , :station_name => que.station_name, :is_active => que.is_active , :is_ap => que.auto_print, :item_count => i })
end
# @queue_items_details = @queue_items_details.paginate(:per_page => 10, :page => params[:page])
@queue_stations_items
end
# Get Order items
def get_order_items
items = []
table_name = params[:table_id]
status = params[:status]
dining = DiningFacility.find_by_name(table_name);
# oqpz = OrderQueueProcessByZone.find_by_zone_id(dining.zone_id)
# if status == ""
# AssignedOrderItem.where("order_queue_station_id=#{ oqpz.order_queue_station_id } AND delivery_status=0").find_each do |aoi|
# oi = OrderItem.find_by_item_code(aoi.item_code)
# items.push(oi)
# end
# else
# AssignedOrderItem.where("order_queue_station_id=#{ oqpz.order_queue_station_id } AND delivery_status=1").find_each do |aoi|
# oi = OrderItem.find_by_item_code(aoi.item_code)
# items.push(oi)
# end
# end
booking = Booking.find_by_dining_facility_id(dining.id)
BookingOrder.where("booking_id='#{ booking.booking_id }'").find_each do |bo|
order=Order.find(bo.order_id)
order.order_items.each do |oi|
items.push(oi)
end
end
# booking_id = dining.get_new_booking
# BookingOrder.where("booking_id='#{ booking_id }'").find_each do |bo|
# order=Order.find(bo.order_id);
# order.order_items.each do |oi|
# items.push(oi)
# end
# end
render :json => items.to_json
end
def show
end
# update delivery status when complete click
def update_delivery_status
removed_item = []
assigned_item_id = params[:id]
assigned_item=AssignedOrderItem.find(assigned_item_id)
assigned_items=AssignedOrderItem.where("item_code='" + assigned_item.item_code + "' AND " + "order_id='" + assigned_item.order_id + "'");
# update delivery status for completed same order items
assigned_items.each do |ai|
ai.delivery_status=true
ai.save
removed_item.push(ai.assigned_order_item_id)
end
render :json => removed_item.to_json
end
# Query for OQS with delivery status
def queue_items_query(status)
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 as type, odt.order_id, odt.item_code, odt.item_name, odt.price, odt.qty, odt.item_order_by, odt.options, cus.name as customer_name, odt.created_at")
.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_code = assigned_order_items.item_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.delivery_status = 0 AND odt.price <> 0 AND assigned_order_items.created_at >= '#{Time.now.beginning_of_day.utc}'")
.group("assigned_order_items.assigned_order_item_id")
.order("assigned_order_items.created_at")
end
# Completed Order
def completed_order
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, cus.name as customer_name, odt.created_at")
.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_code = assigned_order_items.item_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.delivery_status = true AND odt.price <> 0 AND assigned_order_items.created_at between '#{Time.now.beginning_of_day.utc}' and '#{Time.now.end_of_day.utc}'")
.group("assigned_order_items.order_id")
.limit(20)
.order("assigned_order_items.created_at")
# completed_order = AssignedOrderItem.group(:order_id).where('delivery_status=true');
end
end

View File

@@ -1,33 +1,44 @@
class Oqs::HomeController < BaseOqsController
def index
queue_stations=OrderQueueStation.all
@queue_stations = OrderQueueStation.all
# Query for OQS with delivery status false
@queue_items_details = queue_items_query(false)
# @queue_items_details = queue_items_query(false)
# Query for OQS with delivery status true
@queue_completed_item = completed_order
@queue_stations_items=Array.new
@filter = params[:filter]
@queue_completed_item = completed_order(@filter)
if !@filter.nil?
@count = queue_items_count_query(false,@filter)
@count.each do |count|
# Calculate Count for each station tab
queue_stations.each do |que|
i = 0
zone_id = 0
@queue_items_details.each do |qid|
dining = DiningFacility.find_by_name(qid.zone)
que.order_queue_process_by_zones.each do |qz|
if qid.station_id == qz.order_queue_station_id && qid.zone_id == qz.zone_id
zone_id = qid.zone_id
i=i+1
end
end
end
@queue_stations_items.push({:zone_id => zone_id , :station_name => que.station_name, :is_active => que.is_active , :is_ap => que.auto_print, :item_count => i })
end
# @queue_items_details = @queue_items_details.paginate(:per_page => 10, :page => params[:page])
@queue_stations_items
# @queue_stations_items=Array.new
# Calculate Count for each station tab
# @queue_stations.each do |que|
# i = 0
# zone_id = 0
# @queue_items_details.each do |qid|
# dining = DiningFacility.find_by_name(qid.zone)
# que.order_queue_process_by_zones.each do |qz|
# if qid.station_id == qz.order_queue_station_id && qid.zone_id == qz.zone_id
# zone_id = qid.zone_id
# i=i+1
# end
# end
# end
# @queue_stations_items.push({:zone_id => zone_id , :station_name => que.station_name, :is_active => que.is_active , :is_ap => que.auto_print, :item_count => i })
# end
# # @queue_items_details = @queue_items_details.paginate(:per_page => 10, :page => params[:page])
# @queue_stations_items
end
# Get Order items
@@ -68,6 +79,13 @@ class Oqs::HomeController < BaseOqsController
render :json => items.to_json
end
def get_items_by_oqs
oqs_id = params[:id]
filter = params[:filter]
items = queue_items_query(false,oqs_id,filter)
render :json => items.to_json
end
def show
end
@@ -87,9 +105,22 @@ class Oqs::HomeController < BaseOqsController
render :json => removed_item.to_json
end
# Query for OQS with delivery status
def queue_items_query(status)
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, cus.name as customer_name, odt.created_at")
def queue_items_query(status,oqs_id=nil,filter)
if oqs_id == nil
oqs = ''
else
oqs = "and assigned_order_items.order_queue_station_id = '#{oqs_id}' "
end
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 as table_type,
odt.order_id, odt.item_code, odt.item_name,
odt.price, odt.qty, odt.item_order_by, odt.options,
cus.name as customer_name, odt.created_at")
.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
@@ -98,14 +129,15 @@ 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 odt.price <> 0")
.where("assigned_order_items.delivery_status = #{status} AND odt.price <> 0 AND assigned_order_items.created_at >= '#{Time.now.beginning_of_day.utc}' #{oqs} ")
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.assigned_order_item_id")
.order("assigned_order_items.created_at")
end
# Completed Order
def completed_order
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, cus.name as customer_name, odt.created_at")
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, cus.name as customer_name, odt.created_at")
.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
@@ -115,12 +147,28 @@ class Oqs::HomeController < BaseOqsController
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 = true AND odt.price <> 0 AND assigned_order_items.created_at between '#{Time.now.beginning_of_day.utc}' and '#{Time.now.end_of_day.utc}'")
.group("assigned_order_items.order_id")
.limit(20)
.order("assigned_order_items.created_at")
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")
# completed_order = AssignedOrderItem.group(:order_id).where('delivery_status=true');
end
def queue_items_count_query(status,filter)
query = AssignedOrderItem.select("count(odt.item_code) as total,oqs.id as station_id")
.joins(" left join order_queue_stations as oqs on oqs.id = assigned_order_items.order_queue_station_id
left join orders as od ON od.order_id = assigned_order_items.order_id
left join order_items as odt ON odt.item_code = assigned_order_items.item_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.delivery_status = #{status} AND odt.price <> 0 AND assigned_order_items.created_at >= '#{Time.now.beginning_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("oqs.id")
end
end

View File

@@ -8,6 +8,17 @@ class Origami::CustomersController < BaseOrigamiController
def show
end
def get_customer
filter = params[:filter]
if filter.nil?
@crm_customers = Customer.order("customer_id").page(params[:page])
#@products = Product.order("name").page(params[:page]).per(5)
else
@crm_customers = Customer.search(filter)
end
render :json => @crm_customers.to_json
end
def add_customer
@sale_id = params[:sale_id]
@@ -18,9 +29,7 @@ class Origami::CustomersController < BaseOrigamiController
@booking_order = BookingOrder.find_by_order_id(@sale_id)
@booking = Booking.find(@booking_order.booking_id)
@dining_facility = DiningFacility.find(@booking.dining_facility_id)
end
filter = params[:filter]
end
filter = params[:filter]
@@ -28,14 +37,14 @@ class Origami::CustomersController < BaseOrigamiController
@crm_customers = Customer.order("customer_id").page(params[:page])
#@products = Product.order("name").page(params[:page]).per(5)
else
@crm_customers = Customer.search(filter)
@crm_customers = Customer.search(filter)
end
#@crm_customers = Customer.all
@crm_customers = Kaminari.paginate_array(@crm_customers).page(params[:page]).per(50)
@crm_customer = Customer.new
@count_customer = Customer.count_customer
@taxes = TaxProfile.all.order("order_by asc")
# if flash["errors"]
# @crm_customer.valid?
# end
@@ -51,21 +60,22 @@ class Origami::CustomersController < BaseOrigamiController
id = params[:sale_id][0,3]
customer_id = params[:customer_id]
customer = Customer.find(customer_id)
# Check and find with card no
if(!customer_id.include? "CUS")
customer = Customer.find_by_paypar_account_no(customer_id)
if(customer != nil)
customer_id = customer.customer_id
end
end
# if(!customer_id.include? "CUS")
# customer = Customer.find_by_paypar_account_no(customer_id)
# if(customer != nil)
# customer_id = customer.customer_id
# end
# end
if(id == "SAL")
sale = Sale.find(params[:sale_id])
status = sale.update_attributes(customer_id: customer_id)
sale.sale_orders.each do |sale_order|
order = Order.find(sale_order.order_id)
status = order.update_attributes(customer_id: customer_id)
status = order.update_attributes(customer_id: customer_id,order_type:customer.customer_type)
end
else
@booking = BookingOrder.find_by_order_id(params[:sale_id])
@@ -73,13 +83,15 @@ class Origami::CustomersController < BaseOrigamiController
@orders.each do |bo|
order = Order.find(bo.order_id)
status = order.update_attributes(customer_id: customer_id)
status = order.update_attributes(customer_id: customer_id,order_type:customer.customer_type)
end
end
if status == true
render json: JSON.generate({:status => true})
# Re-calc All Amount in Sale
sale.compute_by_sale_items(sale.sale_id, sale.sale_items, sale.total_discount)
else
render json: JSON.generate({:status => false, :error_message => "Record not found"})
end

View File

@@ -155,31 +155,35 @@ class Origami::DiscountsController < BaseOrigamiController
auth_token = memberaction.auth_token.to_s
url = membership.gateway_url.to_s + memberaction.gateway_url.to_s
# Control for Paypar Cloud
begin
response = HTTParty.post(url,
:body => { account_no: nil,
generic_customer_id:generic_customer_id ,
campaign_type_id: campaign_type_id,
receipt_no: receipt_no,
merchant_uid:merchant_uid,
campaign_method:arr.to_json,
total_sale_transaction_amount: sale.grand_total,
auth_token:auth_token}.to_json,
:headers => {
'Content-Type' => 'application/json',
'Accept' => 'application/json'
}, :timeout => 10)
rescue HTTParty::Error
response = {:status=> false, :message => "Can't open membership server " }
# Check for items for Paypar Cloud
if arr.length > 0
begin
response = HTTParty.post(url,
:body => { account_no: nil,
generic_customer_id:generic_customer_id ,
campaign_type_id: campaign_type_id,
receipt_no: receipt_no,
merchant_uid:merchant_uid,
campaign_method:arr.to_json,
total_sale_transaction_amount: sale.grand_total,
auth_token:auth_token}.to_json,
:headers => {
'Content-Type' => 'application/json',
'Accept' => 'application/json'
}, :timeout => 10)
rescue HTTParty::Error
response = {:status=> false, :message => "Can't open membership server " }
rescue Net::OpenTimeout
response = {:status=> false, :message => "Can't open membership server " }
rescue OpenURI::HTTPError
response = {:status=> false, :message => "Can't open membership server " }
rescue Net::OpenTimeout
response = {:status=> false, :message => "Can't open membership server " }
rescue OpenURI::HTTPError
response = {:status=> false, :message => "Can't open membership server " }
rescue SocketError
response = {:status=> false, :message => "Can't open membership server " }
rescue SocketError
response = {:status=> false, :message => "Can't open membership server " }
end
else
response = {:status=> false, :message => "You have no selected discount item" }
end
table_id = sale.bookings[0].dining_facility_id

View File

@@ -2,10 +2,12 @@ class Origami::HomeController < BaseOrigamiController
before_action :set_dining, only: [:show]
def index
@tables = Table.all.active.order('status desc')
@rooms = Room.all.active.order('status desc')
@tables = Table.all.active.order('status desc')
@rooms = Room.all.active.order('status desc')
@complete = Sale.where("sale_status != 'new'")
@orders = Order.all.order('date desc')
@orders = Order.all.order('date desc')
@shop = Shop.find_by_id(1)
# @shift = ShiftSale.current_open_shift(current_user.id)
end
@@ -15,6 +17,7 @@ class Origami::HomeController < BaseOrigamiController
@rooms = Room.all.active.order('status desc')
@complete = Sale.where("sale_status != 'new'")
@orders = Order.all.order('date desc')
@status_order = ""
@status_sale = ""
@sale_array = Array.new
@@ -37,7 +40,6 @@ class Origami::HomeController < BaseOrigamiController
else
sale = Sale.find(booking.sale_id)
if sale.sale_status != "completed" && sale.sale_status != 'void'
puts "enter"
@sale_array.push(sale)
if @status_order == 'order'
@status_order = 'sale'

View File

@@ -163,10 +163,46 @@ class Origami::PaymentsController < BaseOrigamiController
printer.print_receipt_bill(print_settings,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details, "Re-print")
end
def foc
cash = params[:cash]
sale_id = params[:sale_id]
sub_total = params[:sub_total]
member_info = nil
rebate_amount = nil
if(Sale.exists?(sale_id))
saleObj = Sale.find(sale_id)
sale_payment = SalePayment.new
sale_payment.process_payment(saleObj, @user, cash, "foc")
unique_code = "ReceiptBillPdf"
customer= Customer.find(saleObj.customer_id)
#shop detail
shop_details = Shop.find(1)
# get printer info
print_settings=PrintSetting.find_by_unique_code(unique_code)
# Calculate Food and Beverage Total
item_price_by_accounts = SaleItem.calculate_price_by_accounts(saleObj.sale_items)
discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(saleObj.sale_items)
printer = Printer::ReceiptPrinter.new(print_settings)
printer.print_receipt_bill(print_settings,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details, "FOC")
end
end
def rounding_adj
saleObj = Sale.find(params[:sale_id])
new_total = Sale.get_rounding_adjustment(saleObj.grand_total)
@shop = Shop.find_by_id(1)
if @shop.is_rounding_adj
new_total = Sale.get_rounding_adjustment(saleObj.grand_total)
else
new_total = saleObj.grand_total
end
rounding_adj = new_total-saleObj.grand_total
saleObj.update_attributes(grand_total: new_total,old_grand_total: saleObj.grand_total,rounding_adjustment:rounding_adj)

View File

@@ -5,7 +5,7 @@ class Origami::RequestBillsController < BaseOrigamiController
@sale = Sale.new
sale_order=SaleOrder.new
if ShiftSale.current_open_shift(current_user.id)
if shift = ShiftSale.current_open_shift(current_user.id)
order_id = params[:id] # order_id
bk_order = BookingOrder.find_by_order_id(order_id)
check_booking = Booking.find_by_booking_id(bk_order.booking_id)
@@ -20,6 +20,10 @@ class Origami::RequestBillsController < BaseOrigamiController
@sale_data = Sale.find_by_sale_id(check_booking.sale_id)
@sale_items = SaleItem.where("sale_id=?",@sale_data.sale_id)
end
# Bind shift sale id to sale
@sale_data.shift_sale_id = shift.id
@sale_data.save
else
@status = false
@error_message = "No Current Open Shift for This Employee"

View File

@@ -1,36 +1,80 @@
class Origami::RoomsController < BaseOrigamiController
def index
@tables = Table.all.active.order('status desc')
@rooms = Room.all.active.order('status desc')
@complete = Sale.where("sale_status != 'new'")
@orders = Order.all.order('date desc')
# @shift = ShiftSale.current_open_shift(current_user.id)
end
def show
@tables = Table.all.active.order('status desc')
@rooms = Room.all.active.order('status desc')
@complete = Sale.where("sale_status != 'new'")
@orders = Order.all.order('date desc')
@room = DiningFacility.find(params[:room_id])
@status_order = ""
@status_sale = ""
@sale_array = Array.new
@room.bookings.each do |booking|
if booking.sale_id.nil?
@room.bookings.active.each do |booking|
if booking.sale_id.nil? && booking.booking_status != 'moved'
@order_items = Array.new
booking.booking_orders.each do |booking_order|
order = Order.find(booking_order.order_id)
@obj = order
@customer = order.customer
order.order_items.each do |item|
@order_items.push(item)
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
@status = 'order'
@status_order = 'order'
else
sale = Sale.find(booking.sale_id)
if sale.sale_status != "completed"
@sale_array.push(sale)
@status = 'sale'
@obj = sale
if sale.sale_status != "completed" && sale.sale_status != 'void'
puts "enter"
@sale_array.push(sale)
if @status_order == 'order'
@status_order = 'sale'
end
@date = sale.created_at
@status_sale = 'sale'
@obj_sale = sale
@customer = sale.customer
end
end
end
end
# @room.bookings.each do |booking|
# if booking.sale_id.nil?
# @order_items = Array.new
# booking.booking_orders.each do |booking_order|
# order = Order.find(booking_order.order_id)
# @obj = order
# @customer = order.customer
# order.order_items.each do |item|
# @order_items.push(item)
# end
# end
# @status = 'order'
# else
# sale = Sale.find(booking.sale_id)
# if sale.sale_status != "completed"
# @sale_array.push(sale)
# @status = 'sale'
# @obj = sale
# @customer = sale.customer
# end
# end
# end
end

View File

@@ -1,31 +1,50 @@
class Origami::SaleEditController < BaseOrigamiController
authorize_resource :class => false
# Index for sale item void OR edit
def edit
sale_id = params[:sale_id]
@table_id = params[:table_id]
@saleobj = Sale.find(sale_id)
end
# Index for sale item void OR edit
def edit
sale_id = params[:sale_id]
@table_id = params[:table_id]
@saleobj = Sale.find(sale_id)
end
# create item void. make duplicate old record and update qty and price
def item_void
saleitemId = params[:sale_item_id]
saleitemObj = SaleItem.find(saleitemId)
saleitemObj.remark = 'void'
saleitemObj.save
@newsaleitem = SaleItem.new
@newsaleitem = saleitemObj.dup
@newsaleitem.save
@newsaleitem.qty = saleitemObj.qty * -1
@newsaleitem.price = saleitemObj.price * -1
@newsaleitem.is_taxable = 1
@newsaleitem.product_name = saleitemObj.product_name + " - void"
@newsaleitem.save
# create item void. make duplicate old record and update qty and price
def item_void
saleitemId = params[:sale_item_id]
saleitemObj = SaleItem.find(saleitemId)
saleitemObj.remark = 'void'
saleitemObj.save
@newsaleitem = SaleItem.new
@newsaleitem = saleitemObj.dup
@newsaleitem.save
@newsaleitem.qty = saleitemObj.qty * -1
@newsaleitem.price = saleitemObj.price * -1
@newsaleitem.is_taxable = 1
@newsaleitem.product_name = saleitemObj.product_name + " - void"
@newsaleitem.save
# re-calc tax
saleObj = Sale.find(saleitemObj.sale_id)
saleObj.compute_without_void
end
# re-calc tax
saleObj = Sale.find(saleitemObj.sale_id)
saleObj.compute_without_void
end
def item_foc
saleitemId = params[:sale_item_id]
saleitemObj = SaleItem.find(saleitemId)
saleitemObj.remark = 'foc'
saleitemObj.save
@newsaleitem = SaleItem.new
@newsaleitem = saleitemObj.dup
@newsaleitem.save
@newsaleitem.qty = saleitemObj.qty * -1
@newsaleitem.price = saleitemObj.price * -1
@newsaleitem.is_taxable = 1
@newsaleitem.product_name = saleitemObj.product_name + ' foc'
@newsaleitem.save
# re-calc tax
saleObj = Sale.find(saleitemObj.sale_id)
saleObj.compute_without_void
end
# def item_edit
# saleitemId = params[:sale_item_id]
@@ -48,63 +67,63 @@ class Origami::SaleEditController < BaseOrigamiController
# end
def item_edit
saleitemId = params[:sale_item_id]
update_qty = params[:update_qty]
saleitemId = params[:sale_item_id]
update_qty = params[:update_qty]
update_price = params[:update_price]
saleitemObj = SaleItem.find(saleitemId)
saleitemObj = SaleItem.find(saleitemId)
saleitemObj.qty = update_qty
saleitemObj.price = update_qty.to_f * update_price.to_f
saleitemObj.unit_price = update_price
saleitemObj.qty = update_qty
saleitemObj.price = update_qty.to_f * update_price.to_f
saleitemObj.unit_price = update_price
saleitemObj.taxable_price = update_qty.to_f * update_price.to_f
# saleitemObj.remark = 'edit'
saleitemObj.product_name = saleitemObj.product_name + " - updated"
saleitemObj.product_name = saleitemObj.product_name + " - updated"
saleitemObj.save
# re-calc tax
saleObj = Sale.find(saleitemObj.sale_id)
saleObj.compute_without_void
# re-calc tax
saleObj = Sale.find(saleitemObj.sale_id)
saleObj.compute_without_void
end
# make cancel void item
def item_void_cancel
saleitemId = params[:sale_item_id]
saleitemObj = SaleItem.find(saleitemId)
both = SaleItem.where('product_code=?',saleitemObj.product_code)
both.each do |item|
if item.qty.to_i > 0
item.remark = nil
item.save
end
end
saleitemObj.destroy
# make cancel void item
def item_void_cancel
saleitemId = params[:sale_item_id]
saleitemObj = SaleItem.find(saleitemId)
both = SaleItem.where('product_code=?', saleitemObj.product_code)
both.each do |item|
if item.qty.to_i > 0
item.remark = nil
item.save
end
end
saleitemObj.destroy
# re-calc tax
saleObj = Sale.find(saleitemObj.sale_id)
saleObj.compute_without_void
end
# re-calc tax
saleObj = Sale.find(saleitemObj.sale_id)
saleObj.compute_without_void
end
# remove all void items
def cancel_all_void
sale_id = params[:sale_id]
saleObj = Sale.find(sale_id)
saleObj.sale_items.each do |item|
if item.qty.to_i < 0
item.destroy
else
item.remark = nil
end
item.save
end
# remove all void items
def cancel_all_void
sale_id = params[:sale_id]
saleObj = Sale.find(sale_id)
saleObj.sale_items.each do |item|
if item.qty.to_i < 0
item.destroy
else
item.remark = nil
end
item.save
end
# re-calc tax
saleObj.compute_without_void
end
# re-calc tax
saleObj.compute_without_void
end
def apply_void
sale_id = params[:sale_id]
saleObj = Sale.find(sale_id)
saleObj.compute_without_void
end
def apply_void
sale_id = params[:sale_id]
saleObj = Sale.find(sale_id)
saleObj.compute_without_void
end
end

View File

@@ -31,15 +31,21 @@ class Origami::ShiftsController < BaseOrigamiController
unique_code = "CloseCashierPdf"
shop_details = Shop.find(1)
#get tax
shift_obj = ShiftSale.where('id =?',@shift.id)
@sale_taxes = Sale.get_separate_tax(shift_obj,from=nil,to=nil,type='')
shift_obj = ShiftSale.where('id =?',@shift.id)
@sale_taxes = Sale.get_separate_tax(shift_obj,from=nil,to=nil,type='')
#other payment details for mpu or visa like card
@other_payment = ShiftSale.get_by_shift_other_payment(@shift)
# Calculate price_by_accounts
@total_amount_by_account = ShiftSale.calculate_total_price_by_accounts(@shift,'amount')
@total_discount_by_account = ShiftSale.calculate_total_price_by_accounts(@shift,'discount')
@total_member_discount = ShiftSale.get_total_member_discount(@shift)
# get printer info
print_settings=PrintSetting.find_by_unique_code(unique_code)
print_settings = PrintSetting.find_by_unique_code(unique_code)
printer = Printer::CashierStationPrinter.new(print_settings)
printer.print_close_cashier(print_settings,@shift,shop_details,@sale_taxes)
printer.print_close_cashier(print_settings,@shift,shop_details,@sale_taxes,@other_payment,@total_amount_by_account,@total_discount_by_account,@total_member_discount)
end
@@ -52,6 +58,21 @@ class Origami::ShiftsController < BaseOrigamiController
def sale_summary
@shift = ShiftSale.current_open_shift(current_user.id)
# @shift = ShiftSale.find_by_id(shift_id)
if @shift
#get tax
shift_obj = ShiftSale.where('id =?',@shift.id)
@sale_taxes = Sale.get_separate_tax(shift_obj,from=nil,to=nil,type='')
#other payment details for mpu or visa like card
@other_payment = ShiftSale.get_by_shift_other_payment(@shift)
# Calculate price_by_accounts
@total_amount_by_account = ShiftSale.calculate_total_price_by_accounts(@shift,'amount')
@total_discount_by_account = ShiftSale.calculate_total_price_by_accounts(@shift,'discount')
@total_member_discount = ShiftSale.get_total_member_discount(@shift)
end
end

View File

@@ -6,18 +6,19 @@ class Origami::VoidController < BaseOrigamiController
if Sale.exists?(sale_id)
sale = Sale.find_by_sale_id(sale_id)
sale.payment_status = 'void'
sale.sale_status = 'void'
sale.save
# update count for shift sale
if(sale.sale_status == "void")
if(sale.sale_status == "completed")
if sale.shift_sale_id != nil
shift = ShiftSale.find(sale.shift_sale_id)
shift.calculate(sale_id, "void")
end
end
sale.payment_status = 'void'
sale.sale_status = 'void'
sale.save
bookings = sale.bookings
bookings.each do |booking|
orders = booking.orders

View File

@@ -0,0 +1,72 @@
class Origami::VoucherController < BaseOrigamiController
def index
@sale_id = params[:sale_id]
# limit voucher_amount
sale_data = Sale.find_by_sale_id(@sale_id)
total = sale_data.grand_total
@vouchercount = 0
others = 0
sale_data.sale_payments.each do |sale_payment|
if sale_payment.payment_method == "voucher"
@vouchercount = @vouchercount + sale_payment.payment_amount
else
others = others + sale_payment.payment_amount
end
end
@can_voucher = total - @vouchercount - others
end
def create
cash = params[:amount]
sale_id = params[:sale_id]
sale_id = params[:refnumber]
if(Sale.exists?(sale_id))
customer_data= Customer.find_by_customer_id(sale_data.customer_id)
if customer_data
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
# 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
begin
response = HTTParty.get(url,
:body => { app_token: token,membership_id:membership_id,
campaign_type_id:campaign_type_id,merchant_uid:merchant_uid,
auth_token:auth_token
}.to_json,
:headers => {
'Content-Type' => 'application/json',
'Accept' => 'application/json'
}, :timeout => 10
)
rescue Net::OpenTimeout
response = { status: false }
rescue OpenURI::HTTPError
response = { status: false}
rescue SocketError
response = { status: false}
end
# end
end
end
end
if( response["status"]==true )
saleObj = Sale.find(sale_id)
sale_payment = SalePayment.new
@status, @sale = sale_payment.process_payment(saleObj, @user, cash, "voucher")
end
end
end
end

View File

@@ -70,6 +70,6 @@ class PrintSettingsController < ApplicationController
# Never trust parameters from the scary internet, only allow the white list through.
def print_setting_params
params.require(:print_setting).permit(:name, :unique_code, :template, :db_name, :db_type, :db_username, :db_password, :printer_name, :api_settings, :page_width, :page_height, :print_copies,:precision,:delimiter,:heading_space)
params.require(:print_setting).permit(:name, :unique_code, :template, :printer_name, :api_settings, :page_width, :page_height, :print_copies,:precision,:delimiter,:heading_space)
end
end

View File

@@ -0,0 +1,61 @@
class Reports::CreditPaymentController < BaseReportController
authorize_resource :class => false
def index
from, to = get_date_range_from_params
@shift_sale_range = Sale.get_by_shift_sale(from,to,Sale::SALE_STATUS_COMPLETED)
@shift = ''
if params[:shift_name].to_i != 0
shift_sale = ShiftSale.find(params[:shift_name])
if to.blank?
@shift = ShiftSale.where('shift_started_at = ? and shift_closed_at is NULL ',shift_sale.shift_started_at)
else
@shift = ShiftSale.where('shift_started_at = ? and shift_closed_at = ? ',shift_sale.shift_started_at, shift_sale.shift_closed_at)
end
end
@sale_data = Sale.get_by_shift_sale_credit_payment(@shift_sale_range,@shift,from,to)
@from = from
@to = to
if @shift.present?
@shift.each do |sh|
@shift_from = sh.shift_started_at.nil? ? '-' : sh.shift_started_at.utc.getlocal.strftime("%e %b %I:%M%p")
@shift_to = sh.shift_closed_at.nil? ? '-' : sh.shift_closed_at.utc.getlocal.strftime("%e %b %I:%M%p")
@shift_data = sh
end
end
respond_to do |format|
format.html
format.xls
end
end
def show
from, to = get_date_range_from_params
@sale_data = Sale.get_by_shift_sale(from,to,Sale::SALE_STATUS_COMPLETED)
date_arr = Array.new
@sale_data.each do |sale|
local_opening_date = sale.opening_date.nil? ? '-' : sale.opening_date.utc.getlocal.strftime("%e %b %I:%M%p")
local_closing_date = sale.closing_date.nil? ? '-' : sale.closing_date.utc.getlocal.strftime("%e %b %I:%M%p")
opening_date = sale.opening_date.nil? ? '-' : sale.opening_date.utc
closing_date = sale.closing_date.nil? ? '-' : sale.closing_date.utc
shift_id = sale.id.nil? ? '-' : sale.id
str = {:shift_id => shift_id, :local_opening_date => local_opening_date, :local_closing_date => local_closing_date, :opening_date => opening_date, :closing_date => closing_date}
date_arr.push(str)
end
out = {:status => 'ok', :message => date_arr}
respond_to do |format|
format.json { render json: out }
end
end
end

View File

@@ -0,0 +1,60 @@
class Reports::VoidSaleController < BaseReportController
authorize_resource :class => false
def index
from, to = get_date_range_from_params
# @shift_sale_range = Sale.get_by_shift_sale(from,to,Sale::SALE_STATUS_COMPLETED)
@shift = ''
if params[:shift_name].to_i != 0
shift_sale = ShiftSale.find(params[:shift_name])
if to.blank?
@shift = ShiftSale.where('shift_started_at = ? and shift_closed_at is NULL ',shift_sale.shift_started_at)
else
@shift = ShiftSale.where('shift_started_at = ? and shift_closed_at = ? ',shift_sale.shift_started_at, shift_sale.shift_closed_at)
end
end
@sale_data = Sale.get_void_sale(@shift,from,to)
@from = from
@to = to
if @shift.present?
@shift.each do |sh|
@shift_from = sh.shift_started_at.nil? ? '-' : sh.shift_started_at.utc.getlocal.strftime("%e %b %I:%M%p")
@shift_to = sh.shift_closed_at.nil? ? '-' : sh.shift_closed_at.utc.getlocal.strftime("%e %b %I:%M%p")
@shift_data = sh
end
end
respond_to do |format|
format.html
format.xls
end
end
def show
from, to = get_date_range_from_params
@sale_data = Sale.get_by_shift_sale(from,to,Sale::SALE_STATUS_COMPLETED)
date_arr = Array.new
@sale_data.each do |sale|
local_opening_date = sale.opening_date.nil? ? '-' : sale.opening_date.utc.getlocal.strftime("%e %b %I:%M%p")
local_closing_date = sale.closing_date.nil? ? '-' : sale.closing_date.utc.getlocal.strftime("%e %b %I:%M%p")
opening_date = sale.opening_date.nil? ? '-' : sale.opening_date.utc
closing_date = sale.closing_date.nil? ? '-' : sale.closing_date.utc
shift_id = sale.id.nil? ? '-' : sale.id
str = {:shift_id => shift_id, :local_opening_date => local_opening_date, :local_closing_date => local_closing_date, :opening_date => opening_date, :closing_date => closing_date}
date_arr.push(str)
end
out = {:status => 'ok', :message => date_arr}
respond_to do |format|
format.json { render json: out }
end
end
end

View File

@@ -0,0 +1,102 @@
class Settings::DiningChargesController < ApplicationController
before_action :set_dining_charge, only: [:show, :edit, :update, :destroy]
before_action :set_settings_facility
before_action :set_settings_zone
# GET /dining_charges
# GET /dining_charges.json
def index
@dining_charges = DiningCharge.all
end
# GET /dining_charges/1
# GET /dining_charges/1.json
def show
end
# GET /dining_charges/new
def new
@dining_charge = DiningCharge.new
@dining_charge.minimum_free_time="00:30"
@dining_charge.charge_block="02:00"
@dining_charge.time_rounding_block="00:15"
end
# GET /dining_charges/1/edit
def edit
end
# POST /dining_charges
# POST /dining_charges.json
def create
@dining_charge = DiningCharge.new(dining_charge_params)
@dining_charge.dining_facility_id = @settings_dining_facility.id
respond_to do |format|
if @dining_charge.save
if @table
format.html { redirect_to edit_settings_zone_table_path(@zone,@settings_dining_facility), notice: 'Dining charge was successfully created.' }
else
format.html { redirect_to edit_settings_zone_room_path(@zone,@settings_dining_facility), notice: 'Dining charge was successfully created.' }
end
format.json { render :show, status: :created, location: @dining_charge }
else
format.html { render :new }
format.json { render json: @dining_charge.errors, status: :unprocessable_entity }
end
end
end
# PATCH/PUT /dining_charges/1
# PATCH/PUT /dining_charges/1.json
def update
respond_to do |format|
@dining_charge.dining_facility_id = @settings_dining_facility.id
if @dining_charge.update(dining_charge_params)
if @table
format.html { redirect_to edit_settings_zone_table_path(@zone,@settings_dining_facility), notice: 'Dining charge was successfully updated.' }
else
format.html { redirect_to edit_settings_zone_room_path(@zone,@settings_dining_facility), notice: 'Dining charge was successfully updated.' }
end
format.json { render :show, status: :ok, location: @dining_charge }
else
format.html { render :edit }
format.json { render json: @dining_charge.errors, status: :unprocessable_entity }
end
end
end
# DELETE /dining_charges/1
# DELETE /dining_charges/1.json
def destroy
@dining_charge.destroy
respond_to do |format|
format.html { redirect_to dining_charges_url, notice: 'Dining charge was successfully destroyed.' }
format.json { head :no_content }
end
end
private
# Use callbacks to share common setup or constraints between actions.
def set_dining_charge
@dining_charge = DiningCharge.find(params[:id])
end
def set_settings_facility
if params[:table_id]
@table = true
@settings_dining_facility = Table.find(params[:table_id])
elsif params[:room_id]
@room = true
@settings_dining_facility = Room.find(params[:room_id])
end
end
def set_settings_zone
@zone = Zone.find(params[:zone_id])
end
# Never trust parameters from the scary internet, only allow the white list through.
def dining_charge_params
# params.fetch(:dining_charge, {})
params.require(:dining_charge).permit(:item_code, :unit_price, :taxable, :charge_type,:minimum_free_time ,:charge_block,:time_rounding,:time_rounding_block, :zone_id)
end
end

View File

@@ -0,0 +1,74 @@
class Settings::ItemSetsController < ApplicationController
before_action :set_settings_item_set, only: [:show, :edit, :update, :destroy]
load_and_authorize_resource except: [:create]
# GET /settings/item_sets
# GET /settings/item_sets.json
def index
@settings_item_sets = ItemSet.all
end
# GET /settings/item_sets/1
# GET /settings/item_sets/1.json
def show
end
# GET /settings/item_sets/new
def new
@settings_item_set = ItemSet.new
end
# GET /settings/item_sets/1/edit
def edit
end
# POST /settings/item_sets
# POST /settings/item_sets.json
def create
@settings_item_set = ItemSet.new(settings_item_set_params)
respond_to do |format|
if @settings_item_set.save
format.html { redirect_to settings_item_sets_path, notice: 'Item set was successfully created.' }
format.json { render :show, status: :created, location: @settings_item_set }
else
format.html { render :new }
format.json { render json: @settings_item_set.errors, status: :unprocessable_entity }
end
end
end
# PATCH/PUT /settings/item_sets/1
# PATCH/PUT /settings/item_sets/1.json
def update
respond_to do |format|
if @settings_item_set.update(settings_item_set_params)
format.html { redirect_to settings_item_sets_path, notice: 'Item set was successfully updated.' }
format.json { render :show, status: :ok, location: @settings_item_set }
else
format.html { render :edit }
format.json { render json: @settings_item_set.errors, status: :unprocessable_entity }
end
end
end
# DELETE /settings/item_sets/1
# DELETE /settings/item_sets/1.json
def destroy
@settings_item_set.destroy
respond_to do |format|
format.html { redirect_to settings_item_sets_url, notice: 'Item set was successfully destroyed.' }
format.json { head :no_content }
end
end
private
# Use callbacks to share common setup or constraints between actions.
def set_settings_item_set
@settings_item_set = ItemSet.find(params[:id])
end
# Never trust parameters from the scary internet, only allow the white list through.
def settings_item_set_params
params.require(:item_set).permit(:name, :min_selectable_qty, :max_selectable_qty)
end
end

View File

@@ -28,11 +28,11 @@ class Settings::LookupsController < ApplicationController
respond_to do |format|
if @settings_lookup.save
format.html { redirect_to @settings_lookup, notice: 'Lookup was successfully created.' }
format.html { redirect_to settings_lookups_path, notice: 'Lookup was successfully created.' }
format.json { render :show, status: :created, location: @settings_lookup }
else
format.html { render :new }
format.json { render json: @settings_lookup.errors, status: :unprocessable_entity }
format.json { render json: settings_lookups_path.errors, status: :unprocessable_entity }
end
end
end
@@ -42,11 +42,11 @@ class Settings::LookupsController < ApplicationController
def update
respond_to do |format|
if @settings_lookup.update(settings_lookup_params)
format.html { redirect_to @settings_lookup, notice: 'Lookup was successfully updated.' }
format.html { redirect_to settings_lookups_path, notice: 'Lookup was successfully updated.' }
format.json { render :show, status: :ok, location: @settings_lookup }
else
format.html { render :edit }
format.json { render json: @settings_lookup.errors, status: :unprocessable_entity }
format.json { render json: settings_lookups_path.errors, status: :unprocessable_entity }
end
end
end
@@ -56,7 +56,7 @@ class Settings::LookupsController < ApplicationController
def destroy
@settings_lookup.destroy
respond_to do |format|
format.html { redirect_to settings_lookups_url, notice: 'Lookup was successfully destroyed.' }
format.html { redirect_to settings_lookups_path, notice: 'Lookup was successfully destroyed.' }
format.json { head :no_content }
end
end

View File

@@ -0,0 +1,74 @@
class Settings::MenuItemSetsController < ApplicationController
before_action :set_settings_menu_item_set, only: [:show, :edit, :update, :destroy]
load_and_authorize_resource except: [:create]
# GET /settings/menu_item_sets
# GET /settings/menu_item_sets.json
def index
@settings_menu_item_sets = MenuItemSet.all
end
# GET /settings/menu_item_sets/1
# GET /settings/menu_item_sets/1.json
def show
end
# GET /settings/menu_item_sets/new
def new
@settings_menu_item_set = MenuItemSet.new
end
# GET /settings/menu_item_sets/1/edit
def edit
end
# POST /settings/menu_item_sets
# POST /settings/menu_item_sets.json
def create
@settings_menu_item_set = MenuItemSet.new(settings_menu_item_set_params)
respond_to do |format|
if @settings_menu_item_set.save
format.html { redirect_to settings_menu_item_sets_path, notice: 'Menu item set was successfully created.' }
format.json { render :show, status: :created, location: @settings_menu_item_set }
else
format.html { render :new }
format.json { render json: @settings_menu_item_set.errors, status: :unprocessable_entity }
end
end
end
# PATCH/PUT /settings/menu_item_sets/1
# PATCH/PUT /settings/menu_item_sets/1.json
def update
respond_to do |format|
if @settings_menu_item_set.update(settings_menu_item_set_params)
format.html { redirect_to settings_menu_item_sets_path, notice: 'Menu item set was successfully updated.' }
format.json { render :show, status: :ok, location: @settings_menu_item_set }
else
format.html { render :edit }
format.json { render json: @settings_menu_item_set.errors, status: :unprocessable_entity }
end
end
end
# DELETE /settings/menu_item_sets/1
# DELETE /settings/menu_item_sets/1.json
def destroy
@settings_menu_item_set.destroy
respond_to do |format|
format.html { redirect_to settings_menu_item_sets_url, notice: 'Menu item set was successfully destroyed.' }
format.json { head :no_content }
end
end
private
# Use callbacks to share common setup or constraints between actions.
def set_settings_menu_item_set
@settings_menu_item_set = MenuItemSet.find(params[:id])
end
# Never trust parameters from the scary internet, only allow the white list through.
def settings_menu_item_set_params
params.require(:menu_item_set).permit(:item_set_id, :menu_item_id)
end
end

View File

@@ -11,9 +11,7 @@ class Settings::SetMenuItemsController < ApplicationController
# GET /settings/menu_items/1.json
def show
@sub_menu = MenuItem.where("menu_item_id=?",params[:id]).page(params[:page]).per(10)
@menu_item_instance = MenuItemInstance.where("menu_item_id=?",params[:id]).page(params[:page]).per(10)
end
# GET /settings/menu_items/new
@@ -62,6 +60,8 @@ class Settings::SetMenuItemsController < ApplicationController
# DELETE /settings/menu_items/1
# DELETE /settings/menu_items/1.json
def destroy
path_to_file = @settings_menu_item.image_path.to_s
File.delete(path_to_file) if File.exist?(path_to_file)
abc = MenuItem.deleteRecursive(@settings_menu_item)
respond_to do |format|
format.html { redirect_to settings_menu_category_set_menu_items_path, notice: 'Menu item was successfully destroyed.' }
@@ -81,6 +81,6 @@ class Settings::SetMenuItemsController < ApplicationController
# Never trust parameters from the scary internet, only allow the white list through.
def settings_menu_item_params
params.require(:set_menu_item).permit(:item_code, :name, :alt_name, :type, :menu_category_id,:account_id , :menu_item_id, :min_qty, :min_selectable_item, :max_selectable_item, :created_by)
params.require(:set_menu_item).permit(:item_code, :name, :alt_name, :type, :image_path, :menu_category_id,:account_id , :menu_item_id, :min_qty, :min_selectable_item, :max_selectable_item, :created_by)
end
end

View File

@@ -16,7 +16,7 @@ class Settings::SimpleMenuItemsController < ApplicationController
# GET /settings/menu_items/new
def new
@settings_menu_item = MenuItem.new
@settings_menu_item = MenuItem.new
end
# GET /settings/menu_items/1/edit
@@ -27,10 +27,12 @@ class Settings::SimpleMenuItemsController < ApplicationController
# POST /settings/menu_items.json
def create
@settings_menu_item = MenuItem.new(settings_menu_item_params)
if params[:simple_menu_item][:menu_item_id] == ''
@settings_menu_item.menu_category_id = params[:menu_category_id]
end
@settings_menu_item.created_by = current_login_employee.name
respond_to do |format|
if @settings_menu_item.save
format.html { redirect_to settings_menu_category_simple_menu_items_path, notice: 'Menu item was successfully created.' }
@@ -59,6 +61,8 @@ class Settings::SimpleMenuItemsController < ApplicationController
# DELETE /settings/menu_items/1
# DELETE /settings/menu_items/1.json
def destroy
path_to_file = @settings_menu_item.image_path.to_s
File.delete(path_to_file) if File.exist?(path_to_file)
abc = MenuItem.deleteRecursive(@settings_menu_item)
respond_to do |format|
format.html { redirect_to settings_menu_category_simple_menu_items_path, notice: 'Menu item was successfully destroyed.' }
@@ -78,6 +82,6 @@ class Settings::SimpleMenuItemsController < ApplicationController
# Never trust parameters from the scary internet, only allow the white list through.
def settings_menu_item_params
params.require(:simple_menu_item).permit(:item_code, :name, :alt_name, :type, :menu_category_id,:account_id,:item_attributes, :menu_item_id, :min_qty, :min_selectable_item, :max_selectable_item, :created_by)
params.require(:simple_menu_item).permit(:item_code, :name, :alt_name, :type, :image_path, :menu_category_id,:account_id,:item_attributes, :menu_item_id, :min_qty, :min_selectable_item, :max_selectable_item, :created_by)
end
end

View File

@@ -5,9 +5,25 @@ class Transactions::CreditNotesController < ApplicationController
# GET /transactions/sales.json
def index
@sales = Sale.where('payment_status = ?', Sale::SALE_STATUS_OUTSTANDING)
@customers = Customer.all
filter = params[:filter]
customer = params[:customer]
from = params[:from]
to = params[:to]
if filter.nil? && from.nil? && to.nil? && customer.nil?
@sales = Sale.where('payment_status = ?', Sale::SALE_STATUS_OUTSTANDING)
puts "cccccccccccc"
else
sale = Sale.search_credit_sales(customer,filter,from,to)
if sale.count > 0
@sales = sale
@sales = Kaminari.paginate_array(@sales).page(params[:page]).per(50)
else
@sales = 0
end
end
respond_to do |format|
format.html # index.html.erb

View File

@@ -3,6 +3,7 @@ class Transactions::ManualSalesController < ApplicationController
def void
@sale = params[:sale_id]
@reason = Lookup.where("lookup_type = 'void_reason'")
respond_to do |format|
format.html # index.html.erb
format.json { render json: @sales }

View File

@@ -2,23 +2,30 @@ class Transactions::OrdersController < ApplicationController
load_and_authorize_resource except: [:create]
def index
filter = params[:filter]
if filter.nil?
filter = params[:filter]
count = params[:count]
from = params[:from]
to = params[:to]
if filter.nil? && from.nil? && to.nil? && count.nil?
orders = Order.order("order_id desc")
puts "ssssss"
else
order = Order.search(filter)
if order.count > 0
orders = order
else
orders = Order.order("order_id desc")
end
orders = Order.search(filter,from,to,count)
puts "aaaaa"
end
@orders = Kaminari.paginate_array(orders).page(params[:page]).per(50)
respond_to do |format|
format.html # index.html.erb
format.json { render json: @orders }
end
if !orders.nil?
@orders = Kaminari.paginate_array(orders).page(params[:page]).per(50)
else
@orders = []
end
puts @orders.to_json
respond_to do |format|
format.html # index.html.erb
format.json { render json: @orders }
end
end
def show

View File

@@ -6,28 +6,41 @@ class Transactions::SalesController < ApplicationController
# GET /transactions/sales.json
def index
search_date = params[:date]
receipt_no = params[:receipt_no]
today = Date.today
if receipt_no.nil? && search_date.nil?
@sales = Sale.where("NOT sale_status = 'void' " ).order("sale_id desc").limit(500)
@sales = Kaminari.paginate_array(@sales).page(params[:page]).per(50)
receipt_no = params[:receipt_no]
from = params[:from]
to = params[:to]
if receipt_no.nil? && from.nil? && to.nil?
@sales = Sale.where("NOT sale_status = 'void' " ).order("sale_id desc").limit(500)
@sales = Kaminari.paginate_array(@sales).page(params[:page]).per(50)
else
if !search_date.blank? && receipt_no.blank?
sale = Sale.where("DATE_FORMAT(receipt_date,'%d-%m-%Y') = ? and NOT sale_status = 'void' ", search_date).order("sale_id desc").limit(500).page(params[:page])
elsif !search_date.blank? && !receipt_no.blank?
sale = Sale.where("receipt_no LIKE ? or DATE_FORMAT(receipt_date,'%d-%m-%Y') = ? and NOT sale_status = 'void' ", "%#{receipt_no}%", search_date).order("sale_id desc").limit(500).page(params[:page])
else
sale = Sale.where("receipt_no LIKE ? and NOT sale_status = 'void' ", receipt_no).order("sale_id desc").limit(500).page(params[:page])
end
sale = Sale.search(receipt_no,from,to)
if sale.count > 0
@sales = sale
@sales = Kaminari.paginate_array(@sales).page(params[:page]).per(50)
else
@sales = 0
end
@sales = sale
@sales = Kaminari.paginate_array(@sales).page(params[:page]).per(50)
else
@sales = 0
end
end
# if receipt_no.nil? && search_date.nil?
# @sales = Sale.where("NOT sale_status = 'void' " ).order("sale_id desc").limit(500)
# @sales = Kaminari.paginate_array(@sales).page(params[:page]).per(50)
# else
# if !search_date.blank? && receipt_no.blank?
# sale = Sale.where("DATE_FORMAT(receipt_date,'%d-%m-%Y') = ? and NOT sale_status = 'void' ", search_date).order("sale_id desc").limit(500).page(params[:page])
# elsif !search_date.blank? && !receipt_no.blank?
# sale = Sale.where("receipt_no LIKE ? or DATE_FORMAT(receipt_date,'%d-%m-%Y') = ? and NOT sale_status = 'void' ", "%#{receipt_no}%", search_date).order("sale_id desc").limit(500).page(params[:page])
# else
# sale = Sale.where("receipt_no LIKE ? and NOT sale_status = 'void' ", receipt_no).order("sale_id desc").limit(500).page(params[:page])
# end
# if sale.count > 0
# @sales = sale
# @sales = Kaminari.paginate_array(@sales).page(params[:page]).per(50)
# else
# @sales = 0
# end
# end
respond_to do |format|
format.html # index.html.erb

View File

@@ -0,0 +1,2 @@
module DiningChargesHelper
end

View File

@@ -0,0 +1,2 @@
module Settings::ItemSetsHelper
end

View File

@@ -0,0 +1,2 @@
module Settings::MenuItemSetsHelper
end

View File

@@ -5,17 +5,16 @@ class Ability
user ||= Employee.new
if user.role == "administrator"
can :manage, :all
elsif user.role == "manager"
can :manage, Menu
can :manage, MenuCategory
can :manage, MenuItemAttribute
can :manage, MenuItemInstance
can :manage, MenuItemOption
can :manage, SetMenuItem
can :manage, ItemSet
can :manage, MenuItemSet
can :manage, OrderQueueStation
can :manage, Zone
can :manage, CashierTerminal
@@ -37,7 +36,10 @@ class Ability
can :index, :saleitem
can :index, :receipt_no
can :index, :shiftsale
can :index, :credit_payment
can :index, :void_sale
can :get_customer, Customer
can :add_customer, Customer
can :update_sale_by_customer, Customer
@@ -53,6 +55,8 @@ class Ability
can :create, :payment
can :reprint, :payment
can :rounding_adj, :payment
can :foc, :payment
can :move_dining, :movetable
can :moving, :movetable
@@ -68,13 +72,15 @@ class Ability
can :overall_void, :void
elsif user.role == "cashier"
# can :overall_void, :void
can :read, Order
can :update, Order
can :read, Sale
can :update, Sale
can :get_customer, Customer
can :add_customer, Customer
can :update_sale_by_customer, Customer
@@ -97,11 +103,6 @@ class Ability
can :move_dining, :moveroom
can :first_bill, :payment
can :show, :payment
can :create, :payment
can :reprint, :payment
can :manage, DiningQueue
elsif user.role == "account"
@@ -110,6 +111,8 @@ class Ability
can :index, :saleitem
can :index, :receipt_no
can :index, :shiftsale
can :index, :credit_payment
can :index, :void_sale
elsif user.role == "supervisour"
@@ -127,7 +130,5 @@ class Ability
can :reprint, :payment
can :rounding_adj, :payment
end
end
end

View File

@@ -7,10 +7,10 @@ class Customer < ApplicationRecord
has_many :sales
validates_presence_of :name, :contact_no, :email,:card_no
validates :contact_no, uniqueness: true
validates :email, uniqueness: true
validates :contact_no, uniqueness: true, numericality: true
validates :email, uniqueness: true,format: { with: /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\z/i, on: :create }
validates :card_no, uniqueness: true
# validates :paypar_account_no
# validates :paypar_account_no, uniqueness: true
paginates_per 50

View File

@@ -0,0 +1,76 @@
class DiningCharge < ApplicationRecord
belongs_to :table
belongs_to :room
def self.amount_calculate(dining_charges_obj, checkin , checkout)
if !checkin.nil? && !checkout.nil? && !dining_charges_obj.nil?
price = 0
minutes = DiningCharge.time_diff(checkout, checkin)
free_time = DiningCharge.convert_to_minutes(dining_charges_obj.minimum_free_time.strftime('%H:%M'))
dining_minutes = minutes - free_time # stayminutes - free minutes
charge_type = dining_charges_obj.charge_type
if charge_type == 'hr'
price = DiningCharge.charges(dining_charges_obj, dining_minutes, 'hr')
elsif charge_type == 'day'
price = charges(dining_charges_obj, dining_minutes, 'day')
end
return price
else
puts "<<<<<<<< NO"
end
end
def self.charges(chargesObj, dining_minutes, type)
solid_price = 0
block = DiningCharge.convert_to_minutes(chargesObj.charge_block.strftime('%H:%M'))
result = dining_minutes / block
if result.to_i < 1
return chargesObj.unit_price
elsif result.to_i >= 1
solid_price = result * chargesObj.unit_price
remain_value = dining_minutes % block
rounding_block = DiningCharge.convert_to_minutes(chargesObj.time_rounding_block.strftime('%H:%M'))
roundingblock = remain_value / rounding_block
if roundingblock.to_i < 1
return DiningCharge.check_rounding(chargesObj, solid_price)
else
solid_price += roundingblock * chargesObj.time_rounding_block_price
remain_rounding = dining_minutes % block
if remain_rounding.to_i < 1
return DiningCharge.check_rounding(chargesObj, solid_price)
else
return solid_price
end
end
end
end
def self.check_rounding(chargesObj)
if chargesObj.time_rounding == "down"
return solid_price
else
return solid_price += chargesObj.time_rounding_block_price
end
end
def self.time_diff(start_time, end_time)
seconds_diff = (start_time - end_time).to_i.abs
hours = seconds_diff / 3600
seconds_diff -= hours * 3600
minutes = seconds_diff / 60
seconds_diff -= minutes * 60
seconds = seconds_diff
return hours * 60 + minutes
end
def self.convert_to_minutes(time)
arr = time.split(":")
hour = arr[0].to_i * 60
return hour + arr[1].to_i
end
end

View File

@@ -1,5 +1,6 @@
class DiningFacility < ApplicationRecord
belongs_to :zone
has_many :dining_charges
TABLE_TYPE = "Table"
ROOM_TYPE = "Room"

9
app/models/item_set.rb Normal file
View File

@@ -0,0 +1,9 @@
class ItemSet < ApplicationRecord
has_many :menu_item_sets
has_many :menu_items, through: :menu_item_sets
has_many :menu_instance_item_sets
has_many :menu_item_instances, through: :menu_instance_item_sets
validates_presence_of :name
end

View File

@@ -1,5 +1,5 @@
class MenuCategory < ApplicationRecord
before_create :generate_menu_category_code
# before_create :generate_menu_category_code
belongs_to :menu
has_many :children, :class_name => "MenuCategory", foreign_key: "menu_category_id"
@@ -37,7 +37,7 @@ class MenuCategory < ApplicationRecord
private
def generate_menu_category_code
self.code = SeedGenerator.generate_code(self.class.name, "C")
end
# def generate_menu_category_code
# self.code = SeedGenerator.generate_code(self.class.name, "C")
# end
end

View File

@@ -0,0 +1,4 @@
class MenuInstanceItemSet < ApplicationRecord
belongs_to :item_set
belongs_to :menu_item_instance
end

View File

@@ -1,6 +1,5 @@
class MenuItem < ApplicationRecord
before_create :generate_menu_item_code
# before_create :generate_menu_item_code
belongs_to :menu_category, :optional => true
has_many :menu_item_instances
@@ -8,6 +7,9 @@ class MenuItem < ApplicationRecord
has_many :children, :class_name => "MenuItem", foreign_key: "menu_item_id"
belongs_to :account
has_many :menu_item_sets
has_many :item_sets, through: :menu_item_sets
validates_presence_of :name, :type, :min_qty, :taxable, :min_selectable_item, :max_selectable_item
default_scope { order('item_code asc') }
@@ -15,6 +17,9 @@ class MenuItem < ApplicationRecord
scope :simple_menu_item, -> { where(type: 'SimpleMenuItem') }
scope :set_menu_item, -> { where(type: 'SetMenuItem') }
# Item Image Uploader
mount_uploader :image_path, MenuItemImageUploader
def self.collection
MenuItem.select("id, name").map { |e| [e.name, e.id] }
end
@@ -70,10 +75,10 @@ class MenuItem < ApplicationRecord
end
private
# private
def generate_menu_item_code
self.item_code = SeedGenerator.generate_code(self.class.name, "I")
end
# def generate_menu_item_code
# self.item_code = SeedGenerator.generate_code(self.class.name, "I")
# end
end

View File

@@ -1,6 +1,6 @@
class MenuItemInstance < ApplicationRecord
belongs_to :menu_item
before_create :generate_menu_item_instance_code
# before_create :generate_menu_item_instance_code
def self.findParentCategory(item)
if item.menu_category_id
@@ -11,9 +11,9 @@ class MenuItemInstance < ApplicationRecord
end
end
private
# private
def generate_menu_item_instance_code
self.item_instance_code = SeedGenerator.generate_code(self.class.name, "II")
end
# def generate_menu_item_instance_code
# self.item_instance_code = SeedGenerator.generate_code(self.class.name, "II")
# end
end

View File

@@ -0,0 +1,9 @@
class MenuItemSet < ApplicationRecord
belongs_to :item_set
belongs_to :menu_item
end
# class Settings::MenuItemSet < ApplicationRecord
# belongs_to :item_set_id
# belongs_to :menu_item_id
# end

View File

@@ -65,7 +65,6 @@ class Order < ApplicationRecord
end
def adding_line_items
if self.items
#re-order to
ordered_list = re_order_items(self.items)
@@ -320,12 +319,18 @@ class Order < ApplicationRecord
end
def self.search(search)
if search
# find(:all, :conditions => ['name LIKE ? OR contact_no LIKE ?', "%#{search}%", "%#{search}%"])
where("order_id LIKE ?", "%#{search}%")
def self.search(filter,from,to,count)
if count.to_i > 0
item_count = "and item_count = '#{count}'"
else
find(:all)
item_count = ''
end
if from.present? && to.present?
Order.where("DATE_FORMAT(date,'%d-%m-%Y') >= ?" + " AND DATE_FORMAT(date,'%d-%m-%Y') <= ? #{item_count}", from,to)
elsif !from.present? && !to.present? && count.present?
Order.where("item_count = '#{count}'")
else
Order.where("order_id LIKE ? OR status LIKE ? OR order_type LIKE ? OR source='#{filter}'","%#{filter}%","%#{filter}%","%#{filter}%",)
end
end

View File

@@ -22,14 +22,14 @@ class Printer::CashierStationPrinter < Printer::PrinterWorker
# end
#Bill Receipt Print
def print_close_cashier(printer_settings,shift_sale,shop_details,sale_taxes)
def print_close_cashier(printer_settings,shift_sale,shop_details,sale_taxes,other_payment,amount,discount,member_discount)
#Use CUPS service
#Generate PDF
#Print
cashier = shift_sale.employee.name
shift_name = shift_sale.shift_started_at.utc.getlocal.strftime("%d-%m-%Y %I:%M %p") + "_" + shift_sale.shift_closed_at.utc.getlocal.strftime("%d-%m-%Y %I:%M %p")
pdf = CloseCashierPdf.new(printer_settings,shift_sale,shop_details,sale_taxes)
pdf = CloseCashierPdf.new(printer_settings,shift_sale,shop_details,sale_taxes,other_payment,amount,discount,member_discount)
filename = "tmp/close_cashier_#{cashier}_#{shift_name}.pdf"
pdf.render_file filename
self.print(filename)

View File

@@ -91,7 +91,7 @@ class Sale < ApplicationRecord
add_item(item)
end
link_order_sale(order.id)
link_order_sale(order.id)
end
self.save!
@@ -109,6 +109,14 @@ class Sale < ApplicationRecord
booking.checkout_by = requested_by.name
booking.save
# dining charges
charges = DiningCharge.where('dining_facility_id=?',booking.dining_facility_id).take
if !charges.nil?
diningprice = DiningCharge.amount_calculate(charges, booking.checkin_at, booking.checkout_at)
dining_time = booking.checkin_at.strftime('%H:%M %p').to_s + " - " + booking.checkout_at.strftime('%H:%M %p').to_s
create_saleitem_diningcharges(charges, diningprice, booking.dining_facility.name, dining_time)
end
return true, self.id
end
@@ -162,6 +170,20 @@ class Sale < ApplicationRecord
self.sale_items << sale_item
end
def create_saleitem_diningcharges(chargeObj, diningprice, dining_name, dining_time)
sale_item = SaleItem.new
sale_item.product_code = chargeObj.item_code
sale_item.product_name = dining_name.to_s + " ( " + dining_time.to_s + " )"
# sale_item.account_id = item.account_id
sale_item.product_alt_name = "-"
sale_item.qty = 1
sale_item.unit_price = chargeObj.unit_price
sale_item.taxable_price = diningprice
sale_item.is_taxable = chargeObj.taxable
sale_item.sale_id = self.id
sale_item.price = diningprice
sale_item.save
end
def update_item (item)
#save sale_audit
@@ -232,7 +254,6 @@ class Sale < ApplicationRecord
end
#compute rounding adjustment
# adjust_rounding
sale.save!
end
@@ -246,7 +267,7 @@ class Sale < ApplicationRecord
rounding_adjustment = 0
sales_items.each do |item|
if item.remark != 'void'
if item.remark != 'void' && item.remark != 'foc'
#compute each item and added to total
subtotal_price = subtotal_price + item.price
total_taxable = total_taxable + item.price
@@ -274,25 +295,33 @@ class Sale < ApplicationRecord
total_tax_amount = 0
#tax_profile - list by order_by
tax_profiles = TaxProfile.all.order("order_by asc")
customer = Customer.find(sale.customer_id)
# #Creat new tax records
tax_profiles.each do |tax|
sale_tax = SaleTax.new(:sale => sale)
sale_tax.tax_name = tax.name
sale_tax.tax_rate = tax.rate
#include or execulive
# sale_tax.tax_payable_amount = total_taxable * tax.rate
customer.tax_profiles.each do |cus_tax|
if cus_tax.to_i == tax.id
sale_tax = SaleTax.new(:sale => sale)
sale_tax.tax_name = tax.name
sale_tax.tax_rate = tax.rate
# substract , to give after discount
total_tax = total_taxable - total_discount
sale_tax.tax_payable_amount = total_tax * tax.rate / 100
#new taxable amount is standard rule for step by step
# total_taxable = total_taxable + sale_tax.tax_payable_amount
# substract , to give after discount
total_tax = total_taxable - total_discount
#include or execulive
if tax.inclusive
rate = tax.rate
divided_value = (100 + rate)/rate
sale_tax.tax_payable_amount = total_tax / divided_value
else
sale_tax.tax_payable_amount = total_tax * tax.rate / 100
total_tax_amount = total_tax_amount + sale_tax.tax_payable_amount
end
#new taxable amount is standard rule for step by step
# total_taxable = total_taxable + sale_tax.tax_payable_amount
sale_tax.inclusive = tax.inclusive
sale_tax.save
total_tax_amount = total_tax_amount + sale_tax.tax_payable_amount
sale_tax.inclusive = tax.inclusive
sale_tax.save
end
end
end
sale.total_tax = total_tax_amount
@@ -300,12 +329,6 @@ class Sale < ApplicationRecord
# Tax Calculate
def apply_tax(total_taxable)
#if tax is not apply create new record
# self.sale_taxes.each do |existing_tax|
# #delete existing and create new
# existing_tax.delete
# end
#if tax is not apply create new record
SaleTax.where("sale_id='#{self.sale_id}'").find_each do |existing_tax|
#delete existing and create new
@@ -315,27 +338,38 @@ class Sale < ApplicationRecord
total_tax_amount = 0
#tax_profile - list by order_by
tax_profiles = TaxProfile.all.order("order_by asc")
customer = Customer.find(self.customer_id)
# #Creat new tax records
#Create new tax records
tax_profiles.each do |tax|
sale_tax = SaleTax.new(:sale => self)
sale_tax.tax_name = tax.name
sale_tax.tax_rate = tax.rate
#include or execulive
# sale_tax.tax_payable_amount = total_taxable * tax.rate
total_tax = total_taxable - self.total_discount
sale_tax.tax_payable_amount = total_tax * tax.rate / 100
#new taxable amount is standard rule for step by step
# total_taxable = total_taxable + sale_tax.tax_payable_amount
customer.tax_profiles.each do |cus_tax|
if cus_tax.to_i == tax.id
sale_tax = SaleTax.new(:sale => self)
sale_tax.tax_name = tax.name
sale_tax.tax_rate = tax.rate
sale_tax.inclusive = tax.inclusive
sale_tax.save
# substract , to give after discount
total_tax = total_taxable - self.total_discount
#include or execulive
if tax.inclusive
rate = tax.rate
divided_value = (100 + rate)/rate
sale_tax.tax_payable_amount = total_tax / divided_value
else
sale_tax.tax_payable_amount = total_tax * tax.rate / 100
total_tax_amount = total_tax_amount + sale_tax.tax_payable_amount
end
#new taxable amount is standard rule for step by step
# total_taxable = total_taxable + sale_tax.tax_payable_amount
total_tax_amount = total_tax_amount + sale_tax.tax_payable_amount
sale_tax.inclusive = tax.inclusive
sale_tax.save
end
end
end
self.total_tax = total_tax_amount
end
def product_get_unit_price(item_code)
@@ -352,7 +386,7 @@ class Sale < ApplicationRecord
if saleOrder.nil?
sale_order = SaleOrder.new
sale_order.create_sale_order(self.id, order_id)
sale = sale_order.create_sale_order(self.id, order_id)
end
# if (SaleOrder.where("sale_id = #{self.id} and order_id=#{order_id}").nil?)
# SaleOrder.create(:sale_id => self.id, :order_id => order_id)
@@ -379,13 +413,44 @@ class Sale < ApplicationRecord
end
end
def self.search(search)
if search
# find(:all, :conditions => ['name LIKE ? OR contact_no LIKE ?', "%#{search}%", "%#{search}%"])
where("receipt_no LIKE ?", "%#{search}%",)
def self.search(filter,from,to)
if filter.blank?
keyword = ''
else
find(:all)
keyword = "receipt_no LIKE ? OR cashier_name LIKE ? OR sale_status ='#{filter}'","%#{filter}%","%#{filter}%"
end
if from.present? && to.present?
sale = Sale.where("DATE_FORMAT(receipt_date,'%d-%m-%Y') >= ?" + " AND DATE_FORMAT(receipt_date,'%d-%m-%Y') <= ? and NOT sale_status = 'void' ", from,to)
query = sale.where(keyword)
else
where("receipt_no LIKE ? OR cashier_name LIKE ? OR sale_status ='#{filter}'","%#{filter}%","%#{filter}%",)
end
end
def self.search_credit_sales(customer,filter,from,to)
if filter.blank?
keyword = ''
else
keyword = "and receipt_no LIKE ? OR cashier_name LIKE ? OR sale_status ='#{filter}'","%#{filter}%","%#{filter}%"
end
if customer.blank?
custo = ''
else
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)
else
sale = Sale.all.joins("JOIN sale_payments sp on sp.sale_id = sales.sale_id")
.where("sp.payment_method ='creditnote' #{keyword} #{custo}")
end
end
def self.get_rounding_adjustment(num)
@@ -483,31 +548,25 @@ class Sale < ApplicationRecord
end
def self.get_by_range_by_saleitems(from,to,status,report_type)
query = Sale.select("
mi.item_code as code,(SUM(i.qty) * i.unit_price) as grand_total,
SUM(i.qty) as total_item," +
" i.unit_price as unit_price,
mi.name as product_name,
mc.name as menu_category_name,
mc.id as menu_category_id ")
.group('mi.id')
.order("mi.menu_category_id")
query = Sale.select("
mi.item_code as code,(SUM(i.qty) * i.unit_price) as grand_total,
SUM(i.qty) as total_item," +
" i.unit_price as unit_price,
mi.name as product_name,
mc.name as menu_category_name,
mc.id as menu_category_id ")
.group('mi.id')
.order("mi.menu_category_id")
query = query.joins("JOIN sale_items i ON i.sale_id = sales.sale_id
JOIN menu_items mi ON i.product_code = mi.item_code" +
" JOIN menu_categories mc ON mc.id = mi.menu_category_id
JOIN employees ea ON ea.id = sales.cashier_id")
query = query.where("(receipt_date between ? and ? and sale_status=?) AND i.unit_price <> 0",from,to,status)
query = query.joins("JOIN sale_items i ON i.sale_id = sales.sale_id
JOIN menu_items mi ON i.product_code = mi.item_code" +
" JOIN menu_categories mc ON mc.id = mi.menu_category_id
JOIN employees ea ON ea.id = sales.cashier_id")
query = query.where("(receipt_date between ? and ? and sale_status=?) AND i.unit_price <> 0",from,to,status)
end
def self.get_by_shiftsales(from,to,shift)
if !shift.blank?
ShiftSale.where("id =?",shift.id)
@@ -520,97 +579,95 @@ def self.get_by_shift_sale(from,to,status)
query = ShiftSale.select("shift_sales.id ,shift_started_at AS opening_date,
shift_closed_at As closing_date," +
" grand_total AS grand_total, cash_sales AS cash," +
"total_taxes AS total_tax,total_discounts As total_discount")
"total_taxes AS total_tax,total_discounts As total_discount")
.order("shift_sales.id DESC")
return query = query.where("shift_sales.shift_started_at >= ?" + " AND shift_sales.shift_closed_at <= ?", from,to)
end
def self.get_item_query()
query = Sale.select("acc.title as account_name,mi.account_id, mi.item_code as item_code, " +
query = Sale.select("acc.title as account_name,mi.account_id, mi.item_code as item_code, " +
"(SUM(i.qty * i.unit_price)) as grand_total,SUM(i.qty) as total_item," +
" i.unit_price as unit_price,mi.name as product_name, mc.name as" +
" menu_category_name,mc.id as menu_category_id ")
query = query.joins("JOIN sale_items i ON i.sale_id = sales.sale_id JOIN menu_items mi ON i.product_code = mi.item_code" +
query = query.joins("JOIN sale_items i ON i.sale_id = sales.sale_id JOIN menu_items mi ON i.product_code = mi.item_code" +
" JOIN shift_sales sh ON sh.`id` = sales.shift_sale_id JOIN menu_categories mc ON mc.id = mi.menu_category_id ")
# "JOIN employee_accesses ea ON ea.`employee_id` = sales.cashier_id ")
query = query.joins(" JOIN accounts acc ON acc.id = mi.account_id")
query = query.group('i.product_code ').order("mi.account_id, mi.menu_category_id")
end
def self.get_by_shift_items(shift_sale_range, shift, from, to, status)
# date_type_selection = get_sql_function_for_report_type(report_type)
query = self.get_item_query()
discount_query = 0
total_card_amount = 0
total_cash_amount = 0
total_credit_amount = 0
total_foc_amount = 0
total_grand_total = 0
end
if shift.present?
query = query.where("sales.shift_sale_id IN (?) and sale_status='completed'",shift.to_a)
discount_query = Sale.where("sales.shift_sale_id in (?) and sale_status= 'completed' ", shift.to_a).sum(:total_discount)
change_amount = Sale.where("sales.shift_sale_id in (?) and sale_status= 'completed' ", shift.to_a).sum(:amount_changed)
sale_cash = Sale.select("SUM(case when (sale_payments.payment_method ='mpu' or sale_payments.payment_method = 'visa' or sale_payments.payment_method = 'master' or sale_payments.payment_method = 'jcb' or sale_payments.payment_method = 'paypar') then (sale_payments.payment_amount) else 0 end) as card_amount,
SUM(case when (sale_payments.payment_method='cash') then (sale_payments.payment_amount) else 0 end) as cash_amount,
SUM(case when (sale_payments.payment_method='creditnote') then (sale_payments.payment_amount) else 0 end) as credit_amount,
SUM(case when (sale_payments.payment_method='foc') then (sale_payments.payment_amount) else 0 end) as foc_amount")
.joins("join sale_payments on sale_payments.sale_id = sales.sale_id")
.where("sales.shift_sale_id in (?) and sale_status = 'completed' and sale_payments.payment_amount != 0 ", shift.to_a)
sale_cash.each do |s_c|
total_cash_amount += s_c.cash_amount.to_f
total_card_amount += s_c.card_amount.to_f
total_credit_amount += s_c.credit_amount.to_f
total_foc_amount += s_c.foc_amount.to_f
end
total_grand_total = total_cash_amount.to_f + total_card_amount.to_f + total_credit_amount.to_f
### => get all sales range in shift_sales
elsif shift_sale_range.present?
query = query.where("sales.shift_sale_id IN (?) and sale_status='completed'",shift_sale_range.to_a)
discount_query = Sale.where("sales.shift_sale_id IN (?) and sale_status ='completed'", shift_sale_range.to_a).sum(:total_discount)
change_amount = Sale.where("sales.shift_sale_id IN (?) and sale_status ='completed'", shift_sale_range.to_a).sum(:amount_changed)
sale_cash = Sale.select("SUM(case when (sale_payments.payment_method = 'mpu' or sale_payments.payment_method = 'visa' or sale_payments.payment_method = 'master' or sale_payments.payment_method = 'jcb' or sale_payments.payment_method = 'paypar') then (sale_payments.payment_amount) else 0 end) as card_amount,
SUM(case when (sale_payments.payment_method='cash') then (sale_payments.payment_amount) else 0 end) as cash_amount,
SUM(case when (sale_payments.payment_method='creditnote') then (sale_payments.payment_amount) else 0 end) as credit_amount,
SUM(case when (sale_payments.payment_method='foc') then (sale_payments.payment_amount) else 0 end) as foc_amount")
.joins("join sale_payments on sale_payments.sale_id = sales.sale_id")
.where("sales.shift_sale_id in (?) and sale_status = 'completed' and sale_payments.payment_amount != 0 ", shift_sale_range.to_a)
sale_cash.each do |s_c|
total_cash_amount += s_c.cash_amount.to_f
total_card_amount += s_c.card_amount.to_f
total_credit_amount += s_c.credit_amount.to_f
total_foc_amount += s_c.foc_amount.to_f
end
total_grand_total = total_cash_amount.to_f + total_card_amount.to_f + total_credit_amount.to_f
else
query = query.where("sales.receipt_date between ? and ? and sale_status='completed'",from,to)
discount_query = Sale.where("sales.receipt_date between ? and ? and sale_status ='completed'", from,to).sum(:total_discount)
change_amount = Sale.where("sales.receipt_date between ? and ? and sale_status ='completed'", from,to).sum(:amount_changed)
sale_cash = Sale.select("SUM(case when (sale_payments.payment_method = 'mpu' or sale_payments.payment_method = 'visa' or sale_payments.payment_method = 'master' or sale_payments.payment_method = 'jcb' or sale_payments.payment_method = 'paypar') then (sale_payments.payment_amount) else 0 end) as card_amount,
SUM(case when (sale_payments.payment_method='cash') then (sale_payments.payment_amount) else 0 end) as cash_amount,
SUM(case when (sale_payments.payment_method='creditnote') then (sale_payments.payment_amount) else 0 end) as credit_amount,
SUM(case when (sale_payments.payment_method='foc') then (sale_payments.payment_amount) else 0 end) as foc_amount")
.joins("join sale_payments on sale_payments.sale_id = sales.sale_id")
.where("sales.receipt_date between ? and ? and sale_status = 'completed' and sale_payments.payment_amount != 0 ", from,to)
sale_cash.each do |s_c|
total_cash_amount += s_c.cash_amount.to_f
total_card_amount += s_c.card_amount.to_f
total_credit_amount += s_c.credit_amount.to_f
total_foc_amount += s_c.foc_amount.to_f
end
total_grand_total = total_cash_amount.to_f + total_card_amount.to_f + total_credit_amount.to_f
end
def self.get_by_shift_items(shift_sale_range, shift, from, to, status)
# date_type_selection = get_sql_function_for_report_type(report_type)
return query, discount_query , total_cash_amount , total_card_amount , total_credit_amount , total_foc_amount , total_grand_total , change_amount
end
query = self.get_item_query()
discount_query = 0
total_card_amount = 0
total_cash_amount = 0
total_credit_amount = 0
total_foc_amount = 0
total_grand_total = 0
if shift.present?
query = query.where("sales.shift_sale_id IN (?) and sale_status='completed'",shift.to_a)
discount_query = Sale.where("sales.shift_sale_id in (?) and sale_status= 'completed' ", shift.to_a).sum(:total_discount)
change_amount = Sale.where("sales.shift_sale_id in (?) and sale_status= 'completed' ", shift.to_a).sum(:amount_changed)
sale_cash = Sale.select("SUM(case when (sale_payments.payment_method ='mpu' or sale_payments.payment_method = 'visa' or sale_payments.payment_method = 'master' or sale_payments.payment_method = 'jcb' or sale_payments.payment_method = 'paypar') then (sale_payments.payment_amount) else 0 end) as card_amount,
SUM(case when (sale_payments.payment_method='cash') then (sale_payments.payment_amount) else 0 end) as cash_amount,
SUM(case when (sale_payments.payment_method='creditnote') then (sale_payments.payment_amount) else 0 end) as credit_amount,
SUM(case when (sale_payments.payment_method='foc') then (sale_payments.payment_amount) else 0 end) as foc_amount")
.joins("join sale_payments on sale_payments.sale_id = sales.sale_id")
.where("sales.shift_sale_id in (?) and sale_status = 'completed' and sale_payments.payment_amount != 0 ", shift.to_a)
sale_cash.each do |s_c|
total_cash_amount += s_c.cash_amount.to_f
total_card_amount += s_c.card_amount.to_f
total_credit_amount += s_c.credit_amount.to_f
total_foc_amount += s_c.foc_amount.to_f
end
total_grand_total = total_cash_amount.to_f + total_card_amount.to_f + total_credit_amount.to_f
### => get all sales range in shift_sales
elsif shift_sale_range.present?
query = query.where("sales.shift_sale_id IN (?) and sale_status='completed'",shift_sale_range.to_a)
discount_query = Sale.where("sales.shift_sale_id IN (?) and sale_status ='completed'", shift_sale_range.to_a).sum(:total_discount)
change_amount = Sale.where("sales.shift_sale_id IN (?) and sale_status ='completed'", shift_sale_range.to_a).sum(:amount_changed)
sale_cash = Sale.select("SUM(case when (sale_payments.payment_method = 'mpu' or sale_payments.payment_method = 'visa' or sale_payments.payment_method = 'master' or sale_payments.payment_method = 'jcb' or sale_payments.payment_method = 'paypar') then (sale_payments.payment_amount) else 0 end) as card_amount,
SUM(case when (sale_payments.payment_method='cash') then (sale_payments.payment_amount) else 0 end) as cash_amount,
SUM(case when (sale_payments.payment_method='creditnote') then (sale_payments.payment_amount) else 0 end) as credit_amount,
SUM(case when (sale_payments.payment_method='foc') then (sale_payments.payment_amount) else 0 end) as foc_amount")
.joins("join sale_payments on sale_payments.sale_id = sales.sale_id")
.where("sales.shift_sale_id in (?) and sale_status = 'completed' and sale_payments.payment_amount != 0 ", shift_sale_range.to_a)
sale_cash.each do |s_c|
total_cash_amount += s_c.cash_amount.to_f
total_card_amount += s_c.card_amount.to_f
total_credit_amount += s_c.credit_amount.to_f
total_foc_amount += s_c.foc_amount.to_f
end
total_grand_total = total_cash_amount.to_f + total_card_amount.to_f + total_credit_amount.to_f
else
query = query.where("sales.receipt_date between ? and ? and sale_status='completed'",from,to)
discount_query = Sale.where("sales.receipt_date between ? and ? and sale_status ='completed'", from,to).sum(:total_discount)
change_amount = Sale.where("sales.receipt_date between ? and ? and sale_status ='completed'", from,to).sum(:amount_changed)
sale_cash = Sale.select("SUM(case when (sale_payments.payment_method = 'mpu' or sale_payments.payment_method = 'visa' or sale_payments.payment_method = 'master' or sale_payments.payment_method = 'jcb' or sale_payments.payment_method = 'paypar') then (sale_payments.payment_amount) else 0 end) as card_amount,
SUM(case when (sale_payments.payment_method='cash') then (sale_payments.payment_amount) else 0 end) as cash_amount,
SUM(case when (sale_payments.payment_method='creditnote') then (sale_payments.payment_amount) else 0 end) as credit_amount,
SUM(case when (sale_payments.payment_method='foc') then (sale_payments.payment_amount) else 0 end) as foc_amount")
.joins("join sale_payments on sale_payments.sale_id = sales.sale_id")
.where("sales.receipt_date between ? and ? and sale_status = 'completed' and sale_payments.payment_amount != 0 ", from,to)
sale_cash.each do |s_c|
total_cash_amount += s_c.cash_amount.to_f
total_card_amount += s_c.card_amount.to_f
total_credit_amount += s_c.credit_amount.to_f
total_foc_amount += s_c.foc_amount.to_f
end
total_grand_total = total_cash_amount.to_f + total_card_amount.to_f + total_credit_amount.to_f
end
return query, discount_query , total_cash_amount , total_card_amount , total_credit_amount , total_foc_amount , total_grand_total , change_amount
end
def self.get_shift_sales_by_receipt_no(shift_sale_range,shift,from,to,payment_type)
## => left join -> show all sales although no orders
@@ -623,7 +680,7 @@ def self.get_shift_sales_by_receipt_no(shift_sale_range,shift,from,to,payment_ty
payment_type = " and sale_payments.payment_method = '#{payment_type}'"
end
end
query = Sale.all
if shift.present?
@@ -642,9 +699,41 @@ def self.get_shift_sales_by_receipt_no(shift_sale_range,shift,from,to,payment_ty
query = query.where("sale_status='completed' and sales.receipt_date between ? and ? #{payment_type} and sale_payments.payment_amount != 0",from,to)
.joins("join sale_payments on sale_payments.sale_id = sales.sale_id")
.group("sales.sale_id")
end
end
end
end
def self.get_by_shift_sale_credit_payment(shift_sale_range,shift,from,to)
query = SalePayment.select("s.receipt_no, sale_payments.*,s.receipt_date as sale_date,
s.cashier_name as cashier_name")
.joins("INNER JOIN sales s ON s.sale_id = sale_payments.sale_id")
if shift.present?
query = query.where("payment_method= 'creditnote' and s.sale_status = 'completed' and s.shift_sale_id in (?)",shift.to_a)
elsif shift_sale_range.present?
query = query.where("payment_method='creditnote' and s.sale_status = 'completed' and s.shift_sale_id in (?)",shift_sale_range.to_a)
else
query = query.where("payment_method='creditnote' and s.sale_status = 'completed' and s.receipt_date between ? and ? ",from,to)
end
end
def self.get_void_sale(shift,from,to)
sale_arr = Array.new
query = Sale.select("sales.receipt_no,sales.receipt_date, sales.payment_status, sales.sale_status,sales.total_amount,sales.grand_total, sales.rounding_adjustment")
# .joins("INNER JOIN shift_sales sh ON sh.id = sales.shift_sale_id")
# .where("sales.sale_status = 'void' and (sh.shift_started_at between ? and ?
# OR sh.shift_closed_at between ? and ? )", from ,to, from, to)
if shift.present?
query = query.where("sales.sale_status = 'void' and sales.shift_sale_id in (?)",shift.to_a)
else
query = query.where("sales.sale_status = 'void' and sales.receipt_date between ? and ? ",from,to)
end
out = {:items => query}
sale_arr.push(out)
return sale_arr
end
def self.get_separate_tax(shift_sale_range=nil,shift,from,to,payment_type)
@@ -661,10 +750,10 @@ def self.get_separate_tax(shift_sale_range=nil,shift,from,to,payment_type)
if shift.present?
query = SaleTax.select("SUM(tax_payable_amount) AS st_amount,tax_name")
.joins("LEFT JOIN sales ON sales.sale_id = sale_taxes.sale_id")
.joins("join sale_payments on sale_payments.sale_id = sales.sale_id")
.where("sales.shift_sale_id in (?) #{payment_type} and sale_status= 'completed' and sale_payments.payment_amount != 0", shift.to_a)
.joins("join sale_payments on sale_payments.sale_id = sales.sale_id")
.where("sales.shift_sale_id in (?) #{payment_type} and sale_status= 'completed' and sale_payments.payment_amount != 0", shift.to_a)
.group("sale_taxes.tax_name")
.order("sale_taxes.sale_tax_id asc")
.order("sale_taxes.sale_tax_id asc")
elsif shift_sale_range.present?
query = SaleTax.select("SUM(tax_payable_amount) AS st_amount,tax_name")
.joins("LEFT JOIN sales ON sales.sale_id = sale_taxes.sale_id")
@@ -679,27 +768,15 @@ def self.get_separate_tax(shift_sale_range=nil,shift,from,to,payment_type)
.where("sales.receipt_date between ? and ? #{payment_type} and sale_status= 'completed' and sale_payments.payment_amount != 0", from,to)
.group("sale_taxes.tax_name")
.order("sale_taxes.sale_tax_id asc")
end
# query = SaleTax.select("SUM(tax_payable_amount) AS st_amount,tax_name")
# .joins("INNER JOIN sales ON sales.sale_id = sale_taxes.sale_id")
# .joins("join sale_payments on sale_payments.sale_id = sales.sale_id")
# .group("sale_taxes.tax_name")
# .order("sale_taxes.sale_tax_id asc")
# if shift.present?
# query = query.where("sales.shift_sale_id in (?) #{payment_type} and sale_status= 'completed'", shift.to_a)
# else
# query = query.where("sales.receipt_date between ? and ? #{payment_type} and sale_status= 'completed' ",from,to)
# end
end
end
# def self.get_separate_tax(from,to,payment_method=nil)
# query = SaleTax.select("SUM(tax_payable_amount) AS st_amount,tax_name")
# .joins("INNER JOIN sales ON sales.sale_id = sale_taxes.sale_id")
# .group("sale_taxes.tax_name")
# return query = query.where("sale_status=? and receipt_date between ? and ?","completed",from,to)
# end

View File

@@ -46,6 +46,8 @@ class SalePayment < ApplicationRecord
payment_status = giftcard_payment
when "paypar"
payment_status = paypar_payment
when "foc"
payment_status = foc_payment
else
puts "it was something else"
end
@@ -164,6 +166,17 @@ class SalePayment < ApplicationRecord
return payment_status
end
def foc_payment
payment_status = false
self.payment_method = "foc"
self.payment_amount = self.received_amount
self.outstanding_amount = self.sale.grand_total.to_f - self.received_amount.to_f
self.payment_status = "paid"
payment_method = self.save!
sale_update_payment_status(self.received_amount)
return payment_status
end
def creditnote_payment(customer_id)
payment_status = false
@@ -257,11 +270,15 @@ class SalePayment < ApplicationRecord
all_received_amount = 0.0
sObj = Sale.find(self.sale_id)
is_credit = 0
is_foc = 0
sObj.sale_payments.each do |spay|
all_received_amount += spay.payment_amount.to_f
if spay.payment_method == "creditnote"
is_credit = 1
end
if spay.payment_method == "foc"
is_foc = 1
end
end
if (self.sale.grand_total <= all_received_amount)
if is_credit == 0
@@ -269,9 +286,16 @@ class SalePayment < ApplicationRecord
else
self.sale.payment_status = "outstanding"
end
if is_foc == 0
self.sale.payment_status = "paid"
else
self.sale.payment_status = "foc"
end
self.sale.sale_status = "completed"
if MembershipSetting.find_by_rebate(1)
if MembershipSetting.find_by_rebate(1) && is_foc == 0
response = rebat(sObj)
if !response.nil?
@@ -390,20 +414,21 @@ class SalePayment < ApplicationRecord
total_percentage = 0
type_arr = []
response["membership_campaign_data"].each do |a|
data = {:type => a["rules_type"], :percentage => a["change_unit"].to_i * a["base_unit"].to_i}
total_percentage = total_percentage + a["change_unit"].to_i * a["base_unit"].to_i
type_arr.push(data)
# Check for present response fields
if response["membership_campaign_data"].present?
response["membership_campaign_data"].each do |a|
data = {:type => a["rules_type"], :percentage => a["change_unit"].to_i * a["base_unit"].to_i}
total_percentage = total_percentage + a["change_unit"].to_i * a["base_unit"].to_i
type_arr.push(data)
end
end
rebate_arr =[]
campaign_method.each do |a|
data = {:type => a[:type], :amount => a[:amount]}
puts data
type_arr.each do |si|
if si[:type] == a[:type]
puts "steeeeeeeeeeeee"
amount = (redeem_amount / total_percentage)*si[:percentage]
actual = a[:amount] - amount
data[:amount] = actual
@@ -411,10 +436,8 @@ class SalePayment < ApplicationRecord
end
rebate_arr.push(data)
end
puts "ssssssssss"
puts rebate_arr.to_json
total_amount = rebate_prices - payparcost - overall_dis
if credit == 1
@@ -455,8 +478,6 @@ class SalePayment < ApplicationRecord
response = { "status": false, "message": "Can't connect server"}
end
return response
puts "latest respppppp"
puts response.to_json
end
else
response = { "status": "no_member", "message": "Not membership"}

View File

@@ -35,7 +35,7 @@ class SeedGenerator < ApplicationRecord
else
current_no = seed.next
seed.next = seed.next + seed.increase_by
seed.next = seed.next
seed.current = current_no
seed.save
end

View File

@@ -57,6 +57,11 @@ class ShiftSale < ApplicationRecord
self.commercial_taxes = self.commercial_taxes.to_i + tax.to_f
self.total_rounding = self.total_rounding + saleobj.rounding_adjustment
self.total_receipt = self.total_receipt + 1
if saleobj.customer.customer_type == "Dinein"
self.dining_count = self.dining_count + 1
else
self.takeaway_count = self.takeaway_count + 1
end
self.save
end
@@ -79,6 +84,11 @@ class ShiftSale < ApplicationRecord
self.commercial_taxes = self.commercial_taxes.to_i - tax.to_f
self.total_rounding = self.total_rounding - saleobj.rounding_adjustment
self.total_void = self.total_void + saleobj.grand_total
if saleobj.customer.customer_type == "Dinein"
self.dining_count = self.dining_count - 1
else
self.takeaway_count = self.takeaway_count - 1
end
self.save
end
end
@@ -88,4 +98,40 @@ class ShiftSale < ApplicationRecord
closing_balance = shiftobj.grand_total + shiftobj.cash_in - shiftobj.cash_out + shiftobj.total_cash
return closing_balance
end
def self.get_by_shift_other_payment(shift)
other_payment = Sale.select("sale_payments.payment_method as name,
SUM(case when (sale_payments.payment_method='mpu') then (sale_payments.payment_amount) else 0 end) as mpu_amount,
SUM(case when (sale_payments.payment_method='visa') then (sale_payments.payment_amount) else 0 end) as visa_amount,
SUM(case when (sale_payments.payment_method='master') then (sale_payments.payment_amount) else 0 end) as master_amount,
SUM(case when (sale_payments.payment_method='jcb') then (sale_payments.payment_amount) else 0 end) as jcb_amount,
SUM(case when (sale_payments.payment_method='foc') then (sale_payments.payment_amount) else 0 end) as foc_amount,
SUM(case when (sale_payments.payment_method='paypar') then (sale_payments.payment_amount) else 0 end) as paypar_amount")
.joins("join sale_payments on sale_payments.sale_id = sales.sale_id")
.where("sales.shift_sale_id =? and sale_status = 'completed' and sale_payments.payment_amount != 0 ", shift.id)
end
def self.calculate_total_price_by_accounts(shift,type)
query = Sale.select("acc.title as account_name," +
"SUM(case when (acc.id=i.account_id) then (i.price) else 0 end) as total_price")
query = query.joins("JOIN sale_items i ON i.sale_id = sales.sale_id "+
"JOIN accounts acc ON acc.id = i.account_id" +
" JOIN shift_sales sh ON sh.`id` = sales.shift_sale_id")
if type == 'discount'
query = query.where("sales.shift_sale_id =? and sale_status = 'completed' and i.is_taxable = false and i.remark = 'Discount'", shift.id)
.group("acc.title").order("acc.id")
else
query = query.where("sales.shift_sale_id =? and sale_status = 'completed'", shift.id)
.group("acc.title").order("acc.id")
end
end
def self.get_total_member_discount(shift)
query = Sale.select("SUM(sales.total_discount) as member_discount")
.where("shift_sale_id =? and sale_status = 'completed' and discount_type = 'member_discount'", shift.id)
end
end

View File

@@ -1,8 +1,9 @@
class CloseCashierPdf < 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,:text_width
def initialize(printer_settings, shift_sale,shop_details,sale_taxes)
self.page_width = 210
self.page_height = 7000
def initialize(printer_settings, shift_sale,shop_details,sale_taxes,other_payment,total_amount_by_account,total_discount_by_account,total_member_discount)
self.page_width = printer_settings.page_width #PrintSetting.where("name = ?","Close Cashier").first.page_width
self.page_height = printer_settings.page_height
self.margin = 5
self.price_width = 40
self.qty_width = 20
@@ -26,16 +27,11 @@ class CloseCashierPdf < Prawn::Document
self.header_font_size = 10
self.item_font_size = 8
header( shop_details)
stroke_horizontal_rule
shift_detail(shift_sale,sale_taxes)
shift_detail(shift_sale,sale_taxes,other_payment,total_amount_by_account,total_discount_by_account,total_member_discount)
end
def header (shop_details)
@@ -51,7 +47,7 @@ class CloseCashierPdf < Prawn::Document
stroke_horizontal_rule
end
def shift_detail(shift_sale,sale_taxes)
def shift_detail(shift_sale,sale_taxes,other_payment,total_amount_by_account,total_discount_by_account,total_member_discount)
move_down 7
y_position = cursor
bounding_box([0,y_position], :width =>self.label_width, :height => self.item_height) do
@@ -151,6 +147,10 @@ class CloseCashierPdf < Prawn::Document
text "#{shift_sale.total_taxes}", :size => self.item_font_size, :align => :right
end
move_down -5
stroke_horizontal_rule
move_down 7
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
text "Cash Payment :", :size => self.item_font_size, :align => :right
@@ -166,14 +166,91 @@ class CloseCashierPdf < Prawn::Document
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
text "#{shift_sale.credit_sales}", :size => self.item_font_size, :align => :right
end
#start other payment details
if shift_sale.other_sales > 0
other_payment.each do |other|
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
text "Other Payment Details", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
text "", :size => self.item_font_size, :align => :right
end
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
text "Other Payment :", :size => self.item_font_size, :align => :right
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
text "MPU Payment :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
text "#{other.mpu_amount.round(2)}", :size => self.item_font_size, :align => :right
end
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
text "VISA Payment :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
text "#{other.visa_amount.round(2)}", :size => self.item_font_size, :align => :right
end
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
text "JCB Payment :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
text "#{other.master_amount.round(2)}", :size => self.item_font_size, :align => :right
end
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
text "Master Payment :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
text "#{other.jcb_amount.round(2)}", :size => self.item_font_size, :align => :right
end
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
text "Reedem Payment :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
text "#{other.paypar_amount.round(2)}", :size => self.item_font_size, :align => :right
end
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
text "FOC :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
text "#{other.foc_amount.round(2)}", :size => self.item_font_size, :align => :right
end
end
else
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
text "Other Payment :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
text "#{shift_sale.other_sales}", :size => self.item_font_size, :align => :right
end
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
text "#{shift_sale.other_sales}", :size => self.item_font_size, :align => :right
# end other payment details
move_down -5
stroke_horizontal_rule
move_down 7
#start total amount by Account Like Food / Beverage /..
total_amount_by_account.each do |amount|
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
text "Total #{amount.account_name} Amount:", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
text "#{amount.total_price.round(2)} ", :size => self.item_font_size, :align => :right
end
end
#end total amount by Account
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
@@ -183,14 +260,57 @@ class CloseCashierPdf < Prawn::Document
text "#{shift_sale.total_revenue}", :size => self.item_font_size, :align => :right
end
move_down -5
stroke_horizontal_rule
move_down 7
#start total amount by Account Like Food / Beverage /..
total_discount_by_account.each do |amount|
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
text "Total #{amount.account_name} Discount:", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
text "#{amount.total_price.round(2)} ", :size => self.item_font_size, :align => :right
end
end
#end total amount by Account
if total_member_discount[0].member_discount.present?
@member_discount = total_member_discount[0].member_discount rescue 0.0
@overall = shift_sale.total_discounts - @member_discount
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
text "Total Member Discount :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
text "#{@member_discount}", :size => self.item_font_size, :align => :right
end
else
@overall = shift_sale.total_discounts
end
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
text "Discount Amount :", :size => self.item_font_size, :align => :right
text "Total Overall Discount :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
text "#{@overall}", :size => self.item_font_size, :align => :right
end
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
text "Total Discount Amount :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
text "#{shift_sale.total_discounts}", :size => self.item_font_size, :align => :right
end
move_down -5
stroke_horizontal_rule
move_down 7
sale_taxes.each do |tax|
y_position = cursor
@@ -200,6 +320,13 @@ class CloseCashierPdf < Prawn::Document
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
text "#{tax.st_amount.round(2)}", :size => self.item_font_size, :align => :right
end
end
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
text "Rounding Adjustment :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
text "#{shift_sale.total_rounding.round(2)}", :size => self.item_font_size, :align => :right
end
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
@@ -217,6 +344,22 @@ class CloseCashierPdf < Prawn::Document
text "#{shift_sale.total_receipt}", :size => self.item_font_size, :align => :right
end
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
text "Dining Count :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
text "#{shift_sale.dining_count}", :size => self.item_font_size, :align => :right
end
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
text "Takeaway Count :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
text "#{shift_sale.takeaway_count}", :size => self.item_font_size, :align => :right
end
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
text "Total Void:", :size => self.item_font_size, :align => :right
@@ -229,8 +372,6 @@ class CloseCashierPdf < Prawn::Document
stroke_horizontal_rule
move_down 5
move_down 5
end
end

View File

@@ -1,8 +1,8 @@
class CrmOrderPdf < Prawn::Document
attr_accessor :receipt_width,:price_column_width,:p_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_column_width,:item_description_width
def initialize(booking,order_items,printer_settings)
self.p_width = 200
self.page_height = 1450
self.page_width = PrintSetting.where("name = ?","CRM Order").first.page_width
self.page_height = PrintSetting.where("name = ?","CRM Order").first.page_height
self.margin = 10
# self.price_width = self.p_width / 2
self.price_width=80

View File

@@ -2,8 +2,8 @@ class OrderItemPdf < 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
def initialize(print_settings,order_item, print_status, options, alt_name)
self.page_width = 185
self.page_height = 1450
self.page_width = PrintSetting.where("name = ?","OrderItemPdf").first.page_width
self.page_height = PrintSetting.where("name = ?","OrderItemPdf").first.page_height
self.margin = 0
self.price_width = 40 # No Need for item
self.qty_width = 40

View File

@@ -2,8 +2,8 @@ class OrderSummaryPdf < 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
def initialize(print_settings,order, print_status, order_items = nil,alt_name)
self.page_width = 190
self.page_height = 1450
self.page_width = PrintSetting.where("name = ?","Order Summary").first.page_width
self.page_height = PrintSetting.where("name = ?","Order Summary").first.page_height
self.margin = 0
self.price_width = 40 # No Need for item
self.qty_width = 40

View File

@@ -1,8 +1,8 @@
class QueueNoPdf < 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
def initialize(printer_settings, queue)
self.page_width = 210
self.page_height = 1450
self.page_width = PrintSetting.where("name = ?","Queue No").first.page_width
self.page_height = PrintSetting.where("name = ?","Queue No").first.page_height
self.margin = 5
self.price_width = 35
self.qty_width = 20

View File

@@ -2,8 +2,8 @@ class ReceiptBillPdf < 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
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)
self.page_width = 210
self.page_height = 7000
self.page_width = PrintSetting.where("name = ?","Receipt Bill").first.page_width
self.page_height = PrintSetting.where("name = ?","Receipt Bill").first.page_height
self.margin = 5
self.price_width = 40
self.qty_width = 20
@@ -54,8 +54,9 @@ class ReceiptBillPdf < Prawn::Document
end
items_account(item_price_by_accounts,printer_settings.precision,delimiter)
sign(sale_data)
footer(printed_status)
end
@@ -237,12 +238,10 @@ class ReceiptBillPdf < Prawn::Document
end
def sale_payment(sale_data,precision,delimiter)
def sale_payment(sale_data,precision,delimiter)
stroke_horizontal_rule
move_down 5
SalePayment.where('sale_id = ?', sale_data.sale_id).each do |payment|
y_position = cursor
if payment.payment_method == "paypar"
bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do
@@ -269,20 +268,20 @@ class ReceiptBillPdf < Prawn::Document
text "#{number_with_precision(sale_data.amount_changed, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right
end
move_down 5
end
end
end
# show member information
def member_info(member_info,customer_name,rebate_amount,sale_data,precision,delimiter)
if rebate_amount != nil
if rebate_amount != nil
if rebate_amount["status"] == true
stroke_horizontal_rule
total = 0
balance = 0
rebate_balance =0
redeem = 0
rebate_amount["data"].each do |res|
total = total + res["balance"]
#total redeem amount
if res["receipt_no"]== sale_data.receipt_no && res["status"]== "Redeem"
redeem = redeem + res["redeem"]
@@ -292,7 +291,7 @@ class ReceiptBillPdf < Prawn::Document
#total Rebate Earn
if res["receipt_no"]== sale_data.receipt_no && res["account_status"]== "RebateAccount" && res["status"]== "Rebate"
# balance = balance + res["balance"]
rebate_balance = rebate_balance + res["rebate"]
move_down 5
y_position = cursor
@@ -306,7 +305,7 @@ class ReceiptBillPdf < Prawn::Document
end
# Total Rebate Amount if birthday
if res["receipt_no"]== sale_data.receipt_no && res["account_status"]== "RebateBonusAccount" && res["status"]== "Rebate"
# balance = balance + res["balance"]
rebate_balance = rebate_balance + res["rebate"]
move_down 5
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do
@@ -328,7 +327,12 @@ class ReceiptBillPdf < Prawn::Document
text "#{number_with_precision(redeem, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size,:align => :right
end
old = balance + redeem
if redeem == 0
old = total - rebate_balance
else
old = balance + redeem
end
move_down 5
y_position = cursor
@@ -343,11 +347,11 @@ class ReceiptBillPdf < Prawn::Document
end
if member_info["status"] == true && member_info["data"].present?
balance = 0
total_balance = 0
member_info["data"].each do |res|
if res["accountable_type"] == "RebateAccount" || res["accountable_type"] == "RebatebonusAccount"
balance = balance + res["balance"]
total_balance = total_balance + res["balance"]
end
@@ -358,7 +362,7 @@ class ReceiptBillPdf < Prawn::Document
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(balance, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right
text "#{number_with_precision(total_balance, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right
end
end
@@ -406,6 +410,43 @@ class ReceiptBillPdf < Prawn::Document
end
end
def sign(sale_data)
SalePayment.where('sale_id = ?', sale_data.sale_id).each do |payment|
if payment.payment_method == "creditnote"
y_position = cursor
stroke_horizontal_rule
bounding_box([self.label_width,y_position], :width =>self.item_description_width) do
move_down 70
stroke_horizontal_rule
end
bounding_box([self.label_width,y_position], :width =>self.item_description_width) do
move_down 73
text "Approved By" , :size => self.item_font_size,:align => :center
end
end
end
if sale_data.payment_status == "foc"
y_position = cursor
stroke_horizontal_rule
bounding_box([self.label_width,y_position], :width =>self.item_description_width) do
move_down 70
stroke_horizontal_rule
end
bounding_box([self.label_width,y_position], :width =>self.item_description_width) do
move_down 73
text "Acknowledged By" , :size => self.item_font_size,:align => :center
end
end
end
def footer(printed_status)
move_down 5
stroke_horizontal_rule
@@ -413,7 +454,7 @@ class ReceiptBillPdf < Prawn::Document
y_position = cursor
bounding_box([0, y_position], :width =>self.label_width, :height => self.item_height) do
text "#{printed_status}", :size => self.item_font_size,:align => :left
text "#{printed_status}",:style => :bold, :size => self.header_font_size,:align => :left
end
bounding_box([self.item_description_width,y_position], :width =>self.item_description_width, :height => self.item_height) do
text "Thank You! See you Again", :left_margin => -10, :size => self.item_font_size,:align => :left
@@ -421,6 +462,5 @@ class ReceiptBillPdf < Prawn::Document
move_down 5
end
end

View File

@@ -0,0 +1,58 @@
class MenuItemImageUploader < CarrierWave::Uploader::Base
# Include RMagick or MiniMagick support:
# include CarrierWave::RMagick
# include CarrierWave::MiniMagick
# Choose what kind of storage to use for this uploader:
storage :file
# storage :fog
def root
Rails.root.join 'public/'
end
# 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"
# "uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
end
# def cache_dir
# '/tmp/images'
# end
# Provide a default URL as a default if there hasn't been a file uploaded:
# def default_url(*args)
# # For Rails 3.1+ asset pipeline compatibility:
# # ActionController::Base.helpers.asset_path("fallback/" + [version_name, "default.png"].compact.join('_'))
#
# "/images/fallback/" + [version_name, "default.png"].compact.join('_')
# end
# Process files as they are uploaded:
# process scale: [200, 300]
#
# def scale(width, height)
# # do something
# end
# Create different versions of your uploaded files:
# version :thumb do
# process resize_to_fit: [50, 50]
# end
# Add a white list of extensions which are allowed to be uploaded.
# For images you might use something like this:
def extension_whitelist
%w(jpg jpeg gif png)
end
# Override the filename of the uploaded files:
# Avoid using model.id or version_name here, see uploader/store.rb for details.
# def filename
# "something.jpg" if original_filename
# end
end

View File

@@ -1,25 +1,7 @@
<div class="col-lg-4 col-md-4 col-sm-4" style="min-height:600px; max-height:600px; overflow-x:scroll">
<%= 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 col-md-6 " %>
<div class="form-group <%= (flash["errors"]) ? "has-error" : "" %>">
<%= f.input :card_no, :class => "form-control col-md-6 card_no"%>
<% flash.each do |name, msg| %>
<% str="[\"#{msg['name']}\"]"
str.gsub!('["', '')
str.gsub!('"]', '') %>
<span class="help-block" style="margin-top:-6px"><%= str %></span>
<% end -%>
</div>
<div class="form-group">
<label>Paypar Account No:</label>
<div class="input-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>
<%= f.hidden_field :id, :class => "form-control col-md-6 " %>
<div class="form-group">
<label>Salutation :</label><br>
@@ -32,11 +14,12 @@
<label>Mdm</label>
<%= f.radio_button :salutation,"Mdm", :class => "salutation mdm", :value=>"Mdm", :style=>"width: 30px"%>
</div>
<div class="form-group <%= (flash["errors"]) ? "has-error" : "" %>">
<%= f.input :name, :class => "form-control col-md-6 name", :required => true %>
<% flash.each do |name, msg| %>
<% str="[\"#{msg['name']}\"]"
<% flash.each do |test, msg| %>
<%
str="[\"#{msg['name']}\"]"
str.gsub!('["', '')
str.gsub!('"]', '') %>
<span class="help-block" style="margin-top:-6px"><%= str %></span>
@@ -73,18 +56,18 @@
str.gsub!('["', '')
str.gsub!('"]', '') %>
<span class="help-block" style="margin-top:-6px"><%= str %></span>
<% end -%>
<% end %>
</div>
<div class="form-group <%= (flash["errors"]) ? "has-error" : "" %>">
<%= f.input :email, :class => "form-control col-md-6 email" ,:required => true%>
<% flash.each do |name, msg| %>
<% str="[\"#{msg['contact_no']}\"]"
<% str="[\"#{msg['email']}\"]"
str.gsub!('["', '')
str.gsub!('"]', '') %>
<span class="help-block" style="margin-top:-6px"><%= str %></span>
<% end -%>
<% end %>
</div>
<div class="form-group">
@@ -99,7 +82,39 @@
<div class="form-group">
<label>Date Of Birth</label>
<%= f.text_field :date_of_birth,:value=>"01-01-1990",:class=>"form-control datepicker"%>
</div>
</div>
<div class="form-group">
<label>Select Customer Type</label>
<select class="selectpicker form-control col-md-12" id="customer_type" name="customer[customer_type]" style="height: 40px" >
<% 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"]) ? "has-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!('"]', '') %>
<span class="help-block" style="margin-top:-6px"><%= str %></span>
<% end %>
</div>
<div class="form-group">
<label>Paypar Account No:</label>
<div class="input-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>Select Member Group</label>
@@ -109,8 +124,7 @@
<option value="<%= member.value %>">
<%= member.name %></option>
<%end %>
</select>
</select>
</div>
<div class="form-group">
@@ -128,16 +142,20 @@
<script type="text/javascript">
$(function() {
// Read Card Reader
$("#paypar_account_no").on('focus', function(e){
var cardNo = "";
$("#sxModal").show();
$("#paypar_account_no").on('focus', function(e){
if($(this).val() == ''){
$("#sxModal").show();
setTimeout(function(){
getCardNo();
$("#sxModal").hide();
},100);
}
});
// $("#customer_card_no").click(function(){
// var ab=$("#customer_tax_profiles").val();
// console.log(JSON.stringify(ab));
// });
});

View File

@@ -0,0 +1,4 @@
json.extract! @crm_customer, :id, :name, :company, :contact_no, :email, :date_of_birth,
:membership_id, :membership_type, :membership_authentication_code,
:salutation, :gender,:nrc_no,:address,:card_no, :paypar_account_no, :customer_type, :tax_profiles
json.url crm_customer_url(@crm_customer, format: :json)

View File

@@ -1,4 +1,4 @@
<div class="row">
<!-- <div class="row">
<div class="col-lg-12">
<ol class="breadcrumb">
<li><a href="<%= crm_root_path %>">Home</a></li>
@@ -7,17 +7,17 @@
</li>
<!-- <a href="<%= new_crm_customer_path%>" class="btn btn-primary pull-right">
<i class="fa fa-plus-circle fa-lg"></i> Add Customer
</a> -->
</a>
</ol>
</div>
</div>
</div> -->
<div class="row">
<div class="col-lg-7 col-md-7 col-sm-7">
<div class="main-box-body clearfix">
<div class="table-responsive">
<table class="table table-striped">
<thead>
<tr>
@@ -25,7 +25,7 @@
<%= form_tag crm_customers_path, :id => "filter_form", :method => :get do %>
<div class="input-append col-md-7 form-group pull-left">
<input type="text" name="filter" style="margin-right:10px" placeholder="Search" id="search" class="form-control input-xs col-md-9">
<button type="submit" class="btn btn-primary btn-md">Search</button>
<button type="submit" class="btn btn-primary btn-md">Search</button>
<!-- <a href="modal-window" data-toggle= "modal" data-target="#modal-window" class="btn btn-primary btn-md" id="card_read" >Read Card</a> -->
<!-- <button type="button" class="btn btn-info btn-md" data-toggle="modal" data-target="#myModal">Open Modal</button> -->
@@ -48,12 +48,12 @@
<tbody>
<% @i = 0 %>
<% @crm_customers.each do |crm_customer| %>
<tr class="customer_tr" data-ref="<%= crm_customer.customer_id %>">
<td>
<input type="radio" style="width:20px;" name="checkbox" class="checkbox_check" ></td>
<td>
<% if crm_customer.customer_id != "CUS-000000000001" && crm_customer.customer_id != "CUS-000000000002" %>
<% if crm_customer.customer_id != "CUS-000000000001" && crm_customer.customer_id != "CUS-000000000002" %>
<%= @i += 1 %>
<% end %>
</td>
@@ -62,21 +62,21 @@
<td><%= crm_customer.contact_no %></td>
<td><%= crm_customer.email %></td>
<td><%= link_to 'Show', crm_customer_path(crm_customer) %></td>
</tr>
<% end %>
</tbody>
</table>
<br>
<%= paginate @crm_customers %>
</div>
</div>
</div>
<%= render 'new_form', crm_customer: @crm_customer %>
<%= render 'new_form', crm_customer: @crm_customer, taxes: @taxes %>
<div class="col-lg-1 col-md-1 col-sm-1">
<br>
@@ -98,9 +98,9 @@ $(function() {
$('.datepicker').css('cursor','pointer');
// Read Card Reader
$("#member_acc_no").on('click', function(e){
var cardNo = "";
$("#sxModal").show();
$("#member_acc_no").on('click', function(e){
var cardNo = "";
$("#sxModal").show();
setTimeout(function(){
getCardNo();
$("#sxModal").hide();
@@ -120,16 +120,26 @@ $(document).on('click',".customer_tr",function(){
// var url = "/"+customer_id;
update_sale(customer_id,sale_id);
}else{
var url = "customers/"+customer_id;
var url = "customers/" + customer_id + "/edit";
}
$.ajax({
type: "GET",
url: url,
$("#customer_tax_profiles").children().removeAttr("selected").css({'color':'#000','background':'none'});;
$.ajax({
type: "GET",
url: url,
data: {},
dataType: "json",
success: function(data) {
success: function(data) {
// Selected for Taxes
var taxes = JSON.stringify(data.tax_profiles);
var parse_taxes = JSON.parse(taxes);
console.log(parse_taxes);
$.each(parse_taxes, function(i, value){
$("#customer_tax_profiles option[value='" + value + "']").attr("selected","selected").css({'color':'#fff','background':'#215d9c'});
});
$('#customer_id').val(data.id);
$('#customer_name').val(data.name);
$('#customer_company').val(data.company);
@@ -138,6 +148,7 @@ $(document).on('click',".customer_tr",function(){
$('#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);
@@ -158,7 +169,7 @@ $(document).on('click',".customer_tr",function(){
}else{
$('.mdm').prop( "checked", true )
}
$('.membership_authentication_code').val(data.membership_authentication_code);
$('#update_customer').removeAttr('disabled').val('');
@@ -177,7 +188,7 @@ $(document).on('click',".customer_tr",function(){
}
});
// }else{
// }
})
@@ -186,44 +197,43 @@ $(document).on('click',".customer_tr",function(){
title: 'Confirm!',
content: 'Are You Sure to assign this customer!',
buttons: {
cancel: function () {
},
confirm: {
text: 'Confirm',
btnClass: 'btn-green',
keys: ['enter', 'shift'],
action: function(){
$.ajax({
type: "POST",
$.ajax({
type: "POST",
url: "update_sale/" ,
data: {customer_id:customer_id,sale_id:sale_id},
dataType: "json",
success: function(data) {
if(data.status == true)
{
{
window.location.href = '/origami'
}else{
alert('Record not found!');
location.reload();
}
}
}
});
}
}
}
});
}
$('#reset').click(function() {
window.location.href = '/crm/customers'
return false;
});
</script>

View File

@@ -1,4 +1,4 @@
json.extract! @crm_customer, :id, :name, :company, :contact_no, :email, :date_of_birth,
:membership_id, :membership_type, :membership_authentication_code,
:salutation, :gender,:nrc_no,:address,:card_no, :paypar_account_no
:salutation, :gender,:nrc_no,:address,:card_no, :paypar_account_no, :customer_type, :tax_profiles
json.url crm_customer_url(@crm_customer, format: :json)

View File

@@ -1,4 +1,4 @@
<div class="page-header">
<!-- <div class="page-header">
<ul class="breadcrumb">
<li><a href="<%= %>">Home</a></li>
<li>Queue</li>
@@ -6,19 +6,19 @@
<%= link_to t('.new', :default => t("helpers.links.new")),new_crm_dining_queue_path,:class => 'btn btn-primary btn-sm' %>
</span>
</ul>
</div>
</div> -->
<div class="row">
<!-- Column One -->
<div class="col-lg-11 col-md-11 col-sm-11">
<div class="tab-content" style="max-height:670px; overflow-y:scroll">
<div class="tab-content" style="max-height:670px; overflow-y:auto">
<!--- Panel 1 - Table Orders -->
<div class="active" role="tabpanel">
<div class="tab-pane" role="tabpanel">
<div class="card-columns" style="padding-top:10px; column-gap: 1.2rem;">
<% @dining_queues.each do |queue| %>
<% if queue.status == "Assign"
@bg_color = "assign"
@@ -27,10 +27,10 @@
else
@bg_color = "normal"
end
%>
%>
<div class="card select-queue <%= @bg_color %>" data-id="<%= queue.id %>" style="width: 21.5rem;">
<div class="card-block">
<p class="hidden queue-id"><%= queue.id %></p>
<p class="hidden queue-id"><%= queue.id %></p>
<p class="hidden queue-status"><%= queue.status %></p>
<span class="card-title"><strong> Queue No : <%= queue.queue_no %></strong></span>
<span class="card-title pull-right"><strong> Seater : <%= queue.seater %></strong></span><br>
@@ -39,7 +39,7 @@
<span class="card-title"> Remark : <%= queue.remark %></span>
</div>
</div>
<% end %>
</div>
</div>
@@ -48,8 +48,10 @@
<!-- tabs - End -->
</div>
<div class="col-lg-1 col-md-1 col-sm-1">
<%= link_to t('.new', :default => t("helpers.links.new")),new_crm_dining_queue_path,:class => 'btn btn-primary btn-lg btn-block' %>
<hr>
<button type="button" id="assign" class="btn btn-primary btn-lg btn-block" disabled>Assign</button>
<button type="button" id="cancel" class="btn btn-warning btn-lg btn-block" disabled>Cancel</button>
<button type="button" id="cancel" class="btn btn-warning btn-lg btn-block" disabled>Cancel</button>
<a href="<%= dashboard_path %>" class="btn btn-primary btn-lg btn-block" role="button" aria-haspopup="true" aria-expanded="false"> Back </a>
</div>
</div>
@@ -71,7 +73,7 @@ $(function(){
$("#cancel").val($(this).find(".queue-id").text());
}); //End Click
});
$('#assign').click(function() {
var id = $(this).val();
@@ -90,31 +92,31 @@ function cancel_queue(id,url) {
title: 'Confirm!',
content: 'Are You Sure to cancel this Queue!',
buttons: {
cancel: function () {
cancel: function () {
},
confirm: {
text: 'Confirm',
btnClass: 'btn-green',
keys: ['enter', 'shift'],
action: function(){
$.ajax({
type: "POST",
$.ajax({
type: "POST",
url: url ,
data: {id:id},
dataType: "json",
success: function(data) {
if(data.status == true)
{
{
location.reload();
}
}
}
});
}
}
}
});
}
</script>
</script>

View File

@@ -1,35 +1,282 @@
<div class="row">
<div class="col-md-4 col-sm-6 col-md-offset-4 col-sm-offset-3">
<div class="row">
<div class="col-md-4 col-sm-6 col-md-offset-4 col-sm-offset-3">
<% if current_login_employee.role = "admin" %>
<% elsif current_login_employee.role = "cashier" %>
<%= link_to "Cashier Station", origami_path %>
<% if current_login_employee.role = "admin" %>
<% elsif current_login_employee = "waiter" %>
<%= link_to "Cashier Station", oishi_path %>
<% elsif current_login_employee.role = "cashier" %>
<%= link_to "Cashier Station", origami_path %>
<% elsif current_login_employee = "account" %>
<%= link_to "Cashier Station", oishi_path %>
<% else %>
<%= link_to "Cashier Station", oishi_path %>
<% end %>
<% shop = Shop.first %>
<% else %>
<%= link_to "Cashier Station", oishi_path %>
<% end %>
<% shop = Shop.first %>
<!-- -->
<div class="card">
<div class="page-header" style="width:100%;text-align:center;background-color:#ddd;">
<h4 style="color : #ef404a;font-weight:bold;font-style:italic;"><%= shop.name %></h4>
</div>
<div class="card-block">
<%= shop.address %>
</div>
<div class="card-block">
<%= shop.phone_no %>
</div>
</div>
</div>
</div>
<div class="col-md-2 container pull-right" style="margin: 0px !important;">
<div class="row">
<div class="col-md-12">
<div class="card" id="oqs" onclick="location.href='<%= oqs_root_path %>'">
<div class="card-content">
<span class="card-title">OQS</span>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class="card" id="origami" onclick="location.href='<%= origami_root_path %>'">
<div class="card-content">
<span class="card-title">Origami</span>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class="card" id="crm" onclick="location.href='<%= crm_root_path %>'">
<div class="card-content">
<span class="card-title">CRM</span>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class="card" id="backend" onclick="location.href='<%= dashboard_path %>'">
<div class="card-content">
<span class="card-title">Backend</span>
</div>
</div>
</div>
</div>
</div>
<div class="col-md-8 col-lg-8">
<div class="" style="max-height:550px; overflow:auto;padding: 15px">
<h4 class="card-title"><strong>Role Features</strong></h4>
<!-- <p><strong>Note:</strong> The <strong>data-parent</strong> attribute makes sure that all collapsible elements under the specified parent will be closed when one of the collapsible item is shown.</p> -->
<div class="panel-group" id="accordion">
<% if current_user.role == 'administrator' %>
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">
<a data-toggle="collapse" data-parent="#accordion" href="#admin">Administrator
<span class="glyphicon glyphicon-plus"></span></a>
</h4>
</div>
<div id="admin" class="panel-collapse collapse in">
<div class="panel-body">
<ul class="col-md-4">
<li class="">All Settings</li>
<ul class="">
<li>Zone</li>
<li>OQS</li>
<li>Menu</li>
<li>Cashier Terminal</li>
<li>Payment</li>
<li>Merbership</li>
<li>Print</li>
<li>Employees</li>
<li>Accounts</li>
</ul>
</ul>
<ul class="col-md-4">
<li class="">Transactions</li>
<ul class="">
<li>Order</li>
<li>Sale</li>
<li>Credit Note</li>
</ul><br>
<li>Reports</li>
<ul class="">
<li>Daily Sale</li>
<li>Sale Item</li>
<li>Receipt</li>
<li>Shift Sale</li>
<li>Credit Sale</li>
<li>Void Sale</li>
</ul>
</ul>
<ul class="col-md-4">
<li>OQS</li><br>
<li>Origami</li><br>
<li>CRM</li>
</ul>
</div>
</div>
</div>
<% elsif current_user.role == 'manager' %>
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">
<a data-toggle="collapse" data-parent="#accordion" href="#manager">Manager
<span class="glyphicon glyphicon-plus"></span></a>
</h4>
</div>
<div id="admin" class="panel-collapse collapse in">
<div class="panel-body">
<ul class="col-md-4">
<li class="">All Settings</li>
<ul class="">
<li>Zone</li>
<li>OQS</li>
<li>Menu</li>
<li>Cashier Terminal</li>
<li>Print</li>
<li>Employees</li>
<li>Accounts</li>
</ul>
</ul>
<ul class="col-md-4">
<li class="">Transactions</li>
<ul class="">
<li>Order</li>
<li>Sale</li>
<li>Credit Note</li>
</ul><br>
<li>Reports</li>
<ul class="">
<li>Daily Sale</li>
<li>Sale Item</li>
<li>Receipt</li>
<li>Shift Sale</li>
<li>Credit Sale</li>
<li>Void Sale</li>
</ul>
</ul>
<ul class="col-md-4">
<li>OQS</li><br>
<li>Origami</li><br>
<li>CRM</li>
</ul>
</div>
</div>
</div>
<% elsif current_user.role == 'supervisour' %>
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">
<a data-toggle="collapse" data-parent="#accordion" href="#supervisor">Supervisor
<span class="glyphicon glyphicon-plus"></span></a>
</h4>
</div>
<div id="supervisor" class="panel-collapse collapse in">
<div class="panel-body">
<ul class="">
<li>OQS</li>
<ul>
<li class="">Void</li>
<li class="">FOC</li>
<li class="">Edit</li>
<li class="">Credit</li>
<li class="">Payment</li>
</ul>
</ul>
</div>
</div>
</div>
<% elsif current_user.role == 'cashier' %>
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">
<a data-toggle="collapse" data-parent="#accordion" href="#cashier">Cashier
<span class="glyphicon glyphicon-plus"></span></a>
</h4>
</div>
<div id="cashier" class="panel-collapse collapse in">
<div class="panel-body">
<ul class="">
<li class="">Orgami Panel except Edit and Void</li>
<li class="">Sale and Order</li>
<li class="">and Queue in CRM</li>
</ul>
</div>
</div>
</div>
<% elsif current_user.role == 'account' %>
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">
<a data-toggle="collapse" data-parent="#accordion" href="#accountant">Accountant
<span class="glyphicon glyphicon-plus"></span></a>
</h4>
</div>
<div id="accountant" class="panel-collapse collapse in">
<div class="panel-body">
<ul class="">
<li class="">Daily Sale Report</li>
<li class="">Sale Item Report</li>
<li class="">Receipt No Report</li>
<li class="">ShiftSale Report</li>
</ul>
</div>
</div>
</div>
<% end %>
</div> <!-- end accordion id -->
</div>
</div> <!-- end col-md-4 -->
<div class="footer">
<div class="card">
<div class="page-header center-text">
<h4 class="footer-header">
<%= shop.name %>
</h4>
</div>
<div class="center-text">
<%= shop.address %>
</div>
<div class="center-text">
<%= shop.phone_no %>
</div>
</div>
</div>
<style type="text/css">
.card {
margin-top: 10px;
box-sizing: border-box;
border-radius: 2px;
background-clip: padding-box;
transition: 0.3s ease;
background-color: white;
box-shadow: 0 2px 5px 0 rgba(0, 0, 0, 0.16), 0 2px 10px 0 rgba(0, 0, 0, 0.12);
}
.card span.card-title {
color: purple;
font-size: 28px;
font-weight: 400;
text-transform: uppercase;
transition: color 0.3s ease;
line-height: 48px;
}
.card .card-content {
padding: 15%;
border-radius: 0 0 2px 2px;
background-clip: padding-box;
box-sizing: border-box;
height: 120px;
transition: color 0.3s ease;
text-align: center;
}
.card .card-content p {
margin: 0;
color: inherit;
}
.card:hover {
box-shadow: 0 10px 20px 0 rgba(0, 0, 0, 0.16), 0 10px 20px 0 rgba(0, 0, 0, 0.12);
}
</style>

View File

@@ -1,86 +1,91 @@
<style>
.pin_pad {
width: 30%;
height:70px;
line-height:70px;
text-align:center;
background:#54A5AF;
font-size:20px;
color:white;
height: 70px;
line-height: 70px;
text-align: center;
background: #54A5AF;
font-size: 20px;
color: white;
}
.bottom{
margin-bottom: 1px;
.bottom {
margin-bottom: 1px;
}
.left{
margin-left:1px;
.left {
margin-left: 1px;
}
.orange{
background-color:#FF7F50;
.orange {
background-color: #FF7F50;
}
.purple {
background-color:#7a62d3;
background-color: #7a62d3;
}
</style>
<div class="row">
<div class="col-md-4 col-sm-6 col-md-offset-4 col-sm-offset-3">
<%= simple_form_for(@login_form, url: emp_login_update_path, method: "PATCH") do |f| %>
<div class="card">
<div class="content" style="margin:10px">
<div class="form-group">
<%= f.input :emp_id,as: :hidden, label: "Access PIN", required: false, class: "form-control" %>
<div class="col-md-4 col-sm-6 col-md-offset-4 col-sm-offset-3">
<%= simple_form_for(@login_form, url: emp_login_update_path, method: "PATCH") do |f| %>
<div class="card">
<div class="content" style="margin:10px">
<div class="form-group">
<%= f.input :emp_id, as: :hidden, label: "Access PIN", required: false, class: "form-control" %>
<%= f.input :password, label: "Access PIN", required: false, class: "form-control" %>
</div>
</div>
<div class="content row" style="padding-left:10px;margin-left:10px; margin-top:0px; text-align:center">
<div class='col-md-12'>
<div class='row bottom'>
<div class="pin_pad " data-value="1">1</div>
<div class="pin_pad left" data-value="2">2</div>
<div class="pin_pad left" data-value="3">3</div>
</div>
<div class='row bottom'>
<div class="pin_pad" data-value="4">4</div>
<div class="pin_pad left" data-value="5">5</div>
<div class="pin_pad left" data-value="6">6</div>
</div>
<div class='row bottom'>
<div class="pin_pad" data-value="7">7</div>
<div class="pin_pad left" data-value="8">8</div>
<div class="pin_pad left" data-value="9">9</div>
</div>
<div class='row bottom'>
<div class="pin_pad orange" data-value="CLR">CLR</div>
<div class="pin_pad left" data-value="0">0</div>
<div class="pin_pad left purple" data-value="ENT">ENT</div>
</div>
<%= f.input :password, label: "Access PIN", required: false, class: "form-control" %>
</div>
</div>
<div class="content row" style="padding-left:10px;margin-left:10px; margin-top:0px; text-align:center">
<div class='col-md-12'>
<div class='row bottom'>
<div class="pin_pad " data-value="1">1</div>
<div class="pin_pad left" data-value="2">2</div>
<div class="pin_pad left" data-value="3">3</div>
</div>
<div class="footer text-center" style="margin:10px">
</div>
<div class='row bottom'>
<div class="pin_pad" data-value="4">4</div>
<div class="pin_pad left" data-value="5">5</div>
<div class="pin_pad left" data-value="6">6</div>
</div>
<div class='row bottom'>
<div class="pin_pad" data-value="7">7</div>
<div class="pin_pad left" data-value="8">8</div>
<div class="pin_pad left" data-value="9">9</div>
</div>
<div class='row bottom'>
<div class="pin_pad orange" data-value="CLR">CLR</div>
<div class="pin_pad left" data-value="0">0</div>
<div class="pin_pad left purple" data-value="ENT">ENT</div>
</div>
</div>
<div class="footer text-center" style="margin:10px">
</div>
<% end %>
</div>
<% end %>
</div>
</div>
</div>
<script type="text/javascript">
$(document).on('turbolinks:load', function() {
$(".pin_pad").click(function(event){
event.preventDefault();
console.log($(this).data("value"));
var value = $(this).data("value");
$(document).on('turbolinks:load', function () {
$(".pin_pad").click(function (event) {
event.preventDefault();
console.log($(this).data("value"));
var value = $(this).data("value");
if (value == "CLR") {
$("#login_form_password").val("");
} else if(value == "ENT") {
$("#new_login_form").submit();
} else {
var old_value = $("#login_form_password").val();
$("#login_form_password").val(old_value + value);
}
});
});
if (value == "CLR") {
$("#login_form_password").val("");
} else if (value == "ENT") {
$("#new_login_form").submit();
} else {
var old_value = $("#login_form_password").val();
$("#login_form_password").val(old_value + value);
}
});
});
</script>

View File

@@ -2,28 +2,33 @@
<button class="navbar-toggler navbar-toggler-right" type="button" data-toggle="collapse" data-target="#navbarCollapse" aria-controls="navbarCollapse" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<a class="navbar-brand" href="#" style="color: rgba(67, 185, 220, 0.9)">E-menu</a>
<a class="navbar-brand" href="<%= root_path %>" style="color: rgba(67, 185, 220, 0.9)">E-menu</a>
<div class="collapse navbar-collapse" id="navbarCollapse">
<ul class="navbar-nav mr-auto">
<li class="navbar-nav mr-auto dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Settings</a>
<ul class="dropdown-menu">
<li><%= link_to "Zones (Zone,Table,Rooms)", settings_zones_path, :tabindex =>"-1" %></li>
<hr class="hr_advance" />
<li><%= link_to "Order Queue Stations",settings_order_queue_stations_path, :tabindex =>"-1" %></li>
<hr class="hr_advance" />
<li><%= link_to "Menus ", settings_menus_path, :tabindex =>"-1" %></li>
<li><%= link_to "Item Sets ", settings_item_sets_path, :tabindex =>"-1" %></li>
<li><%= link_to "Menu Item Sets ", settings_menu_item_sets_path, :tabindex =>"-1" %></li>
<li><%= link_to "Menu Categories", settings_menu_categories_path, :tabindex =>"-1" %></li>
<li><%= link_to "Menu Item Attributes", settings_menu_item_attributes_path, :tabindex =>"-1" %></li>
<li><%= link_to "Menu Item Options",settings_menu_item_options_path, :tabindex =>"-1" %></li>
<hr>
<li><%= link_to "Order Queue Stations",settings_order_queue_stations_path, :tabindex =>"-1" %></li>
<li><%= link_to "Zones", settings_zones_path, :tabindex =>"-1" %></li>
<hr>
<li><%= link_to "Cashier Terminals ", settings_cashier_terminals_path, :tabindex =>"-1" %></li>
<li><%= link_to "Employees", settings_employees_path, :tabindex =>"-1" %></li>
<hr class="hr_advance" />
<li><%= link_to "Cashier Terminals", settings_cashier_terminals_path, :tabindex =>"-1" %></li>
<li><%= link_to "Tax Profile", settings_tax_profiles_path, :tabindex =>"-1" %></li>
<hr class="hr_advance" />
<li><%= link_to "Membership Setting",settings_membership_settings_path, :tabindex =>"-1" %></li>
<li><%= link_to "Membership Action",settings_membership_actions_path, :tabindex =>"-1" %></li>
<li><%= link_to "Payment Method", settings_payment_method_settings_path, :tabindex =>"-1" %></li>
<li><%= link_to "Tax Profile", settings_tax_profiles_path, :tabindex =>"-1" %></li>
<li><%= link_to "Payment Methods", settings_payment_method_settings_path, :tabindex =>"-1" %></li>
<li><%= link_to "Print Setting", print_settings_path, :tabindex =>"-1" %></li>
<hr>
<hr class="hr_advance" />
<li><%= link_to "Employees", settings_employees_path, :tabindex =>"-1" %></li>
<hr class="hr_advance" />
<li><%= link_to "Accounts", settings_accounts_path, :tabindex =>"-1" %></li>
</ul>
</li>
@@ -33,7 +38,7 @@
<ul class="dropdown-menu">
<li><%= link_to "Orders ", transactions_orders_path, :tabindex =>"-1" %></li>
<li><%= link_to "Sales ", transactions_sales_path, :tabindex =>"-1" %></li>
<li><%= link_to "Credit Note ", transactions_credit_notes_path, :tabindex =>"-1" %></li>
<li><%= link_to "Credit Note ", transactions_credit_notes_path, :tabindex =>"-1" %></li>
</ul>
</li>
<li class="navbar-nav mr-auto dropdown">
@@ -42,14 +47,22 @@
<li><%= link_to "Daily Sale Report", reports_dailysale_index_path, :tabindex =>"-1" %></li>
<li><%= link_to "Sales Item Report", reports_saleitem_index_path, :tabindex =>"-1" %></li>
<li><%= link_to "Receipt Report", reports_receipt_no_index_path, :tabindex =>"-1" %></li>
<li><%= link_to "Shift Sale Report", reports_shiftsale_index_path, :tabindex =>"-1" %></li>
<li><%= link_to "Shift Sale Report", reports_shiftsale_index_path, :tabindex =>"-1" %></li>
<li><%= link_to "Credit Sale Report", reports_credit_payment_index_path, :tabindex =>"-1" %></li>
<li><%= link_to "Void Sale Report", reports_void_sale_index_path, :tabindex =>"-1" %></li>
</ul>
</li>
<li class="navbar-nav mr-auto">
<a href="<%= crm_customers_path %>" role="button" aria-haspopup="true" aria-expanded="false">&nbsp;&nbsp;&nbsp;CRM</a></li>
<a href="<%= oqs_root_path %>" role="button" aria-haspopup="true" aria-expanded="false">&nbsp;&nbsp;&nbsp;OQS</a>
</li>
<li class="navbar-nav mr-auto">
<a href="<%= origami_root_path %>" role="button" aria-haspopup="true" aria-expanded="false">&nbsp;&nbsp;&nbsp;Origami</a>
</li>
<li class="navbar-nav mr-auto">
<a href="<%= crm_customers_path %>" role="button" aria-haspopup="true" aria-expanded="false">&nbsp;&nbsp;&nbsp;CRM</a>
</li>
<li class="navbar-nav mr-auto">
<a href="<%= oqs_root_path %>" role="button" aria-haspopup="true" aria-expanded="false">&nbsp;&nbsp;&nbsp;OQS</a></li>
</ul>
</div>
@@ -58,7 +71,7 @@
<ul class="navbar-nav mr-auto">
<%if current_login_employee.role !="waiter" %>
<li style="color: #959595"><%= current_login_employee.name %> </li>
<li style="padding-right:10px;padding-left:10px"> | </li>
<li ><%= link_to 'Logout', logout_path, method: :delete, data: { confirm: 'Are you sure?' } %>
</li>
@@ -68,3 +81,9 @@
<% end %>
</nav>
<style type="text/css">
hr.hr_advance {
margin-top: 10px !important;
margin-bottom: 10px !important;
}
</style>

View File

@@ -11,7 +11,10 @@
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
<%= stylesheet_link_tag 'settings', media: 'all', 'data-turbolinks-track': 'reload' %>
<%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>
<%= stylesheet_link_tag 'fileinput.min', media: 'all', 'data-turbolinks-track': 'reload' %>
<%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>
<%= javascript_include_tag 'fileinput.min', 'data-turbolinks-track': 'reload' %>
</head>
<body>
@@ -32,8 +35,7 @@
<%= message %>
</div>
<% end %>
<%= yield %>
<%= yield %>
</div>
</body>
</html>

View File

@@ -0,0 +1,197 @@
<div class="row">
<!-- Column One -->
<div class="col-lg-8 col-md-8 col-sm-8">
<!-- Nav tabs -->
<ul class="nav nav-tabs" role="tablist">
<li class="nav-item">
<a class="nav-link active" data-toggle="tab" href="#completed" role="tab">Processed <span class="badge badge-pill badge-default" id="completed_count"><%= @queue_completed_item.length %></span></a>
</li>
<% # For Tab Disable for Station is inactive
status=""
@queue_stations_items.each do |qsi|
if qsi[:is_active] == false
status="disabled"
end
%>
<li class="nav-item">
<a class="nav-link" data-toggle="tab" href=<%= '#' + qsi[:station_name].gsub(' ', '_') %> role="tab" <%= status %>>
<%= qsi[:station_name] %>
<span class="badge badge-pill badge-default" id=<%= qsi[:station_name].gsub(' ', '_') + '_count' %>>
<%= qsi[:item_count] %>
</span>
<% if qsi[:is_ap] %>
<span>(ap)</span>
<% end %>
</a>
</li>
<% end %>
</ul>
<!-- Nav tabs - End -->
<div class="tab-content" style="max-height:670px; overflow:auto">
<!--- Panel 0 - Completed -->
<div class="tab-pane active" id="completed" role="tabpanel">
<div class="card-columns" style="padding-top:10px; column-gap: 1.2rem;">
<%
@queue_completed_item.each do |qid|
%>
<div class="card queue_station">
<div class="card-block">
<h4 class="card-title">
<span class="order-zone-type"><%= qid.type %> - </span>
<span class="order-zone"><%= qid.zone %></span>
<small class="pull-right"><%= qid.order_id %></small>
</h4>
<h4>
<span class="order-item">
<%= qid.item_name %>
</span> [x
<span class="order-qty">
<%= qid.qty %>
</span> ]
</h4>
<p class="card-text item-options"><%= qid.options == "[]"? "" : qid.options %></p>
<p class="card-text">
<small class="text-muted">Order at
<span class="order-at">
<%= qid.created_at.utc.getlocal.strftime("%d-%m-%Y %I:%M %p") %>
</span> -
<span class="order-by">
<%= qid.item_order_by %>
</span>
</small>
</p>
<p class="hidden order-status">completed</p>
<p class="hidden order-customer"><%= qid.customer_name %></p>
<p class="hidden assigned-order-item"><%= qid.assigned_order_item_id %></p>
</div>
</div>
<%
end
%>
</div>
</div>
<!-- End Panel 0 - Completed -->
<!-- Order Item for Queue Station -->
<%
@queue_stations_items.each do |qsi|
%>
<!-- Generated Pane -->
<div class="tab-pane" id=<%= qsi[:station_name].gsub(' ', '_') %> role="tabpanel">
<!--- Order Items -->
<div class="card-columns" style="padding-top:10px; column-gap: 1.2rem;">
<%
@queue_items_details.each do |qid|
if qid.price != 0
if qid.zone_id == qsi[:zone_id] && qid.station_name == qsi[:station_name]
%>
<div class="card queue_station">
<div class="card-block">
<h4 class="card-title">
<span class="order-zone-type"><%= qid.type %> - </span>
<span class="order-zone"><%= qid.zone %></span>
<small class="pull-right"><%= qid.order_id %></small>
</h4>
<h4>
<span class="order-item"><%= qid.item_name %></span> [x
<span class="order-qty"><%= qid.qty %></span> ]
</h4>
<p class="card-text item-options"><%= qid.options == "[]"? "" : qid.options %></p>
<p class="card-text">
<small class="text-muted">Order at
<span class="order-at">
<%= qid.created_at.utc.getlocal.strftime("%d-%m-%Y %I:%M %p") %>
</span> -
<span class="order-by">
<%= qid.item_order_by %>
</span>
</small>
</p>
<!-- Hidden Fields for Items -->
<p class="hidden order-customer"><%= qid.customer_name %></p>
<p class="hidden assigned-order-item"><%= qid.assigned_order_item_id %></p>
</div>
<div class="card-footer">
<button id=<%= 'edit_' + qid.assigned_order_item_id.to_s %> class="btn btn-warning order-item order-item-edit">EDIT</button>
<button id=<%= 'assigned_queue_' + qid.assigned_order_item_id.to_s %> class="btn btn-primary order-item order-complete">COMPLETE</button>
</div>
</div>
<%
end
end
end
%>
<!--- end of Items-->
</div>
</div>
<!-- end of Pane -->
<% end %>
<!-- End Order Item for Queue Station -->
</div>
</div>
<!-- Column Two -->
<div class="col-lg-3 col-md-3 col-sm-3">
<div class="card" >
<div class="card-header">
<div><strong id="order-title">ORDER DETAILS - Table</strong></div>
</div>
<div class="card-block">
<div class="card-title">
<table class="table">
<thead>
<tr>
<th style="width:33%; text-align:left">Order By</th>
<th style="width:33%; text-align:right">Order At</td>
<th style="width:33%; text-align:right">Customer</td>
</tr>
</thead>
<tbody>
<tr>
<td id="order-by" style="width:33%; text-align:left"></td>
<td id="order-at" style="width:33%; text-align:right"></td>
<td id="order-customer" style="width:33%; text-align:right"></td>
</tr>
<tr>
<td><strong>Table/Room</strong></td>
<td id="order-from" colspan="2"></td>
</tr>
</tbody>
</table>
</div>
<div class="card-text" style="min-height:360px; max-height:360px; overflow:auto">
<table class="table" id="oqs-order-details-table">
<thead>
<tr>
<th style="width:80%; text-align:left">Items</th>
<th style="width:20%; text-align:right">QTY</th>
</tr>
</thead>
<tbody>
<!-- Bind With JS -->
</tbody>
</table>
</div>
</div>
</div>
</div>
<!-- Column Three--->
<div class="col-lg-1 col-md-1 col-sm-1">
<!-- OQS Buttons -->
<button type="button" title="Print Order Item" id="print_order_item" class="btn btn-primary btn-lg btn-block">Print</a>
<button type="button" class="btn btn-primary btn-lg btn-block" id="print_order_summary">Print <br/>Order<br/>Summary</button>
<a href="<%= dashboard_path %>" class="btn btn-primary btn-lg btn-block" role="button" aria-haspopup="true"> Back </a>
<!-- <button type="button" class="" id="print_order_summary">Print <br/>Order<br/>Summary</button> -->
</div>
</div>

View File

@@ -1,39 +1,66 @@
<br>
<div class="row">
<!-- Column One -->
<div class="col-lg-8 col-md-8 col-sm-8">
<div class="col-md-6">
<%= form_tag oqs_root_path, :method => :get do %>
<div class="form-group col-md-8">
<input type="text" name="filter" class="form-control input-md" placeholder="">
</div>
<div class="form-group col-md-1">
<input type="submit" value="Search" class='btn btn-primary btn-md'>
</div>
<% end %>
</div>
</div>
<hr>
<!-- Column One -->
<div class="row">
<div class="col-lg-8 col-md-8 col-sm-8">
<!-- Nav tabs -->
<ul class="nav nav-tabs" role="tablist">
<li class="nav-item">
<a class="nav-link active" data-toggle="tab" href="#completed" role="tab">Processed <span class="badge badge-pill badge-default" id="completed_count"><%= @queue_completed_item.length %></span></a>
<!-- <li class="nav-item nav-search <%= @filter.to_s.length > 0? " " : "hide"%>">
<a class="nav-link <%= @filter.to_s.length > 0? "active" : " "%>" data-toggle="tab" href="#search" role="tab">Searching .. <span class="badge badge-pill badge-default" id="completed_count"><%= @queue_completed_item.length %></span></a>
</li> -->
<li class="nav-item nav-completed">
<a class="nav-link" data-toggle="tab" href="#completed" role="tab">Processed <span class="badge badge-pill badge-default" id="completed_count"><%= @queue_completed_item.length %></span></a>
</li>
<%
# For Tab Disable for Station is inactive
<% # For Tab Disable for Station is inactive
status=""
@queue_stations_items.each do |qsi|
if qsi[:is_active] == false
@queue_stations.each do |qsi|
if qsi.is_active == false
status="disabled"
end
%>
<li class="nav-item">
<a class="nav-link" data-toggle="tab" href=<%= '#' + qsi[:station_name].gsub(' ', '_') %> role="tab" <%= status %>>
<%= qsi[:station_name] %>
<span class="badge badge-pill badge-default" id=<%= qsi[:station_name].gsub(' ', '_') + '_count' %>>
<%= qsi[:item_count] %>
end %>
<li class="nav-item oqs_click" >
<p class="hidden oqs-id"><%= qsi.id %></p>
<a class="nav-link" data-toggle="tab" href="" role="tab" <%= status %>>
<%= qsi.station_name %>
<% if @filter.nil? %>
<span class="badge badge-pill badge-default" id=""> <%= qsi.assigned_order_items.where("delivery_status=0").count %>
</span>
<% if qsi[:is_ap] %>
<span>(ap)</span>
<% end %>
</a>
<%else%>
<span class="badge badge-pill badge-default" id="">
<% @count.each do |c|%>
<% if qsi.id == c.station_id %>
<%= c.total %>
<%end %>
<%end %>
</span>
<%end%>
<% if qsi.auto_print %>
<span>(ap)</span>
<% end %>
</a>
</li>
<% end %>
</ul>
<!-- Nav tabs - End -->
<p class="hidden filter"><%= @filter %></p>
<div class="tab-content" style="max-height:670px; overflow:auto">
<!--- Panel 0 - Completed -->
<div class="tab-pane active" id="completed" role="tabpanel">
<div class="card-columns" style="padding-top:10px; column-gap: 1.2rem;">
<%
@@ -77,66 +104,14 @@
%>
</div>
</div>
<!-- End Panel 0 - Completed -->
<!-- Order Item for Queue Station -->
<%
@queue_stations_items.each do |qsi|
%>
<!-- Generated Pane -->
<div class="tab-pane" id=<%= qsi[:station_name].gsub(' ', '_') %> role="tabpanel">
<!--- Order Items -->
<div class="card-columns" style="padding-top:10px; column-gap: 1.2rem;">
<%
@queue_items_details.each do |qid|
if qid.price != 0
if qid.zone_id == qsi[:zone_id] && qid.station_name == qsi[:station_name]
%>
<div class="card queue_station">
<div class="card-block">
<h4 class="card-title">
<span class="order-zone-type"><%= qid.type %> - </span>
<span class="order-zone"><%= qid.zone %></span>
<small class="pull-right"><%= qid.order_id %></small>
</h4>
<h4>
<span class="order-item"><%= qid.item_name %></span> [x
<span class="order-qty"><%= qid.qty %></span> ]
</h4>
<p class="card-text item-options"><%= qid.options == "[]"? "" : qid.options %></p>
<p class="card-text">
<small class="text-muted">Order at
<span class="order-at">
<%= qid.created_at.utc.getlocal.strftime("%d-%m-%Y %I:%M %p") %>
</span> -
<span class="order-by">
<%= qid.item_order_by %>
</span>
</small>
</p>
<!-- Hidden Fields for Items -->
<p class="hidden order-customer"><%= qid.customer_name %></p>
<p class="hidden assigned-order-item"><%= qid.assigned_order_item_id %></p>
</div>
<div class="card-footer">
<button id=<%= 'edit_' + qid.assigned_order_item_id.to_s %> class="btn btn-warning order-item order-item-edit">EDIT</button>
<button id=<%= 'assigned_queue_' + qid.assigned_order_item_id.to_s %> class="btn btn-primary order-item order-complete">COMPLETE</button>
</div>
</div>
<%
end
end
end
%>
<!--- end of Items-->
</div>
</div>
<!-- end of Pane -->
<% end %>
<!-- End Order Item for Queue Station -->
<!--- Order Items -->
<div class="card-columns oqs_append" style="padding-top:10px; column-gap: 1.2rem;">
</div>
<!--- end of Items-->
</div>
</div>
@@ -192,9 +167,11 @@
<!-- OQS Buttons -->
<button type="button" title="Print Order Item" id="print_order_item" class="btn btn-primary btn-lg btn-block">Print</a>
<button type="button" class="btn btn-primary btn-lg btn-block" id="print_order_summary">Print <br/>Order<br/>Summary</button>
<a href="<%= dashboard_path %>" class="btn btn-primary btn-lg btn-block" role="button" aria-haspopup="true" aria-expanded="false"> Back </a>
<a href="<%= dashboard_path %>" class="btn btn-primary btn-lg btn-block" role="button" aria-haspopup="true"> Back </a>
<!-- <button type="button" class="" id="print_order_summary">Print <br/>Order<br/>Summary</button> -->
</div>
</div>
<script type="text/javascript">
</script>

View File

@@ -1,117 +1,177 @@
<div class="row">
<div class="col-lg-3 col-md-3 col-sm-3">
<div class="ta" style="max-height:550px; overflow:auto">
<ul class="nav nav-tabs flex-column" role="tablist" >
<% @menu.each do |menu| %>
<li class="nav-item menu_category" data-ref="<%= api_restaurant_menu_category_path menu.id%>">
<p class="hidden menu-id"><%= menu.id %></p>
<a class="nav-link" data-toggle="tab" href="" role="tab"> <%= menu.name%></a>
</li>
<% end %>
<div class="col-lg-2 col-md-2 col-sm-2">
<ul class="nav nav-tabs flex-column" role="tablist" >
<% @menu.each do |menu| %>
<li class="nav-item menu_category" data-ref="<%= api_restaurant_menu_category_path menu.id%>">
<p class="hidden menu-id"><%= menu.id %></p>
<a class="nav-link" data-toggle="tab" href="" role="tab"> <%= menu.name%></a>
</li>
<% end %>
</ul>
</div>
</div>
<div class="col-md-6 col-lg-6">
<div class="card-columns menu_items_list" style="column-gap: 10px;">
<!-- append data -->
</div>
</div>
<div class="col-md-3 col-lg-3 col-sm-3">
<div class="card-header">
<div><strong id="order-title">ORDER DETAILS </strong> | Table <%=@table_id%></div>
<div class="col-md-7 col-lg-7 col-sm-7">
<div class="card-columns menu_items_list" style="column-gap: 10px;">
<!-- append data -->
</div>
</div>
<div class="card-block">
<div class="card-text" style="min-height:500px; max-height:500px; overflow:auto">
<table class="table table-striped" id="order-items-table">
<thead>
<tr>
<th>#</th>
<th class="item-name">Items</th>
<th class="item-attr">Price</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td class='item-name'>aaaaa x2</td>
<td class='item-attr'>name</td>
</tr>
<div class="col-md-3 col-lg-3 col-sm-3">
<div class="card-header">
<div>
<strong id="order-title">ORDER DETAILS </strong> | Table <%=@table_id%>
</div>
</div>
<div class="card-block">
<div class="card-text" style="min-height:500px; max-height:500px; overflow:auto">
<table class="table table-striped summary-items">
<thead>
<tr>
<th>#</th>
<th class="item-name">Items</th>
<th class="item-qty">QTY</th>
<th class="item-attr">Price</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
<div class="card-footer">
<table class="table" id="order-charges-table" border="0">
<tr>
<td class="charges-name"><strong>Sub Total:</strong></td>
<td class="item-attr"><strong id="order-sub-total">22222</strong></td>
</tr>
</table>
</div>
</div>
</div>
</tbody>
</table>
</div>
<div class="card-footer">
<table class="table" id="order-charges-table" border="0">
<tr>
<td class="charges-name"><strong>Sub Total:</strong></td>
<td class="item-attr"><strong id="order-sub-total">22222</strong></td>
</tr>
</table>
</div>
</div>
</div>
<script type="text/javascript">
$(function(){
$(".menu_category").on("click", function(){
var menu_id = $(this).find(".menu-id").text();
var url = $(this).attr('data-ref');
show_details(url);
}); //End Booking Click
$(".menu_category").on("click", function(){
var menu_id = $(this).find(".menu-id").text();
var url = $(this).attr('data-ref');
show_menu_item_list(url);
}); //End menu category Click
function show_details(url_item){
var menu_list = $('.menu_items_list');
// menu_list.empty();
// var row = '';
//Start Ajax
$.ajax({
type: "GET",
url: url_item,
data: {},
dataType: "json",
success: function(data) {
function show_menu_item_list(url_item){
menu_items = data.menu_items;
var menu_list = $('.menu_items_list');
menu_list.empty();
for(var field in menu_items) {
if (menu_items[field].item_instances){
console.log(menu_items[field].item_instances[0]);
var price = parseFloat(menu_items[field].item_instances[0].price).toFixed(2);
}else{
var price = parseFloat(menu_items[field].price).toFixed(2);
//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;
for(var field in menu_items) {
if (menu_items[field].item_instances){
var price = parseFloat(menu_items[field].item_instances[1].price).toFixed(2);
var is_available = menu_items[field].item_instances[1].is_available
var is_on_promotion = menu_items[field].item_instances[1].is_on_promotion
var item_attributes = menu_items[field].item_instances[1].item_attributes
var item_instance_code = menu_items[field].item_instances[1].item_instance_item_code
var item_instance_name = menu_items[field].item_instances[1].item_instance_name
var promotion_price = menu_items[field].item_instances[1].promotion_price
}else{
var price = parseFloat(menu_items[field].price).toFixed(2);
var is_available = menu_items[field].is_available
var is_on_promotion = menu_items[field].is_on_promotion
var item_attributes = menu_items[field].item_attributes
var item_instance_code = menu_items[field].item_instance_item_code
var item_instance_name = menu_items[field].item_instance_name
var promotion_price = menu_items[field].promotion_price
}
row = '<div class="card">'
+'<div class="card-head" style="line-height:14px;">'
+'<small class="col-md-9">'+ menu_items[field].name +'</small>'
+'<div class="col-md-3 add_icon"'
+'data-id="'+ menu_items[field].name +'"'
+'data-item-code="'+ menu_items[field].item_code +'"'
+'data-name="'+ menu_items[field].name +'"'
+'data-price="'+ price +'"'
+'data-available="'+ is_available +'"'
+'data-promotion="'+ is_on_promotion +'"'
+'data-attributes="'+ item_attributes +'"'
+'data-instance-code="'+ item_instance_code +'"'
+'data-instance="'+ item_instance_name +'"'
+'data-promotion-price="'+ promotion_price +'"'
+'>'
+'<i class="fa fa-plus "'
+ 'style="margin-top:4px;">'
+'</i></div>'
+'</div>'
+'<div class="card-block">'
+'<%= image_tag "logo.png" ,width: '75', height: '75', :style => '' %>'
+'</div>'
+'<div class="card-footer">'
+'<small>'+ price +'</small>'
+'</div>';
$('.menu_items_list').append(row);
}
row = '<div class="card">'
+'<div class="card-head" style="line-height:14px;">'
+'<small>'+ menu_items[field].name +'</small>'
+'</div>'
}
});
//end Ajax
}
//end show detail function
+'<div class="card-block">'
+'<%= image_tag "logo.png" ,width: '75', height: '75', :style => '' %>'
+'</div>'
$(document).on('click', '.add_icon', function(event){
var item_data = $(this);
show_item_detail(item_data);
}); //End Add Icon Click
function show_item_detail(data){
price = data.attr('data-price');
if (data.attr('data-qty') === undefined){
qty = 1;
}else{
qty = data.attr('data-qty');
}
if (data.attr('data-instance') == "undefined"){
instance = '';
}else{
instance = data.attr('data-instance');
}
var rowCount = $('.summary-items tbody');
console.log(rowCount);
for(var field in rowCount) {
// console.log(rowCount[field].attr('data-code'));
}
row ='<tr>'
+'<td class="item-cell-no">'+rowCount+'</td>'
+'<td class="item-cell-name" data-code='+data.attr('data-item-code')+'>' + data.attr('data-name')+ ' ' + instance + '</td>'
+'<td class="item-cell-qty" id="item_qty">' + qty + '</td>'
+'<td class="item-cell-price" id="item_price">'
+ parseFloat(price).toFixed(2)
+'</td>'
+'</tr>';
$(".summary-items tbody").append(row);
}
+'<div class="card-footer">'
+'<small>'+ price +'</small>'
+'</div>';
$('.menu_items_list').append(row);
}
}
});
//end Ajax
}
});
</script>
@@ -156,6 +216,25 @@ function show_details(url_item){
column-count: 4;
}
}
.nav-tabs .nav-item {
border-bottom: 1px solid #fff;
border-left: 1px solid #54A5AF;
border-right: 1px solid #54A5AF;
}
.nav > li > a{
color:#54A5AF;
}
.nav-tabs {
background-color: #eeeeee;
}
.nav-tabs .nav-link.active, .nav-tabs .nav-item.show .nav-link {
background-color: #fff;
border-left: 6px solid #111;
color:#54A5AF;
font-weight: bold;
border-color: #fff #fff #fff #54A5AF;
}
</style>

View File

@@ -1,7 +1,7 @@
<div class='row'>
<div class="col-lg-11 col-md-11 col-sm-11">
<h2> Payment Credit </h2>
<h2> Cash In </h2>
<br>
<table class='table table-striped'>
<tr>

View File

@@ -2,7 +2,7 @@
<div class='row'>
<div class="col-lg-11 col-md-11 col-sm-11">
<h2>Payment Debit</h2>
<h2>Cash Out</h2>
<table class='table table-striped'>
<tr>
<td> Payment Reference

View File

@@ -81,23 +81,7 @@
<input type="hidden" id="table_id" name="table_id" value="<%= @dining_facility.id %>" />
<input type="hidden" id="type" name="type" value="<%= @dining_facility.type %>" />
<%= f.error_notification %>
<%= f.hidden_field :id, :class => "form-control col-md-6 " %>
<div class="form-group <%= (flash["errors"]) ? "has-error" : "" %>">
<%= f.input :card_no, :class => "form-control col-md-6 card_no"%>
<% flash.each do |name, msg| %>
<% str="[\"#{msg['name']}\"]"
str.gsub!('["', '')
str.gsub!('"]', '') %>
<span class="help-block" style="margin-top:-10px"><%= str %></span>
<% end -%>
</div>
<div class="form-group">
<label>Paypar Account No:</label>
<div class="input-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>
<%= f.hidden_field :id, :class => "form-control col-md-6 " %>
<div class="form-group">
<label>Salutation :</label><br>
<label>Mr</label>
@@ -176,6 +160,37 @@
<%= f.text_field :date_of_birth,:value=>"01-01-1990",:class=>"form-control datepicker"%>
</div>
<div class="form-group">
<label>Select Customer Type</label>
<select class="selectpicker form-control col-md-12" id="customer_type" name="customer[customer_type]" style="height: 40px" >
<% 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"]) ? "has-error" : "" %>">
<%= f.input :card_no, :class => "form-control col-md-6 card_no"%>
<% flash.each do |name, msg| %>
<% str="[\"#{msg['name']}\"]"
str.gsub!('["', '')
str.gsub!('"]', '') %>
<span class="help-block" style="margin-top:-10px"><%= str %></span>
<% end -%>
</div>
<div class="form-group">
<label>Paypar Account No:</label>
<div class="input-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>Select Member Group</label>
<select class="selectpicker form-control col-md-12" name="member_group_id">
@@ -216,17 +231,21 @@
$('.datepicker').css('cursor','pointer');
// Read Card Reader
$("#paypar_account_no").on('focus', function(e){
$("#sxModal").show();
setTimeout(function(){
getCardNo();
$("#sxModal").hide();
},100);
$("#paypar_account_no").on('focus', function(e){
if($(this).val() == ''){
$("#sxModal").show();
setTimeout(function(){
getCardNo();
$("#sxModal").hide();
},100);
}
});
// Read Card Reader
$("#member_acc_no").on('click', function(e){
var cardNo = "";
var customer_id = '';
var customer_name = '';
var sale_id = $("#sale_id").val() || 0;
var customer_mamber_card_no = 0;
$("#sxModal").show();
@@ -235,8 +254,18 @@
$("#sxModal").hide();
customer_mamber_card_no = $("#search").val();
if(sale_id != 0 && customer_mamber_card_no != 0){
update_sale(customer_mamber_card_no,sale_id);
if(sale_id != 0 && customer_mamber_card_no != 0){
$.ajax({
type: "POST",
url: "get_customer" ,
data: { filter : customer_mamber_card_no },
dataType: "json",
success: function(data) {
customer_id = data[0].customer_id;
customer_name = data[0].name;
update_sale(customer_id, customer_name,sale_id);
}
});
}
},100);
});
@@ -261,10 +290,11 @@
$(this).closest('tr').find('.checkbox_check').prop( "checked", true );
var sale_id = $("#sale_id").val() || 0;
var customer_id = $(this).attr('data-ref');
var customer_name = $(this).children("td:nth-child(3)").text();
if(sale_id != 0){
// var url = "/"+customer_id;
update_sale(customer_id,sale_id);
update_sale(customer_id, customer_name,sale_id);
}else{
var url = "customers/"+customer_id;
@@ -277,6 +307,12 @@
data: {},
dataType: "json",
success: function(data) {
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");
});
$('#customer_id').val(data.id);
$('#customer_name').val(data.name);
$('#customer_company').val(data.company);
@@ -286,7 +322,8 @@
$('#customer_membership_type').val(data.membership_type);
$('.select > option[value="'+data.membership_id+'"]').attr('selected','selected');
$('.membership_authentication_code').val(data.membership_authentication_code);
$('#customer_card_no').val(data.card_no);
$('#customer_type').val(data.customer_type);
$('#customer_salutation').val(data.salutation);
$('#customer_nrc_no').val(data.nrc_no);
$('#paypar_account_no').val(data.paypar_account_no);
@@ -325,10 +362,15 @@
// }
})
function update_sale(customer_id,sale_id) {
function update_sale(customer_id, customer_name, sale_id) {
var customer="";
if(customer_name != ""){
customer = '(' + customer_name + ')';
}
$.confirm({
title: 'Confirm!',
content: 'Are You Sure to assign this customer!',
content: 'Are You Sure to assign this customer' + customer + '!',
buttons: {
cancel: function () {

View File

@@ -108,8 +108,17 @@
<button id="cash_in" type="button" class="btn btn-block btn-primary"> Cash In </button>
<button id="cash_out" type="button" class="btn btn-block btn-primary"> Cash Out </button>
<!-- Temporary Disabled -->
<!-- <button id="sale_summary" type="button" class="btn btn-block btn-primary">Sale Sammary</button> -->
<%if current_login_employee.role == "cashier" && @shop.quick_sale_summary == true%>
<button id="sale_summary" type="button" class="btn btn-block btn-primary">Sale Summary</button>
<%end%>
<button id="close_cashier" type="button" class="btn btn-block btn-primary"> Close Cashier </button>
<%if current_login_employee.role == "administrator" || current_login_employee.role == "manager" %>
<button id="back" type="button" class="btn btn-block btn-primary"><i class="fa fa-home fa-lg"></i> Back
</button>
<%end%>
</div>
</div>
<!-- Column One -->
@@ -218,4 +227,7 @@ $('#cash_out').on('click',function(){
$('#close_cashier').on('click',function(){
window.location.href = '/origami/shift/close';
})
$('#back').on('click',function(){
window.location.href = '/dashboard';
})
</script>

View File

@@ -20,7 +20,6 @@
</li>
</ul>
<!-- Nav tabs - End -->
<div class="tab-content">
<!--- Panel 0 - Completed Orders -->
@@ -133,6 +132,7 @@
<% if @status_sale == 'sale' %>
<%= @sale_array[0].receipt_no rescue '' %>
<% end %>
</span></p>
</div>
@@ -144,7 +144,10 @@
<div class="card-title row">
<div class="col-lg-6 col-md-6 col-sm-6">
<%if @customer %>
<% if @status_sale == 'sale' %>
<p class="hidden customer-id"><%= @sale_array[0].customer_id rescue '' %></p>
<p>Customer : <%= @sale_array[0].customer.name rescue '' %></p>
<%else%>
<p class="hidden customer-id"><%= @customer.customer_id rescue "" %></p>
<p>Customer : <%= @customer.name rescue "" %></p>
<%end%>
@@ -305,9 +308,7 @@
<button type="button" id="add_order" class="btn btn-primary btn-block" >Add Order</button>
<% if @dining.bookings.length >= 1 %>
<button type="button" id="customer" class="btn btn-primary btn-block" >Customer</button>
<% if @status_order == 'order' && @status_sale != 'sale' %>
<button type="button" id="add_order" class="btn btn-primary btn-block" >Add Order</button>
<button type="button" class="btn btn-primary btn-block" disabled >Edit</button>
<button type="button" id="discount" class="btn btn-primary btn-block" disabled>Discount</button>
<button type="button" id="other-charges" class="btn btn-primary btn-block" disabled>Charges</button>
@@ -317,7 +318,6 @@
<button type="button" id="pay" class="btn btn-primary btn-block" disabled>Pay</button>
<button type="button" class="btn btn-primary btn-block" disabled> Void </button>
<% else %>
<button type="button" id="add_order" class="btn btn-primary btn-block">Add Order</button>
<button type="button" class="btn btn-primary btn-block" id='edit'>Edit</button>
<button type="button" id="discount" class="btn btn-primary btn-block" >Discount</button>
<button type="button" id="other-charges" class="btn btn-primary btn-block" >Charges</button>
@@ -453,15 +453,16 @@ $("#first_bill").on('click', function(){
$('#pay').on('click',function() {
var sale_id = $('#sale_id').val();
var url = '/origami/sale/'+ sale_id + "/rounding_adj" ;
$.ajax({
type: "POST",
url: '/origami/sale/'+ sale_id + "/rounding_adj",
success:function(result){
window.location.href = '/origami/sale/'+ sale_id + "/payment";
}
});
var url = '/origami/sale/'+ sale_id + "/rounding_adj" ;
$.ajax({
type: "POST",
url: '/origami/sale/'+ sale_id + "/rounding_adj",
success:function(result){
window.location.href = '/origami/sale/'+ sale_id + "/payment";
}
});
});

View File

@@ -0,0 +1,2 @@
json.status true
json.get_type @get_type

View File

@@ -2,7 +2,7 @@
<div class="col-lg-11col-md-11 col-sm-11">
<div >
<div >
<% @payment_method_setting.each do |payment_method|%>
<% @payment_method_setting.where("is_active = true").each do |payment_method|%>
<div class="purple others-payment bottom left" data-type="<%= payment_method.payment_method %>" id="<%= payment_method.payment_method %>" data-url="<%=payment_method.gateway_url%>" data-sale-id="<%= @sale_id%>"><%= payment_method.payment_method %></div>
<% end %>
</div>

View File

@@ -41,24 +41,24 @@
<% sub_total = 0
count = 0
%>
<% @sale_data.sale_items.each do |sale_item|
<% @sale_data.sale_items.each do |sale_item|
count += 1
%>
<% sub_total += sale_item.price%>
<tr>
<% sub_total += sale_item.price%>
<tr>
<td><%= count %></td>
<td style="width:60%; text-align:left">
<span id="item-name-price"><%=sale_item.product_name%>@<%=sale_item.unit_price%></span>
</td>
<td style="width:20%; text-align:right">
<span id="item-qty"><%=sale_item.qty%></span>
</td>
<td style="width:20%; text-align:right">
<span id="item-total-price"><%=(sale_item.price)%></span>
</td>
</tr>
<%end %>
<td style="width:60%; text-align:left">
<span id="item-name-price"><%=sale_item.product_name%>@<%=sale_item.unit_price%></span>
</td>
<td style="width:20%; text-align:right">
<span id="item-qty"><%=sale_item.qty%></span>
</td>
<td style="width:20%; text-align:right">
<span id="item-total-price"><%=(sale_item.price)%></span>
</td>
</tr>
<%end %>
</tbody>
</table>
</div>
@@ -75,7 +75,7 @@
<%else%>
<td style="width:80%; text-align:left; border-top:none"><strong>(Discount)</strong></td>
<%end%>
<td style="width:20%; text-align:right; border-top:none"><strong><span>(<%=@sale_data.total_discount rescue 0%>)</span></strong></td>
</tr>
<tr>
@@ -258,7 +258,7 @@
<!-- Waiter Buttons -->
<button type="button" class="btn btn-primary btn-block" onclick="localStorage.removeItem('cash');window.location.href = '/origami';"> Back </button>
<button type="button" class="btn btn-primary btn-block"> FOC </button>
<button type="button" class="btn btn-primary btn-block" id="foc"> FOC </button>
<button type="button" class="btn btn-primary btn-block" id="void"> Void </button>
</div>
@@ -443,4 +443,40 @@ function update_balance(){
$('#balance').text(result.toFixed(2));
}
$('#foc').click(function() {
$( "#loading_wrapper" ).show();
// payment
var cash = $('#amount_due').text();
var sub_total = $('#sub-total').text();
var sale_id = $('#sale_id').text();
var params = { 'cash':cash,'sale_id':sale_id,'sub_total':sub_total };
$.ajax({type: "POST",
url: "<%= origami_payment_foc_path %>",
data: params,
success:function(result){
$( "#loading_wrapper" ).hide();
if (cash > 0) {
$.confirm({
title: 'Infomation!',
content: 'Thank you !',
buttons: {
confirm: {
text: 'Ok',
btnClass: 'btn-green',
action: function(){
window.location.href = '/origami';
}
}
}
});
}
}
});
});
</script>

View File

@@ -26,9 +26,15 @@
<p>Date: <span id="receipt_date"><%= @sale.created_at.utc.getlocal.strftime("%d/%m/%Y - %I:%M %p") rescue '-'%></span></p>
</div>
</div>
<div class="card-title row customer_detail hide">
<div class="card-title row customer_detail">
<div class="col-lg-6 col-md-6 col-sm-6">
<p>Customer : <span id="customer_name"></span></p>
<% if @status_sale == 'sale' %>
<p class="hidden customer-id"><%= @sale.customer_id rescue '' %></p>
<p>Customer : <%= @sale.customer.name rescue '-' %></p>
<%else%>
<p class="hidden customer-id"><%= @customer.customer_id rescue "" %></p>
<p>Customer : <%= @customer.name rescue "-" %></p>
<%end%>
</div>
</div>

View File

@@ -32,12 +32,15 @@
<p>Date: <span id="receipt_date"><%= @sale.created_at.utc.getlocal.strftime("%d/%m/%Y - %I:%M %p") rescue '-'%></span></p>
</div>
</div>
<div class="card-title row customer_detail hide">
<div class="card-title row customer_detail">
<div class="col-lg-6 col-md-6 col-sm-6">
<!-- <% if !@customer.nil? %> -->
<p class="hidden customer-id"><%= @customer.customer_id rescue "" %></p>
<p>Customer : <%= @customer.name rescue "" %></p>
<!-- <% end %> -->
<% if @status_sale == 'sale' %>
<p class="hidden customer-id"><%= @sale.customer_id rescue '' %></p>
<p>Customer : <%= @sale.customer.name rescue '-' %></p>
<%else%>
<p class="hidden customer-id"><%= @customer.customer_id rescue "" %></p>
<p>Customer : <%= @customer.name rescue "-" %></p>
<%end%>
</div>
</div>

View File

@@ -119,9 +119,9 @@
<div class="col-lg-5 col-md-5 col-sm-5">
<div class="card" >
<div class="card-header">
<% if @status == 'order' %>
<div id="save_order_id" data-order="<%= @obj.order_id %>"><strong id="order-title">ORDER DETAILS </strong> | Table <%= @room.name rescue "" %></div>
<% elsif @status == 'sale' %>
<% if @status_order == 'order' %>
<div id="save_order_id" data-order="<%= @obj_order.order_id %>"><strong id="order-title">ORDER DETAILS </strong> | Table <%= @room.name rescue "" %></div>
<% elsif @status_sale == 'sale' %>
<div><strong id="order-title">INVOICE DETAILS </strong> | Table <%= @room.name rescue "" %></div>
<% end %>
@@ -130,21 +130,25 @@
<div class="card-title row">
<div class="col-lg-6 col-md-6 col-sm-6">
<p> Receipt No: <span id="receipt_no">
<% if @status == 'sale' %>
<%= @obj.receipt_no rescue '' %>
<% if @status_sale == 'sale' %>
<%= @obj_sale.receipt_no rescue '' %>
<% end %>
</span></p>
</div>
<div class="col-lg-6 col-md-6 col-sm-6 text-right">
<p>Date: <span id="receipt_date"><%= @obj.created_at.utc.getlocal.strftime("%d/%m/%Y - %I:%M %p") rescue '-'%></span></p>
<p>Date: <span id="receipt_date"><%= @obj_sale.created_at.utc.getlocal.strftime("%d/%m/%Y - %I:%M %p") rescue '-'%></span></p>
</div>
</div>
<div class="card-title row customer_detail hide">
<div class="card-title row customer_detail">
<div class="col-lg-6 col-md-6 col-sm-6">
<%if @customer %>
<p class="hidden customer-id"><%= @customer.customer_id %></p>
<p>Customer : <%= @customer.name %></p>
<%end%>
<% if @status_sale == 'sale' %>
<p class="hidden customer-id"><%= @obj_sale_sale.customer_id rescue '' %></p>
<p>Customer : <%= @obj_sale_sale.customer.name rescue '-' %></p>
<%else%>
<p class="hidden customer-id"><%= @customer.customer_id rescue "" %></p>
<p>Customer : <%= @customer.name rescue "-" %></p>
<%end%>
</div>
</div>
@@ -152,6 +156,7 @@
<table class="table table-striped" id="order-items-table">
<thead>
<tr>
<th></th>
<th class="item-name">Items</th>
<th class="item-attr">QTY</td>
<th class="item-attr">Price</td>
@@ -159,35 +164,48 @@
</thead>
<tbody>
<%
count = 0
sub_total = 0
if @status == "sale"
@obj.sale_items.each do |sale_item|
sub_total = sub_total + sale_item.price
if @status_sale == "sale"
@sale_array[0].sale_items.each do |sale_item|
sub_total = sub_total + sale_item.price
%>
<input type="hidden" id="sale_id" value="<%= @obj.sale_id %>">
<% unless sale_item.price == 0 %>
<input type="hidden" id="sale_id" value="<%= @sale_array[0].sale_id %>">
<%
# Can't check for discount
unless sale_item.price == 0
count += 1
%>
<tr>
<td><%= count %></td>
<td class='item-name'><%= sale_item.product_name %></td>
<td class='item-attr'><%= sale_item.qty %></td>
<td class='item-attr'><%= sale_item.price %></td>
</tr>
<%
end
end
end
end
if @status == 'order'
if @status_order == 'order' && @status_sale != 'sale'
unless @order_items.nil?
count = 0
@order_items.each do |order_item |
count += 1
sub_total = sub_total + (order_item.price * order_item.qty)
unless order_item.price == 0 %>
<tr>
<td><%= count %></td>
<td class='item-name'><%= order_item.item_name %></td>
<td class='item-attr'><%= order_item.qty %></td>
<td class='item-attr'><%= order_item.qty*order_item.price %></td>
</tr>
<%
end
end
end
@@ -203,77 +221,78 @@
<td class="item-attr"><strong id="order-sub-total"><%= sub_total %></strong></td>
</tr>
<tr>
<%if @obj != nil && @status_sale == 'sale' && @obj.discount_type == 'member_discount'%>
<%if @obj_sale != nil && @obj_sale.discount_type == 'member_discount'%>
<td class="charges-name"><strong>Member Discount:</strong></td>
<%else%>
<td class="charges-name"><strong>Discount:</strong></td>
<%end%>
<td class="item-attr"><strong id="order-discount">(<%=@obj.total_discount rescue 0%>)</strong></td>
<td class="item-attr"><strong id="order-discount">(<%= @obj_sale.total_discount rescue 0%>)</strong></td>
</tr>
<% if @status == "sale" %>
<% if @status_sale == "sale" %>
<tr>
<td class="charges-name"><strong>Tax:</strong></td>
<td class="item-attr"><strong id="order-Tax"><%= @obj.total_tax rescue 0%></strong></td>
<td class="item-attr"><strong id="order-Tax"><%= @obj_sale.total_tax rescue 0%></strong></td>
</tr>
<tr>
<td class="charges-name"><strong>Rounding Adj:</strong></td>
<td class="item-attr"><strong id="order-round-adj"><%= @obj.rounding_adjustment rescue 0%></strong></td>
<td class="item-attr"><strong id="order-round-adj"><%= @obj_sale.rounding_adjustment rescue 0%></strong></td>
</tr>
<tr>
<td class="charges-name"><strong>Grand Total:</strong></td>
<td class="item-attr"><strong id="order-grand-total"><%= @obj.grand_total rescue 0%></strong></td>
<td class="item-attr"><strong id="order-grand-total"><%= @obj_sale.grand_total rescue 0%></strong></td>
</tr>
<% end %>
<tr class="rebate_amount"></tr>
</table>
</div>
<br>
<%
if @status == 'sale'
unless @order_items.nil?
%>
Pending New Order
<table class="table table-striped">
<%
count = 0
@order_items.each do |order_item |
count += 1
%>
<tr>
<td><%= count %>
<td class='item-name'><%= order_item.item_name %></td>
<td class='item-attr'><%= order_item.qty %></td>
<td class='item-attr'><%= order_item.qty*order_item.price %></td>
</tr>
<%
end
<%
if @status_sale == 'sale'
unless @order_items.nil?
%>
Pending New Order
<table class="table table-striped">
<%
count = 0
@order_items.each do |order_item |
count += 1
%>
</table>
<button class='btn btn-primary' id='add_invoice'> Add to existing invoice </button>
<% end %>
<% if @sale_array.size > 1 %>
<br><br>
Pending Payment
<% end %>
<% @sale_array.each do |sale|
if @sale_array.size > 1
unless sale.receipt_no == @sale_array[0].receipt_no
%>
<table class="table table-striped">
<tr>
<td>Receipt No - <%= sale.receipt_no %></td>
<td><button class='btn btn-sm btn-primary invoicedetails' id="<%= sale.sale_id %>">Show Detail </button></td>
</tr>
</table>
<%
end
end
end
end
%>
<tr>
<td><%= count %>
<td class='item-name'><%= order_item.item_name %></td>
<td class='item-attr'><%= order_item.qty %></td>
<td class='item-attr'><%= order_item.qty*order_item.price %></td>
</tr>
<%
end
%>
</table>
<button class='btn btn-primary' id='add_invoice'> Add to existing invoice </button>
<% end %>
<% if @sale_array.size > 1 %>
<br><br>
Pending Payment
<% end %>
<% @sale_array.each do |sale|
if @sale_array.size > 1
unless sale.receipt_no == @sale_array[0].receipt_no
%>
<table class="table table-striped">
<tr>
<td>Receipt No - <%= sale.receipt_no %></td>
<td><button class='btn btn-sm btn-primary invoicedetails' id="<%= sale.sale_id %>">Show Detail </button></td>
</tr>
</table>
<%
end
end
end
end
%>
</div>
</div>
@@ -284,12 +303,13 @@
<!-- Waiter Buttons -->
<button type="button" class="btn btn-primary btn-block" id='back' >Back</button>
<% if @room.bookings.length >= 1 %>
<button type="button" id="customer" class="btn btn-primary btn-block" >Customer</button>
<% if @status == 'order' && @status != 'sale' %>
<% if @status_order == 'order' && @status_sale != 'sale' %>
<!-- <button type="button" class="btn btn-primary btn-block" >Add Order</button> -->
<button type="button" id="customer" class="btn btn-primary btn-block" disabled>Customer</button>
<button type="button" class="btn btn-primary btn-block" disabled >Edit</button>
<button type="button" id="discount" class="btn btn-primary btn-block" disabled >Discount</button>
<button type="button" id="other-charges" class="btn btn-primary btn-block" disabled>Charges</button>
<button type="button" class="btn btn-primary btn-block" id='move'>Move</button>
<button type="button" id="request_bills" class="btn btn-primary btn-block">Req.Bill</button>
<button type="button" id="first_bill" class="btn btn-primary btn-block" disabled>First Bill</button>
@@ -297,8 +317,10 @@
<button type="button" class="btn btn-primary btn-block" disabled=""> Void </button>
<% else %>
<!-- <button type="button" class="btn btn-primary btn-block" disabled>Add Order</button> -->
<button type="button" id="customer" class="btn btn-primary btn-block" >Customer</button>
<button type="button" class="btn btn-primary btn-block" id='edit'>Edit</button>
<button type="button" id="discount" class="btn btn-primary btn-block" >Discount</button>
<button type="button" id="other-charges" class="btn btn-primary btn-block" >Charges</button>
<button type="button" class="btn btn-primary btn-block" id='move' disabled="">Move</button>
<button type="button" id="request_bills" class="btn btn-primary btn-block" disabled> Req.Bill</button>
<button type="button" id="first_bill" class="btn btn-primary btn-block">First Bill</button>
@@ -424,6 +446,25 @@ $(document).ready(function(){
return false;
});
// Add Other Charges
$('#other-charges').click(function() {
var sale = $('#sale_id').val();
if (sale!="") {
var sale_id = sale
}else{
var sale_id = $('#save_order_id').attr('data-order');
}
if(sale_id!=""){
window.location.href = '/origami/' + sale_id + '/other_charges'
}
else {
alert("Please select an table!");
}
return false;
});
});
// Print for first bill
@@ -494,7 +535,7 @@ $('#back').on('click',function(){
$('#add_invoice').on('click',function(){
var dining_id = "<%= @room.id %>"
var sale_id = "<%= @obj.sale_id rescue "" %>"
var sale_id = "<%= @obj_sale.sale_id rescue "" %>"
var ajax_url = "/origami/sale/append_order";
$.ajax({
type: "POST",
@@ -577,7 +618,7 @@ $('#add_invoice').on('click',function(){
$('#edit').on('click',function(){
var dining_id = "<%= @room.id %>"
var sale_id = "<%= @obj.sale_id rescue "" %>"
var sale_id = "<%= @obj_sale.sale_id rescue "" %>"
window.location.href = '/origami/table/'+ dining_id + "/sale/"+ sale_id + "/edit";
});

View File

@@ -1,216 +1,235 @@
<div class="row">
<!-- Column Two -->
<!-- Column Two -->
<div class="col-lg-10 col-md-10 col-sm-10">
<div class="card" >
<div class="card-header">
<div><strong id="order-title">INVOICE DETAILS </strong></div>
</div>
<div class="card-block">
<div class="card-title row">
<div class="col-lg-6 col-md-6 col-sm-6">
<p> Receipt No: <span id="receipt_no">
<div class="card">
<div class="card-header">
<div><strong id="order-title">INVOICE DETAILS </strong></div>
</div>
<div class="card-block">
<div class="card-title row">
<div class="col-lg-6 col-md-6 col-sm-6">
<p> Receipt No: <span id="receipt_no">
<%= @saleobj.receipt_no rescue '' %>
</span></p>
</div>
<div class="col-lg-6 col-md-6 col-sm-6 text-right">
<p>Date: <span id="receipt_date"><%= @saleobj.created_at.utc.getlocal.strftime("%d/%m/%Y - %I:%M %p") rescue '-'%></span></p>
</div>
</div>
<div class="card-title row customer_detail hide">
<div class="col-lg-6 col-md-6 col-sm-6">
<p>Customer : <span id="customer_name"></span></p>
</div>
</div>
<div class="col-lg-6 col-md-6 col-sm-6 text-right">
<p>Date:
<span id="receipt_date"><%= @saleobj.created_at.utc.getlocal.strftime("%d/%m/%Y - %I:%M %p") rescue '-' %></span>
</p>
</div>
</div>
<div class="card-title row customer_detail hide">
<div class="col-lg-6 col-md-6 col-sm-6">
<p>Customer : <span id="customer_name"></span></p>
</div>
</div>
<div class="card-text" style="min-height:500px; max-height:500px; overflow-x:scroll">
<table class="table " id="order-items-table">
<thead>
<tr>
<th width="4%">#</th>
<th class="" width="30%">Items</th>
<th style="" width="13%">QTY</td>
<th class="" width="13%">Price</td>
<!-- <th class='' width="17%"> Total </th> -->
<th class='' width="17%"> Action </th>
</tr>
</thead>
<tbody>
<%
count = 0
sub_total = 0
@saleobj.sale_items.each do |sale_item|
count += 1
sub_total = sub_total + sale_item.price
%>
<input type="hidden" id="sale_id" value="<%= @saleobj.sale_id %>">
<%
# Can't check for discount
unless sale_item.price == 0
</div>
<div class="card-text" style="min-height:500px; max-height:500px; overflow-x:scroll">
<table class="table " id="order-items-table">
<thead>
<tr>
<th width="4%">#</th>
<th class="" width="30%">Items</th>
<th style="" width="13%">QTY
</td>
<th class="" width="13%">Price
</td>
<!-- <th class='' width="17%"> Total </th> -->
<th class='' width="17%"> Action</th>
</tr>
</thead>
<tbody>
<%
count = 0
sub_total = 0
@saleobj.sale_items.each do |sale_item|
count += 1
sub_total = sub_total + sale_item.price
%>
<input type="hidden" id="sale_id" value="<%= @saleobj.sale_id %>">
<%
# Can't check for discount
unless sale_item.price == 0
%>
<tr>
<td width="4%"><%= count %></td>
<td class='' width="30%">
<%= sale_item.product_name %>
</td>
<% if sale_item.remark != 'void' && sale_item.remark != 'edit' %>
<td class='' width="13%">
<input id="<%= sale_item.id%>_qty" data-id ="<%= sale_item.id %>" type="text" value="<%= sale_item.qty %>" class="form-control "/>
</td>
<td class='' width="13%">
<input id="<%= sale_item.id%>_price" data-id ="<%= sale_item.id %>" type="text" value="<%= sale_item.unit_price %>" class="form-control"/>
</td>
<!-- <td class='' width="17%">
<input id="<%= sale_item.id%>_price" data-id ="<%= sale_item.id %>" type="text" value="<%= sale_item.price %>" class="form-control"/>
<tr>
<td width="4%"><%= count %></td>
<td class='' width="30%">
<%= sale_item.product_name %>
</td>
<% if sale_item.remark != 'void' && sale_item.remark != 'edit' && sale_item.remark != 'foc' %>
<td class='' width="13%">
<input id="<%= sale_item.id %>_qty" data-id="<%= sale_item.id %>" type="text" value="<%= sale_item.qty %>" class="form-control "/>
</td>
<td class='' width="13%">
<input id="<%= sale_item.id %>_price" data-id="<%= sale_item.id %>" type="text" value="<%= sale_item.unit_price %>" class="form-control"/>
</td>
<!-- <td class='' width="17%">
<input id="<%= sale_item.id %>_price" data-id ="<%= sale_item.id %>" type="text" value="<%= sale_item.price %>" class="form-control"/>
</td> -->
<td class='' width="17%">
<button data-id ="<%= sale_item.id %>" class='btn btn-primary btn-md update'>Update
</button>
<button data-id ="<%= sale_item.id %>" class='btn btn-danger btn-md void'>Void</button>
</td>
<td class='' width="17%">
<button data-id="<%= sale_item.id %>" class='btn btn-primary btn-md update'>Update</button>
<button data-id="<%= sale_item.id %>" class='btn btn-danger btn-md void'>Void</button>
<button data-id="<%= sale_item.id %>" class='btn btn-info btn-md foc'>FOC</button>
</td>
<% elsif sale_item.qty.to_i < 0 || sale_item.remark == 'edit' %>
<td class='' width="13%">
<input data-id ="<%= sale_item.id %>" type="text" value="<%= sale_item.qty %>" class="form-control" disabled/>
</td>
<td class='' width="13%">
<input data-id ="<%= sale_item.id %>" type="text" value="<%= sale_item.unit_price %>" class="form-control" disabled/>
</td>
<!-- <td class='' width="17%">
<% elsif sale_item.qty.to_i < 0 || sale_item.remark == 'edit' %>
<td class='' width="13%">
<input data-id="<%= sale_item.id %>" type="text" value="<%= sale_item.qty %>" class="form-control" disabled/>
</td>
<td class='' width="13%">
<input data-id="<%= sale_item.id %>" type="text" value="<%= sale_item.unit_price %>" class="form-control" disabled/>
</td>
<!-- <td class='' width="17%">
<input data-id ="<%= sale_item.id %>" type="text" value="<%= sale_item.price %>" class="form-control" disabled/>
</td> -->
<td class='' width="17%">
<button data-id ="<%= sale_item.id %>" class='btn btn-primary btn-md cancel'>Cancel Void/Update</button>
</td>
<% else %>
<td class='' width="13%">
<input data-id ="<%= sale_item.id %>" type="text" value="<%= sale_item.qty %>" class="form-control" disabled/>
</td>
<td class='' width="13%">
<input data-id ="<%= sale_item.id %>" type="text" value="<%= sale_item.price %>" class="form-control" disabled/>
</td>
<td></td>
<% end %>
</tr>
<%
end
end
%>
</tbody>
</table>
</div>
<div class="card-footer">
<table class="table" id="order-charges-table" border="0">
<tr>
<td class="charges-name"><strong>Sub Total:</strong></td>
<td class="item-attr"><strong id="order-sub-total"><%= sub_total %></strong></td>
</tr>
<tr class="rebate_amount"></tr>
</table>
</div>
</div>
</div>
<td class='' width="17%">
<button data-id="<%= sale_item.id %>" class='btn btn-primary btn-md cancel'>Cancel
Void/Update
</button>
</td>
<% else %>
<td class='' width="13%">
<input data-id="<%= sale_item.id %>" type="text" value="<%= sale_item.qty %>" class="form-control" disabled/>
</td>
<td class='' width="13%">
<input data-id="<%= sale_item.id %>" type="text" value="<%= sale_item.price %>" class="form-control" disabled/>
</td>
<td></td>
<% end %>
</tr>
<%
end
end
%>
</tbody>
</table>
</div>
<div class="card-footer">
<table class="table" id="order-charges-table" border="0">
<tr>
<td class="charges-name"><strong>Sub Total:</strong></td>
<td class="item-attr"><strong id="order-sub-total"><%= sub_total %></strong></td>
</tr>
<tr class="rebate_amount"></tr>
</table>
</div>
</div>
</div>
</div>
<!-- Column Three -->
<div class="col-lg-2 col-md-2 col-sm-2">
<!-- Waiter Buttons -->
<button type="button" class="btn btn-primary btn-block" id='back' >Back</button>
<button type="button" class="btn btn-primary btn-block" id='cancel_all_void' >Cancel All Void</button>
<button type="button" class="btn btn-primary btn-block" id='apply' >Apply</button>
</div>
<!-- Column Three -->
<div class="col-lg-2 col-md-2 col-sm-2">
<!-- Waiter Buttons -->
<button type="button" class="btn btn-primary btn-block" id='back'>Back</button>
<button type="button" class="btn btn-primary btn-block" id='cancel_all_void'>Cancel All Void</button>
<button type="button" class="btn btn-primary btn-block" id='apply'>Apply</button>
</div>
</div>
<script>
// Bill Request
$(document).ready(function(){
$(".update").on('click',function() {
var sale_item_id = $(this).attr('data-id');
var qty = $('#'+sale_item_id + "_qty").val();
var price = $('#'+ sale_item_id + "_price").val();
console.log(qty + "|" + price)
var ajax_url = "/origami/item_edit";
$.ajax({
type: "POST",
url: ajax_url,
data: 'sale_item_id='+ sale_item_id + "&update_qty="+qty + "&update_price="+ price,
success:function(result){
$.confirm({
title: 'Alert!',
content: 'Qty and Price was successfully Updated',
buttons: {
// Bill Request
$(document).ready(function () {
confirm: {
text: 'Ok',
btnClass: 'btn-green btn-lg',
action: function(){
location.reload();
$(".update").on('click', function () {
var sale_item_id = $(this).attr('data-id');
var qty = $('#' + sale_item_id + "_qty").val();
var price = $('#' + sale_item_id + "_price").val();
console.log(qty + "|" + price)
var ajax_url = "/origami/item_edit";
$.ajax({
type: "POST",
url: ajax_url,
data: 'sale_item_id=' + sale_item_id + "&update_qty=" + qty + "&update_price=" + price,
success: function (result) {
$.confirm({
title: 'Alert!',
content: 'Qty and Price was successfully Updated',
buttons: {
confirm: {
text: 'Ok',
btnClass: 'btn-green btn-lg',
action: function () {
location.reload();
}
}
}
});
}
});
});
$('.void').on('click', function () {
var sale_item_id = $(this).attr('data-id');
var ajax_url = "/origami/item_void";
$.ajax({
type: "POST",
url: ajax_url,
data: 'sale_item_id=' + sale_item_id,
success: function (result) {
location.reload();
}
});
})
$('.foc').on('click', function () {
var sale_item_id = $(this).attr('data-id');
var ajax_url = "/origami/item_foc";
$.ajax({
type: "POST",
url: ajax_url,
data: 'sale_item_id=' + sale_item_id,
success: function (result) {
location.reload();
}
});
})
$('.cancel').on('click', function () {
var sale_item_id = $(this).attr('data-id');
var ajax_url = "/origami/item_void_cancel";
$.ajax({
type: "POST",
url: ajax_url,
data: 'sale_item_id=' + sale_item_id,
success: function (result) {
location.reload();
}
});
})
})
$('#back').on('click', function () {
var table_id = '<%= @table_id %>'
window.location.href = '/origami/table/' + table_id;
})
$('#cancel_all_void').on('click', function () {
var sale_id = "<%= @saleobj.sale_id %>"
var ajax_url = "/origami/cancel_all_void";
$.ajax({
type: "POST",
url: ajax_url,
data: 'sale_id=' + sale_id,
success: function (result) {
location.reload();
}
}
}
});
});
})
}
});
});
$('.void').on('click',function(){
var sale_item_id = $(this).attr('data-id');
var ajax_url = "/origami/item_void";
$.ajax({
type: "POST",
url: ajax_url,
data: 'sale_item_id='+ sale_item_id,
success:function(result){
location.reload();
}
});
})
$('.cancel').on('click',function(){
var sale_item_id = $(this).attr('data-id');
var ajax_url = "/origami/item_void_cancel";
$.ajax({
type: "POST",
url: ajax_url,
data: 'sale_item_id='+ sale_item_id,
success:function(result){
location.reload();
}
});
})
})
$('#back').on('click',function(){
var table_id = '<%= @table_id %>'
window.location.href = '/origami/table/'+ table_id;
})
$('#cancel_all_void').on('click',function(){
var sale_id = "<%= @saleobj.sale_id %>"
var ajax_url = "/origami/cancel_all_void";
$.ajax({
type: "POST",
url: ajax_url,
data: 'sale_id='+ sale_id,
success:function(result){
location.reload();
}
});
})
$('#apply').on('click',function(){
var sale_id = "<%= @saleobj.sale_id %>"
var ajax_url = "/origami/apply_void";
var table_id = '<%= @table_id %>'
$.ajax({
type: "POST",
url: ajax_url,
data: 'sale_id='+ sale_id,
success:function(result){
window.location.href = '/origami/table/'+ table_id ;
}
});
})
$('#apply').on('click', function () {
var sale_id = "<%= @saleobj.sale_id %>"
var ajax_url = "/origami/apply_void";
var table_id = '<%= @table_id %>'
$.ajax({
type: "POST",
url: ajax_url,
data: 'sale_id=' + sale_id,
success: function (result) {
window.location.href = '/origami/table/' + table_id;
}
});
})
</script>

View File

@@ -120,9 +120,11 @@
<p>Date: <span id="receipt_date"><%= @sale.created_at.strftime("%d/%m/%Y - %I:%M %p") rescue '-'%></span></p>
</div>
</div>
<div class="card-title row customer_detail hide">
<div class="card-title row customer_detail">
<div class="col-lg-6 col-md-6 col-sm-6">
<p>Customer : <span id="customer_name"></span></p>
<p>Customer : <%= @sale.customer.name rescue "-" %></p>
</div>
</div>

View File

@@ -0,0 +1,201 @@
<div class="row">
<div class="col-lg-10 col-md-10 col-sm-10">
<h3 style="text-align: center;">Sales Summary Quick View </h3>
<table class="table table-striped">
<tbody>
<tr>
<th>Cashier </th>
<th>Cashier Terminal </th>
<th>Opening Date </th>
<th>Opening float </th>
<th>Received Amount </th>
<th>Cast In </th>
<th>Cast Out </th>
<th>Total Receipt </th>
<th>Dining Count </th>
<th>Takeaway Count </th>
<th>Total Void</th>
</tr>
<tr style="border-bottom:2px solid #000">
<td><%= @shift.employee.name%></td>
<td><%=@shift.cashier_terminal.name%></td>
<td><%= @shift.shift_started_at.utc.getlocal.strftime('%d-%m-%Y %I:%M %p') %>
</td>
<td><%=@shift.opening_balance %></td>
<td><%=@shift.closing_balance %></td>
<td><%=@shift.cash_in %></td>
<td><%=@shift.cash_out %></td>
<th><%= @shift.total_receipt %></th>
<th><%= @shift.dining_count %></th>
<th><%= @shift.takeaway_count %></th>
<th>(<%= @shift.total_void.round(2) %>)</th>
</tr>
<tr>
<td colspan="5">
<table width="100%">
<% @total_amount_by_account.each do |amount| %>
<tr>
<th></th>
<td style="text-align: right;"> Total <%= amount.account_name %> Amount</td>
<td><%= amount.total_price.round(2) %></td>
</tr>
<%end%>
<tr>
<th></th>
<th style="text-align: right;"> Net Sales</th>
<th><%=@shift.nett_sales %></th>
</tr>
<% @total_discount_by_account.each do |amount| %>
<tr>
<th></th>
<td style="text-align: right;"> Total <%= amount.account_name %> Discount</td>
<td><%= amount.total_price.round(2) %></td>
</tr>
<%end%>
<% if !@total_member_discount[0].member_discount.nil?
@member_discount = @total_member_discount[0].member_discount rescue 0.0
@overall = @shift.total_discounts - @member_discount
%>
<tr>
<th></th>
<th style="text-align: right;"> Total Member Discount</th>
<th><%= @member_discount %></th>
</tr>
<%else @overall = @shift.total_discounts %>
<%end%>
<tr>
<th></th>
<th style="text-align: right;"> Total Overall Discount</th>
<th><%= @overall %></th>
</tr>
<tr>
<th></th>
<th style="text-align: right;"> Total Discount</th>
<th><%= @shift.total_discounts %></th>
</tr>
<% @sale_taxes.each do |tax| %>
<tr>
<th></th>
<td style="text-align: right;"> <%= tax.tax_name %> </td>
<td><%= tax.st_amount.round(2) %></td>
</tr>
<%end%>
<tr>
<th></th>
<th style="text-align: right;"> Total Tax </th>
<th><%=@shift.total_taxes %></th>
</tr>
<tr>
<th></th>
<th style="text-align: right;"> Rounding Adj </th>
<th><%= @shift.total_rounding.round(2) %></th>
</tr>
<tr>
<th></th>
<th style="text-align: right;"> Grand Total </th>
<th><%= @shift.grand_total.round(2) %></th>
</tr>
</table>
</td>
<td colspan="6">
<table width="100%">
<tr>
<th></th>
<th style="text-align: right;">Cash Payment </th>
<th><%=@shift.cash_sales %></th>
</tr>
<tr>
<th></th>
<th style="text-align: right;">Credit Payment </th>
<th><%=@shift.credit_sales %></th>
</tr>
<% @total_amount = 0
@other_payment.each do |other| %>
<tr>
<th></th>
<th style="text-align: right;">Other Payment Detail </th>
<th></th>
</tr>
<tr>
<th></th>
<td style="text-align: right;">MPU Payment </td>
<td><%=other.mpu_amount.round(2) rescue 0.0 %></td>
<% @total_amount = @total_amount+other.mpu_amount rescue 0.0 %>
</tr>
<tr>
<th></th>
<td style="text-align: right;">VISA Payment </td>
<td><%=other.visa_amount.round(2) rescue 0.0 %></td>
<% @total_amount = @total_amount+other.visa_amount rescue 0.0 %>
</tr>
<tr>
<th></th>
<td style="text-align: right;">JCB Payment </td>
<td><%=other.master_amount.round(2) rescue 0.0 %></td>
<% @total_amount = @total_amount+other.master_amount rescue 0.0 %>
</tr>
<tr>
<th></th>
<td style="text-align: right;">Master Payment </td>
<td><%=other.jcb_amount.round(2) rescue 0.0 %></td>
<% @total_amount = @total_amount+other.jcb_amount rescue 0.0 %>
</tr>
<tr>
<th></th>
<td style="text-align: right;">Reedem Payment </td>
<td><%=other.paypar_amount.round(2) rescue 0.0 %></td>
<% @total_amount = @total_amount+other.paypar_amount rescue 0.0 %>
</tr>
<tr>
<th></th>
<td style="text-align: right;"><strong>FOC </strong></td>
<td><%=other.foc_amount.round(2) rescue 0.0 %></td>
<% @total_amount = @total_amount+other.foc_amount rescue 0.0 %>
</tr>
<%end%>
<tr>
<th></th>
<th style="text-align: right;">Total Other Payment </th>
<th><%=@shift.other_sales %></th>
</tr>
<tr>
<th></th>
<th style="text-align: right;">Total Payment </th>
<th><%= @total_amount+@shift.cash_sales+@shift.credit_sales %></th>
</tr>
</table>
</td>
</tr>
</tbody>
</table>
</div>
<div class="col-lg-2 col-md-2 col-sm-2">
<br><br><br>
<button id="close_cashier" type="button" class="btn btn-block btn-primary btn-lg"> Close Cashier
</button>
<button id="back" type="button" class="btn btn-block btn-primary btn-lg"><i class="fa fa-home fa-lg"></i> Back
</button>
</div>
</div>
<script type="text/javascript">
$(document).ready(function(){
$('#close_cashier').on('click',function(){
window.location.href = '/origami/shift/close';
})
$('#back').on('click',function(){
window.location.href = '/origami';
})
})
</script>

View File

@@ -26,9 +26,15 @@
<p>Date: <span id="receipt_date"><%= @sale.created_at.utc.getlocal.strftime("%d/%m/%Y - %I:%M %p") rescue '-'%></span></p>
</div>
</div>
<div class="card-title row customer_detail hide">
<div class="card-title row customer_detail">
<div class="col-lg-6 col-md-6 col-sm-6">
<p>Customer : <span id="customer_name"></span></p>
<% if @status_sale == 'sale' %>
<p class="hidden customer-id"><%= @sale.customer_id rescue '' %></p>
<p>Customer : <%= @sale.customer.name rescue '-' %></p>
<%else%>
<p class="hidden customer-id"><%= @customer.customer_id rescue "" %></p>
<p>Customer : <%= @customer.name rescue "-" %></p>
<%end%>
</div>
</div>

View File

@@ -32,12 +32,15 @@
<p>Date: <span id="receipt_date"><%= @sale.created_at.utc.getlocal.strftime("%d/%m/%Y - %I:%M %p") rescue '-'%></span></p>
</div>
</div>
<div class="card-title row customer_detail hide">
<div class="card-title row customer_detail">
<div class="col-lg-6 col-md-6 col-sm-6">
<!-- <% if !@customer.nil? %> -->
<p class="hidden customer-id"><%= @customer.customer_id rescue "" %></p>
<p>Customer : <%= @customer.name rescue "" %></p>
<!-- <% end %> -->
<% if @status_sale == 'sale' %>
<p class="hidden customer-id"><%= @sale.customer_id rescue '' %></p>
<p>Customer : <%= @sale.customer.name rescue '-' %></p>
<%else%>
<p class="hidden customer-id"><%= @customer.customer_id rescue "" %></p>
<p>Customer : <%= @customer.name rescue "-" %></p>
<%end%>
</div>
</div>

View File

@@ -0,0 +1,5 @@
if(@status)
json.status @status
else
json.status false
end

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