@@ -105,7 +105,7 @@ discard block |
||
| 105 | 105 | $contactid = GETPOSTINT('contactid'); |
| 106 | 106 | $projectid = GETPOSTINT('projectid'); |
| 107 | 107 | $origin = GETPOST('origin', 'alpha'); |
| 108 | -$originid = (GETPOSTINT('originid') ? GETPOSTINT('originid') : GETPOSTINT('origin_id')); // For backward compatibility |
|
| 108 | +$originid = (GETPOSTINT('originid') ? GETPOSTINT('originid') : GETPOSTINT('origin_id')); // For backward compatibility |
|
| 109 | 109 | $rank = (GETPOSTINT('rank') > 0) ? GETPOSTINT('rank') : -1; |
| 110 | 110 | |
| 111 | 111 | |
@@ -130,7 +130,7 @@ discard block |
||
| 130 | 130 | $extrafields->fetch_name_optionals_label($object->table_element); |
| 131 | 131 | |
| 132 | 132 | // Load object |
| 133 | -include DOL_DOCUMENT_ROOT . '/core/actions_fetchobject.inc.php'; // Must be include, not include_once |
|
| 133 | +include DOL_DOCUMENT_ROOT . '/core/actions_fetchobject.inc.php'; // Must be include, not include_once |
|
| 134 | 134 | |
| 135 | 135 | // Permissions / Rights |
| 136 | 136 | $usercanread = $user->hasRight("commande", "lire"); |
@@ -147,9 +147,9 @@ discard block |
||
| 147 | 147 | $usermustrespectpricemin = ((getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && !$user->hasRight('produit', 'ignore_price_min_advance')) || !getDolGlobalString('MAIN_USE_ADVANCED_PERMS')); |
| 148 | 148 | $usercancreatepurchaseorder = ($user->hasRight('fournisseur', 'commande', 'creer') || $user->hasRight('supplier_order', 'creer')); |
| 149 | 149 | |
| 150 | -$permissionnote = $usercancreate; // Used by the include of actions_setnotes.inc.php |
|
| 151 | -$permissiondellink = $usercancreate; // Used by the include of actions_dellink.inc.php |
|
| 152 | -$permissiontoadd = $usercancreate; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php |
|
| 150 | +$permissionnote = $usercancreate; // Used by the include of actions_setnotes.inc.php |
|
| 151 | +$permissiondellink = $usercancreate; // Used by the include of actions_dellink.inc.php |
|
| 152 | +$permissiontoadd = $usercancreate; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php |
|
| 153 | 153 | |
| 154 | 154 | |
| 155 | 155 | $error = 0; |
@@ -194,11 +194,11 @@ discard block |
||
| 194 | 194 | $action = ''; |
| 195 | 195 | } |
| 196 | 196 | |
| 197 | - include DOL_DOCUMENT_ROOT . '/core/actions_setnotes.inc.php'; // Must be include, not include_once |
|
| 197 | + include DOL_DOCUMENT_ROOT . '/core/actions_setnotes.inc.php'; // Must be include, not include_once |
|
| 198 | 198 | |
| 199 | - include DOL_DOCUMENT_ROOT . '/core/actions_dellink.inc.php'; // Must be include, not include_once |
|
| 199 | + include DOL_DOCUMENT_ROOT . '/core/actions_dellink.inc.php'; // Must be include, not include_once |
|
| 200 | 200 | |
| 201 | - include DOL_DOCUMENT_ROOT . '/core/actions_lineupdown.inc.php'; // Must be include, not include_once |
|
| 201 | + include DOL_DOCUMENT_ROOT . '/core/actions_lineupdown.inc.php'; // Must be include, not include_once |
|
| 202 | 202 | |
| 203 | 203 | // Action clone object |
| 204 | 204 | if ($action == 'confirm_clone' && $confirm == 'yes' && $usercancreate) { |
@@ -338,7 +338,7 @@ discard block |
||
| 338 | 338 | $object->fk_incoterms = GETPOSTINT('incoterm_id'); |
| 339 | 339 | $object->location_incoterms = GETPOST('location_incoterms', 'alpha'); |
| 340 | 340 | $object->multicurrency_code = GETPOST('multicurrency_code', 'alpha'); |
| 341 | - $object->multicurrency_tx = (float)price2num(GETPOST('originmulticurrency_tx')); |
|
| 341 | + $object->multicurrency_tx = (float) price2num(GETPOST('originmulticurrency_tx')); |
|
| 342 | 342 | // Fill array 'array_options' with data from add form |
| 343 | 343 | if (!$error) { |
| 344 | 344 | $ret = $extrafields->setOptionalsFromPost(null, $object); |
@@ -919,16 +919,16 @@ discard block |
||
| 919 | 919 | } |
| 920 | 920 | } |
| 921 | 921 | |
| 922 | - $tmpvat = (float)price2num(preg_replace('/\s*\(.*\)/', '', $tva_tx)); |
|
| 923 | - $tmpprodvat = (float)price2num(preg_replace('/\s*\(.*\)/', '', (string)$prod->tva_tx)); |
|
| 922 | + $tmpvat = (float) price2num(preg_replace('/\s*\(.*\)/', '', $tva_tx)); |
|
| 923 | + $tmpprodvat = (float) price2num(preg_replace('/\s*\(.*\)/', '', (string) $prod->tva_tx)); |
|
| 924 | 924 | |
| 925 | 925 | // Set unit price to use |
| 926 | 926 | if (!empty($price_ht) || $price_ht === '0') { |
| 927 | 927 | $pu_ht = price2num($price_ht, 'MU'); |
| 928 | - $pu_ttc = price2num((float)$pu_ht * (1 + ($tmpvat / 100)), 'MU'); |
|
| 928 | + $pu_ttc = price2num((float) $pu_ht * (1 + ($tmpvat / 100)), 'MU'); |
|
| 929 | 929 | } elseif (!empty($price_ttc) || $price_ttc === '0') { |
| 930 | 930 | $pu_ttc = price2num($price_ttc, 'MU'); |
| 931 | - $pu_ht = price2num((float)$pu_ttc / (1 + ($tmpvat / 100)), 'MU'); |
|
| 931 | + $pu_ht = price2num((float) $pu_ttc / (1 + ($tmpvat / 100)), 'MU'); |
|
| 932 | 932 | } elseif ($tmpvat != $tmpprodvat) { |
| 933 | 933 | // Is this still used ? |
| 934 | 934 | if ($price_base_type != 'HT') { |
@@ -1057,10 +1057,10 @@ discard block |
||
| 1057 | 1057 | // Check if we have a foreign currency |
| 1058 | 1058 | // If so, we update the pu_equiv as the equivalent price in base currency |
| 1059 | 1059 | if ($pu_ht == '' && $pu_ht_devise != '' && $currency_tx != '') { |
| 1060 | - $pu_equivalent = (float)$pu_ht_devise * (float)$currency_tx; |
|
| 1060 | + $pu_equivalent = (float) $pu_ht_devise * (float) $currency_tx; |
|
| 1061 | 1061 | } |
| 1062 | 1062 | if ($pu_ttc == '' && $pu_ttc_devise != '' && $currency_tx != '') { |
| 1063 | - $pu_equivalent_ttc = (float)$pu_ttc_devise * (float)$currency_tx; |
|
| 1063 | + $pu_equivalent_ttc = (float) $pu_ttc_devise * (float) $currency_tx; |
|
| 1064 | 1064 | } |
| 1065 | 1065 | |
| 1066 | 1066 | // TODO $pu_equivalent or $pu_equivalent_ttc must be calculated from the one defined |
@@ -1078,11 +1078,11 @@ discard block |
||
| 1078 | 1078 | |
| 1079 | 1079 | // Check price is not lower than minimum |
| 1080 | 1080 | if ($usermustrespectpricemin) { |
| 1081 | - if ($pu_equivalent && $price_min && (((float)price2num($pu_equivalent) * (1 - $remise_percent / 100)) < (float)price2num($price_min)) && $price_base_type == 'HT') { |
|
| 1081 | + if ($pu_equivalent && $price_min && (((float) price2num($pu_equivalent) * (1 - $remise_percent / 100)) < (float) price2num($price_min)) && $price_base_type == 'HT') { |
|
| 1082 | 1082 | $mesg = $langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, -1, $conf->currency)); |
| 1083 | 1083 | setEventMessages($mesg, null, 'errors'); |
| 1084 | 1084 | $error++; |
| 1085 | - } elseif ($pu_equivalent_ttc && $price_min_ttc && (((float)price2num($pu_equivalent_ttc) * (1 - $remise_percent / 100)) < (float)price2num($price_min_ttc)) && $price_base_type == 'TTC') { |
|
| 1085 | + } elseif ($pu_equivalent_ttc && $price_min_ttc && (((float) price2num($pu_equivalent_ttc) * (1 - $remise_percent / 100)) < (float) price2num($price_min_ttc)) && $price_base_type == 'TTC') { |
|
| 1086 | 1086 | $mesg = $langs->trans("CantBeLessThanMinPriceInclTax", price(price2num($price_min_ttc, 'MU'), 0, $langs, 0, 0, -1, $conf->currency)); |
| 1087 | 1087 | setEventMessages($mesg, null, 'errors'); |
| 1088 | 1088 | $error++; |
@@ -1187,10 +1187,10 @@ discard block |
||
| 1187 | 1187 | // Check if we have a foreign currency |
| 1188 | 1188 | // If so, we update the pu_equiv as the equivalent price in base currency |
| 1189 | 1189 | if ($pu_ht == '' && $pu_ht_devise != '' && $currency_tx != '') { |
| 1190 | - $pu_equivalent = (float)$pu_ht_devise * (float)$currency_tx; |
|
| 1190 | + $pu_equivalent = (float) $pu_ht_devise * (float) $currency_tx; |
|
| 1191 | 1191 | } |
| 1192 | 1192 | if ($pu_ttc == '' && $pu_ttc_devise != '' && $currency_tx != '') { |
| 1193 | - $pu_equivalent_ttc = (float)$pu_ttc_devise * (float)$currency_tx; |
|
| 1193 | + $pu_equivalent_ttc = (float) $pu_ttc_devise * (float) $currency_tx; |
|
| 1194 | 1194 | } |
| 1195 | 1195 | |
| 1196 | 1196 | // TODO $pu_equivalent or $pu_equivalent_ttc must be calculated from the one not null taking into account all taxes |
@@ -1247,12 +1247,12 @@ discard block |
||
| 1247 | 1247 | |
| 1248 | 1248 | // Check price is not lower than minimum |
| 1249 | 1249 | if ($usermustrespectpricemin) { |
| 1250 | - if ($pu_equivalent && $price_min && (((float)price2num($pu_equivalent) * (1 - $remise_percent / 100)) < (float)price2num($price_min)) && $price_base_type == 'HT') { |
|
| 1250 | + if ($pu_equivalent && $price_min && (((float) price2num($pu_equivalent) * (1 - $remise_percent / 100)) < (float) price2num($price_min)) && $price_base_type == 'HT') { |
|
| 1251 | 1251 | $mesg = $langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, -1, $conf->currency)); |
| 1252 | 1252 | setEventMessages($mesg, null, 'errors'); |
| 1253 | 1253 | $error++; |
| 1254 | 1254 | $action = 'editline'; |
| 1255 | - } elseif ($pu_equivalent_ttc && $price_min_ttc && (((float)price2num($pu_equivalent_ttc) * (1 - $remise_percent / 100)) < (float)price2num($price_min_ttc)) && $price_base_type == 'TTC') { |
|
| 1255 | + } elseif ($pu_equivalent_ttc && $price_min_ttc && (((float) price2num($pu_equivalent_ttc) * (1 - $remise_percent / 100)) < (float) price2num($price_min_ttc)) && $price_base_type == 'TTC') { |
|
| 1256 | 1256 | $mesg = $langs->trans("CantBeLessThanMinPriceInclTax", price(price2num($price_min_ttc, 'MU'), 0, $langs, 0, 0, -1, $conf->currency)); |
| 1257 | 1257 | setEventMessages($mesg, null, 'errors'); |
| 1258 | 1258 | $error++; |
@@ -1379,7 +1379,7 @@ discard block |
||
| 1379 | 1379 | $error = 0; |
| 1380 | 1380 | $deposit = null; |
| 1381 | 1381 | |
| 1382 | - $deposit_percent_from_payment_terms = (float)getDictionaryValue('c_payment_term', 'deposit_percent', $object->cond_reglement_id); |
|
| 1382 | + $deposit_percent_from_payment_terms = (float) getDictionaryValue('c_payment_term', 'deposit_percent', $object->cond_reglement_id); |
|
| 1383 | 1383 | |
| 1384 | 1384 | if ( |
| 1385 | 1385 | GETPOST('generate_deposit', 'alpha') == 'on' && !empty($deposit_percent_from_payment_terms) |
@@ -1857,7 +1857,7 @@ discard block |
||
| 1857 | 1857 | print '<form name="crea_commande" action="' . $_SERVER["PHP_SELF"] . '" method="POST">'; |
| 1858 | 1858 | print '<input type="hidden" name="token" value="' . newToken() . '">'; |
| 1859 | 1859 | print '<input type="hidden" name="action" value="add">'; |
| 1860 | - print '<input type="hidden" name="changecompany" value="0">'; // will be set to 1 by javascript so we know post is done after a company change |
|
| 1860 | + print '<input type="hidden" name="changecompany" value="0">'; // will be set to 1 by javascript so we know post is done after a company change |
|
| 1861 | 1861 | print '<input type="hidden" name="remise_percent" value="' . $soc->remise_percent . '">'; |
| 1862 | 1862 | print '<input type="hidden" name="origin" value="' . $origin . '">'; |
| 1863 | 1863 | print '<input type="hidden" name="originid" value="' . $originid . '">'; |
@@ -1935,7 +1935,7 @@ discard block |
||
| 1935 | 1935 | |
| 1936 | 1936 | $thirdparty = $soc; |
| 1937 | 1937 | $discount_type = 0; |
| 1938 | - $backtopage = $_SERVER["PHP_SELF"] . '?socid=' . $thirdparty->id . '&action=' . $action . '&origin=' . urlencode((string)(GETPOST('origin'))) . '&originid=' . urlencode((string)(GETPOSTINT('originid'))); |
|
| 1938 | + $backtopage = $_SERVER["PHP_SELF"] . '?socid=' . $thirdparty->id . '&action=' . $action . '&origin=' . urlencode((string) (GETPOST('origin'))) . '&originid=' . urlencode((string) (GETPOSTINT('originid'))); |
|
| 1939 | 1939 | include DOL_DOCUMENT_ROOT . '/core/tpl/object_discounts.tpl.php'; |
| 1940 | 1940 | |
| 1941 | 1941 | print '</td></tr>'; |
@@ -2270,7 +2270,7 @@ discard block |
||
| 2270 | 2270 | // Suggestion to create invoice during order validation is not enabled by default. |
| 2271 | 2271 | // Such choice should be managed by the workflow module and trigger. This option generates conflicts with some setup. |
| 2272 | 2272 | // It may also break step of creating an order when invoicing must be done from proposals and not from orders |
| 2273 | - $deposit_percent_from_payment_terms = (float)getDictionaryValue('c_payment_term', 'deposit_percent', $object->cond_reglement_id); |
|
| 2273 | + $deposit_percent_from_payment_terms = (float) getDictionaryValue('c_payment_term', 'deposit_percent', $object->cond_reglement_id); |
|
| 2274 | 2274 | |
| 2275 | 2275 | if (!empty($deposit_percent_from_payment_terms) && isModEnabled('invoice') && $user->hasRight('facture', 'creer')) { |
| 2276 | 2276 | $object->fetchObjectLinked(); |
@@ -151,7 +151,7 @@ discard block |
||
| 151 | 151 | if (getDolGlobalString('THEME_DARKMODEENABLED')) { |
| 152 | 152 | print "/* For dark mode */\n"; |
| 153 | 153 | if (getDolGlobalInt('THEME_DARKMODEENABLED') != 2) { |
| 154 | - print "@media (prefers-color-scheme: dark) {"; // To test, click on the 3 dots menu, then Other options then Display then emulate prefer-color-schemes |
|
| 154 | + print "@media (prefers-color-scheme: dark) {"; // To test, click on the 3 dots menu, then Other options then Display then emulate prefer-color-schemes |
|
| 155 | 155 | } else { |
| 156 | 156 | print "@media not print {"; |
| 157 | 157 | } |
@@ -6613,7 +6613,7 @@ discard block |
||
| 6613 | 6613 | if (getDolGlobalString('THEME_DARKMODEENABLED')) { |
| 6614 | 6614 | print "/* For dark mode */\n"; |
| 6615 | 6615 | if (getDolGlobalInt('THEME_DARKMODEENABLED') != 2) { |
| 6616 | - print "@media (prefers-color-scheme: dark) {"; // To test, click on the 3 dots menu, then Other options then Display then emulate prefer-color-schemes |
|
| 6616 | + print "@media (prefers-color-scheme: dark) {"; // To test, click on the 3 dots menu, then Other options then Display then emulate prefer-color-schemes |
|
| 6617 | 6617 | } else { |
| 6618 | 6618 | print "@media not print {"; |
| 6619 | 6619 | } ?> |
@@ -444,8 +444,8 @@ discard block |
||
| 444 | 444 | // If we ask to add a given permission, we first load properties of this permission (module, perms and subperms). |
| 445 | 445 | $sql = "SELECT module, perms, subperms"; |
| 446 | 446 | $sql .= " FROM " . $this->db->prefix() . "rights_def"; |
| 447 | - $sql .= " WHERE id = " . ((int)$rid); |
|
| 448 | - $sql .= " AND entity = " . ((int)$entity); |
|
| 447 | + $sql .= " WHERE id = " . ((int) $rid); |
|
| 448 | + $sql .= " AND entity = " . ((int) $entity); |
|
| 449 | 449 | |
| 450 | 450 | $result = $this->db->query($sql); |
| 451 | 451 | if ($result) { |
@@ -462,7 +462,7 @@ discard block |
||
| 462 | 462 | } |
| 463 | 463 | |
| 464 | 464 | // Define the where for the permission to add |
| 465 | - $whereforadd = "id=" . ((int)$rid); |
|
| 465 | + $whereforadd = "id=" . ((int) $rid); |
|
| 466 | 466 | // Add also inherited permissions |
| 467 | 467 | if (!empty($subperms)) { |
| 468 | 468 | $whereforadd .= " OR (module='" . $this->db->escape($module) . "' AND perms='" . $this->db->escape($perms) . "' AND (subperms='lire' OR subperms='read'))"; |
@@ -491,15 +491,15 @@ discard block |
||
| 491 | 491 | //print "$module-$perms-$subperms"; |
| 492 | 492 | $sql = "SELECT id"; |
| 493 | 493 | $sql .= " FROM " . $this->db->prefix() . "rights_def"; |
| 494 | - $sql .= " WHERE entity = " . ((int)$entity); |
|
| 494 | + $sql .= " WHERE entity = " . ((int) $entity); |
|
| 495 | 495 | if (!empty($whereforadd) && $whereforadd != 'allmodules') { |
| 496 | - $sql .= " AND (" . $whereforadd . ")"; // Note: parenthesis are important because whereforadd can contains OR. Also note that $whereforadd is already sanitized |
|
| 496 | + $sql .= " AND (" . $whereforadd . ")"; // Note: parenthesis are important because whereforadd can contains OR. Also note that $whereforadd is already sanitized |
|
| 497 | 497 | } |
| 498 | 498 | |
| 499 | 499 | $sqldelete = "DELETE FROM " . $this->db->prefix() . "user_rights"; |
| 500 | - $sqldelete .= " WHERE fk_user = " . ((int)$this->id) . " AND fk_id IN ("; |
|
| 500 | + $sqldelete .= " WHERE fk_user = " . ((int) $this->id) . " AND fk_id IN ("; |
|
| 501 | 501 | $sqldelete .= $sql; |
| 502 | - $sqldelete .= ") AND entity = " . ((int)$entity); |
|
| 502 | + $sqldelete .= ") AND entity = " . ((int) $entity); |
|
| 503 | 503 | if (!$this->db->query($sqldelete)) { |
| 504 | 504 | $error++; |
| 505 | 505 | } |
@@ -515,7 +515,7 @@ discard block |
||
| 515 | 515 | if ($obj) { |
| 516 | 516 | $nid = $obj->id; |
| 517 | 517 | |
| 518 | - $sql = "INSERT INTO " . $this->db->prefix() . "user_rights (entity, fk_user, fk_id) VALUES (" . ((int)$entity) . ", " . ((int)$this->id) . ", " . ((int)$nid) . ")"; |
|
| 518 | + $sql = "INSERT INTO " . $this->db->prefix() . "user_rights (entity, fk_user, fk_id) VALUES (" . ((int) $entity) . ", " . ((int) $this->id) . ", " . ((int) $nid) . ")"; |
|
| 519 | 519 | if (!$this->db->query($sql)) { |
| 520 | 520 | $error++; |
| 521 | 521 | } |
@@ -597,7 +597,7 @@ discard block |
||
| 597 | 597 | } |
| 598 | 598 | |
| 599 | 599 | // Where clause for the list of permissions to delete |
| 600 | - $wherefordel = "id=" . ((int)$rid); |
|
| 600 | + $wherefordel = "id=" . ((int) $rid); |
|
| 601 | 601 | // Suppression des droits induits |
| 602 | 602 | if ($subperms == 'lire' || $subperms == 'read') { |
| 603 | 603 | $wherefordel .= " OR (module='" . $this->db->escape($module) . "' AND perms='" . $this->db->escape($perms) . "' AND subperms IS NOT NULL)"; |
@@ -628,7 +628,7 @@ discard block |
||
| 628 | 628 | $sql .= " FROM " . $this->db->prefix() . "rights_def"; |
| 629 | 629 | $sql .= " WHERE entity IN (" . $this->db->sanitize($entity, 0, 0, 0, 0) . ")"; |
| 630 | 630 | if (!empty($wherefordel) && $wherefordel != 'allmodules') { |
| 631 | - $sql .= " AND (" . $wherefordel . ")"; // Note: parenthesis are important because wherefordel can contains OR. Also note that $wherefordel is already sanitized |
|
| 631 | + $sql .= " AND (" . $wherefordel . ")"; // Note: parenthesis are important because wherefordel can contains OR. Also note that $wherefordel is already sanitized |
|
| 632 | 632 | } |
| 633 | 633 | |
| 634 | 634 | // avoid admin to remove his own important rights |
@@ -640,7 +640,7 @@ discard block |
||
| 640 | 640 | } |
| 641 | 641 | |
| 642 | 642 | $sqldelete = "DELETE FROM " . $this->db->prefix() . "user_rights"; |
| 643 | - $sqldelete .= " WHERE fk_user = " . ((int)$this->id) . " AND fk_id IN ("; |
|
| 643 | + $sqldelete .= " WHERE fk_user = " . ((int) $this->id) . " AND fk_id IN ("; |
|
| 644 | 644 | $sqldelete .= $sql; |
| 645 | 645 | $sqldelete .= ")"; |
| 646 | 646 | $sqldelete .= " AND entity IN (" . $this->db->sanitize($entity, 0, 0, 0, 0) . ")"; |
@@ -752,9 +752,9 @@ discard block |
||
| 752 | 752 | } else { |
| 753 | 753 | // On table r=rights_def, the unique key is (id, entity) because id is hard coded into module descriptor and insert during module activation. |
| 754 | 754 | // So we must include the filter on entity on both table r. and ur. |
| 755 | - $sql .= " AND r.entity = " . ((int)$conf->entity) . " AND ur.entity = " . ((int)$conf->entity); |
|
| 755 | + $sql .= " AND r.entity = " . ((int) $conf->entity) . " AND ur.entity = " . ((int) $conf->entity); |
|
| 756 | 756 | } |
| 757 | - $sql .= " AND ur.fk_user= " . ((int)$this->id); |
|
| 757 | + $sql .= " AND ur.fk_user= " . ((int) $this->id); |
|
| 758 | 758 | $sql .= " AND r.perms IS NOT NULL"; |
| 759 | 759 | if (!getDolGlobalString('MAIN_USE_ADVANCED_PERMS')) { |
| 760 | 760 | $sql .= " AND r.perms NOT LIKE '%_advance'"; // Hide advanced perms if option is not enabled |
@@ -813,19 +813,19 @@ discard block |
||
| 813 | 813 | if (isModEnabled('multicompany') && getDolGlobalString('MULTICOMPANY_TRANSVERSE_MODE')) { |
| 814 | 814 | $sql .= " AND gu.entity IN (0," . $conf->entity . ")"; |
| 815 | 815 | } else { |
| 816 | - $sql .= " AND r.entity = " . ((int)$conf->entity); |
|
| 816 | + $sql .= " AND r.entity = " . ((int) $conf->entity); |
|
| 817 | 817 | } |
| 818 | 818 | } else { |
| 819 | - $sql .= " AND gr.entity = " . ((int)$conf->entity); // Only groups created in current entity |
|
| 819 | + $sql .= " AND gr.entity = " . ((int) $conf->entity); // Only groups created in current entity |
|
| 820 | 820 | // The entity on the table gu=usergroup_user should be useless and should never be used because it is already into gr and r. |
| 821 | 821 | // but when using MULTICOMPANY_TRANSVERSE_MODE, we may have inserted record that make rubbish result here due to the duplicate record of |
| 822 | 822 | // other entities, so we are forced to add a filter on gu here |
| 823 | 823 | $sql .= " AND gu.entity IN (0," . $conf->entity . ")"; |
| 824 | - $sql .= " AND r.entity = " . ((int)$conf->entity); // Only permission of modules enabled in current entity |
|
| 824 | + $sql .= " AND r.entity = " . ((int) $conf->entity); // Only permission of modules enabled in current entity |
|
| 825 | 825 | } |
| 826 | 826 | // End of strange business rule |
| 827 | 827 | $sql .= " AND gr.fk_usergroup = gu.fk_usergroup"; |
| 828 | - $sql .= " AND gu.fk_user = " . ((int)$this->id); |
|
| 828 | + $sql .= " AND gu.fk_user = " . ((int) $this->id); |
|
| 829 | 829 | $sql .= " AND r.perms IS NOT NULL"; |
| 830 | 830 | if ($moduletag) { |
| 831 | 831 | $sql .= " AND r.module = '" . $this->db->escape($moduletag) . "'"; |
@@ -1055,7 +1055,7 @@ discard block |
||
| 1055 | 1055 | */ |
| 1056 | 1056 | public function getLibStatut($mode = 0) |
| 1057 | 1057 | { |
| 1058 | - return $this->LibStatut(isset($this->statut) ? (int)$this->statut : (int)$this->status, $mode); |
|
| 1058 | + return $this->LibStatut(isset($this->statut) ? (int) $this->statut : (int) $this->status, $mode); |
|
| 1059 | 1059 | } |
| 1060 | 1060 | |
| 1061 | 1061 | /** |
@@ -1196,7 +1196,7 @@ discard block |
||
| 1196 | 1196 | $result .= (($option == 'nolink') ? '' : $linkstart); |
| 1197 | 1197 | if ($withpictoimg) { |
| 1198 | 1198 | $paddafterimage = ''; |
| 1199 | - if (abs((int)$withpictoimg) == 1) { |
|
| 1199 | + if (abs((int) $withpictoimg) == 1) { |
|
| 1200 | 1200 | $paddafterimage = 'style="margin-' . ($langs->trans("DIRECTION") == 'rtl' ? 'left' : 'right') . ': 3px;"'; |
| 1201 | 1201 | } |
| 1202 | 1202 | // Only picto |
@@ -1321,16 +1321,16 @@ discard block |
||
| 1321 | 1321 | // Special case for external user |
| 1322 | 1322 | if (!empty($this->socid)) { |
| 1323 | 1323 | if ($module == 'societe' && ($permlevel1 == 'creer' || $permlevel1 == 'write')) { |
| 1324 | - return 0; // An external user never has the permission ->societe->write to see all thirdparties (always restricted to himself) |
|
| 1324 | + return 0; // An external user never has the permission ->societe->write to see all thirdparties (always restricted to himself) |
|
| 1325 | 1325 | } |
| 1326 | 1326 | if ($module == 'societe' && $permlevel1 == 'client' && $permlevel2 == 'voir') { |
| 1327 | - return 0; // An external user never has the permission ->societe->client->voir to see all thirdparties (always restricted to himself) |
|
| 1327 | + return 0; // An external user never has the permission ->societe->client->voir to see all thirdparties (always restricted to himself) |
|
| 1328 | 1328 | } |
| 1329 | 1329 | if ($module == 'societe' && $permlevel1 == 'export') { |
| 1330 | - return 0; // An external user never has the permission ->societe->export to see all thirdparties (always restricted to himself) |
|
| 1330 | + return 0; // An external user never has the permission ->societe->export to see all thirdparties (always restricted to himself) |
|
| 1331 | 1331 | } |
| 1332 | 1332 | if ($module == 'societe' && ($permlevel1 == 'supprimer' || $permlevel1 == 'delete')) { |
| 1333 | - return 0; // An external user never has the permission ->societe->delete to see all thirdparties (always restricted to himself) |
|
| 1333 | + return 0; // An external user never has the permission ->societe->delete to see all thirdparties (always restricted to himself) |
|
| 1334 | 1334 | } |
| 1335 | 1335 | } |
| 1336 | 1336 | |
@@ -1419,8 +1419,8 @@ discard block |
||
| 1419 | 1419 | |
| 1420 | 1420 | // Save in database |
| 1421 | 1421 | $sql = "UPDATE " . $this->db->prefix() . "user"; |
| 1422 | - $sql .= " SET statut = " . ((int)$status); |
|
| 1423 | - $sql .= " WHERE rowid = " . ((int)$this->id); |
|
| 1422 | + $sql .= " SET statut = " . ((int) $status); |
|
| 1423 | + $sql .= " WHERE rowid = " . ((int) $this->id); |
|
| 1424 | 1424 | $result = $this->db->query($sql); |
| 1425 | 1425 | |
| 1426 | 1426 | dol_syslog(get_only_class($this) . "::setstatus", LOG_DEBUG); |
@@ -1488,7 +1488,7 @@ discard block |
||
| 1488 | 1488 | dol_syslog(get_only_class($this) . "::delete", LOG_DEBUG); |
| 1489 | 1489 | |
| 1490 | 1490 | // Remove rights |
| 1491 | - $sql = "DELETE FROM " . $this->db->prefix() . "user_rights WHERE fk_user = " . ((int)$this->id); |
|
| 1491 | + $sql = "DELETE FROM " . $this->db->prefix() . "user_rights WHERE fk_user = " . ((int) $this->id); |
|
| 1492 | 1492 | |
| 1493 | 1493 | if (!$error && !$this->db->query($sql)) { |
| 1494 | 1494 | $error++; |
@@ -1496,14 +1496,14 @@ discard block |
||
| 1496 | 1496 | } |
| 1497 | 1497 | |
| 1498 | 1498 | // Remove group |
| 1499 | - $sql = "DELETE FROM " . $this->db->prefix() . "usergroup_user WHERE fk_user = " . ((int)$this->id); |
|
| 1499 | + $sql = "DELETE FROM " . $this->db->prefix() . "usergroup_user WHERE fk_user = " . ((int) $this->id); |
|
| 1500 | 1500 | if (!$error && !$this->db->query($sql)) { |
| 1501 | 1501 | $error++; |
| 1502 | 1502 | $this->error = $this->db->lasterror(); |
| 1503 | 1503 | } |
| 1504 | 1504 | |
| 1505 | 1505 | // Remove params |
| 1506 | - $sql = "DELETE FROM " . $this->db->prefix() . "user_param WHERE fk_user = " . ((int)$this->id); |
|
| 1506 | + $sql = "DELETE FROM " . $this->db->prefix() . "user_param WHERE fk_user = " . ((int) $this->id); |
|
| 1507 | 1507 | if (!$error && !$this->db->query($sql)) { |
| 1508 | 1508 | $error++; |
| 1509 | 1509 | $this->error = $this->db->lasterror(); |
@@ -1511,7 +1511,7 @@ discard block |
||
| 1511 | 1511 | |
| 1512 | 1512 | // If contact, remove link |
| 1513 | 1513 | if ($this->contact_id > 0) { |
| 1514 | - $sql = "UPDATE " . $this->db->prefix() . "socpeople SET fk_user_creat = null WHERE rowid = " . ((int)$this->contact_id); |
|
| 1514 | + $sql = "UPDATE " . $this->db->prefix() . "socpeople SET fk_user_creat = null WHERE rowid = " . ((int) $this->contact_id); |
|
| 1515 | 1515 | if (!$error && !$this->db->query($sql)) { |
| 1516 | 1516 | $error++; |
| 1517 | 1517 | $this->error = $this->db->lasterror(); |
@@ -1529,7 +1529,7 @@ discard block |
||
| 1529 | 1529 | |
| 1530 | 1530 | // Remove user |
| 1531 | 1531 | if (!$error) { |
| 1532 | - $sql = "DELETE FROM " . $this->db->prefix() . "user WHERE rowid = " . ((int)$this->id); |
|
| 1532 | + $sql = "DELETE FROM " . $this->db->prefix() . "user WHERE rowid = " . ((int) $this->id); |
|
| 1533 | 1533 | dol_syslog(get_only_class($this) . "::delete", LOG_DEBUG); |
| 1534 | 1534 | if (!$this->db->query($sql)) { |
| 1535 | 1535 | $error++; |
@@ -1623,7 +1623,7 @@ discard block |
||
| 1623 | 1623 | |
| 1624 | 1624 | if ($entity < 0) { |
| 1625 | 1625 | if ((!isModEnabled('multicompany') || !getDolGlobalString('MULTICOMPANY_TRANSVERSE_MODE')) && (!empty($user->entity))) { |
| 1626 | - $sql .= " WHERE u.entity IN (0, " . ((int)$conf->entity) . ")"; |
|
| 1626 | + $sql .= " WHERE u.entity IN (0, " . ((int) $conf->entity) . ")"; |
|
| 1627 | 1627 | } else { |
| 1628 | 1628 | $sql .= " WHERE u.entity IS NOT NULL"; // multicompany is on in transverse mode or user making fetch is on entity 0, so user is allowed to fetch anywhere into database |
| 1629 | 1629 | } |
@@ -1632,7 +1632,7 @@ discard block |
||
| 1632 | 1632 | if (isModEnabled('multicompany') && getDolGlobalString('MULTICOMPANY_TRANSVERSE_MODE')) { |
| 1633 | 1633 | $sql .= " WHERE u.entity IS NOT NULL"; // multicompany is on in transverse mode or user making fetch is on entity 0, so user is allowed to fetch anywhere into database |
| 1634 | 1634 | } else { |
| 1635 | - $sql .= " WHERE u.entity IN (0, " . ((int)(($entity != '' && $entity >= 0) ? $entity : $conf->entity)) . ")"; // search in entity provided in parameter |
|
| 1635 | + $sql .= " WHERE u.entity IN (0, " . ((int) (($entity != '' && $entity >= 0) ? $entity : $conf->entity)) . ")"; // search in entity provided in parameter |
|
| 1636 | 1636 | } |
| 1637 | 1637 | } |
| 1638 | 1638 | |
@@ -1648,9 +1648,9 @@ discard block |
||
| 1648 | 1648 | } |
| 1649 | 1649 | $sql .= ")"; |
| 1650 | 1650 | } elseif ($fk_socpeople > 0) { |
| 1651 | - $sql .= " AND u.fk_socpeople = " . ((int)$fk_socpeople); |
|
| 1651 | + $sql .= " AND u.fk_socpeople = " . ((int) $fk_socpeople); |
|
| 1652 | 1652 | } else { |
| 1653 | - $sql .= " AND u.rowid = " . ((int)$id); |
|
| 1653 | + $sql .= " AND u.rowid = " . ((int) $id); |
|
| 1654 | 1654 | } |
| 1655 | 1655 | $sql .= " ORDER BY u.entity ASC"; // Avoid random result when there is 2 login in 2 different entities |
| 1656 | 1656 | |
@@ -1714,14 +1714,14 @@ discard block |
||
| 1714 | 1714 | $this->email = $obj->email; |
| 1715 | 1715 | $this->email_oauth2 = $obj->email_oauth2; |
| 1716 | 1716 | $this->personal_email = $obj->personal_email; |
| 1717 | - $this->socialnetworks = ($obj->socialnetworks ? (array)json_decode($obj->socialnetworks, true) : array()); |
|
| 1717 | + $this->socialnetworks = ($obj->socialnetworks ? (array) json_decode($obj->socialnetworks, true) : array()); |
|
| 1718 | 1718 | $this->job = $obj->job; |
| 1719 | 1719 | $this->signature = $obj->signature; |
| 1720 | 1720 | $this->admin = $obj->admin; |
| 1721 | 1721 | $this->note_public = $obj->note_public; |
| 1722 | 1722 | $this->note_private = $obj->note_private; |
| 1723 | 1723 | |
| 1724 | - $this->statut = $obj->status; // deprecated |
|
| 1724 | + $this->statut = $obj->status; // deprecated |
|
| 1725 | 1725 | $this->status = $obj->status; |
| 1726 | 1726 | |
| 1727 | 1727 | $this->photo = $obj->photo; |
@@ -1810,8 +1810,8 @@ discard block |
||
| 1810 | 1810 | |
| 1811 | 1811 | // Load user->conf for user |
| 1812 | 1812 | $sql = "SELECT param, value FROM " . $this->db->prefix() . "user_param"; |
| 1813 | - $sql .= " WHERE fk_user = " . ((int)$this->id); |
|
| 1814 | - $sql .= " AND entity = " . ((int)$conf->entity); |
|
| 1813 | + $sql .= " WHERE fk_user = " . ((int) $this->id); |
|
| 1814 | + $sql .= " AND entity = " . ((int) $conf->entity); |
|
| 1815 | 1815 | //dol_syslog(get_only_class($this).'::fetch load personalized conf', LOG_DEBUG); |
| 1816 | 1816 | $resql = $this->db->query($sql); |
| 1817 | 1817 | if ($resql) { |
@@ -1849,7 +1849,7 @@ discard block |
||
| 1849 | 1849 | if (getDolGlobalString('MAIN_ENABLE_DEFAULT_VALUES')) { |
| 1850 | 1850 | // Load user->default_values for user. TODO Save this in memcached ? |
| 1851 | 1851 | $defaultValues = new DefaultValues($this->db); |
| 1852 | - $result = $defaultValues->fetchAll('', '', 0, 0, '(t.user_id:in:0,' . $this->id . ') AND (entity:in:' . (isset($this->entity) ? $this->entity : $conf->entity) . ',' . $conf->entity . ')'); // User 0 (all) + me (if defined) |
|
| 1852 | + $result = $defaultValues->fetchAll('', '', 0, 0, '(t.user_id:in:0,' . $this->id . ') AND (entity:in:' . (isset($this->entity) ? $this->entity : $conf->entity) . ',' . $conf->entity . ')'); // User 0 (all) + me (if defined) |
|
| 1853 | 1853 | //$result = $defaultValues->fetchAll('', '', 0, 0, array('t.user_id'=>array(0, $this->id), 'entity'=>array((isset($this->entity) ? $this->entity : $conf->entity), $conf->entity))); // User 0 (all) + me (if defined) |
| 1854 | 1854 | |
| 1855 | 1855 | if (!is_array($result) && $result < 0) { |
@@ -2003,12 +2003,12 @@ discard block |
||
| 2003 | 2003 | $result = $this->create($user, 1); |
| 2004 | 2004 | if ($result > 0) { |
| 2005 | 2005 | $sql = "UPDATE " . $this->db->prefix() . "user"; |
| 2006 | - $sql .= " SET fk_socpeople=" . ((int)$contact->id); |
|
| 2006 | + $sql .= " SET fk_socpeople=" . ((int) $contact->id); |
|
| 2007 | 2007 | $sql .= ", civility='" . $this->db->escape($contact->civility_code) . "'"; |
| 2008 | 2008 | if ($contact->socid > 0) { |
| 2009 | - $sql .= ", fk_soc=" . ((int)$contact->socid); |
|
| 2009 | + $sql .= ", fk_soc=" . ((int) $contact->socid); |
|
| 2010 | 2010 | } |
| 2011 | - $sql .= " WHERE rowid=" . ((int)$this->id); |
|
| 2011 | + $sql .= " WHERE rowid=" . ((int) $this->id); |
|
| 2012 | 2012 | |
| 2013 | 2013 | $resql = $this->db->query($sql); |
| 2014 | 2014 | |
@@ -2057,8 +2057,8 @@ discard block |
||
| 2057 | 2057 | // Clean parameters |
| 2058 | 2058 | $this->setUpperOrLowerCase(); |
| 2059 | 2059 | |
| 2060 | - $this->civility_code = trim((string)$this->civility_code); |
|
| 2061 | - $this->login = trim((string)$this->login); |
|
| 2060 | + $this->civility_code = trim((string) $this->civility_code); |
|
| 2061 | + $this->login = trim((string) $this->login); |
|
| 2062 | 2062 | if (!isset($this->entity)) { |
| 2063 | 2063 | $this->entity = $conf->entity; // If not defined, we use default value |
| 2064 | 2064 | } |
@@ -2090,7 +2090,7 @@ discard block |
||
| 2090 | 2090 | |
| 2091 | 2091 | // Check if login already exists in same entity or into entity 0. |
| 2092 | 2092 | if ($this->login) { |
| 2093 | - $sqltochecklogin = "SELECT COUNT(*) as nb FROM " . $this->db->prefix() . "user WHERE entity IN (" . $this->db->sanitize((int)$this->entity) . ", 0) AND login = '" . $this->db->escape($this->login) . "'"; |
|
| 2093 | + $sqltochecklogin = "SELECT COUNT(*) as nb FROM " . $this->db->prefix() . "user WHERE entity IN (" . $this->db->sanitize((int) $this->entity) . ", 0) AND login = '" . $this->db->escape($this->login) . "'"; |
|
| 2094 | 2094 | $resqltochecklogin = $this->db->query($sqltochecklogin); |
| 2095 | 2095 | if ($resqltochecklogin) { |
| 2096 | 2096 | $objtochecklogin = $this->db->fetch_object($resqltochecklogin); |
@@ -2105,7 +2105,7 @@ discard block |
||
| 2105 | 2105 | } |
| 2106 | 2106 | } |
| 2107 | 2107 | if (!empty($this->email)) { |
| 2108 | - $sqltochecklogin = "SELECT COUNT(*) as nb FROM " . $this->db->prefix() . "user WHERE entity IN (" . $this->db->sanitize((int)$this->entity) . ", 0) AND email = '" . $this->db->escape($this->email) . "'"; |
|
| 2108 | + $sqltochecklogin = "SELECT COUNT(*) as nb FROM " . $this->db->prefix() . "user WHERE entity IN (" . $this->db->sanitize((int) $this->entity) . ", 0) AND email = '" . $this->db->escape($this->email) . "'"; |
|
| 2109 | 2109 | $resqltochecklogin = $this->db->query($sqltochecklogin); |
| 2110 | 2110 | if ($resqltochecklogin) { |
| 2111 | 2111 | $objtochecklogin = $this->db->fetch_object($resqltochecklogin); |
@@ -2122,7 +2122,7 @@ discard block |
||
| 2122 | 2122 | |
| 2123 | 2123 | // Insert into database |
| 2124 | 2124 | $sql = "INSERT INTO " . $this->db->prefix() . "user (datec, login, ldap_sid, entity)"; |
| 2125 | - $sql .= " VALUES('" . $this->db->idate($this->datec) . "', '" . $this->db->escape($this->login) . "', '" . $this->db->escape($this->ldap_sid) . "', " . ((int)$this->entity) . ")"; |
|
| 2125 | + $sql .= " VALUES('" . $this->db->idate($this->datec) . "', '" . $this->db->escape($this->login) . "', '" . $this->db->escape($this->ldap_sid) . "', " . ((int) $this->entity) . ")"; |
|
| 2126 | 2126 | $result = $this->db->query($sql); |
| 2127 | 2127 | |
| 2128 | 2128 | dol_syslog(get_only_class($this) . "::create", LOG_DEBUG); |
@@ -2200,7 +2200,7 @@ discard block |
||
| 2200 | 2200 | $num = 0; |
| 2201 | 2201 | $sql = "SELECT id FROM " . $this->db->prefix() . "rights_def"; |
| 2202 | 2202 | $sql .= " WHERE bydefault = 1"; |
| 2203 | - $sql .= " AND entity = " . ((int)$conf->entity); |
|
| 2203 | + $sql .= " AND entity = " . ((int) $conf->entity); |
|
| 2204 | 2204 | |
| 2205 | 2205 | $resql = $this->db->query($sql); |
| 2206 | 2206 | if ($resql) { |
@@ -2251,48 +2251,48 @@ discard block |
||
| 2251 | 2251 | dol_syslog(get_only_class($this) . "::update notrigger=" . $notrigger . ", nosyncmember=" . $nosyncmember . ", nosyncmemberpass=" . $nosyncmemberpass); |
| 2252 | 2252 | |
| 2253 | 2253 | // Clean parameters |
| 2254 | - $this->civility_code = trim((string)$this->civility_code); |
|
| 2255 | - $this->lastname = trim((string)$this->lastname); |
|
| 2256 | - $this->firstname = trim((string)$this->firstname); |
|
| 2257 | - $this->ref_employee = trim((string)$this->ref_employee); |
|
| 2258 | - $this->national_registration_number = trim((string)$this->national_registration_number); |
|
| 2254 | + $this->civility_code = trim((string) $this->civility_code); |
|
| 2255 | + $this->lastname = trim((string) $this->lastname); |
|
| 2256 | + $this->firstname = trim((string) $this->firstname); |
|
| 2257 | + $this->ref_employee = trim((string) $this->ref_employee); |
|
| 2258 | + $this->national_registration_number = trim((string) $this->national_registration_number); |
|
| 2259 | 2259 | $this->employee = ($this->employee > 0 ? $this->employee : 0); |
| 2260 | - $this->login = trim((string)$this->login); |
|
| 2261 | - $this->gender = trim((string)$this->gender); |
|
| 2260 | + $this->login = trim((string) $this->login); |
|
| 2261 | + $this->gender = trim((string) $this->gender); |
|
| 2262 | 2262 | |
| 2263 | - $this->pass = trim((string)$this->pass); |
|
| 2264 | - $this->api_key = trim((string)$this->api_key); |
|
| 2263 | + $this->pass = trim((string) $this->pass); |
|
| 2264 | + $this->api_key = trim((string) $this->api_key); |
|
| 2265 | 2265 | $this->datestartvalidity = empty($this->datestartvalidity) ? '' : $this->datestartvalidity; |
| 2266 | 2266 | $this->dateendvalidity = empty($this->dateendvalidity) ? '' : $this->dateendvalidity; |
| 2267 | 2267 | |
| 2268 | - $this->address = trim((string)$this->address); |
|
| 2269 | - $this->zip = trim((string)$this->zip); |
|
| 2270 | - $this->town = trim((string)$this->town); |
|
| 2268 | + $this->address = trim((string) $this->address); |
|
| 2269 | + $this->zip = trim((string) $this->zip); |
|
| 2270 | + $this->town = trim((string) $this->town); |
|
| 2271 | 2271 | |
| 2272 | 2272 | $this->state_id = ($this->state_id > 0 ? $this->state_id : 0); |
| 2273 | 2273 | $this->country_id = ($this->country_id > 0 ? $this->country_id : 0); |
| 2274 | - $this->office_phone = trim((string)$this->office_phone); |
|
| 2275 | - $this->office_fax = trim((string)$this->office_fax); |
|
| 2276 | - $this->user_mobile = trim((string)$this->user_mobile); |
|
| 2277 | - $this->personal_mobile = trim((string)$this->personal_mobile); |
|
| 2278 | - $this->email = trim((string)$this->email); |
|
| 2279 | - $this->personal_email = trim((string)$this->personal_email); |
|
| 2280 | - |
|
| 2281 | - $this->job = trim((string)$this->job); |
|
| 2282 | - $this->signature = trim((string)$this->signature); |
|
| 2283 | - $this->note_public = trim((string)$this->note_public); |
|
| 2284 | - $this->note_private = trim((string)$this->note_private); |
|
| 2285 | - $this->openid = trim((string)$this->openid); |
|
| 2274 | + $this->office_phone = trim((string) $this->office_phone); |
|
| 2275 | + $this->office_fax = trim((string) $this->office_fax); |
|
| 2276 | + $this->user_mobile = trim((string) $this->user_mobile); |
|
| 2277 | + $this->personal_mobile = trim((string) $this->personal_mobile); |
|
| 2278 | + $this->email = trim((string) $this->email); |
|
| 2279 | + $this->personal_email = trim((string) $this->personal_email); |
|
| 2280 | + |
|
| 2281 | + $this->job = trim((string) $this->job); |
|
| 2282 | + $this->signature = trim((string) $this->signature); |
|
| 2283 | + $this->note_public = trim((string) $this->note_public); |
|
| 2284 | + $this->note_private = trim((string) $this->note_private); |
|
| 2285 | + $this->openid = trim((string) $this->openid); |
|
| 2286 | 2286 | $this->admin = ($this->admin > 0 ? $this->admin : 0); |
| 2287 | 2287 | |
| 2288 | - $this->accountancy_code = trim((string)$this->accountancy_code); |
|
| 2289 | - $this->color = trim((string)$this->color); |
|
| 2288 | + $this->accountancy_code = trim((string) $this->accountancy_code); |
|
| 2289 | + $this->color = trim((string) $this->color); |
|
| 2290 | 2290 | $this->dateemployment = empty($this->dateemployment) ? '' : $this->dateemployment; |
| 2291 | 2291 | $this->dateemploymentend = empty($this->dateemploymentend) ? '' : $this->dateemploymentend; |
| 2292 | 2292 | |
| 2293 | 2293 | $this->birth = empty($this->birth) ? '' : $this->birth; |
| 2294 | - $this->fk_warehouse = (int)$this->fk_warehouse; |
|
| 2295 | - $this->fk_establishment = (int)$this->fk_establishment; |
|
| 2294 | + $this->fk_warehouse = (int) $this->fk_warehouse; |
|
| 2295 | + $this->fk_establishment = (int) $this->fk_establishment; |
|
| 2296 | 2296 | |
| 2297 | 2297 | $this->setUpperOrLowerCase(); |
| 2298 | 2298 | |
@@ -2318,7 +2318,7 @@ discard block |
||
| 2318 | 2318 | |
| 2319 | 2319 | // Check if login already exists in same entity or into entity 0. |
| 2320 | 2320 | if (is_object($this->oldcopy) && !$this->oldcopy->isEmpty() && $this->oldcopy->login != $this->login) { |
| 2321 | - $sqltochecklogin = "SELECT COUNT(*) as nb FROM " . $this->db->prefix() . "user WHERE entity IN (" . $this->db->sanitize((int)$this->entity) . ", 0) AND login = '" . $this->db->escape($this->login) . "'"; |
|
| 2321 | + $sqltochecklogin = "SELECT COUNT(*) as nb FROM " . $this->db->prefix() . "user WHERE entity IN (" . $this->db->sanitize((int) $this->entity) . ", 0) AND login = '" . $this->db->escape($this->login) . "'"; |
|
| 2322 | 2322 | $resqltochecklogin = $this->db->query($sqltochecklogin); |
| 2323 | 2323 | if ($resqltochecklogin) { |
| 2324 | 2324 | $objtochecklogin = $this->db->fetch_object($resqltochecklogin); |
@@ -2332,7 +2332,7 @@ discard block |
||
| 2332 | 2332 | } |
| 2333 | 2333 | } |
| 2334 | 2334 | if (is_object($this->oldcopy) && !$this->oldcopy->isEmpty() && !empty($this->email) && $this->oldcopy->email != $this->email) { |
| 2335 | - $sqltochecklogin = "SELECT COUNT(*) as nb FROM " . $this->db->prefix() . "user WHERE entity IN (" . $this->db->sanitize((int)$this->entity) . ", 0) AND email = '" . $this->db->escape($this->email) . "'"; |
|
| 2335 | + $sqltochecklogin = "SELECT COUNT(*) as nb FROM " . $this->db->prefix() . "user WHERE entity IN (" . $this->db->sanitize((int) $this->entity) . ", 0) AND email = '" . $this->db->escape($this->email) . "'"; |
|
| 2336 | 2336 | $resqltochecklogin = $this->db->query($sqltochecklogin); |
| 2337 | 2337 | if ($resqltochecklogin) { |
| 2338 | 2338 | $objtochecklogin = $this->db->fetch_object($resqltochecklogin); |
@@ -2353,13 +2353,13 @@ discard block |
||
| 2353 | 2353 | $sql .= ", firstname = '" . $this->db->escape($this->firstname) . "'"; |
| 2354 | 2354 | $sql .= ", ref_employee = '" . $this->db->escape($this->ref_employee) . "'"; |
| 2355 | 2355 | $sql .= ", national_registration_number = '" . $this->db->escape($this->national_registration_number) . "'"; |
| 2356 | - $sql .= ", employee = " . (int)$this->employee; |
|
| 2356 | + $sql .= ", employee = " . (int) $this->employee; |
|
| 2357 | 2357 | $sql .= ", login = '" . $this->db->escape($this->login) . "'"; |
| 2358 | 2358 | $sql .= ", api_key = " . ($this->api_key ? "'" . $this->db->escape(dolEncrypt($this->api_key, '', '', 'dolibarr')) . "'" : "null"); |
| 2359 | 2359 | $sql .= ", gender = " . ($this->gender != -1 ? "'" . $this->db->escape($this->gender) . "'" : "null"); // 'man' or 'woman' or 'other' |
| 2360 | 2360 | $sql .= ", birth=" . (strval($this->birth) != '' ? "'" . $this->db->idate($this->birth, 'tzserver') . "'" : 'null'); |
| 2361 | 2361 | if (!empty($user->admin)) { |
| 2362 | - $sql .= ", admin = " . (int)$this->admin; // admin flag can be set/unset only by an admin user |
|
| 2362 | + $sql .= ", admin = " . (int) $this->admin; // admin flag can be set/unset only by an admin user |
|
| 2363 | 2363 | } |
| 2364 | 2364 | $sql .= ", address = '" . $this->db->escape($this->address) . "'"; |
| 2365 | 2365 | $sql .= ", zip = '" . $this->db->escape($this->zip) . "'"; |
@@ -2402,14 +2402,14 @@ discard block |
||
| 2402 | 2402 | } |
| 2403 | 2403 | $sql .= ", weeklyhours= " . ($this->weeklyhours != '' ? "'" . $this->db->escape($this->weeklyhours) . "'" : "null"); |
| 2404 | 2404 | if (!empty($user->admin) && empty($user->entity) && $user->id != $this->id) { |
| 2405 | - $sql .= ", entity = " . ((int)$this->entity); // entity flag can be set/unset only by an another superadmin user |
|
| 2405 | + $sql .= ", entity = " . ((int) $this->entity); // entity flag can be set/unset only by an another superadmin user |
|
| 2406 | 2406 | } |
| 2407 | 2407 | $sql .= ", default_range = " . ($this->default_range > 0 ? $this->default_range : 'null'); |
| 2408 | 2408 | $sql .= ", default_c_exp_tax_cat = " . ($this->default_c_exp_tax_cat > 0 ? $this->default_c_exp_tax_cat : 'null'); |
| 2409 | 2409 | $sql .= ", fk_warehouse = " . ($this->fk_warehouse > 0 ? $this->fk_warehouse : "null"); |
| 2410 | 2410 | $sql .= ", fk_establishment = " . ($this->fk_establishment > 0 ? $this->fk_establishment : "null"); |
| 2411 | 2411 | $sql .= ", lang = " . ($this->lang ? "'" . $this->db->escape($this->lang) . "'" : "null"); |
| 2412 | - $sql .= " WHERE rowid = " . ((int)$this->id); |
|
| 2412 | + $sql .= " WHERE rowid = " . ((int) $this->id); |
|
| 2413 | 2413 | |
| 2414 | 2414 | dol_syslog(get_only_class($this) . "::update", LOG_DEBUG); |
| 2415 | 2415 | $resql = $this->db->query($sql); |
@@ -2430,7 +2430,7 @@ discard block |
||
| 2430 | 2430 | // If user is linked to a member, remove old link to this member |
| 2431 | 2431 | if ($this->fk_member > 0) { |
| 2432 | 2432 | dol_syslog(get_only_class($this) . "::update remove link with member. We will recreate it later", LOG_DEBUG); |
| 2433 | - $sql = "UPDATE " . $this->db->prefix() . "user SET fk_member = NULL where fk_member = " . ((int)$this->fk_member); |
|
| 2433 | + $sql = "UPDATE " . $this->db->prefix() . "user SET fk_member = NULL where fk_member = " . ((int) $this->fk_member); |
|
| 2434 | 2434 | $resql = $this->db->query($sql); |
| 2435 | 2435 | if (!$resql) { |
| 2436 | 2436 | $this->error = $this->db->error(); |
@@ -2440,7 +2440,7 @@ discard block |
||
| 2440 | 2440 | } |
| 2441 | 2441 | // Set link to user |
| 2442 | 2442 | dol_syslog(get_only_class($this) . "::update set link with member", LOG_DEBUG); |
| 2443 | - $sql = "UPDATE " . $this->db->prefix() . "user SET fk_member =" . ($this->fk_member > 0 ? ((int)$this->fk_member) : 'null') . " where rowid = " . ((int)$this->id); |
|
| 2443 | + $sql = "UPDATE " . $this->db->prefix() . "user SET fk_member =" . ($this->fk_member > 0 ? ((int) $this->fk_member) : 'null') . " where rowid = " . ((int) $this->id); |
|
| 2444 | 2444 | $resql = $this->db->query($sql); |
| 2445 | 2445 | if (!$resql) { |
| 2446 | 2446 | $this->error = $this->db->error(); |
@@ -2659,7 +2659,7 @@ discard block |
||
| 2659 | 2659 | } else { |
| 2660 | 2660 | $sql .= ", pass = '" . $this->db->escape($password) . "'"; |
| 2661 | 2661 | } |
| 2662 | - $sql .= " WHERE rowid = " . ((int)$this->id); |
|
| 2662 | + $sql .= " WHERE rowid = " . ((int) $this->id); |
|
| 2663 | 2663 | |
| 2664 | 2664 | dol_syslog(get_only_class($this) . "::setPassword", LOG_DEBUG); |
| 2665 | 2665 | $result = $this->db->query($sql); |
@@ -2717,7 +2717,7 @@ discard block |
||
| 2717 | 2717 | // After receiving confirmation link, we will erase and store it in pass_crypted |
| 2718 | 2718 | $sql = "UPDATE " . $this->db->prefix() . "user"; |
| 2719 | 2719 | $sql .= " SET pass_temp = '" . $this->db->escape($password) . "'"; |
| 2720 | - $sql .= " WHERE rowid = " . ((int)$this->id); |
|
| 2720 | + $sql .= " WHERE rowid = " . ((int) $this->id); |
|
| 2721 | 2721 | |
| 2722 | 2722 | dol_syslog(get_only_class($this) . "::setPassword", LOG_DEBUG); // No log |
| 2723 | 2723 | $result = $this->db->query($sql); |
@@ -2793,7 +2793,7 @@ discard block |
||
| 2793 | 2793 | } elseif (!empty($this->pass_crypted)) { // If an encrypted password is already known, we save it directly into database because the previous create did not save it. |
| 2794 | 2794 | $sql = "UPDATE " . $this->db->prefix() . "user"; |
| 2795 | 2795 | $sql .= " SET pass_crypted = '" . $this->db->escape($this->pass_crypted) . "'"; |
| 2796 | - $sql .= " WHERE rowid=" . ((int)$this->id); |
|
| 2796 | + $sql .= " WHERE rowid=" . ((int) $this->id); |
|
| 2797 | 2797 | |
| 2798 | 2798 | $resql = $this->db->query($sql); |
| 2799 | 2799 | if (!$resql) { |
@@ -2803,8 +2803,8 @@ discard block |
||
| 2803 | 2803 | |
| 2804 | 2804 | if ($result > 0 && $member->socid) { // If member is linked to a thirdparty |
| 2805 | 2805 | $sql = "UPDATE " . $this->db->prefix() . "user"; |
| 2806 | - $sql .= " SET fk_soc=" . ((int)$member->socid); |
|
| 2807 | - $sql .= " WHERE rowid=" . ((int)$this->id); |
|
| 2806 | + $sql .= " SET fk_soc=" . ((int) $member->socid); |
|
| 2807 | + $sql .= " WHERE rowid=" . ((int) $this->id); |
|
| 2808 | 2808 | |
| 2809 | 2809 | dol_syslog(get_only_class($this) . "::create_from_member", LOG_DEBUG); |
| 2810 | 2810 | $resql = $this->db->query($sql); |
@@ -2849,7 +2849,7 @@ discard block |
||
| 2849 | 2849 | $sql .= " datelastlogin = '" . $this->db->idate($now) . "',"; |
| 2850 | 2850 | $sql .= " iplastlogin = '" . $this->db->escape($userremoteip) . "',"; |
| 2851 | 2851 | $sql .= " tms = tms"; // The last update date must change because the last login date is updated |
| 2852 | - $sql .= " WHERE rowid = " . ((int)$this->id); |
|
| 2852 | + $sql .= " WHERE rowid = " . ((int) $this->id); |
|
| 2853 | 2853 | |
| 2854 | 2854 | dol_syslog(get_only_class($this) . "::update_last_login_date user->id=" . $this->id . " " . $sql, LOG_DEBUG); |
| 2855 | 2855 | $resql = $this->db->query($sql); |
@@ -2988,7 +2988,7 @@ discard block |
||
| 2988 | 2988 | // phpcs:enable |
| 2989 | 2989 | $sql = "SELECT url, login, pass, poste "; |
| 2990 | 2990 | $sql .= " FROM " . $this->db->prefix() . "user_clicktodial as u"; |
| 2991 | - $sql .= " WHERE u.fk_user = " . ((int)$this->id); |
|
| 2991 | + $sql .= " WHERE u.fk_user = " . ((int) $this->id); |
|
| 2992 | 2992 | |
| 2993 | 2993 | $resql = $this->db->query($sql); |
| 2994 | 2994 | if ($resql) { |
@@ -3022,7 +3022,7 @@ discard block |
||
| 3022 | 3022 | $this->db->begin(); |
| 3023 | 3023 | |
| 3024 | 3024 | $sql = "DELETE FROM " . $this->db->prefix() . "user_clicktodial"; |
| 3025 | - $sql .= " WHERE fk_user = " . ((int)$this->id); |
|
| 3025 | + $sql .= " WHERE fk_user = " . ((int) $this->id); |
|
| 3026 | 3026 | |
| 3027 | 3027 | dol_syslog(get_only_class($this) . '::update_clicktodial', LOG_DEBUG); |
| 3028 | 3028 | $result = $this->db->query($sql); |
@@ -3065,14 +3065,14 @@ discard block |
||
| 3065 | 3065 | $this->db->begin(); |
| 3066 | 3066 | |
| 3067 | 3067 | $sql = "DELETE FROM " . $this->db->prefix() . "usergroup_user"; |
| 3068 | - $sql .= " WHERE fk_user = " . ((int)$this->id); |
|
| 3069 | - $sql .= " AND fk_usergroup = " . ((int)$group); |
|
| 3070 | - $sql .= " AND entity = " . ((int)$entity); |
|
| 3068 | + $sql .= " WHERE fk_user = " . ((int) $this->id); |
|
| 3069 | + $sql .= " AND fk_usergroup = " . ((int) $group); |
|
| 3070 | + $sql .= " AND entity = " . ((int) $entity); |
|
| 3071 | 3071 | |
| 3072 | 3072 | $result = $this->db->query($sql); |
| 3073 | 3073 | |
| 3074 | 3074 | $sql = "INSERT INTO " . $this->db->prefix() . "usergroup_user (entity, fk_user, fk_usergroup)"; |
| 3075 | - $sql .= " VALUES (" . ((int)$entity) . "," . ((int)$this->id) . "," . ((int)$group) . ")"; |
|
| 3075 | + $sql .= " VALUES (" . ((int) $entity) . "," . ((int) $this->id) . "," . ((int) $group) . ")"; |
|
| 3076 | 3076 | |
| 3077 | 3077 | $result = $this->db->query($sql); |
| 3078 | 3078 | if ($result) { |
@@ -3122,12 +3122,12 @@ discard block |
||
| 3122 | 3122 | $this->db->begin(); |
| 3123 | 3123 | |
| 3124 | 3124 | $sql = "DELETE FROM " . $this->db->prefix() . "usergroup_user"; |
| 3125 | - $sql .= " WHERE fk_user = " . ((int)$this->id); |
|
| 3126 | - $sql .= " AND fk_usergroup = " . ((int)$group); |
|
| 3125 | + $sql .= " WHERE fk_user = " . ((int) $this->id); |
|
| 3126 | + $sql .= " AND fk_usergroup = " . ((int) $group); |
|
| 3127 | 3127 | if (empty($entity)) { |
| 3128 | - $sql .= " AND entity IN (0, 1)"; // group may be in entity 0 (so $entity=0) and link with user into entity 1. |
|
| 3128 | + $sql .= " AND entity IN (0, 1)"; // group may be in entity 0 (so $entity=0) and link with user into entity 1. |
|
| 3129 | 3129 | } else { |
| 3130 | - $sql .= " AND entity = " . ((int)$entity); |
|
| 3130 | + $sql .= " AND entity = " . ((int) $entity); |
|
| 3131 | 3131 | } |
| 3132 | 3132 | |
| 3133 | 3133 | $result = $this->db->query($sql); |
@@ -3553,7 +3553,7 @@ discard block |
||
| 3553 | 3553 | $this->iplastlogin = '127.0.0.1'; |
| 3554 | 3554 | $this->datepreviouslogin = $now; |
| 3555 | 3555 | $this->ippreviouslogin = '127.0.0.1'; |
| 3556 | - $this->statut = 1; // deprecated |
|
| 3556 | + $this->statut = 1; // deprecated |
|
| 3557 | 3557 | $this->status = 1; |
| 3558 | 3558 | |
| 3559 | 3559 | $this->entity = 1; |
@@ -3574,7 +3574,7 @@ discard block |
||
| 3574 | 3574 | $sql = "SELECT u.rowid, u.login as ref, u.datec,"; |
| 3575 | 3575 | $sql .= " u.tms as date_modification, u.entity"; |
| 3576 | 3576 | $sql .= " FROM " . $this->db->prefix() . "user as u"; |
| 3577 | - $sql .= " WHERE u.rowid = " . ((int)$id); |
|
| 3577 | + $sql .= " WHERE u.rowid = " . ((int) $id); |
|
| 3578 | 3578 | |
| 3579 | 3579 | $result = $this->db->query($sql); |
| 3580 | 3580 | if ($result) { |
@@ -3646,13 +3646,13 @@ discard block |
||
| 3646 | 3646 | } |
| 3647 | 3647 | } |
| 3648 | 3648 | if ($admin >= 0) { |
| 3649 | - $sql .= " AND admin = " . (int)$admin; |
|
| 3649 | + $sql .= " AND admin = " . (int) $admin; |
|
| 3650 | 3650 | } |
| 3651 | 3651 | |
| 3652 | 3652 | $resql = $this->db->query($sql); |
| 3653 | 3653 | if ($resql) { |
| 3654 | 3654 | $obj = $this->db->fetch_object($resql); |
| 3655 | - $nb = (int)$obj->nb; |
|
| 3655 | + $nb = (int) $obj->nb; |
|
| 3656 | 3656 | |
| 3657 | 3657 | $this->db->free($resql); |
| 3658 | 3658 | return $nb; |
@@ -3726,7 +3726,7 @@ discard block |
||
| 3726 | 3726 | { |
| 3727 | 3727 | // phpcs:enable |
| 3728 | 3728 | $sql = "SELECT rowid FROM " . $this->db->prefix() . "user"; |
| 3729 | - $sql .= " WHERE fk_user = " . ((int)$this->id); |
|
| 3729 | + $sql .= " WHERE fk_user = " . ((int) $this->id); |
|
| 3730 | 3730 | |
| 3731 | 3731 | dol_syslog(get_only_class($this) . "::get_children", LOG_DEBUG); |
| 3732 | 3732 | $res = $this->db->query($sql); |
@@ -3872,7 +3872,7 @@ discard block |
||
| 3872 | 3872 | $keyfilter3 = '^' . $deleteafterid . '_'; |
| 3873 | 3873 | $keyfilter4 = '_' . $deleteafterid . '_'; |
| 3874 | 3874 | foreach (array_keys($this->users) as $key) { |
| 3875 | - $fullpath = (string)$this->users[$key]['fullpath']; |
|
| 3875 | + $fullpath = (string) $this->users[$key]['fullpath']; |
|
| 3876 | 3876 | if ( |
| 3877 | 3877 | preg_match('/' . $keyfilter1 . '/', $fullpath) || preg_match('/' . $keyfilter2 . '/', $fullpath) |
| 3878 | 3878 | || preg_match('/' . $keyfilter3 . '/', $fullpath) || preg_match('/' . $keyfilter4 . '/', $fullpath) |
@@ -4052,7 +4052,7 @@ discard block |
||
| 4052 | 4052 | |
| 4053 | 4053 | $sql = "SELECT rowid, email, user_mobile, civility, lastname, firstname"; |
| 4054 | 4054 | $sql .= " FROM " . $this->db->prefix() . "user"; |
| 4055 | - $sql .= " WHERE rowid = " . ((int)$rowid); |
|
| 4055 | + $sql .= " WHERE rowid = " . ((int) $rowid); |
|
| 4056 | 4056 | |
| 4057 | 4057 | $resql = $this->db->query($sql); |
| 4058 | 4058 | if ($resql) { |
@@ -4091,7 +4091,7 @@ discard block |
||
| 4091 | 4091 | |
| 4092 | 4092 | $encodedsecurekey = dol_hash($conf->file->instance_unique_id . 'uservirtualcard' . $this->id . '-' . $this->login, 'md5'); |
| 4093 | 4093 | if (isModEnabled('multicompany')) { |
| 4094 | - $entity_qr = '&entity=' . ((int)$conf->entity); |
|
| 4094 | + $entity_qr = '&entity=' . ((int) $conf->entity); |
|
| 4095 | 4095 | } else { |
| 4096 | 4096 | $entity_qr = ''; |
| 4097 | 4097 | } |
@@ -4144,7 +4144,7 @@ discard block |
||
| 4144 | 4144 | return -1; |
| 4145 | 4145 | } |
| 4146 | 4146 | |
| 4147 | - $this->findUserIdByEmailCache[$email] = (int)$obj->rowid; |
|
| 4147 | + $this->findUserIdByEmailCache[$email] = (int) $obj->rowid; |
|
| 4148 | 4148 | |
| 4149 | 4149 | return $this->findUserIdByEmailCache[$email]; |
| 4150 | 4150 | } |