add fk_projet on stock movements
This commit is contained in:
parent
c647195689
commit
acdf13d769
@ -562,3 +562,5 @@ ALTER TABLE llx_advtargetemailing DROP COLUMN fk_mailing;
|
|||||||
DROP TABLE llx_ticket_logs;
|
DROP TABLE llx_ticket_logs;
|
||||||
|
|
||||||
ALTER TABLE llx_actioncomm MODIFY COLUMN code varchar(50);
|
ALTER TABLE llx_actioncomm MODIFY COLUMN code varchar(50);
|
||||||
|
|
||||||
|
ALTER TABLE llx_stock_mouvement ADD COLUMN fk_projet INTEGER NOT NULL DEFAULT 0 AFTER model_pdf;
|
||||||
|
|||||||
@ -35,5 +35,6 @@ create table llx_stock_mouvement
|
|||||||
inventorycode varchar(128), -- Code used to group different movement line into one operation (may be an inventory, a mass picking)
|
inventorycode varchar(128), -- Code used to group different movement line into one operation (may be an inventory, a mass picking)
|
||||||
fk_origin integer,
|
fk_origin integer,
|
||||||
origintype varchar(32),
|
origintype varchar(32),
|
||||||
model_pdf varchar(255)
|
model_pdf varchar(255),
|
||||||
|
fk_projet integer NOT NULL DEFAULT 0
|
||||||
)ENGINE=innodb;
|
)ENGINE=innodb;
|
||||||
|
|||||||
@ -322,17 +322,31 @@ class MouvementStock extends CommonObject
|
|||||||
|
|
||||||
if ($movestock && $entrepot_id > 0) // Change stock for current product, change for subproduct is done after
|
if ($movestock && $entrepot_id > 0) // Change stock for current product, change for subproduct is done after
|
||||||
{
|
{
|
||||||
|
$fk_project = 0;
|
||||||
if(!empty($this->origin)) { // This is set by caller for tracking reason
|
if(!empty($this->origin)) { // This is set by caller for tracking reason
|
||||||
$origintype = $this->origin->element;
|
$origintype = $this->origin->element;
|
||||||
$fk_origin = $this->origin->id;
|
$fk_origin = $this->origin->id;
|
||||||
|
if($origintype == 'project') $fk_project = $fk_origin;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$res = $this->origin->fetch($fk_origin);
|
||||||
|
if ($res > 0)
|
||||||
|
{
|
||||||
|
if (!empty($this->origin->fk_project))
|
||||||
|
{
|
||||||
|
$fk_project = $this->origin->fk_project;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
$origintype = '';
|
$origintype = '';
|
||||||
$fk_origin = 0;
|
$fk_origin = 0;
|
||||||
|
$fk_project = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."stock_mouvement(";
|
$sql = "INSERT INTO ".MAIN_DB_PREFIX."stock_mouvement(";
|
||||||
$sql.= " datem, fk_product, batch, eatby, sellby,";
|
$sql.= " datem, fk_product, batch, eatby, sellby,";
|
||||||
$sql.= " fk_entrepot, value, type_mouvement, fk_user_author, label, inventorycode, price, fk_origin, origintype";
|
$sql.= " fk_entrepot, value, type_mouvement, fk_user_author, label, inventorycode, price, fk_origin, origintype, fk_projet";
|
||||||
$sql.= ")";
|
$sql.= ")";
|
||||||
$sql.= " VALUES ('".$this->db->idate($now)."', ".$this->product_id.", ";
|
$sql.= " VALUES ('".$this->db->idate($now)."', ".$this->product_id.", ";
|
||||||
$sql.= " ".($batch?"'".$batch."'":"null").", ";
|
$sql.= " ".($batch?"'".$batch."'":"null").", ";
|
||||||
@ -344,7 +358,8 @@ class MouvementStock extends CommonObject
|
|||||||
$sql.= " ".($inventorycode?"'".$this->db->escape($inventorycode)."'":"null").",";
|
$sql.= " ".($inventorycode?"'".$this->db->escape($inventorycode)."'":"null").",";
|
||||||
$sql.= " '".price2num($price)."',";
|
$sql.= " '".price2num($price)."',";
|
||||||
$sql.= " '".$fk_origin."',";
|
$sql.= " '".$fk_origin."',";
|
||||||
$sql.= " '".$origintype."'";
|
$sql.= " '".$origintype."',";
|
||||||
|
$sql.= " ". $fk_project;
|
||||||
$sql.= ")";
|
$sql.= ")";
|
||||||
|
|
||||||
dol_syslog(get_class($this)."::_create insert record into stock_mouvement", LOG_DEBUG);
|
dol_syslog(get_class($this)."::_create insert record into stock_mouvement", LOG_DEBUG);
|
||||||
@ -548,7 +563,8 @@ class MouvementStock extends CommonObject
|
|||||||
$sql .= " t.inventorycode,";
|
$sql .= " t.inventorycode,";
|
||||||
$sql .= " t.batch,";
|
$sql .= " t.batch,";
|
||||||
$sql .= " t.eatby,";
|
$sql .= " t.eatby,";
|
||||||
$sql .= " t.sellby";
|
$sql .= " t.sellby,";
|
||||||
|
$sql .= " t.fk_projet";
|
||||||
$sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element . ' as t';
|
$sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element . ' as t';
|
||||||
$sql.= ' WHERE 1 = 1';
|
$sql.= ' WHERE 1 = 1';
|
||||||
//if (null !== $ref) {
|
//if (null !== $ref) {
|
||||||
|
|||||||
@ -109,6 +109,7 @@ $arrayfields=array(
|
|||||||
'origin'=>array('label'=>$langs->trans("Origin"), 'checked'=>1),
|
'origin'=>array('label'=>$langs->trans("Origin"), 'checked'=>1),
|
||||||
'm.value'=>array('label'=>$langs->trans("Qty"), 'checked'=>1),
|
'm.value'=>array('label'=>$langs->trans("Qty"), 'checked'=>1),
|
||||||
'm.price'=>array('label'=>$langs->trans("UnitPurchaseValue"), 'checked'=>0),
|
'm.price'=>array('label'=>$langs->trans("UnitPurchaseValue"), 'checked'=>0),
|
||||||
|
'm.fk_projet'=>array('label'=>$langs->trans('Project'), 'checked'=>0)
|
||||||
//'m.datec'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0, 'position'=>500),
|
//'m.datec'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0, 'position'=>500),
|
||||||
//'m.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500)
|
//'m.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500)
|
||||||
);
|
);
|
||||||
@ -442,6 +443,7 @@ $sql.= " e.ref as stock, e.rowid as entrepot_id, e.lieu,";
|
|||||||
$sql.= " m.rowid as mid, m.value as qty, m.datem, m.fk_user_author, m.label, m.inventorycode, m.fk_origin, m.origintype,";
|
$sql.= " m.rowid as mid, m.value as qty, m.datem, m.fk_user_author, m.label, m.inventorycode, m.fk_origin, m.origintype,";
|
||||||
$sql.= " m.batch, m.price,";
|
$sql.= " m.batch, m.price,";
|
||||||
$sql.= " m.type_mouvement,";
|
$sql.= " m.type_mouvement,";
|
||||||
|
$sql.= " m.fk_projet,";
|
||||||
$sql.= " pl.rowid as lotid, pl.eatby, pl.sellby,";
|
$sql.= " pl.rowid as lotid, pl.eatby, pl.sellby,";
|
||||||
$sql.= " u.login, u.photo, u.lastname, u.firstname";
|
$sql.= " u.login, u.photo, u.lastname, u.firstname";
|
||||||
// Add fields from extrafields
|
// Add fields from extrafields
|
||||||
@ -874,6 +876,13 @@ if ($resql)
|
|||||||
print ' ';
|
print ' ';
|
||||||
print '</td>';
|
print '</td>';
|
||||||
}
|
}
|
||||||
|
if (! empty($arrayfields['m.fk_projet']['checked']))
|
||||||
|
{
|
||||||
|
// Price
|
||||||
|
print '<td class="liste_titre" align="left">';
|
||||||
|
print ' ';
|
||||||
|
print '</td>';
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Extra fields
|
// Extra fields
|
||||||
@ -918,6 +927,7 @@ if ($resql)
|
|||||||
if (! empty($arrayfields['origin']['checked'])) print_liste_field_titre($arrayfields['origin']['label'],$_SERVER["PHP_SELF"], "","",$param,"",$sortfield,$sortorder);
|
if (! empty($arrayfields['origin']['checked'])) print_liste_field_titre($arrayfields['origin']['label'],$_SERVER["PHP_SELF"], "","",$param,"",$sortfield,$sortorder);
|
||||||
if (! empty($arrayfields['m.value']['checked'])) print_liste_field_titre($arrayfields['m.value']['label'],$_SERVER["PHP_SELF"], "m.value","",$param,'align="right"',$sortfield,$sortorder);
|
if (! empty($arrayfields['m.value']['checked'])) print_liste_field_titre($arrayfields['m.value']['label'],$_SERVER["PHP_SELF"], "m.value","",$param,'align="right"',$sortfield,$sortorder);
|
||||||
if (! empty($arrayfields['m.price']['checked'])) print_liste_field_titre($arrayfields['m.price']['label'],$_SERVER["PHP_SELF"], "m.price","",$param,'align="right"',$sortfield,$sortorder);
|
if (! empty($arrayfields['m.price']['checked'])) print_liste_field_titre($arrayfields['m.price']['label'],$_SERVER["PHP_SELF"], "m.price","",$param,'align="right"',$sortfield,$sortorder);
|
||||||
|
if (! empty($arrayfields['m.fk_projet']['checked'])) print_liste_field_titre($arrayfields['m.fk_projet']['label'],$_SERVER["PHP_SELF"], "m.fk_projet","",$param,'align="right"',$sortfield,$sortorder);
|
||||||
|
|
||||||
// Extra fields
|
// Extra fields
|
||||||
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
|
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
|
||||||
@ -1060,6 +1070,13 @@ if ($resql)
|
|||||||
if ($objp->price != 0) print price($objp->price);
|
if ($objp->price != 0) print price($objp->price);
|
||||||
print '</td>';
|
print '</td>';
|
||||||
}
|
}
|
||||||
|
if (! empty($arrayfields['m.fk_projet']['checked']))
|
||||||
|
{
|
||||||
|
// fk_projet
|
||||||
|
print '<td align="right">';
|
||||||
|
if ($objp->fk_projet != 0) print $movement->get_origin($objp->fk_projet, 'project');
|
||||||
|
print '</td>';
|
||||||
|
}
|
||||||
// Action column
|
// Action column
|
||||||
print '<td class="nowrap" align="center">';
|
print '<td class="nowrap" align="center">';
|
||||||
if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
|
if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user