Merge branch 'adminbsb_ui_changes' of bitbucket.org:code2lab/sxrestaurant

This commit is contained in:
phyusin
2018-09-24 10:29:49 +06:30
13 changed files with 311 additions and 55 deletions

View File

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

View File

@@ -653,4 +653,9 @@ nav.pagination .page a:hover,
font-size: 14px;
color: #FFFFFF;
}
/*customer modal UI */
/*customer modal UI */
.payment-btn-box {
width: 130px;
height: 50px;
}

View File

@@ -255,7 +255,14 @@ class Origami::PaymentsController < BaseOrigamiController
def show
path = request.fullpath
sale_id = params[:sale_id]
@cashier_type = params[:type]
@trans_flag = true
if params[:type] == "transaction"
@trans_flag = false
@cashier_type = "cashier"
else
@cashier_type = params[:type]
end
if path.include? ("credit_payment")
@sale_payment = SalePayment.get_credit_amount_due_left(sale_id)
end

View File

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

View File

@@ -35,7 +35,7 @@ class Transactions::BookingsController < ApplicationController
def show
@booking = Booking.find(params[:id])
@order = []
@order_items = []
@booking.booking_orders.each do |booking_order|
@order = Order.find(booking_order.order_id)

View File

@@ -89,7 +89,8 @@ class Transactions::SalesController < ApplicationController
# GET /transactions/sales/1
# GET /transactions/sales/1.json
def show
@membership = MembershipSetting::MembershipSetting
@payment_methods = PaymentMethodSetting.where("is_active='1'")
@sale = Sale.find(params[:id])
@order_items = []

View File

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

View File

@@ -557,22 +557,26 @@
<h4 class="modal-title" id="paymentModalLabel">Choose Payment Method</h4>
</div>
<div class="modal-body">
<!-- <select class="form-control show-tick payment_method" multiple="true" id="payment_method" > -->
<!-- <option value="Cash">Cash</option> -->
<button class='btn waves-effect payment_btn green' data-type='Credit' data-value='Credit'>Credit</button>
<% @payment_methods.each do |pay| %>
<!-- <option value="<%= pay.payment_method %>">
<%= pay.payment_method %>
</option> -->
<button class='btn btn-lg waves-effect payment_btn green' data-type='<%= pay.payment_method %>' data-value='<%= pay.payment_method %>'><%= pay.payment_method %></button>
<%end %>
<!-- </select> -->
<div class="row text-center">
<div class="col-xs-4 col-sm-4 col-md-4 col-lg-4">
<button class='btn btn-md waves-effect btn-link payment-btn-box payment_btn bg-green' data-type='Credit' data-value='Credit'>Credit</button>
</div>
<% @payment_methods.each_with_index do |pay, pay_index| %>
<%if (pay_index+1)%3 == 0 %>
<div class="row clearfix"></div>
<% end %>
<div class="col-xs-4 col-sm-4 col-md-4 col-lg-4">
<button class='btn btn-md btn-link payment-btn-box waves-effect payment_btn bg-green' data-type='<%= pay.payment_method %>' data-value='<%= pay.payment_method %>'><%= pay.payment_method %></button>
</div>
<%end %>
</div>
</div>
<div class="modal-footer p-r-30">
<button type="button" class="btn btn-link btn-danger waves-effect" data-dismiss="modal">CLOSE</button>
<div class="modal-footer p-r-30 pb-3">
<button type="button" class="btn btn-md btn-link btn-danger waves-effect" data-dismiss="modal">CLOSE</button>
&nbsp; &nbsp;
<button type="button" class="btn btn-link bg-blue waves-effect choose_payment">SAVE</button>
<button type="button" class="btn btn-md btn-link bg-blue waves-effect choose_payment">SAVE</button>
</div>
</div>
</div>

View File

@@ -678,10 +678,19 @@ var cashier_type = "<%= @cashier_type %>";
var customer_id = "<%= @customer.id %>";
var customer_name = "<%= @customer.name %>";
var pdf_view = '<%=@pdf_view%>';
console.log(pdf_view)
var trans_flag = <%= @trans_flag %>;
// console.log(pdf_view)
$(document).ready(function(){
setHeaderBreadCrumb(_PAYMENTS_);
/* replace url type*/
if(!trans_flag){
localStorage.setItem("trans_flag", trans_flag);
var sale_id = $('#sale_id').text();
window.location.replace('/origami/sale/'+sale_id+'/cashier/payment');
}
/* replace url type*/
/* start check first bill or not*/
var member_id = $('#membership_id').text();
var member_discount = $('#member_discount').text();
@@ -727,11 +736,17 @@ var pdf_view = '<%=@pdf_view%>';
localStorage.removeItem('cash');
customer_display_view(null,"reload");
var sale_id = $('#sale_id').text();
if (cashier_type=="cashier") {
window.location.href = '/origami/table/'+ dining_id;
var flag = localStorage.getItem("trans_flag");
if(flag != "true"){
window.location.href = '/transactions/sales/'+sale_id;
}else{
window.location.href = '/origami/quick_service/pending_order/'+sale_id;
}
if (cashier_type=="cashier") {
window.location.href = '/origami/table/'+ dining_id;
}else{
window.location.href = '/origami/quick_service/pending_order/'+sale_id;
}
}
});
if(localStorage.getItem("cash") == null || localStorage.getItem("cash") == 'null'){
@@ -1135,12 +1150,17 @@ var pdf_view = '<%=@pdf_view%>';
}
if (pdf_view ==1) {
if (cashier_type=="cashier") {
window.location.href = '/origami';
var flag = localStorage.getItem("trans_flag");
if(flag != "true"){
window.location.href = "/transactions/sales/"+sale_id;
}else{
window.location.href = '/origami/quick_service';
customer_display_view(null,"reload");
}
if (cashier_type=="cashier") {
window.location.href = '/origami';
}else{
window.location.href = '/origami/quick_service';
customer_display_view(null,"reload");
}
}
}else{
payment_success_alert();
}
@@ -1176,11 +1196,18 @@ var pdf_view = '<%=@pdf_view%>';
$(".btn_pdf_close").on('click',function(){
if (cashier_type=="cashier") {
window.location.href = '/origami';
var flag = localStorage.getItem("trans_flag");
if(flag != "true"){
var sale_id = $('#sale_id').text();
window.location.href = "/transactions/sales/"+sale_id;
}else{
window.location.href = '/origami/quick_service';
}
if (cashier_type=="cashier") {
window.location.href = '/origami';
}else{
window.location.href = '/origami/quick_service';
}
}
});
$(".btn_customer_yes").on('click',function(){

View File

@@ -575,18 +575,26 @@
<h4 class="modal-title" id="paymentModalLabel">Choose Payment</h4>
</div>
<div class="modal-body">
<button class='btn waves-effect payment_btn green' data-type='Credit' data-value='Credit'>Credit</button>
<% @payment_methods.each do |pay| %>
<!-- <option value="<%= pay.payment_method %>">
<%= pay.payment_method %>
</option> -->
<button class='btn btn-lg waves-effect payment_btn green' data-type='<%= pay.payment_method %>' data-value='<%= pay.payment_method %>'><%= pay.payment_method %></button>
<%end %>
<div class="row text-center">
<div class="col-xs-4 col-sm-4 col-md-4 col-lg-4">
<button class='btn btn-md waves-effect btn-link payment-btn-box payment_btn bg-green' data-type='Credit' data-value='Credit'>Credit</button>
</div>
<% @payment_methods.each_with_index do |pay, pay_index| %>
<%if (pay_index+1)%3 == 0 %>
<div class="row clearfix"></div>
<% end %>
<div class="col-xs-4 col-sm-4 col-md-4 col-lg-4">
<button class='btn btn-md btn-link payment-btn-box waves-effect payment_btn bg-green' data-type='<%= pay.payment_method %>' data-value='<%= pay.payment_method %>'><%= pay.payment_method %></button>
</div>
<%end %>
</div>
</div>
<div class="modal-footer p-r-30">
<button type="button" class="btn btn-link btn-danger waves-effect" data-dismiss="modal">CLOSE</button>
<div class="modal-footer p-r-30 pb-3">
<button type="button" class="btn btn-md btn-link btn-danger waves-effect" data-dismiss="modal">CLOSE</button>
&nbsp; &nbsp;
<button type="button" class="btn btn-link bg-blue waves-effect choose_payment">SAVE</button>
<button type="button" class="btn btn-md btn-link bg-blue waves-effect choose_payment">SAVE</button>
</div>
</div>
</div>

View File

@@ -19,7 +19,7 @@
<div class="row clearfix">
<div class="col-lg-4 col-md-4 col-sm-4 col-xs-4">
<label><%= t("views.right_panel.detail.enter_keyboards") %></label>
<input type="text" id="receipt_no" name="receipt_no" class="form-control" placeholder="Booking/Sale ID" style="margin-right: 10px">
<input type="text" id="receipt_no" name="receipt_no" class="form-control" placeholder="Booking/ Sale ID/ Table/ Room" style="margin-right: 10px">
</div>
<div class="col-lg-3 col-md-3 col-sm-3 col-xs-3">
<label class=""><%= t("views.right_panel.detail.from") %></label>

View File

@@ -23,6 +23,7 @@
<a class="nav-link" data-toggle="tab" href="#sale" role="tab"><%= t :sale_details %></a>
</li>
</ul>
<!-- Nav tabs - End -->
<div class="tab-content" style="min-height:670px; max-height:670px;">
<div class="tab-pane active" id="booking" role="tabpanel">
@@ -39,13 +40,18 @@
<th> <%= t("views.right_panel.detail.checkout_by") %></th>
<th><%= t("views.right_panel.detail.booking_status") %></th>
<th><%= t("views.right_panel.detail.booking_date") %></th>
<%if (@booking.sale_id.nil?) && (current_login_employee.role == "administrator") && (!@order.nil?) %>
<th>
<button id="request_bill" class="btn bg-blue btn-md waves-effect">Req. Bill</button>
</th>
<% end %>
</tr>
</thead>
<tbody>
<tr>
<td><%= @booking.booking_id%></td>
<td><%= link_to @booking.sale_id, transactions_sale_path(booking.sale_id) rescue '-' %></td>
<td><%= link_to @booking.sale_id, transactions_sale_path(@booking.sale_id) rescue '-' %></td>
<td><%= @booking.dining_facility.name rescue '' %></td>
<td><%= @booking.checkin_at.utc.getlocal.strftime("%I:%M %p") %></td>
<td><%= @booking.checkout_at.utc.getlocal.strftime("%I:%M %p") rescue '-' %></td>
@@ -53,6 +59,9 @@
<td><%= @booking.checkout_by rescue '-' %></td>
<td><%= @booking.booking_status %> </td>
<td><%= @booking.created_at.utc.getlocal.strftime("%d-%m-%Y %I:%M %p") %> </td>
<%if (@booking.sale_id.nil?) && (current_login_employee.role == "administrator") && (!@order.nil?) %>
<td></td>
<% end %>
</tr>
</tbody>
</table>
@@ -135,6 +144,37 @@
<script type="text/javascript">
$(document).ready(function(){
$("#request_bill").on('click', function(){
var order_id = '';
<%if !@order.nil? %>
order_id ='<%= @order.order_id %>';
<% end %>
var ajax_url = "/origami/" + order_id + "/request_bills";
localStorage.setItem("tax_type", "all");
if(order_id!=undefined && order_id!=null && order_id!=""){
if($('#request_bill').is(":visible")) {
$('#request_bill').prop("disabled",true);
}
$.ajax({
type: "GET",
url: ajax_url,
success: function (result) {
if (!result.status) {
$('#request_bill').prop("disabled",false);
swal("Information!", result.error_message);
}
else {
location.reload();
}
}
});
}else{
swal("Opps","There is no orders!","warning");
}
});
});
</script>

View File

@@ -41,10 +41,22 @@
<th><%= t :cashier %></th>
<th><%= t("views.right_panel.detail.sales_status") %></th>
<th><%= t("views.right_panel.detail.receipt_generated_at") %></th>
<% if @sale["sale_status"] == "completed" %>
<% if @sale.sale_status == "completed" %>
<th>
<button type="button" class="btn btn-block bg-red waves-effect" data-toggle="modal" data-target="#voidModal" <%= (can? :overall_void, :void)? ' ': 'disabled=' %> > Void</button>
</th>
<% else %>
<% if current_login_employee.role == "administrator" %>
<%if @membership.discount && @sale.customer.membership_id %>
<th>
<button type="button" class="btn btn-block bg-blue waves-effect" data-toggle="modal" data-target="#paymentModal">Pay</button>
</th>
<%else%>
<th>
<button type="button" id="pay" class="btn btn-block bg-blue waves-effect">Pay</button>
</th>
<%end%>
<%end%>
<% end %>
</tr>
</thead>
@@ -266,7 +278,107 @@
</div>
</div>
<input type="hidden" id="server_mode" value="<%= ENV["SERVER_MODE"] %>">
<span class="hidden" id="member_discount"><%= @membership.discount%></span>
<span class="hidden" id="membership_id"><%= @sale.customer.membership_id rescue 0%></span>
<div class="modal fade" id="paymentModal" tabindex="-1" role="dialog">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title" id="paymentModalLabel">Choose Payment Method</h4>
</div>
<div class="modal-body">
<!-- <select class="form-control show-tick payment_method" multiple="true" id="payment_method" > -->
<!-- <option value="Cash">Cash</option> -->
<div class="row text-center">
<div class="col-xs-4 col-sm-4 col-md-4 col-lg-4">
<button class='btn btn-md waves-effect payment-btn-box payment_btn bg-green' data-type='Credit' data-value='Credit'>Credit</button>
</div>
<% @payment_methods.each_with_index do |pay, pay_index| %>
<%if (pay_index+1)%3 == 0 %>
<div class="row clearfix"></div>
<% end %>
<div class="col-xs-4 col-sm-4 col-md-4 col-lg-4">
<button class='btn btn-md payment-btn-box waves-effect payment_btn bg-green' data-type='<%= pay.payment_method %>' data-value='<%= pay.payment_method %>'><%= pay.payment_method %></button>
</div>
<%end %>
</div>
<!-- </select> -->
</div>
<div class="modal-footer p-r-30 pb-3">
<button type="button" class="btn btn-md btn-link btn-danger waves-effect" data-dismiss="modal">CLOSE</button>
&nbsp; &nbsp;
<button type="button" class="btn btn-md btn-link bg-blue waves-effect choose_payment">SAVE</button>
</div>
</div>
</div>
</div>
<script type="text/javascript">
// Get Selected Class
function get_selected_attributes(selected_class) {
var item_row = $('.'+selected_class);
var attribute_arr = [];
$(item_row).each(function(i){
value = $(item_row[i]).attr('data-value');
str = value;
attribute_arr.push(str);
});
return attribute_arr;
}
function calculate_member_discount(sale_id,type,tax_type) {
var sub_total = $('#sub-total').text();
if (type == "Cash") {
is_card = false
}else{
is_card = true
}
$.ajax({
type: "POST",
url: "/origami/" + sale_id + "/member_discount",
data: {'sale_id':sale_id, 'sub_total':sub_total,'is_card':is_card,'cashier_type':'cashier','tax_type':tax_type },
async: false,
success:function(result){ }
});
}
function createReceiptNoInFirstBillData(receipt_no,payment) {
var arr_data = [];
var json_data = [];
if(localStorage.hasOwnProperty("receipt_lists") === true){
arr_data = JSON.parse(localStorage.getItem("receipt_lists"));
json_data = arr_data.filter(function(e) { return e.receipt_no == receipt_no });
if (payment) {
jdata = arr_data.filter(function(e) { return e.receipt_no !== receipt_no });
jdata.push({'receipt_no':receipt_no,'payment':payment});
localStorage.setItem("receipt_lists",JSON.stringify(jdata));
}
}
if(((arr_data.length == 0) && (json_data.length == 0)) || ((arr_data.length > 0) && (json_data.length == 0))){
arr_data.push({'receipt_no':receipt_no,'payment':payment});
localStorage.setItem("receipt_lists",JSON.stringify(arr_data));
}
}
// click select option icon for add
$('.payment_btn').on('click', function(event){
active = $(this).hasClass('selected-payment');
value = $(this).data('value');
type = $(this).data('type');
group = $(this).data('group');
payments = $(".payment_btn");
if (active) {
$(this).removeClass('selected-payment');
}else{
$(this).addClass('selected-payment');
}
}); //End selecct attribute buttom
$('#void').on('click', function () {
var access_code = localStorage.getItem("access_code");
if ($(this).attr('active')=== "true") {
@@ -280,7 +392,7 @@
closeOnConfirm: false
}, function (isConfirm) {
if (isConfirm) {
var sale_id = "<%= @sale.sale_id %>"
var sale_id = "<%= @sale.sale_id %>";
// console.log(sale_id)
var ajax_url = "/transactions/sales/" + sale_id + '/cashier/void';
var remark = $("#remark").val();
@@ -291,10 +403,10 @@
data: "remark="+ remark + "&sale_id=" + sale_id+ "&access_code=" + access_code,
success: function (result) {
// For Server Print - from jade
if ($("#server_mode").val() == "cloud") {
code2lab.printFile(result.filepath.substr(6), result.printer_url);
}
window.location.href = '/transactions/sales/';
if ($("#server_mode").val() == "cloud") {
code2lab.printFile(result.filepath.substr(6), result.printer_url);
}
window.location.href = '/transactions/sales/';
}
});
}
@@ -303,5 +415,38 @@
swal("Opps","You are not authorized for void","warning")
}
});
$(".choose_payment").on('click', function () {
$("#loading_wrapper").show();
var sale_id = "<%= @sale.sale_id %>";
var type = get_selected_attributes('selected-payment');
var tax_type = localStorage.getItem("tax_type") ? localStorage.getItem("tax_type") : 'all';
// console.log(type);
if(parseInt(jQuery.inArray("Credit", type)) == -1){
if (parseInt(jQuery.inArray("MPU", type)) != -1 || parseInt(jQuery.inArray("VISA", type)) != -1 || parseInt(jQuery.inArray("JCB", type)) != -1 || parseInt(jQuery.inArray("Master", type)) != -1 || parseInt(jQuery.inArray("UNIONPAY", type)) != -1 || parseInt(jQuery.inArray("Redeem", type)) != -1 || parseInt(jQuery.inArray("PAYMAL",type))!= -1) {
if(!location.pathname.includes("credit_payment")){
calculate_member_discount(sale_id,"Card",tax_type);
}
}else{
if(!location.pathname.includes("credit_payment")){
calculate_member_discount(sale_id,"Cash",tax_type);
}
}
}
$( "#loading_wrapper" ).hide();
receipt_no = "<%= @sale.receipt_no %>";
if((receipt_no!=undefined) && (receipt_no!=""))
createReceiptNoInFirstBillData(receipt_no,type);
window.location = '/origami/sale/'+sale_id+'/transaction/payment';
});
$('#pay').on('click', function() {
var sale_id = "<%= @sale.sale_id %>";
window.location = '/origami/sale/'+sale_id+'/transaction/payment';
});
</script>