*
* 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
@@ -388,7 +388,7 @@ if ($action == 'new') {
$i = 0;
while ($obj = $db->fetch_object($resql)) {
$accounts[$obj->bid] = $obj->label;
- $lines[$obj->bid][$i]["date"] = $db->jdate($obj->date);
+ $lines[$obj->bid][$i]["date"] = $db->jdate($obj->datec);
$lines[$obj->bid][$i]["amount"] = $obj->amount;
$lines[$obj->bid][$i]["emetteur"] = $obj->emetteur;
$lines[$obj->bid][$i]["numero"] = $obj->num_chq;
@@ -398,6 +398,7 @@ if ($action == 'new') {
$lines[$obj->bid][$i]["label"] = $obj->transactionlabel;
$lines[$obj->bid][$i]["paymentid"] = $obj->paymentid;
$lines[$obj->bid][$i]["paymentref"] = $obj->paymentref;
+ $lines[$obj->bid][$i]["paymentdate"] = $db->jdate($obj->date);
$i++;
}
@@ -468,6 +469,7 @@ if ($action == 'new') {
print '';
$paymentstatic->id = $value["paymentid"];
$paymentstatic->ref = $value["paymentref"];
+ $paymentstatic->date = $value["paymentdate"];
if ($paymentstatic->id) {
print $paymentstatic->getNomUrl(1);
} else {
diff --git a/htdocs/contact/ldap.php b/htdocs/contact/ldap.php
index 8babb849e7e..d29aab0386b 100644
--- a/htdocs/contact/ldap.php
+++ b/htdocs/contact/ldap.php
@@ -182,7 +182,6 @@ if ($result > 0) {
}
$ldap->unbind();
- $ldap->close();
} else {
setEventMessages($ldap->error, $ldap->errors, 'errors');
}
diff --git a/htdocs/contact/list.php b/htdocs/contact/list.php
index 82a2161f89f..82c26b559d2 100644
--- a/htdocs/contact/list.php
+++ b/htdocs/contact/list.php
@@ -1031,6 +1031,7 @@ print "\n";
$i = 0;
$totalarray = array();
+$totalarray['nbfield'] = 0;
while ($i < min($num, $limit)) {
$obj = $db->fetch_object($resql);
diff --git a/htdocs/core/class/html.formprojet.class.php b/htdocs/core/class/html.formprojet.class.php
index 34ea7b0a2e8..022bf55f243 100644
--- a/htdocs/core/class/html.formprojet.class.php
+++ b/htdocs/core/class/html.formprojet.class.php
@@ -514,7 +514,17 @@ class FormProjets
}
$linkedtothirdparty = false;
- if (!in_array($table_element, array('don', 'expensereport_det', 'expensereport', 'loan', 'stock_mouvement', 'payment_salary', 'payment_various', 'chargesociales', 'entrepot'))) {
+ if (!in_array($table_element, array(
+ 'don',
+ 'expensereport_det',
+ 'expensereport', 'loan',
+ 'stock_mouvement',
+ 'payment_salary',
+ 'payment_various',
+ 'salary',
+ 'chargesociales',
+ 'entrepot')
+ )) {
$linkedtothirdparty = true;
}
diff --git a/htdocs/core/class/html.formpropal.class.php b/htdocs/core/class/html.formpropal.class.php
index b78ff5cfa8e..2773ece2569 100644
--- a/htdocs/core/class/html.formpropal.class.php
+++ b/htdocs/core/class/html.formpropal.class.php
@@ -104,6 +104,7 @@ class FormPropal
print '';
}
+ $i = 0;
foreach ($listofstatus as $key => $obj) {
if ($excludedraft) {
if ($obj['code'] == 'Draft' || $obj['code'] == 'PR_DRAFT') {
diff --git a/htdocs/core/class/html.formticket.class.php b/htdocs/core/class/html.formticket.class.php
index b9f320b7db8..7e2154ee309 100644
--- a/htdocs/core/class/html.formticket.class.php
+++ b/htdocs/core/class/html.formticket.class.php
@@ -1,17 +1,18 @@
- * Copyright (C) 2016 Christophe Battarel
- * Copyright (C) 2019 Frédéric France
- * Copyright (C) 2021 Juanjo Menent
+/* Copyright (C) 2013-2015 Jean-François FERRY
+ * Copyright (C) 2016 Christophe Battarel
+ * Copyright (C) 2019 Frédéric France
+ * Copyright (C) 2021 Juanjo Menent
+ * Copyright (C) 2021 Alexandre Spangaro
*
* 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 2 of the License, or
+ * 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
+ * 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
@@ -508,11 +509,13 @@ class FormTicket
print '';
}
- if (!empty($conf->projet->enabled) && !$this->ispublic) {
- $formproject = new FormProjets($this->db);
- print ' | ';
- print img_picto('', 'project').$formproject->select_projects(-1, GETPOST('projectid', 'int'), 'projectid', 0, 0, 1, 1, 0, 0, 0, '', 1, 0, 'maxwidth500');
- print ' | ';
+ if ($subelement != 'project') {
+ if (!empty($conf->projet->enabled) && !$this->ispublic) {
+ $formproject = new FormProjets($this->db);
+ print ' | ';
+ print img_picto('', 'project').$formproject->select_projects(-1, GETPOST('projectid', 'int'), 'projectid', 0, 0, 1, 1, 0, 0, 0, '', 1, 0, 'maxwidth500');
+ print ' | ';
+ }
}
// Other attributes
diff --git a/htdocs/core/class/ldap.class.php b/htdocs/core/class/ldap.class.php
index e2ce33cc45f..07e9ba4f2b7 100644
--- a/htdocs/core/class/ldap.class.php
+++ b/htdocs/core/class/ldap.class.php
@@ -1,8 +1,8 @@
* Copyright (C) 2004 Benoit Mortier
- * Copyright (C) 2005-2017 Regis Houssin
- * Copyright (C) 2006-2015 Laurent Destailleur
+ * Copyright (C) 2005-2021 Regis Houssin
+ * Copyright (C) 2006-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
@@ -48,6 +48,11 @@ class Ldap
*/
public $server = array();
+ /**
+ * Current connected server
+ */
+ public $connectedServer;
+
/**
* Base DN (e.g. "dc=foo,dc=com")
*/
@@ -132,35 +137,33 @@ class Ldap
if (!empty($conf->global->LDAP_SERVER_HOST_SLAVE)) {
$this->server[] = $conf->global->LDAP_SERVER_HOST_SLAVE;
}
- $this->serverPort = $conf->global->LDAP_SERVER_PORT;
- $this->ldapProtocolVersion = $conf->global->LDAP_SERVER_PROTOCOLVERSION;
- $this->dn = $conf->global->LDAP_SERVER_DN;
- $this->serverType = $conf->global->LDAP_SERVER_TYPE;
+ $this->serverPort = getDolGlobalInt('LDAP_SERVER_PORT', 389);
+ $this->ldapProtocolVersion = getDolGlobalString('LDAP_SERVER_PROTOCOLVERSION');
+ $this->dn = getDolGlobalString('LDAP_SERVER_DN');
+ $this->serverType = getDolGlobalString('LDAP_SERVER_TYPE');
- $this->domain = $conf->global->LDAP_SERVER_DN;
- $this->searchUser = $conf->global->LDAP_ADMIN_DN;
- $this->searchPassword = $conf->global->LDAP_ADMIN_PASS;
- $this->people = $conf->global->LDAP_USER_DN;
- $this->groups = $conf->global->LDAP_GROUP_DN;
+ $this->domain = getDolGlobalString('LDAP_SERVER_DN');
+ $this->searchUser = getDolGlobalString('LDAP_ADMIN_DN');
+ $this->searchPassword = getDolGlobalString('LDAP_ADMIN_PASS');
+ $this->people = getDolGlobalString('LDAP_USER_DN');
+ $this->groups = getDolGlobalString('LDAP_GROUP_DN');
- $this->filter = $conf->global->LDAP_FILTER_CONNECTION; // Filter on user
- $this->filtergroup = $conf->global->LDAP_GROUP_FILTER; // Filter on groups
- $this->filtermember = $conf->global->LDAP_MEMBER_FILTER; // Filter on member
+ $this->filter = getDolGlobalString('LDAP_FILTER_CONNECTION'); // Filter on user
+ $this->filtergroup = getDolGlobalString('LDAP_GROUP_FILTER'); // Filter on groups
+ $this->filtermember = getDolGlobalString('LDAP_MEMBER_FILTER'); // Filter on member
// Users
- $this->attr_login = $conf->global->LDAP_FIELD_LOGIN; //unix
- $this->attr_sambalogin = $conf->global->LDAP_FIELD_LOGIN_SAMBA; //samba, activedirectory
- $this->attr_name = $conf->global->LDAP_FIELD_NAME;
- $this->attr_firstname = $conf->global->LDAP_FIELD_FIRSTNAME;
- $this->attr_mail = $conf->global->LDAP_FIELD_MAIL;
- $this->attr_phone = $conf->global->LDAP_FIELD_PHONE;
- $this->attr_skype = $conf->global->LDAP_FIELD_SKYPE;
- $this->attr_fax = $conf->global->LDAP_FIELD_FAX;
- $this->attr_mobile = $conf->global->LDAP_FIELD_MOBILE;
+ $this->attr_login = getDolGlobalString('LDAP_FIELD_LOGIN'); //unix
+ $this->attr_sambalogin = getDolGlobalString('LDAP_FIELD_LOGIN_SAMBA'); //samba, activedirectory
+ $this->attr_name = getDolGlobalString('LDAP_FIELD_NAME');
+ $this->attr_firstname = getDolGlobalString('LDAP_FIELD_FIRSTNAME');
+ $this->attr_mail = getDolGlobalString('LDAP_FIELD_MAIL');
+ $this->attr_phone = getDolGlobalString('LDAP_FIELD_PHONE');
+ $this->attr_skype = getDolGlobalString('LDAP_FIELD_SKYPE');
+ $this->attr_fax = getDolGlobalString('LDAP_FIELD_FAX');
+ $this->attr_mobile = getDolGlobalString('LDAP_FIELD_MOBILE');
}
-
-
// Connection handling methods -------------------------------------------
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
@@ -288,16 +291,18 @@ class Ldap
$return = -1;
dol_syslog(get_class($this)."::connect_bind return=".$return.' - '.$this->error, LOG_WARNING);
}
+ $this->connectedServer = $host;
return $return;
}
-
/**
- * Simply closes the connection set up earlier.
- * Returns true if OK, false if there was an error.
+ * Simply closes the connection set up earlier. Returns true if OK, false if there was an error.
+ * This method seems a duplicate/alias of unbind().
*
* @return boolean true or false
+ * @deprecated ldap_close is an alias of ldap_unbind
+ * @see unbind()
*/
public function close()
{
@@ -349,16 +354,21 @@ class Ldap
}
/**
- * Unbind du serveur ldap.
+ * Unbind of LDAP server (close connection).
*
* @return boolean true or false
+ * @see close()
*/
public function unbind()
{
- if (!$this->result = @ldap_unbind($this->connection)) {
- return false;
- } else {
+ $this->result = true;
+ if ($this->connection) {
+ $this->result = @ldap_unbind($this->connection);
+ }
+ if ($this->result) {
return true;
+ } else {
+ return false;
}
}
@@ -411,7 +421,7 @@ class Ldap
*/
public function add($dn, $info, $user)
{
- dol_syslog(get_class($this)."::add dn=".$dn." info=".join(',', $info));
+ dol_syslog(get_class($this)."::add dn=".$dn." info=".json_encode($info));
// Check parameters
if (!$this->connection) {
diff --git a/htdocs/core/db/DoliDB.class.php b/htdocs/core/db/DoliDB.class.php
index 29ced10dc35..a30fa5f4f7e 100644
--- a/htdocs/core/db/DoliDB.class.php
+++ b/htdocs/core/db/DoliDB.class.php
@@ -318,14 +318,14 @@ abstract class DoliDB implements Database
/**
* Return first result from query as object
* 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
- * @deprecated
+ * Dont add LIMIT to your query, it will be added by this method.
+ *
+ * @param string $sql The sql query string
+ * @return bool|object Result of fetch_object
*/
public function getRow($sql)
{
- $sql .= ' LIMIT 1;';
+ $sql .= ' LIMIT 1';
$res = $this->query($sql);
if ($res) {
@@ -338,9 +338,10 @@ abstract class DoliDB implements Database
/**
* return all results from query as an array of objects
* Note : This method executes a given SQL query and retrieves all row of results as an array of objects. It should only be used with SELECT queries
- * be carefull with this method use it only with some limit of results to avoid performences loss
- * @param string $sql the sql query string
- * @return bool| array
+ * be carefull with this method use it only with some limit of results to avoid performences loss.
+ *
+ * @param string $sql The sql query string
+ * @return bool|array Result
* @deprecated
*/
public function getRows($sql)
diff --git a/htdocs/core/extrafieldsinexport.inc.php b/htdocs/core/extrafieldsinexport.inc.php
index 70dd0077e57..fc2210eabd8 100644
--- a/htdocs/core/extrafieldsinexport.inc.php
+++ b/htdocs/core/extrafieldsinexport.inc.php
@@ -48,7 +48,7 @@ if ($resql) { // This can fail when class is used on old database (during mig
case 'sellist':
$tmp = '';
$tmpparam = jsonOrUnserialize($obj->param); // $tmp may be array 'options' => array 'c_currencies:code_iso:code_iso' => null
- if ($tmpparam['options'] && is_array($tmpparam['options'])) {
+ if (is_array($tmpparam) && array_key_exists('options', $tmpparam) && $tmpparam['options'] && is_array($tmpparam['options'])) {
$tmpkeys = array_keys($tmpparam['options']);
$tmp = array_shift($tmpkeys);
}
diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php
index 1c533f0e686..408a771e1ed 100644
--- a/htdocs/core/lib/functions.lib.php
+++ b/htdocs/core/lib/functions.lib.php
@@ -2293,6 +2293,11 @@ function dol_print_date($time, $format = '', $tzoutput = 'auto', $outputlangs =
{
global $conf, $langs;
+ // If date undefined or "", we return ""
+ if (dol_strlen($time) == 0) {
+ return ''; // $time=0 allowed (it means 01/01/1970 00:00:00)
+ }
+
if ($tzoutput === 'auto') {
$tzoutput = (empty($conf) ? 'tzserver' : (isset($conf->tzuserinputkey) ? $conf->tzuserinputkey : 'tzserver'));
}
@@ -2316,7 +2321,7 @@ function dol_print_date($time, $format = '', $tzoutput = 'auto', $outputlangs =
$user_date_tz = new DateTimeZone($offsettzstring);
$user_dt = new DateTime();
$user_dt->setTimezone($user_date_tz);
- $user_dt->setTimestamp($tzoutput == 'tzuser' ? dol_now() : $time);
+ $user_dt->setTimestamp($tzoutput == 'tzuser' ? dol_now() : (int) $time);
$offsettz = $user_dt->getOffset();
} else { // old method (The 'tzuser' was processed like the 'tzuserrel')
$offsettz = (empty($_SESSION['dol_tz']) ? 0 : $_SESSION['dol_tz']) * 60 * 60; // Will not be used anymore
@@ -2384,11 +2389,6 @@ function dol_print_date($time, $format = '', $tzoutput = 'auto', $outputlangs =
$format = str_replace('yyyy', 'yy', $format);
}
- // If date undefined or "", we return ""
- if (dol_strlen($time) == 0) {
- return ''; // $time=0 allowed (it means 01/01/1970 00:00:00)
- }
-
// Clean format
if (preg_match('/%b/i', $format)) { // There is some text to translate
// We inhibate translation to text made by strftime functions. We will use trans instead later.
@@ -2405,7 +2405,7 @@ function dol_print_date($time, $format = '', $tzoutput = 'auto', $outputlangs =
// Analyze date
$reg = array();
if (preg_match('/^([0-9][0-9][0-9][0-9])([0-9][0-9])([0-9][0-9])([0-9][0-9])([0-9][0-9])([0-9][0-9])$/i', $time, $reg)) { // Deprecated. Ex: 1970-01-01, 1970-01-01 01:00:00, 19700101010000
- dol_print_error("Functions.lib::dol_print_date function called with a bad value from page ".$_SERVER["PHP_SELF"]);
+ dol_print_error('', "Functions.lib::dol_print_date function called with a bad value from page ".$_SERVER["PHP_SELF"]);
return '';
} elseif (preg_match('/^([0-9]+)\-([0-9]+)\-([0-9]+) ?([0-9]+)?:?([0-9]+)?:?([0-9]+)?/i', $time, $reg)) { // Still available to solve problems in extrafields of type date
// This part of code should not be used anymore.
@@ -3674,9 +3674,9 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $
'member'=>'user-alt', 'meeting'=>'chalkboard-teacher', 'mrp'=>'cubes', 'next'=>'arrow-alt-circle-right',
'trip'=>'wallet', 'expensereport'=>'wallet', 'group'=>'users', 'movement'=>'people-carry',
'sign-out'=>'sign-out-alt',
- 'switch_off'=>'toggle-off', 'switch_on'=>'toggle-on', 'switch_on_red'=>'toggle-on', 'check'=>'check', 'bookmark'=>'star', 'bookmark'=>'star',
- 'bank'=>'university', 'close_title'=>'times', 'delete'=>'trash', 'edit'=>'pencil-alt', 'filter'=>'filter',
- 'list-alt'=>'list-alt', 'calendar'=>'calendar-alt', 'calendarmonth'=>'calendar-alt', 'calendarweek'=>'calendar-week', 'calendarmonth'=>'calendar-alt', 'calendarday'=>'calendar-day', 'calendarperuser'=>'table',
+ 'switch_off'=>'toggle-off', 'switch_on'=>'toggle-on', 'switch_on_red'=>'toggle-on', 'check'=>'check', 'bookmark'=>'star',
+ 'bank'=>'university', 'close_title'=>'times', 'delete'=>'trash', 'filter'=>'filter',
+ 'list-alt'=>'list-alt', 'calendar'=>'calendar-alt', 'calendarmonth'=>'calendar-alt', 'calendarweek'=>'calendar-week', 'calendarday'=>'calendar-day', 'calendarperuser'=>'table',
'intervention'=>'ambulance', 'invoice'=>'file-invoice-dollar', 'multicurrency'=>'dollar-sign', 'order'=>'file-invoice',
'error'=>'exclamation-triangle', 'warning'=>'exclamation-triangle',
'other'=>'square',
@@ -3686,7 +3686,7 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $
'resize'=>'crop', 'supplier_order'=>'dol-order_supplier', 'supplier_proposal'=>'file-signature',
'refresh'=>'redo', 'region'=>'map-marked', 'resource'=>'laptop-house',
'state'=>'map-marked-alt', 'security'=>'key', 'salary'=>'wallet', 'shipment'=>'dolly', 'stock'=>'box-open', 'stats' => 'chart-bar', 'split'=>'code-branch', 'stripe'=>'stripe-s',
- 'supplier'=>'building', 'supplier_invoice'=>'file-invoice-dollar', 'technic'=>'cogs', 'ticket'=>'ticket-alt',
+ 'supplier'=>'building', 'technic'=>'cogs',
'timespent'=>'clock', 'title_setup'=>'tools', 'title_accountancy'=>'money-check-alt', 'title_bank'=>'university', 'title_hrm'=>'umbrella-beach',
'title_agenda'=>'calendar-alt',
'uncheck'=>'times', 'uparrow'=>'share', 'vcard'=>'address-card',
@@ -4477,7 +4477,7 @@ function info_admin($text, $infoonimgalt = 0, $nodiv = 0, $admin = '1', $morecss
$result = ($nodiv ? '' : '').' '.$text.($nodiv ? '' : ' ');
if ($textfordropdown) {
- $tmpresult .= ''.$langs->trans($textfordropdown).' '.img_picto($langs->trans($textfordropdown), '1downarrow').'';
+ $tmpresult = ''.$langs->trans($textfordropdown).' '.img_picto($langs->trans($textfordropdown), '1downarrow').'';
$tmpresult .= ' |