merge with august spring

This commit is contained in:
Yan
2017-08-28 18:33:49 +06:30
50 changed files with 1677 additions and 976 deletions

View File

@@ -1,2 +0,0 @@
json.extract! commissioner, :id, :created_at, :updated_at
json.url commissioner_url(commissioner, format: :json)

View File

@@ -1,21 +0,0 @@
<div class="col-md-3">
<%= simple_form_for([:origami, @commissioner]) do |f| %>
<%= f.error_notification %>
<div class="form-inputs">
<%= f.input :name %>
<%= f.label :emp_id %>
<%= f.collection_select :emp_id, Employee.all.order('name asc'), :id, :name, {prompt: 'Select an Employee'}, {class: "form-control"} %><br/>
<%= f.label :commission_type %>
<%= f.select :commission_type, Commission.all.map{ |l| [l.menu_item.name, l.id] } %>
<br/>
<label><%= f.check_box :is_active %> Active </label>
</div><br/>
<div class="form-actions">
<%= link_to 'Back', origami_commissioners_path, class: 'btn btn-success' %>
<%= f.button :submit, class: 'btn btn-info' %>
</div>
<% end %>
</div>

View File

@@ -1,10 +0,0 @@
<div class="span12">
<div class="page-header">
<ul class="breadcrumb">
<li><a href="<%= origami_root_path %>">Home</a></li>
<li><a href="<%= origami_commissioners_path %>">Commissioners</a></li>
<li>Edit</li>
</ul>
</div>
<%= render 'form', commissioner: @commissioner %>
</div>

View File

@@ -1,40 +0,0 @@
<div class="page-header">
<ul class="breadcrumb">
<li><a href="<%= origami_root_path %>">Home</a></li>
<li>Commissioner</li>
<span style="float: right">
<%= link_to t('.new', :default => t("helpers.links.new")), new_origami_commissioner_path, :class => 'btn btn-primary btn-sm' %>
</span>
</ul>
</div>
<br>
<div class="card">
<table class="table table-striped">
<thead>
<tr>
<th>Name</th>
<th>Employee Name</th>
<th>Commission type</th>
<th>Active</th>
<th colspan="3"></th>
</tr>
</thead>
<tbody>
<% @commissioners.each do |commissioner| %>
<tr>
<td><%= commissioner.name %></td>
<td>
<%= commissioner.employee.name rescue '-' %>
</td>
<td><%= commissioner.commission.menu_item.name rescue '-' %></td>
<td><%= commissioner.is_active %></td>
<td><%= link_to 'Show', origami_commissioner_path(commissioner) %></td>
<td><%= link_to 'Edit', edit_origami_commissioner_path(commissioner) %></td>
<td><%= link_to 'Destroy', origami_commissioner_path(commissioner), method: :delete, data: {confirm: 'Are you sure?'} %></td>
</tr>
<% end %>
</tbody>
</table>
</div>

View File

@@ -1 +0,0 @@
json.array! @commissioners, partial: 'commissioners/commissioner', as: :commissioner

View File

@@ -1,10 +0,0 @@
<div class="span12">
<div class="page-header">
<ul class="breadcrumb">
<li><a href="<%= origami_root_path %>">Home</a></li>
<li><a href="<%= origami_commissioners_path %>">Commissioners</a></li>
<li>New</li>
</ul>
</div>
<%= render 'form', commissioner: @commissioner %>
</div>

View File

@@ -1,47 +0,0 @@
<div class="page-header">
<ul class="breadcrumb">
<li><a href="<%= origami_root_path %>">Home</a></li>
<li><a href="<%= origami_commissioners_path %>">Commissioners</a></li>
<span style="float: right">
</span>
</ul>
</div>
<div class="card">
<div class="card-block">
<h4 class="card-title">Commissioner</h4>
<table class="table">
<tbody>
<tr>
<td style="width:20%">Name</td>
<td><%= @commissioner.name %></td>
</tr>
<tr>
<td style="width:20%">Employee Name</td>
<td>
<%= @commissioner.employee.name rescue '-' %>
</td>
</tr>
<tr>
<td style="width:20%">Commission Type</td>
<td><%= @commissioner.commission.menu_item.name rescue '-' %></td>
</tr>
<tr>
<td style="width:20%">Active</td>
<td><%= @commissioner.is_active %></td>
</tr>
<tr>
<td style="width:20%">Created By</td>
<td><%= Employee.find(@commissioner.created_by).name %></td>
</tr>
</tbody>
</table>
<%= link_to 'Back', origami_commissioners_path, class: 'btn btn-success' %>
<%= link_to 'Edit', edit_origami_commissioner_path(@commissioner), class: 'btn btn-info' %>
<%= link_to 'Destroy', origami_commissioner_path(@commissioner), method: :delete, data: {confirm: 'Are you sure?'}, class: 'btn btn-danger' %>
</div>
</div>
</div>

View File

@@ -1 +0,0 @@
json.partial! "commissioners/commissioner", commissioner: @commissioner

View File

@@ -1,2 +0,0 @@
json.extract! commission, :id, :created_at, :updated_at
json.url commission_url(commission, format: :json)

View File

@@ -1,18 +0,0 @@
<div class="col-md-3">
<%= simple_form_for([:origami,@commission]) do |f| %>
<%= f.error_notification %>
<div class="form-inputs">
<%= f.label :product_id %>
<%= f.collection_select :product_id, @products, :id, :name, {prompt: 'Select a Product'}, {class: 'form-control'} %><br/>
<%= f.input :amount %>
<%= f.input :commission_type, :collection => ['Percentage','Net Amount'], prompt: 'Select Commission Type', class: 'form-control' %>
<label><%= f.check_box :is_active %> Active </label>
</div><br>
<div class="form-actions">
<%= link_to 'Back', origami_commissions_path, class: 'btn btn-success' %>
<%= f.button :submit, class: 'btn btn-info' %>
</div>
<% end %>
</div>

View File

@@ -1,10 +0,0 @@
<div class="span12">
<div class="page-header">
<ul class="breadcrumb">
<li><a href="<%= origami_root_path %>">Home</a></li>
<li><a href="<%= origami_commissions_path %>">Commissions</a></li>
<li>Edit</li>
</ul>
</div>
<%= render 'form', commission: @commission %>
</div>

View File

@@ -1,38 +0,0 @@
<div class="page-header">
<ul class="breadcrumb">
<li><a href="<%= origami_root_path %>">Home</a></li>
<li>Commissions</li>
<span style="float: right">
<%= link_to t('.new', :default => t("helpers.links.new")), new_origami_commission_path, :class => 'btn btn-primary btn-sm' %>
</span>
</ul>
</div>
<br>
<div class="card">
<table class="table table-striped">
<thead>
<tr>
<th>Product Name</th>
<th>Amount</th>
<th>Commission type</th>
<th>Active</th>
<th colspan="3"></th>
</tr>
</thead>
<tbody>
<% @commissions.each do |commission| %>
<tr>
<td><%= commission.menu_item.name rescue '-' %></td>
<td><%= commission.amount rescue '-' %></td>
<td><%= commission.commission_type rescue '-' %></td>
<td><%= commission.is_active rescue '-' %></td>
<td><%= link_to 'Show', origami_commission_path(commission) %></td>
<td><%= link_to 'Edit', edit_origami_commission_path(commission) %></td>
<td><%= link_to 'Destroy', origami_commission_path(commission), method: :delete, data: {confirm: 'Are you sure?'} %></td>
</tr>
<% end %>
</tbody>
</table>
</div>

View File

@@ -1 +0,0 @@
json.array! @commissions, partial: 'commissions/commission', as: :commission

View File

@@ -1,182 +0,0 @@
<div class="row">
<!-- Column One -->
<div class="col-lg-5 col-md-5 col-sm-5" style="height: 100%">
<div class="card">
<div class="card-header">
<div><strong id="order-title">COMMISSIONERS </strong></div>
</div>
<div class="card-block">
<div class="card-columns" id="commissioners" style="float: left; padding-top:10px; column-gap: 1.2rem; min-height:600px; max-height:600px; overflow-x:scroll;">
<% @commissioners.each do |commissioner| %>
<div class="card tables green text-white commissioner" data-commissioner-id="<%= commissioner.id %>" data-commissioner-name="<%= commissioner.name %>">
<div class="card-block">
<%= commissioner.name %>
</div>
</div>
<% end %>
</div>
</div>
</div>
</div>
<!-- Column Two -->
<div class="col-lg-6 col-md-6 col-sm-6">
<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="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="40%">Items</th>
<th style="" width="20%">QTY</th>
<th class="" width="20%">Price</th>
<th class="" width="20%">Commissioner</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" class="sale_id" value="<%= @saleobj.sale_id %>">
<%
# Can't check for discount
unless sale_item.price == 0
%>
<tr id="sale_item" class="sale_item" data-sale-item="<%= sale_item.sale_item_id %>">
<td width="4%"><%= count %></td>
<td class='product_name' width="40%">
<%= sale_item.product_name %>
</td>
<td class='qty' width="20%">
<%= sale_item.qty %>
</td>
<td class='unit_price' width="20%">
<%= sale_item.unit_price %>
</td>
<td class='commissioner' width="20%">
<% product_commission = ProductCommission.find_by_sale_item_id(sale_item.id) %>
<%= product_commission.commissioner.name rescue '-' %>
</td>
</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-1 col-md-1 col-sm-1">
<!-- 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='apply'>Apply</button>-->
</div>
</div>
<script>
$(document).ready(function () {
var selected_sale_item = 0;
$('.sale_item').on('click', function () {
$('#order-items-table tr').siblings().css( "background-color", "white" );
this.style.backgroundColor = 'lightgray';
var sale_item_id = this.getAttribute('data-sale-item');
var ajax_url = "/origami/select_sale_item";
selected_sale_item = sale_item_id;
localStorage.setItem("selected_sale_item", selected_sale_item);
$.ajax({
type: "POST",
url: ajax_url,
data: 'sale_item_id=' + sale_item_id,
success: function (result) {
if (result != null){
$('#commissioners').empty();
result.commissioner.forEach(function (c) {
if (result.selected_commissioner != null){
if (c.id == result.selected_commissioner.id){
sale_item = "<div class=\"card tables blue text-white commissioner\" onclick=\"click_commissioner(this)\" data-commissioner-id=" + c.id + " data-commissioner-name=\"" + c.name + "\">" + "<div class=\"card-block\">" + c.name + "</div>" + "</div>"
}else {
sale_item = "<div class=\"card tables green text-white commissioner\" onclick=\"click_commissioner(this)\" data-commissioner-id=" + c.id + " data-commissioner-name=\"" + c.name + "\">" + "<div class=\"card-block\">" + c.name + "</div>" + "</div>"
}
}else {
sale_item = "<div class=\"card tables green text-white commissioner\" onclick=\"click_commissioner(this)\" data-commissioner-id=" + c.id + " data-commissioner-name=\"" + c.name + "\">" + "<div class=\"card-block\">" + c.name + "</div>" + "</div>"
}
$('#commissioners').append(sale_item);
})
}
}
});
});
$('#back').on('click', function () {
var table_id = '<%= @table_id %>';
window.location.href = '/origami/table/' + table_id;
});
});
$('.commissioner').on('click', function () {
alert('click');
});
function click_commissioner(commissioner) {
var commissioner_id = commissioner.getAttribute('data-commissioner-id');
var selected_sale_item = localStorage.getItem("selected_sale_item");
$(commissioner).removeClass("green").addClass("blue");
$(commissioner).siblings().removeClass("blue").addClass("green");
$("tr[data-sale-item=" + selected_sale_item + "] td.commissioner").text(commissioner.getAttribute('data-commissioner-name'));
var ajax_url = "/origami/select_commissioner";
var param_data = 'sale_item_id=' + selected_sale_item + '&commissioner_id=' + commissioner_id;
$.ajax({
type: "POST",
url: ajax_url,
data: param_data,
success: function (result) {
console.log(selected_sale_item + "," +commissioner_id);
if(result.deselect == true){
$(commissioner).removeClass("blue").addClass("green");
$("tr[data-sale-item=" + selected_sale_item + "] td.commissioner").text('-');
}
}
});
};
</script>

View File

@@ -1,10 +0,0 @@
<div class="span12">
<div class="page-header">
<ul class="breadcrumb">
<li><a href="<%= origami_root_path %>">Home</a></li>
<li><a href="<%= origami_commissions_path %>">Commissions</a></li>
<li>New</li>
</ul>
</div>
<%= render 'form', commission: @commission %>
</div>

View File

@@ -1,41 +0,0 @@
<p id="notice"><%= notice %></p>
<div class="page-header">
<ul class="breadcrumb">
<li><a href="<%= origami_root_path %>">Home</a></li>
<li><a href="<%= origami_commissions_path %>">Commissions</a></li>
<span style="float: right">
</span>
</ul>
</div>
<div class="card">
<div class="card-block">
<h4 class="card-title">Commission</h4>
<table class="table">
<tbody>
<tr>
<td style="width:20%">Product Name</td>
<td><%= @commission.menu_item.name rescue '-' %></td>
</tr>
<tr>
<td style="width:20%">Amount</td>
<td><%= @commission.amount %></td>
</tr>
<tr>
<td style="width:20%">Commission Type</td>
<td><%= @commission.commission_type %></td>
</tr>
<tr>
<td style="width:20%">Active</td>
<td><%= @commission.is_active %></td>
</tr>
</tbody>
</table>
<%= link_to 'Back', origami_commissions_path, class: 'btn btn-success' %>
<%= link_to 'Edit', edit_origami_commission_path(@commission), class: 'btn btn-info' %>
<%= link_to 'Destroy', origami_commission_path(@commission), method: :delete, class: 'btn btn-danger', data: {confirm: 'Are you sure?'} %>
</div>
</div>
</div>

View File

@@ -1 +0,0 @@
json.partial! "commissions/commission", commission: @commission

View File

@@ -1,9 +1,12 @@
<%= simple_form_for @in_juty,:url => origami_create_for_in_juty_path, :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>
<%= f.error_notification %>
<%= f.hidden_field :id, :class => "form-control col-md-6 " %>
<div class="form-inputs">
<%= f.hidden_field :dinning_id,:value => @table.id, :class => "form-control col-md-6 " %>
<label>Dining Name:</label>
<%= @table.name %>
<br/>
@@ -12,14 +15,14 @@
<label>Commissioner Name:</label>
<%= f.collection_select :commissioner_ids, Commissioner.all, :id, :name, {prompt: 'Select Commissioner'}, {class: 'form-control'} %><br/><br/>
<label>In time</label>
<%= f.text_field :in_time, :value=>DateTime.now.strftime("%Y-%m-%d / %I:%M %p"),:class=>"form-control datepicker"%><br/>
<%= f.text_field :in_time, :value=>'',:class=>"form-control datepicker"%><br/>
<label>Out time</label>
<%= f.text_field :out_time, :value=>DateTime.now.strftime("%Y-%m-%d / %I:%M %p"),:class=>"form-control datepicker"%>
<%= f.text_field :out_time, :value=>'',:class=>"form-control datepicker"%>
</div><br>
<div class="form-group">
<%= f.button :submit, "Create",:class => 'btn btn-primary ', :id => 'create' %>
<%= f.button :submit, "Update",:class => 'btn btn-primary ', :disabled =>'disabled', :id => 'update' %>
<%= f.button :submit, "Update",:class => 'btn btn-primary ', :disabled =>'', :id => 'update' %>
<%= f.button :button, "Reset",:class => 'btn btn-danger ', :id => 'reset' %>
</div>
@@ -30,11 +33,18 @@
$(function() {
$('.datepicker').datepicker({
format : 'dd-mm-yyyy',
format : 'yyyy-mm-dd',
autoclose: true
});
$('.datepicker').attr('ReadOnly','true');
$('.datepicker').css('cursor','pointer');
});
$('#reset').click(function() {
// window.location.href = '/origami/assign_in_juty/'+ table_id;
location.reload();
return false;
});
</script>

View File

@@ -2,8 +2,7 @@
<%= f.error_notification %>
<div class="form-inputs">
<%= f.input :dinning_id %>
<%= f.input :commissioner_ids %>
<%= 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>

View File

@@ -4,6 +4,7 @@
<table class="table table-striped">
<thead>
<tr>
<th>Select</th>
<th>Dining Facility Name</th>
<th>Commissioner Ids</th>
<th>In time</th>
@@ -21,13 +22,12 @@
<td><%= in_juty.commissioner.name rescue '-' %></td>
<td><%= in_juty.in_time.utc.getlocal.strftime("%Y-%m-%d/%I:%M %p") rescue '-' %></td>
<td><%= in_juty.out_time.utc.getlocal.strftime("%Y-%m-%d/%I:%M %p") rescue '-' %></td>
<td><%= link_to 'Back', origami_path(in_juty.dining_facility.id) %></td>
<td><%= link_to 'Edit', origami_edit_in_juty_path(in_juty.dining_facility.id,in_juty) %></td>
<td><%= link_to 'Destroy', origami_destroy_in_juty_path(in_juty.dining_facility.id,in_juty),method: :delete, data: {confirm: 'Are you sure?'} %></td>
</tr>
<% end %>
</tbody>
</table>
<%= paginate @juties_in %>
</div>
<div class="col-md-4">
@@ -35,40 +35,45 @@
</div>
</div>
<div class="col-md-1">
<button type="button" class="btn btn-primary btn-block" id='back'>Back</button>
</div>
<script type="text/javascript">
$(document).on('click',".injuty_tr",function(){
debugger;
// if(this.checked){
$(this).closest('tr').find('.checkbox_check').prop( "checked", true );
//$( "#checkbox_check" ).prop( "checked", true );
var in_juty_id = $(this).attr('data-ref');
var table_id = "<%= @table.id %>";
var url = "/origami/table/" + table_id + "/in_juty/" + in_juty_id + "/edit";
var url = "/origami/assign_in_juty/table/" + table_id + "/in_juty/" + in_juty_id + "/edit";
$.ajax({
type: "GET",
url: url,
data: {},
dataType: "json",
success: function(data) {
// Selected for Taxes
$('#in_juty_commissioner_ids').val(data.commissioner.name);
$('#in_juty_in_time').val(data.in_time);
$('#in_juty_out_time').val(data.out_time);
$('#in_juty_id').val(data.in_juty.id);
$('#in_juty_commissioner_ids').val(data.commissioner.id);
$('#in_juty_in_time').val(data.in_juty.in_time.split('T')[0]);
$('#in_juty_out_time').val(data.in_juty.out_time.split('T')[0]);
$('#update').removeAttr('disabled');
$('#update').removeAttr('disabled').val('');
$('#update').attr('value', 'Update');
$('#create').attr('disabled','disabled');
$("#new_in_juty").attr('class', 'simple_form new_in_juty');
var id = customer_id;
$("#new_customer").attr('id', id);
$("#new_in_juty").attr('class', 'simple_form edit_in_juty');
var id = "edit_in_juty_" + in_juty_id;
$("#new_in_juty").attr('id', id);
$(".edit_customer").attr('id', id);
$(".edit_customer").attr('action', '/crm/customers/' + $('#customer_id').val());
$(".edit_customer").attr('action', '/crm/customers/' + $('#customer_id').val());
$(".edit_in_juty").attr('id', id);
$(".edit_in_juty").attr('action', '/origami/edit_in_juty/' + $('#in_juty_id').val());
$(".edit_in_juty").attr('action', '/origami/edit_in_juty/' + $('#in_juty_id').val());
$(".patch_method").html('<input type="hidden" name="_method" value="patch">');
}
});
@@ -76,4 +81,9 @@ $(document).on('click',".injuty_tr",function(){
// }
})
$('#back').on('click', function () {
window.location.href = '/origami/table/'+ "<%= @table.id %>";
})
</script>