Subversion Repositories SmartDukaan

Rev

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

Rev 37003 Rev 37021
Line 77... Line 77...
77
        let endPoint = `${context}/downloadDateWiseLead?leadStatus=${status}&color=${color}&startDate=${startDate}&endDate=${endDate}`;
77
        let endPoint = `${context}/downloadDateWiseLead?leadStatus=${status}&color=${color}&startDate=${startDate}&endDate=${endDate}`;
78
        window.location.href = endPoint;
78
        window.location.href = endPoint;
79
 
79
 
80
    });
80
    });
81
 
81
 
82
    // Existing lead-table Search box: pressing Enter searches ALL leads (server-side) by
82
    // Lead-table Search box = GLOBAL partner search: matches ANY lead by name / mobile / outlet /
83
    // name / mobile / outlet / city, not just the rows already loaded. Typing still filters
83
    // city across ALL statuses and ALL dates (this year, last year, anytime) - not just the loaded
84
    // the loaded rows via DataTables; clearing the box removes the global results.
84
    // date-scoped rows. It searches AS YOU TYPE (debounced) so old partners surface without needing
-
 
85
    // to press Enter; Enter still triggers an immediate search. Results render into
-
 
86
    // #global-search-results above the date-scoped table.
-
 
87
    var leadGlobalSearchTimer = null;
-
 
88
 
-
 
89
    function runGlobalLeadSearch(term) {
-
 
90
        term = $.trim(term || "");
-
 
91
        if (term.length < 2) {
-
 
92
            $('#global-search-results').html("");
-
 
93
            return;
-
 
94
        }
-
 
95
        var safeTerm = $('<div>').text(term).html();
-
 
96
        doGetAjaxRequestHandler(context + "/globalLeadSearch?searchTerm=" + encodeURIComponent(term),
-
 
97
            function (response) {
-
 
98
                $('#global-search-results').html(
-
 
99
                    '<h4 style="margin:15px 0 8px;">Search results — all partners, any date '
-
 
100
                    + '<small class="text-muted">(matching "' + safeTerm + '")</small></h4>' + response);
-
 
101
            });
-
 
102
    }
-
 
103
 
85
    $(document).on('keydown', "#lead-table_filter input", function (e) {
104
    $(document).on('keydown', "#lead-table_filter input", function (e) {
86
        if (e.which === 13) {
105
        if (e.which === 13) {
87
            e.preventDefault();
106
            e.preventDefault();
88
            var term = $.trim($(this).val() || "");
107
            clearTimeout(leadGlobalSearchTimer);
89
            if (term === "") {
-
 
90
                $('#global-search-results').html("");
108
            runGlobalLeadSearch($(this).val());
91
                return;
-
 
92
            }
-
 
93
            doGetAjaxRequestHandler(context + "/globalLeadSearch?searchTerm=" + encodeURIComponent(term),
-
 
94
                function (response) {
-
 
95
                    $('#global-search-results').html(response);
-
 
96
                });
-
 
97
        }
109
        }
98
    });
110
    });
99
 
111
 
100
    $(document).on('input', "#lead-table_filter input", function () {
112
    $(document).on('input', "#lead-table_filter input", function () {
101
        if ($.trim($(this).val() || "") === "") {
113
        var term = $(this).val();
-
 
114
        clearTimeout(leadGlobalSearchTimer);
-
 
115
        leadGlobalSearchTimer = setTimeout(function () {
102
            $('#global-search-results').html("");
116
            runGlobalLeadSearch(term);
103
        }
117
        }, 350);
104
    });
118
    });
105
 
119
 
106
 
120
 
107
    $(document).on('click', ".visit-request-plan", function () {
121
    $(document).on('click', ".visit-request-plan", function () {
108
 
122