Merge branch 'develop' of https://github.com/Dolibarr/dolibarr into develop
This commit is contained in:
commit
24ede26dd7
@ -1646,7 +1646,7 @@ abstract class CommonObject
|
|||||||
|
|
||||||
$sourceid = (! empty($sourceid) ? $sourceid : $this->id);
|
$sourceid = (! empty($sourceid) ? $sourceid : $this->id);
|
||||||
$targetid = (! empty($targetid) ? $targetid : $this->id);
|
$targetid = (! empty($targetid) ? $targetid : $this->id);
|
||||||
$sourcetype = (! empty($sourcetype) ? $sourcetype : (! empty($this->origin) ? $this->origin : $this->element));
|
$sourcetype = (! empty($sourcetype) ? $sourcetype : $this->element);
|
||||||
$targettype = (! empty($targettype) ? $targettype : $this->element);
|
$targettype = (! empty($targettype) ? $targettype : $this->element);
|
||||||
|
|
||||||
// Links beetween objects are stored in this table
|
// Links beetween objects are stored in this table
|
||||||
|
|||||||
@ -45,12 +45,17 @@ function shipping_prepare_head($object)
|
|||||||
$head[$h][2] = 'shipping';
|
$head[$h][2] = 'shipping';
|
||||||
$h++;
|
$h++;
|
||||||
|
|
||||||
if ($conf->livraison_bon->enabled && $user->rights->expedition->livraison->lire && ! empty($object->linkedObjectsIds['delivery'][0]))
|
if ($conf->livraison_bon->enabled && $user->rights->expedition->livraison->lire)
|
||||||
{
|
{
|
||||||
$head[$h][0] = DOL_URL_ROOT."/livraison/fiche.php?id=".$object->linkedObjectsIds['delivery'][0];
|
// delivery link
|
||||||
$head[$h][1] = $langs->trans("DeliveryCard");
|
$object->fetchObjectLinked($object->id,$object->element);
|
||||||
$head[$h][2] = 'delivery';
|
if (! empty($object->linkedObjectsIds['delivery'][0]))
|
||||||
$h++;
|
{
|
||||||
|
$head[$h][0] = DOL_URL_ROOT."/livraison/fiche.php?id=".$object->linkedObjectsIds['delivery'][0];
|
||||||
|
$head[$h][1] = $langs->trans("DeliveryCard");
|
||||||
|
$head[$h][2] = 'delivery';
|
||||||
|
$h++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$head[$h][0] = DOL_URL_ROOT."/expedition/contact.php?id=".$object->id;
|
$head[$h][0] = DOL_URL_ROOT."/expedition/contact.php?id=".$object->id;
|
||||||
|
|||||||
@ -872,9 +872,6 @@ else
|
|||||||
$soc = new Societe($db);
|
$soc = new Societe($db);
|
||||||
$soc->fetch($object->socid);
|
$soc->fetch($object->socid);
|
||||||
|
|
||||||
// delivery link
|
|
||||||
$object->fetchObjectLinked($object->id,$object->element,-1,-1);
|
|
||||||
|
|
||||||
$head=shipping_prepare_head($object);
|
$head=shipping_prepare_head($object);
|
||||||
dol_fiche_head($head, 'shipping', $langs->trans("Sending"), 0, 'sending');
|
dol_fiche_head($head, 'shipping', $langs->trans("Sending"), 0, 'sending');
|
||||||
|
|
||||||
|
|||||||
@ -226,8 +226,8 @@ $sql = "SELECT e.rowid, e.ref";
|
|||||||
$sql.= ", s.nom, s.rowid as socid";
|
$sql.= ", s.nom, s.rowid as socid";
|
||||||
$sql.= ", c.ref as commande_ref, c.rowid as commande_id";
|
$sql.= ", c.ref as commande_ref, c.rowid as commande_id";
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX."expedition as e";
|
$sql.= " FROM ".MAIN_DB_PREFIX."expedition as e";
|
||||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."element_element as el ON e.rowid = el.fk_target AND el.sourcetype IN ('commande')";
|
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."element_element as el ON e.rowid = el.fk_target AND el.targettype = 'shipping' AND el.sourcetype IN ('commande')";
|
||||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."commande as c ON el.fk_source = c.rowid AND el.targettype IN ('shipping')";
|
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."commande as c ON el.fk_source = c.rowid AND el.sourcetype IN ('commande') AND el.targettype = 'shipping'";
|
||||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = e.fk_soc";
|
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = e.fk_soc";
|
||||||
if (! $user->rights->societe->client->voir && ! $socid) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON e.fk_soc = sc.fk_soc";
|
if (! $user->rights->societe->client->voir && ! $socid) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON e.fk_soc = sc.fk_soc";
|
||||||
$sql.= " WHERE e.entity = ".$conf->entity;
|
$sql.= " WHERE e.entity = ".$conf->entity;
|
||||||
|
|||||||
@ -807,7 +807,7 @@ class Livraison extends CommonObject
|
|||||||
global $langs;
|
global $langs;
|
||||||
|
|
||||||
// Get the linked object
|
// Get the linked object
|
||||||
$this->fetchObjectLinked(-1,-1,$this->id,$this->element);
|
$this->fetchObjectLinked('','',$this->id,$this->element);
|
||||||
//var_dump($this->linkedObjectIds);
|
//var_dump($this->linkedObjectIds);
|
||||||
// Get the product ref and qty in source
|
// Get the product ref and qty in source
|
||||||
$sqlSourceLine = "SELECT st.rowid, st.description, st.qty";
|
$sqlSourceLine = "SELECT st.rowid, st.description, st.qty";
|
||||||
|
|||||||
@ -2405,9 +2405,12 @@ class Product extends CommonObject
|
|||||||
{
|
{
|
||||||
$this->stock_reel = 0;
|
$this->stock_reel = 0;
|
||||||
|
|
||||||
$sql = "SELECT reel, fk_entrepot, pmp";
|
$sql = "SELECT ps.reel, ps.fk_entrepot, ps.pmp";
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX."product_stock";
|
$sql.= " FROM ".MAIN_DB_PREFIX."product_stock as ps";
|
||||||
$sql.= " WHERE fk_product = '".$this->id."'";
|
$sql.= ", ".MAIN_DB_PREFIX."entrepot as w";
|
||||||
|
$sql.= " WHERE w.entity = (".getEntity('warehouse', 1).")";
|
||||||
|
$sql.= " AND w.rowid = ps.fk_entrepot";
|
||||||
|
$sql.= " AND ps.fk_product = ".$this->id;
|
||||||
|
|
||||||
dol_syslog(get_class($this)."::load_stock sql=".$sql);
|
dol_syslog(get_class($this)."::load_stock sql=".$sql);
|
||||||
$result = $this->db->query($sql);
|
$result = $this->db->query($sql);
|
||||||
|
|||||||
@ -76,6 +76,8 @@ class Entrepot extends CommonObject
|
|||||||
*/
|
*/
|
||||||
function create($user)
|
function create($user)
|
||||||
{
|
{
|
||||||
|
global $conf;
|
||||||
|
|
||||||
// Si libelle non defini, erreur
|
// Si libelle non defini, erreur
|
||||||
if ($this->libelle == '')
|
if ($this->libelle == '')
|
||||||
{
|
{
|
||||||
@ -87,8 +89,8 @@ class Entrepot extends CommonObject
|
|||||||
|
|
||||||
$this->db->begin();
|
$this->db->begin();
|
||||||
|
|
||||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."entrepot (datec, fk_user_author, label)";
|
$sql = "INSERT INTO ".MAIN_DB_PREFIX."entrepot (entity, datec, fk_user_author, label)";
|
||||||
$sql .= " VALUES ('".$this->db->idate($now)."',".$user->id.",'".$this->db->escape($this->libelle)."')";
|
$sql .= " VALUES (".$conf->entity.",'".$this->db->idate($now)."',".$user->id.",'".$this->db->escape($this->libelle)."')";
|
||||||
|
|
||||||
dol_syslog(get_class($this)."::create sql=".$sql);
|
dol_syslog(get_class($this)."::create sql=".$sql);
|
||||||
$result=$this->db->query($sql);
|
$result=$this->db->query($sql);
|
||||||
@ -99,7 +101,7 @@ class Entrepot extends CommonObject
|
|||||||
{
|
{
|
||||||
$this->id = $id;
|
$this->id = $id;
|
||||||
|
|
||||||
if ( $this->update($id, $user) > 0)
|
if ($this->update($id, $user) > 0)
|
||||||
{
|
{
|
||||||
$this->db->commit();
|
$this->db->commit();
|
||||||
return $id;
|
return $id;
|
||||||
@ -184,7 +186,6 @@ class Entrepot extends CommonObject
|
|||||||
*/
|
*/
|
||||||
function delete($user)
|
function delete($user)
|
||||||
{
|
{
|
||||||
|
|
||||||
$this->db->begin();
|
$this->db->begin();
|
||||||
|
|
||||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."stock_mouvement";
|
$sql = "DELETE FROM ".MAIN_DB_PREFIX."stock_mouvement";
|
||||||
@ -338,7 +339,8 @@ class Entrepot extends CommonObject
|
|||||||
|
|
||||||
$sql = "SELECT rowid, label";
|
$sql = "SELECT rowid, label";
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX."entrepot";
|
$sql.= " FROM ".MAIN_DB_PREFIX."entrepot";
|
||||||
$sql.= " WHERE statut = ".$status;
|
$sql.= " WHERE entity IN (".getEntity('warehouse', 1).")";
|
||||||
|
$sql.= " AND statut = ".$status;
|
||||||
|
|
||||||
$result = $this->db->query($sql);
|
$result = $this->db->query($sql);
|
||||||
$i = 0;
|
$i = 0;
|
||||||
@ -363,13 +365,13 @@ class Entrepot extends CommonObject
|
|||||||
*/
|
*/
|
||||||
function nb_products()
|
function nb_products()
|
||||||
{
|
{
|
||||||
global $conf,$user;
|
|
||||||
|
|
||||||
$ret=array();
|
$ret=array();
|
||||||
|
|
||||||
$sql = "SELECT sum(ps.reel) as nb, sum(ps.reel * ps.pmp) as value";
|
$sql = "SELECT sum(ps.reel) as nb, sum(ps.reel * ps.pmp) as value";
|
||||||
$sql .= " FROM ".MAIN_DB_PREFIX."product_stock as ps, ".MAIN_DB_PREFIX."product as p";
|
$sql.= " FROM ".MAIN_DB_PREFIX."product_stock as ps";
|
||||||
$sql .= " WHERE ps.fk_entrepot = ".$this->id." AND ps.fk_product=p.rowid";
|
$sql.= ", ".MAIN_DB_PREFIX."product as p";
|
||||||
|
$sql.= " WHERE ps.fk_entrepot = ".$this->id;
|
||||||
|
$sql.= " AND ps.fk_product = p.rowid";
|
||||||
|
|
||||||
//print $sql;
|
//print $sql;
|
||||||
$result = $this->db->query($sql);
|
$result = $this->db->query($sql);
|
||||||
|
|||||||
@ -44,7 +44,7 @@ $id = GETPOST('id')?GETPOST('id'):GETPOST('ref');
|
|||||||
$ref = GETPOST('ref');
|
$ref = GETPOST('ref');
|
||||||
$fieldid = isset($_GET["ref"])?'ref':'rowid';
|
$fieldid = isset($_GET["ref"])?'ref':'rowid';
|
||||||
if ($user->societe_id) $socid=$user->societe_id;
|
if ($user->societe_id) $socid=$user->societe_id;
|
||||||
$result=restrictedArea($user,'produit&stock',$id,'product','','',$fieldid);
|
$result=restrictedArea($user,'produit&stock',$id,'product&product','','',$fieldid);
|
||||||
|
|
||||||
$mesg = '';
|
$mesg = '';
|
||||||
|
|
||||||
@ -217,6 +217,7 @@ if ($_GET["id"] || $_GET["ref"])
|
|||||||
print '</tr>';
|
print '</tr>';
|
||||||
|
|
||||||
// Real stock
|
// Real stock
|
||||||
|
$product->load_stock();
|
||||||
print '<tr><td>'.$langs->trans("PhysicalStock").'</td>';
|
print '<tr><td>'.$langs->trans("PhysicalStock").'</td>';
|
||||||
print '<td>'.$product->stock_reel;
|
print '<td>'.$product->stock_reel;
|
||||||
if ($product->seuil_stock_alerte && ($product->stock_reel < $product->seuil_stock_alerte)) print ' '.img_warning($langs->trans("StockTooLow"));
|
if ($product->seuil_stock_alerte && ($product->stock_reel < $product->seuil_stock_alerte)) print ' '.img_warning($langs->trans("StockTooLow"));
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user