2
0
forked from Wavyzz/dolibarr
Files
dolibarr-fork/htdocs/product/stock/list.php
2020-03-13 13:07:11 +01:00

743 lines
27 KiB
PHP

<?php
/* Copyright (C) 2001-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2016 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2014 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2015 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2020 Tobias Sekan <tobias.sekan@startmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
/**
* \file htdocs/product/stock/list.php
* \ingroup stock
* \brief Page with warehouse and stock value
*/
require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/product/stock/class/entrepot.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcategory.class.php';
if (!empty($conf->categorie->enabled))
{
require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
}
// Load translation files required by the page
$langs->loadLangs(array("stocks", "other"));
$action = GETPOST('action', 'aZ09') ?GETPOST('action', 'aZ09') : 'view'; // The action 'add', 'create', 'edit', 'update', 'view', ...
$massaction = GETPOST('massaction', 'alpha'); // The bulk action (combo box choice into lists)
$show_files = GETPOST('show_files', 'int'); // Show files area generated by bulk actions ?
$confirm = GETPOST('confirm', 'alpha'); // Result of a confirmation
$cancel = GETPOST('cancel', 'alpha'); // We click on a Cancel button
$toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected into a list
$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'stocklist'; // To manage different context of search
$backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page
$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print')
$search_all = trim((GETPOST('search_all', 'alphanohtml') != '') ?GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml'));
$search_ref = GETPOST("sref", "alpha") ?GETPOST("sref", "alpha") : GETPOST("search_ref", "alpha");
$search_label = GETPOST("snom", "alpha") ?GETPOST("snom", "alpha") : GETPOST("search_label", "alpha");
$search_status = GETPOST("search_status", "int");
if (!empty($conf->categorie->enabled))
{
$search_category_list = GETPOST("search_category_".Categorie::TYPE_WAREHOUSE."_list", "array");
}
// Load variable for pagination
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
$sortfield = GETPOST('sortfield', 'alpha');
$sortorder = GETPOST('sortorder', 'alpha');
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page == -1 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha') || (empty($toselect) && $massaction === '0')) { $page = 0; } // If $page is not defined, or '' or -1 or if we click on clear filters or if we select empty mass action
$offset = $limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;
if (!$sortfield) $sortfield = "e.ref";
if (!$sortorder) $sortorder = "ASC";
// Security check
$result = restrictedArea($user, 'stock');
$year = strftime("%Y", time());
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
$object = new Entrepot($db);
$extrafields = new ExtraFields($db);
$diroutputmassaction = $conf->inventory->dir_output.'/temp/massgeneration/'.$user->id;
$hookmanager->initHooks(array('stocklist'));
// Fetch optionals attributes and labels
$extrafields->fetch_name_optionals_label($object->table_element);
$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
// List of fields to search into when doing a "search in all"
$fieldstosearchall = array(
'e.ref'=>"Ref",
'e.lieu'=>"LocationSummary",
'e.description'=>"Description",
'e.address'=>"Address",
'e.zip'=>'Zip',
'e.town'=>'Town',
);
// Definition of fields for list
$arrayfields = array(
'e.ref'=>array('label'=>$langs->trans("Ref"), 'checked'=>1),
'e.lieu'=>array('label'=>$langs->trans("LocationSummary"), 'checked'=>1),
'e.description'=>array('label'=>$langs->trans("Description"), 'checked'=>0),
'e.address'=>array('label'=>$langs->trans("Address"), 'checked'=>0),
'e.zip'=>array('label'=>$langs->trans("Zip"), 'checked'=>0),
'e.town'=>array('label'=>$langs->trans("Town"), 'checked'=>0),
'stockqty'=>array('type'=>'float', 'label'=>$langs->trans("PhysicalStock"), 'enabled'=>1, 'visible'=>-2, 'position'=>70),
'estimatedvalue'=>array('type'=>'float', 'label'=>$langs->trans("EstimatedStockValue"), 'enabled'=>1, 'visible'=>-2, 'position'=>71),
'sellvalue'=>array('type'=>'float', 'label'=>$langs->trans("EstimatedStockValueSell"), 'enabled'=>1, 'visible'=>-2, 'position'=>72),
'e.statut'=>array('label'=>$langs->trans("Status"), 'checked'=>1, 'position'=>100),
);
// Extra fields
if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0)
{
foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val)
{
if (!empty($extrafields->attributes[$object->table_element]['list'][$key]))
$arrayfields["ef.".$key] = array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key] < 0) ? 0 : 1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key]) != 3 && $extrafields->attributes[$object->table_element]['perms'][$key]));
}
}
$object->fields = dol_sort_array($object->fields, 'position');
$arrayfields = dol_sort_array($arrayfields, 'position');
/*
* 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');
if (empty($reshook))
{
// Selection of new fields
include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
// Purge search criteria
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers
{
$search_ref = "";
$sall = "";
$search_label = "";
$search_status = "";
$toselect = '';
$search_array_options = array();
$search_category_list = array();
}
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')
|| GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha'))
{
$massaction = ''; // Protection to avoid mass action if we force a new search during a mass action confirmation
}
// Mass actions
$objectclass = 'Entrepot';
$objectlabel = 'Warehouse';
$permissiontoread = $user->rights->stock->lire;
$permissiontodelete = $user->rights->stock->supprimer;
$uploaddir = $conf->stock->dir_output;
include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
}
/*
* View
*/
$form = new FormCategory($db);
$warehouse = new Entrepot($db);
$now = dol_now();
$help_url = 'EN:Module_Stocks_En|FR:Module_Stock|ES:M&oacute;dulo_Stocks';
$title = $langs->trans("ListOfWarehouses");
// Build and execute select
// --------------------------------------------------------------------
$sql = "SELECT e.rowid, e.ref, e.statut, e.lieu, e.address, e.zip, e.town, e.fk_pays, e.fk_parent,";
$sql .= " SUM(p.pmp * ps.reel) as estimatedvalue, SUM(p.price * ps.reel) as sellvalue, SUM(ps.reel) as stockqty";
// Add fields from extrafields
if (!empty($extrafields->attributes[$object->table_element]['label'])) {
foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
$sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : '');
}
}
// Add fields from hooks
$parameters = array();
$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook
$sql .= $hookmanager->resPrint;
$sql = preg_replace('/,\s*$/', '', $sql);
$sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as e";
if (!empty($conf->categorie->enabled))
{
$sql .= Categorie::getFilterJoinQuery(Categorie::TYPE_WAREHOUSE, "e.rowid");
}
if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (e.rowid = ef.fk_object)";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_stock as ps ON e.rowid = ps.fk_entrepot";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON ps.fk_product = p.rowid";
$sql .= " WHERE e.entity IN (".getEntity('stock').")";
if (!empty($conf->categorie->enabled))
{
$sql .= Categorie::getFilterSelectQuery(Categorie::TYPE_WAREHOUSE, "e.rowid", $search_category_list);
}
if ($search_ref) $sql .= natural_search("e.ref", $search_ref); // ref
if ($search_label) $sql .= natural_search("e.lieu", $search_label); // label
if ($search_status != '' && $search_status >= 0) $sql .= " AND e.statut = ".$search_status;
if ($search_all) $sql .= natural_search(array_keys($fieldstosearchall), $search_all);
// 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, $object); // Note that $action and $object may have been modified by hook
$sql .= $hookmanager->resPrint;
$sql .= " GROUP BY e.rowid, e.ref, e.statut, e.lieu, e.address, e.zip, e.town, e.fk_pays, e.fk_parent";
$totalnboflines = 0;
$result = $db->query($sql);
if ($result)
{
$totalnboflines = $db->num_rows($result);
// fetch totals
$line = $total = $totalsell = $totalStock = 0;
while ($line < $totalnboflines)
{
$objp = $db->fetch_object($result);
$total += price2num($objp->estimatedvalue, 'MU');
$totalsell += price2num($objp->sellvalue, 'MU');
$totalStock += $objp->stockqty;
$line++;
}
}
$sql .= $db->order($sortfield, $sortorder);
// Count total nb of records
$nbtotalofrecords = '';
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
{
$resql = $db->query($sql);
$nbtotalofrecords = $db->num_rows($resql);
if (($page * $limit) > $nbtotalofrecords) // if total of record found is smaller than page * limit, goto and load page 0
{
$page = 0;
$offset = 0;
}
}
// if total of record found is smaller than limit, no need to do paging and to restart another select with limits set.
if (is_numeric($nbtotalofrecords) && $limit > $nbtotalofrecords)
{
$num = $nbtotalofrecords;
}
else
{
$sql .= $db->plimit($limit + 1, $offset);
$resql = $db->query($sql);
if (!$resql)
{
dol_print_error($db);
exit;
}
$num = $db->num_rows($resql);
}
// Direct jump if only one record found
if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all)
{
$obj = $db->fetch_object($resql);
$id = $obj->rowid;
header("Location: ".DOL_URL_ROOT.'/product/stock/card.php?id='.$id);
exit;
}
// Output page
// --------------------------------------------------------------------
llxHeader('', $title, $help_url);
$arrayofselected = is_array($toselect) ? $toselect : array();
$param = '';
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage);
if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit);
if ($search_ref) $param .= "&search_ref=".urlencode($search_ref);
if ($search_label) $param .= "&search_label=".urlencode($search_label);
if ($search_status) $param .= "&search_status=".urlencode($search_status);
if ($search_all) $param .= "&search_all=".urlencode($search_all);
if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss);
// 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 (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array();
$massactionbutton = $form->selectMassAction('', $arrayofmassactions);
print '<form action="'.$_SERVER["PHP_SELF"].'" id="searchFormList" method="POST" name="formulaire">';
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.'">';
$newcardbutton = dolGetButtonTitle($langs->trans('MenuNewWarehouse'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/product/stock/card.php?action=create&backtopage='.urlencode($_SERVER['PHP_SELF']), '', $user->rights->stock->creer);
print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'generic', 0, $newcardbutton, '', $limit);
// Add code for pre mass action (confirmation or email presend form)
$topicmail = "Information";
$modelmail = "warehouse";
$objecttmp = new Entrepot($db);
$trackid = 'ware'.$object->id;
include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
if ($search_all)
{
foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val);
print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $sall).join(', ', $fieldstosearchall).'</div>';
}
$moreforfilter = '';
if (!empty($conf->categorie->enabled))
{
$moreforfilter .= $form->getFilterBox(Categorie::TYPE_WAREHOUSE, $search_category_list);
}
/*$moreforfilter.='<div class="divsearchfield">';
$moreforfilter.= $langs->trans('MyFilter') . ': <input type="text" name="search_myfield" value="'.dol_escape_htmltag($search_myfield).'">';
$moreforfilter.= '</div>';*/
$parameters = array();
$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object); // 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
$selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : '');
print '<div class="div-table-responsive">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table
print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
// Fields title search
// --------------------------------------------------------------------
print '<tr class="liste_titre_filter">';
if (!empty($arrayfields['e.ref']['checked']))
{
print '<td class="liste_titre left">';
print '<input class="flat" type="text" name="search_ref" size="6" value="'.dol_escape_htmltag($search_ref).'">';
print '</td>';
}
if (!empty($arrayfields['e.lieu']['checked']))
{
print '<td class="liste_titre left">';
print '<input class="flat" type="text" name="search_label" size="10" value="'.dol_escape_htmltag($search_label).'">';
print '</td>';
}
if (!empty($arrayfields['e.description']['checked']))
{
print '<td class="liste_titre"></td>';
}
if (!empty($arrayfields['e.address']['checked']))
{
print '<td class="liste_titre"></td>';
}
if (!empty($arrayfields['e.zip']['checked']))
{
print '<td class="liste_titre"></td>';
}
if (!empty($arrayfields['e.town']['checked']))
{
print '<td class="liste_titre"></td>';
}
if (!empty($arrayfields['stockqty']['checked']))
{
print '<td class="liste_titre"></td>';
}
if (!empty($arrayfields['estimatedvalue']['checked']))
{
print '<td class="liste_titre"></td>';
}
if (!empty($arrayfields['sellvalue']['checked']))
{
print '<td class="liste_titre"></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, $object); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
// Status
if (!empty($arrayfields['e.statut']['checked']))
{
print '<td class="liste_titre right">';
print $form->selectarray('search_status', $warehouse->statuts, $search_status, 1, 0, 0, '', 1);
print '</td>';
}
// Action column
print '<td class="liste_titre maxwidthsearch">';
$searchpicto = $form->showFilterButtons();
print $searchpicto;
print '</td>';
print '</tr>'."\n";
// Fields title label
// --------------------------------------------------------------------
print '<tr class="liste_titre">';
if (!empty($arrayfields['e.ref']['checked']))
{
print_liste_field_titre($arrayfields['e.ref']['label'], $_SERVER["PHP_SELF"], "e.ref", "", $param, "", $sortfield, $sortorder);
}
if (!empty($arrayfields['e.lieu']['checked']))
{
print_liste_field_titre($arrayfields['e.lieu']['label'], $_SERVER["PHP_SELF"], "e.lieu", "", $param, "", $sortfield, $sortorder);
}
if (!empty($arrayfields['e.description']['checked']))
{
print_liste_field_titre($arrayfields['e.description']['label'], $_SERVER["PHP_SELF"], "e.description", "", $param, "", $sortfield, $sortorder);
}
if (!empty($arrayfields['e.address']['checked']))
{
print_liste_field_titre($arrayfields['e.address']['label'], $_SERVER["PHP_SELF"], "e.address", "", $param, "", $sortfield, $sortorder);
}
if (!empty($arrayfields['e.zip']['checked']))
{
print_liste_field_titre($arrayfields['e.zip']['label'], $_SERVER["PHP_SELF"], "e.zip", "", $param, "", $sortfield, $sortorder);
}
if (!empty($arrayfields['e.town']['checked']))
{
print_liste_field_titre($arrayfields['e.town']['label'], $_SERVER["PHP_SELF"], "e.town", "", $param, "", $sortfield, $sortorder);
}
if (!empty($arrayfields['stockqty']['checked']))
{
print_liste_field_titre($arrayfields['stockqty']['label'], $_SERVER["PHP_SELF"], "stockqty", '', $param, '', $sortfield, $sortorder, 'right ');
}
if (!empty($arrayfields['estimatedvalue']['checked']))
{
print_liste_field_titre($arrayfields['estimatedvalue']['label'], $_SERVER["PHP_SELF"], "estimatedvalue", '', $param, '', $sortfield, $sortorder, 'right ');
}
if (!empty($arrayfields['sellvalue']['checked']))
{
print_liste_field_titre($arrayfields['sellvalue']['label'], $_SERVER["PHP_SELF"], "sellvalue", '', $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, $object); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
if (!empty($arrayfields['e.statut']['checked']))
{
print_liste_field_titre($arrayfields['e.statut']['label'], $_SERVER["PHP_SELF"], "e.statut", '', $param, '', $sortfield, $sortorder, 'right ');
}
// Action column
print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
print '</tr>'."\n";
// Loop on record
// --------------------------------------------------------------------
$i = 0;
$totalarray = array();
if ($num)
{
$warehouse = new Entrepot($db);
$totalarray = array();
while ($i < min($num, $limit))
{
$obj = $db->fetch_object($resql);
if (empty($obj)) break; // Should not happen
$warehouse->id = $obj->rowid;
$warehouse->ref = $obj->ref;
$warehouse->label = $obj->ref;
$warehouse->lieu = $obj->lieu;
$warehouse->fk_parent = $obj->fk_parent;
$warehouse->statut = $obj->statut;
// Show here line of result
print '<tr class="oddeven">';
//print_r($arrayfields[]);
// Label (ref)
if (!empty($arrayfields['e.ref']['checked']))
{
print '<td>'.$warehouse->getNomUrl(1).'</td>';
}
// Location
if (!empty($arrayfields['e.lieu']['checked']))
{
print '<td>'.$obj->lieu.'</td>';
}
// Description
if (!empty($arrayfields['e.description']['checked']))
{
print '<td>'.$obj->description.'</td>';
}
// Address
if (!empty($arrayfields['e.address']['checked']))
{
print '<td>'.$obj->address.'</td>';
}
// Zip
if (!empty($arrayfields['e.zip']['checked']))
{
print '<td>'.$obj->zip.'</td>';
}
if (!empty($arrayfields['e.town']['checked']))
{
print '<td>'.$obj->town.'</td>';
}
// Stock qty
if (!empty($arrayfields['stockqty']['checked']))
{
print '<td class="right">'.price2num($obj->stockqty, 5).'</td>';
}
// PMP value
if (!empty($arrayfields['estimatedvalue']['checked']))
{
print '<td class="right">';
if (price2num($obj->estimatedvalue, 'MT'))
{
print price(price2num($obj->estimatedvalue, 'MT'), 1);
}
else
{
print '';
}
print '</td>';
}
// Selling value
if (!empty($arrayfields['sellvalue']['checked']))
{
print '<td class="right">';
if (empty($conf->global->PRODUIT_MULTIPRICES))
{
print price(price2num($obj->sellvalue, 'MT'), 1);
}
else
{
$htmltext = $langs->trans("OptionMULTIPRICESIsOn");
print $form->textwithtooltip($langs->trans("Variable"), $htmltext);
}
print '</td>';
}
// Extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
// Fields from hook
$parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj);
$reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
// Status
if (!empty($arrayfields['e.statut']['checked']))
{
print '<td class="right">'.$warehouse->LibStatut($obj->statut, 5).'</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++;
}
if ($totalnboflines - $offset <= $limit)
{
print '<tr class="liste_total">';
$emptyColumn = -1;
if (!empty($arrayfields['e.ref']['checked']))
{
$emptyColumn++;
}
if (!empty($arrayfields['e.lieu']['checked']))
{
$emptyColumn++;
}
if (!empty($arrayfields['e.description']['checked']))
{
$emptyColumn++;
}
if (!empty($arrayfields['e.address']['checked']))
{
$emptyColumn++;
}
if (!empty($arrayfields['e.zip']['checked']))
{
$emptyColumn++;
}
if (!empty($arrayfields['e.town']['checked']))
{
$emptyColumn++;
}
for ($i=0; $i < $emptyColumn; $i++)
{
print '<td></td>';
}
print '<td class="right">'.$langs->trans("Total").'</td>';
if (!empty($arrayfields['stockqty']['checked']))
{
print '<td class="right">'.price2num($totalStock, 5).'</td>';
}
if (!empty($arrayfields['estimatedvalue']['checked']))
{
print '<td class="right">'.price(price2num($total, 'MT'), 1, $langs, 0, 0, -1, $conf->currency).'</td>';
}
if (!empty($arrayfields['sellvalue']['checked']))
{
print '<td class="right">';
if (empty($conf->global->PRODUIT_MULTIPRICES)) print price(price2num($totalsell, 'MT'), 1, $langs, 0, 0, -1, $conf->currency);
else
{
$htmltext = $langs->trans("OptionMULTIPRICESIsOn");
print $form->textwithtooltip($langs->trans("Variable"), $htmltext);
}
print '</td>';
}
if (empty($extrafieldsobjectkey) && is_object($object)) $extrafieldsobjectkey = $object->table_element;
if (is_array($extrafields->attributes[$extrafieldsobjectkey]['label']) && count($extrafields->attributes[$extrafieldsobjectkey]['label']))
{
if (empty($extrafieldsobjectprefix)) $extrafieldsobjectprefix = 'ef.';
foreach ($extrafields->attributes[$extrafieldsobjectkey]['label'] as $key => $val)
{
if (!empty($arrayfields[$extrafieldsobjectprefix.$key]['checked']))
{
print '<td></td>';
}
}
}
if (!empty($arrayfields['e.statut']['checked']))
{
print '<td></td>';
}
print '<td></td>';
print "</tr>\n";
}
}
$db->free($resql);
$parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql);
$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
print '</table>'."\n";
print '</div>'."\n";
print '</form>'."\n";
if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords))
{
$hidegeneratedfilelistifempty = 1;
if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty = 0;
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
$formfile = new FormFile($db);
// Show list of available documents
$urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder;
$urlsource .= str_replace('&amp;', '&', $param);
$filedir = $diroutputmassaction;
$genallowed = $user->rights->mymodule->read;
$delallowed = $user->rights->mymodule->create;
print $formfile->showdocuments('massfilesarea_mymodule', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty);
}
// End of page
llxFooter();
$db->close();