Subversion Repositories SmartDukaan

Rev

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

Rev 36741 Rev 36761
Line 478... Line 478...
478
 
478
 
479
 
479
 
480
    $(document).on('click', ".lead-edit-request",
480
    $(document).on('click', ".lead-edit-request",
481
        function () {
481
        function () {
482
 
482
 
-
 
483
            // Gate the assign/status submit on approved geo. Modal stays open so the
-
 
484
            // user can still work the other sub-forms (lead detail, etc.).
-
 
485
            var clickedBtn = $(this);
-
 
486
            if (clickedBtn.data('geoChecking')) return;
-
 
487
            clickedBtn.data('geoChecking', true);
-
 
488
            doAjaxRequestHandler(
-
 
489
                context + "/lead-geo/check/" + leadId,
-
 
490
                "GET",
-
 
491
                function (response) {
-
 
492
                    clickedBtn.removeData('geoChecking');
-
 
493
                    var hasGeo = response && response.response && response.response.hasApprovedGeo;
-
 
494
                    if (!hasGeo) {
-
 
495
                        alert('Live geo-location for this lead has not been approved yet. Please approve the geo-location before assigning / updating status.');
-
 
496
                        return;
-
 
497
                    }
-
 
498
                    submitLeadEdit();
-
 
499
                }
-
 
500
            );
-
 
501
        });
-
 
502
 
-
 
503
    function submitLeadEdit() {
483
 
504
 
484
            console.log(row);
505
            console.log(row);
485
            var rowIndex = $(this).closest('tr').prevAll().length;
-
 
486
            var remark = $('input[name="remark"]').val();
506
            var remark = $('input[name="remark"]').val();
487
            var assignTo = $("#assignTo").val();
507
            var assignTo = $("#assignTo").val();
488
            var editStatus = $("#editStatus").val();
508
            var editStatus = $("#editStatus").val();
489
            var city = $('input[name="editCity"]').val();
509
            var city = $('input[name="editCity"]').val();
490
            var state = $("#editState").val();
510
            var state = $("#editState").val();
Line 556... Line 576...
556
 
576
 
557
 
577
 
558
            if (editStatus == "followUp") {
578
            if (editStatus == "followUp") {
559
                leadActivityData['communicationType'] = communicationType
579
                leadActivityData['communicationType'] = communicationType
560
                var beatVal = $('#beatDate').val();
580
                var beatVal = $('#beatDate').val();
561
                if (beatVal) {
581
                // Gate: for followUp, the lead must land on an upcoming beat of the
562
                    // Scheduling by beat — derive schedule from the beat's planDate
582
                // assignee. If no beat is picked (or the assignee has no upcoming
563
                    // (default to noon) and forward the selection for both VISIT
583
                // beat slots at all), block the submit with a clear message.
564
                    // and TELEPHONIC so the lead lands on that beat's route.
584
                if (!beatVal) {
565
                    var beatDate = beatVal.split('|')[0];
585
                    var hasBadges = $('#beatBadges .beat-badge').length > 0;
566
                    leadActivityData['scheldule'] = beatDate + 'T12:00:00';
586
                    if (!hasBadges) {
567
                    leadActivityData['beatSelection'] = beatVal;
587
                        alert('No upcoming beat is available for this assignee. Cannot schedule the lead until they have a beat.');
568
                } else {
588
                    } else {
569
                    leadActivityData['scheldule'] = getDatesFromPicker('input[name="editScheduleTime"]').startDate
589
                        alert('Please select a beat date for the assignee before submitting.');
-
 
590
                    }
-
 
591
                    return;
570
                }
592
                }
-
 
593
                var beatDate = beatVal.split('|')[0];
-
 
594
                leadActivityData['scheldule'] = beatDate + 'T12:00:00';
-
 
595
                leadActivityData['beatSelection'] = beatVal;
571
            }
596
            }
572
 
597
 
573
            console.log(leadActivityData);
598
            console.log(leadActivityData);
574
            if (confirm("Are you sure you want to add lead!") == true) {
599
            if (confirm("Are you sure you want to add lead!") == true) {
575
                doPostAjaxRequestWithJsonHandler(context + "/editLead", JSON.stringify(leadActivityData), function (response) {
600
                doPostAjaxRequestWithJsonHandler(context + "/editLead", JSON.stringify(leadActivityData), function (response) {
Line 578... Line 603...
578
                    $('.modal-backdrop').remove();
603
                    $('.modal-backdrop').remove();
579
                    row.html(response);
604
                    row.html(response);
580
                });
605
                });
581
            }
606
            }
582
 
607
 
583
        });
608
    }
584
 
609
 
585
 
610
 
586
    $(document).on('click', ".show-partner-health",
611
    $(document).on('click', ".show-partner-health",
587
        function () {
612
        function () {
588
 
613
 
Line 825... Line 850...
825
        // Show communication type and schedule date
850
        // Show communication type and schedule date
826
        $("#communicationTypeSection").show();
851
        $("#communicationTypeSection").show();
827
        $("#editScheduleTime").show();
852
        $("#editScheduleTime").show();
828
        $("#beatDateSelection").hide();
853
        $("#beatDateSelection").hide();
829
 
854
 
830
        // Reset communication type and assignTo
855
        // Reset communication type only; preserve the assignee the user picked.
831
        $('#communicationType').val('');
856
        $('#communicationType').val('');
832
        $('#assignTo').val('');
-
 
833
        $('#assignTo option').show();
857
        $('#assignTo option').show();
834
 
858
 
835
        // Check if lead has approved geolocation to decide VISIT option
859
        // Check if lead has approved geolocation to decide VISIT option
836
        doAjaxRequestHandler(context + "/lead-geo/check/" + leadId, "GET", function (response) {
860
        doAjaxRequestHandler(context + "/lead-geo/check/" + leadId, "GET", function (response) {
837
            var hasGeo = response.response.hasApprovedGeo;
861
            var hasGeo = response.response.hasApprovedGeo;
Line 850... Line 874...
850
        $('#assignTo option').show();
874
        $('#assignTo option').show();
851
    }
875
    }
852
 
876
 
853
}
877
}
854
 
878
 
855
// Clicking or changing status with a pre-existing Assign To selection clears it,
-
 
856
// so the user must reconfirm the assignee for the new status (avoids stale assignment).
-
 
857
$(document).on('mousedown change', '#editStatus', function () {
-
 
858
    if ($('#assignTo').val()) {
-
 
859
        $('#assignTo').val('');
-
 
860
        $('#assignTo option').show();
-
 
861
        $('#beatDate').val('');
-
 
862
        $('#beatBadges').empty();
-
 
863
        $("#beatDateSelection").hide();
-
 
864
        $("#editScheduleTime").show();
-
 
865
    }
-
 
866
});
-
 
867
 
-
 
868
function loadLeadSearchInfo(search_text) {
879
function loadLeadSearchInfo(search_text) {
869
    loadSearchLead("main-content", search_text);
880
    loadSearchLead("main-content", search_text);
870
}
881
}
871
 
882
 
872
function loadTeamCommitment(domId) {
883
function loadTeamCommitment(domId) {