moved attendee validation after the payment method search

This commit is contained in:
Dorian Vabre 2021-04-19 16:26:45 +02:00
parent 1b947a6e9a
commit 18d16d9509

View File

@ -113,36 +113,6 @@ $uncryptedconferencesubscription = dol_decode($conferencesubscription, $dolibarr
$subscription = substr($uncryptedconferencesubscription, 0, strlen($uncryptedconferencesubscription)-strlen($ref));
$reffrompayment = substr($uncryptedconferencesubscription, -strlen($ref), strlen($ref));
// After a conference attendee payment
if ($subscription == 'subscriptionok' && $ref == $reffrompayment) {
// Looking for the invoice to which add a payment
$paidinvoice = new Facture($db);
$resultinvoice = $paidinvoice->fetch($invoiceref);
if ($resultinvoice < 0) {
setEventMessages(null, $paidinvoice->errors, "errors");
} else {
// Creation of payment line
$paiement = new Paiement($db);
$paiement->datepaye = dol_now();
$paiement->amounts = $amounts; // Array with all payments dispatching with invoice id
$paiement->multicurrency_amounts = $multicurrency_amounts; // Array with all payments dispatching
$paiement->paiementid = dol_getIdFromCode($db, GETPOST('paiementcode'), 'c_paiement', 'code', 'id', 1);
$paiement->num_payment = GETPOST('num_paiement', 'alpha');
$paiement->note_private = GETPOST('comment', 'alpha');
// Validating the attendee
$attendeetovalidate = new ConferenceOrBoothAttendee($db);
$resultattendee = $attendeetovalidate->fetch($ref);
if ($resultattendee < 0) {
setEventMessages(null, $attendeetovalidate->errors, "errors");
} else {
$attendeetovalidate->setStatut(1);
}
}
}
// Detect $paymentmethod
$paymentmethod = '';
@ -186,6 +156,33 @@ $object = new stdClass(); // For triggers
$error = 0;
// After a conference attendee payment
if ($subscription == 'subscriptionok' && $ref == $reffrompayment) {
// Looking for the invoice to which add a payment
$paidinvoice = new Facture($db);
$resultinvoice = $paidinvoice->fetch($invoiceref);
if ($resultinvoice < 0) {
setEventMessages(null, $paidinvoice->errors, "errors");
} else {
// Creation of payment line
$paiement = new Paiement($db);
$paiement->datepaye = dol_now();
$paiement->amounts = $amounts; // Array with all payments dispatching with invoice id
$paiement->multicurrency_amounts = $multicurrency_amounts; // Array with all payments dispatching
$paiement->paiementid = dol_getIdFromCode($db, GETPOST('paiementcode'), 'c_paiement', 'code', 'id', 1);
$paiement->num_payment = GETPOST('num_paiement', 'alpha');
$paiement->note_private = GETPOST('comment', 'alpha');
// Validating the attendee
$attendeetovalidate = new ConferenceOrBoothAttendee($db);
$resultattendee = $attendeetovalidate->fetch($ref);
if ($resultattendee < 0) {
setEventMessages(null, $attendeetovalidate->errors, "errors");
} else {
$attendeetovalidate->setStatut(1);
}
}
}
/*
* Actions