New show on project "overview" tab the informations about movements stock
This commit is contained in:
parent
56d75c552d
commit
ccad6d6dde
@ -460,7 +460,7 @@ class FormProjets
|
|||||||
if ($table_element == 'projet_task') return ''; // Special cas of element we never link to a project (already always done)
|
if ($table_element == 'projet_task') return ''; // Special cas of element we never link to a project (already always done)
|
||||||
|
|
||||||
$linkedtothirdparty=false;
|
$linkedtothirdparty=false;
|
||||||
if (! in_array($table_element, array('don','expensereport_det','expensereport','loan'))) $linkedtothirdparty=true;
|
if (! in_array($table_element, array('don','expensereport_det','expensereport','loan','stock_mouvement'))) $linkedtothirdparty=true;
|
||||||
|
|
||||||
$sqlfilter='';
|
$sqlfilter='';
|
||||||
$projectkey="fk_projet";
|
$projectkey="fk_projet";
|
||||||
@ -499,6 +499,10 @@ class FormProjets
|
|||||||
case "fichinter":
|
case "fichinter":
|
||||||
$sql = "SELECT t.rowid, t.ref";
|
$sql = "SELECT t.rowid, t.ref";
|
||||||
break;
|
break;
|
||||||
|
case 'stock_mouvement':
|
||||||
|
$sql = 'SELECT t.rowid, t.label as ref';
|
||||||
|
$projectkey='fk_origin';
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
$sql = "SELECT t.rowid, t.ref";
|
$sql = "SELECT t.rowid, t.ref";
|
||||||
break;
|
break;
|
||||||
@ -512,7 +516,7 @@ class FormProjets
|
|||||||
if (is_numeric($socid)) $sql.= " AND t.fk_soc=".$socid;
|
if (is_numeric($socid)) $sql.= " AND t.fk_soc=".$socid;
|
||||||
else $sql.= " AND t.fk_soc IN (".$socid.")";
|
else $sql.= " AND t.fk_soc IN (".$socid.")";
|
||||||
}
|
}
|
||||||
if (! in_array($table_element, array('expensereport_det'))) $sql.= ' AND t.entity IN ('.getEntity('project',1).')';
|
if (! in_array($table_element, array('expensereport_det','stock_mouvement'))) $sql.= ' AND t.entity IN ('.getEntity('project',1).')';
|
||||||
if ($linkedtothirdparty) $sql.=" AND s.rowid = t.fk_soc";
|
if ($linkedtothirdparty) $sql.=" AND s.rowid = t.fk_soc";
|
||||||
if ($sqlfilter) $sql.= " AND ".$sqlfilter;
|
if ($sqlfilter) $sql.= " AND ".$sqlfilter;
|
||||||
$sql.= " ORDER BY ref DESC";
|
$sql.= " ORDER BY ref DESC";
|
||||||
|
|||||||
@ -22,6 +22,8 @@ Movements=Movements
|
|||||||
ErrorWarehouseRefRequired=Warehouse reference name is required
|
ErrorWarehouseRefRequired=Warehouse reference name is required
|
||||||
ListOfWarehouses=List of warehouses
|
ListOfWarehouses=List of warehouses
|
||||||
ListOfStockMovements=List of stock movements
|
ListOfStockMovements=List of stock movements
|
||||||
|
StockMovementForId=Movement ID %d
|
||||||
|
ListMouvementStockProject=List of stock movements associated to project
|
||||||
StocksArea=Warehouses area
|
StocksArea=Warehouses area
|
||||||
Location=Location
|
Location=Location
|
||||||
LocationSummary=Short name location
|
LocationSummary=Short name location
|
||||||
|
|||||||
@ -938,4 +938,90 @@ class MouvementStock extends CommonObject
|
|||||||
|
|
||||||
// There is no specific properties. All data into insert are provided as method parameter.
|
// There is no specific properties. All data into insert are provided as method parameter.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return a link (with optionaly the picto)
|
||||||
|
* Use this->id,this->lastname, this->firstname
|
||||||
|
*
|
||||||
|
* @param int $withpicto Include picto in link (0=No picto, 1=Include picto into link, 2=Only picto)
|
||||||
|
* @param string $option On what the link point to
|
||||||
|
* @param integer $notooltip 1=Disable tooltip
|
||||||
|
* @param int $maxlen Max length of visible user name
|
||||||
|
* @param string $morecss Add more css on link
|
||||||
|
* @return string String with URL
|
||||||
|
*/
|
||||||
|
function getNomUrl($withpicto=0, $option='', $notooltip=0, $maxlen=24, $morecss='')
|
||||||
|
{
|
||||||
|
global $langs, $conf, $db;
|
||||||
|
|
||||||
|
$result = '';
|
||||||
|
$companylink = '';
|
||||||
|
|
||||||
|
$label = '<u>' . $langs->trans("Movement") . ' '.$this->id.'</u>';
|
||||||
|
$label.= '<div width="100%">';
|
||||||
|
$label.= '<b>' . $langs->trans('Label') . ':</b> ' . $this->label;
|
||||||
|
$label.= '<br /><b>' . $langs->trans('Qty') . ':</b> ' .$this->qty;
|
||||||
|
$label.= '</div>';
|
||||||
|
|
||||||
|
$link = '<a href="'.DOL_URL_ROOT.'/product/stock/mouvement.php?id='.$this->warehouse_id.'&msid='.$this->id.'"';
|
||||||
|
$link.= ($notooltip?'':' title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip'.($morecss?' '.$morecss:'').'"');
|
||||||
|
$link.= '>';
|
||||||
|
$linkend='</a>';
|
||||||
|
|
||||||
|
if ($withpicto)
|
||||||
|
{
|
||||||
|
$result.=($link.img_object(($notooltip?'':$label), 'stock', ($notooltip?'':'class="classfortooltip"')).$linkend);
|
||||||
|
if ($withpicto != 2) $result.=' ';
|
||||||
|
}
|
||||||
|
$result.= $link . $this->id . $linkend;
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return label statut
|
||||||
|
*
|
||||||
|
* @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto
|
||||||
|
* @return string Label of status
|
||||||
|
*/
|
||||||
|
function getLibStatut($mode=0)
|
||||||
|
{
|
||||||
|
return $this->LibStatut($mode);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Renvoi le libelle d'un status donne
|
||||||
|
*
|
||||||
|
* @param int $status Id status
|
||||||
|
* @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto
|
||||||
|
* @return string Label of status
|
||||||
|
*/
|
||||||
|
function LibStatut($mode=0)
|
||||||
|
{
|
||||||
|
global $langs;
|
||||||
|
|
||||||
|
if ($mode == 0)
|
||||||
|
{
|
||||||
|
return $langs->trans('StatusNotApplicable');
|
||||||
|
}
|
||||||
|
if ($mode == 1)
|
||||||
|
{
|
||||||
|
return $langs->trans('StatusNotApplicable');
|
||||||
|
}
|
||||||
|
if ($mode == 2)
|
||||||
|
{
|
||||||
|
return img_picto($langs->trans('StatusNotApplicable'),'statut9').' '.$langs->trans('StatusNotApplicable');
|
||||||
|
}
|
||||||
|
if ($mode == 3)
|
||||||
|
{
|
||||||
|
return img_picto($langs->trans('StatusNotApplicable'),'statut9');
|
||||||
|
}
|
||||||
|
if ($mode == 4)
|
||||||
|
{
|
||||||
|
return img_picto($langs->trans('StatusNotApplicable'),'statut9').' '.$langs->trans('StatusNotApplicable');
|
||||||
|
}
|
||||||
|
if ($mode == 5)
|
||||||
|
{
|
||||||
|
return $langs->trans('StatusNotApplicable').' '.img_picto($langs->trans('StatusNotApplicable'),'statut9');
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -48,6 +48,7 @@ if (! empty($conf->productbatch->enabled)) $langs->load("productbatch");
|
|||||||
$result=restrictedArea($user,'stock');
|
$result=restrictedArea($user,'stock');
|
||||||
|
|
||||||
$id=GETPOST('id','int');
|
$id=GETPOST('id','int');
|
||||||
|
$msid=GETPOST('msid','int');
|
||||||
$product_id=GETPOST("product_id");
|
$product_id=GETPOST("product_id");
|
||||||
$action=GETPOST('action');
|
$action=GETPOST('action');
|
||||||
$cancel=GETPOST('cancel');
|
$cancel=GETPOST('cancel');
|
||||||
@ -431,6 +432,7 @@ if (is_array($extrafields->attribute_label) && count($extrafields->attribute_lab
|
|||||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."user as u ON m.fk_user_author = u.rowid";
|
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."user as u ON m.fk_user_author = u.rowid";
|
||||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_lot as pl ON m.batch = pl.batch AND m.fk_product = pl.fk_product";
|
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_lot as pl ON m.batch = pl.batch AND m.fk_product = pl.fk_product";
|
||||||
$sql.= " WHERE m.fk_product = p.rowid";
|
$sql.= " WHERE m.fk_product = p.rowid";
|
||||||
|
if ($msid > 0) $sql .= " AND m.rowid = ".$msid;
|
||||||
$sql.= " AND m.fk_entrepot = e.rowid";
|
$sql.= " AND m.fk_entrepot = e.rowid";
|
||||||
$sql.= " AND e.entity IN (".getEntity('stock', 1).")";
|
$sql.= " AND e.entity IN (".getEntity('stock', 1).")";
|
||||||
if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) $sql.= " AND p.fk_product_type = 0";
|
if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) $sql.= " AND p.fk_product_type = 0";
|
||||||
@ -511,8 +513,12 @@ if ($resql)
|
|||||||
|
|
||||||
$i = 0;
|
$i = 0;
|
||||||
$help_url='EN:Module_Stocks_En|FR:Module_Stock|ES:Módulo_Stocks';
|
$help_url='EN:Module_Stocks_En|FR:Module_Stock|ES:Módulo_Stocks';
|
||||||
$texte = $langs->trans("ListOfStockMovements");
|
if ($msid) $texte = $langs->trans('StockMovementForId', $msid);
|
||||||
if ($id) $texte.=' ('.$langs->trans("ForThisWarehouse").')';
|
else
|
||||||
|
{
|
||||||
|
$texte = $langs->trans("ListOfStockMovements");
|
||||||
|
if ($id) $texte.=' ('.$langs->trans("ForThisWarehouse").')';
|
||||||
|
}
|
||||||
llxHeader("",$texte,$help_url);
|
llxHeader("",$texte,$help_url);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@ -496,6 +496,10 @@ class Project extends CommonObject
|
|||||||
{
|
{
|
||||||
$sql = "SELECT DISTINCT pt.rowid, ptt.fk_user FROM " . MAIN_DB_PREFIX . "projet_task as pt, " . MAIN_DB_PREFIX . "projet_task_time as ptt WHERE pt.rowid = ptt.fk_task AND pt.fk_projet=" . $this->id;
|
$sql = "SELECT DISTINCT pt.rowid, ptt.fk_user FROM " . MAIN_DB_PREFIX . "projet_task as pt, " . MAIN_DB_PREFIX . "projet_task_time as ptt WHERE pt.rowid = ptt.fk_task AND pt.fk_projet=" . $this->id;
|
||||||
}
|
}
|
||||||
|
elseif ($type == 'stock_mouvement')
|
||||||
|
{
|
||||||
|
$sql = 'SELECT ms.rowid, ms.fk_user_author as fk_user FROM ' . MAIN_DB_PREFIX . 'stock_mouvement as ms WHERE ms.origintype = "project" AND ms.fk_origin = ' . $this->id . ' AND ms.type_mouvement = 1';
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$sql = "SELECT rowid FROM " . MAIN_DB_PREFIX . $tablename." WHERE fk_projet=" . $this->id;
|
$sql = "SELECT rowid FROM " . MAIN_DB_PREFIX . $tablename." WHERE fk_projet=" . $this->id;
|
||||||
|
|||||||
@ -48,6 +48,7 @@ if (! empty($conf->expensereport->enabled)) require_once DOL_DOCUMENT_ROOT.'/exp
|
|||||||
if (! empty($conf->agenda->enabled)) require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php';
|
if (! empty($conf->agenda->enabled)) require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php';
|
||||||
if (! empty($conf->don->enabled)) require_once DOL_DOCUMENT_ROOT.'/don/class/don.class.php';
|
if (! empty($conf->don->enabled)) require_once DOL_DOCUMENT_ROOT.'/don/class/don.class.php';
|
||||||
if (! empty($conf->loan->enabled)) require_once DOL_DOCUMENT_ROOT.'/loan/class/loan.class.php';
|
if (! empty($conf->loan->enabled)) require_once DOL_DOCUMENT_ROOT.'/loan/class/loan.class.php';
|
||||||
|
if (! empty($conf->stock->enabled)) require_once DOL_DOCUMENT_ROOT.'/product/stock/class/mouvementstock.class.php';
|
||||||
|
|
||||||
$langs->load("projects");
|
$langs->load("projects");
|
||||||
$langs->load("companies");
|
$langs->load("companies");
|
||||||
@ -397,6 +398,15 @@ $listofreferent=array(
|
|||||||
'buttonnew'=>'AddTimeSpent',
|
'buttonnew'=>'AddTimeSpent',
|
||||||
'testnew'=>$user->rights->projet->creer,
|
'testnew'=>$user->rights->projet->creer,
|
||||||
'test'=>($conf->projet->enabled && $user->rights->projet->lire && empty($conf->global->PROJECT_HIDE_TASKS))),
|
'test'=>($conf->projet->enabled && $user->rights->projet->lire && empty($conf->global->PROJECT_HIDE_TASKS))),
|
||||||
|
'stock_mouvement'=>array(
|
||||||
|
'name'=>"MouvementStockAssociated",
|
||||||
|
'title'=>"ListMouvementStockProject",
|
||||||
|
'class'=>'MouvementStock',
|
||||||
|
'margin'=>'minus',
|
||||||
|
'table'=>'stock_mouvement',
|
||||||
|
'datefieldname'=>'datem',
|
||||||
|
'disableamount'=>0,
|
||||||
|
'test'=>$conf->stock->enabled && $user->rights->stock->mouvement->lire),
|
||||||
/* No need for this, available on dedicated tab "Agenda/Events"
|
/* No need for this, available on dedicated tab "Agenda/Events"
|
||||||
'agenda'=>array(
|
'agenda'=>array(
|
||||||
'name'=>"Agenda",
|
'name'=>"Agenda",
|
||||||
@ -483,6 +493,7 @@ $langs->load("bills");
|
|||||||
$langs->load("orders");
|
$langs->load("orders");
|
||||||
$langs->load("proposals");
|
$langs->load("proposals");
|
||||||
$langs->load("margins");
|
$langs->load("margins");
|
||||||
|
if (!empty($conf->stock->enabled)) $langs->load('stocks');
|
||||||
|
|
||||||
print load_fiche_titre($langs->trans("Profit"), '', 'title_accountancy');
|
print load_fiche_titre($langs->trans("Profit"), '', 'title_accountancy');
|
||||||
|
|
||||||
@ -529,6 +540,7 @@ foreach ($listofreferent as $key => $value)
|
|||||||
// Special cases
|
// Special cases
|
||||||
if ($tablename != 'expensereport_det' && method_exists($element, 'fetch_thirdparty')) $element->fetch_thirdparty();
|
if ($tablename != 'expensereport_det' && method_exists($element, 'fetch_thirdparty')) $element->fetch_thirdparty();
|
||||||
if ($tablename == 'don') $total_ht_by_line=$element->amount;
|
if ($tablename == 'don') $total_ht_by_line=$element->amount;
|
||||||
|
elseif ($tablename == 'stock_mouvement') $total_ht_by_line=$element->price*abs($element->qty);
|
||||||
elseif ($tablename == 'projet_task')
|
elseif ($tablename == 'projet_task')
|
||||||
{
|
{
|
||||||
if ($idofelementuser)
|
if ($idofelementuser)
|
||||||
@ -553,6 +565,7 @@ foreach ($listofreferent as $key => $value)
|
|||||||
if ($qualifiedfortotal) $total_ht = $total_ht + $total_ht_by_line;
|
if ($qualifiedfortotal) $total_ht = $total_ht + $total_ht_by_line;
|
||||||
|
|
||||||
if ($tablename == 'don') $total_ttc_by_line=$element->amount;
|
if ($tablename == 'don') $total_ttc_by_line=$element->amount;
|
||||||
|
elseif ($tablename == 'stock_mouvement') $total_ttc_by_line=$element->price*abs($element->qty);
|
||||||
elseif ($tablename == 'projet_task')
|
elseif ($tablename == 'projet_task')
|
||||||
{
|
{
|
||||||
$defaultvat = get_default_tva($mysoc, $mysoc);
|
$defaultvat = get_default_tva($mysoc, $mysoc);
|
||||||
@ -601,6 +614,9 @@ foreach ($listofreferent as $key => $value)
|
|||||||
case 'Contrat':
|
case 'Contrat':
|
||||||
$newclassname = 'Contract';
|
$newclassname = 'Contract';
|
||||||
break;
|
break;
|
||||||
|
case 'MouvementStock':
|
||||||
|
$newclassname = 'StockMovement';
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
$newclassname = $classname;
|
$newclassname = $classname;
|
||||||
}
|
}
|
||||||
@ -717,7 +733,7 @@ foreach ($listofreferent as $key => $value)
|
|||||||
// Thirdparty or user
|
// Thirdparty or user
|
||||||
print '<td>';
|
print '<td>';
|
||||||
if (in_array($tablename, array('projet_task')) && $key == 'project_task') print ''; // if $key == 'project_task', we don't want details per user
|
if (in_array($tablename, array('projet_task')) && $key == 'project_task') print ''; // if $key == 'project_task', we don't want details per user
|
||||||
elseif (in_array($tablename, array('expensereport_det','don','projet_task'))) print $langs->trans("User");
|
elseif (in_array($tablename, array('expensereport_det','don','projet_task','stock_mouvement'))) print $langs->trans("User");
|
||||||
else print $langs->trans("ThirdParty");
|
else print $langs->trans("ThirdParty");
|
||||||
print '</td>';
|
print '</td>';
|
||||||
// Amount HT
|
// Amount HT
|
||||||
@ -800,7 +816,7 @@ foreach ($listofreferent as $key => $value)
|
|||||||
print "<tr ".$bc[$var].">";
|
print "<tr ".$bc[$var].">";
|
||||||
// Remove link
|
// Remove link
|
||||||
print '<td style="width: 24px">';
|
print '<td style="width: 24px">';
|
||||||
if ($tablename != 'projet_task')
|
if ($tablename != 'projet_task' && $tablename != 'stock_mouvement')
|
||||||
{
|
{
|
||||||
print '<a href="' . $_SERVER["PHP_SELF"] . '?id=' . $projectid . '&action=unlink&tablename=' . $tablename . '&elementselect=' . $element->id . '">' . img_picto($langs->trans('Unlink'), 'editdelete') . '</a>';
|
print '<a href="' . $_SERVER["PHP_SELF"] . '?id=' . $projectid . '&action=unlink&tablename=' . $tablename . '&elementselect=' . $element->id . '">' . img_picto($langs->trans('Unlink'), 'editdelete') . '</a>';
|
||||||
}
|
}
|
||||||
@ -848,6 +864,7 @@ foreach ($listofreferent as $key => $value)
|
|||||||
// Date or TimeSpent
|
// Date or TimeSpent
|
||||||
$date=''; $total_time_by_line = null;
|
$date=''; $total_time_by_line = null;
|
||||||
if ($tablename == 'expensereport_det') $date = $element->date; // No draft status on lines
|
if ($tablename == 'expensereport_det') $date = $element->date; // No draft status on lines
|
||||||
|
elseif ($tablename == 'stock_mouvement') $date = $element->datem;
|
||||||
elseif (! empty($element->status) || ! empty($element->statut) || ! empty($element->fk_status))
|
elseif (! empty($element->status) || ! empty($element->statut) || ! empty($element->fk_status))
|
||||||
{
|
{
|
||||||
if ($tablename=='don') $date = $element->datedon;
|
if ($tablename=='don') $date = $element->datedon;
|
||||||
@ -889,7 +906,7 @@ foreach ($listofreferent as $key => $value)
|
|||||||
$tmpuser->fetch($expensereport->fk_user_author);
|
$tmpuser->fetch($expensereport->fk_user_author);
|
||||||
print $tmpuser->getNomUrl(1,'',48);
|
print $tmpuser->getNomUrl(1,'',48);
|
||||||
}
|
}
|
||||||
else if ($tablename == 'don')
|
else if ($tablename == 'don' || $tablename == 'stock_mouvement')
|
||||||
{
|
{
|
||||||
if ($element->fk_user_author > 0)
|
if ($element->fk_user_author > 0)
|
||||||
{
|
{
|
||||||
@ -911,6 +928,7 @@ foreach ($listofreferent as $key => $value)
|
|||||||
$total_ht_by_line=null;
|
$total_ht_by_line=null;
|
||||||
$othermessage='';
|
$othermessage='';
|
||||||
if ($tablename == 'don') $total_ht_by_line=$element->amount;
|
if ($tablename == 'don') $total_ht_by_line=$element->amount;
|
||||||
|
elseif ($tablename == 'stock_mouvement') $total_ht_by_line=$element->price*abs($element->qty);
|
||||||
elseif (in_array($tablename, array('projet_task')))
|
elseif (in_array($tablename, array('projet_task')))
|
||||||
{
|
{
|
||||||
if (! empty($conf->salaries->enabled))
|
if (! empty($conf->salaries->enabled))
|
||||||
@ -950,6 +968,7 @@ foreach ($listofreferent as $key => $value)
|
|||||||
{
|
{
|
||||||
$total_ttc_by_line=null;
|
$total_ttc_by_line=null;
|
||||||
if ($tablename == 'don') $total_ttc_by_line=$element->amount;
|
if ($tablename == 'don') $total_ttc_by_line=$element->amount;
|
||||||
|
elseif ($tablename == 'stock_mouvement') $total_ttc_by_line=$element->price*abs($element->qty);
|
||||||
elseif ($tablename == 'projet_task')
|
elseif ($tablename == 'projet_task')
|
||||||
{
|
{
|
||||||
if (! empty($conf->salaries->enabled))
|
if (! empty($conf->salaries->enabled))
|
||||||
@ -998,6 +1017,10 @@ foreach ($listofreferent as $key => $value)
|
|||||||
print $element->progress.' %';
|
print $element->progress.' %';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if ($tablename == 'stock_mouvement')
|
||||||
|
{
|
||||||
|
print $element->getLibStatut(3);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
print $element->getLibStatut(5);
|
print $element->getLibStatut(5);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user