| Line 220... |
Line 220... |
| 220 |
// (project standard — same as today-offer.vm, lead.vm, etc.) after render.
|
220 |
// (project standard — same as today-offer.vm, lead.vm, etc.) after render.
|
| 221 |
// In-beat parties are filtered out of the list entirely, so only non-beat
|
221 |
// In-beat parties are filtered out of the list entirely, so only non-beat
|
| 222 |
// (extra-visit) parties show up here. existingAgendas[] is pre-selected for
|
222 |
// (extra-visit) parties show up here. existingAgendas[] is pre-selected for
|
| 223 |
// parties that already have a saved visit today (so editing existing ones works).
|
223 |
// parties that already have a saved visit today (so editing existing ones works).
|
| 224 |
function agendaSelectHtml(p) {
|
224 |
function agendaSelectHtml(p) {
|
| - |
|
225 |
// The dropdown offers ONLY manual-assignable agendas (Brand addition,
|
| - |
|
226 |
// System training, New Stock Payment). Auto agendas cannot be assigned
|
| - |
|
227 |
// by the planner — they surface as chips below and the server weaves
|
| - |
|
228 |
// them into task_name on submit automatically.
|
| 225 |
var preset = {};
|
229 |
var preset = {};
|
| 226 |
(p.existingAgendas || []).forEach(function (a) {
|
230 |
(p.existingAgendas || []).forEach(function (a) {
|
| 227 |
preset[a] = true;
|
231 |
preset[a] = true;
|
| 228 |
});
|
232 |
});
|
| 229 |
// Open agenda instances: pre-select them too; AUTO ones get a gear
|
- |
|
| 230 |
// suffix so the planner can tell system-raised agendas from manual picks.
|
- |
|
| 231 |
var autoBadge = {};
|
- |
|
| 232 |
(p.openAgendas || []).forEach(function (oa) {
|
- |
|
| 233 |
preset[oa.label] = true;
|
- |
|
| 234 |
if (oa.source === 'AUTO') autoBadge[oa.label] = true;
|
- |
|
| 235 |
});
|
- |
|
| 236 |
var html = '<select multiple class="av-party-agenda"'
|
233 |
var html = '<select multiple class="av-party-agenda"'
|
| 237 |
+ ' data-fofoid="' + p.fofoStoreId + '">';
|
234 |
+ ' data-fofoid="' + p.fofoStoreId + '">';
|
| 238 |
avContext.agendaOptions.forEach(function (opt) {
|
235 |
avContext.agendaOptions.forEach(function (opt) {
|
| 239 |
html += '<option value="' + opt + '"' + (preset[opt] ? ' selected' : '') + '>'
|
236 |
html += '<option value="' + opt + '"' + (preset[opt] ? ' selected' : '') + '>' + opt + '</option>';
|
| 240 |
+ opt + (autoBadge[opt] ? ' ⚙' : '') + '</option>';
|
- |
|
| 241 |
});
|
237 |
});
|
| 242 |
html += '</select>';
|
238 |
html += '</select>';
|
| 243 |
// Open-instance chips: AUTO = gear (metric-closed only), MANUAL = closable ✕.
|
239 |
// Open-instance chips: AUTO = gear (metric-closed only), MANUAL = closable ✕.
|
| 244 |
var chips = '';
|
240 |
var chips = '';
|
| 245 |
(p.openAgendas || []).forEach(function (oa) {
|
241 |
(p.openAgendas || []).forEach(function (oa) {
|
| Line 414... |
Line 410... |
| 414 |
var missing = 0;
|
410 |
var missing = 0;
|
| 415 |
$('.av-party-chk:checked').each(function () {
|
411 |
$('.av-party-chk:checked').each(function () {
|
| 416 |
var fid = parseInt($(this).data('fofoid'));
|
412 |
var fid = parseInt($(this).data('fofoid'));
|
| 417 |
var agendas = $('.av-party-agenda[data-fofoid="' + fid + '"]').val() || [];
|
413 |
var agendas = $('.av-party-agenda[data-fofoid="' + fid + '"]').val() || [];
|
| 418 |
var description = ($('.av-party-desc[data-fofoid="' + fid + '"]').val() || '').trim();
|
414 |
var description = ($('.av-party-desc[data-fofoid="' + fid + '"]').val() || '').trim();
|
| - |
|
415 |
// A row with open (auto) agendas is already covered — the server
|
| - |
|
416 |
// weaves those into the visit; "missing" = neither picked nor open.
|
| - |
|
417 |
var party = (avContext.allParties || []).filter(function (x) { return x.fofoStoreId === fid; })[0];
|
| - |
|
418 |
var openCount = party && party.openAgendas ? party.openAgendas.length : 0;
|
| 419 |
if (agendas.length === 0) missing++;
|
419 |
if (agendas.length === 0 && openCount === 0) missing++;
|
| 420 |
picks.push({
|
420 |
picks.push({
|
| 421 |
fofoStoreId: fid,
|
421 |
fofoStoreId: fid,
|
| 422 |
outletName: $(this).data('name'),
|
422 |
outletName: $(this).data('name'),
|
| 423 |
latitude: $(this).data('lat') ? String($(this).data('lat')) : null,
|
423 |
latitude: $(this).data('lat') ? String($(this).data('lat')) : null,
|
| 424 |
longitude: $(this).data('lng') ? String($(this).data('lng')) : null,
|
424 |
longitude: $(this).data('lng') ? String($(this).data('lng')) : null,
|