|
@@ -43,17 +43,18 @@ $toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected
|
|
|
$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'bomlist'; // To manage different context of search
|
|
|
$backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page
|
|
|
$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print')
|
|
|
-$mode = GETPOST('mode', 'alpha'); // mode view (kanban or common)
|
|
|
+$mode = GETPOST('mode', 'aZ'); // mode view (kanban or common)
|
|
|
|
|
|
|
|
|
// Load variable for pagination
|
|
|
$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
|
|
|
$sortfield = GETPOST('sortfield', 'aZ09comma');
|
|
|
$sortorder = GETPOST('sortorder', 'aZ09comma');
|
|
|
-$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST('page', 'int');
|
|
|
-if (empty($page) || $page == -1 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha') || (empty($toselect) && $massaction === '0')) {
|
|
|
+$page = GETPOSTISSET('pageplusone') ? (GETPOSTINT('pageplusone') - 1) : GETPOSTINT('page');
|
|
|
+if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) {
|
|
|
+ // If $page is not defined, or '' or -1 or if we click on clear filters
|
|
|
$page = 0;
|
|
|
-} // If $page is not defined, or '' or -1 or if we click on clear filters or if we select empty mass action
|
|
|
+}
|
|
|
$offset = $limit * $page;
|
|
|
$pageprev = $page - 1;
|
|
|
$pagenext = $page + 1;
|
|
@@ -81,7 +82,7 @@ if (!$sortorder) {
|
|
|
}
|
|
|
|
|
|
// Initialize array of search criterias
|
|
|
-$search_all = GETPOST('search_all', 'alphanohtml');
|
|
|
+$search_all = trim(GETPOST('search_all', 'alphanohtml'));
|
|
|
$search = array();
|
|
|
foreach ($object->fields as $key => $val) {
|
|
|
if (GETPOST('search_'.$key, 'alpha') !== '') {
|
|
@@ -93,8 +94,8 @@ foreach ($object->fields as $key => $val) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-// List of fields to search into when doing a "search in all"
|
|
|
$fieldstosearchall = array();
|
|
|
+// List of fields to search into when doing a "search in all"
|
|
|
foreach ($object->fields as $key => $val) {
|
|
|
if (!empty($val['searchall'])) {
|
|
|
$fieldstosearchall['t.'.$key] = $val['label'];
|
|
@@ -288,8 +289,8 @@ $form = new Form($db);
|
|
|
|
|
|
$now = dol_now();
|
|
|
|
|
|
-$help_url = 'EN:Module_BOM';
|
|
|
$title = $langs->trans('ListOfBOMs');
|
|
|
+$help_url = 'EN:Module_BOM';
|
|
|
$morejs = array();
|
|
|
$morecss = array();
|
|
|
|
|
@@ -306,7 +307,7 @@ if (!empty($extrafields->attributes[$object->table_element]['label'])) {
|
|
|
}
|
|
|
// Add fields from hooks
|
|
|
$parameters = array();
|
|
|
-$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook
|
|
|
+$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
|
|
|
$sql .= $hookmanager->resPrint;
|
|
|
$sql = preg_replace('/,\s*$/', '', $sql);
|
|
|
|
|
@@ -318,10 +319,10 @@ if (isset($extrafields->attributes[$object->table_element]['label']) && is_array
|
|
|
}
|
|
|
// Add table from hooks
|
|
|
$parameters = array();
|
|
|
-$reshook = $hookmanager->executeHooks('printFieldListFrom', $parameters, $object); // Note that $action and $object may have been modified by hook
|
|
|
+$reshook = $hookmanager->executeHooks('printFieldListFrom', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
|
|
|
$sql .= $hookmanager->resPrint;
|
|
|
if ($object->ismultientitymanaged == 1) {
|
|
|
- $sql .= " WHERE t.entity IN (".getEntity($object->element).")";
|
|
|
+ $sql .= " WHERE t.entity IN (".getEntity($object->element, (GETPOST('search_current_entity', 'int') ? 0 : 1)).")";
|
|
|
} else {
|
|
|
$sql .= " WHERE 1 = 1";
|
|
|
}
|
|
@@ -363,7 +364,7 @@ if ($search_all) {
|
|
|
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
|
|
|
// Add where from hooks
|
|
|
$parameters = array();
|
|
|
-$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object); // Note that $action and $object may have been modified by hook
|
|
|
+$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
|
|
|
$sql .= $hookmanager->resPrint;
|
|
|
|
|
|
/* If a group by is required
|
|
@@ -377,9 +378,9 @@ if (!empty($extrafields->attributes[$object->table_element]['label'])) {
|
|
|
$sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key.', ' : '');
|
|
|
}
|
|
|
}
|
|
|
-// Add where from hooks
|
|
|
+// Add groupby from hooks
|
|
|
$parameters=array();
|
|
|
-$reshook=$hookmanager->executeHooks('printFieldListGroupBy', $parameters, $object); // Note that $action and $object may have been modified by hook
|
|
|
+$reshook = $hookmanager->executeHooks('printFieldListGroupBy', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
|
|
|
$sql.=$hookmanager->resPrint;
|
|
|
$sql=preg_replace('/,\s*$/','', $sql);
|
|
|
*/
|
|
@@ -398,7 +399,7 @@ if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) {
|
|
|
dol_print_error($db);
|
|
|
}
|
|
|
|
|
|
- if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0
|
|
|
+ if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller than the paging size (filtering), goto and load page 0
|
|
|
$page = 0;
|
|
|
$offset = 0;
|
|
|
}
|
|
@@ -420,10 +421,10 @@ if (!$resql) {
|
|
|
$num = $db->num_rows($resql);
|
|
|
|
|
|
// Direct jump if only one record found
|
|
|
-if ($num == 1 && getDolGlobalString('MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE') && $search_all && !$page) {
|
|
|
+if ($num == 1 && getDolGlobalInt('MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE') && $search_all && !$page) {
|
|
|
$obj = $db->fetch_object($resql);
|
|
|
$id = $obj->rowid;
|
|
|
- header("Location: ".DOL_URL_ROOT.'/bom/bom_card.php?id='.$id);
|
|
|
+ header("Location: ".DOL_URL_ROOT.'/bom/bom_card.php?id='.((int) $id));
|
|
|
exit;
|
|
|
}
|
|
|
|
|
@@ -431,7 +432,7 @@ if ($num == 1 && getDolGlobalString('MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE') && $s
|
|
|
// Output page
|
|
|
// --------------------------------------------------------------------
|
|
|
|
|
|
-llxHeader('', $title, $help_url, '', 0, 0, $morejs, $morecss, '', '');
|
|
|
+llxHeader('', $title, $help_url, '', 0, 0, $morejs, $morecss, '', 'mod-bom page-list bodyforlist');
|
|
|
|
|
|
$arrayofselected = is_array($toselect) ? $toselect : array();
|
|
|
|
|
@@ -445,6 +446,9 @@ if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
|
|
|
if ($limit > 0 && $limit != $conf->liste_limit) {
|
|
|
$param .= '&limit='.((int) $limit);
|
|
|
}
|
|
|
+if ($optioncss != '') {
|
|
|
+ $param .= '&optioncss='.urlencode($optioncss);
|
|
|
+}
|
|
|
foreach ($search as $key => $val) {
|
|
|
if (is_array($search[$key])) {
|
|
|
foreach ($search[$key] as $skey) {
|
|
@@ -460,14 +464,11 @@ foreach ($search as $key => $val) {
|
|
|
$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';
|
|
|
// Add $param from hooks
|
|
|
$parameters = array();
|
|
|
-$reshook = $hookmanager->executeHooks('printFieldListSearchParam', $parameters, $object); // Note that $action and $object may have been modified by hook
|
|
|
+$reshook = $hookmanager->executeHooks('printFieldListSearchParam', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
|
|
|
$param .= $hookmanager->resPrint;
|
|
|
|
|
|
// List of mass actions available
|
|
@@ -529,7 +530,7 @@ $moreforfilter.= $langs->trans('MyFilter') . ': <input type="text" name="search_
|
|
|
$moreforfilter.= '</div>';*/
|
|
|
|
|
|
$parameters = array();
|
|
|
-$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook
|
|
|
+$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
|
|
|
if (empty($reshook)) {
|
|
|
$moreforfilter .= $hookmanager->resPrint;
|
|
|
} else {
|
|
@@ -539,11 +540,14 @@ if (empty($reshook)) {
|
|
|
if (!empty($moreforfilter)) {
|
|
|
print '<div class="liste_titre liste_titre_bydiv centpercent">';
|
|
|
print $moreforfilter;
|
|
|
+ $parameters = array();
|
|
|
+ $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
|
|
|
+ print $hookmanager->resPrint;
|
|
|
print '</div>';
|
|
|
}
|
|
|
|
|
|
$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
|
|
|
-$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN', '')); // This also change content of $arrayfields
|
|
|
+$selectedfields = ($mode != 'kanban' ? $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN', '')) : ''); // This also change content of $arrayfields
|
|
|
$selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : '');
|
|
|
|
|
|
print '<div class="div-table-responsive">';
|
|
@@ -552,11 +556,11 @@ print '<table class="tagtable nobottomiftotal liste'.($moreforfilter ? " listwit
|
|
|
|
|
|
// Fields title search
|
|
|
// --------------------------------------------------------------------
|
|
|
-print '<tr class="liste_titre">';
|
|
|
+print '<tr class="liste_titre_filter">';
|
|
|
|
|
|
// Action column
|
|
|
if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
|
|
|
- print '<td class="liste_titre maxwidthsearch">';
|
|
|
+ print '<td class="liste_titre center maxwidthsearch">';
|
|
|
$searchpicto = $form->showFilterButtons('left');
|
|
|
print $searchpicto;
|
|
|
print '</td>';
|
|
@@ -577,9 +581,9 @@ foreach ($object->fields as $key => $val) {
|
|
|
if (!empty($arrayfields['t.'.$key]['checked'])) {
|
|
|
print '<td class="liste_titre'.($cssforfield ? ' '.$cssforfield : '').($key == 'status' ? ' parentonrightofpage' : '').'">';
|
|
|
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 width100 onrightofpage' : ''), 1);
|
|
|
+ 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);
|
|
|
} elseif ((strpos($val['type'], 'integer:') === 0) || (strpos($val['type'], 'sellist:') === 0)) {
|
|
|
- print $object->showInputField($val, $key, (isset($search[$key]) ? $search[$key] : ''), '', '', 'search_', 'maxwidth125', 1);
|
|
|
+ print $object->showInputField($val, $key, (isset($search[$key]) ? $search[$key] : ''), '', '', 'search_', $cssforfield.' maxwidth250', 1);
|
|
|
} elseif (!preg_match('/^(date|timestamp|datetime)/', $val['type'])) {
|
|
|
print '<input type="text" class="flat maxwidth75" name="search_'.$key.'" value="'.dol_escape_htmltag(isset($search[$key]) ? $search[$key] : '').'">';
|
|
|
} elseif (preg_match('/^(date|timestamp|datetime)/', $val['type'])) {
|
|
@@ -604,11 +608,11 @@ 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
|
|
|
+$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
|
|
|
print $hookmanager->resPrint;
|
|
|
// Action column
|
|
|
if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
|
|
|
- print '<td class="liste_titre maxwidthsearch">';
|
|
|
+ print '<td class="liste_titre center maxwidthsearch">';
|
|
|
$searchpicto = $form->showFilterButtons();
|
|
|
print $searchpicto;
|
|
|
print '</td>';
|
|
@@ -623,7 +627,8 @@ $totalarray['nbfield'] = 0;
|
|
|
print '<tr class="liste_titre">';
|
|
|
// Action column
|
|
|
if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
|
|
|
- print getTitleFieldOfList(($mode != 'kanban' ? $selectedfields : ''), 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
|
|
|
+ print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
|
|
|
+ $totalarray['nbfield']++;
|
|
|
}
|
|
|
foreach ($object->fields as $key => $val) {
|
|
|
$cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']);
|
|
@@ -638,7 +643,7 @@ foreach ($object->fields as $key => $val) {
|
|
|
}
|
|
|
$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";
|
|
|
+ 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";
|
|
|
$totalarray['nbfield']++;
|
|
|
}
|
|
|
}
|
|
@@ -646,13 +651,13 @@ foreach ($object->fields as $key => $val) {
|
|
|
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
|
|
|
// Hook fields
|
|
|
$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
|
|
|
+$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
|
|
|
print $hookmanager->resPrint;
|
|
|
// Action column
|
|
|
if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
|
|
|
print getTitleFieldOfList(($mode != 'kanban' ? $selectedfields : ''), 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
|
|
|
+ $totalarray['nbfield']++;
|
|
|
}
|
|
|
-$totalarray['nbfield']++; // For the column action
|
|
|
print '</tr>'."\n";
|
|
|
|
|
|
|
|
@@ -712,7 +717,7 @@ while ($i < $imaxinloop) {
|
|
|
print '</td></tr>';
|
|
|
}
|
|
|
} else {
|
|
|
- // Show here line of result
|
|
|
+ // Show line of result
|
|
|
$j = 0;
|
|
|
print '<tr data-rowid="'.$object->id.'" class="oddeven">';
|
|
|
// Action column
|
|
@@ -726,6 +731,9 @@ while ($i < $imaxinloop) {
|
|
|
print '<input id="cb'.$object->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.'"'.($selected ? ' checked="checked"' : '').'>';
|
|
|
}
|
|
|
print '</td>';
|
|
|
+ if (!$i) {
|
|
|
+ $totalarray['nbfield']++;
|
|
|
+ }
|
|
|
}
|
|
|
foreach ($object->fields as $key => $val) {
|
|
|
$cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']);
|
|
@@ -736,18 +744,18 @@ while ($i < $imaxinloop) {
|
|
|
}
|
|
|
|
|
|
if (in_array($val['type'], array('timestamp'))) {
|
|
|
- $cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
|
|
|
+ $cssforfield .= ($cssforfield ? ' ' : '').'nowraponall';
|
|
|
} elseif ($key == 'ref') {
|
|
|
- $cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
|
|
|
+ $cssforfield .= ($cssforfield ? ' ' : '').'nowraponall';
|
|
|
}
|
|
|
|
|
|
- if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && !in_array($key, array('rowid', 'status')) && empty($val['arrayofkeyval'])) {
|
|
|
+ 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'])) {
|
|
|
$cssforfield .= ($cssforfield ? ' ' : '').'right';
|
|
|
}
|
|
|
|
|
|
if (!empty($arrayfields['t.'.$key]['checked'])) {
|
|
|
print '<td'.($cssforfield ? ' class="'.$cssforfield.(preg_match('/tdoverflow/', $cssforfield) ? ' classfortooltip' : '').'"' : '');
|
|
|
- if (preg_match('/tdoverflow/', $cssforfield) && !is_numeric($object->$key)) {
|
|
|
+ if (preg_match('/tdoverflow/', $cssforfield) && !in_array($val['type'], array('ip', 'url')) && !is_numeric($object->$key)) {
|
|
|
print ' title="'.dol_escape_htmltag($object->$key).'"';
|
|
|
}
|
|
|
print '>';
|
|
@@ -780,7 +788,7 @@ while ($i < $imaxinloop) {
|
|
|
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
|
|
|
// Fields from hook
|
|
|
$parameters = array('arrayfields'=>$arrayfields, 'object'=>$object, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray);
|
|
|
- $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook
|
|
|
+ $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
|
|
|
print $hookmanager->resPrint;
|
|
|
// Action column
|
|
|
if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
|
|
@@ -793,9 +801,9 @@ while ($i < $imaxinloop) {
|
|
|
print '<input id="cb'.$object->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.'"'.($selected ? ' checked="checked"' : '').'>';
|
|
|
}
|
|
|
print '</td>';
|
|
|
- }
|
|
|
- if (!$i) {
|
|
|
- $totalarray['nbfield']++;
|
|
|
+ if (!$i) {
|
|
|
+ $totalarray['nbfield']++;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
print '</tr>'."\n";
|