nodebb-plugin-onekite-calendar 2.0.77 → 2.0.79
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/api.js
CHANGED
|
@@ -1404,7 +1404,6 @@ api.createReservation = async function (req, res) {
|
|
|
1404
1404
|
try {
|
|
1405
1405
|
const notifyGroups = normalizeAllowedGroups(settings.notifyGroups);
|
|
1406
1406
|
if (notifyGroups.length) {
|
|
1407
|
-
const requester = await user.getUserFields(uid, ['username', 'email']);
|
|
1408
1407
|
const itemsLabel = (resv.itemNames || []).join(', ');
|
|
1409
1408
|
for (const g of notifyGroups) {
|
|
1410
1409
|
const members = await getMembersByGroupIdentifier(g);
|
|
@@ -1436,15 +1435,14 @@ api.createReservation = async function (req, res) {
|
|
|
1436
1435
|
await sendEmail('calendar-onekite_pending', u, 'Location matériel - Demande de réservation', {
|
|
1437
1436
|
uid: u,
|
|
1438
1437
|
username: md && md.username ? md.username : '',
|
|
1439
|
-
requester:
|
|
1438
|
+
requester: targetUsername,
|
|
1439
|
+
createdBy: isForSelf ? '' : (creatorUsername || ''),
|
|
1440
1440
|
itemName: itemsLabel,
|
|
1441
1441
|
itemNames: resv.itemNames || [],
|
|
1442
1442
|
dateRange: `Du ${formatFR(start)} au ${formatFR(end)}`,
|
|
1443
1443
|
start: formatFR(start),
|
|
1444
1444
|
end: formatFR(end),
|
|
1445
1445
|
total: resv.total || 0,
|
|
1446
|
-
// Link to the plugin ACP page so managers can process the request quickly.
|
|
1447
|
-
// Kept as `adminUrl` to match the email template placeholder.
|
|
1448
1446
|
adminUrl: `${forumBaseUrl()}/admin/plugins/calendar-onekite`,
|
|
1449
1447
|
});
|
|
1450
1448
|
}
|
|
@@ -1455,6 +1453,23 @@ api.createReservation = async function (req, res) {
|
|
|
1455
1453
|
console.warn('[calendar-onekite] Failed to send pending email', e && e.message ? e.message : e);
|
|
1456
1454
|
}
|
|
1457
1455
|
|
|
1456
|
+
// Notify target user when a validator created the reservation on their behalf
|
|
1457
|
+
if (!isForSelf) {
|
|
1458
|
+
try {
|
|
1459
|
+
await sendEmail('calendar-onekite_pending_for_you', targetUid, 'Location matériel - Demande créée en votre nom', {
|
|
1460
|
+
uid: targetUid,
|
|
1461
|
+
username: targetUsername,
|
|
1462
|
+
createdBy: creatorUsername,
|
|
1463
|
+
itemName: (resv.itemNames || []).join(', '),
|
|
1464
|
+
itemNames: resv.itemNames || [],
|
|
1465
|
+
dateRange: `Du ${formatFR(start)} au ${formatFR(end)}`,
|
|
1466
|
+
total: resv.total || 0,
|
|
1467
|
+
});
|
|
1468
|
+
} catch (e) {
|
|
1469
|
+
console.warn('[calendar-onekite] Failed to send pending_for_you email', e && e.message ? e.message : e);
|
|
1470
|
+
}
|
|
1471
|
+
}
|
|
1472
|
+
|
|
1458
1473
|
// Discord webhook (optional)
|
|
1459
1474
|
try {
|
|
1460
1475
|
await discord.notifyReservationRequested(settings, {
|
|
@@ -1471,6 +1486,24 @@ api.createReservation = async function (req, res) {
|
|
|
1471
1486
|
|
|
1472
1487
|
}
|
|
1473
1488
|
|
|
1489
|
+
// When a validator explicitly regularizes a reservation for another user (directly paid,
|
|
1490
|
+
// no HelloAsso), the main notification block is skipped. Still notify the target user.
|
|
1491
|
+
if (isRegularization && !isForSelf) {
|
|
1492
|
+
try {
|
|
1493
|
+
await sendEmail('calendar-onekite_paid', targetUid, 'Location matériel - Réservation confirmée', {
|
|
1494
|
+
uid: targetUid,
|
|
1495
|
+
username: targetUsername,
|
|
1496
|
+
itemName: (resv.itemNames || []).join(', '),
|
|
1497
|
+
itemNames: resv.itemNames || [],
|
|
1498
|
+
dateRange: `Du ${formatFR(start)} au ${formatFR(end)}`,
|
|
1499
|
+
icsUrl: '',
|
|
1500
|
+
googleCalUrl: '',
|
|
1501
|
+
});
|
|
1502
|
+
} catch (e) {
|
|
1503
|
+
console.warn('[calendar-onekite] Failed to send regularization paid email', e && e.message ? e.message : e);
|
|
1504
|
+
}
|
|
1505
|
+
}
|
|
1506
|
+
|
|
1474
1507
|
res.json({ ok: true, rid, status: resv.status, autoPaid: isAutoPaid });
|
|
1475
1508
|
};
|
|
1476
1509
|
|
package/package.json
CHANGED
package/public/client.js
CHANGED
|
@@ -1241,7 +1241,10 @@ function toDatetimeLocalValue(date) {
|
|
|
1241
1241
|
<div class="mb-2" id="onekite-period"><strong>Période</strong><br>${formatDt(start)} → ${formatDt(endDisplay)} <span class="text-muted" id="onekite-days">(${days} jour${days > 1 ? 's' : ''})</span></div>
|
|
1242
1242
|
${shortcutsHtml}
|
|
1243
1243
|
${forUserHtml}
|
|
1244
|
-
<div class="mb-
|
|
1244
|
+
<div class="mb-1"><strong>Matériel</strong></div>
|
|
1245
|
+
<div class="mb-2">
|
|
1246
|
+
<input type="text" id="onekite-item-search" class="form-control form-control-sm" placeholder="Rechercher un matériel…" autocomplete="off">
|
|
1247
|
+
</div>
|
|
1245
1248
|
<div id="onekite-items" class="mb-2" style="max-height: 320px; overflow: auto; border: 1px solid var(--bs-border-color, #ddd); border-radius: 6px; padding: 6px;">
|
|
1246
1249
|
${rows}
|
|
1247
1250
|
</div>
|
|
@@ -1359,6 +1362,17 @@ function toDatetimeLocalValue(date) {
|
|
|
1359
1362
|
document.querySelectorAll('.onekite-item-cb').forEach(cb => cb.addEventListener('change', refreshTotal));
|
|
1360
1363
|
refreshTotal();
|
|
1361
1364
|
|
|
1365
|
+
const searchEl = document.getElementById('onekite-item-search');
|
|
1366
|
+
if (searchEl) {
|
|
1367
|
+
searchEl.addEventListener('input', () => {
|
|
1368
|
+
const q = searchEl.value.trim().toLowerCase();
|
|
1369
|
+
document.querySelectorAll('#onekite-items [data-itemid]').forEach((row) => {
|
|
1370
|
+
const name = ((row.querySelector('input.onekite-item-cb') || {}).getAttribute('data-name') || '').toLowerCase();
|
|
1371
|
+
row.style.display = (!q || name.includes(q)) ? '' : 'none';
|
|
1372
|
+
});
|
|
1373
|
+
});
|
|
1374
|
+
}
|
|
1375
|
+
|
|
1362
1376
|
// Duration shortcuts (single-day selections): update end/days + refresh blocked items
|
|
1363
1377
|
const shortcutsWrap = document.getElementById('onekite-duration-shortcuts');
|
|
1364
1378
|
if (shortcutsWrap) {
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
<p>Bonjour {username},</p>
|
|
2
|
+
<p>Une demande de réservation de matériel a été créée en votre nom par {createdBy}.</p>
|
|
3
|
+
|
|
4
|
+
<p><strong>Matériel</strong></p>
|
|
5
|
+
<ul>
|
|
6
|
+
<!-- BEGIN itemNames -->
|
|
7
|
+
<li>{itemNames}</li>
|
|
8
|
+
<!-- END itemNames -->
|
|
9
|
+
</ul>
|
|
10
|
+
|
|
11
|
+
<p>{dateRange}</p>
|
|
12
|
+
|
|
13
|
+
<p><strong>Total estimé :</strong> {total} €</p>
|
|
14
|
+
|
|
15
|
+
<p>Vous recevrez un email avec les instructions de paiement une fois la demande validée par un responsable.</p>
|