diff --git a/htdocs/core/lib/project.lib.php b/htdocs/core/lib/project.lib.php index ad2385c3be3..9e1b3a36048 100644 --- a/htdocs/core/lib/project.lib.php +++ b/htdocs/core/lib/project.lib.php @@ -871,9 +871,12 @@ function projectLinesPerAction(&$inc, $parent, $fuser, $lines, &$level, &$projec * @param int $preselectedday Preselected day * @param array $isavailable Array with data that say if user is available for several days for morning and afternoon * @param int $oldprojectforbreak Old project id of last project break + * @param array $arrayfields Array of additional column + * @param array $extrafields Array of additional column + * @param array $extralabels Array of additional column * @return array Array with time spent for $fuser for each day of week on tasks in $lines and substasks */ -function projectLinesPerDay(&$inc, $parent, $fuser, $lines, &$level, &$projectsrole, &$tasksrole, $mine, $restricteditformytask, $preselectedday, &$isavailable, $oldprojectforbreak = 0) +function projectLinesPerDay(&$inc, $parent, $fuser, $lines, &$level, &$projectsrole, &$tasksrole, $mine, $restricteditformytask, $preselectedday, &$isavailable, $oldprojectforbreak = 0, $arrayfields=array(), $extrafields='', $extralabels=array()) { global $conf, $db, $user, $bc, $langs; global $form, $formother, $projectstatic, $taskstatic, $thirdpartystatic; @@ -906,6 +909,8 @@ function projectLinesPerDay(&$inc, $parent, $fuser, $lines, &$level, &$projectsr if ($lines[$i]->fk_task_parent == $parent) { + $obj = &$lines[$i]; // To display extrafields + // If we want all or we have a role on task, we show it if (empty($mine) || ! empty($tasksrole[$lines[$i]->id])) { @@ -952,8 +957,14 @@ function projectLinesPerDay(&$inc, $parent, $fuser, $lines, &$level, &$projectsr if (empty($oldprojectforbreak) || ($oldprojectforbreak != -1 && $oldprojectforbreak != $projectstatic->id)) { + $addcolspan=0; + foreach ($arrayfields as $key => $val) + { + if ($val['checked'] && substr($key, 0, 5) == 'efpt.') $addcolspan++; + } + print ''."\n"; - print ''; + print ''; print $projectstatic->getNomUrl(1, '', 0, ''.$langs->transnoentitiesnoconv("YourRole").': '.$projectsrole[$lines[$i]->fk_project]); if ($thirdpartystatic->id > 0) print ' - '.$thirdpartystatic->getNomUrl(1); if ($projectstatic->title) @@ -961,6 +972,66 @@ function projectLinesPerDay(&$inc, $parent, $fuser, $lines, &$level, &$projectsr print ' - '; print $projectstatic->title; } + + $colspan=5+(empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)?0:2); + print ''; + + print ''; + + // PROJECT fields + if (! empty($arrayfields['p.fk_opp_status']['checked'])) print_liste_field_titre($arrayfields['p.fk_opp_status']['label'], $_SERVER["PHP_SELF"], 'p.fk_opp_status', "", $param, '', $sortfield, $sortorder, 'center '); + if (! empty($arrayfields['p.opp_amount']['checked'])) print_liste_field_titre($arrayfields['p.opp_amount']['label'], $_SERVER["PHP_SELF"], 'p.opp_amount', "", $param, '', $sortfield, $sortorder, 'right '); + if (! empty($arrayfields['p.opp_percent']['checked'])) print_liste_field_titre($arrayfields['p.opp_percent']['label'], $_SERVER["PHP_SELF"], 'p.opp_percent', "", $param, '', $sortfield, $sortorder, 'right '); + if (! empty($arrayfields['p.budget_amount']['checked'])) print_liste_field_titre($arrayfields['p.budget_amount']['label'], $_SERVER["PHP_SELF"], 'p.budget_amount', "", $param, '', $sortfield, $sortorder, 'right '); + if (! empty($arrayfields['p.bill_time']['checked'])) print_liste_field_titre($arrayfields['p.bill_time']['label'], $_SERVER["PHP_SELF"], 'p.bill_time', "", $param, '', $sortfield, $sortorder, 'right '); + + $extrafieldsobjectkey='projet'; + $extrafieldsobjectprefix='efp.'; + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; + + print ''; + print ''; + + // PROJECT fields + if (! empty($arrayfields['p.fk_opp_status']['checked'])) + { + print '\n"; + } + if (! empty($arrayfields['p.opp_amount']['checked'])) + { + print '\n"; + } + if (! empty($arrayfields['p.opp_percent']['checked'])) + { + print '\n"; + } + if (! empty($arrayfields['p.budget_amount']['checked'])) + { + print '\n"; + } + if (! empty($arrayfields['p.bill_time']['checked'])) + { + print '\n"; + } + + $extrafieldsobjectkey='projet'; + $extrafieldsobjectprefix='efp.'; + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; + + print ''; + print '
'; + $code = dol_getIdFromCode($db, $lines[$i]->fk_opp_status, 'c_lead_status', 'rowid', 'code'); + if ($code) print $langs->trans("OppStatus".$code); + print "'; + print price($lines[$i]->opp_amount, 0, $langs, 1, 0, -1, $conf->currency); + print "'; + print price($lines[$i]->opp_percent, 0, $langs, 1, 0).' %'; + print "'; + print price($lines[$i]->budget_amount, 0, $langs, 1, 0, 0, $conf->currency); + print "'; + print yn($lines[$i]->bill_time); + print "
'; + print ''; print ''; } @@ -1000,7 +1071,12 @@ function projectLinesPerDay(&$inc, $parent, $fuser, $lines, &$level, &$projectsr //print get_date_range($lines[$i]->date_start,$lines[$i]->date_end,'',$langs,0); print "\n"; - // Planned Workload + // TASK extrafields + $extrafieldsobjectkey='projet_task'; + $extrafieldsobjectprefix='efpt.'; + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; + + // Planned Workload print ''; if ($lines[$i]->planned_workload) print convertSecondToTime($lines[$i]->planned_workload, 'allhourmin'); else print '--:--'; @@ -1123,7 +1199,7 @@ function projectLinesPerDay(&$inc, $parent, $fuser, $lines, &$level, &$projectsr { //var_dump('totalforeachday after taskid='.$lines[$i]->id.' and previous one on level '.$level); //var_dump($totalforeachday); - $ret = projectLinesPerDay($inc, $lines[$i]->id, $fuser, ($parent == 0 ? $lineswithoutlevel0 : $lines), $level, $projectsrole, $tasksrole, $mine, $restricteditformytask, $preselectedday, $isavailable, $oldprojectforbreak); + $ret = projectLinesPerDay($inc, $lines[$i]->id, $fuser, ($parent == 0 ? $lineswithoutlevel0 : $lines), $level, $projectsrole, $tasksrole, $mine, $restricteditformytask, $preselectedday, $isavailable, $oldprojectforbreak, $arrayfields, $extrafields, $extralabels); //var_dump('ret with parent='.$lines[$i]->id.' level='.$level); //var_dump($ret); foreach($ret as $key => $val) diff --git a/htdocs/projet/activity/perday.php b/htdocs/projet/activity/perday.php index 7fe2d0af8a6..2a202e5f7c4 100644 --- a/htdocs/projet/activity/perday.php +++ b/htdocs/projet/activity/perday.php @@ -43,6 +43,8 @@ $mode=GETPOST("mode", 'alpha'); $id=GETPOST('id', 'int'); $taskid=GETPOST('taskid', 'int'); +$contextpage=GETPOST('contextpage', 'aZ')?GETPOST('contextpage', 'aZ'):'perdaycard'; + $mine=0; if ($mode == 'mine') $mine=1; @@ -102,6 +104,39 @@ else $object=new Task($db); +$arrayfields=array( + // Project + 'p.opp_amount'=>array('label'=>$langs->trans("OpportunityAmountShort"), 'checked'=>0, 'enabled'=>($conf->global->PROJECT_USE_OPPORTUNITIES?1:0), 'position'=>103), + 'p.fk_opp_status'=>array('label'=>$langs->trans("OpportunityStatusShort"), 'checked'=>0, 'enabled'=>($conf->global->PROJECT_USE_OPPORTUNITIES?1:0), 'position'=>104), + 'p.opp_percent'=>array('label'=>$langs->trans("OpportunityProbabilityShort"), 'checked'=>0, 'enabled'=>($conf->global->PROJECT_USE_OPPORTUNITIES?1:0), 'position'=>105), + 'p.budget_amount'=>array('label'=>$langs->trans("Budget"), 'checked'=>0, 'position'=>110), + 'p.bill_time'=>array('label'=>$langs->trans("BillTimeShort"), 'checked'=>0, 'position'=>115), +); + +// Extra fields +$extrafields = new ExtraFields($db); + +// fetch optionals attributes and labels +$extralabels = $extrafields->fetch_name_optionals_label('projet'); +if (!empty($extrafields->attributes['projet']['label'])) +{ + foreach($extrafields->attributes['projet']['label'] as $key => $val) + { + if (! empty($extrafields->attributes['projet']['list'][$key])) $arrayfields["efp.".$key]=array('label'=>$extrafields->attributes['projet']['label'][$key], 'checked'=>(($extrafields->attributes['projet']['list'][$key]<0)?0:1), 'position'=>$extrafields->attributes['projet']['pos'][$key], 'enabled'=>(abs($extrafields->attributes['projet']['list'][$key])!=3 && $extrafields->attributes['projet']['perms'][$key])); + } +} +$extralabels+= $extrafields->fetch_name_optionals_label('projet_task', true); +if (!empty($extrafields->attributes['projet_task']['label'])) +{ + foreach($extrafields->attributes['projet_task']['label'] as $key => $val) + { + if (! empty($extrafields->attributes['projet_task']['list'][$key])) $arrayfields["efpt.".$key]=array('label'=>$extrafields->attributes['projet_task']['label'][$key], 'checked'=>(($extrafields->attributes['projet_task']['list'][$key]<0)?0:1), 'position'=>$extrafields->attributes['projet_task']['pos'][$key], 'enabled'=>(abs($extrafields->attributes['projet_task']['list'][$key])!=3 && $extrafields->attributes['projet_task']['perms'][$key])); + } +} + +$search_array_options=array(); +$search_array_options_project=$extrafields->getOptionalsFromPost('projet', '', 'search_'); +$search_array_options_task=$extrafields->getOptionalsFromPost('projet_task', '', 'search_task_'); /* * Actions @@ -119,6 +154,9 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x' $search_thirdparty = ''; $search_declared_progress = ''; + $search_array_options_project = array(); + $search_array_options_task = array(); + // We redefine $usertoprocess $usertoprocess=$user; } @@ -137,8 +175,9 @@ if (GETPOST('submitdateselect')) $action = ''; } +include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; -if ($action == 'addtime' && $user->rights->projet->lire && GETPOST('assigntask')) +if ($action == 'addtime' && $user->rights->projet->lire && GETPOST('assigntask') && GETPOST('formfilteraction') != 'listafterchangingselectedfields') { $action = 'assigntask'; @@ -215,7 +254,7 @@ if ($action == 'addtime' && $user->rights->projet->lire && GETPOST('assigntask') $action=''; } -if ($action == 'addtime' && $user->rights->projet->lire) +if ($action == 'addtime' && $user->rights->projet->lire && GETPOST('formfilteraction') != 'listafterchangingselectedfields') { $timespent_duration=array(); @@ -341,7 +380,21 @@ if ($search_task_label) $morewherefilter.=natural_search(array("t.ref", "t.labe if ($search_thirdparty) $morewherefilter.=natural_search("s.nom", $search_thirdparty); if ($search_declared_progress) $morewherefilter.=natural_search("t.progress", $search_declared_progress, 1); -$tasksarray=$taskstatic->getTasksArray(0, 0, ($project->id?$project->id:0), $socid, 0, $search_project_ref, $onlyopenedproject, $morewherefilter, ($search_usertoprocessid?$search_usertoprocessid:0)); // We want to see all task of opened project i am allowed to see and that match filter, not only my tasks. Later only mine will be editable later. +$sql = &$morewherefilter; + +$search_array_options = $search_array_options_project; +$extrafieldsobjectprefix='efp.'; +$search_options_pattern='search_options_'; +$extrafieldsobjectkey='projet'; +include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; + +$search_array_options = $search_array_options_task; +$extrafieldsobjectprefix='efpt.'; +$search_options_pattern='search_task_options_'; +$extrafieldsobjectkey='projet_task'; +include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; + +$tasksarray=$taskstatic->getTasksArray(0, 0, ($project->id?$project->id:0), $socid, 0, $search_project_ref, $onlyopenedproject, $morewherefilter, ($search_usertoprocessid?$search_usertoprocessid:0), 0, $extrafields); // We want to see all task of opened project i am allowed to see and that match filter, not only my tasks. Later only mine will be editable later. if ($morewherefilter) // Get all task without any filter, so we can show total of time spent for not visible tasks { $tasksarraywithoutfilter=$taskstatic->getTasksArray(0, 0, ($project->id?$project->id:0), $socid, 0, '', $onlyopenedproject, '', ($search_usertoprocessid?$search_usertoprocessid:0)); // We want to see all task of opened project i am allowed to see and that match filter, not only my tasks. Later only mine will be editable later. @@ -364,6 +417,21 @@ $param.=($search_thirdparty?'&search_thirdparty='.$search_thirdparty:''); $param.=($search_task_ref?'&search_task_ref='.$search_task_ref:''); $param.=($search_task_label?'&search_task_label='.$search_task_label:''); +$search_array_options=$search_array_options_project; +$search_options_pattern='search_options_'; +include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; + +$search_array_options=$search_array_options_task; +$search_options_pattern='search_task_options_'; +include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; + +// Project +//$search_pattern='search_options_'; +//include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; +// Task +$search_options_pattern='search_task_options_'; +include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; + // Show navigation bar $nav =''.img_previous($langs->trans("Previous"))."\n"; $nav.=dol_print_date(dol_mktime(0, 0, 0, $month, $day, $year), "%A").' '; @@ -378,6 +446,8 @@ $picto='calendarweek'; print '
id > 0 ? '?id='.$project->id : '').'">'; print ''; print ''; +print ''; +print ''; print ''; $tmp = dol_getdate($daytoparse); print ''; @@ -477,6 +547,23 @@ print ''; if (! empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) print ''; if (! empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) print ''; print ''; + +$varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; +$selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields + +$addcolspan=0; +foreach ($arrayfields as $key => $val) +{ + if ($val['checked'] && substr($key, 0, 5) == 'efpt.') $addcolspan++; +} + +// TASK fields +$search_options_pattern='search_task_options_'; +$extrafieldsobjectkey='projet_task'; +$extrafieldsobjectprefix='efpt.'; +include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; + + print ''; print ''; print ''; @@ -495,6 +582,13 @@ print ''; if (! empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) print ''.$langs->trans("Project").''; if (! empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) print ''.$langs->trans("ThirdParty").''; print ''.$langs->trans("Task").''; + +// TASK fields +$extrafieldsobjectkey='projet_task'; +$extrafieldsobjectprefix='efpt.'; +include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; + + print ''.$langs->trans("PlannedWorkload").''; print ''.$langs->trans("ProgressDeclared").''; /*print ''.$langs->trans("TimeSpent").''; @@ -541,7 +635,9 @@ elseif (! $isavailable[$daytoparse]['afternoon']) $cssonholiday.='onholidayafter print ''.$langs->trans("Duration").''; print ''.$langs->trans("Note").''; -print ''; +//print ''; +print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch '); + print "\n"; $colspan = 6+(empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)?0:2); @@ -549,7 +645,7 @@ $colspan = 6+(empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)?0: if ($conf->use_javascript_ajax) { print ''; - print ''; + print ''; print $langs->trans("Total"); print ''; print ''; @@ -586,7 +682,7 @@ if (count($tasksarray) > 0) $j=0; $level=0; - $totalforvisibletasks = projectLinesPerDay($j, 0, $usertoprocess, $tasksarray, $level, $projectsrole, $tasksrole, $mine, $restrictviewformytask, $daytoparse, $isavailable, 0); + $totalforvisibletasks = projectLinesPerDay($j, 0, $usertoprocess, $tasksarray, $level, $projectsrole, $tasksrole, $mine, $restrictviewformytask, $daytoparse, $isavailable, 0, $arrayfields, $extrafields, $extralabels); //var_dump($totalforvisibletasks); // Show total for all other tasks @@ -650,7 +746,7 @@ if (count($tasksarray) > 0) if ($conf->use_javascript_ajax) { print ''; - print ''; + print ''; print $langs->trans("Total"); print ''; print ''; diff --git a/htdocs/projet/activity/perweek.php b/htdocs/projet/activity/perweek.php index 6d6c8cb046a..a54538de6f6 100644 --- a/htdocs/projet/activity/perweek.php +++ b/htdocs/projet/activity/perweek.php @@ -184,7 +184,7 @@ if (GETPOST('submitdateselect')) include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; -if ($action == 'addtime' && $user->rights->projet->lire && GETPOST('assigntask')) +if ($action == 'addtime' && $user->rights->projet->lire && GETPOST('assigntask') && GETPOST('formfilteraction') != 'listafterchangingselectedfields') { $action = 'assigntask'; @@ -262,7 +262,7 @@ if ($action == 'addtime' && $user->rights->projet->lire && GETPOST('assigntask') $action=''; } -if ($action == 'addtime' && $user->rights->projet->lire) +if ($action == 'addtime' && $user->rights->projet->lire && GETPOST('formfilteraction') != 'listafterchangingselectedfields') { $timetoadd=$_POST['task']; if (empty($timetoadd)) @@ -405,7 +405,7 @@ $search_options_pattern='search_task_options_'; $extrafieldsobjectkey='projet_task'; include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; -$tasksarray=$taskstatic->getTasksArray(0, 0, ($project->id?$project->id:0), $socid, 0, $search_project_ref, $onlyopenedproject, $morewherefilter, ($search_usertoprocessid?$search_usertoprocessid:0), 0, $extrafields, $extralabels); // We want to see all tasks of open project i am allowed to see and that match filter, not only my tasks. Later only mine will be editable later. +$tasksarray=$taskstatic->getTasksArray(0, 0, ($project->id?$project->id:0), $socid, 0, $search_project_ref, $onlyopenedproject, $morewherefilter, ($search_usertoprocessid?$search_usertoprocessid:0), 0, $extrafields); // We want to see all tasks of open project i am allowed to see and that match filter, not only my tasks. Later only mine will be editable later. if ($morewherefilter) // Get all task without any filter, so we can show total of time spent for not visible tasks { $tasksarraywithoutfilter=$taskstatic->getTasksArray(0, 0, ($project->id?$project->id:0), $socid, 0, '', $onlyopenedproject, '', ($search_usertoprocessid?$search_usertoprocessid:0)); // We want to see all tasks of open project i am allowed to see and that match filter, not only my tasks. Later only mine will be editable later.