diff --git a/build/phpstan/phpstan-baseline.neon b/build/phpstan/phpstan-baseline.neon index 9b055ffc31c..d8806427808 100644 --- a/build/phpstan/phpstan-baseline.neon +++ b/build/phpstan/phpstan-baseline.neon @@ -1188,18 +1188,6 @@ parameters: count: 1 path: ../../htdocs/adherents/partnership.php - - - message: '#^Variable \$label might not be defined\.$#' - identifier: variable.undefined - count: 1 - path: ../../htdocs/adherents/stats/geo.php - - - - message: '#^Variable \$theme_datacolor might not be defined\.$#' - identifier: variable.undefined - count: 2 - path: ../../htdocs/adherents/stats/geo.php - - message: '#^Negated boolean expression is always true\.$#' identifier: booleanNot.alwaysTrue @@ -7626,12 +7614,6 @@ parameters: count: 3 path: ../../htdocs/compta/tva/payments.php - - - message: '#^Call to function is_array\(\) with list\ will always evaluate to true\.$#' - identifier: function.alreadyNarrowedType - count: 1 - path: ../../htdocs/compta/tva/quadri_detail.php - - message: '#^Call to function is_array\(\) with list\ will always evaluate to true\.$#' identifier: function.alreadyNarrowedType @@ -35682,114 +35664,18 @@ parameters: count: 1 path: ../../scripts/bank/export-bank-receipts.php - - - message: '#^Variable \$conf might not be defined\.$#' - identifier: variable.undefined - count: 6 - path: ../../scripts/company/sync_contacts_dolibarr2ldap.php - - - - message: '#^Variable \$db might not be defined\.$#' - identifier: variable.undefined - count: 5 - path: ../../scripts/company/sync_contacts_dolibarr2ldap.php - - - - message: '#^Variable \$hookmanager might not be defined\.$#' - identifier: variable.undefined - count: 1 - path: ../../scripts/company/sync_contacts_dolibarr2ldap.php - - - - message: '#^Variable \$langs might not be defined\.$#' - identifier: variable.undefined - count: 4 - path: ../../scripts/company/sync_contacts_dolibarr2ldap.php - - - - message: '#^Variable \$user might not be defined\.$#' - identifier: variable.undefined - count: 2 - path: ../../scripts/company/sync_contacts_dolibarr2ldap.php - - - - message: '#^Variable \$conf might not be defined\.$#' - identifier: variable.undefined - count: 3 - path: ../../scripts/contracts/email_expire_services_to_customers.php - - - - message: '#^Variable \$db might not be defined\.$#' - identifier: variable.undefined - count: 8 - path: ../../scripts/contracts/email_expire_services_to_customers.php - - - - message: '#^Variable \$hookmanager might not be defined\.$#' - identifier: variable.undefined - count: 1 - path: ../../scripts/contracts/email_expire_services_to_customers.php - - - - message: '#^Variable \$langs might not be defined\.$#' - identifier: variable.undefined - count: 3 - path: ../../scripts/contracts/email_expire_services_to_customers.php - - - - message: '#^Variable \$conf might not be defined\.$#' - identifier: variable.undefined - count: 3 - path: ../../scripts/contracts/email_expire_services_to_representatives.php - - - - message: '#^Variable \$hookmanager might not be defined\.$#' - identifier: variable.undefined - count: 1 - path: ../../scripts/contracts/email_expire_services_to_representatives.php - - - - message: '#^Variable \$langs might not be defined\.$#' - identifier: variable.undefined - count: 4 - path: ../../scripts/contracts/email_expire_services_to_representatives.php - - message: '#^Result of \|\| is always false\.$#' identifier: booleanOr.alwaysFalse count: 1 path: ../../scripts/doc/regenerate_docs.php - - - message: '#^Variable \$conf might not be defined\.$#' - identifier: variable.undefined - count: 1 - path: ../../scripts/doc/regenerate_docs.php - - - - message: '#^Variable \$db might not be defined\.$#' - identifier: variable.undefined - count: 4 - path: ../../scripts/doc/regenerate_docs.php - - message: '#^Variable \$dir in empty\(\) always exists and is not falsy\.$#' identifier: empty.variable count: 1 path: ../../scripts/doc/regenerate_docs.php - - - message: '#^Variable \$hookmanager might not be defined\.$#' - identifier: variable.undefined - count: 1 - path: ../../scripts/doc/regenerate_docs.php - - - - message: '#^Variable \$langs might not be defined\.$#' - identifier: variable.undefined - count: 2 - path: ../../scripts/doc/regenerate_docs.php - - message: '#^Variable \$newlang in empty\(\) always exists and is always falsy\.$#' identifier: empty.variable @@ -35808,30 +35694,6 @@ parameters: count: 1 path: ../../scripts/emailings/mailing-send.php - - - message: '#^Variable \$conf might not be defined\.$#' - identifier: variable.undefined - count: 2 - path: ../../scripts/emailings/mailing-send.php - - - - message: '#^Variable \$db might not be defined\.$#' - identifier: variable.undefined - count: 1 - path: ../../scripts/emailings/mailing-send.php - - - - message: '#^Variable \$hookmanager might not be defined\.$#' - identifier: variable.undefined - count: 1 - path: ../../scripts/emailings/mailing-send.php - - - - message: '#^Variable \$langs might not be defined\.$#' - identifier: variable.undefined - count: 4 - path: ../../scripts/emailings/mailing-send.php - - message: '#^Variable \$mesg might not be defined\.$#' identifier: variable.undefined diff --git a/htdocs/accountancy/admin/subaccount.php b/htdocs/accountancy/admin/subaccount.php index e5a37b8b709..8790cb6c9bc 100644 --- a/htdocs/accountancy/admin/subaccount.php +++ b/htdocs/accountancy/admin/subaccount.php @@ -54,14 +54,6 @@ $search_subaccount = GETPOST('search_subaccount', 'alpha'); $search_label = GETPOST('search_label', 'alpha'); $search_type = GETPOST('search_type', 'intcomma'); -// Security check -if ($user->socid > 0) { - accessforbidden(); -} -if (!$user->hasRight('accounting', 'chartofaccount')) { - accessforbidden(); -} - // Load variable for pagination $limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'aZ09comma'); @@ -92,6 +84,14 @@ if (getDolGlobalInt('MAIN_FEATURES_LEVEL') < 2) { unset($arrayfields['reconcilable']); } +// Security check +if ($user->socid > 0) { + accessforbidden(); +} +if (!$user->hasRight('accounting', 'chartofaccount')) { // after this test, $user->hasRight('accounting', 'chartofaccount') is always valid + accessforbidden(); +} + /* * Actions @@ -124,6 +124,13 @@ if (empty($reshook)) { $search_type = ""; $search_array_options = array(); } + + if ($action == 'enable' /* && $user->hasRight('accounting', 'chartofaccount') */) { // test useless + setEventMessages($langs->trans("FeatureNotYetAvailable"), null, 'errors'); + } + if ($action == 'disable' /* && $user->hasRight('accounting', 'chartofaccount') */) { + setEventMessages($langs->trans("FeatureNotYetAvailable"), null, 'errors'); + } } @@ -142,7 +149,7 @@ llxHeader('', $title, $help_url, '', 0, 0, '', '', '', 'mod-accountancy page-adm // Customer -$sql = "SELECT sa.rowid, sa.nom as label, sa.code_compta as subaccount, '1' as type, sa.entity, sa.client as nature"; +$sql = "SELECT sa.rowid, sa.nom as label, sa.code_compta as subaccount, '1' as type, sa.entity, sa.client as nature, sa.fournisseur as nature2"; $sql .= " FROM ".MAIN_DB_PREFIX."societe sa"; $sql .= " WHERE sa.entity IN (".getEntity('societe').")"; $sql .= " AND sa.code_compta <> ''"; @@ -163,7 +170,6 @@ if (strlen(trim($search_subaccount))) { } } - //var_dump($search_subaccount); exit; if ($search_subaccount_tmp) { if ($weremovedsomezero) { $search_subaccount_tmp_clean = $search_subaccount_tmp; @@ -190,7 +196,8 @@ if (!empty($search_type) && $search_type >= 0) { // Supplier $sql .= " UNION "; -$sql .= " SELECT sa.rowid, sa.nom as label, sa.code_compta_fournisseur as subaccount, '2' as type, sa.entity, '0' as nature FROM ".MAIN_DB_PREFIX."societe sa"; +$sql .= " SELECT sa.rowid, sa.nom as label, sa.code_compta_fournisseur as subaccount, '2' as type, sa.entity, sa.client as nature, sa.fournisseur as nature2"; +$sql .= " FROM ".MAIN_DB_PREFIX."societe sa"; $sql .= " WHERE sa.entity IN (".getEntity('societe').")"; $sql .= " AND sa.code_compta_fournisseur <> ''"; //print $sql; @@ -237,7 +244,8 @@ if (!empty($search_type) && $search_type >= 0) { // User - Employee $sql .= " UNION "; -$sql .= " SELECT u.rowid, u.lastname as label, u.accountancy_code as subaccount, '3' as type, u.entity, '0' as nature FROM ".MAIN_DB_PREFIX."user u"; +$sql .= " SELECT u.rowid, u.lastname as label, u.accountancy_code as subaccount, '3' as type, u.entity, '0' as nature, '0' as nature2"; +$sql .= " FROM ".MAIN_DB_PREFIX."user u"; $sql .= " WHERE u.entity IN (".getEntity('user').")"; $sql .= " AND u.accountancy_code <> ''"; //print $sql; @@ -368,7 +376,7 @@ if ($resql) { print ''; } if (!empty($arrayfields['type']['checked'])) { - print ''.$form->selectarray('search_type', array('1'=>$langs->trans('Customer'), '2'=>$langs->trans('Supplier'), '3'=>$langs->trans('Employee')), $search_type, 1).''; + print ''.$form->selectarray('search_type', array('1'=>$langs->trans('Customer').' / '.$langs->trans("Prospect"), '2'=>$langs->trans('Supplier'), '3'=>$langs->trans('Employee')), $search_type, 1).''; } if (getDolGlobalInt('MAIN_FEATURES_LEVEL') >= 2) { if (!empty($arrayfields['reconcilable']['checked'])) { @@ -409,12 +417,25 @@ if ($resql) { } print "\n"; + $companystatic = new Societe($db); + $totalarray = array(); $totalarray['nbfield'] = 0; $i = 0; while ($i < min($num, $limit)) { $obj = $db->fetch_object($resql); + if ($obj->type == 1) { + $companystatic->id = $obj->id; + $companystatic->client = $obj->nature; + $companystatic->fournisseur = 0; + } + if ($obj->type == 2) { + $companystatic->id = $obj->id; + $companystatic->client = 0; + $companystatic->fournisseur = $obj->nature2; + } + print ''; // Action column @@ -466,7 +487,12 @@ if ($resql) { // Customer if ($obj->type == 1) { - $s .= ''.$langs->trans("Customer").''; + $s .= ''; + $s .= $langs->trans("Customer"); + $s .= ''; + if ($obj->nature == 2) { + $s .= ' ('.$langs->trans("Prospect").')'; + } } elseif ($obj->type == 2) { // Supplier $s .= ''.$langs->trans("Supplier").''; @@ -475,9 +501,6 @@ if ($resql) { $s .= ''.$langs->trans("Employee").''; } print $s; - if ($obj->nature == 2) { - print ' ('.$langs->trans("Prospect").')'; - } print ''; if (!$i) { $totalarray['nbfield']++; @@ -489,11 +512,11 @@ if ($resql) { if (!empty($arrayfields['reconcilable']['checked'])) { print ''; if (empty($obj->reconcilable)) { - print ''; + print ''; print img_picto($langs->trans("Disabled"), 'switch_off'); print ''; } else { - print ''; + print ''; print img_picto($langs->trans("Activated"), 'switch_on'); print ''; } diff --git a/htdocs/api/class/api.class.php b/htdocs/api/class/api.class.php index 75d92306f16..433f08bcd80 100644 --- a/htdocs/api/class/api.class.php +++ b/htdocs/api/class/api.class.php @@ -418,6 +418,6 @@ class DolibarrApi */ protected static function _forge_criteria_callback($matches) { - return dolForgeCriteriaCallback($matches); + return dolForgeSQLCriteriaCallback($matches); } } diff --git a/htdocs/compta/facture/class/facturestats.class.php b/htdocs/compta/facture/class/facturestats.class.php index e6d8b689ac2..4d69db45350 100644 --- a/htdocs/compta/facture/class/facturestats.class.php +++ b/htdocs/compta/facture/class/facturestats.class.php @@ -136,7 +136,7 @@ class FactureStats extends Stats } if ($categid) { - $this->where .= ' AND EXISTS (SELECT rowid FROM '.MAIN_DB_PREFIX.'categorie_societe as cats WHERE cats.fk_soc = f.fk_soc AND cats.fk_categorie = '.((int) $categid).')'; + $this->where .= ' AND EXISTS (SELECT cats.fk_categorie FROM '.MAIN_DB_PREFIX.'categorie_societe as cats WHERE cats.fk_soc = f.fk_soc AND cats.fk_categorie = '.((int) $categid).')'; } } diff --git a/htdocs/compta/facture/prelevement.php b/htdocs/compta/facture/prelevement.php index 29d6488f4ab..25eb5c6f532 100644 --- a/htdocs/compta/facture/prelevement.php +++ b/htdocs/compta/facture/prelevement.php @@ -990,7 +990,7 @@ if ($object->id > 0) { // Iban print ''; - print $obj->iban; + print dolDecrypt($obj->iban); if ($obj->iban && $obj->bic) { print " / "; } @@ -1119,7 +1119,7 @@ if ($object->id > 0) { // Iban print ''; - print $obj->iban; + print dolDecrypt($obj->iban); if ($obj->iban && $obj->bic) { print " / "; } diff --git a/htdocs/compta/prelevement/class/bonprelevement.class.php b/htdocs/compta/prelevement/class/bonprelevement.class.php index 55222f6c4cd..7fd7ea75d88 100644 --- a/htdocs/compta/prelevement/class/bonprelevement.class.php +++ b/htdocs/compta/prelevement/class/bonprelevement.class.php @@ -1068,7 +1068,7 @@ class BonPrelevement extends CommonObject // phpcs:enable global $conf, $langs, $user; - dol_syslog(__METHOD__ . " Bank=" . $banque . " Office=" . $agence . " mode=" . $mode . " format=" . $format, LOG_DEBUG); + dol_syslog(__METHOD__ . " Bank=".$banque." Office=".$agence." mode=".$mode." format=".$format." type=".$type." did=".$did." fk_bank_account=".$fk_bank_account." sourcetype=".$sourcetype, LOG_DEBUG); require_once DOL_DOCUMENT_ROOT . "/compta/facture/class/facture.class.php"; require_once DOL_DOCUMENT_ROOT . "/societe/class/societe.class.php"; @@ -1150,7 +1150,7 @@ class BonPrelevement extends CommonObject dol_syslog(__METHOD__ . " Read invoices for did=" . ((int) $did), LOG_DEBUG); $sql = "SELECT f.rowid, pd.rowid as pfdrowid"; - $sql .= ", f.".$this->db->sanitize($socOrUser); + $sql .= ", f.".$this->db->sanitize($socOrUser); // fk_soc or fk_user $sql .= ", pd.code_banque, pd.code_guichet, pd.number, pd.cle_rib"; $sql .= ", pd.amount"; if ($sourcetype != 'salary') { @@ -1200,7 +1200,12 @@ class BonPrelevement extends CommonObject while ($i < $num) { $row = $this->db->fetch_row($resql); // TODO Replace with fetch_object() '@phan-var-force array,string> $row'; - $factures[$i] = $row; // All fields + + // All fields: 0=rowid, 1=pfdrowid, 2=$socOrUser, 3=code_banque, 4=code_guichet, 5=number, 6=key, 7=amount, 8=name, 9=ref, 10=bic, 11=iban, 12=frstrecur + $factures[$i] = $row; + + // Decode BAN + $factures[$i][11] = dolDecrypt($factures[$i][11]); if ($row[7] == 0) { $error++; @@ -1232,20 +1237,10 @@ class BonPrelevement extends CommonObject // Check BAN $i = 0; - dol_syslog(__METHOD__ . " Check BAN", LOG_DEBUG); + dol_syslog(__METHOD__ . " Check BAN for each invoices or salary", LOG_DEBUG); if (count($factures) > 0) { foreach ($factures as $key => $fac) { - /* - if ($type != 'bank-transfer') { - $tmpinvoice = new Facture($this->db); - } else { - $tmpinvoice = new FactureFournisseur($this->db); - } - $resfetch = $tmpinvoice->fetch($fac[0]); - if ($resfetch >= 0) { // Field 0 of $fac is rowid of invoice - */ - // Check if $fac[8] s.nom is null if ($fac[8] != null) { if ($type != 'bank-transfer') { @@ -1259,6 +1254,7 @@ class BonPrelevement extends CommonObject $verif = checkSwiftForAccount(null, $fac[10]); if ($verif || (empty($fac[10]) && getDolGlobalInt("WITHDRAWAL_WITHOUT_BIC"))) { + dol_syslog(__METHOD__." now call checkIbanForAccount(null, ".$fac[11].")"); $verif = checkIbanForAccount(null, $fac[11]); } @@ -1312,7 +1308,7 @@ class BonPrelevement extends CommonObject $ok = 0; // Withdraw invoices in factures_prev array - $out = count($factures_prev) . " invoices will be included."; + $out = count($factures_prev) . " invoices or salaries will be included."; //print $out."\n"; dol_syslog($out); @@ -1901,8 +1897,9 @@ class BonPrelevement extends CommonObject $cachearraytotestduplicate[$obj->idfac] = $obj->rowid; $daterum = (!empty($obj->date_rum)) ? $this->db->jdate($obj->date_rum) : $this->db->jdate($obj->datec); + $iban = dolDecrypt($obj->iban); - $fileDebiteurSection .= $this->EnregDestinataireSEPA($obj->code, $obj->nom, $obj->address, $obj->zip, $obj->town, $obj->country_code, $obj->cb, $obj->cg, $obj->cc, $obj->somme, $obj->reffac, $obj->idfac, $obj->iban, $obj->bic, $daterum, $obj->drum, $obj->rum, $type); + $fileDebiteurSection .= $this->EnregDestinataireSEPA($obj->code, $obj->nom, $obj->address, $obj->zip, $obj->town, $obj->country_code, $obj->cb, $obj->cg, $obj->cc, $obj->somme, $obj->reffac, $obj->idfac, $iban, $obj->bic, $daterum, $obj->drum, $obj->rum, $type); $this->total += $obj->somme; $i++; @@ -2044,12 +2041,13 @@ class BonPrelevement extends CommonObject $cachearraytotestduplicate[$obj->idfac] = $obj->rowid; $daterum = (!empty($obj->date_rum)) ? $this->db->jdate($obj->date_rum) : $this->db->jdate($obj->datec); + $iban = dolDecrypt($obj->iban); $refobj = $obj->reffac; if (empty($refobj) && !empty($forsalary)) { // If ref of salary not defined, we force a value $refobj = "SAL" . $obj->idfac; } - $fileCrediteurSection .= $this->EnregDestinataireSEPA($obj->code, $obj->nom, $obj->address, $obj->zip, $obj->town, $obj->country_code, $obj->cb, $obj->cg, $obj->cc, $obj->somme, $refobj, $obj->idfac, $obj->iban, $obj->bic, $daterum, $obj->drum, $obj->rum, $type, $obj->fac_ref_supplier); + $fileCrediteurSection .= $this->EnregDestinataireSEPA($obj->code, $obj->nom, $obj->address, $obj->zip, $obj->town, $obj->country_code, $obj->cb, $obj->cg, $obj->cc, $obj->somme, $refobj, $obj->idfac, $iban, $obj->bic, $daterum, $obj->drum, $obj->rum, $type, $obj->fac_ref_supplier); $this->total += $obj->somme; $i++; diff --git a/htdocs/core/class/commoninvoice.class.php b/htdocs/core/class/commoninvoice.class.php index d4c29542916..748d7e8bc50 100644 --- a/htdocs/core/class/commoninvoice.class.php +++ b/htdocs/core/class/commoninvoice.class.php @@ -1823,9 +1823,9 @@ abstract class CommonInvoice extends CommonObject $s .= ''; // ecda public key $s .= ''; // ecda signature of public key stamp */ - + $mysocname = $mysoc->name ?? ''; // Using TLV format - $s = pack('C1', 1).pack('C1', strlen($mysoc->name)).$mysoc->name; + $s = pack('C1', 1).pack('C1', strlen($mysocname)).$mysocname; $s .= pack('C1', 2).pack('C1', strlen($mysoc->tva_intra)).$mysoc->tva_intra; $s .= pack('C1', 3).pack('C1', strlen($datestring)).$datestring; $s .= pack('C1', 4).pack('C1', strlen($pricewithtaxstring)).$pricewithtaxstring; diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 71cc203b2d8..8fe7db58b72 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -6856,28 +6856,52 @@ abstract class CommonObject } if ($extrafields->attributes[$this->table_element]['type'][$attributeKey] == 'point') { // for point type if (!empty($new_array_options[$key])) { - $sql .= ",ST_PointFromText('".$this->db->escape($new_array_options[$key])."')"; + if (!preg_match('/error/i', $new_array_options[$key])) { + // Text must be a WKT string, so "POINT(15 20)" + $sql .= ",ST_PointFromText('".$this->db->escape($new_array_options[$key])."')"; + } else { + dol_syslog("Bad syntax string for point ".$new_array_options[$key]." to generate SQL request", LOG_WARNING); + $sql .= ",null"; + } } else { $sql .= ",null"; } } if ($extrafields->attributes[$this->table_element]['type'][$attributeKey] == 'multipts') { // for point type if (!empty($new_array_options[$key])) { - $sql .= ",ST_MultiPointFromText('".$this->db->escape($new_array_options[$key])."')"; + if (!preg_match('/error/i', $new_array_options[$key])) { + // Text must be a WKT string, so "MULTIPOINT(0 0, 20 20, 60 60)" + $sql .= ",ST_MultiPointFromText('".$this->db->escape($new_array_options[$key])."')"; + } else { + dol_syslog("Bad syntax string for multipoint ".$new_array_options[$key]." to generate SQL request", LOG_WARNING); + $sql .= ",null"; + } } else { $sql .= ",null"; } } if ($extrafields->attributes[$this->table_element]['type'][$attributeKey] == 'linestrg') { // for linestring type if (!empty($new_array_options[$key])) { - $sql .= ",ST_LineFromText('".$this->db->escape($new_array_options[$key])."')"; + if (!preg_match('/error/i', $new_array_options[$key])) { + // Text must be a WKT string, so "LINESTRING(0 0, 10 10, 20 25, 50 60)" + $sql .= ",ST_LineFromText('".$this->db->escape($new_array_options[$key])."')"; + } else { + dol_syslog("Bad syntax string for line ".$new_array_options[$key]." to generate SQL request", LOG_WARNING); + $sql .= ",null"; + } } else { $sql .= ",null"; } } if ($extrafields->attributes[$this->table_element]['type'][$attributeKey] == 'polygon') { // for polygon type if (!empty($new_array_options[$key])) { - $sql .= ",ST_PolyFromText('".$this->db->escape($new_array_options[$key])."')"; + if (!preg_match('/error/i', $new_array_options[$key])) { + // Text must be a WKT string, so "POLYGON((0 0,10 0,10 10,0 10,0 0),(5 5,7 5,7 7,5 7, 5 5))" + $sql .= ",ST_PolyFromText('".$this->db->escape($new_array_options[$key])."')"; + } else { + dol_syslog("Bad syntax string for polygon ".$new_array_options[$key]." to generate SQL request", LOG_WARNING); + $sql .= ",null"; + } } else { $sql .= ",null"; } diff --git a/htdocs/core/class/dolgeophp.class.php b/htdocs/core/class/dolgeophp.class.php index 78f6bfed620..d5211bcc436 100644 --- a/htdocs/core/class/dolgeophp.class.php +++ b/htdocs/core/class/dolgeophp.class.php @@ -115,10 +115,15 @@ class DolGeoPHP { $value_key = ''; - $geom = geoPHP::load($geojson, 'json'); - if ($geom) { - '@phan-var-force Geometry $geom'; - $value_key = $geom->out('wkt'); + try { + $geom = geoPHP::load($geojson, 'json'); + if ($geom) { + '@phan-var-force Geometry $geom'; + $value_key = $geom->out('wkt'); + } + } catch (Exception $e) { + // Do nothing + $value_key = 'Error: Bad value for property'; } return $value_key; } diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index d27e941d1e6..218c5822d66 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -5263,14 +5263,15 @@ class Form while ($i < $num) { $obj = $this->db->fetch_object($result); + $iban = dolDecrypt($obj->iban_prefix); if ($selected == $obj->rowid || ($useempty == 2 && $num == 1 && empty($selected))) { - $out .= ''; $i++; diff --git a/htdocs/core/class/html.formadmin.class.php b/htdocs/core/class/html.formadmin.class.php index 57f86f121cf..65b4cea3a88 100644 --- a/htdocs/core/class/html.formadmin.class.php +++ b/htdocs/core/class/html.formadmin.class.php @@ -511,7 +511,7 @@ class FormAdmin */ public function selectTypeOfFields($htmlname, $type, $typewecanchangeinto = array()) { - global $type2label; // TODO Remove this + global $type2label; // TODO Remove this global $out = ''; diff --git a/htdocs/core/class/vcard.class.php b/htdocs/core/class/vcard.class.php index 2c2390a9005..0ca6f57f458 100644 --- a/htdocs/core/class/vcard.class.php +++ b/htdocs/core/class/vcard.class.php @@ -515,7 +515,9 @@ class vCard $this->setOrg($company->name); } - $this->setURL($company->url, ""); + if (!empty($company->url)) { + $this->setURL($company->url, ""); + } if ($company->phone && empty($object->office_phone)) { // If we already set the type TYPE=WORK,VOICE with office_phone $this->setPhoneNumber($company->phone, "TYPE=WORK,VOICE"); diff --git a/htdocs/core/lib/ajax.lib.php b/htdocs/core/lib/ajax.lib.php index 20ebd6464df..8378d992bd3 100644 --- a/htdocs/core/lib/ajax.lib.php +++ b/htdocs/core/lib/ajax.lib.php @@ -639,14 +639,14 @@ function ajax_event($htmlname, $events) * @param string $suffix Suffix to use on the name of the switch picto when option is on. Example: '', '_red' * @param string $mode Add parameter &mode= to the href link (Used for href link) * @param string $morecss More CSS - * @param int $userconst 1=OnOff for user constant of user $userconst + * @param User|int $userconst If set, use the ajax On/Off for user or user ID $userconst * @param string $showwarning String to show a warning when enabled the option * @return string * @see ajax_object_onoff() to update the status of an object */ function ajax_constantonoff($code, $input = array(), $entity = null, $revertonoff = 0, $strict = 0, $forcereload = 0, $marginleftonlyshort = 2, $forcenoajax = 0, $setzeroinsteadofdel = 0, $suffix = '', $mode = '', $morecss = 'inline-block', $userconst = 0, $showwarning = '') { - global $conf, $langs, $user; + global $conf, $langs, $user, $db; $entity = ((isset($entity) && is_numeric($entity) && $entity >= 0) ? $entity : $conf->entity); if (!isset($input)) { @@ -660,6 +660,15 @@ function ajax_constantonoff($code, $input = array(), $entity = null, $revertonof $out = ''.img_picto($langs->trans("Enabled"), 'on').''; } } else { + $userconstid = 0; + if (is_object($userconst)) { + $userconstid = $userconst->id; + } elseif (is_numeric($userconst) && $userconst > 0) { + $userconstid = $userconst; + $userconst = new User($db); + $userconst->fetch($userconstid); + } + $out = "\n".' '."\n"; - if ($userconst) { - $value = getDolUserString($code); + if (!empty($userconst) && $userconst instanceof User) { + $value = getDolUserString($code, '', $userconst); } else { $value = getDolGlobalString($code); } @@ -726,7 +734,7 @@ console.log("ee"); * On/off button to change a property status of an object * This uses the ajax service objectonoff.php (May be called when MAIN_DIRECT_STATUS_UPDATE is set for some pages) * - * @param Object $object Object to set + * @param CommonObject $object Object to set * @param string $code Name of property in object : 'status' or 'status_buy' for product by example * @param string $field Name of database field : 'tosell' or 'tobuy' for product by example * @param string $text_on Text if on ('Text' or 'Text:Picto on:Css picto on') @@ -746,7 +754,6 @@ function ajax_object_onoff($object, $code, $field, $text_on, $text_off, $input = if (empty($htmlname)) { $htmlname = $code; } - //var_dump($object->module); var_dump($object->element); $out = ''; diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index d2609495d49..c2800d3ef84 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -4039,7 +4039,7 @@ function dol_print_socialnetworks($value, $cid, $socid, $type, $dictsocialnetwor $link = str_replace('{socialid}', $value, getDolGlobalString($networkconstname)); if (preg_match('/^https?:\/\//i', $link)) { $htmllink .= ''.dol_escape_htmltag($value).''; - } else { + } elseif ($link) { $htmllink .= ''.dol_escape_htmltag($value).''; } } elseif (!empty($dictsocialnetworks[$type]['url'])) { @@ -13777,7 +13777,7 @@ function forgeSQLFromUniversalSearchCriteria($filter, &$errorstr = '', $noand = } } - $ret = ($noand ? "" : " AND ").($nopar ? "" : '(').preg_replace_callback('/'.$regexstring.'/i', 'dolForgeCriteriaCallback', $filter).($nopar ? "" : ')'); + $ret = ($noand ? "" : " AND ").($nopar ? "" : '(').preg_replace_callback('/'.$regexstring.'/i', 'dolForgeSQLCriteriaCallback', $filter).($nopar ? "" : ')'); if (is_object($db)) { $ret = str_replace('__NOW__', $db->idate(dol_now()), $ret); @@ -13938,14 +13938,14 @@ function dolForgeDummyCriteriaCallback($matches) } /** - * Function to forge a SQL criteria from a Dolibarr filter syntax string. + * Function to forge a SQL criteria from a USF (Universal Filter Syntax) string. * This method is called by forgeSQLFromUniversalSearchCriteria() * * @param string[] $matches Array of found string by regex search. * Example: "t.ref:like:'SO-%'" or "t.date_creation:<:'20160101'" or "t.date_creation:<:'2016-01-01 12:30:00'" or "t.nature:is:NULL" * @return string Forged criteria. Example: "t.field LIKE 'abc%'" */ -function dolForgeCriteriaCallback($matches) +function dolForgeSQLCriteriaCallback($matches) { global $db; diff --git a/htdocs/core/tpl/extrafields_view.tpl.php b/htdocs/core/tpl/extrafields_view.tpl.php index 700824e7ae3..8d17be75f40 100644 --- a/htdocs/core/tpl/extrafields_view.tpl.php +++ b/htdocs/core/tpl/extrafields_view.tpl.php @@ -257,7 +257,7 @@ if (empty($reshook) && !empty($object->table_element) && isset($extrafields->att print ''; print ''; print ''; - print $extrafields->showInputField($tmpkeyextra, $value, '', '', '', 0, $object->id, $object->table_element); + print $extrafields->showInputField($tmpkeyextra, $value, '', '', '', 0, $object, $object->table_element); print ''; diff --git a/htdocs/core/tpl/massactions_pre.tpl.php b/htdocs/core/tpl/massactions_pre.tpl.php index b4164ac04c0..3cf6e4f82eb 100644 --- a/htdocs/core/tpl/massactions_pre.tpl.php +++ b/htdocs/core/tpl/massactions_pre.tpl.php @@ -377,7 +377,7 @@ if ($massaction == 'edit_extrafields') { foreach ($extrafields_list as $extraKey => $extraLabel) { $outputShowOutputFields .= ''; } $outputShowOutputFields .= '