From 232f20100706b9d93c5e081f670d7daf44b892fd Mon Sep 17 00:00:00 2001 From: Francis Appels Date: Sun, 23 Feb 2020 17:02:08 +0100 Subject: [PATCH 001/147] Merge remote-tracking branch 'Dolibarr/11.0' into 11 --- htdocs/compta/facture/class/facture.class.php | 9 +++++++++ htdocs/core/lib/pdf.lib.php | 2 +- htdocs/cron/class/cronjob.class.php | 4 ++-- .../framework/Luracast/Restler/AutoLoader.php | 8 +------- .../framework/Luracast/Restler/CommentParser.php | 12 ++++++------ .../framework/Luracast/Restler/Format/XmlFormat.php | 2 +- .../restler/framework/Luracast/Restler/Resources.php | 6 +++--- .../restler/framework/Luracast/Restler/Restler.php | 4 ++-- .../restler/framework/Luracast/Restler/Routes.php | 6 +++--- .../restler/framework/Luracast/Restler/Scope.php | 2 +- .../restler/framework/Luracast/Restler/UI/Emmet.php | 4 ++-- htdocs/projet/element.php | 2 +- htdocs/theme/eldy/global.inc.php | 2 +- 13 files changed, 33 insertions(+), 30 deletions(-) diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index d4a7efd3cf4..99cc638c36f 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -1156,6 +1156,14 @@ class Facture extends CommonInvoice $line->date_start = $object->lines[$i]->date_start; $line->date_end = $object->lines[$i]->date_end; + // Multicurrency + $line->fk_multicurrency = $object->lines[$i]->fk_multicurrency; + $line->multicurrency_code = $object->lines[$i]->multicurrency_code; + $line->multicurrency_subprice = $object->lines[$i]->multicurrency_subprice; + $line->multicurrency_total_ht = $object->lines[$i]->multicurrency_total_ht; + $line->multicurrency_total_tva = $object->lines[$i]->multicurrency_total_tva; + $line->multicurrency_total_ttc = $object->lines[$i]->multicurrency_total_ttc; + $line->fk_fournprice = $object->lines[$i]->fk_fournprice; $marginInfos = getMarginInfos($object->lines[$i]->subprice, $object->lines[$i]->remise_percent, $object->lines[$i]->tva_tx, $object->lines[$i]->localtax1_tx, $object->lines[$i]->localtax2_tx, $object->lines[$i]->fk_fournprice, $object->lines[$i]->pa_ht); $line->pa_ht = $marginInfos[0]; @@ -1170,6 +1178,7 @@ class Facture extends CommonInvoice $this->socid = $object->socid; $this->fk_project = $object->fk_project; + $this->fk_account = $object->fk_account; $this->cond_reglement_id = $object->cond_reglement_id; $this->mode_reglement_id = $object->mode_reglement_id; $this->availability_id = $object->availability_id; diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index a5ba08bb139..59035258c74 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -1401,7 +1401,7 @@ function pdf_getlinedesc($object, $i, $outputlangs, $hideref = 0, $hidedesc = 0, foreach ($tblcateg as $cate) { // Adding the descriptions if they are filled - $desccateg = $cate->add_description; + $desccateg = $cate->description; if ($desccateg) $libelleproduitservice .= '__N__'.$desccateg; } diff --git a/htdocs/cron/class/cronjob.class.php b/htdocs/cron/class/cronjob.class.php index 5cde792bbb5..6139f157f8a 100644 --- a/htdocs/cron/class/cronjob.class.php +++ b/htdocs/cron/class/cronjob.class.php @@ -1320,9 +1320,9 @@ class Cronjob extends CommonObject if ($processing) $moretext = ' ('.$langs->trans("Running").')'; elseif ($lastresult) $moretext .= ' ('.$langs->trans("Error").')'; - $this->labelStatus[self::STATUS_DISABLED] = $langs->trans('Draft').$moretext; + $this->labelStatus[self::STATUS_DISABLED] = $langs->trans('Disabled').$moretext; $this->labelStatus[self::STATUS_ENABLED] = $langs->trans('Enabled').$moretext; - $this->labelStatusShort[self::STATUS_DISABLED] = $langs->trans('Draft'); + $this->labelStatusShort[self::STATUS_DISABLED] = $langs->trans('Disabled'); $this->labelStatusShort[self::STATUS_ENABLED] = $langs->trans('Enabled'); } diff --git a/htdocs/includes/restler/framework/Luracast/Restler/AutoLoader.php b/htdocs/includes/restler/framework/Luracast/Restler/AutoLoader.php index eff8bb61f29..d8445fdc70c 100644 --- a/htdocs/includes/restler/framework/Luracast/Restler/AutoLoader.php +++ b/htdocs/includes/restler/framework/Luracast/Restler/AutoLoader.php @@ -263,13 +263,7 @@ class AutoLoader * @return bool false unless className now exists */ private function loadLastResort($className, $loader = null) { - // @CHANGE LDR Add protection to avoid conflict with other autoloader - /*print 'Try to load '.$className."\n"; - if (in_array($className, array('Google_Client'))) - { - return false; - }*/ - $loaders = array_unique(static::$rogueLoaders); + $loaders = array_unique(static::$rogueLoaders); if (isset($loader)) { if (false === array_search($loader, $loaders)) static::$rogueLoaders[] = $loader; diff --git a/htdocs/includes/restler/framework/Luracast/Restler/CommentParser.php b/htdocs/includes/restler/framework/Luracast/Restler/CommentParser.php index e8248a385fa..2815f1f6c70 100644 --- a/htdocs/includes/restler/framework/Luracast/Restler/CommentParser.php +++ b/htdocs/includes/restler/framework/Luracast/Restler/CommentParser.php @@ -159,7 +159,7 @@ class CommentParser $addNewline = true; } continue; - } elseif ($line{0} == '@') { + } elseif ($line[0] == '@') { $mode = 2; $newParam = true; } @@ -353,7 +353,7 @@ class CommentParser $data = $format->decode($str); } } else { // auto detect - if ($str{0} == '{') { + if ($str[0] == '{') { $d = json_decode($str, true); if (json_last_error() != JSON_ERROR_NONE) { throw new Exception('Error parsing embedded JSON data' @@ -445,7 +445,7 @@ class CommentParser { $r = array(); $email = end($value); - if ($email{0} == '<') { + if ($email[0] == '<') { $email = substr($email, 1, -1); array_pop($value); $r['email'] = $email; @@ -470,7 +470,7 @@ class CommentParser $data = array_shift($value); if (empty($data)) { $r['type'] = 'mixed'; - } elseif ($data{0} == '$') { + } elseif ($data[0] == '$') { $r['name'] = substr($data, 1); $r['type'] = 'mixed'; } else { @@ -478,7 +478,7 @@ class CommentParser $r['type'] = count($data) == 1 ? $data[0] : $data; $data = array_shift($value); - if (!empty($data) && $data{0} == '$') { + if (!empty($data) && $data[0] == '$') { $r['name'] = substr($data, 1); } } @@ -498,7 +498,7 @@ class CommentParser $data = array_shift($value); if (empty($data)) { $r['type'] = 'mixed'; - } elseif ($data{0} == '$') { + } elseif ($data[0] == '$') { $r['name'] = substr($data, 1); $r['type'] = 'mixed'; } else { diff --git a/htdocs/includes/restler/framework/Luracast/Restler/Format/XmlFormat.php b/htdocs/includes/restler/framework/Luracast/Restler/Format/XmlFormat.php index b51fa707a53..ceec32e4cb5 100644 --- a/htdocs/includes/restler/framework/Luracast/Restler/Format/XmlFormat.php +++ b/htdocs/includes/restler/framework/Luracast/Restler/Format/XmlFormat.php @@ -221,7 +221,7 @@ class XmlFormat extends Format $namespaces = $xml->getNamespaces(); if (count($namespaces)) { $p = strpos($data, $xml->getName()); - if ($p && $data{$p - 1} == ':') { + if ($p && $data[$p - 1] == ':') { $s = strpos($data, '<') + 1; $prefix = substr($data, $s, $p - $s - 1); static::$namespacedProperties[static::$rootName] = $prefix; diff --git a/htdocs/includes/restler/framework/Luracast/Restler/Resources.php b/htdocs/includes/restler/framework/Luracast/Restler/Resources.php index 43e95fa02be..2986968a990 100644 --- a/htdocs/includes/restler/framework/Luracast/Restler/Resources.php +++ b/htdocs/includes/restler/framework/Luracast/Restler/Resources.php @@ -198,7 +198,7 @@ class Resources implements iUseAuthentication, iProvideMultiVersionApi } elseif (false !== ($pos = strpos($id, '-v'))) { //$version = intval(substr($id, $pos + 2)); $id = substr($id, 0, $pos); - } elseif ($id{0} == 'v' && is_numeric($v = substr($id, 1))) { + } elseif ($id[0] == 'v' && is_numeric($v = substr($id, 1))) { $id = ''; //$version = $v; } elseif ($id == 'root' || $id == 'index') { @@ -233,7 +233,7 @@ class Resources implements iUseAuthentication, iProvideMultiVersionApi if ($tSlash) { if ($fLen != $tLen && !Text::beginsWith($fullPath, $target . '/')) continue; - } elseif ($fLen > $tLen + 1 && $fullPath{$tLen + 1} != '{' && !Text::beginsWith($fullPath, '{')) { + } elseif ($fLen > $tLen + 1 && $fullPath[$tLen + 1] != '{' && !Text::beginsWith($fullPath, '{')) { //when mapped to root exclude paths that have static parts //they are listed else where under that static part name continue; @@ -275,7 +275,7 @@ class Resources implements iUseAuthentication, iProvideMultiVersionApi if (count($parts) == 1 && $httpMethod == 'GET') { } else { for ($i = 0; $i < count($parts); $i++) { - if (strlen($parts[$i]) && $parts[$i]{0} == '{') { + if (strlen($parts[$i]) && $parts[$i][0] == '{') { $pos = $i - 1; break; } diff --git a/htdocs/includes/restler/framework/Luracast/Restler/Restler.php b/htdocs/includes/restler/framework/Luracast/Restler/Restler.php index c2e9b1acb73..fcb5388726c 100644 --- a/htdocs/includes/restler/framework/Luracast/Restler/Restler.php +++ b/htdocs/includes/restler/framework/Luracast/Restler/Restler.php @@ -533,7 +533,7 @@ class Restler extends EventDispatcher rtrim($path, '/') //remove trailing slash if found ); - if (Defaults::$useUrlBasedVersioning && strlen($path) && $path{0} == 'v') { + if (Defaults::$useUrlBasedVersioning && strlen($path) && $path[0] == 'v') { $version = intval(substr($path, 1)); if ($version && $version <= $this->apiVersion) { $this->requestedApiVersion = $version; @@ -1599,7 +1599,7 @@ class Restler extends EventDispatcher */ public function __get($name) { - if ($name{0} == '_') { + if ($name[0] == '_') { $hiddenProperty = substr($name, 1); if (isset($this->$hiddenProperty)) { return $this->$hiddenProperty; diff --git a/htdocs/includes/restler/framework/Luracast/Restler/Routes.php b/htdocs/includes/restler/framework/Luracast/Restler/Routes.php index 73e78dc0039..999094dec4c 100644 --- a/htdocs/includes/restler/framework/Luracast/Restler/Routes.php +++ b/htdocs/includes/restler/framework/Luracast/Restler/Routes.php @@ -87,7 +87,7 @@ class Routes foreach ($methods as $method) { $methodUrl = strtolower($method->getName()); //method name should not begin with _ - if ($methodUrl{0} == '_') { + if ($methodUrl[0] == '_') { continue; } $doc = $method->getDocComment(); @@ -330,7 +330,7 @@ class Routes if (!$type) { return 's'; } - switch ($type{0}) { + switch ($type[0]) { case 'i': case 'f': return 'n'; @@ -428,7 +428,7 @@ class Routes } $index = intval(substr($k, 1)); $details = $value[$httpMethod]['metadata']['param'][$index]; - if ($k{0} == 's' || strpos($k, static::pathVarTypeOf($v)) === 0) { + if ($k[0] == 's' || strpos($k, static::pathVarTypeOf($v)) === 0) { //remove the newlines $data[$details['name']] = trim($v, PHP_EOL); } else { diff --git a/htdocs/includes/restler/framework/Luracast/Restler/Scope.php b/htdocs/includes/restler/framework/Luracast/Restler/Scope.php index 251262017c3..16ccdd33561 100644 --- a/htdocs/includes/restler/framework/Luracast/Restler/Scope.php +++ b/htdocs/includes/restler/framework/Luracast/Restler/Scope.php @@ -203,7 +203,7 @@ class Scope $divider = '\\'; $qualified = false; - if ($className{0} == $divider) { + if ($className[0] == $divider) { $qualified = trim($className, $divider); } elseif (array_key_exists($className, $scope)) { $qualified = $scope[$className]; diff --git a/htdocs/includes/restler/framework/Luracast/Restler/UI/Emmet.php b/htdocs/includes/restler/framework/Luracast/Restler/UI/Emmet.php index abd4a3a73ba..435804b4469 100644 --- a/htdocs/includes/restler/framework/Luracast/Restler/UI/Emmet.php +++ b/htdocs/includes/restler/framework/Luracast/Restler/UI/Emmet.php @@ -356,7 +356,7 @@ class Emmet $pos = strpos($string, $f, $start); $tokens = array(); for ($i = $start; $i < $pos; $i++) { - $token = $string{$i}; + $token = $string[$i]; if (('#' == $token || '.' == $token) && (!empty($tokens) || $i == 0) ) { @@ -368,7 +368,7 @@ class Emmet $r[] = $f; } while (false != ($f = strtok(static::DELIMITERS))); for ($i = $pos; $i < strlen($string); $i++) { - $token = $string{$i}; + $token = $string[$i]; $r[] = $tokens[] = $token; } return $r; diff --git a/htdocs/projet/element.php b/htdocs/projet/element.php index 46cf12356c5..ffd083d2359 100644 --- a/htdocs/projet/element.php +++ b/htdocs/projet/element.php @@ -606,7 +606,7 @@ foreach ($listofreferent as $key => $value) $elementarray = $object->get_element_list($key, $tablename, $datefieldname, $dates, $datee, !empty($project_field)?$project_field:'fk_projet'); - if (count($elementarray)>0 && is_array($elementarray)) + if (is_array($elementarray) && count($elementarray) > 0) { $total_ht = 0; $total_ttc = 0; diff --git a/htdocs/theme/eldy/global.inc.php b/htdocs/theme/eldy/global.inc.php index fa4f751d6a6..2eebcb19a6b 100644 --- a/htdocs/theme/eldy/global.inc.php +++ b/htdocs/theme/eldy/global.inc.php @@ -1297,7 +1297,7 @@ div.fichetwothirdright { browser->layout == 'phone') { print "padding-bottom: 6px\n"; } ?> } div.fichetwothirdright div.ficheaddleft { - padding-left: 20px; + padding-: 20px; } div.fichehalfleft { browser->layout != 'phone') { print "float: ".$left.";\n"; } ?> From 7788157b199a9c61397bb8fa582a14aa1040c2b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric?= <35066297+c3do@users.noreply.github.com> Date: Tue, 1 Dec 2020 16:55:43 +0100 Subject: [PATCH 002/147] API orders: Update demand reason on order update --- htdocs/commande/class/api_orders.class.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/htdocs/commande/class/api_orders.class.php b/htdocs/commande/class/api_orders.class.php index 71a26eea698..2f4eb6ea996 100644 --- a/htdocs/commande/class/api_orders.class.php +++ b/htdocs/commande/class/api_orders.class.php @@ -623,6 +623,12 @@ class Orders extends DolibarrApi throw new RestException(400, 'Error while updating availability'); } + // Update demand reason + if (!empty($this->commande->demand_reason_id) && $this->commande->demand_reason_id > 0) { + if ($this->commande->demand_reason($this->commande->demand_reason_id) < 0) + throw new RestException(400, 'Error while updating demand reason'); + } + if ($this->commande->update(DolibarrApiAccess::$user) > 0) { return $this->get($id); From c7a31b245815a1277853669ac7c2e788303ba73b Mon Sep 17 00:00:00 2001 From: lmarcouiller Date: Wed, 2 Dec 2020 14:42:56 +0100 Subject: [PATCH 003/147] new widget funnel of prospection --- .../core/boxes/box_funnel_of_prospection.php | 268 ++++++++++++++++++ htdocs/core/modules/modProjet.class.php | 2 + 2 files changed, 270 insertions(+) create mode 100644 htdocs/core/boxes/box_funnel_of_prospection.php diff --git a/htdocs/core/boxes/box_funnel_of_prospection.php b/htdocs/core/boxes/box_funnel_of_prospection.php new file mode 100644 index 00000000000..6e63a80353c --- /dev/null +++ b/htdocs/core/boxes/box_funnel_of_prospection.php @@ -0,0 +1,268 @@ + + * Copyright (C) 2014 Marcos García + * Copyright (C) 2015 Frederic France + * Copyright (C) 2016 Juan José Menent + * Copyright (C) 2020 Pierre Ardoin + * + * 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/core/boxes/box_funnel_of_prospection.php + * \ingroup projet + * \brief Module to show the funnel of prospection + */ +include_once DOL_DOCUMENT_ROOT . "/core/boxes/modules_boxes.php"; + +/** + * Class to manage the box to show last projet + */ +class box_funnel_of_prospection extends ModeleBoxes +{ + public $boxcode = "FunnelOfProspection"; + public $boximg = "object_projectpub"; + public $boxlabel = "BoxFunnelOfProspection"; + public $depends = array("projet"); + + /** + * @var DoliDB Database handler. + */ + public $db; + + public $param; + + public $info_box_head = array(); + public $info_box_contents = array(); + + /** + * Constructor + * + * @param DoliDB $db Database handler + * @param string $param More parameters + */ + public function __construct($db, $param = '') + { + global $user, $langs, $conf; + + // Load translation files required by the page + $langs->loadLangs(array('boxes', 'projects')); + + $this->db = $db; + + $this->hidden = !($user->rights->projet->lire); + } + + /** + * Load data for box to show them later + * + * @param int $max Maximum number of records to load + * @return void + */ + public function loadBox($max = 5) + { + global $conf; + include DOL_DOCUMENT_ROOT . '/theme/' . $conf->theme . '/theme_vars.inc.php'; + $listofoppstatus = array(); + $listofopplabel = array(); + $listofoppcode = array(); + $colorseriesstat = array(); + $sql = "SELECT cls.rowid, cls.code, cls.percent, cls.label"; + $sql .= " FROM " . MAIN_DB_PREFIX . "c_lead_status as cls"; + $sql .= " WHERE active=1"; + $resql = $this->db->query($sql); + if ($resql) { + $num = $this->db->num_rows($resql); + $i = 0; + + while ($i < $num) { + $objp = $this->db->fetch_object($resql); + $listofoppstatus[$objp->rowid] = $objp->percent; + $listofopplabel[$objp->rowid] = $objp->label; + $listofoppcode[$objp->rowid] = $objp->code; + switch ($objp->code) { + case 'PROSP': + $colorseriesstat[$objp->rowid] = "-" . $badgeStatus0; + break; + case 'QUAL': + $colorseriesstat[$objp->rowid] = "-" . $badgeStatus1; + break; + case 'PROPO': + $colorseriesstat[$objp->rowid] = $badgeStatus1; + break; + case 'NEGO': + $colorseriesstat[$objp->rowid] = $badgeStatus4; + break; + case 'LOST': + $colorseriesstat[$objp->rowid] = $badgeStatus9; + break; + case 'WON': + $colorseriesstat[$objp->rowid] = $badgeStatus6; + break; + default: + $colorseriesstat[$objp->rowid] = $badgeStatus2; + break; + } + $i++; + } + } else dol_print_error($this->db); + + global $conf, $user, $langs; + + $this->max = $max; + + $this->info_box_head = array( + 'text' => $langs->trans("Statistics") . ' - ' . $langs->trans("OpportunitiesStatusForOpenedProjects"), + $max + ); + + if ($user->rights->projet->lire || !empty($conf->global->PROJECT_USE_OPPORTUNITIES)) { + $sql = "SELECT p.fk_opp_status as opp_status, cls.code, COUNT(p.rowid) as nb, SUM(p.opp_amount) as opp_amount, SUM(p.opp_amount * p.opp_percent) as ponderated_opp_amount"; + $sql .= " FROM " . MAIN_DB_PREFIX . "projet as p, " . MAIN_DB_PREFIX . "c_lead_status as cls"; + $sql .= " WHERE p.entity IN (" . getEntity('project') . ")"; + $sql .= " AND p.fk_opp_status = cls.rowid"; + $sql .= " AND p.fk_statut = 1"; // Opend projects only + $sql .= " GROUP BY p.fk_opp_status, cls.code"; + $resql = $this->db->query($sql); + + $form = new Form($ths->db); + if ($resql) { + $num = $this->db->num_rows($resql); + $i = 0; + + $totalnb = 0; + $totaloppnb = 0; + $totalamount = 0; + $ponderated_opp_amount = 0; + $valsnb = array(); + $valsamount = array(); + $dataseries = array(); + + while ($i < $num) { + $obj = $this->db->fetch_object($resql); + if ($obj) { + $valsnb[$obj->opp_status] = $obj->nb; + $valsamount[$obj->opp_status] = $obj->opp_amount; + $totalnb += $obj->nb; + if ($obj->opp_status) $totaloppnb += $obj->nb; + if (!in_array($obj->code, array('WON', 'LOST'))) { + $totalamount += $obj->opp_amount; + $ponderated_opp_amount += $obj->ponderated_opp_amount; + } + } + $i++; + } + $this->db->free($resql); + $ponderated_opp_amount = $ponderated_opp_amount / 100; + + $stringtoprint = ''; + $stringtoprint .= '
'; + $listofstatus = array_keys($listofoppstatus); + foreach ($listofstatus as $status) { + $labelStatus = ''; + + $code = dol_getIdFromCode($this->db, $status, 'c_lead_status', 'rowid', 'code'); + if ($code) $labelStatus = $langs->transnoentitiesnoconv("OppStatus" . $code); + if (empty($labelStatus)) $labelStatus = $listofopplabel[$status]; + + $dataseries[] = array($labelStatus, (isset($valsamount[$status]) ? (float) $valsamount[$status] : 0)); + if (!$conf->use_javascript_ajax) { + $stringtoprint .= ''; + $stringtoprint .= '' . $labelStatus . ''; + $stringtoprint .= '' . price((isset($valsamount[$status]) ? (float) $valsamount[$status] : 0), 0, '', 1, -1, -1, $conf->currency) . ''; + $stringtoprint .= "\n"; + } + } + if ($conf->use_javascript_ajax) { + include_once DOL_DOCUMENT_ROOT . '/core/class/dolgraph.class.php'; + $dolgraph = new DolGraph(); + $dolgraph->SetData($dataseries); + $dolgraph->SetDataColor(array_values($colorseriesstat)); + $dolgraph->setShowLegend(2); + $dolgraph->setShowPercent(1); + $dolgraph->SetType(array('pie')); + $dolgraph->SetHeight('200'); + $dolgraph->draw('idgraphstatus'); + $stringtoprint .= $dolgraph->show($totaloppnb ? 0 : 1); + } + $stringtoprint .= '
'; + + $line = 0; + $this->info_box_contents[$line][] = array( + 'tr' => 'class="nohover left "', + 'text' => '' + ); + $this->info_box_contents[$line][] = array( + 'tr' => 'class="nohover left "', + 'text' => '' + ); + $line++; + $this->info_box_contents[$line][] = array( + 'tr' => '', + 'td' => 'class="center nopaddingleftimp nopaddingrightimp" colspan="2"', + 'text' => $stringtoprint + ); + $line++; + $this->info_box_contents[$line][] = array( + 'tr' => 'class="oddeven"', + 'td' => 'class="left "', + 'maxlength' => 500, + 'text' => $langs->trans("OpportunityTotalAmount") . ' (' . $langs->trans("WonLostExcluded") . ')' + ); + $this->info_box_contents[$line][] = array( + 'tr' => 'class="oddeven"', + 'td' => 'class="right "', + 'maxlength' => 500, + 'text' => price($totalamount, 0, '', 1, -1, -1, $conf->currency) + ); + $line++; + $this->info_box_contents[$line][] = array( + 'tr' => 'class="oddeven"', + 'td' => 'class="left "', + 'maxlength' => 500, + 'text' => $form->textwithpicto($langs->trans("OpportunityPonderatedAmount").' ('.$langs->trans("WonLostExcluded").')', $langs->trans("OpportunityPonderatedAmountDesc"), 1) + + ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right "', + 'maxlength' => 500, + 'text' => price(price2num($ponderated_opp_amount, 'MT'), 0, '', 1, -1, -1, $conf->currency) + ); + } else { + $this->info_box_contents[0][0] = array( + 'td' => 'class="center opacitymedium"', + 'text' => $langs->trans("NoRecordedCustomers") + ); + } + } else { + $this->info_box_contents[0][0] = array( + 'td' => '', + 'text' => $langs->trans("ReadPermissionNotAllowed") + ); + } + } + + /** + * Method to show box + * + * @param array $head Array with properties of box title + * @param array $contents Array with properties of box lines + * @param int $nooutput No $stringtoprint .=, only return string + * @return string + */ + public function showBox($head = null, $contents = null, $nooutput = 0) + { + return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); + } +} diff --git a/htdocs/core/modules/modProjet.class.php b/htdocs/core/modules/modProjet.class.php index af6398c7a6d..fcd3e2e1e22 100644 --- a/htdocs/core/modules/modProjet.class.php +++ b/htdocs/core/modules/modProjet.class.php @@ -146,6 +146,8 @@ class modProjet extends DolibarrModules $r++; $this->boxes[$r][1] = "box_validated_projects.php"; $r++; + $this->boxes[$r][1] = "box_funnel_of_prospection.php"; + $r++; // Permissions $this->rights = array(); From 032116b23511601561fce10f67f797dc543b576b Mon Sep 17 00:00:00 2001 From: lmarcouiller Date: Thu, 3 Dec 2020 10:11:16 +0100 Subject: [PATCH 004/147] changes to not diplay won and lost and add on migration --- .../core/boxes/box_funnel_of_prospection.php | 38 ++++++++----------- .../install/mysql/migration/12.0.0-13.0.0.sql | 3 +- htdocs/langs/en_US/boxes.lang | 1 + 3 files changed, 19 insertions(+), 23 deletions(-) diff --git a/htdocs/core/boxes/box_funnel_of_prospection.php b/htdocs/core/boxes/box_funnel_of_prospection.php index 6e63a80353c..7062509a13b 100644 --- a/htdocs/core/boxes/box_funnel_of_prospection.php +++ b/htdocs/core/boxes/box_funnel_of_prospection.php @@ -33,7 +33,7 @@ class box_funnel_of_prospection extends ModeleBoxes { public $boxcode = "FunnelOfProspection"; public $boximg = "object_projectpub"; - public $boxlabel = "BoxFunnelOfProspection"; + public $boxlabel = "BoxTitleFunnelOfProspection"; public $depends = array("projet"); /** @@ -104,12 +104,6 @@ class box_funnel_of_prospection extends ModeleBoxes case 'NEGO': $colorseriesstat[$objp->rowid] = $badgeStatus4; break; - case 'LOST': - $colorseriesstat[$objp->rowid] = $badgeStatus9; - break; - case 'WON': - $colorseriesstat[$objp->rowid] = $badgeStatus6; - break; default: $colorseriesstat[$objp->rowid] = $badgeStatus2; break; @@ -133,6 +127,7 @@ class box_funnel_of_prospection extends ModeleBoxes $sql .= " WHERE p.entity IN (" . getEntity('project') . ")"; $sql .= " AND p.fk_opp_status = cls.rowid"; $sql .= " AND p.fk_statut = 1"; // Opend projects only + $sql .= " AND cls.code NOT IN ('WON', 'LOST')"; $sql .= " GROUP BY p.fk_opp_status, cls.code"; $resql = $this->db->query($sql); @@ -156,10 +151,8 @@ class box_funnel_of_prospection extends ModeleBoxes $valsamount[$obj->opp_status] = $obj->opp_amount; $totalnb += $obj->nb; if ($obj->opp_status) $totaloppnb += $obj->nb; - if (!in_array($obj->code, array('WON', 'LOST'))) { - $totalamount += $obj->opp_amount; - $ponderated_opp_amount += $obj->ponderated_opp_amount; - } + $totalamount += $obj->opp_amount; + $ponderated_opp_amount += $obj->ponderated_opp_amount; } $i++; } @@ -171,17 +164,18 @@ class box_funnel_of_prospection extends ModeleBoxes $listofstatus = array_keys($listofoppstatus); foreach ($listofstatus as $status) { $labelStatus = ''; + if ($status != 7 && $status != 6) { + $code = dol_getIdFromCode($this->db, $status, 'c_lead_status', 'rowid', 'code'); + if ($code) $labelStatus = $langs->transnoentitiesnoconv("OppStatus" . $code); + if (empty($labelStatus)) $labelStatus = $listofopplabel[$status]; - $code = dol_getIdFromCode($this->db, $status, 'c_lead_status', 'rowid', 'code'); - if ($code) $labelStatus = $langs->transnoentitiesnoconv("OppStatus" . $code); - if (empty($labelStatus)) $labelStatus = $listofopplabel[$status]; - - $dataseries[] = array($labelStatus, (isset($valsamount[$status]) ? (float) $valsamount[$status] : 0)); - if (!$conf->use_javascript_ajax) { - $stringtoprint .= ''; - $stringtoprint .= '' . $labelStatus . ''; - $stringtoprint .= '' . price((isset($valsamount[$status]) ? (float) $valsamount[$status] : 0), 0, '', 1, -1, -1, $conf->currency) . ''; - $stringtoprint .= "\n"; + $dataseries[] = array($labelStatus, (isset($valsamount[$status]) ? (float) $valsamount[$status] : 0)); + if (!$conf->use_javascript_ajax) { + $stringtoprint .= ''; + $stringtoprint .= '' . $labelStatus . ''; + $stringtoprint .= '' . price((isset($valsamount[$status]) ? (float) $valsamount[$status] : 0), 0, '', 1, -1, -1, $conf->currency) . ''; + $stringtoprint .= "\n"; + } } } if ($conf->use_javascript_ajax) { @@ -231,7 +225,7 @@ class box_funnel_of_prospection extends ModeleBoxes 'tr' => 'class="oddeven"', 'td' => 'class="left "', 'maxlength' => 500, - 'text' => $form->textwithpicto($langs->trans("OpportunityPonderatedAmount").' ('.$langs->trans("WonLostExcluded").')', $langs->trans("OpportunityPonderatedAmountDesc"), 1) + 'text' => $form->textwithpicto($langs->trans("OpportunityPonderatedAmount") . ' (' . $langs->trans("WonLostExcluded") . ')', $langs->trans("OpportunityPonderatedAmountDesc"), 1) ); $this->info_box_contents[$line][] = array( diff --git a/htdocs/install/mysql/migration/12.0.0-13.0.0.sql b/htdocs/install/mysql/migration/12.0.0-13.0.0.sql index 18802301e5a..7b5fc0aab22 100644 --- a/htdocs/install/mysql/migration/12.0.0-13.0.0.sql +++ b/htdocs/install/mysql/migration/12.0.0-13.0.0.sql @@ -439,7 +439,6 @@ INSERT INTO llx_c_product_nature (code, label, active) VALUES (1, 'Finished', 1) ALTER TABLE llx_product MODIFY COLUMN finished tinyint DEFAULT NULL; ALTER TABLE llx_product ADD CONSTRAINT fk_product_finished FOREIGN KEY (finished) REFERENCES llx_c_product_nature (code); - -- MIGRATION TO DO AFTER RENAMING AN OBJECT -- drop constraint @@ -542,3 +541,5 @@ CREATE TABLE llx_session( user_agent varchar(128) NULL )ENGINE=innodb; +INSERT INTO llx_boxes_def(file,entity) VALUES ('box_funnel_of_prospection.php',1); +INSERT INTO llx_boxes (box_id, position, box_order, maxline, params) VALUES ((SELECT b.rowid FROM llx_boxes_def as b WHERE file = 'box_funnel_of_prospection.php'), 0, 0, NULL, NULL); diff --git a/htdocs/langs/en_US/boxes.lang b/htdocs/langs/en_US/boxes.lang index 75f8eb14f49..40fdc11ba32 100644 --- a/htdocs/langs/en_US/boxes.lang +++ b/htdocs/langs/en_US/boxes.lang @@ -50,6 +50,7 @@ BoxTitleLastOutstandingBillReached=Latest %s customers with maximum outstanding BoxGlobalActivity=Global activity (invoices, proposals, orders) BoxGoodCustomers=Good customers BoxTitleGoodCustomers=%s Good customers +BoxTitleFunnelOfProspection=Amount of prospection by status FailedToRefreshDataInfoNotUpToDate=Failed to refresh RSS flux. Latest successful refresh date: %s LastRefreshDate=Latest refresh date NoRecordedBookmarks=No bookmarks defined. From e08f6aeb2be50bd115cee54cf0e17687613aa556 Mon Sep 17 00:00:00 2001 From: lmarcouiller Date: Thu, 3 Dec 2020 11:00:29 +0100 Subject: [PATCH 005/147] Fix #15383 --- htdocs/core/boxes/box_funnel_of_prospection.php | 13 +++++++++---- htdocs/install/mysql/migration/12.0.0-13.0.0.sql | 1 - 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/htdocs/core/boxes/box_funnel_of_prospection.php b/htdocs/core/boxes/box_funnel_of_prospection.php index 7062509a13b..fa65e696fa6 100644 --- a/htdocs/core/boxes/box_funnel_of_prospection.php +++ b/htdocs/core/boxes/box_funnel_of_prospection.php @@ -104,6 +104,9 @@ class box_funnel_of_prospection extends ModeleBoxes case 'NEGO': $colorseriesstat[$objp->rowid] = $badgeStatus4; break; + case 'WON': + $colorseriesstat[$objp->rowid] = $badgeStatus6; + break; default: $colorseriesstat[$objp->rowid] = $badgeStatus2; break; @@ -127,7 +130,7 @@ class box_funnel_of_prospection extends ModeleBoxes $sql .= " WHERE p.entity IN (" . getEntity('project') . ")"; $sql .= " AND p.fk_opp_status = cls.rowid"; $sql .= " AND p.fk_statut = 1"; // Opend projects only - $sql .= " AND cls.code NOT IN ('WON', 'LOST')"; + $sql .= " AND cls.code NOT IN ('LOST')"; $sql .= " GROUP BY p.fk_opp_status, cls.code"; $resql = $this->db->query($sql); @@ -151,8 +154,10 @@ class box_funnel_of_prospection extends ModeleBoxes $valsamount[$obj->opp_status] = $obj->opp_amount; $totalnb += $obj->nb; if ($obj->opp_status) $totaloppnb += $obj->nb; - $totalamount += $obj->opp_amount; - $ponderated_opp_amount += $obj->ponderated_opp_amount; + if (!in_array($obj->code, array('WON', 'LOST'))) { + $totalamount += $obj->opp_amount; + $ponderated_opp_amount += $obj->ponderated_opp_amount; + } } $i++; } @@ -164,7 +169,7 @@ class box_funnel_of_prospection extends ModeleBoxes $listofstatus = array_keys($listofoppstatus); foreach ($listofstatus as $status) { $labelStatus = ''; - if ($status != 7 && $status != 6) { + if ($status != 7) { $code = dol_getIdFromCode($this->db, $status, 'c_lead_status', 'rowid', 'code'); if ($code) $labelStatus = $langs->transnoentitiesnoconv("OppStatus" . $code); if (empty($labelStatus)) $labelStatus = $listofopplabel[$status]; diff --git a/htdocs/install/mysql/migration/12.0.0-13.0.0.sql b/htdocs/install/mysql/migration/12.0.0-13.0.0.sql index fc8ac7ce102..5865a3e7919 100644 --- a/htdocs/install/mysql/migration/12.0.0-13.0.0.sql +++ b/htdocs/install/mysql/migration/12.0.0-13.0.0.sql @@ -544,7 +544,6 @@ CREATE TABLE llx_session( INSERT INTO llx_boxes_def(file,entity) VALUES ('box_funnel_of_prospection.php',1); -INSERT INTO llx_boxes (box_id, position, box_order, maxline, params) VALUES ((SELECT b.rowid FROM llx_boxes_def as b WHERE file = 'box_funnel_of_prospection.php'), 0, 0, NULL, NULL); INSERT INTO llx_boxes_def(file, entity) VALUES ('box_customers_outstanding_bill_reached.php', 1); From 28ac9764389ca5e6b68192181dc3367b534d91dd Mon Sep 17 00:00:00 2001 From: lmarcouiller Date: Thu, 3 Dec 2020 11:14:58 +0100 Subject: [PATCH 006/147] Show won on graph --- htdocs/core/boxes/box_funnel_of_prospection.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/core/boxes/box_funnel_of_prospection.php b/htdocs/core/boxes/box_funnel_of_prospection.php index fa65e696fa6..c4cebfcf68a 100644 --- a/htdocs/core/boxes/box_funnel_of_prospection.php +++ b/htdocs/core/boxes/box_funnel_of_prospection.php @@ -174,7 +174,7 @@ class box_funnel_of_prospection extends ModeleBoxes if ($code) $labelStatus = $langs->transnoentitiesnoconv("OppStatus" . $code); if (empty($labelStatus)) $labelStatus = $listofopplabel[$status]; - $dataseries[] = array($labelStatus, (isset($valsamount[$status]) ? (float) $valsamount[$status] : 0)); + $dataseries[] = array($labelStatus,(isset($valsamount[$status]) ? (float) $valsamount[$status] : 0)); if (!$conf->use_javascript_ajax) { $stringtoprint .= ''; $stringtoprint .= '' . $labelStatus . ''; @@ -188,6 +188,7 @@ class box_funnel_of_prospection extends ModeleBoxes $dolgraph = new DolGraph(); $dolgraph->SetData($dataseries); $dolgraph->SetDataColor(array_values($colorseriesstat)); + //$dolgraph->SetLegend(array('PROSP',$dataseries['PROSP'])); $dolgraph->setShowLegend(2); $dolgraph->setShowPercent(1); $dolgraph->SetType(array('pie')); From dcc3ecf0129a771d4f20b280384ee33140d85dd2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric?= <35066297+c3do@users.noreply.github.com> Date: Thu, 3 Dec 2020 16:01:17 +0100 Subject: [PATCH 007/147] Update commande.class.php --- htdocs/commande/class/commande.class.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 506cf84c8fd..0b68095c5d0 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -3273,6 +3273,7 @@ class Commande extends CommonOrder $sql .= " fk_cond_reglement=".(isset($this->cond_reglement_id) ? $this->cond_reglement_id : "null").","; $sql .= " fk_mode_reglement=".(isset($this->mode_reglement_id) ? $this->mode_reglement_id : "null").","; $sql .= " fk_account=".($this->fk_account > 0 ? $this->fk_account : "null").","; + $sql .= " fk_input_reason=".($this->demand_reason_id > 0 ? $this->demand_reason_id : "null").","; $sql .= " note_private=".(isset($this->note_private) ? "'".$this->db->escape($this->note_private)."'" : "null").","; $sql .= " note_public=".(isset($this->note_public) ? "'".$this->db->escape($this->note_public)."'" : "null").","; $sql .= " model_pdf=".(isset($this->modelpdf) ? "'".$this->db->escape($this->modelpdf)."'" : "null").","; From 2751d5cefdcc63703a549d04fe6c6161115b6971 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric?= <35066297+c3do@users.noreply.github.com> Date: Thu, 3 Dec 2020 16:02:49 +0100 Subject: [PATCH 008/147] Update api_orders.class.php --- htdocs/commande/class/api_orders.class.php | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/htdocs/commande/class/api_orders.class.php b/htdocs/commande/class/api_orders.class.php index 2f4eb6ea996..3442b9316f7 100644 --- a/htdocs/commande/class/api_orders.class.php +++ b/htdocs/commande/class/api_orders.class.php @@ -622,13 +622,7 @@ class Orders extends DolibarrApi if ($this->commande->availability($this->commande->availability_id) < 0) throw new RestException(400, 'Error while updating availability'); } - - // Update demand reason - if (!empty($this->commande->demand_reason_id) && $this->commande->demand_reason_id > 0) { - if ($this->commande->demand_reason($this->commande->demand_reason_id) < 0) - throw new RestException(400, 'Error while updating demand reason'); - } - + if ($this->commande->update(DolibarrApiAccess::$user) > 0) { return $this->get($id); From 9875e73ee2169d0ed9dca59f91cb25e203438b49 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Thu, 3 Dec 2020 15:04:48 +0000 Subject: [PATCH 009/147] Fixing style errors. --- htdocs/commande/class/api_orders.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/commande/class/api_orders.class.php b/htdocs/commande/class/api_orders.class.php index 3442b9316f7..71a26eea698 100644 --- a/htdocs/commande/class/api_orders.class.php +++ b/htdocs/commande/class/api_orders.class.php @@ -622,7 +622,7 @@ class Orders extends DolibarrApi if ($this->commande->availability($this->commande->availability_id) < 0) throw new RestException(400, 'Error while updating availability'); } - + if ($this->commande->update(DolibarrApiAccess::$user) > 0) { return $this->get($id); From a1428c963b642d09d00d7b6df2483b9ae03709c6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 3 Dec 2020 16:53:26 +0100 Subject: [PATCH 010/147] Fix phpcs --- htdocs/commande/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index d9817dc38c3..f59038aceae 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -954,7 +954,7 @@ if (empty($reshook)) if ($result > 0) { $ret = $object->fetch($object->id); // Reload to get new records $object->fetch_thirdparty(); - + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { // Define output language $outputlangs = $langs; From 8a7f7b355134e8572b93e48b0a97dc20e0d55b82 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 3 Dec 2020 18:38:18 +0100 Subject: [PATCH 011/147] FIX Request on purchase orders in timeout even on very small databases --- htdocs/install/mysql/migration/11.0.0-12.0.0.sql | 3 +++ .../install/mysql/tables/llx_commande_fournisseurdet.key.sql | 3 +++ 2 files changed, 6 insertions(+) diff --git a/htdocs/install/mysql/migration/11.0.0-12.0.0.sql b/htdocs/install/mysql/migration/11.0.0-12.0.0.sql index a7cb8a4729f..8d80486fcf8 100644 --- a/htdocs/install/mysql/migration/11.0.0-12.0.0.sql +++ b/htdocs/install/mysql/migration/11.0.0-12.0.0.sql @@ -338,3 +338,6 @@ ALTER TABLE llx_expedition ADD COLUMN billed smallint DEFAULT 0; -- VMYSQL4.3 ALTER TABLE llx_mrp_mo MODIFY COLUMN tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP; +ALTER TABLE llx_commande_fournisseurdet ADD INDEX idx_commande_fournisseurdet_fk_commande (fk_commande); +ALTER TABLE llx_commande_fournisseurdet ADD INDEX idx_commande_fournisseurdet_fk_product (fk_product); + diff --git a/htdocs/install/mysql/tables/llx_commande_fournisseurdet.key.sql b/htdocs/install/mysql/tables/llx_commande_fournisseurdet.key.sql index 6c2da9cf094..5d30ddf8817 100644 --- a/htdocs/install/mysql/tables/llx_commande_fournisseurdet.key.sql +++ b/htdocs/install/mysql/tables/llx_commande_fournisseurdet.key.sql @@ -17,3 +17,6 @@ -- ============================================================================ ALTER TABLE llx_commande_fournisseurdet ADD CONSTRAINT fk_commande_fournisseurdet_fk_unit FOREIGN KEY (fk_unit) REFERENCES llx_c_units (rowid); + +ALTER TABLE llx_commande_fournisseurdet ADD INDEX idx_commande_fournisseurdet_fk_commande (fk_commande); +ALTER TABLE llx_commande_fournisseurdet ADD INDEX idx_commande_fournisseurdet_fk_product (fk_product); From df48704154522ad77ebefb323ebfd88ddd471e35 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 3 Dec 2020 18:45:56 +0100 Subject: [PATCH 012/147] Fix label --- htdocs/fourn/commande/list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/fourn/commande/list.php b/htdocs/fourn/commande/list.php index 69db75ce5fc..ce638cdffcb 100644 --- a/htdocs/fourn/commande/list.php +++ b/htdocs/fourn/commande/list.php @@ -129,7 +129,7 @@ $search_array_options = $extrafields->getOptionalsFromPost($object->table_elemen // List of fields to search into when doing a "search in all" $fieldstosearchall = array( 'cf.ref'=>'Ref', - 'cf.ref_supplier'=>'RefSupplierOrder', + 'cf.ref_supplier'=>'RefOrderSupplier', 'pd.description'=>'Description', 's.nom'=>"ThirdParty", 'cf.note_public'=>'NotePublic', From ac30348081c0bde8005541a6e471fdb5dc746ac0 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 3 Dec 2020 19:16:34 +0100 Subject: [PATCH 013/147] Prepare 12.0.4 --- htdocs/filefunc.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/filefunc.inc.php b/htdocs/filefunc.inc.php index e1aced7ddf0..b57228f24e9 100644 --- a/htdocs/filefunc.inc.php +++ b/htdocs/filefunc.inc.php @@ -31,7 +31,7 @@ */ if (!defined('DOL_APPLICATION_TITLE')) define('DOL_APPLICATION_TITLE', 'Dolibarr'); -if (!defined('DOL_VERSION')) define('DOL_VERSION', '12.0.3'); // a.b.c-alpha, a.b.c-beta, a.b.c-rcX or a.b.c +if (!defined('DOL_VERSION')) define('DOL_VERSION', '12.0.4'); // a.b.c-alpha, a.b.c-beta, a.b.c-rcX or a.b.c if (!defined('EURO')) define('EURO', chr(128)); From 7a5a6a14f0d3ea5f53a6295ddb4c9a6f664d32ad Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Fri, 4 Dec 2020 09:10:36 +0100 Subject: [PATCH 014/147] fix At install insert shipment mode failed --- htdocs/install/mysql/data/llx_c_shipment_mode.sql | 12 ++++++------ htdocs/install/mysql/migration/11.0.0-12.0.0.sql | 8 ++++++++ 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/htdocs/install/mysql/data/llx_c_shipment_mode.sql b/htdocs/install/mysql/data/llx_c_shipment_mode.sql index e5026f8d2f7..0dd00f27bb4 100644 --- a/htdocs/install/mysql/data/llx_c_shipment_mode.sql +++ b/htdocs/install/mysql/data/llx_c_shipment_mode.sql @@ -37,9 +37,9 @@ INSERT INTO llx_c_shipment_mode (rowid,code,libelle,description,tracking,active) INSERT INTO llx_c_shipment_mode (rowid,code,libelle,description,tracking,active) VALUES (6,'KIALA','KIALA','Relais Kiala','http://www.kiala.fr/tnt/delivery/{TRACKID}', 0); INSERT INTO llx_c_shipment_mode (rowid,code,libelle,description,tracking,active) VALUES (7,'GLS','GLS','General Logistics Systems','https://gls-group.eu/FR/fr/suivi-colis?match={TRACKID}', 0); INSERT INTO llx_c_shipment_mode (rowid,code,libelle,description,tracking,active) VALUES (8,'CHRONO','Chronopost','Chronopost','http://www.chronopost.fr/expedier/inputLTNumbersNoJahia.do?listeNumeros={TRACKID}', 0); -INSERT INTO llx_c_shipment_mode (rowid,code,libelle,description,tracking,active) VALUES (9,'INPERSON', 'In person at your site', NULL, NULL, 0, NULL), -INSERT INTO llx_c_shipment_mode (rowid,code,libelle,description,tracking,active) VALUES (10,'FEDEX', 'Fedex', NULL, 'https://www.fedex.com/apps/fedextrack/index.html?tracknumbers={TRACKID}', 0, NULL), -INSERT INTO llx_c_shipment_mode (rowid,code,libelle,description,tracking,active) VALUES (11,'TNT', 'TNT', NULL, 'https://www.tnt.com/express/fr_fr/site/outils-expedition/suivi.html?searchType=con&cons=={TRACKID}', 0, NULL), -INSERT INTO llx_c_shipment_mode (rowid,code,libelle,description,tracking,active) VALUES (12,'DHL', 'DHL', NULL, 'https://www.dhl.com/fr-fr/home/tracking/tracking-global-forwarding.html?submit=1&tracking-id={TRACKID}', 0, NULL), -INSERT INTO llx_c_shipment_mode (rowid,code,libelle,description,tracking,active) VALUES (13,'DPD', 'DPD', NULL, 'https://www.dpd.fr/trace/{TRACKID}', 0, NULL), -INSERT INTO llx_c_shipment_mode (rowid,code,libelle,description,tracking,active) VALUES (14,'MAINFREIGHT', 'Mainfreight', NULL, 'https://www.mainfreight.com/track?{TRACKID}', 0, NULL); +INSERT INTO llx_c_shipment_mode (rowid,code,libelle,description,tracking,active) VALUES (9,'INPERSON', 'In person at your site', NULL, NULL, 0); +INSERT INTO llx_c_shipment_mode (rowid,code,libelle,description,tracking,active) VALUES (10,'FEDEX', 'Fedex', NULL, 'https://www.fedex.com/apps/fedextrack/index.html?tracknumbers={TRACKID}', 0); +INSERT INTO llx_c_shipment_mode (rowid,code,libelle,description,tracking,active) VALUES (11,'TNT', 'TNT', NULL, 'https://www.tnt.com/express/fr_fr/site/outils-expedition/suivi.html?searchType=con&cons=={TRACKID}', 0); +INSERT INTO llx_c_shipment_mode (rowid,code,libelle,description,tracking,active) VALUES (12,'DHL', 'DHL', NULL, 'https://www.dhl.com/fr-fr/home/tracking/tracking-global-forwarding.html?submit=1&tracking-id={TRACKID}', 0); +INSERT INTO llx_c_shipment_mode (rowid,code,libelle,description,tracking,active) VALUES (13,'DPD', 'DPD', NULL, 'https://www.dpd.fr/trace/{TRACKID}', 0); +INSERT INTO llx_c_shipment_mode (rowid,code,libelle,description,tracking,active) VALUES (14,'MAINFREIGHT', 'Mainfreight', NULL, 'https://www.mainfreight.com/track?{TRACKID}', 0); diff --git a/htdocs/install/mysql/migration/11.0.0-12.0.0.sql b/htdocs/install/mysql/migration/11.0.0-12.0.0.sql index 8d80486fcf8..fddfb8c8097 100644 --- a/htdocs/install/mysql/migration/11.0.0-12.0.0.sql +++ b/htdocs/install/mysql/migration/11.0.0-12.0.0.sql @@ -341,3 +341,11 @@ ALTER TABLE llx_expedition ADD COLUMN billed smallint DEFAULT 0; ALTER TABLE llx_commande_fournisseurdet ADD INDEX idx_commande_fournisseurdet_fk_commande (fk_commande); ALTER TABLE llx_commande_fournisseurdet ADD INDEX idx_commande_fournisseurdet_fk_product (fk_product); +INSERT INTO llx_c_shipment_mode (rowid,code,libelle,description,tracking,active) VALUES (9,'INPERSON', 'In person at your site', NULL, NULL, 0); +INSERT INTO llx_c_shipment_mode (rowid,code,libelle,description,tracking,active) VALUES (10,'FEDEX', 'Fedex', NULL, 'https://www.fedex.com/apps/fedextrack/index.html?tracknumbers={TRACKID}', 0); +INSERT INTO llx_c_shipment_mode (rowid,code,libelle,description,tracking,active) VALUES (11,'TNT', 'TNT', NULL, 'https://www.tnt.com/express/fr_fr/site/outils-expedition/suivi.html?searchType=con&cons=={TRACKID}', 0); +INSERT INTO llx_c_shipment_mode (rowid,code,libelle,description,tracking,active) VALUES (12,'DHL', 'DHL', NULL, 'https://www.dhl.com/fr-fr/home/tracking/tracking-global-forwarding.html?submit=1&tracking-id={TRACKID}', 0); +INSERT INTO llx_c_shipment_mode (rowid,code,libelle,description,tracking,active) VALUES (13,'DPD', 'DPD', NULL, 'https://www.dpd.fr/trace/{TRACKID}', 0); +INSERT INTO llx_c_shipment_mode (rowid,code,libelle,description,tracking,active) VALUES (14,'MAINFREIGHT', 'Mainfreight', NULL, 'https://www.mainfreight.com/track?{TRACKID}', 0); + + From d712e1e6d46fdb58eb8db0e78a2ad39e3cc68109 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Fri, 4 Dec 2020 09:42:30 +0100 Subject: [PATCH 015/147] Fix limit product in customer margins Fix limit of 20 products in product list/search --- htdocs/margin/customerMargins.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/margin/customerMargins.php b/htdocs/margin/customerMargins.php index 3cdd9c3c650..a0b5ad2be04 100644 --- a/htdocs/margin/customerMargins.php +++ b/htdocs/margin/customerMargins.php @@ -134,7 +134,7 @@ if (!$sortfield) } // Products -$TRes = $form->select_produits_list('', '', '', 20, 0, '', 1, 2, 1, 0, '', 1); +$TRes = $form->select_produits_list('', '', '', '', 0, '', 1, 2, 1, 0, '', 1); $TProducts = array(); foreach ($TRes as $prod) { From c752bfe1a6b39f409c3d4c900b338b4da922291c Mon Sep 17 00:00:00 2001 From: Florian Mortgat Date: Fri, 4 Dec 2020 10:02:39 +0100 Subject: [PATCH 016/147] FIX 12.0 - set entity to $conf->entity (instead of 1 by default) when creating a survey; otherwise the survey cannot be listed from the entity it was created on unless it is the main entity --- htdocs/opensurvey/class/opensurveysondage.class.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/htdocs/opensurvey/class/opensurveysondage.class.php b/htdocs/opensurvey/class/opensurveysondage.class.php index c971b69b208..83902f8c678 100644 --- a/htdocs/opensurvey/class/opensurveysondage.class.php +++ b/htdocs/opensurvey/class/opensurveysondage.class.php @@ -128,6 +128,7 @@ class Opensurveysondage extends CommonObject */ public function create(User $user, $notrigger = 0) { + global $conf; $error = 0; // Clean parameters @@ -153,7 +154,8 @@ class Opensurveysondage extends CommonObject $sql .= "mailsonde,"; $sql .= "allow_comments,"; $sql .= "allow_spy,"; - $sql .= "sujet"; + $sql .= "sujet,"; + $sql .= "entity"; $sql .= ") VALUES ("; $sql .= "'".$this->db->escape($this->id_sondage)."',"; $sql .= " ".(empty($this->commentaires) ? 'NULL' : "'".$this->db->escape($this->commentaires)."'").","; @@ -165,7 +167,8 @@ class Opensurveysondage extends CommonObject $sql .= " ".$this->db->escape($this->mailsonde).","; $sql .= " ".$this->db->escape($this->allow_comments).","; $sql .= " ".$this->db->escape($this->allow_spy).","; - $sql .= " '".$this->db->escape($this->sujet)."'"; + $sql .= " '".$this->db->escape($this->sujet)."',"; + $sql .= " '".$conf->entity."',"; $sql .= ")"; $this->db->begin(); From 94d57cd462ca57ee7ad8283321822dabaa34f3e2 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Fri, 4 Dec 2020 10:03:06 +0100 Subject: [PATCH 017/147] fix rounding --- htdocs/fourn/class/fournisseur.commande.class.php | 2 +- htdocs/fourn/class/fournisseur.product.class.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index dc3113f2554..af283d8cdf0 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -1729,9 +1729,9 @@ class CommandeFournisseur extends CommonOrder { $coeff = intval($qty / $prod->packaging) + 1; $qty = $prod->packaging * $coeff; - setEventMessage($langs->trans('QtyRecalculatedWithPackaging'), 'mesgs'); } } + setEventMessage($langs->trans('QtyRecalculatedWithPackaging'), 'mesgs'); } } else diff --git a/htdocs/fourn/class/fournisseur.product.class.php b/htdocs/fourn/class/fournisseur.product.class.php index 1643ae69846..5a36e6bdabf 100644 --- a/htdocs/fourn/class/fournisseur.product.class.php +++ b/htdocs/fourn/class/fournisseur.product.class.php @@ -274,7 +274,7 @@ class ProductFournisseur extends Product $charges = price2num($charges, 'MU'); $qty = price2num($qty, 'MS'); $unitBuyPrice = price2num($buyprice / $qty, 'MU'); - $packaging = ($this->packaging < $qty) ? $qty : $this->packaging; + $packaging = price2num((($this->packaging < $qty) ? $qty : $this->packaging), 'MS'); $error = 0; $now = dol_now(); From 7685ed8295ab60e6c3668610fdba56ad18e45d98 Mon Sep 17 00:00:00 2001 From: Florian Mortgat Date: Fri, 4 Dec 2020 10:10:44 +0100 Subject: [PATCH 018/147] FIX excess comma --- htdocs/opensurvey/class/opensurveysondage.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/opensurvey/class/opensurveysondage.class.php b/htdocs/opensurvey/class/opensurveysondage.class.php index 83902f8c678..9d7462e87b6 100644 --- a/htdocs/opensurvey/class/opensurveysondage.class.php +++ b/htdocs/opensurvey/class/opensurveysondage.class.php @@ -168,7 +168,7 @@ class Opensurveysondage extends CommonObject $sql .= " ".$this->db->escape($this->allow_comments).","; $sql .= " ".$this->db->escape($this->allow_spy).","; $sql .= " '".$this->db->escape($this->sujet)."',"; - $sql .= " '".$conf->entity."',"; + $sql .= " ".$conf->entity; $sql .= ")"; $this->db->begin(); From 2173b8566e83ac7a10fe831e54dc580e671ffb14 Mon Sep 17 00:00:00 2001 From: Denis Date: Fri, 4 Dec 2020 10:58:29 +0100 Subject: [PATCH 019/147] Corrected "cash fence" to "cash desk closing" on english .lang files --- htdocs/langs/en_US/banks.lang | 4 ++-- htdocs/langs/en_US/blockedlog.lang | 2 +- htdocs/langs/en_US/cashdesk.lang | 8 ++++---- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/htdocs/langs/en_US/banks.lang b/htdocs/langs/en_US/banks.lang index 9500a5b8b2e..a0dc27f86c4 100644 --- a/htdocs/langs/en_US/banks.lang +++ b/htdocs/langs/en_US/banks.lang @@ -173,8 +173,8 @@ SEPAMandate=SEPA mandate YourSEPAMandate=Your SEPA mandate FindYourSEPAMandate=This is your SEPA mandate to authorize our company to make direct debit order to your bank. Return it signed (scan of the signed document) or send it by mail to AutoReportLastAccountStatement=Automatically fill the field 'number of bank statement' with last statement number when making reconciliation -CashControl=POS cash fence -NewCashFence=New cash fence +CashControl=POS cash desk control +NewCashFence=New cash desk closing BankColorizeMovement=Colorize movements BankColorizeMovementDesc=If this function is enable, you can choose specific background color for debit or credit movements BankColorizeMovementName1=Background color for debit movement diff --git a/htdocs/langs/en_US/blockedlog.lang b/htdocs/langs/en_US/blockedlog.lang index 5afae6e9e53..0bba5605d0f 100644 --- a/htdocs/langs/en_US/blockedlog.lang +++ b/htdocs/langs/en_US/blockedlog.lang @@ -35,7 +35,7 @@ logDON_DELETE=Donation logical deletion logMEMBER_SUBSCRIPTION_CREATE=Member subscription created logMEMBER_SUBSCRIPTION_MODIFY=Member subscription modified logMEMBER_SUBSCRIPTION_DELETE=Member subscription logical deletion -logCASHCONTROL_VALIDATE=Cash fence recording +logCASHCONTROL_VALIDATE=Cash desk closing recording BlockedLogBillDownload=Customer invoice download BlockedLogBillPreview=Customer invoice preview BlockedlogInfoDialog=Log Details diff --git a/htdocs/langs/en_US/cashdesk.lang b/htdocs/langs/en_US/cashdesk.lang index 549646ab110..8e529fe92f2 100644 --- a/htdocs/langs/en_US/cashdesk.lang +++ b/htdocs/langs/en_US/cashdesk.lang @@ -49,8 +49,8 @@ Footer=Footer AmountAtEndOfPeriod=Amount at end of period (day, month or year) TheoricalAmount=Theorical amount RealAmount=Real amount -CashFence=Cash fence -CashFenceDone=Cash fence done for the period +CashFence=Cash desk closing +CashFenceDone=Cash desk closing done for the period NbOfInvoices=Nb of invoices Paymentnumpad=Type of Pad to enter payment Numberspad=Numbers Pad @@ -99,8 +99,8 @@ CashDeskRefNumberingModules=Numbering module for POS sales CashDeskGenericMaskCodes6 =
{TN} tag is used to add the terminal number TakeposGroupSameProduct=Group same products lines StartAParallelSale=Start a new parallel sale -ControlCashOpening=Control cash box at opening POS -CloseCashFence=Close cash fence +ControlCashOpening=Control cash desk at opening POS +CloseCashFence=Close cash desk control CashReport=Cash report MainPrinterToUse=Main printer to use OrderPrinterToUse=Order printer to use From 0d4121c5bdb34c43adb5b4bdb3cce1b0338703bf Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 4 Dec 2020 12:01:41 +0100 Subject: [PATCH 020/147] Fix warning --- htdocs/contact/class/contact.class.php | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php index 59423ec2b42..6c6133e906a 100644 --- a/htdocs/contact/class/contact.class.php +++ b/htdocs/contact/class/contact.class.php @@ -805,19 +805,16 @@ class Contact extends CommonObject } // Mis a jour alerte birthday - if ($this->birthday_alert) - { + if (!empty($this->birthday_alert)) { //check existing $sql_check = "SELECT rowid FROM ".MAIN_DB_PREFIX."user_alert WHERE type=1 AND fk_contact=".$this->db->escape($id)." AND fk_user=".$user->id; $result_check = $this->db->query($sql_check); - if (!$result_check || ($this->db->num_rows($result_check) < 1)) - { + if (!$result_check || ($this->db->num_rows($result_check) < 1)) { //insert $sql = "INSERT INTO ".MAIN_DB_PREFIX."user_alert(type,fk_contact,fk_user) "; $sql .= "VALUES (1,".$this->db->escape($id).",".$user->id.")"; $result = $this->db->query($sql); - if (!$result) - { + if (!$result) { $error++; $this->error = $this->db->lasterror(); } @@ -828,23 +825,20 @@ class Contact extends CommonObject $sql = "DELETE FROM ".MAIN_DB_PREFIX."user_alert "; $sql .= "WHERE type=1 AND fk_contact=".$this->db->escape($id)." AND fk_user=".$user->id; $result = $this->db->query($sql); - if (!$result) - { + if (!$result) { $error++; $this->error = $this->db->lasterror(); } } - if (!$error && !$notrigger) - { + if (!$error && !$notrigger) { // Call trigger $result = $this->call_trigger('CONTACT_MODIFY', $user); if ($result < 0) { $error++; } // End call triggers } - if (!$error) - { + if (!$error) { $this->db->commit(); return 1; } else { From 34679c3bc1f43aa5f4dbf667384739c7a79e7666 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 4 Dec 2020 13:22:47 +0100 Subject: [PATCH 021/147] Fix warning in phpunit --- htdocs/main.inc.php | 4 ++-- test/phpunit/SecurityTest.php | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 1724ae9dd42..90e173ec168 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -243,12 +243,12 @@ $prefix = dol_getprefix(''); // This uses the $conf file $sessionname = 'DOLSESSID_'.$prefix; $sessiontimeout = 'DOLSESSTIMEOUT_'.$prefix; if (!empty($_COOKIE[$sessiontimeout])) ini_set('session.gc_maxlifetime', $_COOKIE[$sessiontimeout]); -session_set_cookie_params(0, '/', null, (empty($dolibarr_main_force_https) ? false : true), true); // Add tag secure and httponly on session cookie (same as setting session.cookie_httponly into php.ini). Must be called before the session_start. -session_name($sessionname); // This create lock, released by session_write_close() or end of page. // We need this lock as long as we read/write $_SESSION ['vars']. We can remove lock when finished. if (!defined('NOSESSION')) { + session_set_cookie_params(0, '/', null, (empty($dolibarr_main_force_https) ? false : true), true); // Add tag secure and httponly on session cookie (same as setting session.cookie_httponly into php.ini). Must be called before the session_start. + session_name($sessionname); session_start(); } diff --git a/test/phpunit/SecurityTest.php b/test/phpunit/SecurityTest.php index 008a2dcafd1..f6eb7783c4f 100644 --- a/test/phpunit/SecurityTest.php +++ b/test/phpunit/SecurityTest.php @@ -34,6 +34,7 @@ if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); // If there is no if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); // If we don't need to load the html.form.class.php if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); if (! defined("NOLOGIN")) define("NOLOGIN", '1'); // If this page is public (can be called outside logged session) +if (! defined("NOSESSION")) define("NOSESSION", '1'); require_once dirname(__FILE__).'/../../htdocs/main.inc.php'; require_once dirname(__FILE__).'/../../htdocs/core/lib/security.lib.php'; From c8f918265a1cfbf0b28917465667c598d33fd40e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 4 Dec 2020 13:25:56 +0100 Subject: [PATCH 022/147] Removed dead code --- test/phpunit/SocieteTest.php | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/test/phpunit/SocieteTest.php b/test/phpunit/SocieteTest.php index 4ed0771d668..0ca6cc8792b 100755 --- a/test/phpunit/SocieteTest.php +++ b/test/phpunit/SocieteTest.php @@ -382,25 +382,6 @@ class SocieteTest extends PHPUnit\Framework\TestCase return $result; } - /** - * testSocieteStatic - * - * @return void - */ - public function testSocieteStatic() - { - global $conf,$user,$langs,$db; - $conf=$this->savconf; - $user=$this->savuser; - $langs=$this->savlangs; - $db=$this->savdb; - - $localobject=new Societe($db); - - - return; - } - /** * testSocieteGetFullAddress From 575bb7d420a3f8f2638c40baca817f5618f562b8 Mon Sep 17 00:00:00 2001 From: atm-benoit Date: Fri, 4 Dec 2020 14:20:25 +0100 Subject: [PATCH 023/147] FIX SHIP MODE install v12 bug insert --- htdocs/install/mysql/data/llx_c_shipment_mode.sql | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/htdocs/install/mysql/data/llx_c_shipment_mode.sql b/htdocs/install/mysql/data/llx_c_shipment_mode.sql index e5026f8d2f7..97c05b13d0c 100644 --- a/htdocs/install/mysql/data/llx_c_shipment_mode.sql +++ b/htdocs/install/mysql/data/llx_c_shipment_mode.sql @@ -37,9 +37,9 @@ INSERT INTO llx_c_shipment_mode (rowid,code,libelle,description,tracking,active) INSERT INTO llx_c_shipment_mode (rowid,code,libelle,description,tracking,active) VALUES (6,'KIALA','KIALA','Relais Kiala','http://www.kiala.fr/tnt/delivery/{TRACKID}', 0); INSERT INTO llx_c_shipment_mode (rowid,code,libelle,description,tracking,active) VALUES (7,'GLS','GLS','General Logistics Systems','https://gls-group.eu/FR/fr/suivi-colis?match={TRACKID}', 0); INSERT INTO llx_c_shipment_mode (rowid,code,libelle,description,tracking,active) VALUES (8,'CHRONO','Chronopost','Chronopost','http://www.chronopost.fr/expedier/inputLTNumbersNoJahia.do?listeNumeros={TRACKID}', 0); -INSERT INTO llx_c_shipment_mode (rowid,code,libelle,description,tracking,active) VALUES (9,'INPERSON', 'In person at your site', NULL, NULL, 0, NULL), -INSERT INTO llx_c_shipment_mode (rowid,code,libelle,description,tracking,active) VALUES (10,'FEDEX', 'Fedex', NULL, 'https://www.fedex.com/apps/fedextrack/index.html?tracknumbers={TRACKID}', 0, NULL), -INSERT INTO llx_c_shipment_mode (rowid,code,libelle,description,tracking,active) VALUES (11,'TNT', 'TNT', NULL, 'https://www.tnt.com/express/fr_fr/site/outils-expedition/suivi.html?searchType=con&cons=={TRACKID}', 0, NULL), -INSERT INTO llx_c_shipment_mode (rowid,code,libelle,description,tracking,active) VALUES (12,'DHL', 'DHL', NULL, 'https://www.dhl.com/fr-fr/home/tracking/tracking-global-forwarding.html?submit=1&tracking-id={TRACKID}', 0, NULL), -INSERT INTO llx_c_shipment_mode (rowid,code,libelle,description,tracking,active) VALUES (13,'DPD', 'DPD', NULL, 'https://www.dpd.fr/trace/{TRACKID}', 0, NULL), -INSERT INTO llx_c_shipment_mode (rowid,code,libelle,description,tracking,active) VALUES (14,'MAINFREIGHT', 'Mainfreight', NULL, 'https://www.mainfreight.com/track?{TRACKID}', 0, NULL); +INSERT INTO llx_c_shipment_mode (rowid,code,libelle,description,tracking,active) VALUES (9,'INPERSON', 'In person at your site', NULL, NULL, 0), +INSERT INTO llx_c_shipment_mode (rowid,code,libelle,description,tracking,active) VALUES (10,'FEDEX', 'Fedex', NULL, 'https://www.fedex.com/apps/fedextrack/index.html?tracknumbers={TRACKID}', 0), +INSERT INTO llx_c_shipment_mode (rowid,code,libelle,description,tracking,active) VALUES (11,'TNT', 'TNT', NULL, 'https://www.tnt.com/express/fr_fr/site/outils-expedition/suivi.html?searchType=con&cons=={TRACKID}', 0), +INSERT INTO llx_c_shipment_mode (rowid,code,libelle,description,tracking,active) VALUES (12,'DHL', 'DHL', NULL, 'https://www.dhl.com/fr-fr/home/tracking/tracking-global-forwarding.html?submit=1&tracking-id={TRACKID}', 0), +INSERT INTO llx_c_shipment_mode (rowid,code,libelle,description,tracking,active) VALUES (13,'DPD', 'DPD', NULL, 'https://www.dpd.fr/trace/{TRACKID}', 0, ), +INSERT INTO llx_c_shipment_mode (rowid,code,libelle,description,tracking,active) VALUES (14,'MAINFREIGHT', 'Mainfreight', NULL, 'https://www.mainfreight.com/track?{TRACKID}', 0); From 9c191cda431f2a465576359d17d4adea7623a46d Mon Sep 17 00:00:00 2001 From: lmarcouiller Date: Fri, 4 Dec 2020 14:28:09 +0100 Subject: [PATCH 024/147] New #8172 : PHPExcel replace by PHPSpreadSheet --- .../modules/import/import_xlsx.modules.php | 264 ++++++++---------- 1 file changed, 117 insertions(+), 147 deletions(-) diff --git a/htdocs/core/modules/import/import_xlsx.modules.php b/htdocs/core/modules/import/import_xlsx.modules.php index 858dc8e1076..783370eae0f 100644 --- a/htdocs/core/modules/import/import_xlsx.modules.php +++ b/htdocs/core/modules/import/import_xlsx.modules.php @@ -25,7 +25,11 @@ * \brief File to load import files with Excel format */ -require_once DOL_DOCUMENT_ROOT.'/core/modules/import/modules_import.php'; +use PhpOffice\PhpSpreadsheet\Reader\Xlsx; +use PhpOffice\PhpSpreadsheet\Spreadsheet; +use PhpOffice\PhpSpreadsheet\Style\Alignment; + +require_once DOL_DOCUMENT_ROOT . '/core/modules/import/modules_import.php'; /** @@ -107,24 +111,29 @@ class ImportXlsx extends ModeleImports $this->extension = 'xlsx'; // Extension for generated file by this driver $this->picto = 'mime/xls'; // Picto (This is not used by the example file code as Mime type, too bad ...) $this->version = '1.0'; // Driver version - // If driver use an external library, put its name here - require_once PHPEXCEL_PATH.'PHPExcel.php'; - require_once PHPEXCEL_PATH.'PHPExcel/Style/Alignment.php'; - if (!class_exists('ZipArchive')) // For Excel2007, PHPExcel need ZipArchive + require_once DOL_DOCUMENT_ROOT . '/includes/phpoffice/autoloader.php'; + require_once DOL_DOCUMENT_ROOT . '/includes/Psr/autoloader.php'; + require_once PHPEXCELNEW_PATH . 'Spreadsheet.php'; + $this->workbook = new Spreadsheet(); + + //if ($this->id == 'excel2007new') { + if (!class_exists('ZipArchive')) // For Excel2007 + { $langs->load("errors"); $this->error = $langs->trans('ErrorPHPNeedModule', 'zip'); return -1; + } } - $this->label_lib = 'PhpExcel'; + $this->label_lib = 'PhpSpreadSheet'; $this->version_lib = '1.8.0'; - + $this->datatoimport = $datatoimport; if (preg_match('/^societe_/', $datatoimport)) $this->thirpartyobject = new Societe($this->db); } - - + + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Output header of an example file for this format @@ -135,21 +144,12 @@ class ImportXlsx extends ModeleImports public function write_header_example($outputlangs) { // phpcs:enable - global $user, $conf, $langs; + global $user, $conf, $langs, $file; // create a temporary object, the final output will be generated in footer - if (!empty($conf->global->MAIN_USE_FILECACHE_EXPORT_EXCEL_DIR)) { - $cacheMethod = PHPExcel_CachedObjectStorageFactory::cache_to_discISAM; - $cacheSettings = array( - 'dir' => $conf->global->MAIN_USE_FILECACHE_EXPORT_EXCEL_DIR - ); - PHPExcel_Settings::setCacheStorageMethod($cacheMethod, $cacheSettings); - } - - $this->workbook = new PHPExcel(); - $this->workbook->getProperties()->setCreator($user->getFullName($outputlangs).' - Dolibarr '.DOL_VERSION); - $this->workbook->getProperties()->setTitle($outputlangs->trans("Import").' - '.$file); - $this->workbook->getProperties()->setSubject($outputlangs->trans("Import").' - '.$file); - $this->workbook->getProperties()->setDescription($outputlangs->trans("Import").' - '.$file); + $this->workbook->getProperties()->setCreator($user->getFullName($outputlangs) . ' - Dolibarr ' . DOL_VERSION); + $this->workbook->getProperties()->setTitle($outputlangs->trans("Import") . ' - ' . $file); + $this->workbook->getProperties()->setSubject($outputlangs->trans("Import") . ' - ' . $file); + $this->workbook->getProperties()->setDescription($outputlangs->trans("Import") . ' - ' . $file); $this->workbook->setActiveSheetIndex(0); $this->workbook->getActiveSheet()->setTitle($outputlangs->trans("Sheet")); @@ -171,7 +171,7 @@ class ImportXlsx extends ModeleImports // phpcs:enable global $conf; $this->workbook->getActiveSheet()->getStyle('1')->getFont()->setBold(true); - $this->workbook->getActiveSheet()->getStyle('1')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT); + $this->workbook->getActiveSheet()->getStyle('1')->getAlignment()->setHorizontal(Alignment::HORIZONTAL_LEFT); $col = 0; foreach ($headerlinefields as $field) { @@ -217,7 +217,7 @@ class ImportXlsx extends ModeleImports // phpcs:enable // return the file content as a string $tempfile = tempnam(sys_get_temp_dir(), 'dol'); - $objWriter = new PHPExcel_Writer_Excel2007($this->workbook); + $objWriter = new PhpOffice\PhpSpreadsheet\Writer\Xlsx($this->workbook); $objWriter->save($tempfile); $this->workbook->disconnectWorksheets(); unset($this->workbook); @@ -242,9 +242,9 @@ class ImportXlsx extends ModeleImports global $langs; $ret = 1; - dol_syslog(get_class($this)."::open_file file=".$file); + dol_syslog(get_class($this) . "::open_file file=" . $file); - $reader = new PHPExcel_Reader_Excel2007(); + $reader = new Xlsx(); $this->workbook = $reader->load($file); $this->record = 1; $this->file = $file; @@ -263,7 +263,7 @@ class ImportXlsx extends ModeleImports public function import_get_nb_of_lines($file) { // phpcs:enable - $reader = new PHPExcel_Reader_Excel2007(); + $reader = new Xlsx(); $this->workbook = $reader->load($file); $rowcount = $this->workbook->getActiveSheet()->getHighestDataRow(); @@ -286,8 +286,10 @@ class ImportXlsx extends ModeleImports // phpcs:enable // This is not called by the import code !!! $this->headers = array(); - $colcount = PHPExcel_Cell::columnIndexFromString($this->workbook->getActiveSheet()->getHighestDataColumn()); - for ($col = 0; $col < $colcount; $col++) { + $xlsx = new Xlsx(); + $info = $xlsx->listWorksheetinfo($this->file); + $countcolumns = $info[0]['totalColumns']; + for ($col = 0; $col < $countcolumns; $col++) { $this->headers[$col] = $this->workbook->getActiveSheet()->getCellByColumnAndRow($col, 1)->getValue(); } return 0; @@ -309,8 +311,10 @@ class ImportXlsx extends ModeleImports if ($this->record > $rowcount) return false; $array = array(); - $colcount = PHPExcel_Cell::columnIndexFromString($this->workbook->getActiveSheet()->getHighestDataColumn(0)); - for ($col = 0; $col < $colcount; $col++) { + $xlsx = new Xlsx(); + $info = $xlsx->listWorksheetinfo($this->file); + $countcolumns = $info[0]['totalColumns']; + for ($col = 0; $col < $countcolumns; $col++) { $val = $this->workbook->getActiveSheet()->getCellByColumnAndRow($col, $this->record)->getValue(); $array[$col]['val'] = $val; $array[$col]['type'] = (dol_strlen($val) ? 1 : -1); // If empty we consider it null @@ -368,8 +372,7 @@ class ImportXlsx extends ModeleImports //var_dump($sort_array_match_file_to_database); - if (count($arrayrecord) == 0 || (count($arrayrecord) == 1 && empty($arrayrecord[0]['val']))) - { + if (count($arrayrecord) == 0 || (count($arrayrecord) == 1 && empty($arrayrecord[0]['val']))) { //print 'W'; $this->warnings[$warning]['lib'] = $langs->trans('EmptyLine'); $this->warnings[$warning]['type'] = 'EMPTY'; @@ -379,8 +382,7 @@ class ImportXlsx extends ModeleImports $updatedone = false; $insertdone = false; // For each table to insert, me make a separate insert - foreach ($objimport->array_import_tables[0] as $alias => $tablename) - { + foreach ($objimport->array_import_tables[0] as $alias => $tablename) { // Build sql request $sql = ''; $listfields = array(); @@ -391,10 +393,9 @@ class ImportXlsx extends ModeleImports // Define $tablewithentity_cache[$tablename] if not already defined if (!isset($tablewithentity_cache[$tablename])) // keep this test with "isset" { - dol_syslog("Check if table ".$tablename." has an entity field"); + dol_syslog("Check if table " . $tablename . " has an entity field"); $resql = $this->db->DDLDescTable($tablename, 'entity'); - if ($resql) - { + if ($resql) { $obj = $this->db->fetch_object($resql); if ($obj) $tablewithentity_cache[$tablename] = 1; // table contains entity field else $tablewithentity_cache[$tablename] = 0; // table does not contains entity field @@ -410,15 +411,13 @@ class ImportXlsx extends ModeleImports } // Loop on each fields in the match array: $key = 1..n, $val=alias of field (s.nom) - foreach ($sort_array_match_file_to_database as $key => $val) - { + foreach ($sort_array_match_file_to_database as $key => $val) { $fieldalias = preg_replace('/\..*$/i', '', $val); $fieldname = preg_replace('/^.*\./i', '', $val); if ($alias != $fieldalias) continue; // Not a field of current table - if ($key <= $maxfields) - { + if ($key <= $maxfields) { // Set $newval with value to insert and set $listvalues with sql request part for insert $newval = ''; if ($arrayrecord[($key - 1)]['type'] > 0) $newval = $arrayrecord[($key - 1)]['val']; // If type of field into input file is not empty string (so defined into input file), we get value @@ -426,8 +425,7 @@ class ImportXlsx extends ModeleImports // Make some tests on $newval // Is it a required field ? - if (preg_match('/\*/', $objimport->array_import_fields[0][$val]) && ((string) $newval == '')) - { + if (preg_match('/\*/', $objimport->array_import_fields[0][$val]) && ((string) $newval == '')) { $this->errors[$error]['lib'] = $langs->trans('ErrorMissingMandatoryValue', $key); $this->errors[$error]['type'] = 'NOTNULL'; $errorforthistable++; @@ -436,14 +434,13 @@ class ImportXlsx extends ModeleImports // Test format only if field is not a missing mandatory field (field may be a value or empty but not mandatory) else { // We convert field if required - if (!empty($objimport->array_import_convertvalue[0][$val])) - { + if (!empty($objimport->array_import_convertvalue[0][$val])) { //print 'Must convert '.$newval.' with rule '.join(',',$objimport->array_import_convertvalue[0][$val]).'. '; - if ($objimport->array_import_convertvalue[0][$val]['rule'] == 'fetchidfromcodeid' + if ( + $objimport->array_import_convertvalue[0][$val]['rule'] == 'fetchidfromcodeid' || $objimport->array_import_convertvalue[0][$val]['rule'] == 'fetchidfromref' || $objimport->array_import_convertvalue[0][$val]['rule'] == 'fetchidfromcodeorlabel' - ) - { + ) { // New val can be an id or ref. If it start with id: it is forced to id, if it start with ref: it is forced to ref. It not, we try to guess. $isidorref = 'id'; if (!is_numeric($newval) && $newval != '' && !preg_match('/^id:/i', $newval)) $isidorref = 'ref'; @@ -454,21 +451,18 @@ class ImportXlsx extends ModeleImports $file = (empty($objimport->array_import_convertvalue[0][$val]['classfile']) ? $objimport->array_import_convertvalue[0][$val]['file'] : $objimport->array_import_convertvalue[0][$val]['classfile']); $class = $objimport->array_import_convertvalue[0][$val]['class']; $method = $objimport->array_import_convertvalue[0][$val]['method']; - if ($this->cacheconvert[$file.'_'.$class.'_'.$method.'_'][$newval] != '') - { - $newval = $this->cacheconvert[$file.'_'.$class.'_'.$method.'_'][$newval]; + if ($this->cacheconvert[$file . '_' . $class . '_' . $method . '_'][$newval] != '') { + $newval = $this->cacheconvert[$file . '_' . $class . '_' . $method . '_'][$newval]; } else { $resultload = dol_include_once($file); - if (empty($resultload)) - { - dol_print_error('', 'Error trying to call file='.$file.', class='.$class.', method='.$method); + if (empty($resultload)) { + dol_print_error('', 'Error trying to call file=' . $file . ', class=' . $class . ', method=' . $method); break; } $classinstance = new $class($this->db); // Try the fetch from code or ref $param_array = array('', $newval); - if ($class == 'AccountingAccount') - { + if ($class == 'AccountingAccount') { //var_dump($arrayrecord[0]['val']); /*include_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountancysystem.class.php'; $tmpchartofaccount = new AccountancySystem($this->db); @@ -485,12 +479,11 @@ class ImportXlsx extends ModeleImports } call_user_func_array(array($classinstance, $method), $param_array); // If not found, try the fetch from label - if (!($classinstance->id != '') && $objimport->array_import_convertvalue[0][$val]['rule'] == 'fetchidfromcodeorlabel') - { + if (!($classinstance->id != '') && $objimport->array_import_convertvalue[0][$val]['rule'] == 'fetchidfromcodeorlabel') { $param_array = array('', '', $newval); call_user_func_array(array($classinstance, $method), $param_array); } - $this->cacheconvert[$file.'_'.$class.'_'.$method.'_'][$newval] = $classinstance->id; + $this->cacheconvert[$file . '_' . $class . '_' . $method . '_'][$newval] = $classinstance->id; //print 'We have made a '.$class.'->'.$method.' to get id from code '.$newval.'. '; if ($classinstance->id != '') // id may be 0, it is a found value { @@ -516,19 +509,19 @@ class ImportXlsx extends ModeleImports $method = $objimport->array_import_convertvalue[0][$val]['method']; $codefromfield = $objimport->array_import_convertvalue[0][$val]['codefromfield']; $code = $arrayrecord[$arrayfield[$codefromfield]]['val']; - if ($this->cacheconvert[$file.'_'.$class.'_'.$method.'_'.$code][$newval] != '') { - $newval = $this->cacheconvert[$file.'_'.$class.'_'.$method.'_'.$code][$newval]; + if ($this->cacheconvert[$file . '_' . $class . '_' . $method . '_' . $code][$newval] != '') { + $newval = $this->cacheconvert[$file . '_' . $class . '_' . $method . '_' . $code][$newval]; } else { $resultload = dol_include_once($file); if (empty($resultload)) { - dol_print_error('', 'Error trying to call file='.$file.', class='.$class.', method='.$method.', code='.$code); + dol_print_error('', 'Error trying to call file=' . $file . ', class=' . $class . ', method=' . $method . ', code=' . $code); break; } $classinstance = new $class($this->db); // Try the fetch from code and ref $param_array = array('', $newval, $code); call_user_func_array(array($classinstance, $method), $param_array); - $this->cacheconvert[$file.'_'.$class.'_'.$method.'_'.$code][$newval] = $classinstance->id; + $this->cacheconvert[$file . '_' . $class . '_' . $method . '_' . $code][$newval] = $classinstance->id; if ($classinstance->id > 0) // we found record { $newval = $classinstance->id; @@ -548,21 +541,19 @@ class ImportXlsx extends ModeleImports $class = $objimport->array_import_convertvalue[0][$val]['class']; $method = $objimport->array_import_convertvalue[0][$val]['method']; $units = $objimport->array_import_convertvalue[0][$val]['units']; - if ($this->cacheconvert[$file.'_'.$class.'_'.$method.'_'.$units][$newval] != '') - { - $newval = $this->cacheconvert[$file.'_'.$class.'_'.$method.'_'.$units][$newval]; + if ($this->cacheconvert[$file . '_' . $class . '_' . $method . '_' . $units][$newval] != '') { + $newval = $this->cacheconvert[$file . '_' . $class . '_' . $method . '_' . $units][$newval]; } else { $resultload = dol_include_once($file); - if (empty($resultload)) - { - dol_print_error('', 'Error trying to call file='.$file.', class='.$class.', method='.$method.', units='.$units); + if (empty($resultload)) { + dol_print_error('', 'Error trying to call file=' . $file . ', class=' . $class . ', method=' . $method . ', units=' . $units); break; } $classinstance = new $class($this->db); // Try the fetch from code or ref call_user_func_array(array($classinstance, $method), array('', '', $newval, $units)); $scaleorid = (($objimport->array_import_convertvalue[0][$val]['rule'] == 'fetchidfromcodeunits') ? $classinstance->id : $classinstance->scale); - $this->cacheconvert[$file.'_'.$class.'_'.$method.'_'.$units][$newval] = $scaleorid; + $this->cacheconvert[$file . '_' . $class . '_' . $method . '_' . $units][$newval] = $scaleorid; //print 'We have made a '.$class.'->'.$method." to get a value from key '".$newval."' and we got '".$scaleorid."'.";exit; if ($classinstance->id > 0) // we found record { @@ -576,32 +567,28 @@ class ImportXlsx extends ModeleImports } } } elseif ($objimport->array_import_convertvalue[0][$val]['rule'] == 'getcustomercodeifauto') { - if (strtolower($newval) == 'auto') - { + if (strtolower($newval) == 'auto') { $this->thirpartyobject->get_codeclient(0, 0); $newval = $this->thirpartyobject->code_client; //print 'code_client='.$newval; } if (empty($newval)) $arrayrecord[($key - 1)]['type'] = -1; // If we get empty value, we will use "null" } elseif ($objimport->array_import_convertvalue[0][$val]['rule'] == 'getsuppliercodeifauto') { - if (strtolower($newval) == 'auto') - { + if (strtolower($newval) == 'auto') { $newval = $this->thirpartyobject->get_codefournisseur(0, 1); $newval = $this->thirpartyobject->code_fournisseur; //print 'code_fournisseur='.$newval; } if (empty($newval)) $arrayrecord[($key - 1)]['type'] = -1; // If we get empty value, we will use "null" } elseif ($objimport->array_import_convertvalue[0][$val]['rule'] == 'getcustomeraccountancycodeifauto') { - if (strtolower($newval) == 'auto') - { + if (strtolower($newval) == 'auto') { $this->thirpartyobject->get_codecompta('customer'); $newval = $this->thirpartyobject->code_compta; //print 'code_compta='.$newval; } if (empty($newval)) $arrayrecord[($key - 1)]['type'] = -1; // If we get empty value, we will use "null" } elseif ($objimport->array_import_convertvalue[0][$val]['rule'] == 'getsupplieraccountancycodeifauto') { - if (strtolower($newval) == 'auto') - { + if (strtolower($newval) == 'auto') { $this->thirpartyobject->get_codecompta('supplier'); $newval = $this->thirpartyobject->code_compta_fournisseur; if (empty($newval)) $arrayrecord[($key - 1)]['type'] = -1; // If we get empty value, we will use "null" @@ -612,9 +599,8 @@ class ImportXlsx extends ModeleImports $defaultref = ''; // TODO provide the $modTask (module of generation of ref) as parameter of import_insert function $obj = empty($conf->global->PROJECT_TASK_ADDON) ? 'mod_task_simple' : $conf->global->PROJECT_TASK_ADDON; - if (!empty($conf->global->PROJECT_TASK_ADDON) && is_readable(DOL_DOCUMENT_ROOT."/core/modules/project/task/".$conf->global->PROJECT_TASK_ADDON.".php")) - { - require_once DOL_DOCUMENT_ROOT."/core/modules/project/task/".$conf->global->PROJECT_TASK_ADDON.'.php'; + if (!empty($conf->global->PROJECT_TASK_ADDON) && is_readable(DOL_DOCUMENT_ROOT . "/core/modules/project/task/" . $conf->global->PROJECT_TASK_ADDON . ".php")) { + require_once DOL_DOCUMENT_ROOT . "/core/modules/project/task/" . $conf->global->PROJECT_TASK_ADDON . '.php'; $modTask = new $obj; $defaultref = $modTask->getNextValue(null, null); } @@ -625,9 +611,8 @@ class ImportXlsx extends ModeleImports $class = $objimport->array_import_convertvalue[0][$val]['class']; $method = $objimport->array_import_convertvalue[0][$val]['method']; $resultload = dol_include_once($file); - if (empty($resultload)) - { - dol_print_error('', 'Error trying to call file='.$file.', class='.$class.', method='.$method); + if (empty($resultload)) { + dol_print_error('', 'Error trying to call file=' . $file . ', class=' . $class . ', method=' . $method); break; } $classinstance = new $class($this->db); @@ -649,34 +634,29 @@ class ImportXlsx extends ModeleImports } // Test regexp - if (!empty($objimport->array_import_regex[0][$val]) && ($newval != '')) - { + if (!empty($objimport->array_import_regex[0][$val]) && ($newval != '')) { // If test is "Must exist in a field@table or field@table:..." - if (preg_match('/^(.+)@([^:]+)(:.+)?$/', $objimport->array_import_regex[0][$val], $reg)) - { + if (preg_match('/^(.+)@([^:]+)(:.+)?$/', $objimport->array_import_regex[0][$val], $reg)) { $field = $reg[1]; $table = $reg[2]; - $filter = !empty($reg[3]) ?substr($reg[3], 1) : ''; + $filter = !empty($reg[3]) ? substr($reg[3], 1) : ''; - $cachekey = $field.'@'.$table; - if (!empty($filter)) $cachekey .= ':'.$filter; + $cachekey = $field . '@' . $table; + if (!empty($filter)) $cachekey .= ':' . $filter; // Load content of field@table into cache array if (!is_array($this->cachefieldtable[$cachekey])) // If content of field@table not already loaded into cache { - $sql = "SELECT ".$field." as aliasfield FROM ".$table; - if (!empty($filter)) - { - $sql .= ' WHERE '.$filter; + $sql = "SELECT " . $field . " as aliasfield FROM " . $table; + if (!empty($filter)) { + $sql .= ' WHERE ' . $filter; } $resql = $this->db->query($sql); - if ($resql) - { + if ($resql) { $num = $this->db->num_rows($resql); $i = 0; - while ($i < $num) - { + while ($i < $num) { $obj = $this->db->fetch_object($resql); if ($obj) $this->cachefieldtable[$cachekey][] = $obj->aliasfield; $i++; @@ -687,10 +667,9 @@ class ImportXlsx extends ModeleImports } // Now we check cache is not empty (should not) and key is into cache - if (!is_array($this->cachefieldtable[$cachekey]) || !in_array($newval, $this->cachefieldtable[$cachekey])) - { + if (!is_array($this->cachefieldtable[$cachekey]) || !in_array($newval, $this->cachefieldtable[$cachekey])) { $tableforerror = $table; - if (!empty($filter)) $tableforerror .= ':'.$filter; + if (!empty($filter)) $tableforerror .= ':' . $filter; $this->errors[$error]['lib'] = $langs->transnoentitiesnoconv('ErrorFieldValueNotIn', $key, $newval, $field, $tableforerror); $this->errors[$error]['type'] = 'FOREIGNKEY'; $errorforthistable++; @@ -698,7 +677,7 @@ class ImportXlsx extends ModeleImports } } // If test is just a static regex - elseif (!preg_match('/'.$objimport->array_import_regex[0][$val].'/i', $newval)) { + elseif (!preg_match('/' . $objimport->array_import_regex[0][$val] . '/i', $newval)) { //if ($key == 19) print "xxx".$newval."zzz".$objimport->array_import_regex[0][$val]."
"; $this->errors[$error]['lib'] = $langs->transnoentitiesnoconv('ErrorWrongValueForField', $key, $newval, $objimport->array_import_regex[0][$val]); $this->errors[$error]['type'] = 'REGEX'; @@ -717,37 +696,32 @@ class ImportXlsx extends ModeleImports // Note: arrayrecord (and 'type') is filled with ->import_read_record called by import.php page before calling import_insert if (empty($newval) && $arrayrecord[($key - 1)]['type'] < 0) $listvalues[] = ($newval == '0' ? $newval : "null"); elseif (empty($newval) && $arrayrecord[($key - 1)]['type'] == 0) $listvalues[] = "''"; - else $listvalues[] = "'".$this->db->escape($newval)."'"; + else $listvalues[] = "'" . $this->db->escape($newval) . "'"; } $i++; } // We add hidden fields (but only if there is at least one field to add into table) - if (!empty($listfields) && is_array($objimport->array_import_fieldshidden[0])) - { + if (!empty($listfields) && is_array($objimport->array_import_fieldshidden[0])) { // Loop on each hidden fields to add them into listfields/listvalues - foreach ($objimport->array_import_fieldshidden[0] as $key => $val) - { - if (!preg_match('/^'.preg_quote($alias, '/').'\./', $key)) continue; // Not a field of current table - if ($val == 'user->id') - { - $listfields[] = preg_replace('/^'.preg_quote($alias, '/').'\./', '', $key); + foreach ($objimport->array_import_fieldshidden[0] as $key => $val) { + if (!preg_match('/^' . preg_quote($alias, '/') . '\./', $key)) continue; // Not a field of current table + if ($val == 'user->id') { + $listfields[] = preg_replace('/^' . preg_quote($alias, '/') . '\./', '', $key); $listvalues[] = $user->id; - } elseif (preg_match('/^lastrowid-/', $val)) - { + } elseif (preg_match('/^lastrowid-/', $val)) { $tmp = explode('-', $val); $lastinsertid = (isset($last_insert_id_array[$tmp[1]])) ? $last_insert_id_array[$tmp[1]] : 0; - $keyfield = preg_replace('/^'.preg_quote($alias, '/').'\./', '', $key); + $keyfield = preg_replace('/^' . preg_quote($alias, '/') . '\./', '', $key); $listfields[] = $keyfield; $listvalues[] = $lastinsertid; //print $key."-".$val."-".$listfields."-".$listvalues."
";exit; - } elseif (preg_match('/^const-/', $val)) - { + } elseif (preg_match('/^const-/', $val)) { $tmp = explode('-', $val, 2); - $listfields[] = preg_replace('/^'.preg_quote($alias, '/').'\./', '', $key); - $listvalues[] = "'".$tmp[1]."'"; + $listfields[] = preg_replace('/^' . preg_quote($alias, '/') . '\./', '', $key); + $listvalues[] = "'" . $tmp[1] . "'"; } else { - $this->errors[$error]['lib'] = 'Bad value of profile setup '.$val.' for array_import_fieldshidden'; + $this->errors[$error]['lib'] = 'Bad value of profile setup ' . $val . ' for array_import_fieldshidden'; $this->errors[$error]['type'] = 'Import profile setup'; $error++; } @@ -757,18 +731,16 @@ class ImportXlsx extends ModeleImports // If no error for this $alias/$tablename, we have a complete $listfields and $listvalues that are defined // so we can try to make the insert or update now. - if (!$errorforthistable) - { + if (!$errorforthistable) { //print "$alias/$tablename/$listfields/$listvalues
"; - if (!empty($listfields)) - { + if (!empty($listfields)) { $updatedone = false; $insertdone = false; if (!empty($updatekeys)) { // We do SELECT to get the rowid, if we already have the rowid, it's to be used below for related tables (extrafields) if (empty($lastinsertid)) { // No insert done yet for a parent table - $sqlSelect = 'SELECT rowid FROM '.$tablename; + $sqlSelect = 'SELECT rowid FROM ' . $tablename; $data = array_combine($listfields, $listvalues); $where = array(); @@ -776,10 +748,10 @@ class ImportXlsx extends ModeleImports foreach ($updatekeys as $key) { $col = $objimport->array_import_updatekeys[0][$key]; $key = preg_replace('/^.*\./i', '', $key); - $where[] = $key.' = '.$data[$key]; - $filters[] = $col.' = '.$data[$key]; + $where[] = $key . ' = ' . $data[$key]; + $filters[] = $col . ' = ' . $data[$key]; } - $sqlSelect .= ' WHERE '.implode(' AND ', $where); + $sqlSelect .= ' WHERE ' . implode(' AND ', $where); $resql = $this->db->query($sqlSelect); if ($resql) { @@ -806,10 +778,10 @@ class ImportXlsx extends ModeleImports // a direct insert into subtable extrafields, but when me wake an update, the insertid is defined and the child record // may already exists. So we rescan the extrafield table to know if record exists or not for the rowid. // Note: For extrafield tablename, we have in importfieldshidden_array an enty 'extra.fk_object'=>'lastrowid-tableparent' so $keyfield is 'fk_object' - $sqlSelect = 'SELECT rowid FROM '.$tablename; + $sqlSelect = 'SELECT rowid FROM ' . $tablename; if (empty($keyfield)) $keyfield = 'rowid'; - $sqlSelect .= ' WHERE '.$keyfield.' = '.$lastinsertid; + $sqlSelect .= ' WHERE ' . $keyfield . ' = ' . $lastinsertid; $resql = $this->db->query($sqlSelect); if ($resql) { @@ -831,19 +803,19 @@ class ImportXlsx extends ModeleImports if (!empty($lastinsertid)) { // Build SQL UPDATE request - $sqlstart = 'UPDATE '.$tablename; + $sqlstart = 'UPDATE ' . $tablename; $data = array_combine($listfields, $listvalues); $set = array(); foreach ($data as $key => $val) { - $set[] = $key.' = '.$val; + $set[] = $key . ' = ' . $val; } - $sqlstart .= ' SET '.implode(', ', $set); + $sqlstart .= ' SET ' . implode(', ', $set); if (empty($keyfield)) $keyfield = 'rowid'; - $sqlend = ' WHERE '.$keyfield.' = '.$lastinsertid; + $sqlend = ' WHERE ' . $keyfield . ' = ' . $lastinsertid; - $sql = $sqlstart.$sqlend; + $sql = $sqlstart . $sqlend; // Run update request $resql = $this->db->query($sql); @@ -862,25 +834,23 @@ class ImportXlsx extends ModeleImports // Update not done, we do insert if (!$error && !$updatedone) { // Build SQL INSERT request - $sqlstart = 'INSERT INTO '.$tablename.'('.implode(', ', $listfields).', import_key'; - $sqlend = ') VALUES('.implode(', ', $listvalues).", '".$this->db->escape($importid)."'"; + $sqlstart = 'INSERT INTO ' . $tablename . '(' . implode(', ', $listfields) . ', import_key'; + $sqlend = ') VALUES(' . implode(', ', $listvalues) . ", '" . $this->db->escape($importid) . "'"; if (!empty($tablewithentity_cache[$tablename])) { $sqlstart .= ', entity'; - $sqlend .= ', '.$conf->entity; + $sqlend .= ', ' . $conf->entity; } if (!empty($objimport->array_import_tables_creator[0][$alias])) { - $sqlstart .= ', '.$objimport->array_import_tables_creator[0][$alias]; - $sqlend .= ', '.$user->id; + $sqlstart .= ', ' . $objimport->array_import_tables_creator[0][$alias]; + $sqlend .= ', ' . $user->id; } - $sql = $sqlstart.$sqlend.')'; + $sql = $sqlstart . $sqlend . ')'; dol_syslog("import_xlsx.modules", LOG_DEBUG); // Run insert request - if ($sql) - { + if ($sql) { $resql = $this->db->query($sql); - if ($resql) - { + if ($resql) { $last_insert_id_array[$tablename] = $this->db->last_insert_id($tablename); // store the last inserted auto_increment id for each table, so that child tables can be inserted with the appropriate id. This must be done just after the INSERT request, else we risk losing the id (because another sql query will be issued somewhere in Dolibarr). $insertdone = true; } else { From 6a2d842d3ed5c2eefad048354b9e21f0ca7fa99a Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Fri, 4 Dec 2020 13:47:55 +0000 Subject: [PATCH 025/147] Fixing style errors. --- .../modules/import/import_xlsx.modules.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/htdocs/core/modules/import/import_xlsx.modules.php b/htdocs/core/modules/import/import_xlsx.modules.php index 783370eae0f..c427e01a758 100644 --- a/htdocs/core/modules/import/import_xlsx.modules.php +++ b/htdocs/core/modules/import/import_xlsx.modules.php @@ -116,24 +116,24 @@ class ImportXlsx extends ModeleImports require_once DOL_DOCUMENT_ROOT . '/includes/Psr/autoloader.php'; require_once PHPEXCELNEW_PATH . 'Spreadsheet.php'; $this->workbook = new Spreadsheet(); - + //if ($this->id == 'excel2007new') { - if (!class_exists('ZipArchive')) // For Excel2007 + if (!class_exists('ZipArchive')) // For Excel2007 { - $langs->load("errors"); - $this->error = $langs->trans('ErrorPHPNeedModule', 'zip'); - return -1; - } + $langs->load("errors"); + $this->error = $langs->trans('ErrorPHPNeedModule', 'zip'); + return -1; + } } $this->label_lib = 'PhpSpreadSheet'; $this->version_lib = '1.8.0'; - + $this->datatoimport = $datatoimport; if (preg_match('/^societe_/', $datatoimport)) $this->thirpartyobject = new Societe($this->db); } - - + + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Output header of an example file for this format From 6d4a90b54334370459cc7f097a1f92e6945ab7f5 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 4 Dec 2020 14:53:52 +0100 Subject: [PATCH 026/147] Clean code --- htdocs/adherents/class/adherent.class.php | 14 ++++---- htdocs/core/class/html.formother.class.php | 30 ++++++++++------ htdocs/holiday/card.php | 4 +-- htdocs/holiday/common.inc.php | 42 ---------------------- htdocs/holiday/define_holiday.php | 17 +++++++-- htdocs/holiday/list.php | 13 +++++-- htdocs/holiday/month_report.php | 4 +-- htdocs/holiday/view_log.php | 18 +++++++--- test/phpunit/phpunittest.xml | 29 ++++++++------- 9 files changed, 85 insertions(+), 86 deletions(-) delete mode 100644 htdocs/holiday/common.inc.php diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index 0e57b274258..5df6db52f3d 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -103,6 +103,7 @@ class Adherent extends CommonObject * @var int Thirdparty ID */ public $fk_soc; + public $socid; /** * @var string Address @@ -1262,14 +1263,15 @@ class Adherent extends CommonObject $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as dep ON d.state_id = dep.rowid"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as u ON d.rowid = u.fk_member"; $sql .= " WHERE d.fk_adherent_type = t.rowid"; - if ($rowid) - $sql .= " AND d.rowid=".$rowid; - elseif ($ref || $fk_soc) { + if ($rowid) { + $sql .= " AND d.rowid=".((int) $rowid); + } elseif ($ref || $fk_soc) { $sql .= " AND d.entity IN (".getEntity('adherent').")"; - if ($ref) + if ($ref) { $sql .= " AND d.rowid='".$this->db->escape($ref)."'"; - elseif ($fk_soc > 0) - $sql .= " AND d.fk_soc=".$fk_soc; + } elseif ($fk_soc > 0) { + $sql .= " AND d.fk_soc=".((int) $fk_soc); + } } elseif ($ref_ext) { $sql .= " AND d.ref_ext='".$this->db->escape($ref_ext)."'"; } diff --git a/htdocs/core/class/html.formother.class.php b/htdocs/core/class/html.formother.class.php index f1e5ff9921c..3b9d9db2906 100644 --- a/htdocs/core/class/html.formother.class.php +++ b/htdocs/core/class/html.formother.class.php @@ -918,9 +918,10 @@ class FormOther * @param int $useempty Show empty in list * @param int $longlabel Show long label * @param string $morecss More Css + * @param bool $addjscombo Add js combo * @return string */ - public function select_month($selected = '', $htmlname = 'monthid', $useempty = 0, $longlabel = 0, $morecss = 'maxwidth50imp valignmiddle') + public function select_month($selected = '', $htmlname = 'monthid', $useempty = 0, $longlabel = 0, $morecss = 'minwidth50 maxwidth75imp valignmiddle', $addjscombo = false) { // phpcs:enable global $langs; @@ -947,6 +948,15 @@ class FormOther $select_month .= ''; } $select_month .= ''; + + // Add code for jquery to use multiselect + if ($addjscombo) + { + // Enhance with select2 + include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php'; + $select_month .= ajax_combobox($htmlname); + } + return $select_month; } @@ -986,18 +996,10 @@ class FormOther * @param bool $addjscombo Add js combo * @return string */ - public function selectyear($selected = '', $htmlname = 'yearid', $useempty = 0, $min_year = 10, $max_year = 5, $offset = 0, $invert = 0, $option = '', $morecss = 'valignmiddle maxwidth75imp', $addjscombo = false) + public function selectyear($selected = '', $htmlname = 'yearid', $useempty = 0, $min_year = 10, $max_year = 5, $offset = 0, $invert = 0, $option = '', $morecss = 'valignmiddle width75', $addjscombo = false) { $out = ''; - // Add code for jquery to use multiselect - if ($addjscombo) - { - // Enhance with select2 - include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php'; - $out .= ajax_combobox($htmlname); - } - $currentyear = date("Y") + $offset; $max_year = $currentyear + $max_year; $min_year = $currentyear - $min_year; @@ -1028,6 +1030,14 @@ class FormOther } $out .= "\n"; + // Add code for jquery to use multiselect + if ($addjscombo) + { + // Enhance with select2 + include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php'; + $out .= ajax_combobox($htmlname); + } + return $out; } diff --git a/htdocs/holiday/card.php b/htdocs/holiday/card.php index 7248f385994..4adecb20235 100644 --- a/htdocs/holiday/card.php +++ b/htdocs/holiday/card.php @@ -36,7 +36,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/holiday.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/holiday/common.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/holiday/class/holiday.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; // Get parameters @@ -49,7 +49,7 @@ $ref = GETPOST('ref', 'alpha'); $fuserid = (GETPOST('fuserid', 'int') ?GETPOST('fuserid', 'int') : $user->id); // Load translation files required by the page -$langs->loadLangs(array("holiday", "mails")); +$langs->loadLangs(array("other", "holiday", "mails")); $now = dol_now(); diff --git a/htdocs/holiday/common.inc.php b/htdocs/holiday/common.inc.php deleted file mode 100644 index f8a09e85ad5..00000000000 --- a/htdocs/holiday/common.inc.php +++ /dev/null @@ -1,42 +0,0 @@ - - * Copyright (C) 2011 Dimitri Mouillard - * Copyright (C) 2012 Regis Houssin - * - * 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/holiday/common.inc.php - * \ingroup holiday - * \brief Common load of data - */ - -require_once realpath(__DIR__).'/../main.inc.php'; -if (!class_exists('Holiday')) { - require_once DOL_DOCUMENT_ROOT.'/holiday/class/holiday.class.php'; -} - -// Load translation files required by the page -$langs->loadLangs(array('user', 'other', 'holiday')); - -if (empty($conf->holiday->enabled)) -{ - llxHeader('', $langs->trans('CPTitreMenu')); - print '
'; - print ''.$langs->trans('NotActiveModCP').''; - print '
'; - llxFooter(); - exit(); -} diff --git a/htdocs/holiday/define_holiday.php b/htdocs/holiday/define_holiday.php index 585c80e3e6d..45442e6170d 100644 --- a/htdocs/holiday/define_holiday.php +++ b/htdocs/holiday/define_holiday.php @@ -28,10 +28,10 @@ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; -require_once DOL_DOCUMENT_ROOT.'/holiday/common.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/holiday/class/holiday.class.php'; // Load translation files required by the page -$langs->loadlangs(array('users', 'hrm')); +$langs->loadlangs(array('users', 'other', 'holiday', 'hrm')); $action = GETPOST('action', 'aZ09'); $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'defineholidaylist'; @@ -56,7 +56,7 @@ if (!$sortorder) $sortorder = "ASC"; if ($user->socid > 0) accessforbidden(); // If the user does not have perm to read the page -if (!$user->rights->holiday->read) accessforbidden(); +if (empty($user->rights->holiday->read)) accessforbidden(); // Initialize technical object to manage hooks. Note that conf->hooks_modules contains array @@ -65,6 +65,17 @@ $extrafields = new ExtraFields($db); $holiday = new Holiday($db); +if (empty($conf->holiday->enabled)) +{ + llxHeader('', $langs->trans('CPTitreMenu')); + print '
'; + print ''.$langs->trans('NotActiveModCP').''; + print '
'; + llxFooter(); + exit(); +} + + /* * Actions diff --git a/htdocs/holiday/list.php b/htdocs/holiday/list.php index bfdef939be3..41ae8a6956f 100644 --- a/htdocs/holiday/list.php +++ b/htdocs/holiday/list.php @@ -32,12 +32,12 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; require_once DOL_DOCUMENT_ROOT.'/user/class/usergroup.class.php'; -require_once DOL_DOCUMENT_ROOT.'/holiday/common.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/holiday/class/holiday.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/usergroups.lib.php'; // Load translation files required by the page -$langs->loadLangs(array('users', 'holiday', 'hrm')); +$langs->loadLangs(array('users', 'other', 'holiday', 'hrm')); // Protection if external user if ($user->socid > 0) accessforbidden(); @@ -152,6 +152,15 @@ if (is_array($extrafields->attributes[$object->table_element]['label']) && count } } +if (empty($conf->holiday->enabled)) +{ + llxHeader('', $langs->trans('CPTitreMenu')); + print '
'; + print ''.$langs->trans('NotActiveModCP').''; + print '
'; + llxFooter(); + exit(); +} /* diff --git a/htdocs/holiday/month_report.php b/htdocs/holiday/month_report.php index 5108c97f54a..b83d957b27f 100644 --- a/htdocs/holiday/month_report.php +++ b/htdocs/holiday/month_report.php @@ -179,8 +179,8 @@ print load_fiche_titre($langs->trans('MenuReportMonth'), '', 'title_hrm'); // Selection filter print '
'; -print $formother->select_month($search_month, 'remonth'); -print $formother->select_year($search_year, 'reyear'); +print $formother->select_month($search_month, 'remonth', 0, 0, 'minwidth50 maxwidth75imp valignmiddle', true); +print $formother->selectyear($search_year, 'reyear', 0, 10, 5, 0, 0, '', 'valignmiddle width75', true); print ''; print '
'; print '
'; diff --git a/htdocs/holiday/view_log.php b/htdocs/holiday/view_log.php index 54049a201ea..2f2e223c87c 100644 --- a/htdocs/holiday/view_log.php +++ b/htdocs/holiday/view_log.php @@ -34,7 +34,7 @@ if (empty($user->rights->holiday->define_holiday) || $user->socid > 0) { require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; -require_once DOL_DOCUMENT_ROOT.'/holiday/common.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/holiday/class/holiday.class.php'; $action = GETPOST('action', 'aZ09') ?GETPOST('action', 'aZ09') : 'view'; // The action 'add', 'create', 'edit', 'update', 'view', ... $massaction = GETPOST('massaction', 'alpha'); // The bulk action (combo box choice into lists) @@ -72,7 +72,7 @@ if (!$sortorder) $sortorder = "DESC"; if (!$user->rights->holiday->readall) accessforbidden(); // Load translation files required by the page -$langs->load('users'); +$langs->loadLangs(array('users', 'other', 'holiday')); // Initialize technical objects $object = new Holiday($db); @@ -83,6 +83,16 @@ $hookmanager->initHooks(array('leavemovementlist')); // Note that conf->hooks_mo $arrayfields = array(); $arrayofmassactions = array(); +if (empty($conf->holiday->enabled)) +{ + llxHeader('', $langs->trans('CPTitreMenu')); + print '
'; + print ''.$langs->trans('NotActiveModCP').''; + print '
'; + llxFooter(); + exit(); +} + /* * Actions @@ -263,9 +273,9 @@ if (!empty($arrayfields['cpl.rowid']['checked'])) { // Filter: Date if (!empty($arrayfields['cpl.date_action']['checked'])) { - print ''; + print ''; print ''; - print $formother->selectyear($search_year, 'search_year', 1, 10, 5, 0, 0, '', 'maxwidth200', true); + print $formother->selectyear($search_year, 'search_year', 1, 10, 5, 0, 0, '', 'valignmiddle width75', true); print ''; } diff --git a/test/phpunit/phpunittest.xml b/test/phpunit/phpunittest.xml index d648edb6814..7e903daa16d 100644 --- a/test/phpunit/phpunittest.xml +++ b/test/phpunit/phpunittest.xml @@ -17,20 +17,6 @@ - - ../../build/ - ../../dev/ - ../../doc/ - ../../test/ - ../../documents/ - ../../htdocs/custom/ - ../../htdocs/documents/custom/ - ../../htdocs/nltechno/ - ../../htdocs/products/canvas/ - ../../htdocs/contact/canvas/ - ../../htdocs/societe/canvas/ - ../../htdocs/includes/ - ../../htdocs/ ../../htdocs/ @@ -54,8 +40,21 @@ ../../htdocs/contact/canvas/ ../../htdocs/societe/canvas/ ../../htdocs/includes/ - ../../htdocs/holiday/common.inc.php + + ../../build/ + ../../dev/ + ../../doc/ + ../../test/ + ../../documents/ + ../../htdocs/custom/ + ../../htdocs/documents/custom/ + ../../htdocs/nltechno/ + ../../htdocs/products/canvas/ + ../../htdocs/contact/canvas/ + ../../htdocs/societe/canvas/ + ../../htdocs/includes/ + From e7306625f0425648f7ee5aca0815f0c8fa6e9dbb Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 4 Dec 2020 15:28:12 +0100 Subject: [PATCH 027/147] Fix look and feel v13 --- htdocs/admin/dict.php | 2 +- htdocs/holiday/card.php | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php index 3048625cd5f..d06f8a2ce31 100644 --- a/htdocs/admin/dict.php +++ b/htdocs/admin/dict.php @@ -682,7 +682,7 @@ if (GETPOST('actionadd') || GETPOST('actionmodify')) { // Discard check of mandatory fields for country for some tables if ($value == 'country_id' && in_array($tablib[$id], array('DictionaryPublicHolidays', 'DictionaryVAT', 'DictionaryRegion', 'DictionaryCompanyType', 'DictionaryHolidayTypes', 'DictionaryRevenueStamp', 'DictionaryAccountancysystem', 'DictionaryAccountancyCategory'))) continue; // For some pages, country is not mandatory - if ($value == 'country' && in_array($tablib[$id], array('DictionaryPublicHolidays', 'DictionaryCanton', 'DictionaryCompanyType', 'DictionaryRevenueStamp'))) continue; // For some pages, country is not mandatory + if ($value == 'country' && in_array($tablib[$id], array('DictionaryPublicHolidays', 'DictionaryCanton', 'DictionaryCompanyType', 'DictionaryHolidayTypes', 'DictionaryRevenueStamp'))) continue; // For some pages, country is not mandatory // Discard check of mandatory fiedls for other fields if ($value == 'localtax1' && empty($_POST['localtax1_type'])) continue; if ($value == 'localtax2' && empty($_POST['localtax2_type'])) continue; diff --git a/htdocs/holiday/card.php b/htdocs/holiday/card.php index 4adecb20235..e0685789799 100644 --- a/htdocs/holiday/card.php +++ b/htdocs/holiday/card.php @@ -999,10 +999,10 @@ if ((empty($id) && empty($ref)) || $action == 'create' || $action == 'add') if (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || empty($user->rights->holiday->writeall_advance)) { - print $form->select_dolusers(($fuserid ? $fuserid : $user->id), 'fuserid', 0, '', 0, 'hierarchyme', '', '0,'.$conf->entity, 0, 0, $morefilter, 0, '', 'maxwidth300'); + print img_picto('', 'user').$form->select_dolusers(($fuserid ? $fuserid : $user->id), 'fuserid', 0, '', 0, 'hierarchyme', '', '0,'.$conf->entity, 0, 0, $morefilter, 0, '', 'maxwidth500'); //print ''; } else { - print $form->select_dolusers(GETPOST('fuserid', 'int') ? GETPOST('fuserid', 'int') : $user->id, 'fuserid', 0, '', 0, '', '', '0,'.$conf->entity, 0, 0, $morefilter, 0, '', 'maxwidth300'); + print img_picto('', 'user').$form->select_dolusers(GETPOST('fuserid', 'int') ? GETPOST('fuserid', 'int') : $user->id, 'fuserid', 0, '', 0, '', '', '0,'.$conf->entity, 0, 0, $morefilter, 0, '', 'maxwidth500'); } print ''; print ''; @@ -1019,7 +1019,7 @@ if ((empty($id) && empty($ref)) || $action == 'create' || $action == 'add') $labeltoshow .= ($val['delay'] > 0 ? ' ('.$langs->trans("NoticePeriod").': '.$val['delay'].' '.$langs->trans("days").')' : ''); $arraytypeleaves[$val['rowid']] = $labeltoshow; } - print $form->selectarray('type', $arraytypeleaves, (GETPOST('type', 'alpha') ?GETPOST('type', 'alpha') : ''), 1); + print $form->selectarray('type', $arraytypeleaves, (GETPOST('type', 'alpha') ?GETPOST('type', 'alpha') : ''), 1, 0, 0, '', 0, 0, 0, '', '', true); if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); print ''; print ''; @@ -1048,7 +1048,6 @@ if ((empty($id) && empty($ref)) || $action == 'create' || $action == 'add') print $form->textwithpicto($langs->trans("DateFinCP"), $langs->trans("LastDayOfHoliday")); print ''; print ''; - // Si la demande ne vient pas de l'agenda if (!GETPOST('date_fin_')) { print $form->selectDate(-1, 'date_fin_', 0, 0, 0, '', 1, 1); } else { @@ -1067,13 +1066,14 @@ if ((empty($id) && empty($ref)) || $action == 'create' || $action == 'add') $object = new Holiday($db); $include_users = $object->fetch_users_approver_holiday(); - if (empty($include_users)) print img_warning().' '.$langs->trans("NobodyHasPermissionToValidateHolidays"); - else { + if (empty($include_users)) { + print img_warning().' '.$langs->trans("NobodyHasPermissionToValidateHolidays"); + } else { $defaultselectuser = (empty($user->fk_user_holiday_validator) ? $user->fk_user : $user->fk_user_holiday_validator); // Will work only if supervisor has permission to approve so is inside include_users if (!empty($conf->global->HOLIDAY_DEFAULT_VALIDATOR)) $defaultselectuser = $conf->global->HOLIDAY_DEFAULT_VALIDATOR; // Can force default approver if (GETPOST('valideur', 'int') > 0) $defaultselectuser = GETPOST('valideur', 'int'); - $s = $form->select_dolusers($defaultselectuser, "valideur", 1, "", 0, $include_users); - print $form->textwithpicto($s, $langs->trans("AnyOtherInThisListCanValidate")); + $s = $form->select_dolusers($defaultselectuser, "valideur", 1, '', 0, $include_users, '', '0,'.$conf->entity, 0, 0, '', 0, '', 'maxwidth500'); + print img_picto('', 'user').$form->textwithpicto($s, $langs->trans("AnyOtherInThisListCanValidate")); } //print $form->select_dolusers((GETPOST('valideur','int')>0?GETPOST('valideur','int'):$user->fk_user), "valideur", 1, ($user->admin ? '' : array($user->id)), 0, '', 0, 0, 0, 0, '', 0, '', '', 1); // By default, hierarchical parent From d7f56b42cfeca58d036dceee8eb1310cc28b6dee Mon Sep 17 00:00:00 2001 From: lmarcouiller Date: Fri, 4 Dec 2020 15:29:57 +0100 Subject: [PATCH 028/147] Fix #15646 : patch of this bug --- htdocs/projet/tasks/time.php | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/projet/tasks/time.php b/htdocs/projet/tasks/time.php index e076bee598d..c18ec6e4434 100644 --- a/htdocs/projet/tasks/time.php +++ b/htdocs/projet/tasks/time.php @@ -897,7 +897,6 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0) if ($id) $param .= '&id='.urlencode($id); if ($projectid) $param .= '&projectid='.urlencode($projectid); if ($withproject) $param .= '&withproject='.urlencode($withproject); - if ($page) $param .= '&page='.urlencode($page); print '
'; if ($optioncss != '') print ''; From 2e5ac9b40af78e97aa79a61faa7cd9723c65f06f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 4 Dec 2020 15:36:14 +0100 Subject: [PATCH 029/147] CSS --- htdocs/holiday/card.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/holiday/card.php b/htdocs/holiday/card.php index e0685789799..11d3c70c4a8 100644 --- a/htdocs/holiday/card.php +++ b/htdocs/holiday/card.php @@ -999,10 +999,10 @@ if ((empty($id) && empty($ref)) || $action == 'create' || $action == 'add') if (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || empty($user->rights->holiday->writeall_advance)) { - print img_picto('', 'user').$form->select_dolusers(($fuserid ? $fuserid : $user->id), 'fuserid', 0, '', 0, 'hierarchyme', '', '0,'.$conf->entity, 0, 0, $morefilter, 0, '', 'maxwidth500'); + print img_picto('', 'user').$form->select_dolusers(($fuserid ? $fuserid : $user->id), 'fuserid', 0, '', 0, 'hierarchyme', '', '0,'.$conf->entity, 0, 0, $morefilter, 0, '', 'minwidth200 maxwidth500'); //print ''; } else { - print img_picto('', 'user').$form->select_dolusers(GETPOST('fuserid', 'int') ? GETPOST('fuserid', 'int') : $user->id, 'fuserid', 0, '', 0, '', '', '0,'.$conf->entity, 0, 0, $morefilter, 0, '', 'maxwidth500'); + print img_picto('', 'user').$form->select_dolusers(GETPOST('fuserid', 'int') ? GETPOST('fuserid', 'int') : $user->id, 'fuserid', 0, '', 0, '', '', '0,'.$conf->entity, 0, 0, $morefilter, 0, '', 'minwidth200 maxwidth500'); } print ''; print ''; @@ -1072,7 +1072,7 @@ if ((empty($id) && empty($ref)) || $action == 'create' || $action == 'add') $defaultselectuser = (empty($user->fk_user_holiday_validator) ? $user->fk_user : $user->fk_user_holiday_validator); // Will work only if supervisor has permission to approve so is inside include_users if (!empty($conf->global->HOLIDAY_DEFAULT_VALIDATOR)) $defaultselectuser = $conf->global->HOLIDAY_DEFAULT_VALIDATOR; // Can force default approver if (GETPOST('valideur', 'int') > 0) $defaultselectuser = GETPOST('valideur', 'int'); - $s = $form->select_dolusers($defaultselectuser, "valideur", 1, '', 0, $include_users, '', '0,'.$conf->entity, 0, 0, '', 0, '', 'maxwidth500'); + $s = $form->select_dolusers($defaultselectuser, "valideur", 1, '', 0, $include_users, '', '0,'.$conf->entity, 0, 0, '', 0, '', 'minwidth200 maxwidth500'); print img_picto('', 'user').$form->textwithpicto($s, $langs->trans("AnyOtherInThisListCanValidate")); } From b9461322d9cc10370c56f7e120725d60a30d8bbc Mon Sep 17 00:00:00 2001 From: atm-benoit Date: Fri, 4 Dec 2020 15:37:00 +0100 Subject: [PATCH 030/147] FIX SUPPLIER PROPOSAL v12 bug add --- htdocs/supplier_proposal/card.php | 66 +++++++++++++++---------------- 1 file changed, 33 insertions(+), 33 deletions(-) diff --git a/htdocs/supplier_proposal/card.php b/htdocs/supplier_proposal/card.php index 08479b95871..529c446df4d 100644 --- a/htdocs/supplier_proposal/card.php +++ b/htdocs/supplier_proposal/card.php @@ -554,8 +554,8 @@ if (empty($reshook)) } else { - $idprod = GETPOST('idprod', 'int'); - $price_ht = ''; + $idprod = GETPOST('idprod', 'int'); + $price_ht = GETPOST('price_ht'); $tva_tx = ''; } @@ -589,8 +589,8 @@ if (empty($reshook)) $error++; } if (!$error && ($qty >= 0)) { - $pu_ht = 0; - $pu_ttc = 0; + $pu_ht = price2num($price_ht, 'MU'); + $pu_ttc = price2num(GETPOST('price_ttc'), 'MU'); $price_min = 0; $price_base_type = (GETPOST('price_base_type', 'alpha') ? GETPOST('price_base_type', 'alpha') : 'HT'); @@ -658,41 +658,41 @@ if (empty($reshook)) $localtax1_tx = get_localtax($tva_tx, 1, $mysoc, $object->thirdparty, $tva_npr); $localtax2_tx = get_localtax($tva_tx, 2, $mysoc, $object->thirdparty, $tva_npr); - $pu_ht = $productsupplier->fourn_pu; if (empty($pu_ht)) $pu_ht = 0; // If pu is '' or null, we force to have a numeric value // If GETPOST('idprodfournprice') is a numeric, we can use it. If it is empty or if it is 'idprod_123', we should use -1 (not used) $fournprice = (is_numeric(GETPOST('idprodfournprice', 'alpha')) ? GETPOST('idprodfournprice', 'alpha') : -1); $buyingprice = 0; - + $pu_ht_devise = price2num($price_ht_devise, 'MU'); + $result = $object->addline( - $desc, - $pu_ht, - $qty, - $tva_tx, - $localtax1_tx, - $localtax2_tx, - $productsupplier->id, - $remise_percent, - $price_base_type, - $pu_ttc, - $tva_npr, - $type, - -1, - 0, - GETPOST('fk_parent_line'), - $fournprice, - $buyingprice, - $label, - $array_options, - $ref_supplier, - $productsupplier->fk_unit, - '', - 0, - $productsupplier->fourn_multicurrency_unitprice, - $date_start, - $date_end - ); + $desc, + $pu_ht, + $qty, + $tva_tx, + $localtax1_tx, + $localtax2_tx, + $productsupplier->id, + $remise_percent, + $price_base_type, + $pu_ttc, + $tva_npr, + $type, + -1, + 0, + GETPOST('fk_parent_line'), + $fournprice, + $buyingprice, + $label, + $array_options, + $ref_supplier, + $productsupplier->fk_unit, + '', + 0, + $pu_ht_devise, + $date_start, + $date_end + ); //var_dump($tva_tx);var_dump($productsupplier->fourn_pu);var_dump($price_base_type);exit; if ($result < 0) From f0dec80dae23e3b6537777d79b5e30e0c57800ff Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 4 Dec 2020 15:39:30 +0100 Subject: [PATCH 031/147] css --- htdocs/core/class/html.form.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 00bfd60e4ad..44fee06446f 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -1728,7 +1728,7 @@ class Form $out .= ajax_combobox($htmlname); // do not use maxwidthonsmartphone by default. Set it by caller so auto size to 100% will work when not defined - $out .= ''; if ($show_empty && !$multiple) $out .= ''."\n"; if ($show_every) $out .= ''."\n"; From ddf82f3e7a69d75cc414279eeed0250e560d525c Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Fri, 4 Dec 2020 14:45:26 +0000 Subject: [PATCH 032/147] Fixing style errors. --- htdocs/supplier_proposal/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/supplier_proposal/card.php b/htdocs/supplier_proposal/card.php index 529c446df4d..708844b71c8 100644 --- a/htdocs/supplier_proposal/card.php +++ b/htdocs/supplier_proposal/card.php @@ -664,7 +664,7 @@ if (empty($reshook)) $fournprice = (is_numeric(GETPOST('idprodfournprice', 'alpha')) ? GETPOST('idprodfournprice', 'alpha') : -1); $buyingprice = 0; $pu_ht_devise = price2num($price_ht_devise, 'MU'); - + $result = $object->addline( $desc, $pu_ht, From d22646e6ae8df3f811d2b85b291940c662bd9ad5 Mon Sep 17 00:00:00 2001 From: atm-lena Date: Fri, 4 Dec 2020 16:06:10 +0100 Subject: [PATCH 033/147] pricetonum() - preg-replace() delete "-" negativ number --- htdocs/core/lib/functions.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 2a9052d0916..5094fad392a 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -4724,7 +4724,7 @@ function price2num($amount, $rounding = '', $option = 0) if ($option != 1) { // If not a PHP number or unknown, we change or clean format //print 'PP'.$amount.' - '.$dec.' - '.$thousand.' - '.intval($amount).'
'; if (!is_numeric($amount)) { - $amount = preg_replace('/[a-zA-Z\/\\\*\(\)\<\>\-]/', '', $amount); + $amount = preg_replace('/[a-zA-Z\/\\\*\(\)\<\>]/', '', $amount); } if ($option == 2 && $thousand == '.' && preg_match('/\.(\d\d\d)$/', (string) $amount)) { // It means the . is used as a thousand separator and string come frominput data, so 1.123 is 1123 From 223205cf9db90f85a2763aebb7fc8697e9c960ce Mon Sep 17 00:00:00 2001 From: Francis Appels Date: Fri, 4 Dec 2020 16:54:40 +0100 Subject: [PATCH 034/147] Fix volume calcution, depends on surface not surface_units surface_unit can be 0 for m2 --- htdocs/product/class/product.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 0e9841201de..7d1d326cabb 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -854,7 +854,7 @@ class Product extends CommonObject $this->surface = $this->length * $this->width; $this->surface_units = measuring_units_squared($this->length_units); } - if (empty($this->volume) && !empty($this->surface_units) && !empty($this->height) && $this->length_units == $this->height_units) { + if (empty($this->volume) && !empty($this->surface) && !empty($this->height) && $this->length_units == $this->height_units) { $this->volume = $this->surface * $this->height; $this->volume_units = measuring_units_cubed($this->height_units); } From b0e40aa21548d91848f6ab6423f250d37e992b95 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Fri, 4 Dec 2020 18:00:31 +0100 Subject: [PATCH 035/147] fix type_user not define in left menu --- htdocs/core/menus/standard/eldy.lib.php | 666 +++++++++++------------ htdocs/core/menus/standard/eldy_menu.php | 166 +++--- htdocs/core/menus/standard/empty.php | 221 ++++---- 3 files changed, 511 insertions(+), 542 deletions(-) diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index 625e1ef00b3..fdf95e37aa1 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -54,13 +54,14 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout = $substitarray = getCommonSubstitutionArray($langs, 0, null, null); - if (empty($noout)) print_start_menu_array(); + if (empty($noout)) { + print_start_menu_array(); + } $usemenuhider = 1; // Show/Hide vertical menu. The hamburger icon for .menuhider action. - if ($mode != 'jmobile' && $mode != 'topnb' && $usemenuhider && empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) - { + if ($mode != 'jmobile' && $mode != 'topnb' && $usemenuhider && empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { $showmode = 1; $classname = 'class="tmenu menuhider"'; $idsel = 'menu'; @@ -412,29 +413,23 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout = ); // Add menus - foreach ($menu_arr as $key => $smenu) - { + foreach ($menu_arr as $key => $smenu) { $smenu = (object) $smenu; - if ($smenu->enabled) - { - if ($smenu->session) - { + if ($smenu->enabled) { + if ($smenu->session) { $_SESSION['idmenu'] = ''; } // Load Langue - if (!empty($smenu->loadLangs)) - { + if (!empty($smenu->loadLangs)) { $langs->loadLangs($smenu->loadLangs); } // Trans title $mtitle = ''; - if (is_array($smenu->title)) - { - foreach ($smenu->title as $item) - { + if (is_array($smenu->title)) { + foreach ($smenu->title as $item) { $mtitle .= $langs->trans($item); } } else { @@ -451,8 +446,7 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout = $newTabMenu = $menuArbo->menuTopCharger('', '', $type_user, 'eldy', $tabMenu); // Return tabMenu with only top entries $num = count($newTabMenu); - for ($i = 0; $i < $num; $i++) - { + for ($i = 0; $i < $num; $i++) { //var_dump($type_user.' '.$newTabMenu[$i]['url'].' '.$showmode.' '.$newTabMenu[$i]['perms']); $idsel = (empty($newTabMenu[$i]['mainmenu']) ? 'none' : $newTabMenu[$i]['mainmenu']); @@ -460,35 +454,50 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout = // url = url from host, shorturl = relative path into dolibarr sources $url = $shorturl = $newTabMenu[$i]['url']; - if (!preg_match("/^(http:\/\/|https:\/\/)/i", $newTabMenu[$i]['url'])) // Do not change url content for external links - { + if (!preg_match("/^(http:\/\/|https:\/\/)/i", $newTabMenu[$i]['url'])) { // Do not change url content for external links $tmp = explode('?', $newTabMenu[$i]['url'], 2); $url = $shorturl = $tmp[0]; $param = (isset($tmp[1]) ? $tmp[1] : ''); - if (!preg_match('/mainmenu/i', $param) || !preg_match('/leftmenu/i', $param)) $param .= ($param ? '&' : '').'mainmenu='.$newTabMenu[$i]['mainmenu'].'&leftmenu='; + if (!preg_match('/mainmenu/i', $param) || !preg_match('/leftmenu/i', $param)) { + $param .= ($param ? '&' : '').'mainmenu='.$newTabMenu[$i]['mainmenu'].'&leftmenu='; + } //$url.="idmenu=".$newTabMenu[$i]['rowid']; // Already done by menuLoad $url = dol_buildpath($url, 1).($param ? '?'.$param : ''); //$shorturl = $shorturl.($param?'?'.$param:''); $shorturl = $url; - if (DOL_URL_ROOT) $shorturl = preg_replace('/^'.preg_quote(DOL_URL_ROOT, '/').'/', '', $shorturl); + if (DOL_URL_ROOT) { + $shorturl = preg_replace('/^'.preg_quote(DOL_URL_ROOT, '/').'/', '', $shorturl); + } } $showmode = isVisibleToUserType($type_user, $newTabMenu[$i], $listofmodulesforexternal); - if ($showmode == 1) - { + if ($showmode == 1) { // Define the class (top menu selected or not) - if (!empty($_SESSION['idmenu']) && $newTabMenu[$i]['rowid'] == $_SESSION['idmenu']) $classname = 'class="tmenusel"'; - elseif (!empty($_SESSION["mainmenu"]) && $newTabMenu[$i]['mainmenu'] == $_SESSION["mainmenu"]) $classname = 'class="tmenusel"'; - else $classname = 'class="tmenu"'; + if (!empty($_SESSION['idmenu']) && $newTabMenu[$i]['rowid'] == $_SESSION['idmenu']) { + $classname = 'class="tmenusel"'; + } elseif (!empty($_SESSION["mainmenu"]) && $newTabMenu[$i]['mainmenu'] == $_SESSION["mainmenu"]) { + $classname = 'class="tmenusel"'; + } else { + $classname = 'class="tmenu"'; + } } elseif ($showmode == 2) { $classname = 'class="tmenu"'; } - $menu->add($shorturl, $newTabMenu[$i]['titre'], 0, $showmode, ($newTabMenu[$i]['target'] ? $newTabMenu[$i]['target'] : $atarget), + $menu->add( + $shorturl, + $newTabMenu[$i]['titre'], + 0, + $showmode, + ($newTabMenu[$i]['target'] ? $newTabMenu[$i]['target'] : $atarget), ($newTabMenu[$i]['mainmenu'] ? $newTabMenu[$i]['mainmenu'] : $newTabMenu[$i]['rowid']), ($newTabMenu[$i]['leftmenu'] ? $newTabMenu[$i]['leftmenu'] : ''), - $newTabMenu[$i]['position'], $id, $idsel, $classname); + $newTabMenu[$i]['position'], + $id, + $idsel, + $classname + ); } // Sort on position @@ -496,8 +505,7 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout = // Output menu entries // Show logo company - if (empty($conf->global->MAIN_MENU_INVERT) && empty($noout) && !empty($conf->global->MAIN_SHOW_LOGO) && empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) - { + if (empty($conf->global->MAIN_MENU_INVERT) && empty($noout) && !empty($conf->global->MAIN_SHOW_LOGO) && empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { //$mysoc->logo_mini=(empty($conf->global->MAIN_INFO_SOCIETE_LOGO_MINI)?'':$conf->global->MAIN_INFO_SOCIETE_LOGO_MINI); $mysoc->logo_squarred_mini = (empty($conf->global->MAIN_INFO_SOCIETE_LOGO_SQUARRED_MINI) ? '' : $conf->global->MAIN_INFO_SOCIETE_LOGO_SQUARRED_MINI); @@ -506,8 +514,7 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout = $logoContainerAdditionalClass = ''; } - if (!empty($mysoc->logo_squarred_mini) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_squarred_mini)) - { + if (!empty($mysoc->logo_squarred_mini) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_squarred_mini)) { $urllogo = DOL_URL_ROOT.'/viewimage.php?cache=1&modulepart=mycompany&file='.urlencode('logos/thumbs/'.$mysoc->logo_squarred_mini); } /*elseif (! empty($mysoc->logo_mini) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_mini)) @@ -570,8 +577,7 @@ function print_start_menu_array() */ function print_start_menu_entry($idsel, $classname, $showmode) { - if ($showmode) - { + if ($showmode) { print ''; } print "\n"; @@ -655,9 +660,10 @@ function print_end_menu_array() * @param string $forcemainmenu 'x'=Force mainmenu to mainmenu='x' * @param string $forceleftmenu 'all'=Force leftmenu to '' (= all). If value come being '', we change it to value in session and 'none' if not defined in session. * @param array $moredata An array with more data to output + * @param int $type_user 0=Menu for backoffice, 1=Menu for front office * @return int Nb of menu entries */ -function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabMenu, &$menu, $noout = 0, $forcemainmenu = '', $forceleftmenu = '', $moredata = null) +function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabMenu, &$menu, $noout = 0, $forcemainmenu = '', $forceleftmenu = '', $moredata = null, $type_user = 0) { global $user, $conf, $langs, $dolibarr_main_db_name, $mysoc; @@ -670,8 +676,7 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM $usemenuhider = 0; - if (is_array($moredata) && !empty($moredata['searchform'])) // searchform can contains select2 code or link to show old search form or link to switch on search page - { + if (is_array($moredata) && !empty($moredata['searchform'])) { // searchform can contains select2 code or link to show old search form or link to switch on search page print "\n"; print "\n"; print '
'."\n"; @@ -680,8 +685,7 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM print "\n"; } - if (is_array($moredata) && !empty($moredata['bookmarks'])) - { + if (is_array($moredata) && !empty($moredata['bookmarks'])) { print "\n"; print "\n"; print '
'."\n"; @@ -696,13 +700,11 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM * We update newmenu with entries found into database * -------------------------------------------------- */ - if ($mainmenu) // If this is empty, loading hard coded menu and loading personalised menu will fail - { - /* + if ($mainmenu) { // If this is empty, loading hard coded menu and loading personalised menu will fail + /* * Menu HOME */ - if ($mainmenu == 'home') - { + if ($mainmenu == 'home') { $langs->load("users"); // Home - dashboard @@ -711,22 +713,19 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM // Setup $newmenu->add("/admin/index.php?mainmenu=home&leftmenu=setup", $langs->trans("Setup"), 0, $user->admin, '', $mainmenu, 'setup', 0, '', '', '', ''); - if ($usemenuhider || empty($leftmenu) || $leftmenu == "setup") - { + if ($usemenuhider || empty($leftmenu) || $leftmenu == "setup") { // Load translation files required by the page $langs->loadLangs(array("admin", "help")); $warnpicto = ''; - if (empty($conf->global->MAIN_INFO_SOCIETE_NOM) || empty($conf->global->MAIN_INFO_SOCIETE_COUNTRY)) - { + if (empty($conf->global->MAIN_INFO_SOCIETE_NOM) || empty($conf->global->MAIN_INFO_SOCIETE_COUNTRY)) { $langs->load("errors"); $warnpicto = img_warning($langs->trans("WarningMandatorySetupNotComplete")); } $newmenu->add("/admin/company.php?mainmenu=home", $langs->trans("MenuCompanySetup").$warnpicto, 1); $warnpicto = ''; - if (count($conf->modules) <= (empty($conf->global->MAIN_MIN_NB_ENABLED_MODULE_FOR_WARNING) ? 1 : $conf->global->MAIN_MIN_NB_ENABLED_MODULE_FOR_WARNING)) // If only user module enabled - { + if (count($conf->modules) <= (empty($conf->global->MAIN_MIN_NB_ENABLED_MODULE_FOR_WARNING) ? 1 : $conf->global->MAIN_MIN_NB_ENABLED_MODULE_FOR_WARNING)) { // If only user module enabled $langs->load("errors"); $warnpicto = img_warning($langs->trans("WarningMandatorySetupNotComplete")); } @@ -760,8 +759,7 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM // System tools $newmenu->add("/admin/tools/index.php?mainmenu=home&leftmenu=admintools", $langs->trans("AdminTools"), 0, $user->admin, '', $mainmenu, 'admintools', 0, '', '', '', ''); - if ($usemenuhider || empty($leftmenu) || preg_match('/^admintools/', $leftmenu)) - { + if ($usemenuhider || empty($leftmenu) || preg_match('/^admintools/', $leftmenu)) { // Load translation files required by the page $langs->loadLangs(array('admin', 'help')); @@ -788,24 +786,20 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM $newmenu->add("/admin/tools/listsessions.php?mainmenu=home&leftmenu=admintools", $langs->trans("Sessions"), 1); $newmenu->add('/admin/system/about.php?mainmenu=home&leftmenu=admintools', $langs->trans('ExternalResources'), 1); - if (!empty($conf->product->enabled) || !empty($conf->service->enabled)) - { + if (!empty($conf->product->enabled) || !empty($conf->service->enabled)) { $langs->load("products"); $newmenu->add("/product/admin/product_tools.php?mainmenu=home&leftmenu=admintools", $langs->trans("ProductVatMassChange"), 1, $user->admin); } } $newmenu->add("/user/home.php?leftmenu=users", $langs->trans("MenuUsersAndGroups"), 0, $user->rights->user->user->lire, '', $mainmenu, 'users', 0, '', '', '', ''); - if ($user->rights->user->user->lire) - { - if ($usemenuhider || empty($leftmenu) || $leftmenu == "users") - { + if ($user->rights->user->user->lire) { + if ($usemenuhider || empty($leftmenu) || $leftmenu == "users") { $newmenu->add("", $langs->trans("Users"), 1, $user->rights->user->user->lire || $user->admin); $newmenu->add("/user/card.php?leftmenu=users&action=create", $langs->trans("NewUser"), 2, ($user->rights->user->user->creer || $user->admin) && !(!empty($conf->multicompany->enabled) && $conf->entity > 1 && $conf->global->MULTICOMPANY_TRANSVERSE_MODE), '', 'home'); $newmenu->add("/user/list.php?leftmenu=users", $langs->trans("ListOfUsers"), 2, $user->rights->user->user->lire || $user->admin); $newmenu->add("/user/hierarchy.php?leftmenu=users", $langs->trans("HierarchicView"), 2, $user->rights->user->user->lire || $user->admin); - if (!empty($conf->categorie->enabled)) - { + if (!empty($conf->categorie->enabled)) { $langs->load("categories"); $newmenu->add("/categories/index.php?leftmenu=users&type=7", $langs->trans("UsersCategoriesShort"), 2, $user->rights->categorie->lire, '', $mainmenu, 'cat'); } @@ -820,26 +814,24 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM /* * Menu THIRDPARTIES */ - if ($mainmenu == 'companies') - { + if ($mainmenu == 'companies') { // Societes - if (!empty($conf->societe->enabled)) - { + if (!empty($conf->societe->enabled)) { $langs->load("companies"); $newmenu->add("/societe/index.php?leftmenu=thirdparties", $langs->trans("ThirdParty"), 0, $user->rights->societe->lire, '', $mainmenu, 'thirdparties'); - if ($user->rights->societe->creer) - { + if ($user->rights->societe->creer) { $newmenu->add("/societe/card.php?action=create", $langs->trans("MenuNewThirdParty"), 1); - if (!$conf->use_javascript_ajax) $newmenu->add("/societe/card.php?action=create&private=1", $langs->trans("MenuNewPrivateIndividual"), 1); + if (!$conf->use_javascript_ajax) { + $newmenu->add("/societe/card.php?action=create&private=1", $langs->trans("MenuNewPrivateIndividual"), 1); + } } } $newmenu->add("/societe/list.php?leftmenu=thirdparties", $langs->trans("List"), 1); // Prospects - if (!empty($conf->societe->enabled) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS)) - { + if (!empty($conf->societe->enabled) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS)) { $langs->load("commercial"); $newmenu->add("/societe/list.php?type=p&leftmenu=prospects", $langs->trans("ListProspectsShort"), 2, $user->rights->societe->lire, '', $mainmenu, 'prospects'); /* no more required, there is a filter that can do more @@ -853,8 +845,7 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM } // Customers/Prospects - if (!empty($conf->societe->enabled) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) - { + if (!empty($conf->societe->enabled) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) { $langs->load("commercial"); $newmenu->add("/societe/list.php?type=c&leftmenu=customers", $langs->trans("ListCustomersShort"), 2, $user->rights->societe->lire, '', $mainmenu, 'customers'); @@ -862,28 +853,28 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM } // Suppliers - if (!empty($conf->societe->enabled) && ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)) || !empty($conf->supplier_proposal->enabled))) - { + if (!empty($conf->societe->enabled) && ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)) || !empty($conf->supplier_proposal->enabled))) { $langs->load("suppliers"); $newmenu->add("/societe/list.php?type=f&leftmenu=suppliers", $langs->trans("ListSuppliersShort"), 2, ($user->rights->fournisseur->lire), '', $mainmenu, 'suppliers'); $newmenu->add("/societe/card.php?leftmenu=suppliers&action=create&type=f", $langs->trans("MenuNewSupplier"), 3, $user->rights->societe->creer && ($user->rights->fournisseur->lire)); } // Categories - if (!empty($conf->categorie->enabled)) - { + if (!empty($conf->categorie->enabled)) { $langs->load("categories"); - if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS) || empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) - { + if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS) || empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) { // Categories prospects/customers $menutoshow = $langs->trans("CustomersProspectsCategoriesShort"); - if (!empty($conf->global->SOCIETE_DISABLE_PROSPECTS)) $menutoshow = $langs->trans("CustomersCategoriesShort"); - if (!empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) $menutoshow = $langs->trans("ProspectsCategoriesShort"); + if (!empty($conf->global->SOCIETE_DISABLE_PROSPECTS)) { + $menutoshow = $langs->trans("CustomersCategoriesShort"); + } + if (!empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) { + $menutoshow = $langs->trans("ProspectsCategoriesShort"); + } $newmenu->add("/categories/index.php?leftmenu=cat&type=2", $menutoshow, 1, $user->rights->categorie->lire, '', $mainmenu, 'cat'); } // Categories suppliers - if (!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)) - { + if (!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)) { $newmenu->add("/categories/index.php?leftmenu=catfournish&type=1", $langs->trans("SuppliersCategoriesShort"), 1, $user->rights->categorie->lire); } } @@ -892,15 +883,20 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM $newmenu->add("/societe/index.php?leftmenu=thirdparties", (!empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("Contacts") : $langs->trans("ContactsAddresses")), 0, $user->rights->societe->contact->lire, '', $mainmenu, 'contacts'); $newmenu->add("/contact/card.php?leftmenu=contacts&action=create", (!empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("NewContact") : $langs->trans("NewContactAddress")), 1, $user->rights->societe->contact->creer); $newmenu->add("/contact/list.php?leftmenu=contacts", $langs->trans("List"), 1, $user->rights->societe->contact->lire); - if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS)) $newmenu->add("/contact/list.php?leftmenu=contacts&type=p", $langs->trans("Prospects"), 2, $user->rights->societe->contact->lire); - if (empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) $newmenu->add("/contact/list.php?leftmenu=contacts&type=c", $langs->trans("Customers"), 2, $user->rights->societe->contact->lire); - if (!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)) $newmenu->add("/contact/list.php?leftmenu=contacts&type=f", $langs->trans("Suppliers"), 2, $user->rights->societe->contact->lire); + if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS)) { + $newmenu->add("/contact/list.php?leftmenu=contacts&type=p", $langs->trans("Prospects"), 2, $user->rights->societe->contact->lire); + } + if (empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) { + $newmenu->add("/contact/list.php?leftmenu=contacts&type=c", $langs->trans("Customers"), 2, $user->rights->societe->contact->lire); + } + if (!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)) { + $newmenu->add("/contact/list.php?leftmenu=contacts&type=f", $langs->trans("Suppliers"), 2, $user->rights->societe->contact->lire); + } $newmenu->add("/contact/list.php?leftmenu=contacts&type=o", $langs->trans("ContactOthers"), 2, $user->rights->societe->contact->lire); //$newmenu->add("/contact/list.php?userid=$user->id", $langs->trans("MyContacts"), 1, $user->rights->societe->contact->lire); // Categories - if (!empty($conf->categorie->enabled)) - { + if (!empty($conf->categorie->enabled)) { $langs->load("categories"); // Categories Contact $newmenu->add("/categories/index.php?leftmenu=catcontact&type=4", $langs->trans("ContactCategoriesShort"), 1, $user->rights->categorie->lire, '', $mainmenu, 'cat'); @@ -910,13 +906,11 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM /* * Menu COMMERCIAL (propal, commande, supplier_proposal, supplier_order, contrat, ficheinter) */ - if ($mainmenu == 'commercial') - { + if ($mainmenu == 'commercial') { $langs->load("companies"); // Customer proposal - if (!empty($conf->propal->enabled)) - { + if (!empty($conf->propal->enabled)) { $langs->load("propal"); $newmenu->add("/comm/propal/index.php?leftmenu=propals", $langs->trans("Proposals"), 0, $user->rights->propale->lire, '', $mainmenu, 'propals', 100); $newmenu->add("/comm/propal/card.php?action=create&leftmenu=propals", $langs->trans("NewPropal"), 1, $user->rights->propale->creer); @@ -933,8 +927,7 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM } // Customers orders - if (!empty($conf->commande->enabled)) - { + if (!empty($conf->commande->enabled)) { $langs->load("orders"); $newmenu->add("/commande/index.php?leftmenu=orders", $langs->trans("CustomersOrders"), 0, $user->rights->commande->lire, '', $mainmenu, 'orders', 200); $newmenu->add("/commande/card.php?action=create&leftmenu=orders", $langs->trans("NewOrder"), 1, $user->rights->commande->creer); @@ -942,7 +935,9 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM if ($usemenuhider || empty($leftmenu) || $leftmenu == "orders") { $newmenu->add("/commande/list.php?leftmenu=orders&search_status=0", $langs->trans("StatusOrderDraftShort"), 2, $user->rights->commande->lire); $newmenu->add("/commande/list.php?leftmenu=orders&search_status=1", $langs->trans("StatusOrderValidated"), 2, $user->rights->commande->lire); - if (!empty($conf->expedition->enabled)) $newmenu->add("/commande/list.php?leftmenu=orders&search_status=2", $langs->trans("StatusOrderSentShort"), 2, $user->rights->commande->lire); + if (!empty($conf->expedition->enabled)) { + $newmenu->add("/commande/list.php?leftmenu=orders&search_status=2", $langs->trans("StatusOrderSentShort"), 2, $user->rights->commande->lire); + } $newmenu->add("/commande/list.php?leftmenu=orders&search_status=3", $langs->trans("StatusOrderDelivered"), 2, $user->rights->commande->lire); //$newmenu->add("/commande/list.php?leftmenu=orders&search_status=4", $langs->trans("StatusOrderProcessed"), 2, $user->rights->commande->lire); $newmenu->add("/commande/list.php?leftmenu=orders&search_status=-1", $langs->trans("StatusOrderCanceledShort"), 2, $user->rights->commande->lire); @@ -951,8 +946,7 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM } // Supplier proposal - if (!empty($conf->supplier_proposal->enabled)) - { + if (!empty($conf->supplier_proposal->enabled)) { $langs->load("supplier_proposal"); $newmenu->add("/supplier_proposal/index.php?leftmenu=propals_supplier", $langs->trans("SupplierProposalsShort"), 0, $user->rights->supplier_proposal->lire, '', $mainmenu, 'propals_supplier', 300); $newmenu->add("/supplier_proposal/card.php?action=create&leftmenu=supplier_proposals", $langs->trans("SupplierProposalNew"), 1, $user->rights->supplier_proposal->creer); @@ -961,8 +955,7 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM } // Suppliers orders - if (!empty($conf->supplier_order->enabled)) - { + if (!empty($conf->supplier_order->enabled)) { $langs->load("orders"); $newmenu->add("/fourn/commande/index.php?leftmenu=orders_suppliers", $langs->trans("SuppliersOrders"), 0, $user->rights->fournisseur->commande->lire, '', $mainmenu, 'orders_suppliers', 400); $newmenu->add("/fourn/commande/card.php?action=create&leftmenu=orders_suppliers", $langs->trans("NewOrder"), 1, $user->rights->fournisseur->commande->creer); @@ -970,7 +963,9 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM if ($usemenuhider || empty($leftmenu) || $leftmenu == "orders_suppliers") { $newmenu->add("/fourn/commande/list.php?leftmenu=orders_suppliers&statut=0", $langs->trans("StatusSupplierOrderDraftShort"), 2, $user->rights->fournisseur->commande->lire); - if (empty($conf->global->SUPPLIER_ORDER_HIDE_VALIDATED)) $newmenu->add("/fourn/commande/list.php?leftmenu=orders_suppliers&statut=1", $langs->trans("StatusSupplierOrderValidated"), 2, $user->rights->fournisseur->commande->lire); + if (empty($conf->global->SUPPLIER_ORDER_HIDE_VALIDATED)) { + $newmenu->add("/fourn/commande/list.php?leftmenu=orders_suppliers&statut=1", $langs->trans("StatusSupplierOrderValidated"), 2, $user->rights->fournisseur->commande->lire); + } $newmenu->add("/fourn/commande/list.php?leftmenu=orders_suppliers&statut=2", $langs->trans("StatusSupplierOrderApprovedShort"), 2, $user->rights->fournisseur->commande->lire); $newmenu->add("/fourn/commande/list.php?leftmenu=orders_suppliers&statut=3", $langs->trans("StatusSupplierOrderOnProcessShort"), 2, $user->rights->fournisseur->commande->lire); $newmenu->add("/fourn/commande/list.php?leftmenu=orders_suppliers&statut=4", $langs->trans("StatusSupplierOrderReceivedPartiallyShort"), 2, $user->rights->fournisseur->commande->lire); @@ -985,8 +980,7 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM } // Contrat - if (!empty($conf->contrat->enabled)) - { + if (!empty($conf->contrat->enabled)) { $langs->load("contracts"); $newmenu->add("/contrat/index.php?leftmenu=contracts", $langs->trans("ContractsSubscriptions"), 0, $user->rights->contrat->lire, '', $mainmenu, 'contracts', 2000); $newmenu->add("/contrat/card.php?action=create&leftmenu=contracts", $langs->trans("NewContractSubscription"), 1, $user->rights->contrat->creer); @@ -1001,13 +995,14 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM } // Interventions - if (!empty($conf->ficheinter->enabled)) - { + if (!empty($conf->ficheinter->enabled)) { $langs->load("interventions"); $newmenu->add("/fichinter/index.php?leftmenu=ficheinter", $langs->trans("Interventions"), 0, $user->rights->ficheinter->lire, '', $mainmenu, 'ficheinter', 2200); $newmenu->add("/fichinter/card.php?action=create&leftmenu=ficheinter", $langs->trans("NewIntervention"), 1, $user->rights->ficheinter->creer, '', '', '', 201); $newmenu->add("/fichinter/list.php?leftmenu=ficheinter", $langs->trans("List"), 1, $user->rights->ficheinter->lire, '', '', '', 202); - if ($conf->global->MAIN_FEATURES_LEVEL >= 2) $newmenu->add("/fichinter/card-rec.php?leftmenu=ficheinter", $langs->trans("ListOfTemplates"), 1, $user->rights->ficheinter->lire, '', '', '', 203); + if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { + $newmenu->add("/fichinter/card-rec.php?leftmenu=ficheinter", $langs->trans("ListOfTemplates"), 1, $user->rights->ficheinter->lire, '', '', '', 203); + } $newmenu->add("/fichinter/stats/index.php?leftmenu=ficheinter", $langs->trans("Statistics"), 1, $user->rights->ficheinter->lire); } } @@ -1016,20 +1011,17 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM /* * Menu COMPTA-FINANCIAL */ - if ($mainmenu == 'billing') - { + if ($mainmenu == 'billing') { $langs->load("companies"); // Customers invoices - if (!empty($conf->facture->enabled)) - { + if (!empty($conf->facture->enabled)) { $langs->load("bills"); $newmenu->add("/compta/facture/index.php?leftmenu=customers_bills", $langs->trans("BillsCustomers"), 0, $user->rights->facture->lire, '', $mainmenu, 'customers_bills'); $newmenu->add("/compta/facture/card.php?action=create", $langs->trans("NewBill"), 1, $user->rights->facture->creer); $newmenu->add("/compta/facture/list.php?leftmenu=customers_bills", $langs->trans("List"), 1, $user->rights->facture->lire, '', $mainmenu, 'customers_bills_list'); - if ($usemenuhider || empty($leftmenu) || preg_match('/customers_bills(|_draft|_notpaid|_paid|_canceled)$/', $leftmenu)) - { + if ($usemenuhider || empty($leftmenu) || preg_match('/customers_bills(|_draft|_notpaid|_paid|_canceled)$/', $leftmenu)) { $newmenu->add("/compta/facture/list.php?leftmenu=customers_bills_draft&search_status=0", $langs->trans("BillShortStatusDraft"), 2, $user->rights->facture->lire); $newmenu->add("/compta/facture/list.php?leftmenu=customers_bills_notpaid&search_status=1", $langs->trans("BillShortStatusNotPaid"), 2, $user->rights->facture->lire); $newmenu->add("/compta/facture/list.php?leftmenu=customers_bills_paid&search_status=2", $langs->trans("BillShortStatusPaid"), 2, $user->rights->facture->lire); @@ -1039,8 +1031,7 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM $newmenu->add("/compta/paiement/list.php?leftmenu=customers_bills_payment", $langs->trans("Payments"), 1, $user->rights->facture->lire, '', $mainmenu, 'customers_bills_payment'); - if (!empty($conf->global->BILL_ADD_PAYMENT_VALIDATION)) - { + if (!empty($conf->global->BILL_ADD_PAYMENT_VALIDATION)) { $newmenu->add("/compta/paiement/tovalidate.php?leftmenu=customers_bills_tovalid", $langs->trans("MenuToValid"), 2, $user->rights->facture->lire, '', $mainmenu, 'customer_bills_tovalid'); } $newmenu->add("/compta/paiement/rapport.php?leftmenu=customers_bills_reports", $langs->trans("Reportings"), 2, $user->rights->facture->lire, '', $mainmenu, 'customers_bills_reports'); @@ -1049,8 +1040,7 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM } // Suppliers invoices - if (!empty($conf->societe->enabled) && !empty($conf->supplier_invoice->enabled)) - { + if (!empty($conf->societe->enabled) && !empty($conf->supplier_invoice->enabled)) { $langs->load("bills"); $newmenu->add("/fourn/facture/index.php?leftmenu=suppliers_bills", $langs->trans("BillsSuppliers"), 0, $user->rights->fournisseur->facture->lire, '', $mainmenu, 'suppliers_bills'); $newmenu->add("/fourn/facture/card.php?leftmenu=suppliers_bills&action=create", $langs->trans("NewBill"), 1, $user->rights->fournisseur->facture->creer, '', $mainmenu, 'suppliers_bills_create'); @@ -1070,18 +1060,17 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM } // Orders - if (!empty($conf->commande->enabled)) - { + if (!empty($conf->commande->enabled)) { $langs->load("orders"); - if (!empty($conf->facture->enabled)) $newmenu->add("/commande/list.php?leftmenu=orders&search_status=-3&billed=0&contextpage=billableorders", $langs->trans("MenuOrdersToBill2"), 0, $user->rights->commande->lire, '', $mainmenu, 'orders'); + if (!empty($conf->facture->enabled)) { + $newmenu->add("/commande/list.php?leftmenu=orders&search_status=-3&billed=0&contextpage=billableorders", $langs->trans("MenuOrdersToBill2"), 0, $user->rights->commande->lire, '', $mainmenu, 'orders'); + } //if ($usemenuhider || empty($leftmenu) || $leftmenu=="orders") $newmenu->add("/commande/", $langs->trans("StatusOrderToBill"), 1, $user->rights->commande->lire); } // Supplier Orders to bill - if (!empty($conf->supplier_invoice->enabled)) - { - if (!empty($conf->global->SUPPLIER_MENU_ORDER_RECEIVED_INTO_INVOICE)) - { + if (!empty($conf->supplier_invoice->enabled)) { + if (!empty($conf->global->SUPPLIER_MENU_ORDER_RECEIVED_INTO_INVOICE)) { $langs->load("supplier"); $newmenu->add("/fourn/commande/list.php?leftmenu=orders&search_status=5&billed=0", $langs->trans("MenuOrdersSupplierToBill"), 0, $user->rights->commande->lire, '', $mainmenu, 'orders'); //if ($usemenuhider || empty($leftmenu) || $leftmenu=="orders") $newmenu->add("/commande/", $langs->trans("StatusOrderToBill"), 1, $user->rights->commande->lire); @@ -1090,8 +1079,7 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM // Donations - if (!empty($conf->don->enabled)) - { + if (!empty($conf->don->enabled)) { $langs->load("donations"); $newmenu->add("/don/index.php?leftmenu=donations&mainmenu=billing", $langs->trans("Donations"), 0, $user->rights->don->lire, '', $mainmenu, 'donations'); if ($usemenuhider || empty($leftmenu) || $leftmenu == "donations") { @@ -1102,8 +1090,7 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM } // Taxes and social contributions - if (!empty($conf->tax->enabled)) - { + if (!empty($conf->tax->enabled)) { $newmenu->add("/compta/charges/index.php?leftmenu=tax&mainmenu=billing", $langs->trans("MenuTaxesAndSpecialExpenses"), 0, $user->rights->tax->charges->lire, '', $mainmenu, 'tax'); $newmenu->add("/compta/sociales/list.php?leftmenu=tax_social", $langs->trans("MenuSocialContributions"), 1, $user->rights->tax->charges->lire); @@ -1113,8 +1100,7 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM $newmenu->add("/compta/sociales/payments.php?leftmenu=tax_social&mainmenu=billing", $langs->trans("Payments"), 2, $user->rights->tax->charges->lire); } // VAT - if (empty($conf->global->TAX_DISABLE_VAT_MENUS)) - { + if (empty($conf->global->TAX_DISABLE_VAT_MENUS)) { global $mysoc; $newmenu->add("/compta/tva/list.php?leftmenu=tax_vat&mainmenu=billing", $langs->transcountry("VAT", $mysoc->country_code), 1, $user->rights->tax->charges->lire, '', $mainmenu, 'tax_vat'); @@ -1127,8 +1113,7 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM } //Local Taxes 1 - if ($mysoc->useLocalTax(1) && (isset($mysoc->localtax1_assuj) && $mysoc->localtax1_assuj == "1")) - { + if ($mysoc->useLocalTax(1) && (isset($mysoc->localtax1_assuj) && $mysoc->localtax1_assuj == "1")) { $newmenu->add("/compta/localtax/list.php?leftmenu=tax_1_vat&mainmenu=billing&localTaxType=1", $langs->transcountry("LT1", $mysoc->country_code), 1, $user->rights->tax->charges->lire); if ($usemenuhider || empty($leftmenu) || preg_match('/^tax_1_vat/i', $leftmenu)) { $newmenu->add("/compta/localtax/card.php?leftmenu=tax_1_vat&action=create&localTaxType=1", $langs->trans("New"), 2, $user->rights->tax->charges->creer); @@ -1139,8 +1124,7 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM } } //Local Taxes 2 - if ($mysoc->useLocalTax(2) && (isset($mysoc->localtax2_assuj) && $mysoc->localtax2_assuj == "1")) - { + if ($mysoc->useLocalTax(2) && (isset($mysoc->localtax2_assuj) && $mysoc->localtax2_assuj == "1")) { $newmenu->add("/compta/localtax/list.php?leftmenu=tax_2_vat&mainmenu=billing&localTaxType=2", $langs->transcountry("LT2", $mysoc->country_code), 1, $user->rights->tax->charges->lire); if ($usemenuhider || empty($leftmenu) || preg_match('/^tax_2_vat/i', $leftmenu)) { $newmenu->add("/compta/localtax/card.php?leftmenu=tax_2_vat&action=create&localTaxType=2", $langs->trans("New"), 2, $user->rights->tax->charges->creer); @@ -1154,8 +1138,7 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM } // Salaries - if (!empty($conf->salaries->enabled)) - { + if (!empty($conf->salaries->enabled)) { $langs->load("salaries"); $newmenu->add("/salaries/list.php?leftmenu=tax_salary&mainmenu=billing", $langs->trans("Salaries"), 0, $user->rights->salaries->read, '', $mainmenu, 'tax_salary'); if ($usemenuhider || empty($leftmenu) || preg_match('/^tax_salary/i', $leftmenu)) { @@ -1166,8 +1149,7 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM } // Loan - if (!empty($conf->loan->enabled)) - { + if (!empty($conf->loan->enabled)) { $langs->load("loan"); $newmenu->add("/loan/list.php?leftmenu=tax_loan&mainmenu=billing", $langs->trans("Loans"), 0, $user->rights->loan->read, '', $mainmenu, 'tax_loan'); if ($usemenuhider || empty($leftmenu) || preg_match('/^tax_loan/i', $leftmenu)) { @@ -1177,8 +1159,7 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM } // Various payment - if (!empty($conf->banque->enabled) && empty($conf->global->BANK_USE_OLD_VARIOUS_PAYMENT)) - { + if (!empty($conf->banque->enabled) && empty($conf->global->BANK_USE_OLD_VARIOUS_PAYMENT)) { $langs->load("banks"); $newmenu->add("/compta/bank/various_payment/list.php?leftmenu=tax_various&mainmenu=billing", $langs->trans("MenuVariousPayment"), 0, $user->rights->banque->lire, '', $mainmenu, 'tax_various'); if ($usemenuhider || empty($leftmenu) || preg_match('/^tax_various/i', $leftmenu)) { @@ -1191,13 +1172,11 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM /* * Menu COMPTA-FINANCIAL */ - if ($mainmenu == 'accountancy') - { + if ($mainmenu == 'accountancy') { $langs->load("companies"); // Accounting (Double entries) - if (!empty($conf->accounting->enabled)) - { + if (!empty($conf->accounting->enabled)) { $permtoshowmenu = (!empty($conf->accounting->enabled) || $user->rights->accounting->bind->write || $user->rights->compta->resultat->lire); //$newmenu->add("/accountancy/index.php?leftmenu=accountancy", $langs->trans("MenuAccountancy"), 0, $permtoshowmenu, '', $mainmenu, 'accountancy'); @@ -1241,24 +1220,21 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM // Binding // $newmenu->add("", $langs->trans("Binding"), 0, $user->rights->accounting->bind->write, '', $mainmenu, 'dispatch'); - if (!empty($conf->facture->enabled) && empty($conf->global->ACCOUNTING_DISABLE_BINDING_ON_SALES)) - { + if (!empty($conf->facture->enabled) && empty($conf->global->ACCOUNTING_DISABLE_BINDING_ON_SALES)) { $newmenu->add("/accountancy/customer/index.php?leftmenu=accountancy_dispatch_customer&mainmenu=accountancy", $langs->trans("CustomersVentilation"), 1, $user->rights->accounting->bind->write, '', $mainmenu, 'dispatch_customer'); if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_dispatch_customer/', $leftmenu)) { $newmenu->add("/accountancy/customer/list.php?mainmenu=accountancy&leftmenu=accountancy_dispatch_customer", $langs->trans("ToBind"), 2, $user->rights->accounting->bind->write); $newmenu->add("/accountancy/customer/lines.php?mainmenu=accountancy&leftmenu=accountancy_dispatch_customer", $langs->trans("Binded"), 2, $user->rights->accounting->bind->write); } } - if (!empty($conf->supplier_invoice->enabled) && empty($conf->global->ACCOUNTING_DISABLE_BINDING_ON_PURCHASES)) - { + if (!empty($conf->supplier_invoice->enabled) && empty($conf->global->ACCOUNTING_DISABLE_BINDING_ON_PURCHASES)) { $newmenu->add("/accountancy/supplier/index.php?leftmenu=accountancy_dispatch_supplier&mainmenu=accountancy", $langs->trans("SuppliersVentilation"), 1, $user->rights->accounting->bind->write, '', $mainmenu, 'dispatch_supplier'); if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_dispatch_supplier/', $leftmenu)) { $newmenu->add("/accountancy/supplier/list.php?mainmenu=accountancy&leftmenu=accountancy_dispatch_supplier", $langs->trans("ToBind"), 2, $user->rights->accounting->bind->write); $newmenu->add("/accountancy/supplier/lines.php?mainmenu=accountancy&leftmenu=accountancy_dispatch_supplier", $langs->trans("Binded"), 2, $user->rights->accounting->bind->write); } } - if (!empty($conf->expensereport->enabled) && empty($conf->global->ACCOUNTING_DISABLE_BINDING_ON_EXPENSEREPORTS)) - { + if (!empty($conf->expensereport->enabled) && empty($conf->global->ACCOUNTING_DISABLE_BINDING_ON_EXPENSEREPORTS)) { $newmenu->add("/accountancy/expensereport/index.php?leftmenu=accountancy_dispatch_expensereport&mainmenu=accountancy", $langs->trans("ExpenseReportsVentilation"), 1, $user->rights->accounting->bind->write, '', $mainmenu, 'dispatch_expensereport'); if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_dispatch_expensereport/', $leftmenu)) { $newmenu->add("/accountancy/expensereport/list.php?mainmenu=accountancy&leftmenu=accountancy_dispatch_expensereport", $langs->trans("ToBind"), 2, $user->rights->accounting->bind->write); @@ -1267,8 +1243,7 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM } // Journals - if (!empty($conf->accounting->enabled) && !empty($user->rights->accounting->comptarapport->lire) && $mainmenu == 'accountancy') - { + if (!empty($conf->accounting->enabled) && !empty($user->rights->accounting->comptarapport->lire) && $mainmenu == 'accountancy') { $newmenu->add('', $langs->trans("RegistrationInAccounting"), 1, $user->rights->accounting->comptarapport->lire); // Multi journal @@ -1279,39 +1254,49 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM $sql .= " ORDER BY label DESC"; $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $numr = $db->num_rows($resql); $i = 0; - if ($numr > 0) - { - while ($i < $numr) - { + if ($numr > 0) { + while ($i < $numr) { $objp = $db->fetch_object($resql); $nature = ''; // Must match array $sourceList defined into journals_list.php - if ($objp->nature == 2 && !empty($conf->facture->enabled) && empty($conf->global->ACCOUNTING_DISABLE_BINDING_ON_SALES)) $nature = "sells"; + if ($objp->nature == 2 && !empty($conf->facture->enabled) && empty($conf->global->ACCOUNTING_DISABLE_BINDING_ON_SALES)) { + $nature = "sells"; + } if ($objp->nature == 3 && (!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_invoice->enabled)) - && empty($conf->global->ACCOUNTING_DISABLE_BINDING_ON_PURCHASES)) + && empty($conf->global->ACCOUNTING_DISABLE_BINDING_ON_PURCHASES)) { $nature = "purchases"; - if ($objp->nature == 4 && !empty($conf->banque->enabled)) $nature = "bank"; - if ($objp->nature == 5 && !empty($conf->expensereport->enabled) && empty($conf->global->ACCOUNTING_DISABLE_BINDING_ON_EXPENSEREPORTS)) $nature = "expensereports"; - if ($objp->nature == 1) $nature = "various"; - if ($objp->nature == 8) $nature = "inventory"; - if ($objp->nature == 9) $nature = "hasnew"; - - // To enable when page exists - if (empty($conf->global->ACCOUNTANCY_SHOW_DEVELOP_JOURNAL)) - { - if ($nature == 'various' || $nature == 'hasnew' || $nature == 'inventory') $nature = ''; + } + if ($objp->nature == 4 && !empty($conf->banque->enabled)) { + $nature = "bank"; + } + if ($objp->nature == 5 && !empty($conf->expensereport->enabled) && empty($conf->global->ACCOUNTING_DISABLE_BINDING_ON_EXPENSEREPORTS)) { + $nature = "expensereports"; + } + if ($objp->nature == 1) { + $nature = "various"; + } + if ($objp->nature == 8) { + $nature = "inventory"; + } + if ($objp->nature == 9) { + $nature = "hasnew"; } - if ($nature) - { + // To enable when page exists + if (empty($conf->global->ACCOUNTANCY_SHOW_DEVELOP_JOURNAL)) { + if ($nature == 'various' || $nature == 'hasnew' || $nature == 'inventory') { + $nature = ''; + } + } + + if ($nature) { $langs->load('accountancy'); $journallabel = $langs->transnoentities($objp->label); // Labels in this table are set by loading llx_accounting_abc.sql. Label can be 'ACCOUNTING_SELL_JOURNAL', 'InventoryJournal', ... $newmenu->add('/accountancy/journal/'.$nature.'journal.php?mainmenu=accountancy&leftmenu=accountancy_journal&id_journal='.$objp->rowid, $journallabel, 2, $user->rights->accounting->comptarapport->lire); @@ -1322,7 +1307,9 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM // Should not happend. Entries are added $newmenu->add('', $langs->trans("NoJournalDefined"), 2, $user->rights->accounting->comptarapport->lire); } - } else dol_print_error($db); + } else { + dol_print_error($db); + } $db->free($resql); } @@ -1339,8 +1326,7 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM $newmenu->add("/accountancy/bookkeeping/list.php?mainmenu=accountancy&leftmenu=accountancy_accountancy", $langs->trans("Journals"), 1, $user->rights->accounting->mouvements->lire); // Files - if (empty($conf->global->ACCOUNTANCY_HIDE_EXPORT_FILES_MENU)) - { + if (empty($conf->global->ACCOUNTANCY_HIDE_EXPORT_FILES_MENU)) { $newmenu->add("/compta/accounting-files.php?mainmenu=accountancy&leftmenu=accountancy_files", $langs->trans("AccountantFiles"), 1, $user->rights->accounting->mouvements->lire); } @@ -1363,9 +1349,10 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM } $modecompta = 'CREANCES-DETTES'; - if (!empty($conf->accounting->enabled) && !empty($user->rights->accounting->comptarapport->lire) && $mainmenu == 'accountancy') $modecompta = 'BOOKKEEPING'; // Not yet implemented. Should be BOOKKEEPINGCOLLECTED - if ($modecompta) - { + if (!empty($conf->accounting->enabled) && !empty($user->rights->accounting->comptarapport->lire) && $mainmenu == 'accountancy') { + $modecompta = 'BOOKKEEPING'; // Not yet implemented. Should be BOOKKEEPINGCOLLECTED + } + if ($modecompta) { if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_report/', $leftmenu)) { $newmenu->add("/compta/stats/index.php?leftmenu=accountancy_report&modecompta=".$modecompta, $langs->trans("ReportTurnover"), 2, $user->rights->accounting->comptarapport->lire); $newmenu->add("/compta/stats/casoc.php?leftmenu=accountancy_report&modecompta=".$modecompta, $langs->trans("ByCompanies"), 3, $user->rights->accounting->comptarapport->lire); @@ -1377,8 +1364,7 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM $modecompta = 'RECETTES-DEPENSES'; //if (! empty($conf->accounting->enabled) && ! empty($user->rights->accounting->comptarapport->lire) && $mainmenu == 'accountancy') $modecompta=''; // Not yet implemented. Should be BOOKKEEPINGCOLLECTED - if ($modecompta) - { + if ($modecompta) { if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_report/', $leftmenu)) { $newmenu->add("/compta/stats/index.php?leftmenu=accountancy_report&modecompta=".$modecompta, $langs->trans("ReportTurnoverCollected"), 2, $user->rights->accounting->comptarapport->lire); $newmenu->add("/compta/stats/casoc.php?leftmenu=accountancy_report&modecompta=".$modecompta, $langs->trans("ByCompanies"), 3, $user->rights->accounting->comptarapport->lire); @@ -1389,9 +1375,10 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM } $modecompta = 'CREANCES-DETTES'; - if (!empty($conf->accounting->enabled) && !empty($user->rights->accounting->comptarapport->lire) && $mainmenu == 'accountancy') $modecompta = 'BOOKKEEPING'; // Not yet implemented. Should be BOOKKEEPINGCOLLECTED - if ($modecompta && $conf->fournisseur->enabled) - { + if (!empty($conf->accounting->enabled) && !empty($user->rights->accounting->comptarapport->lire) && $mainmenu == 'accountancy') { + $modecompta = 'BOOKKEEPING'; // Not yet implemented. Should be BOOKKEEPINGCOLLECTED + } + if ($modecompta && $conf->fournisseur->enabled) { if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_report/', $leftmenu)) { $newmenu->add("/compta/stats/supplier_turnover.php?leftmenu=accountancy_report&modecompta=".$modecompta, $langs->trans("ReportPurchaseTurnover"), 2, $user->rights->accounting->comptarapport->lire); $newmenu->add("/compta/stats/supplier_turnover_by_thirdparty.php?leftmenu=accountancy_report&modecompta=".$modecompta, $langs->trans("ByCompanies"), 3, $user->rights->accounting->comptarapport->lire); @@ -1401,8 +1388,7 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM $modecompta = 'RECETTES-DEPENSES'; //if (! empty($conf->accounting->enabled) && ! empty($user->rights->accounting->comptarapport->lire) && $mainmenu == 'accountancy') $modecompta=''; // Not yet implemented. Should be BOOKKEEPINGCOLLECTED - if ($modecompta && $conf->fournisseur->enabled) - { + if ($modecompta && $conf->fournisseur->enabled) { if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_report/', $leftmenu)) { $newmenu->add("/compta/stats/supplier_turnover.php?leftmenu=accountancy_report&modecompta=".$modecompta, $langs->trans("ReportPurchaseTurnoverCollected"), 2, $user->rights->accounting->comptarapport->lire); $newmenu->add("/compta/stats/supplier_turnover_by_thirdparty.php?leftmenu=accountancy_report&modecompta=".$modecompta, $langs->trans("ByCompanies"), 3, $user->rights->accounting->comptarapport->lire); @@ -1411,11 +1397,9 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM } // Accountancy (simple) - if (!empty($conf->comptabilite->enabled)) - { + if (!empty($conf->comptabilite->enabled)) { // Files - if (empty($conf->global->ACCOUNTANCY_HIDE_EXPORT_FILES_MENU)) - { + if (empty($conf->global->ACCOUNTANCY_HIDE_EXPORT_FILES_MENU)) { $newmenu->add("/compta/accounting-files.php?mainmenu=accountancy&leftmenu=accountancy_files", $langs->trans("AccountantFiles"), 0, $user->rights->compta->resultat->lire, '', $mainmenu, 'files'); } @@ -1426,18 +1410,18 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM $newmenu->add("/compta/resultat/index.php?leftmenu=report", $langs->trans("MenuReportInOut"), 1, $user->rights->compta->resultat->lire); $newmenu->add("/compta/resultat/clientfourn.php?leftmenu=report", $langs->trans("ByCompanies"), 2, $user->rights->compta->resultat->lire); /* On verra ca avec module compabilite expert - $newmenu->add("/compta/resultat/compteres.php?leftmenu=report","Compte de resultat",2,$user->rights->compta->resultat->lire); - $newmenu->add("/compta/resultat/bilan.php?leftmenu=report","Bilan",2,$user->rights->compta->resultat->lire); - */ + $newmenu->add("/compta/resultat/compteres.php?leftmenu=report","Compte de resultat",2,$user->rights->compta->resultat->lire); + $newmenu->add("/compta/resultat/bilan.php?leftmenu=report","Bilan",2,$user->rights->compta->resultat->lire); + */ $newmenu->add("/compta/stats/index.php?leftmenu=report", $langs->trans("ReportTurnover"), 1, $user->rights->compta->resultat->lire); /* - $newmenu->add("/compta/stats/cumul.php?leftmenu=report","Cumule",2,$user->rights->compta->resultat->lire); - if (! empty($conf->propal->enabled)) { - $newmenu->add("/compta/stats/prev.php?leftmenu=report","Previsionnel",2,$user->rights->compta->resultat->lire); - $newmenu->add("/compta/stats/comp.php?leftmenu=report","Transforme",2,$user->rights->compta->resultat->lire); - } - */ + $newmenu->add("/compta/stats/cumul.php?leftmenu=report","Cumule",2,$user->rights->compta->resultat->lire); + if (! empty($conf->propal->enabled)) { + $newmenu->add("/compta/stats/prev.php?leftmenu=report","Previsionnel",2,$user->rights->compta->resultat->lire); + $newmenu->add("/compta/stats/comp.php?leftmenu=report","Transforme",2,$user->rights->compta->resultat->lire); + } + */ $newmenu->add("/compta/stats/casoc.php?leftmenu=report", $langs->trans("ByCompanies"), 2, $user->rights->compta->resultat->lire); $newmenu->add("/compta/stats/cabyuser.php?leftmenu=report", $langs->trans("ByUsers"), 2, $user->rights->compta->resultat->lire); $newmenu->add("/compta/stats/cabyprodserv.php?leftmenu=report", $langs->trans("ByProductsAndServices"), 2, $user->rights->compta->resultat->lire); @@ -1454,8 +1438,7 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM } // Intracomm report - if (!empty($conf->intracommreport->enabled)) - { + if (!empty($conf->intracommreport->enabled)) { $newmenu->add("/intracommreport/list.php?leftmenu=intracommreport", $langs->trans("MenuIntracommReport"), 0, $user->rights->intracommreport->read, '', $mainmenu, 'intracommreport', 1); if ($usemenuhider || empty($leftmenu) || preg_match('/intracommreport/', $leftmenu)) { // DEB / DES @@ -1465,8 +1448,7 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM } // Assets - if (!empty($conf->asset->enabled)) - { + if (!empty($conf->asset->enabled)) { $newmenu->add("/asset/list.php?leftmenu=asset&mainmenu=accountancy", $langs->trans("MenuAssets"), 0, $user->rights->asset->read, '', $mainmenu, 'asset'); $newmenu->add("/asset/card.php?leftmenu=asset&action=create", $langs->trans("MenuNewAsset"), 1, $user->rights->asset->write); $newmenu->add("/asset/list.php?leftmenu=asset&mainmenu=accountancy", $langs->trans("MenuListAssets"), 1, $user->rights->asset->read); @@ -1482,14 +1464,12 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM /* * Menu BANK */ - if ($mainmenu == 'bank') - { + if ($mainmenu == 'bank') { // Load translation files required by the page $langs->loadLangs(array("withdrawals", "banks", "bills", "categories")); // Bank-Cash account - if (!empty($conf->banque->enabled)) - { + if (!empty($conf->banque->enabled)) { $newmenu->add("/compta/bank/list.php?leftmenu=bank&mainmenu=bank", $langs->trans("MenuBankCash"), 0, $user->rights->banque->lire, '', $mainmenu, 'bank'); $newmenu->add("/compta/bank/card.php?action=create", $langs->trans("MenuNewFinancialAccount"), 1, $user->rights->banque->configurer); @@ -1500,16 +1480,14 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM $newmenu->add("/compta/bank/transfer.php", $langs->trans("MenuBankInternalTransfer"), 1, $user->rights->banque->transfer); } - if (!empty($conf->categorie->enabled)) - { + if (!empty($conf->categorie->enabled)) { $langs->load("categories"); $newmenu->add("/categories/index.php?type=5", $langs->trans("Rubriques"), 1, $user->rights->categorie->creer, '', $mainmenu, 'tags'); $newmenu->add("/compta/bank/categ.php", $langs->trans("RubriquesTransactions"), 1, $user->rights->banque->configurer, '', $mainmenu, 'tags'); } // Direct debit order - if (!empty($conf->prelevement->enabled)) - { + if (!empty($conf->prelevement->enabled)) { $newmenu->add("/compta/prelevement/index.php?leftmenu=withdraw&mainmenu=bank", $langs->trans("PaymentByDirectDebit"), 0, $user->rights->prelevement->bons->lire, '', $mainmenu, 'withdraw'); if ($usemenuhider || empty($leftmenu) || $leftmenu == "withdraw") { @@ -1523,8 +1501,7 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM } // Bank transfer order - if (!empty($conf->paymentbybanktransfer->enabled)) - { + if (!empty($conf->paymentbybanktransfer->enabled)) { $newmenu->add("/compta/paymentbybanktransfer/index.php?leftmenu=banktransfer&mainmenu=bank", $langs->trans("PaymentByBankTransfer"), 0, $user->rights->paymentbybanktransfer->read, '', $mainmenu, 'banktransfer'); if ($usemenuhider || empty($leftmenu) || $leftmenu == "banktransfer") { @@ -1538,8 +1515,7 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM } // Management of checks - if (empty($conf->global->BANK_DISABLE_CHECK_DEPOSIT) && !empty($conf->banque->enabled) && (!empty($conf->facture->enabled) || !empty($conf->global->MAIN_MENU_CHEQUE_DEPOSIT_ON))) - { + if (empty($conf->global->BANK_DISABLE_CHECK_DEPOSIT) && !empty($conf->banque->enabled) && (!empty($conf->facture->enabled) || !empty($conf->global->MAIN_MENU_CHEQUE_DEPOSIT_ON))) { $newmenu->add("/compta/paiement/cheque/index.php?leftmenu=checks&mainmenu=bank", $langs->trans("MenuChequeDeposits"), 0, $user->rights->banque->cheque, '', $mainmenu, 'checks'); if (preg_match('/checks/', $leftmenu)) { $newmenu->add("/compta/paiement/cheque/card.php?leftmenu=checks_bis&action=new&mainmenu=bank", $langs->trans("NewChequeDeposit"), 1, $user->rights->banque->cheque); @@ -1548,8 +1524,7 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM } // Cash Control - if (!empty($conf->takepos->enabled) || !empty($conf->cashdesk->enabled)) - { + if (!empty($conf->takepos->enabled) || !empty($conf->cashdesk->enabled)) { $permtomakecashfence = ($user->rights->cashdesk->run || $user->rights->takepos->run); $newmenu->add("/compta/cashcontrol/cashcontrol_list.php?action=list", $langs->trans("POS"), 0, $permtomakecashfence, '', $mainmenu, 'cashcontrol'); $newmenu->add("/compta/cashcontrol/cashcontrol_card.php?action=create", $langs->trans("NewCashFence"), 1, $permtomakecashfence); @@ -1560,36 +1535,29 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM /* * Menu PRODUCTS-SERVICES */ - if ($mainmenu == 'products') - { + if ($mainmenu == 'products') { // Products - if (!empty($conf->product->enabled)) - { + if (!empty($conf->product->enabled)) { $newmenu->add("/product/index.php?leftmenu=product&type=0", $langs->trans("Products"), 0, $user->rights->produit->lire, '', $mainmenu, 'product'); $newmenu->add("/product/card.php?leftmenu=product&action=create&type=0", $langs->trans("NewProduct"), 1, $user->rights->produit->creer); $newmenu->add("/product/list.php?leftmenu=product&type=0", $langs->trans("List"), 1, $user->rights->produit->lire); - if (!empty($conf->stock->enabled)) - { + if (!empty($conf->stock->enabled)) { $newmenu->add("/product/reassort.php?type=0", $langs->trans("MenuStocks"), 1, $user->rights->produit->lire && $user->rights->stock->lire); } - if (!empty($conf->productbatch->enabled)) - { + if (!empty($conf->productbatch->enabled)) { $langs->load("stocks"); $newmenu->add("/product/reassortlot.php?type=0", $langs->trans("StocksByLotSerial"), 1, $user->rights->produit->lire && $user->rights->stock->lire); $newmenu->add("/product/stock/productlot_list.php", $langs->trans("LotSerial"), 1, $user->rights->produit->lire && $user->rights->stock->lire); } - if (!empty($conf->variants->enabled)) - { + if (!empty($conf->variants->enabled)) { $newmenu->add("/variants/list.php", $langs->trans("VariantAttributes"), 1, $user->rights->produit->lire); } - if (!empty($conf->propal->enabled) || !empty($conf->commande->enabled) || !empty($conf->facture->enabled) || !empty($conf->fournisseur->enabled) || !empty($conf->supplier_proposal->enabled)) - { + if (!empty($conf->propal->enabled) || !empty($conf->commande->enabled) || !empty($conf->facture->enabled) || !empty($conf->fournisseur->enabled) || !empty($conf->supplier_proposal->enabled)) { $newmenu->add("/product/stats/card.php?id=all&leftmenu=stats&type=0", $langs->trans("Statistics"), 1, $user->rights->produit->lire && $user->rights->propale->lire); } // Categories - if (!empty($conf->categorie->enabled)) - { + if (!empty($conf->categorie->enabled)) { $langs->load("categories"); $newmenu->add("/categories/index.php?leftmenu=cat&type=0", $langs->trans("Categories"), 1, $user->rights->categorie->lire, '', $mainmenu, 'cat'); //if ($usemenuhider || empty($leftmenu) || $leftmenu=="cat") $newmenu->add("/categories/list.php", $langs->trans("List"), 1, $user->rights->categorie->lire); @@ -1597,18 +1565,15 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM } // Services - if (!empty($conf->service->enabled)) - { + if (!empty($conf->service->enabled)) { $newmenu->add("/product/index.php?leftmenu=service&type=1", $langs->trans("Services"), 0, $user->rights->service->lire, '', $mainmenu, 'service'); $newmenu->add("/product/card.php?leftmenu=service&action=create&type=1", $langs->trans("NewService"), 1, $user->rights->service->creer); $newmenu->add("/product/list.php?leftmenu=service&type=1", $langs->trans("List"), 1, $user->rights->service->lire); - if (!empty($conf->propal->enabled) || !empty($conf->commande->enabled) || !empty($conf->facture->enabled) || !empty($conf->fournisseur->enabled) || !empty($conf->supplier_proposal->enabled)) - { + if (!empty($conf->propal->enabled) || !empty($conf->commande->enabled) || !empty($conf->facture->enabled) || !empty($conf->fournisseur->enabled) || !empty($conf->supplier_proposal->enabled)) { $newmenu->add("/product/stats/card.php?id=all&leftmenu=stats&type=1", $langs->trans("Statistics"), 1, $user->rights->service->lire && $user->rights->propale->lire); } // Categories - if (!empty($conf->categorie->enabled)) - { + if (!empty($conf->categorie->enabled)) { $langs->load("categories"); $newmenu->add("/categories/index.php?leftmenu=cat&type=0", $langs->trans("Categories"), 1, $user->rights->categorie->lire, '', $mainmenu, 'cat'); //if ($usemenuhider || empty($leftmenu) || $leftmenu=="cat") $newmenu->add("/categories/list.php", $langs->trans("List"), 1, $user->rights->categorie->lire); @@ -1616,8 +1581,7 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM } // Warehouse - if (!empty($conf->stock->enabled)) - { + if (!empty($conf->stock->enabled)) { $langs->load("stocks"); $newmenu->add("/product/stock/index.php?leftmenu=stock", $langs->trans("Warehouses"), 0, $user->rights->stock->lire, '', $mainmenu, 'stock'); $newmenu->add("/product/stock/card.php?action=create", $langs->trans("MenuNewWarehouse"), 1, $user->rights->stock->creer); @@ -1625,24 +1589,22 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM $newmenu->add("/product/stock/movement_list.php", $langs->trans("Movements"), 1, $user->rights->stock->mouvement->lire); $newmenu->add("/product/stock/massstockmove.php", $langs->trans("MassStockTransferShort"), 1, $user->rights->stock->mouvement->creer); - if ($conf->supplier_order->enabled) $newmenu->add("/product/stock/replenish.php", $langs->trans("Replenishment"), 1, $user->rights->stock->mouvement->creer && $user->rights->fournisseur->lire); + if ($conf->supplier_order->enabled) { + $newmenu->add("/product/stock/replenish.php", $langs->trans("Replenishment"), 1, $user->rights->stock->mouvement->creer && $user->rights->fournisseur->lire); + } $newmenu->add("/product/stock/stockatdate.php", $langs->trans("StockAtDate"), 1, $user->rights->produit->lire && $user->rights->stock->lire && $conf->global->MAIN_FEATURES_LEVEL >= 2); // Categories for warehouses - if (!empty($conf->categorie->enabled)) - { + if (!empty($conf->categorie->enabled)) { $newmenu->add("/categories/index.php?leftmenu=stock&type=9", $langs->trans("Categories"), 1, $user->rights->categorie->lire, '', $mainmenu, 'cat'); } } // Inventory - if ($conf->global->MAIN_FEATURES_LEVEL >= 2) - { - if (!empty($conf->stock->enabled)) - { + if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { + if (!empty($conf->stock->enabled)) { $langs->load("stocks"); - if (empty($conf->global->MAIN_USE_ADVANCED_PERMS)) - { + if (empty($conf->global->MAIN_USE_ADVANCED_PERMS)) { $newmenu->add("/product/inventory/list.php?leftmenu=stock_inventories", $langs->trans("Inventories"), 0, $user->rights->stock->lire, '', $mainmenu, 'stock'); if ($usemenuhider || empty($leftmenu) || $leftmenu == "stock_inventories") { $newmenu->add("/product/inventory/card.php?action=create&leftmenu=stock_inventories", $langs->trans("NewInventory"), 1, $user->rights->stock->creer); @@ -1659,8 +1621,7 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM } // Shipments - if (!empty($conf->expedition->enabled)) - { + if (!empty($conf->expedition->enabled)) { $langs->load("sendings"); $newmenu->add("/expedition/index.php?leftmenu=sendings", $langs->trans("Shipments"), 0, $user->rights->expedition->lire, '', $mainmenu, 'sendings'); $newmenu->add("/expedition/card.php?action=create2&leftmenu=sendings", $langs->trans("NewSending"), 1, $user->rights->expedition->creer); @@ -1674,15 +1635,20 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM } // Receptions - if (!empty($conf->reception->enabled)) - { + if (!empty($conf->reception->enabled)) { $langs->load("receptions"); $newmenu->add("/reception/index.php?leftmenu=receptions", $langs->trans("Receptions"), 0, $user->rights->reception->lire, '', $mainmenu, 'receptions'); $newmenu->add("/reception/card.php?action=create2&leftmenu=receptions", $langs->trans("NewReception"), 1, $user->rights->reception->creer); $newmenu->add("/reception/list.php?leftmenu=receptions", $langs->trans("List"), 1, $user->rights->reception->lire); - if ($usemenuhider || empty($leftmenu) || $leftmenu == "receptions") $newmenu->add("/reception/list.php?leftmenu=receptions&search_status=0", $langs->trans("StatusReceptionDraftShort"), 2, $user->rights->reception->lire); - if ($usemenuhider || empty($leftmenu) || $leftmenu == "receptions") $newmenu->add("/reception/list.php?leftmenu=receptions&search_status=1", $langs->trans("StatusReceptionValidatedShort"), 2, $user->rights->reception->lire); - if ($usemenuhider || empty($leftmenu) || $leftmenu == "receptions") $newmenu->add("/reception/list.php?leftmenu=receptions&search_status=2", $langs->trans("StatusReceptionProcessedShort"), 2, $user->rights->reception->lire); + if ($usemenuhider || empty($leftmenu) || $leftmenu == "receptions") { + $newmenu->add("/reception/list.php?leftmenu=receptions&search_status=0", $langs->trans("StatusReceptionDraftShort"), 2, $user->rights->reception->lire); + } + if ($usemenuhider || empty($leftmenu) || $leftmenu == "receptions") { + $newmenu->add("/reception/list.php?leftmenu=receptions&search_status=1", $langs->trans("StatusReceptionValidatedShort"), 2, $user->rights->reception->lire); + } + if ($usemenuhider || empty($leftmenu) || $leftmenu == "receptions") { + $newmenu->add("/reception/list.php?leftmenu=receptions&search_status=2", $langs->trans("StatusReceptionProcessedShort"), 2, $user->rights->reception->lire); + } $newmenu->add("/reception/stats/index.php?leftmenu=receptions", $langs->trans("Statistics"), 1, $user->rights->reception->lire); } } @@ -1690,11 +1656,9 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM /* * Menu PRODUCTS-SERVICES MRP - GPAO */ - if ($mainmenu == 'mrp') - { + if ($mainmenu == 'mrp') { // BOM - if (!empty($conf->bom->enabled) || !empty($conf->mrp->enabled)) - { + if (!empty($conf->bom->enabled) || !empty($conf->mrp->enabled)) { $langs->load("mrp"); $newmenu->add("", $langs->trans("MenuBOM"), 0, $user->rights->bom->read, '', $mainmenu, 'bom'); @@ -1702,8 +1666,7 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM $newmenu->add("/bom/bom_list.php?leftmenu=bom", $langs->trans("List"), 1, $user->rights->bom->read, '', $mainmenu, 'bom'); } - if (!empty($conf->mrp->enabled)) - { + if (!empty($conf->mrp->enabled)) { $langs->load("mrp"); $newmenu->add("", $langs->trans("MenuMRP"), 0, $user->rights->mrp->read, '', $mainmenu, 'mo'); @@ -1715,10 +1678,8 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM /* * Menu PROJECTS */ - if ($mainmenu == 'project') - { - if (!empty($conf->projet->enabled)) - { + if ($mainmenu == 'project') { + if (!empty($conf->projet->enabled)) { $langs->load("projects"); $search_project_user = GETPOST('search_project_user', 'int'); @@ -1732,8 +1693,7 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM $titleboth = $langs->trans("LeadsOrProjects"); $titlenew = $langs->trans("NewLeadOrProject"); // Leads and opportunities by default - if ($conf->global->PROJECT_USE_OPPORTUNITIES == 0) - { + if ($conf->global->PROJECT_USE_OPPORTUNITIES == 0) { $titleboth = $langs->trans("Projects"); $titlenew = $langs->trans("NewProject"); } @@ -1746,11 +1706,9 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM $newmenu->add("/projet/index.php?leftmenu=projects".($search_project_user ? '&search_project_user='.$search_project_user : ''), $titleboth, 0, $user->rights->projet->lire, '', $mainmenu, 'projects'); $newmenu->add("/projet/card.php?leftmenu=projects&action=create".($search_project_user ? '&search_project_user='.$search_project_user : ''), $titlenew, 1, $user->rights->projet->creer); - if ($conf->global->PROJECT_USE_OPPORTUNITIES == 0) - { + if ($conf->global->PROJECT_USE_OPPORTUNITIES == 0) { $newmenu->add("/projet/list.php?leftmenu=projets".($search_project_user ? '&search_project_user='.$search_project_user : '').'&search_status=99', $langs->trans("List"), 1, $showmode, '', 'project', 'list'); - } elseif ($conf->global->PROJECT_USE_OPPORTUNITIES == 1) - { + } elseif ($conf->global->PROJECT_USE_OPPORTUNITIES == 1) { $newmenu->add("/projet/list.php?leftmenu=projets".($search_project_user ? '&search_project_user='.$search_project_user : ''), $langs->trans("List"), 1, $showmode, '', 'project', 'list'); $newmenu->add('/projet/list.php?mainmenu=project&leftmenu=list&search_usage_opportunity=1&search_status=99&search_opp_status=openedopp&contextpage=lead', $langs->trans("ListOpenLeads"), 2, $showmode); $newmenu->add('/projet/list.php?mainmenu=project&leftmenu=list&search_opp_status=notopenedopp&search_status=99&contextpage=project', $langs->trans("ListOpenProjects"), 2, $showmode); @@ -1761,14 +1719,12 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM $newmenu->add("/projet/stats/index.php?leftmenu=projects", $langs->trans("Statistics"), 1, $user->rights->projet->lire); // Categories - if (!empty($conf->categorie->enabled)) - { + if (!empty($conf->categorie->enabled)) { $langs->load("categories"); $newmenu->add("/categories/index.php?leftmenu=cat&type=6", $langs->trans("Categories"), 1, $user->rights->categorie->lire, '', $mainmenu, 'cat'); } - if (empty($conf->global->PROJECT_HIDE_TASKS)) - { + if (empty($conf->global->PROJECT_HIDE_TASKS)) { // Project affected to user $newmenu->add("/projet/activity/index.php?leftmenu=tasks".($search_project_user ? '&search_project_user='.$search_project_user : ''), $langs->trans("Activities"), 0, $user->rights->projet->lire, '', 'project', 'tasks'); $newmenu->add("/projet/tasks.php?leftmenu=tasks&action=create", $langs->trans("NewTask"), 1, $user->rights->projet->creer); @@ -1783,11 +1739,9 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM /* * Menu HRM */ - if ($mainmenu == 'hrm') - { + if ($mainmenu == 'hrm') { // HRM module - if (!empty($conf->hrm->enabled)) - { + if (!empty($conf->hrm->enabled)) { $langs->load("hrm"); $newmenu->add("/user/list.php?mainmenu=hrm&leftmenu=hrm&mode=employee", $langs->trans("Employees"), 0, $user->rights->hrm->employee->read, '', $mainmenu, 'hrm'); @@ -1796,8 +1750,7 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM } // Leave/Holiday/Vacation module - if (!empty($conf->holiday->enabled)) - { + if (!empty($conf->holiday->enabled)) { // Load translation files required by the page $langs->loadLangs(array("holiday", "trips")); @@ -1817,8 +1770,7 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM } // Trips and expenses (old module) - if (!empty($conf->deplacement->enabled)) - { + if (!empty($conf->deplacement->enabled)) { $langs->load("trips"); $newmenu->add("/compta/deplacement/index.php?leftmenu=tripsandexpenses&mainmenu=hrm", $langs->trans("TripsAndExpenses"), 0, $user->rights->deplacement->lire, '', $mainmenu, 'tripsandexpenses'); $newmenu->add("/compta/deplacement/card.php?action=create&leftmenu=tripsandexpenses&mainmenu=hrm", $langs->trans("New"), 1, $user->rights->deplacement->creer); @@ -1827,8 +1779,7 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM } // Expense report - if (!empty($conf->expensereport->enabled)) - { + if (!empty($conf->expensereport->enabled)) { $langs->load("trips"); $newmenu->add("/expensereport/index.php?leftmenu=expensereport&mainmenu=hrm", $langs->trans("TripsAndExpenses"), 0, $user->rights->expensereport->lire, '', $mainmenu, 'expensereport'); $newmenu->add("/expensereport/card.php?action=create&leftmenu=expensereport&mainmenu=hrm", $langs->trans("New"), 1, $user->rights->expensereport->creer); @@ -1844,10 +1795,8 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM $newmenu->add("/expensereport/stats/index.php?leftmenu=expensereport&mainmenu=hrm", $langs->trans("Statistics"), 1, $user->rights->expensereport->lire); } - if (!empty($conf->projet->enabled)) - { - if (empty($conf->global->PROJECT_HIDE_TASKS)) - { + if (!empty($conf->projet->enabled)) { + if (empty($conf->global->PROJECT_HIDE_TASKS)) { $langs->load("projects"); $search_project_user = GETPOST('search_project_user', 'int'); @@ -1861,31 +1810,26 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM /* * Menu TOOLS */ - if ($mainmenu == 'tools') - { - if (empty($user->socid)) // limit to internal users - { + if ($mainmenu == 'tools') { + if (empty($user->socid)) { // limit to internal users $langs->load("mails"); $newmenu->add("/admin/mails_templates.php?leftmenu=email_templates", $langs->trans("EMailTemplates"), 0, 1, '', $mainmenu, 'email_templates'); } - if (!empty($conf->mailing->enabled)) - { + if (!empty($conf->mailing->enabled)) { $newmenu->add("/comm/mailing/index.php?leftmenu=mailing", $langs->trans("EMailings"), 0, $user->rights->mailing->lire, '', $mainmenu, 'mailing'); $newmenu->add("/comm/mailing/card.php?leftmenu=mailing&action=create", $langs->trans("NewMailing"), 1, $user->rights->mailing->creer); $newmenu->add("/comm/mailing/list.php?leftmenu=mailing", $langs->trans("List"), 1, $user->rights->mailing->lire); } - if (!empty($conf->export->enabled)) - { + if (!empty($conf->export->enabled)) { $langs->load("exports"); $newmenu->add("/exports/index.php?leftmenu=export", $langs->trans("FormatedExport"), 0, $user->rights->export->lire, '', $mainmenu, 'export'); $newmenu->add("/exports/export.php?leftmenu=export", $langs->trans("NewExport"), 1, $user->rights->export->creer); //$newmenu->add("/exports/export.php?leftmenu=export",$langs->trans("List"),1, $user->rights->export->lire); } - if (!empty($conf->import->enabled)) - { + if (!empty($conf->import->enabled)) { $langs->load("exports"); $newmenu->add("/imports/index.php?leftmenu=import", $langs->trans("FormatedImport"), 0, $user->rights->import->run, '', $mainmenu, 'import'); $newmenu->add("/imports/import.php?leftmenu=import", $langs->trans("NewImport"), 1, $user->rights->import->run); @@ -1895,10 +1839,8 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM /* * Menu MEMBERS */ - if ($mainmenu == 'members') - { - if (!empty($conf->adherent->enabled)) - { + if ($mainmenu == 'members') { + if (!empty($conf->adherent->enabled)) { // Load translation files required by the page $langs->loadLangs(array("members", "compta")); @@ -1914,10 +1856,11 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM $newmenu->add("/adherents/stats/index.php?leftmenu=members", $langs->trans("MenuMembersStats"), 1, $user->rights->adherent->lire); $newmenu->add("/adherents/cartes/carte.php?leftmenu=export", $langs->trans("MembersCards"), 1, $user->rights->adherent->export); - if (!empty($conf->global->MEMBER_LINK_TO_HTPASSWDFILE) && ($usemenuhider || empty($leftmenu) || $leftmenu == 'none' || $leftmenu == "members" || $leftmenu == "export")) $newmenu->add("/adherents/htpasswd.php?leftmenu=export", $langs->trans("Filehtpasswd"), 1, $user->rights->adherent->export); + if (!empty($conf->global->MEMBER_LINK_TO_HTPASSWDFILE) && ($usemenuhider || empty($leftmenu) || $leftmenu == 'none' || $leftmenu == "members" || $leftmenu == "export")) { + $newmenu->add("/adherents/htpasswd.php?leftmenu=export", $langs->trans("Filehtpasswd"), 1, $user->rights->adherent->export); + } - if (!empty($conf->categorie->enabled)) - { + if (!empty($conf->categorie->enabled)) { $langs->load("categories"); $newmenu->add("/categories/index.php?leftmenu=cat&type=3", $langs->trans("Categories"), 1, $user->rights->categorie->lire, '', $mainmenu, 'cat'); } @@ -1943,16 +1886,13 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM $newmenu = $menuArbo->menuLeftCharger($newmenu, $mainmenu, $leftmenu, (empty($user->socid) ? 0 : 1), 'eldy', $tabMenu); //var_dump($newmenu->liste); // - if (!empty($conf->ftp->enabled) && $mainmenu == 'ftp') // Entry for FTP - { + if (!empty($conf->ftp->enabled) && $mainmenu == 'ftp') { // Entry for FTP $MAXFTP = 20; $i = 1; - while ($i <= $MAXFTP) - { + while ($i <= $MAXFTP) { $paramkey = 'FTP_NAME_'.$i; //print $paramkey; - if (!empty($conf->global->$paramkey)) - { + if (!empty($conf->global->$paramkey)) { $link = "/ftp/index.php?idmenu=".$_SESSION["idmenu"]."&numero_ftp=".$i; $newmenu->add($link, dol_trunc($conf->global->$paramkey, 24)); @@ -1969,10 +1909,16 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM //var_dump($menu_array_before);exit; //var_dump($menu_array_after);exit; $menu_array = $newmenu->liste; - if (is_array($menu_array_before)) $menu_array = array_merge($menu_array_before, $menu_array); - if (is_array($menu_array_after)) $menu_array = array_merge($menu_array, $menu_array_after); + if (is_array($menu_array_before)) { + $menu_array = array_merge($menu_array_before, $menu_array); + } + if (is_array($menu_array_after)) { + $menu_array = array_merge($menu_array, $menu_array_after); + } //var_dump($menu_array);exit; - if (!is_array($menu_array)) return 0; + if (!is_array($menu_array)) { + return 0; + } // TODO Use the position property in menu_array to reorder the $menu_array //var_dump($menu_array); @@ -1982,19 +1928,19 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM while (findNextEntryForLevel($menu_array, $cursor, $position, $level)) { - $cursor++; + $cursor++; }*/ // Show menu $invert = empty($conf->global->MAIN_MENU_INVERT) ? "" : "invert"; - if (empty($noout)) - { + if (empty($noout)) { $altok = 0; $blockvmenuopened = false; $lastlevel0 = ''; $num = count($menu_array); - for ($i = 0; $i < $num; $i++) // Loop on each menu entry - { + for ($i = 0; $i < $num; $i++) { // Loop on each menu entry $showmenu = true; - if (!empty($conf->global->MAIN_MENU_HIDE_UNAUTHORIZED) && empty($menu_array[$i]['enabled'])) $showmenu = false; + if (!empty($conf->global->MAIN_MENU_HIDE_UNAUTHORIZED) && empty($menu_array[$i]['enabled'])) { + $showmenu = false; + } // Begin of new left menu block if (empty($menu_array[$i]['level']) && $showmenu) { @@ -2002,7 +1948,9 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM $blockvmenuopened = true; $lastopened = true; for ($j = ($i + 1); $j < $num; $j++) { - if (empty($menu_array[$j]['level'])) $lastopened = false; + if (empty($menu_array[$j]['level'])) { + $lastopened = false; + } } if ($altok % 2 == 0) { print '
'."\n"; @@ -2025,19 +1973,16 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM $menu_array[$i]['url'] = make_substitutions($menu_array[$i]['url'], $substitarray); $url = $shorturl = $shorturlwithoutparam = $menu_array[$i]['url']; - if (!preg_match("/^(http:\/\/|https:\/\/)/i", $menu_array[$i]['url'])) - { + if (!preg_match("/^(http:\/\/|https:\/\/)/i", $menu_array[$i]['url'])) { $tmp = explode('?', $menu_array[$i]['url'], 2); $url = $shorturl = $tmp[0]; $param = (isset($tmp[1]) ? $tmp[1] : ''); // params in url of the menu link // Complete param to force leftmenu to '' to close open menu when we click on a link with no leftmenu defined. - if ((!preg_match('/mainmenu/i', $param)) && (!preg_match('/leftmenu/i', $param)) && !empty($menu_array[$i]['mainmenu'])) - { + if ((!preg_match('/mainmenu/i', $param)) && (!preg_match('/leftmenu/i', $param)) && !empty($menu_array[$i]['mainmenu'])) { $param .= ($param ? '&' : '').'mainmenu='.$menu_array[$i]['mainmenu'].'&leftmenu='; } - if ((!preg_match('/mainmenu/i', $param)) && (!preg_match('/leftmenu/i', $param)) && empty($menu_array[$i]['mainmenu'])) - { + if ((!preg_match('/mainmenu/i', $param)) && (!preg_match('/leftmenu/i', $param)) && empty($menu_array[$i]['mainmenu'])) { $param .= ($param ? '&' : '').'leftmenu='; } //$url.="idmenu=".$menu_array[$i]['rowid']; // Already done by menuLoad @@ -2050,64 +1995,77 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM print ''."\n"; // Menu level 0 - if ($menu_array[$i]['level'] == 0) - { - if ($menu_array[$i]['enabled']) // Enabled so visible - { + if ($menu_array[$i]['level'] == 0) { + if ($menu_array[$i]['enabled']) { // Enabled so visible print ''."\n"; $lastlevel0 = 'enabled'; - } elseif ($showmenu) // Not enabled but visible (so greyed) - { + } elseif ($showmenu) { // Not enabled but visible (so greyed) print ''."\n"; $lastlevel0 = 'greyed'; } else { $lastlevel0 = 'hidden'; } - if ($showmenu) - { + if ($showmenu) { print ''."\n"; } } // Menu level > 0 - if ($menu_array[$i]['level'] > 0) - { + if ($menu_array[$i]['level'] > 0) { $cssmenu = ''; - if ($menu_array[$i]['url']) $cssmenu = ' menu_contenu'.dol_string_nospecial(preg_replace('/\.php.*$/', '', $menu_array[$i]['url'])); + if ($menu_array[$i]['url']) { + $cssmenu = ' menu_contenu'.dol_string_nospecial(preg_replace('/\.php.*$/', '', $menu_array[$i]['url'])); + } - if ($menu_array[$i]['enabled'] && $lastlevel0 == 'enabled') // Enabled so visible, except if parent was not enabled. - { + if ($menu_array[$i]['enabled'] && $lastlevel0 == 'enabled') { // Enabled so visible, except if parent was not enabled. print ''."\n"; - } elseif ($showmenu && $lastlevel0 == 'enabled') // Not enabled but visible (so greyed), except if parent was not enabled. - { + } elseif ($showmenu && $lastlevel0 == 'enabled') { // Not enabled but visible (so greyed), except if parent was not enabled. print ''."\n"; } } // If next is a new block or if there is nothing after - if (empty($menu_array[$i + 1]['level'])) // End menu block - { - if ($showmenu) + if (empty($menu_array[$i + 1]['level'])) { // End menu block + if ($showmenu) { print ''."\n"; - if ($blockvmenuopened) { print '
'."\n"; $blockvmenuopened = false; } + } + if ($blockvmenuopened) { + print '
'."\n"; $blockvmenuopened = false; + } } } - if ($altok) print '
'; // End menu block + if ($altok) { + print '
'; // End menu block + } } return count($menu_array); diff --git a/htdocs/core/menus/standard/eldy_menu.php b/htdocs/core/menus/standard/eldy_menu.php index 56a56d3af9b..5a6519dd95c 100644 --- a/htdocs/core/menus/standard/eldy_menu.php +++ b/htdocs/core/menus/standard/eldy_menu.php @@ -67,12 +67,15 @@ class MenuManager global $conf, $user, $langs; // We save into session the main menu selected - if (GETPOSTISSET("mainmenu")) $_SESSION["mainmenu"] = GETPOST("mainmenu", 'aZ09'); - if (GETPOSTISSET("idmenu")) $_SESSION["idmenu"] = GETPOST("idmenu", 'int'); + if (GETPOSTISSET("mainmenu")) { + $_SESSION["mainmenu"] = GETPOST("mainmenu", 'aZ09'); + } + if (GETPOSTISSET("idmenu")) { + $_SESSION["idmenu"] = GETPOST("idmenu", 'int'); + } // Read now mainmenu and leftmenu that define which menu to show - if (GETPOSTISSET("mainmenu")) - { + if (GETPOSTISSET("mainmenu")) { // On sauve en session le menu principal choisi $mainmenu = GETPOST("mainmenu", 'aZ09'); $_SESSION["mainmenu"] = $mainmenu; @@ -81,17 +84,17 @@ class MenuManager // On va le chercher en session si non defini par le lien $mainmenu = isset($_SESSION["mainmenu"]) ? $_SESSION["mainmenu"] : ''; } - if (!empty($forcemainmenu)) $mainmenu = $forcemainmenu; + if (!empty($forcemainmenu)) { + $mainmenu = $forcemainmenu; + } - if (GETPOSTISSET("leftmenu")) - { + if (GETPOSTISSET("leftmenu")) { // On sauve en session le menu principal choisi $leftmenu = GETPOST("leftmenu", 'aZ09'); $_SESSION["leftmenu"] = $leftmenu; - if ($_SESSION["leftmenuopened"] == $leftmenu) // To collapse - { - //$leftmenu=""; + if ($_SESSION["leftmenuopened"] == $leftmenu) { // To collapse + //$leftmenu=""; $_SESSION["leftmenuopened"] = ""; } else { $_SESSION["leftmenuopened"] = $leftmenu; @@ -100,7 +103,9 @@ class MenuManager // On va le chercher en session si non defini par le lien $leftmenu = isset($_SESSION["leftmenu"]) ? $_SESSION["leftmenu"] : ''; } - if (!empty($forceleftmenu)) $leftmenu = $forceleftmenu; + if (!empty($forceleftmenu)) { + $leftmenu = $forceleftmenu; + } require_once DOL_DOCUMENT_ROOT.'/core/class/menubase.class.php'; $tabMenu = array(); @@ -129,8 +134,7 @@ class MenuManager require_once DOL_DOCUMENT_ROOT.'/core/menus/standard/eldy.lib.php'; - if ($this->type_user == 1) - { + if ($this->type_user == 1) { $conf->global->MAIN_SEARCHFORM_SOCIETE_DISABLED = 1; $conf->global->MAIN_SEARCHFORM_CONTACT_DISABLED = 1; } @@ -138,36 +142,39 @@ class MenuManager require_once DOL_DOCUMENT_ROOT.'/core/class/menu.class.php'; $this->menu = new Menu(); - if (empty($conf->global->MAIN_MENU_INVERT)) - { - if ($mode == 'top') print_eldy_menu($this->db, $this->atarget, $this->type_user, $this->tabMenu, $this->menu, 0, $mode); - if ($mode == 'left') print_left_eldy_menu($this->db, $this->menu_array, $this->menu_array_after, $this->tabMenu, $this->menu, 0, '', '', $moredata); + if (empty($conf->global->MAIN_MENU_INVERT)) { + if ($mode == 'top') { + print_eldy_menu($this->db, $this->atarget, $this->type_user, $this->tabMenu, $this->menu, 0, $mode); + } + if ($mode == 'left') { + print_left_eldy_menu($this->db, $this->menu_array, $this->menu_array_after, $this->tabMenu, $this->menu, 0, '', '', $moredata, $this->type_user); + } } else { $conf->global->MAIN_SHOW_LOGO = 0; - if ($mode == 'top') print_left_eldy_menu($this->db, $this->menu_array, $this->menu_array_after, $this->tabMenu, $this->menu, 0); - if ($mode == 'left') print_eldy_menu($this->db, $this->atarget, $this->type_user, $this->tabMenu, $this->menu, 0, $mode); + if ($mode == 'top') { + print_left_eldy_menu($this->db, $this->menu_array, $this->menu_array_after, $this->tabMenu, $this->menu, 0, '', '', $moredata, $this->type_user); + } + if ($mode == 'left') { + print_eldy_menu($this->db, $this->atarget, $this->type_user, $this->tabMenu, $this->menu, 0, $mode); + } } - if ($mode == 'topnb') - { + if ($mode == 'topnb') { print_eldy_menu($this->db, $this->atarget, $this->type_user, $this->tabMenu, $this->menu, 1, $mode); // no output return $this->menu->getNbOfVisibleMenuEntries(); } - if ($mode == 'jmobile') // Used to get menu in xml ul/li - { + if ($mode == 'jmobile') { // Used to get menu in xml ul/li print_eldy_menu($this->db, $this->atarget, $this->type_user, $this->tabMenu, $this->menu, 1, $mode); // Fill this->menu that is empty with top menu // $this->menu->liste is top menu //var_dump($this->menu->liste);exit; $lastlevel = array(); print ''."\n"; - foreach ($this->menu->liste as $key => $val) // $val['url','titre','level','enabled'=0|1|2,'target','mainmenu','leftmenu' - { + foreach ($this->menu->liste as $key => $val) { // $val['url','titre','level','enabled'=0|1|2,'target','mainmenu','leftmenu' print '