30require
'../../main.inc.php';
31require_once DOL_DOCUMENT_ROOT.
'/product/stock/class/entrepot.class.php';
32if (isModEnabled(
'category')) {
33 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcategory.class.php';
34 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
38$langs->loadLangs(array(
"stocks",
"other"));
40$action =
GETPOST(
'action',
'aZ09') ?
GETPOST(
'action',
'aZ09') :
'view';
41$massaction =
GETPOST(
'massaction',
'alpha');
43$confirm =
GETPOST(
'confirm',
'alpha');
44$cancel =
GETPOST(
'cancel',
'alpha');
45$toselect =
GETPOST(
'toselect',
'array');
46$contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'stocklist';
47$backtopage =
GETPOST(
'backtopage',
'alpha');
48$optioncss =
GETPOST(
'optioncss',
'aZ');
51$search_all = trim((
GETPOST(
'search_all',
'alphanohtml') !=
'') ?
GETPOST(
'search_all',
'alphanohtml') :
GETPOST(
'sall',
'alphanohtml'));
53$search_label =
GETPOST(
"snom",
"alpha") ?
GETPOST(
"snom",
"alpha") :
GETPOST(
"search_label",
"alpha");
54$search_status =
GETPOST(
"search_status",
"intcomma");
56$search_category_list = array();
57if (isModEnabled(
'category')) {
58 $search_category_list =
GETPOST(
"search_category_".Categorie::TYPE_WAREHOUSE.
"_list",
"array");
63$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
64$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
66if (empty($page) || $page < 0 ||
GETPOST(
'button_search',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
71$offset = $limit * $page;
84$diroutputmassaction = $conf->stock->dir_output.
'/temp/massgeneration/'.$user->id;
85$hookmanager->initHooks(array($contextpage));
88$extrafields->fetch_name_optionals_label(
$object->table_element);
90$search_array_options = $extrafields->getOptionalsFromPost(
$object->table_element,
'',
'search_');
93$search_all =
GETPOST(
"search_all",
'alphanohtml');
95foreach (
$object->fields as $key => $val) {
97 if ($search_key ==
'statut') {
98 $search_key =
'status';
100 if (
GETPOST(
'search_'.$search_key,
'alpha') !==
'') {
101 $search[$search_key] =
GETPOST(
'search_'.$search_key,
'alpha');
106$fieldstosearchall = array();
107foreach (
$object->fields as $key => $val) {
108 if (!empty($val[
'searchall'])) {
109 $fieldstosearchall[
't.'.$key] = $val[
'label'];
115 'stockqty' => array(
'type' =>
'float',
'label' =>
'PhysicalStock',
'enabled' => 1,
'visible' => -2,
'checked' => 0,
'position' => 170),
116 'estimatedvalue' => array(
'type' =>
'float',
'label' =>
'EstimatedStockValue',
'enabled' => 1,
'visible' => 1,
'checked' => 1,
'position' => 171),
117 'estimatedstockvaluesell' => array(
'type' =>
'float',
'label' =>
'EstimatedStockValueSell',
'enabled' => 1,
'checked' => 1,
'visible' => 2,
'position' => 172),
119foreach (
$object->fields as $key => $val) {
121 if (!empty($val[
'visible'])) {
122 $visible = (int)
dol_eval($val[
'visible'], 1);
123 $arrayfields[
't.'.$key] = array(
124 'label' => $val[
'label'],
125 'checked' => (($visible < 0) ? 0 : 1),
126 'enabled' => (abs($visible) != 3 && (bool)
dol_eval($val[
'enabled'], 1)),
127 'position' => $val[
'position'],
128 'help' => isset($val[
'help']) ? $val[
'help'] :
''
133include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_array_fields.tpl.php';
138$permissiontoread = $user->hasRight(
'stock',
'lire');
139$permissiontodelete = $user->hasRight(
'stock',
'supprimer');
140$permissiontoadd = $user->hasRight(
'stock',
'creer');
150if (
GETPOST(
'cancel',
'alpha')) {
154if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'presend' && $massaction !=
'confirm_presend') {
158$parameters = array();
159$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
164if (empty($reshook)) {
166 include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
169 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
170 foreach (
$object->fields as $key => $val) {
172 if (preg_match(
'/^(date|timestamp|datetime)/', $val[
'type'])) {
173 $search[$key.
'_dtstart'] =
'';
174 $search[$key.
'_dtend'] =
'';
178 $search_array_options = array();
179 $search_category_list = array();
181 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')
182 ||
GETPOST(
'button_search_x',
'alpha') ||
GETPOST(
'button_search.x',
'alpha') ||
GETPOST(
'button_search',
'alpha')) {
187 $objectclass =
'Entrepot';
188 $objectlabel =
'Warehouse';
189 $uploaddir = $conf->stock->dir_output;
190 include DOL_DOCUMENT_ROOT.
'/core/actions_massactions.inc.php';
198$form =
new Form($db);
203$title = $langs->trans(
"Warehouses");
204$help_url =
'EN:Module_Stocks_En|FR:Module_Stock|ES:Módulo_Stocks';
210$sql .=
$object->getFieldList(
't');
212if (!empty($extrafields->attributes[
$object->table_element][
'label'])) {
213 foreach ($extrafields->attributes[
$object->table_element][
'label'] as $key => $val) {
214 $sql .= ($extrafields->attributes[
$object->table_element][
'type'][$key] !=
'separate' ?
", ef.".$key.
" as options_".$key :
'');
219$separatedPMP =
false;
221 $separatedPMP =
true;
222 $sql .=
", SUM(pa.pmp * ps.reel) as estimatedvalue, SUM(p.price * ps.reel) as sellvalue, SUM(ps.reel) as stockqty";
224 $sql .=
", SUM(p.pmp * ps.reel) as estimatedvalue, SUM(p.price * ps.reel) as sellvalue, SUM(ps.reel) as stockqty";
229$parameters = array();
230$reshook = $hookmanager->executeHooks(
'printFieldListSelect', $parameters, $object);
231$sql .= $hookmanager->resPrint;
232$sql = preg_replace(
'/,\s*$/',
'', $sql);
236$sql .=
" FROM ".MAIN_DB_PREFIX.$object->table_element.
" as t";
237if (!empty($extrafields->attributes[
$object->table_element][
'label']) && is_array($extrafields->attributes[
$object->table_element][
'label']) && count($extrafields->attributes[
$object->table_element][
'label'])) {
238 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element.
"_extrafields as ef on (t.rowid = ef.fk_object)";
240$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"product_stock as ps ON t.rowid = ps.fk_entrepot";
241$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"product as p ON ps.fk_product = p.rowid";
242$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_departements as c_dep ON c_dep.rowid = t.fk_departement";
243$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_country as ccount ON ccount.rowid = t.fk_pays";
245 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"product_perentity as pa ON pa.fk_product = p.rowid AND pa.fk_product = ps.fk_product AND pa.entity = ". (int) $conf->entity;
247$sql .=
" WHERE t.entity IN (".getEntity(
'stock').
")";
248foreach ($search as $key => $val) {
249 if (array_key_exists($key,
$object->fields)) {
251 if ($class_key ==
'status') {
252 $class_key =
'statut';
254 if (($key ==
'status' && $search[$key] == -1) || $key ==
'entity') {
258 if ((strpos(
$object->fields[$key][
'type'],
'integer:') === 0) || (strpos(
$object->fields[$key][
'type'],
'sellist:') === 0) || !empty(
$object->fields[$key][
'arrayofkeyval'])) {
259 if ($search[$key] ==
'-1' || ($search[$key] ===
'0' && (empty(
$object->fields[$key][
'arrayofkeyval']) || !array_key_exists(
'0',
$object->fields[$key][
'arrayofkeyval'])))) {
264 if ($search[$key] !=
'') {
265 $sql .=
natural_search((($key ==
"ref") ?
"t.ref" :
"t.".$class_key), $search[$key], (($key ==
'status') ? 2 : $mode_search));
268 if (preg_match(
'/(_dtstart|_dtend)$/', $key) && $search[$key] !=
'') {
269 $columnName = preg_replace(
'/(_dtstart|_dtend)$/',
'', $key);
270 if (preg_match(
'/^(date|timestamp|datetime)/',
$object->fields[$columnName][
'type'])) {
271 if (preg_match(
'/_dtstart$/', $key)) {
272 $sql .=
" AND t.".$db->escape($columnName).
" >= '".$db->idate($search[$key]).
"'";
274 if (preg_match(
'/_dtend$/', $key)) {
275 $sql .=
" AND t.".$db->escape($columnName).
" <= '".$db->idate($search[$key]).
"'";
282 $sql .=
natural_search(array_keys($fieldstosearchall), $search_all);
285$searchCategoryWarehouseList = $search_category_list;
286$searchCategoryWarehouseOperator = 0;
287if (!empty($searchCategoryWarehouseList)) {
288 $searchCategoryWarehouseSqlList = array();
289 $listofcategoryid =
'';
290 foreach ($searchCategoryWarehouseList as $searchCategoryWarehouse) {
291 if (intval($searchCategoryWarehouse) == -2) {
292 $searchCategoryWarehouseSqlList[] =
" NOT EXISTS (SELECT ck.fk_warehouse FROM ".MAIN_DB_PREFIX.
"categorie_warehouse as ck WHERE t.rowid = ck.fk_warehouse)";
293 } elseif (intval($searchCategoryWarehouse) > 0) {
294 if ($searchCategoryWarehouseOperator == 0) {
295 $searchCategoryWarehouseSqlList[] =
" EXISTS (SELECT ck.fk_warehouse FROM ".MAIN_DB_PREFIX.
"categorie_warehouse as ck WHERE t.rowid = ck.fk_warehouse AND ck.fk_categorie = ".((int) $searchCategoryWarehouse).
")";
297 $listofcategoryid .= ($listofcategoryid ?
', ' :
'') .((
int) $searchCategoryWarehouse);
301 if ($listofcategoryid) {
302 $searchCategoryWarehouseSqlList[] =
" EXISTS (SELECT ck.fk_warehouse FROM ".MAIN_DB_PREFIX.
"categorie_warehouse as ck WHERE t.rowid = ck.fk_warehouse AND ck.fk_categorie IN (".$db->sanitize($listofcategoryid).
"))";
304 if ($searchCategoryWarehouseOperator == 1) {
305 if (!empty($searchCategoryWarehouseSqlList)) {
306 $sql .=
" AND (".implode(
' OR ', $searchCategoryWarehouseSqlList).
")";
309 if (!empty($searchCategoryWarehouseSqlList)) {
310 $sql .=
" AND (".implode(
' AND ', $searchCategoryWarehouseSqlList).
")";
316include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_sql.tpl.php';
318$parameters = array();
319$reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters, $object, $action);
320$sql .= $hookmanager->resPrint;
323foreach (
$object->fields as $key => $val) {
324 $sql .=
"t.".$db->escape($key).
", ";
327if (!empty($extrafields->attributes[
$object->table_element][
'label'])) {
328 foreach ($extrafields->attributes[
$object->table_element][
'label'] as $key => $val) {
329 $sql .= ($extrafields->attributes[
$object->table_element][
'type'][$key] !=
'separate' ?
"ef.".$key.
', ' :
'');
333$parameters = array();
334$reshook = $hookmanager->executeHooks(
'printFieldListGroupBy', $parameters);
335$sql .= $hookmanager->resPrint;
336$sql = preg_replace(
'/,\s*$/',
'', $sql);
339$result = $db->query($sql);
341 $totalnboflines = $db->num_rows($result);
343 $line = $total = $totalsell = $totalStock = 0;
344 while ($line < $totalnboflines) {
345 $objp = $db->fetch_object($result);
346 $total += $objp->estimatedvalue;
347 $totalsell += $objp->sellvalue;
348 $totalStock += $objp->stockqty;
351 $totalarray[
'val'][
'stockqty'] =
price2num($totalStock,
'MS');
352 $totalarray[
'val'][
'estimatedvalue'] =
price2num($total,
'MT');
353 $totalarray[
'val'][
'estimatedstockvaluesell'] =
price2num($totalsell,
'MT');
357$nbtotalofrecords =
'';
360 $sqlforcount = preg_replace(
'/^'.preg_quote($sqlfields,
'/').
'/',
'SELECT COUNT(*) as nbtotalofrecords', $sql);
361 $sqlforcount = preg_replace(
'/LEFT JOIN [a-z]+_product_stock as ps ON t.rowid = ps.fk_entrepot LEFT JOIN [a-z]+_product as p ON ps.fk_product = p.rowid/',
'', $sqlforcount);
362 $sqlforcount = preg_replace(
'/LEFT JOIN [a-z]+_product_perentity as pa ON pa.fk_product = p.rowid AND pa.fk_product = ps.fk_product AND pa.entity = -?[0-9]+/',
'', $sqlforcount);
363 $sqlforcount = preg_replace(
'/GROUP BY .*$/',
'', $sqlforcount);
365 $resql = $db->query($sqlforcount);
367 $objforcount = $db->fetch_object($resql);
368 $nbtotalofrecords = $objforcount->nbtotalofrecords;
373 if (($page * $limit) > $nbtotalofrecords) {
381$sql .= $db->order($sortfield, $sortorder);
383 $sql .= $db->plimit($limit + 1, $offset);
386$resql = $db->query($sql);
392$num = $db->num_rows($resql);
395if ($num == 1 &&
getDolGlobalInt(
'MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE') && $search_all && !$page) {
396 $obj = $db->fetch_object($resql);
398 header(
"Location: ".DOL_URL_ROOT.
'/product/stock/card.php?id='.$id);
406llxHeader(
'', $title, $help_url,
'', 0, 0,
'',
'',
'',
'bodyforlist mod-product page-stock_list');
408$arrayofselected = is_array($toselect) ? $toselect : array();
412 $param .=
'&mode='.urlencode($mode);
414if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
415 $param .=
'&contextpage='.urlencode($contextpage);
417if ($limit > 0 && $limit != $conf->liste_limit) {
418 $param .=
'&limit='.((int) $limit);
420if ($optioncss !=
'') {
421 $param .=
'&optioncss='.urlencode($optioncss);
423foreach ($search as $key => $val) {
424 if (is_array($search[$key])) {
425 foreach ($search[$key] as $skey) {
427 $param .=
'&search_'.$key.
'[]='.urlencode($skey);
430 } elseif (preg_match(
'/(_dtstart|_dtend)$/', $key) && !empty($val)) {
431 $param .=
'&search_'.$key.
'month='.(
GETPOSTINT(
'search_'.$key.
'month'));
432 $param .=
'&search_'.$key.
'day='.(
GETPOSTINT(
'search_'.$key.
'day'));
433 $param .=
'&search_'.$key.
'year='.(
GETPOSTINT(
'search_'.$key.
'year'));
434 } elseif ($search[$key] !=
'') {
435 $param .=
'&search_'.$key.
'='.urlencode($search[$key]);
439include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_param.tpl.php';
441$parameters = array(
'param' => &$param);
442$reshook = $hookmanager->executeHooks(
'printFieldListSearchParam', $parameters, $object, $action);
443$param .= $hookmanager->resPrint;
446$arrayofmassactions = array(
451if (
GETPOSTINT(
'nomassaction') || in_array($massaction, array(
'presend',
'predelete',
'preaffecttag'))) {
452 $arrayofmassactions = array();
454if (isModEnabled(
'category') && $user->hasRight(
'stock',
'creer')) {
455 $arrayofmassactions[
'preaffecttag'] =
img_picto(
'',
'label',
'class="pictofixedwidth"').$langs->trans(
"AffectTag");
457$massactionbutton = $form->selectMassAction(
'', $arrayofmassactions);
459print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" id="searchFormList" method="POST" name="formulaire">';
460if ($optioncss !=
'') {
461 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
463print
'<input type="hidden" name="token" value="'.newToken().
'">';
464print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
465print
'<input type="hidden" name="action" value="list">';
466print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
467print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
468print
'<input type="hidden" name="page" value="'.$page.
'">';
469print
'<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
470print
'<input type="hidden" name="page_y" value="">';
471print
'<input type="hidden" name="mode" value="'.$mode.
'">';
475$newcardbutton .=
dolGetButtonTitle($langs->trans(
'ViewList'),
'',
'fa fa-bars imgforviewmode', $_SERVER[
"PHP_SELF"].
'?mode=common'.preg_replace(
'/(&|\?)*mode=[^&]+/',
'', $param),
'', ((empty($mode) || $mode ==
'common') ? 2 : 1), array(
'morecss' =>
'reposition'));
476$newcardbutton .=
dolGetButtonTitle($langs->trans(
'ViewKanban'),
'',
'fa fa-th-list imgforviewmode', $_SERVER[
"PHP_SELF"].
'?mode=kanban'.preg_replace(
'/(&|\?)*mode=[^&]+/',
'', $param),
'', ($mode ==
'kanban' ? 2 : 1), array(
'morecss' =>
'reposition'));
478$newcardbutton .=
dolGetButtonTitle($langs->trans(
'MenuNewWarehouse'),
'',
'fa fa-plus-circle', DOL_URL_ROOT.
'/product/stock/card.php?action=create&backtopage='.urlencode($_SERVER[
'PHP_SELF']),
'', $user->hasRight(
'stock',
'creer'));
480print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'stock', 0, $newcardbutton,
'', $limit, 0, 0, 1);
483$topicmail =
"Information";
484$modelmail =
"warehouse";
486$trackid =
'ware'.$object->id;
487include DOL_DOCUMENT_ROOT.
'/core/tpl/massactions_pre.tpl.php';
492 foreach ($fieldstosearchall as $key => $val) {
493 $fieldstosearchall[$key] = $langs->trans($val);
494 $setupstring .= $key.
"=".$val.
";";
496 print
'<!-- Search done like if STOCK_QUICKSEARCH_ON_FIELDS = '.$setupstring.
' -->'.
"\n";
497 print
'<div class="divsearchfieldfilter">'.$langs->trans(
"FilterOnInto", $sall).implode(
', ', $fieldstosearchall).
'</div>';
502if (isModEnabled(
'category') && $user->hasRight(
'categorie',
'lire')) {
504 $moreforfilter .= $formcategory->getFilterBox(Categorie::TYPE_WAREHOUSE, $search_category_list);
511$parameters = array();
512$reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters, $object, $action);
513if (empty($reshook)) {
514 $moreforfilter .= $hookmanager->resPrint;
516 $moreforfilter = $hookmanager->resPrint;
519if (!empty($moreforfilter)) {
520 print
'<div class="liste_titre liste_titre_bydiv centpercent">';
521 print $moreforfilter;
525$varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
526$htmlofselectarray = $form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage,
getDolGlobalString(
'MAIN_CHECKBOX_LEFT_COLUMN'));
527$selectedfields = ($mode !=
'kanban' ? $htmlofselectarray :
'');
528$selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons(
'checkforselect', 1) :
'');
530print
'<div class="div-table-responsive">';
531print
'<table class="tagtable nobottomiftotal liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'">'.
"\n";
535print
'<tr class="liste_titre_filter">';
538 print
'<td class="liste_titre center maxwidthsearch">';
539 $searchpicto = $form->showFilterButtons(
'left');
543foreach (
$object->fields as $key => $val) {
544 if ($key ==
'statut') {
547 $searchkey = empty($search[$key]) ?
'' : $search[$key];
548 $cssforfield = (empty($val[
'csslist']) ? (empty($val[
'css']) ?
'' : $val[
'css']) : $val[
'csslist']);
549 if ($key ==
'status') {
550 $cssforfield .= ($cssforfield ?
' ' :
'').
'center';
551 } elseif (in_array($val[
'type'], array(
'date',
'datetime',
'timestamp'))) {
552 $cssforfield .= ($cssforfield ?
' ' :
'').
'center';
553 } elseif (in_array($val[
'type'], array(
'timestamp'))) {
554 $cssforfield .= ($cssforfield ?
' ' :
'').
'nowrap';
555 } elseif (in_array($val[
'type'], array(
'double(24,8)',
'double(6,3)',
'integer',
'real',
'price')) && !in_array($key, array(
'id',
'rowid',
'ref',
'status')) && $val[
'label'] !=
'TechnicalID' && empty($val[
'arrayofkeyval'])) {
556 $cssforfield .= ($cssforfield ?
' ' :
'').
'right';
558 if (!empty($arrayfields[
't.'.$key][
'checked'])) {
559 print
'<td class="liste_titre'.($cssforfield ?
' '.$cssforfield :
'').($key ==
'status' ?
' parentonrightofpage' :
'').
'">';
560 if (!empty($val[
'arrayofkeyval']) && is_array($val[
'arrayofkeyval'])) {
561 print $form->selectarray(
'search_'.$key, $val[
'arrayofkeyval'], (isset($search[$key]) ? $search[$key] :
''), 1, 0, 0,
'', 1, 0, 0,
'',
'maxwidth100'.($key ==
'status' ?
' search_status width100 onrightofpage' :
''), 1);
562 } elseif ((strpos($val[
'type'],
'integer:') === 0) || (strpos($val[
'type'],
'sellist:') === 0)) {
563 print
$object->showInputField($val, $key, (isset($search[$key]) ? $search[$key] :
''),
'',
'',
'search_', $cssforfield.
' maxwidth250', 1);
564 } elseif (preg_match(
'/^(date|timestamp|datetime)/', $val[
'type'])) {
565 print
'<div class="nowrap">';
566 print $form->selectDate(isset($search[$key.
'_dtstart']) ? $search[$key.
'_dtstart'] :
'',
"search_".$key.
"_dtstart", 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'From'));
568 print
'<div class="nowrap">';
569 print $form->selectDate(isset($search[$key.
'_dtend']) ? $search[$key.
'_dtend'] :
'',
"search_".$key.
"_dtend", 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'to'));
571 } elseif ($key ==
'lang') {
572 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formadmin.class.php';
574 print $formadmin->select_language($search[$key],
'search_lang', 0,
null, 1, 0, 0,
'minwidth100imp maxwidth125', 2);
576 print
'<input type="text" class="flat maxwidth75" name="search_'.$key.
'" value="'.
dol_escape_htmltag(isset($search[$key]) ? $search[$key] :
'').
'">';
582if (!empty($arrayfields[
"stockqty"][
'checked'])) {
583 print
'<td class="liste_titre"></td>';
586if (!empty($arrayfields[
"estimatedvalue"][
'checked'])) {
587 print
'<td class="liste_titre"></td>';
590if (!empty($arrayfields[
"estimatedstockvaluesell"][
'checked'])) {
591 print
'<td class="liste_titre"></td>';
595include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_input.tpl.php';
598$parameters = array(
'arrayfields' => $arrayfields);
599$reshook = $hookmanager->executeHooks(
'printFieldListOption', $parameters, $object, $action);
600print $hookmanager->resPrint;
603if (!empty($arrayfields[
't.statut'][
'checked'])) {
604 print
'<td class="liste_titre center parentonrightofpage">';
605 print $form->selectarray(
'search_status', $warehouse->labelStatus, $search_status, 1, 0, 0,
'', 1, 0, 0,
'',
'search_status width100 onrightofpage');
611 print
'<td class="liste_titre center maxwidthsearch">';
612 $searchpicto = $form->showFilterButtons();
618$totalarray = array();
619$totalarray[
'nbfield'] = 0;
623print
'<tr class="liste_titre">';
626 print
getTitleFieldOfList($selectedfields, 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ').
"\n";
627 $totalarray[
'nbfield']++;
629foreach (
$object->fields as $key => $val) {
630 if ($key ==
'statut') {
633 $cssforfield = (empty($val[
'csslist']) ? (empty($val[
'css']) ?
'' : $val[
'css']) : $val[
'csslist']);
634 if ($key ==
'status') {
635 $cssforfield .= ($cssforfield ?
' ' :
'').
'center';
636 } elseif (in_array($val[
'type'], array(
'date',
'datetime',
'timestamp'))) {
637 $cssforfield .= ($cssforfield ?
' ' :
'').
'center';
638 } elseif (in_array($val[
'type'], array(
'timestamp'))) {
639 $cssforfield .= ($cssforfield ?
' ' :
'').
'nowrap';
640 } elseif (in_array($val[
'type'], array(
'double(24,8)',
'double(6,3)',
'integer',
'real',
'price')) && !in_array($key, array(
'id',
'rowid',
'ref',
'status')) && $val[
'label'] !=
'TechnicalID' && empty($val[
'arrayofkeyval'])) {
641 $cssforfield .= ($cssforfield ?
' ' :
'').
'right';
643 $cssforfield = preg_replace(
'/small\s*/',
'', $cssforfield);
644 if (!empty($arrayfields[
't.'.$key][
'checked'])) {
645 print
getTitleFieldOfList($arrayfields[
't.'.$key][
'label'], 0, $_SERVER[
'PHP_SELF'],
't.'.$key,
'', $param, ($cssforfield ?
'class="'.$cssforfield.
'"' :
''), $sortfield, $sortorder, ($cssforfield ? $cssforfield.
' ' :
''), 0, (empty($val[
'helplist']) ?
'' : $val[
'helplist'])).
"\n";
646 $totalarray[
'nbfield']++;
650if (!empty($arrayfields[
"stockqty"][
'checked'])) {
651 print_liste_field_titre(
"PhysicalStock", $_SERVER[
"PHP_SELF"],
"stockqty",
'', $param,
'', $sortfield, $sortorder,
'right ');
652 $totalarray[
'nbfield']++;
653 $totalarray[
'type'][$totalarray[
'nbfield']] =
'stock';
656if (!empty($arrayfields[
"estimatedvalue"][
'checked'])) {
657 print_liste_field_titre(
"EstimatedStockValue", $_SERVER[
"PHP_SELF"],
"estimatedvalue",
'', $param,
'', $sortfield, $sortorder,
'right ');
658 $totalarray[
'nbfield']++;
659 $totalarray[
'type'][$totalarray[
'nbfield']] =
'price';
662if (!empty($arrayfields[
"estimatedstockvaluesell"][
'checked'])) {
663 print_liste_field_titre(
"EstimatedStockValueSell", $_SERVER[
"PHP_SELF"],
"",
'', $param,
'', $sortfield, $sortorder,
'right ');
664 $totalarray[
'nbfield']++;
665 $totalarray[
'type'][$totalarray[
'nbfield']] =
'price';
669include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_title.tpl.php';
672$parameters = array(
'arrayfields' => $arrayfields,
'param' => $param,
'sortfield' => $sortfield,
'sortorder' => $sortorder);
673$reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters, $object);
674print $hookmanager->resPrint;
676if (!empty($arrayfields[
't.statut'][
'checked'])) {
677 print_liste_field_titre($arrayfields[
't.statut'][
'label'], $_SERVER[
"PHP_SELF"],
"t.statut",
'', $param,
'', $sortfield, $sortorder,
'center ');
678 $totalarray[
'nbfield']++;
683 print
getTitleFieldOfList($selectedfields, 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ').
"\n";
684 $totalarray[
'nbfield']++;
693$savnbfield = $totalarray[
'nbfield'];
694$totalarray[
'nbfield'] = 0;
695$imaxinloop = ($limit ? min($num, $limit) : $num);
696while ($i < $imaxinloop) {
697 $obj = $db->fetch_object($resql);
703 $warehouse->setVarsFromFetchObj($obj);
705 $warehouse->label = $warehouse->ref;
706 $warehouse->sellvalue = $obj->sellvalue;
710 if ($mode ==
'kanban') {
712 print
'<tr class="trkanban"><td colspan="'.$savnbfield.
'">';
713 print
'<div class="box-flex-container kanban">';
717 if ($massactionbutton || $massaction) {
719 if (in_array(
$object->id, $arrayofselected)) {
723 print
$object->getKanbanView(
'', array(
'selected' => $selected));
724 if ($i == ($imaxinloop - 1)) {
731 print
'<tr data-rowid="'.$object->id.
'" class="oddeven">';
735 print
'<td class="nowrap center">';
736 if ($massactionbutton || $massaction) {
738 if (in_array(
$object->id, $arrayofselected)) {
741 print
'<input id="cb'.$object->id.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.
$object->id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
745 $totalarray[
'nbfield']++;
748 foreach (
$object->fields as $key => $val) {
749 if ($key ==
'statut') {
752 $cssforfield = (empty($val[
'csslist']) ? (empty($val[
'css']) ?
'' : $val[
'css']) : $val[
'csslist']);
753 if (in_array($val[
'type'], array(
'date',
'datetime',
'timestamp'))) {
754 $cssforfield .= ($cssforfield ?
' ' :
'').
'center';
755 } elseif ($key ==
'status') {
756 $cssforfield .= ($cssforfield ?
' ' :
'').
'center';
759 if (in_array($val[
'type'], array(
'timestamp'))) {
760 $cssforfield .= ($cssforfield ?
' ' :
'').
'nowraponall';
761 } elseif ($key ==
'ref') {
762 $cssforfield .= ($cssforfield ?
' ' :
'').
'nowraponall';
765 if (in_array($val[
'type'], array(
'double(24,8)',
'double(6,3)',
'integer',
'real',
'price')) && !in_array($key, array(
'id',
'rowid',
'ref',
'status')) && empty($val[
'arrayofkeyval'])) {
766 $cssforfield .= ($cssforfield ?
' ' :
'').
'right';
768 if (in_array($key, array(
'fk_soc',
'fk_user',
'fk_warehouse'))) {
769 $cssforfield =
'tdoverflowmax100';
772 if (!empty($arrayfields[
't.'.$key][
'checked'])) {
773 print
'<td'.($cssforfield ?
' class="'.$cssforfield.(preg_match(
'/tdoverflow/', $cssforfield) ?
' classfortooltip' :
'').
'"' :
'');
774 if (preg_match(
'/tdoverflow/', $cssforfield) && !is_numeric(
$object->$key)) {
775 print
' title="'.dol_escape_htmltag(
$object->$key).
'"';
778 if ($key ==
'statut') {
779 print
$object->getLibStatut(5);
781 if ($key ==
'phone') {
783 } elseif ($key ==
'fax') {
786 print $warehouse->showOutputField($val, $key,
$object->$key,
'');
790 $totalarray[
'nbfield']++;
792 if (!empty($val[
'isameasure']) && $val[
'isameasure'] == 1) {
794 $totalarray[
'pos'][$totalarray[
'nbfield']] =
't.'.$key;
796 if (!isset($totalarray[
'val'])) {
797 $totalarray[
'val'] = array();
799 if (!isset($totalarray[
'val'][
't.'.$key])) {
800 $totalarray[
'val'][
't.'.$key] = 0;
802 $totalarray[
'val'][
't.'.$key] +=
$object->$key;
808 if (!empty($arrayfields[
"stockqty"][
'checked'])) {
809 print
'<td class="right">'.price(
price2num($obj->stockqty,
'MS')).
'</td>';
811 $totalarray[
'nbfield']++;
814 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'stockqty';
819 if (!empty($arrayfields[
"estimatedvalue"][
'checked'])) {
820 print
'<td class="right">';
821 if (
price2num($obj->estimatedvalue,
'MT')) {
822 print
'<span class="amount">'.price(
price2num($obj->estimatedvalue,
'MT'), 1).
'</span>';
828 $totalarray[
'nbfield']++;
831 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'estimatedvalue';
836 if (!empty($arrayfields[
"estimatedstockvaluesell"][
'checked'])) {
837 print
'<td class="right">';
839 if ($obj->sellvalue) {
840 print
'<span class="amount">'.price(
price2num($obj->sellvalue,
'MT'), 1).
'</span>';
843 $htmltext = $langs->trans(
"OptionMULTIPRICESIsOn");
844 print $form->textwithtooltip(
'<span class="opacitymedium">'.$langs->trans(
"Variable").
'</span>', $htmltext);
848 $totalarray[
'nbfield']++;
851 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'estimatedstockvaluesell';
856 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_print_fields.tpl.php';
858 $parameters = array(
'arrayfields' => $arrayfields,
'object' => $object,
'obj' => $obj,
'i' => $i,
'totalarray' => &$totalarray);
859 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object, $action);
860 print $hookmanager->resPrint;
863 if (!empty($arrayfields[
't.statut'][
'checked'])) {
864 print
'<td class="center">'.$warehouse->LibStatut($obj->statut, 5).
'</td>';
866 $totalarray[
'nbfield']++;
872 print
'<td class="nowrap center">';
873 if ($massactionbutton || $massaction) {
875 if (in_array(
$object->id, $arrayofselected)) {
878 print
'<input id="cb'.$object->id.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.
$object->id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
882 $totalarray[
'nbfield']++;
892if ($totalnboflines - $offset <= $limit) {
894 include DOL_DOCUMENT_ROOT.
'/core/tpl/list_print_total.tpl.php';
900 foreach ($arrayfields as $key => $val) {
901 if (!empty($val[
'checked'])) {
905 print
'<tr><td colspan="'.$colspan.
'" class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</td></tr>';
910$parameters = array(
'arrayfields' => $arrayfields,
'sql' => $sql);
911$reshook = $hookmanager->executeHooks(
'printFieldListFooter', $parameters, $object);
912print $hookmanager->resPrint;
914print
'</table>'.
"\n";
919if (in_array(
'builddoc', array_keys($arrayofmassactions)) && ($nbtotalofrecords ===
'' || $nbtotalofrecords)) {
920 $hidegeneratedfilelistifempty = 1;
921 if ($massaction ==
'builddoc' || $action ==
'remove_file' || $show_files) {
922 $hidegeneratedfilelistifempty = 0;
925 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
929 $urlsource = $_SERVER[
'PHP_SELF'].
'?sortfield='.$sortfield.
'&sortorder='.$sortorder;
930 $urlsource .= str_replace(
'&',
'&', $param);
932 $filedir = $diroutputmassaction;
933 $genallowed = $user->hasRight(
'stock',
'lire');
934 $delallowed = $user->hasRight(
'stock',
'creer');
936 print $formfile->showdocuments(
'massfilesarea_stock',
'', $filedir, $urlsource, 0, $delallowed,
'', 1, 1, 0, 48, 1, $param, $title,
'',
'',
'',
null, $hidegeneratedfilelistifempty);
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
Class to manage warehouses.
dol_print_phone($phone, $countrycode='', $cid=0, $socid=0, $addlink='', $separ=" ", $withpicto='', $titlealt='', $adddivfloat=0, $morecss='')
Format phone numbers according to country.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
dolGetButtonTitle($label, $helpText='', $iconClass='fa fa-file', $url='', $id='', $status=1, $params=array())
Function dolGetButtonTitle : this kind of buttons are used in title in list.
dol_eval($s, $returnvalue=1, $hideerrors=1, $onlysimplestring='1')
Replace eval function to add more security.
natural_search($fields, $value, $mode=0, $nofirstand=0)
Generate natural SQL search string for a criteria (this criteria can be tested on one or several fiel...
dol_now($mode='auto')
Return date for now.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_sort_array(&$array, $index, $order='asc', $natsort=0, $case_sensitive=0, $keepindex=0)
Advanced sort array by the value of a given key, which produces ascending (default) or descending out...
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
getTitleFieldOfList($name, $thead=0, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $disablesortlink=0, $tooltip='', $forcenowrapcolumntitle=0)
Get title line of an array.
dolGetButtonTitleSeparator($moreClass="")
Add space between dolGetButtonTitle.
print_barre_liste($title, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='generic', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $hideselectlimit=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.