From ae692ccffd389a697ecfc5dedcc83f476353fea2 Mon Sep 17 00:00:00 2001 From: Lamrani Abdel Date: Tue, 16 Jan 2024 13:20:31 +0100 Subject: [PATCH 01/65] New display style for list of events of user --- htdocs/core/lib/usergroups.lib.php | 600 +++++++++++++++++++++++++++++ htdocs/user/info.php | 2 +- htdocs/user/messaging.php | 230 +++++++++++ 3 files changed, 831 insertions(+), 1 deletion(-) create mode 100644 htdocs/user/messaging.php diff --git a/htdocs/core/lib/usergroups.lib.php b/htdocs/core/lib/usergroups.lib.php index 185527eb4e8..2335424207d 100644 --- a/htdocs/core/lib/usergroups.lib.php +++ b/htdocs/core/lib/usergroups.lib.php @@ -1722,3 +1722,603 @@ function show_actions_done_user($conf, $langs, $db, $filterobj, $objcon = '', $n print $out; } } + +/** + * Show html area with actions in messaging format. + * Note: Global parameter $param must be defined. + * + * @param Conf $conf Object conf + * @param Translate $langs Object langs + * @param DoliDB $db Object db + * @param mixed $filterobj Filter on object Adherent|Societe|Project|Product|CommandeFournisseur|Dolresource|Ticket|... to list events linked to an object + * @param Contact $objcon Filter on object contact to filter events on a contact + * @param int $noprint Return string but does not output it + * @param string $actioncode Filter on actioncode + * @param string $donetodo Filter on event 'done' or 'todo' or ''=nofilter (all). + * @param array $filters Filter on other fields + * @param string $sortfield Sort field + * @param string $sortorder Sort order + * @return string|void Return html part or void if noprint is 1 + */ +function show_actions_messaging_user($conf, $langs, $db, $filterobj, $objcon = '', $noprint = 0, $actioncode = '', $donetodo = 'done', $filters = array(), $sortfield = 'a.datep,a.id', $sortorder = 'DESC') +{ + global $user, $conf; + global $form; + + global $param, $massactionbutton; + + dol_include_once('/comm/action/class/actioncomm.class.php'); + + // Check parameters + if (!is_object($filterobj) && !is_object($objcon)) { + dol_print_error('', 'BadParameter'); + } + + $histo = array(); + $numaction = 0; + $now = dol_now(); + + $sortfield_list = explode(',', $sortfield); + $sortfield_label_list = array('a.id' => 'id', 'a.datep' => 'dp', 'a.percent' => 'percent'); + $sortfield_new_list = array(); + foreach ($sortfield_list as $sortfield_value) { + $sortfield_new_list[] = $sortfield_label_list[trim($sortfield_value)]; + } + $sortfield_new = implode(',', $sortfield_new_list); + + if (isModEnabled('agenda')) { + // Search histo on actioncomm + if (is_object($objcon) && $objcon->id > 0) { + $sql = "SELECT DISTINCT a.id, a.label as label,"; + } else { + $sql = "SELECT a.id, a.label as label,"; + } + $sql .= " a.datep as dp,"; + $sql .= " a.note as message,"; + $sql .= " a.datep2 as dp2,"; + $sql .= " a.percent as percent, 'action' as type,"; + $sql .= " a.fk_element, a.elementtype,"; + $sql .= " a.email_from as msg_from,"; + $sql .= " c.code as acode, c.libelle as alabel, c.picto as apicto,"; + $sql .= " u.rowid as user_id, u.login as user_login, u.photo as user_photo, u.firstname as user_firstname, u.lastname as user_lastname"; + if (is_object($filterobj) && get_class($filterobj) == 'Societe') { + $sql .= ", sp.lastname, sp.firstname"; + } elseif (is_object($filterobj) && get_class($filterobj) == 'Adherent') { + $sql .= ", m.lastname, m.firstname"; + } elseif (is_object($filterobj) && get_class($filterobj) == 'CommandeFournisseur') { + $sql .= ", o.ref"; + } elseif (is_object($filterobj) && get_class($filterobj) == 'Product') { + $sql .= ", o.ref"; + } elseif (is_object($filterobj) && get_class($filterobj) == 'Ticket') { + $sql .= ", o.ref"; + } elseif (is_object($filterobj) && get_class($filterobj) == 'BOM') { + $sql .= ", o.ref"; + } elseif (is_object($filterobj) && get_class($filterobj) == 'Contrat') { + $sql .= ", o.ref"; + } + $sql .= " FROM ".MAIN_DB_PREFIX."actioncomm as a"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as u on u.rowid = a.fk_user_action"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_actioncomm as c ON a.fk_action = c.id"; + + $sql .= " WHERE a.entity IN (".getEntity('agenda').")"; + $sql .= " AND u.rowid = ". ((int) $filterobj->id); + + // Condition on actioncode + if (!empty($actioncode)) { + if (!getDolGlobalString('AGENDA_USE_EVENT_TYPE')) { + if ($actioncode == 'AC_NON_AUTO') { + $sql .= " AND c.type != 'systemauto'"; + } elseif ($actioncode == 'AC_ALL_AUTO') { + $sql .= " AND c.type = 'systemauto'"; + } else { + if ($actioncode == 'AC_OTH') { + $sql .= " AND c.type != 'systemauto'"; + } elseif ($actioncode == 'AC_OTH_AUTO') { + $sql .= " AND c.type = 'systemauto'"; + } + } + } else { + if ($actioncode == 'AC_NON_AUTO') { + $sql .= " AND c.type != 'systemauto'"; + } elseif ($actioncode == 'AC_ALL_AUTO') { + $sql .= " AND c.type = 'systemauto'"; + } else { + $sql .= " AND c.code = '".$db->escape($actioncode)."'"; + } + } + } + if ($donetodo == 'todo') { + $sql .= " AND ((a.percent >= 0 AND a.percent < 100) OR (a.percent = -1 AND a.datep > '".$db->idate($now)."'))"; + } elseif ($donetodo == 'done') { + $sql .= " AND (a.percent = 100 OR (a.percent = -1 AND a.datep <= '".$db->idate($now)."'))"; + } + if (is_array($filters) && $filters['search_agenda_label']) { + $sql .= natural_search('a.label', $filters['search_agenda_label']); + } + } + + + if (!empty($sql) && !empty($sql2)) { + $sql = $sql." UNION ".$sql2; + } elseif (empty($sql) && !empty($sql2)) { + $sql = $sql2; + } + + // TODO Add limit in nb of results + if ($sql) { // May not be defined if module Agenda is not enabled and mailing module disabled too + $sql .= $db->order($sortfield_new, $sortorder); + dol_syslog("function.lib::show_actions_messaging", LOG_DEBUG); + $resql = $db->query($sql); + if ($resql) { + $i = 0; + $num = $db->num_rows($resql); + + while ($i < $num) { + $obj = $db->fetch_object($resql); + + if ($obj->type == 'action') { + $contactaction = new ActionComm($db); + $contactaction->id = $obj->id; + $result = $contactaction->fetchResources(); + if ($result < 0) { + dol_print_error($db); + setEventMessage("actions.lib::show_actions_messaging Error fetch resource", 'errors'); + } + + //if ($donetodo == 'todo') $sql.= " AND ((a.percent >= 0 AND a.percent < 100) OR (a.percent = -1 AND a.datep > '".$db->idate($now)."'))"; + //elseif ($donetodo == 'done') $sql.= " AND (a.percent = 100 OR (a.percent = -1 AND a.datep <= '".$db->idate($now)."'))"; + $tododone = ''; + if (($obj->percent >= 0 and $obj->percent < 100) || ($obj->percent == -1 && $obj->dp > $now)) { + $tododone = 'todo'; + } + + $histo[$numaction] = array( + 'type'=>$obj->type, + 'tododone'=>$tododone, + 'id'=>$obj->id, + 'datestart'=>$db->jdate($obj->dp), + 'dateend'=>$db->jdate($obj->dp2), + 'note'=>$obj->label, + 'message'=>$obj->message, + 'percent'=>$obj->percent, + + 'userid'=>$obj->user_id, + 'login'=>$obj->user_login, + 'userfirstname'=>$obj->user_firstname, + 'userlastname'=>$obj->user_lastname, + 'userphoto'=>$obj->user_photo, + 'msg_from'=>$obj->msg_from, + + 'contact_id'=>$obj->fk_contact, + 'socpeopleassigned' => $contactaction->socpeopleassigned, + 'lastname' => (empty($obj->lastname) ? '' : $obj->lastname), + 'firstname' => (empty($obj->firstname) ? '' : $obj->firstname), + 'fk_element'=>$obj->fk_element, + 'elementtype'=>$obj->elementtype, + // Type of event + 'acode'=>$obj->acode, + 'alabel'=>$obj->alabel, + 'libelle'=>$obj->alabel, // deprecated + 'apicto'=>$obj->apicto + ); + } else { + $histo[$numaction] = array( + 'type'=>$obj->type, + 'tododone'=>'done', + 'id'=>$obj->id, + 'datestart'=>$db->jdate($obj->dp), + 'dateend'=>$db->jdate($obj->dp2), + 'note'=>$obj->label, + 'message'=>$obj->message, + 'percent'=>$obj->percent, + 'acode'=>$obj->acode, + + 'userid'=>$obj->user_id, + 'login'=>$obj->user_login, + 'userfirstname'=>$obj->user_firstname, + 'userlastname'=>$obj->user_lastname, + 'userphoto'=>$obj->user_photo + ); + } + + $numaction++; + $i++; + } + } else { + dol_print_error($db); + } + } + + // Set $out to show events + $out = ''; + + if (!isModEnabled('agenda')) { + $langs->loadLangs(array("admin", "errors")); + $out = info_admin($langs->trans("WarningModuleXDisabledSoYouMayMissEventHere", $langs->transnoentitiesnoconv("Module2400Name")), 0, 0, 'warning'); + } + + if (isModEnabled('agenda') || (isModEnabled('mailing') && !empty($objcon->email))) { + $delay_warning = $conf->global->MAIN_DELAY_ACTIONS_TODO * 24 * 60 * 60; + + require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; + include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; + require_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'; + require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; + + $formactions = new FormActions($db); + + $actionstatic = new ActionComm($db); + $userstatic = new User($db); + $contactstatic = new Contact($db); + $userGetNomUrlCache = array(); + $contactGetNomUrlCache = array(); + + $out .= '
'; + $out .= '
'; + $out .= ''; + + if ($objcon && get_class($objcon) == 'User' && + (is_null($filterobj) || get_class($filterobj) == 'User')) { + $out .= ''; + } else { + $out .= ''; + } + if ($filterobj && get_class($filterobj) == 'User') { + $out .= ''; + } + + $out .= "\n"; + + $out .= '
'; + $out .= ''; + + $out .= ''; + + // Action column + if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + $out .= ''; + } + + $out .= getTitleFieldOfList('Date', 0, $_SERVER["PHP_SELF"], 'a.datep', '', $param, '', $sortfield, $sortorder, '')."\n"; + + $out .= ''; + if ($donetodo) { + $out .= ''; + } + $out .= ''; + $out .= ''; + + // Action column + if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + $out .= ''; + } + + $out .= ''; + + + $out .= '
'; + $searchpicto = $form->showFilterAndCheckAddButtons($massactionbutton ? 1 : 0, 'checkforselect', 1); + $out .= $searchpicto; + $out .= ''.$langs->trans("Search").' : '; + $out .= ''; + //$out .= img_picto($langs->trans("Type"), 'type'); + $out .= $formactions->select_type_actions($actioncode, "actioncode", '', !getDolGlobalString('AGENDA_USE_EVENT_TYPE') ? 1 : -1, 0, 0, 1, 'minwidth200imp'); + $out .= ''; + $out .= ''; + $out .= ''; + $searchpicto = $form->showFilterAndCheckAddButtons($massactionbutton ? 1 : 0, 'checkforselect', 1); + $out .= $searchpicto; + $out .= '
'; + + $out .= ''; + $out .= '
'; + + $out .= "\n"; + + $out .= '\n"; + + if (empty($histo)) { + $out .= ''.$langs->trans("NoRecordFound").''; + } + } + + if ($noprint) { + return $out; + } else { + print $out; + } +} diff --git a/htdocs/user/info.php b/htdocs/user/info.php index 8cfdcdf20d0..436b2d363f9 100644 --- a/htdocs/user/info.php +++ b/htdocs/user/info.php @@ -172,7 +172,7 @@ if ((!empty($objUser->id) || !empty($objcon->id)) && $permok) { $morehtmlright = ''; -$messagingUrl = DOL_URL_ROOT.'/societe/messaging.php?userid='.$object->id; +$messagingUrl = DOL_URL_ROOT.'/user/messaging.php?userid='.$object->id; $morehtmlright .= dolGetButtonTitle($langs->trans('ShowAsConversation'), '', 'fa fa-comments imgforviewmode', $messagingUrl, '', 1); $messagingUrl = DOL_URL_ROOT.'/user/info.php?id='.$object->id; $morehtmlright .= dolGetButtonTitle($langs->trans('MessageListViewType'), '', 'fa fa-bars imgforviewmode', $messagingUrl, '', 2); diff --git a/htdocs/user/messaging.php b/htdocs/user/messaging.php new file mode 100644 index 00000000000..ebb5b93804a --- /dev/null +++ b/htdocs/user/messaging.php @@ -0,0 +1,230 @@ + + * Copyright (C) 2005 Brice Davoleau + * Copyright (C) 2005-2012 Regis Houssin + * Copyright (C) 2006-2019 Laurent Destailleur + * Copyright (C) 2007 Patrick Raguin + * Copyright (C) 2010 Juanjo Menent + * Copyright (C) 2015 Marcos García + * + * 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/societe/messaging.php + * \ingroup societe + * \brief Page of third party events + */ + +// Load Dolibarr environment +require '../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/usergroups.lib.php'; + +// Load translation files required by the page +$langs->loadLangs(array('agenda', 'bills', 'companies', 'orders', 'propal')); + +$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'useragenda'; + +if (GETPOST('actioncode', 'array')) { + $actioncode = GETPOST('actioncode', 'array', 3); + if (!count($actioncode)) { + $actioncode = '0'; + } +} else { + $actioncode = GETPOST("actioncode", "alpha", 3) ? GETPOST("actioncode", "alpha", 3) : (GETPOST("actioncode") == '0' ? '0' : getDolGlobalString('AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT')); +} + +$search_rowid = GETPOST('search_rowid'); +$search_agenda_label = GETPOST('search_agenda_label'); + +$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; +$sortfield = GETPOST('sortfield', 'aZ09comma'); +$sortorder = GETPOST('sortorder', 'aZ09comma'); +$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); +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 = 'a.datep,a.id'; +} +if (!$sortorder) { + $sortorder = 'DESC,DESC'; +} + +// Initialize technical objects +$object = new User($db); +if ($id > 0 || !empty($ref)) { + $result = $object->fetch($id, $ref, '', 1); + $object->getrights(); +} + +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context +$hookmanager->initHooks(array('agendathirdparty', 'globalcard')); + +// Security check +$userid = GETPOST('userid', 'int'); +if ($user->id) { + $userId = $user->id; +} + +$result = $object->fetch($userid); +if ($result <= 0) { + accessforbidden('User not found'); +} + +$result = restrictedArea($user, 'user', $userId, '&user'); + + + +/* + * Actions + */ + +$parameters = array('id'=>$socid); +$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'); +} + +if (empty($reshook)) { + // Cancel + if (GETPOST('cancel', 'alpha') && !empty($backtopage)) { + header("Location: ".$backtopage); + exit; + } + + // Purge search criteria + 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 + $actioncode = ''; + $search_agenda_label = ''; + } +} + + +/* + * View + */ + +$form = new Form($db); + +$person_name = !empty($object->firstname) ? $object->lastname.", ".$object->firstname : $object->lastname; +$title = $person_name." - ".$langs->trans('Info'); +$help_url = ''; +llxHeader('', $title, $help_url); + +$head = user_prepare_head($object); + +$title = $langs->trans("User"); +print dol_get_fiche_head($head, 'info', $title, -1, 'user'); + + +$linkback = ''; + +if ($user->hasRight('user', 'user', 'lire') || $user->admin) { + $linkback = ''.$langs->trans("BackToList").''; +} + +$morehtmlref = ''; +$morehtmlref .= img_picto($langs->trans("Download").' '.$langs->trans("VCard"), 'vcard.png', 'class="valignmiddle marginleftonly paddingrightonly"'); +$morehtmlref .= ''; + +$urltovirtualcard = '/user/virtualcard.php?id='.((int) $object->id); +$morehtmlref .= dolButtonToOpenUrlInDialogPopup('publicvirtualcard', $langs->transnoentitiesnoconv("PublicVirtualCardUrl").' - '.$object->getFullName($langs), img_picto($langs->trans("PublicVirtualCardUrl"), 'card', 'class="valignmiddle marginleftonly paddingrightonly"'), $urltovirtualcard, '', 'nohover'); + +dol_banner_tab($object, 'id', $linkback, $user->hasRight('user', 'user', 'lire') || $user->admin, 'rowid', 'ref', $morehtmlref); + + +$object->info($userid); + + +print '
'; +print '
'; + +print '
'; + +dol_print_object_info($object); + +print '
'; + + +print dol_get_fiche_end(); + +$objUser = $object; +$objcon = new stdClass(); + +$out = ''; +$permok = $user->hasRight('agenda', 'myactions', 'create'); +if ((!empty($objUser->id) || !empty($objcon->id)) && $permok) { + if (is_object($objUser) && get_class($objUser) == 'User') { + $out .= '&originid='.$objUser->id.($objUser->id > 0 ? '&userid='.$objUser->id : '').'&backtopage='.urlencode($_SERVER['PHP_SELF'].($objUser->id > 0 ? '?userid='.$objUser->id : '')); + } + $out .= (!empty($objcon->id) ? '&contactid='.$objcon->id : ''); + $out .= '&datep='.dol_print_date(dol_now(), 'dayhourlog', 'tzuserrel'); +} + +$morehtmlright = ''; + +$messagingUrl = DOL_URL_ROOT.'/user/messaging.php?userid='.$object->id; +$morehtmlright .= dolGetButtonTitle($langs->trans('ShowAsConversation'), '', 'fa fa-comments imgforviewmode', $messagingUrl, '', 1); +$messagingUrl = DOL_URL_ROOT.'/user/info.php?id='.$object->id; +$morehtmlright .= dolGetButtonTitle($langs->trans('MessageListViewType'), '', 'fa fa-bars imgforviewmode', $messagingUrl, '', 2); + +if (isModEnabled('agenda')) { + if ($user->hasRight('agenda', 'myactions', 'create') || $user->hasRight('agenda', 'allactions', 'create')) { + $morehtmlright .= dolGetButtonTitle($langs->trans('AddAction'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/comm/action/card.php?action=create'.$out); + } +} + +if (isModEnabled('agenda') && ($user->hasRight('agenda', 'myactions', 'read') || $user->hasRight('agenda', 'allaactions', 'read'))) { + print '
'; + $param = '&userid='.urlencode($userid); + if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { + $param .= '&contextpage='.urlencode($contextpage); + } + if ($limit > 0 && $limit != $conf->liste_limit) { + $param .= '&limit='.((int) $limit); + } + + + // Try to know count of actioncomm from cache + require_once DOL_DOCUMENT_ROOT.'/core/lib/memory.lib.php'; + $cachekey = 'count_events_user_'.$object->id; + $nbEvent = dol_getcache($cachekey); + + $titlelist = $langs->trans("ActionsOnCompany").(is_numeric($nbEvent) ? '('.$nbEvent.')' : ''); + if (!empty($conf->dol_optimize_smallscreen)) { + $titlelist = $langs->trans("Actions").(is_numeric($nbEvent) ? '('.$nbEvent.')' : ''); + } + + print_barre_liste($titlelist, 0, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, '', 0, -1, '', 0, $morehtmlright, '', 0, 1, 0); + + // List of all actions + $filters = array(); + $filters['search_agenda_label'] = $search_agenda_label; + $filters['search_rowid'] = $search_rowid; + + show_actions_messaging_user($conf, $langs, $db, $object, null, 0, $actioncode, '', $filters, $sortfield, $sortorder); +} + + //End of page + llxFooter(); + $db->close(); From aa706fb4a80a860c6771d046c6c9890e238a243c Mon Sep 17 00:00:00 2001 From: Lamrani Abdel Date: Wed, 17 Jan 2024 17:54:56 +0100 Subject: [PATCH 02/65] fix tag problem --- htdocs/core/class/html.formmail.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index 1f99b92d214..5e6a5bc5cc3 100644 --- a/htdocs/core/class/html.formmail.class.php +++ b/htdocs/core/class/html.formmail.class.php @@ -755,7 +755,7 @@ class FormMail extends Form if (!empty($this->withtoccuser) && is_array($this->withtoccuser) && getDolGlobalString('MAIN_MAIL_ENABLED_USER_DEST_SELECT')) { $out .= ''; $out .= $langs->trans("MailToCCUsers"); - $out .= '<>'; + $out .= ''; // multiselect array convert html entities into options tags, even if we don't want this, so we encode them a second time $tmparray = $this->withtoccuser; From 0c63d5ce4f88c8ca30ba99caabf02b33bed50564 Mon Sep 17 00:00:00 2001 From: Lamrani Abdel Date: Wed, 17 Jan 2024 18:02:01 +0100 Subject: [PATCH 03/65] fix condition problem --- htdocs/core/class/html.formmail.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index 5e6a5bc5cc3..6e28ccd699c 100644 --- a/htdocs/core/class/html.formmail.class.php +++ b/htdocs/core/class/html.formmail.class.php @@ -889,7 +889,7 @@ class FormMail extends Form //input prompt AI require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; - if (isModEnabled('ai') && $apiKey = dolibarr_get_const($this->db, 'AI_CHATGPT_API_KEY', 0)) { + if (isModEnabled('ai') && dolibarr_get_const($this->db, 'AI_CHATGPT_API_KEY', 0)) { $out .= $this->getHtmlForInstruction(); } // Message From 1f647b7c66310c3bebcb505bdfeb7929eb8f8c0a Mon Sep 17 00:00:00 2001 From: Lamrani Abdel Date: Thu, 18 Jan 2024 14:27:17 +0100 Subject: [PATCH 04/65] fix td tag --- htdocs/core/class/html.formmail.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index 6e28ccd699c..d00c5f85d65 100644 --- a/htdocs/core/class/html.formmail.class.php +++ b/htdocs/core/class/html.formmail.class.php @@ -755,7 +755,7 @@ class FormMail extends Form if (!empty($this->withtoccuser) && is_array($this->withtoccuser) && getDolGlobalString('MAIN_MAIL_ENABLED_USER_DEST_SELECT')) { $out .= ''; $out .= $langs->trans("MailToCCUsers"); - $out .= ''; + $out .= ''; // multiselect array convert html entities into options tags, even if we don't want this, so we encode them a second time $tmparray = $this->withtoccuser; From 52e70d491694ccebe9b8142c8e1463f182529761 Mon Sep 17 00:00:00 2001 From: ATM-Lucas Date: Mon, 22 Jan 2024 16:59:28 +0100 Subject: [PATCH 05/65] Default Workstation ok --- htdocs/bom/ajax/ajax.php | 22 ++++++++++++++++++++++ htdocs/bom/class/bom.class.php | 2 +- htdocs/bom/tpl/objectline_create.tpl.php | 19 +++++++++++++++++-- 3 files changed, 40 insertions(+), 3 deletions(-) diff --git a/htdocs/bom/ajax/ajax.php b/htdocs/bom/ajax/ajax.php index 9a55c609252..e201a0ff288 100644 --- a/htdocs/bom/ajax/ajax.php +++ b/htdocs/bom/ajax/ajax.php @@ -65,3 +65,25 @@ if ($action == 'getDurationUnitByProduct' && $user->hasRight('product', 'lire')) echo json_encode($fk_unit); exit(); } + +if ($action == 'getWorkstationByProduct' && $user->hasRight('product', 'lire')) { + $product = new Product($db); + $res = $product->fetch($idproduct); + + $result = array(); + + + if($res < 0){ + $error = 'SQL ERROR'; + }elseif($res == 0){ + $error = 'NOT FOUND'; + }else{ + $error = null; + $result['defaultWk']=$product->fk_default_workstation; + } + + $result['error']=$error; + + echo json_encode($result); + exit(); +} diff --git a/htdocs/bom/class/bom.class.php b/htdocs/bom/class/bom.class.php index 507134881ce..09596ed600f 100644 --- a/htdocs/bom/class/bom.class.php +++ b/htdocs/bom/class/bom.class.php @@ -792,7 +792,7 @@ class BOM extends CommonObject $line->array_options[$key] = $array_options[$key]; } } - if ($fk_default_workstation > 0 && $line->fk_default_workstation != $fk_default_workstation) { + if ($line->fk_default_workstation != $fk_default_workstation) { $line->fk_default_workstation = $fk_default_workstation; } diff --git a/htdocs/bom/tpl/objectline_create.tpl.php b/htdocs/bom/tpl/objectline_create.tpl.php index db3991eac7d..cb05d062e9d 100644 --- a/htdocs/bom/tpl/objectline_create.tpl.php +++ b/htdocs/bom/tpl/objectline_create.tpl.php @@ -185,7 +185,7 @@ if ($filtertype != 1) { $coldisplay++; print ''; - print ' '; + print $formproduct->selectWorkstations('', 'idworkstations', 1); print ''; $coldisplay++; @@ -235,6 +235,7 @@ jQuery(document).ready(function() { ,type: 'POST' ,data: { 'action': 'getDurationUnitByProduct' + ,'token' : "" ,'idproduct' : idproduct } }).done(function(data) { @@ -242,7 +243,21 @@ jQuery(document).ready(function() { console.log(data); var data = JSON.parse(data); $("#fk_unit").val(data).change(); - }); + }); + + $.ajax({ + url : "" + ,type: 'POST' + ,data: { + 'action': 'getWorkstationByProduct' + ,'token' : "" + ,'idproduct' : idproduct + } + }).done(function(data) { + var data = JSON.parse(data); + $('#idworkstations').val(data.defaultWk).select2(); + + }); }); }); From aa914dbe44ebf6ed2f89fb341911a031320c1855 Mon Sep 17 00:00:00 2001 From: ATM-Lucas Date: Tue, 23 Jan 2024 11:39:01 +0100 Subject: [PATCH 06/65] Travis fix --- htdocs/bom/ajax/ajax.php | 29 ++++++++++++------------ htdocs/bom/tpl/objectline_create.tpl.php | 14 ++++++------ 2 files changed, 21 insertions(+), 22 deletions(-) diff --git a/htdocs/bom/ajax/ajax.php b/htdocs/bom/ajax/ajax.php index e201a0ff288..ef30f0e8081 100644 --- a/htdocs/bom/ajax/ajax.php +++ b/htdocs/bom/ajax/ajax.php @@ -67,23 +67,22 @@ if ($action == 'getDurationUnitByProduct' && $user->hasRight('product', 'lire')) } if ($action == 'getWorkstationByProduct' && $user->hasRight('product', 'lire')) { - $product = new Product($db); - $res = $product->fetch($idproduct); + $product = new Product($db); + $res = $product->fetch($idproduct); - $result = array(); + $result = array(); + if ($res < 0) { + $error = 'SQL ERROR'; + }elseif($res == 0){ + $error = 'NOT FOUND'; + }else{ + $error = null; + $result['defaultWk']=$product->fk_default_workstation; + } - if($res < 0){ - $error = 'SQL ERROR'; - }elseif($res == 0){ - $error = 'NOT FOUND'; - }else{ - $error = null; - $result['defaultWk']=$product->fk_default_workstation; - } + $result['error']=$error; - $result['error']=$error; - - echo json_encode($result); - exit(); + echo json_encode($result); + exit(); } diff --git a/htdocs/bom/tpl/objectline_create.tpl.php b/htdocs/bom/tpl/objectline_create.tpl.php index cb05d062e9d..9c59338fa69 100644 --- a/htdocs/bom/tpl/objectline_create.tpl.php +++ b/htdocs/bom/tpl/objectline_create.tpl.php @@ -185,7 +185,7 @@ if ($filtertype != 1) { $coldisplay++; print ''; - print $formproduct->selectWorkstations('', 'idworkstations', 1); + print $formproduct->selectWorkstations('', 'idworkstations', 1); print ''; $coldisplay++; @@ -235,7 +235,7 @@ jQuery(document).ready(function() { ,type: 'POST' ,data: { 'action': 'getDurationUnitByProduct' - ,'token' : "" + ,'token' : "" ,'idproduct' : idproduct } }).done(function(data) { @@ -243,21 +243,21 @@ jQuery(document).ready(function() { console.log(data); var data = JSON.parse(data); $("#fk_unit").val(data).change(); - }); + }); - $.ajax({ + $.ajax({ url : "" ,type: 'POST' ,data: { 'action': 'getWorkstationByProduct' - ,'token' : "" + ,'token' : "" ,'idproduct' : idproduct } }).done(function(data) { var data = JSON.parse(data); - $('#idworkstations').val(data.defaultWk).select2(); + $('#idworkstations').val(data.defaultWk).select2(); - }); + }); }); }); From f90abf8a90466e4ed78e5e009a60714ace840af2 Mon Sep 17 00:00:00 2001 From: ATM-Lucas Date: Tue, 23 Jan 2024 11:52:49 +0100 Subject: [PATCH 07/65] Fix codesniffer --- htdocs/bom/ajax/ajax.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/bom/ajax/ajax.php b/htdocs/bom/ajax/ajax.php index ef30f0e8081..aa37ac33aa7 100644 --- a/htdocs/bom/ajax/ajax.php +++ b/htdocs/bom/ajax/ajax.php @@ -74,9 +74,9 @@ if ($action == 'getWorkstationByProduct' && $user->hasRight('product', 'lire')) if ($res < 0) { $error = 'SQL ERROR'; - }elseif($res == 0){ + } elseif ($res == 0) { $error = 'NOT FOUND'; - }else{ + } else { $error = null; $result['defaultWk']=$product->fk_default_workstation; } From 46fc369f38f73cd5975c8138f1beaa7d95f95863 Mon Sep 17 00:00:00 2001 From: William Mead Date: Wed, 24 Jan 2024 16:35:56 +0100 Subject: [PATCH 08/65] Fixed PHPDoc --- htdocs/societe/class/societeaccount.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/societe/class/societeaccount.class.php b/htdocs/societe/class/societeaccount.class.php index 62219b6d990..04ca7bad2c8 100644 --- a/htdocs/societe/class/societeaccount.class.php +++ b/htdocs/societe/class/societeaccount.class.php @@ -45,7 +45,7 @@ class SocieteAccount extends CommonObject public $table_element = 'societe_account'; /** - * @var array Does societeaccount support multicompany module ? 0=No test on entity, 1=Test with field entity, 2=Test with link by societe + * @var int Does societeaccount support multicompany module ? 0=No test on entity, 1=Test with field entity, 2=Test with link by societe */ public $ismultientitymanaged = 0; From d74af432a0b47b807684c72bf5177eec8406efb9 Mon Sep 17 00:00:00 2001 From: Maximilien Valenzano Date: Wed, 24 Jan 2024 18:15:51 +0100 Subject: [PATCH 09/65] fix: add product line update fields price --- htdocs/core/tpl/objectline_create.tpl.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/htdocs/core/tpl/objectline_create.tpl.php b/htdocs/core/tpl/objectline_create.tpl.php index 42377634ff9..f6afeeb8457 100644 --- a/htdocs/core/tpl/objectline_create.tpl.php +++ b/htdocs/core/tpl/objectline_create.tpl.php @@ -640,6 +640,7 @@ if (!empty($usemargins) && $user->rights->margins->creer) { if (event.which != 9 && (event.which < 37 ||event.which > 40) && jQuery("#price_ht").val() != '') { jQuery("#price_ttc").val(''); jQuery("#multicurrency_subprice").val(''); + jQuery("#multicurrency_price_ht").val(''); } }); jQuery("#price_ttc").keyup(function(event) { @@ -647,11 +648,19 @@ if (!empty($usemargins) && $user->rights->margins->creer) { if (event.which != 9 && (event.which < 37 || event.which > 40) && jQuery("#price_ttc").val() != '') { jQuery("#price_ht").val(''); jQuery("#multicurrency_subprice").val(''); + jQuery("#multicurrency_price_ht").val(''); } }); jQuery("#multicurrency_subprice").keyup(function(event) { // console.log(event.which); // discard event tag and arrows - if (event.which != 9 && (event.which < 37 || event.which > 40) && jQuery("#price_ttc").val() != '') { + if (event.which != 9 && (event.which < 37 || event.which > 40) && jQuery("#multicurrency_subprice").val() != '') { + jQuery("#price_ht").val(''); + jQuery("#price_ttc").val(''); + } + }); + jQuery("#multicurrency_price_ht").keyup(function(event) { + // console.log(event.which); // discard event tag and arrows + if (event.which != 9 && (event.which < 37 || event.which > 40) && jQuery("#multicurrency_price_ht").val() != '') { jQuery("#price_ht").val(''); jQuery("#price_ttc").val(''); } From ce2a606d28bdca13eb49ddc6eb1d9b22eba23b57 Mon Sep 17 00:00:00 2001 From: Lamrani Abdel Date: Wed, 24 Jan 2024 18:18:10 +0100 Subject: [PATCH 10/65] remove functionmessaging user and update function show_actions_messaging --- htdocs/core/lib/functions.lib.php | 18 +- htdocs/core/lib/usergroups.lib.php | 600 ----------------------------- htdocs/user/messaging.php | 2 +- 3 files changed, 17 insertions(+), 603 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 5921f5a33ed..5ad7c2a0cb0 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -12782,7 +12782,11 @@ function show_actions_messaging($conf, $langs, $db, $filterobj, $objcon = '', $n $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as u on u.rowid = a.fk_user_action"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_actioncomm as c ON a.fk_action = c.id"; - $force_filter_contact = false; + if (get_class($filterobj) !== 'User') { + $force_filter_contact = false; + } else { + $force_filter_contact = true; + } if (is_object($objcon) && $objcon->id > 0) { $force_filter_contact = true; $sql .= " INNER JOIN ".MAIN_DB_PREFIX."actioncomm_resources as r ON a.id = r.fk_actioncomm"; @@ -12847,6 +12851,8 @@ function show_actions_messaging($conf, $langs, $db, $filterobj, $objcon = '', $n $sql .= " AND a.fk_element = ".((int) $filterobj->id); } } + } else { + $sql .= " AND u.rowid = ". ((int) $filterobj->id); } // Condition on actioncode @@ -13036,8 +13042,10 @@ function show_actions_messaging($conf, $langs, $db, $filterobj, $objcon = '', $n } else { $out .= ''; } - if ($filterobj && get_class($filterobj) == 'Societe') { + if (($filterobj && get_class($filterobj) == 'Societe')) { $out .= ''; + } else { + $out .= ''; } $out .= "\n"; @@ -13095,6 +13103,9 @@ function show_actions_messaging($conf, $langs, $db, $filterobj, $objcon = '', $n if (get_class($filterobj) == 'Societe') { $tmp .= ''; } + if (get_class($filterobj) == 'User') { + $tmp .= ''; + } $tmp .= ($donetodo != 'done' ? $langs->trans("ActionsToDoShort") : ''); $tmp .= ($donetodo != 'done' && $donetodo != 'todo' ? ' / ' : ''); $tmp .= ($donetodo != 'todo' ? $langs->trans("ActionsDoneShort") : ''); @@ -13102,6 +13113,9 @@ function show_actions_messaging($conf, $langs, $db, $filterobj, $objcon = '', $n if (get_class($filterobj) == 'Societe') { $tmp .= ''; } + if (get_class($filterobj) == 'User') { + $tmp .= ''; + } $out .= getTitleFieldOfList($tmp); } diff --git a/htdocs/core/lib/usergroups.lib.php b/htdocs/core/lib/usergroups.lib.php index 2335424207d..185527eb4e8 100644 --- a/htdocs/core/lib/usergroups.lib.php +++ b/htdocs/core/lib/usergroups.lib.php @@ -1722,603 +1722,3 @@ function show_actions_done_user($conf, $langs, $db, $filterobj, $objcon = '', $n print $out; } } - -/** - * Show html area with actions in messaging format. - * Note: Global parameter $param must be defined. - * - * @param Conf $conf Object conf - * @param Translate $langs Object langs - * @param DoliDB $db Object db - * @param mixed $filterobj Filter on object Adherent|Societe|Project|Product|CommandeFournisseur|Dolresource|Ticket|... to list events linked to an object - * @param Contact $objcon Filter on object contact to filter events on a contact - * @param int $noprint Return string but does not output it - * @param string $actioncode Filter on actioncode - * @param string $donetodo Filter on event 'done' or 'todo' or ''=nofilter (all). - * @param array $filters Filter on other fields - * @param string $sortfield Sort field - * @param string $sortorder Sort order - * @return string|void Return html part or void if noprint is 1 - */ -function show_actions_messaging_user($conf, $langs, $db, $filterobj, $objcon = '', $noprint = 0, $actioncode = '', $donetodo = 'done', $filters = array(), $sortfield = 'a.datep,a.id', $sortorder = 'DESC') -{ - global $user, $conf; - global $form; - - global $param, $massactionbutton; - - dol_include_once('/comm/action/class/actioncomm.class.php'); - - // Check parameters - if (!is_object($filterobj) && !is_object($objcon)) { - dol_print_error('', 'BadParameter'); - } - - $histo = array(); - $numaction = 0; - $now = dol_now(); - - $sortfield_list = explode(',', $sortfield); - $sortfield_label_list = array('a.id' => 'id', 'a.datep' => 'dp', 'a.percent' => 'percent'); - $sortfield_new_list = array(); - foreach ($sortfield_list as $sortfield_value) { - $sortfield_new_list[] = $sortfield_label_list[trim($sortfield_value)]; - } - $sortfield_new = implode(',', $sortfield_new_list); - - if (isModEnabled('agenda')) { - // Search histo on actioncomm - if (is_object($objcon) && $objcon->id > 0) { - $sql = "SELECT DISTINCT a.id, a.label as label,"; - } else { - $sql = "SELECT a.id, a.label as label,"; - } - $sql .= " a.datep as dp,"; - $sql .= " a.note as message,"; - $sql .= " a.datep2 as dp2,"; - $sql .= " a.percent as percent, 'action' as type,"; - $sql .= " a.fk_element, a.elementtype,"; - $sql .= " a.email_from as msg_from,"; - $sql .= " c.code as acode, c.libelle as alabel, c.picto as apicto,"; - $sql .= " u.rowid as user_id, u.login as user_login, u.photo as user_photo, u.firstname as user_firstname, u.lastname as user_lastname"; - if (is_object($filterobj) && get_class($filterobj) == 'Societe') { - $sql .= ", sp.lastname, sp.firstname"; - } elseif (is_object($filterobj) && get_class($filterobj) == 'Adherent') { - $sql .= ", m.lastname, m.firstname"; - } elseif (is_object($filterobj) && get_class($filterobj) == 'CommandeFournisseur') { - $sql .= ", o.ref"; - } elseif (is_object($filterobj) && get_class($filterobj) == 'Product') { - $sql .= ", o.ref"; - } elseif (is_object($filterobj) && get_class($filterobj) == 'Ticket') { - $sql .= ", o.ref"; - } elseif (is_object($filterobj) && get_class($filterobj) == 'BOM') { - $sql .= ", o.ref"; - } elseif (is_object($filterobj) && get_class($filterobj) == 'Contrat') { - $sql .= ", o.ref"; - } - $sql .= " FROM ".MAIN_DB_PREFIX."actioncomm as a"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as u on u.rowid = a.fk_user_action"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_actioncomm as c ON a.fk_action = c.id"; - - $sql .= " WHERE a.entity IN (".getEntity('agenda').")"; - $sql .= " AND u.rowid = ". ((int) $filterobj->id); - - // Condition on actioncode - if (!empty($actioncode)) { - if (!getDolGlobalString('AGENDA_USE_EVENT_TYPE')) { - if ($actioncode == 'AC_NON_AUTO') { - $sql .= " AND c.type != 'systemauto'"; - } elseif ($actioncode == 'AC_ALL_AUTO') { - $sql .= " AND c.type = 'systemauto'"; - } else { - if ($actioncode == 'AC_OTH') { - $sql .= " AND c.type != 'systemauto'"; - } elseif ($actioncode == 'AC_OTH_AUTO') { - $sql .= " AND c.type = 'systemauto'"; - } - } - } else { - if ($actioncode == 'AC_NON_AUTO') { - $sql .= " AND c.type != 'systemauto'"; - } elseif ($actioncode == 'AC_ALL_AUTO') { - $sql .= " AND c.type = 'systemauto'"; - } else { - $sql .= " AND c.code = '".$db->escape($actioncode)."'"; - } - } - } - if ($donetodo == 'todo') { - $sql .= " AND ((a.percent >= 0 AND a.percent < 100) OR (a.percent = -1 AND a.datep > '".$db->idate($now)."'))"; - } elseif ($donetodo == 'done') { - $sql .= " AND (a.percent = 100 OR (a.percent = -1 AND a.datep <= '".$db->idate($now)."'))"; - } - if (is_array($filters) && $filters['search_agenda_label']) { - $sql .= natural_search('a.label', $filters['search_agenda_label']); - } - } - - - if (!empty($sql) && !empty($sql2)) { - $sql = $sql." UNION ".$sql2; - } elseif (empty($sql) && !empty($sql2)) { - $sql = $sql2; - } - - // TODO Add limit in nb of results - if ($sql) { // May not be defined if module Agenda is not enabled and mailing module disabled too - $sql .= $db->order($sortfield_new, $sortorder); - dol_syslog("function.lib::show_actions_messaging", LOG_DEBUG); - $resql = $db->query($sql); - if ($resql) { - $i = 0; - $num = $db->num_rows($resql); - - while ($i < $num) { - $obj = $db->fetch_object($resql); - - if ($obj->type == 'action') { - $contactaction = new ActionComm($db); - $contactaction->id = $obj->id; - $result = $contactaction->fetchResources(); - if ($result < 0) { - dol_print_error($db); - setEventMessage("actions.lib::show_actions_messaging Error fetch resource", 'errors'); - } - - //if ($donetodo == 'todo') $sql.= " AND ((a.percent >= 0 AND a.percent < 100) OR (a.percent = -1 AND a.datep > '".$db->idate($now)."'))"; - //elseif ($donetodo == 'done') $sql.= " AND (a.percent = 100 OR (a.percent = -1 AND a.datep <= '".$db->idate($now)."'))"; - $tododone = ''; - if (($obj->percent >= 0 and $obj->percent < 100) || ($obj->percent == -1 && $obj->dp > $now)) { - $tododone = 'todo'; - } - - $histo[$numaction] = array( - 'type'=>$obj->type, - 'tododone'=>$tododone, - 'id'=>$obj->id, - 'datestart'=>$db->jdate($obj->dp), - 'dateend'=>$db->jdate($obj->dp2), - 'note'=>$obj->label, - 'message'=>$obj->message, - 'percent'=>$obj->percent, - - 'userid'=>$obj->user_id, - 'login'=>$obj->user_login, - 'userfirstname'=>$obj->user_firstname, - 'userlastname'=>$obj->user_lastname, - 'userphoto'=>$obj->user_photo, - 'msg_from'=>$obj->msg_from, - - 'contact_id'=>$obj->fk_contact, - 'socpeopleassigned' => $contactaction->socpeopleassigned, - 'lastname' => (empty($obj->lastname) ? '' : $obj->lastname), - 'firstname' => (empty($obj->firstname) ? '' : $obj->firstname), - 'fk_element'=>$obj->fk_element, - 'elementtype'=>$obj->elementtype, - // Type of event - 'acode'=>$obj->acode, - 'alabel'=>$obj->alabel, - 'libelle'=>$obj->alabel, // deprecated - 'apicto'=>$obj->apicto - ); - } else { - $histo[$numaction] = array( - 'type'=>$obj->type, - 'tododone'=>'done', - 'id'=>$obj->id, - 'datestart'=>$db->jdate($obj->dp), - 'dateend'=>$db->jdate($obj->dp2), - 'note'=>$obj->label, - 'message'=>$obj->message, - 'percent'=>$obj->percent, - 'acode'=>$obj->acode, - - 'userid'=>$obj->user_id, - 'login'=>$obj->user_login, - 'userfirstname'=>$obj->user_firstname, - 'userlastname'=>$obj->user_lastname, - 'userphoto'=>$obj->user_photo - ); - } - - $numaction++; - $i++; - } - } else { - dol_print_error($db); - } - } - - // Set $out to show events - $out = ''; - - if (!isModEnabled('agenda')) { - $langs->loadLangs(array("admin", "errors")); - $out = info_admin($langs->trans("WarningModuleXDisabledSoYouMayMissEventHere", $langs->transnoentitiesnoconv("Module2400Name")), 0, 0, 'warning'); - } - - if (isModEnabled('agenda') || (isModEnabled('mailing') && !empty($objcon->email))) { - $delay_warning = $conf->global->MAIN_DELAY_ACTIONS_TODO * 24 * 60 * 60; - - require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; - include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; - require_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'; - require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; - - $formactions = new FormActions($db); - - $actionstatic = new ActionComm($db); - $userstatic = new User($db); - $contactstatic = new Contact($db); - $userGetNomUrlCache = array(); - $contactGetNomUrlCache = array(); - - $out .= '
'; - $out .= '
'; - $out .= ''; - - if ($objcon && get_class($objcon) == 'User' && - (is_null($filterobj) || get_class($filterobj) == 'User')) { - $out .= ''; - } else { - $out .= ''; - } - if ($filterobj && get_class($filterobj) == 'User') { - $out .= ''; - } - - $out .= "\n"; - - $out .= '
'; - $out .= ''; - - $out .= ''; - - // Action column - if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { - $out .= ''; - } - - $out .= getTitleFieldOfList('Date', 0, $_SERVER["PHP_SELF"], 'a.datep', '', $param, '', $sortfield, $sortorder, '')."\n"; - - $out .= ''; - if ($donetodo) { - $out .= ''; - } - $out .= ''; - $out .= ''; - - // Action column - if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { - $out .= ''; - } - - $out .= ''; - - - $out .= '
'; - $searchpicto = $form->showFilterAndCheckAddButtons($massactionbutton ? 1 : 0, 'checkforselect', 1); - $out .= $searchpicto; - $out .= ''.$langs->trans("Search").' : '; - $out .= ''; - //$out .= img_picto($langs->trans("Type"), 'type'); - $out .= $formactions->select_type_actions($actioncode, "actioncode", '', !getDolGlobalString('AGENDA_USE_EVENT_TYPE') ? 1 : -1, 0, 0, 1, 'minwidth200imp'); - $out .= ''; - $out .= ''; - $out .= ''; - $searchpicto = $form->showFilterAndCheckAddButtons($massactionbutton ? 1 : 0, 'checkforselect', 1); - $out .= $searchpicto; - $out .= '
'; - - $out .= ''; - $out .= '
'; - - $out .= "\n"; - - $out .= '\n"; - - if (empty($histo)) { - $out .= ''.$langs->trans("NoRecordFound").''; - } - } - - if ($noprint) { - return $out; - } else { - print $out; - } -} diff --git a/htdocs/user/messaging.php b/htdocs/user/messaging.php index ebb5b93804a..372616a4cb4 100644 --- a/htdocs/user/messaging.php +++ b/htdocs/user/messaging.php @@ -222,7 +222,7 @@ if (isModEnabled('agenda') && ($user->hasRight('agenda', 'myactions', 'read') || $filters['search_agenda_label'] = $search_agenda_label; $filters['search_rowid'] = $search_rowid; - show_actions_messaging_user($conf, $langs, $db, $object, null, 0, $actioncode, '', $filters, $sortfield, $sortorder); + show_actions_messaging($conf, $langs, $db, $object, null, 0, $actioncode, '', $filters, $sortfield, $sortorder); } //End of page From 7a8bb902e8d151c2404cd52497588c2feb404071 Mon Sep 17 00:00:00 2001 From: thibdrev Date: Wed, 24 Jan 2024 20:14:54 +0100 Subject: [PATCH 11/65] qual: phpstan for /htdocs/compta/bank/card.php htdocs/compta/bank/card.php 130 Property Account::$courant (int) does not accept array|string. htdocs/compta/bank/card.php 131 Property Account::$clos (int) does not accept array|string. htdocs/compta/bank/card.php 162 Property Account::$fk_accountancy_journal (int) does not accept string. htdocs/compta/bank/card.php 164 Property Account::$fk_accountancy_journal (int) does not accept array|string. htdocs/compta/bank/card.php 167 Property Account::$solde (float) does not accept string. htdocs/compta/bank/card.php 168 Property Account::$balance (float) does not accept string. htdocs/compta/bank/card.php 173 Property Account::$state_id (int) does not accept array|string. htdocs/compta/bank/card.php 174 Property CommonObject::$country_id (int) does not accept array|string. htdocs/compta/bank/card.php 176 Property Account::$min_allowed (float) does not accept array|string. htdocs/compta/bank/card.php 177 Property Account::$min_desired (float) does not accept array|string. htdocs/compta/bank/card.php 243 Property Account::$courant (int) does not accept array|string. htdocs/compta/bank/card.php 244 Property Account::$clos (int) does not accept array|string. htdocs/compta/bank/card.php 275 Property Account::$fk_accountancy_journal (int) does not accept string. htdocs/compta/bank/card.php 277 Property Account::$fk_accountancy_journal (int) does not accept array|string. htdocs/compta/bank/card.php 282 Property Account::$state_id (int) does not accept array|string. htdocs/compta/bank/card.php 283 Property CommonObject::$country_id (int) does not accept array|string. htdocs/compta/bank/card.php 285 Property Account::$min_allowed (float) does not accept array|string. htdocs/compta/bank/card.php 286 Property Account::$min_desired (float) does not accept array|string. --- htdocs/compta/bank/card.php | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/htdocs/compta/bank/card.php b/htdocs/compta/bank/card.php index 6c575936eb4..1030b4b10b5 100644 --- a/htdocs/compta/bank/card.php +++ b/htdocs/compta/bank/card.php @@ -127,8 +127,8 @@ if (empty($reshook)) { $object->ref = dol_string_nospecial(trim(GETPOST('ref', 'alpha'))); $object->label = trim(GETPOST("label", 'alphanohtml')); - $object->courant = GETPOST("type"); - $object->clos = GETPOST("clos"); + $object->courant = GETPOSTINT("type"); + $object->clos = GETPOSTINT("clos"); $object->rappro = (GETPOST("norappro", 'alpha') ? 0 : 1); $object->url = trim(GETPOST("url", 'alpha')); @@ -157,24 +157,24 @@ if (empty($reshook)) { } else { $object->account_number = $account_number; } - $fk_accountancy_journal = GETPOST('fk_accountancy_journal', 'int'); + $fk_accountancy_journal = GETPOSTINT('fk_accountancy_journal'); if ($fk_accountancy_journal <= 0) { $object->fk_accountancy_journal = ''; } else { $object->fk_accountancy_journal = $fk_accountancy_journal; } - $object->solde = price2num(GETPOST("solde", 'alpha')); - $object->balance = price2num(GETPOST("solde", 'alpha')); + $object->solde = GETPOSTFLOAT("solde"); + $object->balance = GETPOSTFLOAT("solde"); $object->date_solde = dol_mktime(12, 0, 0, GETPOST("remonth", 'int'), GETPOST('reday', 'int'), GETPOST("reyear", 'int')); $object->currency_code = trim(GETPOST("account_currency_code")); - $object->state_id = GETPOST("account_state_id", 'int'); - $object->country_id = GETPOST("account_country_id", 'int'); + $object->state_id = GETPOSTINT("account_state_id"); + $object->country_id = GETPOSTINT("account_country_id"); - $object->min_allowed = GETPOST("account_min_allowed", 'int'); - $object->min_desired = GETPOST("account_min_desired", 'int'); + $object->min_allowed = GETPOSTFLOAT("account_min_allowed"); + $object->min_desired = GETPOSTFLOAT("account_min_desired"); $object->comment = trim(GETPOST("account_comment", 'restricthtml')); $object->fk_user_author = $user->id; @@ -240,8 +240,8 @@ if (empty($reshook)) { $object->ref = dol_string_nospecial(trim(GETPOST('ref', 'alpha'))); $object->label = trim(GETPOST("label", 'alphanohtml')); - $object->courant = GETPOST("type"); - $object->clos = GETPOST("clos"); + $object->courant = GETPOSTINT("type"); + $object->clos = GETPOSTINT("clos"); $object->rappro = (GETPOST("norappro", 'alpha') ? 0 : 1); $object->url = trim(GETPOST("url", 'alpha')); @@ -270,7 +270,7 @@ if (empty($reshook)) { } else { $object->account_number = $account_number; } - $fk_accountancy_journal = GETPOST('fk_accountancy_journal', 'int'); + $fk_accountancy_journal = GETPOSTINT('fk_accountancy_journal'); if ($fk_accountancy_journal <= 0) { $object->fk_accountancy_journal = ''; } else { @@ -279,11 +279,11 @@ if (empty($reshook)) { $object->currency_code = trim(GETPOST("account_currency_code")); - $object->state_id = GETPOST("account_state_id", 'int'); - $object->country_id = GETPOST("account_country_id", 'int'); + $object->state_id = GETPOSTINT("account_state_id"); + $object->country_id = GETPOSTINT("account_country_id"); - $object->min_allowed = GETPOST("account_min_allowed", 'int'); - $object->min_desired = GETPOST("account_min_desired", 'int'); + $object->min_allowed = GETPOSTFLOAT("account_min_allowed"); + $object->min_desired = GETPOSTFLOAT("account_min_desired"); $object->comment = trim(GETPOST("account_comment", 'restricthtml')); if ($conf->global->MAIN_BANK_ACCOUNTANCY_CODE_ALWAYS_REQUIRED && empty($object->account_number)) { From adce48e4f037add8e5a564056feafe42036ee3f6 Mon Sep 17 00:00:00 2001 From: thibdrev Date: Wed, 24 Jan 2024 20:41:13 +0100 Subject: [PATCH 12/65] qual: phpstan for htdocs/compta/bank/class/paymentvarious.class.php htdocs/compta/bank/class/paymentvarious.class.php 383 Property PaymentVarious::$tms (int) does not accept string. htdocs/compta/bank/class/paymentvarious.class.php 386 Property PaymentVarious::$sens (int) does not accept string. htdocs/compta/bank/class/paymentvarious.class.php 392 Property PaymentVarious::$fk_bank (int) does not accept string. htdocs/compta/bank/class/paymentvarious.class.php 393 Property PaymentVarious::$fk_user_author (int) does not accept string. htdocs/compta/bank/class/paymentvarious.class.php 394 Property PaymentVarious::$fk_user_modif (int) does not accept string. --- htdocs/compta/bank/class/paymentvarious.class.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/htdocs/compta/bank/class/paymentvarious.class.php b/htdocs/compta/bank/class/paymentvarious.class.php index 51e955007eb..bc5eada4436 100644 --- a/htdocs/compta/bank/class/paymentvarious.class.php +++ b/htdocs/compta/bank/class/paymentvarious.class.php @@ -380,18 +380,18 @@ class PaymentVarious extends CommonObject { $this->id = 0; - $this->tms = ''; + $this->tms = 0; $this->datep = ''; $this->datev = ''; - $this->sens = ''; + $this->sens = 0; $this->amount = ''; $this->label = ''; $this->accountancy_code = ''; $this->subledger_account = ''; $this->note = ''; - $this->fk_bank = ''; - $this->fk_user_author = ''; - $this->fk_user_modif = ''; + $this->fk_bank = 0; + $this->fk_user_author = 0; + $this->fk_user_modif = 0; } /** From 82a5e780205ca7d7818922b0788a6e13685a676e Mon Sep 17 00:00:00 2001 From: thibdrev Date: Wed, 24 Jan 2024 21:01:04 +0100 Subject: [PATCH 13/65] qual: phpstan for htdocs/compta/facture/class/facture.class.php --- htdocs/compta/facture/class/facture.class.php | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index e9eb5ec753e..85f19b5f5f2 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -4424,7 +4424,7 @@ class Facture extends CommonInvoice * Set percent discount * * @param User $user User that set discount - * @param double $remise Discount + * @param float $remise Discount * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int Return integer <0 if KO, >0 if OK * @deprecated remise_percent is a deprecated field for object parent @@ -4433,18 +4433,18 @@ class Facture extends CommonInvoice { // Clean parameters if (empty($remise)) { - $remise = 0; + $remise = 0.0; } if ($user->hasRight('facture', 'creer')) { - $remise = price2num($remise, 2); + $remise = (float) price2num($remise, 2); $error = 0; $this->db->begin(); $sql = 'UPDATE '.MAIN_DB_PREFIX.'facture'; - $sql .= ' SET remise_percent = '.((float) $remise); + $sql .= ' SET remise_percent = '.$remise; $sql .= " WHERE rowid = ".((int) $this->id); $sql .= ' AND fk_statut = '.self::STATUS_DRAFT; @@ -6295,7 +6295,8 @@ class FactureLigne extends CommonInvoiceLine // if buy price not defined, define buyprice as configured in margin admin if ($this->pa_ht == 0 && $pa_ht_isemptystring) { - if (($result = $this->defineBuyPrice($this->subprice, $this->remise_percent, $this->fk_product)) < 0) { + ($result = $this->defineBuyPrice($this->subprice, $this->remise_percent, $this->fk_product)) + if ($result < 0) { return $result; } else { $this->pa_ht = $result; @@ -6734,7 +6735,7 @@ class FactureLigne extends CommonInvoiceLine * * @param int $invoiceid Invoice id * @param bool $include_credit_note Include credit note or not - * @return int >= 0 + * @return float|int Reurrn previous situation percent, 0 or -1 if error */ public function get_prev_progress($invoiceid, $include_credit_note = true) { From 3f7e51f4489659fa7e708ed365bd4c56a7ec4df6 Mon Sep 17 00:00:00 2001 From: thibdrev Date: Wed, 24 Jan 2024 21:04:02 +0100 Subject: [PATCH 14/65] Update commonobject.class.php - defineBuyPrice() return type --- htdocs/core/class/commonobject.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index fb41245579d..6dfaffff681 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -8964,7 +8964,7 @@ abstract class CommonObject * @param float $unitPrice Product unit price * @param float $discountPercent Line discount percent * @param int $fk_product Product id - * @return float Return integer <0 if KO, buyprice if OK + * @return float|int Return buy price if OK, integer <0 if KO */ public function defineBuyPrice($unitPrice = 0.0, $discountPercent = 0.0, $fk_product = 0) { From 09b566882565329e1639a646c09853cb0a23b316 Mon Sep 17 00:00:00 2001 From: thibdrev Date: Wed, 24 Jan 2024 21:09:19 +0100 Subject: [PATCH 15/65] qual: phpstan for htdocs/compta/paiement/cheque/card.php htdocs/compta/paiement/cheque/card.php 179 Property CommonObject::$id (int) does not accept array|string. htdocs/compta/paiement/cheque/card.php 190 Property CommonObject::$id (int) does not accept array|string. --- htdocs/compta/paiement/cheque/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/paiement/cheque/card.php b/htdocs/compta/paiement/cheque/card.php index 50ead13e11d..e4cc36e0736 100644 --- a/htdocs/compta/paiement/cheque/card.php +++ b/htdocs/compta/paiement/cheque/card.php @@ -37,7 +37,7 @@ require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; // Load translation files required by the page $langs->loadLangs(array('banks', 'categories', 'bills', 'companies', 'compta')); -$id = GETPOST('id', 'int'); +$id = GETPOSTINT('id'); $ref = GETPOST('ref', 'alpha'); $action = GETPOST('action', 'aZ09'); $confirm = GETPOST('confirm', 'alpha'); From ddb7e109be594cb3bb8025e9ce12e4ddbddfee8b Mon Sep 17 00:00:00 2001 From: thibdrev Date: Wed, 24 Jan 2024 21:11:39 +0100 Subject: [PATCH 16/65] qual: phpstan for htdocs/compta/paiement_charge.php htdocs/compta/paiement_charge.php 103 Property PaymentSocialContribution::$chid (int) does not accept array|string. --- htdocs/compta/paiement_charge.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/compta/paiement_charge.php b/htdocs/compta/paiement_charge.php index 0758dfc3c43..19a2b465507 100644 --- a/htdocs/compta/paiement_charge.php +++ b/htdocs/compta/paiement_charge.php @@ -32,7 +32,7 @@ require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; // Load translation files required by the page $langs->loadLangs(array("banks", "bills", "compta")); -$chid = GETPOST("id", 'int'); +$chid = GETPOSTINT("id"); $action = GETPOST('action', 'aZ09'); $cancel = GETPOST('cancel'); @@ -190,7 +190,7 @@ if ($action == 'create') { $sql = "SELECT sum(p.amount) as total"; $sql .= " FROM ".MAIN_DB_PREFIX."paiementcharge as p"; - $sql .= " WHERE p.fk_charge = ".((int) $chid); + $sql .= " WHERE p.fk_charge = ".$chid; $resql = $db->query($sql); if ($resql) { $obj = $db->fetch_object($resql); From 25d19b1521331e8e88c5689ed7a3108bf7ae8aa3 Mon Sep 17 00:00:00 2001 From: thibdrev Date: Wed, 24 Jan 2024 21:13:22 +0100 Subject: [PATCH 17/65] qual: phpstan for htdocs/compta/paiement_vat.php htdocs/compta/paiement_vat.php 101 Property PaymentVAT::$chid (int) does not accept array|string. --- htdocs/compta/paiement_vat.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/compta/paiement_vat.php b/htdocs/compta/paiement_vat.php index e92ee936c40..88b1a955a35 100644 --- a/htdocs/compta/paiement_vat.php +++ b/htdocs/compta/paiement_vat.php @@ -32,7 +32,7 @@ require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; // Load translation files required by the page $langs->loadLangs(array("banks", "bills")); -$chid = GETPOST("id", 'int'); +$chid = GETPOSTINT("id"); $action = GETPOST('action', 'alpha'); $cancel = GETPOST('cancel'); @@ -190,7 +190,7 @@ if ($action == 'create') { $sql = "SELECT sum(p.amount) as total"; $sql .= " FROM ".MAIN_DB_PREFIX."payment_vat as p"; - $sql .= " WHERE p.fk_tva = ".((int) $chid); + $sql .= " WHERE p.fk_tva = ".$chid; $resql = $db->query($sql); if ($resql) { $obj = $db->fetch_object($resql); From 16f3a3564e5ab542dac4250399445c38fc56a024 Mon Sep 17 00:00:00 2001 From: thibdrev Date: Wed, 24 Jan 2024 21:17:39 +0100 Subject: [PATCH 18/65] qual: phpstan for htdocs/compta/prelevement/class/ligneprelevement.class.php htdocs/compta/prelevement/class/ligneprelevement.class.php 195 Method LignePrelevement::LibStatut() should return string|null but empty return statement found. --- htdocs/compta/prelevement/class/ligneprelevement.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/compta/prelevement/class/ligneprelevement.class.php b/htdocs/compta/prelevement/class/ligneprelevement.class.php index 8c29fe94dc8..a470531a398 100644 --- a/htdocs/compta/prelevement/class/ligneprelevement.class.php +++ b/htdocs/compta/prelevement/class/ligneprelevement.class.php @@ -157,7 +157,7 @@ class LignePrelevement * * @param int $status Id status * @param int $mode 0=Label, 1=Picto + label, 2=Picto, 3=Label + Picto - * @return null|string Label + * @return null|string Return status label (or null if $mode != 0, 1, 2, 3 or 4) */ public function LibStatut($status, $mode = 0) { @@ -192,7 +192,7 @@ class LignePrelevement } } // return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status], '', $statusType, $mode); - return; + return null; } /** From 6cb2b6c01859f4938c931a7b0469b31f759fce2e Mon Sep 17 00:00:00 2001 From: thibdrev Date: Wed, 24 Jan 2024 21:19:42 +0100 Subject: [PATCH 19/65] qual: phpstan for htdocs/compta/sociales/class/cchargesociales.class.php htdocs/compta/sociales/class/cchargesociales.class.php 528 Property Cchargesociales::$fk_pays (int) does not accept string. --- htdocs/compta/sociales/class/cchargesociales.class.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/htdocs/compta/sociales/class/cchargesociales.class.php b/htdocs/compta/sociales/class/cchargesociales.class.php index 1c106b8d399..2575c69b31e 100644 --- a/htdocs/compta/sociales/class/cchargesociales.class.php +++ b/htdocs/compta/sociales/class/cchargesociales.class.php @@ -519,13 +519,12 @@ class Cchargesociales public function initAsSpecimen() { $this->id = 0; - $this->libelle = ''; $this->label = ''; $this->deductible = ''; $this->active = ''; $this->code = ''; - $this->fk_pays = ''; + $this->fk_pays = 0; $this->module = ''; $this->accountancy_code = ''; } From 53c296caa81bf5a2fec074b16f92b276235e6c88 Mon Sep 17 00:00:00 2001 From: thibdrev Date: Wed, 24 Jan 2024 21:27:22 +0100 Subject: [PATCH 20/65] typo --- 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 85f19b5f5f2..6cceb507144 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -6295,7 +6295,7 @@ class FactureLigne extends CommonInvoiceLine // if buy price not defined, define buyprice as configured in margin admin if ($this->pa_ht == 0 && $pa_ht_isemptystring) { - ($result = $this->defineBuyPrice($this->subprice, $this->remise_percent, $this->fk_product)) + $result = $this->defineBuyPrice($this->subprice, $this->remise_percent, $this->fk_product); if ($result < 0) { return $result; } else { From 42befb29cd44515cf20166276754c94049a3ca00 Mon Sep 17 00:00:00 2001 From: thibdrev Date: Wed, 24 Jan 2024 21:30:42 +0100 Subject: [PATCH 21/65] var into sql shall be casted --- htdocs/compta/paiement_charge.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/paiement_charge.php b/htdocs/compta/paiement_charge.php index 19a2b465507..cec162957be 100644 --- a/htdocs/compta/paiement_charge.php +++ b/htdocs/compta/paiement_charge.php @@ -190,7 +190,7 @@ if ($action == 'create') { $sql = "SELECT sum(p.amount) as total"; $sql .= " FROM ".MAIN_DB_PREFIX."paiementcharge as p"; - $sql .= " WHERE p.fk_charge = ".$chid; + $sql .= " WHERE p.fk_charge = ".((int) $chid); $resql = $db->query($sql); if ($resql) { $obj = $db->fetch_object($resql); From c18499c534ccfdb710b0a0e5ab7e822bdfdcbd56 Mon Sep 17 00:00:00 2001 From: thibdrev Date: Wed, 24 Jan 2024 21:31:45 +0100 Subject: [PATCH 22/65] var in sql shall be casted --- htdocs/compta/paiement_vat.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/paiement_vat.php b/htdocs/compta/paiement_vat.php index 88b1a955a35..3cac781c50e 100644 --- a/htdocs/compta/paiement_vat.php +++ b/htdocs/compta/paiement_vat.php @@ -190,7 +190,7 @@ if ($action == 'create') { $sql = "SELECT sum(p.amount) as total"; $sql .= " FROM ".MAIN_DB_PREFIX."payment_vat as p"; - $sql .= " WHERE p.fk_tva = ".$chid; + $sql .= " WHERE p.fk_tva = ".((int) $chid); $resql = $db->query($sql); if ($resql) { $obj = $db->fetch_object($resql); From b151bc16bb2aae6eb5ddb53b1d82d6db67c27877 Mon Sep 17 00:00:00 2001 From: thibdrev Date: Wed, 24 Jan 2024 21:44:05 +0100 Subject: [PATCH 23/65] qual: phpstan for htdocs/compta/sociales/class/paymentsocialcontribution.class.php htdocs/compta/sociales/class/paymentsocialcontribution.class.php 535 Property PaymentSocialContribution::$fk_charge (int) does not accept string. htdocs/compta/sociales/class/paymentsocialcontribution.class.php 540 Property PaymentSocialContribution::$fk_typepaiement (int) does not accept string. htdocs/compta/sociales/class/paymentsocialcontribution.class.php 544 Property PaymentSocialContribution::$fk_bank (int) does not accept string. htdocs/compta/sociales/class/paymentsocialcontribution.class.php 545 Property PaymentSocialContribution::$fk_user_creat (int) does not accept string. htdocs/compta/sociales/class/paymentsocialcontribution.class.php 546 Property PaymentSocialContribution::$fk_user_modif (int) does not accept string. --- .../class/paymentsocialcontribution.class.php | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/htdocs/compta/sociales/class/paymentsocialcontribution.class.php b/htdocs/compta/sociales/class/paymentsocialcontribution.class.php index 40ac77d918b..306b552c1f3 100644 --- a/htdocs/compta/sociales/class/paymentsocialcontribution.class.php +++ b/htdocs/compta/sociales/class/paymentsocialcontribution.class.php @@ -531,19 +531,18 @@ class PaymentSocialContribution extends CommonObject public function initAsSpecimen() { $this->id = 0; - - $this->fk_charge = ''; + $this->fk_charge = 0; $this->datec = ''; $this->tms = ''; $this->datep = ''; $this->amount = ''; $this->fk_typepaiement = ''; - $this->num_payment = ''; + $this->num_payment = 0; $this->note_private = ''; $this->note_public = ''; - $this->fk_bank = ''; - $this->fk_user_creat = ''; - $this->fk_user_modif = ''; + $this->fk_bank = 0; + $this->fk_user_creat = 0; + $this->fk_user_modif = 0; } From b3ae425ad9ec8d2eb6004433ab597040396b900a Mon Sep 17 00:00:00 2001 From: thibdrev Date: Wed, 24 Jan 2024 21:46:46 +0100 Subject: [PATCH 24/65] qual: phpstan for htdocs/compta/tva/card.php htdocs/compta/tva/card.php 175 Property CommonObject::$fk_account (int) does not accept array|string. htdocs/compta/tva/card.php 332 Property CommonObject::$id (int) does not accept null. htdocs/compta/tva/card.php 332 Property CommonObject::$ref (string) does not accept null. --- htdocs/compta/tva/card.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/compta/tva/card.php b/htdocs/compta/tva/card.php index 5ca22da196c..6fdf926a8b9 100644 --- a/htdocs/compta/tva/card.php +++ b/htdocs/compta/tva/card.php @@ -172,7 +172,7 @@ if (empty($reshook)) { if ($action == 'add' && !$cancel) { $error = 0; - $object->fk_account = GETPOST("accountid", 'int'); + $object->fk_account = GETPOSTINT("accountid"); $object->type_payment = GETPOST("type_payment", 'alphanohtml'); $object->num_payment = GETPOST("num_payment", 'alphanohtml'); @@ -329,7 +329,7 @@ if (empty($reshook)) { $object->fetch($id); if ($object->id > 0) { - $object->id = $object->ref = null; + $object->id = $object->ref = 0; $object->paye = 0; if (GETPOST('amount', 'alphanohtml')) { From 93b2d330175c1c47ed067c710534a080f64e53bc Mon Sep 17 00:00:00 2001 From: thibdrev Date: Wed, 24 Jan 2024 21:48:28 +0100 Subject: [PATCH 25/65] qual: phpstan for htdocs/compta/tva/class/paymentvat.class.php htdocs/compta/tva/class/paymentvat.class.php 542 Property PaymentVAT::$fk_typepaiement (int) does not accept string. --- htdocs/compta/tva/class/paymentvat.class.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/htdocs/compta/tva/class/paymentvat.class.php b/htdocs/compta/tva/class/paymentvat.class.php index 9fe6ba57eab..0190b4d2e22 100644 --- a/htdocs/compta/tva/class/paymentvat.class.php +++ b/htdocs/compta/tva/class/paymentvat.class.php @@ -533,13 +533,12 @@ class PaymentVAT extends CommonObject public function initAsSpecimen() { $this->id = 0; - $this->fk_tva = 0; $this->datec = ''; $this->tms = ''; $this->datep = ''; $this->amount = ''; - $this->fk_typepaiement = ''; + $this->fk_typepaiement = 0; $this->num_payment = ''; $this->note_private = ''; $this->note_public = ''; From 3da89dc35c1506bb95a74afc1c8e8b7a55ff99c9 Mon Sep 17 00:00:00 2001 From: thibdrev Date: Wed, 24 Jan 2024 21:51:48 +0100 Subject: [PATCH 26/65] qual: phpstan for htdocs/core/actions_comments.inc.php htdocs/core/actions_comments.inc.php 41 Property Comment::$fk_element (int) does not accept array|string. --- htdocs/core/actions_comments.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/actions_comments.inc.php b/htdocs/core/actions_comments.inc.php index 4d901fbc801..e5007d90752 100644 --- a/htdocs/core/actions_comments.inc.php +++ b/htdocs/core/actions_comments.inc.php @@ -38,7 +38,7 @@ if ($action == 'addcomment') { if (!empty($description)) { $comment->description = $description; $comment->datec = dol_now(); - $comment->fk_element = GETPOST('id', 'int'); + $comment->fk_element = GETPOSTINT('id'); $comment->element_type = GETPOST('comment_element_type', 'alpha'); $comment->fk_user_author = $user->id; $comment->entity = $conf->entity; From bb942ba0091cdb735b301427a1b9541ff778262c Mon Sep 17 00:00:00 2001 From: thibdrev Date: Wed, 24 Jan 2024 21:53:05 +0100 Subject: [PATCH 27/65] qual: phpstan for htdocs/core/actions_massactions.inc.php htdocs/core/actions_massactions.inc.php 1754 Property CommonObject::$fk_project (int) does not accept array|string. --- htdocs/core/actions_massactions.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php index 8994b24e017..63781b79df3 100644 --- a/htdocs/core/actions_massactions.inc.php +++ b/htdocs/core/actions_massactions.inc.php @@ -1751,7 +1751,7 @@ if (!$error && ($massaction == 'clonetasks' || ($action == 'clonetasks' && $conf } if (!$error) { - $clone_task->fk_project = GETPOST('projectid', 'int'); + $clone_task->fk_project = GETPOSTINT('projectid'); $clone_task->ref = $defaultref; $clone_task->label = $origin_task->label; $clone_task->description = $origin_task->description; From ef22c80a82cc3c1922c77d7214f725bb3dd23344 Mon Sep 17 00:00:00 2001 From: thibdrev Date: Wed, 24 Jan 2024 22:00:56 +0100 Subject: [PATCH 28/65] qual: phpstan for htdocs/core/class/html.formaccounting.class.php htdocs/core/class/html.formaccounting.class.php 109 Method FormAccounting::select_journal() should return string but returns int. htdocs/core/class/html.formaccounting.class.php 189 Method FormAccounting::multi_select_journal() should return string but returns int. htdocs/core/class/html.formaccounting.class.php 339 Method FormAccounting::select_bookkeeping_importkey() should return string but returns int. htdocs/core/class/html.formaccounting.class.php 403 Method FormAccounting::select_account() should return string but returns int. htdocs/core/class/html.formaccounting.class.php 503 Method FormAccounting::select_auxaccount() should return string but returns int. htdocs/core/class/html.formaccounting.class.php 526 Method FormAccounting::select_auxaccount() should return string but returns int. htdocs/core/class/html.formaccounting.class.php 582 Method FormAccounting::selectyear_accountancy_bookkepping() should return array|string but returns int. --- htdocs/core/class/html.formaccounting.class.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/htdocs/core/class/html.formaccounting.class.php b/htdocs/core/class/html.formaccounting.class.php index 6a88c5f780a..a2448501e7d 100644 --- a/htdocs/core/class/html.formaccounting.class.php +++ b/htdocs/core/class/html.formaccounting.class.php @@ -77,7 +77,7 @@ class FormAccounting extends Form * @param string $morecss More css non HTML object * @param string $usecache Key to use to store result into a cache. Next call with same key will reuse the cache. * @param int $disabledajaxcombo Disable ajax combo box. - * @return string String with HTML select + * @return string|int String with HTML select, or -1 if error */ public function select_journal($selectid, $htmlname = 'journal', $nature = 0, $showempty = 0, $select_in = 0, $select_out = 0, $morecss = 'maxwidth300 maxwidthonsmartphone', $usecache = '', $disabledajaxcombo = 0) { @@ -157,7 +157,7 @@ class FormAccounting extends Form * @param string $morecss More css non HTML object * @param string $usecache Key to use to store result into a cache. Next call with same key will reuse the cache. * @param int $disabledajaxcombo Disable ajax combo box. - * @return string String with HTML select + * @return string|int String with HTML select, or -1 if error */ public function multi_select_journal($selectedIds = array(), $htmlname = 'journal', $nature = 0, $showempty = 0, $select_in = 0, $select_out = 0, $morecss = '', $usecache = '', $disabledajaxcombo = 0) { @@ -319,7 +319,7 @@ class FormAccounting extends Form * * @param string $htmlname Name of select field * @param string $selectedkey Value - * @return string HTML edit field + * @return string|int HTML edit field, or -1 if error */ public function select_bookkeeping_importkey($htmlname = 'importkey', $selectedkey = '') { @@ -359,7 +359,7 @@ class FormAccounting extends Form * @param string $morecss More css non HTML object * @param string $usecache Key to use to store result into a cache. Next call with same key will reuse the cache. * @param string $active Filter on status active or not: '0', '1' or '' for no filter - * @return string String with HTML select + * @return string|int String with HTML select, or -1 if error */ public function select_account($selectid, $htmlname = 'account', $showempty = 0, $event = array(), $select_in = 0, $select_out = 0, $morecss = 'minwidth100 maxwidth300 maxwidthonsmartphone', $usecache = '', $active = '1') { @@ -467,7 +467,7 @@ class FormAccounting extends Form * @param string $morecss More css * @param string $usecache Key to use to store result into a cache. Next call with same key will reuse the cache. * @param string $labelhtmlname HTML name of label for autofill of account from name. - * @return string String with HTML select + * @return string|int String with HTML select, or -1 if error */ public function select_auxaccount($selectid, $htmlname = 'account_num_aux', $showempty = 0, $morecss = 'minwidth100 maxwidth300 maxwidthonsmartphone', $usecache = '', $labelhtmlname = '') { @@ -560,7 +560,7 @@ class FormAccounting extends Form * @param string $htmlname Name of HTML select object * @param int $useempty Affiche valeur vide dans liste * @param string $output_format (html/option (for option html only)/array (to return options arrays - * @return string|array HTML select component or array of select options + * @return string|array|int HTML select component || array of select options || - 1 if error */ public function selectyear_accountancy_bookkepping($selected = '', $htmlname = 'yearid', $useempty = 0, $output_format = 'html') { From ea7e7456a5884471c13e1c0c2c9b538bc84969f0 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 25 Jan 2024 01:50:38 +0100 Subject: [PATCH 29/65] Fix cloning of projects --- htdocs/projet/card.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/htdocs/projet/card.php b/htdocs/projet/card.php index 801129da8e6..6bd1de90ffb 100644 --- a/htdocs/projet/card.php +++ b/htdocs/projet/card.php @@ -499,8 +499,11 @@ if (empty($reshook)) { $newobject->fetch_optionals(); $newobject->fetch_thirdparty(); // Load new object $object = $newobject; - $action = 'edit'; + $action = 'view'; $comefromclone = true; + + setEventMessages($langs->trans("ProjectCreatedInDolibarr", $newobject->ref), "", 'mesgs'); + //var_dump($newobject); exit; } } From c98325693789eff3195636da4b53723da63ecf7c Mon Sep 17 00:00:00 2001 From: Francis Appels Date: Thu, 25 Jan 2024 09:53:51 +0100 Subject: [PATCH 30/65] Improve doc of loadWarehouses --- htdocs/product/class/html.formproduct.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/product/class/html.formproduct.class.php b/htdocs/product/class/html.formproduct.class.php index b6ec2cb629f..3d5ead67cc5 100644 --- a/htdocs/product/class/html.formproduct.class.php +++ b/htdocs/product/class/html.formproduct.class.php @@ -68,7 +68,7 @@ class FormProduct * 'warehouseinternal' = select products from warehouses for internal correct/transfer only * @param boolean $sumStock sum total stock of a warehouse, default true * @param array $exclude warehouses ids to exclude - * @param bool|int $stockMin [=false] Value of minimum stock to filter or false not not filter by minimum stock + * @param bool|int $stockMin [=false] Value of minimum stock to filter (only warehouse with stock > stockMin are loaded) or false not not filter by minimum stock * @param string $orderBy [='e.ref'] Order by * @return int Nb of loaded lines, 0 if already loaded, <0 if KO * @throws Exception From 5f694a11734f212cf019b66100afd27fe51021e8 Mon Sep 17 00:00:00 2001 From: Francis Appels Date: Thu, 25 Jan 2024 10:16:22 +0100 Subject: [PATCH 31/65] also for selectWarehouses --- htdocs/product/class/html.formproduct.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/product/class/html.formproduct.class.php b/htdocs/product/class/html.formproduct.class.php index 3d5ead67cc5..f336303b813 100644 --- a/htdocs/product/class/html.formproduct.class.php +++ b/htdocs/product/class/html.formproduct.class.php @@ -276,7 +276,7 @@ class FormProduct * @param string $morecss Add more css classes to HTML select * @param array $exclude Warehouses ids to exclude * @param int $showfullpath 1=Show full path of name (parent ref into label), 0=Show only ref of current warehouse - * @param bool|int $stockMin [=false] Value of minimum stock to filter or false not not filter by minimum stock + * @param bool|int $stockMin [=false] Value of minimum stock to filter (only warehouse with stock > stockMin are loaded) or false not not filter by minimum stock * @param string $orderBy [='e.ref'] Order by * @param int $multiselect 1=Allow multiselect * @return string HTML select From db2f7ba8234116fb2b0e375fd2f76c142cae3279 Mon Sep 17 00:00:00 2001 From: vmaury Date: Thu, 25 Jan 2024 11:00:26 +0100 Subject: [PATCH 32/65] Allow external site menu displayed to external users --- htdocs/core/modules/modExternalSite.class.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/htdocs/core/modules/modExternalSite.class.php b/htdocs/core/modules/modExternalSite.class.php index 5919c1d9162..83cdf2ae84b 100644 --- a/htdocs/core/modules/modExternalSite.class.php +++ b/htdocs/core/modules/modExternalSite.class.php @@ -94,6 +94,10 @@ class modExternalSite extends DolibarrModules $this->rights_class = 'externalsite'; // Permission key $this->rights = array(); // Permission array used by this module + $this->module_parts = array( // allow access to external users + 'moduleforexternal' => 1 + ); + // Menus //------ $r = 0; @@ -110,7 +114,7 @@ class modExternalSite extends DolibarrModules 'perms'=>'', 'enabled'=>'$conf->externalsite->enabled', 'target'=>'', - 'user'=>0 + 'user'=>2 ); $r++; } From 7ff8354933b6bb78963069de9cb42da90b377c0a Mon Sep 17 00:00:00 2001 From: vmaury Date: Thu, 25 Jan 2024 11:05:35 +0100 Subject: [PATCH 33/65] Allow external site menu displayed to external users --- htdocs/core/modules/modExternalSite.class.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/core/modules/modExternalSite.class.php b/htdocs/core/modules/modExternalSite.class.php index 83cdf2ae84b..b56f62538b0 100644 --- a/htdocs/core/modules/modExternalSite.class.php +++ b/htdocs/core/modules/modExternalSite.class.php @@ -94,9 +94,9 @@ class modExternalSite extends DolibarrModules $this->rights_class = 'externalsite'; // Permission key $this->rights = array(); // Permission array used by this module - $this->module_parts = array( // allow access to external users - 'moduleforexternal' => 1 - ); + $this->module_parts = array( + 'moduleforexternal' => 1 // allow access to external users + ); // Menus //------ From 4d6f263ec08211ba7ce36519b457d81632fef194 Mon Sep 17 00:00:00 2001 From: ATM-Lucas Date: Thu, 25 Jan 2024 11:08:38 +0100 Subject: [PATCH 34/65] Pr fix --- htdocs/bom/ajax/ajax.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/bom/ajax/ajax.php b/htdocs/bom/ajax/ajax.php index aa37ac33aa7..eddb8a40dc5 100644 --- a/htdocs/bom/ajax/ajax.php +++ b/htdocs/bom/ajax/ajax.php @@ -53,7 +53,7 @@ $idproduct = GETPOST('idproduct', 'int'); * View */ -top_httphead(); +top_httphead('application/json'); if ($action == 'getDurationUnitByProduct' && $user->hasRight('product', 'lire')) { $product = new Product($db); From 2886c688f0f77c23b23802d2f9333b21d740f98e Mon Sep 17 00:00:00 2001 From: Maximilien Valenzano Date: Thu, 25 Jan 2024 11:52:35 +0100 Subject: [PATCH 35/65] fix: invoice line save devise --- htdocs/compta/facture/card.php | 8 +++++--- htdocs/fourn/facture/card.php | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 810bba691c4..8e92b1c56dd 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -2284,8 +2284,10 @@ if (empty($reshook)) { $type = $prod->type; $fk_unit = $prod->fk_unit; } else { - $pu_ht = price2num($price_ht, 'MU'); - $pu_ttc = price2num($price_ttc, 'MU'); + if (!empty($price_ht)) $pu_ht = price2num($price_ht, 'MU'); + else $pu_ht = ''; + if (!empty($price_ttc)) $pu_ttc = price2num($price_ttc, 'MU'); + else $pu_ttc = ''; $tva_npr = (preg_match('/\*/', $tva_tx) ? 1 : 0); $tva_tx = str_replace('*', '', $tva_tx); if (empty($tva_tx)) { @@ -2311,7 +2313,7 @@ if (empty($reshook)) { $localtax1_tx = get_localtax($tva_tx, 1, $object->thirdparty, $mysoc, $tva_npr); $localtax2_tx = get_localtax($tva_tx, 2, $object->thirdparty, $mysoc, $tva_npr); - $pu_ht_devise = price2num(GETPOST('multicurrency_subprice'), '', 2); + $pu_ht_devise = price2num($price_ht_devise, '', 2); $pu_ttc_devise = price2num(GETPOST('multicurrency_subprice_ttc'), '', 2); // Prepare a price equivalent for minimum price check diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index 6837d1dad9c..a9418197592 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -1722,7 +1722,7 @@ if (empty($reshook)) { $pu_ht = price2num($pu_ttc / (1 + ($tva_tx / 100)), 'MU'); // $pu_ht must be rounded according to settings } $price_base_type = 'HT'; - $pu_devise = price2num($price_devise, 'CU'); + $pu_devise = price2num($price_ht_devise, 'CU'); $result = $object->addline($product_desc, $pu_ht, $tva_tx, $localtax1_tx, $localtax2_tx, $qty, 0, $remise_percent, $date_start, $date_end, 0, $tva_npr, $price_base_type, $type, -1, 0, $array_options, $fk_unit, 0, $pu_devise, $ref_supplier); } From 5a15ff99319d19a715801d122f6b2c5d38ffa1b8 Mon Sep 17 00:00:00 2001 From: thibdrev Date: Thu, 25 Jan 2024 12:03:22 +0100 Subject: [PATCH 36/65] qual: phpstan for htdocs/variants/class/ProductAttribute.class.php htdocs/variants/class/ProductAttribute.class.php 1315 Parameter #2 $seller (string) of method ProductAttribute::printObjectLines() should be compatible with parameter $seller (Societe) of method CommonObject::printObjectLines() htdocs/variants/class/ProductAttribute.class.php 1315 Parameter #3 $buyer (string) of method ProductAttribute::printObjectLines() should be compatible with parameter $buyer (Societe) of method CommonObject::printObjectLines() htdocs/variants/class/ProductAttribute.class.php 1401 Parameter #7 $seller (string) of method ProductAttribute::printObjectLine() should be compatible with parameter $seller (Societe) of method CommonObject::printObjectLine() htdocs/variants/class/ProductAttribute.class.php 1401 Parameter #8 $buyer (string) of method ProductAttribute::printObjectLine() should be compatible with parameter $buyer (Societe) of method CommonObject::printObjectLine() --- htdocs/variants/class/ProductAttribute.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/variants/class/ProductAttribute.class.php b/htdocs/variants/class/ProductAttribute.class.php index b16afb3b037..3e09e5362a5 100644 --- a/htdocs/variants/class/ProductAttribute.class.php +++ b/htdocs/variants/class/ProductAttribute.class.php @@ -1304,8 +1304,8 @@ class ProductAttribute extends CommonObject * But for the moment we don't know if it's possible as we keep a method available on overloaded objects. * * @param string $action Action code - * @param string $seller Object of seller third party - * @param string $buyer Object of buyer third party + * @param Societe $seller Object of seller third party + * @param Societe $buyer Object of buyer third party * @param int $selected Object line selected * @param int $dateSelector 1=Show also date range input fields * @param string $defaulttpldir Directory where to find the template From da625fc8472c5d7b324e3bb262a242f2ac553fa1 Mon Sep 17 00:00:00 2001 From: Maximilien Valenzano Date: Thu, 25 Jan 2024 12:06:13 +0100 Subject: [PATCH 37/65] fix: propal use devise changes --- htdocs/comm/propal/card.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index 1bc57c89698..1156df8a2c6 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -1171,6 +1171,10 @@ if (empty($reshook)) { if (!empty($price_ht) || (string) $price_ht === '0') { $pu_ht = price2num($price_ht, 'MU'); $pu_ttc = price2num($pu_ht * (1 + ((float) $tmpvat / 100)), 'MU'); + } elseif (!empty($price_ht_devise) || (string) $price_ht_devise === '0') { + $pu_ht_devise = price2num($price_ht_devise, 'MU'); + $pu_ht = ''; + $pu_ttc = ''; } elseif (!empty($price_ttc) || (string) $price_ttc === '0') { $pu_ttc = price2num($price_ttc, 'MU'); $pu_ht = price2num($pu_ttc / (1 + ((float) $tmpvat / 100)), 'MU'); From a22adbf80264c273fabfb364d9848e5ba3177c29 Mon Sep 17 00:00:00 2001 From: thibdrev Date: Thu, 25 Jan 2024 12:22:09 +0100 Subject: [PATCH 38/65] qual: phpstan for htdocs/takepos/invoice.php htdocs/takepos/invoice.php 279 Property Paiement::$fk_account (int) does not accept array|string. htdocs/takepos/invoice.php 491 Property CommonInvoice::$socid (int) does not accept string. --- htdocs/takepos/invoice.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/htdocs/takepos/invoice.php b/htdocs/takepos/invoice.php index 924a5779ec4..5d7eb3e52fd 100644 --- a/htdocs/takepos/invoice.php +++ b/htdocs/takepos/invoice.php @@ -175,15 +175,15 @@ if (empty($reshook)) { $error = 0; if (getDolGlobalString('TAKEPOS_CAN_FORCE_BANK_ACCOUNT_DURING_PAYMENT')) { - $bankaccount = GETPOST('accountid', 'int'); + $bankaccount = GETPOSTINT('accountid'); } else { if ($pay == 'LIQ') { - $bankaccount = getDolGlobalString('CASHDESK_ID_BANKACCOUNT_CASH'.$_SESSION["takeposterminal"]); // For backward compatibility + $bankaccount = getDolGlobalInt('CASHDESK_ID_BANKACCOUNT_CASH'.$_SESSION["takeposterminal"]); // For backward compatibility } elseif ($pay == "CHQ") { - $bankaccount = getDolGlobalString('CASHDESK_ID_BANKACCOUNT_CHEQUE'.$_SESSION["takeposterminal"]); // For backward compatibility + $bankaccount = getDolGlobalInt('CASHDESK_ID_BANKACCOUNT_CHEQUE'.$_SESSION["takeposterminal"]); // For backward compatibility } else { $accountname = "CASHDESK_ID_BANKACCOUNT_".$pay.$_SESSION["takeposterminal"]; - $bankaccount = getDolGlobalString($accountname); + $bankaccount = getDolGlobalInt($accountname); } } @@ -488,7 +488,7 @@ if (empty($reshook)) { // If we add a line and no invoice yet, we create the invoice if (($action == "addline" || $action == "freezone") && $placeid == 0 && ($user->hasRight('takepos', 'run') || defined('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE'))) { - $invoice->socid = getDolGlobalString($constforcompanyid); + $invoice->socid = getDolGlobalInt($constforcompanyid); $invoice->date = dol_now('tzuserrel'); // We use the local date, only the day will be saved. $invoice->module_source = 'takepos'; $invoice->pos_source = isset($_SESSION["takeposterminal"]) ? $_SESSION["takeposterminal"] : '' ; From 2275dd9610c3841b08d2a164e93729a2ad1767e5 Mon Sep 17 00:00:00 2001 From: EchoLoGeek <73399671+EchoLoGeek@users.noreply.github.com> Date: Thu, 25 Jan 2024 12:27:07 +0100 Subject: [PATCH 39/65] Add morecss properties to common textarea --- htdocs/core/class/commonobject.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index fb41245579d..3a19d0961d9 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -7277,7 +7277,7 @@ abstract class CommonObject if (!preg_match('/search_/', $keyprefix)) { // If keyprefix is search_ or search_options_, we must just use a simple text field require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; $doleditor = new DolEditor($keyprefix.$key.$keysuffix, $value, '', 200, 'dolibarr_notes', 'In', false, false, false, ROWS_5, '90%'); - $out = $doleditor->Create(1); + $out = $doleditor->Create(1,'',true,'','','',$morecss); } else { $out = ''; } From b76245885dfb1a0c70013c2daf8c9f63576b77ba Mon Sep 17 00:00:00 2001 From: thibdrev Date: Thu, 25 Jan 2024 12:29:30 +0100 Subject: [PATCH 40/65] qual: phpstan for htdocs/salaries/class/salariesstats.class.php htdocs/salaries/class/salariesstats.class.php 100 Parameter #1 $year (string) of method SalariesStats::getNbByMonth() should be compatible with parameter $year (int) of method Stats::getNbByMonth() --- htdocs/salaries/class/salariesstats.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/salaries/class/salariesstats.class.php b/htdocs/salaries/class/salariesstats.class.php index fc687add5ea..f7b468653ed 100644 --- a/htdocs/salaries/class/salariesstats.class.php +++ b/htdocs/salaries/class/salariesstats.class.php @@ -93,9 +93,9 @@ class SalariesStats extends Stats /** * Return the number of salary by month, for a given year * - * @param string $year Year to scan + * @param int $year Year to scan * @param int $format 0=Label of abscissa is a translated text, 1=Label of abscissa is month number, 2=Label of abscissa is first letter of month - * @return array Array of values + * @return array Array of values by month */ public function getNbByMonth($year, $format = 0) { From 505841b1948b42cf02af6a4968ddc659e5ed1299 Mon Sep 17 00:00:00 2001 From: Maximilien Valenzano Date: Thu, 25 Jan 2024 12:38:06 +0100 Subject: [PATCH 41/65] fix: save change from product too --- htdocs/compta/facture/card.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 8e92b1c56dd..408a570656f 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -2193,6 +2193,10 @@ if (empty($reshook)) { if (!empty($price_ht) || $price_ht === '0') { $pu_ht = price2num($price_ht, 'MU'); $pu_ttc = price2num($pu_ht * (1 + ($tmpvat / 100)), 'MU'); + } elseif (!empty($price_ht_devise) || $price_ht_devise === '0') { + $pu_ht_devise = price2num($price_ht_devise, 'MU'); + $pu_ht = ''; + $pu_ttc = ''; } elseif (!empty($price_ttc) || $price_ttc === '0') { $pu_ttc = price2num($price_ttc, 'MU'); $pu_ht = price2num($pu_ttc / (1 + ($tmpvat / 100)), 'MU'); From 67db15827874ac6c0ee0d912c241f4d527ab6d24 Mon Sep 17 00:00:00 2001 From: EchoLoGeek <73399671+EchoLoGeek@users.noreply.github.com> Date: Thu, 25 Jan 2024 12:53:23 +0100 Subject: [PATCH 42/65] Fix PHPCS error --- htdocs/core/class/commonobject.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 3a19d0961d9..7c8e3cc2827 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -7277,7 +7277,7 @@ abstract class CommonObject if (!preg_match('/search_/', $keyprefix)) { // If keyprefix is search_ or search_options_, we must just use a simple text field require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; $doleditor = new DolEditor($keyprefix.$key.$keysuffix, $value, '', 200, 'dolibarr_notes', 'In', false, false, false, ROWS_5, '90%'); - $out = $doleditor->Create(1,'',true,'','','',$morecss); + $out = $doleditor->Create(1, '', true, '', '', '', $morecss); } else { $out = ''; } From 49b5c081d68b3caf3cb4fe094f09dcf50c816e34 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 25 Jan 2024 17:51:09 +0100 Subject: [PATCH 43/65] FIX HTML injection vulnerability in Dolibarr Application Home Page FIX #GHSA-7947-48q7-cp5m --- htdocs/filefunc.inc.php | 2 +- htdocs/main.inc.php | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/filefunc.inc.php b/htdocs/filefunc.inc.php index c3fd4705b6d..cba47566c2b 100644 --- a/htdocs/filefunc.inc.php +++ b/htdocs/filefunc.inc.php @@ -34,7 +34,7 @@ if (!defined('DOL_APPLICATION_TITLE')) { define('DOL_APPLICATION_TITLE', 'Dolibarr'); } if (!defined('DOL_VERSION')) { - define('DOL_VERSION', '18.0.4'); // a.b.c-alpha, a.b.c-beta, a.b.c-rcX or a.b.c + define('DOL_VERSION', '18.0.5'); // a.b.c-alpha, a.b.c-beta, a.b.c-rcX or a.b.c } if (!defined('EURO')) { diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index ab78b4bd5f7..0c6ecd25933 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -2164,6 +2164,7 @@ function top_menu($head, $title = '', $target = '', $disablejs = 0, $disablehead if (isset($_POST) && is_array($_POST)) { foreach ($_POST as $key => $value) { + $key = preg_replace('/[^a-z0-9_\-\[\]/i', '', $key); if (in_array($key, array('action', 'massaction', 'password'))) { continue; } From 088c1606df38f9b48334be7bf45d8cefa8c20f64 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 25 Jan 2024 17:57:44 +0100 Subject: [PATCH 44/65] Clean url --- htdocs/main.inc.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 0c6ecd25933..6b20c79e37c 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -2170,12 +2170,12 @@ function top_menu($head, $title = '', $target = '', $disablejs = 0, $disablehead } if (!is_array($value)) { if ($value !== '') { - $qs .= '&'.$key.'='.urlencode($value); + $qs .= '&'.urlencode($key).'='.urlencode($value); } } else { foreach ($value as $value2) { if (($value2 !== '') && (!is_array($value2))) { - $qs .= '&'.$key.'[]='.urlencode($value2); + $qs .= '&'.urlencode($key).'[]='.urlencode($value2); } } } From 4d971a9c337b2919cf8197a8c5eb99561f368089 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 25 Jan 2024 18:02:56 +0100 Subject: [PATCH 45/65] Fix regresion on print link --- htdocs/main.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 6b20c79e37c..9aede3af25a 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -2164,7 +2164,7 @@ function top_menu($head, $title = '', $target = '', $disablejs = 0, $disablehead if (isset($_POST) && is_array($_POST)) { foreach ($_POST as $key => $value) { - $key = preg_replace('/[^a-z0-9_\-\[\]/i', '', $key); + $key = preg_replace('/[^a-z0-9_\.\-\[\]]/i', '', $key); if (in_array($key, array('action', 'massaction', 'password'))) { continue; } From 6a3c5cce697bb3b4bc3d2a7d5628f356dcc339c1 Mon Sep 17 00:00:00 2001 From: Can Arslan <138895927+mc2rcanarslan@users.noreply.github.com> Date: Thu, 25 Jan 2024 11:14:55 -0700 Subject: [PATCH 46/65] FIX: wrong alias --- htdocs/core/lib/project.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/project.lib.php b/htdocs/core/lib/project.lib.php index 9f2dbc0f13e..d9a71380aa9 100644 --- a/htdocs/core/lib/project.lib.php +++ b/htdocs/core/lib/project.lib.php @@ -1116,7 +1116,7 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t // Check if Extrafields is totalizable if (!empty($extrafields->attributes['projet_task']['totalizable'])) { foreach ($extrafields->attributes['projet_task']['totalizable'] as $key => $value) { - if (!empty($arrayfields['efpt.'.$key]['checked']) && $arrayfields['ef.'.$key]['checked'] == 1) { + if (!empty($arrayfields['efpt.'.$key]['checked']) && $arrayfields['efpt.'.$key]['checked'] == 1) { print ''; if ($value == 1) { print empty($totalarray['totalizable'][$key]['total']) ? '' : $totalarray['totalizable'][$key]['total']; From 25661096488bbdc96d61d23e3a98bbb2db3152f4 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 25 Jan 2024 21:15:00 +0100 Subject: [PATCH 47/65] Fix lang --- htdocs/langs/am_ET/main.lang | 22 +++++++++++----------- htdocs/langs/en_US/main.lang | 2 +- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/htdocs/langs/am_ET/main.lang b/htdocs/langs/am_ET/main.lang index 9873e25a288..fa36fedbc52 100644 --- a/htdocs/langs/am_ET/main.lang +++ b/htdocs/langs/am_ET/main.lang @@ -9,26 +9,26 @@ DIRECTION=ltr # cid0kr is for Korean # DejaVuSans is for some Eastern languages, some Asian languages and some Arabic languages # freemono is for ru_RU or uk_UA, uz_UZ -# freeserif is for Tamil -FONTFORPDF=ሄልቬቲካ +# freeserif is for Tamil and Ethiopian +FONTFORPDF=freeserif FONTSIZEFORPDF=10 SeparatorDecimal=. SeparatorThousand=, FormatDateShort=%m/%d/%Y FormatDateShortInput=%m/%d/%Y -FormatDateShortJava=ወወ/ቀን/ዓዓ -FormatDateShortJavaInput=ወወ/ቀን/ዓዓ -FormatDateShortJQuery=ሚሜ/ቀን/ዓ -FormatDateShortJQueryInput=ሚሜ/ቀን/ዓ +FormatDateShortJava=MM/dd/yyyy +FormatDateShortJavaInput=MM/dd/yyyy +FormatDateShortJQuery=mm/dd/yy +FormatDateShortJQueryInput=mm/dd/yy FormatHourShortJQuery=HH:MI FormatHourShort=%I:%M %p -FormatHourShortDuration=%H፡%M -FormatDateTextShort=%b %d፣ %Y -FormatDateText=%B %d፣ %Y +FormatHourShortDuration=%H:%M +FormatDateTextShort=%b %d, %Y +FormatDateText=%B %d, %Y FormatDateHourShort=%m/%d/%Y %I:%M %p FormatDateHourSecShort=%m/%d/%Y %I:%M:%S %p -FormatDateHourTextShort=%b %d፣ %Y፣ %I:%M %p -FormatDateHourText=%B %d፣ %Y፣ %I:%M %p +FormatDateHourTextShort=%b %d, %Y, %I:%M %p +FormatDateHourText=%B %d, %Y, %I:%M %p DatabaseConnection=የውሂብ ጎታ ግንኙነት NoTemplateDefined=ለዚህ ኢሜይል አይነት ምንም አብነት የለም። AvailableVariables=የሚገኙ ተለዋዋጮች diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index 51959ce531e..3fba0afd472 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -9,7 +9,7 @@ DIRECTION=ltr # cid0kr is for Korean # DejaVuSans is for some Eastern languages, some Asian languages and some Arabic languages # freemono is for ru_RU or uk_UA, uz_UZ -# freeserif is for Tamil +# freeserif is for Tamil or Ethiopian FONTFORPDF=helvetica FONTSIZEFORPDF=10 SeparatorDecimal=. From 233e5a3307ebf7fb44e657304e8467c259ce3aac Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 25 Jan 2024 22:19:31 +0100 Subject: [PATCH 48/65] Fix trans --- htdocs/langs/az_AZ/main.lang | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/htdocs/langs/az_AZ/main.lang b/htdocs/langs/az_AZ/main.lang index 0f6a25d0396..fcfa356511c 100644 --- a/htdocs/langs/az_AZ/main.lang +++ b/htdocs/langs/az_AZ/main.lang @@ -10,16 +10,16 @@ DIRECTION=ltr # DejaVuSans is for some Eastern languages, some Asian languages and some Arabic languages # freemono is for ru_RU or uk_UA, uz_UZ # freeserif is for Tamil -FONTFORPDF=helvetica +FONTFORPDF=DejaVuSans FONTSIZEFORPDF=10 SeparatorDecimal=. SeparatorThousand=, FormatDateShort=%m/%d/%Y FormatDateShortInput=%m/%d/%Y -FormatDateShortJava=AA/gg/yyyy -FormatDateShortJavaInput=AA/gg/yyyy -FormatDateShortJQuery=mm/gg/yy -FormatDateShortJQueryInput=mm/gg/yy +FormatDateShortJava=MM/dd/yyyy +FormatDateShortJavaInput=MM/dd/yyyy +FormatDateShortJQuery=MM/dd/yy +FormatDateShortJQueryInput=MM/dd/yy FormatHourShortJQuery=HH:MI FormatHourShort=%I:%M %p FormatHourShortDuration=%H:%M From c6d59e5ddda0c91746eee654ce274383b1dcc3a3 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 25 Jan 2024 22:31:56 +0100 Subject: [PATCH 49/65] Fix lang --- htdocs/langs/bn_BD/main.lang | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/langs/bn_BD/main.lang b/htdocs/langs/bn_BD/main.lang index 61fe55edd1a..f3db4028e10 100644 --- a/htdocs/langs/bn_BD/main.lang +++ b/htdocs/langs/bn_BD/main.lang @@ -1,5 +1,5 @@ # Dolibarr language file - Source file is en_US - main -DIRECTION=লিটার +DIRECTION=ltr # Default for FONTFORPDF=helvetica # Note for Chinese: # msungstdlight or cid0ct are for traditional Chinese zh_TW (traditional does not render with Ubuntu pdf reader) @@ -10,7 +10,7 @@ DIRECTION=লিটার # DejaVuSans is for some Eastern languages, some Asian languages and some Arabic languages # freemono is for ru_RU or uk_UA, uz_UZ # freeserif is for Tamil -FONTFORPDF=হেলভেটিকা +FONTFORPDF=helvetica FONTSIZEFORPDF=10 SeparatorDecimal=. SeparatorThousand=, From 314dd5272fef0a2332af7195a108de766eb47097 Mon Sep 17 00:00:00 2001 From: MDW Date: Thu, 25 Jan 2024 19:17:30 +0100 Subject: [PATCH 50/65] Fix spelling dont -> don't --- htdocs/admin/receiptprinter.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/htdocs/admin/receiptprinter.php b/htdocs/admin/receiptprinter.php index dd946c6a8ee..1305f812c76 100644 --- a/htdocs/admin/receiptprinter.php +++ b/htdocs/admin/receiptprinter.php @@ -3,6 +3,7 @@ * Copyright (C) 2015 Frederic France * Copyright (C) 2016 Juanjo Menent * Copyright (C) 2020 Andreu Bisquerra Gaya + * Copyright (C) 2024 MDW * * 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 @@ -322,7 +323,7 @@ if ($mode == 'config' && $user->admin) { print load_fiche_titre($langs->trans("ReceiptPrinterDesc"), '', '')."\n"; - print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table + print '
'; // You can use div-table-responsive-no-min if you don't need reserved height for your table print ''."\n"; print ''; print ''; @@ -416,7 +417,7 @@ if ($mode == 'config' && $user->admin) { print ''.$langs->trans("ReceiptPrinterTypeDesc").'...

'."\n"; - print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table + print '
'; // You can use div-table-responsive-no-min if you don't need reserved height for your table print '
'.$langs->trans("Name").'
'."\n"; print ''; print ''; @@ -445,7 +446,7 @@ if ($mode == 'template' && $user->admin) { print ''; } - print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table + print '
'; // You can use div-table-responsive-no-min if you don't need reserved height for your table print '
'.$langs->trans("CONNECTOR_DUMMY").''.$langs->trans("CONNECTOR_DUMMY_HELP").'
'.$form->textwithpicto($langs->trans("CONNECTOR_NETWORK_PRINT"), $langs->trans("FromServerPointOfView")).''.$langs->trans("CONNECTOR_NETWORK_PRINT_HELP").'
'."\n"; print ''; print ''; @@ -512,7 +513,7 @@ if ($mode == 'template' && $user->admin) { print '
'; - print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table + print '
'; // You can use div-table-responsive-no-min if you don't need reserved height for your table print '
'.$langs->trans("Name").'
'."\n"; print ''; print ''; From fe7140304699a917db1d490c05dccd1bfabb38b5 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 25 Jan 2024 23:08:46 +0100 Subject: [PATCH 51/65] Fix from #27807 added manually to fix one bug at time --- htdocs/fourn/facture/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index 6837d1dad9c..a9418197592 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -1722,7 +1722,7 @@ if (empty($reshook)) { $pu_ht = price2num($pu_ttc / (1 + ($tva_tx / 100)), 'MU'); // $pu_ht must be rounded according to settings } $price_base_type = 'HT'; - $pu_devise = price2num($price_devise, 'CU'); + $pu_devise = price2num($price_ht_devise, 'CU'); $result = $object->addline($product_desc, $pu_ht, $tva_tx, $localtax1_tx, $localtax2_tx, $qty, 0, $remise_percent, $date_start, $date_end, 0, $tva_npr, $price_base_type, $type, -1, 0, $array_options, $fk_unit, 0, $pu_devise, $ref_supplier); } From 5448261947bf5ad20ae2afb31c9992a5f47fa2fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Thu, 25 Jan 2024 23:32:53 +0100 Subject: [PATCH 52/65] fix pre-commit --- htdocs/admin/receiptprinter.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/admin/receiptprinter.php b/htdocs/admin/receiptprinter.php index dd946c6a8ee..85ef7aeb067 100644 --- a/htdocs/admin/receiptprinter.php +++ b/htdocs/admin/receiptprinter.php @@ -322,7 +322,7 @@ if ($mode == 'config' && $user->admin) { print load_fiche_titre($langs->trans("ReceiptPrinterDesc"), '', '')."\n"; - print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table + print '
'; // You can use div-table-responsive-no-min if you don't need reserved height for your table print '
'.$langs->trans("Tag").'
'."\n"; print ''; print ''; @@ -416,7 +416,7 @@ if ($mode == 'config' && $user->admin) { print ''.$langs->trans("ReceiptPrinterTypeDesc").'...

'."\n"; - print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table + print '
'; // You can use div-table-responsive-no-min if you don't need reserved height for your table print '
'.$langs->trans("Name").'
'."\n"; print ''; print ''; @@ -445,7 +445,7 @@ if ($mode == 'template' && $user->admin) { print ''; } - print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table + print '
'; // You can use div-table-responsive-no-min if you don't need reserved height for your table print '
'.$langs->trans("CONNECTOR_DUMMY").''.$langs->trans("CONNECTOR_DUMMY_HELP").'
'.$form->textwithpicto($langs->trans("CONNECTOR_NETWORK_PRINT"), $langs->trans("FromServerPointOfView")).''.$langs->trans("CONNECTOR_NETWORK_PRINT_HELP").'
'."\n"; print ''; print ''; @@ -512,7 +512,7 @@ if ($mode == 'template' && $user->admin) { print '
'; - print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table + print '
'; // You can use div-table-responsive-no-min if you don't need reserved height for your table print '
'.$langs->trans("Name").'
'."\n"; print ''; print ''; From eb3a6e22972590f7cdf34ab4cd43da9291f8d31d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 26 Jan 2024 00:20:14 +0100 Subject: [PATCH 53/65] Clean code --- 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 408a570656f..a65358b7d58 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -2318,7 +2318,7 @@ if (empty($reshook)) { $localtax2_tx = get_localtax($tva_tx, 2, $object->thirdparty, $mysoc, $tva_npr); $pu_ht_devise = price2num($price_ht_devise, '', 2); - $pu_ttc_devise = price2num(GETPOST('multicurrency_subprice_ttc'), '', 2); + $pu_ttc_devise = price2num($price_ttc_devise, '', 2); // Prepare a price equivalent for minimum price check $pu_equivalent = $pu_ht; From 66a628b306e04bbbecbd1b0b6b2cbb0f312699f3 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 26 Jan 2024 01:08:59 +0100 Subject: [PATCH 54/65] Removed useless initHook. Must use the context of main calling page. --- htdocs/product/class/product.class.php | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 4a5b413177d..f448edfd3d8 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -5852,7 +5852,6 @@ class Product extends CommonObject $this->stock_theorique += ($stock_commande_fournisseur - $stock_reception_fournisseur); } - $hookmanager->initHooks(array('productdao')); $parameters = array('id'=>$this->id, 'includedraftpoforvirtual' => $includedraftpoforvirtual); // Note that $action and $object may have been modified by some hooks $reshook = $hookmanager->executeHooks('loadvirtualstock', $parameters, $this, $action); From 8795e58c252b7219e1c1764e225929d584b3427d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 26 Jan 2024 01:42:33 +0100 Subject: [PATCH 55/65] Doc --- ChangeLog | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 9cdbbb06e38..1e66b4ee536 100644 --- a/ChangeLog +++ b/ChangeLog @@ -253,7 +253,7 @@ The following changes may create regressions for some external modules, but were * Hidden option ACCOUNTANCY_AUTOFIX_MISSING_LINK_TO_USEr_ON_SALARY_BANK_PAYMENT has been renamed into ACCOUNTANCY_AUTOFIX_MISSING_LINK_TO_USER_ON_SALARY_BANK_PAYMENT * The delete() method of AdherentType, Contact, Delivery, MultiCurrency, CurrencyRate now need $user as first parameter. * A very high number of class properties (with old name in french) are now deprecated in favor of the property name in english. - +* The load of hook context productdao has been removed before calling loadvirtualstock. Modules must use the context of main parent page or 'all' for all cases. ***** ChangeLog for 18.0.4 compared to 18.0.3 ***** FIX: $this->newref already exists and could have been modified by trigger but we still use a local variable for the filesystem-based renaming From 3a6468dd33d3a3991f802d92dd91ebcc6df60a3d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 26 Jan 2024 01:52:06 +0100 Subject: [PATCH 56/65] Fix init hook context "cli" for all cli scripts --- htdocs/modulebuilder/template/scripts/mymodule.php | 6 ++++++ scripts/bank/export-bank-receipts.php | 3 +++ scripts/company/sync_contacts_dolibarr2ldap.php | 3 +++ scripts/contracts/email_expire_services_to_customers.php | 3 +++ .../contracts/email_expire_services_to_representatives.php | 3 +++ scripts/doc/regenerate_docs.php | 7 +++++++ scripts/emailings/mailing-send.php | 3 +++ scripts/emailings/reset-invalid-emails.php | 2 ++ scripts/invoices/email_unpaid_invoices_to_customers.php | 3 +++ .../invoices/email_unpaid_invoices_to_representatives.php | 3 +++ scripts/invoices/rebuild_merge_pdf.php | 2 ++ scripts/members/sync_members_dolibarr2ldap.php | 3 +++ scripts/members/sync_members_ldap2dolibarr.php | 3 +++ scripts/members/sync_members_types_dolibarr2ldap.php | 3 +++ scripts/members/sync_members_types_ldap2dolibarr.php | 3 +++ scripts/product/migrate_picture_path.php | 7 +++++++ scripts/product/regenerate_thumbs.php | 6 ++++++ scripts/user/migrate_picture_path.php | 7 +++++++ scripts/user/sync_groups_dolibarr2ldap.php | 3 +++ scripts/user/sync_groups_ldap2dolibarr.php | 3 +++ scripts/user/sync_users_dolibarr2ldap.php | 3 +++ scripts/user/sync_users_ldap2dolibarr.php | 3 +++ scripts/website/migrate-news-joomla2dolibarr.php | 2 ++ scripts/website/regenerate-pages.php | 2 ++ scripts/withdrawals/build_withdrawal_file.php | 3 +++ 25 files changed, 89 insertions(+) diff --git a/htdocs/modulebuilder/template/scripts/mymodule.php b/htdocs/modulebuilder/template/scripts/mymodule.php index 7ced7fd6c6f..9bb5d54cfa5 100644 --- a/htdocs/modulebuilder/template/scripts/mymodule.php +++ b/htdocs/modulebuilder/template/scripts/mymodule.php @@ -107,6 +107,12 @@ if (!($result > 0)) { } $user->getrights(); +$hookmanager->initHooks(array('cli')); + + +/* + * Main + */ print "***** ".$script_file." (".$version.") pid=".dol_getmypid()." *****\n"; if (!isset($argv[1])) { // Check parameters diff --git a/scripts/bank/export-bank-receipts.php b/scripts/bank/export-bank-receipts.php index 522bc5680a9..87cd5a4cffa 100755 --- a/scripts/bank/export-bank-receipts.php +++ b/scripts/bank/export-bank-receipts.php @@ -56,6 +56,9 @@ require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/paymentsocialcontribution $version = DOL_VERSION; $error = 0; +$hookmanager->initHooks(array('cli')); + + /* * Main */ diff --git a/scripts/company/sync_contacts_dolibarr2ldap.php b/scripts/company/sync_contacts_dolibarr2ldap.php index 7d31bb0f79d..0ea0bb77119 100755 --- a/scripts/company/sync_contacts_dolibarr2ldap.php +++ b/scripts/company/sync_contacts_dolibarr2ldap.php @@ -48,6 +48,9 @@ $version = DOL_VERSION; $error = 0; $confirmed = 0; +$hookmanager->initHooks(array('cli')); + + /* * Main */ diff --git a/scripts/contracts/email_expire_services_to_customers.php b/scripts/contracts/email_expire_services_to_customers.php index 24f1529d341..9f6364b4f46 100755 --- a/scripts/contracts/email_expire_services_to_customers.php +++ b/scripts/contracts/email_expire_services_to_customers.php @@ -61,6 +61,9 @@ $langs->loadLangs(array('main', 'contracts')); $version = DOL_VERSION; $error = 0; +$hookmanager->initHooks(array('cli')); + + /* * Main */ diff --git a/scripts/contracts/email_expire_services_to_representatives.php b/scripts/contracts/email_expire_services_to_representatives.php index 43c46c8a1b4..282d348e184 100755 --- a/scripts/contracts/email_expire_services_to_representatives.php +++ b/scripts/contracts/email_expire_services_to_representatives.php @@ -59,6 +59,9 @@ $langs->loadLangs(array('main', 'contracts')); $version = DOL_VERSION; $error = 0; +$hookmanager->initHooks(array('cli')); + + /* * Main */ diff --git a/scripts/doc/regenerate_docs.php b/scripts/doc/regenerate_docs.php index 34e732d9827..192b473f0f3 100755 --- a/scripts/doc/regenerate_docs.php +++ b/scripts/doc/regenerate_docs.php @@ -56,6 +56,13 @@ $version = DOL_VERSION; $error = 0; $forcecommit = 0; +$hookmanager->initHooks(array('cli')); + + +/* + * Main + */ + print "***** ".$script_file." (".$version.") pid=".dol_getmypid()." - dir=".DOL_DATA_ROOT." *****\n"; dol_syslog($script_file." launched with arg ".join(',', $argv)); diff --git a/scripts/emailings/mailing-send.php b/scripts/emailings/mailing-send.php index 77871ecbf0b..2b55389be41 100755 --- a/scripts/emailings/mailing-send.php +++ b/scripts/emailings/mailing-send.php @@ -25,6 +25,7 @@ * \ingroup mailing * \brief Script to send a prepared and validated emaling from command line */ + if (!defined('NOSESSION')) { define('NOSESSION', '1'); } @@ -78,6 +79,8 @@ if (!isModEnabled('mailing')) { exit(-1); } +$hookmanager->initHooks(array('cli')); + /* * Main diff --git a/scripts/emailings/reset-invalid-emails.php b/scripts/emailings/reset-invalid-emails.php index ca383143c3a..45abb45715d 100755 --- a/scripts/emailings/reset-invalid-emails.php +++ b/scripts/emailings/reset-invalid-emails.php @@ -62,6 +62,8 @@ if (!isModEnabled('mailing')) { exit(-1); } +$hookmanager->initHooks(array('cli')); + /* * Main diff --git a/scripts/invoices/email_unpaid_invoices_to_customers.php b/scripts/invoices/email_unpaid_invoices_to_customers.php index 2a5a199db4d..ea544538b07 100755 --- a/scripts/invoices/email_unpaid_invoices_to_customers.php +++ b/scripts/invoices/email_unpaid_invoices_to_customers.php @@ -61,6 +61,9 @@ $langs->load('main'); $version = DOL_VERSION; $error = 0; +$hookmanager->initHooks(array('cli')); + + /* * Main */ diff --git a/scripts/invoices/email_unpaid_invoices_to_representatives.php b/scripts/invoices/email_unpaid_invoices_to_representatives.php index e5da2436d67..48f399fed57 100755 --- a/scripts/invoices/email_unpaid_invoices_to_representatives.php +++ b/scripts/invoices/email_unpaid_invoices_to_representatives.php @@ -59,6 +59,9 @@ $langs->load('main'); $version = DOL_VERSION; $error = 0; +$hookmanager->initHooks(array('cli')); + + /* * Main */ diff --git a/scripts/invoices/rebuild_merge_pdf.php b/scripts/invoices/rebuild_merge_pdf.php index 1d513151d96..0c1545cf309 100755 --- a/scripts/invoices/rebuild_merge_pdf.php +++ b/scripts/invoices/rebuild_merge_pdf.php @@ -52,6 +52,8 @@ $langs->load("main"); $version = DOL_VERSION; $error = 0; +$hookmanager->initHooks(array('cli')); + /* * Main diff --git a/scripts/members/sync_members_dolibarr2ldap.php b/scripts/members/sync_members_dolibarr2ldap.php index 705ffb17852..d21bf34710d 100755 --- a/scripts/members/sync_members_dolibarr2ldap.php +++ b/scripts/members/sync_members_dolibarr2ldap.php @@ -49,6 +49,9 @@ $version = constant('DOL_VERSION'); $error = 0; $confirmed = 0; +$hookmanager->initHooks(array('cli')); + + /* * Main */ diff --git a/scripts/members/sync_members_ldap2dolibarr.php b/scripts/members/sync_members_ldap2dolibarr.php index ea183191086..53c0d945e63 100755 --- a/scripts/members/sync_members_ldap2dolibarr.php +++ b/scripts/members/sync_members_ldap2dolibarr.php @@ -52,6 +52,9 @@ $error = 0; $forcecommit = 0; $confirmed = 0; +$hookmanager->initHooks(array('cli')); + + /* * Main */ diff --git a/scripts/members/sync_members_types_dolibarr2ldap.php b/scripts/members/sync_members_types_dolibarr2ldap.php index 8c118fbcc5b..356ac35f0ee 100755 --- a/scripts/members/sync_members_types_dolibarr2ldap.php +++ b/scripts/members/sync_members_types_dolibarr2ldap.php @@ -54,6 +54,9 @@ require_once DOL_DOCUMENT_ROOT."/adherents/class/adherent_type.class.php"; $version = constant('DOL_VERSION'); $error = 0; +$hookmanager->initHooks(array('cli')); + + /* * Main */ diff --git a/scripts/members/sync_members_types_ldap2dolibarr.php b/scripts/members/sync_members_types_ldap2dolibarr.php index 0ef44facabb..fe62ce536fd 100755 --- a/scripts/members/sync_members_types_ldap2dolibarr.php +++ b/scripts/members/sync_members_types_ldap2dolibarr.php @@ -53,6 +53,9 @@ $error = 0; $forcecommit = 0; $confirmed = 0; +$hookmanager->initHooks(array('cli')); + + /* * Main */ diff --git a/scripts/product/migrate_picture_path.php b/scripts/product/migrate_picture_path.php index 2f5a772fe8e..1bc036710d9 100755 --- a/scripts/product/migrate_picture_path.php +++ b/scripts/product/migrate_picture_path.php @@ -56,6 +56,13 @@ $version = DOL_VERSION; $error = 0; $forcecommit = 0; +$hookmanager->initHooks(array('cli')); + + +/* + * Main + */ + print "***** ".$script_file." (".$version.") pid=".dol_getmypid()." *****\n"; dol_syslog($script_file." launched with arg ".join(',', $argv)); diff --git a/scripts/product/regenerate_thumbs.php b/scripts/product/regenerate_thumbs.php index b81e93c053e..56ac6266e0b 100755 --- a/scripts/product/regenerate_thumbs.php +++ b/scripts/product/regenerate_thumbs.php @@ -56,6 +56,12 @@ $version = DOL_VERSION; $error = 0; $forcecommit = 0; +$hookmanager->initHooks(array('cli')); + +/* + * Main + */ + print "***** ".$script_file." (".$version.") pid=".dol_getmypid()." *****\n"; dol_syslog($script_file." launched with arg ".join(',', $argv)); diff --git a/scripts/user/migrate_picture_path.php b/scripts/user/migrate_picture_path.php index d64c843767f..e4df16b9801 100755 --- a/scripts/user/migrate_picture_path.php +++ b/scripts/user/migrate_picture_path.php @@ -56,6 +56,13 @@ $version = DOL_VERSION; $error = 0; $forcecommit = 0; +$hookmanager->initHooks(array('cli')); + + +/* + * Main + */ + print "***** ".$script_file." (".$version.") pid=".dol_getmypid()." *****\n"; dol_syslog($script_file." launched with arg ".join(',', $argv)); diff --git a/scripts/user/sync_groups_dolibarr2ldap.php b/scripts/user/sync_groups_dolibarr2ldap.php index 4dbdf3ae5eb..e64b2ff5130 100755 --- a/scripts/user/sync_groups_dolibarr2ldap.php +++ b/scripts/user/sync_groups_dolibarr2ldap.php @@ -52,6 +52,9 @@ require_once DOL_DOCUMENT_ROOT."/user/class/usergroup.class.php"; $version = DOL_VERSION; $error = 0; +$hookmanager->initHooks(array('cli')); + + /* * Main */ diff --git a/scripts/user/sync_groups_ldap2dolibarr.php b/scripts/user/sync_groups_ldap2dolibarr.php index 7712e688e7c..ed994cdd4f3 100755 --- a/scripts/user/sync_groups_ldap2dolibarr.php +++ b/scripts/user/sync_groups_ldap2dolibarr.php @@ -53,6 +53,9 @@ $error = 0; $forcecommit = 0; $confirmed = 0; +$hookmanager->initHooks(array('cli')); + + /* * Main */ diff --git a/scripts/user/sync_users_dolibarr2ldap.php b/scripts/user/sync_users_dolibarr2ldap.php index 4241d56ba5a..df49b035a69 100755 --- a/scripts/user/sync_users_dolibarr2ldap.php +++ b/scripts/user/sync_users_dolibarr2ldap.php @@ -52,6 +52,9 @@ require_once DOL_DOCUMENT_ROOT."/user/class/user.class.php"; $version = DOL_VERSION; $error = 0; +$hookmanager->initHooks(array('cli')); + + /* * Main */ diff --git a/scripts/user/sync_users_ldap2dolibarr.php b/scripts/user/sync_users_ldap2dolibarr.php index 145a8a7e41c..98800b07a97 100755 --- a/scripts/user/sync_users_ldap2dolibarr.php +++ b/scripts/user/sync_users_ldap2dolibarr.php @@ -52,6 +52,9 @@ $forcecommit = 0; $excludeuser = array(); $confirmed = 0; +$hookmanager->initHooks(array('cli')); + + /* * Main */ diff --git a/scripts/website/migrate-news-joomla2dolibarr.php b/scripts/website/migrate-news-joomla2dolibarr.php index f07e52c71d9..fbfd77a5230 100755 --- a/scripts/website/migrate-news-joomla2dolibarr.php +++ b/scripts/website/migrate-news-joomla2dolibarr.php @@ -63,6 +63,8 @@ include_once DOL_DOCUMENT_ROOT.'/website/class/website.class.php'; include_once DOL_DOCUMENT_ROOT.'/website/class/websitepage.class.php'; include_once DOL_DOCUMENT_ROOT.'/core/lib/website2.lib.php'; +$hookmanager->initHooks(array('cli')); + /* * Main diff --git a/scripts/website/regenerate-pages.php b/scripts/website/regenerate-pages.php index 8e4b1279532..7329d4d1ba3 100755 --- a/scripts/website/regenerate-pages.php +++ b/scripts/website/regenerate-pages.php @@ -58,6 +58,8 @@ include_once DOL_DOCUMENT_ROOT.'/website/class/website.class.php'; include_once DOL_DOCUMENT_ROOT.'/website/class/websitepage.class.php'; include_once DOL_DOCUMENT_ROOT.'/core/lib/website2.lib.php'; +$hookmanager->initHooks(array('cli')); + /* * Main diff --git a/scripts/withdrawals/build_withdrawal_file.php b/scripts/withdrawals/build_withdrawal_file.php index e6b99c51369..66d2cc52689 100755 --- a/scripts/withdrawals/build_withdrawal_file.php +++ b/scripts/withdrawals/build_withdrawal_file.php @@ -47,6 +47,9 @@ require_once DOL_DOCUMENT_ROOT."/compta/paiement/class/paiement.class.php"; $version = constant('DOL_VERSION'); $error = 0; +$hookmanager->initHooks(array('cli')); + + /* * Main */ From b9a4a4d8d2c01e1e8dffa5f4921e7c429aff2874 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 26 Jan 2024 02:17:36 +0100 Subject: [PATCH 57/65] Update card.php --- htdocs/compta/tva/card.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/compta/tva/card.php b/htdocs/compta/tva/card.php index 6fdf926a8b9..695f3ee45bb 100644 --- a/htdocs/compta/tva/card.php +++ b/htdocs/compta/tva/card.php @@ -329,7 +329,8 @@ if (empty($reshook)) { $object->fetch($id); if ($object->id > 0) { - $object->id = $object->ref = 0; + $object->id = 0; + $object->ref = null; $object->paye = 0; if (GETPOST('amount', 'alphanohtml')) { From c5dc8bbcb142f61641376f0f5f6aee101419452d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 26 Jan 2024 02:20:18 +0100 Subject: [PATCH 58/65] Update paymentsocialcontribution.class.php --- .../sociales/class/paymentsocialcontribution.class.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/htdocs/compta/sociales/class/paymentsocialcontribution.class.php b/htdocs/compta/sociales/class/paymentsocialcontribution.class.php index 306b552c1f3..c777b7ee9c8 100644 --- a/htdocs/compta/sociales/class/paymentsocialcontribution.class.php +++ b/htdocs/compta/sociales/class/paymentsocialcontribution.class.php @@ -532,12 +532,12 @@ class PaymentSocialContribution extends CommonObject { $this->id = 0; $this->fk_charge = 0; - $this->datec = ''; - $this->tms = ''; - $this->datep = ''; - $this->amount = ''; + $this->datec = dol_now(); + $this->tms = dol_now(); + $this->datep = dol_now(); + $this->amount = 100; $this->fk_typepaiement = ''; - $this->num_payment = 0; + $this->num_payment = 'ABC123'; $this->note_private = ''; $this->note_public = ''; $this->fk_bank = 0; From c8e11e114562c3b0240da2f1e482938ac56243db Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 26 Jan 2024 02:26:26 +0100 Subject: [PATCH 59/65] Update facture.class.php --- htdocs/compta/facture/class/facture.class.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 6cceb507144..33b8952e9f0 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -4443,10 +4443,10 @@ class Facture extends CommonInvoice $this->db->begin(); - $sql = 'UPDATE '.MAIN_DB_PREFIX.'facture'; - $sql .= ' SET remise_percent = '.$remise; + $sql = "UPDATE ".MAIN_DB_PREFIX."facture"; + $sql .= " SET remise_percent = ".((float) $remise); $sql .= " WHERE rowid = ".((int) $this->id); - $sql .= ' AND fk_statut = '.self::STATUS_DRAFT; + $sql .= " AND fk_statut = ".((int) self::STATUS_DRAFT); dol_syslog(__METHOD__, LOG_DEBUG); $resql = $this->db->query($sql); From 06a90b5d1b053fa2f725034298dc1e0c60b41920 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 26 Jan 2024 02:27:09 +0100 Subject: [PATCH 60/65] Update facture.class.php --- 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 33b8952e9f0..b1047c84903 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -4433,7 +4433,7 @@ class Facture extends CommonInvoice { // Clean parameters if (empty($remise)) { - $remise = 0.0; + $remise = 0; } if ($user->hasRight('facture', 'creer')) { From 45b2668340b6c9df02a558cdd756dd7dafa61f17 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 26 Jan 2024 02:29:03 +0100 Subject: [PATCH 61/65] Update paymentvarious.class.php --- htdocs/compta/bank/class/paymentvarious.class.php | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/htdocs/compta/bank/class/paymentvarious.class.php b/htdocs/compta/bank/class/paymentvarious.class.php index bc5eada4436..5215cb53170 100644 --- a/htdocs/compta/bank/class/paymentvarious.class.php +++ b/htdocs/compta/bank/class/paymentvarious.class.php @@ -379,13 +379,12 @@ class PaymentVarious extends CommonObject public function initAsSpecimen() { $this->id = 0; - - $this->tms = 0; - $this->datep = ''; - $this->datev = ''; + $this->tms = dol_now(); + $this->datep = dol_now(); + $this->datev = dol_now(); $this->sens = 0; - $this->amount = ''; - $this->label = ''; + $this->amount = 100; + $this->label = 'Specimen payment'; $this->accountancy_code = ''; $this->subledger_account = ''; $this->note = ''; From 3c2bc3a842d7535b8d0e4fecc25427378a55efb4 Mon Sep 17 00:00:00 2001 From: MDW Date: Fri, 26 Jan 2024 02:22:23 +0100 Subject: [PATCH 62/65] FIX Https detection theme/eldy/manifest.json.php was returning http:// links instead of the https link defined in the configuration. I found that this is because I am behide a proxy and that isHTTPS does the detection as expected. Therefore that function is used to detect https which results in the correct urls. Detected on my 18.0.2 installation --- htdocs/filefunc.inc.php | 3 ++- htdocs/main.inc.php | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/htdocs/filefunc.inc.php b/htdocs/filefunc.inc.php index c3fd4705b6d..bada1eb8011 100644 --- a/htdocs/filefunc.inc.php +++ b/htdocs/filefunc.inc.php @@ -286,8 +286,9 @@ if (!$found) { // There is no subdir that compose the main url root or autodetect fails (Ie: when using apache alias that point outside default DOCUMENT_ROOT). $tmp = $dolibarr_main_url_root; } else { - $tmp = 'http'.(((empty($_SERVER["HTTPS"]) || $_SERVER["HTTPS"] != 'on') && (empty($_SERVER["SERVER_PORT"]) || $_SERVER["SERVER_PORT"] != 443)) ? '' : 's').'://'.$_SERVER["SERVER_NAME"].((empty($_SERVER["SERVER_PORT"]) || $_SERVER["SERVER_PORT"] == 80 || $_SERVER["SERVER_PORT"] == 443) ? '' : ':'.$_SERVER["SERVER_PORT"]).($tmp3 ? (preg_match('/^\//', $tmp3) ? '' : '/').$tmp3 : ''); + $tmp = 'http'.((!isHTTPS() && (empty($_SERVER["SERVER_PORT"]) || $_SERVER["SERVER_PORT"] != 443)) ? '' : 's').'://'.$_SERVER["SERVER_NAME"].((empty($_SERVER["SERVER_PORT"]) || $_SERVER["SERVER_PORT"] == 80 || $_SERVER["SERVER_PORT"] == 443) ? '' : ':'.$_SERVER["SERVER_PORT"]).($tmp3 ? (preg_match('/^\//', $tmp3) ? '' : '/').$tmp3 : ''); } + //print "tmp1=".$tmp1." tmp2=".$tmp2." tmp3=".$tmp3." tmp=".$tmp."\n"; if (!empty($dolibarr_main_force_https)) { $tmp = preg_replace('/^http:/i', 'https:', $tmp); diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index ab78b4bd5f7..3ff49604e25 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -432,7 +432,7 @@ if (GETPOST('textbrowser', 'int') || (!empty($conf->browser->name) && $conf->bro // Force HTTPS if required ($conf->file->main_force_https is 0/1 or 'https dolibarr root url') // $_SERVER["HTTPS"] is 'on' when link is https, otherwise $_SERVER["HTTPS"] is empty or 'off' -if (!empty($conf->file->main_force_https) && (empty($_SERVER["HTTPS"]) || $_SERVER["HTTPS"] != 'on') && !defined('NOHTTPSREDIRECT')) { +if (!empty($conf->file->main_force_https) && isHTTPS() && !defined('NOHTTPSREDIRECT')) { $newurl = ''; if (is_numeric($conf->file->main_force_https)) { if ($conf->file->main_force_https == '1' && !empty($_SERVER["SCRIPT_URI"])) { // If SCRIPT_URI supported by server From 63ff08e0d160121e8c245693fac85a2a004b4b43 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 26 Jan 2024 03:17:34 +0100 Subject: [PATCH 63/65] Update bom.class.php --- htdocs/bom/class/bom.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/bom/class/bom.class.php b/htdocs/bom/class/bom.class.php index 64487507d5b..808acba17f6 100644 --- a/htdocs/bom/class/bom.class.php +++ b/htdocs/bom/class/bom.class.php @@ -792,7 +792,7 @@ class BOM extends CommonObject $line->array_options[$key] = $array_options[$key]; } } - if ($line->fk_default_workstation != $fk_default_workstation) { + if ($fk_default_workstation >= 0 && $line->fk_default_workstation != $fk_default_workstation) { $line->fk_default_workstation = $fk_default_workstation; } From f39a439895b7ea355f8af69428a84bc7d2fa22f4 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 26 Jan 2024 03:35:00 +0100 Subject: [PATCH 64/65] Clean code --- htdocs/adherents/class/api_members.class.php | 6 +++--- .../categories/class/api_categories.class.php | 17 ++++++++--------- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/htdocs/adherents/class/api_members.class.php b/htdocs/adherents/class/api_members.class.php index ea7da54148b..5cb0ee3c09c 100644 --- a/htdocs/adherents/class/api_members.class.php +++ b/htdocs/adherents/class/api_members.class.php @@ -423,7 +423,7 @@ class Members extends DolibarrApi * Validate fields before creating an object * * @param array|null $data Data to validate - * @return array + * @return array Return array with validated mandatory fields and their value * * @throws RestException */ @@ -443,8 +443,8 @@ class Members extends DolibarrApi /** * Clean sensible object datas * - * @param Object $object Object to clean - * @return Object Object with cleaned properties + * @param Object $object Object to clean + * @return Object Object with cleaned properties */ protected function _cleanObjectDatas($object) { diff --git a/htdocs/categories/class/api_categories.class.php b/htdocs/categories/class/api_categories.class.php index 159d7925e3a..12d8cd01284 100644 --- a/htdocs/categories/class/api_categories.class.php +++ b/htdocs/categories/class/api_categories.class.php @@ -70,7 +70,8 @@ class Categories extends DolibarrApi */ public function __construct() { - global $db, $conf; + global $db; + $this->db = $db; $this->category = new Categorie($this->db); } @@ -133,8 +134,6 @@ class Categories extends DolibarrApi */ public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $type = '', $sqlfilters = '', $properties = '') { - global $db, $conf; - $obj_ret = array(); if (!DolibarrApiAccess::$user->rights->categorie->lire) { @@ -198,8 +197,8 @@ class Categories extends DolibarrApi throw new RestException(401); } - // Check mandatory fields - $result = $this->_validate($request_data); + // Check mandatory fields (throw an exception if wrong) + $this->_validate($request_data); foreach ($request_data as $field => $value) { if ($field === 'caller') { @@ -666,8 +665,8 @@ class Categories extends DolibarrApi /** * Clean sensible object datas * - * @param Categorie $object Object to clean - * @return Object Object with cleaned properties + * @param Categorie $object Object to clean + * @return Object Object with cleaned properties */ protected function _cleanObjectDatas($object) { @@ -722,8 +721,8 @@ class Categories extends DolibarrApi /** * Validate fields before create or update object * - * @param array|null $data Data to validate - * @return array + * @param array|null $data Data to validate + * @return array Return array with validated mandatory fields and their value * * @throws RestException */ From 09c52d6cf97c33293ed8fa436a14713a8ac2fe37 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 26 Jan 2024 04:03:50 +0100 Subject: [PATCH 65/65] Update html.formmail.class.php --- htdocs/core/class/html.formmail.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index 0a201cf751c..285e37edbf4 100644 --- a/htdocs/core/class/html.formmail.class.php +++ b/htdocs/core/class/html.formmail.class.php @@ -889,7 +889,7 @@ class FormMail extends Form //input prompt AI require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; - if (isModEnabled('ai') && dolibarr_get_const($this->db, 'AI_CHATGPT_API_KEY', 0)) { + if (isModEnabled('ai') && getDolGlobalConst('AI_CHATGPT_API_KEY')) { $out .= $this->getHtmlForInstruction(); } // Message
'.$langs->trans("Tag").'