diff --git a/htdocs/public/eventorganization/attendee_subscription.php b/htdocs/public/eventorganization/attendee_subscription.php index 9fb27168fd1..fab0a9733c8 100644 --- a/htdocs/public/eventorganization/attendee_subscription.php +++ b/htdocs/public/eventorganization/attendee_subscription.php @@ -374,7 +374,7 @@ if (empty($reshook) && $action == 'add') { if (!$error) { $valid = true; $sourcetouse = 'conferencesubscription'; - $reftouse = $confattendee->id; + $reftouse = $facture->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 d6613cb86de..4460988ea60 100644 --- a/htdocs/public/payment/newpayment.php +++ b/htdocs/public/payment/newpayment.php @@ -114,23 +114,23 @@ if (!$action) { if ($source == 'conferencesubscription') { // Finding the Attendee - $attendeeid = GETPOST('ref'); - $attendee = new ConferenceOrBoothAttendee($db); - $resultattendee = $attendee->fetch($attendeeid); - if ($resultattendee <= 0) { - setEventMessages(null, $attendee->errors, "errors"); + $invoiceid = GETPOST('ref'); + $invoice = new Facture($db); + $resultinvoice = $invoice->fetch($invoiceid); + if ($resultinvoice <= 0) { + setEventMessages(null, $invoice->errors, "errors"); } else { - $attendee->fetchObjectLinked(); - $linkedInvoices = $attendee->linkedObjectsIds['facture']; + $invoice->fetchObjectLinked(); + $linkedAttendees = $invoice->linkedObjectsIds['conferenceorboothattendee']; - if (is_array($linkedInvoices)) { - $linkedInvoices = array_values($linkedInvoices); + if (is_array($linkedAttendees)) { + $linkedAttendees = array_values($linkedAttendees); - $invoice = new Facture($db); - $resultinvoice = $invoice->fetch($linkedInvoices[0]); - if ($resultinvoice <= 0) { - setEventMessages(null, $invoice->errors, "errors"); + $attendee = new ConferenceOrBoothAttendee($db); + $resultattendee = $attendee->fetch($linkedAttendees[0]); + if ($resultattendee <= 0) { + setEventMessages(null, $attendee->errors, "errors"); } else { $amount = price2num($invoice->total_ttc); // Finding the associated thirdparty @@ -1809,7 +1809,7 @@ if ($source == 'conferencesubscription') { print ''.$langs->trans("Designation"); print ''.$text; print ''; - print ''; + print ''; print ''."\n"; // Amount diff --git a/htdocs/public/payment/paymentok.php b/htdocs/public/payment/paymentok.php index 444a769673c..39cfa0f37c9 100644 --- a/htdocs/public/payment/paymentok.php +++ b/htdocs/public/payment/paymentok.php @@ -784,7 +784,7 @@ if ($ispaymentok) { // Record payment include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; $object = new Facture($db); - $result = $object->fetch($tmptag['ATT']); + $result = $object->fetch($ref); if ($result) { $FinalPaymentAmt = $_SESSION["FinalPaymentAmt"]; @@ -810,6 +810,14 @@ if ($ispaymentok) { // Do action only if $FinalPaymentAmt is set (session variable is cleaned after this page to avoid duplicate actions when page is POST a second time) if (!empty($FinalPaymentAmt) && $paymentTypeId > 0) { + $resultvalidate = $object->validate($user); + if ($resultvalidate < 0) { + $postactionmessages[] = 'Cannot validate invoice'; + $ispostactionok = -1; + $error++; // Not yet supported + } else { + + } $db->begin(); // Creation of payment line @@ -879,7 +887,7 @@ if ($ispaymentok) { // Validating the attendee $attendeetovalidate = new ConferenceOrBoothAttendee($db); - $resultattendee = $attendeetovalidate->fetch($ref); + $resultattendee = $attendeetovalidate->fetch($tmptag['ATT']); if ($resultattendee < 0) { setEventMessages(null, $attendeetovalidate->errors, "errors"); } else {