added voucher

This commit is contained in:
franknstayn
2021-08-27 19:54:36 +08:00
parent 9b31dc4725
commit 84a194f872

View File

@@ -1,33 +1,40 @@
<!doctype html>
<html lang="en">
<head>
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="csrf_token" content="{{ csrf_token() }}" />
<!-- Bootstrap CSS -->
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
<title>Merchbay</title>
<link rel="icon" href="{{asset('public/favicon.ico')}}">
<link rel="icon" href="{{ asset('public/favicon.ico') }}">
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">
<link href="https://fonts.googleapis.com/css2?family=Montserrat:wght@100;200;400;500;600;700;800;900&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/css2?family=Montserrat:wght@100;200;400;500;600;700;800;900&display=swap"
rel="stylesheet">
<link href="{{asset('public/assets/css/merchbay/styles.css')}}" rel="stylesheet">
<!-- <link href="{{asset('public/assets/login/css/style.css')}}" rel="stylesheet">
<link href="{{asset('public/assets/login/css/form-elements.css')}}" rel="stylesheet"> -->
<link href="{{ asset('public/assets/css/merchbay/styles.css') }}" rel="stylesheet">
<!-- <link href="{{ asset('public/assets/login/css/style.css') }}" rel="stylesheet">
<link href="{{ asset('public/assets/login/css/form-elements.css') }}" rel="stylesheet"> -->
<script src='https://www.google.com/recaptcha/api.js'></script>
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-SB3QK6BR1N"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
function gtag() {
dataLayer.push(arguments);
}
gtag('js', new Date());
gtag('config', 'G-SB3QK6BR1N');
</script>
</head>
<body>
</head>
<body>
@include('merchbay.navbar')
<div class="container">
@@ -42,11 +49,13 @@
<!-- Option 1: jQuery and Bootstrap Bundle (includes Popper) -->
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/js/bootstrap.bundle.min.js" integrity="sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/js/bootstrap.bundle.min.js"
integrity="sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM" crossorigin="anonymous">
</script>
<script src="https://ajax.aspnetcdn.com/ajax/jquery.validate/1.11.1/jquery.validate.min.js"></script>
<script>
$(document).ready(function(){
$('.reveal-password').click(function(e){
$(document).ready(function() {
$('.reveal-password').click(function(e) {
var $pwd = $(".pwd");
if ($pwd.attr('type') === 'password') {
$pwd.attr('type', 'text');
@@ -57,7 +66,7 @@
}
});
if($('.data-errors').length > 0){
if ($('.data-errors').length > 0) {
$('#team-store-login').modal('show')
return false;
}
@@ -78,7 +87,7 @@
var placement = $(element).data('error');
if (placement) {
$(placement).append(error);
}else {
} else {
error.insertAfter(element);
}
},
@@ -88,10 +97,10 @@
$("#frm-register").validate({
rules: {
name: {
required : true
required: true
},
username: {
required : true
required: true
},
email: {
required: true,
@@ -107,14 +116,14 @@
var placement = $(element).data('error');
if (placement) {
$(placement).append(error);
}else {
} else {
error.insertAfter(element);
}
},
submitHandler: submitRegisterForm
});
$('.password-protected').click(function(){
$('.password-protected').click(function() {
$('#_teamstore_id').val($(this).data('store-id'))
// console.log($(this).data('store-id'))
@@ -128,62 +137,86 @@
$('#frm_search_store').submit();
});
$("#frm_voucher").validate({
rules: {
voucher: {
required: true
}
},
messages: {},
errorPlacement: function(error, element) {
var placement = $(element).data('error');
if (placement) {
$(placement).append(error)
} else {
error.insertAfter(element);
}
},
submitHandler: submitVoucher
});
}); // end document ready
function submitLoginForm (){
function submitLoginForm() {
// method="POST" action="{{ url('/auth/login') }}"
var data = $("#frm-login").serialize();
// console.log(data)
$.ajax({
type : 'POST',
url : "{{ url('/custom/auth') }}",
data : data,
dataType : 'json',
type: 'POST',
url: "{{ url('/custom/auth') }}",
data: data,
dataType: 'json',
beforeSend: function() {
$("#login-response-msg").fadeOut();
$("#btn-login").html('Signing in &nbsp; <i class="fa fa-spinner fa-spin"></i>');
},
success : function(response){
success: function(response) {
$("#login-response-msg").html("");
$("#login-response-msg").fadeIn(1000, function(){
$("#login-response-msg").fadeIn(1000, function() {
if(response.success){
if (response.success) {
// $("#login-response-msg").html(response);
// console.log();
location.reload();
}else{
} else {
$("#login-response-msg").html(response.message);
}
//
// console.log(response.success);
$("#btn-login").html('<span class="glyphicon glyphicon-log-in"></span> &nbsp; Sign In');
$("#btn-login").html(
'<span class="glyphicon glyphicon-log-in"></span> &nbsp; Sign In');
});
}
});
return false;
}/* login submit */
} /* login submit */
function submitRegisterForm (){
function submitRegisterForm() {
var data = $("#frm-register").serialize();
$.ajax({
type : 'POST',
url : "{{ url('/custom/register') }}",
data : data,
dataType : 'json',
type: 'POST',
url: "{{ url('/custom/register') }}",
data: data,
dataType: 'json',
beforeSend: function() {
$("#register-response-msg").fadeOut();
$("#btn-register").html('Please wait &nbsp; <i class="fa fa-spinner fa-spin"></i>');
},
success : function(response){
success: function(response) {
$("#register-response-msg").html("");
$("#register-response-msg").fadeIn(1000, function(){
$("#register-response-msg").fadeIn(1000, function() {
if(response.success){
if (response.success) {
location.reload();
}else{
} else {
$("#register-response-msg").html(response.message);
}
$("#btn-register").html('Register');
@@ -195,9 +228,48 @@
return false;
}
function submitVoucher() {
var form = $('#frm_voucher')
var data = form.serialize();
// console.log(data);
$.ajax({
type: "POST",
url: "{{ url('teamstore/q/add-voucher') }}",
data: data,
beforeSend: function(xhr) {
$("#btn_apply_voucher").attr('disabled', true);
$("#btn_apply_voucher").html('Applying <i class="fa fa-spinner fa-spin"></i>');
var token = $('meta[name="csrf_token"]').attr('content');
if (token) {
return xhr.setRequestHeader('X-CSRF-TOKEN', token);
}
},
success: function(response) {
console.log(response);
$("#btn_apply_voucher").attr('disabled', false);
$("#btn_apply_voucher").html('Apply');
if (response.success) {
$("#voucher_list").append(response.message);
form.validate().resetForm();
form[0].reset();
$('#my_subtotal').text(response.subtotal);
} else {
$("#error_voucher").html(response.message).fadeIn().delay(5000).fadeOut('slow',
function() {
$("#error_voucher").html("");
$("#error_voucher").css("display", "block");
});
}
}
});
return false;
}
</script>
<script>
<script>
$(document).ready(function() {
// $('.img-zoom').zoom();
$('.inputName').keyup(function() {
@@ -206,29 +278,29 @@
// $('.carousel').bcSwipe({ threshold: 50 });
$('.btn-number').click(function(e){
$('.btn-number').click(function(e) {
e.preventDefault();
fieldName = $(this).attr('data-field');
type = $(this).attr('data-type');
var input = $("input[name='"+fieldName+"']");
var input = $("input[name='" + fieldName + "']");
var currentVal = parseInt(input.val());
if (!isNaN(currentVal)) {
if(type == 'minus') {
if (type == 'minus') {
if(currentVal > input.attr('min')) {
if (currentVal > input.attr('min')) {
input.val(currentVal - 1).change();
}
if(parseInt(input.val()) == input.attr('min')) {
if (parseInt(input.val()) == input.attr('min')) {
$(this).attr('disabled', true);
}
} else if(type == 'plus') {
} else if (type == 'plus') {
if(currentVal < input.attr('max')) {
if (currentVal < input.attr('max')) {
input.val(currentVal + 1).change();
}
if(parseInt(input.val()) == input.attr('max')) {
if (parseInt(input.val()) == input.attr('max')) {
$(this).attr('disabled', true);
}
@@ -238,15 +310,15 @@
}
});
$('#myCarousel').on('slid.bs.carousel', function (e) {
$('#myCarousel').on('slid.bs.carousel', function(e) {
var id = $('.item.active').data('slide-number');
// $('#carousel-text').html($('#slide-content-'+id).html());
// console.log(id)
$('.a_thumbnail').removeClass('active');
$('#carousel-selector-'+id).addClass('active');
$('#carousel-selector-' + id).addClass('active');
});
$('.input-number').focusin(function(){
$('.input-number').focusin(function() {
$(this).data('oldValue', $(this).val());
});
@@ -257,14 +329,14 @@
valueCurrent = parseInt($(this).val());
name = $(this).attr('name');
if(valueCurrent >= minValue) {
$(".btn-number[data-type='minus'][data-field='"+name+"']").removeAttr('disabled')
if (valueCurrent >= minValue) {
$(".btn-number[data-type='minus'][data-field='" + name + "']").removeAttr('disabled')
} else {
alert('Sorry, the minimum value was reached');
$(this).val($(this).data('oldValue'));
}
if(valueCurrent <= maxValue) {
$(".btn-number[data-type='plus'][data-field='"+name+"']").removeAttr('disabled')
if (valueCurrent <= maxValue) {
$(".btn-number[data-type='plus'][data-field='" + name + "']").removeAttr('disabled')
} else {
alert('Sorry, the maximum value was reached');
$(this).val($(this).data('oldValue'));
@@ -273,7 +345,7 @@
});
$(".input-number").keydown(function (e) {
$(".input-number").keydown(function(e) {
// Allow: backspace, delete, tab, escape, enter and .
if ($.inArray(e.keyCode, [46, 8, 9, 27, 13, 190]) !== -1 ||
// Allow: Ctrl+A
@@ -284,12 +356,13 @@
return;
}
// Ensure that it is a number and stop the keypress
if ((e.shiftKey || (e.keyCode < 48 || e.keyCode > 57)) && (e.keyCode < 96 || e.keyCode > 105)) {
if ((e.shiftKey || (e.keyCode < 48 || e.keyCode > 57)) && (e.keyCode < 96 || e.keyCode >
105)) {
e.preventDefault();
}
});
$('.multi-item-carousel .item').each(function(){
$('.multi-item-carousel .item').each(function() {
var next = $(this).next();
if (!next.length) {
next = $(this).siblings(':first');
@@ -298,32 +371,32 @@
next.children(':first-child').clone().appendTo($(this));
for (var i=0; i<2; i++){
for (var i = 0; i < 2; i++) {
next=next.next();
next = next.next();
if (!next.length){
next=$(this).siblings(':first');
if (!next.length) {
next = $(this).siblings(':first');
}
next.children(':first-child').clone().appendTo($(this));
}
});
$('#jersey_chk').click(function(){
$('#jersey_chk').click(function() {
var product_price = $('#product_price').val();
var getPriceHold = $('#price_holder').val();
var getHalf = getPriceHold / 2;
if($(this).is(':checked')){
if ($(this).is(':checked')) {
$('.td-hide').css('display', '');
$('.th-hide').css('display', '');
$('#product_price').val(Number(product_price) + Number(getHalf));
$('#display-product-price').html('$ ' + $('#product_price').val());
// console.log($('#product_price').val() - getHalf);
}else{
} else {
$('.cls-uniformName').val('');
$('.td-hide').css('display', 'none');
$('.th-hide').css('display', 'none');
@@ -335,16 +408,16 @@
// console.log($(this).is(':checked'));
});
$('#shorts_chk').click(function(){
$('#shorts_chk').click(function() {
var product_price = $('#product_price').val();
var getPriceHold = $('#price_holder').val();
var getHalf = getPriceHold / 2;
if($(this).is(':checked')){
if ($(this).is(':checked')) {
$('#product_price').val(Number(product_price) + Number(getHalf));
$('#display-product-price').html('$ ' + $('#product_price').val());
}else{
} else {
$('#product_price').val(Number(product_price) - Number(getHalf));
$('#display-product-price').html('$ ' + $('#product_price').val());
@@ -355,7 +428,7 @@
$(this).val($(this).val().toUpperCase());
});
$('[id^=carousel-selector-]').click( function(){
$('[id^=carousel-selector-]').click(function() {
var id = this.id.substr(this.id.lastIndexOf("-") + 1);
var id = parseInt(id);
$('#myCarousel').carousel(id);
@@ -395,27 +468,27 @@
submitHandler: submitOrderListForm
});
function submitOrderListForm(){
function submitOrderListForm() {
var data = $("#frm-order-list").serializeArray();
$.ajax({
type : 'POST',
url : "{{ url('teamstore/q/add-to-cart') }}",
data : data,
type: 'POST',
url: "{{ url('teamstore/q/add-to-cart') }}",
data: data,
dataType: 'json',
beforeSend:function(xhr){
beforeSend: function(xhr) {
var token = $('meta[name="csrf_token"]').attr('content');
if (token) {
return xhr.setRequestHeader('X-CSRF-TOKEN', token);
}
xhr.setRequestHeader( 'X-Requested-With', 'XMLHttpRequest');
xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
},
success : function(response){
success: function(response) {
if(response.success){
if (response.success) {
window.location = "{{ url('cart') }}";
}else{
} else {
alert(response.message);
location.reload();
}
@@ -427,26 +500,26 @@
// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ adding of rows @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
$(document).on('button click', '#addNewRow', function(){
$(document).on('button click', '#addNewRow', function() {
var p_id = $('#p_id').val();
$.ajax({ //create an ajax request to load_page.php
type: "POST",
url: "{{ url('/teamstore/q/add-new-row') }}",
data: {
p_id : p_id
p_id: p_id
},
dataType: "html", //expect html to be returned
beforeSend:function(xhr){
beforeSend: function(xhr) {
var token = $('meta[name="csrf_token"]').attr('content');
if (token) {
return xhr.setRequestHeader('X-CSRF-TOKEN', token);
}
xhr.setRequestHeader( 'X-Requested-With', 'XMLHttpRequest');
xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
},
success: function(response){
success: function(response) {
var d = new Date();
var n = d.getTime();
@@ -455,12 +528,18 @@
var doc = parser.parseFromString(response, "text/html");
var elem = doc.getElementById("orderTableBody");
var currentClassName = elem.getElementsByTagName('tr')[0].className;
elem.getElementsByClassName(currentClassName)[0].classList.remove(currentClassName); // remove current Classname
elem.getElementsByTagName('tr')[0].classList.add("table-tr-" + Math.ceil(Math.random() * 999999) + n); // add random classname
elem.getElementsByClassName(currentClassName)[0].classList.remove(
currentClassName); // remove current Classname
elem.getElementsByTagName('tr')[0].classList.add("table-tr-" + Math
.ceil(Math.random() * 999999) + n); // add random classname
$('#tableRow tbody').append(elem.innerHTML);
$('#addnew-btn-tbl-row').html('')
$('#addnew-btn-tbl-row').append('<button type="button" id="addNewRow" class="btn btn-success btn-sm pull-left" data-toggle="tooltip" title="Add Another"><i class="fa fa-plus" aria-hidden="true"></i> Add Row</button>');
$('.tr-remove-btn').html('<button type="button" class="btn btn-danger btn-sm removeRow btn-roster-action" data-toggle="tooltip" title="Remove"><i class="fa fa-remove" aria-hidden="true"></i></button>');
$('#addnew-btn-tbl-row').append(
'<button type="button" id="addNewRow" class="btn btn-success btn-sm pull-left" data-toggle="tooltip" title="Add Another"><i class="fa fa-plus" aria-hidden="true"></i> Add Row</button>'
);
$('.tr-remove-btn').html(
'<button type="button" class="btn btn-danger btn-sm removeRow btn-roster-action" data-toggle="tooltip" title="Remove"><i class="fa fa-remove" aria-hidden="true"></i></button>'
);
$('#orderListPanel').scrollTop($('#orderListPanel')[0].scrollHeight);
$('.inputName').keyup(function() {
this.value = this.value.toLocaleUpperCase();
@@ -472,17 +551,20 @@
// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ end adding of rows @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ removing of rows @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
$(document).on('button click', '.removeRow', function(){
$(document).on('button click', '.removeRow', function() {
var str = $(this).closest('tr').attr('class');
var trCount = $('#tableRow tbody').children('tr').length;
if(trCount <= 2){
if (trCount <= 2) {
$('#addnew-btn-tbl-row').html('');
$('.tr-remove-btn').html('<button type="button" id="addNewRow" class="btn btn-success btn-sm btn-roster-action" data-toggle="tooltip" title="Add Another"><i class="fa fa-plus" aria-hidden="true"></i></button>');
$('.tr-remove-btn').html(
'<button type="button" id="addNewRow" class="btn btn-success btn-sm btn-roster-action" data-toggle="tooltip" title="Add Another"><i class="fa fa-plus" aria-hidden="true"></i></button>'
);
}
$('.'+str).remove();
$('.' + str).remove();
});
// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ end removing of rows @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
}); //end document ready
</script>
</body>
</script>
</body>
</html>