From 26a40e30e3a452a8f11590bea4417754841f3655 Mon Sep 17 00:00:00 2001 From: jpb Date: Wed, 23 Dec 2020 14:46:07 +0100 Subject: [PATCH 001/879] multicurrency update online and change some behaviors --- htdocs/multicurrency/multicurrency_rate.php | 185 +++++++++----------- 1 file changed, 82 insertions(+), 103 deletions(-) diff --git a/htdocs/multicurrency/multicurrency_rate.php b/htdocs/multicurrency/multicurrency_rate.php index eae788b0587..376269c0806 100644 --- a/htdocs/multicurrency/multicurrency_rate.php +++ b/htdocs/multicurrency/multicurrency_rate.php @@ -46,7 +46,8 @@ $confirm = GETPOST('confirm', 'alpha'); $toselect = GETPOST('toselect', 'array'); $id_rate_selected = GETPOST('id_rate', 'int'); $sall = trim((GETPOST('search_all', 'alphanohtml') != '') ?GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml')); -$search_date_sync = GETPOST('search_date_sync', 'alpha'); +$search_date_sync = dol_mktime(0, 0, 0, GETPOST('search_date_syncmonth', 'int'), GETPOST('search_date_syncday', 'int'), GETPOST('search_date_syncyear', 'int')); +$search_date_sync_end = dol_mktime(0, 0, 0, GETPOST('search_date_sync_endmonth', 'int'), GETPOST('search_date_sync_endday', 'int'), GETPOST('search_date_sync_endyear', 'int')); $search_rate = GETPOST('search_rate', 'alpha'); $search_code = GETPOST('search_code', 'alpha'); $multicurrency_code = GETPOST('multicurrency_code', 'alpha'); @@ -58,12 +59,13 @@ $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); $page = (GETPOST("page", 'int') ?GETPOST("page", 'int') : 0); + if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; if (!$sortfield) $sortfield = "cr.date_sync"; -if (!$sortorder) $sortorder = "DESC"; +if (!$sortorder) $sortorder = "ASC"; // Initialize technical object to manage hooks. Note that conf->hooks_modules contains array of hooks @@ -200,6 +202,7 @@ if (empty($reshook)) { $sall = ""; $search_date_sync = ""; + $search_date_sync_end=""; $search_rate = ""; $search_code = ""; $search_array_options = array(); @@ -233,7 +236,7 @@ print dol_get_fiche_head($head, 'ratelist', $langs->trans("ModuleSetup"), -1, "m // ACTION -if ($action != "updateRate") { +if (!in_array( $action, array("updateRate", "deleteRate"))) { print ''; print ''; print ''."\n"; @@ -243,15 +246,15 @@ if ($action != "updateRate") { print ''; print ''; - print '
'.$langs->trans("FormCreateRate").'
'; + print '
'; print ' '; print ' '; print ''; - print ''; + print ''; print ' '; print ' '; @@ -267,54 +270,7 @@ if ($action != "updateRate") { print '
'; } -if ($action == "updateRate") { - $current_rate = new CurrencyRate($db); - $current_rate->fetch(intval($id_rate_selected)); - if ($current_rate) { - $curr = new MultiCurrency($db); - $resultcurrentCurrency = $curr->fetch($current_rate->fk_multicurrency); - - if ($resultcurrentCurrency) { - $currency_code = $curr->code; - } else { - $currency_code = ''; - } - - print '
'.$langs->trans('Date').''; - print $form->selectDate($dateinput, 'dateinput'); + print $form->selectDate($dateinput, 'dateinput', 0, 0, 1); print ' '.$langs->trans('Currency').''.$form->selectMultiCurrency((GETPOSTISSET('multicurrency_code') ? GETPOST('multicurrency_code', 'alpha') : $multicurrency_code), 'multicurrency_code', 0, " code != '".$conf->currency."'", true).''.$form->selectMultiCurrency((GETPOSTISSET('multicurrency_code') ? GETPOST('multicurrency_code', 'alpha') : $multicurrency_code), 'multicurrency_code', 1, " code != '".$conf->currency."'", true).''.$langs->trans('Rate').'
'; - print ''; - print ''."\n"; - print '
'.$langs->trans("FormUpdateRate").'
'; - - $form = new Form($db); - print ''; - print ''; - - print ''; - print ' '; - print ''; - - print ''; - print ''; - - print ''; - print ''; - - print ''; - print '
'.$langs->trans('Date').''; - print $form->selectDate($current_rate->date_sync, 'dateinput'); - print ' '.$langs->trans('Currency').''.$form->selectMultiCurrency($currency_code, 'multicurrency_code', 0, " code != '".$conf->currency."'", true).''.$langs->trans('Rate').''; - print ''; - print ''; - print ''; - print ''.$langs->trans('CancelUpdate').''; - - print '
'; - print ''; - } else { - dol_syslog("currency_rate:list:update", LOG_WARNING); - } -} $sql = 'SELECT cr.rowid, cr.date_sync, cr.rate, cr.entity, m.code, m.name '; @@ -325,7 +281,11 @@ $sql .= $hookmanager->resPrint; $sql .= ' FROM '.MAIN_DB_PREFIX.'multicurrency_rate as cr '; $sql .= " INNER JOIN ".MAIN_DB_PREFIX."multicurrency AS m ON cr.fk_multicurrency = m.rowid"; if ($sall) $sql .= natural_search(array_keys($fieldstosearchall), $sall); -if ($search_date_sync) $sql .= natural_search('cr.date_sync', $search_date_sync); +if ($search_date_sync && $search_date_sync_end ){ + $sql .= " AND (cr.date_sync BETWEEN '".$db->idate($search_date_sync)."' AND '".$db->idate($search_date_sync_end)."')"; +} elseif ($search_date_sync && !$search_date_sync_end) { + $sql .= natural_search('cr.date_sync', $db->idate($search_date_sync)); +} if ($search_rate) $sql .= natural_search('cr.rate', $search_rate); if ($search_code) $sql .= natural_search('m.code', $search_code); $sql .= " WHERE m.code <> '".$db->escape($conf->currency)."'"; @@ -374,9 +334,10 @@ if ($resql) if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); if ($sall) $param .= "&sall=".urlencode($sall); - if ($search_date_sync) $param = "&search_date_sync=".urlencode($search_date_sync); + if ($search_date_sync) $param = "&search_date_sync=".$search_date_sync; + if ($search_date_sync_end) $param="&search_date_sync_end=".$search_date_sync_end; if ($search_rate) $param = "&search_rate=".urlencode($search_rate); - if ($search_code != '') $param .= "&search_code=".urlencode($search_code); + if ($search_code != '') $param.="&search_code=".urlencode($search_code); // Add $param from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; @@ -426,7 +387,7 @@ if ($resql) if ($massactionbutton) $selectedfields .= $form->showCheckAddButtons('checkforselect', 1); print '
'; - print ''."\n"; + print '
'."\n"; // Lines with input filters print ''; @@ -435,14 +396,15 @@ if ($resql) if (!empty($arrayfields['cr.date_sync']['checked'])) { print ''; } // code if (!empty($arrayfields['m.code']['checked'])) { print ''; } // rate @@ -486,52 +448,69 @@ if ($resql) print ''; - // date_sync - if (!empty($arrayfields['cr.date_sync']['checked'])) - { - print '\n"; - if (!$i) $totalarray['nbfield']++; + // USER REQUEST UPDATE FOR THIS LINE + if ($action == "updateRate" && $obj->rowid == $id_rate_selected) { + // var_dump($obj); + print ' '; + print ''; + print ' '; + + print ''; + } + else { + // date_sync + if (!empty($arrayfields['cr.date_sync']['checked'])) + { + print '\n"; + if (!$i) $totalarray['nbfield']++; + } + + // code + if (! empty($arrayfields['m.code']['checked'])) + { + print '\n"; + + if (! $i) $totalarray['nbfield']++; + } + + // rate + if (! empty($arrayfields['cr.rate']['checked'])) + { + print '\n"; + if (! $i) $totalarray['nbfield']++; + } + + + // Fields from hook + $parameters = ['arrayfields' => $arrayfields, 'obj' => $obj]; + $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + + // Action + print ''; + if (!$i) $totalarray['nbfield']++; } - // code - if (!empty($arrayfields['m.code']['checked'])) - { - print '\n"; - - if (!$i) $totalarray['nbfield']++; - } - - // rate - if (!empty($arrayfields['cr.rate']['checked'])) - { - print '\n"; - if (!$i) $totalarray['nbfield']++; - } - - // Fields from hook - $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj); - $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - - // Action - print ''; - if (!$i) $totalarray['nbfield']++; - print "\n"; $i++; } From a37bb4c6f23c506b176d2c977a8e5a947294b582 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Wed, 23 Dec 2020 13:51:13 +0000 Subject: [PATCH 002/879] Fixing style errors. --- htdocs/multicurrency/multicurrency_rate.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/multicurrency/multicurrency_rate.php b/htdocs/multicurrency/multicurrency_rate.php index 376269c0806..b8aaf0064c8 100644 --- a/htdocs/multicurrency/multicurrency_rate.php +++ b/htdocs/multicurrency/multicurrency_rate.php @@ -236,7 +236,7 @@ print dol_get_fiche_head($head, 'ratelist', $langs->trans("ModuleSetup"), -1, "m // ACTION -if (!in_array( $action, array("updateRate", "deleteRate"))) { +if (!in_array($action, array("updateRate", "deleteRate"))) { print '
'; - print ''; + print $form->selectDate($search_date_sync, 'search_date_sync', 0, 0, 1); + print $form->selectDate($search_date_sync_end, 'search_date_sync_end', 0, 0, 1); print ''; - print ''; + print $form->selectMultiCurrency($multicurrency_code, 'search_code', 1, " code != '".$conf->currency."'", true); print '
'; - print $obj->date_sync; - print "' . $form->selectMultiCurrency($obj->code, 'multicurrency_code', 1, " code != '".$conf->currency."'", true) . ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print $obj->date_sync; + print "'; + print $obj->code." ".$obj->name; + print "'; + print $obj->rate; + print "'; + if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined + { + $selected = 0; + if (in_array($obj->rowid, $arrayofselected)) $selected = 1; + print 'rowid.'">'.img_picto('edit', 'edit').''; + print 'rowid.'">'.img_picto('delete', 'delete').''; + print ''; + } + print ''; - print $obj->code." ".$obj->name; - print "'; - print $obj->rate; - print "'; - if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined - { - $selected = 0; - if (in_array($obj->rowid, $arrayofselected)) $selected = 1; - print 'rowid.'">'.img_picto('edit', 'edit').''; - print 'rowid.'">'.img_picto('delete', 'delete').''; - print ''; - } - print '
'; print ''; print ''."\n"; From 367a038a1555b464ca5527be645f5947e9d59b20 Mon Sep 17 00:00:00 2001 From: jpb Date: Thu, 24 Dec 2020 09:55:09 +0100 Subject: [PATCH 003/879] hotfix : idate on create currency --- htdocs/multicurrency/multicurrency_rate.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/multicurrency/multicurrency_rate.php b/htdocs/multicurrency/multicurrency_rate.php index 376269c0806..a7bf7f2c7f7 100644 --- a/htdocs/multicurrency/multicurrency_rate.php +++ b/htdocs/multicurrency/multicurrency_rate.php @@ -109,7 +109,7 @@ if ($action == "create") { $currencyRate_static->fk_multicurrency = $fk_currency; $currencyRate_static->entity = $conf->entity; - $currencyRate_static->date_sync = $dateinput; + $currencyRate_static->date_sync = $db->idate($dateinput); $currencyRate_static->rate = $rateinput; $result = $currencyRate_static->create(intval($fk_currency)); From 20720ae0dd50ad9036f1b1f6103130fe1de77f4f Mon Sep 17 00:00:00 2001 From: jpb Date: Mon, 11 Jan 2021 14:06:21 +0100 Subject: [PATCH 004/879] remove idate --- htdocs/multicurrency/multicurrency_rate.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/multicurrency/multicurrency_rate.php b/htdocs/multicurrency/multicurrency_rate.php index 69d471c62dd..b8aaf0064c8 100644 --- a/htdocs/multicurrency/multicurrency_rate.php +++ b/htdocs/multicurrency/multicurrency_rate.php @@ -109,7 +109,7 @@ if ($action == "create") { $currencyRate_static->fk_multicurrency = $fk_currency; $currencyRate_static->entity = $conf->entity; - $currencyRate_static->date_sync = $db->idate($dateinput); + $currencyRate_static->date_sync = $dateinput; $currencyRate_static->rate = $rateinput; $result = $currencyRate_static->create(intval($fk_currency)); From 6b451bd870a55c33a40b5b55b5116d35d55018aa Mon Sep 17 00:00:00 2001 From: jpb Date: Mon, 1 Feb 2021 09:31:30 +0100 Subject: [PATCH 005/879] use form->selectdate --- htdocs/multicurrency/multicurrency_rate.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/multicurrency/multicurrency_rate.php b/htdocs/multicurrency/multicurrency_rate.php index b8aaf0064c8..21d64734f8b 100644 --- a/htdocs/multicurrency/multicurrency_rate.php +++ b/htdocs/multicurrency/multicurrency_rate.php @@ -396,8 +396,8 @@ if ($resql) if (!empty($arrayfields['cr.date_sync']['checked'])) { print ''; } // code @@ -503,7 +503,7 @@ if ($resql) { $selected = 0; if (in_array($obj->rowid, $arrayofselected)) $selected = 1; - print 'rowid.'">'.img_picto('edit', 'edit').''; + print 'rowid.'&page='.$page.'&sortorder='.$sortorder.'&sortfield='.$sortfield.'&search_code='.$search_code.'&search_rate='.$search_rate.'&search_date_sync='.dol_print_date($search_date_sync, "%Y-%m-%d") .'&search_date_sync_end='.dol_print_date($search_date_sync_end, "%Y-%m-%d") .'&edit_mode='. '1'. '">'.img_picto('edit', 'edit').''; print 'rowid.'">'.img_picto('delete', 'delete').''; print ''; } From 7966c6ed6d7d9291e2f6c01fbaa03ddb74a83ab8 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Mon, 1 Feb 2021 08:34:12 +0000 Subject: [PATCH 006/879] Fixing style errors. --- htdocs/multicurrency/multicurrency_rate.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/multicurrency/multicurrency_rate.php b/htdocs/multicurrency/multicurrency_rate.php index 21d64734f8b..09749ae612e 100644 --- a/htdocs/multicurrency/multicurrency_rate.php +++ b/htdocs/multicurrency/multicurrency_rate.php @@ -396,7 +396,7 @@ if ($resql) if (!empty($arrayfields['cr.date_sync']['checked'])) { print ''; } From 6c8293612d807d6eae8b9fd8daa45f7d962d96c1 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Fri, 26 Mar 2021 16:41:48 +0100 Subject: [PATCH 007/879] 13.0 --- .gitignore | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.gitignore b/.gitignore index 371c8be2f5e..18ae79180a0 100644 --- a/.gitignore +++ b/.gitignore @@ -43,6 +43,10 @@ htdocs/includes/squizlabs/ htdocs/includes/webmozart/ htdocs/.well-known/apple-developer-merchantid-domain-association + +cyberoffice/ +mycyberoffice/ + # Node Modules build/yarn-error.log build/node_modules/ From eef5b9514d3f1ca219ef807e23aa633bd6547225 Mon Sep 17 00:00:00 2001 From: Dorian Vabre Date: Fri, 9 Apr 2021 16:55:54 +0200 Subject: [PATCH 008/879] 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 009/879] 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 010/879] 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 011/879] 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 012/879] 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 013/879] 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 014/879] 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 015/879] 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 6814488d86cf2435aaa335a5143f697771289f7d Mon Sep 17 00:00:00 2001 From: Anthony Berton <34568357+bb2a@users.noreply.github.com> Date: Wed, 14 Apr 2021 00:51:19 +0200 Subject: [PATCH 016/879] Update list.php --- htdocs/commande/list.php | 33 +++++++++++++++++++++++---------- 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php index db6bba130b1..d345bd033be 100644 --- a/htdocs/commande/list.php +++ b/htdocs/commande/list.php @@ -274,7 +274,15 @@ if (empty($reshook)) { $objectclass = 'Commande'; $objectlabel = 'Orders'; $permissiontoread = $user->rights->commande->lire; + $permissiontoadd = $user->rights->commande->creer; $permissiontodelete = $user->rights->commande->supprimer; + if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS)){ + $permissiontovalidate = $user->rights->commande->order_advance->validate; + $permissiontoclose = $user->rights->commande->order_advance->close; + }else{ + $permissiontovalidate = $user->rights->commande->creer; + $permissiontoclose = $user->rights->commande->creer; + } $uploaddir = $conf->commande->multidir_output[$conf->entity]; $triggersendname = 'ORDER_SENTBYMAIL'; include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; @@ -700,16 +708,21 @@ if ($resql) { // List of mass actions available $arrayofmassactions = array( - 'generate_doc'=>$langs->trans("ReGeneratePDF"), - 'builddoc'=>$langs->trans("PDFMerge"), - 'cancelorders'=>$langs->trans("Cancel"), - 'presend'=>$langs->trans("SendByMail"), + 'generate_doc'=>img_picto('', 'pdf').' '.$langs->trans("ReGeneratePDF"), + 'builddoc'=>img_picto('', 'pdf').' '.$langs->trans("PDFMerge"), + 'cancelorders'=>img_picto('', 'close_title').' '.$langs->trans("Cancel"), + 'presend'=>img_picto('', 'email').' '.$langs->trans("SendByMail"), ); if ($user->rights->facture->creer) { - $arrayofmassactions['createbills'] = $langs->trans("CreateInvoiceForThisCustomer"); + $arrayofmassactions['createbills'] = img_picto('', 'bill').' '.$langs->trans("CreateInvoiceForThisCustomer"); } - if ($user->rights->commande->supprimer) { - $arrayofmassactions['predelete'] = ''.$langs->trans("Delete"); + if ($conf->global->MAIN_FEATURES_LEVEL == '2'){ //BB2A + if ($permissiontoclose) { + $arrayofmassactions['setbilled'] = img_picto('', 'bill').' '.$langs->trans("ClassifyBilled"); + } + } + if ($permissiontodelete) { + $arrayofmassactions['predelete'] = img_picto('', 'delete').' '.$langs->trans("Delete"); } if (in_array($massaction, array('presend', 'predelete', 'createbills'))) { $arrayofmassactions = array(); @@ -720,7 +733,7 @@ if ($resql) { if (!empty($socid)) { $url .= '&socid='.$socid; } - $newcardbutton = dolGetButtonTitle($langs->trans('NewOrder'), '', 'fa fa-plus-circle', $url, '', $contextpage == 'orderlist' && $user->rights->commande->creer); + $newcardbutton = dolGetButtonTitle($langs->trans('NewOrder'), '', 'fa fa-plus-circle', $url, '', $contextpage == 'orderlist' && $permissiontoadd); // Lines of title fields print '
'; @@ -1740,8 +1753,8 @@ if ($resql) { $urlsource .= str_replace('&', '&', $param); $filedir = $diroutputmassaction; - $genallowed = $user->rights->commande->lire; - $delallowed = $user->rights->commande->creer; + $genallowed = $permissiontoread; + $delallowed = $permissiontoadd; print $formfile->showdocuments('massfilesarea_orders', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty); } else { From 25ac8bed68b3b512d68c54e5686b223ec0dde8e7 Mon Sep 17 00:00:00 2001 From: Anthony Berton <34568357+bb2a@users.noreply.github.com> Date: Wed, 14 Apr 2021 01:54:30 +0200 Subject: [PATCH 017/879] Update list.php --- htdocs/commande/list.php | 86 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 84 insertions(+), 2 deletions(-) diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php index d345bd033be..4c1a06a9a5d 100644 --- a/htdocs/commande/list.php +++ b/htdocs/commande/list.php @@ -11,6 +11,7 @@ * Copyright (C) 2015 Jean-François Ferry * Copyright (C) 2016 Ferran Marcet * Copyright (C) 2018 Charlene Benke + * Copyright (C) 2021 Anthony Berton * * 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 @@ -279,15 +280,83 @@ if (empty($reshook)) { if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS)){ $permissiontovalidate = $user->rights->commande->order_advance->validate; $permissiontoclose = $user->rights->commande->order_advance->close; + $permissiontocancel = $user->rights->commande->order_advance->annuler; + $permissiontosendbymail = $user->rights->commande->order_advance->send; }else{ $permissiontovalidate = $user->rights->commande->creer; $permissiontoclose = $user->rights->commande->creer; + $permissiontocancel = $user->rights->commande->creer; + $permissiontosendbymail = $user->rights->commande->creer; } $uploaddir = $conf->commande->multidir_output[$conf->entity]; $triggersendname = 'ORDER_SENTBYMAIL'; include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; } +if ($action == 'validate' && $permissiontoadd) { + if (GETPOST('confirm') == 'yes') { + $objecttmp = new $objectclass($db); + $db->begin(); + $error = 0; + foreach ($toselect as $checked) { + if ($objecttmp->fetch($checked)) { + if ($objecttmp->statut == 0) { + if ($objecttmp->valid($user)) { + setEventMessage($objecttmp->ref." ".$langs->trans('PassedInOpenStatus'), 'mesgs'); + } else { + setEventMessage($langs->trans('CantBeValidated'), 'errors'); + $error++; + } + } else { + setEventMessage($objecttmp->ref." ".$langs->trans('IsNotADraft'), 'errors'); + $error++; + } + }else{ + dol_print_error($db); + $error++; + } + } + if ($error) { + $db->rollback(); + } else { + $db->commit(); + } + } +} +// Closed records +if (!$error && $massaction === 'setbilled' && $permissiontoclose) { + $db->begin(); + $objecttmp = new $objectclass($db); + $nbok = 0; + foreach ($toselect as $toselectid) { + $result = $objecttmp->fetch($toselectid); + if ($result > 0) { + $result = $objecttmp->classifyBilled($user, 0); + if ($result <= 0) { + setEventMessages($objecttmp->error, $objecttmp->errors, 'errors'); + $error++; + break; + } else { + $nbok++; + } + } else { + setEventMessages($objecttmp->error, $objecttmp->errors, 'errors'); + $error++; + break; + } + } + + if (!$error) { + if ($nbok > 1) { + setEventMessages($langs->trans("RecordsModified", $nbok), null, 'mesgs'); + } else { + setEventMessages($langs->trans("RecordsModified", $nbok), null, 'mesgs'); + } + $db->commit(); + } else { + $db->rollback(); + } +} /* * View @@ -710,9 +779,18 @@ if ($resql) { $arrayofmassactions = array( 'generate_doc'=>img_picto('', 'pdf').' '.$langs->trans("ReGeneratePDF"), 'builddoc'=>img_picto('', 'pdf').' '.$langs->trans("PDFMerge"), - 'cancelorders'=>img_picto('', 'close_title').' '.$langs->trans("Cancel"), - 'presend'=>img_picto('', 'email').' '.$langs->trans("SendByMail"), ); + if ($conf->global->MAIN_FEATURES_LEVEL == '2'){ //BB2A + if ($permissiontovalidate) { + $arrayofmassactions['prevalidate'] = img_picto('', 'check').' '.$langs->trans("Validate"); + } + } + if ($permissiontosendbymail) { + $arrayofmassactions['presend'] = img_picto('', 'email').' '.$langs->trans("SendByMail"); + } + if ($permissiontocancel) { + $arrayofmassactions['cancelorders'] = img_picto('', 'close_title').' '.$langs->trans("Cancel"); + } if ($user->rights->facture->creer) { $arrayofmassactions['createbills'] = img_picto('', 'bill').' '.$langs->trans("CreateInvoiceForThisCustomer"); } @@ -757,6 +835,10 @@ if ($resql) { $trackid = 'ord'.$object->id; include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; + if ($massaction == 'prevalidate') { + print $form->formconfirm($_SERVER["PHP_SELF"], $langs->trans("ConfirmMassValidation"), $langs->trans("ConfirmMassValidationQuestion"), "validate", null, '', 0, 200, 500, 1); + } + if ($massaction == 'createbills') { //var_dump($_REQUEST); print ''; From 92ca59d20b2d51bfc2e0f6510dbb03799f28008c Mon Sep 17 00:00:00 2001 From: Anthony Berton <34568357+bb2a@users.noreply.github.com> Date: Wed, 14 Apr 2021 02:23:23 +0200 Subject: [PATCH 018/879] Update list.php --- htdocs/commande/list.php | 55 +++++++++++++++++++++++++++++++++------- 1 file changed, 46 insertions(+), 9 deletions(-) diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php index 4c1a06a9a5d..78adb797b88 100644 --- a/htdocs/commande/list.php +++ b/htdocs/commande/list.php @@ -300,7 +300,42 @@ if ($action == 'validate' && $permissiontoadd) { foreach ($toselect as $checked) { if ($objecttmp->fetch($checked)) { if ($objecttmp->statut == 0) { - if ($objecttmp->valid($user)) { + if (!empty($objecttmp->fk_warehouse)){ + $idwarehouse = $objecttmp->fk_warehouse; + }else{ + $idwarehouse = 0; + } + if ($objecttmp->valid($user, $idwarehouse)) { + setEventMessage($objecttmp->ref." ".$langs->trans('PassedInOpenStatus'), 'mesgs'); + } else { + setEventMessage($langs->trans('CantBeValidated'), 'errors'); + $error++; + } + } else { + setEventMessage($objecttmp->ref." ".$langs->trans('IsNotADraft'), 'errors'); + $error++; + } + }else{ + dol_print_error($db); + $error++; + } + } + if ($error) { + $db->rollback(); + } else { + $db->commit(); + } + } +} +if ($action == 'shipped' && $permissiontoadd) { + if (GETPOST('confirm') == 'yes') { + $objecttmp = new $objectclass($db); + $db->begin(); + $error = 0; + foreach ($toselect as $checked) { + if ($objecttmp->fetch($checked)) { + if ($objecttmp->statut == 1) { + if ($objecttmp->cloture($user)) { setEventMessage($objecttmp->ref." ".$langs->trans('PassedInOpenStatus'), 'mesgs'); } else { setEventMessage($langs->trans('CantBeValidated'), 'errors'); @@ -780,24 +815,23 @@ if ($resql) { 'generate_doc'=>img_picto('', 'pdf').' '.$langs->trans("ReGeneratePDF"), 'builddoc'=>img_picto('', 'pdf').' '.$langs->trans("PDFMerge"), ); - if ($conf->global->MAIN_FEATURES_LEVEL == '2'){ //BB2A - if ($permissiontovalidate) { - $arrayofmassactions['prevalidate'] = img_picto('', 'check').' '.$langs->trans("Validate"); - } + if ($permissiontovalidate) { + $arrayofmassactions['prevalidate'] = img_picto('', 'check').' '.$langs->trans("Validate"); } if ($permissiontosendbymail) { $arrayofmassactions['presend'] = img_picto('', 'email').' '.$langs->trans("SendByMail"); } + if ($permissiontoclose) { + $arrayofmassactions['preshipped'] = img_picto('', 'dollyrevert').' '.$langs->trans("ClassifyShipped"); + } if ($permissiontocancel) { $arrayofmassactions['cancelorders'] = img_picto('', 'close_title').' '.$langs->trans("Cancel"); } if ($user->rights->facture->creer) { $arrayofmassactions['createbills'] = img_picto('', 'bill').' '.$langs->trans("CreateInvoiceForThisCustomer"); } - if ($conf->global->MAIN_FEATURES_LEVEL == '2'){ //BB2A - if ($permissiontoclose) { - $arrayofmassactions['setbilled'] = img_picto('', 'bill').' '.$langs->trans("ClassifyBilled"); - } + if ($permissiontoclose) { + $arrayofmassactions['setbilled'] = img_picto('', 'bill').' '.$langs->trans("ClassifyBilled"); } if ($permissiontodelete) { $arrayofmassactions['predelete'] = img_picto('', 'delete').' '.$langs->trans("Delete"); @@ -838,6 +872,9 @@ if ($resql) { if ($massaction == 'prevalidate') { print $form->formconfirm($_SERVER["PHP_SELF"], $langs->trans("ConfirmMassValidation"), $langs->trans("ConfirmMassValidationQuestion"), "validate", null, '', 0, 200, 500, 1); } + if ($massaction == 'preshipped') { + print $form->formconfirm($_SERVER["PHP_SELF"], $langs->trans("CloseOrder"), $langs->trans("ConfirmCloseOrder"), "shipped", null, '', 0, 200, 500, 1); + } if ($massaction == 'createbills') { //var_dump($_REQUEST); From 632487921506e589004ebb769b25bad36a7a6db2 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Wed, 14 Apr 2021 00:25:05 +0000 Subject: [PATCH 019/879] Fixing style errors. --- htdocs/commande/list.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php index 78adb797b88..954c0e95a6d 100644 --- a/htdocs/commande/list.php +++ b/htdocs/commande/list.php @@ -277,12 +277,12 @@ if (empty($reshook)) { $permissiontoread = $user->rights->commande->lire; $permissiontoadd = $user->rights->commande->creer; $permissiontodelete = $user->rights->commande->supprimer; - if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS)){ + if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS)) { $permissiontovalidate = $user->rights->commande->order_advance->validate; $permissiontoclose = $user->rights->commande->order_advance->close; $permissiontocancel = $user->rights->commande->order_advance->annuler; $permissiontosendbymail = $user->rights->commande->order_advance->send; - }else{ + } else { $permissiontovalidate = $user->rights->commande->creer; $permissiontoclose = $user->rights->commande->creer; $permissiontocancel = $user->rights->commande->creer; @@ -300,9 +300,9 @@ if ($action == 'validate' && $permissiontoadd) { foreach ($toselect as $checked) { if ($objecttmp->fetch($checked)) { if ($objecttmp->statut == 0) { - if (!empty($objecttmp->fk_warehouse)){ + if (!empty($objecttmp->fk_warehouse)) { $idwarehouse = $objecttmp->fk_warehouse; - }else{ + } else { $idwarehouse = 0; } if ($objecttmp->valid($user, $idwarehouse)) { @@ -315,7 +315,7 @@ if ($action == 'validate' && $permissiontoadd) { setEventMessage($objecttmp->ref." ".$langs->trans('IsNotADraft'), 'errors'); $error++; } - }else{ + } else { dol_print_error($db); $error++; } @@ -345,7 +345,7 @@ if ($action == 'shipped' && $permissiontoadd) { setEventMessage($objecttmp->ref." ".$langs->trans('IsNotADraft'), 'errors'); $error++; } - }else{ + } else { dol_print_error($db); $error++; } From 2f31720896b94ac235e9a4ad7082959a0cdf6c79 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Wed, 14 Apr 2021 04:45:17 +0200 Subject: [PATCH 020/879] Maxi debug of societe/product per entity --- htdocs/accountancy/admin/productaccount.php | 12 +-- htdocs/accountancy/customer/card.php | 4 +- htdocs/accountancy/customer/index.php | 12 +-- htdocs/accountancy/customer/lines.php | 6 +- htdocs/accountancy/customer/list.php | 16 ++-- .../accountancy/journal/purchasesjournal.php | 10 ++- htdocs/accountancy/journal/sellsjournal.php | 4 +- htdocs/accountancy/supplier/card.php | 12 ++- htdocs/accountancy/supplier/index.php | 29 ++++++-- htdocs/accountancy/supplier/lines.php | 17 ++++- htdocs/accountancy/supplier/list.php | 14 ++-- htdocs/compta/journal/sellsjournal.php | 4 +- htdocs/core/modules/modFacture.class.php | 4 +- htdocs/core/modules/modProduct.class.php | 6 +- htdocs/core/modules/modService.class.php | 4 +- htdocs/product/class/product.class.php | 8 +- htdocs/product/list.php | 8 +- htdocs/societe/class/societe.class.php | 73 ++++++++++++++++--- 18 files changed, 170 insertions(+), 73 deletions(-) diff --git a/htdocs/accountancy/admin/productaccount.php b/htdocs/accountancy/admin/productaccount.php index 2013b0c7295..dd60c33a2e6 100644 --- a/htdocs/accountancy/admin/productaccount.php +++ b/htdocs/accountancy/admin/productaccount.php @@ -270,8 +270,8 @@ if (empty($pcgvercode)) { $sql = "SELECT p.rowid, p.ref, p.label, p.description, p.tosell, p.tobuy, p.tva_tx,"; if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { - $sql .= " pa.accountancy_code_sell, pa.accountancy_code_sell_intra, pa.accountancy_code_sell_export,"; - $sql .= " pa.accountancy_code_buy, pa.accountancy_code_buy_intra, pa.accountancy_code_buy_export,"; + $sql .= " ppe.accountancy_code_sell, ppe.accountancy_code_sell_intra, ppe.accountancy_code_sell_export,"; + $sql .= " ppe.accountancy_code_buy, ppe.accountancy_code_buy_intra, ppe.accountancy_code_buy_export,"; } else { $sql .= " p.accountancy_code_sell, p.accountancy_code_sell_intra, p.accountancy_code_sell_export,"; $sql .= " p.accountancy_code_buy, p.accountancy_code_buy_intra, p.accountancy_code_buy_export,"; @@ -280,14 +280,14 @@ $sql .= " p.tms, p.fk_product_type as product_type,"; $sql .= " aa.rowid as aaid"; $sql .= " FROM ".MAIN_DB_PREFIX."product as p"; if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_perentity as pa ON pa.fk_product = p.rowid AND pa.entity = " . ((int) $conf->entity); - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON aa.account_number = pa." . $accountancy_field_name . " AND aa.fk_pcg_version = '" . $db->escape($pcgvercode) . "'"; + $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_perentity as ppe ON ppe.fk_product = p.rowid AND ppe.entity = " . ((int) $conf->entity); + $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON aa.account_number = ppe." . $accountancy_field_name . " AND aa.fk_pcg_version = '" . $db->escape($pcgvercode) . "'"; } else { $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON aa.account_number = p." . $accountancy_field_name . " AND aa.fk_pcg_version = '" . $db->escape($pcgvercode) . "'"; } $sql .= ' WHERE p.entity IN ('.getEntity('product').')'; if (strlen(trim($search_current_account))) { - $sql .= natural_search((empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED) ? "p." : "pa.") . $accountancy_field_name, $search_current_account); + $sql .= natural_search((empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED) ? "p." : "ppe.") . $accountancy_field_name, $search_current_account); } if ($search_current_account_valid == 'withoutvalidaccount') { $sql .= " AND aa.account_number IS NULL"; @@ -466,7 +466,7 @@ if ($result) { } else { print_liste_field_titre("OnBuy", $_SERVER["PHP_SELF"], "p.tobuy", "", $param, '', $sortfield, $sortorder, 'center '); } - print_liste_field_titre("CurrentDedicatedAccountingAccount", $_SERVER["PHP_SELF"], (empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED) ? "p." : "pa.") . $accountancy_field_name, "", $param, '', $sortfield, $sortorder); + print_liste_field_titre("CurrentDedicatedAccountingAccount", $_SERVER["PHP_SELF"], (empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED) ? "p." : "ppe.") . $accountancy_field_name, "", $param, '', $sortfield, $sortorder); print_liste_field_titre("AssignDedicatedAccountingAccount"); $clickpitco = $form->showCheckAddButtons('checkforselect', 1); print_liste_field_titre($clickpitco, '', '', '', '', '', '', '', 'center '); diff --git a/htdocs/accountancy/customer/card.php b/htdocs/accountancy/customer/card.php index f0bcd9f7a49..b3ce892b235 100644 --- a/htdocs/accountancy/customer/card.php +++ b/htdocs/accountancy/customer/card.php @@ -102,7 +102,7 @@ if (!empty($id)) { $sql = "SELECT f.ref, f.rowid as facid, l.fk_product, l.description, l.price,"; $sql .= " l.qty, l.rowid, l.tva_tx, l.remise_percent, l.subprice,"; if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { - $sql .= " pa.accountancy_code_sell as code_sell,"; + $sql .= " ppe.accountancy_code_sell as code_sell,"; } else { $sql .= " p.accountancy_code_sell as code_sell,"; } @@ -110,7 +110,7 @@ if (!empty($id)) { $sql .= " FROM ".MAIN_DB_PREFIX."facturedet as l"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = l.fk_product"; if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_perentity as pa ON pa.fk_product = p.rowid AND pa.entity = " . ((int) $conf->entity); + $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_perentity as ppe ON ppe.fk_product = p.rowid AND ppe.entity = " . ((int) $conf->entity); } $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON l.fk_code_ventilation = aa.rowid"; $sql .= " INNER JOIN ".MAIN_DB_PREFIX."facture as f ON f.rowid = l.fk_facture"; diff --git a/htdocs/accountancy/customer/index.php b/htdocs/accountancy/customer/index.php index 0b32e2802c4..755d03bbb3a 100644 --- a/htdocs/accountancy/customer/index.php +++ b/htdocs/accountancy/customer/index.php @@ -126,15 +126,15 @@ if ($action == 'validatehistory') { $sql .= " l.rowid, l.fk_product, l.description, l.total_ht, l.fk_code_ventilation, l.product_type as type_l, l.tva_tx as tva_tx_line, l.vat_src_code,"; $sql .= " p.rowid as product_id, p.ref as product_ref, p.label as product_label, p.fk_product_type as type, p.tva_tx as tva_tx_prod,"; if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { - $sql .= " pa.accountancy_code_sell as code_sell, pa.accountancy_code_sell_intra as code_sell_intra, pa.accountancy_code_sell_export as code_sell_export,"; + $sql .= " ppe.accountancy_code_sell as code_sell, ppe.accountancy_code_sell_intra as code_sell_intra, ppe.accountancy_code_sell_export as code_sell_export,"; } else { $sql .= " p.accountancy_code_sell as code_sell, p.accountancy_code_sell_intra as code_sell_intra, p.accountancy_code_sell_export as code_sell_export,"; } $sql .= " aa.rowid as aarowid, aa2.rowid as aarowid_intra, aa3.rowid as aarowid_export, aa4.rowid as aarowid_thirdparty,"; $sql .= " co.code as country_code, co.label as country_label,"; $sql .= " s.tva_intra,"; - if (!empty($conf->global->ACCOUNTANCY_COMPANY_SHARED)) { - $sql .= " sa.accountancy_code_sell as company_code_sell"; + if (!empty($conf->global->MAIN_COMPANY_PERENTITY_SHARED)) { + $sql .= " spe.accountancy_code_sell as company_code_sell"; } else { $sql .= " s.accountancy_code_sell as company_code_sell"; } @@ -145,10 +145,10 @@ if ($action == 'validatehistory') { $sql .= " INNER JOIN ".MAIN_DB_PREFIX."facturedet as l ON f.rowid = l.fk_facture"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = l.fk_product"; if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_perentity as pa ON pa.fk_product = p.rowid AND pa.entity = " . ((int) $conf->entity); + $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_perentity as ppe ON ppe.fk_product = p.rowid AND ppe.entity = " . ((int) $conf->entity); } - $alias_societe_perentity = empty($conf->global->ACCOUNTANCY_COMPANY_SHARED) ? "s" : "sa"; - $alias_product_perentity = empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED) ? "p" : "pa"; + $alias_societe_perentity = empty($conf->global->MAIN_COMPANY_PERENTITY_SHARED) ? "s" : "spe"; + $alias_product_perentity = empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED) ? "p" : "ppe"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON " . $alias_product_perentity . ".accountancy_code_sell = aa.account_number AND aa.active = 1 AND aa.fk_pcg_version = '".$db->escape($chartaccountcode)."' AND aa.entity = ".$conf->entity; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa2 ON " . $alias_product_perentity . ".accountancy_code_sell_intra = aa2.account_number AND aa2.active = 1 AND aa2.fk_pcg_version = '".$db->escape($chartaccountcode)."' AND aa2.entity = ".$conf->entity; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa3 ON " . $alias_product_perentity . ".accountancy_code_sell_export = aa3.account_number AND aa3.active = 1 AND aa3.fk_pcg_version = '".$db->escape($chartaccountcode)."' AND aa3.entity = ".$conf->entity; diff --git a/htdocs/accountancy/customer/lines.php b/htdocs/accountancy/customer/lines.php index 6f522750398..b8cc34c3cae 100644 --- a/htdocs/accountancy/customer/lines.php +++ b/htdocs/accountancy/customer/lines.php @@ -184,9 +184,9 @@ $sql .= " fd.rowid, fd.description, fd.product_type as line_type, fd.total_ht, f $sql .= " s.rowid as socid, s.nom as name, s.code_compta, s.code_client,"; $sql .= " p.rowid as product_id, p.fk_product_type as product_type, p.ref as product_ref, p.label as product_label,"; if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { - $sql .= " pa.accountancy_code_sell,"; + $sql .= " ppe.accountancy_code_sell, ppe.accountancy_code_sell_intra, ppe.accountancy_code_sell_export,"; } else { - $sql .= " p.accountancy_code_sell,"; + $sql .= " p.accountancy_code_sell, p.accountancy_code_sell_intra, p.accountancy_code_sell_export,"; } $sql .= " aa.rowid as fk_compte, aa.account_number, aa.label as label_account, aa.labelshort as labelshort_account,"; $sql .= " fd.situation_percent,"; @@ -198,7 +198,7 @@ $sql .= $hookmanager->resPrint; $sql .= " FROM ".MAIN_DB_PREFIX."facturedet as fd"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = fd.fk_product"; if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_perentity as pa ON pa.fk_product = p.rowid AND pa.entity = " . ((int) $conf->entity); + $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_perentity as ppe ON ppe.fk_product = p.rowid AND ppe.entity = " . ((int) $conf->entity); } $sql .= " INNER JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON aa.rowid = fd.fk_code_ventilation"; $sql .= " INNER JOIN ".MAIN_DB_PREFIX."facture as f ON f.rowid = fd.fk_facture"; diff --git a/htdocs/accountancy/customer/list.php b/htdocs/accountancy/customer/list.php index de160fe2b93..4052ed51fdd 100644 --- a/htdocs/accountancy/customer/list.php +++ b/htdocs/accountancy/customer/list.php @@ -219,8 +219,8 @@ $sql = "SELECT f.rowid as facid, f.ref, f.datef, f.type as ftype,"; $sql .= " l.rowid, l.fk_product, l.description, l.total_ht, l.fk_code_ventilation, l.product_type as type_l, l.tva_tx as tva_tx_line, l.vat_src_code,"; $sql .= " p.rowid as product_id, p.ref as product_ref, p.label as product_label, p.fk_product_type as type, p.tva_tx as tva_tx_prod,"; if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { - $sql .= " pa.accountancy_code_sell as code_sell, pa.accountancy_code_sell_intra as code_sell_intra, pa.accountancy_code_sell_export as code_sell_export,"; - $sql .= " pa.accountancy_code_buy as code_buy, pa.accountancy_code_buy_intra as code_buy_intra, pa.accountancy_code_buy_export as code_buy_export,"; + $sql .= " ppe.accountancy_code_sell as code_sell, ppe.accountancy_code_sell_intra as code_sell_intra, ppe.accountancy_code_sell_export as code_sell_export,"; + $sql .= " ppe.accountancy_code_buy as code_buy, ppe.accountancy_code_buy_intra as code_buy_intra, ppe.accountancy_code_buy_export as code_buy_export,"; } else { $sql .= " p.accountancy_code_sell as code_sell, p.accountancy_code_sell_intra as code_sell_intra, p.accountancy_code_sell_export as code_sell_export,"; $sql .= " p.accountancy_code_buy as code_buy, p.accountancy_code_buy_intra as code_buy_intra, p.accountancy_code_buy_export as code_buy_export,"; @@ -229,8 +229,8 @@ $sql .= " p.tosell as status, p.tobuy as status_buy,"; $sql .= " aa.rowid as aarowid, aa2.rowid as aarowid_intra, aa3.rowid as aarowid_export, aa4.rowid as aarowid_thirdparty,"; $sql .= " co.code as country_code, co.label as country_label,"; $sql .= " s.rowid as socid, s.nom as name, s.tva_intra, s.email, s.town, s.zip, s.fk_pays, s.client, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta as code_compta_client, s.code_compta_fournisseur,"; -if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { - $sql .= " sa.accountancy_code_sell as company_code_sell"; +if (!empty($conf->global->MAIN_COMPANY_PERENTITY_SHARED)) { + $sql .= " spe.accountancy_code_sell as company_code_sell"; } else { $sql .= " s.accountancy_code_sell as company_code_sell"; } @@ -240,16 +240,16 @@ $sql .= $hookmanager->resPrint; $sql .= " FROM ".MAIN_DB_PREFIX."facture as f"; $sql .= " INNER JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = f.fk_soc"; if (!empty($conf->global->MAIN_COMPANY_PERENTITY_SHARED)) { - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "societe_perentity as sa ON sa.fk_soc = s.rowid AND sa.entity = " . ((int) $conf->entity); + $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "societe_perentity as spe ON spe.fk_soc = s.rowid AND spe.entity = " . ((int) $conf->entity); } $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as co ON co.rowid = s.fk_pays "; $sql .= " INNER JOIN ".MAIN_DB_PREFIX."facturedet as l ON f.rowid = l.fk_facture"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = l.fk_product"; if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_perentity as pa ON pa.fk_product = p.rowid AND pa.entity = " . ((int) $conf->entity); + $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_perentity as ppe ON ppe.fk_product = p.rowid AND ppe.entity = " . ((int) $conf->entity); } -$alias_societe_perentity = empty($conf->global->MAIN_COMPANY_PERENTITY_SHARED) ? "s" : "sa"; -$alias_product_perentity = empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED) ? "p" : "pa"; +$alias_societe_perentity = empty($conf->global->MAIN_COMPANY_PERENTITY_SHARED) ? "s" : "spe"; +$alias_product_perentity = empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED) ? "p" : "ppe"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON " . $alias_product_perentity . ".accountancy_code_sell = aa.account_number AND aa.active = 1 AND aa.fk_pcg_version = '".$db->escape($chartaccountcode)."' AND aa.entity = ".$conf->entity; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa2 ON " . $alias_product_perentity . ".accountancy_code_sell_intra = aa2.account_number AND aa2.active = 1 AND aa2.fk_pcg_version = '".$db->escape($chartaccountcode)."' AND aa2.entity = ".$conf->entity; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa3 ON " . $alias_product_perentity . ".accountancy_code_sell_export = aa3.account_number AND aa3.active = 1 AND aa3.fk_pcg_version = '".$db->escape($chartaccountcode)."' AND aa3.entity = ".$conf->entity; diff --git a/htdocs/accountancy/journal/purchasesjournal.php b/htdocs/accountancy/journal/purchasesjournal.php index bf950182798..018cba4ca89 100644 --- a/htdocs/accountancy/journal/purchasesjournal.php +++ b/htdocs/accountancy/journal/purchasesjournal.php @@ -106,9 +106,17 @@ if (!GETPOSTISSET('date_startmonth') && (empty($date_start) || empty($date_end)) $sql = "SELECT f.rowid, f.ref as ref, f.type, f.datef as df, f.libelle,f.ref_supplier, f.date_lim_reglement as dlf, f.close_code,"; $sql .= " fd.rowid as fdid, fd.description, fd.product_type, fd.total_ht, fd.tva as total_tva, fd.total_localtax1, fd.total_localtax2, fd.tva_tx, fd.total_ttc, fd.vat_src_code,"; $sql .= " s.rowid as socid, s.nom as name, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur,"; -$sql .= " p.accountancy_code_buy , aa.rowid as fk_compte, aa.account_number as compte, aa.label as label_compte"; +if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { + $sql .= " ppe.accountancy_code_buy,"; +} else { + $sql .= " p.accountancy_code_buy,"; +} +$sql .= " aa.rowid as fk_compte, aa.account_number as compte, aa.label as label_compte"; $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn_det as fd"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = fd.fk_product"; +if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { + $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_perentity as ppe ON ppe.fk_product = p.rowid AND ppe.entity = " . ((int) $conf->entity); +} $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON aa.rowid = fd.fk_code_ventilation"; $sql .= " JOIN ".MAIN_DB_PREFIX."facture_fourn as f ON f.rowid = fd.fk_facture_fourn"; $sql .= " JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = f.fk_soc"; diff --git a/htdocs/accountancy/journal/sellsjournal.php b/htdocs/accountancy/journal/sellsjournal.php index 1904631775d..a9b6f17a9bd 100644 --- a/htdocs/accountancy/journal/sellsjournal.php +++ b/htdocs/accountancy/journal/sellsjournal.php @@ -110,14 +110,14 @@ $sql .= " fd.rowid as fdid, fd.description, fd.product_type, fd.total_ht, fd.tot $sql .= " s.rowid as socid, s.nom as name, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur,"; $sql .= " p.rowid as pid, p.ref as pref, aa.rowid as fk_compte, aa.account_number as compte, aa.label as label_compte,"; if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { - $sql .= " pa.accountancy_code_sell"; + $sql .= " ppe.accountancy_code_sell"; } else { $sql .= " p.accountancy_code_sell"; } $sql .= " FROM ".MAIN_DB_PREFIX."facturedet as fd"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = fd.fk_product"; if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_perentity as pa ON pa.fk_product = p.rowid AND pa.entity = " . ((int) $conf->entity); + $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_perentity as ppe ON ppe.fk_product = p.rowid AND ppe.entity = " . ((int) $conf->entity); } $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON aa.rowid = fd.fk_code_ventilation"; $sql .= " JOIN ".MAIN_DB_PREFIX."facture as f ON f.rowid = fd.fk_facture"; diff --git a/htdocs/accountancy/supplier/card.php b/htdocs/accountancy/supplier/card.php index cd17df33776..1e7887c1bdc 100644 --- a/htdocs/accountancy/supplier/card.php +++ b/htdocs/accountancy/supplier/card.php @@ -101,10 +101,18 @@ $formaccounting = new FormAccounting($db); if (!empty($id)) { $sql = "SELECT f.ref as ref, f.rowid as facid, l.fk_product, l.description, l.rowid, l.fk_code_ventilation, "; - $sql .= " p.rowid as product_id, p.ref as product_ref, p.label as product_label"; - $sql .= ", aa.account_number, aa.label"; + $sql .= " p.rowid as product_id, p.ref as product_ref, p.label as product_label,"; + if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { + $sql .= " ppe.accountancy_code_buy as code_buy,"; + } else { + $sql .= " p.accountancy_code_buy as code_buy,"; + } + $sql .= " aa.account_number, aa.label"; $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn_det as l"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = l.fk_product"; + if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { + $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_perentity as ppe ON ppe.fk_product = p.rowid AND ppe.entity = " . ((int) $conf->entity); + } $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON l.fk_code_ventilation = aa.rowid"; $sql .= " INNER JOIN ".MAIN_DB_PREFIX."facture_fourn as f ON f.rowid = l.fk_facture_fourn "; $sql .= " WHERE f.fk_statut > 0 AND l.rowid = ".((int) $id); diff --git a/htdocs/accountancy/supplier/index.php b/htdocs/accountancy/supplier/index.php index 392551708de..ff09479ad03 100644 --- a/htdocs/accountancy/supplier/index.php +++ b/htdocs/accountancy/supplier/index.php @@ -132,20 +132,35 @@ if ($action == 'validatehistory') { // Supplier Invoice Lines (must be same request than into page list.php for manual binding) $sql = "SELECT f.rowid as facid, f.ref, f.ref_supplier, f.libelle as invoice_label, f.datef, f.type as ftype,"; $sql .= " l.rowid, l.fk_product, l.description, l.total_ht, l.fk_code_ventilation, l.product_type as type_l, l.tva_tx as tva_tx_line, l.vat_src_code,"; - $sql .= " p.rowid as product_id, p.ref as product_ref, p.label as product_label, p.fk_product_type as type,"; - $sql .= " p.accountancy_code_buy as code_buy, p.accountancy_code_buy_intra as code_buy_intra, p.accountancy_code_buy_export as code_buy_export, p.tva_tx as tva_tx_prod,"; + $sql .= " p.rowid as product_id, p.ref as product_ref, p.label as product_label, p.fk_product_type as type, p.tva_tx as tva_tx_prod,"; + if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { + $sql .= " ppe.accountancy_code_buy as code_buy, ppe.accountancy_code_buy_intra as code_buy_intra, ppe.accountancy_code_buy_export as code_buy_export,"; + } else { + $sql .= " p.accountancy_code_buy as code_buy, p.accountancy_code_buy_intra as code_buy_intra, p.accountancy_code_buy_export as code_buy_export,"; + } $sql .= " aa.rowid as aarowid, aa2.rowid as aarowid_intra, aa3.rowid as aarowid_export, aa4.rowid as aarowid_thirdparty,"; $sql .= " co.code as country_code, co.label as country_label,"; - $sql .= " s.tva_intra, s.accountancy_code_buy as company_code_buy"; + $sql .= " s.tva_intra,"; + if (!empty($conf->global->MAIN_COMPANY_PERENTITY_SHARED)) { + $sql .= " spe.accountancy_code_buy as company_code_buy"; + } else { + $sql .= " s.accountancy_code_buy as company_code_buy"; + } + $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as f"; $sql .= " INNER JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = f.fk_soc"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as co ON co.rowid = s.fk_pays "; $sql .= " INNER JOIN ".MAIN_DB_PREFIX."facture_fourn_det as l ON f.rowid = l.fk_facture_fourn"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = l.fk_product"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON p.accountancy_code_buy = aa.account_number AND aa.active = 1 AND aa.fk_pcg_version = '".$db->escape($chartaccountcode)."' AND aa.entity = ".$conf->entity; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa2 ON p.accountancy_code_buy_intra = aa2.account_number AND aa2.active = 1 AND aa2.fk_pcg_version = '".$db->escape($chartaccountcode)."' AND aa2.entity = ".$conf->entity; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa3 ON p.accountancy_code_buy_export = aa3.account_number AND aa3.active = 1 AND aa3.fk_pcg_version = '".$db->escape($chartaccountcode)."' AND aa3.entity = ".$conf->entity; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa4 ON s.accountancy_code_buy = aa4.account_number AND aa4.active = 1 AND aa4.fk_pcg_version = '".$db->escape($chartaccountcode)."' AND aa4.entity = ".$conf->entity; + if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { + $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_perentity as ppe ON ppe.fk_product = p.rowid AND ppe.entity = " . ((int) $conf->entity); + } + $alias_societe_perentity = empty($conf->global->MAIN_COMPANY_PERENTITY_SHARED) ? "s" : "spe"; + $alias_product_perentity = empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED) ? "p" : "ppe"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON " . $alias_product_perentity . ".accountancy_code_buy = aa.account_number AND aa.active = 1 AND aa.fk_pcg_version = '".$db->escape($chartaccountcode)."' AND aa.entity = ".$conf->entity; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa2 ON " . $alias_product_perentity . ".accountancy_code_buy_intra = aa2.account_number AND aa2.active = 1 AND aa2.fk_pcg_version = '".$db->escape($chartaccountcode)."' AND aa2.entity = ".$conf->entity; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa3 ON " . $alias_product_perentity . ".accountancy_code_buy_export = aa3.account_number AND aa3.active = 1 AND aa3.fk_pcg_version = '".$db->escape($chartaccountcode)."' AND aa3.entity = ".$conf->entity; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa4 ON " . $alias_product_perentity . ".accountancy_code_buy = aa4.account_number AND aa4.active = 1 AND aa4.fk_pcg_version = '".$db->escape($chartaccountcode)."' AND aa4.entity = ".$conf->entity; $sql .= " WHERE f.fk_statut > 0 AND l.fk_code_ventilation <= 0"; $sql .= " AND l.product_type <= 2"; diff --git a/htdocs/accountancy/supplier/lines.php b/htdocs/accountancy/supplier/lines.php index 1f81a5d7e2c..deed1299fd5 100644 --- a/htdocs/accountancy/supplier/lines.php +++ b/htdocs/accountancy/supplier/lines.php @@ -1,6 +1,6 @@ - * Copyright (C) 2013-2020 Alexandre Spangaro + * Copyright (C) 2013-2021 Alexandre Spangaro * Copyright (C) 2014-2015 Ari Elbaz (elarifr) * Copyright (C) 2013-2016 Florian Henry * Copyright (C) 2014 Juanjo Menent @@ -94,6 +94,9 @@ if (empty($user->rights->accounting->mouvements->lire)) { } +$formaccounting = new FormAccounting($db); + + /* * Actions */ @@ -116,7 +119,7 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x' $search_tvaintra = ''; } -if (is_array($changeaccount) && count($changeaccount) > 0) { +if (is_array($changeaccount) && count($changeaccount) > 0 && $user->rights->accounting->bind->write) { $error = 0; if (!(GETPOST('account_parent', 'int') >= 0)) { @@ -124,7 +127,6 @@ if (is_array($changeaccount) && count($changeaccount) > 0) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Account")), null, 'errors'); } - if (!$error) { $db->begin(); @@ -184,7 +186,11 @@ $sql = "SELECT f.rowid as facid, f.ref as ref, f.ref_supplier, f.libelle as invo $sql .= " l.rowid, l.fk_product, l.product_type as line_type, l.description, l.total_ht , l.qty, l.tva_tx, l.vat_src_code,"; $sql .= " aa.label, aa.labelshort, aa.account_number,"; $sql .= " p.rowid as product_id, p.fk_product_type as product_type, p.ref as product_ref, p.label as product_label, p.fk_product_type as type, p.tobuy, p.tosell,"; -$sql .= " p.accountancy_code_buy, p.accountancy_code_buy_intra, p.accountancy_code_buy_export,"; +if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { + $sql .= " ppe.accountancy_code_buy, ppe.accountancy_code_buy_intra, ppe.accountancy_code_buy_export,"; +} else { + $sql .= " p.accountancy_code_buy, p.accountancy_code_buy_intra, p.accountancy_code_buy_export,"; +} $sql .= " co.code as country_code, co.label as country,"; $sql .= " s.rowid as socid, s.nom as name, s.tva_intra, s.email, s.town, s.zip, s.fk_pays, s.client, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta as code_compta_client, s.code_compta_fournisseur"; $parameters = array(); @@ -192,6 +198,9 @@ $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // N $sql .= $hookmanager->resPrint; $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn_det as l"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = l.fk_product"; +if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { + $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_perentity as ppe ON ppe.fk_product = p.rowid AND ppe.entity = " . ((int) $conf->entity); +} $sql .= " INNER JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON aa.rowid = l.fk_code_ventilation"; $sql .= " INNER JOIN ".MAIN_DB_PREFIX."facture_fourn as f ON f.rowid = l.fk_facture_fourn"; $sql .= " INNER JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = f.fk_soc"; diff --git a/htdocs/accountancy/supplier/list.php b/htdocs/accountancy/supplier/list.php index 1dcd17ea074..f70ae669204 100644 --- a/htdocs/accountancy/supplier/list.php +++ b/htdocs/accountancy/supplier/list.php @@ -224,8 +224,8 @@ $sql = "SELECT f.rowid as facid, f.ref, f.ref_supplier, f.libelle as invoice_lab $sql .= " l.rowid, l.fk_product, l.description, l.total_ht, l.fk_code_ventilation, l.product_type as type_l, l.tva_tx as tva_tx_line, l.vat_src_code,"; $sql .= " p.rowid as product_id, p.ref as product_ref, p.label as product_label, p.fk_product_type as type, p.tva_tx as tva_tx_prod,"; if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { - $sql .= " pa.accountancy_code_sell as code_sell, pa.accountancy_code_sell_intra as code_sell_intra, pa.accountancy_code_sell_export as code_sell_export,"; - $sql .= " pa.accountancy_code_buy as code_buy, pa.accountancy_code_buy_intra as code_buy_intra, pa.accountancy_code_buy_export as code_buy_export,"; + $sql .= " ppe.accountancy_code_sell as code_sell, ppe.accountancy_code_sell_intra as code_sell_intra, ppe.accountancy_code_sell_export as code_sell_export,"; + $sql .= " ppe.accountancy_code_buy as code_buy, ppe.accountancy_code_buy_intra as code_buy_intra, ppe.accountancy_code_buy_export as code_buy_export,"; } else { $sql .= " p.accountancy_code_sell as code_sell, p.accountancy_code_sell_intra as code_sell_intra, p.accountancy_code_sell_export as code_sell_export,"; $sql .= " p.accountancy_code_buy as code_buy, p.accountancy_code_buy_intra as code_buy_intra, p.accountancy_code_buy_export as code_buy_export,"; @@ -235,7 +235,7 @@ $sql .= " aa.rowid as aarowid, aa2.rowid as aarowid_intra, aa3.rowid as aarowid_ $sql .= " co.code as country_code, co.label as country_label,"; $sql .= " s.rowid as socid, s.nom as name, s.tva_intra, s.email, s.town, s.zip, s.fk_pays, s.client, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta as code_compta_client, s.code_compta_fournisseur,"; if (!empty($conf->global->MAIN_COMPANY_PERENTITY_SHARED)) { - $sql .= " sa.accountancy_code_buy as company_code_buy"; + $sql .= " spe.accountancy_code_buy as company_code_buy"; } else { $sql .= " s.accountancy_code_buy as company_code_buy"; } @@ -245,16 +245,16 @@ $sql .= $hookmanager->resPrint; $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as f"; $sql .= " INNER JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = f.fk_soc"; if (!empty($conf->global->MAIN_COMPANY_PERENTITY_SHARED)) { - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "societe_perentity as sa ON sa.fk_soc = s.rowid AND sa.entity = " . ((int) $conf->entity); + $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "societe_perentity as spe ON spe.fk_soc = s.rowid AND spe.entity = " . ((int) $conf->entity); } $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as co ON co.rowid = s.fk_pays "; $sql .= " INNER JOIN ".MAIN_DB_PREFIX."facture_fourn_det as l ON f.rowid = l.fk_facture_fourn"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = l.fk_product"; if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_perentity as pa ON pa.fk_product = p.rowid AND pa.entity = " . ((int) $conf->entity); + $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_perentity as ppe ON ppe.fk_product = p.rowid AND ppe.entity = " . ((int) $conf->entity); } -$alias_societe_perentity = empty($conf->global->MAIN_COMPANY_PERENTITY_SHARED) ? "s" : "sa"; -$alias_product_perentity = empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED) ? "p" : "pa"; +$alias_societe_perentity = empty($conf->global->MAIN_COMPANY_PERENTITY_SHARED) ? "s" : "spe"; +$alias_product_perentity = empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED) ? "p" : "ppe"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON " . $alias_product_perentity . ".accountancy_code_buy = aa.account_number AND aa.active = 1 AND aa.fk_pcg_version = '".$db->escape($chartaccountcode)."' AND aa.entity = ".$conf->entity; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa2 ON " . $alias_product_perentity . ".accountancy_code_buy_intra = aa2.account_number AND aa2.active = 1 AND aa2.fk_pcg_version = '".$db->escape($chartaccountcode)."' AND aa2.entity = ".$conf->entity; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa3 ON " . $alias_product_perentity . ".accountancy_code_buy_export = aa3.account_number AND aa3.active = 1 AND aa3.fk_pcg_version = '".$db->escape($chartaccountcode)."' AND aa3.entity = ".$conf->entity; diff --git a/htdocs/compta/journal/sellsjournal.php b/htdocs/compta/journal/sellsjournal.php index 9fa4168ea0a..367ffffbdea 100644 --- a/htdocs/compta/journal/sellsjournal.php +++ b/htdocs/compta/journal/sellsjournal.php @@ -113,7 +113,7 @@ $sql .= " fd.product_type, fd.total_ht, fd.total_tva, fd.tva_tx, fd.total_ttc, f $sql .= " s.rowid as socid, s.nom as name, s.code_compta, s.client,"; $sql .= " p.rowid as pid, p.ref as pref,"; if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { - $sql .= " pa.accountancy_code_sell,"; + $sql .= " ppe.accountancy_code_sell,"; } else { $sql .= " p.accountancy_code_sell,"; } @@ -121,7 +121,7 @@ $sql .= " ct.accountancy_code_sell as account_tva, ct.recuperableonly"; $sql .= " FROM ".MAIN_DB_PREFIX."facturedet as fd"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = fd.fk_product"; if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_perentity as pa ON pa.fk_product = p.rowid AND pa.entity = " . ((int) $conf->entity); + $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_perentity as ppe ON ppe.fk_product = p.rowid AND ppe.entity = " . ((int) $conf->entity); } $sql .= " JOIN ".MAIN_DB_PREFIX."facture as f ON f.rowid = fd.fk_facture"; $sql .= " JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = f.fk_soc"; diff --git a/htdocs/core/modules/modFacture.class.php b/htdocs/core/modules/modFacture.class.php index d1ad993af68..9cc05e5d6f2 100644 --- a/htdocs/core/modules/modFacture.class.php +++ b/htdocs/core/modules/modFacture.class.php @@ -207,7 +207,7 @@ class modFacture extends DolibarrModules //-------- $r = 1; - $alias_product_perentity = empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED) ? "p" : "pa"; + $alias_product_perentity = empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED) ? "p" : "ppe"; $this->export_code[$r] = $this->rights_class.'_'.$r; $this->export_label[$r] = 'CustomersInvoicesAndInvoiceLines'; // Translation key (used only if key ExportDataset_xxx_z not found) $this->export_icon[$r] = 'invoice'; @@ -296,7 +296,7 @@ class modFacture extends DolibarrModules $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'facturedet_extrafields as extra2 on fd.rowid = extra2.fk_object'; $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p on (fd.fk_product = p.rowid)'; if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { - $this->export_sql_end[$r] .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_perentity as pa ON pa.fk_product = p.rowid AND pa.entity = " . ((int) $conf->entity); + $this->export_sql_end[$r] .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_perentity as ppe ON ppe.fk_product = p.rowid AND ppe.entity = " . ((int) $conf->entity); } $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_extrafields as extra3 on p.rowid = extra3.fk_object'; $this->export_sql_end[$r] .= ' WHERE f.fk_soc = s.rowid AND f.rowid = fd.fk_facture'; diff --git a/htdocs/core/modules/modProduct.class.php b/htdocs/core/modules/modProduct.class.php index fd1c7cceca0..344af868b69 100644 --- a/htdocs/core/modules/modProduct.class.php +++ b/htdocs/core/modules/modProduct.class.php @@ -176,7 +176,7 @@ class modProduct extends DolibarrModules //-------- $r = 0; - $alias_product_perentity = empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED) ? "p" : "pa"; + $alias_product_perentity = empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED) ? "p" : "ppe"; $r++; $this->export_code[$r] = $this->rights_class.'_'.$r; @@ -296,7 +296,7 @@ class modProduct extends DolibarrModules $this->export_sql_start[$r] = 'SELECT DISTINCT '; $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'product as p'; if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { - $this->export_sql_end[$r] .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_perentity as pa ON pa.fk_product = p.rowid AND pa.entity = " . ((int) $conf->entity); + $this->export_sql_end[$r] .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_perentity as ppe ON ppe.fk_product = p.rowid AND ppe.entity = " . ((int) $conf->entity); } if (!empty($conf->global->EXPORTTOOL_CATEGORIES)) { $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_product as cp ON cp.fk_product = p.rowid LEFT JOIN '.MAIN_DB_PREFIX.'categorie as cat ON cp.fk_categorie = cat.rowid'; @@ -447,7 +447,7 @@ class modProduct extends DolibarrModules $this->export_sql_start[$r] = 'SELECT DISTINCT '; $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'product as p'; if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { - $this->export_sql_end[$r] .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_perentity as pa ON pa.fk_product = p.rowid AND pa.entity = " . ((int) $conf->entity); + $this->export_sql_end[$r] .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_perentity as ppe ON ppe.fk_product = p.rowid AND ppe.entity = " . ((int) $conf->entity); } $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product_extrafields as extra ON p.rowid = extra.fk_object,'; $this->export_sql_end[$r] .= ' '.MAIN_DB_PREFIX.'product_association as pa, '.MAIN_DB_PREFIX.'product as p2'; diff --git a/htdocs/core/modules/modService.class.php b/htdocs/core/modules/modService.class.php index 3b21cf046c8..40bb2667741 100644 --- a/htdocs/core/modules/modService.class.php +++ b/htdocs/core/modules/modService.class.php @@ -143,7 +143,7 @@ class modService extends DolibarrModules //-------- $r = 0; - $alias_product_perentity = empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED) ? "p" : "pa"; + $alias_product_perentity = empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED) ? "p" : "ppe"; $r++; $this->export_code[$r] = $this->rights_class.'_'.$r; @@ -259,7 +259,7 @@ class modService extends DolibarrModules $this->export_sql_start[$r] = 'SELECT DISTINCT '; $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'product as p'; if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { - $this->export_sql_end[$r] .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_perentity as pa ON pa.fk_product = p.rowid AND pa.entity = " . ((int) $conf->entity); + $this->export_sql_end[$r] .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_perentity as ppe ON ppe.fk_product = p.rowid AND ppe.entity = " . ((int) $conf->entity); } if (!empty($conf->global->EXPORTTOOL_CATEGORIES)) { $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_product as cp ON cp.fk_product = p.rowid LEFT JOIN '.MAIN_DB_PREFIX.'categorie as cat ON cp.fk_categorie = cat.rowid'; diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 16bbc508ac9..224f03fdda1 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -725,6 +725,8 @@ class Product extends CommonObject // update accountancy for this entity if (!$error && !empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { + $this->db->query("DELETE FROM " . MAIN_DB_PREFIX . "product_perentity WHERE fk_product = " . $this->id . " AND entity = " . $conf->entity); + $sql = "INSERT INTO " . MAIN_DB_PREFIX . "product_perentity ("; $sql .= " fk_product"; $sql .= ", entity"; @@ -2168,13 +2170,13 @@ class Product extends CommonObject if (empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { $sql .= " p.accountancy_code_buy, p.accountancy_code_buy_intra, p.accountancy_code_buy_export, p.accountancy_code_sell, p.accountancy_code_sell_intra, p.accountancy_code_sell_export,"; } else { - $sql .= " pa.accountancy_code_buy, pa.accountancy_code_buy_intra, pa.accountancy_code_buy_export, pa.accountancy_code_sell, pa.accountancy_code_sell_intra, pa.accountancy_code_sell_export,"; + $sql .= " ppe.accountancy_code_buy, ppe.accountancy_code_buy_intra, ppe.accountancy_code_buy_export, ppe.accountancy_code_sell, ppe.accountancy_code_sell_intra, ppe.accountancy_code_sell_export,"; } $sql .= " p.stock,p.pmp, p.datec, p.tms, p.import_key, p.entity, p.desiredstock, p.tobatch, p.fk_unit,"; $sql .= " p.fk_price_expression, p.price_autogen, p.model_pdf"; $sql .= " FROM ".MAIN_DB_PREFIX."product as p"; if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_perentity as pa ON pa.fk_product = p.rowid AND pa.entity = " . ((int) $conf->entity); + $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_perentity as ppe ON ppe.fk_product = p.rowid AND ppe.entity = " . ((int) $conf->entity); } if ($id) { $sql .= " WHERE p.rowid = ".((int) $id); @@ -2256,7 +2258,7 @@ class Product extends CommonObject $this->barcode_type = $obj->fk_barcode_type; $this->accountancy_code_buy = $obj->accountancy_code_buy; - $this->accountancy_code_buy_intra = $obj->accountancy_code_buy_intra; + $this->accountancy_code_buy_intra = $obj->accountancy_code_buy_intra; $this->accountancy_code_buy_export = $obj->accountancy_code_buy_export; $this->accountancy_code_sell = $obj->accountancy_code_sell; $this->accountancy_code_sell_intra = $obj->accountancy_code_sell_intra; diff --git a/htdocs/product/list.php b/htdocs/product/list.php index dc035187f30..e649179bb5e 100644 --- a/htdocs/product/list.php +++ b/htdocs/product/list.php @@ -191,7 +191,7 @@ if (empty($conf->global->PRODUIT_MULTIPRICES)) { $isInEEC = isInEEC($mysoc); -$alias_product_perentity = empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED) ? "p" : "pa"; +$alias_product_perentity = empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED) ? "p" : "ppe"; // Definition of fields for lists $arrayfields = array( @@ -364,7 +364,7 @@ $sql .= ' p.tobatch,'; if (empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { $sql .= " p.accountancy_code_sell, p.accountancy_code_sell_intra, p.accountancy_code_sell_export, p.accountancy_code_buy, p.accountancy_code_buy_intra, p.accountancy_code_buy_export,"; } else { - $sql .= " pa.accountancy_code_sell, pa.accountancy_code_sell_intra, pa.accountancy_code_sell_export, pa.accountancy_code_buy, pa.accountancy_code_buy_intra, pa.accountancy_code_buy_export,"; + $sql .= " ppe.accountancy_code_sell, ppe.accountancy_code_sell_intra, ppe.accountancy_code_sell_export, ppe.accountancy_code_buy, ppe.accountancy_code_buy_intra, ppe.accountancy_code_buy_export,"; } $sql .= ' p.datec as date_creation, p.tms as date_update, p.pmp, p.stock, p.cost_price,'; $sql .= ' p.weight, p.weight_units, p.length, p.length_units, p.width, p.width_units, p.height, p.height_units, p.surface, p.surface_units, p.volume, p.volume_units, fk_country, fk_state,'; @@ -387,7 +387,7 @@ $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // N $sql .= $hookmanager->resPrint; $sql .= ' FROM '.MAIN_DB_PREFIX.'product as p'; if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_perentity as pa ON pa.fk_product = p.rowid AND pa.entity = " . ((int) $conf->entity); + $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_perentity as ppe ON ppe.fk_product = p.rowid AND ppe.entity = " . ((int) $conf->entity); } if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_extrafields as ef on (p.rowid = ef.fk_object)"; @@ -523,7 +523,7 @@ $sql .= ' p.datec, p.tms, p.entity, p.tobatch, p.pmp, p.cost_price, p.stock,'; if (empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { $sql .= " p.accountancy_code_sell, p.accountancy_code_sell_intra, p.accountancy_code_sell_export, p.accountancy_code_buy, p.accountancy_code_buy_intra, p.accountancy_code_buy_export,"; } else { - $sql .= " pa.accountancy_code_sell, pa.accountancy_code_sell_intra, pa.accountancy_code_sell_export, pa.accountancy_code_buy, pa.accountancy_code_buy_intra, pa.accountancy_code_buy_export,"; + $sql .= " ppe.accountancy_code_sell, ppe.accountancy_code_sell_intra, ppe.accountancy_code_sell_export, ppe.accountancy_code_buy, ppe.accountancy_code_buy_intra, ppe.accountancy_code_buy_export,"; } $sql .= ' p.weight, p.weight_units, p.length, p.length_units, p.width, p.width_units, p.height, p.height_units, p.surface, p.surface_units, p.volume, p.volume_units, p.fk_country, p.fk_state'; if (!empty($conf->global->PRODUCT_USE_UNITS)) { diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 9d449922dd2..29e125de321 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -879,8 +879,10 @@ class Societe extends CommonObject $sql .= ", import_key"; $sql .= ", fk_multicurrency"; $sql .= ", multicurrency_code"; - $sql .= ", accountancy_code_buy"; - $sql .= ", accountancy_code_sell"; + if (empty($conf->global->MAIN_COMPANY_PERENTITY_SHARED)) { + $sql .= ", accountancy_code_buy"; + $sql .= ", accountancy_code_sell"; + } $sql .= ") VALUES ('".$this->db->escape($this->name)."', '".$this->db->escape($this->name_alias)."', ".$this->db->escape($this->entity).", '".$this->db->idate($now)."'"; $sql .= ", ".(!empty($user->id) ? ((int) $user->id) : "null"); $sql .= ", ".(!empty($this->typent_id) ? ((int) $this->typent_id) : "null"); @@ -893,8 +895,10 @@ class Societe extends CommonObject $sql .= ", ".(!empty($this->import_key) ? "'".$this->db->escape($this->import_key)."'" : "null"); $sql .= ", ".(int) $this->fk_multicurrency; $sql .= ", '".$this->db->escape($this->multicurrency_code)."'"; - $sql .= ", '".$this->db->escape($this->accountancy_code_buy)."'"; - $sql .= ", '".$this->db->escape($this->accountancy_code_sell)."'"; + if (empty($conf->global->MAIN_COMPANY_PERENTITY_SHARED)) { + $sql .= ", '" . $this->db->escape($this->accountancy_code_buy) . "'"; + $sql .= ", '" . $this->db->escape($this->accountancy_code_sell) . "'"; + } $sql .= ")"; dol_syslog(get_class($this)."::create", LOG_DEBUG); @@ -904,6 +908,28 @@ class Societe extends CommonObject $ret = $this->update($this->id, $user, 0, 1, 1, 'add'); + // update accountancy for this entity + if (!$error && !empty($conf->global->MAIN_COMPANY_PERENTITY_SHARED)) { + $this->db->query("DELETE FROM " . MAIN_DB_PREFIX . "societe_perentity WHERE fk_soc = " . $this->id . " AND entity = " . $conf->entity); + + $sql = "INSERT INTO " . MAIN_DB_PREFIX . "societe_perentity ("; + $sql .= " fk_soc"; + $sql .= ", entity"; + $sql .= ", accountancy_code_buy"; + $sql .= ", accountancy_code_sell"; + $sql .= ") VALUES ("; + $sql .= $this->id; + $sql .= ", " . $conf->entity; + $sql .= ", '" . $this->db->escape($this->accountancy_code_buy) . "'"; + $sql .= ", '" . $this->db->escape($this->accountancy_code_sell) . "'"; + $sql .= ")"; + $result = $this->db->query($sql); + if (!$result) { + $error++; + $this->error = 'ErrorFailedToUpdateAccountancyForEntity'; + } + } + // Ajout du commercial affecte if ($this->commercial_id != '' && $this->commercial_id != -1) { $this->add_commercial($user, $this->commercial_id); @@ -1414,10 +1440,10 @@ class Societe extends CommonObject $sql .= ",order_min_amount= ".($this->order_min_amount != '' ? $this->order_min_amount : 'null'); $sql .= ",supplier_order_min_amount= ".($this->supplier_order_min_amount != '' ? $this->supplier_order_min_amount : 'null'); $sql .= ",fk_prospectlevel='".$this->db->escape($this->fk_prospectlevel)."'"; - - $sql.= ", accountancy_code_buy = '" . $this->db->escape($this->accountancy_code_buy)."'"; - $sql.= ", accountancy_code_sell= '" . $this->db->escape($this->accountancy_code_sell)."'"; - + if (empty($conf->global->MAIN_COMPANY_PERENTITY_SHARED)) { + $sql .= ", accountancy_code_buy = '" . $this->db->escape($this->accountancy_code_buy) . "'"; + $sql .= ", accountancy_code_sell= '" . $this->db->escape($this->accountancy_code_sell) . "'"; + } $sql .= ",webservices_url = ".(!empty($this->webservices_url) ? "'".$this->db->escape($this->webservices_url)."'" : "null"); $sql .= ",webservices_key = ".(!empty($this->webservices_key) ? "'".$this->db->escape($this->webservices_key)."'" : "null"); @@ -1499,6 +1525,28 @@ class Societe extends CommonObject $action = 'update'; + // update accountancy for this entity + if (!$error && !empty($conf->global->MAIN_COMPANY_PERENTITY_SHARED)) { + $this->db->query("DELETE FROM " . MAIN_DB_PREFIX . "societe_perentity WHERE fk_soc = " . $this->id . " AND entity = " . $conf->entity); + + $sql = "INSERT INTO " . MAIN_DB_PREFIX . "societe_perentity ("; + $sql .= " fk_soc"; + $sql .= ", entity"; + $sql .= ", accountancy_code_buy"; + $sql .= ", accountancy_code_sell"; + $sql .= ") VALUES ("; + $sql .= $this->id; + $sql .= ", " . $conf->entity; + $sql .= ", '" . $this->db->escape($this->accountancy_code_buy) . "'"; + $sql .= ", '" . $this->db->escape($this->accountancy_code_sell) . "'"; + $sql .= ")"; + $result = $this->db->query($sql); + if (!$result) { + $error++; + $this->error = 'ErrorFailedToUpdateAccountancyForEntity'; + } + } + // Actions on extra fields if (!$error) { $result = $this->insertExtraFields(); @@ -1589,7 +1637,11 @@ class Societe extends CommonObject $sql .= ', s.fk_effectif as effectif_id'; $sql .= ', s.fk_forme_juridique as forme_juridique_code'; $sql .= ', s.webservices_url, s.webservices_key'; - $sql .= ', s.accountancy_code_buy, s.accountancy_code_sell'; + if (empty($conf->global->MAIN_COMPANY_PERENTITY_SHARED)) { + $sql .= ', s.accountancy_code_buy, s.accountancy_code_sell'; + } else { + $sql .= ', spe.accountancy_code_buy, spe.accountancy_code_sell'; + } $sql .= ', s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur, s.parent, s.barcode'; $sql .= ', s.fk_departement as state_id, s.fk_pays as country_id, s.fk_stcomm, s.remise_supplier, s.mode_reglement, s.cond_reglement, s.transport_mode'; $sql .= ', s.fk_account, s.tva_assuj'; @@ -1609,6 +1661,9 @@ class Societe extends CommonObject $sql .= ', i.libelle as label_incoterms'; $sql .= ', sr.remise_client, model_pdf'; $sql .= ' FROM '.MAIN_DB_PREFIX.'societe as s'; + if (!empty($conf->global->MAIN_COMPANY_PERENTITY_SHARED)) { + $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "societe_perentity as spe ON spe.fk_soc = s.rowid AND spe.entity = " . ((int) $conf->entity); + } $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_effectif as e ON s.fk_effectif = e.id'; $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as c ON s.fk_pays = c.rowid'; $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_stcomm as st ON s.fk_stcomm = st.id'; From 69fd2cf24ca3bb6a52de1924686d0af25636d14e Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Wed, 14 Apr 2021 02:50:23 +0000 Subject: [PATCH 021/879] Fixing style errors. --- htdocs/product/list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/product/list.php b/htdocs/product/list.php index e649179bb5e..735c0f6481f 100644 --- a/htdocs/product/list.php +++ b/htdocs/product/list.php @@ -523,7 +523,7 @@ $sql .= ' p.datec, p.tms, p.entity, p.tobatch, p.pmp, p.cost_price, p.stock,'; if (empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { $sql .= " p.accountancy_code_sell, p.accountancy_code_sell_intra, p.accountancy_code_sell_export, p.accountancy_code_buy, p.accountancy_code_buy_intra, p.accountancy_code_buy_export,"; } else { - $sql .= " ppe.accountancy_code_sell, ppe.accountancy_code_sell_intra, ppe.accountancy_code_sell_export, ppe.accountancy_code_buy, ppe.accountancy_code_buy_intra, ppe.accountancy_code_buy_export,"; + $sql .= " ppe.accountancy_code_sell, ppe.accountancy_code_sell_intra, ppe.accountancy_code_sell_export, ppe.accountancy_code_buy, ppe.accountancy_code_buy_intra, ppe.accountancy_code_buy_export,"; } $sql .= ' p.weight, p.weight_units, p.length, p.length_units, p.width, p.width_units, p.height, p.height_units, p.surface, p.surface_units, p.volume, p.volume_units, p.fk_country, p.fk_state'; if (!empty($conf->global->PRODUCT_USE_UNITS)) { From 55afc59db25c55839a8df10dcdd267d9a763ed60 Mon Sep 17 00:00:00 2001 From: Dorian Vabre Date: Wed, 14 Apr 2021 14:33:11 +0200 Subject: [PATCH 022/879] 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 '
'; + print ''; + print "\n"; + } + if (!empty($conf->product->enabled) || !empty($conf->service->enabled)) { + print ''; + 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 023/879] 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 024/879] 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 '
'.$langs->trans("FormCreateRate").''; - print $form->selectDate($search_date_sync, 'search_date_sync', 0, 0, 1); - print $form->selectDate($search_date_sync_end, 'search_date_sync_end', 0, 0, 1); + print $form->selectDate(dol_print_date($search_date_sync, "%Y-%m-%d" ), 'search_date_sync', 0, 0, 1); + print $form->selectDate(dol_print_date($search_date_sync_end, "%Y-%m-%d"), 'search_date_sync_end', 0, 0, 1); print ''; - print $form->selectDate(dol_print_date($search_date_sync, "%Y-%m-%d" ), 'search_date_sync', 0, 0, 1); + print $form->selectDate(dol_print_date($search_date_sync, "%Y-%m-%d"), 'search_date_sync', 0, 0, 1); print $form->selectDate(dol_print_date($search_date_sync_end, "%Y-%m-%d"), 'search_date_sync_end', 0, 0, 1); print '
'.$langs->trans("ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS").''; + $selected = (empty($conf->global->$constname) ? '' : $conf->global->$constname); + $form->select_produits($selected, $constname, '', 0); + print '
'.$langs->trans("ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS").''; + $selected = (empty($conf->global->$constname) ? '' : $conf->global->$constname); + $form->select_produits($selected, $constname, '', 0); + 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 025/879] 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 026/879] 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 027/879] 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 028/879] 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 029/879] 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 059/879] 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 060/879] 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 061/879] 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 5b6439ca5eb742a41d13a40fbe1f33b00a5817f2 Mon Sep 17 00:00:00 2001 From: Gauthier PC portable 024 Date: Mon, 19 Apr 2021 09:15:47 +0200 Subject: [PATCH 062/879] FIX : cast int --- htdocs/comm/mailing/class/advtargetemailing.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/comm/mailing/class/advtargetemailing.class.php b/htdocs/comm/mailing/class/advtargetemailing.class.php index ff2e056344c..730ca263f1d 100644 --- a/htdocs/comm/mailing/class/advtargetemailing.class.php +++ b/htdocs/comm/mailing/class/advtargetemailing.class.php @@ -638,7 +638,7 @@ class AdvanceTargetingMailing extends CommonObject } } elseif ($extrafields->attributes[$elementtype]['type'][$key] == 'boolean') { if ($arrayquery['options_'.$key]!=''){ - $sqlwhere[]= " (te.".$key." = ".$arrayquery['options_'.$key].")"; + $sqlwhere[]= " (te.".$key." = ".((int)$arrayquery['options_'.$key]).")"; } } elseif ($extrafields->attributes[$elementtype]['type'][$key] == 'link') { if ($arrayquery['options_'.$key] > 0){ From 8c428081ab94113a19ae70e0b1d8b8be4eeab84c Mon Sep 17 00:00:00 2001 From: Gauthier PC portable 024 Date: Mon, 19 Apr 2021 09:17:33 +0200 Subject: [PATCH 063/879] FIX : test on link type --- htdocs/comm/mailing/class/advtargetemailing.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/comm/mailing/class/advtargetemailing.class.php b/htdocs/comm/mailing/class/advtargetemailing.class.php index 4356039d080..bb472753204 100644 --- a/htdocs/comm/mailing/class/advtargetemailing.class.php +++ b/htdocs/comm/mailing/class/advtargetemailing.class.php @@ -638,11 +638,11 @@ class AdvanceTargetingMailing extends CommonObject } } elseif ($extrafields->attributes[$elementtype]['type'][$key] == 'boolean') { if ($arrayquery['options_'.$key]!=''){ - $sqlwhere[]= " (te.".$key." = ".((int)$arrayquery['options_'.$key]).")"; + $sqlwhere[]= " (te.".$key." = ".$arrayquery['options_'.$key].")"; } } elseif ($extrafields->attributes[$elementtype]['type'][$key] == 'link') { if ($arrayquery['options_'.$key] > 0){ - $sqlwhere[]= " (te.".$key." = ".$arrayquery['options_'.$key].")"; + $sqlwhere[]= " (te.".$key." = ".((int)$arrayquery['options_'.$key]).")"; } } else { if (is_array($arrayquery['options_'.$key])) { From 318a783237afa2c4c06226d282f28bcaf1cb7e31 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Mon, 19 Apr 2021 07:19:45 +0000 Subject: [PATCH 064/879] Fixing style errors. --- htdocs/comm/mailing/class/advtargetemailing.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/comm/mailing/class/advtargetemailing.class.php b/htdocs/comm/mailing/class/advtargetemailing.class.php index bb472753204..cb539768cf9 100644 --- a/htdocs/comm/mailing/class/advtargetemailing.class.php +++ b/htdocs/comm/mailing/class/advtargetemailing.class.php @@ -642,7 +642,7 @@ class AdvanceTargetingMailing extends CommonObject } } elseif ($extrafields->attributes[$elementtype]['type'][$key] == 'link') { if ($arrayquery['options_'.$key] > 0){ - $sqlwhere[]= " (te.".$key." = ".((int)$arrayquery['options_'.$key]).")"; + $sqlwhere[]= " (te.".$key." = ".((int) $arrayquery['options_'.$key]).")"; } } else { if (is_array($arrayquery['options_'.$key])) { From 701b53773b4e619d82d72a3224459241f4e7f29e Mon Sep 17 00:00:00 2001 From: Dorian Vabre Date: Mon, 19 Apr 2021 09:54:29 +0200 Subject: [PATCH 065/879] 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 066/879] 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 a6c6f9eb08443c2dd4e0c4e7568573ed08002521 Mon Sep 17 00:00:00 2001 From: Pierre Payet Date: Mon, 19 Apr 2021 10:20:51 +0200 Subject: [PATCH 067/879] add missing printFieldListFrom hook --- htdocs/fichinter/list.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/htdocs/fichinter/list.php b/htdocs/fichinter/list.php index d054f5e5bcc..d690feb7407 100644 --- a/htdocs/fichinter/list.php +++ b/htdocs/fichinter/list.php @@ -223,6 +223,10 @@ if (!empty($conf->contrat->enabled)) { } 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 (f.rowid = ef.fk_object)"; if (empty($conf->global->FICHINTER_DISABLE_DETAILS) && $atleastonefieldinlines) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."fichinterdet as fd ON fd.fk_fichinter = f.rowid"; +// Add table from hooks +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListFrom', $parameters, $object); // Note that $action and $object may have been modified by hook +$sql .= $hookmanager->resPrint; if (!$user->rights->societe->client->voir && empty($socid)) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql .= ", ".MAIN_DB_PREFIX."societe as s"; $sql .= " WHERE f.entity IN (".getEntity('intervention').")"; From a4eb4aa80258f3707c37f53071b075f983678cc4 Mon Sep 17 00:00:00 2001 From: NextGestion Date: Mon, 19 Apr 2021 10:08:35 +0100 Subject: [PATCH 068/879] 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 584c09d62c3ec64162d4212dc143000997ceb131 Mon Sep 17 00:00:00 2001 From: x Date: Mon, 19 Apr 2021 11:50:03 +0200 Subject: [PATCH 069/879] shorten link to 509 lenght Stickler CI / stickler-ci --- htdocs/multicurrency/multicurrency_rate.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/multicurrency/multicurrency_rate.php b/htdocs/multicurrency/multicurrency_rate.php index fb597b2e07c..ca3ee91703c 100644 --- a/htdocs/multicurrency/multicurrency_rate.php +++ b/htdocs/multicurrency/multicurrency_rate.php @@ -535,8 +535,8 @@ if ($resql) { { $selected = 0; if (in_array($obj->rowid, $arrayofselected)) $selected = 1; - $atag = 'rowid.'&page='.$page.'&sortorder='.$sortorder.'&sortfield='.$sortfield.'&search_code='.$search_code.'&search_rate='.$search_rate.'&search_date_sync='.dol_print_date($search_date_sync, "%Y-%m-%d") .'&search_date_sync_end='.dol_print_date($search_date_sync_end, "%Y-%m-%d") .'&edit_mode='. '1'. '">'.img_picto('edit', 'edit').'' - print $atag ; + $par = '&id_rate='.$obj->rowid.'&page='.$page.'&sortorder='.$sortorder.'&sortfield='.$sortfield.'&search_code='.$search_code.'&search_rate='.$search_rate.'&search_date_sync='.dol_print_date($search_date_sync, "%Y-%m-%d") .'&search_date_sync_end='.dol_print_date($search_date_sync_end, "%Y-%m-%d") .'&edit_mode=1'; + print ''.img_picto('edit', 'edit').''; print 'rowid.'">'.img_picto('delete', 'delete').''; print ''; } From 08787cf40fb883122265704b7a06c72518fadc5c Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Mon, 19 Apr 2021 09:52:17 +0000 Subject: [PATCH 070/879] Fixing style errors. --- htdocs/multicurrency/multicurrency_rate.php | 121 ++++++++++---------- 1 file changed, 58 insertions(+), 63 deletions(-) diff --git a/htdocs/multicurrency/multicurrency_rate.php b/htdocs/multicurrency/multicurrency_rate.php index ca3ee91703c..8a31a34b1f3 100644 --- a/htdocs/multicurrency/multicurrency_rate.php +++ b/htdocs/multicurrency/multicurrency_rate.php @@ -217,7 +217,7 @@ if (empty($reshook)) { if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers $sall = ""; $search_date_sync = ""; - $search_date_sync_end=""; + $search_date_sync_end=""; $search_rate = ""; $search_code = ""; $search_array_options = array(); @@ -298,10 +298,10 @@ $sql .= $hookmanager->resPrint; $sql .= ' FROM '.MAIN_DB_PREFIX.'multicurrency_rate as cr '; $sql .= " INNER JOIN ".MAIN_DB_PREFIX."multicurrency AS m ON cr.fk_multicurrency = m.rowid"; if ($sall) $sql .= natural_search(array_keys($fieldstosearchall), $sall); -if ($search_date_sync && $search_date_sync_end ){ - $sql .= " AND (cr.date_sync BETWEEN '".$db->idate($search_date_sync)."' AND '".$db->idate($search_date_sync_end)."')"; +if ($search_date_sync && $search_date_sync_end ) { + $sql .= " AND (cr.date_sync BETWEEN '".$db->idate($search_date_sync)."' AND '".$db->idate($search_date_sync_end)."')"; } elseif ($search_date_sync && !$search_date_sync_end) { - $sql .= natural_search('cr.date_sync', $db->idate($search_date_sync)); + $sql .= natural_search('cr.date_sync', $db->idate($search_date_sync)); } if ($search_rate) $sql .= natural_search('cr.rate', $search_rate); if ($search_code) $sql .= natural_search('m.code', $search_code); @@ -355,9 +355,9 @@ if ($resql) { } if ($search_date_sync) $param = "&search_date_sync=".$search_date_sync; - if ($search_date_sync_end) $param="&search_date_sync_end=".$search_date_sync_end; + if ($search_date_sync_end) $param="&search_date_sync_end=".$search_date_sync_end; if ($search_rate) $param = "&search_rate=".urlencode($search_rate); - if ($search_code != '') $param.="&search_code=".urlencode($search_code); + if ($search_code != '') $param.="&search_code=".urlencode($search_code); // Add $param from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; @@ -427,13 +427,13 @@ if ($resql) { if (!empty($arrayfields['cr.date_sync']['checked'])) { print ''; print $form->selectDate(dol_print_date($search_date_sync, "%Y-%m-%d"), 'search_date_sync', 0, 0, 1); - print $form->selectDate(dol_print_date($search_date_sync_end, "%Y-%m-%d"), 'search_date_sync_end', 0, 0, 1); + print $form->selectDate(dol_print_date($search_date_sync_end, "%Y-%m-%d"), 'search_date_sync_end', 0, 0, 1); print ''; } // code if (!empty($arrayfields['m.code']['checked'])) { print ''; - print $form->selectMultiCurrency($multicurrency_code, 'search_code', 1, " code != '".$conf->currency."'", true); + print $form->selectMultiCurrency($multicurrency_code, 'search_code', 1, " code != '".$conf->currency."'", true); print ''; } // rate @@ -481,67 +481,62 @@ if ($resql) { print ''; - // USER REQUEST UPDATE FOR THIS LINE - if ($action == "updateRate" && $obj->rowid == $id_rate_selected) { - // var_dump($obj); - print ' '; - print '' . $form->selectMultiCurrency($obj->code, 'multicurrency_code', 1, " code != '".$conf->currency."'", true) . ''; - print ' '; + // USER REQUEST UPDATE FOR THIS LINE + if ($action == "updateRate" && $obj->rowid == $id_rate_selected) { + // var_dump($obj); + print ' '; + print '' . $form->selectMultiCurrency($obj->code, 'multicurrency_code', 1, " code != '".$conf->currency."'", true) . ''; + print ' '; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - } - else { - // date_sync - if (!empty($arrayfields['cr.date_sync']['checked'])) - { - print ''; - print $obj->date_sync; - print "\n"; - if (!$i) $totalarray['nbfield']++; - } + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + } else { + // date_sync + if (!empty($arrayfields['cr.date_sync']['checked'])) { + print ''; + print $obj->date_sync; + print "\n"; + if (!$i) $totalarray['nbfield']++; + } - // code - if (! empty($arrayfields['m.code']['checked'])) - { - print ''; - print $obj->code." ".$obj->name; - print "\n"; + // code + if (! empty($arrayfields['m.code']['checked'])) { + print ''; + print $obj->code." ".$obj->name; + print "\n"; - if (! $i) $totalarray['nbfield']++; - } + if (! $i) $totalarray['nbfield']++; + } - // rate - if (! empty($arrayfields['cr.rate']['checked'])) - { - print ''; - print $obj->rate; - print "\n"; - if (! $i) $totalarray['nbfield']++; - } + // rate + if (! empty($arrayfields['cr.rate']['checked'])) { + print ''; + print $obj->rate; + print "\n"; + if (! $i) $totalarray['nbfield']++; + } - // Fields from hook - $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj); - $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; + // Fields from hook + $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj); + $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; - // Action - print ''; - if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined - { - $selected = 0; - if (in_array($obj->rowid, $arrayofselected)) $selected = 1; - $par = '&id_rate='.$obj->rowid.'&page='.$page.'&sortorder='.$sortorder.'&sortfield='.$sortfield.'&search_code='.$search_code.'&search_rate='.$search_rate.'&search_date_sync='.dol_print_date($search_date_sync, "%Y-%m-%d") .'&search_date_sync_end='.dol_print_date($search_date_sync_end, "%Y-%m-%d") .'&edit_mode=1'; - print ''.img_picto('edit', 'edit').''; - print 'rowid.'">'.img_picto('delete', 'delete').''; - print ''; - } - print ''; - if (!$i) $totalarray['nbfield']++; + // Action + print ''; + if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined + $selected = 0; + if (in_array($obj->rowid, $arrayofselected)) $selected = 1; + $par = '&id_rate='.$obj->rowid.'&page='.$page.'&sortorder='.$sortorder.'&sortfield='.$sortfield.'&search_code='.$search_code.'&search_rate='.$search_rate.'&search_date_sync='.dol_print_date($search_date_sync, "%Y-%m-%d") .'&search_date_sync_end='.dol_print_date($search_date_sync_end, "%Y-%m-%d") .'&edit_mode=1'; + print ''.img_picto('edit', 'edit').''; + print 'rowid.'">'.img_picto('delete', 'delete').''; + print ''; + } + print ''; + if (!$i) $totalarray['nbfield']++; } print "\n"; From 8f1046fcb3096525c685f1f90d6906e4e9cc81f2 Mon Sep 17 00:00:00 2001 From: x Date: Mon, 19 Apr 2021 11:56:37 +0200 Subject: [PATCH 071/879] use form->selectDate instead of html input type date --- htdocs/multicurrency/multicurrency_rate.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/htdocs/multicurrency/multicurrency_rate.php b/htdocs/multicurrency/multicurrency_rate.php index ca3ee91703c..6a553fc5abf 100644 --- a/htdocs/multicurrency/multicurrency_rate.php +++ b/htdocs/multicurrency/multicurrency_rate.php @@ -484,7 +484,10 @@ if ($resql) { // USER REQUEST UPDATE FOR THIS LINE if ($action == "updateRate" && $obj->rowid == $id_rate_selected) { // var_dump($obj); - print ' '; + $form = new Form($db); + print '' . $form->selectDate($obj->date_sync, 'dateinput', 0, 0, 1).''; + + print '' . $form->selectMultiCurrency($obj->code, 'multicurrency_code', 1, " code != '".$conf->currency."'", true) . ''; print ' '; From e78f6e3001a2ab55659d4cab6fe1192ba4af00fc Mon Sep 17 00:00:00 2001 From: x Date: Mon, 19 Apr 2021 12:03:52 +0200 Subject: [PATCH 072/879] replace urlencode --- htdocs/multicurrency/multicurrency_rate.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/multicurrency/multicurrency_rate.php b/htdocs/multicurrency/multicurrency_rate.php index 9f0a6af576b..0de0d0c458b 100644 --- a/htdocs/multicurrency/multicurrency_rate.php +++ b/htdocs/multicurrency/multicurrency_rate.php @@ -354,7 +354,7 @@ if ($resql) { $param .= "&sall=".urlencode($sall); } - if ($search_date_sync) $param = "&search_date_sync=".$search_date_sync; + if ($search_date_sync) $param = "&search_date_sync=".urlencode($search_date_sync); if ($search_date_sync_end) $param="&search_date_sync_end=".$search_date_sync_end; if ($search_rate) $param = "&search_rate=".urlencode($search_rate); if ($search_code != '') $param.="&search_code=".urlencode($search_code); From f71b15ac8ee9e665e6709194f48d3b513fcf19f8 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Mon, 19 Apr 2021 10:05:56 +0000 Subject: [PATCH 073/879] Fixing style errors. --- htdocs/multicurrency/multicurrency_rate.php | 104 +++++++++----------- 1 file changed, 49 insertions(+), 55 deletions(-) diff --git a/htdocs/multicurrency/multicurrency_rate.php b/htdocs/multicurrency/multicurrency_rate.php index 0de0d0c458b..7445a6ed274 100644 --- a/htdocs/multicurrency/multicurrency_rate.php +++ b/htdocs/multicurrency/multicurrency_rate.php @@ -482,71 +482,65 @@ if ($resql) { print ''; - // USER REQUEST UPDATE FOR THIS LINE - if ($action == "updateRate" && $obj->rowid == $id_rate_selected) { - // var_dump($obj); + // USER REQUEST UPDATE FOR THIS LINE + if ($action == "updateRate" && $obj->rowid == $id_rate_selected) { + // var_dump($obj); $form = new Form($db); print '' . $form->selectDate($obj->date_sync, 'dateinput', 0, 0, 1).''; - print '' . $form->selectMultiCurrency($obj->code, 'multicurrency_code', 1, " code != '".$conf->currency."'", true) . ''; - print ' '; + print '' . $form->selectMultiCurrency($obj->code, 'multicurrency_code', 1, " code != '".$conf->currency."'", true) . ''; + print ' '; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - } - else { - // date_sync - if (!empty($arrayfields['cr.date_sync']['checked'])) - { - print ''; - print $obj->date_sync; - print "\n"; - if (!$i) $totalarray['nbfield']++; - } + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + } else { + // date_sync + if (!empty($arrayfields['cr.date_sync']['checked'])) { + print ''; + print $obj->date_sync; + print "\n"; + if (!$i) $totalarray['nbfield']++; + } - // code - if (! empty($arrayfields['m.code']['checked'])) - { - print ''; - print $obj->code." ".$obj->name; - print "\n"; + // code + if (! empty($arrayfields['m.code']['checked'])) { + print ''; + print $obj->code." ".$obj->name; + print "\n"; - if (! $i) $totalarray['nbfield']++; - } + if (! $i) $totalarray['nbfield']++; + } - // rate - if (! empty($arrayfields['cr.rate']['checked'])) - { - print ''; - print $obj->rate; - print "\n"; - if (! $i) $totalarray['nbfield']++; - } + // rate + if (! empty($arrayfields['cr.rate']['checked'])) { + print ''; + print $obj->rate; + print "\n"; + if (! $i) $totalarray['nbfield']++; + } - // Fields from hook - $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj); - $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - - // Action - print ''; - if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined - { - $selected = 0; - if (in_array($obj->rowid, $arrayofselected)) $selected = 1; - $par = '&id_rate='.$obj->rowid.'&page='.$page.'&sortorder='.$sortorder.'&sortfield='.$sortfield.'&search_code='.$search_code.'&search_rate='.$search_rate.'&search_date_sync='.dol_print_date($search_date_sync, "%Y-%m-%d") .'&search_date_sync_end='.dol_print_date($search_date_sync_end, "%Y-%m-%d") .'&edit_mode=1'; - print ''.img_picto('edit', 'edit').''; - print 'rowid.'">'.img_picto('delete', 'delete').''; - print ''; - } - print ''; - if (!$i) $totalarray['nbfield']++; + // Fields from hook + $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj); + $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + // Action + print ''; + if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined + $selected = 0; + if (in_array($obj->rowid, $arrayofselected)) $selected = 1; + $par = '&id_rate='.$obj->rowid.'&page='.$page.'&sortorder='.$sortorder.'&sortfield='.$sortfield.'&search_code='.$search_code.'&search_rate='.$search_rate.'&search_date_sync='.dol_print_date($search_date_sync, "%Y-%m-%d") .'&search_date_sync_end='.dol_print_date($search_date_sync_end, "%Y-%m-%d") .'&edit_mode=1'; + print ''.img_picto('edit', 'edit').''; + print 'rowid.'">'.img_picto('delete', 'delete').''; + print ''; + } + print ''; + if (!$i) $totalarray['nbfield']++; } print "\n"; From 62d71028407dd94e6d580bdf0a180769a8321f61 Mon Sep 17 00:00:00 2001 From: jpb Date: Mon, 19 Apr 2021 12:22:31 +0200 Subject: [PATCH 074/879] commit git config --- htdocs/multicurrency/multicurrency_rate.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/htdocs/multicurrency/multicurrency_rate.php b/htdocs/multicurrency/multicurrency_rate.php index 0de0d0c458b..5ed206aa8dc 100644 --- a/htdocs/multicurrency/multicurrency_rate.php +++ b/htdocs/multicurrency/multicurrency_rate.php @@ -487,8 +487,6 @@ if ($resql) { // var_dump($obj); $form = new Form($db); print '' . $form->selectDate($obj->date_sync, 'dateinput', 0, 0, 1).''; - - print '' . $form->selectMultiCurrency($obj->code, 'multicurrency_code', 1, " code != '".$conf->currency."'", true) . ''; print ' '; From 2c4e6da36a68f1e6da880585e3dc4ee2535a7d25 Mon Sep 17 00:00:00 2001 From: jpb Date: Mon, 19 Apr 2021 14:02:46 +0200 Subject: [PATCH 075/879] add escape to date --- htdocs/multicurrency/multicurrency_rate.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/multicurrency/multicurrency_rate.php b/htdocs/multicurrency/multicurrency_rate.php index 7445a6ed274..373d2a23304 100644 --- a/htdocs/multicurrency/multicurrency_rate.php +++ b/htdocs/multicurrency/multicurrency_rate.php @@ -299,7 +299,7 @@ $sql .= ' FROM '.MAIN_DB_PREFIX.'multicurrency_rate as cr '; $sql .= " INNER JOIN ".MAIN_DB_PREFIX."multicurrency AS m ON cr.fk_multicurrency = m.rowid"; if ($sall) $sql .= natural_search(array_keys($fieldstosearchall), $sall); if ($search_date_sync && $search_date_sync_end ) { - $sql .= " AND (cr.date_sync BETWEEN '".$db->idate($search_date_sync)."' AND '".$db->idate($search_date_sync_end)."')"; + $sql .= " AND (cr.date_sync BETWEEN '".$db->escape($db->idate($search_date_sync))."' AND '".$db->escape($db->idate($search_date_sync_end))."')"; } elseif ($search_date_sync && !$search_date_sync_end) { $sql .= natural_search('cr.date_sync', $db->idate($search_date_sync)); } From 263e110ca3aebbb74f1430211479335465c23348 Mon Sep 17 00:00:00 2001 From: NextGestion Date: Mon, 19 Apr 2021 13:19:32 +0100 Subject: [PATCH 076/879] 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 31a3c623f436db634dc6e12667c3a040947d9390 Mon Sep 17 00:00:00 2001 From: jpb Date: Mon, 19 Apr 2021 14:24:56 +0200 Subject: [PATCH 077/879] remove ->escape --- htdocs/multicurrency/multicurrency_rate.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/multicurrency/multicurrency_rate.php b/htdocs/multicurrency/multicurrency_rate.php index 373d2a23304..7445a6ed274 100644 --- a/htdocs/multicurrency/multicurrency_rate.php +++ b/htdocs/multicurrency/multicurrency_rate.php @@ -299,7 +299,7 @@ $sql .= ' FROM '.MAIN_DB_PREFIX.'multicurrency_rate as cr '; $sql .= " INNER JOIN ".MAIN_DB_PREFIX."multicurrency AS m ON cr.fk_multicurrency = m.rowid"; if ($sall) $sql .= natural_search(array_keys($fieldstosearchall), $sall); if ($search_date_sync && $search_date_sync_end ) { - $sql .= " AND (cr.date_sync BETWEEN '".$db->escape($db->idate($search_date_sync))."' AND '".$db->escape($db->idate($search_date_sync_end))."')"; + $sql .= " AND (cr.date_sync BETWEEN '".$db->idate($search_date_sync)."' AND '".$db->idate($search_date_sync_end)."')"; } elseif ($search_date_sync && !$search_date_sync_end) { $sql .= natural_search('cr.date_sync', $db->idate($search_date_sync)); } From 6f32b2edda76e1bffd51c47294562a2ae4dbbfc9 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Mon, 19 Apr 2021 13:23:36 +0000 Subject: [PATCH 078/879] 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 079/879] 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 080/879] 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 081/879] 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 082/879] 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 083/879] 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 084/879] 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 085/879] 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 086/879] 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 087/879] 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 088/879] 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 3836481a1e67cb7b6cc3399da6e7a2d9a64fb41e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 19 Apr 2021 21:15:09 +0200 Subject: [PATCH 089/879] Update multicurrency_rate.php --- htdocs/multicurrency/multicurrency_rate.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/multicurrency/multicurrency_rate.php b/htdocs/multicurrency/multicurrency_rate.php index 7445a6ed274..78600c6b327 100644 --- a/htdocs/multicurrency/multicurrency_rate.php +++ b/htdocs/multicurrency/multicurrency_rate.php @@ -530,7 +530,7 @@ if ($resql) { print $hookmanager->resPrint; // Action - print ''; + print ''; if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined $selected = 0; if (in_array($obj->rowid, $arrayofselected)) $selected = 1; From d294bd544d58a4aa6d80671c5a1be7b524576fef Mon Sep 17 00:00:00 2001 From: Anthony Berton <34568357+bb2a@users.noreply.github.com> Date: Mon, 19 Apr 2021 22:42:38 +0200 Subject: [PATCH 090/879] Update list.php --- htdocs/commande/list.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php index 954c0e95a6d..09c8cc3c0b7 100644 --- a/htdocs/commande/list.php +++ b/htdocs/commande/list.php @@ -812,29 +812,29 @@ if ($resql) { // List of mass actions available $arrayofmassactions = array( - 'generate_doc'=>img_picto('', 'pdf').' '.$langs->trans("ReGeneratePDF"), - 'builddoc'=>img_picto('', 'pdf').' '.$langs->trans("PDFMerge"), + 'generate_doc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("ReGeneratePDF"), + 'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"), ); if ($permissiontovalidate) { - $arrayofmassactions['prevalidate'] = img_picto('', 'check').' '.$langs->trans("Validate"); + $arrayofmassactions['prevalidate'] = img_picto('', 'check', 'class="pictofixedwidth"').$langs->trans("Validate"); } if ($permissiontosendbymail) { - $arrayofmassactions['presend'] = img_picto('', 'email').' '.$langs->trans("SendByMail"); + $arrayofmassactions['presend'] = img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"); } if ($permissiontoclose) { - $arrayofmassactions['preshipped'] = img_picto('', 'dollyrevert').' '.$langs->trans("ClassifyShipped"); + $arrayofmassactions['preshipped'] = img_picto('', 'dollyrevert', 'class="pictofixedwidth"').$langs->trans("ClassifyShipped"); } if ($permissiontocancel) { - $arrayofmassactions['cancelorders'] = img_picto('', 'close_title').' '.$langs->trans("Cancel"); + $arrayofmassactions['cancelorders'] = img_picto('', 'close_title', 'class="pictofixedwidth"').$langs->trans("Cancel"); } if ($user->rights->facture->creer) { - $arrayofmassactions['createbills'] = img_picto('', 'bill').' '.$langs->trans("CreateInvoiceForThisCustomer"); + $arrayofmassactions['createbills'] = img_picto('', 'bill', 'class="pictofixedwidth"').$langs->trans("CreateInvoiceForThisCustomer"); } if ($permissiontoclose) { - $arrayofmassactions['setbilled'] = img_picto('', 'bill').' '.$langs->trans("ClassifyBilled"); + $arrayofmassactions['setbilled'] = img_picto('', 'bill', 'class="pictofixedwidth"').$langs->trans("ClassifyBilled"); } if ($permissiontodelete) { - $arrayofmassactions['predelete'] = img_picto('', 'delete').' '.$langs->trans("Delete"); + $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete"); } if (in_array($massaction, array('presend', 'predelete', 'createbills'))) { $arrayofmassactions = array(); From d66540bf001775184275bd2fd966bac8003fa27d Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Tue, 20 Apr 2021 04:42:51 +0200 Subject: [PATCH 091/879] Revert "Split mod fournisseur" This reverts commit 78dbf4f7ffdedb0eaf3b104618cc80536146f4c2. --- htdocs/comm/action/class/cactioncomm.class.php | 4 ++-- htdocs/comm/index.php | 4 ++-- htdocs/compta/accounting-files.php | 2 +- htdocs/compta/index.php | 2 +- htdocs/contact/consumption.php | 4 ++-- htdocs/core/ajax/selectsearchbox.php | 2 +- htdocs/core/lib/product.lib.php | 2 +- htdocs/core/menus/standard/eldy.lib.php | 2 +- 8 files changed, 11 insertions(+), 11 deletions(-) diff --git a/htdocs/comm/action/class/cactioncomm.class.php b/htdocs/comm/action/class/cactioncomm.class.php index 66586cff4a3..8483839b944 100644 --- a/htdocs/comm/action/class/cactioncomm.class.php +++ b/htdocs/comm/action/class/cactioncomm.class.php @@ -201,10 +201,10 @@ class CActionComm if ($obj->module == 'propal' && empty($conf->propal->enabled) && empty($user->propale->lire)) { $qualified = 0; } - if ($obj->module == 'invoice_supplier' && ((!empty($conf->fournisseur->enabled) && empty($user->rights->fournisseur->facture->lire) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || (empty($conf->supplier_invoice->enabled) && empty($user->rights->supplier_invoice->lire)))) { + if ($obj->module == 'invoice_supplier' && ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || empty($conf->supplier_invoice->enabled)) && empty($user->fournisseur->facture->lire)) { $qualified = 0; } - if ($obj->module == 'order_supplier' && ((!empty($conf->fournisseur->enabled) && empty($user->rights->fournisseur->commande->lire) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || (empty($conf->supplier_order->enabled) && empty($user->rights->supplier_order->lire)))) { + if ($obj->module == 'order_supplier' && ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || empty($conf->supplier_order->enabled)) && empty($user->fournisseur->commande->lire)) { $qualified = 0; } if ($obj->module == 'shipping' && empty($conf->expedition->enabled) && empty($user->expedition->lire)) { diff --git a/htdocs/comm/index.php b/htdocs/comm/index.php index 8b763243bf1..a3826fa7dcd 100644 --- a/htdocs/comm/index.php +++ b/htdocs/comm/index.php @@ -588,7 +588,7 @@ if (!empty($conf->societe->enabled) && $user->rights->societe->lire) { /* * Last suppliers */ -if (((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)) && $user->rights->societe->lire) { +if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)) && $user->rights->societe->lire) { $sql = "SELECT s.rowid as socid, s.nom as name, s.name_alias"; $sql .= ", s.code_client, s.code_compta, s.client"; $sql .= ", s.code_fournisseur, s.code_compta_fournisseur, s.fournisseur"; @@ -647,7 +647,7 @@ if (((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_S { $s .= ''.dol_substr($langs->trans("Customer"), 0, 1).''; }*/ - if (((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)) && $obj->fournisseur) { + if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)) && $obj->fournisseur) { $s .= ''.dol_substr($langs->trans("Supplier"), 0, 1).''; } print $s; diff --git a/htdocs/compta/accounting-files.php b/htdocs/compta/accounting-files.php index 9ce9dfb6f8b..68c73c84090 100644 --- a/htdocs/compta/accounting-files.php +++ b/htdocs/compta/accounting-files.php @@ -128,7 +128,7 @@ $error = 0; $listofchoices = array( 'selectinvoices'=>array('label'=>'Invoices', 'lang'=>'bills', 'enabled' => !empty($conf->facture->enabled), 'perms' => !empty($user->rights->facture->lire)), - 'selectsupplierinvoices'=>array('label'=>'BillsSuppliers', 'lang'=>'bills', 'enabled' => !empty($conf->supplier_invoice->enabled), 'perms' => (!empty($user->rights->fournisseur->facture->lire) || !empty($user->rights->supplier_invoice->lire)), + 'selectsupplierinvoices'=>array('label'=>'BillsSuppliers', 'lang'=>'bills', 'enabled' => !empty($conf->supplier_invoice->enabled), 'perms' => !empty($user->rights->fournisseur->facture->lire)), 'selectexpensereports'=>array('label'=>'ExpenseReports', 'lang'=>'trips', 'enabled' => !empty($conf->expensereport->enabled), 'perms' => !empty($user->rights->expensereport->lire)), 'selectdonations'=>array('label'=>'Donations', 'lang'=>'donation', 'enabled' => !empty($conf->don->enabled), 'perms' => !empty($user->rights->don->lire)), 'selectsocialcontributions'=>array('label'=>'SocialContributions', 'enabled' => !empty($conf->tax->enabled), 'perms' => !empty($user->rights->tax->charges->lire)), diff --git a/htdocs/compta/index.php b/htdocs/compta/index.php index e208fce3539..4d46f04a136 100644 --- a/htdocs/compta/index.php +++ b/htdocs/compta/index.php @@ -258,7 +258,7 @@ if (!empty($conf->facture->enabled) && !empty($user->rights->facture->lire)) { // Last modified supplier invoices -if (((!empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture->lire && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || (!empty($conf->supplier_invoice->enabled) && $user->rights->supplier_invoice->lire))) { +if (((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !empty($conf->supplier_invoice->enabled)) && $user->rights->fournisseur->facture->lire) { $langs->load("boxes"); $facstatic = new FactureFournisseur($db); diff --git a/htdocs/contact/consumption.php b/htdocs/contact/consumption.php index f421d287299..b87a73e8cc2 100644 --- a/htdocs/contact/consumption.php +++ b/htdocs/contact/consumption.php @@ -167,10 +167,10 @@ if ($conf->ficheinter->enabled && $user->rights->ficheinter->lire) { if ($object->thirdparty->fournisseur) { $thirdTypeArray['supplier'] = $langs->trans("supplier"); - if ((!empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture->lire && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || (!empty($conf->supplier_invoice->enabled) && $user->rights->supplier_invoice->lire)) { + if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_invoice->enabled)) && $user->rights->fournisseur->facture->lire) { $elementTypeArray['supplier_invoice'] = $langs->transnoentitiesnoconv('SuppliersInvoices'); } - if ((!empty($conf->fournisseur->enabled) && $user->rights->fournisseur->commande->lire && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || (!empty($conf->supplier_order->enabled) && $user->rights->supplier_order->lire)) { + if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled)) && $user->rights->fournisseur->commande->lire) { $elementTypeArray['supplier_order'] = $langs->transnoentitiesnoconv('SuppliersOrders'); } diff --git a/htdocs/core/ajax/selectsearchbox.php b/htdocs/core/ajax/selectsearchbox.php index 5d81f4b250d..d10324ef620 100644 --- a/htdocs/core/ajax/selectsearchbox.php +++ b/htdocs/core/ajax/selectsearchbox.php @@ -115,7 +115,7 @@ if (!empty($conf->supplier_proposal->enabled) && empty($conf->global->MAIN_SEARC if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_SEARCHFORM_SUPPLIER_ORDER_DISABLED) || !empty($conf->supplier_order->enabled)) && $user->rights->fournisseur->commande->lire) { $arrayresult['searchintosupplierorder'] = array('position'=>110, 'img'=>'object_order', 'label'=>$langs->trans("SearchIntoSupplierOrders", $search_boxvalue), 'text'=>img_picto('', 'object_supplier_order').' '.$langs->trans("SearchIntoSupplierOrders", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/fourn/commande/list.php'.($search_boxvalue ? '?search_all='.urlencode($search_boxvalue) : '')); } -if ((!empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture->lire && empty($conf->global->MAIN_SEARCHFORM_SUPPLIER_INVOICE_DISABLED)) || (!empty($conf->supplier_invoice->enabled) && $user->rights->fournisseur->facture->lire)) { +if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_SEARCHFORM_SUPPLIER_INVOICE_DISABLED) || !empty($conf->supplier_invoice->enabled)) && $user->rights->fournisseur->facture->lire) { $arrayresult['searchintosupplierinvoice'] = array('position'=>120, 'img'=>'object_bill', 'label'=>$langs->trans("SearchIntoSupplierInvoices", $search_boxvalue), 'text'=>img_picto('', 'object_supplier_invoice').' '.$langs->trans("SearchIntoSupplierInvoices", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/fourn/facture/list.php'.($search_boxvalue ? '?sall='.urlencode($search_boxvalue) : '')); } diff --git a/htdocs/core/lib/product.lib.php b/htdocs/core/lib/product.lib.php index d054c8d5569..e8ce515317f 100644 --- a/htdocs/core/lib/product.lib.php +++ b/htdocs/core/lib/product.lib.php @@ -58,7 +58,7 @@ function product_prepare_head($object) } if (!empty($object->status_buy) || (!empty($conf->margin->enabled) && !empty($object->status))) { // If margin is on and product on sell, we may need the cost price even if product os not on purchase - if ((((!empty($conf->fournisseur->enabled) && $user->rights->fournisseur->lire && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || (!empty($conf->supplier_order->enabled) && $user->rights->supplier_order->lire) || (!empty($conf->supplier_invoice->enabled) && $user->rights->supplier_invoice->lire))) + if (((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)) && $user->rights->fournisseur->lire) || (!empty($conf->margin->enabled) && $user->rights->margin->liretous) ) { $head[$h][0] = DOL_URL_ROOT."/product/fournisseurs.php?id=".$object->id; diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index 5e63dc4d081..7e815523283 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -281,7 +281,7 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout = ) ? 1 : 0, 'perms'=>(!empty($user->rights->facture->lire) || !empty($user->rights->don->contact->lire) || !empty($user->rights->tax->charges->lire) || !empty($user->rights->salaries->read) - || !empty($user->rights->fournisseur->facture->lire) || !empty($user->rights->supplier_invoice->lire) || !empty($user->rights->loan->read) || !empty($user->rights->margins->liretous)), + || !empty($user->rights->fournisseur->facture->lire) || !empty($user->rights->loan->read) || !empty($user->rights->margins->liretous)), 'module'=>'facture|supplier_invoice|don|tax|salaries|loan' ); $menu_arr[] = array( From f82d1d246d303904abed30b1c1067f9f1bce85e7 Mon Sep 17 00:00:00 2001 From: Dorian Vabre Date: Tue, 20 Apr 2021 09:45:32 +0200 Subject: [PATCH 092/879] 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 81907191ca3e75f57d029966b46136b4c477b16c Mon Sep 17 00:00:00 2001 From: altairis-noe Date: Tue, 20 Apr 2021 10:17:08 +0200 Subject: [PATCH 093/879] product card typo --- htdocs/product/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/product/card.php b/htdocs/product/card.php index 094ce8670a9..66f4b66aa75 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -894,7 +894,7 @@ if (empty($reshook)) { $result = $facture->addline( $desc, $pu_ht, - price2nm(GETPOST('qty'), 'MS'), + price2num(GETPOST('qty'), 'MS'), $tva_tx, $localtax1_tx, $localtax2_tx, From 7405813ad0df90922de51586627cd4c3a25b57e8 Mon Sep 17 00:00:00 2001 From: Dorian Vabre Date: Tue, 20 Apr 2021 10:24:36 +0200 Subject: [PATCH 094/879] 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 095/879] 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 096/879] 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 097/879] 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 53a89180d910e9fdfedb95eda2653c75b183558c Mon Sep 17 00:00:00 2001 From: UT from dolibit <45215329+dolibit-ut@users.noreply.github.com> Date: Tue, 20 Apr 2021 11:22:12 +0200 Subject: [PATCH 098/879] Update element.php merging by - if (!empty($conf->facture->enabled)) - if (!empty($conf->loan->enabled)) --- htdocs/projet/element.php | 4 ---- 1 file changed, 4 deletions(-) diff --git a/htdocs/projet/element.php b/htdocs/projet/element.php index 95c348a7e09..a6e3af11979 100644 --- a/htdocs/projet/element.php +++ b/htdocs/projet/element.php @@ -41,8 +41,6 @@ if (!empty($conf->propal->enabled)) { } if (!empty($conf->facture->enabled)) { require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; -} -if (!empty($conf->facture->enabled)) { require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture-rec.class.php'; } if (!empty($conf->commande->enabled)) { @@ -80,8 +78,6 @@ if (!empty($conf->don->enabled)) { } if (!empty($conf->loan->enabled)) { require_once DOL_DOCUMENT_ROOT.'/loan/class/loan.class.php'; -} -if (!empty($conf->loan->enabled)) { require_once DOL_DOCUMENT_ROOT.'/loan/class/loanschedule.class.php'; } if (!empty($conf->stock->enabled)) { From 3a1f70fe348082167469209bc8b8d2cad2fb3fb7 Mon Sep 17 00:00:00 2001 From: UT from dolibit <45215329+dolibit-ut@users.noreply.github.com> Date: Tue, 20 Apr 2021 11:31:45 +0200 Subject: [PATCH 099/879] Update bom_agenda.php MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit $help_url = 'EN:Module_Agenda_En|FR:Module_Agenda|ES:Módulo_Agenda'; --- htdocs/bom/bom_agenda.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/bom/bom_agenda.php b/htdocs/bom/bom_agenda.php index dc3421dea0c..0f18c39d2af 100644 --- a/htdocs/bom/bom_agenda.php +++ b/htdocs/bom/bom_agenda.php @@ -126,7 +126,7 @@ $form = new Form($db); if ($object->id > 0) { $title = $langs->trans("Agenda"); //if (! empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/',$conf->global->MAIN_HTML_TITLE) && $object->name) $title=$object->name." - ".$title; - $help_url = ''; + $help_url = 'EN:Module_Agenda_En|FR:Module_Agenda|ES:Módulo_Agenda'; llxHeader('', $title, $help_url); if (!empty($conf->notification->enabled)) { From cce6224c910740941f2e5ee74820100d33675c74 Mon Sep 17 00:00:00 2001 From: UT from dolibit <45215329+dolibit-ut@users.noreply.github.com> Date: Tue, 20 Apr 2021 11:33:47 +0200 Subject: [PATCH 100/879] Update bom_card.php $help_url ='EN:Module_BOM'; llxHeader('', $title, $help_url); --- htdocs/bom/bom_card.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/bom/bom_card.php b/htdocs/bom/bom_card.php index 37ec67e1ba3..ae35eae14f4 100644 --- a/htdocs/bom/bom_card.php +++ b/htdocs/bom/bom_card.php @@ -241,8 +241,8 @@ $formfile = new FormFile($db); $title = $langs->trans('BOM'); - -llxHeader('', $title, ''); +$help_url ='EN:Module_BOM'; +llxHeader('', $title, $help_url); // Example : Adding jquery code 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 a28402e3a0704e2c313434b0a63734927b7a7c24 Mon Sep 17 00:00:00 2001 From: antonin_tdj <50403308+ibuiv@users.noreply.github.com> Date: Fri, 23 Apr 2021 18:03:16 +0200 Subject: [PATCH 168/879] Product Stock Card - add new standard Hooks --- htdocs/product/stock/card.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/htdocs/product/stock/card.php b/htdocs/product/stock/card.php index 0a77a39a0df..0cd30ed827a 100644 --- a/htdocs/product/stock/card.php +++ b/htdocs/product/stock/card.php @@ -571,6 +571,9 @@ if ($action == 'create') { print '

'.$text.'

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

'.$project->note_public.'


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

'.$project->note_public.'

'; print ""; + $parameters = array(); + $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; print_liste_field_titre("Product", "", "p.ref", "&id=".$id, "", "", $sortfield, $sortorder); print_liste_field_titre("Label", "", "p.label", "&id=".$id, "", "", $sortfield, $sortorder); print_liste_field_titre("NumberOfUnit", "", "ps.reel", "&id=".$id, "", '', $sortfield, $sortorder, 'right '); @@ -591,6 +594,10 @@ if ($action == 'create') { if ($user->rights->stock->creer) { print_liste_field_titre(''); } + // Hook fields + $parameters = array('sortfield'=>$sortfield, 'sortorder'=>$sortorder); + $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; print "\n"; $totalunit = 0; @@ -601,6 +608,13 @@ if ($action == 'create') { if (!empty($conf->global->PRODUCT_USE_UNITS)) { $sql .= ",fk_unit"; } + // Add fields from hooks + $parameters = array(); + $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook + if($reshook > 0){ //Note that $sql is replaced if reshook > 0 + $sql = ""; + } + $sql .= $hookmanager->resPrint; $sql .= " FROM ".MAIN_DB_PREFIX."product_stock as ps, ".MAIN_DB_PREFIX."product as p"; $sql .= " WHERE ps.fk_product = p.rowid"; $sql .= " AND ps.reel <> 0"; // We do not show if stock is 0 (no product in this warehouse) @@ -635,6 +649,9 @@ if ($action == 'create') { //print ''; print ''; + $parameters = array('obj'=>$objp); + $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; print "\n"; + print '\n"; if (!$i) { $totalarray['nbfield']++; } diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php index 13c2bdba4ce..4e2e60908d8 100644 --- a/htdocs/compta/bank/class/account.class.php +++ b/htdocs/compta/bank/class/account.class.php @@ -509,9 +509,9 @@ class Account extends CommonObject } // Clean parameters - $label = $emetteur = trim($emetteur); $banque = trim($banque); + $label = trim($label); $now = dol_now(); diff --git a/htdocs/compta/bank/class/api_bankaccounts.class.php b/htdocs/compta/bank/class/api_bankaccounts.class.php index 04ef9543867..0f13ed1e523 100644 --- a/htdocs/compta/bank/class/api_bankaccounts.class.php +++ b/htdocs/compta/bank/class/api_bankaccounts.class.php @@ -249,6 +249,10 @@ class BankAccounts extends DolibarrApi $typeto = 'LIQ'; } + // Clean data + $description = checkVal($description, 'alphanohtml'); + + /** * Creating bank line records */ @@ -295,7 +299,9 @@ class BankAccounts extends DolibarrApi return array( 'success' => array( 'code' => 201, - 'message' => 'Internal wire transfer created successfully.' + 'message' => 'Internal wire transfer created successfully.', + 'bank_id_from' => $bank_line_id_from, + 'bank_id_to' => $bank_line_id_to, ) ); } else { diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 7368510484f..cb48ac4d45d 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -686,11 +686,11 @@ function GETPOSTINT($paramname, $method = 0, $filter = null, $options = null, $n /** * Return a value after checking on a rule. * - * @param string $out Value to get/check - * @param string $check Type of check + * @param string $out Value to check/clear. + * @param string $check Type of check/sanitizing * @param int $filter Filter to apply when $check is set to 'custom'. (See http://php.net/manual/en/filter.filters.php for détails) * @param mixed $options Options to pass to filter_var when $check is set to 'custom' - * @return string|array Value found (string or array), or '' if check fails + * @return string|array Value sanitized (string or array). It may be '' if format check fails. */ function checkVal($out = '', $check = 'alphanohtml', $filter = null, $options = null) { From b2c2c552141d76b4d82ea67cc179dc81ac070ea0 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 24 Apr 2021 21:00:26 +0200 Subject: [PATCH 177/879] Fix #yogosha5877 --- htdocs/product/class/api_products.class.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/htdocs/product/class/api_products.class.php b/htdocs/product/class/api_products.class.php index 6b26421d0f8..9b06b30765d 100644 --- a/htdocs/product/class/api_products.class.php +++ b/htdocs/product/class/api_products.class.php @@ -721,6 +721,11 @@ class Products extends DolibarrApi throw new RestException(404, 'Supplier not found'); } + // Clean data + $ref_fourn = checkVal($ref_fourn, 'alphanohtml'); + $desc_fourn = checkVal($desc_fourn, 'restricthtml'); + $barcode = checkVal($barcode, 'alphanohtml'); + $result = $this->productsupplier->update_buyprice($qty, $buyprice, DolibarrApiAccess::$user, $price_base_type, $fourn, $availability, $ref_fourn, $tva_tx, $charges, $remise_percent, $remise, $newnpr, $delivery_time_days, $supplier_reputation, $localtaxes_array, $newdefaultvatcode, $multicurrency_buyprice, $multicurrency_price_base_type, $multicurrency_tx, $multicurrency_code, $desc_fourn, $barcode, $fk_barcode_type); if ($result <= 0) { From ac68599fab8c79acbdaac5c3cb255ec904c8c2c7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 24 Apr 2021 21:02:48 +0200 Subject: [PATCH 178/879] Fix #yogosha5877 --- .../modulebuilder/template/class/api_mymodule.class.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/htdocs/modulebuilder/template/class/api_mymodule.class.php b/htdocs/modulebuilder/template/class/api_mymodule.class.php index da616de0d82..47a3ac984f9 100644 --- a/htdocs/modulebuilder/template/class/api_mymodule.class.php +++ b/htdocs/modulebuilder/template/class/api_mymodule.class.php @@ -208,12 +208,17 @@ class MyModuleApi extends DolibarrApi if (!DolibarrApiAccess::$user->rights->mymodule->write) { throw new RestException(401); } + // Check mandatory fields $result = $this->_validate($request_data); foreach ($request_data as $field => $value) { $this->myobject->$field = $value; } + + // Clean data + // $this->myobject->abc = checkVal($this->myobject->abc, 'alphanohtml'); + if ($this->myobject->create(DolibarrApiAccess::$user)<0) { throw new RestException(500, "Error creating MyObject", array_merge(array($this->myobject->error), $this->myobject->errors)); } @@ -253,6 +258,9 @@ class MyModuleApi extends DolibarrApi $this->myobject->$field = $value; } + // Clean data + // $this->myobject->abc = checkVal($this->myobject->abc, 'alphanohtml'); + if ($this->myobject->update(DolibarrApiAccess::$user, false) > 0) { return $this->get($id); } else { From 42938ffe31da85c013dc7e8598b5f913736f2393 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 24 Apr 2021 21:15:09 +0200 Subject: [PATCH 179/879] FIX #yogosha5879 --- .../accountancy/class/bookkeeping.class.php | 8 +++--- htdocs/adherents/class/subscription.class.php | 2 +- htdocs/admin/boxes.php | 4 +-- htdocs/compta/bank/class/account.class.php | 26 +++++++++++-------- .../cheque/class/remisecheque.class.php | 2 +- .../class/bonprelevement.class.php | 4 +-- htdocs/compta/tva/class/tva.class.php | 2 +- 7 files changed, 26 insertions(+), 22 deletions(-) diff --git a/htdocs/accountancy/class/bookkeeping.class.php b/htdocs/accountancy/class/bookkeeping.class.php index 00ed8879076..a93b36cf2b4 100644 --- a/htdocs/accountancy/class/bookkeeping.class.php +++ b/htdocs/accountancy/class/bookkeeping.class.php @@ -371,8 +371,8 @@ class BookKeeping extends CommonObject $sql .= ", ".(!isset($this->date_lim_reglement) || dol_strlen($this->date_lim_reglement) == 0 ? 'NULL' : "'".$this->db->idate($this->date_lim_reglement)."'"); $sql .= ", '".$this->db->escape($this->doc_type)."'"; $sql .= ", '".$this->db->escape($this->doc_ref)."'"; - $sql .= ", ".$this->fk_doc; - $sql .= ", ".$this->fk_docdet; + $sql .= ", ".((int) $this->fk_doc); + $sql .= ", ".((int) $this->fk_docdet); $sql .= ", ".(!empty($this->thirdparty_code) ? ("'".$this->db->escape($this->thirdparty_code)."'") : "NULL"); $sql .= ", ".(!empty($this->subledger_account) ? ("'".$this->db->escape($this->subledger_account)."'") : "NULL"); $sql .= ", ".(!empty($this->subledger_label) ? ("'".$this->db->escape($this->subledger_label)."'") : "NULL"); @@ -632,8 +632,8 @@ class BookKeeping extends CommonObject $sql .= ' '.(!isset($this->date_lim_reglement) || dol_strlen($this->date_lim_reglement) == 0 ? 'NULL' : "'".$this->db->idate($this->date_lim_reglement)."'").','; $sql .= ' '.(!isset($this->doc_type) ? 'NULL' : "'".$this->db->escape($this->doc_type)."'").','; $sql .= ' '.(!isset($this->doc_ref) ? 'NULL' : "'".$this->db->escape($this->doc_ref)."'").','; - $sql .= ' '.(empty($this->fk_doc) ? '0' : $this->fk_doc).','; - $sql .= ' '.(empty($this->fk_docdet) ? '0' : $this->fk_docdet).','; + $sql .= ' '.(empty($this->fk_doc) ? '0' : (int) $this->fk_doc).','; + $sql .= ' '.(empty($this->fk_docdet) ? '0' : (int) $this->fk_docdet).','; $sql .= ' '.(!isset($this->thirdparty_code) ? 'NULL' : "'".$this->db->escape($this->thirdparty_code)."'").','; $sql .= ' '.(!isset($this->subledger_account) ? 'NULL' : "'".$this->db->escape($this->subledger_account)."'").','; $sql .= ' '.(!isset($this->subledger_label) ? 'NULL' : "'".$this->db->escape($this->subledger_label)."'").','; diff --git a/htdocs/adherents/class/subscription.class.php b/htdocs/adherents/class/subscription.class.php index 95bbe79804f..1285b12b2d0 100644 --- a/htdocs/adherents/class/subscription.class.php +++ b/htdocs/adherents/class/subscription.class.php @@ -165,7 +165,7 @@ class Subscription extends CommonObject } else { $type = $this->fk_type; } - $sql .= " VALUES (".$this->fk_adherent.", '".$this->db->escape($type)."', '".$this->db->idate($now)."',"; + $sql .= " VALUES (".((int) $this->fk_adherent).", '".$this->db->escape($type)."', '".$this->db->idate($now)."',"; $sql .= " '".$this->db->idate($this->dateh)."',"; $sql .= " '".$this->db->idate($this->datef)."',"; $sql .= " ".$this->amount.","; diff --git a/htdocs/admin/boxes.php b/htdocs/admin/boxes.php index fc3e30a484b..44629525a26 100644 --- a/htdocs/admin/boxes.php +++ b/htdocs/admin/boxes.php @@ -114,8 +114,8 @@ if ($action == 'add') { if (empty($arrayofexistingboxid[$boxid['value']])) { $sql = "INSERT INTO ".MAIN_DB_PREFIX."boxes ("; $sql .= "box_id, position, box_order, fk_user, entity"; - $sql .= ") values ("; - $sql .= $boxid['value'].", ".$pos.", '".(($nbboxonleft > $nbboxonright) ? 'B01' : 'A01')."', ".$fk_user.", ".$conf->entity; + $sql .= ") VALUES ("; + $sql .= $boxid['value'].", ".((int) $pos).", '".(($nbboxonleft > $nbboxonright) ? 'B01' : 'A01')."', ".$fk_user.", ".$conf->entity; $sql .= ")"; dol_syslog("boxes.php activate box", LOG_DEBUG); diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php index 4e2e60908d8..5a00e93e83f 100644 --- a/htdocs/compta/bank/class/account.class.php +++ b/htdocs/compta/bank/class/account.class.php @@ -508,6 +508,10 @@ class Account extends CommonObject dol_syslog(__METHOD__.": using numeric operations is deprecated", LOG_WARNING); } + if (empty($this->id) && !empty($this->rowid)) { // For backward compatibility + $this->id = $this->rowid; + } + // Clean parameters $emetteur = trim($emetteur); $banque = trim($banque); @@ -534,8 +538,8 @@ class Account extends CommonObject $this->error = "oper not defined"; return -1; } - if (!$this->rowid) { - $this->error = "this->rowid not defined"; + if (!$this->id) { + $this->error = "this->id not defined"; return -2; } if ($this->courant == Account::TYPE_CASH && $oper != 'LIQ') { @@ -556,7 +560,7 @@ class Account extends CommonObject $accline->label = $label; $accline->amount = $amount; $accline->fk_user_author = $user->id; - $accline->fk_account = $this->rowid; + $accline->fk_account = $this->id; $accline->fk_type = $oper; $accline->numero_compte = $accountancycode; $accline->num_releve = $num_releve; @@ -575,10 +579,10 @@ class Account extends CommonObject if ($accline->insert() > 0) { if ($categorie > 0) { - $sql = "INSERT INTO ".MAIN_DB_PREFIX."bank_class ("; + $sql = "INSERT INTO ".MAIN_DB_PREFIX."bank_class("; $sql .= "lineid, fk_categ"; $sql .= ") VALUES ("; - $sql .= $accline->id.", ".$categorie; + $sql .= ((int) $accline->id).", '".$this->db->escape($categorie)."'"; $sql .= ")"; $result = $this->db->query($sql); @@ -611,7 +615,7 @@ class Account extends CommonObject */ public function create(User $user, $notrigger = 0) { - global $langs, $conf, $hookmanager; + global $langs, $conf; $error = 0; @@ -770,7 +774,7 @@ class Account extends CommonObject */ public function update(User $user, $notrigger = 0) { - global $langs, $conf, $hookmanager; + global $langs, $conf; $error = 0; @@ -796,9 +800,9 @@ class Account extends CommonObject $sql .= " ref = '".$this->db->escape($this->ref)."'"; $sql .= ",label = '".$this->db->escape($this->label)."'"; - $sql .= ",courant = ".$this->courant; - $sql .= ",clos = ".$this->clos; - $sql .= ",rappro = ".$this->rappro; + $sql .= ",courant = ".((int) $this->courant); + $sql .= ",clos = ".((int) $this->clos); + $sql .= ",rappro = ".((int) $this->rappro); $sql .= ",url = ".($this->url ? "'".$this->db->escape($this->url)."'" : "null"); $sql .= ",account_number = '".$this->db->escape($this->account_number)."'"; $sql .= ",fk_accountancy_journal = ".($this->fk_accountancy_journal > 0 ? $this->db->escape($this->fk_accountancy_journal) : "null"); @@ -824,7 +828,7 @@ class Account extends CommonObject $sql .= ",ics = '".$this->db->escape($this->ics)."'"; $sql .= ",ics_transfer = '".$this->db->escape($this->ics_transfer)."'"; - $sql .= " WHERE rowid = ".$this->id; + $sql .= " WHERE rowid = ".((int) $this->id); dol_syslog(get_class($this)."::update", LOG_DEBUG); $result = $this->db->query($sql); diff --git a/htdocs/compta/paiement/cheque/class/remisecheque.class.php b/htdocs/compta/paiement/cheque/class/remisecheque.class.php index 489d4c7cec0..0c05a1bc03a 100644 --- a/htdocs/compta/paiement/cheque/class/remisecheque.class.php +++ b/htdocs/compta/paiement/cheque/class/remisecheque.class.php @@ -171,7 +171,7 @@ class RemiseCheque extends CommonObject $sql .= "'".$this->db->idate($now)."'"; $sql .= ", '".$this->db->idate($now)."'"; $sql .= ", ".$user->id; - $sql .= ", ".$account_id; + $sql .= ", ".((int) $account_id); $sql .= ", 0"; $sql .= ", 0"; $sql .= ", 0"; diff --git a/htdocs/compta/prelevement/class/bonprelevement.class.php b/htdocs/compta/prelevement/class/bonprelevement.class.php index ea44a75899d..dbf2d67778a 100644 --- a/htdocs/compta/prelevement/class/bonprelevement.class.php +++ b/htdocs/compta/prelevement/class/bonprelevement.class.php @@ -229,9 +229,9 @@ class BonPrelevement extends CommonObject $sql .= ", cle_rib"; $sql .= ") VALUES ("; $sql .= $this->id; - $sql .= ", ".$client_id; + $sql .= ", ".((int) $client_id); $sql .= ", '".$this->db->escape($client_nom)."'"; - $sql .= ", '".price2num($amount)."'"; + $sql .= ", ".((float) price2num($amount)); $sql .= ", '".$this->db->escape($code_banque)."'"; $sql .= ", '".$this->db->escape($code_guichet)."'"; $sql .= ", '".$this->db->escape($number)."'"; diff --git a/htdocs/compta/tva/class/tva.class.php b/htdocs/compta/tva/class/tva.class.php index 25d622d825d..ff35ece947b 100644 --- a/htdocs/compta/tva/class/tva.class.php +++ b/htdocs/compta/tva/class/tva.class.php @@ -585,7 +585,7 @@ class Tva extends CommonObject $sql .= " '".$this->db->idate($this->datec)."'"; $sql .= ", '".$this->db->idate($this->datep)."'"; $sql .= ", '".$this->db->idate($this->datev)."'"; - $sql .= ", ".$this->amount; + $sql .= ", ".((float) $this->amount); $sql .= ", '".$this->db->escape($this->type_payment)."'"; $sql .= ", '".$this->db->escape($this->num_payment)."'"; if ($this->note) { From 6c2d9d3b3c4d5cd00dd42750534d70257af4de3d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 25 Apr 2021 13:17:47 +0200 Subject: [PATCH 180/879] Fix permission to reopen invoice. --- htdocs/compta/facture/card.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index b9a3ae86811..60e5d4eb52a 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -119,8 +119,11 @@ $usercancreate = $user->rights->facture->creer; $usercanissuepayment = $user->rights->facture->paiement; $usercandelete = $user->rights->facture->supprimer; $usercanvalidate = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $usercancreate) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->facture->invoice_advance->validate))); -$usercansend = (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->rights->facture->invoice_advance->send); -$usercanreopen = (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->rights->facture->invoice_advance->reopen); +$usercansend = (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->facture->invoice_advance->send))); +$usercanreopen = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $usercancreate) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->facture->invoice_advance->reopen))); +if (!empty($conf->global->INVOICE_DISALLOW_REOPEN)) { + $usercanreopen = false; +} $usercanunvalidate = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($usercancreate)) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->facture->invoice_advance->unvalidate))); $usercanproductignorepricemin = ((!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->produit->ignore_price_min_advance)) || empty($conf->global->MAIN_USE_ADVANCED_PERMS)); @@ -189,7 +192,7 @@ if (empty($reshook)) $action = ''; } } // Change status of invoice - elseif ($action == 'reopen' && $usercancreate && empty($conf->global->INVOICE_DISALLOW_REOPEN)) { + elseif ($action == 'reopen' && $usercanreopen) { $result = $object->fetch($id); if ($object->statut == Facture::STATUS_CLOSED || ($object->statut == Facture::STATUS_ABANDONED && ($object->close_code != 'replaced' || $object->getIdReplacingInvoice() == 0)) || ($object->statut == Facture::STATUS_VALIDATED && $object->paye == 1)) { // ($object->statut == 1 && $object->paye == 1) should not happened but can be found when data are corrupted From 474bfdd6bc66a7042766d732ce02817aa597a403 Mon Sep 17 00:00:00 2001 From: kastoras Date: Sun, 25 Apr 2021 16:20:17 +0300 Subject: [PATCH 181/879] Close/CLOSE #17390 Products API, GET /products without variants When accessing get /products, using $without_variants parameter to true (the deault value is false), the api retur only products and no variants. --- htdocs/product/class/api_products.class.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/htdocs/product/class/api_products.class.php b/htdocs/product/class/api_products.class.php index 9b06b30765d..c3f5c4f5551 100644 --- a/htdocs/product/class/api_products.class.php +++ b/htdocs/product/class/api_products.class.php @@ -166,9 +166,10 @@ class Products extends DolibarrApi * @param int $category Use this param to filter list by category * @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 bool $without_variants Return only products, not variants * @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) + public function index($sortfield = "t.ref", $sortorder = 'ASC', $limit = 100, $page = 0, $mode = 0, $category = 0, $sqlfilters = '', $ids_only = false, $without_variants = false) { global $db, $conf; @@ -186,6 +187,11 @@ class Products extends DolibarrApi $sql .= ", ".MAIN_DB_PREFIX."categorie_product as c"; } $sql .= ' WHERE t.entity IN ('.getEntity('product').')'; + + if($without_variants){ + $sql .= ' AND t.rowid in (select distinct fk_product_parent from '.MAIN_DB_PREFIX.'product_attribute_combination)'; + } + // Select products of given category if ($category > 0) { $sql .= " AND c.fk_categorie = ".$this->db->escape($category); From 2fd2c671391d9b5a423063f3707266013b819d9b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 25 Apr 2021 15:09:56 +0200 Subject: [PATCH 182/879] Clean edit of user card --- htdocs/core/class/html.formcompany.class.php | 4 +- htdocs/core/lib/ajax.lib.php | 6 +- htdocs/langs/en_US/main.lang | 4 +- htdocs/langs/en_US/users.lang | 3 +- htdocs/theme/eldy/global.inc.php | 3 + htdocs/theme/md/style.css.php | 3 + htdocs/user/card.php | 447 ++++++++++--------- 7 files changed, 253 insertions(+), 217 deletions(-) diff --git a/htdocs/core/class/html.formcompany.class.php b/htdocs/core/class/html.formcompany.class.php index 6677f7f8dce..48f46860717 100644 --- a/htdocs/core/class/html.formcompany.class.php +++ b/htdocs/core/class/html.formcompany.class.php @@ -312,9 +312,9 @@ class FormCompany extends Form $out .= ''; } else { if (!$country || $country != $obj->country) { - // Affiche la rupture si on est en mode liste multipays + // Show break if we are in list with multiple countries if (!$country_codeid && $obj->country_code) { - $out .= '\n"; + $out .= '\n"; $country = $obj->country; } } diff --git a/htdocs/core/lib/ajax.lib.php b/htdocs/core/lib/ajax.lib.php index 4108724236d..8874b96eda5 100644 --- a/htdocs/core/lib/ajax.lib.php +++ b/htdocs/core/lib/ajax.lib.php @@ -454,8 +454,10 @@ function ajax_combobox($htmlname, $events = array(), $minLengthToAutocomplete = templateResult: function (data, container) { /* Format visible output into combo list */ /* Code to add class of origin OPTION propagated to the new select2
  • tag */ if (data.element) { $(container).addClass($(data.element).attr("class")); } - //console.log(data.html); - if (data.id == -1) return \' \'; + console.log($(data.element).attr("data-html")); + if (data.id == -1 && $(data.element).attr("data-html") == undefined) { + return \' \'; + } if ($(data.element).attr("data-html") != undefined) return htmlEntityDecodeJs($(data.element).attr("data-html")); // If property html set, we decode html entities and use this return data.text; }, diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index dc2a83f2015..8fea1ffd839 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -503,9 +503,11 @@ By=By From=From FromDate=From FromLocation=From -at=at to=to To=to +ToDate=to +ToLocation=to +at=at and=and or=or Other=Other diff --git a/htdocs/langs/en_US/users.lang b/htdocs/langs/en_US/users.lang index 727773a9606..d84257b69ad 100644 --- a/htdocs/langs/en_US/users.lang +++ b/htdocs/langs/en_US/users.lang @@ -12,6 +12,7 @@ PasswordChangedTo=Password changed to: %s SubjectNewPassword=Your new password for %s GroupRights=Group permissions UserRights=User permissions +Credentials=Credentials UserGUISetup=User Display Setup DisableUser=Disable DisableAUser=Disable a user @@ -115,7 +116,7 @@ DateOfEmployment=Employment date DateEmployment=Employment DateEmploymentstart=Employment Start Date DateEmploymentEnd=Employment End Date -RangeOfLoginValidity=Date range of login validity +RangeOfLoginValidity=Access validity date range CantDisableYourself=You can't disable your own user record ForceUserExpenseValidator=Force expense report validator ForceUserHolidayValidator=Force leave request validator diff --git a/htdocs/theme/eldy/global.inc.php b/htdocs/theme/eldy/global.inc.php index 12d9677c4b5..3622d77de2f 100644 --- a/htdocs/theme/eldy/global.inc.php +++ b/htdocs/theme/eldy/global.inc.php @@ -1354,6 +1354,9 @@ table[summary="list_of_modules"] .fa-cog { .width125 { width: 125px; } .width150 { width: 150px; } .width200 { width: 200px; } +.width300 { width: 300px; } +.width400 { width: 400px; } +.width500 { width: 500px; } .maxwidth25 { max-width: 25px; } .maxwidth50 { max-width: 50px; } .maxwidth75 { max-width: 75px; } diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index 87a9d6b1b47..7b49acc63b5 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -1390,6 +1390,9 @@ table[summary="list_of_modules"] .fa-cog { .width125 { width: 125px; } .width150 { width: 150px; } .width200 { width: 200px; } +.width300 { width: 300px; } +.width400 { width: 400px; } +.width500 { width: 500px; } .maxwidth25 { max-width: 25px; } .maxwidth50 { max-width: 50px; } .maxwidth75 { max-width: 75px; } diff --git a/htdocs/user/card.php b/htdocs/user/card.php index 57d5c44615f..9d2039a4678 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -839,54 +839,6 @@ if ($action == 'create' || $action == 'adduserldap') { } $password = (GETPOSTISSET('password') ?GETPOST('password') : $generated_password); - // Password - print '
  • '; - print ''; - - if (!empty($conf->api->enabled)) { - // API key - //$generated_password = getRandomPassword(false); - print ''; - print ''; - } else { - // PARTIAL WORKAROUND - $generated_fake_api_key = getRandomPassword(false); - print ''; - } - // Administrator if (!empty($user->admin)) { print ''; @@ -936,10 +888,11 @@ if ($action == 'create' || $action == 'adduserldap') { print ''; // Employee - $defaultemployee = 1; + $defaultemployee = '1'; print ''; print ''; // Hierarchy @@ -979,6 +932,70 @@ if ($action == 'create' || $action == 'adduserldap') { print $form->textwithpicto($langs->trans("Internal"), $langs->trans("InternalExternalDesc"), 1, 'help', '', 0, 2); print ''; + + print '
    '.dol_print_date($objp->datem).'
    "; $productstatic->id = $objp->rowid; $productstatic->ref = $objp->ref; From 9fbb5087b91f3fdaab4b6d7a331cc1ad896d81b1 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Fri, 23 Apr 2021 16:05:24 +0000 Subject: [PATCH 169/879] Fixing style errors. --- htdocs/product/stock/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/product/stock/card.php b/htdocs/product/stock/card.php index 0cd30ed827a..3ceb896741e 100644 --- a/htdocs/product/stock/card.php +++ b/htdocs/product/stock/card.php @@ -611,7 +611,7 @@ if ($action == 'create') { // Add fields from hooks $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook - if($reshook > 0){ //Note that $sql is replaced if reshook > 0 + if ($reshook > 0) { //Note that $sql is replaced if reshook > 0 $sql = ""; } $sql .= $hookmanager->resPrint; From f60df8964ab9d450ee8fb7671a47e76cf7d24628 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Sat, 24 Apr 2021 08:05:00 +0200 Subject: [PATCH 170/879] NEW: Add option SUPPLIER_PROPOSAL_ALLOW_EXTERNAL_DOWNLOAD --- htdocs/core/class/commonobject.class.php | 3 +++ htdocs/core/lib/functions.lib.php | 8 ++++++++ 2 files changed, 11 insertions(+) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index a93acda2a17..d5ddbec1245 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -5238,6 +5238,9 @@ abstract class CommonObject if ($this->element == 'contrat' && !empty($conf->global->CONTRACT_ALLOW_EXTERNAL_DOWNLOAD)) { $setsharekey = true; } + if ($this->element == 'supplier_proposal' && !empty($conf->global->SUPPLIER_PROPOSAL_ALLOW_EXTERNAL_DOWNLOAD)) { + $setsharekey = true; + } if ($setsharekey) { if (empty($ecmfile->share)) { // Because object not found or share not set yet diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 7368510484f..6f591c33128 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -7102,6 +7102,11 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null, } else { $substitutionarray['__DIRECTDOWNLOAD_URL_CONTRACT__'] = ''; } + if (!empty($conf->global->SUPPLIER_PROPOSAL_ALLOW_EXTERNAL_DOWNLOAD) && is_object($object) && $object->element == 'supplier_proposal') { + $substitutionarray['__DIRECTDOWNLOAD_URL_SUPPLIER_PROPOSAL__'] = $object->getLastMainDocLink($object->element); + } else { + $substitutionarray['__DIRECTDOWNLOAD_URL_SUPPLIER_PROPOSAL__'] = ''; + } if (is_object($object) && $object->element == 'propal') { $substitutionarray['__URL_PROPOSAL__'] = DOL_MAIN_URL_ROOT."/comm/propal/card.php?id=".$object->id; @@ -7115,6 +7120,9 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null, if (is_object($object) && $object->element == 'contrat') { $substitutionarray['__URL_CONTRACT__'] = DOL_MAIN_URL_ROOT."/contrat/card.php?id=".$object->id; } + if (is_object($object) && $object->element == 'supplier_proposal') { + $substitutionarray['__URL_SUPPLIER_PROPOSAL__'] = DOL_MAIN_URL_ROOT."/supplier_proposal/card.php?id=".$object->id; + } } if (is_object($object) && $object->element == 'action') { From 8b49585b64137442fddeba4f51b7b43776236833 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Sat, 24 Apr 2021 18:21:36 +0200 Subject: [PATCH 171/879] fix: return invoice id when create from order --- htdocs/compta/facture/class/facture.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 4ae9fe197fe..8d0e2bb8b47 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -1387,7 +1387,7 @@ class Facture extends CommonInvoice if (!$error) { - return 1; + return $ret; } else return -1; } else return -1; } From e229348e2c52eec63e7a599658158a4a0e409e99 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Sat, 24 Apr 2021 18:24:25 +0200 Subject: [PATCH 172/879] .gitignre --- .gitignore | 3 --- 1 file changed, 3 deletions(-) diff --git a/.gitignore b/.gitignore index a008514f2ee..371c8be2f5e 100644 --- a/.gitignore +++ b/.gitignore @@ -55,6 +55,3 @@ yarn.lock package-lock.json doc/install.lock - -/htdocs/cyber* -/htdocs/mycyber* From bc924ca00ee4fd76270876a130df1a492d09700a Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Sat, 24 Apr 2021 18:27:43 +0200 Subject: [PATCH 173/879] .gitignre --- htdocs/compta/facture/class/facture.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 8d0e2bb8b47..4ae9fe197fe 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -1387,7 +1387,7 @@ class Facture extends CommonInvoice if (!$error) { - return $ret; + return 1; } else return -1; } else return -1; } From 48c26fd614ead9c3e3d6a7be8bb6a38d3e85082f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 24 Apr 2021 18:43:24 +0200 Subject: [PATCH 174/879] Fix add option INVOICE_DISALLOW_REOPEN to lock problematic feature --- htdocs/compta/facture/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 907d18987ea..b9a3ae86811 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -189,7 +189,7 @@ if (empty($reshook)) $action = ''; } } // Change status of invoice - elseif ($action == 'reopen' && $usercancreate) { + elseif ($action == 'reopen' && $usercancreate && empty($conf->global->INVOICE_DISALLOW_REOPEN)) { $result = $object->fetch($id); if ($object->statut == Facture::STATUS_CLOSED || ($object->statut == Facture::STATUS_ABANDONED && ($object->close_code != 'replaced' || $object->getIdReplacingInvoice() == 0)) || ($object->statut == Facture::STATUS_VALIDATED && $object->paye == 1)) { // ($object->statut == 1 && $object->paye == 1) should not happened but can be found when data are corrupted From d0cc64479d6986e62e29013dde7c42acae472eeb Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 24 Apr 2021 20:18:11 +0200 Subject: [PATCH 175/879] Fix protect sql --- htdocs/accountancy/admin/accountmodel.php | 2 +- htdocs/accountancy/bookkeeping/card.php | 2 +- .../class/accountancycategory.class.php | 10 +++++----- .../class/accountingaccount.class.php | 4 ++-- htdocs/accountancy/class/bookkeeping.class.php | 4 ++-- htdocs/accountancy/customer/index.php | 4 ++-- htdocs/accountancy/expensereport/index.php | 4 ++-- htdocs/accountancy/journal/bankjournal.php | 16 ++++++++-------- htdocs/accountancy/supplier/index.php | 4 ++-- htdocs/adherents/class/adherent.class.php | 4 ++-- htdocs/adherents/class/adherent_type.class.php | 2 +- htdocs/adherents/class/subscription.class.php | 2 +- htdocs/adherents/list.php | 2 +- htdocs/adherents/subscription.php | 2 +- htdocs/adherents/subscription/list.php | 2 +- htdocs/adherents/type.php | 2 +- htdocs/admin/boxes.php | 4 ++-- htdocs/admin/dict.php | 2 +- htdocs/admin/external_rss.php | 2 +- htdocs/admin/security.php | 2 +- htdocs/asset/class/asset_type.class.php | 2 +- htdocs/blockedlog/class/authority.class.php | 2 +- htdocs/bookmarks/class/bookmark.class.php | 2 +- htdocs/categories/class/categorie.class.php | 2 +- htdocs/comm/action/class/actioncomm.class.php | 2 +- htdocs/comm/action/index.php | 2 +- htdocs/comm/action/pertype.php | 2 +- htdocs/comm/action/peruser.php | 2 +- htdocs/comm/index.php | 10 +++++----- htdocs/comm/mailing/advtargetemailing.php | 2 +- htdocs/comm/mailing/cibles.php | 2 +- htdocs/comm/propal/class/propal.class.php | 2 +- htdocs/comm/prospect/index.php | 2 +- htdocs/commande/class/commande.class.php | 4 ++-- htdocs/commande/customer.php | 2 +- htdocs/compta/bank/class/account.class.php | 7 ++++--- htdocs/compta/bank/line.php | 2 +- htdocs/compta/cashcontrol/report.php | 2 +- htdocs/compta/clients.php | 2 +- htdocs/compta/facture/class/facture.class.php | 2 +- .../prelevement/class/bonprelevement.class.php | 2 +- .../prelevement/class/ligneprelevement.class.php | 2 +- htdocs/compta/prelevement/list.php | 2 +- htdocs/compta/prelevement/rejets.php | 2 +- .../sociales/class/chargesociales.class.php | 2 +- htdocs/compta/sociales/list.php | 2 +- htdocs/contact/list.php | 2 +- htdocs/contrat/index.php | 10 +++++----- htdocs/contrat/services_list.php | 2 +- htdocs/core/class/commoninvoice.class.php | 4 ++-- htdocs/core/class/commonobject.class.php | 4 ++-- htdocs/core/lib/company.lib.php | 6 +++--- .../movement/doc/pdf_standard.modules.php | 2 +- htdocs/core/website.inc.php | 2 +- htdocs/don/class/don.class.php | 2 +- htdocs/expedition/class/expedition.class.php | 8 ++++---- htdocs/fichinter/card-rec.php | 2 +- htdocs/fichinter/class/fichinter.class.php | 2 +- htdocs/fichinter/list.php | 2 +- .../fourn/class/fournisseur.commande.class.php | 2 +- htdocs/loan/list.php | 2 +- htdocs/mrp/mo_movements.php | 2 +- htdocs/product/class/product.class.php | 4 ++-- htdocs/product/stock/stockatdate.php | 2 +- htdocs/projet/list.php | 2 +- htdocs/reception/class/reception.class.php | 4 ++-- htdocs/societe/index.php | 2 +- .../class/supplier_proposal.class.php | 2 +- htdocs/supplier_proposal/index.php | 2 +- htdocs/user/class/usergroup.class.php | 2 +- 70 files changed, 109 insertions(+), 108 deletions(-) diff --git a/htdocs/accountancy/admin/accountmodel.php b/htdocs/accountancy/admin/accountmodel.php index 7c05a9a0da4..f0fd9702009 100644 --- a/htdocs/accountancy/admin/accountmodel.php +++ b/htdocs/accountancy/admin/accountmodel.php @@ -442,7 +442,7 @@ if ($id) { } else { $sql .= " WHERE "; } - $sql .= " c.rowid = ".$search_country_id; + $sql .= " c.rowid = ".((int) $search_country_id); } // If sort order is "country", we use country_code instead diff --git a/htdocs/accountancy/bookkeeping/card.php b/htdocs/accountancy/bookkeeping/card.php index e3cac139c08..f91b1821df4 100644 --- a/htdocs/accountancy/bookkeeping/card.php +++ b/htdocs/accountancy/bookkeeping/card.php @@ -563,7 +563,7 @@ if ($action == 'create') { { $sqlmid = 'SELECT rowid as ref'; $sqlmid .= " FROM ".MAIN_DB_PREFIX."facture as fac"; - $sqlmid .= " WHERE fac.rowid=" . $object->fk_doc; + $sqlmid .= " WHERE fac.rowid=" . ((int) $object->fk_doc); dol_syslog("accountancy/bookkeeping/card.php::sqlmid=" . $sqlmid, LOG_DEBUG); $resultmid = $db->query($sqlmid); if ($resultmid) { diff --git a/htdocs/accountancy/class/accountancycategory.class.php b/htdocs/accountancy/class/accountancycategory.class.php index 9550933f2d8..d8e1598d1ac 100644 --- a/htdocs/accountancy/class/accountancycategory.class.php +++ b/htdocs/accountancy/class/accountancycategory.class.php @@ -473,7 +473,7 @@ class AccountancyCategory // extends CommonObject $sql .= " SELECT DISTINCT aa.account_number"; $sql .= " FROM ".MAIN_DB_PREFIX."accounting_account as aa"; $sql .= " INNER JOIN ".MAIN_DB_PREFIX."accounting_system as asy ON aa.fk_pcg_version = asy.pcg_version"; - $sql .= " AND asy.rowid = ".$conf->global->CHARTOFACCOUNTS; + $sql .= " AND asy.rowid = ".((int) $conf->global->CHARTOFACCOUNTS); $sql .= " AND aa.active = 1"; $sql .= " AND aa.entity = ".$conf->entity.")"; $sql .= " GROUP BY t.numero_compte, t.label_operation, t.doc_ref"; @@ -562,7 +562,7 @@ class AccountancyCategory // extends CommonObject $sql = "SELECT aa.rowid, aa.account_number"; $sql .= " FROM ".MAIN_DB_PREFIX."accounting_account as aa"; $sql .= " INNER JOIN ".MAIN_DB_PREFIX."accounting_system as asy ON aa.fk_pcg_version = asy.pcg_version"; - $sql .= " AND asy.rowid = ".$conf->global->CHARTOFACCOUNTS; + $sql .= " AND asy.rowid = ".((int) $conf->global->CHARTOFACCOUNTS); $sql .= " AND aa.active = 1"; $sql .= " AND aa.entity = ".$conf->entity; $sql .= " ORDER BY LENGTH(aa.account_number) DESC;"; // LENGTH is ok with mysql and postgresql @@ -589,8 +589,8 @@ class AccountancyCategory // extends CommonObject $accountincptsadded[$account_number_formated] = 1; // We found an account number that is in list $cpts of account to add $sql = "UPDATE ".MAIN_DB_PREFIX."accounting_account"; - $sql .= " SET fk_accounting_category=".$id_cat; - $sql .= " WHERE rowid=".$obj->rowid; + $sql .= " SET fk_accounting_category=".((int) $id_cat); + $sql .= " WHERE rowid=".((int) $obj->rowid); dol_syslog(__METHOD__, LOG_DEBUG); $resqlupdate = $this->db->query($sql); if (!$resqlupdate) { @@ -629,7 +629,7 @@ class AccountancyCategory // extends CommonObject $sql = "UPDATE ".MAIN_DB_PREFIX."accounting_account as aa"; $sql .= " SET fk_accounting_category= 0"; - $sql .= " WHERE aa.rowid= ".$cpt_id; + $sql .= " WHERE aa.rowid = ".((int) $cpt_id); $this->db->begin(); dol_syslog(__METHOD__." sql=".$sql, LOG_DEBUG); diff --git a/htdocs/accountancy/class/accountingaccount.class.php b/htdocs/accountancy/class/accountingaccount.class.php index a7d89c45294..28601380ac1 100644 --- a/htdocs/accountancy/class/accountingaccount.class.php +++ b/htdocs/accountancy/class/accountingaccount.class.php @@ -347,10 +347,10 @@ class AccountingAccount extends CommonObject $sql .= " , label = ".($this->label ? "'".$this->db->escape($this->label)."'" : "''"); $sql .= " , labelshort = ".($this->labelshort ? "'".$this->db->escape($this->labelshort)."'" : "''"); $sql .= " , fk_accounting_category = ".(empty($this->account_category) ? 0 : (int) $this->account_category); - $sql .= " , fk_user_modif = ".$user->id; + $sql .= " , fk_user_modif = ".((int) $user->id); $sql .= " , active = ".(int) $this->active; $sql .= " , reconcilable = ".(int) $this->reconcilable; - $sql .= " WHERE rowid = ".$this->id; + $sql .= " WHERE rowid = ".((int) $this->id); dol_syslog(get_class($this)."::update sql=".$sql, LOG_DEBUG); $result = $this->db->query($sql); diff --git a/htdocs/accountancy/class/bookkeeping.class.php b/htdocs/accountancy/class/bookkeeping.class.php index 6220904dbe8..00ed8879076 100644 --- a/htdocs/accountancy/class/bookkeeping.class.php +++ b/htdocs/accountancy/class/bookkeeping.class.php @@ -1860,7 +1860,7 @@ class BookKeeping extends CommonObject $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON aa.account_number = ab.numero_compte"; $sql .= " AND aa.active = 1"; $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "accounting_system as asy ON aa.fk_pcg_version = asy.pcg_version"; - $sql .= " AND asy.rowid = " . $pcgver; + $sql .= " AND asy.rowid = " . ((int) $pcgver); $sql .= " AND ab.entity IN (" . getEntity('accountancy') . ")"; $sql .= " ORDER BY account_number ASC"; */ @@ -1893,7 +1893,7 @@ class BookKeeping extends CommonObject $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON aa.account_number = ab.numero_compte"; $sql .= " AND aa.active = 1"; $sql .= " INNER JOIN ".MAIN_DB_PREFIX."accounting_system as asy ON aa.fk_pcg_version = asy.pcg_version"; - $sql .= " AND asy.rowid = ".$pcgver; + $sql .= " AND asy.rowid = ".((int) $pcgver); $sql .= " AND ab.entity IN (".getEntity('accountancy').")"; $sql .= " ORDER BY account_number ASC"; diff --git a/htdocs/accountancy/customer/index.php b/htdocs/accountancy/customer/index.php index 0b32e2802c4..43daa2efa88 100644 --- a/htdocs/accountancy/customer/index.php +++ b/htdocs/accountancy/customer/index.php @@ -110,13 +110,13 @@ if ($action == 'validatehistory') { $sql1 = "UPDATE " . MAIN_DB_PREFIX . "facturedet"; $sql1 .= " SET fk_code_ventilation = accnt.rowid"; $sql1 .= " FROM " . MAIN_DB_PREFIX . "product as p, " . MAIN_DB_PREFIX . "accounting_account as accnt , " . MAIN_DB_PREFIX . "accounting_system as syst"; - $sql1 .= " WHERE " . MAIN_DB_PREFIX . "facturedet.fk_product = p.rowid AND accnt.fk_pcg_version = syst.pcg_version AND syst.rowid=" . $conf->global->CHARTOFACCOUNTS.' AND accnt.entity = '.$conf->entity; + $sql1 .= " WHERE " . MAIN_DB_PREFIX . "facturedet.fk_product = p.rowid AND accnt.fk_pcg_version = syst.pcg_version AND syst.rowid=" . ((int) $conf->global->CHARTOFACCOUNTS).' AND accnt.entity = '.$conf->entity; $sql1 .= " AND accnt.active = 1 AND p.accountancy_code_sell=accnt.account_number"; $sql1 .= " AND " . MAIN_DB_PREFIX . "facturedet.fk_code_ventilation = 0"; } else { $sql1 = "UPDATE " . MAIN_DB_PREFIX . "facturedet as fd, " . MAIN_DB_PREFIX . "product as p, " . MAIN_DB_PREFIX . "accounting_account as accnt , " . MAIN_DB_PREFIX . "accounting_system as syst"; $sql1 .= " SET fk_code_ventilation = accnt.rowid"; - $sql1 .= " WHERE fd.fk_product = p.rowid AND accnt.fk_pcg_version = syst.pcg_version AND syst.rowid=" . $conf->global->CHARTOFACCOUNTS.' AND accnt.entity = '.$conf->entity; + $sql1 .= " WHERE fd.fk_product = p.rowid AND accnt.fk_pcg_version = syst.pcg_version AND syst.rowid=" . ((int) $conf->global->CHARTOFACCOUNTS).' AND accnt.entity = '.$conf->entity; $sql1 .= " AND accnt.active = 1 AND p.accountancy_code_sell=accnt.account_number"; $sql1 .= " AND fd.fk_code_ventilation = 0"; }*/ diff --git a/htdocs/accountancy/expensereport/index.php b/htdocs/accountancy/expensereport/index.php index 38f7f596932..b4e85fd517a 100644 --- a/htdocs/accountancy/expensereport/index.php +++ b/htdocs/accountancy/expensereport/index.php @@ -103,13 +103,13 @@ if ($action == 'validatehistory') { $sql1 = "UPDATE ".MAIN_DB_PREFIX."expensereport_det"; $sql1 .= " SET fk_code_ventilation = accnt.rowid"; $sql1 .= " FROM ".MAIN_DB_PREFIX."c_type_fees as t, ".MAIN_DB_PREFIX."accounting_account as accnt , ".MAIN_DB_PREFIX."accounting_system as syst"; - $sql1 .= " WHERE ".MAIN_DB_PREFIX."expensereport_det.fk_c_type_fees = t.id AND accnt.fk_pcg_version = syst.pcg_version AND syst.rowid=".$conf->global->CHARTOFACCOUNTS.' AND accnt.entity = '.$conf->entity; + $sql1 .= " WHERE ".MAIN_DB_PREFIX."expensereport_det.fk_c_type_fees = t.id AND accnt.fk_pcg_version = syst.pcg_version AND syst.rowid = ".((int) $conf->global->CHARTOFACCOUNTS).' AND accnt.entity = '.$conf->entity; $sql1 .= " AND accnt.active = 1 AND t.accountancy_code = accnt.account_number"; $sql1 .= " AND ".MAIN_DB_PREFIX."expensereport_det.fk_code_ventilation = 0"; } else { $sql1 = "UPDATE ".MAIN_DB_PREFIX."expensereport_det as erd, ".MAIN_DB_PREFIX."c_type_fees as t, ".MAIN_DB_PREFIX."accounting_account as accnt , ".MAIN_DB_PREFIX."accounting_system as syst"; $sql1 .= " SET erd.fk_code_ventilation = accnt.rowid"; - $sql1 .= " WHERE erd.fk_c_type_fees = t.id AND accnt.fk_pcg_version = syst.pcg_version AND syst.rowid=".$conf->global->CHARTOFACCOUNTS.' AND accnt.entity = '.$conf->entity; + $sql1 .= " WHERE erd.fk_c_type_fees = t.id AND accnt.fk_pcg_version = syst.pcg_version AND syst.rowid = ".((int) $conf->global->CHARTOFACCOUNTS).' AND accnt.entity = '.$conf->entity; $sql1 .= " AND accnt.active = 1 AND t.accountancy_code=accnt.account_number"; $sql1 .= " AND erd.fk_code_ventilation = 0"; } diff --git a/htdocs/accountancy/journal/bankjournal.php b/htdocs/accountancy/journal/bankjournal.php index 27b37c74932..741b2c9f038 100644 --- a/htdocs/accountancy/journal/bankjournal.php +++ b/htdocs/accountancy/journal/bankjournal.php @@ -1323,42 +1323,42 @@ function getSourceDocRef($val, $typerecord) } elseif ($typerecord == 'payment_supplier') { $sqlmid = 'SELECT payfac.fk_facturefourn as id, f.ref'; $sqlmid .= " FROM ".MAIN_DB_PREFIX."paiementfourn_facturefourn as payfac, ".MAIN_DB_PREFIX."facture_fourn as f"; - $sqlmid .= " WHERE payfac.fk_facturefourn = f.rowid AND payfac.fk_paiementfourn=".$val["paymentsupplierid"]; + $sqlmid .= " WHERE payfac.fk_facturefourn = f.rowid AND payfac.fk_paiementfourn=".((int) $val["paymentsupplierid"]); $ref = $langs->transnoentitiesnoconv("SupplierInvoice"); } elseif ($typerecord == 'payment_expensereport') { $sqlmid = 'SELECT e.rowid as id, e.ref'; $sqlmid .= " FROM ".MAIN_DB_PREFIX."payment_expensereport as pe, ".MAIN_DB_PREFIX."expensereport as e"; - $sqlmid .= " WHERE pe.rowid=".$val["paymentexpensereport"]." AND pe.fk_expensereport = e.rowid"; + $sqlmid .= " WHERE pe.rowid=".((int) $val["paymentexpensereport"])." AND pe.fk_expensereport = e.rowid"; $ref = $langs->transnoentitiesnoconv("ExpenseReport"); } elseif ($typerecord == 'payment_salary') { $sqlmid = 'SELECT s.rowid as ref'; $sqlmid .= " FROM ".MAIN_DB_PREFIX."payment_salary as s"; - $sqlmid .= " WHERE s.rowid=".$val["paymentsalid"]; + $sqlmid .= " WHERE s.rowid=".((int) $val["paymentsalid"]); $ref = $langs->transnoentitiesnoconv("SalaryPayment"); } elseif ($typerecord == 'sc') { $sqlmid = 'SELECT sc.rowid as ref'; $sqlmid .= " FROM ".MAIN_DB_PREFIX."paiementcharge as sc"; - $sqlmid .= " WHERE sc.rowid=".$val["paymentscid"]; + $sqlmid .= " WHERE sc.rowid=".((int) $val["paymentscid"]); $ref = $langs->transnoentitiesnoconv("SocialContribution"); } elseif ($typerecord == 'payment_vat') { $sqlmid = 'SELECT v.rowid as ref'; $sqlmid .= " FROM ".MAIN_DB_PREFIX."tva as v"; - $sqlmid .= " WHERE v.rowid=".$val["paymentvatid"]; + $sqlmid .= " WHERE v.rowid=".((int) $val["paymentvatid"]); $ref = $langs->transnoentitiesnoconv("PaymentVat"); } elseif ($typerecord == 'payment_donation') { $sqlmid = 'SELECT payd.fk_donation as ref'; $sqlmid .= " FROM ".MAIN_DB_PREFIX."payment_donation as payd"; - $sqlmid .= " WHERE payd.fk_donation=".$val["paymentdonationid"]; + $sqlmid .= " WHERE payd.fk_donation=".((int) $val["paymentdonationid"]); $ref = $langs->transnoentitiesnoconv("Donation"); } elseif ($typerecord == 'payment_loan') { $sqlmid = 'SELECT l.rowid as ref'; $sqlmid .= " FROM ".MAIN_DB_PREFIX."payment_loan as l"; - $sqlmid .= " WHERE l.rowid=".$val["paymentloanid"]; + $sqlmid .= " WHERE l.rowid=".((int) $val["paymentloanid"]); $ref = $langs->transnoentitiesnoconv("LoanPayment"); } elseif ($typerecord == 'payment_various') { $sqlmid = 'SELECT v.rowid as ref'; $sqlmid .= " FROM ".MAIN_DB_PREFIX."payment_various as v"; - $sqlmid .= " WHERE v.rowid=".$val["paymentvariousid"]; + $sqlmid .= " WHERE v.rowid=".((int) $val["paymentvariousid"]); $ref = $langs->transnoentitiesnoconv("VariousPayment"); } // Add warning diff --git a/htdocs/accountancy/supplier/index.php b/htdocs/accountancy/supplier/index.php index 392551708de..91dd921f1fa 100644 --- a/htdocs/accountancy/supplier/index.php +++ b/htdocs/accountancy/supplier/index.php @@ -118,13 +118,13 @@ if ($action == 'validatehistory') { $sql1 = "UPDATE " . MAIN_DB_PREFIX . "facture_fourn_det"; $sql1 .= " SET fk_code_ventilation = accnt.rowid"; $sql1 .= " FROM " . MAIN_DB_PREFIX . "product as p, " . MAIN_DB_PREFIX . "accounting_account as accnt , " . MAIN_DB_PREFIX . "accounting_system as syst"; - $sql1 .= " WHERE " . MAIN_DB_PREFIX . "facture_fourn_det.fk_product = p.rowid AND accnt.fk_pcg_version = syst.pcg_version AND syst.rowid=" . $conf->global->CHARTOFACCOUNTS.' AND accnt.entity = '.$conf->entity; + $sql1 .= " WHERE " . MAIN_DB_PREFIX . "facture_fourn_det.fk_product = p.rowid AND accnt.fk_pcg_version = syst.pcg_version AND syst.rowid=" . ((int) $conf->global->CHARTOFACCOUNTS).' AND accnt.entity = '.$conf->entity; $sql1 .= " AND accnt.active = 1 AND p.accountancy_code_buy=accnt.account_number"; $sql1 .= " AND " . MAIN_DB_PREFIX . "facture_fourn_det.fk_code_ventilation = 0"; } else { $sql1 = "UPDATE " . MAIN_DB_PREFIX . "facture_fourn_det as fd, " . MAIN_DB_PREFIX . "product as p, " . MAIN_DB_PREFIX . "accounting_account as accnt , " . MAIN_DB_PREFIX . "accounting_system as syst"; $sql1 .= " SET fk_code_ventilation = accnt.rowid"; - $sql1 .= " WHERE fd.fk_product = p.rowid AND accnt.fk_pcg_version = syst.pcg_version AND syst.rowid=" . $conf->global->CHARTOFACCOUNTS.' AND accnt.entity = '.$conf->entity; + $sql1 .= " WHERE fd.fk_product = p.rowid AND accnt.fk_pcg_version = syst.pcg_version AND syst.rowid=" . ((int) $conf->global->CHARTOFACCOUNTS).' AND accnt.entity = '.$conf->entity; $sql1 .= " AND accnt.active = 1 AND p.accountancy_code_buy=accnt.account_number"; $sql1 .= " AND fd.fk_code_ventilation = 0"; }*/ diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index 0299b32663c..d7dbeb9eb13 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -1597,8 +1597,8 @@ class Adherent extends CommonObject $inserturlid = $acct->add_url_line($insertid, $this->id, DOL_URL_ROOT.'/adherents/card.php?rowid=', $this->getFullname($langs), 'member'); if ($inserturlid > 0) { // Update table subscription - $sql = "UPDATE ".MAIN_DB_PREFIX."subscription SET fk_bank=".$insertid; - $sql .= " WHERE rowid=".$subscriptionid; + $sql = "UPDATE ".MAIN_DB_PREFIX."subscription SET fk_bank=".((int) $insertid); + $sql .= " WHERE rowid=".((int) $subscriptionid); dol_syslog("subscription::subscription", LOG_DEBUG); $resql = $this->db->query($sql); diff --git a/htdocs/adherents/class/adherent_type.class.php b/htdocs/adherents/class/adherent_type.class.php index b2f181e59be..d051c40810b 100644 --- a/htdocs/adherents/class/adherent_type.class.php +++ b/htdocs/adherents/class/adherent_type.class.php @@ -365,7 +365,7 @@ class AdherentType extends CommonObject $sql .= "note = '".$this->db->escape($this->note)."',"; $sql .= "vote = ".(integer) $this->db->escape($this->vote).","; $sql .= "mail_valid = '".$this->db->escape($this->mail_valid)."'"; - $sql .= " WHERE rowid =".$this->id; + $sql .= " WHERE rowid =".((int) $this->id); $result = $this->db->query($sql); if ($result) { diff --git a/htdocs/adherents/class/subscription.class.php b/htdocs/adherents/class/subscription.class.php index 65b01991100..95bbe79804f 100644 --- a/htdocs/adherents/class/subscription.class.php +++ b/htdocs/adherents/class/subscription.class.php @@ -217,7 +217,7 @@ class Subscription extends CommonObject $sql .= " datef,"; $sql .= " subscription, note, fk_bank"; $sql .= " FROM ".MAIN_DB_PREFIX."subscription"; - $sql .= " WHERE rowid=".$rowid; + $sql .= " WHERE rowid=".((int) $rowid); dol_syslog(get_class($this)."::fetch", LOG_DEBUG); $resql = $this->db->query($sql); diff --git a/htdocs/adherents/list.php b/htdocs/adherents/list.php index 9560a284e2a..b713362912e 100644 --- a/htdocs/adherents/list.php +++ b/htdocs/adherents/list.php @@ -318,7 +318,7 @@ if ($sall) { $sql .= natural_search(array_keys($fieldstosearchall), $sall); } if ($search_type > 0) { - $sql .= " AND t.rowid=".$db->escape($search_type); + $sql .= " AND t.rowid=".((int) $search_type); } if ($search_filter == 'withoutsubscription') { $sql .= " AND (datefin IS NULL OR t.subscription = 0)"; diff --git a/htdocs/adherents/subscription.php b/htdocs/adherents/subscription.php index 54729e5ba8a..ec9b2c3a65e 100644 --- a/htdocs/adherents/subscription.php +++ b/htdocs/adherents/subscription.php @@ -677,7 +677,7 @@ if ($rowid > 0) { $sql .= " FROM ".MAIN_DB_PREFIX."adherent as d, ".MAIN_DB_PREFIX."subscription as c"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON c.fk_bank = b.rowid"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank_account as ba ON b.fk_account = ba.rowid"; - $sql .= " WHERE d.rowid = c.fk_adherent AND d.rowid=".$rowid; + $sql .= " WHERE d.rowid = c.fk_adherent AND d.rowid=".((int) $rowid); $sql .= $db->order($sortfield, $sortorder); $result = $db->query($sql); diff --git a/htdocs/adherents/subscription/list.php b/htdocs/adherents/subscription/list.php index 7322f92fccd..55cafade309 100644 --- a/htdocs/adherents/subscription/list.php +++ b/htdocs/adherents/subscription/list.php @@ -170,7 +170,7 @@ if (isset($date_select) && $date_select != '') { } if ($search_ref) { if (is_numeric($search_ref)) { - $sql .= " AND (c.rowid = ".$db->escape($search_ref).")"; + $sql .= " AND c.rowid = ".((int) $search_ref); } else { $sql .= " AND 1 = 2"; // Always wrong } diff --git a/htdocs/adherents/type.php b/htdocs/adherents/type.php index 25c44baa7db..c9b98784142 100644 --- a/htdocs/adherents/type.php +++ b/htdocs/adherents/type.php @@ -500,7 +500,7 @@ if ($rowid > 0) { $sql .= " FROM ".MAIN_DB_PREFIX."adherent as d, ".MAIN_DB_PREFIX."adherent_type as t"; $sql .= " WHERE d.fk_adherent_type = t.rowid "; $sql .= " AND d.entity IN (".getEntity('adherent').")"; - $sql .= " AND t.rowid = ".$object->id; + $sql .= " AND t.rowid = ".((int) $object->id); if ($sall) { $sql .= natural_search(array("f.firstname", "d.lastname", "d.societe", "d.email", "d.login", "d.address", "d.town", "d.note_public", "d.note_private"), $sall); } diff --git a/htdocs/admin/boxes.php b/htdocs/admin/boxes.php index e8793ca3c30..fc3e30a484b 100644 --- a/htdocs/admin/boxes.php +++ b/htdocs/admin/boxes.php @@ -156,7 +156,7 @@ if ($action == 'delete') { $sql = "DELETE FROM ".MAIN_DB_PREFIX."boxes"; $sql .= " WHERE entity = ".$conf->entity; - $sql .= " AND box_id=".$obj->box_id; + $sql .= " AND box_id=".((int) $obj->box_id); $resql = $db->query($sql); @@ -255,7 +255,7 @@ if ($resql) { // We renumber the order of the boxes if one of them is in '' // This occurs just after an insert. if ($decalage) { - $sql = "UPDATE ".MAIN_DB_PREFIX."boxes SET box_order='".$db->escape($decalage)."' WHERE rowid=".$obj->rowid; + $sql = "UPDATE ".MAIN_DB_PREFIX."boxes SET box_order='".$db->escape($decalage)."' WHERE rowid=".((int) $obj->rowid); $db->query($sql); } } diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php index 636278dd6fb..455c01d0337 100644 --- a/htdocs/admin/dict.php +++ b/htdocs/admin/dict.php @@ -1151,7 +1151,7 @@ if ($id) { $sql .= " WHERE 1 = 1"; } if ($search_country_id > 0) { - $sql .= " AND c.rowid = ".$search_country_id; + $sql .= " AND c.rowid = ".((int) $search_country_id); } if ($search_code != '' && $id == 9) { $sql .= natural_search("code_iso", $search_code); diff --git a/htdocs/admin/external_rss.php b/htdocs/admin/external_rss.php index b8b412ad6f8..71086096e4f 100644 --- a/htdocs/admin/external_rss.php +++ b/htdocs/admin/external_rss.php @@ -136,7 +136,7 @@ if (GETPOST("delete")) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."boxes"; $sql .= " WHERE entity = ".$conf->entity; - $sql .= " AND box_id = ".$obj->rowid; + $sql .= " AND box_id = ".((int) $obj->rowid); $resql = $db->query($sql); $sql = "DELETE FROM ".MAIN_DB_PREFIX."boxes_def"; diff --git a/htdocs/admin/security.php b/htdocs/admin/security.php index 9ce22b7c08e..e3521f1d0af 100644 --- a/htdocs/admin/security.php +++ b/htdocs/admin/security.php @@ -71,7 +71,7 @@ if ($action == 'activate_encrypt') { if (dol_hash($obj->pass)) { $sql = "UPDATE ".MAIN_DB_PREFIX."user"; $sql .= " SET pass_crypted = '".dol_hash($obj->pass)."', pass = NULL"; - $sql .= " WHERE rowid=".$obj->rowid; + $sql .= " WHERE rowid=".((int) $obj->rowid); //print $sql; $resql2 = $db->query($sql); diff --git a/htdocs/asset/class/asset_type.class.php b/htdocs/asset/class/asset_type.class.php index 99205d2b3f3..36c654c28ba 100644 --- a/htdocs/asset/class/asset_type.class.php +++ b/htdocs/asset/class/asset_type.class.php @@ -188,7 +188,7 @@ class AssetType extends CommonObject $sql .= "accountancy_code_depreciation_asset = '".$this->db->escape($this->accountancy_code_depreciation_asset)."',"; $sql .= "accountancy_code_depreciation_expense = '".$this->db->escape($this->accountancy_code_depreciation_expense)."',"; $sql .= "note = '".$this->db->escape($this->note)."'"; - $sql .= " WHERE rowid =".$this->id; + $sql .= " WHERE rowid = ".((int) $this->id); $result = $this->db->query($sql); if ($result) { diff --git a/htdocs/blockedlog/class/authority.class.php b/htdocs/blockedlog/class/authority.class.php index 9fc10fdc59e..2071eb03c47 100644 --- a/htdocs/blockedlog/class/authority.class.php +++ b/htdocs/blockedlog/class/authority.class.php @@ -148,7 +148,7 @@ class BlockedLogAuthority global $langs; - dol_syslog(get_class($this)."::fetch id=".$id, LOG_DEBUG); + dol_syslog(get_class($this)."::fetch id=".((int) $id), LOG_DEBUG); if (empty($id) && empty($signature)) { $this->error = 'BadParameter'; diff --git a/htdocs/bookmarks/class/bookmark.class.php b/htdocs/bookmarks/class/bookmark.class.php index 4fe8c3cee83..9a5b3a53c20 100644 --- a/htdocs/bookmarks/class/bookmark.class.php +++ b/htdocs/bookmarks/class/bookmark.class.php @@ -219,7 +219,7 @@ class Bookmark extends CommonObject $sql .= " ,title = '".$this->db->escape($this->title)."'"; $sql .= " ,favicon = '".$this->db->escape($this->favicon)."'"; $sql .= " ,position = ".(int) $this->position; - $sql .= " WHERE rowid = ".$this->id; + $sql .= " WHERE rowid = ".((int) $this->id); dol_syslog("Bookmark::update", LOG_DEBUG); if ($this->db->query($sql)) { diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index 1f467b507d1..51079636d4f 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -1470,7 +1470,7 @@ class Categorie extends CommonObject // Load bank categories $sql = "SELECT c.label, c.rowid"; $sql .= " FROM ".MAIN_DB_PREFIX."bank_class as a, ".MAIN_DB_PREFIX."bank_categ as c"; - $sql .= " WHERE a.lineid=".$id." AND a.fk_categ = c.rowid"; + $sql .= " WHERE a.lineid=".((int) $id)." AND a.fk_categ = c.rowid"; $sql .= " AND c.entity IN (".getEntity('category').")"; $sql .= " ORDER BY c.label"; diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index f7ceea4743d..d8bcd0efb1b 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -2436,7 +2436,7 @@ class ActionComm extends CommonObject $sql = "UPDATE ".MAIN_DB_PREFIX."actioncomm "; $sql .= " SET percent = ".(int) $percent; - $sql .= " WHERE id=".$id; + $sql .= " WHERE id = ".((int) $id); if ($this->db->query($sql)) { $this->db->commit(); diff --git a/htdocs/comm/action/index.php b/htdocs/comm/action/index.php index 33e4fabe2aa..be0884a5556 100644 --- a/htdocs/comm/action/index.php +++ b/htdocs/comm/action/index.php @@ -720,7 +720,7 @@ if ($action == 'show_day') { $sql .= ')'; } if ($type) { - $sql .= " AND ca.id = ".$type; + $sql .= " AND ca.id = ".((int) $type); } if ($status == '0') { $sql .= " AND a.percent = 0"; diff --git a/htdocs/comm/action/pertype.php b/htdocs/comm/action/pertype.php index 8d436f0e0f6..19f8a8ce31c 100644 --- a/htdocs/comm/action/pertype.php +++ b/htdocs/comm/action/pertype.php @@ -592,7 +592,7 @@ if ($action == 'show_day') { $sql .= ')'; } if ($type) { - $sql .= " AND ca.id = ".$type; + $sql .= " AND ca.id = ".((int) $type); } if ($status == '0') { $sql .= " AND a.percent = 0"; diff --git a/htdocs/comm/action/peruser.php b/htdocs/comm/action/peruser.php index 3ad2d31b353..62af33b34ee 100644 --- a/htdocs/comm/action/peruser.php +++ b/htdocs/comm/action/peruser.php @@ -613,7 +613,7 @@ if ($action == 'show_day') { $sql .= ')'; } if ($type) { - $sql .= " AND ca.id = ".$type; + $sql .= " AND ca.id = ".((int) $type); } if ($status == '0') { $sql .= " AND a.percent = 0"; diff --git a/htdocs/comm/index.php b/htdocs/comm/index.php index 60a6bd5974b..5c2360624a4 100644 --- a/htdocs/comm/index.php +++ b/htdocs/comm/index.php @@ -219,7 +219,7 @@ if (!empty($conf->supplier_proposal->enabled) && $user->rights->supplier_proposa $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; } if ($socid) { - $sql .= " AND s.rowid = ".$socid; + $sql .= " AND s.rowid = ".((int) $socid); } $resql = $db->query($sql); @@ -605,7 +605,7 @@ if (((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_S $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; } if ($socid) { - $sql .= " AND s.rowid = ".$socid; + $sql .= " AND s.rowid = ".((int) $socid); } $sql .= " ORDER BY s.datec DESC"; $sql .= $db->plimit($max, 0); @@ -711,7 +711,7 @@ if (!empty($conf->contrat->enabled) && $user->rights->contrat->lire && 0) { // T $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; } if ($socid) { - $sql .= " AND s.rowid = ".$socid; + $sql .= " AND s.rowid = ".((int) $socid); } $sql .= " ORDER BY c.tms DESC"; $sql .= $db->plimit($max + 1, 0); @@ -786,7 +786,7 @@ if (!empty($conf->propal->enabled) && $user->rights->propal->lire) { $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; } if ($socid) { - $sql .= " AND s.rowid = ".$socid; + $sql .= " AND s.rowid = ".((int) $socid); } $sql .= " ORDER BY p.rowid DESC"; @@ -902,7 +902,7 @@ if (!empty($conf->commande->enabled) && $user->rights->commande->lire) { $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; } if ($socid) { - $sql .= " AND s.rowid = ".$socid; + $sql .= " AND s.rowid = ".((int) $socid); } $sql .= " ORDER BY c.rowid DESC"; diff --git a/htdocs/comm/mailing/advtargetemailing.php b/htdocs/comm/mailing/advtargetemailing.php index 2487e772373..bd052f4161e 100644 --- a/htdocs/comm/mailing/advtargetemailing.php +++ b/htdocs/comm/mailing/advtargetemailing.php @@ -379,7 +379,7 @@ if ($action == 'deletefilter') { if ($action == 'delete') { // Ici, rowid indique le destinataire et id le mailing - $sql = "DELETE FROM ".MAIN_DB_PREFIX."mailing_cibles WHERE rowid=".$rowid; + $sql = "DELETE FROM ".MAIN_DB_PREFIX."mailing_cibles WHERE rowid = ".((int) $rowid); $resql = $db->query($sql); if ($resql) { if (!empty($id)) { diff --git a/htdocs/comm/mailing/cibles.php b/htdocs/comm/mailing/cibles.php index d9557845492..27859403d96 100644 --- a/htdocs/comm/mailing/cibles.php +++ b/htdocs/comm/mailing/cibles.php @@ -167,7 +167,7 @@ if (GETPOST('exportcsv', 'int')) { if ($action == 'delete') { // Ici, rowid indique le destinataire et id le mailing - $sql = "DELETE FROM ".MAIN_DB_PREFIX."mailing_cibles WHERE rowid=".$rowid; + $sql = "DELETE FROM ".MAIN_DB_PREFIX."mailing_cibles WHERE rowid = ".((int) $rowid); $resql = $db->query($sql); if ($resql) { if (!empty($id)) { diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index ffee98ffbba..441020c9b5d 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -1477,7 +1477,7 @@ class Propal extends CommonObject $sql .= " WHERE p.entity IN (".getEntity('propal').")"; // Dont't use entity if you use rowid $sql .= " AND p.ref='".$this->db->escape($ref)."'"; } else { - $sql .= " WHERE p.rowid=".$rowid; + $sql .= " WHERE p.rowid = ".((int) $rowid); } dol_syslog(get_class($this)."::fetch", LOG_DEBUG); diff --git a/htdocs/comm/prospect/index.php b/htdocs/comm/prospect/index.php index 3aacd070ae4..8883e0af6f3 100644 --- a/htdocs/comm/prospect/index.php +++ b/htdocs/comm/prospect/index.php @@ -194,7 +194,7 @@ if (!empty($conf->propal->enabled) && $user->rights->propale->lire) { $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; } if ($socid) { - $sql .= " AND s.rowid = ".$socid; + $sql .= " AND s.rowid = ".((int) $socid); } $sql .= " ORDER BY p.rowid DESC"; $sql .= $db->plimit(5, 0); diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 635e561eaef..c89ad9340d2 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -1807,7 +1807,7 @@ class Commande extends CommonOrder $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_incoterms as i ON c.fk_incoterms = i.rowid'; if ($id) { - $sql .= " WHERE c.rowid=".$id; + $sql .= " WHERE c.rowid=".((int) $id); } else { $sql .= " WHERE c.entity IN (".getEntity('commande').")"; // Dont't use entity if you use rowid } @@ -2687,7 +2687,7 @@ class Commande extends CommonOrder $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; } if ($socid) { - $sql .= " AND s.rowid = ".$socid; + $sql .= " AND s.rowid = ".((int) $socid); } if ($draft) { $sql .= " AND c.fk_statut = ".self::STATUS_DRAFT; diff --git a/htdocs/commande/customer.php b/htdocs/commande/customer.php index 4f75ca3d4c5..6dfa898a024 100644 --- a/htdocs/commande/customer.php +++ b/htdocs/commande/customer.php @@ -105,7 +105,7 @@ if (dol_strlen($begin)) { $sql .= " AND s.nom like '".$db->escape($begin)."'"; } if ($socid > 0) { - $sql .= " AND s.rowid = ".$socid; + $sql .= " AND s.rowid = ".((int) $socid); } $sql .= " AND c.fk_statut in (1, 2) AND c.facture = 0"; $sql .= " GROUP BY s.nom"; diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php index 943fef0c32a..13c2bdba4ce 100644 --- a/htdocs/compta/bank/class/account.class.php +++ b/htdocs/compta/bank/class/account.class.php @@ -509,6 +509,7 @@ class Account extends CommonObject } // Clean parameters + $label = $emetteur = trim($emetteur); $banque = trim($banque); @@ -516,7 +517,7 @@ class Account extends CommonObject if (is_numeric($oper)) { // Clean operation to have a code instead of a rowid $sql = "SELECT code FROM ".MAIN_DB_PREFIX."c_paiement"; - $sql .= " WHERE id=".$oper; + $sql .= " WHERE id = ".((int) $oper); $sql .= " AND entity IN (".getEntity('c_paiement').")"; $resql = $this->db->query($sql); if ($resql) { @@ -1223,7 +1224,7 @@ class Account extends CommonObject $sql .= " AND (ba.rappro = 1 AND ba.courant != 2)"; // Compte rapprochable $sql .= " AND clos = 0"; if ($filteraccountid) { - $sql .= " AND ba.rowid = ".$filteraccountid; + $sql .= " AND ba.rowid = ".((int) $filteraccountid); } $resql = $this->db->query($sql); @@ -1278,7 +1279,7 @@ class Account extends CommonObject $sql .= " AND (ba.rappro = 1 AND ba.courant != 2)"; // Compte rapprochable $sql .= " AND clos = 0"; if ($filteraccountid) { - $sql .= " AND ba.rowid = ".$filteraccountid; + $sql .= " AND ba.rowid = ".((int) $filteraccountid); } $resql = $this->db->query($sql); diff --git a/htdocs/compta/bank/line.php b/htdocs/compta/bank/line.php index bfea7c74b60..3aa477dfc9c 100644 --- a/htdocs/compta/bank/line.php +++ b/htdocs/compta/bank/line.php @@ -268,7 +268,7 @@ $sql = "SELECT b.rowid,b.dateo as do,b.datev as dv, b.amount, b.label, b.rappro, $sql .= " b.num_releve, b.fk_user_author, b.num_chq, b.fk_type, b.fk_account, b.fk_bordereau as receiptid,"; $sql .= " b.emetteur,b.banque"; $sql .= " FROM ".MAIN_DB_PREFIX."bank as b"; -$sql .= " WHERE rowid=".$rowid; +$sql .= " WHERE rowid=".((int) $rowid); $sql .= " ORDER BY dateo ASC"; $result = $db->query($sql); if ($result) { diff --git a/htdocs/compta/cashcontrol/report.php b/htdocs/compta/cashcontrol/report.php index add61ac086c..653161ca3bc 100644 --- a/htdocs/compta/cashcontrol/report.php +++ b/htdocs/compta/cashcontrol/report.php @@ -342,7 +342,7 @@ if ($resql) { $sql .= "SET"; $sql .= " cash='".$db->escape($cash)."'"; $sql .= ", card='".$db->escape($bank)."'"; - $sql .= " where rowid=".$id; + $sql .= " where rowid = ".((int) $id); $db->query($sql); */ diff --git a/htdocs/compta/clients.php b/htdocs/compta/clients.php index 191038ed28a..60924dae644 100644 --- a/htdocs/compta/clients.php +++ b/htdocs/compta/clients.php @@ -127,7 +127,7 @@ if (dol_strlen($begin)) { $sql .= natural_search("s.nom", $begin); } if ($socid) { - $sql .= " AND s.rowid = ".$socid; + $sql .= " AND s.rowid = ".((int) $socid); } $sql .= " ORDER BY $sortfield $sortorder "; $sql .= $db->plimit($conf->liste_limit + 1, $offset); diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index b949877dc82..9ae760220a4 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -1604,7 +1604,7 @@ class Facture extends CommonInvoice $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_incoterms as i ON f.fk_incoterms = i.rowid'; if ($rowid) { - $sql .= " WHERE f.rowid=".$rowid; + $sql .= " WHERE f.rowid=".((int) $rowid); } else { $sql .= ' WHERE f.entity IN ('.getEntity('invoice').')'; // Dont't use entity if you use rowid if ($ref) { diff --git a/htdocs/compta/prelevement/class/bonprelevement.class.php b/htdocs/compta/prelevement/class/bonprelevement.class.php index 087911ce140..ea44a75899d 100644 --- a/htdocs/compta/prelevement/class/bonprelevement.class.php +++ b/htdocs/compta/prelevement/class/bonprelevement.class.php @@ -290,7 +290,7 @@ class BonPrelevement extends CommonObject $sql .= " FROM ".MAIN_DB_PREFIX."prelevement_bons as p"; $sql .= " WHERE p.entity IN (".getEntity('invoice').")"; if ($rowid > 0) { - $sql .= " AND p.rowid = ".$rowid; + $sql .= " AND p.rowid = ".((int) $rowid); } else { $sql .= " AND p.ref = '".$this->db->escape($ref)."'"; } diff --git a/htdocs/compta/prelevement/class/ligneprelevement.class.php b/htdocs/compta/prelevement/class/ligneprelevement.class.php index 6fa9b94b637..1c57feca37e 100644 --- a/htdocs/compta/prelevement/class/ligneprelevement.class.php +++ b/htdocs/compta/prelevement/class/ligneprelevement.class.php @@ -79,7 +79,7 @@ class LignePrelevement $sql .= ", pl.statut, pl.fk_soc"; $sql .= " FROM ".MAIN_DB_PREFIX."prelevement_lignes as pl"; $sql .= ", ".MAIN_DB_PREFIX."prelevement_bons as p"; - $sql .= " WHERE pl.rowid=".$rowid; + $sql .= " WHERE pl.rowid=".((int) $rowid); $sql .= " AND p.rowid = pl.fk_prelevement_bons"; $sql .= " AND p.entity = ".$conf->entity; diff --git a/htdocs/compta/prelevement/list.php b/htdocs/compta/prelevement/list.php index 0818dbb61d1..feb69bdc7fb 100644 --- a/htdocs/compta/prelevement/list.php +++ b/htdocs/compta/prelevement/list.php @@ -125,7 +125,7 @@ if ($type == 'bank-transfer') { $sql .= " AND f.fk_soc = s.rowid"; $sql .= " AND f.entity IN (".getEntity('invoice').")"; if ($socid) { - $sql .= " AND s.rowid = ".$socid; + $sql .= " AND s.rowid = ".((int) $socid); } if ($search_line) { $sql .= " AND pl.rowid = '".$db->escape($search_line)."'"; diff --git a/htdocs/compta/prelevement/rejets.php b/htdocs/compta/prelevement/rejets.php index fb03f2a6c6c..5aec35cf504 100644 --- a/htdocs/compta/prelevement/rejets.php +++ b/htdocs/compta/prelevement/rejets.php @@ -99,7 +99,7 @@ if ($type == 'bank-transfer') { $sql .= " AND p.type = 'debit-order'"; } if ($socid) { - $sql .= " AND s.rowid = ".$socid; + $sql .= " AND s.rowid = ".((int) $socid); } $sql .= $db->order($sortfield, $sortorder); $sql .= $db->plimit($limit + 1, $offset); diff --git a/htdocs/compta/sociales/class/chargesociales.class.php b/htdocs/compta/sociales/class/chargesociales.class.php index 20cc2c82b0c..1977ac9791b 100644 --- a/htdocs/compta/sociales/class/chargesociales.class.php +++ b/htdocs/compta/sociales/class/chargesociales.class.php @@ -147,7 +147,7 @@ class ChargeSociales extends CommonObject $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as p ON cs.fk_mode_reglement = p.id'; $sql .= ' WHERE cs.entity IN ('.getEntity('tax').')'; if ($ref) { - $sql .= " AND cs.rowid = ".$ref; + $sql .= " AND cs.ref = '".$this->db->escape($ref)."'"; } else { $sql .= " AND cs.rowid = ".((int) $id); } diff --git a/htdocs/compta/sociales/list.php b/htdocs/compta/sociales/list.php index ffebc7dcc73..2b0c3961759 100644 --- a/htdocs/compta/sociales/list.php +++ b/htdocs/compta/sociales/list.php @@ -195,7 +195,7 @@ $sql .= " WHERE cs.fk_type = c.id"; $sql .= " AND cs.entity = ".$conf->entity; // Search criteria if ($search_ref) { - $sql .= " AND cs.rowid=".$db->escape($search_ref); + $sql .= " AND cs.ref = '".$db->escape($search_ref)."'"; } if ($search_label) { $sql .= natural_search("cs.libelle", $search_label); diff --git a/htdocs/contact/list.php b/htdocs/contact/list.php index b02856ceb3b..c7386c260ed 100644 --- a/htdocs/contact/list.php +++ b/htdocs/contact/list.php @@ -513,7 +513,7 @@ if ($type == "o") { // filtre sur type $sql .= " AND s.client IN (2, 3)"; } if (!empty($socid)) { - $sql .= " AND s.rowid = ".$socid; + $sql .= " AND s.rowid = ".((int) $socid); } // Add where from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; diff --git a/htdocs/contrat/index.php b/htdocs/contrat/index.php index 8ab94ca6793..aed4cba2fe1 100644 --- a/htdocs/contrat/index.php +++ b/htdocs/contrat/index.php @@ -323,11 +323,11 @@ if (!$user->rights->societe->client->voir && !$socid) { $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; } if ($socid) { - $sql .= " AND s.rowid = ".$socid; + $sql .= " AND s.rowid = ".((int) $socid); } $sql .= " GROUP BY c.rowid, c.ref, c.datec, c.tms, c.statut, s.nom, s.rowid"; $sql .= " ORDER BY c.tms DESC"; -$sql .= " LIMIT ".$max; +$sql .= $db->plimit($max); dol_syslog("contrat/index.php", LOG_DEBUG); $result = $db->query($sql); @@ -398,7 +398,7 @@ if (!$user->rights->societe->client->voir && !$socid) { $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; } if ($socid) { - $sql .= " AND s.rowid = ".$socid; + $sql .= " AND s.rowid = ".((int) $socid); } $sql .= " ORDER BY cd.tms DESC"; @@ -480,7 +480,7 @@ if (!$user->rights->societe->client->voir && !$socid) { $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; } if ($socid) { - $sql .= " AND s.rowid = ".$socid; + $sql .= " AND s.rowid = ".((int) $socid); } $sql .= " ORDER BY cd.tms DESC"; @@ -562,7 +562,7 @@ if (!$user->rights->societe->client->voir && !$socid) { $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; } if ($socid) { - $sql .= " AND s.rowid = ".$socid; + $sql .= " AND s.rowid = ".((int) $socid); } $sql .= " ORDER BY cd.tms DESC"; diff --git a/htdocs/contrat/services_list.php b/htdocs/contrat/services_list.php index 7247dc02c83..a0ecc6b4be8 100644 --- a/htdocs/contrat/services_list.php +++ b/htdocs/contrat/services_list.php @@ -288,7 +288,7 @@ if ($search_service) { $sql .= " AND (p.ref LIKE '%".$db->escape($search_service)."%' OR p.description LIKE '%".$db->escape($search_service)."%' OR cd.description LIKE '%".$db->escape($search_service)."%')"; } if ($socid > 0) { - $sql .= " AND s.rowid = ".$socid; + $sql .= " AND s.rowid = ".((int) $socid); } $filter_dateouvertureprevue_start = dol_mktime(0, 0, 0, $opouvertureprevuemonth, $opouvertureprevueday, $opouvertureprevueyear); diff --git a/htdocs/core/class/commoninvoice.class.php b/htdocs/core/class/commoninvoice.class.php index 50d94da8531..81f2b529f1d 100644 --- a/htdocs/core/class/commoninvoice.class.php +++ b/htdocs/core/class/commoninvoice.class.php @@ -604,10 +604,10 @@ abstract class CommonInvoice extends CommonObject $sqltemp = 'SELECT c.type_cdr, c.nbjour, c.decalage'; $sqltemp .= ' FROM '.MAIN_DB_PREFIX.'c_payment_term as c'; if (is_numeric($cond_reglement)) { - $sqltemp .= " WHERE c.rowid=".$cond_reglement; + $sqltemp .= " WHERE c.rowid=".((int) $cond_reglement); } else { $sqltemp .= " WHERE c.entity IN (".getEntity('c_payment_term').")"; - $sqltemp .= " AND c.code='".$this->db->escape($cond_reglement)."'"; + $sqltemp .= " AND c.code = '".$this->db->escape($cond_reglement)."'"; } dol_syslog(get_class($this).'::calculate_date_lim_reglement', LOG_DEBUG); diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index a93acda2a17..2088263a2c2 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -3969,7 +3969,7 @@ abstract class CommonObject $sql = "DELETE FROM " . MAIN_DB_PREFIX . "element_element"; $sql .= " WHERE"; if ($rowid > 0) { - $sql .= " rowid = " . $rowid; + $sql .= " rowid = " . ((int) $rowid); } else { if ($deletesource) { $sql .= " fk_source = " . $sourceid . " AND sourcetype = '" . $this->db->escape($sourcetype) . "'"; @@ -5012,7 +5012,7 @@ abstract class CommonObject $this->db->begin(); $sql = "DELETE FROM ".MAIN_DB_PREFIX."element_resources"; - $sql .= " WHERE rowid=".$rowid; + $sql .= " WHERE rowid = ".((int) $rowid); dol_syslog(get_class($this)."::delete_resource", LOG_DEBUG); diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php index fb97d2e5361..7183e24dea5 100644 --- a/htdocs/core/lib/company.lib.php +++ b/htdocs/core/lib/company.lib.php @@ -504,11 +504,11 @@ function getCountry($searchkey, $withcode = '', $dbtouse = 0, $outputlangs = '', $sql = "SELECT rowid, code, label FROM ".MAIN_DB_PREFIX."c_country"; if (is_numeric($searchkey)) { - $sql .= " WHERE rowid=".$searchkey; + $sql .= " WHERE rowid = ".((int) $searchkey); } elseif (!empty($searchkey)) { - $sql .= " WHERE code='".$db->escape($searchkey)."'"; + $sql .= " WHERE code = '".$db->escape($searchkey)."'"; } else { - $sql .= " WHERE label='".$db->escape($searchlabel)."'"; + $sql .= " WHERE label = '".$db->escape($searchlabel)."'"; } $resql = $dbtouse->query($sql); diff --git a/htdocs/core/modules/movement/doc/pdf_standard.modules.php b/htdocs/core/modules/movement/doc/pdf_standard.modules.php index c8a0c50862b..c2817fb50f6 100644 --- a/htdocs/core/modules/movement/doc/pdf_standard.modules.php +++ b/htdocs/core/modules/movement/doc/pdf_standard.modules.php @@ -295,7 +295,7 @@ class pdf_stdandard extends ModelePDFMovement $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_lot as pl ON m.batch = pl.batch AND m.fk_product = pl.fk_product"; $sql .= " WHERE m.fk_product = p.rowid"; if ($msid > 0) { - $sql .= " AND m.rowid = ".$msid; + $sql .= " AND m.rowid = ".((int) $msid); } $sql .= " AND m.fk_entrepot = e.rowid"; $sql .= " AND e.entity IN (".getEntity('stock').")"; diff --git a/htdocs/core/website.inc.php b/htdocs/core/website.inc.php index 30ffee00248..8ffa69e31ac 100644 --- a/htdocs/core/website.inc.php +++ b/htdocs/core/website.inc.php @@ -94,7 +94,7 @@ if ($_SERVER['PHP_SELF'] != DOL_URL_ROOT.'/website/index.php') { // If we browsi $sql = "SELECT wp.rowid, wp.lang, wp.pageurl, wp.fk_page"; $sql .= " FROM ".MAIN_DB_PREFIX."website_page as wp"; $sql .= " WHERE wp.fk_website = ".((int) $website->id); - $sql .= " AND (wp.fk_page = ".$pageid." OR wp.rowid = ".$pageid; + $sql .= " AND (wp.fk_page = ".((int) $pageid)." OR wp.rowid = ".((int) $pageid); if (is_object($websitepage) && $websitepage->fk_page > 0) { $sql .= " OR wp.fk_page = ".$websitepage->fk_page." OR wp.rowid = ".$websitepage->fk_page; } diff --git a/htdocs/don/class/don.class.php b/htdocs/don/class/don.class.php index 1ec3ebe1cc5..a925cdb4ba4 100644 --- a/htdocs/don/class/don.class.php +++ b/htdocs/don/class/don.class.php @@ -612,7 +612,7 @@ class Don extends CommonObject $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON d.fk_country = c.rowid"; $sql .= " WHERE d.entity IN (".getEntity('donation').")"; if (!empty($id)) { - $sql .= " AND d.rowid=".$id; + $sql .= " AND d.rowid=".((int) $id); } elseif (!empty($ref)) { $sql .= " AND d.ref='".$this->db->escape($ref)."'"; } diff --git a/htdocs/expedition/class/expedition.class.php b/htdocs/expedition/class/expedition.class.php index ed6f7a25eaf..f7c5a1d32a8 100644 --- a/htdocs/expedition/class/expedition.class.php +++ b/htdocs/expedition/class/expedition.class.php @@ -545,7 +545,7 @@ class Expedition extends CommonObject $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_shipment_mode as s ON e.fk_shipping_method = s.rowid'; $sql .= " WHERE e.entity IN (".getEntity('expedition').")"; if ($id) { - $sql .= " AND e.rowid=".$id; + $sql .= " AND e.rowid = ".((int) $id); } if ($ref) { $sql .= " AND e.ref='".$this->db->escape($ref)."'"; @@ -2033,7 +2033,7 @@ class Expedition extends CommonObject $sql = "SELECT em.rowid, em.code, em.libelle as label, em.description, em.tracking, em.active"; $sql .= " FROM ".MAIN_DB_PREFIX."c_shipment_mode as em"; if ($id != '') { - $sql .= " WHERE em.rowid=".$id; + $sql .= " WHERE em.rowid=".((int) $id); } $resql = $this->db->query($sql); @@ -2072,7 +2072,7 @@ class Expedition extends CommonObject $sql .= ",libelle='".$this->db->escape($this->update['libelle'])."'"; $sql .= ",description='".$this->db->escape($this->update['description'])."'"; $sql .= ",tracking='".$this->db->escape($this->update['tracking'])."'"; - $sql .= " WHERE rowid=".$id; + $sql .= " WHERE rowid=".((int) $id); $resql = $this->db->query($sql); } if ($resql < 0) { @@ -2952,7 +2952,7 @@ class ExpeditionLigne extends CommonObjectLine // delete lot expedition line $sql = "DELETE FROM ".MAIN_DB_PREFIX."expeditiondet_batch"; $sql .= " WHERE fk_expeditiondet = ".$this->id; - $sql .= " AND rowid = ".$expedition_batch_id; + $sql .= " AND rowid = ".((int) $expedition_batch_id); if (!$this->db->query($sql)) { $this->errors[] = $this->db->lasterror()." - sql=$sql"; diff --git a/htdocs/fichinter/card-rec.php b/htdocs/fichinter/card-rec.php index b7280c2f4a4..26ea2cfaaa8 100644 --- a/htdocs/fichinter/card-rec.php +++ b/htdocs/fichinter/card-rec.php @@ -771,7 +771,7 @@ if ($action == 'create') { $sql .= " WHERE f.fk_soc = s.rowid"; $sql .= " AND f.entity = ".$conf->entity; if ($socid) { - $sql .= " AND s.rowid = ".$socid; + $sql .= " AND s.rowid = ".((int) $socid); } if (!$user->rights->societe->client->voir && !$socid) { $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; diff --git a/htdocs/fichinter/class/fichinter.class.php b/htdocs/fichinter/class/fichinter.class.php index 1fef1ed7c03..1c1c1ab37be 100644 --- a/htdocs/fichinter/class/fichinter.class.php +++ b/htdocs/fichinter/class/fichinter.class.php @@ -432,7 +432,7 @@ class Fichinter extends CommonObject $sql .= " WHERE f.entity IN (".getEntity('intervention').")"; $sql .= " AND f.ref='".$this->db->escape($ref)."'"; } else { - $sql .= " WHERE f.rowid=".$rowid; + $sql .= " WHERE f.rowid=".((int) $rowid); } dol_syslog(get_class($this)."::fetch", LOG_DEBUG); diff --git a/htdocs/fichinter/list.php b/htdocs/fichinter/list.php index ee9edc6694b..86c1cccef95 100644 --- a/htdocs/fichinter/list.php +++ b/htdocs/fichinter/list.php @@ -282,7 +282,7 @@ if (!$user->rights->societe->client->voir && empty($socid)) { $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; } if ($socid) { - $sql .= " AND s.rowid = ".$socid; + $sql .= " AND s.rowid = ".((int) $socid); } if ($sall) { $sql .= natural_search(array_keys($fieldstosearchall), $sall); diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index c999f204749..331e211e5ac 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -331,7 +331,7 @@ class CommandeFournisseur extends CommonOrder if (empty($id)) { $sql .= " WHERE c.entity IN (".getEntity('supplier_order').")"; } else { - $sql .= " WHERE c.rowid=".$id; + $sql .= " WHERE c.rowid=".((int) $id); } if ($ref) { diff --git a/htdocs/loan/list.php b/htdocs/loan/list.php index fa1de74b0cc..f9b08a63a48 100644 --- a/htdocs/loan/list.php +++ b/htdocs/loan/list.php @@ -113,7 +113,7 @@ if ($search_amount) { $sql .= natural_search("l.capital", $search_amount, 1); } if ($search_ref) { - $sql .= " AND l.rowid = ".$db->escape($search_ref); + $sql .= " AND l.rowid = ".((int) $search_ref); } if ($search_label) { $sql .= natural_search("l.label", $search_label); diff --git a/htdocs/mrp/mo_movements.php b/htdocs/mrp/mo_movements.php index b4b777f7b49..7b9c0662e53 100644 --- a/htdocs/mrp/mo_movements.php +++ b/htdocs/mrp/mo_movements.php @@ -441,7 +441,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea $sql .= " WHERE m.fk_product = p.rowid"; $sql .= " AND m.origintype = 'mo' AND m.fk_origin = ".(int) $object->id; if ($msid > 0) { - $sql .= " AND m.rowid = ".$msid; + $sql .= " AND m.rowid = ".((int) $msid); } $sql .= " AND m.fk_entrepot = e.rowid"; $sql .= " AND e.entity IN (".getEntity('stock').")"; diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 6ed0b4266a8..fbe706e93db 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -1679,11 +1679,11 @@ class Product extends CommonObject { // phpcs:enable $sql = "DELETE FROM ".MAIN_DB_PREFIX."product_price_by_qty"; - $sql .= " WHERE fk_product_price=".$rowid; + $sql .= " WHERE fk_product_price=".((int) $rowid); $resql = $this->db->query($sql); $sql = "DELETE FROM ".MAIN_DB_PREFIX."product_price"; - $sql .= " WHERE rowid=".$rowid; + $sql .= " WHERE rowid=".((int) $rowid); $resql = $this->db->query($sql); if ($resql) { return 1; diff --git a/htdocs/product/stock/stockatdate.php b/htdocs/product/stock/stockatdate.php index d9a9be0cd70..e5eb2751109 100644 --- a/htdocs/product/stock/stockatdate.php +++ b/htdocs/product/stock/stockatdate.php @@ -266,7 +266,7 @@ $reshook = $hookmanager->executeHooks('printFieldListJoin', $parameters); // Not $sql .= $hookmanager->resPrint; $sql .= ' WHERE p.entity IN ('.getEntity('product').')'; if ($productid > 0) { - $sql .= " AND p.rowid = ".$productid; + $sql .= " AND p.rowid = ".((int) $productid); } if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) { $sql .= " AND p.fk_product_type = 0"; diff --git a/htdocs/projet/list.php b/htdocs/projet/list.php index a0888daee2a..a9f17f5439b 100644 --- a/htdocs/projet/list.php +++ b/htdocs/projet/list.php @@ -424,7 +424,7 @@ if ($search_public != '') { $sql .= " AND p.public = ".$db->escape($search_public); } // For external user, no check is done on company permission because readability is managed by public status of project and assignement. -//if ($socid > 0) $sql.= " AND s.rowid = ".$socid; +//if ($socid > 0) $sql.= " AND s.rowid = ".((int) $socid); if ($search_sale > 0) { $sql .= " AND sc.fk_user = ".((int) $search_sale); } diff --git a/htdocs/reception/class/reception.class.php b/htdocs/reception/class/reception.class.php index b2f31505c44..d5e3feaa255 100644 --- a/htdocs/reception/class/reception.class.php +++ b/htdocs/reception/class/reception.class.php @@ -384,7 +384,7 @@ class Reception extends CommonObject $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_incoterms as i ON e.fk_incoterms = i.rowid'; $sql .= " WHERE e.entity IN (".getEntity('reception').")"; if ($id) { - $sql .= " AND e.rowid=".$id; + $sql .= " AND e.rowid=".((int) $id); } if ($ref) { $sql .= " AND e.ref='".$this->db->escape($ref)."'"; @@ -1356,7 +1356,7 @@ class Reception extends CommonObject $sql .= ",libelle='".$this->db->escape($this->update['libelle'])."'"; $sql .= ",description='".$this->db->escape($this->update['description'])."'"; $sql .= ",tracking='".$this->db->escape($this->update['tracking'])."'"; - $sql .= " WHERE rowid=".$id; + $sql .= " WHERE rowid=".((int) $id); $resql = $this->db->query($sql); } if ($resql < 0) { diff --git a/htdocs/societe/index.php b/htdocs/societe/index.php index a8a4c454c2c..f56beedb64e 100644 --- a/htdocs/societe/index.php +++ b/htdocs/societe/index.php @@ -274,7 +274,7 @@ if (!$user->rights->societe->client->voir && !$socid) { $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; } if ($socid) { - $sql .= " AND s.rowid = ".$socid; + $sql .= " AND s.rowid = ".((int) $socid); } if (!$user->rights->fournisseur->lire) { $sql .= " AND (s.fournisseur != 1 OR s.client != 0)"; diff --git a/htdocs/supplier_proposal/class/supplier_proposal.class.php b/htdocs/supplier_proposal/class/supplier_proposal.class.php index 0320a663ea8..728bf8f0fd9 100644 --- a/htdocs/supplier_proposal/class/supplier_proposal.class.php +++ b/htdocs/supplier_proposal/class/supplier_proposal.class.php @@ -1938,7 +1938,7 @@ class SupplierProposal extends CommonObject $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; } if ($socid) { - $sql .= " AND s.rowid = ".$socid; + $sql .= " AND s.rowid = ".((int) $socid); } if ($draft) { $sql .= " AND p.fk_statut = 0"; diff --git a/htdocs/supplier_proposal/index.php b/htdocs/supplier_proposal/index.php index 0cfdc5a09b6..75eba410d0f 100644 --- a/htdocs/supplier_proposal/index.php +++ b/htdocs/supplier_proposal/index.php @@ -315,7 +315,7 @@ if (!empty($conf->supplier_proposal->enabled) && $user->rights->supplier_proposa $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; } if ($socid) { - $sql .= " AND s.rowid = ".$socid; + $sql .= " AND s.rowid = ".((int) $socid); } $sql .= " ORDER BY p.rowid DESC"; diff --git a/htdocs/user/class/usergroup.class.php b/htdocs/user/class/usergroup.class.php index f0b6bcdfe87..3738c63b435 100644 --- a/htdocs/user/class/usergroup.class.php +++ b/htdocs/user/class/usergroup.class.php @@ -504,7 +504,7 @@ class UserGroup extends CommonObject } $sql = "DELETE FROM ".MAIN_DB_PREFIX."usergroup_rights"; - $sql .= " WHERE fk_usergroup = $this->id AND fk_id=".$nid; + $sql .= " WHERE fk_usergroup = $this->id AND fk_id=".((int) $nid); $sql .= " AND entity = ".$entity; if (!$this->db->query($sql)) { $error++; From 9f03054fc45fac448fe76e3af0711a9ac7759fac Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 24 Apr 2021 20:52:48 +0200 Subject: [PATCH 176/879] Fix #yogosha5877 --- htdocs/compta/bank/bankentries_list.php | 23 ++++++++++--------- htdocs/compta/bank/class/account.class.php | 2 +- .../bank/class/api_bankaccounts.class.php | 8 ++++++- htdocs/core/lib/functions.lib.php | 6 ++--- 4 files changed, 23 insertions(+), 16 deletions(-) diff --git a/htdocs/compta/bank/bankentries_list.php b/htdocs/compta/bank/bankentries_list.php index f6b719515cc..39967304e4c 100644 --- a/htdocs/compta/bank/bankentries_list.php +++ b/htdocs/compta/bank/bankentries_list.php @@ -791,7 +791,7 @@ if ($resql) { $nbmax = 12; // We show last 12 receipts (so we can have more than one year) $liste = ""; $sql = "SELECT DISTINCT num_releve FROM ".MAIN_DB_PREFIX."bank"; - $sql .= " WHERE fk_account=".$object->id." AND num_releve IS NOT NULL"; + $sql .= " WHERE fk_account = ".((int) $object->id)." AND num_releve IS NOT NULL"; $sql .= $db->order("num_releve", "DESC"); $sql .= $db->plimit($nbmax + 1); print '
    '; @@ -967,7 +967,7 @@ if ($resql) { $moreforfilter = ''; $moreforfilter .= '
    '; - $moreforfilter .= $langs->trans('DateOperationShort').' :'; + $moreforfilter .= $langs->trans('DateOperationShort').' '; $moreforfilter .= ($conf->browser->layout == 'phone' ? '
    ' : ' '); $moreforfilter .= '
    '; $moreforfilter .= $form->selectDate($search_dt_start, 'search_start_dt', 0, 0, 1, "search_form", 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From')).'
    '; @@ -976,7 +976,7 @@ if ($resql) { $moreforfilter .= '
    '; $moreforfilter .= '
    '; - $moreforfilter .= $langs->trans('DateValueShort').' : '; + $moreforfilter .= $langs->trans('DateValueShort').' '; $moreforfilter .= ($conf->browser->layout == 'phone' ? '
    ' : ' '); $moreforfilter .= '
    '; $moreforfilter .= $form->selectDate($search_dv_start, 'search_start_dv', 0, 0, 1, "search_form", 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From')).'
    '; @@ -1329,21 +1329,22 @@ if ($resql) { // Description if (!empty($arrayfields['b.label']['checked'])) { - print "
    "; - - //print "rowid."&account=".$objp->fk_account."\">"; + $labeltoshow = ''; + $titletoshow = ''; $reg = array(); preg_match('/\((.+)\)/i', $objp->label, $reg); // Si texte entoure de parenthee on tente recherche de traduction if ($reg[1] && $langs->trans($reg[1]) != $reg[1]) { - print $langs->trans($reg[1]); + $labeltoshow = $langs->trans($reg[1]); } else { if ($objp->label == '(payment_salary)') { - print dol_trunc($langs->trans("SalaryPayment", 40)); + $labeltoshow = dol_trunc($langs->trans("SalaryPayment", 40)); } else { - print dol_trunc($objp->label, 40); + $labeltoshow = dol_escape_htmltag($objp->label); + $titletoshow = $objp->label; } } - //print " "; + print ''; + print $labeltoshow; // Already escaped // Add links after description $cachebankaccount = array(); @@ -1498,7 +1499,7 @@ if ($resql) { // Num cheque if (!empty($arrayfields['b.num_chq']['checked'])) { - print ''.($objp->num_chq ? $objp->num_chq : "")."'.($objp->num_chq ? dol_escape_htmltag($objp->num_chq) : "")."
    '.$langs->trans("Password").''; - $valuetoshow = ''; - if (preg_match('/ldap/', $dolibarr_main_authentication)) { - $valuetoshow .= ($valuetoshow ? ', ' : '').$langs->trans("PasswordOfUserInLDAP"); - } - if (preg_match('/http/', $dolibarr_main_authentication)) { - $valuetoshow .= ($valuetoshow ? ', ' : '').$langs->trans("HTTPBasicPassword"); - } - if (preg_match('/dolibarr/', $dolibarr_main_authentication)) { - if (!empty($ldap_pass)) { // For very old system comaptibilty. Now clear password can't be viewed from LDAP read - $valuetoshow .= ($valuetoshow ? ', ' : '').''; // Dolibarr password is preffiled with LDAP known password - $valuetoshow .= preg_replace('/./i', '*', $ldap_pass); - } else { - // We do not use a field password but a field text to show new password to use. - $valuetoshow .= ($valuetoshow ? ', ' : '').''; - } - } - - // Other form for user password - $parameters = array('valuetoshow' => $valuetoshow, 'password' => $password); - $reshook = $hookmanager->executeHooks('printUserPasswordField', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - if ($reshook > 0) { - $valuetoshow = $hookmanager->resPrint; // to replace - } else { - $valuetoshow .= $hookmanager->resPrint; // to add - } - - print $valuetoshow; - print '
    '.$langs->trans("ApiKey").''; - print ''; - if (!empty($conf->use_javascript_ajax)) { - print ' '.img_picto($langs->trans('Generate'), 'refresh', 'id="generate_api_key" class="linkobject"'); - } - print '
    '.$langs->trans("Administrator").'
    '.$langs->trans('Employee').''; - print $form->selectyesno("employee", (GETPOST('employee') != '' ?GETPOST('employee') : $defaultemployee), 1); + print ''; + //print $form->selectyesno("employee", (GETPOST('employee') != '' ?GETPOST('employee') : $defaultemployee), 1); print '

    '; + + + // Date validity + print ''; + print ''; + print "\n"; + + // Password + print ''; + print ''; + + if (!empty($conf->api->enabled)) { + // API key + //$generated_password = getRandomPassword(false); + print ''; + print ''; + } else { + // PARTIAL WORKAROUND + $generated_fake_api_key = getRandomPassword(false); + print ''; + } + + print '
    '.$langs->trans("RangeOfLoginValidity").''; + print $form->selectDate($datestartvalidity, 'datestartvalidity', 0, 0, 1, 'formdatestartvalidity', 1, 1); + + print '   '; + + print $form->selectDate($dateendvalidity, 'dateendvalidity', 0, 0, 1, 'formdateendvalidity', 1, 0); + print '
    '.$langs->trans("Password").''; + $valuetoshow = ''; + if (preg_match('/ldap/', $dolibarr_main_authentication)) { + $valuetoshow .= ($valuetoshow ? ', ' : '').$langs->trans("PasswordOfUserInLDAP"); + } + if (preg_match('/http/', $dolibarr_main_authentication)) { + $valuetoshow .= ($valuetoshow ? ', ' : '').$langs->trans("HTTPBasicPassword"); + } + if (preg_match('/dolibarr/', $dolibarr_main_authentication)) { + if (!empty($ldap_pass)) { // For very old system comaptibilty. Now clear password can't be viewed from LDAP read + $valuetoshow .= ($valuetoshow ? ', ' : '').''; // Dolibarr password is preffiled with LDAP known password + $valuetoshow .= preg_replace('/./i', '*', $ldap_pass); + } else { + // We do not use a field password but a field text to show new password to use. + $valuetoshow .= ($valuetoshow ? ', ' : '').''; + } + } + + // Other form for user password + $parameters = array('valuetoshow' => $valuetoshow, 'password' => $password); + $reshook = $hookmanager->executeHooks('printUserPasswordField', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + if ($reshook > 0) { + $valuetoshow = $hookmanager->resPrint; // to replace + } else { + $valuetoshow .= $hookmanager->resPrint; // to add + } + + print $valuetoshow; + print '
    '.$langs->trans("ApiKey").''; + print ''; + if (!empty($conf->use_javascript_ajax)) { + print ' '.img_picto($langs->trans('Generate'), 'refresh', 'id="generate_api_key" class="linkobject"'); + } + print '

    '; @@ -1223,17 +1240,6 @@ if ($action == 'create' || $action == 'adduserldap') { print ''; print "\n"; - // Date validity - print ''; - print ''; - print "\n"; - // Date birth print ''; print '
    '.$langs->trans("RangeOfLoginValidity").''; - print $form->selectDate($datestartvalidity, 'datestartvalidity', 0, 0, 1, 'formdatestartvalidity', 1, 1); - - print ' - '; - - print $form->selectDate($dateendvalidity, 'dateendvalidity', 0, 0, 1, 'formdateendvalidity', 1, 0); - print '
    '.$langs->trans("DateOfBirth").''; @@ -1371,7 +1377,7 @@ if ($action == 'create' || $action == 'adduserldap') { print ''; // Login - print ''; + print ''; if (!empty($object->ldap_sid) && $object->statut == 0) { print ''; } else { @@ -1379,72 +1385,6 @@ if ($action == 'create' || $action == 'adduserldap') { } print ''."\n"; - // Password - print ''; - - print '"; - print ''."\n"; - - // API key - if (!empty($conf->api->enabled) && $user->admin) { - print ''; - print ''; - } - // Administrator print ''."\n"; // TODO Move this into tab RH, visible when salarie or RH is visible (HierarchicalResponsible must be on both tab) @@ -1604,20 +1545,6 @@ if ($action == 'create' || $action == 'adduserldap') { print ''; print "\n"; - // Date login validity - print ''; - print ''; - print "\n"; - // Date of birth print ''; print ''; print ''; - // Pass - print ''; - print '\n"; - - // API key - if (!empty($conf->api->enabled) && $user->admin) { - print ''; - print ''; - } - // Administrator print ''; if ($object->socid > 0) { @@ -2145,13 +2123,15 @@ if ($action == 'create' || $action == 'adduserldap') { print ''; print ''; @@ -2246,6 +2226,74 @@ if ($action == 'create' || $action == 'adduserldap') { } print ''; + + print '
    '.$langs->trans("Login").'
    '.$langs->trans("Login").''.$langs->trans("LoginAccountDisableInDolibarr").'
    '.$langs->trans("Password").''; - $valuetoshow = ''; - if (preg_match('/ldap/', $dolibarr_main_authentication)) { - if (!empty($object->ldap_sid)) { - if ($passDoNotExpire) { - $valuetoshow .= ($valuetoshow ? (' '.$langs->trans("or").' ') : '').$langs->trans("LdapUacf_".$statutUACF); - } elseif ($userChangePassNextLogon) { - $valuetoshow .= ($valuetoshow ? (' '.$langs->trans("or").' ') : '').''.$langs->trans("UserMustChangePassNextLogon", $ldap->domainFQDN).''; - } elseif ($userDisabled) { - $valuetoshow .= ($valuetoshow ? (' '.$langs->trans("or").' ') : '').''.$langs->trans("LdapUacf_".$statutUACF, $ldap->domainFQDN).''; - } else { - $valuetoshow .= ($valuetoshow ? (' '.$langs->trans("or").' ') : '').$langs->trans("PasswordOfUserInLDAP"); - } - } else { - $valuetoshow .= ($valuetoshow ? (' '.$langs->trans("or").' ') : '').$langs->trans("PasswordOfUserInLDAP"); - } - } - if (preg_match('/http/', $dolibarr_main_authentication)) { - $valuetoshow .= ($valuetoshow ? (' '.$langs->trans("or").' ') : '').$langs->trans("HTTPBasicPassword"); - } - if (preg_match('/dolibarr/', $dolibarr_main_authentication)) { - if ($object->pass) { - $valuetoshow .= ($valuetoshow ? (' '.$langs->trans("or").' ') : ''); - $valuetoshow .= ''.$langs->trans("Hidden").''; - } else { - if ($user->admin && $user->id == $object->id) { - $valuetoshow .= ($valuetoshow ? (' '.$langs->trans("or").' ') : ''); - //$valuetoshow .= ''.$langs->trans("Crypted").' - '; - $valuetoshow .= ''.$langs->trans("Hidden").''; - // TODO Add a feature to reveal the hash - $valuetoshow .= ''; - } else { - $valuetoshow .= ($valuetoshow ? (' '.$langs->trans("or").' ') : '').''.$langs->trans("Hidden").''; - } - } - } - - // Other form for user password - $parameters = array('valuetoshow' => $valuetoshow); - $reshook = $hookmanager->executeHooks('printUserPasswordField', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - if ($reshook > 0) { - $valuetoshow = $hookmanager->resPrint; // to replace - } else { - $valuetoshow .= $hookmanager->resPrint; // to add - } - - print $valuetoshow; - print "
    '.$langs->trans("ApiKey").''; - if (!empty($object->api_key)) { - print ''.preg_replace('/./', '*', $object->api_key).''; - } - if ($user->admin || $user->id == $object->id) { - // TODO Add a feature to reveal the hash - } - print '
    '.$langs->trans("Administrator").''; if (!empty($conf->multicompany->enabled) && $object->admin && !$object->entity) { @@ -1480,7 +1420,8 @@ if ($action == 'create' || $action == 'adduserldap') { // Employee print '
    '.$langs->trans("Employee").''; - print yn($object->employee); + print 'employee ? ' checked="checked"' : '').'>'; + //print yn($object->employee); print '
    '.$langs->trans("RangeOfLoginValidity").''; - if ($object->datestartvalidity) { - print ''.$langs->trans("FromDate").' '; - print dol_print_date($object->datestartvalidity, 'day'); - } - if ($object->dateendvalidity) { - print ' - '.$langs->trans("To").' '; - print dol_print_date($object->dateendvalidity, 'day'); - } - print '
    '.$langs->trans("DateOfBirth").''; @@ -1637,6 +1564,7 @@ if ($action == 'create' || $action == 'adduserldap') { print '
    '; print '
    '; + print ''; // Color user @@ -1755,7 +1683,7 @@ if ($action == 'create' || $action == 'adduserldap') { print dol_htmlentitiesbr($object->signature); print "\n"; - //VCard + // VCard print ''; print '\n"; print "
    '.$langs->trans("VCard").''; print ''; @@ -1765,6 +1693,97 @@ if ($action == 'create' || $action == 'adduserldap') { print "
    \n"; + + + print '
    '; + print ''; + print ''; + print ''; + print ''; + + // Date login validity + print ''; + print ''; + print "\n"; + + // Password + print ''; + + print '"; + print ''."\n"; + + // API key + if (!empty($conf->api->enabled) && $user->admin) { + print ''; + print ''; + } + print '
    '; + print $langs->trans("Credentials"); + print '
    '.$langs->trans("RangeOfLoginValidity").''; + if ($object->datestartvalidity) { + print ''.$langs->trans("FromDate").' '; + print dol_print_date($object->datestartvalidity, 'day'); + } + if ($object->dateendvalidity) { + print ' - '.$langs->trans("To").' '; + print dol_print_date($object->dateendvalidity, 'day'); + } + print '
    '.$langs->trans("Password").''; + $valuetoshow = ''; + if (preg_match('/ldap/', $dolibarr_main_authentication)) { + if (!empty($object->ldap_sid)) { + if ($passDoNotExpire) { + $valuetoshow .= ($valuetoshow ? (' '.$langs->trans("or").' ') : '').$langs->trans("LdapUacf_".$statutUACF); + } elseif ($userChangePassNextLogon) { + $valuetoshow .= ($valuetoshow ? (' '.$langs->trans("or").' ') : '').''.$langs->trans("UserMustChangePassNextLogon", $ldap->domainFQDN).''; + } elseif ($userDisabled) { + $valuetoshow .= ($valuetoshow ? (' '.$langs->trans("or").' ') : '').''.$langs->trans("LdapUacf_".$statutUACF, $ldap->domainFQDN).''; + } else { + $valuetoshow .= ($valuetoshow ? (' '.$langs->trans("or").' ') : '').$langs->trans("PasswordOfUserInLDAP"); + } + } else { + $valuetoshow .= ($valuetoshow ? (' '.$langs->trans("or").' ') : '').$langs->trans("PasswordOfUserInLDAP"); + } + } + if (preg_match('/http/', $dolibarr_main_authentication)) { + $valuetoshow .= ($valuetoshow ? (' '.$langs->trans("or").' ') : '').$langs->trans("HTTPBasicPassword"); + } + if (preg_match('/dolibarr/', $dolibarr_main_authentication)) { + if ($object->pass) { + $valuetoshow .= ($valuetoshow ? (' '.$langs->trans("or").' ') : ''); + $valuetoshow .= ''.$langs->trans("Hidden").''; + } else { + if ($user->admin && $user->id == $object->id) { + $valuetoshow .= ($valuetoshow ? (' '.$langs->trans("or").' ') : ''); + //$valuetoshow .= ''.$langs->trans("Crypted").' - '; + $valuetoshow .= ''.$langs->trans("Hidden").''; + // TODO Add a feature to reveal the hash + $valuetoshow .= ''; + } else { + $valuetoshow .= ($valuetoshow ? (' '.$langs->trans("or").' ') : '').''.$langs->trans("Hidden").''; + } + } + } + + // Other form for user password + $parameters = array('valuetoshow' => $valuetoshow); + $reshook = $hookmanager->executeHooks('printUserPasswordField', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + if ($reshook > 0) { + $valuetoshow = $hookmanager->resPrint; // to replace + } else { + $valuetoshow .= $hookmanager->resPrint; // to add + } + + print $valuetoshow; + print "
    '.$langs->trans("ApiKey").''; + if (!empty($object->api_key)) { + print ''.preg_replace('/./', '*', $object->api_key).''; + } + if ($user->admin || $user->id == $object->id) { + // TODO Add a feature to reveal the hash + } + print '
    '; + print '
    '; print '
    '; @@ -2011,47 +2030,6 @@ if ($action == 'create' || $action == 'adduserldap') { print '
    '.$langs->trans("Password").''; - $valuetoshow = ''; - if (preg_match('/ldap/', $dolibarr_main_authentication)) { - $valuetoshow .= ($valuetoshow ? (' '.$langs->trans("or").' ') : '').$langs->trans("PasswordOfUserInLDAP"); - } - if (preg_match('/http/', $dolibarr_main_authentication)) { - $valuetoshow .= ($valuetoshow ? (' '.$langs->trans("or").' ') : '').$form->textwithpicto($text, $langs->trans("DolibarrInHttpAuthenticationSoPasswordUseless", $dolibarr_main_authentication), 1, 'warning'); - } - if (preg_match('/dolibarr/', $dolibarr_main_authentication)) { - if ($caneditpassword) { - $valuetoshow .= ($valuetoshow ? (' '.$langs->trans("or").' ') : '').''; - } else { - $valuetoshow .= ($valuetoshow ? (' '.$langs->trans("or").' ') : '').preg_replace('/./i', '*', $object->pass); - } - } - - // Other form for user password - $parameters = array('valuetoshow' => $valuetoshow, 'caneditpassword' => $caneditpassword); - $reshook = $hookmanager->executeHooks('printUserPasswordField', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - if ($reshook > 0) { - $valuetoshow = $hookmanager->resPrint; // to replace - } else { - $valuetoshow .= $hookmanager->resPrint; // to add - } - - print $valuetoshow; - print "
    '.$langs->trans("ApiKey").''; - print ''; - if (!empty($conf->use_javascript_ajax)) { - print ' '.img_picto($langs->trans('Generate'), 'refresh', 'id="generate_api_key" class="linkobject"'); - } - print '
    '.$langs->trans("Administrator").'
    '.$form->editfieldkey('Employee', 'employee', '', $object, 0).''; if ($caneditfield) { - print $form->selectyesno("employee", $object->employee, 1); + print 'employee ? ' checked="checked"' : '').'>'; + //print $form->selectyesno("employee", $object->employee, 1); } else { - if ($object->employee) { + print 'employee ? ' checked="checked"' : '').'>'; + /*if ($object->employee) { print $langs->trans("Yes"); } else { print $langs->trans("No"); - } + }*/ } print '

    '; + + + // Date access validity + print ''; + print ''; + print "\n"; + + // Pass + print ''; + print '\n"; + + // API key + if (!empty($conf->api->enabled) && $user->admin) { + print ''; + print ''; + } + + print '
    '.$langs->trans("RangeOfLoginValidity").''; + if ($caneditfield) { + print $form->selectDate($datestartvalidity ? $datestartvalidity : $object->datestartvalidity, 'datestartvalidity', 0, 0, 1, 'formdatestartvalidity', 1, 1, 0, '', '', '', '', 1, '', ''); + } else { + print dol_print_date($object->datestartvalidity, 'day'); + } + + /*if ($datestartvalidity && $dateendvalidity) { + print ' - '; + }*/ + print '   '; + + if ($caneditfield) { + print $form->selectDate($dateendvalidity ? $datendevalidity : $object->dateendvalidity, 'dateendvalidity', 0, 0, 1, 'formdateendvalidity', 1, 0, 0, '', '', '', '', 1, '', ''); + } else { + print dol_print_date($object->dateendvalidity, 'day'); + } + print '
    '.$langs->trans("Password").''; + $valuetoshow = ''; + if (preg_match('/ldap/', $dolibarr_main_authentication)) { + $valuetoshow .= ($valuetoshow ? (' '.$langs->trans("or").' ') : '').$langs->trans("PasswordOfUserInLDAP"); + } + if (preg_match('/http/', $dolibarr_main_authentication)) { + $valuetoshow .= ($valuetoshow ? (' '.$langs->trans("or").' ') : '').$form->textwithpicto($text, $langs->trans("DolibarrInHttpAuthenticationSoPasswordUseless", $dolibarr_main_authentication), 1, 'warning'); + } + if (preg_match('/dolibarr/', $dolibarr_main_authentication)) { + if ($caneditpassword) { + $valuetoshow .= ($valuetoshow ? (' '.$langs->trans("or").' ') : '').''; + } else { + $valuetoshow .= ($valuetoshow ? (' '.$langs->trans("or").' ') : '').preg_replace('/./i', '*', $object->pass); + } + } + + // Other form for user password + $parameters = array('valuetoshow' => $valuetoshow, 'caneditpassword' => $caneditpassword); + $reshook = $hookmanager->executeHooks('printUserPasswordField', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + if ($reshook > 0) { + $valuetoshow = $hookmanager->resPrint; // to replace + } else { + $valuetoshow .= $hookmanager->resPrint; // to add + } + + print $valuetoshow; + print "
    '.$langs->trans("ApiKey").''; + print ''; + if (!empty($conf->use_javascript_ajax)) { + print ' '.img_picto($langs->trans('Generate'), 'refresh', 'id="generate_api_key" class="linkobject"'); + } + print '

    '; @@ -2636,29 +2684,6 @@ if ($action == 'create' || $action == 'adduserldap') { print ''; print "\n"; - - // Date login validity - print ''; - print ''; - print "\n"; - - // Date birth print ''; print ''; - print '\n"; From a8563de1c434df445ffa7cf05276887570e9a6d7 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Sun, 25 Apr 2021 13:34:26 +0000 Subject: [PATCH 184/879] Fixing style errors. --- htdocs/product/class/api_products.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/product/class/api_products.class.php b/htdocs/product/class/api_products.class.php index c3f5c4f5551..0ceb082bd93 100644 --- a/htdocs/product/class/api_products.class.php +++ b/htdocs/product/class/api_products.class.php @@ -188,7 +188,7 @@ class Products extends DolibarrApi } $sql .= ' WHERE t.entity IN ('.getEntity('product').')'; - if($without_variants){ + if ($without_variants) { $sql .= ' AND t.rowid in (select distinct fk_product_parent from '.MAIN_DB_PREFIX.'product_attribute_combination)'; } From fd2d317b4af758680c4173c1c3d3a5ae795983c7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 25 Apr 2021 15:55:36 +0200 Subject: [PATCH 185/879] Fix #yogosha5881 --- htdocs/accountancy/journal/bankjournal.php | 2 +- htdocs/comm/action/card.php | 2 +- htdocs/comm/mailing/card.php | 4 ++-- htdocs/comm/mailing/cibles.php | 2 -- htdocs/comm/propal/card.php | 4 ++-- htdocs/commande/card.php | 4 ++-- htdocs/commande/class/commande.class.php | 8 ++++++-- htdocs/compta/bank/account_statement_document.php | 2 +- htdocs/compta/bank/line.php | 2 +- htdocs/compta/bank/various_payment/list.php | 2 +- htdocs/compta/deplacement/card.php | 2 +- htdocs/compta/facture/card-rec.php | 6 +++--- htdocs/compta/facture/card.php | 10 +++++----- htdocs/compta/facture/class/facture-rec.class.php | 2 +- htdocs/compta/facture/class/facture.class.php | 2 +- htdocs/compta/prelevement/card.php | 2 +- htdocs/compta/prelevement/factures.php | 2 +- htdocs/compta/prelevement/line.php | 2 +- htdocs/contrat/card.php | 4 ++-- htdocs/contrat/class/contrat.class.php | 2 +- htdocs/core/class/commonobject.class.php | 2 +- htdocs/core/lib/company.lib.php | 2 +- htdocs/core/tpl/resource_view.tpl.php | 4 ++-- htdocs/don/card.php | 2 +- htdocs/expedition/class/expeditionbatch.class.php | 4 +--- htdocs/expedition/shipment.php | 2 +- htdocs/fourn/class/fournisseur.facture.class.php | 2 +- htdocs/fourn/commande/card.php | 4 ++-- htdocs/fourn/commande/dispatch.php | 2 +- htdocs/fourn/facture/card.php | 2 +- htdocs/ftp/admin/ftpclient.php | 1 + htdocs/install/lib/repair.lib.php | 2 +- htdocs/intracommreport/card.php | 2 +- htdocs/margin/productMargins.php | 2 +- htdocs/product/class/product.class.php | 4 ++-- htdocs/product/price.php | 2 +- htdocs/product/stock/card.php | 2 +- htdocs/reception/class/reception.class.php | 2 +- htdocs/societe/list.php | 2 +- htdocs/supplier_proposal/card.php | 2 +- htdocs/ticket/class/ticket.class.php | 2 +- htdocs/user/notify/card.php | 6 +++--- htdocs/variants/combinations.php | 2 +- 43 files changed, 62 insertions(+), 61 deletions(-) diff --git a/htdocs/accountancy/journal/bankjournal.php b/htdocs/accountancy/journal/bankjournal.php index 741b2c9f038..e3e2a308cf9 100644 --- a/htdocs/accountancy/journal/bankjournal.php +++ b/htdocs/accountancy/journal/bankjournal.php @@ -130,7 +130,7 @@ $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank_url as bu3 ON bu3.fk_bank = b.rowid A $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank_url as bu4 ON bu4.fk_bank = b.rowid AND bu4.type='payment_supplier'"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as soc on bu1.url_id=soc.rowid"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as u on bu2.url_id=u.rowid"; -$sql .= " WHERE ba.fk_accountancy_journal=".$id_journal; +$sql .= " WHERE ba.fk_accountancy_journal=".((int) $id_journal); $sql .= ' AND b.amount != 0 AND ba.entity IN ('.getEntity('bank_account', 0).')'; // We don't share object for accountancy if ($date_start && $date_end) { $sql .= " AND b.dateo >= '".$db->idate($date_start)."' AND b.dateo <= '".$db->idate($date_end)."'"; diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index 74ff6c6aa62..322a688bd45 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -1395,7 +1395,7 @@ if ($id > 0) { // Confirmation suppression action if ($action == 'delete') { - print $form->formconfirm("card.php?id=".$id, $langs->trans("DeleteAction"), $langs->trans("ConfirmDeleteAction"), "confirm_delete", '', '', 1); + print $form->formconfirm("card.php?id=".urlencode($id), $langs->trans("DeleteAction"), $langs->trans("ConfirmDeleteAction"), "confirm_delete", '', '', 1); } if ($action == 'edit') { diff --git a/htdocs/comm/mailing/card.php b/htdocs/comm/mailing/card.php index 4958811ef4d..c3ef480d2ae 100644 --- a/htdocs/comm/mailing/card.php +++ b/htdocs/comm/mailing/card.php @@ -308,7 +308,7 @@ if (empty($reshook)) { dol_syslog("comm/mailing/card.php: ok for #".$i.($mail->error ? ' - '.$mail->error : ''), LOG_DEBUG); $sql = "UPDATE ".MAIN_DB_PREFIX."mailing_cibles"; - $sql .= " SET statut=1, date_envoi='".$db->idate($now)."' WHERE rowid=".$obj->rowid; + $sql .= " SET statut=1, date_envoi = '".$db->idate($now)."' WHERE rowid=".((int) $obj->rowid); $resql2 = $db->query($sql); if (!$resql2) { dol_print_error($db); @@ -378,7 +378,7 @@ if (empty($reshook)) { } } - $sql = "UPDATE ".MAIN_DB_PREFIX."mailing SET statut=".$statut." WHERE rowid=".$object->id; + $sql = "UPDATE ".MAIN_DB_PREFIX."mailing SET statut=".((int) $statut)." WHERE rowid = ".((int) $object->id); dol_syslog("comm/mailing/card.php: update global status", LOG_DEBUG); $resql2 = $db->query($sql); if (!$resql2) { diff --git a/htdocs/comm/mailing/cibles.php b/htdocs/comm/mailing/cibles.php index 27859403d96..afd6273d6c0 100644 --- a/htdocs/comm/mailing/cibles.php +++ b/htdocs/comm/mailing/cibles.php @@ -104,8 +104,6 @@ if ($action == 'add') { } if ($result > 0) { setEventMessages($langs->trans("XTargetsAdded", $result), null, 'mesgs'); - //header("Location: ".$_SERVER['PHP_SELF']."?id=".$id); - //exit; $action = ''; } if ($result == 0) { diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index ebca0177868..44e2ad8a4cd 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -1248,7 +1248,7 @@ if (empty($reshook)) { if (empty($user->rights->margins->creer)) { foreach ($object->lines as &$line) { - if ($line->id == GETPOST('lineid')) { + if ($line->id == GETPOST('lineid', 'int')) { $fournprice = $line->fk_fournprice; $buyingprice = $line->pa_ht; break; @@ -2433,7 +2433,7 @@ if ($action == 'create') { // Show object lines $result = $object->getLinesArray(); - print '
    + print ' diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index 0665a567738..12117a5f1cb 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -1052,7 +1052,7 @@ if (empty($reshook)) { if (!$error) { if (empty($user->rights->margins->creer)) { foreach ($object->lines as &$line) { - if ($line->id == GETPOST('lineid')) { + if ($line->id == GETPOST('lineid', 'int')) { $fournprice = $line->fk_fournprice; $buyingprice = $line->pa_ht; break; @@ -2416,7 +2416,7 @@ if ($action == 'create' && $usercancreate) { */ $result = $object->getLinesArray(); - print ' + print ' diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index c89ad9340d2..40fd3892c4c 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -4206,11 +4206,15 @@ class OrderLine extends CommonOrderLine $error = 0; + if (empty($this->id) && !empty($this->rowid)) { // For backward compatibility + $this->id = $this->rowid; + } + // check if order line is not in a shipment line before deleting $sqlCheckShipmentLine = "SELECT"; $sqlCheckShipmentLine .= " ed.rowid"; $sqlCheckShipmentLine .= " FROM ".MAIN_DB_PREFIX."expeditiondet ed"; - $sqlCheckShipmentLine .= " WHERE ed.fk_origin_line = ".$this->rowid; + $sqlCheckShipmentLine .= " WHERE ed.fk_origin_line = ".((int) $this->id); $resqlCheckShipmentLine = $this->db->query($sqlCheckShipmentLine); if (!$resqlCheckShipmentLine) { @@ -4235,7 +4239,7 @@ class OrderLine extends CommonOrderLine $this->db->begin(); - $sql = 'DELETE FROM '.MAIN_DB_PREFIX."commandedet WHERE rowid=".$this->rowid; + $sql = 'DELETE FROM '.MAIN_DB_PREFIX."commandedet WHERE rowid = ".((int) $this->id); dol_syslog("OrderLine::delete", LOG_DEBUG); $resql = $this->db->query($sql); diff --git a/htdocs/compta/bank/account_statement_document.php b/htdocs/compta/bank/account_statement_document.php index 6103df38f66..4f317c1a9ed 100644 --- a/htdocs/compta/bank/account_statement_document.php +++ b/htdocs/compta/bank/account_statement_document.php @@ -129,7 +129,7 @@ if (!empty($numref)) { $object->fetch_thirdparty(); $upload_dir = $conf->bank->dir_output."/".$id."/statement/".dol_sanitizeFileName($numref); } -$backtopage = $_SERVER['PHP_SELF']."?account=".$id."&num=".$numref; +$backtopage = $_SERVER['PHP_SELF']."?account=".urlencode($id)."&num=".urlencode($numref); include DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php'; diff --git a/htdocs/compta/bank/line.php b/htdocs/compta/bank/line.php index 3aa477dfc9c..76f7f821f8a 100644 --- a/htdocs/compta/bank/line.php +++ b/htdocs/compta/bank/line.php @@ -291,7 +291,7 @@ if ($result) { // Confirmations if ($action == 'delete_categ') { - print $form->formconfirm($_SERVER['PHP_SELF']."?rowid=".$rowid."&cat1=".GETPOST("fk_categ")."&orig_account=".$orig_account, $langs->trans("RemoveFromRubrique"), $langs->trans("RemoveFromRubriqueConfirm"), "confirm_delete_categ", '', 'yes', 1); + print $form->formconfirm($_SERVER['PHP_SELF']."?rowid=".urlencode($rowid)."&cat1=".urlencode(GETPOST("fk_categ", 'int'))."&orig_account=".urlencode($orig_account), $langs->trans("RemoveFromRubrique"), $langs->trans("RemoveFromRubriqueConfirm"), "confirm_delete_categ", '', 'yes', 1); } print ''; diff --git a/htdocs/compta/bank/various_payment/list.php b/htdocs/compta/bank/various_payment/list.php index dcc1f4aef97..5e6d199db0a 100644 --- a/htdocs/compta/bank/various_payment/list.php +++ b/htdocs/compta/bank/various_payment/list.php @@ -226,7 +226,7 @@ $sql .= " WHERE v.entity IN (".getEntity('payment_various').")"; // Search criteria if ($search_ref) { - $sql .= " AND v.rowid=".$db->escape($search_ref); + $sql .= " AND v.rowid = ".((int) $search_ref); } if ($search_label) { $sql .= natural_search(array('v.label'), $search_label); diff --git a/htdocs/compta/deplacement/card.php b/htdocs/compta/deplacement/card.php index 3d4693f8c7b..6f390e82552 100644 --- a/htdocs/compta/deplacement/card.php +++ b/htdocs/compta/deplacement/card.php @@ -366,7 +366,7 @@ if ($action == 'create') { * Confirm delete trip */ if ($action == 'delete') { - print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$id, $langs->trans("DeleteTrip"), $langs->trans("ConfirmDeleteTrip"), "confirm_delete"); + print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".urlencode($id), $langs->trans("DeleteTrip"), $langs->trans("ConfirmDeleteTrip"), "confirm_delete"); } $soc = new Societe($db); diff --git a/htdocs/compta/facture/card-rec.php b/htdocs/compta/facture/card-rec.php index 4f0148a05a1..1ee26e6daf3 100644 --- a/htdocs/compta/facture/card-rec.php +++ b/htdocs/compta/facture/card-rec.php @@ -770,7 +770,7 @@ if (empty($reshook)) { } /*$line = new FactureLigne($db); - $line->fetch(GETPOST('lineid')); + $line->fetch(GETPOST('lineid', 'int')); $percent = $line->get_prev_progress($object->id); if (GETPOST('progress') < $percent) @@ -823,7 +823,7 @@ if (empty($reshook)) { // Update line if (!$error) { $result = $object->updateline( - GETPOST('lineid'), + GETPOST('lineid', 'int'), $description, $pu_ht, $qty, @@ -1597,7 +1597,7 @@ if ($action == 'create') { // Lines - print ' + print ' diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index bde5a6e6c38..df27efe91ed 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -238,13 +238,13 @@ if (empty($reshook)) { $object->fetch($id); $object->fetch_thirdparty(); - $result = $object->deleteline(GETPOST('lineid')); + $result = $object->deleteline(GETPOST('lineid', 'int')); if ($result > 0) { // Define output language $outputlangs = $langs; $newlang = ''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && !empty($_REQUEST['lang_id'])) { - $newlang = $_REQUEST['lang_id']; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id')) { + $newlang = GETPOST('lang_id'); } if ($conf->global->MAIN_MULTILANGS && empty($newlang)) { $newlang = $object->thirdparty->default_lang; @@ -2416,7 +2416,7 @@ if (empty($reshook)) { if (!$error) { if (empty($usercancreatemargin)) { foreach ($object->lines as &$line) { - if ($line->id == GETPOST('lineid')) { + if ($line->id == GETPOST('lineid', 'int')) { $fournprice = $line->fk_fournprice; $buyingprice = $line->pa_ht; break; @@ -5168,7 +5168,7 @@ if ($action == 'create') { } } - print ' + print ' diff --git a/htdocs/compta/facture/class/facture-rec.class.php b/htdocs/compta/facture/class/facture-rec.class.php index 363a781538a..ee4d1a48397 100644 --- a/htdocs/compta/facture/class/facture-rec.class.php +++ b/htdocs/compta/facture/class/facture-rec.class.php @@ -765,7 +765,7 @@ class FactureRec extends CommonInvoice { $rowid = $this->id; - dol_syslog(get_class($this)."::delete rowid=".$rowid, LOG_DEBUG); + dol_syslog(get_class($this)."::delete rowid=".((int) $rowid), LOG_DEBUG); $error = 0; $this->db->begin(); diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 9ae760220a4..26a5d862457 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -3657,7 +3657,7 @@ class Facture extends CommonInvoice { global $user; - dol_syslog(get_class($this)."::deleteline rowid=".$rowid, LOG_DEBUG); + dol_syslog(get_class($this)."::deleteline rowid=".((int) $rowid), LOG_DEBUG); if ($this->statut != self::STATUS_DRAFT) { $this->error = 'ErrorDeleteLineNotAllowedByObjectStatus'; diff --git a/htdocs/compta/prelevement/card.php b/htdocs/compta/prelevement/card.php index 20a11effdad..cd3e155ae06 100644 --- a/htdocs/compta/prelevement/card.php +++ b/htdocs/compta/prelevement/card.php @@ -380,7 +380,7 @@ if ($id > 0 || $ref) { $num = $db->num_rows($result); $i = 0; - $urladd = "&id=".$id; + $urladd = "&id=".urlencode($id); print ''."\n"; print ''; diff --git a/htdocs/compta/prelevement/factures.php b/htdocs/compta/prelevement/factures.php index 9cfeb860d33..c00c29e1c39 100644 --- a/htdocs/compta/prelevement/factures.php +++ b/htdocs/compta/prelevement/factures.php @@ -220,7 +220,7 @@ if ($resql) { $num = $db->num_rows($resql); $i = 0; - $param = "&id=".$id; + $param = "&id=".urlencode($id); // Lines of title fields print ''; diff --git a/htdocs/compta/prelevement/line.php b/htdocs/compta/prelevement/line.php index dce5dd39b60..a912ecdba3a 100644 --- a/htdocs/compta/prelevement/line.php +++ b/htdocs/compta/prelevement/line.php @@ -275,7 +275,7 @@ if ($id) { $num = $db->num_rows($result); $i = 0; - $urladd = "&id=".$id; + $urladd = "&id=".urlencode($id); print_barre_liste($langs->trans("Bills"), $page, "factures.php", $urladd, $sortfield, $sortorder, '', $num, 0, ''); diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php index 1ab26b73c75..c925dea94bf 100644 --- a/htdocs/contrat/card.php +++ b/htdocs/contrat/card.php @@ -711,7 +711,7 @@ if (empty($reshook)) { $db->rollback(); } } elseif ($action == 'confirm_deleteline' && $confirm == 'yes' && $user->rights->contrat->creer) { - $result = $object->deleteline(GETPOST('lineid'), $user); + $result = $object->deleteline(GETPOST('lineid', 'int'), $user); if ($result >= 0) { header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); @@ -1963,7 +1963,7 @@ if ($action == 'create') { $dateSelector = 1; print "\n"; - print ' + print ' diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index 33dd0e8e2f7..3bfe1a2315e 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -1832,7 +1832,7 @@ class Contrat extends CommonObject $this->db->begin(); $sql = "DELETE FROM ".MAIN_DB_PREFIX.$this->table_element_line; - $sql .= " WHERE rowid=".$idline; + $sql .= " WHERE rowid = ".((int) $idline); dol_syslog(get_class($this)."::deleteline", LOG_DEBUG); $resql = $this->db->query($sql); diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 2088263a2c2..4aa20d8f41a 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -8893,7 +8893,7 @@ abstract class CommonObject $this->db->begin(); $sql = "DELETE FROM ".MAIN_DB_PREFIX.$this->table_element_line; - $sql .= " WHERE rowid=".$idline; + $sql .= " WHERE rowid = ".((int) $idline); dol_syslog(get_class($this)."::deleteLineCommon", LOG_DEBUG); $resql = $this->db->query($sql); diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php index 7183e24dea5..d197b687876 100644 --- a/htdocs/core/lib/company.lib.php +++ b/htdocs/core/lib/company.lib.php @@ -571,7 +571,7 @@ function getState($id, $withcode = '', $dbtouse = 0, $withregion = 0, $outputlan $sql = "SELECT d.rowid as id, d.code_departement as code, d.nom as name, d.active, c.label as country, c.code as country_code, r.code_region as region_code, r.nom as region_name FROM"; $sql .= " ".MAIN_DB_PREFIX."c_departements as d, ".MAIN_DB_PREFIX."c_regions as r,".MAIN_DB_PREFIX."c_country as c"; - $sql .= " WHERE d.fk_region=r.code_region and r.fk_pays=c.rowid and d.rowid=".$id; + $sql .= " WHERE d.fk_region=r.code_region and r.fk_pays=c.rowid and d.rowid=".((int) $id); $sql .= " AND d.active = 1 AND r.active = 1 AND c.active = 1"; $sql .= " ORDER BY c.code, d.code_departement"; diff --git a/htdocs/core/tpl/resource_view.tpl.php b/htdocs/core/tpl/resource_view.tpl.php index 81ad11ebdc9..740590cb34a 100644 --- a/htdocs/core/tpl/resource_view.tpl.php +++ b/htdocs/core/tpl/resource_view.tpl.php @@ -33,7 +33,7 @@ if ((array) $linked_resources && count($linked_resources) > 0) { //$element_id = $linked_resource['rowid']; - if ($mode == 'edit' && $linked_resource['rowid'] == GETPOST('lineid')) { + if ($mode == 'edit' && $linked_resource['rowid'] == GETPOST('lineid', 'int')) { print '
    '; print ''; print ''; @@ -47,7 +47,7 @@ if ((array) $linked_resources && count($linked_resources) > 0) { print '
    '; } else { $class = ''; - if ($linked_resource['rowid'] == GETPOST('lineid')) { + if ($linked_resource['rowid'] == GETPOST('lineid', 'int')) { $class = 'highlight'; } diff --git a/htdocs/don/card.php b/htdocs/don/card.php index 1dfade00bec..0763ff9b7e5 100644 --- a/htdocs/don/card.php +++ b/htdocs/don/card.php @@ -120,7 +120,7 @@ if ($action == 'confirm_reopen' && $confirm == 'yes' && $permissiontoadd) { if ($action == 'update') { if (!empty($cancel)) { - header("Location: ".$_SERVER['PHP_SELF']."?id=".$id); + header("Location: ".$_SERVER['PHP_SELF']."?id=".urlencode($id)); exit; } diff --git a/htdocs/expedition/class/expeditionbatch.class.php b/htdocs/expedition/class/expeditionbatch.class.php index f97d6b87a1b..736cfba6e42 100644 --- a/htdocs/expedition/class/expeditionbatch.class.php +++ b/htdocs/expedition/class/expeditionbatch.class.php @@ -151,10 +151,8 @@ class ExpeditionLineBatch extends CommonObject */ public static function deletefromexp($db, $id_expedition) { - $id_expedition = (int) $id_expedition; - $sql = "DELETE FROM ".MAIN_DB_PREFIX.self::$_table_element; - $sql .= " WHERE fk_expeditiondet in (SELECT rowid FROM ".MAIN_DB_PREFIX."expeditiondet WHERE fk_expedition=".$id_expedition.")"; + $sql .= " WHERE fk_expeditiondet in (SELECT rowid FROM ".MAIN_DB_PREFIX."expeditiondet WHERE fk_expedition=".((int) $id_expedition).")"; dol_syslog(__METHOD__, LOG_DEBUG); if ($db->query($sql)) { diff --git a/htdocs/expedition/shipment.php b/htdocs/expedition/shipment.php index cba2e14cf74..80dbaf698ef 100644 --- a/htdocs/expedition/shipment.php +++ b/htdocs/expedition/shipment.php @@ -258,7 +258,7 @@ if ($id > 0 || !empty($ref)) { // Confirm validation if ($action == 'cloture') { - $formconfirm = $form->formconfirm($_SERVER['PHP_SELF']."?id=".$id, $langs->trans("CloseShipment"), $langs->trans("ConfirmCloseShipment"), "confirm_cloture"); + $formconfirm = $form->formconfirm($_SERVER['PHP_SELF']."?id=".urlencode($id), $langs->trans("CloseShipment"), $langs->trans("ConfirmCloseShipment"), "confirm_cloture"); } // Call Hook formConfirm diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index fca16305047..8245e8ec1cc 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -678,7 +678,7 @@ class FactureFournisseur extends CommonInvoice $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as p ON t.fk_mode_reglement = p.id"; $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_incoterms as i ON t.fk_incoterms = i.rowid'; if ($id) { - $sql .= " WHERE t.rowid=".$id; + $sql .= " WHERE t.rowid=".((int) $id); } if ($ref) { $sql .= " WHERE t.ref='".$this->db->escape($ref)."' AND t.entity IN (".getEntity('supplier_invoice').")"; diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index 8358b71f2c7..e33b9de48c1 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -1326,7 +1326,7 @@ if (empty($reshook)) { $_GET['socid'] = $_POST['socid']; } else { $db->commit(); - header("Location: ".$_SERVER['PHP_SELF']."?id=".$id); + header("Location: ".$_SERVER['PHP_SELF']."?id=".urlencode($id)); exit; } } @@ -2275,7 +2275,7 @@ if ($action == 'create') { //$result = $object->getLinesArray(); - print ' + print ' diff --git a/htdocs/fourn/commande/dispatch.php b/htdocs/fourn/commande/dispatch.php index c27a33f522b..b183092972e 100644 --- a/htdocs/fourn/commande/dispatch.php +++ b/htdocs/fourn/commande/dispatch.php @@ -1166,7 +1166,7 @@ if ($id > 0 || !empty($ref)) { $objp = $db->fetch_object($resql); if ($action == 'editline' && $lineid == $objp->dispatchlineid) { - print ' + print ' diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index 578c9c7e062..e59e4583e72 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -3293,7 +3293,7 @@ if ($action == 'create') { /* * Lines */ - print ''; + print ''; print ''; print ''; print ''; diff --git a/htdocs/ftp/admin/ftpclient.php b/htdocs/ftp/admin/ftpclient.php index 5094f178cea..12ee32a496f 100644 --- a/htdocs/ftp/admin/ftpclient.php +++ b/htdocs/ftp/admin/ftpclient.php @@ -237,6 +237,7 @@ if (!function_exists('ftp_connect')) { while ($i < $num) { $obj = $db->fetch_object($resql); + $reg = array(); preg_match('/([0-9]+)$/i', $obj->name, $reg); $idrss = $reg[0]; //print "x".join(',',$reg)."=".$obj->name."=".$idrss; diff --git a/htdocs/install/lib/repair.lib.php b/htdocs/install/lib/repair.lib.php index 242fbff25d4..bd54e55ebde 100644 --- a/htdocs/install/lib/repair.lib.php +++ b/htdocs/install/lib/repair.lib.php @@ -140,7 +140,7 @@ function clean_data_ecm_directories() $label = $obj->label; $newlabel = dol_sanitizeFileName($label); if ($label != $newlabel) { - $sqlupdate = "UPDATE ".MAIN_DB_PREFIX."ecm_directories set label='".$db->escape($newlabel)."' WHERE rowid=".$id; + $sqlupdate = "UPDATE ".MAIN_DB_PREFIX."ecm_directories set label = '".$db->escape($newlabel)."' WHERE rowid = ".((int) $id); print '
    \n"; $resqlupdate = $db->query($sqlupdate); if (!$resqlupdate) { diff --git a/htdocs/intracommreport/card.php b/htdocs/intracommreport/card.php index 0226848bd48..24b8797a670 100644 --- a/htdocs/intracommreport/card.php +++ b/htdocs/intracommreport/card.php @@ -203,7 +203,7 @@ if ($id > 0 && $action != 'edit') { ); } print $form->formconfirm( - "card.php?rowid=".$id, + "card.php?rowid=".urlencode($id), $langs->trans("DeleteReport"), $langs->trans("ConfirmDeleteReport"), "confirm_delete", diff --git a/htdocs/margin/productMargins.php b/htdocs/margin/productMargins.php index f18cc4ee503..ac006c042aa 100644 --- a/htdocs/margin/productMargins.php +++ b/htdocs/margin/productMargins.php @@ -198,7 +198,7 @@ $sql .= ' AND f.entity IN ('.getEntity('invoice').')'; $sql .= " AND f.fk_statut NOT IN (".$db->sanitize(implode(', ', $invoice_status_except_list)).")"; $sql .= " AND d.fk_facture = f.rowid"; if ($id > 0) { - $sql .= " AND d.fk_product =".$id; + $sql .= " AND d.fk_product =".((int) $id); } if (!empty($TSelectedCats)) { $sql .= ' AND cp.fk_categorie IN ('.$db->sanitize(implode(',', $TSelectedCats)).')'; diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index fbe706e93db..a1fd7a5b1dc 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -4535,8 +4535,8 @@ class Product extends CommonObject $sql .= " FROM ".MAIN_DB_PREFIX."product as p,"; $sql .= " ".MAIN_DB_PREFIX."product_association as pa"; $sql .= " WHERE p.rowid = pa.fk_product_fils"; - $sql .= " AND pa.fk_product_pere = ".$id; - $sql .= " AND pa.fk_product_fils != ".$id; // This should not happens, it is to avoid infinite loop if it happens + $sql .= " AND pa.fk_product_pere = ".((int) $id); + $sql .= " AND pa.fk_product_fils <> ".((int) $id); // This should not happens, it is to avoid infinite loop if it happens dol_syslog(get_class($this).'::getChildsArbo id='.$id.' level='.$level, LOG_DEBUG); diff --git a/htdocs/product/price.php b/htdocs/product/price.php index a08eaa8558b..7dfb94be79f 100644 --- a/htdocs/product/price.php +++ b/htdocs/product/price.php @@ -568,7 +568,7 @@ if (empty($reshook)) { if ($action == 'delete_customer_price' && ($user->rights->produit->supprimer || $user->rights->service->supprimer)) { // Delete price by customer - $prodcustprice->id = GETPOST('lineid'); + $prodcustprice->id = GETPOST('lineid', 'int'); $result = $prodcustprice->delete($user); if ($result < 0) { diff --git a/htdocs/product/stock/card.php b/htdocs/product/stock/card.php index 0a77a39a0df..0d3783dc161 100644 --- a/htdocs/product/stock/card.php +++ b/htdocs/product/stock/card.php @@ -137,7 +137,7 @@ if (empty($reshook)) { header("Location: ".$backtopage); exit; } else { - header("Location: card.php?id=".$id); + header("Location: card.php?id=".urlencode($id)); exit; } } else { diff --git a/htdocs/reception/class/reception.class.php b/htdocs/reception/class/reception.class.php index d5e3feaa255..946990f0c7b 100644 --- a/htdocs/reception/class/reception.class.php +++ b/htdocs/reception/class/reception.class.php @@ -1317,7 +1317,7 @@ class Reception extends CommonObject $sql = "SELECT em.rowid, em.code, em.libelle, em.description, em.tracking, em.active"; $sql .= " FROM ".MAIN_DB_PREFIX."c_shipment_mode as em"; if ($id != '') { - $sql .= " WHERE em.rowid=".$id; + $sql .= " WHERE em.rowid = ".((int) $id); } $resql = $this->db->query($sql); diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index 9c5d261f996..f79857d744f 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -292,7 +292,7 @@ if ($action == "change") { // Change customer for TakePOS $db->query($sql); } - $sql = "UPDATE ".MAIN_DB_PREFIX."facture set fk_soc=".$idcustomer." where ref='(PROV-POS".$_SESSION["takeposterminal"]."-".$place.")'"; + $sql = "UPDATE ".MAIN_DB_PREFIX."facture set fk_soc=".((int) $idcustomer)." where ref='(PROV-POS".$_SESSION["takeposterminal"]."-".$place.")'"; $resql = $db->query($sql); ?> - - + + - + + @@ -37,6 +41,10 @@ url = "swagger.json"; } + hljs.configure({ + highlightSizeThreshold: 5000 + }); + // Pre load translate... if(window.SwaggerTranslator) { window.SwaggerTranslator.translate(); @@ -51,8 +59,8 @@ clientId: "your-client-id", clientSecret: "your-client-secret-if-required", realm: "your-realms", - appName: "your-app-name", - scopeSeparator: ",", + appName: "your-app-name", + scopeSeparator: " ", additionalQueryStringParams: {} }); } @@ -60,11 +68,7 @@ if(window.SwaggerTranslator) { window.SwaggerTranslator.translate(); } - - $('pre code').each(function(i, e) { - hljs.highlightBlock(e) - }); - + addApiKeyAuthorization(); }, onFailure: function(data) { @@ -74,8 +78,12 @@ jsonEditor: false, apisSorter: "alpha", operationsSorter: "alpha", - defaultModelRendering: 'schema', - showRequestHeaders: false + defaultModelRendering: 'model', /* example or model or schema */ + defaultModelsExpandDepth: -1, + showRequestHeaders: false, + showOperationIds: false, + displayOperationIds: false, + displayRequestDuration: true }); function addApiKeyAuthorization(){ @@ -100,13 +108,7 @@ } $('#input_apiKey').change(addApiKeyAuthorization); - - // if you have an apiKey you would like to pre-populate on the page for demonstration purposes... - /* - var apiKey = "myApiKeyXXXX123456789"; - $('#input_apiKey').val(apiKey); - */ - + window.swaggerUi.load(); function log() { @@ -118,14 +120,14 @@ -
    '.$langs->trans("RangeOfLoginValidity").''; - if ($caneditfield) { - print $form->selectDate($datestartvalidity ? $datestartvalidity : $object->datestartvalidity, 'datestartvalidity', 0, 0, 1, 'formdatestartvalidity', 1, 1); - } else { - print dol_print_date($object->datestartvalidity, 'day'); - } - - if ($datestartvalidity && $dateendvalidity) { - print ' - '; - } - - if ($caneditfield) { - print $form->selectDate($dateendvalidity ? $datendevalidity : $object->dateendvalidity, 'dateendvalidity', 0, 0, 1, 'formdateendvalidity', 1, 0); - } else { - print dol_print_date($object->dateendvalidity, 'day'); - } - print '
    '.$langs->trans("DateOfBirth").''; From e780bae77f609ae760a2022c3b1460fac2ec779b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 25 Apr 2021 15:27:10 +0200 Subject: [PATCH 183/879] css --- htdocs/user/card.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/user/card.php b/htdocs/user/card.php index 9d2039a4678..b1a9a229827 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -1165,7 +1165,7 @@ if ($action == 'create' || $action == 'adduserldap') { // Signature print '
    '.$langs->trans("Signature").''; + print ''; require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; $doleditor = new DolEditor('signature', GETPOST('signature', 'restricthtml'), '', 138, 'dolibarr_notes', 'In', true, true, empty($conf->global->FCKEDITOR_ENABLE_USERSIGN) ? 0 : 1, ROWS_4, '90%'); print $doleditor->Create(1); @@ -1679,7 +1679,7 @@ if ($action == 'create' || $action == 'adduserldap') { } // Signature - print '
    '.$langs->trans('Signature').''; + print '
    '.$langs->trans('Signature').''; print dol_htmlentitiesbr($object->signature); print "
    '.$sqlupdate."