31require
'../../main.inc.php';
32require_once DOL_DOCUMENT_ROOT.
'/product/stock/class/entrepot.class.php';
33if (isModEnabled(
'category')) {
34 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcategory.class.php';
35 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
47$langs->loadLangs(array(
"stocks",
"other"));
49$action =
GETPOST(
'action',
'aZ09') ?
GETPOST(
'action',
'aZ09') :
'view';
50$massaction =
GETPOST(
'massaction',
'alpha');
52$confirm =
GETPOST(
'confirm',
'alpha');
53$cancel =
GETPOST(
'cancel',
'alpha');
54$toselect =
GETPOST(
'toselect',
'array');
55$contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'stocklist';
56$backtopage =
GETPOST(
'backtopage',
'alpha');
57$optioncss =
GETPOST(
'optioncss',
'aZ');
60$search_all = trim(
GETPOST(
'search_all',
'alphanohtml'));
62$search_label =
GETPOST(
"snom",
"alpha") ?
GETPOST(
"snom",
"alpha") :
GETPOST(
"search_label",
"alpha");
63$search_status =
GETPOST(
"search_status",
"intcomma");
65$search_category_list = array();
66if (isModEnabled(
'category')) {
67 $search_category_list =
GETPOST(
"search_category_".Categorie::TYPE_WAREHOUSE.
"_list",
"array");
72$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
73$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
75if (empty($page) || $page < 0 ||
GETPOST(
'button_search',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
80$offset = $limit * $page;
93$diroutputmassaction =
$conf->stock->dir_output.
'/temp/massgeneration/'.$user->id;
94$hookmanager->initHooks(array($contextpage));
97$extrafields->fetch_name_optionals_label(
$object->table_element);
99$search_array_options = $extrafields->getOptionalsFromPost(
$object->table_element,
'',
'search_');
102$search_all =
GETPOST(
"search_all",
'alphanohtml');
104foreach (
$object->fields as $key => $val) {
106 if ($search_key ==
'statut') {
107 $search_key =
'status';
109 if (
GETPOST(
'search_'.$search_key,
'alpha') !==
'') {
110 $search[$search_key] =
GETPOST(
'search_'.$search_key,
'alpha');
115$fieldstosearchall = array();
116foreach (
$object->fields as $key => $val) {
117 if (!empty($val[
'searchall'])) {
118 $fieldstosearchall[
't.'.$key] = $val[
'label'];
124 'stockqty' => array(
'type' =>
'float',
'label' =>
'PhysicalStock',
'enabled' => 1,
'visible' => -2,
'checked' => 0,
'position' => 170),
125 'estimatedvalue' => array(
'type' =>
'float',
'label' =>
'EstimatedStockValue',
'enabled' => 1,
'visible' => 1,
'checked' => 1,
'position' => 171),
126 'estimatedstockvaluesell' => array(
'type' =>
'float',
'label' =>
'EstimatedStockValueSell',
'enabled' => 1,
'checked' => 1,
'visible' => 2,
'position' => 172),
128foreach (
$object->fields as $key => $val) {
130 if (!empty($val[
'visible'])) {
131 $visible = (int)
dol_eval((
string) $val[
'visible'], 1);
132 $arrayfields[
't.'.$key] = array(
133 'label' => $val[
'label'],
134 'checked' => (($visible < 0) ? 0 : 1),
135 'enabled' => (abs($visible) != 3 && (bool)
dol_eval($val[
'enabled'], 1)),
136 'position' => $val[
'position'],
137 'help' => isset($val[
'help']) ? $val[
'help'] :
''
142include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_array_fields.tpl.php';
147$permissiontoread = $user->hasRight(
'stock',
'lire');
148$permissiontodelete = $user->hasRight(
'stock',
'supprimer');
149$permissiontoadd = $user->hasRight(
'stock',
'creer');
159if (
GETPOST(
'cancel',
'alpha')) {
163if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'presend' && $massaction !=
'confirm_presend') {
167$parameters = array();
168$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
173if (empty($reshook)) {
175 include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
178 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
179 foreach (
$object->fields as $key => $val) {
181 if (preg_match(
'/^(date|timestamp|datetime)/', $val[
'type'])) {
182 $search[$key.
'_dtstart'] =
'';
183 $search[$key.
'_dtend'] =
'';
186 $search[
'status'] =
'';
189 $search_array_options = array();
190 $search_category_list = array();
192 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')
193 ||
GETPOST(
'button_search_x',
'alpha') ||
GETPOST(
'button_search.x',
'alpha') ||
GETPOST(
'button_search',
'alpha')) {
198 $objectclass =
'Entrepot';
199 $objectlabel =
'Warehouse';
200 $uploaddir =
$conf->stock->dir_output;
201 include DOL_DOCUMENT_ROOT.
'/core/actions_massactions.inc.php';
209$form =
new Form($db);
213$totalarray = array();
215$title = $langs->trans(
"Warehouses");
216$help_url =
'EN:Module_Stocks_En|FR:Module_Stock|ES:Módulo_Stocks';
222$sql .=
$object->getFieldList(
't');
224if (!empty($extrafields->attributes[
$object->table_element][
'label'])) {
225 foreach ($extrafields->attributes[
$object->table_element][
'label'] as $key => $val) {
226 $sql .= ($extrafields->attributes[
$object->table_element][
'type'][$key] !=
'separate' ?
", ef.".$key.
" as options_".$key :
'');
231$separatedPMP =
false;
233 $separatedPMP =
true;
234 $sql .=
", SUM(pa.pmp * ps.reel) as estimatedvalue, SUM(p.price * ps.reel) as sellvalue, SUM(ps.reel) as stockqty";
236 $sql .=
", SUM(p.pmp * ps.reel) as estimatedvalue, SUM(p.price * ps.reel) as sellvalue, SUM(ps.reel) as stockqty";
241$parameters = array();
242$reshook = $hookmanager->executeHooks(
'printFieldListSelect', $parameters, $object);
243$sql .= $hookmanager->resPrint;
244$sql = preg_replace(
'/,\s*$/',
'', $sql);
248$sql .=
" FROM ".MAIN_DB_PREFIX.$object->table_element.
" as t";
249if (!empty($extrafields->attributes[
$object->table_element][
'label']) && is_array($extrafields->attributes[
$object->table_element][
'label']) && count($extrafields->attributes[
$object->table_element][
'label'])) {
250 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element.
"_extrafields as ef on (t.rowid = ef.fk_object)";
252$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"product_stock as ps ON t.rowid = ps.fk_entrepot";
253$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"product as p ON ps.fk_product = p.rowid";
254$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_departements as c_dep ON c_dep.rowid = t.fk_departement";
255$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_country as ccount ON ccount.rowid = t.fk_pays";
257 $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;
259$sql .=
" WHERE t.entity IN (".getEntity(
'stock').
")";
260foreach ($search as $key => $val) {
262 if ($class_key ==
'status') {
263 $class_key =
'statut';
265 if (array_key_exists($class_key,
$object->fields)) {
266 if (($key ==
'status' && $search[$key] == -1) || $key ==
'entity') {
270 if ((strpos(
$object->fields[$class_key][
'type'],
'integer:') === 0) || (strpos(
$object->fields[$class_key][
'type'],
'sellist:') === 0) || !empty(
$object->fields[$class_key][
'arrayofkeyval'])) {
271 if ($search[$key] ==
'-1' || ($search[$key] ===
'0' && (empty(
$object->fields[$class_key][
'arrayofkeyval']) || !array_key_exists(
'0',
$object->fields[$class_key][
'arrayofkeyval'])))) {
276 if ($search[$key] !=
'') {
277 $sql .=
natural_search((($key ==
"ref") ?
"t.ref" :
"t.".$class_key), $search[$key], (($key ==
'status') ? 2 : $mode_search));
280 if (preg_match(
'/(_dtstart|_dtend)$/', $key) && $search[$key] !=
'') {
281 $columnName = preg_replace(
'/(_dtstart|_dtend)$/',
'', $key);
282 if (preg_match(
'/^(date|timestamp|datetime)/',
$object->fields[$columnName][
'type'])) {
283 if (preg_match(
'/_dtstart$/', $key)) {
284 $sql .=
" AND t.".$db->escape($columnName).
" >= '".$db->idate($search[$key]).
"'";
286 if (preg_match(
'/_dtend$/', $key)) {
287 $sql .=
" AND t.".$db->escape($columnName).
" <= '".$db->idate($search[$key]).
"'";
294 $sql .=
natural_search(array_keys($fieldstosearchall), $search_all);
297$searchCategoryWarehouseList = $search_category_list;
298$searchCategoryWarehouseOperator = 0;
299if (!empty($searchCategoryWarehouseList)) {
300 $searchCategoryWarehouseSqlList = array();
301 $listofcategoryid =
'';
302 foreach ($searchCategoryWarehouseList as $searchCategoryWarehouse) {
303 if (intval($searchCategoryWarehouse) == -2) {
304 $searchCategoryWarehouseSqlList[] =
" NOT EXISTS (SELECT ck.fk_warehouse FROM ".MAIN_DB_PREFIX.
"categorie_warehouse as ck WHERE t.rowid = ck.fk_warehouse)";
305 } elseif (intval($searchCategoryWarehouse) > 0) {
306 if ($searchCategoryWarehouseOperator == 0) {
307 $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).
")";
309 $listofcategoryid .= ($listofcategoryid ?
', ' :
'') .((
int) $searchCategoryWarehouse);
313 if ($listofcategoryid) {
314 $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).
"))";
316 if ($searchCategoryWarehouseOperator == 1) {
317 if (!empty($searchCategoryWarehouseSqlList)) {
318 $sql .=
" AND (".implode(
' OR ', $searchCategoryWarehouseSqlList).
")";
321 if (!empty($searchCategoryWarehouseSqlList)) {
322 $sql .=
" AND (".implode(
' AND ', $searchCategoryWarehouseSqlList).
")";
328include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_sql.tpl.php';
330$parameters = array();
331$reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters, $object, $action);
332$sql .= $hookmanager->resPrint;
335foreach (
$object->fields as $key => $val) {
336 $sql .=
"t.".$db->escape($key).
", ";
339if (!empty($extrafields->attributes[
$object->table_element][
'label'])) {
340 foreach ($extrafields->attributes[
$object->table_element][
'label'] as $key => $val) {
341 $sql .= ($extrafields->attributes[
$object->table_element][
'type'][$key] !=
'separate' ?
"ef.".$key.
', ' :
'');
345$parameters = array();
346$reshook = $hookmanager->executeHooks(
'printFieldListGroupBy', $parameters);
347$sql .= $hookmanager->resPrint;
348$sql = preg_replace(
'/,\s*$/',
'', $sql);
351$result = $db->query($sql);
353 $totalnboflines = $db->num_rows($result);
355 $line = $total = $totalsell = $totalStock = 0;
356 while ($line < $totalnboflines) {
357 $objp = $db->fetch_object($result);
358 $total += $objp->estimatedvalue;
359 $totalsell += $objp->sellvalue;
360 $totalStock += $objp->stockqty;
363 $totalarray[
'val'][
'stockqty'] =
price2num($totalStock,
'MS');
364 $totalarray[
'val'][
'estimatedvalue'] =
price2num($total,
'MT');
365 $totalarray[
'val'][
'estimatedstockvaluesell'] =
price2num($totalsell,
'MT');
369$nbtotalofrecords =
'';
372 $sqlforcount = preg_replace(
'/^'.preg_quote($sqlfields,
'/').
'/',
'SELECT COUNT(*) as nbtotalofrecords', $sql);
373 $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);
374 $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);
375 $sqlforcount = preg_replace(
'/GROUP BY .*$/',
'', $sqlforcount);
377 $resql = $db->query($sqlforcount);
379 $objforcount = $db->fetch_object($resql);
380 $nbtotalofrecords = $objforcount->nbtotalofrecords;
385 if (($page * $limit) > $nbtotalofrecords) {
393$sql .= $db->order($sortfield, $sortorder);
395 $sql .= $db->plimit($limit + 1, $offset);
398$resql = $db->query($sql);
404$num = $db->num_rows($resql);
407if ($num == 1 &&
getDolGlobalInt(
'MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE') && $search_all && !$page) {
408 $obj = $db->fetch_object($resql);
410 header(
"Location: ".DOL_URL_ROOT.
'/product/stock/card.php?id='.
$id);
418llxHeader(
'', $title, $help_url,
'', 0, 0,
'',
'',
'',
'bodyforlist mod-product page-stock_list');
420$arrayofselected = is_array($toselect) ? $toselect : array();
424 $param .=
'&mode='.urlencode($mode);
426if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
427 $param .=
'&contextpage='.urlencode($contextpage);
429if ($limit > 0 && $limit !=
$conf->liste_limit) {
430 $param .=
'&limit='.((int) $limit);
432if ($optioncss !=
'') {
433 $param .=
'&optioncss='.urlencode($optioncss);
435foreach ($search as $key => $val) {
436 if (is_array($search[$key])) {
437 foreach ($search[$key] as $skey) {
439 $param .=
'&search_'.$key.
'[]='.urlencode($skey);
442 } elseif (preg_match(
'/(_dtstart|_dtend)$/', $key) && !empty($val)) {
443 $param .=
'&search_'.$key.
'month='.(
GETPOSTINT(
'search_'.$key.
'month'));
444 $param .=
'&search_'.$key.
'day='.(
GETPOSTINT(
'search_'.$key.
'day'));
445 $param .=
'&search_'.$key.
'year='.(
GETPOSTINT(
'search_'.$key.
'year'));
446 } elseif ($search[$key] !=
'') {
447 $param .=
'&search_'.$key.
'='.urlencode($search[$key]);
451include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_param.tpl.php';
453$parameters = array(
'param' => &$param);
454$reshook = $hookmanager->executeHooks(
'printFieldListSearchParam', $parameters, $object, $action);
455$param .= $hookmanager->resPrint;
458$arrayofmassactions = array(
463if (
GETPOSTINT(
'nomassaction') || in_array($massaction, array(
'presend',
'predelete',
'preaffecttag'))) {
464 $arrayofmassactions = array();
466if (isModEnabled(
'category') && $user->hasRight(
'stock',
'creer')) {
467 $arrayofmassactions[
'preaffecttag'] =
img_picto(
'',
'label',
'class="pictofixedwidth"').$langs->trans(
"AffectTag");
469$massactionbutton = $form->selectMassAction(
'', $arrayofmassactions);
471print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" id="searchFormList" method="POST" name="formulaire">';
472if ($optioncss !=
'') {
473 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
475print
'<input type="hidden" name="token" value="'.newToken().
'">';
476print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
477print
'<input type="hidden" name="action" value="list">';
478print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
479print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
480print
'<input type="hidden" name="page" value="'.$page.
'">';
481print
'<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
482print
'<input type="hidden" name="page_y" value="">';
483print
'<input type="hidden" name="mode" value="'.$mode.
'">';
487$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'));
488$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'));
490$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'));
492print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'stock', 0, $newcardbutton,
'', $limit, 0, 0, 1);
495$topicmail =
"Information";
496$modelmail =
"warehouse";
498$trackid =
'ware'.$object->id;
499include DOL_DOCUMENT_ROOT.
'/core/tpl/massactions_pre.tpl.php';
504 foreach ($fieldstosearchall as $key => $val) {
505 $fieldstosearchall[$key] = $langs->trans($val);
506 $setupstring .= $key.
"=".$val.
";";
508 print
'<!-- Search done like if STOCK_QUICKSEARCH_ON_FIELDS = '.$setupstring.
' -->'.
"\n";
509 print
'<div class="divsearchfieldfilter">'.$langs->trans(
"FilterOnInto", $sall).implode(
', ', $fieldstosearchall).
'</div>';
514if (isModEnabled(
'category') && $user->hasRight(
'categorie',
'lire')) {
516 $moreforfilter .= $formcategory->getFilterBox(Categorie::TYPE_WAREHOUSE, $search_category_list);
523$parameters = array();
524$reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters, $object, $action);
525if (empty($reshook)) {
526 $moreforfilter .= $hookmanager->resPrint;
528 $moreforfilter = $hookmanager->resPrint;
531if (!empty($moreforfilter)) {
532 print
'<div class="liste_titre liste_titre_bydiv centpercent">';
533 print $moreforfilter;
537$varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
538$htmlofselectarray = $form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage,
getDolGlobalString(
'MAIN_CHECKBOX_LEFT_COLUMN'));
539$selectedfields = ($mode !=
'kanban' ? $htmlofselectarray :
'');
540$selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons(
'checkforselect', 1) :
'');
542print
'<div class="div-table-responsive">';
543print
'<table class="tagtable nobottomiftotal liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'">'.
"\n";
547print
'<tr class="liste_titre_filter">';
550 print
'<td class="liste_titre center maxwidthsearch">';
551 $searchpicto = $form->showFilterButtons(
'left');
555foreach (
$object->fields as $key => $val) {
556 if ($key ==
'statut') {
559 $searchkey = empty($search[$key]) ?
'' : $search[$key];
560 $cssforfield = (empty($val[
'csslist']) ? (empty($val[
'css']) ?
'' : $val[
'css']) : $val[
'csslist']);
561 if ($key ==
'status') {
562 $cssforfield .= ($cssforfield ?
' ' :
'').
'center';
563 } elseif (in_array($val[
'type'], array(
'date',
'datetime',
'timestamp'))) {
564 $cssforfield .= ($cssforfield ?
' ' :
'').
'center';
565 } elseif (in_array($val[
'type'], array(
'timestamp'))) {
566 $cssforfield .= ($cssforfield ?
' ' :
'').
'nowrap';
567 } 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'])) {
568 $cssforfield .= ($cssforfield ?
' ' :
'').
'right';
570 if (!empty($arrayfields[
't.'.$key][
'checked'])) {
571 print
'<td class="liste_titre'.($cssforfield ?
' '.$cssforfield :
'').($key ==
'status' ?
' parentonrightofpage' :
'').
'">';
572 if (!empty($val[
'arrayofkeyval']) && is_array($val[
'arrayofkeyval'])) {
573 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);
574 } elseif ((strpos($val[
'type'],
'integer:') === 0) || (strpos($val[
'type'],
'sellist:') === 0)) {
575 print
$object->showInputField($val, $key, (isset($search[$key]) ? $search[$key] :
''),
'',
'',
'search_', $cssforfield.
' maxwidth250', 1);
576 } elseif (preg_match(
'/^(date|timestamp|datetime)/', $val[
'type'])) {
577 print
'<div class="nowrap">';
578 print $form->selectDate(isset($search[$key.
'_dtstart']) ? $search[$key.
'_dtstart'] :
'',
"search_".$key.
"_dtstart", 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'From'));
580 print
'<div class="nowrap">';
581 print $form->selectDate(isset($search[$key.
'_dtend']) ? $search[$key.
'_dtend'] :
'',
"search_".$key.
"_dtend", 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'to'));
583 } elseif ($key ==
'lang') {
584 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formadmin.class.php';
586 print $formadmin->select_language($search[$key],
'search_lang', 0,
null, 1, 0, 0,
'minwidth100imp maxwidth125', 2);
588 print
'<input type="text" class="flat maxwidth'.($val[
'type'] ==
'integer' ?
'50' :
'75').
'" name="search_'.$key.
'" value="'.
dol_escape_htmltag(isset($search[$key]) ? $search[$key] :
'').
'">';
594if (!empty($arrayfields[
"stockqty"][
'checked'])) {
595 print
'<td class="liste_titre"></td>';
598if (!empty($arrayfields[
"estimatedvalue"][
'checked'])) {
599 print
'<td class="liste_titre"></td>';
602if (!empty($arrayfields[
"estimatedstockvaluesell"][
'checked'])) {
603 print
'<td class="liste_titre"></td>';
607include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_input.tpl.php';
610$parameters = array(
'arrayfields' => $arrayfields);
611$reshook = $hookmanager->executeHooks(
'printFieldListOption', $parameters, $object, $action);
612print $hookmanager->resPrint;
615if (!empty($arrayfields[
't.statut'][
'checked'])) {
616 print
'<td class="liste_titre center parentonrightofpage">';
617 print $form->selectarray(
'search_status', $warehouse->labelStatus, $search_status, 1, 0, 0,
'', 1, 0, 0,
'',
'search_status width100 onrightofpage');
623 print
'<td class="liste_titre center maxwidthsearch">';
624 $searchpicto = $form->showFilterButtons();
630$totalarray[
'nbfield'] = 0;
634print
'<tr class="liste_titre">';
637 print
getTitleFieldOfList($selectedfields, 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ').
"\n";
638 $totalarray[
'nbfield']++;
640foreach (
$object->fields as $key => $val) {
641 if ($key ==
'statut') {
644 $cssforfield = (empty($val[
'csslist']) ? (empty($val[
'css']) ?
'' : $val[
'css']) : $val[
'csslist']);
645 if ($key ==
'status') {
646 $cssforfield .= ($cssforfield ?
' ' :
'').
'center';
647 } elseif (in_array($val[
'type'], array(
'date',
'datetime',
'timestamp'))) {
648 $cssforfield .= ($cssforfield ?
' ' :
'').
'center';
649 } elseif (in_array($val[
'type'], array(
'timestamp'))) {
650 $cssforfield .= ($cssforfield ?
' ' :
'').
'nowrap';
651 } 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'])) {
652 $cssforfield .= ($cssforfield ?
' ' :
'').
'right';
654 $cssforfield = preg_replace(
'/small\s*/',
'', $cssforfield);
655 if (!empty($arrayfields[
't.'.$key][
'checked'])) {
656 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";
657 $totalarray[
'nbfield']++;
661if (!empty($arrayfields[
"stockqty"][
'checked'])) {
662 print_liste_field_titre(
"PhysicalStock", $_SERVER[
"PHP_SELF"],
"stockqty",
'', $param,
'', $sortfield, $sortorder,
'right ');
663 $totalarray[
'nbfield']++;
664 $totalarray[
'type'][$totalarray[
'nbfield']] =
'stock';
667if (!empty($arrayfields[
"estimatedvalue"][
'checked'])) {
668 print_liste_field_titre(
"EstimatedStockValue", $_SERVER[
"PHP_SELF"],
"estimatedvalue",
'', $param,
'', $sortfield, $sortorder,
'right ');
669 $totalarray[
'nbfield']++;
670 $totalarray[
'type'][$totalarray[
'nbfield']] =
'price';
673if (!empty($arrayfields[
"estimatedstockvaluesell"][
'checked'])) {
674 print_liste_field_titre(
"EstimatedStockValueSell", $_SERVER[
"PHP_SELF"],
"",
'', $param,
'', $sortfield, $sortorder,
'right ');
675 $totalarray[
'nbfield']++;
676 $totalarray[
'type'][$totalarray[
'nbfield']] =
'price';
680include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_title.tpl.php';
683$parameters = array(
'arrayfields' => $arrayfields,
'param' => $param,
'sortfield' => $sortfield,
'sortorder' => $sortorder);
684$reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters, $object);
685print $hookmanager->resPrint;
687if (!empty($arrayfields[
't.statut'][
'checked'])) {
688 print_liste_field_titre($arrayfields[
't.statut'][
'label'], $_SERVER[
"PHP_SELF"],
"t.statut",
'', $param,
'', $sortfield, $sortorder,
'center ');
689 $totalarray[
'nbfield']++;
694 print
getTitleFieldOfList($selectedfields, 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ').
"\n";
695 $totalarray[
'nbfield']++;
704$savnbfield = $totalarray[
'nbfield'];
705$totalarray[
'nbfield'] = 0;
706$imaxinloop = ($limit ? min($num, $limit) : $num);
707while ($i < $imaxinloop) {
708 $obj = $db->fetch_object($resql);
714 $warehouse->setVarsFromFetchObj($obj);
716 $warehouse->label = $warehouse->ref;
717 $warehouse->sellvalue = $obj->sellvalue;
721 if ($mode ==
'kanban') {
723 print
'<tr class="trkanban"><td colspan="'.$savnbfield.
'">';
724 print
'<div class="box-flex-container kanban">';
728 if ($massactionbutton || $massaction) {
730 if (in_array(
$object->id, $arrayofselected)) {
734 print
$object->getKanbanView(
'', array(
'selected' => $selected));
735 if ($i == ($imaxinloop - 1)) {
742 print
'<tr data-rowid="'.$object->id.
'" class="oddeven">';
746 print
'<td class="nowrap center">';
747 if ($massactionbutton || $massaction) {
749 if (in_array(
$object->id, $arrayofselected)) {
752 print
'<input id="cb'.$object->id.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.
$object->id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
756 $totalarray[
'nbfield']++;
759 foreach (
$object->fields as $key => $val) {
760 if ($key ==
'statut') {
763 $cssforfield = (empty($val[
'csslist']) ? (empty($val[
'css']) ?
'' : $val[
'css']) : $val[
'csslist']);
764 if (in_array($val[
'type'], array(
'date',
'datetime',
'timestamp'))) {
765 $cssforfield .= ($cssforfield ?
' ' :
'').
'center';
766 } elseif ($key ==
'status') {
767 $cssforfield .= ($cssforfield ?
' ' :
'').
'center';
770 if (in_array($val[
'type'], array(
'timestamp'))) {
771 $cssforfield .= ($cssforfield ?
' ' :
'').
'nowraponall';
772 } elseif ($key ==
'ref') {
773 $cssforfield .= ($cssforfield ?
' ' :
'').
'nowraponall';
776 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'])) {
777 $cssforfield .= ($cssforfield ?
' ' :
'').
'right';
779 if (in_array($key, array(
'fk_soc',
'fk_user',
'fk_warehouse'))) {
780 $cssforfield =
'tdoverflowmax100';
783 if (!empty($arrayfields[
't.'.$key][
'checked'])) {
784 print
'<td'.($cssforfield ?
' class="'.$cssforfield.(preg_match(
'/tdoverflow/', $cssforfield) ?
' classfortooltip' :
'').
'"' :
'');
785 if (preg_match(
'/tdoverflow/', $cssforfield) && !is_numeric(
$object->$key)) {
786 print
' title="'.dol_escape_htmltag(
$object->$key).
'"';
789 if ($key ==
'statut') {
790 print
$object->getLibStatut(5);
792 if ($key ==
'phone') {
794 } elseif ($key ==
'fax') {
797 print $warehouse->showOutputField($val, $key,
$object->$key,
'');
801 $totalarray[
'nbfield']++;
803 if (!empty($val[
'isameasure']) && $val[
'isameasure'] == 1) {
805 $totalarray[
'pos'][$totalarray[
'nbfield']] =
't.'.$key;
807 if (!isset($totalarray[
'val'])) {
808 $totalarray[
'val'] = array();
810 if (!isset($totalarray[
'val'][
't.'.$key])) {
811 $totalarray[
'val'][
't.'.$key] = 0;
813 $totalarray[
'val'][
't.'.$key] +=
$object->$key;
819 if (!empty($arrayfields[
"stockqty"][
'checked'])) {
820 print
'<td class="right">'.price(
price2num($obj->stockqty,
'MS')).
'</td>';
822 $totalarray[
'nbfield']++;
825 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'stockqty';
830 if (!empty($arrayfields[
"estimatedvalue"][
'checked'])) {
831 print
'<td class="right">';
832 if (
price2num($obj->estimatedvalue,
'MT')) {
833 print
'<span class="amount">'.price(
price2num($obj->estimatedvalue,
'MT'), 1).
'</span>';
839 $totalarray[
'nbfield']++;
842 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'estimatedvalue';
847 if (!empty($arrayfields[
"estimatedstockvaluesell"][
'checked'])) {
848 print
'<td class="right">';
850 if ($obj->sellvalue) {
851 print
'<span class="amount">'.price(
price2num($obj->sellvalue,
'MT'), 1).
'</span>';
854 $htmltext = $langs->trans(
"OptionMULTIPRICESIsOn");
855 print $form->textwithtooltip(
'<span class="opacitymedium">'.$langs->trans(
"Variable").
'</span>', $htmltext);
859 $totalarray[
'nbfield']++;
862 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'estimatedstockvaluesell';
867 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_print_fields.tpl.php';
869 $parameters = array(
'arrayfields' => $arrayfields,
'object' => $object,
'obj' => $obj,
'i' => $i,
'totalarray' => &$totalarray);
870 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object, $action);
871 print $hookmanager->resPrint;
874 if (!empty($arrayfields[
't.statut'][
'checked'])) {
875 print
'<td class="center">'.$warehouse->LibStatut($obj->statut, 5).
'</td>';
877 $totalarray[
'nbfield']++;
883 print
'<td class="nowrap center">';
884 if ($massactionbutton || $massaction) {
886 if (in_array(
$object->id, $arrayofselected)) {
889 print
'<input id="cb'.$object->id.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.
$object->id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
893 $totalarray[
'nbfield']++;
903if ($totalnboflines - $offset <= $limit) {
905 include DOL_DOCUMENT_ROOT.
'/core/tpl/list_print_total.tpl.php';
911 foreach ($arrayfields as $key => $val) {
912 if (!empty($val[
'checked'])) {
916 print
'<tr><td colspan="'.$colspan.
'" class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</td></tr>';
921$parameters = array(
'arrayfields' => $arrayfields,
'sql' => $sql);
922$reshook = $hookmanager->executeHooks(
'printFieldListFooter', $parameters, $object);
923print $hookmanager->resPrint;
925print
'</table>'.
"\n";
930if (in_array(
'builddoc', array_keys($arrayofmassactions)) && ($nbtotalofrecords ===
'' || $nbtotalofrecords)) {
931 $hidegeneratedfilelistifempty = 1;
932 if ($massaction ==
'builddoc' || $action ==
'remove_file' || $show_files) {
933 $hidegeneratedfilelistifempty = 0;
936 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
940 $urlsource = $_SERVER[
'PHP_SELF'].
'?sortfield='.$sortfield.
'&sortorder='.$sortorder;
941 $urlsource .= str_replace(
'&',
'&', $param);
943 $filedir = $diroutputmassaction;
944 $genallowed = $user->hasRight(
'stock',
'lire');
945 $delallowed = $user->hasRight(
'stock',
'creer');
947 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
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Class to manage warehouses.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
print_barre_liste($title, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='generic', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $selectlimitsuffix=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
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.
dol_print_phone($phone, $countrycode='', $cid=0, $socid=0, $addlink='', $separ=" ", $withpicto='', $titlealt='', $adddivfloat=0, $morecss='paddingright')
Format phone numbers according to country.
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.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
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 a 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...
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
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.