From ba4f6c5a6b06c5a9d02b0488c64d5d149707aabe Mon Sep 17 00:00:00 2001 From: "jove@bisquerra.com" Date: Sat, 19 Dec 2020 22:28:16 +0100 Subject: [PATCH 01/23] FIX Open Drawer with new TakePOS connector --- htdocs/takepos/index.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/htdocs/takepos/index.php b/htdocs/takepos/index.php index a2293786924..961168221f6 100644 --- a/htdocs/takepos/index.php +++ b/htdocs/takepos/index.php @@ -686,7 +686,10 @@ function OpenDrawer(){ console.log("OpenDrawer call ajax url http://global->TAKEPOS_PRINT_SERVER; ?>:8111/print"); $.ajax({ type: "POST", - url: 'http://global->TAKEPOS_PRINT_SERVER; ?>:8111/print', + global->TAKEPOS_PRINT_SERVER, FILTER_VALIDATE_URL) == true) echo "url: '".$conf->global->TAKEPOS_PRINT_SERVER."/printer/drawer.php',"; + else echo "url: 'http://".$conf->global->TAKEPOS_PRINT_SERVER.":8111/print',"; + ?> data: "opendrawer" }); } From 16d1bf9b007494f38a2957cc664dc45809e22a60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sun, 20 Dec 2020 10:17:28 +0100 Subject: [PATCH 02/23] fix unknown variable --- htdocs/api/class/api_setup.class.php | 360 ++++++++++++--------------- 1 file changed, 163 insertions(+), 197 deletions(-) diff --git a/htdocs/api/class/api_setup.class.php b/htdocs/api/class/api_setup.class.php index 47ab4686a1d..fbeb2cc931b 100644 --- a/htdocs/api/class/api_setup.class.php +++ b/htdocs/api/class/api_setup.class.php @@ -75,10 +75,8 @@ class Setup extends DolibarrApi $sql .= " FROM ".MAIN_DB_PREFIX."c_input_method as t"; $sql .= " WHERE t.active = ".$active; // Add sql filters - if ($sqlfilters) - { - if (!DolibarrApi::_checkFilters($sqlfilters)) - { + if ($sqlfilters) { + if (!DolibarrApi::_checkFilters($sqlfilters)) { throw new RestException(400, 'error when validating parameter sqlfilters '.$sqlfilters); } $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; @@ -112,70 +110,68 @@ class Setup extends DolibarrApi return $list; } - /** - * Get the list of ordering origins. - * - * @param string $sortfield Sort field - * @param string $sortorder Sort order - * @param int $limit Number of items per page - * @param int $page Page number {@min 0} - * @param int $active Payment type is active or not {@min 0} {@max 1} - * @param string $sqlfilters SQL criteria to filter with. Syntax example "(t.code:=:'OrderByWWW')" - * - * @url GET dictionary/ordering_origins - * - * @return array [List of ordering reasons] - * - * @throws RestException 400 - */ - public function getOrderingOrigins($sortfield = "code", $sortorder = 'ASC', $limit = 100, $page = 0, $active = 1, $sqlfilters = '') - { - $list = array(); + /** + * Get the list of ordering origins. + * + * @param string $sortfield Sort field + * @param string $sortorder Sort order + * @param int $limit Number of items per page + * @param int $page Page number {@min 0} + * @param int $active Payment type is active or not {@min 0} {@max 1} + * @param string $sqlfilters SQL criteria to filter with. Syntax example "(t.code:=:'OrderByWWW')" + * + * @url GET dictionary/ordering_origins + * + * @return array [List of ordering reasons] + * + * @throws RestException 400 + */ + public function getOrderingOrigins($sortfield = "code", $sortorder = 'ASC', $limit = 100, $page = 0, $active = 1, $sqlfilters = '') + { + $list = array(); - if (!DolibarrApiAccess::$user->rights->commande->lire) { - throw new RestException(401); - } + if (!DolibarrApiAccess::$user->rights->commande->lire) { + throw new RestException(401); + } - $sql = "SELECT rowid, code, label, module"; - $sql .= " FROM ".MAIN_DB_PREFIX."c_input_reason as t"; - $sql .= " WHERE t.active = ".$active; - // Add sql filters - if ($sqlfilters) - { - if (!DolibarrApi::_checkFilters($sqlfilters)) - { - throw new RestException(400, 'error when validating parameter sqlfilters '.$sqlfilters); - } - $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; - $sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; - } + $sql = "SELECT rowid, code, label, module"; + $sql .= " FROM ".MAIN_DB_PREFIX."c_input_reason as t"; + $sql .= " WHERE t.active = ".$active; + // Add sql filters + if ($sqlfilters) { + if (!DolibarrApi::_checkFilters($sqlfilters)) { + throw new RestException(400, 'error when validating parameter sqlfilters '.$sqlfilters); + } + $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; + $sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; + } - $sql .= $this->db->order($sortfield, $sortorder); + $sql .= $this->db->order($sortfield, $sortorder); - if ($limit) { - if ($page < 0) { - $page = 0; - } - $offset = $limit * $page; + if ($limit) { + if ($page < 0) { + $page = 0; + } + $offset = $limit * $page; - $sql .= $this->db->plimit($limit, $offset); - } + $sql .= $this->db->plimit($limit, $offset); + } - $result = $this->db->query($sql); + $result = $this->db->query($sql); - if ($result) { - $num = $this->db->num_rows($result); - $min = min($num, ($limit <= 0 ? $num : $limit)); - for ($i = 0; $i < $min; $i++) { - $list[] = $this->db->fetch_object($result); - } - } else { - throw new RestException(400, $this->db->lasterror()); - } + if ($result) { + $num = $this->db->num_rows($result); + $min = min($num, ($limit <= 0 ? $num : $limit)); + for ($i = 0; $i < $min; $i++) { + $list[] = $this->db->fetch_object($result); + } + } else { + throw new RestException(400, $this->db->lasterror()); + } - return $list; - } + return $list; + } /** * Get the list of payments types. @@ -206,10 +202,8 @@ class Setup extends DolibarrApi $sql .= " WHERE t.entity IN (".getEntity('c_paiement').")"; $sql .= " AND t.active = ".$active; // Add sql filters - if ($sqlfilters) - { - if (!DolibarrApi::_checkFilters($sqlfilters)) - { + if ($sqlfilters) { + if (!DolibarrApi::_checkFilters($sqlfilters)) { throw new RestException(400, 'error when validating parameter sqlfilters '.$sqlfilters); } $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; @@ -272,10 +266,8 @@ class Setup extends DolibarrApi $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."c_departements as t"; $sql .= " WHERE 1 = 1"; // Add sql filters - if ($sqlfilters) - { - if (!DolibarrApi::_checkFilters($sqlfilters)) - { + if ($sqlfilters) { + if (!DolibarrApi::_checkFilters($sqlfilters)) { throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); } $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; @@ -374,10 +366,8 @@ class Setup extends DolibarrApi $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."c_country as t"; $sql .= " WHERE 1 = 1"; // Add sql filters - if ($sqlfilters) - { - if (!DolibarrApi::_checkFilters($sqlfilters)) - { + if ($sqlfilters) { + if (!DolibarrApi::_checkFilters($sqlfilters)) { throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); } $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; @@ -551,10 +541,8 @@ class Setup extends DolibarrApi $sql .= " FROM ".MAIN_DB_PREFIX."c_availability as t"; $sql .= " WHERE t.active = ".$active; // Add sql filters - if ($sqlfilters) - { - if (!DolibarrApi::_checkFilters($sqlfilters)) - { + if ($sqlfilters) { + if (!DolibarrApi::_checkFilters($sqlfilters)) { throw new RestException(400, 'error when validating parameter sqlfilters '.$sqlfilters); } $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; @@ -659,10 +647,8 @@ class Setup extends DolibarrApi $sql .= " FROM ".MAIN_DB_PREFIX."c_shipment_mode as t"; $sql .= " WHERE t.active = ".$active; // Add sql filters - if ($sqlfilters) - { - if (!DolibarrApi::_checkFilters($sqlfilters)) - { + if ($sqlfilters) { + if (!DolibarrApi::_checkFilters($sqlfilters)) { throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); } $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; @@ -720,13 +706,15 @@ class Setup extends DolibarrApi $sql = "SELECT id, code, type, libelle as label, module"; $sql .= " FROM ".MAIN_DB_PREFIX."c_actioncomm as t"; $sql .= " WHERE t.active = ".$active; - if ($type) $sql .= " AND t.type LIKE '%".$this->db->escape($type)."%'"; - if ($module) $sql .= " AND t.module LIKE '%".$this->db->escape($module)."%'"; + if ($type) { + $sql .= " AND t.type LIKE '%".$this->db->escape($type)."%'"; + } + if ($module) { + $sql .= " AND t.module LIKE '%".$this->db->escape($module)."%'"; + } // Add sql filters - if ($sqlfilters) - { - if (!DolibarrApi::_checkFilters($sqlfilters)) - { + if ($sqlfilters) { + if (!DolibarrApi::_checkFilters($sqlfilters)) { throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); } $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; @@ -784,12 +772,12 @@ class Setup extends DolibarrApi $sql = "SELECT id, code, label, accountancy_code, active, module, position"; $sql .= " FROM ".MAIN_DB_PREFIX."c_type_fees as t"; $sql .= " WHERE t.active = ".$active; - if ($module) $sql .= " AND t.module LIKE '%".$this->db->escape($module)."%'"; + if ($module) { + $sql .= " AND t.module LIKE '%".$this->db->escape($module)."%'"; + } // Add sql filters - if ($sqlfilters) - { - if (!DolibarrApi::_checkFilters($sqlfilters)) - { + if ($sqlfilters) { + if (!DolibarrApi::_checkFilters($sqlfilters)) { throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); } $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; @@ -848,13 +836,15 @@ class Setup extends DolibarrApi $sql = "SELECT rowid, code, element as type, libelle as label, source, module, position"; $sql .= " FROM ".MAIN_DB_PREFIX."c_type_contact as t"; $sql .= " WHERE t.active = ".$active; - if ($type) $sql .= " AND type LIKE '%".$this->db->escape($type)."%'"; - if ($module) $sql .= " AND t.module LIKE '%".$this->db->escape($module)."%'"; + if ($type) { + $sql .= " AND type LIKE '%".$this->db->escape($type)."%'"; + } + if ($module) { + $sql .= " AND t.module LIKE '%".$this->db->escape($module)."%'"; + } // Add sql filters - if ($sqlfilters) - { - if (!DolibarrApi::_checkFilters($sqlfilters)) - { + if ($sqlfilters) { + if (!DolibarrApi::_checkFilters($sqlfilters)) { throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); } $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; @@ -911,12 +901,12 @@ class Setup extends DolibarrApi $sql = "SELECT rowid, code, label, module"; $sql .= " FROM ".MAIN_DB_PREFIX."c_civility as t"; $sql .= " WHERE t.active = ".$active; - if ($module) $sql .= " AND t.module LIKE '%".$this->db->escape($module)."%'"; + if ($module) { + $sql .= " AND t.module LIKE '%".$this->db->escape($module)."%'"; + } // Add sql filters - if ($sqlfilters) - { - if (!DolibarrApi::_checkFilters($sqlfilters)) - { + if ($sqlfilters) { + if (!DolibarrApi::_checkFilters($sqlfilters)) { throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); } $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; @@ -970,7 +960,9 @@ class Setup extends DolibarrApi { $list = array(); $sql = "SELECT t.code_iso, t.label, t.unicode"; - if (!empty($multicurrency)) $sql .= " , cr.date_sync, cr.rate "; + if (!empty($multicurrency)) { + $sql .= " , cr.date_sync, cr.rate "; + } $sql .= " FROM ".MAIN_DB_PREFIX."c_currencies as t"; if (!empty($multicurrency)) { $sql .= " JOIN ".MAIN_DB_PREFIX."multicurrency as m ON m.code=t.code_iso"; @@ -985,10 +977,8 @@ class Setup extends DolibarrApi } // Add sql filters - if ($sqlfilters) - { - if (!DolibarrApi::_checkFilters($sqlfilters)) - { + if ($sqlfilters) { + if (!DolibarrApi::_checkFilters($sqlfilters)) { throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); } $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; @@ -1043,18 +1033,22 @@ class Setup extends DolibarrApi throw new RestException(401, 'Only an admin user can get list of extrafields'); } - if ($type == 'thirdparty') $type = 'societe'; - if ($type == 'contact') $type = 'socpeople'; + if ($type == 'thirdparty') { + $type = 'societe'; + } + if ($type == 'contact') { + $type = 'socpeople'; + } $sql = "SELECT t.rowid, t.name, t.label, t.type, t.size, t.elementtype, t.fieldunique, t.fieldrequired, t.param, t.pos, t.alwayseditable, t.perms, t.list, t.fielddefault, t.fieldcomputed"; $sql .= " FROM ".MAIN_DB_PREFIX."extrafields as t"; $sql .= " WHERE t.entity IN (".getEntity('extrafields').")"; - if (!empty($type)) $sql .= " AND t.elementtype = '".$this->db->escape($type)."'"; + if (!empty($type)) { + $sql .= " AND t.elementtype = '".$this->db->escape($type)."'"; + } // Add sql filters - if ($sqlfilters) - { - if (!DolibarrApi::_checkFilters($sqlfilters)) - { + if ($sqlfilters) { + if (!DolibarrApi::_checkFilters($sqlfilters)) { throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); } $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; @@ -1064,12 +1058,9 @@ class Setup extends DolibarrApi $sql .= $this->db->order($sortfield, $sortorder); $resql = $this->db->query($sql); - if ($resql) - { - if ($this->db->num_rows($resql)) - { - while ($tab = $this->db->fetch_object($resql)) - { + if ($resql) { + if ($this->db->num_rows($resql)) { + while ($tab = $this->db->fetch_object($resql)) { // New usage $list[$tab->elementtype][$tab->name]['type'] = $tab->type; $list[$tab->elementtype][$tab->name]['label'] = $tab->label; @@ -1090,8 +1081,7 @@ class Setup extends DolibarrApi throw new RestException(503, 'Error when retrieving list of extra fields : '.$this->db->lasterror()); } - if (!count($list)) - { + if (!count($list)) { throw new RestException(404, 'No extrafield found'); } @@ -1123,13 +1113,15 @@ class Setup extends DolibarrApi $sql = "SELECT rowid AS id, zip, town, fk_county, fk_pays AS fk_country"; $sql .= " FROM ".MAIN_DB_PREFIX."c_ziptown as t"; $sql .= " AND t.active = ".$active; - if ($zipcode) $sql .= " AND t.zip LIKE '%".$this->db->escape($zipcode)."%'"; - if ($town) $sql .= " AND t.town LIKE '%".$this->db->escape($town)."%'"; + if ($zipcode) { + $sql .= " AND t.zip LIKE '%".$this->db->escape($zipcode)."%'"; + } + if ($town) { + $sql .= " AND t.town LIKE '%".$this->db->escape($town)."%'"; + } // Add sql filters - if ($sqlfilters) - { - if (!DolibarrApi::_checkFilters($sqlfilters)) - { + if ($sqlfilters) { + if (!DolibarrApi::_checkFilters($sqlfilters)) { throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); } $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; @@ -1192,10 +1184,8 @@ class Setup extends DolibarrApi $sql .= " WHERE t.entity IN (".getEntity('c_payment_term').")"; $sql .= " AND t.active = ".$active; // Add sql filters - if ($sqlfilters) - { - if (!DolibarrApi::_checkFilters($sqlfilters)) - { + if ($sqlfilters) { + if (!DolibarrApi::_checkFilters($sqlfilters)) { throw new RestException(400, 'Error when validating parameter sqlfilters '.$sqlfilters); } $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; @@ -1252,10 +1242,8 @@ class Setup extends DolibarrApi $sql .= " WHERE t.entity IN (".getEntity('c_shipment_mode').")"; $sql .= " AND t.active = ".$active; // Add sql filters - if ($sqlfilters) - { - if (!DolibarrApi::_checkFilters($sqlfilters)) - { + if ($sqlfilters) { + if (!DolibarrApi::_checkFilters($sqlfilters)) { throw new RestException(400, 'Error when validating parameter sqlfilters '.$sqlfilters); } $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; @@ -1313,10 +1301,8 @@ class Setup extends DolibarrApi $sql .= " FROM ".MAIN_DB_PREFIX."c_units as t"; $sql .= " WHERE t.active = ".$active; // Add sql filters - if ($sqlfilters) - { - if (!DolibarrApi::_checkFilters($sqlfilters)) - { + if ($sqlfilters) { + if (!DolibarrApi::_checkFilters($sqlfilters)) { throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); } $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; @@ -1380,10 +1366,8 @@ class Setup extends DolibarrApi $sql .= " WHERE t.entity IN (".getEntity('c_socialnetworks').")"; $sql .= " AND t.active = ".$active; // Add sql filters - if ($sqlfilters) - { - if (!DolibarrApi::_checkFilters($sqlfilters)) - { + if ($sqlfilters) { + if (!DolibarrApi::_checkFilters($sqlfilters)) { throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); } $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; @@ -1440,10 +1424,8 @@ class Setup extends DolibarrApi $sql .= " FROM ".MAIN_DB_PREFIX."c_ticket_category as t"; $sql .= " WHERE t.active = ".$active; // Add sql filters - if ($sqlfilters) - { - if (!DolibarrApi::_checkFilters($sqlfilters)) - { + if ($sqlfilters) { + if (!DolibarrApi::_checkFilters($sqlfilters)) { throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); } $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; @@ -1500,10 +1482,8 @@ class Setup extends DolibarrApi $sql .= " FROM ".MAIN_DB_PREFIX."c_ticket_severity as t"; $sql .= " WHERE t.active = ".$active; // Add sql filters - if ($sqlfilters) - { - if (!DolibarrApi::_checkFilters($sqlfilters)) - { + if ($sqlfilters) { + if (!DolibarrApi::_checkFilters($sqlfilters)) { throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); } $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; @@ -1562,10 +1542,8 @@ class Setup extends DolibarrApi // if ($type) $sql .= " AND t.type LIKE '%".$this->db->escape($type)."%'"; // if ($module) $sql .= " AND t.module LIKE '%".$this->db->escape($module)."%'"; // Add sql filters - if ($sqlfilters) - { - if (!DolibarrApi::_checkFilters($sqlfilters)) - { + if ($sqlfilters) { + if (!DolibarrApi::_checkFilters($sqlfilters)) { throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); } $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; @@ -1604,13 +1582,13 @@ class Setup extends DolibarrApi * * @url GET /company * - * @return array|mixed Data without useless information + * @return Object Mysoc object * * @throws RestException 403 Forbidden */ public function getCompany() { - global $mysoc; + global $conf, $mysoc; if (!DolibarrApiAccess::$user->admin && (empty($conf->global->API_LOGINS_ALLOWED_FOR_GET_COMPANY) || DolibarrApiAccess::$user->login != $conf->global->API_LOGINS_ALLOWED_FOR_GET_COMPANY)) { @@ -1710,8 +1688,7 @@ class Setup extends DolibarrApi global $langs, $conf; if (!DolibarrApiAccess::$user->admin - && (empty($conf->global->API_LOGIN_ALLOWED_FOR_INTEGRITY_CHECK) || DolibarrApiAccess::$user->login != $conf->global->API_LOGIN_ALLOWED_FOR_INTEGRITY_CHECK)) - { + && (empty($conf->global->API_LOGIN_ALLOWED_FOR_INTEGRITY_CHECK) || DolibarrApiAccess::$user->login != $conf->global->API_LOGIN_ALLOWED_FOR_INTEGRITY_CHECK)) { throw new RestException(403, 'Error API open to admin users only or to the users with logins defined into constant API_LOGIN_ALLOWED_FOR_INTEGRITY_CHECK'); } @@ -1731,10 +1708,16 @@ class Setup extends DolibarrApi $xmlfile = DOL_DOCUMENT_ROOT.$xmlshortfile; // Remote file to compare to $xmlremote = ($target == 'default' ? '' : $target); - if (empty($xmlremote) && !empty($conf->global->MAIN_FILECHECK_URL)) $xmlremote = $conf->global->MAIN_FILECHECK_URL; + if (empty($xmlremote) && !empty($conf->global->MAIN_FILECHECK_URL)) { + $xmlremote = $conf->global->MAIN_FILECHECK_URL; + } $param = 'MAIN_FILECHECK_URL_'.DOL_VERSION; - if (empty($xmlremote) && !empty($conf->global->$param)) $xmlremote = $conf->global->$param; - if (empty($xmlremote)) $xmlremote = 'https://www.dolibarr.org/files/stable/signatures/filelist-'.DOL_VERSION.'.xml'; + if (empty($xmlremote) && !empty($conf->global->$param)) { + $xmlremote = $conf->global->$param; + } + if (empty($xmlremote)) { + $xmlremote = 'https://www.dolibarr.org/files/stable/signatures/filelist-'.DOL_VERSION.'.xml'; + } if ($target == 'local') { if (dol_is_file($xmlfile)) { @@ -1756,8 +1739,7 @@ class Setup extends DolibarrApi } } - if ($xml) - { + if ($xml) { $checksumconcat = array(); $file_list = array(); $out = ''; @@ -1776,14 +1758,15 @@ class Setup extends DolibarrApi $out .= ''."\n"; $i = 0; - foreach ($xml->dolibarr_constants[0]->constant as $constant) // $constant is a simpleXMLElement - { + foreach ($xml->dolibarr_constants[0]->constant as $constant) { // $constant is a simpleXMLElement $constname = $constant['name']; $constvalue = (string) $constant; $constvalue = (empty($constvalue) ? '0' : $constvalue); // Value found $value = ''; - if ($constname && $conf->global->$constname != '') $value = $conf->global->$constname; + if ($constname && $conf->global->$constname != '') { + $value = $conf->global->$constname; + } $valueforchecksum = (empty($value) ? '0' : $value); $checksumconcat[] = $valueforchecksum; @@ -1797,8 +1780,7 @@ class Setup extends DolibarrApi $out .= "\n"; } - if ($i == 0) - { + if ($i == 0) { $out .= ''.$langs->trans("None").''; } $out .= ''; @@ -1808,9 +1790,7 @@ class Setup extends DolibarrApi } // Scan htdocs - if (is_object($xml->dolibarr_htdocs_dir[0])) - { - //var_dump($xml->dolibarr_htdocs_dir[0]['includecustom']);exit; + if (is_object($xml->dolibarr_htdocs_dir[0])) { $includecustom = (empty($xml->dolibarr_htdocs_dir[0]['includecustom']) ? 0 : $xml->dolibarr_htdocs_dir[0]['includecustom']); // Defined qualified files (must be same than into generate_filelist_xml.php) @@ -1821,11 +1801,9 @@ class Setup extends DolibarrApi // Fill file_list with files in signature, new files, modified files $ret = getFilesUpdated($file_list, $xml->dolibarr_htdocs_dir[0], '', DOL_DOCUMENT_ROOT, $checksumconcat); // Fill array $file_list // Complete with list of new files - foreach ($scanfiles as $keyfile => $valfile) - { + foreach ($scanfiles as $keyfile => $valfile) { $tmprelativefilename = preg_replace('/^'.preg_quote(DOL_DOCUMENT_ROOT, '/').'/', '', $valfile['fullname']); - if (!in_array($tmprelativefilename, $file_list['insignature'])) - { + if (!in_array($tmprelativefilename, $file_list['insignature'])) { $md5newfile = @md5_file($valfile['fullname']); // Can fails if we don't have permission to open/read file $file_list['added'][] = array('filename'=>$tmprelativefilename, 'md5'=>$md5newfile); } @@ -1842,11 +1820,9 @@ class Setup extends DolibarrApi $out .= ''.$langs->trans("ExpectedChecksum").''; $out .= ''."\n"; $tmpfilelist = dol_sort_array($file_list['missing'], 'filename'); - if (is_array($tmpfilelist) && count($tmpfilelist)) - { + if (is_array($tmpfilelist) && count($tmpfilelist)) { $i = 0; - foreach ($tmpfilelist as $file) - { + foreach ($tmpfilelist as $file) { $i++; $out .= ''; $out .= ''.$i.''."\n"; @@ -1877,11 +1853,9 @@ class Setup extends DolibarrApi $out .= ''.$langs->trans("DateModification").''; $out .= ''."\n"; $tmpfilelist2 = dol_sort_array($file_list['updated'], 'filename'); - if (is_array($tmpfilelist2) && count($tmpfilelist2)) - { + if (is_array($tmpfilelist2) && count($tmpfilelist2)) { $i = 0; - foreach ($tmpfilelist2 as $file) - { + foreach ($tmpfilelist2 as $file) { $i++; $out .= ''; $out .= ''.$i.''."\n"; @@ -1925,11 +1899,9 @@ class Setup extends DolibarrApi $out .= ''.$langs->trans("DateModification").''; $out .= ''."\n"; $tmpfilelist3 = dol_sort_array($file_list['added'], 'filename'); - if (is_array($tmpfilelist3) && count($tmpfilelist3)) - { + if (is_array($tmpfilelist3) && count($tmpfilelist3)) { $i = 0; - foreach ($tmpfilelist3 as $file) - { + foreach ($tmpfilelist3 as $file) { $i++; $out .= ''; $out .= ''.$i.''."\n"; @@ -1958,8 +1930,7 @@ class Setup extends DolibarrApi // Show warning - if (empty($tmpfilelist) && empty($tmpfilelist2) && empty($tmpfilelist3)) - { + if (empty($tmpfilelist) && empty($tmpfilelist2) && empty($tmpfilelist3)) { //setEventMessages($langs->trans("FileIntegrityIsStrictlyConformedWithReference"), null, 'mesgs'); } else { //setEventMessages($langs->trans("FileIntegritySomeFilesWereRemovedOrModified"), null, 'warnings'); @@ -1970,17 +1941,13 @@ class Setup extends DolibarrApi // Scan scripts - - asort($checksumconcat); // Sort list of checksum - //var_dump($checksumconcat); $checksumget = md5(join(',', $checksumconcat)); $checksumtoget = trim((string) $xml->dolibarr_htdocs_dir_checksum); $outexpectedchecksum = ($checksumtoget ? $checksumtoget : $langs->trans("Unknown")); if ($checksumget == $checksumtoget) { - if (count($file_list['added'])) - { + if (count($file_list['added'])) { $resultcode = 'warning'; $resultcomment = 'FileIntegrityIsOkButFilesWereAdded'; //$outcurrentchecksum = $checksumget.' - '.$langs->trans("FileIntegrityIsOkButFilesWereAdded").''; @@ -2019,8 +1986,7 @@ class Setup extends DolibarrApi global $conf; if (!DolibarrApiAccess::$user->admin - && (empty($conf->global->API_LOGIN_ALLOWED_FOR_GET_MODULES) || DolibarrApiAccess::$user->login != $conf->global->API_LOGIN_ALLOWED_FOR_GET_MODULES)) - { + && (empty($conf->global->API_LOGIN_ALLOWED_FOR_GET_MODULES) || DolibarrApiAccess::$user->login != $conf->global->API_LOGIN_ALLOWED_FOR_GET_MODULES)) { throw new RestException(403, 'Error API open to admin users only or to the users with logins defined into constant API_LOGIN_ALLOWED_FOR_GET_MODULES'); } From f9ea75df3d3383fb32fafd6f4fcdbbdce4160246 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sun, 20 Dec 2020 10:28:06 +0100 Subject: [PATCH 03/23] fix phpcs --- dev/tools/test/namespacemig/aaa.class.php | 3 + dev/tools/test/namespacemig/bbb.class.php | 3 + htdocs/admin/sms.php | 1 - htdocs/install/fileconf.php | 342 ++++++++++++++-------- 4 files changed, 219 insertions(+), 130 deletions(-) diff --git a/dev/tools/test/namespacemig/aaa.class.php b/dev/tools/test/namespacemig/aaa.class.php index d7578b78e40..84d936479f2 100644 --- a/dev/tools/test/namespacemig/aaa.class.php +++ b/dev/tools/test/namespacemig/aaa.class.php @@ -15,6 +15,9 @@ function faaa() return 'faaa'; } +/** + * Class Aaa + */ class Aaa { const AAA='aaa'; diff --git a/dev/tools/test/namespacemig/bbb.class.php b/dev/tools/test/namespacemig/bbb.class.php index f68b3b2f36c..ea3c1b18d61 100644 --- a/dev/tools/test/namespacemig/bbb.class.php +++ b/dev/tools/test/namespacemig/bbb.class.php @@ -12,6 +12,9 @@ function fbbb() return 'fbbb'; } +/** + * Class Bbb + */ class Bbb { const BBB='bbb'; diff --git a/htdocs/admin/sms.php b/htdocs/admin/sms.php index 9b333d7b4f1..d2cf26a0c9a 100644 --- a/htdocs/admin/sms.php +++ b/htdocs/admin/sms.php @@ -161,7 +161,6 @@ if (!count($listofmethods)) { } if ($action == 'edit') { - print '
'; print ''; print ''; diff --git a/htdocs/install/fileconf.php b/htdocs/install/fileconf.php index 713f3132eaf..cfe42adc79f 100644 --- a/htdocs/install/fileconf.php +++ b/htdocs/install/fileconf.php @@ -44,21 +44,45 @@ dolibarr_install_syslog("- fileconf: entering fileconf.php page"); // install.forced.php into directory htdocs/install (This is the case with some wizard // installer like DoliWamp, DoliMamp or DoliBuntu). // We first init "forced values" to nothing. -if (!isset($force_install_noedit)) $force_install_noedit = ''; // 1=To block vars specific to distrib, 2 to block all technical parameters -if (!isset($force_install_type)) $force_install_type = ''; -if (!isset($force_install_dbserver)) $force_install_dbserver = ''; -if (!isset($force_install_port)) $force_install_port = ''; -if (!isset($force_install_database)) $force_install_database = ''; -if (!isset($force_install_prefix)) $force_install_prefix = ''; -if (!isset($force_install_createdatabase)) $force_install_createdatabase = ''; -if (!isset($force_install_databaselogin)) $force_install_databaselogin = ''; -if (!isset($force_install_databasepass)) $force_install_databasepass = ''; -if (!isset($force_install_databaserootlogin)) $force_install_databaserootlogin = ''; -if (!isset($force_install_databaserootpass)) $force_install_databaserootpass = ''; +if (!isset($force_install_noedit)) { + $force_install_noedit = ''; // 1=To block vars specific to distrib, 2 to block all technical parameters +} +if (!isset($force_install_type)) { + $force_install_type = ''; +} +if (!isset($force_install_dbserver)) { + $force_install_dbserver = ''; +} +if (!isset($force_install_port)) { + $force_install_port = ''; +} +if (!isset($force_install_database)) { + $force_install_database = ''; +} +if (!isset($force_install_prefix)) { + $force_install_prefix = ''; +} +if (!isset($force_install_createdatabase)) { + $force_install_createdatabase = ''; +} +if (!isset($force_install_databaselogin)) { + $force_install_databaselogin = ''; +} +if (!isset($force_install_databasepass)) { + $force_install_databasepass = ''; +} +if (!isset($force_install_databaserootlogin)) { + $force_install_databaserootlogin = ''; +} +if (!isset($force_install_databaserootpass)) { + $force_install_databaserootpass = ''; +} // Now we load forced values from install.forced.php file. $useforcedwizard = false; $forcedfile = "./install.forced.php"; -if ($conffile == "/etc/dolibarr/conf.php") $forcedfile = "/etc/dolibarr/install.forced.php"; // Must be after inc.php +if ($conffile == "/etc/dolibarr/conf.php") { + $forcedfile = "/etc/dolibarr/install.forced.php"; // Must be after inc.php +} if (@file_exists($forcedfile)) { $useforcedwizard = true; include_once $forcedfile; @@ -75,8 +99,7 @@ session_start(); // To be able to keep info into session (used for not losing pa pHeader($langs->trans("ConfigurationFile"), "step1", "set", "", (empty($force_dolibarr_js_JQUERY) ? '' : $force_dolibarr_js_JQUERY.'/'), 'main-inside-bis'); // Test if we can run a first install process -if (!is_writable($conffile)) -{ +if (!is_writable($conffile)) { print $langs->trans("ConfFileIsNotWritable", $conffiletoshow); dolibarr_install_syslog("fileconf: config file is not writable", LOG_WARNING); dolibarr_install_syslog("- fileconf: end"); @@ -84,29 +107,30 @@ if (!is_writable($conffile)) exit; } -if (!empty($force_install_message)) -{ +if (!empty($force_install_message)) { print '

'.$langs->trans($force_install_message).'
'; /*print ''; + print ''; - print '
'.$langs->trans("ShowEditTechnicalParameters").'
'; - */ + print '
'.$langs->trans("ShowEditTechnicalParameters").'
'; + */ } ?>
- +
- + - - - + - + @@ -252,8 +282,7 @@ if (!empty($force_install_noedit)) { @@ -273,55 +302,86 @@ if (!empty($force_install_noedit)) { // Scan les drivers $dir = DOL_DOCUMENT_ROOT.'/core/db'; $handle = opendir($dir); - if (is_resource($handle)) - { - while (($file = readdir($handle)) !== false) - { - if (is_readable($dir."/".$file) && preg_match('/^(.*)\.class\.php$/i', $file, $reg)) - { + if (is_resource($handle)) { + while (($file = readdir($handle)) !== false) { + if (is_readable($dir."/".$file) && preg_match('/^(.*)\.class\.php$/i', $file, $reg)) { $type = $reg[1]; - if ($type === 'DoliDB') continue; // Skip abstract class + if ($type === 'DoliDB') { + continue; // Skip abstract class + } $class = 'DoliDB'.ucfirst($type); include_once $dir."/".$file; - if ($type == 'sqlite') continue; // We hide sqlite because support can't be complete until sqlite does not manage foreign key creation after table creation (ALTER TABLE child ADD CONSTRAINT not supported) - if ($type == 'sqlite3') continue; // We hide sqlite3 because support can't be complete until sqlite does not manage foreign key creation after table creation (ALTER TABLE child ADD CONSTRAINT not supported) + if ($type == 'sqlite') { + continue; // We hide sqlite because support can't be complete until sqlite does not manage foreign key creation after table creation (ALTER TABLE child ADD CONSTRAINT not supported) + } + if ($type == 'sqlite3') { + continue; // We hide sqlite3 because support can't be complete until sqlite does not manage foreign key creation after table creation (ALTER TABLE child ADD CONSTRAINT not supported) + } // Version min of database $versionbasemin = explode('.', $class::VERSIONMIN); $note = '('.$class::LABEL.' >= '.$class::VERSIONMIN.')'; // Switch to mysql if mysqli is not present - if ($defaultype == 'mysqli' && !function_exists('mysqli_connect')) $defaultype = 'mysql'; + if ($defaultype == 'mysqli' && !function_exists('mysqli_connect')) { + $defaultype = 'mysql'; + } // Show line into list - if ($type == 'mysql') { $testfunction = 'mysql_connect'; $testclass = ''; } - if ($type == 'mysqli') { $testfunction = 'mysqli_connect'; $testclass = ''; } - if ($type == 'pgsql') { $testfunction = 'pg_connect'; $testclass = ''; } - if ($type == 'mssql') { $testfunction = 'mssql_connect'; $testclass = ''; } - if ($type == 'sqlite') { $testfunction = ''; $testclass = 'PDO'; } - if ($type == 'sqlite3') { $testfunction = ''; $testclass = 'SQLite3'; } + if ($type == 'mysql') { + $testfunction = 'mysql_connect'; $testclass = ''; + } + if ($type == 'mysqli') { + $testfunction = 'mysqli_connect'; $testclass = ''; + } + if ($type == 'pgsql') { + $testfunction = 'pg_connect'; $testclass = ''; + } + if ($type == 'mssql') { + $testfunction = 'mssql_connect'; $testclass = ''; + } + if ($type == 'sqlite') { + $testfunction = ''; $testclass = 'PDO'; + } + if ($type == 'sqlite3') { + $testfunction = ''; $testclass = 'SQLite3'; + } $option .= ''; } } } ?> @@ -335,10 +395,12 @@ if (!empty($force_install_noedit)) { - + - + - + @@ -405,17 +477,19 @@ if (!empty($force_install_noedit)) { @@ -425,10 +499,14 @@ if (!empty($force_install_noedit)) { '; -// Date +// Date payment print ''; +// Date value +print ''; // Type print ''; print_liste_field_titre("Ref", $_SERVER["PHP_SELF"], "s.rowid", "", $param, "", $sortfield, $sortorder); print_liste_field_titre("Employee", $_SERVER["PHP_SELF"], "u.rowid", "", $param, "", $sortfield, $sortorder); print_liste_field_titre("Label", $_SERVER["PHP_SELF"], "s.label", "", $param, 'class="left"', $sortfield, $sortorder); -print_liste_field_titre("DatePayment", $_SERVER["PHP_SELF"], "s.datep,s.rowid", "", $param, 'align="center"', $sortfield, $sortorder); +print_liste_field_titre("DatePayment", $_SERVER["PHP_SELF"], "s.datep,s.rowid", "", $param, '', $sortfield, $sortorder, 'center '); +print_liste_field_titre("DateValue", $_SERVER["PHP_SELF"], "s.datev,s.rowid", "", $param, '', $sortfield, $sortorder, 'center '); print_liste_field_titre("PaymentMode", $_SERVER["PHP_SELF"], "type", "", $param, 'class="left"', $sortfield, $sortorder); if (!empty($conf->banque->enabled)) print_liste_field_titre("BankAccount", $_SERVER["PHP_SELF"], "ba.label", "", $param, "", $sortfield, $sortorder); print_liste_field_titre("PayedByThisPayment", $_SERVER["PHP_SELF"], "s.amount", "", $param, 'class="right"', $sortfield, $sortorder); @@ -419,6 +423,10 @@ while ($i < ($limit ? min($num, $limit) : $num)) print '\n"; if (!$i) $totalarray['nbfield']++; + // Date value + print '\n"; + if (!$i) $totalarray['nbfield']++; + // Type print ''; if (!$i) $totalarray['nbfield']++; From 14223d74bd9a26042d5ff512b66305594222f4a8 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 21 Dec 2020 15:00:29 +0100 Subject: [PATCH 11/23] Fix css --- htdocs/core/lib/salaries.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/salaries.lib.php b/htdocs/core/lib/salaries.lib.php index c11e37b7aaa..f4662f43991 100644 --- a/htdocs/core/lib/salaries.lib.php +++ b/htdocs/core/lib/salaries.lib.php @@ -50,7 +50,7 @@ function salaries_prepare_head($object) $nbLinks = Link::count($db, $object->element, $object->id); $head[$h][0] = DOL_URL_ROOT.'/salaries/document.php?id='.$object->id; $head[$h][1] = $langs->trans('Documents'); - if (($nbFiles + $nbLinks) > 0) $head[$h][1] .= ''.($nbFiles + $nbLinks).''; + if (($nbFiles + $nbLinks) > 0) $head[$h][1] .= ''.($nbFiles + $nbLinks).''; $head[$h][2] = 'documents'; $h++; From cba10bbd4d17e704345b0743c1d6818d4837f42d Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Mon, 21 Dec 2020 15:18:55 +0100 Subject: [PATCH 12/23] FIX: create form variant https://github.com/Dolibarr/dolibarr/issues/15759 --- htdocs/variants/create.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/variants/create.php b/htdocs/variants/create.php index 84530e01cb5..ff1ed1be127 100644 --- a/htdocs/variants/create.php +++ b/htdocs/variants/create.php @@ -70,7 +70,7 @@ print dol_get_fiche_head(); print '
'; print ''; -print ''; +print ''; print ''; ?> From 4d32529e66352f88f59e5bd90a9ff4f2431cd499 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Mon, 21 Dec 2020 15:25:15 +0100 Subject: [PATCH 13/23] include --- htdocs/societe/class/api_thirdparties.class.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/htdocs/societe/class/api_thirdparties.class.php b/htdocs/societe/class/api_thirdparties.class.php index b4ae02cd532..81a1c167a02 100644 --- a/htdocs/societe/class/api_thirdparties.class.php +++ b/htdocs/societe/class/api_thirdparties.class.php @@ -20,8 +20,6 @@ use Luracast\Restler\RestException; -require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; - /** * API class for thirdparties * @@ -52,6 +50,7 @@ class Thirdparties extends DolibarrApi global $db, $conf; $this->db = $db; + require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; require_once DOL_DOCUMENT_ROOT.'/societe/class/societeaccount.class.php'; require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; require_once DOL_DOCUMENT_ROOT.'/societe/class/companybankaccount.class.php'; From 94cf393f7f4a68acf676d44fb620d600f942f055 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Mon, 21 Dec 2020 15:43:45 +0100 Subject: [PATCH 14/23] Update combinations.php --- htdocs/variants/combinations.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/variants/combinations.php b/htdocs/variants/combinations.php index 3a2936d0df5..24da596f3c2 100644 --- a/htdocs/variants/combinations.php +++ b/htdocs/variants/combinations.php @@ -227,7 +227,7 @@ if (($action == 'add' || $action == 'create') && empty($massaction) && !GETPOST( $db->commit(); setEventMessages($langs->trans('RecordSaved'), null, 'mesgs'); } -} elseif ($valueid > 0) { +} elseif ($action === 'update' && $valueid > 0) { if ($prodcomb->fetch($valueid) < 0) { dol_print_error($db, $langs->trans('ErrorRecordNotFound')); exit(); From 8d901d03fd8bbf3243944883de81c43a299b3b84 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 21 Dec 2020 16:01:47 +0100 Subject: [PATCH 15/23] Fix link --- htdocs/compta/accounting-files.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/compta/accounting-files.php b/htdocs/compta/accounting-files.php index cc9abb8d594..734d21b1c87 100644 --- a/htdocs/compta/accounting-files.php +++ b/htdocs/compta/accounting-files.php @@ -529,7 +529,7 @@ print ''.$langs->trans("ExportAccountingSourceDocHel print '
'; print $langs->trans("ReportPeriod").': '.$form->selectDate($date_start, 'date_start', 0, 0, 0, "", 1, 1, 0); -print ' - '.$form->selectDate($date_stop, 'date_stop', 0, 0, 0, "", 1, 1, 0)."\n"; +print ' - '.$form->selectDate($date_stop, 'date_stop', 0, 0, 0, "", 1, 1, 0)."\n"; // Export is for current company only if (!empty($conf->multicompany->enabled) && is_object($mc)) @@ -560,7 +560,7 @@ $listofchoices = array( ); foreach ($listofchoices as $choice => $val) { $checked = (((!GETPOSTISSET('search') && $action != 'searchfiles') || GETPOST($choice)) ? ' checked="checked"' : ''); - print '
'.$langs->trans($val['label']).'
'; + print '
'; } print ''; From 4ca6e38f5f08e4ceea6a5ec564b1e09c5524c699 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Mon, 21 Dec 2020 16:07:46 +0100 Subject: [PATCH 16/23] FIX variant api code v13+ Better clean code --- htdocs/product/class/api_products.class.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/product/class/api_products.class.php b/htdocs/product/class/api_products.class.php index f7406692f8d..189161712d5 100644 --- a/htdocs/product/class/api_products.class.php +++ b/htdocs/product/class/api_products.class.php @@ -1514,6 +1514,7 @@ class Products extends DolibarrApi foreach ($combinations as $key => $combination) { $prodc2vp = new ProductCombination2ValuePair($this->db); $combinations[$key]->attributes = $prodc2vp->fetchByFkCombination((int) $combination->id); + $combinations[$key] = $this->_cleanObjectDatas($combinations[$key]); } return $combinations; @@ -1547,6 +1548,7 @@ class Products extends DolibarrApi foreach ($combinations as $key => $combination) { $prodc2vp = new ProductCombination2ValuePair($this->db); $combinations[$key]->attributes = $prodc2vp->fetchByFkCombination((int) $combination->id); + $combinations[$key] = $this->_cleanObjectDatas($combinations[$key]); } return $combinations; @@ -1754,7 +1756,7 @@ class Products extends DolibarrApi unset($object->libelle); unset($object->product_id_already_linked); unset($object->reputations); - + unset($object->db); unset($object->name); unset($object->firstname); unset($object->lastname); From 4bc0b46556ec2385982c78bc7bdc0a195fb8b47b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 21 Dec 2020 17:33:57 +0100 Subject: [PATCH 17/23] css --- htdocs/core/boxes/box_scheduled_jobs.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/boxes/box_scheduled_jobs.php b/htdocs/core/boxes/box_scheduled_jobs.php index 01dd86a999d..2ac81c80d16 100644 --- a/htdocs/core/boxes/box_scheduled_jobs.php +++ b/htdocs/core/boxes/box_scheduled_jobs.php @@ -165,7 +165,7 @@ class box_scheduled_jobs extends ModeleBoxes ); $this->info_box_contents[$line][] = array( 'td' => 'class="center"', - 'textnoformat' => ($nbjobsinerror ? ''.$nbjobsinerror.img_error() : '
0
') + 'textnoformat' => ($nbjobsinerror ? '
'.$nbjobsinerror.'
' : '
0
') ); } else { $this->info_box_contents[0][0] = array( From dfb632f2d535b0ef088d4716dfc35776009df624 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 21 Dec 2020 17:56:31 +0100 Subject: [PATCH 18/23] Fix phpunit --- htdocs/core/lib/price.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/price.lib.php b/htdocs/core/lib/price.lib.php index 4e3ce29f69e..98311d093cd 100644 --- a/htdocs/core/lib/price.lib.php +++ b/htdocs/core/lib/price.lib.php @@ -129,7 +129,7 @@ function calcul_price_total($qty, $pu, $remise_percent_ligne, $txtva, $uselocalt $localtax1_type = 0; $localtax2_type = 0; - if (is_array($localtaxes_array)) { + if (is_array($localtaxes_array) && count($localtaxes_array)) { $localtax1_type = $localtaxes_array[0]; $localtax1_rate = $localtaxes_array[1]; $localtax2_type = $localtaxes_array[2]; From 48dfc90c8b6620b01427112a76eb42a5ed0b9d36 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 21 Dec 2020 18:06:02 +0100 Subject: [PATCH 19/23] Update create.php --- htdocs/variants/create.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/variants/create.php b/htdocs/variants/create.php index ff1ed1be127..e37548f39f3 100644 --- a/htdocs/variants/create.php +++ b/htdocs/variants/create.php @@ -29,7 +29,7 @@ $action = GETPOST('action', 'alpha'); * Actions */ -if ($action == 'create') { +if ($action == 'add') { if (empty($ref) || empty($label)) { setEventMessages($langs->trans('ErrorFieldsRequired'), null, 'errors'); } else { @@ -70,7 +70,7 @@ print dol_get_fiche_head(); print ''; print ''; -print ''; +print ''; print ''; ?> From 48ce5c549961b53bead7b4fdc4d2da5812dd13ce Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 21 Dec 2020 18:16:16 +0100 Subject: [PATCH 20/23] Update api_setup.class.php --- htdocs/api/class/api_setup.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/api/class/api_setup.class.php b/htdocs/api/class/api_setup.class.php index fbeb2cc931b..84d4ddc3679 100644 --- a/htdocs/api/class/api_setup.class.php +++ b/htdocs/api/class/api_setup.class.php @@ -1582,7 +1582,7 @@ class Setup extends DolibarrApi * * @url GET /company * - * @return Object Mysoc object + * @return array|mixed Mysoc object * * @throws RestException 403 Forbidden */ From 5252aa42b26a35565d9348f2bd3e740a92e55a92 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 21 Dec 2020 18:20:13 +0100 Subject: [PATCH 21/23] Trans --- htdocs/langs/en_US/admin.lang | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index d74201b2f17..537da1102e8 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -258,6 +258,7 @@ ReferencedPreferredPartners=Preferred Partners OtherResources=Other resources ExternalResources=External Resources SocialNetworks=Social Networks +SocialNetworkId=Social Network ID ForDocumentationSeeWiki=For user or developer documentation (Doc, FAQs...),
take a look at the Dolibarr Wiki:
%s ForAnswersSeeForum=For any other questions/help, you can use the Dolibarr forum:
%s HelpCenterDesc1=Here are some resources for getting help and support with Dolibarr. From 58b4de8bc33c79869d4d4f96586a1858fc4e0cb6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 21 Dec 2020 19:27:42 +0100 Subject: [PATCH 22/23] More complete fix for #15712 --- htdocs/compta/bank/bankentries_list.php | 43 ++++++++++++++----------- 1 file changed, 25 insertions(+), 18 deletions(-) diff --git a/htdocs/compta/bank/bankentries_list.php b/htdocs/compta/bank/bankentries_list.php index 902a96ec16c..d57e2cf5591 100644 --- a/htdocs/compta/bank/bankentries_list.php +++ b/htdocs/compta/bank/bankentries_list.php @@ -496,7 +496,7 @@ if (dol_strlen($search_dv_end) > 0) $sql .= " AND b.datev <= '".$db->idate($sear if ($search_ref) $sql .= natural_search("b.rowid", $search_ref, 1); if ($search_req_nb) $sql .= natural_search("b.num_chq", $search_req_nb); if ($search_num_releve) $sql .= natural_search("b.num_releve", $search_num_releve); -if ($search_conciliated != '' && $search_conciliated != '-1') $sql .= " AND b.rappro = ".$search_conciliated; +if ($search_conciliated != '' && $search_conciliated != '-1') $sql .= " AND b.rappro = ".urlencode($search_conciliated); if ($search_thirdparty) $sql .= natural_search("s.nom", $search_thirdparty); if ($search_description) { @@ -861,6 +861,10 @@ if ($resql) $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields + // When action is 'reconcile', we force to have the column num_releve always enabled (otherwise we can't make reconciliation). + if ($action == 'reconcile') { + $arrayfields['b.num_releve']['checked'] = 1; + } print '
'; print '
@@ -116,7 +140,7 @@ if (!empty($force_install_message))
@@ -185,14 +209,14 @@ if (!empty($force_install_noedit)) { } ?>
+
- - + + + > trans("CheckToForceHttps"); ?> @@ -238,13 +266,15 @@ if (!empty($force_install_noedit)) {
+ id="db_name" + name="db_name" + value="" + > trans("DatabaseName"); ?> + id="db_host" + name="db_host" + value="" + > trans("ServerAddressDescription"); ?> @@ -347,13 +409,15 @@ if (!empty($force_install_noedit)) {
+ name="db_port" + id="db_port" + value="" + > trans("ServerPortDescription"); ?> @@ -362,26 +426,32 @@ if (!empty($force_install_noedit)) {
+ id="db_prefix" + name="db_prefix" + value="" + > trans("DatabasePrefixDescription"); ?>
- + id="db_create_database" + name="db_create_database" + + > trans("CheckToCreateDatabase"); ?> @@ -392,10 +462,12 @@ if (!empty($force_install_noedit)) { + id="db_user" + name="db_user" + value="" + > trans("AdminLogin"); ?> + id="db_pass" autocomplete="off" + name="db_pass" + value="" + > trans("AdminPassword"); ?> - + id="db_create_user" + name="db_create_user" + + > trans("CheckToCreateUser"); ?> @@ -451,11 +529,13 @@ if (!empty($force_install_noedit)) { 0 && !empty($force_install_databaserootlogin)) { print ' disabled'; } ?> + id="db_user_root" + name="db_user_root" + class="needroot" + value="" + 0 && !empty($force_install_databaserootlogin)) { + print ' disabled'; + } ?> > trans("DatabaseRootLoginDescription"); ?> @@ -473,25 +553,29 @@ if (!empty($force_install_noedit)) { " - 0 && !empty($force_install_databaserootpass)) { print ' disabled'; /* May be removed by javascript*/ } ?> + 0 && !empty($force_install_databaserootpass)) { + print ' disabled'; /* May be removed by javascript*/ + } ?> > trans("KeepEmptyIfNoPassword"); ?> @@ -535,7 +619,7 @@ jQuery(document).ready(function() { jQuery(".hideroot").show(); - jQuery(".needroot").removeAttr('disabled'); + jQuery(".needroot").removeAttr('disabled'); } else From 92f38f664a10ecc27a28677e0dd3e132846f1dc1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sun, 20 Dec 2020 10:44:55 +0100 Subject: [PATCH 04/23] Remove no more needed file --- htdocs/admin/socialnetworks.php | 118 -------------------------------- 1 file changed, 118 deletions(-) delete mode 100644 htdocs/admin/socialnetworks.php diff --git a/htdocs/admin/socialnetworks.php b/htdocs/admin/socialnetworks.php deleted file mode 100644 index 0ab3a91432b..00000000000 --- a/htdocs/admin/socialnetworks.php +++ /dev/null @@ -1,118 +0,0 @@ - - * Copyright (C) 2019 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 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/admin/socialnetworks.php - * \ingroup socialnetworks - * \brief Page to setup the module Social Networks - */ - -require '../main.inc.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/mailmanspip.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; - -// Load translation files required by the page -$langs->loadLangs(array("admin", "errors")); - -if (!$user->admin) accessforbidden(); - -$type = array('yesno', 'texte', 'chaine'); - -$action = GETPOST('action', 'aZ09'); - - - -/* - * Action - */ -if (preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg)) -{ - $code = $reg[1]; - if (dolibarr_set_const($db, $code, 1, 'chaine', 0, '', $conf->entity) > 0) - { - header("Location: ".$_SERVER["PHP_SELF"]); - exit; - } else { - dol_print_error($db); - } -} - -if (preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg)) -{ - $code = $reg[1]; - if (dolibarr_del_const($db, $code, $conf->entity) > 0) - { - header("Location: ".$_SERVER["PHP_SELF"]); - exit; - } else { - dol_print_error($db); - } -} - - -/* - * View - */ - -$help_url = ''; - -llxHeader('', $langs->trans("SocialNetworkSetup"), $help_url); - - -$linkback = ''.$langs->trans("BackToModuleList").''; -print load_fiche_titre($langs->trans("SocialNetworkSetup"), $linkback, 'title_setup'); - -//$head = socialnetworks_admin_prepare_head(); -$h = 0; -$head = array(); -$head[$h][0] = DOL_URL_ROOT.'/admin/socialnetworks.php'; -$head[$h][1] = $langs->trans("Setup"); -$head[$h][2] = 'setup'; -$h++; - - -print ''; - -print dol_get_fiche_head($head, 'setup', '', 0, 'user'); - -print '
'; - -$arrayofsocialnetworks = array('jabber'=>'Jabber', 'skype'=>'Skype', 'twitter'=>'Twitter', 'facebook'=>'Facebook', 'linkedin'=>'LinkedIn'); - -foreach ($arrayofsocialnetworks as $snkey => $snlabel) { - $consttocheck = 'SOCIALNETWORKS_'.strtoupper($snkey); - if ($conf->use_javascript_ajax) { - $link = ajax_constantonoff($consttocheck); - } else { - $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); - $link = $form->selectarray($consttocheck, $arrval, $conf->global->$consttocheck); - } - - print $langs->trans('EnableFeatureFor', $snlabel).' '.$link.'

'; -} - - -print dol_get_fiche_end(); - -print ''; - - -// End of page -llxFooter(); -$db->close(); From b7b35f4cd408ef2f7824fbc0bc5af1dcc69ade9b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sun, 20 Dec 2020 11:04:21 +0100 Subject: [PATCH 05/23] simplify notications class --- htdocs/core/class/notify.class.php | 308 ++++++++++++++++------------- 1 file changed, 169 insertions(+), 139 deletions(-) diff --git a/htdocs/core/class/notify.class.php b/htdocs/core/class/notify.class.php index 7cc51bfecb9..6f60f6cdca6 100644 --- a/htdocs/core/class/notify.class.php +++ b/htdocs/core/class/notify.class.php @@ -113,25 +113,38 @@ class Notify $listofnotiftodo = $this->getNotificationsArray($action, $socid, $object, 0); $nb = -1; - if (is_array($listofnotiftodo)) $nb = count($listofnotiftodo); - if ($nb < 0) $texte = img_object($langs->trans("Notifications"), 'email').' '.$langs->trans("ErrorFailedToGetListOfNotificationsToSend"); - if ($nb == 0) $texte = img_object($langs->trans("Notifications"), 'email').' '.$langs->trans("NoNotificationsWillBeSent"); - if ($nb == 1) $texte = img_object($langs->trans("Notifications"), 'email').' '.$langs->trans("ANotificationsWillBeSent"); - if ($nb >= 2) $texte = img_object($langs->trans("Notifications"), 'email').' '.$langs->trans("SomeNotificationsWillBeSent", $nb); + if (is_array($listofnotiftodo)) { + $nb = count($listofnotiftodo); + } + if ($nb < 0) { + $texte = img_object($langs->trans("Notifications"), 'email').' '.$langs->trans("ErrorFailedToGetListOfNotificationsToSend"); + } elseif ($nb == 0) { + $texte = img_object($langs->trans("Notifications"), 'email').' '.$langs->trans("NoNotificationsWillBeSent"); + } elseif ($nb == 1) { + $texte = img_object($langs->trans("Notifications"), 'email').' '.$langs->trans("ANotificationsWillBeSent"); + } elseif ($nb >= 2) { + $texte = img_object($langs->trans("Notifications"), 'email').' '.$langs->trans("SomeNotificationsWillBeSent", $nb); + } - if (is_array($listofnotiftodo)) - { + if (is_array($listofnotiftodo)) { $i = 0; - foreach ($listofnotiftodo as $key => $val) - { - if ($i) $texte .= ', '; - else $texte .= ' ('; - if ($val['isemailvalid']) $texte .= $val['email']; - else $texte .= $val['emaildesc']; + foreach ($listofnotiftodo as $key => $val) { + if ($i) { + $texte .= ', '; + } else { + $texte .= ' ('; + } + if ($val['isemailvalid']) { + $texte .= $val['email']; + } else { + $texte .= $val['emaildesc']; + } $i++; } - if ($i) $texte .= ')'; - } + if ($i) { + $texte .= ')'; + } + } return $texte; } @@ -154,12 +167,19 @@ class Notify $resarray = array(); $valueforthreshold = 0; - if (is_object($object)) $valueforthreshold = $object->total_ht; + if (is_object($object)) { + $valueforthreshold = $object->total_ht; + } + if ($notifcode) { + if (is_numeric($notifcode)) { + $sqlnotifcode = " AND n.fk_action = ".$notifcode; // Old usage + } else { + $sqlnotifcode = " AND a.code = '".$this->db->escape($notifcode)."'"; // New usage + } + } - if (!$error) - { - if ($socid >= 0 && in_array('thirdparty', $scope)) - { + if (!$error) { + if ($socid >= 0 && in_array('thirdparty', $scope)) { $sql = "SELECT a.code, c.email, c.rowid"; $sql .= " FROM ".MAIN_DB_PREFIX."notify_def as n,"; $sql .= " ".MAIN_DB_PREFIX."socpeople as c,"; @@ -168,29 +188,26 @@ class Notify $sql .= " WHERE n.fk_contact = c.rowid"; $sql .= " AND a.rowid = n.fk_action"; $sql .= " AND n.fk_soc = s.rowid"; - if ($notifcode) - { - if (is_numeric($notifcode)) $sql .= " AND n.fk_action = ".$notifcode; // Old usage - else $sql .= " AND a.code = '".$this->db->escape($notifcode)."'"; // New usage - } + $sql .= $sqlnotifcode; $sql .= " AND s.entity IN (".getEntity('societe').")"; - if ($socid > 0) $sql .= " AND s.rowid = ".$socid; + if ($socid > 0) { + $sql .= " AND s.rowid = ".$socid; + } dol_syslog(__METHOD__." ".$notifcode.", ".$socid."", LOG_DEBUG); $resql = $this->db->query($sql); - if ($resql) - { + if ($resql) { $num = $this->db->num_rows($resql); $i = 0; - while ($i < $num) - { + while ($i < $num) { $obj = $this->db->fetch_object($resql); - if ($obj) - { + if ($obj) { $newval2 = trim($obj->email); $isvalid = isValidEmail($newval2); - if (empty($resarray[$newval2])) $resarray[$newval2] = array('type'=> 'tocontact', 'code'=>trim($obj->code), 'emaildesc'=>'Contact id '.$obj->rowid, 'email'=>$newval2, 'contactid'=>$obj->rowid, 'isemailvalid'=>$isvalid); + if (empty($resarray[$newval2])) { + $resarray[$newval2] = array('type'=> 'tocontact', 'code'=>trim($obj->code), 'emaildesc'=>'Contact id '.$obj->rowid, 'email'=>$newval2, 'contactid'=>$obj->rowid, 'isemailvalid'=>$isvalid); + } } $i++; } @@ -201,39 +218,34 @@ class Notify } } - if (!$error) - { - if ($userid >= 0 && in_array('user', $scope)) - { + if (!$error) { + if ($userid >= 0 && in_array('user', $scope)) { $sql = "SELECT a.code, c.email, c.rowid"; $sql .= " FROM ".MAIN_DB_PREFIX."notify_def as n,"; $sql .= " ".MAIN_DB_PREFIX."user as c,"; $sql .= " ".MAIN_DB_PREFIX."c_action_trigger as a"; $sql .= " WHERE n.fk_user = c.rowid"; $sql .= " AND a.rowid = n.fk_action"; - if ($notifcode) - { - if (is_numeric($notifcode)) $sql .= " AND n.fk_action = ".$notifcode; // Old usage - else $sql .= " AND a.code = '".$this->db->escape($notifcode)."'"; // New usage - } + $sql .= $sqlnotifcode; $sql .= " AND c.entity IN (".getEntity('user').")"; - if ($userid > 0) $sql .= " AND c.rowid = ".$userid; + if ($userid > 0) { + $sql .= " AND c.rowid = ".$userid; + } dol_syslog(__METHOD__." ".$notifcode.", ".$socid."", LOG_DEBUG); $resql = $this->db->query($sql); - if ($resql) - { + if ($resql) { $num = $this->db->num_rows($resql); $i = 0; - while ($i < $num) - { + while ($i < $num) { $obj = $this->db->fetch_object($resql); - if ($obj) - { + if ($obj) { $newval2 = trim($obj->email); $isvalid = isValidEmail($newval2); - if (empty($resarray[$newval2])) $resarray[$newval2] = array('type'=> 'touser', 'code'=>trim($obj->code), 'emaildesc'=>'User id '.$obj->rowid, 'email'=>$newval2, 'userid'=>$obj->rowid, 'isemailvalid'=>$isvalid); + if (empty($resarray[$newval2])) { + $resarray[$newval2] = array('type'=> 'touser', 'code'=>trim($obj->code), 'emaildesc'=>'User id '.$obj->rowid, 'email'=>$newval2, 'userid'=>$obj->rowid, 'isemailvalid'=>$isvalid); + } } $i++; } @@ -244,48 +256,55 @@ class Notify } } - if (!$error) - { - if (in_array('global', $scope)) - { + if (!$error) { + if (in_array('global', $scope)) { // List of notifications enabled for fixed email - foreach ($conf->global as $key => $val) - { - if ($notifcode) - { - if ($val == '' || !preg_match('/^NOTIFICATION_FIXEDEMAIL_'.$notifcode.'_THRESHOLD_HIGHER_(.*)$/', $key, $reg)) continue; + foreach ($conf->global as $key => $val) { + if ($notifcode) { + if ($val == '' || !preg_match('/^NOTIFICATION_FIXEDEMAIL_'.$notifcode.'_THRESHOLD_HIGHER_(.*)$/', $key, $reg)) { + continue; + } } else { - if ($val == '' || !preg_match('/^NOTIFICATION_FIXEDEMAIL_.*_THRESHOLD_HIGHER_(.*)$/', $key, $reg)) continue; + if ($val == '' || !preg_match('/^NOTIFICATION_FIXEDEMAIL_.*_THRESHOLD_HIGHER_(.*)$/', $key, $reg)) { + continue; + } } $threshold = (float) $reg[1]; - if ($valueforthreshold < $threshold) continue; + if ($valueforthreshold < $threshold) { + continue; + } $tmpemail = explode(',', $val); - foreach ($tmpemail as $key2 => $val2) - { + foreach ($tmpemail as $key2 => $val2) { $newval2 = trim($val2); - if ($newval2 == '__SUPERVISOREMAIL__') - { - if ($user->fk_user > 0) - { + if ($newval2 == '__SUPERVISOREMAIL__') { + if ($user->fk_user > 0) { $tmpuser = new User($this->db); $tmpuser->fetch($user->fk_user); - if ($tmpuser->email) $newval2 = trim($tmpuser->email); - else $newval2 = ''; - } else $newval2 = ''; + if ($tmpuser->email) { + $newval2 = trim($tmpuser->email); + } else { + $newval2 = ''; + } + } else { + $newval2 = ''; + } } - if ($newval2) - { + if ($newval2) { $isvalid = isValidEmail($newval2, 0); - if (empty($resarray[$newval2])) $resarray[$newval2] = array('type'=> 'tofixedemail', 'code'=>trim($key), 'emaildesc'=>trim($val2), 'email'=>$newval2, 'isemailvalid'=>$isvalid); + if (empty($resarray[$newval2])) { + $resarray[$newval2] = array('type'=> 'tofixedemail', 'code'=>trim($key), 'emaildesc'=>trim($val2), 'email'=>$newval2, 'isemailvalid'=>$isvalid); + } } } } } } - if ($error) return -1; + if ($error) { + return -1; + } //var_dump($resarray); return $resarray; @@ -309,11 +328,12 @@ class Notify global $dolibarr_main_url_root; global $action; - if (!in_array($notifcode, $this->arrayofnotifsupported)) return 0; + if (!in_array($notifcode, $this->arrayofnotifsupported)) { + return 0; + } include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - if (!is_object($hookmanager)) - { + if (!is_object($hookmanager)) { include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; $hookmanager = new HookManager($this->db); } @@ -330,7 +350,9 @@ class Notify // Define some vars $application = 'Dolibarr'; - if (!empty($conf->global->MAIN_APPLICATION_TITLE)) $application = $conf->global->MAIN_APPLICATION_TITLE; + if (!empty($conf->global->MAIN_APPLICATION_TITLE)) { + $application = $conf->global->MAIN_APPLICATION_TITLE; + } $replyto = $conf->notification->email_from; $object_type = ''; $link = ''; @@ -343,8 +365,7 @@ class Notify $sql = ''; // Check notification per third party - if (!empty($object->socid) && $object->socid > 0) - { + if (!empty($object->socid) && $object->socid > 0) { $sql .= "SELECT 'tocontactid' as type_target, c.email, c.rowid as cid, c.lastname, c.firstname, c.default_lang,"; $sql .= " a.rowid as adid, a.label, a.code, n.rowid, n.type"; $sql .= " FROM ".MAIN_DB_PREFIX."socpeople as c,"; @@ -354,8 +375,11 @@ class Notify $sql .= " WHERE n.fk_contact = c.rowid AND a.rowid = n.fk_action"; $sql .= " AND n.fk_soc = s.rowid"; $sql .= " AND c.statut = 1"; - if (is_numeric($notifcode)) $sql .= " AND n.fk_action = ".$notifcode; // Old usage - else $sql .= " AND a.code = '".$this->db->escape($notifcode)."'"; // New usage + if (is_numeric($notifcode)) { + $sql .= " AND n.fk_action = ".$notifcode; // Old usage + } else { + $sql .= " AND a.code = '".$this->db->escape($notifcode)."'"; // New usage + } $sql .= " AND s.rowid = ".$object->socid; $sql .= "\nUNION\n"; @@ -369,41 +393,42 @@ class Notify $sql .= " ".MAIN_DB_PREFIX."notify_def as n"; $sql .= " WHERE n.fk_user = c.rowid AND a.rowid = n.fk_action"; $sql .= " AND c.statut = 1"; - if (is_numeric($notifcode)) $sql .= " AND n.fk_action = ".$notifcode; // Old usage - else $sql .= " AND a.code = '".$this->db->escape($notifcode)."'"; // New usage + if (is_numeric($notifcode)) { + $sql .= " AND n.fk_action = ".$notifcode; // Old usage + } else { + $sql .= " AND a.code = '".$this->db->escape($notifcode)."'"; // New usage + } $result = $this->db->query($sql); - if ($result) - { + if ($result) { $num = $this->db->num_rows($result); $projtitle = ''; - if (!empty($object->fk_project)) - { + if (!empty($object->fk_project)) { require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; $proj = new Project($this->db); $proj->fetch($object->fk_project); $projtitle = '('.$proj->title.')'; } - if ($num > 0) - { + if ($num > 0) { $i = 0; - while ($i < $num && !$error) // For each notification couple defined (third party/actioncode) - { + while ($i < $num && !$error) { // For each notification couple defined (third party/actioncode) $obj = $this->db->fetch_object($result); $sendto = dolGetFirstLastname($obj->firstname, $obj->lastname)." <".$obj->email.">"; $notifcodedefid = $obj->adid; $trackid = ''; - if ($obj->type_target == 'tocontactid') $trackid = 'con'.$obj->id; - if ($obj->type_target == 'touserid') $trackid = 'use'.$obj->id; + if ($obj->type_target == 'tocontactid') { + $trackid = 'con'.$obj->id; + } + if ($obj->type_target == 'touserid') { + $trackid = 'use'.$obj->id; + } - if (dol_strlen($obj->email)) - { + if (dol_strlen($obj->email)) { // Set output language $outputlangs = $langs; - if ($obj->default_lang && $obj->default_lang != $langs->defaultlang) - { + if ($obj->default_lang && $obj->default_lang != $langs->defaultlang) { $outputlangs = new Translate('', $conf); $outputlangs->setDefaultLang($obj->default_lang); $outputlangs->loadLangs(array("main", "other")); @@ -511,8 +536,7 @@ class Notify } $ref = dol_sanitizeFileName($newref); $pdf_path = $dir_output."/".$ref."/".$ref.".pdf"; - if (!dol_is_file($pdf_path)) - { + if (!dol_is_file($pdf_path)) { // We can't add PDF as it is not generated yet. $filepdf = ''; } else { @@ -525,13 +549,18 @@ class Notify $message .= $mesg; $parameters = array('notifcode'=>$notifcode, 'sendto'=>$sendto, 'replyto'=>$replyto, 'file'=>$filename_list, 'mimefile'=>$mimetype_list, 'filename'=>$mimefilename_list); - if (!isset($action)) $action = ''; + if (!isset($action)) { + $action = ''; + } $reshook = $hookmanager->executeHooks('formatNotificationMessage', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks - if (empty($reshook)) - { - if (!empty($hookmanager->resArray['subject'])) $subject .= $hookmanager->resArray['subject']; - if (!empty($hookmanager->resArray['message'])) $message .= $hookmanager->resArray['message']; + if (empty($reshook)) { + if (!empty($hookmanager->resArray['subject'])) { + $subject .= $hookmanager->resArray['subject']; + } + if (!empty($hookmanager->resArray['message'])) { + $message .= $hookmanager->resArray['message']; + } } $mailfile = new CMailFile( @@ -553,17 +582,15 @@ class Notify 'notification' ); - if ($mailfile->sendfile()) - { + if ($mailfile->sendfile()) { if ($obj->type_target == 'touserid') { - $sql = "INSERT INTO ".MAIN_DB_PREFIX."notify (daten, fk_action, fk_soc, fk_user, type, objet_type, type_target, objet_id, email)"; + $sql = "INSERT INTO ".MAIN_DB_PREFIX."notify (daten, fk_action, fk_soc, fk_user, type, objet_type, type_target, objet_id, email)"; $sql .= " VALUES ('".$this->db->idate(dol_now())."', ".$notifcodedefid.", ".($object->socid ? $object->socid : 'null').", ".$obj->cid.", '".$obj->type."', '".$object_type."', '".$obj->type_target."', ".$object->id.", '".$this->db->escape($obj->email)."')"; } else { $sql = "INSERT INTO ".MAIN_DB_PREFIX."notify (daten, fk_action, fk_soc, fk_contact, type, objet_type, type_target, objet_id, email)"; $sql .= " VALUES ('".$this->db->idate(dol_now())."', ".$notifcodedefid.", ".($object->socid ? $object->socid : 'null').", ".$obj->cid.", '".$obj->type."', '".$object_type."', '".$obj->type_target."', ".$object->id.", '".$this->db->escape($obj->email)."')"; } - if (!$this->db->query($sql)) - { + if (!$this->db->query($sql)) { dol_print_error($this->db); } } else { @@ -579,23 +606,22 @@ class Notify dol_syslog("No notification to thirdparty sent, nothing into notification setup for the thirdparty socid = ".(empty($object->socid) ? '' : $object->socid)); } } else { - $error++; + $error++; $this->errors[] = $this->db->lasterror(); dol_syslog("Failed to get list of notification to send ".$this->db->lasterror(), LOG_ERR); - return -1; + return -1; } // Check notification using fixed email - if (!$error) - { - foreach ($conf->global as $key => $val) - { + if (!$error) { + foreach ($conf->global as $key => $val) { $reg = array(); - if ($val == '' || !preg_match('/^NOTIFICATION_FIXEDEMAIL_'.$notifcode.'_THRESHOLD_HIGHER_(.*)$/', $key, $reg)) continue; + if ($val == '' || !preg_match('/^NOTIFICATION_FIXEDEMAIL_'.$notifcode.'_THRESHOLD_HIGHER_(.*)$/', $key, $reg)) { + continue; + } $threshold = (float) $reg[1]; - if (!empty($object->total_ht) && $object->total_ht <= $threshold) - { + if (!empty($object->total_ht) && $object->total_ht <= $threshold) { dol_syslog("A notification is requested for notifcode = ".$notifcode." but amount = ".$object->total_ht." so lower than threshold = ".$threshold.". We discard this notification"); continue; } @@ -604,7 +630,9 @@ class Notify $sendto = $conf->global->$param; $notifcodedefid = dol_getIdFromCode($this->db, $notifcode, 'c_action_trigger', 'code', 'rowid'); - if ($notifcodedefid <= 0) dol_print_error($this->db, 'Failed to get id from code'); + if ($notifcodedefid <= 0) { + dol_print_error($this->db, 'Failed to get id from code'); + } $trackid = ''; $object_type = ''; @@ -721,8 +749,7 @@ class Notify } $ref = dol_sanitizeFileName($newref); $pdf_path = $dir_output."/".$ref."/".$ref.".pdf"; - if (!dol_is_file($pdf_path)) - { + if (!dol_is_file($pdf_path)) { // We can't add PDF as it is not generated yet. $filepdf = ''; } else { @@ -736,14 +763,14 @@ class Notify $message = nl2br($message); // Replace keyword __SUPERVISOREMAIL__ - if (preg_match('/__SUPERVISOREMAIL__/', $sendto)) - { + if (preg_match('/__SUPERVISOREMAIL__/', $sendto)) { $newval = ''; - if ($user->fk_user > 0) - { + if ($user->fk_user > 0) { $supervisoruser = new User($this->db); $supervisoruser->fetch($user->fk_user); - if ($supervisoruser->email) $newval = trim(dolGetFirstLastname($supervisoruser->firstname, $supervisoruser->lastname).' <'.$supervisoruser->email.'>'); + if ($supervisoruser->email) { + $newval = trim(dolGetFirstLastname($supervisoruser->firstname, $supervisoruser->lastname).' <'.$supervisoruser->email.'>'); + } } dol_syslog("Replace the __SUPERVISOREMAIL__ key into recipient email string with ".$newval); $sendto = preg_replace('/__SUPERVISOREMAIL__/', $newval, $sendto); @@ -752,14 +779,16 @@ class Notify $sendto = preg_replace('/[\s,]+$/', '', $sendto); // Clean end of string } - if ($sendto) - { + if ($sendto) { $parameters = array('notifcode'=>$notifcode, 'sendto'=>$sendto, 'replyto'=>$replyto, 'file'=>$filename_list, 'mimefile'=>$mimetype_list, 'filename'=>$mimefilename_list); $reshook = $hookmanager->executeHooks('formatNotificationMessage', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks - if (empty($reshook)) - { - if (!empty($hookmanager->resArray['subject'])) $subject .= $hookmanager->resArray['subject']; - if (!empty($hookmanager->resArray['message'])) $message .= $hookmanager->resArray['message']; + if (empty($reshook)) { + if (!empty($hookmanager->resArray['subject'])) { + $subject .= $hookmanager->resArray['subject']; + } + if (!empty($hookmanager->resArray['message'])) { + $message .= $hookmanager->resArray['message']; + } } $mailfile = new CMailFile( $subject, @@ -780,12 +809,10 @@ class Notify 'notification' ); - if ($mailfile->sendfile()) - { + if ($mailfile->sendfile()) { $sql = "INSERT INTO ".MAIN_DB_PREFIX."notify (daten, fk_action, fk_soc, fk_contact, type, type_target, objet_type, objet_id, email)"; $sql .= " VALUES ('".$this->db->idate(dol_now())."', ".$notifcodedefid.", ".($object->socid ? $object->socid : 'null').", null, 'email', 'tofixedemail', '".$object_type."', ".$object->id.", '".$this->db->escape($conf->global->$param)."')"; - if (!$this->db->query($sql)) - { + if (!$this->db->query($sql)) { dol_print_error($this->db); } } else { @@ -796,7 +823,10 @@ class Notify } } - if (!$error) return $num; - else return -1 * $error; + if (!$error) { + return $num; + } else { + return -1 * $error; + } } } From abbe340723409edde7ffebb3ff02876e85a1ba2b Mon Sep 17 00:00:00 2001 From: Francis Appels Date: Mon, 21 Dec 2020 12:24:45 +0100 Subject: [PATCH 06/23] FIX missing reception link in stock movement list. --- htdocs/product/stock/class/mouvementstock.class.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/htdocs/product/stock/class/mouvementstock.class.php b/htdocs/product/stock/class/mouvementstock.class.php index a23846c3e08..2429a4c09c5 100644 --- a/htdocs/product/stock/class/mouvementstock.class.php +++ b/htdocs/product/stock/class/mouvementstock.class.php @@ -981,6 +981,10 @@ class MouvementStock extends CommonObject require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; $origin = new User($this->db); break; + case 'reception': + require_once DOL_DOCUMENT_ROOT.'/reception/class/reception.class.php'; + $origin = new Reception($this->db); + break; default: if ($origintype) From 0195c11437293088131a9e475a760b06ede8ba22 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 21 Dec 2020 12:58:03 +0100 Subject: [PATCH 07/23] Add missing field required for real funnel of prospection. --- htdocs/install/mysql/migration/12.0.0-13.0.0.sql | 3 +++ htdocs/install/mysql/tables/llx_projet.sql | 1 + 2 files changed, 4 insertions(+) diff --git a/htdocs/install/mysql/migration/12.0.0-13.0.0.sql b/htdocs/install/mysql/migration/12.0.0-13.0.0.sql index e391787479d..309d4d4b170 100644 --- a/htdocs/install/mysql/migration/12.0.0-13.0.0.sql +++ b/htdocs/install/mysql/migration/12.0.0-13.0.0.sql @@ -552,3 +552,6 @@ INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES -- VMYSQL4.1 INSERT INTO llx_boxes_def (file, entity) SELECT 'box_scheduled_jobs.php', 1 FROM DUAL WHERE NOT EXISTS (SELECT * FROM llx_boxes_def WHERE file = 'box_scheduled_jobs.php' AND entity = 1); ALTER TABLE llx_product_fournisseur_price ADD COLUMN packaging varchar(64); + +ALTER TABLE llx_projet ADD COLUMN fk_opp_status_end integer DEFAULT NULL; + diff --git a/htdocs/install/mysql/tables/llx_projet.sql b/htdocs/install/mysql/tables/llx_projet.sql index a36adb3a672..1b95444b3a1 100644 --- a/htdocs/install/mysql/tables/llx_projet.sql +++ b/htdocs/install/mysql/tables/llx_projet.sql @@ -35,6 +35,7 @@ create table llx_projet fk_statut integer DEFAULT 0 NOT NULL, -- open or close fk_opp_status integer DEFAULT NULL, -- if project is used to manage opportunities opp_percent double(5,2), + fk_opp_status_end integer DEFAULT NULL, -- if project is used to manage opportunities (the opportunity status the project has when set to lose) date_close datetime DEFAULT NULL, fk_user_close integer DEFAULT NULL, note_private text, From 7d0e71165a47f4748d4b70cd30975b71f4f42126 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 21 Dec 2020 14:40:27 +0100 Subject: [PATCH 08/23] Clean code --- htdocs/core/class/dolgraph.class.php | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/core/class/dolgraph.class.php b/htdocs/core/class/dolgraph.class.php index 4495c5ae50d..5fcc7b00c91 100644 --- a/htdocs/core/class/dolgraph.class.php +++ b/htdocs/core/class/dolgraph.class.php @@ -891,7 +891,6 @@ class DolGraph $color1 = sprintf("%02x%02x%02x", $this->bgcolorgrid[0], $this->bgcolorgrid[0], $this->bgcolorgrid[2]); $color2 = sprintf("%02x%02x%02x", $this->bgcolorgrid[0], $this->bgcolorgrid[1], $this->bgcolorgrid[2]); $this->stringtoshow .= ', grid: { hoverable: true, backgroundColor: { colors: ["#' . $color1 . '", "#' . $color2 . '"] }, borderWidth: 1, borderColor: \'#e6e6e6\', tickColor : \'#e6e6e6\' }' . "\n"; - //$this->stringtoshow.=', shadowSize: 20'."\n"; TODO Uncommet this $this->stringtoshow .= '});' . "\n"; $this->stringtoshow .= '}' . "\n"; } From d05f9c42f5317df9a44b6c83896df8ecba09c526 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 21 Dec 2020 14:43:23 +0100 Subject: [PATCH 09/23] Fix bad dir --- htdocs/salaries/list.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/htdocs/salaries/list.php b/htdocs/salaries/list.php index 26477900be2..3e2694cf445 100644 --- a/htdocs/salaries/list.php +++ b/htdocs/salaries/list.php @@ -154,9 +154,7 @@ if (empty($reshook)) // Mass actions $objectclass = 'PaymentSalary'; $objectlabel = 'SalariesPayments'; - $permissiontoread = $user->rights->salaries->read; - $permissiontodelete = $user->rights->salaries->delete; - $uploaddir = $conf->bom->dir_output; + $uploaddir = $conf->salaries->dir_output; include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; // Validate records From eebdd0bd7a13e160de4de89015a220b8ba400b96 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 21 Dec 2020 14:54:20 +0100 Subject: [PATCH 10/23] Fix missing date value --- htdocs/salaries/list.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/htdocs/salaries/list.php b/htdocs/salaries/list.php index 3e2694cf445..b8a0ba69ef7 100644 --- a/htdocs/salaries/list.php +++ b/htdocs/salaries/list.php @@ -306,7 +306,7 @@ print '
'; print '
'; print $form->selectDate($search_date_start ? $search_date_start : -1, 'search_date_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From')); @@ -315,6 +315,9 @@ print '
'; print $form->selectDate($search_date_end ? $search_date_end : -1, 'search_date_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to')); print '
'; print '
'; +print ''; $form->select_types_paiements($search_type_id, 'search_type_id', '', 0, 1, 1, 16); @@ -350,7 +353,8 @@ print '
'.dol_print_date($db->jdate($obj->datep), 'day')."'.dol_print_date($db->jdate($obj->datev), 'day')."'.$langs->trans("PaymentTypeShort".$obj->payment_code).' '.$obj->num_payment.'
'."\n"; @@ -993,9 +997,8 @@ if ($resql) while ($i < min($num, $limit)) { $objp = $db->fetch_object($resql); - // If we are in a situation where we need/can show balance, we calculate the start of balance - if (!$balancecalculated && (!empty($arrayfields['balancebefore']['checked']) || !empty($arrayfields['balance']['checked'])) && $mode_balance_ok) + if (!$balancecalculated && (!empty($arrayfields['balancebefore']['checked']) || !empty($arrayfields['balance']['checked'])) && ($mode_balance_ok || $search_conciliated === '0')) { if (!$search_account) { @@ -1016,11 +1019,9 @@ if ($resql) $sqlforbalance .= " AND (b.datev < '".$db->idate($db->jdate($objp->dv))."' OR (b.datev = '".$db->idate($db->jdate($objp->dv))."' AND (b.dateo < '".$db->idate($db->jdate($objp->do))."' OR (b.dateo = '".$db->idate($db->jdate($objp->do))."' AND b.rowid < ".$objp->rowid."))))"; $resqlforbalance = $db->query($sqlforbalance); //print $sqlforbalance; - if ($resqlforbalance) - { + if ($resqlforbalance) { $objforbalance = $db->fetch_object($resqlforbalance); - if ($objforbalance) - { + if ($objforbalance) { // If sort is desc,desc,desc then total of previous date + amount is the balancebefore of the previous line before the line to show if ($sortfield == 'b.datev,b.dateo,b.rowid' && $sortorder == 'desc,desc,desc') { @@ -1081,24 +1082,30 @@ if ($resql) if (!empty($arrayfields['balancebefore']['checked'])) { print ''; } if (!empty($arrayfields['balance']['checked'])) { print ''; + } + if (!empty($arrayfields['b.num_releve']['checked'])) + { + print ''; } - - print ''; print ''; From 7b15197ded678aa68189430580b7d49ea342aa5f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 22 Dec 2020 10:56:27 +0100 Subject: [PATCH 23/23] Trans --- htdocs/langs/en_US/admin.lang | 1 - htdocs/langs/en_US/main.lang | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 537da1102e8..e3512280644 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -87,7 +87,6 @@ ShowPreview=Show preview ShowHideDetails=Show-Hide details PreviewNotAvailable=Preview not available ThemeCurrentlyActive=Theme currently active -CurrentTimeZone=TimeZone PHP (server) MySQLTimeZone=TimeZone MySql (database) TZHasNoEffect=Dates are stored and returned by database server as if they were kept as submitted string. The timezone has effect only when using the UNIX_TIMESTAMP function (that should not be used by Dolibarr, so database TZ should have no effect, even if changed after data was entered). Space=Space diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index c2eae911053..c6ce8ca9be0 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -28,6 +28,7 @@ NoTemplateDefined=No template available for this email type AvailableVariables=Available substitution variables NoTranslation=No translation Translation=Translation +CurrentTimeZone=TimeZone PHP (server) EmptySearchString=Enter non empty search criterias EnterADateCriteria=Enter a date criteria NoRecordFound=No record found
'; - print price(price2num($balance, 'MT'), 1, $langs); + if ($search_conciliated !== '0') { + print price(price2num($balance, 'MT'), 1, $langs); + } print ''; - print price(price2num($balance, 'MT'), 1, $langs); + if ($search_conciliated !== '0') { + print price(price2num($balance, 'MT'), 1, $langs); + } + print ''; + print ''; + print ' '; print ''; - print ''; - print ' '; - print ''; print ' '; print '