Merge branch 'master' into adminbsb_material_ui_test

This commit is contained in:
Yan
2017-09-28 18:25:44 +06:30
20 changed files with 957 additions and 119 deletions

View File

@@ -10,6 +10,7 @@ $(function(){
//show menu item list when click menu category
function show_menu_item_list(url_item){
var menu_list = $('.menu_items_list');
menu_list.empty();
//Start Ajax
@@ -22,22 +23,11 @@ $(function(){
var menu_items_list = $('.menu_items_list');
menu_items_list.empty();
menu_items = data.menu_items;
for(var field in menu_items) {
if (menu_items[field].is_sub_item == false) {
instances = menu_items[field].instances ;
$(instances).each(function(i){
if (instances[i].is_default === true) {
code = instances[i].code;
name = instances[i].name;
price = parseFloat(instances[i].price).toFixed(2);
is_available = instances[i].is_available ;
is_on_promotion = instances[i].is_on_promotion;
item_attributes = instances[i].values;
promotion_price = instances[i].promotion_price;
code = instances[i].code;
}
});
qty = 1;
options = [];
@@ -45,10 +35,32 @@ $(function(){
fa_plus = '';
menu_item_box = 'set_item_box';
data_target = 'sx_item_set_detailModal';
code = menu_items[field].code;
name = menu_items[field].name;
price = 0;//parseFloat( menu_items[field].price).toFixed(2);
is_available = menu_items[field].is_available ;
is_on_promotion = 0;
item_attributes = menu_items[field].attributes;
promotion_price = menu_items[field].promotion_price;
}else{
fa_plus = 'fa-plus';
menu_item_box = 'menu_item_box';
data_target = 'sx_item_detailModal'
data_target = 'sx_item_detailModal';
$(instances).each(function(i){
if (instances[i].is_default === true) {
code = instances[i].code;
name = instances[i].name;
price = parseFloat(instances[i].price).toFixed(2);
is_available = instances[i].is_available ;
is_on_promotion = instances[i].is_on_promotion;
item_attributes = instances[i].values;
promotion_price = instances[i].promotion_price;
code = instances[i].code;
}
});
}
if (menu_items[field].image) {
@@ -108,6 +120,9 @@ $(function(){
item_sets = $(this).data('item-sets');
for(var field in item_sets) {
$('.set_order').attr('data-min-qty',item_sets[field]["min_selectable_qty"]);
value = item_sets[field]["instances"];
$(value).each(function(i){
$.ajax({
@@ -121,6 +136,8 @@ $(function(){
+"' data-code='"+result["code"]
+"' data-price='"+result["price"]
+"' data-option='"+JSON.stringify(result["options"])
+"' data-min-qty='"+item_sets[field]["min_selectable_qty"]
+"' data-max-qty='"+item_sets[field]["max_selectable_qty"]
+"'>"
+'<div class="custom-card-head card-head" style="line-height:14px;">'
+'<small class="">'+result["name"]+'</small>'
@@ -156,46 +173,54 @@ $(function(){
$(".options-list").empty();
rowCount = $('.selected-instance');
item_options = $(this).data('option');
min_qty = $(this).data('min-qty');
max_qty = $(this).data('max-qty');
code = $(this).data('code');
for(var field in item_options) {
value = item_options[field]["values"];
type = item_options[field]["type"];
row = "<p style='font-size:16px;margin-bottom:3px'>"+type+"</p>"
$(value).each(function(i){
row +="<button class='btn btn-default btn-sm option_btn "+ type +"' data-type='"
+type+"' data-value='"+value[i]+"' data-code='"+code+"' data-group='set_menu'>"
+value[i]+"</button>";
});
$(".options-list").append(row);
if (rowCount.length+1 <= max_qty) {
for(var field in item_options) {
value = item_options[field]["values"];
type = item_options[field]["type"];
row = "<p style='font-size:16px;margin-bottom:3px'>"+type+"</p>"
$(value).each(function(i){
row +="<button class='btn btn-default btn-sm option_btn "+ type +"' data-type='"
+type+"' data-value='"+value[i]+"' data-code='"+code+"' data-group='set_menu'>"
+value[i]+"</button>";
});
$(".options-list").append(row);
}
}
if($(this).hasClass('selected-instance') == true){
sub_total = $('#set_total_price').text();
name = $(this).data('name');
price = $(this).data('price');
// qty = $('#set_change_qty').val();
qty = document.getElementById("set_count").value;
total = qty*price;
var total_price = +sub_total - +total;
$(this).removeClass('selected-instance');
$(".options-list").empty();
$(this).removeAttr('data-options');
$('#instance_option').text('')
}else {
sub_total = $('#set_total_price').text();
name = $(this).data('name');
price = $(this).data('price');
// qty = $('#set_change_qty').val();
qty = document.getElementById("set_count").value;
total = qty*price;
var total_price = +sub_total + +total;
$(this).addClass('selected-instance');
}
$('#set_unit_price').text(price);
$('#set_total_price').text(total_price);
if($(this).hasClass('selected-instance') == true){
sub_total = $('#set_total_price').text();
name = $(this).data('name');
price = $(this).data('price');
// qty = $('#set_change_qty').val();
qty = document.getElementById("set_count").value;
total = qty*price;
var total_price = +sub_total - +total;
$(this).removeClass('selected-instance');
$(".options-list").empty();
$(this).removeAttr('data-options');
$('#instance_option').text('')
}else {
if (rowCount.length+1 <= max_qty) {
sub_total = $('#set_total_price').text();
name = $(this).data('name');
price = $(this).data('price');
// qty = $('#set_change_qty').val();
qty = document.getElementById("set_count").value;
total = qty*price;
var total_price = +sub_total + +total;
$(this).addClass('selected-instance');
}
}
$('#set_unit_price').text(price);
$('#set_total_price').text(total_price);
}); //End selecct attribute buttom
// click add order
@@ -204,36 +229,49 @@ $(function(){
qty = parseInt($('#set_count').val());
item_code = $('#set_item_code').text();
item_name = $('#set_name').text();
min_qty = $(this).data('min-qty');
var items = $('.selected-instance');
attribute_arr = []
option_arr = []
var rowCount = $('.summary-items tbody tr').length+1;
$(items).each(function(i){
code = $(items[i]).attr('data-code');
name = $(items[i]).attr('data-name');
price = $(items[i]).attr('data-price');
option = $(items[i]).attr('data-options');
total = qty * price ;
option_arr.push(option);
row ="<tr class='item_box' data-price ='"
+price+ "' data-toggle='modal' data-target='#sx_itemModal' 'data-instance ='"
+name+ "' data-code='"+item_code+"' data-instance-code='"
+code+"' data-attributes='"
+attribute_arr+"' data-options ='"
+option_arr+"' data-row ='"+rowCount+ "'>"
+'<td class="item-cell-no">'+rowCount+'</td>'
+'<td class="item-cell-name" id="item_name" >' + item_name+ ' ' + name +'</td>'
+'<td class="item-cell-qty" id="item_qty">' + qty + '</td>'
+'<td class="item-cell-price" id="item_price">'
+ parseFloat(total).toFixed(2)
+'</td>'
+'</tr>';
$(".summary-items tbody").append(row);
rowCount = rowCount + 1;
});
calculate_sub_total();
if (items.length >= min_qty) {
attribute_arr = []
option_arr = []
var rowCount = $('.summary-items tbody tr').length+1;
$(items).each(function(i){
code = $(items[i]).attr('data-code');
name = $(items[i]).attr('data-name');
price = $(items[i]).attr('data-price');
option = $(items[i]).attr('data-options');
total = qty * price ;
option_arr.push(option);
row ="<tr class='item_box' data-price ='"
+price+ "' data-toggle='modal' data-target='#sx_itemModal' 'data-instance ='"
+name+ "' data-code='"+item_code+"' data-instance-code='"
+code+"' data-attributes='"
+attribute_arr+"' data-options ='"
+option_arr+"' data-row ='"+rowCount+ "'>"
+'<td class="item-cell-no">'+rowCount+'</td>'
+'<td class="item-cell-name" id="item_name" >' + item_name+ ' ' + name +'</td>'
+'<td class="item-cell-qty" id="item_qty">' + qty + '</td>'
+'<td class="item-cell-price" id="item_price">'
+ parseFloat(total).toFixed(2)
+'</td>'
+'</tr>';
$(".summary-items tbody").append(row);
rowCount = rowCount + 1;
});
calculate_sub_total();
$(".sx_item_set_detailModal").css({ 'display': "none" });
}else{
$(".sx_item_set_detailModal").css({ 'display': "block" });
$.alert({
title: 'Alert!',
content: 'Please Select Minimum ' + min_qty + " items",
type: 'red',
typeAnimated: true,
btnClass: 'btn-danger',
});
}
}); //End add order Click
@@ -596,6 +634,9 @@ $(function(){
$(".item_box").removeAttr("data-active");
});
$('#sx_item_set_detailModal').on('click','#close', function(){
$("#sx_item_set_detailModal").css({ 'display': "none" });
});
//click save buttom after change qty
$('#sx_itemModal').on('click','#save', function(){
summary_items_filter();

View File

@@ -0,0 +1,223 @@
/*!
* Start Bootstrap - Simple Sidebar (http://startbootstrap.com/template-overviews/simple-sidebar)
* Copyright 2013-2017 Start Bootstrap
* Licensed under MIT (https://github.com/BlackrockDigital/startbootstrap-simple-sidebar/blob/master/LICENSE)
*/
/**/
#wrapper {
padding-left: 0;
-webkit-transition: all 0.5s ease;
-moz-transition: all 0.5s ease;
-o-transition: all 0.5s ease;
transition: all 0.5s ease;
}
#wrapper.toggled {
padding-left: 200px;
}
#sidebar-wrapper {
/* z-index: 1000;*/
/*position: fixed;*/
z-index: 1;
position: ;
left: 200px;
width: 0;
height: 100%;
margin-left: -224px;
margin-top:-20px;
overflow-x: ;
-webkit-transition: all 0.5s ease;
-moz-transition: all 0.5s ease;
-o-transition: all 0.5s ease;
transition: all 0.5s ease;
}
#wrapper.toggled #sidebar-wrapper {
width: 216px;
}
#page-content-wrapper {
width: 100%;
position: absolute;
padding: 0px;
}
#wrapper.toggled #page-content-wrapper {
position: absolute;
margin-right: -200px;
}
/* Sidebar Styles */
.sidebar-nav {
position: absolute;
background: #222d32;
top: 0;
width: 200px;
margin: 0;
padding: 0;
list-style: none;
}
.sidebar-nav li {
text-indent: 20px;
line-height: 40px;
}
.sidebar-nav>li.header {
color: #4b646f;
background-color: #1a2226;
line-height: 35px !important;
}
.main-nav {
/* background-color: #161926 !important;*/
}
/*.main-nav a {
color: #fff !important;
}
*/
.sidebar-nav li a {
display: block;
text-decoration: none;
color: #999999;
}
.sidebar-nav li a:hover {
text-decoration: none;
color: #fff;
background: rgba(255, 255, 255, 0.2);
}
.sidebar-nav li a:active,
.sidebar-nav li a:focus {
text-decoration: none;
}
.sidebar-nav > .sidebar-brand {
height: 65px;
font-size: 18px;
line-height: 60px;
}
.sidebar-nav > .sidebar-brand a {
color: #999999;
}
.sidebar-nav > .sidebar-brand a:hover {
color: #fff;
background: none;
}
@media(min-width:768px) {
#wrapper {
padding-left: 0;
}
#wrapper.toggled {
padding-left: 210px;
}
#sidebar-wrapper {
width: 0;
}
#wrapper.toggled #sidebar-wrapper {
width: 216px;
}
#page-content-wrapper {
padding: 0px;
position: relative;
}
#wrapper.toggled #page-content-wrapper {
position: relative;
margin-right: 0;
}
}
.accordion {
width: 200px;
list-style: none;
font-size: 14px;
color: #999999 ;
padding: 0px !important;
margin: 0px !important;
}
.accordion .link {
cursor: pointer;
display: block;
/* padding: 15px 15px 15px 42px;
color: #4D4D4D;*/
/* font-size: 14px;
font-weight: 700;*/
/*border-bottom: 1px solid #CCC;*/
position: relative;
-webkit-transition: all 0.4s ease;
-o-transition: all 0.4s ease;
transition: all 0.4s ease;
}
/*.accordion li:last-child .link { border-bottom: 0; }*/
.accordion li i {
position: absolute;
top: 13px;
left: 12px;
font-size: 16px;
color: #999999;
-webkit-transition: all 0.4s ease;
-o-transition: all 0.4s ease;
transition: all 0.4s ease;
}
.accordion li i.fa-chevron-down {
right: 12px;
left: auto;
font-size: 16px;
}
.accordion li .link:hover {
background: rgba(255, 255, 255, 0.2);
color: #FFF;
}
.accordion li.open .link { color: #fff; }
.accordion li.open .link > .submenu { display: block;overflow: hidden;}
.accordion li.open i { color: #fff; }
.accordion li.open i.fa-chevron-down {
-webkit-transform: rotateX(180deg);
-ms-transform: rotateX(180deg);
-o-transform: rotateX(180deg);
transform: rotateX(180deg);
}
.submenu {
display: none;
list-style: none;
margin-left: ;
background: #161926;
font-size: 14px;
}
.submenu li {
margin-left: -38px;
}
.submenu a {
display: block;
text-decoration: none;
color: #d9d9d9;
padding-left:20px;
-webkit-transition: all 0.25s ease;
-o-transition: all 0.25s ease;
transition: all 0.25s ease;
}
.submenu a:hover {
background: #b63b4d;
color: #FFF;
}