diff --git a/htdocs/bom/bom_list.php b/htdocs/bom/bom_list.php
index 1cb4946715a..601eb9b75b3 100644
--- a/htdocs/bom/bom_list.php
+++ b/htdocs/bom/bom_list.php
@@ -72,6 +72,7 @@ $search_array_options = $extrafields->getOptionalsFromPost($object->table_elemen
// Default sort order (if not yet defined by previous GETPOST)
if (!$sortfield) {
+ reset($object->fields); // Reset is required to avoid key() to return null.
$sortfield = "t.".key($object->fields); // Set here default search field. By default 1st field in definition.
}
if (!$sortorder) {
@@ -79,7 +80,7 @@ if (!$sortorder) {
}
// Initialize array of search criterias
-$search_all = GETPOST("search_all", 'alpha');
+$search_all = GETPOST('search_all', 'alphanohtml');
$search = array();
foreach ($object->fields as $key => $val) {
if (GETPOST('search_'.$key, 'alpha') !== '') {
@@ -108,7 +109,7 @@ foreach ($object->fields as $key => $val) {
$arrayfields['t.'.$key] = array(
'label'=>$val['label'],
'checked'=>(($visible < 0) ? 0 : 1),
- 'enabled'=>($visible != 3 && dol_eval($val['enabled'], 1, 1, '1')),
+ 'enabled'=>(abs($visible) != 3 && dol_eval($val['enabled'], 1)),
'position'=>$val['position'],
'help'=> isset($val['help']) ? $val['help'] : ''
);
@@ -299,7 +300,7 @@ $sql .= $object->getFieldList('t');
// 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.' ' : '');
+ $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key." as options_".$key : '');
}
}
// Add fields from hooks
@@ -336,17 +337,17 @@ foreach ($search as $key => $val) {
$mode_search = 2;
}
if ($search[$key] != '') {
- $sql .= natural_search($key, $search[$key], (($key == 'status') ? 2 : $mode_search));
+ $sql .= natural_search("t.".$db->escape($key), $search[$key], (($key == 'status') ? 2 : $mode_search));
}
} else {
if (preg_match('/(_dtstart|_dtend)$/', $key) && $search[$key] != '') {
$columnName=preg_replace('/(_dtstart|_dtend)$/', '', $key);
if (preg_match('/^(date|timestamp|datetime)/', $object->fields[$columnName]['type'])) {
if (preg_match('/_dtstart$/', $key)) {
- $sql .= " AND t." . $columnName . " >= '" . $db->idate($search[$key]) . "'";
+ $sql .= " AND t.".$db->escape($columnName)." >= '".$db->idate($search[$key])."'";
}
if (preg_match('/_dtend$/', $key)) {
- $sql .= " AND t." . $columnName . " <= '" . $db->idate($search[$key]) . "'";
+ $sql .= " AND t.".$db->escape($columnName)." <= '".$db->idate($search[$key])."'";
}
}
}
@@ -366,9 +367,8 @@ $sql .= $hookmanager->resPrint;
/* If a group by is required
$sql.= " GROUP BY ";
-foreach($object->fields as $key => $val)
-{
- $sql .= "t.".$key.", ";
+foreach($object->fields as $key => $val) {
+ $sql .= "t.".$db->escape($key).", ";
}
// Add fields from extrafields
if (!empty($extrafields->attributes[$object->table_element]['label'])) {
@@ -445,11 +445,17 @@ if ($limit > 0 && $limit != $conf->liste_limit) {
$param .= '&limit='.urlencode($limit);
}
foreach ($search as $key => $val) {
- if (is_array($search[$key]) && count($search[$key])) {
+ if (is_array($search[$key])) {
foreach ($search[$key] as $skey) {
- $param .= '&search_'.$key.'[]='.urlencode($skey);
+ if ($skey != '') {
+ $param .= '&search_'.$key.'[]='.urlencode($skey);
+ }
}
- } else {
+ } elseif (preg_match('/(_dtstart|_dtend)$/', $key) && !empty($val)) {
+ $param .= '&search_'.$key.'month='.((int) GETPOST('search_'.$key.'month', 'int'));
+ $param .= '&search_'.$key.'day='.((int) GETPOST('search_'.$key.'day', 'int'));
+ $param .= '&search_'.$key.'year='.((int) GETPOST('search_'.$key.'year', 'int'));
+ } elseif ($search[$key] != '') {
$param .= '&search_'.$key.'='.urlencode($search[$key]);
}
}
@@ -469,7 +475,7 @@ $arrayofmassactions = array(
'enable'=>img_picto('', 'check', 'class="pictofixedwidth"').$langs->trans("Enable"),
'disable'=>img_picto('', 'close_title', 'class="pictofixedwidth"').$langs->trans("Disable"),
);
-if ($permissiontodelete) {
+if (!empty($permissiontodelete)) {
$arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete");
}
if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) {
@@ -488,6 +494,7 @@ print ' ';
print ' ';
print ' ';
print ' ';
+print ' ';
print ' ';
$newcardbutton = '';
@@ -505,10 +512,13 @@ $trackid = 'bom'.$object->id;
include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
if ($search_all) {
+ $setupstring = '';
foreach ($fieldstosearchall as $key => $val) {
$fieldstosearchall[$key] = $langs->trans($val);
+ $setupstring .= $key."=".$val.";";
}
- print '
'.$langs->trans("FilterOnInto", $search_all).join(', ', $fieldstosearchall).'
';
+ print ''."\n";
+ print ''.$langs->trans("FilterOnInto", $search_all).join(', ', $fieldstosearchall).'
'."\n";
}
$moreforfilter = '';
@@ -544,13 +554,14 @@ print '';
// Action column
if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
- print '';
+ print ' ';
$searchpicto = $form->showFilterButtons('left');
print $searchpicto;
print ' ';
}
foreach ($object->fields as $key => $val) {
+ $searchkey = empty($search[$key]) ? '' : $search[$key];
$cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']);
if ($key == 'status') {
$cssforfield .= ($cssforfield ? ' ' : '').'center';
@@ -558,13 +569,13 @@ foreach ($object->fields as $key => $val) {
$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' && empty($val['arrayofkeyval'])) {
+ } elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $key != 'rowid' && $val['label'] != 'TechnicalID' && empty($val['arrayofkeyval'])) {
$cssforfield .= ($cssforfield ? ' ' : '').'right';
}
if (!empty($arrayfields['t.'.$key]['checked'])) {
print '';
if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) {
- print $form->selectarray('search_'.$key, $val['arrayofkeyval'], (isset($search[$key]) ? $search[$key] : ''), $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth100'.($key == 'status' ? ' search_status onrightofpage' : ''), 1);
+ print $form->selectarray('search_'.$key, $val['arrayofkeyval'], (isset($search[$key]) ? $search[$key] : ''), $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth100'.($key == 'status' ? ' search_status width100 onrightofpage' : ''), 1);
} elseif ((strpos($val['type'], 'integer:') === 0) || (strpos($val['type'], 'sellist:') === 0)) {
print $object->showInputField($val, $key, (isset($search[$key]) ? $search[$key] : ''), '', '', 'search_', 'maxwidth125', 1);
} elseif (!preg_match('/^(date|timestamp|datetime)/', $val['type'])) {
@@ -576,6 +587,12 @@ foreach ($object->fields as $key => $val) {
print '';
print $form->selectDate($search[$key.'_dtend'] ? $search[$key.'_dtend'] : '', "search_".$key."_dtend", 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
print '
';
+ } elseif ($key == 'lang') {
+ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php';
+ $formadmin = new FormAdmin($db);
+ print $formadmin->select_language($search[$key], 'search_lang', 0, null, 1, 0, 0, 'minwidth150 maxwidth200', 2);
+ } else {
+ print ' ';
}
print ' ';
}
@@ -589,20 +606,22 @@ $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $obje
print $hookmanager->resPrint;
// Action column
if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
- print '';
+ print ' ';
$searchpicto = $form->showFilterButtons();
print $searchpicto;
print ' ';
}
print ' '."\n";
+$totalarray = array();
+$totalarray['nbfield'] = 0;
// Fields title label
// --------------------------------------------------------------------
print '';
// Action column
if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
- print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
+ print getTitleFieldOfList(($mode != 'kanban' ? $selectedfields : ''), 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
}
foreach ($object->fields as $key => $val) {
$cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']);
@@ -612,23 +631,26 @@ foreach ($object->fields as $key => $val) {
$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' && empty($val['arrayofkeyval'])) {
+ } elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $key != 'rowid' && $val['label'] != 'TechnicalID' && empty($val['arrayofkeyval'])) {
$cssforfield .= ($cssforfield ? ' ' : '').'right';
}
+ $cssforfield = preg_replace('/small\s*/', '', $cssforfield); // the 'small' css must not be used for the title label
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";
+ $totalarray['nbfield']++;
}
}
// Extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
// Hook fields
-$parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder);
+$parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder, 'totalarray'=>&$totalarray);
$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
// Action column
if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
- print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
+ print getTitleFieldOfList(($mode != 'kanban' ? $selectedfields : ''), 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
}
+$totalarray['nbfield']++; // For the column action
print ' '."\n";
@@ -646,9 +668,11 @@ if (isset($extrafields->attributes[$object->table_element]['computed']) && is_ar
// Loop on record
// --------------------------------------------------------------------
$i = 0;
+$savnbfield = $totalarray['nbfield'];
$totalarray = array();
$totalarray['nbfield'] = 0;
-while ($i < ($limit ? min($num, $limit) : $num)) {
+$imaxinloop = ($limit ? min($num, $limit) : $num);
+while ($i < $imaxinloop) {
$obj = $db->fetch_object($resql);
if (empty($obj)) {
break; // Should not happen
@@ -660,20 +684,19 @@ while ($i < ($limit ? min($num, $limit) : $num)) {
// mode view kanban
if ($mode == 'kanban') {
if ($i == 0) {
- print '';
+ print ' ';
print '';
}
-
+ // Output kanban
print $object->getKanbanView('');
-
-
- if ($i == min($num, $limit)-1) {
+ if ($i == ($imaxinloop - 1)) {
print '
';
print ' ';
}
} else {
// Show here line of result
- print '';
+ $j = 0;
+ print ' ';
// Action column
if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
print '';
@@ -705,7 +728,11 @@ while ($i < ($limit ? min($num, $limit) : $num)) {
}
if (!empty($arrayfields['t.'.$key]['checked'])) {
- print ' ';
+ print ' ';
if ($key == 'status') {
print $object->getLibStatut(5);
} elseif ($key == 'rowid') {
@@ -754,9 +781,9 @@ while ($i < ($limit ? min($num, $limit) : $num)) {
}
print ' '."\n";
-
- $i++;
}
+
+ $i++;
}
// Show total line
@@ -771,14 +798,14 @@ if ($num == 0) {
$colspan++;
}
}
- print ''.$langs->trans("NoRecordFound").' ';
+ print ''.$langs->trans("NoRecordFound").' ';
}
$db->free($resql);
$parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql);
-$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object); // Note that $action and $object may have been modified by hook
+$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
print ''."\n";
diff --git a/htdocs/modulebuilder/template/myobject_list.php b/htdocs/modulebuilder/template/myobject_list.php
index 5ff0628bc8f..b28a7a5f955 100644
--- a/htdocs/modulebuilder/template/myobject_list.php
+++ b/htdocs/modulebuilder/template/myobject_list.php
@@ -136,7 +136,7 @@ if (!$sortorder) {
}
// Initialize array of search criterias
-$search_all = GETPOST('search_all', 'alphanohtml') ? GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml');
+$search_all = GETPOST('search_all', 'alphanohtml');
$search = array();
foreach ($object->fields as $key => $val) {
if (GETPOST('search_'.$key, 'alpha') !== '') {
@@ -552,7 +552,7 @@ print '';
// Action column
-if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) {
+if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
print '';
$searchpicto = $form->showFilterButtons('left');
print $searchpicto;
@@ -604,7 +604,7 @@ print $hookmanager->resPrint;
print ' ';
}*/
// Action column
-if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) {
+if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
print '';
$searchpicto = $form->showFilterButtons();
print $searchpicto;
@@ -618,7 +618,7 @@ $totalarray['nbfield'] = 0;
// Fields title label
// --------------------------------------------------------------------
print ' ';
-if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) {
+if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
print getTitleFieldOfList(($mode != 'kanban' ? $selectedfields : ''), 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
}
foreach ($object->fields as $key => $val) {
@@ -649,7 +649,7 @@ print $hookmanager->resPrint;
$totalarray['nbfield']++;
}*/
// Action column
-if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) {
+if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
print getTitleFieldOfList(($mode != 'kanban' ? $selectedfields : ''), 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
}
$totalarray['nbfield']++; // For the column action
@@ -699,7 +699,7 @@ while ($i < $imaxinloop) {
$j = 0;
print ' ';
// Action column
- if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) {
+ if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
print '';
if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
$selected = 0;
@@ -770,7 +770,7 @@ while ($i < $imaxinloop) {
print ' '.$obj->anotherfield.' ';
}*/
// Action column
- if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) {
+ if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
print '';
if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
$selected = 0;