Rev 36668 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed
<section class="wrapper"><div class="row"><div class="col-lg-12"><h3 class="page-header"><i class="icon_document_alt"></i> BEAT PLAN — BULK UPLOAD</h3><ol class="breadcrumb"><li><i class="fa fa-home"></i><a href="${rc.contextPath}/dashboard">Home</a></li><li><i class="icon_document_alt"></i>Beat Plan Bulk Upload</li></ol></div></div><div class="row"><div class="col-lg-8"><div class="panel panel-default"><div class="panel-heading"><strong>Upload Beat Plans CSV</strong><a href="${rc.contextPath}/beatPlan/downloadTemplate" class="btn btn-xs btn-info pull-right">DownloadTemplate</a></div><div class="panel-body"><p style="margin-bottom:15px;color:#666;">Upload a CSV file to create beat plans and schedule them on the calendar in one go.<br>Each row defines one partner visit within a beat. Beats are grouped by <strong>beat_name +auth_user_id</strong>.</p><div class="well" style="background:#f9f9f9;"><strong>CSV Format (one row = one day):</strong><table class="table table-bordered table-condensed" style="margin-top:10px;font-size:12px;"><thead><tr style="background:#eee;"><th>beat_name</th><th>auth_user_id</th><th>start_date</th><th>day_number</th><th>partner_codes</th></tr></thead><tbody><tr><td>Jaipur East Route</td><td>280</td><td>2026-06-02</td><td>1</td><td>RJKAI1478,RJBUN1449,RJDEG1443</td></tr><tr><td>Jaipur East Route</td><td>280</td><td></td><td>2</td><td>RJALR1362,RJBTR1388</td></tr><tr><td>Jaipur East Route</td><td>280</td><td></td><td>3</td><td>RJRSD1518,RJSML356</td></tr><tr style="border-top:2px solid #ccc;"><td>Agra Circuit</td><td>145</td><td>2026-06-05</td><td>1</td><td>UPAGR101,UPAGR102,UPAGR103</td></tr></tbody></table><p style="font-size:11px;color:#888;"><strong>beat_name</strong>: Name for the beat — <strong>only needed on day 1</strong>. Leaveblank for day 2, 3 etc (auto-uses day 1's name). Extra spaces are normalizedautomatically.<br><strong>auth_user_id</strong>: ID of the sales user<br><strong>start_date</strong>: Start date (YYYY-MM-DD) — <strong>only needed on day 1</strong>.System auto-calculates day 2, 3 etc skipping holidays. Leave empty for unscheduled beat.<br><strong>day_number</strong>: Day within the beat (1, 2, 3...)<br><strong>partner_codes</strong>: Comma-separated partner codes for this day (in visitorder)<br><br>Multiple users & beats in one file — just use different auth_user_id.</p></div><form id="beat-bulk-form" enctype="multipart/form-data" style="margin-top:15px;"><div class="form-group"><label>Select CSV File</label><input type="file" id="beat-bulk-file" name="file" accept=".csv" class="form-control"></div><div class="checkbox" style="margin-bottom:10px;"><label><input type="checkbox" id="beat-bulk-include-sundays"> Include Sundays (don't skipSundays when scheduling)</label></div><button type="button" class="btn btn-primary beat-bulk-submit">Upload & Process</button></form><div id="beat-bulk-result" style="display:none;margin-top:15px;"></div></div></div></div></div></section><script>$(document).on('click', '.beat-bulk-submit', function () {var fileInput = document.getElementById('beat-bulk-file');if (!fileInput.files || !fileInput.files[0]) {alert('Please select a CSV file');return;}var formData = new FormData();formData.append('file', fileInput.files[0]);formData.append('includeSundays', $('#beat-bulk-include-sundays').is(':checked'));var $btn = $(this);$btn.prop('disabled', true).text('Processing...');$.ajax({url: context + '/beatPlan/bulkUploadProcess',type: 'POST',data: formData,processData: false,contentType: false,success: function (response) {$btn.prop('disabled', false).text('Upload & Process');var data = response.response || response;var html = '<div class="alert alert-' + (data.errors > 0 ? 'warning' : 'success') + '">';html += '<strong>Done!</strong> ' + data.beatsCreated + ' beat(s) created.';if (data.errors > 0) {html += ' ' + data.errors + ' error(s).';html += '<ul style="margin-top:8px;font-size:12px;">';(data.errorMessages || []).forEach(function (msg) {html += '<li>' + msg + '</li>';});html += '</ul>';}html += '</div>';$('#beat-bulk-result').html(html).show();},error: function (xhr) {$btn.prop('disabled', false).text('Upload & Process');$('#beat-bulk-result').html('<div class="alert alert-danger">Error: ' + (xhr.responseText || xhr.statusText) + '</div>').show();}});});</script>