check print copy greater than 0 in print_settings

This commit is contained in:
phyusin
2017-11-27 19:33:18 +06:30
7 changed files with 67 additions and 29 deletions

View File

@@ -8,7 +8,7 @@ class Origami::CreditPaymentsController < BaseOrigamiController
@creditcount = 0 @creditcount = 0
others = 0 others = 0
sale_data.sale_payments.each do |sale_payment| sale_data.sale_payments.each do |sale_payment|
if sale_payment.payment_method == "visa" if sale_payment.payment_method == "creditnote"
@creditcount = @creditcount + sale_payment.payment_amount @creditcount = @creditcount + sale_payment.payment_amount
else else
others = others + sale_payment.payment_amount others = others + sale_payment.payment_amount

View File

@@ -67,7 +67,11 @@ class Settings::MenuItemInstancesController < ApplicationController
respond_to do |format| respond_to do |format|
if @settings_menu_item_instances.save if @settings_menu_item_instances.save
<<<<<<< HEAD
@settings_menu_item_instances.item_attributes = params[:menu_item_instance][:item_attributes].split("") @settings_menu_item_instances.item_attributes = params[:menu_item_instance][:item_attributes].split("")
=======
@settings_menu_item_instances.item_attributes = params[:menu_item_instance][:item_attributes].split(" ")
>>>>>>> 7a28dc1ddc100e61789fae7f1f3503e2f703711e
@settings_menu_item_instances.save @settings_menu_item_instances.save
format.html { redirect_to settings_menu_category_simple_menu_item_path(category,catID), notice: 'Menu item instance was successfully created.' } format.html { redirect_to settings_menu_category_simple_menu_item_path(category,catID), notice: 'Menu item instance was successfully created.' }
format.json { render :show, status: :created, location: @settings_menu_item_instances } format.json { render :show, status: :created, location: @settings_menu_item_instances }

View File

@@ -1,4 +1,4 @@
class PrintSetting < ApplicationRecord class PrintSetting < ApplicationRecord
# validations # validations
validates_presence_of :name, :unique_code, :printer_name, :page_width, :page_height validates_presence_of :name, :unique_code, :printer_name, :page_width, :page_height, :print_copies
end end

View File

@@ -40,13 +40,13 @@
<!-- </div> --> <!-- </div> -->
<% end %> <% end %>
<!-- <div class="row"> --> <!-- <div class="row"> -->
<div class="row"> <!-- <div class="row">
<div class="col-lg-5 col-md-5 col-sm-5"> <div class="col-lg-5 col-md-5 col-sm-5">
<label >Recent Credit Amount</label> <label >Recent Credit Amount</label>
</div> </div>
<div class="col-lg-6 col-md-6 col-sm-6"> <div class="col-lg-6 col-md-6 col-sm-6">
<input type="text" name="valid_amount" id="valid_amount" class="form-control" value="" data-value="<%=@sale_id %>" data-member-value=""> <input type="text" name="valid_amount" id="valid_amount" class="form-control" value="" data-value="<%=@sale_id %>" data-member-value="">
</div> </div> -->
</div> </div>
<hr> <hr>
<!-- </div> --> <!-- </div> -->

View File

@@ -374,14 +374,14 @@
<% end %> <% end %>
<% if @status_sale == 'sale' %> <% if @status_sale == 'sale' %>
<button type="button" id="customer" class="btn btn-block bg-blue waves-effect">Customer</button> <button type="button" id="customer" class="btn btn-block bg-blue waves-effect">Customer</button>
<button type="button" class="btn btn-block bg-blue waves-effect" id='edit'>Edit</button> <button type="button" class="btn btn-block bg-blue waves-effect" id='edit' active="<%= can? :edit, :sale_edit %>">Edit</button>
<button type="button" id="discount" class="btn btn-block bg-blue waves-effect">Discount</button> <button type="button" id="discount" class="btn btn-block bg-blue waves-effect">Discount</button>
<button type="button" id="other-charges" class="btn btn-block bg-blue waves-effect">Charges</button> <button type="button" id="other-charges" class="btn btn-block bg-blue waves-effect">Charges</button>
<button type="button" id="commissions" class="btn btn-block bg-blue waves-effect">Commissions</button> <button type="button" id="commissions" class="btn btn-block bg-blue waves-effect">Commissions</button>
<button type="button" id="in_duties" class="btn btn-block bg-blue waves-effect">In Duties</button> <button type="button" id="in_duties" class="btn btn-block bg-blue waves-effect">In Duties</button>
<button type="button" id="first_bill" class="btn btn-block bg-blue waves-effect">First Bill</button> <button type="button" id="first_bill" class="btn btn-block bg-blue waves-effect">First Bill</button>
<button type="button" id="pay" class="btn btn-block bg-blue waves-effect">Pay</button> <button type="button" id="pay" class="btn btn-block bg-blue waves-effect">Pay</button>
<button type="button" id="void" class="btn btn-block bg-blue waves-effect"> Void</button> <button type="button" id="void" class="btn btn-block bg-blue waves-effect" active="<%= can? :overall_void, :void %>"> Void</button>
<% end %> <% end %>
<!-- Cashier Buttons --> <!-- Cashier Buttons -->
@@ -617,7 +617,12 @@
$('#edit').on('click', function () { $('#edit').on('click', function () {
var dining_id = "<%= @dining.id %>" var dining_id = "<%= @dining.id %>"
var sale_id = "<%= @obj_sale.sale_id rescue "" %>" var sale_id = "<%= @obj_sale.sale_id rescue "" %>"
window.location.href = '/origami/table/' + dining_id + "/sale/" + sale_id + "/edit"; if ($(this).attr('active')=== "true") {
window.location.href = '/origami/table/' + dining_id + "/sale/" + sale_id + "/edit";
}else{
swal("Opps","You are not authorized for void","warning")
}
}); });
$('#commissions').on('click', function () { $('#commissions').on('click', function () {
@@ -632,6 +637,7 @@
}); });
$('#void').on('click', function () { $('#void').on('click', function () {
if ($(this).attr('active')=== "true") {
swal({ swal({
title: "Alert", title: "Alert",
text: "Are you sure want to Void?", text: "Are you sure want to Void?",
@@ -652,7 +658,10 @@
} }
}); });
} }
}); });
}else{
swal("Opps","You are not authorized for void","warning")
}
}); });
$('#add_order').on('click', function () { $('#add_order').on('click', function () {

View File

@@ -276,8 +276,8 @@
<i class="material-icons">reply</i> <i class="material-icons">reply</i>
Back Back
</button> </button>
<button type="button" class="btn bg-deep-purple btn-block" id="foc"> FOC </button> <button type="button" class="btn bg-deep-purple btn-block" id="foc" active="<%= can? :foc, :payment %>"> FOC </button>
<button type="button" class="btn bg-red btn-block" id="void"> Void </button> <button type="button" class="btn bg-red btn-block" id="void" active="<%= can? :overall_void, :void %>"> Void </button>
<!-- Waiter Buttons --> <!-- Waiter Buttons -->
</div> </div>
@@ -431,20 +431,25 @@
}); });
$('#void').on('click',function () { $('#void').on('click',function () {
swal({ if ($(this).attr('active') === "true") {
title: "Information!", swal({
text: 'Are you sure want to Void !', title: "Information!",
}, function () { text: 'Are you sure want to Void !',
var sale_id = $('#sale_id').text(); }, function () {
var ajax_url = "/origami/sale/" + sale_id + '/void'; var sale_id = $('#sale_id').text();
$.ajax({ var ajax_url = "/origami/sale/" + sale_id + '/void';
type: 'POST', $.ajax({
url: ajax_url, type: 'POST',
success: function () { url: ajax_url,
window.location.href = '/origami/'; success: function () {
} window.location.href = '/origami/';
}) }
}); })
});
}else{
swal("Opps","You are not authorized for void","warning")
}
}); });
}); });
@@ -463,19 +468,21 @@
} }
$('#foc').click(function() { $('#foc').click(function() {
$( "#loading_wrapper" ).show(); //$( "#loading_wrapper" ).show();
// payment // payment
var cash = $('#amount_due').text(); var cash = $('#amount_due').text();
var sub_total = $('#sub-total').text(); var sub_total = $('#sub-total').text();
var sale_id = $('#sale_id').text(); var sale_id = $('#sale_id').text();
var params = { 'cash':cash,'sale_id':sale_id,'sub_total':sub_total }; var params = { 'cash':cash,'sale_id':sale_id,'sub_total':sub_total };
$.ajax({type: "POST", if ($(this).attr('active')=== "true") {
$.ajax({
type: "POST",
url: "<%= origami_payment_foc_path %>", url: "<%= origami_payment_foc_path %>",
data: params, data: params,
success:function(result){ success:function(result){
$( "#loading_wrapper" ).hide(); //$( "#loading_wrapper" ).hide();
if (cash > 0) { if (cash > 0) {
swal({ swal({
@@ -488,6 +495,9 @@
} }
}); });
}else{
swal("Opps","You are not authorized for foc","warning")
}
}); });
function calculate_member_discount(sale_id) { function calculate_member_discount(sale_id) {

View File

@@ -15,7 +15,7 @@
<%= f.input :api_settings %> <%= f.input :api_settings %>
<%= f.input :page_width %> <%= f.input :page_width %>
<%= f.input :page_height %> <%= f.input :page_height %>
<%= f.input :print_copies %> <%= f.input :print_copies, input_html: { min: '1', step: '1', :onkeypress => "return isNumberKey(event);", :onkeyup => "greaterThanOne(this.value);" } %>
<%= f.input :precision %> <%= f.input :precision %>
<%= f.input :delimiter %> <%= f.input :delimiter %>
<%= f.input :heading_space %> <%= f.input :heading_space %>
@@ -58,4 +58,19 @@
</div> </div>
</div> </div>
</div> </div>
</div> </div>
<script type="text/javascript">
function isNumberKey(evt) {
var charCode = (evt.which) ? evt.which : event.keyCode;
if (charCode != 46 && charCode > 31 && (charCode < 48 || charCode > 57)) {
return false;
} else {
return true;
}
}
function greaterThanOne(val){
if(parseInt(val)==0) $("#print_setting_print_copies").val(1);
}
</script>