Skip to content

Commit

Permalink
Update sql queries
Browse files Browse the repository at this point in the history
Replace the values :
propal: $this->table_element
propaldet : $this->table_element_line
in the sql queries.
see Dolibarr#31056
  • Loading branch information
dolibarr95 authored Sep 27, 2024
1 parent 73c2c2b commit 3cf9ad9
Showing 1 changed file with 26 additions and 26 deletions.
52 changes: 26 additions & 26 deletions htdocs/comm/propal/class/propal.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -1125,7 +1125,7 @@ public function create($user, $notrigger = 0)
$this->db->begin();

// Insert into database
$sql = "INSERT INTO ".MAIN_DB_PREFIX."propal (";
$sql = "INSERT INTO ".MAIN_DB_PREFIX.$this->table_element." (";
$sql .= "fk_soc";
$sql .= ", price";
$sql .= ", total_tva";
Expand Down Expand Up @@ -1193,11 +1193,11 @@ public function create($user, $notrigger = 0)
dol_syslog(get_class($this)."::create", LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql) {
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."propal");
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX.$this->table_element);

if ($this->id) {
$this->ref = '(PROV'.$this->id.')';
$sql = 'UPDATE '.MAIN_DB_PREFIX."propal SET ref='".$this->db->escape($this->ref)."' WHERE rowid=".((int) $this->id);
$sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element." SET ref='".$this->db->escape($this->ref)."' WHERE rowid=".((int) $this->id);

dol_syslog(get_class($this)."::create", LOG_DEBUG);
$resql = $this->db->query($sql);
Expand Down Expand Up @@ -1314,7 +1314,7 @@ public function create($user, $notrigger = 0)
// Set delivery address
/*if (! $error && $this->fk_delivery_address)
{
$sql = "UPDATE ".MAIN_DB_PREFIX."propal";
$sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element;
$sql.= " SET fk_delivery_address = ".((int) $this->fk_delivery_address);
$sql.= " WHERE ref = '".$this->db->escape($this->ref)."'";
$sql.= " AND entity = ".setEntity($this);
Expand Down Expand Up @@ -1597,7 +1597,7 @@ public function fetch($rowid, $ref = '', $ref_ext = '', $forceentity = 0)
$sql .= ", dr.code as demand_reason_code, dr.label as demand_reason";
$sql .= ", cr.code as cond_reglement_code, cr.libelle as cond_reglement, cr.libelle_facture as cond_reglement_libelle_doc, p.deposit_percent";
$sql .= ", cp.code as mode_reglement_code, cp.libelle as mode_reglement";
$sql .= " FROM ".MAIN_DB_PREFIX."propal as p";
$sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element." as p";
$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_propalst as c ON p.fk_statut = c.id';
$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as cp ON p.fk_mode_reglement = cp.id AND cp.entity IN ('.getEntity('c_paiement').')';
$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_payment_term as cr ON p.fk_cond_reglement = cr.rowid AND cr.entity IN ('.getEntity('c_payment_term').')';
Expand Down Expand Up @@ -1767,7 +1767,7 @@ public function update(User $user, $notrigger = 0)
// Put here code to add control on parameters values

// Update request
$sql = "UPDATE ".MAIN_DB_PREFIX."propal SET";
$sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element." SET";
$sql .= " ref=".(isset($this->ref) ? "'".$this->db->escape($this->ref)."'" : "null").",";
$sql .= " ref_client=".(isset($this->ref_client) ? "'".$this->db->escape($this->ref_client)."'" : "null").",";
$sql .= " ref_ext=".(isset($this->ref_ext) ? "'".$this->db->escape($this->ref_ext)."'" : "null").",";
Expand Down Expand Up @@ -1857,7 +1857,7 @@ public function fetch_lines($only_product = 0, $loadalsotranslation = 0, $sqlfor
$sql .= ' p.weight, p.weight_units, p.volume, p.volume_units,';
$sql .= ' d.date_start, d.date_end,';
$sql .= ' d.fk_multicurrency, d.multicurrency_code, d.multicurrency_subprice, d.multicurrency_total_ht, d.multicurrency_total_tva, d.multicurrency_total_ttc';
$sql .= ' FROM '.MAIN_DB_PREFIX.'propaldet as d';
$sql .= ' FROM '.MAIN_DB_PREFIX.$this->$table_element_line.' as d';
$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON (d.fk_product = p.rowid)';
$sql .= ' WHERE d.fk_propal = '.((int) $this->id);
if ($only_product) {
Expand Down Expand Up @@ -2013,7 +2013,7 @@ public function valid($user, $notrigger = 0)
}
$this->newref = dol_sanitizeFileName($num);

$sql = "UPDATE ".MAIN_DB_PREFIX."propal";
$sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element;
$sql .= " SET ref = '".$this->db->escape($num)."',";
$sql .= " fk_statut = ".self::STATUS_VALIDATED.", date_valid='".$this->db->idate($now)."', fk_user_valid=".((int) $user->id);
$sql .= " WHERE rowid = ".((int) $this->id)." AND fk_statut = ".self::STATUS_DRAFT;
Expand Down Expand Up @@ -2117,7 +2117,7 @@ public function set_date($user, $date, $notrigger = 0)

$this->db->begin();

$sql = "UPDATE ".MAIN_DB_PREFIX."propal SET datep = '".$this->db->idate($date)."'";
$sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element." SET datep = '".$this->db->idate($date)."'";
$sql .= " WHERE rowid = ".((int) $this->id);

dol_syslog(__METHOD__, LOG_DEBUG);
Expand Down Expand Up @@ -2175,7 +2175,7 @@ public function set_echeance($user, $date_end_validity, $notrigger = 0)

$this->db->begin();

$sql = "UPDATE ".MAIN_DB_PREFIX."propal SET fin_validite = ".($date_end_validity != '' ? "'".$this->db->idate($date_end_validity)."'" : 'null');
$sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element." SET fin_validite = ".($date_end_validity != '' ? "'".$this->db->idate($date_end_validity)."'" : 'null');
$sql .= " WHERE rowid = ".((int) $this->id);

dol_syslog(__METHOD__, LOG_DEBUG);
Expand Down Expand Up @@ -2248,7 +2248,7 @@ public function setDeliveryDate($user, $delivery_date, $notrigger = 0)

$this->db->begin();

$sql = "UPDATE ".MAIN_DB_PREFIX."propal ";
$sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element;
$sql .= " SET date_livraison = ".(isDolTms($delivery_date) ? "'".$this->db->idate($delivery_date)."'" : 'null');
$sql .= " WHERE rowid = ".((int) $this->id);

Expand Down Expand Up @@ -2306,7 +2306,7 @@ public function set_availability($user, $id, $notrigger = 0)

$this->db->begin();

$sql = "UPDATE ".MAIN_DB_PREFIX."propal";
$sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element;
$sql .= " SET fk_availability = ".((int) $id);
$sql .= " WHERE rowid = ".((int) $this->id);

Expand Down Expand Up @@ -2369,7 +2369,7 @@ public function set_demand_reason($user, $id, $notrigger = 0)

$this->db->begin();

$sql = "UPDATE ".MAIN_DB_PREFIX."propal ";
$sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element;
$sql .= " SET fk_input_reason = ".((int) $id);
$sql .= " WHERE rowid = ".((int) $this->id);

Expand Down Expand Up @@ -2434,7 +2434,7 @@ public function set_ref_client($user, $ref_client, $notrigger = 0)

$this->db->begin();

$sql = "UPDATE ".MAIN_DB_PREFIX."propal SET ref_client = ".(empty($ref_client) ? 'NULL' : "'".$this->db->escape($ref_client)."'");
$sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element." SET ref_client = ".(empty($ref_client) ? 'NULL' : "'".$this->db->escape($ref_client)."'");
$sql .= " WHERE rowid = ".((int) $this->id);

dol_syslog(__METHOD__.' $this->id='.$this->id.', ref_client='.$ref_client, LOG_DEBUG);
Expand Down Expand Up @@ -2488,7 +2488,7 @@ public function reopen($user, $status, $note = '', $notrigger = 0)
{
$error = 0;

$sql = "UPDATE ".MAIN_DB_PREFIX."propal";
$sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element;
$sql .= " SET fk_statut = ".((int) $status).",";
if (!empty($note)) {
$sql .= " note_private = '".$this->db->escape($note)."',";
Expand Down Expand Up @@ -2570,7 +2570,7 @@ public function closeProposal($user, $status, $note_private = '', $notrigger = 0
}
}

$sql = "UPDATE ".MAIN_DB_PREFIX."propal";
$sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element;
$sql .= " SET fk_statut = ".((int) $status).", note_private = '".$this->db->escape($newprivatenote)."', note_public = '".$this->db->escape($newpublicnote)."'";
if ($status == self::STATUS_SIGNED) {
$sql .= ", date_signature='".$this->db->idate($now)."', fk_user_signature = ".($fk_user_signature);
Expand Down Expand Up @@ -2676,7 +2676,7 @@ public function classifyBilled(User $user, $notrigger = 0, $note = '')

$newprivatenote = dol_concatdesc($this->note_private, $note);

$sql = 'UPDATE '.MAIN_DB_PREFIX.'propal SET fk_statut = '.self::STATUS_BILLED.", ";
$sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element.' SET fk_statut = '.self::STATUS_BILLED.", ";
$sql .= " note_private = '".$this->db->escape($newprivatenote)."', date_cloture='".$this->db->idate($now)."', fk_user_cloture=".((int) $user->id);
$sql .= ' WHERE rowid = '.((int) $this->id).' AND fk_statut = '.((int) self::STATUS_SIGNED);

Expand Down Expand Up @@ -2751,7 +2751,7 @@ public function setCancel(User $user)

$this->db->begin();

$sql = "UPDATE ". MAIN_DB_PREFIX . "propal";
$sql = "UPDATE ". MAIN_DB_PREFIX.$this->table_element;
$sql .= " SET fk_statut = " . self::STATUS_CANCELED . ",";
$sql .= " fk_user_modif = " . ((int) $user->id);
$sql .= " WHERE rowid = " . ((int) $this->id);
Expand Down Expand Up @@ -2809,7 +2809,7 @@ public function setDraft($user, $notrigger = 0)

$this->db->begin();

$sql = "UPDATE ".MAIN_DB_PREFIX."propal";
$sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element;
$sql .= " SET fk_statut = ".self::STATUS_DRAFT;
$sql .= ", online_sign_ip = NULL , online_sign_name = NULL";
$sql .= " WHERE rowid = ".((int) $this->id);
Expand Down Expand Up @@ -2874,7 +2874,7 @@ public function liste_array($shortlist = 0, $draft = 0, $notcurrentuser = 0, $so
$sql = "SELECT s.rowid, s.nom as name, s.client,";
$sql .= " p.rowid as propalid, p.fk_statut, p.total_ht, p.ref, p.remise, ";
$sql .= " p.datep as dp, p.fin_validite as datelimite";
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."propal as p, ".MAIN_DB_PREFIX."c_propalst as c";
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX.$this->table_element." as p, ".MAIN_DB_PREFIX."c_propalst as c";
$sql .= " WHERE p.entity IN (".getEntity('propal').")";
$sql .= " AND p.fk_soc = s.rowid";
$sql .= " AND p.fk_statut = c.id";
Expand Down Expand Up @@ -3155,7 +3155,7 @@ public function availability($availability_id, $notrigger = 0)

$this->db->begin();

$sql = 'UPDATE '.MAIN_DB_PREFIX.'propal';
$sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element;
$sql .= ' SET fk_availability = '.((int) $availability_id);
$sql .= ' WHERE rowid='.((int) $this->id);

Expand Down Expand Up @@ -3219,7 +3219,7 @@ public function demand_reason($demand_reason_id, $notrigger = 0)

$this->db->begin();

$sql = 'UPDATE '.MAIN_DB_PREFIX.'propal';
$sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element;
$sql .= ' SET fk_input_reason = '.((int) $demand_reason_id);
$sql .= ' WHERE rowid='.((int) $this->id);

Expand Down Expand Up @@ -3276,7 +3276,7 @@ public function info($id)
$sql = "SELECT c.rowid, ";
$sql .= " c.datec, c.date_valid as datev, c.date_signature, c.date_cloture,";
$sql .= " c.fk_user_author, c.fk_user_valid, c.fk_user_signature, c.fk_user_cloture";
$sql .= " FROM ".MAIN_DB_PREFIX."propal as c";
$sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element." as c";
$sql .= " WHERE c.rowid = ".((int) $id);

$result = $this->db->query($sql);
Expand Down Expand Up @@ -3394,7 +3394,7 @@ public function load_board($user, $mode)
$clause = " WHERE";

$sql = "SELECT p.rowid, p.ref, p.datec as datec, p.fin_validite as datefin, p.total_ht";
$sql .= " FROM ".MAIN_DB_PREFIX."propal as p";
$sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element." as p";
$sql .= $clause." p.entity IN (".getEntity('propal').")";
if ($mode == 'opened') {
$sql .= " AND p.fk_statut = ".self::STATUS_VALIDATED;
Expand Down Expand Up @@ -3575,7 +3575,7 @@ public function loadStateBoard()
$clause = "WHERE";

$sql = "SELECT count(p.rowid) as nb";
$sql .= " FROM ".MAIN_DB_PREFIX."propal as p";
$sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element." as p";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON p.fk_soc = s.rowid";
$sql .= " ".$clause." p.entity IN (".getEntity('propal').")";

Expand Down Expand Up @@ -3934,7 +3934,7 @@ public static function replaceThirdparty(DoliDB $dbs, $origin_id, $dest_id)
public static function replaceProduct(DoliDB $db, $origin_id, $dest_id)
{
$tables = array(
'propaldet'
$this->$table_element_line
);

return CommonObject::commonReplaceProduct($db, $origin_id, $dest_id, $tables);
Expand Down

0 comments on commit 3cf9ad9

Please sign in to comment.