From 3b17a0d66ae6b67e462051311f7ece6b6669eedc Mon Sep 17 00:00:00 2001 From: Dorian Vabre Date: Tue, 20 Apr 2021 10:42:50 +0200 Subject: [PATCH] wip on paymentok page --- htdocs/public/payment/paymentok.php | 40 +++++++++++++++++++++-------- 1 file changed, 29 insertions(+), 11 deletions(-) diff --git a/htdocs/public/payment/paymentok.php b/htdocs/public/payment/paymentok.php index c4f6b0a012c..533ce56cee1 100644 --- a/htdocs/public/payment/paymentok.php +++ b/htdocs/public/payment/paymentok.php @@ -164,18 +164,36 @@ if ($subscription == 'subscriptionok' && $ref == $reffrompayment) { if ($resultinvoice < 0) { setEventMessages(null, $paidinvoice->errors, "errors"); } else { - // Creation of payment line - $paiement = new Paiement($db); - $paiement->datepaye = dol_now(); - $paiement->amounts[] = $paidinvoice->total_ttc; // Array with all payments dispatching with invoice id - - // Validating the attendee - $attendeetovalidate = new ConferenceOrBoothAttendee($db); - $resultattendee = $attendeetovalidate->fetch($ref); - if ($resultattendee < 0) { - setEventMessages(null, $attendeetovalidate->errors, "errors"); + // Finding thirdparty + $thirdparty = new Societe($db); + $resultthirdparty = $thirdparty->fetch($paidinvoice->socid); + if ($resultthirdparty <= 0) { + $mesg = $thirdparty->error; + $error++; } else { - $attendeetovalidate->setStatut(1); + // Creation of payment line + $paiement = new Paiement($db); + $paiement->facid = $paidinvoice->id; + $paiement->datepaye = dol_now(); + $paiement->amount = $paidinvoice->total_ttc; + $paiement->amounts[] = $paidinvoice->total_ttc; + + $paiement_id = $paiement->create($user, 1, $thirdparty); // This include closing invoices and regenerating documents + if ($paiement_id < 0) { + setEventMessages($paiement->error, $paiement->errors, 'errors'); + $error++; + } + else { + // Validating the attendee + $attendeetovalidate = new ConferenceOrBoothAttendee($db); + $resultattendee = $attendeetovalidate->fetch($ref); + if ($resultattendee < 0) { + setEventMessages(null, $attendeetovalidate->errors, "errors"); + } else { + $attendeetovalidate->setStatut(1); + // @todo send email + } + } } } }