Subversion Repositories SmartDukaan

Rev

Rev 33795 | Rev 34204 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 33795 Rev 34179
Line 76... Line 76...
76
            // ajax
76
            // ajax
77
        }
77
        }
78
 
78
 
79
    });
79
    });
80
 
80
 
-
 
81
 
81
    $('form#newaddress').validate({
82
    $('form#newaddress').validate({
82
        rules: {
83
        rules: {
83
            firstName: {
84
            firstName: {
84
                required: true
85
                required: true
85
            },
86
            },
Line 343... Line 344...
343
    var customerObj = {};
344
    var customerObj = {};
344
    var paymentOptionIdAmount = [];
345
    var paymentOptionIdAmount = [];
345
    var globalInsurance = false;
346
    var globalInsurance = false;
346
 
347
 
347
    $("#order-items").find("tr:not(:first-child)").each(function (index, el) {
348
    $("#order-items").find("tr:not(:first-child)").each(function (index, el) {
348
        // console.log(el);
349
            // console.log(el);
349
        // console.log(index);
350
            // console.log(index);
350
        var $el = $(el);
351
            var $el = $(el);
351
        var $customerOfferItemId = $el.find('.offerSelect');
352
            var $customerOfferItemId = $el.find('.offerSelect');
352
        var $unitPriceElement = $el.find('.unitPrice');
353
            var $unitPriceElement = $el.find('.unitPrice');
353
        var itemId = parseInt($unitPriceElement.attr("itemId"));
354
            var itemId = parseInt($unitPriceElement.attr("itemId"));
354
        var qty = parseInt($unitPriceElement.attr("quantity"));
355
            var qty = parseInt($unitPriceElement.attr("quantity"));
355
        var found = false;
356
            var found = false;
356
            var customSerialNumberEl = $(el).find('.customSerialNumber');
357
            var customSerialNumberEl = $(el).find('.customSerialNumber');
357
        let tmpObj;
358
            let tmpObj;
358
        let filteredList = priceQtyArray.filter(x => x.itemId === itemId);
359
            let filteredList = priceQtyArray.filter(x => x.itemId === itemId);
359
        if (filteredList.length === 0) {
360
            if (filteredList.length === 0) {
360
            var $discountElement = $el.find('.discount');
361
                var $discountElement = $el.find('.discount');
361
            var $poiId = $el.find('.poiId');
362
                var $poiId = $el.find('.poiId');
362
            var unitPrice = parseFloat($unitPriceElement.val());
363
                var unitPrice = parseFloat($unitPriceElement.val());
363
            var discount = parseFloat($discountElement.val());
364
                var discount = parseFloat($discountElement.val());
364
            var poiId = $poiId.val();
365
                var poiId = $poiId.val();
365
            var customerOfferItemId;
366
                var customerOfferItemId;
366
            if ($customerOfferItemId) {
367
                if ($customerOfferItemId) {
367
                customerOfferItemId = $customerOfferItemId.val();
368
                    customerOfferItemId = $customerOfferItemId.val();
368
            } else {
369
                } else {
369
                customerOfferItemId = 0;
370
                    customerOfferItemId = 0;
370
            }
371
                }
371
 
372
 
372
            if (isNaN(discount)) {
373
                if (isNaN(discount)) {
373
                discount = 0;
374
                    discount = 0;
374
            }
375
                }
375
            let customSerialNumbers = [];
376
                let customSerialNumbers = [];
376
 
377
 
377
            if (customSerialNumberEl.val() !== '') {
378
                if (customSerialNumberEl.val() !== '') {
378
                customSerialNumbers = customSerialNumberEl.val().split(",").map(function (serial) {
379
                    customSerialNumbers = customSerialNumberEl.val().split(",").map(function (serial) {
379
                    return serial.trim(); // Trim spaces from each serial number
380
                        return serial.trim(); // Trim spaces from each serial number
380
                });
381
                    });
381
 
382
 
382
                if (customSerialNumbers.length !== qty) {
383
                    if (customSerialNumbers.length !== qty) {
383
                    alert("Please add all serial numbers");
384
                        alert("Please add all serial numbers");
384
                    return false;
385
                        return false;
-
 
386
                    }
385
                }
387
                }
386
            }
-
 
387
 
388
 
388
            tmpObj = {
389
                tmpObj = {
389
                itemId: itemId,
390
                    itemId: itemId,
390
                poiId: poiId,
391
                    poiId: poiId,
391
                sellingPrice: unitPrice - discount,
392
                    sellingPrice: unitPrice - discount,
392
                quantity: 0,
393
                    quantity: 0,
393
                customerOfferItemId: customerOfferItemId,
394
                    customerOfferItemId: customerOfferItemId,
394
                discountAmount: discount,
395
                    discountAmount: discount,
395
                customSerialNumbers: customSerialNumberEl.val().split(","),
396
                    customSerialNumbers: customSerialNumberEl.val().split(","),
396
                serialNumberDetails: []
397
                    serialNumberDetails: []
397
            };
398
                };
398
 
399
 
399
            priceQtyArray.push(tmpObj);
400
                priceQtyArray.push(tmpObj);
400
        } else {
401
            } else {
401
            tmpObj = filteredList[0];
402
                tmpObj = filteredList[0];
402
        }
403
            }
403
 
404
 
404
            tmpObj.quantity += qty;
405
            tmpObj.quantity += qty;
405
 
406
 
406
            var $serialNumberElement = $(el).find('.serialNumber');
407
            var $serialNumberElement = $(el).find('.serialNumber');
407
            var insuranceEle = $(el).find('.insuranceamount');
408
            var insuranceEle = $(el).find('.insuranceamount');
Line 536... Line 537...
536
 
537
 
537
function validateEmail(email) {
538
function validateEmail(email) {
538
    const re = /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
539
    const re = /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
539
    return re.test(String(email).toLowerCase());
540
    return re.test(String(email).toLowerCase());
540
}
541
}
-
 
542
function sendInvoiceOnWApp(orderId){
-
 
543
    let whatsAppMobile = $('#whatsApp-invoice-number').val();
-
 
544
    doPutAjaxRequestHandler(`${context}/sendInvoiceOnWhatsApp?orderId=${orderId}&whatsAppMobile=${whatsAppMobile}`, function (response) {
-
 
545
        if(response){
-
 
546
            alert('Invoice send successfully on whatsApp');
-
 
547
        }
-
 
548
    });
-
 
549
 
-
 
550
}