Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update sql queries #31154

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from
Open
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -1164,7 +1164,7 @@
$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 @@ -1232,11 +1232,11 @@
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 @@ -1353,7 +1353,7 @@
// 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 @@ -1636,7 +1636,7 @@
$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 @@ -1806,7 +1806,7 @@
// 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 @@ -1896,7 +1896,7 @@
$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';

Check failure on line 1899 in htdocs/comm/propal/class/propal.class.php

View workflow job for this annotation

GitHub Actions / phpstan / php-stan (8.2)

Undefined variable: $table_element_line

Check warning on line 1899 in htdocs/comm/propal/class/propal.class.php

View workflow job for this annotation

GitHub Actions / phan / Run phan

propal.class.php: PhanTypeInvalidPropertyName: Saw a dynamic usage of an instance property with a name of type null= but expected the name to be a string

Check warning on line 1899 in htdocs/comm/propal/class/propal.class.php

View workflow job for this annotation

GitHub Actions / phan / Run phan

propal.class.php: PhanUndeclaredVariable: Variable $table_element_line is undeclared (Did you mean $this->table_element_line)
dolibarr95 marked this conversation as resolved.
Show resolved Hide resolved
$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 @@ -2052,7 +2052,7 @@
}
$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 @@ -2156,7 +2156,7 @@

$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 @@ -2214,7 +2214,7 @@

$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 @@ -2287,7 +2287,7 @@

$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 @@ -2345,7 +2345,7 @@

$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 @@ -2408,7 +2408,7 @@

$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 @@ -2473,7 +2473,7 @@

$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 @@ -2527,7 +2527,7 @@
{
$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 @@ -2609,7 +2609,7 @@
}
}

$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 @@ -2715,7 +2715,7 @@

$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 @@ -2790,7 +2790,7 @@

$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 @@ -2848,7 +2848,7 @@

$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 @@ -2913,7 +2913,7 @@
$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 @@ -3194,7 +3194,7 @@

$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 @@ -3258,7 +3258,7 @@

$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 @@ -3315,7 +3315,7 @@
$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 @@ -3433,7 +3433,7 @@
$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 @@ -3614,7 +3614,7 @@
$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 @@ -3973,7 +3973,7 @@
public static function replaceProduct(DoliDB $db, $origin_id, $dest_id)
{
$tables = array(
'propaldet'
$this->$table_element_line

Check failure on line 3976 in htdocs/comm/propal/class/propal.class.php

View workflow job for this annotation

GitHub Actions / phpstan / php-stan (8.2)

Undefined variable: $table_element_line

Check failure on line 3976 in htdocs/comm/propal/class/propal.class.php

View workflow job for this annotation

GitHub Actions / phpstan / php-stan (8.2)

Undefined variable: $this

Check warning on line 3976 in htdocs/comm/propal/class/propal.class.php

View workflow job for this annotation

GitHub Actions / phan / Run phan

propal.class.php: PhanTypeInvalidPropertyName: Saw a dynamic usage of an instance property with a name of type null= but expected the name to be a string

Check failure on line 3976 in htdocs/comm/propal/class/propal.class.php

View workflow job for this annotation

GitHub Actions / phan / Run phan

propal.class.php: PhanUndeclaredThis: Variable $this is undeclared (Did you mean (function instead of static function for replaceProduct() at line 3973))

Check warning on line 3976 in htdocs/comm/propal/class/propal.class.php

View workflow job for this annotation

GitHub Actions / phan / Run phan

propal.class.php: PhanUndeclaredVariable: Variable $table_element_line is undeclared
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

idem

);

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