30 require
'../../main.inc.php';
31 require_once DOL_DOCUMENT_ROOT.
'/product/stock/class/entrepot.class.php';
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');
49 $toselect =
GETPOST(
'toselect',
'array');
52 $search_all = trim((
GETPOST(
'search_all',
'alphanohtml') !=
'') ?
GETPOST(
'search_all',
'alphanohtml') :
GETPOST(
'sall',
'alphanohtml'));
54 $search_label =
GETPOST(
"snom",
"alpha") ?
GETPOST(
"snom",
"alpha") :
GETPOST(
"search_label",
"alpha");
55 $search_status =
GETPOST(
"search_status",
"intcomma");
57 $search_category_list = array();
59 $search_category_list =
GETPOST(
"search_category_".Categorie::TYPE_WAREHOUSE.
"_list",
"array");
64 $sortfield =
GETPOST(
'sortfield',
'aZ09comma');
65 $sortorder =
GETPOST(
'sortorder',
'aZ09comma');
67 if (empty($page) || $page < 0 ||
GETPOST(
'button_search',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
72 $offset = $limit * $page;
73 $pageprev = $page - 1;
74 $pagenext = $page + 1;
85 $diroutputmassaction = $conf->stock->dir_output.
'/temp/massgeneration/'.$user->id;
86 $hookmanager->initHooks(array($contextpage));
89 $extrafields->fetch_name_optionals_label(
$object->table_element);
91 $search_array_options = $extrafields->getOptionalsFromPost(
$object->table_element,
'',
'search_');
94 $search_all =
GETPOST(
"search_all",
'alphanohtml');
96 foreach (
$object->fields as $key => $val) {
98 if ($search_key ==
'statut') {
99 $search_key =
'status';
101 if (
GETPOST(
'search_'.$search_key,
'alpha') !==
'') {
102 $search[$search_key] =
GETPOST(
'search_'.$search_key,
'alpha');
107 $fieldstosearchall = array();
108 foreach (
$object->fields as $key => $val) {
109 if (!empty($val[
'searchall'])) {
110 $fieldstosearchall[
't.'.$key] = $val[
'label'];
115 $arrayfields = array(
116 'stockqty' => array(
'type' =>
'float',
'label' =>
'PhysicalStock',
'enabled' => 1,
'visible' => -2,
'checked' => 0,
'position' => 170),
117 'estimatedvalue' => array(
'type' =>
'float',
'label' =>
'EstimatedStockValue',
'enabled' => 1,
'visible' => 1,
'checked' => 1,
'position' => 171),
118 'estimatedstockvaluesell' => array(
'type' =>
'float',
'label' =>
'EstimatedStockValueSell',
'enabled' => 1,
'checked' => 1,
'visible' => 2,
'position' => 172),
120 foreach (
$object->fields as $key => $val) {
122 if (!empty($val[
'visible'])) {
123 $visible = (int)
dol_eval($val[
'visible'], 1);
124 $arrayfields[
't.'.$key] = array(
125 'label' => $val[
'label'],
126 'checked' => (($visible < 0) ? 0 : 1),
127 'enabled' => (abs($visible) != 3 && (
int)
dol_eval($val[
'enabled'], 1)),
128 'position' => $val[
'position'],
129 'help' => isset($val[
'help']) ? $val[
'help'] :
''
134 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_array_fields.tpl.php';
139 $permissiontoread = $user->hasRight(
'stock',
'lire');
140 $permissiontodelete = $user->hasRight(
'stock',
'supprimer');
141 $permissiontoadd = $user->hasRight(
'stock',
'creer');
151 if (
GETPOST(
'cancel',
'alpha')) {
155 if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'presend' && $massaction !=
'confirm_presend') {
159 $parameters = array();
160 $reshook = $hookmanager->executeHooks(
'doActions', $parameters,
$object, $action);
165 if (empty($reshook)) {
167 include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
170 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
171 foreach (
$object->fields as $key => $val) {
173 if (preg_match(
'/^(date|timestamp|datetime)/', $val[
'type'])) {
174 $search[$key.
'_dtstart'] =
'';
175 $search[$key.
'_dtend'] =
'';
179 $search_array_options = array();
180 $search_category_list = array();
182 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')
183 ||
GETPOST(
'button_search_x',
'alpha') ||
GETPOST(
'button_search.x',
'alpha') ||
GETPOST(
'button_search',
'alpha')) {
188 $objectclass =
'Entrepot';
189 $objectlabel =
'Warehouse';
190 $uploaddir = $conf->stock->dir_output;
191 include DOL_DOCUMENT_ROOT.
'/core/actions_massactions.inc.php';
204 $title = $langs->trans(
"Warehouses");
205 $help_url =
'EN:Module_Stocks_En|FR:Module_Stock|ES:Módulo_Stocks';
213 if (!empty($extrafields->attributes[
$object->table_element][
'label'])) {
214 foreach ($extrafields->attributes[
$object->table_element][
'label'] as $key => $val) {
215 $sql .= ($extrafields->attributes[
$object->table_element][
'type'][$key] !=
'separate' ?
", ef.".$key.
" as options_".$key :
'');
220 $separatedPMP =
false;
222 $separatedPMP =
true;
223 $sql .=
", SUM(pa.pmp * ps.reel) as estimatedvalue, SUM(p.price * ps.reel) as sellvalue, SUM(ps.reel) as stockqty";
225 $sql .=
", SUM(p.pmp * ps.reel) as estimatedvalue, SUM(p.price * ps.reel) as sellvalue, SUM(ps.reel) as stockqty";
230 $parameters = array();
231 $reshook = $hookmanager->executeHooks(
'printFieldListSelect', $parameters,
$object);
232 $sql .= $hookmanager->resPrint;
233 $sql = preg_replace(
'/,\s*$/',
'',
$sql);
237 $sql .=
" FROM ".MAIN_DB_PREFIX.$object->table_element.
" as t";
238 if (!empty($extrafields->attributes[
$object->table_element][
'label']) && is_array($extrafields->attributes[
$object->table_element][
'label']) && count($extrafields->attributes[
$object->table_element][
'label'])) {
239 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element.
"_extrafields as ef on (t.rowid = ef.fk_object)";
241 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"product_stock as ps ON t.rowid = ps.fk_entrepot";
242 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"product as p ON ps.fk_product = p.rowid";
243 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_departements as c_dep ON c_dep.rowid = t.fk_departement";
244 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_country as ccount ON ccount.rowid = t.fk_pays";
246 $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;
248 $sql .=
" WHERE t.entity IN (".getEntity(
'stock').
")";
249 foreach ($search as $key => $val) {
250 if (array_key_exists($key,
$object->fields)) {
252 if ($class_key ==
'status') {
253 $class_key =
'statut';
255 if (($key ==
'status' && $search[$key] == -1) || $key ==
'entity') {
259 if ((strpos(
$object->fields[$key][
'type'],
'integer:') === 0) || (strpos(
$object->fields[$key][
'type'],
'sellist:') === 0) || !empty(
$object->fields[$key][
'arrayofkeyval'])) {
260 if ($search[$key] ==
'-1' || ($search[$key] ===
'0' && (empty(
$object->fields[$key][
'arrayofkeyval']) || !array_key_exists(
'0',
$object->fields[$key][
'arrayofkeyval'])))) {
265 if ($search[$key] !=
'') {
266 $sql .=
natural_search((($key ==
"ref") ?
"t.ref" :
"t.".$class_key), $search[$key], (($key ==
'status') ? 2 : $mode_search));
269 if (preg_match(
'/(_dtstart|_dtend)$/', $key) && $search[$key] !=
'') {
270 $columnName = preg_replace(
'/(_dtstart|_dtend)$/',
'', $key);
271 if (preg_match(
'/^(date|timestamp|datetime)/',
$object->fields[$columnName][
'type'])) {
272 if (preg_match(
'/_dtstart$/', $key)) {
273 $sql .=
" AND t.".$db->escape($columnName).
" >= '".$db->idate($search[$key]).
"'";
275 if (preg_match(
'/_dtend$/', $key)) {
276 $sql .=
" AND t.".$db->escape($columnName).
" <= '".$db->idate($search[$key]).
"'";
286 $searchCategoryWarehouseList = $search_category_list;
287 $searchCategoryWarehouseOperator = 0;
288 if (!empty($searchCategoryWarehouseList)) {
289 $searchCategoryWarehouseSqlList = array();
290 $listofcategoryid =
'';
291 foreach ($searchCategoryWarehouseList as $searchCategoryWarehouse) {
292 if (intval($searchCategoryWarehouse) == -2) {
293 $searchCategoryWarehouseSqlList[] =
" NOT EXISTS (SELECT ck.fk_warehouse FROM ".MAIN_DB_PREFIX.
"categorie_warehouse as ck WHERE t.rowid = ck.fk_warehouse)";
294 } elseif (intval($searchCategoryWarehouse) > 0) {
295 if ($searchCategoryWarehouseOperator == 0) {
296 $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).
")";
298 $listofcategoryid .= ($listofcategoryid ?
', ' :
'') .((
int) $searchCategoryWarehouse);
302 if ($listofcategoryid) {
303 $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).
"))";
305 if ($searchCategoryWarehouseOperator == 1) {
306 if (!empty($searchCategoryWarehouseSqlList)) {
307 $sql .=
" AND (".implode(
' OR ', $searchCategoryWarehouseSqlList).
")";
310 if (!empty($searchCategoryWarehouseSqlList)) {
311 $sql .=
" AND (".implode(
' AND ', $searchCategoryWarehouseSqlList).
")";
317 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_sql.tpl.php';
319 $parameters = array();
320 $reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters,
$object, $action);
321 $sql .= $hookmanager->resPrint;
323 $sql .=
" GROUP BY ";
324 foreach (
$object->fields as $key => $val) {
325 $sql .=
"t.".$db->escape($key).
", ";
328 if (!empty($extrafields->attributes[
$object->table_element][
'label'])) {
329 foreach ($extrafields->attributes[
$object->table_element][
'label'] as $key => $val) {
330 $sql .= ($extrafields->attributes[
$object->table_element][
'type'][$key] !=
'separate' ?
"ef.".$key.
', ' :
'');
334 $parameters = array();
335 $reshook = $hookmanager->executeHooks(
'printFieldListGroupBy', $parameters);
336 $sql .= $hookmanager->resPrint;
337 $sql = preg_replace(
'/,\s*$/',
'',
$sql);
340 $result = $db->query(
$sql);
342 $totalnboflines = $db->num_rows($result);
344 $line = $total = $totalsell = $totalStock = 0;
345 while ($line < $totalnboflines) {
346 $objp = $db->fetch_object($result);
347 $total += $objp->estimatedvalue;
348 $totalsell += $objp->sellvalue;
349 $totalStock += $objp->stockqty;
352 $totalarray[
'val'][
'stockqty'] =
price2num($totalStock,
'MS');
353 $totalarray[
'val'][
'estimatedvalue'] =
price2num($total,
'MT');
354 $totalarray[
'val'][
'estimatedstockvaluesell'] =
price2num($totalsell,
'MT');
358 $nbtotalofrecords =
'';
361 $sqlforcount = preg_replace(
'/^'.preg_quote($sqlfields,
'/').
'/',
'SELECT COUNT(*) as nbtotalofrecords',
$sql);
362 $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);
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);
395 if ($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);
408 $arrayofselected = is_array($toselect) ? $toselect : array();
412 $param .=
'&mode='.urlencode($mode);
414 if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
415 $param .=
'&contextpage='.urlencode($contextpage);
417 if ($limit > 0 && $limit != $conf->liste_limit) {
418 $param .=
'&limit='.((int) $limit);
420 if ($optioncss !=
'') {
421 $param .=
'&optioncss='.urlencode($optioncss);
423 foreach ($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]);
439 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_param.tpl.php';
441 $parameters = array();
442 $reshook = $hookmanager->executeHooks(
'printFieldListSearchParam', $parameters,
$object, $action);
443 $param .= $hookmanager->resPrint;
446 $arrayofmassactions = array(
451 if (
GETPOSTINT(
'nomassaction') || in_array($massaction, array(
'presend',
'predelete',
'preaffecttag'))) {
452 $arrayofmassactions = array();
454 if (
isModEnabled(
'category') && $user->hasRight(
'stock',
'creer')) {
455 $arrayofmassactions[
'preaffecttag'] =
img_picto(
'',
'label',
'class="pictofixedwidth"').$langs->trans(
"AffectTag");
457 $massactionbutton =
$form->selectMassAction(
'', $arrayofmassactions);
459 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" id="searchFormList" method="POST" name="formulaire">';
460 if ($optioncss !=
'') {
461 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
463 print
'<input type="hidden" name="token" value="'.newToken().
'">';
464 print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
465 print
'<input type="hidden" name="action" value="list">';
466 print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
467 print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
468 print
'<input type="hidden" name="page" value="'.$page.
'">';
469 print
'<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
470 print
'<input type="hidden" name="page_y" value="">';
471 print
'<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'));
480 print_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;
487 include 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>';
502 if (
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);
513 if (empty($reshook)) {
514 $moreforfilter .= $hookmanager->resPrint;
516 $moreforfilter = $hookmanager->resPrint;
519 if (!empty($moreforfilter)) {
520 print
'<div class="liste_titre liste_titre_bydiv centpercent">';
521 print $moreforfilter;
522 $parameters = array();
523 $reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters,
$object, $action);
524 print $hookmanager->resPrint;
528 $varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
529 $htmlofselectarray =
$form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage,
getDolGlobalString(
'MAIN_CHECKBOX_LEFT_COLUMN'));
530 $selectedfields = ($mode !=
'kanban' ? $htmlofselectarray :
'');
531 $selectedfields .= (count($arrayofmassactions) ?
$form->showCheckAddButtons(
'checkforselect', 1) :
'');
533 print
'<div class="div-table-responsive">';
534 print
'<table class="tagtable nobottomiftotal liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'">'.
"\n";
538 print
'<tr class="liste_titre_filter">';
541 print
'<td class="liste_titre center maxwidthsearch">';
542 $searchpicto =
$form->showFilterButtons(
'left');
546 foreach (
$object->fields as $key => $val) {
547 if ($key ==
'statut') {
550 $searchkey = empty($search[$key]) ?
'' : $search[$key];
551 $cssforfield = (empty($val[
'csslist']) ? (empty($val[
'css']) ?
'' : $val[
'css']) : $val[
'csslist']);
552 if ($key ==
'status') {
553 $cssforfield .= ($cssforfield ?
' ' :
'').
'center';
554 } elseif (in_array($val[
'type'], array(
'date',
'datetime',
'timestamp'))) {
555 $cssforfield .= ($cssforfield ?
' ' :
'').
'center';
556 } elseif (in_array($val[
'type'], array(
'timestamp'))) {
557 $cssforfield .= ($cssforfield ?
' ' :
'').
'nowrap';
558 } 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'])) {
559 $cssforfield .= ($cssforfield ?
' ' :
'').
'right';
561 if (!empty($arrayfields[
't.'.$key][
'checked'])) {
562 print
'<td class="liste_titre'.($cssforfield ?
' '.$cssforfield :
'').($key ==
'status' ?
' parentonrightofpage' :
'').
'">';
563 if (!empty($val[
'arrayofkeyval']) && is_array($val[
'arrayofkeyval'])) {
564 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);
565 } elseif ((strpos($val[
'type'],
'integer:') === 0) || (strpos($val[
'type'],
'sellist:') === 0)) {
566 print
$object->showInputField($val, $key, (isset($search[$key]) ? $search[$key] :
''),
'',
'',
'search_', $cssforfield.
' maxwidth250', 1);
567 } elseif (preg_match(
'/^(date|timestamp|datetime)/', $val[
'type'])) {
568 print
'<div class="nowrap">';
569 print
$form->selectDate(isset($search[$key.
'_dtstart']) ? $search[$key.
'_dtstart'] :
'',
"search_".$key.
"_dtstart", 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'From'));
571 print
'<div class="nowrap">';
572 print
$form->selectDate(isset($search[$key.
'_dtend']) ? $search[$key.
'_dtend'] :
'',
"search_".$key.
"_dtend", 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'to'));
574 } elseif ($key ==
'lang') {
575 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formadmin.class.php';
577 print $formadmin->select_language($search[$key],
'search_lang', 0,
null, 1, 0, 0,
'minwidth150 maxwidth200', 2);
579 print
'<input type="text" class="flat maxwidth75" name="search_'.$key.
'" value="'.
dol_escape_htmltag(isset($search[$key]) ? $search[$key] :
'').
'">';
585 if (!empty($arrayfields[
"stockqty"][
'checked'])) {
586 print
'<td class="liste_titre"></td>';
589 if (!empty($arrayfields[
"estimatedvalue"][
'checked'])) {
590 print
'<td class="liste_titre"></td>';
593 if (!empty($arrayfields[
"estimatedstockvaluesell"][
'checked'])) {
594 print
'<td class="liste_titre"></td>';
598 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_input.tpl.php';
601 $parameters = array(
'arrayfields' => $arrayfields);
602 $reshook = $hookmanager->executeHooks(
'printFieldListOption', $parameters,
$object, $action);
603 print $hookmanager->resPrint;
606 if (!empty($arrayfields[
't.statut'][
'checked'])) {
607 print
'<td class="liste_titre center parentonrightofpage">';
608 print
$form->selectarray(
'search_status', $warehouse->labelStatus, $search_status, 1, 0, 0,
'', 1, 0, 0,
'',
'search_status width100 onrightofpage');
614 print
'<td class="liste_titre center maxwidthsearch">';
615 $searchpicto =
$form->showFilterButtons();
621 $totalarray = array();
622 $totalarray[
'nbfield'] = 0;
626 print
'<tr class="liste_titre">';
629 print
getTitleFieldOfList($selectedfields, 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ').
"\n";
630 $totalarray[
'nbfield']++;
632 foreach (
$object->fields as $key => $val) {
633 if ($key ==
'statut') {
636 $cssforfield = (empty($val[
'csslist']) ? (empty($val[
'css']) ?
'' : $val[
'css']) : $val[
'csslist']);
637 if ($key ==
'status') {
638 $cssforfield .= ($cssforfield ?
' ' :
'').
'center';
639 } elseif (in_array($val[
'type'], array(
'date',
'datetime',
'timestamp'))) {
640 $cssforfield .= ($cssforfield ?
' ' :
'').
'center';
641 } elseif (in_array($val[
'type'], array(
'timestamp'))) {
642 $cssforfield .= ($cssforfield ?
' ' :
'').
'nowrap';
643 } 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'])) {
644 $cssforfield .= ($cssforfield ?
' ' :
'').
'right';
646 $cssforfield = preg_replace(
'/small\s*/',
'', $cssforfield);
647 if (!empty($arrayfields[
't.'.$key][
'checked'])) {
648 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";
649 $totalarray[
'nbfield']++;
653 if (!empty($arrayfields[
"stockqty"][
'checked'])) {
654 print_liste_field_titre(
"PhysicalStock", $_SERVER[
"PHP_SELF"],
"stockqty",
'', $param,
'', $sortfield, $sortorder,
'right ');
655 $totalarray[
'nbfield']++;
656 $totalarray[
'type'][$totalarray[
'nbfield']] =
'stock';
659 if (!empty($arrayfields[
"estimatedvalue"][
'checked'])) {
660 print_liste_field_titre(
"EstimatedStockValue", $_SERVER[
"PHP_SELF"],
"estimatedvalue",
'', $param,
'', $sortfield, $sortorder,
'right ');
661 $totalarray[
'nbfield']++;
662 $totalarray[
'type'][$totalarray[
'nbfield']] =
'price';
665 if (!empty($arrayfields[
"estimatedstockvaluesell"][
'checked'])) {
666 print_liste_field_titre(
"EstimatedStockValueSell", $_SERVER[
"PHP_SELF"],
"",
'', $param,
'', $sortfield, $sortorder,
'right ');
667 $totalarray[
'nbfield']++;
668 $totalarray[
'type'][$totalarray[
'nbfield']] =
'price';
672 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_title.tpl.php';
675 $parameters = array(
'arrayfields' => $arrayfields,
'param' => $param,
'sortfield' => $sortfield,
'sortorder' => $sortorder);
676 $reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters,
$object);
677 print $hookmanager->resPrint;
679 if (!empty($arrayfields[
't.statut'][
'checked'])) {
680 print_liste_field_titre($arrayfields[
't.statut'][
'label'], $_SERVER[
"PHP_SELF"],
"t.statut",
'', $param,
'', $sortfield, $sortorder,
'center ');
681 $totalarray[
'nbfield']++;
686 print
getTitleFieldOfList($selectedfields, 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ').
"\n";
687 $totalarray[
'nbfield']++;
696 $savnbfield = $totalarray[
'nbfield'];
697 $totalarray[
'nbfield'] = 0;
698 $imaxinloop = ($limit ? min($num, $limit) : $num);
699 while ($i < $imaxinloop) {
700 $obj = $db->fetch_object($resql);
706 $warehouse->setVarsFromFetchObj($obj);
708 $warehouse->label = $warehouse->ref;
709 $warehouse->sellvalue = $obj->sellvalue;
713 if ($mode ==
'kanban') {
715 print
'<tr class="trkanban"><td colspan="'.$savnbfield.
'">';
716 print
'<div class="box-flex-container kanban">';
720 if ($massactionbutton || $massaction) {
722 if (in_array(
$object->id, $arrayofselected)) {
726 print
$object->getKanbanView(
'', array(
'selected' => $selected));
727 if ($i == ($imaxinloop - 1)) {
734 print
'<tr data-rowid="'.$object->id.
'" class="oddeven">';
738 print
'<td class="nowrap center">';
739 if ($massactionbutton || $massaction) {
741 if (in_array(
$object->id, $arrayofselected)) {
744 print
'<input id="cb'.$object->id.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.
$object->id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
748 $totalarray[
'nbfield']++;
751 foreach (
$object->fields as $key => $val) {
752 if ($key ==
'statut') {
755 $cssforfield = (empty($val[
'csslist']) ? (empty($val[
'css']) ?
'' : $val[
'css']) : $val[
'csslist']);
756 if (in_array($val[
'type'], array(
'date',
'datetime',
'timestamp'))) {
757 $cssforfield .= ($cssforfield ?
' ' :
'').
'center';
758 } elseif ($key ==
'status') {
759 $cssforfield .= ($cssforfield ?
' ' :
'').
'center';
762 if (in_array($val[
'type'], array(
'timestamp'))) {
763 $cssforfield .= ($cssforfield ?
' ' :
'').
'nowraponall';
764 } elseif ($key ==
'ref') {
765 $cssforfield .= ($cssforfield ?
' ' :
'').
'nowraponall';
768 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'])) {
769 $cssforfield .= ($cssforfield ?
' ' :
'').
'right';
771 if (in_array($key, array(
'fk_soc',
'fk_user',
'fk_warehouse'))) {
772 $cssforfield =
'tdoverflowmax100';
775 if (!empty($arrayfields[
't.'.$key][
'checked'])) {
776 print
'<td'.($cssforfield ?
' class="'.$cssforfield.(preg_match(
'/tdoverflow/', $cssforfield) ?
' classfortooltip' :
'').
'"' :
'');
777 if (preg_match(
'/tdoverflow/', $cssforfield) && !is_numeric(
$object->$key)) {
778 print
' title="'.dol_escape_htmltag(
$object->$key).
'"';
781 if ($key ==
'statut') {
782 print
$object->getLibStatut(5);
784 if ($key ==
'phone') {
786 } elseif ($key ==
'fax') {
789 print $warehouse->showOutputField($val, $key,
$object->$key,
'');
793 $totalarray[
'nbfield']++;
795 if (!empty($val[
'isameasure']) && $val[
'isameasure'] == 1) {
797 $totalarray[
'pos'][$totalarray[
'nbfield']] =
't.'.$key;
799 if (!isset($totalarray[
'val'])) {
800 $totalarray[
'val'] = array();
802 if (!isset($totalarray[
'val'][
't.'.$key])) {
803 $totalarray[
'val'][
't.'.$key] = 0;
805 $totalarray[
'val'][
't.'.$key] +=
$object->$key;
811 if (!empty($arrayfields[
"stockqty"][
'checked'])) {
812 print
'<td class="right">'.price(
price2num($obj->stockqty,
'MS')).
'</td>';
814 $totalarray[
'nbfield']++;
817 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'stockqty';
822 if (!empty($arrayfields[
"estimatedvalue"][
'checked'])) {
823 print
'<td class="right">';
824 if (
price2num($obj->estimatedvalue,
'MT')) {
825 print
'<span class="amount">'.price(
price2num($obj->estimatedvalue,
'MT'), 1).
'</span>';
831 $totalarray[
'nbfield']++;
834 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'estimatedvalue';
839 if (!empty($arrayfields[
"estimatedstockvaluesell"][
'checked'])) {
840 print
'<td class="right">';
842 if ($obj->sellvalue) {
843 print
'<span class="amount">'.price(
price2num($obj->sellvalue,
'MT'), 1).
'</span>';
846 $htmltext = $langs->trans(
"OptionMULTIPRICESIsOn");
847 print
$form->textwithtooltip(
'<span class="opacitymedium">'.$langs->trans(
"Variable").
'</span>', $htmltext);
851 $totalarray[
'nbfield']++;
854 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'estimatedstockvaluesell';
859 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_print_fields.tpl.php';
861 $parameters = array(
'arrayfields' => $arrayfields,
'object' =>
$object,
'obj' => $obj,
'i' => $i,
'totalarray' => &$totalarray);
862 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters,
$object, $action);
863 print $hookmanager->resPrint;
866 if (!empty($arrayfields[
't.statut'][
'checked'])) {
867 print
'<td class="center">'.$warehouse->LibStatut($obj->statut, 5).
'</td>';
869 $totalarray[
'nbfield']++;
875 print
'<td class="nowrap center">';
876 if ($massactionbutton || $massaction) {
878 if (in_array(
$object->id, $arrayofselected)) {
881 print
'<input id="cb'.$object->id.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.
$object->id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
885 $totalarray[
'nbfield']++;
895 if ($totalnboflines - $offset <= $limit) {
897 include DOL_DOCUMENT_ROOT.
'/core/tpl/list_print_total.tpl.php';
903 foreach ($arrayfields as $key => $val) {
904 if (!empty($val[
'checked'])) {
908 print
'<tr><td colspan="'.$colspan.
'" class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</td></tr>';
913 $parameters = array(
'arrayfields' => $arrayfields,
'sql' =>
$sql);
914 $reshook = $hookmanager->executeHooks(
'printFieldListFooter', $parameters,
$object);
915 print $hookmanager->resPrint;
917 print
'</table>'.
"\n";
920 print
'</form>'.
"\n";
922 if (in_array(
'builddoc', array_keys($arrayofmassactions)) && ($nbtotalofrecords ===
'' || $nbtotalofrecords)) {
923 $hidegeneratedfilelistifempty = 1;
924 if ($massaction ==
'builddoc' || $action ==
'remove_file' || $show_files) {
925 $hidegeneratedfilelistifempty = 0;
928 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
932 $urlsource = $_SERVER[
'PHP_SELF'].
'?sortfield='.$sortfield.
'&sortorder='.$sortorder;
933 $urlsource .= str_replace(
'&',
'&', $param);
935 $filedir = $diroutputmassaction;
936 $genallowed = $user->hasRight(
'stock',
'lire');
937 $delallowed = $user->hasRight(
'stock',
'creer');
939 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(GETPOST('button_removefilter_x', 'alpha')||GETPOST('button_removefilter.x', 'alpha')||GETPOST('button_removefilter', 'alpha')) if(GETPOST('button_search_x', 'alpha')||GETPOST('button_search.x', 'alpha')||GETPOST('button_search', 'alpha')) if($action=="save" &&empty($cancel)) $help_url
View.
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.
if(isModEnabled('invoice') && $user->hasRight('facture', 'lire')) if((isModEnabled('fournisseur') &&!getDolGlobalString('MAIN_USE_NEW_SUPPLIERMOD') && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') && $user->hasRight('don', 'lire')) if(isModEnabled('tax') && $user->hasRight('tax', 'charges', 'lire')) if(isModEnabled('invoice') &&isModEnabled('order') && $user->hasRight("commande", "lire") &&!getDolGlobalString('WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER')) $sql
Social contributions to pay.
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
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_print_phone($phone, $countrycode='', $cid=0, $socid=0, $addlink='', $separ=" ", $withpicto='', $titlealt='', $adddivfloat=0)
Format phone numbers according to country.
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.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
print_barre_liste($titre, $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.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
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.