new: Add thirdparty column to task time list

This commit is contained in:
Florian HENRY 2022-07-03 13:02:42 +02:00
parent a6fd9203fa
commit 1216294667

View File

@ -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 '</td>';
}
// Thirdparty
if (!empty($arrayfields['p.fk_soc']['checked'])) {
print '<td class="liste_titre"><input type="text" class="flat maxwidth100" name="$search_company" value="'.dol_escape_htmltag($search_company).'"></td>';
}
if (!empty($allprojectforuser)) {
print '<td class="liste_titre"></td>';
}
@ -1706,6 +1718,23 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser
}
}
// Thirdparty
if (!empty($arrayfields['p.fk_soc']['checked'])) {
print '<td class="nowrap">';
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 '</td>';
if (!$i) {
$totalarray['nbfield']++;
}
}
// Project ref
if (!empty($allprojectforuser)) {
print '<td class="nowraponall">';
@ -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