Subversion Repositories SmartDukaan

Rev

Rev 33612 | Rev 33758 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
27711 amit.gupta 1
const MAIN_CONTAINER = "#main-content";
24440 amit.gupta 2
var logosmapping = {
32301 amit.gupta 3
    mobile_insurance_providers: {
4
        "0": context + '/resources/images/icons/provider-logos/iffco.png',
5
        "1": context + '/resources/images/icons/provider-logos/icici.jpg',
6
        "2": context + '/resources/images/icons/provider-logos/tataaig.png',
7
        "3": context + '/resources/images/icons/provider-logos/bharti.jpg',
8
        "4": context + '/resources/images/icons/provider-logos/bharti.jpg',
9
        "5": context + '/resources/images/icons/provider-logos/oneassist.jpeg'
10
    }
24440 amit.gupta 11
}
30414 amit.gupta 12
 
33756 ranu 13
function uuidv4() {
14
    return "10000000-1000-4000-8000-100000000000".replace(/[018]/g, c =>
15
        (+c ^ crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> +c / 4).toString(16)
16
    );
17
}
18
 
19
let IdempotencyKey = uuidv4();
20
 
24595 tejbeer 21
function badRequestAlert(response) {
33756 ranu 22
    //console.log(response.responseText);
23
    try {
24
        var errorObject = JSON.parse(response.responseText);
25
        errorObject = errorObject.response;
26
        bootbox.alert('Bad Request\n' + 'rejectedType : '
27
            + errorObject.rejectedType + '\n' + 'rejectedValue : '
28
            + errorObject.rejectedValue + '\n' + 'message : '
29
            + errorObject.message);
30
    } catch (e) {
31
        bootbox.alert(response.responseText);
32
    }
22956 ashik.ali 33
}
24595 tejbeer 34
 
35
function internalServerErrorAlert(response) {
33756 ranu 36
    // console.log(response.responseText);
37
    try {
38
        var errorObject = JSON.parse(response.responseText);
39
        errorObject = errorObject.response;
40
        bootbox.alert('Internal Server Error\n' + 'rejectedType : '
41
            + errorObject.rejectedType + '\n' + 'rejectedValue : '
42
            + errorObject.rejectedValue + '\n' + 'message : '
43
            + errorObject.message);
44
    } catch (e) {
45
        bootbox.alert(response.responseText);
46
    }
22956 ashik.ali 47
}
48
 
32301 amit.gupta 49
$(document).ajaxError(function (event, jqxhr, settings, thrownError) {
50
    if (typeof loaderDialogObj != "undefined") {
51
        loaderDialogObj.modal('hide');
52
        // $('div.modal-backdrop.fade').remove();
53
    }
54
    if (jqxhr.status == 400) {
55
        // $('#error-prompt-model').modal();
56
        badRequestAlert(jqxhr);
57
    } else {
58
        internalServerErrorAlert(jqxhr);
59
    }
22956 ashik.ali 60
});
61
 
32301 amit.gupta 62
$(document).ajaxComplete(function () {
63
    if (typeof loaderDialogObj != "undefined") {
64
        loaderDialogObj.modal('hide');
65
        // $('div.modal-backdrop.fade').remove();
66
    }
23946 amit.gupta 67
});
30017 amit.gupta 68
 
24992 tejbeer 69
function ajaxStartHandler() {
32301 amit.gupta 70
    if (typeof loaderDialogObj != "undefined")
71
        loaderDialogObj.modal('show');
24976 amit.gupta 72
}
30017 amit.gupta 73
 
24976 amit.gupta 74
$(document).ajaxStart(ajaxStartHandler);
24595 tejbeer 75
 
76
function doAjaxRequestWithParamsHandler(urlString, httpType, params,
32301 amit.gupta 77
                                        callback_function) {
78
    $.ajax({
79
        url: urlString,
80
        async: true,
81
        cache: false,
82
        data: params,
83
        // dataType:'json',
84
        type: httpType,
33756 ranu 85
        headers: {'IdempotencyKey': IdempotencyKey},
32301 amit.gupta 86
        success: function (response) {
33756 ranu 87
            IdempotencyKey = uuidv4();
32301 amit.gupta 88
            callback_function(response);
32308 amit.gupta 89
            formatCurrency();
32301 amit.gupta 90
        }
91
    });
23193 ashik.ali 92
}
93
 
24595 tejbeer 94
function doGetAjaxRequestWithParamsHandler(urlString, params, callback_function) {
32301 amit.gupta 95
    doAjaxRequestWithParamsHandler(urlString, "GET", params, callback_function);
23500 ashik.ali 96
}
97
 
24595 tejbeer 98
function doPostAjaxRequestWithParamsHandler(urlString, params,
32301 amit.gupta 99
                                            callback_function) {
100
    doAjaxRequestWithParamsHandler(urlString, "POST", params, callback_function);
23500 ashik.ali 101
}
102
 
32308 amit.gupta 103
function formatCurrency() {
104
    $('.rcurrency').each(function (index, ele) {
105
        if (!isNaN(parseInt($(ele).html()))) {
106
            $(ele).html(numberToComma($(ele).html(), true));
107
        }
108
    });
109
    $('.currency').each(function (index, ele) {
110
        if (!isNaN(parseInt($(ele).html()))) {
111
            $(ele).html(numberToComma($(ele).html()));
112
        }
113
    });
114
 
115
}
116
 
24595 tejbeer 117
function doAjaxRequestWithJsonHandler(urlString, httpType, json,
32301 amit.gupta 118
                                      callback_function) {
119
    $.ajax({
120
        url: urlString,
121
        async: true,
122
        cache: false,
123
        processData: false,
124
        data: json,
125
        contentType: 'application/json',
126
        type: httpType,
33756 ranu 127
        headers: {'IdempotencyKey': IdempotencyKey},
32301 amit.gupta 128
        success: function (response) {
33756 ranu 129
            IdempotencyKey = uuidv4();
32301 amit.gupta 130
            // console.log("response"+JSON.stringify(data));
131
            callback_function(response);
32308 amit.gupta 132
            formatCurrency();
32301 amit.gupta 133
        }
134
    });
23032 ashik.ali 135
}
136
 
24595 tejbeer 137
function doPostAjaxRequestWithJsonHandler(urlString, json, callback_function) {
32301 amit.gupta 138
    doAjaxRequestWithJsonHandler(urlString, "POST", json, callback_function);
23500 ashik.ali 139
}
23032 ashik.ali 140
 
24595 tejbeer 141
function doPutAjaxRequestWithJsonHandler(urlString, json, callback_function) {
32301 amit.gupta 142
    doAjaxRequestWithJsonHandler(urlString, "PUT", json, callback_function);
23500 ashik.ali 143
}
144
 
24595 tejbeer 145
function doAjaxRequestHandler(urlString, httpType, callback_function) {
33756 ranu 146
    console.log("Current IdempotencyKey:", IdempotencyKey);
32301 amit.gupta 147
    $.ajax({
148
        url: urlString,
149
        async: true,
150
        cache: false,
151
        type: httpType,
33756 ranu 152
        headers: {'IdempotencyKey': IdempotencyKey},
32301 amit.gupta 153
        success: function (response) {
33756 ranu 154
            IdempotencyKey = uuidv4();
32301 amit.gupta 155
            callback_function(response);
32308 amit.gupta 156
            formatCurrency();
32301 amit.gupta 157
        }
158
    });
22982 ashik.ali 159
}
160
 
24595 tejbeer 161
function doGetAjaxRequestHandler(urlString, callback_function) {
32301 amit.gupta 162
    doAjaxRequestHandler(urlString, "GET", callback_function);
23500 ashik.ali 163
}
164
 
24595 tejbeer 165
function doPutAjaxRequestHandler(urlString, callback_function) {
32301 amit.gupta 166
    doAjaxRequestHandler(urlString, "PUT", callback_function);
23500 ashik.ali 167
}
168
 
24595 tejbeer 169
function doPostAjaxRequestHandler(urlString, callback_function) {
32301 amit.gupta 170
    doAjaxRequestHandler(urlString, "POST", callback_function);
23629 ashik.ali 171
}
172
 
24595 tejbeer 173
function doDeleteAjaxRequestHandler(urlString, callback_function) {
32301 amit.gupta 174
    doAjaxRequestHandler(urlString, "DELETE", callback_function);
23783 ashik.ali 175
}
176
 
24595 tejbeer 177
function doAjaxUploadRequest(urlString, httpType, file) {
32301 amit.gupta 178
    var response;
179
    doAjaxUploadRequestHandler(urlString, httpType, file,
180
        function (ajaxResponse) {
181
            response = ajaxResponse;
182
        });
183
    return response;
23347 ashik.ali 184
}
185
 
24595 tejbeer 186
function doAjaxUploadRequestHandler(urlString, httpType, file,
32301 amit.gupta 187
                                    callback_function) {
188
    var formData = new FormData();
189
    formData.append("file", file);
190
    $.ajax({
191
        url: urlString,
192
        type: httpType,
193
        data: formData,
194
        dataType: 'json',
195
        async: true,
196
        cache: false,
197
        contentType: false,
198
        enctype: 'multipart/form-data',
199
        processData: false,
33756 ranu 200
        headers: {'IdempotencyKey': IdempotencyKey},
32301 amit.gupta 201
        success: function (response) {
33756 ranu 202
            IdempotencyKey = uuidv4();
32301 amit.gupta 203
            // console.log("response"+JSON.stringify(data));
204
            callback_function(response);
205
        }
206
    });
22982 ashik.ali 207
}
30017 amit.gupta 208
 
24595 tejbeer 209
function doAjaxUploadRequestJsonHandler(urlString, httpType, file, json,
32301 amit.gupta 210
                                        callback_function) {
211
    var formData = new FormData();
212
    formData.append("file", file);
213
    formData.append('json', new Blob([json]));
214
    $.ajax({
215
        url: urlString,
216
        type: httpType,
217
        data: formData,
218
        enctype: 'multipart/form-data',
219
        contentType: false,
220
        processData: false,
33756 ranu 221
        headers: {'IdempotencyKey': IdempotencyKey},
32301 amit.gupta 222
        success: function (response) {
33756 ranu 223
            IdempotencyKey = uuidv4();
32301 amit.gupta 224
            // console.log("response"+JSON.stringify(data));
225
            callback_function(response);
226
        }
227
    });
24171 govind 228
}
22982 ashik.ali 229
 
33508 tejus.loha 230
function uploadDocument(file, callback) {
32301 amit.gupta 231
    var url = context + '/document-upload';
232
    doAjaxUploadRequestHandler(url, 'POST', file, function (response) {
233
        var documentId = response.response.document_id;
33756 ranu 234
        //console.log("documentId : " + documentId);
33508 tejus.loha 235
        callback(documentId);
32301 amit.gupta 236
    });
23347 ashik.ali 237
}
238
 
24595 tejbeer 239
function doAjaxGetDownload(urlString, fileName) {
33756 ranu 240
    // console.log("fileName : " + fileName);
32301 amit.gupta 241
    doAjaxDownload(urlString, "GET", null, fileName);
22982 ashik.ali 242
}
243
 
31702 amit.gupta 244
function doAjaxPostDownload(urlString, data, fileName, callback) {
32301 amit.gupta 245
    doAjaxDownload(urlString, "POST", data, fileName, callback);
21627 kshitij.so 246
}
247
 
31702 amit.gupta 248
function doAjaxDownload(urlString, httpType, data, fileName, callback) {
32301 amit.gupta 249
    xhttp = new XMLHttpRequest();
250
    if (typeof loaderDialogObj != "undefined")
251
        loaderDialogObj.modal('show');
252
    xhttp.onreadystatechange = function () {
253
        var a;
254
        if (xhttp.readyState === 2) {
255
            if (xhttp.status == 200) {
256
                xhttp.responseType = "blob";
257
            } else {
258
                xhttp.responseType = "text";
259
            }
260
        } else if (xhttp.readyState === 4 && xhttp.status === 200) {
261
            // Trick for making downloadable link
262
            if (typeof loaderDialogObj != "undefined") {
263
                loaderDialogObj.modal('hide');
264
                // $('div.modal-backdrop.fade').remove();
265
            }
27355 tejbeer 266
 
32301 amit.gupta 267
            a = document.createElement('a');
268
            a.href = window.URL.createObjectURL(xhttp.response);
269
            // Give filename you wish to download
270
            a.download = fileName;
271
            a.style.display = 'none';
272
            document.body.appendChild(a);
273
            a.click();
274
        } else if (xhttp.readyState == 4 && xhttp.status === 400) {
275
            if (typeof loaderDialogObj != "undefined") {
276
                loaderDialogObj.modal('hide');
277
                // $('div.modal-backdrop.fade').remove();
278
            }
279
            badRequestAlert(xhttp);
280
        } else if (xhttp.readyState == 4 && xhttp.status === 500) {
281
            if (typeof loaderDialogObj != "undefined") {
282
                loaderDialogObj.modal('hide');
283
                // $('div.modal-backdrop.fade').remove();
284
            }
285
            internalServerErrorAlert(xhttp);
286
        }
287
    };
288
    // Post data to URL which handles post request
289
    xhttp.open(httpType, urlString);
290
    if (httpType == "POST") {
291
        xhttp.setRequestHeader("Content-Type", "application/json");
292
    }
293
    // You should set responseType as blob for binary responses
294
    // xhttp.responseType = 'blob';
295
    xhttp.send(data);
23405 amit.gupta 296
}
30017 amit.gupta 297
 
27618 tejbeer 298
function loadPaginatedCatalogNextItems(url, params, paginatedIdentifier,
32301 amit.gupta 299
                                       tableIdentifier, detailsContainerIdentifier) {
300
    var start = $("#" + paginatedIdentifier + " .start").text();
23405 amit.gupta 301
 
32301 amit.gupta 302
    var end = $("#" + paginatedIdentifier + " .end").text();
27618 tejbeer 303
 
32301 amit.gupta 304
    url = context + url + "?offset=" + end;
27618 tejbeer 305
 
32301 amit.gupta 306
    if (params != null) {
307
        for (var key in params) {
308
            if (params.hasOwnProperty(key)) {
309
                //console.log(key + " -> " + params[key]);
310
                url = url + "&" + key + "=" + params[key];
311
            }
312
        }
313
    }
27618 tejbeer 314
 
32301 amit.gupta 315
    doGetAjaxRequestHandler(url, function (response) {
316
        var size = $("#" + paginatedIdentifier + " .size").text();
317
        if ((parseInt(end) + 20) > parseInt(size)) {
318
            // console.log("(end + 10) > size == true");
319
            $("#" + paginatedIdentifier + " .end").text(size);
320
        } else {
321
            // console.log("(end + 10) > size == false");
322
            $("#" + paginatedIdentifier + " .end").text(+end + +20);
323
        }
324
        $("#" + paginatedIdentifier + " .start").text(+start + +20);
325
        var last = $("#" + paginatedIdentifier + " .end").text();
326
        var temp = $("#" + paginatedIdentifier + " .size").text();
327
        console.log("last" + last);
328
        if (parseInt(last) >= parseInt(temp)) {
329
            $("#" + paginatedIdentifier + " .next").prop('disabled', true);
330
            // $( "#good-inventory-paginated .end" ).text(temp);
331
        }
332
        $('#' + tableIdentifier).html(response);
333
        if (detailsContainerIdentifier != null) {
334
            $('#' + detailsContainerIdentifier).html('');
335
        }
336
        $("#" + paginatedIdentifier + " .previous").prop('disabled', false);
337
    });
27618 tejbeer 338
 
339
}
30017 amit.gupta 340
 
27618 tejbeer 341
function loadPaginatedCatalogPreviousItem(url, params, paginatedIdentifier,
32301 amit.gupta 342
                                          tableIdentifier, detailsContainerIdentifier) {
343
    var start = $("#" + paginatedIdentifier + " .start").text();
33756 ranu 344
    //console.log("start" + start);
32301 amit.gupta 345
    var end = $("#" + paginatedIdentifier + " .end").text();
33756 ranu 346
    //console.log("Startend" + end);
32301 amit.gupta 347
    var size = $("#" + paginatedIdentifier + " .size").text();
33756 ranu 348
    //console.log("size" + size);
32301 amit.gupta 349
    if (parseInt(end) == parseInt(size) && parseInt(end) % 20 != 0) {
350
        var mod = parseInt(end) % 20;
351
        end = parseInt(end) + (20 - mod);
352
    }
353
    var pre = end - 20;
354
    var lat = pre - 20;
355
    //console.log("preCatalog" +pre);
27618 tejbeer 356
 
32301 amit.gupta 357
    url = context + url + "?offset=" + pre;
27618 tejbeer 358
 
32301 amit.gupta 359
    if (params != null) {
360
        for (var key in params) {
361
            if (params.hasOwnProperty(key)) {
362
                url = url + "&" + key + "=" + params[key];
363
            }
364
        }
365
    }
27618 tejbeer 366
 
32301 amit.gupta 367
    doGetAjaxRequestHandler(url, function (response) {
368
        $("#" + paginatedIdentifier + " .end").text(+end - +20);
369
        $("#" + paginatedIdentifier + " .start").text(+start - +20);
370
        $('#' + tableIdentifier).html(response);
371
        if (detailsContainerIdentifier != null) {
372
            $('#' + detailsContainerIdentifier).html('');
373
        }
374
        $("#" + paginatedIdentifier + " .next").prop('disabled', false);
375
        if (parseInt(lat) == 0) {
376
            $("#" + paginatedIdentifier + " .previous").prop('disabled', true);
377
        }
378
    });
27618 tejbeer 379
 
380
}
381
 
24595 tejbeer 382
function loadPaginatedNextItems(url, params, paginatedIdentifier,
32301 amit.gupta 383
                                tableIdentifier, detailsContainerIdentifier) {
384
    var start = $("#" + paginatedIdentifier + " .start").text();
385
    var end = $("#" + paginatedIdentifier + " .end").text();
386
    url = context + url + "?offset=" + end;
24595 tejbeer 387
 
32301 amit.gupta 388
    if (params != null) {
389
        for (var key in params) {
390
            if (params.hasOwnProperty(key)) {
391
                // console.log(key + " -> " + p[key]);
392
                url = url + "&" + key + "=" + params[key];
393
            }
394
        }
395
    }
24595 tejbeer 396
 
32301 amit.gupta 397
    doGetAjaxRequestHandler(url, function (response) {
398
        var size = $("#" + paginatedIdentifier + " .size").text();
399
        if ((parseInt(end) + 10) > parseInt(size)) {
400
            console.log("(end + 10) > size == true");
401
            $("#" + paginatedIdentifier + " .end").text(size);
402
        } else {
403
            console.log("(end + 10) > size == false");
404
            $("#" + paginatedIdentifier + " .end").text(+end + +10);
405
        }
406
        $("#" + paginatedIdentifier + " .start").text(+start + +10);
407
        var last = $("#" + paginatedIdentifier + " .end").text();
408
        var temp = $("#" + paginatedIdentifier + " .size").text();
409
        if (parseInt(last) >= parseInt(temp)) {
410
            $("#" + paginatedIdentifier + " .next").prop('disabled', true);
411
            // $( "#good-inventory-paginated .end" ).text(temp);
412
        }
413
        $('#' + tableIdentifier).html(response);
414
        if (detailsContainerIdentifier != null) {
415
            $('#' + detailsContainerIdentifier).html('');
416
        }
417
        $("#" + paginatedIdentifier + " .previous").prop('disabled', false);
418
    });
24595 tejbeer 419
 
23629 ashik.ali 420
}
23405 amit.gupta 421
 
24595 tejbeer 422
function loadPaginatedPreviousItems(url, params, paginatedIdentifier,
32301 amit.gupta 423
                                    tableIdentifier, detailsContainerIdentifier) {
424
    var start = $("#" + paginatedIdentifier + " .start").text();
425
    var end = $("#" + paginatedIdentifier + " .end").text();
426
    var size = $("#" + paginatedIdentifier + " .size").text();
427
    if (parseInt(end) == parseInt(size) && parseInt(end) % 10 != 0) {
428
        var mod = parseInt(end) % 10;
429
        end = parseInt(end) + (10 - mod);
430
    }
431
    var pre = end - 10;
24595 tejbeer 432
 
32301 amit.gupta 433
    url = context + url + "?offset=" + pre;
24595 tejbeer 434
 
32301 amit.gupta 435
    if (params != null) {
436
        for (var key in params) {
437
            if (params.hasOwnProperty(key)) {
438
                url = url + "&" + key + "=" + params[key];
439
            }
440
        }
441
    }
24595 tejbeer 442
 
32301 amit.gupta 443
    doGetAjaxRequestHandler(url, function (response) {
444
        $("#" + paginatedIdentifier + " .end").text(+end - +10);
445
        $("#" + paginatedIdentifier + " .start").text(+start - +10);
446
        $('#' + tableIdentifier).html(response);
447
        if (detailsContainerIdentifier != null) {
448
            $('#' + detailsContainerIdentifier).html('');
449
        }
450
        $("#" + paginatedIdentifier + " .next").prop('disabled', false);
451
        if (parseInt(pre) == 0) {
452
            $("#" + paginatedIdentifier + " .previous").prop('disabled', true);
453
        }
454
    });
24595 tejbeer 455
 
23629 ashik.ali 456
}
457
 
32308 amit.gupta 458
function numberToComma(x, rounded) {
32301 amit.gupta 459
    if (isNaN(x)) {
460
        x = x.replaceAll(",", '');
461
    }
462
    x = parseFloat(x);
32308 amit.gupta 463
    if (typeof rounded != "undefined" && rounded) {
464
        x = Math.round(x);
465
    } else {
466
        x = Math.round(x * 100) / 100;
467
    }
32301 amit.gupta 468
    x = x.toString();
469
    x = x.split('.');
470
    var x1 = x[0];
471
    var x2 = x.length > 1 && x[1] != '0' ? '.' + x[1] : '';
472
    var lastThree = x1.substring(x1.length - 3);
473
    var otherNumbers = x1.substring(0, x1.length - 3);
474
    if (x1.charAt(x1.length - 4) == ',' || x1.charAt(x1.length - 4) == '-') {
475
        console.log(lastThree)
476
    } else {
477
        if (otherNumbers != '')
478
            lastThree = ',' + lastThree;
479
    }
480
    return otherNumbers.replace(/\B(?=(\d{2})+(?!\d))/g, ",") + (lastThree)
481
        + x2;
24992 tejbeer 482
 
23786 amit.gupta 483
}
23870 amit.gupta 484
 
30599 amit.gupta 485
function getSingleDatePicker(startMoment) {
32301 amit.gupta 486
    var singleDatePicker = {
487
        "todayHighlight": true,
488
        "startDate": startMoment || moment(),
489
        "autoclose": true,
490
        "autoUpdateInput": true,
491
        "singleDatePicker": true,
492
        "locale": {
493
            'format': 'DD/MM/YYYY'
494
        }
495
    };
496
    return singleDatePicker;
23886 amit.gupta 497
}
498
 
30599 amit.gupta 499
function getDatesFromPicker(pickerElement) {
32301 amit.gupta 500
    return {
501
        startDate: $(pickerElement).data('daterangepicker').startDate.format(moment.HTML5_FMT.DATETIME_LOCAL_SECONDS),
502
        endDate: $(pickerElement).data('daterangepicker').endDate.format(moment.HTML5_FMT.DATETIME_LOCAL_SECONDS)
503
    }
30599 amit.gupta 504
}
505
 
506
function getReporticoDatesFromPicker(pickerElement) {
32301 amit.gupta 507
    let datePickerData = $(pickerElement).data('daterangepicker');
508
    let formattedEndDate = null;
509
    if (typeof datePickerData.endDate == "object") {
510
        formattedEndDate = datePickerData.endDate.format(moment.HTML5_FMT.DATE);
511
    }
512
    return {
513
        startDate: datePickerData.startDate.format(moment.HTML5_FMT.DATE),
514
        endDate: formattedEndDate
515
    };
30599 amit.gupta 516
}
517
 
33220 amit.gupta 518
function getStartOfFinancialYear(momentObj) {
519
    recentQuarter = momentObj.startOf('quarter').set('quarter', 2);
520
    return momentObj.quarter >= 2 ? recentQuarter : recentQuarter.subtract('year', 1);
521
}
30599 amit.gupta 522
 
33220 amit.gupta 523
function getStatementRanges() {
524
    return {
525
        ranges: {
526
            'This Month': [moment().startOf('month'), moment().startOf('day')],
527
            'Last Month': [moment().subtract(1, 'month').startOf('month'), moment().subtract(1,'month').endOf('month')],
528
            'Last 3 Months': [moment().subtract(3, 'month').startOf('month'), moment().subtract(1,'month').endOf('month')],
529
            'Last 6 Months': [moment().subtract(6, 'month').startOf('month'), moment().subtract(1,'month').endOf('month')],
530
            'Current Financial Year': [getStartOfFinancialYear(moment()), getStartOfFinancialYear(moment()).add('year', 1).subtract(1, 'day')],
531
            'Last Financial Year': [getStartOfFinancialYear(moment()).subtract('year', 1), getStartOfFinancialYear(moment()).subtract(1, 'day')]
532
        },
533
        alwaysShowCalendars: false,
534
        showCustomRangeLabel: false,
535
        showDropdowns: true,
536
        locale: {
537
            format: 'DD/MM/YYYY'
538
        }
539
    }
540
}
541
 
30599 amit.gupta 542
function getRangedDatePicker(showRanges, startMoment, endMoment) {
32301 amit.gupta 543
    if (typeof showRanges == "undefined") {
544
        showRanges = false;
545
    }
546
    var rangedDatePicker = {
547
        "todayHighlight": true,
33220 amit.gupta 548
        "showDropdowns": true,
32301 amit.gupta 549
        "opens": "right",
550
        "startDate": startMoment || moment().startOf('day'),
551
        "endDate": endMoment || moment().endOf('day'),
552
        "autoclose": true,
553
        "alwaysShowCalendars": false,
554
        "autoUpdateInput": true,
555
        "locale": {
556
            'format': 'DD/MM/YYYY'
557
        }
558
    };
559
    if (showRanges) {
560
        rangedDatePicker['ranges'] = {
561
            'Today': [moment(), moment()],
562
            'Yesterday': [moment().subtract(1, 'days'),
563
                moment().subtract(1, 'days')],
564
            'Last 7 Days': [moment().subtract(6, 'days'), moment()],
565
            'Last 30 Days': [moment().subtract(29, 'days'), moment()],
566
            'This Month': [moment().startOf('month'), moment().endOf('month')],
567
            'Last Month': [moment().subtract(1, 'month').startOf('month'),
568
                moment()],
569
            'Last 3 Months': [moment().subtract(3, 'month').startOf('month'),
570
                moment()],
571
            'Last 6 Months': [moment().subtract(6, 'month').startOf('month'),
572
                moment()]
573
        }
574
    }
575
    return rangedDatePicker;
23892 amit.gupta 576
}
30017 amit.gupta 577
 
23946 amit.gupta 578
function showPosition(position) {
32301 amit.gupta 579
    if (typeof latitude == "undefined") {
580
        var coords = {
581
            latitude: position.coords.latitude,
582
            longitude: position.coords.longitude
583
        }
584
        doAjaxRequestWithJsonHandler('partner/location', 'PUT', JSON
585
            .stringify(coords), function () {
586
            latitude = position.coords.latitude;
587
            longitude = position.coords.longitude;
588
        });
589
    }
590
    // distance = getDistance(latitude, longitude, position.coords.latitude,
591
    // position.coords.longitude);
24168 amit.gupta 592
}
593
 
24595 tejbeer 594
function getAuthorisedWarehouses(callback) {
32301 amit.gupta 595
    bootBoxObj = {
596
        size: "small",
597
        title: "Choose Warehouse",
598
        callback: callback,
599
        inputType: 'select',
600
        inputOptions: typeof inputOptions == "undefined" ? undefined
601
            : inputOptions
602
    }
603
    if (typeof inputOptions == "undefined") {
604
        doGetAjaxRequestHandler(context + "/authorisedWarehouses", function (
605
            response) {
606
            response = JSON.parse(response);
607
            inputOptions = [];
608
            response.forEach(function (warehouse) {
609
                inputOptions.push({
610
                    text: warehouse.name,
611
                    value: warehouse.id,
612
                });
613
            });
614
            bootBoxObj['inputOptions'] = inputOptions;
615
            bootbox.prompt(bootBoxObj);
616
        });
617
    } else if (inputOptions.length == 1) {
618
        callback(inputOptions[0].warehouse.id);
619
    } else {
620
        bootbox.prompt(bootBoxObj);
621
    }
24595 tejbeer 622
 
24176 amit.gupta 623
}
30017 amit.gupta 624
 
24410 amit.gupta 625
function getColorsForItems(catalogId, itemId, description, callback) {
32301 amit.gupta 626
    colorCheckboxHandler(catalogId, itemId, description, callback);
30017 amit.gupta 627
}
628
 
629
function colorNumberHandler(catalogId, itemId, title, actionText, callback) {
32301 amit.gupta 630
    doGetAjaxRequestHandler(context + "/itemsByCatalogId?catalogId="
631
        + catalogId + "&itemId=" + itemId, function (response) {
632
        let coloredItems = JSON.parse(response);
633
        let modalBody = [];
634
        coloredItems.forEach(function (item) {
635
            modalBody.push(`
30017 amit.gupta 636
                <div class="row">
637
                    <div class="col-sm-2">
638
                        ${item.color}
639
                    </div>
640
                    <div class="col-sm-2">
641
                            <input data-itemid="${item.id}" type="text" class="form-control" />
642
                    </div>
643
                </div>
644
            `);
32301 amit.gupta 645
        });
646
        let dialogBoxHtml = `<div class="modal modal" tabindex="-1" role="dialog">
30017 amit.gupta 647
                              <div class="modal-dialog" >
648
                                <div class="modal-content">
649
                                  <div class="modal-header">
650
                                    <h5 class="modal-title">${title}</h5>
651
                                  </div>
652
                                  <div class="modal-body">
653
                                        ${modalBody.join('')}
654
                                  </div>
655
                                  <div class="modal-footer">
656
                                    <button type="button" class="btn btn-primary number_dialog">${actionText}</button>
657
                                  </div>
658
                                </div>
659
                              </div>
660
                            </div>`;
32301 amit.gupta 661
        let $dialog = $(dialogBoxHtml);
662
        let modalObj = $dialog.modal('show');
663
        modalObj.on('hidden.bs.modal', function (e) {
664
            $dialog.remove();
665
        });
666
        $('button.number_dialog').on('click', function () {
667
            let itemQty = [];
668
            let anySelected = false;
669
            $(modalObj).find('.modal-body').find('input').each(function () {
670
                $input = $(this);
671
                if ($input.val() > 0) {
672
                    itemQty.push({
673
                        itemId: $input.data("itemid"),
674
                        quantity: $input.val()
675
                    });
676
                    anySelected = true;
677
                }
678
            });
679
            if (anySelected && confirm("Are you sure want to notify?")) {
680
                $that = $(this);
681
                callback(itemQty, function () {
682
                    $that.off('click');
683
                    modalObj.hide();
684
                });
685
            } else {
686
                alert("Pls mention quantity");
687
            }
688
        });
689
    });
30017 amit.gupta 690
}
691
 
692
 
30021 amit.gupta 693
function colorCheckboxHandler(catalogId, itemId, description, callback) {
32301 amit.gupta 694
    let bootBoxObj = {
695
        size: "small",
696
        className: "item-wrapper",
697
        title: description,
698
        callback: callback,
699
        inputType: 'checkbox',
700
    }
701
    doGetAjaxRequestHandler(context + "/itemsByCatalogId?catalogId="
702
        + catalogId + "&itemId=" + itemId, function (response) {
703
        coloredItems = JSON.parse(response);
704
        inputOptions = [{
705
            text: "All",
706
            value: "0",
707
            onclick: "toggleAll('itemIds')"
708
        }];
709
        coloredItems.forEach(function (item) {
710
            inputOptions.push({
711
                text: item.color,
712
                value: item.id,
713
                selected: item.active
714
            });
715
        });
716
        bootBoxObj['inputOptions'] = inputOptions;
717
        promptObj = bootbox.prompt(bootBoxObj);
718
        promptObj.modal('show')
719
        $('.item-wrapper').find("input[type='checkbox']").slice(1).each(
720
            function (index, checkbox) {
721
                checkbox.checked = coloredItems[index].active;
722
            });
723
    });
24406 amit.gupta 724
}
28055 tejbeer 725
 
726
function getHotdealsForItems(catalogId, itemId, description, callback) {
32301 amit.gupta 727
    bootBoxObj = {
728
        size: "small",
729
        className: "item-wrapper",
730
        title: description,
731
        callback: callback,
732
        inputType: 'checkbox',
733
    }
734
    doGetAjaxRequestHandler(context + "/hotdealsitemsByCatalogId?catalogId="
735
        + catalogId + "&itemId=" + itemId, function (response) {
736
        coloredItems = JSON.parse(response);
737
        inputOptions = [{
738
            text: "All",
739
            value: "0",
740
            onclick: "toggleAll('itemIds')"
741
        }];
742
        coloredItems.forEach(function (item) {
743
            inputOptions.push({
744
                text: item.color,
745
                value: item.id,
746
                selected: item.hotDeals
747
            });
748
        });
749
        bootBoxObj['inputOptions'] = inputOptions;
750
        promptObj = bootbox.prompt(bootBoxObj);
751
        promptObj.modal('show')
752
        $('.item-wrapper').find("input[type='checkbox']").slice(1).each(
753
            function (index, checkbox) {
754
                checkbox.checked = coloredItems[index].hotDeals;
755
            });
756
    });
28055 tejbeer 757
}
30017 amit.gupta 758
 
27763 tejbeer 759
$(document).on('change', ".item-wrapper input[type='checkbox']:first",
32301 amit.gupta 760
    function () {
761
        if (this.value == "0") {
762
            $(this).closest('.item-wrapper').find("input[type='checkbox']")
763
                .slice(1).prop('checked', $(this).prop('checked'));
764
        }
765
    });
30017 amit.gupta 766
 
27618 tejbeer 767
function getItemAheadOptions(jqElement, anyColor, callback) {
32301 amit.gupta 768
    console.log(anyColor)
769
    jqElement.typeahead('destroy').typeahead({
770
        source: function (q, process) {
771
            if (q.length >= 3) {
772
                return $.ajax(context + "/item?anyColor=" + anyColor, {
773
                    global: false,
774
                    data: {
775
                        query: q
776
                    },
777
                    success: function (data) {
778
                        queryData = JSON.parse(data);
779
                        process(queryData);
780
                    },
781
                });
782
            }
783
        },
784
        delay: 300,
785
        items: 20,
786
        displayText: function (item) {
787
            return item.itemDescription;
788
        },
789
        autoSelect: true,
790
        afterSelect: callback
791
    });
24176 amit.gupta 792
}
28795 tejbeer 793
 
794
 
32195 tejbeer 795
function getVendorItemAheadOptions(jqElement, vendorId, callback) {
32301 amit.gupta 796
    jqElement.typeahead('destroy').typeahead({
797
        source: function (q, process) {
798
            if (q.length >= 3) {
799
                return $.ajax(context + "/vendorItem?vendorId=" + vendorId, {
800
                    global: false,
801
                    data: {
802
                        query: q
803
                    },
804
                    success: function (data) {
805
                        queryData = JSON.parse(data);
806
                        process(queryData);
807
                    },
808
                });
809
            }
810
        },
811
        delay: 300,
812
        items: 20,
813
        displayText: function (item) {
814
            return item.itemDescription;
815
        },
816
        autoSelect: true,
817
        afterSelect: callback
818
    });
32195 tejbeer 819
}
820
 
28795 tejbeer 821
function getImeiAheadOptions(jqElement, fofoId, callback) {
32301 amit.gupta 822
    jqElement.typeahead('destroy').typeahead({
823
            source: function (q, process) {
824
                if (q.length >= 3) {
825
                    return $.ajax(context + "/imei?fofoId=" + fofoId, {
826
                        global: false,
827
                        data: {
828
                            query: q
829
                        },
830
                        success: function (data) {
831
                            queryData = JSON.parse(data);
832
                            process(queryData);
833
                        },
834
                    });
835
                }
836
            },
837
            delay: 300,
838
            items: 20,
839
            displayText: function (imei) {
840
                return imei;
841
            },
842
            autoSelect: true,
843
            afterSelect: callback
844
        }
845
    );
31762 tejbeer 846
}
847
 
848
 
849
function getAllImeiAheadOptions(jqElement, callback) {
32301 amit.gupta 850
    jqElement.typeahead('destroy').typeahead({
851
        source: function (q, process) {
852
            if (q.length >= 3) {
853
                return $.ajax(context + "/allimei", {
854
                    global: false,
855
                    data: {
856
                        query: q
857
                    },
858
                    success: function (data) {
859
                        queryData = JSON.parse(data);
860
                        process(queryData);
861
                    },
862
                });
863
            }
864
        },
865
        delay: 300,
866
        items: 20,
867
        displayText: function (imei) {
868
            return imei;
869
        },
870
        autoSelect: true,
871
        afterSelect: callback
872
    });
28795 tejbeer 873
}
874
 
875
 
25394 amit.gupta 876
function getEntityAheadOptions(jqElement, callback) {
32301 amit.gupta 877
    jqElement.typeahead('destroy').typeahead({
878
        source: function (q, process) {
879
            if (q.length >= 3) {
880
                return $.ajax(context + "/entity", {
881
                    global: false,
882
                    data: {
883
                        query: q
884
                    },
885
                    success: function (data) {
886
                        queryData = JSON.parse(data);
887
                        process(queryData);
888
                    },
889
                });
890
            }
891
        },
892
        delay: 300,
893
        items: 30,
894
        displayText: function (entity) {
895
            return entity.title_s + "(" + entity.catalogId_i + ")";
896
        },
897
        autoSelect: true,
898
        afterSelect: callback
899
    });
25394 amit.gupta 900
}
30017 amit.gupta 901
 
24349 amit.gupta 902
function getPartnerAheadOptions(jqElement, callback) {
32301 amit.gupta 903
    jqElement.typeahead('destroy').typeahead({
904
        source: function (q, process) {
905
            if (q.length >= 3) {
906
                return $.ajax(context + "/partners", {
907
                    global: false,
908
                    data: {
909
                        query: q
910
                    },
911
                    success: function (data) {
912
                        queryData = JSON.parse(data);
913
                        process(queryData);
914
                    },
915
                });
916
            }
917
        },
918
        delay: 300,
919
        items: 20,
920
        displayText: function (partner) {
921
            return partner.displayName;
922
        },
923
        autoSelect: true,
924
        afterSelect: callback
925
    });
24349 amit.gupta 926
}
24406 amit.gupta 927
 
32074 tejbeer 928
function getVendorAheadOptions(jqElement, callback) {
32301 amit.gupta 929
    jqElement.typeahead('destroy').typeahead({
930
        source: function (q, process) {
931
            if (q.length >= 3) {
932
                return $.ajax(context + "/vendors", {
933
                    global: false,
934
                    data: {
935
                        query: q
936
                    },
937
                    success: function (data) {
938
                        queryData = JSON.parse(data);
939
                        process(queryData);
940
                    },
941
                });
942
            }
943
        },
944
        delay: 300,
945
        items: 20,
946
        displayText: function (vendor) {
947
            return vendor.name;
948
        },
949
        autoSelect: true,
950
        afterSelect: callback
951
    });
32074 tejbeer 952
}
953
 
24595 tejbeer 954
function loadPriceDrop(domId) {
32301 amit.gupta 955
    doGetAjaxRequestHandler(context + "/getItemDescription",
956
        function (response) {
957
            $('#' + domId).html(response);
958
        });
24406 amit.gupta 959
}
30017 amit.gupta 960
 
32301 amit.gupta 961
$(document).on('click', ".price_drop", function () {
962
    loadPriceDrop("main-content");
24595 tejbeer 963
});
25649 tejbeer 964
 
27618 tejbeer 965
 
32301 amit.gupta 966
$(document).on('click', ".closed_pricedrop", function () {
967
    loadClosedPriceDrop("main-content");
28569 amit.gupta 968
});
969
 
970
function loadClosedPriceDrop(domId) {
32301 amit.gupta 971
    doGetAjaxRequestHandler(context + "/getClosedPricedropItemDescription",
972
        function (response) {
973
            $('#' + domId).html(response);
974
        });
28569 amit.gupta 975
}
976
 
27696 tejbeer 977
function notifyTypeChange(messageType, $container) {
32301 amit.gupta 978
    var messageQueryString = "?messageType=" + messageType;
979
    if (messageType == null) {
980
        messageQueryString = "";
981
    }
982
    doGetAjaxRequestHandler(context + "/notifications" + messageQueryString, function (response) {
983
        if ($container != null) {
984
            loaderDialogObj.one('hidden.bs.modal', function () {
985
                $container.popover({
986
                    container: $container,
987
                    template: '<div class="popover popover1" role="tooltip"><div class="arrow"></div><h3 class="popover-title"></h3><div class="popover-content popover2"></div></div>',
988
                    content: response,
989
                    html: true,
990
                    placement: "bottom",
991
                    trigger: "manual",
992
                    sanitize: false
993
                }).popover('show');
994
                setTimeout(function () {
995
                    $container.focus().one('blur', function () {
996
                        $container.popover('destroy');
997
                    });
998
                }, 100);
999
            });
1000
        }
1001
    });
25649 tejbeer 1002
}
25651 tejbeer 1003
 
25689 amit.gupta 1004
function downloadNotifyDocument(documentId, cid, documentName) {
32301 amit.gupta 1005
    doAjaxGetDownload(context + "/notifyDocument/download?cid=" + cid,
1006
        documentName);
25651 tejbeer 1007
}
28051 amit.gupta 1008
 
1009
 
1010
/* Create an array with the values of all the input boxes in a column */
32301 amit.gupta 1011
$.fn.dataTable.ext.order['dom-text'] = function (settings, col) {
1012
    return this.api().column(col, {order: 'index'}).nodes().map(function (td, i) {
1013
        return $('input', td).val();
1014
    });
28051 amit.gupta 1015
}
28795 tejbeer 1016
 
28063 amit.gupta 1017
/* Create an array with the values of all the input boxes in a column, parsed as numbers */
32301 amit.gupta 1018
$.fn.dataTable.ext.order['dom-text-numeric'] = function (settings, col) {
1019
    return this.api().column(col, {order: 'index'}).nodes().map(function (td, i) {
1020
        return $('input', td).val() * 1;
1021
    });
28051 amit.gupta 1022
}
28795 tejbeer 1023
 
32301 amit.gupta 1024
$.fn.dataTable.ext.order['dom-stock-numeric'] = function (settings, col) {
1025
    return this.api().column(col, {order: 'index'}).nodes().map(function (td, i) {
1026
        return $(td).html().split("/")[0] * 1;
1027
    });
28870 tejbeer 1028
}
28051 amit.gupta 1029
/* Create an array with the values of all the select options in a column */
32301 amit.gupta 1030
$.fn.dataTable.ext.order['dom-select'] = function (settings, col) {
1031
    return this.api().column(col, {order: 'index'}).nodes().map(function (td, i) {
1032
        return $('select', td).val();
1033
    });
28051 amit.gupta 1034
}
28795 tejbeer 1035
 
28051 amit.gupta 1036
/* Create an array with the values of all the checkboxes in a column */
32301 amit.gupta 1037
$.fn.dataTable.ext.order['dom-checkbox'] = function (settings, col) {
1038
    return this.api().column(col, {
1039
        order: 'index'
1040
    }).nodes().map(function (td, i) {
1041
        return $('input', td).prop('checked') ? '1' : '0';
1042
    });
30414 amit.gupta 1043
}
1044
 
32301 amit.gupta 1045
$.fn.dataTable.Api.register('sum()', function () {
1046
    return this.flatten().reduce(function (a, b) {
1047
        if (typeof a === 'string') {
1048
            a = a.replace(/[^\d.-]/g, '') * 1;
1049
            a = isNaN(a) ? 0 : a;
1050
        }
1051
        if (typeof b === 'string') {
1052
            b = b.replace(/[^\d.-]/g, '') * 1;
1053
            b = isNaN(b) ? 0 : b;
1054
        }
30414 amit.gupta 1055
 
32301 amit.gupta 1056
        return a + b;
1057
    }, 0);
30694 amit.gupta 1058
});
1059
 
1060
const debounce = (func, delay) => {
32301 amit.gupta 1061
    let debounceTimer
1062
    return function () {
1063
        const context = this
1064
        const args = arguments
1065
        clearTimeout(debounceTimer)
1066
        debounceTimer
1067
            = setTimeout(() => func.apply(context, args), delay)
1068
    }
30694 amit.gupta 1069
}
31687 amit.gupta 1070
 
32301 amit.gupta 1071
function parseDate(str) {
1072
    var m = str.match(/^(\d{1,2})[-/](\d{1,2})[-/](\d{4})$/);
1073
    return (m) ? new Date(m[3], m[2] - 1, m[1]) : null;
1074
}
31687 amit.gupta 1075
 
32130 amit.gupta 1076
function ExportToExcel(container, fn) {
32301 amit.gupta 1077
    let tableId = $(container).data('tableid');
1078
    var elt = document.getElementById(tableId);
33220 amit.gupta 1079
    console.log('elt', elt);
32301 amit.gupta 1080
    if ($.fn.DataTable.isDataTable(`#${tableId}`)) {
33220 amit.gupta 1081
        let dataTable = $(`#${tableId}`).DataTable();
1082
        dataTable.page.len(-1).draw();
1083
        elt = dataTable.table(0).container();
32301 amit.gupta 1084
    }
1085
    ExportTableToExcel(elt, fn);
31687 amit.gupta 1086
}
1087
 
32301 amit.gupta 1088
function ExportTableToExcel(tableElt, fn) {
1089
    $table = $(tableElt)
1090
    $table.find('td').each((index, value) => {
1091
        let $tdElement = $(value);
1092
        console.log($tdElement);
1093
        let parsedDate = parseDate($tdElement.html());
1094
        if (parsedDate != null) {
1095
            let days = Math.floor(parsedDate.getTime() / 86400 * 1000);
1096
            $tdElement.data('v', days);
1097
            $tdElement.data("t", "n");
1098
            $tdElement.data("z", "yyyy-mm-dd");
1099
        }
1100
    });
1101
    console.log($table.get(0))
1102
    var wb = XLSX.utils.table_to_book($table.get(0), {sheet: "sheet1"});
1103
    XLSX.writeFile(wb, fn + '.xlsx');
1104
}
31687 amit.gupta 1105
 
32301 amit.gupta 1106
 
1107
$(document).on('click', ".manage-pcm", function () {
1108
    managePCM();
31687 amit.gupta 1109
});
1110
 
1111
function managePCM() {
32301 amit.gupta 1112
    doGetAjaxRequestHandler(`${context}/brand-pcm`, function (response) {
1113
        $('#main-content').html(response);
1114
    });
31687 amit.gupta 1115
}
31786 tejbeer 1116
 
1117
 
32301 amit.gupta 1118
$(document).on('click', ".digify-retailer-login", function () {
31786 tejbeer 1119
 
32301 amit.gupta 1120
    doGetAjaxRequestHandler(context + "/digify/register", function (response) {
32074 tejbeer 1121
 
1122
 
32301 amit.gupta 1123
        $('#main-content').html(response);
32074 tejbeer 1124
 
32301 amit.gupta 1125
    });
1126
    //$('#main-content').html(`<iframe class="wrapper" src="${context}/digify/register" style="width:100%;height:100vh"> </iframe>`);
1127
    //$('#main-content').html(`<a class="wrapper" href="${context}/digify/register" target="_blank" style="width:100%;height:100vh"> </a>`);
32074 tejbeer 1128
 
31786 tejbeer 1129
});
31878 tejbeer 1130
 
32301 amit.gupta 1131
$(document).on('click', '.warehousewise_stock', function () {
1132
    doGetAjaxRequestHandler(`${context}/warehouse/stock-qty`, function (response) {
1133
        $('#main-content').html(response);
1134
    });
32130 amit.gupta 1135
});
31878 tejbeer 1136
 
32567 tejbeer 1137
function loadMainContent(htmlContent) {
1138
    $('#main-content').html(htmlContent);
1139
}
31878 tejbeer 1140
 
1141
 
32979 amit.gupta 1142
function jsonStartDate(dateInputString) {
33220 amit.gupta 1143
    if (dateInputString === '') return null;
33141 amit.gupta 1144
    return moment(dateInputString, "yyyy-MM-DD").format(moment.HTML5_FMT.DATETIME_LOCAL_SECONDS);
32979 amit.gupta 1145
}
33220 amit.gupta 1146
 
32979 amit.gupta 1147
function jsonEndDate(dateInputString) {
33220 amit.gupta 1148
    if (dateInputString === '') return null;
33141 amit.gupta 1149
    return moment(dateInputString, "yyyy-MM-DD").endOf('day').format(moment.HTML5_FMT.DATETIME_LOCAL_SECONDS);
32979 amit.gupta 1150
}
31878 tejbeer 1151
 
33167 amit.gupta 1152
function showToast(message) {
1153
    Toastify({
1154
        text: message,
1155
        duration: 3000, // 3 seconds
1156
        gravity: "top", // or "bottom"
1157
        position: "right", // "left", "center", "right"
1158
        backgroundColor: "green", // specify the background color
33400 ranu 1159
        offset: {
1160
            x: 20, // Horizontal margin from the right
1161
            y: 70 // Vertical margin from the top
1162
        }
33167 amit.gupta 1163
    }).showToast();
1164
}
31878 tejbeer 1165
 
33612 amit.gupta 1166
function loadHtml(html) {
1167
    $("#main-content").html(html);
1168
}
32130 amit.gupta 1169
 
33612 amit.gupta 1170
 
33508 tejus.loha 1171
function objectifyForm(formArray) {
1172
    //serialize data function
1173
    console.log('Row form  data ', formArray);
1174
    var returnArray = {};
1175
    for (var i = 0; i < formArray.length; i++) {
1176
        returnArray[formArray[i]['name']] = formArray[i]['value'].trim();
1177
    }
1178
    return returnArray;
1179
}
32567 tejbeer 1180
 
32979 amit.gupta 1181
 
33167 amit.gupta 1182
 
33508 tejus.loha 1183
 
1184