mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-12-06 09:38:23 +01:00
Fix: regression
This commit is contained in:
@@ -33,7 +33,6 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
require_once(DOL_DOCUMENT_ROOT ."/core/class/commonobject.class.php");
|
require_once(DOL_DOCUMENT_ROOT ."/core/class/commonobject.class.php");
|
||||||
require_once(DOL_DOCUMENT_ROOT ."/core/class/commonobjectline.class.php");
|
|
||||||
require_once(DOL_DOCUMENT_ROOT ."/product/class/product.class.php");
|
require_once(DOL_DOCUMENT_ROOT ."/product/class/product.class.php");
|
||||||
require_once(DOL_DOCUMENT_ROOT ."/contact/class/contact.class.php");
|
require_once(DOL_DOCUMENT_ROOT ."/contact/class/contact.class.php");
|
||||||
|
|
||||||
@@ -525,18 +524,16 @@ class Propal extends CommonObject
|
|||||||
* \param idligne Id de la ligne detail a supprimer
|
* \param idligne Id de la ligne detail a supprimer
|
||||||
* \return int >0 si ok, <0 si ko
|
* \return int >0 si ok, <0 si ko
|
||||||
*/
|
*/
|
||||||
function delete_product($lineid)
|
function delete_product($idligne)
|
||||||
{
|
{
|
||||||
if ($this->statut == 0)
|
if ($this->statut == 0)
|
||||||
{
|
{
|
||||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."propaldet WHERE rowid = ".$lineid;
|
$sql = "DELETE FROM ".MAIN_DB_PREFIX."propaldet WHERE rowid = ".$idligne;
|
||||||
|
|
||||||
if ($this->db->query($sql) )
|
if ($this->db->query($sql) )
|
||||||
{
|
{
|
||||||
$this->update_price();
|
$this->update_price();
|
||||||
|
|
||||||
$this->delRangOfLine($lineid, $this->element);
|
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -929,21 +926,12 @@ class Propal extends CommonObject
|
|||||||
* Lignes propales liees a un produit ou non
|
* Lignes propales liees a un produit ou non
|
||||||
*/
|
*/
|
||||||
$sql = "SELECT d.description, d.price, d.tva_tx, d.localtax1_tx, d.localtax2_tx, d.qty, d.fk_remise_except, d.remise_percent, d.subprice, d.fk_product,";
|
$sql = "SELECT d.description, d.price, d.tva_tx, d.localtax1_tx, d.localtax2_tx, d.qty, d.fk_remise_except, d.remise_percent, d.subprice, d.fk_product,";
|
||||||
$sql.= " d.info_bits, d.total_ht, d.total_tva, d.total_localtax1, d.total_localtax2, d.total_ttc, d.marge_tx, d.marque_tx, d.special_code, d.product_type,";
|
$sql.= " d.info_bits, d.total_ht, d.total_tva, d.total_localtax1, d.total_localtax2, d.total_ttc, d.marge_tx, d.marque_tx, d.special_code, d.rang, d.product_type,";
|
||||||
$sql.= " p.ref, p.label, p.description as product_desc";
|
$sql.= " p.ref, p.label, p.description as product_desc";
|
||||||
// FIXME: There is a bug when using a join with element_rang and
|
|
||||||
// condition outside of left join. This give unpredicable results as this is not
|
|
||||||
// a valid SQL syntax .
|
|
||||||
// $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."element_rang as r ON r.fk_parent = ed.fk_expedition AND r.parenttype = '".$this->element."'";
|
|
||||||
// Getting a "sort order" must be done outside of the request to get values
|
|
||||||
//$sql.= " r.rang";
|
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX."propaldet as d";
|
$sql.= " FROM ".MAIN_DB_PREFIX."propaldet as d";
|
||||||
//$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."element_rang as r ON r.fk_parent = d.fk_propal AND r.parenttype = '".$this->element."'";
|
|
||||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON d.fk_product = p.rowid";
|
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON d.fk_product = p.rowid";
|
||||||
$sql.= " WHERE d.fk_propal = ".$this->id;
|
$sql.= " WHERE d.fk_propal = ".$this->id;
|
||||||
//$sql.= " AND r.fk_child = d.rowid";
|
$sql.= " ORDER by d.rang";
|
||||||
//$sql.= " AND r.childtype = '".$this->element."'";
|
|
||||||
//$sql.= " ORDER by r.rang";
|
|
||||||
|
|
||||||
$result = $this->db->query($sql);
|
$result = $this->db->query($sql);
|
||||||
if ($result)
|
if ($result)
|
||||||
@@ -1579,9 +1567,6 @@ class Propal extends CommonObject
|
|||||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."propaldet WHERE fk_propal = ".$this->id;
|
$sql = "DELETE FROM ".MAIN_DB_PREFIX."propaldet WHERE fk_propal = ".$this->id;
|
||||||
if ( $this->db->query($sql) )
|
if ( $this->db->query($sql) )
|
||||||
{
|
{
|
||||||
// Delete all rang of lines
|
|
||||||
$this->delAllRangOfLines();
|
|
||||||
|
|
||||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."propal WHERE rowid = ".$this->id;
|
$sql = "DELETE FROM ".MAIN_DB_PREFIX."propal WHERE rowid = ".$this->id;
|
||||||
if ( $this->db->query($sql) )
|
if ( $this->db->query($sql) )
|
||||||
{
|
{
|
||||||
@@ -1892,7 +1877,7 @@ class Propal extends CommonObject
|
|||||||
$this->nbtodolate++;
|
$this->nbtodolate++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// TODO Definir regle des propales a facturer en retard
|
// \todo Definir regle des propales a facturer en retard
|
||||||
// if ($mode == 'signed' && ! sizeof($this->FactureListeArray($obj->rowid))) $this->nbtodolate++;
|
// if ($mode == 'signed' && ! sizeof($this->FactureListeArray($obj->rowid))) $this->nbtodolate++;
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
@@ -2093,30 +2078,22 @@ class Propal extends CommonObject
|
|||||||
* \brief Return an array of propal lines
|
* \brief Return an array of propal lines
|
||||||
* \param option 0=No filter on rang, 1=filter on rang <> 0, 2=filter on rang=0
|
* \param option 0=No filter on rang, 1=filter on rang <> 0, 2=filter on rang=0
|
||||||
*/
|
*/
|
||||||
function getLinesArray()
|
function getLinesArray($option=0)
|
||||||
{
|
{
|
||||||
$lines = array();
|
$lines = array();
|
||||||
|
|
||||||
$sql = 'SELECT pt.rowid, pt.description, pt.fk_product, pt.fk_remise_except,';
|
$sql = 'SELECT pt.rowid, pt.description, pt.fk_product, pt.fk_remise_except,';
|
||||||
$sql.= ' pt.qty, pt.tva_tx, pt.remise_percent, pt.subprice, pt.info_bits,';
|
$sql.= ' pt.qty, pt.tva_tx, pt.remise_percent, pt.subprice, pt.info_bits,';
|
||||||
$sql.= ' pt.total_ht, pt.total_tva, pt.total_ttc, pt.marge_tx, pt.marque_tx, pt.pa_ht, pt.special_code,';
|
$sql.= ' pt.total_ht, pt.total_tva, pt.total_ttc, pt.marge_tx, pt.marque_tx, pt.pa_ht, pt.special_code,';
|
||||||
$sql.= ' pt.date_start, pt.date_end, pt.product_type,';
|
$sql.= ' pt.date_start, pt.date_end, pt.product_type, pt.rang,';
|
||||||
$sql.= ' p.label as product_label, p.ref, p.fk_product_type, p.rowid as prodid,';
|
$sql.= ' p.label as product_label, p.ref, p.fk_product_type, p.rowid as prodid,';
|
||||||
$sql.= ' p.description as product_desc';
|
$sql.= ' p.description as product_desc';
|
||||||
// FIXME: There is a bug when using a join with element_rang and
|
|
||||||
// condition outside of left join. This give unpredicable results as this is not
|
|
||||||
// a valid SQL syntax .
|
|
||||||
// $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."element_rang as r ON r.fk_parent = ed.fk_expedition AND r.parenttype = '".$this->element."'";
|
|
||||||
// Getting a "sort order" must be done outside of the request to get values
|
|
||||||
//$sql.= " r.rang";
|
|
||||||
$sql.= ' FROM '.MAIN_DB_PREFIX.'propaldet as pt';
|
$sql.= ' FROM '.MAIN_DB_PREFIX.'propaldet as pt';
|
||||||
//$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."element_rang as r ON r.fk_parent = pt.fk_propal AND r.parenttype = '".$this->element."'";
|
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON pt.fk_product=p.rowid';
|
||||||
//$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON pt.fk_product=p.rowid';
|
|
||||||
$sql.= ' WHERE pt.fk_propal = '.$this->id;
|
$sql.= ' WHERE pt.fk_propal = '.$this->id;
|
||||||
//$sql.= " AND r.fk_child = pt.rowid";
|
if ($option == 1) $sql.= ' AND pt.rang <> 0';
|
||||||
//$sql.= " AND r.childtype = '".$this->element."'";
|
if ($option == 2) $sql.= ' AND pt.rang = 0';
|
||||||
//$sql.= ' ORDER BY r.rang ASC, pt.rowid';
|
$sql.= ' ORDER BY pt.rang ASC, pt.rowid';
|
||||||
$sql.= ' ORDER BY pt.rowid';
|
|
||||||
|
|
||||||
$resql = $this->db->query($sql);
|
$resql = $this->db->query($sql);
|
||||||
if ($resql)
|
if ($resql)
|
||||||
@@ -2172,7 +2149,7 @@ class Propal extends CommonObject
|
|||||||
* \class PropaleLigne
|
* \class PropaleLigne
|
||||||
* \brief Class to manage commercial proposal lines
|
* \brief Class to manage commercial proposal lines
|
||||||
*/
|
*/
|
||||||
class PropaleLigne extends CommonObjectLine
|
class PropaleLigne
|
||||||
{
|
{
|
||||||
var $db;
|
var $db;
|
||||||
var $error;
|
var $error;
|
||||||
@@ -2234,21 +2211,11 @@ class PropaleLigne extends CommonObjectLine
|
|||||||
{
|
{
|
||||||
$sql = 'SELECT pd.rowid, pd.fk_propal, pd.fk_product, pd.description, pd.price, pd.qty, pd.tva_tx,';
|
$sql = 'SELECT pd.rowid, pd.fk_propal, pd.fk_product, pd.description, pd.price, pd.qty, pd.tva_tx,';
|
||||||
$sql.= ' pd.remise, pd.remise_percent, pd.fk_remise_except, pd.subprice,';
|
$sql.= ' pd.remise, pd.remise_percent, pd.fk_remise_except, pd.subprice,';
|
||||||
$sql.= ' pd.info_bits, pd.total_ht, pd.total_tva, pd.total_ttc, pd.marge_tx, pd.marque_tx, pd.special_code,';
|
$sql.= ' pd.info_bits, pd.total_ht, pd.total_tva, pd.total_ttc, pd.marge_tx, pd.marque_tx, pd.special_code, pd.rang,';
|
||||||
$sql.= ' p.ref as product_ref, p.label as product_libelle, p.description as product_desc';
|
$sql.= ' p.ref as product_ref, p.label as product_libelle, p.description as product_desc';
|
||||||
// FIXME: There is a bug when using a join with element_rang and
|
|
||||||
// condition outside of left join. This give unpredicable results as this is not
|
|
||||||
// a valid SQL syntax .
|
|
||||||
// $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."element_rang as r ON r.fk_parent = ed.fk_expedition AND r.parenttype = '".$this->element."'";
|
|
||||||
// Getting a "sort order" must be done outside of the request to get values
|
|
||||||
//$sql.= ' r.rang';
|
|
||||||
$sql.= ' FROM '.MAIN_DB_PREFIX.'propaldet as pd';
|
$sql.= ' FROM '.MAIN_DB_PREFIX.'propaldet as pd';
|
||||||
//$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."element_rang as r ON r.fk_parent = pd.fk_propal AND r.parenttype = '".$this->element."'";
|
|
||||||
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON pd.fk_product = p.rowid';
|
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON pd.fk_product = p.rowid';
|
||||||
$sql.= ' WHERE pd.rowid = '.$rowid;
|
$sql.= ' WHERE pd.rowid = '.$rowid;
|
||||||
//$sql.= " AND r.fk_child = pd.rowid";
|
|
||||||
//$sql.= " AND r.childtype = '".$this->element."'";
|
|
||||||
|
|
||||||
$result = $this->db->query($sql);
|
$result = $this->db->query($sql);
|
||||||
if ($result)
|
if ($result)
|
||||||
{
|
{
|
||||||
@@ -2316,7 +2283,7 @@ class PropaleLigne extends CommonObjectLine
|
|||||||
$sql.= ' (fk_propal, description, fk_product, product_type, fk_remise_except, qty, tva_tx, localtax1_tx, localtax2_tx,';
|
$sql.= ' (fk_propal, description, fk_product, product_type, fk_remise_except, qty, tva_tx, localtax1_tx, localtax2_tx,';
|
||||||
$sql.= ' subprice, remise_percent, ';
|
$sql.= ' subprice, remise_percent, ';
|
||||||
$sql.= ' info_bits, ';
|
$sql.= ' info_bits, ';
|
||||||
$sql.= ' total_ht, total_tva, total_localtax1, total_localtax2, total_ttc, marge_tx, marque_tx, special_code)';
|
$sql.= ' total_ht, total_tva, total_localtax1, total_localtax2, total_ttc, marge_tx, marque_tx, special_code, rang)';
|
||||||
$sql.= " VALUES (".$this->fk_propal.",";
|
$sql.= " VALUES (".$this->fk_propal.",";
|
||||||
$sql.= " '".addslashes($this->desc)."',";
|
$sql.= " '".addslashes($this->desc)."',";
|
||||||
$sql.= " ".($this->fk_product?"'".$this->fk_product."'":"null").",";
|
$sql.= " ".($this->fk_product?"'".$this->fk_product."'":"null").",";
|
||||||
@@ -2339,17 +2306,17 @@ class PropaleLigne extends CommonObjectLine
|
|||||||
if (isset($this->marque_tx)) $sql.= ' '.$this->marque_tx.',';
|
if (isset($this->marque_tx)) $sql.= ' '.$this->marque_tx.',';
|
||||||
else $sql.= ' null,';
|
else $sql.= ' null,';
|
||||||
if (isset($this->special_code)) $sql.= ' '.$this->special_code.',';
|
if (isset($this->special_code)) $sql.= ' '.$this->special_code.',';
|
||||||
else $sql.= ' 0';
|
else $sql.= ' 0,';
|
||||||
|
$sql.= ' '.$this->rang;
|
||||||
$sql.= ')';
|
$sql.= ')';
|
||||||
|
|
||||||
dol_syslog("PropaleLigne::insert sql=$sql");
|
dol_syslog("PropaleLigne::insert sql=$sql");
|
||||||
$resql=$this->db->query($sql);
|
$resql=$this->db->query($sql);
|
||||||
if ($resql)
|
if ($resql)
|
||||||
{
|
{
|
||||||
|
$this->rang=$rangmax;
|
||||||
|
|
||||||
$this->rowid=$this->db->last_insert_id(MAIN_DB_PREFIX.'propaldet');
|
$this->rowid=$this->db->last_insert_id(MAIN_DB_PREFIX.'propaldet');
|
||||||
|
|
||||||
$this->addRangOfLine($this->fk_propal,'propal',$this->rowid,'propal',$this->rang);
|
|
||||||
|
|
||||||
if (! $notrigger)
|
if (! $notrigger)
|
||||||
{
|
{
|
||||||
// Appel des triggers
|
// Appel des triggers
|
||||||
|
|||||||
@@ -27,7 +27,6 @@
|
|||||||
* \version $Id$
|
* \version $Id$
|
||||||
*/
|
*/
|
||||||
require_once(DOL_DOCUMENT_ROOT."/core/class/commonobject.class.php");
|
require_once(DOL_DOCUMENT_ROOT."/core/class/commonobject.class.php");
|
||||||
require_once(DOL_DOCUMENT_ROOT."/core/class/commonobjectline.class.php");
|
|
||||||
require_once(DOL_DOCUMENT_ROOT."/product/class/product.class.php");
|
require_once(DOL_DOCUMENT_ROOT."/product/class/product.class.php");
|
||||||
|
|
||||||
|
|
||||||
@@ -1231,23 +1230,14 @@ class Commande extends CommonObject
|
|||||||
$this->lines=array();
|
$this->lines=array();
|
||||||
|
|
||||||
$sql = 'SELECT l.rowid, l.fk_product, l.product_type, l.fk_commande, l.description, l.price, l.qty, l.tva_tx,';
|
$sql = 'SELECT l.rowid, l.fk_product, l.product_type, l.fk_commande, l.description, l.price, l.qty, l.tva_tx,';
|
||||||
$sql.= ' l.localtax1_tx, l.localtax2_tx, l.fk_remise_except, l.remise_percent, l.subprice, l.marge_tx, l.marque_tx, l.info_bits,';
|
$sql.= ' l.localtax1_tx, l.localtax2_tx, l.fk_remise_except, l.remise_percent, l.subprice, l.marge_tx, l.marque_tx, l.rang, l.info_bits,';
|
||||||
$sql.= ' l.total_ht, l.total_ttc, l.total_tva, l.total_localtax1, l.total_localtax2, l.date_start, l.date_end,';
|
$sql.= ' l.total_ht, l.total_ttc, l.total_tva, l.total_localtax1, l.total_localtax2, l.date_start, l.date_end,';
|
||||||
$sql.= ' p.ref as product_ref, p.description as product_desc, p.fk_product_type, p.label';
|
$sql.= ' p.ref as product_ref, p.description as product_desc, p.fk_product_type, p.label';
|
||||||
// FIXME: There is a bug when using a join with element_rang and
|
|
||||||
// condition outside of left join. This give unpredicable results as this is not
|
|
||||||
// a valid SQL syntax .
|
|
||||||
// $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."element_rang as r ON r.fk_parent = ed.fk_expedition AND r.parenttype = '".$this->element."'";
|
|
||||||
// Getting a "sort order" must be done outside of the request to get values
|
|
||||||
//$sql.= ' r.rang';
|
|
||||||
$sql.= ' FROM '.MAIN_DB_PREFIX.'commandedet as l';
|
$sql.= ' FROM '.MAIN_DB_PREFIX.'commandedet as l';
|
||||||
//$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."element_rang as r ON r.fk_parent = l.fk_commande AND r.parenttype = '".$this->element."'";
|
|
||||||
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON (p.rowid = l.fk_product)';
|
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON (p.rowid = l.fk_product)';
|
||||||
$sql.= ' WHERE l.fk_commande = '.$this->id;
|
$sql.= ' WHERE l.fk_commande = '.$this->id;
|
||||||
//$sql.= " AND r.fk_child = l.rowid";
|
|
||||||
//$sql.= " AND r.childtype = '".$this->element."'";
|
|
||||||
if ($only_product) $sql .= ' AND p.fk_product_type = 0';
|
if ($only_product) $sql .= ' AND p.fk_product_type = 0';
|
||||||
//$sql .= ' ORDER BY r.rang';
|
$sql .= ' ORDER BY l.rang';
|
||||||
|
|
||||||
dol_syslog("Commande::fetch_lines sql=".$sql,LOG_DEBUG);
|
dol_syslog("Commande::fetch_lines sql=".$sql,LOG_DEBUG);
|
||||||
$result = $this->db->query($sql);
|
$result = $this->db->query($sql);
|
||||||
@@ -1449,7 +1439,7 @@ class Commande extends CommonObject
|
|||||||
* \param idligne Id de la ligne a supprimer
|
* \param idligne Id de la ligne a supprimer
|
||||||
* \return int >0 si ok, 0 si rien a supprimer, <0 si ko
|
* \return int >0 si ok, 0 si rien a supprimer, <0 si ko
|
||||||
*/
|
*/
|
||||||
function delete_line($lineid)
|
function delete_line($idligne)
|
||||||
{
|
{
|
||||||
global $user;
|
global $user;
|
||||||
|
|
||||||
@@ -1459,7 +1449,7 @@ class Commande extends CommonObject
|
|||||||
|
|
||||||
$sql = "SELECT fk_product, qty";
|
$sql = "SELECT fk_product, qty";
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX."commandedet";
|
$sql.= " FROM ".MAIN_DB_PREFIX."commandedet";
|
||||||
$sql.= " WHERE rowid = ".$lineid;
|
$sql.= " WHERE rowid = ".$idligne;
|
||||||
|
|
||||||
$result = $this->db->query($sql);
|
$result = $this->db->query($sql);
|
||||||
if ($result)
|
if ($result)
|
||||||
@@ -1474,7 +1464,7 @@ class Commande extends CommonObject
|
|||||||
// Supprime ligne
|
// Supprime ligne
|
||||||
$line = new OrderLine($this->db);
|
$line = new OrderLine($this->db);
|
||||||
|
|
||||||
$line->id = $lineid;
|
$line->id = $idligne;
|
||||||
$line->fk_commande = $this->id; // On en a besoin dans les triggers
|
$line->fk_commande = $this->id; // On en a besoin dans les triggers
|
||||||
|
|
||||||
$result=$line->delete($user);
|
$result=$line->delete($user);
|
||||||
@@ -1483,8 +1473,6 @@ class Commande extends CommonObject
|
|||||||
{
|
{
|
||||||
$result=$this->update_price();
|
$result=$this->update_price();
|
||||||
|
|
||||||
$this->delRangOfLine($lineid, $this->element);
|
|
||||||
|
|
||||||
if ($result > 0)
|
if ($result > 0)
|
||||||
{
|
{
|
||||||
$this->db->commit();
|
$this->db->commit();
|
||||||
@@ -1998,9 +1986,6 @@ class Commande extends CommonObject
|
|||||||
$err++;
|
$err++;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Delete all rang of lines
|
|
||||||
$this->delAllRangOfLines();
|
|
||||||
|
|
||||||
// Delete order
|
// Delete order
|
||||||
$sql = 'DELETE FROM '.MAIN_DB_PREFIX."commande WHERE rowid = ".$this->id;
|
$sql = 'DELETE FROM '.MAIN_DB_PREFIX."commande WHERE rowid = ".$this->id;
|
||||||
dol_syslog("Commande::delete sql=".$sql);
|
dol_syslog("Commande::delete sql=".$sql);
|
||||||
@@ -2415,31 +2400,23 @@ class Commande extends CommonObject
|
|||||||
* \brief Return an array of order lines
|
* \brief Return an array of order lines
|
||||||
* \param option 0=No filter on rang, 1=filter on rang <> 0, 2=filter on rang=0
|
* \param option 0=No filter on rang, 1=filter on rang <> 0, 2=filter on rang=0
|
||||||
*/
|
*/
|
||||||
function getLinesArray()
|
function getLinesArray($option=0)
|
||||||
{
|
{
|
||||||
$lines = array();
|
$lines = array();
|
||||||
|
|
||||||
$sql = 'SELECT l.rowid, l.fk_product, l.product_type, l.description, l.price, l.qty, l.tva_tx, ';
|
$sql = 'SELECT l.rowid, l.fk_product, l.product_type, l.description, l.price, l.qty, l.tva_tx, ';
|
||||||
$sql.= ' l.fk_remise_except, l.remise_percent, l.subprice, l.info_bits,';
|
$sql.= ' l.fk_remise_except, l.remise_percent, l.subprice, l.info_bits,l.rang,';
|
||||||
$sql.= ' l.total_ht, l.total_tva, l.total_ttc,';
|
$sql.= ' l.total_ht, l.total_tva, l.total_ttc,';
|
||||||
$sql.= ' l.date_start,';
|
$sql.= ' l.date_start,';
|
||||||
$sql.= ' l.date_end,';
|
$sql.= ' l.date_end,';
|
||||||
$sql.= ' p.label as product_label, p.ref, p.fk_product_type, p.rowid as prodid, ';
|
$sql.= ' p.label as product_label, p.ref, p.fk_product_type, p.rowid as prodid, ';
|
||||||
$sql.= ' p.description as product_desc';
|
$sql.= ' p.description as product_desc';
|
||||||
// FIXME: There is a bug when using a join with element_rang and
|
|
||||||
// condition outside of left join. This give unpredicable results as this is not
|
|
||||||
// a valid SQL syntax .
|
|
||||||
// $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."element_rang as r ON r.fk_parent = ed.fk_expedition AND r.parenttype = '".$this->element."'";
|
|
||||||
// Getting a "sort order" must be done outside of the request to get values
|
|
||||||
//$sql.= ' r.rang';
|
|
||||||
$sql.= ' FROM '.MAIN_DB_PREFIX.'commandedet as l';
|
$sql.= ' FROM '.MAIN_DB_PREFIX.'commandedet as l';
|
||||||
//$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."element_rang as r ON r.fk_parent = l.fk_commande AND r.parenttype = '".$this->element."'";
|
|
||||||
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON l.fk_product=p.rowid';
|
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON l.fk_product=p.rowid';
|
||||||
$sql.= ' WHERE l.fk_commande = '.$this->id;
|
$sql.= ' WHERE l.fk_commande = '.$this->id;
|
||||||
//$sql.= " AND r.fk_child = l.rowid";
|
if ($option == 1) $sql.= ' AND l.rang <> 0';
|
||||||
//$sql.= " AND r.childtype = '".$this->element."'";
|
if ($option == 2) $sql.= ' AND l.rang = 0';
|
||||||
$sql.= ' ORDER BY r.rang ASC, l.rowid';
|
$sql.= ' ORDER BY l.rang ASC, l.rowid';
|
||||||
$sql.= ' ORDER BY l.rowid';
|
|
||||||
|
|
||||||
$resql = $this->db->query($sql);
|
$resql = $this->db->query($sql);
|
||||||
if ($resql)
|
if ($resql)
|
||||||
@@ -2492,7 +2469,7 @@ class Commande extends CommonObject
|
|||||||
* \class OrderLine
|
* \class OrderLine
|
||||||
* \brief Classe de gestion des lignes de commande
|
* \brief Classe de gestion des lignes de commande
|
||||||
*/
|
*/
|
||||||
class OrderLine extends CommonObjectLine
|
class OrderLine
|
||||||
{
|
{
|
||||||
var $db;
|
var $db;
|
||||||
var $error;
|
var $error;
|
||||||
@@ -2553,22 +2530,12 @@ class OrderLine extends CommonObjectLine
|
|||||||
{
|
{
|
||||||
$sql = 'SELECT cd.rowid, cd.fk_commande, cd.fk_product, cd.product_type, cd.description, cd.price, cd.qty, cd.tva_tx, cd.localtax1_tx, cd.localtax2_tx,';
|
$sql = 'SELECT cd.rowid, cd.fk_commande, cd.fk_product, cd.product_type, cd.description, cd.price, cd.qty, cd.tva_tx, cd.localtax1_tx, cd.localtax2_tx,';
|
||||||
$sql.= ' cd.remise, cd.remise_percent, cd.fk_remise_except, cd.subprice,';
|
$sql.= ' cd.remise, cd.remise_percent, cd.fk_remise_except, cd.subprice,';
|
||||||
$sql.= ' cd.info_bits, cd.total_ht, cd.total_tva, cd.total_localtax1, cd.total_localtax2, cd.total_ttc, cd.marge_tx, cd.marque_tx,';
|
$sql.= ' cd.info_bits, cd.total_ht, cd.total_tva, cd.total_localtax1, cd.total_localtax2, cd.total_ttc, cd.marge_tx, cd.marque_tx, cd.rang,';
|
||||||
$sql.= ' p.ref as product_ref, p.label as product_libelle, p.description as product_desc,';
|
$sql.= ' p.ref as product_ref, p.label as product_libelle, p.description as product_desc,';
|
||||||
$sql.= ' cd.date_start, cd.date_end';
|
$sql.= ' cd.date_start, cd.date_end';
|
||||||
// FIXME: There is a bug when using a join with element_rang and
|
|
||||||
// condition outside of left join. This give unpredicable results as this is not
|
|
||||||
// a valid SQL syntax .
|
|
||||||
// $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."element_rang as r ON r.fk_parent = ed.fk_expedition AND r.parenttype = '".$this->element."'";
|
|
||||||
// Getting a "sort order" must be done outside of the request to get values
|
|
||||||
//$sql.= ' r.rang';
|
|
||||||
$sql.= ' FROM '.MAIN_DB_PREFIX.'commandedet as cd';
|
$sql.= ' FROM '.MAIN_DB_PREFIX.'commandedet as cd';
|
||||||
//$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."element_rang as r ON r.fk_parent = cd.fk_commande AND r.parenttype = '".$this->element."'";
|
|
||||||
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON cd.fk_product = p.rowid';
|
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON cd.fk_product = p.rowid';
|
||||||
$sql.= ' WHERE cd.rowid = '.$rowid;
|
$sql.= ' WHERE cd.rowid = '.$rowid;
|
||||||
//$sql.= " AND r.fk_child = cd.rowid";
|
|
||||||
//$sql.= " AND r.childtype = '".$this->element."'";
|
|
||||||
|
|
||||||
$result = $this->db->query($sql);
|
$result = $this->db->query($sql);
|
||||||
if ($result)
|
if ($result)
|
||||||
{
|
{
|
||||||
@@ -2673,7 +2640,7 @@ class OrderLine extends CommonObjectLine
|
|||||||
$sql = 'INSERT INTO '.MAIN_DB_PREFIX.'commandedet';
|
$sql = 'INSERT INTO '.MAIN_DB_PREFIX.'commandedet';
|
||||||
$sql.= ' (fk_commande, description, qty, tva_tx, localtax1_tx, localtax2_tx,';
|
$sql.= ' (fk_commande, description, qty, tva_tx, localtax1_tx, localtax2_tx,';
|
||||||
$sql.= ' fk_product, product_type, remise_percent, subprice, price, remise, fk_remise_except,';
|
$sql.= ' fk_product, product_type, remise_percent, subprice, price, remise, fk_remise_except,';
|
||||||
$sql.= ' marge_tx, marque_tx,';
|
$sql.= ' rang, marge_tx, marque_tx,';
|
||||||
// Updated by Matelli (See http://matelli.fr/showcases/patchs-dolibarr/add-dates-in-order-lines.html)
|
// Updated by Matelli (See http://matelli.fr/showcases/patchs-dolibarr/add-dates-in-order-lines.html)
|
||||||
// Insert in the database the start and end dates
|
// Insert in the database the start and end dates
|
||||||
$sql.= ' info_bits, total_ht, total_tva, total_localtax1, total_localtax2, total_ttc, date_start, date_end)';
|
$sql.= ' info_bits, total_ht, total_tva, total_localtax1, total_localtax2, total_ttc, date_start, date_end)';
|
||||||
@@ -2692,6 +2659,7 @@ class OrderLine extends CommonObjectLine
|
|||||||
$sql.= " '".price2num($this->remise)."',";
|
$sql.= " '".price2num($this->remise)."',";
|
||||||
if ($this->fk_remise_except) $sql.= $this->fk_remise_except.",";
|
if ($this->fk_remise_except) $sql.= $this->fk_remise_except.",";
|
||||||
else $sql.= 'null,';
|
else $sql.= 'null,';
|
||||||
|
$sql.= ' '.$this->rang.',';
|
||||||
if (isset($this->marge_tx)) $sql.= ' '.$this->marge_tx.',';
|
if (isset($this->marge_tx)) $sql.= ' '.$this->marge_tx.',';
|
||||||
else $sql.= ' null,';
|
else $sql.= ' null,';
|
||||||
if (isset($this->marque_tx)) $sql.= ' '.$this->marque_tx.',';
|
if (isset($this->marque_tx)) $sql.= ' '.$this->marque_tx.',';
|
||||||
@@ -2716,8 +2684,6 @@ class OrderLine extends CommonObjectLine
|
|||||||
{
|
{
|
||||||
$this->rowid=$this->db->last_insert_id(MAIN_DB_PREFIX.'commandedet');
|
$this->rowid=$this->db->last_insert_id(MAIN_DB_PREFIX.'commandedet');
|
||||||
|
|
||||||
$this->addRangOfLine($this->fk_commande,'commande',$this->rowid,'commande',$this->rang);
|
|
||||||
|
|
||||||
if (! $notrigger)
|
if (! $notrigger)
|
||||||
{
|
{
|
||||||
// Appel des triggers
|
// Appel des triggers
|
||||||
|
|||||||
@@ -136,7 +136,6 @@ if ($_REQUEST['action'] == 'confirm_delete' && $_REQUEST['confirm'] == 'yes')
|
|||||||
$commande = new Commande($db);
|
$commande = new Commande($db);
|
||||||
$commande->fetch($comid);
|
$commande->fetch($comid);
|
||||||
$result=$commande->delete($user);
|
$result=$commande->delete($user);
|
||||||
|
|
||||||
if ($result > 0)
|
if ($result > 0)
|
||||||
{
|
{
|
||||||
Header('Location: index.php');
|
Header('Location: index.php');
|
||||||
@@ -161,9 +160,6 @@ if ($_REQUEST['action'] == 'confirm_deleteline' && $_REQUEST['confirm'] == 'yes'
|
|||||||
$result = $commande->delete_line($_GET['lineid']);
|
$result = $commande->delete_line($_GET['lineid']);
|
||||||
if ($result > 0)
|
if ($result > 0)
|
||||||
{
|
{
|
||||||
// reorder lines
|
|
||||||
$commande->line_order(true);
|
|
||||||
|
|
||||||
// Define output language
|
// Define output language
|
||||||
$outputlangs = $langs;
|
$outputlangs = $langs;
|
||||||
$newlang='';
|
$newlang='';
|
||||||
@@ -1801,7 +1797,7 @@ else
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{*/
|
{*/
|
||||||
print '<a class="butAction" href="'.DOL_URL_ROOT.'/expedition/shipment.php?id='.$commande->id.'">'.$langs->trans('ShipProduct').'</a>';
|
print '<a class="butAction" href="'.DOL_URL_ROOT.'/expedition/shipment.php?id='.$comid.'">'.$langs->trans('ShipProduct').'</a>';
|
||||||
//}
|
//}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -396,19 +396,10 @@ if ($id > 0 || ! empty($ref))
|
|||||||
$sql.= ' l.date_end,';
|
$sql.= ' l.date_end,';
|
||||||
$sql.= ' p.label as product_label, p.ref, p.fk_product_type, p.rowid as prodid,';
|
$sql.= ' p.label as product_label, p.ref, p.fk_product_type, p.rowid as prodid,';
|
||||||
$sql.= ' p.description as product_desc';
|
$sql.= ' p.description as product_desc';
|
||||||
// FIXME: There is a bug when using a join with element_rang and
|
|
||||||
// condition outside of left join. This give unpredicable results as this is not
|
|
||||||
// a valid SQL syntax .
|
|
||||||
// $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."element_rang as r ON r.fk_parent = ed.fk_expedition AND r.parenttype = '".$this->element."'";
|
|
||||||
// Getting a "sort order" must be done outside of the request to get values
|
|
||||||
$sql.= ' FROM '.MAIN_DB_PREFIX."commandedet as l";
|
$sql.= ' FROM '.MAIN_DB_PREFIX."commandedet as l";
|
||||||
//$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."element_rang as r ON r.fk_parent = l.fk_commande AND r.parenttype = '".$commande->element."'";
|
|
||||||
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON l.fk_product=p.rowid';
|
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON l.fk_product=p.rowid';
|
||||||
$sql.= " WHERE l.fk_commande = ".$commande->id;
|
$sql.= " WHERE l.fk_commande = ".$commande->id;
|
||||||
//$sql.= " AND r.fk_child = l.rowid";
|
$sql.= " ORDER BY l.rang, l.rowid";
|
||||||
//$sql.= " AND r.childtype = '".$commande->element."'";
|
|
||||||
//$sql.= " ORDER BY r.rang, l.rowid";
|
|
||||||
$sql.=" ORDER BY l.rowid";
|
|
||||||
|
|
||||||
$resql = $db->query($sql);
|
$resql = $db->query($sql);
|
||||||
if ($resql)
|
if ($resql)
|
||||||
|
|||||||
@@ -148,9 +148,6 @@ if ($_REQUEST['action'] == 'confirm_deleteproductline' && $_REQUEST['confirm'] =
|
|||||||
$result = $fac->deleteline($_GET['rowid'], $user);
|
$result = $fac->deleteline($_GET['rowid'], $user);
|
||||||
if ($result > 0)
|
if ($result > 0)
|
||||||
{
|
{
|
||||||
// reorder lines
|
|
||||||
$fac->line_order(true);
|
|
||||||
|
|
||||||
// Define output language
|
// Define output language
|
||||||
$outputlangs = $langs;
|
$outputlangs = $langs;
|
||||||
$newlang='';
|
$newlang='';
|
||||||
@@ -1769,19 +1766,10 @@ if ($_GET['action'] == 'create')
|
|||||||
$sql = 'SELECT pt.rowid, pt.description, pt.fk_remise_except,';
|
$sql = 'SELECT pt.rowid, pt.description, pt.fk_remise_except,';
|
||||||
$sql.= ' pt.qty, pt.tva_tx, pt.remise_percent, pt.subprice, pt.product_type, pt.info_bits,';
|
$sql.= ' pt.qty, pt.tva_tx, pt.remise_percent, pt.subprice, pt.product_type, pt.info_bits,';
|
||||||
$sql.= ' p.label as product, p.ref, p.fk_product_type, p.rowid as prodid';
|
$sql.= ' p.label as product, p.ref, p.fk_product_type, p.rowid as prodid';
|
||||||
// FIXME: There is a bug when using a join with element_rang and
|
|
||||||
// condition outside of left join. This give unpredicable results as this is not
|
|
||||||
// a valid SQL syntax .
|
|
||||||
// $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."element_rang as r ON r.fk_parent = ed.fk_expedition AND r.parenttype = '".$this->element."'";
|
|
||||||
// Getting a "sort order" must be done outside of the request to get values
|
|
||||||
$sql.= ' FROM '.MAIN_DB_PREFIX.'propaldet as pt';
|
$sql.= ' FROM '.MAIN_DB_PREFIX.'propaldet as pt';
|
||||||
//$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."element_rang as r ON r.fk_parent = pt.fk_propal AND r.parenttype = '".$object->element."'";
|
|
||||||
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON pt.fk_product = p.rowid';
|
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON pt.fk_product = p.rowid';
|
||||||
$sql.= ' WHERE pt.fk_propal = '.$object->id;
|
$sql.= ' WHERE pt.fk_propal = '.$object->id;
|
||||||
//$sql.= " AND r.fk_child = pt.rowid";
|
$sql.= ' ORDER BY pt.rang ASC, pt.rowid';
|
||||||
//$sql.= " AND r.childtype = '".$object->element."'";
|
|
||||||
//$sql.= ' ORDER BY r.rang ASC, pt.rowid';
|
|
||||||
$sql.=" ORDER BY pt.rowid";
|
|
||||||
}
|
}
|
||||||
// TODO deplacer dans la classe
|
// TODO deplacer dans la classe
|
||||||
if ($_GET['origin'] == 'commande')
|
if ($_GET['origin'] == 'commande')
|
||||||
@@ -1792,19 +1780,10 @@ if ($_GET['action'] == 'create')
|
|||||||
$sql.= ' pt.qty, pt.tva_tx, pt.remise_percent, pt.subprice, pt.product_type, pt.info_bits,';
|
$sql.= ' pt.qty, pt.tva_tx, pt.remise_percent, pt.subprice, pt.product_type, pt.info_bits,';
|
||||||
$sql.= ' pt.date_start as date_debut_prevue, pt.date_end as date_fin_prevue,';
|
$sql.= ' pt.date_start as date_debut_prevue, pt.date_end as date_fin_prevue,';
|
||||||
$sql.= ' p.label as product, p.ref, p.fk_product_type, p.rowid as prodid';
|
$sql.= ' p.label as product, p.ref, p.fk_product_type, p.rowid as prodid';
|
||||||
// FIXME: There is a bug when using a join with element_rang and
|
|
||||||
// condition outside of left join. This give unpredicable results as this is not
|
|
||||||
// a valid SQL syntax .
|
|
||||||
// $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."element_rang as r ON r.fk_parent = ed.fk_expedition AND r.parenttype = '".$this->element."'";
|
|
||||||
// Getting a "sort order" must be done outside of the request to get values
|
|
||||||
$sql.= ' FROM '.MAIN_DB_PREFIX.'commandedet as pt';
|
$sql.= ' FROM '.MAIN_DB_PREFIX.'commandedet as pt';
|
||||||
//$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."element_rang as r ON r.fk_parent = pt.fk_commande AND r.parenttype = '".$object->element."'";
|
|
||||||
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON pt.fk_product = p.rowid';
|
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON pt.fk_product = p.rowid';
|
||||||
$sql.= ' WHERE pt.fk_commande = '.$object->id;
|
$sql.= ' WHERE pt.fk_commande = '.$object->id;
|
||||||
//$sql.= " AND r.fk_child = pt.rowid";
|
$sql.= ' ORDER BY pt.rowid ASC';
|
||||||
//$sql.= " AND r.childtype = '".$object->element."'";
|
|
||||||
//$sql.= ' ORDER BY r.rang ASC, pt.rowid';
|
|
||||||
$sql.=" ORDER BY pt.rowid";
|
|
||||||
}
|
}
|
||||||
// TODO deplacer dans la classe
|
// TODO deplacer dans la classe
|
||||||
if ($_GET['origin'] == 'contrat')
|
if ($_GET['origin'] == 'contrat')
|
||||||
@@ -2667,13 +2646,9 @@ else
|
|||||||
$sql.= ' p.ref as product_ref, p.fk_product_type, p.label as product_label,';
|
$sql.= ' p.ref as product_ref, p.fk_product_type, p.label as product_label,';
|
||||||
$sql.= ' p.description as product_desc';
|
$sql.= ' p.description as product_desc';
|
||||||
$sql.= ' FROM '.MAIN_DB_PREFIX.'facturedet as l';
|
$sql.= ' FROM '.MAIN_DB_PREFIX.'facturedet as l';
|
||||||
//$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."element_rang as r ON r.fk_parent = l.fk_facture AND r.parenttype = '".$fac->element."'";
|
|
||||||
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product p ON l.fk_product=p.rowid';
|
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product p ON l.fk_product=p.rowid';
|
||||||
$sql.= ' WHERE l.fk_facture = '.$fac->id;
|
$sql.= ' WHERE l.fk_facture = '.$fac->id;
|
||||||
//$sql.= " AND r.fk_child = l.rowid";
|
$sql.= ' ORDER BY l.rang ASC, l.rowid';
|
||||||
//$sql.= " AND r.childtype = '".$fac->element."'";
|
|
||||||
$sql.= ' ORDER BY r.rang ASC, l.rowid';
|
|
||||||
$sql.= " ORDER BY l.rowid";
|
|
||||||
|
|
||||||
$resql = $db->query($sql);
|
$resql = $db->query($sql);
|
||||||
if ($resql)
|
if ($resql)
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
* Copyright (C) 2004 Sebastien Di Cintio <sdicintio@ressource-toi.org>
|
* Copyright (C) 2004 Sebastien Di Cintio <sdicintio@ressource-toi.org>
|
||||||
* Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be>
|
* Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be>
|
||||||
* Copyright (C) 2005 Marc Barilley / Ocebo <marc@ocebo.com>
|
* Copyright (C) 2005 Marc Barilley / Ocebo <marc@ocebo.com>
|
||||||
* Copyright (C) 2005-2010 Regis Houssin <regis@dolibarr.fr>
|
* Copyright (C) 2005-2009 Regis Houssin <regis@dolibarr.fr>
|
||||||
* Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr>
|
* Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr>
|
||||||
* Copyright (C) 2007 Franky Van Liedekerke <franky.van.liedekerke@telenet.be>
|
* Copyright (C) 2007 Franky Van Liedekerke <franky.van.liedekerke@telenet.be>
|
||||||
* Copyright (C) 2010 Juanjo Menent <jmenent@2byte.es>
|
* Copyright (C) 2010 Juanjo Menent <jmenent@2byte.es>
|
||||||
@@ -32,7 +32,6 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
require_once(DOL_DOCUMENT_ROOT ."/core/class/commonobject.class.php");
|
require_once(DOL_DOCUMENT_ROOT ."/core/class/commonobject.class.php");
|
||||||
require_once(DOL_DOCUMENT_ROOT ."/core/class/commonobjectline.class.php");
|
|
||||||
require_once(DOL_DOCUMENT_ROOT ."/product/class/product.class.php");
|
require_once(DOL_DOCUMENT_ROOT ."/product/class/product.class.php");
|
||||||
require_once(DOL_DOCUMENT_ROOT ."/societe/class/client.class.php");
|
require_once(DOL_DOCUMENT_ROOT ."/societe/class/client.class.php");
|
||||||
|
|
||||||
@@ -675,19 +674,10 @@ class Facture extends CommonObject
|
|||||||
$sql.= ' l.date_start as date_start, l.date_end as date_end,';
|
$sql.= ' l.date_start as date_start, l.date_end as date_end,';
|
||||||
$sql.= ' l.info_bits, l.total_ht, l.total_tva, l.total_localtax1, l.total_localtax2, l.total_ttc, l.fk_code_ventilation, l.fk_export_compta,';
|
$sql.= ' l.info_bits, l.total_ht, l.total_tva, l.total_localtax1, l.total_localtax2, l.total_ttc, l.fk_code_ventilation, l.fk_export_compta,';
|
||||||
$sql.= ' p.ref as product_ref, p.fk_product_type as fk_product_type, p.label as label, p.description as product_desc';
|
$sql.= ' p.ref as product_ref, p.fk_product_type as fk_product_type, p.label as label, p.description as product_desc';
|
||||||
// FIXME: There is a bug when using a join with element_rang and
|
|
||||||
// condition outside of left join. This give unpredicable results as this is not
|
|
||||||
// a valid SQL syntax .
|
|
||||||
// $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."element_rang as r ON r.fk_parent = ed.fk_expedition AND r.parenttype = '".$this->element."'";
|
|
||||||
// Getting a "sort order" must be done outside of the request to get values
|
|
||||||
//$sql.= ' r.rang';
|
|
||||||
$sql.= ' FROM '.MAIN_DB_PREFIX.'facturedet as l';
|
$sql.= ' FROM '.MAIN_DB_PREFIX.'facturedet as l';
|
||||||
//$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."element_rang as r ON r.fk_parent = l.fk_facture AND r.parenttype = '".$this->element."'";
|
|
||||||
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON l.fk_product = p.rowid';
|
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON l.fk_product = p.rowid';
|
||||||
$sql.= ' WHERE l.fk_facture = '.$this->id;
|
$sql.= ' WHERE l.fk_facture = '.$this->id;
|
||||||
//$sql.= " AND r.fk_child = l.rowid";
|
$sql.= ' ORDER BY l.rang';
|
||||||
//$sql.= " AND r.childtype = '".$this->element."'";
|
|
||||||
//$sql.= ' ORDER BY r.rang';
|
|
||||||
|
|
||||||
dol_syslog('Facture::fetch_lines sql='.$sql, LOG_DEBUG);
|
dol_syslog('Facture::fetch_lines sql='.$sql, LOG_DEBUG);
|
||||||
$result = $this->db->query($sql);
|
$result = $this->db->query($sql);
|
||||||
@@ -727,7 +717,6 @@ class Facture extends CommonObject
|
|||||||
$faclig->total_ttc = $objp->total_ttc;
|
$faclig->total_ttc = $objp->total_ttc;
|
||||||
$faclig->export_compta = $objp->fk_export_compta;
|
$faclig->export_compta = $objp->fk_export_compta;
|
||||||
$faclig->code_ventilation = $objp->fk_code_ventilation;
|
$faclig->code_ventilation = $objp->fk_code_ventilation;
|
||||||
$faclig->rang = $objp->rang;
|
|
||||||
|
|
||||||
// Ne plus utiliser
|
// Ne plus utiliser
|
||||||
$faclig->price = $objp->price;
|
$faclig->price = $objp->price;
|
||||||
@@ -1029,24 +1018,12 @@ class Facture extends CommonObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
$sql = 'DELETE FROM '.MAIN_DB_PREFIX.'facturedet WHERE fk_facture = '.$rowid;
|
$sql = 'DELETE FROM '.MAIN_DB_PREFIX.'facturedet WHERE fk_facture = '.$rowid;
|
||||||
if ($this->db->query($sql))
|
if ($this->db->query($sql) && $this->delete_linked_contact())
|
||||||
{
|
{
|
||||||
// Delete all rang of lines
|
|
||||||
$this->delAllRangOfLines();
|
|
||||||
|
|
||||||
$sql = 'DELETE FROM '.MAIN_DB_PREFIX.'facture WHERE rowid = '.$rowid;
|
$sql = 'DELETE FROM '.MAIN_DB_PREFIX.'facture WHERE rowid = '.$rowid;
|
||||||
$resql=$this->db->query($sql);
|
$resql=$this->db->query($sql);
|
||||||
if ($resql)
|
if ($resql)
|
||||||
{
|
{
|
||||||
// Delete linked contacts
|
|
||||||
$res = $this->delete_linked_contact();
|
|
||||||
if ($res < 0)
|
|
||||||
{
|
|
||||||
$this->error='ErrorFailToDeleteLinkedContact';
|
|
||||||
$this->db->rollback();
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Appel des triggers
|
// Appel des triggers
|
||||||
include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php");
|
include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php");
|
||||||
$interface=new Interfaces($this->db);
|
$interface=new Interfaces($this->db);
|
||||||
@@ -1857,11 +1834,11 @@ class Facture extends CommonObject
|
|||||||
* \param user User object
|
* \param user User object
|
||||||
* \return int <0 if KO, >0 if OK
|
* \return int <0 if KO, >0 if OK
|
||||||
*/
|
*/
|
||||||
function deleteline($lineid, $user='')
|
function deleteline($rowid, $user='')
|
||||||
{
|
{
|
||||||
global $langs, $conf;
|
global $langs, $conf;
|
||||||
|
|
||||||
dol_syslog("Facture::Deleteline rowid=".$lineid, LOG_DEBUG);
|
dol_syslog("Facture::Deleteline rowid=".$rowid, LOG_DEBUG);
|
||||||
|
|
||||||
if (! $this->brouillon)
|
if (! $this->brouillon)
|
||||||
{
|
{
|
||||||
@@ -1874,7 +1851,7 @@ class Facture extends CommonObject
|
|||||||
// Libere remise liee a ligne de facture
|
// Libere remise liee a ligne de facture
|
||||||
$sql = 'UPDATE '.MAIN_DB_PREFIX.'societe_remise_except';
|
$sql = 'UPDATE '.MAIN_DB_PREFIX.'societe_remise_except';
|
||||||
$sql.= ' SET fk_facture_line = NULL';
|
$sql.= ' SET fk_facture_line = NULL';
|
||||||
$sql.= ' WHERE fk_facture_line = '.$lineid;
|
$sql.= ' WHERE fk_facture_line = '.$rowid;
|
||||||
|
|
||||||
dol_syslog("Facture::Deleteline sql=".$sql);
|
dol_syslog("Facture::Deleteline sql=".$sql);
|
||||||
$result = $this->db->query($sql);
|
$result = $this->db->query($sql);
|
||||||
@@ -1888,7 +1865,7 @@ class Facture extends CommonObject
|
|||||||
|
|
||||||
// Efface ligne de facture
|
// Efface ligne de facture
|
||||||
$sql = 'DELETE FROM '.MAIN_DB_PREFIX.'facturedet';
|
$sql = 'DELETE FROM '.MAIN_DB_PREFIX.'facturedet';
|
||||||
$sql.= ' WHERE rowid = '.$lineid;
|
$sql.= ' WHERE rowid = '.$rowid;
|
||||||
|
|
||||||
dol_syslog("Facture::Deleteline sql=".$sql);
|
dol_syslog("Facture::Deleteline sql=".$sql);
|
||||||
$result = $this->db->query($sql);
|
$result = $this->db->query($sql);
|
||||||
@@ -1902,8 +1879,6 @@ class Facture extends CommonObject
|
|||||||
|
|
||||||
$result=$this->update_price();
|
$result=$this->update_price();
|
||||||
|
|
||||||
$this->delRangOfLine($lineid, $this->element);
|
|
||||||
|
|
||||||
// Appel des triggers
|
// Appel des triggers
|
||||||
include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php");
|
include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php");
|
||||||
$interface=new Interfaces($this->db);
|
$interface=new Interfaces($this->db);
|
||||||
@@ -2920,7 +2895,7 @@ class Facture extends CommonObject
|
|||||||
* \brief Classe permettant la gestion des lignes de factures
|
* \brief Classe permettant la gestion des lignes de factures
|
||||||
* \remarks Gere des lignes de la table llx_facturedet
|
* \remarks Gere des lignes de la table llx_facturedet
|
||||||
*/
|
*/
|
||||||
class FactureLigne extends CommonObjectLine
|
class FactureLigne
|
||||||
{
|
{
|
||||||
var $db;
|
var $db;
|
||||||
var $error;
|
var $error;
|
||||||
@@ -2990,17 +2965,12 @@ class FactureLigne extends CommonObjectLine
|
|||||||
$sql = 'SELECT fd.rowid, fd.fk_facture, fd.fk_product, fd.product_type, fd.description, fd.price, fd.qty, fd.tva_tx,';
|
$sql = 'SELECT fd.rowid, fd.fk_facture, fd.fk_product, fd.product_type, fd.description, fd.price, fd.qty, fd.tva_tx,';
|
||||||
$sql.= ' fd.localtax1_tx, fd. localtax2_tx, fd.remise, fd.remise_percent, fd.fk_remise_except, fd.subprice,';
|
$sql.= ' fd.localtax1_tx, fd. localtax2_tx, fd.remise, fd.remise_percent, fd.fk_remise_except, fd.subprice,';
|
||||||
$sql.= ' fd.date_start as date_start, fd.date_end as date_end,';
|
$sql.= ' fd.date_start as date_start, fd.date_end as date_end,';
|
||||||
$sql.= ' fd.info_bits, fd.total_ht, fd.total_tva, fd.total_ttc,';
|
$sql.= ' fd.info_bits, fd.total_ht, fd.total_tva, fd.total_ttc, fd.rang,';
|
||||||
$sql.= ' fd.fk_code_ventilation, fd.fk_export_compta,';
|
$sql.= ' fd.fk_code_ventilation, fd.fk_export_compta,';
|
||||||
$sql.= ' p.ref as product_ref, p.label as product_libelle, p.description as product_desc,';
|
$sql.= ' p.ref as product_ref, p.label as product_libelle, p.description as product_desc';
|
||||||
$sql.= ' r.rang';
|
|
||||||
$sql.= ' FROM '.MAIN_DB_PREFIX.'facturedet as fd';
|
$sql.= ' FROM '.MAIN_DB_PREFIX.'facturedet as fd';
|
||||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."element_rang as r ON r.fk_parent = fd.fk_facture AND r.parenttype = '".$this->element."'";
|
|
||||||
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON fd.fk_product = p.rowid';
|
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON fd.fk_product = p.rowid';
|
||||||
$sql.= ' WHERE fd.rowid = '.$rowid;
|
$sql.= ' WHERE fd.rowid = '.$rowid;
|
||||||
$sql.= " AND r.fk_child = fd.rowid";
|
|
||||||
$sql.= " AND r.childtype = '".$this->element."'";
|
|
||||||
|
|
||||||
$result = $this->db->query($sql);
|
$result = $this->db->query($sql);
|
||||||
if ($result)
|
if ($result)
|
||||||
{
|
{
|
||||||
@@ -3079,6 +3049,7 @@ class FactureLigne extends CommonObjectLine
|
|||||||
$sql.= ' (fk_facture, description, qty, tva_tx, localtax1_tx, localtax2_tx,';
|
$sql.= ' (fk_facture, description, qty, tva_tx, localtax1_tx, localtax2_tx,';
|
||||||
$sql.= ' fk_product, product_type, remise_percent, subprice, price, remise, fk_remise_except,';
|
$sql.= ' fk_product, product_type, remise_percent, subprice, price, remise, fk_remise_except,';
|
||||||
$sql.= ' date_start, date_end, fk_code_ventilation, fk_export_compta, ';
|
$sql.= ' date_start, date_end, fk_code_ventilation, fk_export_compta, ';
|
||||||
|
$sql.= ' rang,';
|
||||||
$sql.= ' info_bits, total_ht, total_tva, total_localtax1, total_localtax2, total_ttc)';
|
$sql.= ' info_bits, total_ht, total_tva, total_localtax1, total_localtax2, total_ttc)';
|
||||||
$sql.= " VALUES (".$this->fk_facture.",";
|
$sql.= " VALUES (".$this->fk_facture.",";
|
||||||
$sql.= " '".addslashes($this->desc)."',";
|
$sql.= " '".addslashes($this->desc)."',";
|
||||||
@@ -3101,6 +3072,7 @@ class FactureLigne extends CommonObjectLine
|
|||||||
else { $sql.='null,'; }
|
else { $sql.='null,'; }
|
||||||
$sql.= ' '.$this->fk_code_ventilation.',';
|
$sql.= ' '.$this->fk_code_ventilation.',';
|
||||||
$sql.= ' '.$this->fk_export_compta.',';
|
$sql.= ' '.$this->fk_export_compta.',';
|
||||||
|
$sql.= ' '.$this->rang.',';
|
||||||
$sql.= " '".$this->info_bits."',";
|
$sql.= " '".$this->info_bits."',";
|
||||||
$sql.= " ".price2num($this->total_ht).",";
|
$sql.= " ".price2num($this->total_ht).",";
|
||||||
$sql.= " ".price2num($this->total_tva).",";
|
$sql.= " ".price2num($this->total_tva).",";
|
||||||
@@ -3115,8 +3087,6 @@ class FactureLigne extends CommonObjectLine
|
|||||||
{
|
{
|
||||||
$this->rowid=$this->db->last_insert_id(MAIN_DB_PREFIX.'facturedet');
|
$this->rowid=$this->db->last_insert_id(MAIN_DB_PREFIX.'facturedet');
|
||||||
|
|
||||||
$this->addRangOfLine($this->fk_facture,'facture',$this->rowid,'facture',$this->rang);
|
|
||||||
|
|
||||||
// Si fk_remise_except defini, on lie la remise a la facture
|
// Si fk_remise_except defini, on lie la remise a la facture
|
||||||
// ce qui la flague comme "consommee".
|
// ce qui la flague comme "consommee".
|
||||||
if ($this->fk_remise_except)
|
if ($this->fk_remise_except)
|
||||||
|
|||||||
@@ -326,20 +326,10 @@ if ($id > 0 || ! empty($ref))
|
|||||||
$sql.= ' pt.product_type,';
|
$sql.= ' pt.product_type,';
|
||||||
$sql.= ' p.rowid as prodid, p.label as product_label, p.ref, p.fk_product_type, ';
|
$sql.= ' p.rowid as prodid, p.label as product_label, p.ref, p.fk_product_type, ';
|
||||||
$sql.= ' p.description as product_desc';
|
$sql.= ' p.description as product_desc';
|
||||||
// FIXME: There is a bug when using a join with element_rang and
|
|
||||||
// condition outside of left join. This give unpredicable results as this is not
|
|
||||||
// a valid SQL syntax .
|
|
||||||
// $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."element_rang as r ON r.fk_parent = ed.fk_expedition AND r.parenttype = '".$this->element."'";
|
|
||||||
// Getting a "sort order" must be done outside of the request to get values
|
|
||||||
$sql.= ' FROM '.MAIN_DB_PREFIX.'propaldet as pt';
|
$sql.= ' FROM '.MAIN_DB_PREFIX.'propaldet as pt';
|
||||||
//$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."element_rang as r ON r.fk_parent = pt.fk_propal AND r.parenttype = '".$propal->element."'";
|
|
||||||
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON pt.fk_product=p.rowid';
|
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON pt.fk_product=p.rowid';
|
||||||
$sql.= ' WHERE pt.fk_propal = '.$propal->id;
|
$sql.= ' WHERE pt.fk_propal = '.$propal->id;
|
||||||
//$sql.= " AND r.fk_child = pt.rowid";
|
$sql.= ' ORDER BY pt.rang ASC, pt.rowid';
|
||||||
//$sql.= " AND r.childtype = '".$propal->element."'";
|
|
||||||
//$sql.= ' ORDER BY r.rang ASC, pt.rowid';
|
|
||||||
$sql.=" ORDER BY pt.rowid";
|
|
||||||
|
|
||||||
$resql = $db->query($sql);
|
$resql = $db->query($sql);
|
||||||
if ($resql)
|
if ($resql)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -31,22 +31,6 @@
|
|||||||
|
|
||||||
class CommonObjectLine
|
class CommonObjectLine
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* Add position of line (rang)
|
|
||||||
*/
|
|
||||||
function addRangOfLine($parentid,$parenttype,$childid,$childtype,$rang)
|
|
||||||
{
|
|
||||||
$sql = 'INSERT INTO '.MAIN_DB_PREFIX.'element_rang (';
|
|
||||||
$sql.= 'fk_parent, parenttype, fk_child, childtype, rang';
|
|
||||||
$sql.= ') VALUES (';
|
|
||||||
$sql.= $parentid.', "'.$parenttype.'", '.$childid.', "'.$childtype.'", '.$rang;
|
|
||||||
$sql.= ')';
|
|
||||||
|
|
||||||
if (! $this->db->query($sql) )
|
|
||||||
{
|
|
||||||
dol_print_error($this->db);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -231,19 +231,13 @@ class Expedition extends CommonObject
|
|||||||
$sql.= ", ".$qty;
|
$sql.= ", ".$qty;
|
||||||
$sql.= ")";
|
$sql.= ")";
|
||||||
|
|
||||||
if ($this->db->query($sql))
|
if (! $this->db->query($sql))
|
||||||
{
|
{
|
||||||
$this->rowid=$this->db->last_insert_id(MAIN_DB_PREFIX.'expeditiondet');
|
$error++;
|
||||||
|
|
||||||
$this->rang = 0; // TODO en attendant une gestion de la disposition
|
|
||||||
$this->addRangOfLine($this->rowid,$this->element,$this->rang);
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (! $error) return 1;
|
||||||
|
else return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -550,19 +544,17 @@ class Expedition extends CommonObject
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
function delete_line($lineid)
|
function delete_line($id)
|
||||||
{
|
{
|
||||||
if ($this->statut == 0)
|
if ($this->statut == 0)
|
||||||
{
|
{
|
||||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."expeditiondet";
|
$sql = "DELETE FROM ".MAIN_DB_PREFIX."commandedet";
|
||||||
$sql.= " WHERE rowid = ".$lineid;
|
$sql.= " WHERE rowid = ".$id;
|
||||||
|
|
||||||
if ($this->db->query($sql) )
|
if ($this->db->query($sql) )
|
||||||
{
|
{
|
||||||
$this->update_price();
|
$this->update_price();
|
||||||
|
|
||||||
$this->delRangOfLine($lineid, $this->element);
|
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -687,9 +679,6 @@ class Expedition extends CommonObject
|
|||||||
|
|
||||||
if ( $this->db->query($sql) )
|
if ( $this->db->query($sql) )
|
||||||
{
|
{
|
||||||
// Delete all rang of lines
|
|
||||||
$this->delAllRangOfLines();
|
|
||||||
|
|
||||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."element_element";
|
$sql = "DELETE FROM ".MAIN_DB_PREFIX."element_element";
|
||||||
$sql.= " WHERE fk_target = ".$this->id;
|
$sql.= " WHERE fk_target = ".$this->id;
|
||||||
$sql.= " AND targettype = '".$this->element."'";
|
$sql.= " AND targettype = '".$this->element."'";
|
||||||
@@ -757,22 +746,16 @@ class Expedition extends CommonObject
|
|||||||
*/
|
*/
|
||||||
function fetch_lines()
|
function fetch_lines()
|
||||||
{
|
{
|
||||||
|
// TODO: recuperer les champs du document associe a part
|
||||||
|
|
||||||
$sql = "SELECT cd.rowid, cd.fk_product, cd.description, cd.qty as qty_asked";
|
$sql = "SELECT cd.rowid, cd.fk_product, cd.description, cd.qty as qty_asked";
|
||||||
$sql.= ", ed.qty as qty_shipped, ed.fk_origin_line, ed.fk_entrepot";
|
$sql.= ", ed.qty as qty_shipped, ed.fk_origin_line, ed.fk_entrepot";
|
||||||
$sql.= ", p.ref, p.fk_product_type, p.label, p.weight, p.weight_units, p.volume, p.volume_units";
|
$sql.= ", p.ref, p.fk_product_type, p.label, p.weight, p.weight_units, p.volume, p.volume_units";
|
||||||
$sql.= " FROM (".MAIN_DB_PREFIX."expeditiondet as ed,";
|
$sql.= " FROM (".MAIN_DB_PREFIX."expeditiondet as ed,";
|
||||||
$sql.= " ".MAIN_DB_PREFIX."commandedet as cd)"; // FIXME utiliser llx_element_element
|
$sql.= " ".MAIN_DB_PREFIX."commandedet as cd)";
|
||||||
// FIXME: There is a bug when using a join with element_rang and
|
|
||||||
// condition outside of left join. This give unpredicable results as this is not
|
|
||||||
// a valid SQL syntax .
|
|
||||||
// $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."element_rang as r ON r.fk_parent = ed.fk_expedition AND r.parenttype = '".$this->element."'";
|
|
||||||
// Getting a "sort order" must be done outside of the request to get values
|
|
||||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = cd.fk_product";
|
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = cd.fk_product";
|
||||||
$sql.= " WHERE ed.fk_expedition = ".$this->id;
|
$sql.= " WHERE ed.fk_expedition = ".$this->id;
|
||||||
//$sql.= " AND r.fk_child = ed.rowid";
|
$sql.= " AND ed.fk_origin_line = cd.rowid";
|
||||||
//$sql.= " AND r.childtype = '".$this->element."'";
|
|
||||||
$sql.= " AND ed.fk_origin_line = cd.rowid"; // FIXME utiliser llx_element_element
|
|
||||||
//$sql.= " ORDER by r.rang";
|
|
||||||
|
|
||||||
dol_syslog("Expedition::fetch_lines sql=".$sql);
|
dol_syslog("Expedition::fetch_lines sql=".$sql);
|
||||||
$resql = $this->db->query($sql);
|
$resql = $this->db->query($sql);
|
||||||
|
|||||||
@@ -49,7 +49,6 @@ $langs->load('other');
|
|||||||
$langs->load('propal');
|
$langs->load('propal');
|
||||||
|
|
||||||
$origin = $_GET["origin"]?$_GET["origin"]:$_POST["origin"]; // Example: commande, propal
|
$origin = $_GET["origin"]?$_GET["origin"]:$_POST["origin"]; // Example: commande, propal
|
||||||
if (empty($origin)) $origin = 'expedition';
|
|
||||||
$origin_id = isset($_REQUEST["id"])?$_REQUEST["id"]:'';
|
$origin_id = isset($_REQUEST["id"])?$_REQUEST["id"]:'';
|
||||||
if (empty($origin_id)) $origin_id = $_GET["origin_id"]?$_GET["origin_id"]:$_POST["origin_id"]; // Id of order or propal
|
if (empty($origin_id)) $origin_id = $_GET["origin_id"]?$_GET["origin_id"]:$_POST["origin_id"]; // Id of order or propal
|
||||||
if (empty($origin_id)) $origin_id = $_GET["object_id"]?$_GET["object_id"]:$_POST["object_id"]; // Id of order or propal
|
if (empty($origin_id)) $origin_id = $_GET["object_id"]?$_GET["object_id"]:$_POST["object_id"]; // Id of order or propal
|
||||||
@@ -58,7 +57,7 @@ $id = $origin_id;
|
|||||||
|
|
||||||
// Security check
|
// Security check
|
||||||
if ($user->societe_id) $socid=$user->societe_id;
|
if ($user->societe_id) $socid=$user->societe_id;
|
||||||
$result=restrictedArea($user,$origin,$origin_id);
|
$result=restrictedArea($user,$origin,$origin_id,'');
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -394,18 +394,11 @@ if ($id > 0 || ! empty($ref))
|
|||||||
$sql.= ' p.label as product_label, p.ref, p.fk_product_type, p.rowid as prodid,';
|
$sql.= ' p.label as product_label, p.ref, p.fk_product_type, p.rowid as prodid,';
|
||||||
$sql.= ' p.description as product_desc, p.fk_product_type as product_type';
|
$sql.= ' p.description as product_desc, p.fk_product_type as product_type';
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX."commandedet as cd";
|
$sql.= " FROM ".MAIN_DB_PREFIX."commandedet as cd";
|
||||||
// FIXME: There is a bug when using a join with element_rang and
|
|
||||||
// condition outside of left join. This give unpredicable results as this is not
|
|
||||||
// a valid SQL syntax .
|
|
||||||
// $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."element_rang as r ON r.fk_parent = ed.fk_expedition AND r.parenttype = '".$this->element."'";
|
|
||||||
// Getting a "sort order" must be done outside of the request to get values
|
|
||||||
//$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."element_rang as r ON r.fk_parent = cd.fk_commande AND r.parenttype = '".$commande->element."'";
|
|
||||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON cd.fk_product = p.rowid";
|
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON cd.fk_product = p.rowid";
|
||||||
$sql.= " WHERE cd.fk_commande = ".$commande->id;
|
$sql.= " WHERE cd.fk_commande = ".$commande->id;
|
||||||
//$sql.= " AND r.fk_child = cd.rowid";
|
// $sql.= " AND p.fk_product_type <> 1"; Why this line ?
|
||||||
//$sql.= " AND r.childtype = '".$commande->element."'";
|
//$sql.= " GROUP by cd.rowid, cd.fk_product";
|
||||||
//$sql.= " ORDER BY r.rang, cd.rowid";
|
$sql.= " ORDER BY cd.rang, cd.rowid";
|
||||||
$sql.=" ORDER BY cd.rowid";
|
|
||||||
|
|
||||||
//print $sql;
|
//print $sql;
|
||||||
dol_syslog("commande.php sql=".$sql, LOG_DEBUG);
|
dol_syslog("commande.php sql=".$sql, LOG_DEBUG);
|
||||||
|
|||||||
@@ -301,8 +301,6 @@ if (GETPOST('action') && preg_match('/upgrade/i',GETPOST("action")))
|
|||||||
{
|
{
|
||||||
//print $langs->trans("AlreadyDone");
|
//print $langs->trans("AlreadyDone");
|
||||||
|
|
||||||
//migrate_element_rang($db,$langs,$conf);
|
|
||||||
|
|
||||||
// Reload menus
|
// Reload menus
|
||||||
migrate_reload_menu($db,$langs,$conf,$versionto);
|
migrate_reload_menu($db,$langs,$conf,$versionto);
|
||||||
}
|
}
|
||||||
@@ -3054,98 +3052,6 @@ function migrate_shipping_delivery2($db,$langs,$conf)
|
|||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Migration de la gestion des rangs dans llx_element_rang
|
|
||||||
*/
|
|
||||||
function migrate_element_rang($db,$langs,$conf)
|
|
||||||
{
|
|
||||||
dolibarr_install_syslog("upgrade2::migrate_element_rang");
|
|
||||||
|
|
||||||
print '<tr><td colspan="4">';
|
|
||||||
|
|
||||||
print '<br>';
|
|
||||||
print '<b>'.$langs->trans('MigrationElementRang')."</b><br>\n";
|
|
||||||
|
|
||||||
$tables = array();
|
|
||||||
|
|
||||||
// llx_propaldet
|
|
||||||
$tables[] = array('name'=>'propaldet','element'=>'propal','fk_element'=>'fk_propal');
|
|
||||||
// llx_commandedet
|
|
||||||
$tables[] = array('name'=>'commandedet','element'=>'commande','fk_element'=>'fk_commande');
|
|
||||||
//llx_facturedet
|
|
||||||
$tables[] = array('name'=>'facturedet','element'=>'facture','fk_element'=>'fk_facture');
|
|
||||||
//llx_expeditiondet
|
|
||||||
$tables[] = array('name'=>'expeditiondet','element'=>'shipping','fk_element'=>'fk_expedition');
|
|
||||||
//llx_livraisondet
|
|
||||||
$tables[] = array('name'=>'livraisondet','element'=>'delivery','fk_element'=>'fk_livraison');
|
|
||||||
//llx_projet_task
|
|
||||||
//$tables[] = array('name'=>'projet_task','element'=>'project_task','fk_element'=>'fk_projet');
|
|
||||||
|
|
||||||
foreach($tables as $table)
|
|
||||||
{
|
|
||||||
$result = $db->DDLDescTable(MAIN_DB_PREFIX.$table['name'],"rang");
|
|
||||||
$obj = $db->fetch_object($result);
|
|
||||||
if ($obj)
|
|
||||||
{
|
|
||||||
$error = 0;
|
|
||||||
|
|
||||||
$db->begin();
|
|
||||||
|
|
||||||
$sql = "SELECT rowid, ".$table['fk_element'].", rang FROM ".MAIN_DB_PREFIX.$table['name'];
|
|
||||||
$resql = $db->query($sql);
|
|
||||||
if ($resql)
|
|
||||||
{
|
|
||||||
$i = 0;
|
|
||||||
$num = $db->num_rows($resql);
|
|
||||||
|
|
||||||
if ($num)
|
|
||||||
{
|
|
||||||
while ($i < $num)
|
|
||||||
{
|
|
||||||
$obj = $db->fetch_object($resql);
|
|
||||||
|
|
||||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."element_rang (fk_parent,parenttype,fk_child,childtype,rang)";
|
|
||||||
$sql.= " VALUES (".$obj->$table['fk_element'].",'".$table['element']."',".$obj->rowid.",'".$table['element']."',".$obj->rang.")";
|
|
||||||
$resql2=$db->query($sql);
|
|
||||||
|
|
||||||
if (!$resql2)
|
|
||||||
{
|
|
||||||
$error++;
|
|
||||||
dol_print_error($db);
|
|
||||||
}
|
|
||||||
print ". ";
|
|
||||||
$i++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($error == 0)
|
|
||||||
{
|
|
||||||
$db->commit();
|
|
||||||
// DDL sql order must not be done into the data migrate process
|
|
||||||
//$sql = "ALTER TABLE ".MAIN_DB_PREFIX.$table['name']." DROP COLUMN rang";
|
|
||||||
//print "<br>".$langs->trans('FieldMigrated',$table['name'])."<br>\n";
|
|
||||||
//$db->query($sql);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$db->rollback();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
dol_print_error($db);
|
|
||||||
$db->rollback();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
print $langs->trans('AlreadyDone')."<br>\n";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
print '</td></tr>';
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Migration directory
|
* Migration directory
|
||||||
|
|||||||
@@ -224,18 +224,14 @@ class Livraison extends CommonObject
|
|||||||
$sql.= $qty.")";
|
$sql.= $qty.")";
|
||||||
|
|
||||||
dol_syslog("Livraison::create_line sql=".$sql, LOG_DEBUG);
|
dol_syslog("Livraison::create_line sql=".$sql, LOG_DEBUG);
|
||||||
if ($this->db->query($sql))
|
if (! $this->db->query($sql) )
|
||||||
{
|
{
|
||||||
$this->rowid=$this->db->last_insert_id(MAIN_DB_PREFIX.'livraisondet');
|
$error++;
|
||||||
|
|
||||||
$this->rang = 0; // TODO en attendant une gestion de la disposition
|
|
||||||
$this->addRangOfLine($this->rowid,$this->element,$this->rang);
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
if ($error == 0 )
|
||||||
{
|
{
|
||||||
return -1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -540,19 +536,17 @@ class Livraison extends CommonObject
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
function delete_line($lineid)
|
function delete_line($idligne)
|
||||||
{
|
{
|
||||||
if ($this->statut == 0)
|
if ($this->statut == 0)
|
||||||
{
|
{
|
||||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."commandedet";
|
$sql = "DELETE FROM ".MAIN_DB_PREFIX."commandedet";
|
||||||
$sql.= " WHERE rowid = ".$lineid;
|
$sql.= " WHERE rowid = ".$idligne;
|
||||||
|
|
||||||
if ($this->db->query($sql) )
|
if ($this->db->query($sql) )
|
||||||
{
|
{
|
||||||
$this->update_price();
|
$this->update_price();
|
||||||
|
|
||||||
$this->delRangOfLine($lineid, $this->element);
|
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -574,9 +568,6 @@ class Livraison extends CommonObject
|
|||||||
$sql.= " WHERE fk_livraison = ".$this->id;
|
$sql.= " WHERE fk_livraison = ".$this->id;
|
||||||
if ( $this->db->query($sql) )
|
if ( $this->db->query($sql) )
|
||||||
{
|
{
|
||||||
// Delete all rang of lines
|
|
||||||
$this->delAllRangOfLines();
|
|
||||||
|
|
||||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."element_element";
|
$sql = "DELETE FROM ".MAIN_DB_PREFIX."element_element";
|
||||||
$sql.= " WHERE fk_target = ".$this->id;
|
$sql.= " WHERE fk_target = ".$this->id;
|
||||||
$sql.= " AND targettype = '".$this->element."'";
|
$sql.= " AND targettype = '".$this->element."'";
|
||||||
@@ -672,20 +663,10 @@ class Livraison extends CommonObject
|
|||||||
$sql = "SELECT ld.rowid, ld.fk_product, ld.description, ld.subprice, ld.total_ht, ld.qty as qty_shipped,";
|
$sql = "SELECT ld.rowid, ld.fk_product, ld.description, ld.subprice, ld.total_ht, ld.qty as qty_shipped,";
|
||||||
$sql.= " cd.qty as qty_asked,";
|
$sql.= " cd.qty as qty_asked,";
|
||||||
$sql.= " p.ref, p.fk_product_type as fk_product_type, p.label as label, p.description as product_desc";
|
$sql.= " p.ref, p.fk_product_type as fk_product_type, p.label as label, p.description as product_desc";
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX."commandedet as cd"; // TODO utiliser llx_element_element
|
$sql.= " FROM ".MAIN_DB_PREFIX."commandedet as cd, ".MAIN_DB_PREFIX."livraisondet as ld";
|
||||||
$sql.= ", ".MAIN_DB_PREFIX."livraisondet as ld";
|
|
||||||
// FIXME: There is a bug when using a join with element_rang and
|
|
||||||
// condition outside of left join. This give unpredicable results as this is not
|
|
||||||
// a valid SQL syntax .
|
|
||||||
// $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."element_rang as r ON r.fk_parent = ed.fk_expedition AND r.parenttype = '".$this->element."'";
|
|
||||||
// Getting a "sort order" must be done outside of the request to get values
|
|
||||||
//$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."element_rang as r ON r.fk_parent = ld.fk_livraison AND r.parenttype = '".$this->element."'";
|
|
||||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p on p.rowid = ld.fk_product";
|
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p on p.rowid = ld.fk_product";
|
||||||
$sql.= " WHERE ld.fk_origin_line = cd.rowid";
|
$sql.= " WHERE ld.fk_origin_line = cd.rowid";
|
||||||
$sql.= " AND ld.fk_livraison = ".$this->id;
|
$sql.= " AND ld.fk_livraison = ".$this->id;
|
||||||
//$sql.= " AND r.fk_child = ld.rowid";
|
|
||||||
//$sql.= " AND r.childtype = '".$this->element."'";
|
|
||||||
//$sql.= " ORDER by r.rang";
|
|
||||||
|
|
||||||
dol_syslog("Livraison::fetch_lignes sql=".$sql);
|
dol_syslog("Livraison::fetch_lignes sql=".$sql);
|
||||||
$resql = $this->db->query($sql);
|
$resql = $this->db->query($sql);
|
||||||
|
|||||||
Reference in New Issue
Block a user