From e52531114242a754b3437c1f76217849cf5c5e3a Mon Sep 17 00:00:00 2001 From: Dorian Vabre Date: Fri, 16 Apr 2021 14:54:07 +0200 Subject: [PATCH] now using the invoice id as ref in url passed to newpayment page, for conference subscriptions --- .../attendee_subscription.php | 2 +- htdocs/public/payment/newpayment.php | 48 +++++++------------ 2 files changed, 17 insertions(+), 33 deletions(-) diff --git a/htdocs/public/eventorganization/attendee_subscription.php b/htdocs/public/eventorganization/attendee_subscription.php index 28c3375a62f..1121248e048 100644 --- a/htdocs/public/eventorganization/attendee_subscription.php +++ b/htdocs/public/eventorganization/attendee_subscription.php @@ -338,7 +338,7 @@ if (empty($reshook) && $action == 'add') { $error++; } if (!$error) { - $redirection = $dolibarr_main_url_root.'/public/payment/newpayment.php?source=conferencesubscription&ref='.$confattendee->id; + $redirection = $dolibarr_main_url_root.'/public/payment/newpayment.php?source=conferencesubscription&ref='.dol_encode($facture->id, $dolibarr_main_instance_unique_id); Header("Location: ".$redirection); exit; } diff --git a/htdocs/public/payment/newpayment.php b/htdocs/public/payment/newpayment.php index 546a7ee0e11..d03f004f317 100644 --- a/htdocs/public/payment/newpayment.php +++ b/htdocs/public/payment/newpayment.php @@ -61,8 +61,7 @@ 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.'/product/class/product.class.php'; require_once DOL_DOCUMENT_ROOT.'/societe/class/societeaccount.class.php'; -require_once DOL_DOCUMENT_ROOT.'/eventorganization/class/conferenceorbooth.class.php'; -require_once DOL_DOCUMENT_ROOT.'/eventorganization/class/conferenceorboothattendee.class.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; // Hook to be used by external payment modules (ie Payzen, ...) include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; @@ -114,36 +113,21 @@ if (!$action) { if ($source == 'conferencesubscription') { // Finding the Attendee - $attendee = new ConferenceOrBoothAttendee($db); - $result = $attendee->fetch('', $ref); - if ($result <= 0) { - $mesg = $attendee->error; - $error++; - } - $object = $attendee; - - // Finding the thirdparty associated to the Attendee - $thirdparty = new Societe($db); - $resultthirdparty = $thirdparty->fetch($attendee->fk_soc); - if ($resultthirdparty <= 0) { - $mesg = $thirdparty->error; - $error++; - } - - // Finding the conference - $conference = new ConferenceOrBooth($db); - $resultconf = $conference->fetch($attendee->fk_actioncomm); - if ($resultconf <= 0) { - $mesg = $conference->error; - $error++; - } - - // Finding the project - $project = new Project($db); - $resultproj = $project->fetch($conference->fk_project); - if ($resultproj <= 0) { - $mesg = $project->error; + $decodedinvoiceid = dol_decode(GETPOST('ref'), $dolibarr_main_instance_unique_id); + $invoice = new Facture($db); + $resultinvoice = $invoice->fetch($decodedinvoiceid); + if ($resultinvoice <= 0) { + $mesg = $invoice->error; $error++; + } else { + // Finding the thirdparty associated to the Attendee + $thirdparty = new Societe($db); + $resultthirdparty = $thirdparty->fetch($invoice->socid); + if ($resultthirdparty <= 0) { + $mesg = $thirdparty->error; + $error++; + } + $object = $thirdparty; } } @@ -1824,7 +1808,7 @@ if ($source == 'conferencesubscription') { // Amount print ''.$langs->trans("Amount"); print ''; - $valtoshow = $project->price_registration; + $valtoshow = $invoice->total_ttc; print ''.price($valtoshow).''; print ''; print '';