@@ -213,8 +213,8 @@ discard block |
||
213 | 213 | /** |
214 | 214 | * @var int Thirdparty ID |
215 | 215 | */ |
216 | - public $socid; // both socid and fk_soc are used |
|
217 | - public $fk_soc; // both socid and fk_soc are used |
|
216 | + public $socid; // both socid and fk_soc are used |
|
217 | + public $fk_soc; // both socid and fk_soc are used |
|
218 | 218 | |
219 | 219 | /** |
220 | 220 | * @var string Thirdparty name |
@@ -447,13 +447,13 @@ discard block |
||
447 | 447 | if (!$user->hasRight('societe', 'client', 'voir')) { |
448 | 448 | $sql .= ", " . MAIN_DB_PREFIX . "societe as s"; |
449 | 449 | $sql .= ", " . MAIN_DB_PREFIX . "societe_commerciaux as sc"; |
450 | - $sql .= " WHERE sp.fk_soc = s.rowid AND s.rowid = sc.fk_soc AND sc.fk_user = " . ((int)$user->id); |
|
450 | + $sql .= " WHERE sp.fk_soc = s.rowid AND s.rowid = sc.fk_soc AND sc.fk_user = " . ((int) $user->id); |
|
451 | 451 | $clause = "AND"; |
452 | 452 | } |
453 | 453 | $sql .= " " . $clause . " sp.entity IN (" . getEntity($this->element) . ")"; |
454 | - $sql .= " AND (sp.priv='0' OR (sp.priv='1' AND sp.fk_user_creat = " . ((int)$user->id) . "))"; |
|
454 | + $sql .= " AND (sp.priv='0' OR (sp.priv='1' AND sp.fk_user_creat = " . ((int) $user->id) . "))"; |
|
455 | 455 | if ($user->socid > 0) { |
456 | - $sql .= " AND sp.fk_soc = " . ((int)$user->socid); |
|
456 | + $sql .= " AND sp.fk_soc = " . ((int) $user->socid); |
|
457 | 457 | } |
458 | 458 | // Add where from hooks |
459 | 459 | if (is_object($hookmanager)) { |
@@ -526,19 +526,19 @@ discard block |
||
526 | 526 | $sql .= ") VALUES ("; |
527 | 527 | $sql .= "'" . $this->db->idate($now) . "',"; |
528 | 528 | if ($this->socid > 0) { |
529 | - $sql .= " " . ((int)$this->socid) . ","; |
|
529 | + $sql .= " " . ((int) $this->socid) . ","; |
|
530 | 530 | } else { |
531 | 531 | $sql .= "null,"; |
532 | 532 | } |
533 | 533 | $sql .= "'" . $this->db->escape($this->name_alias) . "',"; |
534 | 534 | $sql .= "'" . $this->db->escape($this->lastname) . "',"; |
535 | 535 | $sql .= "'" . $this->db->escape($this->firstname) . "',"; |
536 | - $sql .= " " . ($user->id > 0 ? ((int)$user->id) : "null") . ","; |
|
537 | - $sql .= " " . ((int)$this->priv) . ","; |
|
536 | + $sql .= " " . ($user->id > 0 ? ((int) $user->id) : "null") . ","; |
|
537 | + $sql .= " " . ((int) $this->priv) . ","; |
|
538 | 538 | $sql .= " 0,"; |
539 | - $sql .= " " . ((int)$this->statut) . ","; |
|
539 | + $sql .= " " . ((int) $this->statut) . ","; |
|
540 | 540 | $sql .= " " . (!empty($this->canvas) ? "'" . $this->db->escape($this->canvas) . "'" : "null") . ","; |
541 | - $sql .= " " . ((int)$this->entity) . ","; |
|
541 | + $sql .= " " . ((int) $this->entity) . ","; |
|
542 | 542 | $sql .= "'" . $this->db->escape($this->ref_ext) . "',"; |
543 | 543 | $sql .= " " . (!empty($this->import_key) ? "'" . $this->db->escape($this->import_key) . "'" : "null"); |
544 | 544 | $sql .= ")"; |
@@ -640,7 +640,7 @@ discard block |
||
640 | 640 | |
641 | 641 | $sql = "UPDATE " . MAIN_DB_PREFIX . "socpeople SET"; |
642 | 642 | if ($this->socid > 0) { |
643 | - $sql .= " fk_soc = " . ((int)$this->socid) . ","; |
|
643 | + $sql .= " fk_soc = " . ((int) $this->socid) . ","; |
|
644 | 644 | } elseif ($this->socid == -1) { |
645 | 645 | $sql .= " fk_soc = NULL,"; |
646 | 646 | } |
@@ -670,11 +670,11 @@ discard block |
||
670 | 670 | if (isset($this->stcomm_id)) { |
671 | 671 | $sql .= ", fk_stcommcontact = " . ($this->stcomm_id > 0 || $this->stcomm_id == -1 ? $this->stcomm_id : "0"); |
672 | 672 | } |
673 | - $sql .= ", statut = " . ((int)$this->statut); |
|
673 | + $sql .= ", statut = " . ((int) $this->statut); |
|
674 | 674 | $sql .= ", fk_user_modif=" . ($user->id > 0 ? "'" . $this->db->escape($user->id) . "'" : "NULL"); |
675 | 675 | $sql .= ", default_lang=" . ($this->default_lang ? "'" . $this->db->escape($this->default_lang) . "'" : "NULL"); |
676 | - $sql .= ", entity = " . ((int)$this->entity); |
|
677 | - $sql .= " WHERE rowid = " . ((int)$id); |
|
676 | + $sql .= ", entity = " . ((int) $this->entity); |
|
677 | + $sql .= " WHERE rowid = " . ((int) $id); |
|
678 | 678 | |
679 | 679 | dol_syslog(get_only_class($this) . "::update", LOG_DEBUG); |
680 | 680 | $result = $this->db->query($sql); |
@@ -792,12 +792,12 @@ discard block |
||
792 | 792 | $error = 0; |
793 | 793 | |
794 | 794 | if (!isset($this->roles)) { |
795 | - return 0; // Avoid to loose roles when property not set |
|
795 | + return 0; // Avoid to loose roles when property not set |
|
796 | 796 | } |
797 | 797 | |
798 | 798 | $this->db->begin(); |
799 | 799 | |
800 | - $sql = "DELETE FROM " . MAIN_DB_PREFIX . "societe_contacts WHERE fk_socpeople=" . ((int)$this->id) . " AND entity IN (" . getEntity("contact") . ")"; |
|
800 | + $sql = "DELETE FROM " . MAIN_DB_PREFIX . "societe_contacts WHERE fk_socpeople=" . ((int) $this->id) . " AND entity IN (" . getEntity("contact") . ")"; |
|
801 | 801 | |
802 | 802 | $result = $this->db->query($sql); |
803 | 803 | if (!$result) { |
@@ -902,7 +902,7 @@ discard block |
||
902 | 902 | $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "societe as s ON c.fk_soc = s.rowid"; |
903 | 903 | $sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'c_stcommcontact as st ON c.fk_stcommcontact = st.id'; |
904 | 904 | if ($id) { |
905 | - $sql .= " WHERE c.rowid = " . ((int)$id); |
|
905 | + $sql .= " WHERE c.rowid = " . ((int) $id); |
|
906 | 906 | } else { |
907 | 907 | $sql .= " WHERE c.entity IN (" . getEntity($this->element) . ")"; |
908 | 908 | if ($ref_ext) { |
@@ -950,8 +950,8 @@ discard block |
||
950 | 950 | $this->country_code = $obj->country_id ? $obj->country_code : ''; |
951 | 951 | $this->country = $obj->country_id ? ($langs->trans('Country' . $obj->country_code) != 'Country' . $obj->country_code ? $langs->transnoentities('Country' . $obj->country_code) : $obj->country) : ''; |
952 | 952 | |
953 | - $this->fk_soc = $obj->fk_soc; // Both fk_soc and socid are used |
|
954 | - $this->socid = $obj->fk_soc; // Both fk_soc and socid are used |
|
953 | + $this->fk_soc = $obj->fk_soc; // Both fk_soc and socid are used |
|
954 | + $this->socid = $obj->fk_soc; // Both fk_soc and socid are used |
|
955 | 955 | $this->socname = $obj->socname; |
956 | 956 | $this->poste = $obj->poste; |
957 | 957 | $this->statut = $obj->statut; |
@@ -970,7 +970,7 @@ discard block |
||
970 | 970 | $this->phone_mobile = trim($obj->phone_mobile); |
971 | 971 | |
972 | 972 | $this->email = $obj->email; |
973 | - $this->socialnetworks = ($obj->socialnetworks ? (array)json_decode($obj->socialnetworks, true) : array()); |
|
973 | + $this->socialnetworks = ($obj->socialnetworks ? (array) json_decode($obj->socialnetworks, true) : array()); |
|
974 | 974 | $this->photo = $obj->photo; |
975 | 975 | $this->priv = $obj->priv; |
976 | 976 | $this->mail = $obj->email; |
@@ -992,7 +992,7 @@ discard block |
||
992 | 992 | // Search Dolibarr user linked to this contact |
993 | 993 | $sql = "SELECT u.rowid "; |
994 | 994 | $sql .= " FROM " . MAIN_DB_PREFIX . "user as u"; |
995 | - $sql .= " WHERE u.fk_socpeople = " . ((int)$this->id); |
|
995 | + $sql .= " WHERE u.fk_socpeople = " . ((int) $this->id); |
|
996 | 996 | |
997 | 997 | $resql = $this->db->query($sql); |
998 | 998 | if ($resql) { |
@@ -1015,7 +1015,7 @@ discard block |
||
1015 | 1015 | if ($user) { |
1016 | 1016 | $sql = "SELECT fk_user"; |
1017 | 1017 | $sql .= " FROM " . MAIN_DB_PREFIX . "user_alert"; |
1018 | - $sql .= " WHERE fk_user = " . ((int)$user->id) . " AND fk_contact = " . ((int)$id); |
|
1018 | + $sql .= " WHERE fk_user = " . ((int) $user->id) . " AND fk_contact = " . ((int) $id); |
|
1019 | 1019 | |
1020 | 1020 | $resql = $this->db->query($sql); |
1021 | 1021 | if ($resql) { |
@@ -1084,7 +1084,7 @@ discard block |
||
1084 | 1084 | $sql .= " FROM " . MAIN_DB_PREFIX . "societe_contacts as sc, " . MAIN_DB_PREFIX . "c_type_contact as tc"; |
1085 | 1085 | $sql .= " WHERE tc.rowid = sc.fk_c_type_contact"; |
1086 | 1086 | $sql .= " AND tc.source = 'external' AND tc.active=1"; |
1087 | - $sql .= " AND sc.fk_socpeople = " . ((int)$this->id); |
|
1087 | + $sql .= " AND sc.fk_socpeople = " . ((int) $this->id); |
|
1088 | 1088 | $sql .= " AND sc.entity IN (" . getEntity('societe') . ')'; |
1089 | 1089 | |
1090 | 1090 | $resql = $this->db->query($sql); |
@@ -1135,9 +1135,9 @@ discard block |
||
1135 | 1135 | $sql .= " birthday = " . ($this->birthday ? "'" . $this->db->idate($this->birthday) . "'" : "null"); |
1136 | 1136 | $sql .= ", photo = " . ($this->photo ? "'" . $this->db->escape($this->photo) . "'" : "null"); |
1137 | 1137 | if ($user) { |
1138 | - $sql .= ", fk_user_modif = " . ((int)$user->id); |
|
1138 | + $sql .= ", fk_user_modif = " . ((int) $user->id); |
|
1139 | 1139 | } |
1140 | - $sql .= " WHERE rowid = " . ((int)$id); |
|
1140 | + $sql .= " WHERE rowid = " . ((int) $id); |
|
1141 | 1141 | |
1142 | 1142 | dol_syslog(get_only_class($this) . "::update_perso this->birthday=" . $this->birthday . " -", LOG_DEBUG); |
1143 | 1143 | $resql = $this->db->query($sql); |
@@ -1150,12 +1150,12 @@ discard block |
||
1150 | 1150 | // Update birthday alert |
1151 | 1151 | if (!empty($this->birthday_alert)) { |
1152 | 1152 | //check existing |
1153 | - $sql_check = "SELECT rowid FROM " . MAIN_DB_PREFIX . "user_alert WHERE type = 1 AND fk_contact = " . ((int)$id) . " AND fk_user = " . ((int)$user->id); |
|
1153 | + $sql_check = "SELECT rowid FROM " . MAIN_DB_PREFIX . "user_alert WHERE type = 1 AND fk_contact = " . ((int) $id) . " AND fk_user = " . ((int) $user->id); |
|
1154 | 1154 | $result_check = $this->db->query($sql_check); |
1155 | 1155 | if (!$result_check || ($this->db->num_rows($result_check) < 1)) { |
1156 | 1156 | //insert |
1157 | 1157 | $sql = "INSERT INTO " . MAIN_DB_PREFIX . "user_alert(type, fk_contact, fk_user) "; |
1158 | - $sql .= "VALUES (1," . ((int)$id) . "," . ((int)$user->id) . ")"; |
|
1158 | + $sql .= "VALUES (1," . ((int) $id) . "," . ((int) $user->id) . ")"; |
|
1159 | 1159 | $result = $this->db->query($sql); |
1160 | 1160 | if (!$result) { |
1161 | 1161 | $error++; |
@@ -1166,7 +1166,7 @@ discard block |
||
1166 | 1166 | } |
1167 | 1167 | } else { |
1168 | 1168 | $sql = "DELETE FROM " . MAIN_DB_PREFIX . "user_alert "; |
1169 | - $sql .= "WHERE type=1 AND fk_contact=" . ((int)$id) . " AND fk_user=" . ((int)$user->id); |
|
1169 | + $sql .= "WHERE type=1 AND fk_contact=" . ((int) $id) . " AND fk_user=" . ((int) $user->id); |
|
1170 | 1170 | $result = $this->db->query($sql); |
1171 | 1171 | if (!$result) { |
1172 | 1172 | $error++; |
@@ -1343,7 +1343,7 @@ discard block |
||
1343 | 1343 | $sql = "SELECT tc.element, count(ec.rowid) as nb"; |
1344 | 1344 | $sql .= " FROM " . MAIN_DB_PREFIX . "element_contact as ec, " . MAIN_DB_PREFIX . "c_type_contact as tc"; |
1345 | 1345 | $sql .= " WHERE ec.fk_c_type_contact = tc.rowid"; |
1346 | - $sql .= " AND fk_socpeople = " . ((int)$this->id); |
|
1346 | + $sql .= " AND fk_socpeople = " . ((int) $this->id); |
|
1347 | 1347 | $sql .= " AND tc.source = 'external'"; |
1348 | 1348 | $sql .= " GROUP BY tc.element"; |
1349 | 1349 | |
@@ -1399,7 +1399,7 @@ discard block |
||
1399 | 1399 | $sql = "SELECT ec.rowid"; |
1400 | 1400 | $sql .= " FROM " . MAIN_DB_PREFIX . "element_contact ec,"; |
1401 | 1401 | $sql .= " " . MAIN_DB_PREFIX . "c_type_contact tc"; |
1402 | - $sql .= " WHERE ec.fk_socpeople=" . ((int)$this->id); |
|
1402 | + $sql .= " WHERE ec.fk_socpeople=" . ((int) $this->id); |
|
1403 | 1403 | $sql .= " AND ec.fk_c_type_contact=tc.rowid"; |
1404 | 1404 | $sql .= " AND tc.source='external'"; |
1405 | 1405 | dol_syslog(__METHOD__, LOG_DEBUG); |
@@ -1412,7 +1412,7 @@ discard block |
||
1412 | 1412 | $obj = $this->db->fetch_object($resql); |
1413 | 1413 | |
1414 | 1414 | $sqldel = "DELETE FROM " . MAIN_DB_PREFIX . "element_contact"; |
1415 | - $sqldel .= " WHERE rowid = " . ((int)$obj->rowid); |
|
1415 | + $sqldel .= " WHERE rowid = " . ((int) $obj->rowid); |
|
1416 | 1416 | dol_syslog(__METHOD__, LOG_DEBUG); |
1417 | 1417 | $result = $this->db->query($sqldel); |
1418 | 1418 | if (!$result) { |
@@ -1430,7 +1430,7 @@ discard block |
||
1430 | 1430 | |
1431 | 1431 | if (!$error) { |
1432 | 1432 | // Remove Roles |
1433 | - $sql = "DELETE FROM " . MAIN_DB_PREFIX . "societe_contacts WHERE fk_socpeople = " . ((int)$this->id); |
|
1433 | + $sql = "DELETE FROM " . MAIN_DB_PREFIX . "societe_contacts WHERE fk_socpeople = " . ((int) $this->id); |
|
1434 | 1434 | dol_syslog(__METHOD__, LOG_DEBUG); |
1435 | 1435 | $resql = $this->db->query($sql); |
1436 | 1436 | if (!$resql) { |
@@ -1442,7 +1442,7 @@ discard block |
||
1442 | 1442 | |
1443 | 1443 | if (!$error) { |
1444 | 1444 | // Remove Notifications |
1445 | - $sql = "DELETE FROM " . MAIN_DB_PREFIX . "notify_def WHERE fk_contact = " . ((int)$this->id); |
|
1445 | + $sql = "DELETE FROM " . MAIN_DB_PREFIX . "notify_def WHERE fk_contact = " . ((int) $this->id); |
|
1446 | 1446 | dol_syslog(__METHOD__, LOG_DEBUG); |
1447 | 1447 | $resql = $this->db->query($sql); |
1448 | 1448 | if (!$resql) { |
@@ -1454,7 +1454,7 @@ discard block |
||
1454 | 1454 | |
1455 | 1455 | if (!$error) { |
1456 | 1456 | // Remove category |
1457 | - $sql = "DELETE FROM " . MAIN_DB_PREFIX . "categorie_contact WHERE fk_socpeople = " . ((int)$this->id); |
|
1457 | + $sql = "DELETE FROM " . MAIN_DB_PREFIX . "categorie_contact WHERE fk_socpeople = " . ((int) $this->id); |
|
1458 | 1458 | dol_syslog(__METHOD__, LOG_DEBUG); |
1459 | 1459 | $resql = $this->db->query($sql); |
1460 | 1460 | if (!$resql) { |
@@ -1466,7 +1466,7 @@ discard block |
||
1466 | 1466 | |
1467 | 1467 | if (!$error) { |
1468 | 1468 | $sql = "DELETE FROM " . MAIN_DB_PREFIX . "socpeople"; |
1469 | - $sql .= " WHERE rowid = " . ((int)$this->id); |
|
1469 | + $sql .= " WHERE rowid = " . ((int) $this->id); |
|
1470 | 1470 | dol_syslog(__METHOD__, LOG_DEBUG); |
1471 | 1471 | $result = $this->db->query($sql); |
1472 | 1472 | if (!$result) { |
@@ -1505,7 +1505,7 @@ discard block |
||
1505 | 1505 | $sql = "SELECT c.rowid, c.datec as datec, c.fk_user_creat,"; |
1506 | 1506 | $sql .= " c.tms as tms, c.fk_user_modif"; |
1507 | 1507 | $sql .= " FROM " . MAIN_DB_PREFIX . "socpeople as c"; |
1508 | - $sql .= " WHERE c.rowid = " . ((int)$id); |
|
1508 | + $sql .= " WHERE c.rowid = " . ((int) $id); |
|
1509 | 1509 | |
1510 | 1510 | $resql = $this->db->query($sql); |
1511 | 1511 | if ($resql) { |
@@ -1666,9 +1666,9 @@ discard block |
||
1666 | 1666 | |
1667 | 1667 | // User disable |
1668 | 1668 | $sql = "UPDATE " . MAIN_DB_PREFIX . "socpeople"; |
1669 | - $sql .= " SET statut = " . ((int)$this->statut); |
|
1670 | - $sql .= ", fk_user_modif = " . ((int)$user->id); |
|
1671 | - $sql .= " WHERE rowid = " . ((int)$this->id); |
|
1669 | + $sql .= " SET statut = " . ((int) $this->statut); |
|
1670 | + $sql .= ", fk_user_modif = " . ((int) $user->id); |
|
1671 | + $sql .= " WHERE rowid = " . ((int) $this->id); |
|
1672 | 1672 | $result = $this->db->query($sql); |
1673 | 1673 | |
1674 | 1674 | dol_syslog(get_only_class($this) . "::setstatus", LOG_DEBUG); |
@@ -1725,7 +1725,7 @@ discard block |
||
1725 | 1725 | $sql .= ", " . MAIN_DB_PREFIX . "societe_contacts sc"; |
1726 | 1726 | $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "socpeople sp"; |
1727 | 1727 | $sql .= " ON sc.fk_socpeople = sp.rowid AND sp.statut = 1"; |
1728 | - $sql .= " WHERE sc.fk_soc =" . ((int)$this->socid); |
|
1728 | + $sql .= " WHERE sc.fk_soc =" . ((int) $this->socid); |
|
1729 | 1729 | $sql .= " AND sc.fk_c_type_contact=tc.rowid"; |
1730 | 1730 | $sql .= " AND tc.element = '" . $this->db->escape($element) . "'"; |
1731 | 1731 | $sql .= " AND sp.entity IN (" . getEntity('contact') . ")"; |
@@ -1763,7 +1763,7 @@ discard block |
||
1763 | 1763 | |
1764 | 1764 | $sql = "SELECT id, code, libelle as label, picto FROM " . MAIN_DB_PREFIX . "c_stcommcontact"; |
1765 | 1765 | if ($active >= 0) { |
1766 | - $sql .= " WHERE active = " . ((int)$active); |
|
1766 | + $sql .= " WHERE active = " . ((int) $active); |
|
1767 | 1767 | } |
1768 | 1768 | $resql = $this->db->query($sql); |
1769 | 1769 | $num = $this->db->num_rows($resql); |
@@ -842,8 +842,8 @@ discard block |
||
842 | 842 | $newclient = 3; //If prospect, we keep prospect tag |
843 | 843 | } |
844 | 844 | $sql = "UPDATE " . MAIN_DB_PREFIX . $this->table_element; |
845 | - $sql .= " SET client = " . ((int)$newclient); |
|
846 | - $sql .= " WHERE rowid = " . ((int)$this->id); |
|
845 | + $sql .= " SET client = " . ((int) $newclient); |
|
846 | + $sql .= " WHERE rowid = " . ((int) $this->id); |
|
847 | 847 | |
848 | 848 | $resql = $this->db->query($sql); |
849 | 849 | if ($resql) { |
@@ -886,7 +886,7 @@ discard block |
||
886 | 886 | // Position current discount |
887 | 887 | $sql = "UPDATE " . MAIN_DB_PREFIX . "societe "; |
888 | 888 | $sql .= " SET remise_client = '" . $this->db->escape($remise) . "'"; |
889 | - $sql .= " WHERE rowid = " . ((int)$this->id); |
|
889 | + $sql .= " WHERE rowid = " . ((int) $this->id); |
|
890 | 890 | $resql = $this->db->query($sql); |
891 | 891 | if (!$resql) { |
892 | 892 | $this->db->rollback(); |
@@ -897,9 +897,9 @@ discard block |
||
897 | 897 | // Writes trace in discount history |
898 | 898 | $sql = "INSERT INTO " . MAIN_DB_PREFIX . "societe_remise"; |
899 | 899 | $sql .= " (entity, datec, fk_soc, remise_client, note, fk_user_author)"; |
900 | - $sql .= " VALUES (" . $conf->entity . ", '" . $this->db->idate($now) . "', " . ((int)$this->id) . ", '" . $this->db->escape($remise) . "',"; |
|
900 | + $sql .= " VALUES (" . $conf->entity . ", '" . $this->db->idate($now) . "', " . ((int) $this->id) . ", '" . $this->db->escape($remise) . "',"; |
|
901 | 901 | $sql .= " '" . $this->db->escape($note) . "',"; |
902 | - $sql .= " " . ((int)$user->id); |
|
902 | + $sql .= " " . ((int) $user->id); |
|
903 | 903 | $sql .= ")"; |
904 | 904 | |
905 | 905 | $resql = $this->db->query($sql); |
@@ -946,7 +946,7 @@ discard block |
||
946 | 946 | // Position current discount |
947 | 947 | $sql = "UPDATE " . MAIN_DB_PREFIX . "societe "; |
948 | 948 | $sql .= " SET remise_supplier = '" . $this->db->escape($remise) . "'"; |
949 | - $sql .= " WHERE rowid = " . ((int)$this->id); |
|
949 | + $sql .= " WHERE rowid = " . ((int) $this->id); |
|
950 | 950 | $resql = $this->db->query($sql); |
951 | 951 | if (!$resql) { |
952 | 952 | $this->db->rollback(); |
@@ -957,9 +957,9 @@ discard block |
||
957 | 957 | // Writes trace in discount history |
958 | 958 | $sql = "INSERT INTO " . MAIN_DB_PREFIX . "societe_remise_supplier"; |
959 | 959 | $sql .= " (entity, datec, fk_soc, remise_supplier, note, fk_user_author)"; |
960 | - $sql .= " VALUES (" . $conf->entity . ", '" . $this->db->idate($now) . "', " . ((int)$this->id) . ", '" . $this->db->escape($remise) . "',"; |
|
960 | + $sql .= " VALUES (" . $conf->entity . ", '" . $this->db->idate($now) . "', " . ((int) $this->id) . ", '" . $this->db->escape($remise) . "',"; |
|
961 | 961 | $sql .= " '" . $this->db->escape($note) . "',"; |
962 | - $sql .= " " . ((int)$user->id); |
|
962 | + $sql .= " " . ((int) $user->id); |
|
963 | 963 | $sql .= ")"; |
964 | 964 | |
965 | 965 | $resql = $this->db->query($sql); |
@@ -1024,15 +1024,15 @@ discard block |
||
1024 | 1024 | |
1025 | 1025 | if ($price_base_type == 'TTC') { |
1026 | 1026 | $discount->amount_ttc = $discount->multicurrency_amount_ttc = price2num($remise, 'MT'); |
1027 | - $discount->amount_ht = $discount->multicurrency_amount_ht = price2num((float)$remise / (1 + (float)$vatrate / 100), 'MT'); |
|
1028 | - $discount->amount_tva = $discount->multicurrency_amount_tva = price2num((float)$discount->amount_ttc - (float)$discount->amount_ht, 'MT'); |
|
1027 | + $discount->amount_ht = $discount->multicurrency_amount_ht = price2num((float) $remise / (1 + (float) $vatrate / 100), 'MT'); |
|
1028 | + $discount->amount_tva = $discount->multicurrency_amount_tva = price2num((float) $discount->amount_ttc - (float) $discount->amount_ht, 'MT'); |
|
1029 | 1029 | } else { |
1030 | 1030 | $discount->amount_ht = $discount->multicurrency_amount_ht = price2num($remise, 'MT'); |
1031 | - $discount->amount_tva = $discount->multicurrency_amount_tva = price2num((float)$remise * (float)$vatrate / 100, 'MT'); |
|
1032 | - $discount->amount_ttc = $discount->multicurrency_amount_ttc = price2num((float)$discount->amount_ht + (float)$discount->amount_tva, 'MT'); |
|
1031 | + $discount->amount_tva = $discount->multicurrency_amount_tva = price2num((float) $remise * (float) $vatrate / 100, 'MT'); |
|
1032 | + $discount->amount_ttc = $discount->multicurrency_amount_ttc = price2num((float) $discount->amount_ht + (float) $discount->amount_tva, 'MT'); |
|
1033 | 1033 | } |
1034 | 1034 | |
1035 | - $discount->tva_tx = (float)price2num($vatrate); |
|
1035 | + $discount->tva_tx = (float) price2num($vatrate); |
|
1036 | 1036 | $discount->vat_src_code = $vat_src_code; |
1037 | 1037 | |
1038 | 1038 | $discount->description = $desc; |
@@ -1067,7 +1067,7 @@ discard block |
||
1067 | 1067 | if (empty($this->status)) { |
1068 | 1068 | $this->status = 0; |
1069 | 1069 | } |
1070 | - $this->name = $this->name ? trim($this->name) : trim((string)$this->nom); |
|
1070 | + $this->name = $this->name ? trim($this->name) : trim((string) $this->nom); |
|
1071 | 1071 | $this->setUpperOrLowerCase(); |
1072 | 1072 | $this->nom = $this->name; // For backward compatibility |
1073 | 1073 | if (empty($this->client)) { |
@@ -1076,12 +1076,12 @@ discard block |
||
1076 | 1076 | if (empty($this->fournisseur)) { |
1077 | 1077 | $this->fournisseur = 0; |
1078 | 1078 | } |
1079 | - $this->import_key = trim((string)$this->import_key); |
|
1079 | + $this->import_key = trim((string) $this->import_key); |
|
1080 | 1080 | |
1081 | - $this->accountancy_code_customer = trim((string)$this->code_compta); |
|
1082 | - $this->accountancy_code_supplier = trim((string)$this->code_compta_fournisseur); |
|
1083 | - $this->accountancy_code_buy = trim((string)$this->accountancy_code_buy); |
|
1084 | - $this->accountancy_code_sell = trim((string)$this->accountancy_code_sell); |
|
1081 | + $this->accountancy_code_customer = trim((string) $this->code_compta); |
|
1082 | + $this->accountancy_code_supplier = trim((string) $this->code_compta_fournisseur); |
|
1083 | + $this->accountancy_code_buy = trim((string) $this->accountancy_code_buy); |
|
1084 | + $this->accountancy_code_sell = trim((string) $this->accountancy_code_sell); |
|
1085 | 1085 | |
1086 | 1086 | if (!empty($this->multicurrency_code)) { |
1087 | 1087 | $this->fk_multicurrency = MultiCurrency::getIdFromCode($this->db, $this->multicurrency_code); |
@@ -1139,18 +1139,18 @@ discard block |
||
1139 | 1139 | } |
1140 | 1140 | $sql .= ") VALUES ('" . $this->db->escape($this->name) . "',"; |
1141 | 1141 | $sql .= " '" . $this->db->escape($this->name_alias) . "',"; |
1142 | - $sql .= " " . ((int)$this->entity) . ","; |
|
1142 | + $sql .= " " . ((int) $this->entity) . ","; |
|
1143 | 1143 | $sql .= " '" . $this->db->idate($this->date_creation) . "'"; |
1144 | - $sql .= ", " . (!empty($user->id) ? ((int)$user->id) : "null"); |
|
1145 | - $sql .= ", " . (!empty($this->typent_id) ? ((int)$this->typent_id) : "null"); |
|
1144 | + $sql .= ", " . (!empty($user->id) ? ((int) $user->id) : "null"); |
|
1145 | + $sql .= ", " . (!empty($this->typent_id) ? ((int) $this->typent_id) : "null"); |
|
1146 | 1146 | $sql .= ", " . (!empty($this->canvas) ? "'" . $this->db->escape($this->canvas) . "'" : "null"); |
1147 | - $sql .= ", " . ((int)$this->status); |
|
1147 | + $sql .= ", " . ((int) $this->status); |
|
1148 | 1148 | $sql .= ", " . (!empty($this->ref_ext) ? "'" . $this->db->escape($this->ref_ext) . "'" : "null"); |
1149 | 1149 | $sql .= ", 0"; |
1150 | - $sql .= ", " . (int)$this->fk_incoterms; |
|
1150 | + $sql .= ", " . (int) $this->fk_incoterms; |
|
1151 | 1151 | $sql .= ", '" . $this->db->escape($this->location_incoterms) . "'"; |
1152 | 1152 | $sql .= ", " . (!empty($this->import_key) ? "'" . $this->db->escape($this->import_key) . "'" : "null"); |
1153 | - $sql .= ", " . (int)$this->fk_multicurrency; |
|
1153 | + $sql .= ", " . (int) $this->fk_multicurrency; |
|
1154 | 1154 | $sql .= ", '" . $this->db->escape($this->multicurrency_code) . "'"; |
1155 | 1155 | if (!getDolGlobalString('MAIN_COMPANY_PERENTITY_SHARED')) { |
1156 | 1156 | $sql .= ", " . (empty($this->vat_reverse_charge) ? '0' : '1'); |
@@ -1169,7 +1169,7 @@ discard block |
||
1169 | 1169 | |
1170 | 1170 | // update accountancy for this entity |
1171 | 1171 | if (!$error && getDolGlobalString('MAIN_COMPANY_PERENTITY_SHARED')) { |
1172 | - $this->db->query("DELETE FROM " . MAIN_DB_PREFIX . "societe_perentity WHERE fk_soc = " . ((int)$this->id) . " AND entity = " . ((int)$conf->entity)); |
|
1172 | + $this->db->query("DELETE FROM " . MAIN_DB_PREFIX . "societe_perentity WHERE fk_soc = " . ((int) $this->id) . " AND entity = " . ((int) $conf->entity)); |
|
1173 | 1173 | |
1174 | 1174 | $sql = "INSERT INTO " . MAIN_DB_PREFIX . "societe_perentity ("; |
1175 | 1175 | $sql .= " fk_soc"; |
@@ -1181,7 +1181,7 @@ discard block |
||
1181 | 1181 | $sql .= ", accountancy_code_sell"; |
1182 | 1182 | $sql .= ") VALUES ("; |
1183 | 1183 | $sql .= $this->id; |
1184 | - $sql .= ", " . ((int)$conf->entity); |
|
1184 | + $sql .= ", " . ((int) $conf->entity); |
|
1185 | 1185 | $sql .= ", " . (empty($this->vat_reverse_charge) ? '0' : '1'); |
1186 | 1186 | $sql .= ", '" . $this->db->escape($this->accountancy_code_customer) . "'"; |
1187 | 1187 | $sql .= ", '" . $this->db->escape($this->accountancy_code_supplier) . "'"; |
@@ -1378,7 +1378,7 @@ discard block |
||
1378 | 1378 | } elseif ($key == 'ACCOUNTANCY_CODE_SUPPLIER') { |
1379 | 1379 | $keymin = 'code_compta_fournisseur'; |
1380 | 1380 | } |
1381 | - $i = (int)preg_replace('/[^0-9]/', '', $key); |
|
1381 | + $i = (int) preg_replace('/[^0-9]/', '', $key); |
|
1382 | 1382 | $vallabel = $this->$keymin; |
1383 | 1383 | |
1384 | 1384 | if ($i > 0) { |
@@ -1585,7 +1585,7 @@ discard block |
||
1585 | 1585 | } |
1586 | 1586 | } |
1587 | 1587 | |
1588 | - return (bool)$isACompany; |
|
1588 | + return (bool) $isACompany; |
|
1589 | 1589 | } |
1590 | 1590 | |
1591 | 1591 | /** |
@@ -1718,40 +1718,40 @@ discard block |
||
1718 | 1718 | // Clean parameters |
1719 | 1719 | $this->id = $id; |
1720 | 1720 | $this->entity = ((isset($this->entity) && is_numeric($this->entity)) ? $this->entity : $conf->entity); |
1721 | - $this->name = $this->name ? trim($this->name) : trim((string)$this->nom); |
|
1721 | + $this->name = $this->name ? trim($this->name) : trim((string) $this->nom); |
|
1722 | 1722 | $this->nom = $this->name; // For backward compatibility |
1723 | - $this->name_alias = trim((string)$this->name_alias); |
|
1723 | + $this->name_alias = trim((string) $this->name_alias); |
|
1724 | 1724 | $this->ref_ext = (empty($this->ref_ext) ? '' : trim($this->ref_ext)); |
1725 | - $this->address = trim((string)$this->address); |
|
1726 | - $this->zip = trim((string)$this->zip); |
|
1727 | - $this->town = trim((string)$this->town); |
|
1728 | - $this->state_id = (is_numeric($this->state_id)) ? (int)trim((string)$this->state_id) : 0; |
|
1725 | + $this->address = trim((string) $this->address); |
|
1726 | + $this->zip = trim((string) $this->zip); |
|
1727 | + $this->town = trim((string) $this->town); |
|
1728 | + $this->state_id = (is_numeric($this->state_id)) ? (int) trim((string) $this->state_id) : 0; |
|
1729 | 1729 | $this->country_id = ($this->country_id > 0) ? $this->country_id : 0; |
1730 | - $this->phone = trim((string)$this->phone); |
|
1730 | + $this->phone = trim((string) $this->phone); |
|
1731 | 1731 | $this->phone = preg_replace("/\s/", "", $this->phone); |
1732 | 1732 | $this->phone = preg_replace("/\./", "", $this->phone); |
1733 | - $this->phone_mobile = trim((string)$this->phone_mobile); |
|
1733 | + $this->phone_mobile = trim((string) $this->phone_mobile); |
|
1734 | 1734 | $this->phone_mobile = preg_replace("/\s/", "", $this->phone_mobile); |
1735 | 1735 | $this->phone_mobile = preg_replace("/\./", "", $this->phone_mobile); |
1736 | - $this->fax = trim((string)$this->fax); |
|
1736 | + $this->fax = trim((string) $this->fax); |
|
1737 | 1737 | $this->fax = preg_replace("/\s/", "", $this->fax); |
1738 | 1738 | $this->fax = preg_replace("/\./", "", $this->fax); |
1739 | - $this->email = trim((string)$this->email); |
|
1739 | + $this->email = trim((string) $this->email); |
|
1740 | 1740 | $this->url = $this->url ? clean_url($this->url, 0) : ''; |
1741 | 1741 | $this->note_private = (empty($this->note_private) ? '' : trim($this->note_private)); |
1742 | 1742 | $this->note_public = (empty($this->note_public) ? '' : trim($this->note_public)); |
1743 | - $this->idprof1 = trim((string)$this->idprof1); |
|
1744 | - $this->idprof2 = trim((string)$this->idprof2); |
|
1745 | - $this->idprof3 = trim((string)$this->idprof3); |
|
1746 | - $this->idprof4 = trim((string)$this->idprof4); |
|
1743 | + $this->idprof1 = trim((string) $this->idprof1); |
|
1744 | + $this->idprof2 = trim((string) $this->idprof2); |
|
1745 | + $this->idprof3 = trim((string) $this->idprof3); |
|
1746 | + $this->idprof4 = trim((string) $this->idprof4); |
|
1747 | 1747 | $this->idprof5 = (!empty($this->idprof5) ? trim($this->idprof5) : ''); |
1748 | 1748 | $this->idprof6 = (!empty($this->idprof6) ? trim($this->idprof6) : ''); |
1749 | - $this->prefix_comm = trim((string)$this->prefix_comm); |
|
1749 | + $this->prefix_comm = trim((string) $this->prefix_comm); |
|
1750 | 1750 | $this->outstanding_limit = price2num($this->outstanding_limit); |
1751 | 1751 | $this->order_min_amount = price2num($this->order_min_amount); |
1752 | 1752 | $this->supplier_order_min_amount = price2num($this->supplier_order_min_amount); |
1753 | 1753 | |
1754 | - $this->tva_assuj = (is_numeric($this->tva_assuj)) ? (int)trim((string)$this->tva_assuj) : 0; |
|
1754 | + $this->tva_assuj = (is_numeric($this->tva_assuj)) ? (int) trim((string) $this->tva_assuj) : 0; |
|
1755 | 1755 | $this->tva_intra = dol_sanitizeFileName($this->tva_intra, ''); |
1756 | 1756 | $this->vat_reverse_charge = empty($this->vat_reverse_charge) ? 0 : 1; |
1757 | 1757 | if (empty($this->status)) { |
@@ -1773,10 +1773,10 @@ discard block |
||
1773 | 1773 | $this->localtax1_value = trim($this->localtax1_value); |
1774 | 1774 | $this->localtax2_value = trim($this->localtax2_value); |
1775 | 1775 | |
1776 | - $this->capital = ($this->capital != '') ? (float)price2num(trim((string)$this->capital)) : null; |
|
1776 | + $this->capital = ($this->capital != '') ? (float) price2num(trim((string) $this->capital)) : null; |
|
1777 | 1777 | |
1778 | - $this->effectif_id = trim((string)$this->effectif_id); |
|
1779 | - $this->forme_juridique_code = trim((string)$this->forme_juridique_code); |
|
1778 | + $this->effectif_id = trim((string) $this->effectif_id); |
|
1779 | + $this->forme_juridique_code = trim((string) $this->forme_juridique_code); |
|
1780 | 1780 | |
1781 | 1781 | //Gencod |
1782 | 1782 | $this->barcode = trim($this->barcode); |
@@ -1834,7 +1834,7 @@ discard block |
||
1834 | 1834 | $this->accountancy_code_sell = (empty($this->accountancy_code_sell) ? '' : trim($this->accountancy_code_sell)); |
1835 | 1835 | |
1836 | 1836 | //Incoterms |
1837 | - $this->fk_incoterms = (int)$this->fk_incoterms; |
|
1837 | + $this->fk_incoterms = (int) $this->fk_incoterms; |
|
1838 | 1838 | $this->location_incoterms = trim($this->location_incoterms); |
1839 | 1839 | |
1840 | 1840 | $this->db->begin(); |
@@ -1879,8 +1879,8 @@ discard block |
||
1879 | 1879 | $sql .= ",zip = " . (!empty($this->zip) ? "'" . $this->db->escape($this->zip) . "'" : "null"); |
1880 | 1880 | $sql .= ",town = " . (!empty($this->town) ? "'" . $this->db->escape($this->town) . "'" : "null"); |
1881 | 1881 | |
1882 | - $sql .= ",fk_departement = " . ((!empty($this->state_id) && $this->state_id > 0) ? ((int)$this->state_id) : 'null'); |
|
1883 | - $sql .= ",fk_pays = " . ((!empty($this->country_id) && $this->country_id > 0) ? ((int)$this->country_id) : 'null'); |
|
1882 | + $sql .= ",fk_departement = " . ((!empty($this->state_id) && $this->state_id > 0) ? ((int) $this->state_id) : 'null'); |
|
1883 | + $sql .= ",fk_pays = " . ((!empty($this->country_id) && $this->country_id > 0) ? ((int) $this->country_id) : 'null'); |
|
1884 | 1884 | |
1885 | 1885 | $sql .= ",phone = " . (!empty($this->phone) ? "'" . $this->db->escape($this->phone) . "'" : "null"); |
1886 | 1886 | $sql .= ",phone_mobile = " . (!empty($this->phone_mobile) ? "'" . $this->db->escape($this->phone_mobile) . "'" : "null"); |
@@ -1906,7 +1906,7 @@ discard block |
||
1906 | 1906 | if (!getDolGlobalString('MAIN_COMPANY_PERENTITY_SHARED')) { |
1907 | 1907 | $sql .= ",vat_reverse_charge = " . ($this->vat_reverse_charge != '' ? "'" . $this->db->escape($this->vat_reverse_charge) . "'" : 0); |
1908 | 1908 | } |
1909 | - $sql .= ",status = " . ((int)$this->status); |
|
1909 | + $sql .= ",status = " . ((int) $this->status); |
|
1910 | 1910 | |
1911 | 1911 | // Local taxes |
1912 | 1912 | $sql .= ",localtax1_assuj = " . ($this->localtax1_assuj != '' ? "'" . $this->db->escape($this->localtax1_assuj) . "'" : "null"); |
@@ -1935,12 +1935,12 @@ discard block |
||
1935 | 1935 | |
1936 | 1936 | $sql .= ",prefix_comm = " . (!empty($this->prefix_comm) ? "'" . $this->db->escape($this->prefix_comm) . "'" : "null"); |
1937 | 1937 | |
1938 | - $sql .= ",fk_effectif = " . ($this->effectif_id > 0 ? ((int)$this->effectif_id) : "null"); |
|
1938 | + $sql .= ",fk_effectif = " . ($this->effectif_id > 0 ? ((int) $this->effectif_id) : "null"); |
|
1939 | 1939 | if (isset($this->stcomm_id)) { |
1940 | - $sql .= ",fk_stcomm=" . (int)$this->stcomm_id; |
|
1940 | + $sql .= ",fk_stcomm=" . (int) $this->stcomm_id; |
|
1941 | 1941 | } |
1942 | 1942 | if (isset($this->typent_id)) { |
1943 | - $sql .= ",fk_typent = " . ($this->typent_id > 0 ? ((int)$this->typent_id) : "0"); |
|
1943 | + $sql .= ",fk_typent = " . ($this->typent_id > 0 ? ((int) $this->typent_id) : "0"); |
|
1944 | 1944 | } |
1945 | 1945 | |
1946 | 1946 | $sql .= ",fk_forme_juridique = " . (!empty($this->forme_juridique_code) ? "'" . $this->db->escape($this->forme_juridique_code) . "'" : "null"); |
@@ -1979,7 +1979,7 @@ discard block |
||
1979 | 1979 | $sql .= ",webservices_key = " . (!empty($this->webservices_key) ? "'" . $this->db->escape($this->webservices_key) . "'" : "null"); |
1980 | 1980 | |
1981 | 1981 | //Incoterms |
1982 | - $sql .= ", fk_incoterms = " . ((int)$this->fk_incoterms); |
|
1982 | + $sql .= ", fk_incoterms = " . ((int) $this->fk_incoterms); |
|
1983 | 1983 | $sql .= ", location_incoterms = " . (!empty($this->location_incoterms) ? "'" . $this->db->escape($this->location_incoterms) . "'" : "null"); |
1984 | 1984 | |
1985 | 1985 | if ($customer) { |
@@ -1990,10 +1990,10 @@ discard block |
||
1990 | 1990 | $sql .= ", code_fournisseur = " . (!empty($this->code_fournisseur) ? "'" . $this->db->escape($this->code_fournisseur) . "'" : "null"); |
1991 | 1991 | } |
1992 | 1992 | $sql .= ", fk_user_modif = " . ($user->id > 0 ? $user->id : "null"); |
1993 | - $sql .= ", fk_multicurrency = " . (int)$this->fk_multicurrency; |
|
1993 | + $sql .= ", fk_multicurrency = " . (int) $this->fk_multicurrency; |
|
1994 | 1994 | $sql .= ", multicurrency_code = '" . $this->db->escape($this->multicurrency_code) . "'"; |
1995 | 1995 | $sql .= ", model_pdf = '" . $this->db->escape($this->model_pdf) . "'"; |
1996 | - $sql .= " WHERE rowid = " . (int)$id; |
|
1996 | + $sql .= " WHERE rowid = " . (int) $id; |
|
1997 | 1997 | |
1998 | 1998 | $resql = $this->db->query($sql); |
1999 | 1999 | if ($resql) { |
@@ -2055,7 +2055,7 @@ discard block |
||
2055 | 2055 | |
2056 | 2056 | // update accountancy for this entity |
2057 | 2057 | if (!$error && getDolGlobalString('MAIN_COMPANY_PERENTITY_SHARED')) { |
2058 | - $this->db->query("DELETE FROM " . MAIN_DB_PREFIX . "societe_perentity WHERE fk_soc = " . ((int)$this->id) . " AND entity = " . ((int)$conf->entity)); |
|
2058 | + $this->db->query("DELETE FROM " . MAIN_DB_PREFIX . "societe_perentity WHERE fk_soc = " . ((int) $this->id) . " AND entity = " . ((int) $conf->entity)); |
|
2059 | 2059 | |
2060 | 2060 | $sql = "INSERT INTO " . MAIN_DB_PREFIX . "societe_perentity ("; |
2061 | 2061 | $sql .= " fk_soc"; |
@@ -2260,7 +2260,7 @@ discard block |
||
2260 | 2260 | } |
2261 | 2261 | $sql .= ' FROM ' . MAIN_DB_PREFIX . 'societe as s'; |
2262 | 2262 | if (getDolGlobalString('MAIN_COMPANY_PERENTITY_SHARED')) { |
2263 | - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "societe_perentity as spe ON spe.fk_soc = s.rowid AND spe.entity = " . ((int)$conf->entity); |
|
2263 | + $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "societe_perentity as spe ON spe.fk_soc = s.rowid AND spe.entity = " . ((int) $conf->entity); |
|
2264 | 2264 | } |
2265 | 2265 | $sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'c_effectif as e ON s.fk_effectif = e.id'; |
2266 | 2266 | $sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'c_country as c ON s.fk_pays = c.rowid'; |
@@ -2287,7 +2287,7 @@ discard block |
||
2287 | 2287 | } // if both false, no test (the thirdparty can be client and/or supplier) |
2288 | 2288 | |
2289 | 2289 | if ($rowid) { |
2290 | - $sql .= ' AND s.rowid = ' . ((int)$rowid); |
|
2290 | + $sql .= ' AND s.rowid = ' . ((int) $rowid); |
|
2291 | 2291 | } |
2292 | 2292 | if ($ref) { |
2293 | 2293 | $sql .= " AND s.nom = '" . $this->db->escape($ref) . "'"; |
@@ -2369,7 +2369,7 @@ discard block |
||
2369 | 2369 | $this->stcomm_picto = $obj->stcomm_picto; // picto statut commercial |
2370 | 2370 | |
2371 | 2371 | $this->email = $obj->email; |
2372 | - $this->socialnetworks = ($obj->socialnetworks ? (array)json_decode($obj->socialnetworks, true) : array()); |
|
2372 | + $this->socialnetworks = ($obj->socialnetworks ? (array) json_decode($obj->socialnetworks, true) : array()); |
|
2373 | 2373 | |
2374 | 2374 | $this->url = $obj->url; |
2375 | 2375 | $this->phone = $obj->phone; |
@@ -2390,7 +2390,7 @@ discard block |
||
2390 | 2390 | $this->code_client = $obj->code_client; |
2391 | 2391 | $this->code_fournisseur = $obj->code_fournisseur; |
2392 | 2392 | |
2393 | - $this->code_compta = $obj->code_compta; // For backward compatibility |
|
2393 | + $this->code_compta = $obj->code_compta; // For backward compatibility |
|
2394 | 2394 | $this->code_compta_client = $obj->code_compta; |
2395 | 2395 | $this->code_compta_fournisseur = $obj->code_compta_fournisseur; |
2396 | 2396 | |
@@ -2524,7 +2524,7 @@ discard block |
||
2524 | 2524 | |
2525 | 2525 | if (!$error) { |
2526 | 2526 | $sql = "DELETE FROM " . MAIN_DB_PREFIX . "societe_commerciaux"; |
2527 | - $sql .= " WHERE fk_soc = " . ((int)$this->id) . " AND fk_user = " . ((int)$commid); |
|
2527 | + $sql .= " WHERE fk_soc = " . ((int) $this->id) . " AND fk_user = " . ((int) $commid); |
|
2528 | 2528 | |
2529 | 2529 | $resql = $this->db->query($sql); |
2530 | 2530 | if (!$resql) { |
@@ -2536,7 +2536,7 @@ discard block |
||
2536 | 2536 | if (!$error) { |
2537 | 2537 | $sql = "INSERT INTO " . MAIN_DB_PREFIX . "societe_commerciaux"; |
2538 | 2538 | $sql .= " (fk_soc, fk_user)"; |
2539 | - $sql .= " VALUES (" . ((int)$this->id) . ", " . ((int)$commid) . ")"; |
|
2539 | + $sql .= " VALUES (" . ((int) $this->id) . ", " . ((int) $commid) . ")"; |
|
2540 | 2540 | |
2541 | 2541 | $resql = $this->db->query($sql); |
2542 | 2542 | if (!$resql) { |
@@ -2601,8 +2601,8 @@ discard block |
||
2601 | 2601 | $now = dol_now(); |
2602 | 2602 | |
2603 | 2603 | $sql = "UPDATE " . MAIN_DB_PREFIX . "societe"; |
2604 | - $sql .= " SET price_level = " . ((int)$price_level); |
|
2605 | - $sql .= " WHERE rowid = " . ((int)$this->id); |
|
2604 | + $sql .= " SET price_level = " . ((int) $price_level); |
|
2605 | + $sql .= " WHERE rowid = " . ((int) $this->id); |
|
2606 | 2606 | |
2607 | 2607 | if (!$this->db->query($sql)) { |
2608 | 2608 | dol_print_error($this->db); |
@@ -2611,7 +2611,7 @@ discard block |
||
2611 | 2611 | |
2612 | 2612 | $sql = "INSERT INTO " . MAIN_DB_PREFIX . "societe_prices"; |
2613 | 2613 | $sql .= " (datec, fk_soc, price_level, fk_user_author)"; |
2614 | - $sql .= " VALUES ('" . $this->db->idate($now) . "', " . ((int)$this->id) . ", " . ((int)$price_level) . ", " . ((int)$user->id) . ")"; |
|
2614 | + $sql .= " VALUES ('" . $this->db->idate($now) . "', " . ((int) $this->id) . ", " . ((int) $price_level) . ", " . ((int) $user->id) . ")"; |
|
2615 | 2615 | |
2616 | 2616 | if (!$this->db->query($sql)) { |
2617 | 2617 | dol_print_error($this->db); |
@@ -2667,7 +2667,7 @@ discard block |
||
2667 | 2667 | |
2668 | 2668 | $sql = "SELECT rowid, email, statut as status, phone_mobile, lastname, poste, firstname"; |
2669 | 2669 | $sql .= " FROM " . MAIN_DB_PREFIX . "socpeople"; |
2670 | - $sql .= " WHERE fk_soc = " . ((int)$this->id); |
|
2670 | + $sql .= " WHERE fk_soc = " . ((int) $this->id); |
|
2671 | 2671 | $sql .= " AND entity IN (" . getEntity($this->element) . ")"; |
2672 | 2672 | $sql .= " ORDER BY lastname, firstname"; |
2673 | 2673 | |
@@ -2754,7 +2754,7 @@ discard block |
||
2754 | 2754 | // phpcs:enable |
2755 | 2755 | $contacts = array(); |
2756 | 2756 | |
2757 | - $sql = "SELECT rowid, lastname, firstname FROM " . MAIN_DB_PREFIX . "socpeople WHERE fk_soc = " . ((int)$this->id); |
|
2757 | + $sql = "SELECT rowid, lastname, firstname FROM " . MAIN_DB_PREFIX . "socpeople WHERE fk_soc = " . ((int) $this->id); |
|
2758 | 2758 | $resql = $this->db->query($sql); |
2759 | 2759 | if ($resql) { |
2760 | 2760 | $nump = $this->db->num_rows($resql); |
@@ -2784,7 +2784,7 @@ discard block |
||
2784 | 2784 | { |
2785 | 2785 | $contacts = array(); |
2786 | 2786 | |
2787 | - $sql = "SELECT rowid FROM " . MAIN_DB_PREFIX . "socpeople WHERE fk_soc = " . ((int)$this->id); |
|
2787 | + $sql = "SELECT rowid FROM " . MAIN_DB_PREFIX . "socpeople WHERE fk_soc = " . ((int) $this->id); |
|
2788 | 2788 | $resql = $this->db->query($sql); |
2789 | 2789 | if ($resql) { |
2790 | 2790 | $nump = $this->db->num_rows($resql); |
@@ -2824,7 +2824,7 @@ discard block |
||
2824 | 2824 | |
2825 | 2825 | $sql = "SELECT rowid, email, phone_mobile, lastname, firstname"; |
2826 | 2826 | $sql .= " FROM " . MAIN_DB_PREFIX . "socpeople"; |
2827 | - $sql .= " WHERE rowid = " . ((int)$rowid); |
|
2827 | + $sql .= " WHERE rowid = " . ((int) $rowid); |
|
2828 | 2828 | |
2829 | 2829 | $resql = $this->db->query($sql); |
2830 | 2830 | if ($resql) { |
@@ -2894,7 +2894,7 @@ discard block |
||
2894 | 2894 | public function get_all_rib() |
2895 | 2895 | { |
2896 | 2896 | // phpcs:enable |
2897 | - $sql = "SELECT rowid FROM " . MAIN_DB_PREFIX . "societe_rib WHERE type='ban' AND fk_soc = " . ((int)$this->id); |
|
2897 | + $sql = "SELECT rowid FROM " . MAIN_DB_PREFIX . "societe_rib WHERE type='ban' AND fk_soc = " . ((int) $this->id); |
|
2898 | 2898 | $result = $this->db->query($sql); |
2899 | 2899 | if (!$result) { |
2900 | 2900 | $this->error++; |
@@ -3020,7 +3020,7 @@ discard block |
||
3020 | 3020 | } |
3021 | 3021 | } |
3022 | 3022 | |
3023 | - $sql = 'UPDATE ' . MAIN_DB_PREFIX . 'societe SET parent = ' . ($id > 0 ? $id : 'null') . ' WHERE rowid = ' . ((int)$this->id); |
|
3023 | + $sql = 'UPDATE ' . MAIN_DB_PREFIX . 'societe SET parent = ' . ($id > 0 ? $id : 'null') . ' WHERE rowid = ' . ((int) $this->id); |
|
3024 | 3024 | |
3025 | 3025 | $resql = $this->db->query($sql); |
3026 | 3026 | if ($resql) { |
@@ -3052,7 +3052,7 @@ discard block |
||
3052 | 3052 | |
3053 | 3053 | $sql = 'SELECT s.parent'; |
3054 | 3054 | $sql .= ' FROM ' . MAIN_DB_PREFIX . 'societe as s'; |
3055 | - $sql .= ' WHERE rowid = ' . ((int)$idparent); |
|
3055 | + $sql .= ' WHERE rowid = ' . ((int) $idparent); |
|
3056 | 3056 | $resql = $this->db->query($sql); |
3057 | 3057 | if ($resql) { |
3058 | 3058 | $obj = $this->db->fetch_object($resql); |
@@ -3085,7 +3085,7 @@ discard block |
||
3085 | 3085 | global $langs; |
3086 | 3086 | |
3087 | 3087 | if ($company_id > 0) { |
3088 | - $sql = "SELECT parent FROM " . MAIN_DB_PREFIX . "societe WHERE rowid = " . ((int)$company_id); |
|
3088 | + $sql = "SELECT parent FROM " . MAIN_DB_PREFIX . "societe WHERE rowid = " . ((int) $company_id); |
|
3089 | 3089 | $resql = $this->db->query($sql); |
3090 | 3090 | if ($resql) { |
3091 | 3091 | if ($obj = $this->db->fetch_object($resql)) { |
@@ -3231,7 +3231,7 @@ discard block |
||
3231 | 3231 | public function has_projects() |
3232 | 3232 | { |
3233 | 3233 | // phpcs:enable |
3234 | - $sql = "SELECT COUNT(*) as numproj FROM " . MAIN_DB_PREFIX . "projet WHERE fk_soc = " . ((int)$this->id); |
|
3234 | + $sql = "SELECT COUNT(*) as numproj FROM " . MAIN_DB_PREFIX . "projet WHERE fk_soc = " . ((int) $this->id); |
|
3235 | 3235 | $resql = $this->db->query($sql); |
3236 | 3236 | if ($resql) { |
3237 | 3237 | $obj = $this->db->fetch_object($resql); |
@@ -3255,7 +3255,7 @@ discard block |
||
3255 | 3255 | $sql = "SELECT s.rowid, s.nom as name, s.datec, tms as datem,"; |
3256 | 3256 | $sql .= " fk_user_creat, fk_user_modif"; |
3257 | 3257 | $sql .= " FROM " . MAIN_DB_PREFIX . "societe as s"; |
3258 | - $sql .= " WHERE s.rowid = " . ((int)$id); |
|
3258 | + $sql .= " WHERE s.rowid = " . ((int) $id); |
|
3259 | 3259 | |
3260 | 3260 | $result = $this->db->query($sql); |
3261 | 3261 | if ($result) { |
@@ -3326,7 +3326,7 @@ discard block |
||
3326 | 3326 | // phpcs:enable |
3327 | 3327 | if ($categorie_id > 0 && $this->id > 0) { |
3328 | 3328 | $sql = "INSERT INTO " . MAIN_DB_PREFIX . "categorie_fournisseur (fk_categorie, fk_soc) "; |
3329 | - $sql .= " VALUES (" . ((int)$categorie_id) . ", " . ((int)$this->id) . ")"; |
|
3329 | + $sql .= " VALUES (" . ((int) $categorie_id) . ", " . ((int) $this->id) . ")"; |
|
3330 | 3330 | |
3331 | 3331 | if ($resql = $this->db->query($sql)) { |
3332 | 3332 | return 0; |
@@ -3446,8 +3446,8 @@ discard block |
||
3446 | 3446 | } |
3447 | 3447 | |
3448 | 3448 | $sql = "UPDATE " . MAIN_DB_PREFIX . "adherent"; |
3449 | - $sql .= " SET fk_soc = " . ((int)$this->id); |
|
3450 | - $sql .= " WHERE rowid = " . ((int)$member->id); |
|
3449 | + $sql .= " SET fk_soc = " . ((int) $this->id); |
|
3450 | + $sql .= " WHERE rowid = " . ((int) $member->id); |
|
3451 | 3451 | |
3452 | 3452 | $resql = $this->db->query($sql); |
3453 | 3453 | if ($resql) { |
@@ -3596,7 +3596,7 @@ discard block |
||
3596 | 3596 | $country_code = $country_label = ''; |
3597 | 3597 | if (getDolGlobalString('MAIN_INFO_SOCIETE_COUNTRY')) { |
3598 | 3598 | $tmp = explode(':', getDolGlobalString('MAIN_INFO_SOCIETE_COUNTRY')); |
3599 | - $country_id = (is_numeric($tmp[0])) ? (int)$tmp[0] : 0; |
|
3599 | + $country_id = (is_numeric($tmp[0])) ? (int) $tmp[0] : 0; |
|
3600 | 3600 | if (!empty($tmp[1])) { // If $conf->global->MAIN_INFO_SOCIETE_COUNTRY is "id:code:label" |
3601 | 3601 | $country_code = $tmp[1]; |
3602 | 3602 | $country_label = $tmp[2]; |
@@ -3680,7 +3680,7 @@ discard block |
||
3680 | 3680 | $this->idprof6 = getDolGlobalString('MAIN_INFO_PROFID6'); |
3681 | 3681 | $this->tva_intra = getDolGlobalString('MAIN_INFO_TVAINTRA'); // VAT number, not necessarily INTRA. |
3682 | 3682 | $this->managers = getDolGlobalString('MAIN_INFO_SOCIETE_MANAGERS'); |
3683 | - $this->capital = is_numeric(getDolGlobalString('MAIN_INFO_CAPITAL')) ? (float)price2num(getDolGlobalString('MAIN_INFO_CAPITAL')) : 0; |
|
3683 | + $this->capital = is_numeric(getDolGlobalString('MAIN_INFO_CAPITAL')) ? (float) price2num(getDolGlobalString('MAIN_INFO_CAPITAL')) : 0; |
|
3684 | 3684 | $this->forme_juridique_code = getDolGlobalString('MAIN_INFO_SOCIETE_FORME_JURIDIQUE'); |
3685 | 3685 | $this->email = getDolGlobalString('MAIN_INFO_SOCIETE_MAIL'); |
3686 | 3686 | $this->default_lang = getDolGlobalString('MAIN_LANG_DEFAULT', 'auto'); |
@@ -3966,14 +3966,14 @@ discard block |
||
3966 | 3966 | } |
3967 | 3967 | |
3968 | 3968 | $sql = "SELECT rowid, ref, total_ht, total_ttc, fk_statut as status FROM " . MAIN_DB_PREFIX . $table . " as f"; |
3969 | - $sql .= " WHERE fk_soc = " . ((int)$this->id); |
|
3969 | + $sql .= " WHERE fk_soc = " . ((int) $this->id); |
|
3970 | 3970 | if ($mode == 'supplier') { |
3971 | 3971 | $sql .= " AND entity IN (" . getEntity('supplier_proposal') . ")"; |
3972 | 3972 | } else { |
3973 | 3973 | $sql .= " AND entity IN (" . getEntity('propal') . ")"; |
3974 | 3974 | } |
3975 | 3975 | |
3976 | - dol_syslog("getOutstandingProposals for fk_soc = " . ((int)$this->id), LOG_DEBUG); |
|
3976 | + dol_syslog("getOutstandingProposals for fk_soc = " . ((int) $this->id), LOG_DEBUG); |
|
3977 | 3977 | |
3978 | 3978 | $resql = $this->db->query($sql); |
3979 | 3979 | if ($resql) { |
@@ -4010,7 +4010,7 @@ discard block |
||
4010 | 4010 | } |
4011 | 4011 | |
4012 | 4012 | $sql = "SELECT rowid, ref, total_ht, total_ttc, fk_statut as status FROM " . MAIN_DB_PREFIX . $table . " as f"; |
4013 | - $sql .= " WHERE fk_soc = " . ((int)$this->id); |
|
4013 | + $sql .= " WHERE fk_soc = " . ((int) $this->id); |
|
4014 | 4014 | if ($mode == 'supplier') { |
4015 | 4015 | $sql .= " AND entity IN (" . getEntity('supplier_order') . ")"; |
4016 | 4016 | } else { |
@@ -4061,7 +4061,7 @@ discard block |
||
4061 | 4061 | $remaintopay=price2num($invoice->total_ttc - $paiement - $creditnotes - $deposits,'MT'); |
4062 | 4062 | */ |
4063 | 4063 | $sql = "SELECT rowid, ref, total_ht, total_ttc, paye, type, fk_statut as status, close_code FROM " . MAIN_DB_PREFIX . $table . " as f"; |
4064 | - $sql .= " WHERE fk_soc = " . ((int)$this->id); |
|
4064 | + $sql .= " WHERE fk_soc = " . ((int) $this->id); |
|
4065 | 4065 | if (!empty($late)) { |
4066 | 4066 | $sql .= " AND date_lim_reglement < '" . $this->db->idate(dol_now()) . "'"; |
4067 | 4067 | } |
@@ -4297,7 +4297,7 @@ discard block |
||
4297 | 4297 | $sql .= " WHERE entity IN (0, " . $this->db->sanitize($conf->entity) . ")"; |
4298 | 4298 | } |
4299 | 4299 | |
4300 | - $sql .= " AND u.rowid = sc.fk_user AND sc.fk_soc = " . ((int)$this->id); |
|
4300 | + $sql .= " AND u.rowid = sc.fk_user AND sc.fk_soc = " . ((int) $this->id); |
|
4301 | 4301 | if (empty($sortfield) && empty($sortorder)) { |
4302 | 4302 | $sortfield = 'u.lastname,u.firstname'; |
4303 | 4303 | $sortorder = 'ASC,ASC'; |
@@ -4317,10 +4317,10 @@ discard block |
||
4317 | 4317 | $reparray[$i]['firstname'] = $obj->firstname; |
4318 | 4318 | $reparray[$i]['email'] = $obj->email; |
4319 | 4319 | $reparray[$i]['phone'] = $obj->office_phone; |
4320 | - $reparray[$i]['office_phone'] = $obj->office_phone; // Pro phone |
|
4320 | + $reparray[$i]['office_phone'] = $obj->office_phone; // Pro phone |
|
4321 | 4321 | $reparray[$i]['office_fax'] = $obj->office_fax; |
4322 | - $reparray[$i]['user_mobile'] = $obj->user_mobile; // Pro mobile |
|
4323 | - $reparray[$i]['personal_mobile'] = $obj->personal_mobile; // Personal mobile |
|
4322 | + $reparray[$i]['user_mobile'] = $obj->user_mobile; // Pro mobile |
|
4323 | + $reparray[$i]['personal_mobile'] = $obj->personal_mobile; // Personal mobile |
|
4324 | 4324 | $reparray[$i]['job'] = $obj->job; |
4325 | 4325 | $reparray[$i]['statut'] = $obj->status; // deprecated |
4326 | 4326 | $reparray[$i]['status'] = $obj->status; |
@@ -4362,7 +4362,7 @@ discard block |
||
4362 | 4362 | |
4363 | 4363 | if ($this->id > 0 && $commid > 0) { |
4364 | 4364 | $sql = "DELETE FROM " . MAIN_DB_PREFIX . "societe_commerciaux "; |
4365 | - $sql .= " WHERE fk_soc = " . ((int)$this->id) . " AND fk_user = " . ((int)$commid); |
|
4365 | + $sql .= " WHERE fk_soc = " . ((int) $this->id) . " AND fk_user = " . ((int) $commid); |
|
4366 | 4366 | |
4367 | 4367 | if (!$this->db->query($sql)) { |
4368 | 4368 | $error++; |
@@ -4428,7 +4428,7 @@ discard block |
||
4428 | 4428 | |
4429 | 4429 | $sql = "UPDATE " . MAIN_DB_PREFIX . $this->table_element . " SET "; |
4430 | 4430 | $sql .= $field . " = '" . $this->db->escape($value) . "'"; |
4431 | - $sql .= " WHERE rowid = " . ((int)$this->id); |
|
4431 | + $sql .= " WHERE rowid = " . ((int) $this->id); |
|
4432 | 4432 | |
4433 | 4433 | dol_syslog(get_only_class($this) . "::" . __FUNCTION__, LOG_DEBUG); |
4434 | 4434 | $resql = $this->db->query($sql); |
@@ -4916,7 +4916,7 @@ discard block |
||
4916 | 4916 | $sql .= " FROM " . $this->db->prefix() . "c_type_contact tc"; |
4917 | 4917 | $sql .= ", " . $this->db->prefix() . "societe_contacts sc"; |
4918 | 4918 | $sql .= " LEFT JOIN " . $this->db->prefix() . "socpeople t on sc.fk_socpeople = t.rowid"; |
4919 | - $sql .= " WHERE sc.fk_soc = " . ((int)$this->id); |
|
4919 | + $sql .= " WHERE sc.fk_soc = " . ((int) $this->id); |
|
4920 | 4920 | $sql .= " AND sc.fk_c_type_contact = tc.rowid"; |
4921 | 4921 | if (!empty($element)) { |
4922 | 4922 | $sql .= " AND tc.element = '" . $this->db->escape($element) . "'"; |
@@ -4990,7 +4990,7 @@ discard block |
||
4990 | 4990 | global $conf, $langs, $hookmanager, $user, $action; |
4991 | 4991 | |
4992 | 4992 | $error = 0; |
4993 | - $soc_origin = new Societe($this->db); // The thirdparty that we will delete |
|
4993 | + $soc_origin = new Societe($this->db); // The thirdparty that we will delete |
|
4994 | 4994 | |
4995 | 4995 | dol_syslog("mergeCompany merge thirdparty id=" . $soc_origin_id . " (will be deleted) into the thirdparty id=" . $this->id); |
4996 | 4996 | |
@@ -5230,14 +5230,14 @@ discard block |
||
5230 | 5230 | // Sales representationves cannot be twice in the same thirdparties so we look for them and remove the one that are common some to avoid duplicate. |
5231 | 5231 | // Because this function is meant to be executed within a transaction, we won't take care of begin/commit. |
5232 | 5232 | $sql = 'SELECT rowid FROM ' . MAIN_DB_PREFIX . 'societe_commerciaux '; |
5233 | - $sql .= ' WHERE fk_soc = ' . (int)$dest_id . ' AND fk_user IN ( '; |
|
5233 | + $sql .= ' WHERE fk_soc = ' . (int) $dest_id . ' AND fk_user IN ( '; |
|
5234 | 5234 | $sql .= ' SELECT fk_user '; |
5235 | 5235 | $sql .= ' FROM ' . MAIN_DB_PREFIX . 'societe_commerciaux '; |
5236 | - $sql .= ' WHERE fk_soc = ' . (int)$origin_id . ') '; |
|
5236 | + $sql .= ' WHERE fk_soc = ' . (int) $origin_id . ') '; |
|
5237 | 5237 | |
5238 | 5238 | $resql = $dbs->query($sql); |
5239 | 5239 | while ($obj = $dbs->fetch_object($resql)) { |
5240 | - $dbs->query('DELETE FROM ' . MAIN_DB_PREFIX . 'societe_commerciaux WHERE rowid = ' . ((int)$obj->rowid)); |
|
5240 | + $dbs->query('DELETE FROM ' . MAIN_DB_PREFIX . 'societe_commerciaux WHERE rowid = ' . ((int) $obj->rowid)); |
|
5241 | 5241 | } |
5242 | 5242 | |
5243 | 5243 | // llx_societe_extrafields table must not be here because we don't care about the old thirdparty extrafields that are managed directly into mergeCompany. |
@@ -5330,7 +5330,7 @@ discard block |
||
5330 | 5330 | } |
5331 | 5331 | } else { |
5332 | 5332 | $sql = "DELETE FROM " . MAIN_DB_PREFIX . $tabletodelete; |
5333 | - $sql .= " WHERE fk_soc = " . ((int)$id); |
|
5333 | + $sql .= " WHERE fk_soc = " . ((int) $id); |
|
5334 | 5334 | if (!$this->db->query($sql)) { |
5335 | 5335 | $error++; |
5336 | 5336 | $this->errors[] = $this->db->lasterror(); |
@@ -5353,7 +5353,7 @@ discard block |
||
5353 | 5353 | if (!$error) { |
5354 | 5354 | $sql = "UPDATE " . MAIN_DB_PREFIX . "societe"; |
5355 | 5355 | $sql .= " SET parent = NULL"; |
5356 | - $sql .= " WHERE parent = " . ((int)$id); |
|
5356 | + $sql .= " WHERE parent = " . ((int) $id); |
|
5357 | 5357 | if (!$this->db->query($sql)) { |
5358 | 5358 | $error++; |
5359 | 5359 | $this->errors[] = $this->db->lasterror(); |
@@ -5364,7 +5364,7 @@ discard block |
||
5364 | 5364 | if (!$error) { |
5365 | 5365 | if (getDolGlobalString('MAIN_COMPANY_PERENTITY_SHARED')) { |
5366 | 5366 | $sql = "DELETE FROM " . MAIN_DB_PREFIX . "societe_perentity"; |
5367 | - $sql .= " WHERE fk_soc = " . ((int)$id); |
|
5367 | + $sql .= " WHERE fk_soc = " . ((int) $id); |
|
5368 | 5368 | if (!$this->db->query($sql)) { |
5369 | 5369 | $error++; |
5370 | 5370 | $this->errors[] = $this->db->lasterror(); |
@@ -5372,7 +5372,7 @@ discard block |
||
5372 | 5372 | } |
5373 | 5373 | |
5374 | 5374 | $sql = "DELETE FROM " . MAIN_DB_PREFIX . "societe"; |
5375 | - $sql .= " WHERE rowid = " . ((int)$id); |
|
5375 | + $sql .= " WHERE rowid = " . ((int) $id); |
|
5376 | 5376 | if (!$this->db->query($sql)) { |
5377 | 5377 | $error++; |
5378 | 5378 | $this->errors[] = $this->db->lasterror(); |
@@ -416,11 +416,11 @@ discard block |
||
416 | 416 | /** |
417 | 417 | * @var float Multicurrency total VAT amount (TVA = "Taxe sur la Valeur Ajoutée" in French) |
418 | 418 | */ |
419 | - public $multicurrency_total_tva; // Private to call DolDeprecationHandler |
|
419 | + public $multicurrency_total_tva; // Private to call DolDeprecationHandler |
|
420 | 420 | /** |
421 | 421 | * @var float Multicurrency total amount including taxes (TTC = "Toutes Taxes Comprises" in French) |
422 | 422 | */ |
423 | - public $multicurrency_total_ttc; // Internal value for deprecation |
|
423 | + public $multicurrency_total_ttc; // Internal value for deprecation |
|
424 | 424 | /** |
425 | 425 | * @var float Multicurrency total localta1 |
426 | 426 | */ |
@@ -472,12 +472,12 @@ discard block |
||
472 | 472 | * @var float Total amount excluding taxes (HT = "Hors Taxe" in French) |
473 | 473 | * @see update_price() |
474 | 474 | */ |
475 | - public $total_ht; // not in database |
|
475 | + public $total_ht; // not in database |
|
476 | 476 | /** |
477 | 477 | * @var float Total VAT amount (TVA = "Taxe sur la Valeur Ajoutée" in French) |
478 | 478 | * @see update_price() |
479 | 479 | */ |
480 | - public $total_tva; // not in database |
|
480 | + public $total_tva; // not in database |
|
481 | 481 | /** |
482 | 482 | * @var float Total local tax 1 amount |
483 | 483 | * @see update_price() |
@@ -767,7 +767,7 @@ discard block |
||
767 | 767 | $sql .= " WHERE entity IN (" . getEntity($element) . ")"; |
768 | 768 | |
769 | 769 | if ($id > 0) { |
770 | - $sql .= " AND rowid = " . ((int)$id); |
|
770 | + $sql .= " AND rowid = " . ((int) $id); |
|
771 | 771 | } elseif ($ref) { |
772 | 772 | $sql .= " AND ref = '" . $db->escape($ref) . "'"; |
773 | 773 | } elseif ($ref_ext) { |
@@ -778,7 +778,7 @@ discard block |
||
778 | 778 | return -1; |
779 | 779 | } |
780 | 780 | if ($ref || $ref_ext) { // Because the same ref can exists in 2 different entities, we force the current one in priority |
781 | - $sql .= " AND entity = " . ((int)$conf->entity); |
|
781 | + $sql .= " AND entity = " . ((int) $conf->entity); |
|
782 | 782 | } |
783 | 783 | |
784 | 784 | dol_syslog(get_only_class($this) . "::isExistingObject", LOG_DEBUG); |
@@ -814,7 +814,7 @@ discard block |
||
814 | 814 | |
815 | 815 | global $db; |
816 | 816 | |
817 | - $sql = "SELECT " . $field_select . " FROM " . $db->prefix() . $table_element . " WHERE " . $field_where . " = " . ((int)$fk_object_where); |
|
817 | + $sql = "SELECT " . $field_select . " FROM " . $db->prefix() . $table_element . " WHERE " . $field_where . " = " . ((int) $fk_object_where); |
|
818 | 818 | $resql = $db->query($sql); |
819 | 819 | |
820 | 820 | $TRes = array(); |
@@ -843,7 +843,7 @@ discard block |
||
843 | 843 | |
844 | 844 | global $db; |
845 | 845 | |
846 | - $sql = "SELECT COUNT(*) as nb FROM " . $db->prefix() . $table_element . " WHERE " . $field_where . " = " . ((int)$fk_object_where); |
|
846 | + $sql = "SELECT COUNT(*) as nb FROM " . $db->prefix() . $table_element . " WHERE " . $field_where . " = " . ((int) $fk_object_where); |
|
847 | 847 | $resql = $db->query($sql); |
848 | 848 | $n = 0; |
849 | 849 | if ($resql) { |
@@ -872,7 +872,7 @@ discard block |
||
872 | 872 | |
873 | 873 | global $db; |
874 | 874 | |
875 | - $sql = "DELETE FROM " . $db->prefix() . $table_element . " WHERE " . $field_where . " = " . ((int)$fk_object_where); |
|
875 | + $sql = "DELETE FROM " . $db->prefix() . $table_element . " WHERE " . $field_where . " = " . ((int) $fk_object_where); |
|
876 | 876 | $resql = $db->query($sql); |
877 | 877 | |
878 | 878 | if (empty($resql)) { |
@@ -897,7 +897,7 @@ discard block |
||
897 | 897 | public static function commonReplaceThirdparty(DoliDB $dbs, $origin_id, $dest_id, array $tables, $ignoreerrors = 0) |
898 | 898 | { |
899 | 899 | foreach ($tables as $table) { |
900 | - $sql = 'UPDATE ' . $dbs->prefix() . $table . ' SET fk_soc = ' . ((int)$dest_id) . ' WHERE fk_soc = ' . ((int)$origin_id); |
|
900 | + $sql = 'UPDATE ' . $dbs->prefix() . $table . ' SET fk_soc = ' . ((int) $dest_id) . ' WHERE fk_soc = ' . ((int) $origin_id); |
|
901 | 901 | |
902 | 902 | if (!$dbs->query($sql)) { |
903 | 903 | if ($ignoreerrors) { |
@@ -926,7 +926,7 @@ discard block |
||
926 | 926 | public static function commonReplaceProduct(DoliDB $dbs, $origin_id, $dest_id, array $tables, $ignoreerrors = 0) |
927 | 927 | { |
928 | 928 | foreach ($tables as $table) { |
929 | - $sql = 'UPDATE ' . MAIN_DB_PREFIX . $table . ' SET fk_product = ' . ((int)$dest_id) . ' WHERE fk_product = ' . ((int)$origin_id); |
|
929 | + $sql = 'UPDATE ' . MAIN_DB_PREFIX . $table . ' SET fk_product = ' . ((int) $dest_id) . ' WHERE fk_product = ' . ((int) $origin_id); |
|
930 | 930 | |
931 | 931 | if (!$dbs->query($sql)) { |
932 | 932 | if ($ignoreerrors) { |
@@ -996,14 +996,14 @@ discard block |
||
996 | 996 | } |
997 | 997 | $enabled = 1; |
998 | 998 | if ($enabled && isset($extrafields->attributes[$this->table_element]['enabled'][$key])) { |
999 | - $enabled = (int)dol_eval($extrafields->attributes[$this->table_element]['enabled'][$key], 1, 1, '2'); |
|
999 | + $enabled = (int) dol_eval($extrafields->attributes[$this->table_element]['enabled'][$key], 1, 1, '2'); |
|
1000 | 1000 | } |
1001 | 1001 | if ($enabled && isset($extrafields->attributes[$this->table_element]['list'][$key])) { |
1002 | - $enabled = (int)dol_eval($extrafields->attributes[$this->table_element]['list'][$key], 1, 1, '2'); |
|
1002 | + $enabled = (int) dol_eval($extrafields->attributes[$this->table_element]['list'][$key], 1, 1, '2'); |
|
1003 | 1003 | } |
1004 | 1004 | $perms = 1; |
1005 | 1005 | if ($perms && isset($extrafields->attributes[$this->table_element]['perms'][$key])) { |
1006 | - $perms = (int)dol_eval($extrafields->attributes[$this->table_element]['perms'][$key], 1, 1, '2'); |
|
1006 | + $perms = (int) dol_eval($extrafields->attributes[$this->table_element]['perms'][$key], 1, 1, '2'); |
|
1007 | 1007 | } |
1008 | 1008 | if (empty($enabled)) { |
1009 | 1009 | continue; // 0 = Never visible field |
@@ -1017,7 +1017,7 @@ discard block |
||
1017 | 1017 | if (!empty($extrafields->attributes[$this->table_element]['langfile'][$key])) { |
1018 | 1018 | $langs->load($extrafields->attributes[$this->table_element]['langfile'][$key]); |
1019 | 1019 | } |
1020 | - $labelextra = $langs->trans((string)$extrafields->attributes[$this->table_element]['label'][$key]); |
|
1020 | + $labelextra = $langs->trans((string) $extrafields->attributes[$this->table_element]['label'][$key]); |
|
1021 | 1021 | if ($extrafields->attributes[$this->table_element]['type'][$key] == 'separate') { |
1022 | 1022 | $data[$key] = '<br><b><u>' . $labelextra . '</u></b>'; |
1023 | 1023 | } else { |
@@ -1157,9 +1157,9 @@ discard block |
||
1157 | 1157 | } elseif ($type == 'boolean') { |
1158 | 1158 | $morecss = ''; |
1159 | 1159 | } else { |
1160 | - if (is_numeric($size) && round((float)$size) < 12) { |
|
1160 | + if (is_numeric($size) && round((float) $size) < 12) { |
|
1161 | 1161 | $morecss = 'minwidth100'; |
1162 | - } elseif (is_numeric($size) && round((float)$size) <= 48) { |
|
1162 | + } elseif (is_numeric($size) && round((float) $size) <= 48) { |
|
1163 | 1163 | $morecss = 'minwidth200'; |
1164 | 1164 | } else { |
1165 | 1165 | $morecss = 'minwidth400'; |
@@ -1218,7 +1218,7 @@ discard block |
||
1218 | 1218 | $value = price($value, 0, $langs, 0, 0, -1, $conf->currency); |
1219 | 1219 | } |
1220 | 1220 | } elseif ($type == 'select') { |
1221 | - $value = isset($param['options'][(string)$value]) ? $param['options'][(string)$value] : ''; |
|
1221 | + $value = isset($param['options'][(string) $value]) ? $param['options'][(string) $value] : ''; |
|
1222 | 1222 | if (strpos($value, "|") !== false) { |
1223 | 1223 | $value = $langs->trans(explode('|', $value)[0]); |
1224 | 1224 | } elseif (!is_numeric($value)) { |
@@ -1257,7 +1257,7 @@ discard block |
||
1257 | 1257 | if ($selectkey == 'rowid' && empty($value)) { |
1258 | 1258 | $sql .= " WHERE " . $selectkey . " = 0"; |
1259 | 1259 | } elseif ($selectkey == 'rowid') { |
1260 | - $sql .= " WHERE " . $selectkey . " = " . ((int)$value); |
|
1260 | + $sql .= " WHERE " . $selectkey . " = " . ((int) $value); |
|
1261 | 1261 | } else { |
1262 | 1262 | $sql .= " WHERE " . $selectkey . " = '" . $this->db->escape($value) . "'"; |
1263 | 1263 | } |
@@ -1315,9 +1315,9 @@ discard block |
||
1315 | 1315 | dol_syslog(get_only_class($this) . '::showOutputField error ' . $this->db->lasterror(), LOG_WARNING); |
1316 | 1316 | } |
1317 | 1317 | } elseif ($type == 'radio') { |
1318 | - $value = $param['options'][(string)$value]; |
|
1318 | + $value = $param['options'][(string) $value]; |
|
1319 | 1319 | } elseif ($type == 'checkbox') { |
1320 | - $value_arr = explode(',', (string)$value); |
|
1320 | + $value_arr = explode(',', (string) $value); |
|
1321 | 1321 | $value = ''; |
1322 | 1322 | if (is_array($value_arr) && count($value_arr) > 0) { |
1323 | 1323 | $toprint = array(); |
@@ -1740,7 +1740,7 @@ discard block |
||
1740 | 1740 | if ($source == 'external' || $source == 'thirdparty') { // external contact (socpeople) |
1741 | 1741 | $sql .= " LEFT JOIN " . $this->db->prefix() . "socpeople t on ec.fk_socpeople = t.rowid"; |
1742 | 1742 | } |
1743 | - $sql .= " WHERE ec.element_id = " . ((int)$this->id); |
|
1743 | + $sql .= " WHERE ec.element_id = " . ((int) $this->id); |
|
1744 | 1744 | $sql .= " AND ec.fk_c_type_contact = tc.rowid"; |
1745 | 1745 | $sql .= " AND tc.element = '" . $this->db->escape($this->element) . "'"; |
1746 | 1746 | if ($code) { |
@@ -1749,18 +1749,18 @@ discard block |
||
1749 | 1749 | if ($source == 'internal') { |
1750 | 1750 | $sql .= " AND tc.source = 'internal'"; |
1751 | 1751 | if ($status >= 0) { |
1752 | - $sql .= " AND t.statut = " . ((int)$status); |
|
1752 | + $sql .= " AND t.statut = " . ((int) $status); |
|
1753 | 1753 | } |
1754 | 1754 | } |
1755 | 1755 | if ($source == 'external' || $source == 'thirdparty') { |
1756 | 1756 | $sql .= " AND tc.source = 'external'"; |
1757 | 1757 | if ($status >= 0) { |
1758 | - $sql .= " AND t.statut = " . ((int)$status); // t is llx_socpeople |
|
1758 | + $sql .= " AND t.statut = " . ((int) $status); // t is llx_socpeople |
|
1759 | 1759 | } |
1760 | 1760 | } |
1761 | 1761 | $sql .= " AND tc.active = 1"; |
1762 | 1762 | if ($statusoflink >= 0) { |
1763 | - $sql .= " AND ec.statut = " . ((int)$statusoflink); |
|
1763 | + $sql .= " AND ec.statut = " . ((int) $statusoflink); |
|
1764 | 1764 | } |
1765 | 1765 | $sql .= " ORDER BY t.lastname ASC"; |
1766 | 1766 | |
@@ -1888,9 +1888,9 @@ discard block |
||
1888 | 1888 | // Insert into database |
1889 | 1889 | $sql = "INSERT INTO " . $this->db->prefix() . "element_contact"; |
1890 | 1890 | $sql .= " (element_id, fk_socpeople, datecreate, statut, fk_c_type_contact) "; |
1891 | - $sql .= " VALUES (" . $this->id . ", " . ((int)$fk_socpeople) . " , "; |
|
1891 | + $sql .= " VALUES (" . $this->id . ", " . ((int) $fk_socpeople) . " , "; |
|
1892 | 1892 | $sql .= "'" . $this->db->idate($datecreate) . "'"; |
1893 | - $sql .= ", 4, " . ((int)$id_type_contact); |
|
1893 | + $sql .= ", 4, " . ((int) $id_type_contact); |
|
1894 | 1894 | $sql .= ")"; |
1895 | 1895 | |
1896 | 1896 | $resql = $this->db->query($sql); |
@@ -1976,7 +1976,7 @@ discard block |
||
1976 | 1976 | |
1977 | 1977 | if (!$error && empty($notrigger)) { |
1978 | 1978 | // Call trigger |
1979 | - $this->context['contact_id'] = ((int)$rowid); |
|
1979 | + $this->context['contact_id'] = ((int) $rowid); |
|
1980 | 1980 | $result = $this->call_trigger(strtoupper($this->element) . '_DELETE_CONTACT', $user); |
1981 | 1981 | if ($result < 0) { |
1982 | 1982 | $error++; |
@@ -1988,7 +1988,7 @@ discard block |
||
1988 | 1988 | dol_syslog(get_only_class($this) . "::delete_contact", LOG_DEBUG); |
1989 | 1989 | |
1990 | 1990 | $sql = "DELETE FROM " . MAIN_DB_PREFIX . "element_contact"; |
1991 | - $sql .= " WHERE rowid = " . ((int)$rowid); |
|
1991 | + $sql .= " WHERE rowid = " . ((int) $rowid); |
|
1992 | 1992 | |
1993 | 1993 | $result = $this->db->query($sql); |
1994 | 1994 | if (!$result) { |
@@ -2037,7 +2037,7 @@ discard block |
||
2037 | 2037 | } |
2038 | 2038 | |
2039 | 2039 | $sql = "DELETE FROM " . $this->db->prefix() . "element_contact"; |
2040 | - $sql .= " WHERE element_id = " . ((int)$this->id); |
|
2040 | + $sql .= " WHERE element_id = " . ((int) $this->id); |
|
2041 | 2041 | $sql .= " AND fk_c_type_contact IN (" . $this->db->sanitize($listId) . ")"; |
2042 | 2042 | |
2043 | 2043 | dol_syslog(get_only_class($this) . "::delete_linked_contact", LOG_DEBUG); |
@@ -2124,7 +2124,7 @@ discard block |
||
2124 | 2124 | $sql = "SELECT ec.datecreate, ec.statut, ec.fk_socpeople, ec.fk_c_type_contact,"; |
2125 | 2125 | $sql .= " tc.code, tc.libelle as type_label"; |
2126 | 2126 | $sql .= " FROM (" . $this->db->prefix() . "element_contact as ec, " . $this->db->prefix() . "c_type_contact as tc)"; |
2127 | - $sql .= " WHERE ec.rowid =" . ((int)$rowid); |
|
2127 | + $sql .= " WHERE ec.rowid =" . ((int) $rowid); |
|
2128 | 2128 | $sql .= " AND ec.fk_c_type_contact = tc.rowid"; |
2129 | 2129 | $sql .= " AND tc.element = '" . $this->db->escape($this->element) . "'"; |
2130 | 2130 | |
@@ -2161,12 +2161,12 @@ discard block |
||
2161 | 2161 | $sql = "UPDATE " . $this->db->prefix() . "element_contact set"; |
2162 | 2162 | $sql .= " statut = " . $statut; |
2163 | 2163 | if ($type_contact_id) { |
2164 | - $sql .= ", fk_c_type_contact = " . ((int)$type_contact_id); |
|
2164 | + $sql .= ", fk_c_type_contact = " . ((int) $type_contact_id); |
|
2165 | 2165 | } |
2166 | 2166 | if ($fk_socpeople) { |
2167 | - $sql .= ", fk_socpeople = " . ((int)$fk_socpeople); |
|
2167 | + $sql .= ", fk_socpeople = " . ((int) $fk_socpeople); |
|
2168 | 2168 | } |
2169 | - $sql .= " where rowid = " . ((int)$rowid); |
|
2169 | + $sql .= " where rowid = " . ((int) $rowid); |
|
2170 | 2170 | $resql = $this->db->query($sql); |
2171 | 2171 | if ($resql) { |
2172 | 2172 | return 0; |
@@ -2300,7 +2300,7 @@ discard block |
||
2300 | 2300 | $sql .= " " . $this->db->prefix() . "socpeople as c,"; |
2301 | 2301 | } |
2302 | 2302 | $sql .= " " . $this->db->prefix() . "c_type_contact as tc"; |
2303 | - $sql .= " WHERE ec.element_id = " . ((int)$id); |
|
2303 | + $sql .= " WHERE ec.element_id = " . ((int) $id); |
|
2304 | 2304 | $sql .= " AND ec.fk_socpeople = c.rowid"; |
2305 | 2305 | if ($source == 'internal') { |
2306 | 2306 | $sql .= " AND c.entity IN (" . getEntity('user') . ")"; |
@@ -2316,7 +2316,7 @@ discard block |
||
2316 | 2316 | } |
2317 | 2317 | $sql .= " AND tc.active = 1"; |
2318 | 2318 | if ($status) { |
2319 | - $sql .= " AND ec.statut = " . ((int)$status); |
|
2319 | + $sql .= " AND ec.statut = " . ((int) $status); |
|
2320 | 2320 | } |
2321 | 2321 | |
2322 | 2322 | dol_syslog(get_only_class($this) . "::getIdContact", LOG_DEBUG); |
@@ -2465,7 +2465,7 @@ discard block |
||
2465 | 2465 | if (empty($this->barcode_type) || empty($this->barcode_type_code) || empty($this->barcode_type_label) || empty($this->barcode_type_coder)) { // If data not already loaded |
2466 | 2466 | $sql = "SELECT rowid, code, libelle as label, coder"; |
2467 | 2467 | $sql .= " FROM " . $this->db->prefix() . "c_barcode_type"; |
2468 | - $sql .= " WHERE rowid = " . ((int)$idtype); |
|
2468 | + $sql .= " WHERE rowid = " . ((int) $idtype); |
|
2469 | 2469 | dol_syslog(get_only_class($this) . '::fetch_barcode', LOG_DEBUG); |
2470 | 2470 | $resql = $this->db->query($sql); |
2471 | 2471 | if ($resql) { |
@@ -2584,7 +2584,7 @@ discard block |
||
2584 | 2584 | if (!empty($element)) { |
2585 | 2585 | $sql .= " AND entity IN (" . getEntity($element) . ")"; |
2586 | 2586 | } else { |
2587 | - $sql .= " AND entity = " . ((int)$conf->entity); |
|
2587 | + $sql .= " AND entity = " . ((int) $conf->entity); |
|
2588 | 2588 | } |
2589 | 2589 | |
2590 | 2590 | dol_syslog(get_only_class($this) . '::fetchObjectFrom', LOG_DEBUG); |
@@ -2620,7 +2620,7 @@ discard block |
||
2620 | 2620 | $result = false; |
2621 | 2621 | if (!empty($id) && !empty($field) && !empty($table)) { |
2622 | 2622 | $sql = "SELECT " . $field . " FROM " . $this->db->prefix() . $table; |
2623 | - $sql .= " WHERE rowid = " . ((int)$id); |
|
2623 | + $sql .= " WHERE rowid = " . ((int) $id); |
|
2624 | 2624 | |
2625 | 2625 | dol_syslog(get_only_class($this) . '::getValueFrom', LOG_DEBUG); |
2626 | 2626 | $resql = $this->db->query($sql); |
@@ -2681,7 +2681,7 @@ discard block |
||
2681 | 2681 | if ($trigkey) { |
2682 | 2682 | $sql = "SELECT " . $field; |
2683 | 2683 | $sql .= " FROM " . MAIN_DB_PREFIX . $table; |
2684 | - $sql .= " WHERE " . $id_field . " = " . ((int)$id); |
|
2684 | + $sql .= " WHERE " . $id_field . " = " . ((int) $id); |
|
2685 | 2685 | |
2686 | 2686 | $resql = $this->db->query($sql); |
2687 | 2687 | if ($resql) { |
@@ -2709,7 +2709,7 @@ discard block |
||
2709 | 2709 | if ($format == 'text') { |
2710 | 2710 | $sql .= $field . " = '" . $this->db->escape($value) . "'"; |
2711 | 2711 | } elseif ($format == 'int') { |
2712 | - $sql .= $field . " = " . ((int)$value); |
|
2712 | + $sql .= $field . " = " . ((int) $value); |
|
2713 | 2713 | } elseif ($format == 'date') { |
2714 | 2714 | $sql .= $field . " = " . ($value ? "'" . $this->db->idate($value) . "'" : "null"); |
2715 | 2715 | } elseif ($format == 'dategmt') { |
@@ -2718,13 +2718,13 @@ discard block |
||
2718 | 2718 | |
2719 | 2719 | if ($fk_user_field) { |
2720 | 2720 | if (!empty($fuser) && is_object($fuser)) { |
2721 | - $sql .= ", " . $fk_user_field . " = " . ((int)$fuser->id); |
|
2721 | + $sql .= ", " . $fk_user_field . " = " . ((int) $fuser->id); |
|
2722 | 2722 | } elseif (empty($fuser) || $fuser != 'none') { |
2723 | - $sql .= ", " . $fk_user_field . " = " . ((int)$user->id); |
|
2723 | + $sql .= ", " . $fk_user_field . " = " . ((int) $user->id); |
|
2724 | 2724 | } |
2725 | 2725 | } |
2726 | 2726 | |
2727 | - $sql .= " WHERE " . $id_field . " = " . ((int)$id); |
|
2727 | + $sql .= " WHERE " . $id_field . " = " . ((int) $id); |
|
2728 | 2728 | |
2729 | 2729 | $resql = $this->db->query($sql); |
2730 | 2730 | if ($resql) { |
@@ -2793,7 +2793,7 @@ discard block |
||
2793 | 2793 | $sql .= " FROM " . $this->db->prefix() . $this->table_element . ' as t'; |
2794 | 2794 | |
2795 | 2795 | if (!empty($id)) { |
2796 | - $sql .= ' WHERE t.rowid = ' . ((int)$id); |
|
2796 | + $sql .= ' WHERE t.rowid = ' . ((int) $id); |
|
2797 | 2797 | } elseif (!empty($ref)) { |
2798 | 2798 | $sql .= " WHERE t.ref = '" . $this->db->escape($ref) . "'"; |
2799 | 2799 | } else { |
@@ -2880,17 +2880,17 @@ discard block |
||
2880 | 2880 | } |
2881 | 2881 | } elseif ($this->isInt($info)) { |
2882 | 2882 | if ($field == 'rowid') { |
2883 | - $this->id = (int)$obj->$field; |
|
2883 | + $this->id = (int) $obj->$field; |
|
2884 | 2884 | } else { |
2885 | 2885 | if ($this->isForcedToNullIfZero($info)) { |
2886 | 2886 | if (empty($obj->$field)) { |
2887 | 2887 | $this->$field = null; |
2888 | 2888 | } else { |
2889 | - $this->$field = (int)$obj->$field; |
|
2889 | + $this->$field = (int) $obj->$field; |
|
2890 | 2890 | } |
2891 | 2891 | } else { |
2892 | 2892 | if (isset($obj->$field) && (!is_null($obj->$field) || (array_key_exists('notnull', $info) && $info['notnull'] == 1))) { |
2893 | - $this->$field = (int)$obj->$field; |
|
2893 | + $this->$field = (int) $obj->$field; |
|
2894 | 2894 | } else { |
2895 | 2895 | $this->$field = null; |
2896 | 2896 | } |
@@ -2901,11 +2901,11 @@ discard block |
||
2901 | 2901 | if (empty($obj->$field)) { |
2902 | 2902 | $this->$field = null; |
2903 | 2903 | } else { |
2904 | - $this->$field = (float)$obj->$field; |
|
2904 | + $this->$field = (float) $obj->$field; |
|
2905 | 2905 | } |
2906 | 2906 | } else { |
2907 | 2907 | if (isset($obj->$field) && (!is_null($obj->$field) || (array_key_exists('notnull', $info) && $info['notnull'] == 1))) { |
2908 | - $this->$field = (float)$obj->$field; |
|
2908 | + $this->$field = (float) $obj->$field; |
|
2909 | 2909 | } else { |
2910 | 2910 | $this->$field = null; |
2911 | 2911 | } |
@@ -2917,7 +2917,7 @@ discard block |
||
2917 | 2917 | |
2918 | 2918 | // If there is no 'ref' field, we force property ->ref to ->id for a better compatibility with common functions. |
2919 | 2919 | if (!isset($this->fields['ref']) && isset($this->id)) { |
2920 | - $this->ref = (string)$this->id; |
|
2920 | + $this->ref = (string) $this->id; |
|
2921 | 2921 | } |
2922 | 2922 | } |
2923 | 2923 | |
@@ -3061,7 +3061,7 @@ discard block |
||
3061 | 3061 | } |
3062 | 3062 | } |
3063 | 3063 | $sql .= " FROM " . $this->db->prefix() . $table_element . "_extrafields"; |
3064 | - $sql .= " WHERE fk_object = " . ((int)$rowid); |
|
3064 | + $sql .= " WHERE fk_object = " . ((int) $rowid); |
|
3065 | 3065 | |
3066 | 3066 | //dol_syslog(get_only_class($this)."::fetch_optionals get extrafields data for ".$this->table_element, LOG_DEBUG); // Too verbose |
3067 | 3067 | $resql = $this->db->query($sql); |
@@ -3108,8 +3108,8 @@ discard block |
||
3108 | 3108 | if (!empty($extrafields->attributes[$this->table_element]) && !empty($extrafields->attributes[$this->table_element]['computed'][$key])) { |
3109 | 3109 | //var_dump($conf->disable_compute); |
3110 | 3110 | if (empty($conf->disable_compute)) { |
3111 | - global $objectoffield; // We set a global variable to $objectoffield so |
|
3112 | - $objectoffield = $this; // we can use it inside computed formula |
|
3111 | + global $objectoffield; // We set a global variable to $objectoffield so |
|
3112 | + $objectoffield = $this; // we can use it inside computed formula |
|
3113 | 3113 | $this->array_options['options_' . $key] = dol_eval($extrafields->attributes[$this->table_element]['computed'][$key], 1, 0, '2'); |
3114 | 3114 | } |
3115 | 3115 | } |
@@ -3186,15 +3186,15 @@ discard block |
||
3186 | 3186 | $sql .= " LEFT JOIN " . $this->db->prefix() . "societe_commerciaux as sc ON " . $aliastablesociete . ".rowid = sc.fk_soc"; |
3187 | 3187 | } |
3188 | 3188 | if ($fieldid == 'rowid') { |
3189 | - $sql .= " WHERE te." . $fieldid . " < " . ((int)$this->id); |
|
3189 | + $sql .= " WHERE te." . $fieldid . " < " . ((int) $this->id); |
|
3190 | 3190 | } else { |
3191 | 3191 | $sql .= " WHERE te." . $fieldid . " < '" . $this->db->escape($this->ref) . "'"; // ->ref must always be defined (set to id if field does not exists) |
3192 | 3192 | } |
3193 | 3193 | if ($restrictiononfksoc == 1 && !$user->hasRight('societe', 'client', 'voir') && !$socid) { |
3194 | - $sql .= " AND sc.fk_user = " . ((int)$user->id); |
|
3194 | + $sql .= " AND sc.fk_user = " . ((int) $user->id); |
|
3195 | 3195 | } |
3196 | 3196 | if ($restrictiononfksoc == 2 && !$user->hasRight('societe', 'client', 'voir') && !$socid) { |
3197 | - $sql .= " AND (sc.fk_user = " . ((int)$user->id) . ' OR te.fk_soc IS NULL)'; |
|
3197 | + $sql .= " AND (sc.fk_user = " . ((int) $user->id) . ' OR te.fk_soc IS NULL)'; |
|
3198 | 3198 | } |
3199 | 3199 | |
3200 | 3200 | $filtermax = $filter; |
@@ -3233,13 +3233,13 @@ discard block |
||
3233 | 3233 | $sql .= ' AND parenttable.entity IN (' . getEntity($tmparray[1]) . ')'; |
3234 | 3234 | } |
3235 | 3235 | if ($restrictiononfksoc == 1 && $socid && $this->element != 'societe') { |
3236 | - $sql .= ' AND te.fk_soc = ' . ((int)$socid); |
|
3236 | + $sql .= ' AND te.fk_soc = ' . ((int) $socid); |
|
3237 | 3237 | } |
3238 | 3238 | if ($restrictiononfksoc == 2 && $socid && $this->element != 'societe') { |
3239 | - $sql .= ' AND (te.fk_soc = ' . ((int)$socid) . ' OR te.fk_soc IS NULL)'; |
|
3239 | + $sql .= ' AND (te.fk_soc = ' . ((int) $socid) . ' OR te.fk_soc IS NULL)'; |
|
3240 | 3240 | } |
3241 | 3241 | if ($restrictiononfksoc && $socid && $this->element == 'societe') { |
3242 | - $sql .= ' AND te.rowid = ' . ((int)$socid); |
|
3242 | + $sql .= ' AND te.rowid = ' . ((int) $socid); |
|
3243 | 3243 | } |
3244 | 3244 | //print 'socid='.$socid.' restrictiononfksoc='.$restrictiononfksoc.' ismultientitymanaged = '.$this->ismultientitymanaged.' filter = '.$filter.' -> '.$sql."<br>"; |
3245 | 3245 | |
@@ -3265,12 +3265,12 @@ discard block |
||
3265 | 3265 | $sql .= " LEFT JOIN " . $this->db->prefix() . "societe_commerciaux as sc ON " . $aliastablesociete . ".rowid = sc.fk_soc"; |
3266 | 3266 | } |
3267 | 3267 | if ($fieldid == 'rowid') { |
3268 | - $sql .= " WHERE te." . $fieldid . " > " . ((int)$this->id); |
|
3268 | + $sql .= " WHERE te." . $fieldid . " > " . ((int) $this->id); |
|
3269 | 3269 | } else { |
3270 | 3270 | $sql .= " WHERE te." . $fieldid . " > '" . $this->db->escape($this->ref) . "'"; // ->ref must always be defined (set to id if field does not exists) |
3271 | 3271 | } |
3272 | 3272 | if ($restrictiononfksoc == 1 && !$user->hasRight('societe', 'client', 'voir') && !$socid) { |
3273 | - $sql .= " AND (sc.fk_user = " . ((int)$user->id); |
|
3273 | + $sql .= " AND (sc.fk_user = " . ((int) $user->id); |
|
3274 | 3274 | if (getDolGlobalInt('MAIN_SEE_SUBORDINATES')) { |
3275 | 3275 | $userschilds = $user->getAllChildIds(); |
3276 | 3276 | $sql .= " OR sc.fk_user IN (" . $this->db->sanitize(implode(',', $userschilds)) . ")"; |
@@ -3278,7 +3278,7 @@ discard block |
||
3278 | 3278 | $sql .= ')'; |
3279 | 3279 | } |
3280 | 3280 | if ($restrictiononfksoc == 2 && !$user->hasRight('societe', 'client', 'voir') && !$socid) { |
3281 | - $sql .= " AND (sc.fk_user = " . ((int)$user->id) . ' OR te.fk_soc IS NULL)'; |
|
3281 | + $sql .= " AND (sc.fk_user = " . ((int) $user->id) . ' OR te.fk_soc IS NULL)'; |
|
3282 | 3282 | } |
3283 | 3283 | |
3284 | 3284 | $filtermin = $filter; |
@@ -3319,13 +3319,13 @@ discard block |
||
3319 | 3319 | $sql .= ' AND parenttable.entity IN (' . getEntity($tmparray[1]) . ')'; |
3320 | 3320 | } |
3321 | 3321 | if ($restrictiononfksoc == 1 && $socid && $this->element != 'societe') { |
3322 | - $sql .= ' AND te.fk_soc = ' . ((int)$socid); |
|
3322 | + $sql .= ' AND te.fk_soc = ' . ((int) $socid); |
|
3323 | 3323 | } |
3324 | 3324 | if ($restrictiononfksoc == 2 && $socid && $this->element != 'societe') { |
3325 | - $sql .= ' AND (te.fk_soc = ' . ((int)$socid) . ' OR te.fk_soc IS NULL)'; |
|
3325 | + $sql .= ' AND (te.fk_soc = ' . ((int) $socid) . ' OR te.fk_soc IS NULL)'; |
|
3326 | 3326 | } |
3327 | 3327 | if ($restrictiononfksoc && $socid && $this->element == 'societe') { |
3328 | - $sql .= ' AND te.rowid = ' . ((int)$socid); |
|
3328 | + $sql .= ' AND te.rowid = ' . ((int) $socid); |
|
3329 | 3329 | } |
3330 | 3330 | //print 'socid='.$socid.' restrictiononfksoc='.$restrictiononfksoc.' ismultientitymanaged = '.$this->ismultientitymanaged.' filter = '.$filter.' -> '.$sql."<br>"; |
3331 | 3331 | // Rem: Bug in some mysql version: SELECT MIN(rowid) FROM llx_socpeople WHERE rowid > 1 when one row in database with rowid=1, returns 1 instead of null |
@@ -3390,32 +3390,32 @@ discard block |
||
3390 | 3390 | $sql = "UPDATE " . $this->db->prefix() . $this->table_element; |
3391 | 3391 | if (!empty($this->fields['fk_project'])) { // Common case |
3392 | 3392 | if ($projectid) { |
3393 | - $sql .= " SET fk_project = " . ((int)$projectid); |
|
3393 | + $sql .= " SET fk_project = " . ((int) $projectid); |
|
3394 | 3394 | } else { |
3395 | 3395 | $sql .= " SET fk_project = NULL"; |
3396 | 3396 | } |
3397 | - $sql .= ' WHERE rowid = ' . ((int)$this->id); |
|
3397 | + $sql .= ' WHERE rowid = ' . ((int) $this->id); |
|
3398 | 3398 | } elseif ($this->table_element == 'actioncomm') { // Special case for actioncomm |
3399 | 3399 | if ($projectid) { |
3400 | - $sql .= " SET fk_project = " . ((int)$projectid); |
|
3400 | + $sql .= " SET fk_project = " . ((int) $projectid); |
|
3401 | 3401 | } else { |
3402 | 3402 | $sql .= " SET fk_project = NULL"; |
3403 | 3403 | } |
3404 | - $sql .= ' WHERE id = ' . ((int)$this->id); |
|
3404 | + $sql .= ' WHERE id = ' . ((int) $this->id); |
|
3405 | 3405 | } else { // Special case for old architecture objects |
3406 | 3406 | if ($projectid) { |
3407 | - $sql .= ' SET fk_projet = ' . ((int)$projectid); |
|
3407 | + $sql .= ' SET fk_projet = ' . ((int) $projectid); |
|
3408 | 3408 | } else { |
3409 | 3409 | $sql .= ' SET fk_projet = NULL'; |
3410 | 3410 | } |
3411 | - $sql .= " WHERE rowid = " . ((int)$this->id); |
|
3411 | + $sql .= " WHERE rowid = " . ((int) $this->id); |
|
3412 | 3412 | } |
3413 | 3413 | |
3414 | 3414 | $this->db->begin(); |
3415 | 3415 | |
3416 | 3416 | dol_syslog(get_only_class($this) . "::setProject", LOG_DEBUG); |
3417 | 3417 | if ($this->db->query($sql)) { |
3418 | - $this->fk_project = ((int)$projectid); |
|
3418 | + $this->fk_project = ((int) $projectid); |
|
3419 | 3419 | } else { |
3420 | 3420 | dol_print_error($this->db); |
3421 | 3421 | $error++; |
@@ -3475,8 +3475,8 @@ discard block |
||
3475 | 3475 | } |
3476 | 3476 | |
3477 | 3477 | $sql = "UPDATE " . $this->db->prefix() . $this->table_element; |
3478 | - $sql .= " SET " . $fieldname . " = " . (($id > 0 || $id == '0') ? ((int)$id) : 'NULL'); |
|
3479 | - $sql .= ' WHERE rowid=' . ((int)$this->id); |
|
3478 | + $sql .= " SET " . $fieldname . " = " . (($id > 0 || $id == '0') ? ((int) $id) : 'NULL'); |
|
3479 | + $sql .= ' WHERE rowid=' . ((int) $this->id); |
|
3480 | 3480 | |
3481 | 3481 | if ($this->db->query($sql)) { |
3482 | 3482 | $this->mode_reglement_id = $id; |
@@ -3526,7 +3526,7 @@ discard block |
||
3526 | 3526 | |
3527 | 3527 | $sql = 'UPDATE ' . $this->db->prefix() . $this->table_element; |
3528 | 3528 | $sql .= " SET " . $fieldname . " = '" . $this->db->escape($code) . "'"; |
3529 | - $sql .= ' WHERE rowid=' . ((int)$this->id); |
|
3529 | + $sql .= ' WHERE rowid=' . ((int) $this->id); |
|
3530 | 3530 | |
3531 | 3531 | if ($this->db->query($sql)) { |
3532 | 3532 | $this->multicurrency_code = $code; |
@@ -3563,8 +3563,8 @@ discard block |
||
3563 | 3563 | $fieldname = 'multicurrency_tx'; |
3564 | 3564 | |
3565 | 3565 | $sql = 'UPDATE ' . $this->db->prefix() . $this->table_element; |
3566 | - $sql .= " SET " . $fieldname . " = " . ((float)$rate); |
|
3567 | - $sql .= ' WHERE rowid=' . ((int)$this->id); |
|
3566 | + $sql .= " SET " . $fieldname . " = " . ((float) $rate); |
|
3567 | + $sql .= ' WHERE rowid=' . ((int) $this->id); |
|
3568 | 3568 | |
3569 | 3569 | if ($this->db->query($sql)) { |
3570 | 3570 | $this->multicurrency_tx = $rate; |
@@ -3786,7 +3786,7 @@ discard block |
||
3786 | 3786 | } |
3787 | 3787 | |
3788 | 3788 | if (empty($deposit_percent) || $deposit_percent < 0) { |
3789 | - $deposit_percent = (float)getDictionaryValue('c_payment_term', 'deposit_percent', $id); |
|
3789 | + $deposit_percent = (float) getDictionaryValue('c_payment_term', 'deposit_percent', $id); |
|
3790 | 3790 | } |
3791 | 3791 | |
3792 | 3792 | if ($deposit_percent > 100) { |
@@ -3794,11 +3794,11 @@ discard block |
||
3794 | 3794 | } |
3795 | 3795 | |
3796 | 3796 | $sql = 'UPDATE ' . $this->db->prefix() . $this->table_element; |
3797 | - $sql .= " SET " . $fieldname . " = " . (($id > 0 || $id == '0') ? ((int)$id) : 'NULL'); |
|
3797 | + $sql .= " SET " . $fieldname . " = " . (($id > 0 || $id == '0') ? ((int) $id) : 'NULL'); |
|
3798 | 3798 | if (in_array($this->table_element, array('propal', 'commande', 'societe'))) { |
3799 | 3799 | $sql .= " , deposit_percent = " . (empty($deposit_percent) ? 'NULL' : "'" . $this->db->escape($deposit_percent) . "'"); |
3800 | 3800 | } |
3801 | - $sql .= ' WHERE rowid=' . ((int)$this->id); |
|
3801 | + $sql .= ' WHERE rowid=' . ((int) $this->id); |
|
3802 | 3802 | |
3803 | 3803 | if ($this->db->query($sql)) { |
3804 | 3804 | $this->cond_reglement_id = $id; |
@@ -3840,8 +3840,8 @@ discard block |
||
3840 | 3840 | } |
3841 | 3841 | |
3842 | 3842 | $sql = 'UPDATE ' . $this->db->prefix() . $this->table_element; |
3843 | - $sql .= " SET " . $fieldname . " = " . (($id > 0 || $id == '0') ? ((int)$id) : 'NULL'); |
|
3844 | - $sql .= ' WHERE rowid=' . ((int)$this->id); |
|
3843 | + $sql .= " SET " . $fieldname . " = " . (($id > 0 || $id == '0') ? ((int) $id) : 'NULL'); |
|
3844 | + $sql .= ' WHERE rowid=' . ((int) $this->id); |
|
3845 | 3845 | |
3846 | 3846 | if ($this->db->query($sql)) { |
3847 | 3847 | $this->transport_mode_id = $id; |
@@ -3875,8 +3875,8 @@ discard block |
||
3875 | 3875 | $fieldname = 'retained_warranty_fk_cond_reglement'; |
3876 | 3876 | |
3877 | 3877 | $sql = 'UPDATE ' . $this->db->prefix() . $this->table_element; |
3878 | - $sql .= " SET " . $fieldname . " = " . ((int)$id); |
|
3879 | - $sql .= ' WHERE rowid=' . ((int)$this->id); |
|
3878 | + $sql .= " SET " . $fieldname . " = " . ((int) $id); |
|
3879 | + $sql .= ' WHERE rowid=' . ((int) $this->id); |
|
3880 | 3880 | |
3881 | 3881 | if ($this->db->query($sql)) { |
3882 | 3882 | $this->retained_warranty_fk_cond_reglement = $id; |
@@ -3907,8 +3907,8 @@ discard block |
||
3907 | 3907 | $fieldname = 'fk_address'; |
3908 | 3908 | } |
3909 | 3909 | |
3910 | - $sql = "UPDATE " . $this->db->prefix() . $this->table_element . " SET " . $fieldname . " = " . ((int)$id); |
|
3911 | - $sql .= " WHERE rowid = " . ((int)$this->id) . " AND fk_statut = 0"; |
|
3910 | + $sql = "UPDATE " . $this->db->prefix() . $this->table_element . " SET " . $fieldname . " = " . ((int) $id); |
|
3911 | + $sql .= " WHERE rowid = " . ((int) $this->id) . " AND fk_statut = 0"; |
|
3912 | 3912 | |
3913 | 3913 | if ($this->db->query($sql)) { |
3914 | 3914 | $this->fk_delivery_address = $id; |
@@ -3951,8 +3951,8 @@ discard block |
||
3951 | 3951 | dol_syslog(get_only_class($this) . '::setShippingMethod(' . $shipping_method_id . ')'); |
3952 | 3952 | |
3953 | 3953 | $sql = "UPDATE " . $this->db->prefix() . $this->table_element; |
3954 | - $sql .= " SET fk_shipping_method = " . ((int)$shipping_method_id); |
|
3955 | - $sql .= " WHERE rowid=" . ((int)$this->id); |
|
3954 | + $sql .= " SET fk_shipping_method = " . ((int) $shipping_method_id); |
|
3955 | + $sql .= " WHERE rowid=" . ((int) $this->id); |
|
3956 | 3956 | $resql = $this->db->query($sql); |
3957 | 3957 | if (!$resql) { |
3958 | 3958 | dol_syslog(get_only_class($this) . '::setShippingMethod Error ', LOG_DEBUG); |
@@ -3999,8 +3999,8 @@ discard block |
||
3999 | 3999 | dol_syslog(get_only_class($this) . '::setWarehouse(' . $warehouse_id . ')'); |
4000 | 4000 | |
4001 | 4001 | $sql = "UPDATE " . $this->db->prefix() . $this->table_element; |
4002 | - $sql .= " SET fk_warehouse = " . ((int)$warehouse_id); |
|
4003 | - $sql .= " WHERE rowid=" . ((int)$this->id); |
|
4002 | + $sql .= " SET fk_warehouse = " . ((int) $warehouse_id); |
|
4003 | + $sql .= " WHERE rowid=" . ((int) $this->id); |
|
4004 | 4004 | |
4005 | 4005 | if ($this->db->query($sql)) { |
4006 | 4006 | $this->warehouse_id = ($warehouse_id == 'NULL') ? null : $warehouse_id; |
@@ -4032,7 +4032,7 @@ discard block |
||
4032 | 4032 | |
4033 | 4033 | $sql = "UPDATE " . $this->db->prefix() . $this->table_element; |
4034 | 4034 | $sql .= " SET model_pdf = '" . $this->db->escape($newmodelpdf) . "'"; |
4035 | - $sql .= " WHERE rowid = " . ((int)$this->id); |
|
4035 | + $sql .= " WHERE rowid = " . ((int) $this->id); |
|
4036 | 4036 | |
4037 | 4037 | dol_syslog(get_only_class($this) . "::setDocModel", LOG_DEBUG); |
4038 | 4038 | $resql = $this->db->query($sql); |
@@ -4077,8 +4077,8 @@ discard block |
||
4077 | 4077 | dol_syslog(get_only_class($this) . '::setBankAccount(' . $fk_account . ')'); |
4078 | 4078 | |
4079 | 4079 | $sql = "UPDATE " . $this->db->prefix() . $this->table_element; |
4080 | - $sql .= " SET fk_account = " . ((int)$fk_account); |
|
4081 | - $sql .= " WHERE rowid=" . ((int)$this->id); |
|
4080 | + $sql .= " SET fk_account = " . ((int) $fk_account); |
|
4081 | + $sql .= " WHERE rowid=" . ((int) $this->id); |
|
4082 | 4082 | |
4083 | 4083 | $resql = $this->db->query($sql); |
4084 | 4084 | if (!$resql) { |
@@ -4163,7 +4163,7 @@ discard block |
||
4163 | 4163 | // Count number of lines to reorder (according to choice $renum) |
4164 | 4164 | $nl = 0; |
4165 | 4165 | $sql = "SELECT count(rowid) FROM " . $this->db->prefix() . $this->table_element_line; |
4166 | - $sql .= " WHERE " . $this->fk_element . " = " . ((int)$this->id); |
|
4166 | + $sql .= " WHERE " . $this->fk_element . " = " . ((int) $this->id); |
|
4167 | 4167 | if (!$renum) { |
4168 | 4168 | $sql .= " AND " . $fieldposition . " = 0"; |
4169 | 4169 | } |
@@ -4185,7 +4185,7 @@ discard block |
||
4185 | 4185 | |
4186 | 4186 | // We first search all lines that are parent lines (for multilevel details lines) |
4187 | 4187 | $sql = "SELECT rowid FROM " . $this->db->prefix() . $this->table_element_line; |
4188 | - $sql .= " WHERE " . $this->fk_element . " = " . ((int)$this->id); |
|
4188 | + $sql .= " WHERE " . $this->fk_element . " = " . ((int) $this->id); |
|
4189 | 4189 | if ($fk_parent_line) { |
4190 | 4190 | $sql .= ' AND fk_parent_line IS NULL'; |
4191 | 4191 | } |
@@ -4240,8 +4240,8 @@ discard block |
||
4240 | 4240 | $rows = array(); |
4241 | 4241 | |
4242 | 4242 | $sql = "SELECT rowid FROM " . $this->db->prefix() . $this->table_element_line; |
4243 | - $sql .= " WHERE " . $this->fk_element . " = " . ((int)$this->id); |
|
4244 | - $sql .= ' AND fk_parent_line = ' . ((int)$id); |
|
4243 | + $sql .= " WHERE " . $this->fk_element . " = " . ((int) $this->id); |
|
4244 | + $sql .= ' AND fk_parent_line = ' . ((int) $id); |
|
4245 | 4245 | $sql .= " ORDER BY " . $fieldposition . " ASC"; |
4246 | 4246 | |
4247 | 4247 | dol_syslog(get_only_class($this) . "::getChildrenOfLine search children lines for line " . $id, LOG_DEBUG); |
@@ -4274,8 +4274,8 @@ discard block |
||
4274 | 4274 | $fieldposition = 'position'; |
4275 | 4275 | } |
4276 | 4276 | |
4277 | - $sql = "UPDATE " . $this->db->prefix() . $this->table_element_line . " SET " . $fieldposition . " = " . ((int)$rang); |
|
4278 | - $sql .= ' WHERE rowid = ' . ((int)$rowid); |
|
4277 | + $sql = "UPDATE " . $this->db->prefix() . $this->table_element_line . " SET " . $fieldposition . " = " . ((int) $rang); |
|
4278 | + $sql .= ' WHERE rowid = ' . ((int) $rowid); |
|
4279 | 4279 | |
4280 | 4280 | dol_syslog(get_only_class($this) . "::updateRangOfLine", LOG_DEBUG); |
4281 | 4281 | if (!$this->db->query($sql)) { |
@@ -4303,7 +4303,7 @@ discard block |
||
4303 | 4303 | } |
4304 | 4304 | |
4305 | 4305 | $sql = "SELECT " . $fieldposition . " FROM " . $this->db->prefix() . $this->table_element_line; |
4306 | - $sql .= " WHERE rowid = " . ((int)$rowid); |
|
4306 | + $sql .= " WHERE rowid = " . ((int) $rowid); |
|
4307 | 4307 | |
4308 | 4308 | dol_syslog(get_only_class($this) . "::getRangOfLine", LOG_DEBUG); |
4309 | 4309 | $resql = $this->db->query($sql); |
@@ -4330,12 +4330,12 @@ discard block |
||
4330 | 4330 | $fieldposition = 'position'; |
4331 | 4331 | } |
4332 | 4332 | |
4333 | - $sql = "UPDATE " . $this->db->prefix() . $this->table_element_line . " SET " . $fieldposition . " = " . ((int)$rang); |
|
4334 | - $sql .= " WHERE " . $this->fk_element . " = " . ((int)$this->id); |
|
4335 | - $sql .= " AND " . $fieldposition . " = " . ((int)($rang - 1)); |
|
4333 | + $sql = "UPDATE " . $this->db->prefix() . $this->table_element_line . " SET " . $fieldposition . " = " . ((int) $rang); |
|
4334 | + $sql .= " WHERE " . $this->fk_element . " = " . ((int) $this->id); |
|
4335 | + $sql .= " AND " . $fieldposition . " = " . ((int) ($rang - 1)); |
|
4336 | 4336 | if ($this->db->query($sql)) { |
4337 | - $sql = "UPDATE " . $this->db->prefix() . $this->table_element_line . " SET " . $fieldposition . " = " . ((int)($rang - 1)); |
|
4338 | - $sql .= ' WHERE rowid = ' . ((int)$rowid); |
|
4337 | + $sql = "UPDATE " . $this->db->prefix() . $this->table_element_line . " SET " . $fieldposition . " = " . ((int) ($rang - 1)); |
|
4338 | + $sql .= ' WHERE rowid = ' . ((int) $rowid); |
|
4339 | 4339 | if (!$this->db->query($sql)) { |
4340 | 4340 | dol_print_error($this->db); |
4341 | 4341 | } |
@@ -4384,8 +4384,8 @@ discard block |
||
4384 | 4384 | // Search the last rang with fk_parent_line |
4385 | 4385 | if ($fk_parent_line) { |
4386 | 4386 | $sql = "SELECT max(" . $positionfield . ") FROM " . $this->db->prefix() . $this->table_element_line; |
4387 | - $sql .= " WHERE " . $this->fk_element . " = " . ((int)$this->id); |
|
4388 | - $sql .= " AND fk_parent_line = " . ((int)$fk_parent_line); |
|
4387 | + $sql .= " WHERE " . $this->fk_element . " = " . ((int) $this->id); |
|
4388 | + $sql .= " AND fk_parent_line = " . ((int) $fk_parent_line); |
|
4389 | 4389 | |
4390 | 4390 | dol_syslog(get_only_class($this) . "::line_max", LOG_DEBUG); |
4391 | 4391 | $resql = $this->db->query($sql); |
@@ -4400,7 +4400,7 @@ discard block |
||
4400 | 4400 | } else { |
4401 | 4401 | // If not, search the last rang of element |
4402 | 4402 | $sql = "SELECT max(" . $positionfield . ") FROM " . $this->db->prefix() . $this->table_element_line; |
4403 | - $sql .= " WHERE " . $this->fk_element . " = " . ((int)$this->id); |
|
4403 | + $sql .= " WHERE " . $this->fk_element . " = " . ((int) $this->id); |
|
4404 | 4404 | |
4405 | 4405 | dol_syslog(get_only_class($this) . "::line_max", LOG_DEBUG); |
4406 | 4406 | $resql = $this->db->query($sql); |
@@ -4429,12 +4429,12 @@ discard block |
||
4429 | 4429 | $fieldposition = 'position'; |
4430 | 4430 | } |
4431 | 4431 | |
4432 | - $sql = "UPDATE " . $this->db->prefix() . $this->table_element_line . " SET " . $fieldposition . " = " . ((int)$rang); |
|
4433 | - $sql .= " WHERE " . $this->fk_element . " = " . ((int)$this->id); |
|
4434 | - $sql .= " AND " . $fieldposition . " = " . ((int)($rang + 1)); |
|
4432 | + $sql = "UPDATE " . $this->db->prefix() . $this->table_element_line . " SET " . $fieldposition . " = " . ((int) $rang); |
|
4433 | + $sql .= " WHERE " . $this->fk_element . " = " . ((int) $this->id); |
|
4434 | + $sql .= " AND " . $fieldposition . " = " . ((int) ($rang + 1)); |
|
4435 | 4435 | if ($this->db->query($sql)) { |
4436 | - $sql = "UPDATE " . $this->db->prefix() . $this->table_element_line . " SET " . $fieldposition . " = " . ((int)($rang + 1)); |
|
4437 | - $sql .= ' WHERE rowid = ' . ((int)$rowid); |
|
4436 | + $sql = "UPDATE " . $this->db->prefix() . $this->table_element_line . " SET " . $fieldposition . " = " . ((int) ($rang + 1)); |
|
4437 | + $sql .= ' WHERE rowid = ' . ((int) $rowid); |
|
4438 | 4438 | if (!$this->db->query($sql)) { |
4439 | 4439 | dol_print_error($this->db); |
4440 | 4440 | } |
@@ -4473,8 +4473,8 @@ discard block |
||
4473 | 4473 | } |
4474 | 4474 | |
4475 | 4475 | $sql = "SELECT rowid FROM " . $this->db->prefix() . $this->table_element_line; |
4476 | - $sql .= " WHERE " . $this->fk_element . " = " . ((int)$this->id); |
|
4477 | - $sql .= " AND " . $fieldposition . " = " . ((int)$rang); |
|
4476 | + $sql .= " WHERE " . $this->fk_element . " = " . ((int) $this->id); |
|
4477 | + $sql .= " AND " . $fieldposition . " = " . ((int) $rang); |
|
4478 | 4478 | $resql = $this->db->query($sql); |
4479 | 4479 | if ($resql) { |
4480 | 4480 | $row = $this->db->fetch_row($resql); |
@@ -4500,7 +4500,7 @@ discard block |
||
4500 | 4500 | |
4501 | 4501 | $sql = "UPDATE " . $this->db->prefix() . $this->table_element; |
4502 | 4502 | $sql .= " SET ref_ext = '" . $this->db->escape($ref_ext) . "'"; |
4503 | - $sql .= " WHERE " . (isset($this->table_rowid) ? $this->table_rowid : 'rowid') . " = " . ((int)$this->id); |
|
4503 | + $sql .= " WHERE " . (isset($this->table_rowid) ? $this->table_rowid : 'rowid') . " = " . ((int) $this->id); |
|
4504 | 4504 | |
4505 | 4505 | dol_syslog(get_only_class($this) . "::update_ref_ext", LOG_DEBUG); |
4506 | 4506 | if ($this->db->query($sql)) { |
@@ -4565,8 +4565,8 @@ discard block |
||
4565 | 4565 | } |
4566 | 4566 | $sql = "UPDATE " . $this->db->prefix() . $this->table_element; |
4567 | 4567 | $sql .= " SET note" . $newsuffix . " = " . (!empty($note) ? ("'" . $this->db->escape($note) . "'") : "NULL"); |
4568 | - $sql .= ", " . $fieldusermod . " = " . ((int)$user->id); |
|
4569 | - $sql .= " WHERE rowid = " . ((int)$this->id); |
|
4568 | + $sql .= ", " . $fieldusermod . " = " . ((int) $user->id); |
|
4569 | + $sql .= " WHERE rowid = " . ((int) $this->id); |
|
4570 | 4570 | |
4571 | 4571 | dol_syslog(get_only_class($this) . "::update_note", LOG_DEBUG); |
4572 | 4572 | if ($this->db->query($sql)) { |
@@ -4709,7 +4709,7 @@ discard block |
||
4709 | 4709 | } |
4710 | 4710 | $sql .= ', multicurrency_total_ht, multicurrency_total_tva, multicurrency_total_ttc'; |
4711 | 4711 | $sql .= " FROM " . $this->db->prefix() . $this->table_element_line; |
4712 | - $sql .= " WHERE " . $this->fk_element . " = " . ((int)$this->id); |
|
4712 | + $sql .= " WHERE " . $this->fk_element . " = " . ((int) $this->id); |
|
4713 | 4713 | if ($exclspec) { |
4714 | 4714 | $product_field = 'product_type'; |
4715 | 4715 | if ($this->table_element_line == 'contratdet') { |
@@ -4760,7 +4760,7 @@ discard block |
||
4760 | 4760 | |
4761 | 4761 | if ($diff_on_current_total) { |
4762 | 4762 | // This should not happen, we should always have in table: total_ttc = total_ht + total_vat + total_localtax1 + total_localtax2 |
4763 | - $sqlfix = "UPDATE " . $this->db->prefix() . $this->table_element_line . " SET " . $fieldtva . " = " . price2num((float)$tmpcal[1]) . ", total_ttc = " . price2num((float)$tmpcal[2]) . " WHERE rowid = " . ((int)$obj->rowid); |
|
4763 | + $sqlfix = "UPDATE " . $this->db->prefix() . $this->table_element_line . " SET " . $fieldtva . " = " . price2num((float) $tmpcal[1]) . ", total_ttc = " . price2num((float) $tmpcal[2]) . " WHERE rowid = " . ((int) $obj->rowid); |
|
4764 | 4764 | dol_syslog('We found inconsistent data into detailed line (diff_on_current_total = ' . $diff_on_current_total . ') for line rowid = ' . $obj->rowid . " (ht=" . $obj->total_ht . " vat=" . $obj->total_tva . " tax1=" . $obj->total_localtax1 . " tax2=" . $obj->total_localtax2 . " ttc=" . $obj->total_ttc . "). We fix the total_vat and total_ttc of line by running sqlfix = " . $sqlfix, LOG_WARNING); |
4765 | 4765 | $resqlfix = $this->db->query($sqlfix); |
4766 | 4766 | if (!$resqlfix) { |
@@ -4771,7 +4771,7 @@ discard block |
||
4771 | 4771 | } elseif ($diff_when_using_price_ht) { |
4772 | 4772 | // After calculation from HT, total is consistent but we have found a difference between VAT part in calculation and into database and |
4773 | 4773 | // we ask to force the use of rounding on line (like done on calculation) so we force update of line |
4774 | - $sqlfix = "UPDATE " . $this->db->prefix() . $this->table_element_line . " SET " . $fieldtva . " = " . price2num((float)$tmpcal[1]) . ", total_ttc = " . price2num((float)$tmpcal[2]) . " WHERE rowid = " . ((int)$obj->rowid); |
|
4774 | + $sqlfix = "UPDATE " . $this->db->prefix() . $this->table_element_line . " SET " . $fieldtva . " = " . price2num((float) $tmpcal[1]) . ", total_ttc = " . price2num((float) $tmpcal[2]) . " WHERE rowid = " . ((int) $obj->rowid); |
|
4775 | 4775 | dol_syslog('We found a line with different rounding data into detailed line (diff_when_using_price_ht = ' . $diff_when_using_price_ht . ' and diff_on_current_total = ' . $diff_on_current_total . ') for line rowid = ' . $obj->rowid . " (total vat of line calculated=" . $tmpcal[1] . ", database=" . $obj->total_tva . "). We fix the total_vat and total_ttc of line by running sqlfix = " . $sqlfix); |
4776 | 4776 | $resqlfix = $this->db->query($sqlfix); |
4777 | 4777 | if (!$resqlfix) { |
@@ -4810,10 +4810,10 @@ discard block |
||
4810 | 4810 | } else { |
4811 | 4811 | $tmpvat = price2num($total_ht_by_vats[$obj->vatrate] * $obj->vatrate / 100, 'MT', 1); |
4812 | 4812 | } |
4813 | - $diff = price2num($total_tva_by_vats[$obj->vatrate] - (float)$tmpvat, 'MT', 1); |
|
4813 | + $diff = price2num($total_tva_by_vats[$obj->vatrate] - (float) $tmpvat, 'MT', 1); |
|
4814 | 4814 | //print 'Line '.$i.' rowid='.$obj->rowid.' vat_rate='.$obj->vatrate.' total_ht='.$obj->total_ht.' total_tva='.$obj->total_tva.' total_ttc='.$obj->total_ttc.' total_ht_by_vats='.$total_ht_by_vats[$obj->vatrate].' total_tva_by_vats='.$total_tva_by_vats[$obj->vatrate].' (new calculation = '.$tmpvat.') total_ttc_by_vats='.$total_ttc_by_vats[$obj->vatrate].($diff?" => DIFF":"")."<br>\n"; |
4815 | 4815 | if ($diff) { |
4816 | - if (abs((float)$diff) > (10 * pow(10, -1 * getDolGlobalInt('MAIN_MAX_DECIMALS_TOT', 0)))) { |
|
4816 | + if (abs((float) $diff) > (10 * pow(10, -1 * getDolGlobalInt('MAIN_MAX_DECIMALS_TOT', 0)))) { |
|
4817 | 4817 | // If error is more than 10 times the accuracy of rounding. This should not happen. |
4818 | 4818 | $errmsg = 'A rounding difference was detected into TOTAL but is too high to be corrected. Some data in your lines may be corrupted. Try to edit each line manually to fix this before restarting.'; |
4819 | 4819 | dol_syslog($errmsg, LOG_WARNING); |
@@ -4822,10 +4822,10 @@ discard block |
||
4822 | 4822 | break; |
4823 | 4823 | } |
4824 | 4824 | if ($base_price_type == 'TTC') { |
4825 | - $sqlfix = "UPDATE " . $this->db->prefix() . $this->table_element_line . " SET " . $fieldtva . " = " . price2num($obj->total_tva - (float)$diff) . ", total_ht = " . price2num($obj->total_ht + (float)$diff) . " WHERE rowid = " . ((int)$obj->rowid); |
|
4825 | + $sqlfix = "UPDATE " . $this->db->prefix() . $this->table_element_line . " SET " . $fieldtva . " = " . price2num($obj->total_tva - (float) $diff) . ", total_ht = " . price2num($obj->total_ht + (float) $diff) . " WHERE rowid = " . ((int) $obj->rowid); |
|
4826 | 4826 | dol_syslog('We found a difference of ' . $diff . ' for line rowid = ' . $obj->rowid . ". We fix the total_vat and total_ht of line by running sqlfix = " . $sqlfix); |
4827 | 4827 | } else { |
4828 | - $sqlfix = "UPDATE " . $this->db->prefix() . $this->table_element_line . " SET " . $fieldtva . " = " . price2num($obj->total_tva - (float)$diff) . ", total_ttc = " . price2num($obj->total_ttc - (float)$diff) . " WHERE rowid = " . ((int)$obj->rowid); |
|
4828 | + $sqlfix = "UPDATE " . $this->db->prefix() . $this->table_element_line . " SET " . $fieldtva . " = " . price2num($obj->total_tva - (float) $diff) . ", total_ttc = " . price2num($obj->total_ttc - (float) $diff) . " WHERE rowid = " . ((int) $obj->rowid); |
|
4829 | 4829 | dol_syslog('We found a difference of ' . $diff . ' for line rowid = ' . $obj->rowid . ". We fix the total_vat and total_ttc of line by running sqlfix = " . $sqlfix); |
4830 | 4830 | } |
4831 | 4831 | |
@@ -4835,14 +4835,14 @@ discard block |
||
4835 | 4835 | dol_print_error($this->db, 'Failed to update line'); |
4836 | 4836 | } |
4837 | 4837 | |
4838 | - $this->total_tva = (float)price2num($this->total_tva - (float)$diff, '', 1); |
|
4839 | - $total_tva_by_vats[$obj->vatrate] = (float)price2num($total_tva_by_vats[$obj->vatrate] - (float)$diff, '', 1); |
|
4838 | + $this->total_tva = (float) price2num($this->total_tva - (float) $diff, '', 1); |
|
4839 | + $total_tva_by_vats[$obj->vatrate] = (float) price2num($total_tva_by_vats[$obj->vatrate] - (float) $diff, '', 1); |
|
4840 | 4840 | if ($base_price_type == 'TTC') { |
4841 | - $this->total_ht = (float)price2num($this->total_ht + (float)$diff, '', 1); |
|
4842 | - $total_ht_by_vats[$obj->vatrate] = (float)price2num($total_ht_by_vats[$obj->vatrate] + (float)$diff, '', 1); |
|
4841 | + $this->total_ht = (float) price2num($this->total_ht + (float) $diff, '', 1); |
|
4842 | + $total_ht_by_vats[$obj->vatrate] = (float) price2num($total_ht_by_vats[$obj->vatrate] + (float) $diff, '', 1); |
|
4843 | 4843 | } else { |
4844 | - $this->total_ttc = (float)price2num($this->total_ttc - (float)$diff, '', 1); |
|
4845 | - $total_ttc_by_vats[$obj->vatrate] = (float)price2num($total_ttc_by_vats[$obj->vatrate] - (float)$diff, '', 1); |
|
4844 | + $this->total_ttc = (float) price2num($this->total_ttc - (float) $diff, '', 1); |
|
4845 | + $total_ttc_by_vats[$obj->vatrate] = (float) price2num($total_ttc_by_vats[$obj->vatrate] - (float) $diff, '', 1); |
|
4846 | 4846 | } |
4847 | 4847 | } |
4848 | 4848 | } |
@@ -4875,11 +4875,11 @@ discard block |
||
4875 | 4875 | } |
4876 | 4876 | |
4877 | 4877 | // Clean total |
4878 | - $this->total_ht = (float)price2num($this->total_ht); |
|
4879 | - $this->total_tva = (float)price2num($this->total_tva); |
|
4880 | - $this->total_localtax1 = (float)price2num($this->total_localtax1); |
|
4881 | - $this->total_localtax2 = (float)price2num($this->total_localtax2); |
|
4882 | - $this->total_ttc = (float)price2num($this->total_ttc); |
|
4878 | + $this->total_ht = (float) price2num($this->total_ht); |
|
4879 | + $this->total_tva = (float) price2num($this->total_tva); |
|
4880 | + $this->total_localtax1 = (float) price2num($this->total_localtax1); |
|
4881 | + $this->total_localtax2 = (float) price2num($this->total_localtax2); |
|
4882 | + $this->total_ttc = (float) price2num($this->total_ttc); |
|
4883 | 4883 | |
4884 | 4884 | $this->db->free($resql); |
4885 | 4885 | |
@@ -4896,15 +4896,15 @@ discard block |
||
4896 | 4896 | |
4897 | 4897 | if (!$error && empty($nodatabaseupdate)) { |
4898 | 4898 | $sql = "UPDATE " . $this->db->prefix() . $this->table_element . ' SET'; |
4899 | - $sql .= " " . $fieldht . " = " . ((float)price2num($this->total_ht, 'MT', 1)) . ","; |
|
4900 | - $sql .= " " . $fieldtva . " = " . ((float)price2num($this->total_tva, 'MT', 1)) . ","; |
|
4901 | - $sql .= " " . $fieldlocaltax1 . " = " . ((float)price2num($this->total_localtax1, 'MT', 1)) . ","; |
|
4902 | - $sql .= " " . $fieldlocaltax2 . " = " . ((float)price2num($this->total_localtax2, 'MT', 1)) . ","; |
|
4903 | - $sql .= " " . $fieldttc . " = " . ((float)price2num($this->total_ttc, 'MT', 1)); |
|
4904 | - $sql .= ", multicurrency_total_ht = " . ((float)price2num($this->multicurrency_total_ht, 'MT', 1)); |
|
4905 | - $sql .= ", multicurrency_total_tva = " . ((float)price2num($this->multicurrency_total_tva, 'MT', 1)); |
|
4906 | - $sql .= ", multicurrency_total_ttc = " . ((float)price2num($this->multicurrency_total_ttc, 'MT', 1)); |
|
4907 | - $sql .= " WHERE rowid = " . ((int)$this->id); |
|
4899 | + $sql .= " " . $fieldht . " = " . ((float) price2num($this->total_ht, 'MT', 1)) . ","; |
|
4900 | + $sql .= " " . $fieldtva . " = " . ((float) price2num($this->total_tva, 'MT', 1)) . ","; |
|
4901 | + $sql .= " " . $fieldlocaltax1 . " = " . ((float) price2num($this->total_localtax1, 'MT', 1)) . ","; |
|
4902 | + $sql .= " " . $fieldlocaltax2 . " = " . ((float) price2num($this->total_localtax2, 'MT', 1)) . ","; |
|
4903 | + $sql .= " " . $fieldttc . " = " . ((float) price2num($this->total_ttc, 'MT', 1)); |
|
4904 | + $sql .= ", multicurrency_total_ht = " . ((float) price2num($this->multicurrency_total_ht, 'MT', 1)); |
|
4905 | + $sql .= ", multicurrency_total_tva = " . ((float) price2num($this->multicurrency_total_tva, 'MT', 1)); |
|
4906 | + $sql .= ", multicurrency_total_ttc = " . ((float) price2num($this->multicurrency_total_ttc, 'MT', 1)); |
|
4907 | + $sql .= " WHERE rowid = " . ((int) $this->id); |
|
4908 | 4908 | |
4909 | 4909 | dol_syslog(get_only_class($this) . "::update_price", LOG_DEBUG); |
4910 | 4910 | $resql = $this->db->query($sql); |
@@ -4982,9 +4982,9 @@ discard block |
||
4982 | 4982 | $sql .= ", fk_target"; |
4983 | 4983 | $sql .= ", targettype"; |
4984 | 4984 | $sql .= ") VALUES ("; |
4985 | - $sql .= ((int)$origin_id); |
|
4985 | + $sql .= ((int) $origin_id); |
|
4986 | 4986 | $sql .= ", '" . $this->db->escape($origin) . "'"; |
4987 | - $sql .= ", " . ((int)$this->id); |
|
4987 | + $sql .= ", " . ((int) $this->id); |
|
4988 | 4988 | $sql .= ", '" . $this->db->escape($targettype) . "'"; |
4989 | 4989 | $sql .= ")"; |
4990 | 4990 | |
@@ -5117,19 +5117,19 @@ discard block |
||
5117 | 5117 | $sql .= " WHERE "; |
5118 | 5118 | if ($justsource || $justtarget) { |
5119 | 5119 | if ($justsource) { |
5120 | - $sql .= "fk_source = " . ((int)$sourceid) . " AND sourcetype = '" . $this->db->escape($sourcetype) . "'"; |
|
5120 | + $sql .= "fk_source = " . ((int) $sourceid) . " AND sourcetype = '" . $this->db->escape($sourcetype) . "'"; |
|
5121 | 5121 | if ($withtargettype) { |
5122 | 5122 | $sql .= " AND targettype = '" . $this->db->escape($targettype) . "'"; |
5123 | 5123 | } |
5124 | 5124 | } elseif ($justtarget) { |
5125 | - $sql .= "fk_target = " . ((int)$targetid) . " AND targettype = '" . $this->db->escape($targettype) . "'"; |
|
5125 | + $sql .= "fk_target = " . ((int) $targetid) . " AND targettype = '" . $this->db->escape($targettype) . "'"; |
|
5126 | 5126 | if ($withsourcetype) { |
5127 | 5127 | $sql .= " AND sourcetype = '" . $this->db->escape($sourcetype) . "'"; |
5128 | 5128 | } |
5129 | 5129 | } |
5130 | 5130 | } else { |
5131 | - $sql .= "(fk_source = " . ((int)$sourceid) . " AND sourcetype = '" . $this->db->escape($sourcetype) . "')"; |
|
5132 | - $sql .= " " . $clause . " (fk_target = " . ((int)$targetid) . " AND targettype = '" . $this->db->escape($targettype) . "')"; |
|
5131 | + $sql .= "(fk_source = " . ((int) $sourceid) . " AND sourcetype = '" . $this->db->escape($sourcetype) . "')"; |
|
5132 | + $sql .= " " . $clause . " (fk_target = " . ((int) $targetid) . " AND targettype = '" . $this->db->escape($targettype) . "')"; |
|
5133 | 5133 | if ($loadalsoobjects && $this->id > 0 && $sourceid == $this->id && $sourcetype == $this->element && $targetid == $this->id && $targettype == $this->element && $clause == 'OR') { |
5134 | 5134 | $this->linkedObjectsFullLoaded[$this->id] = true; |
5135 | 5135 | } |
@@ -5248,14 +5248,14 @@ discard block |
||
5248 | 5248 | |
5249 | 5249 | $sql = "UPDATE " . $this->db->prefix() . "element_element SET "; |
5250 | 5250 | if ($updatesource) { |
5251 | - $sql .= "fk_source = " . ((int)$sourceid); |
|
5251 | + $sql .= "fk_source = " . ((int) $sourceid); |
|
5252 | 5252 | $sql .= ", sourcetype = '" . $this->db->escape($sourcetype) . "'"; |
5253 | - $sql .= " WHERE fk_target = " . ((int)$this->id); |
|
5253 | + $sql .= " WHERE fk_target = " . ((int) $this->id); |
|
5254 | 5254 | $sql .= " AND targettype = '" . $this->db->escape($this->element) . "'"; |
5255 | 5255 | } elseif ($updatetarget) { |
5256 | - $sql .= "fk_target = " . ((int)$targetid); |
|
5256 | + $sql .= "fk_target = " . ((int) $targetid); |
|
5257 | 5257 | $sql .= ", targettype = '" . $this->db->escape($targettype) . "'"; |
5258 | - $sql .= " WHERE fk_source = " . ((int)$this->id); |
|
5258 | + $sql .= " WHERE fk_source = " . ((int) $this->id); |
|
5259 | 5259 | $sql .= " AND sourcetype = '" . $this->db->escape($this->element) . "'"; |
5260 | 5260 | } |
5261 | 5261 | |
@@ -5338,11 +5338,11 @@ discard block |
||
5338 | 5338 | } |
5339 | 5339 | |
5340 | 5340 | $sql = "UPDATE " . $this->db->prefix() . $elementTable; |
5341 | - $sql .= " SET " . $fieldstatus . " = " . ((int)$status); |
|
5341 | + $sql .= " SET " . $fieldstatus . " = " . ((int) $status); |
|
5342 | 5342 | // If status = 1 = validated, update also fk_user_valid |
5343 | 5343 | // TODO Replace the test on $elementTable by doing a test on existence of the field in $this->fields |
5344 | 5344 | if ($status == 1 && in_array($elementTable, array('expensereport', 'inventory'))) { |
5345 | - $sql .= ", fk_user_valid = " . ((int)$user->id); |
|
5345 | + $sql .= ", fk_user_valid = " . ((int) $user->id); |
|
5346 | 5346 | } |
5347 | 5347 | if ($status == 1 && in_array($elementTable, array('expensereport'))) { |
5348 | 5348 | $sql .= ", date_valid = '" . $this->db->idate(dol_now()) . "'"; |
@@ -5350,15 +5350,15 @@ discard block |
||
5350 | 5350 | if ($status == 1 && in_array($elementTable, array('inventory'))) { |
5351 | 5351 | $sql .= ", date_validation = '" . $this->db->idate(dol_now()) . "'"; |
5352 | 5352 | } |
5353 | - $sql .= " WHERE rowid = " . ((int)$elementId); |
|
5354 | - $sql .= " AND " . $fieldstatus . " <> " . ((int)$status); // We avoid update if status already correct |
|
5353 | + $sql .= " WHERE rowid = " . ((int) $elementId); |
|
5354 | + $sql .= " AND " . $fieldstatus . " <> " . ((int) $status); // We avoid update if status already correct |
|
5355 | 5355 | |
5356 | 5356 | dol_syslog(get_only_class($this) . "::setStatut", LOG_DEBUG); |
5357 | 5357 | $resql = $this->db->query($sql); |
5358 | 5358 | if ($resql) { |
5359 | 5359 | $error = 0; |
5360 | 5360 | |
5361 | - $nb_rows_affected = $this->db->affected_rows($resql); // should be 1 or 0 if status was already correct |
|
5361 | + $nb_rows_affected = $this->db->affected_rows($resql); // should be 1 or 0 if status was already correct |
|
5362 | 5362 | |
5363 | 5363 | if ($nb_rows_affected > 0) { |
5364 | 5364 | if (empty($trigkey)) { |
@@ -5403,7 +5403,7 @@ discard block |
||
5403 | 5403 | if ($fieldstatus == 'tosell') { |
5404 | 5404 | $this->status = $status; |
5405 | 5405 | } elseif ($fieldstatus == 'tobuy') { |
5406 | - $this->status_buy = $status; // @phpstan-ignore-line |
|
5406 | + $this->status_buy = $status; // @phpstan-ignore-line |
|
5407 | 5407 | } else { |
5408 | 5408 | $this->status = $status; |
5409 | 5409 | } |
@@ -5447,7 +5447,7 @@ discard block |
||
5447 | 5447 | $sql .= " FROM " . $this->db->prefix() . $this->table_element; |
5448 | 5448 | $sql .= " WHERE entity IN (" . getEntity($this->element) . ")"; |
5449 | 5449 | if (!empty($id)) { |
5450 | - $sql .= " AND rowid = " . ((int)$id); |
|
5450 | + $sql .= " AND rowid = " . ((int) $id); |
|
5451 | 5451 | } |
5452 | 5452 | if (!empty($ref)) { |
5453 | 5453 | $sql .= " AND ref = '" . $this->db->escape($ref) . "'"; |
@@ -5480,7 +5480,7 @@ discard block |
||
5480 | 5480 | public function getSpecialCode($lineid) |
5481 | 5481 | { |
5482 | 5482 | $sql = "SELECT special_code FROM " . $this->db->prefix() . $this->table_element_line; |
5483 | - $sql .= " WHERE rowid = " . ((int)$lineid); |
|
5483 | + $sql .= " WHERE rowid = " . ((int) $lineid); |
|
5484 | 5484 | $resql = $this->db->query($sql); |
5485 | 5485 | if ($resql) { |
5486 | 5486 | $row = $this->db->fetch_row($resql); |
@@ -5540,7 +5540,7 @@ discard block |
||
5540 | 5540 | |
5541 | 5541 | $sql = "SELECT subprice as pu_ht, qty, remise_percent, total_ht"; |
5542 | 5542 | $sql .= " FROM " . $this->db->prefix() . $this->table_element_line; |
5543 | - $sql .= " WHERE " . $this->fk_element . " = " . ((int)$this->id); |
|
5543 | + $sql .= " WHERE " . $this->fk_element . " = " . ((int) $this->id); |
|
5544 | 5544 | |
5545 | 5545 | dol_syslog(get_only_class($this) . '::getTotalDiscount', LOG_DEBUG); |
5546 | 5546 | $resql = $this->db->query($sql); |
@@ -5554,7 +5554,7 @@ discard block |
||
5554 | 5554 | $qty = $obj->qty; |
5555 | 5555 | $total_ht = $obj->total_ht; |
5556 | 5556 | |
5557 | - $total_discount_line = (float)price2num(($pu_ht * $qty) - $total_ht, 'MT'); |
|
5557 | + $total_discount_line = (float) price2num(($pu_ht * $qty) - $total_ht, 'MT'); |
|
5558 | 5558 | $total_discount += $total_discount_line; |
5559 | 5559 | |
5560 | 5560 | $i++; |
@@ -5562,7 +5562,7 @@ discard block |
||
5562 | 5562 | } |
5563 | 5563 | |
5564 | 5564 | //print $total_discount; exit; |
5565 | - return (float)price2num($total_discount); |
|
5565 | + return (float) price2num($total_discount); |
|
5566 | 5566 | } |
5567 | 5567 | |
5568 | 5568 | return null; |
@@ -5685,7 +5685,7 @@ discard block |
||
5685 | 5685 | |
5686 | 5686 | $sql = "UPDATE " . $this->db->prefix() . $this->table_element; |
5687 | 5687 | $sql .= " SET extraparams = " . (!empty($extraparams) ? "'" . $this->db->escape($extraparams) . "'" : "null"); |
5688 | - $sql .= " WHERE rowid = " . ((int)$this->id); |
|
5688 | + $sql .= " WHERE rowid = " . ((int) $this->id); |
|
5689 | 5689 | |
5690 | 5690 | dol_syslog(get_only_class($this) . "::setExtraParameters", LOG_DEBUG); |
5691 | 5691 | $resql = $this->db->query($sql); |
@@ -6237,7 +6237,7 @@ discard block |
||
6237 | 6237 | $sql .= ", busy"; |
6238 | 6238 | $sql .= ", mandatory"; |
6239 | 6239 | $sql .= ") VALUES ("; |
6240 | - $sql .= ((int)$resource_id); |
|
6240 | + $sql .= ((int) $resource_id); |
|
6241 | 6241 | $sql .= ", '" . $this->db->escape($resource_type) . "'"; |
6242 | 6242 | $sql .= ", '" . $this->db->escape($this->id) . "'"; |
6243 | 6243 | $sql .= ", '" . $this->db->escape($this->element) . "'"; |
@@ -6275,7 +6275,7 @@ discard block |
||
6275 | 6275 | $this->db->begin(); |
6276 | 6276 | |
6277 | 6277 | $sql = "DELETE FROM " . $this->db->prefix() . "element_resources"; |
6278 | - $sql .= " WHERE rowid = " . ((int)$rowid); |
|
6278 | + $sql .= " WHERE rowid = " . ((int) $rowid); |
|
6279 | 6279 | |
6280 | 6280 | dol_syslog(get_only_class($this) . "::delete_resource", LOG_DEBUG); |
6281 | 6281 | |
@@ -6337,7 +6337,7 @@ discard block |
||
6337 | 6337 | $maxwidthmini = $tmparraysize['maxwidthmini']; |
6338 | 6338 | $maxheightmini = $tmparraysize['maxheightmini']; |
6339 | 6339 | //$quality = $tmparraysize['quality']; |
6340 | - $quality = 50; // For thumbs, we force quality to 50 |
|
6340 | + $quality = 50; // For thumbs, we force quality to 50 |
|
6341 | 6341 | |
6342 | 6342 | // Create small thumbs for company (Ratio is near 16/9) |
6343 | 6343 | // Used on logon for example |
@@ -6443,7 +6443,7 @@ discard block |
||
6443 | 6443 | $sql = "SELECT rowid, property, lang , value"; |
6444 | 6444 | $sql .= " FROM " . $this->db->prefix() . "object_lang"; |
6445 | 6445 | $sql .= " WHERE type_object = '" . $this->db->escape($element) . "'"; |
6446 | - $sql .= " AND fk_object = " . ((int)$this->id); |
|
6446 | + $sql .= " AND fk_object = " . ((int) $this->id); |
|
6447 | 6447 | |
6448 | 6448 | //dol_syslog(get_only_class($this)."::fetch_optionals get extrafields data for ".$this->table_element, LOG_DEBUG); // Too verbose |
6449 | 6449 | $resql = $this->db->query($sql); |
@@ -6513,7 +6513,7 @@ discard block |
||
6513 | 6513 | |
6514 | 6514 | $enabled = 1; |
6515 | 6515 | if (isset($this->fields[$key]['enabled'])) { |
6516 | - $enabled = (int)dol_eval($this->fields[$key]['enabled'], 1, 1, '1'); |
|
6516 | + $enabled = (int) dol_eval($this->fields[$key]['enabled'], 1, 1, '1'); |
|
6517 | 6517 | } |
6518 | 6518 | /*$perms = 1; |
6519 | 6519 | if (isset($this->fields[$key]['perms'])) |
@@ -6660,7 +6660,7 @@ discard block |
||
6660 | 6660 | foreach ($new_array_languages as $key => $langcodearray) { // $key = 'name', 'town', ... |
6661 | 6661 | foreach ($langcodearray as $langcode => $value) { |
6662 | 6662 | $sql_del = "DELETE FROM " . $this->db->prefix() . "object_lang"; |
6663 | - $sql_del .= " WHERE fk_object = " . ((int)$this->id) . " AND property = '" . $this->db->escape($key) . "' AND type_object = '" . $this->db->escape($table_element) . "'"; |
|
6663 | + $sql_del .= " WHERE fk_object = " . ((int) $this->id) . " AND property = '" . $this->db->escape($key) . "' AND type_object = '" . $this->db->escape($table_element) . "'"; |
|
6664 | 6664 | $sql_del .= " AND lang = '" . $this->db->escape($langcode) . "'"; |
6665 | 6665 | $this->db->query($sql_del); |
6666 | 6666 | |
@@ -6828,7 +6828,7 @@ discard block |
||
6828 | 6828 | if (isset($this->oldcopy->array_options["options_" . $key]) && $this->array_options["options_" . $key] == $this->oldcopy->array_options["options_" . $key]) { // If old value encrypted in database is same than submitted new value, it means we don't change it, so we don't update. |
6829 | 6829 | if ($algo == 'dolcrypt') { // dolibarr reversible encryption |
6830 | 6830 | if (!preg_match('/^dolcrypt:/', $this->array_options["options_" . $key])) { |
6831 | - $new_array_options["options_" . $key] = dolEncrypt($this->array_options["options_" . $key]); // warning, must be called when on the master |
|
6831 | + $new_array_options["options_" . $key] = dolEncrypt($this->array_options["options_" . $key]); // warning, must be called when on the master |
|
6832 | 6832 | } else { |
6833 | 6833 | $new_array_options["options_" . $key] = $this->array_options["options_" . $key]; // Value is kept |
6834 | 6834 | } |
@@ -6848,7 +6848,7 @@ discard block |
||
6848 | 6848 | } |
6849 | 6849 | } else { |
6850 | 6850 | if ($algo == 'dolcrypt' && !preg_match('/^dolcrypt:/', $this->array_options["options_" . $key])) { // dolibarr reversible encryption |
6851 | - $new_array_options["options_" . $key] = dolEncrypt($this->array_options["options_" . $key]); // warning, must be called when on the master |
|
6851 | + $new_array_options["options_" . $key] = dolEncrypt($this->array_options["options_" . $key]); // warning, must be called when on the master |
|
6852 | 6852 | } else { |
6853 | 6853 | $new_array_options["options_" . $key] = $this->array_options["options_" . $key]; // Value is kept |
6854 | 6854 | } |
@@ -6948,7 +6948,7 @@ discard block |
||
6948 | 6948 | $table_element = 'categories'; // For compatibility |
6949 | 6949 | } |
6950 | 6950 | |
6951 | - $sql = "SELECT COUNT(rowid) as nb FROM " . $this->db->prefix() . $table_element . "_extrafields WHERE fk_object = " . ((int)$this->id); |
|
6951 | + $sql = "SELECT COUNT(rowid) as nb FROM " . $this->db->prefix() . $table_element . "_extrafields WHERE fk_object = " . ((int) $this->id); |
|
6952 | 6952 | $resql = $this->db->query($sql); |
6953 | 6953 | if ($resql) { |
6954 | 6954 | $tmpobj = $this->db->fetch_object($resql); |
@@ -6964,7 +6964,7 @@ discard block |
||
6964 | 6964 | } else { |
6965 | 6965 | $sql = "UPDATE " . $this->db->prefix() . $this->table_element . "_extrafields SET " . $key . " = '" . $this->db->escape($new_array_options["options_" . $key]) . "'"; |
6966 | 6966 | } |
6967 | - $sql .= " WHERE fk_object = " . ((int)$this->id); |
|
6967 | + $sql .= " WHERE fk_object = " . ((int) $this->id); |
|
6968 | 6968 | |
6969 | 6969 | $resql = $this->db->query($sql); |
6970 | 6970 | if (!$resql) { |
@@ -7133,7 +7133,7 @@ discard block |
||
7133 | 7133 | // If old value encrypted in database is same than submitted new value, it means we don't change it, so we don't update. |
7134 | 7134 | if ($algo == 'dolcrypt') { // dolibarr reversible encryption |
7135 | 7135 | if (!preg_match('/^dolcrypt:/', $this->array_options[$key])) { |
7136 | - $new_array_options[$key] = dolEncrypt($this->array_options[$key]); // warning, must be called when on the master |
|
7136 | + $new_array_options[$key] = dolEncrypt($this->array_options[$key]); // warning, must be called when on the master |
|
7137 | 7137 | } else { |
7138 | 7138 | $new_array_options[$key] = $this->array_options[$key]; // Value is kept |
7139 | 7139 | } |
@@ -7144,7 +7144,7 @@ discard block |
||
7144 | 7144 | // If value has changed |
7145 | 7145 | if ($algo == 'dolcrypt') { // dolibarr reversible encryption |
7146 | 7146 | if (!preg_match('/^dolcrypt:/', $this->array_options[$key])) { |
7147 | - $new_array_options[$key] = dolEncrypt($this->array_options[$key]); // warning, must be called when on the master |
|
7147 | + $new_array_options[$key] = dolEncrypt($this->array_options[$key]); // warning, must be called when on the master |
|
7148 | 7148 | } else { |
7149 | 7149 | $new_array_options[$key] = $this->array_options[$key]; // Value is kept |
7150 | 7150 | } |
@@ -7156,7 +7156,7 @@ discard block |
||
7156 | 7156 | //var_dump('jjj'.$algo.' '.$this->oldcopy->array_options[$key].' -> '.$this->array_options[$key]); |
7157 | 7157 | // If this->oldcopy is not defined, we can't know if we change attribute or not, so we must keep value |
7158 | 7158 | if ($algo == 'dolcrypt' && !preg_match('/^dolcrypt:/', $this->array_options[$key])) { // dolibarr reversible encryption |
7159 | - $new_array_options[$key] = dolEncrypt($this->array_options[$key]); // warning, must be called when on the master |
|
7159 | + $new_array_options[$key] = dolEncrypt($this->array_options[$key]); // warning, must be called when on the master |
|
7160 | 7160 | } else { |
7161 | 7161 | $new_array_options[$key] = $this->array_options[$key]; // Value is kept |
7162 | 7162 | } |
@@ -7232,7 +7232,7 @@ discard block |
||
7232 | 7232 | |
7233 | 7233 | dol_syslog(get_only_class($this) . "::insertExtraFields delete then insert", LOG_DEBUG); |
7234 | 7234 | |
7235 | - $sql_del = "DELETE FROM " . $this->db->prefix() . $table_element . "_extrafields WHERE fk_object = " . ((int)$this->id); |
|
7235 | + $sql_del = "DELETE FROM " . $this->db->prefix() . $table_element . "_extrafields WHERE fk_object = " . ((int) $this->id); |
|
7236 | 7236 | $this->db->query($sql_del); |
7237 | 7237 | |
7238 | 7238 | $sql = "INSERT INTO " . $this->db->prefix() . $table_element . "_extrafields (fk_object"; |
@@ -7703,7 +7703,7 @@ discard block |
||
7703 | 7703 | // Test on 'enabled' ('enabled' is different than 'list' = 'visibility') |
7704 | 7704 | $enabled = 1; |
7705 | 7705 | if ($enabled && isset($extrafields->attributes[$this->table_element]['enabled'][$key])) { |
7706 | - $enabled = (int)dol_eval($extrafields->attributes[$this->table_element]['enabled'][$key], 1, 1, '2'); |
|
7706 | + $enabled = (int) dol_eval($extrafields->attributes[$this->table_element]['enabled'][$key], 1, 1, '2'); |
|
7707 | 7707 | } |
7708 | 7708 | if (empty($enabled)) { |
7709 | 7709 | continue; |
@@ -7711,12 +7711,12 @@ discard block |
||
7711 | 7711 | |
7712 | 7712 | $visibility = 1; |
7713 | 7713 | if (isset($extrafields->attributes[$this->table_element]['list'][$key])) { |
7714 | - $visibility = (int)dol_eval($extrafields->attributes[$this->table_element]['list'][$key], 1, 1, '2'); |
|
7714 | + $visibility = (int) dol_eval($extrafields->attributes[$this->table_element]['list'][$key], 1, 1, '2'); |
|
7715 | 7715 | } |
7716 | 7716 | |
7717 | 7717 | $perms = 1; |
7718 | 7718 | if ($perms && isset($extrafields->attributes[$this->table_element]['perms'][$key])) { |
7719 | - $perms = (int)dol_eval($extrafields->attributes[$this->table_element]['perms'][$key], 1, 1, '2'); |
|
7719 | + $perms = (int) dol_eval($extrafields->attributes[$this->table_element]['perms'][$key], 1, 1, '2'); |
|
7720 | 7720 | } |
7721 | 7721 | |
7722 | 7722 | if (($mode == 'create') && !in_array(abs($visibility), array(1, 3))) { |
@@ -8102,16 +8102,16 @@ discard block |
||
8102 | 8102 | $morecss = 'minwidth100imp'; |
8103 | 8103 | } elseif ($type == 'datetime' || $type == 'link') { // link means an foreign key to another primary id |
8104 | 8104 | $morecss = 'minwidth200imp'; |
8105 | - } elseif (in_array($type, array('int', 'integer', 'price')) || preg_match('/^double(\([0-9],[0-9]\)){0,1}/', (string)$type)) { |
|
8105 | + } elseif (in_array($type, array('int', 'integer', 'price')) || preg_match('/^double(\([0-9],[0-9]\)){0,1}/', (string) $type)) { |
|
8106 | 8106 | $morecss = 'maxwidth75'; |
8107 | 8107 | } elseif ($type == 'url') { |
8108 | 8108 | $morecss = 'minwidth400'; |
8109 | 8109 | } elseif ($type == 'boolean') { |
8110 | 8110 | $morecss = ''; |
8111 | 8111 | } else { |
8112 | - if (is_numeric($size) && round((float)$size) < 12) { |
|
8112 | + if (is_numeric($size) && round((float) $size) < 12) { |
|
8113 | 8113 | $morecss = 'minwidth100'; |
8114 | - } elseif (is_numeric($size) && round((float)$size) <= 48) { |
|
8114 | + } elseif (is_numeric($size) && round((float) $size) <= 48) { |
|
8115 | 8115 | $morecss = 'minwidth200'; |
8116 | 8116 | } else { |
8117 | 8117 | $morecss = 'minwidth400'; |
@@ -8156,11 +8156,11 @@ discard block |
||
8156 | 8156 | $out = '<input type="text" class="flat ' . $morecss . '" name="' . $keyprefix . $key . $keysuffix . '" id="' . $keyprefix . $key . $keysuffix . '"' . ($newsize > 0 ? ' maxlength="' . $newsize . '"' : '') . ' value="' . dol_escape_htmltag($value) . '"' . ($moreparam ? $moreparam : '') . ($autofocusoncreate ? ' autofocus' : '') . '>'; |
8157 | 8157 | } elseif (in_array($type, array('real'))) { |
8158 | 8158 | $out = '<input type="text" class="flat ' . $morecss . '" name="' . $keyprefix . $key . $keysuffix . '" id="' . $keyprefix . $key . $keysuffix . '" value="' . dol_escape_htmltag($value) . '"' . ($moreparam ? $moreparam : '') . ($autofocusoncreate ? ' autofocus' : '') . '>'; |
8159 | - } elseif (preg_match('/varchar/', (string)$type)) { |
|
8159 | + } elseif (preg_match('/varchar/', (string) $type)) { |
|
8160 | 8160 | $out = '<input type="text" class="flat ' . $morecss . '" name="' . $keyprefix . $key . $keysuffix . '" id="' . $keyprefix . $key . $keysuffix . '"' . ($size > 0 ? ' maxlength="' . $size . '"' : '') . ' value="' . dol_escape_htmltag($value) . '"' . ($moreparam ? $moreparam : '') . ($autofocusoncreate ? ' autofocus' : '') . '>'; |
8161 | 8161 | } elseif (in_array($type, array('email', 'mail', 'phone', 'url', 'ip'))) { |
8162 | 8162 | $out = '<input type="text" class="flat ' . $morecss . '" name="' . $keyprefix . $key . $keysuffix . '" id="' . $keyprefix . $key . $keysuffix . '" value="' . dol_escape_htmltag($value) . '" ' . ($moreparam ? $moreparam : '') . ($autofocusoncreate ? ' autofocus' : '') . '>'; |
8163 | - } elseif (preg_match('/^text/', (string)$type)) { |
|
8163 | + } elseif (preg_match('/^text/', (string) $type)) { |
|
8164 | 8164 | if (!preg_match('/search_/', $keyprefix)) { // If keyprefix is search_ or search_options_, we must just use a simple text field |
8165 | 8165 | if (!empty($param['options'])) { |
8166 | 8166 | // If the textarea field has a list of arrayofkeyval into its definition, we suggest a combo with possible values to fill the textarea. |
@@ -8210,14 +8210,14 @@ discard block |
||
8210 | 8210 | $out .= "</script>"; |
8211 | 8211 | } |
8212 | 8212 | $doleditor = new DolEditor($keyprefix . $key . $keysuffix, $value, '', 200, 'dolibarr_notes', 'In', false, false, false, ROWS_5, '90%'); |
8213 | - $out .= (string)$doleditor->Create(1, '', true, '', '', '', $morecss); |
|
8213 | + $out .= (string) $doleditor->Create(1, '', true, '', '', '', $morecss); |
|
8214 | 8214 | } else { |
8215 | 8215 | $out = '<input type="text" class="flat ' . $morecss . ' maxwidthonsmartphone" name="' . $keyprefix . $key . $keysuffix . '" id="' . $keyprefix . $key . $keysuffix . '" value="' . dol_escape_htmltag($value) . '" ' . ($moreparam ? $moreparam : '') . '>'; |
8216 | 8216 | } |
8217 | - } elseif (preg_match('/^html/', (string)$type)) { |
|
8217 | + } elseif (preg_match('/^html/', (string) $type)) { |
|
8218 | 8218 | if (!preg_match('/search_/', $keyprefix)) { // If keyprefix is search_ or search_options_, we must just use a simple text field |
8219 | 8219 | $doleditor = new DolEditor($keyprefix . $key . $keysuffix, $value, '', 200, 'dolibarr_notes', 'In', false, false, isModEnabled('fckeditor') && getDolGlobalInt('FCKEDITOR_ENABLE_SOCIETE'), ROWS_5, '90%'); |
8220 | - $out = (string)$doleditor->Create(1, '', true, '', '', $moreparam, $morecss); |
|
8220 | + $out = (string) $doleditor->Create(1, '', true, '', '', $moreparam, $morecss); |
|
8221 | 8221 | } else { |
8222 | 8222 | $out = '<input type="text" class="flat ' . $morecss . ' maxwidthonsmartphone" name="' . $keyprefix . $key . $keysuffix . '" id="' . $keyprefix . $key . $keysuffix . '" value="' . dol_escape_htmltag($value) . '" ' . ($moreparam ? $moreparam : '') . '>'; |
8223 | 8223 | } |
@@ -8234,7 +8234,7 @@ discard block |
||
8234 | 8234 | $value = price($value); |
8235 | 8235 | } |
8236 | 8236 | $out = '<input type="text" class="flat ' . $morecss . ' maxwidthonsmartphone" name="' . $keyprefix . $key . $keysuffix . '" id="' . $keyprefix . $key . $keysuffix . '" value="' . $value . '" ' . ($moreparam ? $moreparam : '') . '> ' . $langs->getCurrencySymbol($conf->currency); |
8237 | - } elseif (preg_match('/^double(\([0-9],[0-9]\)){0,1}/', (string)$type)) { |
|
8237 | + } elseif (preg_match('/^double(\([0-9],[0-9]\)){0,1}/', (string) $type)) { |
|
8238 | 8238 | if (!empty($value)) { // $value in memory is a php numeric, we format it into user number format. |
8239 | 8239 | $value = price($value); |
8240 | 8240 | } |
@@ -8249,7 +8249,7 @@ discard block |
||
8249 | 8249 | $tmpselect = ''; |
8250 | 8250 | $nbchoice = 0; |
8251 | 8251 | foreach ($param['options'] as $keyb => $valb) { |
8252 | - if ((string)$keyb == '') { |
|
8252 | + if ((string) $keyb == '') { |
|
8253 | 8253 | continue; |
8254 | 8254 | } |
8255 | 8255 | if (strpos($valb, "|") !== false) { |
@@ -8257,7 +8257,7 @@ discard block |
||
8257 | 8257 | } |
8258 | 8258 | $nbchoice++; |
8259 | 8259 | $tmpselect .= '<option value="' . $keyb . '"'; |
8260 | - $tmpselect .= (((string)$value == (string)$keyb) ? ' selected' : ''); |
|
8260 | + $tmpselect .= (((string) $value == (string) $keyb) ? ' selected' : ''); |
|
8261 | 8261 | if (!empty($parent)) { |
8262 | 8262 | $isDependList = 1; |
8263 | 8263 | } |
@@ -8353,7 +8353,7 @@ discard block |
||
8353 | 8353 | |
8354 | 8354 | // current object id can be use into filter |
8355 | 8355 | if (strpos($InfoFieldList[4], '$ID$') !== false && !empty($objectid)) { |
8356 | - $InfoFieldList[4] = str_replace('$ID$', (string)$objectid, $InfoFieldList[4]); |
|
8356 | + $InfoFieldList[4] = str_replace('$ID$', (string) $objectid, $InfoFieldList[4]); |
|
8357 | 8357 | } else { |
8358 | 8358 | $InfoFieldList[4] = str_replace('$ID$', '0', $InfoFieldList[4]); |
8359 | 8359 | } |
@@ -8372,7 +8372,7 @@ discard block |
||
8372 | 8372 | } |
8373 | 8373 | // Some tables may have field, some other not. For the moment we disable it. |
8374 | 8374 | if (in_array($InfoFieldList[0], array('tablewithentity'))) { |
8375 | - $sqlwhere .= " AND entity = " . ((int)$conf->entity); |
|
8375 | + $sqlwhere .= " AND entity = " . ((int) $conf->entity); |
|
8376 | 8376 | } |
8377 | 8377 | $sql .= $sqlwhere; |
8378 | 8378 | //print $sql; |
@@ -8533,7 +8533,7 @@ discard block |
||
8533 | 8533 | |
8534 | 8534 | // current object id can be use into filter |
8535 | 8535 | if (strpos($InfoFieldList[4], '$ID$') !== false && !empty($objectid)) { |
8536 | - $InfoFieldList[4] = str_replace('$ID$', (string)$objectid, $InfoFieldList[4]); |
|
8536 | + $InfoFieldList[4] = str_replace('$ID$', (string) $objectid, $InfoFieldList[4]); |
|
8537 | 8537 | } else { |
8538 | 8538 | $InfoFieldList[4] = str_replace('$ID$', '0', $InfoFieldList[4]); |
8539 | 8539 | } |
@@ -8550,7 +8550,7 @@ discard block |
||
8550 | 8550 | } |
8551 | 8551 | // Some tables may have field, some other not. For the moment we disable it. |
8552 | 8552 | if (in_array($InfoFieldList[0], array('tablewithentity'))) { |
8553 | - $sqlwhere .= " AND entity = " . ((int)$conf->entity); |
|
8553 | + $sqlwhere .= " AND entity = " . ((int) $conf->entity); |
|
8554 | 8554 | } |
8555 | 8555 | // $sql.=preg_replace('/^ AND /','',$sqlwhere); |
8556 | 8556 | // print $sql; |
@@ -9255,7 +9255,7 @@ discard block |
||
9255 | 9255 | // If field is an implicit foreign key field (so type = 'integer:...') |
9256 | 9256 | if (isset($key_fields['type']) && preg_match('/^integer:/i', $key_fields['type']) && empty($values[$key])) { |
9257 | 9257 | if (isset($key_fields['default'])) { |
9258 | - $values[$key] = ((int)$key_fields['default']); |
|
9258 | + $values[$key] = ((int) $key_fields['default']); |
|
9259 | 9259 | } else { |
9260 | 9260 | $values[$key] = 'null'; |
9261 | 9261 | } |
@@ -9274,7 +9274,7 @@ discard block |
||
9274 | 9274 | if (!$error) { |
9275 | 9275 | $sql = "INSERT INTO " . $this->db->prefix() . $this->table_element; |
9276 | 9276 | $sql .= " (" . implode(", ", $keys) . ')'; |
9277 | - $sql .= " VALUES (" . implode(", ", $values) . ")"; // $values can contains 'abc' or 123 |
|
9277 | + $sql .= " VALUES (" . implode(", ", $values) . ")"; // $values can contains 'abc' or 123 |
|
9278 | 9278 | |
9279 | 9279 | $res = $this->db->query($sql); |
9280 | 9280 | if (!$res) { |
@@ -9295,7 +9295,7 @@ discard block |
||
9295 | 9295 | if (!$error) { |
9296 | 9296 | // @phan-suppress-next-line PhanTypePossiblyInvalidDimOffset |
9297 | 9297 | if (array_key_exists('ref', $this->fields) && array_key_exists('notnull', $this->fields['ref']) && $this->fields['ref']['notnull'] > 0 && array_key_exists('default', $this->fields['ref']) && $this->fields['ref']['default'] == '(PROV)') { |
9298 | - $sql = "UPDATE " . $this->db->prefix() . $this->table_element . " SET ref = '(PROV" . ((int)$this->id) . ")' WHERE (ref = '(PROV)' OR ref = '') AND rowid = " . ((int)$this->id); |
|
9298 | + $sql = "UPDATE " . $this->db->prefix() . $this->table_element . " SET ref = '(PROV" . ((int) $this->id) . ")' WHERE (ref = '(PROV)' OR ref = '') AND rowid = " . ((int) $this->id); |
|
9299 | 9299 | $resqlupdate = $this->db->query($sql); |
9300 | 9300 | |
9301 | 9301 | if ($resqlupdate === false) { |
@@ -9324,7 +9324,7 @@ discard block |
||
9324 | 9324 | // Test and convert into object this->lines[$i]. When coming from REST API, we may still have an array |
9325 | 9325 | //if (! is_object($line)) $line=json_decode(json_encode($line), false); // convert recursively array into object. |
9326 | 9326 | if (!is_object($line)) { |
9327 | - $line = (object)$line; |
|
9327 | + $line = (object) $line; |
|
9328 | 9328 | } |
9329 | 9329 | |
9330 | 9330 | $result = 0; |
@@ -9392,23 +9392,23 @@ discard block |
||
9392 | 9392 | $queryarray[$field] = 0; |
9393 | 9393 | } |
9394 | 9394 | } else { |
9395 | - $queryarray[$field] = (int)$this->{$field}; // If '0', it may be set to null later if $info['notnull'] == -1 |
|
9395 | + $queryarray[$field] = (int) $this->{$field}; // If '0', it may be set to null later if $info['notnull'] == -1 |
|
9396 | 9396 | } |
9397 | 9397 | } else { |
9398 | 9398 | $queryarray[$field] = null; |
9399 | 9399 | } |
9400 | 9400 | } elseif ($this->isInt($info) || $this->isFloat($info)) { |
9401 | 9401 | if ($field == 'entity' && is_null($this->{$field})) { |
9402 | - $queryarray[$field] = ((int)$conf->entity); |
|
9402 | + $queryarray[$field] = ((int) $conf->entity); |
|
9403 | 9403 | } else { |
9404 | 9404 | // $this->{$field} may be null, '', 0, '0', 123, '123' |
9405 | - if ((isset($this->{$field}) && ((string)$this->{$field}) != '') || !empty($info['notnull'])) { |
|
9405 | + if ((isset($this->{$field}) && ((string) $this->{$field}) != '') || !empty($info['notnull'])) { |
|
9406 | 9406 | if (!isset($this->{$field})) { |
9407 | 9407 | $queryarray[$field] = 0; |
9408 | 9408 | } elseif ($this->isInt($info)) { |
9409 | - $queryarray[$field] = (int)$this->{$field}; // If '0', it may be set to null later if $info['notnull'] == -1 |
|
9409 | + $queryarray[$field] = (int) $this->{$field}; // If '0', it may be set to null later if $info['notnull'] == -1 |
|
9410 | 9410 | } elseif ($this->isFloat($info)) { |
9411 | - $queryarray[$field] = (float)$this->{$field}; // If '0', it may be set to null later if $info['notnull'] == -1 |
|
9411 | + $queryarray[$field] = (float) $this->{$field}; // If '0', it may be set to null later if $info['notnull'] == -1 |
|
9412 | 9412 | } |
9413 | 9413 | } else { |
9414 | 9414 | $queryarray[$field] = null; |
@@ -9443,9 +9443,9 @@ discard block |
||
9443 | 9443 | if (is_null($value)) { |
9444 | 9444 | return 'NULL'; |
9445 | 9445 | } elseif (preg_match('/^(int|double|real|price)/i', $fieldsentry['type'])) { |
9446 | - return price2num((string)$value); |
|
9446 | + return price2num((string) $value); |
|
9447 | 9447 | } elseif (preg_match('/int$/i', $fieldsentry['type'])) { |
9448 | - return (int)$value; |
|
9448 | + return (int) $value; |
|
9449 | 9449 | } elseif ($fieldsentry['type'] == 'boolean') { |
9450 | 9450 | if ($value) { |
9451 | 9451 | return 'true'; |
@@ -9477,7 +9477,7 @@ discard block |
||
9477 | 9477 | |
9478 | 9478 | $sql = "SELECT " . $objectline->getFieldList('l'); |
9479 | 9479 | $sql .= " FROM " . $this->db->prefix() . $objectline->table_element . " as l"; |
9480 | - $sql .= " WHERE l.fk_" . $this->db->escape($this->element) . " = " . ((int)$this->id); |
|
9480 | + $sql .= " WHERE l.fk_" . $this->db->escape($this->element) . " = " . ((int) $this->id); |
|
9481 | 9481 | if ($morewhere) { |
9482 | 9482 | $sql .= $morewhere; |
9483 | 9483 | } |
@@ -9586,7 +9586,7 @@ discard block |
||
9586 | 9586 | }*/ |
9587 | 9587 | } |
9588 | 9588 | |
9589 | - $sql = 'UPDATE ' . $this->db->prefix() . $this->table_element . ' SET ' . implode(', ', $tmp) . ' WHERE rowid=' . ((int)$this->id); |
|
9589 | + $sql = 'UPDATE ' . $this->db->prefix() . $this->table_element . ' SET ' . implode(', ', $tmp) . ' WHERE rowid=' . ((int) $this->id); |
|
9590 | 9590 | |
9591 | 9591 | $this->db->begin(); |
9592 | 9592 | |
@@ -9600,7 +9600,7 @@ discard block |
||
9600 | 9600 | |
9601 | 9601 | // Update extrafield |
9602 | 9602 | if (!$error) { |
9603 | - $result = $this->insertExtraFields(); // This delete and reinsert extrafields |
|
9603 | + $result = $this->insertExtraFields(); // This delete and reinsert extrafields |
|
9604 | 9604 | if ($result < 0) { |
9605 | 9605 | $error++; |
9606 | 9606 | } |
@@ -9644,7 +9644,7 @@ discard block |
||
9644 | 9644 | |
9645 | 9645 | if ($forcechilddeletion) { // Force also delete of childtables that should lock deletion in standard case when option force is off |
9646 | 9646 | foreach ($this->childtables as $table) { |
9647 | - $sql = "DELETE FROM " . $this->db->prefix() . $table . " WHERE " . $this->fk_element . " = " . ((int)$this->id); |
|
9647 | + $sql = "DELETE FROM " . $this->db->prefix() . $table . " WHERE " . $this->fk_element . " = " . ((int) $this->id); |
|
9648 | 9648 | $resql = $this->db->query($sql); |
9649 | 9649 | if (!$resql) { |
9650 | 9650 | $this->error = $this->db->lasterror(); |
@@ -9698,7 +9698,7 @@ discard block |
||
9698 | 9698 | } |
9699 | 9699 | } else { |
9700 | 9700 | // Delete record in child table |
9701 | - $sql = "DELETE FROM " . $this->db->prefix() . $tabletodelete . " WHERE " . $this->fk_element . " = " . ((int)$this->id); |
|
9701 | + $sql = "DELETE FROM " . $this->db->prefix() . $tabletodelete . " WHERE " . $this->fk_element . " = " . ((int) $this->id); |
|
9702 | 9702 | |
9703 | 9703 | $resql = $this->db->query($sql); |
9704 | 9704 | if (!$resql) { |
@@ -9744,7 +9744,7 @@ discard block |
||
9744 | 9744 | } |
9745 | 9745 | |
9746 | 9746 | if (!$error) { |
9747 | - $sql = 'DELETE FROM ' . $this->db->prefix() . $this->table_element . ' WHERE rowid=' . ((int)$this->id); |
|
9747 | + $sql = 'DELETE FROM ' . $this->db->prefix() . $this->table_element . ' WHERE rowid=' . ((int) $this->id); |
|
9748 | 9748 | |
9749 | 9749 | $resql = $this->db->query($sql); |
9750 | 9750 | if (!$resql) { |
@@ -9785,7 +9785,7 @@ discard block |
||
9785 | 9785 | return -1; |
9786 | 9786 | } |
9787 | 9787 | |
9788 | - $arraytoscan = $this->childtables; // array('tablename'=>array('fk_element'=>'parentfield'), ...) or array('tablename'=>array('parent'=>table_parent, 'parentkey'=>'nameoffieldforparentfkkey'), ...) |
|
9788 | + $arraytoscan = $this->childtables; // array('tablename'=>array('fk_element'=>'parentfield'), ...) or array('tablename'=>array('parent'=>table_parent, 'parentkey'=>'nameoffieldforparentfkkey'), ...) |
|
9789 | 9789 | // For backward compatibility, we check if array is old format array('tablename1', 'tablename2', ...) |
9790 | 9790 | $tmparray = array_keys($this->childtables); |
9791 | 9791 | if (is_numeric($tmparray[0])) { |
@@ -9803,9 +9803,9 @@ discard block |
||
9803 | 9803 | $sql .= ", " . $this->db->prefix() . $element['parent'] . " as p"; |
9804 | 9804 | } |
9805 | 9805 | if (!empty($element['fk_element'])) { |
9806 | - $sql .= " WHERE c." . $element['fk_element'] . " = " . ((int)$id); |
|
9806 | + $sql .= " WHERE c." . $element['fk_element'] . " = " . ((int) $id); |
|
9807 | 9807 | } else { |
9808 | - $sql .= " WHERE c." . $this->fk_element . " = " . ((int)$id); |
|
9808 | + $sql .= " WHERE c." . $this->fk_element . " = " . ((int) $id); |
|
9809 | 9809 | } |
9810 | 9810 | if (!empty($element['parent']) && !empty($element['parentkey'])) { |
9811 | 9811 | $sql .= " AND c." . $element['parentkey'] . " = p.rowid"; |
@@ -9815,9 +9815,9 @@ discard block |
||
9815 | 9815 | } |
9816 | 9816 | if (!empty($entity)) { |
9817 | 9817 | if (!empty($element['parent']) && !empty($element['parentkey'])) { |
9818 | - $sql .= " AND p.entity = " . ((int)$entity); |
|
9818 | + $sql .= " AND p.entity = " . ((int) $entity); |
|
9819 | 9819 | } else { |
9820 | - $sql .= " AND c.entity = " . ((int)$entity); |
|
9820 | + $sql .= " AND c.entity = " . ((int) $entity); |
|
9821 | 9821 | } |
9822 | 9822 | } |
9823 | 9823 | |
@@ -9872,7 +9872,7 @@ discard block |
||
9872 | 9872 | $this->db->begin(); |
9873 | 9873 | |
9874 | 9874 | $sql = "SELECT rowid FROM " . $this->db->prefix() . $this->table_element; |
9875 | - $sql .= " WHERE " . $this->db->sanitize($parentField) . " = " . (int)$parentId; |
|
9875 | + $sql .= " WHERE " . $this->db->sanitize($parentField) . " = " . (int) $parentId; |
|
9876 | 9876 | |
9877 | 9877 | // Manage filter |
9878 | 9878 | $errormessage = ''; |
@@ -9889,7 +9889,7 @@ discard block |
||
9889 | 9889 | $error++; |
9890 | 9890 | } else { |
9891 | 9891 | while ($obj = $this->db->fetch_object($resql)) { |
9892 | - $result = $this->fetch($obj->rowid); // @phpstan-ignore-line |
|
9892 | + $result = $this->fetch($obj->rowid); // @phpstan-ignore-line |
|
9893 | 9893 | if ($result < 0) { |
9894 | 9894 | $error++; |
9895 | 9895 | $this->errors[] = $this->error; |
@@ -9966,7 +9966,7 @@ discard block |
||
9966 | 9966 | // Delete ecm_files_extrafields with mode 0 (using name) |
9967 | 9967 | $sql = "DELETE FROM " . $this->db->prefix() . "ecm_files_extrafields WHERE fk_object IN ("; |
9968 | 9968 | $sql .= " SELECT rowid FROM " . $this->db->prefix() . "ecm_files WHERE filename LIKE '" . $this->db->escape($this->ref) . "%'"; |
9969 | - $sql .= " AND filepath = '" . $this->db->escape($element) . "/" . $this->db->escape($this->ref) . "' AND entity = " . ((int)$conf->entity); // No need of getEntity here |
|
9969 | + $sql .= " AND filepath = '" . $this->db->escape($element) . "/" . $this->db->escape($this->ref) . "' AND entity = " . ((int) $conf->entity); // No need of getEntity here |
|
9970 | 9970 | $sql .= ")"; |
9971 | 9971 | |
9972 | 9972 | if (!$this->db->query($sql)) { |
@@ -9978,7 +9978,7 @@ discard block |
||
9978 | 9978 | // Delete ecm_files with mode 0 (using name) |
9979 | 9979 | $sql = "DELETE FROM " . $this->db->prefix() . "ecm_files"; |
9980 | 9980 | $sql .= " WHERE filename LIKE '" . $this->db->escape($this->ref) . "%'"; |
9981 | - $sql .= " AND filepath = '" . $this->db->escape($element) . "/" . $this->db->escape($this->ref) . "' AND entity = " . ((int)$conf->entity); // No need of getEntity here |
|
9981 | + $sql .= " AND filepath = '" . $this->db->escape($element) . "/" . $this->db->escape($this->ref) . "' AND entity = " . ((int) $conf->entity); // No need of getEntity here |
|
9982 | 9982 | |
9983 | 9983 | if (!$this->db->query($sql)) { |
9984 | 9984 | $this->error = $this->db->lasterror(); |
@@ -9990,7 +9990,7 @@ discard block |
||
9990 | 9990 | // Delete in database with mode 1 |
9991 | 9991 | if ($mode == 1) { |
9992 | 9992 | $sql = 'DELETE FROM ' . $this->db->prefix() . "ecm_files_extrafields"; |
9993 | - $sql .= " WHERE fk_object IN (SELECT rowid FROM " . $this->db->prefix() . "ecm_files WHERE src_object_type = '" . $this->db->escape($this->table_element . (empty($this->module) ? "" : "@" . $this->module)) . "' AND src_object_id = " . ((int)$this->id) . ")"; |
|
9993 | + $sql .= " WHERE fk_object IN (SELECT rowid FROM " . $this->db->prefix() . "ecm_files WHERE src_object_type = '" . $this->db->escape($this->table_element . (empty($this->module) ? "" : "@" . $this->module)) . "' AND src_object_id = " . ((int) $this->id) . ")"; |
|
9994 | 9994 | $resql = $this->db->query($sql); |
9995 | 9995 | if (!$resql) { |
9996 | 9996 | $this->error = $this->db->lasterror(); |
@@ -9999,7 +9999,7 @@ discard block |
||
9999 | 9999 | } |
10000 | 10000 | |
10001 | 10001 | $sql = 'DELETE FROM ' . $this->db->prefix() . "ecm_files"; |
10002 | - $sql .= " WHERE src_object_type = '" . $this->db->escape($this->table_element . (empty($this->module) ? "" : "@" . $this->module)) . "' AND src_object_id = " . ((int)$this->id); |
|
10002 | + $sql .= " WHERE src_object_type = '" . $this->db->escape($this->table_element . (empty($this->module) ? "" : "@" . $this->module)) . "' AND src_object_id = " . ((int) $this->id); |
|
10003 | 10003 | $resql = $this->db->query($sql); |
10004 | 10004 | if (!$resql) { |
10005 | 10005 | $this->error = $this->db->lasterror(); |
@@ -10063,18 +10063,18 @@ discard block |
||
10063 | 10063 | $sql = "DELETE FROM " . $this->db->prefix() . "element_element"; |
10064 | 10064 | $sql .= " WHERE"; |
10065 | 10065 | if ($rowid > 0) { |
10066 | - $sql .= " rowid = " . ((int)$rowid); |
|
10066 | + $sql .= " rowid = " . ((int) $rowid); |
|
10067 | 10067 | } else { |
10068 | 10068 | if ($deletesource) { |
10069 | - $sql .= " fk_source = " . ((int)$sourceid) . " AND sourcetype = '" . $this->db->escape($sourcetype) . "'"; |
|
10070 | - $sql .= " AND fk_target = " . ((int)$this->id) . " AND targettype = '" . $this->db->escape($this->element) . "'"; |
|
10069 | + $sql .= " fk_source = " . ((int) $sourceid) . " AND sourcetype = '" . $this->db->escape($sourcetype) . "'"; |
|
10070 | + $sql .= " AND fk_target = " . ((int) $this->id) . " AND targettype = '" . $this->db->escape($this->element) . "'"; |
|
10071 | 10071 | } elseif ($deletetarget) { |
10072 | - $sql .= " fk_target = " . ((int)$targetid) . " AND targettype = '" . $this->db->escape($targettype) . "'"; |
|
10073 | - $sql .= " AND fk_source = " . ((int)$this->id) . " AND sourcetype = '" . $this->db->escape($this->element) . "'"; |
|
10072 | + $sql .= " fk_target = " . ((int) $targetid) . " AND targettype = '" . $this->db->escape($targettype) . "'"; |
|
10073 | + $sql .= " AND fk_source = " . ((int) $this->id) . " AND sourcetype = '" . $this->db->escape($this->element) . "'"; |
|
10074 | 10074 | } else { |
10075 | - $sql .= " (fk_source = " . ((int)$this->id) . " AND sourcetype = '" . $this->db->escape($this->element) . "')"; |
|
10075 | + $sql .= " (fk_source = " . ((int) $this->id) . " AND sourcetype = '" . $this->db->escape($this->element) . "')"; |
|
10076 | 10076 | $sql .= " OR"; |
10077 | - $sql .= " (fk_target = " . ((int)$this->id) . " AND targettype = '" . $this->db->escape($this->element) . "')"; |
|
10077 | + $sql .= " (fk_target = " . ((int) $this->id) . " AND targettype = '" . $this->db->escape($this->element) . "')"; |
|
10078 | 10078 | } |
10079 | 10079 | } |
10080 | 10080 | |
@@ -10118,7 +10118,7 @@ discard block |
||
10118 | 10118 | |
10119 | 10119 | dol_syslog(get_only_class($this) . "::deleteExtraFields delete", LOG_DEBUG); |
10120 | 10120 | |
10121 | - $sql_del = "DELETE FROM " . $this->db->prefix() . $table_element . "_extrafields WHERE fk_object = " . ((int)$this->id); |
|
10121 | + $sql_del = "DELETE FROM " . $this->db->prefix() . $table_element . "_extrafields WHERE fk_object = " . ((int) $this->id); |
|
10122 | 10122 | |
10123 | 10123 | $resql = $this->db->query($sql_del); |
10124 | 10124 | if (!$resql) { |
@@ -10157,7 +10157,7 @@ discard block |
||
10157 | 10157 | |
10158 | 10158 | if (empty($error)) { |
10159 | 10159 | $sql = "DELETE FROM " . $this->db->prefix() . $this->table_element_line; |
10160 | - $sql .= " WHERE rowid = " . ((int)$idline); |
|
10160 | + $sql .= " WHERE rowid = " . ((int) $idline); |
|
10161 | 10161 | |
10162 | 10162 | $resql = $this->db->query($sql); |
10163 | 10163 | if (!$resql) { |
@@ -10211,8 +10211,8 @@ discard block |
||
10211 | 10211 | } |
10212 | 10212 | |
10213 | 10213 | $sql = "UPDATE " . $this->db->prefix() . $this->table_element; |
10214 | - $sql .= " SET " . $statusfield . " = " . ((int)$status); |
|
10215 | - $sql .= " WHERE rowid = " . ((int)$this->id); |
|
10214 | + $sql .= " SET " . $statusfield . " = " . ((int) $status); |
|
10215 | + $sql .= " WHERE rowid = " . ((int) $this->id); |
|
10216 | 10216 | |
10217 | 10217 | if ($this->db->query($sql)) { |
10218 | 10218 | if (!$error) { |
@@ -10263,8 +10263,8 @@ discard block |
||
10263 | 10263 | $statusfield = 'signed_status'; |
10264 | 10264 | |
10265 | 10265 | $sql = "UPDATE " . $this->db->prefix() . $this->table_element; |
10266 | - $sql .= " SET " . $statusfield . " = " . ((int)$status); |
|
10267 | - $sql .= " WHERE rowid = " . ((int)$this->id); |
|
10266 | + $sql .= " SET " . $statusfield . " = " . ((int) $status); |
|
10267 | + $sql .= " WHERE rowid = " . ((int) $this->id); |
|
10268 | 10268 | |
10269 | 10269 | if ($this->db->query($sql)) { |
10270 | 10270 | if (!$error) { |
@@ -10321,7 +10321,7 @@ discard block |
||
10321 | 10321 | ); |
10322 | 10322 | foreach ($fields as $key => $value) { |
10323 | 10323 | if (array_key_exists($key, $this->fields)) { |
10324 | - $this->{$key} = $value; // @phpstan-ignore-line |
|
10324 | + $this->{$key} = $value; // @phpstan-ignore-line |
|
10325 | 10325 | } |
10326 | 10326 | } |
10327 | 10327 | |
@@ -10508,7 +10508,7 @@ discard block |
||
10508 | 10508 | |
10509 | 10509 | $sql = "INSERT INTO " . $this->db->prefix() . "categorie_" . (empty($categorystatic->MAP_CAT_TABLE[$type]) ? $type : $categorystatic->MAP_CAT_TABLE[$type]) . " (fk_categorie, fk_product)"; |
10510 | 10510 | $sql .= " SELECT fk_categorie, $toId FROM " . $this->db->prefix() . "categorie_" . (empty($categorystatic->MAP_CAT_TABLE[$type]) ? $type : $categorystatic->MAP_CAT_TABLE[$type]); |
10511 | - $sql .= " WHERE fk_product = " . ((int)$fromId); |
|
10511 | + $sql .= " WHERE fk_product = " . ((int) $fromId); |
|
10512 | 10512 | |
10513 | 10513 | if (!$this->db->query($sql)) { |
10514 | 10514 | $this->error = $this->db->lasterror(); |
@@ -10769,7 +10769,7 @@ discard block |
||
10769 | 10769 | $setsharekey = false; |
10770 | 10770 | if ($this->element == 'propal' || $this->element == 'proposal') { |
10771 | 10771 | if (getDolGlobalInt("PROPOSAL_ALLOW_ONLINESIGN")) { |
10772 | - $setsharekey = true; // feature to make online signature is not set or set to on (default) |
|
10772 | + $setsharekey = true; // feature to make online signature is not set or set to on (default) |
|
10773 | 10773 | } |
10774 | 10774 | if (getDolGlobalInt("PROPOSAL_ALLOW_EXTERNAL_DOWNLOAD")) { |
10775 | 10775 | $setsharekey = true; |
@@ -10827,7 +10827,7 @@ discard block |
||
10827 | 10827 | $ecmfile->gen_or_uploaded = 'generated'; |
10828 | 10828 | $ecmfile->description = ''; // indexed content |
10829 | 10829 | $ecmfile->keywords = ''; // keyword content |
10830 | - $ecmfile->src_object_type = $this->table_element; // $this->table_name is 'myobject' or 'mymodule_myobject'. |
|
10830 | + $ecmfile->src_object_type = $this->table_element; // $this->table_name is 'myobject' or 'mymodule_myobject'. |
|
10831 | 10831 | $ecmfile->src_object_id = $this->id; |
10832 | 10832 | |
10833 | 10833 | $result = $ecmfile->create($user); |
@@ -10844,7 +10844,7 @@ discard block |
||
10844 | 10844 | |
10845 | 10845 | if ($update_main_doc_field && !empty($this->table_element)) { |
10846 | 10846 | $sql = "UPDATE " . $this->db->prefix() . $this->table_element . " SET last_main_doc = '" . $this->db->escape($ecmfile->filepath . "/" . $ecmfile->filename) . "'"; |
10847 | - $sql .= " WHERE rowid = " . ((int)$this->id); |
|
10847 | + $sql .= " WHERE rowid = " . ((int) $this->id); |
|
10848 | 10848 | |
10849 | 10849 | $resql = $this->db->query($sql); |
10850 | 10850 | if (!$resql) { |