diff --git a/htdocs/core/lib/security2.lib.php b/htdocs/core/lib/security2.lib.php index d0def9d5627..3876dc0e2cd 100644 --- a/htdocs/core/lib/security2.lib.php +++ b/htdocs/core/lib/security2.lib.php @@ -189,7 +189,7 @@ function dol_loginfunction($langs,$conf,$mysoc) if (GETPOST('urlfrom','alpha')) $_SESSION["urlfrom"]=GETPOST('urlfrom','alpha'); else unset($_SESSION["urlfrom"]); - if (! GETPOST("username")) $focus_element='username'; + if (! GETPOST("username",'alpha')) $focus_element='username'; else $focus_element='password'; $demologin=''; diff --git a/htdocs/master.inc.php b/htdocs/master.inc.php index a8d068cfd7d..ce3080e32e4 100644 --- a/htdocs/master.inc.php +++ b/htdocs/master.inc.php @@ -152,7 +152,7 @@ else if (! empty($_ENV["dol_entity"])) // Entity inside a CLI script { $conf->entity = $_ENV["dol_entity"]; } -else if (isset($_POST["loginfunction"]) && GETPOST("entity")) // Just after a login page +else if (isset($_POST["loginfunction"]) && GETPOST("entity",'int')) // Just after a login page { $conf->entity = GETPOST("entity",'int'); } diff --git a/htdocs/product/class/productbatch.class.php b/htdocs/product/class/productbatch.class.php index 5ab70506693..64a43485604 100644 --- a/htdocs/product/class/productbatch.class.php +++ b/htdocs/product/class/productbatch.class.php @@ -154,7 +154,7 @@ class Productbatch extends CommonObject $sql.= " pl.sellby"; $sql.= " FROM ".MAIN_DB_PREFIX."product_batch as t INNER JOIN ".MAIN_DB_PREFIX."product_stock w on t.fk_product_stock = w.rowid"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_lot as pl on pl.fk_product = w.fk_product and pl.batch = t.batch"; + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_lot as pl on pl.fk_product = w.fk_product and pl.batch = t.batch"; $sql.= " WHERE t.rowid = ".$id; dol_syslog(get_class($this)."::fetch", LOG_DEBUG); @@ -205,9 +205,9 @@ class Productbatch extends CommonObject // TODO Check qty is ok for stock move. Negative may not be allowed. if ($this->qty < 0) { - + } - + // Update request $sql = "UPDATE ".MAIN_DB_PREFIX.self::$_table_element." SET"; $sql.= " fk_product_stock=".(isset($this->fk_product_stock)?$this->fk_product_stock:"null").","; @@ -435,7 +435,7 @@ class Productbatch extends CommonObject if (! empty($eatby)) array_push($where," eatby = '".$this->db->idate($eatby)."'"); // deprecated if (! empty($sellby)) array_push($where," sellby = '".$this->db->idate($sellby)."'"); // deprecated - + if (! empty($batch_number)) $sql.= " AND batch = '".$this->db->escape($batch_number)."'"; if (! empty($where)) $sql.= " AND (".implode(" OR ",$where).")"; @@ -493,7 +493,7 @@ class Productbatch extends CommonObject $sql.= " t.import_key"; if ($fk_product > 0) { - $sql.= ", pl.eatby as eatby, pl.sellby as sellby"; + $sql.= ", pl.rowid as lotid, pl.eatby as eatby, pl.sellby as sellby"; // TODO May add extrafields to ? } $sql.= " FROM ".MAIN_DB_PREFIX."product_batch as t"; @@ -517,6 +517,7 @@ class Productbatch extends CommonObject $tmp = new Productbatch($db); $tmp->id = $obj->rowid; + $tmp->lotid = $obj->lotid; $tmp->tms = $db->jdate($obj->tms); $tmp->fk_product_stock = $obj->fk_product_stock; $tmp->sellby = $db->jdate($obj->sellby ? $obj->sellby : $obj->oldsellby); diff --git a/htdocs/product/reassortlot.php b/htdocs/product/reassortlot.php index 5c89aa4845f..cf4e889e89e 100644 --- a/htdocs/product/reassortlot.php +++ b/htdocs/product/reassortlot.php @@ -28,6 +28,7 @@ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; +require_once DOL_DOCUMENT_ROOT.'/product/stock/class/productlot.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/stock/class/entrepot.class.php'; @@ -115,7 +116,7 @@ $sql.= ' p.duration, p.tosell as statut, p.tobuy, p.seuil_stock_alerte, p.desire $sql.= ' ps.fk_entrepot,'; $sql.= ' e.label as warehouse_ref, e.lieu as warehouse_lieu, e.fk_parent as warehouse_parent,'; $sql.= ' pb.batch, pb.eatby as oldeatby, pb.sellby as oldsellby,'; -$sql.= ' pl.eatby, pl.sellby,'; +$sql.= ' pl.rowid as lotid, pl.eatby, pl.sellby,'; $sql.= ' SUM(pb.qty) as stock_physique, COUNT(pb.rowid) as nbinbatchtable'; $sql.= ' FROM '.MAIN_DB_PREFIX.'product as p'; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_stock as ps on p.rowid = ps.fk_product'; // Detail for each warehouse @@ -157,7 +158,7 @@ $sql.= " p.duration, p.tosell, p.tobuy, p.seuil_stock_alerte, p.desiredstock, p. $sql.= " ps.fk_entrepot,"; $sql.= " e.label, e.lieu, e.fk_parent,"; $sql.= " pb.batch, pb.eatby, pb.sellby,"; -$sql.= " pl.eatby, pl.sellby"; +$sql.= " pl.rowid, pl.eatby, pl.sellby"; if ($toolowstock) $sql.= " HAVING SUM(".$db->ifsql('ps.reel IS NULL', '0', 'ps.reel').") < p.seuil_stock_alerte"; // Not used yet $sql.= $db->order($sortfield,$sortorder); @@ -306,6 +307,7 @@ if ($resql) print "\n"; $product_static=new Product($db); + $product_lot_static=new Productlot($db); $warehousetmp=new Entrepot($db); while ($i < min($num,$limit)) @@ -336,6 +338,13 @@ if ($resql) $product_static->type=$objp->fk_product_type; $product_static->entity=$objp->entity; + $product_lot_static->batch=$objp->batch; + $product_lot_static->product_id=$objp->rowid; + $product_lot_static->id=$objp->lotid; + $product_lot_static->eatby=$objp->eatby; + $product_lot_static->sellby=$objp->sellby; + + $warehousetmp->id=$objp->fk_entrepot; $warehousetmp->ref=$objp->warehouse_ref; $warehousetmp->label=$objp->warehouse_ref; @@ -372,7 +381,15 @@ if ($resql) print $warehousetmp->getNomUrl(1); } print ''; - print '
| '.$langs->trans("Label").' | |
| '.$langs->trans("Fieldentity").' | |
| '.$langs->trans("Fieldfk_product").' | |
| '.$langs->trans("Fieldbatch").' | |
| '.$langs->trans("Fieldfk_user_creat").' |