New evol "Input per week" display
This commit is contained in:
parent
23ce97fb2d
commit
fa41eeec7f
@ -1160,9 +1160,12 @@ function projectLinesPerDay(&$inc, $parent, $fuser, $lines, &$level, &$projectsr
|
||||
* @param int $restricteditformytask 0=No restriction, 1=Enable add time only if task is assigned to me, 2=Enable add time only if tasks is assigned to me and hide others
|
||||
* @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 projectLinesPerWeek(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &$level, &$projectsrole, &$tasksrole, $mine, $restricteditformytask, &$isavailable, $oldprojectforbreak = 0)
|
||||
function projectLinesPerWeek(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &$level, &$projectsrole, &$tasksrole, $mine, $restricteditformytask, &$isavailable, $oldprojectforbreak = 0, $arrayfields=array(), $extrafields='', $extralabels=array())
|
||||
{
|
||||
global $conf, $db, $user, $bc, $langs;
|
||||
global $form, $formother, $projectstatic, $taskstatic, $thirdpartystatic;
|
||||
@ -1196,6 +1199,8 @@ function projectLinesPerWeek(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &$
|
||||
|
||||
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]))
|
||||
{
|
||||
@ -1241,8 +1246,14 @@ function projectLinesPerWeek(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &$
|
||||
|
||||
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 '<tr class="oddeven trforbreak">'."\n";
|
||||
print '<td colspan="13">';
|
||||
print '<td colspan="'.(13+$addcolspan).'">';
|
||||
print $projectstatic->getNomUrl(1, '', 0, '<strong>'.$langs->transnoentitiesnoconv("YourRole").':</strong> '.$projectsrole[$lines[$i]->fk_project]);
|
||||
if ($thirdpartystatic->id > 0) print ' - '.$thirdpartystatic->getNomUrl(1);
|
||||
if ($projectstatic->title)
|
||||
@ -1250,6 +1261,66 @@ function projectLinesPerWeek(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &$
|
||||
print ' - ';
|
||||
print $projectstatic->title;
|
||||
}
|
||||
|
||||
$colspan=5+(empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)?0:2);
|
||||
print '<table class="">';
|
||||
|
||||
print '<tr class="liste_titre">';
|
||||
|
||||
// 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 '</tr>';
|
||||
print '<tr>';
|
||||
|
||||
// PROJECT fields
|
||||
if (! empty($arrayfields['p.fk_opp_status']['checked']))
|
||||
{
|
||||
print '<td class="nowrap">';
|
||||
$code = dol_getIdFromCode($db, $lines[$i]->fk_opp_status, 'c_lead_status', 'rowid', 'code');
|
||||
if ($code) print $langs->trans("OppStatus".$code);
|
||||
print "</td>\n";
|
||||
}
|
||||
if (! empty($arrayfields['p.opp_amount']['checked']))
|
||||
{
|
||||
print '<td class="nowrap">';
|
||||
print price($lines[$i]->opp_amount, 0, $langs, 1, 0, -1, $conf->currency);
|
||||
print "</td>\n";
|
||||
}
|
||||
if (! empty($arrayfields['p.opp_percent']['checked']))
|
||||
{
|
||||
print '<td class="nowrap">';
|
||||
print price($lines[$i]->opp_percent, 0, $langs, 1, 0).' %';
|
||||
print "</td>\n";
|
||||
}
|
||||
if (! empty($arrayfields['p.budget_amount']['checked']))
|
||||
{
|
||||
print '<td class="nowrap">';
|
||||
print price($lines[$i]->budget_amount, 0, $langs, 1, 0, 0, $conf->currency);
|
||||
print "</td>\n";
|
||||
}
|
||||
if (! empty($arrayfields['p.bill_time']['checked']))
|
||||
{
|
||||
print '<td class="nowrap">';
|
||||
print yn($lines[$i]->bill_time);
|
||||
print "</td>\n";
|
||||
}
|
||||
|
||||
$extrafieldsobjectkey='projet';
|
||||
$extrafieldsobjectprefix='efp.';
|
||||
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
|
||||
|
||||
print '</tr>';
|
||||
print '</table>';
|
||||
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
}
|
||||
@ -1290,7 +1361,13 @@ function projectLinesPerWeek(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &$
|
||||
//print get_date_range($lines[$i]->date_start,$lines[$i]->date_end,'',$langs,0);
|
||||
print "</td>\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 '<td class="leftborder plannedworkload right">';
|
||||
if ($lines[$i]->planned_workload) print convertSecondToTime($lines[$i]->planned_workload, 'allhourmin');
|
||||
else print '--:--';
|
||||
@ -1402,7 +1479,7 @@ function projectLinesPerWeek(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &$
|
||||
{
|
||||
//var_dump('totalforeachday after taskid='.$lines[$i]->id.' and previous one on level '.$level);
|
||||
//var_dump($totalforeachday);
|
||||
$ret = projectLinesPerWeek($inc, $firstdaytoshow, $fuser, $lines[$i]->id, ($parent == 0 ? $lineswithoutlevel0 : $lines), $level, $projectsrole, $tasksrole, $mine, $restricteditformytask, $isavailable, $oldprojectforbreak);
|
||||
$ret = projectLinesPerWeek($inc, $firstdaytoshow, $fuser, $lines[$i]->id, ($parent == 0 ? $lineswithoutlevel0 : $lines), $level, $projectsrole, $tasksrole, $mine, $restricteditformytask, $isavailable, $oldprojectforbreak, $arrayfields, $extrafields, $extralabels);
|
||||
//var_dump('ret with parent='.$lines[$i]->id.' level='.$level);
|
||||
//var_dump($ret);
|
||||
foreach($ret as $key => $val)
|
||||
|
||||
@ -14,9 +14,11 @@ if (! empty($extrafieldsobjectkey)) // $extrafieldsobject is the $object->table_
|
||||
{
|
||||
if (is_array($extrafields->attributes[$extrafieldsobjectkey]['label']) && count($extrafields->attributes[$extrafieldsobjectkey]['label']))
|
||||
{
|
||||
foreach($extrafields->attributes[$extrafieldsobjectkey]['label'] as $key => $val)
|
||||
if (empty($extrafieldsobjectprefix)) $extrafieldsobjectprefix = 'ef.';
|
||||
|
||||
foreach($extrafields->attributes[$extrafieldsobjectkey]['label'] as $key => $val)
|
||||
{
|
||||
if (! empty($arrayfields["ef.".$key]['checked']))
|
||||
if (! empty($arrayfields[$extrafieldsobjectprefix.$key]['checked']))
|
||||
{
|
||||
$align=$extrafields->getAlignFlag($key, $extrafieldsobjectkey);
|
||||
print '<td';
|
||||
@ -24,6 +26,7 @@ if (! empty($extrafieldsobjectkey)) // $extrafieldsobject is the $object->table_
|
||||
print ' data-key="'.$key.'"';
|
||||
print '>';
|
||||
$tmpkey='options_'.$key;
|
||||
|
||||
if (in_array($extrafields->attributes[$extrafieldsobjectkey]['type'][$key], array('date', 'datetime', 'timestamp')) && !is_numeric($obj->$tmpkey))
|
||||
{
|
||||
$datenotinstring = $obj->$tmpkey;
|
||||
@ -51,8 +54,8 @@ if (! empty($extrafieldsobjectkey)) // $extrafieldsobject is the $object->table_
|
||||
}
|
||||
if (! empty($val['isameasure']))
|
||||
{
|
||||
if (! $i) $totalarray['pos'][$totalarray['nbfield']]='ef.'.$tmpkey;
|
||||
$totalarray['val']['ef.'.$tmpkey] += $obj->$tmpkey;
|
||||
if (! $i) $totalarray['pos'][$totalarray['nbfield']]=$extrafieldsobjectprefix.$tmpkey;
|
||||
$totalarray['val'][$extrafieldsobjectprefix.$tmpkey] += $obj->$tmpkey;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -14,27 +14,30 @@ if (! empty($extrafieldsobjectkey)) // $extrafieldsobject is the $object->table_
|
||||
{
|
||||
if (is_array($extrafields->attributes[$extrafieldsobjectkey]['label']) && count($extrafields->attributes[$extrafieldsobjectkey]['label']))
|
||||
{
|
||||
if (empty($extrafieldsobjectprefix)) $extrafieldsobjectprefix = 'ef.';
|
||||
if (empty($search_options_pattern)) $search_options_pattern='search_options_';
|
||||
|
||||
foreach($extrafields->attributes[$extrafieldsobjectkey]['label'] as $key => $val)
|
||||
{
|
||||
if (! empty($arrayfields["ef.".$key]['checked'])) {
|
||||
if (! empty($arrayfields[$extrafieldsobjectprefix.$key]['checked'])) {
|
||||
$align=$extrafields->getAlignFlag($key);
|
||||
$typeofextrafield=$extrafields->attributes[$extrafieldsobjectkey]['type'][$key];
|
||||
print '<td class="liste_titre'.($align?' '.$align:'').'">';
|
||||
if (in_array($typeofextrafield, array('varchar', 'int', 'double', 'select')) && empty($extrafields->attributes[$extrafieldsobjectkey]['computed'][$key]))
|
||||
{
|
||||
$crit=$val;
|
||||
$tmpkey=preg_replace('/search_options_/', '', $key);
|
||||
$tmpkey=preg_replace('/'.$search_options_pattern.'/', '', $key);
|
||||
$searchclass='';
|
||||
if (in_array($typeofextrafield, array('varchar', 'select'))) $searchclass='searchstring';
|
||||
if (in_array($typeofextrafield, array('int', 'double'))) $searchclass='searchnum';
|
||||
print '<input class="flat'.($searchclass?' '.$searchclass:'').'" size="4" type="text" name="search_options_'.$tmpkey.'" value="'.dol_escape_htmltag($search_array_options['search_options_'.$tmpkey]).'">';
|
||||
print '<input class="flat'.($searchclass?' '.$searchclass:'').'" size="4" type="text" name="'.$search_options_pattern.$tmpkey.'" value="'.dol_escape_htmltag($search_array_options[$search_options_pattern.$tmpkey]).'">';
|
||||
}
|
||||
elseif (! in_array($typeofextrafield, array('datetime','timestamp')))
|
||||
{
|
||||
// for the type as 'checkbox', 'chkbxlst', 'sellist' we should use code instead of id (example: I declare a 'chkbxlst' to have a link with dictionnairy, I have to extend it with the 'code' instead 'rowid')
|
||||
$morecss='';
|
||||
if ($typeofextrafield == 'sellist') $morecss='maxwidth200';
|
||||
echo $extrafields->showInputField($key, $search_array_options['search_options_'.$key], '', '', 'search_', $morecss);
|
||||
echo $extrafields->showInputField($key, $search_array_options[$search_options_pattern.$key], '', '', 'search_', $morecss);
|
||||
}
|
||||
elseif (in_array($typeofextrafield, array('datetime','timestamp')))
|
||||
{
|
||||
|
||||
@ -10,10 +10,12 @@ if (empty($conf) || ! is_object($conf))
|
||||
// Loop to complete $param for extrafields
|
||||
if (! empty($search_array_options)) // $extrafieldsobject is the $object->table_element like 'societe', 'socpeople', ...
|
||||
{
|
||||
if (empty($search_options_pattern)) $search_options_pattern='search_options_';
|
||||
|
||||
foreach ($search_array_options as $key => $val)
|
||||
{
|
||||
$crit=$val;
|
||||
$tmpkey=preg_replace('/search_options_/', '', $key);
|
||||
if ($val != '') $param.='&search_options_'.$tmpkey.'='.urlencode($val);
|
||||
$tmpkey=preg_replace('/'.$search_options_pattern.'/', '', $key);
|
||||
if ($val != '') $param.='&'.$search_options_pattern.$tmpkey.'='.urlencode($val);
|
||||
}
|
||||
}
|
||||
|
||||
@ -12,15 +12,18 @@ if (empty($extrafieldsobjectkey) && is_object($object)) $extrafieldsobjectkey=$o
|
||||
// Loop to complete the sql search criterias from extrafields
|
||||
if (! empty($extrafieldsobjectkey) && ! empty($search_array_options) && is_array($search_array_options)) // $extrafieldsobject is the $object->table_element like 'societe', 'socpeople', ...
|
||||
{
|
||||
foreach ($search_array_options as $key => $val)
|
||||
if (empty($extrafieldsobjectprefix)) $extrafieldsobjectprefix = 'ef.';
|
||||
if (empty($search_options_pattern)) $search_options_pattern='search_options_';
|
||||
|
||||
foreach ($search_array_options as $key => $val)
|
||||
{
|
||||
$crit=$val;
|
||||
$tmpkey=preg_replace('/search_options_/', '', $key);
|
||||
$tmpkey=preg_replace('/'.$search_options_pattern.'/', '', $key);
|
||||
$typ=$extrafields->attributes[$extrafieldsobjectkey]['type'][$tmpkey];
|
||||
|
||||
if ($crit != '' && in_array($typ, array('date', 'datetime', 'timestamp')))
|
||||
{
|
||||
$sql .= " AND ef.".$tmpkey." = '".$db->idate($crit)."'";
|
||||
$sql .= " AND ".$extrafieldsobjectprefix.$tmpkey." = '".$db->idate($crit)."'";
|
||||
}
|
||||
elseif ($crit != '' && (! in_array($typ, array('select','sellist')) || $crit != '0') && (! in_array($typ, array('link')) || $crit != '-1'))
|
||||
{
|
||||
@ -29,7 +32,7 @@ if (! empty($extrafieldsobjectkey) && ! empty($search_array_options) && is_array
|
||||
if (in_array($typ, array('sellist','link')) && $crit != '0' && $crit != '-1') $mode_search=2; // Search on a foreign key int
|
||||
if (in_array($typ, array('chkbxlst','checkbox'))) $mode_search=4; // Search on a multiselect field with sql type = text
|
||||
|
||||
$sql .= natural_search('ef.'.$tmpkey, $crit, $mode_search);
|
||||
$sql .= natural_search($extrafieldsobjectprefix.$tmpkey, $crit, $mode_search);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -14,12 +14,14 @@ if (! empty($extrafieldsobjectkey)) // $extrafieldsobject is the $object->table_
|
||||
{
|
||||
if (is_array($extrafields->attributes[$extrafieldsobjectkey]['label']) && count($extrafields->attributes[$extrafieldsobjectkey]['label']))
|
||||
{
|
||||
if (empty($extrafieldsobjectprefix)) $extrafieldsobjectprefix = 'ef.';
|
||||
|
||||
foreach($extrafields->attributes[$extrafieldsobjectkey]['label'] as $key => $val)
|
||||
{
|
||||
if (! empty($arrayfields["ef.".$key]['checked']))
|
||||
if (! empty($arrayfields[$extrafieldsobjectprefix.$key]['checked']))
|
||||
{
|
||||
$align=$extrafields->getAlignFlag($key);
|
||||
$sortonfield = "ef.".$key;
|
||||
$sortonfield = $extrafieldsobjectprefix.$key;
|
||||
if (! empty($extrafields->attributes[$extrafieldsobjectkey]['computed'][$key])) $sortonfield='';
|
||||
if ($extrafields->attributes[$extrafieldsobjectkey]['type'][$key] == 'separate') print '<th class="liste_titre thseparator"></th>';
|
||||
else print getTitleFieldOfList($langs->trans($extralabels[$key]), 0, $_SERVER["PHP_SELF"], $sortonfield, "", $param, ($align?'align="'.$align.'" data-titlekey="'.$key.'"':'data-titlekey="'.$key.'"'), $sortfield, $sortorder)."\n";
|
||||
|
||||
@ -43,6 +43,8 @@ $mode=GETPOST("mode", 'alpha');
|
||||
$id=GETPOST('id', 'int');
|
||||
$taskid=GETPOST('taskid', 'int');
|
||||
|
||||
$contextpage=GETPOST('contextpage', 'aZ')?GETPOST('contextpage', 'aZ'):'perweekcard';
|
||||
|
||||
$mine=0;
|
||||
if ($mode == 'mine') $mine=1;
|
||||
|
||||
@ -113,6 +115,38 @@ 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
|
||||
@ -130,6 +164,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;
|
||||
}
|
||||
@ -145,6 +182,8 @@ if (GETPOST('submitdateselect'))
|
||||
$action = '';
|
||||
}
|
||||
|
||||
include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
|
||||
|
||||
if ($action == 'addtime' && $user->rights->projet->lire && GETPOST('assigntask'))
|
||||
{
|
||||
$action = 'assigntask';
|
||||
@ -302,6 +341,14 @@ if ($action == 'addtime' && $user->rights->projet->lire)
|
||||
$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';
|
||||
|
||||
// Redirect to avoid submit twice on back
|
||||
header('Location: '.$_SERVER["PHP_SELF"].'?'.$param);
|
||||
exit;
|
||||
@ -344,7 +391,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 tasks of open 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, $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.
|
||||
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.
|
||||
@ -368,6 +429,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 ='<a class="inline-block valignmiddle" href="?year='.$prev_year."&month=".$prev_month."&day=".$prev_day.$param.'">'.img_previous($langs->trans("Previous"))."</a>\n";
|
||||
$nav.=" <span id=\"month_name\">".dol_print_date(dol_mktime(0, 0, 0, $first_month, $first_day, $first_year), "%Y").", ".$langs->trans("WeekShort")." ".$week." </span>\n";
|
||||
@ -381,6 +457,8 @@ $picto='calendarweek';
|
||||
print '<form name="addtime" method="POST" action="'.$_SERVER["PHP_SELF"].'">';
|
||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
print '<input type="hidden" name="action" value="addtime">';
|
||||
print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
|
||||
print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
|
||||
print '<input type="hidden" name="mode" value="'.$mode.'">';
|
||||
print '<input type="hidden" name="day" value="'.$day.'">';
|
||||
print '<input type="hidden" name="month" value="'.$month.'">';
|
||||
@ -513,6 +591,23 @@ print '<tr class="liste_titre_filter">';
|
||||
if (! empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) print '<td class="liste_titre"><input type="text" size="4" name="search_project_ref" value="'.dol_escape_htmltag($search_project_ref).'"></td>';
|
||||
if (! empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) print '<td class="liste_titre"><input type="text" size="4" name="search_thirdparty" value="'.dol_escape_htmltag($search_thirdparty).'"></td>';
|
||||
print '<td class="liste_titre"><input type="text" size="4" name="search_task_label" value="'.dol_escape_htmltag($search_task_label).'"></td>';
|
||||
|
||||
$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 '<td class="liste_titre"></td>';
|
||||
print '<td class="liste_titre right"><input type="text" size="4" name="search_declared_progress" value="'.dol_escape_htmltag($search_declared_progress).'"></td>';
|
||||
print '<td class="liste_titre"></td>';
|
||||
@ -532,6 +627,13 @@ print '<tr class="liste_titre">';
|
||||
if (! empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) print '<td>'.$langs->trans("Project").'</td>';
|
||||
if (! empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) print '<td>'.$langs->trans("ThirdParty").'</td>';
|
||||
print '<td>'.$langs->trans("Task").'</td>';
|
||||
|
||||
// TASK fields
|
||||
$extrafieldsobjectkey='projet_task';
|
||||
$extrafieldsobjectprefix='efpt.';
|
||||
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
|
||||
|
||||
|
||||
print '<td class="leftborder plannedworkload maxwidth75 right">'.$langs->trans("PlannedWorkload").'</td>';
|
||||
print '<td class="maxwidth75 right">'.$langs->trans("ProgressDeclared").'</td>';
|
||||
/*print '<td class="maxwidth75 right">'.$langs->trans("TimeSpent").'</td>';
|
||||
@ -560,7 +662,10 @@ for ($idw=0; $idw<7; $idw++)
|
||||
|
||||
print '<td width="6%" align="center" class="bold hide'.$idw.($cssonholiday?' '.$cssonholiday:'').($cssweekend?' '.$cssweekend:'').'">'.dol_print_date($dayinloopfromfirstdaytoshow, '%a').'<br>'.dol_print_date($dayinloopfromfirstdaytoshow, 'dayreduceformat').'</td>';
|
||||
}
|
||||
print '<td></td>';
|
||||
//print '<td></td>';
|
||||
print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ');
|
||||
|
||||
|
||||
print "</tr>\n";
|
||||
|
||||
$colspan=5+(empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)?0:2);
|
||||
@ -568,7 +673,7 @@ $colspan=5+(empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)?0:2)
|
||||
if ($conf->use_javascript_ajax)
|
||||
{
|
||||
print '<tr class="liste_total">';
|
||||
print '<td class="liste_total" colspan="'.$colspan.'">';
|
||||
print '<td class="liste_total" colspan="'.($colspan+$addcolspan).'">';
|
||||
print $langs->trans("Total");
|
||||
print ' - '.$langs->trans("ExpectedWorkedHours").': <strong>'.price($usertoprocess->weeklyhours, 1, $langs, 0, 0).'</strong>';
|
||||
print '</td>';
|
||||
@ -606,7 +711,7 @@ if (count($tasksarray) > 0)
|
||||
|
||||
$j=0;
|
||||
$level=0;
|
||||
$totalforvisibletasks = projectLinesPerWeek($j, $firstdaytoshow, $usertoprocess, 0, $tasksarray, $level, $projectsrole, $tasksrole, $mine, $restrictviewformytask, $isavailable, 0);
|
||||
$totalforvisibletasks = projectLinesPerWeek($j, $firstdaytoshow, $usertoprocess, 0, $tasksarray, $level, $projectsrole, $tasksrole, $mine, $restrictviewformytask, $isavailable, 0, $arrayfields, $extrafields, $extralabels);
|
||||
//var_dump($totalforvisibletasks);
|
||||
|
||||
// Show total for all other tasks
|
||||
@ -656,7 +761,7 @@ if (count($tasksarray) > 0)
|
||||
if ($isdiff)
|
||||
{
|
||||
print '<tr class="oddeven othertaskwithtime">';
|
||||
print '<td colspan="'.$colspan.'" class="opacitymedium">';
|
||||
print '<td colspan="'.($colspan+$addcolspan).'" class="opacitymedium">';
|
||||
print $langs->trans("OtherFilteredTasks");
|
||||
print '</td>';
|
||||
for ($idw = 0; $idw < 7; $idw++)
|
||||
@ -685,7 +790,7 @@ if (count($tasksarray) > 0)
|
||||
if ($conf->use_javascript_ajax)
|
||||
{
|
||||
print '<tr class="liste_total">
|
||||
<td class="liste_total" colspan="'.$colspan.'">';
|
||||
<td class="liste_total" colspan="'.($colspan+$addcolspan).'">';
|
||||
print $langs->trans("Total");
|
||||
print ' - '.$langs->trans("ExpectedWorkedHours").': <strong>'.price($usertoprocess->weeklyhours, 1, $langs, 0, 0).'</strong>';
|
||||
print '</td>';
|
||||
|
||||
@ -729,9 +729,10 @@ class Task extends CommonObject
|
||||
* @param string $morewherefilter Add more filter into where SQL request (must start with ' AND ...')
|
||||
* @param string $filteronprojuser Filter on user that is a contact of project
|
||||
* @param string $filterontaskuser Filter on user assigned to task
|
||||
* @param array $extrafields Show additional column from project or task
|
||||
* @return array Array of tasks
|
||||
*/
|
||||
public function getTasksArray($usert = null, $userp = null, $projectid = 0, $socid = 0, $mode = 0, $filteronproj = '', $filteronprojstatus = '-1', $morewherefilter = '', $filteronprojuser = 0, $filterontaskuser = 0)
|
||||
public function getTasksArray($usert = null, $userp = null, $projectid = 0, $socid = 0, $mode = 0, $filteronproj = '', $filteronprojstatus = '-1', $morewherefilter = '', $filteronprojuser = 0, $filterontaskuser = 0, $extrafields=array())
|
||||
{
|
||||
global $conf;
|
||||
|
||||
@ -746,8 +747,23 @@ class Task extends CommonObject
|
||||
$sql.= " t.rowid as taskid, t.ref as taskref, t.label, t.description, t.fk_task_parent, t.duration_effective, t.progress, t.fk_statut as status,";
|
||||
$sql.= " t.dateo as date_start, t.datee as date_end, t.planned_workload, t.rang,";
|
||||
$sql.= " s.rowid as thirdparty_id, s.nom as thirdparty_name, s.email as thirdparty_email";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."projet as p";
|
||||
|
||||
$sql.= ", p.fk_opp_status, p.opp_amount, p.opp_percent, p.budget_amount, p.bill_time ";
|
||||
|
||||
if (!empty($extrafields->attributes['projet']['label']))
|
||||
{
|
||||
foreach ($extrafields->attributes['projet']['label'] as $key => $val) $sql.=($extrafields->attributes['projet']['type'][$key] != 'separate' ? ",efp.".$key.' as options_'.$key : '');
|
||||
}
|
||||
|
||||
if (!empty($extrafields->attributes['projet_task']['label']))
|
||||
{
|
||||
foreach ($extrafields->attributes['projet_task']['label'] as $key => $val) $sql.=($extrafields->attributes['projet_task']['type'][$key] != 'separate' ? ",efpt.".$key.' as options_'.$key : '');
|
||||
}
|
||||
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."projet as p";
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON p.fk_soc = s.rowid";
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."projet_extrafields as efp ON (p.rowid = efp.fk_object)";
|
||||
|
||||
if ($mode == 0)
|
||||
{
|
||||
if ($filteronprojuser > 0)
|
||||
@ -761,7 +777,8 @@ class Task extends CommonObject
|
||||
$sql.= ", ".MAIN_DB_PREFIX."element_contact as ec2";
|
||||
$sql.= ", ".MAIN_DB_PREFIX."c_type_contact as ctc2";
|
||||
}
|
||||
$sql.= " WHERE p.entity IN (".getEntity('project').")";
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."projet_task_extrafields as efpt ON (t.rowid = efpt.fk_object)";
|
||||
$sql.= " WHERE p.entity IN (".getEntity('project').")";
|
||||
$sql.= " AND t.fk_projet = p.rowid";
|
||||
}
|
||||
elseif ($mode == 1)
|
||||
@ -781,7 +798,8 @@ class Task extends CommonObject
|
||||
{
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."projet_task as t on t.fk_projet = p.rowid";
|
||||
}
|
||||
$sql.= " WHERE p.entity IN (".getEntity('project').")";
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."projet_task_extrafields as efpt ON (t.rowid = efpt.fk_object)";
|
||||
$sql.= " WHERE p.entity IN (".getEntity('project').")";
|
||||
}
|
||||
else return 'BadValueForParameterMode';
|
||||
|
||||
@ -866,6 +884,31 @@ class Task extends CommonObject
|
||||
$tasks[$i]->thirdparty_id = $obj->thirdparty_id;
|
||||
$tasks[$i]->thirdparty_name = $obj->thirdparty_name;
|
||||
$tasks[$i]->thirdparty_email= $obj->thirdparty_email;
|
||||
|
||||
|
||||
$tasks[$i]->fk_opp_status = $obj->fk_opp_status;
|
||||
$tasks[$i]->opp_amount = $obj->opp_amount;
|
||||
$tasks[$i]->opp_percent = $obj->opp_percent;
|
||||
$tasks[$i]->budget_amount = $obj->budget_amount;
|
||||
$tasks[$i]->bill_time = $obj->bill_time;
|
||||
|
||||
if (!empty($extrafields->attributes['projet']['label']))
|
||||
{
|
||||
foreach ($extrafields->attributes['projet']['label'] as $key => $val)
|
||||
{
|
||||
if ($extrafields->attributes['projet']['type'][$key] != 'separate')
|
||||
$tasks[$i]->{'options_'.$key} = $obj->{'options_'.$key};
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($extrafields->attributes['projet_task']['label']))
|
||||
{
|
||||
foreach ($extrafields->attributes['projet_task']['label'] as $key => $val)
|
||||
{
|
||||
if ($extrafields->attributes['projet_task']['type'][$key] != 'separate')
|
||||
$tasks[$i]->{'options_'.$key} = $obj->{'options_'.$key};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$i++;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user