Add tab with stock movements
This commit is contained in:
parent
c6f46e0aec
commit
d2bafe3052
@ -47,11 +47,11 @@ require '../main.inc.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/product/stock/class/entrepot.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/product/stock/class/productlot.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/product/stock/class/mouvementstock.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/product/stock/class/productlot.class.php';
|
||||
dol_include_once('/mrp/class/mo.class.php');
|
||||
dol_include_once('/mrp/lib/mrp_mo.lib.php');
|
||||
|
||||
@ -64,11 +64,32 @@ $ref = GETPOST('ref', 'alpha');
|
||||
$action = GETPOST('action', 'aZ09');
|
||||
$confirm = GETPOST('confirm', 'alpha');
|
||||
$cancel = GETPOST('cancel', 'aZ09');
|
||||
$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'mocard'; // To manage different context of search
|
||||
$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'mostockmovement'; // To manage different context of search
|
||||
$backtopage = GETPOST('backtopage', 'alpha');
|
||||
//$lineid = GETPOST('lineid', 'int');
|
||||
|
||||
$collapse = GETPOST('collapse', 'aZ09comma');
|
||||
$msid = GETPOST('msid', 'int');
|
||||
$year = GETPOST("year", 'int');
|
||||
$month = GETPOST("month", 'int');
|
||||
$search_ref = GETPOST('search_ref', 'alpha');
|
||||
$search_movement = GETPOST("search_movement", 'alpha');
|
||||
$search_product_ref = trim(GETPOST("search_product_ref", 'alpha'));
|
||||
$search_product = trim(GETPOST("search_product", 'alpha'));
|
||||
$search_warehouse = trim(GETPOST("search_warehouse", 'alpha'));
|
||||
$search_inventorycode = trim(GETPOST("search_inventorycode", 'alpha'));
|
||||
$search_user = trim(GETPOST("search_user", 'alpha'));
|
||||
$search_batch = trim(GETPOST("search_batch", 'alpha'));
|
||||
$search_qty = trim(GETPOST("search_qty", 'alpha'));
|
||||
$search_type_mouvement = GETPOST('search_type_mouvement', 'int');
|
||||
|
||||
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
|
||||
$page = GETPOST("page", 'int');
|
||||
$sortfield = GETPOST("sortfield", 'alpha');
|
||||
$sortorder = GETPOST("sortorder", 'alpha');
|
||||
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
|
||||
$offset = $limit * $page;
|
||||
if (!$sortfield) $sortfield = "m.datem";
|
||||
if (!$sortorder) $sortorder = "DESC";
|
||||
|
||||
// Initialize technical objects
|
||||
$object = new Mo($db);
|
||||
@ -100,6 +121,31 @@ include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be includ
|
||||
//$isdraft = (($object->statut == $object::STATUS_DRAFT) ? 1 : 0);
|
||||
//$result = restrictedArea($user, 'mrp', $object->id, '', '', 'fk_soc', 'rowid', $isdraft);
|
||||
|
||||
$objectlist = new MouvementStock($db);
|
||||
|
||||
// Definition of fields for list
|
||||
$arrayfields = array(
|
||||
'm.rowid'=>array('label'=>$langs->trans("Ref"), 'checked'=>1),
|
||||
'm.datem'=>array('label'=>$langs->trans("Date"), 'checked'=>1),
|
||||
'p.ref'=>array('label'=>$langs->trans("ProductRef"), 'checked'=>1, 'css'=>'maxwidth100'),
|
||||
'p.label'=>array('label'=>$langs->trans("ProductLabel"), 'checked'=>1),
|
||||
'm.batch'=>array('label'=>$langs->trans("BatchNumberShort"), 'checked'=>1, 'enabled'=>(!empty($conf->productbatch->enabled))),
|
||||
'pl.eatby'=>array('label'=>$langs->trans("EatByDate"), 'checked'=>0, 'position'=>10, 'enabled'=>(!empty($conf->productbatch->enabled))),
|
||||
'pl.sellby'=>array('label'=>$langs->trans("SellByDate"), 'checked'=>0, 'position'=>10, 'enabled'=>(!empty($conf->productbatch->enabled))),
|
||||
'e.ref'=>array('label'=>$langs->trans("Warehouse"), 'checked'=>1),
|
||||
'm.fk_user_author'=>array('label'=>$langs->trans("Author"), 'checked'=>0),
|
||||
'm.inventorycode'=>array('label'=>$langs->trans("InventoryCodeShort"), 'checked'=>1),
|
||||
'm.label'=>array('label'=>$langs->trans("MovementLabel"), 'checked'=>1),
|
||||
'm.type_mouvement'=>array('label'=>$langs->trans("TypeMovement"), 'checked'=>1),
|
||||
'origin'=>array('label'=>$langs->trans("Origin"), 'enabled'=>0, 'checked'=>0),
|
||||
'm.value'=>array('label'=>$langs->trans("Qty"), 'checked'=>1),
|
||||
'm.price'=>array('label'=>$langs->trans("UnitPurchaseValue"), 'enabled'=>0, 'checked'=>0),
|
||||
//'m.datec'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0, 'position'=>500),
|
||||
//'m.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500)
|
||||
);
|
||||
$objectlist->fields = dol_sort_array($objectlist->fields, 'position');
|
||||
$arrayfields = dol_sort_array($arrayfields, 'position');
|
||||
|
||||
$permissionnote = $user->rights->mrp->write; // Used by the include of actions_setnotes.inc.php
|
||||
$permissiondellink = $user->rights->mrp->write; // Used by the include of actions_dellink.inc.php
|
||||
$permissiontoadd = $user->rights->mrp->write; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php
|
||||
@ -113,10 +159,35 @@ $permissiontoproduce = $permissiontoadd;
|
||||
* Actions
|
||||
*/
|
||||
|
||||
if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; }
|
||||
if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; }
|
||||
|
||||
$parameters = array();
|
||||
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
|
||||
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
||||
|
||||
include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
|
||||
|
||||
// Do we click on purge search criteria ?
|
||||
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // Both test are required to be compatible with all browsers
|
||||
{
|
||||
$year = '';
|
||||
$month = '';
|
||||
$search_ref = '';
|
||||
$search_movement = "";
|
||||
$search_type_mouvement = "";
|
||||
$search_inventorycode = "";
|
||||
$search_product_ref = "";
|
||||
$search_product = "";
|
||||
$search_warehouse = "";
|
||||
$search_user = "";
|
||||
$search_batch = "";
|
||||
$search_qty = '';
|
||||
$sall = "";
|
||||
$toselect = '';
|
||||
$search_array_options = array();
|
||||
}
|
||||
|
||||
if (empty($reshook))
|
||||
{
|
||||
$error = 0;
|
||||
@ -171,8 +242,10 @@ if (empty($reshook))
|
||||
$form = new Form($db);
|
||||
$formproject = new FormProjets($db);
|
||||
$formproduct = new FormProduct($db);
|
||||
$tmpwarehouse = new Entrepot($db);
|
||||
$tmpbatch = new Productlot($db);
|
||||
$productstatic = new Product($db);
|
||||
$productlot = new ProductLot($db);
|
||||
$warehousestatic = new Entrepot($db);
|
||||
$userstatic = new User($db);
|
||||
|
||||
llxHeader('', $langs->trans('Mo'), '');
|
||||
|
||||
@ -334,7 +407,480 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
|
||||
*/
|
||||
|
||||
|
||||
$sql = "SELECT p.rowid, p.ref as product_ref, p.label as produit, p.tobatch, p.fk_product_type as type, p.entity,";
|
||||
$sql .= " e.ref as warehouse_ref, 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 .= " pl.rowid as lotid, pl.eatby, pl.sellby,";
|
||||
$sql .= " u.login, u.photo, u.lastname, u.firstname";
|
||||
// Add fields from extrafields
|
||||
if (!empty($extrafields->attributes[$objectlist->table_element]['label'])) {
|
||||
foreach ($extrafields->attributes[$objectlist->table_element]['label'] as $key => $val) $sql .= ($extrafields->attributes[$objectlist->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : '');
|
||||
}
|
||||
// Add fields from hooks
|
||||
$parameters = array();
|
||||
$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $objectlist may have been modified by hook
|
||||
$sql .= $hookmanager->resPrint;
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."entrepot as e,";
|
||||
$sql .= " ".MAIN_DB_PREFIX."product as p,";
|
||||
$sql .= " ".MAIN_DB_PREFIX."stock_mouvement as m";
|
||||
if (is_array($extrafields->attributes[$objectlist->table_element]['label']) && count($extrafields->attributes[$objectlist->table_element]['label'])) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$objectlist->table_element."_extrafields as ef on (m.rowid = ef.fk_object)";
|
||||
$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 .= " WHERE m.fk_product = p.rowid";
|
||||
$sql .= " AND m.origintype = 'mo' AND m.fk_origin = ".(int) $object->id;
|
||||
if ($msid > 0) $sql .= " AND m.rowid = ".$msid;
|
||||
$sql .= " AND m.fk_entrepot = e.rowid";
|
||||
$sql .= " AND e.entity IN (".getEntity('stock').")";
|
||||
if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) $sql .= " AND p.fk_product_type = 0";
|
||||
$sql .= dolSqlDateFilter('m.datem', 0, $month, $year);
|
||||
if (!empty($search_ref)) $sql .= natural_search('m.rowid', $search_ref, 1);
|
||||
if (!empty($search_movement)) $sql .= natural_search('m.label', $search_movement);
|
||||
if (!empty($search_inventorycode)) $sql .= natural_search('m.inventorycode', $search_inventorycode);
|
||||
if (!empty($search_product_ref)) $sql .= natural_search('p.ref', $search_product_ref);
|
||||
if (!empty($search_product)) $sql .= natural_search('p.label', $search_product);
|
||||
if ($search_warehouse != '' && $search_warehouse != '-1') $sql .= natural_search('e.rowid', $search_warehouse, 2);
|
||||
if (!empty($search_user)) $sql .= natural_search('u.login', $search_user);
|
||||
if (!empty($search_batch)) $sql .= natural_search('m.batch', $search_batch);
|
||||
if ($search_qty != '') $sql .= natural_search('m.value', $search_qty, 1);
|
||||
if ($search_type_mouvement != '' && $search_type_mouvement != '-1') $sql .= natural_search('m.type_mouvement', $search_type_mouvement, 2);
|
||||
// Add where from extra fields
|
||||
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
|
||||
// Add where from hooks
|
||||
$parameters = array();
|
||||
$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $objectlist may have been modified by hook
|
||||
$sql .= $hookmanager->resPrint;
|
||||
$sql .= $db->order($sortfield, $sortorder);
|
||||
|
||||
$nbtotalofrecords = '';
|
||||
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
|
||||
{
|
||||
$result = $db->query($sql);
|
||||
$nbtotalofrecords = $db->num_rows($result);
|
||||
if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0
|
||||
{
|
||||
$page = 0;
|
||||
$offset = 0;
|
||||
}
|
||||
}
|
||||
$sql .= $db->plimit($limit + 1, $offset);
|
||||
|
||||
$param = '';
|
||||
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage);
|
||||
if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit);
|
||||
if ($id > 0) $param .= '&id='.urlencode($id);
|
||||
if ($search_movement) $param .= '&search_movement='.urlencode($search_movement);
|
||||
if ($search_inventorycode) $param .= '&search_inventorycode='.urlencode($search_inventorycode);
|
||||
if ($search_type_mouvement) $param .= '&search_type_mouvement='.urlencode($search_type_mouvement);
|
||||
if ($search_product_ref) $param .= '&search_product_ref='.urlencode($search_product_ref);
|
||||
if ($search_product) $param .= '&search_product='.urlencode($search_product);
|
||||
if ($search_batch) $param .= '&search_batch='.urlencode($search_batch);
|
||||
if ($search_warehouse > 0) $param .= '&search_warehouse='.urlencode($search_warehouse);
|
||||
if ($search_user) $param .= '&search_user='.urlencode($search_user);
|
||||
|
||||
// Add $param from extra fields
|
||||
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
|
||||
|
||||
// List of mass actions available
|
||||
$arrayofmassactions = array(
|
||||
// 'presend'=>$langs->trans("SendByMail"),
|
||||
// 'builddoc'=>$langs->trans("PDFMerge"),
|
||||
);
|
||||
//if ($user->rights->stock->supprimer) $arrayofmassactions['predelete']='<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete");
|
||||
if (in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array();
|
||||
$massactionbutton = $form->selectMassAction('', $arrayofmassactions);
|
||||
|
||||
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
|
||||
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
|
||||
print '<input type="hidden" name="token" value="'.newToken().'">';
|
||||
print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
|
||||
print '<input type="hidden" name="action" value="list">';
|
||||
print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
|
||||
print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
|
||||
print '<input type="hidden" name="page" value="'.$page.'">';
|
||||
print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
|
||||
if ($id > 0) print '<input type="hidden" name="id" value="'.$id.'">';
|
||||
|
||||
if ($id > 0) print_barre_liste($texte, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, '', 0, '', '', $limit);
|
||||
else print_barre_liste($texte, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'generic', 0, '', '', $limit);
|
||||
|
||||
$moreforfilter = '';
|
||||
|
||||
$parameters = array();
|
||||
$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook
|
||||
if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint;
|
||||
else $moreforfilter = $hookmanager->resPrint;
|
||||
|
||||
if (!empty($moreforfilter))
|
||||
{
|
||||
print '<div class="liste_titre liste_titre_bydiv centpercent">';
|
||||
print $moreforfilter;
|
||||
print '</div>';
|
||||
}
|
||||
|
||||
$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
|
||||
$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
|
||||
|
||||
print '<div class="div-table-responsive">';
|
||||
print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
|
||||
|
||||
// Fields title search
|
||||
print '<tr class="liste_titre_filter">';
|
||||
if (!empty($arrayfields['m.rowid']['checked']))
|
||||
{
|
||||
// Ref
|
||||
print '<td class="liste_titre left">';
|
||||
print '<input class="flat maxwidth25" type="text" name="search_ref" value="'.dol_escape_htmltag($search_ref).'">';
|
||||
print '</td>';
|
||||
}
|
||||
if (!empty($arrayfields['m.datem']['checked']))
|
||||
{
|
||||
print '<td class="liste_titre nowraponall">';
|
||||
print '<input class="flat" type="text" size="2" maxlength="2" placeholder="'.dol_escape_htmltag($langs->trans("Month")).'" name="month" value="'.$month.'">';
|
||||
if (empty($conf->productbatch->enabled)) print ' ';
|
||||
//else print '<br>';
|
||||
$syear = $year ? $year : -1;
|
||||
print '<input class="flat maxwidth50" type="text" maxlength="4" placeholder="'.dol_escape_htmltag($langs->trans("Year")).'" name="year" value="'.($syear > 0 ? $syear : '').'">';
|
||||
//print $formother->selectyear($syear,'year',1, 20, 5);
|
||||
print '</td>';
|
||||
}
|
||||
if (!empty($arrayfields['p.ref']['checked']))
|
||||
{
|
||||
// Product Ref
|
||||
print '<td class="liste_titre left">';
|
||||
print '<input class="flat maxwidth75" type="text" name="search_product_ref" value="'.dol_escape_htmltag($idproduct ? $product->ref : $search_product_ref).'">';
|
||||
print '</td>';
|
||||
}
|
||||
if (!empty($arrayfields['p.label']['checked']))
|
||||
{
|
||||
// Product label
|
||||
print '<td class="liste_titre left">';
|
||||
print '<input class="flat maxwidth100" type="text" name="search_product" value="'.dol_escape_htmltag($idproduct ? $product->label : $search_product).'">';
|
||||
print '</td>';
|
||||
}
|
||||
// Batch
|
||||
if (!empty($arrayfields['m.batch']['checked']))
|
||||
{
|
||||
print '<td class="liste_titre center"><input class="flat maxwidth75" type="text" name="search_batch" value="'.dol_escape_htmltag($search_batch).'"></td>';
|
||||
}
|
||||
if (!empty($arrayfields['pl.eatby']['checked']))
|
||||
{
|
||||
print '<td class="liste_titre left">';
|
||||
print '</td>';
|
||||
}
|
||||
if (!empty($arrayfields['pl.sellby']['checked']))
|
||||
{
|
||||
print '<td class="liste_titre left">';
|
||||
print '</td>';
|
||||
}
|
||||
// Warehouse
|
||||
if (!empty($arrayfields['e.ref']['checked']))
|
||||
{
|
||||
print '<td class="liste_titre maxwidthonsmartphone left">';
|
||||
//print '<input class="flat" type="text" size="8" name="search_warehouse" value="'.($search_warehouse).'">';
|
||||
print $formproduct->selectWarehouses($search_warehouse, 'search_warehouse', 'warehouseopen,warehouseinternal', 1, 0, 0, '', 0, 0, null, 'maxwidth200');
|
||||
print '</td>';
|
||||
}
|
||||
if (!empty($arrayfields['m.fk_user_author']['checked']))
|
||||
{
|
||||
// Author
|
||||
print '<td class="liste_titre left">';
|
||||
print '<input class="flat" type="text" size="6" name="search_user" value="'.dol_escape_htmltag($search_user).'">';
|
||||
print '</td>';
|
||||
}
|
||||
if (!empty($arrayfields['m.inventorycode']['checked']))
|
||||
{
|
||||
// Inventory code
|
||||
print '<td class="liste_titre left">';
|
||||
print '<input class="flat" type="text" size="4" name="search_inventorycode" value="'.dol_escape_htmltag($search_inventorycode).'">';
|
||||
print '</td>';
|
||||
}
|
||||
if (!empty($arrayfields['m.label']['checked']))
|
||||
{
|
||||
// Label of movement
|
||||
print '<td class="liste_titre left">';
|
||||
print '<input class="flat" type="text" size="8" name="search_movement" value="'.dol_escape_htmltag($search_movement).'">';
|
||||
print '</td>';
|
||||
}
|
||||
if (!empty($arrayfields['m.type_mouvement']['checked']))
|
||||
{
|
||||
// Type of movement
|
||||
print '<td class="liste_titre center">';
|
||||
//print '<input class="flat" type="text" size="3" name="search_type_mouvement" value="'.dol_escape_htmltag($search_type_mouvement).'">';
|
||||
print '<select id="search_type_mouvement" name="search_type_mouvement" class="maxwidth150">';
|
||||
print '<option value="" '.(($search_type_mouvement == "") ? 'selected="selected"' : '').'></option>';
|
||||
print '<option value="0" '.(($search_type_mouvement == "0") ? 'selected="selected"' : '').'>'.$langs->trans('StockIncreaseAfterCorrectTransfer').'</option>';
|
||||
print '<option value="1" '.(($search_type_mouvement == "1") ? 'selected="selected"' : '').'>'.$langs->trans('StockDecreaseAfterCorrectTransfer').'</option>';
|
||||
print '<option value="2" '.(($search_type_mouvement == "2") ? 'selected="selected"' : '').'>'.$langs->trans('StockDecrease').'</option>';
|
||||
print '<option value="3" '.(($search_type_mouvement == "3") ? 'selected="selected"' : '').'>'.$langs->trans('StockIncrease').'</option>';
|
||||
print '</select>';
|
||||
print ajax_combobox('search_type_mouvement');
|
||||
// TODO: add new function $formentrepot->selectTypeOfMovement(...) like
|
||||
// print $formproduct->selectWarehouses($search_warehouse, 'search_warehouse', 'warehouseopen,warehouseinternal', 1, 0, 0, '', 0, 0, null, 'maxwidth200');
|
||||
print '</td>';
|
||||
}
|
||||
if (!empty($arrayfields['origin']['checked']))
|
||||
{
|
||||
// Origin of movement
|
||||
print '<td class="liste_titre left">';
|
||||
print ' ';
|
||||
print '</td>';
|
||||
}
|
||||
if (!empty($arrayfields['m.value']['checked']))
|
||||
{
|
||||
// Qty
|
||||
print '<td class="liste_titre right">';
|
||||
print '<input class="flat" type="text" size="4" name="search_qty" value="'.dol_escape_htmltag($search_qty).'">';
|
||||
print '</td>';
|
||||
}
|
||||
if (!empty($arrayfields['m.price']['checked']))
|
||||
{
|
||||
// Price
|
||||
print '<td class="liste_titre left">';
|
||||
print ' ';
|
||||
print '</td>';
|
||||
}
|
||||
|
||||
|
||||
// Extra fields
|
||||
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
|
||||
|
||||
// Fields from hook
|
||||
$parameters = array('arrayfields'=>$arrayfields);
|
||||
$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook
|
||||
print $hookmanager->resPrint;
|
||||
// Date creation
|
||||
if (!empty($arrayfields['m.datec']['checked']))
|
||||
{
|
||||
print '<td class="liste_titre">';
|
||||
print '</td>';
|
||||
}
|
||||
// Date modification
|
||||
if (!empty($arrayfields['m.tms']['checked']))
|
||||
{
|
||||
print '<td class="liste_titre">';
|
||||
print '</td>';
|
||||
}
|
||||
// Actions
|
||||
print '<td class="liste_titre maxwidthsearch">';
|
||||
$searchpicto = $form->showFilterAndCheckAddButtons(0);
|
||||
print $searchpicto;
|
||||
print '</td>';
|
||||
print "</tr>\n";
|
||||
|
||||
print '<tr class="liste_titre">';
|
||||
if (! empty($arrayfields['m.rowid']['checked']))
|
||||
print_liste_field_titre($arrayfields['m.rowid']['label'], $_SERVER["PHP_SELF"], 'm.rowid', '', $param, '', $sortfield, $sortorder);
|
||||
if (! empty($arrayfields['m.datem']['checked']))
|
||||
print_liste_field_titre($arrayfields['m.datem']['label'], $_SERVER["PHP_SELF"], 'm.datem', '', $param, '', $sortfield, $sortorder);
|
||||
if (! empty($arrayfields['p.ref']['checked']))
|
||||
print_liste_field_titre($arrayfields['p.ref']['label'], $_SERVER["PHP_SELF"], 'p.ref', '', $param, '', $sortfield, $sortorder);
|
||||
if (! empty($arrayfields['p.label']['checked']))
|
||||
print_liste_field_titre($arrayfields['p.label']['label'], $_SERVER["PHP_SELF"], 'p.label', '', $param, '', $sortfield, $sortorder);
|
||||
if (! empty($arrayfields['m.batch']['checked']))
|
||||
print_liste_field_titre($arrayfields['m.batch']['label'], $_SERVER["PHP_SELF"], 'm.batch', '', $param, '', $sortfield, $sortorder, 'center ');
|
||||
if (! empty($arrayfields['pl.eatby']['checked']))
|
||||
print_liste_field_titre($arrayfields['pl.eatby']['label'], $_SERVER["PHP_SELF"], 'pl.eatby', '', $param, '', $sortfield, $sortorder, 'center ');
|
||||
if (! empty($arrayfields['pl.sellby']['checked']))
|
||||
print_liste_field_titre($arrayfields['pl.sellby']['label'], $_SERVER["PHP_SELF"], 'pl.sellby', '', $param, '', $sortfield, $sortorder, 'center ');
|
||||
if (! empty($arrayfields['e.ref']['checked'])) {
|
||||
// We are on a specific warehouse card, no filter on other should be possible
|
||||
print_liste_field_titre($arrayfields['e.ref']['label'], $_SERVER["PHP_SELF"], "e.ref", "", $param, "", $sortfield, $sortorder);
|
||||
}
|
||||
if (! empty($arrayfields['m.fk_user_author']['checked']))
|
||||
print_liste_field_titre($arrayfields['m.fk_user_author']['label'], $_SERVER["PHP_SELF"], "m.fk_user_author", "", $param, "", $sortfield, $sortorder);
|
||||
if (! empty($arrayfields['m.inventorycode']['checked']))
|
||||
print_liste_field_titre($arrayfields['m.inventorycode']['label'], $_SERVER["PHP_SELF"], "m.inventorycode", "", $param, "", $sortfield, $sortorder);
|
||||
if (! empty($arrayfields['m.label']['checked']))
|
||||
print_liste_field_titre($arrayfields['m.label']['label'], $_SERVER["PHP_SELF"], "m.label", "", $param, "", $sortfield, $sortorder);
|
||||
if (! empty($arrayfields['m.type_mouvement']['checked']))
|
||||
print_liste_field_titre($arrayfields['m.type_mouvement']['label'], $_SERVER["PHP_SELF"], "m.type_mouvement", "", $param, '', $sortfield, $sortorder, 'center ');
|
||||
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, '', $sortfield, $sortorder, 'right ');
|
||||
if (! empty($arrayfields['m.price']['checked']))
|
||||
print_liste_field_titre($arrayfields['m.price']['label'], $_SERVER["PHP_SELF"], "m.price", "", $param, '', $sortfield, $sortorder, 'right ');
|
||||
|
||||
// Extra fields
|
||||
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_list_search_title.tpl.php';
|
||||
|
||||
// Hook fields
|
||||
$parameters = array('arrayfields' => $arrayfields,'param' => $param,'sortfield' => $sortfield,'sortorder' => $sortorder);
|
||||
$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook
|
||||
print $hookmanager->resPrint;
|
||||
if (! empty($arrayfields['m.datec']['checked'])) {
|
||||
print_liste_field_titre($arrayfields['p.datec']['label'], $_SERVER["PHP_SELF"], "p.datec", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
|
||||
}
|
||||
if (! empty($arrayfields['m.tms']['checked'])) {
|
||||
print_liste_field_titre($arrayfields['p.tms']['label'], $_SERVER["PHP_SELF"], "p.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap ');
|
||||
}
|
||||
print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ');
|
||||
print "</tr>\n";
|
||||
|
||||
$resql = $db->query($sql);
|
||||
if (! $resql) {
|
||||
dol_print_error($db);
|
||||
}
|
||||
$num = $db->num_rows($resql);
|
||||
|
||||
$i = 0;
|
||||
while ($i < ($limit ? min($num, $limit) : $num)) {
|
||||
$objp = $db->fetch_object($resql);
|
||||
|
||||
$userstatic->id = $objp->fk_user_author;
|
||||
$userstatic->login = $objp->login;
|
||||
$userstatic->lastname = $objp->lastname;
|
||||
$userstatic->firstname = $objp->firstname;
|
||||
$userstatic->photo = $objp->photo;
|
||||
|
||||
$productstatic->id = $objp->rowid;
|
||||
$productstatic->ref = $objp->product_ref;
|
||||
$productstatic->label = $objp->produit;
|
||||
$productstatic->type = $objp->type;
|
||||
$productstatic->entity = $objp->entity;
|
||||
$productstatic->status_batch = $objp->tobatch;
|
||||
|
||||
$productlot->id = $objp->lotid;
|
||||
$productlot->batch = $objp->batch;
|
||||
$productlot->eatby = $objp->eatby;
|
||||
$productlot->sellby = $objp->sellby;
|
||||
|
||||
$warehousestatic->id = $objp->entrepot_id;
|
||||
$warehousestatic->libelle = $objp->warehouse_ref; // deprecated
|
||||
$warehousestatic->label = $objp->warehouse_ref;
|
||||
$warehousestatic->lieu = $objp->lieu;
|
||||
|
||||
if (! empty($objp->fk_origin)) {
|
||||
$origin = $objectlist->get_origin($objp->fk_origin, $objp->origintype);
|
||||
} else {
|
||||
$origin = '';
|
||||
}
|
||||
|
||||
print '<tr class="oddeven">';
|
||||
// Id movement
|
||||
if (! empty($arrayfields['m.rowid']['checked'])) {
|
||||
// This is primary not movement id
|
||||
print '<td>' . $objp->mid . '</td>';
|
||||
}
|
||||
if (! empty($arrayfields['m.datem']['checked'])) {
|
||||
// Date
|
||||
print '<td>' . dol_print_date($db->jdate($objp->datem), 'dayhour') . '</td>';
|
||||
}
|
||||
if (! empty($arrayfields['p.ref']['checked'])) {
|
||||
// Product ref
|
||||
print '<td class="nowraponall">';
|
||||
print $productstatic->getNomUrl(1, 'stock', 16);
|
||||
print "</td>\n";
|
||||
}
|
||||
if (! empty($arrayfields['p.label']['checked'])) {
|
||||
// Product label
|
||||
print '<td>';
|
||||
/*
|
||||
* $productstatic->id=$objp->rowid;
|
||||
* $productstatic->ref=$objp->produit;
|
||||
* $productstatic->type=$objp->type;
|
||||
* print $productstatic->getNomUrl(1,'',16);
|
||||
*/
|
||||
print $productstatic->label;
|
||||
print "</td>\n";
|
||||
}
|
||||
if (! empty($arrayfields['m.batch']['checked'])) {
|
||||
print '<td class="center nowraponall">';
|
||||
if ($productlot->id > 0)
|
||||
print $productlot->getNomUrl(1);
|
||||
else
|
||||
print $productlot->batch; // the id may not be defined if movement was entered when lot was not saved or if lot was removed after movement.
|
||||
print '</td>';
|
||||
}
|
||||
if (! empty($arrayfields['pl.eatby']['checked'])) {
|
||||
print '<td class="center">' . dol_print_date($objp->eatby, 'day') . '</td>';
|
||||
}
|
||||
if (! empty($arrayfields['pl.sellby']['checked'])) {
|
||||
print '<td class="center">' . dol_print_date($objp->sellby, 'day') . '</td>';
|
||||
}
|
||||
// Warehouse
|
||||
if (! empty($arrayfields['e.ref']['checked'])) {
|
||||
print '<td>';
|
||||
print $warehousestatic->getNomUrl(1);
|
||||
print "</td>\n";
|
||||
}
|
||||
// Author
|
||||
if (! empty($arrayfields['m.fk_user_author']['checked'])) {
|
||||
print '<td class="tdoverflowmax100">';
|
||||
print $userstatic->getNomUrl(- 1);
|
||||
print "</td>\n";
|
||||
}
|
||||
if (! empty($arrayfields['m.inventorycode']['checked'])) {
|
||||
// Inventory code
|
||||
print '<td>';
|
||||
//print '<a href="' . DOL_URL_ROOT . '/product/stock/movement_card.php' . '?id=' . $objp->entrepot_id . '&search_inventorycode=' . $objp->inventorycode . '&search_type_mouvement=' . $objp->type_mouvement . '">';
|
||||
print $objp->inventorycode;
|
||||
//print '</a>';
|
||||
print '</td>';
|
||||
}
|
||||
if (! empty($arrayfields['m.label']['checked'])) {
|
||||
// Label of movement
|
||||
print '<td class="tdoverflowmax100aaa">' . $objp->label . '</td>';
|
||||
}
|
||||
if (! empty($arrayfields['m.type_mouvement']['checked'])) {
|
||||
// Type of movement
|
||||
switch ($objp->type_mouvement) {
|
||||
case "0":
|
||||
print '<td class="center">' . $langs->trans('StockIncreaseAfterCorrectTransfer') . '</td>';
|
||||
break;
|
||||
case "1":
|
||||
print '<td class="center">' . $langs->trans('StockDecreaseAfterCorrectTransfer') . '</td>';
|
||||
break;
|
||||
case "2":
|
||||
print '<td class="center">' . $langs->trans('StockDecrease') . '</td>';
|
||||
break;
|
||||
case "3":
|
||||
print '<td class="center">' . $langs->trans('StockIncrease') . '</td>';
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (! empty($arrayfields['origin']['checked'])) {
|
||||
// Origin of movement
|
||||
print '<td class="nowraponall">' . $origin . '</td>';
|
||||
}
|
||||
if (! empty($arrayfields['m.value']['checked'])) {
|
||||
// Qty
|
||||
print '<td class="right">';
|
||||
if ($objp->qt > 0)
|
||||
print '+';
|
||||
print $objp->qty;
|
||||
print '</td>';
|
||||
}
|
||||
if (! empty($arrayfields['m.price']['checked'])) {
|
||||
// Price
|
||||
print '<td class="right">';
|
||||
if ($objp->price != 0)
|
||||
print price($objp->price);
|
||||
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
|
||||
{
|
||||
$selected = 0;
|
||||
if (in_array($obj->rowid, $arrayofselected))
|
||||
$selected = 1;
|
||||
print '<input id="cb' . $obj->rowid . '" class="flat checkforselect" type="checkbox" name="toselect[]" value="' . $obj->rowid . '"' . ($selected ? ' checked="checked"' : '') . '>';
|
||||
}
|
||||
print '</td>';
|
||||
if (! $i)
|
||||
$totalarray['nbfield'] ++;
|
||||
|
||||
print "</tr>\n";
|
||||
$i++;
|
||||
}
|
||||
$db->free($resql);
|
||||
|
||||
print "</table>";
|
||||
print '</div>';
|
||||
print "</form>";
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -77,6 +77,29 @@ class MouvementStock extends CommonObject
|
||||
public $batch;
|
||||
|
||||
|
||||
public $fields=array(
|
||||
'rowid' =>array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>10, 'showoncombobox'=>1),
|
||||
'tms' =>array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>15),
|
||||
'datem' =>array('type'=>'datetime', 'label'=>'Datem', 'enabled'=>1, 'visible'=>-1, 'position'=>20),
|
||||
'fk_product' =>array('type'=>'integer:Product:product/class/product.class.php:1', 'label'=>'Product', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>25),
|
||||
'fk_entrepot' =>array('type'=>'integer:Entrepot:product/stock/class/entrepot.class.php', 'label'=>'Warehouse', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>30),
|
||||
'value' =>array('type'=>'double', 'label'=>'Value', 'enabled'=>1, 'visible'=>-1, 'position'=>35),
|
||||
'price' =>array('type'=>'double(24,8)', 'label'=>'Price', 'enabled'=>1, 'visible'=>-1, 'position'=>40),
|
||||
'type_mouvement' =>array('type'=>'smallint(6)', 'label'=>'Type mouvement', 'enabled'=>1, 'visible'=>-1, 'position'=>45),
|
||||
'fk_user_author' =>array('type'=>'integer:User:user/class/user.class.php', 'label'=>'Fk user author', 'enabled'=>1, 'visible'=>-1, 'position'=>50),
|
||||
'label' =>array('type'=>'varchar(255)', 'label'=>'Label', 'enabled'=>1, 'visible'=>-1, 'position'=>55),
|
||||
'fk_origin' =>array('type'=>'integer', 'label'=>'Fk origin', 'enabled'=>1, 'visible'=>-1, 'position'=>60),
|
||||
'origintype' =>array('type'=>'varchar(32)', 'label'=>'Origintype', 'enabled'=>1, 'visible'=>-1, 'position'=>65),
|
||||
'model_pdf' =>array('type'=>'varchar(255)', 'label'=>'Model pdf', 'enabled'=>1, 'visible'=>0, 'position'=>70),
|
||||
'fk_projet' =>array('type'=>'integer:Project:projet/class/project.class.php:1:fk_statut=1', 'label'=>'Project', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>75),
|
||||
'inventorycode' =>array('type'=>'varchar(128)', 'label'=>'InventoryCode', 'enabled'=>1, 'visible'=>-1, 'position'=>80),
|
||||
'batch' =>array('type'=>'varchar(30)', 'label'=>'Batch', 'enabled'=>1, 'visible'=>-1, 'position'=>85),
|
||||
'eatby' =>array('type'=>'date', 'label'=>'Eatby', 'enabled'=>1, 'visible'=>-1, 'position'=>90),
|
||||
'sellby' =>array('type'=>'date', 'label'=>'Sellby', 'enabled'=>1, 'visible'=>-1, 'position'=>95),
|
||||
'fk_project' =>array('type'=>'integer:Project:projet/class/project.class.php:1:fk_statut=1', 'label'=>'Fk project', 'enabled'=>1, 'visible'=>-1, 'position'=>100),
|
||||
);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
|
||||
@ -99,7 +99,7 @@ $arrayfields = array(
|
||||
'p.ref'=>array('label'=>$langs->trans("ProductRef"), 'checked'=>1, 'css'=>'maxwidth100'),
|
||||
'p.label'=>array('label'=>$langs->trans("ProductLabel"), 'checked'=>1),
|
||||
'm.batch'=>array('label'=>$langs->trans("BatchNumberShort"), 'checked'=>1, 'enabled'=>(!empty($conf->productbatch->enabled))),
|
||||
'pl.eatby'=>array('label'=>$langs->trans("EatByDate"), 'checked'=>0, 'enabled'=>(!empty($conf->productbatch->enabled))),
|
||||
'pl.eatby'=>array('label'=>$langs->trans("EatByDate"), 'checked'=>0, 'position'=>10, 'enabled'=>(!empty($conf->productbatch->enabled))),
|
||||
'pl.sellby'=>array('label'=>$langs->trans("SellByDate"), 'checked'=>0, 'position'=>10, 'enabled'=>(!empty($conf->productbatch->enabled))),
|
||||
'e.ref'=>array('label'=>$langs->trans("Warehouse"), 'checked'=>1, 'enabled'=>(!$id > 0)), // If we are on specific warehouse, we hide it
|
||||
'm.fk_user_author'=>array('label'=>$langs->trans("Author"), 'checked'=>0),
|
||||
@ -113,16 +113,16 @@ $arrayfields = array(
|
||||
//'m.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500)
|
||||
);
|
||||
|
||||
$usercanread = (($user->rights->stock->mouvement->lire));
|
||||
$usercancreate = (($user->rights->stock->mouvement->creer));
|
||||
$usercandelete = (($user->rights->stock->mouvement->supprimer));
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Actions
|
||||
*/
|
||||
|
||||
$usercanread = (($user->rights->stock->mouvement->lire));
|
||||
$usercancreate = (($user->rights->stock->mouvement->creer));
|
||||
$usercandelete = (($user->rights->stock->mouvement->supprimer));
|
||||
|
||||
if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; }
|
||||
if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; }
|
||||
|
||||
@ -702,8 +702,6 @@ if ($resql)
|
||||
if ($search_product) $param .= '&search_product='.urlencode($search_product);
|
||||
if ($search_batch) $param .= '&search_batch='.urlencode($search_batch);
|
||||
if ($search_warehouse > 0) $param .= '&search_warehouse='.urlencode($search_warehouse);
|
||||
if (!empty($sref)) $param .= '&sref='.urlencode($sref); // FIXME $sref is not defined
|
||||
if (!empty($snom)) $param .= '&snom='.urlencode($snom); // FIXME $snom is not defined
|
||||
if ($search_user) $param .= '&search_user='.urlencode($search_user);
|
||||
if ($idproduct > 0) $param .= '&idproduct='.urlencode($idproduct);
|
||||
// Add $param from extra fields
|
||||
@ -726,7 +724,6 @@ if ($resql)
|
||||
print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
|
||||
print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
|
||||
print '<input type="hidden" name="page" value="'.$page.'">';
|
||||
print '<input type="hidden" name="type" value="'.$type.'">';
|
||||
print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
|
||||
if ($id > 0) print '<input type="hidden" name="id" value="'.$id.'">';
|
||||
|
||||
@ -956,7 +953,7 @@ if ($resql)
|
||||
|
||||
$arrayofuniqueproduct = array();
|
||||
|
||||
while ($i < min($num, $limit)) {
|
||||
while ($i < ($limit ? min($num, $limit) : $num)) {
|
||||
$objp = $db->fetch_object($resql);
|
||||
|
||||
$userstatic->id = $objp->fk_user_author;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user