diff --git a/README.md b/README.md
index 9dfd1a8a750..ad1702fffe4 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,6 @@
# DOLIBARR ERP & CRM
-
+
[](https://houndci.com)
|6|7|8|9|develop|
diff --git a/dev/setup/codesniffer/ruleset.xml b/dev/setup/codesniffer/ruleset.xml
index b6f62aede64..d8fff2265e9 100644
--- a/dev/setup/codesniffer/ruleset.xml
+++ b/dev/setup/codesniffer/ruleset.xml
@@ -428,4 +428,5 @@
+
diff --git a/htdocs/adherents/stats/byproperties.php b/htdocs/adherents/stats/byproperties.php
index 164606431ff..6ba88e7771b 100644
--- a/htdocs/adherents/stats/byproperties.php
+++ b/htdocs/adherents/stats/byproperties.php
@@ -58,15 +58,16 @@ llxHeader('', $langs->trans("MembersStatisticsByProperties"), '', '', 0, 0, arra
$title=$langs->trans("MembersStatisticsByProperties");
-print load_fiche_titre($title, $mesg);
+print load_fiche_titre($title, '');
dol_mkdir($dir);
$tab='byproperties';
$data = array();
-$sql.="SELECT COUNT(d.rowid) as nb, MAX(d.datevalid) as lastdate, d.morphy as code";
+$sql.="SELECT COUNT(d.rowid) as nb, MAX(d.datevalid) as lastdate, MAX(s.dateadh) as lastsubscriptiondate, d.morphy as code";
$sql.=" FROM ".MAIN_DB_PREFIX."adherent as d";
+$sql.=" LEFT JOIN ".MAIN_DB_PREFIX."subscription as s ON s.fk_adherent = d.rowid";
$sql.=" WHERE d.entity IN (".getEntity('adherent').")";
$sql.=" AND d.statut = 1";
$sql.=" GROUP BY d.morphy";
@@ -87,7 +88,7 @@ if ($resql)
if ($obj->code == 'phy') $foundphy++;
if ($obj->code == 'mor') $foundmor++;
- $data[]=array('label'=>$obj->code, 'nb'=>$obj->nb, 'lastdate'=>$db->jdate($obj->lastdate));
+ $data[]=array('label'=>$obj->code, 'nb'=>$obj->nb, 'lastdate'=>$db->jdate($obj->lastdate), 'lastsubscriptiondate'=>$db->jdate($obj->lastsubscriptiondate));
$i++;
}
@@ -120,22 +121,21 @@ print '
';
print '';
print ''.$langs->trans("Nature").' ';
print ''.$langs->trans("NbOfMembers").' ';
+print ''.$langs->trans("LastMemberDate").' ';
print ''.$langs->trans("LatestSubscriptionDate").' ';
print ' ';
-if (! $foundphy) $data[]=array('label'=>'phy','nb'=>'0','lastdate'=>'');
-if (! $foundmor) $data[]=array('label'=>'mor','nb'=>'0','lastdate'=>'');
+if (! $foundphy) $data[]=array('label'=>'phy','nb'=>'0','lastdate'=>'', 'lastsubscriptiondate'=>'');
+if (! $foundmor) $data[]=array('label'=>'mor','nb'=>'0','lastdate'=>'', 'lastsubscriptiondate'=>'');
-$oldyear=0;
foreach ($data as $val)
{
- $year = $val['year'];
print '';
print ''.$memberstatic->getmorphylib($val['label']).' ';
print ''.$val['nb'].' ';
print ''.dol_print_date($val['lastdate'], 'dayhour').' ';
+ print ''.dol_print_date($val['lastsubscriptiondate'], 'dayhour').' ';
print ' ';
- $oldyear=$year;
}
print '
';
diff --git a/htdocs/adherents/stats/geo.php b/htdocs/adherents/stats/geo.php
index f5816f46aca..79aa5ab6a82 100644
--- a/htdocs/adherents/stats/geo.php
+++ b/htdocs/adherents/stats/geo.php
@@ -77,8 +77,10 @@ if ($mode)
$tab='statscountry';
$data = array();
- $sql.="SELECT COUNT(d.rowid) as nb, MAX(d.datevalid) as lastdate, c.code, c.label";
- $sql.=" FROM ".MAIN_DB_PREFIX."adherent as d LEFT JOIN ".MAIN_DB_PREFIX."c_country as c on d.country = c.rowid";
+ $sql.="SELECT COUNT(d.rowid) as nb, MAX(d.datevalid) as lastdate, MAX(s.dateadh) as lastsubscriptiondate, c.code, c.label";
+ $sql.=" FROM ".MAIN_DB_PREFIX."adherent as d";
+ $sql.=" LEFT JOIN ".MAIN_DB_PREFIX."c_country as c on d.country = c.rowid";
+ $sql.=" LEFT JOIN ".MAIN_DB_PREFIX."subscription as s ON s.fk_adherent = d.rowid";
$sql.=" WHERE d.entity IN (".getEntity('adherent').")";
$sql.=" AND d.statut = 1";
$sql.=" GROUP BY c.label, c.code";
@@ -92,10 +94,12 @@ if ($mode)
$tab='statsstate';
$data = array();
- $sql.="SELECT COUNT(d.rowid) as nb, MAX(d.datevalid) as lastdate, co.code, co.label, c.nom as label2"; //
- $sql.=" FROM ".MAIN_DB_PREFIX."adherent as d LEFT JOIN ".MAIN_DB_PREFIX."c_departements as c on d.state_id = c.rowid";
+ $sql.="SELECT COUNT(d.rowid) as nb, MAX(d.datevalid) as lastdate, MAX(s.dateadh) as lastsubscriptiondate, co.code, co.label, c.nom as label2"; //
+ $sql.=" FROM ".MAIN_DB_PREFIX."adherent as d";
+ $sql.=" LEFT JOIN ".MAIN_DB_PREFIX."c_departements as c on d.state_id = c.rowid";
$sql.=" LEFT JOIN ".MAIN_DB_PREFIX."c_regions as r on c.fk_region = r.code_region";
$sql.=" LEFT JOIN ".MAIN_DB_PREFIX."c_country as co on d.country = co.rowid";
+ $sql.=" LEFT JOIN ".MAIN_DB_PREFIX."subscription as s ON s.fk_adherent = d.rowid";
$sql.=" WHERE d.entity IN (".getEntity('adherent').")";
$sql.=" AND d.statut = 1";
$sql.=" GROUP BY co.label, co.code, c.nom";
@@ -108,10 +112,12 @@ if ($mode)
$tab='statsregion'; //onglet
$data = array(); //tableau de donnée
- $sql.="SELECT COUNT(d.rowid) as nb, MAX(d.datevalid) as lastdate, co.code, co.label, r.nom as label2";
- $sql.=" FROM ".MAIN_DB_PREFIX."adherent as d LEFT JOIN ".MAIN_DB_PREFIX."c_departements as c on d.state_id = c.rowid";
+ $sql.="SELECT COUNT(d.rowid) as nb, MAX(d.datevalid) as lastdate, MAX(s.dateadh) as lastsubscriptiondate, co.code, co.label, r.nom as label2";
+ $sql.=" FROM ".MAIN_DB_PREFIX."adherent as d";
+ $sql.=" LEFT JOIN ".MAIN_DB_PREFIX."c_departements as c on d.state_id = c.rowid";
$sql.=" LEFT JOIN ".MAIN_DB_PREFIX."c_regions as r on c.fk_region = r.code_region";
$sql.=" LEFT JOIN ".MAIN_DB_PREFIX."c_country as co on d.country = co.rowid";
+ $sql.=" LEFT JOIN ".MAIN_DB_PREFIX."subscription as s ON s.fk_adherent = d.rowid";
$sql.=" WHERE d.entity IN (".getEntity('adherent').")";
$sql.=" AND d.statut = 1";
$sql.=" GROUP BY co.label, co.code, r.nom"; //+
@@ -124,9 +130,10 @@ if ($mode)
$tab='statstown';
$data = array();
- $sql.="SELECT COUNT(d.rowid) as nb, MAX(d.datevalid) as lastdate, c.code, c.label, d.town as label2";
+ $sql.="SELECT COUNT(d.rowid) as nb, MAX(d.datevalid) as lastdate, MAX(s.dateadh) as lastsubscriptiondate, c.code, c.label, d.town as label2";
$sql.=" FROM ".MAIN_DB_PREFIX."adherent as d";
$sql.=" LEFT JOIN ".MAIN_DB_PREFIX."c_country as c on d.country = c.rowid";
+ $sql.=" LEFT JOIN ".MAIN_DB_PREFIX."subscription as s ON s.fk_adherent = d.rowid";
$sql.=" WHERE d.entity IN (".getEntity('adherent').")";
$sql.=" AND d.statut = 1";
$sql.=" GROUP BY c.label, c.code, d.town";
@@ -154,7 +161,8 @@ if ($mode)
'label_en'=>(($obj->code && $langsen->transnoentitiesnoconv("Country".$obj->code)!="Country".$obj->code)?$langsen->transnoentitiesnoconv("Country".$obj->code):($obj->label?$obj->label:$langs->trans("Unknown"))),
'code'=>$obj->code,
'nb'=>$obj->nb,
- 'lastdate'=>$db->jdate($obj->lastdate)
+ 'lastdate'=>$db->jdate($obj->lastdate),
+ 'lastsubscriptiondate'=>$db->jdate($obj->lastsubscriptiondate)
);
}
if ($mode == 'memberbyregion') //+
@@ -164,7 +172,8 @@ if ($mode)
'label_en'=>(($obj->code && $langsen->transnoentitiesnoconv("Country".$obj->code)!="Country".$obj->code)?$langsen->transnoentitiesnoconv("Country".$obj->code):($obj->label?$obj->label:$langs->trans("Unknown"))),
'label2'=>($obj->label2?$obj->label2:$langs->trans("Unknown")),
'nb'=>$obj->nb,
- 'lastdate'=>$db->jdate($obj->lastdate)
+ 'lastdate'=>$db->jdate($obj->lastdate),
+ 'lastsubscriptiondate'=>$db->jdate($obj->lastsubscriptiondate)
);
}
if ($mode == 'memberbystate')
@@ -173,7 +182,8 @@ if ($mode)
'label_en'=>(($obj->code && $langsen->transnoentitiesnoconv("Country".$obj->code)!="Country".$obj->code)?$langsen->transnoentitiesnoconv("Country".$obj->code):($obj->label?$obj->label:$langs->trans("Unknown"))),
'label2'=>($obj->label2?$obj->label2:$langs->trans("Unknown")),
'nb'=>$obj->nb,
- 'lastdate'=>$db->jdate($obj->lastdate)
+ 'lastdate'=>$db->jdate($obj->lastdate),
+ 'lastsubscriptiondate'=>$db->jdate($obj->lastsubscriptiondate)
);
}
if ($mode == 'memberbytown')
@@ -182,7 +192,8 @@ if ($mode)
'label_en'=>(($obj->code && $langsen->transnoentitiesnoconv("Country".$obj->code)!="Country".$obj->code)?$langsen->transnoentitiesnoconv("Country".$obj->code):($obj->label?$obj->label:$langs->trans("Unknown"))),
'label2'=>($obj->label2?$obj->label2:$langs->trans("Unknown")),
'nb'=>$obj->nb,
- 'lastdate'=>$db->jdate($obj->lastdate)
+ 'lastdate'=>$db->jdate($obj->lastdate),
+ 'lastsubscriptiondate'=>$db->jdate($obj->lastsubscriptiondate)
);
}
@@ -289,9 +300,9 @@ if ($mode)
if ($label2) print ''.$label2.' ';
print ''.$langs->trans("NbOfMembers").' ';
print ''.$langs->trans("LastMemberDate").' ';
+ print ''.$langs->trans("LatestSubscriptionDate").' ';
print '';
- $oldyear=0;
foreach ($data as $val)
{
$year = $val['year'];
@@ -300,8 +311,8 @@ if ($mode)
if ($label2) print ''.$val['label2'].' ';
print ''.$val['nb'].' ';
print ''.dol_print_date($val['lastdate'], 'dayhour').' ';
+ print ''.dol_print_date($val['lastsubscriptiondate'], 'dayhour').' ';
print '';
- $oldyear=$year;
}
print '';
diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php
index 11134f70194..541262b2bf5 100644
--- a/htdocs/admin/dict.php
+++ b/htdocs/admin/dict.php
@@ -1912,7 +1912,7 @@ function fieldList($fieldlist, $obj = '', $tabname = '', $context = '')
print ' ';
}
elseif ($fieldlist[$field] == 'code' && isset($obj->{$fieldlist[$field]})) {
- print ' ';
+ print ' ';
}
elseif ($fieldlist[$field]=='unit') {
print '';
diff --git a/htdocs/admin/system/filecheck.php b/htdocs/admin/system/filecheck.php
index a110e19b172..94d8909e063 100644
--- a/htdocs/admin/system/filecheck.php
+++ b/htdocs/admin/system/filecheck.php
@@ -339,8 +339,8 @@ if (! $error && $xml)
$out.=' '.$i.' ' . "\n";
$out.=''.$file['filename'];
if (! preg_match('/^win/i', PHP_OS)) {
- $htmltext=$langs->trans("YouCanDeleteFileOnServerWith", 'rm '.DOL_DOCUMENT_ROOT.'/'.$file['filename']);
- $out.=' '.$form->textwithpicto('', $htmltext, 1, 'help', '', 0, 2, 'helprm');
+ $htmltext=$langs->trans("YouCanDeleteFileOnServerWith", 'rm '.DOL_DOCUMENT_ROOT.$file['filename']); // The slash is included int file['filename']
+ $out.=' '.$form->textwithpicto('', $htmltext, 1, 'help', '', 0, 2, 'helprm'.$i);
}
$out.=' ' . "\n";
$out.=''.$file['expectedmd5'].' ' . "\n";
diff --git a/htdocs/bom/admin/setup.php b/htdocs/bom/admin/setup.php
index 561b44fa262..a484718ac32 100644
--- a/htdocs/bom/admin/setup.php
+++ b/htdocs/bom/admin/setup.php
@@ -1,6 +1,7 @@
- * Copyright (C) 2019 Maxime Kohlhaas
+/* Copyright (C) 2004-2017 Laurent Destailleur
+ * Copyright (C) 2019 Maxime Kohlhaas
+ * Copyright (C) 2019 Frédéric France
*
* 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
@@ -23,21 +24,7 @@
*/
// Load Dolibarr environment
-$res=0;
-// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined)
-if (! $res && ! empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res=@include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php";
-// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME
-$tmp=empty($_SERVER['SCRIPT_FILENAME'])?'':$_SERVER['SCRIPT_FILENAME'];$tmp2=realpath(__FILE__); $i=strlen($tmp)-1; $j=strlen($tmp2)-1;
-while($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i]==$tmp2[$j]) { $i--; $j--; }
-if (! $res && $i > 0 && file_exists(substr($tmp, 0, ($i+1))."/main.inc.php")) $res=@include substr($tmp, 0, ($i+1))."/main.inc.php";
-if (! $res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i+1)))."/main.inc.php")) $res=@include dirname(substr($tmp, 0, ($i+1)))."/main.inc.php";
-// Try main.inc.php using relative path
-if (! $res && file_exists("../../main.inc.php")) $res=@include "../../main.inc.php";
-if (! $res && file_exists("../../../main.inc.php")) $res=@include "../../../main.inc.php";
-if (! $res) die("Include of main fails");
-
-global $langs, $user;
-
+require '../../main.inc.php';
// Libraries
require_once DOL_DOCUMENT_ROOT . "/core/lib/admin.lib.php";
require_once '../lib/bom.lib.php';
@@ -62,11 +49,7 @@ $arrayofparameters=array(
/*
* Actions
*/
-if ((float) DOL_VERSION >= 6)
-{
- include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
-}
-
+include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
/*
* View
diff --git a/htdocs/bom/bom_card.php b/htdocs/bom/bom_card.php
index 0054e427996..19d7fdaa60b 100644
--- a/htdocs/bom/bom_card.php
+++ b/htdocs/bom/bom_card.php
@@ -1,6 +1,6 @@
- * Copyright (C) ---Put here your own copyright and developer email---
+/* Copyright (C) 2017 Laurent Destailleur
+ * Copyright (C) 2019 Frédéric France
*
* 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
@@ -17,50 +17,17 @@
*/
/**
- * \file bom_card.php
+ * \file htdocs/bom/bom_card.php
* \ingroup bom
* \brief Page to create/edit/view bom
*/
-//if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); // Do not create database handler $db
-//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); // Do not load object $user
-//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); // Do not load object $mysoc
-//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); // Do not load object $langs
-//if (! defined('NOSCANGETFORINJECTION')) define('NOSCANGETFORINJECTION','1'); // Do not check injection attack on GET parameters
-//if (! defined('NOSCANPOSTFORINJECTION')) define('NOSCANPOSTFORINJECTION','1'); // Do not check injection attack on POST parameters
-//if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK','1'); // Do not check CSRF attack (test on referer + on token if option MAIN_SECURITY_CSRF_WITH_TOKEN is on).
-//if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Do not roll the Anti CSRF token (used if MAIN_SECURITY_CSRF_WITH_TOKEN is on)
-//if (! defined('NOSTYLECHECK')) define('NOSTYLECHECK','1'); // Do not check style html tag into posted data
-//if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); // If there is no need to load and show top and left menu
-//if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); // If we don't need to load the html.form.class.php
-//if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); // Do not load ajax.lib.php library
-//if (! defined("NOLOGIN")) define("NOLOGIN",'1'); // If this page is public (can be called outside logged session). This include the NOIPCHECK too.
-//if (! defined('NOIPCHECK')) define('NOIPCHECK','1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip
-//if (! defined("MAIN_LANG_DEFAULT")) define('MAIN_LANG_DEFAULT','auto'); // Force lang to a particular value
-//if (! defined("MAIN_AUTHENTICATION_MODE")) define('MAIN_AUTHENTICATION_MODE','aloginmodule'); // Force authentication handler
-//if (! defined("NOREDIRECTBYMAINTOLOGIN")) define('NOREDIRECTBYMAINTOLOGIN',1); // The main.inc.php does not make a redirect if not logged, instead show simple error message
-//if (! defined("FORCECSP")) define('FORCECSP','none'); // Disable all Content Security Policies
-
-
// Load Dolibarr environment
-$res=0;
-// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined)
-if (! $res && ! empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res=@include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php";
-// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME
-$tmp=empty($_SERVER['SCRIPT_FILENAME'])?'':$_SERVER['SCRIPT_FILENAME'];$tmp2=realpath(__FILE__); $i=strlen($tmp)-1; $j=strlen($tmp2)-1;
-while($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i]==$tmp2[$j]) { $i--; $j--; }
-if (! $res && $i > 0 && file_exists(substr($tmp, 0, ($i+1))."/main.inc.php")) $res=@include substr($tmp, 0, ($i+1))."/main.inc.php";
-if (! $res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i+1)))."/main.inc.php")) $res=@include dirname(substr($tmp, 0, ($i+1)))."/main.inc.php";
-// Try main.inc.php using relative path
-if (! $res && file_exists("../main.inc.php")) $res=@include "../main.inc.php";
-if (! $res && file_exists("../../main.inc.php")) $res=@include "../../main.inc.php";
-if (! $res && file_exists("../../../main.inc.php")) $res=@include "../../../main.inc.php";
-if (! $res) die("Include of main fails");
-
+require '../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
-dol_include_once('/bom/class/bom.class.php');
-dol_include_once('/bom/lib/bom_bom.lib.php');
+require_once DOL_DOCUMENT_ROOT.'/bom/class/bom.class.php';
+require_once DOL_DOCUMENT_ROOT.'/bom/lib/bom_bom.lib.php';
// Load translation files required by the page
$langs->loadLangs(array("mrp","other"));
@@ -75,7 +42,7 @@ $contextpage= GETPOST('contextpage', 'aZ')?GETPOST('contextpage', 'aZ'):'bomcard
$backtopage = GETPOST('backtopage', 'alpha');
// Initialize technical objects
-$object=new BillOfMaterials($db);
+$object=new BOM($db);
$extrafields = new ExtraFields($db);
$diroutputmassaction=$conf->bom->dir_output . '/temp/massgeneration/'.$user->id;
$hookmanager->initHooks(array('bomcard', 'globalcard')); // Note that conf->hooks_modules contains array
@@ -119,10 +86,10 @@ if (empty($reshook))
$permissiontoadd = $user->rights->bom->write;
$permissiontodelete = $user->rights->bom->delete || ($permissiontoadd && $object->status == 0);
- $backurlforlist = dol_buildpath('/bom/bom_list.php', 1);
+ $backurlforlist = DOL_URL_ROOT.'/bom/bom_list.php';
if (empty($backtopage)) {
if (empty($id)) $backtopage = $backurlforlist;
- else $backtopage = dol_buildpath('/bom/bom_card.php', 1).($id > 0 ? $id : '__ID__');
+ else $backtopage = DOL_URL_ROOT.'/bom/bom_card.php?id='.$id;
}
$triggermodname = 'BILLOFMATERIALS_BILLOFMATERIALS_MODIFY'; // Name of trigger action code to execute when we modify record
diff --git a/htdocs/bom/bom_document.php b/htdocs/bom/bom_document.php
index b13277cd82b..ff8887bb4e8 100644
--- a/htdocs/bom/bom_document.php
+++ b/htdocs/bom/bom_document.php
@@ -1,6 +1,6 @@
- * Copyright (C) ---Put here your own copyright and developer email---
+/* Copyright (C) 2007-2017 Laurent Destailleur
+ * Copyright (C) 2019 Frédéric France
*
* 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
@@ -23,26 +23,13 @@
*/
// Load Dolibarr environment
-$res=0;
-// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined)
-if (! $res && ! empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res=@include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php";
-// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME
-$tmp=empty($_SERVER['SCRIPT_FILENAME'])?'':$_SERVER['SCRIPT_FILENAME'];$tmp2=realpath(__FILE__); $i=strlen($tmp)-1; $j=strlen($tmp2)-1;
-while($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i]==$tmp2[$j]) { $i--; $j--; }
-if (! $res && $i > 0 && file_exists(substr($tmp, 0, ($i+1))."/main.inc.php")) $res=@include substr($tmp, 0, ($i+1))."/main.inc.php";
-if (! $res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i+1)))."/main.inc.php")) $res=@include dirname(substr($tmp, 0, ($i+1)))."/main.inc.php";
-// Try main.inc.php using relative path
-if (! $res && file_exists("../main.inc.php")) $res=@include "../main.inc.php";
-if (! $res && file_exists("../../main.inc.php")) $res=@include "../../main.inc.php";
-if (! $res && file_exists("../../../main.inc.php")) $res=@include "../../../main.inc.php";
-if (! $res) die("Include of main fails");
-
+require '../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
-dol_include_once('/bom/class/bom.class.php');
-dol_include_once('/bom/lib/bom_bom.lib.php');
+require_once DOL_DOCUMENT_ROOT.'/bom/class/bom.class.php';
+require_once DOL_DOCUMENT_ROOT.'/bom/lib/bom_bom.lib.php';
// Load translation files required by the page
$langs->loadLangs(array("mrp","companies","other","mails"));
diff --git a/htdocs/bom/bom_list.php b/htdocs/bom/bom_list.php
index 25fad036b65..cf9ad7ffaf2 100644
--- a/htdocs/bom/bom_list.php
+++ b/htdocs/bom/bom_list.php
@@ -17,49 +17,16 @@
*/
/**
- * \file bom_list.php
+ * \file htdocs/bom/bom_list.php
* \ingroup bom
* \brief List page for bom
*/
-
-//if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); // Do not create database handler $db
-//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); // Do not load object $user
-//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); // Do not load object $mysoc
-//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); // Do not load object $langs
-//if (! defined('NOSCANGETFORINJECTION')) define('NOSCANGETFORINJECTION','1'); // Do not check injection attack on GET parameters
-//if (! defined('NOSCANPOSTFORINJECTION')) define('NOSCANPOSTFORINJECTION','1'); // Do not check injection attack on POST parameters
-//if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK','1'); // Do not check CSRF attack (test on referer + on token if option MAIN_SECURITY_CSRF_WITH_TOKEN is on).
-//if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Do not roll the Anti CSRF token (used if MAIN_SECURITY_CSRF_WITH_TOKEN is on)
-//if (! defined('NOSTYLECHECK')) define('NOSTYLECHECK','1'); // Do not check style html tag into posted data
-//if (! defined('NOIPCHECK')) define('NOIPCHECK','1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip
-//if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); // If there is no need to load and show top and left menu
-//if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); // If we don't need to load the html.form.class.php
-//if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); // Do not load ajax.lib.php library
-//if (! defined("NOLOGIN")) define("NOLOGIN",'1'); // If this page is public (can be called outside logged session)
-//if (! defined("MAIN_LANG_DEFAULT")) define('MAIN_LANG_DEFAULT','auto'); // Force lang to a particular value
-//if (! defined("MAIN_AUTHENTICATION_MODE")) define('MAIN_AUTHENTICATION_MODE','aloginmodule'); // Force authentication handler
-//if (! defined("NOREDIRECTBYMAINTOLOGIN")) define('NOREDIRECTBYMAINTOLOGIN',1); // The main.inc.php does not make a redirect if not logged, instead show simple error message
-//if (! defined("XFRAMEOPTIONS_ALLOWALL")) define('XFRAMEOPTIONS_ALLOWALL',1); // Do not add the HTTP header 'X-Frame-Options: SAMEORIGIN' but 'X-Frame-Options: ALLOWALL'
-
// Load Dolibarr environment
-$res=0;
-// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined)
-if (! $res && ! empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res=@include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php";
-// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME
-$tmp=empty($_SERVER['SCRIPT_FILENAME'])?'':$_SERVER['SCRIPT_FILENAME'];$tmp2=realpath(__FILE__); $i=strlen($tmp)-1; $j=strlen($tmp2)-1;
-while($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i]==$tmp2[$j]) { $i--; $j--; }
-if (! $res && $i > 0 && file_exists(substr($tmp, 0, ($i+1))."/main.inc.php")) $res=@include substr($tmp, 0, ($i+1))."/main.inc.php";
-if (! $res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i+1)))."/main.inc.php")) $res=@include dirname(substr($tmp, 0, ($i+1)))."/main.inc.php";
-// Try main.inc.php using relative path
-if (! $res && file_exists("../main.inc.php")) $res=@include "../main.inc.php";
-if (! $res && file_exists("../../main.inc.php")) $res=@include "../../main.inc.php";
-if (! $res && file_exists("../../../main.inc.php")) $res=@include "../../../main.inc.php";
-if (! $res) die("Include of main fails");
-
+require '../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
-dol_include_once('/bom/class/bom.class.php');
+require_once DOL_DOCUMENT_ROOT.'/bom/class/bom.class.php';
// Load translation files required by the page
$langs->loadLangs(array("mrp", "other"));
@@ -89,7 +56,7 @@ $pagenext = $page + 1;
//if (! $sortorder) $sortorder="DESC";
// Initialize technical objects
-$object = new BillOfMaterials($db);
+$object = new BOM($db);
$extrafields = new ExtraFields($db);
$diroutputmassaction = $conf->bom->dir_output . '/temp/massgeneration/'.$user->id;
$hookmanager->initHooks(array('bomlist')); // Note that conf->hooks_modules contains array
@@ -179,7 +146,7 @@ if (empty($reshook))
}
// Mass actions
- $objectclass='BillOfMaterials';
+ $objectclass='BOM';
$objectlabel='BillOfMaterials';
$permtoread = $user->rights->bom->read;
$permtodelete = $user->rights->bom->delete;
diff --git a/htdocs/bom/bom_note.php b/htdocs/bom/bom_note.php
index fb0d58509d7..4c45512c064 100644
--- a/htdocs/bom/bom_note.php
+++ b/htdocs/bom/bom_note.php
@@ -1,6 +1,6 @@
- * Copyright (C) ---Put here your own copyright and developer email---
+/* Copyright (C) 2007-2017 Laurent Destailleur
+ * Copyright (C) 2019 Frédéric France
*
* 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
@@ -23,22 +23,9 @@
*/
// Load Dolibarr environment
-$res=0;
-// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined)
-if (! $res && ! empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res=@include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php";
-// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME
-$tmp=empty($_SERVER['SCRIPT_FILENAME'])?'':$_SERVER['SCRIPT_FILENAME'];$tmp2=realpath(__FILE__); $i=strlen($tmp)-1; $j=strlen($tmp2)-1;
-while($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i]==$tmp2[$j]) { $i--; $j--; }
-if (! $res && $i > 0 && file_exists(substr($tmp, 0, ($i+1))."/main.inc.php")) $res=@include substr($tmp, 0, ($i+1))."/main.inc.php";
-if (! $res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i+1)))."/main.inc.php")) $res=@include dirname(substr($tmp, 0, ($i+1)))."/main.inc.php";
-// Try main.inc.php using relative path
-if (! $res && file_exists("../main.inc.php")) $res=@include "../main.inc.php";
-if (! $res && file_exists("../../main.inc.php")) $res=@include "../../main.inc.php";
-if (! $res && file_exists("../../../main.inc.php")) $res=@include "../../../main.inc.php";
-if (! $res) die("Include of main fails");
-
-dol_include_once('/bom/class/bom.class.php');
-dol_include_once('/bom/lib/bom_bom.lib.php');
+require '../main.inc.php';
+require_once DOL_DOCUMENT_ROOT.'/bom/class/bom.class.php';
+require_once DOL_DOCUMENT_ROOT.'/bom/lib/bom_bom.lib.php';
// Load translation files required by the page
$langs->loadLangs(array("mrp","companies"));
diff --git a/htdocs/bom/class/api_bom.class.php b/htdocs/bom/class/api_boms.class.php
similarity index 84%
rename from htdocs/bom/class/api_bom.class.php
rename to htdocs/bom/class/api_boms.class.php
index 4d13475be1a..adda9ceb238 100644
--- a/htdocs/bom/class/api_bom.class.php
+++ b/htdocs/bom/class/api_boms.class.php
@@ -18,12 +18,11 @@
use Luracast\Restler\RestException;
-dol_include_once('/bom/class/bom.class.php');
-
+require_once DOL_DOCUMENT_ROOT.'/bom/class/bom.class.php';
/**
- * \file bom/class/api_bom.class.php
+ * \file bom/class/api_boms.class.php
* \ingroup bom
* \brief File for API management of bom.
*/
@@ -31,36 +30,32 @@ dol_include_once('/bom/class/bom.class.php');
/**
* API class for bom bom
*
- * @smart-auto-routing false
* @access protected
* @class DolibarrApiAccess {@requires user,external}
*/
-class BillOfMaterialsApi extends DolibarrApi
+class BOMs extends DolibarrApi
{
/**
* @var array $FIELDS Mandatory fields, checked when create and update object
*/
static $FIELDS = array(
- 'name',
+ 'label'
);
/**
- * @var BillOfMaterials $bom {@type BillOfMaterials}
+ * @var BOM $bom {@type BOM}
*/
public $bom;
/**
* Constructor
- *
- * @url GET /
- *
*/
public function __construct()
{
global $db, $conf;
$this->db = $db;
- $this->bom = new BillOfMaterials($this->db);
+ $this->bom = new BOM($this->db);
}
/**
@@ -71,7 +66,7 @@ class BillOfMaterialsApi extends DolibarrApi
* @param int $id ID of bom
* @return array|mixed data without useless information
*
- * @url GET boms/{id}
+ * @url GET {id}
* @throws RestException
*/
public function get($id)
@@ -82,7 +77,7 @@ class BillOfMaterialsApi extends DolibarrApi
$result = $this->bom->fetch($id);
if( ! $result ) {
- throw new RestException(404, 'BillOfMaterials not found');
+ throw new RestException(404, 'BOM not found');
}
if( ! DolibarrApi::_checkAccessToResource('bom', $this->bom->id)) {
@@ -106,8 +101,6 @@ class BillOfMaterialsApi extends DolibarrApi
* @return array Array of order objects
*
* @throws RestException
- *
- * @url GET /boms/
*/
public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $sqlfilters = '')
{
@@ -134,7 +127,7 @@ class BillOfMaterialsApi extends DolibarrApi
//if ($mode == 1) $sql.= " AND s.client IN (1, 3)";
//if ($mode == 2) $sql.= " AND s.client IN (2, 3)";
- $tmpobject = new BillOfMaterials($db);
+ $tmpobject = new BOM($db);
if ($tmpobject->ismultientitymanaged) $sql.= ' AND t.entity IN ('.getEntity('bom').')';
if ($restictonsocid && (!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql.= " AND t.fk_soc = sc.fk_soc";
if ($restictonsocid && $socid) $sql.= " AND t.fk_soc = ".$socid;
@@ -172,7 +165,7 @@ class BillOfMaterialsApi extends DolibarrApi
while ($i < $num)
{
$obj = $db->fetch_object($result);
- $bom_static = new BillOfMaterials($db);
+ $bom_static = new BOM($db);
if($bom_static->fetch($obj->rowid)) {
$obj_ret[] = $this->_cleanObjectDatas($bom_static);
}
@@ -193,8 +186,6 @@ class BillOfMaterialsApi extends DolibarrApi
*
* @param array $request_data Request datas
* @return int ID of bom
- *
- * @url POST boms/
*/
public function post($request_data = null)
{
@@ -208,7 +199,7 @@ class BillOfMaterialsApi extends DolibarrApi
$this->bom->$field = $value;
}
if( ! $this->bom->create(DolibarrApiAccess::$user)) {
- throw new RestException(500);
+ throw new RestException(500, "Error creating BOM", array_merge(array($this->bom->error), $this->bom->errors));
}
return $this->bom->id;
}
@@ -218,9 +209,8 @@ class BillOfMaterialsApi extends DolibarrApi
*
* @param int $id Id of bom to update
* @param array $request_data Datas
- * @return int
*
- * @url PUT boms/{id}
+ * @return int
*/
public function put($id, $request_data = null)
{
@@ -230,7 +220,7 @@ class BillOfMaterialsApi extends DolibarrApi
$result = $this->bom->fetch($id);
if( ! $result ) {
- throw new RestException(404, 'BillOfMaterials not found');
+ throw new RestException(404, 'BOM not found');
}
if( ! DolibarrApi::_checkAccessToResource('bom', $this->bom->id)) {
@@ -238,46 +228,49 @@ class BillOfMaterialsApi extends DolibarrApi
}
foreach($request_data as $field => $value) {
+ if ($field == 'id') continue;
$this->bom->$field = $value;
}
- if($this->bom->update($id, DolibarrApiAccess::$user))
+ if($this->bom->update($id, DolibarrApiAccess::$user) > 0)
+ {
return $this->get($id);
-
- return false;
+ }
+ else
+ {
+ throw new RestException(500, $this->commande->error);
+ }
}
/**
* Delete bom
*
- * @param int $id BillOfMaterials ID
+ * @param int $id BOM ID
* @return array
- *
- * @url DELETE bom/{id}
*/
public function delete($id)
{
- if(! DolibarrApiAccess::$user->rights->bom->delete) {
+ if (! DolibarrApiAccess::$user->rights->bom->delete) {
throw new RestException(401);
}
$result = $this->bom->fetch($id);
- if( ! $result ) {
- throw new RestException(404, 'BillOfMaterials not found');
+ if (! $result) {
+ throw new RestException(404, 'BOM not found');
}
- if( ! DolibarrApi::_checkAccessToResource('bom', $this->bom->id)) {
+ if (! DolibarrApi::_checkAccessToResource('bom', $this->bom->id)) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
- if( !$this->bom->delete(DolibarrApiAccess::$user, 0))
+ if (! $this->bom->delete(DolibarrApiAccess::$user))
{
- throw new RestException(500);
+ throw new RestException(500, 'Error when deleting BOM : '.$this->bom->error);
}
return array(
'success' => array(
'code' => 200,
- 'message' => 'BillOfMaterials deleted'
+ 'message' => 'BOM deleted'
)
);
}
@@ -287,8 +280,8 @@ class BillOfMaterialsApi extends DolibarrApi
/**
* Clean sensible object datas
*
- * @param object $object Object to clean
- * @return array Array of cleaned object properties
+ * @param object $object Object to clean
+ * @return array Array of cleaned object properties
*/
protected function _cleanObjectDatas($object)
{
@@ -308,15 +301,15 @@ class BillOfMaterialsApi extends DolibarrApi
/**
* Validate fields before create or update object
*
- * @param array $data Data to validate
- * @return array
+ * @param array $data Array of data to validate
+ * @return array
*
- * @throws RestException
+ * @throws RestException
*/
private function _validate($data)
{
$bom = array();
- foreach (BillOfMaterialsApi::$FIELDS as $field) {
+ foreach (BOMs::$FIELDS as $field) {
if (!isset($data[$field]))
throw new RestException(400, "$field field missing");
$bom[$field] = $data[$field];
diff --git a/htdocs/bom/lib/bom.lib.php b/htdocs/bom/lib/bom.lib.php
index 0085d06b69c..20f9fccfb01 100644
--- a/htdocs/bom/lib/bom.lib.php
+++ b/htdocs/bom/lib/bom.lib.php
@@ -1,5 +1,6 @@
+/* Copyright (C) 2019 Maxime Kohlhaas
+ * Copyright (C) 2019 Frédéric France
*
* 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
@@ -16,7 +17,7 @@
*/
/**
- * \file bom/lib/bom.lib.php
+ * \file htdocs/bom/lib/bom.lib.php
* \ingroup bom
* \brief Library files with common functions for BillOfMaterials
*/
@@ -40,7 +41,7 @@ function bomAdminPrepareHead()
$head[$h][2] = 'settings';
$h++;
- /*$head[$h][0] = dol_buildpath("/bom/admin/about.php", 1);
+ /*$head[$h][0] = DOL_URL_ROOT."/bom/admin/about.php";
$head[$h][1] = $langs->trans("About");
$head[$h][2] = 'about';
$h++;
@@ -77,7 +78,7 @@ function bomPrepareHead($object)
$h = 0;
$head = array();
- $head[$h][0] = dol_buildpath("/bom/bom_card.php", 1).'?id='.$object->id;
+ $head[$h][0] = DOL_URL_ROOT."/bom/bom_card.php?id=".$object->id;
$head[$h][1] = $langs->trans("Card");
$head[$h][2] = 'card';
$h++;
@@ -87,7 +88,7 @@ function bomPrepareHead($object)
$nbNote = 0;
if (!empty($object->note_private)) $nbNote++;
if (!empty($object->note_public)) $nbNote++;
- $head[$h][0] = dol_buildpath('/bom/bom_note.php', 1).'?id='.$object->id;
+ $head[$h][0] = DOL_URL_ROOT.'/bom/bom_note.php?id='.$object->id;
$head[$h][1] = $langs->trans('Notes');
if ($nbNote > 0) $head[$h][1].= ' '.$nbNote.' ';
$head[$h][2] = 'note';
@@ -99,13 +100,13 @@ function bomPrepareHead($object)
$upload_dir = $conf->bom->dir_output . "/bom/" . dol_sanitizeFileName($object->ref);
$nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$'));
$nbLinks=Link::count($db, $object->element, $object->id);
- $head[$h][0] = dol_buildpath("/bom/bom_document.php", 1).'?id='.$object->id;
+ $head[$h][0] = DOL_URL_ROOT.'/bom/bom_document.php?id='.$object->id;
$head[$h][1] = $langs->trans('Documents');
if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' '.($nbFiles+$nbLinks).' ';
$head[$h][2] = 'document';
$h++;
- $head[$h][0] = dol_buildpath("/bom/bom_agenda.php", 1).'?id='.$object->id;
+ $head[$h][0] = DOL_URL_ROOT.'/bom/bom_agenda.php?id='.$object->id;
$head[$h][1] = $langs->trans("Events");
$head[$h][2] = 'agenda';
$h++;
diff --git a/htdocs/categories/edit.php b/htdocs/categories/edit.php
index a85c320a992..9416ddae748 100644
--- a/htdocs/categories/edit.php
+++ b/htdocs/categories/edit.php
@@ -81,6 +81,7 @@ if ($cancel)
// Action mise a jour d'une categorie
if ($action == 'update' && $user->rights->categorie->creer)
{
+ $object->oldcopy = dol_clone($object);
$object->label = $label;
$object->description = dol_htmlcleanlastbr($description);
$object->color = $color;
diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php
index 8458207a5d8..6ad881d141c 100644
--- a/htdocs/comm/action/card.php
+++ b/htdocs/comm/action/card.php
@@ -160,6 +160,10 @@ if ($action == 'confirm_clone' && $confirm == 'yes')
{
if ($id > 0) {
$object->fetch($id);
+ if (!empty($object->socpeopleassigned)) {
+ reset($object->socpeopleassigned);
+ $object->contactid = key($object->socpeopleassigned);
+ }
$result = $object->createFromClone(GETPOST('fk_userowner'), GETPOST('socid'));
if ($result > 0) {
header("Location: " . $_SERVER['PHP_SELF'] . '?id=' . $result);
@@ -431,6 +435,10 @@ if ($action == 'update')
$object->socpeopleassigned = array();
foreach ($socpeopleassigned as $cid) $object->socpeopleassigned[$cid] = array('id' => $cid);
$object->contactid = GETPOST("contactid", 'int');
+ if (empty($object->contactid) && !empty($object->socpeopleassigned)) {
+ reset($object->socpeopleassigned);
+ $object->contactid = key($object->socpeopleassigned);
+ }
$object->fk_project = GETPOST("projectid", 'int');
$object->note = GETPOST("note", "none"); // deprecated
$object->note_private= GETPOST("note", "none");
diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php
index fba891a848a..56e5e68b2f7 100644
--- a/htdocs/comm/action/class/actioncomm.class.php
+++ b/htdocs/comm/action/class/actioncomm.class.php
@@ -270,7 +270,7 @@ class ActionComm extends CommonObject
$this->userassigned[$tmpid]=array('id'=>$tmpid, 'transparency'=>$this->transparency);
}
- if (is_object($this->contact) && isset($this->contact->id) && $this->contact->id > 0 && ! ($this->contactid > 0)) $this->contactid = $this->contact->id; // For backward compatibility. Using this->contact->xx is deprecated
+ //if (is_object($this->contact) && isset($this->contact->id) && $this->contact->id > 0 && ! ($this->contactid > 0)) $this->contactid = $this->contact->id; // For backward compatibility. Using this->contact->xx is deprecated
$userownerid=$this->userownerid;
@@ -656,7 +656,7 @@ class ActionComm extends CommonObject
$this->fk_project = $obj->fk_project; // To have fetch_project method working
$this->societe->id = $obj->fk_soc; // deprecated
- $this->contact->id = $obj->fk_contact; // deprecated
+ //$this->contact->id = $obj->fk_contact; // deprecated
$this->fk_element = $obj->elementid;
$this->elementid = $obj->elementid;
@@ -867,7 +867,7 @@ class ActionComm extends CommonObject
}
$socid=($this->socid?$this->socid:((isset($this->societe->id) && $this->societe->id > 0) ? $this->societe->id : 0));
- $contactid=($this->contactid?$this->contactid:((isset($this->contact->id) && $this->contact->id > 0) ? $this->contact->id : 0));
+ $contactid=($this->contactid?$this->contactid:0);
$userownerid=($this->userownerid?$this->userownerid:0);
$userdoneid=($this->userdoneid?$this->userdoneid:0);
diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php
index 304eccf9bb7..ad5197512d4 100644
--- a/htdocs/comm/propal/class/propal.class.php
+++ b/htdocs/comm/propal/class/propal.class.php
@@ -3526,13 +3526,13 @@ class Propal extends CommonObject
if ($option == '') {
$url = DOL_URL_ROOT.'/comm/propal/card.php?id='.$this->id. $get_params;
}
- if ($option == 'compta') { // deprecated
+ elseif ($option == 'compta') { // deprecated
$url = DOL_URL_ROOT.'/comm/propal/card.php?id='.$this->id. $get_params;
}
- if ($option == 'expedition') {
+ elseif ($option == 'expedition') {
$url = DOL_URL_ROOT.'/expedition/propal.php?id='.$this->id. $get_params;
}
- if ($option == 'document') {
+ elseif ($option == 'document') {
$url = DOL_URL_ROOT.'/comm/propal/document.php?id='.$this->id. $get_params;
}
@@ -3646,68 +3646,68 @@ class PropaleLigne extends CommonObjectLine
*/
public $table_element='propaldet';
- var $oldline;
+ public $oldline;
// From llx_propaldet
- var $fk_propal;
- var $fk_parent_line;
- var $desc; // Description ligne
- var $fk_product; // Id produit predefini
+ public $fk_propal;
+ public $fk_parent_line;
+ public $desc; // Description ligne
+ public $fk_product; // Id produit predefini
/**
* @deprecated
* @see product_type
*/
- var $fk_product_type;
+ public $fk_product_type;
/**
* Product type.
* @var int
* @see Product::TYPE_PRODUCT, Product::TYPE_SERVICE
*/
- var $product_type = Product::TYPE_PRODUCT;
+ public $product_type = Product::TYPE_PRODUCT;
- var $qty;
- var $tva_tx;
- var $subprice;
- var $remise_percent;
- var $fk_remise_except;
+ public $qty;
+ public $tva_tx;
+ public $subprice;
+ public $remise_percent;
+ public $fk_remise_except;
- var $rang = 0;
+ public $rang = 0;
- var $fk_fournprice;
- var $pa_ht;
- var $marge_tx;
- var $marque_tx;
+ public $fk_fournprice;
+ public $pa_ht;
+ public $marge_tx;
+ public $marque_tx;
- var $special_code; // Tag for special lines (exlusive tags)
+ public $special_code; // Tag for special lines (exlusive tags)
// 1: frais de port
// 2: ecotaxe
// 3: option line (when qty = 0)
- var $info_bits = 0; // Liste d'options cumulables:
+ public $info_bits = 0; // Liste d'options cumulables:
// Bit 0: 0 si TVA normal - 1 si TVA NPR
// Bit 1: 0 ligne normale - 1 si ligne de remise fixe
- var $total_ht; // Total HT de la ligne toute quantite et incluant la remise ligne
- var $total_tva; // Total TVA de la ligne toute quantite et incluant la remise ligne
- var $total_ttc; // Total TTC de la ligne toute quantite et incluant la remise ligne
+ public $total_ht; // Total HT de la ligne toute quantite et incluant la remise ligne
+ public $total_tva; // Total TVA de la ligne toute quantite et incluant la remise ligne
+ public $total_ttc; // Total TTC de la ligne toute quantite et incluant la remise ligne
/**
* @deprecated
* @see $remise_percent, $fk_remise_except
*/
- var $remise;
+ public $remise;
/**
* @deprecated
* @see subprice
*/
- var $price;
+ public $price;
// From llx_product
/**
* @deprecated
* @see product_ref
*/
- var $ref;
+ public $ref;
/**
* Product reference
* @var string
@@ -3717,7 +3717,7 @@ class PropaleLigne extends CommonObjectLine
* @deprecated
* @see product_label
*/
- var $libelle;
+ public $libelle;
/**
* Product label
* @var string
@@ -3729,25 +3729,25 @@ class PropaleLigne extends CommonObjectLine
*/
public $product_desc;
- var $localtax1_tx; // Local tax 1
- var $localtax2_tx; // Local tax 2
- var $localtax1_type; // Local tax 1 type
- var $localtax2_type; // Local tax 2 type
- var $total_localtax1; // Line total local tax 1
- var $total_localtax2; // Line total local tax 2
+ public $localtax1_tx; // Local tax 1
+ public $localtax2_tx; // Local tax 2
+ public $localtax1_type; // Local tax 1 type
+ public $localtax2_type; // Local tax 2 type
+ public $total_localtax1; // Line total local tax 1
+ public $total_localtax2; // Line total local tax 2
- var $date_start;
- var $date_end;
+ public $date_start;
+ public $date_end;
- var $skip_update_total; // Skip update price total for special lines
+ public $skip_update_total; // Skip update price total for special lines
// Multicurrency
- var $fk_multicurrency;
- var $multicurrency_code;
- var $multicurrency_subprice;
- var $multicurrency_total_ht;
- var $multicurrency_total_tva;
- var $multicurrency_total_ttc;
+ public $fk_multicurrency;
+ public $multicurrency_code;
+ public $multicurrency_subprice;
+ public $multicurrency_total_ht;
+ public $multicurrency_total_tva;
+ public $multicurrency_total_ttc;
/**
* Class line Contructor
diff --git a/htdocs/commande/class/api_orders.class.php b/htdocs/commande/class/api_orders.class.php
index 24508d6fb11..ca7823a6ac1 100644
--- a/htdocs/commande/class/api_orders.class.php
+++ b/htdocs/commande/class/api_orders.class.php
@@ -16,9 +16,9 @@
* along with this program. If not, see .
*/
- use Luracast\Restler\RestException;
+use Luracast\Restler\RestException;
- require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
+require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
/**
* API class for orders
@@ -544,7 +544,7 @@ class Orders extends DolibarrApi
}
if( ! $this->commande->delete(DolibarrApiAccess::$user)) {
- throw new RestException(500, 'Error when delete order : '.$this->commande->error);
+ throw new RestException(500, 'Error when deleting order : '.$this->commande->error);
}
return array(
diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php
index 0f1b420f66e..01ef8b4c7c3 100644
--- a/htdocs/compta/facture/card.php
+++ b/htdocs/compta/facture/card.php
@@ -1131,7 +1131,7 @@ if (empty($reshook))
// Source facture
$object->fac_rec = GETPOST('fac_rec', 'int');
- $id = $object->create($user); // This include recopy of links from recurring invoice and invoice lines
+ $id = $object->create($user); // This include recopy of links from recurring invoice and recurring invoice lines
}
}
diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php
index 5e2db021f83..7b34ad4e895 100644
--- a/htdocs/compta/facture/class/facture.class.php
+++ b/htdocs/compta/facture/class/facture.class.php
@@ -723,7 +723,7 @@ class Facture extends CommonInvoice
}
/*
- * Insert lines of predefined invoices
+ * Insert lines of template invoices
*/
if (! $error && $this->fac_rec > 0)
{
@@ -749,7 +749,32 @@ class Facture extends CommonInvoice
$localtax1_tx = $_facrec->lines[$i]->localtax1_tx;
$localtax2_tx = $_facrec->lines[$i]->localtax2_tx;
- $result_insert = $this->addline(
+ $fk_product_fournisseur_price = empty($_facrec->lines[$i]->fk_product_fournisseur_price)?null:$_facrec->lines[$i]->fk_product_fournisseur_price;
+ $buyprice = empty($_facrec->lines[$i]->buyprice)?0:$_facrec->lines[$i]->buyprice;
+ // If buyprice not defined from template invoice, we try to guess the best value
+ if (! $buyprice && $_facrec->lines[$i]->fk_product > 0)
+ {
+ require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php';
+ $producttmp = new ProductFournisseur($this->db);
+ $producttmp->fetch($_facrec->lines[$i]->fk_product);
+
+ // If margin module defined on costprice, we try the costprice
+ // If not defined or if module margin defined and pmp and stock module enabled, we try pmp price
+ // else we get the best supplier price
+ if ($conf->global->MARGIN_TYPE == 'costprice' && ! empty($producttmp->cost_price)) $buyprice = $producttmp->cost_price;
+ elseif (! empty($conf->stock->enabled) && ($conf->global->MARGIN_TYPE == 'costprice' || $conf->global->MARGIN_TYPE == 'pmp') && ! empty($producttmp->pmp)) $buyprice = $producttmp->pmp;
+ else {
+ if ($producttmp->find_min_price_product_fournisseur($_facrec->lines[$i]->fk_product) > 0)
+ {
+ if ($producttmp->product_fourn_price_id > 0)
+ {
+ $buyprice = price2num($producttmp->fourn_unitprice * (1 - $producttmp->fourn_remise_percent/100) + $producttmp->fourn_remise, 'MU');
+ }
+ }
+ }
+ }
+
+ $result_insert = $this->addline(
$_facrec->lines[$i]->desc,
$_facrec->lines[$i]->subprice,
$_facrec->lines[$i]->qty,
@@ -771,8 +796,8 @@ class Facture extends CommonInvoice
'',
0,
0,
- null,
- 0,
+ $fk_product_fournisseur_price,
+ $buyprice,
$_facrec->lines[$i]->label,
empty($_facrec->lines[$i]->array_options)?null:$_facrec->lines[$i]->array_options,
$_facrec->lines[$i]->situation_percent,
@@ -4273,9 +4298,9 @@ class Facture extends CommonInvoice
/**
* Function used to replace a thirdparty id with another one.
*
- * @param DoliDB $db Database handler
- * @param int $origin_id Old thirdparty id
- * @param int $dest_id New thirdparty id
+ * @param DoliDB $db Database handler
+ * @param int $origin_id Old thirdparty id
+ * @param int $dest_id New thirdparty id
* @return bool
*/
public static function replaceThirdparty(DoliDB $db, $origin_id, $dest_id)
diff --git a/htdocs/core/class/CMailFile.class.php b/htdocs/core/class/CMailFile.class.php
index e23b32c5fb7..3c0e979cbed 100644
--- a/htdocs/core/class/CMailFile.class.php
+++ b/htdocs/core/class/CMailFile.class.php
@@ -1,11 +1,12 @@
- * Copyright (C) 2003 Jean-Louis Bergamo
- * Copyright (C) 2004-2015 Laurent Destailleur
- * Copyright (C) 2005-2012 Regis Houssin
+ * Copyright (C) Dan Potter
+ * Copyright (C) Eric Seigne
+ * Copyright (C) 2000-2005 Rodolphe Quiedeville
+ * Copyright (C) 2003 Jean-Louis Bergamo
+ * Copyright (C) 2004-2015 Laurent Destailleur
+ * Copyright (C) 2005-2012 Regis Houssin
+ * Copyright (C) 2019 Frédéric France
*
* 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
@@ -1429,7 +1430,7 @@ class CMailFile
* Return a formatted address string for SMTP protocol
*
* @param string $address Example: 'John Doe , Alan Smith ' or 'john@doe.com, alan@smith.com'
- * @param int $format 0=auto, 1=emails with <>, 2=emails without <>, 3=auto + label between "
+ * @param int $format 0=auto, 1=emails with <>, 2=emails without <>, 3=auto + label between ", 4 label or email, 5 mailto link
* @param int $encode 0=No encode name, 1=Encode name to RFC2822
* @param int $maxnumberofemail 0=No limit. Otherwise, maximum number of emails returned ($address may contains several email separated with ','). Add '...' if there is more.
* @return string If format 0: '' or 'John Doe ' or '=?UTF-8?B?Sm9obiBEb2U=?= '
@@ -1437,6 +1438,7 @@ class CMailFile
* If format 2: 'john@doe.com'
* If format 3: '' or '"John Doe" ' or '"=?UTF-8?B?Sm9obiBEb2U=?=" '
* If format 4: 'John Doe' or 'john@doe.com' if no label exists
+ * If format 5: John Doe or john@doe.com if no label exists
*/
public static function getValidAddress($address, $format, $encode = 0, $maxnumberofemail = 0)
{
@@ -1466,6 +1468,10 @@ class CMailFile
$i++;
$newemail='';
+ if ($format == 5) {
+ $newemail = $name?$name:$email;
+ $newemail = ''.$newemail.' ';
+ }
if ($format == 4)
{
$newemail = $name?$name:$email;
diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php
index f6232fd9394..e962e59264c 100644
--- a/htdocs/core/class/commonobject.class.php
+++ b/htdocs/core/class/commonobject.class.php
@@ -6378,6 +6378,7 @@ abstract class CommonObject
}
if (($mode == 'create' || $mode == 'edit') && abs($visibility) != 1 && abs($visibility) != 3) continue; // <> -1 and <> 1 and <> 3 = not visible on forms, only on list
+ elseif($mode == 'view' && empty($visibility)) continue;
if (empty($perms)) continue;
// Load language if required
diff --git a/htdocs/core/class/commonorder.class.php b/htdocs/core/class/commonorder.class.php
index 9d9445df91c..ddaef527630 100644
--- a/htdocs/core/class/commonorder.class.php
+++ b/htdocs/core/class/commonorder.class.php
@@ -82,7 +82,7 @@ abstract class CommonOrderLine extends CommonObjectLine
* @deprecated
* @see subprice
*/
- var $price;
+ public $price;
/**
* Unit price before taxes
diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php
index 5e875be176d..2577d70e549 100644
--- a/htdocs/core/class/html.formfile.class.php
+++ b/htdocs/core/class/html.formfile.class.php
@@ -682,6 +682,7 @@ class FormFile
// Model
if (! empty($modellist))
{
+ asort($modellist);
$out.= ''.$langs->trans('Model').' ';
if (is_array($modellist) && count($modellist) == 1) // If there is only one element
{
diff --git a/htdocs/core/class/stats.class.php b/htdocs/core/class/stats.class.php
index b35e9947644..b06f1deb4c3 100644
--- a/htdocs/core/class/stats.class.php
+++ b/htdocs/core/class/stats.class.php
@@ -29,9 +29,9 @@
*/
abstract class Stats
{
- protected $db;
- var $_lastfetchdate=array(); // Dates of cache file read by methods
- var $cachefilesuffix=''; // Suffix to add to name of cache file (to avoid file name conflicts)
+ protected $db;
+ private $_lastfetchdate=array(); // Dates of cache file read by methods
+ public $cachefilesuffix=''; // Suffix to add to name of cache file (to avoid file name conflicts)
/**
* Return nb of elements by month for several years
diff --git a/htdocs/core/db/mysqli.class.php b/htdocs/core/db/mysqli.class.php
index 6c3bfd2362f..1e244df883f 100644
--- a/htdocs/core/db/mysqli.class.php
+++ b/htdocs/core/db/mysqli.class.php
@@ -257,6 +257,7 @@ class DoliDBMysqli extends DoliDB
$query = trim($query);
if (! in_array($query, array('BEGIN','COMMIT','ROLLBACK'))) dol_syslog('sql='.$query, LOG_DEBUG);
+ if (empty($query)) return false; // Return false = error if empty request
if (! $this->database_name)
{
diff --git a/htdocs/core/lib/website.lib.php b/htdocs/core/lib/website.lib.php
index 40c12d302c9..972a271c140 100644
--- a/htdocs/core/lib/website.lib.php
+++ b/htdocs/core/lib/website.lib.php
@@ -22,7 +22,6 @@
*/
-
/**
* Convert a page content to have correct links (based on DOL_URL_ROOT) into an html content.
* Used to ouput the page on the Preview from backoffice.
@@ -661,7 +660,7 @@ function dolSavePageContent($filetpl, $object, $objectpage)
$tplcontent ='';
$tplcontent.= "trans("Home");
- if (! empty($conf->global->THEME_TOPMENU_DISABLE_IMAGE)) $titlehome = ' ';
- $menu->add('/index.php?mainmenu=home&leftmenu=home', $titlehome, 0, $showmode, $atarget, "home", '', 10, $id, $idsel, $classname);
+ $menu_arr[] = array(
+ 'name' => 'Home',
+ 'link' => '/index.php?mainmenu=home&leftmenu=home',
+ 'title' => (! empty($conf->global->THEME_TOPMENU_DISABLE_IMAGE)? ' ' : "Home") ,
+ 'level' => 0,
+ 'enabled' => $showmode = 1,
+ 'target' => $atarget,
+ 'mainmenu' => "home",
+ 'leftmenu' => '',
+ 'position' => 10,
+ 'id' => $id,
+ 'idsel' => 'home',
+ 'classname' => $classname = ( $_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "home" ) ? 'class="tmenusel"' : 'class="tmenu"',
+ 'prefix' => '',
+ 'session' => ( ( $_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "home" ) ? 0 : 1 ),
+ 'loadLangs' => array(),
+ 'submenus' => array(),
+ );
// Members
- $tmpentry = array(
- 'enabled'=>(! empty($conf->adherent->enabled)),
- 'perms'=>(! empty($user->rights->adherent->lire)),
- 'module'=>'adherent',
- );
- $showmode=isVisibleToUserType($type_user, $tmpentry, $listofmodulesforexternal);
- if ($showmode)
- {
- $classname="";
- if ($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "members") { $classname='class="tmenusel"'; $_SESSION['idmenu']=''; }
- else $classname = 'class="tmenu"';
- $idsel='members';
-
- $menu->add('/adherents/index.php?mainmenu=members&leftmenu=', $langs->trans("MenuMembers"), 0, $showmode, $atarget, "members", '', 18, $id, $idsel, $classname);
- }
+ $menu_arr[] = array(
+ 'name' => 'Members',
+ 'link' => '/adherents/index.php?mainmenu=members&leftmenu=',
+ 'title' => "MenuMembers",
+ 'level' => 0,
+ 'enabled' => $showmode = isVisibleToUserType(
+ $type_user,
+ $tmpentry = array(
+ 'enabled' => (! empty($conf->adherent->enabled) ) ,
+ 'perms' => (! empty($user->rights->adherent->lire) ),
+ 'module' => 'adherent',
+ ),
+ $listofmodulesforexternal
+ ),
+ 'target' => $atarget,
+ 'mainmenu' => "members",
+ 'leftmenu' => '',
+ 'position' => 18,
+ 'id' => $id,
+ 'idsel' => 'members',
+ 'classname' => $classname = ( $_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "members" ) ? 'class="tmenusel"' : 'class="tmenu"',
+ 'prefix' => '',
+ 'session' => ( ( $_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "members" ) ? 0 : 1 ),
+ 'loadLangs' => array(),
+ 'submenus' => array(),
+ );
// Third parties
- $tmpentry = array(
- 'enabled'=>(( ! empty($conf->societe->enabled) && (empty($conf->global->SOCIETE_DISABLE_PROSPECTS) || empty($conf->global->SOCIETE_DISABLE_CUSTOMERS))) || ! empty($conf->fournisseur->enabled)),
- 'perms'=>(! empty($user->rights->societe->lire) || ! empty($user->rights->fournisseur->lire)),
- 'module'=>'societe|fournisseur',
- );
- $showmode=isVisibleToUserType($type_user, $tmpentry, $listofmodulesforexternal);
- if ($showmode)
- {
- // Load translation files required by the page
- $langs->loadLangs(array("companies","suppliers"));
-
- $classname="";
- if ($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "companies") { $classname='class="tmenusel"'; $_SESSION['idmenu']=''; }
- else $classname = 'class="tmenu"';
- $idsel='companies';
-
- $menu->add('/societe/index.php?mainmenu=companies&leftmenu=', $langs->trans("ThirdParties"), 0, $showmode, $atarget, "companies", '', 20, $id, $idsel, $classname);
- }
+ $menu_arr[] = array(
+ 'name' => 'Companies',
+ 'link' => '/societe/index.php?mainmenu=companies&leftmenu=',
+ 'title' => "ThirdParties",
+ 'level' => 0,
+ 'enabled' => $showmode = isVisibleToUserType(
+ $type_user,
+ $tmpentry = array(
+ 'enabled'=> ( ( ! empty($conf->societe->enabled) &&
+ ( empty($conf->global->SOCIETE_DISABLE_PROSPECTS) || empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) )
+ )
+ || ! empty($conf->fournisseur->enabled)
+ ),
+ 'perms'=> (! empty($user->rights->societe->lire) || ! empty($user->rights->fournisseur->lire)),
+ 'module'=>'societe|fournisseur',
+ ),
+ $listofmodulesforexternal
+ ),
+ 'target' => $atarget,
+ 'mainmenu' => "companies",
+ 'leftmenu' => '',
+ 'position' => 20,
+ 'id' => $id,
+ 'idsel' => 'companies',
+ 'classname' => $classname = ( $_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "companies" ) ? 'class="tmenusel"' : 'class="tmenu"',
+ 'prefix' => '',
+ 'session' => ( ( $_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "companies" ) ? 0 : 1 ),
+ 'loadLangs' => array("companies","suppliers"),
+ 'submenus' => array(),
+ );
// Products-Services
- $tmpentry = array(
- 'enabled'=>(! empty($conf->product->enabled) || ! empty($conf->service->enabled)),
- 'perms'=>(! empty($user->rights->produit->lire) || ! empty($user->rights->service->lire)),
- 'module'=>'product|service',
- );
- $showmode=isVisibleToUserType($type_user, $tmpentry, $listofmodulesforexternal);
- if ($showmode)
- {
- $langs->load("products");
-
- $classname="";
- if ($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "products") { $classname='class="tmenusel"'; $_SESSION['idmenu']=''; }
- else $classname = 'class="tmenu"';
- $idsel='products';
-
- $chaine="";
- if (! empty($conf->product->enabled)) {
- $chaine.=$langs->trans("TMenuProducts");
- }
- if (! empty($conf->product->enabled) && ! empty($conf->service->enabled)) {
- $chaine.=" | ";
- }
- if (! empty($conf->service->enabled)) {
- $chaine.=$langs->trans("TMenuServices");
- }
-
- $menu->add('/product/index.php?mainmenu=products&leftmenu=', $chaine, 0, $showmode, $atarget, "products", '', 30, $id, $idsel, $classname);
- }
+ $menu_arr[] = array(
+ 'name' => 'Products',
+ 'link' => '/product/index.php?mainmenu=products&leftmenu=',
+ 'title' => (! empty($conf->product->enabled) && ! empty($conf->service->enabled))
+ ? ( array("TMenuProducts" , " | " ,"TMenuServices") )
+ : (! empty($conf->product->enabled)? "TMenuProducts" : "TMenuServices" ),
+ 'level' => 0,
+ 'enabled' => $showmode = isVisibleToUserType(
+ $type_user,
+ $tmpentry = array(
+ 'enabled'=> (( ! empty($conf->societe->enabled) &&
+ ( empty($conf->global->SOCIETE_DISABLE_PROSPECTS) || empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) )
+ )
+ || ! empty($conf->fournisseur->enabled)
+ ),
+ 'perms'=> (! empty($user->rights->societe->lire) || ! empty($user->rights->fournisseur->lire)),
+ 'module'=>'product|service',
+ ),
+ $listofmodulesforexternal
+ ),
+ 'target' => $atarget,
+ 'mainmenu' => "products",
+ 'leftmenu' => '',
+ 'position' => 30,
+ 'id' => $id,
+ 'idsel' => 'products',
+ 'classname' => $classname = ( $_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "products" ) ? 'class="tmenusel"' : 'class="tmenu"',
+ 'prefix' => '',
+ 'session' => ( ( $_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "products" ) ? 0 : 1 ),
+ 'loadLangs' => array("products"),
+ 'submenus' => array(),
+ );
// MRP
- $tmpentry = array(
- 'enabled'=>(! empty($conf->bom->enabled) || ! empty($conf->mrp->enabled)),
- 'perms'=>(! empty($user->rights->bom->read) || ! empty($user->rights->mrp->read)),
- 'module'=>'bom|mrp',
+ $menu_arr[] = array(
+ 'name' => 'TMenuMRP',
+ 'link' => '/bom/bom_list.php?mainmenu=mrp&leftmenu=',
+ 'title' => $langs->trans("TMenuMRP"),
+ 'level' => 0,
+ 'enabled' => $showmode = isVisibleToUserType(
+ $type_user,
+ $tmpentry = array(
+ 'enabled'=>(! empty($conf->bom->enabled) || ! empty($conf->mrp->enabled)),
+ 'perms'=>(! empty($user->rights->bom->read) || ! empty($user->rights->mrp->read)),
+ 'module'=>'bom|mrp',
+ ),
+ $listofmodulesforexternal
+ ),
+ 'target' => $atarget,
+ 'mainmenu' => "mrp",
+ 'leftmenu' => '',
+ 'position' => 30,
+ 'id' => $id,
+ 'idsel' => 'mrp',
+ 'classname' => $classname = ( $_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "project" ) ? 'class="tmenusel"' : 'class="tmenu"',
+ 'prefix' => '',
+ 'session' => ( ( $_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "project" ) ? 0 : 1 ),
+ 'loadLangs' => array("projects"),
+ 'submenus' => array(),
);
- $showmode=isVisibleToUserType($type_user, $tmpentry, $listofmodulesforexternal);
- if ($showmode)
- {
- $classname="";
- if ($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "mrp") { $classname='class="tmenusel"'; $_SESSION['idmenu']=''; }
- else $classname = 'class="tmenu"';
- $idsel='products';
-
- $chaine=$langs->trans("TMenuMRP");
-
- $menu->add('/bom/bom_list.php?mainmenu=mrp&leftmenu=', $chaine, 0, $showmode, $atarget, "bom", '', 30, $id, $idsel, $classname);
- }
// Projects
- $tmpentry=array('enabled'=>(! empty($conf->projet->enabled)),
- 'perms'=>(! empty($user->rights->projet->lire)),
- 'module'=>'projet');
- $showmode=isVisibleToUserType($type_user, $tmpentry, $listofmodulesforexternal);
- if ($showmode)
- {
- $langs->load("projects");
-
- $classname="";
- if ($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "project") { $classname='class="tmenusel"'; $_SESSION['idmenu']=''; }
- else $classname = 'class="tmenu"';
- $idsel='project';
-
- $title = $langs->trans("LeadsOrProjects"); // Leads and opportunities by default
- $showmodel = $showmodep = $showmode;
- if (empty($conf->global->PROJECT_USE_OPPORTUNITIES))
- {
- $title = $langs->trans("Projects");
- $showmodel = 0;
- }
- if ($conf->global->PROJECT_USE_OPPORTUNITIES == 2) {
- $title = $langs->trans("Leads");
- $showmodep = 0;
- }
-
- $menu->add('/projet/index.php?mainmenu=project&leftmenu=', $title, 0, $showmode, $atarget, "project", '', 35, $id, $idsel, $classname);
- //$menu->add('/projet/index.php?mainmenu=project&leftmenu=&search_opp_status=openedopp', $langs->trans("ListLeads"), 0, $showmodel & $conf->global->PROJECT_USE_OPPORTUNITIES, $atarget, "project", '', 70, $id, $idsel, $classname);
- //$menu->add('/projet/index.php?mainmenu=project&leftmenu=&search_opp_status=notopenedopp', $langs->trans("ListProjects"), 0, $showmodep, $atarget, "project", '', 70, $id, $idsel, $classname);
- }
+ $menu_arr[] = array(
+ 'name' => 'Projet',
+ 'link' => '/projet/index.php?mainmenu=project&leftmenu=',
+ 'title' => (empty($conf->global->PROJECT_USE_OPPORTUNITIES) || $conf->global->PROJECT_USE_OPPORTUNITIES == 2 )
+ ? (($conf->global->PROJECT_USE_OPPORTUNITIES == 2)?"Leads":"Projects")
+ : "LeadsOrProjects",
+ 'level' => 0,
+ 'enabled' => $showmode = isVisibleToUserType(
+ $type_user,
+ $tmpentry = array(
+ 'enabled'=> ( ! empty($conf->projet->enabled) ? 1 : 0),
+ 'perms'=> (! empty($user->rights->projet->lire) ? 1 : 0),
+ 'module'=>'projet',
+ ),
+ $listofmodulesforexternal
+ ),
+ 'target' => $atarget,
+ 'mainmenu' => "project",
+ 'leftmenu' => '',
+ 'position' => 35,
+ 'id' => $id,
+ 'idsel' => 'project',
+ 'classname' => $classname = ( $_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "project" ) ? 'class="tmenusel"' : 'class="tmenu"',
+ 'prefix' => '',
+ 'session' => ( ( $_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "project" ) ? 0 : 1 ),
+ 'loadLangs' => array("projects"),
+ 'submenus' => array(),
+ );
// Commercial
- $menuqualified=0;
- if (! empty($conf->propal->enabled)) $menuqualified++;
- if (! empty($conf->commande->enabled)) $menuqualified++;
- if (! empty($conf->supplier_order->enabled)) $menuqualified++;
- if (! empty($conf->supplier_proposal->enabled)) $menuqualified++;
- if (! empty($conf->contrat->enabled)) $menuqualified++;
- if (! empty($conf->ficheinter->enabled)) $menuqualified++;
- $tmpentry = array(
- 'enabled'=>$menuqualified,
- 'perms'=>(! empty($user->rights->societe->lire) || ! empty($user->rights->societe->contact->lire)),
- 'module'=>'propal|commande|supplier_order|contrat|ficheinter',
- );
- $showmode=isVisibleToUserType($type_user, $tmpentry, $listofmodulesforexternal);
- if ($showmode)
- {
- $langs->load("commercial");
-
- $classname="";
- if ($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "commercial") { $classname='class="tmenusel"'; $_SESSION['idmenu']=''; }
- else $classname = 'class="tmenu"';
- $idsel='commercial';
-
- $menu->add('/comm/index.php?mainmenu=commercial&leftmenu=', $langs->trans("Commercial"), 0, $showmode, $atarget, "commercial", "", 40, $id, $idsel, $classname);
- }
+ $menu_arr[] = array(
+ 'name' => 'Commercial',
+ 'link' => '/comm/index.php?mainmenu=commercial&leftmenu=',
+ 'title' => "Commercial",
+ 'level' => 0,
+ 'enabled' => $showmode = isVisibleToUserType(
+ $type_user,
+ $tmpentry = array(
+ 'enabled'=>(! empty($conf->propal->enabled) ||
+ ! empty($conf->commande->enabled) ||
+ ! empty($conf->supplier_order->enabled) ||
+ ! empty($conf->supplier_proposal->enabled) ||
+ ! empty($conf->contrat->enabled) ||
+ ! empty($conf->ficheinter->enabled)
+ )?1:0,
+ 'perms'=>(! empty($user->rights->societe->lire) || ! empty($user->rights->societe->contact->lire)),
+ 'module'=>'propal|commande|supplier_order|contrat|ficheinter',
+ ),
+ $listofmodulesforexternal
+ ),
+ 'target' => $atarget,
+ 'mainmenu' => "commercial",
+ 'leftmenu' => '',
+ 'position' => 40,
+ 'id' => $id,
+ 'idsel' => 'commercial',
+ 'classname' => $classname = ( $_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "commercial" ) ? 'class="tmenusel"' : 'class="tmenu"',
+ 'prefix' => '',
+ 'session' => ( ( $_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "commercial" ) ? 0 : 1 ),
+ 'loadLangs' => array("commercial"),
+ 'submenus' => array(),
+ );
// Billing - Financial
- $menuqualified=0;
- if (! empty($conf->facture->enabled)) $menuqualified++;
- if (! empty($conf->don->enabled)) $menuqualified++;
- if (! empty($conf->tax->enabled)) $menuqualified++;
- if (! empty($conf->salaries->enabled)) $menuqualified++;
- if (! empty($conf->supplier_invoice->enabled)) $menuqualified++;
- if (! empty($conf->loan->enabled)) $menuqualified++;
- $tmpentry = array(
- 'enabled'=>$menuqualified,
- 'perms'=>(! empty($user->rights->facture->lire) || ! empty($user->rights->don->lire) || ! empty($user->rights->tax->charges->lire) || ! empty($user->rights->salaries->read) || ! empty($user->rights->fournisseur->facture->lire) || ! empty($user->rights->loan->read)),
- 'module'=>'facture|supplier_invoice|don|tax|salaries|loan',
- );
- $showmode=isVisibleToUserType($type_user, $tmpentry, $listofmodulesforexternal);
- if ($showmode)
- {
- $langs->load("compta");
-
- $classname="";
- if ($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "billing") { $classname='class="tmenusel"'; $_SESSION['idmenu']=''; }
- else $classname = 'class="tmenu"';
- $idsel='billing';
-
- $menu->add('/compta/index.php?mainmenu=billing&leftmenu=', $langs->trans("MenuFinancial"), 0, $showmode, $atarget, "billing", '', 50, $id, $idsel, $classname);
- }
+ $menu_arr[] = array(
+ 'name' => 'Compta',
+ 'link' => '/compta/index.php?mainmenu=billing&leftmenu=',
+ 'title' => "MenuFinancial",
+ 'level' => 0,
+ 'enabled' => $showmode = isVisibleToUserType(
+ $type_user,
+ $tmpentry = array(
+ 'enabled'=>(! empty($conf->facture->enabled) ||
+ ! empty($conf->don->enabled) ||
+ ! empty($conf->tax->enabled) ||
+ ! empty($conf->salaries->enabled) ||
+ ! empty($conf->supplier_invoice->enabled) ||
+ ! empty($conf->loan->enabled)
+ )?1:0,
+ 'perms'=>(! empty($user->rights->facture->lire) || ! empty($user->rights->don->contact->lire)
+ || ! empty($user->rights->tax->charges->lire) || ! empty($user->rights->salaries->read)
+ || ! empty($user->rights->fournisseur->facture->lire) || ! empty($user->rights->loan->read)),
+ 'module'=>'facture|supplier_invoice|don|tax|salaries|loan',
+ ),
+ $listofmodulesforexternal
+ ),
+ 'target' => $atarget,
+ 'mainmenu' => "billing",
+ 'leftmenu' => '',
+ 'position' => 50,
+ 'id' => $id,
+ 'idsel' => 'billing',
+ 'classname' => $classname = ( $_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "billing" ) ? 'class="tmenusel"' : 'class="tmenu"',
+ 'prefix' => '',
+ 'session' => ( ( $_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "billing" ) ? 0 : 1 ),
+ 'loadLangs' => array("compta"),
+ 'submenus' => array(),
+ );
// Bank
- $tmpentry = array(
- 'enabled'=>(! empty($conf->banque->enabled) || ! empty($conf->prelevement->enabled)),
- 'perms'=>(! empty($user->rights->banque->lire) || ! empty($user->rights->prelevement->lire)),
- 'module'=>'banque|prelevement',
- );
- $showmode=isVisibleToUserType($type_user, $tmpentry, $listofmodulesforexternal);
- if ($showmode)
- {
- // Load translation files required by the page
- $langs->loadLangs(array("compta","banks"));
+ $menu_arr[] = array(
+ 'name' => 'Bank',
+ 'link' => '/compta/bank/list.php?mainmenu=bank&leftmenu=',
+ 'title' => "MenuBankCash",
+ 'level' => 0,
+ 'enabled' => $showmode = isVisibleToUserType(
+ $type_user,
+ $tmpentry = array(
+ 'enabled'=>(! empty($conf->banque->enabled) || ! empty($conf->prelevement->enabled)),
+ 'perms'=>(! empty($user->rights->banque->lire) || ! empty($user->rights->prelevement->lire)),
+ 'module'=>'banque|prelevement',
+ ),
+ $listofmodulesforexternal
+ ),
+ 'target' => $atarget,
+ 'mainmenu' => "bank",
+ 'leftmenu' => '',
+ 'position' => 52,
+ 'id' => $id,
+ 'idsel' => 'bank',
+ 'classname' => $classname = ( $_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "bank" ) ? 'class="tmenusel"' : 'class="tmenu"',
+ 'prefix' => '',
- $classname="";
- if ($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "bank") { $classname='class="tmenusel"'; $_SESSION['idmenu']=''; }
- else $classname = 'class="tmenu"';
- $idsel='bank';
+ 'session' => ( ( $_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "bank" ) ? 0 : 1 ),
- $menu->add('/compta/bank/list.php?mainmenu=bank&leftmenu=', $langs->trans("MenuBankCash"), 0, $showmode, $atarget, "bank", '', 52, $id, $idsel, $classname);
- }
+ 'loadLangs' => array("compta","banks"),
+ 'submenus' => array(),
+ );
// Accounting
- $menuqualified=0;
- if (! empty($conf->comptabilite->enabled)) $menuqualified++;
- if (! empty($conf->accounting->enabled)) $menuqualified++;
- if (! empty($conf->asset->enabled)) $menuqualified++;
- $tmpentry = array(
- 'enabled'=>$menuqualified,
- 'perms'=>(! empty($user->rights->compta->resultat->lire) || ! empty($user->rights->accounting->mouvements->lire) || ! empty($user->rights->asset->read)),
- 'module'=>'comptabilite|accounting',
- );
- $showmode=isVisibleToUserType($type_user, $tmpentry, $listofmodulesforexternal);
- if ($showmode)
- {
- $langs->load("compta");
+ $menu_arr[] = array(
+ 'name' => 'Accounting',
+ 'link' => '/accountancy/index.php?mainmenu=accountancy&leftmenu=',
+ 'title' => "MenuAccountancy",
+ 'level' => 0,
+ 'enabled' => $showmode = isVisibleToUserType(
+ $type_user,
+ $tmpentry = array(
+ 'enabled'=>(! empty($conf->comptabilite->enabled) || ! empty($conf->accounting->enabled) || ! empty($conf->asset->enabled)),
+ 'perms'=>(! empty($user->rights->compta->resultat->lire) || ! empty($user->rights->accounting->mouvements->lire) || ! empty($user->rights->asset->read)),
+ 'comptabilite|accounting',
+ ),
+ $listofmodulesforexternal
+ ),
+ 'target' => $atarget,
+ 'mainmenu' => "accountancy",
+ 'leftmenu' => '',
+ 'position' => 54,
+ 'id' => $id,
+ 'idsel' => 'accountancy',
+ 'classname' => $classname = ( $_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "accountancy" ) ? 'class="tmenusel"' : 'class="tmenu"',
+ 'prefix' => '',
- $classname="";
- if ($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "accountancy") { $classname='class="tmenusel"'; $_SESSION['idmenu']=''; }
- else $classname = 'class="tmenu"';
- $idsel='accountancy';
+ 'session' => ( ( $_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "accountancy" ) ? 0 : 1 ),
- $menu->add('/accountancy/index.php?mainmenu=accountancy&leftmenu=', $langs->trans("MenuAccountancy"), 0, $showmode, $atarget, "accountancy", '', 54, $id, $idsel, $classname);
- }
+ 'loadLangs' => array("compta"),
+ 'submenus' => array(),
+ );
// HRM
- $tmpentry = array(
- 'enabled'=>(! empty($conf->hrm->enabled) || ! empty($conf->holiday->enabled) || ! empty($conf->deplacement->enabled) || ! empty($conf->expensereport->enabled)),
- 'perms'=>(! empty($user->rights->hrm->employee->read) || ! empty($user->rights->holiday->write) || ! empty($user->rights->deplacement->lire) || ! empty($user->rights->expensereport->lire)),
- 'module'=>'hrm|holiday|deplacement|expensereport',
- );
- $showmode=isVisibleToUserType($type_user, $tmpentry, $listofmodulesforexternal);
- if ($showmode)
- {
- $langs->load("holiday");
+ $menu_arr[] = array(
+ 'name' => 'HRM',
+ 'link' => '/hrm/index.php?mainmenu=hrm&leftmenu=',
+ 'title' => "HRM",
+ 'level' => 0,
+ 'enabled' => $showmode = isVisibleToUserType(
+ $type_user,
+ $tmpentry = array(
+ 'enabled'=>(! empty($conf->hrm->enabled) || ! empty($conf->holiday->enabled) || ! empty($conf->deplacement->enabled) || ! empty($conf->expensereport->enabled)),
+ 'perms'=>(! empty($user->rights->hrm->employee->read) || ! empty($user->rights->holiday->write) || ! empty($user->rights->deplacement->lire) || ! empty($user->rights->expensereport->lire)),
+ 'module'=>'hrm|holiday|deplacement|expensereport',
+ ),
+ $listofmodulesforexternal
+ ),
+ 'target' => $atarget,
+ 'mainmenu' => "hrm",
+ 'leftmenu' => '',
+ 'position' => 80,
+ 'id' => $id,
+ 'idsel' => 'hrm',
+ 'classname' => $classname = ( $_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "hrm" ) ? 'class="tmenusel"' : 'class="tmenu"',
+ 'prefix' => '',
- $classname="";
- if ($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "hrm") { $classname='class="tmenusel"'; $_SESSION['idmenu']=''; }
- else $classname = 'class="tmenu"';
- $idsel='hrm';
+ 'session' => ( ( $_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "hrm" ) ? 0 : 1 ),
- $menu->add('/hrm/index.php?mainmenu=hrm&leftmenu=', $langs->trans("HRM"), 0, $showmode, $atarget, "hrm", '', 80, $id, $idsel, $classname);
- }
+ 'loadLangs' => array("holiday"),
+ 'submenus' => array(),
+ );
// Tools
- $tmpentry = array(
- 'enabled'=>1,
- 'perms'=>1,
- 'module'=>'',
- );
- $showmode=isVisibleToUserType($type_user, $tmpentry, $listofmodulesforexternal);
- if ($showmode)
+ $menu_arr[] = array(
+ 'name' => 'Tools',
+ 'link' => '/core/tools.php?mainmenu=tools&leftmenu=',
+ 'title' => "Tools",
+ 'level' => 0,
+ 'enabled' => $showmode = isVisibleToUserType(
+ $type_user,
+ $tmpentry = array(
+ 'enabled'=>1,
+ 'perms'=>1,
+ 'module'=>'',
+ ),
+ $listofmodulesforexternal
+ ),
+ 'target' => $atarget,
+ 'mainmenu' => "tools",
+ 'leftmenu' => '',
+ 'position' => 90,
+ 'id' => $id,
+ 'idsel' => 'tools',
+ 'classname' => $classname = ( $_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "tools" ) ? 'class="tmenusel"' : 'class="tmenu"',
+ 'prefix' => '',
+
+ 'session' => ( ( $_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "tools" ) ? 0 : 1 ),
+
+ 'loadLangs' => array("other"),
+ 'submenus' => array(),
+ );
+
+ // Add menus
+ foreach($menu_arr as $key => $smenu)
{
- $langs->load("other");
+ $smenu = (object) $smenu;
- $classname="";
- if ($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "tools") { $classname='class="tmenusel"'; $_SESSION['idmenu']=''; }
- else $classname = 'class="tmenu"';
- $idsel='tools';
+ if( $smenu->enabled )
+ {
+ if($langs->session)
+ {
+ $_SESSION['idmenu']='';
+ }
- $menu->add('/core/tools.php?mainmenu=tools&leftmenu=', $langs->trans("Tools"), 0, $showmode, $atarget, "tools", '', 90, $id, $idsel, $classname);
+ // Load Langue
+ if(! empty($smenu->loadLangs))
+ {
+ $langs->loadLangs($smenu->loadLangs);
+ }
+
+ // Trans title
+ $mtitle = '';
+ if(is_array($smenu->title))
+ {
+ foreach($smenu->title as $item)
+ {
+ $mtitle .= $langs->trans($item);
+ }
+ }
+ else
+ {
+ $mtitle = $langs->trans($smenu->title);
+ }
+ // Add item
+ $menu->add($smenu->link, $mtitle, $smenu->level, $smenu->enabled, $smenu->target, $smenu->mainmenu, $smenu->leftmenu, $smenu->position, $smenu->id, $smenu->idsel, $smenu->classname, $smenu->prefix);
+ }
}
// Show personalized menus
diff --git a/htdocs/core/modules/export/export_csv.modules.php b/htdocs/core/modules/export/export_csv.modules.php
index 249d1563988..5bdc2f384ac 100644
--- a/htdocs/core/modules/export/export_csv.modules.php
+++ b/htdocs/core/modules/export/export_csv.modules.php
@@ -24,6 +24,8 @@
require_once DOL_DOCUMENT_ROOT .'/core/modules/export/modules_export.php';
+// avoid timeout for big export
+set_time_limit(0);
/**
* Class to build export files with format CSV
diff --git a/htdocs/core/modules/syslog/mod_syslog_chromephp.php b/htdocs/core/modules/syslog/mod_syslog_chromephp.php
index 8ace164fce6..f3d34c4a9cd 100644
--- a/htdocs/core/modules/syslog/mod_syslog_chromephp.php
+++ b/htdocs/core/modules/syslog/mod_syslog_chromephp.php
@@ -7,7 +7,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/modules/syslog/logHandler.php';
*/
class mod_syslog_chromephp extends LogHandler implements LogHandlerInterface
{
- var $code = 'chromephp';
+ public $code = 'chromephp';
/**
* Return name of logger
@@ -50,7 +50,7 @@ class mod_syslog_chromephp extends LogHandler implements LogHandlerInterface
return ($this->isActive() == 1)?'':$langs->trans('ClassNotFoundIntoPathWarning', 'ChromePhp.class.php');
}
-
+
/**
* Is the module active ?
*
@@ -159,7 +159,7 @@ class mod_syslog_chromephp extends LogHandler implements LogHandlerInterface
$res = @include_once 'ChromePhp.php';
if (! $res) $res=@include_once 'ChromePhp.class.php';
set_include_path($oldinclude);
-
+
ob_start(); // To be sure headers are not flushed until all page is completely processed
if ($content['level'] == LOG_ERR) ChromePhp::error($content['message']);
elseif ($content['level'] == LOG_WARNING) ChromePhp::warn($content['message']);
diff --git a/htdocs/core/modules/syslog/mod_syslog_file.php b/htdocs/core/modules/syslog/mod_syslog_file.php
index ced2cf9133b..4c59eb5ef98 100644
--- a/htdocs/core/modules/syslog/mod_syslog_file.php
+++ b/htdocs/core/modules/syslog/mod_syslog_file.php
@@ -7,8 +7,8 @@ require_once DOL_DOCUMENT_ROOT.'/core/modules/syslog/logHandler.php';
*/
class mod_syslog_file extends LogHandler implements LogHandlerInterface
{
- var $code = 'file';
- var $lastTime = 0;
+ public $code = 'file';
+ public $lastTime = 0;
/**
* Return name of logger
diff --git a/htdocs/core/modules/syslog/mod_syslog_syslog.php b/htdocs/core/modules/syslog/mod_syslog_syslog.php
index 26232e91ed5..97a37ff2c8a 100644
--- a/htdocs/core/modules/syslog/mod_syslog_syslog.php
+++ b/htdocs/core/modules/syslog/mod_syslog_syslog.php
@@ -7,7 +7,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/modules/syslog/logHandler.php';
*/
class mod_syslog_syslog extends LogHandler implements LogHandlerInterface
{
- var $code = 'syslog';
+ public $code = 'syslog';
/**
* Return name of logger
diff --git a/htdocs/core/tpl/objectline_create.tpl.php b/htdocs/core/tpl/objectline_create.tpl.php
index 8b577b71bcc..2cc990056da 100644
--- a/htdocs/core/tpl/objectline_create.tpl.php
+++ b/htdocs/core/tpl/objectline_create.tpl.php
@@ -596,6 +596,28 @@ if (! empty($usemargins) && $user->rights->margins->creer)
/* JQuery for product free or predefined select */
jQuery(document).ready(function() {
+ jQuery("#price_ht").keyup(function(event) {
+ // console.log(event.which); // discard event tag and arrows
+ if (event.which != 9 && (event.which < 37 ||event.which > 40) && jQuery("#price_ht").val() != '') {
+ jQuery("#price_ttc").val('');
+ jQuery("#multicurrency_subprice").val('');
+ }
+ });
+ jQuery("#price_ttc").keyup(function(event) {
+ // console.log(event.which); // discard event tag and arrows
+ if (event.which != 9 && (event.which < 37 || event.which > 40) && jQuery("#price_ttc").val() != '') {
+ jQuery("#price_ht").val('');
+ jQuery("#multicurrency_subprice").val('');
+ }
+ });
+ jQuery("#multicurrency_subprice").keyup(function(event) {
+ // console.log(event.which); // discard event tag and arrows
+ if (event.which != 9 && (event.which < 37 || event.which > 40) && jQuery("#price_ttc").val() != '') {
+ jQuery("#price_ht").val('');
+ jQuery("#price_ttc").val('');
+ }
+ });
+
$("#prod_entry_mode_free").on( "click", function() {
setforfree();
});
@@ -662,10 +684,7 @@ jQuery(document).ready(function() {
$.post('/fourn/ajax/getSupplierPrices.php?bestpricefirst=1', { 'idprod': $(this).val() }, function(data) {
if (data && data.length > 0)
{
- var options = '';
- var defaultkey = '';
- var defaultprice = '';
- var bestpricefound = 0;
+ var options = ''; var defaultkey = ''; var defaultprice = ''; var bestpricefound = 0;
var bestpriceid = 0; var bestpricevalue = 0;
var pmppriceid = 0; var pmppricevalue = 0;
@@ -796,61 +815,29 @@ jQuery(document).ready(function() {
setforpredef();
-
});
/* Function to set fields from choice */
function setforfree() {
console.log("Call setforfree. We show most fields");
- jQuery("#search_idprod").val('');
- jQuery("#idprod").val('');
jQuery("#idprodfournprice").val('0'); // Set cursor on not selected product
- jQuery("#search_idprodfournprice").val('');
jQuery("#prod_entry_mode_free").prop('checked',true).change();
jQuery("#prod_entry_mode_predef").prop('checked',false).change();
- jQuery("#price_ht").show();
- jQuery("#multicurrency_price_ht").show();
- jQuery("#price_ttc").show(); // May not exist
- jQuery("#fourn_ref").show();
- jQuery("#tva_tx").show();
- jQuery("#buying_price").val('').show();
+ jQuery("#search_idprod, #idprod, #search_idprodfournprice, #buying_price").val('');
+ jQuery("#price_ht, #multicurrency_price_ht, #price_ttc, #price_ttc, #fourn_ref, #tva_tx, #buying_price, #title_vat, #title_up_ht, #title_up_ht_currency, #title_up_ttc, #title_up_ttc_currency").show();
+ jQuery("#np_marginRate, #np_markRate, .np_marginRate, .np_markRate, #units, #title_units").show();
jQuery("#fournprice_predef").hide();
- jQuery("#title_vat").show();
- jQuery("#title_up_ht").show();
- jQuery("#title_up_ht_currency").show();
- jQuery("#title_up_ttc").show();
- jQuery("#title_up_ttc_currency").show();
- jQuery("#np_marginRate").show(); // May not exist
- jQuery("#np_markRate").show(); // May not exist
- jQuery(".np_marginRate").show(); // May not exist
- jQuery(".np_markRate").show(); // May not exist
- jQuery("#units, #title_units").show();
}
function setforpredef() {
console.log("Call setforpredef. We hide some fields and show dates");
jQuery("#select_type").val(-1);
-
jQuery("#prod_entry_mode_free").prop('checked',false).change();
jQuery("#prod_entry_mode_predef").prop('checked',true).change();
- jQuery("#price_ht").val('').hide();
- jQuery("#multicurrency_price_ht").hide();
- jQuery("#price_ttc").hide(); // May not exist
- jQuery("#fourn_ref").hide();
- jQuery("#tva_tx").hide();
+ jQuery("#price_ht").val('')
+ jQuery("#price_ht, #multicurrency_price_ht, #price_ttc, #fourn_ref, #tva_tx, #title_vat, #title_up_ht, #title_up_ht_currency, #title_up_ttc, #title_up_ttc_currency").hide();
+ jQuery("#np_marginRate, #np_markRate, .np_marginRate, .np_markRate, #units, #title_units").hide();
jQuery("#buying_price").show();
- jQuery("#title_vat").hide();
- jQuery("#title_up_ht").hide();
- jQuery("#title_up_ht_currency").hide();
- jQuery("#title_up_ttc").hide();
- jQuery("#title_up_ttc_currency").hide();
- jQuery("#np_marginRate").hide(); // May not exist
- jQuery("#np_markRate").hide(); // May not exist
- jQuery(".np_marginRate").hide(); // May not exist
- jQuery(".np_markRate").hide(); // May not exist
- jQuery("#units, #title_units").hide();
-
- jQuery('#trlinefordates').show();
- jQuery('.divlinefordates').show();
+ jQuery('#trlinefordates, .divlinefordates').show();
}
diff --git a/htdocs/expensereport/card.php b/htdocs/expensereport/card.php
index 2ce6ca0f70a..3c7253f9065 100644
--- a/htdocs/expensereport/card.php
+++ b/htdocs/expensereport/card.php
@@ -133,6 +133,7 @@ if (empty($reshook))
$date='';
$comments='';
$vatrate='';
+ $value_unit_ht='';
$value_unit='';
$qty=1;
$fk_c_type_fees=-1;
@@ -1095,10 +1096,16 @@ if (empty($reshook))
// if VAT is not used in Dolibarr, set VAT rate to 0 because VAT rate is necessary.
if (empty($vatrate)) $vatrate = "0.000";
- $vatrate = price2num($vatrate);
+ $tmpvat = price2num(preg_replace('/\s*\(.*\)/', '', $vatrate));
+ $value_unit_ht=price2num(GETPOST('value_unit_ht', 'alpha'), 'MU');
$value_unit=price2num(GETPOST('value_unit', 'alpha'), 'MU');
- $fk_c_exp_tax_cat = GETPOST('fk_c_exp_tax_cat', 'int');
+ if (empty($value_unit))
+ {
+ $value_unit = price2num($value_unit_ht + ($value_unit_ht * $tmpvat / 100), 'MU');
+ }
+
+ $fk_c_exp_tax_cat = GETPOST('fk_c_exp_tax_cat', 'int');
$qty = GETPOST('qty', 'int');
if (empty($qty)) $qty=1;
@@ -1110,23 +1117,13 @@ if (empty($reshook))
$action='';
}
- if ($vatrate < 0 || $vatrate == '')
+ if ((int) $tmpvat < 0 || $tmpvat == '')
{
$error++;
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("VAT")), null, 'errors');
$action='';
}
- /* Projects are never required. To force them, check module forceproject
- if ($conf->projet->enabled)
- {
- if (empty($object_ligne->fk_projet) || $object_ligne->fk_projet==-1)
- {
- $error++;
- setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Project")), null, 'errors');
- }
- }*/
-
// Si aucune date n'est rentrée
if (empty($date) || $date=="--")
{
@@ -1134,7 +1131,7 @@ if (empty($reshook))
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Date")), null, 'errors');
}
// Si aucun prix n'est rentré
- if ($value_unit==0)
+ if ($value_unit == 0)
{
$error++;
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("PriceUTTC")), null, 'errors');
@@ -1171,6 +1168,7 @@ if (empty($reshook))
}
unset($qty);
+ unset($value_unit_ht);
unset($value_unit);
unset($vatrate);
unset($comments);
@@ -1240,12 +1238,18 @@ if (empty($reshook))
$projet_id = $fk_projet;
$comments = GETPOST('comments', 'none');
$qty = GETPOST('qty', 'int');
- $value_unit = price2num(GETPOST('value_unit', 'alpha'), 'MU');
$vatrate = GETPOST('vatrate', 'alpha');
- // if VAT is not used in Dolibarr, set VAT rate to 0 because VAT rate is necessary.
- if (empty($vatrate)) $vatrate = "0.000";
- $vatrate = price2num($vatrate);
+ // if VAT is not used in Dolibarr, set VAT rate to 0 because VAT rate is necessary.
+ if (empty($vatrate)) $vatrate = "0.000";
+ $tmpvat = price2num(preg_replace('/\s*\(.*\)/', '', $vatrate));
+
+ $value_unit_ht=price2num(GETPOST('value_unit_ht', 'alpha'), 'MU');
+ $value_unit=price2num(GETPOST('value_unit', 'alpha'), 'MU');
+ if (empty($value_unit))
+ {
+ $value_unit = price2num($value_unit_ht + ($value_unit_ht * $tmpvat / 100), 'MU');
+ }
if (! GETPOST('fk_c_type_fees', 'int') > 0)
{
@@ -1253,7 +1257,7 @@ if (empty($reshook))
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")), null, 'errors');
$action='';
}
- if ((int) $vatrate < 0 || $vatrate == '')
+ if ((int) $tmpvat < 0 || $tmpvat == '')
{
$error++;
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Vat")), null, 'errors');
@@ -1742,7 +1746,7 @@ else
print '';
// User to inform for approval
- if ($object->fk_statut < 3) // informed
+ if ($object->fk_statut <= ExpenseReport::STATUS_VALIDATED) // informed
{
print '';
print ''.$langs->trans("VALIDATOR").' '; // approver
@@ -1760,7 +1764,7 @@ else
}
print ' ';
}
- elseif($object->fk_statut == 4)
+ elseif($object->fk_statut == ExpenseReport::STATUS_CANCELED)
{
print '';
print ''.$langs->trans("CANCEL_USER").' ';
@@ -1854,11 +1858,11 @@ else
print ''.$langs->trans("AmountHT").' ';
print ''.price($object->total_ht, 1, '', 1, - 1, - 1, $conf->currency).' ';
$rowspan = 5;
- if ($object->fk_statut < 3) $rowspan++;
- elseif($object->fk_statut == 4) $rowspan+=2;
+ if ($object->fk_statut <= ExpenseReport::STATUS_VALIDATED) $rowspan++;
+ elseif($object->fk_statut == ExpenseReport::STATUS_CANCELED) $rowspan+=2;
else $rowspan+=2;
- if ($object->fk_statut==99 || !empty($object->detail_refuse)) $rowspan+=2;
- if($object->fk_statut==6) $rowspan+=2;
+ if ($object->fk_statut == ExpenseReport::STATUS_REFUSED || !empty($object->detail_refuse)) $rowspan+=2;
+ if ($object->fk_statut == ExpenseReport::STATUS_CLOSED) $rowspan+=2;
print "";
print ' ';
@@ -2016,6 +2020,7 @@ else
print ''.$langs->trans('Type').' ';
print ''.$langs->trans('Description').' ';
print ''.$langs->trans('VAT').' ';
+ print ''.$langs->trans('PriceUHT').' ';
print ''.$langs->trans('PriceUTTC').' ';
print ''.$langs->trans('Qty').' ';
if ($action != 'editline')
@@ -2071,6 +2076,7 @@ else
print '';
print ''.dol_escape_htmltag($line->comments).' ';
print ''.vatrate($line->vatrate, true).' ';
+ print ''.price($line->value_unit_ht).' ';
print ''.price($line->value_unit).' ';
print ''.dol_escape_htmltag($line->qty).' ';
@@ -2081,7 +2087,7 @@ else
}
// Ajout des boutons de modification/suppression
- if (($object->fk_statut < 2 || $object->fk_statut == 99) && $user->rights->expensereport->creer)
+ if (($object->fk_statut < ExpenseReport::STATUS_VALIDATED || $object->fk_statut == ExpenseReport::STATUS_REFUSED) && $user->rights->expensereport->creer)
{
print '';
@@ -2137,12 +2143,17 @@ else
// VAT
print ' ';
- print $form->load_tva('vatrate', (isset($_POST["vatrate"])?$_POST["vatrate"]:$line->vatrate), $mysoc, '');
+ print $form->load_tva('vatrate', (isset($_POST["vatrate"])?$_POST["vatrate"]:$line->vatrate), $mysoc, '', 0, 0, '', false, 1);
print ' ';
// Unit price
print '';
- print ' ';
+ print ' ';
+ print ' ';
+
+ // Unit price with tax
+ print '';
+ print ' ';
print ' ';
// Quantity
@@ -2178,6 +2189,7 @@ else
print ''.$langs->trans('Type').' ';
print ''.$langs->trans('Description').' ';
print ''.$langs->trans('VAT').' ';
+ print ''.$langs->trans('PriceUHT').' ';
print ''.$langs->trans('PriceUTTC').' ';
print ''.$langs->trans('Qty').' ';
print ' ';
@@ -2225,9 +2237,14 @@ else
print $form->load_tva('vatrate', ($vatrate!=''?$vatrate:$defaultvat), $mysoc, '', 0, 0, '', false, 1);
print '';
- // Unit price
+ // Unit price net
print '';
- print ' ';
+ print ' ';
+ print ' ';
+
+ // Unit price with tax
+ print '';
+ print ' ';
print ' ';
// Quantity
@@ -2249,6 +2266,26 @@ else
print '';
print '';
+ print '';
+
print '';
dol_fiche_end();
@@ -2286,7 +2323,7 @@ if ($action != 'create' && $action != 'edit')
* ET fk_user_author == user courant
* Afficher : "Enregistrer" / "Modifier" / "Supprimer"
*/
- if ($user->rights->expensereport->creer && $object->fk_statut==0)
+ if ($user->rights->expensereport->creer && $object->fk_statut == ExpenseReport::STATUS_DRAFT)
{
if (in_array($object->fk_user_author, $user->getAllChildIds(1)) || !empty($user->rights->expensereport->writeall_advance))
{
@@ -2306,7 +2343,7 @@ if ($action != 'create' && $action != 'edit')
* ET fk_user_author == user courant
* Afficher : "Enregistrer" / "Modifier" / "Supprimer"
*/
- if($user->rights->expensereport->creer && $object->fk_statut==99)
+ if($user->rights->expensereport->creer && $object->fk_statut == ExpenseReport::STATUS_REFUSED)
{
if ($user->id == $object->fk_user_author || $user->id == $object->fk_user_valid)
{
@@ -2320,7 +2357,7 @@ if ($action != 'create' && $action != 'edit')
}
}
- if ($user->rights->expensereport->to_paid && $object->fk_statut==5)
+ if ($user->rights->expensereport->to_paid && $object->fk_statut == ExpenseReport::STATUS_APPROVED)
{
if ($user->id == $object->fk_user_author || $user->id == $object->fk_user_valid)
{
@@ -2334,7 +2371,7 @@ if ($action != 'create' && $action != 'edit')
* ET fk_user_validator == user courant
* Afficher : "Valider" / "Refuser" / "Supprimer"
*/
- if ($object->fk_statut == 2)
+ if ($object->fk_statut == ExpenseReport::STATUS_VALIDATED)
{
if (in_array($object->fk_user_author, $user->getAllChildIds(1)))
{
@@ -2343,7 +2380,7 @@ if ($action != 'create' && $action != 'edit')
}
}
- if ($user->rights->expensereport->approve && $object->fk_statut == 2)
+ if ($user->rights->expensereport->approve && $object->fk_statut == ExpenseReport::STATUS_VALIDATED)
{
//if($object->fk_user_validator==$user->id)
//{
@@ -2364,13 +2401,13 @@ if ($action != 'create' && $action != 'edit')
// If status is Appoved
// --------------------
- if ($user->rights->expensereport->approve && $object->fk_statut == 5)
+ if ($user->rights->expensereport->approve && $object->fk_statut == ExpenseReport::STATUS_APPROVED)
{
print '';
}
// If bank module is used
- if ($user->rights->expensereport->to_paid && ! empty($conf->banque->enabled) && $object->fk_statut == 5)
+ if ($user->rights->expensereport->to_paid && ! empty($conf->banque->enabled) && $object->fk_statut == ExpenseReport::STATUS_APPROVED)
{
// Pay
if ($remaintopay == 0)
@@ -2384,7 +2421,7 @@ if ($action != 'create' && $action != 'edit')
}
// If bank module is not used
- if (($user->rights->expensereport->to_paid || empty($conf->banque->enabled)) && $object->fk_statut == 5)
+ if (($user->rights->expensereport->to_paid || empty($conf->banque->enabled)) && $object->fk_statut == ExpenseReport::STATUS_APPROVED)
{
//if ((round($remaintopay) == 0 || empty($conf->banque->enabled)) && $object->paid == 0)
if ($object->paid == 0)
@@ -2393,14 +2430,14 @@ if ($action != 'create' && $action != 'edit')
}
}
- if ($user->rights->expensereport->creer && ($user->id == $object->fk_user_author || $user->id == $object->fk_user_valid) && $object->fk_statut == 5)
+ if ($user->rights->expensereport->creer && ($user->id == $object->fk_user_author || $user->id == $object->fk_user_valid) && $object->fk_statut == ExpenseReport::STATUS_APPROVED)
{
// Cancel
print '';
}
// TODO Replace this. It should be SetUnpaid and should go back to status unpaid not canceled.
- if (($user->rights->expensereport->approve || $user->rights->expensereport->to_paid) && $object->fk_statut == 6)
+ if (($user->rights->expensereport->approve || $user->rights->expensereport->to_paid) && $object->fk_statut == ExpenseReport::STATUS_CLOSED)
{
// Cancel
print '';
@@ -2412,12 +2449,12 @@ if ($action != 'create' && $action != 'edit')
}
/* If draft, validated, cancel, and user can create, he can always delete its card before it is approved */
- if ($user->rights->expensereport->creer && $user->id == $object->fk_user_author && $object->fk_statut <= 4)
+ if ($user->rights->expensereport->creer && $user->id == $object->fk_user_author && $object->fk_statut < ExpenseReport::STATUS_APPROVED)
{
// Delete
print '';
}
- elseif($user->rights->expensereport->supprimer && $object->fk_statut != 6)
+ elseif($user->rights->expensereport->supprimer && $object->fk_statut != ExpenseReport::STATUS_CLOSED)
{
// Delete
print '';
diff --git a/htdocs/expensereport/class/expensereport.class.php b/htdocs/expensereport/class/expensereport.class.php
index bbada0e22f7..dc0ffefe4ff 100644
--- a/htdocs/expensereport/class/expensereport.class.php
+++ b/htdocs/expensereport/class/expensereport.class.php
@@ -115,6 +115,11 @@ class ExpenseReport extends CommonObject
*/
const STATUS_VALIDATED = 2;
+ /**
+ * Classified canceled
+ */
+ const STATUS_CANCELED = 4;
+
/**
* Classified approved
*/
@@ -1442,12 +1447,12 @@ class ExpenseReport extends CommonObject
// phpcs:enable
$error = 0;
$this->date_cancel = $this->db->idate(gmmktime());
- if ($this->fk_statut != 4)
+ if ($this->fk_statut != ExpenseReport::STATUS_CANCELED)
{
$this->db->begin();
$sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element;
- $sql.= " SET fk_statut = 4, fk_user_cancel = ".$fuser->id;
+ $sql.= " SET fk_statut = ".ExpenseReport::STATUS_CANCELED.", fk_user_cancel = ".$fuser->id;
$sql.= ", date_cancel='".$this->db->idate($this->date_cancel)."'";
$sql.= " ,detail_cancel='".$this->db->escape($detail)."'";
$sql.= ' WHERE rowid = '.$this->id;
@@ -1676,10 +1681,10 @@ class ExpenseReport extends CommonObject
/**
* addline
*
- * @param real $qty Qty
+ * @param float $qty Qty
* @param double $up Value init
* @param int $fk_c_type_fees Type payment
- * @param double $vatrate Vat rate
+ * @param string $vatrate Vat rate (Can be '10' or '10 (ABC)')
* @param string $date Date
* @param string $comments Description
* @param int $fk_project Project id
@@ -1703,8 +1708,8 @@ class ExpenseReport extends CommonObject
if (empty($fk_project)) $fk_project = 0;
$qty = price2num($qty);
- if (!preg_match('/\((.*)\)/', $vatrate)) {
- $vatrate = price2num($vatrate); // $txtva can have format '5.0(XXX)' or '5'
+ if (! preg_match('/\s*\((.*)\)/', $vatrate)) {
+ $vatrate = price2num($vatrate); // $txtva can have format '5.0 (XXX)' or '5'
}
$up = price2num($up);
@@ -1715,7 +1720,7 @@ class ExpenseReport extends CommonObject
$localtaxes_type=getLocalTaxesFromRate($vatrate, 0, $mysoc, $this->thirdparty);
$vat_src_code = '';
- if (preg_match('/\((.*)\)/', $vatrate, $reg))
+ if (preg_match('/\s*\((.*)\)/', $vatrate, $reg))
{
$vat_src_code = $reg[1];
$vatrate = preg_replace('/\s*\(.*\)/', '', $vatrate); // Remove code into vatrate.
@@ -1727,6 +1732,7 @@ class ExpenseReport extends CommonObject
$tmp = calcul_price_total($qty, $up, 0, $vatrate, 0, 0, 0, 'TTC', 0, $type, $seller, $localtaxes_type);
$this->line->value_unit = $up;
+ $this->line->vat_src_code = $vat_src_code;
$this->line->vatrate = price2num($vatrate);
$this->line->total_ttc = $tmp[2];
$this->line->total_ht = $tmp[0];
@@ -1928,9 +1934,9 @@ class ExpenseReport extends CommonObject
* @param int $rowid Line to edit
* @param int $type_fees_id Type payment
* @param int $projet_id Project id
- * @param double $vatrate Vat rate. Can be '8.5* (8.5NPROM...)'
+ * @param double $vatrate Vat rate. Can be '8.5' or '8.5* (8.5NPROM...)'
* @param string $comments Description
- * @param real $qty Qty
+ * @param float $qty Qty
* @param double $value_unit Value init
* @param int $date Date
* @param int $expensereport_id Expense report id
diff --git a/htdocs/expensereport/class/expensereportstats.class.php b/htdocs/expensereport/class/expensereportstats.class.php
index 082e3ce016e..5edf301ac25 100644
--- a/htdocs/expensereport/class/expensereportstats.class.php
+++ b/htdocs/expensereport/class/expensereportstats.class.php
@@ -35,12 +35,12 @@ class ExpenseReportStats extends Stats
*/
public $table_element;
- var $socid;
- var $userid;
+ public $socid;
+ public $userid;
- var $from;
- var $field;
- var $where;
+ public $from;
+ public $field;
+ public $where;
/**
* Constructor
diff --git a/htdocs/holiday/common.inc.php b/htdocs/holiday/common.inc.php
index 45a95bcbada..cc213007fc0 100644
--- a/htdocs/holiday/common.inc.php
+++ b/htdocs/holiday/common.inc.php
@@ -23,7 +23,7 @@
* \brief Common load of data
*/
-require_once realpath(dirname(__FILE__)).'/../main.inc.php';
+require_once realpath(__DIR__).'/../main.inc.php';
if (! class_exists('Holiday')) {
require_once DOL_DOCUMENT_ROOT. '/holiday/class/holiday.class.php';
}
diff --git a/htdocs/install/mysql/migration/9.0.0-10.0.0.sql b/htdocs/install/mysql/migration/9.0.0-10.0.0.sql
index 5154d7311a9..19c6d2b386c 100644
--- a/htdocs/install/mysql/migration/9.0.0-10.0.0.sql
+++ b/htdocs/install/mysql/migration/9.0.0-10.0.0.sql
@@ -58,6 +58,8 @@ CREATE TABLE llx_pos_cash_fence(
-- For 10.0
+DROP TABLE llx_cotisation;
+
ALTER TABLE llx_loan ADD COLUMN insurance_amount double(24,8) DEFAULT 0;
ALTER TABLE llx_facture DROP INDEX idx_facture_uk_facnumber;
@@ -230,3 +232,13 @@ ALTER TABLE llx_bom_bom ADD INDEX idx_bom_bom_fk_product (fk_product);
ALTER TABLE llx_bom_bomline ADD INDEX idx_bom_bomline_rowid (rowid);
ALTER TABLE llx_bom_bomline ADD INDEX idx_bom_bomline_fk_product (fk_product);
ALTER TABLE llx_bom_bomline ADD INDEX idx_bom_bomline_fk_bom (fk_bom);
+
+ALTER TABLE llx_facturedet_rec ADD COLUMN buy_price_ht double(24,8) DEFAULT 0;
+ALTER TABLE llx_facturedet_rec ADD COLUMN fk_product_fournisseur_price integer DEFAULT NULL;
+
+ALTER TABLE llx_facturedet_rec ADD COLUMN fk_user_author integer;
+ALTER TABLE llx_facturedet_rec ADD COLUMN fk_user_modif integer;
+
+ALTER TABLE llx_expensereport_det MODIFY COLUMN value_unit double(24,8) NOT NULL;
+ALTER TABLE llx_expensereport_det ADD COLUMN subprice double(24,8) NOT NULL after qty;
+
diff --git a/htdocs/install/mysql/tables/llx_expensereport_det.sql b/htdocs/install/mysql/tables/llx_expensereport_det.sql
index fc0bd6e697f..1000e10955f 100644
--- a/htdocs/install/mysql/tables/llx_expensereport_det.sql
+++ b/htdocs/install/mysql/tables/llx_expensereport_det.sql
@@ -27,7 +27,8 @@ CREATE TABLE llx_expensereport_det
comments text NOT NULL,
product_type integer DEFAULT -1,
qty real NOT NULL,
- value_unit real NOT NULL,
+ subprice double(24,8), -- P.U. HT (example 100)
+ value_unit double(24,8) NOT NULL, -- P.U. TTC (example 120)
remise_percent real,
vat_src_code varchar(10) DEFAULT '', -- Vat code used as source of vat fields. Not strict foreign key here.
tva_tx double(6,3), -- Vat rate
diff --git a/htdocs/install/mysql/tables/llx_facturedet.sql b/htdocs/install/mysql/tables/llx_facturedet.sql
index ac7142c898d..deb52576a8a 100644
--- a/htdocs/install/mysql/tables/llx_facturedet.sql
+++ b/htdocs/install/mysql/tables/llx_facturedet.sql
@@ -55,16 +55,16 @@ create table llx_facturedet
buy_price_ht double(24,8) DEFAULT 0, -- buying price. Note: this value is saved as an always positive value, even on credit notes (it is price we bought the product before selling it).
fk_product_fournisseur_price integer DEFAULT NULL, -- reference of supplier price when line was added (may be used to update buy_price_ht current price when future invoice will be created)
- fk_code_ventilation integer DEFAULT 0 NOT NULL, -- Id in table llx_accounting_bookeeping to know accounting account for product line
-
special_code integer DEFAULT 0, -- code for special lines (may be 1=transport, 2=ecotax, 3=option, moduleid=...)
rang integer DEFAULT 0, -- position of line
fk_contract_line integer NULL, -- id of contract line when invoice comes from contract lines
+ fk_unit integer DEFAULT NULL, -- id of the unit code
import_key varchar(14),
+ fk_code_ventilation integer DEFAULT 0 NOT NULL, -- Id in table llx_accounting_bookeeping to know accounting account for product line
+
situation_percent real, -- % progression of lines invoicing
- fk_prev_id integer, -- id of the line in the previous situation,
- fk_unit integer DEFAULT NULL, -- id of the unit code¡
+ fk_prev_id integer, -- id of the line in the previous situation
fk_user_author integer, -- user making creation
fk_user_modif integer, -- user making last change
diff --git a/htdocs/install/mysql/tables/llx_facturedet_rec.sql b/htdocs/install/mysql/tables/llx_facturedet_rec.sql
index ac79dfd891d..267abcd5053 100644
--- a/htdocs/install/mysql/tables/llx_facturedet_rec.sql
+++ b/htdocs/install/mysql/tables/llx_facturedet_rec.sql
@@ -48,11 +48,18 @@ create table llx_facturedet_rec
date_start_fill integer DEFAULT 0, -- 1=autofill the date_start of invoice with __INVOICE_DATE_NEXT_INVOICE_BEFORE_GEN__
date_end_fill integer DEFAULT 0, -- 1=autofill the date_start of invoice with __INVOICE_PREVIOUS_DATE_NEXT_INVOICE_AFTER_GEN__
info_bits integer DEFAULT 0, -- TVA NPR ou non
+
+ buy_price_ht double(24,8) DEFAULT 0, -- buying price. Note: this value is saved as an always positive value, even on credit notes (it is price we bought the product before selling it).
+ fk_product_fournisseur_price integer DEFAULT NULL, -- reference of supplier price when line was added (may be used to update buy_price_ht current price when future invoice will be created)
+
special_code integer UNSIGNED DEFAULT 0, -- code pour les lignes speciales
rang integer DEFAULT 0, -- ordre d'affichage
fk_contract_line integer NULL, -- id of contract line when template invoice comes from contract lines
fk_unit integer DEFAULT NULL,
import_key varchar(14),
+
+ fk_user_author integer, -- user making creation
+ fk_user_modif integer, -- user making last change
fk_multicurrency integer,
multicurrency_code varchar(255),
diff --git a/htdocs/install/upgrade.php b/htdocs/install/upgrade.php
index 274efc04eb1..6a821d8dbaf 100644
--- a/htdocs/install/upgrade.php
+++ b/htdocs/install/upgrade.php
@@ -88,7 +88,7 @@ if (! $versionfrom && ! $versionto)
// Test if batch mode
$sapi_type = php_sapi_name();
$script_file = basename(__FILE__);
- $path=dirname(__FILE__).'/';
+ $path=__DIR__.'/';
if (substr($sapi_type, 0, 3) == 'cli')
{
print 'Syntax from command line: '.$script_file." x.y.z a.b.c\n";
diff --git a/htdocs/install/upgrade2.php b/htdocs/install/upgrade2.php
index 2fa5fad38ac..45b5f8fe95c 100644
--- a/htdocs/install/upgrade2.php
+++ b/htdocs/install/upgrade2.php
@@ -96,7 +96,7 @@ if ((! $versionfrom || preg_match('/version/', $versionfrom)) && (! $versionto |
// Test if batch mode
$sapi_type = php_sapi_name();
$script_file = basename(__FILE__);
- $path=dirname(__FILE__).'/';
+ $path=__DIR__.'/';
if (substr($sapi_type, 0, 3) == 'cli')
{
print 'Syntax from command line: '.$script_file." x.y.z a.b.c [MAIN_MODULE_NAME1_TO_ENABLE,MAIN_MODULE_NAME2_TO_ENABLE...]\n";
@@ -186,7 +186,7 @@ if (! GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'a
{
// Current version is $conf->global->MAIN_VERSION_LAST_UPGRADE
// Version to install is DOL_VERSION
- $dolibarrlastupgradeversionarray=preg_split('/[\.-]/', isset($conf->global->MAIN_VERSION_LAST_UPGRADE)?$conf->global->MAIN_VERSION_LAST_UPGRADE:$conf->global->MAIN_VERSION_LAST_INSTALL);
+ $dolibarrlastupgradeversionarray=preg_split('/[\.-]/', isset($conf->global->MAIN_VERSION_LAST_UPGRADE)?$conf->global->MAIN_VERSION_LAST_UPGRADE:(isset($conf->global->MAIN_VERSION_LAST_INSTALL)?$conf->global->MAIN_VERSION_LAST_INSTALL:''));
// Chaque action de migration doit renvoyer une ligne sur 4 colonnes avec
// dans la 1ere colonne, la description de l'action a faire
diff --git a/htdocs/langs/en_US/blockedlog.lang b/htdocs/langs/en_US/blockedlog.lang
index 6cc85024843..cff8f7d657b 100644
--- a/htdocs/langs/en_US/blockedlog.lang
+++ b/htdocs/langs/en_US/blockedlog.lang
@@ -14,9 +14,9 @@ OkCheckFingerprintValidityButChainIsKo=Archived log seems valid compared to prev
AddedByAuthority=Stored into remote authority
NotAddedByAuthorityYet=Not yet stored into remote authority
ShowDetails=Show stored details
-logPAYMENT_VARIOUS_CREATE=Payment (not assigned to invoice) created
-logPAYMENT_VARIOUS_MODIFY=Payment (not assigned to invoice) modified
-logPAYMENT_VARIOUS_DELETE=Payment (not assigned to invoice) logical deletion
+logPAYMENT_VARIOUS_CREATE=Payment (not assigned to an invoice) created
+logPAYMENT_VARIOUS_MODIFY=Payment (not assigned to an invoice) modified
+logPAYMENT_VARIOUS_DELETE=Payment (not assigned to an invoice) logical deletion
logPAYMENT_ADD_TO_BANK=Payment added to bank
logPAYMENT_CUSTOMER_CREATE=Customer payment created
logPAYMENT_CUSTOMER_DELETE=Customer payment logical deletion
diff --git a/htdocs/langs/en_US/users.lang b/htdocs/langs/en_US/users.lang
index 53ac720d862..fb35cb5e112 100644
--- a/htdocs/langs/en_US/users.lang
+++ b/htdocs/langs/en_US/users.lang
@@ -109,4 +109,4 @@ UserLogoff=User logout
UserLogged=User logged
DateEmployment=Employment Start Date
DateEmploymentEnd=Employment End Date
-CantDisableYourself=You can disable your own user record
\ No newline at end of file
+CantDisableYourself=You can't disable your own user record
\ No newline at end of file
diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php
index 70571964162..4a85cd8ddab 100644
--- a/htdocs/main.inc.php
+++ b/htdocs/main.inc.php
@@ -395,6 +395,7 @@ if ((! defined('NOCSRFCHECK') && empty($dolibarr_nocsrfcheck) && ! empty($conf->
{
dol_syslog("Invalid token, so we disable POST and some GET parameters - referer=".$_SERVER['HTTP_REFERER'].", action=".GETPOST('action', 'aZ09').", _GET|POST['token']=".GETPOST('token', 'alpha').", _SESSION['token']=".$_SESSION['token'], LOG_WARNING);
//print 'Unset POST by CSRF protection in main.inc.php.'; // Do not output anything because this create problems when using the BACK button on browsers.
+ if ($conf->global->MAIN_FEATURES_LEVEL>1) setEventMessages('Unset POST by CSRF protection in main.inc.php.', null, 'warnings');
unset($_POST);
unset($_GET['confirm']);
}
diff --git a/htdocs/modulebuilder/template/class/api_mymodule.class.php b/htdocs/modulebuilder/template/class/api_mymodule.class.php
index 566fe56affb..acf7f65454d 100644
--- a/htdocs/modulebuilder/template/class/api_mymodule.class.php
+++ b/htdocs/modulebuilder/template/class/api_mymodule.class.php
@@ -31,7 +31,6 @@ dol_include_once('/mymodule/class/myobject.class.php');
/**
* API class for mymodule myobject
*
- * @smart-auto-routing false
* @access protected
* @class DolibarrApiAccess {@requires user,external}
*/
@@ -205,7 +204,7 @@ class MyModuleApi extends DolibarrApi
$this->myobject->$field = $value;
}
if( ! $this->myobject->create(DolibarrApiAccess::$user)) {
- throw new RestException(500);
+ throw new RestException(500, "Error creating MyObject", array_merge(array($this->myobject->error), $this->myobject->errors));
}
return $this->myobject->id;
}
@@ -235,13 +234,18 @@ class MyModuleApi extends DolibarrApi
}
foreach($request_data as $field => $value) {
+ if ($field == 'id') continue;
$this->myobject->$field = $value;
}
- if($this->myobject->update($id, DolibarrApiAccess::$user))
+ if ($this->myobject->update($id, DolibarrApiAccess::$user) > 0)
+ {
return $this->get($id);
-
- return false;
+ }
+ else
+ {
+ throw new RestException(500, $this->myobject->error);
+ }
}
/**
@@ -254,21 +258,21 @@ class MyModuleApi extends DolibarrApi
*/
public function delete($id)
{
- if(! DolibarrApiAccess::$user->rights->myobject->delete) {
+ if (! DolibarrApiAccess::$user->rights->myobject->delete) {
throw new RestException(401);
}
$result = $this->myobject->fetch($id);
- if( ! $result ) {
+ if (! $result) {
throw new RestException(404, 'MyObject not found');
}
- if( ! DolibarrApi::_checkAccessToResource('myobject', $this->myobject->id)) {
+ if (! DolibarrApi::_checkAccessToResource('myobject', $this->myobject->id)) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
- if( !$this->myobject->delete(DolibarrApiAccess::$user, 0))
+ if (! $this->myobject->delete(DolibarrApiAccess::$user))
{
- throw new RestException(500);
+ throw new RestException(500, 'Error when deleting MyObject : '.$this->myobject->error);
}
return array(
@@ -305,10 +309,10 @@ class MyModuleApi extends DolibarrApi
/**
* Validate fields before create or update object
*
- * @param array $data Data to validate
- * @return array
+ * @param array $data Array of data to validate
+ * @return array
*
- * @throws RestException
+ * @throws RestException
*/
private function _validate($data)
{
diff --git a/htdocs/modulebuilder/template/core/modules/mailings/mailinglist_mymodule_myobject.modules.php b/htdocs/modulebuilder/template/core/modules/mailings/mailinglist_mymodule_myobject.modules.php
index 83644cd1f0e..07419af532d 100644
--- a/htdocs/modulebuilder/template/core/modules/mailings/mailinglist_mymodule_myobject.modules.php
+++ b/htdocs/modulebuilder/template/core/modules/mailings/mailinglist_mymodule_myobject.modules.php
@@ -97,9 +97,10 @@ class mailing_mailinglist_mymodule_myobject extends MailingTargets
* This is the main function that returns the array of emails
*
* @param int $mailing_id Id of emailing
+ * @param array $cibles Array with targets
* @return int <0 if error, number of emails added if ok
*/
- public function add_to_target($mailing_id)
+ public function add_to_target($mailing_id, $cibles)
{
// phpcs:enable
$target = array();
diff --git a/htdocs/modulebuilder/template/scripts/myobject.php b/htdocs/modulebuilder/template/scripts/myobject.php
index 97310f11de6..f80a5f67b3e 100644
--- a/htdocs/modulebuilder/template/scripts/myobject.php
+++ b/htdocs/modulebuilder/template/scripts/myobject.php
@@ -25,7 +25,7 @@
$sapi_type = php_sapi_name();
$script_file = basename(__FILE__);
-$path=dirname(__FILE__).'/';
+$path=__DIR__.'/';
// Test if batch mode
if (substr($sapi_type, 0, 3) == 'cgi') {
diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php
index 9ef3ba450cf..0721016a8aa 100644
--- a/htdocs/product/class/product.class.php
+++ b/htdocs/product/class/product.class.php
@@ -1561,7 +1561,7 @@ class Product extends CommonObject
* @param Societe $thirdparty_buyer Buyer
* @param int $pqp Id of product per price if a selection was done of such a price
* @return array Array of price information
- * @see get_buyprice()
+ * @see get_buyprice(), find_min_price_product_fournisseur()
*/
public function getSellPrice($thirdparty_seller, $thirdparty_buyer, $pqp = 0)
{
@@ -1672,8 +1672,8 @@ class Product extends CommonObject
* @param int $product_id Filter on a particular product id
* @param string $fourn_ref Filter on a supplier price ref. 'none' to exclude ref in search.
* @param int $fk_soc If of supplier
- * @return int <-1 if KO, -1 if qty not enough, 0 if OK but nothing found, id_product if OK and found. May also initialize some properties like (->ref_supplier, buyprice, fourn_pu, vatrate_supplier...)
- * @see getSellPrice()
+ * @return int <-1 if KO, -1 if qty not enough, 0 if OK but nothing found, id_product if OK and found. May also initialize some properties like (->ref_supplier, buyprice, fourn_pu, vatrate_supplier...)
+ * @see getSellPrice(), find_min_price_product_fournisseur()
*/
public function get_buyprice($prodfournprice, $qty, $product_id = 0, $fourn_ref = '', $fk_soc = 0)
{
diff --git a/htdocs/theme/eldy/main_menu_fa_icons.css b/htdocs/theme/eldy/main_menu_fa_icons.css
index 58890786111..57d422b8395 100644
--- a/htdocs/theme/eldy/main_menu_fa_icons.css
+++ b/htdocs/theme/eldy/main_menu_fa_icons.css
@@ -118,6 +118,14 @@ div.mainmenu.products::before {
font-size: 1.5em;
}
+div.mainmenu.mrp::before {
+ font-family: "Font Awesome 5 Free";
+ font-weight: 900;
+ content: "\f468";
+ color: white;
+ font-size: 1.5em;
+}
+
div.mainmenu.project::before {
font-family: "Font Awesome 5 Free";
font-weight: 900;
diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php
index 1f58937d879..35f6f56c57c 100644
--- a/htdocs/theme/eldy/style.css.php
+++ b/htdocs/theme/eldy/style.css.php
@@ -61,7 +61,7 @@ if (defined('THEME_ONLY_CONSTANT')) return;
session_cache_limiter('public');
-require_once '../../main.inc.php';
+require_once __DIR__.'/../../main.inc.php'; // __DIR__ allow this script to be included in custom themes
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
// Load user to have $user->conf loaded (not done into main because of NOLOGIN constant defined)
diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php
index 6748bcb215a..1f98c2d25ca 100644
--- a/htdocs/theme/md/style.css.php
+++ b/htdocs/theme/md/style.css.php
@@ -1764,6 +1764,10 @@ div.mainmenu.products {
background-image: url();
}
+div.mainmenu.mrp {
+ background-image: url();
+}
+
div.mainmenu.project {
background-image: url();
}
diff --git a/htdocs/website/index.php b/htdocs/website/index.php
index 2814cbf41a9..a23385f1083 100644
--- a/htdocs/website/index.php
+++ b/htdocs/website/index.php
@@ -920,7 +920,7 @@ if ($action == 'updatecss')
/* We disable php code since htmlheader is never executed as an include but only read by fgets_content.
$htmlheadercontent.= "