Works on migration management positioning lines
Phase 4 : llx_expeditiondet et llx_livraisondet
This commit is contained in:
parent
9b1b24cf56
commit
b9ba88a5d2
@ -1574,6 +1574,9 @@ class Propal extends CommonObject
|
||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."propaldet WHERE fk_propal = ".$this->id;
|
||||
if ( $this->db->query($sql) )
|
||||
{
|
||||
// Delete all rang of files
|
||||
$this->delAllRangOfLines();
|
||||
|
||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."propal WHERE rowid = ".$this->id;
|
||||
if ( $this->db->query($sql) )
|
||||
{
|
||||
|
||||
@ -1992,6 +1992,9 @@ class Commande extends CommonObject
|
||||
dol_syslog("CustomerOrder::delete error", LOG_ERR);
|
||||
$err++;
|
||||
}
|
||||
|
||||
// Delete all rang of lines
|
||||
$this->delAllRangOfLines();
|
||||
|
||||
// Delete order
|
||||
$sql = 'DELETE FROM '.MAIN_DB_PREFIX."commande WHERE rowid = ".$this->id;
|
||||
|
||||
@ -1801,7 +1801,7 @@ else
|
||||
}
|
||||
else
|
||||
{*/
|
||||
print '<a class="butAction" href="'.DOL_URL_ROOT.'/expedition/shipment.php?id='.$comid.'">'.$langs->trans('ShipProduct').'</a>';
|
||||
print '<a class="butAction" href="'.DOL_URL_ROOT.'/expedition/shipment.php?id='.$commande->id.'">'.$langs->trans('ShipProduct').'</a>';
|
||||
//}
|
||||
}
|
||||
else
|
||||
|
||||
@ -1030,6 +1030,8 @@ class Facture extends CommonObject
|
||||
$resql=$this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$this->delAllRangOfLines();
|
||||
|
||||
// Appel des triggers
|
||||
include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php");
|
||||
$interface=new Interfaces($this->db);
|
||||
|
||||
@ -754,7 +754,7 @@ class CommonObject
|
||||
/**
|
||||
* Add position of line (rang)
|
||||
*/
|
||||
function addRangOfLine($childid,$childtype,$rang)
|
||||
function addRangOfLine($childid,$childtype,$rang=0)
|
||||
{
|
||||
$sql = 'INSERT INTO '.MAIN_DB_PREFIX.'element_rang (';
|
||||
$sql.= 'fk_parent, parenttype, fk_child, childtype, rang';
|
||||
@ -784,6 +784,21 @@ class CommonObject
|
||||
dol_print_error($this->db);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete all position of lines (rang)
|
||||
*/
|
||||
function delAllRangOfLines()
|
||||
{
|
||||
$sql = 'DELETE FROM '.MAIN_DB_PREFIX.'element_rang';
|
||||
$sql.= ' WHERE fk_parent = '.$this->id;
|
||||
$sql.= ' AND parenttype = "'.$this->element.'"';
|
||||
|
||||
if (! $this->db->query($sql) )
|
||||
{
|
||||
dol_print_error($this->db);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update position of line (rang)
|
||||
|
||||
@ -231,13 +231,19 @@ class Expedition extends CommonObject
|
||||
$sql.= ", ".$qty;
|
||||
$sql.= ")";
|
||||
|
||||
if (! $this->db->query($sql))
|
||||
if ($this->db->query($sql))
|
||||
{
|
||||
$error++;
|
||||
}
|
||||
$this->rowid=$this->db->last_insert_id(MAIN_DB_PREFIX.'expeditiondet');
|
||||
|
||||
if (! $error) return 1;
|
||||
else return -1;
|
||||
$this->rang = 0; // TODO en attendant une gestion de la disposition
|
||||
$this->addRangOfLine($this->rowid,$this->element,$this->rang);
|
||||
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -544,16 +550,18 @@ class Expedition extends CommonObject
|
||||
*
|
||||
*
|
||||
*/
|
||||
function delete_line($id)
|
||||
function delete_line($lineid)
|
||||
{
|
||||
if ($this->statut == 0)
|
||||
{
|
||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."commandedet";
|
||||
$sql.= " WHERE rowid = ".$id;
|
||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."expeditiondet";
|
||||
$sql.= " WHERE rowid = ".$lineid;
|
||||
|
||||
if ($this->db->query($sql) )
|
||||
{
|
||||
$this->update_price();
|
||||
|
||||
$this->delRangOfLine($lineid, $this->element);
|
||||
|
||||
return 1;
|
||||
}
|
||||
@ -679,6 +687,9 @@ class Expedition extends CommonObject
|
||||
|
||||
if ( $this->db->query($sql) )
|
||||
{
|
||||
// Delete all rang of files
|
||||
$this->delAllRangOfLines();
|
||||
|
||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."element_element";
|
||||
$sql.= " WHERE fk_target = ".$this->id;
|
||||
$sql.= " AND targettype = '".$this->element."'";
|
||||
@ -752,10 +763,14 @@ class Expedition extends CommonObject
|
||||
$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.= " FROM (".MAIN_DB_PREFIX."expeditiondet as ed,";
|
||||
$sql.= " ".MAIN_DB_PREFIX."commandedet as cd)";
|
||||
$sql.= " ".MAIN_DB_PREFIX."commandedet as cd)"; // FIXME utiliser llx_element_element
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."element_rang as r ON r.fk_parent = ed.fk_expedition AND r.parenttype = '".$this->element."'";
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = cd.fk_product";
|
||||
$sql.= " WHERE ed.fk_expedition = ".$this->id;
|
||||
$sql.= " AND ed.fk_origin_line = cd.rowid";
|
||||
$sql.= " AND r.fk_child = ed.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);
|
||||
$resql = $this->db->query($sql);
|
||||
|
||||
@ -49,6 +49,7 @@ $langs->load('other');
|
||||
$langs->load('propal');
|
||||
|
||||
$origin = $_GET["origin"]?$_GET["origin"]:$_POST["origin"]; // Example: commande, propal
|
||||
if (empty($origin)) $origin = 'expedition';
|
||||
$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["object_id"]?$_GET["object_id"]:$_POST["object_id"]; // Id of order or propal
|
||||
@ -57,7 +58,7 @@ $id = $origin_id;
|
||||
|
||||
// Security check
|
||||
if ($user->societe_id) $socid=$user->societe_id;
|
||||
$result=restrictedArea($user,$origin,$origin_id,'');
|
||||
$result=restrictedArea($user,$origin,$origin_id);
|
||||
|
||||
|
||||
/*
|
||||
|
||||
@ -394,11 +394,12 @@ if ($id > 0 || ! empty($ref))
|
||||
$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.= " 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 = '".$commande->element."'";
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON cd.fk_product = p.rowid";
|
||||
$sql.= " WHERE cd.fk_commande = ".$commande->id;
|
||||
// $sql.= " AND p.fk_product_type <> 1"; Why this line ?
|
||||
//$sql.= " GROUP by cd.rowid, cd.fk_product";
|
||||
$sql.= " ORDER BY cd.rang, cd.rowid";
|
||||
$sql.= " AND r.fk_child = cd.rowid";
|
||||
$sql.= " AND r.childtype = '".$commande->element."'";
|
||||
$sql.= " ORDER BY r.rang, cd.rowid";
|
||||
|
||||
//print $sql;
|
||||
dol_syslog("commande.php sql=".$sql, LOG_DEBUG);
|
||||
|
||||
@ -25,6 +25,5 @@ create table llx_expeditiondet
|
||||
fk_expedition integer NOT NULL,
|
||||
fk_origin_line integer, -- Correspondance de la ligne avec le document d'origine (propal, commande)
|
||||
fk_entrepot integer, -- Entrepot de depart du produit
|
||||
qty real, -- Quantity
|
||||
rang integer DEFAULT 0
|
||||
qty real -- Quantity
|
||||
)type=innodb;
|
||||
|
||||
@ -28,6 +28,5 @@ create table llx_livraisondet
|
||||
description text,
|
||||
qty real, -- quantity
|
||||
subprice double(24,8) DEFAULT 0, -- prix unitaire
|
||||
total_ht double(24,8) DEFAULT 0, -- Total HT de la ligne toute quantite
|
||||
rang integer DEFAULT 0
|
||||
total_ht double(24,8) DEFAULT 0 -- Total HT de la ligne toute quantite
|
||||
)type=innodb;
|
||||
|
||||
@ -38,6 +38,5 @@ create table llx_projet_task
|
||||
fk_user_valid integer, -- user who validated the task
|
||||
fk_statut smallint DEFAULT 0 NOT NULL,
|
||||
note_private text,
|
||||
note_public text,
|
||||
rang integer DEFAULT 0
|
||||
note_public text
|
||||
)type=innodb;
|
||||
|
||||
@ -3074,6 +3074,12 @@ function migrate_element_rang($db,$langs,$conf)
|
||||
$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','fk_element'=>'fk_projet');
|
||||
|
||||
foreach($tables as $table)
|
||||
{
|
||||
|
||||
@ -224,15 +224,19 @@ class Livraison extends CommonObject
|
||||
$sql.= $qty.")";
|
||||
|
||||
dol_syslog("Livraison::create_line sql=".$sql, LOG_DEBUG);
|
||||
if (! $this->db->query($sql) )
|
||||
if ($this->db->query($sql))
|
||||
{
|
||||
$error++;
|
||||
}
|
||||
$this->rowid=$this->db->last_insert_id(MAIN_DB_PREFIX.'livraisondet');
|
||||
|
||||
if ($error == 0 )
|
||||
{
|
||||
$this->rang = 0; // TODO en attendant une gestion de la disposition
|
||||
$this->addRangOfLine($this->rowid,$this->element,$this->rang);
|
||||
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -536,16 +540,18 @@ class Livraison extends CommonObject
|
||||
*
|
||||
*
|
||||
*/
|
||||
function delete_line($idligne)
|
||||
function delete_line($lineid)
|
||||
{
|
||||
if ($this->statut == 0)
|
||||
{
|
||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."commandedet";
|
||||
$sql.= " WHERE rowid = ".$idligne;
|
||||
$sql.= " WHERE rowid = ".$lineid;
|
||||
|
||||
if ($this->db->query($sql) )
|
||||
{
|
||||
$this->update_price();
|
||||
|
||||
$this->delRangOfLine($lineid, $this->element);
|
||||
|
||||
return 1;
|
||||
}
|
||||
@ -568,6 +574,9 @@ class Livraison extends CommonObject
|
||||
$sql.= " WHERE fk_livraison = ".$this->id;
|
||||
if ( $this->db->query($sql) )
|
||||
{
|
||||
// Delete all rang of files
|
||||
$this->delAllRangOfLines();
|
||||
|
||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."element_element";
|
||||
$sql.= " WHERE fk_target = ".$this->id;
|
||||
$sql.= " AND targettype = '".$this->element."'";
|
||||
@ -576,7 +585,7 @@ class Livraison extends CommonObject
|
||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."livraison";
|
||||
$sql.= " WHERE rowid = ".$this->id;
|
||||
if ( $this->db->query($sql) )
|
||||
{
|
||||
{
|
||||
$this->db->commit();
|
||||
|
||||
// On efface le repertoire de pdf provisoire
|
||||
@ -663,10 +672,15 @@ class Livraison extends CommonObject
|
||||
$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.= " 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, ".MAIN_DB_PREFIX."livraisondet as ld";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."commandedet as cd"; // TODO utiliser llx_element_element
|
||||
$sql.= ", ".MAIN_DB_PREFIX."livraisondet as ld";
|
||||
$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.= " WHERE ld.fk_origin_line = cd.rowid";
|
||||
$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);
|
||||
$resql = $this->db->query($sql);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user