From 4d20079c496cd8a79a3e6cbf0a0d5d50b9e3dac0 Mon Sep 17 00:00:00 2001 From: Dorian Vabre Date: Wed, 21 Apr 2021 15:20:08 +0200 Subject: [PATCH] fix: the ref passed in url is now attendee s one, not invoice s --- .../attendee_subscription.php | 2 +- htdocs/public/payment/newpayment.php | 44 ++++++++++--------- 2 files changed, 24 insertions(+), 22 deletions(-) diff --git a/htdocs/public/eventorganization/attendee_subscription.php b/htdocs/public/eventorganization/attendee_subscription.php index 7f04bfe0cb5..91bc2da646b 100644 --- a/htdocs/public/eventorganization/attendee_subscription.php +++ b/htdocs/public/eventorganization/attendee_subscription.php @@ -343,7 +343,7 @@ if (empty($reshook) && $action == 'add') { if (!$error) { $valid = true; $sourcetouse = 'conferencesubscription'; - $reftouse = $facture->id; + $reftouse = $confattendee->id; $redirection = $dolibarr_main_url_root.'/public/payment/newpayment.php?source='.$sourcetouse.'&ref='.$reftouse; if (!empty($conf->global->PAYMENT_SECURITY_TOKEN)) { if (!empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) { diff --git a/htdocs/public/payment/newpayment.php b/htdocs/public/payment/newpayment.php index 1032737919b..461cd406a92 100644 --- a/htdocs/public/payment/newpayment.php +++ b/htdocs/public/payment/newpayment.php @@ -59,6 +59,7 @@ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/eventorganization/class/conferenceorboothattendee.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; require_once DOL_DOCUMENT_ROOT.'/societe/class/societeaccount.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; @@ -113,30 +114,31 @@ if (!$action) { if ($source == 'conferencesubscription') { // Finding the Attendee - $invoiceid = GETPOST('ref'); - $invoice = new Facture($db); - $resultinvoice = $invoice->fetch($invoiceid); - if ($resultinvoice <= 0) { - setEventMessages(null, $invoice->errors, "errors"); + $attendeeid = GETPOST('ref'); + $attendee = new ConferenceOrBoothAttendee($db); + $resultattendee = $attendee->fetch($attendeeid); + if ($resultattendee <= 0) { + setEventMessages(null, $attendee->errors, "errors"); } else { - $invoice->fetchObjectLinked(); - // Finding the thirdparty associated to the Attendee - $thirdparty = new Societe($db); - $resultthirdparty = $thirdparty->fetch($invoice->socid); - if ($resultthirdparty <= 0) { - setEventMessages(null, $thirdparty->errors, "errors"); - } - $object = $thirdparty; - $linkedAttendees = $invoice->linkedObjectsIds['conferenceorboothattendee']; + $attendee->fetchObjectLinked(); + $linkedInvoices = $attendee->linkedObjectsIds['facture']; - if (is_array($linkedAttendees)) { - $linkedAttendees = array_values($linkedAttendees); + if (is_array($linkedInvoices)) { + $linkedInvoices = array_values($linkedInvoices); - $attendee = new ConferenceOrBoothAttendee($db); - $resultattendee = $attendee->fetch($linkedAttendees[0]); - if ($resultattendee <= 0) { - setEventMessages(null, $attendee->errors, "errors"); + $invoice = new Facture($db); + $resultinvoice = $invoice->fetch($linkedInvoices[0]); + if ($resultinvoice <= 0) { + setEventMessages(null, $invoice->errors, "errors"); + } else { + // Finding the associated thirdparty + $thirdparty = new Societe($db); + $resultthirdparty = $thirdparty->fetch($invoice->socid); + if ($resultthirdparty <= 0) { + setEventMessages(null, $thirdparty->errors, "errors"); + } + $object = $thirdparty; } } } @@ -1808,7 +1810,7 @@ if ($source == 'conferencesubscription') { print ''.$langs->trans("Designation"); print ''.$text; print ''; - print ''; + print ''; print ''."\n"; // Amount