|
|
|
|
@@ -33,7 +33,7 @@ require_once DOL_DOCUMENT_ROOT.'/asset/class/asset.class.php';
|
|
|
|
|
// Load translation files required by the page
|
|
|
|
|
$langs->loadLangs(array("assets"));
|
|
|
|
|
|
|
|
|
|
$action = GETPOST('action', 'alpha') ?GETPOST('action', 'alpha') : 'view'; // The action 'add', 'create', 'edit', 'update', 'view', ...
|
|
|
|
|
$action = GETPOST('action', 'aZ09') ?GETPOST('action', 'aZ09') : 'view'; // The action 'add', 'create', 'edit', 'update', 'view', ...
|
|
|
|
|
$massaction = GETPOST('massaction', 'alpha'); // The bulk action (combo box choice into lists)
|
|
|
|
|
$show_files = GETPOST('show_files', 'int'); // Show files area generated by bulk actions ?
|
|
|
|
|
$confirm = GETPOST('confirm', 'alpha'); // Result of a confirmation
|
|
|
|
|
@@ -50,7 +50,7 @@ $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
|
|
|
|
|
$sortfield = GETPOST('sortfield', 'alpha');
|
|
|
|
|
$sortorder = GETPOST('sortorder', 'alpha');
|
|
|
|
|
$page = GETPOST('page', 'int');
|
|
|
|
|
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
|
|
|
|
|
if (empty($page) || $page == -1 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha') || (empty($toselect) && $massaction === '0')) { $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;
|
|
|
|
|
@@ -63,6 +63,7 @@ $hookmanager->initHooks(array('assetlist')); // Note that conf->hooks_modules co
|
|
|
|
|
|
|
|
|
|
// Fetch optionals attributes and labels
|
|
|
|
|
$extrafields->fetch_name_optionals_label($object->table_element);
|
|
|
|
|
//$extrafields->fetch_name_optionals_label($object->table_element_line);
|
|
|
|
|
|
|
|
|
|
$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
|
|
|
|
|
|
|
|
|
|
@@ -70,9 +71,9 @@ $search_array_options = $extrafields->getOptionalsFromPost($object->table_elemen
|
|
|
|
|
if (!$sortfield) $sortfield = "t.".key($object->fields); // Set here default search field. By default 1st field in definition.
|
|
|
|
|
if (!$sortorder) $sortorder = "ASC";
|
|
|
|
|
|
|
|
|
|
// Protection if external user
|
|
|
|
|
// Security check
|
|
|
|
|
$socid = 0;
|
|
|
|
|
if ($user->socid > 0)
|
|
|
|
|
if ($user->socid > 0) // Protection if external user
|
|
|
|
|
{
|
|
|
|
|
//$socid = $user->socid;
|
|
|
|
|
accessforbidden();
|
|
|
|
|
@@ -84,7 +85,7 @@ $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');
|
|
|
|
|
if (GETPOST('search_'.$key, 'alpha') !== '') $search[$key] = GETPOST('search_'.$key, 'alpha');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// List of fields to search into when doing a "search in all"
|
|
|
|
|
@@ -99,26 +100,33 @@ $arrayfields = array();
|
|
|
|
|
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'], 'position'=>$val['position']);
|
|
|
|
|
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');
|
|
|
|
|
|
|
|
|
|
$permissiontoread = $user->rights->asset->read;
|
|
|
|
|
$permissiontoadd = $user->rights->asset->write;
|
|
|
|
|
$permissiontodelete = $user->rights->asset->delete;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Actions
|
|
|
|
|
*
|
|
|
|
|
* Put here all code to do according to value of "$action" parameter
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; }
|
|
|
|
|
@@ -152,8 +160,6 @@ if (empty($reshook))
|
|
|
|
|
// Mass actions
|
|
|
|
|
$objectclass = 'Asset';
|
|
|
|
|
$objectlabel = 'Asset';
|
|
|
|
|
$permissiontoread = $user->rights->asset->read;
|
|
|
|
|
$permissiontodelete = $user->rights->asset->delete;
|
|
|
|
|
$uploaddir = $conf->asset->dir_output;
|
|
|
|
|
include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
|
|
|
|
|
}
|
|
|
|
|
@@ -162,8 +168,6 @@ if (empty($reshook))
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* View
|
|
|
|
|
*
|
|
|
|
|
* Put here all code to render page
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
$form = new Form($db);
|
|
|
|
|
@@ -183,23 +187,30 @@ foreach ($object->fields as $key => $val)
|
|
|
|
|
$sql .= 't.'.$key.', ';
|
|
|
|
|
}
|
|
|
|
|
// Add fields from extrafields
|
|
|
|
|
if (!empty($extrafields->attributes[$object->table_element]['label']))
|
|
|
|
|
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.', ' : '');
|
|
|
|
|
}
|
|
|
|
|
// 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('/^,/', '', $hookmanager->resPrint);
|
|
|
|
|
$sql = preg_replace('/,\s*$/', '', $sql);
|
|
|
|
|
$sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t";
|
|
|
|
|
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)";
|
|
|
|
|
if ($object->ismultientitymanaged == 1) $sql .= " WHERE t.entity IN (".getEntity('assets').")";
|
|
|
|
|
if ($object->ismultientitymanaged == 1) $sql .= " WHERE t.entity IN (".getEntity($object->element).")";
|
|
|
|
|
else $sql .= " WHERE 1 = 1";
|
|
|
|
|
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_all) $sql .= natural_search(array_keys($fieldstosearchall), $search_all);
|
|
|
|
|
//$sql.= dolSqlDateFilter("t.field", $search_xxxday, $search_xxxmonth, $search_xxxyear);
|
|
|
|
|
// Add where from extra fields
|
|
|
|
|
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
|
|
|
|
|
// Add where from hooks
|
|
|
|
|
@@ -216,10 +227,12 @@ foreach($object->fields as $key => $val)
|
|
|
|
|
// 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);
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
$sql .= $db->order($sortfield, $sortorder);
|
|
|
|
|
@@ -228,28 +241,35 @@ $sql .= $db->order($sortfield, $sortorder);
|
|
|
|
|
$nbtotalofrecords = '';
|
|
|
|
|
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
|
|
|
|
|
{
|
|
|
|
|
$result = $db->query($sql);
|
|
|
|
|
$nbtotalofrecords = $db->num_rows($result);
|
|
|
|
|
if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0
|
|
|
|
|
$resql = $db->query($sql);
|
|
|
|
|
$nbtotalofrecords = $db->num_rows($resql);
|
|
|
|
|
if (($page * $limit) > $nbtotalofrecords) // if total of record found is smaller than page * limit, goto and load page 0
|
|
|
|
|
{
|
|
|
|
|
$page = 0;
|
|
|
|
|
$offset = 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$sql .= $db->plimit($limit + 1, $offset);
|
|
|
|
|
|
|
|
|
|
$resql = $db->query($sql);
|
|
|
|
|
if (!$resql)
|
|
|
|
|
// if total of record found is smaller than limit, no need to do paging and to restart another select with limits set.
|
|
|
|
|
if (is_numeric($nbtotalofrecords) && ($limit > $nbtotalofrecords || empty($limit)))
|
|
|
|
|
{
|
|
|
|
|
dol_print_error($db);
|
|
|
|
|
exit;
|
|
|
|
|
$num = $nbtotalofrecords;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if ($limit) $sql .= $db->plimit($limit + 1, $offset);
|
|
|
|
|
|
|
|
|
|
$resql = $db->query($sql);
|
|
|
|
|
if (!$resql)
|
|
|
|
|
{
|
|
|
|
|
dol_print_error($db);
|
|
|
|
|
exit;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$num = $db->num_rows($resql);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$num = $db->num_rows($resql);
|
|
|
|
|
|
|
|
|
|
// Direct jump if only one record found
|
|
|
|
|
if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all)
|
|
|
|
|
if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all && !$page)
|
|
|
|
|
{
|
|
|
|
|
$obj = $db->fetch_object($resql);
|
|
|
|
|
$id = $obj->rowid;
|
|
|
|
|
@@ -285,7 +305,8 @@ if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&co
|
|
|
|
|
if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit);
|
|
|
|
|
foreach ($search as $key => $val)
|
|
|
|
|
{
|
|
|
|
|
$param .= '&search_'.$key.'='.urlencode($search[$key]);
|
|
|
|
|
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
|
|
|
|
|
@@ -296,19 +317,11 @@ $arrayofmassactions = array(
|
|
|
|
|
//'presend'=>$langs->trans("SendByMail"),
|
|
|
|
|
//'builddoc'=>$langs->trans("PDFMerge"),
|
|
|
|
|
);
|
|
|
|
|
if ($user->rights->asset->delete) $arrayofmassactions['predelete'] = '<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete");
|
|
|
|
|
if (in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array();
|
|
|
|
|
if ($permissiontodelete) $arrayofmassactions['predelete'] = '<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete");
|
|
|
|
|
if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array();
|
|
|
|
|
$massactionbutton = $form->selectMassAction('', $arrayofmassactions);
|
|
|
|
|
|
|
|
|
|
$newcardbutton = '';
|
|
|
|
|
if ($user->rights->asset->write)
|
|
|
|
|
{
|
|
|
|
|
$newcardbutton = '<a class="butActionNew" href="'.DOL_URL_ROOT.'/asset/card.php?action=create"><span class="valignmiddle text-plus-circle">'.$langs->trans('NewAsset').'</span>';
|
|
|
|
|
$newcardbutton .= '<span class="fa fa-plus-circle valignmiddle"></span>';
|
|
|
|
|
$newcardbutton .= '</a>';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">';
|
|
|
|
|
print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'."\n";
|
|
|
|
|
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
|
|
|
|
|
print '<input type="hidden" name="token" value="'.newToken().'">';
|
|
|
|
|
print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
|
|
|
|
|
@@ -318,6 +331,8 @@ print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
|
|
|
|
|
print '<input type="hidden" name="page" value="'.$page.'">';
|
|
|
|
|
print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
|
|
|
|
|
|
|
|
|
|
$newcardbutton = dolGetButtonTitle($langs->trans('NewAsset'), '', 'fa fa-plus-circle', dol_buildpath('/asset/card.php', 1).'?action=create&backtopage='.urlencode($_SERVER['PHP_SELF']), '', $permissiontoadd);
|
|
|
|
|
|
|
|
|
|
print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'accountancy', 0, $newcardbutton, '', $limit);
|
|
|
|
|
|
|
|
|
|
// Add code for pre mass action (confirmation or email presend form)
|
|
|
|
|
@@ -363,11 +378,21 @@ print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" :
|
|
|
|
|
print '<tr class="liste_titre">';
|
|
|
|
|
foreach ($object->fields as $key => $val)
|
|
|
|
|
{
|
|
|
|
|
$align = '';
|
|
|
|
|
if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $align .= ($align ? ' ' : '').'center';
|
|
|
|
|
if (in_array($val['type'], array('timestamp'))) $align .= ($align ? ' ' : '').'nowrap';
|
|
|
|
|
if ($key == 'status') $align .= ($align ? ' ' : '').'center';
|
|
|
|
|
if (!empty($arrayfields['t.'.$key]['checked'])) print '<td class="liste_titre'.($align ? ' '.$align : '').'"><input type="text" class="flat maxwidth75" name="search_'.$key.'" value="'.dol_escape_htmltag($search[$key]).'"></td>';
|
|
|
|
|
$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) {
|
|
|
|
|
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>';
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// Extra fields
|
|
|
|
|
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
|
|
|
|
|
@@ -389,11 +414,15 @@ print '</tr>'."\n";
|
|
|
|
|
print '<tr class="liste_titre">';
|
|
|
|
|
foreach($object->fields as $key => $val)
|
|
|
|
|
{
|
|
|
|
|
$align='';
|
|
|
|
|
if (in_array($val['type'], array('date','datetime','timestamp'))) $align.=($align?' ':'').'center';
|
|
|
|
|
if (in_array($val['type'], array('timestamp'))) $align.=($align?' ':'').'nowrap';
|
|
|
|
|
if ($key == 'status') $align.=($align?' ':'').'center';
|
|
|
|
|
if (! empty($arrayfields['t.'.$key]['checked'])) print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($align?'class="'.$align.'"':''), $sortfield, $sortorder, $align.' ')."\n";
|
|
|
|
|
$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";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// Extra fields
|
|
|
|
|
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
|
|
|
|
|
@@ -401,19 +430,19 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
|
|
|
|
|
$parameters=array('arrayfields'=>$arrayfields,'param'=>$param,'sortfield'=>$sortfield,'sortorder'=>$sortorder);
|
|
|
|
|
$reshook=$hookmanager->executeHooks('printFieldListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook
|
|
|
|
|
print $hookmanager->resPrint;
|
|
|
|
|
// Action column
|
|
|
|
|
print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', 'align="center"', $sortfield, $sortorder, 'maxwidthsearch ')."\n";
|
|
|
|
|
print '</tr>'."\n";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Detect if we need a fetch on each output line
|
|
|
|
|
$needToFetchEachLine=0;
|
|
|
|
|
if (is_array($extrafields->attributes[$object->table_element]['computed'])) {
|
|
|
|
|
foreach ($extrafields->attributes[$object->table_element]['computed'] as $key => $val) {
|
|
|
|
|
if (preg_match('/\$object/', $val)) {
|
|
|
|
|
// There is at least one compute field that use $object
|
|
|
|
|
$needToFetchEachLine++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (is_array($extrafields->attributes[$object->table_element]['computed']) && count($extrafields->attributes[$object->table_element]['computed']) > 0)
|
|
|
|
|
{
|
|
|
|
|
foreach ($extrafields->attributes[$object->table_element]['computed'] as $key => $val)
|
|
|
|
|
{
|
|
|
|
|
if (preg_match('/\$object/', $val)) $needToFetchEachLine++; // There is at least one compute field that use $object
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -421,84 +450,65 @@ if (is_array($extrafields->attributes[$object->table_element]['computed'])) {
|
|
|
|
|
// --------------------------------------------------------------------
|
|
|
|
|
$i=0;
|
|
|
|
|
$totalarray=array();
|
|
|
|
|
while ($i < min($num, $limit))
|
|
|
|
|
while ($i < ($limit ? min($num, $limit) : $num))
|
|
|
|
|
{
|
|
|
|
|
$obj = $db->fetch_object($resql);
|
|
|
|
|
if (empty($obj)) break; // Should not happen
|
|
|
|
|
|
|
|
|
|
// Store properties in $object
|
|
|
|
|
$object->id = $obj->rowid;
|
|
|
|
|
foreach($object->fields as $key => $val)
|
|
|
|
|
{
|
|
|
|
|
if (property_exists($obj, $key)) $object->$key = $obj->$key;
|
|
|
|
|
}
|
|
|
|
|
$object->setVarsFromFetchObj($obj);
|
|
|
|
|
|
|
|
|
|
// Show here line of result
|
|
|
|
|
print '<tr class="oddeven">';
|
|
|
|
|
foreach($object->fields as $key => $val)
|
|
|
|
|
{
|
|
|
|
|
$align='';
|
|
|
|
|
if (in_array($val['type'], array('date','datetime','timestamp'))) $align.=($align?' ':'').'center';
|
|
|
|
|
if (in_array($val['type'], array('timestamp'))) $align.=($align?' ':'').'nowrap';
|
|
|
|
|
if ($key == 'status') $align.=($align?' ':'').'center';
|
|
|
|
|
if (! empty($arrayfields['t.'.$key]['checked']))
|
|
|
|
|
$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 (in_array($val['type'], array('timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
|
|
|
|
|
elseif ($key == 'ref') $cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
|
|
|
|
|
|
|
|
|
|
if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $key != 'status') $cssforfield .= ($cssforfield ? ' ' : '').'right';
|
|
|
|
|
|
|
|
|
|
if (!empty($arrayfields['t.'.$key]['checked']))
|
|
|
|
|
{
|
|
|
|
|
print '<td';
|
|
|
|
|
if ($align) print ' class="'.$align.'"';
|
|
|
|
|
print '>';
|
|
|
|
|
print $object->showOutputField($val, $key, $obj->$key, '');
|
|
|
|
|
print '<td'.($cssforfield ? ' class="'.$cssforfield.'"' : '').'>';
|
|
|
|
|
if ($key == 'status') print $object->getLibStatut(5);
|
|
|
|
|
else print $object->showOutputField($val, $key, $object->$key, '');
|
|
|
|
|
print '</td>';
|
|
|
|
|
if (! $i) $totalarray['nbfield']++;
|
|
|
|
|
if (! empty($val['isameasure']))
|
|
|
|
|
if (!$i) $totalarray['nbfield']++;
|
|
|
|
|
if (!empty($val['isameasure']))
|
|
|
|
|
{
|
|
|
|
|
if (! $i) $totalarray['pos'][$totalarray['nbfield']]='t.'.$key;
|
|
|
|
|
$totalarray['val']['t.'.$key] += $obj->$key;
|
|
|
|
|
if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 't.'.$key;
|
|
|
|
|
$totalarray['val']['t.'.$key] += $object->$key;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// Extra fields
|
|
|
|
|
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
|
|
|
|
|
// Fields from hook
|
|
|
|
|
$parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj);
|
|
|
|
|
$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
|
|
|
|
|
print $hookmanager->resPrint;
|
|
|
|
|
// Action column
|
|
|
|
|
print '<td class="nowrap" align="center">';
|
|
|
|
|
print '<td class="nowrap center">';
|
|
|
|
|
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;
|
|
|
|
|
if (in_array($obj->rowid, $arrayofselected)) $selected = 1;
|
|
|
|
|
print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>';
|
|
|
|
|
if (in_array($object->id, $arrayofselected)) $selected = 1;
|
|
|
|
|
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']++;
|
|
|
|
|
|
|
|
|
|
print '</tr>';
|
|
|
|
|
print '</tr>'."\n";
|
|
|
|
|
|
|
|
|
|
$i++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Show total line
|
|
|
|
|
if (isset($totalarray['pos']))
|
|
|
|
|
{
|
|
|
|
|
print '<tr class="liste_total">';
|
|
|
|
|
$i = 0;
|
|
|
|
|
while ($i < $totalarray['nbfield'])
|
|
|
|
|
{
|
|
|
|
|
$i++;
|
|
|
|
|
if (!empty($totalarray['pos'][$i])) print '<td class="right">'.price($totalarray['val'][$totalarray['pos'][$i]]).'</td>';
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if ($i == 1)
|
|
|
|
|
{
|
|
|
|
|
if ($num < $limit) print '<td class="left">'.$langs->trans("Total").'</td>';
|
|
|
|
|
else print '<td class="left">'.$langs->trans("Totalforthispage").'</td>';
|
|
|
|
|
}
|
|
|
|
|
else print '<td></td>';
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
print '</tr>';
|
|
|
|
|
}
|
|
|
|
|
include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
|
|
|
|
|
|
|
|
|
|
// If no record found
|
|
|
|
|
if ($num == 0)
|
|
|
|
|
@@ -522,25 +532,21 @@ print '</form>'."\n";
|
|
|
|
|
|
|
|
|
|
if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords))
|
|
|
|
|
{
|
|
|
|
|
if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files)
|
|
|
|
|
{
|
|
|
|
|
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
|
|
|
|
|
$formfile = new FormFile($db);
|
|
|
|
|
$hidegeneratedfilelistifempty = 1;
|
|
|
|
|
if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty = 0;
|
|
|
|
|
|
|
|
|
|
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
|
|
|
|
|
$formfile = new FormFile($db);
|
|
|
|
|
|
|
|
|
|
// Show list of available documents
|
|
|
|
|
$urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder;
|
|
|
|
|
$urlsource .= str_replace('&', '&', $param);
|
|
|
|
|
|
|
|
|
|
$filedir = $diroutputmassaction;
|
|
|
|
|
$genallowed = $permissiontoread;
|
|
|
|
|
$delallowed = $permissiontoadd;
|
|
|
|
|
|
|
|
|
|
// Show list of available documents
|
|
|
|
|
$urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder;
|
|
|
|
|
$urlsource .= str_replace('&', '&', $param);
|
|
|
|
|
|
|
|
|
|
$filedir = $diroutputmassaction;
|
|
|
|
|
$genallowed = $user->rights->asset->read;
|
|
|
|
|
$delallowed = $user->rights->asset->create;
|
|
|
|
|
|
|
|
|
|
print $formfile->showdocuments('massfilesarea_asset', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '');
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
print '<br><a name="show_files"></a><a href="'.$_SERVER["PHP_SELF"].'?show_files=1'.$param.'#show_files">'.$langs->trans("ShowTempMassFilesArea").'</a>';
|
|
|
|
|
}
|
|
|
|
|
print $formfile->showdocuments('massfilesarea_asset', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// End of page
|
|
|
|
|
|