diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 5cf2c238a3310..aaa8a5cf6f396 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -1164,7 +1164,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"; @@ -1232,11 +1232,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); @@ -1353,7 +1353,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); @@ -1636,7 +1636,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').')'; @@ -1806,7 +1806,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").","; @@ -1896,7 +1896,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) { @@ -2052,7 +2052,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; @@ -2156,7 +2156,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); @@ -2214,7 +2214,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); @@ -2287,7 +2287,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); @@ -2345,7 +2345,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); @@ -2408,7 +2408,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); @@ -2473,7 +2473,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); @@ -2527,7 +2527,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)."',"; @@ -2609,7 +2609,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); @@ -2715,7 +2715,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); @@ -2790,7 +2790,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); @@ -2848,7 +2848,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); @@ -2913,7 +2913,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"; @@ -3194,7 +3194,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); @@ -3258,7 +3258,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); @@ -3315,7 +3315,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); @@ -3433,7 +3433,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; @@ -3614,7 +3614,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').")";