NEW Can use the result_mode of mysqli driver. Save memory for list count
This commit is contained in:
parent
a5df1d28d7
commit
23083427e8
@ -517,19 +517,23 @@ $parameters = array();
|
|||||||
$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook
|
$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook
|
||||||
$sql .= $hookmanager->resPrint;
|
$sql .= $hookmanager->resPrint;
|
||||||
|
|
||||||
$sql .= $db->order($sortfield, $sortorder);
|
// Count total nb of records
|
||||||
|
$nbtotalofrecords = '';
|
||||||
$nbtotalofrecords = ''; // TODO We can set and use an optimized request in $sqlforcount with no fields and no useless join to calculate nb of records
|
|
||||||
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
|
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
|
||||||
/* This old method to get and count full list returns all record so use a high amount of memory.
|
/* This old and fast method to get and count full list returns all record so use a high amount of memory.
|
||||||
$resql = $db->query($sql);
|
$resql = $db->query($sql);
|
||||||
$nbtotalofrecords = $db->num_rows($resql);
|
$nbtotalofrecords = $db->num_rows($resql);
|
||||||
*/
|
*/
|
||||||
/* The new method does not consume memory on mysql (not tested on pgsql) */
|
/* The slow method does not consume memory on mysql (not tested on pgsql) */
|
||||||
$resql = $db->query($sql, 0, 'auto', 1);
|
/*$resql = $db->query($sql, 0, 'auto', 1);
|
||||||
while ($db->fetch_object($resql)) {
|
while ($db->fetch_object($resql)) {
|
||||||
$nbtotalofrecords++;
|
$nbtotalofrecords++;
|
||||||
}
|
}*/
|
||||||
|
/* This fast and low memory method to get and count full list converts the sql into a sql count */
|
||||||
|
$sqlforcount = preg_replace('/^SELECT[a-z0-9\._\s\(\),]+FROM/i', 'SELECT COUNT(*) as nbtotalofrecords FROM', $sql);
|
||||||
|
$resql = $db->query($sqlforcount);
|
||||||
|
$objforcount = $db->fetch_object($resql);
|
||||||
|
$nbtotalofrecords = $objforcount->nbtotalofrecords;
|
||||||
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 then paging size (filtering), goto and load page 0
|
||||||
$page = 0;
|
$page = 0;
|
||||||
$offset = 0;
|
$offset = 0;
|
||||||
@ -537,72 +541,67 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
|
|||||||
$db->free($resql);
|
$db->free($resql);
|
||||||
}
|
}
|
||||||
|
|
||||||
// if total of record found is smaller than limit, no need to do paging and to restart another select with limits set.
|
// Complete request and execute it with limit
|
||||||
if (is_numeric($nbtotalofrecords) && ($limit > $nbtotalofrecords || empty($limit))) {
|
$sql .= $db->order($sortfield, $sortorder);
|
||||||
$num = $nbtotalofrecords;
|
if ($limit) {
|
||||||
} else {
|
|
||||||
if ($limit) {
|
|
||||||
$sql .= $db->plimit($limit + 1, $offset);
|
$sql .= $db->plimit($limit + 1, $offset);
|
||||||
}
|
|
||||||
|
|
||||||
$resql = $db->query($sql);
|
|
||||||
if (!$resql) {
|
|
||||||
dol_print_error($db);
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
|
|
||||||
$num = $db->num_rows($resql);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
dol_syslog("comm/action/list.php", LOG_DEBUG);
|
|
||||||
$resql = $db->query($sql);
|
$resql = $db->query($sql);
|
||||||
if ($resql) {
|
if (!$resql) {
|
||||||
$actionstatic = new ActionComm($db);
|
dol_print_error($db);
|
||||||
$societestatic = new Societe($db);
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
$num = $db->num_rows($resql);
|
$num = $db->num_rows($resql);
|
||||||
|
|
||||||
$arrayofselected = is_array($toselect) ? $toselect : array();
|
|
||||||
|
|
||||||
// Local calendar
|
$actionstatic = new ActionComm($db);
|
||||||
$newtitle = '<div class="nowrap clear inline-block minheight30 margintoponly">';
|
$societestatic = new Societe($db);
|
||||||
$newtitle .= '<input type="checkbox" id="check_mytasks" name="check_mytasks" checked disabled> '.$langs->trans("LocalAgenda").' ';
|
|
||||||
$newtitle .= '</div>';
|
|
||||||
//$newtitle=$langs->trans($title);
|
|
||||||
|
|
||||||
$tabactive = 'cardlist';
|
$num = $db->num_rows($resql);
|
||||||
|
|
||||||
$head = calendars_prepare_head($param);
|
$arrayofselected = is_array($toselect) ? $toselect : array();
|
||||||
|
|
||||||
print '<form method="POST" id="searchFormList" class="listactionsfilter" action="'.$_SERVER["PHP_SELF"].'">'."\n";
|
// Local calendar
|
||||||
|
$newtitle = '<div class="nowrap clear inline-block minheight30 margintoponly">';
|
||||||
|
$newtitle .= '<input type="checkbox" id="check_mytasks" name="check_mytasks" checked disabled> '.$langs->trans("LocalAgenda").' ';
|
||||||
|
$newtitle .= '</div>';
|
||||||
|
//$newtitle=$langs->trans($title);
|
||||||
|
|
||||||
if ($optioncss != '') {
|
$tabactive = 'cardlist';
|
||||||
|
|
||||||
|
$head = calendars_prepare_head($param);
|
||||||
|
|
||||||
|
print '<form method="POST" id="searchFormList" class="listactionsfilter" action="'.$_SERVER["PHP_SELF"].'">'."\n";
|
||||||
|
|
||||||
|
if ($optioncss != '') {
|
||||||
print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
|
print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
|
||||||
}
|
}
|
||||||
print '<input type="hidden" name="token" value="'.newToken().'">';
|
print '<input type="hidden" name="token" value="'.newToken().'">';
|
||||||
print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
|
print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
|
||||||
print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
|
print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
|
||||||
print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
|
print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
|
||||||
print '<input type="hidden" name="type" value="'.$type.'">';
|
print '<input type="hidden" name="type" value="'.$type.'">';
|
||||||
$nav = '';
|
$nav = '';
|
||||||
|
|
||||||
if ($filter) {
|
if ($filter) {
|
||||||
$nav .= '<input type="hidden" name="search_filter" value="'.$filter.'">';
|
$nav .= '<input type="hidden" name="search_filter" value="'.$filter.'">';
|
||||||
}
|
}
|
||||||
if ($showbirthday) {
|
if ($showbirthday) {
|
||||||
$nav .= '<input type="hidden" name="search_showbirthday" value="1">';
|
$nav .= '<input type="hidden" name="search_showbirthday" value="1">';
|
||||||
}
|
}
|
||||||
print $nav;
|
print $nav;
|
||||||
|
|
||||||
//print dol_get_fiche_head($head, $tabactive, $langs->trans('Agenda'), 0, 'action');
|
//print dol_get_fiche_head($head, $tabactive, $langs->trans('Agenda'), 0, 'action');
|
||||||
//print_actions_filter($form, $canedit, $search_status, $year, $month, $day, $showbirthday, 0, $filtert, 0, $pid, $socid, $action, -1, $actioncode, $usergroup, '', $resourceid);
|
//print_actions_filter($form, $canedit, $search_status, $year, $month, $day, $showbirthday, 0, $filtert, 0, $pid, $socid, $action, -1, $actioncode, $usergroup, '', $resourceid);
|
||||||
//print dol_get_fiche_end();
|
//print dol_get_fiche_end();
|
||||||
|
|
||||||
// Add link to show birthdays
|
// Add link to show birthdays
|
||||||
/*
|
/*
|
||||||
$link = '';
|
$link = '';
|
||||||
if (empty($conf->use_javascript_ajax))
|
if (empty($conf->use_javascript_ajax))
|
||||||
{
|
{
|
||||||
$newparam=$param; // newparam is for birthday links
|
$newparam=$param; // newparam is for birthday links
|
||||||
$newparam=preg_replace('/showbirthday=[0-1]/i','showbirthday='.(empty($showbirthday)?1:0),$newparam);
|
$newparam=preg_replace('/showbirthday=[0-1]/i','showbirthday='.(empty($showbirthday)?1:0),$newparam);
|
||||||
if (! preg_match('/showbirthday=/i',$newparam)) $newparam.='&showbirthday=1';
|
if (! preg_match('/showbirthday=/i',$newparam)) $newparam.='&showbirthday=1';
|
||||||
@ -612,227 +611,227 @@ if ($resql) {
|
|||||||
if (empty($showbirthday)) $link.=$langs->trans("AgendaShowBirthdayEvents");
|
if (empty($showbirthday)) $link.=$langs->trans("AgendaShowBirthdayEvents");
|
||||||
else $link.=$langs->trans("AgendaHideBirthdayEvents");
|
else $link.=$langs->trans("AgendaHideBirthdayEvents");
|
||||||
$link.='</a>';
|
$link.='</a>';
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
$s = $newtitle;
|
$s = $newtitle;
|
||||||
|
|
||||||
// Calendars from hooks
|
// Calendars from hooks
|
||||||
$parameters = array(); $object = null;
|
$parameters = array(); $object = null;
|
||||||
$reshook = $hookmanager->executeHooks('addCalendarChoice', $parameters, $object, $action);
|
$reshook = $hookmanager->executeHooks('addCalendarChoice', $parameters, $object, $action);
|
||||||
if (empty($reshook)) {
|
if (empty($reshook)) {
|
||||||
$s .= $hookmanager->resPrint;
|
$s .= $hookmanager->resPrint;
|
||||||
} elseif ($reshook > 1) {
|
} elseif ($reshook > 1) {
|
||||||
$s = $hookmanager->resPrint;
|
$s = $hookmanager->resPrint;
|
||||||
}
|
}
|
||||||
|
|
||||||
$viewmode = '';
|
$viewmode = '';
|
||||||
$viewmode .= '<a class="btnTitle btnTitleSelected reposition" href="'.DOL_URL_ROOT.'/comm/action/list.php?action=show_list&restore_lastsearch_values=1'.$paramnoactionodate.'">';
|
$viewmode .= '<a class="btnTitle btnTitleSelected reposition" href="'.DOL_URL_ROOT.'/comm/action/list.php?action=show_list&restore_lastsearch_values=1'.$paramnoactionodate.'">';
|
||||||
//$viewmode .= '<span class="fa paddingleft imgforviewmode valignmiddle btnTitle-icon">';
|
//$viewmode .= '<span class="fa paddingleft imgforviewmode valignmiddle btnTitle-icon">';
|
||||||
$viewmode .= img_picto($langs->trans("List"), 'object_list', 'class="pictoactionview block"');
|
$viewmode .= img_picto($langs->trans("List"), 'object_list', 'class="pictoactionview block"');
|
||||||
//$viewmode .= '</span>';
|
//$viewmode .= '</span>';
|
||||||
$viewmode .= '<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone">'.$langs->trans("ViewList").'</span></a>';
|
$viewmode .= '<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone">'.$langs->trans("ViewList").'</span></a>';
|
||||||
|
|
||||||
$viewmode .= '<a class="btnTitle reposition" href="'.DOL_URL_ROOT.'/comm/action/index.php?action=show_month&year='.dol_print_date($object->datep, '%Y').'&month='.dol_print_date($object->datep, '%m').'&day='.dol_print_date($object->datep, '%d').$paramnoactionodate.'">';
|
$viewmode .= '<a class="btnTitle reposition" href="'.DOL_URL_ROOT.'/comm/action/index.php?action=show_month&year='.dol_print_date($object->datep, '%Y').'&month='.dol_print_date($object->datep, '%m').'&day='.dol_print_date($object->datep, '%d').$paramnoactionodate.'">';
|
||||||
//$viewmode .= '<span class="fa paddingleft imgforviewmode valignmiddle btnTitle-icon">';
|
//$viewmode .= '<span class="fa paddingleft imgforviewmode valignmiddle btnTitle-icon">';
|
||||||
$viewmode .= img_picto($langs->trans("ViewCal"), 'object_calendarmonth', 'class="pictoactionview block"');
|
$viewmode .= img_picto($langs->trans("ViewCal"), 'object_calendarmonth', 'class="pictoactionview block"');
|
||||||
//$viewmode .= '</span>';
|
//$viewmode .= '</span>';
|
||||||
$viewmode .= '<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone">'.$langs->trans("ViewCal").'</span></a>';
|
$viewmode .= '<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone">'.$langs->trans("ViewCal").'</span></a>';
|
||||||
|
|
||||||
$viewmode .= '<a class="btnTitle reposition" href="'.DOL_URL_ROOT.'/comm/action/index.php?action=show_week&year='.dol_print_date($object->datep, '%Y').'&month='.dol_print_date($object->datep, '%m').'&day='.dol_print_date($object->datep, '%d').$paramnoactionodate.'">';
|
$viewmode .= '<a class="btnTitle reposition" href="'.DOL_URL_ROOT.'/comm/action/index.php?action=show_week&year='.dol_print_date($object->datep, '%Y').'&month='.dol_print_date($object->datep, '%m').'&day='.dol_print_date($object->datep, '%d').$paramnoactionodate.'">';
|
||||||
//$viewmode .= '<span class="fa paddingleft imgforviewmode valignmiddle btnTitle-icon">';
|
//$viewmode .= '<span class="fa paddingleft imgforviewmode valignmiddle btnTitle-icon">';
|
||||||
$viewmode .= img_picto($langs->trans("ViewWeek"), 'object_calendarweek', 'class="pictoactionview block"');
|
$viewmode .= img_picto($langs->trans("ViewWeek"), 'object_calendarweek', 'class="pictoactionview block"');
|
||||||
//$viewmode .= '</span>';
|
//$viewmode .= '</span>';
|
||||||
$viewmode .= '<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone">'.$langs->trans("ViewWeek").'</span></a>';
|
$viewmode .= '<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone">'.$langs->trans("ViewWeek").'</span></a>';
|
||||||
|
|
||||||
$viewmode .= '<a class="btnTitle reposition" href="'.DOL_URL_ROOT.'/comm/action/index.php?action=show_day&year='.dol_print_date($object->datep, '%Y').'&month='.dol_print_date($object->datep, '%m').'&day='.dol_print_date($object->datep, '%d').$paramnoactionodate.'">';
|
$viewmode .= '<a class="btnTitle reposition" href="'.DOL_URL_ROOT.'/comm/action/index.php?action=show_day&year='.dol_print_date($object->datep, '%Y').'&month='.dol_print_date($object->datep, '%m').'&day='.dol_print_date($object->datep, '%d').$paramnoactionodate.'">';
|
||||||
//$viewmode .= '<span class="fa paddingleft imgforviewmode valignmiddle btnTitle-icon">';
|
//$viewmode .= '<span class="fa paddingleft imgforviewmode valignmiddle btnTitle-icon">';
|
||||||
$viewmode .= img_picto($langs->trans("ViewDay"), 'object_calendarday', 'class="pictoactionview block"');
|
$viewmode .= img_picto($langs->trans("ViewDay"), 'object_calendarday', 'class="pictoactionview block"');
|
||||||
//$viewmode .= '</span>';
|
//$viewmode .= '</span>';
|
||||||
$viewmode .= '<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone">'.$langs->trans("ViewDay").'</span></a>';
|
$viewmode .= '<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone">'.$langs->trans("ViewDay").'</span></a>';
|
||||||
|
|
||||||
$viewmode .= '<a class="btnTitle reposition marginrightonly" href="'.DOL_URL_ROOT.'/comm/action/peruser.php?action=show_peruser&year='.dol_print_date($object->datep, '%Y').'&month='.dol_print_date($object->datep, '%m').'&day='.dol_print_date($object->datep, '%d').$paramnoactionodate.'">';
|
$viewmode .= '<a class="btnTitle reposition marginrightonly" href="'.DOL_URL_ROOT.'/comm/action/peruser.php?action=show_peruser&year='.dol_print_date($object->datep, '%Y').'&month='.dol_print_date($object->datep, '%m').'&day='.dol_print_date($object->datep, '%d').$paramnoactionodate.'">';
|
||||||
//$viewmode .= '<span class="fa paddingleft imgforviewmode valignmiddle btnTitle-icon">';
|
//$viewmode .= '<span class="fa paddingleft imgforviewmode valignmiddle btnTitle-icon">';
|
||||||
$viewmode .= img_picto($langs->trans("ViewPerUser"), 'object_calendarperuser', 'class="pictoactionview block"');
|
$viewmode .= img_picto($langs->trans("ViewPerUser"), 'object_calendarperuser', 'class="pictoactionview block"');
|
||||||
//$viewmode .= '</span>';
|
//$viewmode .= '</span>';
|
||||||
$viewmode .= '<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone">'.$langs->trans("ViewPerUser").'</span></a>';
|
$viewmode .= '<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone">'.$langs->trans("ViewPerUser").'</span></a>';
|
||||||
|
|
||||||
$viewmode .= '<span class="marginrightonly"></span>';
|
$viewmode .= '<span class="marginrightonly"></span>';
|
||||||
|
|
||||||
// Add more views from hooks
|
// Add more views from hooks
|
||||||
$parameters = array(); $object = null;
|
$parameters = array(); $object = null;
|
||||||
$reshook = $hookmanager->executeHooks('addCalendarView', $parameters, $object, $action);
|
$reshook = $hookmanager->executeHooks('addCalendarView', $parameters, $object, $action);
|
||||||
if (empty($reshook)) {
|
if (empty($reshook)) {
|
||||||
$viewmode .= $hookmanager->resPrint;
|
$viewmode .= $hookmanager->resPrint;
|
||||||
} elseif ($reshook > 1) {
|
} elseif ($reshook > 1) {
|
||||||
$viewmode = $hookmanager->resPrint;
|
$viewmode = $hookmanager->resPrint;
|
||||||
}
|
}
|
||||||
|
|
||||||
$tmpforcreatebutton = dol_getdate(dol_now(), true);
|
$tmpforcreatebutton = dol_getdate(dol_now(), true);
|
||||||
|
|
||||||
$newparam .= '&month='.str_pad($month, 2, "0", STR_PAD_LEFT).'&year='.$tmpforcreatebutton['year'];
|
$newparam .= '&month='.str_pad($month, 2, "0", STR_PAD_LEFT).'&year='.$tmpforcreatebutton['year'];
|
||||||
|
|
||||||
//$param='month='.$monthshown.'&year='.$year;
|
//$param='month='.$monthshown.'&year='.$year;
|
||||||
$hourminsec = '100000';
|
$hourminsec = '100000';
|
||||||
|
|
||||||
$url = DOL_URL_ROOT.'/comm/action/card.php?action=create';
|
$url = DOL_URL_ROOT.'/comm/action/card.php?action=create';
|
||||||
$url .= '&datep='.sprintf("%04d%02d%02d", $tmpforcreatebutton['year'], $tmpforcreatebutton['mon'], $tmpforcreatebutton['mday']).$hourminsec;
|
$url .= '&datep='.sprintf("%04d%02d%02d", $tmpforcreatebutton['year'], $tmpforcreatebutton['mon'], $tmpforcreatebutton['mday']).$hourminsec;
|
||||||
$url .= '&backtopage='.urlencode($_SERVER["PHP_SELF"].($newparam ? '?'.$newparam : ''));
|
$url .= '&backtopage='.urlencode($_SERVER["PHP_SELF"].($newparam ? '?'.$newparam : ''));
|
||||||
|
|
||||||
$newcardbutton = dolGetButtonTitle($langs->trans('AddAction'), '', 'fa fa-plus-circle', $url, '', $user->rights->agenda->myactions->create || $user->rights->agenda->allactions->create);
|
$newcardbutton = dolGetButtonTitle($langs->trans('AddAction'), '', 'fa fa-plus-circle', $url, '', $user->rights->agenda->myactions->create || $user->rights->agenda->allactions->create);
|
||||||
|
|
||||||
$param .= '&action='.$action;
|
$param .= '&action='.$action;
|
||||||
|
|
||||||
print_barre_liste($langs->trans("Agenda"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, -1 * $nbtotalofrecords, 'object_action', 0, $nav.$newcardbutton, '', $limit, 0, 0, 1, $viewmode);
|
print_barre_liste($langs->trans("Agenda"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, -1 * $nbtotalofrecords, 'object_action', 0, $nav.$newcardbutton, '', $limit, 0, 0, 1, $viewmode);
|
||||||
|
|
||||||
print $s;
|
print $s;
|
||||||
|
|
||||||
$objecttmp = new ActionComm($db);
|
$objecttmp = new ActionComm($db);
|
||||||
include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
|
include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
|
||||||
|
|
||||||
$moreforfilter = '';
|
$moreforfilter = '';
|
||||||
|
|
||||||
$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
|
$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
|
||||||
$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
|
$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
|
||||||
if ($massactionbutton) {
|
if ($massactionbutton) {
|
||||||
$selectedfields .= $form->showCheckAddButtons('checkforselect', 1);
|
$selectedfields .= $form->showCheckAddButtons('checkforselect', 1);
|
||||||
}
|
}
|
||||||
$i = 0;
|
$i = 0;
|
||||||
|
|
||||||
print '<div class="liste_titre liste_titre_bydiv centpercent">';
|
print '<div class="liste_titre liste_titre_bydiv centpercent">';
|
||||||
print_actions_filter($form, $canedit, $search_status, $year, $month, $day, $showbirthday, 0, $filtert, 0, $pid, $socid, $action, -1, $actioncode, $usergroup, '', $resourceid);
|
print_actions_filter($form, $canedit, $search_status, $year, $month, $day, $showbirthday, 0, $filtert, 0, $pid, $socid, $action, -1, $actioncode, $usergroup, '', $resourceid);
|
||||||
print '</div>';
|
print '</div>';
|
||||||
|
|
||||||
print '<div class="div-table-responsive">';
|
print '<div class="div-table-responsive">';
|
||||||
print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
|
print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
|
||||||
|
|
||||||
print '<tr class="liste_titre_filter">';
|
print '<tr class="liste_titre_filter">';
|
||||||
if (!empty($arrayfields['a.id']['checked'])) {
|
if (!empty($arrayfields['a.id']['checked'])) {
|
||||||
print '<td class="liste_titre"><input type="text" class="maxwidth50" name="search_id" value="'.$search_id.'"></td>';
|
print '<td class="liste_titre"><input type="text" class="maxwidth50" name="search_id" value="'.$search_id.'"></td>';
|
||||||
}
|
}
|
||||||
if (!empty($arrayfields['owner']['checked'])) {
|
if (!empty($arrayfields['owner']['checked'])) {
|
||||||
print '<td class="liste_titre"></td>';
|
print '<td class="liste_titre"></td>';
|
||||||
}
|
}
|
||||||
if (!empty($arrayfields['c.libelle']['checked'])) {
|
if (!empty($arrayfields['c.libelle']['checked'])) {
|
||||||
print '<td class="liste_titre"></td>';
|
print '<td class="liste_titre"></td>';
|
||||||
}
|
}
|
||||||
if (!empty($arrayfields['a.label']['checked'])) {
|
if (!empty($arrayfields['a.label']['checked'])) {
|
||||||
print '<td class="liste_titre"><input type="text" class="maxwidth75" name="search_title" value="'.$search_title.'"></td>';
|
print '<td class="liste_titre"><input type="text" class="maxwidth75" name="search_title" value="'.$search_title.'"></td>';
|
||||||
}
|
}
|
||||||
if (!empty($arrayfields['a.note']['checked'])) {
|
if (!empty($arrayfields['a.note']['checked'])) {
|
||||||
print '<td class="liste_titre"><input type="text" class="maxwidth75" name="search_note" value="'.$search_note.'"></td>';
|
print '<td class="liste_titre"><input type="text" class="maxwidth75" name="search_note" value="'.$search_note.'"></td>';
|
||||||
}
|
}
|
||||||
if (!empty($arrayfields['a.datep']['checked'])) {
|
if (!empty($arrayfields['a.datep']['checked'])) {
|
||||||
print '<td class="liste_titre nowraponall" align="center">';
|
print '<td class="liste_titre nowraponall" align="center">';
|
||||||
print $form->selectDate($datestart, 'datestart', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', '', 'tzuserrel');
|
print $form->selectDate($datestart, 'datestart', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', '', 'tzuserrel');
|
||||||
print '</td>';
|
print '</td>';
|
||||||
}
|
}
|
||||||
if (!empty($arrayfields['a.datep2']['checked'])) {
|
if (!empty($arrayfields['a.datep2']['checked'])) {
|
||||||
print '<td class="liste_titre nowraponall" align="center">';
|
print '<td class="liste_titre nowraponall" align="center">';
|
||||||
print $form->selectDate($dateend, 'dateend', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', '', 'tzuserrel');
|
print $form->selectDate($dateend, 'dateend', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', '', 'tzuserrel');
|
||||||
print '</td>';
|
print '</td>';
|
||||||
}
|
}
|
||||||
if (!empty($arrayfields['s.nom']['checked'])) {
|
if (!empty($arrayfields['s.nom']['checked'])) {
|
||||||
print '<td class="liste_titre"></td>';
|
print '<td class="liste_titre"></td>';
|
||||||
}
|
}
|
||||||
if (!empty($arrayfields['a.fk_contact']['checked'])) {
|
if (!empty($arrayfields['a.fk_contact']['checked'])) {
|
||||||
print '<td class="liste_titre"></td>';
|
print '<td class="liste_titre"></td>';
|
||||||
}
|
}
|
||||||
if (!empty($arrayfields['a.fk_element']['checked'])) {
|
if (!empty($arrayfields['a.fk_element']['checked'])) {
|
||||||
print '<td class="liste_titre"></td>';
|
print '<td class="liste_titre"></td>';
|
||||||
}
|
}
|
||||||
|
|
||||||
// Extra fields
|
// Extra fields
|
||||||
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
|
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
|
||||||
|
|
||||||
// Fields from hook
|
// Fields from hook
|
||||||
$parameters = array('arrayfields'=>$arrayfields);
|
$parameters = array('arrayfields'=>$arrayfields);
|
||||||
$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook
|
$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook
|
||||||
print $hookmanager->resPrint;
|
print $hookmanager->resPrint;
|
||||||
|
|
||||||
if (!empty($arrayfields['a.datec']['checked'])) {
|
if (!empty($arrayfields['a.datec']['checked'])) {
|
||||||
print '<td class="liste_titre"></td>';
|
print '<td class="liste_titre"></td>';
|
||||||
}
|
}
|
||||||
if (!empty($arrayfields['a.tms']['checked'])) {
|
if (!empty($arrayfields['a.tms']['checked'])) {
|
||||||
print '<td class="liste_titre"></td>';
|
print '<td class="liste_titre"></td>';
|
||||||
}
|
}
|
||||||
if (!empty($arrayfields['a.percent']['checked'])) {
|
if (!empty($arrayfields['a.percent']['checked'])) {
|
||||||
print '<td class="liste_titre center">';
|
print '<td class="liste_titre center">';
|
||||||
$formactions->form_select_status_action('formaction', $search_status, 1, 'search_status', 1, 2, 'minwidth100imp maxwidth125');
|
$formactions->form_select_status_action('formaction', $search_status, 1, 'search_status', 1, 2, 'minwidth100imp maxwidth125');
|
||||||
print ajax_combobox('selectsearch_status');
|
print ajax_combobox('selectsearch_status');
|
||||||
print '</td>';
|
print '</td>';
|
||||||
}
|
}
|
||||||
// Action column
|
// Action column
|
||||||
print '<td class="liste_titre" align="middle">';
|
print '<td class="liste_titre" align="middle">';
|
||||||
$searchpicto = $form->showFilterButtons();
|
$searchpicto = $form->showFilterButtons();
|
||||||
print $searchpicto;
|
print $searchpicto;
|
||||||
print '</td>';
|
print '</td>';
|
||||||
print "</tr>\n";
|
print "</tr>\n";
|
||||||
|
|
||||||
print '<tr class="liste_titre">';
|
print '<tr class="liste_titre">';
|
||||||
if (!empty($arrayfields['a.id']['checked'])) {
|
if (!empty($arrayfields['a.id']['checked'])) {
|
||||||
print_liste_field_titre($arrayfields['a.id']['label'], $_SERVER["PHP_SELF"], "a.id", $param, "", "", $sortfield, $sortorder);
|
print_liste_field_titre($arrayfields['a.id']['label'], $_SERVER["PHP_SELF"], "a.id", $param, "", "", $sortfield, $sortorder);
|
||||||
}
|
}
|
||||||
if (!empty($arrayfields['owner']['checked'])) {
|
if (!empty($arrayfields['owner']['checked'])) {
|
||||||
print_liste_field_titre($arrayfields['owner']['label'], $_SERVER["PHP_SELF"], "", $param, "", "", $sortfield, $sortorder);
|
print_liste_field_titre($arrayfields['owner']['label'], $_SERVER["PHP_SELF"], "", $param, "", "", $sortfield, $sortorder);
|
||||||
}
|
}
|
||||||
if (!empty($arrayfields['c.libelle']['checked'])) {
|
if (!empty($arrayfields['c.libelle']['checked'])) {
|
||||||
print_liste_field_titre($arrayfields['c.libelle']['label'], $_SERVER["PHP_SELF"], "c.libelle", $param, "", "", $sortfield, $sortorder);
|
print_liste_field_titre($arrayfields['c.libelle']['label'], $_SERVER["PHP_SELF"], "c.libelle", $param, "", "", $sortfield, $sortorder);
|
||||||
}
|
}
|
||||||
if (!empty($arrayfields['a.label']['checked'])) {
|
if (!empty($arrayfields['a.label']['checked'])) {
|
||||||
print_liste_field_titre($arrayfields['a.label']['label'], $_SERVER["PHP_SELF"], "a.label", $param, "", "", $sortfield, $sortorder);
|
print_liste_field_titre($arrayfields['a.label']['label'], $_SERVER["PHP_SELF"], "a.label", $param, "", "", $sortfield, $sortorder);
|
||||||
}
|
}
|
||||||
if (!empty($arrayfields['a.note']['checked'])) {
|
if (!empty($arrayfields['a.note']['checked'])) {
|
||||||
print_liste_field_titre($arrayfields['a.note']['label'], $_SERVER["PHP_SELF"], "a.note", $param, "", "", $sortfield, $sortorder);
|
print_liste_field_titre($arrayfields['a.note']['label'], $_SERVER["PHP_SELF"], "a.note", $param, "", "", $sortfield, $sortorder);
|
||||||
}
|
}
|
||||||
//if (! empty($conf->global->AGENDA_USE_EVENT_TYPE))
|
//if (! empty($conf->global->AGENDA_USE_EVENT_TYPE))
|
||||||
if (!empty($arrayfields['a.datep']['checked'])) {
|
if (!empty($arrayfields['a.datep']['checked'])) {
|
||||||
print_liste_field_titre($arrayfields['a.datep']['label'], $_SERVER["PHP_SELF"], "a.datep,a.id", $param, '', 'align="center"', $sortfield, $sortorder);
|
print_liste_field_titre($arrayfields['a.datep']['label'], $_SERVER["PHP_SELF"], "a.datep,a.id", $param, '', 'align="center"', $sortfield, $sortorder);
|
||||||
}
|
}
|
||||||
if (!empty($arrayfields['a.datep2']['checked'])) {
|
if (!empty($arrayfields['a.datep2']['checked'])) {
|
||||||
print_liste_field_titre($arrayfields['a.datep2']['label'], $_SERVER["PHP_SELF"], "a.datep2", $param, '', 'align="center"', $sortfield, $sortorder);
|
print_liste_field_titre($arrayfields['a.datep2']['label'], $_SERVER["PHP_SELF"], "a.datep2", $param, '', 'align="center"', $sortfield, $sortorder);
|
||||||
}
|
}
|
||||||
if (!empty($arrayfields['s.nom']['checked'])) {
|
if (!empty($arrayfields['s.nom']['checked'])) {
|
||||||
print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], "s.nom", $param, "", "", $sortfield, $sortorder);
|
print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], "s.nom", $param, "", "", $sortfield, $sortorder);
|
||||||
}
|
}
|
||||||
if (!empty($arrayfields['a.fk_contact']['checked'])) {
|
if (!empty($arrayfields['a.fk_contact']['checked'])) {
|
||||||
print_liste_field_titre($arrayfields['a.fk_contact']['label'], $_SERVER["PHP_SELF"], "", $param, "", "", $sortfield, $sortorder);
|
print_liste_field_titre($arrayfields['a.fk_contact']['label'], $_SERVER["PHP_SELF"], "", $param, "", "", $sortfield, $sortorder);
|
||||||
}
|
}
|
||||||
if (!empty($arrayfields['a.fk_element']['checked'])) {
|
if (!empty($arrayfields['a.fk_element']['checked'])) {
|
||||||
print_liste_field_titre($arrayfields['a.fk_element']['label'], $_SERVER["PHP_SELF"], "", $param, "", "", $sortfield, $sortorder);
|
print_liste_field_titre($arrayfields['a.fk_element']['label'], $_SERVER["PHP_SELF"], "", $param, "", "", $sortfield, $sortorder);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Extra fields
|
// Extra fields
|
||||||
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
|
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
|
||||||
|
|
||||||
// Hook fields
|
// Hook fields
|
||||||
$parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder);
|
$parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder);
|
||||||
$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook
|
$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook
|
||||||
print $hookmanager->resPrint;
|
print $hookmanager->resPrint;
|
||||||
|
|
||||||
if (!empty($arrayfields['a.datec']['checked'])) {
|
if (!empty($arrayfields['a.datec']['checked'])) {
|
||||||
print_liste_field_titre($arrayfields['a.datec']['label'], $_SERVER["PHP_SELF"], "a.datec,a.id", $param, "", 'align="center"', $sortfield, $sortorder);
|
print_liste_field_titre($arrayfields['a.datec']['label'], $_SERVER["PHP_SELF"], "a.datec,a.id", $param, "", 'align="center"', $sortfield, $sortorder);
|
||||||
}
|
}
|
||||||
if (!empty($arrayfields['a.tms']['checked'])) {
|
if (!empty($arrayfields['a.tms']['checked'])) {
|
||||||
print_liste_field_titre($arrayfields['a.tms']['label'], $_SERVER["PHP_SELF"], "a.tms,a.id", $param, "", 'align="center"', $sortfield, $sortorder);
|
print_liste_field_titre($arrayfields['a.tms']['label'], $_SERVER["PHP_SELF"], "a.tms,a.id", $param, "", 'align="center"', $sortfield, $sortorder);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($arrayfields['a.percent']['checked'])) {
|
if (!empty($arrayfields['a.percent']['checked'])) {
|
||||||
print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "a.percent", $param, "", 'align="center"', $sortfield, $sortorder);
|
print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "a.percent", $param, "", 'align="center"', $sortfield, $sortorder);
|
||||||
}
|
}
|
||||||
print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', 'align="center"', $sortfield, $sortorder, 'maxwidthsearch ');
|
print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', 'align="center"', $sortfield, $sortorder, 'maxwidthsearch ');
|
||||||
print "</tr>\n";
|
print "</tr>\n";
|
||||||
|
|
||||||
$contactstatic = new Contact($db);
|
$contactstatic = new Contact($db);
|
||||||
$now = dol_now();
|
$now = dol_now();
|
||||||
$delay_warning = $conf->global->MAIN_DELAY_ACTIONS_TODO * 24 * 60 * 60;
|
$delay_warning = $conf->global->MAIN_DELAY_ACTIONS_TODO * 24 * 60 * 60;
|
||||||
|
|
||||||
require_once DOL_DOCUMENT_ROOT.'/comm/action/class/cactioncomm.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/comm/action/class/cactioncomm.class.php';
|
||||||
$caction = new CActionComm($db);
|
$caction = new CActionComm($db);
|
||||||
$arraylist = $caction->liste_array(1, 'code', '', (empty($conf->global->AGENDA_USE_EVENT_TYPE) ? 1 : 0), '', 1);
|
$arraylist = $caction->liste_array(1, 'code', '', (empty($conf->global->AGENDA_USE_EVENT_TYPE) ? 1 : 0), '', 1);
|
||||||
$contactListCache = array();
|
$contactListCache = array();
|
||||||
|
|
||||||
while ($i < min($num, $limit)) {
|
while ($i < min($num, $limit)) {
|
||||||
$obj = $db->fetch_object($resql);
|
$obj = $db->fetch_object($resql);
|
||||||
|
|
||||||
// Discard auto action if option is on
|
// Discard auto action if option is on
|
||||||
@ -1049,15 +1048,12 @@ if ($resql) {
|
|||||||
|
|
||||||
print "</tr>\n";
|
print "</tr>\n";
|
||||||
$i++;
|
$i++;
|
||||||
}
|
|
||||||
print "</table>";
|
|
||||||
print '</div>';
|
|
||||||
print '</form>';
|
|
||||||
|
|
||||||
$db->free($resql);
|
|
||||||
} else {
|
|
||||||
dol_print_error($db);
|
|
||||||
}
|
}
|
||||||
|
print "</table>";
|
||||||
|
print '</div>';
|
||||||
|
print '</form>';
|
||||||
|
|
||||||
|
$db->free($resql);
|
||||||
|
|
||||||
// End of page
|
// End of page
|
||||||
llxFooter();
|
llxFooter();
|
||||||
|
|||||||
@ -344,43 +344,45 @@ $sql .= $hookmanager->resPrint;
|
|||||||
$sql = preg_replace('/,\s*$/', '', $sql);
|
$sql = preg_replace('/,\s*$/', '', $sql);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
$sql .= $db->order($sortfield, $sortorder);
|
|
||||||
|
|
||||||
// Count total nb of records
|
// Count total nb of records
|
||||||
$nbtotalofrecords = '';
|
$nbtotalofrecords = '';
|
||||||
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
|
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
|
||||||
/* This old method to get and count full list returns all record so use a high amount of memory.
|
/* This old and fast method to get and count full list returns all record so use a high amount of memory.
|
||||||
$resql = $db->query($sql);
|
$resql = $db->query($sql);
|
||||||
$nbtotalofrecords = $db->num_rows($resql);
|
$nbtotalofrecords = $db->num_rows($resql);
|
||||||
*/
|
*/
|
||||||
/* The new method does not consume memory on mysql (not tested on pgsql) */
|
/* The slow method does not consume memory on mysql (not tested on pgsql) */
|
||||||
$resql = $db->query($sql, 0, 'auto', 1);
|
/*$resql = $db->query($sql, 0, 'auto', 1);
|
||||||
while ($db->fetch_object($resql)) {
|
while ($db->fetch_object($resql)) {
|
||||||
$nbtotalofrecords++;
|
$nbtotalofrecords++;
|
||||||
}
|
}*/
|
||||||
|
/* This fast and low memory method to get and count full list convert the sql into a sql count */
|
||||||
|
$sqlforcount = preg_replace('/^SELECT[a-z0-9\._\s\(\),]+FROM/i', 'SELECT COUNT(*) as nbtotalofrecords FROM', $sql);
|
||||||
|
$resql = $db->query($sqlforcount);
|
||||||
|
$objforcount = $db->fetch_object($resql);
|
||||||
|
$nbtotalofrecords = $objforcount->nbtotalofrecords;
|
||||||
if (($page * $limit) > $nbtotalofrecords) { // if total of record found is smaller than page * limit, goto and load page 0
|
if (($page * $limit) > $nbtotalofrecords) { // if total of record found is smaller than page * limit, goto and load page 0
|
||||||
$page = 0;
|
$page = 0;
|
||||||
$offset = 0;
|
$offset = 0;
|
||||||
}
|
}
|
||||||
$db->free($resql);
|
$db->free($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))) {
|
|
||||||
$num = $nbtotalofrecords;
|
|
||||||
} else {
|
|
||||||
if ($limit) {
|
|
||||||
$sql .= $db->plimit($limit + 1, $offset);
|
|
||||||
}
|
|
||||||
|
|
||||||
$resql = $db->query($sql);
|
// Complete request and execute it with limit
|
||||||
if (!$resql) {
|
$sql .= $db->order($sortfield, $sortorder);
|
||||||
|
if ($limit) {
|
||||||
|
$sql .= $db->plimit($limit + 1, $offset);
|
||||||
|
}
|
||||||
|
|
||||||
|
$resql = $db->query($sql);
|
||||||
|
if (!$resql) {
|
||||||
dol_print_error($db);
|
dol_print_error($db);
|
||||||
exit;
|
exit;
|
||||||
}
|
|
||||||
|
|
||||||
$num = $db->num_rows($resql);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$num = $db->num_rows($resql);
|
||||||
|
|
||||||
|
|
||||||
// Direct jump if only one record found
|
// Direct jump if only one record found
|
||||||
if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all && !$page) {
|
if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all && !$page) {
|
||||||
$obj = $db->fetch_object($resql);
|
$obj = $db->fetch_object($resql);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user