From b70e477f471a571408f2521b72533558f0ca3d0c Mon Sep 17 00:00:00 2001 From: Dorian Vabre Date: Tue, 20 Apr 2021 14:49:11 +0200 Subject: [PATCH] removal of the mail sending (not functional yet) in the subscriptionok page, it will be moved to the paymentok after payment or the attendeesubscription if no payment has to be done --- .../attendee_subscription.php | 2 +- .../eventorganization/subscriptionok.php | 58 ------------------- htdocs/public/payment/paymentok.php | 24 +++++--- 3 files changed, 16 insertions(+), 68 deletions(-) diff --git a/htdocs/public/eventorganization/attendee_subscription.php b/htdocs/public/eventorganization/attendee_subscription.php index 03fa023ad11..56855c70b62 100644 --- a/htdocs/public/eventorganization/attendee_subscription.php +++ b/htdocs/public/eventorganization/attendee_subscription.php @@ -349,7 +349,7 @@ if (empty($reshook) && $action == 'add') { // No price has been set // Validating the subscription $confattendee->setStatut(1); - $redirection = $dolibarr_main_url_root.'/public/eventorganization/subscriptionok.php?idthirdparty='.dol_encode($thirdparty->id, $dolibarr_main_instance_unique_id).'&securekey='.dol_encode($conf->global->EVENTORGANIZATION_SECUREKEY, $dolibarr_main_instance_unique_id); + $redirection = $dolibarr_main_url_root.'/public/eventorganization/subscriptionok.php?securekey='.dol_encode($conf->global->EVENTORGANIZATION_SECUREKEY, $dolibarr_main_instance_unique_id); Header("Location: ".$redirection); exit; } diff --git a/htdocs/public/eventorganization/subscriptionok.php b/htdocs/public/eventorganization/subscriptionok.php index 3fcf74a4c0c..81db5ac1c02 100644 --- a/htdocs/public/eventorganization/subscriptionok.php +++ b/htdocs/public/eventorganization/subscriptionok.php @@ -71,64 +71,6 @@ if ($securekey != $conf->global->EVENTORGANIZATION_SECUREKEY) { exit; } -$idthirdparty = dol_decode(GETPOST('idthirdparty'), $dolibarr_main_instance_unique_id); - -$thirdparty = new Societe($db); -$resthirdparty = $thirdparty->fetch($idthirdparty); -if ($resthirdparty<0) { - $error++; - $errmsg .= $thirdparty->error; -} - -// Send subscription email -include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; -$formmail = new FormMail($db); -// Set output language -$outputlangs = new Translate('', $conf); -$outputlangs->setDefaultLang(empty($object->thirdparty->default_lang) ? $mysoc->default_lang : $object->thirdparty->default_lang); -// Load traductions files required by page -$outputlangs->loadLangs(array("main", "members")); -// Get email content from template -$arraydefaultmessage = null; -$labeltouse = $conf->global->EVENTORGANIZATION_TEMPLATE_EMAIL_AFT_SUBS_EVENT; - -if (!empty($labeltouse)) { - $arraydefaultmessage = $formmail->getEMailTemplate($db, 'member', $user, $outputlangs, 0, 1, $labeltouse); -} - -if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) { - $subject = $arraydefaultmessage->topic; - $msg = $arraydefaultmessage->content; -} - -$substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object); -complete_substitutions_array($substitutionarray, $outputlangs, $object); -$subjecttosend = make_substitutions($subject, $substitutionarray, $outputlangs); -$texttosend = make_substitutions($msg, $substitutionarray, $outputlangs); - -if ($subjecttosend && $texttosend) { - $moreinheader = 'X-Dolibarr-Info: send_an_email by public/members/new.php'."\r\n"; - - global $conf, $langs; - - // Envoi mail confirmation - $from = $conf->email_from; - if (!empty($conf->global->ADHERENT_MAIL_FROM)) { - $from = $conf->global->ADHERENT_MAIL_FROM; - } - - $trackid = 'mem'.$this->id; - - include_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; - $mailfile = new CMailFile($subjecttosend, $thirdparty->email, $from, $texttosend, array(), array(), array(), "", "", 0, -1, '', '', $trackid, $moreinheader); - if ($mailfile->sendfile()) { - return 1; - } else { - $this->error = $langs->trans("ErrorFailedToSendMail", $from, $this->email).'. '.$mailfile->error; - return -1; - } -} - /* * Actions */ diff --git a/htdocs/public/payment/paymentok.php b/htdocs/public/payment/paymentok.php index 950d68560b5..88d50d66a62 100644 --- a/htdocs/public/payment/paymentok.php +++ b/htdocs/public/payment/paymentok.php @@ -783,11 +783,11 @@ if ($ispaymentok) { $postactionmessages[] = 'Invoice paid '.$tmptag['INV'].' was not found'; $ispostactionok = -1; } - } elseif (array_key_exists('ATT', $tmptag) && $tmptag['INV'] > 0) { + } elseif (array_key_exists('ATT', $tmptag) && $tmptag['ATT'] > 0) { // Record payment include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; $object = new Facture($db); - $result = $object->fetch($tmptag['INV']); + $result = $object->fetch($tmptag['ATT']); if ($result) { $FinalPaymentAmt = $_SESSION["FinalPaymentAmt"]; @@ -888,23 +888,29 @@ if ($ispaymentok) { } else { $attendeetovalidate->setStatut(1); } - $redirection = $dolibarr_main_url_root.'/public/eventorganization/subscriptionok.php?idthirdparty='.dol_encode($thirdparty->id, $dolibarr_main_instance_unique_id).'&securekey='.dol_encode($conf->global->EVENTORGANIZATION_SECUREKEY, $dolibarr_main_instance_unique_id); - Header("Location: ".$redirection); - exit; + // Redirecting to confirmation page + $thirdparty = new Societe($db); + $resultthirdparty = $thirdparty->fetch($attendeetovalidate->fk_soc); + if ($resultthirdparty < 0) { + setEventMessages(null, $thirdparty->errors, "errors"); + } else { + $redirection = $dolibarr_main_url_root.'/public/eventorganization/subscriptionok.php?idthirdparty='.dol_encode($thirdparty->id, $dolibarr_main_instance_unique_id).'&securekey='.dol_encode($conf->global->EVENTORGANIZATION_SECUREKEY, $dolibarr_main_instance_unique_id); + Header("Location: ".$redirection); + exit; + } } else { $db->rollback(); } } else { - $postactionmessages[] = 'Failed to get a valid value for "amount paid" ('.$FinalPaymentAmt.') or "payment type" ('.$paymentType.') to record the payment of invoice '.$tmptag['INV'].'. May be payment was already recorded.'; + $postactionmessages[] = 'Failed to get a valid value for "amount paid" ('.$FinalPaymentAmt.') or "payment type" ('.$paymentType.') to record the payment of invoice '.$tmptag['ATT'].'. May be payment was already recorded.'; $ispostactionok = -1; } - } else { - $postactionmessages[] = 'Invoice paid '.$tmptag['INV'].' was not found'; + $postactionmessages[] = 'Invoice paid '.$tmptag['ATT'].' was not found'; $ispostactionok = -1; } - } elseif (array_key_exists('BOO', $tmptag) && $tmptag['INV'] > 0) { + } elseif (array_key_exists('BOO', $tmptag) && $tmptag['BOO'] > 0) { // BOOTH CASE (to copy and adapt from above) } else { // Nothing done