Subversion Repositories SmartDukaan

Rev

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

Rev 36865 Rev 36962
Line 15... Line 15...
15
	days: [], // [{dayNumber, startLat, startLng, startName, visits:[], endAction, stayName, stayLat, stayLng, totalKm, totalMins}]
15
	days: [], // [{dayNumber, startLat, startLng, startName, visits:[], endAction, stayName, stayLat, stayLng, totalKm, totalMins}]
16
	partners: [],
16
	partners: [],
17
	calMonth: null,
17
	calMonth: null,
18
	calData: null,
18
	calData: null,
19
	calSelectedBeat: null,
19
	calSelectedBeat: null,
20
	calPickedDates: []
20
	calPickedDates: [],
-
 
21
	// L4+ operators may schedule a beat on today's date (set from the page).
-
 
22
	canScheduleToday: (typeof canScheduleToday !== 'undefined' && !!canScheduleToday)
21
};
23
};
22
 
24
 
23
var VISIT_MINS = 30;
25
var VISIT_MINS = 30;
24
var AVG_SPEED = 30;
26
var AVG_SPEED = 30;
25
var DAY_LIMIT = 540;
27
var DAY_LIMIT = 540;
Line 2379... Line 2381...
2379
        if (d.getMonth() !== startMonth) {
2381
        if (d.getMonth() !== startMonth) {
2380
            alert('Beat has ' + daysNeeded + ' days but only ' + dates.length + ' available days left in this month starting from ' + startDateStr + '. Try an earlier date.');
2382
            alert('Beat has ' + daysNeeded + ' days but only ' + dates.length + ' available days left in this month starting from ' + startDateStr + '. Try an earlier date.');
2381
            return null;
2383
            return null;
2382
		}
2384
		}
2383
 
2385
 
2384
        // Past dates — skip
2386
        // Past dates — skip. Today is skipped too, unless this is an L4+ operator.
2385
        var today = fmtDate(new Date());
2387
        var today = fmtDate(new Date());
2386
        if (ds <= today) {
2388
        if (ds < today || (ds === today && !state.canScheduleToday)) {
2387
            d.setDate(d.getDate() + 1);
2389
            d.setDate(d.getDate() + 1);
2388
            continue;
2390
            continue;
2389
        }
2391
        }
2390
 
2392
 
2391
        // Holidays — always skip
2393
        // Holidays — always skip
Line 2419... Line 2421...
2419
    return dates;
2421
    return dates;
2420
}
2422
}
2421
 
2423
 
2422
function isDateBlocked(ds) {
2424
function isDateBlocked(ds) {
2423
    var today = fmtDate(new Date());
2425
    var today = fmtDate(new Date());
2424
    if (ds <= today) return true; // past or today
2426
    if (ds < today) return true; // past
-
 
2427
    if (ds === today && !state.canScheduleToday) return true; // today blocked unless L4+
2425
    // Sundays NOT blocked — handled via confirm dialog instead
2428
    // Sundays NOT blocked — handled via confirm dialog instead
2426
    // Only block holidays
2429
    // Only block holidays
2427
    if (state.calData && state.calData.blockedDates) {
2430
    if (state.calData && state.calData.blockedDates) {
2428
        var blocked = state.calData.blockedDates;
2431
        var blocked = state.calData.blockedDates;
2429
        // blockedDates from server includes Sundays+holidays, but we only block holidays now
2432
        // blockedDates from server includes Sundays+holidays, but we only block holidays now