forked from Wavyzz/dolibarr
NEW Show badge with nbr of shipment on shimpen tab of order
NEW Add button cancel on shipment creation
This commit is contained in:
@@ -1906,6 +1906,40 @@ class Commande extends CommonOrder
|
||||
return $nb;
|
||||
}
|
||||
|
||||
/**
|
||||
* Count numbe rof shipments for this order
|
||||
*
|
||||
* @return int <0 if KO, Nb of shipment found if OK
|
||||
*/
|
||||
function getNbOfShipments()
|
||||
{
|
||||
$nb = 0;
|
||||
|
||||
$sql = 'SELECT COUNT(DISTINCT ed.fk_expedition) as nb';
|
||||
$sql.= ' FROM '.MAIN_DB_PREFIX.'expeditiondet as ed,';
|
||||
$sql.= ' '.MAIN_DB_PREFIX.'commandedet as cd';
|
||||
$sql.= ' WHERE';
|
||||
$sql.= ' ed.fk_origin_line = cd.rowid';
|
||||
$sql.= ' AND cd.fk_commande =' .$this->id;
|
||||
//print $sql;
|
||||
|
||||
dol_syslog(get_class($this)."::getNbOfShipments", LOG_DEBUG);
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$obj = $this->db->fetch_object($resql);
|
||||
if ($obj) $nb = $obj->nb;
|
||||
|
||||
$this->db->free($resql);
|
||||
return $nb;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->error=$this->db->lasterror();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Load array this->expeditions of lines of shipments with nb of products sent for each order line
|
||||
* Note: For a dedicated shipment, the fetch_lines can be used to load the qty_asked and qty_shipped. This function is use to return qty_shipped cumulated for the order
|
||||
@@ -1932,18 +1966,18 @@ class Commande extends CommonOrder
|
||||
//print $sql;
|
||||
|
||||
dol_syslog(get_class($this)."::loadExpeditions", LOG_DEBUG);
|
||||
$result = $this->db->query($sql);
|
||||
if ($result)
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$num = $this->db->num_rows($result);
|
||||
$num = $this->db->num_rows($resql);
|
||||
$i = 0;
|
||||
while ($i < $num)
|
||||
{
|
||||
$obj = $this->db->fetch_object($result);
|
||||
$obj = $this->db->fetch_object($resql);
|
||||
$this->expeditions[$obj->rowid] = $obj->qty;
|
||||
$i++;
|
||||
}
|
||||
$this->db->free();
|
||||
$this->db->free($resql);
|
||||
return $num;
|
||||
}
|
||||
else
|
||||
@@ -1951,7 +1985,6 @@ class Commande extends CommonOrder
|
||||
$this->error=$this->db->lasterror();
|
||||
return -1;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2002,18 +2035,18 @@ class Commande extends CommonOrder
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."product_stock as ps";
|
||||
$sql.= " WHERE ps.fk_product IN (".join(',',$array_of_product).")";
|
||||
$sql.= ' GROUP BY fk_product ';
|
||||
$result = $this->db->query($sql);
|
||||
if ($result)
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$num = $this->db->num_rows($result);
|
||||
$num = $this->db->num_rows($resql);
|
||||
$i = 0;
|
||||
while ($i < $num)
|
||||
{
|
||||
$obj = $this->db->fetch_object($result);
|
||||
$obj = $this->db->fetch_object($resql);
|
||||
$this->stocks[$obj->fk_product] = $obj->total;
|
||||
$i++;
|
||||
}
|
||||
$this->db->free();
|
||||
$this->db->free($resql);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user