Subversion Repositories SmartDukaan

Rev

Rev 36740 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 36740 Rev 36761
Line 10... Line 10...
10
        </div>
10
        </div>
11
    </div>
11
    </div>
12
 
12
 
13
    <div class="row" style="margin-bottom:10px;">
13
    <div class="row" style="margin-bottom:10px;">
14
        <div class="col-lg-12" style="display:flex; gap:10px; align-items:center; flex-wrap:wrap;">
14
        <div class="col-lg-12" style="display:flex; gap:10px; align-items:center; flex-wrap:wrap;">
15
            <label style="margin:0;">From:</label>
15
            <label style="margin:0;">Date:</label>
16
            <input type="date" id="defStart" class="form-control input-sm" style="width:160px;">
16
            <input type="date" id="defDate" class="form-control input-sm" style="width:160px;">
17
            <label style="margin:0;">To:</label>
-
 
18
            <input type="date" id="defEnd" class="form-control input-sm" style="width:160px;">
-
 
19
            <button class="btn btn-primary btn-sm" id="defLoad">Load</button>
17
            <button class="btn btn-primary btn-sm" id="defLoad">Load</button>
20
            <span id="defSummary" style="color:#777; font-size:12px; margin-left:10px;"></span>
18
            <span id="defSummary" style="color:#777; font-size:12px; margin-left:10px;"></span>
21
        </div>
19
        </div>
22
    </div>
20
    </div>
23
 
21
 
Line 37... Line 35...
37
                        <th>Action</th>
35
                        <th>Action</th>
38
                    </tr>
36
                    </tr>
39
                    </thead>
37
                    </thead>
40
                    <tbody id="defRows">
38
                    <tbody id="defRows">
41
                    <tr>
39
                    <tr>
42
                        <td colspan="8" style="text-align:center; color:#999;">Pick a date range and click Load.</td>
40
                        <td colspan="8" style="text-align:center; color:#999;">Pick a date and click Load.</td>
43
                    </tr>
41
                    </tr>
44
                    </tbody>
42
                    </tbody>
45
                </table>
43
                </table>
46
            </div>
44
            </div>
47
        </div>
45
        </div>
Line 67... Line 65...
67
</div>
65
</div>
68
 
66
 
69
<script>
67
<script>
70
    (function () {
68
    (function () {
71
        var d = new Date();
69
        var d = new Date();
72
        var from = new Date();
-
 
73
        from.setDate(d.getDate() - 7);
-
 
74
 
70
 
75
        function fmt(x) {
71
        function fmt(x) {
76
            return x.getFullYear() + '-' + ('0' + (x.getMonth() + 1)).slice(-2) + '-' + ('0' + x.getDate()).slice(-2);
72
            return x.getFullYear() + '-' + ('0' + (x.getMonth() + 1)).slice(-2) + '-' + ('0' + x.getDate()).slice(-2);
77
        }
73
        }
78
 
74
 
79
        $('#defStart').val(fmt(from));
-
 
80
        $('#defEnd').val(fmt(d));
75
        $('#defDate').val(fmt(d));
81
        loadDeferred();
76
        loadDeferred();
82
    })();
77
    })();
83
 
78
 
84
    $(document).on('click', '#defLoad', function () {
79
    $(document).on('click', '#defLoad', function () {
85
        loadDeferred();
80
        loadDeferred();
86
    });
81
    });
87
 
82
 
88
    function loadDeferred() {
83
    function loadDeferred() {
89
        var s = $('#defStart').val(), e = $('#defEnd').val();
84
        var d = $('#defDate').val();
90
        if (!s || !e) {
85
        if (!d) {
91
            alert('Pick a date range');
86
            alert('Pick a date');
92
            return;
87
            return;
93
        }
88
        }
94
        $('#defRows').html('<tr><td colspan="8" style="text-align:center;">Loading...</td></tr>');
89
        $('#defRows').html('<tr><td colspan="8" style="text-align:center;">Loading...</td></tr>');
95
        $('#defSummary').text('');
90
        $('#defSummary').text('');
96
        $.get(context + '/beatPlan/deferred', {startDate: s, endDate: e}).done(function (r) {
91
        $.get(context + '/beatPlan/deferred', {startDate: d, endDate: d}).done(function (r) {
97
            var data = r.response || r;
92
            var data = r.response || r;
98
            renderDeferredRows(data.rows || []);
93
            renderDeferredRows(data.rows || []);
99
            $('#defSummary').text((data.rows || []).length + ' deferred between ' + data.startDate + ' and ' + data.endDate);
94
            $('#defSummary').text((data.rows || []).length + ' deferred on ' + data.startDate);
100
        }).fail(function (xhr) {
95
        }).fail(function (xhr) {
101
            $('#defRows').html('<tr><td colspan="8" style="color:#d9534f; text-align:center;">Error: ' + (xhr.responseText || xhr.statusText) + '</td></tr>');
96
            $('#defRows').html('<tr><td colspan="8" style="color:#d9534f; text-align:center;">Error: ' + (xhr.responseText || xhr.statusText) + '</td></tr>');
102
        });
97
        });
103
    }
98
    }
104
 
99
 
105
    function renderDeferredRows(rows) {
100
    function renderDeferredRows(rows) {
106
        if (!rows || rows.length === 0) {
101
        if (!rows || rows.length === 0) {
107
            $('#defRows').html('<tr><td colspan="8" style="text-align:center; color:#999;">No deferred items in this range.</td></tr>');
102
            $('#defRows').html('<tr><td colspan="8" style="text-align:center; color:#999;">No deferred items on this date.</td></tr>');
108
            return;
103
            return;
109
        }
104
        }
110
        var html = '';
105
        var html = '';
111
        rows.forEach(function (r) {
106
        rows.forEach(function (r) {
112
            // "Auto-covered" = the same partner is on an upcoming beat run. Just a
107
            // "Auto-covered" = the same partner is on an upcoming beat run. Just a