Subversion Repositories SmartDukaan

Rev

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

Rev 36716 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="dayViewStart" class="form-control input-sm" style="width:160px;">
16
            <input type="date" id="dayViewDate" class="form-control input-sm" style="width:160px;">
17
            <label style="margin:0;">To:</label>
-
 
18
            <input type="date" id="dayViewEnd" class="form-control input-sm" style="width:160px;">
-
 
19
            <button class="btn btn-primary btn-sm" id="dayViewLoad">Load</button>
17
            <button class="btn btn-primary btn-sm" id="dayViewLoad">Load</button>
20
            <span id="dayViewSummary" style="color:#777; font-size:12px; margin-left:10px;"></span>
18
            <span id="dayViewSummary" style="color:#777; font-size:12px; margin-left:10px;"></span>
21
        </div>
19
        </div>
22
    </div>
20
    </div>
23
 
21
 
Line 49... Line 47...
49
</section>
47
</section>
50
 
48
 
51
 
49
 
52
<script>
50
<script>
53
    (function () {
51
    (function () {
54
        // Default: today → today + 7 days
52
        // Default: today only. Other dates → use the per-user calendar from the row's View button.
55
        var today = new Date();
53
        var today = new Date();
56
        var week = new Date();
-
 
57
        week.setDate(today.getDate() + 7);
-
 
58
 
54
 
59
        function fmt(d) {
55
        function fmt(d) {
60
            return d.getFullYear() + '-' + ('0' + (d.getMonth() + 1)).slice(-2) + '-' + ('0' + d.getDate()).slice(-2);
56
            return d.getFullYear() + '-' + ('0' + (d.getMonth() + 1)).slice(-2) + '-' + ('0' + d.getDate()).slice(-2);
61
        }
57
        }
62
 
58
 
63
        $('#dayViewStart').val(fmt(today));
59
        $('#dayViewDate').val(fmt(today));
64
        $('#dayViewEnd').val(fmt(week));
-
 
65
        loadDayView();
60
        loadDayView();
66
    })();
61
    })();
67
 
62
 
68
    $(document).on('click', '#dayViewLoad', function () {
63
    $(document).on('click', '#dayViewLoad', function () {
69
        loadDayView();
64
        loadDayView();
70
    });
65
    });
71
 
66
 
72
    function loadDayView() {
67
    function loadDayView() {
73
        var s = $('#dayViewStart').val();
68
        var d = $('#dayViewDate').val();
74
        var e = $('#dayViewEnd').val();
-
 
75
        if (!s || !e) {
69
        if (!d) {
76
            alert('Pick a date range');
70
            alert('Pick a date');
77
            return;
71
            return;
78
        }
72
        }
79
        $('#dayViewRows').html('<tr><td colspan="8" style="text-align:center;">Loading...</td></tr>');
73
        $('#dayViewRows').html('<tr><td colspan="8" style="text-align:center;">Loading...</td></tr>');
80
        $('#dayViewSummary').text('');
74
        $('#dayViewSummary').text('');
81
        $.get(context + '/beatPlan/scheduledList', {startDate: s, endDate: e}).done(function (r) {
75
        $.get(context + '/beatPlan/scheduledList', {startDate: d, endDate: d}).done(function (r) {
82
            var data = r.response || r;
76
            var data = r.response || r;
83
            renderDayViewRows(data.rows || []);
77
            renderDayViewRows(data.rows || []);
84
            $('#dayViewSummary').text(data.rows.length + ' beats scheduled between ' + data.startDate + ' and ' + data.endDate);
78
            $('#dayViewSummary').text((data.rows || []).length + ' beats scheduled on ' + data.startDate);
85
        }).fail(function (xhr) {
79
        }).fail(function (xhr) {
86
            $('#dayViewRows').html('<tr><td colspan="8" style="color:#d9534f; text-align:center;">Error: ' + (xhr.responseText || xhr.statusText) + '</td></tr>');
80
            $('#dayViewRows').html('<tr><td colspan="8" style="color:#d9534f; text-align:center;">Error: ' + (xhr.responseText || xhr.statusText) + '</td></tr>');
87
        });
81
        });
88
    }
82
    }
89
 
83