Fix: uniformize code
This commit is contained in:
parent
9cd4d949c3
commit
e765f83644
@ -1787,21 +1787,21 @@ class Product extends CommonObject
|
|||||||
*/
|
*/
|
||||||
function clone_price($fromId, $toId)
|
function clone_price($fromId, $toId)
|
||||||
{
|
{
|
||||||
global $db;
|
$this->db->begin();
|
||||||
|
|
||||||
$db->begin();
|
|
||||||
|
|
||||||
// les prix
|
// les prix
|
||||||
$sql = "insert " .MAIN_DB_PREFIX."product_price ("
|
$sql = "INSERT ".MAIN_DB_PREFIX."product_price ("
|
||||||
. " fk_product, date_price, price, tva_tx, fk_user_author, envente )"
|
. " fk_product, date_price, price, tva_tx, fk_user_author, envente )"
|
||||||
. " select ".$toId . ", date_price, price, tva_tx, fk_user_author, envente "
|
. " SELECT ".$toId . ", date_price, price, tva_tx, fk_user_author, envente "
|
||||||
. " from ".MAIN_DB_PREFIX."product_price "
|
. " FROM ".MAIN_DB_PREFIX."product_price "
|
||||||
. " where fk_product = ". $fromId . ";" ;
|
. " WHERE fk_product = ". $fromId;
|
||||||
if ( ! $db->query($sql ) ) {
|
|
||||||
$db->rollback();
|
if ( ! $this->db->query($sql ) )
|
||||||
|
{
|
||||||
|
$this->db->rollback();
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
$db->commit();
|
$this->db->commit();
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1813,31 +1813,34 @@ class Product extends CommonObject
|
|||||||
*/
|
*/
|
||||||
function clone_fournisseurs($fromId, $toId)
|
function clone_fournisseurs($fromId, $toId)
|
||||||
{
|
{
|
||||||
global $db;
|
$this->db->begin();
|
||||||
|
|
||||||
$db->begin();
|
|
||||||
|
|
||||||
// les fournisseurs
|
// les fournisseurs
|
||||||
$sql = "insert ".MAIN_DB_PREFIX."product_fournisseur ("
|
$sql = "INSERT ".MAIN_DB_PREFIX."product_fournisseur ("
|
||||||
. " datec, fk_product, fk_soc, ref_fourn, fk_user_author )"
|
. " datec, fk_product, fk_soc, ref_fourn, fk_user_author )"
|
||||||
. " select '".$this->db->idate(mktime())."', ".$toId.", fk_soc, ref_fourn, fk_user_author"
|
. " SELECT '".$this->db->idate(mktime())."', ".$toId.", fk_soc, ref_fourn, fk_user_author"
|
||||||
. " from ".MAIN_DB_PREFIX."product_fournisseur "
|
. " FROM ".MAIN_DB_PREFIX."product_fournisseur"
|
||||||
. " where fk_product = ".$fromId .";" ;
|
. " WHERE fk_product = ".$fromId;
|
||||||
if ( ! $db->query($sql ) ) {
|
|
||||||
$db->rollback();
|
if ( ! $this->db->query($sql ) )
|
||||||
|
{
|
||||||
|
$this->db->rollback();
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// les prix de fournisseurs.
|
// les prix de fournisseurs.
|
||||||
$sql = "insert ".MAIN_DB_PREFIX."product_fournisseur_price ("
|
$sql = "INSERT ".MAIN_DB_PREFIX."product_fournisseur_price ("
|
||||||
. " datec, fk_product, fk_soc, price, quantity, fk_user )"
|
. " datec, fk_product, fk_soc, price, quantity, fk_user )"
|
||||||
. " select '".$this->db->idate(mktime())."', ".$toId. ", fk_soc, price, quantity, fk_user"
|
. " SELECT '".$this->db->idate(mktime())."', ".$toId. ", fk_soc, price, quantity, fk_user"
|
||||||
. " from ".MAIN_DB_PREFIX."product_fournisseur_price"
|
. " FROM ".MAIN_DB_PREFIX."product_fournisseur_price"
|
||||||
. " where fk_product = ".$fromId.";";
|
. " WHERE fk_product = ".$fromId;
|
||||||
if ( ! $db->query($sql ) ) {
|
|
||||||
$db->rollback();
|
if ( ! $this->db->query($sql ) )
|
||||||
|
{
|
||||||
|
$this->db->rollback();
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
$db->commit();
|
$this->db->commit();
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1961,12 +1964,13 @@ class Product extends CommonObject
|
|||||||
function get_pere()
|
function get_pere()
|
||||||
{
|
{
|
||||||
|
|
||||||
$sql = "SELECT p.label as label,p.rowid,pa.fk_product_pere as id FROM ";
|
$sql = "SELECT p.label as label,p.rowid,pa.fk_product_pere as id";
|
||||||
$sql .= MAIN_DB_PREFIX."product_association as pa,";
|
$sql.= " FROM ".MAIN_DB_PREFIX."product_association as pa";
|
||||||
$sql .= MAIN_DB_PREFIX."product as p";
|
$sql.= ", ".MAIN_DB_PREFIX."product as p";
|
||||||
$sql .= " where p.rowid=pa.fk_product_pere and p.rowid = '".$this->id."'";
|
$sql.= " WHERE p.rowid = pa.fk_product_pere";
|
||||||
|
$sql.= " AND p.rowid = ".$this->id;
|
||||||
|
|
||||||
$res = $this->db->query ($sql);
|
$res = $this->db->query($sql);
|
||||||
if ($res)
|
if ($res)
|
||||||
{
|
{
|
||||||
$prods = array ();
|
$prods = array ();
|
||||||
@ -1989,15 +1993,17 @@ class Product extends CommonObject
|
|||||||
*/
|
*/
|
||||||
function get_fils_arbo ($id_pere)
|
function get_fils_arbo ($id_pere)
|
||||||
{
|
{
|
||||||
$sql = "SELECT p.rowid, p.label as label,pa.qty as qty,pa.fk_product_fils as id FROM ";
|
$sql = "SELECT p.rowid, p.label as label, pa.qty as qty, pa.fk_product_fils as id";
|
||||||
$sql .= MAIN_DB_PREFIX."product as p,".MAIN_DB_PREFIX."product_association as pa";
|
$sql.= "FROM ".MAIN_DB_PREFIX."product as p";
|
||||||
$sql .= " WHERE p.rowid = pa.fk_product_fils and pa.fk_product_pere = '".$id_pere."'";
|
$sql.= ", ".MAIN_DB_PREFIX."product_association as pa";
|
||||||
|
$sql.= " WHERE p.rowid = pa.fk_product_fils";
|
||||||
|
$sql.= " AND pa.fk_product_pere = ".$id_pere;
|
||||||
|
|
||||||
$res = $this->db->query ($sql);
|
$res = $this->db->query($sql);
|
||||||
if ($res)
|
if ($res)
|
||||||
{
|
{
|
||||||
$prods = array();
|
$prods = array();
|
||||||
while ($rec = $this->db->fetch_array ($res))
|
while ($rec = $this->db->fetch_array($res))
|
||||||
{
|
{
|
||||||
$prods[addslashes($rec['label'])]= array(0=>$rec['id'],1=>$rec['qty']);
|
$prods[addslashes($rec['label'])]= array(0=>$rec['id'],1=>$rec['qty']);
|
||||||
foreach($this -> get_fils_arbo($rec['id']) as $kf=>$vf)
|
foreach($this -> get_fils_arbo($rec['id']) as $kf=>$vf)
|
||||||
@ -2123,7 +2129,7 @@ class Product extends CommonObject
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Retourne le libell<EFBFBD> du finished du produit
|
* \brief Retourne le libelle du finished du produit
|
||||||
* \return string Libelle
|
* \return string Libelle
|
||||||
*/
|
*/
|
||||||
function getLibFinished()
|
function getLibFinished()
|
||||||
@ -2152,8 +2158,10 @@ class Product extends CommonObject
|
|||||||
{
|
{
|
||||||
$this->db->begin();
|
$this->db->begin();
|
||||||
|
|
||||||
$sql = "SELECT count(*) as nb FROM ".MAIN_DB_PREFIX."product_stock";
|
$sql = "SELECT count(*) as nb";
|
||||||
$sql .= " WHERE fk_product = ".$this->id." AND fk_entrepot = ".$id_entrepot;
|
$sql.= " FROM ".MAIN_DB_PREFIX."product_stock";
|
||||||
|
$sql.= " WHERE fk_product = ".$this->id;
|
||||||
|
$sql.= " AND fk_entrepot = ".$id_entrepot;
|
||||||
|
|
||||||
dol_syslog("Product::correct_stock sql=".$sql, LOG_DEBUG);
|
dol_syslog("Product::correct_stock sql=".$sql, LOG_DEBUG);
|
||||||
$resql=$this->db->query($sql);
|
$resql=$this->db->query($sql);
|
||||||
@ -2612,8 +2620,8 @@ class Product extends CommonObject
|
|||||||
function update_barcode($user)
|
function update_barcode($user)
|
||||||
{
|
{
|
||||||
$sql = "UPDATE ".MAIN_DB_PREFIX."product";
|
$sql = "UPDATE ".MAIN_DB_PREFIX."product";
|
||||||
$sql .= " SET barcode = '".$this->barcode."'";
|
$sql.= " SET barcode = '".$this->barcode."'";
|
||||||
$sql .= " WHERE rowid = ".$this->id;
|
$sql.= " WHERE rowid = ".$this->id;
|
||||||
|
|
||||||
dol_syslog("Product::update_barcode sql=".$sql);
|
dol_syslog("Product::update_barcode sql=".$sql);
|
||||||
$resql=$this->db->query($sql);
|
$resql=$this->db->query($sql);
|
||||||
@ -2635,8 +2643,8 @@ class Product extends CommonObject
|
|||||||
function update_barcode_type($user)
|
function update_barcode_type($user)
|
||||||
{
|
{
|
||||||
$sql = "UPDATE ".MAIN_DB_PREFIX."product";
|
$sql = "UPDATE ".MAIN_DB_PREFIX."product";
|
||||||
$sql .= " SET fk_barcode_type = '".$this->barcode_type."'";
|
$sql.= " SET fk_barcode_type = '".$this->barcode_type."'";
|
||||||
$sql .= " WHERE rowid = ".$this->id;
|
$sql.= " WHERE rowid = ".$this->id;
|
||||||
|
|
||||||
dol_syslog("Product::update_barcode_type sql=".$sql);
|
dol_syslog("Product::update_barcode_type sql=".$sql);
|
||||||
$resql=$this->db->query($sql);
|
$resql=$this->db->query($sql);
|
||||||
@ -2652,27 +2660,35 @@ class Product extends CommonObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
\brief Affecte les valeurs smarty
|
* \brief Affecte les valeurs smarty
|
||||||
\remarks Rodolphe : pour l'instant la fonction est vide mais necessaire pour compatibilite
|
* \remarks Rodolphe : pour l'instant la fonction est vide mais necessaire pour compatibilite
|
||||||
avec les canvas A terme la fiche produit utilisera aussi smarty
|
* avec les canvas A terme la fiche produit utilisera aussi smarty
|
||||||
*/
|
*/
|
||||||
function assign_smarty_values(&$smarty)
|
function assign_smarty_values(&$smarty)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function isproduct() {
|
function isproduct()
|
||||||
if ($this->type != 1) {
|
{
|
||||||
|
if ($this->type != 1)
|
||||||
|
{
|
||||||
return 1;
|
return 1;
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function isservice() {
|
function isservice()
|
||||||
if ($this->type==1) {
|
{
|
||||||
|
if ($this->type==1)
|
||||||
|
{
|
||||||
return 1;
|
return 1;
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user