';
From fdcb9674d8470419daddb3c1b970113117f6a46b Mon Sep 17 00:00:00 2001
From: John BOTELLA
Date: Sun, 24 Oct 2021 02:09:49 +0200
Subject: [PATCH 007/178] Remove prints
---
htdocs/core/class/html.formsetup.class.php | 38 +++++++++++-----------
htdocs/langs/en_US/admin.lang | 1 +
2 files changed, 20 insertions(+), 19 deletions(-)
diff --git a/htdocs/core/class/html.formsetup.class.php b/htdocs/core/class/html.formsetup.class.php
index 095cf0d8887..27b0e3fb615 100644
--- a/htdocs/core/class/html.formsetup.class.php
+++ b/htdocs/core/class/html.formsetup.class.php
@@ -69,7 +69,7 @@ class formSetup{
$out.= ' '.$this->langs->trans("Value").' ';
$out.= '';
- foreach ($this->arrayOfParameters as $const => $item) {
+ foreach ($this->arrayOfParameters as $item) {
$out.= $this->generateLineOutput($item, $edit);
}
@@ -98,10 +98,10 @@ class formSetup{
$out.= '';
if($edit){
- $item->generateInputField();
+ $out.= $item->generateInputField();
}
else{
- $item->generateOutputField();
+ $out.= $item->generateOutputField();
}
if(!empty($item->errors)){
@@ -125,7 +125,6 @@ class formSetup{
public function addItemsFromParamsArray($params){
if(!array($params)){ return false; }
-
foreach ($params as $confKey => $param){
$this->addItemFromParams($confKey, $param); // todo manage error
}
@@ -139,7 +138,7 @@ class formSetup{
*/
public function addItemFromParams($confKey, $params){
- if(empty($confKey) || !empty($params['type'])){ return false; }
+ if(empty($confKey) || empty($params['type'])){ return false; }
/*
* Exemple from old module builder setup page
@@ -155,13 +154,14 @@ class formSetup{
$item = new formSetupItem($this->db);
$item->type = $params['type'];
+ $item->confKey = $confKey;
if(!empty($params['enabled'])) {
$item->enabled = $params['enabled'];
}
if(!empty($params['css'])){
- $item->enabled = $params['css'];
+ $item->cssClass = $params['css'];
}
$this->arrayOfParameters[$item->confKey] = $item;
@@ -233,7 +233,7 @@ class formSetupItem
public function getNameText(){
if(!empty($this->nameText)){ return $this->nameText; }
- return (($this->langs->trans($this->confKey) != $this->confKey) ? $this->langs->trans($this->confKey) : '');
+ return (($this->langs->trans($this->confKey) != $this->confKey) ? $this->langs->trans($this->confKey) : $this->langs->trans('MissingTranslationForConfKey',$this->confKey));
}
public function generateInputField(){
@@ -313,7 +313,7 @@ class formSetupItem
$this->form->select_produits($selected, $this->confKey, '', 0);
}
} else {
- $out.= ' ';
+ $out.= ' ';
}
return $out;
@@ -347,11 +347,11 @@ class formSetupItem
$out = '';
if ($this->type == 'textarea') {
- print dol_nl2br($conf->global->{$this->confKey});
+ $out.= dol_nl2br($conf->global->{$this->confKey});
} elseif ($this->type== 'html') {
- print $conf->global->{$this->confKey};
+ $out.= $conf->global->{$this->confKey};
} elseif ($this->type == 'yesno') {
- print ajax_constantonoff($this->confKey);
+ $out.= ajax_constantonoff($this->confKey);
} elseif (preg_match('/emailtemplate:/', $this->type)) {
include_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php';
$formmail = new FormMail($this->db);
@@ -362,7 +362,7 @@ class formSetupItem
if ($template<0) {
$this->setErrors($formmail->errors);
}
- print $this->langs->trans($template->label);
+ $out.= $this->langs->trans($template->label);
} elseif (preg_match('/category:/', $this->type)) {
$c = new Categorie($this->db);
$result = $c->fetch($conf->global->{$this->confKey});
@@ -374,27 +374,27 @@ class formSetupItem
foreach ($ways as $way) {
$toprint[] = 'color ? ' style="background: #' . $c->color . ';"' : ' style="background: #bbb"') . '>' . $way . ' ';
}
- print '' . implode(' ', $toprint) . ' ';
+ $out.= '' . implode(' ', $toprint) . ' ';
} elseif (preg_match('/thirdparty_type/', $this->type)) {
if ($conf->global->{$this->confKey}==2) {
- print $this->langs->trans("Prospect");
+ $out.= $this->langs->trans("Prospect");
} elseif ($conf->global->{$this->confKey}==3) {
- print $this->langs->trans("ProspectCustomer");
+ $out.= $this->langs->trans("ProspectCustomer");
} elseif ($conf->global->{$this->confKey}==1) {
- print $this->langs->trans("Customer");
+ $out.= $this->langs->trans("Customer");
} elseif ($conf->global->{$this->confKey}==0) {
- print $this->langs->trans("NorProspectNorCustomer");
+ $out.= $this->langs->trans("NorProspectNorCustomer");
}
} elseif ($this->type == 'product') {
$product = new Product($this->db);
$resprod = $product->fetch($conf->global->{$this->confKey});
if ($resprod > 0) {
- print $product->ref;
+ $out.= $product->ref;
} elseif ($resprod < 0) {
$this->setErrors($product->errors);
}
} else {
- print $conf->global->{$this->confKey};
+ $out.= $conf->global->{$this->confKey};
}
return $out;
diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang
index f75ba12abe5..96fba681373 100644
--- a/htdocs/langs/en_US/admin.lang
+++ b/htdocs/langs/en_US/admin.lang
@@ -2198,3 +2198,4 @@ SkinAndColors=Skin and colors
IfYouUseASecondTaxYouMustSetYouUseTheMainTax=If you want to use a second tax, you must enable also the first sales tax
IfYouUseAThirdTaxYouMustSetYouUseTheMainTax=If you want to use a third tax, you must enable also the first sales tax
PDF_USE_1A=Generate PDF with PDF/A-1b format
+MissingTranslationForConfKey = Missing translation for %s
From 61576dad539cc363fa3efdfbb55e9f9512cb5cf7 Mon Sep 17 00:00:00 2001
From: stickler-ci
Date: Sun, 24 Oct 2021 00:17:18 +0000
Subject: [PATCH 008/178] Fixing style errors.
---
htdocs/core/class/html.formsetup.class.php | 73 ++++++++++++----------
1 file changed, 39 insertions(+), 34 deletions(-)
diff --git a/htdocs/core/class/html.formsetup.class.php b/htdocs/core/class/html.formsetup.class.php
index 27b0e3fb615..70dd11e47ae 100644
--- a/htdocs/core/class/html.formsetup.class.php
+++ b/htdocs/core/class/html.formsetup.class.php
@@ -19,7 +19,8 @@
/**
* This class help you create setup render
*/
-class formSetup{
+class formSetup
+{
/**
* @var DoliDB Database handler.
@@ -48,10 +49,9 @@ class formSetup{
$this->db = $db;
$this->form = new Form($this->db);
- if($outputLangs){
+ if ($outputLangs) {
$this->langs = $outputLangs;
- }
- else{
+ } else {
$this->langs = $langs;
}
}
@@ -59,7 +59,8 @@ class formSetup{
/**
* @return string
*/
- public function generateOutput($edit = false){
+ public function generateOutput($edit = false)
+ {
require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php';
@@ -82,7 +83,8 @@ class formSetup{
* @param bool $edit
* @return string
*/
- public function generateLineOutput($item, $edit = false){
+ public function generateLineOutput($item, $edit = false)
+ {
$out = '';
if ($item->enabled==1) {
@@ -97,14 +99,13 @@ class formSetup{
$out.= '';
- if($edit){
+ if ($edit) {
$out.= $item->generateInputField();
- }
- else{
+ } else {
$out.= $item->generateOutputField();
}
- if(!empty($item->errors)){
+ if (!empty($item->errors)) {
// TODO : move set event message in a methode to be called by cards not by this class
setEventMessages(null, $item->errors, 'errors');
}
@@ -122,10 +123,11 @@ class formSetup{
* @param array $params
* @
*/
- public function addItemsFromParamsArray($params){
+ public function addItemsFromParamsArray($params)
+ {
- if(!array($params)){ return false; }
- foreach ($params as $confKey => $param){
+ if (!array($params)) { return false; }
+ foreach ($params as $confKey => $param) {
$this->addItemFromParams($confKey, $param); // todo manage error
}
}
@@ -136,9 +138,10 @@ class formSetup{
* @param string $confKey
* @param array $params
*/
- public function addItemFromParams($confKey, $params){
+ public function addItemFromParams($confKey, $params)
+ {
- if(empty($confKey) || empty($params['type'])){ return false; }
+ if (empty($confKey) || empty($params['type'])) { return false; }
/*
* Exemple from old module builder setup page
@@ -156,11 +159,11 @@ class formSetup{
$item->type = $params['type'];
$item->confKey = $confKey;
- if(!empty($params['enabled'])) {
+ if (!empty($params['enabled'])) {
$item->enabled = $params['enabled'];
}
- if(!empty($params['css'])){
+ if (!empty($params['css'])) {
$item->cssClass = $params['css'];
}
@@ -168,7 +171,6 @@ class formSetup{
return true;
}
-
}
@@ -226,20 +228,23 @@ class formSetupItem
$this->confKey = $confKey;
}
- public function getHelpText(){
- if(!empty($this->helpText)){ return $this->helpText; }
+ public function getHelpText()
+ {
+ if (!empty($this->helpText)) { return $this->helpText; }
return (($this->langs->trans($this->confKey . 'Tooltip') != $this->confKey . 'Tooltip') ? $this->langs->trans($this->confKey . 'Tooltip') : '');
}
- public function getNameText(){
- if(!empty($this->nameText)){ return $this->nameText; }
- return (($this->langs->trans($this->confKey) != $this->confKey) ? $this->langs->trans($this->confKey) : $this->langs->trans('MissingTranslationForConfKey',$this->confKey));
+ public function getNameText()
+ {
+ if (!empty($this->nameText)) { return $this->nameText; }
+ return (($this->langs->trans($this->confKey) != $this->confKey) ? $this->langs->trans($this->confKey) : $this->langs->trans('MissingTranslationForConfKey', $this->confKey));
}
- public function generateInputField(){
+ public function generateInputField()
+ {
global $conf, $user;
- if(!empty($this->fieldOverride)){
+ if (!empty($this->fieldOverride)) {
return $this->fieldOverride;
}
@@ -324,23 +329,24 @@ class formSetupItem
* add error
* @param array|string $errors
*/
- public function setErrors($errors){
- if(is_array($errors)){
- if(!empty($errors)){
- foreach ($errors as $error){
+ public function setErrors($errors)
+ {
+ if (is_array($errors)) {
+ if (!empty($errors)) {
+ foreach ($errors as $error) {
$this->setErrors($error);
}
}
- }
- elseif(!empty($errors)){
+ } elseif (!empty($errors)) {
$this->errors[] = $errors;
}
}
- public function generateOutputField(){
+ public function generateOutputField()
+ {
global $conf, $user;
- if(!empty($this->fieldOverride)){
+ if (!empty($this->fieldOverride)) {
return $this->fieldOverride;
}
@@ -399,5 +405,4 @@ class formSetupItem
return $out;
}
-
}
From 1e45b9b1cd5f0b6c934a3b275c225ec6d3da7e8a Mon Sep 17 00:00:00 2001
From: Gauthier PC portable 024
Date: Mon, 25 Oct 2021 15:25:58 +0200
Subject: [PATCH 009/178] FIX : We need a default price base type in variant
creation case with multiprices when parent has been created with only one
level price
---
htdocs/variants/class/ProductCombination.class.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/htdocs/variants/class/ProductCombination.class.php b/htdocs/variants/class/ProductCombination.class.php
index bc479b68653..10318f11a46 100644
--- a/htdocs/variants/class/ProductCombination.class.php
+++ b/htdocs/variants/class/ProductCombination.class.php
@@ -509,7 +509,7 @@ class ProductCombination
for ($i = 1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i++)
{
if ($parent->multiprices[$i] != '' || isset($this->combination_price_levels[$i]->variation_price)) {
- $new_type = $parent->multiprices_base_type[$i];
+ $new_type = !empty($parent->multiprices_base_type[$i]) ? $parent->multiprices_base_type[$i] : 'HT';
$new_min_price = $parent->multiprices_min[$i];
$variation_price = doubleval(!isset($this->combination_price_levels[$i]->variation_price) ? $this->variation_price : $this->combination_price_levels[$i]->variation_price);
$variation_price_percentage = doubleval(!isset($this->combination_price_levels[$i]->variation_price_percentage) ? $this->variation_price_percentage : $this->combination_price_levels[$i]->variation_price_percentage);
From 1683f46d9bd7142f89cd801ecd07e086f2efcd5a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?=
Date: Mon, 25 Oct 2021 21:21:48 +0200
Subject: [PATCH 010/178] backport fix
---
htdocs/main.inc.php | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php
index 2e9f0558421..9753f4b3d83 100644
--- a/htdocs/main.inc.php
+++ b/htdocs/main.inc.php
@@ -1042,6 +1042,16 @@ if (!defined('NOLOGIN')) {
//Required if advanced permissions are used with MAIN_USE_ADVANCED_PERMS
if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS)) {
+ if (empty($user->rights->user->user_advance)) {
+ $user->rights->user->user_advance = new stdClass(); // To avoid warnings
+ }
+ if (empty($user->rights->user->self_advance)) {
+ $user->rights->user->self_advance = new stdClass(); // To avoid warnings
+ }
+ if (empty($user->rights->user->group_advance)) {
+ $user->rights->user->group_advance = new stdClass(); // To avoid warnings
+ }
+
$user->rights->user->user_advance->readperms = 1;
$user->rights->user->user_advance->write = 1;
$user->rights->user->self_advance->readperms = 1;
From c998abe54e36977b8144936c4587919eff2dab21 Mon Sep 17 00:00:00 2001
From: Administrator
Date: Wed, 27 Oct 2021 11:09:00 +0200
Subject: [PATCH 011/178] FIX: resource list : Use standard code to handle list
filters
---
htdocs/resource/list.php | 26 ++++++++++----------------
1 file changed, 10 insertions(+), 16 deletions(-)
diff --git a/htdocs/resource/list.php b/htdocs/resource/list.php
index 033d49ae8c8..a4721b2d174 100644
--- a/htdocs/resource/list.php
+++ b/htdocs/resource/list.php
@@ -75,22 +75,16 @@ if ($search_type != '') {
}
// Add $param from extra fields
-foreach ($search_array_options as $key => $val)
-{
- $crit = $val;
- $tmpkey = preg_replace('/search_options_/', '', $key);
- $typ = $extrafields->attributes[$object->table_element]['type'][$tmpkey];
- if ($val != '') {
- $param .= '&search_options_'.$tmpkey.'='.urlencode($val);
- }
- $mode_search = 0;
- if (in_array($typ, array('int', 'double', 'real'))) $mode_search = 1; // Search on a numeric
- if (in_array($typ, array('sellist', 'link')) && $crit != '0' && $crit != '-1') $mode_search = 2; // Search on a foreign key int
- if ($crit != '' && (!in_array($typ, array('select', 'sellist')) || $crit != '0') && (!in_array($typ, array('link')) || $crit != '-1'))
- {
- $filter['ef.'.$tmpkey] = natural_search('ef.'.$tmpkey, $crit, $mode_search);
- }
-}
+include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
+$sql= null;
+include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
+
+// Including the previous script generate the correct SQL filter for all the extrafields
+// we are playing with the behaviour of the Dolresource::fetch_all() by generating a fake
+// extrafields filter key to make it works
+$filter['ef.resource'] = $sql;
+
+
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage);
From 3a862212905ceebf3a1de29b33dd1abede9ae25f Mon Sep 17 00:00:00 2001
From: John BOTELLA
Date: Sat, 30 Oct 2021 12:54:13 +0200
Subject: [PATCH 012/178] add more customisation
---
htdocs/core/class/html.formsetup.class.php | 327 +++++++++++++-----
htdocs/modulebuilder/template/admin/setup.php | 28 +-
2 files changed, 272 insertions(+), 83 deletions(-)
diff --git a/htdocs/core/class/html.formsetup.class.php b/htdocs/core/class/html.formsetup.class.php
index 27b0e3fb615..f781afe0079 100644
--- a/htdocs/core/class/html.formsetup.class.php
+++ b/htdocs/core/class/html.formsetup.class.php
@@ -19,7 +19,8 @@
/**
* This class help you create setup render
*/
-class formSetup{
+class formSetup
+{
/**
* @var DoliDB Database handler.
@@ -27,7 +28,7 @@ class formSetup{
public $db;
/** @var formSetupItem[] */
- public $arrayOfParameters = array();
+ public $params = array();
public $setupNotEmpty = 0;
@@ -37,10 +38,12 @@ class formSetup{
/** @var Form */
public $form;
+
/**
* Constructor
*
- * @param DoliDB $db Database handler
+ * @param DoliDB $db Database handler
+ * @param Translate $outputLangs if needed can use another lang
*/
public function __construct($db, $outputLangs = false)
{
@@ -48,41 +51,53 @@ class formSetup{
$this->db = $db;
$this->form = new Form($this->db);
- if($outputLangs){
+ if ($outputLangs) {
$this->langs = $outputLangs;
- }
- else{
+ } else {
$this->langs = $langs;
}
}
/**
+ * @param bool $editMode true will display output on edit mod
* @return string
*/
- public function generateOutput($edit = false){
+ public function generateOutput($editMode = false)
+ {
+ $out = '';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php';
- $out = '';
+ $out.= ' ';
+ if ($editMode) {
+ $out .= ' ';
+ }
+
+ $out.= '';
+ $out.= '';
$out.= '';
$out.= ' '.$this->langs->trans("Parameter").' ';
$out.= ' '.$this->langs->trans("Value").' ';
$out.= ' ';
+ $out.= ' ';
- foreach ($this->arrayOfParameters as $item) {
- $out.= $this->generateLineOutput($item, $edit);
+ $out.= '';
+ foreach ($this->params as $item) {
+ $out.= $this->generateLineOutput($item, $editMode);
}
+ $out.= ' ';
$out.= '
';
return $out;
}
/**
- * @param formSetupItem $item
- * @param bool $edit
- * @return string
+ * @param formSetupItem $item the setup item
+ * @param bool $editMode Display as edit mod
+ * @return string the html output for an setup item
*/
- public function generateLineOutput($item, $edit = false){
+ public function generateLineOutput($item, $editMode = false)
+ {
$out = '';
if ($item->enabled==1) {
@@ -97,14 +112,13 @@ class formSetup{
$out.= '';
- if($edit){
+ if ($editMode) {
$out.= $item->generateInputField();
- }
- else{
+ } else {
$out.= $item->generateOutputField();
}
- if(!empty($item->errors)){
+ if (!empty($item->errors)) {
// TODO : move set event message in a methode to be called by cards not by this class
setEventMessages(null, $item->errors, 'errors');
}
@@ -118,14 +132,14 @@ class formSetup{
/**
- * @param string $confKey
- * @param array $params
- * @
+ * @param array $params an array of arrays of params from old modulBuilder params
+ * @deprecated was used to test module builder convertion to this form usage
+ * @return null
*/
- public function addItemsFromParamsArray($params){
-
- if(!array($params)){ return false; }
- foreach ($params as $confKey => $param){
+ public function addItemsFromParamsArray($params)
+ {
+ if (!array($params)) { return false; }
+ foreach ($params as $confKey => $param) {
$this->addItemFromParams($confKey, $param); // todo manage error
}
}
@@ -133,12 +147,14 @@ class formSetup{
/**
* From old
- * @param string $confKey
- * @param array $params
+ * @param string $confKey the conf name to store
+ * @param array $params an array of params from old modulBuilder params
+ * @deprecated was used to test module builder convertion to this form usage
+ * @return bool
*/
- public function addItemFromParams($confKey, $params){
-
- if(empty($confKey) || empty($params['type'])){ return false; }
+ public function addItemFromParams($confKey, $params)
+ {
+ if (empty($confKey) || empty($params['type'])) { return false; }
/*
* Exemple from old module builder setup page
@@ -152,26 +168,56 @@ class formSetup{
//'MYMODULE_MYPARAM7'=>array('type'=>'product', 'enabled'=>1),
*/
- $item = new formSetupItem($this->db);
+ $item = new formSetupItem($confKey);
$item->type = $params['type'];
- $item->confKey = $confKey;
- if(!empty($params['enabled'])) {
+ if (!empty($params['enabled'])) {
$item->enabled = $params['enabled'];
}
- if(!empty($params['css'])){
+ if (!empty($params['css'])) {
$item->cssClass = $params['css'];
}
- $this->arrayOfParameters[$item->confKey] = $item;
+ $this->params[$item->confKey] = $item;
return true;
}
+ /**
+ * Reload for each item default conf
+ * note: this will override custom configuration
+ * @return bool
+ */
+ public function reloadConfs()
+ {
+
+ if (!array($this->params)) { return false; }
+ foreach ($this->params as $item) {
+ $item->reloadConf();
+ }
+
+ return true;
+ }
+
+
+
+ /**
+ * Create a new item
+ * @param $confKey the conf key used in database
+ * @return formSetupItem the new setup item created
+ */
+ public function newItem($confKey)
+ {
+ $item = new formSetupItem($confKey);
+ $this->params[$item->confKey] = $item;
+ return $this->params[$item->confKey];
+ }
}
-
+/**
+ * This class help to create item for class formSetup
+ */
class formSetupItem
{
/**
@@ -194,67 +240,108 @@ class formSetupItem
/** @var string $helpText */
public $helpText = '';
- /** @var bool|string set this var to override field output */
+ /** @var string $value */
+ public $fieldValue;
+
+ /** @var bool|string set this var to override field output will override $fieldInputOverride and $fieldOutputOverride too */
public $fieldOverride = false;
+ /** @var bool|string set this var to override field output */
+ public $fieldInputOverride = false;
+
+ /** @var bool|string set this var to override field output */
+ public $fieldOutputOverride = false;
+
/**
* @var string $errors
*/
public $errors = array();
/**
+ * TODO each type must have setAs{type} method to help configuration
+ * And set var as protected when its done configuration must be done by method
* @var string $type 'string', 'textarea', 'category:'.Categorie::TYPE_CUSTOMER', 'emailtemplate', 'thirdparty_type'
*/
- public $type;
+ public $type = 'string';
- public $enabled = 0;
+ public $enabled = 1;
public $cssClass = '';
/**
* Constructor
*
- * @param $confKey
+ * @param $confKey the conf key used in database
*/
public function __construct($confKey)
{
- global $langs, $db;
+ global $langs, $db, $conf;
$this->db = $db;
$this->form = new Form($this->db);
$this->langs = $langs;
$this->confKey = $confKey;
+ $this->fieldValue = $conf->global->{$this->confKey};
}
- public function getHelpText(){
- if(!empty($this->helpText)){ return $this->helpText; }
+ /**
+ * reload conf value from databases
+ * @return null
+ */
+ public function reloadConf()
+ {
+ global $conf;
+ $this->fieldValue = $conf->global->{$this->confKey};
+ }
+
+ /**
+ * Get help text or generate it
+ * @return int|string
+ */
+ public function getHelpText()
+ {
+ if (!empty($this->helpText)) { return $this->helpText; }
return (($this->langs->trans($this->confKey . 'Tooltip') != $this->confKey . 'Tooltip') ? $this->langs->trans($this->confKey . 'Tooltip') : '');
}
- public function getNameText(){
- if(!empty($this->nameText)){ return $this->nameText; }
- return (($this->langs->trans($this->confKey) != $this->confKey) ? $this->langs->trans($this->confKey) : $this->langs->trans('MissingTranslationForConfKey',$this->confKey));
+ /**
+ * Get field name text or generate it
+ * @return false|int|string
+ */
+ public function getNameText()
+ {
+ if (!empty($this->nameText)) { return $this->nameText; }
+ return (($this->langs->trans($this->confKey) != $this->confKey) ? $this->langs->trans($this->confKey) : $this->langs->trans('MissingTranslationForConfKey', $this->confKey));
}
- public function generateInputField(){
+ /**
+ * generate input field
+ * @return bool|string
+ */
+ public function generateInputField()
+ {
global $conf, $user;
- if(!empty($this->fieldOverride)){
+ if (!empty($this->fieldOverride)) {
return $this->fieldOverride;
}
+ if (!empty($this->fieldInputOverride)) {
+ return $this->fieldInputOverride;
+ }
+
$out = '';
if ($this->type == 'textarea') {
$out.= '\n";
} elseif ($this->type== 'html') {
require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php';
- $doleditor = new DolEditor($this->confKey, $conf->global->{$this->confKey}, '', 160, 'dolibarr_notes', '', false, false, $conf->fckeditor->enabled, ROWS_5, '90%');
+ $doleditor = new DolEditor($this->confKey, $this->fieldValue, '', 160, 'dolibarr_notes', '', false, false, $conf->fckeditor->enabled, ROWS_5, '90%');
$doleditor->Create();
} elseif ($this->type == 'yesno') {
- $out.= $this->form->selectyesno($this->confKey, $conf->global->{$this->confKey}, 1);
+ $out.= $this->form->selectyesno($this->confKey, $this->fieldValue, 1);
} elseif (preg_match('/emailtemplate:/', $this->type)) {
include_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php';
$formmail = new FormMail($this->db);
@@ -274,7 +361,7 @@ class formSetupItem
$arrayOfMessageName[$modelMail->id] = $this->langs->trans(preg_replace('/\(|\)/', '', $modelMail->label)) . $moreonlabel;
}
}
- $out.= $this->form->selectarray($this->confKey, $arrayOfMessageName, $conf->global->{$this->confKey}, 'None', 0, 0, '', 0, 0, 0, '', '', 1);
+ $out.= $this->form->selectarray($this->confKey, $arrayOfMessageName, $this->fieldValue, 'None', 0, 0, '', 0, 0, 0, '', '', 1);
} elseif (preg_match('/category:/', $this->type)) {
require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
@@ -282,13 +369,13 @@ class formSetupItem
$tmp = explode(':', $this->type);
$out.= img_picto('', 'category', 'class="pictofixedwidth"');
- $out.= $formother->select_categories($tmp[1], $conf->global->{$this->confKey}, $this->confKey, 0, $this->langs->trans('CustomersProspectsCategoriesShort'));
+ $out.= $formother->select_categories($tmp[1], $this->fieldValue, $this->confKey, 0, $this->langs->trans('CustomersProspectsCategoriesShort'));
} elseif (preg_match('/thirdparty_type/', $this->type)) {
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
$formcompany = new FormCompany($this->db);
- $out.= $formcompany->selectProspectCustomerType($conf->global->{$this->confKey}, $this->confKey);
+ $out.= $formcompany->selectProspectCustomerType($this->fieldValue, $this->confKey);
} elseif ($this->type == 'securekey') {
- $out.= ' ';
+ $out.= ' ';
if (!empty($conf->use_javascript_ajax)) {
$out.= ' '.img_picto($this->langs->trans('Generate'), 'refresh', 'id="generate_token'.$this->confKey.'" class="linkobject"');
}
@@ -309,11 +396,11 @@ class formSetupItem
}
} elseif ($this->type == 'product') {
if (!empty($conf->product->enabled) || !empty($conf->service->enabled)) {
- $selected = (empty($conf->global->{$this->confKey}) ? '' : $conf->global->{$this->confKey});
+ $selected = (empty($this->fieldValue) ? '' : $this->fieldValue);
$this->form->select_produits($selected, $this->confKey, '', 0);
}
} else {
- $out.= ' ';
+ $out.= ' ';
}
return $out;
@@ -321,35 +408,44 @@ class formSetupItem
/**
- * add error
- * @param array|string $errors
+ * Add error
+ * @param array|string $errors the error text
+ * @return null
*/
- public function setErrors($errors){
- if(is_array($errors)){
- if(!empty($errors)){
- foreach ($errors as $error){
+ public function setErrors($errors)
+ {
+ if (is_array($errors)) {
+ if (!empty($errors)) {
+ foreach ($errors as $error) {
$this->setErrors($error);
}
}
- }
- elseif(!empty($errors)){
+ } elseif (!empty($errors)) {
$this->errors[] = $errors;
}
}
- public function generateOutputField(){
+ /**
+ * @return bool|string Generate the output html for this item
+ */
+ public function generateOutputField()
+ {
global $conf, $user;
- if(!empty($this->fieldOverride)){
+ if (!empty($this->fieldOverride)) {
return $this->fieldOverride;
}
+ if (!empty($this->fieldOutputOverride)) {
+ return $this->fieldOutputOverride;
+ }
+
$out = '';
if ($this->type == 'textarea') {
- $out.= dol_nl2br($conf->global->{$this->confKey});
+ $out.= dol_nl2br($this->fieldValue);
} elseif ($this->type== 'html') {
- $out.= $conf->global->{$this->confKey};
+ $out.= $this->fieldValue;
} elseif ($this->type == 'yesno') {
$out.= ajax_constantonoff($this->confKey);
} elseif (preg_match('/emailtemplate:/', $this->type)) {
@@ -358,14 +454,14 @@ class formSetupItem
$tmp = explode(':', $this->type);
- $template = $formmail->getEMailTemplate($this->db, $tmp[1], $user, $this->langs, $conf->global->{$this->confKey});
+ $template = $formmail->getEMailTemplate($this->db, $tmp[1], $user, $this->langs, $this->fieldValue);
if ($template<0) {
$this->setErrors($formmail->errors);
}
$out.= $this->langs->trans($template->label);
} elseif (preg_match('/category:/', $this->type)) {
$c = new Categorie($this->db);
- $result = $c->fetch($conf->global->{$this->confKey});
+ $result = $c->fetch($this->fieldValue);
if ($result < 0) {
$this->setErrors($c->errors);
}
@@ -376,28 +472,105 @@ class formSetupItem
}
$out.= '' . implode(' ', $toprint) . ' ';
} elseif (preg_match('/thirdparty_type/', $this->type)) {
- if ($conf->global->{$this->confKey}==2) {
+ if ($this->fieldValue==2) {
$out.= $this->langs->trans("Prospect");
- } elseif ($conf->global->{$this->confKey}==3) {
+ } elseif ($this->fieldValue==3) {
$out.= $this->langs->trans("ProspectCustomer");
- } elseif ($conf->global->{$this->confKey}==1) {
+ } elseif ($this->fieldValue==1) {
$out.= $this->langs->trans("Customer");
- } elseif ($conf->global->{$this->confKey}==0) {
+ } elseif ($this->fieldValue==0) {
$out.= $this->langs->trans("NorProspectNorCustomer");
}
} elseif ($this->type == 'product') {
$product = new Product($this->db);
- $resprod = $product->fetch($conf->global->{$this->confKey});
+ $resprod = $product->fetch($this->fieldValue);
if ($resprod > 0) {
$out.= $product->ref;
} elseif ($resprod < 0) {
$this->setErrors($product->errors);
}
} else {
- $out.= $conf->global->{$this->confKey};
+ $out.= $this->fieldValue;
}
return $out;
}
+ /*
+ * METHODS FOR SETTING DISPLAY TYPE
+ */
+
+ /**
+ * Set type of input as string
+ * @return null
+ */
+ public function setAsString()
+ {
+ $this->type = 'string';
+ }
+
+ /**
+ * Set type of input as textarea
+ * @return null
+ */
+ public function setAsTextarea()
+ {
+ $this->type = 'textarea';
+ }
+
+ /**
+ * Set type of input as html editor
+ * @return null
+ */
+ public function setAsHtml()
+ {
+ $this->type = 'html';
+ }
+
+ /**
+ * Set type of input as emailtemplate selector
+ * @return null
+ */
+ public function setAsEmailTemplate()
+ {
+ $this->type = 'emailtemplate';
+ }
+
+ /**
+ * Set type of input as thirdparty_type selector
+ * @return null
+ */
+ public function setAsThirdpartyType()
+ {
+ $this->type = 'thirdparty_type';
+ }
+
+ /**
+ * Set type of input as Yes
+ * @return null
+ */
+ public function setAsYesNo()
+ {
+ $this->type = 'yesno';
+ }
+
+ /**
+ * Set type of input as secure key
+ * @return null
+ */
+ public function setAsSecureKey()
+ {
+ $this->type = 'securekey';
+ }
+
+ /**
+ * Set type of input as a category selector
+ * TODO add default value
+ * @param int $catType Type of category ('customer', 'supplier', 'contact', 'product', 'member'). Old mode (0, 1, 2, ...) is deprecated.
+ * @return null
+ */
+ public function setAsCategory($catType)
+ {
+ $this->type = 'category:'.$catType;
+ }
}
diff --git a/htdocs/modulebuilder/template/admin/setup.php b/htdocs/modulebuilder/template/admin/setup.php
index 390f45d955c..e3e32cf6f6b 100644
--- a/htdocs/modulebuilder/template/admin/setup.php
+++ b/htdocs/modulebuilder/template/admin/setup.php
@@ -85,6 +85,27 @@ $arrayofparameters = array(
//'MYMODULE_MYPARAM7'=>array('type'=>'product', 'enabled'=>1),
);
+require_once DOL_DOCUMENT_ROOT.'/core/class/html.formsetup.class.php';
+$formSetup = new formSetup($db);
+
+$formSetup->addItemsFromParamsArray($arrayofparameters);
+
+// Hôte
+$item = $formSetup->newItem('GPC_HOST');
+$item->fieldOverride = (empty($_SERVER['HTTPS']) ? 'http://' : 'https://') . $_SERVER['HTTP_HOST'];
+
+// Setup conf MYMODULE_MYPARAM1 as a simple string input
+$item = $formSetup->newItem('MYMODULE_MYPARAM1');
+
+// // Setup conf MYMODULE_MYPARAM1 as a simple textarea input but we replace the text of field title
+$item = $formSetup->newItem('MYMODULE_MYPARAM2');
+$item->nameText = $item->getNameText().' https://console.developers.google.com/apis/credentials ';
+
+// Clé pour API : Client Secret
+$formSetup->newItem('GPC_GOOGLE_CLIENT_SECRET');
+
+
+
$error = 0;
$setupnotempty = 0;
@@ -97,6 +118,7 @@ $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
if ((float) DOL_VERSION >= 6) {
include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
+ $formSetup->reloadConfs();
}
if ($action == 'updateMask') {
@@ -222,11 +244,6 @@ print dol_get_fiche_head($head, 'settings', $langs->trans($page_name), -1, "mymo
echo ''.$langs->trans("MyModuleSetupPage").' ';
-require_once DOL_DOCUMENT_ROOT.'/core/class/html.formsetup.class.php';
-$formSetup = new formSetup($db);
-
-$formSetup->addItemsFromParamsArray($arrayofparameters);
-
if ($action == 'edit') {
print ' '.$langs->trans("LDAPServerUseTLSExample").' ';
+// Password hash type
+print ''.$langs->trans("LDAPPasswordHashType").' ';
+print $formldap->selectLdapPasswordHashType(getDolGlobalString('LDAP_PASSWORD_HASH_TYPE'), 'LDAP_PASSWORD_HASH_TYPE');
+print ' '.$langs->trans("LDAPPasswordHashTypeExample").' ';
+
print '';
print ''.$langs->trans("ForANonAnonymousAccess").' ';
print " \n";
diff --git a/htdocs/core/class/ldap.class.php b/htdocs/core/class/ldap.class.php
index e2ce33cc45f..0815874d71c 100644
--- a/htdocs/core/class/ldap.class.php
+++ b/htdocs/core/class/ldap.class.php
@@ -159,8 +159,6 @@ class Ldap
$this->attr_mobile = $conf->global->LDAP_FIELD_MOBILE;
}
-
-
// Connection handling methods -------------------------------------------
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
@@ -218,8 +216,9 @@ class Ldap
// Upgrade connexion to TLS, if requested by the configuration
if (!empty($conf->global->LDAP_SERVER_USE_TLS)) {
// For test/debug
- //ldap_set_option($this->connection, LDAP_OPT_DEBUG_LEVEL, 7);
- //ldap_set_option($this->connection, LDAP_OPT_PROTOCOL_VERSION, 3);
+ ldap_set_option($this->connection, LDAP_OPT_DEBUG_LEVEL, 7);
+ ldap_set_option($this->connection, LDAP_OPT_PROTOCOL_VERSION, 3);
+ ldap_set_option($this->connection, LDAP_OPT_REFERRALS, 0);
$resulttls = ldap_start_tls($this->connection);
if (!$resulttls) {
@@ -291,8 +290,6 @@ class Ldap
return $return;
}
-
-
/**
* Simply closes the connection set up earlier.
* Returns true if OK, false if there was an error.
@@ -906,10 +903,10 @@ class Ldap
return -3;
}
- $search = ldap_search($this->connection, $dn, $filter);
+ $search = @ldap_search($this->connection, $dn, $filter);
// Only one entry should ever be returned
- $entry = ldap_first_entry($this->connection, $search);
+ $entry = @ldap_first_entry($this->connection, $search);
if (!$entry) {
$this->ldapErrorCode = -1;
diff --git a/htdocs/langs/en_US/ldap.lang b/htdocs/langs/en_US/ldap.lang
index 8b6f0864215..b13e454159d 100644
--- a/htdocs/langs/en_US/ldap.lang
+++ b/htdocs/langs/en_US/ldap.lang
@@ -25,3 +25,5 @@ ContactSynchronized=Contact synchronized
ForceSynchronize=Force synchronizing Dolibarr -> LDAP
ErrorFailedToReadLDAP=Failed to read LDAP database. Check LDAP module setup and database accessibility.
PasswordOfUserInLDAP=Password of user in LDAP
+LDAPPasswordHashType=Password hash type
+LDAPPasswordHashTypeExample=Type of password hash used on the server
\ No newline at end of file
From 5be40b926b6198e638dba1e796c2114417cd75c9 Mon Sep 17 00:00:00 2001
From: Benjamin Chantalat <74144396+PyroShape@users.noreply.github.com>
Date: Mon, 1 Nov 2021 19:56:24 +0100
Subject: [PATCH 021/178] Clean function not use anymore
---
.../class/fournisseur.commande.class.php | 44 -------------------
1 file changed, 44 deletions(-)
diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php
index 787d9ee321b..9cf3c74e967 100644
--- a/htdocs/fourn/class/fournisseur.commande.class.php
+++ b/htdocs/fourn/class/fournisseur.commande.class.php
@@ -2274,50 +2274,6 @@ class CommandeFournisseur extends CommonOrder
return $ret;
}
- /**
- * Return array of the lines that are waiting to be dispatched
- *
- * @return array Array of lines
- */
- public function getNotCompletlyDispatchedLines()
- {
- $ret = array();
-
- $sql = "SELECT supplierOrderDet.fk_product as product_id, supplierOrderDet.qty as qty_ordered, supplierOrderDet.fk_commande,";
- $sql .= " dispatch.rowid as dispatchedlineid, sum(dispatch.qty) as qty_dispatched";
- $sql .= " FROM ".MAIN_DB_PREFIX."commande_fournisseurdet as supplierOrderDet";
- $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."commande_fournisseur_dispatch as dispatch ON supplierOrderDet.rowid = dispatch.fk_commandefourndet";
- $sql .= " WHERE supplierOrderDet.fk_commande = ".((int) $this->id);
- $sql .= " GROUP BY supplierOrderDet.fk_product";
-
- $resql = $this->db->query($sql);
-
- if ($resql) {
- $num = $this->db->num_rows($resql);
- $i = 0;
-
- while ($i < $num) {
- $objp = $this->db->fetch_object($resql);
-
- if ($objp) {
- // If product not completly dispatched
- if (is_null($objp->qty_dispatched) OR ($objp->qty_dispatched < $objp->qty_ordered)) {
- $ret[] = array(
- 'product_id' => $objp->product_id,
- 'qty_ordered' => $objp->qty_ordered,
- 'qty_dispatched' => $objp->qty_dispatched,
- );
- }
- }
- $i++;
- }
- } else {
- dol_print_error($this->db, 'Failed to execute request to get not completly dispatched lines');
- }
-
- return $ret;
- }
-
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Set a delivery in database for this supplier order
From 7b88f1da3fea112919f0c61bf9cb894323cbfbab Mon Sep 17 00:00:00 2001
From: Benjamin Chantalat <74144396+PyroShape@users.noreply.github.com>
Date: Mon, 1 Nov 2021 19:56:55 +0100
Subject: [PATCH 022/178] Change to have number of item dispached on number of
total item
---
htdocs/core/lib/fourn.lib.php | 18 +++++++++++++++---
1 file changed, 15 insertions(+), 3 deletions(-)
diff --git a/htdocs/core/lib/fourn.lib.php b/htdocs/core/lib/fourn.lib.php
index e81bdb5e9d0..7fc903db72b 100644
--- a/htdocs/core/lib/fourn.lib.php
+++ b/htdocs/core/lib/fourn.lib.php
@@ -157,12 +157,24 @@ function ordersupplier_prepare_head($object)
if (!empty($conf->stock->enabled) && (!empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER) || !empty($conf->global->STOCK_CALCULATE_ON_RECEPTION) || !empty($conf->global->STOCK_CALCULATE_ON_RECEPTION_CLOSE))) {
$langs->load("stocks");
- $nbLineToDispatch = count($object->getNotCompletlyDispatchedLines());
$head[$h][0] = DOL_URL_ROOT.'/fourn/commande/dispatch.php?id='.$object->id;
$head[$h][1] = $langs->trans("OrderDispatch");
- if ($nbLineToDispatch > 0) {
- $head[$h][1] .= ''.$nbLineToDispatch.' ';
+
+ //If dispach process running we add the number of item to dispatch into the head
+ if ($object->statut == '3' OR $object->statut == '4' OR $object->statut == '5') {
+ $lines = $object->fetch_lines();
+ $dispachedLines = $object->getDispachedLines(1);
+ $sumQtyAllreadyDispatched = 0;
+ for ($line = 0 ; $line < count($dispachedLines) ; $line++) {
+ $sumQtyAllreadyDispatched = $sumQtyAllreadyDispatched + $dispachedLines[$line]['qty'];
+ }
+ $sumQtyOrdered = 0;
+ for ($line = 0 ; $line < count($object->lines) ; $line++) {
+ $sumQtyOrdered = $sumQtyOrdered + $object->lines[$line]->qty;
+ }
+ $head[$h][1] .= ''.$sumQtyAllreadyDispatched.' / '.$sumQtyOrdered.' ';
}
+
$head[$h][2] = 'dispatch';
$h++;
}
From 85372a70836d2d9cdb003cc490bd8fa17c73fc46 Mon Sep 17 00:00:00 2001
From: stickler-ci
Date: Mon, 1 Nov 2021 18:57:35 +0000
Subject: [PATCH 023/178] Fixing style errors.
---
htdocs/core/lib/fourn.lib.php | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/htdocs/core/lib/fourn.lib.php b/htdocs/core/lib/fourn.lib.php
index 7fc903db72b..27ebc98635d 100644
--- a/htdocs/core/lib/fourn.lib.php
+++ b/htdocs/core/lib/fourn.lib.php
@@ -159,22 +159,22 @@ function ordersupplier_prepare_head($object)
$langs->load("stocks");
$head[$h][0] = DOL_URL_ROOT.'/fourn/commande/dispatch.php?id='.$object->id;
$head[$h][1] = $langs->trans("OrderDispatch");
-
+
//If dispach process running we add the number of item to dispatch into the head
if ($object->statut == '3' OR $object->statut == '4' OR $object->statut == '5') {
$lines = $object->fetch_lines();
$dispachedLines = $object->getDispachedLines(1);
$sumQtyAllreadyDispatched = 0;
- for ($line = 0 ; $line < count($dispachedLines) ; $line++) {
+ for ($line = 0 ; $line < count($dispachedLines); $line++) {
$sumQtyAllreadyDispatched = $sumQtyAllreadyDispatched + $dispachedLines[$line]['qty'];
}
$sumQtyOrdered = 0;
- for ($line = 0 ; $line < count($object->lines) ; $line++) {
+ for ($line = 0 ; $line < count($object->lines); $line++) {
$sumQtyOrdered = $sumQtyOrdered + $object->lines[$line]->qty;
- }
+ }
$head[$h][1] .= ''.$sumQtyAllreadyDispatched.' / '.$sumQtyOrdered.' ';
}
-
+
$head[$h][2] = 'dispatch';
$h++;
}
From 85776f7529dbc3d969e827a82d6fcf1c1b168159 Mon Sep 17 00:00:00 2001
From: Benjamin Chantalat <74144396+PyroShape@users.noreply.github.com>
Date: Mon, 1 Nov 2021 20:08:00 +0100
Subject: [PATCH 024/178] Avoid function calls in a FOR loop test part
---
htdocs/core/lib/fourn.lib.php | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/htdocs/core/lib/fourn.lib.php b/htdocs/core/lib/fourn.lib.php
index 27ebc98635d..25bbd52e413 100644
--- a/htdocs/core/lib/fourn.lib.php
+++ b/htdocs/core/lib/fourn.lib.php
@@ -162,14 +162,17 @@ function ordersupplier_prepare_head($object)
//If dispach process running we add the number of item to dispatch into the head
if ($object->statut == '3' OR $object->statut == '4' OR $object->statut == '5') {
- $lines = $object->fetch_lines();
+ $object->fetch_lines();
+ $nbLinesOrdered = count($object->lines);
$dispachedLines = $object->getDispachedLines(1);
+ $nbDispachedLines = count($dispachedLines);
+
$sumQtyAllreadyDispatched = 0;
- for ($line = 0 ; $line < count($dispachedLines); $line++) {
+ for ($line = 0 ; $line < $nbDispachedLines; $line++) {
$sumQtyAllreadyDispatched = $sumQtyAllreadyDispatched + $dispachedLines[$line]['qty'];
}
$sumQtyOrdered = 0;
- for ($line = 0 ; $line < count($object->lines); $line++) {
+ for ($line = 0 ; $line < $nbLinesOrdered; $line++) {
$sumQtyOrdered = $sumQtyOrdered + $object->lines[$line]->qty;
}
$head[$h][1] .= ''.$sumQtyAllreadyDispatched.' / '.$sumQtyOrdered.' ';
From 5bb6185e64359d476954359076e64473d13591e6 Mon Sep 17 00:00:00 2001
From: Anthony Berton <34568357+bb2a@users.noreply.github.com>
Date: Tue, 2 Nov 2021 12:37:39 +0100
Subject: [PATCH 025/178] add_substitution
---
htdocs/core/lib/functions.lib.php | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php
index 084a4a4f25a..5eb0bd7d62c 100644
--- a/htdocs/core/lib/functions.lib.php
+++ b/htdocs/core/lib/functions.lib.php
@@ -7212,7 +7212,10 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null,
if ($object->id > 0) {
$substitutionarray['__ONLINE_PAYMENT_TEXT_AND_URL__'] = ($paymenturl ?str_replace('\n', "\n", $outputlangs->trans("PredefinedMailContentLink", $paymenturl)) : '');
$substitutionarray['__ONLINE_PAYMENT_URL__'] = $paymenturl;
-
+
+ if (is_object($object) && $object->element == 'propal') {
+ $substitutionarray['__ONLINE_SIGN_URL__'] = getOnlineSignatureUrl(0, 'proposal', $object->ref);
+ }
if (!empty($conf->global->PROPOSAL_ALLOW_EXTERNAL_DOWNLOAD) && is_object($object) && $object->element == 'propal') {
$substitutionarray['__DIRECTDOWNLOAD_URL_PROPOSAL__'] = $object->getLastMainDocLink($object->element);
} else {
From b98efd7e44085ff4f7bb0e9ac056139994bb7c4a Mon Sep 17 00:00:00 2001
From: John BOTELLA
Date: Tue, 2 Nov 2021 13:55:12 +0100
Subject: [PATCH 026/178] Add rank item management and add Hook
---
htdocs/core/class/html.formsetup.class.php | 258 ++++++++++++++++--
htdocs/modulebuilder/template/admin/setup.php | 27 +-
2 files changed, 248 insertions(+), 37 deletions(-)
diff --git a/htdocs/core/class/html.formsetup.class.php b/htdocs/core/class/html.formsetup.class.php
index df99b6cdbbb..cbf8cbd37ba 100644
--- a/htdocs/core/class/html.formsetup.class.php
+++ b/htdocs/core/class/html.formsetup.class.php
@@ -30,6 +30,9 @@ class formSetup
/** @var formSetupItem[] */
public $params = array();
+ /**
+ * @var int
+ */
public $setupNotEmpty = 0;
/** @var Translate */
@@ -38,6 +41,9 @@ class formSetup
/** @var Form */
public $form;
+ /** @var int */
+ protected $maxItemRank;
+
/**
* Constructor
*
@@ -63,29 +69,81 @@ class formSetup
*/
public function generateOutput($editMode = false)
{
+ global $hookmanager, $action;
require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php';
- $out = ' ';
- if ($editMode) {
- $out .= ' ';
+ $parameters = array(
+ 'editMode' => $editMode
+ );
+ $reshook = $hookmanager->executeHooks('formSetupBeforeGenerateOutput', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
+ if ($reshook < 0) {
+ setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
}
- $out.= '';
- $out.= '';
- $out.= '';
- $out.= ' '.$this->langs->trans("Parameter").' ';
- $out.= ' '.$this->langs->trans("Value").' ';
- $out.= ' ';
- $out.= ' ';
+ if ($reshook > 0) {
+ return $hookmanager->resPrint;
+ } else {
+ $out = ' ';
+ if ($editMode) {
+ $out .= ' ';
+ }
- $out.= '';
+ $out .= '';
+ $out .= '';
+ $out .= '';
+ $out .= ' ' . $this->langs->trans("Parameter") . ' ';
+ $out .= ' ' . $this->langs->trans("Value") . ' ';
+ $out .= ' ';
+ $out .= ' ';
+
+ // Sort items before render
+ $this->sortingItems();
+
+ $out .= '';
+ foreach ($this->params as $item) {
+ $out .= $this->generateLineOutput($item, $editMode);
+ }
+ $out .= ' ';
+
+ $out .= '
';
+ return $out;
+ }
+ }
+
+ /**
+ * @param bool $noMessageInUpdate display event message on errors and success
+ * @return void|null
+ */
+ public function saveConfFromPost($noMessageInUpdate = false)
+ {
+
+ if (empty($this->params)) {
+ return null;
+ }
+
+ $this->db->begin();
+ $error = 0;
foreach ($this->params as $item) {
- $out.= $this->generateLineOutput($item, $editMode);
+ $res = $item->setValueFromPost();
+ if ($res > 0) {
+ $item->saveConfValue();
+ } elseif ($res < 0) {
+ $error++;
+ break;
+ }
}
- $out.= ' ';
- $out.= '
';
- return $out;
+ if (!$error) {
+ $this->db->commit();
+ if (empty($noMessageInUpdate)) {
+ setEventMessages($this->langs->trans("SetupSaved"), null);
+ }
+ } else {
+ $this->db->rollback();
+ if (empty($noMessageInUpdate)) {
+ setEventMessages($this->langs->trans("SetupNotSaved"), null, 'errors');
+ }
+ }
}
/**
@@ -209,25 +267,133 @@ class formSetup
if (!array($this->params)) { return false; }
foreach ($this->params as $item) {
- $item->reloadConf();
+ $item->reloadValueFromConf();
}
return true;
}
-
/**
* Create a new item
+ * the tagret is useful with hooks : that allow externals modules to add setup items on good place
* @param $confKey the conf key used in database
+ * @param string $targetItemKey target item used to place the new item beside
+ * @param bool $insertAfterTarget insert before or after target item ?
* @return formSetupItem the new setup item created
*/
- public function newItem($confKey)
+ public function newItem($confKey, $targetItemKey = false, $insertAfterTarget = false)
{
$item = new formSetupItem($confKey);
+
+ // set item rank if not defined as last item
+ if (empty($item->rank)) {
+ $item->rank = $this->getCurentItemMaxRank() + 1;
+ $this->setItemMaxRank($item->rank); // set new max rank if needed
+ }
+
+ // try to get rank from target column, this will override item->rank
+ if (!empty($targetItemKey)) {
+ if (isset($this->params[$targetItemKey])) {
+ $targetItem = $this->params[$targetItemKey];
+ $item->rank = $targetItem->rank; // $targetItem->rank will be increase after
+ if ($targetItem->rank >= 0 && $insertAfterTarget) {
+ $item->rank++;
+ }
+ }
+
+ // calc new rank for each item to make place for new item
+ foreach ($this->params as $fItem) {
+ if ($item->rank <= $fItem->rank) {
+ $fItem->rank = $fItem->rank + 1;
+ $this->setItemMaxRank($fItem->rank); // set new max rank if needed
+ }
+ }
+ }
+
$this->params[$item->confKey] = $item;
return $this->params[$item->confKey];
}
+
+ /**
+ * Sort items according to rank
+ * @return bool
+ */
+ public function sortingItems()
+ {
+ // Sorting
+ return uasort($this->params, array($this, 'itemSort'));
+ }
+
+ /**
+ * @param bool $cache To use cache or not
+ * @return int
+ */
+ public function getCurentItemMaxRank($cache = true)
+ {
+ if (empty($this->params)) {
+ return 0;
+ }
+
+ if ($cache && $this->maxItemRank > 0) {
+ return $this->maxItemRank;
+ }
+
+ $this->maxItemRank = 0;
+ foreach ($this->params as $item) {
+ $this->maxItemRank = max($this->maxItemRank, $item->rank);
+ }
+
+ return $this->maxItemRank;
+ }
+
+
+ /**
+ * set new max rank if needed
+ * @param int $rank the item rank
+ * @return int|void
+ */
+ public function setItemMaxRank($rank)
+ {
+ $this->maxItemRank = max($this->maxItemRank, $rank);
+ }
+
+
+ /**
+ * get item position rank from item key
+ *
+ * @param string $itemKey the item key
+ * @return int rank on success and -1 on error
+ */
+ public function getLineRank($itemKey)
+ {
+ if (!isset($this->params[$itemKey]->rank)) {
+ return -1;
+ }
+ return $this->params[$itemKey]->rank;
+ }
+
+
+ /**
+ * uasort callback function to Sort params items
+ *
+ * @param formSetupItem $a formSetup item
+ * @param formSetupItem $b formSetup item
+ * @return int Return compare result
+ */
+ public function itemSort(formSetupItem $a, formSetupItem $b)
+ {
+ if (empty($a->rank)) {
+ $a->rank = 0;
+ }
+ if (empty($b->rank)) {
+ $b->rank = 0;
+ }
+ if ($a->rank == $b->rank) {
+ return 0;
+ }
+ return ($a->rank < $b->rank) ? -1 : 1;
+ }
}
/**
@@ -243,6 +409,9 @@ class formSetupItem
/** @var Translate */
public $langs;
+ /** @var int */
+ public $entity;
+
/** @var Form */
public $form;
@@ -267,6 +436,9 @@ class formSetupItem
/** @var bool|string set this var to override field output */
public $fieldOutputOverride = false;
+ /** @var int $rank */
+ public $rank = 0;
+
/**
* @var string $errors
*/
@@ -294,6 +466,7 @@ class formSetupItem
$this->db = $db;
$this->form = new Form($this->db);
$this->langs = $langs;
+ $this->entity = $conf->entity;
$this->confKey = $confKey;
$this->fieldValue = $conf->global->{$this->confKey};
@@ -303,12 +476,58 @@ class formSetupItem
* reload conf value from databases
* @return null
*/
- public function reloadConf()
+ public function reloadValueFromConf()
{
global $conf;
$this->fieldValue = $conf->global->{$this->confKey};
}
+
+ /**
+ * Save const value based on htdocs/core/actions_setmoduleoptions.inc.php
+ * @return int -1 if KO, 1 if OK
+ */
+ public function saveConfValue()
+ {
+ // Modify constant only if key was posted (avoid resetting key to the null value)
+ if ($this->type != 'title') {
+ $result = dolibarr_set_const($this->db, $this->confKey, $this->fieldValue, 'chaine', 0, '', $this->entity);
+ if ($result < 0) {
+ return -1;
+ } else {
+ return 1;
+ }
+ }
+ }
+
+
+ /**
+ * Save const value based on htdocs/core/actions_setmoduleoptions.inc.php
+ * @return int -1 if KO, 0 nothing to do , 1 if OK
+ */
+ public function setValueFromPost()
+ {
+ // Modify constant only if key was posted (avoid resetting key to the null value)
+ if ($this->type != 'title') {
+ if (preg_match('/category:/', $this->type)) {
+ if (GETPOST($this->confKey, 'int') == '-1') {
+ $val_const = '';
+ } else {
+ $val_const = GETPOST($this->confKey, 'int');
+ }
+ } else {
+ $val_const = GETPOST($this->confKey, 'alpha');
+ }
+
+ // TODO add value check with class validate
+ $this->fieldValue = $val_const;
+
+ return 1;
+ }
+
+ return 0;
+ }
+
/**
* Get help text or generate it
* @return int|string
@@ -596,6 +815,7 @@ class formSetupItem
return $out;
}
+
/*
* METHODS FOR SETTING DISPLAY TYPE
*/
diff --git a/htdocs/modulebuilder/template/admin/setup.php b/htdocs/modulebuilder/template/admin/setup.php
index 007e9d84b12..527ea8eb32d 100644
--- a/htdocs/modulebuilder/template/admin/setup.php
+++ b/htdocs/modulebuilder/template/admin/setup.php
@@ -60,6 +60,9 @@ require_once '../lib/mymodule.lib.php';
// Translations
$langs->loadLangs(array("admin", "mymodule@mymodule"));
+// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
+$hookmanager->initHooks(array('mymodulesetup', 'globalsetup'));
+
// Access control
if (!$user->admin) {
accessforbidden();
@@ -74,22 +77,10 @@ $label = GETPOST('label', 'alpha');
$scandir = GETPOST('scan_dir', 'alpha');
$type = 'myobject';
-$arrayofparameters = array(
- 'MYMODULE_MYPARAM1'=>array('type'=>'string', 'css'=>'minwidth500' ,'enabled'=>1),
- 'MYMODULE_MYPARAM2'=>array('type'=>'textarea','enabled'=>1),
- //'MYMODULE_MYPARAM3'=>array('type'=>'category:'.Categorie::TYPE_CUSTOMER, 'enabled'=>1),
- //'MYMODULE_MYPARAM4'=>array('type'=>'emailtemplate:thirdparty', 'enabled'=>1),
- //'MYMODULE_MYPARAM5'=>array('type'=>'yesno', 'enabled'=>1),
- //'MYMODULE_MYPARAM5'=>array('type'=>'thirdparty_type', 'enabled'=>1),
- //'MYMODULE_MYPARAM6'=>array('type'=>'securekey', 'enabled'=>1),
- //'MYMODULE_MYPARAM7'=>array('type'=>'product', 'enabled'=>1),
-);
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formsetup.class.php';
$formSetup = new formSetup($db);
-$formSetup->addItemsFromParamsArray($arrayofparameters);
-
// Hôte
$item = $formSetup->newItem('NO_PARAM_JUST_TEXT');
@@ -131,11 +122,10 @@ $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
* Actions
*/
-if ((float) DOL_VERSION >= 6) {
- // TODO Add save setup by formSetup
- $arrayofparameters = $formSetup->exportItemsAsParamsArray();
- include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
- $formSetup->reloadConfs();
+if ((float) DOL_VERSION >= 15) {
+ if ($action == 'update') {
+ $formSetup->saveConfFromPost();
+ }
}
if ($action == 'updateMask') {
@@ -275,8 +265,9 @@ if ($action == 'edit') {
print '';
print ' ';
} else {
- if (!empty($arrayofparameters)) {
+ if (!empty($formSetup->params)) {
print $formSetup->generateOutput();
+ $setupnotempty++;
print '';
print '
'.$langs->trans("Modify").' ';
From bbe71c9c32d792a3fd0cfe56b37394d9af6f4942 Mon Sep 17 00:00:00 2001
From: John BOTELLA
Date: Tue, 2 Nov 2021 14:07:36 +0100
Subject: [PATCH 027/178] Rename var
---
htdocs/core/class/html.formsetup.class.php | 36 +++++++++----------
htdocs/modulebuilder/template/admin/setup.php | 2 +-
2 files changed, 19 insertions(+), 19 deletions(-)
diff --git a/htdocs/core/class/html.formsetup.class.php b/htdocs/core/class/html.formsetup.class.php
index cbf8cbd37ba..8f9d3af0528 100644
--- a/htdocs/core/class/html.formsetup.class.php
+++ b/htdocs/core/class/html.formsetup.class.php
@@ -28,7 +28,7 @@ class formSetup
public $db;
/** @var formSetupItem[] */
- public $params = array();
+ public $items = array();
/**
* @var int
@@ -100,7 +100,7 @@ class formSetup
$this->sortingItems();
$out .= '';
- foreach ($this->params as $item) {
+ foreach ($this->items as $item) {
$out .= $this->generateLineOutput($item, $editMode);
}
$out .= ' ';
@@ -117,13 +117,13 @@ class formSetup
public function saveConfFromPost($noMessageInUpdate = false)
{
- if (empty($this->params)) {
+ if (empty($this->items)) {
return null;
}
$this->db->begin();
$error = 0;
- foreach ($this->params as $item) {
+ foreach ($this->items as $item) {
$res = $item->setValueFromPost();
if ($res > 0) {
$item->saveConfValue();
@@ -234,7 +234,7 @@ class formSetup
$item->cssClass = $params['css'];
}
- $this->params[$item->confKey] = $item;
+ $this->items[$item->confKey] = $item;
return true;
}
@@ -247,7 +247,7 @@ class formSetup
public function exportItemsAsParamsArray()
{
$arrayofparameters = array();
- foreach ($this->params as $key => $item) {
+ foreach ($this->items as $key => $item) {
$arrayofparameters[$item->confKey] = array(
'type' => $item->getType(),
'enabled' => $item->enabled
@@ -265,8 +265,8 @@ class formSetup
public function reloadConfs()
{
- if (!array($this->params)) { return false; }
- foreach ($this->params as $item) {
+ if (!array($this->items)) { return false; }
+ foreach ($this->items as $item) {
$item->reloadValueFromConf();
}
@@ -294,8 +294,8 @@ class formSetup
// try to get rank from target column, this will override item->rank
if (!empty($targetItemKey)) {
- if (isset($this->params[$targetItemKey])) {
- $targetItem = $this->params[$targetItemKey];
+ if (isset($this->items[$targetItemKey])) {
+ $targetItem = $this->items[$targetItemKey];
$item->rank = $targetItem->rank; // $targetItem->rank will be increase after
if ($targetItem->rank >= 0 && $insertAfterTarget) {
$item->rank++;
@@ -303,7 +303,7 @@ class formSetup
}
// calc new rank for each item to make place for new item
- foreach ($this->params as $fItem) {
+ foreach ($this->items as $fItem) {
if ($item->rank <= $fItem->rank) {
$fItem->rank = $fItem->rank + 1;
$this->setItemMaxRank($fItem->rank); // set new max rank if needed
@@ -311,8 +311,8 @@ class formSetup
}
}
- $this->params[$item->confKey] = $item;
- return $this->params[$item->confKey];
+ $this->items[$item->confKey] = $item;
+ return $this->items[$item->confKey];
}
/**
@@ -322,7 +322,7 @@ class formSetup
public function sortingItems()
{
// Sorting
- return uasort($this->params, array($this, 'itemSort'));
+ return uasort($this->items, array($this, 'itemSort'));
}
/**
@@ -331,7 +331,7 @@ class formSetup
*/
public function getCurentItemMaxRank($cache = true)
{
- if (empty($this->params)) {
+ if (empty($this->items)) {
return 0;
}
@@ -340,7 +340,7 @@ class formSetup
}
$this->maxItemRank = 0;
- foreach ($this->params as $item) {
+ foreach ($this->items as $item) {
$this->maxItemRank = max($this->maxItemRank, $item->rank);
}
@@ -367,10 +367,10 @@ class formSetup
*/
public function getLineRank($itemKey)
{
- if (!isset($this->params[$itemKey]->rank)) {
+ if (!isset($this->items[$itemKey]->rank)) {
return -1;
}
- return $this->params[$itemKey]->rank;
+ return $this->items[$itemKey]->rank;
}
diff --git a/htdocs/modulebuilder/template/admin/setup.php b/htdocs/modulebuilder/template/admin/setup.php
index 527ea8eb32d..417c28f30a2 100644
--- a/htdocs/modulebuilder/template/admin/setup.php
+++ b/htdocs/modulebuilder/template/admin/setup.php
@@ -265,7 +265,7 @@ if ($action == 'edit') {
print '';
print ' ';
} else {
- if (!empty($formSetup->params)) {
+ if (!empty($formSetup->items)) {
print $formSetup->generateOutput();
$setupnotempty++;
From 12b046cb68a41ace480a519d366f3243b03144d6 Mon Sep 17 00:00:00 2001
From: John BOTELLA
Date: Tue, 2 Nov 2021 14:11:36 +0100
Subject: [PATCH 028/178] Fix class name
---
htdocs/core/class/html.formsetup.class.php | 20 +++++++++----------
htdocs/modulebuilder/template/admin/setup.php | 2 +-
2 files changed, 11 insertions(+), 11 deletions(-)
diff --git a/htdocs/core/class/html.formsetup.class.php b/htdocs/core/class/html.formsetup.class.php
index 8f9d3af0528..6f2ec2acfb6 100644
--- a/htdocs/core/class/html.formsetup.class.php
+++ b/htdocs/core/class/html.formsetup.class.php
@@ -19,7 +19,7 @@
/**
* This class help you create setup render
*/
-class formSetup
+class FormSetup
{
/**
@@ -27,7 +27,7 @@ class formSetup
*/
public $db;
- /** @var formSetupItem[] */
+ /** @var FormSetupItem[] */
public $items = array();
/**
@@ -147,7 +147,7 @@ class formSetup
}
/**
- * @param formSetupItem $item the setup item
+ * @param FormSetupItem $item the setup item
* @param bool $editMode Display as edit mod
* @return string the html output for an setup item
*/
@@ -223,7 +223,7 @@ class formSetup
//'MYMODULE_MYPARAM7'=>array('type'=>'product', 'enabled'=>1),
*/
- $item = new formSetupItem($confKey);
+ $item = new FormSetupItem($confKey);
$item->setTypeFromTypeString($params['type']);
if (!empty($params['enabled'])) {
@@ -280,11 +280,11 @@ class formSetup
* @param $confKey the conf key used in database
* @param string $targetItemKey target item used to place the new item beside
* @param bool $insertAfterTarget insert before or after target item ?
- * @return formSetupItem the new setup item created
+ * @return FormSetupItem the new setup item created
*/
public function newItem($confKey, $targetItemKey = false, $insertAfterTarget = false)
{
- $item = new formSetupItem($confKey);
+ $item = new FormSetupItem($confKey);
// set item rank if not defined as last item
if (empty($item->rank)) {
@@ -377,11 +377,11 @@ class formSetup
/**
* uasort callback function to Sort params items
*
- * @param formSetupItem $a formSetup item
- * @param formSetupItem $b formSetup item
+ * @param FormSetupItem $a formSetup item
+ * @param FormSetupItem $b formSetup item
* @return int Return compare result
*/
- public function itemSort(formSetupItem $a, formSetupItem $b)
+ public function itemSort(FormSetupItem $a, FormSetupItem $b)
{
if (empty($a->rank)) {
$a->rank = 0;
@@ -399,7 +399,7 @@ class formSetup
/**
* This class help to create item for class formSetup
*/
-class formSetupItem
+class FormSetupItem
{
/**
* @var DoliDB Database handler.
diff --git a/htdocs/modulebuilder/template/admin/setup.php b/htdocs/modulebuilder/template/admin/setup.php
index 417c28f30a2..206cca0ff52 100644
--- a/htdocs/modulebuilder/template/admin/setup.php
+++ b/htdocs/modulebuilder/template/admin/setup.php
@@ -79,7 +79,7 @@ $type = 'myobject';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formsetup.class.php';
-$formSetup = new formSetup($db);
+$formSetup = new FormSetup($db);
// Hôte
From 82b7f0e9e45e7b85b544ed8a8d9ca60cdb0dfabc Mon Sep 17 00:00:00 2001
From: kamel
Date: Tue, 2 Nov 2021 15:21:14 +0100
Subject: [PATCH 029/178] FIX second approval back in stable feature as is the
setting for minimum amount (last part from PR#14286)
---
htdocs/fourn/class/fournisseur.commande.class.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php
index 72ba5be84ee..00bc994096f 100644
--- a/htdocs/fourn/class/fournisseur.commande.class.php
+++ b/htdocs/fourn/class/fournisseur.commande.class.php
@@ -999,7 +999,7 @@ class CommandeFournisseur extends CommonOrder
if (empty($secondlevel)) { // standard or first level approval
$sql .= " date_approve='".$this->db->idate($now)."',";
$sql .= " fk_user_approve = ".$user->id;
- if (!empty($conf->global->SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED) && $conf->global->MAIN_FEATURES_LEVEL > 0 && $this->total_ht >= $conf->global->SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED) {
+ if (!empty($conf->global->SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED) && $this->total_ht >= $conf->global->SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED) {
if (empty($this->user_approve_id2)) {
$movetoapprovestatus = false; // second level approval not done
$comment = ' (first level)';
From 126fbf9f631a3ff7d226e8719d0c3b12a8c2dc20 Mon Sep 17 00:00:00 2001
From: Benjamin Chantalat <74144396+PyroShape@users.noreply.github.com>
Date: Tue, 2 Nov 2021 15:46:04 +0100
Subject: [PATCH 030/178] Change date format to be equal to mass stock
transfert
---
htdocs/product/stock/tpl/stockcorrection.tpl.php | 2 +-
htdocs/product/stock/tpl/stocktransfer.tpl.php | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/htdocs/product/stock/tpl/stockcorrection.tpl.php b/htdocs/product/stock/tpl/stockcorrection.tpl.php
index 05d628902fb..e1a5e734016 100644
--- a/htdocs/product/stock/tpl/stockcorrection.tpl.php
+++ b/htdocs/product/stock/tpl/stockcorrection.tpl.php
@@ -155,7 +155,7 @@ print ''.$langs->trans("MovementLabel").' ';
print '';
print ' ';
print ' ';
-print ''.$langs->trans("InventoryCode").' ';
+print ''.$langs->trans("InventoryCode").' ';
print '';
print '
';
diff --git a/htdocs/product/stock/tpl/stocktransfer.tpl.php b/htdocs/product/stock/tpl/stocktransfer.tpl.php
index 27c9b2acb21..711e5a0c9ac 100644
--- a/htdocs/product/stock/tpl/stocktransfer.tpl.php
+++ b/htdocs/product/stock/tpl/stocktransfer.tpl.php
@@ -130,7 +130,7 @@ print ''.$langs->trans("MovementLabel").' ';
print '';
print ' ';
print ' ';
-print ''.$langs->trans("InventoryCode").' ';
+print ''.$langs->trans("InventoryCode").' ';
print '';
print '';
From 0c1d4c9d5104717bc9957ac0cde20bba21872881 Mon Sep 17 00:00:00 2001
From: Benjamin Chantalat <74144396+PyroShape@users.noreply.github.com>
Date: Tue, 2 Nov 2021 15:48:12 +0100
Subject: [PATCH 031/178] No need of escape htmltag thanks to GETPOST before
---
htdocs/product/stock/tpl/stocktransfer.tpl.php | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/htdocs/product/stock/tpl/stocktransfer.tpl.php b/htdocs/product/stock/tpl/stocktransfer.tpl.php
index 711e5a0c9ac..b71e1e8b248 100644
--- a/htdocs/product/stock/tpl/stocktransfer.tpl.php
+++ b/htdocs/product/stock/tpl/stocktransfer.tpl.php
@@ -124,11 +124,11 @@ if (!empty($conf->productbatch->enabled) &&
}
// Label
-$valformovementlabel = (GETPOST("label") ?GETPOST("label") : $langs->trans("MovementTransferStock", $productref));
+$valformovementlabel = (GETPOST("label") ? GETPOST("label") : $langs->trans("MovementTransferStock", $productref));
print '';
print ''.$langs->trans("MovementLabel").' ';
print '';
-print ' ';
+print ' ';
print ' ';
print ''.$langs->trans("InventoryCode").' ';
print ' ';
From 49d955b7948a1c730c519402f5c003fb5f2dfb5d Mon Sep 17 00:00:00 2001
From: Benjamin Chantalat <74144396+PyroShape@users.noreply.github.com>
Date: Tue, 2 Nov 2021 15:53:57 +0100
Subject: [PATCH 032/178] Uniformization of the table code as the line above
---
htdocs/product/stock/tpl/stockcorrection.tpl.php | 5 ++++-
htdocs/product/stock/tpl/stocktransfer.tpl.php | 5 ++++-
2 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/htdocs/product/stock/tpl/stockcorrection.tpl.php b/htdocs/product/stock/tpl/stockcorrection.tpl.php
index e1a5e734016..e4dfd8b5d7c 100644
--- a/htdocs/product/stock/tpl/stockcorrection.tpl.php
+++ b/htdocs/product/stock/tpl/stockcorrection.tpl.php
@@ -155,7 +155,10 @@ print ''.$langs->trans("MovementLabel").' ';
print '';
print ' ';
print ' ';
-print ''.$langs->trans("InventoryCode").' ';
+print ''.$langs->trans("InventoryCode").' ';
+print '';
+print ' ';
+print ' ';
print '';
print '';
diff --git a/htdocs/product/stock/tpl/stocktransfer.tpl.php b/htdocs/product/stock/tpl/stocktransfer.tpl.php
index b71e1e8b248..31a3103c3eb 100644
--- a/htdocs/product/stock/tpl/stocktransfer.tpl.php
+++ b/htdocs/product/stock/tpl/stocktransfer.tpl.php
@@ -130,7 +130,10 @@ print ''.$langs->trans("MovementLabel").' ';
print '';
print ' ';
print ' ';
-print ''.$langs->trans("InventoryCode").' ';
+print ''.$langs->trans("InventoryCode").' ';
+print '';
+print ' ';
+print ' ';
print '';
print '';
From b02c89bd8b7e68090c52142ef33e42d8c39be7d7 Mon Sep 17 00:00:00 2001
From: daraelmin
Date: Tue, 2 Nov 2021 23:07:46 +0100
Subject: [PATCH 033/178] Add link year subscription list in subscription by
year stats page
---
htdocs/adherents/stats/index.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/htdocs/adherents/stats/index.php b/htdocs/adherents/stats/index.php
index ed79978552f..de9a5b3d9d9 100644
--- a/htdocs/adherents/stats/index.php
+++ b/htdocs/adherents/stats/index.php
@@ -196,7 +196,7 @@ foreach ($data as $val) {
print '';
print '';
//print '';
- print $year;
+ print ' '.$year.' ';
//print '';
print ' ';
print ''.$val['nb'].' ';
From d334fe1292b1abfe4b2ec1083f504e5b1f852bf1 Mon Sep 17 00:00:00 2001
From: daraelmin
Date: Wed, 3 Nov 2021 13:12:33 +0100
Subject: [PATCH 034/178] Fix Bad count of subscription by year
If
---
htdocs/core/boxes/box_members_subscriptions_by_year.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/htdocs/core/boxes/box_members_subscriptions_by_year.php b/htdocs/core/boxes/box_members_subscriptions_by_year.php
index be835511c6b..b6c146312bc 100644
--- a/htdocs/core/boxes/box_members_subscriptions_by_year.php
+++ b/htdocs/core/boxes/box_members_subscriptions_by_year.php
@@ -111,7 +111,7 @@ class box_members_subscriptions_by_year extends ModeleBoxes
$i = 0;
while ($i < $num) {
$objp = $this->db->fetch_object($result);
- $year = dol_print_date($this->db->jdate($objp->dateh), "%Y", 'gmt');
+ $year = dol_print_date($this->db->jdate($objp->dateh), "%Y");
$Total[$year] = (isset($Total[$year]) ? $Total[$year] : 0) + $objp->subscription;
$Number[$year] = (isset($Number[$year]) ? $Number[$year] : 0) + 1;
$tot += $objp->subscription;
From 973f408b6e3caa54a862b887f759279d214d487b Mon Sep 17 00:00:00 2001
From: daraelmin
Date: Wed, 3 Nov 2021 20:35:57 +0100
Subject: [PATCH 035/178] Fix default enddate subscription must be in futur
---
htdocs/adherents/subscription.php | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/htdocs/adherents/subscription.php b/htdocs/adherents/subscription.php
index 1316a337610..839680c3874 100644
--- a/htdocs/adherents/subscription.php
+++ b/htdocs/adherents/subscription.php
@@ -943,8 +943,10 @@ if ($rowid > 0) {
}
if (!$datefrom) {
$datefrom = $object->datevalid;
- if ($object->datefin > 0) {
- $datefrom = dol_time_plus_duree($object->datefin, 1, 'd');
+ if ($object->datefin > 0 && dol_now() > dol_time_plus_duree(dol_time_plus_duree($object->datefin, 2 * $defaultdelay, $defaultdelayunit), -1, 'd') {
+ $datefrom = dol_time_plus_duree($object->datefin, 1, 'd');
+ } else {
+ $datefrom = dol_get_first_day(dol_print_date(time(), "%Y"));
}
}
print $form->selectDate($datefrom, '', '', '', '', "subscription", 1, 1);
From 0e91b32e990e764fade7abec6e03ea6d7a605b9c Mon Sep 17 00:00:00 2001
From: daraelmin
Date: Wed, 3 Nov 2021 20:40:09 +0100
Subject: [PATCH 036/178] Update subscription.php
---
htdocs/adherents/subscription.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/htdocs/adherents/subscription.php b/htdocs/adherents/subscription.php
index 839680c3874..11b3aed8f00 100644
--- a/htdocs/adherents/subscription.php
+++ b/htdocs/adherents/subscription.php
@@ -943,7 +943,7 @@ if ($rowid > 0) {
}
if (!$datefrom) {
$datefrom = $object->datevalid;
- if ($object->datefin > 0 && dol_now() > dol_time_plus_duree(dol_time_plus_duree($object->datefin, 2 * $defaultdelay, $defaultdelayunit), -1, 'd') {
+ if ($object->datefin > 0 && dol_now() > dol_time_plus_duree(dol_time_plus_duree($object->datefin, 2 * $defaultdelay, $defaultdelayunit), -1, 'd')) {
$datefrom = dol_time_plus_duree($object->datefin, 1, 'd');
} else {
$datefrom = dol_get_first_day(dol_print_date(time(), "%Y"));
From f9db196512ac5b405780368bc2ea2667e43db5a3 Mon Sep 17 00:00:00 2001
From: daraelmin
Date: Wed, 3 Nov 2021 22:31:45 +0100
Subject: [PATCH 037/178] Update subscription.php
---
htdocs/adherents/subscription.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/htdocs/adherents/subscription.php b/htdocs/adherents/subscription.php
index 11b3aed8f00..f38562da5a0 100644
--- a/htdocs/adherents/subscription.php
+++ b/htdocs/adherents/subscription.php
@@ -943,7 +943,7 @@ if ($rowid > 0) {
}
if (!$datefrom) {
$datefrom = $object->datevalid;
- if ($object->datefin > 0 && dol_now() > dol_time_plus_duree(dol_time_plus_duree($object->datefin, 2 * $defaultdelay, $defaultdelayunit), -1, 'd')) {
+ if ($object->datefin > 0 && dol_now() < dol_time_plus_duree(dol_time_plus_duree($object->datefin, 2 * $defaultdelay, $defaultdelayunit), -1, 'd')) {
$datefrom = dol_time_plus_duree($object->datefin, 1, 'd');
} else {
$datefrom = dol_get_first_day(dol_print_date(time(), "%Y"));
From 586005ff2e5daf46870bb62c908052aa947cd28c Mon Sep 17 00:00:00 2001
From: stickler-ci
Date: Wed, 3 Nov 2021 21:43:30 +0000
Subject: [PATCH 038/178] Fixing style errors.
---
htdocs/adherents/subscription.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/htdocs/adherents/subscription.php b/htdocs/adherents/subscription.php
index f38562da5a0..e8a703a6efb 100644
--- a/htdocs/adherents/subscription.php
+++ b/htdocs/adherents/subscription.php
@@ -944,7 +944,7 @@ if ($rowid > 0) {
if (!$datefrom) {
$datefrom = $object->datevalid;
if ($object->datefin > 0 && dol_now() < dol_time_plus_duree(dol_time_plus_duree($object->datefin, 2 * $defaultdelay, $defaultdelayunit), -1, 'd')) {
- $datefrom = dol_time_plus_duree($object->datefin, 1, 'd');
+ $datefrom = dol_time_plus_duree($object->datefin, 1, 'd');
} else {
$datefrom = dol_get_first_day(dol_print_date(time(), "%Y"));
}
From 3fb0e3c5ad4789209478f43ff65716edc358c93c Mon Sep 17 00:00:00 2001
From: Regis Houssin
Date: Wed, 3 Nov 2021 22:56:15 +0100
Subject: [PATCH 039/178] NEW add html.formldap.class.php
---
htdocs/adherents/ldap.php | 4 +-
htdocs/adherents/type_ldap.php | 4 +-
htdocs/admin/ldap.php | 67 ++----
htdocs/admin/ldap_groups.php | 4 +-
htdocs/admin/ldap_members_types.php | 2 +-
htdocs/admin/ldap_users.php | 4 +-
htdocs/contact/ldap.php | 4 +-
htdocs/core/class/conf.class.php | 21 +-
htdocs/core/class/html.formldap.class.php | 196 ++++++++++++++++++
htdocs/core/class/ldap.class.php | 19 +-
htdocs/core/login/functions_ldap.php | 2 +-
...interface_50_modLdap_Ldapsynchro.class.php | 44 ++--
htdocs/langs/en_US/ldap.lang | 4 +-
htdocs/user/card.php | 2 +-
htdocs/user/group/ldap.php | 4 +-
htdocs/user/ldap.php | 4 +-
16 files changed, 293 insertions(+), 92 deletions(-)
create mode 100644 htdocs/core/class/html.formldap.class.php
diff --git a/htdocs/adherents/ldap.php b/htdocs/adherents/ldap.php
index 4b64290f107..70624983815 100644
--- a/htdocs/adherents/ldap.php
+++ b/htdocs/adherents/ldap.php
@@ -158,13 +158,13 @@ print dol_get_fiche_end();
*/
print '';
-if (!empty($conf->global->LDAP_MEMBER_ACTIVE) && $conf->global->LDAP_MEMBER_ACTIVE != 'ldap2dolibarr') {
+if (!empty($conf->global->LDAP_MEMBER_ACTIVE) && $conf->global->LDAP_MEMBER_ACTIVE != Ldap::SYNCHRO_LDAP_TO_DOLIBARR) {
print '
';
}
print "
\n";
-if (!empty($conf->global->LDAP_MEMBER_ACTIVE) && $conf->global->LDAP_MEMBER_ACTIVE != 'ldap2dolibarr') {
+if (!empty($conf->global->LDAP_MEMBER_ACTIVE) && $conf->global->LDAP_MEMBER_ACTIVE != Ldap::SYNCHRO_LDAP_TO_DOLIBARR) {
print " \n";
}
diff --git a/htdocs/adherents/type_ldap.php b/htdocs/adherents/type_ldap.php
index 43902a5e1bf..d7650a8de2b 100644
--- a/htdocs/adherents/type_ldap.php
+++ b/htdocs/adherents/type_ldap.php
@@ -124,13 +124,13 @@ print dol_get_fiche_end();
print '\n";
-if ($conf->global->LDAP_MEMBER_TYPE_ACTIVE == 1) {
+if (getDolGlobalInt('LDAP_MEMBER_TYPE_ACTIVE') === Ldap::SYNCHRO_DOLIBARR_TO_LDAP) {
print " \n";
}
diff --git a/htdocs/admin/ldap.php b/htdocs/admin/ldap.php
index 167c48d84c0..99c86f783fc 100644
--- a/htdocs/admin/ldap.php
+++ b/htdocs/admin/ldap.php
@@ -100,7 +100,7 @@ if (empty($reshook)) {
if (!dolibarr_set_const($db, 'LDAP_MEMBER_TYPE_ACTIVE', GETPOST("activememberstypes", 'aZ09'), 'chaine', 0, '', $conf->entity)) {
$error++;
}
- if (!dolibarr_set_const($db, 'LDAP_PASSWORD_HASH_TYPE', GETPOST("'LDAP_PASSWORD_HASH_TYPE'", 'aZ09'), 'chaine', 0, '', $conf->entity)) {
+ if (!dolibarr_set_const($db, 'LDAP_PASSWORD_HASH_TYPE', GETPOST("LDAP_PASSWORD_HASH_TYPE", 'aZ09'), 'chaine', 0, '', $conf->entity)) {
$error++;
}
@@ -150,13 +150,9 @@ print " \n";
// Synchro utilisateurs/groupes active
print ''.$langs->trans("LDAPDnSynchroActive").' ';
-$arraylist = array();
-$arraylist['0'] = $langs->trans("No");
-$arraylist['ldap2dolibarr'] = $langs->trans("LDAPToDolibarr");
-$arraylist['dolibarr2ldap'] = $langs->trans("DolibarrToLDAP");
-print $form->selectarray('activesynchro', $arraylist, $conf->global->LDAP_SYNCHRO_ACTIVE);
+print $formldap->selectLdapDnSynchroActive(getDolGlobalInt('LDAP_SYNCHRO_ACTIVE'), 'activesynchro');
print ' '.$langs->trans("LDAPDnSynchroActiveExample").' ';
-if ($conf->global->LDAP_SYNCHRO_ACTIVE && !$conf->global->LDAP_USER_DN) {
+if (!empty($conf->global->LDAP_SYNCHRO_ACTIVE) && empty($conf->global->LDAP_USER_DN)) {
print ''.$langs->trans("LDAPSetupNotComplete").' ';
}
print ' ';
@@ -164,32 +160,21 @@ print ' ';
// Synchro contact active
if (!empty($conf->societe->enabled)) {
print ''.$langs->trans("LDAPDnContactActive").' ';
- $arraylist = array();
- $arraylist['0'] = $langs->trans("No");
- $arraylist['1'] = $langs->trans("DolibarrToLDAP");
- print $form->selectarray('activecontact', $arraylist, $conf->global->LDAP_CONTACT_ACTIVE);
+ print $formldap->selectLdapDnSynchroActive(getDolGlobalInt('LDAP_CONTACT_ACTIVE'), 'activecontact', array(Ldap::SYNCHRO_LDAP_TO_DOLIBARR));
print ' '.$langs->trans("LDAPDnContactActiveExample").' ';
}
// Synchro member active
if (!empty($conf->adherent->enabled)) {
print ''.$langs->trans("LDAPDnMemberActive").' ';
- $arraylist = array();
- $arraylist['0'] = $langs->trans("No");
- $arraylist['1'] = $langs->trans("DolibarrToLDAP");
- $arraylist['ldap2dolibarr'] = $langs->trans("LDAPToDolibarr").' ('.$langs->trans("SupportedForLDAPImportScriptOnly").')';
- print $form->selectarray('activemembers', $arraylist, $conf->global->LDAP_MEMBER_ACTIVE);
+ print $formldap->selectLdapDnSynchroActive(getDolGlobalInt('LDAP_MEMBER_ACTIVE'), 'activemembers', array(), 2);
print ' '.$langs->trans("LDAPDnMemberActiveExample").' ';
}
// Synchro member type active
if (!empty($conf->adherent->enabled)) {
print ''.$langs->trans("LDAPDnMemberTypeActive").' ';
- $arraylist = array();
- $arraylist['0'] = $langs->trans("No");
- $arraylist['1'] = $langs->trans("DolibarrToLDAP");
- $arraylist['ldap2dolibarr'] = $langs->trans("LDAPToDolibarr").' ('.$langs->trans("SupportedForLDAPImportScriptOnly").')';
- print $form->selectarray('activememberstypes', $arraylist, $conf->global->LDAP_MEMBER_TYPE_ACTIVE);
+ print $formldap->selectLdapDnSynchroActive(getDolGlobalInt('LDAP_MEMBER_TYPE_ACTIVE'), 'activememberstypes', array(), 2);
print ' '.$langs->trans("LDAPDnMemberTypeActiveExample").' ';
}
@@ -206,53 +191,39 @@ print "\n";
// Type
print ''.$langs->trans("Type").' ';
-$arraylist = array();
-$arraylist['activedirectory'] = 'Active Directory';
-$arraylist['openldap'] = 'OpenLdap';
-$arraylist['egroupware'] = 'Egroupware';
-print $form->selectarray('type', $arraylist, $conf->global->LDAP_SERVER_TYPE);
+print $formldap->selectLdapServerType(getDolGlobalString('LDAP_SERVER_TYPE'), 'type');
print ' ';
// Version
print ''.$langs->trans("Version").' ';
-$arraylist = array();
-$arraylist['3'] = 'Version 3';
-$arraylist['2'] = 'Version 2';
-print $form->selectarray('LDAP_SERVER_PROTOCOLVERSION', $arraylist, $conf->global->LDAP_SERVER_PROTOCOLVERSION);
+print $formldap->selectLdapServerProtocolVersion(getDolGlobalString('LDAP_SERVER_PROTOCOLVERSION'), 'LDAP_SERVER_PROTOCOLVERSION');
print ' '.$langs->trans("LDAPServerProtocolVersion").' ';
// Serveur primaire
print '';
print $langs->trans("LDAPPrimaryServer").' ';
-print ' ';
+print ' ';
print ' '.$langs->trans("LDAPServerExample").' ';
// Serveur secondaire
print '';
print $langs->trans("LDAPSecondaryServer").' ';
-print ' ';
+print ' ';
print ' '.$langs->trans("LDAPServerExample").' ';
// Port
print ''.$langs->trans("LDAPServerPort").' ';
-if (!empty($conf->global->LDAP_SERVER_PORT)) {
- print ' ';
-} else {
- print ' ';
-}
+print ' ';
print ' '.$langs->trans("LDAPServerPortExample").' ';
// DNserver
print ''.$langs->trans("LDAPServerDn").' ';
-print ' ';
+print ' ';
print ' '.$langs->trans("LDAPServerDnExample").' ';
// Utiliser TLS
print ''.$langs->trans("LDAPServerUseTLS").' ';
-$arraylist = array();
-$arraylist['0'] = $langs->trans("No");
-$arraylist['1'] = $langs->trans("Yes");
-print $form->selectarray('usetls', $arraylist, $conf->global->LDAP_SERVER_USE_TLS);
+print $form->selectyesno('usetls', getDolGlobalInt('LDAP_SERVER_USE_TLS'), 1);
print ' '.$langs->trans("LDAPServerUseTLSExample").' ';
// Password hash type
@@ -267,7 +238,7 @@ print "\n";
// DNAdmin
print '';
print ''.$langs->trans("LDAPAdminDn").' ';
-print ' ';
+print ' ';
print ' '.$langs->trans("LDAPAdminDnExample").' ';
// Pass
@@ -276,7 +247,7 @@ print ''.$langs->trans("LDAPPassword").' ';
if (!empty($conf->global->LDAP_ADMIN_PASS)) {
print ' '; // je le met en visible pour test
} else {
- print ' ';
+ print ' ';
}
print ' '.$langs->trans('Password').' (ex: secret) ';
@@ -306,17 +277,17 @@ if (function_exists("ldap_connect")) {
if ($result > 0) {
// Test ldap connect and bind
print img_picto('', 'info').' ';
- print ''.$langs->trans("LDAPTCPConnectOK", $ldap->connectedServer, $conf->global->LDAP_SERVER_PORT).' ';
+ print ''.$langs->trans("LDAPTCPConnectOK", $ldap->connectedServer, getDolGlobalString('LDAP_SERVER_PORT')).' ';
print ' ';
if (!empty($conf->global->LDAP_ADMIN_DN) && !empty($conf->global->LDAP_ADMIN_PASS)) {
if ($result == 2) {
print img_picto('', 'info').' ';
- print ''.$langs->trans("LDAPBindOK", $ldap->connectedServer, $conf->global->LDAP_SERVER_PORT, $conf->global->LDAP_ADMIN_DN, preg_replace('/./i', '*', $conf->global->LDAP_ADMIN_PASS)).' ';
+ print ''.$langs->trans("LDAPBindOK", $ldap->connectedServer, getDolGlobalString('LDAP_SERVER_PORT'), $conf->global->LDAP_ADMIN_DN, preg_replace('/./i', '*', $conf->global->LDAP_ADMIN_PASS)).' ';
print ' ';
} else {
print img_picto('', 'error').' ';
- print ''.$langs->trans("LDAPBindKO", $ldap->connectedServer, $conf->global->LDAP_SERVER_PORT, $conf->global->LDAP_ADMIN_DN, preg_replace('/./i', '*', $conf->global->LDAP_ADMIN_PASS)).' ';
+ print ''.$langs->trans("LDAPBindKO", $ldap->connectedServer, getDolGlobalString('LDAP_SERVER_PORT'), $conf->global->LDAP_ADMIN_DN, preg_replace('/./i', '*', $conf->global->LDAP_ADMIN_PASS)).' ';
print ' ';
print $langs->trans("Error").' '.$ldap->error;
print ' ';
@@ -342,7 +313,7 @@ if (function_exists("ldap_connect")) {
$ldap->unbind();
} else {
print img_picto('', 'error').' ';
- print ''.$langs->trans("LDAPTCPConnectKO", $ldap->connectedServer, $conf->global->LDAP_SERVER_PORT).' ';
+ print ''.$langs->trans("LDAPTCPConnectKO", $ldap->connectedServer, getDolGlobalString('LDAP_SERVER_PORT')).' ';
print ' ';
print $langs->trans("Error").' '.$ldap->error;
print ' ';
diff --git a/htdocs/admin/ldap_groups.php b/htdocs/admin/ldap_groups.php
index 82ee85b9a20..5723183735e 100644
--- a/htdocs/admin/ldap_groups.php
+++ b/htdocs/admin/ldap_groups.php
@@ -218,7 +218,7 @@ print '';
/*
* Test de la connexion
*/
-if ($conf->global->LDAP_SYNCHRO_ACTIVE == 'dolibarr2ldap') {
+if (getDolGlobalInt('LDAP_SYNCHRO_ACTIVE') === Ldap::SYNCHRO_DOLIBARR_TO_LDAP) {
$butlabel = $langs->trans("LDAPTestSynchroGroup");
$testlabel = 'testgroup';
$key = $conf->global->LDAP_KEY_GROUPS;
@@ -226,7 +226,7 @@ if ($conf->global->LDAP_SYNCHRO_ACTIVE == 'dolibarr2ldap') {
$objectclass = $conf->global->LDAP_GROUP_OBJECT_CLASS;
show_ldap_test_button($butlabel, $testlabel, $key, $dn, $objectclass);
-} elseif ($conf->global->LDAP_SYNCHRO_ACTIVE == 'ldap2dolibarr') {
+} elseif (getDolGlobalInt('LDAP_SYNCHRO_ACTIVE') === Ldap::SYNCHRO_LDAP_TO_DOLIBARR) {
$butlabel = $langs->trans("LDAPTestSearch");
$testlabel = 'testsearchgroup';
$key = $conf->global->LDAP_KEY_GROUPS;
diff --git a/htdocs/admin/ldap_members_types.php b/htdocs/admin/ldap_members_types.php
index 05572dc8bbf..7933b59d5e0 100644
--- a/htdocs/admin/ldap_members_types.php
+++ b/htdocs/admin/ldap_members_types.php
@@ -188,7 +188,7 @@ print '';
/*
* Test de la connexion
*/
-if ($conf->global->LDAP_MEMBER_TYPE_ACTIVE == '1') {
+if (getDolGlobalInt('LDAP_MEMBER_TYPE_ACTIVE') === Ldap::SYNCHRO_DOLIBARR_TO_LDAP) {
$butlabel = $langs->trans("LDAPTestSynchroMemberType");
$testlabel = 'testmembertype';
$key = $conf->global->LDAP_KEY_MEMBERS_TYPES;
diff --git a/htdocs/admin/ldap_users.php b/htdocs/admin/ldap_users.php
index 33bec1cb2e8..f395eb88fb4 100644
--- a/htdocs/admin/ldap_users.php
+++ b/htdocs/admin/ldap_users.php
@@ -405,7 +405,7 @@ print '';
/*
* Test de la connexion
*/
-if (getDolGlobalString('LDAP_SYNCHRO_ACTIVE') == 'dolibarr2ldap') {
+if (getDolGlobalString('LDAP_SYNCHRO_ACTIVE') == Ldap::SYNCHRO_DOLIBARR_TO_LDAP) {
$butlabel = $langs->trans("LDAPTestSynchroUser");
$testlabel = 'testuser';
$key = getDolGlobalString('LDAP_KEY_USERS');
@@ -413,7 +413,7 @@ if (getDolGlobalString('LDAP_SYNCHRO_ACTIVE') == 'dolibarr2ldap') {
$objectclass = getDolGlobalString('LDAP_USER_OBJECT_CLASS');
show_ldap_test_button($butlabel, $testlabel, $key, $dn, $objectclass);
-} elseif (getDolGlobalString('LDAP_SYNCHRO_ACTIVE') == 'ldap2dolibarr') {
+} elseif (getDolGlobalString('LDAP_SYNCHRO_ACTIVE') == Ldap::SYNCHRO_LDAP_TO_DOLIBARR) {
$butlabel = $langs->trans("LDAPTestSearch");
$testlabel = 'testsearchuser';
$key = getDolGlobalString('LDAP_KEY_USERS');
diff --git a/htdocs/contact/ldap.php b/htdocs/contact/ldap.php
index d29aab0386b..92b9c1ad337 100644
--- a/htdocs/contact/ldap.php
+++ b/htdocs/contact/ldap.php
@@ -136,13 +136,13 @@ print dol_get_fiche_end();
*/
print '\n";
-if (!empty($conf->global->LDAP_CONTACT_ACTIVE) && $conf->global->LDAP_CONTACT_ACTIVE != 'ldap2dolibarr') {
+if (!empty($conf->global->LDAP_CONTACT_ACTIVE) && $conf->global->LDAP_CONTACT_ACTIVE != Ldap::SYNCHRO_LDAP_TO_DOLIBARR) {
print " \n";
}
diff --git a/htdocs/core/class/conf.class.php b/htdocs/core/class/conf.class.php
index 044dc192426..cf54151d2d6 100644
--- a/htdocs/core/class/conf.class.php
+++ b/htdocs/core/class/conf.class.php
@@ -775,8 +775,8 @@ class Conf
$this->contrat->services->expires->warning_delay = (isset($this->global->MAIN_DELAY_RUNNING_SERVICES) ? $this->global->MAIN_DELAY_RUNNING_SERVICES : 0) * 86400;
}
if (isset($this->commande)) {
- $this->bank->rappro = new stdClass();
- $this->bank->cheque = new stdClass();
+ $this->bank->rappro = new stdClass();
+ $this->bank->cheque = new stdClass();
$this->bank->rappro->warning_delay = (isset($this->global->MAIN_DELAY_TRANSACTIONS_TO_CONCILIATE) ? $this->global->MAIN_DELAY_TRANSACTIONS_TO_CONCILIATE : 0) * 86400;
$this->bank->cheque->warning_delay = (isset($this->global->MAIN_DELAY_CHEQUES_TO_DEPOSIT) ? $this->global->MAIN_DELAY_CHEQUES_TO_DEPOSIT : 0) * 86400;
}
@@ -845,6 +845,23 @@ class Conf
}
}
+ // For backward compatibility
+ if (!empty($this->global->LDAP_SYNCHRO_ACTIVE)) {
+ if ($this->global->LDAP_SYNCHRO_ACTIVE == 'dolibarr2ldap') {
+ $this->global->LDAP_SYNCHRO_ACTIVE = 1;
+ } else if ($this->global->LDAP_SYNCHRO_ACTIVE == 'ldap2dolibarr') {
+ $this->global->LDAP_SYNCHRO_ACTIVE = 2;
+ }
+ }
+ // For backward compatibility
+ if (!empty($this->global->LDAP_MEMBER_ACTIVE) && $this->global->LDAP_MEMBER_ACTIVE == 'ldap2dolibarr') {
+ $this->global->LDAP_MEMBER_ACTIVE = 2;
+ }
+ // For backward compatibility
+ if (!empty($this->global->LDAP_MEMBER_TYPE_ACTIVE) && $this->global->LDAP_MEMBER_TYPE_ACTIVE == 'ldap2dolibarr') {
+ $this->global->LDAP_MEMBER_TYPE_ACTIVE = 2;
+ }
+
if (!empty($this->global->MAIN_TZUSERINPUTKEY)) {
$this->tzuserinputkey = $this->global->MAIN_TZUSERINPUTKEY; // 'tzserver' or 'tzuserrel'
}
diff --git a/htdocs/core/class/html.formldap.class.php b/htdocs/core/class/html.formldap.class.php
new file mode 100644
index 00000000000..acee0bbbea7
--- /dev/null
+++ b/htdocs/core/class/html.formldap.class.php
@@ -0,0 +1,196 @@
+
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+/**
+ * \file htdocs/core/class/html.formldap.class.php
+ * \ingroup core
+ * \brief File of class with ldap html predefined components
+ */
+require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php';
+
+/**
+ * Class to manage generation of HTML components for ldap module
+ */
+class FormLdap
+{
+ /**
+ * @var DoliDB Database handler.
+ */
+ public $db;
+
+ /**
+ * @var string Error code (or message)
+ */
+ public $error = '';
+
+ /**
+ * @var string[] Array of error strings
+ */
+ public $errors = array();
+
+
+ /**
+ * Constructor
+ *
+ * @param DoliDB $db Database handler
+ */
+ public function __construct($db)
+ {
+ global $langs, $form;
+
+ if (!is_object($form)) {
+ $form = new Form($this->db);
+ }
+
+ $langs->loadLangs(array("admin", "ldap"));
+
+ $this->db = $db;
+ }
+
+ /**
+ * Return list of types of hash
+ *
+ * @param string $selected Preselected type
+ * @param string $htmlname Name of field in form
+ * @param int $showempty Add an empty field
+ * @return string HTML select string
+ */
+ public function selectLdapPasswordHashType($selected = 'md5', $htmlname = 'ldaphashtype', $showempty = 0)
+ {
+ global $form;
+
+ if (empty($selected)) {
+ $selected = 'md5';
+ }
+ if (empty($htmlname)) {
+ $htmlname = 'ldaphashtype';
+ }
+
+ $arraylist = array(
+ "pbkdf2sha256" => "PBKDF2_SHA256",
+ "ssha512" => "SSHA512",
+ "ssha256" => "SSHA256",
+ "ssha" => "SSHA",
+ "sha" => "SHA",
+ "md5" => "MD5",
+ "smd5" => "SMD5",
+ "cryptmd5" => "CRYPT-MD5",
+ "cryptsha512" => "CRYPT-SHA512",
+ "cryptsha256" => "CRYPT-SHA256",
+ "crypt" => "CRYPT",
+ "clear" => "CLEAR"
+ );
+
+ return $form->selectarray($htmlname, $arraylist, $selected, $showempty);
+ }
+
+ /**
+ * Return list of type of synchronization
+ *
+ * @param int $selected Preselected type
+ * @param string $htmlname Name of field in form
+ * @param array $exclude Exclude values from the list
+ * @param int $scriptonly Add warning if synchro only work with a script (0 = disable, 1 = Dolibarr2ldap, 2 = ldap2dolibarr, 3 = all)
+ * @param int $showempty Add an empty field
+ * @return string HTML select string
+ */
+ public function selectLdapDnSynchroActive($selected = 0, $htmlname = 'activesynchro', $exclude = array(), $scriptonly = 0, $showempty = 0)
+ {
+ global $langs, $form;
+
+ if (empty($selected)) {
+ $selected = Ldap::SYNCHRO_NONE;
+ }
+ if (empty($htmlname)) {
+ $htmlname = 'activesynchro';
+ }
+
+ $dolibarr2ldaplabel = $langs->trans("DolibarrToLDAP") . (($scriptonly == 1 || $scriptonly == 3) ? " (".$langs->trans("SupportedForLDAPExportScriptOnly").")" : "");
+ $ldap2dolibarrlabel = $langs->trans("LDAPToDolibarr") . (($scriptonly == 2 || $scriptonly == 3) ? " (".$langs->trans("SupportedForLDAPImportScriptOnly").")" : "");
+
+ $arraylist = array(
+ Ldap::SYNCHRO_NONE => $langs->trans("No"),
+ Ldap::SYNCHRO_DOLIBARR_TO_LDAP => $dolibarr2ldaplabel,
+ Ldap::SYNCHRO_LDAP_TO_DOLIBARR => $ldap2dolibarrlabel
+ );
+
+ if (is_array($exclude) && !empty($exclude)) {
+ foreach($exclude as $value) {
+ if (array_key_exists($value, $arraylist)) {
+ unset($arraylist[$value]);
+ }
+ }
+ }
+
+ return $form->selectarray($htmlname, $arraylist, $selected, $showempty);
+ }
+
+ /**
+ * Return list of ldap server types
+ *
+ * @param string $selected Preselected type
+ * @param string $htmlname Name of field in form
+ * @param int $showempty Add an empty field
+ * @return string HTML select string
+ */
+ public function selectLdapServerType($selected = 'openldap', $htmlname = 'type', $showempty = 0)
+ {
+ global $form;
+
+ if (empty($selected)) {
+ $selected = 'openldap';
+ }
+ if (empty($htmlname)) {
+ $htmlname = 'type';
+ }
+
+ $arraylist = array(
+ 'activedirectory' => 'Active Directory',
+ 'openldap' => 'OpenLdap',
+ 'egroupware' => 'Egroupware'
+ );
+
+ return $form->selectarray($htmlname, $arraylist, $selected, $showempty);
+ }
+
+ /**
+ * Return list of ldap server protocol version
+ *
+ * @param string $selected Preselected type
+ * @param string $htmlname Name of field in form
+ * @param int $showempty Add an empty field
+ * @return string HTML select string
+ */
+ public function selectLdapServerProtocolVersion($selected = '3', $htmlname = 'ldapprotocolversion', $showempty = 0)
+ {
+ global $form;
+
+ if (empty($selected)) {
+ $selected = '3';
+ }
+ if (empty($htmlname)) {
+ $htmlname = 'ldapprotocolversion';
+ }
+
+ $arraylist = array(
+ '3' => 'Version 3',
+ '2' => 'Version 2'
+ );
+
+ return $form->selectarray($htmlname, $arraylist, $selected, $showempty);
+ }
+}
diff --git a/htdocs/core/class/ldap.class.php b/htdocs/core/class/ldap.class.php
index a1921ea2217..bd0ccbee5ac 100644
--- a/htdocs/core/class/ldap.class.php
+++ b/htdocs/core/class/ldap.class.php
@@ -122,6 +122,21 @@ class Ldap
*/
public $result;
+ /**
+ * No Ldap synchronization
+ */
+ const SYNCHRO_NONE = 0;
+
+ /**
+ * Dolibarr to Ldap synchronization
+ */
+ const SYNCHRO_DOLIBARR_TO_LDAP = 1;
+
+ /**
+ * Ldap to Dolibarr synchronization
+ */
+ const SYNCHRO_LDAP_TO_DOLIBARR = 2;
+
/**
* Constructor
@@ -230,7 +245,7 @@ class Ldap
dol_syslog(get_class($this)."::connect_bind failed to start tls", LOG_WARNING);
$this->error = 'ldap_start_tls Failed to start TLS '.ldap_errno($this->connection).' '.ldap_error($this->connection);
$connected = 0;
- $this->close();
+ $this->unbind();
}
}
@@ -279,7 +294,7 @@ class Ldap
}
if (!$connected) {
- $this->close();
+ $this->unbind();
}
}
}
diff --git a/htdocs/core/login/functions_ldap.php b/htdocs/core/login/functions_ldap.php
index 2d55ca2815b..5ae3af3f008 100644
--- a/htdocs/core/login/functions_ldap.php
+++ b/htdocs/core/login/functions_ldap.php
@@ -181,7 +181,7 @@ function check_user_password_ldap($usertotest, $passwordtotest, $entitytotest)
}
// ldap2dolibarr synchronisation
- if ($login && !empty($conf->ldap->enabled) && $conf->global->LDAP_SYNCHRO_ACTIVE == 'ldap2dolibarr') { // ldap2dolibarr synchronisation
+ if ($login && !empty($conf->ldap->enabled) && $conf->global->LDAP_SYNCHRO_ACTIVE == Ldap::SYNCHRO_LDAP_TO_DOLIBARR) { // ldap2dolibarr synchronization
dol_syslog("functions_ldap::check_user_password_ldap Sync ldap2dolibarr");
// On charge les attributs du user ldap
diff --git a/htdocs/core/triggers/interface_50_modLdap_Ldapsynchro.class.php b/htdocs/core/triggers/interface_50_modLdap_Ldapsynchro.class.php
index d4db5ebccfc..24df646efd6 100644
--- a/htdocs/core/triggers/interface_50_modLdap_Ldapsynchro.class.php
+++ b/htdocs/core/triggers/interface_50_modLdap_Ldapsynchro.class.php
@@ -81,7 +81,7 @@ class InterfaceLdapsynchro extends DolibarrTriggers
// Users
if ($action == 'USER_CREATE') {
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
- if (!empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE === 'dolibarr2ldap') {
+ if (!empty($conf->global->LDAP_SYNCHRO_ACTIVE) && getDolGlobalInt('LDAP_SYNCHRO_ACTIVE') === Ldap::SYNCHRO_DOLIBARR_TO_LDAP) {
$ldap = new Ldap();
$result = $ldap->connect_bind();
@@ -98,7 +98,7 @@ class InterfaceLdapsynchro extends DolibarrTriggers
}
} elseif ($action == 'USER_MODIFY') {
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
- if (!empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE === 'dolibarr2ldap') {
+ if (!empty($conf->global->LDAP_SYNCHRO_ACTIVE) && getDolGlobalInt('LDAP_SYNCHRO_ACTIVE') === Ldap::SYNCHRO_DOLIBARR_TO_LDAP) {
$ldap = new Ldap();
$result = $ldap->connect_bind();
@@ -177,7 +177,7 @@ class InterfaceLdapsynchro extends DolibarrTriggers
}
} elseif ($action == 'USER_NEW_PASSWORD') {
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
- if (!empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE === 'dolibarr2ldap') {
+ if (!empty($conf->global->LDAP_SYNCHRO_ACTIVE) && getDolGlobalInt('LDAP_SYNCHRO_ACTIVE') === Ldap::SYNCHRO_DOLIBARR_TO_LDAP) {
$ldap = new Ldap();
$result = $ldap->connect_bind();
@@ -212,7 +212,7 @@ class InterfaceLdapsynchro extends DolibarrTriggers
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
} elseif ($action == 'USER_DELETE') {
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
- if (!empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE === 'dolibarr2ldap') {
+ if (!empty($conf->global->LDAP_SYNCHRO_ACTIVE) && getDolGlobalInt('LDAP_SYNCHRO_ACTIVE') === Ldap::SYNCHRO_DOLIBARR_TO_LDAP) {
$ldap = new Ldap();
$result = $ldap->connect_bind();
@@ -229,7 +229,7 @@ class InterfaceLdapsynchro extends DolibarrTriggers
}
/*} elseif ($action == 'USER_SETINGROUP') {
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
- if (!empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE === 'dolibarr2ldap') {
+ if (!empty($conf->global->LDAP_SYNCHRO_ACTIVE) && getDolGlobalInt('LDAP_SYNCHRO_ACTIVE') === Ldap::SYNCHRO_DOLIBARR_TO_LDAP) {
$ldap = new Ldap();
$result = $ldap->connect_bind();
@@ -263,7 +263,7 @@ class InterfaceLdapsynchro extends DolibarrTriggers
}
} elseif ($action == 'USER_REMOVEFROMGROUP') {
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
- if (!empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE === 'dolibarr2ldap') {
+ if (!empty($conf->global->LDAP_SYNCHRO_ACTIVE) && getDolGlobalInt('LDAP_SYNCHRO_ACTIVE') === Ldap::SYNCHRO_DOLIBARR_TO_LDAP) {
$ldap = new Ldap();
$result = $ldap->connect_bind();
@@ -298,7 +298,7 @@ class InterfaceLdapsynchro extends DolibarrTriggers
} elseif ($action == 'USERGROUP_CREATE') {
// Groupes
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
- if (!empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE === 'dolibarr2ldap') {
+ if (!empty($conf->global->LDAP_SYNCHRO_ACTIVE) && getDolGlobalInt('LDAP_SYNCHRO_ACTIVE') === Ldap::SYNCHRO_DOLIBARR_TO_LDAP) {
$ldap = new Ldap();
$result = $ldap->connect_bind();
@@ -320,7 +320,7 @@ class InterfaceLdapsynchro extends DolibarrTriggers
}
} elseif ($action == 'USERGROUP_MODIFY') {
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
- if (!empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE === 'dolibarr2ldap') {
+ if (!empty($conf->global->LDAP_SYNCHRO_ACTIVE) && getDolGlobalInt('LDAP_SYNCHRO_ACTIVE') === Ldap::SYNCHRO_DOLIBARR_TO_LDAP) {
$ldap = new Ldap();
$result = $ldap->connect_bind();
@@ -353,7 +353,7 @@ class InterfaceLdapsynchro extends DolibarrTriggers
}
} elseif ($action == 'USERGROUP_DELETE') {
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
- if (!empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE === 'dolibarr2ldap') {
+ if (!empty($conf->global->LDAP_SYNCHRO_ACTIVE) && getDolGlobalInt('LDAP_SYNCHRO_ACTIVE') === Ldap::SYNCHRO_DOLIBARR_TO_LDAP) {
$ldap = new Ldap();
$result = $ldap->connect_bind();
@@ -439,7 +439,7 @@ class InterfaceLdapsynchro extends DolibarrTriggers
} elseif ($action == 'MEMBER_CREATE') {
// Members
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
- if (!empty($conf->global->LDAP_MEMBER_ACTIVE) && (string) $conf->global->LDAP_MEMBER_ACTIVE == '1') {
+ if (!empty($conf->global->LDAP_MEMBER_ACTIVE) && $conf->global->LDAP_MEMBER_ACTIVE == Ldap::SYNCHRO_DOLIBARR_TO_LDAP) {
$ldap = new Ldap();
$result = $ldap->connect_bind();
@@ -450,7 +450,7 @@ class InterfaceLdapsynchro extends DolibarrTriggers
$result = $ldap->add($dn, $info, $user);
// For member type
- if (!empty($conf->global->LDAP_MEMBER_TYPE_ACTIVE) && (string) $conf->global->LDAP_MEMBER_TYPE_ACTIVE == '1') {
+ if (!empty($conf->global->LDAP_MEMBER_TYPE_ACTIVE) && getDolGlobalInt('LDAP_MEMBER_TYPE_ACTIVE') === Ldap::SYNCHRO_DOLIBARR_TO_LDAP) {
if ($object->typeid > 0) {
require_once DOL_DOCUMENT_ROOT."/adherents/class/adherent_type.class.php";
$membertype = new AdherentType($this->db);
@@ -482,7 +482,7 @@ class InterfaceLdapsynchro extends DolibarrTriggers
}
} elseif ($action == 'MEMBER_VALIDATE') {
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
- if (!empty($conf->global->LDAP_MEMBER_ACTIVE) && (string) $conf->global->LDAP_MEMBER_ACTIVE == '1') {
+ if (!empty($conf->global->LDAP_MEMBER_ACTIVE) && (string) $conf->global->LDAP_MEMBER_ACTIVE == Ldap::SYNCHRO_DOLIBARR_TO_LDAP) {
// If status field is setup to be synchronized
if (!empty($conf->global->LDAP_FIELD_MEMBER_STATUS)) {
$ldap = new Ldap();
@@ -503,7 +503,7 @@ class InterfaceLdapsynchro extends DolibarrTriggers
}
} elseif ($action == 'MEMBER_SUBSCRIPTION') {
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
- if (!empty($conf->global->LDAP_MEMBER_ACTIVE) && (string) $conf->global->LDAP_MEMBER_ACTIVE == '1') {
+ if (!empty($conf->global->LDAP_MEMBER_ACTIVE) && (string) $conf->global->LDAP_MEMBER_ACTIVE == Ldap::SYNCHRO_DOLIBARR_TO_LDAP) {
// If subscriptions fields are setup to be synchronized
if ($conf->global->LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_DATE
|| $conf->global->LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_AMOUNT
@@ -528,7 +528,7 @@ class InterfaceLdapsynchro extends DolibarrTriggers
}
} elseif ($action == 'MEMBER_MODIFY') {
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
- if (!empty($conf->global->LDAP_MEMBER_ACTIVE) && (string) $conf->global->LDAP_MEMBER_ACTIVE == '1') {
+ if (!empty($conf->global->LDAP_MEMBER_ACTIVE) && (string) $conf->global->LDAP_MEMBER_ACTIVE == Ldap::SYNCHRO_DOLIBARR_TO_LDAP) {
$ldap = new Ldap();
$result = $ldap->connect_bind();
@@ -557,7 +557,7 @@ class InterfaceLdapsynchro extends DolibarrTriggers
$result = $ldap->update($dn, $info, $user, $olddn, $newrdn, $newparent);
// For member type
- if (!empty($conf->global->LDAP_MEMBER_TYPE_ACTIVE) && (string) $conf->global->LDAP_MEMBER_TYPE_ACTIVE == '1') {
+ if (!empty($conf->global->LDAP_MEMBER_TYPE_ACTIVE) && getDolGlobalInt('LDAP_MEMBER_TYPE_ACTIVE') === Ldap::SYNCHRO_DOLIBARR_TO_LDAP) {
require_once DOL_DOCUMENT_ROOT."/adherents/class/adherent_type.class.php";
/*
@@ -616,7 +616,7 @@ class InterfaceLdapsynchro extends DolibarrTriggers
}
} elseif ($action == 'MEMBER_NEW_PASSWORD') {
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
- if (!empty($conf->global->LDAP_MEMBER_ACTIVE) && (string) $conf->global->LDAP_MEMBER_ACTIVE == '1') {
+ if (!empty($conf->global->LDAP_MEMBER_ACTIVE) && (string) $conf->global->LDAP_MEMBER_ACTIVE == Ldap::SYNCHRO_DOLIBARR_TO_LDAP) {
// If password field is setup to be synchronized
if ($conf->global->LDAP_FIELD_PASSWORD || $conf->global->LDAP_FIELD_PASSWORD_CRYPTED) {
$ldap = new Ldap();
@@ -637,7 +637,7 @@ class InterfaceLdapsynchro extends DolibarrTriggers
}
} elseif ($action == 'MEMBER_RESILIATE') {
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
- if (!empty($conf->global->LDAP_MEMBER_ACTIVE) && (string) $conf->global->LDAP_MEMBER_ACTIVE == '1') {
+ if (!empty($conf->global->LDAP_MEMBER_ACTIVE) && (string) $conf->global->LDAP_MEMBER_ACTIVE == Ldap::SYNCHRO_DOLIBARR_TO_LDAP) {
// If status field is setup to be synchronized
if (!empty($conf->global->LDAP_FIELD_MEMBER_STATUS)) {
$ldap = new Ldap();
@@ -658,7 +658,7 @@ class InterfaceLdapsynchro extends DolibarrTriggers
}
} elseif ($action == 'MEMBER_DELETE') {
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
- if (!empty($conf->global->LDAP_MEMBER_ACTIVE) && (string) $conf->global->LDAP_MEMBER_ACTIVE == '1') {
+ if (!empty($conf->global->LDAP_MEMBER_ACTIVE) && (string) $conf->global->LDAP_MEMBER_ACTIVE == Ldap::SYNCHRO_DOLIBARR_TO_LDAP) {
$ldap = new Ldap();
$result = $ldap->connect_bind();
@@ -669,7 +669,7 @@ class InterfaceLdapsynchro extends DolibarrTriggers
$result = $ldap->delete($dn);
// For member type
- if (!empty($conf->global->LDAP_MEMBER_TYPE_ACTIVE) && (string) $conf->global->LDAP_MEMBER_TYPE_ACTIVE == '1') {
+ if (!empty($conf->global->LDAP_MEMBER_TYPE_ACTIVE) && getDolGlobalInt('LDAP_MEMBER_TYPE_ACTIVE') === Ldap::SYNCHRO_DOLIBARR_TO_LDAP) {
if ($object->typeid > 0) {
require_once DOL_DOCUMENT_ROOT."/adherents/class/adherent_type.class.php";
@@ -706,7 +706,7 @@ class InterfaceLdapsynchro extends DolibarrTriggers
} elseif ($action == 'MEMBER_TYPE_CREATE') {
// Members types
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
- if (!empty($conf->global->LDAP_MEMBER_TYPE_ACTIVE) && (string) $conf->global->LDAP_MEMBER_TYPE_ACTIVE == '1') {
+ if (!empty($conf->global->LDAP_MEMBER_TYPE_ACTIVE) && getDolGlobalInt('LDAP_MEMBER_TYPE_ACTIVE') === Ldap::SYNCHRO_DOLIBARR_TO_LDAP) {
$ldap = new Ldap();
$result = $ldap->connect_bind();
@@ -728,7 +728,7 @@ class InterfaceLdapsynchro extends DolibarrTriggers
}
} elseif ($action == 'MEMBER_TYPE_MODIFY') {
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
- if (!empty($conf->global->LDAP_MEMBER_TYPE_ACTIVE) && (string) $conf->global->LDAP_MEMBER_TYPE_ACTIVE == '1') {
+ if (!empty($conf->global->LDAP_MEMBER_TYPE_ACTIVE) && getDolGlobalInt('LDAP_MEMBER_TYPE_ACTIVE') === Ldap::SYNCHRO_DOLIBARR_TO_LDAP) {
$ldap = new Ldap();
$result = $ldap->connect_bind();
@@ -765,7 +765,7 @@ class InterfaceLdapsynchro extends DolibarrTriggers
}
} elseif ($action == 'MEMBER_TYPE_DELETE') {
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
- if (!empty($conf->global->LDAP_MEMBER_TYPE_ACTIVE) && (string) $conf->global->LDAP_MEMBER_TYPE_ACTIVE == '1') {
+ if (!empty($conf->global->LDAP_MEMBER_TYPE_ACTIVE) && getDolGlobalInt('LDAP_MEMBER_TYPE_ACTIVE') === Ldap::SYNCHRO_DOLIBARR_TO_LDAP) {
$ldap = new Ldap();
$result = $ldap->connect_bind();
diff --git a/htdocs/langs/en_US/ldap.lang b/htdocs/langs/en_US/ldap.lang
index b13e454159d..19dd29e0a51 100644
--- a/htdocs/langs/en_US/ldap.lang
+++ b/htdocs/langs/en_US/ldap.lang
@@ -26,4 +26,6 @@ ForceSynchronize=Force synchronizing Dolibarr -> LDAP
ErrorFailedToReadLDAP=Failed to read LDAP database. Check LDAP module setup and database accessibility.
PasswordOfUserInLDAP=Password of user in LDAP
LDAPPasswordHashType=Password hash type
-LDAPPasswordHashTypeExample=Type of password hash used on the server
\ No newline at end of file
+LDAPPasswordHashTypeExample=Type of password hash used on the server
+SupportedForLDAPExportScriptOnly=Only supported by an ldap export script
+SupportedForLDAPImportScriptOnly=Only supported by an ldap import script
\ No newline at end of file
diff --git a/htdocs/user/card.php b/htdocs/user/card.php
index e3a72384050..da4cbf5fac0 100644
--- a/htdocs/user/card.php
+++ b/htdocs/user/card.php
@@ -731,7 +731,7 @@ if ($action == 'create' || $action == 'adduserldap') {
print " ";
- if (!empty($conf->ldap->enabled) && (isset($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE == 'ldap2dolibarr')) {
+ if (!empty($conf->ldap->enabled) && (isset($conf->global->LDAP_SYNCHRO_ACTIVE) && getDolGlobalInt('LDAP_SYNCHRO_ACTIVE') === Ldap::SYNCHRO_LDAP_TO_DOLIBARR)) {
// Show form to add an account from LDAP if sync LDAP -> Dolibarr is set
$ldap = new Ldap();
$result = $ldap->connect_bind();
diff --git a/htdocs/user/group/ldap.php b/htdocs/user/group/ldap.php
index d8d1995a847..e3a01f27731 100644
--- a/htdocs/user/group/ldap.php
+++ b/htdocs/user/group/ldap.php
@@ -147,13 +147,13 @@ print dol_get_fiche_end();
*/
print '\n";
-if ($conf->global->LDAP_SYNCHRO_ACTIVE == 'dolibarr2ldap') {
+if (getDolGlobalInt('LDAP_SYNCHRO_ACTIVE') === Ldap::SYNCHRO_DOLIBARR_TO_LDAP) {
print " \n";
}
diff --git a/htdocs/user/ldap.php b/htdocs/user/ldap.php
index 8e12bf1b461..66199e9b3f6 100644
--- a/htdocs/user/ldap.php
+++ b/htdocs/user/ldap.php
@@ -153,13 +153,13 @@ print dol_get_fiche_end();
*/
print '\n";
-if ($conf->global->LDAP_SYNCHRO_ACTIVE == 'dolibarr2ldap') {
+if (getDolGlobalInt('LDAP_SYNCHRO_ACTIVE') === Ldap::SYNCHRO_DOLIBARR_TO_LDAP) {
print " \n";
}
From dd8d4e9e983c5650f31db1386fdb698ee668f315 Mon Sep 17 00:00:00 2001
From: ATM john
Date: Thu, 4 Nov 2021 12:10:19 +0100
Subject: [PATCH 040/178] Fix missing return status
---
htdocs/core/db/DoliDB.class.php | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/htdocs/core/db/DoliDB.class.php b/htdocs/core/db/DoliDB.class.php
index 8f2a9dc315e..af470ac62d6 100644
--- a/htdocs/core/db/DoliDB.class.php
+++ b/htdocs/core/db/DoliDB.class.php
@@ -308,7 +308,7 @@ abstract class DoliDB implements Database
* Note : This method executes a given SQL query and retrieves the first row of results as an object. It should only be used with SELECT queries
* Dont add LIMIT to your query, it will be added by this method
* @param string $sql the sql query string
- * @return bool| object
+ * @return bool|int|object false on failure, 0 on empty, object on success
*/
public function getRow($sql)
{
@@ -317,7 +317,13 @@ abstract class DoliDB implements Database
$res = $this->query($sql);
if ($res)
{
- return $this->fetch_object($res);
+ $obj = $this->fetch_object($res);
+ if(!$obj){
+ return 0;
+ }
+ else{
+ return $obj;
+ }
}
return false;
From 3959d12a39bf5022c6436b493b6de4be77f754fb Mon Sep 17 00:00:00 2001
From: Laurent Destailleur
Date: Fri, 5 Nov 2021 12:42:42 +0100
Subject: [PATCH 041/178] Update DoliDB.class.php
---
htdocs/core/db/DoliDB.class.php | 12 +++++-------
1 file changed, 5 insertions(+), 7 deletions(-)
diff --git a/htdocs/core/db/DoliDB.class.php b/htdocs/core/db/DoliDB.class.php
index af470ac62d6..68e29f22481 100644
--- a/htdocs/core/db/DoliDB.class.php
+++ b/htdocs/core/db/DoliDB.class.php
@@ -312,17 +312,15 @@ abstract class DoliDB implements Database
*/
public function getRow($sql)
{
- $sql .= ' LIMIT 1;';
+ $sql .= ' LIMIT 1';
$res = $this->query($sql);
- if ($res)
- {
+ if ($res) {
$obj = $this->fetch_object($res);
- if(!$obj){
- return 0;
- }
- else{
+ if ($obj) {
return $obj;
+ } else {
+ return 0;
}
}
From 19b9412c1357299940c14be206bf464fc774cd61 Mon Sep 17 00:00:00 2001
From: Laurent Destailleur
Date: Fri, 5 Nov 2021 12:49:33 +0100
Subject: [PATCH 042/178] FIX #19305
---
htdocs/core/modules/modPropale.class.php | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/htdocs/core/modules/modPropale.class.php b/htdocs/core/modules/modPropale.class.php
index 007e92e4277..12835530bf9 100644
--- a/htdocs/core/modules/modPropale.class.php
+++ b/htdocs/core/modules/modPropale.class.php
@@ -156,7 +156,8 @@ class modPropale extends DolibarrModules
$this->rights[$r][1] = 'Close commercial proposals'; // libelle de la permission
$this->rights[$r][2] = 'd'; // type de la permission (deprecie a ce jour)
$this->rights[$r][3] = 0; // La permission est-elle une permission par defaut
- $this->rights[$r][4] = 'cloturer';
+ $this->rights[$r][4] = 'propal_advance';
+ $this->rights[$r][5] = 'close';
$r++;
$this->rights[$r][0] = 27; // id de la permission
From 15bc4a7d6b4b0a7a9c943b12989f3950b3fb5aad Mon Sep 17 00:00:00 2001
From: Laurent Destailleur
Date: Fri, 5 Nov 2021 13:18:37 +0100
Subject: [PATCH 043/178] Update index.php
---
htdocs/adherents/stats/index.php | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/htdocs/adherents/stats/index.php b/htdocs/adherents/stats/index.php
index de9a5b3d9d9..7bf395e9bcc 100644
--- a/htdocs/adherents/stats/index.php
+++ b/htdocs/adherents/stats/index.php
@@ -195,9 +195,7 @@ foreach ($data as $val) {
}
print '';
print '';
- //print '';
- print ' '.$year.' ';
- //print '';
+ print ''.$year.' ';
print ' ';
print ''.$val['nb'].' ';
print ''.price(price2num($val['total'], 'MT'), 1).' ';
From 9d7f7e2090fa84ebece603aefa7fb34e7952bdb5 Mon Sep 17 00:00:00 2001
From: daraelmin
Date: Fri, 5 Nov 2021 14:03:56 +0100
Subject: [PATCH 044/178] Better condition
---
htdocs/adherents/subscription.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/htdocs/adherents/subscription.php b/htdocs/adherents/subscription.php
index e8a703a6efb..05e55206c02 100644
--- a/htdocs/adherents/subscription.php
+++ b/htdocs/adherents/subscription.php
@@ -943,7 +943,7 @@ if ($rowid > 0) {
}
if (!$datefrom) {
$datefrom = $object->datevalid;
- if ($object->datefin > 0 && dol_now() < dol_time_plus_duree(dol_time_plus_duree($object->datefin, 2 * $defaultdelay, $defaultdelayunit), -1, 'd')) {
+ if ($object->datefin > 0 && dol_time_plus_duree($object->datefin, $defaultdelay, $defaultdelayunit) < dol_now()) {
$datefrom = dol_time_plus_duree($object->datefin, 1, 'd');
} else {
$datefrom = dol_get_first_day(dol_print_date(time(), "%Y"));
From 61d97ccd22abfc9fd60bce6741b7cf4e1d2047bf Mon Sep 17 00:00:00 2001
From: Nicolas Domenech
Date: Fri, 5 Nov 2021 16:02:24 +0100
Subject: [PATCH 045/178] NEW : redirect after connection in login page
---
htdocs/core/lib/security2.lib.php | 5 +++++
htdocs/core/tpl/login.tpl.php | 2 +-
2 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/htdocs/core/lib/security2.lib.php b/htdocs/core/lib/security2.lib.php
index ab47bc02899..d6546e64cfd 100644
--- a/htdocs/core/lib/security2.lib.php
+++ b/htdocs/core/lib/security2.lib.php
@@ -224,6 +224,11 @@ if (!function_exists('dol_loginfunction')) {
$reshook = $hookmanager->executeHooks('getLoginPageExtraOptions', $parameters); // Note that $action and $object may have been modified by some hooks.
$moreloginextracontent = $hookmanager->resPrint;
+ //Redirect after connection
+ $parameters = array('entity' => GETPOST('entity', 'int'));
+ $reshook = $hookmanager->executeHooks('redirectAfterConnection', $parameters); // Note that $action and $object may have been modified by some hooks.
+ $php_self = $hookmanager->resPrint;
+
// Login
$login = (!empty($hookmanager->resArray['username']) ? $hookmanager->resArray['username'] : (GETPOST("username", "alpha") ? GETPOST("username", "alpha") : $demologin));
$password = $demopassword;
diff --git a/htdocs/core/tpl/login.tpl.php b/htdocs/core/tpl/login.tpl.php
index 0a4bb149986..9f2f2f68712 100644
--- a/htdocs/core/tpl/login.tpl.php
+++ b/htdocs/core/tpl/login.tpl.php
@@ -57,7 +57,7 @@ if (!empty($conf->dol_use_jmobile)) {
$conf->use_javascript_ajax = 1;
}
-$php_self = dol_escape_htmltag($_SERVER['PHP_SELF']);
+$php_self = empty($php_self) ? dol_escape_htmltag($_SERVER['PHP_SELF']) : $php_self;
$php_self .= dol_escape_htmltag($_SERVER["QUERY_STRING"]) ? '?'.dol_escape_htmltag($_SERVER["QUERY_STRING"]) : '';
if (!preg_match('/mainmenu=/', $php_self)) {
$php_self .= (preg_match('/\?/', $php_self) ? '&' : '?').'mainmenu=home';
From 77864f2c2c45678f167c891e106d9912bf738edf Mon Sep 17 00:00:00 2001
From: Laurent Destailleur
Date: Sat, 6 Nov 2021 19:07:28 +0100
Subject: [PATCH 046/178] NEW Can set value for EHLO smtp command in
MAIL_SMTP_USE_FROM_FOR_HELO
---
htdocs/core/class/smtps.class.php | 77 ++++++++++++++++++++++++-------
1 file changed, 61 insertions(+), 16 deletions(-)
diff --git a/htdocs/core/class/smtps.class.php b/htdocs/core/class/smtps.class.php
index c287aae1c2f..dbaaacc2d18 100644
--- a/htdocs/core/class/smtps.class.php
+++ b/htdocs/core/class/smtps.class.php
@@ -464,20 +464,26 @@ class SMTPs
$host = 'tls://'.$host;
}
- $hosth = $host;
+ $hosth = $host; // so for example 'localhost' or 'smtp-relay.gmail.com'
if (!empty($conf->global->MAIL_SMTP_USE_FROM_FOR_HELO)) {
- // If the from to is 'aaa ', we will keep 'ccc.com'
- $hosth = $this->getFrom('addr');
- $hosth = preg_replace('/^.*', '', $hosth);
- $hosth = preg_replace('/>.*$/', '', $hosth);
- $hosth = preg_replace('/.*@/', '', $hosth);
+ if (!is_numeric($conf->global->MAIL_SMTP_USE_FROM_FOR_HELO)) {
+ // If value of MAIL_SMTP_USE_FROM_FOR_HELO is a string, we use it as domain name
+ $hosth = $conf->global->MAIL_SMTP_USE_FROM_FOR_HELO;
+ } else {
+ // If value of MAIL_SMTP_USE_FROM_FOR_HELO is 1, we use the domain in the from.
+ // So if the from to is 'aaa ', we will keep 'ccc.com'
+ $hosth = $this->getFrom('addr');
+ $hosth = preg_replace('/^.*', '', $hosth);
+ $hosth = preg_replace('/>.*$/', '', $hosth);
+ $hosth = preg_replace('/.*@/', '', $hosth);
+ }
}
if ($_retVal = $this->socket_send_str('EHLO '.$hosth, '250')) {
if ($usetls) {
/*
- The following dialog illustrates how a client and server can start a TLS STARTTLS session
+ The following dialog illustrates how a client and server can start a TLS STARTTLS session:
S:
C:
S: 220 mail.imc.org SMTP service ready
@@ -494,6 +500,39 @@ class SMTPs
S: 250-server-domain.com
S: 250 AUTH LOGIN
C:
+ S: 250 OK
+ C: RCPT TO:
+ S: 250 OK
+ C: DATA
+ S: 354 Send message, end with a "." on a line by itself
+ C:
+ S .
+ S: 250 OK, message accepted for delivery: queued as 12345
+ C: QUIT
+ S: 221 Bye
*/
if (!$_retVal = $this->socket_send_str('STARTTLS', 220)) {
$this->_setErr(131, 'STARTTLS connection is not supported.');
@@ -517,10 +556,10 @@ class SMTPs
$this->_setErr(132, 'STARTTLS connection failed.');
return $_retVal;
}
- // Most server servers expect a 2nd pass of EHLO after TLS is established to get another time
+ // Most servers expect a 2nd pass of EHLO after TLS is established to get another time
// the answer with list of supported AUTH methods. They may differs between non STARTTLS and with STARTTLS.
- if (!$_retVal = $this->socket_send_str('EHLO '.$hosth, '250')) {
- $this->_setErr(126, '"'.$hosth.'" does not support authenticated connections.');
+ if (! $_retVal = $this->socket_send_str('EHLO '.$hosth, '250')) {
+ $this->_setErr(126, '"'.$hosth.'" does not support authenticated connections. Error after sending EHLO '.$hosth);
return $_retVal;
}
}
@@ -560,7 +599,7 @@ class SMTPs
$this->_setErr(130, 'Invalid Authentication Credentials.');
}
} else {
- $this->_setErr(126, '"'.$host.'" does not support authenticated connections.');
+ $this->_setErr(126, '"'.$host.'" does not support authenticated connections. Error after sending EHLO '.$hosth);
}
return $_retVal;
@@ -603,11 +642,17 @@ class SMTPs
$hosth = $host;
if (!empty($conf->global->MAIL_SMTP_USE_FROM_FOR_HELO)) {
- // If the from to is 'aaa ', we will keep 'ccc.com'
- $hosth = $this->getFrom('addr');
- $hosth = preg_replace('/^.*', '', $hosth);
- $hosth = preg_replace('/>.*$/', '', $hosth);
- $hosth = preg_replace('/.*@/', '', $hosth);
+ if (!is_numeric($conf->global->MAIL_SMTP_USE_FROM_FOR_HELO)) {
+ // If value of MAIL_SMTP_USE_FROM_FOR_HELO is a string, we use it as domain name
+ $hosth = $conf->global->MAIL_SMTP_USE_FROM_FOR_HELO;
+ } else {
+ // If value of MAIL_SMTP_USE_FROM_FOR_HELO is 1, we use the domain in the from.
+ // If the from to is 'aaa ', we will keep 'ccc.com'
+ $hosth = $this->getFrom('addr');
+ $hosth = preg_replace('/^.*', '', $hosth);
+ $hosth = preg_replace('/>.*$/', '', $hosth);
+ $hosth = preg_replace('/.*@/', '', $hosth);
+ }
}
$_retVal = $this->socket_send_str('HELO '.$hosth, '250');
From 65105a3e05b26a8c6959da65394ed38fb909df42 Mon Sep 17 00:00:00 2001
From: Laurent Destailleur
Date: Sat, 6 Nov 2021 19:27:50 +0100
Subject: [PATCH 047/178] Better log
---
htdocs/core/class/ldap.class.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/htdocs/core/class/ldap.class.php b/htdocs/core/class/ldap.class.php
index e2ce33cc45f..48618a83dd9 100644
--- a/htdocs/core/class/ldap.class.php
+++ b/htdocs/core/class/ldap.class.php
@@ -261,7 +261,7 @@ class Ldap
}
// Try in anonymous
if (!$this->bind) {
- dol_syslog(get_class($this)."::connect_bind try bind on ".$host, LOG_DEBUG);
+ dol_syslog(get_class($this)."::connect_bind try bind anonymously on ".$host, LOG_DEBUG);
$result = $this->bind();
if ($result) {
$this->bind = $this->result;
From fc70adb2e74f53dbcf3746b94731dc55ae4df8c9 Mon Sep 17 00:00:00 2001
From: Laurent Destailleur
Date: Sat, 6 Nov 2021 20:40:26 +0100
Subject: [PATCH 048/178] Fix ref suffix for patnership into PSHIP
---
.../core/modules/partnership/mod_partnership_standard.php | 2 +-
htdocs/partnership/partnership_card.php | 4 ++--
htdocs/partnership/partnership_list.php | 2 +-
3 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/htdocs/partnership/core/modules/partnership/mod_partnership_standard.php b/htdocs/partnership/core/modules/partnership/mod_partnership_standard.php
index fefcafa2350..d5a2bb326b2 100644
--- a/htdocs/partnership/core/modules/partnership/mod_partnership_standard.php
+++ b/htdocs/partnership/core/modules/partnership/mod_partnership_standard.php
@@ -36,7 +36,7 @@ class mod_partnership_standard extends ModeleNumRefPartnership
*/
public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr'
- public $prefix = 'PARTNERSHIP';
+ public $prefix = 'PSHIP';
/**
* @var string Error code (or message)
diff --git a/htdocs/partnership/partnership_card.php b/htdocs/partnership/partnership_card.php
index 99cdb74e264..72787042e0e 100644
--- a/htdocs/partnership/partnership_card.php
+++ b/htdocs/partnership/partnership_card.php
@@ -232,7 +232,7 @@ if (empty($reshook)) {
// Actions to send emails
$triggersendname = 'PARTNERSHIP_SENTBYMAIL';
$autocopy = 'MAIN_MAIL_AUTOCOPY_PARTNERSHIP_TO';
- $trackid = 'partnership'.$object->id;
+ $trackid = 'pship'.$object->id;
include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php';
if (!empty($id) && !empty(GETPOST('confirm'))) {
@@ -664,7 +664,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
$modelmail = 'partnership_send';
$defaulttopic = 'InformationMessage';
$diroutput = $conf->partnership->dir_output;
- $trackid = 'partnership'.$object->id;
+ $trackid = 'pship'.$object->id;
include DOL_DOCUMENT_ROOT.'/core/tpl/card_presend.tpl.php';
}
diff --git a/htdocs/partnership/partnership_list.php b/htdocs/partnership/partnership_list.php
index a5c52609d74..ef3b55ae44b 100644
--- a/htdocs/partnership/partnership_list.php
+++ b/htdocs/partnership/partnership_list.php
@@ -464,7 +464,7 @@ print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sort
$topicmail = "SendPartnershipRef";
$modelmail = "partnership_send";
$objecttmp = new Partnership($db);
-$trackid = 'partnership'.$object->id;
+$trackid = 'pship'.$object->id;
include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
if ($search_all) {
From ccc1d4d1fa1871d7b5680376427dbd95a43ef513 Mon Sep 17 00:00:00 2001
From: Laurent Destailleur
Date: Sun, 7 Nov 2021 12:24:25 +0100
Subject: [PATCH 049/178] Fix warning
---
htdocs/core/lib/pdf.lib.php | 2 ++
1 file changed, 2 insertions(+)
diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php
index 4821bfde2b9..3ba436cf28c 100644
--- a/htdocs/core/lib/pdf.lib.php
+++ b/htdocs/core/lib/pdf.lib.php
@@ -979,6 +979,7 @@ function pdf_pagefoot(&$pdf, $outputlangs, $paramfreetext, $fromcompany, $marge_
$outputlangs->load("dict");
$line = '';
+ $reg = aray();
$dims = $pdf->getPageDimensions();
@@ -1273,6 +1274,7 @@ function pdf_writelinedesc(&$pdf, $object, $i, $outputlangs, $w, $h, $posx, $pos
// Fix bug of some HTML editors that replace links ]*src=")([^"]*)(&)([^"]*")/', '\1\2&\4', $labelproductservice, -1, $nbrep);
//var_dump($labelproductservice);exit;
From 713db0e61355924009116566e720c8e90bc8b7e7 Mon Sep 17 00:00:00 2001
From: Laurent Destailleur
Date: Sun, 7 Nov 2021 12:26:44 +0100
Subject: [PATCH 050/178] Removed function pdf_getTotalQty (duplicate with
pdf_getlineqty)
---
htdocs/core/lib/pdf.lib.php | 42 -------------------------------------
1 file changed, 42 deletions(-)
diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php
index 1a8d15a4fc4..c8334edc705 100644
--- a/htdocs/core/lib/pdf.lib.php
+++ b/htdocs/core/lib/pdf.lib.php
@@ -2214,48 +2214,6 @@ function pdf_getlinetotalwithtax($object, $i, $outputlangs, $hidedetails = 0)
return $result;
}
-/**
- * Return total quantity of products and/or services
- *
- * @param Object $object Object
- * @param string $type Type
- * @param Translate $outputlangs Object langs for output
- * @return integer
- * @deprecated Not used by Dolibarr core, so will be removed.
- */
-function pdf_getTotalQty($object, $type, $outputlangs)
-{
- global $hookmanager;
-
- $total = 0;
- $nblines = count($object->lines);
-
- // Loop on each lines
- for ($i = 0; $i < $nblines; $i++) {
- if ($object->lines[$i]->special_code != 3) {
- if ($type == 'all') {
- $total += $object->lines[$i]->qty;
- } elseif ($type == 9 && is_object($hookmanager) && (($object->lines[$i]->product_type == 9 && !empty($object->lines[$i]->special_code)) || !empty($object->lines[$i]->fk_parent_line))) {
- $special_code = $object->lines[$i]->special_code;
- if (!empty($object->lines[$i]->fk_parent_line)) {
- $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
- }
- $hidedetails = '';
- $parameters = array('i'=>$i, 'outputlangs'=>$outputlangs, 'hidedetails'=>$hidedetails, 'special_code'=>$special_code);
- $action = '';
- $reshook = $hookmanager->executeHooks('pdf_getTotalQty', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
- return $hookmanager->resPrint;
- } elseif ($type == 0 && $object->lines[$i]->product_type == 0) {
- $total += $object->lines[$i]->qty;
- } elseif ($type == 1 && $object->lines[$i]->product_type == 1) {
- $total += $object->lines[$i]->qty;
- }
- }
- }
-
- return $total;
-}
-
/**
* Return linked objects to use for document generation.
* Warning: To save space, this function returns only one link per link type (all links are concated on same record string). This function is used by pdf_writeLinkedObjects
From 11bb7428cedf682dd322f1494b545e80d7c5f3f6 Mon Sep 17 00:00:00 2001
From: Laurent Destailleur
Date: Sun, 7 Nov 2021 12:34:08 +0100
Subject: [PATCH 051/178] Clean code
---
htdocs/fourn/facture/list.php | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/htdocs/fourn/facture/list.php b/htdocs/fourn/facture/list.php
index 6c133c9b5a1..7dbead5536b 100644
--- a/htdocs/fourn/facture/list.php
+++ b/htdocs/fourn/facture/list.php
@@ -975,13 +975,13 @@ if ($resql) {
// Ref
if (!empty($arrayfields['f.ref']['checked'])) {
print '';
- print ' ';
+ print ' ';
print ' ';
}
// Ref supplier
if (!empty($arrayfields['f.ref_supplier']['checked'])) {
print '';
- print ' ';
+ print ' ';
print ' ';
}
// Type
@@ -1006,7 +1006,7 @@ if ($resql) {
// Label
if (!empty($arrayfields['f.label']['checked'])) {
print '';
- print ' ';
+ print ' ';
print ' ';
}
// Date invoice
@@ -1037,11 +1037,11 @@ if ($resql) {
}
// Project
if (!empty($arrayfields['p.ref']['checked'])) {
- print ' ';
+ print ' ';
}
// Thirpdarty
if (!empty($arrayfields['s.nom']['checked'])) {
- print ' ';
+ print ' ';
}
// Town
if (!empty($arrayfields['s.town']['checked'])) {
@@ -1096,13 +1096,13 @@ if ($resql) {
if (!empty($arrayfields['f.total_localtax1']['checked'])) {
// Amount tax 1
print '';
- print ' ';
+ print ' ';
print ' ';
}
if (!empty($arrayfields['f.total_localtax2']['checked'])) {
// Amount tax 2
print '';
- print ' ';
+ print ' ';
print ' ';
}
if (!empty($arrayfields['f.total_ttc']['checked'])) {
From 09d9d1ac4242a626d253fe4b02c6fe2d667b1958 Mon Sep 17 00:00:00 2001
From: Laurent Destailleur
Date: Sun, 7 Nov 2021 12:38:44 +0100
Subject: [PATCH 052/178] Add missing unique key
---
.../install/mysql/migration/14.0.0-15.0.0.sql | 2 ++
.../tables/llx_c_partnership_type.key.sql | 19 +++++++++++++++++++
.../mysql/tables/llx_c_partnership_type.sql | 2 +-
3 files changed, 22 insertions(+), 1 deletion(-)
create mode 100644 htdocs/install/mysql/tables/llx_c_partnership_type.key.sql
diff --git a/htdocs/install/mysql/migration/14.0.0-15.0.0.sql b/htdocs/install/mysql/migration/14.0.0-15.0.0.sql
index 02a18f69a40..2c460d4ab88 100644
--- a/htdocs/install/mysql/migration/14.0.0-15.0.0.sql
+++ b/htdocs/install/mysql/migration/14.0.0-15.0.0.sql
@@ -80,6 +80,8 @@ INSERT INTO llx_c_email_templates (entity, module, type_template, lang, private,
-- v15
+ALTER TABLE llx_c_partnership_type ADD UNIQUE INDEX uk_c_partnership_type(entity, code);
+
ALTER TABLE llx_c_holiday_types CHANGE COLUMN newByMonth newbymonth double(8,5) DEFAULT 0 NOT NULL;
ALTER TABLE llx_product ADD COLUMN mandatory_period tinyint NULL DEFAULT 0;
diff --git a/htdocs/install/mysql/tables/llx_c_partnership_type.key.sql b/htdocs/install/mysql/tables/llx_c_partnership_type.key.sql
new file mode 100644
index 00000000000..c4aa0c04b0a
--- /dev/null
+++ b/htdocs/install/mysql/tables/llx_c_partnership_type.key.sql
@@ -0,0 +1,19 @@
+-- ========================================================================
+-- Copyright (C) 2021 Laurent Destailleur
+--
+-- This program is free software; you can redistribute it and/or modify
+-- it under the terms of the GNU General Public License as published by
+-- the Free Software Foundation; either version 3 of the License, or
+-- (at your option) any later version.
+--
+-- This program is distributed in the hope that it will be useful,
+-- but WITHOUT ANY WARRANTY; without even the implied warranty of
+-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+-- GNU General Public License for more details.
+--
+-- You should have received a copy of the GNU General Public License
+-- along with this program. If not, see .
+--
+-- ========================================================================
+
+ALTER TABLE llx_c_partnership_type ADD UNIQUE INDEX uk_c_partnership_type(entity, code);
diff --git a/htdocs/install/mysql/tables/llx_c_partnership_type.sql b/htdocs/install/mysql/tables/llx_c_partnership_type.sql
index 23d5a89e16c..d2a4a3b7549 100644
--- a/htdocs/install/mysql/tables/llx_c_partnership_type.sql
+++ b/htdocs/install/mysql/tables/llx_c_partnership_type.sql
@@ -30,6 +30,6 @@ create table llx_c_partnership_type
entity integer DEFAULT 1 NOT NULL,
code varchar(32) NOT NULL,
label varchar(64) NOT NULL,
- active tinyint DEFAULT 1 NOT NULL
+ active tinyint DEFAULT 1 NOT NULL
)ENGINE=innodb;
From e8a2fc33c31fce90c5c51563a0ea3021e2caa2de Mon Sep 17 00:00:00 2001
From: Laurent Destailleur
Date: Sun, 7 Nov 2021 12:47:03 +0100
Subject: [PATCH 053/178] Fix visiblity of dictionnary for MAIN_USE_EXPENSE_IK
---
htdocs/admin/dict.php | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php
index 4a5a09a3461..035d44cf3b2 100644
--- a/htdocs/admin/dict.php
+++ b/htdocs/admin/dict.php
@@ -509,8 +509,8 @@ $tabcond[30] = !empty($conf->label->enabled);
$tabcond[32] = (!empty($conf->holiday->enabled) || !empty($conf->hrm->enabled));
$tabcond[33] = !empty($conf->hrm->enabled);
$tabcond[34] = !empty($conf->hrm->enabled);
-$tabcond[35] = !empty($conf->expensereport->enabled);
-$tabcond[36] = !empty($conf->expensereport->enabled);
+$tabcond[35] = !empty($conf->expensereport->enabled) && !empty($conf->global->MAIN_USE_EXPENSE_IK);
+$tabcond[36] = !empty($conf->expensereport->enabled) && !empty($conf->global->MAIN_USE_EXPENSE_IK);
$tabcond[37] = !empty($conf->product->enabled);
$tabcond[38] = !empty($conf->socialnetworks->enabled);
$tabcond[39] = (!empty($conf->societe->enabled) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && !empty($conf->global->THIRDPARTY_ENABLE_PROSPECTION_ON_ALTERNATIVE_ADRESSES));
From 22345225190627b3b1a44c5a9d121db2af9931aa Mon Sep 17 00:00:00 2001
From: Laurent Destailleur
Date: Sun, 7 Nov 2021 13:51:31 +0100
Subject: [PATCH 054/178] Debug module parnership. Add the type of partnership.
---
htdocs/admin/dict.php | 2 +-
htdocs/core/lib/modulebuilder.lib.php | 4 +-
.../install/mysql/migration/14.0.0-15.0.0.sql | 2 +
.../install/mysql/tables/llx_partnership.sql | 1 +
htdocs/modulebuilder/index.php | 29 +-
.../template/class/myobject.class.php | 6 +-
.../partnership/class/partnership.class.php | 18 +-
.../class/partnership_type.class.php | 562 ++++++++++++++++++
8 files changed, 609 insertions(+), 15 deletions(-)
create mode 100644 htdocs/partnership/class/partnership_type.class.php
diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php
index 035d44cf3b2..35fd58980b1 100644
--- a/htdocs/admin/dict.php
+++ b/htdocs/admin/dict.php
@@ -2107,7 +2107,7 @@ if ($id) {
if ($iserasable) {
print '';
if ($user->admin) {
- print ''.img_delete().' ';
+ print ''.img_delete().' ';
}
//else print ''.img_delete().' '; // Some dictionary can be edited by other profile than admin
print ' ';
diff --git a/htdocs/core/lib/modulebuilder.lib.php b/htdocs/core/lib/modulebuilder.lib.php
index a5589679b50..d44da05fa38 100644
--- a/htdocs/core/lib/modulebuilder.lib.php
+++ b/htdocs/core/lib/modulebuilder.lib.php
@@ -17,8 +17,8 @@
*/
/**
- * \file htdocs/core/lib/memory.lib.php
- * \brief Set of function for memory/cache management
+ * \file htdocs/core/lib/modulebuilder.lib.php
+ * \brief Set of function for modulebuilder management
*/
diff --git a/htdocs/install/mysql/migration/14.0.0-15.0.0.sql b/htdocs/install/mysql/migration/14.0.0-15.0.0.sql
index 2c460d4ab88..960b8010d51 100644
--- a/htdocs/install/mysql/migration/14.0.0-15.0.0.sql
+++ b/htdocs/install/mysql/migration/14.0.0-15.0.0.sql
@@ -82,6 +82,8 @@ INSERT INTO llx_c_email_templates (entity, module, type_template, lang, private,
ALTER TABLE llx_c_partnership_type ADD UNIQUE INDEX uk_c_partnership_type(entity, code);
+ALTER TABLE llx_partnership ADD COLUMN fk_type integer DEFAULT 0 NOT NULL;
+
ALTER TABLE llx_c_holiday_types CHANGE COLUMN newByMonth newbymonth double(8,5) DEFAULT 0 NOT NULL;
ALTER TABLE llx_product ADD COLUMN mandatory_period tinyint NULL DEFAULT 0;
diff --git a/htdocs/install/mysql/tables/llx_partnership.sql b/htdocs/install/mysql/tables/llx_partnership.sql
index 6ab312f8875..47ee7f3a48b 100644
--- a/htdocs/install/mysql/tables/llx_partnership.sql
+++ b/htdocs/install/mysql/tables/llx_partnership.sql
@@ -20,6 +20,7 @@ CREATE TABLE llx_partnership(
rowid integer AUTO_INCREMENT PRIMARY KEY NOT NULL,
ref varchar(128) DEFAULT '(PROV)' NOT NULL,
status smallint NOT NULL DEFAULT '0',
+ fk_type integer DEFAULT 0 NOT NULL,
fk_soc integer,
fk_member integer,
date_partnership_start date NOT NULL,
diff --git a/htdocs/modulebuilder/index.php b/htdocs/modulebuilder/index.php
index cab90270d64..9239413d951 100644
--- a/htdocs/modulebuilder/index.php
+++ b/htdocs/modulebuilder/index.php
@@ -262,6 +262,7 @@ if ($dirins && $action == 'initmodule' && $modulename) {
// Delete some files related to Object (because the previous dolCopyDir has copied everything)
dol_delete_file($destdir.'/myobject_card.php');
+ dol_delete_file($destdir.'/myobject_contact.php');
dol_delete_file($destdir.'/myobject_note.php');
dol_delete_file($destdir.'/myobject_document.php');
dol_delete_file($destdir.'/myobject_agenda.php');
@@ -337,6 +338,14 @@ if ($dirins && $action == 'initmodule' && $modulename) {
setEventMessages('ModuleInitialized', null);
$module = $modulename;
$modulename = '';
+
+ clearstatcache(true);
+ if (function_exists('opcache_invalidate')) {
+ opcache_reset(); // remove the include cache hell !
+ }
+
+ header("Location: ".$_SERVER["PHP_SELF"].'?module='.$modulename);
+ exit;
}
}
@@ -953,7 +962,7 @@ if ($dirins && $action == 'initobject' && $module && GETPOST('createtablearray',
if ($notnull) {
$string .= ", 'notnull'=>".$notnull;
}
- if ($fieldname == 'ref') {
+ if ($fieldname == 'ref' || $fieldname == 'code') {
$string .= ", 'showoncombobox'=>1";
}
$string .= ", 'position'=>".$position;
@@ -1417,6 +1426,14 @@ if ($dirins && $action == 'confirm_deletemodule') {
if ($result > 0) {
setEventMessages($langs->trans("DirWasRemoved", $modulelowercase), null);
+
+ clearstatcache(true);
+ if (function_exists('opcache_invalidate')) {
+ opcache_reset(); // remove the include cache hell !
+ }
+
+ header("Location: ".$_SERVER["PHP_SELF"].'?module=deletemodule');
+ exit;
} else {
setEventMessages($langs->trans("PurgeNothingToDelete"), null, 'warnings');
}
@@ -1757,6 +1774,10 @@ if (!empty($module) && $module != 'initmodule' && $module != 'deletemodule') {
$loadclasserrormessage = $e->getMessage()." \n";
$loadclasserrormessage .= 'File: '.$e->getFile()." \n";
$loadclasserrormessage .= 'Line: '.$e->getLine()." \n";
+ } catch (Exception $e) {
+ $loadclasserrormessage = $e->getMessage()." \n";
+ $loadclasserrormessage .= 'File: '.$e->getFile()." \n";
+ $loadclasserrormessage .= 'Line: '.$e->getLine()." \n";
}
if (class_exists($class)) {
@@ -1771,6 +1792,7 @@ if (!empty($module) && $module != 'initmodule' && $module != 'deletemodule') {
$error++;
}
$langs->load("errors");
+ print '';
print img_warning('').' '.$langs->trans("ErrorFailedToLoadModuleDescriptorForXXX", $module).' ';
print $loadclasserrormessage;
}
@@ -2423,8 +2445,8 @@ if ($module == 'initmodule') {
print ''.$langs->trans("EnterNameOfObjectDesc").' ';
print ' ';
- print ' '.$form->textwithpicto($langs->trans("IncludeRefGeneration"), $langs->trans("IncludeRefGenerationHelp")).' ';
- print ' '.$form->textwithpicto($langs->trans("IncludeDocGeneration"), $langs->trans("IncludeDocGenerationHelp")).' ';
+ print ' '.$form->textwithpicto($langs->trans("IncludeRefGeneration"), $langs->trans("IncludeRefGenerationHelp")).' ';
+ print ' '.$form->textwithpicto($langs->trans("IncludeDocGeneration"), $langs->trans("IncludeDocGenerationHelp")).' ';
print ' ';
print ' ';
print ' ';
@@ -2633,6 +2655,7 @@ if ($module == 'initmodule') {
print ' ';
+ clearstatcache(true);
if (function_exists('opcache_invalidate')) {
opcache_invalidate($dirread.'/'.$pathtoclass, true); // remove the include cache hell !
}
diff --git a/htdocs/modulebuilder/template/class/myobject.class.php b/htdocs/modulebuilder/template/class/myobject.class.php
index 8e316d014d5..6e5d6efcff4 100644
--- a/htdocs/modulebuilder/template/class/myobject.class.php
+++ b/htdocs/modulebuilder/template/class/myobject.class.php
@@ -767,7 +767,7 @@ class MyObject extends CommonObject
if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) {
$add_save_lastsearch_values = 1;
}
- if ($add_save_lastsearch_values) {
+ if ($url && $add_save_lastsearch_values) {
$url .= '&save_lastsearch_values=1';
}
}
@@ -784,13 +784,13 @@ class MyObject extends CommonObject
$linkclose = ($morecss ? ' class="'.$morecss.'"' : '');
}
- if ($option == 'nolink') {
+ if ($option == 'nolink' || empty($url)) {
$linkstart = '';
- if ($option == 'nolink') {
+ if ($option == 'nolink' || empty($url)) {
$linkend = ' ';
} else {
$linkend = '';
diff --git a/htdocs/partnership/class/partnership.class.php b/htdocs/partnership/class/partnership.class.php
index f2b15735762..b378435e546 100644
--- a/htdocs/partnership/class/partnership.class.php
+++ b/htdocs/partnership/class/partnership.class.php
@@ -1,6 +1,6 @@
- * Copyright (C) 2021 NextGestion
+/* Copyright (C) 2017 Laurent Destailleur
+ * Copyright (C) 2021 NextGestion
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -27,6 +27,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php';
//require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php';
//require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php';
+
/**
* Class for Partnership
*/
@@ -105,7 +106,7 @@ class Partnership extends CommonObject
'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>'1', 'position'=>1, 'notnull'=>1, 'visible'=>0, 'noteditable'=>'1', 'index'=>1, 'css'=>'left', 'comment'=>"Id"),
'ref' => array('type'=>'varchar(128)', 'label'=>'Ref', 'enabled'=>'1', 'position'=>10, 'notnull'=>1, 'visible'=>4, 'noteditable'=>'1', 'default'=>'(PROV)', 'index'=>1, 'searchall'=>1, 'showoncombobox'=>'1', 'comment'=>"Reference of object"),
'entity' => array('type' => 'integer', 'label' => 'Entity', 'default' => 1, 'enabled' => 1, 'visible' => -2, 'notnull' => 1, 'position' => 15, 'index' => 1),
- //'fk_type' => array('type' => 'integer:PartnershipType:partnership/class/partnershiptype.class.php', 'label' => 'Type', 'default' => 1, 'enabled' => 1, 'visible' => 1, 'position' => 20),
+ 'fk_type' => array('type' => 'integer:PartnershipType:partnership/class/partnership_type.class.php', 'label' => 'Type', 'enabled' => 1, 'visible' => 1, 'position' => 20),
'note_public' => array('type'=>'html', 'label'=>'NotePublic', 'enabled'=>'1', 'position'=>61, 'notnull'=>0, 'visible'=>0,),
'note_private' => array('type'=>'html', 'label'=>'NotePrivate', 'enabled'=>'1', 'position'=>62, 'notnull'=>0, 'visible'=>0,),
'date_creation' => array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>'1', 'position'=>500, 'notnull'=>1, 'visible'=>-2,),
@@ -366,14 +367,15 @@ class Partnership extends CommonObject
return -1;
}
- $sql = 'SELECT p.rowid, p.ref, p.fk_soc, p.fk_member, p.status';
+ $sql = 'SELECT p.rowid, p.ref, p.fk_type, p.fk_soc, p.fk_member, p.status';
$sql .= ', p.entity, p.date_partnership_start, p.date_partnership_end, p.date_creation';
$sql .= ', p.fk_user_creat, p.tms, p.fk_user_modif, p.fk_user_modif';
$sql .= ', p.note_private, p.note_public';
$sql .= ', p.last_main_doc, p.count_last_url_check_error, p.last_check_backlink, p.reason_decline_or_cancel';
$sql .= ', p.import_key, p.model_pdf';
-
+ $sql .= ', pt.code as type_code, pt.label as type_label';
$sql .= ' FROM '.MAIN_DB_PREFIX.'partnership as p';
+ $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_partnership_type as pt ON p.fk_type = pt.rowid';
if ($id) {
$sql .= " WHERE p.rowid=".((int) $id);
@@ -400,8 +402,12 @@ class Partnership extends CommonObject
if ($obj) {
$this->id = $obj->rowid;
$this->entity = $obj->entity;
- $this->rowid = $obj->rowid;
$this->ref = $obj->ref;
+
+ $this->fk_type = $obj->fk_type;
+ $this->type_code = $obj->type_code;
+ $this->type_label = $obj->type_label;
+
$this->fk_soc = $obj->fk_soc;
$this->fk_member = $obj->fk_member;
$this->status = $obj->status;
diff --git a/htdocs/partnership/class/partnership_type.class.php b/htdocs/partnership/class/partnership_type.class.php
new file mode 100644
index 00000000000..6916d95e4f3
--- /dev/null
+++ b/htdocs/partnership/class/partnership_type.class.php
@@ -0,0 +1,562 @@
+
+ * Copyright (C) 2004-2008 Laurent Destailleur
+ * Copyright (C) 2009-2017 Regis Houssin
+ * Copyright (C) 2016 Charlie Benke
+ * Copyright (C) 2018-2019 Thibault Foucart
+ * Copyright (C) 2021 Waël Almoman
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+/**
+ * \file htdocs/partnership/class/partnership_type.class.php
+ * \ingroup partnership
+ * \brief File of class to manage partnership types
+ */
+
+require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php';
+
+
+/**
+ * Class to manage partnership type
+ */
+class PartnershipType extends CommonObject
+{
+ /**
+ * @var string Name of table without prefix where object is stored
+ */
+ public $table_element = 'c_partnership_type';
+
+ /**
+ * @var string ID to identify managed object
+ */
+ public $element = 'partnership_type';
+
+ /**
+ * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png
+ */
+ public $picto = 'generic';
+
+ /**
+ * 0=No test on entity, 1=Test with field entity, 2=Test with link by societe
+ * @var int
+ */
+ public $ismultientitymanaged = 1;
+
+ /**
+ * @var string Partnership code
+ */
+ public $code;
+
+ /**
+ * @var string Partnership type label
+ */
+ public $label;
+
+
+ public $fields=array(
+ 'rowid' =>array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>10),
+ 'entity' =>array('type'=>'integer', 'label'=>'Entity', 'default'=>1, 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>15, 'index'=>1),
+ 'code' =>array('type'=>'varchar(32)', 'label'=>'Code', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>20, 'showoncombobox'=>1),
+ 'label' =>array('type'=>'varchar(64)', 'label'=>'Label', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>25, 'showoncombobox'=>1),
+ 'active' =>array('type'=>'integer', 'label'=>'Active', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>30),
+ );
+
+
+
+ /**
+ * Constructor
+ *
+ * @param DoliDb $db Database handler
+ */
+ public function __construct(DoliDB $db)
+ {
+ global $conf, $langs;
+
+ $this->db = $db;
+
+ if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID) && isset($this->fields['rowid'])) {
+ $this->fields['rowid']['visible'] = 0;
+ }
+ if (empty($conf->multicompany->enabled) && isset($this->fields['entity'])) {
+ $this->fields['entity']['enabled'] = 0;
+ }
+
+ // Example to show how to set values of fields definition dynamically
+ /*if ($user->rights->mymodule->myobject->read) {
+ $this->fields['myfield']['visible'] = 1;
+ $this->fields['myfield']['noteditable'] = 0;
+ }*/
+
+ // Unset fields that are disabled
+ foreach ($this->fields as $key => $val) {
+ if (isset($val['enabled']) && empty($val['enabled'])) {
+ unset($this->fields[$key]);
+ }
+ }
+
+ // Translate some data of arrayofkeyval
+ if (is_object($langs)) {
+ foreach ($this->fields as $key => $val) {
+ if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) {
+ foreach ($val['arrayofkeyval'] as $key2 => $val2) {
+ $this->fields[$key]['arrayofkeyval'][$key2] = $langs->trans($val2);
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * Create object into database
+ *
+ * @param User $user User that creates
+ * @param bool $notrigger false=launch triggers after, true=disable triggers
+ * @return int <0 if KO, Id of created object if OK
+ */
+ public function create(User $user, $notrigger = false)
+ {
+ $resultcreate = $this->createCommon($user, $notrigger);
+
+ //$resultvalidate = $this->validate($user, $notrigger);
+
+ return $resultcreate;
+ }
+
+ /**
+ * Load object in memory from the database
+ *
+ * @param int $id Id object
+ * @param string $ref Ref
+ * @return int <0 if KO, 0 if not found, >0 if OK
+ */
+ public function fetch($id, $ref = null)
+ {
+ $result = $this->fetchCommon($id, $ref);
+ if ($result > 0 && !empty($this->table_element_line)) {
+ $this->fetchLines();
+ }
+ return $result;
+ }
+
+ /**
+ * Load list of objects in memory from the database.
+ *
+ * @param string $sortorder Sort Order
+ * @param string $sortfield Sort field
+ * @param int $limit limit
+ * @param int $offset Offset
+ * @param array $filter Filter array. Example array('field'=>'valueforlike', 'customurl'=>...)
+ * @param string $filtermode Filter mode (AND or OR)
+ * @return array|int int <0 if KO, array of pages if OK
+ */
+ public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND')
+ {
+ global $conf;
+
+ dol_syslog(__METHOD__, LOG_DEBUG);
+
+ $records = array();
+
+ $sql = "SELECT ";
+ $sql .= $this->getFieldList('t');
+ $sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element." as t";
+ if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) {
+ $sql .= " WHERE t.entity IN (".getEntity($this->table_element).")";
+ } else {
+ $sql .= " WHERE 1 = 1";
+ }
+ // Manage filter
+ $sqlwhere = array();
+ if (count($filter) > 0) {
+ foreach ($filter as $key => $value) {
+ if ($key == 't.rowid') {
+ $sqlwhere[] = $key." = ".((int) $value);
+ } elseif (in_array($this->fields[$key]['type'], array('date', 'datetime', 'timestamp'))) {
+ $sqlwhere[] = $key." = '".$this->db->idate($value)."'";
+ } elseif ($key == 'customsql') {
+ $sqlwhere[] = $value;
+ } elseif (strpos($value, '%') === false) {
+ $sqlwhere[] = $key." IN (".$this->db->sanitize($this->db->escape($value)).")";
+ } else {
+ $sqlwhere[] = $key." LIKE '%".$this->db->escape($value)."%'";
+ }
+ }
+ }
+ if (count($sqlwhere) > 0) {
+ $sql .= " AND (".implode(" ".$filtermode." ", $sqlwhere).")";
+ }
+
+ if (!empty($sortfield)) {
+ $sql .= $this->db->order($sortfield, $sortorder);
+ }
+ if (!empty($limit)) {
+ $sql .= $this->db->plimit($limit, $offset);
+ }
+
+ $resql = $this->db->query($sql);
+ if ($resql) {
+ $num = $this->db->num_rows($resql);
+ $i = 0;
+ while ($i < ($limit ? min($limit, $num) : $num)) {
+ $obj = $this->db->fetch_object($resql);
+
+ $record = new self($this->db);
+ $record->setVarsFromFetchObj($obj);
+
+ $records[$record->id] = $record;
+
+ $i++;
+ }
+ $this->db->free($resql);
+
+ return $records;
+ } else {
+ $this->errors[] = 'Error '.$this->db->lasterror();
+ dol_syslog(__METHOD__.' '.join(',', $this->errors), LOG_ERR);
+
+ return -1;
+ }
+ }
+
+ /**
+ * Update object into database
+ *
+ * @param User $user User that modifies
+ * @param bool $notrigger false=launch triggers after, true=disable triggers
+ * @return int <0 if KO, >0 if OK
+ */
+ public function update(User $user, $notrigger = false)
+ {
+ return $this->updateCommon($user, $notrigger);
+ }
+
+ /**
+ * Delete object in database
+ *
+ * @param User $user User that deletes
+ * @param bool $notrigger false=launch triggers after, true=disable triggers
+ * @return int <0 if KO, >0 if OK
+ */
+ public function delete(User $user, $notrigger = false)
+ {
+ return $this->deleteCommon($user, $notrigger);
+ //return $this->deleteCommon($user, $notrigger, 1);
+ }
+
+ /**
+ * Set draft status
+ *
+ * @param User $user Object user that modify
+ * @param int $notrigger 1=Does not execute triggers, 0=Execute triggers
+ * @return int <0 if KO, >0 if OK
+ */
+ public function setDraft($user, $notrigger = 0)
+ {
+ // Protection
+ if ($this->status <= self::STATUS_DRAFT) {
+ return 0;
+ }
+
+ /*if (! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->mymodule->write))
+ || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->mymodule->mymodule_advance->validate))))
+ {
+ $this->error='Permission denied';
+ return -1;
+ }*/
+
+ return $this->setStatusCommon($user, self::STATUS_DRAFT, $notrigger, 'PARTNERSHIPTYPE_UNVALIDATE');
+ }
+
+ /**
+ * Set cancel status
+ *
+ * @param User $user Object user that modify
+ * @param int $notrigger 1=Does not execute triggers, 0=Execute triggers
+ * @return int <0 if KO, 0=Nothing done, >0 if OK
+ */
+ public function cancel($user, $notrigger = 0)
+ {
+ // Protection
+ if ($this->status != self::STATUS_VALIDATED) {
+ return 0;
+ }
+
+ /*if (! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->mymodule->write))
+ || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->mymodule->mymodule_advance->validate))))
+ {
+ $this->error='Permission denied';
+ return -1;
+ }*/
+
+ return $this->setStatusCommon($user, self::STATUS_CANCELED, $notrigger, 'PARTNERSHIPTYPE_CANCEL');
+ }
+
+ /**
+ * Set back to validated status
+ *
+ * @param User $user Object user that modify
+ * @param int $notrigger 1=Does not execute triggers, 0=Execute triggers
+ * @return int <0 if KO, 0=Nothing done, >0 if OK
+ */
+ public function reopen($user, $notrigger = 0)
+ {
+ // Protection
+ if ($this->status != self::STATUS_CANCELED) {
+ return 0;
+ }
+
+ /*if (! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->mymodule->write))
+ || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->mymodule->mymodule_advance->validate))))
+ {
+ $this->error='Permission denied';
+ return -1;
+ }*/
+
+ return $this->setStatusCommon($user, self::STATUS_VALIDATED, $notrigger, 'PARTNERSHIPTYPE_REOPEN');
+ }
+
+ /**
+ * Return a link to the object card (with optionaly the picto)
+ *
+ * @param int $withpicto Include picto in link (0=No picto, 1=Include picto into link, 2=Only picto)
+ * @param string $option On what the link point to ('nolink', ...)
+ * @param int $notooltip 1=Disable tooltip
+ * @param string $morecss Add more css on link
+ * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking
+ * @return string String with URL
+ */
+ public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1)
+ {
+ global $conf, $langs, $hookmanager;
+
+ if (!empty($conf->dol_no_mouse_hover)) {
+ $notooltip = 1; // Force disable tooltips
+ }
+
+ $result = '';
+
+ $label = img_picto('', $this->picto).' '.$langs->trans("PartnershipType").' ';
+ if (isset($this->status)) {
+ $label .= ' '.$this->getLibStatut(5);
+ }
+ $label .= ' ';
+ $label .= ''.$langs->trans('Code').': '.$this->code;
+ $label .= ''.$langs->trans('Label').': '.$this->label;
+
+ //$url = dol_buildpath('/partnership/partnership_card.php', 1).'?id='.$this->id;
+ $url = '';
+
+ if ($option != 'nolink') {
+ // Add param to save lastsearch_values or not
+ $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
+ if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) {
+ $add_save_lastsearch_values = 1;
+ }
+ if ($url && $add_save_lastsearch_values) {
+ $url .= '&save_lastsearch_values=1';
+ }
+ }
+
+ $linkclose = '';
+ if (empty($notooltip)) {
+ if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) {
+ $label = $langs->trans("ShowMyObject");
+ $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"';
+ }
+ $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"';
+ $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"';
+ } else {
+ $linkclose = ($morecss ? ' class="'.$morecss.'"' : '');
+ }
+
+ if ($option == 'nolink' || empty($url)) {
+ $linkstart = '';
+ if ($option == 'nolink' || empty($url)) {
+ $linkend = ' ';
+ } else {
+ $linkend = '';
+ }
+
+ $result .= $linkstart;
+
+ if (empty($this->showphoto_on_popup)) {
+ if ($withpicto) {
+ $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1);
+ }
+ } else {
+ if ($withpicto) {
+ require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
+
+ list($class, $module) = explode('@', $this->picto);
+ $upload_dir = $conf->$module->multidir_output[$conf->entity]."/$class/".dol_sanitizeFileName($this->ref);
+ $filearray = dol_dir_list($upload_dir, "files");
+ $filename = $filearray[0]['name'];
+ if (!empty($filename)) {
+ $pospoint = strpos($filearray[0]['name'], '.');
+
+ $pathtophoto = $class.'/'.$this->ref.'/thumbs/'.substr($filename, 0, $pospoint).'_mini'.substr($filename, $pospoint);
+ if (empty($conf->global->{strtoupper($module.'_'.$class).'_FORMATLISTPHOTOSASUSERS'})) {
+ $result .= '';
+ } else {
+ $result .= ' ';
+ }
+
+ $result .= '';
+ } else {
+ $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1);
+ }
+ }
+ }
+
+ if ($withpicto != 2) {
+ $result .= $this->ref;
+ }
+
+ $result .= $linkend;
+ //if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : '');
+
+ global $action, $hookmanager;
+ $hookmanager->initHooks(array('myobjectdao'));
+ $parameters = array('id'=>$this->id, 'getnomurl'=>$result);
+ $reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
+ if ($reshook > 0) {
+ $result = $hookmanager->resPrint;
+ } else {
+ $result .= $hookmanager->resPrint;
+ }
+
+ return $result;
+ }
+
+ /**
+ * Return the label of the status
+ *
+ * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto
+ * @return string Label of status
+ */
+ public function getLabelStatus($mode = 0)
+ {
+ return $this->LibStatut($this->status, $mode);
+ }
+
+ /**
+ * Return the label of the status
+ *
+ * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto
+ * @return string Label of status
+ */
+ public function getLibStatut($mode = 0)
+ {
+ return $this->LibStatut($this->status, $mode);
+ }
+
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+ /**
+ * Return the status
+ *
+ * @param int $status Id status
+ * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto
+ * @return string Label of status
+ */
+ public function LibStatut($status, $mode = 0)
+ {
+ // phpcs:enable
+ if (empty($this->labelStatus) || empty($this->labelStatusShort)) {
+ global $langs;
+ //$langs->load("mymodule@mymodule");
+ $this->labelStatus[self::STATUS_DRAFT] = $langs->transnoentitiesnoconv('Draft');
+ $this->labelStatus[self::STATUS_VALIDATED] = $langs->transnoentitiesnoconv('Enabled');
+ $this->labelStatus[self::STATUS_CANCELED] = $langs->transnoentitiesnoconv('Disabled');
+ $this->labelStatusShort[self::STATUS_DRAFT] = $langs->transnoentitiesnoconv('Draft');
+ $this->labelStatusShort[self::STATUS_VALIDATED] = $langs->transnoentitiesnoconv('Enabled');
+ $this->labelStatusShort[self::STATUS_CANCELED] = $langs->transnoentitiesnoconv('Disabled');
+ }
+
+ $statusType = 'status'.$status;
+ //if ($status == self::STATUS_VALIDATED) $statusType = 'status1';
+ if ($status == self::STATUS_CANCELED) {
+ $statusType = 'status6';
+ }
+
+ return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status], '', $statusType, $mode);
+ }
+
+ /**
+ * Load the info information in the object
+ *
+ * @param int $id Id of object
+ * @return void
+ */
+ public function info($id)
+ {
+ $sql = "SELECT rowid, date_creation as datec, tms as datem,";
+ $sql .= " fk_user_creat, fk_user_modif";
+ $sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element." as t";
+ $sql .= " WHERE t.rowid = ".((int) $id);
+
+ $result = $this->db->query($sql);
+ if ($result) {
+ if ($this->db->num_rows($result)) {
+ $obj = $this->db->fetch_object($result);
+ $this->id = $obj->rowid;
+ if ($obj->fk_user_author) {
+ $cuser = new User($this->db);
+ $cuser->fetch($obj->fk_user_author);
+ $this->user_creation = $cuser;
+ }
+
+ if ($obj->fk_user_valid) {
+ $vuser = new User($this->db);
+ $vuser->fetch($obj->fk_user_valid);
+ $this->user_validation = $vuser;
+ }
+
+ if ($obj->fk_user_cloture) {
+ $cluser = new User($this->db);
+ $cluser->fetch($obj->fk_user_cloture);
+ $this->user_cloture = $cluser;
+ }
+
+ $this->date_creation = $this->db->jdate($obj->datec);
+ $this->date_modification = $this->db->jdate($obj->datem);
+ $this->date_validation = $this->db->jdate($obj->datev);
+ }
+
+ $this->db->free($result);
+ } else {
+ dol_print_error($this->db);
+ }
+ }
+
+ /**
+ * Initialise object with example values
+ * Id must be 0 if object instance is a specimen
+ *
+ * @return void
+ */
+ public function initAsSpecimen()
+ {
+ // Set here init that are not commonf fields
+ // $this->property1 = ...
+ // $this->property2 = ...
+
+ $this->initAsSpecimenCommon();
+ }
+}
From 3b7c385c6c5ee621586a78e775ccf943c0699b50 Mon Sep 17 00:00:00 2001
From: Laurent Destailleur
Date: Sun, 7 Nov 2021 13:53:30 +0100
Subject: [PATCH 055/178] Fix syntax error
---
htdocs/core/lib/pdf.lib.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php
index 3ba436cf28c..1b051a6081f 100644
--- a/htdocs/core/lib/pdf.lib.php
+++ b/htdocs/core/lib/pdf.lib.php
@@ -979,7 +979,7 @@ function pdf_pagefoot(&$pdf, $outputlangs, $paramfreetext, $fromcompany, $marge_
$outputlangs->load("dict");
$line = '';
- $reg = aray();
+ $reg = array();
$dims = $pdf->getPageDimensions();
From 98ba48c0e76f7585701e1d5bf9017d7cc797e87e Mon Sep 17 00:00:00 2001
From: Laurent Destailleur
Date: Sun, 7 Nov 2021 15:58:46 +0100
Subject: [PATCH 056/178] Look and feel v15
---
htdocs/modulebuilder/index.php | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/htdocs/modulebuilder/index.php b/htdocs/modulebuilder/index.php
index 9239413d951..ef777569ee5 100644
--- a/htdocs/modulebuilder/index.php
+++ b/htdocs/modulebuilder/index.php
@@ -1724,8 +1724,8 @@ print load_fiche_titre($text, '', 'title_setup');
print ''.$langs->trans("ModuleBuilderDesc", 'https://wiki.dolibarr.org/index.php/Module_development#Create_your_module').' ';
-print $textforlistofdirs;
-print ' ';
+//print $textforlistofdirs;
+//print ' ';
//var_dump($listofmodules);
@@ -1750,7 +1750,7 @@ if ($message) {
}
//print $langs->trans("ModuleBuilderDesc3", count($listofmodules), $FILEFLAG).' ';
-$infomodulesfound = ''.$form->textwithpicto(''.$langs->trans("ModuleBuilderDesc3", count($listofmodules)).' ', $langs->trans("ModuleBuilderDesc4", $FILEFLAG)).'
';
+$infomodulesfound = ''.$form->textwithpicto(''.$langs->trans("ModuleBuilderDesc3", count($listofmodules)).' ', $langs->trans("ModuleBuilderDesc4", $FILEFLAG).' '.$textforlistofdirs).'
';
// Load module descriptor
From 6d10facf5bda1e5d0a04893a334625134e865153 Mon Sep 17 00:00:00 2001
From: Laurent Destailleur
Date: Sun, 7 Nov 2021 16:04:37 +0100
Subject: [PATCH 057/178] Debug v15
---
htdocs/modulebuilder/index.php | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/htdocs/modulebuilder/index.php b/htdocs/modulebuilder/index.php
index ef777569ee5..1ab03743747 100644
--- a/htdocs/modulebuilder/index.php
+++ b/htdocs/modulebuilder/index.php
@@ -3355,7 +3355,8 @@ if ($module == 'initmodule') {
}
} else {
print '';
- print ' '.$langs->trans("NoTrigger");
+ print ' '.$langs->trans("TriggersFile");
+ print ' : '.$langs->trans("FileNotYetGenerated").' ';
print ''.img_picto('Generate', 'generate', 'class="paddingleft"').' ';
print ' ';
print ' ';
From ed9806576aa61063fe6ea9bf7da9ddb146137dd9 Mon Sep 17 00:00:00 2001
From: Laurent Destailleur
Date: Sun, 7 Nov 2021 16:07:16 +0100
Subject: [PATCH 058/178] Trans
---
htdocs/langs/en_US/modulebuilder.lang | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/htdocs/langs/en_US/modulebuilder.lang b/htdocs/langs/en_US/modulebuilder.lang
index 5d6b51d5fe4..e479438769d 100644
--- a/htdocs/langs/en_US/modulebuilder.lang
+++ b/htdocs/langs/en_US/modulebuilder.lang
@@ -98,7 +98,7 @@ MenusDefDescTooltip=The menus provided by your module/application are defined in
DictionariesDefDescTooltip=The dictionaries provided by your module/application are defined into the array $this->dictionaries into the module descriptor file. You can edit manually this file or use the embedded editor. Note: Once defined (and module re-activated), dictionaries are also visible into the setup area to administrator users on %s.
PermissionsDefDescTooltip=The permissions provided by your module/application are defined into the array $this->rights into the module descriptor file. You can edit manually this file or use the embedded editor. Note: Once defined (and module re-activated), permissions are visible into the default permissions setup %s.
HooksDefDesc=Define in the module_parts['hooks'] property, in the module descriptor, the context of hooks you want to manage (list of contexts can be found by a search on 'initHooks( ' in core code). Edit the hook file to add code of your hooked functions (hookable functions can be found by a search on 'executeHooks ' in core code).
-TriggerDefDesc=Define in the trigger file the code you want to execute for each business event executed.
+TriggerDefDesc=Define in the trigger file the code that you want to execute when a business event external to your module is executed (events recorded by other modules).
SeeIDsInUse=See IDs in use in your installation
SeeReservedIDsRangeHere=See range of reserved IDs
ToolkitForDevelopers=Toolkit for Dolibarr developers
From 969fe16442a098490142eb0d2622377622933e3e Mon Sep 17 00:00:00 2001
From: Laurent Destailleur
Date: Sun, 7 Nov 2021 16:51:18 +0100
Subject: [PATCH 059/178] Debug mass actions of partnership module
---
htdocs/core/actions_massactions.inc.php | 1 +
htdocs/langs/en_US/partnership.lang | 1 +
.../partnership/class/partnership.class.php | 22 ++++----
.../class/partnershiputils.class.php | 4 +-
htdocs/partnership/partnership_card.php | 8 +--
htdocs/partnership/partnership_list.php | 56 +++++++++++++++++--
6 files changed, 69 insertions(+), 23 deletions(-)
diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php
index 00bfe865aaa..8ccff0eb017 100644
--- a/htdocs/core/actions_massactions.inc.php
+++ b/htdocs/core/actions_massactions.inc.php
@@ -1556,6 +1556,7 @@ if (!$error && ($massaction == 'disable' || ($action == 'disable' && $confirm ==
}
}
+// Approve for leave only
if (!$error && ($massaction == 'approveleave' || ($action == 'approveleave' && $confirm == 'yes')) && $permissiontoapprove) {
$db->begin();
diff --git a/htdocs/langs/en_US/partnership.lang b/htdocs/langs/en_US/partnership.lang
index f5b9ebcde24..0eb73c17920 100644
--- a/htdocs/langs/en_US/partnership.lang
+++ b/htdocs/langs/en_US/partnership.lang
@@ -58,6 +58,7 @@ ManagePartnership=Manage partnership
BacklinkNotFoundOnPartnerWebsite=Backlink not found on partner website
ConfirmClosePartnershipAsk=Are you sure you want to cancel this partnership?
PartnershipType=Partnership type
+PartnershipRefApproved=Partnership %s approved
#
# Template Mail
diff --git a/htdocs/partnership/class/partnership.class.php b/htdocs/partnership/class/partnership.class.php
index b378435e546..4981dde2b45 100644
--- a/htdocs/partnership/class/partnership.class.php
+++ b/htdocs/partnership/class/partnership.class.php
@@ -67,7 +67,7 @@ class Partnership extends CommonObject
const STATUS_DRAFT = 0;
const STATUS_VALIDATED = 1; // Validate (no more draft)
- const STATUS_ACCEPTED = 2; // Approved
+ const STATUS_APPROVED = 2; // Approved
const STATUS_REFUSED = 3; // Refused
const STATUS_CANCELED = 9;
@@ -707,13 +707,13 @@ class Partnership extends CommonObject
}
/**
- * Accept object
+ * Approve object
*
* @param User $user User making status change
* @param int $notrigger 1=Does not execute triggers, 0= execute triggers
* @return int <=0 if OK, 0=Nothing done, >0 if KO
*/
- public function accept($user, $notrigger = 0)
+ public function approve($user, $notrigger = 0)
{
global $conf, $langs;
@@ -722,7 +722,7 @@ class Partnership extends CommonObject
$error = 0;
// Protection
- if ($this->status == self::STATUS_ACCEPTED) {
+ if ($this->status == self::STATUS_APPROVED) {
dol_syslog(get_class($this)."::accept action abandonned: already acceptd", LOG_WARNING);
return 0;
}
@@ -751,7 +751,7 @@ class Partnership extends CommonObject
// Accept
$sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element;
$sql .= " SET ref = '".$this->db->escape($num)."',";
- $sql .= " status = ".self::STATUS_ACCEPTED;
+ $sql .= " status = ".self::STATUS_APPROVED;
// if (!empty($this->fields['date_validation'])) {
// $sql .= ", date_validation = '".$this->db->idate($now)."'";
// }
@@ -818,7 +818,7 @@ class Partnership extends CommonObject
// Set new ref and current status
if (!$error) {
$this->ref = $num;
- $this->status = self::STATUS_ACCEPTED;
+ $this->status = self::STATUS_APPROVED;
}
if (!$error) {
@@ -893,7 +893,7 @@ class Partnership extends CommonObject
public function cancel($user, $notrigger = 0)
{
// Protection
- if ($this->status != self::STATUS_ACCEPTED) {
+ if ($this->status != self::STATUS_APPROVED) {
return 0;
}
@@ -928,7 +928,7 @@ class Partnership extends CommonObject
return -1;
}*/
- return $this->setStatusCommon($user, self::STATUS_ACCEPTED, $notrigger, 'PARTNERSHIP_REOPEN');
+ return $this->setStatusCommon($user, self::STATUS_APPROVED, $notrigger, 'PARTNERSHIP_REOPEN');
}
/**
@@ -1073,18 +1073,18 @@ class Partnership extends CommonObject
//$langs->load("partnership");
$this->labelStatus[self::STATUS_DRAFT] = $langs->transnoentitiesnoconv('Draft');
$this->labelStatus[self::STATUS_VALIDATED] = $langs->transnoentitiesnoconv('Validated');
- $this->labelStatus[self::STATUS_ACCEPTED] = $langs->transnoentitiesnoconv('Accepted');
+ $this->labelStatus[self::STATUS_APPROVED] = $langs->transnoentitiesnoconv('Approved');
$this->labelStatus[self::STATUS_REFUSED] = $langs->transnoentitiesnoconv('Refused');
$this->labelStatus[self::STATUS_CANCELED] = $langs->transnoentitiesnoconv('Canceled');
$this->labelStatusShort[self::STATUS_DRAFT] = $langs->transnoentitiesnoconv('Draft');
$this->labelStatusShort[self::STATUS_VALIDATED] = $langs->transnoentitiesnoconv('Validated');
- $this->labelStatusShort[self::STATUS_ACCEPTED] = $langs->transnoentitiesnoconv('Accepted');
+ $this->labelStatusShort[self::STATUS_APPROVED] = $langs->transnoentitiesnoconv('Approved');
$this->labelStatusShort[self::STATUS_REFUSED] = $langs->transnoentitiesnoconv('Refused');
$this->labelStatusShort[self::STATUS_CANCELED] = $langs->transnoentitiesnoconv('Canceled');
}
$statusType = 'status'.$status;
- if ($status == self::STATUS_ACCEPTED) {
+ if ($status == self::STATUS_APPROVED) {
$statusType = 'status4';
}
if ($status == self::STATUS_REFUSED) {
diff --git a/htdocs/partnership/class/partnershiputils.class.php b/htdocs/partnership/class/partnershiputils.class.php
index 0588b9e5df2..35b8a3b01e5 100644
--- a/htdocs/partnership/class/partnershiputils.class.php
+++ b/htdocs/partnership/class/partnershiputils.class.php
@@ -101,7 +101,7 @@ class PartnershipUtils
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."adherent_type as dty on (dty.rowid = d.fk_adherent_type)";
$sql .= " WHERE fk_member > 0";
$sql .= " AND (d.datefin < '".$this->db->idate($datetotest)."' AND dty.subscription = 1)";
- $sql .= " AND p.status = ".((int) $partnership::STATUS_ACCEPTED); // Only accepted not yet canceled
+ $sql .= " AND p.status = ".((int) $partnership::STATUS_APPROVED); // Only accepted not yet canceled
$sql .= $this->db->order('d.rowid', 'ASC');
// Limit is managed into loop later
@@ -262,7 +262,7 @@ class PartnershipUtils
$sql .= " WHERE 1 = 1";
$sql .= " AND p.".$fk_partner." > 0";
- $sql .= " AND p.status = ".((int) $partnership::STATUS_ACCEPTED); // Only accepted not yet canceled
+ $sql .= " AND p.status = ".((int) $partnership::STATUS_APPROVED); // Only accepted not yet canceled
$sql .= " AND (p.last_check_backlink IS NULL OR p.last_check_backlink <= '".$this->db->idate($now - 7 * 24 * 3600)."')"; // Every week, check that website contains a link to dolibarr.
$sql .= $this->db->order('p.rowid', 'ASC');
// Limit is managed into loop later
diff --git a/htdocs/partnership/partnership_card.php b/htdocs/partnership/partnership_card.php
index 72787042e0e..0f32eb94580 100644
--- a/htdocs/partnership/partnership_card.php
+++ b/htdocs/partnership/partnership_card.php
@@ -153,7 +153,7 @@ if (empty($reshook)) {
setEventMessages($object->error, $object->errors, 'errors');
}
} elseif ($action == 'confirm_accept' && $confirm == 'yes' && $permissiontoadd) {
- $result = $object->accept($user);
+ $result = $object->approve($user);
if ($result >= 0) {
// Define output language
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
@@ -590,9 +590,9 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
// Cancel
if ($permissiontoadd) {
- if ($object->status == $object::STATUS_ACCEPTED) {
+ if ($object->status == $object::STATUS_APPROVED) {
print dolGetButtonAction($langs->trans('Cancel'), '', 'default', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=close&token='.newToken(), '', $permissiontoadd);
- } elseif ($object->status > $object::STATUS_ACCEPTED) {
+ } elseif ($object->status > $object::STATUS_APPROVED) {
// print 'id.'&action=reopen&token='.newToken().'">'.$langs->trans("Re-Open").' '."\n";
print dolGetButtonAction($langs->trans('Re-Open'), '', 'default', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=confirm_reopen&confirm=yes&token='.newToken(), '', $permissiontoadd);
}
@@ -600,7 +600,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
// Refuse
if ($permissiontoadd) {
- if ($object->status != $object::STATUS_DRAFT && $object->status != $object::STATUS_ACCEPTED && $object->status != $object::STATUS_CANCELED && $object->status != $object::STATUS_REFUSED) {
+ if ($object->status != $object::STATUS_DRAFT && $object->status != $object::STATUS_APPROVED && $object->status != $object::STATUS_CANCELED && $object->status != $object::STATUS_REFUSED) {
print dolGetButtonAction($langs->trans('Refuse'), '', 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.'&action=refuse&token='.newToken(), '', $permissiontoadd);
}
}
diff --git a/htdocs/partnership/partnership_list.php b/htdocs/partnership/partnership_list.php
index ef3b55ae44b..2703d431e1a 100644
--- a/htdocs/partnership/partnership_list.php
+++ b/htdocs/partnership/partnership_list.php
@@ -29,8 +29,6 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
-
-// load partnership libraries
require_once DOL_DOCUMENT_ROOT.'/partnership/class/partnership.class.php';
// for other modules
@@ -158,6 +156,8 @@ if ($user->socid > 0) { // Protection if external user
* Actions
*/
+$error = 0;
+
if (GETPOST('cancel', 'alpha')) {
$action = 'list';
$massaction = '';
@@ -200,6 +200,43 @@ if (empty($reshook)) {
$uploaddir = $conf->partnership->dir_output;
include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
+ // Validate and approve
+ if (!$error && $massaction == 'approve' && $permissiontoadd) {
+ $objecttmp = new Partnership($db);
+
+ $db->begin();
+ $error = 0;
+ $result = 0;
+
+ foreach ($toselect as $checked) {
+ if ($objecttmp->fetch($checked)) {
+ if ($objecttmp->status == $objecttmp::STATUS_DRAFT) {
+ //$objecttmp->date = dol_now();
+ $result = $objecttmp->validate($user);
+ }
+
+ if ($result >= 0 && $objecttmp->status == $objecttmp::STATUS_VALIDATED) {
+ $result = $objecttmp->approve($user);
+ if ($result > 0) {
+ setEventMessages($langs->trans("PartnershipRefApproved", $objecttmp->ref), null);
+ } else {
+ setEventMessages($objecttmp->error, $objecttmp->errors, 'errors');
+ $error++;
+ }
+ } else {
+ setEventMessages($objecttmp->error, $objecttmp->errors, 'errors');
+ $error++;
+ }
+ }
+ }
+
+ if (!$error) {
+ $db->commit();
+ } else {
+ $db->rollback();
+ }
+ }
+
// Cancel partnership
if ($massaction == 'cancel' && $permissiontoadd) {
$db->begin();
@@ -208,9 +245,14 @@ if (empty($reshook)) {
$nbok = 0;
foreach ($toselect as $toselectid) {
$result = $objecttmp->fetch($toselectid);
+ var_dump($objecttmp->status);
if ($result > 0) {
- $result = $objecttmp->cancel($user, 3);
- if ($result <= 0) {
+ $result = $objecttmp->cancel($user, 0);
+ var_dump($result);
+ if ($result == 0) {
+ setEventMessages($langs->trans('StatusOfRefMustBe', $objecttmp->ref, $objecttmp->LibStatut($objecttmp::STATUS_APPROVED)), null, 'warnings');
+ $error++;
+ } elseif ($result <= 0) {
setEventMessages($objecttmp->error, $objecttmp->errors, 'errors');
$error++;
break;
@@ -432,7 +474,9 @@ $param .= $hookmanager->resPrint;
// List of mass actions available
$arrayofmassactions = array(
-'cancel'=>img_picto('', 'close_title', 'class="pictofixedwidth"').$langs->trans("Cancel"),
+ //'validate'=>img_picto('', 'check', 'class="pictofixedwidth"').$langs->trans("Validate"),
+ 'approve'=>img_picto('', 'check', 'class="pictofixedwidth"').$langs->trans("ValidateAndApprove"),
+ 'cancel'=>img_picto('', 'close_title', 'class="pictofixedwidth"').$langs->trans("Cancel"),
//'generate_doc'=>img_picto('', 'pdf').$langs->trans("ReGeneratePDF"),
//'builddoc'=>img_picto('', 'pdf').$langs->trans("PDFMerge"),
'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendMail"),
@@ -440,7 +484,7 @@ $arrayofmassactions = array(
if ($permissiontodelete) {
$arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete");
}
-if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) {
+if (GETPOST('nomassaction', 'int') || in_array($massaction, array('prevalidate', 'presend', 'predelete'))) {
$arrayofmassactions = array();
}
$massactionbutton = $form->selectMassAction('', $arrayofmassactions);
From 424727546550d4f653e58176d9e03f74b61cf0a5 Mon Sep 17 00:00:00 2001
From: Laurent Destailleur
Date: Sun, 7 Nov 2021 17:27:37 +0100
Subject: [PATCH 060/178] css
---
htdocs/index.php | 8 ++++----
htdocs/theme/eldy/global.inc.php | 2 +-
htdocs/theme/md/style.css.php | 2 +-
3 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/htdocs/index.php b/htdocs/index.php
index 1884d9a823a..b9ac604ca95 100644
--- a/htdocs/index.php
+++ b/htdocs/index.php
@@ -539,9 +539,9 @@ if (empty($conf->global->MAIN_DISABLE_GLOBAL_WORKBOARD)) {
$openedDashBoard .= ''."\n";
}
diff --git a/htdocs/theme/eldy/global.inc.php b/htdocs/theme/eldy/global.inc.php
index d2e3c43a3aa..31bc0e036b6 100644
--- a/htdocs/theme/eldy/global.inc.php
+++ b/htdocs/theme/eldy/global.inc.php
@@ -1086,7 +1086,7 @@ select.flat.selectlimit {
max-width: 62px;
}
.selectlimit, .marginrightonly {
- margin-right: 10px !important;
+ margin-: 10px !important;
}
.marginleftonly {
margin-: 10px !important;
diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php
index 4acf119eff7..06598624da2 100644
--- a/htdocs/theme/md/style.css.php
+++ b/htdocs/theme/md/style.css.php
@@ -1170,7 +1170,7 @@ select.flat.selectlimit {
max-width: 62px;
}
.selectlimit, .marginrightonly {
- margin-right: 10px !important;
+ margin-: 10px !important;
}
.marginleftonly {
margin-: 10px !important;
From 1934a3767651f836b3eabe3b228f7d8cf1f732dc Mon Sep 17 00:00:00 2001
From: Laurent Destailleur
Date: Sun, 7 Nov 2021 17:35:43 +0100
Subject: [PATCH 061/178] Escape to avoid false positive, even if it should be
useless.
---
htdocs/core/class/commonobject.class.php | 7 +------
htdocs/core/class/fileupload.class.php | 2 +-
2 files changed, 2 insertions(+), 7 deletions(-)
diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php
index 91446f38070..812353591ed 100644
--- a/htdocs/core/class/commonobject.class.php
+++ b/htdocs/core/class/commonobject.class.php
@@ -7874,11 +7874,6 @@ abstract class CommonObject
$out .= ($display_type=='card' ? '' : '');
- /*for($ii = 0; $ii < ($colspan - 1); $ii++)
- {
- $out .='';
- }*/
-
if (!empty($conf->global->MAIN_EXTRAFIELDS_USE_TWO_COLUMS) && (($e % 2) == 1)) {
$out .= ($display_type=='card' ? ' ' : '');
} else {
@@ -8887,7 +8882,7 @@ abstract class CommonObject
$sql = "SELECT ".$objectline->getFieldList('l');
$sql .= " FROM ".MAIN_DB_PREFIX.$objectline->table_element." as l";
- $sql .= " WHERE l.fk_".$this->element." = ".((int) $this->id);
+ $sql .= " WHERE l.fk_".$this->db->escape($this->element)." = ".((int) $this->id);
if ($morewhere) {
$sql .= $morewhere;
}
diff --git a/htdocs/core/class/fileupload.class.php b/htdocs/core/class/fileupload.class.php
index 45bc622b9db..ea8618c8b92 100644
--- a/htdocs/core/class/fileupload.class.php
+++ b/htdocs/core/class/fileupload.class.php
@@ -222,7 +222,7 @@ class FileUpload
protected function setFileDeleteUrl($file)
{
$file->delete_url = $this->options['script_url']
- .'?file='.rawurlencode($file->name).'&fk_element='.$this->fk_element.'&element='.$this->element;
+ .'?file='.urlencode($file->name).'&fk_element='.urlencode($this->fk_element).'&element='.urlencode($this->element);
$file->delete_type = $this->options['delete_type'];
if ($file->delete_type !== 'DELETE') {
$file->delete_url .= '&_method=DELETE';
From 66f85d674db5967808806cacea45cc5945d27df7 Mon Sep 17 00:00:00 2001
From: Laurent Destailleur
Date: Sun, 7 Nov 2021 17:43:17 +0100
Subject: [PATCH 062/178] Fix warning scrutinizer
---
htdocs/core/class/ldap.class.php | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/htdocs/core/class/ldap.class.php b/htdocs/core/class/ldap.class.php
index 1d31c0cfc86..4af22683b2c 100644
--- a/htdocs/core/class/ldap.class.php
+++ b/htdocs/core/class/ldap.class.php
@@ -181,6 +181,8 @@ class Ldap
$connected = 0;
$this->bind = 0;
+ $this->error = 0;
+ $this->connectedServer = '';
// Check parameters
if (count($this->server) == 0 || empty($this->server[0])) {
@@ -229,7 +231,7 @@ class Ldap
dol_syslog(get_class($this)."::connect_bind failed to start tls", LOG_WARNING);
$this->error = 'ldap_start_tls Failed to start TLS '.ldap_errno($this->connection).' '.ldap_error($this->connection);
$connected = 0;
- $this->close();
+ $this->unbind();
}
}
@@ -278,7 +280,9 @@ class Ldap
}
if (!$connected) {
- $this->close();
+ $this->unbind();
+ } else {
+ $this->connectedServer = $host;
}
}
}
@@ -291,7 +295,7 @@ class Ldap
$return = -1;
dol_syslog(get_class($this)."::connect_bind return=".$return.' - '.$this->error, LOG_WARNING);
}
- $this->connectedServer = $host;
+
return $return;
}
From 68295073720d52307b3c8040269dfbf6bab28be8 Mon Sep 17 00:00:00 2001
From: Laurent Destailleur
Date: Sun, 7 Nov 2021 17:44:34 +0100
Subject: [PATCH 063/178] Fix missing $db
---
htdocs/core/lib/functions.lib.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php
index 25dec3e47bb..602460e0e6d 100644
--- a/htdocs/core/lib/functions.lib.php
+++ b/htdocs/core/lib/functions.lib.php
@@ -106,7 +106,7 @@ function getDoliDBInstance($type, $host, $user, $pass, $name, $port)
*/
function getEntity($element, $shared = 1, $currentobject = null)
{
- global $conf, $mc, $hookmanager, $object, $action;
+ global $conf, $mc, $hookmanager, $object, $action, $db;
if (! is_object($hookmanager)) {
$hookmanager = new HookManager($db);
From 2e499c2d17326353b6a4417c70175f199e995739 Mon Sep 17 00:00:00 2001
From: Laurent Destailleur
Date: Sun, 7 Nov 2021 17:46:08 +0100
Subject: [PATCH 064/178] Fix unknown property
---
htdocs/core/lib/functions.lib.php | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php
index 602460e0e6d..0ad85cc6c49 100644
--- a/htdocs/core/lib/functions.lib.php
+++ b/htdocs/core/lib/functions.lib.php
@@ -144,10 +144,10 @@ function getEntity($element, $shared = 1, $currentobject = null)
$reshook = $hookmanager->executeHooks('hookGetEntity', $parameters, $currentobject, $action); // Note that $action and $object may have been modified by some hooks
if (is_numeric($reshook)) {
- if ($reshook == 0 && !empty($hookmanager->resprints)) {
- $out .= ','.$hookmanager->resprints; // add
+ if ($reshook == 0 && !empty($hookmanager->resPrint)) {
+ $out .= ','.$hookmanager->resPrint; // add
} elseif ($reshook == 1) {
- $out = $hookmanager->resprints; // replace
+ $out = $hookmanager->resPrint; // replace
}
}
From 5613ec71d60b2c64f4444609c69bbd8aa2f85738 Mon Sep 17 00:00:00 2001
From: Laurent Destailleur
Date: Sun, 7 Nov 2021 17:48:01 +0100
Subject: [PATCH 065/178] Fix syntax
---
htdocs/fourn/facture/card.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php
index a6cf0cb232d..7ad7d434f46 100755
--- a/htdocs/fourn/facture/card.php
+++ b/htdocs/fourn/facture/card.php
@@ -1,4 +1,4 @@
-
* Copyright (C) 2004-2020 Laurent Destailleur
* Copyright (C) 2004 Christophe Combelles
From eaf2c6e89cf762cc31c7efab842607ab07ee2023 Mon Sep 17 00:00:00 2001
From: Laurent Destailleur
Date: Sun, 7 Nov 2021 17:49:31 +0100
Subject: [PATCH 066/178] Fix $action not defined
---
htdocs/core/lib/functions.lib.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php
index 0ad85cc6c49..53ec09f943b 100644
--- a/htdocs/core/lib/functions.lib.php
+++ b/htdocs/core/lib/functions.lib.php
@@ -1845,7 +1845,7 @@ function dol_get_fiche_end($notab = 0)
*/
function dol_banner_tab($object, $paramid, $morehtml = '', $shownav = 1, $fieldid = 'rowid', $fieldref = 'ref', $morehtmlref = '', $moreparam = '', $nodbprefix = 0, $morehtmlleft = '', $morehtmlstatus = '', $onlybanner = 0, $morehtmlright = '')
{
- global $conf, $form, $user, $langs, $hookmanager;
+ global $conf, $form, $user, $langs, $hookmanager, $action;
$error = 0;
From 5d4cf586d60a8ebdae04b03a7d6ddf1e0f696c1a Mon Sep 17 00:00:00 2001
From: Laurent Destailleur
Date: Sun, 7 Nov 2021 17:51:30 +0100
Subject: [PATCH 067/178] Fix duplicate call
---
scripts/company/sync_contacts_dolibarr2ldap.php | 1 -
scripts/members/sync_members_dolibarr2ldap.php | 1 -
scripts/members/sync_members_types_dolibarr2ldap.php | 1 -
scripts/user/sync_groups_dolibarr2ldap.php | 1 -
scripts/user/sync_users_dolibarr2ldap.php | 1 -
5 files changed, 5 deletions(-)
diff --git a/scripts/company/sync_contacts_dolibarr2ldap.php b/scripts/company/sync_contacts_dolibarr2ldap.php
index e161a813ec7..ccaabb1afda 100755
--- a/scripts/company/sync_contacts_dolibarr2ldap.php
+++ b/scripts/company/sync_contacts_dolibarr2ldap.php
@@ -154,7 +154,6 @@ if ($resql) {
}
$ldap->unbind();
- $ldap->close();
} else {
dol_print_error($db);
}
diff --git a/scripts/members/sync_members_dolibarr2ldap.php b/scripts/members/sync_members_dolibarr2ldap.php
index 66c245cf3eb..74a5c4db210 100755
--- a/scripts/members/sync_members_dolibarr2ldap.php
+++ b/scripts/members/sync_members_dolibarr2ldap.php
@@ -163,7 +163,6 @@ if ($resql) {
}
$ldap->unbind();
- $ldap->close();
} else {
dol_print_error($db);
}
diff --git a/scripts/members/sync_members_types_dolibarr2ldap.php b/scripts/members/sync_members_types_dolibarr2ldap.php
index 3d592673296..3ec2c9d0d90 100755
--- a/scripts/members/sync_members_types_dolibarr2ldap.php
+++ b/scripts/members/sync_members_types_dolibarr2ldap.php
@@ -121,7 +121,6 @@ if ($resql) {
}
$ldap->unbind();
- $ldap->close();
} else {
print $ldap->error;
}
diff --git a/scripts/user/sync_groups_dolibarr2ldap.php b/scripts/user/sync_groups_dolibarr2ldap.php
index dd0476bbfca..7d9ed2f307e 100755
--- a/scripts/user/sync_groups_dolibarr2ldap.php
+++ b/scripts/user/sync_groups_dolibarr2ldap.php
@@ -112,7 +112,6 @@ if ($resql) {
}
$ldap->unbind();
- $ldap->close();
} else {
dol_print_error($db);
}
diff --git a/scripts/user/sync_users_dolibarr2ldap.php b/scripts/user/sync_users_dolibarr2ldap.php
index 26b1363d5a1..abe0b9fbcf4 100755
--- a/scripts/user/sync_users_dolibarr2ldap.php
+++ b/scripts/user/sync_users_dolibarr2ldap.php
@@ -111,7 +111,6 @@ if ($resql) {
}
$ldap->unbind();
- $ldap->close();
} else {
dol_print_error($db);
}
From f5edd25f6dfefcc6e090c603bb69af074c190cad Mon Sep 17 00:00:00 2001
From: Laurent Destailleur
Date: Sun, 7 Nov 2021 18:14:49 +0100
Subject: [PATCH 068/178] Clean code
---
.../class/ProductCombination.class.php | 28 ++++++++-----------
1 file changed, 12 insertions(+), 16 deletions(-)
diff --git a/htdocs/variants/class/ProductCombination.class.php b/htdocs/variants/class/ProductCombination.class.php
index 5e396fba8db..bb6372fd5eb 100644
--- a/htdocs/variants/class/ProductCombination.class.php
+++ b/htdocs/variants/class/ProductCombination.class.php
@@ -1061,37 +1061,33 @@ class ProductCombinationLevel
*/
public function fetchAll($fk_product_attribute_combination, $fk_price_level = 0)
{
+ $result = array();
$sql = "SELECT rowid, fk_product_attribute_combination, fk_price_level, variation_price, variation_price_percentage";
$sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element;
$sql .= " WHERE fk_product_attribute_combination = ".intval($fk_product_attribute_combination);
-
if (!empty($fk_price_level)) {
$sql .= ' AND fk_price_level = '.intval($fk_price_level);
}
- $combination_price_levels = $this->db->getRows($sql);
-
- if (!is_array($combination_price_levels)) {
- return -1;
- }
-
- $result = array();
-
- if (!empty($combination_price_levels)) {
- // For more simple usage set level as array key
- foreach ($combination_price_levels as $k => $row) {
- $productCombinationLevel = new ProductCombinationLevel($this->db);
- $productCombinationLevel->fetchFormObj($row);
- $result[$row->fk_price_level] = $productCombinationLevel;
+ $res = $this->db->query($sql);
+ if ($res) {
+ if ($this->db->num_rows($res) > 0) {
+ while ($obj = $this->db->fetch_object($res)) {
+ $productCombinationLevel = new ProductCombinationLevel($this->db);
+ $productCombinationLevel->fetchFormObj($obj);
+ $result[$obj->fk_price_level] = $productCombinationLevel;
+ }
}
+ } else {
+ return -1;
}
return $result;
}
/**
- * assign vars form an stdclass like sql obj
+ * Assign vars form an stdclass like sql obj
*
* @param int $obj Object resultset
* @return int <0 KO, >0 OK
From 142e9473c5af94978048f70149e097a72b27d307 Mon Sep 17 00:00:00 2001
From: Laurent Destailleur
Date: Sun, 7 Nov 2021 18:28:59 +0100
Subject: [PATCH 069/178] Responsive
---
htdocs/admin/barcode.php | 152 +++++++++++++++++--------------
htdocs/variants/combinations.php | 40 +++++---
2 files changed, 109 insertions(+), 83 deletions(-)
diff --git a/htdocs/admin/barcode.php b/htdocs/admin/barcode.php
index c370c07b73b..2fbfed35536 100644
--- a/htdocs/admin/barcode.php
+++ b/htdocs/admin/barcode.php
@@ -176,6 +176,71 @@ foreach ($dirbarcode as $reldir) {
}
}
+
+
+// Select barcode numbering module
+if ($conf->product->enabled) {
+ print load_fiche_titre($langs->trans("BarCodeNumberManager")." (".$langs->trans("Product").")", '', '');
+
+ print '';
+ print '
';
+ print '';
+ print ''.$langs->trans("Name").' ';
+ print ''.$langs->trans("Description").' ';
+ print ''.$langs->trans("Example").' ';
+ print ''.$langs->trans("Status").' ';
+ print ''.$langs->trans("ShortInfo").' ';
+ print " \n";
+
+ $dirbarcodenum = array_merge(array('/core/modules/barcode/'), $conf->modules_parts['barcode']);
+
+ foreach ($dirbarcodenum as $dirroot) {
+ $dir = dol_buildpath($dirroot, 0);
+
+ $handle = @opendir($dir);
+ if (is_resource($handle)) {
+ while (($file = readdir($handle)) !== false) {
+ if (preg_match('/^mod_barcode_product_.*php$/', $file)) {
+ $file = substr($file, 0, dol_strlen($file) - 4);
+
+ try {
+ dol_include_once($dirroot.$file.'.php');
+ } catch (Exception $e) {
+ dol_syslog($e->getMessage(), LOG_ERR);
+ }
+
+ $modBarCode = new $file();
+
+ print '';
+ print ''.(isset($modBarCode->name) ? $modBarCode->name : $modBarCode->nom)." \n";
+ print $modBarCode->info($langs);
+ print ' ';
+ print ''.$modBarCode->getExample($langs)." \n";
+
+ if (!empty($conf->global->BARCODE_PRODUCT_ADDON_NUM) && $conf->global->BARCODE_PRODUCT_ADDON_NUM == "$file") {
+ print '';
+ print img_picto($langs->trans("Activated"), 'switch_on');
+ print ' ';
+ } else {
+ print '';
+ print img_picto($langs->trans("Disabled"), 'switch_off');
+ print ' ';
+ }
+ print '';
+ $s = $modBarCode->getToolTip($langs, null, -1);
+ print $form->textwithpicto('', $s, 1);
+ print ' ';
+ print " \n";
+ }
+ }
+ closedir($handle);
+ }
+ }
+ print "
\n";
+ print '
';
+}
+
+
/*
* CHOIX ENCODAGE
*/
@@ -189,6 +254,7 @@ if (empty($conf->use_javascript_ajax)) {
print ' ';
}
+print '';
print '
';
print '';
print ''.$langs->trans("Name").' ';
@@ -211,8 +277,9 @@ if ($resql) {
while ($i < $num) {
$obj = $db->fetch_object($resql);
- print ' ';
- print $obj->label;
+ print ' ';
+ print '';
+ print dol_escape_htmltag($obj->label);
print " \n";
print $langs->trans('BarcodeDesc'.$obj->encoding);
//print "L'EAN se compose de 8 caracteres, 7 chiffres plus une cle de controle. ";
@@ -270,6 +337,7 @@ if ($resql) {
}
}
print "
\n";
+print '
';
if (empty($conf->use_javascript_ajax)) {
print $form->buttonsSaveCancel("Save", '');
@@ -287,6 +355,7 @@ print "";
print ' ';
print " ";
+print '';
print '
';
print '';
print ''.$langs->trans("Parameter").' ';
@@ -304,7 +373,9 @@ if (!isset($_SERVER['WINDIR'])) {
$langs->load("errors");
print ''.$langs->trans("ErrorFileNotFound", $conf->global->GENBARCODE_LOCATION).' ';
}
- print ' ';
+ print '';
+ print ' ';
+ print '';
}
// Module products
@@ -313,7 +384,9 @@ if (!empty($conf->product->enabled)) {
print ''.$langs->trans("SetDefaultBarcodeTypeProducts").' ';
print '';
print $formbarcode->selectBarcodeType($conf->global->PRODUIT_DEFAULT_BARCODE_TYPE, "PRODUIT_DEFAULT_BARCODE_TYPE", 1);
- print ' ';
+ print '';
+ print ' ';
+ print '';
}
// Module thirdparty
@@ -322,10 +395,14 @@ if (!empty($conf->societe->enabled)) {
print ''.$langs->trans("SetDefaultBarcodeTypeThirdParties").' ';
print '';
print $formbarcode->selectBarcodeType($conf->global->GENBARCODE_BARCODETYPE_THIRDPARTY, "GENBARCODE_BARCODETYPE_THIRDPARTY", 1);
- print ' ';
+ print '';
+ print ' ';
+ print '';
}
print "
\n";
+print '
';
+
print '';
print ' ';
print "
";
@@ -334,71 +411,6 @@ print ' ';
print ' ';
-
-// Select barcode numbering module
-if ($conf->product->enabled) {
- print load_fiche_titre($langs->trans("BarCodeNumberManager")." (".$langs->trans("Product").")", '', '');
-
- print '';
- print '';
- print ''.$langs->trans("Name").' ';
- print ''.$langs->trans("Description").' ';
- print ''.$langs->trans("Example").' ';
- print ''.$langs->trans("Status").' ';
- print ''.$langs->trans("ShortInfo").' ';
- print " \n";
-
- $dirbarcodenum = array_merge(array('/core/modules/barcode/'), $conf->modules_parts['barcode']);
-
- foreach ($dirbarcodenum as $dirroot) {
- $dir = dol_buildpath($dirroot, 0);
-
- $handle = @opendir($dir);
- if (is_resource($handle)) {
- while (($file = readdir($handle)) !== false) {
- if (preg_match('/^mod_barcode_product_.*php$/', $file)) {
- $file = substr($file, 0, dol_strlen($file) - 4);
-
- try {
- dol_include_once($dirroot.$file.'.php');
- } catch (Exception $e) {
- dol_syslog($e->getMessage(), LOG_ERR);
- }
-
- $modBarCode = new $file();
-
- print '';
- print ''.(isset($modBarCode->name) ? $modBarCode->name : $modBarCode->nom)." \n";
- print $modBarCode->info($langs);
- print ' ';
- print ''.$modBarCode->getExample($langs)." \n";
-
- if (!empty($conf->global->BARCODE_PRODUCT_ADDON_NUM) && $conf->global->BARCODE_PRODUCT_ADDON_NUM == "$file") {
- print '';
- print img_picto($langs->trans("Activated"), 'switch_on');
- print ' ';
- } else {
- print '';
- print img_picto($langs->trans("Disabled"), 'switch_off');
- print ' ';
- }
- print '';
- $s = $modBarCode->getToolTip($langs, null, -1);
- print $form->textwithpicto('', $s, 1);
- print ' ';
- print " \n";
- }
- }
- closedir($handle);
- }
- }
- print "
\n";
-}
-
-//print '';
-
-print " ";
-
// End of page
llxFooter();
$db->close();
diff --git a/htdocs/variants/combinations.php b/htdocs/variants/combinations.php
index d70419060f5..1569fcabb39 100644
--- a/htdocs/variants/combinations.php
+++ b/htdocs/variants/combinations.php
@@ -194,14 +194,11 @@ if (($action == 'add' || $action == 'create') && empty($massaction) && !GETPOST(
$bulkaction = $massaction;
$error = 0;
-
-
$db->begin();
foreach ($toselect as $prodid) {
// need create new of Product to prevent rename dir behavior
$prodstatic = new Product($db);
-
if ($prodstatic->fetch($prodid) < 0) {
continue;
}
@@ -209,33 +206,50 @@ if (($action == 'add' || $action == 'create') && empty($massaction) && !GETPOST(
if ($bulkaction == 'on_sell') {
$prodstatic->status = 1;
$res = $prodstatic->update($prodstatic->id, $user);
+ if ($res <= 0) {
+ setEventMessages($prodstatic->error, $prodstatic->errors, 'errors');
+ $error++;
+ break;
+ }
} elseif ($bulkaction == 'on_buy') {
$prodstatic->status_buy = 1;
$res = $prodstatic->update($prodstatic->id, $user);
+ if ($res <= 0) {
+ setEventMessages($prodstatic->error, $prodstatic->errors, 'errors');
+ $error++;
+ break;
+ }
} elseif ($bulkaction == 'not_sell') {
$prodstatic->status = 0;
$res = $prodstatic->update($prodstatic->id, $user);
+ if ($res <= 0) {
+ setEventMessages($prodstatic->error, $prodstatic->errors, 'errors');
+ $error++;
+ break;
+ }
} elseif ($bulkaction == 'not_buy') {
$prodstatic->status_buy = 0;
$res = $prodstatic->update($prodstatic->id, $user);
+ if ($res <= 0) {
+ setEventMessages($prodstatic->error, $prodstatic->errors, 'errors');
+ $error++;
+ break;
+ }
} elseif ($bulkaction == 'delete') {
$res = $prodstatic->delete($user, $prodstatic->id);
+ if ($res <= 0) {
+ setEventMessages($prodstatic->error, $prodstatic->errors, 'errors');
+ $error++;
+ break;
+ }
} else {
break;
}
-
- if ($res <= 0) {
- $error++;
- break;
- }
}
if ($error) {
$db->rollback();
-
- if ($prodstatic->error) {
- setEventMessages($prodstatic->error, $prodstatic->errors, 'errors');
- } else {
+ if (empty($prodstatic->error)) {
setEventMessages($langs->trans('CoreErrorMessage'), null, 'errors');
}
} else {
@@ -834,7 +848,7 @@ if (!empty($id) || !empty($ref)) {
$aaa .= ' '.$langs->trans('ProductStatusOnSell').' ';
$aaa .= ' '.$langs->trans('Delete').' ';
$aaa .= '';
- $aaa .= ' ';
+ $aaa .= ' ';
}
$massactionbutton = $aaa;
From 9fd57279855a097354c80ea58ca73800c657e722 Mon Sep 17 00:00:00 2001
From: Laurent Destailleur
Date: Sun, 7 Nov 2021 18:47:27 +0100
Subject: [PATCH 070/178] Try to fix some regressions
---
htdocs/accountancy/customer/list.php | 13 ++++++++-----
htdocs/accountancy/supplier/list.php | 21 +++++++++++++--------
2 files changed, 21 insertions(+), 13 deletions(-)
diff --git a/htdocs/accountancy/customer/list.php b/htdocs/accountancy/customer/list.php
index abf5a8d4c2e..c07f4854b84 100644
--- a/htdocs/accountancy/customer/list.php
+++ b/htdocs/accountancy/customer/list.php
@@ -413,6 +413,9 @@ if ($result) {
if ($search_ref) {
$param .= '&search_ref='.urlencode($search_ref);
}
+ if ($search_label) {
+ $param .= '&search_label='.urlencode($search_label);
+ }
if ($search_desc) {
$param .= '&search_desc='.urlencode($search_desc);
}
@@ -491,7 +494,7 @@ if ($result) {
$searchpicto = $form->showFilterButtons();
print $searchpicto;
print ' ';
- print '';
+ print "\n";
print '';
print_liste_field_titre("LineId", $_SERVER["PHP_SELF"], "l.rowid", "", $param, '', $sortfield, $sortorder);
@@ -539,7 +542,7 @@ if ($result) {
$thirdpartystatic->email = $objp->email;
$thirdpartystatic->country_code = $objp->country_code;
$thirdpartystatic->tva_intra = $objp->tva_intra;
- $thirdpartystatic->code_compta = $objp->company_code_sell;
+ $thirdpartystatic->code_compta_company = $objp->company_code_sell;
$product_static->ref = $objp->product_ref;
$product_static->id = $objp->product_id;
@@ -558,7 +561,7 @@ if ($result) {
$facture_static->ref = $objp->ref;
$facture_static->id = $objp->facid;
$facture_static->type = $objp->ftype;
- $facture_static->date = $objp->datef;
+ $facture_static->date = $db->jdate($objp->datef);
$facture_static_det->id = $objp->rowid;
$facture_static_det->total_ht = $objp->total_ht;
@@ -634,7 +637,7 @@ if ($result) {
// Ref Invoice
print ''.$facture_static->getNomUrl(1).' ';
- print ''.dol_print_date($db->jdate($facture_static->date), 'day').' ';
+ print ''.dol_print_date($facture_static->date, 'day').' ';
// Ref Product
print '';
@@ -728,7 +731,7 @@ if ($result) {
// Column with checkbox
print ' ';
- if (!empty($suggestedid) && $suggestedaccountingaccountfor<>'') {
+ if (!empty($suggestedid) && $suggestedaccountingaccountfor <> '') {
$ischecked=1;
} elseif ($suggestedaccountingaccountfor == 'eecwithoutvatnumber') {
$ischecked = 0;
diff --git a/htdocs/accountancy/supplier/list.php b/htdocs/accountancy/supplier/list.php
index 20230c7cfad..b7e914c381a 100644
--- a/htdocs/accountancy/supplier/list.php
+++ b/htdocs/accountancy/supplier/list.php
@@ -291,7 +291,7 @@ if (strlen(trim($search_ref))) {
$sql .= natural_search("p.ref", $search_ref);
}
if (strlen(trim($search_label))) {
- $sql .= natural_search("f.libelle", $search_label);
+ $sql .= natural_search(array("p.label", "f.libelle"), $search_label);
}
if (strlen(trim($search_desc))) {
$sql .= natural_search("l.description", $search_desc);
@@ -546,7 +546,7 @@ if ($result) {
$thirdpartystatic->email = $objp->email;
$thirdpartystatic->country_code = $objp->country_code;
$thirdpartystatic->tva_intra = $objp->tva_intra;
- $thirdpartystatic->code_compta_fournisseur = $objp->company_code_buy;
+ $thirdpartystatic->code_compta_company = $objp->company_code_buy;
$product_static->ref = $objp->product_ref;
$product_static->id = $objp->product_id;
@@ -566,10 +566,11 @@ if ($result) {
$facturefourn_static->id = $objp->facid;
$facturefourn_static->type = $objp->ftype;
$facturefourn_static->label = $objp->invoice_label;
+ $facturefourn_static->date = $db->jdate($objp->datef);
$facturefourn_static_det->id = $objp->rowid;
$facturefourn_static_det->total_ht = $objp->total_ht;
- $facturefourn_static_det->tva_tx_line = $objp->tva_tx_line;
+ $facturefourn_static_det->tva_tx = $objp->tva_tx_line;
$facturefourn_static_det->vat_src_code = $objp->vat_src_code;
$facturefourn_static_det->product_type = $objp->type_l;
$facturefourn_static_det->desc = $objp->description;
@@ -608,6 +609,9 @@ if ($result) {
if (empty($code_buy_l) && empty($code_buy_p)) {
$code_buy_p_notset = 'color:red';
}
+ /*if ($suggestedaccountingaccountfor == 'eecwithoutvatnumber' && empty($code_sell_p_notset)) {
+ $code_sell_p_notset = 'color:orange';
+ }*/
// $code_buy_l is now default code of product/service
// $code_buy_p is now code of product/service
@@ -626,15 +630,15 @@ if ($result) {
print ' ';
*/
- print ''.dol_print_date($db->jdate($facturefourn_static_det->datef), 'day').' ';
+ print ''.dol_print_date($facturefourn_static->date, 'day').' ';
// Ref Product
print '';
if ($product_static->id > 0) {
print $product_static->getNomUrl(1);
}
- if ($product_static->product_label) {
- print ''.$product_static->product_label.' ';
+ if ($product_static->label) {
+ print ''.$product_static->label.' ';
}
print ' ';
@@ -650,11 +654,12 @@ if ($result) {
print '';
// Vat rate
+ $code_vat_differ='';
if ($objp->vat_tx_l != $objp->vat_tx_p && ! empty($objp->vat_tx_l)) { // Note: having a vat rate of 0 is often the normal case when sells is intra b2b or to export
$code_vat_differ = 'font-weight:bold; text-decoration:blink; color:red';
}
print '';
- print vatrate($facturefourn_static_det->tva_tx_line.($facturefourn_static_det->vat_src_code ? ' ('.$facturefourn_static_det->vat_src_code.')' : ''));
+ print vatrate($facturefourn_static_det->tva_tx.($facturefourn_static_det->vat_src_code ? ' ('.$facturefourn_static_det->vat_src_code.')' : ''));
print ' ';
// Thirdparty
@@ -671,7 +676,7 @@ if ($result) {
// Found accounts
print '';
- $s = '1. '.(($facturefourn_static_det->type_l == 1) ? $langs->trans("DefaultForService") : $langs->trans("DefaultForProduct")).': ';
+ $s = '1. '.(($facturefourn_static_det->product_type == 1) ? $langs->trans("DefaultForService") : $langs->trans("DefaultForProduct")).': ';
$shelp = '';
if ($suggestedaccountingaccountbydefaultfor == 'eec') {
$shelp .= $langs->trans("SaleEEC");
From 47451432a743abe22270c6d803f38b4673c8dfef Mon Sep 17 00:00:00 2001
From: Laurent Destailleur
Date: Sun, 7 Nov 2021 18:49:58 +0100
Subject: [PATCH 071/178] Fix warning
---
htdocs/admin/defaultvalues.php | 21 ++++++---------------
1 file changed, 6 insertions(+), 15 deletions(-)
diff --git a/htdocs/admin/defaultvalues.php b/htdocs/admin/defaultvalues.php
index 026a4315c83..9c80b1f7fa8 100644
--- a/htdocs/admin/defaultvalues.php
+++ b/htdocs/admin/defaultvalues.php
@@ -350,17 +350,15 @@ if (empty($conf->global->MAIN_ENABLE_DEFAULT_VALUES)) {
$disabled = ' disabled="disabled"';
}
print ' ';
-print " \n";
-print ' ';
+print ''."\n";
+print ''."\n";
-$result=$object->fetchAll($sortorder, $sortfield, 0, 0, array('t.type'=>$mode,'t.entity'=>array($user->entity,$conf->entity)));
+$result = $object->fetchAll($sortorder, $sortfield, 0, 0, array('t.type'=>$mode,'t.entity'=>array($user->entity,$conf->entity)));
-if (!is_array($result) && $result<0) {
+if (!is_array($result) && $result < 0) {
setEventMessages($object->error, $object->errors, 'errors');
-} elseif (count($result)>0) {
- foreach ($result as $key=>$defaultvalue) {
- print "\n";
-
+} elseif (is_array($result) && count($result) > 0) {
+ foreach ($result as $key => $defaultvalue) {
print '';
// Page
@@ -378,11 +376,6 @@ if (!is_array($result) && $result<0) {
// Value
if ($mode != 'focus' && $mode != 'mandatory') {
print '';
- /*print ' ';
- print ' ';
- print ' ';
- print ' ';
- */
if ($action != 'edit' || GETPOST('rowid') != $defaultvalue->id) print dol_escape_htmltag($defaultvalue->value);
else print ' ';
print ' ';
@@ -405,8 +398,6 @@ if (!is_array($result) && $result<0) {
print '';
print " \n";
- print "\n";
- $i++;
}
}
From 5085db36a7e6fba0d8a2f6dbce9fee0f501eb704 Mon Sep 17 00:00:00 2001
From: Laurent Destailleur
Date: Sun, 7 Nov 2021 18:54:59 +0100
Subject: [PATCH 072/178] Clean code
---
.../accountancy/class/accountancyexport.class.php | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
diff --git a/htdocs/accountancy/class/accountancyexport.class.php b/htdocs/accountancy/class/accountancyexport.class.php
index 2c4dbfd51cd..07d28b7abdb 100644
--- a/htdocs/accountancy/class/accountancyexport.class.php
+++ b/htdocs/accountancy/class/accountancyexport.class.php
@@ -87,11 +87,11 @@ class AccountancyExport
*
* @param DoliDb $db Database handler
*/
- public function __construct(DoliDB &$db)
+ public function __construct(DoliDB $db)
{
global $conf;
- $this->db = &$db;
+ $this->db = $db;
$this->separator = $conf->global->ACCOUNTING_EXPORT_SEPARATORCSV;
$this->end_line = empty($conf->global->ACCOUNTING_EXPORT_ENDLINE) ? "\n" : ($conf->global->ACCOUNTING_EXPORT_ENDLINE == 1 ? "\n" : "\r\n");
}
@@ -928,17 +928,18 @@ class AccountancyExport
$date_validation = dol_print_date($line->date_validation, '%Y%m%d');
$date_limit_payment = dol_print_date($line->date_lim_reglement, '%Y%m%d');
+ $refInvoice = '';
if ($line->doc_type == 'customer_invoice') {
// Customer invoice
require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
- $invoice = new Facture($db);
+ $invoice = new Facture($this->db);
$invoice->fetch($line->fk_doc);
$refInvoice = $invoice->ref;
} elseif ($line->doc_type == 'supplier_invoice') {
// Supplier invoice
require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
- $invoice = new FactureFournisseur($db);
+ $invoice = new FactureFournisseur($this->db);
$invoice->fetch($line->fk_doc);
$refInvoice = $invoice->ref_supplier;
@@ -1054,17 +1055,18 @@ class AccountancyExport
$date_validation = dol_print_date($line->date_validation, '%Y%m%d');
$date_limit_payment = dol_print_date($line->date_lim_reglement, '%Y%m%d');
+ $refInvoice = '';
if ($line->doc_type == 'customer_invoice') {
// Customer invoice
require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
- $invoice = new Facture($db);
+ $invoice = new Facture($this->db);
$invoice->fetch($line->fk_doc);
$refInvoice = $invoice->ref;
} elseif ($line->doc_type == 'supplier_invoice') {
// Supplier invoice
require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
- $invoice = new FactureFournisseur($db);
+ $invoice = new FactureFournisseur($this->db);
$invoice->fetch($line->fk_doc);
$refInvoice = $invoice->ref_supplier;
From 1d09ffa4c6f7cd63292ccd636e26718c268c263b Mon Sep 17 00:00:00 2001
From: Laurent Destailleur
Date: Sun, 7 Nov 2021 18:59:11 +0100
Subject: [PATCH 073/178] Fix scrutinizer
---
htdocs/admin/hrm.php | 10 ++++++----
htdocs/admin/mails.php | 7 +++++--
2 files changed, 11 insertions(+), 6 deletions(-)
diff --git a/htdocs/admin/hrm.php b/htdocs/admin/hrm.php
index 8eb2f93c13c..c006688fca1 100644
--- a/htdocs/admin/hrm.php
+++ b/htdocs/admin/hrm.php
@@ -79,10 +79,12 @@ if ($action == 'update') {
if (!empty($max_rank)) {
$static_skill = new Skill($db);
$TAllSkills = $static_skill->fetchAll();
- foreach ($TAllSkills as &$skill) {
- if (empty($skill->lines)) $skill->fetchLines();
- if (count($skill->lines) < $conf->global->HRM_MAXRANK) {
- $skill->createSkills(count($skill->lines) + 1);
+ if (is_array($TAllSkills)) {
+ foreach ($TAllSkills as &$skill) {
+ if (empty($skill->lines)) $skill->fetchLines();
+ if (count($skill->lines) < $conf->global->HRM_MAXRANK) {
+ $skill->createSkills(count($skill->lines) + 1);
+ }
}
}
}
diff --git a/htdocs/admin/mails.php b/htdocs/admin/mails.php
index 90036b752b0..d60b4e4ddc6 100644
--- a/htdocs/admin/mails.php
+++ b/htdocs/admin/mails.php
@@ -851,8 +851,11 @@ if ($action == 'edit') {
$companyemail = getDolGlobalString('MAIN_INFO_SOCIETE_MAIL');
$dnsinfo = false;
if (!empty($companyemail) && function_exists('dns_get_record')) {
- $domain = array_pop(explode('@', $companyemail));
- $dnsinfo = dns_get_record($domain, DNS_TXT);
+ $arrayofemailparts = explode('@', $companyemail);
+ if (count($arrayofemailparts) == 2) {
+ $domain = $arrayofemailparts[1];
+ $dnsinfo = dns_get_record($domain, DNS_TXT);
+ }
}
if (!empty($dnsinfo) && is_array($dnsinfo)) {
foreach ($dnsinfo as $info) {
From 29bf662cc4431c1c2503bcfcb5526fd7f7332b57 Mon Sep 17 00:00:00 2001
From: Laurent Destailleur
Date: Sun, 7 Nov 2021 19:01:44 +0100
Subject: [PATCH 074/178] Fix warnings
---
htdocs/adherents/class/adherent_type.class.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/htdocs/adherents/class/adherent_type.class.php b/htdocs/adherents/class/adherent_type.class.php
index 90b34e604be..cdf021cfa68 100644
--- a/htdocs/adherents/class/adherent_type.class.php
+++ b/htdocs/adherents/class/adherent_type.class.php
@@ -90,7 +90,7 @@ class AdherentType extends CommonObject
public $subscription;
/**
- * @var float amount for subscription
+ * @var float|string Amount for subscription (null or '' means not defined)
*/
public $amount;
From c3fb8416a58e0d0327c658541ec0b4932731029b Mon Sep 17 00:00:00 2001
From: Laurent Destailleur
Date: Sun, 7 Nov 2021 20:40:02 +0100
Subject: [PATCH 075/178] reponsive
---
htdocs/contrat/list.php | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/htdocs/contrat/list.php b/htdocs/contrat/list.php
index cee0faf95aa..ca544e94a1b 100644
--- a/htdocs/contrat/list.php
+++ b/htdocs/contrat/list.php
@@ -492,7 +492,7 @@ $massactionbutton = $form->selectMassAction('', $arrayofmassactions);
$url = DOL_URL_ROOT.'/contrat/card.php?action=create';
if (!empty($socid)) {
- $url .= '&socid='.$socid;
+ $url .= '&socid='.((int) $socid);
}
$newcardbutton = dolGetButtonTitle($langs->trans('NewContractSubscription'), '', 'fa fa-plus-circle', $url, '', $user->rights->contrat->creer);
@@ -795,11 +795,12 @@ while ($i < min($num, $limit)) {
print '';
}
+ // Ref thirdparty
if (!empty($arrayfields['c.ref_customer']['checked'])) {
- print ''.$contracttmp->getFormatedCustomerRef($obj->ref_customer).' ';
+ print ''.$contracttmp->getFormatedCustomerRef($obj->ref_customer).' ';
}
if (!empty($arrayfields['c.ref_supplier']['checked'])) {
- print ''.$obj->ref_supplier.' ';
+ print ''.dol_escape_htmltag($obj->ref_supplier).' ';
}
if (!empty($arrayfields['s.nom']['checked'])) {
print '';
@@ -810,7 +811,7 @@ while ($i < min($num, $limit)) {
print ' ';
}
if (!empty($arrayfields['s.email']['checked'])) {
- print ''.$obj->email.' ';
+ print ''.dol_print_email($obj->email).' ';
}
// Town
if (!empty($arrayfields['s.town']['checked'])) {
From a386d637b3cd5c062187a9910be580abd020eb9f Mon Sep 17 00:00:00 2001
From: Laurent Destailleur
Date: Sun, 7 Nov 2021 20:43:04 +0100
Subject: [PATCH 076/178] Clean code
---
htdocs/contrat/list.php | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/htdocs/contrat/list.php b/htdocs/contrat/list.php
index ca544e94a1b..110afee0cd5 100644
--- a/htdocs/contrat/list.php
+++ b/htdocs/contrat/list.php
@@ -319,7 +319,7 @@ if ($sall) {
}
if ($search_user > 0) {
$sql .= " AND ec.fk_c_type_contact = tc.rowid AND tc.element='contrat' AND tc.source='internal' AND ec.element_id = c.rowid AND ec.fk_socpeople = ".((int) $search_user);
-}
+}tdoverflowmax200
// Add where from extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
// Add where from hooks
@@ -600,11 +600,11 @@ if (!empty($arrayfields['s.email']['checked'])) {
}
// Town
if (!empty($arrayfields['s.town']['checked'])) {
- print ' ';
+ print ' ';
}
// Zip
if (!empty($arrayfields['s.zip']['checked'])) {
- print ' ';
+ print ' ';
}
// State
if (!empty($arrayfields['state.nom']['checked'])) {
@@ -797,7 +797,7 @@ while ($i < min($num, $limit)) {
// Ref thirdparty
if (!empty($arrayfields['c.ref_customer']['checked'])) {
- print ''.$contracttmp->getFormatedCustomerRef($obj->ref_customer).' ';
+ print ''.$contracttmp->getFormatedCustomerRef($obj->ref_customer).' ';
}
if (!empty($arrayfields['c.ref_supplier']['checked'])) {
print ''.dol_escape_htmltag($obj->ref_supplier).' ';
From c7cb5213bd321873f9e1eb477c9e09321e6c07e6 Mon Sep 17 00:00:00 2001
From: Laurent Destailleur
Date: Sun, 7 Nov 2021 20:43:26 +0100
Subject: [PATCH 077/178] Clean code
---
htdocs/contrat/list.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/htdocs/contrat/list.php b/htdocs/contrat/list.php
index 110afee0cd5..0cfa0b2bf16 100644
--- a/htdocs/contrat/list.php
+++ b/htdocs/contrat/list.php
@@ -319,7 +319,7 @@ if ($sall) {
}
if ($search_user > 0) {
$sql .= " AND ec.fk_c_type_contact = tc.rowid AND tc.element='contrat' AND tc.source='internal' AND ec.element_id = c.rowid AND ec.fk_socpeople = ".((int) $search_user);
-}tdoverflowmax200
+}
// Add where from extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
// Add where from hooks
From 2fc05a4c1cdd0541e51b90e960d7d23e5501110e Mon Sep 17 00:00:00 2001
From: Laurent Destailleur
Date: Mon, 8 Nov 2021 00:37:42 +0100
Subject: [PATCH 078/178] Add test virus file
---
test/phpunit/testvirus.txt | 1 +
1 file changed, 1 insertion(+)
create mode 100644 test/phpunit/testvirus.txt
diff --git a/test/phpunit/testvirus.txt b/test/phpunit/testvirus.txt
new file mode 100644
index 00000000000..a2463df6d64
--- /dev/null
+++ b/test/phpunit/testvirus.txt
@@ -0,0 +1 @@
+X5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*
\ No newline at end of file
From d591a83085c93346e969054c6967350648d68755 Mon Sep 17 00:00:00 2001
From: Laurent Destailleur
Date: Mon, 8 Nov 2021 00:57:00 +0100
Subject: [PATCH 079/178] css
---
htdocs/admin/tools/dolibarr_import.php | 3 +++
1 file changed, 3 insertions(+)
diff --git a/htdocs/admin/tools/dolibarr_import.php b/htdocs/admin/tools/dolibarr_import.php
index 29bfe5c12a4..77dea6f23ab 100644
--- a/htdocs/admin/tools/dolibarr_import.php
+++ b/htdocs/admin/tools/dolibarr_import.php
@@ -207,6 +207,9 @@ if (in_array($type, array('mysql', 'mysqli'))) {
//if (empty($_GET["showpass"]) && $dolibarr_main_db_pass) print ''.$langs->trans("UnHidePassword").' ';
//else print ''.$langs->trans("HidePassword").' ';
print '