Subversion Repositories SmartDukaan

Rev

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

Rev 37021 Rev 37046
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
    // Lead-table Search boxes (top DataTables box + bottom mirror below the table/pagination) =
82
    // Lead-table Search box = GLOBAL partner search: matches ANY lead by name / mobile / outlet /
83
    // GLOBAL partner search: matches ANY lead by name / mobile / outlet / city across ALL statuses
83
    // city across ALL statuses and ALL dates (this year, last year, anytime) - not just the loaded
84
    // and ALL dates (this year, last year, anytime) - not just the loaded date-scoped rows. It
84
    // date-scoped rows. It searches AS YOU TYPE (debounced) so old partners surface without needing
85
    // searches AS YOU TYPE (debounced) so old partners surface without needing to press Enter;
85
    // to press Enter; Enter still triggers an immediate search. Results render into
86
    // Enter still triggers an immediate search. Results render into #global-search-results above
-
 
87
    // the date-scoped table; the view auto-scrolls there so a search from the bottom box is visible
86
    // #global-search-results above the date-scoped table.
88
    // without the user having to scroll back up manually.
-
 
89
    var LEAD_SEARCH_BOXES = "#lead-table_filter input, #lead-table-bottom-filter";
87
    var leadGlobalSearchTimer = null;
90
    var leadGlobalSearchTimer = null;
88
 
91
 
89
    function runGlobalLeadSearch(term) {
92
    function runGlobalLeadSearch(term) {
90
        term = $.trim(term || "");
93
        term = $.trim(term || "");
91
        if (term.length < 2) {
94
        if (term.length < 2) {
Line 96... Line 99...
96
        doGetAjaxRequestHandler(context + "/globalLeadSearch?searchTerm=" + encodeURIComponent(term),
99
        doGetAjaxRequestHandler(context + "/globalLeadSearch?searchTerm=" + encodeURIComponent(term),
97
            function (response) {
100
            function (response) {
98
                $('#global-search-results').html(
101
                $('#global-search-results').html(
99
                    '<h4 style="margin:15px 0 8px;">Search results — all partners, any date '
102
                    '<h4 style="margin:15px 0 8px;">Search results — all partners, any date '
100
                    + '<small class="text-muted">(matching "' + safeTerm + '")</small></h4>' + response);
103
                    + '<small class="text-muted">(matching "' + safeTerm + '")</small></h4>' + response);
-
 
104
                var resultsEl = document.getElementById('global-search-results');
-
 
105
                if (resultsEl) {
-
 
106
                    resultsEl.scrollIntoView({behavior: 'smooth', block: 'start'});
-
 
107
                }
101
            });
108
            });
102
    }
109
    }
103
 
110
 
104
    $(document).on('keydown', "#lead-table_filter input", function (e) {
111
    $(document).on('keydown', LEAD_SEARCH_BOXES, function (e) {
105
        if (e.which === 13) {
112
        if (e.which === 13) {
106
            e.preventDefault();
113
            e.preventDefault();
107
            clearTimeout(leadGlobalSearchTimer);
114
            clearTimeout(leadGlobalSearchTimer);
108
            runGlobalLeadSearch($(this).val());
115
            runGlobalLeadSearch($(this).val());
109
        }
116
        }
110
    });
117
    });
111
 
118
 
112
    $(document).on('input', "#lead-table_filter input", function () {
119
    $(document).on('input', LEAD_SEARCH_BOXES, function () {
113
        var term = $(this).val();
120
        var term = $(this).val();
114
        clearTimeout(leadGlobalSearchTimer);
121
        clearTimeout(leadGlobalSearchTimer);
115
        leadGlobalSearchTimer = setTimeout(function () {
122
        leadGlobalSearchTimer = setTimeout(function () {
116
            runGlobalLeadSearch(term);
123
            runGlobalLeadSearch(term);
117
        }, 350);
124
        }, 350);
118
    });
125
    });
119
 
126
 
-
 
127
    // Bottom box isn't a native DataTables filter element, so mirror it into the DataTable's own
-
 
128
    // search + keep both boxes showing the same value regardless of which one the user typed into.
-
 
129
    $(document).on('keyup input', '#lead-table-bottom-filter', function () {
-
 
130
        var term = $(this).val();
-
 
131
        $('#lead-table_filter input').val(term);
-
 
132
        if ($.fn.dataTable.isDataTable('#lead-table')) {
-
 
133
            $('#lead-table').DataTable().search(term).draw();
-
 
134
        }
-
 
135
    });
-
 
136
 
-
 
137
    $(document).on('keyup input', '#lead-table_filter input', function () {
-
 
138
        $('#lead-table-bottom-filter').val($(this).val());
-
 
139
    });
-
 
140
 
120
 
141
 
121
    $(document).on('click', ".visit-request-plan", function () {
142
    $(document).on('click', ".visit-request-plan", function () {
122
 
143
 
123
        doGetAjaxRequestHandler(context + "/visitPlan", function (response) {
144
        doGetAjaxRequestHandler(context + "/visitPlan", function (response) {
124
            $('#' + 'main-content').html(response);
145
            $('#' + 'main-content').html(response);