|
@@ -2054,7 +2054,7 @@ abstract class CommonObject
|
|
|
}
|
|
|
if (isset($this->ismultientitymanaged) && !is_numeric($this->ismultientitymanaged)) {
|
|
|
$tmparray = explode('@', $this->ismultientitymanaged);
|
|
|
- $sql .= ' AND te.'.$tmparray[0].' = '.($tmparray[1] == 'societe' ? 's' : 'parenttable').'.rowid'; // If we need to link to this table to limit select to entity
|
|
|
+ $sql .= " AND te.".$tmparray[0]." = ".($tmparray[1] == "societe" ? "s" : "parenttable").".rowid"; // If we need to link to this table to limit select to entity
|
|
|
} elseif ($restrictiononfksoc == 1 && $this->element != 'societe' && !$user->rights->societe->client->voir && !$socid) {
|
|
|
$sql .= ' AND te.fk_soc = s.rowid'; // If we need to link to societe to limit select to socid
|
|
|
}
|
|
@@ -2075,13 +2075,13 @@ abstract class CommonObject
|
|
|
$sql .= ' AND parenttable.entity IN ('.getEntity($tmparray[1]).')';
|
|
|
}
|
|
|
if ($restrictiononfksoc == 1 && $socid && $this->element != 'societe') {
|
|
|
- $sql .= ' AND te.fk_soc = '.$socid;
|
|
|
+ $sql .= ' AND te.fk_soc = '.((int) $socid);
|
|
|
}
|
|
|
if ($restrictiononfksoc == 2 && $socid && $this->element != 'societe') {
|
|
|
- $sql .= ' AND (te.fk_soc = '.$socid.' OR te.fk_soc IS NULL)';
|
|
|
+ $sql .= ' AND (te.fk_soc = '.((int) $socid).' OR te.fk_soc IS NULL)';
|
|
|
}
|
|
|
if ($restrictiononfksoc && $socid && $this->element == 'societe') {
|
|
|
- $sql .= ' AND te.rowid = '.$socid;
|
|
|
+ $sql .= ' AND te.rowid = '.((int) $socid);
|
|
|
}
|
|
|
//print 'socid='.$socid.' restrictiononfksoc='.$restrictiononfksoc.' ismultientitymanaged = '.$this->ismultientitymanaged.' filter = '.$filter.' -> '.$sql."<br>";
|
|
|
|
|
@@ -2124,7 +2124,7 @@ abstract class CommonObject
|
|
|
}
|
|
|
if (isset($this->ismultientitymanaged) && !is_numeric($this->ismultientitymanaged)) {
|
|
|
$tmparray = explode('@', $this->ismultientitymanaged);
|
|
|
- $sql .= ' AND te.'.$tmparray[0].' = '.($tmparray[1] == 'societe' ? 's' : 'parenttable').'.rowid'; // If we need to link to this table to limit select to entity
|
|
|
+ $sql .= " AND te.".$tmparray[0]." = ".($tmparray[1] == "societe" ? "s" : "parenttable").".rowid"; // If we need to link to this table to limit select to entity
|
|
|
} elseif ($restrictiononfksoc == 1 && $this->element != 'societe' && !$user->rights->societe->client->voir && !$socid) {
|
|
|
$sql .= ' AND te.fk_soc = s.rowid'; // If we need to link to societe to limit select to socid
|
|
|
}
|
|
@@ -2145,13 +2145,13 @@ abstract class CommonObject
|
|
|
$sql .= ' AND parenttable.entity IN ('.getEntity($tmparray[1]).')';
|
|
|
}
|
|
|
if ($restrictiononfksoc == 1 && $socid && $this->element != 'societe') {
|
|
|
- $sql .= ' AND te.fk_soc = '.$socid;
|
|
|
+ $sql .= ' AND te.fk_soc = '.((int) $socid);
|
|
|
}
|
|
|
if ($restrictiononfksoc == 2 && $socid && $this->element != 'societe') {
|
|
|
- $sql .= ' AND (te.fk_soc = '.$socid.' OR te.fk_soc IS NULL)';
|
|
|
+ $sql .= ' AND (te.fk_soc = '.((int) $socid).' OR te.fk_soc IS NULL)';
|
|
|
}
|
|
|
if ($restrictiononfksoc && $socid && $this->element == 'societe') {
|
|
|
- $sql .= ' AND te.rowid = '.$socid;
|
|
|
+ $sql .= ' AND te.rowid = '.((int) $socid);
|
|
|
}
|
|
|
//print 'socid='.$socid.' restrictiononfksoc='.$restrictiononfksoc.' ismultientitymanaged = '.$this->ismultientitymanaged.' filter = '.$filter.' -> '.$sql."<br>";
|
|
|
// 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
|
|
@@ -2206,19 +2206,19 @@ abstract class CommonObject
|
|
|
return -1;
|
|
|
}
|
|
|
|
|
|
- $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element;
|
|
|
+ $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element;
|
|
|
if (!empty($this->fields['fk_project'])) { // Common case
|
|
|
if ($projectid) {
|
|
|
- $sql .= ' SET fk_project = '.((int) $projectid);
|
|
|
+ $sql .= " SET fk_project = ".((int) $projectid);
|
|
|
} else {
|
|
|
- $sql .= ' SET fk_project = NULL';
|
|
|
+ $sql .= " SET fk_project = NULL";
|
|
|
}
|
|
|
$sql .= ' WHERE rowid = '.((int) $this->id);
|
|
|
} elseif ($this->table_element == 'actioncomm') { // Special case for actioncomm
|
|
|
if ($projectid) {
|
|
|
- $sql .= ' SET fk_project = '.((int) $projectid);
|
|
|
+ $sql .= " SET fk_project = ".((int) $projectid);
|
|
|
} else {
|
|
|
- $sql .= ' SET fk_project = NULL';
|
|
|
+ $sql .= " SET fk_project = NULL";
|
|
|
}
|
|
|
$sql .= ' WHERE id = '.((int) $this->id);
|
|
|
} else // Special case for old architecture objects
|
|
@@ -2266,8 +2266,8 @@ abstract class CommonObject
|
|
|
$fieldname = 'fk_typepayment';
|
|
|
}
|
|
|
|
|
|
- $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element;
|
|
|
- $sql .= ' SET '.$fieldname.' = '.(($id > 0 || $id == '0') ? $id : 'NULL');
|
|
|
+ $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element;
|
|
|
+ $sql .= " SET ".$fieldname." = ".(($id > 0 || $id == '0') ? ((int) $id) : 'NULL');
|
|
|
$sql .= ' WHERE rowid='.((int) $this->id);
|
|
|
|
|
|
if ($this->db->query($sql)) {
|
|
@@ -2278,7 +2278,7 @@ abstract class CommonObject
|
|
|
}
|
|
|
return 1;
|
|
|
} else {
|
|
|
- dol_syslog(get_class($this).'::setPaymentMethods Error '.$sql.' - '.$this->db->error());
|
|
|
+ dol_syslog(get_class($this).'::setPaymentMethods Error '.$this->db->error());
|
|
|
$this->error = $this->db->error();
|
|
|
return -1;
|
|
|
}
|
|
@@ -2302,7 +2302,7 @@ abstract class CommonObject
|
|
|
$fieldname = 'multicurrency_code';
|
|
|
|
|
|
$sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element;
|
|
|
- $sql .= ' SET '.$fieldname." = '".$this->db->escape($code)."'";
|
|
|
+ $sql .= " SET ".$fieldname." = '".$this->db->escape($code)."'";
|
|
|
$sql .= ' WHERE rowid='.((int) $this->id);
|
|
|
|
|
|
if ($this->db->query($sql)) {
|
|
@@ -2340,7 +2340,7 @@ abstract class CommonObject
|
|
|
$fieldname = 'multicurrency_tx';
|
|
|
|
|
|
$sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element;
|
|
|
- $sql .= ' SET '.$fieldname.' = '.((float) $rate);
|
|
|
+ $sql .= " SET ".$fieldname." = ".((float) $rate);
|
|
|
$sql .= ' WHERE rowid='.((int) $this->id);
|
|
|
|
|
|
if ($this->db->query($sql)) {
|
|
@@ -2548,7 +2548,7 @@ abstract class CommonObject
|
|
|
}
|
|
|
|
|
|
$sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element;
|
|
|
- $sql .= ' SET '.$fieldname.' = '.(($id > 0 || $id == '0') ? $id : 'NULL');
|
|
|
+ $sql .= " SET ".$fieldname." = ".(($id > 0 || $id == '0') ? ((int) $id) : 'NULL');
|
|
|
$sql .= ' WHERE rowid='.((int) $this->id);
|
|
|
|
|
|
if ($this->db->query($sql)) {
|
|
@@ -2590,7 +2590,7 @@ abstract class CommonObject
|
|
|
}
|
|
|
|
|
|
$sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element;
|
|
|
- $sql .= ' SET '.$fieldname.' = '.(($id > 0 || $id == '0') ? $id : 'NULL');
|
|
|
+ $sql .= " SET ".$fieldname." = ".(($id > 0 || $id == '0') ? ((int) $id) : 'NULL');
|
|
|
$sql .= ' WHERE rowid='.((int) $this->id);
|
|
|
|
|
|
if ($this->db->query($sql)) {
|
|
@@ -2625,7 +2625,7 @@ abstract class CommonObject
|
|
|
$fieldname = 'retained_warranty_fk_cond_reglement';
|
|
|
|
|
|
$sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element;
|
|
|
- $sql .= ' SET '.$fieldname.' = '.((int) $id);
|
|
|
+ $sql .= " SET ".$fieldname." = ".((int) $id);
|
|
|
$sql .= ' WHERE rowid='.((int) $this->id);
|
|
|
|
|
|
if ($this->db->query($sql)) {
|
|
@@ -2665,7 +2665,7 @@ abstract class CommonObject
|
|
|
return 1;
|
|
|
} else {
|
|
|
$this->error = $this->db->error();
|
|
|
- dol_syslog(get_class($this).'::setDeliveryAddress Error '.$sql.' - '.$this->error);
|
|
|
+ dol_syslog(get_class($this).'::setDeliveryAddress Error '.$this->error);
|
|
|
return -1;
|
|
|
}
|
|
|
}
|
|
@@ -2884,7 +2884,7 @@ abstract class CommonObject
|
|
|
// Count number of lines to reorder (according to choice $renum)
|
|
|
$nl = 0;
|
|
|
$sql = 'SELECT count(rowid) FROM '.MAIN_DB_PREFIX.$this->table_element_line;
|
|
|
- $sql .= ' WHERE '.$this->fk_element.'='.((int) $this->id);
|
|
|
+ $sql .= " WHERE ".$this->fk_element." = ".((int) $this->id);
|
|
|
if (!$renum) {
|
|
|
$sql .= ' AND rang = 0';
|
|
|
}
|
|
@@ -2906,7 +2906,7 @@ abstract class CommonObject
|
|
|
|
|
|
// We first search all lines that are parent lines (for multilevel details lines)
|
|
|
$sql = 'SELECT rowid FROM '.MAIN_DB_PREFIX.$this->table_element_line;
|
|
|
- $sql .= ' WHERE '.$this->fk_element.' = '.((int) $this->id);
|
|
|
+ $sql .= " WHERE ".$this->fk_element." = ".((int) $this->id);
|
|
|
if ($fk_parent_line) {
|
|
|
$sql .= ' AND fk_parent_line IS NULL';
|
|
|
}
|
|
@@ -2954,7 +2954,7 @@ abstract class CommonObject
|
|
|
$rows = array();
|
|
|
|
|
|
$sql = 'SELECT rowid FROM '.MAIN_DB_PREFIX.$this->table_element_line;
|
|
|
- $sql .= ' WHERE '.$this->fk_element.' = '.((int) $this->id);
|
|
|
+ $sql .= " WHERE ".$this->fk_element." = ".((int) $this->id);
|
|
|
$sql .= ' AND fk_parent_line = '.((int) $id);
|
|
|
$sql .= ' ORDER BY rang ASC';
|
|
|
|
|
@@ -3031,7 +3031,7 @@ abstract class CommonObject
|
|
|
$fieldposition = 'position';
|
|
|
}
|
|
|
|
|
|
- $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element_line.' SET '.$fieldposition.' = '.((int) $rang);
|
|
|
+ $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element_line." SET ".$fieldposition." = ".((int) $rang);
|
|
|
$sql .= ' WHERE rowid = '.((int) $rowid);
|
|
|
|
|
|
dol_syslog(get_class($this)."::updateRangOfLine", LOG_DEBUG);
|
|
@@ -3074,11 +3074,11 @@ abstract class CommonObject
|
|
|
$fieldposition = 'position';
|
|
|
}
|
|
|
|
|
|
- $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element_line.' SET '.$fieldposition.' = '.((int) $rang);
|
|
|
- $sql .= ' WHERE '.$this->fk_element.' = '.((int) $this->id);
|
|
|
+ $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element_line." SET ".$fieldposition." = ".((int) $rang);
|
|
|
+ $sql .= " WHERE ".$this->fk_element." = ".((int) $this->id);
|
|
|
$sql .= ' AND rang = '.((int) ($rang - 1));
|
|
|
if ($this->db->query($sql)) {
|
|
|
- $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element_line.' SET '.$fieldposition.' = '.((int) ($rang - 1));
|
|
|
+ $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element_line." SET ".$fieldposition." = ".((int) ($rang - 1));
|
|
|
$sql .= ' WHERE rowid = '.((int) $rowid);
|
|
|
if (!$this->db->query($sql)) {
|
|
|
dol_print_error($this->db);
|
|
@@ -3105,11 +3105,11 @@ abstract class CommonObject
|
|
|
$fieldposition = 'position';
|
|
|
}
|
|
|
|
|
|
- $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element_line.' SET '.$fieldposition.' = '.((int) $rang);
|
|
|
- $sql .= ' WHERE '.$this->fk_element.' = '.((int) $this->id);
|
|
|
+ $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element_line." SET ".$fieldposition." = ".((int) $rang);
|
|
|
+ $sql .= " WHERE ".$this->fk_element." = ".((int) $this->id);
|
|
|
$sql .= ' AND rang = '.((int) ($rang + 1));
|
|
|
if ($this->db->query($sql)) {
|
|
|
- $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element_line.' SET '.$fieldposition.' = '.((int) ($rang + 1));
|
|
|
+ $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element_line." SET ".$fieldposition." = ".((int) ($rang + 1));
|
|
|
$sql .= ' WHERE rowid = '.((int) $rowid);
|
|
|
if (!$this->db->query($sql)) {
|
|
|
dol_print_error($this->db);
|
|
@@ -3148,7 +3148,7 @@ abstract class CommonObject
|
|
|
public function getIdOfLine($rang)
|
|
|
{
|
|
|
$sql = 'SELECT rowid FROM '.MAIN_DB_PREFIX.$this->table_element_line;
|
|
|
- $sql .= ' WHERE '.$this->fk_element.' = '.((int) $this->id);
|
|
|
+ $sql .= " WHERE ".$this->fk_element." = ".((int) $this->id);
|
|
|
$sql .= ' AND rang = '.((int) $rang);
|
|
|
$resql = $this->db->query($sql);
|
|
|
if ($resql) {
|
|
@@ -3174,8 +3174,8 @@ abstract class CommonObject
|
|
|
|
|
|
// Search the last rang with fk_parent_line
|
|
|
if ($fk_parent_line) {
|
|
|
- $sql = 'SELECT max('.$positionfield.') FROM '.MAIN_DB_PREFIX.$this->table_element_line;
|
|
|
- $sql .= ' WHERE '.$this->fk_element.' = '.((int) $this->id);
|
|
|
+ $sql = "SELECT max(".$positionfield.") FROM ".MAIN_DB_PREFIX.$this->table_element_line;
|
|
|
+ $sql .= " WHERE ".$this->fk_element." = ".((int) $this->id);
|
|
|
$sql .= ' AND fk_parent_line = '.((int) $fk_parent_line);
|
|
|
|
|
|
dol_syslog(get_class($this)."::line_max", LOG_DEBUG);
|
|
@@ -3190,8 +3190,8 @@ abstract class CommonObject
|
|
|
}
|
|
|
} else {
|
|
|
// If not, search the last rang of element
|
|
|
- $sql = 'SELECT max('.$positionfield.') FROM '.MAIN_DB_PREFIX.$this->table_element_line;
|
|
|
- $sql .= ' WHERE '.$this->fk_element.' = '.$this->id;
|
|
|
+ $sql = "SELECT max(".$positionfield.") FROM ".MAIN_DB_PREFIX.$this->table_element_line;
|
|
|
+ $sql .= " WHERE ".$this->fk_element." = ".((int) $this->id);
|
|
|
|
|
|
dol_syslog(get_class($this)."::line_max", LOG_DEBUG);
|
|
|
$resql = $this->db->query($sql);
|
|
@@ -3217,7 +3217,7 @@ abstract class CommonObject
|
|
|
return -1;
|
|
|
}
|
|
|
|
|
|
- $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element;
|
|
|
+ $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element;
|
|
|
$sql .= " SET ref_ext = '".$this->db->escape($ref_ext)."'";
|
|
|
$sql .= " WHERE ".(isset($this->table_rowid) ? $this->table_rowid : 'rowid')." = ".((int) $this->id);
|
|
|
|
|
@@ -3268,7 +3268,7 @@ abstract class CommonObject
|
|
|
} else {
|
|
|
$fieldusermod = "fk_user_modif";
|
|
|
}
|
|
|
- $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element;
|
|
|
+ $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element;
|
|
|
$sql .= " SET note".$newsuffix." = ".(!empty($note) ? ("'".$this->db->escape($note)."'") : "NULL");
|
|
|
$sql .= ", ".$fieldusermod." = ".((int) $user->id);
|
|
|
$sql .= " WHERE rowid = ".((int) $this->id);
|
|
@@ -3386,21 +3386,21 @@ abstract class CommonObject
|
|
|
$fieldup = 'value_unit';
|
|
|
}
|
|
|
|
|
|
- $sql = 'SELECT rowid, qty, '.$fieldup.' as up, remise_percent, total_ht, '.$fieldtva.' as total_tva, total_ttc, '.$fieldlocaltax1.' as total_localtax1, '.$fieldlocaltax2.' as total_localtax2,';
|
|
|
+ $sql = "SELECT rowid, qty, ".$fieldup." as up, remise_percent, total_ht, ".$fieldtva." as total_tva, total_ttc, ".$fieldlocaltax1." as total_localtax1, ".$fieldlocaltax2." as total_localtax2,";
|
|
|
$sql .= ' tva_tx as vatrate, localtax1_tx, localtax2_tx, localtax1_type, localtax2_type, info_bits, product_type';
|
|
|
if ($this->table_element_line == 'facturedet') {
|
|
|
$sql .= ', situation_percent';
|
|
|
}
|
|
|
$sql .= ', multicurrency_total_ht, multicurrency_total_tva, multicurrency_total_ttc';
|
|
|
$sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element_line;
|
|
|
- $sql .= ' WHERE '.$this->fk_element.' = '.((int) $this->id);
|
|
|
+ $sql .= " WHERE ".$this->fk_element." = ".((int) $this->id);
|
|
|
if ($exclspec) {
|
|
|
$product_field = 'product_type';
|
|
|
if ($this->table_element_line == 'contratdet') {
|
|
|
$product_field = ''; // contratdet table has no product_type field
|
|
|
}
|
|
|
if ($product_field) {
|
|
|
- $sql .= ' AND '.$product_field.' <> 9';
|
|
|
+ $sql .= " AND ".$product_field." <> 9";
|
|
|
}
|
|
|
}
|
|
|
$sql .= ' ORDER by rowid'; // We want to be sure to always use same order of line to not change lines differently when option MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND is used
|
|
@@ -3553,14 +3553,14 @@ abstract class CommonObject
|
|
|
|
|
|
if (empty($nodatabaseupdate)) {
|
|
|
$sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element.' SET';
|
|
|
- $sql .= " ".$fieldht." = ".price2num($this->total_ht).",";
|
|
|
- $sql .= " ".$fieldtva." = ".price2num($this->total_tva).",";
|
|
|
- $sql .= " ".$fieldlocaltax1." = ".price2num($this->total_localtax1).",";
|
|
|
- $sql .= " ".$fieldlocaltax2." = ".price2num($this->total_localtax2).",";
|
|
|
- $sql .= " ".$fieldttc." = ".price2num($this->total_ttc);
|
|
|
- $sql .= ", multicurrency_total_ht = ".price2num($this->multicurrency_total_ht, 'MT', 1);
|
|
|
- $sql .= ", multicurrency_total_tva = ".price2num($this->multicurrency_total_tva, 'MT', 1);
|
|
|
- $sql .= ", multicurrency_total_ttc = ".price2num($this->multicurrency_total_ttc, 'MT', 1);
|
|
|
+ $sql .= " ".$fieldht." = ".((float) price2num($this->total_ht)).",";
|
|
|
+ $sql .= " ".$fieldtva." = ".((float) price2num($this->total_tva)).",";
|
|
|
+ $sql .= " ".$fieldlocaltax1." = ".((float) price2num($this->total_localtax1)).",";
|
|
|
+ $sql .= " ".$fieldlocaltax2." = ".((float) price2num($this->total_localtax2)).",";
|
|
|
+ $sql .= " ".$fieldttc." = ".((float) price2num($this->total_ttc));
|
|
|
+ $sql .= ", multicurrency_total_ht = ".((float) price2num($this->multicurrency_total_ht, 'MT', 1));
|
|
|
+ $sql .= ", multicurrency_total_tva = ".((float) price2num($this->multicurrency_total_tva, 'MT', 1));
|
|
|
+ $sql .= ", multicurrency_total_ttc = ".((float) price2num($this->multicurrency_total_ttc, 'MT', 1));
|
|
|
$sql .= " WHERE rowid = ".((int) $this->id);
|
|
|
|
|
|
dol_syslog(get_class($this)."::update_price", LOG_DEBUG);
|
|
@@ -4038,7 +4038,7 @@ abstract class CommonObject
|
|
|
|
|
|
global $db;
|
|
|
|
|
|
- $sql = 'SELECT '.$field_select.' FROM '.MAIN_DB_PREFIX.$table_element.' WHERE '.$field_where.' = '.((int) $fk_object_where);
|
|
|
+ $sql = "SELECT ".$field_select." FROM ".MAIN_DB_PREFIX.$table_element." WHERE ".$field_where." = ".((int) $fk_object_where);
|
|
|
$resql = $db->query($sql);
|
|
|
|
|
|
$TRes = array();
|
|
@@ -4067,7 +4067,7 @@ abstract class CommonObject
|
|
|
|
|
|
global $db;
|
|
|
|
|
|
- $sql = 'DELETE FROM '.MAIN_DB_PREFIX.$table_element.' WHERE '.$field_where.' = '.((int) $fk_object_where);
|
|
|
+ $sql = "DELETE FROM ".MAIN_DB_PREFIX.$table_element." WHERE ".$field_where." = ".((int) $fk_object_where);
|
|
|
$resql = $db->query($sql);
|
|
|
|
|
|
if (empty($resql)) {
|
|
@@ -5317,7 +5317,7 @@ abstract class CommonObject
|
|
|
$update_main_doc_field = 1;
|
|
|
}
|
|
|
if ($update_main_doc_field && !empty($this->table_element)) {
|
|
|
- $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element." SET last_main_doc = '".$this->db->escape($ecmfile->filepath.'/'.$ecmfile->filename)."'";
|
|
|
+ $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element." SET last_main_doc = '".$this->db->escape($ecmfile->filepath."/".$ecmfile->filename)."'";
|
|
|
$sql .= " WHERE rowid = ".((int) $this->id);
|
|
|
|
|
|
$resql = $this->db->query($sql);
|
|
@@ -6677,17 +6677,17 @@ abstract class CommonObject
|
|
|
|
|
|
//We have to join on extrafield table
|
|
|
if (strpos($InfoFieldList[4], 'extra') !== false) {
|
|
|
- $sql .= ' as main, '.MAIN_DB_PREFIX.$InfoFieldList[0].'_extrafields as extra';
|
|
|
- $sqlwhere .= ' WHERE extra.fk_object=main.'.$InfoFieldList[2].' AND '.$InfoFieldList[4];
|
|
|
+ $sql .= " as main, ".MAIN_DB_PREFIX.$InfoFieldList[0]."_extrafields as extra";
|
|
|
+ $sqlwhere .= " WHERE extra.fk_object=main.".$InfoFieldList[2]." AND ".$InfoFieldList[4];
|
|
|
} else {
|
|
|
- $sqlwhere .= ' WHERE '.$InfoFieldList[4];
|
|
|
+ $sqlwhere .= " WHERE ".$InfoFieldList[4];
|
|
|
}
|
|
|
} else {
|
|
|
$sqlwhere .= ' WHERE 1=1';
|
|
|
}
|
|
|
// Some tables may have field, some other not. For the moment we disable it.
|
|
|
if (in_array($InfoFieldList[0], array('tablewithentity'))) {
|
|
|
- $sqlwhere .= ' AND entity = '.$conf->entity;
|
|
|
+ $sqlwhere .= " AND entity = ".((int) $conf->entity);
|
|
|
}
|
|
|
$sql .= $sqlwhere;
|
|
|
//print $sql;
|
|
@@ -6830,16 +6830,16 @@ abstract class CommonObject
|
|
|
// We have to join on extrafield table
|
|
|
if (strpos($InfoFieldList[4], 'extra') !== false) {
|
|
|
$sql .= ' as main, '.MAIN_DB_PREFIX.$InfoFieldList[0].'_extrafields as extra';
|
|
|
- $sqlwhere .= ' WHERE extra.fk_object=main.'.$InfoFieldList[2].' AND '.$InfoFieldList[4];
|
|
|
+ $sqlwhere .= " WHERE extra.fk_object=main.".$InfoFieldList[2]." AND ".$InfoFieldList[4];
|
|
|
} else {
|
|
|
- $sqlwhere .= ' WHERE '.$InfoFieldList[4];
|
|
|
+ $sqlwhere .= " WHERE ".$InfoFieldList[4];
|
|
|
}
|
|
|
} else {
|
|
|
$sqlwhere .= ' WHERE 1=1';
|
|
|
}
|
|
|
// Some tables may have field, some other not. For the moment we disable it.
|
|
|
if (in_array($InfoFieldList[0], array('tablewithentity'))) {
|
|
|
- $sqlwhere .= ' AND entity = '.$conf->entity;
|
|
|
+ $sqlwhere .= " AND entity = ".((int) $conf->entity);
|
|
|
}
|
|
|
// $sql.=preg_replace('/^ AND /','',$sqlwhere);
|
|
|
// print $sql;
|
|
@@ -8770,8 +8770,8 @@ abstract class CommonObject
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
- $sql = 'SELECT '.$fieldlist;
|
|
|
- $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t';
|
|
|
+ $sql = "SELECT ".$fieldlist;
|
|
|
+ $sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element.' as t';
|
|
|
|
|
|
if (!empty($id)) {
|
|
|
$sql .= ' WHERE t.rowid = '.((int) $id);
|
|
@@ -8825,9 +8825,9 @@ abstract class CommonObject
|
|
|
|
|
|
$objectline = new $objectlineclassname($this->db);
|
|
|
|
|
|
- $sql = 'SELECT '.$objectline->getFieldList('l');
|
|
|
- $sql .= ' FROM '.MAIN_DB_PREFIX.$objectline->table_element.' as l';
|
|
|
- $sql .= ' WHERE l.fk_'.$this->element.' = '.((int) $this->id);
|
|
|
+ $sql = "SELECT ".$objectline->getFieldList('l');
|
|
|
+ $sql .= " FROM ".MAIN_DB_PREFIX.$objectline->table_element." as l";
|
|
|
+ $sql .= " WHERE l.fk_".$this->element." = ".((int) $this->id);
|
|
|
if ($morewhere) {
|
|
|
$sql .= $morewhere;
|
|
|
}
|
|
@@ -8973,7 +8973,7 @@ abstract class CommonObject
|
|
|
|
|
|
if ($forcechilddeletion) { // Force also delete of childtables that should lock deletion in standard case when option force is off
|
|
|
foreach ($this->childtables as $table) {
|
|
|
- $sql = 'DELETE FROM '.MAIN_DB_PREFIX.$table.' WHERE '.$this->fk_element.' = '.((int) $this->id);
|
|
|
+ $sql = "DELETE FROM ".MAIN_DB_PREFIX.$table." WHERE ".$this->fk_element." = ".((int) $this->id);
|
|
|
$resql = $this->db->query($sql);
|
|
|
if (!$resql) {
|
|
|
$this->error = $this->db->lasterror();
|
|
@@ -9022,7 +9022,7 @@ abstract class CommonObject
|
|
|
}
|
|
|
} else {
|
|
|
// Delete record in child table
|
|
|
- $sql = 'DELETE FROM '.MAIN_DB_PREFIX.$table.' WHERE '.$this->fk_element.' = '.((int) $this->id);
|
|
|
+ $sql = "DELETE FROM ".MAIN_DB_PREFIX.$table." WHERE ".$this->fk_element." = ".((int) $this->id);
|
|
|
|
|
|
$resql = $this->db->query($sql);
|
|
|
if (!$resql) {
|
|
@@ -9100,7 +9100,7 @@ abstract class CommonObject
|
|
|
$this->db->begin();
|
|
|
|
|
|
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX.$this->table_element;
|
|
|
- $sql .= ' WHERE '.$parentField.' = '.(int) $parentId;
|
|
|
+ $sql .= " WHERE ".$parentField." = ".(int) $parentId;
|
|
|
|
|
|
$resql = $this->db->query($sql);
|
|
|
if (!$resql) {
|
|
@@ -9533,7 +9533,7 @@ abstract class CommonObject
|
|
|
// Delete in database with mode 1
|
|
|
if ($mode == 1) {
|
|
|
$sql = 'DELETE FROM '.MAIN_DB_PREFIX."ecm_files_extrafields";
|
|
|
- $sql .= " WHERE fk_object IN (SELECT rowid FROM ".MAIN_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).")";
|
|
|
+ $sql .= " WHERE fk_object IN (SELECT rowid FROM ".MAIN_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).")";
|
|
|
$resql = $this->db->query($sql);
|
|
|
if (!$resql) {
|
|
|
$this->error = $this->db->lasterror();
|
|
@@ -9542,7 +9542,7 @@ abstract class CommonObject
|
|
|
}
|
|
|
|
|
|
$sql = 'DELETE FROM '.MAIN_DB_PREFIX."ecm_files";
|
|
|
- $sql .= " WHERE src_object_type = '".$this->db->escape($this->table_element.(empty($this->module) ? '' : '@'.$this->module))."' AND src_object_id = ".((int) $this->id);
|
|
|
+ $sql .= " WHERE src_object_type = '".$this->db->escape($this->table_element.(empty($this->module) ? "" : "@".$this->module))."' AND src_object_id = ".((int) $this->id);
|
|
|
$resql = $this->db->query($sql);
|
|
|
if (!$resql) {
|
|
|
$this->error = $this->db->lasterror();
|