Merge pull request #11678 from atm-greg/develop_fk_projet_on_stock_movement
NEW Add fk projet on stock movement
This commit is contained in:
commit
5d1bfdaa29
@ -74,3 +74,5 @@ ALTER TABLE llx_payment_salary_extrafields ADD INDEX idx_payment_salary_extrafie
|
||||
ALTER TABLE llx_c_price_expression MODIFY COLUMN expression varchar(255) NOT NULL;
|
||||
|
||||
UPDATE llx_bank_url set url = REPLACE( url, 'compta/salaries/', 'salaries/');
|
||||
|
||||
ALTER TABLE llx_stock_mouvement ADD COLUMN fk_projet INTEGER NOT NULL DEFAULT 0 AFTER model_pdf;
|
||||
|
||||
@ -36,5 +36,6 @@ create table llx_stock_mouvement
|
||||
fk_project integer,
|
||||
fk_origin integer,
|
||||
origintype varchar(32),
|
||||
model_pdf varchar(255)
|
||||
model_pdf varchar(255),
|
||||
fk_projet integer NOT NULL DEFAULT 0
|
||||
)ENGINE=innodb;
|
||||
|
||||
@ -344,17 +344,31 @@ class MouvementStock extends CommonObject
|
||||
|
||||
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
|
||||
$origintype = $this->origin->element;
|
||||
$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 {
|
||||
$origintype = '';
|
||||
$fk_origin = 0;
|
||||
$fk_project = 0;
|
||||
}
|
||||
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."stock_mouvement(";
|
||||
$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.= " VALUES ('".$this->db->idate($now)."', ".$this->product_id.", ";
|
||||
$sql.= " ".($batch?"'".$batch."'":"null").", ";
|
||||
@ -366,7 +380,8 @@ class MouvementStock extends CommonObject
|
||||
$sql.= " ".($inventorycode?"'".$this->db->escape($inventorycode)."'":"null").",";
|
||||
$sql.= " '".price2num($price)."',";
|
||||
$sql.= " '".$fk_origin."',";
|
||||
$sql.= " '".$origintype."'";
|
||||
$sql.= " '".$origintype."',";
|
||||
$sql.= " ". $fk_project;
|
||||
$sql.= ")";
|
||||
|
||||
dol_syslog(get_class($this)."::_create insert record into stock_mouvement", LOG_DEBUG);
|
||||
@ -569,7 +584,8 @@ class MouvementStock extends CommonObject
|
||||
$sql .= " t.inventorycode,";
|
||||
$sql .= " t.batch,";
|
||||
$sql .= " t.eatby,";
|
||||
$sql .= " t.sellby";
|
||||
$sql .= " t.sellby,";
|
||||
$sql .= " t.fk_projet";
|
||||
$sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element . ' as t';
|
||||
$sql.= ' WHERE 1 = 1';
|
||||
//if (null !== $ref) {
|
||||
|
||||
@ -112,6 +112,7 @@ $arrayfields=array(
|
||||
'origin'=>array('label'=>$langs->trans("Origin"), 'checked'=>1),
|
||||
'm.value'=>array('label'=>$langs->trans("Qty"), 'checked'=>1),
|
||||
'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.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500)
|
||||
);
|
||||
@ -423,6 +424,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.batch, m.price,";
|
||||
$sql.= " m.type_mouvement,";
|
||||
$sql.= " m.fk_projet,";
|
||||
$sql.= " pl.rowid as lotid, pl.eatby, pl.sellby,";
|
||||
$sql.= " u.login, u.photo, u.lastname, u.firstname";
|
||||
// Add fields from extrafields
|
||||
@ -854,7 +856,14 @@ if ($resql)
|
||||
if (! empty($arrayfields['m.price']['checked']))
|
||||
{
|
||||
// Price
|
||||
print '<td class="liste_titre left">';
|
||||
print '<td class="liste_titre" align="left">';
|
||||
print ' ';
|
||||
print '</td>';
|
||||
}
|
||||
if (! empty($arrayfields['m.fk_projet']['checked']))
|
||||
{
|
||||
// fk_projet
|
||||
print '<td class="liste_titre" align="left">';
|
||||
print ' ';
|
||||
print '</td>';
|
||||
}
|
||||
@ -933,6 +942,9 @@ if ($resql)
|
||||
if (! empty($arrayfields['m.price']['checked'])) {
|
||||
print_liste_field_titre($arrayfields['m.price']['label'], $_SERVER["PHP_SELF"], "m.price", "", $param, '', $sortfield, $sortorder, 'right ');
|
||||
}
|
||||
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
|
||||
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
|
||||
@ -1100,6 +1112,13 @@ if ($resql)
|
||||
if ($objp->price != 0) print price($objp->price);
|
||||
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
|
||||
print '<td class="nowrap center">';
|
||||
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