Berater Bestellungen
This commit is contained in:
parent
a5db985ae8
commit
bde1095014
26 changed files with 1524 additions and 577 deletions
|
|
@ -45,43 +45,46 @@ jQuery(document).ready(function() {
|
|||
e.preventDefault();
|
||||
update_modal_data_load(e, $(this));
|
||||
});
|
||||
if($('.datepicker-base').length > 0) {
|
||||
$('.datepicker-base').datepicker({
|
||||
orientation: 'auto right',
|
||||
calendarWeeks: true,
|
||||
todayBtn: 'linked',
|
||||
//daysOfWeekDisabled: '1',
|
||||
todayHighlight: true,
|
||||
multidate: false,
|
||||
daysOfWeekHighlighted: '0,6',
|
||||
autoclose: true,
|
||||
format: 'dd.mm.yyyy',
|
||||
language: 'de',
|
||||
clearBtn: true,
|
||||
});
|
||||
}
|
||||
if($('.datepicker-birthday').length > 0) {
|
||||
$('.datepicker-birthday').datepicker({
|
||||
todayBtn: 'linked',
|
||||
// daysOfWeekDisabled: '1',
|
||||
multidate: false,
|
||||
daysOfWeekHighlighted: '0,6',
|
||||
autoclose: true,
|
||||
format: 'dd.mm.yyyy',
|
||||
language: 'de',
|
||||
clearBtn: true,
|
||||
startView: 2,
|
||||
|
||||
$('.datepicker-base').datepicker({
|
||||
orientation: 'auto right',
|
||||
calendarWeeks: true,
|
||||
todayBtn: 'linked',
|
||||
//daysOfWeekDisabled: '1',
|
||||
todayHighlight: true,
|
||||
multidate: false,
|
||||
daysOfWeekHighlighted: '0,6',
|
||||
autoclose: true,
|
||||
format: 'dd.mm.yyyy',
|
||||
language: 'de',
|
||||
clearBtn: true,
|
||||
});
|
||||
|
||||
$('.datepicker-birthday').datepicker({
|
||||
todayBtn: 'linked',
|
||||
// daysOfWeekDisabled: '1',
|
||||
multidate: false,
|
||||
daysOfWeekHighlighted: '0,6',
|
||||
autoclose: true,
|
||||
format: 'dd.mm.yyyy',
|
||||
language: 'de',
|
||||
clearBtn: true,
|
||||
startView: 2,
|
||||
|
||||
});
|
||||
|
||||
$('.b-material-datetime-picker').bootstrapMaterialDatePicker({
|
||||
weekStart: 1,
|
||||
format : 'DD.MM.YYYY HH:mm',
|
||||
shortTime: false,
|
||||
nowButton : true,
|
||||
clearButton: true,
|
||||
lang: 'de',
|
||||
//currentDate: ''
|
||||
});
|
||||
});
|
||||
}
|
||||
if($('.b-material-datetime-picker').length > 0) {
|
||||
$('.b-material-datetime-picker').bootstrapMaterialDatePicker({
|
||||
weekStart: 1,
|
||||
format: 'DD.MM.YYYY HH:mm',
|
||||
shortTime: false,
|
||||
nowButton: true,
|
||||
clearButton: true,
|
||||
lang: 'de',
|
||||
//currentDate: ''
|
||||
});
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
|
|
|||
188
public/js/iq-shopping-cart.js
Executable file
188
public/js/iq-shopping-cart.js
Executable file
|
|
@ -0,0 +1,188 @@
|
|||
|
||||
var IqShoppingCart = {
|
||||
table: "#datatables-order-list",
|
||||
btn_add: '.add-product-basket',
|
||||
btn_remove: '.remove-product-basket',
|
||||
card_holder: '#holder_html_view_card',
|
||||
is_for: null,
|
||||
url: null,
|
||||
btn_clear: '#clear-products-basket',
|
||||
modal: null,
|
||||
oTable: null,
|
||||
cProductId: null,
|
||||
table_input: '.table-input-event-onchange',
|
||||
cart_input: '.cart-input-event-onchange',
|
||||
remove_item: '.remove_item_form_cart',
|
||||
shipping_state: '#change_shipping_state',
|
||||
comp_product: 'switchers-comp-product',
|
||||
shipping_is_for: 'shipping_is_for',
|
||||
|
||||
init: function () {
|
||||
var _self = this;
|
||||
_self.url = $(_self.table).data('url');
|
||||
_self.is_for = $('input[name="'+_self.shipping_is_for+'"]').val();
|
||||
_self.cProductId = $('input[name="'+_self.comp_product+'"]:checked').val();
|
||||
_self.showInit();
|
||||
$(_self.shipping_state).on('change', function(){
|
||||
_self.update_shipping_state($(this));
|
||||
});
|
||||
$('input[name="'+_self.comp_product+'"]').on('change', function(){
|
||||
_self.update_comp_product();
|
||||
});
|
||||
// _self.update_comp_product();
|
||||
return _self;
|
||||
},
|
||||
setDatabase: function (oTable){
|
||||
var _self = this;
|
||||
_self.oTable = oTable;
|
||||
},
|
||||
reInit: function (){
|
||||
var _self = this;
|
||||
$(_self.table).find(_self.btn_add).on('click', function(){
|
||||
_self.add_product($(this))
|
||||
});
|
||||
|
||||
$(_self.table).find(_self.btn_remove).on('click', function(){
|
||||
_self.remove_product($(this))
|
||||
});
|
||||
$(_self.table).find(_self.table_input).off('change').on('change', function(){
|
||||
_self.update_input_table($(this));
|
||||
});
|
||||
},
|
||||
showInit: function (){
|
||||
var _self = this;
|
||||
$(_self.btn_clear).on('click', function (){
|
||||
_self.performRequest({action: 'clearCart'})
|
||||
.done(_self.refreshDatabaseRefreshAndView)
|
||||
});
|
||||
$(_self.cart_input).on('change', function(){
|
||||
_self.update_input_cart($(this));
|
||||
});
|
||||
$(_self.remove_item).on('click', function(){
|
||||
_self.update_cart_database($(this).data('product-id'), 0);
|
||||
});
|
||||
|
||||
},
|
||||
update_shipping_state : function (_obj){
|
||||
var _self = this;
|
||||
var id = parseInt(_obj.val());
|
||||
var is_for = _obj.data('is-for');
|
||||
_self.performRequest({shipping_country_id: id, shipping_is_for: is_for, action: 'updateShippingCountry'})
|
||||
.done(_self.refreshItemsAndView);
|
||||
},
|
||||
update_input_table: function (_obj){
|
||||
var _self = this;
|
||||
var qty = parseInt(_obj.val());
|
||||
qty = _self.checkNumber(qty);
|
||||
_obj.val(qty);
|
||||
_self.update_cart(_obj.data('product-id'), qty);
|
||||
},
|
||||
update_input_cart: function (_obj){
|
||||
var _self = this;
|
||||
var qty = parseInt(_obj.val());
|
||||
qty = _self.checkNumber(qty);
|
||||
_obj.val(qty);
|
||||
_self.update_cart_database(_obj.data('product-id'), qty);
|
||||
},
|
||||
update_comp_product: function (){
|
||||
var _self = this;
|
||||
_self.cProductId = $('input[name="'+_self.comp_product+'"]:checked').val();
|
||||
_self.performRequest({action: 'updateCompProduct'})
|
||||
.done(_self.refreshItemsAndView);
|
||||
},
|
||||
add_product: function (_obj){
|
||||
var _self = this;
|
||||
var input = $(_self.table).find('input[name="product_qty_'+_obj.data('product-id')+'"]');
|
||||
var qty = parseInt(input.val()) + 1;
|
||||
qty = _self.checkNumber(qty);
|
||||
input.val(qty);
|
||||
_self.update_cart(_obj.data('product-id'), qty);
|
||||
},
|
||||
remove_product: function (_obj){
|
||||
var _self = this;
|
||||
var input = $(_self.table).find('input[name="product_qty_'+_obj.data('product-id')+'"]');
|
||||
var qty = parseInt(input.val()) - 1;
|
||||
if(qty < 0){
|
||||
qty = 0;
|
||||
}
|
||||
input.val(qty);
|
||||
_self.update_cart(_obj.data('product-id'), qty);
|
||||
},
|
||||
update_cart_database: function (product_id, qty){
|
||||
var _self = this;
|
||||
_self.performRequest({product_id: product_id, qty: qty, action: 'updateCart'})
|
||||
.done(_self.refreshDatabaseAndView);
|
||||
},
|
||||
update_cart: function (product_id, qty){
|
||||
var _self = this;
|
||||
_self.performRequest({product_id: product_id, qty: qty, action: 'updateCart'})
|
||||
.done(_self.refreshItemsAndView);
|
||||
},
|
||||
refreshItemsAndView: function (data){
|
||||
var _self = IqShoppingCart;
|
||||
$(_self.card_holder).html(data.html);
|
||||
_self.showInit();
|
||||
|
||||
},
|
||||
refreshDatabaseAndView: function (data) {
|
||||
var _self = IqShoppingCart;
|
||||
$(_self.card_holder).html(data.html);
|
||||
var input = $(_self.table).find('input[name="product_qty_'+data.data.product_id+'"]');
|
||||
input.val(data.data.qty);
|
||||
_self.showInit();
|
||||
},
|
||||
refreshDatabaseRefreshAndView : function (data){
|
||||
var _self = IqShoppingCart;
|
||||
$(_self.card_holder).html(data.html);
|
||||
_self.showInit();
|
||||
_self.oTable.draw();
|
||||
_self.update_comp_product();
|
||||
|
||||
},
|
||||
checkNumber : function(number){
|
||||
if(number < 0 || isNaN(number)){
|
||||
return 0;
|
||||
}
|
||||
if(number >= 100){
|
||||
return 100;
|
||||
}
|
||||
return number;
|
||||
},
|
||||
performRequest : function(data) {
|
||||
var _self = this;
|
||||
var url = _self.url,
|
||||
contentType = 'application/x-www-form-urlencoded; charset=UTF-8';
|
||||
|
||||
data.shipping_is_for = _self.is_for;
|
||||
data.comp_product_id = _self.cProductId;
|
||||
console.log(data);
|
||||
console.log(url);
|
||||
|
||||
return $.ajax({
|
||||
url: url,
|
||||
data: data,
|
||||
type: "POST",
|
||||
dataType: "json",
|
||||
cache: false,
|
||||
contentType: contentType,
|
||||
encode: true,
|
||||
headers: {
|
||||
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
|
||||
}
|
||||
})
|
||||
.done(function (data) {
|
||||
|
||||
console.log('performRequest');
|
||||
console.log(data);
|
||||
|
||||
|
||||
|
||||
}).fail(function (jqXHR, textStatus, errorThrown) {
|
||||
console.log(jqXHR);
|
||||
console.log(jqXHR.responseText);
|
||||
console.log(textStatus);
|
||||
console.log(errorThrown);
|
||||
console.log("Sorry, there was a problem!");
|
||||
});
|
||||
}
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue