Subversion Repositories SmartDukaan

Rev

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

Rev 32565 Rev 34329
Line 54... Line 54...
54
                    }
54
                    }
55
                });
55
                });
56
        }
56
        }
57
 
57
 
58
    });
58
    });
-
 
59
    //
-
 
60
    $(document).on('click', ".supplier-edit", function () {
-
 
61
        let supplierId = $(this).data('id');
-
 
62
        let formData = objectifyForm($('form#new-supplier-create-form').serializeArray());
-
 
63
        console.log("Form Data: ", formData);
-
 
64
        doGetAjaxRequestHandler(`${context}/supplier/edit/${supplierId}`,
-
 
65
            function (response) {
-
 
66
                loadMainContent(response);
-
 
67
            });
59
 
68
 
-
 
69
    });
-
 
70
 
-
 
71
    function objectifyForm(formArray) {
-
 
72
        return formArray.reduce(function (result, item) {
-
 
73
            if (item.name) {
-
 
74
                result[item.name] = item.value;
-
 
75
            }
-
 
76
            return result;
-
 
77
        }, {});
-
 
78
    }
-
 
79
 
60
    //$(document).on('click', ".submit-edit", function () {
80
    $(document).on('click', ".submit-supplier-edit", function () {
61
           // let supplierId = $(this).data('id');
81
        const supplierId = $(this).data('dd');
-
 
82
        const form = $('#new-supplier-create-form');
-
 
83
        const formData = new FormData(form[0]);
-
 
84
        const jsonData = {};
-
 
85
        formData.forEach((value, key) => {
-
 
86
            if (key === 'inputWarehouseLocation') {
-
 
87
                jsonData[key] = Array.from(form.find(`[name="${key}"]`)[0].selectedOptions)
62
            //if (confirm("Are you sure you want to edit this Supplier") == true) {
88
                    .map(option => parseInt(option.value));
-
 
89
            } else {
-
 
90
                jsonData[key] = value;
-
 
91
            }
-
 
92
        });
-
 
93
        doPostAjaxRequestWithJsonHandler(
63
               // doGetAjaxRequestHandler(`${context}/supplier/edit/${supplierId}`,
94
            `${context}/supplier/update/${supplierId}`,
-
 
95
            JSON.stringify(jsonData),
64
                    //function (response) {
96
            function (response) {
65
                     //   loadMainContent(response);
97
                alert("Supplier updated successfully");
66
                    //});
98
                getAllSupplier("main-content");
67
            //}
99
            }
-
 
100
        );
-
 
101
    });
68
 
102
 
69
       // });//
-
 
70
    $(document).on('click', ".taxation", function () {
103
    $(document).on('click', ".taxation", function () {
71
        loadTaxation("main-content");
104
        loadTaxation("main-content");
72
    });
105
    });
73
 
106
 
74
 
107
 
75
 
-
 
76
    $(document).on('click', ".create-warehouse", function () {
108
    $(document).on('click', ".create-warehouse", function () {
77
        loadCreateWarehouse("main-content");
109
        loadCreateWarehouse("main-content");
78
    });
110
    });
79
 
111
 
80
    $(document).on('click', ".warehouses", function () {
112
    $(document).on('click', ".warehouses", function () {
Line 316... Line 348...
316
 
348
 
317
 
349
 
318
});
350
});
319
 
351
 
320
 
352
 
321
$(document).on('change', '#warehouseCheckbox', function(){
353
$(document).on('change', '#warehouseCheckbox', function () {
322
    let warehouseContainer = document.getElementById("warehouseId");
354
    let warehouseContainer = document.getElementById("warehouseId");
323
    warehouseContainer.disabled = !this.checked;
355
    warehouseContainer.disabled = !this.checked;
324
});
356
});
325
$(document).on('click', ".create-supplier-submit", function () {
357
$(document).on('click', ".create-supplier-submit", function () {
326
    console.log("hello");
358
    console.log("hello");
Line 364... Line 396...
364
    if (contactPerson === "") {
396
    if (contactPerson === "") {
365
        alert("Contact Person is required");
397
        alert("Contact Person is required");
366
        return false;
398
        return false;
367
    }
399
    }
368
    var contactPhone = $("form#new-supplier-create-form input[name=inputContactPhone]").val();
400
    var contactPhone = $("form#new-supplier-create-form input[name=inputContactPhone]").val();
369
        if (contactPhone === "") {
401
    if (contactPhone === "") {
370
            alert("Contact Phone is required");
402
        alert("Contact Phone is required");
371
            return false;
403
        return false;
372
        }
404
    }
373
    var registeredAddress = $("form#new-supplier-create-form input[name=inputRegisteredAddress]").val();
405
    var registeredAddress = $("form#new-supplier-create-form input[name=inputRegisteredAddress]").val();
374
    if (registeredAddress === "") {
406
    if (registeredAddress === "") {
375
        alert("Registered Address is required");
407
        alert("Registered Address is required");
376
        return false;
408
        return false;
377
    }
409
    }
Line 385... Line 417...
385
    if (warehouseId === "") {
417
    if (warehouseId === "") {
386
        alert("Warehouse Location  is required");
418
        alert("Warehouse Location  is required");
387
        return false;
419
        return false;
388
    }
420
    }
389
    var warehouseName = $("#warehouseId").val();
421
    var warehouseName = $("#warehouseId").val();
390
        if (warehouseName === "") {
422
    if (warehouseName === "") {
391
            alert("warehouseName  is required");
423
        alert("warehouseName  is required");
392
            return false;
424
        return false;
393
        }
425
    }
394
 
426
 
395
    var state = $("#stateId").val();
427
    var state = $("#stateId").val();
396
    if (state === "") {
428
    if (state === "") {
397
        alert("state  is required");
429
        alert("state  is required");
398
        return false;
430
        return false;
Line 406... Line 438...
406
    if (termConditions === "") {
438
    if (termConditions === "") {
407
        alert("termConditions  is required");
439
        alert("termConditions  is required");
408
        return false;
440
        return false;
409
    }
441
    }
410
    var internalWarehouse = $("#internalWarehouseId").val();
442
    var internalWarehouse = $("#internalWarehouseId").val();
411
            if (internalWarehouse === "") {
443
    if (internalWarehouse === "") {
412
                alert("internalWarehouse  is required");
444
        alert("internalWarehouse  is required");
413
                return false;
445
        return false;
414
            }
446
    }
415
 
447
 
416
    var json = newSupplierCreateObjectJson();
448
    var json = newSupplierCreateObjectJson();
417
 
449
 
418
 
450
 
419
    if (confirm("Are you sure you want to create supplier")) {
451
    if (confirm("Are you sure you want to create supplier")) {
420
        doAjaxRequestWithJsonHandler(context + "/submitNewSupplier", "POST", json, function (response) {
452
        doAjaxRequestWithJsonHandler(context + "/submitNewSupplier", "POST", json, function (response) {
421
                if(response){
453
            if (response) {
422
                    alert("Supplier created successfully. Its inactive as of now, pls check inactive section");
454
                    alert("Supplier created successfully. Its inactive as of now, pls check inactive section");
423
 
455
 
424
                    $("#main-content").html(response);
456
                    $("#main-content").html(response);
425
                }
457
                }
426
            }
458
            }