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

This commit is contained in:
Moe Su
2017-06-13 10:46:06 +06:30
18 changed files with 198 additions and 190 deletions

View File

@@ -17,11 +17,7 @@
//= require turbolinks
//= require cable
//= require settings/processing_items
//= require bootstrap-datepicker/core
//= require bootstrap-datepicker/locales/bootstrap-datepicker.es
//= require bootstrap-datepicker
$(document).on("focus", "[data-behaviour~='datepicker']", function(e){
$(this).datepicker({"format": "yyyy-M-dd", "weekStart": 1, "autoclose": true});
$('.dropdown-toggle').dropdown();
});

View File

@@ -0,0 +1,4 @@
$(document).on("focus", "[data-behaviour~='datepicker']", function(e){
$(this).datepicker({"format": "yyyy-M-dd", "weekStart": 1, "autoclose": true});
$('.dropdown-toggle').dropdown();
});

View File

View File

@@ -2,7 +2,7 @@
@import "bootstrap";
@import "font-awesome";
@import "theme";
@import 'bootstrap-datepicker';
@import "bootstrap-datepicker";
/* Show it is fixed to the top */
// body {

View File

@@ -1,8 +1,77 @@
class BaseReportController < ActionController::Base
include LoginVerification
include LoginVerification
layout "application"
#before_action :check_installation
protect_from_forgery with: :exception
#before_action :check_installation
protect_from_forgery with: :exception
PERIOD = {
"today" => 0,
"yesterday" => 1,
"this_week" => 2,
"last_week" => 3,
"last_7" => 4,
"this_month" => 5,
"last_month" => 6,
"last_30" => 7,
"this_year" => 8,
"last_year" => 9
}
def get_date_range_from_params
period_type = params[:period_type]
period = params[:period]
from = params[:from]
to = params[:to]
day_ref = Time.now
if period_type.to_i == 1
if params[:from] && params[:to]
if params[:from] != "" && params[:to] !=""
from = DateTime.strptime(params[:from], "%m/%d/%Y")
to = DateTime.strptime(params[:to], "%m/%d/%Y")
else
from = day_ref.beginning_of_day.utc
to = day_ref.end_of_day.utc
end
end
else
case period.to_i
when PERIOD["today"]
from = day_ref.beginning_of_day.utc
to = day_ref.end_of_day.utc
when PERIOD["yesterday"]
from = (day_ref - 1.day).beginning_of_day.utc
to = (day_ref - 1.day).end_of_day.utc
when PERIOD["this_week"]
from = Time.now.beginning_of_week.utc
to = Time.now.utc
when PERIOD["last_week"]
from = (day_ref - 7.day).beginning_of_week.utc
to = (day_ref - 7.day).end_of_week.utc
when PERIOD["last_7"]
from = (day_ref - 7.day).utc
to = Time.now.utc
when PERIOD["this_month"]
from = Time.now.beginning_of_month.utc
to = Time.now.utc
when PERIOD["last_month"]
from = (day_ref - 1.month).beginning_of_month.utc
to = (day_ref - 1.month).end_of_month.utc
when PERIOD["last_30"]
from = (day_ref - 30.day).utc
to = Time.now.utc
when PERIOD["this_year"]
from = Time.now.beginning_of_year.utc
to = Time.now.utc
when PERIOD["last_year"]
from = (day_ref - 1.year).beginning_of_year.utc
to = (day_ref - 1.year).end_of_year.utc
end
end
return from, to
end
end

View File

@@ -10,13 +10,13 @@ class Crm::CustomersController < BaseCrmController
@crm_customers = Customer.order("customer_id").page(params[:page])
#@products = Product.order("name").page(params[:page]).per(5)
else
@crm_customers = Customer.where("name LIKE ?", "%#{filter}%").order("name").page(params[:page])
end
@crm_customers = Customer.where("name LIKE ?", "%#{filter}%").order("name").page(params[:page]) end
#@crm_customers = Customer.all
@crm_customer = Customer.new
if @crm_customer.valid?
@crm_customer.errors.messages
end
# puts @crm_customer.valid?
# @membership = Customer.get_member_group
# if @membership["status"] == true
# @member_group = @membership["data"]
@@ -57,8 +57,8 @@ class Crm::CustomersController < BaseCrmController
def create
@crm_customers = Customer.new(customer_params)
respond_to do |format|
puts @crm_customers.errors.to_json
if @crm_customers.save
name = customer_params[:name]
phone = customer_params[:contact_no]
@@ -107,6 +107,7 @@ class Crm::CustomersController < BaseCrmController
if params[:sale_id]
format.html { redirect_to '/origami/'+params[:sale_id]+'/add_customer'}
else
format.html { redirect_to crm_customers_path}
format.json { render json: @crm_customers.errors, status: :unprocessable_entity }
end

View File

@@ -20,6 +20,31 @@ class Origami::PaymentsController < BaseOrigamiController
@cash = 0.0
@other = 0.0
@sale_data = Sale.find_by_sale_id(sale_id)
#get customer amount
@customer = Customer.find(@sale_data.customer_id)
membership = MembershipSetting.find_by_membership_type("paypar_url")
memberaction = MembershipAction.find_by_membership_type("get_all_member_account")
merchant_uid = memberaction.merchant_account_id.to_s
url = membership.gateway_url.to_s + memberaction.gateway_url.to_s
response = HTTParty.get(url, :body => { membership_id: @customer.membership_id,merchant_uid:merchant_uid}.to_json,
:headers => {
'Content-Type' => 'application/json',
'Accept' => 'application/json'
}
)
@balance = 0.00
response["data"].each do |res|
if res["accountable_type"] == "RebateAccount"
@balance = res["balance"]
end
end
#end customer amount
@sale_data.sale_payments.each do |spay|
if spay.payment_method == "cash"
@cash = spay.payment_amount

View File

@@ -0,0 +1,21 @@
class Reports::DailySaleController < BaseReportController
PERIOD = {
"today" => 0,
"yesterday" => 1,
"this_week" => 2,
"last_week" => 3,
"last_7" => 4,
"this_month" => 5,
"last_month" => 6,
"last_30" => 7,
"this_year" => 8,
"last_year" => 9
}
def index
from, to = get_date_range_from_params
@sale_data = Sale.get_receipt_no_list(from,to)
@sale_data = Kaminari.paginate_array(@sale_data).page(params[:page]).per(50)
end
end

View File

@@ -1,17 +1,4 @@
class Reports::ReceiptNoController < ApplicationController
PERIOD = {
"today" => 0,
"yesterday" => 1,
"this_week" => 2,
"last_week" => 3,
"last_7" => 4,
"this_month" => 5,
"last_month" => 6,
"last_30" => 7,
"this_year" => 8,
"last_year" => 9
}
class Reports::ReceiptNoController < BaseReportController
def index
from, to = get_date_range_from_params
puts "from..."
@@ -25,61 +12,4 @@ class Reports::ReceiptNoController < ApplicationController
def show
end
private
def get_date_range_from_params
period_type = params[:period_type]
period = params[:period]
from = params[:from]
to = params[:to]
day_ref = Time.now
if period_type.to_i == 1
if params[:from] && params[:to]
if params[:from] != "" && params[:to] !=""
from = DateTime.strptime(params[:from], "%m/%d/%Y")
to = DateTime.strptime(params[:to], "%m/%d/%Y")
else
from = day_ref.beginning_of_day.utc
to = day_ref.end_of_day.utc
end
end
else
case period.to_i
when PERIOD["today"]
from = day_ref.beginning_of_day.utc
to = day_ref.end_of_day.utc
when PERIOD["yesterday"]
from = (day_ref - 1.day).beginning_of_day.utc
to = (day_ref - 1.day).end_of_day.utc
when PERIOD["this_week"]
from = Time.now.beginning_of_week.utc
to = Time.now.utc
when PERIOD["last_week"]
from = (day_ref - 7.day).beginning_of_week.utc
to = (day_ref - 7.day).end_of_week.utc
when PERIOD["last_7"]
from = (day_ref - 7.day).utc
to = Time.now.utc
when PERIOD["this_month"]
from = Time.now.beginning_of_month.utc
to = Time.now.utc
when PERIOD["last_month"]
from = (day_ref - 1.month).beginning_of_month.utc
to = (day_ref - 1.month).end_of_month.utc
when PERIOD["last_30"]
from = (day_ref - 30.day).utc
to = Time.now.utc
when PERIOD["this_year"]
from = Time.now.beginning_of_year.utc
to = Time.now.utc
when PERIOD["last_year"]
from = (day_ref - 1.year).beginning_of_year.utc
to = (day_ref - 1.year).end_of_year.utc
end
end
return from, to
end
end

View File

@@ -66,37 +66,32 @@
</div>
</div>
<div class="col-lg-4">
<%= simple_form_for @crm_customer,:url => crm_customers_path, :method => :post do |f| %>
<span class="patch_method"></span>
<%= f.error_notification %>
<%= f.hidden_field :id, :class => "form-control col-md-6 " %>
<div class="form-group">
<%= f.input :name, :class => "form-control col-md-6 name" %>
</div>
<div class="form-group">
<%= f.input :company, :class => "form-control col-md-6 company" %>
</div>
<div class="form-group">
<%= f.input :contact_no, :class => "form-control col-md-6 contact_no" %>
</div>
<div class="form-group">
<%= f.input :email, :class => "form-control col-md-6 email" %>
<%= f.input :email, :class => "form-control col-md-6 email" %>
</div>
<div class="form-group">
<label>Date Of Birth</label>
<%= f.text_field :date_of_birth,:class => "form-control datepicker date_of_birth "%>
<%= f.input :date_of_birth,:class=>"form-control date_of_birth"%>
</div>
<div class="form-group">
<div class="form-group">
<label>Select Member Group</label>
<select class="selectpicker form-control col-md-12" name="member_group_id">
<option>Select Member Group</option>
<% Lookup.where("lookup_type = ?", "member_group_type" ).each do |member| %>
@@ -104,7 +99,7 @@
<%= member.name %></option>
<%end %>
</select>
</div>
</div>
<div class="form-group">
@@ -115,21 +110,8 @@
</div>
</div>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/jquery-confirm/3.2.0/jquery-confirm.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-confirm/3.2.0/jquery-confirm.min.js"></script>
<script type="text/javascript">
$(function () {
if (jQuery().datepicker) {
$('.datepicker').datepicker({
format : 'dd-mm-yyyy',
autoclose: true
});
$('.datepicker').attr('ReadOnly','true');
$('.datepicker').css('cursor','pointer');
}
});
$(document).on('click',".checkbox_check",function(){
if(this.checked){
@@ -137,13 +119,13 @@
var sale_id = $("#sale_id").val() || 0;
var customer_id = $(this).val();
if(sale_id != 0){
// var url = "/"+customer_id;
update_sale(customer_id,sale_id);
}else{
// if(sale_id != 0){
// // var url = "/"+customer_id;
// update_sale(customer_id,sale_id);
// }else{
var url = "customers/"+customer_id;
}
// var url = "customers/"+customer_id;
// }
$.ajax({
type: "GET",
@@ -179,43 +161,43 @@
}
})
function update_sale(customer_id,sale_id) {
$.confirm({
title: 'Confirm!',
content: 'Are You Sure to assign this customer!',
buttons: {
// function update_sale(customer_id,sale_id) {
// $.confirm({
// title: 'Confirm!',
// content: 'Are You Sure to assign this customer!',
// buttons: {
cancel: function () {
// cancel: function () {
},
confirm: {
text: 'Confirm',
btnClass: 'btn-green',
keys: ['enter', 'shift'],
action: function(){
$.ajax({
type: "POST",
url: "update_sale/" ,
data: {customer_id:customer_id,sale_id:sale_id},
dataType: "json",
success: function(data) {
if(data.status == true)
{
alert('Customer has assigned');
window.location.href = '/origami'
}else{
alert('Record not found!');
location.reload();
}
// },
// confirm: {
// text: 'Confirm',
// btnClass: 'btn-green',
// keys: ['enter', 'shift'],
// action: function(){
// $.ajax({
// type: "POST",
// url: "update_sale/" ,
// data: {customer_id:customer_id,sale_id:sale_id},
// dataType: "json",
// success: function(data) {
// if(data.status == true)
// {
// alert('Customer has assigned');
// window.location.href = '/origami'
// }else{
// alert('Record not found!');
// location.reload();
// }
}
});
}
}
// }
// });
// }
// }
}
});
}
// }
// });
// }
</script>

View File

@@ -38,6 +38,7 @@
<th>Company</th>
<th>Contact no</th>
<th>Email</th>
<th>Date of Birth</th>
</tr>
</thead>
@@ -47,11 +48,11 @@
<td>
<input type="radio" style="width:20px;" value="<%= crm_customer.customer_id %>" name="checkbox" class="checkbox_check" ></td>
<td><%= crm_customer.name %></td>
<td><%= crm_customer.company %></td>
<td><%= crm_customer.company rescue '-' %></td>
<td><%= crm_customer.contact_no %></td>
<td><%= crm_customer.email %></td>
<td>
<%= link_to 'Destroy', crm_customer_path(crm_customer), method: :delete, data: { confirm: 'Are you sure?' } %>
<%= crm_customer.date_of_birth rescue '-' %>
</td>
@@ -84,8 +85,6 @@
</div>
<div class="form-group">
<%= f.input :contact_no, :class => "form-control col-md-6 contact_no" %>
</div>
<div class="form-group">
@@ -93,11 +92,11 @@
</div>
<div class="form-group">
<label>Date Of Birth</label>
<%= f.text_field :date_of_birth,:class=>"form-control date_of_birth datepicker"%>
<%= f.input :date_of_birth,:class=>"form-control date_of_birth"%>
</div>
<div class="form-group">
<label>Select Member Group</label>
<select class="selectpicker form-control col-md-12" name="member_group_id">
<option>Select Member Group</option>
<% Lookup.where("lookup_type = ?", "member_group_type" ).each do |member| %>
@@ -105,21 +104,11 @@
<%= member.name %></option>
<%end %>
</select>
</div>
<!-- <div class="form-group">
<%= f.input :membership_type, :class => "form-control col-md-6 membership_type" %>
</div>
<div class="form-group">
<%= f.input :membership_authentication_code, :class => "form-control col-md-6 membership_authentication_code" %>
</div> -->
<div class="form-group">
<%= f.button :submit, "Submit",:class => 'btn btn-primary ', :id => 'submit_customer' %>
<%= f.button :submit, "Update",:class => 'btn btn-primary ', :disabled =>'', :id => 'update_customer' %>
<!-- <%= f.button :submit, "Update",:class => 'btn btn-primary ', :disabled =>'', :id => 'update_customer' %> -->
</div>
<%end%>
</div>
@@ -128,17 +117,6 @@
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/jquery-confirm/3.2.0/jquery-confirm.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-confirm/3.2.0/jquery-confirm.min.js"></script>
<script type="text/javascript">
$(function () {
if (jQuery().datepicker) {
$('.datepicker').datepicker({
format : 'dd-mm-yyyy',
autoclose: true
});
$('.datepicker').attr('ReadOnly','true');
$('.datepicker').css('cursor','pointer');
}
});
$(document).on('click',".checkbox_check",function(){
if(this.checked){

View File

@@ -316,7 +316,7 @@
sub_total = 0
if @selected_item_type == "Sale"
@selected_item.sale_items.each do |sale_item|
sub_total += sale_item.qty*sale_item.unit_price
sub_total += (sale_item.qty*sale_item.unit_price)
%>
<tr>
<td class='item-name'><%= sale_item.product_name %></td>
@@ -351,7 +351,7 @@
<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>
<td class="item-attr"><strong id="order-sub-total"><%= sub_total %></strong></td>
</tr>
<!-- <tr>
<td class="charges-name"><strong>Food:</strong></td>

View File

@@ -14,8 +14,8 @@
<td><strong>Sale Id</strong> </span><span id="sale_id"><% if @sale_data %><%=@sale_data.sale_id %><% end %></td>
</tr>
<tr>
<td><strong>Customer :</strong> Default Customer</td>
<td><strong>Points :</strong> 1234 </td>
<td><strong>Customer :</strong> <%= @sale_data.customer.name%></td>
<td><strong>Points :</strong> <%= @balance %> </td>
</tr>
</table>
</div>

View File

@@ -1,5 +1,6 @@
<%= form_tag report_path, :method => :get, :id=>"frm_report" do %>
<div class="row">
<div class="col-md-12"></div>
<div class="span3">
<% if defined? product_account %>
<%= select_tag "account", options_from_collection_for_select(@accounts,"id","title", :selected => params[:account])%>

View File

@@ -8,6 +8,7 @@
</span>
</ul>
</div>
<div class="card">
<table class="table table-striped">
<thead>