- // update actual inscriptions
- $updated = false;
- $total = 0;
- $paid = $evt['paid'] ? $evt['paid'] : 0;
- $telepaid = $evt['telepaid'] ? $evt['telepaid'] : 0;
- $paid_inserted = false;
- foreach ($subs as $j => $nb) {
- if ($nb >= 0) {
- XDB::execute('INSERT INTO group_event_participants (eid, uid, item_id, nb, flags, paid)
- VALUES ({?}, {?}, {?}, {?}, {?}, {?})
- ON DUPLICATE KEY UPDATE nb = VALUES(nb), flags = VALUES(flags), paid = VALUES(paid)',
- $eid, S::v('uid'), $j, $nb, (Env::has('notify_payment') ? 'notify_payment' : ''),
- ((!$paid_inserted) ? $paid - $telepaid : 0));
- $updated = $eid;
- $paid_inserted = true;
+ // count what the user must pay, and what he manually paid
+ $manual_paid = 0;
+ foreach ($items as $item_id => $item) {
+ if (array_key_exists($item_id, $old_subs)) {
+ $manual_paid += $old_subs[$item_id]['paid'];
+ }
+ }
+ // impossible to unsubscribe if you already paid sthing
+ if (!array_sum($subs) && $manual_paid != 0) {
+ $page->trigError("Impossible de te désinscrire complètement " .
+ "parce que tu as fait un paiement par " .
+ "chèque ou par liquide. Contacte un " .
+ "administrateur du groupe si tu es sûr de " .
+ "ne pas venir.");
+ $updated = false;