Debug v18

This commit is contained in:
Laurent Destailleur 2023-04-05 17:31:58 +02:00
parent 849c4fa57a
commit ab6a6b87f6

View File

@ -149,7 +149,6 @@ if ($object->fk_project > 0) {
} }
/* /*
* Actions * Actions
*/ */
@ -875,9 +874,11 @@ if ($action == 'confirm_generateinter') {
} }
} }
/* /*
* View * View
*/ */
$form = new Form($db); $form = new Form($db);
$formother = new FormOther($db); $formother = new FormOther($db);
$formproject = new FormProjets($db); $formproject = new FormProjets($db);
@ -1304,7 +1305,7 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser
if ($search_year > 0) { if ($search_year > 0) {
$param .= '&search_year='.urlencode($search_year); $param .= '&search_year='.urlencode($search_year);
} }
if ($search_user > 0) { if (!empty($search_user)) { // We keep param if -1 because default value is forced to user id if not set
$param .= '&search_user='.urlencode($search_user); $param .= '&search_user='.urlencode($search_user);
} }
if ($search_task_ref != '') { if ($search_task_ref != '') {
@ -1564,6 +1565,9 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser
$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook
$sql .= $hookmanager->resPrint; $sql .= $hookmanager->resPrint;
$sql = preg_replace('/,\s*$/', '', $sql); $sql = preg_replace('/,\s*$/', '', $sql);
$sqlfields = $sql; // $sql fields to remove for count total
$sql .= " FROM ".MAIN_DB_PREFIX."element_time as t"; $sql .= " FROM ".MAIN_DB_PREFIX."element_time as t";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."facturedet as il ON il.rowid = t.invoice_line_id"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."facturedet as il ON il.rowid = t.invoice_line_id";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."facture as inv ON inv.rowid = il.fk_facture"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."facture as inv ON inv.rowid = il.fk_facture";
@ -1657,29 +1661,33 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser
$parameters = array(); $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 // Count total nb of records
$nbtotalofrecords = ''; $nbtotalofrecords = '';
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
$resql = $db->query($sql); /* The fast and low memory method to get and count full list converts the sql into a sql count */
$sqlforcount = preg_replace('/^'.preg_quote($sqlfields, '/').'/', 'SELECT COUNT(*) as nbtotalofrecords', $sql);
if (! $resql) { $sqlforcount = preg_replace('/GROUP BY .*$/', '', $sqlforcount);
$resql = $db->query($sqlforcount);
if ($resql) {
$objforcount = $db->fetch_object($resql);
$nbtotalofrecords = $objforcount->nbtotalofrecords;
} else {
dol_print_error($db); dol_print_error($db);
exit;
} }
$nbtotalofrecords = $db->num_rows($resql); if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller than the paging size (filtering), 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);
} }
// 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) { // Complete request and execute it with limit
$num = $nbtotalofrecords; $sql .= $db->order($sortfield, $sortorder);
} else { if ($limit) {
$sql .= $db->plimit($limit + 1, $offset); $sql .= $db->plimit($limit + 1, $offset);
}
$resql = $db->query($sql); $resql = $db->query($sql);
if (!$resql) { if (!$resql) {
@ -1688,7 +1696,6 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser
} }
$num = $db->num_rows($resql); $num = $db->num_rows($resql);
}
if ($num >= 0) { if ($num >= 0) {
if (!empty($projectidforalltimes)) { if (!empty($projectidforalltimes)) {
@ -1870,6 +1877,7 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser
print '<table class="tagtable nobottomiftotal liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n"; print '<table class="tagtable nobottomiftotal liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
// Fields title search // Fields title search
// --------------------------------------------------------------------
print '<tr class="liste_titre_filter">'; print '<tr class="liste_titre_filter">';
// Action column // Action column
if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
@ -1918,7 +1926,7 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser
} }
// Author // Author
if (!empty($arrayfields['author']['checked'])) { if (!empty($arrayfields['author']['checked'])) {
print '<td class="liste_titre">'.$form->select_dolusers(($search_user > 0 ? $search_user : -1), 'search_user', 1, null, 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth250').'</td>'; print '<td class="liste_titre">'.$form->select_dolusers(($search_user > 0 ? $search_user : -1), 'search_user', 1, null, 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth150').'</td>';
} }
// Note // Note
if (!empty($arrayfields['t.note']['checked'])) { if (!empty($arrayfields['t.note']['checked'])) {
@ -1977,54 +1985,72 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser
} }
print '</tr>'."\n"; print '</tr>'."\n";
$totalarray = array();
$totalarray['nbfield'] = 0;
// Fields title label
// --------------------------------------------------------------------
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', 'width="80"', $sortfield, $sortorder, 'center maxwidthsearch '); print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ');
$totalarray['nbfield']++;
} }
if (!empty($arrayfields['t.element_date']['checked'])) { if (!empty($arrayfields['t.element_date']['checked'])) {
print_liste_field_titre($arrayfields['t.element_date']['label'], $_SERVER['PHP_SELF'], 't.element_date,t.element_datehour,t.rowid', '', $param, '', $sortfield, $sortorder); print_liste_field_titre($arrayfields['t.element_date']['label'], $_SERVER['PHP_SELF'], 't.element_date,t.element_datehour,t.rowid', '', $param, '', $sortfield, $sortorder);
$totalarray['nbfield']++;
} }
if (!empty($arrayfields['p.fk_soc']['checked'])) { if (!empty($arrayfields['p.fk_soc']['checked'])) {
print_liste_field_titre($arrayfields['p.fk_soc']['label'], $_SERVER['PHP_SELF'], 't.element_date,t.element_datehour,t.rowid', '', $param, '', $sortfield, $sortorder); print_liste_field_titre($arrayfields['p.fk_soc']['label'], $_SERVER['PHP_SELF'], 't.element_date,t.element_datehour,t.rowid', '', $param, '', $sortfield, $sortorder);
$totalarray['nbfield']++;
} }
if (!empty($arrayfields['s.name_alias']['checked'])) { if (!empty($arrayfields['s.name_alias']['checked'])) {
print_liste_field_titre($arrayfields['s.name_alias']['label'], $_SERVER['PHP_SELF'], 's.name_alias', '', $param, '', $sortfield, $sortorder); print_liste_field_titre($arrayfields['s.name_alias']['label'], $_SERVER['PHP_SELF'], 's.name_alias', '', $param, '', $sortfield, $sortorder);
$totalarray['nbfield']++;
} }
if (!empty($allprojectforuser)) { if (!empty($allprojectforuser)) {
if (!empty($arrayfields['p.project_ref']['checked'])) { if (!empty($arrayfields['p.project_ref']['checked'])) {
print_liste_field_titre("Project", $_SERVER['PHP_SELF'], 'p.ref', '', $param, '', $sortfield, $sortorder); print_liste_field_titre("Project", $_SERVER['PHP_SELF'], 'p.ref', '', $param, '', $sortfield, $sortorder);
$totalarray['nbfield']++;
} }
if (!empty($arrayfields['p.project_label']['checked'])) { if (!empty($arrayfields['p.project_label']['checked'])) {
print_liste_field_titre("ProjectLabel", $_SERVER['PHP_SELF'], 'p.title', '', $param, '', $sortfield, $sortorder); print_liste_field_titre("ProjectLabel", $_SERVER['PHP_SELF'], 'p.title', '', $param, '', $sortfield, $sortorder);
$totalarray['nbfield']++;
} }
} }
if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) { // Not a dedicated task if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) { // Not a dedicated task
if (!empty($arrayfields['t.element_ref']['checked'])) { if (!empty($arrayfields['t.element_ref']['checked'])) {
print_liste_field_titre($arrayfields['t.element_ref']['label'], $_SERVER['PHP_SELF'], 'pt.ref', '', $param, '', $sortfield, $sortorder); print_liste_field_titre($arrayfields['t.element_ref']['label'], $_SERVER['PHP_SELF'], 'pt.ref', '', $param, '', $sortfield, $sortorder);
$totalarray['nbfield']++;
} }
if (!empty($arrayfields['t.element_label']['checked'])) { if (!empty($arrayfields['t.element_label']['checked'])) {
print_liste_field_titre($arrayfields['t.element_label']['label'], $_SERVER['PHP_SELF'], 'pt.label', '', $param, '', $sortfield, $sortorder); print_liste_field_titre($arrayfields['t.element_label']['label'], $_SERVER['PHP_SELF'], 'pt.label', '', $param, '', $sortfield, $sortorder);
$totalarray['nbfield']++;
} }
} }
if (!empty($arrayfields['author']['checked'])) { if (!empty($arrayfields['author']['checked'])) {
print_liste_field_titre($arrayfields['author']['label'], $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder); print_liste_field_titre($arrayfields['author']['label'], $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder);
$totalarray['nbfield']++;
} }
if (!empty($arrayfields['t.note']['checked'])) { if (!empty($arrayfields['t.note']['checked'])) {
print_liste_field_titre($arrayfields['t.note']['label'], $_SERVER['PHP_SELF'], 't.note', '', $param, '', $sortfield, $sortorder); print_liste_field_titre($arrayfields['t.note']['label'], $_SERVER['PHP_SELF'], 't.note', '', $param, '', $sortfield, $sortorder);
$totalarray['nbfield']++;
} }
if (!empty($arrayfields['t.element_duration']['checked'])) { if (!empty($arrayfields['t.element_duration']['checked'])) {
print_liste_field_titre($arrayfields['t.element_duration']['label'], $_SERVER['PHP_SELF'], 't.element_duration', '', $param, '', $sortfield, $sortorder, 'right '); print_liste_field_titre($arrayfields['t.element_duration']['label'], $_SERVER['PHP_SELF'], 't.element_duration', '', $param, '', $sortfield, $sortorder, 'right ');
$totalarray['nbfield']++;
} }
if (!empty($arrayfields['t.fk_product']['checked'])) { if (!empty($arrayfields['t.fk_product']['checked'])) {
print_liste_field_titre($arrayfields['t.fk_product']['label'], $_SERVER['PHP_SELF'], 't.fk_product', '', $param, '', $sortfield, $sortorder); print_liste_field_titre($arrayfields['t.fk_product']['label'], $_SERVER['PHP_SELF'], 't.fk_product', '', $param, '', $sortfield, $sortorder);
$totalarray['nbfield']++;
} }
if (!empty($arrayfields['value']['checked'])) { if (!empty($arrayfields['value']['checked'])) {
print_liste_field_titre($arrayfields['value']['label'], $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder, 'right '); print_liste_field_titre($arrayfields['value']['label'], $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder, 'right ');
$totalarray['nbfield']++;
} }
if (!empty($arrayfields['valuebilled']['checked'])) { if (!empty($arrayfields['valuebilled']['checked'])) {
print_liste_field_titre($arrayfields['valuebilled']['label'], $_SERVER['PHP_SELF'], 'il.total_ht', '', $param, '', $sortfield, $sortorder, 'center ', $langs->trans("SelectLinesOfTimeSpentToInvoice")); print_liste_field_titre($arrayfields['valuebilled']['label'], $_SERVER['PHP_SELF'], 'il.total_ht', '', $param, '', $sortfield, $sortorder, 'center ', $langs->trans("SelectLinesOfTimeSpentToInvoice"));
$totalarray['nbfield']++;
} }
/* /*
// Extra fields // Extra fields
@ -2036,6 +2062,7 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser
print $hookmanager->resPrint; print $hookmanager->resPrint;
if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', 'width="80"', $sortfield, $sortorder, 'center maxwidthsearch '); print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', 'width="80"', $sortfield, $sortorder, 'center maxwidthsearch ');
$totalarray['nbfield']++;
} }
print "</tr>\n"; print "</tr>\n";
@ -2043,10 +2070,13 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser
$tmpinvoice = new Facture($db); $tmpinvoice = new Facture($db);
$i = 0; $i = 0;
$total = 0; $total = 0;
$totalvalue = 0; $totalvalue = 0;
$totalarray = array('nbfield'=>0);
$savnbfield = $totalarray['nbfield'];
$totalarray = array();
$totalarray['nbfield'] = 0;
//$imaxinloop = ($limit ? min($num, $limit) : $num);
foreach ($tasks as $task_time) { foreach ($tasks as $task_time) {
if ($i >= $limit) { if ($i >= $limit) {
break; break;
@ -2055,11 +2085,13 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser
$date1 = $db->jdate($task_time->element_date); $date1 = $db->jdate($task_time->element_date);
$date2 = $db->jdate($task_time->element_datehour); $date2 = $db->jdate($task_time->element_datehour);
print '<tr class="oddeven">'; // Show here line of result
$j = 0;
print '<tr data-rowid="'.$object->id.'" class="oddeven">';
// Action column // Action column
if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
print '<td class="center nowraponall">'; print '<td class="center nowraponall maxwidth75">';
if (($action == 'editline' || $action == 'splitline') && GETPOST('lineid', 'int') == $task_time->rowid) { if (($action == 'editline' || $action == 'splitline') && GETPOST('lineid', 'int') == $task_time->rowid) {
print '<input type="hidden" name="lineid" value="'.GETPOST('lineid', 'int').'">'; print '<input type="hidden" name="lineid" value="'.GETPOST('lineid', 'int').'">';
print '<input type="submit" class="button buttongen margintoponlyshort marginbottomonlyshort button-save" name="save" value="'.$langs->trans("Save").'">'; print '<input type="submit" class="button buttongen margintoponlyshort marginbottomonlyshort button-save" name="save" value="'.$langs->trans("Save").'">';
@ -2092,6 +2124,10 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser
} }
} }
} }
print '</td>';
if (!$i) {
$totalarray['nbfield']++;
}
} }
// Date // Date
if (!empty($arrayfields['t.element_date']['checked'])) { if (!empty($arrayfields['t.element_date']['checked'])) {
@ -2113,7 +2149,7 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser
// Thirdparty // Thirdparty
if (!empty($arrayfields['p.fk_soc']['checked'])) { if (!empty($arrayfields['p.fk_soc']['checked'])) {
print '<td class="nowrap">'; print '<td class="nowrap tdoverflowmax150">';
if ($task_time->fk_soc > 0) { if ($task_time->fk_soc > 0) {
if (empty($conf->cache['thridparty'][$task_time->fk_soc])) { if (empty($conf->cache['thridparty'][$task_time->fk_soc])) {
$tmpsociete = new Societe($db); $tmpsociete = new Societe($db);
@ -2132,7 +2168,6 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser
// Thirdparty alias // Thirdparty alias
if (!empty($arrayfields['s.name_alias']['checked'])) { if (!empty($arrayfields['s.name_alias']['checked'])) {
print '<td class="nowrap">';
if ($task_time->fk_soc > 0) { if ($task_time->fk_soc > 0) {
if (empty($conf->cache['thridparty'][$task_time->fk_soc])) { if (empty($conf->cache['thridparty'][$task_time->fk_soc])) {
$tmpsociete = new Societe($db); $tmpsociete = new Societe($db);
@ -2141,8 +2176,10 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser
} else { } else {
$tmpsociete = $conf->cache['thridparty'][$task_time->fk_soc]; $tmpsociete = $conf->cache['thridparty'][$task_time->fk_soc];
} }
print $tmpsociete->name_alias; $valtoshow = $tmpsociete->name_alias;
} }
print '<td class="nowrap tdoverflowmax150" title="'.dol_escape_htmltag($valtoshow).'">';
print $valtoshow;
print '</td>'; print '</td>';
if (!$i) { if (!$i) {
$totalarray['nbfield']++; $totalarray['nbfield']++;
@ -2309,6 +2346,9 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser
} }
} }
print '</td>'; print '</td>';
if (!$i) {
$totalarray['nbfield']++;
}
} }
// Value spent // Value spent
@ -2422,11 +2462,11 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser
} }
} }
} }
}
print '</td>'; print '</td>';
if (!$i) { if (!$i) {
$totalarray['nbfield']++; $totalarray['nbfield']++;
} }
}
print "</tr>\n"; print "</tr>\n";
@ -2724,7 +2764,7 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser
if ($num < $limit && empty($offset)) { if ($num < $limit && empty($offset)) {
print '<td class="left">'.$langs->trans("Total").'</td>'; print '<td class="left">'.$langs->trans("Total").'</td>';
} else { } else {
print '<td class="left">'.$langs->trans("Totalforthispage").'</td>'; print '<td class="left">'.$form->textwithpicto($langs->trans("Total"), $langs->trans("Totalforthispage")).'</td>';
} }
} elseif ($totalarray['totaldurationfield'] == $i) { } elseif ($totalarray['totaldurationfield'] == $i) {
print '<td class="right">'.convertSecondToTime($totalarray['totalduration'], 'allhourmin').'</td>'; print '<td class="right">'.convertSecondToTime($totalarray['totalduration'], 'allhourmin').'</td>';