Debug organizedeventregistration module

This commit is contained in:
Laurent Destailleur 2021-09-08 01:41:59 +02:00
parent b92784c04b
commit 880ac07661
9 changed files with 192 additions and 130 deletions

View File

@ -246,7 +246,7 @@ class ConferenceOrBooth extends ActionComm
$result = parent::fetch($id, $ref, $ref_ext, $email_msgid);
$link_subscription = $dolibarr_main_url_root.'/public/eventorganization/attendee_subscription.php?id='.urlencode($id).'&type=conf';
$link_subscription = $dolibarr_main_url_root.'/public/eventorganization/attendee_registration.php?id='.urlencode($id).'&type=conf';
$encodedsecurekey = dol_hash($conf->global->EVENTORGANIZATION_SECUREKEY.'conferenceorbooth'.$id, 2);
$link_subscription .= '&securekey='.urlencode($encodedsecurekey);

View File

@ -404,7 +404,7 @@ class ConferenceOrBoothAttendee extends CommonObject
$sql = 'SELECT ';
$sql .= $this->getFieldList('t');
$sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t';
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."actioncomm as a on a.id=t.fk_actioncomm";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."actioncomm as a on a.id = t.fk_actioncomm";
if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) {
$sql .= ' WHERE t.entity IN ('.getEntity($this->table_element).')';
} else {

View File

@ -147,9 +147,11 @@ if ($user->socid > 0) { // Protection if external user
$result = restrictedArea($user, 'eventorganization');
if (!$permissiontoread) accessforbidden();
/*
* Actions
*/
if (preg_match('/^set/', $action) && $projectid > 0) {
$project = new Project($db);
//If "set" fields keys is in projects fields
@ -429,7 +431,7 @@ if ($projectid > 0) {
//print '</span>';
print '</td><td>';
$linksuggest = $dolibarr_main_url_root.'/public/project/index.php?id='.$project->id;
$encodedsecurekey = dol_hash($conf->global->EVENTORGANIZATION_SECUREKEY.'conferenceorbooth'.$project->id, 2);
$encodedsecurekey = dol_hash($conf->global->EVENTORGANIZATION_SECUREKEY.'conferenceorbooth'.$project->id, 'md5');
$linksuggest .= '&securekey='.urlencode($encodedsecurekey);
//print '<div class="urllink">';
//print '<input type="text" value="'.$linksuggest.'" id="linkregister" class="quatrevingtpercent paddingrightonly">';
@ -445,8 +447,8 @@ if ($projectid > 0) {
print $langs->trans("PublicAttendeeSubscriptionGlobalPage");
//print '</span>';
print '</td><td>';
$link_subscription = $dolibarr_main_url_root.'/public/eventorganization/attendee_subscription.php?id='.$project->id.'&type=global';
$encodedsecurekey = dol_hash($conf->global->EVENTORGANIZATION_SECUREKEY.'conferenceorbooth'.$project->id, 2);
$link_subscription = $dolibarr_main_url_root.'/public/eventorganization/attendee_registration.php?id='.$project->id.'&type=global';
$encodedsecurekey = dol_hash($conf->global->EVENTORGANIZATION_SECUREKEY.'conferenceorbooth'.$project->id, 'md5');
$link_subscription .= '&securekey='.urlencode($encodedsecurekey);
//print '<div class="urllink">';
//print '<input type="text" value="'.$linkregister.'" id="linkregister" class="quatrevingtpercent paddingrightonly">';

View File

@ -382,7 +382,7 @@ if (!empty($withproject)) {
print $langs->trans("PublicAttendeeSubscriptionGlobalPage");
//print '</span>';
print '</td><td>';
$link_subscription = $dolibarr_main_url_root.'/public/eventorganization/attendee_subscription.php?id='.$projectstatic->id.'&type=global';
$link_subscription = $dolibarr_main_url_root.'/public/eventorganization/attendee_registration.php?id='.$projectstatic->id.'&type=global';
$encodedsecurekey = dol_hash($conf->global->EVENTORGANIZATION_SECUREKEY.'conferenceorbooth'.$projectstatic->id, 2);
$link_subscription .= '&securekey='.urlencode($encodedsecurekey);
//print '<div class="urllink">';

View File

@ -467,7 +467,10 @@ if ($projectstatic->id > 0 || $confOrBooth > 0) {
// Other attributes
$cols = 2;
//include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php';
$objectconf = $object;
$object = $projectstatic;
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php';
$object = $objectconf;
print '</table>';
@ -554,7 +557,7 @@ if ($projectstatic->id > 0 || $confOrBooth > 0) {
print $langs->trans("PublicAttendeeSubscriptionGlobalPage");
//print '</span>';
print '</td><td>';
$link_subscription = $dolibarr_main_url_root.'/public/eventorganization/attendee_subscription.php?id='.$projectstatic->id.'&type=global';
$link_subscription = $dolibarr_main_url_root.'/public/eventorganization/attendee_registration.php?id='.$projectstatic->id.'&type=global';
$encodedsecurekey = dol_hash($conf->global->EVENTORGANIZATION_SECUREKEY.'conferenceorbooth'.$projectstatic->id, 2);
$link_subscription .= '&securekey='.urlencode($encodedsecurekey);
//print '<div class="urllink">';

View File

@ -26,6 +26,8 @@ EventOrganizationDescriptionLong= Manage Event organization for conference, atte
EventOrganizationMenuLeft = Organized events
EventOrganizationConferenceOrBoothMenuLeft = Conference Or Booth
PaymentEvent=Payment of event
#
# Admin page
#

View File

@ -16,7 +16,7 @@
*/
/**
* \file htdocs/public/eventorganization/attendee_subscription.php
* \file htdocs/public/eventorganization/attendee_registration.php
* \ingroup project
* \brief Example of form to subscribe to an event
*
@ -79,13 +79,17 @@ $email = GETPOST("email");
$societe = GETPOST("societe");
// Getting id from Post and decoding it
$id = GETPOST('id', 'int');
$type = GETPOST('type', 'alpha');
$type = GETPOST('type', 'aZ09');
if ($type == 'conf') {
$id = GETPOST('id', 'int');
} else {
$id = GETPOST('fk_project', 'int') ? GETPOST('fk_project', 'int') : GETPOST('id', 'int');
}
$conference = new ConferenceOrBooth($db);
$project = new Project($db);
if ($type=='conf') {
if ($type == 'conf') {
$resultconf = $conference->fetch($id);
if ($resultconf < 0) {
print 'Bad value for parameter id';
@ -97,11 +101,7 @@ if ($type=='conf') {
$errmsg .= $project->error;
}
}
if ($type=='global') {
$project = new Project($db);
if (empty($id)) {
$id = GETPOST('fk_project', 'int');
}
if ($type == 'global') {
$resultproject = $project->fetch($id);
if ($resultproject < 0) {
$error++;
@ -110,10 +110,9 @@ if ($type=='global') {
}
// Security check
$securekeyreceived = GETPOST('securekey', 'alpha');
$securekeytocompare = dol_hash($conf->global->EVENTORGANIZATION_SECUREKEY.'conferenceorbooth'.$id, 2);
$securekeytocompare = dol_hash($conf->global->EVENTORGANIZATION_SECUREKEY.'conferenceorbooth'.$id, 'md5');
// We check if the securekey collected is OK
if ($securekeytocompare != $securekeyreceived) {
@ -221,7 +220,7 @@ if ($reshook < 0) {
}
// Action called when page is submitted
if (empty($reshook) && $action == 'add' && (!empty($conference->id) && $conference->status!=2 || !empty($project->id) && $project->status==Project::STATUS_VALIDATED)) {
if (empty($reshook) && $action == 'add' && (!empty($conference->id) && $conference->status!=2 || !empty($project->id) && $project->status == Project::STATUS_VALIDATED)) {
$error = 0;
$urlback = '';
@ -251,20 +250,22 @@ if (empty($reshook) && $action == 'add' && (!empty($conference->id) && $conferen
// Check if attendee already exists (by email and for this event)
$confattendee = new ConferenceOrBoothAttendee($db);
if ($type=='global') {
if ($type == 'global') {
$filter = array('t.fk_project'=>$id, 'customsql'=>'t.email="'.$email.'"');
}
if ($action='conf') {
if ($action == 'conf') {
$filter = array('t.fk_actioncomm'=>$id, 'customsql'=>'t.email="'.$email.'"');
}
// Check if there is already an attendee into table eventorganization_conferenceorboothattendee for same event (or conference/booth)
$resultfetchconfattendee = $confattendee->fetchAll('', '', 0, 0, $filter);
if ($resultfetchconfattendee > 0 && count($resultfetchconfattendee)>0) {
if (is_array($resultfetchconfattendee) && count($resultfetchconfattendee) > 0) {
// Found confattendee
$confattendee = array_shift($resultfetchconfattendee);
} else {
// Need to create a confattendee
$confattendee->date_subscription = dol_now();
$confattendee->date_creation = dol_now();
$confattendee->email = $email;
$confattendee->fk_project = $project->id;
$confattendee->fk_actioncomm = $id;
@ -274,42 +275,50 @@ if (empty($reshook) && $action == 'add' && (!empty($conference->id) && $conferen
$errmsg .= $confattendee->error;
}
}
// At this point, we have an attendee. It may not be linked to a thirdparty if we just created it
// If the attendee has already paid
if ($confattendee->status == 1) {
// At this point, we have an existing $confattendee. It may not be linked to a thirdparty.
//var_dump($confattendee);
// If the attendee has already been paid
if (!empty($confattendee->date_subscription)) {
$securekeyurl = dol_hash($conf->global->EVENTORGANIZATION_SECUREKEY.'conferenceorbooth'.$id, 2);
$redirection = $dolibarr_main_url_root.'/public/eventorganization/subscriptionok.php?id='.$id.'&securekey='.$securekeyurl;
$redirection = $dolibarr_main_url_root.'/public/eventorganization/subscriptionok.php?id='.((int) $id).'&securekey='.urlencode($securekeyurl);
Header("Location: ".$redirection);
exit;
}
// Getting the thirdparty or creating it
$thirdparty = new Societe($db);
// Fetch using fk_soc if the attendee was already existing
if (!empty($confattendee->fk_soc)) {
// Fetch using fk_soc if the attendee was already found
if (!empty($confattendee->fk_soc) && $confattendee->fk_soc > 0) {
$resultfetchthirdparty = $thirdparty->fetch($confattendee->fk_soc);
} else {
// Fetch using the input field by user if we just created the attendee
if (!empty($societe)) {
$resultfetchthirdparty = $thirdparty->fetch('', $societe);
if ($resultfetchthirdparty<=0) {
// Need to create a new one (not found or multiple with the same name)
$resultfetchthirdparty = 0;
if (empty($conf->global->EVENTORGANIZATION_DISABLE_RETREIVE_THIRDPARTY_FROM_NAME)) {
// Fetch using the input field by user if we just created the attendee
if (!empty($societe)) {
$resultfetchthirdparty = $thirdparty->fetch('', $societe, '', '', '', '', '', '', '', '', $email);
if ($resultfetchthirdparty <= 0) {
// Need to create a new one (not found or multiple with the same name/email)
$resultfetchthirdparty = 0;
} else {
// We found an unique result with that name/email, so we set the fk_soc of attendee
$confattendee->fk_soc = $thirdparty->id;
$confattendee->update($user);
}
} else {
// We found an unique result with that name, so we put in in fk_soc of attendee
$confattendee->fk_soc = $thirdparty->id;
$confattendee->update($user);
// Need to create a thirdparty (put number>0 if we do not want to create a thirdparty for free-conferences)
$resultfetchthirdparty = 0;
}
} else {
// Need to create a thirdparty (put number>0 if we do not want to create a thirdparty for free-conferences)
$resultfetchthirdparty = 0;
}
}
if ($resultfetchthirdparty<0) {
if ($resultfetchthirdparty < 0) {
$error++;
$errmsg .= $thirdparty->error;
} elseif ($resultfetchthirdparty==0) {
// creation of a new thirdparty
} elseif ($resultfetchthirdparty == 0) {
// Creation of a new thirdparty
if (!empty($societe)) {
$thirdparty->name = $societe;
} else {
@ -318,7 +327,7 @@ if (empty($reshook) && $action == 'add' && (!empty($conference->id) && $conferen
$thirdparty->address = GETPOST("address");
$thirdparty->zip = GETPOST("zipcode");
$thirdparty->town = GETPOST("town");
$thirdparty->client = 2;
$thirdparty->client = $thirdparty::PROSPECT;
$thirdparty->fournisseur = 0;
$thirdparty->country_id = GETPOST("country_id", 'int');
$thirdparty->state_id = GETPOST("state_id", 'int');
@ -343,12 +352,13 @@ if (empty($reshook) && $action == 'add' && (!empty($conference->id) && $conferen
}
$thirdparty->code_client = $tmpcode;
$readythirdparty = $thirdparty->create($user);
if ($readythirdparty <0) {
if ($readythirdparty < 0) {
$error++;
$errmsg .= $thirdparty->error;
} else {
$thirdparty->country_code = getCountry($thirdparty->country_id, 2, $db, $langs);
$thirdparty->country = getCountry($thirdparty->country_code, 0, $db, $langs);
$confattendee->fk_soc = $thirdparty->id;
$confattendee->update($user);
}
@ -356,10 +366,18 @@ if (empty($reshook) && $action == 'add' && (!empty($conference->id) && $conferen
}
if (!$error) {
$db->commit();
if (!empty(floatval($project->price_registration))) {
$outputlangs = $langs;
// TODO Use default language of $thirdparty->default_lang to build $outputlang
$productforinvoicerow = new Product($db);
$resultprod = $productforinvoicerow->fetch($conf->global->SERVICE_CONFERENCE_ATTENDEE_SUBSCRIPTION);
$productforinvoicerow->id = 0;
$resultprod = 0;
if ($conf->global->SERVICE_CONFERENCE_ATTENDEE_SUBSCRIPTION > 0) {
$resultprod = $productforinvoicerow->fetch($conf->global->SERVICE_CONFERENCE_ATTENDEE_SUBSCRIPTION);
}
if ($resultprod < 0) {
$error++;
$errmsg .= $productforinvoicerow->error;
@ -371,6 +389,7 @@ if (empty($reshook) && $action == 'add' && (!empty($conference->id) && $conferen
$facture->date = dol_now();
$facture->cond_reglement_id = $confattendee->cond_reglement_id;
$facture->fk_project = $project->id;
if (empty($facture->cond_reglement_id)) {
$paymenttermstatic = new PaymentTerm($confattendee->db);
$facture->cond_reglement_id = $paymenttermstatic->getDefaultId();
@ -393,29 +412,44 @@ if (empty($reshook) && $action == 'add' && (!empty($conference->id) && $conferen
if (!$error) {
// Add line to draft invoice
$vattouse = get_default_tva($mysoc, $thirdparty, $productforinvoicerow->id);
$result = $facture->addline($langs->trans("ConferenceAttendeeFee", $conference->label, dol_print_date($conference->datep, '%d/%m/%y %H:%M:%S'), dol_print_date($conference->datep2, '%d/%m/%y %H:%M:%S')), floatval($project->price_registration), 1, $vattouse, 0, 0, $productforinvoicerow->id, 0, dol_now(), '', 0, 0, '', 'HT', 0, 1);
$labelforproduct = $outputlangs->trans("EventFee", $project->title);
$date_start = $project->date_start;
$date_end = $project->date_end;
$result = $facture->addline($labelforproduct, floatval($project->price_registration), 1, $vattouse, 0, 0, $productforinvoicerow->id, 0, $date_start, $date_end, 0, 0, '', 'HT', 0, 1);
if ($result <= 0) {
$confattendee->error = $facture->error;
$confattendee->errors = $facture->errors;
$error++;
}
if (!$error) {
$valid = true;
$sourcetouse = 'conferencesubscription';
$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)) {
$redirection .= '&securekey='.dol_hash($conf->global->PAYMENT_SECURITY_TOKEN . $sourcetouse . $reftouse, 2); // Use the source in the hash to avoid duplicates if the references are identical
} else {
$redirection .= '&securekey='.$conf->global->PAYMENT_SECURITY_TOKEN;
}
}
if (!$error) {
$db->commit();
// Registration was recorded and invoice was generated, so we send an email
// TODO
// Now we redirect to the payment page
$sourcetouse = 'organizedeventregistration';
$reftouse = $facture->id;
$redirection = $dolibarr_main_url_root.'/public/payment/newpayment.php?source='.urlencode($sourcetouse).'&ref='.urlencode($reftouse);
if (!empty($conf->global->PAYMENT_SECURITY_TOKEN)) {
if (!empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) {
$redirection .= '&securekey='.dol_hash($conf->global->PAYMENT_SECURITY_TOKEN . $sourcetouse . $reftouse, 2); // Use the source in the hash to avoid duplicates if the references are identical
} else {
$redirection .= '&securekey='.urlencode($conf->global->PAYMENT_SECURITY_TOKEN);
}
Header("Location: ".$redirection);
exit;
}
Header("Location: ".$redirection);
exit;
} else {
$db->rollback();
}
} else {
$db->commit();
// No price has been set
// Validating the subscription
$confattendee->setStatut(1);
@ -464,7 +498,8 @@ if (empty($reshook) && $action == 'add' && (!empty($conference->id) && $conferen
}
$securekeyurl = dol_hash($conf->global->EVENTORGANIZATION_SECUREKEY.'conferenceorbooth'.$id, 2);
$redirection = $dolibarr_main_url_root.'/public/eventorganization/subscriptionok.php?id='.$id.'&securekey='.$securekeyurl;
$redirection = $dolibarr_main_url_root.'/public/eventorganization/subscriptionok.php?id='.((int) $id).'&securekey='.urlencode($securekeyurl);
Header("Location: ".$redirection);
exit;
}
@ -524,8 +559,8 @@ if (!empty($conference->id) && $conference->status==ConferenceOrBooth::STATUS_CO
print '<input type="hidden" name="token" value="' . newToken() . '" / >';
print '<input type="hidden" name="entity" value="' . $entity . '" />';
print '<input type="hidden" name="action" value="add" />';
print '<input type="hidden" name="id" value="' . $conference->id . '" />';
print '<input type="hidden" name="type" value="' . $type . '" />';
print '<input type="hidden" name="id" value="' . $conference->id . '" />';
print '<input type="hidden" name="fk_project" value="' . $project->id . '" />';
print '<input type="hidden" name="securekey" value="' . $securekeyreceived . '" />';

View File

@ -113,11 +113,13 @@ if (!$action) {
}
}
if ($source == 'conferencesubscription') {
if ($source == 'organizedeventregistration') {
// Finding the Attendee
$invoiceid = GETPOST('ref');
$invoiceid = GETPOST('ref', 'int');
$invoice = new Facture($db);
$resultinvoice = $invoice->fetch($invoiceid);
if ($resultinvoice <= 0) {
setEventMessages(null, $invoice->errors, "errors");
} else {
@ -129,9 +131,12 @@ if ($source == 'conferencesubscription') {
$attendee = new ConferenceOrBoothAttendee($db);
$resultattendee = $attendee->fetch($linkedAttendees[0]);
if ($resultattendee <= 0) {
setEventMessages(null, $attendee->errors, "errors");
} else {
$attendee->fetch_projet();
$amount = price2num($invoice->total_ttc);
// Finding the associated thirdparty
$thirdparty = new Societe($db);
@ -1806,9 +1811,9 @@ if ($source == 'donation') {
print '<input type="hidden" name="desc" value="'.dol_escape_htmltag($labeldesc).'">'."\n";
}
if ($source == 'conferencesubscription') {
if ($source == 'organizedeventregistration') {
$found = true;
$langs->load("members");
$langs->loadLangs(array("members", "eventorganization"));
if (GETPOST('fulltag', 'alpha')) {
$fulltag = GETPOST('fulltag', 'alpha');
@ -1833,10 +1838,15 @@ if ($source == 'conferencesubscription') {
print '</b>';
print '</td></tr>'."\n";
if (! is_object($attendee->project)) {
$text = 'ErrorProjectotFound';
} else {
$text = $langs->trans("PaymentEvent").' - '.$attendee->project->title;
}
// Object
$text = '<b>'.$langs->trans("PaymentConferenceAttendee").'</b>';
print '<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans("Designation");
print '</td><td class="CTableRow2">'.$text;
print '</td><td class="CTableRow2"><b>'.$text.'</b>';
print '<input type="hidden" name="source" value="'.dol_escape_htmltag($source).'">';
print '<input type="hidden" name="ref" value="'.dol_escape_htmltag($invoice->id).'">';
print '</td></tr>'."\n";

View File

@ -23,9 +23,10 @@
/**
* \file htdocs/public/payment/paymentok.php
* \ingroup core
* \brief File to show page after a successful payment
* \brief File to show page after a successful payment on a payment line system.
* The payment was already really recorded. So an error here must send warning to admin but must still infor user that payment is ok.
* This page is called by payment system with url provided to it completed with parameter TOKEN=xxx
* This token can be used to get more informations.
* This token and session can be used to get more informations.
*/
if (!defined('NOLOGIN')) {
@ -804,7 +805,7 @@ if ($ispaymentok) {
$ispostactionok = 1;
}
} else {
$postactionmessages[] = 'Setup of bank account to use in module '.$paymentmethod.' was not set. No way to record the payment.';
$postactionmessages[] = 'Setup of bank account to use in module '.$paymentmethod.' was not set. Your payment was really executed but we failed to record it. Please contact us.';
$ispostactionok = -1;
$error++;
}
@ -910,7 +911,7 @@ if ($ispaymentok) {
$ispostactionok = 1;
}
} else {
$postactionmessages[] = 'Setup of bank account to use in module '.$paymentmethod.' was not set. No way to record the payment.';
$postactionmessages[] = 'Setup of bank account to use in module '.$paymentmethod.' was not set. Your payment was really executed but we failed to record it. Please contact us.';
$ispostactionok = -1;
$error++;
}
@ -933,7 +934,7 @@ if ($ispaymentok) {
// TODO send email with acknowledgment for the donation
// (need that the donation module can gen a pdf document for the cerfa with pre filled content)
} elseif (array_key_exists('ATT', $tmptag) && $tmptag['ATT'] > 0) {
// Record payment for attendee
// Record payment for registration to an event for an attendee
include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
$object = new Facture($db);
$result = $object->fetch($ref);
@ -985,7 +986,7 @@ if ($ispaymentok) {
}
$paiement->paiementid = $paymentTypeId;
$paiement->num_payment = '';
$paiement->note_public = 'Online payment '.dol_print_date($now, 'standard').' from '.$ipaddress;
$paiement->note_public = 'Online payment '.dol_print_date($now, 'standard').' from '.$ipaddress.' for event registration';
$paiement->ext_payment_id = $TRANSACTIONID;
$paiement->ext_payment_site = $service;
@ -1026,77 +1027,86 @@ if ($ispaymentok) {
$ispostactionok = 1;
}
} else {
$postactionmessages[] = 'Setup of bank account to use in module '.$paymentmethod.' was not set. No way to record the payment.';
$postactionmessages[] = 'Setup of bank account to use in module '.$paymentmethod.' was not set. Your payment was really executed but we failed to record it. Please contact us.';
$ispostactionok = -1;
$error++;
}
}
if (!$error) {
$db->commit();
// Validating the attendee
$attendeetovalidate = new ConferenceOrBoothAttendee($db);
$resultattendee = $attendeetovalidate->fetch($tmptag['ATT']);
if ($resultattendee < 0) {
$error++;
setEventMessages(null, $attendeetovalidate->errors, "errors");
} else {
$attendeetovalidate->amount=$FinalPaymentAmt;
$attendeetovalidate->update($user);
$attendeetovalidate->validate($user);
// Sending mail
$thirdparty = new Societe($db);
$resultthirdparty = $thirdparty->fetch($attendeetovalidate->fk_soc);
if ($resultthirdparty < 0) {
setEventMessages(null, $attendeetovalidate->errors, "errors");
$attendeetovalidate->amount = $FinalPaymentAmt;
$attendeetovalidate->date_subscription = dol_now();
$attendeetovalidate->update($user);
}
}
if (!$error) {
$db->commit();
} else {
setEventMessages(null, $postactionmessages, 'warnings');
$db->rollback();
}
if (! $error) {
// Sending mail
$thirdparty = new Societe($db);
$resultthirdparty = $thirdparty->fetch($attendeetovalidate->fk_soc);
if ($resultthirdparty < 0) {
setEventMessages(null, $attendeetovalidate->errors, "errors");
} else {
require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php';
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($thirdparty->default_lang) ? $mysoc->default_lang : $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, 'conferenceorbooth', $user, $outputlangs, $labeltouse, 1, '');
}
if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) {
$subject = $arraydefaultmessage->topic;
$msg = $arraydefaultmessage->content;
}
$substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $thirdparty);
complete_substitutions_array($substitutionarray, $outputlangs, $object);
$subjecttosend = make_substitutions($subject, $substitutionarray, $outputlangs);
$texttosend = make_substitutions($msg, $substitutionarray, $outputlangs);
$sendto = $attendeetovalidate->email;
$from = $conf->global->MAILING_EMAIL_FROM;
$urlback = $_SERVER["REQUEST_URI"];
$ishtml = dol_textishtml($texttosend); // May contain urls
$mailfile = new CMailFile($subjecttosend, $sendto, $from, $texttosend, array(), array(), array(), '', '', 0, $ishtml);
$result = $mailfile->sendfile();
if ($result) {
dol_syslog("EMail sent to ".$sendto, LOG_DEBUG, 0, '_payment');
} else {
require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php';
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($thirdparty->default_lang) ? $mysoc->default_lang : $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, 'conferenceorbooth', $user, $outputlangs, $labeltouse, 1, '');
}
if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) {
$subject = $arraydefaultmessage->topic;
$msg = $arraydefaultmessage->content;
}
$substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $thirdparty);
complete_substitutions_array($substitutionarray, $outputlangs, $object);
$subjecttosend = make_substitutions($subject, $substitutionarray, $outputlangs);
$texttosend = make_substitutions($msg, $substitutionarray, $outputlangs);
$sendto = $attendeetovalidate->email;
$from = $conf->global->MAILING_EMAIL_FROM;
$urlback = $_SERVER["REQUEST_URI"];
$ishtml = dol_textishtml($texttosend); // May contain urls
$mailfile = new CMailFile($subjecttosend, $sendto, $from, $texttosend, array(), array(), array(), '', '', 0, $ishtml);
$result = $mailfile->sendfile();
if ($result) {
dol_syslog("EMail sent to ".$sendto, LOG_DEBUG, 0, '_payment');
} else {
dol_syslog("Failed to send EMail to ".$sendto, LOG_ERR, 0, '_payment');
}
dol_syslog("Failed to send EMail to ".$sendto, LOG_ERR, 0, '_payment');
}
}
} else {
$db->rollback();
}
}
} else {
@ -1201,7 +1211,7 @@ if ($ispaymentok) {
$ispostactionok = 1;
}
} else {
$postactionmessages[] = 'Setup of bank account to use in module '.$paymentmethod.' was not set. No way to record the payment.';
$postactionmessages[] = 'Setup of bank account to use in module '.$paymentmethod.' was not set. Your payment was really executed but we failed to record it. Please contact us.';
$ispostactionok = -1;
$error++;
}