change UI and query for dashboard and UI for Origami/Commissions

This commit is contained in:
phyusin
2017-11-23 11:56:49 +06:30
parent 86ec4c7c80
commit b64229aded
7 changed files with 120 additions and 101 deletions

View File

@@ -82,6 +82,7 @@ class HomeController < ApplicationController
@sale_data = Array.new @sale_data = Array.new
@total_payment_methods = Sale.total_payment_methods(today) @total_payment_methods = Sale.total_payment_methods(today)
@total_payment_methods.each do |payment| @total_payment_methods.each do |payment|
if payment.payment_method == "mpu" || payment.payment_method == "visa" || payment.payment_method == "master" || payment.payment_method == "jcb" if payment.payment_method == "mpu" || payment.payment_method == "visa" || payment.payment_method == "master" || payment.payment_method == "jcb"
pay = Sale.payment_sale('card', today) pay = Sale.payment_sale('card', today)
@@ -92,7 +93,6 @@ class HomeController < ApplicationController
end end
end end
@summ_sale = Sale.summary_sale_receipt(today) @summ_sale = Sale.summary_sale_receipt(today)
p @summ_sale
@total_customer = Sale.total_customer(today) @total_customer = Sale.total_customer(today)
@total_dinein = Sale.total_dinein(today) @total_dinein = Sale.total_dinein(today)
@total_takeaway = Sale.total_takeaway(today) @total_takeaway = Sale.total_takeaway(today)

View File

@@ -988,7 +988,7 @@ end
end end
def self.total_payment_methods(today) def self.total_payment_methods(today)
query = Sale.select("sp.payment_method") query = Sale.select("distinct sp.payment_method")
.where('sales.sale_status = "completed" and DATE_FORMAT(sales.receipt_date,"%Y-%m-%d") = ?',today) .where('sales.sale_status = "completed" and DATE_FORMAT(sales.receipt_date,"%Y-%m-%d") = ?',today)
.joins("JOIN sale_payments as sp ON sp.sale_id = sales.sale_id") .joins("JOIN sale_payments as sp ON sp.sale_id = sales.sale_id")
end end
@@ -996,7 +996,7 @@ end
def self.payment_sale(payment_method, today) def self.payment_sale(payment_method, today)
query = Sale.joins("JOIN sale_payments as sp ON sp.sale_id = sales.sale_id") query = Sale.joins("JOIN sale_payments as sp ON sp.sale_id = sales.sale_id")
if payment_method == 'card' if payment_method == 'card'
query = query.where('sales.sale_status = "completed" and DATE_FORMAT(sales.receipt_date,"%Y-%m-%d") = ? and sp.payment_method = "mpu" or sp.payment_method = "visa" or sp.payment_method = "master" or sp.payment_method = "jcb"',today) query = query.where('sales.sale_status = "completed" and DATE_FORMAT(sales.receipt_date,"%Y-%m-%d") = ? and (sp.payment_method = "mpu" or sp.payment_method = "visa" or sp.payment_method = "master" or sp.payment_method = "jcb")',today)
else else
query = query.where("sales.sale_status = 'completed' and sp.payment_method = '#{payment_method}' and DATE_FORMAT(sales.receipt_date,'%Y-%m-%d') = ?",today) query = query.where("sales.sale_status = 'completed' and sp.payment_method = '#{payment_method}' and DATE_FORMAT(sales.receipt_date,'%Y-%m-%d') = ?",today)
end end

View File

@@ -147,7 +147,11 @@
<% if payment.payment_method == 'mpu' || payment.payment_method == 'visa' || payment.payment_method == 'master' || payment.payment_method == 'jcb' %> <% if payment.payment_method == 'mpu' || payment.payment_method == 'visa' || payment.payment_method == 'master' || payment.payment_method == 'jcb' %>
<tr> <tr>
<td>Card Sale : </td> <td>Card Sale : </td>
<td align="right"><%= @sale_data[0]['card'] %></td> <td align="right">
<% @sale_data.each do |data| %>
<%= data["card"] %>
<% end %>
</td>
</tr> </tr>
<% else %> <% else %>
<tr> <tr>
@@ -220,16 +224,16 @@
<table class="table"> <table class="table">
<% if !@total_order.nil? %> <% if !@total_order.nil? %>
<tr> <tr>
<td>Total Order : </td> <td width="40px">Total Order : </td>
<td align="right"><%= @total_order.total_order %></td> <td align="right" width="60px" style="padding: 5px"><%= @total_order.total_order %></td>
</tr> </tr>
<% end %> <% end %>
<% if !(@total_accounts.nil?) %> <% if !(@total_accounts.nil?) %>
<% @total_accounts.each do |account| %> <% @total_accounts.each do |account| %>
<tr> <tr>
<td><%= account.title %> (Account) : </td> <td width="40px"><%= account.title %> (Account) : </td>
<td align="right"> <td align="right" width="60px" style="padding: 5px">
<% @account_data.each do |data| %> <% @account_data.each do |data| %>
<% acc = account.title %> <% acc = account.title %>
<%= data[""+acc+""] %> <% if !data[''+acc+''].nil? %> ( <%= data[''+acc+'_amount'] %> ) <% end %> <%= data[""+acc+""] %> <% if !data[''+acc+''].nil? %> ( <%= data[''+acc+'_amount'] %> ) <% end %>
@@ -240,15 +244,15 @@
<% end %> <% end %>
<% if !@top_items.nil? %> <% if !@top_items.nil? %>
<tr> <tr>
<td>Top Item : </td> <td width="40px">Top Item : </td>
<td align="right"><%= @top_items.item_name %> <td align="right" width="60px" style="padding: 5px"><%= @top_items.item_name %>
<br>( <%= @top_items.item_total_price %> )</td> <br>(<%= @top_items.item_total_price %>)</td>
</tr> </tr>
<% end %> <% end %>
<% if !@total_foc_items.nil? %> <% if !@total_foc_items.nil? %>
<tr> <tr>
<td>Total FOC Item : </td> <td width="40px">Total FOC Item : </td>
<td align="right"><%= @total_foc_items %></td> <td align="right" width="60px" style="padding: 5px"><%= @total_foc_items %></td>
</tr> </tr>
<% end %> <% end %>
</table> </table>

View File

@@ -1,24 +1,27 @@
<%= simple_form_for @in_juty, :url => origami_index_in_juty_path(@table.id), :method => :post do |f| %> <%= simple_form_for @in_juty, :url => origami_index_in_juty_path(@table.id), :method => :post do |f| %>
<span class="patch_method"></span> <div class="card">
<%= f.error_notification %> <div class="body">
<%= f.hidden_field :id, :class => "form-control col-md-6 " %> <span class="patch_method"></span>
<%= f.error_notification %>
<%= f.hidden_field :id, :class => "form-control col-md-6 " %>
<div class="form-inputs"> <div class="form-inputs">
<%= f.hidden_field :dinning_id, :value => @table.id, :class => "form-control col-md-4 " %> <%= f.hidden_field :dinning_id, :value => @table.id, :class => "form-control col-md-4 " %>
<label>Commissioner Name:</label> <label>Commissioner Name:</label>
<%= f.collection_select :commissioner_ids, Commissioner.all, :id, :name, {prompt: 'Select Commissioner'}, {class: 'form-control'} %> <%= f.collection_select :commissioner_ids, Commissioner.all, :id, :name, {prompt: 'Select Commissioner'}, {class: 'form-control'} %>
<%= f.input :in_time, :placeholder => "From Date", :class => "form-control" %> <%= f.input :in_time, :placeholder => "From Date", :class => "form-control" %>
<%= f.input :out_time, :placeholder => "To Date", :class => "form-control" %> <%= f.input :out_time, :placeholder => "To Date", :class => "form-control" %>
</div><br> </div><br>
<div class="form-group"> <div class="form-group">
<%= f.button :submit, "Create", :class => 'btn btn-primary ', :id => 'create' %> <%= f.button :submit, "Create", :class => 'btn btn-primary ', :id => 'create' %>
<%= f.button :submit, "Update", :class => 'btn btn-primary ', :disabled => '', :id => 'update' %> <%= f.button :submit, "Update", :class => 'btn btn-primary ', :disabled => '', :id => 'update' %>
<%= f.button :button, "Reset", :class => 'btn btn-danger ', :id => 'reset' %> <%= f.button :button, "Reset", :class => 'btn btn-danger ', :id => 'reset' %>
<button type="button" class="btn btn-inverse pull-right" id='back'> <button type="button" class="btn bg-default btn-block" onclick="window.location.href = "origami_index_in_duty_path(@table.id)"><i class="material-icons">reply</i> Back </button>Back</button> <button type="button" class="btn btn-inverse pull-right" id='back'> <button type="button" class="btn bg-default btn-block" onclick="window.location.href = "origami_index_in_duty_path(@table.id)"><i class="material-icons">reply</i> Back </button>Back</button>
</div>
</div> </div>
</div>
<% end %> <% end %>

View File

@@ -1,14 +1,18 @@
<%= simple_form_for([:origami, @in_duty]) do |f| %> <%= simple_form_for([:origami, @in_duty]) do |f| %>
<%= f.error_notification %> <div class="card">
<div class="body">
<%= f.error_notification %>
<div class="form-inputs">
<%= f.collection_select :commissioner_ids, Commissioner.all, :id, :name, {prompt: 'Select Commissioner'}, {class: 'form-control'} %>
<br/><br/>
<%= f.input :in_time %>
<%= f.input :out_time %>
</div>
<div class="form-inputs"> <div class="form-actions">
<%= f.collection_select :commissioner_ids, Commissioner.all, :id, :name, {prompt: 'Select Commissioner'}, {class: 'form-control'} %> <%= f.button :submit %>
<br/><br/> </div>
<%= f.input :in_time %>
<%= f.input :out_time %>
</div> </div>
</div>
<div class="form-actions">
<%= f.button :submit %>
</div>
<% end %> <% end %>

View File

@@ -1,5 +1,7 @@
<br> <br>
<%= simple_form_for @in_duty, :url => origami_index_in_duty_path, :method => :post do |f| %> <%= simple_form_for @in_duty, :url => origami_index_in_duty_path, :method => :post do |f| %>
<div class="card">
<div class="body">
<span class="patch_method"></span> <span class="patch_method"></span>
<%= f.error_notification %> <%= f.error_notification %>
<%= f.hidden_field :id, :class => "form-control col-md-6 " %> <%= f.hidden_field :id, :class => "form-control col-md-6 " %>
@@ -10,52 +12,55 @@
<br/> <br/>
<!-- <%= f.input :in_time, :placeholder => "From Date", :class => "form-control datetimepicker" %> <!-- <%= f.input :in_time, :placeholder => "From Date", :class => "form-control datetimepicker" %>
<%= f.input :out_time, :placeholder => "To Date", :class => "form-control datetimepicker" %>--> <%= f.input :out_time, :placeholder => "To Date", :class => "form-control datetimepicker" %>-->
<div class="form-group"> <div class="form-group">
<label class="font-14">* In Time</label> <label class="font-14">* In Time</label>
<div class="input-group"> <div class="input-group">
<span class="input-group-addon"> <span class="input-group-addon">
<i class="material-icons">date_range</i> <i class="material-icons">date_range</i>
</span> </span>
<% if !@in_duty.in_time.nil?%> <% if !@in_duty.in_time.nil?%>
<input type="text" name="in_duty[in_time]" value="<%= @in_duty.in_time.strftime('%A, %d-%m-%Y') %>" class="datepicker form-control col-md-12" placeholder="Start Date..."> <input type="text" name="in_duty[in_time]" value="<%= @in_duty.in_time.strftime('%A, %d-%m-%Y') %>" class="datepicker form-control col-md-12" placeholder="Start Date...">
<% else %> <% else %>
<input type="text" name="in_duty[in_time]" class="datetimepicker form-control col-md-12" placeholder="In Time..."> <input type="text" name="in_duty[in_time]" class="datetimepicker form-control col-md-12" placeholder="In Time...">
<% end %> <% end %>
</div>
</div> </div>
<div class="form-group"> </div>
<label>* Out Time</label>
<div class="input-group">
<span class="input-group-addon">
<i class="material-icons">date_range</i>
</span>
<% if !@in_duty.out_time.nil?%>
<input type="text" name="in_duty[out_time]" value="<%= @in_duty.out_time.strftime('%A, %d-%m-%Y') %>" class="datepicker form-control col-md-12" placeholder="Start Date...">
<% else %>
<input type="text" name="in_duty[out_time]" class="datetimepicker form-control col-md-12" placeholder="Out Time...">
<% end %>
</div>
</div>
</div><br>
<div class="form-group"> <div class="form-group">
<% f.button :submit, "Create", :class => 'btn bg-blue ', :id => 'create' %> <label>* Out Time</label>
<% f.button :submit, "Update", :class => 'btn bg-blue ', :disabled => '', :id => 'update' %> <div class="input-group">
<% f.button :button, "Reset", :class => 'btn bg-danger ', :id => 'reset' %> <span class="input-group-addon">
</div> <i class="material-icons">date_range</i>
<div class="form-actions"> </span>
<%= f.submit "Create In Duty", :class => 'btn bg-blue' %> <% if !@in_duty.out_time.nil?%>
<input type="text" name="in_duty[out_time]" value="<%= @in_duty.out_time.strftime('%A, %d-%m-%Y') %>" class="datepicker form-control col-md-12" placeholder="Start Date...">
<% else %>
<input type="text" name="in_duty[out_time]" class="datetimepicker form-control col-md-12" placeholder="Out Time...">
<% end %>
</div>
</div> </div>
</div><br>
<div class="form-group">
<% f.button :submit, "Create", :class => 'btn bg-blue ', :id => 'create' %>
<% f.button :submit, "Update", :class => 'btn bg-blue ', :disabled => '', :id => 'update' %>
<% f.button :button, "Reset", :class => 'btn bg-danger ', :id => 'reset' %>
</div>
<div class="form-actions">
<%= f.submit "Create In Duty", :class => 'btn bg-blue' %>
</div>
</div>
</div>
<% end %> <% end %>
<script type="text/javascript"> <script type="text/javascript">
$(document).ready(function () { $(document).ready(function () {
}); });
</script> </script>

View File

@@ -4,31 +4,34 @@
</div> </div>
<div class="col-md-3"> <div class="col-md-3">
<%= simple_form_for([:origami,@in_duty]) do |f| %> <%= simple_form_for([:origami,@in_duty]) do |f| %>
<%= f.error_notification %> <div class="card">
<div class="body">
<%= f.error_notification %>
<div class="form-inputs">
<label>Dining Name:</label>
<%= @table.name %>
<br/>
<br/>
<div class="form-inputs"> <label>Commissioner Name:</label>
<label>Dining Name:</label> <%= f.collection_select :commissioner_ids, Commissioner.all, :id, :name, {prompt: 'Select Commissioner'}, {class: 'form-control'} %><br/><br/>
<%= @table.name %> <label>In time</label>
<br/> <%= f.text_field :in_time, :value=>DateTime.now.strftime("%Y-%m-%d / %I:%M %p"),:class=>"form-control datepicker"%><br/>
<br/> <label>Out time</label>
<%= f.text_field :out_time, :value=>DateTime.now.strftime("%Y-%m-%d / %I:%M %p"),:class=>"form-control datepicker"%>
<label>Commissioner Name:</label> </div><br>
<%= f.collection_select :commissioner_ids, Commissioner.all, :id, :name, {prompt: 'Select Commissioner'}, {class: 'form-control'} %><br/><br/> <div class="form-actions">
<label>In time</label> <div class='row'>
<%= f.text_field :in_time, :value=>DateTime.now.strftime("%Y-%m-%d / %I:%M %p"),:class=>"form-control datepicker"%><br/> <div class="col-md-2">
<label>Out time</label> <%= link_to 'Back', origami_index_in_duty_path(@table.id), class: 'btn bg-default' %>
<%= f.text_field :out_time, :value=>DateTime.now.strftime("%Y-%m-%d / %I:%M %p"),:class=>"form-control datepicker"%> </div>
</div><br> <div class="col-md-10">
<div class="form-actions"> <button type="button" class="btn bg-blue btn-block" id='in_duty'>Create In Duty</button>
<div class='row'> </div>
<div class="col-md-2"> </div>
<%= link_to 'Back', origami_index_in_duty_path(@table.id), class: 'btn bg-default' %> </div>
</div> </div>
<div class="col-md-10"> </div>
<button type="button" class="btn bg-blue btn-block" id='in_duty'>Create In Duty</button>
</div>
</div>
</div>
<% end %> <% end %>
</div> </div>
</div> </div>