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'] =
'';
187 $search_array_options = array();
188 $search_category_list = array();
190 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')
191 ||
GETPOST(
'button_search_x',
'alpha') ||
GETPOST(
'button_search.x',
'alpha') ||
GETPOST(
'button_search',
'alpha')) {
196 $objectclass =
'Entrepot';
197 $objectlabel =
'Warehouse';
198 $uploaddir =
$conf->stock->dir_output;
199 include DOL_DOCUMENT_ROOT.
'/core/actions_massactions.inc.php';
207$form =
new Form($db);
212$title = $langs->trans(
"Warehouses");
213$help_url =
'EN:Module_Stocks_En|FR:Module_Stock|ES:Módulo_Stocks';
219$sql .=
$object->getFieldList(
't');
221if (!empty($extrafields->attributes[
$object->table_element][
'label'])) {
222 foreach ($extrafields->attributes[
$object->table_element][
'label'] as $key => $val) {
223 $sql .= ($extrafields->attributes[
$object->table_element][
'type'][$key] !=
'separate' ?
", ef.".$key.
" as options_".$key :
'');
228$separatedPMP =
false;
230 $separatedPMP =
true;
231 $sql .=
", SUM(pa.pmp * ps.reel) as estimatedvalue, SUM(p.price * ps.reel) as sellvalue, SUM(ps.reel) as stockqty";
233 $sql .=
", SUM(p.pmp * ps.reel) as estimatedvalue, SUM(p.price * ps.reel) as sellvalue, SUM(ps.reel) as stockqty";
238$parameters = array();
239$reshook = $hookmanager->executeHooks(
'printFieldListSelect', $parameters, $object);
240$sql .= $hookmanager->resPrint;
241$sql = preg_replace(
'/,\s*$/',
'', $sql);
245$sql .=
" FROM ".MAIN_DB_PREFIX.$object->table_element.
" as t";
246if (!empty($extrafields->attributes[
$object->table_element][
'label']) && is_array($extrafields->attributes[
$object->table_element][
'label']) && count($extrafields->attributes[
$object->table_element][
'label'])) {
247 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element.
"_extrafields as ef on (t.rowid = ef.fk_object)";
249$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"product_stock as ps ON t.rowid = ps.fk_entrepot";
250$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"product as p ON ps.fk_product = p.rowid";
251$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_departements as c_dep ON c_dep.rowid = t.fk_departement";
252$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_country as ccount ON ccount.rowid = t.fk_pays";
254 $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;
256$sql .=
" WHERE t.entity IN (".getEntity(
'stock').
")";
257foreach ($search as $key => $val) {
258 if (array_key_exists($key,
$object->fields)||$key ==
'status') {
260 if ($class_key ==
'status') {
261 $class_key =
'statut';
263 if (($key ==
'status' && $search[$key] == -1) || $key ==
'entity') {
267 if ((strpos(
$object->fields[$key][
'type'],
'integer:') === 0) || (strpos(
$object->fields[$key][
'type'],
'sellist:') === 0) || !empty(
$object->fields[$key][
'arrayofkeyval'])) {
268 if ($search[$key] ==
'-1' || ($search[$key] ===
'0' && (empty(
$object->fields[$key][
'arrayofkeyval']) || !array_key_exists(
'0',
$object->fields[$key][
'arrayofkeyval'])))) {
273 if ($search[$key] !=
'') {
274 $sql .=
natural_search((($key ==
"ref") ?
"t.ref" :
"t.".$class_key), $search[$key], (($key ==
'status') ? 2 : $mode_search));
277 if (preg_match(
'/(_dtstart|_dtend)$/', $key) && $search[$key] !=
'') {
278 $columnName = preg_replace(
'/(_dtstart|_dtend)$/',
'', $key);
279 if (preg_match(
'/^(date|timestamp|datetime)/',
$object->fields[$columnName][
'type'])) {
280 if (preg_match(
'/_dtstart$/', $key)) {
281 $sql .=
" AND t.".$db->escape($columnName).
" >= '".$db->idate($search[$key]).
"'";
283 if (preg_match(
'/_dtend$/', $key)) {
284 $sql .=
" AND t.".$db->escape($columnName).
" <= '".$db->idate($search[$key]).
"'";
291 $sql .=
natural_search(array_keys($fieldstosearchall), $search_all);
294$searchCategoryWarehouseList = $search_category_list;
295$searchCategoryWarehouseOperator = 0;
296if (!empty($searchCategoryWarehouseList)) {
297 $searchCategoryWarehouseSqlList = array();
298 $listofcategoryid =
'';
299 foreach ($searchCategoryWarehouseList as $searchCategoryWarehouse) {
300 if (intval($searchCategoryWarehouse) == -2) {
301 $searchCategoryWarehouseSqlList[] =
" NOT EXISTS (SELECT ck.fk_warehouse FROM ".MAIN_DB_PREFIX.
"categorie_warehouse as ck WHERE t.rowid = ck.fk_warehouse)";
302 } elseif (intval($searchCategoryWarehouse) > 0) {
303 if ($searchCategoryWarehouseOperator == 0) {
304 $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).
")";
306 $listofcategoryid .= ($listofcategoryid ?
', ' :
'') .((
int) $searchCategoryWarehouse);
310 if ($listofcategoryid) {
311 $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).
"))";
313 if ($searchCategoryWarehouseOperator == 1) {
314 if (!empty($searchCategoryWarehouseSqlList)) {
315 $sql .=
" AND (".implode(
' OR ', $searchCategoryWarehouseSqlList).
")";
318 if (!empty($searchCategoryWarehouseSqlList)) {
319 $sql .=
" AND (".implode(
' AND ', $searchCategoryWarehouseSqlList).
")";
325include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_sql.tpl.php';
327$parameters = array();
328$reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters, $object, $action);
329$sql .= $hookmanager->resPrint;
332foreach (
$object->fields as $key => $val) {
333 $sql .=
"t.".$db->escape($key).
", ";
336if (!empty($extrafields->attributes[
$object->table_element][
'label'])) {
337 foreach ($extrafields->attributes[
$object->table_element][
'label'] as $key => $val) {
338 $sql .= ($extrafields->attributes[
$object->table_element][
'type'][$key] !=
'separate' ?
"ef.".$key.
', ' :
'');
342$parameters = array();
343$reshook = $hookmanager->executeHooks(
'printFieldListGroupBy', $parameters);
344$sql .= $hookmanager->resPrint;
345$sql = preg_replace(
'/,\s*$/',
'', $sql);
348$result = $db->query($sql);
350 $totalnboflines = $db->num_rows($result);
352 $line = $total = $totalsell = $totalStock = 0;
353 while ($line < $totalnboflines) {
354 $objp = $db->fetch_object($result);
355 $total += $objp->estimatedvalue;
356 $totalsell += $objp->sellvalue;
357 $totalStock += $objp->stockqty;
360 $totalarray[
'val'][
'stockqty'] =
price2num($totalStock,
'MS');
361 $totalarray[
'val'][
'estimatedvalue'] =
price2num($total,
'MT');
362 $totalarray[
'val'][
'estimatedstockvaluesell'] =
price2num($totalsell,
'MT');
366$nbtotalofrecords =
'';
369 $sqlforcount = preg_replace(
'/^'.preg_quote($sqlfields,
'/').
'/',
'SELECT COUNT(*) as nbtotalofrecords', $sql);
370 $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);
371 $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);
372 $sqlforcount = preg_replace(
'/GROUP BY .*$/',
'', $sqlforcount);
374 $resql = $db->query($sqlforcount);
376 $objforcount = $db->fetch_object($resql);
377 $nbtotalofrecords = $objforcount->nbtotalofrecords;
382 if (($page * $limit) > $nbtotalofrecords) {
390$sql .= $db->order($sortfield, $sortorder);
392 $sql .= $db->plimit($limit + 1, $offset);
395$resql = $db->query($sql);
401$num = $db->num_rows($resql);
404if ($num == 1 &&
getDolGlobalInt(
'MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE') && $search_all && !$page) {
405 $obj = $db->fetch_object($resql);
407 header(
"Location: ".DOL_URL_ROOT.
'/product/stock/card.php?id='.
$id);
415llxHeader(
'', $title, $help_url,
'', 0, 0,
'',
'',
'',
'bodyforlist mod-product page-stock_list');
417$arrayofselected = is_array($toselect) ? $toselect : array();
421 $param .=
'&mode='.urlencode($mode);
423if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
424 $param .=
'&contextpage='.urlencode($contextpage);
426if ($limit > 0 && $limit !=
$conf->liste_limit) {
427 $param .=
'&limit='.((int) $limit);
429if ($optioncss !=
'') {
430 $param .=
'&optioncss='.urlencode($optioncss);
432foreach ($search as $key => $val) {
433 if (is_array($search[$key])) {
434 foreach ($search[$key] as $skey) {
436 $param .=
'&search_'.$key.
'[]='.urlencode($skey);
439 } elseif (preg_match(
'/(_dtstart|_dtend)$/', $key) && !empty($val)) {
440 $param .=
'&search_'.$key.
'month='.(
GETPOSTINT(
'search_'.$key.
'month'));
441 $param .=
'&search_'.$key.
'day='.(
GETPOSTINT(
'search_'.$key.
'day'));
442 $param .=
'&search_'.$key.
'year='.(
GETPOSTINT(
'search_'.$key.
'year'));
443 } elseif ($search[$key] !=
'') {
444 $param .=
'&search_'.$key.
'='.urlencode($search[$key]);
448include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_param.tpl.php';
450$parameters = array(
'param' => &$param);
451$reshook = $hookmanager->executeHooks(
'printFieldListSearchParam', $parameters, $object, $action);
452$param .= $hookmanager->resPrint;
455$arrayofmassactions = array(
460if (
GETPOSTINT(
'nomassaction') || in_array($massaction, array(
'presend',
'predelete',
'preaffecttag'))) {
461 $arrayofmassactions = array();
463if (isModEnabled(
'category') && $user->hasRight(
'stock',
'creer')) {
464 $arrayofmassactions[
'preaffecttag'] =
img_picto(
'',
'label',
'class="pictofixedwidth"').$langs->trans(
"AffectTag");
466$massactionbutton = $form->selectMassAction(
'', $arrayofmassactions);
468print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" id="searchFormList" method="POST" name="formulaire">';
469if ($optioncss !=
'') {
470 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
472print
'<input type="hidden" name="token" value="'.newToken().
'">';
473print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
474print
'<input type="hidden" name="action" value="list">';
475print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
476print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
477print
'<input type="hidden" name="page" value="'.$page.
'">';
478print
'<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
479print
'<input type="hidden" name="page_y" value="">';
480print
'<input type="hidden" name="mode" value="'.$mode.
'">';
484$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'));
485$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'));
487$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'));
489print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'stock', 0, $newcardbutton,
'', $limit, 0, 0, 1);
492$topicmail =
"Information";
493$modelmail =
"warehouse";
495$trackid =
'ware'.$object->id;
496include DOL_DOCUMENT_ROOT.
'/core/tpl/massactions_pre.tpl.php';
501 foreach ($fieldstosearchall as $key => $val) {
502 $fieldstosearchall[$key] = $langs->trans($val);
503 $setupstring .= $key.
"=".$val.
";";
505 print
'<!-- Search done like if STOCK_QUICKSEARCH_ON_FIELDS = '.$setupstring.
' -->'.
"\n";
506 print
'<div class="divsearchfieldfilter">'.$langs->trans(
"FilterOnInto", $sall).implode(
', ', $fieldstosearchall).
'</div>';
511if (isModEnabled(
'category') && $user->hasRight(
'categorie',
'lire')) {
513 $moreforfilter .= $formcategory->getFilterBox(Categorie::TYPE_WAREHOUSE, $search_category_list);
520$parameters = array();
521$reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters, $object, $action);
522if (empty($reshook)) {
523 $moreforfilter .= $hookmanager->resPrint;
525 $moreforfilter = $hookmanager->resPrint;
528if (!empty($moreforfilter)) {
529 print
'<div class="liste_titre liste_titre_bydiv centpercent">';
530 print $moreforfilter;
534$varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
535$htmlofselectarray = $form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage,
getDolGlobalString(
'MAIN_CHECKBOX_LEFT_COLUMN'));
536$selectedfields = ($mode !=
'kanban' ? $htmlofselectarray :
'');
537$selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons(
'checkforselect', 1) :
'');
539print
'<div class="div-table-responsive">';
540print
'<table class="tagtable nobottomiftotal liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'">'.
"\n";
544print
'<tr class="liste_titre_filter">';
547 print
'<td class="liste_titre center maxwidthsearch">';
548 $searchpicto = $form->showFilterButtons(
'left');
552foreach (
$object->fields as $key => $val) {
553 if ($key ==
'statut') {
556 $searchkey = empty($search[$key]) ?
'' : $search[$key];
557 $cssforfield = (empty($val[
'csslist']) ? (empty($val[
'css']) ?
'' : $val[
'css']) : $val[
'csslist']);
558 if ($key ==
'status') {
559 $cssforfield .= ($cssforfield ?
' ' :
'').
'center';
560 } elseif (in_array($val[
'type'], array(
'date',
'datetime',
'timestamp'))) {
561 $cssforfield .= ($cssforfield ?
' ' :
'').
'center';
562 } elseif (in_array($val[
'type'], array(
'timestamp'))) {
563 $cssforfield .= ($cssforfield ?
' ' :
'').
'nowrap';
564 } 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'])) {
565 $cssforfield .= ($cssforfield ?
' ' :
'').
'right';
567 if (!empty($arrayfields[
't.'.$key][
'checked'])) {
568 print
'<td class="liste_titre'.($cssforfield ?
' '.$cssforfield :
'').($key ==
'status' ?
' parentonrightofpage' :
'').
'">';
569 if (!empty($val[
'arrayofkeyval']) && is_array($val[
'arrayofkeyval'])) {
570 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);
571 } elseif ((strpos($val[
'type'],
'integer:') === 0) || (strpos($val[
'type'],
'sellist:') === 0)) {
572 print
$object->showInputField($val, $key, (isset($search[$key]) ? $search[$key] :
''),
'',
'',
'search_', $cssforfield.
' maxwidth250', 1);
573 } elseif (preg_match(
'/^(date|timestamp|datetime)/', $val[
'type'])) {
574 print
'<div class="nowrap">';
575 print $form->selectDate(isset($search[$key.
'_dtstart']) ? $search[$key.
'_dtstart'] :
'',
"search_".$key.
"_dtstart", 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'From'));
577 print
'<div class="nowrap">';
578 print $form->selectDate(isset($search[$key.
'_dtend']) ? $search[$key.
'_dtend'] :
'',
"search_".$key.
"_dtend", 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'to'));
580 } elseif ($key ==
'lang') {
581 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formadmin.class.php';
583 print $formadmin->select_language($search[$key],
'search_lang', 0,
null, 1, 0, 0,
'minwidth100imp maxwidth125', 2);
585 print
'<input type="text" class="flat maxwidth'.($val[
'type'] ==
'integer' ?
'50' :
'75').
'" name="search_'.$key.
'" value="'.
dol_escape_htmltag(isset($search[$key]) ? $search[$key] :
'').
'">';
591if (!empty($arrayfields[
"stockqty"][
'checked'])) {
592 print
'<td class="liste_titre"></td>';
595if (!empty($arrayfields[
"estimatedvalue"][
'checked'])) {
596 print
'<td class="liste_titre"></td>';
599if (!empty($arrayfields[
"estimatedstockvaluesell"][
'checked'])) {
600 print
'<td class="liste_titre"></td>';
604include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_input.tpl.php';
607$parameters = array(
'arrayfields' => $arrayfields);
608$reshook = $hookmanager->executeHooks(
'printFieldListOption', $parameters, $object, $action);
609print $hookmanager->resPrint;
612if (!empty($arrayfields[
't.statut'][
'checked'])) {
613 print
'<td class="liste_titre center parentonrightofpage">';
614 print $form->selectarray(
'search_status', $warehouse->labelStatus, $search_status, 1, 0, 0,
'', 1, 0, 0,
'',
'search_status width100 onrightofpage');
620 print
'<td class="liste_titre center maxwidthsearch">';
621 $searchpicto = $form->showFilterButtons();
627$totalarray = array();
628$totalarray[
'nbfield'] = 0;
632print
'<tr class="liste_titre">';
635 print
getTitleFieldOfList($selectedfields, 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ').
"\n";
636 $totalarray[
'nbfield']++;
638foreach (
$object->fields as $key => $val) {
639 if ($key ==
'statut') {
642 $cssforfield = (empty($val[
'csslist']) ? (empty($val[
'css']) ?
'' : $val[
'css']) : $val[
'csslist']);
643 if ($key ==
'status') {
644 $cssforfield .= ($cssforfield ?
' ' :
'').
'center';
645 } elseif (in_array($val[
'type'], array(
'date',
'datetime',
'timestamp'))) {
646 $cssforfield .= ($cssforfield ?
' ' :
'').
'center';
647 } elseif (in_array($val[
'type'], array(
'timestamp'))) {
648 $cssforfield .= ($cssforfield ?
' ' :
'').
'nowrap';
649 } 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'])) {
650 $cssforfield .= ($cssforfield ?
' ' :
'').
'right';
652 $cssforfield = preg_replace(
'/small\s*/',
'', $cssforfield);
653 if (!empty($arrayfields[
't.'.$key][
'checked'])) {
654 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";
655 $totalarray[
'nbfield']++;
659if (!empty($arrayfields[
"stockqty"][
'checked'])) {
660 print_liste_field_titre(
"PhysicalStock", $_SERVER[
"PHP_SELF"],
"stockqty",
'', $param,
'', $sortfield, $sortorder,
'right ');
661 $totalarray[
'nbfield']++;
662 $totalarray[
'type'][$totalarray[
'nbfield']] =
'stock';
665if (!empty($arrayfields[
"estimatedvalue"][
'checked'])) {
666 print_liste_field_titre(
"EstimatedStockValue", $_SERVER[
"PHP_SELF"],
"estimatedvalue",
'', $param,
'', $sortfield, $sortorder,
'right ');
667 $totalarray[
'nbfield']++;
668 $totalarray[
'type'][$totalarray[
'nbfield']] =
'price';
671if (!empty($arrayfields[
"estimatedstockvaluesell"][
'checked'])) {
672 print_liste_field_titre(
"EstimatedStockValueSell", $_SERVER[
"PHP_SELF"],
"",
'', $param,
'', $sortfield, $sortorder,
'right ');
673 $totalarray[
'nbfield']++;
674 $totalarray[
'type'][$totalarray[
'nbfield']] =
'price';
678include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_title.tpl.php';
681$parameters = array(
'arrayfields' => $arrayfields,
'param' => $param,
'sortfield' => $sortfield,
'sortorder' => $sortorder);
682$reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters, $object);
683print $hookmanager->resPrint;
685if (!empty($arrayfields[
't.statut'][
'checked'])) {
686 print_liste_field_titre($arrayfields[
't.statut'][
'label'], $_SERVER[
"PHP_SELF"],
"t.statut",
'', $param,
'', $sortfield, $sortorder,
'center ');
687 $totalarray[
'nbfield']++;
692 print
getTitleFieldOfList($selectedfields, 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ').
"\n";
693 $totalarray[
'nbfield']++;
702$savnbfield = $totalarray[
'nbfield'];
703$totalarray[
'nbfield'] = 0;
704$imaxinloop = ($limit ? min($num, $limit) : $num);
705while ($i < $imaxinloop) {
706 $obj = $db->fetch_object($resql);
712 $warehouse->setVarsFromFetchObj($obj);
714 $warehouse->label = $warehouse->ref;
715 $warehouse->sellvalue = $obj->sellvalue;
719 if ($mode ==
'kanban') {
721 print
'<tr class="trkanban"><td colspan="'.$savnbfield.
'">';
722 print
'<div class="box-flex-container kanban">';
726 if ($massactionbutton || $massaction) {
728 if (in_array(
$object->id, $arrayofselected)) {
732 print
$object->getKanbanView(
'', array(
'selected' => $selected));
733 if ($i == ($imaxinloop - 1)) {
740 print
'<tr data-rowid="'.$object->id.
'" class="oddeven">';
744 print
'<td class="nowrap center">';
745 if ($massactionbutton || $massaction) {
747 if (in_array(
$object->id, $arrayofselected)) {
750 print
'<input id="cb'.$object->id.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.
$object->id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
754 $totalarray[
'nbfield']++;
757 foreach (
$object->fields as $key => $val) {
758 if ($key ==
'statut') {
761 $cssforfield = (empty($val[
'csslist']) ? (empty($val[
'css']) ?
'' : $val[
'css']) : $val[
'csslist']);
762 if (in_array($val[
'type'], array(
'date',
'datetime',
'timestamp'))) {
763 $cssforfield .= ($cssforfield ?
' ' :
'').
'center';
764 } elseif ($key ==
'status') {
765 $cssforfield .= ($cssforfield ?
' ' :
'').
'center';
768 if (in_array($val[
'type'], array(
'timestamp'))) {
769 $cssforfield .= ($cssforfield ?
' ' :
'').
'nowraponall';
770 } elseif ($key ==
'ref') {
771 $cssforfield .= ($cssforfield ?
' ' :
'').
'nowraponall';
774 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'])) {
775 $cssforfield .= ($cssforfield ?
' ' :
'').
'right';
777 if (in_array($key, array(
'fk_soc',
'fk_user',
'fk_warehouse'))) {
778 $cssforfield =
'tdoverflowmax100';
781 if (!empty($arrayfields[
't.'.$key][
'checked'])) {
782 print
'<td'.($cssforfield ?
' class="'.$cssforfield.(preg_match(
'/tdoverflow/', $cssforfield) ?
' classfortooltip' :
'').
'"' :
'');
783 if (preg_match(
'/tdoverflow/', $cssforfield) && !is_numeric(
$object->$key)) {
784 print
' title="'.dol_escape_htmltag(
$object->$key).
'"';
787 if ($key ==
'statut') {
788 print
$object->getLibStatut(5);
790 if ($key ==
'phone') {
792 } elseif ($key ==
'fax') {
795 print $warehouse->showOutputField($val, $key,
$object->$key,
'');
799 $totalarray[
'nbfield']++;
801 if (!empty($val[
'isameasure']) && $val[
'isameasure'] == 1) {
803 $totalarray[
'pos'][$totalarray[
'nbfield']] =
't.'.$key;
805 if (!isset($totalarray[
'val'])) {
806 $totalarray[
'val'] = array();
808 if (!isset($totalarray[
'val'][
't.'.$key])) {
809 $totalarray[
'val'][
't.'.$key] = 0;
811 $totalarray[
'val'][
't.'.$key] +=
$object->$key;
817 if (!empty($arrayfields[
"stockqty"][
'checked'])) {
818 print
'<td class="right">'.price(
price2num($obj->stockqty,
'MS')).
'</td>';
820 $totalarray[
'nbfield']++;
823 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'stockqty';
828 if (!empty($arrayfields[
"estimatedvalue"][
'checked'])) {
829 print
'<td class="right">';
830 if (
price2num($obj->estimatedvalue,
'MT')) {
831 print
'<span class="amount">'.price(
price2num($obj->estimatedvalue,
'MT'), 1).
'</span>';
837 $totalarray[
'nbfield']++;
840 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'estimatedvalue';
845 if (!empty($arrayfields[
"estimatedstockvaluesell"][
'checked'])) {
846 print
'<td class="right">';
848 if ($obj->sellvalue) {
849 print
'<span class="amount">'.price(
price2num($obj->sellvalue,
'MT'), 1).
'</span>';
852 $htmltext = $langs->trans(
"OptionMULTIPRICESIsOn");
853 print $form->textwithtooltip(
'<span class="opacitymedium">'.$langs->trans(
"Variable").
'</span>', $htmltext);
857 $totalarray[
'nbfield']++;
860 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'estimatedstockvaluesell';
865 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_print_fields.tpl.php';
867 $parameters = array(
'arrayfields' => $arrayfields,
'object' => $object,
'obj' => $obj,
'i' => $i,
'totalarray' => &$totalarray);
868 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object, $action);
869 print $hookmanager->resPrint;
872 if (!empty($arrayfields[
't.statut'][
'checked'])) {
873 print
'<td class="center">'.$warehouse->LibStatut($obj->statut, 5).
'</td>';
875 $totalarray[
'nbfield']++;
881 print
'<td class="nowrap center">';
882 if ($massactionbutton || $massaction) {
884 if (in_array(
$object->id, $arrayofselected)) {
887 print
'<input id="cb'.$object->id.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.
$object->id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
891 $totalarray[
'nbfield']++;
901if ($totalnboflines - $offset <= $limit) {
903 include DOL_DOCUMENT_ROOT.
'/core/tpl/list_print_total.tpl.php';
909 foreach ($arrayfields as $key => $val) {
910 if (!empty($val[
'checked'])) {
914 print
'<tr><td colspan="'.$colspan.
'" class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</td></tr>';
919$parameters = array(
'arrayfields' => $arrayfields,
'sql' => $sql);
920$reshook = $hookmanager->executeHooks(
'printFieldListFooter', $parameters, $object);
921print $hookmanager->resPrint;
923print
'</table>'.
"\n";
928if (in_array(
'builddoc', array_keys($arrayofmassactions)) && ($nbtotalofrecords ===
'' || $nbtotalofrecords)) {
929 $hidegeneratedfilelistifempty = 1;
930 if ($massaction ==
'builddoc' || $action ==
'remove_file' || $show_files) {
931 $hidegeneratedfilelistifempty = 0;
934 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
938 $urlsource = $_SERVER[
'PHP_SELF'].
'?sortfield='.$sortfield.
'&sortorder='.$sortorder;
939 $urlsource .= str_replace(
'&',
'&', $param);
941 $filedir = $diroutputmassaction;
942 $genallowed = $user->hasRight(
'stock',
'lire');
943 $delallowed = $user->hasRight(
'stock',
'creer');
945 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)
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.