From a6fd9203fa42631abd0e867c3693868c4a77ffcc Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Sun, 3 Jul 2022 00:26:01 +0200 Subject: [PATCH 1/3] on going --- htdocs/projet/tasks/time.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/htdocs/projet/tasks/time.php b/htdocs/projet/tasks/time.php index ab93e3561b0..b237afcb5b1 100644 --- a/htdocs/projet/tasks/time.php +++ b/htdocs/projet/tasks/time.php @@ -73,6 +73,7 @@ $search_task_ref = GETPOST('search_task_ref', 'alpha'); $search_task_label = GETPOST('search_task_label', 'alpha'); $search_user = GETPOST('search_user', 'int'); $search_valuebilled = GETPOST('search_valuebilled', 'int'); +$search_thirdparty = GETPOST('search_thirdparty', 'alpha'); $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'aZ09comma'); @@ -164,6 +165,7 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x' $search_task_label = ''; $search_user = 0; $search_valuebilled = ''; + $search_thirdparty = ''; $toselect = array(); $search_array_options = array(); $action = ''; @@ -1071,6 +1073,7 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser // Definition of fields for list $arrayfields = array(); $arrayfields['t.task_date'] = array('label'=>$langs->trans("Date"), 'checked'=>1); + $arrayfields['p.fk_soc'] = array('label'=>$langs->trans("Thirdparty"), 'type'=>'integer:Societe:/societe/class/societe.class.php:1','checked'=>1); if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) { // Not a dedicated task $arrayfields['t.task_ref'] = array('label'=>$langs->trans("RefTask"), 'checked'=>1); $arrayfields['t.task_label'] = array('label'=>$langs->trans("LabelTask"), 'checked'=>1); @@ -1113,6 +1116,9 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser if ($search_duration != '') { $param .= '&search_field2='.urlencode($search_duration); } + if ($search_thirdparty != '') { + $param .= '&search_thirdparty='.urlencode($search_thirdparty); + } if ($optioncss != '') { $param .= '&optioncss='.urlencode($optioncss); } @@ -1624,6 +1630,9 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser if (!empty($arrayfields['t.task_date']['checked'])) { print_liste_field_titre($arrayfields['t.task_date']['label'], $_SERVER['PHP_SELF'], 't.task_date,t.task_datehour,t.rowid', '', $param, '', $sortfield, $sortorder); } + if (!empty($arrayfields['p.fk_soc']['checked'])) { + print_liste_field_titre($arrayfields['p.fk_soc']['label'], $_SERVER['PHP_SELF'], 't.task_date,t.task_datehour,t.rowid', '', $param, '', $sortfield, $sortorder); + } if (!empty($allprojectforuser)) { print_liste_field_titre("Project", $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder); } @@ -1714,6 +1723,9 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser } } + if (!empty($arrayfields['p.fk_soc']['checked'])) { + } + // Task ref if (!empty($arrayfields['t.task_ref']['checked'])) { if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) { // Not a dedicated task From 1216294667035a9cef4fc04ced7b985c373816fb Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Sun, 3 Jul 2022 13:02:42 +0200 Subject: [PATCH 2/3] new: Add thirdparty column to task time list --- htdocs/projet/tasks/time.php | 52 +++++++++++++++++++++++++++--------- 1 file changed, 39 insertions(+), 13 deletions(-) diff --git a/htdocs/projet/tasks/time.php b/htdocs/projet/tasks/time.php index b237afcb5b1..e674246b6a9 100644 --- a/htdocs/projet/tasks/time.php +++ b/htdocs/projet/tasks/time.php @@ -38,7 +38,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formintervention.class.php'; // Load translation files required by the page -$langsLoad=array('projects', 'bills', 'orders'); +$langsLoad=array('projects', 'bills', 'orders', 'companies'); if (!empty($conf->eventorganization->enabled)) { $langsLoad[]='eventorganization'; } @@ -73,7 +73,7 @@ $search_task_ref = GETPOST('search_task_ref', 'alpha'); $search_task_label = GETPOST('search_task_label', 'alpha'); $search_user = GETPOST('search_user', 'int'); $search_valuebilled = GETPOST('search_valuebilled', 'int'); -$search_thirdparty = GETPOST('search_thirdparty', 'alpha'); +$search_company = GETPOST('$search_company', 'alpha'); $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'aZ09comma'); @@ -162,10 +162,10 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x' $search_date_creation = ''; $search_date_update = ''; $search_task_ref = ''; + $search_company = ''; $search_task_label = ''; $search_user = 0; $search_valuebilled = ''; - $search_thirdparty = ''; $toselect = array(); $search_array_options = array(); $action = ''; @@ -1073,7 +1073,7 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser // Definition of fields for list $arrayfields = array(); $arrayfields['t.task_date'] = array('label'=>$langs->trans("Date"), 'checked'=>1); - $arrayfields['p.fk_soc'] = array('label'=>$langs->trans("Thirdparty"), 'type'=>'integer:Societe:/societe/class/societe.class.php:1','checked'=>1); + $arrayfields['p.fk_soc'] = array('label'=>$langs->trans("ThirdParty"), 'type'=>'integer:Societe:/societe/class/societe.class.php:1','checked'=>1); if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) { // Not a dedicated task $arrayfields['t.task_ref'] = array('label'=>$langs->trans("RefTask"), 'checked'=>1); $arrayfields['t.task_label'] = array('label'=>$langs->trans("LabelTask"), 'checked'=>1); @@ -1107,6 +1107,9 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser if ($search_task_ref != '') { $param .= '&search_task_ref='.urlencode($search_task_ref); } + if ($search_company != '') { + $param .= '&$search_company='.urlencode($search_company); + } if ($search_task_label != '') { $param .= '&search_task_label='.urlencode($search_task_label); } @@ -1116,9 +1119,6 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser if ($search_duration != '') { $param .= '&search_field2='.urlencode($search_duration); } - if ($search_thirdparty != '') { - $param .= '&search_thirdparty='.urlencode($search_thirdparty); - } if ($optioncss != '') { $param .= '&optioncss='.urlencode($optioncss); } @@ -1310,6 +1310,7 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser $sql .= " pt.ref, pt.label, pt.fk_projet,"; $sql .= " u.lastname, u.firstname, u.login, u.photo, u.statut as user_status,"; $sql .= " il.fk_facture as invoice_id, inv.fk_statut,"; + $sql .= " p.fk_soc,"; // Add fields from hooks $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook @@ -1318,13 +1319,16 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser $sql .= " FROM ".MAIN_DB_PREFIX."projet_task_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."facture as inv ON inv.rowid = il.fk_facture"; + $sql .= " INNER JOIN ".MAIN_DB_PREFIX."projet_task as pt ON pt.rowid = t.fk_task"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as u ON t.fk_user = u.rowid"; + $sql .= " INNER JOIN ".MAIN_DB_PREFIX."projet as p ON p.rowid = pt.fk_projet"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = p.fk_soc"; + // Add table from hooks $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListFrom', $parameters, $object); // Note that $action and $object may have been modified by hook $sql .= $hookmanager->resPrint; - $sql .= ", ".MAIN_DB_PREFIX."projet_task as pt, ".MAIN_DB_PREFIX."user as u"; - $sql .= " WHERE t.fk_user = u.rowid AND t.fk_task = pt.rowid"; - + $sql .= " WHERE 1 = 1 "; if (empty($projectidforalltimes) && empty($allprojectforuser)) { // Limit on one task $sql .= " AND t.fk_task =".((int) $object->id); @@ -1345,6 +1349,9 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser if ($search_task_ref) { $sql .= natural_search('pt.ref', $search_task_ref); } + if ($search_company) { + $sql .= natural_search('s.nom', $search_company); + } if ($search_task_label) { $sql .= natural_search('pt.label', $search_task_label); } @@ -1578,6 +1585,11 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser print $formother->selectyear($search_year, 'search_year', 1, 20, 5); print ''; } + // Thirdparty + if (!empty($arrayfields['p.fk_soc']['checked'])) { + print ''; + } + if (!empty($allprojectforuser)) { print ''; } @@ -1706,6 +1718,23 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser } } + // Thirdparty + if (!empty($arrayfields['p.fk_soc']['checked'])) { + print ''; + if (empty($conf->cache['thridparty'][$task_time->fk_soc])) { + $tmpsociete = new Societe($db); + $tmpsociete->fetch($task_time->fk_soc); + $conf->cache['thridparty'][$task_time->fk_soc] = $tmpsociete; + } else { + $tmpsociete = $conf->cache['thridparty'][$task_time->fk_soc]; + } + print $tmpsociete->getNomUrl(1); + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Project ref if (!empty($allprojectforuser)) { print ''; @@ -1723,9 +1752,6 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser } } - if (!empty($arrayfields['p.fk_soc']['checked'])) { - } - // Task ref if (!empty($arrayfields['t.task_ref']['checked'])) { if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) { // Not a dedicated task From eab3541ca56dad38d24078d6167295fb02ab81b4 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Sun, 3 Jul 2022 13:07:25 +0200 Subject: [PATCH 3/3] better sql request --- htdocs/projet/tasks/time.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/projet/tasks/time.php b/htdocs/projet/tasks/time.php index e674246b6a9..801e0cb0a00 100644 --- a/htdocs/projet/tasks/time.php +++ b/htdocs/projet/tasks/time.php @@ -1320,7 +1320,7 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser $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 .= " INNER JOIN ".MAIN_DB_PREFIX."projet_task as pt ON pt.rowid = t.fk_task"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as u ON t.fk_user = u.rowid"; + $sql .= " INNER JOIN ".MAIN_DB_PREFIX."user as u ON t.fk_user = u.rowid"; $sql .= " INNER JOIN ".MAIN_DB_PREFIX."projet as p ON p.rowid = pt.fk_projet"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = p.fk_soc";