|
@@ -66,7 +66,7 @@ if (empty($page) || $page == -1 || GETPOST('button_search', 'alpha') || GETPOST(
|
|
|
$offset = $limit * $page;
|
|
|
$pageprev = $page - 1;
|
|
|
$pagenext = $page + 1;
|
|
|
-if (!$sortfield) $sortfield = "e.ref";
|
|
|
+if (!$sortfield) $sortfield = "t.ref";
|
|
|
if (!$sortorder) $sortorder = "ASC";
|
|
|
|
|
|
// Security check
|
|
@@ -89,45 +89,55 @@ $search_array_options = $extrafields->getOptionalsFromPost($object->table_elemen
|
|
|
|
|
|
// List of fields to search into when doing a "search in all"
|
|
|
$fieldstosearchall = array(
|
|
|
- 'e.ref'=>"Ref",
|
|
|
- 'e.lieu'=>"LocationSummary",
|
|
|
- 'e.description'=>"Description",
|
|
|
- 'e.address'=>"Address",
|
|
|
- 'e.zip'=>'Zip',
|
|
|
- 'e.town'=>'Town',
|
|
|
- 'e.phone'=>'Phone',
|
|
|
- 'e.fax'=>'Fax',
|
|
|
+ 't.ref'=>"Ref",
|
|
|
+ 't.lieu'=>"LocationSummary",
|
|
|
+ 't.description'=>"Description",
|
|
|
+ 't.address'=>"Address",
|
|
|
+ 't.zip'=>'Zip',
|
|
|
+ 't.town'=>'Town',
|
|
|
+ 't.phone'=>'Phone',
|
|
|
+ 't.fax'=>'Fax',
|
|
|
);
|
|
|
|
|
|
+// Initialize array of search criterias
|
|
|
+$search_all=trim(GETPOST("search_all", 'alpha'));
|
|
|
+$search=array();
|
|
|
+foreach($object->fields as $key => $val)
|
|
|
+{
|
|
|
+ if (GETPOST('search_'.$key, 'alpha') !== '') $search[$key]=GETPOST('search_'.$key, 'alpha');
|
|
|
+}
|
|
|
+
|
|
|
// Definition of fields for list
|
|
|
$arrayfields = array(
|
|
|
- 'e.ref'=>array('label'=>$langs->trans("Ref"), 'checked'=>1),
|
|
|
- 'e.lieu'=>array('label'=>$langs->trans("LocationSummary"), 'checked'=>1),
|
|
|
- 'e.description'=>array('label'=>$langs->trans("Description"), 'checked'=>0),
|
|
|
- 'e.address'=>array('label'=>$langs->trans("Address"), 'checked'=>0),
|
|
|
- 'e.zip'=>array('label'=>$langs->trans("Zip"), 'checked'=>0),
|
|
|
- 'e.town'=>array('label'=>$langs->trans("Town"), 'checked'=>0),
|
|
|
- 'e.phone'=>array('label'=>$langs->trans("Phone"), 'checked'=>0),
|
|
|
- 'e.fax'=>array('label'=>$langs->trans("Fax"), 'checked'=>0),
|
|
|
- 'stockqty'=>array('type'=>'float', 'label'=>$langs->trans("PhysicalStock"), 'enabled'=>1, 'visible'=>-2, 'position'=>70),
|
|
|
- 'estimatedvalue'=>array('type'=>'float', 'label'=>$langs->trans("EstimatedStockValue"), 'enabled'=>1, 'visible'=>-2, 'position'=>71),
|
|
|
- 'sellvalue'=>array('type'=>'float', 'label'=>$langs->trans("EstimatedStockValueSell"), 'enabled'=>1, 'visible'=>-2, 'position'=>72),
|
|
|
- 'e.statut'=>array('label'=>$langs->trans("Status"), 'checked'=>1, 'position'=>100),
|
|
|
+ 'stockqty'=>array('type'=>'float', 'label'=>'PhysicalStock', 'enabled'=>1, 'visible'=>-2, 'position'=>70),
|
|
|
+ 'estimatedvalue'=>array('type'=>'float', 'label'=>'EstimatedStockValue', 'enabled'=>1, 'visible'=>-2, 'position'=>71),
|
|
|
+ 'estimatedstockvaluesell'=>array('type'=>'float', 'label'=>'EstimatedStockValueSell', 'enabled'=>1, 'visible'=>-2, 'position'=>72),
|
|
|
);
|
|
|
-
|
|
|
+foreach($object->fields as $key => $val)
|
|
|
+{
|
|
|
+ // If $val['visible']==0, then we never show the field
|
|
|
+ if (!empty($val['visible'])) $arrayfields['t.'.$key] = array('label'=>$val['label'], 'checked'=>(($val['visible'] < 0) ? 0 : 1), 'enabled'=>($val['enabled'] && ($val['visible'] != 3)), 'position'=>$val['position']);
|
|
|
+}
|
|
|
// Extra fields
|
|
|
if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0)
|
|
|
{
|
|
|
foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val)
|
|
|
{
|
|
|
- if (!empty($extrafields->attributes[$object->table_element]['list'][$key]))
|
|
|
- $arrayfields["ef.".$key] = array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key] < 0) ? 0 : 1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key]) != 3 && $extrafields->attributes[$object->table_element]['perms'][$key]));
|
|
|
+ if (!empty($extrafields->attributes[$object->table_element]['list'][$key])) {
|
|
|
+ $arrayfields["ef.".$key] = array(
|
|
|
+ 'label'=>$extrafields->attributes[$object->table_element]['label'][$key],
|
|
|
+ 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key] < 0) ? 0 : 1),
|
|
|
+ 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key],
|
|
|
+ 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key]) != 3 && $extrafields->attributes[$object->table_element]['perms'][$key])
|
|
|
+ );
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
$object->fields = dol_sort_array($object->fields, 'position');
|
|
|
$arrayfields = dol_sort_array($arrayfields, 'position');
|
|
|
|
|
|
|
|
|
+
|
|
|
/*
|
|
|
* Actions
|
|
|
*/
|
|
@@ -147,13 +157,12 @@ if (empty($reshook))
|
|
|
// Purge search criteria
|
|
|
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers
|
|
|
{
|
|
|
- $search_ref = "";
|
|
|
- $sall = "";
|
|
|
- $search_label = "";
|
|
|
- $search_status = "";
|
|
|
- $toselect = '';
|
|
|
- $search_array_options = array();
|
|
|
- $search_category_list = array();
|
|
|
+ foreach ($object->fields as $key => $val)
|
|
|
+ {
|
|
|
+ $search[$key] = '';
|
|
|
+ }
|
|
|
+ $toselect = '';
|
|
|
+ $search_array_options = array();
|
|
|
}
|
|
|
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')
|
|
|
|| GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha'))
|
|
@@ -175,9 +184,11 @@ if (empty($reshook))
|
|
|
* View
|
|
|
*/
|
|
|
|
|
|
-$form = new FormCategory($db);
|
|
|
+$form = new Form($db);
|
|
|
+$formcategory = new FormCategory($db);
|
|
|
$warehouse = new Entrepot($db);
|
|
|
|
|
|
+$totalarray = array();
|
|
|
$now = dol_now();
|
|
|
|
|
|
$help_url = 'EN:Module_Stocks_En|FR:Module_Stock|ES:Módulo_Stocks';
|
|
@@ -186,39 +197,46 @@ $title = $langs->trans("ListOfWarehouses");
|
|
|
|
|
|
// Build and execute select
|
|
|
// --------------------------------------------------------------------
|
|
|
-$sql = "SELECT e.rowid, e.ref, e.statut, e.lieu, e.address, e.zip, e.town, e.phone, e.fax, e.fk_pays, e.fk_parent,";
|
|
|
-$sql .= " SUM(p.pmp * ps.reel) as estimatedvalue, SUM(p.price * ps.reel) as sellvalue, SUM(ps.reel) as stockqty";
|
|
|
+$sql = 'SELECT ';
|
|
|
+foreach ($object->fields as $key => $val)
|
|
|
+{
|
|
|
+ $sql .= 't.'.$key.', ';
|
|
|
+}
|
|
|
// Add fields from extrafields
|
|
|
if (!empty($extrafields->attributes[$object->table_element]['label'])) {
|
|
|
- foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
|
|
|
- $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : '');
|
|
|
- }
|
|
|
+ foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key.' as options_'.$key.', ' : '');
|
|
|
}
|
|
|
+$sql .= " SUM(p.pmp * ps.reel) as estimatedvalue, SUM(p.price * ps.reel) as sellvalue, SUM(ps.reel) as stockqty";
|
|
|
// Add fields from hooks
|
|
|
$parameters = array();
|
|
|
$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook
|
|
|
$sql .= $hookmanager->resPrint;
|
|
|
$sql = preg_replace('/,\s*$/', '', $sql);
|
|
|
-$sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as e";
|
|
|
-
|
|
|
+$sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t";
|
|
|
if (!empty($conf->categorie->enabled))
|
|
|
{
|
|
|
- $sql .= Categorie::getFilterJoinQuery(Categorie::TYPE_WAREHOUSE, "e.rowid");
|
|
|
+ $sql .= Categorie::getFilterJoinQuery(Categorie::TYPE_WAREHOUSE, "t.rowid");
|
|
|
}
|
|
|
-
|
|
|
-if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (e.rowid = ef.fk_object)";
|
|
|
-$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_stock as ps ON e.rowid = ps.fk_entrepot";
|
|
|
+if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (t.rowid = ef.fk_object)";
|
|
|
+$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_stock as ps ON t.rowid = ps.fk_entrepot";
|
|
|
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON ps.fk_product = p.rowid";
|
|
|
-$sql .= " WHERE e.entity IN (".getEntity('stock').")";
|
|
|
-
|
|
|
+$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as c_dep ON c_dep.rowid = t.fk_departement";
|
|
|
+$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as ccount ON ccount.rowid = t.fk_pays";
|
|
|
+$sql .= " WHERE t.entity IN (".getEntity('stock').")";
|
|
|
if (!empty($conf->categorie->enabled))
|
|
|
{
|
|
|
- $sql .= Categorie::getFilterSelectQuery(Categorie::TYPE_WAREHOUSE, "e.rowid", $search_category_list);
|
|
|
+ $sql .= Categorie::getFilterSelectQuery(Categorie::TYPE_WAREHOUSE, "t.rowid", $search_category_list);
|
|
|
+}
|
|
|
+foreach ($search as $key => $val)
|
|
|
+{
|
|
|
+ if ($key == 'status' && $search[$key] == -1) continue;
|
|
|
+ $mode_search = (($object->isInt($object->fields[$key]) || $object->isFloat($object->fields[$key])) ? 1 : 0);
|
|
|
+ if (strpos($object->fields[$key]['type'], 'integer:') === 0) {
|
|
|
+ if ($search[$key] == '-1') $search[$key] = '';
|
|
|
+ $mode_search = 2;
|
|
|
+ }
|
|
|
+ if ($search[$key] != '') $sql .= natural_search($key, $search[$key], (($key == 'status') ? 2 : $mode_search));
|
|
|
}
|
|
|
-
|
|
|
-if ($search_ref) $sql .= natural_search("e.ref", $search_ref); // ref
|
|
|
-if ($search_label) $sql .= natural_search("e.lieu", $search_label); // label
|
|
|
-if ($search_status != '' && $search_status >= 0) $sql .= " AND e.statut = ".$search_status;
|
|
|
if ($search_all) $sql .= natural_search(array_keys($fieldstosearchall), $search_all);
|
|
|
// Add where from extra fields
|
|
|
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
|
|
@@ -226,7 +244,20 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
|
|
|
$parameters = array();
|
|
|
$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object); // Note that $action and $object may have been modified by hook
|
|
|
$sql .= $hookmanager->resPrint;
|
|
|
-$sql .= " GROUP BY e.rowid, e.ref, e.statut, e.lieu, e.address, e.zip, e.town, e.fk_pays, e.phone, e.fax, e.fk_parent";
|
|
|
+$sql.= " GROUP BY ";
|
|
|
+foreach($object->fields as $key => $val)
|
|
|
+{
|
|
|
+ $sql.='t.'.$key.', ';
|
|
|
+}
|
|
|
+// Add fields from extrafields
|
|
|
+if (! empty($extrafields->attributes[$object->table_element]['label'])) {
|
|
|
+ foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql.=($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key.', ' : '');
|
|
|
+}
|
|
|
+// Add where from hooks
|
|
|
+$parameters=array();
|
|
|
+$reshook=$hookmanager->executeHooks('printFieldListGroupBy',$parameters); // Note that $action and $object may have been modified by hook
|
|
|
+$sql.=$hookmanager->resPrint;
|
|
|
+$sql=preg_replace('/,\s*$/','', $sql);
|
|
|
$totalnboflines = 0;
|
|
|
$result = $db->query($sql);
|
|
|
if ($result)
|
|
@@ -242,6 +273,9 @@ if ($result)
|
|
|
$totalStock += $objp->stockqty;
|
|
|
$line++;
|
|
|
}
|
|
|
+ $totalarray['val']['stockqty'] = $totalStock;
|
|
|
+ $totalarray['val']['estimatedvalue'] = $total;
|
|
|
+ $totalarray['val']['estimatedstockvaluesell'] = $totalsell;
|
|
|
}
|
|
|
$sql .= $db->order($sortfield, $sortorder);
|
|
|
|
|
@@ -296,10 +330,11 @@ $arrayofselected = is_array($toselect) ? $toselect : array();
|
|
|
$param = '';
|
|
|
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage);
|
|
|
if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit);
|
|
|
-if ($search_ref) $param .= "&search_ref=".urlencode($search_ref);
|
|
|
-if ($search_label) $param .= "&search_label=".urlencode($search_label);
|
|
|
-if ($search_status) $param .= "&search_status=".urlencode($search_status);
|
|
|
-if ($search_all) $param .= "&search_all=".urlencode($search_all);
|
|
|
+foreach ($search as $key => $val)
|
|
|
+{
|
|
|
+ if (is_array($search[$key]) && count($search[$key])) foreach ($search[$key] as $skey) $param .= '&search_'.$key.'[]='.urlencode($skey);
|
|
|
+ else $param .= '&search_'.$key.'='.urlencode($search[$key]);
|
|
|
+}
|
|
|
if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss);
|
|
|
// Add $param from extra fields
|
|
|
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
|
|
@@ -345,7 +380,7 @@ $moreforfilter = '';
|
|
|
|
|
|
if (!empty($conf->categorie->enabled))
|
|
|
{
|
|
|
- $moreforfilter .= $form->getFilterBox(Categorie::TYPE_WAREHOUSE, $search_category_list);
|
|
|
+ $moreforfilter .= $formcategory->getFilterBox(Categorie::TYPE_WAREHOUSE, $search_category_list);
|
|
|
}
|
|
|
|
|
|
/*$moreforfilter.='<div class="divsearchfield">';
|
|
@@ -375,65 +410,48 @@ print '<table class="tagtable nobottomiftotal liste'.($moreforfilter ? " listwit
|
|
|
// --------------------------------------------------------------------
|
|
|
print '<tr class="liste_titre_filter">';
|
|
|
|
|
|
-if (!empty($arrayfields['e.ref']['checked']))
|
|
|
-{
|
|
|
- print '<td class="liste_titre left">';
|
|
|
- print '<input class="flat" type="text" name="search_ref" size="6" value="'.dol_escape_htmltag($search_ref).'">';
|
|
|
- print '</td>';
|
|
|
-}
|
|
|
-if (!empty($arrayfields['e.lieu']['checked']))
|
|
|
-{
|
|
|
- print '<td class="liste_titre left">';
|
|
|
- print '<input class="flat" type="text" name="search_label" size="10" value="'.dol_escape_htmltag($search_label).'">';
|
|
|
- print '</td>';
|
|
|
-}
|
|
|
-if (!empty($arrayfields['e.description']['checked']))
|
|
|
-{
|
|
|
- print '<td class="liste_titre"></td>';
|
|
|
-}
|
|
|
-if (!empty($arrayfields['e.address']['checked']))
|
|
|
-{
|
|
|
- print '<td class="liste_titre"></td>';
|
|
|
-}
|
|
|
-if (!empty($arrayfields['e.zip']['checked']))
|
|
|
-{
|
|
|
- print '<td class="liste_titre"></td>';
|
|
|
-}
|
|
|
-if (!empty($arrayfields['e.town']['checked']))
|
|
|
-{
|
|
|
- print '<td class="liste_titre"></td>';
|
|
|
-}
|
|
|
-if (!empty($arrayfields['e.phone']['checked']))
|
|
|
+foreach ($object->fields as $key => $val)
|
|
|
{
|
|
|
- print '<td class="liste_titre"></td>';
|
|
|
-}
|
|
|
-if (!empty($arrayfields['e.fax']['checked']))
|
|
|
-{
|
|
|
- print '<td class="liste_titre"></td>';
|
|
|
+ if($key == 'statut'){ continue; }
|
|
|
+ $cssforfield = (empty($val['css']) ? '' : $val['css']);
|
|
|
+ if ($key == 'status') $cssforfield .= ($cssforfield ? ' ' : '').'center';
|
|
|
+ elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'center';
|
|
|
+ elseif (in_array($val['type'], array('timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
|
|
|
+ elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID') $cssforfield .= ($cssforfield ? ' ' : '').'right';
|
|
|
+ if (!empty($arrayfields['t.'.$key]['checked']))
|
|
|
+ {
|
|
|
+ print '<td class="liste_titre'.($cssforfield ? ' '.$cssforfield : '').'">';
|
|
|
+ if (is_array($val['arrayofkeyval'])) print $form->selectarray('search_'.$key, $val['arrayofkeyval'], $search[$key], $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth75');
|
|
|
+ elseif (strpos($val['type'], 'integer:') === 0 || strpos($val['type'], 'sellist:') === 0) {
|
|
|
+ print $object->showInputField($val, $key, $search[$key], '', '', 'search_', 'maxwidth150', 1);
|
|
|
+ }
|
|
|
+ elseif (! preg_match('/^(date|timestamp)/', $val['type'])) print '<input type="text" class="flat maxwidth75" name="search_'.$key.'" value="'.dol_escape_htmltag($search[$key]).'">';
|
|
|
+ print '</td>';
|
|
|
+ }
|
|
|
}
|
|
|
-if (!empty($arrayfields['stockqty']['checked']))
|
|
|
-{
|
|
|
+
|
|
|
+if (!empty($arrayfields["stockqty"]['checked'])) {
|
|
|
print '<td class="liste_titre"></td>';
|
|
|
}
|
|
|
-if (!empty($arrayfields['estimatedvalue']['checked']))
|
|
|
-{
|
|
|
+
|
|
|
+if (!empty($arrayfields["estimatedvalue"]['checked'])) {
|
|
|
print '<td class="liste_titre"></td>';
|
|
|
}
|
|
|
-if (!empty($arrayfields['sellvalue']['checked']))
|
|
|
-{
|
|
|
+
|
|
|
+if (!empty($arrayfields["estimatedstockvaluesell"]['checked'])) {
|
|
|
print '<td class="liste_titre"></td>';
|
|
|
}
|
|
|
|
|
|
// Extra fields
|
|
|
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
|
|
|
+
|
|
|
// Fields from hook
|
|
|
$parameters = array('arrayfields'=>$arrayfields);
|
|
|
$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object); // Note that $action and $object may have been modified by hook
|
|
|
print $hookmanager->resPrint;
|
|
|
|
|
|
// Status
|
|
|
-if (!empty($arrayfields['e.statut']['checked']))
|
|
|
-{
|
|
|
+if (!empty($arrayfields['t.statut']['checked'])) {
|
|
|
print '<td class="liste_titre right">';
|
|
|
print $form->selectarray('search_status', $warehouse->statuts, $search_status, 1, 0, 0, '', 1);
|
|
|
print '</td>';
|
|
@@ -450,49 +468,30 @@ print '</tr>'."\n";
|
|
|
// --------------------------------------------------------------------
|
|
|
print '<tr class="liste_titre">';
|
|
|
|
|
|
-if (!empty($arrayfields['e.ref']['checked']))
|
|
|
-{
|
|
|
- print_liste_field_titre($arrayfields['e.ref']['label'], $_SERVER["PHP_SELF"], "e.ref", "", $param, "", $sortfield, $sortorder);
|
|
|
-}
|
|
|
-if (!empty($arrayfields['e.lieu']['checked']))
|
|
|
+foreach ($object->fields as $key => $val)
|
|
|
{
|
|
|
- print_liste_field_titre($arrayfields['e.lieu']['label'], $_SERVER["PHP_SELF"], "e.lieu", "", $param, "", $sortfield, $sortorder);
|
|
|
-}
|
|
|
-if (!empty($arrayfields['e.description']['checked']))
|
|
|
-{
|
|
|
- print_liste_field_titre($arrayfields['e.description']['label'], $_SERVER["PHP_SELF"], "e.description", "", $param, "", $sortfield, $sortorder);
|
|
|
-}
|
|
|
-if (!empty($arrayfields['e.address']['checked']))
|
|
|
-{
|
|
|
- print_liste_field_titre($arrayfields['e.address']['label'], $_SERVER["PHP_SELF"], "e.address", "", $param, "", $sortfield, $sortorder);
|
|
|
-}
|
|
|
-if (!empty($arrayfields['e.zip']['checked']))
|
|
|
-{
|
|
|
- print_liste_field_titre($arrayfields['e.zip']['label'], $_SERVER["PHP_SELF"], "e.zip", "", $param, "", $sortfield, $sortorder);
|
|
|
-}
|
|
|
-if (!empty($arrayfields['e.town']['checked']))
|
|
|
-{
|
|
|
- print_liste_field_titre($arrayfields['e.town']['label'], $_SERVER["PHP_SELF"], "e.town", "", $param, "", $sortfield, $sortorder);
|
|
|
-}
|
|
|
-if (!empty($arrayfields['e.phone']['checked']))
|
|
|
-{
|
|
|
- print_liste_field_titre($arrayfields['e.phone']['label'], $_SERVER["PHP_SELF"], "e.phone", "", $param, "", $sortfield, $sortorder);
|
|
|
-}
|
|
|
-if (!empty($arrayfields['e.fax']['checked']))
|
|
|
-{
|
|
|
- print_liste_field_titre($arrayfields['e.fax']['label'], $_SERVER["PHP_SELF"], "e.fax", "", $param, "", $sortfield, $sortorder);
|
|
|
+ if($key == 'statut'){ continue; }
|
|
|
+ $cssforfield = (empty($val['css']) ? '' : $val['css']);
|
|
|
+ if ($key == 'status') $cssforfield .= ($cssforfield ? ' ' : '').'center';
|
|
|
+ elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'center';
|
|
|
+ elseif (in_array($val['type'], array('timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
|
|
|
+ elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID') $cssforfield .= ($cssforfield ? ' ' : '').'right';
|
|
|
+ if (!empty($arrayfields['t.'.$key]['checked']))
|
|
|
+ {
|
|
|
+ print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($cssforfield ? 'class="'.$cssforfield.'"' : ''), $sortfield, $sortorder, ($cssforfield ? $cssforfield.' ' : ''))."\n";
|
|
|
+ }
|
|
|
}
|
|
|
-if (!empty($arrayfields['stockqty']['checked']))
|
|
|
-{
|
|
|
- print_liste_field_titre($arrayfields['stockqty']['label'], $_SERVER["PHP_SELF"], "stockqty", '', $param, '', $sortfield, $sortorder, 'right ');
|
|
|
+
|
|
|
+if (!empty($arrayfields["stockqty"]['checked'])) {
|
|
|
+ print_liste_field_titre("PhysicalStock", $_SERVER["PHP_SELF"], "stockqty", '', $param, '', $sortfield, $sortorder, 'right ');
|
|
|
}
|
|
|
-if (!empty($arrayfields['estimatedvalue']['checked']))
|
|
|
-{
|
|
|
- print_liste_field_titre($arrayfields['estimatedvalue']['label'], $_SERVER["PHP_SELF"], "estimatedvalue", '', $param, '', $sortfield, $sortorder, 'right ');
|
|
|
+
|
|
|
+if (!empty($arrayfields["estimatedvalue"]['checked'])) {
|
|
|
+ print_liste_field_titre("EstimatedStockValue", $_SERVER["PHP_SELF"], "estimatedvalue", '', $param, '', $sortfield, $sortorder, 'right ');
|
|
|
}
|
|
|
-if (!empty($arrayfields['sellvalue']['checked']))
|
|
|
-{
|
|
|
- print_liste_field_titre($arrayfields['sellvalue']['label'], $_SERVER["PHP_SELF"], "sellvalue", '', $param, '', $sortfield, $sortorder, 'right ');
|
|
|
+
|
|
|
+if (!empty($arrayfields["estimatedstockvaluesell"]['checked'])) {
|
|
|
+ print_liste_field_titre("EstimatedStockValueSell", $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder, 'right ');
|
|
|
}
|
|
|
|
|
|
// Extra fields
|
|
@@ -503,9 +502,8 @@ $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$
|
|
|
$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook
|
|
|
print $hookmanager->resPrint;
|
|
|
|
|
|
-if (!empty($arrayfields['e.statut']['checked']))
|
|
|
-{
|
|
|
- print_liste_field_titre($arrayfields['e.statut']['label'], $_SERVER["PHP_SELF"], "e.statut", '', $param, '', $sortfield, $sortorder, 'right ');
|
|
|
+if (!empty($arrayfields['t.statut']['checked'])) {
|
|
|
+ print_liste_field_titre($arrayfields['t.statut']['label'], $_SERVER["PHP_SELF"], "t.statut", '', $param, '', $sortfield, $sortorder, 'right ');
|
|
|
}
|
|
|
|
|
|
// Action column
|
|
@@ -515,12 +513,10 @@ print '</tr>'."\n";
|
|
|
// Loop on record
|
|
|
// --------------------------------------------------------------------
|
|
|
$i = 0;
|
|
|
-$totalarray = array();
|
|
|
if ($num)
|
|
|
{
|
|
|
$warehouse = new Entrepot($db);
|
|
|
|
|
|
- $totalarray = array();
|
|
|
while ($i < min($num, $limit))
|
|
|
{
|
|
|
$obj = $db->fetch_object($resql);
|
|
@@ -533,97 +529,69 @@ if ($num)
|
|
|
$warehouse->fk_parent = $obj->fk_parent;
|
|
|
$warehouse->statut = $obj->statut;
|
|
|
|
|
|
- // Show here line of result
|
|
|
- print '<tr class="oddeven">';
|
|
|
-
|
|
|
- //print_r($arrayfields[]);
|
|
|
-
|
|
|
- // Label (ref)
|
|
|
- if (!empty($arrayfields['e.ref']['checked']))
|
|
|
- {
|
|
|
- print '<td>'.$warehouse->getNomUrl(1).'</td>';
|
|
|
+ foreach ($object->fields as $key => $val){
|
|
|
+ $warehouse->{$key} = $obj->{$key};
|
|
|
}
|
|
|
|
|
|
- // Location
|
|
|
- if (!empty($arrayfields['e.lieu']['checked']))
|
|
|
- {
|
|
|
- print '<td>'.$obj->lieu.'</td>';
|
|
|
- }
|
|
|
|
|
|
- // Description
|
|
|
- if (!empty($arrayfields['e.description']['checked']))
|
|
|
- {
|
|
|
- print '<td>'.$obj->description.'</td>';
|
|
|
- }
|
|
|
-
|
|
|
- // Address
|
|
|
- if (!empty($arrayfields['e.address']['checked']))
|
|
|
- {
|
|
|
- print '<td>'.$obj->address.'</td>';
|
|
|
- }
|
|
|
+ // Show here line of result
|
|
|
+ print '<tr class="oddeven">';
|
|
|
|
|
|
- // Zip
|
|
|
- if (!empty($arrayfields['e.zip']['checked']))
|
|
|
+ foreach ($warehouse->fields as $key => $val)
|
|
|
{
|
|
|
- print '<td>'.$obj->zip.'</td>';
|
|
|
- }
|
|
|
+ if($key == 'statut'){ continue; }
|
|
|
+ $cssforfield = (empty($val['css']) ? '' : $val['css']);
|
|
|
+ if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'center';
|
|
|
+ elseif ($key == 'status') $cssforfield .= ($cssforfield ? ' ' : '').'center';
|
|
|
|
|
|
- if (!empty($arrayfields['e.town']['checked']))
|
|
|
- {
|
|
|
- print '<td>'.$obj->town.'</td>';
|
|
|
- }
|
|
|
+ if (in_array($val['type'], array('timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
|
|
|
+ elseif ($key == 'ref') $cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
|
|
|
|
|
|
- // Phone
|
|
|
- if (!empty($arrayfields['e.phone']['checked']))
|
|
|
- {
|
|
|
- print '<td>'.$obj->phone.'</td>';
|
|
|
- }
|
|
|
+ if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $key != 'status') $cssforfield .= ($cssforfield ? ' ' : '').'right';
|
|
|
|
|
|
- //Fax
|
|
|
- if (!empty($arrayfields['e.fax']['checked']))
|
|
|
- {
|
|
|
- print '<td>'.$obj->fax.'</td>';
|
|
|
+ if (!empty($arrayfields['t.'.$key]['checked']))
|
|
|
+ {
|
|
|
+ print '<td'.($cssforfield ? ' class="'.$cssforfield.'"' : '').'>';
|
|
|
+ if ($key == 'statut') print $warehouse->getLibStatut(5);
|
|
|
+ else print $warehouse->showOutputField($val, $key, $warehouse->$key, '');
|
|
|
+ print '</td>';
|
|
|
+ if (!$i) $totalarray['nbfield']++;
|
|
|
+ if (!empty($val['isameasure']))
|
|
|
+ {
|
|
|
+ if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 't.'.$key;
|
|
|
+ $totalarray['val']['t.'.$key] += $warehouse->$key;
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
// Stock qty
|
|
|
- if (!empty($arrayfields['stockqty']['checked']))
|
|
|
- {
|
|
|
- print '<td class="right">'.price2num($obj->stockqty, 5).'</td>';
|
|
|
+ if (!empty($arrayfields["stockqty"]['checked'])) {
|
|
|
+ print '<td class="right">' . price2num($obj->stockqty, 5) . '</td>';
|
|
|
+ if (!$i) $totalarray['nbfield']++;
|
|
|
+ if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'stockqty';
|
|
|
}
|
|
|
|
|
|
// PMP value
|
|
|
- if (!empty($arrayfields['estimatedvalue']['checked']))
|
|
|
- {
|
|
|
+ if (!empty($arrayfields["estimatedvalue"]['checked'])) {
|
|
|
print '<td class="right">';
|
|
|
-
|
|
|
- if (price2num($obj->estimatedvalue, 'MT'))
|
|
|
- {
|
|
|
- print price(price2num($obj->estimatedvalue, 'MT'), 1);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- print '';
|
|
|
- }
|
|
|
-
|
|
|
+ if (price2num($obj->estimatedvalue, 'MT')) print price(price2num($obj->estimatedvalue, 'MT'), 1);
|
|
|
+ else print '';
|
|
|
print '</td>';
|
|
|
+ if (!$i) $totalarray['nbfield']++;
|
|
|
+ if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'estimatedvalue';
|
|
|
}
|
|
|
|
|
|
// Selling value
|
|
|
- if (!empty($arrayfields['sellvalue']['checked']))
|
|
|
- {
|
|
|
+ if (!empty($arrayfields["estimatedstockvaluesell"]['checked'])) {
|
|
|
print '<td class="right">';
|
|
|
-
|
|
|
- if (empty($conf->global->PRODUIT_MULTIPRICES))
|
|
|
- {
|
|
|
- print price(price2num($obj->sellvalue, 'MT'), 1);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
+ if (empty($conf->global->PRODUIT_MULTIPRICES)) print price(price2num($obj->sellvalue, 'MT'), 1);
|
|
|
+ else {
|
|
|
$htmltext = $langs->trans("OptionMULTIPRICESIsOn");
|
|
|
print $form->textwithtooltip($langs->trans("Variable"), $htmltext);
|
|
|
}
|
|
|
-
|
|
|
print '</td>';
|
|
|
+ if (!$i) $totalarray['nbfield']++;
|
|
|
+ if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'estimatedstockvaluesell';
|
|
|
}
|
|
|
|
|
|
// Extra fields
|
|
@@ -634,9 +602,9 @@ if ($num)
|
|
|
print $hookmanager->resPrint;
|
|
|
|
|
|
// Status
|
|
|
- if (!empty($arrayfields['e.statut']['checked']))
|
|
|
- {
|
|
|
- print '<td class="right">'.$warehouse->LibStatut($obj->statut, 5).'</td>';
|
|
|
+ if (!empty($arrayfields['t.statut']['checked'])) {
|
|
|
+ print '<td class="right">' . $warehouse->LibStatut($obj->statut, 5) . '</td>';
|
|
|
+ if (!$i) $totalarray['nbfield']++;
|
|
|
}
|
|
|
|
|
|
// Action column
|
|
@@ -658,92 +626,8 @@ if ($num)
|
|
|
|
|
|
if ($totalnboflines - $offset <= $limit)
|
|
|
{
|
|
|
- print '<tr class="liste_total">';
|
|
|
-
|
|
|
- $emptyColumn = -1;
|
|
|
-
|
|
|
- if (!empty($arrayfields['e.ref']['checked']))
|
|
|
- {
|
|
|
- $emptyColumn++;
|
|
|
- }
|
|
|
- if (!empty($arrayfields['e.lieu']['checked']))
|
|
|
- {
|
|
|
- $emptyColumn++;
|
|
|
- }
|
|
|
- if (!empty($arrayfields['e.description']['checked']))
|
|
|
- {
|
|
|
- $emptyColumn++;
|
|
|
- }
|
|
|
- if (!empty($arrayfields['e.address']['checked']))
|
|
|
- {
|
|
|
- $emptyColumn++;
|
|
|
- }
|
|
|
- if (!empty($arrayfields['e.zip']['checked']))
|
|
|
- {
|
|
|
- $emptyColumn++;
|
|
|
- }
|
|
|
- if (!empty($arrayfields['e.town']['checked']))
|
|
|
- {
|
|
|
- $emptyColumn++;
|
|
|
- }
|
|
|
- if (!empty($arrayfields['e.phone']['checked']))
|
|
|
- {
|
|
|
- $emptyColumn++;
|
|
|
- }
|
|
|
- if (!empty($arrayfields['e.fax']['checked']))
|
|
|
- {
|
|
|
- $emptyColumn++;
|
|
|
- }
|
|
|
-
|
|
|
- for ($i=0; $i < $emptyColumn; $i++)
|
|
|
- {
|
|
|
- print '<td></td>';
|
|
|
- }
|
|
|
-
|
|
|
- print '<td class="right">'.$langs->trans("Total").'</td>';
|
|
|
-
|
|
|
- if (!empty($arrayfields['stockqty']['checked']))
|
|
|
- {
|
|
|
- print '<td class="right">'.price2num($totalStock, 5).'</td>';
|
|
|
- }
|
|
|
- if (!empty($arrayfields['estimatedvalue']['checked']))
|
|
|
- {
|
|
|
- print '<td class="right">'.price(price2num($total, 'MT'), 1, $langs, 0, 0, -1, $conf->currency).'</td>';
|
|
|
- }
|
|
|
-
|
|
|
- if (!empty($arrayfields['sellvalue']['checked']))
|
|
|
- {
|
|
|
- print '<td class="right">';
|
|
|
- if (empty($conf->global->PRODUIT_MULTIPRICES)) print price(price2num($totalsell, 'MT'), 1, $langs, 0, 0, -1, $conf->currency);
|
|
|
- else
|
|
|
- {
|
|
|
- $htmltext = $langs->trans("OptionMULTIPRICESIsOn");
|
|
|
- print $form->textwithtooltip($langs->trans("Variable"), $htmltext);
|
|
|
- }
|
|
|
- print '</td>';
|
|
|
- }
|
|
|
-
|
|
|
- if (empty($extrafieldsobjectkey) && is_object($object)) $extrafieldsobjectkey = $object->table_element;
|
|
|
- if (is_array($extrafields->attributes[$extrafieldsobjectkey]['label']) && count($extrafields->attributes[$extrafieldsobjectkey]['label']))
|
|
|
- {
|
|
|
- if (empty($extrafieldsobjectprefix)) $extrafieldsobjectprefix = 'ef.';
|
|
|
-
|
|
|
- foreach ($extrafields->attributes[$extrafieldsobjectkey]['label'] as $key => $val)
|
|
|
- {
|
|
|
- if (!empty($arrayfields[$extrafieldsobjectprefix.$key]['checked']))
|
|
|
- {
|
|
|
- print '<td></td>';
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- if (!empty($arrayfields['e.statut']['checked']))
|
|
|
- {
|
|
|
- print '<td></td>';
|
|
|
- }
|
|
|
-
|
|
|
- print '<td></td>';
|
|
|
- print "</tr>\n";
|
|
|
+ // Show total line
|
|
|
+ include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
|
|
|
}
|
|
|
}
|
|
|
|