From eef5b9514d3f1ca219ef807e23aa633bd6547225 Mon Sep 17 00:00:00 2001 From: Dorian Vabre Date: Fri, 9 Apr 2021 16:55:54 +0200 Subject: [PATCH 001/147] wip --- .../eventorganization/attendee_subscription.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/htdocs/public/eventorganization/attendee_subscription.php b/htdocs/public/eventorganization/attendee_subscription.php index 885058d34bb..2e49ad131d9 100644 --- a/htdocs/public/eventorganization/attendee_subscription.php +++ b/htdocs/public/eventorganization/attendee_subscription.php @@ -263,6 +263,19 @@ if (empty($reshook) && $action == 'add') { if (!$error) { $db->commit(); + + $project = new Project($db); + $resultproject = $project->fetch($object->fk_project); + if ($resultproject < 0){ + $error++; + $errmsg .= $project->error; + } else { + if (!empty($project->price_registration)){ + // @todo traiter invoice et payment page + } + } + + // invoice //Header("Location: ".$urlback); //exit; } else { From ebd5f292318c538e88709fffc2681f7f87e2c0c0 Mon Sep 17 00:00:00 2001 From: Dorian Vabre Date: Mon, 12 Apr 2021 15:44:25 +0200 Subject: [PATCH 002/147] invoice OK except price, wip on the payment page --- .../attendee_subscription.php | 47 +++++++++++++------ 1 file changed, 33 insertions(+), 14 deletions(-) diff --git a/htdocs/public/eventorganization/attendee_subscription.php b/htdocs/public/eventorganization/attendee_subscription.php index b044ad2e914..172e6cee798 100644 --- a/htdocs/public/eventorganization/attendee_subscription.php +++ b/htdocs/public/eventorganization/attendee_subscription.php @@ -66,6 +66,8 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.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.'/projet/class/project.class.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; // Init vars @@ -78,6 +80,12 @@ $action = GETPOST('action', 'aZ09'); $key = 'DV3PH'; $id = dol_decode(GETPOST('id'), $key); +$conference = new ConferenceOrBooth($db); +$resultconf = $conference->fetch($id); +if ($resultconf < 0) { + setEventMessages(null, $object->errors, "errors"); +} + // Securekey check $securekey = GETPOST('securekey', 'alpha'); if ($securekey != $conf->global->EVENTORGANIZATION_SECUREKEY) { @@ -258,22 +266,39 @@ if (empty($reshook) && $action == 'add') { } } } - if (!$error) { $db->commit(); - $project = new Project($db); - $resultproject = $project->fetch($object->fk_project); - if ($resultproject < 0){ + $resultproject = $project->fetch($conference->fk_project); + if ($resultproject < 0){ $error++; $errmsg .= $project->error; } else { - if (!empty($project->price_registration)){ - // @todo traiter invoice et payment page + var_dump($project->price_registration); + if (!empty(floatval($project->price_registration))){ + $facture = new Facture($db); + //$facture->rowid = ; + //$facture->ref = ; + //$facture->entity = ; + $facture->type = 0; + $facture->socid = $thirdparty->id; + $facture->paye = 0; + //$facture->fk_user_modif = ; + //$facture->fk_cond_reglement = ; + //$facture->tms = ; + //$facture->fk_statut = ; + $facture->date = dol_now(); + $resultfacture = $facture->create($user); + } else { + // No price has been set + // Validating the subscription + $confattendee->setStatut(1); + global $dolibarr_main_url_root; + $redirection = $dolibarr_main_url_root.'/public/eventorganization/subscriptionok.php'; + Header("Location: ".$redirection); + exit; } } - - // invoice //Header("Location: ".$urlback); //exit; } else { @@ -289,12 +314,6 @@ if (empty($reshook) && $action == 'add') { $form = new Form($db); $formcompany = new FormCompany($db); -$conference = new ConferenceOrBooth($db); -$resultconf = $conference->fetch($id); -if ($resultconf < 0) { - setEventMessages(null, $object->errors, "errors"); -} - llxHeaderVierge($langs->trans("NewSubscription")); From 15d103e957f94e63d1b9b50fd80bd7fcff69ad4f Mon Sep 17 00:00:00 2001 From: Dorian Vabre Date: Mon, 12 Apr 2021 15:52:49 +0200 Subject: [PATCH 003/147] subs validation for free conferences added --- htdocs/langs/en_US/eventorganization.lang | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/htdocs/langs/en_US/eventorganization.lang b/htdocs/langs/en_US/eventorganization.lang index 03fb460d6b9..302790f91f0 100644 --- a/htdocs/langs/en_US/eventorganization.lang +++ b/htdocs/langs/en_US/eventorganization.lang @@ -98,3 +98,7 @@ MissingOrBadSecureKey = The security key is invalid or missing EvntOrgWelcomeMessage = This form allows you to register as a new participant to the conference EvntOrgStartDuration = This conference starts on EvntOrgEndDuration = and ends on +# +# SubscriptionOk page +# +SubscriptionOk = Your subscription to this conference has been validated From e1fb368d3a40662623f02199f528540a073055b7 Mon Sep 17 00:00:00 2001 From: Dorian Vabre Date: Mon, 12 Apr 2021 16:50:56 +0200 Subject: [PATCH 004/147] wip --- .../public/eventorganization/attendee_subscription.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/htdocs/public/eventorganization/attendee_subscription.php b/htdocs/public/eventorganization/attendee_subscription.php index 172e6cee798..0adf783ee05 100644 --- a/htdocs/public/eventorganization/attendee_subscription.php +++ b/htdocs/public/eventorganization/attendee_subscription.php @@ -274,7 +274,7 @@ if (empty($reshook) && $action == 'add') { $error++; $errmsg .= $project->error; } else { - var_dump($project->price_registration); + global $dolibarr_main_url_root; if (!empty(floatval($project->price_registration))){ $facture = new Facture($db); //$facture->rowid = ; @@ -288,12 +288,15 @@ if (empty($reshook) && $action == 'add') { //$facture->tms = ; //$facture->fk_statut = ; $facture->date = dol_now(); - $resultfacture = $facture->create($user); + $resultfacture = $facture->create($user); + //@todo rediriger page paiement + $redirection = $dolibarr_main_url_root.'/public/payment/newpayment.php'; + Header("Location: ".$redirection); + exit; } else { // No price has been set // Validating the subscription $confattendee->setStatut(1); - global $dolibarr_main_url_root; $redirection = $dolibarr_main_url_root.'/public/eventorganization/subscriptionok.php'; Header("Location: ".$redirection); exit; From db8dfb219cbea1814ba6f7f951e91fe9dcff06e9 Mon Sep 17 00:00:00 2001 From: Dorian Vabre Date: Tue, 13 Apr 2021 14:10:20 +0200 Subject: [PATCH 005/147] addition of the subscriptionok page when the subscription price is not set or 0 --- .../eventorganization/subscriptionok.php | 156 ++++++++++++++++++ 1 file changed, 156 insertions(+) create mode 100644 htdocs/public/eventorganization/subscriptionok.php diff --git a/htdocs/public/eventorganization/subscriptionok.php b/htdocs/public/eventorganization/subscriptionok.php new file mode 100644 index 00000000000..c12c1053e97 --- /dev/null +++ b/htdocs/public/eventorganization/subscriptionok.php @@ -0,0 +1,156 @@ + + * Copyright (C) 2006-2013 Laurent Destailleur + * Copyright (C) 2012 Regis Houssin + * Copyright (C) 2021 Waël Almoman + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/public/payment/paymentok.php + * \ingroup core + * \brief File to show page after a successful payment + * 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. + */ + +if (!defined('NOLOGIN')) { + define("NOLOGIN", 1); // This means this output page does not require to be logged. +} +if (!defined('NOCSRFCHECK')) { + define("NOCSRFCHECK", 1); // We accept to go on this page from external web site. +} +if (!defined('NOIPCHECK')) { + define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip +} +if (!defined('NOBROWSERNOTIF')) { + define('NOBROWSERNOTIF', '1'); +} + +// For MultiCompany module. +// Do not use GETPOST here, function is not defined and define must be done before including main.inc.php +// TODO This should be useless. Because entity must be retrieve from object ref and not from url. +$entity = (!empty($_GET['e']) ? (int) $_GET['e'] : (!empty($_POST['e']) ? (int) $_POST['e'] : 1)); +if (is_numeric($entity)) { + define("DOLENTITY", $entity); +} + +require '../../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php'; + +if (!empty($conf->paypal->enabled)) { + require_once DOL_DOCUMENT_ROOT.'/paypal/lib/paypal.lib.php'; + require_once DOL_DOCUMENT_ROOT.'/paypal/lib/paypalfunctions.lib.php'; +} + +$langs->loadLangs(array("main", "companies", "install", "other", "eventorganization")); + +$object = new stdClass(); // For triggers + +$error = 0; + + +/* + * Actions + */ + + + +/* + * View + */ + +$now = dol_now(); + +dol_syslog("Callback url when a payment was done. query_string=".(dol_escape_htmltag($_SERVER["QUERY_STRING"]) ?dol_escape_htmltag($_SERVER["QUERY_STRING"]) : '')." script_uri=".(dol_escape_htmltag($_SERVER["SCRIPT_URI"]) ?dol_escape_htmltag($_SERVER["SCRIPT_URI"]) : ''), LOG_DEBUG, 0, '_payment'); + +$tracepost = ""; +foreach ($_POST as $k => $v) { + $tracepost .= "{$k} - {$v}\n"; +} +dol_syslog("POST=".$tracepost, LOG_DEBUG, 0, '_payment'); + +$head = ''; +if (!empty($conf->global->ONLINE_PAYMENT_CSS_URL)) { + $head = ''."\n"; +} + +$conf->dol_hide_topmenu = 1; +$conf->dol_hide_leftmenu = 1; + +$replacemainarea = (empty($conf->dol_hide_leftmenu) ? '
' : '').'
'; +llxHeader($head, $langs->trans("PaymentForm"), '', '', 0, 0, '', '', '', 'onlinepaymentbody', $replacemainarea); + + +// Show message +print ''."\n"; +print '
'."\n"; + + +// Show logo (search order: logo defined by PAYMENT_LOGO_suffix, then PAYMENT_LOGO, then small company logo, large company logo, theme logo, common logo) +// Define logo and logosmall +$logosmall = $mysoc->logo_small; +$logo = $mysoc->logo; +$paramlogo = 'ONLINE_PAYMENT_LOGO_'.$suffix; +if (!empty($conf->global->$paramlogo)) { + $logosmall = $conf->global->$paramlogo; +} elseif (!empty($conf->global->ONLINE_PAYMENT_LOGO)) { + $logosmall = $conf->global->ONLINE_PAYMENT_LOGO; +} +//print ''."\n"; +// Define urllogo +$urllogo = ''; +$urllogofull = ''; +if (!empty($logosmall) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$logosmall)) { + $urllogo = DOL_URL_ROOT.'/viewimage.php?modulepart=mycompany&entity='.$conf->entity.'&file='.urlencode('logos/thumbs/'.$logosmall); + $urllogofull = $dolibarr_main_url_root.'/viewimage.php?modulepart=mycompany&entity='.$conf->entity.'&file='.urlencode('logos/thumbs/'.$logosmall); +} elseif (!empty($logo) && is_readable($conf->mycompany->dir_output.'/logos/'.$logo)) { + $urllogo = DOL_URL_ROOT.'/viewimage.php?modulepart=mycompany&entity='.$conf->entity.'&file='.urlencode('logos/'.$logo); + $urllogofull = $dolibarr_main_url_root.'/viewimage.php?modulepart=mycompany&entity='.$conf->entity.'&file='.urlencode('logos/'.$logo); +} + +// Output html code for logo +if ($urllogo) { + print '
'; + print '
'; + print ''; + print '
'; + if (empty($conf->global->MAIN_HIDE_POWERED_BY)) { + print ''; + } + print '
'; +} + + +print '


'; + +print $langs->trans("SubscriptionOk"); + +print "\n
\n"; + + +htmlPrintOnlinePaymentFooter($mysoc, $langs, 0, $suffix); + + +// Clean session variables to avoid duplicate actions if post is resent +unset($_SESSION["FinalPaymentAmt"]); +unset($_SESSION["TRANSACTIONID"]); + + +llxFooter('', 'public'); + +$db->close(); \ No newline at end of file From 633a3d39c6bbfecf3df67edf3e13fbeebf9234b4 Mon Sep 17 00:00:00 2001 From: Dorian Vabre Date: Tue, 13 Apr 2021 14:32:17 +0200 Subject: [PATCH 006/147] wip on adding taxes and price to invoice --- .../attendee_subscription.php | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/htdocs/public/eventorganization/attendee_subscription.php b/htdocs/public/eventorganization/attendee_subscription.php index ba52057b796..1887754bf23 100644 --- a/htdocs/public/eventorganization/attendee_subscription.php +++ b/htdocs/public/eventorganization/attendee_subscription.php @@ -284,7 +284,7 @@ if (empty($reshook) && $action == 'add') { } if (!$error) { - $db->commit(); + $db->commit(); $project = new Project($db); $resultproject = $project->fetch($conference->fk_project); if ($resultproject < 0){ @@ -294,22 +294,22 @@ if (empty($reshook) && $action == 'add') { global $dolibarr_main_url_root; if (!empty(floatval($project->price_registration))){ $facture = new Facture($db); - //$facture->rowid = ; - //$facture->ref = ; - //$facture->entity = ; $facture->type = 0; $facture->socid = $thirdparty->id; $facture->paye = 0; - //$facture->fk_user_modif = ; - //$facture->fk_cond_reglement = ; - //$facture->tms = ; - //$facture->fk_statut = ; + //@todo price and taxes to add + $tva = get_default_tva($mysoc, $thirdparty); + $facture->date = dol_now(); $resultfacture = $facture->create($user); - //@todo rediriger page paiement - $redirection = $dolibarr_main_url_root.'/public/payment/newpayment.php'; - Header("Location: ".$redirection); - exit; + if ($resultfacture < 0){ + $error++; + $errmsg .= $facture->error; + } else { + $redirection = $dolibarr_main_url_root.'/public/payment/newpayment.php'; + Header("Location: ".$redirection); + exit; + } } else { // No price has been set // Validating the subscription From a3e75c587c425a908b81b898061e570873b887af Mon Sep 17 00:00:00 2001 From: Dorian Vabre Date: Tue, 13 Apr 2021 15:07:15 +0200 Subject: [PATCH 007/147] adding amount and source to redirection url to newpayment --- htdocs/public/eventorganization/attendee_subscription.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/public/eventorganization/attendee_subscription.php b/htdocs/public/eventorganization/attendee_subscription.php index 1887754bf23..f5efd274edf 100644 --- a/htdocs/public/eventorganization/attendee_subscription.php +++ b/htdocs/public/eventorganization/attendee_subscription.php @@ -306,7 +306,7 @@ if (empty($reshook) && $action == 'add') { $error++; $errmsg .= $facture->error; } else { - $redirection = $dolibarr_main_url_root.'/public/payment/newpayment.php'; + $redirection = $dolibarr_main_url_root.'/public/payment/newpayment.php?amount='.$project->price_registration.'&source=conferenceattendeesubscription'; Header("Location: ".$redirection); exit; } From 339596f13410f7358ffce6b7bd74c92aae404e13 Mon Sep 17 00:00:00 2001 From: Dorian Vabre Date: Tue, 13 Apr 2021 15:30:28 +0200 Subject: [PATCH 008/147] ref add in redirection url to payment page --- htdocs/public/eventorganization/attendee_subscription.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/public/eventorganization/attendee_subscription.php b/htdocs/public/eventorganization/attendee_subscription.php index f5efd274edf..a47a93557d3 100644 --- a/htdocs/public/eventorganization/attendee_subscription.php +++ b/htdocs/public/eventorganization/attendee_subscription.php @@ -306,7 +306,8 @@ if (empty($reshook) && $action == 'add') { $error++; $errmsg .= $facture->error; } else { - $redirection = $dolibarr_main_url_root.'/public/payment/newpayment.php?amount='.$project->price_registration.'&source=conferenceattendeesubscription'; + $thirdparty->fetch('', '', '', '', '', '', '', '', '', '', $email); + $redirection = $dolibarr_main_url_root.'/public/payment/newpayment.php?amount='.$project->price_registration.'&source=conferenceattendeesubscription&ref='.$thirdparty->ref; Header("Location: ".$redirection); exit; } From 55afc59db25c55839a8df10dcdd267d9a763ed60 Mon Sep 17 00:00:00 2001 From: Dorian Vabre Date: Wed, 14 Apr 2021 14:33:11 +0200 Subject: [PATCH 009/147] removed useless fetch, moved link to the fetch method of the conferenceorbooth class, wip on service to use on the invoice --- htdocs/admin/eventorganization.php | 19 +++++++++++++++++++ .../class/conferenceorbooth.class.php | 12 ++++++++++++ .../conferenceorbooth_card.php | 12 +----------- htdocs/langs/en_US/eventorganization.lang | 2 ++ .../attendee_subscription.php | 4 ++-- 5 files changed, 36 insertions(+), 13 deletions(-) diff --git a/htdocs/admin/eventorganization.php b/htdocs/admin/eventorganization.php index b6a964d8617..c76d9a5c188 100644 --- a/htdocs/admin/eventorganization.php +++ b/htdocs/admin/eventorganization.php @@ -61,6 +61,8 @@ $arrayofparameters = array( 'EVENTORGANIZATION_TEMPLATE_EMAIL_BULK_SPEAKER'=>array('type'=>'emailtemplate:eventorganization_send', 'enabled'=>1), 'EVENTORGANIZATION_TEMPLATE_EMAIL_BULK_ATTENDES'=>array('type'=>'emailtemplate:eventorganization_send', 'enabled'=>1), 'EVENTORGANIZATION_SECUREKEY'=>array('type'=>'securekey', 'enabled'=>1), + 'SERVICE_BOOTH_LOCATION'=>array('type'=>'product', 'enabled'=>1), + 'SERVICE_CONFERENCE_ATTENDEE_SUBSCRIPTION'=>array('type'=>'product', 'enabled'=>1), ); $error = 0; @@ -276,6 +278,23 @@ if ($action == 'edit') { });'; print ''; } + } elseif ($var['type'] == 'product') { + if (!empty($conf->product->enabled) || !empty($conf->service->enabled)) { + print ''.$langs->trans("ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS").''; + print ''; + $selected = (empty($conf->global->$constname) ? '' : $conf->global->$constname); + $form->select_produits($selected, $constname, '', 0); + print ''; + print "\n"; + } + if (!empty($conf->product->enabled) || !empty($conf->service->enabled)) { + print ''.$langs->trans("ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS").''; + print ''; + $selected = (empty($conf->global->$constname) ? '' : $conf->global->$constname); + $form->select_produits($selected, $constname, '', 0); + print ''; + } + print "\n"; } else { print ''; } diff --git a/htdocs/eventorganization/class/conferenceorbooth.class.php b/htdocs/eventorganization/class/conferenceorbooth.class.php index 41fe4ebd94d..b859c10a98d 100644 --- a/htdocs/eventorganization/class/conferenceorbooth.class.php +++ b/htdocs/eventorganization/class/conferenceorbooth.class.php @@ -237,7 +237,19 @@ class ConferenceOrBooth extends ActionComm */ public function fetch($id, $ref = null, $ref_ext = '', $email_msgid = '') { + global $dolibarr_main_url_root, $dolibarr_main_instance_unique_id, $conf, $langs; + $result = parent::fetch($id, $ref, $ref_ext, $email_msgid); + + $encodedid = dol_encode($id, $dolibarr_main_instance_unique_id); + $link_subscription = $dolibarr_main_url_root.'/public/eventorganization/attendee_subscription.php?id='.$encodedid; + + $encodedsecurekey = dol_encode($conf->global->EVENTORGANIZATION_SECUREKEY.$encodedid, $dolibarr_main_instance_unique_id); + $link_subscription .= '&securekey='.urlencode($encodedsecurekey); + + $this->fields['pubregister'] = array('type'=>'url', 'label'=>$langs->trans("PublicAttendeeSubscriptionPage"), 'enabled'=>'1', 'position'=>72, 'notnull'=>0, 'visible'=>1); + $this->pubregister = $link_subscription; + $this->getActionCommFields(); return $result; } diff --git a/htdocs/eventorganization/conferenceorbooth_card.php b/htdocs/eventorganization/conferenceorbooth_card.php index 15b52eda038..fc232406ce9 100644 --- a/htdocs/eventorganization/conferenceorbooth_card.php +++ b/htdocs/eventorganization/conferenceorbooth_card.php @@ -493,18 +493,8 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea //$keyforbreak='fieldkeytoswitchonsecondcolumn'; // We change column just before this field //unset($object->fields['fk_project']); // Hide field already shown in banner //unset($object->fields['fk_soc']); // Hide field already shown in banner - global $dolibarr_main_url_root; - - $encodedid = dol_encode($id, $dolibarr_main_instance_unique_id); - $link_subscription = $dolibarr_main_url_root.'/public/eventorganization/attendee_subscription.php?id='.$encodedid; - - $encodedsecurekey = dol_encode($conf->global->EVENTORGANIZATION_SECUREKEY.$encodedid, $dolibarr_main_instance_unique_id); - $link_subscription .= '&securekey='.urlencode($encodedsecurekey); - - $object->fields['pubregister'] = array('type'=>'url', 'label'=>$langs->trans("PublicAttendeeSubscriptionPage"), 'enabled'=>'1', 'position'=>72, 'notnull'=>0, 'visible'=>1); - $object->pubregister = $link_subscription; $keyforbreak='pubregister'; - + include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_view.tpl.php'; //var_dump($object); // Other attributes. Fields from hook formObjectOptions and Extrafields. diff --git a/htdocs/langs/en_US/eventorganization.lang b/htdocs/langs/en_US/eventorganization.lang index fbee3de4e3d..3fc655b92e9 100644 --- a/htdocs/langs/en_US/eventorganization.lang +++ b/htdocs/langs/en_US/eventorganization.lang @@ -82,6 +82,8 @@ EventOrganizationICSLink=Link ICS for events ConferenceOrBoothInformation=Conference Or Booth informations Attendees = Attendees EVENTORGANIZATION_SECUREKEY = Secure Key of the public registration link to a conference +SERVICE_BOOTH_LOCATION = Service used for the invoice row about a booth location +SERVICE_CONFERENCE_ATTENDEE_SUBSCRIPTION = Service used for the invoice row about an attendee subscription to a conference # # Status # diff --git a/htdocs/public/eventorganization/attendee_subscription.php b/htdocs/public/eventorganization/attendee_subscription.php index a47a93557d3..9aa1ca7d2e0 100644 --- a/htdocs/public/eventorganization/attendee_subscription.php +++ b/htdocs/public/eventorganization/attendee_subscription.php @@ -299,14 +299,14 @@ if (empty($reshook) && $action == 'add') { $facture->paye = 0; //@todo price and taxes to add $tva = get_default_tva($mysoc, $thirdparty); - $facture->date = dol_now(); + $resultfacture = $facture->create($user); if ($resultfacture < 0){ $error++; $errmsg .= $facture->error; } else { - $thirdparty->fetch('', '', '', '', '', '', '', '', '', '', $email); + // @todo corriger la réf qui est surement celle de la facture au lieu du client $redirection = $dolibarr_main_url_root.'/public/payment/newpayment.php?amount='.$project->price_registration.'&source=conferenceattendeesubscription&ref='.$thirdparty->ref; Header("Location: ".$redirection); exit; From a91a9256a34f8a7d59d5d9cae36ff531d4471941 Mon Sep 17 00:00:00 2001 From: NextGestion Date: Wed, 14 Apr 2021 13:49:26 +0100 Subject: [PATCH 010/147] Fix extrafields in list --- htdocs/partnership/partnership_list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/partnership/partnership_list.php b/htdocs/partnership/partnership_list.php index 408b7355ab1..e03ed536806 100644 --- a/htdocs/partnership/partnership_list.php +++ b/htdocs/partnership/partnership_list.php @@ -266,7 +266,7 @@ $sql .= $object->getFieldList('t'); // Add fields from extrafields if (!empty($extrafields->attributes[$object->table_element]['label'])) { foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { - $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key.' as options_'.$key.', ' : ''); + $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : ''); } } // Add fields from hooks From 4e45011e45bc44f41434d19396fca77b7c413fb6 Mon Sep 17 00:00:00 2001 From: NextGestion Date: Wed, 14 Apr 2021 13:59:38 +0100 Subject: [PATCH 011/147] Manage Partnership for third-party --- htdocs/core/modules/modPartnership.class.php | 4 +- htdocs/langs/en_US/partnership.lang | 1 + htdocs/partnership/admin/setup.php | 4 +- .../partnership/class/partnership.class.php | 154 ++++- .../class/partnershiputils.class.php | 2 +- htdocs/partnership/partnership_card.php | 22 +- htdocs/societe/partnership.php | 614 ++++++++++++++++++ 7 files changed, 743 insertions(+), 58 deletions(-) create mode 100644 htdocs/societe/partnership.php diff --git a/htdocs/core/modules/modPartnership.class.php b/htdocs/core/modules/modPartnership.class.php index 442e01b56f6..9f8c1437eee 100644 --- a/htdocs/core/modules/modPartnership.class.php +++ b/htdocs/core/modules/modPartnership.class.php @@ -180,10 +180,10 @@ class modPartnership extends DolibarrModules $tabtoadd = ($conf->global->PARTNERSHIP_IS_MANAGED_FOR == 'member') ? 'member' : 'thirdparty'; if ($tabtoadd == 'member') { - $this->tabs[] = array('data'=>'member:+partnership:Partnership:partnership@partnership:$user->rights->partnership->read:/partnership/partnership.php?socid=__ID__'); + $this->tabs[] = array('data'=>'member:+partnership:Partnership:partnership@partnership:$user->rights->partnership->read:/adherents/partnership.php?socid=__ID__'); $fk_mainmenu = "members"; } else { - $this->tabs[] = array('data'=>'thirdparty:+partnership:Partnership:partnership@partnership:$user->rights->partnership->read:/partnership/partnership.php?socid=__ID__'); + $this->tabs[] = array('data'=>'thirdparty:+partnership:Partnership:partnership@partnership:$user->rights->partnership->read:/societe/partnership.php?socid=__ID__'); $fk_mainmenu = "companies"; } diff --git a/htdocs/langs/en_US/partnership.lang b/htdocs/langs/en_US/partnership.lang index 63b3bec0bb6..e9fb30d1fd6 100644 --- a/htdocs/langs/en_US/partnership.lang +++ b/htdocs/langs/en_US/partnership.lang @@ -37,6 +37,7 @@ PartnershipAboutPage = Partnership about page # # Object # +PartnershipDedicatedToThisThirdParty=Partnership dedicated to this third party DatePartnershipStart=Start date DatePartnershipEnd=End date diff --git a/htdocs/partnership/admin/setup.php b/htdocs/partnership/admin/setup.php index d55daab2347..6ba689cbd00 100644 --- a/htdocs/partnership/admin/setup.php +++ b/htdocs/partnership/admin/setup.php @@ -91,10 +91,10 @@ if ($action == 'setting') { $partnership->tabs = array(); if ($modulemenu == 'member') { - $partnership->tabs[] = array('data'=>'member:+partnership:Partnership:partnership@partnership:$user->rights->partnership->read:/partnership/partnership.php?socid=__ID__'); + $partnership->tabs[] = array('data'=>'member:+partnership:Partnership:partnership@partnership:$user->rights->partnership->read:/adherents/partnership.php?socid=__ID__'); $fk_mainmenu = "members"; } else { - $partnership->tabs[] = array('data'=>'thirdparty:+partnership:Partnership:partnership@partnership:$user->rights->partnership->read:/partnership/partnership.php?socid=__ID__'); + $partnership->tabs[] = array('data'=>'thirdparty:+partnership:Partnership:partnership@partnership:$user->rights->partnership->read:/societe/partnership.php?socid=__ID__'); $fk_mainmenu = "companies"; } diff --git a/htdocs/partnership/class/partnership.class.php b/htdocs/partnership/class/partnership.class.php index 019d72a6012..6a676bf24e9 100644 --- a/htdocs/partnership/class/partnership.class.php +++ b/htdocs/partnership/class/partnership.class.php @@ -100,26 +100,7 @@ class Partnership extends CommonObject /** * @var array Array with all fields and their property. Do not use it as a static var. It may be modified by constructor. */ - public $fields=array( - 'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>'1', 'position'=>1, 'notnull'=>1, 'visible'=>0, 'noteditable'=>'1', 'index'=>1, 'css'=>'left', 'comment'=>"Id"), - 'ref' => array('type'=>'varchar(128)', 'label'=>'Ref', 'enabled'=>'1', 'position'=>10, 'notnull'=>1, 'visible'=>4, 'noteditable'=>'1', 'default'=>'(PROV)', 'index'=>1, 'searchall'=>1, 'showoncombobox'=>'1', 'comment'=>"Reference of object"), - 'fk_soc' => array('type'=>'integer:Societe:societe/class/societe.class.php:1:status=1 AND entity IN (__SHARED_ENTITIES__)', 'label'=>'ThirdParty', 'enabled'=>'1', 'position'=>50, 'notnull'=>-1, 'visible'=>1, 'index'=>1,), - 'note_public' => array('type'=>'html', 'label'=>'NotePublic', 'enabled'=>'1', 'position'=>61, 'notnull'=>0, 'visible'=>0,), - 'note_private' => array('type'=>'html', 'label'=>'NotePrivate', 'enabled'=>'1', 'position'=>62, 'notnull'=>0, 'visible'=>0,), - 'date_creation' => array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>'1', 'position'=>500, 'notnull'=>1, 'visible'=>-2,), - 'tms' => array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>'1', 'position'=>501, 'notnull'=>0, 'visible'=>-2,), - 'fk_user_creat' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserAuthor', 'enabled'=>'1', 'position'=>510, 'notnull'=>1, 'visible'=>-2, 'foreignkey'=>'user.rowid',), - 'fk_user_modif' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserModif', 'enabled'=>'1', 'position'=>511, 'notnull'=>-1, 'visible'=>-2,), - 'last_main_doc' => array('type'=>'varchar(255)', 'label'=>'LastMainDoc', 'enabled'=>'1', 'position'=>600, 'notnull'=>0, 'visible'=>0,), - 'import_key' => array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>'1', 'position'=>1000, 'notnull'=>-1, 'visible'=>-2,), - 'model_pdf' => array('type'=>'varchar(255)', 'label'=>'Model pdf', 'enabled'=>'1', 'position'=>1010, 'notnull'=>-1, 'visible'=>0,), - 'status' => array('type'=>'smallint', 'label'=>'Status', 'enabled'=>'1', 'position'=>1000, 'notnull'=>1, 'visible'=>1, 'index'=>1, 'arrayofkeyval'=>array('0'=>'Brouillon', '1'=>'Accepté', '2'=>'Refusé', '9'=>'Annulé'),), - 'fk_member' => array('type'=>'integer:Adherent:adherents/class/adherent.class.php:1', 'label'=>'Member', 'enabled'=>'1', 'position'=>51, 'notnull'=>-1, 'visible'=>1, 'index'=>1,), - 'date_partnership_start' => array('type'=>'datetime', 'label'=>'DatePartnershipStart', 'enabled'=>'1', 'position'=>52, 'notnull'=>1, 'visible'=>1,), - 'date_partnership_end' => array('type'=>'datetime', 'label'=>'DatePartnershipEnd', 'enabled'=>'1', 'position'=>53, 'notnull'=>1, 'visible'=>1,), - 'count_last_url_check_error' => array('type'=>'integer', 'label'=>'CountLastUrlCheckError', 'enabled'=>'1', 'position'=>63, 'notnull'=>0, 'visible'=>-2, 'default'=>'0',), - 'reason_decline_or_cancel' => array('type'=>'text', 'label'=>'ReasonDeclineOrCancel', 'enabled'=>'1', 'position'=>64, 'notnull'=>0, 'visible'=>-2,), - ); + public $fields=array(); public $rowid; public $ref; public $fk_soc; @@ -188,12 +169,37 @@ class Partnership extends CommonObject $this->db = $db; + $fk_soc_visible = ($conf->global->PARTNERSHIP_IS_MANAGED_FOR == 'member') ? 0 : 1; + $fk_member_visible = ($conf->global->PARTNERSHIP_IS_MANAGED_FOR == 'member') ? 1 : 0; + + $this->fields=array( + 'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>'1', 'position'=>1, 'notnull'=>1, 'visible'=>0, 'noteditable'=>'1', 'index'=>1, 'css'=>'left', 'comment'=>"Id"), + 'ref' => array('type'=>'varchar(128)', 'label'=>'Ref', 'enabled'=>'1', 'position'=>10, 'notnull'=>1, 'visible'=>4, 'noteditable'=>'1', 'default'=>'(PROV)', 'index'=>1, 'searchall'=>1, 'showoncombobox'=>'1', 'comment'=>"Reference of object"), + 'fk_soc' => array('type'=>'integer:Societe:societe/class/societe.class.php:1:status=1 AND entity IN (__SHARED_ENTITIES__)', 'label'=>'ThirdParty', 'enabled'=>'1', 'position'=>50, 'notnull'=>-1, 'visible'=>$fk_soc_visible, 'index'=>1,), + 'fk_member' => array('type'=>'integer:Adherent:adherents/class/adherent.class.php:1', 'label'=>'Member', 'enabled'=>'1', 'position'=>51, 'notnull'=>-1, 'visible'=>$fk_member_visible, 'index'=>1,), + 'entity' => array('type' => 'integer', 'label' => 'Entity', 'default' => 1, 'enabled' => 1, 'visible' => -2, 'notnull' => 1, 'position' => 15, 'index' => 1), + 'note_public' => array('type'=>'html', 'label'=>'NotePublic', 'enabled'=>'1', 'position'=>61, 'notnull'=>0, 'visible'=>0,), + 'note_private' => array('type'=>'html', 'label'=>'NotePrivate', 'enabled'=>'1', 'position'=>62, 'notnull'=>0, 'visible'=>0,), + 'date_creation' => array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>'1', 'position'=>500, 'notnull'=>1, 'visible'=>-2,), + 'tms' => array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>'1', 'position'=>501, 'notnull'=>0, 'visible'=>-2,), + 'fk_user_creat' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserAuthor', 'enabled'=>'1', 'position'=>510, 'notnull'=>1, 'visible'=>-2, 'foreignkey'=>'user.rowid',), + 'fk_user_modif' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserModif', 'enabled'=>'1', 'position'=>511, 'notnull'=>-1, 'visible'=>-2,), + 'last_main_doc' => array('type'=>'varchar(255)', 'label'=>'LastMainDoc', 'enabled'=>'1', 'position'=>600, 'notnull'=>0, 'visible'=>0,), + 'import_key' => array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>'1', 'position'=>1000, 'notnull'=>-1, 'visible'=>-2,), + 'model_pdf' => array('type'=>'varchar(255)', 'label'=>'Model pdf', 'enabled'=>'1', 'position'=>1010, 'notnull'=>-1, 'visible'=>0,), + 'status' => array('type'=>'smallint', 'label'=>'Status', 'enabled'=>'1', 'position'=>1000, 'notnull'=>0, 'visible'=>0, 'index'=>1, 'arrayofkeyval'=>array('0'=>'Brouillon', '1'=>'Accepté', '2'=>'Refusé', '9'=>'Annulé'),), + 'date_partnership_start' => array('type'=>'date', 'label'=>'DatePartnershipStart', 'enabled'=>'1', 'position'=>52, 'notnull'=>1, 'visible'=>1,), + 'date_partnership_end' => array('type'=>'date', 'label'=>'DatePartnershipEnd', 'enabled'=>'1', 'position'=>53, 'notnull'=>1, 'visible'=>1,), + 'count_last_url_check_error' => array('type'=>'integer', 'label'=>'CountLastUrlCheckError', 'enabled'=>'1', 'position'=>63, 'notnull'=>0, 'visible'=>-2, 'default'=>'0',), + 'reason_decline_or_cancel' => array('type'=>'text', 'label'=>'ReasonDeclineOrCancel', 'enabled'=>'1', 'position'=>64, 'notnull'=>0, 'visible'=>-2,), + ); + if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID) && isset($this->fields['rowid'])) { $this->fields['rowid']['visible'] = 0; } - if (empty($conf->multicompany->enabled) && isset($this->fields['entity'])) { - $this->fields['entity']['enabled'] = 0; - } + // if (empty($conf->multicompany->enabled) && isset($this->fields['entity'])) { + // $this->fields['entity']['enabled'] = 0; + // } // Example to show how to set values of fields definition dynamically /*if ($user->rights->partnership->read) { @@ -229,6 +235,7 @@ class Partnership extends CommonObject */ public function create(User $user, $notrigger = false) { + $this->status = 0; return $this->createCommon($user, $notrigger); } @@ -333,20 +340,97 @@ class Partnership extends CommonObject /** * Load object in memory from the database + * Get object from database. Get also lines. * - * @param int $id Id object - * @param string $ref Ref - * @return int <0 if KO, 0 if not found, >0 if OK + * @param int $id Id of object to load + * @param string $ref Ref of object + * @param int $fk_soc_or_member fk_soc or fk_member + * @return int >0 if OK, <0 if KO, 0 if not found */ - public function fetch($id, $ref = null) + public function fetch($id, $ref = null, $fk_soc_or_member = null) { - $result = $this->fetchCommon($id, $ref); - if ($result > 0 && !empty($this->table_element_line)) { - $this->fetchLines(); + global $conf; + + // Check parameters + if (empty($id) && empty($ref) && empty($fk_soc_or_member)) { + return -1; + } + + $sql = 'SELECT p.rowid, p.ref, p.fk_soc, p.fk_member, p.status'; + $sql .= ', p.entity, p.date_partnership_start, p.date_partnership_end, p.date_creation'; + $sql .= ', p.fk_user_creat, p.tms, p.fk_user_modif, p.fk_user_modif'; + $sql .= ', p.note_private, p.note_public'; + $sql .= ', p.last_main_doc, p.count_last_url_check_error, p.reason_decline_or_cancel'; + $sql .= ', p.import_key, p.model_pdf'; + + $sql .= ' FROM '.MAIN_DB_PREFIX.'partnership as p'; + + if ($id) { + $sql .= " WHERE p.rowid=".$id; + } else { + $sql .= " WHERE p.entity IN (0,".getEntity('partnership').")"; // Dont't use entity if you use rowid + } + + if ($ref) { + $sql .= " AND p.ref='".$this->db->escape($ref)."'"; + } + + if($fk_soc_or_member){ + $sql .= ' AND'; + if($conf->global->PARTNERSHIP_IS_MANAGED_FOR == 'member') + $sql .= ' p.fk_member = '; + else + $sql .= ' p.fk_soc = '; + $sql .= $fk_soc_or_member; + $sql .= ' ORDER BY p.date_partnership_end DESC'; + } + + dol_syslog(get_class($this)."::fetch", LOG_DEBUG); + $result = $this->db->query($sql); + if ($result) { + $obj = $this->db->fetch_object($result); + if ($obj) { + $this->id = $obj->rowid; + $this->entity = $obj->entity; + $this->rowid = $obj->rowid; + $this->ref = $obj->ref; + $this->fk_soc = $obj->fk_soc; + $this->fk_member = $obj->fk_member; + $this->status = $obj->status; + $this->date_partnership_start = $this->db->jdate($obj->date_partnership_start); + $this->date_partnership_end = $this->db->jdate($obj->date_partnership_end); + $this->date_creation = $this->db->jdate($obj->date_creation); + $this->fk_user_creat = $obj->fk_user_creat; + $this->tms = $obj->tms; + $this->fk_user_modif = $obj->fk_user_modif; + $this->note_private = $obj->note_private; + $this->note_public = $obj->note_public; + $this->last_main_doc = $obj->last_main_doc; + $this->count_last_url_check_error = $obj->count_last_url_check_error; + $this->reason_decline_or_cancel = $obj->reason_decline_or_cancel; + $this->import_key = $obj->import_key; + $this->model_pdf = $obj->model_pdf; + + $this->lines = array(); + + // Retrieve all extrafield + // fetch optionals attributes and labels + $this->fetch_optionals(); + + $this->db->free($result); + + return 1; + } else { + $this->error = 'Partnership with id '.$id.' not found sql='.$sql; + return 0; + } + } else { + $this->error = $this->db->error(); + return -1; } - return $result; } + /** * Load object lines in memory from the database * @@ -768,9 +852,9 @@ class Partnership extends CommonObject public function refused($user, $notrigger = '') { // Protection - // if ($this->status != self::STATUS_DRAFT) { - // return 0; - // } + if ($this->status == self::STATUS_REFUSED) { + return 0; + } /*if (! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->partnership->write)) || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->partnership_advance->validate)))) @@ -816,7 +900,7 @@ class Partnership extends CommonObject public function reopen($user, $notrigger = 0) { // Protection - if ($this->status != self::STATUS_CANCELED) { + if ($this->status != self::STATUS_CANCELED && $this->status != self::STATUS_REFUSED) { return 0; } diff --git a/htdocs/partnership/class/partnershiputils.class.php b/htdocs/partnership/class/partnershiputils.class.php index 61659e6075c..08c61b3454c 100644 --- a/htdocs/partnership/class/partnershiputils.class.php +++ b/htdocs/partnership/class/partnershiputils.class.php @@ -35,7 +35,7 @@ dol_include_once('partnership/lib/partnership.lib.php'); class PartnershipUtils { public $db; //!< To store db handler - public $error; //!< To return error code (or message) + public $error; //!< To return error code (or message) public $errors=array(); //!< To return several error codes (or messages) diff --git a/htdocs/partnership/partnership_card.php b/htdocs/partnership/partnership_card.php index dbf889137d8..c44174af52c 100644 --- a/htdocs/partnership/partnership_card.php +++ b/htdocs/partnership/partnership_card.php @@ -108,9 +108,7 @@ $search_array_options = $extrafields->getOptionalsFromPost($object->table_elemen // Initialize array of search criterias $search_all = GETPOST("search_all", 'alpha'); $search = array(); -if ($conf->global->PARTNERSHIP_IS_MANAGED_FOR == 'member') - unset($object->fields['fk_soc']); -else unset($object->fields['fk_member']); + foreach ($object->fields as $key => $val) { if (GETPOST('search_'.$key, 'alpha')) { $search[$key] = GETPOST('search_'.$key, 'alpha'); @@ -581,7 +579,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea } // Back to draft - if ($object->status == $object::STATUS_ACCEPTED) { + if ($object->status != $object::STATUS_DRAFT) { print dolGetButtonAction($langs->trans('SetToDraft'), '', 'default', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=confirm_setdraft&confirm=yes', '', $permissiontoadd); } @@ -598,23 +596,11 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea } } - // Clone - // print dolGetButtonAction($langs->trans('ToClone'), '', 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.'&socid='.$object->socid.'&action=clone&object=scrumsprint', '', $permissiontoadd); - - - // if ($permissiontoadd) { - // if ($object->status == $object::STATUS_ENABLED) { - // print ''.$langs->trans("Disable").''."\n"; - // } else { - // print ''.$langs->trans("Enable").''."\n"; - // } - // } - // Cancel if ($permissiontoadd) { if ($object->status == $object::STATUS_ACCEPTED) { print dolGetButtonAction($langs->trans('Cancel'), '', 'default', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=confirm_close&confirm=yes&token='.newToken(), '', $permissiontoadd); - } elseif ($object->status == $object::STATUS_CANCELED) { + } elseif ($object->status > $object::STATUS_ACCEPTED) { // print ''.$langs->trans("Re-Open").''."\n"; print dolGetButtonAction($langs->trans('Re-Open'), '', 'default', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=confirm_reopen&confirm=yes&token='.newToken(), '', $permissiontoadd); } @@ -622,7 +608,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea // Refuse if ($permissiontoadd) { - if ($object->status != $object::STATUS_CANCELED) { + if ($object->status != $object::STATUS_CANCELED && $object->status != $object::STATUS_REFUSED) { print ''.$langs->trans("Refuse").''."\n"; } } diff --git a/htdocs/societe/partnership.php b/htdocs/societe/partnership.php new file mode 100644 index 00000000000..2484936f686 --- /dev/null +++ b/htdocs/societe/partnership.php @@ -0,0 +1,614 @@ + + * Copyright (C) 2021 NextGestion + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file partnership_card.php + * \ingroup partnership + * \brief Page to create/edit/view partnership + */ + +//if (! defined('NOREQUIREDB')) define('NOREQUIREDB', '1'); // Do not create database handler $db +//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER', '1'); // Do not load object $user +//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); // Do not load object $mysoc +//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN', '1'); // Do not load object $langs +//if (! defined('NOSCANGETFORINJECTION')) define('NOSCANGETFORINJECTION', '1'); // Do not check injection attack on GET parameters +//if (! defined('NOSCANPOSTFORINJECTION')) define('NOSCANPOSTFORINJECTION', '1'); // Do not check injection attack on POST parameters +//if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK', '1'); // Do not check CSRF attack (test on referer + on token if option MAIN_SECURITY_CSRF_WITH_TOKEN is on). +//if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Do not roll the Anti CSRF token (used if MAIN_SECURITY_CSRF_WITH_TOKEN is on) +//if (! defined('NOSTYLECHECK')) define('NOSTYLECHECK', '1'); // Do not check style html tag into posted data +//if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); // If there is no need to load and show top and left menu +//if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); // If we don't need to load the html.form.class.php +//if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); // Do not load ajax.lib.php library +//if (! defined("NOLOGIN")) define("NOLOGIN", '1'); // If this page is public (can be called outside logged session). This include the NOIPCHECK too. +//if (! defined('NOIPCHECK')) define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip +//if (! defined("MAIN_LANG_DEFAULT")) define('MAIN_LANG_DEFAULT', 'auto'); // Force lang to a particular value +//if (! defined("MAIN_AUTHENTICATION_MODE")) define('MAIN_AUTHENTICATION_MODE', 'aloginmodule'); // Force authentication handler +//if (! defined("NOREDIRECTBYMAINTOLOGIN")) define('NOREDIRECTBYMAINTOLOGIN', 1); // The main.inc.php does not make a redirect if not logged, instead show simple error message +//if (! defined("FORCECSP")) define('FORCECSP', 'none'); // Disable all Content Security Policies +//if (! defined('CSRFCHECK_WITH_TOKEN')) define('CSRFCHECK_WITH_TOKEN', '1'); // Force use of CSRF protection with tokens even for GET +//if (! defined('NOBROWSERNOTIF')) define('NOBROWSERNOTIF', '1'); // Disable browser notification + +// Load Dolibarr environment +$res = 0; +// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) +if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) { + $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; +} +// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME +$tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1; +while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { + $i--; $j--; +} +if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) { + $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php"; +} +if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) { + $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php"; +} +// Try main.inc.php using relative path +if (!$res && file_exists("../main.inc.php")) { + $res = @include "../main.inc.php"; +} +if (!$res && file_exists("../../main.inc.php")) { + $res = @include "../../main.inc.php"; +} +if (!$res && file_exists("../../../main.inc.php")) { + $res = @include "../../../main.inc.php"; +} +if (!$res) { + die("Include of main fails"); +} + +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; +dol_include_once('/partnership/class/partnership.class.php'); +dol_include_once('/partnership/lib/partnership.lib.php'); + +// Load translation files required by the page +$langs->loadLangs(array("companies","partnership@partnership", "other")); + +// Get parameters +$id = GETPOST('id', 'int'); +$ref = GETPOST('ref', 'alpha'); +$action = GETPOST('action', 'aZ09'); +$confirm = GETPOST('confirm', 'alpha'); +$cancel = GETPOST('cancel', 'aZ09'); +$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'partnershipcard'; // To manage different context of search +$backtopage = GETPOST('backtopage', 'alpha'); +$backtopageforcancel = GETPOST('backtopageforcancel', 'alpha'); +//$lineid = GETPOST('lineid', 'int'); + +// Security check +$socid = GETPOST('socid', 'int'); +if (!empty($user->socid)) { + $socid = $user->socid; +} + +$societe = new Societe($db); +if ($socid > 0) { + $societe->fetch($socid); +} + +// Initialize technical objects +$object = new Partnership($db); +$extrafields = new ExtraFields($db); +$diroutputmassaction = $conf->partnership->dir_output.'/temp/massgeneration/'.$user->id; +$hookmanager->initHooks(array('partnershipthirdparty', 'globalcard')); // Note that conf->hooks_modules contains array + +// Fetch optionals attributes and labels +$extrafields->fetch_name_optionals_label($object->table_element); + +$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); + +// Initialize array of search criterias +$search_all = GETPOST("search_all", 'alpha'); +$search = array(); + +foreach ($object->fields as $key => $val) { + if (GETPOST('search_'.$key, 'alpha')) { + $search[$key] = GETPOST('search_'.$key, 'alpha'); + } +} + +// Load object +include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once. + +$permissiontoread = $user->rights->partnership->read; +$permissiontoadd = $user->rights->partnership->write; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php +$permissiontodelete = $user->rights->partnership->delete || ($permissiontoadd && isset($object->status) && $object->status == $object::STATUS_DRAFT); +$permissionnote = $user->rights->partnership->write; // Used by the include of actions_setnotes.inc.php +$permissiondellink = $user->rights->partnership->write; // Used by the include of actions_dellink.inc.php +$usercanclose = $user->rights->partnership->write; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php +$upload_dir = $conf->partnership->multidir_output[isset($object->entity) ? $object->entity : 1]; + + +if (empty($conf->partnership->enabled)) accessforbidden(); +if (empty($permissiontoread)) accessforbidden(); +if ($action == 'edit' && empty($permissiontoadd)) accessforbidden(); + +$partnershipid = $object->fetch(0, "", $socid); +if(empty($action) && empty($partnershipid)){ + $action = 'create'; +} +if (($action == 'update' || $action == 'edit') && $object->status != $object::STATUS_DRAFT && !empty($user->socid)) accessforbidden(); + +if(empty($socid) && $object){ + $socid = $object->fk_soc; +} +/* + * Actions + */ + +$parameters = array(); +$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks +if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +} + +$date_start = dol_mktime(0, 0, 0, GETPOST('date_partnership_startmonth', 'int'), GETPOST('date_partnership_startday', 'int'), GETPOST('date_partnership_startyear', 'int')); +$date_end = dol_mktime(0, 0, 0, GETPOST('date_partnership_endmonth', 'int'), GETPOST('date_partnership_endday', 'int'), GETPOST('date_partnership_endyear', 'int')); + +if (empty($reshook)) { + $error = 0; + + $backtopage = dol_buildpath('/partnership/partnership.php', 1).'?socid='.($socid > 0 ? $socid : '__ID__'); + + $triggermodname = 'PARTNERSHIP_MODIFY'; // Name of trigger action code to execute when we modify record + + if ($action == 'add' && $permissiontoread) { + $error = 0; + + $db->begin(); + + $now = dol_now(); + + if (!$error) { + $old_start_date = $object->date_partnership_start; + + $object->fk_soc = $socid; + $object->date_partnership_start = (!GETPOST('date_partnership_start')) ? '' : $date_start; + $object->date_partnership_end = (!GETPOST('date_partnership_end')) ? '' : $date_end; + $object->date_creation = $now; + $object->fk_user_creat = $user->id; + $object->entity = $conf->entity; + + // Fill array 'array_options' with data from add form + $ret = $extrafields->setOptionalsFromPost(null, $object); + if ($ret < 0) { + $error++; + } + } + + if (!$error) { + $result = $object->create($user); + if ($result < 0) { + $error++; + if ($result == -4) { + setEventMessages($langs->trans("ErrorRefAlreadyExists"), null, 'errors'); + } else { + setEventMessages($object->error, $object->errors, 'errors'); + } + } + } + + if ($error) { + $db->rollback(); + $action = 'edit'; + } else { + $db->commit(); + } + } elseif ($action == 'update' && $permissiontoread) { + $error = 0; + + $db->begin(); + + $now = dol_now(); + + if (!$error) { + $object->oldcopy = clone $object; + + $old_start_date = $object->date_partnership_start; + + $object->date_partnership_start = (!GETPOST('date_partnership_start')) ? '' : $date_start; + $object->date_partnership_end = (!GETPOST('date_partnership_end')) ? '' : $date_end; + $object->fk_user_creat = $user->id; + $object->fk_user_modif = $user->id; + + // Fill array 'array_options' with data from add form + $ret = $extrafields->setOptionalsFromPost(null, $object); + if ($ret < 0) { + $error++; + } + } + + if (!$error) { + $result = $object->update($user); + if ($result < 0) { + $error++; + if ($result == -4) { + setEventMessages($langs->trans("ErrorRefAlreadyExists"), null, 'errors'); + } else { + setEventMessages($object->error, $object->errors, 'errors'); + } + } + } + + if ($error) { + $db->rollback(); + $action = 'edit'; + } else { + $db->commit(); + } + } elseif ($action == 'confirm_close' || $action == 'update_extras') { + include DOL_DOCUMENT_ROOT.'/core/actions_addupdatedelete.inc.php'; + + header("Location: ".$_SERVER['PHP_SELF']."?socid=".$socid); + exit; + } + + // Actions when linking object each other + include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php'; + + // // Actions to send emails + // $triggersendname = 'PARTNERSHIP_SENTBYMAIL'; + // $autocopy = 'MAIN_MAIL_AUTOCOPY_PARTNERSHIP_TO'; + // $trackid = 'partnership'.$object->id; + // include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php'; +} + + + +/* + * View + * + * Put here all code to build page + */ + +$form = new Form($db); +$formfile = new FormFile($db); +$formproject = new FormProjets($db); + +$title = $langs->trans("Partnership"); +llxHeader('', $title); + +$form = new Form($db); + +if ($socid) { + require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; + require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; + + $langs->load("companies"); + + $societe = new Societe($db); + $result = $societe->fetch($socid); + + if (!empty($conf->notification->enabled)) { + $langs->load("mails"); + } + $head = societe_prepare_head($societe); + + print dol_get_fiche_head($head, 'partnership', $langs->trans("ThirdParty"), -1, 'company'); + + $linkback = ''.$langs->trans("BackToList").''; + + dol_banner_tab($societe, 'socid', $linkback, ($user->socid ? 0 : 1), 'rowid', 'nom'); + + print '
'; + + print '
'; + print ''; + + if (!empty($conf->global->SOCIETE_USEPREFIX)) { // Old not used prefix field + print ''; + } + + if ($societe->client) { + print ''; + } + + if ($societe->fournisseur) { + print ''; + } + + print '
'.$langs->trans('Prefix').''.$societe->prefix_comm.'
'; + print $langs->trans('CustomerCode').''; + print showValueWithClipboardCPButton(dol_escape_htmltag($societe->code_client)); + $tmpcheck = $societe->check_codeclient(); + if ($tmpcheck != 0 && $tmpcheck != -5) { + print ' ('.$langs->trans("WrongCustomerCode").')'; + } + print '
'; + print $langs->trans('SupplierCode').''; + print showValueWithClipboardCPButton(dol_escape_htmltag($societe->code_fournisseur)); + $tmpcheck = $societe->check_codefournisseur(); + if ($tmpcheck != 0 && $tmpcheck != -5) { + print ' ('.$langs->trans("WrongSupplierCode").')'; + } + print '
'; + + print '
'; + + print dol_get_fiche_end(); + + $params = ''; + + $newcardbutton .= dolGetButtonTitle($langs->trans("NewProject"), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/projet/card.php?action=create&socid='.$societe->id.'&backtopage='.urlencode($backtopage), '', 1, $params); + + print '
'; + +} else { + dol_print_error('', 'Parameter socid not defined'); +} + +$object->fields['fk_soc']['visible'] = 0; + +// Part to create +if ($action == 'create') { + print load_fiche_titre($langs->trans("NewObject", $langs->transnoentitiesnoconv("Partnership")), '', ''); + + $backtopageforcancel = DOL_URL_ROOT.'/partnership/partnership.php?socid='.$socid; + + print '
'; + print ''; + print ''; + print ''; + print ''; + + if ($backtopage) { + print ''; + } + if ($backtopageforcancel) { + print ''; + } + + print dol_get_fiche_head(array(), ''); + + print ''."\n"; + + // Common attributes + include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_add.tpl.php'; + + // Other attributes + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_add.tpl.php'; + + print '
'."\n"; + + print dol_get_fiche_end(); + + print '
'; + print ''; + print '  '; + // print ''; // Cancel for create does not post form if we don't know the backtopage + print '
'; + + print '
'; +} + +// Part to edit record +if (($partnershipid || $ref) && $action == 'edit') { + print load_fiche_titre($langs->trans("Partnership"), '', ''); + + $backtopageforcancel = DOL_URL_ROOT.'/partnership/partnership.php?socid='.$socid; + + print '
'; + print ''; + print ''; + print ''; + print ''; + if ($backtopage) { + print ''; + } + if ($backtopageforcancel) { + print ''; + } + + print dol_get_fiche_head(); + + print ''."\n"; + + // Common attributes + include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_edit.tpl.php'; + + // Other attributes + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_edit.tpl.php'; + + print '
'; + + print dol_get_fiche_end(); + + print '
'; + print '   '; + print '
'; + + print '
'; +} + +// Part to show record +if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create'))) { + + + print load_fiche_titre($langs->trans("PartnershipDedicatedToThisThirdParty", $langs->transnoentitiesnoconv("Partnership")), '', ''); + + $res = $object->fetch_optionals(); + + // $head = partnershipPrepareHead($object); + // print dol_get_fiche_head($head, 'card', $langs->trans("Partnership"), -1, $object->picto); + + $linkback = ''; + dol_banner_tab($object, 'id', $linkback, 0, 'rowid', 'ref'); + + $formconfirm = ''; + + // Close confirmation + if ($action == 'close') { + // Create an array for form + $formquestion = array(); + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClose'), $langs->trans('ConfirmCloseAsk', $object->ref), 'confirm_close', $formquestion, 'yes', 1); + } + // Reopon confirmation + if ($action == 'reopen') { + // Create an array for form + $formquestion = array(); + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToReopon'), $langs->trans('ConfirmReoponAsk', $object->ref), 'confirm_reopen', $formquestion, 'yes', 1); + } + + // Refuse confirmatio + if ($action == 'refuse') { + //Form to close proposal (signed or not) + $formquestion = array( + array('type' => 'text', 'name' => 'reason_decline_or_cancel', 'label' => $langs->trans("Note"), 'morecss' => 'reason_decline_or_cancel', 'value' => '') // Field to complete private note (not replace) + ); + + // if (!empty($conf->notification->enabled)) { + // require_once DOL_DOCUMENT_ROOT.'/core/class/notify.class.php'; + // $notify = new Notify($db); + // $formquestion = array_merge($formquestion, array( + // array('type' => 'onecolumn', 'value' => $notify->confirmMessage('PROPAL_CLOSE_SIGNED', $object->socid, $object)), + // )); + // } + + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ReasonDecline'), $text, 'confirm_refuse', $formquestion, '', 1, 250); + } + + // Call Hook formConfirm + $parameters = array('formConfirm' => $formconfirm, 'lineid' => $lineid); + $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + if (empty($reshook)) { + $formconfirm .= $hookmanager->resPrint; + } elseif ($reshook > 0) { + $formconfirm = $hookmanager->resPrint; + } + + // Print form confirm + print $formconfirm; + + + // Object card + // ------------------------------------------------------------ + $linkback = ''.$langs->trans("BackToList").''; + + print '
'; + print '
'; + print '
'; + print ''."\n"; + + // Common attributes + //$keyforbreak='fieldkeytoswitchonsecondcolumn'; // We change column just before this field + //unset($object->fields['fk_project']); // Hide field already shown in banner + //unset($object->fields['fk_soc']); // Hide field already shown in banner + include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_view.tpl.php'; + + // Other attributes. Fields from hook formObjectOptions and Extrafields. + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; + + print '
'; + print '
'; + + print '
'; + + print dol_get_fiche_end(); + + // Buttons for actions + + if ($action != 'presend') { + print '
'."\n"; + $parameters = array(); + $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + } + + if (empty($reshook)) { + + if ($object->status == $object::STATUS_DRAFT) { + print dolGetButtonAction($langs->trans('Modify'), '', 'default', $_SERVER["PHP_SELF"].'?socid='.$socid.'&action=edit', '', $permissiontoadd); + } + + // Cancel + if ($permissiontoadd) { + if ($object->status == $object::STATUS_ACCEPTED) { + print dolGetButtonAction($langs->trans('Cancel'), '', 'default', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=close&token='.newToken(), '', $permissiontoadd); + } + } + } + print '
'."\n"; + } + + + // Select mail models is same action as presend + if (GETPOST('modelselected')) { + $action = 'presend'; + } + + // if ($action != 'presend') { + // print '
'; + // print ''; // ancre + + // $includedocgeneration = 0; + + // // Documents + // if ($includedocgeneration) { + // $objref = dol_sanitizeFileName($object->ref); + // $relativepath = $objref.'/'.$objref.'.pdf'; + // $filedir = $conf->partnership->dir_output.'/'.$object->element.'/'.$objref; + // $urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id; + // $genallowed = $user->rights->partnership->read; // If you can read, you can build the PDF to read content + // $delallowed = $user->rights->partnership->write; // If you can create/edit, you can remove a file on card + // print $formfile->showdocuments('partnership:Partnership', $object->element.'/'.$objref, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 1, 0, 0, 28, 0, '', '', '', $langs->defaultlang); + // } + + // // Show links to link elements + // $linktoelem = $form->showLinkToObjectBlock($object, null, array('partnership')); + // $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem); + + + // print '
'; + + // $MAXEVENT = 10; + + // $morehtmlright = ''; + // $morehtmlright .= $langs->trans("SeeAll"); + // $morehtmlright .= ''; + + // // List of actions on element + // include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'; + // $formactions = new FormActions($db); + // $somethingshown = $formactions->showactions($object, $object->element.'@'.$object->module, (is_object($object->thirdparty) ? $object->thirdparty->id : 0), 1, '', $MAXEVENT, '', $morehtmlright); + + // print '
'; + // } + + //Select mail models is same action as presend + if (GETPOST('modelselected')) { + $action = 'presend'; + } + + // Presend form + $modelmail = 'partnership'; + $defaulttopic = 'InformationMessage'; + $diroutput = $conf->partnership->dir_output; + $trackid = 'partnership'.$object->id; + + include DOL_DOCUMENT_ROOT.'/core/tpl/card_presend.tpl.php'; +} + +// End of page +llxFooter(); +$db->close(); From 4700fd467f43ab20aa76f7bd2c7aad5d8f4c3e9b Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Wed, 14 Apr 2021 14:14:39 +0000 Subject: [PATCH 012/147] Fixing style errors. --- htdocs/partnership/class/partnership.class.php | 9 ++++----- htdocs/societe/partnership.php | 10 +++------- 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/htdocs/partnership/class/partnership.class.php b/htdocs/partnership/class/partnership.class.php index 6a676bf24e9..395a3893b7d 100644 --- a/htdocs/partnership/class/partnership.class.php +++ b/htdocs/partnership/class/partnership.class.php @@ -374,13 +374,12 @@ class Partnership extends CommonObject if ($ref) { $sql .= " AND p.ref='".$this->db->escape($ref)."'"; } - - if($fk_soc_or_member){ + + if ($fk_soc_or_member) { $sql .= ' AND'; - if($conf->global->PARTNERSHIP_IS_MANAGED_FOR == 'member') + if ($conf->global->PARTNERSHIP_IS_MANAGED_FOR == 'member') $sql .= ' p.fk_member = '; - else - $sql .= ' p.fk_soc = '; + else $sql .= ' p.fk_soc = '; $sql .= $fk_soc_or_member; $sql .= ' ORDER BY p.date_partnership_end DESC'; } diff --git a/htdocs/societe/partnership.php b/htdocs/societe/partnership.php index 2484936f686..2576c2348c5 100644 --- a/htdocs/societe/partnership.php +++ b/htdocs/societe/partnership.php @@ -144,12 +144,12 @@ if (empty($permissiontoread)) accessforbidden(); if ($action == 'edit' && empty($permissiontoadd)) accessforbidden(); $partnershipid = $object->fetch(0, "", $socid); -if(empty($action) && empty($partnershipid)){ +if (empty($action) && empty($partnershipid)) { $action = 'create'; } if (($action == 'update' || $action == 'edit') && $object->status != $object::STATUS_DRAFT && !empty($user->socid)) accessforbidden(); -if(empty($socid) && $object){ +if (empty($socid) && $object) { $socid = $object->fk_soc; } /* @@ -262,7 +262,7 @@ if (empty($reshook)) { header("Location: ".$_SERVER['PHP_SELF']."?socid=".$socid); exit; } - + // Actions when linking object each other include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php'; @@ -352,7 +352,6 @@ if ($socid) { $newcardbutton .= dolGetButtonTitle($langs->trans("NewProject"), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/projet/card.php?action=create&socid='.$societe->id.'&backtopage='.urlencode($backtopage), '', 1, $params); print '
'; - } else { dol_print_error('', 'Parameter socid not defined'); } @@ -442,8 +441,6 @@ if (($partnershipid || $ref) && $action == 'edit') { // Part to show record if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create'))) { - - print load_fiche_titre($langs->trans("PartnershipDedicatedToThisThirdParty", $langs->transnoentitiesnoconv("Partnership")), '', ''); $res = $object->fetch_optionals(); @@ -536,7 +533,6 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea } if (empty($reshook)) { - if ($object->status == $object::STATUS_DRAFT) { print dolGetButtonAction($langs->trans('Modify'), '', 'default', $_SERVER["PHP_SELF"].'?socid='.$socid.'&action=edit', '', $permissiontoadd); } From caf74fe1cb3452c93146ac8a00a89786afaededd Mon Sep 17 00:00:00 2001 From: Dorian Vabre Date: Wed, 14 Apr 2021 16:20:05 +0200 Subject: [PATCH 013/147] pull problem corrected --- .../attendee_subscription.php | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/htdocs/public/eventorganization/attendee_subscription.php b/htdocs/public/eventorganization/attendee_subscription.php index faff3d40712..cdb848ed28c 100644 --- a/htdocs/public/eventorganization/attendee_subscription.php +++ b/htdocs/public/eventorganization/attendee_subscription.php @@ -293,6 +293,33 @@ if (empty($reshook) && $action == 'add') { if (!$error) { $db->commit(); + global $dolibarr_main_url_root; + if (!empty(floatval($project->price_registration))){ + $facture = new Facture($db); + $facture->type = 0; + $facture->socid = $thirdparty->id; + $facture->paye = 0; + //@todo price and taxes to add + $tva = get_default_tva($mysoc, $thirdparty); + $facture->date = dol_now(); + $resultfacture = $facture->create($user); + if ($resultfacture < 0){ + $error++; + $errmsg .= $facture->error; + } else { + $redirection = $dolibarr_main_url_root.'/public/payment/newpayment.php'; + Header("Location: ".$redirection); + exit; + } + + } else { + // No price has been set + // Validating the subscription + $confattendee->setStatut(1); + $redirection = $dolibarr_main_url_root.'/public/eventorganization/subscriptionok.php'; + Header("Location: ".$redirection); + exit; + } //Header("Location: ".$urlback); //exit; } else { From 03a944edf5fdab56c91362f10ec859af9f6acf7f Mon Sep 17 00:00:00 2001 From: NextGestion Date: Wed, 14 Apr 2021 16:32:23 +0100 Subject: [PATCH 014/147] Manage membership expiration --- htdocs/partnership/partnership_list.php | 89 +++++++++++++++++++++++-- htdocs/societe/partnership.php | 4 +- 2 files changed, 85 insertions(+), 8 deletions(-) diff --git a/htdocs/partnership/partnership_list.php b/htdocs/partnership/partnership_list.php index e03ed536806..e1820d7c8c9 100644 --- a/htdocs/partnership/partnership_list.php +++ b/htdocs/partnership/partnership_list.php @@ -77,6 +77,7 @@ if (!$res) { require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; // load partnership libraries require_once __DIR__.'/class/partnership.class.php'; @@ -112,8 +113,9 @@ $pageprev = $page - 1; $pagenext = $page + 1; // Initialize technical objects -$object = new Partnership($db); -$extrafields = new ExtraFields($db); +$object = new Partnership($db); +$extrafields = new ExtraFields($db); +$adherent = new Adherent($db); $diroutputmassaction = $conf->partnership->dir_output.'/temp/massgeneration/'.$user->id; $hookmanager->initHooks(array('partnershiplist')); // Note that conf->hooks_modules contains array @@ -123,9 +125,9 @@ $extrafields->fetch_name_optionals_label($object->table_element); $search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); -if ($conf->global->PARTNERSHIP_IS_MANAGED_FOR == 'member') - unset($object->fields['fk_soc']); -else unset($object->fields['fk_member']); +$managedfor = $conf->global->PARTNERSHIP_IS_MANAGED_FOR; + +if($managedfor != 'member' && $sortfield == 'd.datefin') $sortfield = ''; // Default sort order (if not yet defined by previous GETPOST) if (!$sortfield) { @@ -148,6 +150,11 @@ foreach ($object->fields as $key => $val) { $search[$key.'_dtend'] = dol_mktime(23, 59, 59, GETPOST('search_'.$key.'_dtendmonth', 'int'), GETPOST('search_'.$key.'_dtendday', 'int'), GETPOST('search_'.$key.'_dtendyear', 'int')); } } +$search_filter = GETPOST("search_filter", 'alpha'); +$filter = GETPOST("filter", 'alpha'); +if ($filter) { + $search_filter = $filter; // For backward compatibility +} // List of fields to search into when doing a "search in all" $fieldstosearchall = array(); @@ -229,6 +236,7 @@ if (empty($reshook)) { } $toselect = ''; $search_array_options = array(); + $search_filter = ""; } if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha') || GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) { @@ -263,6 +271,9 @@ $morecss = array(); // -------------------------------------------------------------------- $sql = 'SELECT '; $sql .= $object->getFieldList('t'); +if ($managedfor == 'member'){ + $sql .= ', d.datefin, d.fk_adherent_type, dty.subscription'; +} // Add fields from extrafields if (!empty($extrafields->attributes[$object->table_element]['label'])) { foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { @@ -278,6 +289,10 @@ $sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t"; if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (t.rowid = ef.fk_object)"; } +if ($managedfor == 'member'){ + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."adherent as d on (d.rowid = t.fk_member)"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."adherent_type as dty on (dty.rowid = d.fk_adherent_type)"; +} // Add table from hooks $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListFrom', $parameters, $object); // Note that $action and $object may have been modified by hook @@ -287,6 +302,10 @@ if ($object->ismultientitymanaged == 1) { } else { $sql .= " WHERE 1 = 1"; } +if ($managedfor == 'member') + $sql .= " AND fk_member > 0"; +else + $sql .= " AND fk_soc > 0"; foreach ($search as $key => $val) { if (array_key_exists($key, $object->fields)) { if ($key == 'status' && $search[$key] == -1) { @@ -316,6 +335,17 @@ foreach ($search as $key => $val) { } } } +if ($managedfor == 'member'){ + if ($search_filter == 'withoutsubscription') { + $sql .= " AND (d.datefin IS NULL OR dty.subscription = 0)"; + } + if ($search_filter == 'uptodate') { + $sql .= " AND (d.datefin >= '".$db->idate($now)."' OR dty.subscription = 0)"; + } + if ($search_filter == 'outofdate') { + $sql .= " AND (d.datefin < '".$db->idate($now)."' AND dty.subscription = 1)"; + } +} if ($search_all) { $sql .= natural_search(array_keys($fieldstosearchall), $search_all); } @@ -422,6 +452,9 @@ foreach ($search as $key => $val) { if ($optioncss != '') { $param .= '&optioncss='.urlencode($optioncss); } +if ($search_filter && $search_filter != '-1') { + $param .= "&search_filter=".urlencode($search_filter); +} // Add $param from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; // Add $param from hooks @@ -500,6 +533,12 @@ print '
'; // You can use div-table-responsive- print ''."\n"; +if ($managedfor == 'member'){ + $arrayfields['t.fk_member']['checked'] = 1; +} +else { + $arrayfields['t.fk_soc']['checked'] = 1; +} // Fields title search // -------------------------------------------------------------------- print ''; @@ -533,6 +572,13 @@ foreach ($object->fields as $key => $val) { print ''; } } +// End of subscription date +if ($managedfor == 'member'){ + print ''; +} // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; @@ -566,6 +612,12 @@ foreach ($object->fields as $key => $val) { print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($cssforfield ? 'class="'.$cssforfield.'"' : ''), $sortfield, $sortorder, ($cssforfield ? $cssforfield.' ' : ''))."\n"; } } +// End of subscription date +if ($managedfor == 'member'){ + $key = 'datefin'; + $cssforfield = 'center'; + print getTitleFieldOfList('SubscriptionEndDate', 0, $_SERVER['PHP_SELF'], 'd.'.$key, '', $param, ($cssforfield ? 'class="'.$cssforfield.'"' : ''), $sortfield, $sortorder, ($cssforfield ? $cssforfield.' ' : ''))."\n"; +} // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; // Hook fields @@ -641,6 +693,33 @@ while ($i < ($limit ? min($num, $limit) : $num)) { } } } + // End of subscription date + if ($managedfor == 'member'){ + print ''; + } else { + print ''; + } // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; // Fields from hook diff --git a/htdocs/societe/partnership.php b/htdocs/societe/partnership.php index 2576c2348c5..90071846531 100644 --- a/htdocs/societe/partnership.php +++ b/htdocs/societe/partnership.php @@ -139,6 +139,7 @@ $usercanclose = $user->rights->partnership->write; // Used by the include of $upload_dir = $conf->partnership->multidir_output[isset($object->entity) ? $object->entity : 1]; +if ($conf->global->PARTNERSHIP_IS_MANAGED_FOR == 'member') accessforbidden(); if (empty($conf->partnership->enabled)) accessforbidden(); if (empty($permissiontoread)) accessforbidden(); if ($action == 'edit' && empty($permissiontoadd)) accessforbidden(); @@ -283,7 +284,6 @@ if (empty($reshook)) { $form = new Form($db); $formfile = new FormFile($db); -$formproject = new FormProjets($db); $title = $langs->trans("Partnership"); llxHeader('', $title); @@ -349,8 +349,6 @@ if ($socid) { $params = ''; - $newcardbutton .= dolGetButtonTitle($langs->trans("NewProject"), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/projet/card.php?action=create&socid='.$societe->id.'&backtopage='.urlencode($backtopage), '', 1, $params); - print '
'; } else { dol_print_error('', 'Parameter socid not defined'); From 5d404836f751afedda3906137b7a571af74f6448 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Wed, 14 Apr 2021 16:35:19 +0000 Subject: [PATCH 015/147] Fixing style errors. --- htdocs/partnership/partnership_list.php | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/htdocs/partnership/partnership_list.php b/htdocs/partnership/partnership_list.php index e1820d7c8c9..8cd0cf79fd7 100644 --- a/htdocs/partnership/partnership_list.php +++ b/htdocs/partnership/partnership_list.php @@ -127,7 +127,7 @@ $search_array_options = $extrafields->getOptionalsFromPost($object->table_elemen $managedfor = $conf->global->PARTNERSHIP_IS_MANAGED_FOR; -if($managedfor != 'member' && $sortfield == 'd.datefin') $sortfield = ''; +if ($managedfor != 'member' && $sortfield == 'd.datefin') $sortfield = ''; // Default sort order (if not yet defined by previous GETPOST) if (!$sortfield) { @@ -271,7 +271,7 @@ $morecss = array(); // -------------------------------------------------------------------- $sql = 'SELECT '; $sql .= $object->getFieldList('t'); -if ($managedfor == 'member'){ +if ($managedfor == 'member') { $sql .= ', d.datefin, d.fk_adherent_type, dty.subscription'; } // Add fields from extrafields @@ -289,7 +289,7 @@ $sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t"; if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (t.rowid = ef.fk_object)"; } -if ($managedfor == 'member'){ +if ($managedfor == 'member') { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."adherent as d on (d.rowid = t.fk_member)"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."adherent_type as dty on (dty.rowid = d.fk_adherent_type)"; } @@ -304,8 +304,7 @@ if ($object->ismultientitymanaged == 1) { } if ($managedfor == 'member') $sql .= " AND fk_member > 0"; -else - $sql .= " AND fk_soc > 0"; +else $sql .= " AND fk_soc > 0"; foreach ($search as $key => $val) { if (array_key_exists($key, $object->fields)) { if ($key == 'status' && $search[$key] == -1) { @@ -335,7 +334,7 @@ foreach ($search as $key => $val) { } } } -if ($managedfor == 'member'){ +if ($managedfor == 'member') { if ($search_filter == 'withoutsubscription') { $sql .= " AND (d.datefin IS NULL OR dty.subscription = 0)"; } @@ -533,10 +532,9 @@ print '
'; // You can use div-table-responsive- print '
'; + $selectarray = array('-1'=>'', 'withoutsubscription'=>$langs->trans("WithoutSubscription"), 'uptodate'=>$langs->trans("UpToDate"), 'outofdate'=>$langs->trans("OutOfDate")); + print $form->selectarray('search_filter', $selectarray, $search_filter); + print ''; + $result = $adherent->fetch($object->fk_member); + if($result){ + $datefin = $adherent->datefin; + if ($datefin) { + print dol_print_date($datefin, 'day'); + if ($adherent->hasDelay()) { + $textlate .= ' ('.$langs->trans("DateReference").' > '.$langs->trans("DateToday").' '.(ceil($conf->adherent->subscription->warning_delay / 60 / 60 / 24) >= 0 ? '+' : '').ceil($conf->adherent->subscription->warning_delay / 60 / 60 / 24).' '.$langs->trans("days").')'; + print " ".img_warning($langs->trans("SubscriptionLate").$textlate); + } + print ''; + if ($adherent->subscription == 'yes') { + print $langs->trans("SubscriptionNotReceived"); + if ($adherent->statut > 0) { + print " ".img_warning(); + } + } else { + print ' '; + } + } + } + print '
'."\n"; -if ($managedfor == 'member'){ +if ($managedfor == 'member') { $arrayfields['t.fk_member']['checked'] = 1; -} -else { +} else { $arrayfields['t.fk_soc']['checked'] = 1; } // Fields title search @@ -573,7 +571,7 @@ foreach ($object->fields as $key => $val) { } } // End of subscription date -if ($managedfor == 'member'){ +if ($managedfor == 'member') { print ''; foreach ($arrayofparameters as $constname => $val) { - if ($val['enabled']==1) { - $setupnotempty++; - print ''; print ''; + // Website + print ''; + print ''; + // Address print ''; +print ''; +print ''; +print ''; + + +if($conf->global->PARTNERSHIP_IS_MANAGED_FOR == 'member'){ + print ''; + print ''; + print ''; + print ''; +} + + +print ''; +print ''; +print ''; +print ''; + + +print '
'; $selectarray = array('-1'=>'', 'withoutsubscription'=>$langs->trans("WithoutSubscription"), 'uptodate'=>$langs->trans("UpToDate"), 'outofdate'=>$langs->trans("OutOfDate")); print $form->selectarray('search_filter', $selectarray, $search_filter); @@ -613,7 +611,7 @@ foreach ($object->fields as $key => $val) { } } // End of subscription date -if ($managedfor == 'member'){ +if ($managedfor == 'member') { $key = 'datefin'; $cssforfield = 'center'; print getTitleFieldOfList('SubscriptionEndDate', 0, $_SERVER['PHP_SELF'], 'd.'.$key, '', $param, ($cssforfield ? 'class="'.$cssforfield.'"' : ''), $sortfield, $sortorder, ($cssforfield ? $cssforfield.' ' : ''))."\n"; @@ -694,10 +692,10 @@ while ($i < ($limit ? min($num, $limit) : $num)) { } } // End of subscription date - if ($managedfor == 'member'){ + if ($managedfor == 'member') { print ''; $result = $adherent->fetch($object->fk_member); - if($result){ + if ($result) { $datefin = $adherent->datefin; if ($datefin) { print dol_print_date($datefin, 'day'); From dd7c09582fdc7b19bdaac710e765f9e1f4cf39e2 Mon Sep 17 00:00:00 2001 From: Dorian Vabre Date: Thu, 15 Apr 2021 10:45:44 +0200 Subject: [PATCH 016/147] payment page structure ok, still need to confirm the attendee after the payment --- htdocs/admin/eventorganization.php | 57 ++++---- htdocs/langs/en_US/eventorganization.lang | 4 + .../attendee_subscription.php | 64 ++++----- htdocs/public/payment/newpayment.php | 133 ++++++++++++++++++ 4 files changed, 193 insertions(+), 65 deletions(-) diff --git a/htdocs/admin/eventorganization.php b/htdocs/admin/eventorganization.php index c76d9a5c188..58f09786e23 100644 --- a/htdocs/admin/eventorganization.php +++ b/htdocs/admin/eventorganization.php @@ -61,8 +61,8 @@ $arrayofparameters = array( 'EVENTORGANIZATION_TEMPLATE_EMAIL_BULK_SPEAKER'=>array('type'=>'emailtemplate:eventorganization_send', 'enabled'=>1), 'EVENTORGANIZATION_TEMPLATE_EMAIL_BULK_ATTENDES'=>array('type'=>'emailtemplate:eventorganization_send', 'enabled'=>1), 'EVENTORGANIZATION_SECUREKEY'=>array('type'=>'securekey', 'enabled'=>1), - 'SERVICE_BOOTH_LOCATION'=>array('type'=>'product', 'enabled'=>1), - 'SERVICE_CONFERENCE_ATTENDEE_SUBSCRIPTION'=>array('type'=>'product', 'enabled'=>1), + 'SERVICE_BOOTH_LOCATION'=>array('type'=>'product', 'enabled'=>1), + 'SERVICE_CONFERENCE_ATTENDEE_SUBSCRIPTION'=>array('type'=>'product', 'enabled'=>1), ); $error = 0; @@ -209,12 +209,12 @@ if ($action == 'edit') { print '
'.$langs->trans("Parameter").''.$langs->trans("Value").'
'; - $tooltiphelp = (($langs->trans($constname . 'Tooltip') != $constname . 'Tooltip') ? $langs->trans($constname . 'Tooltip') : ''); - print ''.$form->textwithpicto($langs->trans($constname), $tooltiphelp, 1, 'info', '', 0, 3, 'tootips'.$constname).''; - print ''; + if ($val['enabled']==1) { + $setupnotempty++; + print '
'; + $tooltiphelp = (($langs->trans($constname . 'Tooltip') != $constname . 'Tooltip') ? $langs->trans($constname . 'Tooltip') : ''); + print ''.$form->textwithpicto($langs->trans($constname), $tooltiphelp, 1, 'info', '', 0, 3, 'tootips'.$constname).''; + print ''; if ($val['type'] == 'textarea') { print ''; @@ -1278,6 +1289,10 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { print '
'.($conf->global->ADHERENT_MAIL_REQUIRED ? '' : '').$langs->trans("EMail").($conf->global->ADHERENT_MAIL_REQUIRED ? '' : '').''.img_picto('', 'object_email').' email).'">
'.$form->editfieldkey('Web', 'member_url', GETPOST('member_url', 'alpha'), $object, 0).''.img_picto('', 'globe').'
'.$langs->trans("Address").''; print ''; diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index 0299b32663c..bd9613d0645 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -141,6 +141,11 @@ class Adherent extends CommonObject */ public $email; + /** + * @var string url + */ + public $url; + /** * @var array array of socialnetworks */ @@ -309,6 +314,7 @@ class Adherent extends CommonObject 'state_id' => array('type' => 'integer', 'label' => 'State id', 'enabled' => 1, 'visible' => -1, 'position' => 90), 'country' => array('type' => 'integer:Ccountry:core/class/ccountry.class.php', 'label' => 'Country', 'enabled' => 1, 'visible' => -1, 'position' => 95), 'email' => array('type' => 'varchar(255)', 'label' => 'Email', 'enabled' => 1, 'visible' => -1, 'position' => 100), + 'url' =>array('type'=>'varchar(255)', 'label'=>'Url', 'enabled'=>1, 'visible'=>-1, 'position'=>110), 'socialnetworks' => array('type' => 'text', 'label' => 'Socialnetworks', 'enabled' => 1, 'visible' => -1, 'position' => 105), 'phone' => array('type' => 'varchar(30)', 'label' => 'Phone', 'enabled' => 1, 'visible' => -1, 'position' => 115), 'phone_perso' => array('type' => 'varchar(30)', 'label' => 'Phone perso', 'enabled' => 1, 'visible' => -1, 'position' => 120), @@ -645,6 +651,7 @@ class Adherent extends CommonObject $this->setUpperOrLowerCase(); $this->note_public = ($this->note_public ? $this->note_public : $this->note_public); $this->note_private = ($this->note_private ? $this->note_private : $this->note_private); + $this->url = $this->url ?clean_url($this->url, 0) : ''; // Check parameters if (!empty($conf->global->ADHERENT_MAIL_REQUIRED) && !isValidEMail($this->email)) { @@ -670,6 +677,7 @@ class Adherent extends CommonObject $sql .= ", country = ".($this->country_id > 0 ? $this->db->escape($this->country_id) : "null"); $sql .= ", state_id = ".($this->state_id > 0 ? $this->db->escape($this->state_id) : "null"); $sql .= ", email = '".$this->db->escape($this->email)."'"; + $sql .= ", url = ".(!empty($this->url) ? "'".$this->db->escape($this->url)."'" : "null"); $sql .= ", socialnetworks = '".$this->db->escape(json_encode($this->socialnetworks))."'"; $sql .= ", phone = ".($this->phone ? "'".$this->db->escape($this->phone)."'" : "null"); $sql .= ", phone_perso = ".($this->phone_perso ? "'".$this->db->escape($this->phone_perso)."'" : "null"); @@ -1282,7 +1290,7 @@ class Adherent extends CommonObject $sql = "SELECT d.rowid, d.ref, d.ref_ext, d.civility as civility_code, d.gender, d.firstname, d.lastname,"; $sql .= " d.societe as company, d.fk_soc, d.statut, d.public, d.address, d.zip, d.town, d.note_private,"; $sql .= " d.note_public,"; - $sql .= " d.email, d.socialnetworks, d.phone, d.phone_perso, d.phone_mobile, d.login, d.pass, d.pass_crypted,"; + $sql .= " d.email, d.url, d.socialnetworks, d.phone, d.phone_perso, d.phone_mobile, d.login, d.pass, d.pass_crypted,"; $sql .= " d.photo, d.fk_adherent_type, d.morphy, d.entity,"; $sql .= " d.datec as datec,"; $sql .= " d.tms as datem,"; @@ -1361,6 +1369,7 @@ class Adherent extends CommonObject $this->phone_perso = $obj->phone_perso; $this->phone_mobile = $obj->phone_mobile; $this->email = $obj->email; + $this->url = $obj->url; $this->socialnetworks = (array) json_decode($obj->socialnetworks, true); diff --git a/htdocs/install/mysql/migration/13.0.0-14.0.0.sql b/htdocs/install/mysql/migration/13.0.0-14.0.0.sql index 97ee2b751ae..c1e75bbe353 100644 --- a/htdocs/install/mysql/migration/13.0.0-14.0.0.sql +++ b/htdocs/install/mysql/migration/13.0.0-14.0.0.sql @@ -424,7 +424,7 @@ INSERT INTO llx_c_email_templates (entity,module,type_template,label,lang,positi INSERT INTO llx_c_email_templates (entity,module,type_template,label,lang,position,topic,joinfiles,content) VALUES (0, 'partnership', 'partnership_send', '(SendingEmailOnPartnershipCanceled)', NULL, 100, '[__[MAIN_INFO_SOCIETE_NOM]__] - __(YourPartnershipCanceledTopic)__', 0, '\n

Hello,

\n__(YourPartnershipCanceledContent)__

\n
\n\n
\n\n __(Sincerely)__
\n __[MAIN_INFO_SOCIETE_NOM]__
\n \n'); INSERT INTO llx_c_email_templates (entity,module,type_template,label,lang,position,topic,joinfiles,content) VALUES (0, 'partnership', 'partnership_send', '(SendingEmailOnPartnershipRefused)', NULL, 100, '[__[MAIN_INFO_SOCIETE_NOM]__] - __(YourPartnershipRefusedTopic)__', 0, '\n

Hello,

\n__(YourPartnershipRefusedContent)__

\n
\n\n
\n\n __(Sincerely)__
\n __[MAIN_INFO_SOCIETE_NOM]__
\n \n'); INSERT INTO llx_c_email_templates (entity,module,type_template,label,lang,position,topic,joinfiles,content) VALUES (0, 'partnership', 'partnership_send', '(SendingEmailOnPartnershipAccepted)', NULL, 100, '[__[MAIN_INFO_SOCIETE_NOM]__] - __(YourPartnershipAcceptedTopic)__', 0, '\n

Hello,

\n__(YourPartnershipAcceptedContent)__

\n
\n\n
\n\n __(Sincerely)__
\n __[MAIN_INFO_SOCIETE_NOM]__
\n \n'); -ALTER TABLE llx_adherent ADD COLUMN website varchar(255) NULL AFTER email; +ALTER TABLE llx_adherent ADD COLUMN url varchar(255) NULL AFTER email; ALTER TABLE llx_facture_fourn ADD COLUMN date_closing datetime DEFAULT NULL after date_valid; ALTER TABLE llx_facture_fourn ADD COLUMN fk_user_closing integer DEFAULT NULL after fk_user_valid; From 5a8742b3ebe313c14565e0944527777e1b100df9 Mon Sep 17 00:00:00 2001 From: NextGestion Date: Sat, 17 Apr 2021 13:25:28 +0100 Subject: [PATCH 042/147] Cancel Partnership For Expired Members & Warning of partnership if Dolibarr backlink not found on partner website --- htdocs/core/modules/modPartnership.class.php | 6 +- .../install/mysql/migration/13.0.0-14.0.0.sql | 13 +- htdocs/langs/en_US/partnership.lang | 6 +- htdocs/partnership/admin/setup.php | 59 ++- .../partnership/class/partnership.class.php | 5 +- .../class/partnershiputils.class.php | 420 +++++++++++++++++- htdocs/partnership/partnership_list.php | 6 +- 7 files changed, 474 insertions(+), 41 deletions(-) diff --git a/htdocs/core/modules/modPartnership.class.php b/htdocs/core/modules/modPartnership.class.php index ae5886e589c..0d5d6dce7ca 100644 --- a/htdocs/core/modules/modPartnership.class.php +++ b/htdocs/core/modules/modPartnership.class.php @@ -177,7 +177,7 @@ class modPartnership extends DolibarrModules // Array to add new pages in new tabs $this->tabs = array(); - $tabtoadd = (!empty(getDolGlobalString('PARTNERSHIP_IS_MANAGED_FOR')) && getDolGlobalString('PARTNERSHIP_IS_MANAGED_FOR') == 'member') ? 'member' : 'thirdparty'; + $tabtoadd = ($conf->global->PARTNERSHIP_IS_MANAGED_FOR == 'member') ? 'member' : 'thirdparty'; if ($tabtoadd == 'member') { $this->tabs[] = array('data'=>'member:+partnership:Partnership:partnership@partnership:$user->rights->partnership->read:/adherents/partnership.php?socid=__ID__'); @@ -253,12 +253,12 @@ class modPartnership extends DolibarrModules // Cronjobs (List of cron jobs entries to add when module is enabled) // unit_frequency must be 60 for minute, 3600 for hour, 86400 for day, 604800 for week - $statusatinstall=0; $arraydate=dol_getdate(dol_now()); $datestart=dol_mktime(21, 15, 0, $arraydate['mon'], $arraydate['mday'], $arraydate['year']); $this->cronjobs = array( - 0 => array('priority'=>60, 'label'=>'CancelPartnershipForExpiredMembers', 'jobtype'=>'method', 'class'=>'/partnership/class/partnershiputils.class.php', 'objectname'=>'PartnershipUtils', 'method'=>'doCancelStatusOfPartnership', 'parameters'=>'', 'comment'=>'Cancel status of partnership when subscription is expired + x days.', 'frequency'=>1, 'unitfrequency'=>86400, 'status'=>$statusatinstall, 'test'=>'$conf->partnership->enabled', 'datestart'=>$datestart), + 0 => array('priority'=>60, 'label'=>'CancelPartnershipForExpiredMembers', 'jobtype'=>'method', 'class'=>'/partnership/class/partnershiputils.class.php', 'objectname'=>'PartnershipUtils', 'method'=>'doCancelStatusOfMemberPartnership', 'parameters'=>'', 'comment'=>'Cancel status of partnership when subscription is expired + x days.', 'frequency'=>1, 'unitfrequency'=>86400, 'status'=>1, 'test'=>'$conf->partnership->enabled', 'datestart'=>$datestart), + 1 => array('priority'=>61, 'label'=>'WarningOfPartnershipIfDolibarrBacklinkNotfound', 'jobtype'=>'method', 'class'=>'/partnership/class/partnershiputils.class.php', 'objectname'=>'PartnershipUtils', 'method'=>'doWarningOfPartnershipIfDolibarrBacklinkNotfound', 'parameters'=>'', 'comment'=>'Warning of partnership if Dolibarr backlink not found on partner website.', 'frequency'=>1, 'unitfrequency'=>86400, 'status'=>0, 'test'=>'$conf->partnership->enabled', 'datestart'=>$datestart), ); // Permissions provided by this module diff --git a/htdocs/install/mysql/migration/13.0.0-14.0.0.sql b/htdocs/install/mysql/migration/13.0.0-14.0.0.sql index c1e75bbe353..d0375349880 100644 --- a/htdocs/install/mysql/migration/13.0.0-14.0.0.sql +++ b/htdocs/install/mysql/migration/13.0.0-14.0.0.sql @@ -398,8 +398,9 @@ CREATE TABLE llx_partnership( note_private text, note_public text, last_main_doc varchar(255), - count_last_url_check_error integer DEFAULT '0', - import_key varchar(14), + count_last_url_check_error integer DEFAULT '0', + last_check_backlink datetime NULL, + import_key varchar(14), model_pdf varchar(255) ) ENGINE=innodb; @@ -420,10 +421,10 @@ create table llx_partnership_extrafields ALTER TABLE llx_partnership_extrafields ADD INDEX idx_partnership_fk_object(fk_object); -INSERT INTO llx_c_email_templates (entity,module,type_template,label,lang,position,topic,joinfiles,content) VALUES (0, 'partnership', 'partnership_send', '(SendingEmailOnPartnershipWillExpire)', NULL, 100, '[__[MAIN_INFO_SOCIETE_NOM]__] - __(YourPartnershipWillSoonExpireTopic)__', 0, '\n

Hello,

\n__(YourPartnershipWillSoonExpireContent)__

\n
\n\n
\n\n __(Sincerely)__
\n __[MAIN_INFO_SOCIETE_NOM]__
\n \n'); -INSERT INTO llx_c_email_templates (entity,module,type_template,label,lang,position,topic,joinfiles,content) VALUES (0, 'partnership', 'partnership_send', '(SendingEmailOnPartnershipCanceled)', NULL, 100, '[__[MAIN_INFO_SOCIETE_NOM]__] - __(YourPartnershipCanceledTopic)__', 0, '\n

Hello,

\n__(YourPartnershipCanceledContent)__

\n
\n\n
\n\n __(Sincerely)__
\n __[MAIN_INFO_SOCIETE_NOM]__
\n \n'); -INSERT INTO llx_c_email_templates (entity,module,type_template,label,lang,position,topic,joinfiles,content) VALUES (0, 'partnership', 'partnership_send', '(SendingEmailOnPartnershipRefused)', NULL, 100, '[__[MAIN_INFO_SOCIETE_NOM]__] - __(YourPartnershipRefusedTopic)__', 0, '\n

Hello,

\n__(YourPartnershipRefusedContent)__

\n
\n\n
\n\n __(Sincerely)__
\n __[MAIN_INFO_SOCIETE_NOM]__
\n \n'); -INSERT INTO llx_c_email_templates (entity,module,type_template,label,lang,position,topic,joinfiles,content) VALUES (0, 'partnership', 'partnership_send', '(SendingEmailOnPartnershipAccepted)', NULL, 100, '[__[MAIN_INFO_SOCIETE_NOM]__] - __(YourPartnershipAcceptedTopic)__', 0, '\n

Hello,

\n__(YourPartnershipAcceptedContent)__

\n
\n\n
\n\n __(Sincerely)__
\n __[MAIN_INFO_SOCIETE_NOM]__
\n \n'); +INSERT INTO llx_c_email_templates (entity,module,type_template,label,lang,position,topic,joinfiles,content) VALUES (0, 'partnership', 'partnership_send', '(SendingEmailOnPartnershipWillExpire)', '', 100, '[__[MAIN_INFO_SOCIETE_NOM]__] - __(YourPartnershipWillSoonExpireTopic)__', 0, '\n

Hello,

\n__(YourPartnershipWillSoonExpireContent)__

\n
\n\n
\n\n __(Sincerely)__
\n __[MAIN_INFO_SOCIETE_NOM]__
\n \n'); +INSERT INTO llx_c_email_templates (entity,module,type_template,label,lang,position,topic,joinfiles,content) VALUES (0, 'partnership', 'partnership_send', '(SendingEmailOnPartnershipCanceled)', '', 100, '[__[MAIN_INFO_SOCIETE_NOM]__] - __(YourPartnershipCanceledTopic)__', 0, '\n

Hello,

\n__(YourPartnershipCanceledContent)__

\n
\n\n
\n\n __(Sincerely)__
\n __[MAIN_INFO_SOCIETE_NOM]__
\n \n'); +INSERT INTO llx_c_email_templates (entity,module,type_template,label,lang,position,topic,joinfiles,content) VALUES (0, 'partnership', 'partnership_send', '(SendingEmailOnPartnershipRefused)', '', 100, '[__[MAIN_INFO_SOCIETE_NOM]__] - __(YourPartnershipRefusedTopic)__', 0, '\n

Hello,

\n__(YourPartnershipRefusedContent)__

\n
\n\n
\n\n __(Sincerely)__
\n __[MAIN_INFO_SOCIETE_NOM]__
\n \n'); +INSERT INTO llx_c_email_templates (entity,module,type_template,label,lang,position,topic,joinfiles,content) VALUES (0, 'partnership', 'partnership_send', '(SendingEmailOnPartnershipAccepted)', '', 100, '[__[MAIN_INFO_SOCIETE_NOM]__] - __(YourPartnershipAcceptedTopic)__', 0, '\n

Hello,

\n__(YourPartnershipAcceptedContent)__

\n
\n\n
\n\n __(Sincerely)__
\n __[MAIN_INFO_SOCIETE_NOM]__
\n \n'); ALTER TABLE llx_adherent ADD COLUMN url varchar(255) NULL AFTER email; ALTER TABLE llx_facture_fourn ADD COLUMN date_closing datetime DEFAULT NULL after date_valid; diff --git a/htdocs/langs/en_US/partnership.lang b/htdocs/langs/en_US/partnership.lang index 4d5b518431f..2da278dd36c 100644 --- a/htdocs/langs/en_US/partnership.lang +++ b/htdocs/langs/en_US/partnership.lang @@ -32,7 +32,10 @@ ListOfPartnerships=List of partnership PartnershipSetup=Partnership setup PartnershipAbout=About Partnership PartnershipAboutPage=Partnership about page -PartnershipManagedFor=Partnership managed for +partnershipforthirdpartyormember=Partnership is for a 'thirdparty' or for a 'member' +PARTNERSHIP_IS_MANAGED_FOR=Partnership managed for +PARTNERSHIP_BACKLINKS_TO_CHECK=Backlinks to check +PARTNERSHIP_NBDAYS_AFTER_MEMBER_EXPIRATION_BEFORE_CANCEL=Nb of days before cancel status of partnership # # Object @@ -44,6 +47,7 @@ ReasonDecline=Decline reason ReasonDeclineOrCancel=Decline reason PartnershipAlreadyExist=Partnership already exist ShowPartnership=Show partnership +BacklinkNotFoundOnPartnerWebsite=Backlink not found on partner website ConfirmClosePartnershipAsk=Are you sure you want to cancel this partnership? # diff --git a/htdocs/partnership/admin/setup.php b/htdocs/partnership/admin/setup.php index 77edba1f21f..4cd5fe5f387 100644 --- a/htdocs/partnership/admin/setup.php +++ b/htdocs/partnership/admin/setup.php @@ -82,9 +82,7 @@ include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; if ($action == 'setting') { require_once DOL_DOCUMENT_ROOT."/core/modules/modPartnership.class.php"; - $value = GETPOST('managed_for', 'alpha'); - - $modulemenu = ($value == 'member') ? 'member' : 'thirdparty'; + $modulemenu = (GETPOST('PARTNERSHIP_IS_MANAGED_FOR', 'alpha') == 'member') ? 'member' : 'thirdparty'; $res = dolibarr_set_const($db, "PARTNERSHIP_IS_MANAGED_FOR", $modulemenu, 'chaine', 0, '', $conf->entity); $partnership = new modPartnership($db); @@ -94,6 +92,10 @@ if ($action == 'setting') { $error += $partnership->delete_menus(); $error += $partnership->insert_menus(); + + if(GETPOST("PARTNERSHIP_NBDAYS_AFTER_MEMBER_EXPIRATION_BEFORE_CANCEL",'int')) + dolibarr_set_const($db, "PARTNERSHIP_NBDAYS_AFTER_MEMBER_EXPIRATION_BEFORE_CANCEL", GETPOST("PARTNERSHIP_NBDAYS_AFTER_MEMBER_EXPIRATION_BEFORE_CANCEL",'int'), 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "PARTNERSHIP_BACKLINKS_TO_CHECK", GETPOST("PARTNERSHIP_BACKLINKS_TO_CHECK"), 'chaine', 0, '', $conf->entity); } if ($action) { @@ -102,6 +104,8 @@ if ($action) { } else { setEventMessages($langs->trans("SetupNotError"), null, 'errors'); } + header("Location: ".$_SERVER['PHP_SELF']); + exit; } /* @@ -137,19 +141,48 @@ print ''; print ''; -// Default partnership price base type -print ''; -print ''; -print ''; + +print ''; +print ''; +print ''; +print ''; print ''; -print '
'.$langs->trans("PartnershipManagedFor").''; - print ''; -print '
'.$langs->trans("Setting").''.$langs->trans("Value").''.$langs->trans("Examples").'
'; +print '
'.$langs->trans("PARTNERSHIP_IS_MANAGED_FOR").''; +print ''; +print ''.$langs->trans("partnershipforthirdpartyormember").'
'.$langs->trans("PARTNERSHIP_NBDAYS_AFTER_MEMBER_EXPIRATION_BEFORE_CANCEL").''; + $dnbdays = '7'; + $backlinks = (!empty($conf->global->PARTNERSHIP_NBDAYS_AFTER_MEMBER_EXPIRATION_BEFORE_CANCEL)) ? $conf->global->PARTNERSHIP_NBDAYS_AFTER_MEMBER_EXPIRATION_BEFORE_CANCEL : $dnbdays; + print ''; + print ''.$dnbdays.'
'.$langs->trans("PARTNERSHIP_BACKLINKS_TO_CHECK").''; +$dbacklinks = 'dolibarr.org|dolibarr.fr|dolibarr.es'; +$backlinks = (!empty($conf->global->PARTNERSHIP_BACKLINKS_TO_CHECK)) ? $conf->global->PARTNERSHIP_BACKLINKS_TO_CHECK : $dbacklinks; +print ''; +print ''.$dbacklinks.'
'; print '
'; print ''; print '
'; diff --git a/htdocs/partnership/class/partnership.class.php b/htdocs/partnership/class/partnership.class.php index fd0233d3fef..6bf84ba38cc 100644 --- a/htdocs/partnership/class/partnership.class.php +++ b/htdocs/partnership/class/partnership.class.php @@ -118,6 +118,7 @@ class Partnership extends CommonObject public $date_partnership_start; public $date_partnership_end; public $count_last_url_check_error; + public $last_check_backlink; public $reason_decline_or_cancel; // END MODULEBUILDER PROPERTIES @@ -186,6 +187,7 @@ class Partnership extends CommonObject 'date_partnership_end' => array('type'=>'date', 'label'=>'DatePartnershipEnd', 'enabled'=>'1', 'position'=>53, 'notnull'=>1, 'visible'=>1,), 'status' => array('type'=>'smallint', 'label'=>'Status', 'enabled'=>'1', 'position'=>54, 'notnull'=>0, 'visible'=>2, 'index'=>1, 'arrayofkeyval'=>array('-1'=>'','0'=>$langs->trans('Draft'), '1'=>$langs->trans('Accepted'), '2'=>$langs->trans('Refused'), '9'=>$langs->trans('Canceled')),), 'count_last_url_check_error' => array('type'=>'integer', 'label'=>'CountLastUrlCheckError', 'enabled'=>'1', 'position'=>63, 'notnull'=>0, 'visible'=>-2, 'default'=>'0',), + 'last_check_backlink' => array('type'=>'datetime', 'label'=>'LastCheckBacklink', 'enabled'=>'1', 'position'=>65, 'notnull'=>0, 'visible'=>-2,), 'reason_decline_or_cancel' => array('type'=>'text', 'label'=>'ReasonDeclineOrCancel', 'enabled'=>'1', 'position'=>64, 'notnull'=>0, 'visible'=>-2,), ); @@ -361,7 +363,7 @@ class Partnership extends CommonObject $sql .= ', p.entity, p.date_partnership_start, p.date_partnership_end, p.date_creation'; $sql .= ', p.fk_user_creat, p.tms, p.fk_user_modif, p.fk_user_modif'; $sql .= ', p.note_private, p.note_public'; - $sql .= ', p.last_main_doc, p.count_last_url_check_error, p.reason_decline_or_cancel'; + $sql .= ', p.last_main_doc, p.count_last_url_check_error, p.last_check_backlink, p.reason_decline_or_cancel'; $sql .= ', p.import_key, p.model_pdf'; $sql .= ' FROM '.MAIN_DB_PREFIX.'partnership as p'; @@ -407,6 +409,7 @@ class Partnership extends CommonObject $this->note_public = $obj->note_public; $this->last_main_doc = $obj->last_main_doc; $this->count_last_url_check_error = $obj->count_last_url_check_error; + $this->last_check_backlink = $this->db->jdate($obj->last_check_backlink); $this->reason_decline_or_cancel = $obj->reason_decline_or_cancel; $this->import_key = $obj->import_key; $this->model_pdf = $obj->model_pdf; diff --git a/htdocs/partnership/class/partnershiputils.class.php b/htdocs/partnership/class/partnershiputils.class.php index 08c61b3454c..64fd0f62431 100644 --- a/htdocs/partnership/class/partnershiputils.class.php +++ b/htdocs/partnership/class/partnershiputils.class.php @@ -26,9 +26,13 @@ require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/geturl.lib.php'; + dol_include_once('partnership/lib/partnership.lib.php'); +dol_include_once('/partnership/class/partnership.class.php'); - +require_once(DOL_DOCUMENT_ROOT."/societe/class/societe.class.php"); +require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; /** * Class with cron tasks of Partnership module */ @@ -49,34 +53,422 @@ class PartnershipUtils $this->db = $db; return 1; } - - + /** - * Action executed by scheduler to cancel status of partnership when subscription is expired + x days. (Max number of cancel per call = $conf->global->PARTNERSHIP_MAX_CANCEL_PER_CALL) + * Action executed by scheduler to cancel status of partnership when subscription is expired + x days. (Max number of action batch per call = $conf->global->PARTNERSHIP_MAX_EXPIRATION_CANCEL_PER_CALL) * * CAN BE A CRON TASK * * @return int 0 if OK, <>0 if KO (this function is used also by cron so only 0 is OK) */ - public function doCancelStatusOfPartnership() + public function doCancelStatusOfMemberPartnership() { global $conf, $langs, $user; - $langs->load("agenda"); + $managedfor = $conf->global->PARTNERSHIP_IS_MANAGED_FOR; - $MAXPERCALL = (empty($conf->global->PARTNERSHIP_MAX_CANCEL_PER_CALL) ? 100 : $conf->global->PARTNERSHIP_MAX_CANCEL_PER_CALL); // Limit to 100 per call + if($managedfor != 'member'){ + return 0; // If option 'PARTNERSHIP_IS_MANAGED_FOR' = 'thirdparty', this cron job does nothing. + } - $error = 0; - $this->output = ''; - $this->error=''; + $partnership = new Partnership($this->db); + $MAXPERCALL = (empty($conf->global->PARTNERSHIP_MAX_EXPIRATION_CANCEL_PER_CALL) ? 25 : $conf->global->PARTNERSHIP_MAX_EXPIRATION_CANCEL_PER_CALL); // Limit to 25 per call + + $langs->loadLangs(array("partnership", "member")); + + $error = 0; + $erroremail = ''; + $this->output = ''; + $this->error = ''; + $partnershipsprocessed = array(); + + $gracedelay=$conf->global->PARTNERSHIP_NBDAYS_AFTER_MEMBER_EXPIRATION_BEFORE_CANCEL; + if ($gracedelay < 1) + { + $this->error='BadValueForDelayBeforeCancelCheckSetup'; + return -1; + } + + dol_syslog(get_class($this)."::doCancelStatusOfMemberPartnership cancel expired partnerships with grace delay of ".$gracedelay); + + $now = dol_now(); + $datetotest = dol_time_plus_duree($now, -1 * abs($gracedelay), 'd'); + + $this->db->begin(); + + $sql = "SELECT p.rowid, p.fk_member, p.status"; + $sql .= ", d.datefin, d.fk_adherent_type, dty.subscription"; + $sql .= " FROM ".MAIN_DB_PREFIX."partnership as p"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."adherent as d on (d.rowid = p.fk_member)"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."adherent_type as dty on (dty.rowid = d.fk_adherent_type)"; + $sql .= " WHERE fk_member > 0"; + $sql .= " AND (d.datefin < '".$this->db->idate($datetotest)."' AND dty.subscription = 1)"; + $sql .= " AND p.status = ".$partnership::STATUS_ACCEPTED; // Only accepted not yet canceled + $sql .= $this->db->order('d.rowid','ASC'); + // Limit is managed into loop later + + $resql = $this->db->query($sql); + if ($resql) + { + $numofexpiredmembers = $this->db->num_rows($resql); + + $somethingdoneonpartnership = 0; + $ifetchpartner = 0; + while ($ifetchpartner < $numofexpiredmembers) + { + $ifetchpartner++; + + $obj = $this->db->fetch_object($resql); + if ($obj) + { + if (! empty($partnershipsprocessed[$obj->rowid])) continue; + + if ($somethingdoneonpartnership >= $MAXPERCALL) + { + dol_syslog("We reach the limit of ".$MAXPERCALL." partnership processed, so we quit loop for this batch doCancelStatusOfMemberPartnership to avoid to reach email quota.", LOG_WARNING); + break; + } + + $object = new Partnership($this->db); + $object->fetch($obj->rowid); + + // Get expiration date + $expirationdate = $obj->datefin; + + if ($expirationdate && $expirationdate < $now) // If contract expired (we already had a test into main select, this is a security) + { + $somethingdoneonpartnership++; + + $result = $object->cancel($user, 0); + // $conf->global->noapachereload = null; + if ($result < 0) + { + $error++; + $this->error = $object->error; + if (is_array($object->errors) && count($object->errors)) { + if (is_array($this->errors)) $this->errors = array_merge($this->errors, $object->errors); + else $this->errors = $object->errors; + } + } + else + { + $partnershipsprocessed[$object->id]=$object->ref; + + // Send an email to inform member + $labeltemplate = '(SendingEmailOnPartnershipCanceled)'; + + dol_syslog("Now we will send an email to member id=".$object->fk_member." with label ".$labeltemplate); + + // Send deployment email + include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; + include_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; + $formmail=new FormMail($this->db); + + // Define output language + $outputlangs = $langs; + $newlang = ''; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id','aZ09')) $newlang = GETPOST('lang_id','aZ09'); + if (! empty($newlang)) { + $outputlangs = new Translate("", $conf); + $outputlangs->setDefaultLang($newlang); + $outputlangs->loadLangs(array('main','member','partnership')); + } + + $arraydefaultmessage=$formmail->getEMailTemplate($this->db, 'partnership_send', $user, $outputlangs, 0, 1, $labeltemplate); + + $substitutionarray=getCommonSubstitutionArray($outputlangs, 0, null, $object); + complete_substitutions_array($substitutionarray, $outputlangs, $object); + + $subject = make_substitutions($arraydefaultmessage->topic, $substitutionarray, $outputlangs); + $msg = make_substitutions($arraydefaultmessage->content, $substitutionarray, $outputlangs); + $from = dol_string_nospecial($conf->global->MAIN_INFO_SOCIETE_NOM, ' ', array(",")).' <'.$conf->global->MAIN_INFO_SOCIETE_MAIL.'>'; + + $adherent = new Adherent($this->db); + $adherent->fetch($object->fk_member); + $to = $adherent->email; + + $cmail = new CMailFile($subject, $to, $from, $msg, array(), array(), array(), '', '', 0, 1); + $result = $cmail->sendfile(); + if (! $result || $cmail->error) + { + $erroremail .= ($erroremail ? ', ' : '').$cmail->error; + $this->errors[] = $cmail->error; + if (is_array($cmail->errors) && count($cmail->errors) > 0) $this->errors += $cmail->errors; + } + } + + } + } + } + } + else + { + $error++; + $this->error = $this->db->lasterror(); + } + + if (! $error) + { + $this->db->commit(); + $this->output = $numofexpiredmembers.' expired partnership members found'."\n"; + if ($erroremail) $this->output.='. Got errors when sending some email : '.$erroremail; + } + else + { + $this->db->rollback(); + $this->output = "Rollback after error\n"; + $this->output.= $numofexpiredmembers.' expired partnership members found'."\n"; + if ($erroremail) $this->output.='. Got errors when sending some email : '.$erroremail; + } + + return ($error ? 1: 0); + } - dol_syslog(__METHOD__." we cancel status of partnership ", LOG_DEBUG); + /** + * Action executed by scheduler to check if Dolibarr backlink not found on partner website. (Max number of action batch per call = $conf->global->PARTNERSHIP_MAX_WARNING_BACKLINK_PER_CALL) + * + * CAN BE A CRON TASK + * + * @return int 0 if OK, <>0 if KO (this function is used also by cron so only 0 is OK) + */ + public function doWarningOfPartnershipIfDolibarrBacklinkNotfound() + { + global $conf, $langs, $user; - $now = dol_now(); + $managedfor = $conf->global->PARTNERSHIP_IS_MANAGED_FOR; - // En cours de traitement ... + $partnership = new Partnership($this->db); + $MAXPERCALL = (empty($conf->global->PARTNERSHIP_MAX_WARNING_BACKLINK_PER_CALL) ? 10 : $conf->global->PARTNERSHIP_MAX_WARNING_BACKLINK_PER_CALL); // Limit to 10 per call - return ($error ? 1: 0); + $langs->loadLangs(array("partnership", "member")); + + $error = 0; + $erroremail = ''; + $this->output = ''; + $this->error = ''; + $partnershipsprocessed = array(); + + $gracedelay=$conf->global->PARTNERSHIP_NBDAYS_AFTER_MEMBER_EXPIRATION_BEFORE_CANCEL; + if ($gracedelay < 1) + { + $this->error='BadValueForDelayBeforeCancelCheckSetup'; + return -1; + } + + $fk_partner = ($managedfor == 'member') ? 'fk_member' : 'fk_soc'; + + dol_syslog(get_class($this)."::doWarningOfPartnershipIfDolibarrBacklinkNotfound Warning of partnership"); + + $now = dol_now(); + $datetotest = dol_time_plus_duree($now, -1 * abs($gracedelay), 'd'); + + $this->db->begin(); + + $sql = "SELECT p.rowid, p.status, p.".$fk_partner; + $sql .= ", p.last_check_backlink"; + + $sql .= ', partner.url, partner.email'; + + $sql .= " FROM ".MAIN_DB_PREFIX."partnership as p"; + + if ($managedfor == 'member') { + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."adherent as partner on (partner.rowid = p.fk_member)"; + } else { + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as partner on (partner.rowid = p.fk_soc)"; + } + + $sql .= " WHERE 1 = 1"; + $sql .= " AND p.".$fk_partner." > 0"; + $sql .= " AND p.status = ".$partnership::STATUS_ACCEPTED; // Only accepted not yet canceled + $sql .= " AND (p.last_check_backlink IS NULL OR p.last_check_backlink <= '".$this->db->idate($now - 7 * 24 * 3600)."')"; // Every week, check that website contains a link to dolibarr. + $sql .= $this->db->order('p.rowid','ASC'); + // Limit is managed into loop later + + $resql = $this->db->query($sql); + if ($resql) + { + $numofexpiredmembers = $this->db->num_rows($resql); + $somethingdoneonpartnership = 0; + $ifetchpartner = 0; + while ($ifetchpartner < $numofexpiredmembers) + { + $ifetchpartner++; + + $obj = $this->db->fetch_object($resql); + if ($obj) + { + if (! empty($partnershipsprocessed[$obj->rowid])) continue; + + if ($somethingdoneonpartnership >= $MAXPERCALL) + { + dol_syslog("We reach the limit of ".$MAXPERCALL." partnership processed, so we quit loop for this batch doWarningOfPartnershipIfDolibarrBacklinkNotfound to avoid to reach email quota.", LOG_WARNING); + break; + } + + $backlinkfound = 0; + + $object = new Partnership($this->db); + $object->fetch($obj->rowid); + + if($managedfor == 'member'){ + $fk_partner = $object->fk_member; + }else{ + $fk_partner = $object->fk_soc; + } + + $website = $obj->url; + + if(empty($website)){ + $websitenotfound .= ($websitenotfound ? ', ' : '').'Website not found for id="'.$fk_partner.'"'."\n"; + } else { + $backlinkfound = $this->checkDolibarrBacklink($website); + } + + if(!$backlinkfound){ + $tmpcount = $object->count_last_url_check_error + 1; + + if($tmpcount == 3){ // Send Warning Email + + if (!empty($obj->email)){ + $emailnotfound .= ($emailnotfound ? ', ' : '').'Email not found for id="'.$fk_partner.'"'."\n"; + + } else { + + $labeltemplate = '(SendingEmailOnPartnershipWillExpire)'; + + dol_syslog("Now we will send an email to partner id=".$fk_partner." with label ".$labeltemplate); + + // Send deployment email + include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; + include_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; + $formmail=new FormMail($this->db); + + // Define output language + $outputlangs = $langs; + $newlang = ''; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id','aZ09')) $newlang = GETPOST('lang_id','aZ09'); + if (! empty($newlang)) { + $outputlangs = new Translate("", $conf); + $outputlangs->setDefaultLang($newlang); + $outputlangs->loadLangs(array('main','member','partnership')); + } + + $arraydefaultmessage=$formmail->getEMailTemplate($this->db, 'partnership_send', $user, $outputlangs, 0, 1, $labeltemplate); + + $substitutionarray=getCommonSubstitutionArray($outputlangs, 0, null, $object); + complete_substitutions_array($substitutionarray, $outputlangs, $object); + + $subject = make_substitutions($arraydefaultmessage->topic, $substitutionarray, $outputlangs); + $msg = make_substitutions($arraydefaultmessage->content, $substitutionarray, $outputlangs); + $from = dol_string_nospecial($conf->global->MAIN_INFO_SOCIETE_NOM, ' ', array(",")).' <'.$conf->global->MAIN_INFO_SOCIETE_MAIL.'>'; + + $to = $obj->email; + + $cmail = new CMailFile($subject, $to, $from, $msg, array(), array(), array(), '', '', 0, 1); + $result = $cmail->sendfile(); + if (! $result || $cmail->error) + { + $erroremail .= ($erroremail ? ', ' : '').$cmail->error; + $this->errors[] = $cmail->error; + if (is_array($cmail->errors) && count($cmail->errors) > 0) $this->errors += $cmail->errors; + } + } + + + } elseif($tmpcount > 4) { // Cancel Partnership + $object->status = $object::STATUS_CANCELED; + $object->reason_decline_or_cancel = $langs->trans('BacklinkNotFoundOnPartnerWebsite'); + } + + $object->count_last_url_check_error = $tmpcount; + + } else { + $object->count_last_url_check_error = 0; + $object->reason_decline_or_cancel = ''; + } + + $partnershipsprocessed[$object->id]=$object->ref; + + $object->last_check_backlink = $this->db->idate($now); + + $object->update($user); + } + } + } + else + { + $error++; + $this->error = $this->db->lasterror(); + } + + if (! $error) + { + $this->db->commit(); + $this->output = $numofexpiredmembers.' partnership checked'."\n"; + if ($erroremail) $this->output.='. Got errors when sending some email : '.$erroremail."\n"; + if ($emailnotfound) $this->output.='. Email not found for some partner : '.$emailnotfound."\n"; + if ($websitenotfound) $this->output.='. Website not found for some partner : '.$websitenotfound."\n"; + } + else + { + $this->db->rollback(); + $this->output = "Rollback after error\n"; + $this->output.= $numofexpiredmembers.' partnership checked'."\n"; + if ($erroremail) $this->output.='. Got errors when sending some email : '.$erroremail."\n"; + if ($emailnotfound) $this->output.='. Email not found for some partner : '.$emailnotfound."\n"; + if ($websitenotfound) $this->output.='. Website not found for some partner : '.$websitenotfound."\n"; + } + + return ($error ? 1: 0); + } + + /** + * Action to check if Dolibarr backlink not found on partner website + * + * CAN BE A CRON TASK + * + * @return int 0 if KO, 1 if OK + */ + public function checkDolibarrBacklink($website = null) + { + global $conf, $langs, $user; + + $found = 0; + $error = 0; + $webcontent = ''; + + // $website = 'https://nextgestion.com/'; // For Test + $tmpgeturl = getURLContent($website); + if ($tmpgeturl['curl_error_no']) { + $error++; + dol_syslog('Error getting '.$website.': '.$tmpgeturl['curl_error_msg']); + } elseif ($tmpgeturl['http_code'] != '200') { + $error++; + dol_syslog('Error getting '.$website.': '.$tmpgeturl['curl_error_msg']); + } else { + $urlContent = $tmpgeturl['content']; + $dom = new DOMDocument(); + @$dom->loadHTML($urlContent); + + $xpath = new DOMXPath($dom); + $hrefs = $xpath->evaluate("//a"); + + for($i = 0; $i < $hrefs->length; $i++){ + $href = $hrefs->item($i); + $url = $href->getAttribute('href'); + $url = filter_var($url, FILTER_SANITIZE_URL); + if(!filter_var($url, FILTER_VALIDATE_URL) === false){ + $webcontent .= $url; + } + } + } + + if ($webcontent && !empty($conf->global->PARTNERSHIP_BACKLINKS_TO_CHECK) && preg_match('/'.$conf->global->PARTNERSHIP_BACKLINKS_TO_CHECK.'/', $webcontent)) + { + $found = 1; + } + + return $found; } } diff --git a/htdocs/partnership/partnership_list.php b/htdocs/partnership/partnership_list.php index 5ded7ae0047..1ae90d0d4cf 100644 --- a/htdocs/partnership/partnership_list.php +++ b/htdocs/partnership/partnership_list.php @@ -496,9 +496,9 @@ $param .= $hookmanager->resPrint; // List of mass actions available $arrayofmassactions = array( 'cancel'=>img_picto('', 'close_title', 'class="pictofixedwidth"').$langs->trans("Cancel"), - //'generate_doc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("ReGeneratePDF"), - //'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"), - 'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"), + //'generate_doc'=>img_picto('', 'pdf').$langs->trans("ReGeneratePDF"), + //'builddoc'=>img_picto('', 'pdf').$langs->trans("PDFMerge"), + 'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendMail"), ); if ($permissiontodelete) { $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete"); From 973ea370e8d23a95c091fc4312e2f3b88831af34 Mon Sep 17 00:00:00 2001 From: NextGestion Date: Sat, 17 Apr 2021 13:38:23 +0100 Subject: [PATCH 043/147] Fixing errors --- htdocs/core/modules/modPartnership.class.php | 4 ++-- htdocs/partnership/class/partnershiputils.class.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/core/modules/modPartnership.class.php b/htdocs/core/modules/modPartnership.class.php index 0d5d6dce7ca..d70b626a99b 100644 --- a/htdocs/core/modules/modPartnership.class.php +++ b/htdocs/core/modules/modPartnership.class.php @@ -177,7 +177,7 @@ class modPartnership extends DolibarrModules // Array to add new pages in new tabs $this->tabs = array(); - $tabtoadd = ($conf->global->PARTNERSHIP_IS_MANAGED_FOR == 'member') ? 'member' : 'thirdparty'; + $tabtoadd = (!empty(getDolGlobalString('PARTNERSHIP_IS_MANAGED_FOR')) && getDolGlobalString('PARTNERSHIP_IS_MANAGED_FOR') == 'member') ? 'member' : 'thirdparty'; if ($tabtoadd == 'member') { $this->tabs[] = array('data'=>'member:+partnership:Partnership:partnership@partnership:$user->rights->partnership->read:/adherents/partnership.php?socid=__ID__'); @@ -258,7 +258,7 @@ class modPartnership extends DolibarrModules $this->cronjobs = array( 0 => array('priority'=>60, 'label'=>'CancelPartnershipForExpiredMembers', 'jobtype'=>'method', 'class'=>'/partnership/class/partnershiputils.class.php', 'objectname'=>'PartnershipUtils', 'method'=>'doCancelStatusOfMemberPartnership', 'parameters'=>'', 'comment'=>'Cancel status of partnership when subscription is expired + x days.', 'frequency'=>1, 'unitfrequency'=>86400, 'status'=>1, 'test'=>'$conf->partnership->enabled', 'datestart'=>$datestart), - 1 => array('priority'=>61, 'label'=>'WarningOfPartnershipIfDolibarrBacklinkNotfound', 'jobtype'=>'method', 'class'=>'/partnership/class/partnershiputils.class.php', 'objectname'=>'PartnershipUtils', 'method'=>'doWarningOfPartnershipIfDolibarrBacklinkNotfound', 'parameters'=>'', 'comment'=>'Warning of partnership if Dolibarr backlink not found on partner website.', 'frequency'=>1, 'unitfrequency'=>86400, 'status'=>0, 'test'=>'$conf->partnership->enabled', 'datestart'=>$datestart), + 1 => array('priority'=>61, 'label'=>'CheckDolibarrBacklink', 'jobtype'=>'method', 'class'=>'/partnership/class/partnershiputils.class.php', 'objectname'=>'PartnershipUtils', 'method'=>'doWarningOfPartnershipIfDolibarrBacklinkNotfound', 'parameters'=>'', 'comment'=>'Warning of partnership if Dolibarr backlink not found on partner website.', 'frequency'=>1, 'unitfrequency'=>86400, 'status'=>0, 'test'=>'$conf->partnership->enabled', 'datestart'=>$datestart), ); // Permissions provided by this module diff --git a/htdocs/partnership/class/partnershiputils.class.php b/htdocs/partnership/class/partnershiputils.class.php index 64fd0f62431..6ed76518b42 100644 --- a/htdocs/partnership/class/partnershiputils.class.php +++ b/htdocs/partnership/class/partnershiputils.class.php @@ -427,7 +427,7 @@ class PartnershipUtils * Action to check if Dolibarr backlink not found on partner website * * CAN BE A CRON TASK - * + * @param $website Partner's website * @return int 0 if KO, 1 if OK */ public function checkDolibarrBacklink($website = null) From 48dffaaa537474399ddf631c6b90bebfd0482d20 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Sat, 17 Apr 2021 13:30:56 +0000 Subject: [PATCH 044/147] Fixing style errors. --- htdocs/partnership/admin/setup.php | 6 +- .../class/partnershiputils.class.php | 530 ++++++++---------- 2 files changed, 251 insertions(+), 285 deletions(-) diff --git a/htdocs/partnership/admin/setup.php b/htdocs/partnership/admin/setup.php index 4cd5fe5f387..f388c184517 100644 --- a/htdocs/partnership/admin/setup.php +++ b/htdocs/partnership/admin/setup.php @@ -93,8 +93,8 @@ if ($action == 'setting') { $error += $partnership->delete_menus(); $error += $partnership->insert_menus(); - if(GETPOST("PARTNERSHIP_NBDAYS_AFTER_MEMBER_EXPIRATION_BEFORE_CANCEL",'int')) - dolibarr_set_const($db, "PARTNERSHIP_NBDAYS_AFTER_MEMBER_EXPIRATION_BEFORE_CANCEL", GETPOST("PARTNERSHIP_NBDAYS_AFTER_MEMBER_EXPIRATION_BEFORE_CANCEL",'int'), 'chaine', 0, '', $conf->entity); + if (GETPOST("PARTNERSHIP_NBDAYS_AFTER_MEMBER_EXPIRATION_BEFORE_CANCEL", 'int')) + dolibarr_set_const($db, "PARTNERSHIP_NBDAYS_AFTER_MEMBER_EXPIRATION_BEFORE_CANCEL", GETPOST("PARTNERSHIP_NBDAYS_AFTER_MEMBER_EXPIRATION_BEFORE_CANCEL", 'int'), 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "PARTNERSHIP_BACKLINKS_TO_CHECK", GETPOST("PARTNERSHIP_BACKLINKS_TO_CHECK"), 'chaine', 0, '', $conf->entity); } @@ -160,7 +160,7 @@ print ''.$langs->trans("partnershipforthirdparty print ''; -if($conf->global->PARTNERSHIP_IS_MANAGED_FOR == 'member'){ +if ($conf->global->PARTNERSHIP_IS_MANAGED_FOR == 'member') { print ''.$langs->trans("PARTNERSHIP_NBDAYS_AFTER_MEMBER_EXPIRATION_BEFORE_CANCEL").''; print ''; $dnbdays = '7'; diff --git a/htdocs/partnership/class/partnershiputils.class.php b/htdocs/partnership/class/partnershiputils.class.php index 64fd0f62431..13616c32804 100644 --- a/htdocs/partnership/class/partnershiputils.class.php +++ b/htdocs/partnership/class/partnershiputils.class.php @@ -31,7 +31,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/geturl.lib.php'; dol_include_once('partnership/lib/partnership.lib.php'); dol_include_once('/partnership/class/partnership.class.php'); -require_once(DOL_DOCUMENT_ROOT."/societe/class/societe.class.php"); +require_once DOL_DOCUMENT_ROOT."/societe/class/societe.class.php"; require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; /** * Class with cron tasks of Partnership module @@ -53,7 +53,7 @@ class PartnershipUtils $this->db = $db; return 1; } - + /** * Action executed by scheduler to cancel status of partnership when subscription is expired + x days. (Max number of action batch per call = $conf->global->PARTNERSHIP_MAX_EXPIRATION_CANCEL_PER_CALL) * @@ -65,163 +65,147 @@ class PartnershipUtils { global $conf, $langs, $user; - $managedfor = $conf->global->PARTNERSHIP_IS_MANAGED_FOR; + $managedfor = $conf->global->PARTNERSHIP_IS_MANAGED_FOR; - if($managedfor != 'member'){ + if ($managedfor != 'member') { return 0; // If option 'PARTNERSHIP_IS_MANAGED_FOR' = 'thirdparty', this cron job does nothing. } - $partnership = new Partnership($this->db); - $MAXPERCALL = (empty($conf->global->PARTNERSHIP_MAX_EXPIRATION_CANCEL_PER_CALL) ? 25 : $conf->global->PARTNERSHIP_MAX_EXPIRATION_CANCEL_PER_CALL); // Limit to 25 per call + $partnership = new Partnership($this->db); + $MAXPERCALL = (empty($conf->global->PARTNERSHIP_MAX_EXPIRATION_CANCEL_PER_CALL) ? 25 : $conf->global->PARTNERSHIP_MAX_EXPIRATION_CANCEL_PER_CALL); // Limit to 25 per call - $langs->loadLangs(array("partnership", "member")); + $langs->loadLangs(array("partnership", "member")); - $error = 0; - $erroremail = ''; - $this->output = ''; - $this->error = ''; - $partnershipsprocessed = array(); + $error = 0; + $erroremail = ''; + $this->output = ''; + $this->error = ''; + $partnershipsprocessed = array(); - $gracedelay=$conf->global->PARTNERSHIP_NBDAYS_AFTER_MEMBER_EXPIRATION_BEFORE_CANCEL; - if ($gracedelay < 1) - { - $this->error='BadValueForDelayBeforeCancelCheckSetup'; - return -1; - } + $gracedelay=$conf->global->PARTNERSHIP_NBDAYS_AFTER_MEMBER_EXPIRATION_BEFORE_CANCEL; + if ($gracedelay < 1) { + $this->error='BadValueForDelayBeforeCancelCheckSetup'; + return -1; + } - dol_syslog(get_class($this)."::doCancelStatusOfMemberPartnership cancel expired partnerships with grace delay of ".$gracedelay); + dol_syslog(get_class($this)."::doCancelStatusOfMemberPartnership cancel expired partnerships with grace delay of ".$gracedelay); - $now = dol_now(); - $datetotest = dol_time_plus_duree($now, -1 * abs($gracedelay), 'd'); + $now = dol_now(); + $datetotest = dol_time_plus_duree($now, -1 * abs($gracedelay), 'd'); - $this->db->begin(); + $this->db->begin(); - $sql = "SELECT p.rowid, p.fk_member, p.status"; - $sql .= ", d.datefin, d.fk_adherent_type, dty.subscription"; - $sql .= " FROM ".MAIN_DB_PREFIX."partnership as p"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."adherent as d on (d.rowid = p.fk_member)"; + $sql = "SELECT p.rowid, p.fk_member, p.status"; + $sql .= ", d.datefin, d.fk_adherent_type, dty.subscription"; + $sql .= " FROM ".MAIN_DB_PREFIX."partnership as p"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."adherent as d on (d.rowid = p.fk_member)"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."adherent_type as dty on (dty.rowid = d.fk_adherent_type)"; $sql .= " WHERE fk_member > 0"; $sql .= " AND (d.datefin < '".$this->db->idate($datetotest)."' AND dty.subscription = 1)"; - $sql .= " AND p.status = ".$partnership::STATUS_ACCEPTED; // Only accepted not yet canceled - $sql .= $this->db->order('d.rowid','ASC'); - // Limit is managed into loop later + $sql .= " AND p.status = ".$partnership::STATUS_ACCEPTED; // Only accepted not yet canceled + $sql .= $this->db->order('d.rowid', 'ASC'); + // Limit is managed into loop later - $resql = $this->db->query($sql); - if ($resql) - { - $numofexpiredmembers = $this->db->num_rows($resql); + $resql = $this->db->query($sql); + if ($resql) { + $numofexpiredmembers = $this->db->num_rows($resql); - $somethingdoneonpartnership = 0; - $ifetchpartner = 0; - while ($ifetchpartner < $numofexpiredmembers) - { - $ifetchpartner++; + $somethingdoneonpartnership = 0; + $ifetchpartner = 0; + while ($ifetchpartner < $numofexpiredmembers) { + $ifetchpartner++; - $obj = $this->db->fetch_object($resql); - if ($obj) - { - if (! empty($partnershipsprocessed[$obj->rowid])) continue; + $obj = $this->db->fetch_object($resql); + if ($obj) { + if (! empty($partnershipsprocessed[$obj->rowid])) continue; - if ($somethingdoneonpartnership >= $MAXPERCALL) - { - dol_syslog("We reach the limit of ".$MAXPERCALL." partnership processed, so we quit loop for this batch doCancelStatusOfMemberPartnership to avoid to reach email quota.", LOG_WARNING); - break; - } + if ($somethingdoneonpartnership >= $MAXPERCALL) { + dol_syslog("We reach the limit of ".$MAXPERCALL." partnership processed, so we quit loop for this batch doCancelStatusOfMemberPartnership to avoid to reach email quota.", LOG_WARNING); + break; + } - $object = new Partnership($this->db); - $object->fetch($obj->rowid); + $object = new Partnership($this->db); + $object->fetch($obj->rowid); - // Get expiration date - $expirationdate = $obj->datefin; + // Get expiration date + $expirationdate = $obj->datefin; - if ($expirationdate && $expirationdate < $now) // If contract expired (we already had a test into main select, this is a security) - { - $somethingdoneonpartnership++; + if ($expirationdate && $expirationdate < $now) { // If contract expired (we already had a test into main select, this is a security) + $somethingdoneonpartnership++; - $result = $object->cancel($user, 0); - // $conf->global->noapachereload = null; - if ($result < 0) - { - $error++; - $this->error = $object->error; - if (is_array($object->errors) && count($object->errors)) { - if (is_array($this->errors)) $this->errors = array_merge($this->errors, $object->errors); - else $this->errors = $object->errors; - } - } - else - { - $partnershipsprocessed[$object->id]=$object->ref; + $result = $object->cancel($user, 0); + // $conf->global->noapachereload = null; + if ($result < 0) { + $error++; + $this->error = $object->error; + if (is_array($object->errors) && count($object->errors)) { + if (is_array($this->errors)) $this->errors = array_merge($this->errors, $object->errors); + else $this->errors = $object->errors; + } + } else { + $partnershipsprocessed[$object->id]=$object->ref; - // Send an email to inform member - $labeltemplate = '(SendingEmailOnPartnershipCanceled)'; + // Send an email to inform member + $labeltemplate = '(SendingEmailOnPartnershipCanceled)'; - dol_syslog("Now we will send an email to member id=".$object->fk_member." with label ".$labeltemplate); + dol_syslog("Now we will send an email to member id=".$object->fk_member." with label ".$labeltemplate); - // Send deployment email - include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; - include_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; - $formmail=new FormMail($this->db); + // Send deployment email + include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; + include_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; + $formmail=new FormMail($this->db); - // Define output language - $outputlangs = $langs; - $newlang = ''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id','aZ09')) $newlang = GETPOST('lang_id','aZ09'); - if (! empty($newlang)) { - $outputlangs = new Translate("", $conf); - $outputlangs->setDefaultLang($newlang); - $outputlangs->loadLangs(array('main','member','partnership')); - } + // Define output language + $outputlangs = $langs; + $newlang = ''; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); + if (! empty($newlang)) { + $outputlangs = new Translate("", $conf); + $outputlangs->setDefaultLang($newlang); + $outputlangs->loadLangs(array('main','member','partnership')); + } - $arraydefaultmessage=$formmail->getEMailTemplate($this->db, 'partnership_send', $user, $outputlangs, 0, 1, $labeltemplate); + $arraydefaultmessage=$formmail->getEMailTemplate($this->db, 'partnership_send', $user, $outputlangs, 0, 1, $labeltemplate); - $substitutionarray=getCommonSubstitutionArray($outputlangs, 0, null, $object); - complete_substitutions_array($substitutionarray, $outputlangs, $object); + $substitutionarray=getCommonSubstitutionArray($outputlangs, 0, null, $object); + complete_substitutions_array($substitutionarray, $outputlangs, $object); - $subject = make_substitutions($arraydefaultmessage->topic, $substitutionarray, $outputlangs); - $msg = make_substitutions($arraydefaultmessage->content, $substitutionarray, $outputlangs); - $from = dol_string_nospecial($conf->global->MAIN_INFO_SOCIETE_NOM, ' ', array(",")).' <'.$conf->global->MAIN_INFO_SOCIETE_MAIL.'>'; + $subject = make_substitutions($arraydefaultmessage->topic, $substitutionarray, $outputlangs); + $msg = make_substitutions($arraydefaultmessage->content, $substitutionarray, $outputlangs); + $from = dol_string_nospecial($conf->global->MAIN_INFO_SOCIETE_NOM, ' ', array(",")).' <'.$conf->global->MAIN_INFO_SOCIETE_MAIL.'>'; - $adherent = new Adherent($this->db); - $adherent->fetch($object->fk_member); - $to = $adherent->email; + $adherent = new Adherent($this->db); + $adherent->fetch($object->fk_member); + $to = $adherent->email; - $cmail = new CMailFile($subject, $to, $from, $msg, array(), array(), array(), '', '', 0, 1); - $result = $cmail->sendfile(); - if (! $result || $cmail->error) - { - $erroremail .= ($erroremail ? ', ' : '').$cmail->error; - $this->errors[] = $cmail->error; - if (is_array($cmail->errors) && count($cmail->errors) > 0) $this->errors += $cmail->errors; - } - } - - } - } - } - } - else - { - $error++; - $this->error = $this->db->lasterror(); - } + $cmail = new CMailFile($subject, $to, $from, $msg, array(), array(), array(), '', '', 0, 1); + $result = $cmail->sendfile(); + if (! $result || $cmail->error) { + $erroremail .= ($erroremail ? ', ' : '').$cmail->error; + $this->errors[] = $cmail->error; + if (is_array($cmail->errors) && count($cmail->errors) > 0) $this->errors += $cmail->errors; + } + } + } + } + } + } else { + $error++; + $this->error = $this->db->lasterror(); + } - if (! $error) - { - $this->db->commit(); - $this->output = $numofexpiredmembers.' expired partnership members found'."\n"; - if ($erroremail) $this->output.='. Got errors when sending some email : '.$erroremail; - } - else - { - $this->db->rollback(); - $this->output = "Rollback after error\n"; - $this->output.= $numofexpiredmembers.' expired partnership members found'."\n"; - if ($erroremail) $this->output.='. Got errors when sending some email : '.$erroremail; - } + if (! $error) { + $this->db->commit(); + $this->output = $numofexpiredmembers.' expired partnership members found'."\n"; + if ($erroremail) $this->output.='. Got errors when sending some email : '.$erroremail; + } else { + $this->db->rollback(); + $this->output = "Rollback after error\n"; + $this->output.= $numofexpiredmembers.' expired partnership members found'."\n"; + if ($erroremail) $this->output.='. Got errors when sending some email : '.$erroremail; + } - return ($error ? 1: 0); + return ($error ? 1: 0); } @@ -236,43 +220,42 @@ class PartnershipUtils { global $conf, $langs, $user; - $managedfor = $conf->global->PARTNERSHIP_IS_MANAGED_FOR; + $managedfor = $conf->global->PARTNERSHIP_IS_MANAGED_FOR; - $partnership = new Partnership($this->db); - $MAXPERCALL = (empty($conf->global->PARTNERSHIP_MAX_WARNING_BACKLINK_PER_CALL) ? 10 : $conf->global->PARTNERSHIP_MAX_WARNING_BACKLINK_PER_CALL); // Limit to 10 per call + $partnership = new Partnership($this->db); + $MAXPERCALL = (empty($conf->global->PARTNERSHIP_MAX_WARNING_BACKLINK_PER_CALL) ? 10 : $conf->global->PARTNERSHIP_MAX_WARNING_BACKLINK_PER_CALL); // Limit to 10 per call - $langs->loadLangs(array("partnership", "member")); + $langs->loadLangs(array("partnership", "member")); - $error = 0; - $erroremail = ''; - $this->output = ''; - $this->error = ''; - $partnershipsprocessed = array(); + $error = 0; + $erroremail = ''; + $this->output = ''; + $this->error = ''; + $partnershipsprocessed = array(); - $gracedelay=$conf->global->PARTNERSHIP_NBDAYS_AFTER_MEMBER_EXPIRATION_BEFORE_CANCEL; - if ($gracedelay < 1) - { - $this->error='BadValueForDelayBeforeCancelCheckSetup'; - return -1; - } + $gracedelay=$conf->global->PARTNERSHIP_NBDAYS_AFTER_MEMBER_EXPIRATION_BEFORE_CANCEL; + if ($gracedelay < 1) { + $this->error='BadValueForDelayBeforeCancelCheckSetup'; + return -1; + } - $fk_partner = ($managedfor == 'member') ? 'fk_member' : 'fk_soc'; + $fk_partner = ($managedfor == 'member') ? 'fk_member' : 'fk_soc'; - dol_syslog(get_class($this)."::doWarningOfPartnershipIfDolibarrBacklinkNotfound Warning of partnership"); + dol_syslog(get_class($this)."::doWarningOfPartnershipIfDolibarrBacklinkNotfound Warning of partnership"); - $now = dol_now(); - $datetotest = dol_time_plus_duree($now, -1 * abs($gracedelay), 'd'); + $now = dol_now(); + $datetotest = dol_time_plus_duree($now, -1 * abs($gracedelay), 'd'); - $this->db->begin(); + $this->db->begin(); - $sql = "SELECT p.rowid, p.status, p.".$fk_partner; - $sql .= ", p.last_check_backlink"; + $sql = "SELECT p.rowid, p.status, p.".$fk_partner; + $sql .= ", p.last_check_backlink"; - $sql .= ', partner.url, partner.email'; + $sql .= ', partner.url, partner.email'; - $sql .= " FROM ".MAIN_DB_PREFIX."partnership as p"; + $sql .= " FROM ".MAIN_DB_PREFIX."partnership as p"; - if ($managedfor == 'member') { + if ($managedfor == 'member') { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."adherent as partner on (partner.rowid = p.fk_member)"; } else { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as partner on (partner.rowid = p.fk_soc)"; @@ -280,147 +263,131 @@ class PartnershipUtils $sql .= " WHERE 1 = 1"; $sql .= " AND p.".$fk_partner." > 0"; - $sql .= " AND p.status = ".$partnership::STATUS_ACCEPTED; // Only accepted not yet canceled - $sql .= " AND (p.last_check_backlink IS NULL OR p.last_check_backlink <= '".$this->db->idate($now - 7 * 24 * 3600)."')"; // Every week, check that website contains a link to dolibarr. - $sql .= $this->db->order('p.rowid','ASC'); - // Limit is managed into loop later + $sql .= " AND p.status = ".$partnership::STATUS_ACCEPTED; // Only accepted not yet canceled + $sql .= " AND (p.last_check_backlink IS NULL OR p.last_check_backlink <= '".$this->db->idate($now - 7 * 24 * 3600)."')"; // Every week, check that website contains a link to dolibarr. + $sql .= $this->db->order('p.rowid', 'ASC'); + // Limit is managed into loop later - $resql = $this->db->query($sql); - if ($resql) - { - $numofexpiredmembers = $this->db->num_rows($resql); - $somethingdoneonpartnership = 0; - $ifetchpartner = 0; - while ($ifetchpartner < $numofexpiredmembers) - { - $ifetchpartner++; + $resql = $this->db->query($sql); + if ($resql) { + $numofexpiredmembers = $this->db->num_rows($resql); + $somethingdoneonpartnership = 0; + $ifetchpartner = 0; + while ($ifetchpartner < $numofexpiredmembers) { + $ifetchpartner++; - $obj = $this->db->fetch_object($resql); - if ($obj) - { - if (! empty($partnershipsprocessed[$obj->rowid])) continue; + $obj = $this->db->fetch_object($resql); + if ($obj) { + if (! empty($partnershipsprocessed[$obj->rowid])) continue; - if ($somethingdoneonpartnership >= $MAXPERCALL) - { - dol_syslog("We reach the limit of ".$MAXPERCALL." partnership processed, so we quit loop for this batch doWarningOfPartnershipIfDolibarrBacklinkNotfound to avoid to reach email quota.", LOG_WARNING); - break; - } + if ($somethingdoneonpartnership >= $MAXPERCALL) { + dol_syslog("We reach the limit of ".$MAXPERCALL." partnership processed, so we quit loop for this batch doWarningOfPartnershipIfDolibarrBacklinkNotfound to avoid to reach email quota.", LOG_WARNING); + break; + } - $backlinkfound = 0; + $backlinkfound = 0; - $object = new Partnership($this->db); - $object->fetch($obj->rowid); + $object = new Partnership($this->db); + $object->fetch($obj->rowid); - if($managedfor == 'member'){ - $fk_partner = $object->fk_member; - }else{ - $fk_partner = $object->fk_soc; - } + if ($managedfor == 'member') { + $fk_partner = $object->fk_member; + } else { + $fk_partner = $object->fk_soc; + } - $website = $obj->url; + $website = $obj->url; - if(empty($website)){ - $websitenotfound .= ($websitenotfound ? ', ' : '').'Website not found for id="'.$fk_partner.'"'."\n"; - } else { - $backlinkfound = $this->checkDolibarrBacklink($website); - } + if (empty($website)) { + $websitenotfound .= ($websitenotfound ? ', ' : '').'Website not found for id="'.$fk_partner.'"'."\n"; + } else { + $backlinkfound = $this->checkDolibarrBacklink($website); + } - if(!$backlinkfound){ - $tmpcount = $object->count_last_url_check_error + 1; + if (!$backlinkfound) { + $tmpcount = $object->count_last_url_check_error + 1; - if($tmpcount == 3){ // Send Warning Email + if ($tmpcount == 3) { // Send Warning Email + if (!empty($obj->email)) { + $emailnotfound .= ($emailnotfound ? ', ' : '').'Email not found for id="'.$fk_partner.'"'."\n"; + } else { + $labeltemplate = '(SendingEmailOnPartnershipWillExpire)'; - if (!empty($obj->email)){ - $emailnotfound .= ($emailnotfound ? ', ' : '').'Email not found for id="'.$fk_partner.'"'."\n"; + dol_syslog("Now we will send an email to partner id=".$fk_partner." with label ".$labeltemplate); - } else { + // Send deployment email + include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; + include_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; + $formmail=new FormMail($this->db); - $labeltemplate = '(SendingEmailOnPartnershipWillExpire)'; + // Define output language + $outputlangs = $langs; + $newlang = ''; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); + if (! empty($newlang)) { + $outputlangs = new Translate("", $conf); + $outputlangs->setDefaultLang($newlang); + $outputlangs->loadLangs(array('main','member','partnership')); + } - dol_syslog("Now we will send an email to partner id=".$fk_partner." with label ".$labeltemplate); + $arraydefaultmessage=$formmail->getEMailTemplate($this->db, 'partnership_send', $user, $outputlangs, 0, 1, $labeltemplate); - // Send deployment email - include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; - include_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; - $formmail=new FormMail($this->db); + $substitutionarray=getCommonSubstitutionArray($outputlangs, 0, null, $object); + complete_substitutions_array($substitutionarray, $outputlangs, $object); - // Define output language - $outputlangs = $langs; - $newlang = ''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id','aZ09')) $newlang = GETPOST('lang_id','aZ09'); - if (! empty($newlang)) { - $outputlangs = new Translate("", $conf); - $outputlangs->setDefaultLang($newlang); - $outputlangs->loadLangs(array('main','member','partnership')); - } + $subject = make_substitutions($arraydefaultmessage->topic, $substitutionarray, $outputlangs); + $msg = make_substitutions($arraydefaultmessage->content, $substitutionarray, $outputlangs); + $from = dol_string_nospecial($conf->global->MAIN_INFO_SOCIETE_NOM, ' ', array(",")).' <'.$conf->global->MAIN_INFO_SOCIETE_MAIL.'>'; - $arraydefaultmessage=$formmail->getEMailTemplate($this->db, 'partnership_send', $user, $outputlangs, 0, 1, $labeltemplate); + $to = $obj->email; - $substitutionarray=getCommonSubstitutionArray($outputlangs, 0, null, $object); - complete_substitutions_array($substitutionarray, $outputlangs, $object); + $cmail = new CMailFile($subject, $to, $from, $msg, array(), array(), array(), '', '', 0, 1); + $result = $cmail->sendfile(); + if (! $result || $cmail->error) { + $erroremail .= ($erroremail ? ', ' : '').$cmail->error; + $this->errors[] = $cmail->error; + if (is_array($cmail->errors) && count($cmail->errors) > 0) $this->errors += $cmail->errors; + } + } + } elseif ($tmpcount > 4) { // Cancel Partnership + $object->status = $object::STATUS_CANCELED; + $object->reason_decline_or_cancel = $langs->trans('BacklinkNotFoundOnPartnerWebsite'); + } - $subject = make_substitutions($arraydefaultmessage->topic, $substitutionarray, $outputlangs); - $msg = make_substitutions($arraydefaultmessage->content, $substitutionarray, $outputlangs); - $from = dol_string_nospecial($conf->global->MAIN_INFO_SOCIETE_NOM, ' ', array(",")).' <'.$conf->global->MAIN_INFO_SOCIETE_MAIL.'>'; + $object->count_last_url_check_error = $tmpcount; + } else { + $object->count_last_url_check_error = 0; + $object->reason_decline_or_cancel = ''; + } - $to = $obj->email; + $partnershipsprocessed[$object->id]=$object->ref; - $cmail = new CMailFile($subject, $to, $from, $msg, array(), array(), array(), '', '', 0, 1); - $result = $cmail->sendfile(); - if (! $result || $cmail->error) - { - $erroremail .= ($erroremail ? ', ' : '').$cmail->error; - $this->errors[] = $cmail->error; - if (is_array($cmail->errors) && count($cmail->errors) > 0) $this->errors += $cmail->errors; - } - } + $object->last_check_backlink = $this->db->idate($now); + $object->update($user); + } + } + } else { + $error++; + $this->error = $this->db->lasterror(); + } - } elseif($tmpcount > 4) { // Cancel Partnership - $object->status = $object::STATUS_CANCELED; - $object->reason_decline_or_cancel = $langs->trans('BacklinkNotFoundOnPartnerWebsite'); - } + if (! $error) { + $this->db->commit(); + $this->output = $numofexpiredmembers.' partnership checked'."\n"; + if ($erroremail) $this->output.='. Got errors when sending some email : '.$erroremail."\n"; + if ($emailnotfound) $this->output.='. Email not found for some partner : '.$emailnotfound."\n"; + if ($websitenotfound) $this->output.='. Website not found for some partner : '.$websitenotfound."\n"; + } else { + $this->db->rollback(); + $this->output = "Rollback after error\n"; + $this->output.= $numofexpiredmembers.' partnership checked'."\n"; + if ($erroremail) $this->output.='. Got errors when sending some email : '.$erroremail."\n"; + if ($emailnotfound) $this->output.='. Email not found for some partner : '.$emailnotfound."\n"; + if ($websitenotfound) $this->output.='. Website not found for some partner : '.$websitenotfound."\n"; + } - $object->count_last_url_check_error = $tmpcount; - - } else { - $object->count_last_url_check_error = 0; - $object->reason_decline_or_cancel = ''; - } - - $partnershipsprocessed[$object->id]=$object->ref; - - $object->last_check_backlink = $this->db->idate($now); - - $object->update($user); - } - } - } - else - { - $error++; - $this->error = $this->db->lasterror(); - } - - if (! $error) - { - $this->db->commit(); - $this->output = $numofexpiredmembers.' partnership checked'."\n"; - if ($erroremail) $this->output.='. Got errors when sending some email : '.$erroremail."\n"; - if ($emailnotfound) $this->output.='. Email not found for some partner : '.$emailnotfound."\n"; - if ($websitenotfound) $this->output.='. Website not found for some partner : '.$websitenotfound."\n"; - } - else - { - $this->db->rollback(); - $this->output = "Rollback after error\n"; - $this->output.= $numofexpiredmembers.' partnership checked'."\n"; - if ($erroremail) $this->output.='. Got errors when sending some email : '.$erroremail."\n"; - if ($emailnotfound) $this->output.='. Email not found for some partner : '.$emailnotfound."\n"; - if ($websitenotfound) $this->output.='. Website not found for some partner : '.$websitenotfound."\n"; - } - - return ($error ? 1: 0); + return ($error ? 1: 0); } /** @@ -439,8 +406,8 @@ class PartnershipUtils $webcontent = ''; // $website = 'https://nextgestion.com/'; // For Test - $tmpgeturl = getURLContent($website); - if ($tmpgeturl['curl_error_no']) { + $tmpgeturl = getURLContent($website); + if ($tmpgeturl['curl_error_no']) { $error++; dol_syslog('Error getting '.$website.': '.$tmpgeturl['curl_error_msg']); } elseif ($tmpgeturl['http_code'] != '200') { @@ -454,19 +421,18 @@ class PartnershipUtils $xpath = new DOMXPath($dom); $hrefs = $xpath->evaluate("//a"); - for($i = 0; $i < $hrefs->length; $i++){ - $href = $hrefs->item($i); - $url = $href->getAttribute('href'); - $url = filter_var($url, FILTER_SANITIZE_URL); - if(!filter_var($url, FILTER_VALIDATE_URL) === false){ - $webcontent .= $url; - } + for ($i = 0; $i < $hrefs->length; $i++) { + $href = $hrefs->item($i); + $url = $href->getAttribute('href'); + $url = filter_var($url, FILTER_SANITIZE_URL); + if (!filter_var($url, FILTER_VALIDATE_URL) === false) { + $webcontent .= $url; + } } - } - - if ($webcontent && !empty($conf->global->PARTNERSHIP_BACKLINKS_TO_CHECK) && preg_match('/'.$conf->global->PARTNERSHIP_BACKLINKS_TO_CHECK.'/', $webcontent)) - { - $found = 1; + } + + if ($webcontent && !empty($conf->global->PARTNERSHIP_BACKLINKS_TO_CHECK) && preg_match('/'.$conf->global->PARTNERSHIP_BACKLINKS_TO_CHECK.'/', $webcontent)) { + $found = 1; } return $found; From 701b53773b4e619d82d72a3224459241f4e7f29e Mon Sep 17 00:00:00 2001 From: Dorian Vabre Date: Mon, 19 Apr 2021 09:54:29 +0200 Subject: [PATCH 045/147] added description of the line in the invoice, problem with dates that are int --- htdocs/langs/en_US/eventorganization.lang | 1 + htdocs/public/eventorganization/attendee_subscription.php | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/langs/en_US/eventorganization.lang b/htdocs/langs/en_US/eventorganization.lang index f486a64dac1..037a74076fe 100644 --- a/htdocs/langs/en_US/eventorganization.lang +++ b/htdocs/langs/en_US/eventorganization.lang @@ -101,6 +101,7 @@ MissingOrBadSecureKey = The security key is invalid or missing EvntOrgWelcomeMessage = This form allows you to register as a new participant to the conference EvntOrgStartDuration = This conference starts on EvntOrgEndDuration = and ends on +ConferenceAttendeeFee = Conference attendee fee # # SubscriptionOk page # diff --git a/htdocs/public/eventorganization/attendee_subscription.php b/htdocs/public/eventorganization/attendee_subscription.php index 1121248e048..b477d644dc7 100644 --- a/htdocs/public/eventorganization/attendee_subscription.php +++ b/htdocs/public/eventorganization/attendee_subscription.php @@ -331,7 +331,7 @@ if (empty($reshook) && $action == 'add') { if (!$error) { // Add line to draft invoice $vattouse = get_default_tva($mysoc, $thirdparty, $productforinvoicerow->id); - $result = $facture->addline($label, floatval($project->price_registration), 1, $vattouse, 0, 0, $productforinvoicerow->id, 0, dol_now(), '', 0, 0, '', 'HT', 0, 1); + $result = $facture->addline($langs->trans("ConferenceAttendeeFee").' for the event : \''.$conference->label.'\' occuring from '.$conference->datep.' to '.$conference->datep2, floatval($project->price_registration), 1, $vattouse, 0, 0, $productforinvoicerow->id, 0, dol_now(), '', 0, 0, '', 'HT', 0, 1); if ($result <= 0) { $confattendee->error = $facture->error; $confattendee->errors = $facture->errors; From 0325f023680258309230b08f39833d54247da5ed Mon Sep 17 00:00:00 2001 From: Dorian Vabre Date: Mon, 19 Apr 2021 10:09:19 +0200 Subject: [PATCH 046/147] timestamp converted to get date of start and end on the invoice --- htdocs/public/eventorganization/attendee_subscription.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/public/eventorganization/attendee_subscription.php b/htdocs/public/eventorganization/attendee_subscription.php index b477d644dc7..9f3115e56f4 100644 --- a/htdocs/public/eventorganization/attendee_subscription.php +++ b/htdocs/public/eventorganization/attendee_subscription.php @@ -331,7 +331,7 @@ if (empty($reshook) && $action == 'add') { if (!$error) { // Add line to draft invoice $vattouse = get_default_tva($mysoc, $thirdparty, $productforinvoicerow->id); - $result = $facture->addline($langs->trans("ConferenceAttendeeFee").' for the event : \''.$conference->label.'\' occuring from '.$conference->datep.' to '.$conference->datep2, floatval($project->price_registration), 1, $vattouse, 0, 0, $productforinvoicerow->id, 0, dol_now(), '', 0, 0, '', 'HT', 0, 1); + $result = $facture->addline($langs->trans("ConferenceAttendeeFee").' for the event : \''.$conference->label.'\' occuring from '.dol_print_date($conference->datep, '%d/%m/%y %H:%M:%S').' to '.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); if ($result <= 0) { $confattendee->error = $facture->error; $confattendee->errors = $facture->errors; From a4eb4aa80258f3707c37f53071b075f983678cc4 Mon Sep 17 00:00:00 2001 From: NextGestion Date: Mon, 19 Apr 2021 10:08:35 +0100 Subject: [PATCH 047/147] Code optimisation. --- htdocs/partnership/class/partnershiputils.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/partnership/class/partnershiputils.class.php b/htdocs/partnership/class/partnershiputils.class.php index 05a76ae19d2..f3f398e0676 100644 --- a/htdocs/partnership/class/partnershiputils.class.php +++ b/htdocs/partnership/class/partnershiputils.class.php @@ -307,7 +307,7 @@ class PartnershipUtils if (!$backlinkfound) { $tmpcount = $object->count_last_url_check_error + 1; - if ($tmpcount == 3) { // Send Warning Email + if ($tmpcount > 2 && $tmpcount <= 4) { // Send Warning Email if (!empty($obj->email)) { $emailnotfound .= ($emailnotfound ? ', ' : '').'Email not found for id="'.$fk_partner.'"'."\n"; } else { From 263e110ca3aebbb74f1430211479335465c23348 Mon Sep 17 00:00:00 2001 From: NextGestion Date: Mon, 19 Apr 2021 13:19:32 +0100 Subject: [PATCH 048/147] Enhance module Member --- htdocs/adherents/admin/member.php | 6 +++++ htdocs/adherents/list.php | 39 +++++++++++++++++++++++++++++ htdocs/core/lib/functions.lib.php | 2 ++ htdocs/langs/en_US/admin.lang | 1 + htdocs/langs/en_US/main.lang | 1 + htdocs/langs/en_US/members.lang | 1 + htdocs/public/payment/paymentok.php | 21 ++++++++++++++++ 7 files changed, 71 insertions(+) diff --git a/htdocs/adherents/admin/member.php b/htdocs/adherents/admin/member.php index 62291791fc5..b3c7646689b 100644 --- a/htdocs/adherents/admin/member.php +++ b/htdocs/adherents/admin/member.php @@ -107,6 +107,7 @@ if ($action == 'set_default') { $res1 = dolibarr_set_const($db, 'ADHERENT_LOGIN_NOT_REQUIRED', GETPOST('ADHERENT_LOGIN_NOT_REQUIRED', 'alpha') ? 0 : 1, 'chaine', 0, '', $conf->entity); $res2 = dolibarr_set_const($db, 'ADHERENT_MAIL_REQUIRED', GETPOST('ADHERENT_MAIL_REQUIRED', 'alpha'), 'chaine', 0, '', $conf->entity); $res3 = dolibarr_set_const($db, 'ADHERENT_DEFAULT_SENDINFOBYMAIL', GETPOST('ADHERENT_DEFAULT_SENDINFOBYMAIL', 'alpha'), 'chaine', 0, '', $conf->entity); + $res3 = dolibarr_set_const($db, 'ADHERENT_CREATE_EXTERNAL_USER_LOGIN', GETPOST('ADHERENT_CREATE_EXTERNAL_USER_LOGIN', 'alpha'), 'chaine', 0, '', $conf->entity); $res4 = dolibarr_set_const($db, 'ADHERENT_BANK_USE', GETPOST('ADHERENT_BANK_USE', 'alpha'), 'chaine', 0, '', $conf->entity); // Use vat for invoice creation if ($conf->facture->enabled) { @@ -219,6 +220,11 @@ print ''.$langs->trans("MemberSendInformationByMailByDef print $form->selectyesno('ADHERENT_DEFAULT_SENDINFOBYMAIL', (!empty($conf->global->ADHERENT_DEFAULT_SENDINFOBYMAIL) ? $conf->global->ADHERENT_DEFAULT_SENDINFOBYMAIL : 0), 1); print "\n"; +// Create an external user login for each new member subscription validated +print ''.$langs->trans("MemberCreateAnExternalUserForSubscriptionValidated").''; +print $form->selectyesno('ADHERENT_CREATE_EXTERNAL_USER_LOGIN', (!empty($conf->global->ADHERENT_CREATE_EXTERNAL_USER_LOGIN) ? $conf->global->ADHERENT_CREATE_EXTERNAL_USER_LOGIN : 0), 1); +print "\n"; + // Insert subscription into bank account print ''.$langs->trans("MoreActionsOnSubscription").''; $arraychoices = array('0'=>$langs->trans("None")); diff --git a/htdocs/adherents/list.php b/htdocs/adherents/list.php index 9560a284e2a..5dd0e1e5d74 100644 --- a/htdocs/adherents/list.php +++ b/htdocs/adherents/list.php @@ -247,6 +247,42 @@ if (empty($reshook)) { } } + // Create external user + if ($massaction == 'createexternaluser' && $user->rights->adherent->creer && $user->rights->user->user->creer) { + $tmpmember = new Adherent($db); + $error = 0; + $nbcreated = 0; + + $db->begin(); + + foreach ($toselect as $idtoclose) { + $tmpmember->fetch($idtoclose); + + if(!empty($tmpmember->fk_soc)){ + $nuser = new User($db); + $tmpuser = dol_clone($tmpmember); + + $result = $nuser->create_from_member($tmpuser, $tmpmember->login); + + if ($result < 0 && !count($tmpmember->errors)) { + setEventMessages($tmpmember->error, $tmpmember->errors, 'errors'); + } else { + if ($result > 0) { + $nbcreated++; + } + } + } + } + + if (!$error) { + setEventMessages($langs->trans("XExternalUserCreated", $nbcreated), null, 'mesgs'); + + $db->commit(); + } else { + $db->rollback(); + } + } + // Mass actions $objectclass = 'Adherent'; $objectlabel = 'Members'; @@ -555,6 +591,9 @@ if ($user->rights->adherent->supprimer) { if ($user->rights->societe->creer) { $arrayofmassactions['preaffecttag'] = img_picto('', 'category', 'class="pictofixedwidth"').$langs->trans("AffectTag"); } +if ($user->rights->adherent->creer && $user->rights->user->user->creer) { + $arrayofmassactions['createexternaluser'] = img_picto('', 'user', 'class="pictofixedwidth"').$langs->trans("CreateExternalUser"); +} if (in_array($massaction, array('presend', 'predelete','preaffecttag'))) { $arrayofmassactions = array(); } diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 2b981530834..7f2d7eff7a8 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -6835,6 +6835,7 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null, $substitutionarray['__MEMBER_CIVILITY__'] = '__MEMBER_CIVILITY__'; $substitutionarray['__MEMBER_FIRSTNAME__'] = '__MEMBER_FIRSTNAME__'; $substitutionarray['__MEMBER_LASTNAME__'] = '__MEMBER_LASTNAME__'; + $substitutionarray['__MEMBER_USER_LOGIN_INFORMATION__'] = 'Login and pass of the external user account'; /*$substitutionarray['__MEMBER_NOTE_PUBLIC__'] = '__MEMBER_NOTE_PUBLIC__'; $substitutionarray['__MEMBER_NOTE_PRIVATE__'] = '__MEMBER_NOTE_PRIVATE__';*/ } @@ -6910,6 +6911,7 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null, } $substitutionarray['__MEMBER_FIRSTNAME__'] = (isset($object->firstname) ? $object->firstname : ''); $substitutionarray['__MEMBER_LASTNAME__'] = (isset($object->lastname) ? $object->lastname : ''); + $substitutionarray['__MEMBER_USER_LOGIN_INFORMATION__'] = ''; if (method_exists($object, 'getFullName')) { $substitutionarray['__MEMBER_FULLNAME__'] = $object->getFullName($outputlangs); } diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index b103d0082ba..7a35efb30e1 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -1431,6 +1431,7 @@ MemberMainOptions=Main options AdherentLoginRequired= Manage a Login for each member AdherentMailRequired=Email required to create a new member MemberSendInformationByMailByDefault=Checkbox to send mail confirmation to members (validation or new subscription) is on by default +MemberCreateAnExternalUserForSubscriptionValidated=Create an external user login for each new member subscription validated VisitorCanChooseItsPaymentMode=Visitor can choose from available payment modes MEMBER_REMINDER_EMAIL=Enable automatic reminder by email of expired subscriptions. Note: Module %s must be enabled and correctly setup to send reminders. MembersDocModules=Document templates for documents generated from member record diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index 51d4d99bd8c..4dca585538a 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -1125,6 +1125,7 @@ UpdateForAllLines=Update for all lines OnHold=On hold Civility=Civility AffectTag=Affect Tag +CreateExternalUser=Create external user ConfirmAffectTag=Bulk Tag Affect ConfirmAffectTagQuestion=Are you sure you want to affect tags to the %s selected record(s)? CategTypeNotFound=No tag type found for type of records diff --git a/htdocs/langs/en_US/members.lang b/htdocs/langs/en_US/members.lang index 2ab2fb87270..52bc295c974 100644 --- a/htdocs/langs/en_US/members.lang +++ b/htdocs/langs/en_US/members.lang @@ -213,3 +213,4 @@ SendReminderForExpiredSubscription=Send reminder by email to members when subscr MembershipPaid=Membership paid for current period (until %s) YouMayFindYourInvoiceInThisEmail=You may find your invoice attached to this email XMembersClosed=%s member(s) closed +XExternalUserCreated=%s external user(s) created diff --git a/htdocs/public/payment/paymentok.php b/htdocs/public/payment/paymentok.php index 1942635001f..d61bb4d20d1 100644 --- a/htdocs/public/payment/paymentok.php +++ b/htdocs/public/payment/paymentok.php @@ -623,6 +623,27 @@ if ($ispaymentok) { } $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object); + + // Create external user + if(!empty($conf->global->ADHERENT_CREATE_EXTERNAL_USER_LOGIN)){ + $infouserlogin = ''; + $nuser = new User($db); + $tmpuser = dol_clone($object); + + $result = $nuser->create_from_member($tmpuser, $object->login); + $newpassword = $nuser->setPassword($user, ''); + + if ($result < 0) { + $outputlangs->load("errors"); + $postactionmessages[] = 'Error in create external user : '.$nuser->error; + } else { + $infouserlogin .= $outputlangs->trans("Login").': '.$nuser->login."
"."\n"; + $infouserlogin .= $outputlangs->trans("Password").': '.$newpassword; + $postactionmessages[] = $langs->trans("NewUserCreated", $nuser->login); + } + $substitutionarray['__MEMBER_USER_LOGIN_INFORMATION__'] = $infouserlogin; + } + complete_substitutions_array($substitutionarray, $outputlangs, $object); $subjecttosend = make_substitutions($subject, $substitutionarray, $outputlangs); $texttosend = make_substitutions(dol_concatdesc($msg, $adht->getMailOnSubscription()), $substitutionarray, $outputlangs); From 6f32b2edda76e1bffd51c47294562a2ae4dbbfc9 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Mon, 19 Apr 2021 13:23:36 +0000 Subject: [PATCH 049/147] Fixing style errors. --- htdocs/adherents/list.php | 2 +- htdocs/public/payment/paymentok.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/adherents/list.php b/htdocs/adherents/list.php index 5dd0e1e5d74..ef32b64e513 100644 --- a/htdocs/adherents/list.php +++ b/htdocs/adherents/list.php @@ -258,7 +258,7 @@ if (empty($reshook)) { foreach ($toselect as $idtoclose) { $tmpmember->fetch($idtoclose); - if(!empty($tmpmember->fk_soc)){ + if (!empty($tmpmember->fk_soc)) { $nuser = new User($db); $tmpuser = dol_clone($tmpmember); diff --git a/htdocs/public/payment/paymentok.php b/htdocs/public/payment/paymentok.php index d61bb4d20d1..c0eb195199e 100644 --- a/htdocs/public/payment/paymentok.php +++ b/htdocs/public/payment/paymentok.php @@ -625,11 +625,11 @@ if ($ispaymentok) { $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object); // Create external user - if(!empty($conf->global->ADHERENT_CREATE_EXTERNAL_USER_LOGIN)){ + if (!empty($conf->global->ADHERENT_CREATE_EXTERNAL_USER_LOGIN)) { $infouserlogin = ''; $nuser = new User($db); $tmpuser = dol_clone($object); - + $result = $nuser->create_from_member($tmpuser, $object->login); $newpassword = $nuser->setPassword($user, ''); From f396160bb867562c620d551253b71e63449d080b Mon Sep 17 00:00:00 2001 From: NextGestion Date: Mon, 19 Apr 2021 13:39:50 +0100 Subject: [PATCH 050/147] Fixing error. --- htdocs/public/payment/paymentok.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/public/payment/paymentok.php b/htdocs/public/payment/paymentok.php index c0eb195199e..bdafc704f30 100644 --- a/htdocs/public/payment/paymentok.php +++ b/htdocs/public/payment/paymentok.php @@ -637,7 +637,7 @@ if ($ispaymentok) { $outputlangs->load("errors"); $postactionmessages[] = 'Error in create external user : '.$nuser->error; } else { - $infouserlogin .= $outputlangs->trans("Login").': '.$nuser->login."
"."\n"; + $infouserlogin = $outputlangs->trans("Login").': '.$nuser->login."
"."\n"; $infouserlogin .= $outputlangs->trans("Password").': '.$newpassword; $postactionmessages[] = $langs->trans("NewUserCreated", $nuser->login); } From ea97cf5bafdf6d7312f5039733d3de23706c4698 Mon Sep 17 00:00:00 2001 From: NextGestion Date: Mon, 19 Apr 2021 13:46:21 +0100 Subject: [PATCH 051/147] Change translate file --- htdocs/langs/en_US/partnership.lang | 2 +- htdocs/public/payment/paymentok.php | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/htdocs/langs/en_US/partnership.lang b/htdocs/langs/en_US/partnership.lang index 2da278dd36c..ab51d2136e0 100644 --- a/htdocs/langs/en_US/partnership.lang +++ b/htdocs/langs/en_US/partnership.lang @@ -35,7 +35,7 @@ PartnershipAboutPage=Partnership about page partnershipforthirdpartyormember=Partnership is for a 'thirdparty' or for a 'member' PARTNERSHIP_IS_MANAGED_FOR=Partnership managed for PARTNERSHIP_BACKLINKS_TO_CHECK=Backlinks to check -PARTNERSHIP_NBDAYS_AFTER_MEMBER_EXPIRATION_BEFORE_CANCEL=Nb of days before cancel status of partnership +PARTNERSHIP_NBDAYS_AFTER_MEMBER_EXPIRATION_BEFORE_CANCEL=Nb of days before cancel status of partnership when subscription is expired # # Object diff --git a/htdocs/public/payment/paymentok.php b/htdocs/public/payment/paymentok.php index bdafc704f30..aeb27dc5a55 100644 --- a/htdocs/public/payment/paymentok.php +++ b/htdocs/public/payment/paymentok.php @@ -637,8 +637,7 @@ if ($ispaymentok) { $outputlangs->load("errors"); $postactionmessages[] = 'Error in create external user : '.$nuser->error; } else { - $infouserlogin = $outputlangs->trans("Login").': '.$nuser->login."
"."\n"; - $infouserlogin .= $outputlangs->trans("Password").': '.$newpassword; + $infouserlogin = $outputlangs->trans("Login").': '.$nuser->login."
"."\n".$outputlangs->trans("Password").': '.$newpassword; $postactionmessages[] = $langs->trans("NewUserCreated", $nuser->login); } $substitutionarray['__MEMBER_USER_LOGIN_INFORMATION__'] = $infouserlogin; From da0067ff6c8043042e790a279131e55ddc4f76b2 Mon Sep 17 00:00:00 2001 From: NextGestion Date: Mon, 19 Apr 2021 13:51:50 +0100 Subject: [PATCH 052/147] Fixing error --- htdocs/public/payment/paymentok.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/public/payment/paymentok.php b/htdocs/public/payment/paymentok.php index aeb27dc5a55..e97b9bd073f 100644 --- a/htdocs/public/payment/paymentok.php +++ b/htdocs/public/payment/paymentok.php @@ -637,7 +637,7 @@ if ($ispaymentok) { $outputlangs->load("errors"); $postactionmessages[] = 'Error in create external user : '.$nuser->error; } else { - $infouserlogin = $outputlangs->trans("Login").': '.$nuser->login."
"."\n".$outputlangs->trans("Password").': '.$newpassword; + $infouserlogin = $outputlangs->trans("Login").': '.$nuser->login.' '."\n".$outputlangs->trans("Password").': '.$newpassword; $postactionmessages[] = $langs->trans("NewUserCreated", $nuser->login); } $substitutionarray['__MEMBER_USER_LOGIN_INFORMATION__'] = $infouserlogin; From 8a43dac46d51c691b9208c4580aa05fbd1937ef7 Mon Sep 17 00:00:00 2001 From: Dorian Vabre Date: Mon, 19 Apr 2021 15:21:16 +0200 Subject: [PATCH 053/147] now giving the invoice id to the payment validation page so it can validate the payment --- htdocs/public/payment/newpayment.php | 6 ++--- htdocs/public/payment/paymentok.php | 33 +++++++++++++++++++++++----- 2 files changed, 30 insertions(+), 9 deletions(-) diff --git a/htdocs/public/payment/newpayment.php b/htdocs/public/payment/newpayment.php index d03f004f317..75d72b4bbea 100644 --- a/htdocs/public/payment/newpayment.php +++ b/htdocs/public/payment/newpayment.php @@ -363,7 +363,7 @@ if ($action == 'dopayment') { // A redirect is added if API call successfull if ($source == 'conferencesubscription') { - $PAYPAL_API_OK .= '&conferencesubscription='.dol_encode('subscriptionok'.$ref, $dolibarr_main_instance_unique_id); + $PAYPAL_API_OK .= '&conferencesubscription='.dol_encode('subscriptionok'.$ref, $dolibarr_main_instance_unique_id).'&invoice='.dol_encode($invoice->id, $dolibarr_main_instance_unique_id); } $mesg = print_paypal_redirect($PAYPAL_API_PRICE, $PAYPAL_API_DEVISE, $PAYPAL_PAYMENT_TYPE, $PAYPAL_API_OK, $PAYPAL_API_KO, $FULLTAG); @@ -384,7 +384,7 @@ if ($action == 'dopayment') { $urlko = preg_replace('/securekey=[^&]+/', '', $urlko); if ($source == 'conferencesubscription') { - $urlok .= '&conferencesubscription='.dol_encode('subscriptionok'.$ref, $dolibarr_main_instance_unique_id); + $urlok .= '&conferencesubscription='.dol_encode('subscriptionok'.$ref, $dolibarr_main_instance_unique_id).'&invoice='.dol_encode($invoice->id, $dolibarr_main_instance_unique_id); } $mesg = ''; @@ -742,7 +742,7 @@ if ($action == 'charge' && !empty($conf->stripe->enabled)) { exit; } else { if ($source == 'conferencesubscription') { - $urlok .= '&conferencesubscription='.dol_encode('subscriptionok'.$ref, $dolibarr_main_instance_unique_id); + $urlok .= '&conferencesubscription='.dol_encode('subscriptionok'.$ref, $dolibarr_main_instance_unique_id).'&invoice='.dol_encode($invoice->id, $dolibarr_main_instance_unique_id); } header("Location: ".$urlok); exit; diff --git a/htdocs/public/payment/paymentok.php b/htdocs/public/payment/paymentok.php index 7e11944c243..d9cfdc28b69 100644 --- a/htdocs/public/payment/paymentok.php +++ b/htdocs/public/payment/paymentok.php @@ -103,6 +103,7 @@ if (empty($FULLTAG)) { } $source = GETPOST('s', 'alpha') ? GETPOST('s', 'alpha') : GETPOST('source', 'alpha'); $ref = GETPOST('ref'); +$invoiceref = GETPOST('invoice'); $suffix = GETPOST("suffix", 'aZ09'); $membertypeid = GETPOST("membertypeid", 'int'); @@ -112,15 +113,35 @@ $uncryptedconferencesubscription = dol_decode($conferencesubscription, $dolibarr $subscription = substr($uncryptedconferencesubscription, 0, strlen($uncryptedconferencesubscription)-strlen($ref)); $reffrompayment = substr($uncryptedconferencesubscription, -strlen($ref), strlen($ref)); -// Validation of an attendee after his payment +// After a conference attendee payment if ($subscription == 'subscriptionok' && $ref == $reffrompayment) { - $attendeetovalidate = new ConferenceOrBoothAttendee($db); - $resultattendee = $attendeetovalidate->fetch($ref); - if ($resultattendee < 0) { - setEventMessages(null, $attendeetovalidate->errors, "errors"); + // Looking for the invoice to which add a payment + $paidinvoice = new Facture($db); + $resultinvoice = $paidinvoice->fetch($invoiceref); + if ($resultinvoice < 0) { + setEventMessages(null, $paidinvoice->errors, "errors"); } else { - $attendeetovalidate->setStatut(1); + // Creation of payment line + $paiement = new Paiement($db); + $paiement->datepaye = dol_now(); + $paiement->amounts = $amounts; // Array with all payments dispatching with invoice id + $paiement->multicurrency_amounts = $multicurrency_amounts; // Array with all payments dispatching + $paiement->paiementid = dol_getIdFromCode($db, GETPOST('paiementcode'), 'c_paiement', 'code', 'id', 1); + $paiement->num_payment = GETPOST('num_paiement', 'alpha'); + $paiement->note_private = GETPOST('comment', 'alpha'); + + // Validating the attendee + $attendeetovalidate = new ConferenceOrBoothAttendee($db); + $resultattendee = $attendeetovalidate->fetch($ref); + if ($resultattendee < 0) { + setEventMessages(null, $attendeetovalidate->errors, "errors"); + } else { + $attendeetovalidate->setStatut(1); + } } + + + } // Detect $paymentmethod From 9a325269385005ec73aff5f15c759d159723ba4a Mon Sep 17 00:00:00 2001 From: Dorian Vabre Date: Mon, 19 Apr 2021 15:49:51 +0200 Subject: [PATCH 054/147] added space for the link to the conference/booth registration page --- htdocs/eventorganization/conferenceorbooth_list.php | 11 +++++++++++ htdocs/langs/en_US/eventorganization.lang | 3 ++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/htdocs/eventorganization/conferenceorbooth_list.php b/htdocs/eventorganization/conferenceorbooth_list.php index 814a61ae894..feb202de663 100644 --- a/htdocs/eventorganization/conferenceorbooth_list.php +++ b/htdocs/eventorganization/conferenceorbooth_list.php @@ -39,6 +39,8 @@ if ($conf->categorie->enabled) { // Load translation files required by the page $langs->loadLangs(array("eventorganization", "other")); +global $dolibarr_main_url_root, $dolibarr_main_instance_unique_id; + $action = GETPOST('action', 'aZ09') ?GETPOST('action', 'aZ09') : 'view'; // The action 'add', 'create', 'edit', 'update', 'view', ... $massaction = GETPOST('massaction', 'alpha'); // The bulk action (combo box choice into lists) $show_files = GETPOST('show_files', 'int'); // Show files area generated by bulk actions ? @@ -360,6 +362,15 @@ if ($projectid > 0) { } print ''; + // Link to the vote/register page + print ''.$langs->trans("RegisterPage").''; + $encodedid = dol_encode($project->id, $dolibarr_main_instance_unique_id); + $linkregister = $dolibarr_main_url_root.'/public/project/index.php?id='.$encodedid; + $encodedsecurekey = dol_encode($conf->global->EVENTORGANIZATION_SECUREKEY.$encodedid, $dolibarr_main_instance_unique_id); + $linkregister .= '&securekey='.urlencode($encodedsecurekey); + print ''.$linkregister.''; + print ''; + // Other attributes $cols = 2; $objectconf=$object; diff --git a/htdocs/langs/en_US/eventorganization.lang b/htdocs/langs/en_US/eventorganization.lang index 037a74076fe..157fc1c8a99 100644 --- a/htdocs/langs/en_US/eventorganization.lang +++ b/htdocs/langs/en_US/eventorganization.lang @@ -96,6 +96,7 @@ EvntOrgCancelled = Cancelled # # Public page # +RegisterPage = Page for conferences or booth PublicAttendeeSubscriptionPage = Public link of registration to a conference MissingOrBadSecureKey = The security key is invalid or missing EvntOrgWelcomeMessage = This form allows you to register as a new participant to the conference @@ -110,4 +111,4 @@ SubscriptionOk = Your subscription to this conference has been validated # Payment page # Attendee = Participant -PaymentConferenceAttendee = Paiement de participation à une conférence \ No newline at end of file +PaymentConferenceAttendee = Paiement de participation à une conférence From 1b947a6e9a0e525e7d440b97b4b1bf1cb7463356 Mon Sep 17 00:00:00 2001 From: Dorian Vabre Date: Mon, 19 Apr 2021 16:17:11 +0200 Subject: [PATCH 055/147] added index page for the booth/conference registration --- htdocs/public/project/index.php | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 htdocs/public/project/index.php diff --git a/htdocs/public/project/index.php b/htdocs/public/project/index.php new file mode 100644 index 00000000000..e69de29bb2d From 7cab4dd19d4990a8d8b2f1a0efee81a0cee8f814 Mon Sep 17 00:00:00 2001 From: NextGestion Date: Mon, 19 Apr 2021 15:17:57 +0100 Subject: [PATCH 056/147] Manage partnership for members & code optimisation --- htdocs/adherents/partnership.php | 558 ++++++++++++++++++ htdocs/core/modules/modPartnership.class.php | 2 +- .../install/mysql/migration/13.0.0-14.0.0.sql | 2 +- htdocs/langs/en_US/partnership.lang | 8 +- .../partnership/class/partnership.class.php | 2 +- .../class/partnershiputils.class.php | 2 +- htdocs/societe/partnership.php | 6 +- 7 files changed, 570 insertions(+), 10 deletions(-) create mode 100644 htdocs/adherents/partnership.php diff --git a/htdocs/adherents/partnership.php b/htdocs/adherents/partnership.php new file mode 100644 index 00000000000..3cd70de3228 --- /dev/null +++ b/htdocs/adherents/partnership.php @@ -0,0 +1,558 @@ + + * Copyright (C) 2021 NextGestion + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file partnership_card.php + * \ingroup partnership + * \brief Page to create/edit/view partnership + */ + +//if (! defined('NOREQUIREDB')) define('NOREQUIREDB', '1'); // Do not create database handler $db +//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER', '1'); // Do not load object $user +//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); // Do not load object $mysoc +//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN', '1'); // Do not load object $langs +//if (! defined('NOSCANGETFORINJECTION')) define('NOSCANGETFORINJECTION', '1'); // Do not check injection attack on GET parameters +//if (! defined('NOSCANPOSTFORINJECTION')) define('NOSCANPOSTFORINJECTION', '1'); // Do not check injection attack on POST parameters +//if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK', '1'); // Do not check CSRF attack (test on referer + on token if option MAIN_SECURITY_CSRF_WITH_TOKEN is on). +//if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Do not roll the Anti CSRF token (used if MAIN_SECURITY_CSRF_WITH_TOKEN is on) +//if (! defined('NOSTYLECHECK')) define('NOSTYLECHECK', '1'); // Do not check style html tag into posted data +//if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); // If there is no need to load and show top and left menu +//if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); // If we don't need to load the html.form.class.php +//if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); // Do not load ajax.lib.php library +//if (! defined("NOLOGIN")) define("NOLOGIN", '1'); // If this page is public (can be called outside logged session). This include the NOIPCHECK too. +//if (! defined('NOIPCHECK')) define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip +//if (! defined("MAIN_LANG_DEFAULT")) define('MAIN_LANG_DEFAULT', 'auto'); // Force lang to a particular value +//if (! defined("MAIN_AUTHENTICATION_MODE")) define('MAIN_AUTHENTICATION_MODE', 'aloginmodule'); // Force authentication handler +//if (! defined("NOREDIRECTBYMAINTOLOGIN")) define('NOREDIRECTBYMAINTOLOGIN', 1); // The main.inc.php does not make a redirect if not logged, instead show simple error message +//if (! defined("FORCECSP")) define('FORCECSP', 'none'); // Disable all Content Security Policies +//if (! defined('CSRFCHECK_WITH_TOKEN')) define('CSRFCHECK_WITH_TOKEN', '1'); // Force use of CSRF protection with tokens even for GET +//if (! defined('NOBROWSERNOTIF')) define('NOBROWSERNOTIF', '1'); // Disable browser notification + +// Load Dolibarr environment +$res = 0; +// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) +if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) { + $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; +} +// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME +$tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1; +while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { + $i--; $j--; +} +if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) { + $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php"; +} +if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) { + $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php"; +} +// Try main.inc.php using relative path +if (!$res && file_exists("../main.inc.php")) { + $res = @include "../main.inc.php"; +} +if (!$res && file_exists("../../main.inc.php")) { + $res = @include "../../main.inc.php"; +} +if (!$res && file_exists("../../../main.inc.php")) { + $res = @include "../../../main.inc.php"; +} +if (!$res) { + die("Include of main fails"); +} + +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/member.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; +require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php'; +dol_include_once('/partnership/class/partnership.class.php'); +dol_include_once('/partnership/lib/partnership.lib.php'); + +// Load translation files required by the page +$langs->loadLangs(array("companies","members","partnership", "other")); + +// Get parameters +$id = GETPOST('id', 'int'); +$memberid = GETPOST('rowid', 'int'); +$ref = GETPOST('ref', 'alpha'); +$action = GETPOST('action', 'aZ09'); +$confirm = GETPOST('confirm', 'alpha'); +$cancel = GETPOST('cancel', 'aZ09'); +$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'partnershipcard'; // To manage different context of search +$backtopage = GETPOST('backtopage', 'alpha'); +$backtopageforcancel = GETPOST('backtopageforcancel', 'alpha'); +//$lineid = GETPOST('lineid', 'int'); + +$member = new Adherent($db); +if ($memberid > 0) { + $member->fetch($memberid); +} + +// Initialize technical objects +$object = new Partnership($db); +$extrafields = new ExtraFields($db); +$adht = new AdherentType($db); +$diroutputmassaction = $conf->partnership->dir_output.'/temp/massgeneration/'.$user->id; +$hookmanager->initHooks(array('partnershipthirdparty', 'globalcard')); // Note that conf->hooks_modules contains array + +// Fetch optionals attributes and labels +$extrafields->fetch_name_optionals_label($object->table_element); + +$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); + +// Initialize array of search criterias +$search_all = GETPOST("search_all", 'alpha'); +$search = array(); + +foreach ($object->fields as $key => $val) { + if (GETPOST('search_'.$key, 'alpha')) { + $search[$key] = GETPOST('search_'.$key, 'alpha'); + } +} + +// Load object +include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once. + +$permissiontoread = $user->rights->partnership->read; +$permissiontoadd = $user->rights->partnership->write; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php +$permissiontodelete = $user->rights->partnership->delete || ($permissiontoadd && isset($object->status) && $object->status == $object::STATUS_DRAFT); +$permissionnote = $user->rights->partnership->write; // Used by the include of actions_setnotes.inc.php +$permissiondellink = $user->rights->partnership->write; // Used by the include of actions_dellink.inc.php +$usercanclose = $user->rights->partnership->write; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php +$upload_dir = $conf->partnership->multidir_output[isset($object->entity) ? $object->entity : 1]; + + +if ($conf->global->PARTNERSHIP_IS_MANAGED_FOR != 'member') accessforbidden(); +if (empty($conf->partnership->enabled)) accessforbidden(); +if (empty($permissiontoread)) accessforbidden(); +if ($action == 'edit' && empty($permissiontoadd)) accessforbidden(); + +$partnershipid = $object->fetch(0, "", $memberid); +if (empty($action) && empty($partnershipid)) { + $action = 'create'; +} +if (($action == 'update' || $action == 'edit') && $object->status != $object::STATUS_DRAFT) accessforbidden(); + +if (empty($memberid) && $object) { + $memberid = $object->fk_member; +} +/* + * Actions + */ + +$parameters = array(); +$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks +if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +} + +$date_start = dol_mktime(0, 0, 0, GETPOST('date_partnership_startmonth', 'int'), GETPOST('date_partnership_startday', 'int'), GETPOST('date_partnership_startyear', 'int')); +$date_end = dol_mktime(0, 0, 0, GETPOST('date_partnership_endmonth', 'int'), GETPOST('date_partnership_endday', 'int'), GETPOST('date_partnership_endyear', 'int')); + +if (empty($reshook)) { + $error = 0; + + $backtopage = dol_buildpath('/partnership/partnership.php', 1).'?rowid='.($memberid > 0 ? $memberid : '__ID__'); + + $triggermodname = 'PARTNERSHIP_MODIFY'; // Name of trigger action code to execute when we modify record + + if ($action == 'add' && $permissiontoread) { + $error = 0; + + $db->begin(); + + $now = dol_now(); + + if (!$error) { + $old_start_date = $object->date_partnership_start; + + $object->fk_member = $memberid; + $object->date_partnership_start = (!GETPOST('date_partnership_start')) ? '' : $date_start; + $object->date_partnership_end = (!GETPOST('date_partnership_end')) ? '' : $date_end; + $object->note_public = GETPOST('note_public', 'restricthtml'); + $object->date_creation = $now; + $object->fk_user_creat = $user->id; + $object->entity = $conf->entity; + + // Fill array 'array_options' with data from add form + $ret = $extrafields->setOptionalsFromPost(null, $object); + if ($ret < 0) { + $error++; + } + } + + if (!$error) { + $result = $object->create($user); + if ($result < 0) { + $error++; + if ($result == -4) { + setEventMessages($langs->trans("ErrorRefAlreadyExists"), null, 'errors'); + } else { + setEventMessages($object->error, $object->errors, 'errors'); + } + } + } + + if ($error) { + $db->rollback(); + $action = 'create'; + } else { + $db->commit(); + } + } elseif ($action == 'update' && $permissiontoread) { + $error = 0; + + $db->begin(); + + $now = dol_now(); + + if (!$error) { + $object->oldcopy = clone $object; + + $old_start_date = $object->date_partnership_start; + + $object->date_partnership_start = (!GETPOST('date_partnership_start')) ? '' : $date_start; + $object->date_partnership_end = (!GETPOST('date_partnership_end')) ? '' : $date_end; + $object->note_public = GETPOST('note_public', 'restricthtml'); + $object->fk_user_creat = $user->id; + $object->fk_user_modif = $user->id; + + // Fill array 'array_options' with data from add form + $ret = $extrafields->setOptionalsFromPost(null, $object); + if ($ret < 0) { + $error++; + } + } + + if (!$error) { + $result = $object->update($user); + if ($result < 0) { + $error++; + if ($result == -4) { + setEventMessages($langs->trans("ErrorRefAlreadyExists"), null, 'errors'); + } else { + setEventMessages($object->error, $object->errors, 'errors'); + } + } + } + + if ($error) { + $db->rollback(); + $action = 'edit'; + } else { + $db->commit(); + } + } elseif ($action == 'confirm_close' || $action == 'update_extras') { + include DOL_DOCUMENT_ROOT.'/core/actions_addupdatedelete.inc.php'; + + header("Location: ".$_SERVER['PHP_SELF']."?rowid=".$memberid); + exit; + } + + // Actions when linking object each other + include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php'; +} + +$object->fields['fk_member']['visible'] = 0; +if ($object->id > 0 && $object->status == $object::STATUS_REFUSED && empty($action)) $object->fields['reason_decline_or_cancel']['visible'] = 1; +$object->fields['note_public']['visible'] = 1; + +/* + * View + * + * Put here all code to build page + */ + +$form = new Form($db); +$formfile = new FormFile($db); + +$title = $langs->trans("Partnership"); +llxHeader('', $title); + +$form = new Form($db); + +if ($memberid) { + $langs->load("members"); + + $member = new Adherent($db); + $result = $member->fetch($memberid); + + if (!empty($conf->notification->enabled)) { + $langs->load("mails"); + } + + $adht->fetch($object->typeid); + + $head = member_prepare_head($member); + + print dol_get_fiche_head($head, 'partnership', $langs->trans("ThirdParty"), -1, 'user'); + + $linkback = ''.$langs->trans("BackToList").''; + + dol_banner_tab($member, 'rowid', $linkback); + + print '
'; + + print '
'; + print ''; + + // Login + if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) { + print ''; + } + + // Type + print '\n"; + + // Morphy + print ''; + print ''; + + // Company + print ''; + + // Civility + print ''; + print ''; + + print '
'.$langs->trans("Login").' / '.$langs->trans("Id").''.$member->login.' 
'.$langs->trans("Type").''.$adht->getNomUrl(1)."
'.$langs->trans("MemberNature").''.$member->getmorphylib().'
'.$langs->trans("Company").''.$member->company.'
'.$langs->trans("UserTitle").''.$member->getCivilityLabel().' 
'; + + print '
'; + + print dol_get_fiche_end(); + + $params = ''; + + print '
'; +} else { + dol_print_error('', 'Parameter rowid not defined'); +} + +// Part to create +if ($action == 'create') { + print load_fiche_titre($langs->trans("NewObject", $langs->transnoentitiesnoconv("Partnership")), '', ''); + + $backtopageforcancel = DOL_URL_ROOT.'/partnership/partnership.php?rowid='.$memberid; + + print '
'; + print ''; + print ''; + print ''; + print ''; + + if ($backtopage) { + print ''; + } + if ($backtopageforcancel) { + print ''; + } + + print dol_get_fiche_head(array(), ''); + + print ''."\n"; + + // Common attributes + include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_add.tpl.php'; + + // Other attributes + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_add.tpl.php'; + + print '
'."\n"; + + print dol_get_fiche_end(); + + print '
'; + print ''; + print '  '; + // print ''; // Cancel for create does not post form if we don't know the backtopage + print '
'; + + print '
'; +} + +// Part to edit record +if (($partnershipid || $ref) && $action == 'edit') { + print load_fiche_titre($langs->trans("Partnership"), '', ''); + + $backtopageforcancel = DOL_URL_ROOT.'/partnership/partnership.php?rowid='.$memberid; + + print '
'; + print ''; + print ''; + print ''; + print ''; + if ($backtopage) { + print ''; + } + if ($backtopageforcancel) { + print ''; + } + + print dol_get_fiche_head(); + + print ''."\n"; + + // Common attributes + include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_edit.tpl.php'; + + // Other attributes + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_edit.tpl.php'; + + print '
'; + + print dol_get_fiche_end(); + + print '
'; + print '   '; + print '
'; + + print '
'; +} + +// Part to show record +if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create'))) { + print load_fiche_titre($langs->trans("PartnershipDedicatedToThisMember", $langs->transnoentitiesnoconv("Partnership")), '', ''); + + $res = $object->fetch_optionals(); + + // $head = partnershipPrepareHead($object); + // print dol_get_fiche_head($head, 'card', $langs->trans("Partnership"), -1, $object->picto); + + $linkback = ''; + dol_banner_tab($object, 'id', $linkback, 0, 'rowid', 'ref'); + + $formconfirm = ''; + + // Close confirmation + if ($action == 'close') { + // Create an array for form + $formquestion = array(); + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClose'), $langs->trans('ConfirmClosePartnershipAsk', $object->ref), 'confirm_close', $formquestion, 'yes', 1); + } + // Reopon confirmation + if ($action == 'reopen') { + // Create an array for form + $formquestion = array(); + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToReopon'), $langs->trans('ConfirmReoponAsk', $object->ref), 'confirm_reopen', $formquestion, 'yes', 1); + } + + // Refuse confirmatio + if ($action == 'refuse') { + //Form to close proposal (signed or not) + $formquestion = array( + array('type' => 'text', 'name' => 'reason_decline_or_cancel', 'label' => $langs->trans("Note"), 'morecss' => 'reason_decline_or_cancel', 'value' => '') // Field to complete private note (not replace) + ); + + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ReasonDecline'), $text, 'confirm_refuse', $formquestion, '', 1, 250); + } + + // Call Hook formConfirm + $parameters = array('formConfirm' => $formconfirm, 'lineid' => $lineid); + $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + if (empty($reshook)) { + $formconfirm .= $hookmanager->resPrint; + } elseif ($reshook > 0) { + $formconfirm = $hookmanager->resPrint; + } + + // Print form confirm + print $formconfirm; + + + // Object card + // ------------------------------------------------------------ + $linkback = ''.$langs->trans("BackToList").''; + + print '
'; + print '
'; + print '
'; + print ''."\n"; + + // Common attributes + //$keyforbreak='fieldkeytoswitchonsecondcolumn'; // We change column just before this field + //unset($object->fields['fk_project']); // Hide field already shown in banner + //unset($object->fields['fk_member']); // Hide field already shown in banner + include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_view.tpl.php'; + + // End of subscription date + $fadherent = new Adherent($db); + $fadherent->fetch($object->fk_member); + print ''; + + // Other attributes. Fields from hook formObjectOptions and Extrafields. + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; + + print '
'.$langs->trans("SubscriptionEndDate").''; + if ($fadherent->datefin) { + print dol_print_date($fadherent->datefin, 'day'); + if ($fadherent->hasDelay()) { + print " ".img_warning($langs->trans("Late")); + } + } else { + if (!$adht->subscription) { + print $langs->trans("SubscriptionNotRecorded"); + if ($fadherent->statut > 0) { + print " ".img_warning($langs->trans("Late")); // Display a delay picto only if it is not a draft and is not canceled + } + } else { + print $langs->trans("SubscriptionNotReceived"); + if ($fadherent->statut > 0) { + print " ".img_warning($langs->trans("Late")); // Display a delay picto only if it is not a draft and is not canceled + } + } + } + print '
'; + print '
'; + + print '
'; + + print dol_get_fiche_end(); + + // Buttons for actions + + if ($action != 'presend') { + print '
'."\n"; + $parameters = array(); + $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + } + + if (empty($reshook)) { + if ($object->status == $object::STATUS_DRAFT) { + print dolGetButtonAction($langs->trans('Modify'), '', 'default', $_SERVER["PHP_SELF"].'?rowid='.$memberid.'&action=edit', '', $permissiontoadd); + } + + // Show + if ($permissiontoadd) { + print dolGetButtonAction($langs->trans('ShowPartnership'), '', 'default', dol_buildpath('/partnership/partnership_card.php', 1).'?id='.$object->id, '', $permissiontoadd); + } + + // Cancel + if ($permissiontoadd) { + if ($object->status == $object::STATUS_ACCEPTED) { + print dolGetButtonAction($langs->trans('Cancel'), '', 'default', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=close&token='.newToken(), '', $permissiontoadd); + } + } + } + print '
'."\n"; + } +} + +// End of page +llxFooter(); +$db->close(); diff --git a/htdocs/core/modules/modPartnership.class.php b/htdocs/core/modules/modPartnership.class.php index d70b626a99b..3bfd8d4aeab 100644 --- a/htdocs/core/modules/modPartnership.class.php +++ b/htdocs/core/modules/modPartnership.class.php @@ -180,7 +180,7 @@ class modPartnership extends DolibarrModules $tabtoadd = (!empty(getDolGlobalString('PARTNERSHIP_IS_MANAGED_FOR')) && getDolGlobalString('PARTNERSHIP_IS_MANAGED_FOR') == 'member') ? 'member' : 'thirdparty'; if ($tabtoadd == 'member') { - $this->tabs[] = array('data'=>'member:+partnership:Partnership:partnership@partnership:$user->rights->partnership->read:/adherents/partnership.php?socid=__ID__'); + $this->tabs[] = array('data'=>'member:+partnership:Partnership:partnership@partnership:$user->rights->partnership->read:/adherents/partnership.php?rowid=__ID__'); $fk_mainmenu = "members"; } else { $this->tabs[] = array('data'=>'thirdparty:+partnership:Partnership:partnership@partnership:$user->rights->partnership->read:/societe/partnership.php?socid=__ID__'); diff --git a/htdocs/install/mysql/migration/13.0.0-14.0.0.sql b/htdocs/install/mysql/migration/13.0.0-14.0.0.sql index d0375349880..69b3eb1a818 100644 --- a/htdocs/install/mysql/migration/13.0.0-14.0.0.sql +++ b/htdocs/install/mysql/migration/13.0.0-14.0.0.sql @@ -421,7 +421,7 @@ create table llx_partnership_extrafields ALTER TABLE llx_partnership_extrafields ADD INDEX idx_partnership_fk_object(fk_object); -INSERT INTO llx_c_email_templates (entity,module,type_template,label,lang,position,topic,joinfiles,content) VALUES (0, 'partnership', 'partnership_send', '(SendingEmailOnPartnershipWillExpire)', '', 100, '[__[MAIN_INFO_SOCIETE_NOM]__] - __(YourPartnershipWillSoonExpireTopic)__', 0, '\n

Hello,

\n__(YourPartnershipWillSoonExpireContent)__

\n
\n\n
\n\n __(Sincerely)__
\n __[MAIN_INFO_SOCIETE_NOM]__
\n \n'); +INSERT INTO llx_c_email_templates (entity,module,type_template,label,lang,position,topic,joinfiles,content) VALUES (0, 'partnership', 'partnership_send', '(SendingEmailOnPartnershipWillSoonBeCanceled)', '', 100, '[__[MAIN_INFO_SOCIETE_NOM]__] - __(YourPartnershipWillSoonBeCanceledTopic)__', 0, '\n

Hello,

\n__(YourPartnershipWillSoonBeCanceledContent)__

\n
\n\n
\n\n __(Sincerely)__
\n __[MAIN_INFO_SOCIETE_NOM]__
\n \n'); INSERT INTO llx_c_email_templates (entity,module,type_template,label,lang,position,topic,joinfiles,content) VALUES (0, 'partnership', 'partnership_send', '(SendingEmailOnPartnershipCanceled)', '', 100, '[__[MAIN_INFO_SOCIETE_NOM]__] - __(YourPartnershipCanceledTopic)__', 0, '\n

Hello,

\n__(YourPartnershipCanceledContent)__

\n
\n\n
\n\n __(Sincerely)__
\n __[MAIN_INFO_SOCIETE_NOM]__
\n \n'); INSERT INTO llx_c_email_templates (entity,module,type_template,label,lang,position,topic,joinfiles,content) VALUES (0, 'partnership', 'partnership_send', '(SendingEmailOnPartnershipRefused)', '', 100, '[__[MAIN_INFO_SOCIETE_NOM]__] - __(YourPartnershipRefusedTopic)__', 0, '\n

Hello,

\n__(YourPartnershipRefusedContent)__

\n
\n\n
\n\n __(Sincerely)__
\n __[MAIN_INFO_SOCIETE_NOM]__
\n \n'); INSERT INTO llx_c_email_templates (entity,module,type_template,label,lang,position,topic,joinfiles,content) VALUES (0, 'partnership', 'partnership_send', '(SendingEmailOnPartnershipAccepted)', '', 100, '[__[MAIN_INFO_SOCIETE_NOM]__] - __(YourPartnershipAcceptedTopic)__', 0, '\n

Hello,

\n__(YourPartnershipAcceptedContent)__

\n
\n\n
\n\n __(Sincerely)__
\n __[MAIN_INFO_SOCIETE_NOM]__
\n \n'); diff --git a/htdocs/langs/en_US/partnership.lang b/htdocs/langs/en_US/partnership.lang index ab51d2136e0..3e63acc92f6 100644 --- a/htdocs/langs/en_US/partnership.lang +++ b/htdocs/langs/en_US/partnership.lang @@ -40,7 +40,9 @@ PARTNERSHIP_NBDAYS_AFTER_MEMBER_EXPIRATION_BEFORE_CANCEL=Nb of days before cance # # Object # +DeletePartnership=Delete a partnership PartnershipDedicatedToThisThirdParty=Partnership dedicated to this third party +PartnershipDedicatedToThisMember=Partnership dedicated to this member DatePartnershipStart=Start date DatePartnershipEnd=End date ReasonDecline=Decline reason @@ -53,17 +55,17 @@ ConfirmClosePartnershipAsk=Are you sure you want to cancel this partnership? # # Template Mail # -SendingEmailOnPartnershipWillExpire=Partnership will expire +SendingEmailOnPartnershipWillSoonBeCanceled=Partnership will soon be canceled SendingEmailOnPartnershipRefused=Partnership refused SendingEmailOnPartnershipAccepted=Partnership accepted SendingEmailOnPartnershipCanceled=Partnership canceled -YourPartnershipWillSoonExpireTopic=Partnership expiration +YourPartnershipWillSoonBeCanceledTopic=Partnership will soon be canceled YourPartnershipRefusedTopic=Partnership refused YourPartnershipAcceptedTopic=Partnership accepted YourPartnershipCanceledTopic=Partnership canceled -YourPartnershipWillSoonExpireContent=We inform you that your partnership will soon expire. +YourPartnershipWillSoonBeCanceledContent=We inform you that your partnership will soon be canceled (Backlink not found) YourPartnershipRefusedContent=We inform you that your partnership request has been refused. YourPartnershipAcceptedContent=We inform you that your partnership request has been accepted. YourPartnershipCanceledContent=We inform you that your partnership has been canceled. diff --git a/htdocs/partnership/class/partnership.class.php b/htdocs/partnership/class/partnership.class.php index 6bf84ba38cc..b211e9c5323 100644 --- a/htdocs/partnership/class/partnership.class.php +++ b/htdocs/partnership/class/partnership.class.php @@ -424,7 +424,7 @@ class Partnership extends CommonObject return 1; } else { - $this->error = 'Partnership with id '.$id.' not found sql='.$sql; + // $this->error = 'Partnership with id '.$id.' not found sql='.$sql; return 0; } } else { diff --git a/htdocs/partnership/class/partnershiputils.class.php b/htdocs/partnership/class/partnershiputils.class.php index f3f398e0676..992fca2703e 100644 --- a/htdocs/partnership/class/partnershiputils.class.php +++ b/htdocs/partnership/class/partnershiputils.class.php @@ -311,7 +311,7 @@ class PartnershipUtils if (!empty($obj->email)) { $emailnotfound .= ($emailnotfound ? ', ' : '').'Email not found for id="'.$fk_partner.'"'."\n"; } else { - $labeltemplate = '(SendingEmailOnPartnershipWillExpire)'; + $labeltemplate = '(SendingEmailOnPartnershipWillSoonBeCanceled)'; dol_syslog("Now we will send an email to partner id=".$fk_partner." with label ".$labeltemplate); diff --git a/htdocs/societe/partnership.php b/htdocs/societe/partnership.php index 1ee013f985c..0a5205799a9 100644 --- a/htdocs/societe/partnership.php +++ b/htdocs/societe/partnership.php @@ -82,7 +82,7 @@ dol_include_once('/partnership/class/partnership.class.php'); dol_include_once('/partnership/lib/partnership.lib.php'); // Load translation files required by the page -$langs->loadLangs(array("companies","partnership@partnership", "other")); +$langs->loadLangs(array("companies","partnership", "other")); // Get parameters $id = GETPOST('id', 'int'); @@ -139,7 +139,7 @@ $usercanclose = $user->rights->partnership->write; // Used by the include of $upload_dir = $conf->partnership->multidir_output[isset($object->entity) ? $object->entity : 1]; -if ($conf->global->PARTNERSHIP_IS_MANAGED_FOR == 'member') accessforbidden(); +if ($conf->global->PARTNERSHIP_IS_MANAGED_FOR != 'thirdparty') accessforbidden(); if (empty($conf->partnership->enabled)) accessforbidden(); if (empty($permissiontoread)) accessforbidden(); if ($action == 'edit' && empty($permissiontoadd)) accessforbidden(); @@ -212,7 +212,7 @@ if (empty($reshook)) { if ($error) { $db->rollback(); - $action = 'edit'; + $action = 'create'; } else { $db->commit(); } From 18d16d95092f04a81f743377f46a857e6416dfde Mon Sep 17 00:00:00 2001 From: Dorian Vabre Date: Mon, 19 Apr 2021 16:26:45 +0200 Subject: [PATCH 057/147] moved attendee validation after the payment method search --- htdocs/public/payment/paymentok.php | 57 ++++++++++++++--------------- 1 file changed, 27 insertions(+), 30 deletions(-) diff --git a/htdocs/public/payment/paymentok.php b/htdocs/public/payment/paymentok.php index d9cfdc28b69..a52ddb5fbcc 100644 --- a/htdocs/public/payment/paymentok.php +++ b/htdocs/public/payment/paymentok.php @@ -113,36 +113,6 @@ $uncryptedconferencesubscription = dol_decode($conferencesubscription, $dolibarr $subscription = substr($uncryptedconferencesubscription, 0, strlen($uncryptedconferencesubscription)-strlen($ref)); $reffrompayment = substr($uncryptedconferencesubscription, -strlen($ref), strlen($ref)); -// After a conference attendee payment -if ($subscription == 'subscriptionok' && $ref == $reffrompayment) { - // Looking for the invoice to which add a payment - $paidinvoice = new Facture($db); - $resultinvoice = $paidinvoice->fetch($invoiceref); - if ($resultinvoice < 0) { - setEventMessages(null, $paidinvoice->errors, "errors"); - } else { - // Creation of payment line - $paiement = new Paiement($db); - $paiement->datepaye = dol_now(); - $paiement->amounts = $amounts; // Array with all payments dispatching with invoice id - $paiement->multicurrency_amounts = $multicurrency_amounts; // Array with all payments dispatching - $paiement->paiementid = dol_getIdFromCode($db, GETPOST('paiementcode'), 'c_paiement', 'code', 'id', 1); - $paiement->num_payment = GETPOST('num_paiement', 'alpha'); - $paiement->note_private = GETPOST('comment', 'alpha'); - - // Validating the attendee - $attendeetovalidate = new ConferenceOrBoothAttendee($db); - $resultattendee = $attendeetovalidate->fetch($ref); - if ($resultattendee < 0) { - setEventMessages(null, $attendeetovalidate->errors, "errors"); - } else { - $attendeetovalidate->setStatut(1); - } - } - - - -} // Detect $paymentmethod $paymentmethod = ''; @@ -186,6 +156,33 @@ $object = new stdClass(); // For triggers $error = 0; +// After a conference attendee payment +if ($subscription == 'subscriptionok' && $ref == $reffrompayment) { + // Looking for the invoice to which add a payment + $paidinvoice = new Facture($db); + $resultinvoice = $paidinvoice->fetch($invoiceref); + if ($resultinvoice < 0) { + setEventMessages(null, $paidinvoice->errors, "errors"); + } else { + // Creation of payment line + $paiement = new Paiement($db); + $paiement->datepaye = dol_now(); + $paiement->amounts = $amounts; // Array with all payments dispatching with invoice id + $paiement->multicurrency_amounts = $multicurrency_amounts; // Array with all payments dispatching + $paiement->paiementid = dol_getIdFromCode($db, GETPOST('paiementcode'), 'c_paiement', 'code', 'id', 1); + $paiement->num_payment = GETPOST('num_paiement', 'alpha'); + $paiement->note_private = GETPOST('comment', 'alpha'); + + // Validating the attendee + $attendeetovalidate = new ConferenceOrBoothAttendee($db); + $resultattendee = $attendeetovalidate->fetch($ref); + if ($resultattendee < 0) { + setEventMessages(null, $attendeetovalidate->errors, "errors"); + } else { + $attendeetovalidate->setStatut(1); + } + } +} /* * Actions From ac8ddd88315db36f1e1058c1a54678559fa8a01e Mon Sep 17 00:00:00 2001 From: Dorian Vabre Date: Mon, 19 Apr 2021 16:52:08 +0200 Subject: [PATCH 058/147] removed redundant fetch --- htdocs/public/eventorganization/attendee_subscription.php | 6 ------ 1 file changed, 6 deletions(-) diff --git a/htdocs/public/eventorganization/attendee_subscription.php b/htdocs/public/eventorganization/attendee_subscription.php index 9f3115e56f4..b5ae6b0ba01 100644 --- a/htdocs/public/eventorganization/attendee_subscription.php +++ b/htdocs/public/eventorganization/attendee_subscription.php @@ -366,12 +366,6 @@ if (empty($reshook) && $action == 'add') { $form = new Form($db); $formcompany = new FormCompany($db); -$conference = new ConferenceOrBooth($db); -$resultconf = $conference->fetch($id); -if ($resultconf < 0) { - setEventMessages(null, $object->errors, "errors"); -} - llxHeaderVierge($langs->trans("NewSubscription")); From 128dcb2e2bd2b68fdf1eba7f05234e45aeef2600 Mon Sep 17 00:00:00 2001 From: Dorian Vabre Date: Mon, 19 Apr 2021 17:26:01 +0200 Subject: [PATCH 059/147] public registration page for booths and conferences created, wip --- htdocs/langs/en_US/eventorganization.lang | 5 + htdocs/public/project/index.php | 829 ++++++++++++++++++++++ 2 files changed, 834 insertions(+) diff --git a/htdocs/langs/en_US/eventorganization.lang b/htdocs/langs/en_US/eventorganization.lang index 157fc1c8a99..9e2df362467 100644 --- a/htdocs/langs/en_US/eventorganization.lang +++ b/htdocs/langs/en_US/eventorganization.lang @@ -97,6 +97,11 @@ EvntOrgCancelled = Cancelled # Public page # RegisterPage = Page for conferences or booth +EvntOrgRegistrationWelcomeMessage = Welcome on the conference or booth suggestion page. +EvntOrgRegistrationHelpMessage = Here, you can suggest a new conference or a new booth for the project +SuggestConference = Suggest a new conference +SuggestBooth = Suggest a booth +ViewAndVote = View and vote for suggested events PublicAttendeeSubscriptionPage = Public link of registration to a conference MissingOrBadSecureKey = The security key is invalid or missing EvntOrgWelcomeMessage = This form allows you to register as a new participant to the conference diff --git a/htdocs/public/project/index.php b/htdocs/public/project/index.php index e69de29bb2d..9b04890084e 100644 --- a/htdocs/public/project/index.php +++ b/htdocs/public/project/index.php @@ -0,0 +1,829 @@ + + * Copyright (C) 2006-2017 Laurent Destailleur + * Copyright (C) 2009-2012 Regis Houssin + * Copyright (C) 2018 Juanjo Menent + * Copyright (C) 2018-2019 Thibault FOUCART + * Copyright (C) 2021 Waël Almoman + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * For Paypal test: https://developer.paypal.com/ + * For Paybox test: ??? + * For Stripe test: Use credit card 4242424242424242 .More example on https://stripe.com/docs/testing + * + * Variants: + * - When option STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION is on, we use the new PaymentIntent API + * - When option STRIPE_USE_NEW_CHECKOUT is on, we use the new checkout API + * - If no option set, we use old APIS (charge) + */ + +/** + * \file htdocs/public/payment/newpayment.php + * \ingroup core + * \brief File to offer a way to make a payment for a particular Dolibarr object + */ + +if (!defined('NOLOGIN')) { + define("NOLOGIN", 1); // This means this output page does not require to be logged. +} +if (!defined('NOCSRFCHECK')) { + define("NOCSRFCHECK", 1); // We accept to go on this page from external web site. +} +if (!defined('NOIPCHECK')) { + define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip +} +if (!defined('NOBROWSERNOTIF')) { + define('NOBROWSERNOTIF', '1'); +} + +// For MultiCompany module. +// Do not use GETPOST here, function is not defined and get of entity must be done before including main.inc.php +$entity = (!empty($_GET['entity']) ? (int) $_GET['entity'] : (!empty($_POST['entity']) ? (int) $_POST['entity'] : (!empty($_GET['e']) ? (int) $_GET['e'] : (!empty($_POST['e']) ? (int) $_POST['e'] : 1)))); +if (is_numeric($entity)) { + define("DOLENTITY", $entity); +} + +require '../../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; +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.'/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'; +$hookmanager = new HookManager($db); +$hookmanager->initHooks(array('newpayment')); + +// For encryption +global $dolibarr_main_instance_unique_id; + +// Load translation files +$langs->loadLangs(array("main", "other", "dict", "bills", "companies", "errors", "paybox", "paypal", "stripe")); // File with generic data + +// Security check +// No check on module enabled. Done later according to $validpaymentmethod + +$action = GETPOST('action', 'aZ09'); +$id = dol_decode(GETPOST('id'), $dolibarr_main_instance_unique_id); + +// Define $urlwithroot +//$urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root)); +//$urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file +$urlwithroot = DOL_MAIN_URL_ROOT; // This is to use same domain name than current. For Paypal payment, we can use internal URL like localhost. + + +/* + * Actions + */ + + +/* + * View + */ + +$head = ''; +if (!empty($conf->global->ONLINE_PAYMENT_CSS_URL)) { + $head = ''."\n"; +} + +$conf->dol_hide_topmenu = 1; +$conf->dol_hide_leftmenu = 1; + +$replacemainarea = (empty($conf->dol_hide_leftmenu) ? '
' : '').'
'; +llxHeader($head, $langs->trans("PaymentForm"), '', '', 0, 0, '', '', '', 'onlinepaymentbody', $replacemainarea); + + +// Show sandbox warning +if ((empty($paymentmethod) || $paymentmethod == 'paypal') && !empty($conf->paypal->enabled) && (!empty($conf->global->PAYPAL_API_SANDBOX) || GETPOST('forcesandbox', 'int'))) { // We can force sand box with param 'forcesandbox' + dol_htmloutput_mesg($langs->trans('YouAreCurrentlyInSandboxMode', 'Paypal'), '', 'warning'); +} +if ((empty($paymentmethod) || $paymentmethod == 'stripe') && !empty($conf->stripe->enabled) && (empty($conf->global->STRIPE_LIVE) || GETPOST('forcesandbox', 'int'))) { + dol_htmloutput_mesg($langs->trans('YouAreCurrentlyInSandboxMode', 'Stripe'), '', 'warning'); +} + + +print ''."\n"; +print '
'."\n"; +print '
'."\n"; +print ''."\n"; +print ''."\n"; +print ''."\n"; +print ''."\n"; +print ''."\n"; +print ''; +print ''; +print "\n"; + + +// Show logo (search order: logo defined by PAYMENT_LOGO_suffix, then PAYMENT_LOGO, then small company logo, large company logo, theme logo, common logo) +// Define logo and logosmall +$logosmall = $mysoc->logo_small; +$logo = $mysoc->logo; +$paramlogo = 'ONLINE_PAYMENT_LOGO_'.$suffix; +if (!empty($conf->global->$paramlogo)) { + $logosmall = $conf->global->$paramlogo; +} elseif (!empty($conf->global->ONLINE_PAYMENT_LOGO)) { + $logosmall = $conf->global->ONLINE_PAYMENT_LOGO; +} +//print ''."\n"; +// Define urllogo +$urllogo = ''; +$urllogofull = ''; +if (!empty($logosmall) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$logosmall)) { + $urllogo = DOL_URL_ROOT.'/viewimage.php?modulepart=mycompany&entity='.$conf->entity.'&file='.urlencode('logos/thumbs/'.$logosmall); + $urllogofull = $dolibarr_main_url_root.'/viewimage.php?modulepart=mycompany&entity='.$conf->entity.'&file='.urlencode('logos/thumbs/'.$logosmall); +} elseif (!empty($logo) && is_readable($conf->mycompany->dir_output.'/logos/'.$logo)) { + $urllogo = DOL_URL_ROOT.'/viewimage.php?modulepart=mycompany&entity='.$conf->entity.'&file='.urlencode('logos/'.$logo); + $urllogofull = $dolibarr_main_url_root.'/viewimage.php?modulepart=mycompany&entity='.$conf->entity.'&file='.urlencode('logos/'.$logo); +} + +// Output html code for logo +if ($urllogo) { + print '
'; + print '
'; + print ''; + print '
'; + if (empty($conf->global->MAIN_HIDE_POWERED_BY)) { + print ''; + } + print '
'; +} + +print ''."\n"; + +// Output introduction text +$text = ''; +if (!empty($conf->global->PAYMENT_NEWFORM_TEXT)) { + $langs->load("members"); + if (preg_match('/^\((.*)\)$/', $conf->global->PAYMENT_NEWFORM_TEXT, $reg)) { + $text .= $langs->trans($reg[1])."
\n"; + } else { + $text .= $conf->global->PAYMENT_NEWFORM_TEXT."
\n"; + } + $text = ''."\n"; +} +if (empty($text)) { + $text .= ''."\n"; + $text .= ''."\n"; +} +print $text; + +// Output payment summary form +print ''."\n"; +} + +print "\n"; + + +// Show all payment mode buttons (Stripe, Paypal, ...) +print '
'; +print ''; +print '

'; +print ''; +print '

'; +print ''; + + +print ''."\n"; + +print '

'.$text.'

'.$langs->trans("EvntOrgRegistrationWelcomeMessage").'
'.$langs->trans("EvntOrgRegistrationHelpMessage").' '.$id.'.

'; + +$found = false; +$error = 0; +$var = false; + +$object = null; + + +// Free payment +if (!$source) { + $found = true; + $tag = GETPOST("tag", 'alpha'); + if (GETPOST('fulltag', 'alpha')) { + $fulltag = GETPOST('fulltag', 'alpha'); + } else { + $fulltag = "TAG=".$tag; + } + +} + + +// Payment on customer order +if ($source == 'order') { + $found = true; + $langs->load("orders"); + + require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; + + $order = new Commande($db); + $result = $order->fetch('', $ref); + if ($result <= 0) { + $mesg = $order->error; + $error++; + } else { + $result = $order->fetch_thirdparty($order->socid); + } + $object = $order; + + if (GETPOST('fulltag', 'alpha')) { + $fulltag = GETPOST('fulltag', 'alpha'); + } else { + $fulltag = 'ORD='.$order->id.'.CUS='.$order->thirdparty->id; + if (!empty($TAG)) { + $tag = $TAG; $fulltag .= '.TAG='.$TAG; + } + } + $fulltag = dol_string_unaccent($fulltag); +} + + +// Payment on customer invoice +if ($source == 'invoice') { + $found = true; + $langs->load("bills"); + + require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; + + $invoice = new Facture($db); + $result = $invoice->fetch('', $ref); + if ($result <= 0) { + $mesg = $invoice->error; + $error++; + } else { + $result = $invoice->fetch_thirdparty($invoice->socid); + } + $object = $invoice; + + if ($action != 'dopayment') { // Do not change amount if we just click on first dopayment + $amount = price2num($invoice->total_ttc - ($invoice->getSommePaiement() + $invoice->getSumCreditNotesUsed() + $invoice->getSumDepositsUsed())); + if (GETPOST("amount", 'alpha')) { + $amount = GETPOST("amount", 'alpha'); + } + $amount = price2num($amount); + } + + if (GETPOST('fulltag', 'alpha')) { + $fulltag = GETPOST('fulltag', 'alpha'); + } else { + $fulltag = 'INV='.$invoice->id.'.CUS='.$invoice->thirdparty->id; + if (!empty($TAG)) { + $tag = $TAG; $fulltag .= '.TAG='.$TAG; + } + } + $fulltag = dol_string_unaccent($fulltag); + + $labeldesc = $langs->trans("Invoice").' '.$invoice->ref; + if (GETPOST('desc', 'alpha')) { + $labeldesc = GETPOST('desc', 'alpha'); + } + print ''."\n"; +} + +if (!$found && !$mesg) { + $mesg = $langs->trans("ErrorBadParameters"); +} + +if ($mesg) { + print '

'.dol_escape_htmltag($mesg).'
'."\n"; + +print '
'."\n"; +print '
'."\n"; +print '
'; + + + +// Add more content on page for some services +if (preg_match('/^dopayment/', $action)) { // If we choosed/click on the payment mode + // Stripe + if (GETPOST('dopayment_stripe', 'alpha')) { + // Personalized checkout + print ''; + + print '
'; + + print ''."\n"; + print '
'."\n"; + + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''; + print ''."\n"; + print ''."\n"; + print ''; + print ''; + print ''; + + if (!empty($conf->global->STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION) || !empty($conf->global->STRIPE_USE_NEW_CHECKOUT)) { // Use a SCA ready method + require_once DOL_DOCUMENT_ROOT.'/stripe/class/stripe.class.php'; + + $service = 'StripeLive'; + $servicestatus = 1; + if (empty($conf->global->STRIPE_LIVE) || GETPOST('forcesandbox', 'alpha')) { + $service = 'StripeTest'; + $servicestatus = 0; + } + + $stripe = new Stripe($db); + $stripeacc = $stripe->getStripeAccount($service); + $stripecu = null; + if (is_object($object) && is_object($object->thirdparty)) { + $stripecu = $stripe->customerStripe($object->thirdparty, $stripeacc, $servicestatus, 1); + } + + if (!empty($conf->global->STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION)) { + $noidempotency_key = (GETPOSTISSET('noidempotency') ? GETPOST('noidempotency', 'int') : 0); // By default noidempotency is unset, so we must use a different tag/ref for each payment. If set, we can pay several times the same tag/ref. + $paymentintent = $stripe->getPaymentIntent($amount, $currency, $tag, 'Stripe payment: '.$fulltag.(is_object($object) ? ' ref='.$object->ref : ''), $object, $stripecu, $stripeacc, $servicestatus, 0, 'automatic', false, null, 0, $noidempotency_key); + // The paymentintnent has status 'requires_payment_method' (even if paymentintent was already paid) + //var_dump($paymentintent); + if ($stripe->error) { + setEventMessages($stripe->error, null, 'errors'); + } + } + } + + //if (empty($conf->global->STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION) || ! empty($paymentintent)) + //{ + print ' + + '; + print '
'; + + if (!empty($conf->global->STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION)) { + print '
'; + } + + print '
'; + print ''; + + if (!empty($conf->global->STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION)) { + print '
'; + } + + print '
+ +
'; + + print ' + +
'; + + print '
'; + print ''; + print ''; + + print '
'; + //} + + if (!empty($conf->global->STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION)) { + if (empty($paymentintent)) { + print '
'.$langs->trans("Error").'
'; + } else { + print ''; + //$_SESSION["paymentintent_id"] = $paymentintent->id; + } + } + + print '
'."\n"; + + + // JS Code for Stripe + if (empty($stripearrayofkeys['publishable_key'])) { + $langs->load("errors"); + print info_admin($langs->trans("ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv("Stripe")), 0, 0, 'error'); + } else { + print ''; + print ''."\n"; + print ''."\n"; + + // Code to ask the credit card. This use the default "API version". No way to force API version when using JS code. + print ''; + } + } + // This hook is used to show the embedded form to make payments with external payment modules (ie Payzen, ...) + $parameters = [ + 'paymentmethod' => $paymentmethod, + 'amount' => price2num(GETPOST("newamount"), 'MT'), + 'tag' => GETPOST("tag", 'alpha'), + 'dopayment' => GETPOST('dopayment', 'alpha') + ]; + $reshook = $hookmanager->executeHooks('doPayment', $parameters, $object, $action); +} + + +htmlPrintOnlinePaymentFooter($mysoc, $langs, 1, $suffix, $object); + +llxFooter('', 'public'); + +$db->close(); From f82d1d246d303904abed30b1c1067f9f1bce85e7 Mon Sep 17 00:00:00 2001 From: Dorian Vabre Date: Tue, 20 Apr 2021 09:45:32 +0200 Subject: [PATCH 060/147] cleanup on the index registration page --- htdocs/public/project/index.php | 618 +------------------------------- 1 file changed, 8 insertions(+), 610 deletions(-) diff --git a/htdocs/public/project/index.php b/htdocs/public/project/index.php index 9b04890084e..7ff74c31cb9 100644 --- a/htdocs/public/project/index.php +++ b/htdocs/public/project/index.php @@ -85,6 +85,12 @@ $id = dol_decode(GETPOST('id'), $dolibarr_main_instance_unique_id); //$urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file $urlwithroot = DOL_MAIN_URL_ROOT; // This is to use same domain name than current. For Paypal payment, we can use internal URL like localhost. +$project = new Project($db); +$resultproject = $project->fetch($id); +if ($resultproject < 0) { + $error++; + $errmsg .= $project->error; +} /* * Actions @@ -180,6 +186,7 @@ if (!empty($conf->global->PAYMENT_NEWFORM_TEXT)) { if (empty($text)) { $text .= '
'.$langs->trans("EvntOrgRegistrationWelcomeMessage").''."\n"; $text .= ''.$langs->trans("EvntOrgRegistrationHelpMessage").' '.$id.'.

'."\n"; + $text .= ''.$project->note_public.'

'."\n";; } print $text; @@ -192,103 +199,10 @@ $var = false; $object = null; - -// Free payment -if (!$source) { - $found = true; - $tag = GETPOST("tag", 'alpha'); - if (GETPOST('fulltag', 'alpha')) { - $fulltag = GETPOST('fulltag', 'alpha'); - } else { - $fulltag = "TAG=".$tag; - } - -} - - -// Payment on customer order -if ($source == 'order') { - $found = true; - $langs->load("orders"); - - require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; - - $order = new Commande($db); - $result = $order->fetch('', $ref); - if ($result <= 0) { - $mesg = $order->error; - $error++; - } else { - $result = $order->fetch_thirdparty($order->socid); - } - $object = $order; - - if (GETPOST('fulltag', 'alpha')) { - $fulltag = GETPOST('fulltag', 'alpha'); - } else { - $fulltag = 'ORD='.$order->id.'.CUS='.$order->thirdparty->id; - if (!empty($TAG)) { - $tag = $TAG; $fulltag .= '.TAG='.$TAG; - } - } - $fulltag = dol_string_unaccent($fulltag); -} - - -// Payment on customer invoice -if ($source == 'invoice') { - $found = true; - $langs->load("bills"); - - require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; - - $invoice = new Facture($db); - $result = $invoice->fetch('', $ref); - if ($result <= 0) { - $mesg = $invoice->error; - $error++; - } else { - $result = $invoice->fetch_thirdparty($invoice->socid); - } - $object = $invoice; - - if ($action != 'dopayment') { // Do not change amount if we just click on first dopayment - $amount = price2num($invoice->total_ttc - ($invoice->getSommePaiement() + $invoice->getSumCreditNotesUsed() + $invoice->getSumDepositsUsed())); - if (GETPOST("amount", 'alpha')) { - $amount = GETPOST("amount", 'alpha'); - } - $amount = price2num($amount); - } - - if (GETPOST('fulltag', 'alpha')) { - $fulltag = GETPOST('fulltag', 'alpha'); - } else { - $fulltag = 'INV='.$invoice->id.'.CUS='.$invoice->thirdparty->id; - if (!empty($TAG)) { - $tag = $TAG; $fulltag .= '.TAG='.$TAG; - } - } - $fulltag = dol_string_unaccent($fulltag); - - $labeldesc = $langs->trans("Invoice").' '.$invoice->ref; - if (GETPOST('desc', 'alpha')) { - $labeldesc = GETPOST('desc', 'alpha'); - } - print ''."\n"; -} - -if (!$found && !$mesg) { - $mesg = $langs->trans("ErrorBadParameters"); -} - -if ($mesg) { - print '
'.dol_escape_htmltag($mesg).'
'."\n"; -} - print "\n"; -// Show all payment mode buttons (Stripe, Paypal, ...) +// Show all action buttons print '
'; print ''; print '

'; @@ -306,522 +220,6 @@ print '
'."\n"; print '
'; - -// Add more content on page for some services -if (preg_match('/^dopayment/', $action)) { // If we choosed/click on the payment mode - // Stripe - if (GETPOST('dopayment_stripe', 'alpha')) { - // Personalized checkout - print ''; - - print '
'; - - print ''."\n"; - print '
'."\n"; - - print ''."\n"; - print ''."\n"; - print ''."\n"; - print ''."\n"; - print ''."\n"; - print ''."\n"; - print ''."\n"; - print ''."\n"; - print ''."\n"; - print ''; - print ''."\n"; - print ''."\n"; - print ''; - print ''; - print ''; - - if (!empty($conf->global->STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION) || !empty($conf->global->STRIPE_USE_NEW_CHECKOUT)) { // Use a SCA ready method - require_once DOL_DOCUMENT_ROOT.'/stripe/class/stripe.class.php'; - - $service = 'StripeLive'; - $servicestatus = 1; - if (empty($conf->global->STRIPE_LIVE) || GETPOST('forcesandbox', 'alpha')) { - $service = 'StripeTest'; - $servicestatus = 0; - } - - $stripe = new Stripe($db); - $stripeacc = $stripe->getStripeAccount($service); - $stripecu = null; - if (is_object($object) && is_object($object->thirdparty)) { - $stripecu = $stripe->customerStripe($object->thirdparty, $stripeacc, $servicestatus, 1); - } - - if (!empty($conf->global->STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION)) { - $noidempotency_key = (GETPOSTISSET('noidempotency') ? GETPOST('noidempotency', 'int') : 0); // By default noidempotency is unset, so we must use a different tag/ref for each payment. If set, we can pay several times the same tag/ref. - $paymentintent = $stripe->getPaymentIntent($amount, $currency, $tag, 'Stripe payment: '.$fulltag.(is_object($object) ? ' ref='.$object->ref : ''), $object, $stripecu, $stripeacc, $servicestatus, 0, 'automatic', false, null, 0, $noidempotency_key); - // The paymentintnent has status 'requires_payment_method' (even if paymentintent was already paid) - //var_dump($paymentintent); - if ($stripe->error) { - setEventMessages($stripe->error, null, 'errors'); - } - } - } - - //if (empty($conf->global->STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION) || ! empty($paymentintent)) - //{ - print ' - - '; - print '
'; - - if (!empty($conf->global->STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION)) { - print '
'; - } - - print '
'; - print ''; - - if (!empty($conf->global->STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION)) { - print '
'; - } - - print '
- -
'; - - print ' - -
'; - - print '
'; - print ''; - print ''; - - print '
'; - //} - - if (!empty($conf->global->STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION)) { - if (empty($paymentintent)) { - print '
'.$langs->trans("Error").'
'; - } else { - print ''; - //$_SESSION["paymentintent_id"] = $paymentintent->id; - } - } - - print '
'."\n"; - - - // JS Code for Stripe - if (empty($stripearrayofkeys['publishable_key'])) { - $langs->load("errors"); - print info_admin($langs->trans("ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv("Stripe")), 0, 0, 'error'); - } else { - print ''; - print ''."\n"; - print ''."\n"; - - // Code to ask the credit card. This use the default "API version". No way to force API version when using JS code. - print ''; - } - } - // This hook is used to show the embedded form to make payments with external payment modules (ie Payzen, ...) - $parameters = [ - 'paymentmethod' => $paymentmethod, - 'amount' => price2num(GETPOST("newamount"), 'MT'), - 'tag' => GETPOST("tag", 'alpha'), - 'dopayment' => GETPOST('dopayment', 'alpha') - ]; - $reshook = $hookmanager->executeHooks('doPayment', $parameters, $object, $action); -} - - htmlPrintOnlinePaymentFooter($mysoc, $langs, 1, $suffix, $object); llxFooter('', 'public'); From 7405813ad0df90922de51586627cd4c3a25b57e8 Mon Sep 17 00:00:00 2001 From: Dorian Vabre Date: Tue, 20 Apr 2021 10:24:36 +0200 Subject: [PATCH 061/147] now displays only buttons if the corresponding boolean is checked --- htdocs/compta/paiement.php | 2 +- htdocs/public/payment/paymentok.php | 6 +----- htdocs/public/project/index.php | 32 ++++++++++++----------------- 3 files changed, 15 insertions(+), 25 deletions(-) diff --git a/htdocs/compta/paiement.php b/htdocs/compta/paiement.php index 94b114c03d8..418bca03d83 100644 --- a/htdocs/compta/paiement.php +++ b/htdocs/compta/paiement.php @@ -253,7 +253,7 @@ if (empty($reshook)) { if (!$error) { // Create payment and update this->multicurrency_amounts if this->amounts filled or // this->amounts if this->multicurrency_amounts filled. - $paiement_id = $paiement->create($user, (GETPOST('closepaidinvoices') == 'on' ? 1 : 0), $thirdparty); // This include closing invoices and regenerating documents + $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++; diff --git a/htdocs/public/payment/paymentok.php b/htdocs/public/payment/paymentok.php index a52ddb5fbcc..c4f6b0a012c 100644 --- a/htdocs/public/payment/paymentok.php +++ b/htdocs/public/payment/paymentok.php @@ -167,11 +167,7 @@ if ($subscription == 'subscriptionok' && $ref == $reffrompayment) { // Creation of payment line $paiement = new Paiement($db); $paiement->datepaye = dol_now(); - $paiement->amounts = $amounts; // Array with all payments dispatching with invoice id - $paiement->multicurrency_amounts = $multicurrency_amounts; // Array with all payments dispatching - $paiement->paiementid = dol_getIdFromCode($db, GETPOST('paiementcode'), 'c_paiement', 'code', 'id', 1); - $paiement->num_payment = GETPOST('num_paiement', 'alpha'); - $paiement->note_private = GETPOST('comment', 'alpha'); + $paiement->amounts[] = $paidinvoice->total_ttc; // Array with all payments dispatching with invoice id // Validating the attendee $attendeetovalidate = new ConferenceOrBoothAttendee($db); diff --git a/htdocs/public/project/index.php b/htdocs/public/project/index.php index 7ff74c31cb9..ff6da63be9a 100644 --- a/htdocs/public/project/index.php +++ b/htdocs/public/project/index.php @@ -172,22 +172,10 @@ if ($urllogo) { print ''."\n"; -// Output introduction text -$text = ''; -if (!empty($conf->global->PAYMENT_NEWFORM_TEXT)) { - $langs->load("members"); - if (preg_match('/^\((.*)\)$/', $conf->global->PAYMENT_NEWFORM_TEXT, $reg)) { - $text .= $langs->trans($reg[1])."
\n"; - } else { - $text .= $conf->global->PAYMENT_NEWFORM_TEXT."
\n"; - } - $text = ''."\n"; -} -if (empty($text)) { - $text .= ''."\n"; - $text .= ''."\n"; - $text .= ''."\n";; -} +$text = ''."\n"; +$text .= ''."\n"; +$text .= ''."\n";; + print $text; // Output payment summary form @@ -204,11 +192,17 @@ print "\n"; // Show all action buttons print '
'; -print ''; -print '

'; +// Output introduction text +if($project->accept_conference_suggestions){ + print ''; + print '

'; +} print ''; print '

'; -print ''; +if($project->accept_booth_suggestions){ + print ''; +} + print ''."\n"; From b43e85dbf48f3cc50779a9bed03ca34827e2144a Mon Sep 17 00:00:00 2001 From: Dorian Vabre Date: Tue, 20 Apr 2021 10:27:32 +0200 Subject: [PATCH 062/147] added global dolibarr_main_instance_unique_id in attendeesubscription page --- htdocs/public/eventorganization/attendee_subscription.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/public/eventorganization/attendee_subscription.php b/htdocs/public/eventorganization/attendee_subscription.php index b5ae6b0ba01..bb2de7a590c 100644 --- a/htdocs/public/eventorganization/attendee_subscription.php +++ b/htdocs/public/eventorganization/attendee_subscription.php @@ -71,6 +71,8 @@ require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/paymentterm.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; +global $dolibarr_main_instance_unique_id; + // Init vars $errmsg = ''; $num = 0; From 3b17a0d66ae6b67e462051311f7ece6b6669eedc Mon Sep 17 00:00:00 2001 From: Dorian Vabre Date: Tue, 20 Apr 2021 10:42:50 +0200 Subject: [PATCH 063/147] 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 + } + } } } } From 5c490ca57e4e9794b55bcf86fbdc0b409ffbab8c Mon Sep 17 00:00:00 2001 From: Dorian Vabre Date: Tue, 20 Apr 2021 10:56:45 +0200 Subject: [PATCH 064/147] security added to subscriptionok page --- .../attendee_subscription.php | 2 +- .../eventorganization/subscriptionok.php | 19 ++++++++++++++++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/htdocs/public/eventorganization/attendee_subscription.php b/htdocs/public/eventorganization/attendee_subscription.php index bb2de7a590c..03fa023ad11 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'; + $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; } diff --git a/htdocs/public/eventorganization/subscriptionok.php b/htdocs/public/eventorganization/subscriptionok.php index c12c1053e97..e51358f907d 100644 --- a/htdocs/public/eventorganization/subscriptionok.php +++ b/htdocs/public/eventorganization/subscriptionok.php @@ -56,12 +56,29 @@ if (!empty($conf->paypal->enabled)) { require_once DOL_DOCUMENT_ROOT.'/paypal/lib/paypalfunctions.lib.php'; } +global $dolibarr_main_instance_unique_id, $dolibarr_main_url_root, $mysoc; + $langs->loadLangs(array("main", "companies", "install", "other", "eventorganization")); $object = new stdClass(); // For triggers $error = 0; +// Security check +$securekey = dol_decode(GETPOST('securekey'), $dolibarr_main_instance_unique_id); +if ($securekey != $conf->global->EVENTORGANIZATION_SECUREKEY) { + print $langs->trans('MissingOrBadSecureKey'); + 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; +} /* * Actions @@ -153,4 +170,4 @@ unset($_SESSION["TRANSACTIONID"]); llxFooter('', 'public'); -$db->close(); \ No newline at end of file +$db->close(); From 529909c3d1a8bd39729e72170074920acfdc2867 Mon Sep 17 00:00:00 2001 From: Dorian Vabre Date: Tue, 20 Apr 2021 11:35:31 +0200 Subject: [PATCH 065/147] wip on sending mails --- .../eventorganization/subscriptionok.php | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/htdocs/public/eventorganization/subscriptionok.php b/htdocs/public/eventorganization/subscriptionok.php index e51358f907d..7fc72f78e7c 100644 --- a/htdocs/public/eventorganization/subscriptionok.php +++ b/htdocs/public/eventorganization/subscriptionok.php @@ -80,6 +80,38 @@ if ($resthirdparty<0) { $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"; + + $result = $object->send_an_email($texttosend, $subjecttosend, array(), array(), array(), "", "", 0, -1, '', $moreinheader); +} + /* * Actions */ From d0d0e0390b748758d075cd63425c3124c382cdb0 Mon Sep 17 00:00:00 2001 From: Dorian Vabre Date: Tue, 20 Apr 2021 12:28:34 +0200 Subject: [PATCH 066/147] wip on mail --- .../eventorganization/subscriptionok.php | 19 ++++++++++++++++++- htdocs/public/payment/paymentok.php | 5 +---- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/htdocs/public/eventorganization/subscriptionok.php b/htdocs/public/eventorganization/subscriptionok.php index 7fc72f78e7c..3fcf74a4c0c 100644 --- a/htdocs/public/eventorganization/subscriptionok.php +++ b/htdocs/public/eventorganization/subscriptionok.php @@ -109,7 +109,24 @@ $texttosend = make_substitutions($msg, $substitutionarray, $outputlangs); if ($subjecttosend && $texttosend) { $moreinheader = 'X-Dolibarr-Info: send_an_email by public/members/new.php'."\r\n"; - $result = $object->send_an_email($texttosend, $subjecttosend, array(), array(), array(), "", "", 0, -1, '', $moreinheader); + 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; + } } /* diff --git a/htdocs/public/payment/paymentok.php b/htdocs/public/payment/paymentok.php index 533ce56cee1..90cf38a6051 100644 --- a/htdocs/public/payment/paymentok.php +++ b/htdocs/public/payment/paymentok.php @@ -177,13 +177,11 @@ if ($subscription == 'subscriptionok' && $ref == $reffrompayment) { $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 { + } else { // Validating the attendee $attendeetovalidate = new ConferenceOrBoothAttendee($db); $resultattendee = $attendeetovalidate->fetch($ref); @@ -191,7 +189,6 @@ if ($subscription == 'subscriptionok' && $ref == $reffrompayment) { setEventMessages(null, $attendeetovalidate->errors, "errors"); } else { $attendeetovalidate->setStatut(1); - // @todo send email } } } From 2cde31d17c3fd9300c0c99341a80c311c1a4c6da Mon Sep 17 00:00:00 2001 From: Dorian Vabre Date: Tue, 20 Apr 2021 14:39:41 +0200 Subject: [PATCH 067/147] creation of ATT and BOO payment event --- htdocs/public/payment/paymentok.php | 162 +++++++++++++++++++++------- 1 file changed, 123 insertions(+), 39 deletions(-) diff --git a/htdocs/public/payment/paymentok.php b/htdocs/public/payment/paymentok.php index 90cf38a6051..950d68560b5 100644 --- a/htdocs/public/payment/paymentok.php +++ b/htdocs/public/payment/paymentok.php @@ -156,45 +156,6 @@ $object = new stdClass(); // For triggers $error = 0; -// After a conference attendee payment -if ($subscription == 'subscriptionok' && $ref == $reffrompayment) { - // Looking for the invoice to which add a payment - $paidinvoice = new Facture($db); - $resultinvoice = $paidinvoice->fetch($invoiceref); - if ($resultinvoice < 0) { - setEventMessages(null, $paidinvoice->errors, "errors"); - } else { - // Finding thirdparty - $thirdparty = new Societe($db); - $resultthirdparty = $thirdparty->fetch($paidinvoice->socid); - if ($resultthirdparty <= 0) { - $mesg = $thirdparty->error; - $error++; - } else { - // 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); - } - } - } - } -} - /* * Actions */ @@ -822,6 +783,129 @@ if ($ispaymentok) { $postactionmessages[] = 'Invoice paid '.$tmptag['INV'].' was not found'; $ispostactionok = -1; } + } elseif (array_key_exists('ATT', $tmptag) && $tmptag['INV'] > 0) { + // Record payment + include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; + $object = new Facture($db); + $result = $object->fetch($tmptag['INV']); + if ($result) { + $FinalPaymentAmt = $_SESSION["FinalPaymentAmt"]; + + $paymentTypeId = 0; + if ($paymentmethod == 'paybox') { + $paymentTypeId = $conf->global->PAYBOX_PAYMENT_MODE_FOR_PAYMENTS; + } + if ($paymentmethod == 'paypal') { + $paymentTypeId = $conf->global->PAYPAL_PAYMENT_MODE_FOR_PAYMENTS; + } + if ($paymentmethod == 'stripe') { + $paymentTypeId = $conf->global->STRIPE_PAYMENT_MODE_FOR_PAYMENTS; + } + if (empty($paymentTypeId)) { + $paymentType = $_SESSION["paymentType"]; + if (empty($paymentType)) { + $paymentType = 'CB'; + } + $paymentTypeId = dol_getIdFromCode($db, $paymentType, 'c_paiement', 'code', 'id', 1); + } + + $currencyCodeType = $_SESSION['currencyCodeType']; + + // 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) { + $db->begin(); + + // Creation of payment line + include_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php'; + $paiement = new Paiement($db); + $paiement->datepaye = $now; + if ($currencyCodeType == $conf->currency) { + $paiement->amounts = array($object->id => $FinalPaymentAmt); // Array with all payments dispatching with invoice id + } else { + $paiement->multicurrency_amounts = array($object->id => $FinalPaymentAmt); // Array with all payments dispatching + + $postactionmessages[] = 'Payment was done in a different currency that currency expected of company'; + $ispostactionok = -1; + $error++; // Not yet supported + } + $paiement->paiementid = $paymentTypeId; + $paiement->num_payment = ''; + $paiement->note_public = 'Online payment '.dol_print_date($now, 'standard').' from '.$ipaddress; + $paiement->ext_payment_id = $TRANSACTIONID; + $paiement->ext_payment_site = $service; + + if (!$error) { + $paiement_id = $paiement->create($user, 1); // This include closing invoices and regenerating documents + if ($paiement_id < 0) { + $postactionmessages[] = $paiement->error.' '.join("
\n", $paiement->errors); + $ispostactionok = -1; + $error++; + } else { + $postactionmessages[] = 'Payment created'; + $ispostactionok = 1; + } + } + + if (!$error && !empty($conf->banque->enabled)) { + $bankaccountid = 0; + if ($paymentmethod == 'paybox') { + $bankaccountid = $conf->global->PAYBOX_BANK_ACCOUNT_FOR_PAYMENTS; + } elseif ($paymentmethod == 'paypal') { + $bankaccountid = $conf->global->PAYPAL_BANK_ACCOUNT_FOR_PAYMENTS; + } elseif ($paymentmethod == 'stripe') { + $bankaccountid = $conf->global->STRIPE_BANK_ACCOUNT_FOR_PAYMENTS; + } + + if ($bankaccountid > 0) { + $label = '(CustomerInvoicePayment)'; + if ($object->type == Facture::TYPE_CREDIT_NOTE) { + $label = '(CustomerInvoicePaymentBack)'; // Refund of a credit note + } + $result = $paiement->addPaymentToBank($user, 'payment', $label, $bankaccountid, '', ''); + if ($result < 0) { + $postactionmessages[] = $paiement->error.' '.join("
\n", $paiement->errors); + $ispostactionok = -1; + $error++; + } else { + $postactionmessages[] = 'Bank transaction of payment created'; + $ispostactionok = 1; + } + } else { + $postactionmessages[] = 'Setup of bank account to use in module '.$paymentmethod.' was not set. No way to record the payment.'; + $ispostactionok = -1; + $error++; + } + } + + if (!$error) { + $db->commit(); + + // Validating the attendee + $attendeetovalidate = new ConferenceOrBoothAttendee($db); + $resultattendee = $attendeetovalidate->fetch($ref); + if ($resultattendee < 0) { + setEventMessages(null, $attendeetovalidate->errors, "errors"); + } 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; + + } 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.'; + $ispostactionok = -1; + } + + } else { + $postactionmessages[] = 'Invoice paid '.$tmptag['INV'].' was not found'; + $ispostactionok = -1; + } + } elseif (array_key_exists('BOO', $tmptag) && $tmptag['INV'] > 0) { + // BOOTH CASE (to copy and adapt from above) } else { // Nothing done } From b70e477f471a571408f2521b72533558f0ca3d0c Mon Sep 17 00:00:00 2001 From: Dorian Vabre Date: Tue, 20 Apr 2021 14:49:11 +0200 Subject: [PATCH 068/147] 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 From 07cd751c59046fb837bece52a4cbb9d5c25cd73c Mon Sep 17 00:00:00 2001 From: altairis-noe Date: Tue, 20 Apr 2021 15:51:02 +0200 Subject: [PATCH 069/147] batch status dictionnary --- htdocs/admin/dict.php | 13 ++++++++- .../mysql/data/llx_c_productbatch_status.sql | 28 +++++++++++++++++++ .../tables/llx_c_productbatch_status.key.sql | 19 +++++++++++++ .../tables/llx_c_productbatch_status.sql | 25 +++++++++++++++++ htdocs/langs/en_US/admin.lang | 1 + htdocs/langs/en_US/productbatch.lang | 5 ++-- htdocs/langs/fr_FR/admin.lang | 1 + htdocs/langs/fr_FR/productbatch.lang | 6 ++-- 8 files changed, 93 insertions(+), 5 deletions(-) create mode 100644 htdocs/install/mysql/data/llx_c_productbatch_status.sql create mode 100644 htdocs/install/mysql/tables/llx_c_productbatch_status.key.sql create mode 100644 htdocs/install/mysql/tables/llx_c_productbatch_status.sql diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php index 9061fd150b7..8efbbf4cbfa 100644 --- a/htdocs/admin/dict.php +++ b/htdocs/admin/dict.php @@ -100,7 +100,7 @@ $hookmanager->initHooks(array('admin')); // Put here declaration of dictionaries properties // Sort order to show dictionary (0 is space). All other dictionaries (added by modules) will be at end of this. -$taborder = array(9, 0, 4, 3, 2, 0, 1, 8, 19, 16, 39, 27, 40, 38, 0, 5, 11, 0, 32, 33, 34, 0, 6, 0, 29, 0, 7, 24, 28, 17, 35, 36, 0, 10, 23, 12, 13, 0, 14, 0, 22, 20, 18, 21, 41, 0, 15, 30, 0, 37, 42, 0, 25, 0); +$taborder = array(9, 0, 4, 3, 2, 0, 1, 8, 19, 16, 39, 27, 40, 38, 0, 5, 11, 0, 32, 33, 34, 0, 6, 0, 29, 0, 7, 24, 28, 17, 35, 36, 0, 10, 23, 12, 13, 0, 14, 0, 22, 20, 18, 21, 41, 0, 15, 30, 0, 37, 42, 0, 25, 0, 43, 0); // Name of SQL tables of dictionaries $tabname = array(); @@ -146,6 +146,7 @@ $tabname[39] = MAIN_DB_PREFIX."c_prospectcontactlevel"; $tabname[40] = MAIN_DB_PREFIX."c_stcommcontact"; $tabname[41] = MAIN_DB_PREFIX."c_transport_mode"; $tabname[42] = MAIN_DB_PREFIX."c_product_nature"; +$tabname[43] = MAIN_DB_PREFIX."c_productbatch_status"; // Dictionary labels $tablib = array(); @@ -191,6 +192,7 @@ $tablib[39] = "DictionaryProspectContactLevel"; $tablib[40] = "DictionaryProspectContactStatus"; $tablib[41] = "DictionaryTransportMode"; $tablib[42] = "DictionaryProductNature"; +$tablib[43] = "DictionaryBatchStatus"; // Requests to extract data $tabsql = array(); @@ -236,6 +238,7 @@ $tabsql[39] = "SELECT code, label as libelle, sortorder, active FROM ".MAIN_DB_P $tabsql[40] = "SELECT id as rowid, code, libelle, picto, active FROM ".MAIN_DB_PREFIX."c_stcommcontact"; $tabsql[41] = "SELECT rowid as rowid, code, label, active FROM ".MAIN_DB_PREFIX."c_transport_mode"; $tabsql[42] = "SELECT rowid as rowid, code, label, active FROM ".MAIN_DB_PREFIX."c_product_nature"; +$tabsql[43] = "SELECT rowid, code, label, active FROM ".MAIN_DB_PREFIX."c_productbatch_status"; // Criteria to sort dictionaries $tabsqlsort = array(); @@ -281,6 +284,7 @@ $tabsqlsort[39] = "sortorder ASC"; $tabsqlsort[40] = "code ASC"; $tabsqlsort[41] = "code ASC"; $tabsqlsort[42] = "code ASC"; +$tabsqlsort[43] = "code ASC"; // Field names in select result for dictionary display $tabfield = array(); @@ -326,6 +330,7 @@ $tabfield[39] = "code,libelle,sortorder"; $tabfield[40] = "code,libelle,picto"; $tabfield[41] = "code,label"; $tabfield[42] = "code,label"; +$tabfield[43] = "code,label"; // Edit field names for editing a record $tabfieldvalue = array(); @@ -371,6 +376,7 @@ $tabfieldvalue[39] = "code,libelle,sortorder"; $tabfieldvalue[40] = "code,libelle,picto"; $tabfieldvalue[41] = "code,label"; $tabfieldvalue[42] = "code,label"; +$tabfieldvalue[43] = "code,label"; // Field names in the table for inserting a record $tabfieldinsert = array(); @@ -417,6 +423,7 @@ $tabfieldinsert[39] = "code,label,sortorder"; $tabfieldinsert[40] = "code,libelle,picto"; $tabfieldinsert[41] = "code,label"; $tabfieldinsert[42] = "code,label"; +$tabfieldinsert[43] = "code,label"; // Rowid name of field depending if field is autoincrement on or off.. // Use "" if id field is "rowid" and has autoincrement on @@ -464,6 +471,7 @@ $tabrowid[39] = "code"; $tabrowid[40] = "id"; $tabrowid[41] = ""; $tabrowid[42] = "rowid"; +$tabrowid[43] = "rowid"; // Condition to show dictionary in setup page $tabcond = array(); @@ -509,6 +517,7 @@ $tabcond[39] = (!empty($conf->societe->enabled) && empty($conf->global->SOCIETE_ $tabcond[40] = (!empty($conf->societe->enabled) && !empty($conf->global->THIRDPARTY_ENABLE_PROSPECTION_ON_ALTERNATIVE_ADRESSES)); $tabcond[41] = !empty($conf->intracommreport->enabled); $tabcond[42] = !empty($conf->product->enabled); +$tabcond[43] = !empty($conf->product->enabled && !empty($conf->productbatch->enabled)); // List of help for fields $tabhelp = array(); @@ -554,6 +563,7 @@ $tabhelp[39] = array('code'=>$langs->trans("EnterAnyCode")); $tabhelp[40] = array('code'=>$langs->trans("EnterAnyCode"), 'picto'=>$langs->trans("PictoHelp")); $tabhelp[41] = array('code'=>$langs->trans("EnterAnyCode")); $tabhelp[42] = array('code'=>$langs->trans("EnterAnyCode")); +$tabhelp[43] = array('code'=>$langs->trans("EnterAnyCode")); // List of check for fields (NOT USED YET) $tabfieldcheck = array(); @@ -599,6 +609,7 @@ $tabfieldcheck[39] = array(); $tabfieldcheck[40] = array(); $tabfieldcheck[41] = array(); $tabfieldcheck[42] = array(); +$tabfieldcheck[43] = array(); // Complete all arrays with entries found into modules complete_dictionary_with_modules($taborder, $tabname, $tablib, $tabsql, $tabsqlsort, $tabfield, $tabfieldvalue, $tabfieldinsert, $tabrowid, $tabcond, $tabhelp, $tabfieldcheck); diff --git a/htdocs/install/mysql/data/llx_c_productbatch_status.sql b/htdocs/install/mysql/data/llx_c_productbatch_status.sql new file mode 100644 index 00000000000..a4628e0bd91 --- /dev/null +++ b/htdocs/install/mysql/data/llx_c_productbatch_status.sql @@ -0,0 +1,28 @@ +-- Copyright (C) 2021 Noé Cendrier +-- +-- This program is free software; you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation; either version 3 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program. If not, see . +-- +-- + +-- +-- Do not place a comment at the end of the line, this file is parsed when +-- from the install and all '--' are removed. +-- +-- Ne pas placer de commentaire en fin de ligne, ce fichier est parsé lors +-- de l'install et tous les sigles '--' sont supprimés. +-- + +INSERT INTO llx_c_productbatch_status (code, label, active) VALUES ('OK', 'ProductCanBeUsed', 1); +INSERT INTO llx_c_productbatch_status (code, label, active) VALUES ('KO', 'OutOfOrder', 1); + diff --git a/htdocs/install/mysql/tables/llx_c_productbatch_status.key.sql b/htdocs/install/mysql/tables/llx_c_productbatch_status.key.sql new file mode 100644 index 00000000000..fc72f556a97 --- /dev/null +++ b/htdocs/install/mysql/tables/llx_c_productbatch_status.key.sql @@ -0,0 +1,19 @@ +-- ======================================================================== +-- Copyright (C) 2021 Noé Cendrier +-- +-- This program is free software; you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation; either version 3 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program. If not, see . +-- +-- ======================================================================== + +ALTER TABLE llx_c_productbatch_status ADD UNIQUE INDEX uk_c_productbatch_status(code); diff --git a/htdocs/install/mysql/tables/llx_c_productbatch_status.sql b/htdocs/install/mysql/tables/llx_c_productbatch_status.sql new file mode 100644 index 00000000000..2ffad7f5939 --- /dev/null +++ b/htdocs/install/mysql/tables/llx_c_productbatch_status.sql @@ -0,0 +1,25 @@ +-- ======================================================================== +-- Copyright (C) 2012-2017 Noé Cendrier +-- +-- This program is free software; you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation; either version 2 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program. If not, see . +-- +-- ======================================================================== + +create table llx_c_productbatch_status +( + rowid integer AUTO_INCREMENT PRIMARY KEY, + code varchar(16) NOT NULL, + label varchar(50) NOT NULL, + active integer DEFAULT 1 NOT NULL +)ENGINE=innodb; diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index b103d0082ba..5d336524798 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -1043,6 +1043,7 @@ DictionaryOpportunityStatus=Lead status for project/lead DictionaryExpenseTaxCat=Expense report - Transportation categories DictionaryExpenseTaxRange=Expense report - Range by transportation category DictionaryTransportMode=Intracomm report - Transport mode +DictionaryBatchStatus=Product batch status TypeOfUnit=Type of unit SetupSaved=Setup saved SetupNotSaved=Setup not saved diff --git a/htdocs/langs/en_US/productbatch.lang b/htdocs/langs/en_US/productbatch.lang index 4414b6ad8d8..dc1cccd7d7b 100644 --- a/htdocs/langs/en_US/productbatch.lang +++ b/htdocs/langs/en_US/productbatch.lang @@ -1,4 +1,4 @@ -# ProductBATCH language file - en_US - ProductBATCH +# ProductBATCH language file - Source file is en_US - ProductBATCH ManageLotSerial=Use lot/serial number ProductStatusOnBatch=Yes (lot required) ProductStatusOnSerial=Yes (unique serial number required) @@ -32,4 +32,5 @@ CustomMasks=Adds an option to define mask in the product card LotProductTooltip=Adds an option in the product card to define a dedicated batch number mask SNProductTooltip=Adds an option in the product card to define a dedicated serial number mask QtyToAddAfterBarcodeScan=Qty to add for each barcode/lot/serial scanned - +OutOfOrder=Out of order +ProductCanBeUsed=Functional diff --git a/htdocs/langs/fr_FR/admin.lang b/htdocs/langs/fr_FR/admin.lang index ef48fc0a82d..a9a5327e924 100644 --- a/htdocs/langs/fr_FR/admin.lang +++ b/htdocs/langs/fr_FR/admin.lang @@ -1034,6 +1034,7 @@ DictionaryOpportunityStatus=Statut d'opportunités pour les affaires/projets DictionaryExpenseTaxCat=Note de frais - catégories de déplacement DictionaryExpenseTaxRange=Note de frais - Tri par catégorie de déplacement DictionaryTransportMode=Déclaration d'échanges intracommunautaires - Mode de transport +DictionaryBatchStatus=État du lot (produits) TypeOfUnit=Type d'unité SetupSaved=Configuration sauvegardée SetupNotSaved=Configuration non enregistrée diff --git a/htdocs/langs/fr_FR/productbatch.lang b/htdocs/langs/fr_FR/productbatch.lang index cd38ac89278..ce8eae07253 100644 --- a/htdocs/langs/fr_FR/productbatch.lang +++ b/htdocs/langs/fr_FR/productbatch.lang @@ -1,4 +1,4 @@ -# ProductBATCH language file - en_US - ProductBATCH +# ProductBATCH language file - Source file is en_US - ProductBATCH ManageLotSerial=Utiliser les numéros de lots/série ProductStatusOnBatch=Lot (requis) ProductStatusOnSerial=Numéro de série (doit être unique pour chaque équipement) @@ -30,4 +30,6 @@ BatchLotNumberingModules=Modèle de génération et contrôle des numéros de lo BatchSerialNumberingModules=Modèle de génération et contrôle des numéros de série CustomMasks=Ajoute une option pour définir le masque dans la fiche produit LotProductTooltip=Crée un champ dans la fiche produit pour définir un modèle spécifique de numéro de lot -SNProductTooltip=Crée un champ dans la fiche produit pour définir un modèle spécifique de numéro de série \ No newline at end of file +SNProductTooltip=Crée un champ dans la fiche produit pour définir un modèle spécifique de numéro de série +OutOfOrder=Hors d'usage +ProductCanBeUsed=En état de marche \ No newline at end of file From a500d83c0bb988f18eb7217ec8843abfb2a87430 Mon Sep 17 00:00:00 2001 From: Dorian Vabre Date: Tue, 20 Apr 2021 16:09:22 +0200 Subject: [PATCH 070/147] linked invoice and attendee --- htdocs/core/class/commonobject.class.php | 5 +++ .../attendee_subscription.php | 3 +- htdocs/public/payment/newpayment.php | 37 +++++++++++-------- 3 files changed, 28 insertions(+), 17 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index a93acda2a17..2c9e81b369e 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -3820,6 +3820,11 @@ abstract class CommonObject $classpath = 'projet/class'; $classfile = 'project'; $classname = 'Project'; + } elseif ($objecttype == 'conferenceorboothattendee') { + $classpath = 'eventorganization/class'; + $classfile = 'conferenceorboothattendee'; + $classname = 'ConferenceOrBoothAttendee'; + $module = 'eventorganization'; } // Here $module, $classfile and $classname are set diff --git a/htdocs/public/eventorganization/attendee_subscription.php b/htdocs/public/eventorganization/attendee_subscription.php index 56855c70b62..0f92400b5f2 100644 --- a/htdocs/public/eventorganization/attendee_subscription.php +++ b/htdocs/public/eventorganization/attendee_subscription.php @@ -321,12 +321,13 @@ if (empty($reshook) && $action == 'add') { $confattendee->errors[] = $confattendee->error; } } - $resultfacture = $facture->create($user); if ($resultfacture <= 0) { $confattendee->error = $facture->error; $confattendee->errors = $facture->errors; $error++; + } else { + $facture->add_object_linked($confattendee->element, $confattendee->id); } } diff --git a/htdocs/public/payment/newpayment.php b/htdocs/public/payment/newpayment.php index 75d72b4bbea..06f81fccea3 100644 --- a/htdocs/public/payment/newpayment.php +++ b/htdocs/public/payment/newpayment.php @@ -117,17 +117,30 @@ if ($source == 'conferencesubscription') { $invoice = new Facture($db); $resultinvoice = $invoice->fetch($decodedinvoiceid); if ($resultinvoice <= 0) { - $mesg = $invoice->error; - $error++; + setEventMessages(null, $invoice->errors, "errors"); } else { + $invoice->fetchObjectLinked(); // Finding the thirdparty associated to the Attendee $thirdparty = new Societe($db); $resultthirdparty = $thirdparty->fetch($invoice->socid); if ($resultthirdparty <= 0) { - $mesg = $thirdparty->error; - $error++; + setEventMessages(null, $thirdparty->errors, "errors"); } $object = $thirdparty; + + $linkedAttendees = $invoice->linkedObjectsIds['conferenceorboothattendee']; + + if (is_array($linkedAttendees)) { + $linkedAttendees = array_values($linkedAttendees); + + $attendee = new ConferenceOrBoothAttendee($db); + $resultattendee = $attendee->fetch($linkedAttendees[0]); + if ($resultattendee <= 0) { + setEventMessages(null, $attendee->errors, "errors"); + } + var_dump($attendee); + exit; + } } } @@ -363,7 +376,7 @@ if ($action == 'dopayment') { // A redirect is added if API call successfull if ($source == 'conferencesubscription') { - $PAYPAL_API_OK .= '&conferencesubscription='.dol_encode('subscriptionok'.$ref, $dolibarr_main_instance_unique_id).'&invoice='.dol_encode($invoice->id, $dolibarr_main_instance_unique_id); + $PAYPAL_API_OK .= '&invoice='.dol_encode($invoice->id, $dolibarr_main_instance_unique_id); } $mesg = print_paypal_redirect($PAYPAL_API_PRICE, $PAYPAL_API_DEVISE, $PAYPAL_PAYMENT_TYPE, $PAYPAL_API_OK, $PAYPAL_API_KO, $FULLTAG); @@ -384,7 +397,7 @@ if ($action == 'dopayment') { $urlko = preg_replace('/securekey=[^&]+/', '', $urlko); if ($source == 'conferencesubscription') { - $urlok .= '&conferencesubscription='.dol_encode('subscriptionok'.$ref, $dolibarr_main_instance_unique_id).'&invoice='.dol_encode($invoice->id, $dolibarr_main_instance_unique_id); + $urlok .= '&invoice='.dol_encode($invoice->id, $dolibarr_main_instance_unique_id); } $mesg = ''; @@ -742,7 +755,7 @@ if ($action == 'charge' && !empty($conf->stripe->enabled)) { exit; } else { if ($source == 'conferencesubscription') { - $urlok .= '&conferencesubscription='.dol_encode('subscriptionok'.$ref, $dolibarr_main_instance_unique_id).'&invoice='.dol_encode($invoice->id, $dolibarr_main_instance_unique_id); + $urlok .= '&invoice='.dol_encode($invoice->id, $dolibarr_main_instance_unique_id); } header("Location: ".$urlok); exit; @@ -1763,18 +1776,10 @@ if ($source == 'conferencesubscription') { $found = true; $langs->load("members"); - if ($action != 'dopayment') { // Do not change amount if we just click on first dopayment - $amount = $project->price_registration; - if (GETPOST("amount", 'alpha')) { - $amount = GETPOST("amount", 'alpha'); - } - $amount = price2num($amount, 'MT'); - } - if (GETPOST('fulltag', 'alpha')) { $fulltag = GETPOST('fulltag', 'alpha'); } else { - $fulltag = 'MEM='.$member->id.'.DAT='.dol_print_date(dol_now(), '%Y%m%d%H%M%S'); + $fulltag = 'ATT='.$attendee->id.'.DAT='.dol_print_date(dol_now(), '%Y%m%d%H%M%S'); if (!empty($TAG)) { $tag = $TAG; $fulltag .= '.TAG='.$TAG; } From d340e21cb3ba468f24bdd04cdc21bdc46d4e00c7 Mon Sep 17 00:00:00 2001 From: altairis-noe Date: Tue, 20 Apr 2021 16:13:36 +0200 Subject: [PATCH 071/147] No translation for dictionary labels --- htdocs/install/mysql/data/llx_c_productbatch_status.sql | 4 ++-- htdocs/langs/en_US/productbatch.lang | 2 -- htdocs/langs/fr_FR/productbatch.lang | 4 +--- 3 files changed, 3 insertions(+), 7 deletions(-) diff --git a/htdocs/install/mysql/data/llx_c_productbatch_status.sql b/htdocs/install/mysql/data/llx_c_productbatch_status.sql index a4628e0bd91..ebe64ff3a26 100644 --- a/htdocs/install/mysql/data/llx_c_productbatch_status.sql +++ b/htdocs/install/mysql/data/llx_c_productbatch_status.sql @@ -23,6 +23,6 @@ -- de l'install et tous les sigles '--' sont supprimés. -- -INSERT INTO llx_c_productbatch_status (code, label, active) VALUES ('OK', 'ProductCanBeUsed', 1); -INSERT INTO llx_c_productbatch_status (code, label, active) VALUES ('KO', 'OutOfOrder', 1); +INSERT INTO llx_c_productbatch_status (code, label, active) VALUES ('OK', 'En état de marche', 1); +INSERT INTO llx_c_productbatch_status (code, label, active) VALUES ('KO', "Hors d'usage", 1); diff --git a/htdocs/langs/en_US/productbatch.lang b/htdocs/langs/en_US/productbatch.lang index dc1cccd7d7b..92c224b55f5 100644 --- a/htdocs/langs/en_US/productbatch.lang +++ b/htdocs/langs/en_US/productbatch.lang @@ -32,5 +32,3 @@ CustomMasks=Adds an option to define mask in the product card LotProductTooltip=Adds an option in the product card to define a dedicated batch number mask SNProductTooltip=Adds an option in the product card to define a dedicated serial number mask QtyToAddAfterBarcodeScan=Qty to add for each barcode/lot/serial scanned -OutOfOrder=Out of order -ProductCanBeUsed=Functional diff --git a/htdocs/langs/fr_FR/productbatch.lang b/htdocs/langs/fr_FR/productbatch.lang index ce8eae07253..c3e48ddbeb1 100644 --- a/htdocs/langs/fr_FR/productbatch.lang +++ b/htdocs/langs/fr_FR/productbatch.lang @@ -30,6 +30,4 @@ BatchLotNumberingModules=Modèle de génération et contrôle des numéros de lo BatchSerialNumberingModules=Modèle de génération et contrôle des numéros de série CustomMasks=Ajoute une option pour définir le masque dans la fiche produit LotProductTooltip=Crée un champ dans la fiche produit pour définir un modèle spécifique de numéro de lot -SNProductTooltip=Crée un champ dans la fiche produit pour définir un modèle spécifique de numéro de série -OutOfOrder=Hors d'usage -ProductCanBeUsed=En état de marche \ No newline at end of file +SNProductTooltip=Crée un champ dans la fiche produit pour définir un modèle spécifique de numéro de série \ No newline at end of file From 5ad64640c2270c2dc41c7bc598afe70531c0b0dc Mon Sep 17 00:00:00 2001 From: Dorian Vabre Date: Tue, 20 Apr 2021 16:26:11 +0200 Subject: [PATCH 072/147] removal of var_dump --- htdocs/public/payment/newpayment.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/htdocs/public/payment/newpayment.php b/htdocs/public/payment/newpayment.php index 06f81fccea3..22efe3d18af 100644 --- a/htdocs/public/payment/newpayment.php +++ b/htdocs/public/payment/newpayment.php @@ -138,8 +138,6 @@ if ($source == 'conferencesubscription') { if ($resultattendee <= 0) { setEventMessages(null, $attendee->errors, "errors"); } - var_dump($attendee); - exit; } } } From f1d68c201b6169bc6f8d19df2e7806e96f003cf2 Mon Sep 17 00:00:00 2001 From: altairis-noe Date: Tue, 20 Apr 2021 16:56:15 +0200 Subject: [PATCH 073/147] conflict resolution --- htdocs/langs/en_US/productbatch.lang | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/langs/en_US/productbatch.lang b/htdocs/langs/en_US/productbatch.lang index 92c224b55f5..aedf85a4fb8 100644 --- a/htdocs/langs/en_US/productbatch.lang +++ b/htdocs/langs/en_US/productbatch.lang @@ -32,3 +32,4 @@ CustomMasks=Adds an option to define mask in the product card LotProductTooltip=Adds an option in the product card to define a dedicated batch number mask SNProductTooltip=Adds an option in the product card to define a dedicated serial number mask QtyToAddAfterBarcodeScan=Qty to add for each barcode/lot/serial scanned + From 4c57a6c207636ba44cf2256c829d3a93d9a0c2de Mon Sep 17 00:00:00 2001 From: Dorian Vabre Date: Tue, 20 Apr 2021 17:28:18 +0200 Subject: [PATCH 074/147] wip on mail, sending ok but no content --- htdocs/core/class/CMailFile.class.php | 1 - htdocs/langs/en_US/eventorganization.lang | 4 ++ .../attendee_subscription.php | 46 +++++++++++++++++++ 3 files changed, 50 insertions(+), 1 deletion(-) diff --git a/htdocs/core/class/CMailFile.class.php b/htdocs/core/class/CMailFile.class.php index 863bb9a6794..526c464403f 100644 --- a/htdocs/core/class/CMailFile.class.php +++ b/htdocs/core/class/CMailFile.class.php @@ -584,7 +584,6 @@ class CMailFile if ($reshook < 0) { $this->error = "Error in hook maildao sendMail ".$reshook; dol_syslog("CMailFile::sendfile: mail end error=".$this->error, LOG_ERR); - return $reshook; } if ($reshook == 1) { // Hook replace standard code diff --git a/htdocs/langs/en_US/eventorganization.lang b/htdocs/langs/en_US/eventorganization.lang index 9e2df362467..5ddd3d259ea 100644 --- a/htdocs/langs/en_US/eventorganization.lang +++ b/htdocs/langs/en_US/eventorganization.lang @@ -113,6 +113,10 @@ ConferenceAttendeeFee = Conference attendee fee # SubscriptionOk = Your subscription to this conference has been validated # +# Subscription validation mail +# +ConfAttendeeSubscriptionConfirmation = Confirmation of your subscription to a conference +# # Payment page # Attendee = Participant diff --git a/htdocs/public/eventorganization/attendee_subscription.php b/htdocs/public/eventorganization/attendee_subscription.php index 0f92400b5f2..cad279687e7 100644 --- a/htdocs/public/eventorganization/attendee_subscription.php +++ b/htdocs/public/eventorganization/attendee_subscription.php @@ -350,6 +350,52 @@ if (empty($reshook) && $action == 'add') { // No price has been set // Validating the subscription $confattendee->setStatut(1); + + // Sending mail + 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, '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 = $msg; + + $sendto = $thirdparty->email; + $from = $conf->global->MAILING_EMAIL_FROM; + $urlback = $_SERVER["REQUEST_URI"]; + $topic = $langs->trans("ConfAttendeeSubscriptionConfirmation"); + + $ishtml = dol_textishtml($texttosend); // May contain urls + + $mailfile = new CMailFile($topic, $sendto, $from, $texttosend, array(), array(), array(), '', '', 0, $ishtml); + + $result = $mailfile->sendfile(); + var_dump($result); + 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'); + } + $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; From 86812c13ee4e1dbef605568ab2da0d2af4af93cc Mon Sep 17 00:00:00 2001 From: altairis-noe Date: Wed, 21 Apr 2021 09:18:40 +0200 Subject: [PATCH 075/147] no double quote --- htdocs/install/mysql/data/llx_c_productbatch_status.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/install/mysql/data/llx_c_productbatch_status.sql b/htdocs/install/mysql/data/llx_c_productbatch_status.sql index ebe64ff3a26..c925c0cd937 100644 --- a/htdocs/install/mysql/data/llx_c_productbatch_status.sql +++ b/htdocs/install/mysql/data/llx_c_productbatch_status.sql @@ -24,5 +24,5 @@ -- INSERT INTO llx_c_productbatch_status (code, label, active) VALUES ('OK', 'En état de marche', 1); -INSERT INTO llx_c_productbatch_status (code, label, active) VALUES ('KO', "Hors d'usage", 1); +INSERT INTO llx_c_productbatch_status (code, label, active) VALUES ('KO', 'Hors d’usage', 1); From 790ff0c64c1a7c93392f87c614e5180ec88356f8 Mon Sep 17 00:00:00 2001 From: Dorian Vabre Date: Wed, 21 Apr 2021 10:48:37 +0200 Subject: [PATCH 076/147] mail template working, but info in it not replaced by values --- htdocs/public/eventorganization/attendee_subscription.php | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/htdocs/public/eventorganization/attendee_subscription.php b/htdocs/public/eventorganization/attendee_subscription.php index cad279687e7..6cad964446f 100644 --- a/htdocs/public/eventorganization/attendee_subscription.php +++ b/htdocs/public/eventorganization/attendee_subscription.php @@ -364,9 +364,8 @@ if (empty($reshook) && $action == 'add') { $arraydefaultmessage = null; $labeltouse = $conf->global->EVENTORGANIZATION_TEMPLATE_EMAIL_AFT_SUBS_EVENT; - if (!empty($labeltouse)) { - $arraydefaultmessage = $formmail->getEMailTemplate($db, 'member', $user, $outputlangs, 0, 1, $labeltouse); + $arraydefaultmessage = $formmail->getEMailTemplate($db, 'eventorganization_send', $user, $outputlangs, $labeltouse, 1, ''); } if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) { @@ -377,16 +376,15 @@ if (empty($reshook) && $action == 'add') { $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object); complete_substitutions_array($substitutionarray, $outputlangs, $object); $subjecttosend = make_substitutions($subject, $substitutionarray, $outputlangs); - $texttosend = $msg; + $texttosend = make_substitutions($msg, $substitutionarray, $outputlangs); $sendto = $thirdparty->email; $from = $conf->global->MAILING_EMAIL_FROM; $urlback = $_SERVER["REQUEST_URI"]; - $topic = $langs->trans("ConfAttendeeSubscriptionConfirmation"); $ishtml = dol_textishtml($texttosend); // May contain urls - $mailfile = new CMailFile($topic, $sendto, $from, $texttosend, array(), array(), array(), '', '', 0, $ishtml); + $mailfile = new CMailFile($subjecttosend, $sendto, $from, $texttosend, array(), array(), array(), '', '', 0, $ishtml); $result = $mailfile->sendfile(); var_dump($result); From 7a65a1768a10fb9b45ab83de56300449d05983b6 Mon Sep 17 00:00:00 2001 From: Dorian Vabre Date: Wed, 21 Apr 2021 11:57:03 +0200 Subject: [PATCH 077/147] wip on mail content --- htdocs/public/eventorganization/attendee_subscription.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/htdocs/public/eventorganization/attendee_subscription.php b/htdocs/public/eventorganization/attendee_subscription.php index 6cad964446f..727f2c64d6f 100644 --- a/htdocs/public/eventorganization/attendee_subscription.php +++ b/htdocs/public/eventorganization/attendee_subscription.php @@ -373,8 +373,11 @@ if (empty($reshook) && $action == 'add') { $msg = $arraydefaultmessage->content; } - $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object); + $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $thirdparty); complete_substitutions_array($substitutionarray, $outputlangs, $object); + + $substitutionarray['ThisIsContentOfYourOrganizationEventEventSubscriptionWasReceived'] = 'Vous êtes bien enregistré.'; + $subjecttosend = make_substitutions($subject, $substitutionarray, $outputlangs); $texttosend = make_substitutions($msg, $substitutionarray, $outputlangs); @@ -387,7 +390,6 @@ if (empty($reshook) && $action == 'add') { $mailfile = new CMailFile($subjecttosend, $sendto, $from, $texttosend, array(), array(), array(), '', '', 0, $ishtml); $result = $mailfile->sendfile(); - var_dump($result); if ($result) { dol_syslog("EMail sent to ".$sendto, LOG_DEBUG, 0, '_payment'); } else { From 780b3f4714d8db3f07308ed0b51139bcfeff2da0 Mon Sep 17 00:00:00 2001 From: Dorian Vabre Date: Wed, 21 Apr 2021 13:41:30 +0200 Subject: [PATCH 078/147] target:blank added for the link to the registration pag --- htdocs/eventorganization/conferenceorbooth_list.php | 2 +- htdocs/public/eventorganization/attendee_subscription.php | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/htdocs/eventorganization/conferenceorbooth_list.php b/htdocs/eventorganization/conferenceorbooth_list.php index feb202de663..cbf0e91f7fa 100644 --- a/htdocs/eventorganization/conferenceorbooth_list.php +++ b/htdocs/eventorganization/conferenceorbooth_list.php @@ -368,7 +368,7 @@ if ($projectid > 0) { $linkregister = $dolibarr_main_url_root.'/public/project/index.php?id='.$encodedid; $encodedsecurekey = dol_encode($conf->global->EVENTORGANIZATION_SECUREKEY.$encodedid, $dolibarr_main_instance_unique_id); $linkregister .= '&securekey='.urlencode($encodedsecurekey); - print ''.$linkregister.''; + print ''.$linkregister.''; print ''; // Other attributes diff --git a/htdocs/public/eventorganization/attendee_subscription.php b/htdocs/public/eventorganization/attendee_subscription.php index 727f2c64d6f..22b6955c6f5 100644 --- a/htdocs/public/eventorganization/attendee_subscription.php +++ b/htdocs/public/eventorganization/attendee_subscription.php @@ -376,8 +376,6 @@ if (empty($reshook) && $action == 'add') { $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $thirdparty); complete_substitutions_array($substitutionarray, $outputlangs, $object); - $substitutionarray['ThisIsContentOfYourOrganizationEventEventSubscriptionWasReceived'] = 'Vous êtes bien enregistré.'; - $subjecttosend = make_substitutions($subject, $substitutionarray, $outputlangs); $texttosend = make_substitutions($msg, $substitutionarray, $outputlangs); From 9809179aa45bb22f107b82a27e9dc1f88a774e2b Mon Sep 17 00:00:00 2001 From: Dorian Vabre Date: Wed, 21 Apr 2021 14:19:07 +0200 Subject: [PATCH 079/147] securekey added to newpayment page, correction in the invoice line created --- htdocs/langs/en_US/eventorganization.lang | 2 +- .../eventorganization/attendee_subscription.php | 15 +++++++++++++-- htdocs/public/payment/newpayment.php | 3 +++ 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/htdocs/langs/en_US/eventorganization.lang b/htdocs/langs/en_US/eventorganization.lang index 5ddd3d259ea..863cec82164 100644 --- a/htdocs/langs/en_US/eventorganization.lang +++ b/htdocs/langs/en_US/eventorganization.lang @@ -107,7 +107,7 @@ MissingOrBadSecureKey = The security key is invalid or missing EvntOrgWelcomeMessage = This form allows you to register as a new participant to the conference EvntOrgStartDuration = This conference starts on EvntOrgEndDuration = and ends on -ConferenceAttendeeFee = Conference attendee fee +ConferenceAttendeeFee = Conference attendee fee for the event : '%s' occurring from %s to %s # # SubscriptionOk page # diff --git a/htdocs/public/eventorganization/attendee_subscription.php b/htdocs/public/eventorganization/attendee_subscription.php index 22b6955c6f5..ed6d5261fcd 100644 --- a/htdocs/public/eventorganization/attendee_subscription.php +++ b/htdocs/public/eventorganization/attendee_subscription.php @@ -334,14 +334,25 @@ if (empty($reshook) && $action == 'add') { if (!$error) { // Add line to draft invoice $vattouse = get_default_tva($mysoc, $thirdparty, $productforinvoicerow->id); - $result = $facture->addline($langs->trans("ConferenceAttendeeFee").' for the event : \''.$conference->label.'\' occuring from '.dol_print_date($conference->datep, '%d/%m/%y %H:%M:%S').' to '.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); + $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); if ($result <= 0) { $confattendee->error = $facture->error; $confattendee->errors = $facture->errors; $error++; } if (!$error) { - $redirection = $dolibarr_main_url_root.'/public/payment/newpayment.php?source=conferencesubscription&ref='.dol_encode($facture->id, $dolibarr_main_instance_unique_id); + $valid = true; + $sourcetouse = 'conferencesubscription'; + $reftouse = dol_encode($facture->id, $dolibarr_main_instance_unique_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; + } + } Header("Location: ".$redirection); exit; } diff --git a/htdocs/public/payment/newpayment.php b/htdocs/public/payment/newpayment.php index 22efe3d18af..2a43e655288 100644 --- a/htdocs/public/payment/newpayment.php +++ b/htdocs/public/payment/newpayment.php @@ -155,6 +155,7 @@ foreach ($_POST as $key => $val) { } + // Define $urlwithroot //$urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root)); //$urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file @@ -168,6 +169,7 @@ $ref = $REF = GETPOST('ref', 'alpha'); $TAG = GETPOST("tag", 'alpha'); $FULLTAG = GETPOST("fulltag", 'alpha'); // fulltag is tag with more informations $SECUREKEY = GETPOST("securekey"); // Secure key + if ($paymentmethod && !preg_match('/'.preg_quote('PM='.$paymentmethod, '/').'/', $FULLTAG)) { $FULLTAG .= ($FULLTAG ? '.' : '').'PM='.$paymentmethod; } @@ -262,6 +264,7 @@ if (!empty($conf->global->PAYMENT_SECURITY_TOKEN)) { } else { $token = $conf->global->PAYMENT_SECURITY_TOKEN; } + if ($SECUREKEY != $token) { if (empty($conf->global->PAYMENT_SECURITY_ACCEPT_ANY_TOKEN)) { $valid = false; // PAYMENT_SECURITY_ACCEPT_ANY_TOKEN is for backward compatibility From f059cbe89c715775277140bec559283b4112a542 Mon Sep 17 00:00:00 2001 From: Dorian Vabre Date: Wed, 21 Apr 2021 14:50:50 +0200 Subject: [PATCH 080/147] ref passed in url no longer crypted (useless) and correctly passed through POST at submit --- htdocs/public/eventorganization/attendee_subscription.php | 2 +- htdocs/public/payment/newpayment.php | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/public/eventorganization/attendee_subscription.php b/htdocs/public/eventorganization/attendee_subscription.php index ed6d5261fcd..7f04bfe0cb5 100644 --- a/htdocs/public/eventorganization/attendee_subscription.php +++ b/htdocs/public/eventorganization/attendee_subscription.php @@ -343,7 +343,7 @@ if (empty($reshook) && $action == 'add') { if (!$error) { $valid = true; $sourcetouse = 'conferencesubscription'; - $reftouse = dol_encode($facture->id, $dolibarr_main_instance_unique_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 2a43e655288..1032737919b 100644 --- a/htdocs/public/payment/newpayment.php +++ b/htdocs/public/payment/newpayment.php @@ -113,9 +113,9 @@ if (!$action) { if ($source == 'conferencesubscription') { // Finding the Attendee - $decodedinvoiceid = dol_decode(GETPOST('ref'), $dolibarr_main_instance_unique_id); + $invoiceid = GETPOST('ref'); $invoice = new Facture($db); - $resultinvoice = $invoice->fetch($decodedinvoiceid); + $resultinvoice = $invoice->fetch($invoiceid); if ($resultinvoice <= 0) { setEventMessages(null, $invoice->errors, "errors"); } else { @@ -1808,7 +1808,7 @@ if ($source == 'conferencesubscription') { print '
'."\n"; // Amount From 4d20079c496cd8a79a3e6cbf0a0d5d50b9e3dac0 Mon Sep 17 00:00:00 2001 From: Dorian Vabre Date: Wed, 21 Apr 2021 15:20:08 +0200 Subject: [PATCH 081/147] fix: the ref passed in url is now attendee s one, not invoice s --- .../attendee_subscription.php | 2 +- htdocs/public/payment/newpayment.php | 44 ++++++++++--------- 2 files changed, 24 insertions(+), 22 deletions(-) diff --git a/htdocs/public/eventorganization/attendee_subscription.php b/htdocs/public/eventorganization/attendee_subscription.php index 7f04bfe0cb5..91bc2da646b 100644 --- a/htdocs/public/eventorganization/attendee_subscription.php +++ b/htdocs/public/eventorganization/attendee_subscription.php @@ -343,7 +343,7 @@ if (empty($reshook) && $action == 'add') { if (!$error) { $valid = true; $sourcetouse = 'conferencesubscription'; - $reftouse = $facture->id; + $reftouse = $confattendee->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 1032737919b..461cd406a92 100644 --- a/htdocs/public/payment/newpayment.php +++ b/htdocs/public/payment/newpayment.php @@ -59,6 +59,7 @@ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; 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.'/eventorganization/class/conferenceorboothattendee.class.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.'/compta/facture/class/facture.class.php'; @@ -113,30 +114,31 @@ if (!$action) { if ($source == 'conferencesubscription') { // Finding the Attendee - $invoiceid = GETPOST('ref'); - $invoice = new Facture($db); - $resultinvoice = $invoice->fetch($invoiceid); - if ($resultinvoice <= 0) { - setEventMessages(null, $invoice->errors, "errors"); + $attendeeid = GETPOST('ref'); + $attendee = new ConferenceOrBoothAttendee($db); + $resultattendee = $attendee->fetch($attendeeid); + if ($resultattendee <= 0) { + setEventMessages(null, $attendee->errors, "errors"); } else { - $invoice->fetchObjectLinked(); - // Finding the thirdparty associated to the Attendee - $thirdparty = new Societe($db); - $resultthirdparty = $thirdparty->fetch($invoice->socid); - if ($resultthirdparty <= 0) { - setEventMessages(null, $thirdparty->errors, "errors"); - } - $object = $thirdparty; - $linkedAttendees = $invoice->linkedObjectsIds['conferenceorboothattendee']; + $attendee->fetchObjectLinked(); + $linkedInvoices = $attendee->linkedObjectsIds['facture']; - if (is_array($linkedAttendees)) { - $linkedAttendees = array_values($linkedAttendees); + if (is_array($linkedInvoices)) { + $linkedInvoices = array_values($linkedInvoices); - $attendee = new ConferenceOrBoothAttendee($db); - $resultattendee = $attendee->fetch($linkedAttendees[0]); - if ($resultattendee <= 0) { - setEventMessages(null, $attendee->errors, "errors"); + $invoice = new Facture($db); + $resultinvoice = $invoice->fetch($linkedInvoices[0]); + if ($resultinvoice <= 0) { + setEventMessages(null, $invoice->errors, "errors"); + } else { + // Finding the associated thirdparty + $thirdparty = new Societe($db); + $resultthirdparty = $thirdparty->fetch($invoice->socid); + if ($resultthirdparty <= 0) { + setEventMessages(null, $thirdparty->errors, "errors"); + } + $object = $thirdparty; } } } @@ -1808,7 +1810,7 @@ if ($source == 'conferencesubscription') { print ''."\n"; // Amount From 8e7043eca6d1a18d9d98c6328c41da3829ceb99e Mon Sep 17 00:00:00 2001 From: Dorian Vabre Date: Wed, 21 Apr 2021 15:31:14 +0200 Subject: [PATCH 082/147] conforbooth class included in paymentok page --- htdocs/public/payment/paymentok.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/public/payment/paymentok.php b/htdocs/public/payment/paymentok.php index 88d50d66a62..88ab62a8b2f 100644 --- a/htdocs/public/payment/paymentok.php +++ b/htdocs/public/payment/paymentok.php @@ -50,6 +50,7 @@ if (is_numeric($entity)) { require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/eventorganization/class/conferenceorboothattendee.class.php'; if (!empty($conf->paypal->enabled)) { require_once DOL_DOCUMENT_ROOT.'/paypal/lib/paypal.lib.php'; From ebf2466d7b347836edc500762d3838d4e9b859d3 Mon Sep 17 00:00:00 2001 From: Dorian Vabre Date: Wed, 21 Apr 2021 15:36:07 +0200 Subject: [PATCH 083/147] no more redirection to subscriptionok after paymentok successful --- htdocs/public/payment/paymentok.php | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/htdocs/public/payment/paymentok.php b/htdocs/public/payment/paymentok.php index 88ab62a8b2f..8b040692dc8 100644 --- a/htdocs/public/payment/paymentok.php +++ b/htdocs/public/payment/paymentok.php @@ -889,17 +889,6 @@ if ($ispaymentok) { } else { $attendeetovalidate->setStatut(1); } - - // 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(); } From e81637b60811babd93e5b8e2d1ba2ce598c821d9 Mon Sep 17 00:00:00 2001 From: Dorian Vabre Date: Wed, 21 Apr 2021 16:37:02 +0200 Subject: [PATCH 084/147] wip on getting the existing attendee --- htdocs/langs/en_US/eventorganization.lang | 3 +- .../attendee_subscription.php | 32 ++++++++++++------- 2 files changed, 21 insertions(+), 14 deletions(-) diff --git a/htdocs/langs/en_US/eventorganization.lang b/htdocs/langs/en_US/eventorganization.lang index 863cec82164..6ef39e81ff6 100644 --- a/htdocs/langs/en_US/eventorganization.lang +++ b/htdocs/langs/en_US/eventorganization.lang @@ -105,8 +105,7 @@ ViewAndVote = View and vote for suggested events PublicAttendeeSubscriptionPage = Public link of registration to a conference MissingOrBadSecureKey = The security key is invalid or missing EvntOrgWelcomeMessage = This form allows you to register as a new participant to the conference -EvntOrgStartDuration = This conference starts on -EvntOrgEndDuration = and ends on +EvntOrgDuration = This conference starts on %s and ends on %s ConferenceAttendeeFee = Conference attendee fee for the event : '%s' occurring from %s to %s # # SubscriptionOk page diff --git a/htdocs/public/eventorganization/attendee_subscription.php b/htdocs/public/eventorganization/attendee_subscription.php index 91bc2da646b..2bacd3a1951 100644 --- a/htdocs/public/eventorganization/attendee_subscription.php +++ b/htdocs/public/eventorganization/attendee_subscription.php @@ -284,14 +284,24 @@ if (empty($reshook) && $action == 'add') { } else { // creation of an attendee $confattendee = new ConferenceOrBoothAttendee($db); - $confattendee->fk_soc = $thirdparty->id; - $confattendee->date_subscription = dol_now(); - $confattendee->email = GETPOST("email"); - $confattendee->fk_actioncomm = $id; - $resultconfattendee = $confattendee->create($user); - if ($resultconfattendee < 0) { - $error++; - $errmsg .= $confattendee->error; + $resultfetchattendee = $confattendee->fetchAll('','', 1, 0, array('t.fk_soc'=>$thirdparty->id, 't.fk_actioncomm'=>$id)); + if ($resultfetchattendee == 0 || count($resultfetchattendee) == 0) { + // Need to create an attendee + $confattendee->fk_soc = $thirdparty->id; + $confattendee->date_subscription = dol_now(); + $confattendee->email = GETPOST("email"); + $confattendee->fk_actioncomm = $id; + $resultconfattendee = $confattendee->create($user); + if ($resultconfattendee < 0) { + $error++; + $errmsg .= $confattendee->error; + } + print 'created attendee'; + } else { + // Found an attendee + print 'found attendee'; + var_dump($resultfetchattendee); + $confattendee = $resultfetchattendee[0]; } } } @@ -312,6 +322,7 @@ if (empty($reshook) && $action == 'add') { $facture->paye = 0; $facture->date = dol_now(); $facture->cond_reglement_id = $confattendee->cond_reglement_id; + if (empty($facture->cond_reglement_id)) { $paymenttermstatic = new PaymentTerm($confattendee->db); $facture->cond_reglement_id = $paymenttermstatic->getDefaultId(); @@ -437,10 +448,7 @@ print '
'; // Welcome message print $langs->trans("EvntOrgWelcomeMessage"); print $id.".".'
'; -print $langs->trans("EvntOrgStartDuration"); -print dol_print_date($conference->datep).' '; -print $langs->trans("EvntOrgEndDuration"); -print ' '.dol_print_date($conference->datef)."."; +print $langs->trans("EvntOrgDuration", dol_print_date($conference->datep), dol_print_date($conference->datef)); print '
'; dol_htmloutput_errors($errmsg); From b9408d6c711df9e90091b317474bf40515150648 Mon Sep 17 00:00:00 2001 From: Dorian Vabre Date: Wed, 21 Apr 2021 16:43:57 +0200 Subject: [PATCH 085/147] email sending added in paymentok --- htdocs/public/payment/paymentok.php | 43 +++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/htdocs/public/payment/paymentok.php b/htdocs/public/payment/paymentok.php index 8b040692dc8..27b00fec402 100644 --- a/htdocs/public/payment/paymentok.php +++ b/htdocs/public/payment/paymentok.php @@ -888,6 +888,49 @@ if ($ispaymentok) { setEventMessages(null, $attendeetovalidate->errors, "errors"); } else { $attendeetovalidate->setStatut(1); + + // Sending mail + 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, 'eventorganization_send', $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 = $thirdparty->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'); + } } } else { $db->rollback(); From 1700ac937a33c69ef007a4d4361f8f66dcbe8eb8 Mon Sep 17 00:00:00 2001 From: Dorian Vabre Date: Wed, 21 Apr 2021 17:25:28 +0200 Subject: [PATCH 086/147] wip on looking for existing attendees instead of creating them each time --- .../attendee_subscription.php | 51 ++++++++----------- 1 file changed, 21 insertions(+), 30 deletions(-) diff --git a/htdocs/public/eventorganization/attendee_subscription.php b/htdocs/public/eventorganization/attendee_subscription.php index 2bacd3a1951..d88a1ddd55a 100644 --- a/htdocs/public/eventorganization/attendee_subscription.php +++ b/htdocs/public/eventorganization/attendee_subscription.php @@ -228,10 +228,26 @@ if (empty($reshook) && $action == 'add') { } if (!$error) { - // Vérifier si client existe par l'email + // Check if attendee already exists (by email) + $confattendee = new ConferenceOrBoothAttendee($db); + $resultfetchconfattendee = $confattendee->fetchAll('', '', 0, 0, array('t.fk_actioncomm'=>$id, 't.email'=>$email)); + if ($resultfetchconfattendee != 0 && count($resultfetchconfattendee)>0) { + // Found confattendee + $confattendee = $resultfetchconfattendee[0]; + } else { + // Need to create a confattendee + } + $confattendee->date_subscription = dol_now(); + $confattendee->email = GETPOST("email"); + $confattendee->fk_actioncomm = $id; + $resultconfattendee = $confattendee->create($user); + if ($resultconfattendee < 0) { + $error++; + $errmsg .= $confattendee->error; + } + // Getting the thirdparty or creating it $thirdparty = new Societe($db); - $resultfetchthirdparty = $thirdparty->fetch('', '', '', '', '', '', '', '', '', '', $email); - + $resultfetchthirdparty = $thirdparty->fetch($confattendee->fk_soc); if ($resultfetchthirdparty<0) { $error++; $errmsg .= $thirdparty->error; @@ -277,33 +293,8 @@ if (empty($reshook) && $action == 'add') { // We have an existing thirdparty ready to use $readythirdparty = 1; } - - if ($readythirdparty < 0) { - $error++; - $errmsg .= $thirdparty->error; - } else { - // creation of an attendee - $confattendee = new ConferenceOrBoothAttendee($db); - $resultfetchattendee = $confattendee->fetchAll('','', 1, 0, array('t.fk_soc'=>$thirdparty->id, 't.fk_actioncomm'=>$id)); - if ($resultfetchattendee == 0 || count($resultfetchattendee) == 0) { - // Need to create an attendee - $confattendee->fk_soc = $thirdparty->id; - $confattendee->date_subscription = dol_now(); - $confattendee->email = GETPOST("email"); - $confattendee->fk_actioncomm = $id; - $resultconfattendee = $confattendee->create($user); - if ($resultconfattendee < 0) { - $error++; - $errmsg .= $confattendee->error; - } - print 'created attendee'; - } else { - // Found an attendee - print 'found attendee'; - var_dump($resultfetchattendee); - $confattendee = $resultfetchattendee[0]; - } - } + // Updating the fk_soc associated to the confattendee to match the ready to use thirdparty we have got + $confattendee->fk_soc = $thirdparty->id; } if (!$error) { From 22dab0e0afb32b929ed503ca88fff5eb60edba34 Mon Sep 17 00:00:00 2001 From: Dorian Vabre Date: Wed, 21 Apr 2021 17:26:46 +0200 Subject: [PATCH 087/147] fix on creating attendee --- .../attendee_subscription.php | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/htdocs/public/eventorganization/attendee_subscription.php b/htdocs/public/eventorganization/attendee_subscription.php index d88a1ddd55a..e564bec5839 100644 --- a/htdocs/public/eventorganization/attendee_subscription.php +++ b/htdocs/public/eventorganization/attendee_subscription.php @@ -228,7 +228,7 @@ if (empty($reshook) && $action == 'add') { } if (!$error) { - // Check if attendee already exists (by email) + // Check if attendee already exists (by email and for this event) $confattendee = new ConferenceOrBoothAttendee($db); $resultfetchconfattendee = $confattendee->fetchAll('', '', 0, 0, array('t.fk_actioncomm'=>$id, 't.email'=>$email)); if ($resultfetchconfattendee != 0 && count($resultfetchconfattendee)>0) { @@ -236,15 +236,16 @@ if (empty($reshook) && $action == 'add') { $confattendee = $resultfetchconfattendee[0]; } else { // Need to create a confattendee + $confattendee->date_subscription = dol_now(); + $confattendee->email = GETPOST("email"); + $confattendee->fk_actioncomm = $id; + $resultconfattendee = $confattendee->create($user); + if ($resultconfattendee < 0) { + $error++; + $errmsg .= $confattendee->error; + } } - $confattendee->date_subscription = dol_now(); - $confattendee->email = GETPOST("email"); - $confattendee->fk_actioncomm = $id; - $resultconfattendee = $confattendee->create($user); - if ($resultconfattendee < 0) { - $error++; - $errmsg .= $confattendee->error; - } + // Getting the thirdparty or creating it $thirdparty = new Societe($db); $resultfetchthirdparty = $thirdparty->fetch($confattendee->fk_soc); From e05c318fd863845edf09aae4a5cae50aeda4d970 Mon Sep 17 00:00:00 2001 From: Dorian Vabre Date: Thu, 22 Apr 2021 11:45:00 +0200 Subject: [PATCH 088/147] various modifications on the way existing attendees and thirdparties are handled at registration --- .../class/conferenceorboothattendee.class.php | 1 + .../attendee_subscription.php | 55 +++++++++++++------ 2 files changed, 40 insertions(+), 16 deletions(-) diff --git a/htdocs/eventorganization/class/conferenceorboothattendee.class.php b/htdocs/eventorganization/class/conferenceorboothattendee.class.php index 6418d73580b..d8e166fde5a 100644 --- a/htdocs/eventorganization/class/conferenceorboothattendee.class.php +++ b/htdocs/eventorganization/class/conferenceorboothattendee.class.php @@ -438,6 +438,7 @@ class ConferenceOrBoothAttendee extends CommonObject } $resql = $this->db->query($sql); + if ($resql) { $num = $this->db->num_rows($resql); $i = 0; diff --git a/htdocs/public/eventorganization/attendee_subscription.php b/htdocs/public/eventorganization/attendee_subscription.php index e564bec5839..6e06838de91 100644 --- a/htdocs/public/eventorganization/attendee_subscription.php +++ b/htdocs/public/eventorganization/attendee_subscription.php @@ -81,6 +81,7 @@ $backtopage = GETPOST('backtopage', 'alpha'); $action = GETPOST('action', 'aZ09'); $email = GETPOST("email"); +$societe = GETPOST("societe"); // Getting id from Post and decoding it $encodedid = GETPOST('id'); @@ -230,14 +231,14 @@ if (empty($reshook) && $action == 'add') { if (!$error) { // Check if attendee already exists (by email and for this event) $confattendee = new ConferenceOrBoothAttendee($db); - $resultfetchconfattendee = $confattendee->fetchAll('', '', 0, 0, array('t.fk_actioncomm'=>$id, 't.email'=>$email)); - if ($resultfetchconfattendee != 0 && count($resultfetchconfattendee)>0) { + $resultfetchconfattendee = $confattendee->fetchAll('', '', 0, 0, array('t.fk_actioncomm'=>$id, 'customsql'=>'t.email="'.$email.'"')); + if ($resultfetchconfattendee > 0 && count($resultfetchconfattendee)>0) { // Found confattendee - $confattendee = $resultfetchconfattendee[0]; + $confattendee = array_shift($resultfetchconfattendee); } else { // Need to create a confattendee $confattendee->date_subscription = dol_now(); - $confattendee->email = GETPOST("email"); + $confattendee->email = $email; $confattendee->fk_actioncomm = $id; $resultconfattendee = $confattendee->create($user); if ($resultconfattendee < 0) { @@ -248,17 +249,36 @@ if (empty($reshook) && $action == 'add') { // Getting the thirdparty or creating it $thirdparty = new Societe($db); - $resultfetchthirdparty = $thirdparty->fetch($confattendee->fk_soc); + // Fetch using fk_soc of the existing attendee + if (!empty($confattendee->fk_soc)) { + $resultfetchthirdparty = $thirdparty->fetch($confattendee->fk_soc); + } else { + // Fetch using the input field by user + if (!empty($societe)) { + $resultfetchthirdparty = $thirdparty->fetch('', $societe); + var_dump($resultfetchthirdparty); + if ($resultfetchthirdparty<=0) { + // Need to create a new one + $resultfetchthirdparty = 0; + } else { + $confattendee->fk_soc = $thirdparty->id; + $confattendee->update($user); + } + } else { + // Need to create a thirdparty + $resultfetchthirdparty = 0; + } + } + var_dump($resultfetchthirdparty); if ($resultfetchthirdparty<0) { $error++; $errmsg .= $thirdparty->error; - $readythirdparty = -1; } elseif ($resultfetchthirdparty==0) { // creation of a new thirdparty - if (!empty(GETPOST("societe"))) { - $thirdparty->name = GETPOST("societe"); + if (!empty($societe)) { + $thirdparty->name = $societe; } else { - $thirdparty->name = $email; + $thirdparty->name = $email; } $thirdparty->address = GETPOST("address"); $thirdparty->zip = GETPOST("zipcode"); @@ -288,14 +308,16 @@ if (empty($reshook) && $action == 'add') { } $thirdparty->code_client = $tmpcode; $readythirdparty = $thirdparty->create($user); - $thirdparty->country_code = getCountry($thirdparty->country_id, 2, $db, $langs); - $thirdparty->country = getCountry($thirdparty->country_code, 0, $db, $langs); - } else { - // We have an existing thirdparty ready to use - $readythirdparty = 1; + 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); + } } - // Updating the fk_soc associated to the confattendee to match the ready to use thirdparty we have got - $confattendee->fk_soc = $thirdparty->id; } if (!$error) { @@ -316,6 +338,7 @@ if (empty($reshook) && $action == 'add') { $facture->cond_reglement_id = $confattendee->cond_reglement_id; if (empty($facture->cond_reglement_id)) { + var_dump($confattendee->db); $paymenttermstatic = new PaymentTerm($confattendee->db); $facture->cond_reglement_id = $paymenttermstatic->getDefaultId(); if (empty($facture->cond_reglement_id)) { From e6318eb4f4da90eaaed1d01828c2f46486acd0fa Mon Sep 17 00:00:00 2001 From: Dorian Vabre Date: Thu, 22 Apr 2021 12:06:33 +0200 Subject: [PATCH 089/147] style --- htdocs/public/eventorganization/attendee_subscription.php | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/htdocs/public/eventorganization/attendee_subscription.php b/htdocs/public/eventorganization/attendee_subscription.php index 6e06838de91..1a17f13c2b4 100644 --- a/htdocs/public/eventorganization/attendee_subscription.php +++ b/htdocs/public/eventorganization/attendee_subscription.php @@ -256,7 +256,6 @@ if (empty($reshook) && $action == 'add') { // Fetch using the input field by user if (!empty($societe)) { $resultfetchthirdparty = $thirdparty->fetch('', $societe); - var_dump($resultfetchthirdparty); if ($resultfetchthirdparty<=0) { // Need to create a new one $resultfetchthirdparty = 0; @@ -269,7 +268,6 @@ if (empty($reshook) && $action == 'add') { $resultfetchthirdparty = 0; } } - var_dump($resultfetchthirdparty); if ($resultfetchthirdparty<0) { $error++; $errmsg .= $thirdparty->error; @@ -314,7 +312,7 @@ if (empty($reshook) && $action == 'add') { } 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->fk_soc = $thirdparty->id; $confattendee->update($user); } } @@ -338,7 +336,6 @@ if (empty($reshook) && $action == 'add') { $facture->cond_reglement_id = $confattendee->cond_reglement_id; if (empty($facture->cond_reglement_id)) { - var_dump($confattendee->db); $paymenttermstatic = new PaymentTerm($confattendee->db); $facture->cond_reglement_id = $paymenttermstatic->getDefaultId(); if (empty($facture->cond_reglement_id)) { From 467595ce60a4291f581746088cf2200ebfaa773e Mon Sep 17 00:00:00 2001 From: Dorian Vabre Date: Thu, 22 Apr 2021 14:53:32 +0200 Subject: [PATCH 090/147] an already subscribed attendee will not be redirected to a payment page, now --- htdocs/public/eventorganization/attendee_subscription.php | 8 ++++++-- htdocs/public/payment/paymentok.php | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/htdocs/public/eventorganization/attendee_subscription.php b/htdocs/public/eventorganization/attendee_subscription.php index 1a17f13c2b4..6c069122d65 100644 --- a/htdocs/public/eventorganization/attendee_subscription.php +++ b/htdocs/public/eventorganization/attendee_subscription.php @@ -72,6 +72,7 @@ require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/paymentterm.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; global $dolibarr_main_instance_unique_id; +global $dolibarr_main_url_root; // Init vars $errmsg = ''; @@ -246,7 +247,11 @@ if (empty($reshook) && $action == 'add') { $errmsg .= $confattendee->error; } } - + if($confattendee->status == 1) { + $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; + } // Getting the thirdparty or creating it $thirdparty = new Societe($db); // Fetch using fk_soc of the existing attendee @@ -320,7 +325,6 @@ if (empty($reshook) && $action == 'add') { if (!$error) { $db->commit(); - global $dolibarr_main_url_root; if (!empty(floatval($project->price_registration))) { $productforinvoicerow = new Product($db); $resultprod = $productforinvoicerow->fetch($conf->global->SERVICE_CONFERENCE_ATTENDEE_SUBSCRIPTION); diff --git a/htdocs/public/payment/paymentok.php b/htdocs/public/payment/paymentok.php index 27b00fec402..d4946ce0ac7 100644 --- a/htdocs/public/payment/paymentok.php +++ b/htdocs/public/payment/paymentok.php @@ -944,7 +944,7 @@ if ($ispaymentok) { $ispostactionok = -1; } } elseif (array_key_exists('BOO', $tmptag) && $tmptag['BOO'] > 0) { - // BOOTH CASE (to copy and adapt from above) + // @todo BOOTH CASE (to copy and adapt from above) } else { // Nothing done } From eb96d5bd58017c1d236e56e7fb6c163569c9a753 Mon Sep 17 00:00:00 2001 From: Dorian Vabre Date: Thu, 22 Apr 2021 15:27:16 +0200 Subject: [PATCH 091/147] added comments --- .../eventorganization/attendee_subscription.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/htdocs/public/eventorganization/attendee_subscription.php b/htdocs/public/eventorganization/attendee_subscription.php index 6c069122d65..9fb27168fd1 100644 --- a/htdocs/public/eventorganization/attendee_subscription.php +++ b/htdocs/public/eventorganization/attendee_subscription.php @@ -247,6 +247,9 @@ if (empty($reshook) && $action == 'add') { $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) { $redirection = $dolibarr_main_url_root.'/public/eventorganization/subscriptionok.php?securekey='.dol_encode($conf->global->EVENTORGANIZATION_SECUREKEY, $dolibarr_main_instance_unique_id); Header("Location: ".$redirection); @@ -254,22 +257,23 @@ if (empty($reshook) && $action == 'add') { } // Getting the thirdparty or creating it $thirdparty = new Societe($db); - // Fetch using fk_soc of the existing attendee + // Fetch using fk_soc if the attendee was already existing if (!empty($confattendee->fk_soc)) { $resultfetchthirdparty = $thirdparty->fetch($confattendee->fk_soc); } else { - // Fetch using the input field by user + // 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 + // Need to create a new one (not found or multiple with the same name) $resultfetchthirdparty = 0; } 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); } } else { - // Need to create a thirdparty + // Need to create a thirdparty (put number>0 if we do not want to create a thirdparty for free-conferences) $resultfetchthirdparty = 0; } } From 804547997bea4a6b65e52286ce376d671fecc91f Mon Sep 17 00:00:00 2001 From: Dorian Vabre Date: Thu, 22 Apr 2021 15:52:45 +0200 Subject: [PATCH 092/147] removed obsolete post information and now giving the source in the url --- htdocs/public/payment/newpayment.php | 8 +++----- htdocs/public/payment/paymentok.php | 6 ------ 2 files changed, 3 insertions(+), 11 deletions(-) diff --git a/htdocs/public/payment/newpayment.php b/htdocs/public/payment/newpayment.php index 461cd406a92..1b737037a93 100644 --- a/htdocs/public/payment/newpayment.php +++ b/htdocs/public/payment/newpayment.php @@ -207,8 +207,6 @@ if (!empty($entity)) { $urlok = preg_replace('/&$/', '', $urlok); // Remove last & $urlko = preg_replace('/&$/', '', $urlko); // Remove last & - - // Make special controls if ((empty($paymentmethod) || $paymentmethod == 'paypal') && !empty($conf->paypal->enabled)) { @@ -379,7 +377,7 @@ if ($action == 'dopayment') { // A redirect is added if API call successfull if ($source == 'conferencesubscription') { - $PAYPAL_API_OK .= '&invoice='.dol_encode($invoice->id, $dolibarr_main_instance_unique_id); + $PAYPAL_API_OK .= '&source=conferencesubscription&invoice='.dol_encode($invoice->id, $dolibarr_main_instance_unique_id); } $mesg = print_paypal_redirect($PAYPAL_API_PRICE, $PAYPAL_API_DEVISE, $PAYPAL_PAYMENT_TYPE, $PAYPAL_API_OK, $PAYPAL_API_KO, $FULLTAG); @@ -400,7 +398,7 @@ if ($action == 'dopayment') { $urlko = preg_replace('/securekey=[^&]+/', '', $urlko); if ($source == 'conferencesubscription') { - $urlok .= '&invoice='.dol_encode($invoice->id, $dolibarr_main_instance_unique_id); + $urlok .= '&source=conferencesubscription&invoice='.dol_encode($invoice->id, $dolibarr_main_instance_unique_id); } $mesg = ''; @@ -758,7 +756,7 @@ if ($action == 'charge' && !empty($conf->stripe->enabled)) { exit; } else { if ($source == 'conferencesubscription') { - $urlok .= '&invoice='.dol_encode($invoice->id, $dolibarr_main_instance_unique_id); + $urlok .= '&source=conferencesubscription&invoice='.dol_encode($invoice->id, $dolibarr_main_instance_unique_id); } header("Location: ".$urlok); exit; diff --git a/htdocs/public/payment/paymentok.php b/htdocs/public/payment/paymentok.php index d4946ce0ac7..681c980a3e8 100644 --- a/htdocs/public/payment/paymentok.php +++ b/htdocs/public/payment/paymentok.php @@ -109,12 +109,6 @@ $invoiceref = GETPOST('invoice'); $suffix = GETPOST("suffix", 'aZ09'); $membertypeid = GETPOST("membertypeid", 'int'); -$conferencesubscription = GETPOST('conferencesubscription'); -$uncryptedconferencesubscription = dol_decode($conferencesubscription, $dolibarr_main_instance_unique_id); -$subscription = substr($uncryptedconferencesubscription, 0, strlen($uncryptedconferencesubscription)-strlen($ref)); -$reffrompayment = substr($uncryptedconferencesubscription, -strlen($ref), strlen($ref)); - - // Detect $paymentmethod $paymentmethod = ''; $reg = array(); From f832434ce3ebfbd2245d33ef5d456169ce562927 Mon Sep 17 00:00:00 2001 From: Dorian Vabre Date: Thu, 22 Apr 2021 16:17:22 +0200 Subject: [PATCH 093/147] removing mistake from last commit: source is already given in urlok --- htdocs/public/payment/newpayment.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/public/payment/newpayment.php b/htdocs/public/payment/newpayment.php index 1b737037a93..2f6b61a82d4 100644 --- a/htdocs/public/payment/newpayment.php +++ b/htdocs/public/payment/newpayment.php @@ -377,7 +377,7 @@ if ($action == 'dopayment') { // A redirect is added if API call successfull if ($source == 'conferencesubscription') { - $PAYPAL_API_OK .= '&source=conferencesubscription&invoice='.dol_encode($invoice->id, $dolibarr_main_instance_unique_id); + $PAYPAL_API_OK .= '&invoice='.dol_encode($invoice->id, $dolibarr_main_instance_unique_id); } $mesg = print_paypal_redirect($PAYPAL_API_PRICE, $PAYPAL_API_DEVISE, $PAYPAL_PAYMENT_TYPE, $PAYPAL_API_OK, $PAYPAL_API_KO, $FULLTAG); @@ -398,7 +398,7 @@ if ($action == 'dopayment') { $urlko = preg_replace('/securekey=[^&]+/', '', $urlko); if ($source == 'conferencesubscription') { - $urlok .= '&source=conferencesubscription&invoice='.dol_encode($invoice->id, $dolibarr_main_instance_unique_id); + $urlok .= '&invoice='.dol_encode($invoice->id, $dolibarr_main_instance_unique_id); } $mesg = ''; @@ -756,7 +756,7 @@ if ($action == 'charge' && !empty($conf->stripe->enabled)) { exit; } else { if ($source == 'conferencesubscription') { - $urlok .= '&source=conferencesubscription&invoice='.dol_encode($invoice->id, $dolibarr_main_instance_unique_id); + $urlok .= '&invoice='.dol_encode($invoice->id, $dolibarr_main_instance_unique_id); } header("Location: ".$urlok); exit; From 4589813d3f87521e10f7fdb05d239e009cc50934 Mon Sep 17 00:00:00 2001 From: Dorian Vabre Date: Fri, 23 Apr 2021 09:46:02 +0200 Subject: [PATCH 094/147] added thirdparty fetch before mail sending to get its name --- htdocs/public/payment/paymentok.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/htdocs/public/payment/paymentok.php b/htdocs/public/payment/paymentok.php index 681c980a3e8..cdee63c2955 100644 --- a/htdocs/public/payment/paymentok.php +++ b/htdocs/public/payment/paymentok.php @@ -884,6 +884,9 @@ if ($ispaymentok) { $attendeetovalidate->setStatut(1); // Sending mail + $thirdparty = new Societe($db); + $thirdparty->fetch($attendeetovalidate->fk_soc); + 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); From b441c600bb1a9c5fe8daff4df13ba68c836be9fe Mon Sep 17 00:00:00 2001 From: Dorian Vabre Date: Fri, 23 Apr 2021 10:32:28 +0200 Subject: [PATCH 095/147] fixing error introduced in a previous commit --- htdocs/compta/paiement.php | 2 +- htdocs/core/class/CMailFile.class.php | 1 + .../class/conferenceorboothattendee.class.php | 1 - htdocs/public/payment/newpayment.php | 4 ++-- htdocs/public/payment/paymentok.php | 2 ++ 5 files changed, 6 insertions(+), 4 deletions(-) diff --git a/htdocs/compta/paiement.php b/htdocs/compta/paiement.php index 418bca03d83..94b114c03d8 100644 --- a/htdocs/compta/paiement.php +++ b/htdocs/compta/paiement.php @@ -253,7 +253,7 @@ if (empty($reshook)) { if (!$error) { // Create payment and update this->multicurrency_amounts if this->amounts filled or // this->amounts if this->multicurrency_amounts filled. - $paiement_id = $paiement->create($user, 1, $thirdparty); // This include closing invoices and regenerating documents + $paiement_id = $paiement->create($user, (GETPOST('closepaidinvoices') == 'on' ? 1 : 0), $thirdparty); // This include closing invoices and regenerating documents if ($paiement_id < 0) { setEventMessages($paiement->error, $paiement->errors, 'errors'); $error++; diff --git a/htdocs/core/class/CMailFile.class.php b/htdocs/core/class/CMailFile.class.php index 526c464403f..863bb9a6794 100644 --- a/htdocs/core/class/CMailFile.class.php +++ b/htdocs/core/class/CMailFile.class.php @@ -584,6 +584,7 @@ class CMailFile if ($reshook < 0) { $this->error = "Error in hook maildao sendMail ".$reshook; dol_syslog("CMailFile::sendfile: mail end error=".$this->error, LOG_ERR); + return $reshook; } if ($reshook == 1) { // Hook replace standard code diff --git a/htdocs/eventorganization/class/conferenceorboothattendee.class.php b/htdocs/eventorganization/class/conferenceorboothattendee.class.php index d8e166fde5a..6418d73580b 100644 --- a/htdocs/eventorganization/class/conferenceorboothattendee.class.php +++ b/htdocs/eventorganization/class/conferenceorboothattendee.class.php @@ -438,7 +438,6 @@ class ConferenceOrBoothAttendee extends CommonObject } $resql = $this->db->query($sql); - if ($resql) { $num = $this->db->num_rows($resql); $i = 0; diff --git a/htdocs/public/payment/newpayment.php b/htdocs/public/payment/newpayment.php index 2f6b61a82d4..5007b325c11 100644 --- a/htdocs/public/payment/newpayment.php +++ b/htdocs/public/payment/newpayment.php @@ -157,7 +157,6 @@ foreach ($_POST as $key => $val) { } - // Define $urlwithroot //$urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root)); //$urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file @@ -207,6 +206,8 @@ if (!empty($entity)) { $urlok = preg_replace('/&$/', '', $urlok); // Remove last & $urlko = preg_replace('/&$/', '', $urlko); // Remove last & + + // Make special controls if ((empty($paymentmethod) || $paymentmethod == 'paypal') && !empty($conf->paypal->enabled)) { @@ -264,7 +265,6 @@ if (!empty($conf->global->PAYMENT_SECURITY_TOKEN)) { } else { $token = $conf->global->PAYMENT_SECURITY_TOKEN; } - if ($SECUREKEY != $token) { if (empty($conf->global->PAYMENT_SECURITY_ACCEPT_ANY_TOKEN)) { $valid = false; // PAYMENT_SECURITY_ACCEPT_ANY_TOKEN is for backward compatibility diff --git a/htdocs/public/payment/paymentok.php b/htdocs/public/payment/paymentok.php index cdee63c2955..444a769673c 100644 --- a/htdocs/public/payment/paymentok.php +++ b/htdocs/public/payment/paymentok.php @@ -109,6 +109,7 @@ $invoiceref = GETPOST('invoice'); $suffix = GETPOST("suffix", 'aZ09'); $membertypeid = GETPOST("membertypeid", 'int'); + // Detect $paymentmethod $paymentmethod = ''; $reg = array(); @@ -151,6 +152,7 @@ $object = new stdClass(); // For triggers $error = 0; + /* * Actions */ From 432bdaea654a030c2968b7e2fdf0b1e0bee13269 Mon Sep 17 00:00:00 2001 From: Dorian Vabre Date: Fri, 23 Apr 2021 10:36:12 +0200 Subject: [PATCH 096/147] same as previous commit --- htdocs/admin/eventorganization.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/admin/eventorganization.php b/htdocs/admin/eventorganization.php index b4b6604b118..9cbbdaf3f7d 100644 --- a/htdocs/admin/eventorganization.php +++ b/htdocs/admin/eventorganization.php @@ -283,6 +283,8 @@ if ($action == 'edit') { $selected = (empty($conf->global->$constname) ? '' : $conf->global->$constname); $form->select_produits($selected, $constname, '', 0); } + } else { + print ''; } print ''; } From 1511bf811c0438f36d7c088fc49abd52ab285057 Mon Sep 17 00:00:00 2001 From: Dorian Vabre Date: Fri, 23 Apr 2021 12:22:03 +0200 Subject: [PATCH 097/147] now getting the amount of the invoice in the newpayment page --- htdocs/public/payment/newpayment.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/public/payment/newpayment.php b/htdocs/public/payment/newpayment.php index 5007b325c11..d6613cb86de 100644 --- a/htdocs/public/payment/newpayment.php +++ b/htdocs/public/payment/newpayment.php @@ -132,6 +132,7 @@ if ($source == 'conferencesubscription') { if ($resultinvoice <= 0) { setEventMessages(null, $invoice->errors, "errors"); } else { + $amount = price2num($invoice->total_ttc); // Finding the associated thirdparty $thirdparty = new Societe($db); $resultthirdparty = $thirdparty->fetch($invoice->socid); @@ -1814,7 +1815,7 @@ if ($source == 'conferencesubscription') { // Amount 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 { From f65fa98c37a7894ea69e6afb5f0c6bdb7a57732c Mon Sep 17 00:00:00 2001 From: Dorian Vabre Date: Fri, 23 Apr 2021 16:46:09 +0200 Subject: [PATCH 099/147] indent fix, validation and mail sending put into else block to avoid errors --- htdocs/public/payment/paymentok.php | 219 ++++++++++++++-------------- 1 file changed, 109 insertions(+), 110 deletions(-) diff --git a/htdocs/public/payment/paymentok.php b/htdocs/public/payment/paymentok.php index 39cfa0f37c9..3d3946927c8 100644 --- a/htdocs/public/payment/paymentok.php +++ b/htdocs/public/payment/paymentok.php @@ -810,137 +810,136 @@ 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) { + $resultvalidate = $object->validate($user); + if ($resultvalidate < 0) { $postactionmessages[] = 'Cannot validate invoice'; - $ispostactionok = -1; - $error++; // Not yet supported - } else { - - } - $db->begin(); - - // Creation of payment line - include_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php'; - $paiement = new Paiement($db); - $paiement->datepaye = $now; - if ($currencyCodeType == $conf->currency) { - $paiement->amounts = array($object->id => $FinalPaymentAmt); // Array with all payments dispatching with invoice id - } else { - $paiement->multicurrency_amounts = array($object->id => $FinalPaymentAmt); // Array with all payments dispatching - - $postactionmessages[] = 'Payment was done in a different currency that currency expected of company'; $ispostactionok = -1; $error++; // Not yet supported - } - $paiement->paiementid = $paymentTypeId; - $paiement->num_payment = ''; - $paiement->note_public = 'Online payment '.dol_print_date($now, 'standard').' from '.$ipaddress; - $paiement->ext_payment_id = $TRANSACTIONID; - $paiement->ext_payment_site = $service; + } else { + $db->begin(); - if (!$error) { - $paiement_id = $paiement->create($user, 1); // This include closing invoices and regenerating documents - if ($paiement_id < 0) { - $postactionmessages[] = $paiement->error.' '.join("
\n", $paiement->errors); - $ispostactionok = -1; - $error++; + // Creation of payment line + include_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php'; + $paiement = new Paiement($db); + $paiement->datepaye = $now; + if ($currencyCodeType == $conf->currency) { + $paiement->amounts = array($object->id => $FinalPaymentAmt); // Array with all payments dispatching with invoice id } else { - $postactionmessages[] = 'Payment created'; - $ispostactionok = 1; - } - } + $paiement->multicurrency_amounts = array($object->id => $FinalPaymentAmt); // Array with all payments dispatching - if (!$error && !empty($conf->banque->enabled)) { - $bankaccountid = 0; - if ($paymentmethod == 'paybox') { - $bankaccountid = $conf->global->PAYBOX_BANK_ACCOUNT_FOR_PAYMENTS; - } elseif ($paymentmethod == 'paypal') { - $bankaccountid = $conf->global->PAYPAL_BANK_ACCOUNT_FOR_PAYMENTS; - } elseif ($paymentmethod == 'stripe') { - $bankaccountid = $conf->global->STRIPE_BANK_ACCOUNT_FOR_PAYMENTS; + $postactionmessages[] = 'Payment was done in a different currency that currency expected of company'; + $ispostactionok = -1; + $error++; // Not yet supported } + $paiement->paiementid = $paymentTypeId; + $paiement->num_payment = ''; + $paiement->note_public = 'Online payment '.dol_print_date($now, 'standard').' from '.$ipaddress; + $paiement->ext_payment_id = $TRANSACTIONID; + $paiement->ext_payment_site = $service; - if ($bankaccountid > 0) { - $label = '(CustomerInvoicePayment)'; - if ($object->type == Facture::TYPE_CREDIT_NOTE) { - $label = '(CustomerInvoicePaymentBack)'; // Refund of a credit note - } - $result = $paiement->addPaymentToBank($user, 'payment', $label, $bankaccountid, '', ''); - if ($result < 0) { + if (!$error) { + $paiement_id = $paiement->create($user, 1); // This include closing invoices and regenerating documents + if ($paiement_id < 0) { $postactionmessages[] = $paiement->error.' '.join("
\n", $paiement->errors); $ispostactionok = -1; $error++; } else { - $postactionmessages[] = 'Bank transaction of payment created'; + $postactionmessages[] = 'Payment created'; $ispostactionok = 1; } - } else { - $postactionmessages[] = 'Setup of bank account to use in module '.$paymentmethod.' was not set. No way to record the payment.'; - $ispostactionok = -1; - $error++; } - } - if (!$error) { - $db->commit(); - - // Validating the attendee - $attendeetovalidate = new ConferenceOrBoothAttendee($db); - $resultattendee = $attendeetovalidate->fetch($tmptag['ATT']); - if ($resultattendee < 0) { - setEventMessages(null, $attendeetovalidate->errors, "errors"); - } else { - $attendeetovalidate->setStatut(1); - - // Sending mail - $thirdparty = new Societe($db); - $thirdparty->fetch($attendeetovalidate->fk_soc); - - 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, 'eventorganization_send', $user, $outputlangs, $labeltouse, 1, ''); + if (!$error && !empty($conf->banque->enabled)) { + $bankaccountid = 0; + if ($paymentmethod == 'paybox') { + $bankaccountid = $conf->global->PAYBOX_BANK_ACCOUNT_FOR_PAYMENTS; + } elseif ($paymentmethod == 'paypal') { + $bankaccountid = $conf->global->PAYPAL_BANK_ACCOUNT_FOR_PAYMENTS; + } elseif ($paymentmethod == 'stripe') { + $bankaccountid = $conf->global->STRIPE_BANK_ACCOUNT_FOR_PAYMENTS; } - 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 = $thirdparty->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'); + if ($bankaccountid > 0) { + $label = '(CustomerInvoicePayment)'; + if ($object->type == Facture::TYPE_CREDIT_NOTE) { + $label = '(CustomerInvoicePaymentBack)'; // Refund of a credit note + } + $result = $paiement->addPaymentToBank($user, 'payment', $label, $bankaccountid, '', ''); + if ($result < 0) { + $postactionmessages[] = $paiement->error.' '.join("
\n", $paiement->errors); + $ispostactionok = -1; + $error++; + } else { + $postactionmessages[] = 'Bank transaction of payment created'; + $ispostactionok = 1; + } } else { - dol_syslog("Failed to send EMail to ".$sendto, LOG_ERR, 0, '_payment'); + $postactionmessages[] = 'Setup of bank account to use in module '.$paymentmethod.' was not set. No way to record the payment.'; + $ispostactionok = -1; + $error++; } } - } else { - $db->rollback(); + + if (!$error) { + $db->commit(); + + // Validating the attendee + $attendeetovalidate = new ConferenceOrBoothAttendee($db); + $resultattendee = $attendeetovalidate->fetch($tmptag['ATT']); + if ($resultattendee < 0) { + setEventMessages(null, $attendeetovalidate->errors, "errors"); + } else { + $attendeetovalidate->setStatut(1); + + // Sending mail + $thirdparty = new Societe($db); + $thirdparty->fetch($attendeetovalidate->fk_soc); + + 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, 'eventorganization_send', $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 = $thirdparty->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'); + } + } + } 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['ATT'].'. May be payment was already recorded.'; From e9b35cf36b7f5b4e3ad1441bdd33afae09cb2a8e Mon Sep 17 00:00:00 2001 From: Dorian Vabre Date: Fri, 23 Apr 2021 16:53:34 +0200 Subject: [PATCH 100/147] mail template modified to add company name and remove useless payment link --- htdocs/install/mysql/data/llx_c_email_templates.sql | 2 +- htdocs/install/mysql/migration/13.0.0-14.0.0.sql | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/install/mysql/data/llx_c_email_templates.sql b/htdocs/install/mysql/data/llx_c_email_templates.sql index fabbbf2e700..5ca98be8545 100644 --- a/htdocs/install/mysql/data/llx_c_email_templates.sql +++ b/htdocs/install/mysql/data/llx_c_email_templates.sql @@ -35,6 +35,6 @@ INSERT INTO llx_c_email_templates (entity,module,type_template,lang,private,fk_u INSERT INTO llx_c_email_templates (entity, module, type_template, lang, private, fk_user, datec, tms, label, position, active, topic, content, content_lines, enabled, joinfiles) values (0, '', 'eventorganization_send', '', 0, null, null, '2021-02-14 14:42:41', 'EventOrganizationEmailAskConf', 10, 1, '[__[MAIN_INFO_SOCIETE_NOM]__] __(EventOrganizationEmailAskConf)__', '__(Hello)__ __THIRDPARTY_NAME__,

__(ThisIsContentOfYourOrganizationEventConfRequestWasReceived)__

__ONLINE_PAYMENT_TEXT_AND_URL__


__(Sincerely)__
__USER_SIGNATURE__', null, '1', null); INSERT INTO llx_c_email_templates (entity, module, type_template, lang, private, fk_user, datec, tms, label, position, active, topic, content, content_lines, enabled, joinfiles) values (0, '', 'eventorganization_send', '', 0, null, null, '2021-02-14 14:42:41', 'EventOrganizationEmailAskBooth', 20, 1, '[__[MAIN_INFO_SOCIETE_NOM]__] __(EventOrganizationEmailAskBooth)__', '__(Hello)__ __THIRDPARTY_NAME__,

__(ThisIsContentOfYourOrganizationEventBoothRequestWasReceived)__

__ONLINE_PAYMENT_TEXT_AND_URL__


__(Sincerely)__
__USER_SIGNATURE__', null, '1', null); INSERT INTO llx_c_email_templates (entity, module, type_template, lang, private, fk_user, datec, tms, label, position, active, topic, content, content_lines, enabled, joinfiles) values (0, '', 'eventorganization_send', '', 0, null, null, '2021-02-14 14:42:41', 'EventOrganizationEmailSubsBooth', 30, 1, '[__[MAIN_INFO_SOCIETE_NOM]__] __(EventOrganizationEmailSubsBooth)__', '__(Hello)__ __THIRDPARTY_NAME__,

__(ThisIsContentOfYourOrganizationEventBoothSubscriptionWasReceived)__

__ONLINE_PAYMENT_TEXT_AND_URL__


__(Sincerely)__
__USER_SIGNATURE__', null, '1', null); -INSERT INTO llx_c_email_templates (entity, module, type_template, lang, private, fk_user, datec, tms, label, position, active, topic, content, content_lines, enabled, joinfiles) values (0, '', 'eventorganization_send', '', 0, null, null, '2021-02-14 14:42:41', 'EventOrganizationEmailSubsEvent', 40, 1, '[__[MAIN_INFO_SOCIETE_NOM]__] __(EventOrganizationEmailSubsEvent)__', '__(Hello)__ __THIRDPARTY_NAME__,

__(ThisIsContentOfYourOrganizationEventEventSubscriptionWasReceived)__

__ONLINE_PAYMENT_TEXT_AND_URL__


__(Sincerely)__
__USER_SIGNATURE__', null, '1', null); +INSERT INTO llx_c_email_templates (entity, module, type_template, lang, private, fk_user, datec, tms, label, position, active, topic, content, content_lines, enabled, joinfiles) values (0, '', 'eventorganization_send', '', 0, null, null, '2021-02-14 14:42:41', 'EventOrganizationEmailSubsEvent', 40, 1, '[__[MAIN_INFO_SOCIETE_NOM]__] __(EventOrganizationEmailSubsEvent)__', '__(Hello)__ __THIRDPARTY_NAME__,

__(ThisIsContentOfYourOrganizationEventEventSubscriptionWasReceived)__

__(Sincerely)__

__MYCOMPANY_NAME__
__USER_SIGNATURE__', null, '1', null); INSERT INTO llx_c_email_templates (entity, module, type_template, lang, private, fk_user, datec, tms, label, position, active, topic, content, content_lines, enabled, joinfiles) values (0, '', 'eventorganization_send', '', 0, null, null, '2021-02-14 14:42:41', 'EventOrganizationMassEmailAttendees', 50, 1, '[__[MAIN_INFO_SOCIETE_NOM]__] __(EventOrganizationMassEmailAttendees)__', '__(Hello)__ __THIRDPARTY_NAME__,

__(ThisIsContentOfYourOrganizationEventBulkMailToAttendees)__

__(Sincerely)__
__USER_SIGNATURE__', null, '1', null); INSERT INTO llx_c_email_templates (entity, module, type_template, lang, private, fk_user, datec, tms, label, position, active, topic, content, content_lines, enabled, joinfiles) values (0, '', 'eventorganization_send', '', 0, null, null, '2021-02-14 14:42:41', 'EventOrganizationMassEmailSpeakers', 60, 1, '[__[MAIN_INFO_SOCIETE_NOM]__] __(EventOrganizationMassEmailSpeakers)__', '__(Hello)__ __THIRDPARTY_NAME__,

__(ThisIsContentOfYourOrganizationEventBulkMailToSpeakers)__

__(Sincerely)__
__USER_SIGNATURE__', null, '1', null); diff --git a/htdocs/install/mysql/migration/13.0.0-14.0.0.sql b/htdocs/install/mysql/migration/13.0.0-14.0.0.sql index ba36b27e885..52ac44e05a0 100644 --- a/htdocs/install/mysql/migration/13.0.0-14.0.0.sql +++ b/htdocs/install/mysql/migration/13.0.0-14.0.0.sql @@ -196,7 +196,7 @@ ALTER TABLE llx_tva ALTER COLUMN paye SET DEFAULT 0; INSERT INTO llx_c_email_templates (entity, module, type_template, lang, private, fk_user, datec, tms, label, position, active, topic, content, content_lines, enabled, joinfiles) values (0, '', 'eventorganization_send', '', 0, null, null, '2021-02-14 14:42:41', 'EventOrganizationEmailAskConf', 10, 1, '[__[MAIN_INFO_SOCIETE_NOM]__] __(EventOrganizationEmailAskConf)__', '__(Hello)__ __THIRDPARTY_NAME__,

__(ThisIsContentOfYourOrganizationEventConfRequestWasReceived)__

__ONLINE_PAYMENT_TEXT_AND_URL__


__(Sincerely)__
__USER_SIGNATURE__', null, '1', null); INSERT INTO llx_c_email_templates (entity, module, type_template, lang, private, fk_user, datec, tms, label, position, active, topic, content, content_lines, enabled, joinfiles) values (0, '', 'eventorganization_send', '', 0, null, null, '2021-02-14 14:42:41', 'EventOrganizationEmailAskBooth', 20, 1, '[__[MAIN_INFO_SOCIETE_NOM]__] __(EventOrganizationEmailAskBooth)__', '__(Hello)__ __THIRDPARTY_NAME__,

__(ThisIsContentOfYourOrganizationEventBoothRequestWasReceived)__

__ONLINE_PAYMENT_TEXT_AND_URL__


__(Sincerely)__
__USER_SIGNATURE__', null, '1', null); INSERT INTO llx_c_email_templates (entity, module, type_template, lang, private, fk_user, datec, tms, label, position, active, topic, content, content_lines, enabled, joinfiles) values (0, '', 'eventorganization_send', '', 0, null, null, '2021-02-14 14:42:41', 'EventOrganizationEmailSubsBooth', 30, 1, '[__[MAIN_INFO_SOCIETE_NOM]__] __(EventOrganizationEmailSubsBooth)__', '__(Hello)__ __THIRDPARTY_NAME__,

__(ThisIsContentOfYourOrganizationEventBoothSubscriptionWasReceived)__

__ONLINE_PAYMENT_TEXT_AND_URL__


__(Sincerely)__
__USER_SIGNATURE__', null, '1', null); -INSERT INTO llx_c_email_templates (entity, module, type_template, lang, private, fk_user, datec, tms, label, position, active, topic, content, content_lines, enabled, joinfiles) values (0, '', 'eventorganization_send', '', 0, null, null, '2021-02-14 14:42:41', 'EventOrganizationEmailSubsEvent', 40, 1, '[__[MAIN_INFO_SOCIETE_NOM]__] __(EventOrganizationEmailSubsEvent)__', '__(Hello)__ __THIRDPARTY_NAME__,

__(ThisIsContentOfYourOrganizationEventEventSubscriptionWasReceived)__

__ONLINE_PAYMENT_TEXT_AND_URL__


__(Sincerely)__
__USER_SIGNATURE__', null, '1', null); +INSERT INTO llx_c_email_templates (entity, module, type_template, lang, private, fk_user, datec, tms, label, position, active, topic, content, content_lines, enabled, joinfiles) values (0, '', 'eventorganization_send', '', 0, null, null, '2021-02-14 14:42:41', 'EventOrganizationEmailSubsEvent', 40, 1, '[__[MAIN_INFO_SOCIETE_NOM]__] __(EventOrganizationEmailSubsEvent)__', '__(Hello)__ __THIRDPARTY_NAME__,

__(ThisIsContentOfYourOrganizationEventEventSubscriptionWasReceived)__

__(Sincerely)__

__MYCOMPANY_NAME__
__USER_SIGNATURE__', null, '1', null); INSERT INTO llx_c_email_templates (entity, module, type_template, lang, private, fk_user, datec, tms, label, position, active, topic, content, content_lines, enabled, joinfiles) values (0, '', 'eventorganization_send', '', 0, null, null, '2021-02-14 14:42:41', 'EventOrganizationMassEmailAttendees', 50, 1, '[__[MAIN_INFO_SOCIETE_NOM]__] __(EventOrganizationMassEmailAttendees)__', '__(Hello)__ __THIRDPARTY_NAME__,

__(ThisIsContentOfYourOrganizationEventBulkMailToAttendees)__

__(Sincerely)__
__USER_SIGNATURE__', null, '1', null); INSERT INTO llx_c_email_templates (entity, module, type_template, lang, private, fk_user, datec, tms, label, position, active, topic, content, content_lines, enabled, joinfiles) values (0, '', 'eventorganization_send', '', 0, null, null, '2021-02-14 14:42:41', 'EventOrganizationMassEmailSpeakers', 60, 1, '[__[MAIN_INFO_SOCIETE_NOM]__] __(EventOrganizationMassEmailSpeakers)__', '__(Hello)__ __THIRDPARTY_NAME__,

__(ThisIsContentOfYourOrganizationEventBulkMailToSpeakers)__

__(Sincerely)__
__USER_SIGNATURE__', null, '1', null); From 7f9f67e7efadf8a732daa1e8c55a944af2617b70 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Fri, 23 Apr 2021 15:12:34 +0000 Subject: [PATCH 101/147] Fixing style errors. --- .../class/conferenceorbooth.class.php | 12 ++++---- .../conferenceorbooth_card.php | 2 +- htdocs/modulebuilder/template/admin/setup.php | 30 +++++++++---------- .../attendee_subscription.php | 3 +- htdocs/public/payment/newpayment.php | 1 - htdocs/public/project/index.php | 4 +-- 6 files changed, 25 insertions(+), 27 deletions(-) diff --git a/htdocs/eventorganization/class/conferenceorbooth.class.php b/htdocs/eventorganization/class/conferenceorbooth.class.php index b859c10a98d..02714496b35 100644 --- a/htdocs/eventorganization/class/conferenceorbooth.class.php +++ b/htdocs/eventorganization/class/conferenceorbooth.class.php @@ -237,19 +237,19 @@ class ConferenceOrBooth extends ActionComm */ public function fetch($id, $ref = null, $ref_ext = '', $email_msgid = '') { - global $dolibarr_main_url_root, $dolibarr_main_instance_unique_id, $conf, $langs; - + global $dolibarr_main_url_root, $dolibarr_main_instance_unique_id, $conf, $langs; + $result = parent::fetch($id, $ref, $ref_ext, $email_msgid); - + $encodedid = dol_encode($id, $dolibarr_main_instance_unique_id); $link_subscription = $dolibarr_main_url_root.'/public/eventorganization/attendee_subscription.php?id='.$encodedid; - + $encodedsecurekey = dol_encode($conf->global->EVENTORGANIZATION_SECUREKEY.$encodedid, $dolibarr_main_instance_unique_id); $link_subscription .= '&securekey='.urlencode($encodedsecurekey); - + $this->fields['pubregister'] = array('type'=>'url', 'label'=>$langs->trans("PublicAttendeeSubscriptionPage"), 'enabled'=>'1', 'position'=>72, 'notnull'=>0, 'visible'=>1); $this->pubregister = $link_subscription; - + $this->getActionCommFields(); return $result; } diff --git a/htdocs/eventorganization/conferenceorbooth_card.php b/htdocs/eventorganization/conferenceorbooth_card.php index fc232406ce9..f983994c4ec 100644 --- a/htdocs/eventorganization/conferenceorbooth_card.php +++ b/htdocs/eventorganization/conferenceorbooth_card.php @@ -494,7 +494,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea //unset($object->fields['fk_project']); // Hide field already shown in banner //unset($object->fields['fk_soc']); // Hide field already shown in banner $keyforbreak='pubregister'; - + include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_view.tpl.php'; //var_dump($object); // Other attributes. Fields from hook formObjectOptions and Extrafields. diff --git a/htdocs/modulebuilder/template/admin/setup.php b/htdocs/modulebuilder/template/admin/setup.php index 96f4d831261..21057347115 100644 --- a/htdocs/modulebuilder/template/admin/setup.php +++ b/htdocs/modulebuilder/template/admin/setup.php @@ -81,8 +81,8 @@ $arrayofparameters = array( //'MYMODULE_MYPARAM4'=>array('type'=>'emailtemplate:thirdparty', 'enabled'=>1), //'MYMODULE_MYPARAM5'=>array('type'=>'yesno', 'enabled'=>1), //'MYMODULE_MYPARAM5'=>array('type'=>'thirdparty_type', 'enabled'=>1), - //'MYMODULE_MYPARAM6'=>array('type'=>'securekey', 'enabled'=>1), - //'MYMODULE_MYPARAM7'=>array('type'=>'product', 'enabled'=>1), + //'MYMODULE_MYPARAM6'=>array('type'=>'securekey', 'enabled'=>1), + //'MYMODULE_MYPARAM7'=>array('type'=>'product', 'enabled'=>1), ); $error = 0; @@ -296,13 +296,13 @@ if ($action == 'edit') { }); }); });'; - print ''; - } + print ''; + } } elseif ($val['type'] == 'product') { - if (!empty($conf->product->enabled) || !empty($conf->service->enabled)) { - $selected = (empty($conf->global->$constname) ? '' : $conf->global->$constname); - $form->select_produits($selected, $constname, '', 0); - } + if (!empty($conf->product->enabled) || !empty($conf->service->enabled)) { + $selected = (empty($conf->global->$constname) ? '' : $conf->global->$constname); + $form->select_produits($selected, $constname, '', 0); + } } else { print ''; } @@ -370,13 +370,13 @@ if ($action == 'edit') { print $langs->trans("NorProspectNorCustomer"); } } elseif ($val['type'] == 'product') { - $product = new Product($db); - $resprod = $product->fetch($conf->global->{$constname}); - if ($resprod > 0) { - print $product->ref; - } elseif ($resprod < 0) { - setEventMessages(null, $object->errors, "errors"); - } + $product = new Product($db); + $resprod = $product->fetch($conf->global->{$constname}); + if ($resprod > 0) { + print $product->ref; + } elseif ($resprod < 0) { + setEventMessages(null, $object->errors, "errors"); + } } else { print $conf->global->{$constname}; } diff --git a/htdocs/public/eventorganization/attendee_subscription.php b/htdocs/public/eventorganization/attendee_subscription.php index fab0a9733c8..40f238c90d6 100644 --- a/htdocs/public/eventorganization/attendee_subscription.php +++ b/htdocs/public/eventorganization/attendee_subscription.php @@ -250,7 +250,7 @@ if (empty($reshook) && $action == 'add') { // 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) { + if ($confattendee->status == 1) { $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; @@ -379,7 +379,6 @@ if (empty($reshook) && $action == 'add') { 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; } diff --git a/htdocs/public/payment/newpayment.php b/htdocs/public/payment/newpayment.php index 4460988ea60..b351367f6ea 100644 --- a/htdocs/public/payment/newpayment.php +++ b/htdocs/public/payment/newpayment.php @@ -120,7 +120,6 @@ if ($source == 'conferencesubscription') { if ($resultinvoice <= 0) { setEventMessages(null, $invoice->errors, "errors"); } else { - $invoice->fetchObjectLinked(); $linkedAttendees = $invoice->linkedObjectsIds['conferenceorboothattendee']; diff --git a/htdocs/public/project/index.php b/htdocs/public/project/index.php index ff6da63be9a..03f26ed2f37 100644 --- a/htdocs/public/project/index.php +++ b/htdocs/public/project/index.php @@ -193,13 +193,13 @@ print "\n"; // Show all action buttons print '
'; // Output introduction text -if($project->accept_conference_suggestions){ +if ($project->accept_conference_suggestions) { print ''; print '

'; } print ''; print '

'; -if($project->accept_booth_suggestions){ +if ($project->accept_booth_suggestions) { print ''; } From 99589fd69318f3777ad1913af1ac4e55f12dd797 Mon Sep 17 00:00:00 2001 From: Dorian Vabre Date: Tue, 27 Apr 2021 09:57:27 +0200 Subject: [PATCH 102/147] added fk_project in $facture --- htdocs/public/eventorganization/attendee_subscription.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/public/eventorganization/attendee_subscription.php b/htdocs/public/eventorganization/attendee_subscription.php index 40f238c90d6..5f0025b23aa 100644 --- a/htdocs/public/eventorganization/attendee_subscription.php +++ b/htdocs/public/eventorganization/attendee_subscription.php @@ -342,7 +342,7 @@ if (empty($reshook) && $action == 'add') { $facture->paye = 0; $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(); From d034446205e41d31d7c103500b99c483386852ad Mon Sep 17 00:00:00 2001 From: Dorian Vabre Date: Tue, 27 Apr 2021 10:08:32 +0200 Subject: [PATCH 103/147] not giving the invoiceref anymore in the url from newpayment to paymentok, since it was already in ref= anyway --- htdocs/public/payment/newpayment.php | 10 ---------- htdocs/public/payment/paymentok.php | 1 - 2 files changed, 11 deletions(-) diff --git a/htdocs/public/payment/newpayment.php b/htdocs/public/payment/newpayment.php index b351367f6ea..0e24d94c177 100644 --- a/htdocs/public/payment/newpayment.php +++ b/htdocs/public/payment/newpayment.php @@ -376,9 +376,6 @@ if ($action == 'dopayment') { dol_syslog("SCRIPT_URI: ".(empty($_SERVER["SCRIPT_URI"]) ? '' : $_SERVER["SCRIPT_URI"]), LOG_DEBUG); // If defined script uri must match domain of PAYPAL_API_OK and PAYPAL_API_KO // A redirect is added if API call successfull - if ($source == 'conferencesubscription') { - $PAYPAL_API_OK .= '&invoice='.dol_encode($invoice->id, $dolibarr_main_instance_unique_id); - } $mesg = print_paypal_redirect($PAYPAL_API_PRICE, $PAYPAL_API_DEVISE, $PAYPAL_PAYMENT_TYPE, $PAYPAL_API_OK, $PAYPAL_API_KO, $FULLTAG); // If we are here, it means the Paypal redirect was not done, so we show error message @@ -397,10 +394,6 @@ if ($action == 'dopayment') { $urlok = preg_replace('/securekey=[^&]+/', '', $urlok); $urlko = preg_replace('/securekey=[^&]+/', '', $urlko); - if ($source == 'conferencesubscription') { - $urlok .= '&invoice='.dol_encode($invoice->id, $dolibarr_main_instance_unique_id); - } - $mesg = ''; if (empty($PRICE) || !is_numeric($PRICE)) { $mesg = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Amount")); @@ -755,9 +748,6 @@ if ($action == 'charge' && !empty($conf->stripe->enabled)) { header("Location: ".$urlko); exit; } else { - if ($source == 'conferencesubscription') { - $urlok .= '&invoice='.dol_encode($invoice->id, $dolibarr_main_instance_unique_id); - } header("Location: ".$urlok); exit; } diff --git a/htdocs/public/payment/paymentok.php b/htdocs/public/payment/paymentok.php index 3d3946927c8..1cfeb99ec80 100644 --- a/htdocs/public/payment/paymentok.php +++ b/htdocs/public/payment/paymentok.php @@ -104,7 +104,6 @@ if (empty($FULLTAG)) { } $source = GETPOST('s', 'alpha') ? GETPOST('s', 'alpha') : GETPOST('source', 'alpha'); $ref = GETPOST('ref'); -$invoiceref = GETPOST('invoice'); $suffix = GETPOST("suffix", 'aZ09'); $membertypeid = GETPOST("membertypeid", 'int'); From a508cdbf5957dbc4d87035ee6119e374fb055147 Mon Sep 17 00:00:00 2001 From: Dorian Vabre Date: Tue, 27 Apr 2021 14:01:44 +0200 Subject: [PATCH 104/147] every dol_encode for securekey replaced with dol_hash (dol_encode kept for encoding ids --- .../class/conferenceorbooth.class.php | 2 +- .../conferenceorbooth_list.php | 2 +- htdocs/langs/en_US/eventorganization.lang | 4 ++-- .../attendee_subscription.php | 21 ++++++++++--------- .../eventorganization/subscriptionok.php | 8 +++++-- 5 files changed, 21 insertions(+), 16 deletions(-) diff --git a/htdocs/eventorganization/class/conferenceorbooth.class.php b/htdocs/eventorganization/class/conferenceorbooth.class.php index 02714496b35..16e61959f0c 100644 --- a/htdocs/eventorganization/class/conferenceorbooth.class.php +++ b/htdocs/eventorganization/class/conferenceorbooth.class.php @@ -244,7 +244,7 @@ class ConferenceOrBooth extends ActionComm $encodedid = dol_encode($id, $dolibarr_main_instance_unique_id); $link_subscription = $dolibarr_main_url_root.'/public/eventorganization/attendee_subscription.php?id='.$encodedid; - $encodedsecurekey = dol_encode($conf->global->EVENTORGANIZATION_SECUREKEY.$encodedid, $dolibarr_main_instance_unique_id); + $encodedsecurekey = dol_hash($conf->global->EVENTORGANIZATION_SECUREKEY.'conferenceorbooth'.$id, 2); $link_subscription .= '&securekey='.urlencode($encodedsecurekey); $this->fields['pubregister'] = array('type'=>'url', 'label'=>$langs->trans("PublicAttendeeSubscriptionPage"), 'enabled'=>'1', 'position'=>72, 'notnull'=>0, 'visible'=>1); diff --git a/htdocs/eventorganization/conferenceorbooth_list.php b/htdocs/eventorganization/conferenceorbooth_list.php index cbf0e91f7fa..e3ba815121c 100644 --- a/htdocs/eventorganization/conferenceorbooth_list.php +++ b/htdocs/eventorganization/conferenceorbooth_list.php @@ -366,7 +366,7 @@ if ($projectid > 0) { print '
'; diff --git a/htdocs/langs/en_US/eventorganization.lang b/htdocs/langs/en_US/eventorganization.lang index 6ef39e81ff6..55117ebb5e4 100644 --- a/htdocs/langs/en_US/eventorganization.lang +++ b/htdocs/langs/en_US/eventorganization.lang @@ -105,8 +105,8 @@ ViewAndVote = View and vote for suggested events PublicAttendeeSubscriptionPage = Public link of registration to a conference MissingOrBadSecureKey = The security key is invalid or missing EvntOrgWelcomeMessage = This form allows you to register as a new participant to the conference -EvntOrgDuration = This conference starts on %s and ends on %s -ConferenceAttendeeFee = Conference attendee fee for the event : '%s' occurring from %s to %s +EvntOrgDuration = This conference starts on %s and ends on %s. +ConferenceAttendeeFee = Conference attendee fee for the event : '%s' occurring from %s to %s. # # SubscriptionOk page # diff --git a/htdocs/public/eventorganization/attendee_subscription.php b/htdocs/public/eventorganization/attendee_subscription.php index 5f0025b23aa..0f583f7cfc0 100644 --- a/htdocs/public/eventorganization/attendee_subscription.php +++ b/htdocs/public/eventorganization/attendee_subscription.php @@ -101,16 +101,13 @@ if ($resultproject < 0) { $errmsg .= $project->error; } -// Getting 'securekey'.'id' from Post and decoding it -$encodedsecurekeyandid = GETPOST('securekey', 'alpha'); -$securekeyandid = dol_decode($encodedsecurekeyandid, $dolibarr_main_instance_unique_id); -// Securekey decomposition into pure securekey and id added at the end -$securekey = substr($securekeyandid, 0, strlen($securekeyandid)-strlen($encodedid)); -$idgotfromsecurekey = dol_decode(substr($securekeyandid, -strlen($encodedid), strlen($encodedid)), $dolibarr_main_instance_unique_id); +// Getting 'securekey'.'id' from Post and decoding it +$securekeyreceived = GETPOST('securekey', 'alpha'); +$securekeytocompare = dol_hash($conf->global->EVENTORGANIZATION_SECUREKEY.'conferenceorbooth'.$id, 2); // We check if the securekey collected is OK and if the id collected is the same than the id in the securekey -if ($securekey != $conf->global->EVENTORGANIZATION_SECUREKEY || $idgotfromsecurekey != $id) { +if ($securekeytocompare != $securekeyreceived) { print $langs->trans('MissingOrBadSecureKey'); exit; } @@ -251,7 +248,9 @@ if (empty($reshook) && $action == 'add') { // If the attendee has already paid if ($confattendee->status == 1) { - $redirection = $dolibarr_main_url_root.'/public/eventorganization/subscriptionok.php?securekey='.dol_encode($conf->global->EVENTORGANIZATION_SECUREKEY, $dolibarr_main_instance_unique_id); + $encodedid = dol_encode($id, $dolibarr_main_instance_unique_id); + $securekeyurl = dol_hash($conf->global->EVENTORGANIZATION_SECUREKEY.'conferenceorbooth'.$id, 2); + $redirection = $dolibarr_main_url_root.'/public/eventorganization/subscriptionok.php?id='.$encodedid.'&securekey='.$securekeyurl; Header("Location: ".$redirection); exit; } @@ -435,7 +434,9 @@ if (empty($reshook) && $action == 'add') { dol_syslog("Failed to send EMail to ".$sendto, LOG_ERR, 0, '_payment'); } - $redirection = $dolibarr_main_url_root.'/public/eventorganization/subscriptionok.php?securekey='.dol_encode($conf->global->EVENTORGANIZATION_SECUREKEY, $dolibarr_main_instance_unique_id); + $encodedid = dol_encode($id, $dolibarr_main_instance_unique_id); + $securekeyurl = dol_hash($conf->global->EVENTORGANIZATION_SECUREKEY.'conferenceorbooth'.$id, 2); + $redirection = $dolibarr_main_url_root.'/public/eventorganization/subscriptionok.php?id='.$encodedid.'&securekey='.$securekeyurl; Header("Location: ".$redirection); exit; } @@ -478,7 +479,7 @@ print ''; print ''; print ''; print ''; -print ''; +print ''; print '
'; diff --git a/htdocs/public/eventorganization/subscriptionok.php b/htdocs/public/eventorganization/subscriptionok.php index 81db5ac1c02..31c3281a526 100644 --- a/htdocs/public/eventorganization/subscriptionok.php +++ b/htdocs/public/eventorganization/subscriptionok.php @@ -65,8 +65,12 @@ $object = new stdClass(); // For triggers $error = 0; // Security check -$securekey = dol_decode(GETPOST('securekey'), $dolibarr_main_instance_unique_id); -if ($securekey != $conf->global->EVENTORGANIZATION_SECUREKEY) { +$encodedid = GETPOST("id"); +$id = dol_decode($encodedid, $dolibarr_main_instance_unique_id); +$securekeyreceived = GETPOST("securekey"); +$securekeytocompare = dol_hash($conf->global->EVENTORGANIZATION_SECUREKEY.'conferenceorbooth'.$id, 2); + +if ($securekeyreceived != $securekeytocompare) { print $langs->trans('MissingOrBadSecureKey'); exit; } From fab12bc5e582e61b41e42487acdfea7c27d9e45e Mon Sep 17 00:00:00 2001 From: Dorian Vabre Date: Tue, 27 Apr 2021 14:04:08 +0200 Subject: [PATCH 105/147] removed the indicated id of conf when on the subscription page for security (now showing label instead) --- htdocs/langs/en_US/eventorganization.lang | 2 +- htdocs/public/eventorganization/attendee_subscription.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/langs/en_US/eventorganization.lang b/htdocs/langs/en_US/eventorganization.lang index 55117ebb5e4..9f75374f2a0 100644 --- a/htdocs/langs/en_US/eventorganization.lang +++ b/htdocs/langs/en_US/eventorganization.lang @@ -104,7 +104,7 @@ SuggestBooth = Suggest a booth ViewAndVote = View and vote for suggested events PublicAttendeeSubscriptionPage = Public link of registration to a conference MissingOrBadSecureKey = The security key is invalid or missing -EvntOrgWelcomeMessage = This form allows you to register as a new participant to the conference +EvntOrgWelcomeMessage = This form allows you to register as a new participant to the conference : '%s' EvntOrgDuration = This conference starts on %s and ends on %s. ConferenceAttendeeFee = Conference attendee fee for the event : '%s' occurring from %s to %s. # diff --git a/htdocs/public/eventorganization/attendee_subscription.php b/htdocs/public/eventorganization/attendee_subscription.php index 0f583f7cfc0..f6b167d91f3 100644 --- a/htdocs/public/eventorganization/attendee_subscription.php +++ b/htdocs/public/eventorganization/attendee_subscription.php @@ -466,8 +466,8 @@ print '
'; print '
'; // Welcome message -print $langs->trans("EvntOrgWelcomeMessage"); -print $id.".".'
'; +print $langs->trans("EvntOrgWelcomeMessage", $conference->label); +print '
'; print $langs->trans("EvntOrgDuration", dol_print_date($conference->datep), dol_print_date($conference->datef)); print '
'; From 79dce3ad0567ffed65841402e8a9e515c989802e Mon Sep 17 00:00:00 2001 From: Dorian Vabre Date: Tue, 27 Apr 2021 14:06:40 +0200 Subject: [PATCH 106/147] typo in comment --- htdocs/public/eventorganization/attendee_subscription.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/public/eventorganization/attendee_subscription.php b/htdocs/public/eventorganization/attendee_subscription.php index f6b167d91f3..5c31c88c38a 100644 --- a/htdocs/public/eventorganization/attendee_subscription.php +++ b/htdocs/public/eventorganization/attendee_subscription.php @@ -102,7 +102,7 @@ if ($resultproject < 0) { } -// Getting 'securekey'.'id' from Post and decoding it +// Security check $securekeyreceived = GETPOST('securekey', 'alpha'); $securekeytocompare = dol_hash($conf->global->EVENTORGANIZATION_SECUREKEY.'conferenceorbooth'.$id, 2); From 74057251980a089632f4bb1d28009dddaddf0792 Mon Sep 17 00:00:00 2001 From: Dorian Vabre Date: Tue, 27 Apr 2021 14:11:46 +0200 Subject: [PATCH 107/147] added security check at beginning of /project/index page (according to the security I added in the previous commits) --- .../public/eventorganization/attendee_subscription.php | 2 +- htdocs/public/project/index.php | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/htdocs/public/eventorganization/attendee_subscription.php b/htdocs/public/eventorganization/attendee_subscription.php index 5c31c88c38a..4940f5965fe 100644 --- a/htdocs/public/eventorganization/attendee_subscription.php +++ b/htdocs/public/eventorganization/attendee_subscription.php @@ -106,7 +106,7 @@ if ($resultproject < 0) { $securekeyreceived = GETPOST('securekey', 'alpha'); $securekeytocompare = dol_hash($conf->global->EVENTORGANIZATION_SECUREKEY.'conferenceorbooth'.$id, 2); -// We check if the securekey collected is OK and if the id collected is the same than the id in the securekey +// We check if the securekey collected is OK if ($securekeytocompare != $securekeyreceived) { print $langs->trans('MissingOrBadSecureKey'); exit; diff --git a/htdocs/public/project/index.php b/htdocs/public/project/index.php index 03f26ed2f37..d1744db0b4e 100644 --- a/htdocs/public/project/index.php +++ b/htdocs/public/project/index.php @@ -78,7 +78,15 @@ $langs->loadLangs(array("main", "other", "dict", "bills", "companies", "errors", // No check on module enabled. Done later according to $validpaymentmethod $action = GETPOST('action', 'aZ09'); -$id = dol_decode(GETPOST('id'), $dolibarr_main_instance_unique_id); +$encodedid = GETPOST('id'); +$id = dol_decode($encodedid, $dolibarr_main_instance_unique_id); +$securekeyreceived = GETPOST("securekey"); +$securekeytocompare = dol_hash($conf->global->EVENTORGANIZATION_SECUREKEY.'conferenceorbooth'.$id, 2); + +if ($securekeytocompare != $securekeyreceived) { + print $langs->trans('MissingOrBadSecureKey'); + exit; +} // Define $urlwithroot //$urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root)); From 9fc67275fd7ce174a9ca2c50dfcef41de1e72137 Mon Sep 17 00:00:00 2001 From: altairis-noe Date: Tue, 27 Apr 2021 15:55:51 +0200 Subject: [PATCH 108/147] llx_c_productbatch_status to migration and translatable strings --- .../install/mysql/data/llx_c_productbatch_status.sql | 4 ++-- htdocs/install/mysql/migration/13.0.0-14.0.0.sql | 11 +++++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/htdocs/install/mysql/data/llx_c_productbatch_status.sql b/htdocs/install/mysql/data/llx_c_productbatch_status.sql index c925c0cd937..cd57bbb504b 100644 --- a/htdocs/install/mysql/data/llx_c_productbatch_status.sql +++ b/htdocs/install/mysql/data/llx_c_productbatch_status.sql @@ -23,6 +23,6 @@ -- de l'install et tous les sigles '--' sont supprimés. -- -INSERT INTO llx_c_productbatch_status (code, label, active) VALUES ('OK', 'En état de marche', 1); -INSERT INTO llx_c_productbatch_status (code, label, active) VALUES ('KO', 'Hors d’usage', 1); +INSERT INTO llx_c_productbatch_status (code, label, active) VALUES ('OK', 'InWorkingOrder', 1); +INSERT INTO llx_c_productbatch_status (code, label, active) VALUES ('KO', 'OutOfOrder', 1); diff --git a/htdocs/install/mysql/migration/13.0.0-14.0.0.sql b/htdocs/install/mysql/migration/13.0.0-14.0.0.sql index 3f17d23b51f..818381588c4 100644 --- a/htdocs/install/mysql/migration/13.0.0-14.0.0.sql +++ b/htdocs/install/mysql/migration/13.0.0-14.0.0.sql @@ -141,6 +141,17 @@ CREATE TABLE llx_workstation_workstation_usergroup( fk_workstation integer ) ENGINE=innodb; +CREATE TABLE llx_c_producbatch_status( + rowid integer AUTO_INCREMENT PRIMARY KEY NOT NULL, + code varchar(16) NOT NULL, + label varchar(50) NOT NULL, + active integer DEFAULT 1 NOT NULL +) ENGINE=innodb; + +ALTER TABLE llx_c_productbatch_status ADD UNIQUE INDEX uk_c_productbatch_status(code); + +INSERT INTO llx_c_productbatch_status (code, label, active) VALUES ('OK', 'InWorkingOrder', 1); +INSERT INTO llx_c_productbatch_status (code, label, active) VALUES ('KO', 'OutOfOrder', 1); ALTER TABLE llx_product_customer_price ADD COLUMN ref_customer varchar(30); ALTER TABLE llx_product_customer_price_log ADD COLUMN ref_customer varchar(30); From df2849152454406114472dacbb7495af211159cb Mon Sep 17 00:00:00 2001 From: Dorian Vabre Date: Thu, 29 Apr 2021 09:40:47 +0200 Subject: [PATCH 109/147] every id is now clear in url + in the hash of the securekey --- .../eventorganization/class/conferenceorbooth.class.php | 3 +-- htdocs/eventorganization/conferenceorbooth_list.php | 3 +-- .../public/eventorganization/attendee_subscription.php | 9 +++------ htdocs/public/eventorganization/subscriptionok.php | 3 +-- htdocs/public/project/index.php | 3 +-- 5 files changed, 7 insertions(+), 14 deletions(-) diff --git a/htdocs/eventorganization/class/conferenceorbooth.class.php b/htdocs/eventorganization/class/conferenceorbooth.class.php index 16e61959f0c..0df30ac61db 100644 --- a/htdocs/eventorganization/class/conferenceorbooth.class.php +++ b/htdocs/eventorganization/class/conferenceorbooth.class.php @@ -241,8 +241,7 @@ class ConferenceOrBooth extends ActionComm $result = parent::fetch($id, $ref, $ref_ext, $email_msgid); - $encodedid = dol_encode($id, $dolibarr_main_instance_unique_id); - $link_subscription = $dolibarr_main_url_root.'/public/eventorganization/attendee_subscription.php?id='.$encodedid; + $link_subscription = $dolibarr_main_url_root.'/public/eventorganization/attendee_subscription.php?id='.$id; $encodedsecurekey = dol_hash($conf->global->EVENTORGANIZATION_SECUREKEY.'conferenceorbooth'.$id, 2); $link_subscription .= '&securekey='.urlencode($encodedsecurekey); diff --git a/htdocs/eventorganization/conferenceorbooth_list.php b/htdocs/eventorganization/conferenceorbooth_list.php index e3ba815121c..be8770b6390 100644 --- a/htdocs/eventorganization/conferenceorbooth_list.php +++ b/htdocs/eventorganization/conferenceorbooth_list.php @@ -364,8 +364,7 @@ if ($projectid > 0) { // Link to the vote/register page print '
'; print ''; print '

'.$text.'

'.$langs->trans("EvntOrgRegistrationWelcomeMessage").'
'.$langs->trans("EvntOrgRegistrationHelpMessage").' '.$id.'.

'.$project->note_public.'


'.$langs->trans("EvntOrgRegistrationWelcomeMessage").'
'.$langs->trans("EvntOrgRegistrationHelpMessage").' '.$id.'.

'.$project->note_public.'

'.$langs->trans("Designation"); print ''.$text; print ''; - print ''; + print ''; print '
'.$langs->trans("Designation"); print ''.$text; print ''; - print ''; + print ''; print '
'.$langs->trans("Amount"); print ''; - $valtoshow = $invoice->total_ttc; + $valtoshow = $amount; print ''.price($valtoshow).''; print ''; print ''; From f8479b4a574a2f175f00daa1fc7c88cca3e5b787 Mon Sep 17 00:00:00 2001 From: Dorian Vabre Date: Fri, 23 Apr 2021 16:37:39 +0200 Subject: [PATCH 098/147] fixed invoice validation, payment, and attendee validation --- .../attendee_subscription.php | 2 +- htdocs/public/payment/newpayment.php | 28 +++++++++---------- htdocs/public/payment/paymentok.php | 12 ++++++-- 3 files changed, 25 insertions(+), 17 deletions(-) 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 '
'.$langs->trans("RegisterPage").''; $encodedid = dol_encode($project->id, $dolibarr_main_instance_unique_id); $linkregister = $dolibarr_main_url_root.'/public/project/index.php?id='.$encodedid; - $encodedsecurekey = dol_encode($conf->global->EVENTORGANIZATION_SECUREKEY.$encodedid, $dolibarr_main_instance_unique_id); + $encodedsecurekey = dol_hash($conf->global->EVENTORGANIZATION_SECUREKEY.'conferenceorbooth'.$project->id, 2); $linkregister .= '&securekey='.urlencode($encodedsecurekey); print ''.$linkregister.''; print '
'.$langs->trans("RegisterPage").''; - $encodedid = dol_encode($project->id, $dolibarr_main_instance_unique_id); - $linkregister = $dolibarr_main_url_root.'/public/project/index.php?id='.$encodedid; + $linkregister = $dolibarr_main_url_root.'/public/project/index.php?id='.$project->id; $encodedsecurekey = dol_hash($conf->global->EVENTORGANIZATION_SECUREKEY.'conferenceorbooth'.$project->id, 2); $linkregister .= '&securekey='.urlencode($encodedsecurekey); print ''.$linkregister.''; diff --git a/htdocs/public/eventorganization/attendee_subscription.php b/htdocs/public/eventorganization/attendee_subscription.php index 4940f5965fe..c833cdaec8e 100644 --- a/htdocs/public/eventorganization/attendee_subscription.php +++ b/htdocs/public/eventorganization/attendee_subscription.php @@ -85,8 +85,7 @@ $email = GETPOST("email"); $societe = GETPOST("societe"); // Getting id from Post and decoding it -$encodedid = GETPOST('id'); -$id = dol_decode($encodedid, $dolibarr_main_instance_unique_id); +$id = GETPOST('id'); $conference = new ConferenceOrBooth($db); $resultconf = $conference->fetch($id); @@ -248,9 +247,8 @@ if (empty($reshook) && $action == 'add') { // If the attendee has already paid if ($confattendee->status == 1) { - $encodedid = dol_encode($id, $dolibarr_main_instance_unique_id); $securekeyurl = dol_hash($conf->global->EVENTORGANIZATION_SECUREKEY.'conferenceorbooth'.$id, 2); - $redirection = $dolibarr_main_url_root.'/public/eventorganization/subscriptionok.php?id='.$encodedid.'&securekey='.$securekeyurl; + $redirection = $dolibarr_main_url_root.'/public/eventorganization/subscriptionok.php?id='.$id.'&securekey='.$securekeyurl; Header("Location: ".$redirection); exit; } @@ -434,9 +432,8 @@ if (empty($reshook) && $action == 'add') { dol_syslog("Failed to send EMail to ".$sendto, LOG_ERR, 0, '_payment'); } - $encodedid = dol_encode($id, $dolibarr_main_instance_unique_id); $securekeyurl = dol_hash($conf->global->EVENTORGANIZATION_SECUREKEY.'conferenceorbooth'.$id, 2); - $redirection = $dolibarr_main_url_root.'/public/eventorganization/subscriptionok.php?id='.$encodedid.'&securekey='.$securekeyurl; + $redirection = $dolibarr_main_url_root.'/public/eventorganization/subscriptionok.php?id='.$id.'&securekey='.$securekeyurl; Header("Location: ".$redirection); exit; } diff --git a/htdocs/public/eventorganization/subscriptionok.php b/htdocs/public/eventorganization/subscriptionok.php index 31c3281a526..02fb456f7d2 100644 --- a/htdocs/public/eventorganization/subscriptionok.php +++ b/htdocs/public/eventorganization/subscriptionok.php @@ -65,8 +65,7 @@ $object = new stdClass(); // For triggers $error = 0; // Security check -$encodedid = GETPOST("id"); -$id = dol_decode($encodedid, $dolibarr_main_instance_unique_id); +$id = GETPOST("id"); $securekeyreceived = GETPOST("securekey"); $securekeytocompare = dol_hash($conf->global->EVENTORGANIZATION_SECUREKEY.'conferenceorbooth'.$id, 2); diff --git a/htdocs/public/project/index.php b/htdocs/public/project/index.php index d1744db0b4e..ce48db9e729 100644 --- a/htdocs/public/project/index.php +++ b/htdocs/public/project/index.php @@ -78,8 +78,7 @@ $langs->loadLangs(array("main", "other", "dict", "bills", "companies", "errors", // No check on module enabled. Done later according to $validpaymentmethod $action = GETPOST('action', 'aZ09'); -$encodedid = GETPOST('id'); -$id = dol_decode($encodedid, $dolibarr_main_instance_unique_id); +$id = GETPOST('id'); $securekeyreceived = GETPOST("securekey"); $securekeytocompare = dol_hash($conf->global->EVENTORGANIZATION_SECUREKEY.'conferenceorbooth'.$id, 2); From d1fe595c09af59eac57d24f19bc512840d974bd1 Mon Sep 17 00:00:00 2001 From: Dorian Vabre Date: Thu, 29 Apr 2021 10:00:49 +0200 Subject: [PATCH 110/147] fix on the clear ids --- htdocs/public/eventorganization/attendee_subscription.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/public/eventorganization/attendee_subscription.php b/htdocs/public/eventorganization/attendee_subscription.php index c833cdaec8e..70e994d57cd 100644 --- a/htdocs/public/eventorganization/attendee_subscription.php +++ b/htdocs/public/eventorganization/attendee_subscription.php @@ -475,7 +475,7 @@ print '
'. print ''; print ''; print ''; -print ''; +print ''; print ''; print '
'; From 762f41ea861018239eaa16cc88ca952960f107ef Mon Sep 17 00:00:00 2001 From: altairis-noe Date: Thu, 29 Apr 2021 12:49:15 +0200 Subject: [PATCH 111/147] llx_c_productbatch_qcstatus as dictionnary name --- htdocs/admin/dict.php | 7 +++++-- htdocs/install/mysql/migration/13.0.0-14.0.0.sql | 8 ++++---- ...status.key.sql => llx_c_productbatch_qcstatus.key.sql} | 2 +- ...ctbatch_status.sql => llx_c_productbatch_qcstatus.sql} | 2 +- htdocs/langs/en_US/productbatch.lang | 3 +++ htdocs/langs/fr_FR/productbatch.lang | 6 +++++- 6 files changed, 19 insertions(+), 9 deletions(-) rename htdocs/install/mysql/tables/{llx_c_productbatch_status.key.sql => llx_c_productbatch_qcstatus.key.sql} (90%) rename htdocs/install/mysql/tables/{llx_c_productbatch_status.sql => llx_c_productbatch_qcstatus.sql} (96%) diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php index 8efbbf4cbfa..2b331c0c175 100644 --- a/htdocs/admin/dict.php +++ b/htdocs/admin/dict.php @@ -146,7 +146,7 @@ $tabname[39] = MAIN_DB_PREFIX."c_prospectcontactlevel"; $tabname[40] = MAIN_DB_PREFIX."c_stcommcontact"; $tabname[41] = MAIN_DB_PREFIX."c_transport_mode"; $tabname[42] = MAIN_DB_PREFIX."c_product_nature"; -$tabname[43] = MAIN_DB_PREFIX."c_productbatch_status"; +$tabname[43] = MAIN_DB_PREFIX."c_productbatch_qcstatus"; // Dictionary labels $tablib = array(); @@ -238,7 +238,7 @@ $tabsql[39] = "SELECT code, label as libelle, sortorder, active FROM ".MAIN_DB_P $tabsql[40] = "SELECT id as rowid, code, libelle, picto, active FROM ".MAIN_DB_PREFIX."c_stcommcontact"; $tabsql[41] = "SELECT rowid as rowid, code, label, active FROM ".MAIN_DB_PREFIX."c_transport_mode"; $tabsql[42] = "SELECT rowid as rowid, code, label, active FROM ".MAIN_DB_PREFIX."c_product_nature"; -$tabsql[43] = "SELECT rowid, code, label, active FROM ".MAIN_DB_PREFIX."c_productbatch_status"; +$tabsql[43] = "SELECT rowid, code, label, active FROM ".MAIN_DB_PREFIX."c_productbatch_qcstatus"; // Criteria to sort dictionaries $tabsqlsort = array(); @@ -1979,6 +1979,9 @@ if ($id) { } elseif ($fieldlist[$field] == 'label' && $tabname[$id] == MAIN_DB_PREFIX.'c_product_nature') { $langs->load("products"); $valuetoshow = $langs->trans($obj->{$fieldlist[$field]}); + } elseif ($fieldlist[$field] == 'label' && $tabname[$id] == MAIN_DB_PREFIX.'c_productbatch_qcstatus') { + $langs->load("productbatch"); + $valuetoshow = $langs->trans($obj->{$fieldlist[$field]}); } $class .= ($class ? ' ' : '').'tddict'; if ($fieldlist[$field] == 'note' && $id == 10) { diff --git a/htdocs/install/mysql/migration/13.0.0-14.0.0.sql b/htdocs/install/mysql/migration/13.0.0-14.0.0.sql index 818381588c4..9eedc2872c6 100644 --- a/htdocs/install/mysql/migration/13.0.0-14.0.0.sql +++ b/htdocs/install/mysql/migration/13.0.0-14.0.0.sql @@ -141,17 +141,17 @@ CREATE TABLE llx_workstation_workstation_usergroup( fk_workstation integer ) ENGINE=innodb; -CREATE TABLE llx_c_producbatch_status( +CREATE TABLE llx_c_producbatch_qcstatus( rowid integer AUTO_INCREMENT PRIMARY KEY NOT NULL, code varchar(16) NOT NULL, label varchar(50) NOT NULL, active integer DEFAULT 1 NOT NULL ) ENGINE=innodb; -ALTER TABLE llx_c_productbatch_status ADD UNIQUE INDEX uk_c_productbatch_status(code); +ALTER TABLE llx_c_productbatch_qcstatus ADD UNIQUE INDEX uk_c_productbatch_qcstatus(code); -INSERT INTO llx_c_productbatch_status (code, label, active) VALUES ('OK', 'InWorkingOrder', 1); -INSERT INTO llx_c_productbatch_status (code, label, active) VALUES ('KO', 'OutOfOrder', 1); +INSERT INTO llx_c_productbatch_qcstatus (code, label, active) VALUES ('OK', 'InWorkingOrder', 1); +INSERT INTO llx_c_productbatch_qcstatus (code, label, active) VALUES ('KO', 'OutOfOrder', 1); ALTER TABLE llx_product_customer_price ADD COLUMN ref_customer varchar(30); ALTER TABLE llx_product_customer_price_log ADD COLUMN ref_customer varchar(30); diff --git a/htdocs/install/mysql/tables/llx_c_productbatch_status.key.sql b/htdocs/install/mysql/tables/llx_c_productbatch_qcstatus.key.sql similarity index 90% rename from htdocs/install/mysql/tables/llx_c_productbatch_status.key.sql rename to htdocs/install/mysql/tables/llx_c_productbatch_qcstatus.key.sql index fc72f556a97..1c00ac13deb 100644 --- a/htdocs/install/mysql/tables/llx_c_productbatch_status.key.sql +++ b/htdocs/install/mysql/tables/llx_c_productbatch_qcstatus.key.sql @@ -16,4 +16,4 @@ -- -- ======================================================================== -ALTER TABLE llx_c_productbatch_status ADD UNIQUE INDEX uk_c_productbatch_status(code); +ALTER TABLE llx_c_productbatch_qcstatus ADD UNIQUE INDEX uk_c_productbatch_qcstatus(code); diff --git a/htdocs/install/mysql/tables/llx_c_productbatch_status.sql b/htdocs/install/mysql/tables/llx_c_productbatch_qcstatus.sql similarity index 96% rename from htdocs/install/mysql/tables/llx_c_productbatch_status.sql rename to htdocs/install/mysql/tables/llx_c_productbatch_qcstatus.sql index 2ffad7f5939..35a9581bf8e 100644 --- a/htdocs/install/mysql/tables/llx_c_productbatch_status.sql +++ b/htdocs/install/mysql/tables/llx_c_productbatch_qcstatus.sql @@ -16,7 +16,7 @@ -- -- ======================================================================== -create table llx_c_productbatch_status +create table llx_c_productbatch_qcstatus ( rowid integer AUTO_INCREMENT PRIMARY KEY, code varchar(16) NOT NULL, diff --git a/htdocs/langs/en_US/productbatch.lang b/htdocs/langs/en_US/productbatch.lang index aedf85a4fb8..2a19be96cf6 100644 --- a/htdocs/langs/en_US/productbatch.lang +++ b/htdocs/langs/en_US/productbatch.lang @@ -33,3 +33,6 @@ LotProductTooltip=Adds an option in the product card to define a dedicated batch SNProductTooltip=Adds an option in the product card to define a dedicated serial number mask QtyToAddAfterBarcodeScan=Qty to add for each barcode/lot/serial scanned +#Traceability - qc status +OutOfOrder=Out of order +InWorkingOrder=In working order \ No newline at end of file diff --git a/htdocs/langs/fr_FR/productbatch.lang b/htdocs/langs/fr_FR/productbatch.lang index c3e48ddbeb1..49a249ce0e5 100644 --- a/htdocs/langs/fr_FR/productbatch.lang +++ b/htdocs/langs/fr_FR/productbatch.lang @@ -30,4 +30,8 @@ BatchLotNumberingModules=Modèle de génération et contrôle des numéros de lo BatchSerialNumberingModules=Modèle de génération et contrôle des numéros de série CustomMasks=Ajoute une option pour définir le masque dans la fiche produit LotProductTooltip=Crée un champ dans la fiche produit pour définir un modèle spécifique de numéro de lot -SNProductTooltip=Crée un champ dans la fiche produit pour définir un modèle spécifique de numéro de série \ No newline at end of file +SNProductTooltip=Crée un champ dans la fiche produit pour définir un modèle spécifique de numéro de série + +#Traceability - qc status +OutOfOrder=Hors d'usage +InWorkingOrder=En état de marche \ No newline at end of file From f7182d43fdd0c72cc9f49d97bf35926b36795763 Mon Sep 17 00:00:00 2001 From: altairis-noe Date: Thu, 29 Apr 2021 13:00:47 +0200 Subject: [PATCH 112/147] add entity in c_productbatch_qcstatus key --- ...roductbatch_status.sql => llx_c_productbatch_qcstatus.sql} | 4 ++-- htdocs/install/mysql/migration/13.0.0-14.0.0.sql | 3 ++- .../install/mysql/tables/llx_c_productbatch_qcstatus.key.sql | 2 +- htdocs/install/mysql/tables/llx_c_productbatch_qcstatus.sql | 3 ++- 4 files changed, 7 insertions(+), 5 deletions(-) rename htdocs/install/mysql/data/{llx_c_productbatch_status.sql => llx_c_productbatch_qcstatus.sql} (83%) diff --git a/htdocs/install/mysql/data/llx_c_productbatch_status.sql b/htdocs/install/mysql/data/llx_c_productbatch_qcstatus.sql similarity index 83% rename from htdocs/install/mysql/data/llx_c_productbatch_status.sql rename to htdocs/install/mysql/data/llx_c_productbatch_qcstatus.sql index cd57bbb504b..7e0bb6661f6 100644 --- a/htdocs/install/mysql/data/llx_c_productbatch_status.sql +++ b/htdocs/install/mysql/data/llx_c_productbatch_qcstatus.sql @@ -23,6 +23,6 @@ -- de l'install et tous les sigles '--' sont supprimés. -- -INSERT INTO llx_c_productbatch_status (code, label, active) VALUES ('OK', 'InWorkingOrder', 1); -INSERT INTO llx_c_productbatch_status (code, label, active) VALUES ('KO', 'OutOfOrder', 1); +INSERT INTO llx_c_productbatch_qcstatus (code, label, active) VALUES ('OK', 'InWorkingOrder', 1); +INSERT INTO llx_c_productbatch_qcstatus (code, label, active) VALUES ('KO', 'OutOfOrder', 1); diff --git a/htdocs/install/mysql/migration/13.0.0-14.0.0.sql b/htdocs/install/mysql/migration/13.0.0-14.0.0.sql index 9eedc2872c6..81b5f8b96f7 100644 --- a/htdocs/install/mysql/migration/13.0.0-14.0.0.sql +++ b/htdocs/install/mysql/migration/13.0.0-14.0.0.sql @@ -143,12 +143,13 @@ CREATE TABLE llx_workstation_workstation_usergroup( CREATE TABLE llx_c_producbatch_qcstatus( rowid integer AUTO_INCREMENT PRIMARY KEY NOT NULL, + entity integer NOT NULL DEFAULT 1, code varchar(16) NOT NULL, label varchar(50) NOT NULL, active integer DEFAULT 1 NOT NULL ) ENGINE=innodb; -ALTER TABLE llx_c_productbatch_qcstatus ADD UNIQUE INDEX uk_c_productbatch_qcstatus(code); +ALTER TABLE llx_c_productbatch_qcstatus ADD UNIQUE INDEX uk_c_productbatch_qcstatus(code, entity); INSERT INTO llx_c_productbatch_qcstatus (code, label, active) VALUES ('OK', 'InWorkingOrder', 1); INSERT INTO llx_c_productbatch_qcstatus (code, label, active) VALUES ('KO', 'OutOfOrder', 1); diff --git a/htdocs/install/mysql/tables/llx_c_productbatch_qcstatus.key.sql b/htdocs/install/mysql/tables/llx_c_productbatch_qcstatus.key.sql index 1c00ac13deb..9ffa27bc3a5 100644 --- a/htdocs/install/mysql/tables/llx_c_productbatch_qcstatus.key.sql +++ b/htdocs/install/mysql/tables/llx_c_productbatch_qcstatus.key.sql @@ -16,4 +16,4 @@ -- -- ======================================================================== -ALTER TABLE llx_c_productbatch_qcstatus ADD UNIQUE INDEX uk_c_productbatch_qcstatus(code); +ALTER TABLE llx_c_productbatch_qcstatus ADD UNIQUE INDEX uk_c_productbatch_qcstatus(code, entity); diff --git a/htdocs/install/mysql/tables/llx_c_productbatch_qcstatus.sql b/htdocs/install/mysql/tables/llx_c_productbatch_qcstatus.sql index 35a9581bf8e..73daa56067a 100644 --- a/htdocs/install/mysql/tables/llx_c_productbatch_qcstatus.sql +++ b/htdocs/install/mysql/tables/llx_c_productbatch_qcstatus.sql @@ -16,9 +16,10 @@ -- -- ======================================================================== -create table llx_c_productbatch_qcstatus +CREATE TABLE llx_c_productbatch_qcstatus ( rowid integer AUTO_INCREMENT PRIMARY KEY, + entity integer NOT NULL DEFAULT 1, code varchar(16) NOT NULL, label varchar(50) NOT NULL, active integer DEFAULT 1 NOT NULL From b04afc17538981a8b259b5cf0d1e397fd645eb4d Mon Sep 17 00:00:00 2001 From: altairis-noe Date: Thu, 29 Apr 2021 13:08:24 +0200 Subject: [PATCH 113/147] merge conflict resolution --- htdocs/admin/dict.php | 4 ++-- htdocs/langs/en_US/productbatch.lang | 2 +- htdocs/langs/fr_FR/productbatch.lang | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php index 2b331c0c175..06aad44d123 100644 --- a/htdocs/admin/dict.php +++ b/htdocs/admin/dict.php @@ -1978,10 +1978,10 @@ if ($id) { $valuetoshow = $obj->state_code; } elseif ($fieldlist[$field] == 'label' && $tabname[$id] == MAIN_DB_PREFIX.'c_product_nature') { $langs->load("products"); - $valuetoshow = $langs->trans($obj->{$fieldlist[$field]}); + $valuetoshow = $langs->trans($obj->{$value}); } elseif ($fieldlist[$field] == 'label' && $tabname[$id] == MAIN_DB_PREFIX.'c_productbatch_qcstatus') { $langs->load("productbatch"); - $valuetoshow = $langs->trans($obj->{$fieldlist[$field]}); + $valuetoshow = $langs->trans($obj->{$value}); } $class .= ($class ? ' ' : '').'tddict'; if ($fieldlist[$field] == 'note' && $id == 10) { diff --git a/htdocs/langs/en_US/productbatch.lang b/htdocs/langs/en_US/productbatch.lang index 2a19be96cf6..756eb0a5947 100644 --- a/htdocs/langs/en_US/productbatch.lang +++ b/htdocs/langs/en_US/productbatch.lang @@ -35,4 +35,4 @@ QtyToAddAfterBarcodeScan=Qty to add for each barcode/lot/serial scanned #Traceability - qc status OutOfOrder=Out of order -InWorkingOrder=In working order \ No newline at end of file +InWorkingOrder=In working order diff --git a/htdocs/langs/fr_FR/productbatch.lang b/htdocs/langs/fr_FR/productbatch.lang index 49a249ce0e5..37ebb65135b 100644 --- a/htdocs/langs/fr_FR/productbatch.lang +++ b/htdocs/langs/fr_FR/productbatch.lang @@ -34,4 +34,4 @@ SNProductTooltip=Crée un champ dans la fiche produit pour définir un modèle s #Traceability - qc status OutOfOrder=Hors d'usage -InWorkingOrder=En état de marche \ No newline at end of file +InWorkingOrder=En état de marche From f3ede35b4fa66d79132f7c672ac7106533447878 Mon Sep 17 00:00:00 2001 From: altairis-noe Date: Thu, 29 Apr 2021 13:18:14 +0200 Subject: [PATCH 114/147] lang correction --- htdocs/langs/en_US/admin.lang | 2 +- htdocs/langs/fr_FR/admin.lang | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 9f93b416668..85bc7871a74 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -1043,7 +1043,7 @@ DictionaryOpportunityStatus=Lead status for project/lead DictionaryExpenseTaxCat=Expense report - Transportation categories DictionaryExpenseTaxRange=Expense report - Range by transportation category DictionaryTransportMode=Intracomm report - Transport mode -DictionaryBatchStatus=Product batch status +DictionaryBatchStatus=Product lot/serial Quality Control status TypeOfUnit=Type of unit SetupSaved=Setup saved SetupNotSaved=Setup not saved diff --git a/htdocs/langs/fr_FR/admin.lang b/htdocs/langs/fr_FR/admin.lang index ff8531e1809..9d33eb2b74a 100644 --- a/htdocs/langs/fr_FR/admin.lang +++ b/htdocs/langs/fr_FR/admin.lang @@ -1043,7 +1043,7 @@ DictionaryOpportunityStatus=Statut d'opportunités pour les affaires/projets DictionaryExpenseTaxCat=Note de frais - catégories de déplacement DictionaryExpenseTaxRange=Note de frais - Tri par catégorie de déplacement DictionaryTransportMode=Déclaration d'échanges intracommunautaires - Mode de transport -DictionaryBatchStatus=État du lot (produits) +DictionaryBatchStatus=État de qualité du lot/série (produits) TypeOfUnit=Type d'unité SetupSaved=Configuration sauvegardée SetupNotSaved=Configuration non enregistrée From 05a96b3ee2bf7c08e67363a6baeb0e8267c1dede Mon Sep 17 00:00:00 2001 From: Francis Appels Date: Fri, 30 Apr 2021 10:46:05 +0200 Subject: [PATCH 115/147] FIX missing token on dolGetButtonAction for action delete --- htdocs/core/lib/functions.lib.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 37e55b42fde..73f75cc98cf 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -8731,6 +8731,7 @@ function dolGetButtonAction($label, $html = '', $actionType = 'default', $url = $class = 'butAction'; if ($actionType == 'danger' || $actionType == 'delete') { $class = 'butActionDelete'; + $url .= '&token='.newToken(); } $attr = array( From 773b16928d5d2fed4e0635eb44a2d62fdd035fcc Mon Sep 17 00:00:00 2001 From: Francis Appels Date: Fri, 30 Apr 2021 11:15:01 +0200 Subject: [PATCH 116/147] only if no token --- htdocs/core/lib/functions.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 73f75cc98cf..766ee1b71a8 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -8731,7 +8731,7 @@ function dolGetButtonAction($label, $html = '', $actionType = 'default', $url = $class = 'butAction'; if ($actionType == 'danger' || $actionType == 'delete') { $class = 'butActionDelete'; - $url .= '&token='.newToken(); + if (strpos($url, 'token=') === false) $url .= '&token='.newToken(); } $attr = array( From ce677c4f272fbc4fcac7754592ba5566ee9f8cf4 Mon Sep 17 00:00:00 2001 From: lmarcouiller Date: Fri, 30 Apr 2021 14:50:18 +0200 Subject: [PATCH 117/147] Fix #17361 : change of llx_export_model type to varchar(64) --- htdocs/install/mysql/migration/12.0.0-13.0.0.sql | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/install/mysql/migration/12.0.0-13.0.0.sql b/htdocs/install/mysql/migration/12.0.0-13.0.0.sql index bfa8bf01b39..81471e18e4c 100644 --- a/htdocs/install/mysql/migration/12.0.0-13.0.0.sql +++ b/htdocs/install/mysql/migration/12.0.0-13.0.0.sql @@ -583,4 +583,5 @@ insert into llx_c_actioncomm (id, code, type, libelle, module, active, position) -- VMYSQL4.3 ALTER TABLE llx_accounting_bookkeeping MODIFY COLUMN montant double(24,8) NULL; -- VPGSQL8.2 ALTER TABLE llx_accounting_bookkeeping ALTER COLUMN montant DROP NOT NULL; +ALTER TABLE llx_export_model MODIFY COLUMN type varchar(64); From 034378a9588da5cb0b29614d7acda402a53e9783 Mon Sep 17 00:00:00 2001 From: daraelmin Date: Tue, 4 May 2021 00:58:29 +0200 Subject: [PATCH 118/147] Add online substitution keys link in mailing --- htdocs/comm/mailing/card.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/htdocs/comm/mailing/card.php b/htdocs/comm/mailing/card.php index c3ef480d2ae..98b3622d5ef 100644 --- a/htdocs/comm/mailing/card.php +++ b/htdocs/comm/mailing/card.php @@ -222,14 +222,23 @@ if (empty($reshook)) { $onlinepaymentenabled++; } if ($onlinepaymentenabled && !empty($conf->global->PAYMENT_SECURITY_TOKEN)) { + require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php'; + $substitutionarray['__ONLINEPAYMENTLINK_MEMBER__'] = getOnlinePaymentUrl(0, 'member', $obj->source_id); + $substitutionarray['__ONLINEPAYMENTLINK_DONATION__'] = getOnlinePaymentUrl(0, 'donation', $obj->source_id); + $substitutionarray['__ONLINEPAYMENTLINK_ORDER__'] = getOnlinePaymentUrl(0, 'order', $obj->source_id); + $substitutionarray['__ONLINEPAYMENTLINK_INVOICE__'] = getOnlinePaymentUrl(0, 'invoice', $obj->source_id); + $substitutionarray['__ONLINEPAYMENTLINK_CONTRACTLINE__'] = getOnlinePaymentUrl(0, 'contractline', $obj->source_id); + $substitutionarray['__SECUREKEYPAYMENT__'] = dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2); if (empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) { $substitutionarray['__SECUREKEYPAYMENT_MEMBER__'] = dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2); + $substitutionarray['__SECUREKEYPAYMENT_DONATION__'] = dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2); $substitutionarray['__SECUREKEYPAYMENT_ORDER__'] = dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2); $substitutionarray['__SECUREKEYPAYMENT_INVOICE__'] = dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2); $substitutionarray['__SECUREKEYPAYMENT_CONTRACTLINE__'] = dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2); } else { - $substitutionarray['__SECUREKEYPAYMENT_MEMBER__'] = dol_hash($conf->global->PAYMENT_SECURITY_TOKEN.'membersubscription'.$obj->source_id, 2); + $substitutionarray['__SECUREKEYPAYMENT_MEMBER__'] = dol_hash($conf->global->PAYMENT_SECURITY_TOKEN.'member'.$obj->source_id, 2); + $substitutionarray['__SECUREKEYPAYMENT_DONATION__'] = dol_hash($conf->global->PAYMENT_SECURITY_TOKEN.'donation'.$obj->source_id, 2); $substitutionarray['__SECUREKEYPAYMENT_ORDER__'] = dol_hash($conf->global->PAYMENT_SECURITY_TOKEN.'order'.$obj->source_id, 2); $substitutionarray['__SECUREKEYPAYMENT_INVOICE__'] = dol_hash($conf->global->PAYMENT_SECURITY_TOKEN.'invoice'.$obj->source_id, 2); $substitutionarray['__SECUREKEYPAYMENT_CONTRACTLINE__'] = dol_hash($conf->global->PAYMENT_SECURITY_TOKEN.'contractline'.$obj->source_id, 2); From 9ab7f4ec0194c910a94fd5c4a1e66ddef329d456 Mon Sep 17 00:00:00 2001 From: daraelmin Date: Tue, 4 May 2021 01:41:32 +0200 Subject: [PATCH 119/147] Add tooltip for new substitution keys --- htdocs/core/class/html.formmail.class.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index f56b9f6070e..ff38cdcf282 100644 --- a/htdocs/core/class/html.formmail.class.php +++ b/htdocs/core/class/html.formmail.class.php @@ -1592,15 +1592,23 @@ class FormMail extends Form $tmparray['__SECUREKEYPAYMENT__'] = $conf->global->PAYMENT_SECURITY_TOKEN; if (!empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) { if ($conf->adherent->enabled) { + $tmparray['__ONLINEPAYMENTLINK_MEMBER__'] = 'OnlinePaymentLinkUniquePerMember'; $tmparray['__SECUREKEYPAYMENT_MEMBER__'] = 'SecureKeyPAYMENTUniquePerMember'; } + if ($conf->donation->enabled) { + $tmparray['__ONLINEPAYMENTLINK_DONATION__'] = 'OnlinePaymentLinkUniquePerDonation'; + $tmparray['__SECUREKEYPAYMENT_DONATION__'] = 'SecureKeyPAYMENTUniquePerDonation'; + } if ($conf->facture->enabled) { + $tmparray['__ONLINEPAYMENTLINK_INVOICE__'] = 'OnlinePaymentLinkUniquePerInvoice'; $tmparray['__SECUREKEYPAYMENT_INVOICE__'] = 'SecureKeyPAYMENTUniquePerInvoice'; } if ($conf->commande->enabled) { + $tmparray['__ONLINEPAYMENTLINK_ORDER__'] = 'OnlinePaymentLinkUniquePerOrder'; $tmparray['__SECUREKEYPAYMENT_ORDER__'] = 'SecureKeyPAYMENTUniquePerOrder'; } if ($conf->contrat->enabled) { + $tmparray['__ONLINEPAYMENTLINK_CONTRACTLINE__'] = 'OnlinePaymentLinkUniquePerContractLine'; $tmparray['__SECUREKEYPAYMENT_CONTRACTLINE__'] = 'SecureKeyPAYMENTUniquePerContractLine'; } } From 729a5677ad4610e39f0f5e88dbc777cdd9cb67ed Mon Sep 17 00:00:00 2001 From: daraelmin Date: Tue, 4 May 2021 01:53:46 +0200 Subject: [PATCH 120/147] Group tooltip by key type --- htdocs/core/class/html.formmail.class.php | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index ff38cdcf282..96f6ee0a741 100644 --- a/htdocs/core/class/html.formmail.class.php +++ b/htdocs/core/class/html.formmail.class.php @@ -1592,25 +1592,37 @@ class FormMail extends Form $tmparray['__SECUREKEYPAYMENT__'] = $conf->global->PAYMENT_SECURITY_TOKEN; if (!empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) { if ($conf->adherent->enabled) { - $tmparray['__ONLINEPAYMENTLINK_MEMBER__'] = 'OnlinePaymentLinkUniquePerMember'; $tmparray['__SECUREKEYPAYMENT_MEMBER__'] = 'SecureKeyPAYMENTUniquePerMember'; } if ($conf->donation->enabled) { - $tmparray['__ONLINEPAYMENTLINK_DONATION__'] = 'OnlinePaymentLinkUniquePerDonation'; $tmparray['__SECUREKEYPAYMENT_DONATION__'] = 'SecureKeyPAYMENTUniquePerDonation'; } if ($conf->facture->enabled) { - $tmparray['__ONLINEPAYMENTLINK_INVOICE__'] = 'OnlinePaymentLinkUniquePerInvoice'; $tmparray['__SECUREKEYPAYMENT_INVOICE__'] = 'SecureKeyPAYMENTUniquePerInvoice'; } if ($conf->commande->enabled) { - $tmparray['__ONLINEPAYMENTLINK_ORDER__'] = 'OnlinePaymentLinkUniquePerOrder'; $tmparray['__SECUREKEYPAYMENT_ORDER__'] = 'SecureKeyPAYMENTUniquePerOrder'; } if ($conf->contrat->enabled) { - $tmparray['__ONLINEPAYMENTLINK_CONTRACTLINE__'] = 'OnlinePaymentLinkUniquePerContractLine'; $tmparray['__SECUREKEYPAYMENT_CONTRACTLINE__'] = 'SecureKeyPAYMENTUniquePerContractLine'; } + + //Online payement link + if ($conf->adherent->enabled) { + $tmparray['__ONLINEPAYMENTLINK_MEMBER__'] = 'OnlinePaymentLinkUniquePerMember'; + } + if ($conf->donation->enabled) { + $tmparray['__ONLINEPAYMENTLINK_DONATION__'] = 'OnlinePaymentLinkUniquePerDonation'; + } + if ($conf->facture->enabled) { + $tmparray['__ONLINEPAYMENTLINK_INVOICE__'] = 'OnlinePaymentLinkUniquePerInvoice'; + } + if ($conf->commande->enabled) { + $tmparray['__ONLINEPAYMENTLINK_ORDER__'] = 'OnlinePaymentLinkUniquePerOrder'; + } + if ($conf->contrat->enabled) { + $tmparray['__ONLINEPAYMENTLINK_CONTRACTLINE__'] = 'OnlinePaymentLinkUniquePerContractLine'; + } } } else { /* No need to show into tooltip help, option is not enabled From ee4288fae31fd2321d7e840902a66eb1ca10c633 Mon Sep 17 00:00:00 2001 From: kastoras Date: Tue, 4 May 2021 10:48:31 +0300 Subject: [PATCH 121/147] NEW Add pagination at Get Products response At REST API generate pagination data when getting products list using $pagination_data parameter --- htdocs/product/class/api_products.class.php | 24 ++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/htdocs/product/class/api_products.class.php b/htdocs/product/class/api_products.class.php index fbbf17628ba..e6dbae812bc 100644 --- a/htdocs/product/class/api_products.class.php +++ b/htdocs/product/class/api_products.class.php @@ -167,9 +167,10 @@ class Products extends DolibarrApi * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.tobuy:=:0) and (t.tosell:=:1)" * @param bool $ids_only Return only IDs of product instead of all properties (faster, above all if list is long) * @param int $variant_filter Use this param to filter list (0 = all, 1=products without variants, 2=parent of variants, 3=variants only) + * @param bool $pagination_data If this parameter is set to true the response will include pagination data. Default value is false. Page starts from 0 * @return array Array of product objects */ - public function index($sortfield = "t.ref", $sortorder = 'ASC', $limit = 100, $page = 0, $mode = 0, $category = 0, $sqlfilters = '', $ids_only = false, $variant_filter = 0) + public function index($sortfield = "t.ref", $sortorder = 'ASC', $limit = 100, $page = 0, $mode = 0, $category = 0, $sqlfilters = '', $ids_only = false, $variant_filter = 0, $pagination_data = false) { global $db, $conf; @@ -221,6 +222,9 @@ class Products extends DolibarrApi $sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; } + //this query will return total products with the filters given + $sqlTotals = str_replace('SELECT t.rowid, t.ref, t.ref_ext','SELECT count(t.rowid) as total',$sql); + $sql .= $this->db->order($sortfield, $sortorder); if ($limit) { if ($page < 0) { @@ -254,6 +258,24 @@ class Products extends DolibarrApi if (!count($obj_ret)) { throw new RestException(404, 'No product found'); } + + //if $pagination_data is true the response will contain element data with all values and element pagination with pagination data(total,page,limit) + if($pagination_data){ + $totalsResult = $this->db->query($sqlTotals); + $total = $this->db->fetch_object($totalsResult)->total; + + $tmp = $obj_ret; + $obj_ret = []; + + $obj_ret['data'] = $tmp; + $obj_ret['pagination'] = [ + 'total' => (int)$total, + 'page' => $page, //count starts from 0 + 'page_count' => ceil((int)$total/$limit), + 'limit' => $limit + ]; + } + return $obj_ret; } From 60fc9f5ecd671ca4ff57a90e2861ee74aafecb02 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Tue, 4 May 2021 07:52:53 +0000 Subject: [PATCH 122/147] Fixing style errors. --- htdocs/product/class/api_products.class.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/htdocs/product/class/api_products.class.php b/htdocs/product/class/api_products.class.php index e6dbae812bc..fc89787deda 100644 --- a/htdocs/product/class/api_products.class.php +++ b/htdocs/product/class/api_products.class.php @@ -223,7 +223,7 @@ class Products extends DolibarrApi } //this query will return total products with the filters given - $sqlTotals = str_replace('SELECT t.rowid, t.ref, t.ref_ext','SELECT count(t.rowid) as total',$sql); + $sqlTotals = str_replace('SELECT t.rowid, t.ref, t.ref_ext', 'SELECT count(t.rowid) as total', $sql); $sql .= $this->db->order($sortfield, $sortorder); if ($limit) { @@ -260,7 +260,7 @@ class Products extends DolibarrApi } //if $pagination_data is true the response will contain element data with all values and element pagination with pagination data(total,page,limit) - if($pagination_data){ + if ($pagination_data) { $totalsResult = $this->db->query($sqlTotals); $total = $this->db->fetch_object($totalsResult)->total; @@ -269,12 +269,12 @@ class Products extends DolibarrApi $obj_ret['data'] = $tmp; $obj_ret['pagination'] = [ - 'total' => (int)$total, + 'total' => (int) $total, 'page' => $page, //count starts from 0 - 'page_count' => ceil((int)$total/$limit), + 'page_count' => ceil((int) $total/$limit), 'limit' => $limit ]; - } + } return $obj_ret; } From e497e58ebd1ec7f23efd745aecdf274acc843998 Mon Sep 17 00:00:00 2001 From: NextGestion Date: Tue, 4 May 2021 10:29:31 +0100 Subject: [PATCH 123/147] Conflicts --- htdocs/partnership/admin/about.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/htdocs/partnership/admin/about.php b/htdocs/partnership/admin/about.php index c8a01516ed6..0d3fb11c4e3 100644 --- a/htdocs/partnership/admin/about.php +++ b/htdocs/partnership/admin/about.php @@ -72,8 +72,6 @@ $backtopage = GETPOST('backtopage', 'alpha'); * Actions */ -// None - /* * View From ef6ebd4793220540d474abc9b54cc7382b2c64e7 Mon Sep 17 00:00:00 2001 From: Marc de Lima Lucio <68746600+marc-dll@users.noreply.github.com> Date: Tue, 4 May 2021 16:24:15 +0200 Subject: [PATCH 124/147] FIX: expense report: column last_main_doc forgotten in v14 migration script --- htdocs/install/mysql/migration/13.0.0-14.0.0.sql | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/install/mysql/migration/13.0.0-14.0.0.sql b/htdocs/install/mysql/migration/13.0.0-14.0.0.sql index af6c2f48f50..a18bc993441 100644 --- a/htdocs/install/mysql/migration/13.0.0-14.0.0.sql +++ b/htdocs/install/mysql/migration/13.0.0-14.0.0.sql @@ -187,6 +187,7 @@ ALTER TABLE llx_mrp_production ADD COLUMN origin_type varchar(10) AFTER origin_i ALTER TABLE llx_fichinter ADD COLUMN last_main_doc varchar(255) AFTER model_pdf; ALTER TABLE llx_projet ADD COLUMN last_main_doc varchar(255) AFTER model_pdf; +ALTER TABLE llx_expensereport ADD COLUMN last_main_doc varchar(255) DEFAULT NULL AFTER model_pdf; create table llx_payment_vat ( From c4e0d8da42696410089d4dca02f611cb60d6ec33 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Tue, 4 May 2021 17:28:20 +0200 Subject: [PATCH 125/147] FIX: merge thirparty also work for bank URL entry --- htdocs/compta/bank/class/account.class.php | 22 ++++++++++++++++++++++ htdocs/societe/card.php | 3 ++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php index 0002dbcb8ed..c59e768f6dc 100644 --- a/htdocs/compta/bank/class/account.class.php +++ b/htdocs/compta/bank/class/account.class.php @@ -1676,6 +1676,28 @@ class Account extends CommonObject $this->owner_address = 'Owner address'; $this->country_id = 1; } + + /** + * Function used to replace a thirdparty id with another one. + * + * @param DoliDB $db Database handler + * @param int $origin_id Old thirdparty id + * @param int $dest_id New thirdparty id + * @return bool + */ + public static function replaceThirdparty($db, $origin_id, $dest_id) + { + $sql = 'UPDATE '.MAIN_DB_PREFIX.'bank_url SET url_id = '.$dest_id.' WHERE url_id = '.$origin_id.' AND type=\'company\''; + + if (!$db->query($sql)) + { + //if ($ignoreerrors) return true; // TODO Not enough. If there is A-B on kept thirdarty and B-C on old one, we must get A-B-C after merge. Not A-B. + //$this->errors = $db->lasterror(); + return false; + } else { + return true; + } + } } diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index 66b5f68564e..1fbb1ad6082 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -254,7 +254,8 @@ if (empty($reshook)) 'Product' => '/product/class/product.class.php', 'Project' => '/projet/class/project.class.php', 'Ticket' => '/ticket/class/ticket.class.php', - 'User' => '/user/class/user.class.php' + 'User' => '/user/class/user.class.php', + 'Account' => '/compta/bank/class/account.class.php', ); //First, all core objects must update their tables From 6574e54a41e9f2be5aae55c4478767e15b38236b Mon Sep 17 00:00:00 2001 From: ATM john Date: Tue, 4 May 2021 18:09:13 +0200 Subject: [PATCH 126/147] Fix saving template email --- htdocs/admin/mails_templates.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/admin/mails_templates.php b/htdocs/admin/mails_templates.php index 60a15f4899e..f82e67096eb 100644 --- a/htdocs/admin/mails_templates.php +++ b/htdocs/admin/mails_templates.php @@ -257,7 +257,7 @@ if (empty($reshook)) $sql = "INSERT INTO ".$tabname[$id]." ("; // List of fields $sql .= $tabfieldinsert[$id]; - $sql .= ",active)"; + $sql .= ",active,enabled)"; $sql .= " VALUES("; // List of values @@ -289,7 +289,7 @@ if (empty($reshook)) $i++; } - $sql .= ", 1)"; + $sql .= ", 1, 1)"; dol_syslog("actionadd", LOG_DEBUG); $result = $db->query($sql); From b04dfcadc77d26e8863413dc4af7d05b6c98cfbe Mon Sep 17 00:00:00 2001 From: daraelmin Date: Tue, 4 May 2021 21:55:19 +0200 Subject: [PATCH 127/147] Add function to get html online payment link --- htdocs/core/lib/payments.lib.php | 39 ++++++++++++++++++++------------ 1 file changed, 24 insertions(+), 15 deletions(-) diff --git a/htdocs/core/lib/payments.lib.php b/htdocs/core/lib/payments.lib.php index 494a92d33e3..90fba70464c 100644 --- a/htdocs/core/lib/payments.lib.php +++ b/htdocs/core/lib/payments.lib.php @@ -3,6 +3,7 @@ * Copyright (C) 2013 Marcos García * Copyright (C) 2018 Frédéric France * Copyright (C) 2020 Abbes Bahfir + * Copyright (C) 2021 Waël Almoman * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -26,8 +27,7 @@ * @param Paiement $object Current payment object * @return array Tabs for the payment section */ -function payment_prepare_head(Paiement $object) -{ +function payment_prepare_head(Paiement $object) { global $langs, $conf; $h = 0; @@ -61,8 +61,7 @@ function payment_prepare_head(Paiement $object) * @param int $id ID of bank line * @return array Tabs for the Bankline section */ -function bankline_prepare_head($id) -{ +function bankline_prepare_head($id) { global $langs, $conf; $h = 0; @@ -96,8 +95,7 @@ function bankline_prepare_head($id) * @param Paiement $object Current payment object * @return array Tabs for the payment section */ -function payment_supplier_prepare_head(Paiement $object) -{ +function payment_supplier_prepare_head(Paiement $object) { global $langs, $conf; $h = 0; @@ -130,8 +128,7 @@ function payment_supplier_prepare_head(Paiement $object) * @param string $paymentmethod Filter on this payment method (''=none, 'paypal', ...) * @return array Array of valid payment method */ -function getValidOnlinePaymentMethods($paymentmethod = '') -{ +function getValidOnlinePaymentMethods($paymentmethod = '') { global $conf, $langs; $validpaymentmethod = array(); @@ -155,14 +152,13 @@ function getValidOnlinePaymentMethods($paymentmethod = '') } /** - * Return string with full Url + * Return string with full online payment Url * * @param string $type Type of URL ('free', 'order', 'invoice', 'contractline', 'membersubscription' ...) * @param string $ref Ref of object * @return string Url string */ -function showOnlinePaymentUrl($type, $ref) -{ +function showOnlinePaymentUrl($type, $ref) { global $langs; // Load translation files required by the page @@ -178,6 +174,21 @@ function showOnlinePaymentUrl($type, $ref) return $out; } +/** + * Return string with HTML link for online payment + * + * @param string $type Type of URL ('free', 'order', 'invoice', 'contractline', 'membersubscription' ...) + * @param string $ref Ref of object + * @param string $label Text or HTML tag to display, if empty it display the URL + * @return string Url string + */ +function getHtmlOnlinePaymentLink($type, $ref, $label='') { + $url = getOnlinePaymentUrl(0, $type, $ref); + $label = $label ? $label : $url; + return''.$label.''; +} + + /** * Return string with full Url * @@ -189,8 +200,7 @@ function showOnlinePaymentUrl($type, $ref) * @param string $localorexternal 0=Url for browser, 1=Url for external access * @return string Url string */ -function getOnlinePaymentUrl($mode, $type, $ref = '', $amount = '9.99', $freetag = 'your_tag', $localorexternal = 0) -{ +function getOnlinePaymentUrl($mode, $type, $ref = '', $amount = '9.99', $freetag = 'your_tag', $localorexternal = 0) { global $conf, $dolibarr_main_url_root; $ref = str_replace(' ', '', $ref); @@ -355,8 +365,7 @@ function getOnlinePaymentUrl($mode, $type, $ref = '', $amount = '9.99', $freetag * @param Object $object Object related to payment * @return void */ -function htmlPrintOnlinePaymentFooter($fromcompany, $langs, $addformmessage = 0, $suffix = '', $object = null) -{ +function htmlPrintOnlinePaymentFooter($fromcompany, $langs, $addformmessage = 0, $suffix = '', $object = null) { global $conf; // Juridical status From 866857c111ae2523294b40a0e40d910d43aaf3b6 Mon Sep 17 00:00:00 2001 From: daraelmin Date: Tue, 4 May 2021 21:57:59 +0200 Subject: [PATCH 128/147] Html link instead of url in substitutionarray --- htdocs/comm/mailing/card.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/htdocs/comm/mailing/card.php b/htdocs/comm/mailing/card.php index 98b3622d5ef..ce260a44a35 100644 --- a/htdocs/comm/mailing/card.php +++ b/htdocs/comm/mailing/card.php @@ -223,11 +223,11 @@ if (empty($reshook)) { } if ($onlinepaymentenabled && !empty($conf->global->PAYMENT_SECURITY_TOKEN)) { require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php'; - $substitutionarray['__ONLINEPAYMENTLINK_MEMBER__'] = getOnlinePaymentUrl(0, 'member', $obj->source_id); - $substitutionarray['__ONLINEPAYMENTLINK_DONATION__'] = getOnlinePaymentUrl(0, 'donation', $obj->source_id); - $substitutionarray['__ONLINEPAYMENTLINK_ORDER__'] = getOnlinePaymentUrl(0, 'order', $obj->source_id); - $substitutionarray['__ONLINEPAYMENTLINK_INVOICE__'] = getOnlinePaymentUrl(0, 'invoice', $obj->source_id); - $substitutionarray['__ONLINEPAYMENTLINK_CONTRACTLINE__'] = getOnlinePaymentUrl(0, 'contractline', $obj->source_id); + $substitutionarray['__ONLINEPAYMENTLINK_MEMBER__'] = getHtmlOnlinePaymentLink('member', $obj->source_id); + $substitutionarray['__ONLINEPAYMENTLINK_DONATION__'] = getHtmlOnlinePaymentLink('donation', $obj->source_id); + $substitutionarray['__ONLINEPAYMENTLINK_ORDER__'] = getHtmlOnlinePaymentLink('order', $obj->source_id); + $substitutionarray['__ONLINEPAYMENTLINK_INVOICE__'] = getHtmlOnlinePaymentLink('invoice', $obj->source_id); + $substitutionarray['__ONLINEPAYMENTLINK_CONTRACTLINE__'] = getHtmlOnlinePaymentLink('contractline', $obj->source_id); $substitutionarray['__SECUREKEYPAYMENT__'] = dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2); if (empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) { From fb3c8e698ed028cad7d5c707e1ea1c70343be14a Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Tue, 4 May 2021 20:59:32 +0000 Subject: [PATCH 129/147] Fixing style errors. --- htdocs/core/lib/payments.lib.php | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/htdocs/core/lib/payments.lib.php b/htdocs/core/lib/payments.lib.php index 90fba70464c..59d9eb4aa4c 100644 --- a/htdocs/core/lib/payments.lib.php +++ b/htdocs/core/lib/payments.lib.php @@ -27,7 +27,8 @@ * @param Paiement $object Current payment object * @return array Tabs for the payment section */ -function payment_prepare_head(Paiement $object) { +function payment_prepare_head(Paiement $object) +{ global $langs, $conf; $h = 0; @@ -61,7 +62,8 @@ function payment_prepare_head(Paiement $object) { * @param int $id ID of bank line * @return array Tabs for the Bankline section */ -function bankline_prepare_head($id) { +function bankline_prepare_head($id) +{ global $langs, $conf; $h = 0; @@ -95,7 +97,8 @@ function bankline_prepare_head($id) { * @param Paiement $object Current payment object * @return array Tabs for the payment section */ -function payment_supplier_prepare_head(Paiement $object) { +function payment_supplier_prepare_head(Paiement $object) +{ global $langs, $conf; $h = 0; @@ -128,7 +131,8 @@ function payment_supplier_prepare_head(Paiement $object) { * @param string $paymentmethod Filter on this payment method (''=none, 'paypal', ...) * @return array Array of valid payment method */ -function getValidOnlinePaymentMethods($paymentmethod = '') { +function getValidOnlinePaymentMethods($paymentmethod = '') +{ global $conf, $langs; $validpaymentmethod = array(); @@ -158,7 +162,8 @@ function getValidOnlinePaymentMethods($paymentmethod = '') { * @param string $ref Ref of object * @return string Url string */ -function showOnlinePaymentUrl($type, $ref) { +function showOnlinePaymentUrl($type, $ref) +{ global $langs; // Load translation files required by the page @@ -182,7 +187,8 @@ function showOnlinePaymentUrl($type, $ref) { * @param string $label Text or HTML tag to display, if empty it display the URL * @return string Url string */ -function getHtmlOnlinePaymentLink($type, $ref, $label='') { +function getHtmlOnlinePaymentLink($type, $ref, $label = '') +{ $url = getOnlinePaymentUrl(0, $type, $ref); $label = $label ? $label : $url; return''.$label.''; @@ -200,7 +206,8 @@ function getHtmlOnlinePaymentLink($type, $ref, $label='') { * @param string $localorexternal 0=Url for browser, 1=Url for external access * @return string Url string */ -function getOnlinePaymentUrl($mode, $type, $ref = '', $amount = '9.99', $freetag = 'your_tag', $localorexternal = 0) { +function getOnlinePaymentUrl($mode, $type, $ref = '', $amount = '9.99', $freetag = 'your_tag', $localorexternal = 0) +{ global $conf, $dolibarr_main_url_root; $ref = str_replace(' ', '', $ref); @@ -365,7 +372,8 @@ function getOnlinePaymentUrl($mode, $type, $ref = '', $amount = '9.99', $freetag * @param Object $object Object related to payment * @return void */ -function htmlPrintOnlinePaymentFooter($fromcompany, $langs, $addformmessage = 0, $suffix = '', $object = null) { +function htmlPrintOnlinePaymentFooter($fromcompany, $langs, $addformmessage = 0, $suffix = '', $object = null) +{ global $conf; // Juridical status From d840593ed795acdce1b9cbe2824ee9f982279aa0 Mon Sep 17 00:00:00 2001 From: daraelmin Date: Tue, 4 May 2021 23:19:19 +0200 Subject: [PATCH 130/147] Fix amnt can be paid for member as membersubscription --- htdocs/public/payment/newpayment.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/public/payment/newpayment.php b/htdocs/public/payment/newpayment.php index 7007455791a..1c0939ea9a8 100644 --- a/htdocs/public/payment/newpayment.php +++ b/htdocs/public/payment/newpayment.php @@ -1753,7 +1753,7 @@ if ($action != 'dopayment') { print '

'.$langs->trans("DonationPaid").''; } else { // Membership can be paid and we still allow to make renewal - if ($source == 'membersubscription' && $object->datefin > dol_now()) { + if (($source == 'member' || $source == 'membersubscription') && $object->datefin > dol_now()) { $langs->load("members"); print '
'.$langs->trans("MembershipPaid", dol_print_date($object->datefin, 'day')).'
'; print '
'.$langs->trans("PaymentWillBeRecordedForNextPeriod").'
'; From 3807804acc6babca8d63d6ef4eff8250c9091d95 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 5 May 2021 00:15:52 +0200 Subject: [PATCH 131/147] Fix option MAIN_GENERATE_SUPPLIER_ORDER_WITH_PICTURE --- .../modules/supplier_order/doc/pdf_cornas.modules.php | 7 +++---- .../modules/supplier_order/doc/pdf_muscadet.modules.php | 8 +++----- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php b/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php index 9ebff653a56..cfe7a476d05 100644 --- a/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php +++ b/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php @@ -218,12 +218,11 @@ class pdf_cornas extends ModelePDFSuppliersOrders $objphoto = new Product($this->db); $objphoto->fetch($object->lines[$i]->fk_product); - if (!empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) - { - $pdir = get_exdir($object->lines[$i]->fk_product, 2, 0, 0, $objphoto, 'product').$object->lines[$i]->fk_product."/photos/"; + if (!empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) { + $pdir = get_exdir($objphoto->id, 2, 0, 0, $objphoto, 'product').$object->lines[$i]->fk_product."/photos/"; $dir = $conf->product->dir_output.'/'.$pdir; } else { - $pdir = get_exdir(0, 2, 0, 0, $objphoto, 'product').dol_sanitizeFileName($objphoto->ref).'/'; + $pdir = get_exdir($objphoto->id, 0, 0, 0, $objphoto, 'product'); $dir = $conf->product->dir_output.'/'.$pdir; } diff --git a/htdocs/core/modules/supplier_order/doc/pdf_muscadet.modules.php b/htdocs/core/modules/supplier_order/doc/pdf_muscadet.modules.php index be195d923da..e76793db00c 100644 --- a/htdocs/core/modules/supplier_order/doc/pdf_muscadet.modules.php +++ b/htdocs/core/modules/supplier_order/doc/pdf_muscadet.modules.php @@ -233,15 +233,13 @@ class pdf_muscadet extends ModelePDFSuppliersOrders $objphoto = new Product($this->db); $objphoto->fetch($object->lines[$i]->fk_product); - if (!empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) - { - $pdir = get_exdir($object->lines[$i]->fk_product, 2, 0, 0, $objphoto, 'product').$object->lines[$i]->fk_product."/photos/"; + if (!empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) { + $pdir = get_exdir($objphoto->id, 2, 0, 0, $objphoto, 'product').$object->lines[$i]->fk_product."/photos/"; $dir = $conf->product->dir_output.'/'.$pdir; } else { - $pdir = get_exdir(0, 2, 0, 0, $objphoto, 'product').dol_sanitizeFileName($objphoto->ref).'/'; + $pdir = get_exdir($objphoto->id, 0, 0, 0, $objphoto, 'product'); $dir = $conf->product->dir_output.'/'.$pdir; } - $realpath = ''; foreach ($objphoto->liste_photos($dir, 1) as $key => $obj) { From 209682e7102155684cc5f6fa4835ed16fe163a54 Mon Sep 17 00:00:00 2001 From: lmarcouiller Date: Wed, 5 May 2021 11:30:13 +0200 Subject: [PATCH 132/147] Fix #17361 : changes into mysql/tables of export_model --- htdocs/install/mysql/tables/llx_export_model.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/install/mysql/tables/llx_export_model.sql b/htdocs/install/mysql/tables/llx_export_model.sql index 53952430c14..7e68eab4ad5 100644 --- a/htdocs/install/mysql/tables/llx_export_model.sql +++ b/htdocs/install/mysql/tables/llx_export_model.sql @@ -24,7 +24,7 @@ create table llx_export_model rowid integer AUTO_INCREMENT PRIMARY KEY, fk_user integer DEFAULT 0 NOT NULL, label varchar(50) NOT NULL, - type varchar(20) NOT NULL, + type varchar(64) NOT NULL, field text NOT NULL, filter text From 139ae3db0025ce86d1898739f3df4e6e7a24ec0a Mon Sep 17 00:00:00 2001 From: Marc de Lima Lucio <68746600+marc-dll@users.noreply.github.com> Date: Wed, 5 May 2021 11:49:11 +0200 Subject: [PATCH 133/147] FIX: pgsql: prevent 'WHERE 1' --- build/exe/doliwamp/config.inc.php.install | 2 +- htdocs/core/lib/functions.lib.php | 2 +- htdocs/user/class/user.class.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/build/exe/doliwamp/config.inc.php.install b/build/exe/doliwamp/config.inc.php.install index 19a3d36a45e..6ad04752766 100644 --- a/build/exe/doliwamp/config.inc.php.install +++ b/build/exe/doliwamp/config.inc.php.install @@ -542,7 +542,7 @@ $cfg['ThemePerServer'] = FALSE; // allow diferent theme for each co * %f will be replaced by a list of field names. * (%t and %f only applies to DefaultQueryTable) */ -$cfg['DefaultQueryTable'] = 'SELECT * FROM %t WHERE 1'; +$cfg['DefaultQueryTable'] = 'SELECT * FROM %t WHERE 1 = 1'; $cfg['DefaultQueryDatabase'] = ''; /** diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index fccb019a730..4148d385716 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -8123,7 +8123,7 @@ function getDictvalue($tablename, $field, $id, $checkentity = false, $rowidfield if (!isset($dictvalues[$tablename])) { $dictvalues[$tablename] = array(); - $sql = 'SELECT * FROM '.$tablename.' WHERE 1'; // Here select * is allowed as it is generic code and we don't have list of fields + $sql = 'SELECT * FROM '.$tablename.' WHERE 1 = 1'; // Here select * is allowed as it is generic code and we don't have list of fields if ($checkentity) $sql .= ' AND entity IN (0,'.getEntity($tablename).')'; $resql = $db->query($sql); diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index cc405571990..89995a4584e 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -3320,7 +3320,7 @@ class User extends CommonObject } else { - $sql .= " WHERE 1"; + $sql .= " WHERE 1 = 1"; } // Manage filter From 6f66efacb8f7047c3cea9e3f54fcade9234721e2 Mon Sep 17 00:00:00 2001 From: Ferran Marcet Date: Wed, 5 May 2021 13:47:43 +0200 Subject: [PATCH 134/147] New: Add import on BOM --- htdocs/core/modules/modBom.class.php | 137 +++++++++++++++++++++++++++ 1 file changed, 137 insertions(+) diff --git a/htdocs/core/modules/modBom.class.php b/htdocs/core/modules/modBom.class.php index 6b69c6b7af0..18f46fda70f 100644 --- a/htdocs/core/modules/modBom.class.php +++ b/htdocs/core/modules/modBom.class.php @@ -2,6 +2,7 @@ /* Copyright (C) 2004-2018 Laurent Destailleur * Copyright (C) 2018 Nicolas ZABOURI * Copyright (C) 2019 Maxime Kohlhaas + * Copyright (C) 2021 Ferran Marcet * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -315,6 +316,142 @@ class modBom extends DolibarrModules $this->export_sql_end[$r] .= ' AND t.entity IN ('.getEntity('bom').')'; $r++; /* END MODULEBUILDER EXPORT BILLOFMATERIALS */ + + // Imports + //-------- + $r = 0; + //Import BOM Header + + $r++; + $this->import_code[$r] = 'bom_'.$r; + $this->import_label[$r] = 'BillOfMaterials'; + $this->import_icon[$r] = $this->picto; + $this->import_entities_array[$r] = []; + $this->import_tables_array[$r] = ['b' => MAIN_DB_PREFIX.'bom_bom', 'extra' => MAIN_DB_PREFIX.'bom_bom_extrafields']; + $this->import_tables_creator_array[$r] = ['b' => 'fk_user_creat']; // Fields to store import user id + $this->import_fields_array[$r] = [ + 'b.ref' => 'Document Ref*', + 'b.label' => 'BomLabel*', + 'b.fk_product' => 'ProductRef*', + 'b.description' => 'Description', + 'b.note_public' => 'Note', + 'b.note_private' => 'NotePrivate', + 'b.fk_warehouse' => 'WarehouseRef', + 'b.qty' => 'Qty', + 'b.efficiency' => 'Efficiency', + 'b.duration' => 'Duration', + 'b.date_creation' => 'DateCreation', + 'b.date_valid' => 'DateValid', + 'b.fk_user_modif' => 'ModifiedById', + 'b.fk_user_valid' => 'ValidatedById', + 'b.model_pdf' => 'Model', + 'b.status' => 'Status*', + 'b.bomtype' => 'BomType*' + + ]; + + // Add extra fields + $import_extrafield_sample = []; + $sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'bom_bom' AND entity IN (0, ".$conf->entity.")"; + $resql = $this->db->query($sql); + + if ($resql) { + while ($obj = $this->db->fetch_object($resql)) { + $fieldname = 'extra.'.$obj->name; + $fieldlabel = ucfirst($obj->label); + $this->import_fields_array[$r][$fieldname] = $fieldlabel.($obj->fieldrequired ? '*' : ''); + $import_extrafield_sample[$fieldname] = $fieldlabel; + } + } + // End add extra fields + + $this->import_fieldshidden_array[$r] = ['extra.fk_object' => 'lastrowid-'.MAIN_DB_PREFIX.'bom_bom']; + $this->import_regex_array[$r] = [ + 'b.ref' => '(CPV\d{4}-\d{4}|BOM\d{4}-\d{4}|PROV.{1,32}$)' + ]; + + $this->import_updatekeys_array[$r] = ['b.ref' => 'Ref']; + $this->import_convertvalue_array[$r] = [ + 'b.fk_product' => [ + 'rule' => 'fetchidfromref', + 'file' => '/product/class/product.class.php', + 'class' => 'Product', + 'method' => 'fetch', + 'element' => 'Product' + ], + 'b.fk_warehouse' => [ + 'rule' => 'fetchidfromref', + 'file' => '/product/stock/class/entrepot.class.php', + 'class' => 'Entrepot', + 'method' => 'fetch', + 'element' => 'Warehouse' + ], + 'b.fk_user_valid' => [ + 'rule' => 'fetchidfromref', + 'file' => '/user/class/user.class.php', + 'class' => 'User', + 'method' => 'fetch', + 'element' => 'user' + ], + 'b.fk_user_modif' => [ + 'rule' => 'fetchidfromref', + 'file' => '/user/class/user.class.php', + 'class' => 'User', + 'method' => 'fetch', + 'element' => 'user' + ], + ]; + + //Import BOM Lines + $r++; + $this->import_code[$r] = 'bom_lines_'.$r; + $this->import_label[$r] = 'BillOfMaterialsLine'; + $this->import_icon[$r] = $this->picto; + $this->import_entities_array[$r] = []; + $this->import_tables_array[$r] = ['bd' => MAIN_DB_PREFIX.'bom_bomline', 'extra' => MAIN_DB_PREFIX.'bom_bomline_extrafields']; + $this->import_fields_array[$r] = [ + 'bd.fk_bom' => 'Document Ref*', + 'bd.fk_product' => 'ProductRef', + 'bd.fk_bom_child' => 'BOMChild', + 'bd.description' => 'Description', + 'bd.qty' => 'LineQty', + 'bd.qty_frozen' => 'LineIsFrozen', + 'bd.disable_stock_change' => 'Disable Stock Change', + 'bd.efficiency' => 'Efficiency', + 'bd.position' => 'LinePosition' + ]; + + // Add extra fields + $sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'bom_bomline' AND entity IN (0, ".$conf->entity.")"; + $resql = $this->db->query($sql); + if ($resql) { + while ($obj = $this->db->fetch_object($resql)) { + $fieldname = 'extra.'.$obj->name; + $fieldlabel = ucfirst($obj->label); + $this->import_fields_array[$r][$fieldname] = $fieldlabel.($obj->fieldrequired ? '*' : ''); + } + } + // End add extra fields + + $this->import_fieldshidden_array[$r] = ['extra.fk_object' => 'lastrowid-'.MAIN_DB_PREFIX.'bom_bomline']; + $this->import_regex_array[$r] = []; + $this->import_updatekeys_array[$r] = ['bd.fk_bom' => 'BOM Id']; + $this->import_convertvalue_array[$r] = [ + 'bd.fk_bom' => [ + 'rule' => 'fetchidfromref', + 'file' => '/bom/class/bom.class.php', + 'class' => 'BOM', + 'method' => 'fetch', + 'element' => 'bom' + ], + 'bd.fk_product' => [ + 'rule' => 'fetchidfromref', + 'file' => '/product/class/product.class.php', + 'class' => 'Product', + 'method' => 'fetch', + 'element' => 'Product' + ], + ]; } /** From ed59a8851f3e7b243f89fde128f16db2a543aec2 Mon Sep 17 00:00:00 2001 From: lmarcouiller Date: Wed, 5 May 2021 16:48:04 +0200 Subject: [PATCH 135/147] Fix #17501 : Undownloable attached file --- htdocs/core/actions_linkedfiles.inc.php | 4 ++++ htdocs/langs/en_US/errors.lang | 1 + 2 files changed, 5 insertions(+) diff --git a/htdocs/core/actions_linkedfiles.inc.php b/htdocs/core/actions_linkedfiles.inc.php index af60583118d..482f4cf1dea 100644 --- a/htdocs/core/actions_linkedfiles.inc.php +++ b/htdocs/core/actions_linkedfiles.inc.php @@ -44,6 +44,10 @@ if (GETPOST('sendit', 'alpha') && !empty($conf->global->MAIN_UPLOAD_DOC)) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("File")), null, 'errors'); } } + if (preg_match('/__.*__/', $_FILES['userfile']['name'][$key])) { + $error++; + setEventMessages($langs->trans('ErrorWrongFileName'), null, 'errors'); + } } if (!$error) { diff --git a/htdocs/langs/en_US/errors.lang b/htdocs/langs/en_US/errors.lang index 6df5438de8f..cbf7214245a 100644 --- a/htdocs/langs/en_US/errors.lang +++ b/htdocs/langs/en_US/errors.lang @@ -298,3 +298,4 @@ WarningModuleXDisabledSoYouMayMissEventHere=Module %s has not been enabled. So y ErrorActionCommPropertyUserowneridNotDefined=User's owner is required ErrorActionCommBadType=Selected event type (id: %n, code: %s) do not exist in Event Type dictionary CheckVersionFail=Version check fail +ErrorWrongFileName=Name of the file cannot have __SOMETHING__ in it \ No newline at end of file From 020ad5aebe41a22ba9bf6d4c18967d3c688103b0 Mon Sep 17 00:00:00 2001 From: lmarcouiller Date: Wed, 5 May 2021 16:49:51 +0200 Subject: [PATCH 136/147] Add endofline in errors.lang --- htdocs/langs/en_US/errors.lang | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/langs/en_US/errors.lang b/htdocs/langs/en_US/errors.lang index 55ae87b4613..a1155b0f57c 100644 --- a/htdocs/langs/en_US/errors.lang +++ b/htdocs/langs/en_US/errors.lang @@ -299,4 +299,4 @@ WarningModuleXDisabledSoYouMayMissEventHere=Module %s has not been enabled. So y ErrorActionCommPropertyUserowneridNotDefined=User's owner is required ErrorActionCommBadType=Selected event type (id: %n, code: %s) do not exist in Event Type dictionary CheckVersionFail=Version check fail -ErrorWrongFileName=Name of the file cannot have __SOMETHING__ in it \ No newline at end of file +ErrorWrongFileName=Name of the file cannot have __SOMETHING__ in it From 7857da4db755937deb9d7d6c3691ae0c2a9b525c Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Wed, 5 May 2021 17:05:51 +0200 Subject: [PATCH 137/147] fix missing token --- htdocs/core/class/html.formfile.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index 0ca49a49ff2..3adb6265564 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -1870,7 +1870,7 @@ class FormFile print '
'.dol_print_date($link->datea, "dayhour", "tzuser").''; - print ''.img_edit().''; // id= is included into $param + print ''.img_edit().''; // id= is included into $param if ($permissiontodelete) { print '   '.img_delete().''; // id= is included into $param } else { From adc862050692184a4feb2c5b5157174e9ae155e6 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Wed, 5 May 2021 17:14:58 +0200 Subject: [PATCH 138/147] fix: allow webdavs link type --- htdocs/core/actions_linkedfiles.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/actions_linkedfiles.inc.php b/htdocs/core/actions_linkedfiles.inc.php index b0671bbf555..73b80a47973 100644 --- a/htdocs/core/actions_linkedfiles.inc.php +++ b/htdocs/core/actions_linkedfiles.inc.php @@ -68,7 +68,7 @@ if (GETPOST('sendit', 'alpha') && !empty($conf->global->MAIN_UPLOAD_DOC)) $link = GETPOST('link', 'alpha'); if ($link) { - if (substr($link, 0, 7) != 'http://' && substr($link, 0, 8) != 'https://' && substr($link, 0, 7) != 'file://') { + if (substr($link, 0, 7) != 'http://' && substr($link, 0, 8) != 'https://' && substr($link, 0, 7) != 'file://' && substr($link, 0, 7) != 'davs://') { $link = 'http://'.$link; } dol_add_file_process($upload_dir, 0, 1, 'userfile', null, $link, '', 0); From 9108651a7aace0c48b2de1a0cc1a8f5358dc4008 Mon Sep 17 00:00:00 2001 From: Gauthier PC portable 024 Date: Wed, 5 May 2021 17:25:12 +0200 Subject: [PATCH 139/147] FIX : if dom is added with ajax, selector need to keep working --- htdocs/core/js/lib_foot.js.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/js/lib_foot.js.php b/htdocs/core/js/lib_foot.js.php index d04379210a6..9bf67ee7e58 100644 --- a/htdocs/core/js/lib_foot.js.php +++ b/htdocs/core/js/lib_foot.js.php @@ -87,7 +87,7 @@ if (!defined('JS_JQUERY_DISABLE_DROPDOWN')) var lastopendropdown = null; // Click onto the link "link to" or "hamburger", toggle dropdown - $(".dropdown dt a").on(\'click\', function () { + $(document).on(\'click\', \'.dropdown dt a\', function () { console.log("toggle dropdown dt a"); //$(this).parent().parent().find(\'dd ul\').slideToggle(\'fast\'); From 63292255ccbc7ad08270bb6820f033f2bc7ed0ff Mon Sep 17 00:00:00 2001 From: ATM john Date: Wed, 5 May 2021 18:45:23 +0200 Subject: [PATCH 140/147] Fix search accented words in product description --- htdocs/societe/consumption.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/societe/consumption.php b/htdocs/societe/consumption.php index cd82533fc88..420282c4cef 100644 --- a/htdocs/societe/consumption.php +++ b/htdocs/societe/consumption.php @@ -309,7 +309,7 @@ if (!empty($sql_select)) if ($sref) $sql.= " AND ".$doc_number." LIKE '%".$db->escape($sref)."%'"; if ($sprod_fulldescr) { - $sql.= " AND (d.description LIKE '%".$db->escape($sprod_fulldescr)."%'"; + $sql.= " AND (d.description LIKE '%".$db->escape($sprod_fulldescr)."%' OR d.description LIKE '%".$db->escape(dol_htmlentities($sprod_fulldescr))."%'"; if (GETPOST('type_element') != 'fichinter') $sql.= " OR p.ref LIKE '%".$db->escape($sprod_fulldescr)."%'"; if (GETPOST('type_element') != 'fichinter') $sql.= " OR p.label LIKE '%".$db->escape($sprod_fulldescr)."%'"; $sql.=")"; From 6b89b99dfddb82bf6cceba40399d7fa721b4953d Mon Sep 17 00:00:00 2001 From: UT from dolibit <45215329+dolibit-ut@users.noreply.github.com> Date: Wed, 5 May 2021 23:07:52 +0200 Subject: [PATCH 141/147] Update llx_00_c_country.sql --- htdocs/install/mysql/data/llx_00_c_country.sql | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/htdocs/install/mysql/data/llx_00_c_country.sql b/htdocs/install/mysql/data/llx_00_c_country.sql index 88df2349391..fa2b4339983 100644 --- a/htdocs/install/mysql/data/llx_00_c_country.sql +++ b/htdocs/install/mysql/data/llx_00_c_country.sql @@ -6,6 +6,7 @@ -- Copyright (C) 2005-2009 Regis Houssin -- Copyright (C) 2007 Patrick Raguin -- Copyright (C) 2014 Alexandre Spangaro +-- Copyright (C) 2021 Udo Tamm -- -- This program is free software; you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by @@ -50,7 +51,7 @@ INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (19 INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (20,'SE','SWE','Sweden',1,0); INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (21,'CI','CIV','Côte d''Ivoire',1,0); INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (22,'SN','SEN','Senegal',1,0); -INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (23,'AR','ARG','Argentine',1,0); +INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (23,'AR','ARG','Argentina',1,0); INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (24,'CM','CMR','Cameroun',1,0); INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (25,'PT','PRT','Portugal',1,0); INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (26,'SA','SAU','Saudi Arabia',1,0); @@ -59,21 +60,21 @@ INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (28 INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (29,'SG','SGP','Singapour',1,0); INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (30,'AF','AFG','Afghanistan',1,0); INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (31,'AX','ALA','Iles Aland',1,0); -INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (32,'AL','ALB','Albanie',1,0); +INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (32,'AL','ALB','Albania',1,0); INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (33,'AS','ASM','Samoa américaines',1,0); -INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (34,'AD','AND','Andorre',1,0); +INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (34,'AD','AND','Andorra',1,0); INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (35,'AO','AGO','Angola',1,0); INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (36,'AI','AIA','Anguilla',1,0); INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (37,'AQ','ATA','Antarctique',1,0); INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (38,'AG','ATG','Antigua-et-Barbuda',1,0); -INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (39,'AM','ARM','Arménie',1,0); -INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (41,'AT','AUT','Autriche',1,0); +INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (39,'AM','ARM','Armenia',1,0); +INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (41,'AT','AUT','Austria',1,0); INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (42,'AZ','AZE','Azerbaïdjan',1,0); INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (43,'BS','BHS','Bahamas',1,0); INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (44,'BH','BHR','Bahreïn',1,0); INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (45,'BD','BGD','Bangladesh',1,0); INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (46,'BB','BRB','Barbade',1,0); -INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (47,'BY','BLR','Biélorussie',1,0); +INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (47,'BY','BLR','Belarus',1,0); INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (48,'BZ','BLZ','Belize',1,0); INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (49,'BJ','BEN','Bénin',1,0); INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (50,'BM','BMU','Bermudes',1,0); From d55309c84793bfee371e4688f866e852415cbd8b Mon Sep 17 00:00:00 2001 From: lmarcouiller Date: Thu, 6 May 2021 09:46:54 +0200 Subject: [PATCH 142/147] fix rename file --- htdocs/core/actions_linkedfiles.inc.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/htdocs/core/actions_linkedfiles.inc.php b/htdocs/core/actions_linkedfiles.inc.php index 482f4cf1dea..2a610cb3bf6 100644 --- a/htdocs/core/actions_linkedfiles.inc.php +++ b/htdocs/core/actions_linkedfiles.inc.php @@ -176,8 +176,11 @@ if ($action == 'confirm_deletefile' && $confirm == 'yes') { // We apply dol_string_nohtmltag also to clean file names (this remove duplicate spaces) because // this function is also applied when we upload and when we make try to download file (by the GETPOST(filename, 'alphanohtml') call). $filenameto = dol_string_nohtmltag($filenameto); - - if ($filenamefrom != $filenameto) { + if (preg_match('/__.*__/', $filenameto)) { + $error++; + setEventMessages($langs->trans('ErrorWrongFileName'), null, 'errors'); + } + if (!$error && $filenamefrom != $filenameto) { // Security: // Disallow file with some extensions. We rename them. // Because if we put the documents directory into a directory inside web root (very bad), this allows to execute on demand arbitrary code. From 9cd78e6ecf0dcdcb2cc387e8aac0ffa5c01ffae5 Mon Sep 17 00:00:00 2001 From: UT from dolibit <45215329+dolibit-ut@users.noreply.github.com> Date: Thu, 6 May 2021 16:00:49 +0200 Subject: [PATCH 143/147] Update modules_member.class.php --- htdocs/core/modules/member/modules_member.class.php | 4 ---- 1 file changed, 4 deletions(-) diff --git a/htdocs/core/modules/member/modules_member.class.php b/htdocs/core/modules/member/modules_member.class.php index 1ff1ffc3d30..3a1b4edcc1d 100644 --- a/htdocs/core/modules/member/modules_member.class.php +++ b/htdocs/core/modules/member/modules_member.class.php @@ -20,10 +20,6 @@ */ -/** - * \class ModeleProductCode - * \brief Parent class for product code generators - */ /** * \file htdocs/core/modules/member/modules_member.class.php From 7386a223e80572284bf833b170d85974c9592564 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 6 May 2021 16:38:34 +0200 Subject: [PATCH 144/147] Update account.class.php --- htdocs/compta/bank/class/account.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php index c59e768f6dc..75738abc3d4 100644 --- a/htdocs/compta/bank/class/account.class.php +++ b/htdocs/compta/bank/class/account.class.php @@ -1687,7 +1687,7 @@ class Account extends CommonObject */ public static function replaceThirdparty($db, $origin_id, $dest_id) { - $sql = 'UPDATE '.MAIN_DB_PREFIX.'bank_url SET url_id = '.$dest_id.' WHERE url_id = '.$origin_id.' AND type=\'company\''; + $sql = "UPDATE ".MAIN_DB_PREFIX."bank_url SET url_id = ".((int) $dest_id)." WHERE url_id = ".((int) $origin_id)." AND type='company'"; if (!$db->query($sql)) { From 98a4f603f2af21052b331937c28c1d20ef21d0b3 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 6 May 2021 16:41:06 +0200 Subject: [PATCH 145/147] Complete merge of thirdparty into API --- htdocs/societe/class/api_thirdparties.class.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/societe/class/api_thirdparties.class.php b/htdocs/societe/class/api_thirdparties.class.php index af9122cba9d..39773b7b637 100644 --- a/htdocs/societe/class/api_thirdparties.class.php +++ b/htdocs/societe/class/api_thirdparties.class.php @@ -445,7 +445,8 @@ class Thirdparties extends DolibarrApi 'Product' => '/product/class/product.class.php', 'Project' => '/projet/class/project.class.php', 'Ticket' => '/ticket/class/ticket.class.php', - 'User' => '/user/class/user.class.php' + 'User' => '/user/class/user.class.php', + 'Account' => '/compta/bank/class/account.class.php' ); //First, all core objects must update their tables From 0daab6a55ae87d7bfa5abb2036877aac31e71c2b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 6 May 2021 16:50:22 +0200 Subject: [PATCH 146/147] Code comment --- htdocs/install/mysql/migration/13.0.0-14.0.0.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/install/mysql/migration/13.0.0-14.0.0.sql b/htdocs/install/mysql/migration/13.0.0-14.0.0.sql index 642ce0cb98d..8eacab54fa8 100644 --- a/htdocs/install/mysql/migration/13.0.0-14.0.0.sql +++ b/htdocs/install/mysql/migration/13.0.0-14.0.0.sql @@ -59,11 +59,11 @@ insert into llx_c_actioncomm (id, code, type, libelle, module, active, position) UPDATE llx_c_country SET eec = 1 WHERE code IN ('AT','BE','BG','CY','CZ','DE','DK','EE','ES','FI','FR','GR','HR','NL','HU','IE','IM','IT','LT','LU','LV','MC','MT','PL','PT','RO','SE','SK','SI'); +ALTER TABLE llx_export_model MODIFY COLUMN type varchar(64); + -- For v14 -ALTER TABLE llx_export_model MODIFY COLUMN type varchar(64); - create table llx_accounting_groups_account ( rowid integer AUTO_INCREMENT PRIMARY KEY, From d5c737ddb6b069fd655caa3f3332df0d0c8cecfa Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 6 May 2021 17:19:28 +0200 Subject: [PATCH 147/147] Update modTakePos.class.php --- htdocs/core/modules/modTakePos.class.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/core/modules/modTakePos.class.php b/htdocs/core/modules/modTakePos.class.php index 84810e80a53..5cb7a7f0c38 100644 --- a/htdocs/core/modules/modTakePos.class.php +++ b/htdocs/core/modules/modTakePos.class.php @@ -198,21 +198,21 @@ class modTakePos extends DolibarrModules $r++; $this->rights[$r][0] = 50151; - $this->rights[$r][1] = 'Use Point Of Sale'; + $this->rights[$r][1] = 'Use Point Of Sale (record a sale, add products, record payment)'; $this->rights[$r][2] = 'a'; $this->rights[$r][3] = 0; $this->rights[$r][4] = 'run'; $r++; $this->rights[$r][0] = 50152; - $this->rights[$r][1] = 'Edit sales lines'; + $this->rights[$r][1] = 'Can modify added sales lines (prices, discount)'; $this->rights[$r][2] = 'a'; $this->rights[$r][3] = 0; $this->rights[$r][4] = 'editlines'; $r++; $this->rights[$r][0] = 50153; - $this->rights[$r][1] = 'Edit ordered sales lines'; + $this->rights[$r][1] = 'Edit ordered sales lines (useful only when option "Order printers" has been enabled). Allow to edit sales lines even after the order has been printed'; $this->rights[$r][2] = 'a'; $this->rights[$r][3] = 0; $this->rights[$r][4] = 'editorderedlines';