load commissioner

This commit is contained in:
Zin Lin Phyo
2017-08-23 10:24:26 +06:30
parent 74c2955ef0
commit fd1bfb7c0e
13 changed files with 738 additions and 255 deletions

View File

@@ -0,0 +1,16 @@
<div class="card">
<div class="card-header">
<div><strong id="order-title">COMMISSIONERS </strong></div>
</div>
<div class="card-block">
<div class="card-columns" style="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" data-id="<%= commissioner.id %>">
<div class="card-block">
<%= commissioner.name %>
</div>
</div>
<% end %>
</div>
</div>
</div>

View File

@@ -5,8 +5,9 @@
<div class="form-inputs">
<%= f.input :name %>
<%= f.label :emp_id %>
<%= f.collection_select :emp_id, Employee.all.order('name asc'), :emp_id, :name, {prompt: "Select an Employee"}, {class: "form-control"} %><br/>
<%= f.input :commission_type %>
<%= 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.collection_select :commission_type, Commission.all, :id, :product_id, {prompt: 'Select Commission Type'}, class: 'form-control' %><br/>
<label><%= f.check_box :is_active %> Active </label>
</div>

View File

@@ -1,11 +1,11 @@
<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' %>
<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>
</ul>
</div>
<br>
@@ -23,22 +23,18 @@
<tbody>
<% @commissioners.each do |commissioner| %>
<tr>
<td><%= commissioner.name %></td>
<td>
<% if Employee.exists? %>
<% employee = Employee.where('emp_id=?',commissioner.emp_id) %>
<%= employee[0].name %>
<% end %>
</td>
<td><%= commissioner.commission_type %></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>
<tr>
<td><%= commissioner.name %></td>
<td>
<%= commissioner.employee.name rescue '-' %>
</td>
<td><%= commissioner.commission.product.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>
</tbody>
</table>
</div>

View File

@@ -21,16 +21,12 @@
<tr>
<td style="width:20%">Employee Name</td>
<td>
<% if Employee.exists? %>
<% employee = Employee.where('emp_id=?', @commissioner.emp_id) %>
<%= employee[0].name %>
<% end %>
<%= @commissioner.employee.name rescue '-' %>
</td>
</tr>
<tr>
<td style="width:20%">Commission Type</td>
<td><%= @commissioner.commission_type %></td>
<td><%= @commissioner.commission.product.name rescue '-' %></td>
</tr>
<tr>
<td style="width:20%">Active</td>

View File

@@ -0,0 +1,217 @@
<div class="row">
<!-- Column One -->
<div class="col-lg-5 col-md-5 col-sm-5" style="height: 100%">
<%= render 'origami/commissioners/commissioners_form', commissioners: @commissioners %>
</div>
<!-- Column Two -->
<div class="col-lg-5 col-md-5 col-sm-5">
<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="60%">Items</th>
<th style="" width="20%">QTY
</td>
<th class="" width="30%">Price
</td>
</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" value="<%= @saleobj.sale_id %>">
<%
# Can't check for discount
unless sale_item.price == 0
%>
<tr id="sale_item" data-sale-item="<%= sale_item.sale_item_id %>">
<td width="4%"><%= count %></td>
<td class='' width="60%">
<%= sale_item.product_name %>
</td>
<td class='' width="20%">
<%= sale_item.qty %>
</td>
<td class='' width="20%">
<%= sale_item.unit_price %>
</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-2 col-md-2 col-sm-2">
<!-- 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>
// Bill Request
$(document).ready(function () {
$(".update").on('click', function () {
var sale_item_id = $(this).attr('data-id');
var qty = $('#' + sale_item_id + "_qty").val();
var price = $('#' + sale_item_id + "_price").val();
console.log(qty + "|" + price)
var ajax_url = "/origami/item_edit";
$.ajax({
type: "POST",
url: ajax_url,
data: 'sale_item_id=' + sale_item_id + "&update_qty=" + qty + "&update_price=" + price,
success: function (result) {
$.confirm({
title: 'Alert!',
content: 'Qty and Price was successfully Updated',
buttons: {
confirm: {
text: 'Ok',
btnClass: 'btn-green btn-lg',
action: function () {
location.reload();
}
}
}
});
}
});
});
$('.void').on('click', function () {
var sale_item_id = $(this).attr('data-id');
var ajax_url = "/origami/item_void";
$.ajax({
type: "POST",
url: ajax_url,
data: 'sale_item_id=' + sale_item_id,
success: function (result) {
location.reload();
}
});
})
$('.foc').on('click', function () {
var sale_item_id = $(this).attr('data-id');
var ajax_url = "/origami/item_foc";
$.ajax({
type: "POST",
url: ajax_url,
data: 'sale_item_id=' + sale_item_id,
success: function (result) {
location.reload();
}
});
})
$('.cancel').on('click', function () {
var sale_item_id = $(this).attr('data-id');
var ajax_url = "/origami/item_void_cancel";
$.ajax({
type: "POST",
url: ajax_url,
data: 'sale_item_id=' + sale_item_id,
success: function (result) {
location.reload();
}
});
})
})
$('#back').on('click', function () {
var table_id = '<%= @table_id %>'
window.location.href = '/origami/table/' + table_id;
})
$('#cancel_all_void').on('click', function () {
var sale_id = "<%= @saleobj.sale_id %>"
var ajax_url = "/origami/cancel_all_void";
$.ajax({
type: "POST",
url: ajax_url,
data: 'sale_id=' + sale_id,
success: function (result) {
location.reload();
}
});
})
$('#apply').on('click', function () {
var sale_id = "<%= @saleobj.sale_id %>"
var ajax_url = "/origami/apply_void";
var table_id = '<%= @table_id %>'
$.ajax({
type: "POST",
url: ajax_url,
data: 'sale_id=' + sale_id,
success: function (result) {
window.location.href = '/origami/table/' + table_id;
}
});
})
$('#sale_item').on('click', function () {
var sale_item_id = this.getAttribute('data-sale-item');
var ajax_url = "/origami/select_sale_item";
var table_id = '<%= @table_id %>'
$.ajax({
type: "POST",
url: ajax_url,
data: 'sale_item_id=' + sale_item_id,
success: function (result) {
// window.location.href = '/origami/table/' + table_id;
}
});
})
</script>

View File

@@ -572,6 +572,12 @@
window.location.href = '/origami/table/' + dining_id + "/sale/" + sale_id + "/edit";
});
$('#commissions').on('click', function () {
var dining_id = "<%= @dining.id %>"
var sale_id = "<%= @obj_sale.sale_id rescue "" %>"
window.location.href = '/origami/table/' + dining_id + "/sale/" + sale_id + "/load_commissioners";
});
$('#void').on('click', function () {
var sure = confirm("Are you sure want to Void");
if (sure == true) {