--- /tmp/dsg/dolibarr/htdocs/projet/tasks/github_19.0.3_comment.php +++ /tmp/dsg/dolibarr/htdocs/projet/tasks/client_comment.php @@ -21 +21 @@ - * \file htdocs/projet/tasks/comment.php + * \file htdocs/projet/tasks/task.php @@ -23 +23 @@ - * \brief Page of a project task comment + * \brief Page of a project task @@ -44 +44 @@ -$action = GETPOST('action', 'aZ09'); +$action = GETPOST('action', 'alpha'); @@ -48 +48,6 @@ -$planned_workload = ((GETPOST('planned_workloadhour', 'int') != '' || GETPOST('planned_workloadmin', 'int') != '') ? (GETPOST('planned_workloadhour', 'int') > 0 ? GETPOST('planned_workloadhour', 'int') * 3600 : 0) + (GETPOST('planned_workloadmin', 'int') > 0 ? GETPOST('planned_workloadmin', 'int') * 60 : 0) : ''); +$planned_workload = ((GETPOST('planned_workloadhour', 'int') != '' || GETPOST('planned_workloadmin', 'int') != '') ? (GETPOST('planned_workloadhour', 'int') > 0 ?GETPOST('planned_workloadhour', 'int') * 3600 : 0) + (GETPOST('planned_workloadmin', 'int') > 0 ?GETPOST('planned_workloadmin', 'int') * 60 : 0) : ''); + +// Security check +$socid = 0; +//if ($user->socid > 0) $socid = $user->socid; // For external user, no check is done on company because readability is managed by public status of project and assignement. +if (!$user->rights->projet->lire) accessforbidden(); @@ -63,3 +68,5 @@ -// Retrieve First Task ID of Project if withprojet is on to allow project prev next to work -if (!empty($project_ref) && !empty($withproject)) { - if ($projectstatic->fetch('', $project_ref) > 0) { +// Retreive First Task ID of Project if withprojet is on to allow project prev next to work +if (!empty($project_ref) && !empty($withproject)) +{ + if ($projectstatic->fetch('', $project_ref) > 0) + { @@ -67 +74,2 @@ - if (count($objectsarray) > 0) { + if (count($objectsarray) > 0) + { @@ -69 +77,3 @@ - } else { + } + else + { @@ -75,12 +84,0 @@ - -if ($id > 0 || $ref) { - $object->fetch($id, $ref); -} - -// Security check -$socid = 0; - -restrictedArea($user, 'projet', $object->fk_project, 'projet&project'); - - - @@ -89 +87,2 @@ - */ +*/ + @@ -97,2 +96,4 @@ -if ($id > 0 || !empty($ref)) { - if ($object->fetch($id, $ref) > 0) { +if ($id > 0 || !empty($ref)) +{ + if ($object->fetch($id, $ref) > 0) + { @@ -107,6 +108,2 @@ - if (!empty($projectstatic->socid)) { - $projectstatic->fetch_thirdparty(); - } - if (getDolGlobalString('PROJECT_ALLOW_COMMENT_ON_PROJECT') && method_exists($projectstatic, 'fetchComments') && empty($projectstatic->comments)) { - $projectstatic->fetchComments(); - } + if (!empty($projectstatic->socid)) $projectstatic->fetch_thirdparty(); + if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($projectstatic, 'fetchComments') && empty($projectstatic->comments)) $projectstatic->fetchComments(); @@ -118 +115,2 @@ - if (!empty($withproject)) { + if (!empty($withproject)) + { @@ -122 +120 @@ - print dol_get_fiche_head($head, $tab, $langs->trans("Project"), -1, ($projectstatic->public ? 'projectpub' : 'project')); + dol_fiche_head($head, $tab, $langs->trans("Project"), -1, ($projectstatic->public ? 'projectpub' : 'project')); @@ -128,147 +126,134 @@ - $linkback = ''.$langs->trans("BackToList").''; - - $morehtmlref = '
'; - // Title - $morehtmlref .= $projectstatic->title; - // Thirdparty - if ($projectstatic->thirdparty->id > 0) { - $morehtmlref .= '
'.$projectstatic->thirdparty->getNomUrl(1, 'project'); - } - $morehtmlref .= '
'; - - // Define a complementary filter for search of next/prev ref. - if (!$user->hasRight('projet', 'all', 'lire')) { - $objectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 0); - $projectstatic->next_prev_filter = "rowid IN (".$db->sanitize(count($objectsListId) ? join(',', array_keys($objectsListId)) : '0').")"; - } - - dol_banner_tab($projectstatic, 'project_ref', $linkback, 1, 'ref', 'ref', $morehtmlref); - - print '
'; - print '
'; - print '
'; - - print ''; - - // Usage - if (getDolGlobalString('PROJECT_USE_OPPORTUNITIES') || !getDolGlobalString('PROJECT_HIDE_TASKS') || isModEnabled('eventorganization')) { - print ''; - print ''; - } - - // Visibility - print ''; - - // Opportunities - if (getDolGlobalString('PROJECT_USE_OPPORTUNITIES') && !empty($object->usage_opportunity)) { - // Opportunity status - print ''; - - // Opportunity percent - print ''; - - // Opportunity Amount - print ''; - } - - // Budget - print ''; - - // Date start - end project - print ''; - - // Other attributes - $cols = 2; - //include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; - - print '
'; - print $langs->trans("Usage"); - print ''; - if (getDolGlobalString('PROJECT_USE_OPPORTUNITIES')) { - print 'usage_opportunity ? ' checked="checked"' : '')).'"> '; - $htmltext = $langs->trans("ProjectFollowOpportunity"); - print $form->textwithpicto($langs->trans("ProjectFollowOpportunity"), $htmltext); - print '
'; - } - if (!getDolGlobalString('PROJECT_HIDE_TASKS')) { - print 'usage_task ? ' checked="checked"' : '')).'"> '; - $htmltext = $langs->trans("ProjectFollowTasks"); - print $form->textwithpicto($langs->trans("ProjectFollowTasks"), $htmltext); - print '
'; - } - if (!getDolGlobalString('PROJECT_HIDE_TASKS') && getDolGlobalString('PROJECT_BILL_TIME_SPENT')) { - print 'usage_bill_time ? ' checked="checked"' : '')).'"> '; - $htmltext = $langs->trans("ProjectBillTimeDescription"); - print $form->textwithpicto($langs->trans("BillTime"), $htmltext); - print '
'; - } - if (isModEnabled('eventorganization')) { - print 'usage_organize_event ? ' checked="checked"' : '')).'"> '; - $htmltext = $langs->trans("EventOrganizationDescriptionLong"); - print $form->textwithpicto($langs->trans("ManageOrganizeEvent"), $htmltext); - } - print '
'.$langs->trans("Visibility").''; - if ($projectstatic->public) { - print img_picto($langs->trans('SharedProject'), 'world', 'class="paddingrightonly"'); - print $langs->trans('SharedProject'); - } else { - print img_picto($langs->trans('PrivateProject'), 'private', 'class="paddingrightonly"'); - print $langs->trans('PrivateProject'); - } - print '
'.$langs->trans("OpportunityStatus").''; - $code = dol_getIdFromCode($db, $projectstatic->opp_status, 'c_lead_status', 'rowid', 'code'); - if ($code) { - print $langs->trans("OppStatus".$code); - } - print '
'.$langs->trans("OpportunityProbability").''; - if (strcmp($projectstatic->opp_percent, '')) { - print price($projectstatic->opp_percent, 0, $langs, 1, 0).' %'; - } - print '
'.$langs->trans("OpportunityAmount").''; - if (strcmp($projectstatic->opp_amount, '')) { - print price($projectstatic->opp_amount, 0, $langs, 1, 0, -1, $conf->currency); - if (strcmp($projectstatic->opp_percent, '')) { - print '       '.$langs->trans("Weighted").': '.price($projectstatic->opp_amount * $projectstatic->opp_percent / 100, 0, $langs, 1, 0, -1, $conf->currency).''; - } - } - print '
'.$langs->trans("Budget").''; - if (strcmp($projectstatic->budget_amount, '')) { - print price($projectstatic->budget_amount, '', $langs, 1, 0, 0, $conf->currency); - } - print '
'.$langs->trans("Dates").''; - $start = dol_print_date($projectstatic->date_start, 'day'); - print($start ? $start : '?'); - $end = dol_print_date($projectstatic->date_end, 'day'); - print ' - '; - print($end ? $end : '?'); - if ($projectstatic->hasDelay()) { - print img_warning("Late"); - } - print '
'; - - print '
'; - print '
'; - print '
'; - - print ''; - - // Description - print ''; - - // Categories - if (isModEnabled('categorie')) { - print '"; - } - - print '
'.$langs->trans("Description").''; - print nl2br($projectstatic->description); - print '
'.$langs->trans("Categories").''; - print $form->showCategories($projectstatic->id, 'project', 1); - print "
'; - - print '
'; - print '
'; - - print '
'; - - print dol_get_fiche_end(); + $linkback = ''.$langs->trans("BackToList").''; + + $morehtmlref = '
'; + // Title + $morehtmlref .= $projectstatic->title; + // Thirdparty + if ($projectstatic->thirdparty->id > 0) + { + $morehtmlref .= '
'.$langs->trans('ThirdParty').' : '.$projectstatic->thirdparty->getNomUrl(1, 'project'); + } + $morehtmlref .= '
'; + + // Define a complementary filter for search of next/prev ref. + if (!$user->rights->projet->all->lire) + { + $objectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 0); + $projectstatic->next_prev_filter = " rowid in (".(count($objectsListId) ?join(',', array_keys($objectsListId)) : '0').")"; + } + + dol_banner_tab($projectstatic, 'project_ref', $linkback, 1, 'ref', 'ref', $morehtmlref); + + print '
'; + print '
'; + print '
'; + + print ''; + + // Usage + print ''; + print ''; + + // Visibility + print ''; + + // Usage + if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES) && !empty($object->usage_opportunity)) + { + // Opportunity status + print ''; + + // Opportunity percent + print ''; + + // Opportunity Amount + print ''; + } + + // Date start - end + print ''; + + // Budget + print ''; + + // Other attributes + $cols = 2; + //include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; + + print '
'; + print $langs->trans("Usage"); + print ''; + if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) + { + print 'usage_opportunity ? ' checked="checked"' : '')).'"> '; + $htmltext = $langs->trans("ProjectFollowOpportunity"); + print $form->textwithpicto($langs->trans("ProjectFollowOpportunity"), $htmltext); + print '
'; + } + if (empty($conf->global->PROJECT_HIDE_TASKS)) + { + print 'usage_task ? ' checked="checked"' : '')).'"> '; + $htmltext = $langs->trans("ProjectFollowTasks"); + print $form->textwithpicto($langs->trans("ProjectFollowTasks"), $htmltext); + print '
'; + } + if (!empty($conf->global->PROJECT_BILL_TIME_SPENT)) + { + print 'usage_bill_time ? ' checked="checked"' : '')).'"> '; + $htmltext = $langs->trans("ProjectBillTimeDescription"); + print $form->textwithpicto($langs->trans("BillTime"), $htmltext); + print '
'; + } + print '
'.$langs->trans("Visibility").''; + if ($projectstatic->public) print $langs->trans('SharedProject'); + else print $langs->trans('PrivateProject'); + print '
'.$langs->trans("OpportunityStatus").''; + $code = dol_getIdFromCode($db, $projectstatic->opp_status, 'c_lead_status', 'rowid', 'code'); + if ($code) print $langs->trans("OppStatus".$code); + print '
'.$langs->trans("OpportunityProbability").''; + if (strcmp($object->opp_percent, '')) print price($projectstatic->opp_percent, 0, $langs, 1, 0).' %'; + print '
'.$langs->trans("OpportunityAmount").''; + /*if ($object->opp_status) + { + print price($obj->opp_amount, 1, $langs, 1, 0, -1, $conf->currency); + }*/ + if (strcmp($projectstatic->opp_amount, '')) print price($projectstatic->opp_amount, 0, $langs, 1, 0, -1, $conf->currency); + print '
'.$langs->trans("DateStart").' - '.$langs->trans("DateEnd").''; + $start = dol_print_date($projectstatic->date_start, 'day'); + print ($start ? $start : '?'); + $end = dol_print_date($projectstatic->date_end, 'day'); + print ' - '; + print ($end ? $end : '?'); + if ($projectstatic->hasDelay()) print img_warning("Late"); + print '
'.$langs->trans("Budget").''; + if (strcmp($projectstatic->budget_amount, '')) print price($projectstatic->budget_amount, '', $langs, 1, 0, 0, $conf->currency); + print '
'; + + print '
'; + print '
'; + print '
'; + print '
'; + + print ''; + + // Description + print ''; + + // Categories + if ($conf->categorie->enabled) { + print '"; + } + + print '
'.$langs->trans("Description").''; + print nl2br($projectstatic->description); + print '
'.$langs->trans("Categories").''; + print $form->showCategories($projectstatic->id, 'project', 1); + print "
'; + + print '
'; + print '
'; + print '
'; + + print '
'; + + dol_fiche_end(); @@ -287,12 +272,13 @@ - print dol_get_fiche_head($head, 'task_comment', $langs->trans("Task"), -1, 'projecttask'); - - if ($action == 'delete') { - print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".GETPOST("id", "int").'&withproject='.$withproject, $langs->trans("DeleteATask"), $langs->trans("ConfirmDeleteATask"), "confirm_delete"); - } - - if (!GETPOST('withproject') || empty($projectstatic->id)) { - $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1); - $object->next_prev_filter = "fk_projet IN (".$db->sanitize($projectsListId).")"; - } else { - $object->next_prev_filter = "fk_projet = ".((int) $projectstatic->id); - } + dol_fiche_head($head, 'task_comment', $langs->trans("Task"), -1, 'projecttask'); + + if ($action == 'delete') + { + print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$_GET["id"].'&withproject='.$withproject, $langs->trans("DeleteATask"), $langs->trans("ConfirmDeleteATask"), "confirm_delete"); + } + + if (!GETPOST('withproject') || empty($projectstatic->id)) + { + $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1); + $object->next_prev_filter = " fk_projet in (".$projectsListId.")"; + } + else $object->next_prev_filter = " fk_projet = ".$projectstatic->id; @@ -303,12 +289,13 @@ - if (empty($withproject)) { - $morehtmlref .= '
'; - $morehtmlref .= $langs->trans("Project").': '; - $morehtmlref .= $projectstatic->getNomUrl(1); - $morehtmlref .= '
'; - - // Third party - $morehtmlref .= $langs->trans("ThirdParty").': '; - if (!empty($projectstatic->thirdparty)) { - $morehtmlref .= $projectstatic->thirdparty->getNomUrl(1); - } - $morehtmlref .= '
'; + if (empty($withproject)) + { + $morehtmlref .= '
'; + $morehtmlref .= $langs->trans("Project").': '; + $morehtmlref .= $projectstatic->getNomUrl(1); + $morehtmlref .= '
'; + + // Third party + $morehtmlref .= $langs->trans("ThirdParty").': '; + if (!empty($projectstatic->thirdparty)) { + $morehtmlref .= $projectstatic->thirdparty->getNomUrl(1); + } + $morehtmlref .= '
'; @@ -338 +325 @@ - print dol_get_fiche_end(); + dol_fiche_end(); --- /tmp/dsg/dolibarr/htdocs/projet/tasks/github_19.0.3_contact.php +++ /tmp/dsg/dolibarr/htdocs/projet/tasks/client_contact.php @@ -38 +38 @@ -$action = GETPOST('action', 'aZ09'); +$action = GETPOST('action', 'alpha'); @@ -42,0 +43,6 @@ +// Security check +$socid = 0; +//if ($user->socid > 0) $socid = $user->socid; // For external user, no check is done on company because readability is managed by public status of project and assignement. +//$result = restrictedArea($user, 'projet', $id, 'projet_task'); +if (!$user->rights->projet->lire) accessforbidden(); + @@ -45,9 +50,0 @@ - -if ($id > 0 || $ref) { - $object->fetch($id, $ref); -} - -// Security check -$socid = 0; - -restrictedArea($user, 'projet', $object->fk_project, 'projet&project'); @@ -61,6 +58,2 @@ -if ($action == 'addcontact' && $user->hasRight('projet', 'creer')) { - $source = 'internal'; - if (GETPOST("addsourceexternal")) { - $source = 'external'; - } - +if ($action == 'addcontact' && $user->rights->projet->creer) +{ @@ -69,24 +62,27 @@ - if ($result > 0 && $id > 0) { - if ($source == 'internal') { - $idfortaskuser = ((GETPOST("userid") != 0 && GETPOST('userid') != -1) ? GETPOST("userid") : 0); // GETPOST('contactid') may val -1 to mean empty or -2 to means "everybody" - $typeid = GETPOST('type'); - } else { - $idfortaskuser = ((GETPOST("contactid") > 0) ? GETPOST("contactid", 'int') : 0); // GETPOST('contactid') may val -1 to mean empty or -2 to means "everybody" - $typeid = GETPOST('typecontact'); - } - if ($idfortaskuser == -2) { - $result = $projectstatic->fetch($object->fk_project); - if ($result <= 0) { - dol_print_error($db, $projectstatic->error, $projectstatic->errors); - } else { - $contactsofproject = $projectstatic->getListContactId('internal'); - foreach ($contactsofproject as $key => $val) { - $result = $object->add_contact($val, $typeid, $source); - } - } - } else { - $result = $object->add_contact($idfortaskuser, $typeid, $source); - } - } - - if ($result >= 0) { + if ($result > 0 && $id > 0) + { + $idfortaskuser = (GETPOST("contactid") != 0) ?GETPOST("contactid") : GETPOST("userid"); // GETPOST('contactid') may val -1 to mean empty or -2 to means "everybody" + if ($idfortaskuser == -2) + { + $result = $projectstatic->fetch($object->fk_project); + if ($result <= 0) + { + dol_print_error($db, $projectstatic->error, $projectstatic->errors); + } + else + { + $contactsofproject = $projectstatic->getListContactId('internal'); + foreach ($contactsofproject as $key => $val) + { + $result = $object->add_contact($val, GETPOST("type"), GETPOST("source")); + } + } + } + else + { + $result = $object->add_contact($idfortaskuser, GETPOST("type"), GETPOST("source")); + } + } + + if ($result >= 0) + { @@ -95,2 +91,5 @@ - } else { - if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') { + } + else + { + if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') + { @@ -99 +98,3 @@ - } else { + } + else + { @@ -106,4 +107,8 @@ -if ($action == 'swapstatut' && $user->hasRight('projet', 'creer')) { - if ($object->fetch($id, $ref)) { - $result = $object->swapContactStatus(GETPOST('ligne', 'int')); - } else { +if ($action == 'swapstatut' && $user->rights->projet->creer) +{ + if ($object->fetch($id, $ref)) + { + $result = $object->swapContactStatus(GETPOST('ligne')); + } + else + { @@ -115 +120,2 @@ -if ($action == 'deleteline' && $user->hasRight('projet', 'creer')) { +if ($action == 'deleteline' && $user->rights->projet->creer) +{ @@ -117,3 +123,4 @@ - $result = $object->delete_contact(GETPOST("lineid", 'int')); - - if ($result >= 0) { + $result = $object->delete_contact($_GET["lineid"]); + + if ($result >= 0) + { @@ -122 +129,3 @@ - } else { + } + else + { @@ -127,3 +136,5 @@ -// Retrieve First Task ID of Project if withprojet is on to allow project prev next to work -if (!empty($project_ref) && !empty($withproject)) { - if ($projectstatic->fetch(0, $project_ref) > 0) { +// Retreive First Task ID of Project if withprojet is on to allow project prev next to work +if (!empty($project_ref) && !empty($withproject)) +{ + if ($projectstatic->fetch(0, $project_ref) > 0) + { @@ -131 +142,2 @@ - if (count($tasksarray) > 0) { + if (count($tasksarray) > 0) + { @@ -133 +145,3 @@ - } else { + } + else + { @@ -142,0 +157,3 @@ + +llxHeader('', $langs->trans("Task")); + @@ -147,9 +163,0 @@ -$result = $projectstatic->fetch($object->fk_project); - -$title = $object->ref . ' - ' . $langs->trans("Contacts"); -if (!empty($withproject)) { - $title .= ' | ' . $langs->trans("Project") . (!empty($projectstatic->ref) ? ': '.$projectstatic->ref : '') ; -} -$help_url = ''; - -llxHeader('', $title, $help_url); @@ -164,13 +172,10 @@ -if ($id > 0 || !empty($ref)) { - if ($object->fetch($id, $ref) > 0) { - if (getDolGlobalString('PROJECT_ALLOW_COMMENT_ON_TASK') && method_exists($object, 'fetchComments') && empty($object->comments)) { - $object->fetchComments(); - } - $id = $object->id; // So when doing a search from ref, id is also set correctly. - - if (getDolGlobalString('PROJECT_ALLOW_COMMENT_ON_PROJECT') && method_exists($projectstatic, 'fetchComments') && empty($projectstatic->comments)) { - $projectstatic->fetchComments(); - } - if (!empty($projectstatic->socid)) { - $projectstatic->fetch_thirdparty(); - } +if ($id > 0 || !empty($ref)) +{ + if ($object->fetch($id, $ref) > 0) + { + if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_TASK) && method_exists($object, 'fetchComments') && empty($object->comments)) $object->fetchComments(); + $id = $object->id; // So when doing a search from ref, id is also set correctly. + + $result = $projectstatic->fetch($object->fk_project); + if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($projectstatic, 'fetchComments') && empty($projectstatic->comments)) $projectstatic->fetchComments(); + if (!empty($projectstatic->socid)) $projectstatic->fetch_thirdparty(); @@ -182,7 +187,8 @@ - if ($withproject) { - // Tabs for project - $tab = 'tasks'; - $head = project_prepare_head($projectstatic); - print dol_get_fiche_head($head, $tab, $langs->trans("Project"), -1, ($projectstatic->public ? 'projectpub' : 'project')); - - $param = (!empty($mode) && $mode == 'mine' ? '&mode=mine' : ''); + if ($withproject) + { + // Tabs for project + $tab = 'tasks'; + $head = project_prepare_head($projectstatic); + dol_fiche_head($head, $tab, $langs->trans("Project"), -1, ($projectstatic->public ? 'projectpub' : 'project')); + + $param = ($mode == 'mine' ? '&mode=mine' : ''); @@ -192,121 +198,112 @@ - $linkback = ''.$langs->trans("BackToList").''; - - $morehtmlref = '
'; - // Title - $morehtmlref .= $projectstatic->title; - // Thirdparty - if (isset($projectstatic->thirdparty->id) && $projectstatic->thirdparty->id > 0) { - $morehtmlref .= '
'.$projectstatic->thirdparty->getNomUrl(1, 'project'); - } - $morehtmlref .= '
'; - - // Define a complementary filter for search of next/prev ref. - if (!$user->hasRight('projet', 'all', 'lire')) { - $objectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 0); - $projectstatic->next_prev_filter = "rowid IN (".$db->sanitize(count($objectsListId) ? join(',', array_keys($objectsListId)) : '0').")"; - } - - dol_banner_tab($projectstatic, 'project_ref', $linkback, 1, 'ref', 'ref', $morehtmlref); - - print '
'; - print '
'; - print '
'; - - print ''; - - // Usage - if (getDolGlobalString('PROJECT_USE_OPPORTUNITIES') || !getDolGlobalString('PROJECT_HIDE_TASKS') || isModEnabled('eventorganization')) { - print ''; - print ''; - } - - // Visibility - print ''; - - // Budget - print ''; - - // Date start - end project - print ''; - - // Other attributes - $cols = 2; - //include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; - - print '
'; - print $langs->trans("Usage"); - print ''; - if (getDolGlobalString('PROJECT_USE_OPPORTUNITIES')) { - print 'usage_opportunity ? ' checked="checked"' : '')).'"> '; - $htmltext = $langs->trans("ProjectFollowOpportunity"); - print $form->textwithpicto($langs->trans("ProjectFollowOpportunity"), $htmltext); - print '
'; - } - if (!getDolGlobalString('PROJECT_HIDE_TASKS')) { - print 'usage_task ? ' checked="checked"' : '')).'"> '; - $htmltext = $langs->trans("ProjectFollowTasks"); - print $form->textwithpicto($langs->trans("ProjectFollowTasks"), $htmltext); - print '
'; - } - if (!getDolGlobalString('PROJECT_HIDE_TASKS') && getDolGlobalString('PROJECT_BILL_TIME_SPENT')) { - print 'usage_bill_time ? ' checked="checked"' : '')).'"> '; - $htmltext = $langs->trans("ProjectBillTimeDescription"); - print $form->textwithpicto($langs->trans("BillTime"), $htmltext); - print '
'; - } - if (isModEnabled('eventorganization')) { - print 'usage_organize_event ? ' checked="checked"' : '')).'"> '; - $htmltext = $langs->trans("EventOrganizationDescriptionLong"); - print $form->textwithpicto($langs->trans("ManageOrganizeEvent"), $htmltext); - } - print '
'.$langs->trans("Visibility").''; - if ($projectstatic->public) { - print img_picto($langs->trans('SharedProject'), 'world', 'class="paddingrightonly"'); - print $langs->trans('SharedProject'); - } else { - print img_picto($langs->trans('PrivateProject'), 'private', 'class="paddingrightonly"'); - print $langs->trans('PrivateProject'); - } - print '
'.$langs->trans("Budget").''; - if (strcmp($projectstatic->budget_amount, '')) { - print price($projectstatic->budget_amount, '', $langs, 1, 0, 0, $conf->currency); - } - print '
'.$langs->trans("Dates").''; - $start = dol_print_date($projectstatic->date_start, 'day'); - print($start ? $start : '?'); - $end = dol_print_date($projectstatic->date_end, 'day'); - print ' - '; - print($end ? $end : '?'); - if ($projectstatic->hasDelay()) { - print img_warning("Late"); - } - print '
'; - - print '
'; - print '
'; - print '
'; - - print ''; - - // Description - print ''; - - // Categories - if (isModEnabled('categorie')) { - print '"; - } - - print '
'.$langs->trans("Description").''; - print nl2br($projectstatic->description); - print '
'.$langs->trans("Categories").''; - print $form->showCategories($projectstatic->id, 'project', 1); - print "
'; - - print '
'; - print '
'; - - print '
'; - - print dol_get_fiche_end(); - - print '
'; + $linkback = ''.$langs->trans("BackToList").''; + + $morehtmlref = '
'; + // Title + $morehtmlref .= $projectstatic->title; + // Thirdparty + if ($projectstatic->thirdparty->id > 0) + { + $morehtmlref .= '
'.$langs->trans('ThirdParty').' : '.$projectstatic->thirdparty->getNomUrl(1, 'project'); + } + $morehtmlref .= '
'; + + // Define a complementary filter for search of next/prev ref. + if (!$user->rights->projet->all->lire) + { + $objectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 0); + $projectstatic->next_prev_filter = " rowid in (".(count($objectsListId) ?join(',', array_keys($objectsListId)) : '0').")"; + } + + dol_banner_tab($projectstatic, 'project_ref', $linkback, 1, 'ref', 'ref', $morehtmlref); + + print '
'; + print '
'; + print '
'; + + print ''; + + // Usage + print ''; + print ''; + + // Visibility + print ''; + + // Date start - end + print ''; + + // Budget + print ''; + + // Other attributes + $cols = 2; + //include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; + + print '
'; + print $langs->trans("Usage"); + print ''; + if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) + { + print 'usage_opportunity ? ' checked="checked"' : '')).'"> '; + $htmltext = $langs->trans("ProjectFollowOpportunity"); + print $form->textwithpicto($langs->trans("ProjectFollowOpportunity"), $htmltext); + print '
'; + } + if (empty($conf->global->PROJECT_HIDE_TASKS)) + { + print 'usage_task ? ' checked="checked"' : '')).'"> '; + $htmltext = $langs->trans("ProjectFollowTasks"); + print $form->textwithpicto($langs->trans("ProjectFollowTasks"), $htmltext); + print '
'; + } + if (!empty($conf->global->PROJECT_BILL_TIME_SPENT)) + { + print 'usage_bill_time ? ' checked="checked"' : '')).'"> '; + $htmltext = $langs->trans("ProjectBillTimeDescription"); + print $form->textwithpicto($langs->trans("BillTime"), $htmltext); + print '
'; + } + print '
'.$langs->trans("Visibility").''; + if ($projectstatic->public) print $langs->trans('SharedProject'); + else print $langs->trans('PrivateProject'); + print '
'.$langs->trans("DateStart").' - '.$langs->trans("DateEnd").''; + $start = dol_print_date($projectstatic->date_start, 'day'); + print ($start ? $start : '?'); + $end = dol_print_date($projectstatic->date_end, 'day'); + print ' - '; + print ($end ? $end : '?'); + if ($projectstatic->hasDelay()) print img_warning("Late"); + print '
'.$langs->trans("Budget").''; + if (strcmp($projectstatic->budget_amount, '')) print price($projectstatic->budget_amount, '', $langs, 1, 0, 0, $conf->currency); + print '
'; + + print '
'; + print '
'; + print '
'; + print '
'; + + print ''; + + // Description + print ''; + + // Categories + if ($conf->categorie->enabled) { + print '"; + } + + print '
'.$langs->trans("Description").''; + print nl2br($projectstatic->description); + print '
'.$langs->trans("Categories").''; + print $form->showCategories($projectstatic->id, 'project', 1); + print "
'; + + print '
'; + print '
'; + print '
'; + + print '
'; + + dol_fiche_end(); + + print '
'; @@ -321 +318 @@ - print dol_get_fiche_head($head, 'task_contact', $langs->trans("Task"), -1, 'projecttask', 0, '', 'reposition'); + dol_fiche_head($head, 'task_contact', $langs->trans("Task"), -1, 'projecttask', 0, '', 'reposition'); @@ -327,6 +324,6 @@ - if (!GETPOST('withproject') || empty($projectstatic->id)) { - $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1); - $object->next_prev_filter = "fk_projet IN (".$db->sanitize($projectsListId).")"; - } else { - $object->next_prev_filter = "fk_projet = ".((int) $projectstatic->id); - } + if (!GETPOST('withproject') || empty($projectstatic->id)) + { + $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1); + $object->next_prev_filter = " fk_projet in (".$projectsListId.")"; + } + else $object->next_prev_filter = " fk_projet = ".$projectstatic->id; @@ -337,15 +334,16 @@ - if (empty($withproject)) { - $result = $projectstatic->fetch($object->fk_project); - $morehtmlref .= '
'; - $morehtmlref .= $langs->trans("Project").': '; - $morehtmlref .= $projectstatic->getNomUrl(1); - $morehtmlref .= '
'; - - // Third party - $morehtmlref .= $langs->trans("ThirdParty").': '; - if ($projectstatic->socid > 0) { - $projectstatic->fetch_thirdparty(); - $morehtmlref .= $projectstatic->thirdparty->getNomUrl(1); - } - - $morehtmlref .= '
'; + if (empty($withproject)) + { + $result = $projectstatic->fetch($object->fk_project); + $morehtmlref .= '
'; + $morehtmlref .= $langs->trans("Project").': '; + $morehtmlref .= $projectstatic->getNomUrl(1); + $morehtmlref .= '
'; + + // Third party + $morehtmlref .= $langs->trans("ThirdParty").': '; + if ($projectstatic->socid > 0) { + $projectstatic->fetch_thirdparty(); + $morehtmlref .= $projectstatic->thirdparty->getNomUrl(1); + } + + $morehtmlref .= '
'; @@ -356 +354 @@ - print dol_get_fiche_end(); + dol_fiche_end(); @@ -366,2 +364,2 @@ - $res=@include dol_buildpath($reldir.'/contacts.tpl.php'); - if ($res) break; + $res=@include dol_buildpath($reldir.'/contacts.tpl.php'); + if ($res) break; @@ -374,8 +371,0 @@ - print '
'; - print ''; - print ''; - print ''; - if ($withproject) { - print ''; - } - @@ -384 +374,2 @@ - if ($action != 'editline' && $user->hasRight('projet', 'creer')) { + if ($action != 'editline' && $user->rights->projet->creer) + { @@ -392,0 +384,7 @@ + print ''; + print ''; + print ''; + print ''; + print ''; + if ($withproject) print ''; + @@ -406,6 +404,3 @@ - if ($object->project->public) { - $contactsofproject = ''; // Everybody - } else { - $contactsofproject = $projectstatic->getListContactId('internal'); - } - print $form->select_dolusers((GETPOSTISSET('userid') ? GETPOST('userid', 'int') : $user->id), 'userid', 0, '', 0, '', $contactsofproject, 0, 0, 0, '', 1, $langs->trans("ResourceNotAssignedToProject")); + if ($object->project->public) $contactsofproject = ''; // Everybody + else $contactsofproject = $projectstatic->getListContactId('internal'); + print $form->select_dolusers((GETPOST('contactid') ?GETPOST('contactid') : $user->id), 'contactid', 0, '', 0, '', $contactsofproject, 0, 0, 0, '', 1, $langs->trans("ResourceNotAssignedToProject")); @@ -414 +409 @@ - $formcompany->selectTypeContact($object, '', 'type', 'internal', 'position'); + $formcompany->selectTypeContact($object, '', 'type', 'internal', 'rowid'); @@ -416 +411 @@ - print ''; + print ''; @@ -418,0 +414,2 @@ + print '
'; + @@ -420 +417,10 @@ - if ($projectstatic->socid) { + if ($projectstatic->socid) + { + print '
'; + print ''; + print ''; + print ''; + print ''; + if ($withproject) print ''; + + @@ -435,2 +441 @@ - print $form->selectcontacts($selectedCompany, '', 'contactid', 0, '', $contactofproject, 0, '', false, 0, 0); - $nbofcontacts = $form->num; + $nbofcontacts = $form->select_contacts($selectedCompany, '', 'contactid', 0, '', $contactofproject); @@ -439,6 +444,4 @@ - $formcompany->selectTypeContact($object, '', 'typecontact', 'external', 'position'); - print ''; - print 'selectTypeContact($object, '', 'type', 'external', 'rowid'); + print ''; + print '"; @@ -450 +455 @@ - // List of contact line + // Liste des contacts lies @@ -462 +467,2 @@ - foreach (array('internal', 'external') as $source) { + foreach (array('internal', 'external') as $source) + { @@ -464 +469,0 @@ - @@ -468 +473,2 @@ - while ($i < $num) { + while ($i < $num) + { @@ -473,6 +479,2 @@ - if ($tab[$i]['source'] == 'internal') { - print $langs->trans("User"); - } - if ($tab[$i]['source'] == 'external') { - print $langs->trans("ThirdPartyContact"); - } + if ($tab[$i]['source'] == 'internal') print $langs->trans("User"); + if ($tab[$i]['source'] == 'external') print $langs->trans("ThirdPartyContact"); @@ -483 +485,2 @@ - if ($tab[$i]['socid'] > 0) { + if ($tab[$i]['socid'] > 0) + { @@ -487 +490,2 @@ - if ($tab[$i]['socid'] < 0) { + if ($tab[$i]['socid'] < 0) + { @@ -490 +494,2 @@ - if (!$tab[$i]['socid']) { + if (!$tab[$i]['socid']) + { @@ -497,19 +502,16 @@ - if ($tab[$i]['source'] == 'internal') { - $userstatic->id = $tab[$i]['id']; - $userstatic->lastname = $tab[$i]['lastname']; - $userstatic->firstname = $tab[$i]['firstname']; - $userstatic->photo = $tab[$i]['photo']; - $userstatic->login = $tab[$i]['login']; - $userstatic->email = $tab[$i]['email']; - $userstatic->statut = $tab[$i]['statuscontact']; - - print $userstatic->getNomUrl(-1); - } - if ($tab[$i]['source'] == 'external') { - $contactstatic->id = $tab[$i]['id']; - $contactstatic->lastname = $tab[$i]['lastname']; - $contactstatic->firstname = $tab[$i]['firstname']; - $contactstatic->email = $tab[$i]['email']; - $contactstatic->statut = $tab[$i]['statuscontact']; - print $contactstatic->getNomUrl(1); - } + if ($tab[$i]['source'] == 'internal') + { + $userstatic->id = $tab[$i]['id']; + $userstatic->lastname = $tab[$i]['lastname']; + $userstatic->firstname = $tab[$i]['firstname']; + $userstatic->photo = $tab[$i]['photo']; + $userstatic->login = $tab[$i]['login']; + print $userstatic->getNomUrl(-1); + } + if ($tab[$i]['source'] == 'external') + { + $contactstatic->id = $tab[$i]['id']; + $contactstatic->lastname = $tab[$i]['lastname']; + $contactstatic->firstname = $tab[$i]['firstname']; + print $contactstatic->getNomUrl(1); + } @@ -524,3 +526 @@ - if ($object->statut >= 0) { - print ''; - } + if ($object->statut >= 0) print ''; @@ -528,3 +528 @@ - if ($object->statut >= 0) { - print ''; - } + if ($object->statut >= 0) print ''; @@ -535 +533,2 @@ - if ($user->hasRight('projet', 'creer')) { + if ($user->rights->projet->creer) + { @@ -537 +536 @@ - print ''; + print ''; @@ -549,3 +548,3 @@ - - print ""; - } else { + } + else + { @@ -556 +555,2 @@ -if (is_object($hookmanager)) { +if (is_object($hookmanager)) +{ --- /tmp/dsg/dolibarr/htdocs/projet/tasks/github_19.0.3_document.php +++ /tmp/dsg/dolibarr/htdocs/projet/tasks/client_document.php @@ -27 +26,0 @@ -// Load Dolibarr environment @@ -39 +38 @@ -$action = GETPOST('action', 'aZ09'); +$action = GETPOST('action', 'alpha'); @@ -41 +40 @@ -$mine = GETPOST('mode') == 'mine' ? 1 : 0; +$mine = $_REQUEST['mode'] == 'mine' ? 1 : 0; @@ -47,0 +47,6 @@ +// Security check +$socid = 0; +//if ($user->socid > 0) $socid = $user->socid; // For external user, no check is done on company because readability is managed by public status of project and assignement. +//$result=restrictedArea($user,'projet',$id,''); +if (!$user->rights->projet->lire) accessforbidden(); + @@ -50,2 +55,2 @@ -$sortfield = GETPOST('sortfield', 'aZ09comma'); -$sortorder = GETPOST('sortorder', 'aZ09comma'); +$sortfield = GETPOST("sortfield", 'alpha'); +$sortorder = GETPOST("sortorder", 'alpha'); @@ -53,3 +58 @@ -if (empty($page) || $page == -1) { - $page = 0; -} // If $page is not defined, or '' or -1 +if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 @@ -59,6 +62,2 @@ -if (!$sortorder) { - $sortorder = "ASC"; -} -if (!$sortfield) { - $sortfield = "name"; -} +if (!$sortorder) $sortorder = "ASC"; +if (!$sortfield) $sortfield = "name"; @@ -68,12 +66,0 @@ - -if ($id > 0 || $ref) { - $object->fetch($id, $ref); -} - -// Security check -$socid = 0; - -restrictedArea($user, 'projet', $object->fk_project, 'projet&project'); - -$permissiontoadd = $user->hasRight('projet', 'creer'); // Used by the include of actions_addupdatedelete.inc.php and actions_linkedfiles.inc.php - @@ -85,3 +72,5 @@ -// Retrieve First Task ID of Project if withprojet is on to allow project prev next to work -if (!empty($project_ref) && !empty($withproject)) { - if ($projectstatic->fetch(0, $project_ref) > 0) { +// Retreive First Task ID of Project if withprojet is on to allow project prev next to work +if (!empty($project_ref) && !empty($withproject)) +{ + if ($projectstatic->fetch(0, $project_ref) > 0) + { @@ -89 +78,2 @@ - if (count($tasksarray) > 0) { + if (count($tasksarray) > 0) + { @@ -92 +82,3 @@ - } else { + } + else + { @@ -99,16 +91,20 @@ -if ($id > 0 || !empty($ref)) { - if (getDolGlobalString('PROJECT_ALLOW_COMMENT_ON_TASK') && method_exists($object, 'fetchComments') && empty($object->comments)) { - $object->fetchComments(); - } - $projectstatic->fetch($object->fk_project); - if (getDolGlobalString('PROJECT_ALLOW_COMMENT_ON_PROJECT') && method_exists($projectstatic, 'fetchComments') && empty($projectstatic->comments)) { - $projectstatic->fetchComments(); - } - - if (!empty($projectstatic->socid)) { - $projectstatic->fetch_thirdparty(); - } - - $object->project = clone $projectstatic; - - $upload_dir = $conf->project->multidir_output[$projectstatic->entity].'/'.dol_sanitizeFileName($projectstatic->ref).'/'.dol_sanitizeFileName($object->ref); +if ($id > 0 || !empty($ref)) +{ + if ($object->fetch($id, $ref) > 0) + { + if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_TASK) && method_exists($object, 'fetchComments') && empty($object->comments)) $object->fetchComments(); + $projectstatic->fetch($object->fk_project); + if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($projectstatic, 'fetchComments') && empty($projectstatic->comments)) $projectstatic->fetchComments(); + + if (!empty($projectstatic->socid)) { + $projectstatic->fetch_thirdparty(); + } + + $object->project = clone $projectstatic; + + $upload_dir = $conf->projet->dir_output.'/'.dol_sanitizeFileName($projectstatic->ref).'/'.dol_sanitizeFileName($object->ref); + } + else + { + dol_print_error($db); + } @@ -117 +113 @@ -include DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php'; +include_once DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php'; @@ -122,0 +119 @@ + @@ -125,9 +122,4 @@ -$title = $object->ref . ' - ' . $langs->trans("Documents"); -if (!empty($withproject)) { - $title .= ' | ' . $langs->trans("Project") . (!empty($projectstatic->ref) ? ': '.$projectstatic->ref : '') ; -} -$help_url = ''; - -llxHeader('', $title, $help_url); - -if ($object->id > 0) { +llxHeader('', $langs->trans('Task')); + +if ($object->id > 0) +{ @@ -138 +130,2 @@ - if (!empty($withproject)) { + if (!empty($withproject)) + { @@ -143,3 +136,3 @@ - print dol_get_fiche_head($head, $tab, $langs->trans("Project"), -1, ($projectstatic->public ? 'projectpub' : 'project')); - - $param = (isset($mode) && $mode == 'mine' ? '&mode=mine' : ''); + dol_fiche_head($head, $tab, $langs->trans("Project"), -1, ($projectstatic->public ? 'projectpub' : 'project')); + + $param = ($mode == 'mine' ? '&mode=mine' : ''); @@ -149,119 +142,110 @@ - $linkback = '
'.$langs->trans("BackToList").''; - - $morehtmlref = '
'; - // Title - $morehtmlref .= $projectstatic->title; - // Thirdparty - if (isset($projectstatic->thirdparty->id) && $projectstatic->thirdparty->id > 0) { - $morehtmlref .= '
'.$projectstatic->thirdparty->getNomUrl(1, 'project'); - } - $morehtmlref .= '
'; - - // Define a complementary filter for search of next/prev ref. - if (!$user->hasRight('projet', 'all', 'lire')) { - $objectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 0); - $projectstatic->next_prev_filter = "rowid IN (".$db->sanitize(count($objectsListId) ? join(',', array_keys($objectsListId)) : '0').")"; - } - - dol_banner_tab($projectstatic, 'project_ref', $linkback, 1, 'ref', 'ref', $morehtmlref); - - print '
'; - print '
'; - print '
'; - - print ''; - - // Usage - if (getDolGlobalString('PROJECT_USE_OPPORTUNITIES') || !getDolGlobalString('PROJECT_HIDE_TASKS') || isModEnabled('eventorganization')) { - print ''; - print ''; - } - - // Visibility - print ''; - - // Budget - print ''; - - // Date start - end project - print ''; - - // Other attributes - $cols = 2; - //include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; - - print '
'; - print $langs->trans("Usage"); - print ''; - if (getDolGlobalString('PROJECT_USE_OPPORTUNITIES')) { - print 'usage_opportunity ? ' checked="checked"' : '')).'"> '; - $htmltext = $langs->trans("ProjectFollowOpportunity"); - print $form->textwithpicto($langs->trans("ProjectFollowOpportunity"), $htmltext); - print '
'; - } - if (!getDolGlobalString('PROJECT_HIDE_TASKS')) { - print 'usage_task ? ' checked="checked"' : '')).'"> '; - $htmltext = $langs->trans("ProjectFollowTasks"); - print $form->textwithpicto($langs->trans("ProjectFollowTasks"), $htmltext); - print '
'; - } - if (!getDolGlobalString('PROJECT_HIDE_TASKS') && getDolGlobalString('PROJECT_BILL_TIME_SPENT')) { - print 'usage_bill_time ? ' checked="checked"' : '')).'"> '; - $htmltext = $langs->trans("ProjectBillTimeDescription"); - print $form->textwithpicto($langs->trans("BillTime"), $htmltext); - print '
'; - } - if (isModEnabled('eventorganization')) { - print 'usage_organize_event ? ' checked="checked"' : '')).'"> '; - $htmltext = $langs->trans("EventOrganizationDescriptionLong"); - print $form->textwithpicto($langs->trans("ManageOrganizeEvent"), $htmltext); - } - print '
'.$langs->trans("Visibility").''; - if ($projectstatic->public) { - print img_picto($langs->trans('SharedProject'), 'world', 'class="paddingrightonly"'); - print $langs->trans('SharedProject'); - } else { - print img_picto($langs->trans('PrivateProject'), 'private', 'class="paddingrightonly"'); - print $langs->trans('PrivateProject'); - } - print '
'.$langs->trans("Budget").''; - if (strcmp($projectstatic->budget_amount, '')) { - print price($projectstatic->budget_amount, '', $langs, 1, 0, 0, $conf->currency); - } - print '
'.$langs->trans("Dates").''; - $start = dol_print_date($projectstatic->date_start, 'day'); - print($start ? $start : '?'); - $end = dol_print_date($projectstatic->date_end, 'day'); - print ' - '; - print($end ? $end : '?'); - if ($projectstatic->hasDelay()) { - print img_warning("Late"); - } - print '
'; - - print '
'; - print '
'; - print '
'; - - print ''; - - // Description - print ''; - - // Categories - if (isModEnabled('categorie')) { - print '"; - } - - print '
'.$langs->trans("Description").''; - print nl2br($projectstatic->description); - print '
'.$langs->trans("Categories").''; - print $form->showCategories($projectstatic->id, 'project', 1); - print "
'; - - print '
'; - print '
'; - - print '
'; - - print dol_get_fiche_end(); + $linkback = ''.$langs->trans("BackToList").''; + + $morehtmlref = '
'; + // Title + $morehtmlref .= $projectstatic->title; + // Thirdparty + if ($projectstatic->thirdparty->id > 0) + { + $morehtmlref .= '
'.$langs->trans('ThirdParty').' : '.$projectstatic->thirdparty->getNomUrl(1, 'project'); + } + $morehtmlref .= '
'; + + // Define a complementary filter for search of next/prev ref. + if (!$user->rights->projet->all->lire) + { + $objectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 0); + $projectstatic->next_prev_filter = " rowid in (".(count($objectsListId) ?join(',', array_keys($objectsListId)) : '0').")"; + } + + dol_banner_tab($projectstatic, 'project_ref', $linkback, 1, 'ref', 'ref', $morehtmlref); + + print '
'; + print '
'; + print '
'; + + print ''; + + // Usage + print ''; + print ''; + + // Visibility + print ''; + + // Date start - end + print ''; + + // Budget + print ''; + + // Other attributes + $cols = 2; + //include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; + + print '
'; + print $langs->trans("Usage"); + print ''; + if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) + { + print 'usage_opportunity ? ' checked="checked"' : '')).'"> '; + $htmltext = $langs->trans("ProjectFollowOpportunity"); + print $form->textwithpicto($langs->trans("ProjectFollowOpportunity"), $htmltext); + print '
'; + } + if (empty($conf->global->PROJECT_HIDE_TASKS)) + { + print 'usage_task ? ' checked="checked"' : '')).'"> '; + $htmltext = $langs->trans("ProjectFollowTasks"); + print $form->textwithpicto($langs->trans("ProjectFollowTasks"), $htmltext); + print '
'; + } + if (!empty($conf->global->PROJECT_BILL_TIME_SPENT)) + { + print 'usage_bill_time ? ' checked="checked"' : '')).'"> '; + $htmltext = $langs->trans("ProjectBillTimeDescription"); + print $form->textwithpicto($langs->trans("BillTime"), $htmltext); + print '
'; + } + print '
'.$langs->trans("Visibility").''; + if ($projectstatic->public) print $langs->trans('SharedProject'); + else print $langs->trans('PrivateProject'); + print '
'.$langs->trans("DateStart").' - '.$langs->trans("DateEnd").''; + $start = dol_print_date($projectstatic->date_start, 'day'); + print ($start ? $start : '?'); + $end = dol_print_date($projectstatic->date_end, 'day'); + print ' - '; + print ($end ? $end : '?'); + if ($projectstatic->hasDelay()) print img_warning("Late"); + print '
'.$langs->trans("Budget").''; + if (strcmp($projectstatic->budget_amount, '')) print price($projectstatic->budget_amount, '', $langs, 1, 0, 0, $conf->currency); + print '
'; + + print '
'; + print '
'; + print '
'; + print '
'; + + print ''; + + // Description + print ''; + + // Categories + if ($conf->categorie->enabled) { + print '"; + } + + print '
'.$langs->trans("Description").''; + print nl2br($projectstatic->description); + print '
'.$langs->trans("Categories").''; + print $form->showCategories($projectstatic->id, 'project', 1); + print "
'; + + print '
'; + print '
'; + print '
'; + + print '
'; + + dol_fiche_end(); @@ -273 +257 @@ - print dol_get_fiche_head($head, 'task_document', $langs->trans("Task"), -1, 'projecttask', 0, '', 'reposition'); + dol_fiche_head($head, 'task_document', $langs->trans("Task"), -1, 'projecttask', 0, '', 'reposition'); @@ -276 +260 @@ - $filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) == 'desc' ? SORT_DESC : SORT_ASC), 1); + $filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) == 'desc' ?SORT_DESC:SORT_ASC), 1); @@ -278 +262,2 @@ - foreach ($filearray as $key => $file) { + foreach ($filearray as $key => $file) + { @@ -285,6 +270,6 @@ - if (!GETPOST('withproject') || empty($projectstatic->id)) { - $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1); - $object->next_prev_filter = "fk_projet IN (".$db->sanitize($projectsListId).")"; - } else { - $object->next_prev_filter = "fk_projet = ".((int) $projectstatic->id); - } + if (!GETPOST('withproject') || empty($projectstatic->id)) + { + $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1); + $object->next_prev_filter = " fk_projet in (".$projectsListId.")"; + } + else $object->next_prev_filter = " fk_projet = ".$projectstatic->id; @@ -295,12 +280,13 @@ - if (empty($withproject)) { - $morehtmlref .= '
'; - $morehtmlref .= $langs->trans("Project").': '; - $morehtmlref .= $projectstatic->getNomUrl(1); - $morehtmlref .= '
'; - - // Third party - $morehtmlref .= $langs->trans("ThirdParty").': '; - if (is_object($projectstatic->thirdparty) && $projectstatic->thirdparty->id > 0) { - $morehtmlref .= $projectstatic->thirdparty->getNomUrl(1); - } - $morehtmlref .= '
'; + if (empty($withproject)) + { + $morehtmlref .= '
'; + $morehtmlref .= $langs->trans("Project").': '; + $morehtmlref .= $projectstatic->getNomUrl(1); + $morehtmlref .= '
'; + + // Third party + $morehtmlref .= $langs->trans("ThirdParty").': '; + if (is_object($projectstatic->thirdparty) && $projectstatic->thirdparty->id > 0) { + $morehtmlref .= $projectstatic->thirdparty->getNomUrl(1); + } + $morehtmlref .= '
'; @@ -324 +310 @@ - print dol_get_fiche_end(); + dol_fiche_end(); @@ -329,3 +315 @@ - if ($withproject) { - $param .= '&withproject=1'; - } + if ($withproject) $param .= '&withproject=1'; @@ -333,2 +317,2 @@ - $permissiontoadd = $user->hasRight('projet', 'creer'); - $permtoedit = $user->hasRight('projet', 'creer'); + $permission = $user->rights->projet->creer; + $permtoedit = $user->rights->projet->creer; @@ -336,2 +320,4 @@ - include DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php'; -} else { + include_once DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php'; +} +else +{ --- /tmp/dsg/dolibarr/htdocs/projet/tasks/github_19.0.3_list.php +++ /tmp/dsg/dolibarr/htdocs/projet/tasks/client_list.php @@ -6,2 +5,0 @@ - * Copyright (C) 2021 Alexandre Spangaro - * Copyright (C) 2023 Gauthier VERDOL @@ -39 +37 @@ -$action = GETPOST('action', 'aZ09'); +$action = GETPOST('action', 'alpha'); @@ -44,2 +41,0 @@ -$optioncss = GETPOST('optioncss', 'aZ09'); -$mode = GETPOST('mode', 'aZ'); @@ -49,2 +45,3 @@ -$search_all = trim((GETPOST('search_all', 'alphanohtml') != '') ? GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml')); -$search_categ = GETPOST("search_categ", 'int'); +$search_all = trim((GETPOST('search_all', 'alphanohtml') != '') ?GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml')); +$search_categ = GETPOST("search_categ", 'alpha'); +$search_project = GETPOST('search_project'); @@ -53,6 +50,4 @@ -if (!isset($search_projectstatus) || $search_projectstatus === '') { - if ($search_all != '') { - $search_projectstatus = -1; - } else { - $search_projectstatus = 1; - } +if (!isset($search_projectstatus) || $search_projectstatus === '') +{ + if ($search_all != '') $search_projectstatus = -1; + else $search_projectstatus = 1; @@ -67,4 +62,2 @@ -$search_project_user = GETPOST('search_project_user', 'int'); -$search_task_user = GETPOST('search_task_user', 'int'); -$search_task_progress = GETPOST('search_task_progress'); -$search_task_budget_amount = GETPOST('search_task_budget_amount'); +$search_project_user = GETPOST('search_project_user'); +$search_task_user = GETPOST('search_task_user'); @@ -72,33 +65,10 @@ -$search_societe_alias = GETPOST('search_societe_alias'); -$search_opp_status = GETPOST("search_opp_status", 'alpha'); -$searchCategoryCustomerOperator = 0; -if (GETPOSTISSET('formfilteraction')) { - $searchCategoryCustomerOperator = GETPOST('search_category_customer_operator', 'int'); -} elseif (getDolGlobalString('MAIN_SEARCH_CAT_OR_BY_DEFAULT')) { - $searchCategoryCustomerOperator = $conf->global->MAIN_SEARCH_CAT_OR_BY_DEFAULT; -} -$searchCategoryCustomerList = GETPOST('search_category_customer_list', 'array'); - -$mine = GETPOST('mode', 'alpha') == 'mine' ? 1 : 0; -if ($mine) { - $search_task_user = $user->id; - $mine = 0; -} -$type = GETPOST('type'); - -$search_date_startday = GETPOST('search_date_startday', 'int'); -$search_date_startmonth = GETPOST('search_date_startmonth', 'int'); -$search_date_startyear = GETPOST('search_date_startyear', 'int'); -$search_date_endday = GETPOST('search_date_endday', 'int'); -$search_date_endmonth = GETPOST('search_date_endmonth', 'int'); -$search_date_endyear = GETPOST('search_date_endyear', 'int'); -$search_date_start = dol_mktime(0, 0, 0, $search_date_startmonth, $search_date_startday, $search_date_startyear); // Use tzserver -$search_date_end = dol_mktime(23, 59, 59, $search_date_endmonth, $search_date_endday, $search_date_endyear); -$search_datelimit_startday = GETPOST('search_datelimit_startday', 'int'); -$search_datelimit_startmonth = GETPOST('search_datelimit_startmonth', 'int'); -$search_datelimit_startyear = GETPOST('search_datelimit_startyear', 'int'); -$search_datelimit_endday = GETPOST('search_datelimit_endday', 'int'); -$search_datelimit_endmonth = GETPOST('search_datelimit_endmonth', 'int'); -$search_datelimit_endyear = GETPOST('search_datelimit_endyear', 'int'); -$search_datelimit_start = dol_mktime(0, 0, 0, $search_datelimit_startmonth, $search_datelimit_startday, $search_datelimit_startyear); -$search_datelimit_end = dol_mktime(23, 59, 59, $search_datelimit_endmonth, $search_datelimit_endday, $search_datelimit_endyear); + +$mine = $_REQUEST['mode'] == 'mine' ? 1 : 0; +if ($mine) { $search_task_user = $user->id; $mine = 0; } + +$search_sday = GETPOST('search_sday', 'int'); +$search_smonth = GETPOST('search_smonth', 'int'); +$search_syear = GETPOST('search_syear', 'int'); +$search_eday = GETPOST('search_eday', 'int'); +$search_emonth = GETPOST('search_emonth', 'int'); +$search_eyear = GETPOST('search_eyear', 'int'); @@ -107 +77 @@ -$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'tasklist'; +$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'tasklist'; @@ -121,9 +91,7 @@ -if (!$user->hasRight('projet', 'lire')) { - accessforbidden(); -} - -$diroutputmassaction = $conf->project->dir_output.'/tasks/temp/massgeneration/'.$user->id; - -$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; -$sortfield = GETPOST('sortfield', 'aZ09comma'); -$sortorder = GETPOST('sortorder', 'aZ09comma'); +if (!$user->rights->projet->lire) accessforbidden(); + +$diroutputmassaction = $conf->projet->dir_output.'/tasks/temp/massgeneration/'.$user->id; + +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; +$sortfield = GETPOST("sortfield", 'alpha'); +$sortorder = GETPOST("sortorder", 'alpha'); @@ -131,4 +99 @@ -if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) { - // If $page is not defined, or '' or -1 or if we click on clear filters - $page = 0; -} +if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 @@ -138,6 +103,2 @@ -if (!$sortfield) { - $sortfield = 'p.ref'; -} -if (!$sortorder) { - $sortorder = 'DESC'; -} +if (!$sortfield) $sortfield = 'p.ref'; +if (!$sortorder) $sortorder = 'DESC'; @@ -152,3 +113 @@ -if (empty($user->socid)) { - $fieldstosearchall['t.note_private'] = "NotePrivate"; -} +if (empty($user->socid)) $fieldstosearchall['t.note_private'] = "NotePrivate"; @@ -157,22 +116,20 @@ - 't.fk_task_parent'=>array('label'=>"RefTaskParent", 'checked'=>0, 'position'=>70), - 't.ref'=>array('label'=>"RefTask", 'checked'=>1, 'position'=>80), - 't.label'=>array('label'=>"LabelTask", 'checked'=>1, 'position'=>80), - 't.description'=>array('label'=>"Description", 'checked'=>0, 'position'=>80), - 't.dateo'=>array('label'=>"DateStart", 'checked'=>1, 'position'=>100), - 't.datee'=>array('label'=>"Deadline", 'checked'=>1, 'position'=>101), - 'p.ref'=>array('label'=>"ProjectRef", 'checked'=>1, 'position'=>151), - 'p.title'=>array('label'=>"ProjectLabel", 'checked'=>0, 'position'=>152), - 's.nom'=>array('label'=>"ThirdParty", 'checked'=>1, 'csslist'=>'tdoverflowmax125', 'position'=>200), - 's.name_alias'=>array('label'=>"AliasNameShort", 'checked'=>0, 'csslist'=>'tdoverflowmax125', 'position'=>201), - 'p.fk_statut'=>array('label'=>"ProjectStatus", 'checked'=>1, 'position'=>205), - 't.planned_workload'=>array('label'=>"PlannedWorkload", 'checked'=>1, 'position'=>302), - 't.duration_effective'=>array('label'=>"TimeSpent", 'checked'=>1, 'position'=>303), - 't.progress_calculated'=>array('label'=>"ProgressCalculated", 'checked'=>1, 'position'=>304), - 't.progress'=>array('label'=>"ProgressDeclared", 'checked'=>1, 'position'=>305), - 't.progress_summary'=>array('label'=>"TaskProgressSummary", 'checked'=>1, 'position'=>306), - 't.budget_amount'=>array('label'=>"Budget", 'checked'=>0, 'position'=>307), - 't.tobill'=>array('label'=>"TimeToBill", 'checked'=>0, 'position'=>310), - 't.billed'=>array('label'=>"TimeBilled", 'checked'=>0, 'position'=>311), - 't.datec'=>array('label'=>"DateCreation", 'checked'=>0, 'position'=>500), - 't.tms'=>array('label'=>"DateModificationShort", 'checked'=>0, 'position'=>501), - //'t.fk_statut'=>array('label'=>"Status", 'checked'=>1, 'position'=>1000), + 't.fk_task_parent'=>array('label'=>$langs->trans("RefTaskParent"), 'checked'=>0, 'position'=>70), + 't.ref'=>array('label'=>$langs->trans("RefTask"), 'checked'=>1, 'position'=>80), + 't.label'=>array('label'=>$langs->trans("LabelTask"), 'checked'=>1, 'position'=>80), + 't.description'=>array('label'=>$langs->trans("Description"), 'checked'=>0, 'position'=>80), + 't.dateo'=>array('label'=>$langs->trans("DateStart"), 'checked'=>1, 'position'=>100), + 't.datee'=>array('label'=>$langs->trans("DateEnd"), 'checked'=>1, 'position'=>101), + 'p.ref'=>array('label'=>$langs->trans("ProjectRef"), 'checked'=>1), + 'p.title'=>array('label'=>$langs->trans("ProjectLabel"), 'checked'=>0), + 's.nom'=>array('label'=>$langs->trans("ThirdParty"), 'checked'=>0), + 'p.fk_statut'=>array('label'=>$langs->trans("ProjectStatus"), 'checked'=>1), + 't.planned_workload'=>array('label'=>$langs->trans("PlannedWorkload"), 'checked'=>1, 'position'=>102), + 't.duration_effective'=>array('label'=>$langs->trans("TimeSpent"), 'checked'=>1, 'position'=>103), + 't.progress_calculated'=>array('label'=>$langs->trans("ProgressCalculated"), 'checked'=>1, 'position'=>104), + 't.progress'=>array('label'=>$langs->trans("ProgressDeclared"), 'checked'=>1, 'position'=>105), + 't.progress_summary'=>array('label'=>$langs->trans("TaskProgressSummary"), 'checked'=>1, 'position'=>106), + 't.tobill'=>array('label'=>$langs->trans("TimeToBill"), 'checked'=>0, 'position'=>110), + 't.billed'=>array('label'=>$langs->trans("TimeBilled"), 'checked'=>0, 'position'=>111), + 't.datec'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0, 'position'=>500), + 't.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500), + //'t.fk_statut'=>array('label'=>$langs->trans("Status"), 'checked'=>1, 'position'=>1000), @@ -181,2 +138,8 @@ -include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php'; - +if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0) +{ + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) + { + if (!empty($extrafields->attributes[$object->table_element]['list'][$key])) + $arrayfields["ef.".$key] = array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key] < 0) ? 0 : 1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key]) != 3 && $extrafields->attributes[$object->table_element]['perms'][$key])); + } +} @@ -185,8 +147,0 @@ - -$permissiontoread = $user->hasRight('projet', 'lire'); -$permissiontocreate = $user->hasRight('projet', 'creer'); -$permissiontodelete = $user->hasRight('projet', 'supprimer'); - -if (!$permissiontoread) { - accessforbidden(); -} @@ -199,7 +154,2 @@ -if (GETPOST('cancel', 'alpha')) { - $action = 'list'; - $massaction = ''; -} -if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { - $massaction = ''; -} +if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; } +if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend' && $massaction != 'confirm_createbills') { $massaction = ''; } @@ -209,5 +159,4 @@ -if ($reshook < 0) { - setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); -} - -if (empty($reshook)) { +if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + +if (empty($reshook)) +{ @@ -218 +167,2 @@ - if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers + if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers + { @@ -220,0 +171 @@ + $search_project = ""; @@ -223,2 +173,0 @@ - $search_societe = ""; - $search_societe_alias = ""; @@ -230,2 +178,0 @@ - $search_task_progress = ""; - $search_task_budget_amount = ""; @@ -234,18 +181,7 @@ - $search_date_startday = ''; - $search_date_startmonth = ''; - $search_date_startyear = ''; - $search_date_endday = ''; - $search_date_endmonth = ''; - $search_date_endyear = ''; - $search_date_start = ''; - $search_date_end = ''; - $search_datelimit_startday = ''; - $search_datelimit_startmonth = ''; - $search_datelimit_startyear = ''; - $search_datelimit_endday = ''; - $search_datelimit_endmonth = ''; - $search_datelimit_endyear = ''; - $search_datelimit_start = ''; - $search_datelimit_end = ''; - $toselect = array(); - $searchCategoryCustomerList = array(); + $search_sday = ''; + $search_smonth = ''; + $search_syear = ''; + $search_eday = ''; + $search_emonth = ''; + $search_eyear = ''; + $toselect = ''; @@ -258 +194,3 @@ - $uploaddir = $conf->project->dir_output.'/tasks'; + $permissiontoread = $user->rights->projet->lire; + $permissiontodelete = $user->rights->projet->supprimer; + $uploaddir = $conf->projet->dir_output.'/tasks'; @@ -262,3 +200 @@ -if (empty($search_projectstatus) && $search_projectstatus == '') { - $search_projectstatus = 1; -} +if (empty($search_projectstatus) && $search_projectstatus == '') $search_projectstatus = 1; @@ -272,0 +209 @@ +$now = dol_now(); @@ -279,2 +216,7 @@ - -$now = dol_now(); +if ($search_project_user > 0) $puser->fetch($search_project_user); +if ($search_task_user > 0) $tuser->fetch($search_task_user); + + +$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; +$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields + @@ -283,17 +225,4 @@ -$help_url = "EN:Module_Projects|FR:Module_Projets|ES:Módulo_Proyectos"; -$morejs = array(); -$morecss = array(); - -if ($search_project_user > 0) { - $puser->fetch($search_project_user); -} -if ($search_task_user > 0) { - $tuser->fetch($search_task_user); -} - - -$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; -$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN', '')); // This also change content of $arrayfields - - -if ($id) { +//if ($search_task_user == $user->id) $title=$langs->trans("MyActivities"); + +if ($id) +{ @@ -305,3 +234 @@ -if (!$user->hasRight('projet', 'all', 'lire')) { - $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1, $socid); -} +if (!$user->rights->projet->all->lire) $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1, $socid); @@ -313 +240 @@ -$sql .= " WHERE ctc.element = '".$db->escape($projectstatic->element)."'"; +$sql .= " WHERE ctc.element = '".$projectstatic->element."'"; @@ -316,2 +243,4 @@ -if ($resql) { - while ($obj = $db->fetch_object($resql)) { +if ($resql) +{ + while ($obj = $db->fetch_object($resql)) + { @@ -320,6 +249,3 @@ -} else { - dol_print_error($db); -} -if (count($listofprojectcontacttype) == 0) { - $listofprojectcontacttype[0] = '0'; // To avoid sql syntax error if not found -} +} +else dol_print_error($db); +if (count($listofprojectcontacttype) == 0) $listofprojectcontacttype[0] = '0'; // To avoid sql syntax error if not found @@ -329 +255 @@ -$sql .= " WHERE ctc.element = '".$db->escape($object->element)."'"; +$sql .= " WHERE ctc.element = '".$object->element."'"; @@ -332,2 +258,4 @@ -if ($resql) { - while ($obj = $db->fetch_object($resql)) { +if ($resql) +{ + while ($obj = $db->fetch_object($resql)) + { @@ -336,9 +264,4 @@ -} else { - dol_print_error($db); -} -if (count($listoftaskcontacttype) == 0) { - $listoftaskcontacttype[0] = '0'; // To avoid sql syntax error if not found -} - -// Build and execute select -// -------------------------------------------------------------------- +} +else dol_print_error($db); +if (count($listoftaskcontacttype) == 0) $listoftaskcontacttype[0] = '0'; // To avoid sql syntax error if not found + @@ -347 +270 @@ -$sql .= " s.nom as name, s.name_alias as alias, s.rowid as socid,"; +$sql .= " s.nom as name, s.rowid as socid,"; @@ -349 +272 @@ -$sql .= " t.rowid as id, t.ref, t.label, t.planned_workload, t.duration_effective, t.progress, t.fk_statut,"; +$sql .= " t.rowid as id, t.ref, t.label, t.planned_workload, t.duration_effective, t.progress, t.fk_statut, "; @@ -351 +274,2 @@ -$sql .= " ,t.budget_amount"; +// We'll need these fields in order to filter by categ +if ($search_categ) $sql .= ", cs.fk_categorie, cs.fk_project"; @@ -353,2 +277,3 @@ -if (!empty($arrayfields['t.tobill']['checked']) || !empty($arrayfields['t.billed']['checked'])) { - $sql .= " , SUM(tt.element_duration * ".$db->ifsql("invoice_id IS NULL", "1", "0").") as tobill, SUM(tt.element_duration * ".$db->ifsql("invoice_id IS NULL", "0", "1").") as billed"; +if (!empty($arrayfields['t.tobill']['checked']) || !empty($arrayfields['t.billed']['checked'])) +{ + $sql .= " , SUM(tt.task_duration * ".$db->ifsql("invoice_id IS NULL", "1", "0").") as tobill, SUM(tt.task_duration * ".$db->ifsql("invoice_id IS NULL", "0", "1").") as billed"; @@ -358,3 +283 @@ - foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { - $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key." as options_".$key : ''); - } + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : ''); @@ -364 +287 @@ -$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object, $action); // Note that $action and $object may have been modified by hook +$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook @@ -366,4 +288,0 @@ -$sql = preg_replace('/,\s*$/', '', $sql); - -$sqlfields = $sql; // $sql fields to remove for count total - @@ -371,0 +291,2 @@ +// We'll need this table joined to the select in order to filter by categ +if (!empty($search_categ)) $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_project as cs ON p.rowid = cs.fk_project"; // We'll need this table joined to the select in order to filter by categ @@ -373,12 +294,7 @@ -if (!empty($arrayfields['t.tobill']['checked']) || !empty($arrayfields['t.billed']['checked'])) { - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."element_time as tt ON (tt.fk_element = t.rowid AND tt.elementtype = 'task')"; -} -if (isset($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (t.rowid = ef.fk_object)"; -} -if ($search_project_user > 0) { - $sql .= ", ".MAIN_DB_PREFIX."element_contact as ecp"; -} -if ($search_task_user > 0) { - $sql .= ", ".MAIN_DB_PREFIX."element_contact as ect"; -} +if (!empty($arrayfields['t.tobill']['checked']) || !empty($arrayfields['t.billed']['checked'])) +{ + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."projet_task_time as tt ON tt.fk_task = t.rowid"; +} +if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (t.rowid = ef.fk_object)"; +if ($search_project_user > 0) $sql .= ", ".MAIN_DB_PREFIX."element_contact as ecp"; +if ($search_task_user > 0) $sql .= ", ".MAIN_DB_PREFIX."element_contact as ect"; @@ -387,6 +303,2 @@ -if (!$user->hasRight('projet', 'all', 'lire')) { - $sql .= " AND p.rowid IN (".$db->sanitize($projectsListId ? $projectsListId : '0').")"; // public and assigned to projects, or restricted to company for external users -} -if (is_object($projectstatic) && $projectstatic->id > 0) { - $sql .= " AND p.rowid = ".((int) $projectstatic->id); -} +if (!$user->rights->projet->all->lire) $sql .= " AND p.rowid IN (".($projectsListId ? $projectsListId : '0').")"; // public and assigned to projects, or restricted to company for external users +if (is_object($projectstatic) && $projectstatic->id > 0) $sql .= " AND p.rowid = ".$projectstatic->id; @@ -394,139 +306,21 @@ -if ($socid) { - $sql .= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".((int) $socid).")"; -} -if ($search_project_ref) { - $sql .= natural_search('p.ref', $search_project_ref); -} -if ($search_project_title) { - $sql .= natural_search('p.title', $search_project_title); -} -if ($search_task_ref) { - $sql .= natural_search('t.ref', $search_task_ref); -} -if ($search_task_label) { - $sql .= natural_search('t.label', $search_task_label); -} -if ($search_task_description) { - $sql .= natural_search('t.description', $search_task_description); -} -if ($search_task_ref_parent) { - $sql .= ' AND t.fk_task_parent IN (SELECT ipt.rowid FROM '.MAIN_DB_PREFIX.'projet_task as ipt WHERE '.natural_search('ipt.ref', $search_task_ref_parent, 0, 1).')'; -} -if ($search_task_progress) { - $sql .= natural_search('t.progress', $search_task_progress, 1); -} -if ($search_task_budget_amount) { - $sql .= natural_search('t.budget_amount', $search_task_budget_amount, 1); -} -if (empty($arrayfields['s.name_alias']['checked']) && $search_societe) { - $sql .= natural_search(array("s.nom", "s.name_alias"), $search_societe); -} else { - if ($search_societe) { - $sql .= natural_search('s.nom', $search_societe); - } - if ($search_societe_alias) { - $sql .= natural_search('s.name_alias', $search_societe_alias); - } -} -if ($search_date_start) { - $sql .= " AND t.dateo >= '".$db->idate($search_date_start)."'"; -} -if ($search_date_end) { - $sql .= " AND t.dateo <= '".$db->idate($search_date_end)."'"; -} -if ($search_datelimit_start) { - $sql .= " AND t.datee >= '".$db->idate($search_datelimit_start)."'"; -} -if ($search_datelimit_end) { - $sql .= " AND t.datee <= '".$db->idate($search_datelimit_end)."'"; -} -if ($search_all) { - $sql .= natural_search(array_keys($fieldstosearchall), $search_all); -} -if ($search_projectstatus >= 0) { - if ($search_projectstatus == 99) { - $sql .= " AND p.fk_statut <> 2"; - } else { - $sql .= " AND p.fk_statut = ".((int) $search_projectstatus); - } -} -if ($search_project_user > 0) { - $sql .= " AND ecp.fk_c_type_contact IN (".$db->sanitize(join(',', array_keys($listofprojectcontacttype))).") AND ecp.element_id = p.rowid AND ecp.fk_socpeople = ".((int) $search_project_user); -} -if ($search_task_user > 0) { - $sql .= " AND ect.fk_c_type_contact IN (".$db->sanitize(join(',', array_keys($listoftaskcontacttype))).") AND ect.element_id = t.rowid AND ect.fk_socpeople = ".((int) $search_task_user); -} -// Search for tag/category ($searchCategoryProjectList is an array of ID) -$searchCategoryProjectList = array($search_categ); -$searchCategoryProjectOperator = 0; -if (!empty($searchCategoryProjectList)) { - $searchCategoryProjectSqlList = array(); - $listofcategoryid = ''; - foreach ($searchCategoryProjectList as $searchCategoryProject) { - if (intval($searchCategoryProject) == -2) { - $searchCategoryProjectSqlList[] = "NOT EXISTS (SELECT ck.fk_project FROM ".MAIN_DB_PREFIX."categorie_project as ck WHERE p.rowid = ck.fk_project)"; - } elseif (intval($searchCategoryProject) > 0) { - if ($searchCategoryProjectOperator == 0) { - $searchCategoryProjectSqlList[] = " EXISTS (SELECT ck.fk_project FROM ".MAIN_DB_PREFIX."categorie_project as ck WHERE p.rowid = ck.fk_project AND ck.fk_categorie = ".((int) $searchCategoryProject).")"; - } else { - $listofcategoryid .= ($listofcategoryid ? ', ' : '') .((int) $searchCategoryProject); - } - } - } - if ($listofcategoryid) { - $searchCategoryProjectSqlList[] = " EXISTS (SELECT ck.fk_project FROM ".MAIN_DB_PREFIX."categorie_project as ck WHERE p.rowid = ck.fk_project AND ck.fk_categorie IN (".$db->sanitize($listofcategoryid)."))"; - } - if ($searchCategoryProjectOperator == 1) { - if (!empty($searchCategoryProjectSqlList)) { - $sql .= " AND (".implode(' OR ', $searchCategoryProjectSqlList).")"; - } - } else { - if (!empty($searchCategoryProjectSqlList)) { - $sql .= " AND (".implode(' AND ', $searchCategoryProjectSqlList).")"; - } - } -} -$searchCategoryCustomerSqlList = array(); -if ($searchCategoryCustomerOperator == 1) { - $existsCategoryCustomerList = array(); - foreach ($searchCategoryCustomerList as $searchCategoryCustomer) { - if (intval($searchCategoryCustomer) == -2) { - $sqlCategoryCustomerNotExists = " NOT EXISTS ("; - $sqlCategoryCustomerNotExists .= " SELECT cat_cus.fk_soc"; - $sqlCategoryCustomerNotExists .= " FROM ".$db->prefix()."categorie_societe AS cat_cus"; - $sqlCategoryCustomerNotExists .= " WHERE cat_cus.fk_soc = p.fk_soc"; - $sqlCategoryCustomerNotExists .= " )"; - $searchCategoryCustomerSqlList[] = $sqlCategoryCustomerNotExists; - } elseif (intval($searchCategoryCustomer) > 0) { - $existsCategoryCustomerList[] = $db->escape($searchCategoryCustomer); - } - } - if (!empty($existsCategoryCustomerList)) { - $sqlCategoryCustomerExists = " EXISTS ("; - $sqlCategoryCustomerExists .= " SELECT cat_cus.fk_soc"; - $sqlCategoryCustomerExists .= " FROM ".$db->prefix()."categorie_societe AS cat_cus"; - $sqlCategoryCustomerExists .= " WHERE cat_cus.fk_soc = p.fk_soc"; - $sqlCategoryCustomerExists .= " AND cat_cus.fk_categorie IN (".$db->sanitize(implode(',', $existsCategoryCustomerList)).")"; - $sqlCategoryCustomerExists .= " )"; - $searchCategoryCustomerSqlList[] = $sqlCategoryCustomerExists; - } - if (!empty($searchCategoryCustomerSqlList)) { - $sql .= " AND (".implode(' OR ', $searchCategoryCustomerSqlList).")"; - } -} else { - foreach ($searchCategoryCustomerList as $searchCategoryCustomer) { - if (intval($searchCategoryCustomer) == -2) { - $sqlCategoryCustomerNotExists = " NOT EXISTS ("; - $sqlCategoryCustomerNotExists .= " SELECT cat_cus.fk_soc"; - $sqlCategoryCustomerNotExists .= " FROM ".$db->prefix()."categorie_societe AS cat_cus"; - $sqlCategoryCustomerNotExists .= " WHERE cat_cus.fk_soc = p.fk_soc"; - $sqlCategoryCustomerNotExists .= " )"; - $searchCategoryCustomerSqlList[] = $sqlCategoryCustomerNotExists; - } elseif (intval($searchCategoryCustomer) > 0) { - $searchCategoryCustomerSqlList[] = "p.fk_soc IN (SELECT fk_soc FROM ".$db->prefix()."categorie_societe WHERE fk_categorie = ".((int) $searchCategoryCustomer).")"; - } - } - if (!empty($searchCategoryCustomerSqlList)) { - $sql .= " AND (".implode(' AND ', $searchCategoryCustomerSqlList).")"; - } -} +if ($socid) $sql .= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")"; +if ($search_categ > 0) $sql .= " AND cs.fk_categorie = ".$db->escape($search_categ); +if ($search_categ == -2) $sql .= " AND cs.fk_categorie IS NULL"; +if ($search_project_ref) $sql .= natural_search('p.ref', $search_project_ref); +if ($search_project_title) $sql .= natural_search('p.title', $search_project_title); +if ($search_task_ref) $sql .= natural_search('t.ref', $search_task_ref); +if ($search_task_label) $sql .= natural_search('t.label', $search_task_label); +if ($search_task_description) $sql .= natural_search('t.description', $search_task_description); +if ($search_task_ref_parent) $sql .= ' AND t.fk_task_parent IN (SELECT ipt.rowid FROM '.MAIN_DB_PREFIX.'projet_task as ipt WHERE '.natural_search('ipt.ref', $search_task_ref_parent, 0, 1).')'; +if ($search_societe) $sql .= natural_search('s.nom', $search_societe); +$sql .= dolSqlDateFilter('t.dateo', $search_sday, $search_smonth, $search_syear); +$sql .= dolSqlDateFilter('t.datee', $search_eday, $search_emonth, $search_eyear); +if ($search_all) $sql .= natural_search(array_keys($fieldstosearchall), $search_all); +if ($search_projectstatus >= 0) +{ + if ($search_projectstatus == 99) $sql .= " AND p.fk_statut <> 2"; + else $sql .= " AND p.fk_statut = ".$db->escape($search_projectstatus); +} +if ($search_public != '') $sql .= " AND p.public = ".$db->escape($search_public); +if ($search_project_user > 0) $sql .= " AND ecp.fk_c_type_contact IN (".join(',', array_keys($listofprojectcontacttype)).") AND ecp.element_id = p.rowid AND ecp.fk_socpeople = ".$search_project_user; +if ($search_task_user > 0) $sql .= " AND ect.fk_c_type_contact IN (".join(',', array_keys($listoftaskcontacttype)).") AND ect.element_id = t.rowid AND ect.fk_socpeople = ".$search_task_user; @@ -537 +331 @@ -$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object, $action); // 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 @@ -539,14 +333,14 @@ -if (!empty($arrayfields['t.tobill']['checked']) || !empty($arrayfields['t.billed']['checked'])) { - $sql .= " GROUP BY p.rowid, p.ref, p.title, p.fk_statut, p.datee, p.fk_opp_status, p.public, p.fk_user_creat,"; - $sql .= " s.nom, s.rowid,"; - $sql .= " t.datec, t.dateo, t.datee, t.tms,"; - $sql .= " t.rowid, t.ref, t.label, t.planned_workload, t.duration_effective, t.progress,t.budget_amount, t.fk_statut"; - // Add fields from extrafields - if (!empty($extrafields->attributes[$object->table_element]['label'])) { - foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { - $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key : ''); - } - } -} - -// Count total nb of records +if (!empty($arrayfields['t.tobill']['checked']) || !empty($arrayfields['t.billed']['checked'])) +{ + $sql .= " GROUP BY p.rowid, p.ref, p.title, p.fk_statut, p.datee, p.fk_opp_status, p.public, p.fk_user_creat,"; + $sql .= " s.nom, s.rowid,"; + $sql .= " t.datec, t.dateo, t.datee, t.tms,"; + $sql .= " t.rowid, t.ref, t.label, t.planned_workload, t.duration_effective, t.progress, t.fk_statut"; + if ($search_categ) $sql .= ", cs.fk_categorie, cs.fk_project"; + // Add fields from extrafields + if (!empty($extrafields->attributes[$object->table_element]['label'])) { + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key : ''); + } +} +$sql .= $db->order($sortfield, $sortorder); + @@ -554,13 +348,6 @@ -if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) { - /* 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); - $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); - } - - if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller than the paging size (filtering), goto and load page 0 +if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) +{ + $result = $db->query($sql); + $nbtotalofrecords = $db->num_rows($result); + if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 + { @@ -570,8 +357,5 @@ - $db->free($resql); -} - -// Complete request and execute it with limit -$sql .= $db->order($sortfield, $sortorder); -if ($limit) { - $sql .= $db->plimit($limit + 1, $offset); -} +} + +$sql .= $db->plimit($limit + 1, $offset); + +dol_syslog("list allowed project", LOG_DEBUG); @@ -580 +364,2 @@ -if (!$resql) { +if (!$resql) +{ @@ -587,3 +372,4 @@ - -// Direct jump if only one record found -if ($num == 1 && getDolGlobalString('MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE') && $search_all) { +$arrayofselected = is_array($toselect) ? $toselect : array(); + +if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all) +{ @@ -591,2 +377,2 @@ - $id = $obj->id; // in select, task id has been aliases into 'id' - header("Location: ".DOL_URL_ROOT.'/projet/tasks/task.php?id='.$id.'&withproject=1'); + $id = $obj->id; + header("Location: ".DOL_URL_ROOT.'/projet/tasks/task.php?id='.$id.'&withprojet=1'); @@ -596,7 +382,2 @@ - -// Output page -// -------------------------------------------------------------------- - -llxHeader('', $title, $help_url, '', 0, 0, $morejs, $morecss, '', 'bodyforlist'); // Can use also classforhorizontalscrolloftabs instead of bodyforlist for no horizontal scroll - -$arrayofselected = is_array($toselect) ? $toselect : array(); +$help_url = "EN:Module_Projects|FR:Module_Projets|ES:Módulo_Proyectos"; +llxHeader("", $title, $help_url); @@ -605,99 +386,23 @@ -if (!empty($mode)) { - $param .= '&mode='.urlencode($mode); -} -if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { - $param .= '&contextpage='.urlencode($contextpage); -} -if ($limit > 0 && $limit != $conf->liste_limit) { - $param .= '&limit='.((int) $limit); -} -if ($search_date_startday) { - $param .= '&search_date_startday='.urlencode($search_date_startday); -} -if ($search_date_startmonth) { - $param .= '&search_date_startmonth='.urlencode($search_date_startmonth); -} -if ($search_date_startyear) { - $param .= '&search_date_startyear='.urlencode($search_date_startyear); -} -if ($search_date_endday) { - $param .= '&search_date_endday='.urlencode($search_date_endday); -} -if ($search_date_endmonth) { - $param .= '&search_date_endmonth='.urlencode($search_date_endmonth); -} -if ($search_date_endyear) { - $param .= '&search_date_endyear='.urlencode($search_date_endyear); -} -if ($search_datelimit_startday) { - $param .= '&search_datelimit_startday='.urlencode($search_datelimit_startday); -} -if ($search_datelimit_startmonth) { - $param .= '&search_datelimit_startmonth='.urlencode($search_datelimit_startmonth); -} -if ($search_datelimit_startyear) { - $param .= '&search_datelimit_startyear='.urlencode($search_datelimit_startyear); -} -if ($search_datelimit_endday) { - $param .= '&search_datelimit_endday='.urlencode($search_datelimit_endday); -} -if ($search_datelimit_endmonth) { - $param .= '&search_datelimit_endmonth='.urlencode($search_datelimit_endmonth); -} -if ($search_datelimit_endyear) { - $param .= '&search_datelimit_endyear='.urlencode($search_datelimit_endyear); -} -if ($search_task_budget_amount) { - $param .= '&search_task_budget_amount='.urlencode($search_task_budget_amount); -} -if ($socid) { - $param .= '&socid='.urlencode($socid); -} -if ($search_all != '') { - $param .= '&search_all='.urlencode($search_all); -} -if ($search_project_ref != '') { - $param .= '&search_project_ref='.urlencode($search_project_ref); -} -if ($search_project_title != '') { - $param .= '&search_project_title='.urlencode($search_project_title); -} -if ($search_task_ref != '') { - $param .= '&search_task_ref='.urlencode($search_task_ref); -} -if ($search_task_label != '') { - $param .= '&search_task_label='.urlencode($search_task_label); -} -if ($search_task_description != '') { - $param .= '&search_task_description='.urlencode($search_task_description); -} -if ($search_task_ref_parent != '') { - $param .= '&search_task_ref_parent='.urlencode($search_task_ref_parent); -} -if ($search_task_progress != '') { - $param .= '&search_task_progress='.urlencode($search_task_progress); -} -if ($search_societe != '') { - $param .= '&search_societe='.urlencode($search_societe); -} -if ($search_societe != '') { - $param .= '&search_societe_alias='.urlencode($search_societe_alias); -} -if ($search_projectstatus != '') { - $param .= '&search_projectstatus='.urlencode($search_projectstatus); -} -if ((is_numeric($search_opp_status) && $search_opp_status >= 0) || in_array($search_opp_status, array('all', 'none'))) { - $param .= '&search_opp_status='.urlencode($search_opp_status); -} -if ($search_project_user != '') { - $param .= '&search_project_user='.urlencode($search_project_user); -} -if ($search_task_user > 0) { - $param .= '&search_task_user='.urlencode($search_task_user); -} -if ($optioncss != '') { - $param .= '&optioncss='.urlencode($optioncss); -} -foreach ($searchCategoryCustomerList as $searchCategoryCustomer) { - $param .= "&search_category_customer_list[]=".urlencode($searchCategoryCustomer); -} +if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); +if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); +if ($search_sday) $param .= '&search_sday='.urlencode($search_sday); +if ($search_smonth) $param .= '&search_smonth='.urlencode($search_smonth); +if ($search_syear) $param .= '&search_syear='.urlencode($search_syear); +if ($search_eday) $param .= '&search_eday='.urlencode($search_eday); +if ($search_emonth) $param .= '&search_emonth='.urlencode($search_emonth); +if ($search_eyear) $param .= '&search_eyear='.urlencode($search_eyear); +if ($socid) $param .= '&socid='.urlencode($socid); +if ($search_all != '') $param .= '&search_all='.urlencode($search_all); +if ($search_project_ref != '') $param .= '&search_project_ref='.urlencode($search_project_ref); +if ($search_project_title != '') $param .= '&search_project_title='.urlencode($search_project_title); +if ($search_task_ref != '') $param .= '&search_task_ref='.urlencode($search_ref); +if ($search_task_label != '') $param .= '&search_task_label='.urlencode($search_label); +if ($search_task_description != '') $param .= '&search_task_description='.urlencode($search_description); +if ($search_task_ref_parent != '') $param .= '&search_task_ref_parent='.urlencode($search_task_ref_parent); +if ($search_societe != '') $param .= '&search_societe='.urlencode($search_societe); +if ($search_projectstatus != '') $param .= '&search_projectstatus='.urlencode($search_projectstatus); +if ((is_numeric($search_opp_status) && $search_opp_status >= 0) || in_array($search_opp_status, array('all', 'none'))) $param .= '&search_opp_status='.urlencode($search_opp_status); +if ($search_public != '') $param .= '&search_public='.urlencode($search_public); +if ($search_project_user != '') $param .= '&search_project_user='.urlencode($search_project_user); +if ($search_task_user > 0) $param .= '&search_task_user='.urlencode($search_task_user); +if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss); @@ -706,4 +410,0 @@ -// Add $param from hooks -$parameters = array('param' => &$param); -$reshook = $hookmanager->executeHooks('printFieldListSearchParam', $parameters, $object, $action); // Note that $action and $object may have been modified by hook -$param .= $hookmanager->resPrint; @@ -713,2 +414,2 @@ -// 'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"), -// 'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"), +// 'presend'=>$langs->trans("SendByMail"), +// 'builddoc'=>$langs->trans("PDFMerge"), @@ -717,6 +418,2 @@ -if (!empty($permissiontodelete)) { - $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete"); -} -if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) { - $arrayofmassactions = array(); -} +if ($user->rights->societe->supprimer) $arrayofmassactions['predelete'] = ''.$langs->trans("Delete"); +if (in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array(); @@ -725,4 +422,8 @@ -print '
'."\n"; -if ($optioncss != '') { - print ''; -} +$newcardbutton = ''; +if ($user->rights->projet->creer) +{ + $newcardbutton .= dolGetButtonTitle($langs->trans('NewTask'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/projet/tasks.php?action=create'); +} + +print ''; +if ($optioncss != '') print ''; @@ -734,4 +435 @@ -print ''; -if (!empty($type)) { - print ''; -} +print ''; @@ -739,11 +436,0 @@ -print ''; -print ''; - - -$newcardbutton = ''; - -$newcardbutton .= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-bars imgforviewmode', $_SERVER["PHP_SELF"].'?mode=common'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ((empty($mode) || $mode == 'common') ? 2 : 1), array('morecss'=>'reposition')); -$newcardbutton .= dolGetButtonTitle($langs->trans('ViewKanban'), '', 'fa fa-th-list imgforviewmode', $_SERVER["PHP_SELF"].'?mode=kanban'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ($mode == 'kanban' ? 2 : 1), array('morecss'=>'reposition')); -$newcardbutton .= dolGetButtonTitleSeparator(); -$newcardbutton .= dolGetButtonTitle($langs->trans('NewTask'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/projet/tasks.php?action=create', '', $permissiontocreate); - @@ -753,8 +440,5 @@ -if ($search_task_user == $user->id) { - $texthelp .= $langs->trans("MyTasksDesc"); -} else { - if ($user->hasRight('projet', 'all', 'lire') && !$socid) { - $texthelp .= $langs->trans("TasksOnProjectsDesc"); - } else { - $texthelp .= $langs->trans("TasksOnProjectsPublicDesc"); - } +if ($search_task_user == $user->id) $texthelp .= $langs->trans("MyTasksDesc"); +else +{ + if ($user->rights->projet->all->lire && !$socid) $texthelp .= $langs->trans("TasksOnProjectsDesc"); + else $texthelp .= $langs->trans("TasksOnProjectsPublicDesc"); @@ -771,11 +455,7 @@ -if ($search_all) { - $setupstring = ''; - foreach ($fieldstosearchall as $key => $val) { - $fieldstosearchall[$key] = $langs->trans($val); - $setupstring .= $key."=".$val.";"; - } - print ''."\n"; - print '
'.$langs->trans("FilterOnInto", $search_all).join(', ', $fieldstosearchall).'
'."\n"; -} - -$moreforfilter = ''; +if ($search_all) +{ + foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val); + print '
'.$langs->trans("FilterOnInto", $search_all).join(', ', $fieldstosearchall).'
'; +} + +$morehtmlfilter = ''; @@ -784 +464,2 @@ -if (isModEnabled('categorie') && $user->hasRight('categorie', 'lire')) { +if (!empty($conf->categorie->enabled)) +{ @@ -787,2 +468,2 @@ - $tmptitle = $langs->trans('ProjectCategories'); - $moreforfilter .= img_picto($tmptitle, 'category', 'class="pictofixedwidth"').$formother->select_categories('project', $search_categ, 'search_categ', 1, $tmptitle, 'maxwidth300'); + $moreforfilter .= $langs->trans('ProjectCategories').': '; + $moreforfilter .= $formother->select_categories('project', $search_categ, 'search_categ', 1, 'maxwidth300'); @@ -794 +475 @@ -$tmptitle = $langs->trans('ProjectsWithThisUserAsContact'); +$moreforfilter .= $langs->trans('ProjectsWithThisUserAsContact').' '; @@ -796,4 +477,2 @@ -if (!$user->hasRight('user', 'user', 'lire')) { - $includeonly = array($user->id); -} -$moreforfilter .= img_picto($tmptitle, 'user', 'class="pictofixedwidth"').$form->select_dolusers($search_project_user ? $search_project_user : '', 'search_project_user', $tmptitle, '', 0, $includeonly, '', 0, 0, 0, '', 0, '', 'maxwidth250'); +if (empty($user->rights->user->user->lire)) $includeonly = array($user->id); +$moreforfilter .= $form->select_dolusers($search_project_user ? $search_project_user : '', 'search_project_user', 1, '', 0, $includeonly, '', 0, 0, 0, '', 0, '', 'maxwidth200'); @@ -804 +483 @@ -$tmptitle = $langs->trans('TasksWithThisUserAsContact'); +$moreforfilter .= $langs->trans('TasksWithThisUserAsContact').': '; @@ -806,4 +485,2 @@ -if (!$user->hasRight('user', 'user', 'lire')) { - $includeonly = array($user->id); -} -$moreforfilter .= img_picto($tmptitle, 'user', 'class="pictofixedwidth"').$form->select_dolusers($search_task_user, 'search_task_user', $tmptitle, '', 0, $includeonly, '', 0, 0, 0, '', 0, '', 'maxwidth250'); +if (empty($user->rights->user->user->lire)) $includeonly = array($user->id); +$moreforfilter .= $form->select_dolusers($search_task_user, 'search_task_user', 1, '', 0, $includeonly, '', 0, 0, 0, '', 0, '', 'maxwidth200'); @@ -812,14 +489,2 @@ -// Filter on customer categories -if (getDolGlobalString('MAIN_SEARCH_CATEGORY_CUSTOMER_ON_TASK_LIST') && isModEnabled("categorie") && $user->hasRight('categorie', 'lire')) { - $moreforfilter .= '
'; - $tmptitle = $langs->transnoentities('CustomersProspectsCategoriesShort'); - $moreforfilter .= img_picto($tmptitle, 'category', 'class="pictofixedwidth"'); - $categoriesArr = $form->select_all_categories(Categorie::TYPE_CUSTOMER, '', '', 64, 0, 1); - $categoriesArr[-2] = '- '.$langs->trans('NotCategorized').' -'; - $moreforfilter .= Form::multiselectarray('search_category_customer_list', $categoriesArr, $searchCategoryCustomerList, 0, 0, 'minwidth300', 0, 0, '', 'category', $tmptitle); - $moreforfilter .= ' '; - $moreforfilter .= $form->textwithpicto('', $langs->trans('UseOrOperatorForCategories') . ' : ' . $tmptitle, 1, 'help', '', 0, 2, 'tooltip_cat_cus'); // Tooltip on click - $moreforfilter .= '
'; -} - -if (!empty($moreforfilter)) { +if (!empty($moreforfilter)) +{ @@ -829 +494 @@ - $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook @@ -834,5 +499,3 @@ -$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; -$selectedfields = ($mode != 'kanban' ? $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN', '')) : ''); // This also change content of $arrayfields -$selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : ''); - -print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table +if ($massactionbutton) $selectedfields .= $form->showCheckAddButtons('checkforselect', 1); + +print '
'; @@ -841,2 +503,0 @@ -// Fields title search -// -------------------------------------------------------------------- @@ -844,8 +505,2 @@ -// Action column -if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { - print ''; - $searchpicto = $form->showFilterButtons('left'); - print $searchpicto; - print ''; -} -if (!empty($arrayfields['t.fk_task_parent']['checked'])) { +if (!empty($arrayfields['t.fk_task_parent']['checked'])) +{ @@ -856 +511,2 @@ -if (!empty($arrayfields['t.ref']['checked'])) { +if (!empty($arrayfields['t.ref']['checked'])) +{ @@ -861 +517,2 @@ -if (!empty($arrayfields['t.label']['checked'])) { +if (!empty($arrayfields['t.label']['checked'])) +{ @@ -866,2 +523,3 @@ -// Task Description -if (!empty($arrayfields['t.description']['checked'])) { +//Task Description +if (!empty($arrayfields['t.description']['checked'])) +{ @@ -873,8 +531,6 @@ -if (!empty($arrayfields['t.dateo']['checked'])) { - print ''; - print '
'; - print $form->selectDate($search_date_start ? $search_date_start : -1, 'search_date_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From')); - print '
'; - print '
'; - print $form->selectDate($search_date_end ? $search_date_end : -1, 'search_date_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to')); - print '
'; +if (!empty($arrayfields['t.dateo']['checked'])) +{ + print ''; + if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ''; + print ''; + $formother->select_year($search_syear ? $search_syear : -1, 'search_syear', 1, 20, 5); @@ -884,13 +540,10 @@ -if (!empty($arrayfields['t.datee']['checked'])) { - print ''; - print '
'; - print $form->selectDate($search_datelimit_start ? $search_datelimit_start : -1, 'search_datelimit_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From')); - print '
'; - print '
'; - print $form->selectDate($search_datelimit_end ? $search_datelimit_end : -1, 'search_datelimit_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to')); - // TODO Add option late - //print '
'.$langs->trans("Alert"); - print '
'; - print ''; -} -if (!empty($arrayfields['p.ref']['checked'])) { +if (!empty($arrayfields['t.datee']['checked'])) +{ + print ''; + if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ''; + print ''; + $formother->select_year($search_eyear ? $search_eyear : -1, 'search_eyear', 1, 20, 5); + print ''; +} +if (!empty($arrayfields['p.ref']['checked'])) +{ @@ -901 +554,2 @@ -if (!empty($arrayfields['p.title']['checked'])) { +if (!empty($arrayfields['p.title']['checked'])) +{ @@ -906 +560,2 @@ -if (!empty($arrayfields['s.nom']['checked'])) { +if (!empty($arrayfields['s.nom']['checked'])) +{ @@ -911,6 +566,2 @@ -if (!empty($arrayfields['s.name_alias']['checked'])) { - print ''; - print ''; - print ''; -} -if (!empty($arrayfields['p.fk_statut']['checked'])) { +if (!empty($arrayfields['p.fk_statut']['checked'])) +{ @@ -919,3 +570 @@ - foreach ($projectstatic->labelStatusShort as $key => $val) { - $arrayofstatus[$key] = $langs->trans($val); - } + foreach ($projectstatic->statuts_short as $key => $val) $arrayofstatus[$key] = $langs->trans($val); @@ -926,31 +575,7 @@ -if (!empty($arrayfields['t.planned_workload']['checked'])) { - print ''; -} -if (!empty($arrayfields['t.duration_effective']['checked'])) { - print ''; -} -if (!empty($arrayfields['t.progress_calculated']['checked'])) { - print ''; -} -if (!empty($arrayfields['t.progress']['checked'])) { - print ''; - print ''; - print ''; -} - -if (!empty($arrayfields['t.progress_summary']['checked'])) { - print ''; -} - -if (!empty($arrayfields['t.budget_amount']['checked'])) { - print ''; - print ''; - print ''; -} - -if (!empty($arrayfields['t.tobill']['checked'])) { - print ''; -} -if (!empty($arrayfields['t.billed']['checked'])) { - print ''; -} +if (!empty($arrayfields['t.planned_workload']['checked'])) print ''; +if (!empty($arrayfields['t.duration_effective']['checked'])) print ''; +if (!empty($arrayfields['t.progress_calculated']['checked'])) print ''; +if (!empty($arrayfields['t.progress']['checked'])) print ''; +if (!empty($arrayfields['t.progress_summary']['checked'])) print ''; +if (!empty($arrayfields['t.tobill']['checked'])) print ''; +if (!empty($arrayfields['t.billed']['checked'])) print ''; @@ -961 +586 @@ -$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object, $action); // Note that $action and $object may have been modified by hook +$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook @@ -963 +588,2 @@ -if (!empty($arrayfields['t.datec']['checked'])) { +if (!empty($arrayfields['t.datec']['checked'])) +{ @@ -968 +594,2 @@ -if (!empty($arrayfields['t.tms']['checked'])) { +if (!empty($arrayfields['t.tms']['checked'])) +{ @@ -974,29 +601,6 @@ -if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { - print ''; - $searchpicto = $form->showFilterButtons(); - print $searchpicto; - print ''; -} -print ''."\n"; - -$totalarray = array( - 'nbfield' => 0, - 'val' => array( - 't.planned_workload' => 0, - 't.duration_effective' => 0, - 't.progress' => 0, - 't.budget_amount' => 0, - ), - 'totalplannedworkload' => 0, - 'totaldurationeffective' => 0, - 'totaldurationdeclared' => 0, - 'totaltobillfield' => 0, - 'totalbilledfield' => 0, - 'totalbudget_amountfield' => 0, - 'totalbudgetamount' => 0, - 'totaltobill' => 0, - 'totalbilled' => 0, -); - -// Fields title label -// -------------------------------------------------------------------- +print ''; +$searchpicto = $form->showFilterButtons(); +print $searchpicto; +print ''; +print "\n"; + @@ -1004,81 +608,17 @@ -// Action column -if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { - print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n"; - $totalarray['nbfield']++; -} -if (!empty($arrayfields['t.fk_task_parent']['checked'])) { - print_liste_field_titre($arrayfields['t.fk_task_parent']['label'], $_SERVER["PHP_SELF"], "t.fk_task_parent", "", $param, "", $sortfield, $sortorder); - $totalarray['nbfield']++; -} -if (!empty($arrayfields['t.ref']['checked'])) { - print_liste_field_titre($arrayfields['t.ref']['label'], $_SERVER["PHP_SELF"], "t.ref", "", $param, "", $sortfield, $sortorder); - $totalarray['nbfield']++; -} -if (!empty($arrayfields['t.label']['checked'])) { - print_liste_field_titre($arrayfields['t.label']['label'], $_SERVER["PHP_SELF"], "t.label", "", $param, "", $sortfield, $sortorder); - $totalarray['nbfield']++; -} -if (!empty($arrayfields['t.description']['checked'])) { - print_liste_field_titre($arrayfields['t.description']['label'], $_SERVER["PHP_SELF"], "t.description", "", $param, "", $sortfield, $sortorder); - $totalarray['nbfield']++; -} -if (!empty($arrayfields['t.dateo']['checked'])) { - print_liste_field_titre($arrayfields['t.dateo']['label'], $_SERVER["PHP_SELF"], "t.dateo", "", $param, '', $sortfield, $sortorder, 'center '); - $totalarray['nbfield']++; -} -if (!empty($arrayfields['t.datee']['checked'])) { - print_liste_field_titre($arrayfields['t.datee']['label'], $_SERVER["PHP_SELF"], "t.datee", "", $param, '', $sortfield, $sortorder, 'center '); - $totalarray['nbfield']++; -} -if (!empty($arrayfields['p.ref']['checked'])) { - print_liste_field_titre($arrayfields['p.ref']['label'], $_SERVER["PHP_SELF"], "p.ref", "", $param, "", $sortfield, $sortorder); - $totalarray['nbfield']++; -} -if (!empty($arrayfields['p.title']['checked'])) { - print_liste_field_titre($arrayfields['p.title']['label'], $_SERVER["PHP_SELF"], "p.title", "", $param, "", $sortfield, $sortorder); - $totalarray['nbfield']++; -} -if (!empty($arrayfields['s.nom']['checked'])) { - print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], "s.nom", "", $param, "", $sortfield, $sortorder); - $totalarray['nbfield']++; -} -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); - $totalarray['nbfield']++; -} -if (!empty($arrayfields['p.fk_statut']['checked'])) { - print_liste_field_titre($arrayfields['p.fk_statut']['label'], $_SERVER["PHP_SELF"], "p.fk_statut", "", $param, '', $sortfield, $sortorder, 'center '); - $totalarray['nbfield']++; -} -if (!empty($arrayfields['t.planned_workload']['checked'])) { - print_liste_field_titre($arrayfields['t.planned_workload']['label'], $_SERVER["PHP_SELF"], "t.planned_workload", "", $param, '', $sortfield, $sortorder, 'center '); - $totalarray['nbfield']++; -} -if (!empty($arrayfields['t.duration_effective']['checked'])) { - print_liste_field_titre($arrayfields['t.duration_effective']['label'], $_SERVER["PHP_SELF"], "t.duration_effective", "", $param, '', $sortfield, $sortorder, 'center '); - $totalarray['nbfield']++; -} -if (!empty($arrayfields['t.progress_calculated']['checked'])) { - print_liste_field_titre($arrayfields['t.progress_calculated']['label'], $_SERVER["PHP_SELF"], "", "", $param, '', '', '', 'center '); - $totalarray['nbfield']++; -} -if (!empty($arrayfields['t.progress']['checked'])) { - print_liste_field_titre($arrayfields['t.progress']['label'], $_SERVER["PHP_SELF"], "t.progress", "", $param, '', $sortfield, $sortorder, 'center '); - $totalarray['nbfield']++; -} -if (!empty($arrayfields['t.progress_summary']['checked'])) { - print_liste_field_titre($arrayfields['t.progress_summary']['label'], $_SERVER["PHP_SELF"], "t.progress", "", $param, '', $sortfield, $sortorder, 'center '); - $totalarray['nbfield']++; -} -if (!empty($arrayfields['t.budget_amount']['checked'])) { - print_liste_field_titre($arrayfields['t.budget_amount']['label'], $_SERVER["PHP_SELF"], "t.budget_amount", "", $param, '', $sortfield, $sortorder, 'center '); - $totalarray['nbfield']++; -} -if (!empty($arrayfields['t.tobill']['checked'])) { - print_liste_field_titre($arrayfields['t.tobill']['label'], $_SERVER["PHP_SELF"], "", "", $param, '', $sortfield, $sortorder, 'center '); - $totalarray['nbfield']++; -} -if (!empty($arrayfields['t.billed']['checked'])) { - print_liste_field_titre($arrayfields['t.billed']['label'], $_SERVER["PHP_SELF"], "", "", $param, '', $sortfield, $sortorder, 'center '); - $totalarray['nbfield']++; -} +if (!empty($arrayfields['t.fk_task_parent']['checked'])) print_liste_field_titre($arrayfields['t.fk_task_parent']['label'], $_SERVER["PHP_SELF"], "t.fk_task_parent", "", $param, "", $sortfield, $sortorder); +if (!empty($arrayfields['t.ref']['checked'])) print_liste_field_titre($arrayfields['t.ref']['label'], $_SERVER["PHP_SELF"], "t.ref", "", $param, "", $sortfield, $sortorder); +if (!empty($arrayfields['t.label']['checked'])) print_liste_field_titre($arrayfields['t.label']['label'], $_SERVER["PHP_SELF"], "t.label", "", $param, "", $sortfield, $sortorder); +if (!empty($arrayfields['t.description']['checked'])) print_liste_field_titre($arrayfields['t.description']['label'], $_SERVER["PHP_SELF"], "t.description", "", $param, "", $sortfield, $sortorder); +if (!empty($arrayfields['t.dateo']['checked'])) print_liste_field_titre($arrayfields['t.dateo']['label'], $_SERVER["PHP_SELF"], "t.dateo", "", $param, '', $sortfield, $sortorder, 'center '); +if (!empty($arrayfields['t.datee']['checked'])) print_liste_field_titre($arrayfields['t.datee']['label'], $_SERVER["PHP_SELF"], "t.datee", "", $param, '', $sortfield, $sortorder, 'center '); +if (!empty($arrayfields['p.ref']['checked'])) print_liste_field_titre($arrayfields['p.ref']['label'], $_SERVER["PHP_SELF"], "p.ref", "", $param, "", $sortfield, $sortorder); +if (!empty($arrayfields['p.title']['checked'])) print_liste_field_titre($arrayfields['p.title']['label'], $_SERVER["PHP_SELF"], "p.title", "", $param, "", $sortfield, $sortorder); +if (!empty($arrayfields['s.nom']['checked'])) print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], "s.nom", "", $param, "", $sortfield, $sortorder); +if (!empty($arrayfields['p.fk_statut']['checked'])) print_liste_field_titre($arrayfields['p.fk_statut']['label'], $_SERVER["PHP_SELF"], "p.fk_statut", "", $param, '', $sortfield, $sortorder, 'center '); +if (!empty($arrayfields['t.planned_workload']['checked'])) print_liste_field_titre($arrayfields['t.planned_workload']['label'], $_SERVER["PHP_SELF"], "t.planned_workload", "", $param, '', $sortfield, $sortorder, 'center '); +if (!empty($arrayfields['t.duration_effective']['checked'])) print_liste_field_titre($arrayfields['t.duration_effective']['label'], $_SERVER["PHP_SELF"], "t.duration_effective", "", $param, '', $sortfield, $sortorder, 'center '); +if (!empty($arrayfields['t.progress_calculated']['checked'])) print_liste_field_titre($arrayfields['t.progress_calculated']['label'], $_SERVER["PHP_SELF"], "", "", $param, '', '', '', 'center '); +if (!empty($arrayfields['t.progress']['checked'])) print_liste_field_titre($arrayfields['t.progress']['label'], $_SERVER["PHP_SELF"], "t.progress", "", $param, '', $sortfield, $sortorder, 'center '); +if (!empty($arrayfields['t.progress_summary']['checked'])) print_liste_field_titre($arrayfields['t.progress_summary']['label'], $_SERVER["PHP_SELF"], "t.progress", "", $param, '', $sortfield, $sortorder, 'center '); +if (!empty($arrayfields['t.tobill']['checked'])) print_liste_field_titre($arrayfields['t.tobill']['label'], $_SERVER["PHP_SELF"], "", "", $param, '', $sortfield, $sortorder, 'center '); +if (!empty($arrayfields['t.billed']['checked'])) print_liste_field_titre($arrayfields['t.billed']['label'], $_SERVER["PHP_SELF"], "", "", $param, '', $sortfield, $sortorder, 'center '); @@ -1088,8 +628,2 @@ -$parameters = array( - 'arrayfields' => $arrayfields, - 'param' => $param, - 'sortfield' => $sortfield, - 'sortorder' => $sortorder, - 'totalarray' => &$totalarray, -); -$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook +$parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder); +$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook @@ -1097,14 +631,5 @@ -if (!empty($arrayfields['t.datec']['checked'])) { - print_liste_field_titre($arrayfields['t.datec']['label'], $_SERVER["PHP_SELF"], "t.datec", "", $param, '', $sortfield, $sortorder, 'center nowrap '); - $totalarray['nbfield']++; -} -if (!empty($arrayfields['t.tms']['checked'])) { - print_liste_field_titre($arrayfields['t.tms']['label'], $_SERVER["PHP_SELF"], "t.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap '); - $totalarray['nbfield']++; -} -// Action column -if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { - print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n"; - $totalarray['nbfield']++; -} -print ''."\n"; +if (!empty($arrayfields['t.datec']['checked'])) print_liste_field_titre($arrayfields['t.datec']['label'], $_SERVER["PHP_SELF"], "t.datec", "", $param, '', $sortfield, $sortorder, 'center nowrap '); +if (!empty($arrayfields['t.tms']['checked'])) print_liste_field_titre($arrayfields['t.tms']['label'], $_SERVER["PHP_SELF"], "t.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap '); +print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch '); +print "\n"; + @@ -1114,9 +639,3 @@ -if (getDolGlobalString('PROJECT_PLANNED_WORKLOAD_FORMAT')) { - $plannedworkloadoutputformat = $conf->global->PROJECT_PLANNED_WORKLOAD_FORMAT; -} -if (getDolGlobalString('PROJECT_TIMES_SPENT_FORMAT')) { - $timespentoutputformat = $conf->global->PROJECT_TIME_SPENT_FORMAT; -} - -// Loop on record -// -------------------------------------------------------------------- +if (!empty($conf->global->PROJECT_PLANNED_WORKLOAD_FORMAT)) $plannedworkloadoutputformat = $conf->global->PROJECT_PLANNED_WORKLOAD_FORMAT; +if (!empty($conf->global->PROJECT_TIMES_SPENT_FORMAT)) $timespentoutputformat = $conf->global->PROJECT_TIME_SPENT_FORMAT; + @@ -1124 +642,0 @@ -$savnbfield = $totalarray['nbfield']; @@ -1126,3 +644,2 @@ -$totalarray['nbfield'] = 0; -$imaxinloop = ($limit ? min($num, $limit) : $num); -while ($i < $imaxinloop) { +while ($i < min($num, $limit)) +{ @@ -1130,5 +647 @@ - if (empty($obj)) { - break; // Should not happen - } - - // Store properties in $object + @@ -1141,2 +654 @@ - $object->budget_amount = $obj->budget_amount; - $object->date_start = $db->jdate($obj->date_start); + $object->datee = $db->jdate($obj->date_end); // deprecated @@ -1144,3 +656,4 @@ - $object->planned_workload = $obj->planned_workload; - $object->duration_effective = $obj->duration_effective; - $object->fk_task_parent = $obj->fk_task_parent; + $object->planned_workload = $obj->planned_workload; + $object->duration_effective = $obj->duration_effective; + $object->fk_task_parent = $obj->fk_task_parent; + @@ -1155,47 +668,17 @@ - if ($obj->socid) { - $socstatic->id = $obj->socid; - $socstatic->name = $obj->name; - $socstatic->name_alias = $obj->alias; - } - if ($mode == 'kanban') { - if ($i == 0) { - print ''; - print '
'; - } - // Output Kanban - if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined - $selected = 0; - if (in_array($object->id, $arrayofselected)) { - $selected = 1; - } - } - - $arraydata = array(); - $arraydata['projectlink'] = $projectstatic->getNomUrl(1); - $arraydata['selected'] = in_array($object->id, $arrayofselected); - - print $object->getKanbanView('', $arraydata); - if ($i == ($imaxinloop - 1)) { - print '
'; - print ''; - } - } else { - $userAccess = $projectstatic->restrictedProjectArea($user); // why this ? - if ($userAccess >= 0) { - // Show here line of result - $j = 0; - print ''; - - // Action column - if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { - print ''; - if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined - $selected = 0; - if (in_array($object->id, $arrayofselected)) { - $selected = 1; - } - print ''; - } - print ''; - if (!$i) { - $totalarray['nbfield']++; + $userAccess = $projectstatic->restrictedProjectArea($user); // why this ? + if ($userAccess >= 0) + { + print ''; + + // Ref Parent + if (!empty($arrayfields['t.fk_task_parent']['checked'])) { + print ''; + if (!empty($object->fk_task_parent)) { + $object_parent = new Task($db); + $result = $object_parent->fetch($object->fk_task_parent); + if ($result < 0) { + setEventMessage($object_parent->error, 'errors'); + } else { + print $object_parent->getNomUrl(1, 'withproject'); + if ($object_parent->hasDelay()) + print img_warning("Late"); @@ -1204,19 +687,70 @@ - // Ref Parent - if (!empty($arrayfields['t.fk_task_parent']['checked'])) { - print ''; - if (!empty($object->fk_task_parent)) { - $object_parent = new Task($db); - $result = $object_parent->fetch($object->fk_task_parent); - if ($result < 0) { - setEventMessage($object_parent->error, 'errors'); - } else { - print $object_parent->getNomUrl(1, 'withproject'); - if ($object_parent->hasDelay()) { - print img_warning("Late"); - } - } - } - print ''; - if (!$i) { - $totalarray['nbfield']++; - } + print ''; + if (!$i) $totalarray['nbfield']++; + } + // Ref + if (!empty($arrayfields['t.ref']['checked'])) + { + print ''; + print $object->getNomUrl(1, 'withproject'); + if ($object->hasDelay()) print img_warning("Late"); + print ''; + if (!$i) $totalarray['nbfield']++; + } + // Label + if (!empty($arrayfields['t.label']['checked'])) + { + print ''; + print $object->label; + print ''; + if (!$i) $totalarray['nbfield']++; + } + // Description + if (!empty($arrayfields['t.description']['checked'])) + { + print ''; + print $object->description; + print ''; + if (!$i) $totalarray['nbfield']++; + } + // Date start + if (!empty($arrayfields['t.dateo']['checked'])) + { + print ''; + print dol_print_date($db->jdate($obj->date_start), 'day'); + print ''; + if (!$i) $totalarray['nbfield']++; + } + // Date end + if (!empty($arrayfields['t.datee']['checked'])) + { + print ''; + print dol_print_date($db->jdate($obj->date_end), 'day'); + print ''; + if (!$i) $totalarray['nbfield']++; + } + // Project ref + if (!empty($arrayfields['p.ref']['checked'])) + { + print ''; + print $projectstatic->getNomUrl(1, 'task'); + if ($projectstatic->hasDelay()) print img_warning("Late"); + print ''; + if (!$i) $totalarray['nbfield']++; + } + // Project title + if (!empty($arrayfields['p.title']['checked'])) + { + print ''; + print dol_trunc($obj->projecttitle, 80); + print ''; + if (!$i) $totalarray['nbfield']++; + } + // Third party + if (!empty($arrayfields['s.nom']['checked'])) + { + print ''; + if ($obj->socid) + { + $socstatic->id = $obj->socid; + $socstatic->name = $obj->name; + print $socstatic->getNomUrl(1); @@ -1224,11 +758,3 @@ - // Ref - if (!empty($arrayfields['t.ref']['checked'])) { - print ''; - print $object->getNomUrl(1, 'withproject'); - if ($object->hasDelay()) { - print img_warning("Late"); - } - print ''; - if (!$i) { - $totalarray['nbfield']++; - } + else + { + print ' '; @@ -1236,8 +762,23 @@ - // Label - if (!empty($arrayfields['t.label']['checked'])) { - print ''; - print dol_escape_htmltag($object->label); - print ''; - if (!$i) { - $totalarray['nbfield']++; - } + print ''; + if (!$i) $totalarray['nbfield']++; + } + // Project status + if (!empty($arrayfields['p.fk_statut']['checked'])) + { + print ''; + print $projectstatic->getLibStatut(1); + print ''; + if (!$i) $totalarray['nbfield']++; + } + + // Planned workload + if (!empty($arrayfields['t.planned_workload']['checked'])) + { + print ''; + $fullhour = convertSecondToTime($obj->planned_workload, $plannedworkloadoutputformat); + $workingdelay = convertSecondToTime($obj->planned_workload, 'all', 86400, 7); // TODO Replace 86400 and 7 to take account working hours per day and working day per weeks + if ($obj->planned_workload != '') + { + print $fullhour; + // TODO Add delay taking account of working hours per day and working day per week + //if ($workingdelay != $fullhour) print '
('.$workingdelay.')'; @@ -1245,8 +786,34 @@ - // Description - if (!empty($arrayfields['t.description']['checked'])) { - print ''; - print dolGetFirstLineOfText($object->description, 5); - print ''; - if (!$i) { - $totalarray['nbfield']++; - } + //else print '--:--'; + print ''; + if (!$i) $totalarray['nbfield']++; + if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 't.planned_workload'; + $totalarray['val']['t.planned_workload'] += $obj->planned_workload; + if (!$i) $totalarray['totalplannedworkloadfield'] = $totalarray['nbfield']; + $totalarray['totalplannedworkload'] += $obj->planned_workload; + } + // Time spent + if (!empty($arrayfields['t.duration_effective']['checked'])) + { + $showlineingray = 0; $showproject = 1; + print ''; + if ($showlineingray) print ''; + else print ''; + if ($obj->duration_effective) print convertSecondToTime($obj->duration_effective, $timespentoutputformat); + else print '--:--'; + if ($showlineingray) print ''; + else print ''; + print ''; + if (!$i) $totalarray['nbfield']++; + if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 't.duration_effective'; + $totalarray['val']['t.duration_effective'] += $obj->duration_effective; + if (!$i) $totalarray['totaldurationeffectivefield'] = $totalarray['nbfield']; + $totalarray['totaldurationeffective'] += $obj->duration_effective; + } + // Calculated progress + if (!empty($arrayfields['t.progress_calculated']['checked'])) + { + print ''; + if ($obj->planned_workload || $obj->duration_effective) + { + if ($obj->planned_workload) print round(100 * $obj->duration_effective / $obj->planned_workload, 2).' %'; + else print $form->textwithpicto('', $langs->trans('WorkloadNotDefined'), 1, 'help'); @@ -1254,9 +821,11 @@ - - // Date start project - if (!empty($arrayfields['t.dateo']['checked'])) { - print ''; - print dol_print_date($db->jdate($obj->date_start), 'day'); - print ''; - if (!$i) { - $totalarray['nbfield']++; - } + print ''; + if (!$i) $totalarray['nbfield']++; + if (!$i) $totalarray['totalprogress_calculatedfield'] = $totalarray['nbfield']; + } + // Declared progress + if (!empty($arrayfields['t.progress']['checked'])) + { + print ''; + if ($obj->progress != '') + { + print getTaskProgressBadge($object); @@ -1264,301 +833,96 @@ - // Date end project - if (!empty($arrayfields['t.datee']['checked'])) { - print ''; - print dol_print_date($db->jdate($obj->date_end), 'day'); - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Project ref - if (!empty($arrayfields['p.ref']['checked'])) { - print ''; - print $projectstatic->getNomUrl(1, 'task'); - if ($projectstatic->hasDelay()) { - print img_warning("Late"); - } - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Project title - if (!empty($arrayfields['p.title']['checked'])) { - print ''; - print dol_escape_htmltag($obj->projecttitle); - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Third party - if (!empty($arrayfields['s.nom']['checked'])) { - print ''; - if ($obj->socid) { - print $socstatic->getNomUrl(1, '', 0, 0, -1, empty($arrayfields['s.name_alias']['checked']) ? 0 : 1); - } else { - print ' '; - } - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Alias - if (!empty($arrayfields['s.name_alias']['checked'])) { - $name_alias = ''; - if ($obj->socid) { - $name_alias = $socstatic->name_alias; - } - print ''; - print dol_escape_htmltag($name_alias); - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Project status - if (!empty($arrayfields['p.fk_statut']['checked'])) { - print ''; - print $projectstatic->getLibStatut(1); - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Planned workload - if (!empty($arrayfields['t.planned_workload']['checked'])) { - print ''; - $fullhour = convertSecondToTime($obj->planned_workload, $plannedworkloadoutputformat); - $workingdelay = convertSecondToTime($obj->planned_workload, 'all', 86400, 7); // TODO Replace 86400 and 7 to take account working hours per day and working day per weeks - if ($obj->planned_workload != '') { - print $fullhour; - // TODO Add delay taking account of working hours per day and working day per week - //if ($workingdelay != $fullhour) print '
('.$workingdelay.')'; - } - //else print '--:--'; - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - if (!$i) { - $totalarray['pos'][$totalarray['nbfield']] = 't.planned_workload'; - } - if (!isset($totalarray['val']['planned_workload'])) { - $totalarray['val']['t.planned_workload'] = 0; - } - $totalarray['val']['t.planned_workload'] += $obj->planned_workload; - if (!$i) { - $totalarray['totalplannedworkloadfield'] = $totalarray['nbfield']; - } - if (!isset($totalarray['totalplannedworkload'])) { - $totalarray['totalplannedworkload'] = 0; - } - $totalarray['totalplannedworkload'] += $obj->planned_workload; - } - // Time spent - if (!empty($arrayfields['t.duration_effective']['checked'])) { - $showlineingray = 0; - $showproject = 1; - print ''; - if ($showlineingray) { - print ''; - } else { - print ''; - } - if ($obj->duration_effective) { - print convertSecondToTime($obj->duration_effective, $timespentoutputformat); - } else { - print '--:--'; - } - if ($showlineingray) { - print ''; - } else { - print ''; - } - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - if (!$i) { - $totalarray['pos'][$totalarray['nbfield']] = 't.duration_effective'; - } - if (!isset($totalarray['val']['t.duration_effective'])) { - $totalarray['val']['t.duration_effective'] = 0; - } - $totalarray['val']['t.duration_effective'] += $obj->duration_effective; - if (!$i) { - $totalarray['totaldurationeffectivefield'] = $totalarray['nbfield']; - } - if (!isset($totalarray['totaldurationeffective'])) { - $totalarray['totaldurationeffective'] = 0; - } - $totalarray['totaldurationeffective'] += $obj->duration_effective; - } - // Calculated progress - if (!empty($arrayfields['t.progress_calculated']['checked'])) { - print ''; - if ($obj->planned_workload || $obj->duration_effective) { - if ($obj->planned_workload) { - print round(100 * $obj->duration_effective / $obj->planned_workload, 2).' %'; - } else { - print $form->textwithpicto('', $langs->trans('WorkloadNotDefined'), 1, 'help'); - } - } - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - if (!$i) { - $totalarray['totalprogress_calculatedfield'] = $totalarray['nbfield']; - } - } - // Declared progress - if (!empty($arrayfields['t.progress']['checked'])) { - print ''; - if ($obj->progress != '') { - print getTaskProgressBadge($object); - } - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - if (!$i) { - $totalarray['pos'][$totalarray['nbfield']] = 't.progress'; - } - if (!isset($totalarray['val']['t.progress'])) { - $totalarray['val']['t.progress'] = 0; - } - $totalarray['val']['t.progress'] += ($obj->planned_workload * $obj->progress / 100); - if (!$i) { - $totalarray['totalprogress_declaredfield'] = $totalarray['nbfield']; - } - if (!isset($totalarray['totaldurationdeclared'])) { - $totalarray['totaldurationdeclared'] = 0; - } - $totalarray['totaldurationdeclared'] += $obj->planned_workload * $obj->progress / 100; - } - // Progress summary - if (!empty($arrayfields['t.progress_summary']['checked'])) { - print ''; - if ($obj->progress != '' && $obj->duration_effective) { - print getTaskProgressView($object, false, false); - } - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - if (!$i) { - $totalarray['totalprogress_summary'] = $totalarray['nbfield']; - } - } - // Budget for task - if (!empty($arrayfields['t.budget_amount']['checked'])) { - print ''; - if ($object->budget_amount) { - print ''.price($object->budget_amount, 0, $langs, 1, 0, 0, $conf->currency).''; - } - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - if (!$i) { - $totalarray['pos'][$totalarray['nbfield']] = 't.budget_amount'; - } - $totalarray['val']['t.budget_amount'] += $obj->budget_amount; - if (!$i) { - $totalarray['totalbudget_amountfield'] = $totalarray['nbfield']; - } - $totalarray['totalbudgetamount'] += $obj->budget_amount; - } - // Time not billed - if (!empty($arrayfields['t.tobill']['checked'])) { - print ''; - if ($obj->usage_bill_time) { - print convertSecondToTime($obj->tobill, 'allhourmin'); - $totalarray['val']['t.tobill'] += $obj->tobill; - $totalarray['totaltobill'] += $obj->tobill; - } else { - print ''.$langs->trans("NA").''; - } - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - if (!$i) { - $totalarray['pos'][$totalarray['nbfield']] = 't.tobill'; - } - if (!$i) { - $totalarray['totaltobillfield'] = $totalarray['nbfield']; - } - } - // Time billed - if (!empty($arrayfields['t.billed']['checked'])) { - print ''; - if ($obj->usage_bill_time) { - print convertSecondToTime($obj->billed, 'allhourmin'); - $totalarray['val']['t.billed'] += $obj->billed; - $totalarray['totalbilled'] += $obj->billed; - } else { - print ''.$langs->trans("NA").''; - } - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - if (!$i) { - $totalarray['pos'][$totalarray['nbfield']] = 't.billed'; - } - if (!$i) { - $totalarray['totalbilledfield'] = $totalarray['nbfield']; - } - } - // Extra fields - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; - // Fields from hook - $parameters = array('arrayfields'=>$arrayfields, 'object'=>$object, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray); - $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - // Date creation - if (!empty($arrayfields['t.datec']['checked'])) { - print ''; - print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser'); - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Date modification - if (!empty($arrayfields['t.tms']['checked'])) { - print ''; - print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser'); - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Status - /*if (!empty($arrayfields['p.fk_statut']['checked'])) - { - $projectstatic->statut = $obj->fk_statut; - print ''.$projectstatic->getLibStatut(5).''; - }*/ - // Action column - if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { - print ''; - if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined - $selected = 0; - if (in_array($object->id, $arrayofselected)) { - $selected = 1; - } - print ''; - } - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - print ''."\n"; - } + print ''; + if (!$i) $totalarray['nbfield']++; + if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 't.progress'; + $totalarray['val']['t.progress'] += ($obj->planned_workload * $obj->progress / 100); + if (!$i) $totalarray['totalprogress_declaredfield'] = $totalarray['nbfield']; + $totalarray['totaldurationdeclared'] += $obj->planned_workload * $obj->progress / 100; + } + // Progress summary + if (!empty($arrayfields['t.progress_summary']['checked'])) + { + print ''; + if ($obj->progress != '' && $obj->duration_effective) { + print getTaskProgressView($object, false, false); + } + print ''; + if (!$i) $totalarray['nbfield']++; + if (!$i) $totalarray['totalprogress_summary'] = $totalarray['nbfield']; + } + // Time not billed + if (!empty($arrayfields['t.tobill']['checked'])) + { + print ''; + if ($obj->usage_bill_time) + { + print convertSecondToTime($obj->tobill, 'allhourmin'); + $totalarray['val']['t.tobill'] += $obj->tobill; + $totalarray['totaltobill'] += $obj->tobill; + } + else + { + print ''.$langs->trans("NA").''; + } + print ''; + if (!$i) $totalarray['nbfield']++; + if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 't.tobill'; + if (!$i) $totalarray['totaltobillfield'] = $totalarray['nbfield']; + } + // Time billed + if (!empty($arrayfields['t.billed']['checked'])) + { + print ''; + if ($obj->usage_bill_time) + { + print convertSecondToTime($obj->billed, 'allhourmin'); + $totalarray['val']['t.billed'] += $obj->billed; + $totalarray['totalbilled'] += $obj->billed; + } + else + { + print ''.$langs->trans("NA").''; + } + print ''; + if (!$i) $totalarray['nbfield']++; + if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 't.billed'; + if (!$i) $totalarray['totalbilledfield'] = $totalarray['nbfield']; + } + // Extra fields + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; + // Fields from hook + $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray); + $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + // Date creation + if (!empty($arrayfields['t.datec']['checked'])) + { + print ''; + print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser'); + print ''; + if (!$i) $totalarray['nbfield']++; + } + // Date modification + if (!empty($arrayfields['t.tms']['checked'])) + { + print ''; + print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser'); + print ''; + if (!$i) $totalarray['nbfield']++; + } + // Status + /*if (! empty($arrayfields['p.fk_statut']['checked'])) + { + $projectstatic->statut = $obj->fk_statut; + print ''.$projectstatic->getLibStatut(5).''; + }*/ + // Action column + print ''; + if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined + { + $selected = 0; + if (in_array($obj->id, $arrayofselected)) $selected = 1; + print ''; + } + print ''; + if (!$i) $totalarray['nbfield']++; + + print "\n"; @@ -1569 +932,0 @@ - @@ -1571,7 +933,0 @@ -if (!empty($totalarray['totalizable']) && is_array($totalarray['totalizable'])) { - foreach ($totalarray['totalizable'] as $keytotalizable => $valtotalizable) { - $totalarray['pos'][$valtotalizable['pos']] = $keytotalizable; - $totalarray['val'][$keytotalizable] = $valtotalizable['total']; - } -} - @@ -1579 +935,2 @@ - || isset($totalarray['totaltobill']) || isset($totalarray['totalbilled']) || isset($totalarray['totalbudget'])) { + || isset($totalarray['totaltobill']) || isset($totalarray['totalbilled'])) +{ @@ -1582 +939,2 @@ - while ($i < $totalarray['nbfield']) { + while ($i < $totalarray['nbfield']) + { @@ -1584,31 +942,12 @@ - if ($i == 1) { - if ($num < $limit && empty($offset)) { - print ''.$langs->trans("Total").''; - } else { - print ''.$langs->trans("Totalforthispage").''; - } - } elseif (isset($totalarray['totalplannedworkloadfield']) && $totalarray['totalplannedworkloadfield'] == $i) { - print ''.convertSecondToTime($totalarray['totalplannedworkload'], $plannedworkloadoutputformat).''; - } elseif (isset($totalarray['totaldurationeffectivefield']) && $totalarray['totaldurationeffectivefield'] == $i) { - print ''.convertSecondToTime($totalarray['totaldurationeffective'], $timespentoutputformat).''; - } elseif (isset($totalarray['totalprogress_calculatedfield']) && $totalarray['totalprogress_calculatedfield'] == $i) { - print ''.($totalarray['totalplannedworkload'] > 0 ? round(100 * $totalarray['totaldurationeffective'] / $totalarray['totalplannedworkload'], 2).' %' : '').''; - } elseif (isset($totalarray['totalprogress_declaredfield']) && $totalarray['totalprogress_declaredfield'] == $i) { - print ''.($totalarray['totalplannedworkload'] > 0 ? round(100 * $totalarray['totaldurationdeclared'] / $totalarray['totalplannedworkload'], 2).' %' : '').''; - } elseif (isset($totalarray['totaltobillfield']) && $totalarray['totaltobillfield'] == $i) { - print ''.convertSecondToTime($totalarray['totaltobill'], $plannedworkloadoutputformat).''; - } elseif (isset($totalarray['totalbilledfield']) && $totalarray['totalbilledfield'] == $i) { - print ''.convertSecondToTime($totalarray['totalbilled'], $plannedworkloadoutputformat).''; - } elseif (isset($totalarray['totalbudget_amountfield']) && $totalarray['totalbudget_amountfield'] == $i) { - print ''.price($totalarray['totalbudgetamount'], 0, $langs, 1, 0, 0, $conf->currency).''; - } elseif (!empty($totalarray['pos'][$i])) { - print ''; - if (isset($totalarray['type']) && $totalarray['type'][$i] == 'duration') { - print(!empty($totalarray['val'][$totalarray['pos'][$i]]) ? convertSecondToTime($totalarray['val'][$totalarray['pos'][$i]], 'allhourmin') : 0); - } else { - print price(!empty($totalarray['val'][$totalarray['pos'][$i]]) ? $totalarray['val'][$totalarray['pos'][$i]] : 0); - } - print ''; - } else { - print ''; - } + if ($i == 1) + { + if ($num < $limit && empty($offset)) print ''.$langs->trans("Total").''; + else print ''.$langs->trans("Totalforthispage").''; + } + elseif ($totalarray['totalplannedworkloadfield'] == $i) print ''.convertSecondToTime($totalarray['totalplannedworkload'], $plannedworkloadoutputformat).''; + elseif ($totalarray['totaldurationeffectivefield'] == $i) print ''.convertSecondToTime($totalarray['totaldurationeffective'], $timespentoutputformat).''; + elseif ($totalarray['totalprogress_calculatedfield'] == $i) print ''.($totalarray['totalplannedworkload'] > 0 ? round(100 * $totalarray['totaldurationeffective'] / $totalarray['totalplannedworkload'], 2).' %' : '').''; + elseif ($totalarray['totalprogress_declaredfield'] == $i) print ''.($totalarray['totalplannedworkload'] > 0 ? round(100 * $totalarray['totaldurationdeclared'] / $totalarray['totalplannedworkload'], 2).' %' : '').''; + elseif ($totalarray['totaltobillfield'] == $i) print ''.convertSecondToTime($totalarray['totaltobill'], $plannedworkloadoutputformat).''; + elseif ($totalarray['totalbilledfield'] == $i) print ''.convertSecondToTime($totalarray['totalbilled'], $plannedworkloadoutputformat).''; + else print ''; @@ -1621,2 +960,2 @@ -$parameters = array('arrayfields'=>$arrayfields, 'sql' => $sql); -$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object, $action); // Note that $action and $object may have been modified by hook +$parameters = array('sql' => $sql); +$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters); // Note that $action and $object may have been modified by hook @@ -1625,4 +964,4 @@ -print ''."\n"; -print '
'."\n"; - -print ''."\n"; +print ""; +print '
'; + +print ''; --- /tmp/dsg/dolibarr/htdocs/projet/tasks/github_19.0.3_note.php +++ /tmp/dsg/dolibarr/htdocs/projet/tasks/client_note.php @@ -32 +32 @@ -$action = GETPOST('action', 'aZ09'); +$action = GETPOST('action', 'alpha'); @@ -34 +34 @@ -$mine = GETPOST('mode') == 'mine' ? 1 : 0; +$mine = $_REQUEST['mode'] == 'mine' ? 1 : 0; @@ -44,6 +44,2 @@ -if (!$user->hasRight('projet', 'lire')) { - accessforbidden(); -} - -$hookmanager->initHooks(array('projettasknote')); - +if (!$user->rights->projet->lire) accessforbidden(); +//$result = restrictedArea($user, 'projet', $id, '', 'task'); // TODO ameliorer la verification @@ -54,5 +50,5 @@ -if ($id > 0 || !empty($ref)) { - if ($object->fetch($id, $ref) > 0) { - if (getDolGlobalString('PROJECT_ALLOW_COMMENT_ON_TASK') && method_exists($object, 'fetchComments') && empty($object->comments)) { - $object->fetchComments(); - } +if ($id > 0 || !empty($ref)) +{ + if ($object->fetch($id, $ref) > 0) + { + if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_TASK) && method_exists($object, 'fetchComments') && empty($object->comments)) $object->fetchComments(); @@ -60,6 +56,2 @@ - if (getDolGlobalString('PROJECT_ALLOW_COMMENT_ON_PROJECT') && method_exists($projectstatic, 'fetchComments') && empty($projectstatic->comments)) { - $projectstatic->fetchComments(); - } - if (!empty($projectstatic->socid)) { - $projectstatic->fetch_thirdparty(); - } + if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($projectstatic, 'fetchComments') && empty($projectstatic->comments)) $projectstatic->fetchComments(); + if (!empty($projectstatic->socid)) $projectstatic->fetch_thirdparty(); @@ -68 +60,3 @@ - } else { + } + else + { @@ -74,3 +68,5 @@ -// Retrieve First Task ID of Project if withprojet is on to allow project prev next to work -if (!empty($project_ref) && !empty($withproject)) { - if ($projectstatic->fetch(0, $project_ref) > 0) { +// Retreive First Task ID of Project if withprojet is on to allow project prev next to work +if (!empty($project_ref) && !empty($withproject)) +{ + if ($projectstatic->fetch(0, $project_ref) > 0) + { @@ -78 +74,2 @@ - if (count($tasksarray) > 0) { + if (count($tasksarray) > 0) + { @@ -81 +78,3 @@ - } else { + } + else + { @@ -87,8 +86 @@ -if ($id > 0 || $ref) { - $object->fetch($id, $ref); -} - -//$result = restrictedArea($user, 'projet', $id, '', 'task'); // TODO ameliorer la verification -restrictedArea($user, 'projet', $object->fk_project, 'projet&project'); - -$permissionnote = ($user->hasRight('projet', 'creer') || $user->hasRight('projet', 'all', 'creer')); +$permissionnote = ($user->rights->projet->creer || $user->rights->projet->all->creer); @@ -101,8 +93 @@ -$parameters = array(); -$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks -if ($reshook < 0) { - setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); -} -if (empty($reshook)) { - include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not include_once -} +include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; @@ -113,0 +99,3 @@ + +llxHeader('', $langs->trans("Task")); + @@ -119,9 +107,2 @@ -$title = $object->ref . ' - ' . $langs->trans("Notes"); -if (!empty($withproject)) { - $title .= ' | ' . $langs->trans("Project") . (!empty($projectstatic->ref) ? ': '.$projectstatic->ref : '') ; -} -$help_url = ''; - -llxHeader('', $title, $help_url); - -if ($object->id > 0) { +if ($object->id > 0) +{ @@ -130 +111,2 @@ - if (!empty($withproject)) { + if (!empty($withproject)) + { @@ -134,3 +116,3 @@ - print dol_get_fiche_head($head, $tab, $langs->trans("Project"), -1, ($projectstatic->public ? 'projectpub' : 'project')); - - $param = (isset($mode) && $mode == 'mine' ? '&mode=mine' : ''); + dol_fiche_head($head, $tab, $langs->trans("Project"), -1, ($projectstatic->public ? 'projectpub' : 'project')); + + $param = ($mode == 'mine' ? '&mode=mine' : ''); @@ -145,2 +127,3 @@ - if (isset($projectstatic->thirdparty->id) && $projectstatic->thirdparty->id > 0) { - $morehtmlref .= '
'.$projectstatic->thirdparty->getNomUrl(1, 'project'); + if ($projectstatic->thirdparty->id > 0) + { + $morehtmlref .= '
'.$langs->trans('ThirdParty').' : '.$projectstatic->thirdparty->getNomUrl(1, 'project'); @@ -151,3 +134,4 @@ - if (!$user->hasRight('projet', 'all', 'lire')) { - $objectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 0); - $projectstatic->next_prev_filter = "rowid IN (".$db->sanitize(count($objectsListId) ? join(',', array_keys($objectsListId)) : '0').")"; + if (!$user->rights->projet->all->lire) + { + $objectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 0); + $projectstatic->next_prev_filter = " rowid in (".(count($objectsListId) ?join(',', array_keys($objectsListId)) : '0').")"; @@ -165,30 +149,26 @@ - if (getDolGlobalString('PROJECT_USE_OPPORTUNITIES') || !getDolGlobalString('PROJECT_HIDE_TASKS') || isModEnabled('eventorganization')) { - print ''; - print $langs->trans("Usage"); - print ''; - print ''; - if (getDolGlobalString('PROJECT_USE_OPPORTUNITIES')) { - print 'usage_opportunity ? ' checked="checked"' : '')).'"> '; - $htmltext = $langs->trans("ProjectFollowOpportunity"); - print $form->textwithpicto($langs->trans("ProjectFollowOpportunity"), $htmltext); - print '
'; - } - if (!getDolGlobalString('PROJECT_HIDE_TASKS')) { - print 'usage_task ? ' checked="checked"' : '')).'"> '; - $htmltext = $langs->trans("ProjectFollowTasks"); - print $form->textwithpicto($langs->trans("ProjectFollowTasks"), $htmltext); - print '
'; - } - if (!getDolGlobalString('PROJECT_HIDE_TASKS') && getDolGlobalString('PROJECT_BILL_TIME_SPENT')) { - print 'usage_bill_time ? ' checked="checked"' : '')).'"> '; - $htmltext = $langs->trans("ProjectBillTimeDescription"); - print $form->textwithpicto($langs->trans("BillTime"), $htmltext); - print '
'; - } - if (isModEnabled('eventorganization')) { - print 'usage_organize_event ? ' checked="checked"' : '')).'"> '; - $htmltext = $langs->trans("EventOrganizationDescriptionLong"); - print $form->textwithpicto($langs->trans("ManageOrganizeEvent"), $htmltext); - } - print ''; - } + print ''; + print $langs->trans("Usage"); + print ''; + print ''; + if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) + { + print 'usage_opportunity ? ' checked="checked"' : '')).'"> '; + $htmltext = $langs->trans("ProjectFollowOpportunity"); + print $form->textwithpicto($langs->trans("ProjectFollowOpportunity"), $htmltext); + print '
'; + } + if (empty($conf->global->PROJECT_HIDE_TASKS)) + { + print 'usage_task ? ' checked="checked"' : '')).'"> '; + $htmltext = $langs->trans("ProjectFollowTasks"); + print $form->textwithpicto($langs->trans("ProjectFollowTasks"), $htmltext); + print '
'; + } + if (!empty($conf->global->PROJECT_BILL_TIME_SPENT)) + { + print 'usage_bill_time ? ' checked="checked"' : '')).'"> '; + $htmltext = $langs->trans("ProjectBillTimeDescription"); + print $form->textwithpicto($langs->trans("BillTime"), $htmltext); + print '
'; + } + print ''; @@ -198,7 +178,12 @@ - if ($projectstatic->public) { - print img_picto($langs->trans('SharedProject'), 'world', 'class="paddingrightonly"'); - print $langs->trans('SharedProject'); - } else { - print img_picto($langs->trans('PrivateProject'), 'private', 'class="paddingrightonly"'); - print $langs->trans('PrivateProject'); - } + if ($projectstatic->public) print $langs->trans('SharedProject'); + else print $langs->trans('PrivateProject'); + print ''; + + // Date start - end + print ''.$langs->trans("DateStart").' - '.$langs->trans("DateEnd").''; + $start = dol_print_date($projectstatic->date_start, 'day'); + print ($start ? $start : '?'); + $end = dol_print_date($projectstatic->date_end, 'day'); + print ' - '; + print ($end ? $end : '?'); + if ($projectstatic->hasDelay()) print img_warning("Late"); @@ -209,15 +194 @@ - if (strcmp($projectstatic->budget_amount, '')) { - print price($projectstatic->budget_amount, '', $langs, 1, 0, 0, $conf->currency); - } - print ''; - - // Date start - end project - print ''.$langs->trans("Dates").''; - $start = dol_print_date($projectstatic->date_start, 'day'); - print($start ? $start : '?'); - $end = dol_print_date($projectstatic->date_end, 'day'); - print ' - '; - print($end ? $end : '?'); - if ($projectstatic->hasDelay()) { - print img_warning("Late"); - } + if (strcmp($projectstatic->budget_amount, '')) print price($projectstatic->budget_amount, '', $langs, 1, 0, 0, $conf->currency); @@ -233,0 +205 @@ + print '
'; @@ -244,4 +216,4 @@ - if (isModEnabled('categorie')) { - print ''.$langs->trans("Categories").''; - print $form->showCategories($projectstatic->id, 'project', 1); - print ""; + if ($conf->categorie->enabled) { + print ''.$langs->trans("Categories").''; + print $form->showCategories($projectstatic->id, 'project', 1); + print ""; @@ -253,0 +226 @@ + print '
'; @@ -257 +230 @@ - print dol_get_fiche_end(); + dol_fiche_end(); @@ -263 +236 @@ - print dol_get_fiche_head($head, 'task_notes', $langs->trans('Task'), -1, 'projecttask', 0, '', 'reposition'); + dol_fiche_head($head, 'task_notes', $langs->trans('Task'), -1, 'projecttask', 0, '', 'reposition'); @@ -269,6 +242,6 @@ - if (!GETPOST('withproject') || empty($projectstatic->id)) { - $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1); - $object->next_prev_filter = " fk_projet IN (".$db->sanitize($projectsListId).")"; - } else { - $object->next_prev_filter = " fk_projet = ".((int) $projectstatic->id); - } + if (!GETPOST('withproject') || empty($projectstatic->id)) + { + $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1); + $object->next_prev_filter = " fk_projet in (".$projectsListId.")"; + } + else $object->next_prev_filter = " fk_projet = ".$projectstatic->id; @@ -279,10 +252,11 @@ - if (empty($withproject)) { - $morehtmlref .= '
'; - $morehtmlref .= $langs->trans("Project").': '; - $morehtmlref .= $projectstatic->getNomUrl(1); - $morehtmlref .= '
'; - - // Third party - $morehtmlref .= $langs->trans("ThirdParty").': '; - $morehtmlref .= $projectstatic->thirdparty->getNomUrl(1); - $morehtmlref .= '
'; + if (empty($withproject)) + { + $morehtmlref .= '
'; + $morehtmlref .= $langs->trans("Project").': '; + $morehtmlref .= $projectstatic->getNomUrl(1); + $morehtmlref .= '
'; + + // Third party + $morehtmlref .= $langs->trans("ThirdParty").': '; + $morehtmlref .= $projectstatic->thirdparty->getNomUrl(1); + $morehtmlref .= '
'; @@ -295 +269 @@ - print '
'; + print '
'; @@ -298 +272 @@ - $moreparam = $param; + $moreparam = $param; @@ -303 +277 @@ - print dol_get_fiche_end(); + dol_fiche_end(); --- /tmp/dsg/dolibarr/htdocs/projet/tasks/github_19.0.3_task.php +++ /tmp/dsg/dolibarr/htdocs/projet/tasks/client_task.php @@ -40,3 +39,0 @@ -$action = GETPOST('action', 'aZ09'); -$confirm = GETPOST('confirm', 'alpha'); - @@ -45,0 +43,2 @@ +$action = GETPOST('action', 'alpha'); +$confirm = GETPOST('confirm', 'alpha'); @@ -48,2 +47,6 @@ -$planned_workload = ((GETPOST('planned_workloadhour', 'int') != '' || GETPOST('planned_workloadmin', 'int') != '') ? (GETPOST('planned_workloadhour', 'int') > 0 ? GETPOST('planned_workloadhour', 'int') * 3600 : 0) + (GETPOST('planned_workloadmin', 'int') > 0 ? GETPOST('planned_workloadmin', 'int') * 60 : 0) : ''); -$mode = GETPOST('mode', 'alpha'); +$planned_workload = ((GETPOST('planned_workloadhour', 'int') != '' || GETPOST('planned_workloadmin', 'int') != '') ? (GETPOST('planned_workloadhour', 'int') > 0 ?GETPOST('planned_workloadhour', 'int') * 3600 : 0) + (GETPOST('planned_workloadmin', 'int') > 0 ?GETPOST('planned_workloadmin', 'int') * 60 : 0) : ''); + +// Security check +$socid = 0; +//if ($user->socid > 0) $socid = $user->socid; // For external user, no check is done on company because readability is managed by public status of project and assignement. +if (!$user->rights->projet->lire) accessforbidden(); @@ -63,14 +66 @@ -if ($reshook < 0) { - setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); -} - -if ($id > 0 || $ref) { - $object->fetch($id, $ref); -} - -// Security check -$socid = 0; - -restrictedArea($user, 'projet', $object->fk_project, 'projet&project'); - - +if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); @@ -82 +72,2 @@ -if ($action == 'update' && !GETPOST("cancel") && $user->hasRight('projet', 'creer')) { +if ($action == 'update' && !$_POST["cancel"] && $user->rights->projet->creer) +{ @@ -85 +76,2 @@ - if (empty($taskref)) { + if (empty($taskref)) + { @@ -89 +81,2 @@ - if (!GETPOST("label")) { + if (empty($_POST["label"])) + { @@ -93,4 +86,6 @@ - if (!$error) { - $object->oldcopy = clone $object; - - $tmparray = explode('_', GETPOST('task_parent')); + if (!$error) + { + $object->fetch($id, $ref); + $object->oldcopy = clone $object; + + $tmparray = explode('_', $_POST['task_parent']); @@ -98,3 +93 @@ - if (empty($task_parent)) { - $task_parent = 0; // If task_parent is '' - } + if (empty($task_parent)) $task_parent = 0; // If task_parent is '' @@ -103,6 +96,2 @@ - $object->label = GETPOST("label", "alphanohtml"); - if (!getDolGlobalString('FCKEDITOR_ENABLE_SOCIETE')) { - $object->description = GETPOST('description', "alphanohtml"); - } else { - $object->description = GETPOST('description', "restricthtml"); - } + $object->label = $_POST["label"]; + $object->description = $_POST['description']; @@ -111,4 +100,3 @@ - $object->date_start = dol_mktime(GETPOST('dateohour', 'int'), GETPOST('dateomin', 'int'), 0, GETPOST('dateomonth', 'int'), GETPOST('dateoday', 'int'), GETPOST('dateoyear', 'int')); - $object->date_end = dol_mktime(GETPOST('dateehour', 'int'), GETPOST('dateemin', 'int'), 0, GETPOST('dateemonth', 'int'), GETPOST('dateeday', 'int'), GETPOST('dateeyear', 'int')); - $object->progress = price2num(GETPOST('progress', 'alphanohtml')); - $object->budget_amount = price2num(GETPOST('budget_amount', 'alphanohtml')); + $object->date_start = dol_mktime($_POST['dateohour'], $_POST['dateomin'], 0, $_POST['dateomonth'], $_POST['dateoday'], $_POST['dateoyear']); + $object->date_end = dol_mktime($_POST['dateehour'], $_POST['dateemin'], 0, $_POST['dateemonth'], $_POST['dateeday'], $_POST['dateeyear']); + $object->progress = $_POST['progress']; @@ -117,6 +105,5 @@ - $ret = $extrafields->setOptionalsFromPost(null, $object, '@GETPOSTISSET'); - if ($ret < 0) { - $error++; - } - - if (!$error) { + $ret = $extrafields->setOptionalsFromPost(null, $object); + if ($ret < 0) $error++; + + if (!$error) + { @@ -124,8 +111,8 @@ - if ($result < 0) { - setEventMessages($object->error, $object->errors, 'errors'); - $action = 'edit'; - } - } else { - $action = 'edit'; - } - } else { + if ($result < 0) + { + setEventMessages($object->error, $object->errors, 'errors'); + } + } + } + else + { @@ -136,19 +123,17 @@ -if ($action == 'confirm_clone' && $confirm == 'yes') { - //$clone_contacts = GETPOST('clone_contacts') ? 1 : 0; - $clone_prog = GETPOST('clone_prog') ? 1 : 0; - $clone_time = GETPOST('clone_time') ? 1 : 0; - $clone_affectation = GETPOST('clone_affectation') ? 1 : 0; - $clone_change_dt = GETPOST('clone_change_dt') ? 1 : 0; - $clone_notes = GETPOST('clone_notes') ? 1 : 0; - $clone_file = GETPOST('clone_file') ? 1 : 0; - $result = $object->createFromClone($user, $object->id, $object->fk_project, $object->fk_task_parent, $clone_change_dt, $clone_affectation, $clone_time, $clone_file, $clone_notes, $clone_prog); - if ($result <= 0) { - setEventMessages($object->error, $object->errors, 'errors'); - } else { - // Load new object - $newobject = new Task($db); - $newobject->fetch($result); - $newobject->fetch_optionals(); - $newobject->fetch_thirdparty(); // Load new object - $object = $newobject; - $action = ''; +if ($action == 'confirm_delete' && $confirm == "yes" && $user->rights->projet->supprimer) +{ + if ($object->fetch($id, $ref) >= 0) + { + $result = $projectstatic->fetch($object->fk_project); + $projectstatic->fetch_thirdparty(); + + if ($object->delete($user) > 0) + { + header('Location: '.DOL_URL_ROOT.'/projet/tasks.php?restore_lastsearch_values=1&id='.$projectstatic->id.($withproject ? '&withproject=1' : '')); + exit; + } + else + { + setEventMessages($object->error, $object->errors, 'errors'); + $action = ''; + } @@ -158,10 +143,14 @@ -if ($action == 'confirm_delete' && $confirm == "yes" && $user->hasRight('projet', 'supprimer')) { - $result = $projectstatic->fetch($object->fk_project); - $projectstatic->fetch_thirdparty(); - - if ($object->delete($user) > 0) { - header('Location: '.DOL_URL_ROOT.'/projet/tasks.php?restore_lastsearch_values=1&id='.$projectstatic->id.($withproject ? '&withproject=1' : '')); - exit; - } else { - setEventMessages($object->error, $object->errors, 'errors'); - $action = ''; +// Retreive First Task ID of Project if withprojet is on to allow project prev next to work +if (!empty($project_ref) && !empty($withproject)) +{ + if ($projectstatic->fetch('', $project_ref) > 0) + { + $tasksarray = $object->getTasksArray(0, 0, $projectstatic->id, $socid, 0); + if (count($tasksarray) > 0) + { + $id = $tasksarray[0]->id; + } + else + { + header("Location: ".DOL_URL_ROOT.'/projet/tasks.php?id='.$projectstatic->id.(empty($mode) ? '' : '&mode='.$mode)); + } @@ -171,12 +159,0 @@ -// Retrieve First Task ID of Project if withprojet is on to allow project prev next to work -if (!empty($project_ref) && !empty($withproject)) { - if ($projectstatic->fetch('', $project_ref) > 0) { - $tasksarray = $object->getTasksArray(0, 0, $projectstatic->id, $socid, 0); - if (count($tasksarray) > 0) { - $id = $tasksarray[0]->id; - } else { - header("Location: ".DOL_URL_ROOT.'/projet/tasks.php?id='.$projectstatic->id.(empty($mode) ? '' : '&mode='.$mode)); - } - } -} - @@ -184 +161,4 @@ -if ($action == 'builddoc' && $user->hasRight('projet', 'creer')) { +if ($action == 'builddoc' && $user->rights->projet->creer) +{ + $object->fetch($id, $ref); + @@ -186,3 +166 @@ - if (GETPOST('model')) { - $object->setDocModel($user, GETPOST('model', 'alpha')); - } + if (GETPOST('model')) $object->setDocModel($user, GETPOST('model', 'alpha')); @@ -191 +169,2 @@ - if (GETPOST('lang_id', 'aZ09')) { + if (GETPOST('lang_id', 'aZ09')) + { @@ -195,2 +174,3 @@ - $result = $object->generateDocument($object->model_pdf, $outputlangs); - if ($result <= 0) { + $result = $object->generateDocument($object->modelpdf, $outputlangs); + if ($result <= 0) + { @@ -198 +178 @@ - $action = ''; + $action = ''; @@ -203 +183,2 @@ -if ($action == 'remove_file' && $user->hasRight('projet', 'creer')) { +if ($action == 'remove_file' && $user->rights->projet->creer) +{ @@ -206,9 +187,9 @@ - $langs->load("other"); - $upload_dir = $conf->project->dir_output; - $file = $upload_dir.'/'.dol_sanitizeFileName(GETPOST('file')); - - $ret = dol_delete_file($file); - if ($ret) { - setEventMessages($langs->trans("FileWasRemoved", GETPOST('urlfile')), null, 'mesgs'); - } else { - setEventMessages($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), null, 'errors'); + if ($object->fetch($id, $ref) >= 0) + { + $langs->load("other"); + $upload_dir = $conf->projet->dir_output; + $file = $upload_dir.'/'.GETPOST('file'); + + $ret = dol_delete_file($file); + if ($ret) setEventMessages($langs->trans("FileWasRemoved", GETPOST('urlfile')), null, 'mesgs'); + else setEventMessages($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), null, 'errors'); @@ -217 +197,0 @@ - @@ -221,0 +202,4 @@ + + +llxHeader('', $langs->trans("Task")); + @@ -225,431 +209,142 @@ -$result = $projectstatic->fetch($object->fk_project); - -$title = $object->ref; -if (!empty($withproject)) { - $title .= ' | ' . $langs->trans("Project") . (!empty($projectstatic->ref) ? ': '.$projectstatic->ref : '') ; -} -$help_url = ''; - -llxHeader('', $title, $help_url); - - -if ($id > 0 || !empty($ref)) { - $res = $object->fetch_optionals(); - if (getDolGlobalString('PROJECT_ALLOW_COMMENT_ON_TASK') && method_exists($object, 'fetchComments') && empty($object->comments)) { - $object->fetchComments(); - } - - - if (getDolGlobalString('PROJECT_ALLOW_COMMENT_ON_PROJECT') && method_exists($projectstatic, 'fetchComments') && empty($projectstatic->comments)) { - $projectstatic->fetchComments(); - } - if (!empty($projectstatic->socid)) { - $projectstatic->fetch_thirdparty(); - } - - $object->project = clone $projectstatic; - - //$userWrite = $projectstatic->restrictedProjectArea($user, 'write'); - - if (!empty($withproject)) { - // Tabs for project - $tab = 'tasks'; - $head = project_prepare_head($projectstatic); - print dol_get_fiche_head($head, $tab, $langs->trans("Project"), -1, ($projectstatic->public ? 'projectpub' : 'project'), 0, '', ''); - - $param = ($mode == 'mine' ? '&mode=mine' : ''); - - // Project card - - $linkback = ''.$langs->trans("BackToList").''; - - $morehtmlref = '
'; - // Title - $morehtmlref .= $projectstatic->title; - // Thirdparty - if (!empty($projectstatic->thirdparty->id) &&$projectstatic->thirdparty->id > 0) { - $morehtmlref .= '
'.$projectstatic->thirdparty->getNomUrl(1, 'project'); - } - $morehtmlref .= '
'; - - // Define a complementary filter for search of next/prev ref. - if (!$user->hasRight('projet', 'all', 'lire')) { - $objectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 0); - $projectstatic->next_prev_filter = "rowid IN (".$db->sanitize(count($objectsListId) ? join(',', array_keys($objectsListId)) : '0').")"; - } - - dol_banner_tab($projectstatic, 'project_ref', $linkback, 1, 'ref', 'ref', $morehtmlref, $param); - - print '
'; - print '
'; - print '
'; - - print ''; - - // Usage - if (getDolGlobalString('PROJECT_USE_OPPORTUNITIES') || !getDolGlobalString('PROJECT_HIDE_TASKS') || isModEnabled('eventorganization')) { - print ''; - print ''; - } - - // Visibility - print ''; - - // Budget - print ''; - - // Date start - end project - print ''; - - // Other attributes - $cols = 2; - //include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; - - print '
'; - print $langs->trans("Usage"); - print ''; - if (getDolGlobalString('PROJECT_USE_OPPORTUNITIES')) { - print 'usage_opportunity ? ' checked="checked"' : '')).'"> '; - $htmltext = $langs->trans("ProjectFollowOpportunity"); - print $form->textwithpicto($langs->trans("ProjectFollowOpportunity"), $htmltext); - print '
'; - } - if (!getDolGlobalString('PROJECT_HIDE_TASKS')) { - print 'usage_task ? ' checked="checked"' : '')).'"> '; - $htmltext = $langs->trans("ProjectFollowTasks"); - print $form->textwithpicto($langs->trans("ProjectFollowTasks"), $htmltext); - print '
'; - } - if (!getDolGlobalString('PROJECT_HIDE_TASKS') && getDolGlobalString('PROJECT_BILL_TIME_SPENT')) { - print 'usage_bill_time ? ' checked="checked"' : '')).'"> '; - $htmltext = $langs->trans("ProjectBillTimeDescription"); - print $form->textwithpicto($langs->trans("BillTime"), $htmltext); - print '
'; - } - if (isModEnabled('eventorganization')) { - print 'usage_organize_event ? ' checked="checked"' : '')).'"> '; - $htmltext = $langs->trans("EventOrganizationDescriptionLong"); - print $form->textwithpicto($langs->trans("ManageOrganizeEvent"), $htmltext); - } - print '
'.$langs->trans("Visibility").''; - if ($projectstatic->public) { - print img_picto($langs->trans('SharedProject'), 'world', 'class="paddingrightonly"'); - print $langs->trans('SharedProject'); - } else { - print img_picto($langs->trans('PrivateProject'), 'private', 'class="paddingrightonly"'); - print $langs->trans('PrivateProject'); - } - print '
'.$langs->trans("Budget").''; - if (strcmp($projectstatic->budget_amount, '')) { - print ''.price($projectstatic->budget_amount, '', $langs, 1, 0, 0, $conf->currency).''; - } - print '
'.$langs->trans("Dates").''; - $start = dol_print_date($projectstatic->date_start, 'day'); - print($start ? $start : '?'); - $end = dol_print_date($projectstatic->date_end, 'day'); - print ' - '; - print($end ? $end : '?'); - if ($projectstatic->hasDelay()) { - print img_warning("Late"); - } - print '
'; - - print '
'; - - print '
'; - print '
'; - - print ''; - - // Description - print ''; - - // Categories - if (isModEnabled('categorie')) { - print '"; - } - - print '
'.$langs->trans("Description").''; - print nl2br($projectstatic->description); - print '
'.$langs->trans("Categories").''; - print $form->showCategories($projectstatic->id, 'project', 1); - print "
'; - - print '
'; - print '
'; - - print '
'; - - print dol_get_fiche_end(); - - print '
'; - } - - /* - * Actions - */ - /*print '
'; - - if ($user->rights->projet->all->creer || $user->rights->projet->creer) - { - if ($projectstatic->public || $userWrite > 0) - { - print ''.$langs->trans('AddTask').''; - } - else - { - print ''.$langs->trans('AddTask').''; - } - } - else - { - print ''.$langs->trans('AddTask').''; - } - - print '
'; - */ - - // To verify role of users - //$userAccess = $projectstatic->restrictedProjectArea($user); // We allow task affected to user even if a not allowed project - //$arrayofuseridoftask=$object->getListContactId('internal'); - - if ($action == 'clone') { - $formquestion = array( - 'text' => $langs->trans("ConfirmClone"), - //array('type' => 'checkbox', 'name' => 'clone_contacts', 'label' => $langs->trans("CloneContacts"), 'value' => true), - array('type' => 'checkbox', 'name' => 'clone_change_dt', 'label' => $langs->trans("CloneChanges"), 'value' => true), - array('type' => 'checkbox', 'name' => 'clone_affectation', 'label' => $langs->trans("CloneAffectation"), 'value' => true), - array('type' => 'checkbox', 'name' => 'clone_prog', 'label' => $langs->trans("CloneProgression"), 'value' => true), - array('type' => 'checkbox', 'name' => 'clone_time', 'label' => $langs->trans("CloneTimes"), 'value' => true), - array('type' => 'checkbox', 'name' => 'clone_file', 'label' => $langs->trans("CloneFile"), 'value' => true), - - ); - - print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id, $langs->trans("ToClone"), $langs->trans("ConfirmCloneTask"), "confirm_clone", $formquestion, '', 1, 300, 590); - } - - - $head = task_prepare_head($object); - - if ($action == 'edit' && $user->hasRight('projet', 'creer')) { - print '
'; - print ''; - print ''; - print ''; - print ''; - - print dol_get_fiche_head($head, 'task_task', $langs->trans("Task"), 0, 'projecttask', 0, '', ''); - - print ''; - - // Ref - print ''; - print ''; - - // Label - print ''; - print ''; - - // Project - if (empty($withproject)) { - print ''; - - // Third party - print ''; - } - - // Task parent - print ''; - - // Date start - print ''; - - // Date end - print ''; - - // Planned workload - print ''; - - // Progress declared - print ''; - - // Description - print ''; - print ''; - - print ''; - print ''; - print ''; - - // Other options - $parameters = array(); - $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - if (empty($reshook)) { - print $object->showOptionals($extrafields, 'edit'); - } - - print '
'.$langs->trans("Ref").'
'.$langs->trans("Label").'
'.$langs->trans("Project").''; - print $projectstatic->getNomUrl(1); - print '
'.$langs->trans("ThirdParty").''; - if ($projectstatic->thirdparty->id) { - print $projectstatic->thirdparty->getNomUrl(1); - } else { - print ' '; - } - print '
'.$langs->trans("ChildOfProjectTask").''; - $formother->selectProjectTasks($object->fk_task_parent, $projectstatic->id, 'task_parent', ($user->admin ? 0 : 1), 0, 0, 0, $object->id); - print '
'.$langs->trans("DateStart").''; - print $form->selectDate($object->date_start, 'dateo', 1, 1, 0, '', 1, 0); - print '
'.$langs->trans("Deadline").''; - print $form->selectDate($object->date_end ? $object->date_end : -1, 'datee', 1, 1, 0, '', 1, 0); - print '
'.$langs->trans("PlannedWorkload").''; - print $form->select_duration('planned_workload', $object->planned_workload, 0, 'text'); - print '
'.$langs->trans("ProgressDeclared").''; - print $formother->select_percent($object->progress, 'progress', 0, 5, 0, 100, 1); - print '
'.$langs->trans("Description").''; - - // WYSIWYG editor - include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $cked_enabled = (getDolGlobalString('FCKEDITOR_ENABLE_SOCIETE') ? $conf->global->FCKEDITOR_ENABLE_SOCIETE : 0); - $nbrows = getDolGlobalInt('MAIN_INPUT_DESC_HEIGHT', 0); - $doleditor = new DolEditor('description', $object->description, '', 80, 'dolibarr_details', '', false, true, $cked_enabled, $nbrows); - print $doleditor->Create(); - print '
'.$langs->trans("Budget").'
'; - - print dol_get_fiche_end(); - - print $form->buttonsSaveCancel("Modify"); - - print '
'; - } else { - /* - * Fiche tache en mode visu - */ - $param = ($withproject ? '&withproject=1' : ''); - $linkback = $withproject ? ''.$langs->trans("BackToList").'' : ''; - - print dol_get_fiche_head($head, 'task_task', $langs->trans("Task"), -1, 'projecttask', 0, '', 'reposition'); - - if ($action == 'delete') { - print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".GETPOST("id", 'int').'&withproject='.$withproject, $langs->trans("DeleteATask"), $langs->trans("ConfirmDeleteATask"), "confirm_delete"); - } - - if (!GETPOST('withproject') || empty($projectstatic->id)) { - $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1); - $object->next_prev_filter = "fk_projet IN (".$db->sanitize($projectsListId).")"; - } else { - $object->next_prev_filter = "fk_projet = ".((int) $projectstatic->id); - } - - $morehtmlref = ''; - - // Project - if (empty($withproject)) { - $morehtmlref .= '
'; - $morehtmlref .= $langs->trans("Project").': '; - $morehtmlref .= $projectstatic->getNomUrl(1); - $morehtmlref .= '
'; - - // Third party - $morehtmlref .= $langs->trans("ThirdParty").': '; - if (!empty($projectstatic->thirdparty) && is_object($projectstatic->thirdparty)) { - $morehtmlref .= $projectstatic->thirdparty->getNomUrl(1); - } - $morehtmlref .= '
'; - } - - dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref, $param); - - print '
'; - print '
'; - - print '
'; - print ''; - - // Task parent - print ''; - - // Date start - Date end task - print ''; - - // Planned workload - print ''; - - // Description - print ''; - - print '
'.$langs->trans("ChildOfTask").''; - if ($object->fk_task_parent > 0) { - $tasktmp = new Task($db); - $tasktmp->fetch($object->fk_task_parent); - print $tasktmp->getNomUrl(1); - } - print '
'.$langs->trans("DateStart").' - '.$langs->trans("Deadline").''; - $start = dol_print_date($object->date_start, 'dayhour'); - print($start ? $start : '?'); - $end = dol_print_date($object->date_end, 'dayhour'); - print ' - '; - print($end ? $end : '?'); - if ($object->hasDelay()) { - print img_warning("Late"); - } - print '
'.$langs->trans("PlannedWorkload").''; - if ($object->planned_workload != '') { - print convertSecondToTime($object->planned_workload, 'allhourmin'); - } - print '
'.$langs->trans("Description").''; - print dol_htmlentitiesbr($object->description); - print '
'; - print '
'; - - print '
'; - - print '
'; - print ''; - - // Progress declared - print ''; - - // Progress calculated - print ''; - - // Budget - print ''; - - // Other attributes - $cols = 3; - $parameters = array('socid'=>$socid); - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; - - print '
'.$langs->trans("ProgressDeclared").''; - if ($object->progress != '') { - print $object->progress.' %'; - } - print '
'.$langs->trans("ProgressCalculated").''; - if ($object->planned_workload != '') { - $tmparray = $object->getSummaryOfTimeSpent(); - if ($tmparray['total_duration'] > 0 && !empty($object->planned_workload)) { - print round($tmparray['total_duration'] / $object->planned_workload * 100, 2).' %'; - } else { - print '0 %'; - } - } else { - print ''.$langs->trans("WorkloadNotDefined").''; - } - print '
'.$langs->trans("Budget").''; - if (!is_null($object->budget_amount) && strcmp($object->budget_amount, '')) { - print ''.price($object->budget_amount, 0, $langs, 1, 0, 0, $conf->currency).''; - } - print '
'; - - print '
'; - - print '
'; - print '
'; - - print dol_get_fiche_end(); - } - - - if ($action != 'edit') { + +if ($id > 0 || !empty($ref)) +{ + if ($object->fetch($id, $ref) > 0) + { + $res = $object->fetch_optionals(); + if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_TASK) && method_exists($object, 'fetchComments') && empty($object->comments)) $object->fetchComments(); + + $result = $projectstatic->fetch($object->fk_project); + if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($projectstatic, 'fetchComments') && empty($projectstatic->comments)) $projectstatic->fetchComments(); + if (!empty($projectstatic->socid)) $projectstatic->fetch_thirdparty(); + + $object->project = clone $projectstatic; + + $userWrite = $projectstatic->restrictedProjectArea($user, 'write'); + + if (!empty($withproject)) + { + // Tabs for project + $tab = 'tasks'; + $head = project_prepare_head($projectstatic); + dol_fiche_head($head, $tab, $langs->trans("Project"), -1, ($projectstatic->public ? 'projectpub' : 'project'), 0, '', ''); + + $param = ($mode == 'mine' ? '&mode=mine' : ''); + + // Project card + + $linkback = ''.$langs->trans("BackToList").''; + + $morehtmlref = '
'; + // Title + $morehtmlref .= $projectstatic->title; + // Thirdparty + if ($projectstatic->thirdparty->id > 0) + { + $morehtmlref .= '
'.$langs->trans('ThirdParty').' : '.$projectstatic->thirdparty->getNomUrl(1, 'project'); + } + $morehtmlref .= '
'; + + // Define a complementary filter for search of next/prev ref. + if (!$user->rights->projet->all->lire) + { + $objectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 0); + $projectstatic->next_prev_filter = " rowid in (".(count($objectsListId) ?join(',', array_keys($objectsListId)) : '0').")"; + } + + dol_banner_tab($projectstatic, 'project_ref', $linkback, 1, 'ref', 'ref', $morehtmlref); + + print '
'; + print '
'; + print '
'; + + print ''; + + // Usage + print ''; + print ''; + + // Visibility + print ''; + + // Date start - end + print ''; + + // Budget + print ''; + + // Other attributes + $cols = 2; + //include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; + + print '
'; + print $langs->trans("Usage"); + print ''; + if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) + { + print 'usage_opportunity ? ' checked="checked"' : '')).'"> '; + $htmltext = $langs->trans("ProjectFollowOpportunity"); + print $form->textwithpicto($langs->trans("ProjectFollowOpportunity"), $htmltext); + print '
'; + } + if (empty($conf->global->PROJECT_HIDE_TASKS)) + { + print 'usage_task ? ' checked="checked"' : '')).'"> '; + $htmltext = $langs->trans("ProjectFollowTasks"); + print $form->textwithpicto($langs->trans("ProjectFollowTasks"), $htmltext); + print '
'; + } + if (!empty($conf->global->PROJECT_BILL_TIME_SPENT)) + { + print 'usage_bill_time ? ' checked="checked"' : '')).'"> '; + $htmltext = $langs->trans("ProjectBillTimeDescription"); + print $form->textwithpicto($langs->trans("BillTime"), $htmltext); + print '
'; + } + print '
'.$langs->trans("Visibility").''; + if ($projectstatic->public) print $langs->trans('SharedProject'); + else print $langs->trans('PrivateProject'); + print '
'.$langs->trans("DateStart").' - '.$langs->trans("DateEnd").''; + $start = dol_print_date($projectstatic->date_start, 'day'); + print ($start ? $start : '?'); + $end = dol_print_date($projectstatic->date_end, 'day'); + print ' - '; + print ($end ? $end : '?'); + if ($projectstatic->hasDelay()) print img_warning("Late"); + print '
'.$langs->trans("Budget").''; + if (strcmp($projectstatic->budget_amount, '')) print price($projectstatic->budget_amount, '', $langs, 1, 0, 0, $conf->currency); + print '
'; + + print '
'; + + print '
'; + print '
'; + print '
'; + + print ''; + + // Description + print ''; + + // Categories + if ($conf->categorie->enabled) { + print '"; + } + + print '
'.$langs->trans("Description").''; + print nl2br($projectstatic->description); + print '
'.$langs->trans("Categories").''; + print $form->showCategories($projectstatic->id, 'project', 1); + print "
'; + + print '
'; + print '
'; + print '
'; + + print '
'; + + dol_fiche_end(); + + print '
'; + } + @@ -658,23 +353,255 @@ - */ - - print '
'; - - $parameters = array(); - $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been - // modified by hook - if (empty($reshook)) { - // Modify - if ($user->hasRight('projet', 'creer')) { - print ''.$langs->trans('Modify').''; - print ''.$langs->trans('Clone').''; - } else { - print ''.$langs->trans('Modify').''; - } - - // Delete - $permissiontodelete = $user->hasRight('projet', 'supprimer'); - if ($permissiontodelete) { - if (!$object->hasChildren() && !$object->hasTimeSpent()) { - print dolGetButtonAction($langs->trans("Delete"), '', 'delete', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delete&token='.newToken().'&withproject='.((int) $withproject), 'delete', $permissiontodelete); - } else { - print dolGetButtonAction($langs->trans("TaskHasChild"), $langs->trans("Delete"), 'delete', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delete&token='.newToken().'&withproject='.((int) $withproject), 'delete', 0); + */ + /*print '
'; + + if ($user->rights->projet->all->creer || $user->rights->projet->creer) + { + if ($projectstatic->public || $userWrite > 0) + { + print ''.$langs->trans('AddTask').''; + } + else + { + print ''.$langs->trans('AddTask').''; + } + } + else + { + print ''.$langs->trans('AddTask').''; + } + + print '
'; + */ + + // To verify role of users + //$userAccess = $projectstatic->restrictedProjectArea($user); // We allow task affected to user even if a not allowed project + //$arrayofuseridoftask=$object->getListContactId('internal'); + + $head = task_prepare_head($object); + + if ($action == 'edit' && $user->rights->projet->creer) + { + print '
'; + print ''; + print ''; + print ''; + print ''; + + dol_fiche_head($head, 'task_task', $langs->trans("Task"), 0, 'projecttask', 0, '', ''); + + print ''; + + // Ref + print ''; + print ''; + + // Label + print ''; + print ''; + + // Project + if (empty($withproject)) + { + print ''; + + // Third party + print ''; + } + + // Task parent + print ''; + + // Date start + print ''; + + // Date end + print ''; + + // Planned workload + print ''; + + // Progress declared + print ''; + + // Description + print ''; + print ''; + + // Other options + $parameters = array(); + $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + if (empty($reshook)) + { + print $object->showOptionals($extrafields, 'edit'); + } + + print '
'.$langs->trans("Ref").'
'.$langs->trans("Label").'
'.$langs->trans("Project").''; + print $projectstatic->getNomUrl(1); + print '
'.$langs->trans("ThirdParty").''; + if ($projectstatic->societe->id) print $projectstatic->societe->getNomUrl(1); + else print ' '; + print '
'.$langs->trans("ChildOfProjectTask").''; + print $formother->selectProjectTasks($object->fk_task_parent, $projectstatic->id, 'task_parent', ($user->admin ? 0 : 1), 0, 0, 0, $object->id); + print '
'.$langs->trans("DateStart").''; + print $form->selectDate($object->date_start, 'dateo', 1, 1, 0, '', 1, 0); + print '
'.$langs->trans("DateEnd").''; + print $form->selectDate($object->date_end ? $object->date_end : -1, 'datee', 1, 1, 0, '', 1, 0); + print '
'.$langs->trans("PlannedWorkload").''; + print $form->select_duration('planned_workload', $object->planned_workload, 0, 'text'); + print '
'.$langs->trans("ProgressDeclared").''; + print $formother->select_percent($object->progress, 'progress', 0, 5, 0, 100, 1); + print '
'.$langs->trans("Description").''; + print ''; + print '
'; + + dol_fiche_end(); + + print '
'; + print '   '; + print ''; + print '
'; + + print '
'; + } + else + { + /* + * Fiche tache en mode visu + */ + $param = ($withproject ? '&withproject=1' : ''); + $linkback = $withproject ? ''.$langs->trans("BackToList").'' : ''; + + dol_fiche_head($head, 'task_task', $langs->trans("Task"), -1, 'projecttask', 0, '', 'reposition'); + + if ($action == 'delete') + { + print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$_GET["id"].'&withproject='.$withproject, $langs->trans("DeleteATask"), $langs->trans("ConfirmDeleteATask"), "confirm_delete"); + } + + if (!GETPOST('withproject') || empty($projectstatic->id)) + { + $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1); + $object->next_prev_filter = " fk_projet in (".$projectsListId.")"; + } + else $object->next_prev_filter = " fk_projet = ".$projectstatic->id; + + $morehtmlref = ''; + + // Project + if (empty($withproject)) + { + $morehtmlref .= '
'; + $morehtmlref .= $langs->trans("Project").': '; + $morehtmlref .= $projectstatic->getNomUrl(1); + $morehtmlref .= '
'; + + // Third party + $morehtmlref .= $langs->trans("ThirdParty").': '; + if (!empty($projectstatic->thirdparty)) { + $morehtmlref .= $projectstatic->thirdparty->getNomUrl(1); + } + $morehtmlref .= '
'; + } + + dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref, $param); + + print '
'; + print '
'; + + print '
'; + print ''; + + // Task parent + print ''; + + // Date start - Date end + print ''; + + // Planned workload + print ''; + + // Description + print ''; + + print '
'.$langs->trans("ChildOfTask").''; + if ($object->fk_task_parent > 0) + { + $tasktmp = new Task($db); + $tasktmp->fetch($object->fk_task_parent); + print $tasktmp->getNomUrl(1); + } + print '
'.$langs->trans("DateStart").' - '.$langs->trans("DateEnd").''; + $start = dol_print_date($object->date_start, 'dayhour'); + print ($start ? $start : '?'); + $end = dol_print_date($object->date_end, 'dayhour'); + print ' - '; + print ($end ? $end : '?'); + if ($object->hasDelay()) print img_warning("Late"); + print '
'.$langs->trans("PlannedWorkload").''; + if ($object->planned_workload != '') + { + print convertSecondToTime($object->planned_workload, 'allhourmin'); + } + print '
'.$langs->trans("Description").''; + print nl2br($object->description); + print '
'; + print '
'; + + print '
'; + + print '
'; + print ''; + + // Progress declared + print ''; + + // Progress calculated + print ''; + + // Other attributes + $cols = 3; + $parameters = array('socid'=>$socid); + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; + + print '
'.$langs->trans("ProgressDeclared").''; + if ($object->progress != '') + { + print $object->progress.' %'; + } + print '
'.$langs->trans("ProgressCalculated").''; + if ($object->planned_workload != '') + { + $tmparray = $object->getSummaryOfTimeSpent(); + if ($tmparray['total_duration'] > 0 && !empty($object->planned_workload)) print round($tmparray['total_duration'] / $object->planned_workload * 100, 2).' %'; + else print '0 %'; + } + else print ''.$langs->trans("WorkloadNotDefined").''; + print '
'; + + print '
'; + print '
'; + + print '
'; + print '
'; + + dol_fiche_end(); + } + + + if ($action != 'edit') + { + /* + * Actions + */ + + print '
'; + + $parameters = array(); + $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been + // modified by hook + if (empty($reshook)) + { + // Modify + if ($user->rights->projet->creer) + { + print ''.$langs->trans('Modify').''; @@ -682,29 +609,48 @@ - } else { - print dolGetButtonAction($langs->trans("Delete"), '', 'delete', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delete&token='.newToken().'&withproject='.((int) $withproject), 'delete', $permissiontodelete); - } - - print '
'; - } - - print '
'; - print ''; // ancre - - /* - * Generated documents - */ - $filename = dol_sanitizeFileName($projectstatic->ref)."/".dol_sanitizeFileName($object->ref); - $filedir = $conf->project->dir_output."/".dol_sanitizeFileName($projectstatic->ref)."/".dol_sanitizeFileName($object->ref); - $urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id; - $genallowed = ($user->rights->projet->lire); - $delallowed = ($user->hasRight('projet', 'creer')); - - print $formfile->showdocuments('project_task', $filename, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf); - - print '
'; - - // List of actions on element - include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'; - $formactions = new FormActions($db); - $formactions->showactions($object, 'project_task', 0, 1, '', 10, 'withproject='.$withproject); - - print '
'; + else + { + print ''.$langs->trans('Modify').''; + } + + // Delete + if ($user->rights->projet->supprimer) + { + if (!$object->hasChildren() && !$object->hasTimeSpent()) + { + print ''.$langs->trans('Delete').''; + } + else + { + print ''.$langs->trans('Delete').''; + } + } + else + { + print ''.$langs->trans('Delete').''; + } + + print '
'; + } + + print '
'; + print ''; // ancre + + /* + * Documents generes + */ + $filename = dol_sanitizeFileName($projectstatic->ref)."/".dol_sanitizeFileName($object->ref); + $filedir = $conf->projet->dir_output."/".dol_sanitizeFileName($projectstatic->ref)."/".dol_sanitizeFileName($object->ref); + $urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id; + $genallowed = ($user->rights->projet->lire); + $delallowed = ($user->rights->projet->creer); + + print $formfile->showdocuments('project_task', $filename, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf); + + print '
'; + + // List of actions on element + include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'; + $formactions = new FormActions($db); + $somethingshown = $formactions->showactions($object, 'task', $socid, 1, '', 10, 'withproject='.$withproject); + + print '
'; + } --- /tmp/dsg/dolibarr/htdocs/projet/tasks/github_19.0.3_time.php +++ /tmp/dsg/dolibarr/htdocs/projet/tasks/client_time.php @@ -3 +3 @@ - * Copyright (C) 2006-2023 Laurent Destailleur + * Copyright (C) 2006-2020 Laurent Destailleur @@ -8,2 +8 @@ - * Copyright (C) 2019-2021 Christophe Battarel - * Copyright (C) 2023 Gauthier VERDOL + * Copyright (C) 2019 Christophe Battarel @@ -26,3 +25,3 @@ - * \file htdocs/projet/tasks/time.php - * \ingroup project - * \brief Page to add new time spent on a task + * \file htdocs/projet/tasks/time.php + * \ingroup project + * \brief Page to add new time spent on a task @@ -31 +29,0 @@ -// Load Dolibarr environment @@ -33,8 +31,7 @@ -require_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php'; -require_once DOL_DOCUMENT_ROOT . '/projet/class/task.class.php'; -require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php'; -require_once DOL_DOCUMENT_ROOT . '/core/lib/project.lib.php'; -require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php'; -require_once DOL_DOCUMENT_ROOT . '/core/class/html.formother.class.php'; -require_once DOL_DOCUMENT_ROOT . '/core/class/html.formprojet.class.php'; -require_once DOL_DOCUMENT_ROOT . '/core/class/html.formintervention.class.php'; +require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; +require_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; @@ -43,8 +40,3 @@ -$langsLoad = array('projects', 'bills', 'orders', 'companies'); -if (isModEnabled('eventorganization')) { - $langsLoad[] = 'eventorganization'; -} - -$langs->loadLangs($langsLoad); - -$action = GETPOST('action', 'alpha'); +$langs->loadLangs(array('projects', 'bills', 'orders')); + +$action = GETPOST('action', 'alpha'); @@ -52,2 +44,2 @@ -$confirm = GETPOST('confirm', 'alpha'); -$cancel = GETPOST('cancel', 'alpha'); +$confirm = GETPOST('confirm', 'alpha'); +$cancel = GETPOST('cancel', 'alpha'); @@ -55 +47 @@ -$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'timespentlist'; // To manage different context of search +$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'myobjectlist'; // To manage different context of search @@ -57,6 +49,5 @@ -$optioncss = GETPOST('optioncss', 'alpha'); -$mode = GETPOST('mode', 'alpha'); - -$id = GETPOST('id', 'int'); -$projectid = GETPOST('projectid', 'int'); -$ref = GETPOST('ref', 'alpha'); +$optioncss = GETPOST('optioncss', 'alpha'); + +$id = GETPOST('id', 'int'); +$projectid = GETPOST('projectid', 'int'); +$ref = GETPOST('ref', 'alpha'); @@ -65 +56 @@ -$tab = GETPOST('tab', 'aZ09'); +$tab = GETPOST('tab', 'aZ09'); @@ -70,8 +61,2 @@ -$search_date_startday = GETPOST('search_date_startday', 'int'); -$search_date_startmonth = GETPOST('search_date_startmonth', 'int'); -$search_date_startyear = GETPOST('search_date_startyear', 'int'); -$search_date_endday = GETPOST('search_date_endday', 'int'); -$search_date_endmonth = GETPOST('search_date_endmonth', 'int'); -$search_date_endyear = GETPOST('search_date_endyear', 'int'); -$search_date_start = dol_mktime(0, 0, 0, $search_date_startmonth, $search_date_startday, $search_date_startyear); // Use tzserver -$search_date_end = dol_mktime(23, 59, 59, $search_date_endmonth, $search_date_endday, $search_date_endyear); +$search_datehour = ''; +$search_datewithhour = ''; @@ -85,13 +70,9 @@ -$search_product_ref = GETPOST('search_product_ref', 'alpha'); -$search_company = GETPOST('$search_company', 'alpha'); -$search_company_alias = GETPOST('$search_company_alias', 'alpha'); -$search_project_ref = GETPOST('$search_project_ref', 'alpha'); -$search_project_label = GETPOST('$search_project_label', 'alpha'); -$search_timespent_starthour = GETPOSTINT("search_timespent_duration_starthour"); -$search_timespent_startmin = GETPOSTINT("search_timespent_duration_startmin"); -$search_timespent_endhour = GETPOSTINT("search_timespent_duration_endhour"); -$search_timespent_endmin = GETPOSTINT("search_timespent_duration_endmin"); - -$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; -$sortfield = GETPOST('sortfield', 'aZ09comma'); -$sortorder = GETPOST('sortorder', 'aZ09comma'); + +// Security check +$socid = 0; +//if ($user->socid > 0) $socid = $user->socid; // For external user, no check is done on company because readability is managed by public status of project and assignement. +if (!$user->rights->projet->lire) accessforbidden(); + +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; +$sortfield = GETPOST("sortfield", 'alpha'); +$sortorder = GETPOST("sortorder", 'alpha'); @@ -99,3 +80 @@ -if (empty($page) || $page == -1) { - $page = 0; -} // If $page is not defined, or '' or -1 +if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 @@ -105,8 +84,2 @@ -if (!$sortfield) { - $sortfield = 't.element_date,t.element_datehour,t.rowid'; -} -if (!$sortorder) { - $sortorder = 'DESC,DESC,DESC'; -} - -$childids = $user->getAllChildIds(1); +if (!$sortfield) $sortfield = 't.task_date,t.task_datehour,t.rowid'; +if (!$sortorder) $sortorder = 'DESC,DESC,DESC'; @@ -118,0 +92 @@ +$projectstatic = new Project($db); @@ -120,3 +93,0 @@ -$projectstatic = new Project($db); - -// fetch optionals attributes and labels @@ -125,23 +95,0 @@ - -// Load task -if ($id > 0 || $ref) { - $object->fetch($id, $ref); -} - - -// Security check -$socid = 0; -//if ($user->socid > 0) $socid = $user->socid; // For external user, no check is done on company because readability is managed by public status of project and assignement. -if (!$user->hasRight('projet', 'lire')) { - accessforbidden(); -} - -if ($object->fk_project > 0) { - restrictedArea($user, 'projet', $object->fk_project, 'projet&project'); -} else { - restrictedArea($user, 'projet', null, 'projet&project'); - // We check user has permission to see all tasks of all users - if (empty($projectid) && !$user->hasRight('projet', 'all', 'lire')) { - $search_user = $user->id; - } -} @@ -154,8 +102,4 @@ -if (GETPOST('cancel', 'alpha')) { - $action = ''; -} -if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend' && $massaction != 'confirm_generateinvoice' && $massaction != 'confirm_generateinter') { - $massaction = ''; -} - -$parameters = array('socid' => $socid, 'projectid' => $projectid); +if (GETPOST('cancel', 'alpha')) { $action = ''; } +if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend' && $massaction != 'confirm_generateinvoice') { $massaction = ''; } + +$parameters = array('socid'=>$socid, 'projectid'=>$projectid); @@ -163,5 +107,3 @@ -if ($reshook < 0) { - setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); -} - -include DOL_DOCUMENT_ROOT . '/core/actions_changeselectedfields.inc.php'; +if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + +include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; @@ -170 +112,2 @@ -if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers +if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers +{ @@ -173,0 +117,3 @@ + $search_date = ''; + $search_datehour = ''; + $search_datewithhour = ''; @@ -177,8 +123,2 @@ - $search_date_startday = ''; - $search_date_startmonth = ''; - $search_date_startyear = ''; - $search_date_endday = ''; - $search_date_endmonth = ''; - $search_date_endyear = ''; - $search_date_start = ''; - $search_date_end = ''; + $search_date_creation = ''; + $search_date_update = ''; @@ -186,4 +125,0 @@ - $search_company = ''; - $search_company_alias = ''; - $search_project_ref = ''; - $search_project_label = ''; @@ -191 +127 @@ - $search_user = -1; + $search_user = 0; @@ -193,2 +129 @@ - $search_product_ref = ''; - $toselect = array(); + $toselect = ''; @@ -196,4 +130,0 @@ - $search_timespent_starthour = ''; - $search_timespent_startmin = ''; - $search_timespent_endhour = ''; - $search_timespent_endmin = ''; @@ -203 +134,2 @@ -if ($action == 'addtimespent' && $user->hasRight('projet', 'time')) { +if ($action == 'addtimespent' && $user->rights->projet->lire) +{ @@ -208 +140,2 @@ - if (empty($timespent_durationhour) && empty($timespent_durationmin)) { + if (empty($timespent_durationhour) && empty($timespent_durationmin)) + { @@ -212 +145,2 @@ - if (!GETPOST("userid", 'int')) { + if (empty($_POST["userid"])) + { @@ -218,2 +152,4 @@ - if (!$error) { - if ($id || $ref) { + if (!$error) + { + if ($id || $ref) + { @@ -221,2 +157,5 @@ - } else { - if (!GETPOST('taskid', 'int') || GETPOST('taskid', 'int') < 0) { + } + else + { + if (!GETPOST('taskid', 'int') || GETPOST('taskid', 'int') < 0) + { @@ -226 +165,3 @@ - } else { + } + else + { @@ -231 +172,2 @@ - if (!$error) { + if (!$error) + { @@ -234 +176,2 @@ - if (empty($object->project->statut)) { + if (empty($object->project->statut)) + { @@ -238,9 +181,10 @@ - } else { - $object->timespent_note = GETPOST("timespent_note", 'alpha'); - if (GETPOST('progress', 'int') > 0) { - $object->progress = GETPOST('progress', 'int'); // If progress is -1 (not defined), we do not change value - } - $object->timespent_duration = GETPOSTINT("timespent_durationhour") * 60 * 60; // We store duration in seconds - $object->timespent_duration += (GETPOSTINT('timespent_durationmin') ? GETPOSTINT('timespent_durationmin') : 0) * 60; // We store duration in seconds - if (GETPOST("timehour") != '' && GETPOST("timehour") >= 0) { // If hour was entered - $object->timespent_date = dol_mktime(GETPOST("timehour", 'int'), GETPOST("timemin", 'int'), 0, GETPOST("timemonth", 'int'), GETPOST("timeday", 'int'), GETPOST("timeyear", 'int')); + } + else + { + $object->timespent_note = $_POST["timespent_note"]; + if (GETPOST('progress', 'int') > 0) $object->progress = GETPOST('progress', 'int'); // If progress is -1 (not defined), we do not change value + $object->timespent_duration = $_POST["timespent_durationhour"] * 60 * 60; // We store duration in seconds + $object->timespent_duration += ($_POST["timespent_durationmin"] ? $_POST["timespent_durationmin"] : 0) * 60; // We store duration in seconds + if (GETPOST("timehour") != '' && GETPOST("timehour") >= 0) // If hour was entered + { + $object->timespent_date = dol_mktime(GETPOST("timehour"), GETPOST("timemin"), 0, GETPOST("timemonth"), GETPOST("timeday"), GETPOST("timeyear")); @@ -248,6 +192,6 @@ - } else { - $object->timespent_date = dol_mktime(12, 0, 0, GETPOST("timemonth", 'int'), GETPOST("timeday", 'int'), GETPOST("timeyear", 'int')); - } - $object->timespent_fk_user = GETPOST("userid", 'int'); - $object->timespent_fk_product = GETPOST("fk_product", 'int'); - + } + else + { + $object->timespent_date = dol_mktime(12, 0, 0, GETPOST("timemonth"), GETPOST("timeday"), GETPOST("timeyear")); + } + $object->timespent_fk_user = $_POST["userid"]; @@ -255,2 +199,2 @@ - - if ($result >= 0) { + if ($result >= 0) + { @@ -258 +202,3 @@ - } else { + } + else + { @@ -264,6 +210,5 @@ - } else { - if (empty($id)) { - $action = 'createtime'; - } else { - $action = 'createtime'; - } + } + else + { + if (empty($id)) $action = 'createtime'; + else $action = 'createtime'; @@ -273 +218,2 @@ -if (($action == 'updateline' || $action == 'updatesplitline') && !$cancel && $user->hasRight('projet', 'lire')) { +if (($action == 'updateline' || $action == 'updatesplitline') && !$cancel && $user->rights->projet->lire) +{ @@ -276 +222,2 @@ - if (!GETPOST("new_durationhour") && !GETPOST("new_durationmin")) { + if (!GETPOST("new_durationhour") && !GETPOST("new_durationmin")) + { @@ -281,4 +228,5 @@ - if (!$error) { - if (GETPOST('taskid', 'int') != $id) { // GETPOST('taskid') is id of new task - $id_temp = GETPOST('taskid', 'int'); // should not overwrite $id - + if (!$error) + { + if (GETPOST('taskid', 'int') != $id) // GETPOST('taskid') is id of new task + { + $id = GETPOST('taskid', 'int'); @@ -287,13 +235,10 @@ - - $result = 0; - if (in_array($object->timespent_fk_user, $childids) || $user->hasRight('projet', 'all', 'creer')) { - $result = $object->delTimeSpent($user); - } - - $object->fetch($id_temp, $ref); - - $object->timespent_note = GETPOST("timespent_note_line", "alphanohtml"); - $object->timespent_old_duration = GETPOST("old_duration", "int"); - $object->timespent_duration = GETPOSTINT("new_durationhour") * 60 * 60; // We store duration in seconds - $object->timespent_duration += (GETPOSTINT("new_durationmin") ? GETPOSTINT('new_durationmin') : 0) * 60; // We store duration in seconds - if (GETPOST("timelinehour") != '' && GETPOST("timelinehour") >= 0) { // If hour was entered + // TODO Check that ($task_time->fk_user == $user->id || in_array($task_time->fk_user, $childids)) + $result = $object->delTimeSpent($user); + + $object->fetch($id, $ref); + $object->timespent_note = $_POST["timespent_note_line"]; + $object->timespent_old_duration = $_POST["old_duration"]; + $object->timespent_duration = $_POST["new_durationhour"] * 60 * 60; // We store duration in seconds + $object->timespent_duration += ($_POST["new_durationmin"] ? $_POST["new_durationmin"] : 0) * 60; // We store duration in seconds + if (GETPOST("timelinehour") != '' && GETPOST("timelinehour") >= 0) // If hour was entered + { @@ -302 +247,3 @@ - } else { + } + else + { @@ -305,16 +252,14 @@ - $object->timespent_fk_user = GETPOST("userid_line", 'int'); - $object->timespent_fk_product = GETPOST("fk_product", 'int'); - $object->timespent_invoiceid = GETPOST("invoiceid", 'int'); - $object->timespent_invoicelineid = GETPOST("invoicelineid", 'int'); - - $result = 0; - if (in_array($object->timespent_fk_user, $childids) || $user->hasRight('projet', 'all', 'creer')) { - $result = $object->addTimeSpent($user); - if ($result >= 0) { - setEventMessages($langs->trans("RecordSaved"), null, 'mesgs'); - } else { - setEventMessages($langs->trans($object->error), null, 'errors'); - $error++; - } - } - } else { + $object->timespent_fk_user = $_POST["userid_line"]; + $result = $object->addTimeSpent($user); + if ($result >= 0) + { + setEventMessages($langs->trans("RecordSaved"), null, 'mesgs'); + } + else + { + setEventMessages($langs->trans($object->error), null, 'errors'); + $error++; + } + } + else + { @@ -322,8 +267,10 @@ - - $object->timespent_id = GETPOST("lineid", 'int'); - $object->timespent_note = GETPOST("timespent_note_line", "alphanohtml"); - $object->timespent_old_duration = GETPOST("old_duration", "int"); - $object->timespent_duration = GETPOSTINT("new_durationhour") * 60 * 60; // We store duration in seconds - $object->timespent_duration += (GETPOSTINT("new_durationmin") ? GETPOSTINT('new_durationmin') : 0) * 60; // We store duration in seconds - if (GETPOST("timelinehour") != '' && GETPOST("timelinehour") >= 0) { // If hour was entered - $object->timespent_date = dol_mktime(GETPOST("timelinehour", 'int'), GETPOST("timelinemin", 'int'), 0, GETPOST("timelinemonth", 'int'), GETPOST("timelineday", 'int'), GETPOST("timelineyear", 'int')); + // TODO Check that ($task_time->fk_user == $user->id || in_array($task_time->fk_user, $childids)) + + $object->timespent_id = $_POST["lineid"]; + $object->timespent_note = $_POST["timespent_note_line"]; + $object->timespent_old_duration = $_POST["old_duration"]; + $object->timespent_duration = $_POST["new_durationhour"] * 60 * 60; // We store duration in seconds + $object->timespent_duration += ($_POST["new_durationmin"] ? $_POST["new_durationmin"] : 0) * 60; // We store duration in seconds + if (GETPOST("timelinehour") != '' && GETPOST("timelinehour") >= 0) // If hour was entered + { + $object->timespent_date = dol_mktime(GETPOST("timelinehour"), GETPOST("timelinemin"), 0, GETPOST("timelinemonth"), GETPOST("timelineday"), GETPOST("timelineyear")); @@ -331,21 +278,21 @@ - } else { - $object->timespent_date = dol_mktime(12, 0, 0, GETPOST("timelinemonth", 'int'), GETPOST("timelineday", 'int'), GETPOST("timelineyear", 'int')); - } - $object->timespent_fk_user = GETPOST("userid_line", 'int'); - $object->timespent_fk_product = GETPOST("fk_product", 'int'); - $object->timespent_invoiceid = GETPOST("invoiceid", 'int'); - $object->timespent_invoicelineid = GETPOST("invoicelineid", 'int'); - $result = 0; - - if (in_array($object->timespent_fk_user, $childids) || $user->hasRight('projet', 'all', 'creer')) { - $result = $object->updateTimeSpent($user); - - if ($result >= 0) { - setEventMessages($langs->trans("RecordSaved"), null, 'mesgs'); - } else { - setEventMessages($langs->trans($object->error), null, 'errors'); - $error++; - } - } - } - } else { + } + else + { + $object->timespent_date = dol_mktime(12, 0, 0, GETPOST("timelinemonth"), GETPOST("timelineday"), GETPOST("timelineyear")); + } + $object->timespent_fk_user = $_POST["userid_line"]; + + $result = $object->updateTimeSpent($user); + if ($result >= 0) + { + setEventMessages($langs->trans("RecordSaved"), null, 'mesgs'); + } + else + { + setEventMessages($langs->trans($object->error), null, 'errors'); + $error++; + } + } + } + else + { @@ -356,14 +303,16 @@ -if ($action == 'confirm_deleteline' && $confirm == "yes" && ($user->hasRight('projet', 'time') || $user->hasRight('projet', 'all', 'creer'))) { - $object->fetchTimeSpent(GETPOST('lineid', 'int')); // load properties like $object->timespent_xxx - - if (in_array($object->timespent_fk_user, $childids) || $user->hasRight('projet', 'all', 'creer')) { - $result = $object->delTimeSpent($user); // delete line with $object->timespent_id - - if ($result < 0) { - $langs->load("errors"); - setEventMessages($langs->trans($object->error), null, 'errors'); - $error++; - $action = ''; - } else { - setEventMessages($langs->trans("RecordDeleted"), null, 'mesgs'); - } +if ($action == 'confirm_delete' && $confirm == "yes" && $user->rights->projet->lire) +{ + $object->fetchTimeSpent(GETPOST('lineid', 'int')); + // TODO Check that ($task_time->fk_user == $user->id || in_array($task_time->fk_user, $childids)) + $result = $object->delTimeSpent($user); + + if ($result < 0) + { + $langs->load("errors"); + setEventMessages($langs->trans($object->error), null, 'errors'); + $error++; + $action = ''; + } + else + { + setEventMessages($langs->trans("RecordDeleted"), null, 'mesgs'); @@ -373,3 +322,5 @@ -// Retrieve First Task ID of Project if withprojet is on to allow project prev next to work -if (!empty($project_ref) && !empty($withproject)) { - if ($projectstatic->fetch(0, $project_ref) > 0) { +// Retreive First Task ID of Project if withprojet is on to allow project prev next to work +if (!empty($project_ref) && !empty($withproject)) +{ + if ($projectstatic->fetch(0, $project_ref) > 0) + { @@ -377 +328,2 @@ - if (count($tasksarray) > 0) { + if (count($tasksarray) > 0) + { @@ -379,2 +331,4 @@ - } else { - header("Location: " . DOL_URL_ROOT . '/projet/tasks.php?id=' . $projectstatic->id . ($withproject ? '&withproject=1' : '') . (empty($mode) ? '' : '&mode=' . $mode)); + } + else + { + header("Location: ".DOL_URL_ROOT.'/projet/tasks.php?id='.$projectstatic->id.($withproject ? '&withproject=1' : '').(empty($mode) ? '' : '&mode='.$mode)); @@ -388 +342,2 @@ -if (GETPOST('projectid', 'int') > 0) { +if (GETPOST('projectid', 'int') > 0) +{ @@ -392,3 +347 @@ - if (!empty($projectstatic->socid)) { - $projectstatic->fetch_thirdparty(); - } + if (!empty($projectstatic->socid)) $projectstatic->fetch_thirdparty(); @@ -396 +349,3 @@ -} elseif (GETPOST('project_ref', 'alpha')) { +} +elseif (GETPOST('project_ref', 'alpha')) +{ @@ -400 +355,3 @@ -} elseif ($id > 0) { +} +elseif ($id > 0) +{ @@ -404,8 +361,9 @@ -// If not task selected and no project selected -if ($id <= 0 && $projectidforalltimes == 0) { - $allprojectforuser = $user->id; -} - -if ($action == 'confirm_generateinvoice') { - if (!empty($projectstatic->socid)) { - $projectstatic->fetch_thirdparty(); + +if ($action == 'confirm_generateinvoice') +{ + if (!empty($projectstatic->socid)) $projectstatic->fetch_thirdparty(); + + + if (!($projectstatic->thirdparty->id > 0)) + { + setEventMessages($langs->trans("ThirdPartyRequiredToGenerateInvoice"), null, 'errors'); @@ -413,7 +371,5 @@ - - if (!($projectstatic->thirdparty->id > 0)) { - setEventMessages($langs->trans("ThirdPartyRequiredToGenerateInvoice"), null, 'errors'); - } else { - include_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php'; - include_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php'; - include_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php'; + else + { + include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; + include_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; + include_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; @@ -429,5 +385,5 @@ - $invoiceToUse = GETPOST('invoiceid', 'int'); - - $prodDurationHoursBase = 1.0; - $product_data_cache = array(); - if ($idprod > 0) { + $invoiceToUse = GETPOST('invoiceid', 'int'); + + $prodDurationHours = 1.0; + if ($idprod > 0) + { @@ -435,11 +391,13 @@ - if ($result < 0) { - $error++; - setEventMessages($tmpproduct->error, $tmpproduct->errors, 'errors'); - } - - $prodDurationHoursBase = $tmpproduct->getProductDurationHours(); - if ($prodDurationHoursBase < 0) { - $error++; - $langs->load("errors"); - setEventMessages(null, $tmpproduct->errors, 'errors'); - } + if ($tmpproduct->duration_unit == 'i') + $prodDurationHours = 1. / 60; + if ($tmpproduct->duration_unit == 'h') + $prodDurationHours = 1.; + if ($tmpproduct->duration_unit == 'd') + $prodDurationHours = 24.; + if ($tmpproduct->duration_unit == 'w') + $prodDurationHours = 24. * 7; + if ($tmpproduct->duration_unit == 'm') + $prodDurationHours = 24. * 30; + if ($tmpproduct->duration_unit == 'y') + $prodDurationHours = 24. * 365; + $prodDurationHours *= $tmpproduct->duration_value; @@ -448 +405,0 @@ - @@ -453,3 +410,3 @@ - } else { - $prodDurationHoursBase = 1; - + } + else + { @@ -465,18 +422,19 @@ - $tmpinvoice->cond_reglement_id = $projectstatic->thirdparty->cond_reglement_id; - $tmpinvoice->mode_reglement_id = $projectstatic->thirdparty->mode_reglement_id; - $tmpinvoice->fk_account = $projectstatic->thirdparty->fk_account; - - if ($invoiceToUse) { - $tmpinvoice->fetch($invoiceToUse); - } else { - $result = $tmpinvoice->create($user); - if ($result <= 0) { - $error++; - setEventMessages($tmpinvoice->error, $tmpinvoice->errors, 'errors'); - } - } - - if (!$error) { - if ($generateinvoicemode == 'onelineperuser') { // 1 line per user (and per product) - $arrayoftasks = array(); - foreach ($toselect as $key => $value) { + + if ($invoiceToUse) { + $tmpinvoice->fetch($invoiceToUse); + } + else { + $result = $tmpinvoice->create($user); + if ($result <= 0) + { + $error++; + setEventMessages($tmpinvoice->error, $tmpinvoice->errors, 'errors'); + } + } + + if (!$error) + { + if ($generateinvoicemode == 'onelineperuser') { + $arrayoftasks = array(); + foreach ($toselect as $key => $value) + { @@ -484,6 +442,7 @@ - $object->fetchTimeSpent($value); // $value is ID of 1 line in timespent table - $arrayoftasks[$object->timespent_fk_user][(int) $object->timespent_fk_product]['timespent'] += $object->timespent_duration; - $arrayoftasks[$object->timespent_fk_user][(int) $object->timespent_fk_product]['totalvaluetodivideby3600'] += ($object->timespent_duration * $object->timespent_thm); - } - - foreach ($arrayoftasks as $userid => $data) { + $object->fetchTimeSpent($value); + $arrayoftasks[$object->timespent_fk_user]['timespent'] += $object->timespent_duration; + $arrayoftasks[$object->timespent_fk_user]['totalvaluetodivideby3600'] += ($object->timespent_duration * $object->timespent_thm); + } + + foreach ($arrayoftasks as $userid => $value) + { @@ -490,0 +450 @@ + //$pu_ht = $value['timespent'] * $fuser->thm; @@ -493,86 +453,73 @@ - foreach ($data as $fk_product => $timespent_data) { - // Define qty per hour - $qtyhour = $timespent_data['timespent'] / 3600; - $qtyhourtext = convertSecondToTime($timespent_data['timespent'], 'all', $conf->global->MAIN_DURATION_OF_WORKDAY); - - // Set the unit price we want to sell the time, for this user - if (getDolGlobalInt('PROJECT_USE_REAL_COST_FOR_TIME_INVOICING')) { - // We set unit price to 0 to force the use of the rate saved during recording - $pu_ht = 0; - } elseif ($idprod <= 0) { - // We want to sell all the time spent with the last hourly rate of user - // -> but what about choice user selected ? add idprod test - $pu_ht = $fuser->thm; - } - - // If no unit price known for user, we use the price recorded when recording timespent. - if (empty($pu_ht)) { - if ($timespent_data['timespent']) { - $pu_ht = price2num(($timespent_data['totalvaluetodivideby3600'] / $timespent_data['timespent']), 'MU'); - } - } - - // Add lines - $prodDurationHours = $prodDurationHoursBase; - $idprodline = $idprod; - $pu_htline = $pu_ht; - $txtvaline = $txtva; - $localtax1line = $localtax1; - $localtax2line = $localtax2; - - // If a particular product/service was defined for the task - if (!empty($fk_product) && ($fk_product > 0) && ($fk_product !== $idprod)) { - if (!array_key_exists($fk_product, $product_data_cache)) { - $result = $tmpproduct->fetch($fk_product); - if ($result < 0) { - $error++; - setEventMessages($tmpproduct->error, $tmpproduct->errors, 'errors'); - } - $prodDurationHours = $tmpproduct->getProductDurationHours(); - if ($prodDurationHours < 0) { - $error++; - $langs->load("errors"); - setEventMessages(null, $tmpproduct->errors, 'errors'); - } - - $dataforprice = $tmpproduct->getSellPrice($mysoc, $projectstatic->thirdparty, 0); - - $pu_htline = empty($dataforprice['pu_ht']) ? 0 : $dataforprice['pu_ht']; - $txtvaline = $dataforprice['tva_tx']; - $localtax1line = $dataforprice['localtax1']; - $localtax2line = $dataforprice['localtax2']; - - $product_data_cache[$fk_product] = array('duration' => $prodDurationHours, 'dataforprice' => $dataforprice); - } else { - $prodDurationHours = $product_data_cache[$fk_product]['duration']; - $pu_htline = empty($product_data_cache[$fk_product]['dataforprice']['pu_ht']) ? 0 : $product_data_cache[$fk_product]['dataforprice']['pu_ht']; - $txtvaline = $product_data_cache[$fk_product]['dataforprice']['tva_tx']; - $localtax1line = $product_data_cache[$fk_product]['dataforprice']['localtax1']; - $localtax2line = $product_data_cache[$fk_product]['dataforprice']['localtax2']; - } - $idprodline = $fk_product; - } - - // Add lines - $lineid = $tmpinvoice->addline($langs->trans("TimeSpentForInvoice", $username) . ' : ' . $qtyhourtext, $pu_htline, round($qtyhour / $prodDurationHours, 2), $txtvaline, $localtax1line, $localtax2line, ($idprodline > 0 ? $idprodline : 0)); - if ($lineid < 0) { - $error++; - setEventMessages(null, $tmpinvoice->errors, 'errors'); - } - - // Update lineid into line of timespent - $sql = 'UPDATE '.MAIN_DB_PREFIX.'element_time SET invoice_line_id = '.((int) $lineid).', invoice_id = '.((int) $tmpinvoice->id); - $sql .= ' WHERE rowid IN ('.$db->sanitize(join(',', $toselect)).') AND fk_user = '.((int) $userid); - $result = $db->query($sql); - if (!$result) { - $error++; - setEventMessages($db->lasterror(), null, 'errors'); - break; - } - } - } - } elseif ($generateinvoicemode == 'onelineperperiod') { // One line for each time spent line - $arrayoftasks = array(); - - $withdetail = GETPOST('detail_time_duration', 'alpha'); - foreach ($toselect as $key => $value) { + // Define qty per hour + $qtyhour = $value['timespent'] / 3600; + $qtyhourtext = convertSecondToTime($value['timespent'], 'all', $conf->global->MAIN_DURATION_OF_WORKDAY); + + // If no unit price known + if (empty($pu_ht)) + { + $pu_ht = price2num($value['totalvaluetodivideby3600'] / 3600, 'MU'); + } + + // Add lines + $lineid = $tmpinvoice->addline($langs->trans("TimeSpentForInvoice", $username).' : '.$qtyhourtext, $pu_ht, round($qtyhour / $prodDurationHours, 2), $txtva, $localtax1, $localtax2, ($idprod > 0 ? $idprod : 0)); + + // Update lineid into line of timespent + $sql = 'UPDATE '.MAIN_DB_PREFIX.'projet_task_time SET invoice_line_id = '.$lineid.', invoice_id = '.$tmpinvoice->id; + $sql .= ' WHERE rowid in ('.join(',', $toselect).') AND fk_user = '.$userid; + $result = $db->query($sql); + if (!$result) + { + $error++; + setEventMessages($db->lasterror(), null, 'errors'); + break; + } + } + } + elseif ($generateinvoicemode == 'onelineperperiod') { + $arrayoftasks = array(); + foreach ($toselect as $key => $value) + { + // Get userid, timepent + $object->fetchTimeSpent($value); + $arrayoftasks[$object->timespent_id]['timespent'] = $object->timespent_duration; + $arrayoftasks[$object->timespent_id]['totalvaluetodivideby3600'] = $object->timespent_duration * $object->timespent_thm; + $arrayoftasks[$object->timespent_id]['note'] = $object->timespent_note; + $arrayoftasks[$object->timespent_id]['user'] = $object->timespent_fk_user; + } + + foreach ($arrayoftasks as $timespent_id => $value) + { + $userid = $value['user']; + $fuser->fetch($userid); + //$pu_ht = $value['timespent'] * $fuser->thm; + $username = $fuser->getFullName($langs); + + // Define qty per hour + $qtyhour = $value['timespent'] / 3600; + $qtyhourtext = convertSecondToTime($value['timespent'], 'all', $conf->global->MAIN_DURATION_OF_WORKDAY); + + // If no unit price known + if (empty($pu_ht)) + { + $pu_ht = price2num($value['totalvaluetodivideby3600'] / 3600, 'MU'); + } + + // Add lines + $lineid = $tmpinvoice->addline($value['note'], $pu_ht, round($qtyhour / $prodDurationHours, 2), $txtva, $localtax1, $localtax2, ($idprod > 0 ? $idprod : 0)); + + // Update lineid into line of timespent + $sql = 'UPDATE '.MAIN_DB_PREFIX.'projet_task_time SET invoice_line_id = '.$lineid.', invoice_id = '.$tmpinvoice->id; + $sql .= ' WHERE rowid in ('.join(',', $toselect).') AND fk_user = '.$userid; + $result = $db->query($sql); + if (!$result) + { + $error++; + setEventMessages($db->lasterror(), null, 'errors'); + break; + } + } + } + elseif ($generateinvoicemode == 'onelinepertask') { + $arrayoftasks = array(); + foreach ($toselect as $key => $value) + { @@ -581,0 +529,6 @@ + $arrayoftasks[$object->id]['timespent'] += $object->timespent_duration; + $arrayoftasks[$object->id]['totalvaluetodivideby3600'] += $object->timespent_duration * $object->timespent_thm; + } + + foreach ($arrayoftasks as $task_id => $value) + { @@ -583,26 +536 @@ - $ftask->fetch($object->id); - - $fuser->fetch($object->timespent_fk_user); - $username = $fuser->getFullName($langs); - - $arrayoftasks[$object->timespent_id]['timespent'] = $object->timespent_duration; - $arrayoftasks[$object->timespent_id]['totalvaluetodivideby3600'] = $object->timespent_duration * $object->timespent_thm; - $arrayoftasks[$object->timespent_id]['note'] = $ftask->ref . ' - ' . $ftask->label . ' - ' . $username; - $arrayoftasks[$object->timespent_id]['note'] = dol_concatdesc($arrayoftasks[$object->timespent_id]['note'], $object->timespent_note); - - if (!empty($withdetail)) { - if (!empty($object->timespent_withhour)) { - $arrayoftasks[$object->timespent_id]['note'] = dol_concatdesc($arrayoftasks[$object->timespent_id]['note'], $langs->trans("Date") . ': ' . dol_print_date($object->timespent_datehour)); - } else { - $arrayoftasks[$object->timespent_id]['note'] = dol_concatdesc($arrayoftasks[$object->timespent_id]['note'], $langs->trans("Date") . ': ' . dol_print_date($object->timespent_date)); - } - $arrayoftasks[$object->timespent_id]['note'] = dol_concatdesc($arrayoftasks[$object->timespent_id]['note'], $langs->trans("Duration") . ': ' . convertSecondToTime($object->timespent_duration, 'all', $conf->global->MAIN_DURATION_OF_WORKDAY)); - } - $arrayoftasks[$object->timespent_id]['user'] = $object->timespent_fk_user; - $arrayoftasks[$object->timespent_id]['fk_product'] = $object->timespent_fk_product; - } - - foreach ($arrayoftasks as $timespent_id => $value) { - $userid = $value['user']; - //$pu_ht = $value['timespent'] * $fuser->thm; - + $ftask->fetch($task_id); @@ -610,0 +539 @@ + $qtyhourtext = convertSecondToTime($value['timespent'], 'all', $conf->global->MAIN_DURATION_OF_WORKDAY); @@ -613 +542,2 @@ - if (empty($pu_ht)) { + if (empty($pu_ht)) + { @@ -618,44 +548,2 @@ - $prodDurationHours = $prodDurationHoursBase; - $idprodline = $idprod; - $pu_htline = $pu_ht; - $txtvaline = $txtva; - $localtax1line = $localtax1; - $localtax2line = $localtax2; - - if (!empty($value['fk_product']) && $value['fk_product'] !== $idprod) { - if (!array_key_exists($value['fk_product'], $product_data_cache)) { - $result = $tmpproduct->fetch($value['fk_product']); - if ($result < 0) { - $error++; - setEventMessages($tmpproduct->error, $tmpproduct->errors, 'errors'); - } - $prodDurationHours = $tmpproduct->getProductDurationHours(); - if ($prodDurationHours < 0) { - $error++; - $langs->load("errors"); - setEventMessages(null, $tmpproduct->errors, 'errors'); - } - - $dataforprice = $tmpproduct->getSellPrice($mysoc, $projectstatic->thirdparty, 0); - - $pu_htline = empty($dataforprice['pu_ht']) ? 0 : $dataforprice['pu_ht']; - $txtvaline = $dataforprice['tva_tx']; - $localtax1line = $dataforprice['localtax1']; - $localtax2line = $dataforprice['localtax2']; - - $product_data_cache[$value['fk_product']] = array('duration' => $prodDurationHours, 'dataforprice' => $dataforprice); - } else { - $prodDurationHours = $product_data_cache[$value['fk_product']]['duration']; - $pu_htline = empty($product_data_cache[$value['fk_product']]['dataforprice']['pu_ht']) ? 0 : $product_data_cache[$value['fk_product']]['dataforprice']['pu_ht']; - $txtvaline = $product_data_cache[$value['fk_product']]['dataforprice']['tva_tx']; - $localtax1line = $product_data_cache[$value['fk_product']]['dataforprice']['localtax1']; - $localtax2line = $product_data_cache[$value['fk_product']]['dataforprice']['localtax2']; - } - $idprodline = $value['fk_product']; - } - $lineid = $tmpinvoice->addline($value['note'], $pu_htline, round($qtyhour / $prodDurationHours, 2), $txtvaline, $localtax1line, $localtax2line, ($idprodline > 0 ? $idprodline : 0)); - if ($lineid < 0) { - $error++; - setEventMessages(null, $tmpinvoice->errors, 'errors'); - } - //var_dump($lineid);exit; + $lineName = $ftask->ref.' - '.$ftask->label; + $lineid = $tmpinvoice->addline($lineName, $pu_ht, round($qtyhour / $prodDurationHours, 2), $txtva, $localtax1, $localtax2, ($idprod > 0 ? $idprod : 0)); @@ -664,2 +552,2 @@ - $sql = 'UPDATE '.MAIN_DB_PREFIX.'element_time SET invoice_line_id = '.((int) $lineid).', invoice_id = '.((int) $tmpinvoice->id); - $sql .= ' WHERE rowid IN ('.$db->sanitize(join(',', $toselect)).') AND fk_user = '.((int) $userid); + $sql = 'UPDATE '.MAIN_DB_PREFIX.'projet_task_time SET invoice_line_id = '.$lineid.', invoice_id = '.$tmpinvoice->id; + $sql .= ' WHERE rowid in ('.join(',', $toselect).')'; @@ -667 +555,2 @@ - if (!$result) { + if (!$result) + { @@ -673,105 +562,5 @@ - } elseif ($generateinvoicemode == 'onelinepertask') { // One line for each different task - $arrayoftasks = array(); - foreach ($toselect as $key => $value) { - // Get userid, timepent - $object->fetchTimeSpent($value); // Call method to get list of timespent for a timespent line id (We use the utiliy method found into Task object) - // $object->id is now the task id - $arrayoftasks[$object->id][(int) $object->timespent_fk_product]['timespent'] += $object->timespent_duration; - $arrayoftasks[$object->id][(int) $object->timespent_fk_product]['totalvaluetodivideby3600'] += ($object->timespent_duration * $object->timespent_thm); - } - - foreach ($arrayoftasks as $task_id => $data) { - $ftask = new Task($db); - $ftask->fetch($task_id); - - foreach ($data as $fk_product => $timespent_data) { - $qtyhour = $timespent_data['timespent'] / 3600; - $qtyhourtext = convertSecondToTime($timespent_data['timespent'], 'all', $conf->global->MAIN_DURATION_OF_WORKDAY); - - // Add lines - $prodDurationHours = $prodDurationHoursBase; - $idprodline = $idprod; - $pu_htline = $pu_ht; - $txtvaline = $txtva; - $localtax1line = $localtax1; - $localtax2line = $localtax2; - - if (!empty($fk_product) && $fk_product !== $idprod) { - if (!array_key_exists($fk_product, $product_data_cache)) { - $result = $tmpproduct->fetch($fk_product); - if ($result < 0) { - $error++; - setEventMessages($tmpproduct->error, $tmpproduct->errors, 'errors'); - } - $prodDurationHours = $tmpproduct->getProductDurationHours(); - if ($prodDurationHours < 0) { - $error++; - $langs->load("errors"); - setEventMessages(null, $tmpproduct->errors, 'errors'); - } - - $dataforprice = $tmpproduct->getSellPrice($mysoc, $projectstatic->thirdparty, 0); - - $pu_htline = empty($dataforprice['pu_ht']) ? 0 : $dataforprice['pu_ht']; - $txtvaline = $dataforprice['tva_tx']; - $localtax1line = $dataforprice['localtax1']; - $localtax2line = $dataforprice['localtax2']; - - $product_data_cache[$fk_product] = array('duration' => $prodDurationHours, 'dataforprice' => $dataforprice); - } else { - $prodDurationHours = $product_data_cache[$fk_product]['duration']; - $pu_htline = empty($product_data_cache[$fk_product]['dataforprice']['pu_ht']) ? 0 : $product_data_cache[$fk_product]['dataforprice']['pu_ht']; - $txtvaline = $product_data_cache[$fk_product]['dataforprice']['tva_tx']; - $localtax1line = $product_data_cache[$fk_product]['dataforprice']['localtax1']; - $localtax2line = $product_data_cache[$fk_product]['dataforprice']['localtax2']; - } - $idprodline = $fk_product; - } - - - if ($idprodline > 0) { - // If a product is defined, we msut use the $prodDurationHours and $pu_ht of product (already set previously). - $pu_ht_for_task = $pu_htline; - // If we want to reuse the value of timespent (so use same price than cost price) - if (getDolGlobalString('PROJECT_TIME_SPENT_INTO_INVOICE_USE_VALUE')) { - $pu_ht_for_task = price2num($timespent_data['totalvaluetodivideby3600'] / $timespent_data['timespent'], 'MU') * $prodDurationHours; - } - $pa_ht = price2num($timespent_data['totalvaluetodivideby3600'] / $timespent_data['timespent'], 'MU') * $prodDurationHours; - } else { - // If not product used, we use the hour unit for duration and unit price. - $pu_ht_for_task = 0; - // If we want to reuse the value of timespent (so use same price than cost price) - if (getDolGlobalString('PROJECT_TIME_SPENT_INTO_INVOICE_USE_VALUE')) { - $pu_ht_for_task = price2num($timespent_data['totalvaluetodivideby3600'] / $timespent_data['timespent'], 'MU'); - } - $pa_ht = price2num($timespent_data['totalvaluetodivideby3600'] / $timespent_data['timespent'], 'MU'); - } - - // Add lines - $date_start = ''; - $date_end = ''; - $lineName = $ftask->ref . ' - ' . $ftask->label; - $lineid = $tmpinvoice->addline($lineName, $pu_ht_for_task, price2num($qtyhour / $prodDurationHours, 'MS'), $txtvaline, $localtax1line, $localtax2line, ($idprodline > 0 ? $idprodline : 0), 0, $date_start, $date_end, 0, 0, '', 'HT', 0, 1, -1, 0, '', 0, 0, null, $pa_ht); - if ($lineid < 0) { - $error++; - setEventMessages($tmpinvoice->error, $tmpinvoice->errors, 'errors'); - break; - } - - if (!$error) { - // Update lineid into line of timespent - $sql = 'UPDATE ' . MAIN_DB_PREFIX . 'element_time SET invoice_line_id = ' . ((int) $lineid) . ', invoice_id = ' . ((int) $tmpinvoice->id); - $sql .= ' WHERE rowid IN (' . $db->sanitize(join(',', $toselect)) . ')'; - $result = $db->query($sql); - if (!$result) { - $error++; - setEventMessages($db->lasterror(), null, 'errors'); - break; - } - } - } - } - } - } - - if (!$error) { + } + } + + if (!$error) + { @@ -779,4 +568 @@ - $mesg = $langs->trans("InvoiceGeneratedFromTimeSpent", '{s1}'); - $mesg = str_replace('{s1}', $urltoinvoice, $mesg); - setEventMessages($mesg, null, 'mesgs'); - + setEventMessages($langs->trans("InvoiceGeneratedFromTimeSpent", $urltoinvoice), null, 'mesgs'); @@ -786,80 +572,3 @@ - } else { - $db->rollback(); - } - } -} - -if ($action == 'confirm_generateinter') { - $langs->load('interventions'); - - if (!empty($projectstatic->socid)) { - $projectstatic->fetch_thirdparty(); - } - - if (!($projectstatic->thirdparty->id > 0)) { - setEventMessages($langs->trans("ThirdPartyRequiredToGenerateIntervention"), null, 'errors'); - } else { - include_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php'; - include_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php'; - include_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php'; - - - require_once DOL_DOCUMENT_ROOT . '/fichinter/class/fichinter.class.php'; - $tmpinter = new Fichinter($db); - $tmptimespent = new Task($db); - $fuser = new User($db); - - $db->begin(); - $interToUse = GETPOST('interid', 'int'); - - - $tmpinter->socid = $projectstatic->thirdparty->id; - $tmpinter->date = dol_mktime(GETPOST('rehour', 'int'), GETPOST('remin', 'int'), GETPOST('resec', 'int'), GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int')); - $tmpinter->fk_project = $projectstatic->id; - $tmpinter->description = $projectstatic->title . (!empty($projectstatic->description) ? '-' . $projectstatic->label : ''); - - if ($interToUse) { - $tmpinter->fetch($interToUse); - } else { - $result = $tmpinter->create($user); - if ($result <= 0) { - $error++; - setEventMessages($tmpinter->error, $tmpinter->errors, 'errors'); - } - } - - if (!$error) { - $arrayoftasks = array(); - foreach ($toselect as $key => $value) { - // Get userid, timespent - $object->fetchTimeSpent($value); - // $object->id is the task id - $arrayoftasks[$object->timespent_id]['id'] = $object->id; - $arrayoftasks[$object->timespent_id]['timespent'] = $object->timespent_duration; - $arrayoftasks[$object->timespent_id]['totalvaluetodivideby3600'] = $object->timespent_duration * $object->timespent_thm; - $arrayoftasks[$object->timespent_id]['note'] = $object->timespent_note; - $arrayoftasks[$object->timespent_id]['date'] = date('Y-m-d H:i:s', $object->timespent_datehour); - } - - foreach ($arrayoftasks as $timespent_id => $value) { - $ftask = new Task($db); - $ftask->fetch($value['id']); - // Define qty per hour - $qtyhour = $value['timespent'] / 3600; - $qtyhourtext = convertSecondToTime($value['timespent'], 'all', $conf->global->MAIN_DURATION_OF_WORKDAY); - - // Add lines - $lineid = $tmpinter->addline($user, $tmpinter->id, $ftask->label . (!empty($value['note']) ? ' - ' . $value['note'] : ''), $value['date'], $value['timespent']); - } - } - - if (!$error) { - $urltointer = $tmpinter->getNomUrl(0); - $mesg = $langs->trans("InterventionGeneratedFromTimeSpent", '{s1}'); - $mesg = str_replace('{s1}', $urltointer, $mesg); - setEventMessages($mesg, null, 'mesgs'); - - //var_dump($tmpinvoice); - - $db->commit(); - } else { + } + else + { @@ -874,0 +584,4 @@ + +$arrayofselected = is_array($toselect) ? $toselect : array(); + +llxHeader("", $langs->trans("Task")); @@ -880,12 +593,3 @@ -//$result = $projectstatic->fetch($object->fk_project); -$arrayofselected = is_array($toselect) ? $toselect : array(); - -$title = $object->ref . ' - ' . $langs->trans("TimeSpent"); -if (!empty($withproject)) { - $title .= ' | ' . $langs->trans("Project") . (!empty($projectstatic->ref) ? ': ' . $projectstatic->ref : ''); -} -$help_url = ''; - -llxHeader('', $title, $help_url); - -if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser > 0) { + +if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0) +{ @@ -895 +599,2 @@ - if ($projectidforalltimes > 0) { + if ($projectidforalltimes > 0) + { @@ -897,3 +602 @@ - if (!empty($projectstatic->socid)) { - $projectstatic->fetch_thirdparty(); - } + if (!empty($projectstatic->socid)) $projectstatic->fetch_thirdparty(); @@ -901,4 +604,4 @@ - } elseif ($object->fetch($id, $ref) >= 0) { - if (getDolGlobalString('PROJECT_ALLOW_COMMENT_ON_TASK') && method_exists($object, 'fetchComments') && empty($object->comments)) { - $object->fetchComments(); - } + } + elseif ($object->fetch($id, $ref) >= 0) + { + if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_TASK) && method_exists($object, 'fetchComments') && empty($object->comments)) $object->fetchComments(); @@ -906,6 +609,2 @@ - if (getDolGlobalString('PROJECT_ALLOW_COMMENT_ON_PROJECT') && method_exists($projectstatic, 'fetchComments') && empty($projectstatic->comments)) { - $projectstatic->fetchComments(); - } - if (!empty($projectstatic->socid)) { - $projectstatic->fetch_thirdparty(); - } + if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($projectstatic, 'fetchComments') && empty($projectstatic->comments)) $projectstatic->fetchComments(); + if (!empty($projectstatic->socid)) $projectstatic->fetch_thirdparty(); @@ -920,2 +619,4 @@ - if ($projectstatic->id > 0) { - if ($withproject) { + if ($projectstatic->id > 0) + { + if ($withproject) + { @@ -923,5 +624,2 @@ - if (empty($id) || $tab == 'timespent') { - $tab = 'timespent'; - } else { - $tab = 'tasks'; - } + if (empty($id) || $tab == 'timespent') $tab = 'timespent'; + else $tab = 'tasks'; @@ -930,12 +628,3 @@ - print dol_get_fiche_head($head, $tab, $langs->trans("Project"), -1, ($projectstatic->public ? 'projectpub' : 'project')); - - $param = ((!empty($mode) && $mode == 'mine') ? '&mode=mine' : ''); - if ($search_user) { - $param .= '&search_user=' . ((int) $search_user); - } - if ($search_month) { - $param .= '&search_month=' . ((int) $search_month); - } - if ($search_year) { - $param .= '&search_year=' . ((int) $search_year); - } + dol_fiche_head($head, $tab, $langs->trans("Project"), -1, ($projectstatic->public ? 'projectpub' : 'project')); + + $param = ($mode == 'mine' ? '&mode=mine' : ''); @@ -951,2 +640,3 @@ - if (!empty($projectstatic->thirdparty->id) && $projectstatic->thirdparty->id > 0) { - $morehtmlref .= '
' . $projectstatic->thirdparty->getNomUrl(1, 'project'); + if ($projectstatic->thirdparty->id > 0) + { + $morehtmlref .= '
'.$langs->trans('ThirdParty').' : '.$projectstatic->thirdparty->getNomUrl(1, 'project'); @@ -957 +647,2 @@ - if (!$user->hasRight('projet', 'all', 'lire')) { + if (!$user->rights->projet->all->lire) + { @@ -959,4 +650,4 @@ - $projectstatic->next_prev_filter = "rowid IN (" . $db->sanitize(count($objectsListId) ? join(',', array_keys($objectsListId)) : '0') . ")"; - } - - dol_banner_tab($projectstatic, 'project_ref', $linkback, 1, 'ref', 'ref', $morehtmlref, $param); + $projectstatic->next_prev_filter = " rowid in (".(count($objectsListId) ?join(',', array_keys($objectsListId)) : '0').")"; + } + + dol_banner_tab($projectstatic, 'project_ref', $linkback, 1, 'ref', 'ref', $morehtmlref); @@ -971,30 +662,26 @@ - if (getDolGlobalString('PROJECT_USE_OPPORTUNITIES') || !getDolGlobalString('PROJECT_HIDE_TASKS') || isModEnabled('eventorganization')) { - print ''; - print $langs->trans("Usage"); - print ''; - print ''; - if (getDolGlobalString('PROJECT_USE_OPPORTUNITIES')) { - print 'usage_opportunity ? ' checked="checked"' : '')) . '"> '; - $htmltext = $langs->trans("ProjectFollowOpportunity"); - print $form->textwithpicto($langs->trans("ProjectFollowOpportunity"), $htmltext); - print '
'; - } - if (!getDolGlobalString('PROJECT_HIDE_TASKS')) { - print 'usage_task ? ' checked="checked"' : '')) . '"> '; - $htmltext = $langs->trans("ProjectFollowTasks"); - print $form->textwithpicto($langs->trans("ProjectFollowTasks"), $htmltext); - print '
'; - } - if (!getDolGlobalString('PROJECT_HIDE_TASKS') && getDolGlobalString('PROJECT_BILL_TIME_SPENT')) { - print 'usage_bill_time ? ' checked="checked"' : '')) . '"> '; - $htmltext = $langs->trans("ProjectBillTimeDescription"); - print $form->textwithpicto($langs->trans("BillTime"), $htmltext); - print '
'; - } - if (isModEnabled('eventorganization')) { - print 'usage_organize_event ? ' checked="checked"' : '')) . '"> '; - $htmltext = $langs->trans("EventOrganizationDescriptionLong"); - print $form->textwithpicto($langs->trans("ManageOrganizeEvent"), $htmltext); - } - print ''; - } + print ''; + print $langs->trans("Usage"); + print ''; + print ''; + if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) + { + print 'usage_opportunity ? ' checked="checked"' : '')).'"> '; + $htmltext = $langs->trans("ProjectFollowOpportunity"); + print $form->textwithpicto($langs->trans("ProjectFollowOpportunity"), $htmltext); + print '
'; + } + if (empty($conf->global->PROJECT_HIDE_TASKS)) + { + print 'usage_task ? ' checked="checked"' : '')).'"> '; + $htmltext = $langs->trans("ProjectFollowTasks"); + print $form->textwithpicto($langs->trans("ProjectFollowTasks"), $htmltext); + print '
'; + } + if (!empty($conf->global->PROJECT_BILL_TIME_SPENT)) + { + print 'usage_bill_time ? ' checked="checked"' : '')).'"> '; + $htmltext = $langs->trans("ProjectBillTimeDescription"); + print $form->textwithpicto($langs->trans("BillTime"), $htmltext); + print '
'; + } + print ''; @@ -1003,8 +690,3 @@ - print '' . $langs->trans("Visibility") . ''; - if ($projectstatic->public) { - print img_picto($langs->trans('SharedProject'), 'world', 'class="paddingrightonly"'); - print $langs->trans('SharedProject'); - } else { - print img_picto($langs->trans('PrivateProject'), 'private', 'class="paddingrightonly"'); - print $langs->trans('PrivateProject'); - } + print ''.$langs->trans("Visibility").''; + if ($projectstatic->public) print $langs->trans('SharedProject'); + else print $langs->trans('PrivateProject'); @@ -1013,9 +695,2 @@ - // Budget - print '' . $langs->trans("Budget") . ''; - if (!is_null($projectstatic->budget_amount) && strcmp($projectstatic->budget_amount, '')) { - print '' . price($projectstatic->budget_amount, '', $langs, 1, 0, 0, $conf->currency) . ''; - } - print ''; - - // Date start - end project - print '' . $langs->trans("Dates") . ''; + // Date start - end + print ''.$langs->trans("DateStart").' - '.$langs->trans("DateEnd").''; @@ -1023 +698 @@ - print($start ? $start : '?'); + print ($start ? $start : '?'); @@ -1026,4 +701,7 @@ - print($end ? $end : '?'); - if ($projectstatic->hasDelay()) { - print img_warning("Late"); - } + print ($end ? $end : '?'); + if ($projectstatic->hasDelay()) print img_warning("Late"); + print ''; + + // Budget + print ''.$langs->trans("Budget").''; + if (strcmp($projectstatic->budget_amount, '')) print price($projectstatic->budget_amount, '', $langs, 1, 0, 0, $conf->currency); @@ -1034,4 +712 @@ - $savobject = $object; - $object = $projectstatic; - include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; - $object = $savobject; + //include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; @@ -1042,0 +718 @@ + print '
'; @@ -1045 +721 @@ - print ''; + print '
'; @@ -1049 +725 @@ - print dol_htmlentitiesbr($projectstatic->description); + print nl2br($projectstatic->description); @@ -1053,2 +729,2 @@ - if (isModEnabled('categorie')) { - print '
' . $langs->trans("Categories") . ''; + if ($conf->categorie->enabled) { + print '
'.$langs->trans("Categories").''; @@ -1062,0 +739 @@ + print ''; @@ -1066 +743 @@ - print dol_get_fiche_end(); + dol_fiche_end(); @@ -1070,2 +746,0 @@ - - $param = ''; @@ -1077,2 +752,4 @@ - if ($user->hasRight('projet', 'time')) { - if ($projectstatic->public || $userRead > 0) { + if ($user->rights->projet->all->lire || $user->rights->projet->lire) // To enter time, read permission is enough + { + if ($projectstatic->public || $userRead > 0) + { @@ -1081,10 +758,13 @@ - if (!empty($projectidforalltimes)) { - // We are on tab 'Time Spent' of project - $backtourl = $_SERVER['PHP_SELF'] . '?projectid=' . $projectstatic->id . ($withproject ? '&withproject=1' : ''); - $linktocreatetimeUrl = $_SERVER['PHP_SELF'] . '?' . ($withproject ? 'withproject=1' : '') . '&projectid=' . $projectstatic->id . '&action=createtime&token=' . newToken() . $param . '&backtopage=' . urlencode($backtourl); - } else { - // We are on tab 'Time Spent' of task - $backtourl = $_SERVER['PHP_SELF'] . '?id=' . $object->id . ($withproject ? '&withproject=1' : ''); - $linktocreatetimeUrl = $_SERVER['PHP_SELF'] . '?' . ($withproject ? 'withproject=1' : '') . ($object->id > 0 ? '&id=' . $object->id : '&projectid=' . $projectstatic->id) . '&action=createtime&token=' . newToken() . $param . '&backtopage=' . urlencode($backtourl); - } - } else { + if (!empty($projectidforalltimes)) // We are on tab 'Time Spent' of project + { + $backtourl = $_SERVER['PHP_SELF'].'?projectid='.$projectstatic->id.($withproject ? '&withproject=1' : ''); + $linktocreatetimeUrl = $_SERVER['PHP_SELF'].'?'.($withproject ? 'withproject=1' : '').'&projectid='.$projectstatic->id.'&action=createtime'.$param.'&backtopage='.urlencode($backtourl); + } + else // We are on tab 'Time Spent' of task + { + $backtourl = $_SERVER['PHP_SELF'].'?id='.$object->id.($withproject ? '&withproject=1' : ''); + $linktocreatetimeUrl = $_SERVER['PHP_SELF'].'?'.($withproject ? 'withproject=1' : '').($object->id > 0 ? '&id='.$object->id : '&projectid='.$projectstatic->id).'&action=createtime'.$param.'&backtopage='.urlencode($backtourl); + } + } + else + { @@ -1094,7 +774,3 @@ - } else { - $linktocreatetimeBtnStatus = -2; - $linktocreatetimeHelpText = $langs->trans("NotEnoughPermissions"); - } - - $paramsbutton = array('morecss' => 'reposition'); - $linktocreatetime = dolGetButtonTitle($langs->trans('AddTimeSpent'), $linktocreatetimeHelpText, 'fa fa-plus-circle', $linktocreatetimeUrl, '', $linktocreatetimeBtnStatus, $paramsbutton); + } + + $linktocreatetime = dolGetButtonTitle($langs->trans('AddTimeSpent'), $linktocreatetimeHelpText, 'fa fa-plus-circle', $linktocreatetimeUrl, '', $linktocreatetimeBtnStatus); @@ -1104,14 +780,9 @@ - $arrayofmassactions = array(); - - if ($projectstatic->id > 0) { - // If we are on a given project. - if ($projectstatic->usage_bill_time) { - $arrayofmassactions = array( - 'generateinvoice' => $langs->trans("GenerateBill"), - //'builddoc'=>$langs->trans("PDFMerge"), - ); - } - if (isModEnabled('ficheinter') && $user->hasRight('ficheinter', 'creer')) { - $langs->load("interventions"); - $arrayofmassactions['generateinter'] = $langs->trans("GenerateInter"); - } + if ($projectstatic->usage_bill_time) + { + $arrayofmassactions = array( + 'generateinvoice'=>$langs->trans("GenerateBill"), + //'builddoc'=>$langs->trans("PDFMerge"), + ); + //if ($user->rights->projet->creer) $arrayofmassactions['predelete']=''.$langs->trans("Delete"); + if (in_array($massaction, array('presend', 'predelete', 'generateinvoice'))) $arrayofmassactions = array(); + $massactionbutton = $form->selectMassAction('', $arrayofmassactions); @@ -1119,7 +789,0 @@ - //if ($user->rights->projet->creer) $arrayofmassactions['predelete']=''.$langs->trans("Delete"); - if (in_array($massaction, array('presend', 'predelete', 'generateinvoice', 'generateinter'))) { - $arrayofmassactions = array(); - } - $massactionbutton = $form->selectMassAction('', $arrayofmassactions); - - // Task @@ -1128 +792,2 @@ - if (empty($projectidforalltimes) && empty($allprojectforuser)) { + if (empty($projectidforalltimes)) + { @@ -1130,5 +795,5 @@ - print dol_get_fiche_head($head, 'task_time', $langs->trans("Task"), -1, 'projecttask', 0, '', 'reposition'); - - if ($action == 'deleteline') { - $urlafterconfirm = $_SERVER["PHP_SELF"] . "?" . ($object->id > 0 ? "id=" . $object->id : 'projectid=' . $projectstatic->id) . '&lineid=' . GETPOST("lineid", 'int') . ($withproject ? '&withproject=1' : ''); - print $form->formconfirm($urlafterconfirm, $langs->trans("DeleteATimeSpent"), $langs->trans("ConfirmDeleteATimeSpent"), "confirm_deleteline", '', '', 1); + dol_fiche_head($head, 'task_time', $langs->trans("Task"), -1, 'projecttask', 0, '', 'reposition'); + + if ($action == 'deleteline') + { + print $form->formconfirm($_SERVER["PHP_SELF"]."?".($object->id > 0 ? "id=".$object->id : 'projectid='.$projectstatic->id).'&lineid='.GETPOST("lineid", 'int').($withproject ? '&withproject=1' : ''), $langs->trans("DeleteATimeSpent"), $langs->trans("ConfirmDeleteATimeSpent"), "confirm_delete", '', '', 1); @@ -1138,4 +803,4 @@ - $param .= ($param ? '&' : '') . 'id=' . $object->id; // ID of task - $linkback = $withproject ? '' . $langs->trans("BackToList") . '' : ''; - - if (!GETPOST('withproject') || empty($projectstatic->id)) { + $linkback = $withproject ? ''.$langs->trans("BackToList").'' : ''; + + if (!GETPOST('withproject') || empty($projectstatic->id)) + { @@ -1143,4 +808,3 @@ - $object->next_prev_filter = "fk_projet IN (" . $db->sanitize($projectsListId) . ")"; - } else { - $object->next_prev_filter = "fk_projet = " . ((int) $projectstatic->id); - } + $object->next_prev_filter = " fk_projet in (".$projectsListId.")"; + } + else $object->next_prev_filter = " fk_projet = ".$projectstatic->id; @@ -1151 +815,2 @@ - if (empty($withproject)) { + if (empty($withproject)) + { @@ -1153 +818 @@ - $morehtmlref .= $langs->trans("Project") . ': '; + $morehtmlref .= $langs->trans("Project").': '; @@ -1158,2 +823,2 @@ - $morehtmlref .= $langs->trans("ThirdParty") . ': '; - if (!empty($projectstatic->thirdparty) && is_object($projectstatic->thirdparty)) { + $morehtmlref .= $langs->trans("ThirdParty").': '; + if (is_object($projectstatic->thirdparty)) { @@ -1171,13 +836,4 @@ - print ''; - - // Task parent - print ''; - - // Date start - Date end task - print ''; - if (!empty($allprojectforuser)) { - print ''; - } - if (empty($id)) { - print ''; - } - print ''; - print ''; - print ''; - print ''; - if (!getDolGlobalString('PROJECT_HIDE_TASKS') && getDolGlobalString('PROJECT_BILL_TIME_SPENT')) { + print ''; + if (empty($id)) print ''; + print ''; + print ''; + print ''; + print ''; + if (empty($conf->global->PROJECT_HIDE_TASKS) && !empty($conf->global->PROJECT_BILL_TIME_SPENT)) + { @@ -1756,9 +1141 @@ - - if (isModEnabled("service") && !empty($projectstatic->thirdparty) && $projectstatic->thirdparty->id > 0 && $projectstatic->usage_bill_time) { - print ''; - } - } - // Hook fields - $parameters = array('mode' => 'create'); - $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; + } @@ -1771,0 +1149 @@ + //$newdate=dol_mktime(12,0,0,$_POST["timemonth"],$_POST["timeday"],$_POST["timeyear"]); @@ -1776,6 +1153,0 @@ - if (!empty($allprojectforuser)) { - print ''; - } - @@ -1784 +1156,2 @@ - if (empty($id)) { + if (empty($id)) + { @@ -1786 +1159 @@ - $nboftasks = $formproject->selectTasks(-1, GETPOST('taskid', 'int'), 'taskid', 0, 0, 1, 1, 0, 0, 'maxwidth300', $projectstatic->id, 'progress'); + $nboftasks = $formproject->selectTasks(-1, GETPOST('taskid', 'int'), 'taskid', 0, 0, 1, 1, 0, 0, 'maxwidth300', $projectstatic->id, ''); @@ -1793 +1166,2 @@ - if (count($contactsofproject) > 0) { + if (count($contactsofproject) > 0) + { @@ -1795,11 +1169,8 @@ - if (in_array($user->id, $contactsofproject)) { - $userid = $user->id; - } else { - $userid = $contactsofproject[0]; - } - - if ($projectstatic->public) { - $contactsofproject = array(); - } - print $form->select_dolusers((GETPOST('userid', 'int') ? GETPOST('userid', 'int') : $userid), 'userid', 0, '', 0, '', $contactsofproject, 0, 0, 0, '', 0, $langs->trans("ResourceNotAssignedToProject"), 'minwidth150imp maxwidth200'); - } else { + if (in_array($user->id, $contactsofproject)) $userid = $user->id; + else $userid = $contactsofproject[0]; + + if ($projectstatic->public) $contactsofproject = array(); + print $form->select_dolusers((GETPOST('userid', 'int') ? GETPOST('userid', 'int') : $userid), 'userid', 0, '', 0, '', $contactsofproject, 0, 0, 0, '', 0, $langs->trans("ResourceNotAssignedToProject"), 'maxwidth200'); + } + else + { @@ -1807 +1178 @@ - print img_error($langs->trans('FirstAddRessourceToAllocateTime')) . ' ' . $langs->trans('FirstAddRessourceToAllocateTime'); + print img_error($langs->trans('FirstAddRessourceToAllocateTime')).' '.$langs->trans('FirstAddRessourceToAllocateTime'); @@ -1814 +1185 @@ - print ''; + print ''; @@ -1818,4 +1189,5 @@ - print ''; - } - } - - // Fields from hook - $parameters = array('mode' => 'create'); - $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; + } @@ -1850,3 +1211,2 @@ - $form->buttonsSaveCancel(); - print ''; - print ''; + print ''; + print ''; @@ -1864,8 +1224,6 @@ - $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - if (empty($reshook)) { - $moreforfilter .= $hookmanager->resPrint; - } else { - $moreforfilter = $hookmanager->resPrint; - } - - if (!empty($moreforfilter)) { + $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook + if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint; + else $moreforfilter = $hookmanager->resPrint; + + if (!empty($moreforfilter)) + { @@ -1878 +1236 @@ - $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')); // This also change content of $arrayfields + $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields @@ -1882 +1240 @@ - print '
' . $langs->trans("ChildOfTask") . ''; - if ($object->fk_task_parent > 0) { - $tasktmp = new Task($db); - $tasktmp->fetch($object->fk_task_parent); - print $tasktmp->getNomUrl(1); - } - print '
' . $langs->trans("DateStart") . ' - ' . $langs->trans("Deadline") . ''; + print ''; + + // Date start - Date end + print ''; + print ''; + print ''; + print ''; + /*print ''; + print ''; + print ''; + print '';*/ + print '
'.$langs->trans("DateStart").' - '.$langs->trans("DateEnd").''; @@ -1185 +841 @@ - print($start ? $start : '?'); + print ($start ? $start : '?'); @@ -1188,4 +844,2 @@ - print($end ? $end : '?'); - if ($object->hasDelay()) { - print img_warning("Late"); - } + print ($end ? $end : '?'); + if ($object->hasDelay()) print img_warning("Late"); @@ -1195,2 +849,3 @@ - print '
' . $langs->trans("PlannedWorkload") . ''; - if ($object->planned_workload) { + print '
'.$langs->trans("PlannedWorkload").''; + if ($object->planned_workload) + { @@ -1204 +859 @@ - print '
'; + print '
'; @@ -1210,2 +865,2 @@ - print '
' . $langs->trans("ProgressDeclared") . ''; - print $object->progress != '' ? $object->progress . ' %' : ''; + print '
'.$langs->trans("ProgressDeclared").''; + print $object->progress != '' ? $object->progress.' %' : ''; @@ -1215,2 +870,3 @@ - print '
' . $langs->trans("ProgressCalculated") . ''; - if ($object->planned_workload) { + print '
'.$langs->trans("ProgressCalculated").''; + if ($object->planned_workload) + { @@ -1218,8 +874,4 @@ - if ($tmparray['total_duration'] > 0) { - print round($tmparray['total_duration'] / $object->planned_workload * 100, 2) . ' %'; - } else { - print '0 %'; - } - } else { - print '' . $langs->trans("WorkloadNotDefined") . ''; - } + if ($tmparray['total_duration'] > 0) print round($tmparray['total_duration'] / $object->planned_workload * 100, 2).' %'; + else print '0 %'; + } + else print ''.$langs->trans("WorkloadNotDefined").''; @@ -1231,0 +884 @@ + print ''; @@ -1237,6 +890 @@ - print dol_get_fiche_end(); - } else { - if ($action == 'deleteline') { - $urlafterconfirm = $_SERVER["PHP_SELF"] . "?" . ($object->id > 0 ? "id=" . $object->id : 'projectid=' . $projectstatic->id) . '&lineid=' . GETPOST("lineid", 'int') . ($withproject ? '&withproject=1' : ''); - print $form->formconfirm($urlafterconfirm, $langs->trans("DeleteATimeSpent"), $langs->trans("ConfirmDeleteATimeSpent"), "confirm_deleteline", '', '', 1); - } + dol_fiche_end(); @@ -1246 +894,7 @@ - if ($projectstatic->id > 0 || $allprojectforuser > 0) { + if ($projectstatic->id > 0) + { + if ($action == 'deleteline' && !empty($projectidforalltimes)) + { + print $form->formconfirm($_SERVER["PHP_SELF"]."?".($object->id > 0 ? "id=".$object->id : 'projectid='.$projectstatic->id).'&lineid='.GETPOST('lineid', 'int').($withproject ? '&withproject=1' : ''), $langs->trans("DeleteATimeSpent"), $langs->trans("ConfirmDeleteATimeSpent"), "confirm_delete", '', '', 1); + } + @@ -1250,20 +903,0 @@ - $formconfirm = ''; - - if ($action == 'deleteline' && !empty($projectidforalltimes)) { - // We must use projectidprojectid if on list of timespent of project and id=taskid if on list of timespent of a task - $urlafterconfirm = $_SERVER["PHP_SELF"] . "?" . ($projectstatic->id > 0 ? 'projectid=' . $projectstatic->id : ($object->id > 0 ? "id=" . $object->id : '')) . '&lineid=' . GETPOST('lineid', 'int') . ($withproject ? '&withproject=1' : '') . "&contextpage=" . urlencode($contextpage); - $formconfirm = $form->formconfirm($urlafterconfirm, $langs->trans("DeleteATimeSpent"), $langs->trans("ConfirmDeleteATimeSpent"), "confirm_deleteline", '', '', 1); - } - - // Call Hook formConfirm - $parameters = array('formConfirm' => $formconfirm, "projectstatic" => $projectstatic, "withproject" => $withproject); - $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - if (empty($reshook)) { - $formconfirm .= $hookmanager->resPrint; - } elseif ($reshook > 0) { - $formconfirm = $hookmanager->resPrint; - } - - // Print form confirm - print $formconfirm; - @@ -1272,19 +906,11 @@ - $arrayfields['t.element_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['s.name_alias'] = array('label'=>$langs->trans("AliasNameShort"), 'type'=>'integer:Societe:/societe/class/societe.class.php:1'); - if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) { // Not a dedicated task - if (! empty($allprojectforuser)) { - $arrayfields['p.project_ref'] = ['label' => $langs->trans('RefProject'), 'checked' => 1]; - $arrayfields['p.project_label'] = ['label' => $langs->trans('ProjectLabel'), 'checked' => 1]; - } - $arrayfields['t.element_ref'] = array('label'=>$langs->trans("RefTask"), 'checked'=>1); - $arrayfields['t.element_label'] = array('label'=>$langs->trans("LabelTask"), 'checked'=>1); - } - $arrayfields['author'] = array('label' => $langs->trans("By"), 'checked' => 1); - $arrayfields['t.note'] = array('label' => $langs->trans("Note"), 'checked' => 1); - if (isModEnabled('service') && !empty($projectstatic->thirdparty) && $projectstatic->thirdparty->id > 0 && $projectstatic->usage_bill_time) { - $arrayfields['t.fk_product'] = array('label' => $langs->trans("Product"), 'checked' => 1); - } - $arrayfields['t.element_duration'] = array('label'=>$langs->trans("Duration"), 'checked'=>1); - $arrayfields['value'] = array('label'=>$langs->trans("Value"), 'checked'=>1, 'enabled'=>isModEnabled("salaries")); - $arrayfields['valuebilled'] = array('label'=>$langs->trans("Billed"), 'checked'=>1, 'enabled'=>(((getDolGlobalInt('PROJECT_HIDE_TASKS') || !getDolGlobalInt('PROJECT_BILL_TIME_SPENT')) ? 0 : 1) && $projectstatic->usage_bill_time)); + $arrayfields['t.task_date'] = array('label'=>$langs->trans("Date"), '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); + } + $arrayfields['author'] = array('label'=>$langs->trans("By"), 'checked'=>1); + $arrayfields['t.note'] = array('label'=>$langs->trans("Note"), 'checked'=>1); + $arrayfields['t.task_duration'] = array('label'=>$langs->trans("Duration"), 'checked'=>1); + $arrayfields['value'] = array('label'=>$langs->trans("Value"), 'checked'=>1, 'enabled'=>(empty($conf->salaries->enabled) ? 0 : 1)); + $arrayfields['valuebilled'] = array('label'=>$langs->trans("Billed"), 'checked'=>1, 'enabled'=>(((!empty($conf->global->PROJECT_HIDE_TASKS) || empty($conf->global->PROJECT_BILL_TIME_SPENT)) ? 0 : 1) && $projectstatic->usage_bill_time)); @@ -1292,2 +918,8 @@ - include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_list_array_fields.tpl.php'; - + if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0) + { + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) + { + if (!empty($extrafields->attributes[$object->table_element]['list'][$key])) + $arrayfields["ef.".$key] = array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key] < 0) ? 0 : 1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key]) != 3 && $extrafields->attributes[$object->table_element]['perms'][$key])); + } + } @@ -1297,73 +929,10 @@ - if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { - $param .= '&contextpage=' . urlencode($contextpage); - } - if ($limit > 0 && $limit != $conf->liste_limit) { - $param .= '&limit='.((int) $limit); - } - if ($search_month > 0) { - $param .= '&search_month=' . urlencode($search_month); - } - if ($search_year > 0) { - $param .= '&search_year=' . urlencode($search_year); - } - 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); - } - if ($search_task_ref != '') { - $param .= '&search_task_ref=' . urlencode($search_task_ref); - } - if ($search_company != '') { - $param .= '&$search_company=' . urlencode($search_company); - } - if ($search_company_alias != '') { - $param .= '&$search_company_alias=' . urlencode($search_company_alias); - } - if ($search_project_ref != '') { - $param .= '&$search_project_ref=' . urlencode($search_project_ref); - } - if ($search_project_label != '') { - $param .= '&$search_project_label=' . urlencode($search_project_label); - } - if ($search_task_label != '') { - $param .= '&search_task_label=' . urlencode($search_task_label); - } - if ($search_note != '') { - $param .= '&search_note=' . urlencode($search_note); - } - if ($search_duration != '') { - $param .= '&search_field2=' . urlencode($search_duration); - } - if ($optioncss != '') { - $param .= '&optioncss=' . urlencode($optioncss); - } - if ($search_date_startday) { - $param .= '&search_date_startday=' . urlencode($search_date_startday); - } - if ($search_date_startmonth) { - $param .= '&search_date_startmonth=' . urlencode($search_date_startmonth); - } - if ($search_date_startyear) { - $param .= '&search_date_startyear=' . urlencode($search_date_startyear); - } - if ($search_date_endday) { - $param .= '&search_date_endday=' . urlencode($search_date_endday); - } - if ($search_date_endmonth) { - $param .= '&search_date_endmonth=' . urlencode($search_date_endmonth); - } - if ($search_date_endyear) { - $param .= '&search_date_endyear=' . urlencode($search_date_endyear); - } - if ($search_timespent_starthour) { - $param .= '&search_timespent_duration_starthour=' . urlencode($search_timespent_starthour); - } - if ($search_timespent_startmin) { - $param .= '&search_timespent_duration_startmin=' . urlencode($search_timespent_startmin); - } - if ($search_timespent_endhour) { - $param .= '&search_timespent_duration_endhour=' . urlencode($search_timespent_endhour); - } - if ($search_timespent_endmin) { - $param .= '&search_timespent_duration_endmin=' . urlencode($search_timespent_endmin); - } - + if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); + if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); + if ($search_month > 0) $param .= '&search_month='.urlencode($search_month); + if ($search_year > 0) $param .= '&search_year='.urlencode($search_year); + if ($search_user > 0) $param .= '&search_user='.urlencode($search_user); + if ($search_task_ref != '') $param .= '&search_task_ref='.urlencode($search_task_ref); + if ($search_task_label != '') $param .= '&search_task_label='.urlencode($search_task_label); + if ($search_note != '') $param .= '&search_note='.urlencode($search_note); + if ($search_duration != '') $param .= '&search_field2='.urlencode($search_duration); + if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss); @@ -1374,19 +943,7 @@ - if ($id) { - $param .= '&id=' . urlencode($id); - } - if ($projectid) { - $param .= '&projectid=' . urlencode($projectid); - } - if ($withproject) { - $param .= '&withproject=' . urlencode($withproject); - } - // Add $param from hooks - $parameters = array('param' => &$param); - $reshook = $hookmanager->executeHooks('printFieldListSearchParam', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - $param .= $hookmanager->resPrint; - - print '
'; - if ($optioncss != '') { - print ''; - } - print ''; + if ($id) $param .= '&id='.urlencode($id); + if ($projectid) $param .= '&projectid='.urlencode($projectid); + if ($withproject) $param .= '&withproject='.urlencode($withproject); + + print ''; + if ($optioncss != '') print ''; + print ''; @@ -1394,26 +951,43 @@ - if ($action == 'editline') { - print ''; - } elseif ($action == 'splitline') { - print ''; - } elseif ($action == 'createtime' && $user->hasRight('projet', 'time')) { - print ''; - } elseif ($massaction == 'generateinvoice' && $user->hasRight('facture', 'creer')) { - print ''; - } elseif ($massaction == 'generateinter' && $user->hasRight('ficheinter', 'creer')) { - print ''; - } else { - print ''; - } - print ''; - print ''; - - print ''; - print ''; - print ''; - print ''; - print ''; - - // Form to convert time spent into invoice - if ($massaction == 'generateinvoice') { - if (!empty($projectstatic->thirdparty) && $projectstatic->thirdparty->id > 0) { - print ''; + if ($action == 'editline') print ''; + elseif ($action == 'splitline') print ''; + elseif ($action == 'createtime' && $user->rights->projet->lire) print ''; + elseif ($massaction == 'generateinvoice' && $user->rights->facture->lire) print ''; + else print ''; + print ''; + print ''; + print ''; + + print ''; + print ''; + print ''; + print ''; + + if ($massaction == 'generateinvoice') + { + //var_dump($_REQUEST); + print ''; + + print '
'; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + if ($conf->service->enabled) + { @@ -1421,2 +995,2 @@ - print ''; - print ''; - print ''; - print ''; - - if (isModEnabled("service")) { - print ''; - print ''; - print ''; - print ''; - } - - print ''; - print ''; - print ''; - print ''; - /*print ''; - print ''; - print ''; - print '';*/ - print '
'; + print $langs->trans('DateInvoice'); + print ''; + print $form->selectDate('', '', '', '', '', '', 1, 1); + print '
'; + print $langs->trans('Mode'); + print ''; + $tmparray = array( + 'onelineperuser'=>'OneLinePerUser', + 'onelinepertask'=>'OneLinePerTask', + 'onelineperperiod'=>'OneLinePerPeriod', + ); + print $form->selectarray('generateinvoicemode', $tmparray, 'onelineperuser', 0, 0, 0, '', 1); + print '
'; - print $langs->trans('DateInvoice'); + print ''; + print $langs->trans('ServiceToUseOnLines'); @@ -1425 +999 @@ - print $form->selectDate('', '', '', '', '', '', 1, 1); + $form->select_produits('', 'productid', '1', 0, 0, 1, 2, '', 0, array(), 0, 'None', 0, 'maxwidth500'); @@ -1428,119 +1002,26 @@ - - print '
'; - print $langs->trans('Mode'); - print ''; - $tmparray = array( - 'onelineperuser' => 'OneLinePerUser', - 'onelinepertask' => 'OneLinePerTask', - 'onelineperperiod' => 'OneLinePerTimeSpentLine', - ); - print $form->selectarray('generateinvoicemode', $tmparray, 'onelineperuser', 0, 0, 0, '', 1); - print "\n" . '' . "\n"; - print ''; - print '
'; - print $langs->trans('ServiceToUseOnLines'); - print ''; - $form->select_produits('', 'productid', '1', 0, $projectstatic->thirdparty->price_level, 1, 2, '', 0, array(), $projectstatic->thirdparty->id, 'None', 0, 'maxwidth500'); - print '
'; - print $langs->trans('InvoiceToUse'); - print ''; - print $form->selectInvoice($projectstatic->thirdparty->id, '', 'invoiceid', 24, 0, $langs->trans('NewInvoice'), 1, 0, 0, 'maxwidth500', '', 'all'); - print '
'; - print $langs->trans('ValidateInvoices'); - print ''; - print $form->selectyesno('validate_invoices', 0, 1); - print '
'; - - print '
'; - print '
'; - print ' '; - print ''; - print '
'; - print '
'; - } else { - print '
' . $langs->trans("ThirdPartyRequiredToGenerateInvoice") . '
'; - print '
'; - print ''; - print '
'; - $massaction = ''; - } - } elseif ($massaction == 'generateinter') { - // Form to convert time spent into invoice - print ''; - - if (!empty($projectstatic->thirdparty) && $projectstatic->thirdparty->id > 0) { - print '
'; - print ''; - print ''; - print ''; - print ''; - print ''; - print '
'; - print img_picto('', 'intervention', 'class="pictofixedwidth"') . $langs->trans('InterToUse'); - print ''; - $forminter = new FormIntervention($db); - print $forminter->select_interventions($projectstatic->thirdparty->id, '', 'interid', 24, $langs->trans('NewInter'), true); - print '
'; - - print '
'; - print ' '; - print ''; - print '
'; - print '
'; - } else { - print '
' . $langs->trans("ThirdPartyRequiredToGenerateIntervention") . '
'; - print '
'; - print ''; - print '
'; - $massaction = ''; - } - } - - // Allow Pre-Mass-Action hook (eg for confirmation dialog) - $parameters = array( - 'toselect' => $toselect, - 'uploaddir' => isset($uploaddir) ? $uploaddir : null - ); - - $reshook = $hookmanager->executeHooks('doPreMassActions', $parameters, $object, $action); - if ($reshook < 0) { - setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); - } else { - print $hookmanager->resPrint; + } + print '
'; + print $langs->trans('InvoiceToUse'); + print ''; + $form->selectInvoice('invoice', '', 'invoiceid', 24, 0, $langs->trans('NewInvoice'), + 1, 0, 0, 'maxwidth500', '', 'all'); + print '
'; + print $langs->trans('ValidateInvoices'); + print ''; + print $form->selectyesno('validate_invoices', 0, 1); + print '
'; + + print '
'; + print '
'; + print ' '; + print ''; + print '
'; + print '
'; @@ -1554,6 +1035,2 @@ - $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; - $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN', '')); // This also change content of $arrayfields - - $sql = "SELECT t.rowid, t.fk_element, t.element_date, t.element_datehour, t.element_date_withhour, t.element_duration, t.fk_user, t.note, t.thm,"; - $sql .= " t.fk_product,"; - $sql .= " pt.ref, pt.label, pt.fk_projet,"; + $sql = "SELECT t.rowid, t.fk_task, t.task_date, t.task_datehour, t.task_date_withhour, t.task_duration, t.fk_user, t.note, t.thm,"; + $sql .= " pt.ref, pt.label,"; @@ -1561,12 +1038,2 @@ - $sql .= " il.fk_facture as invoice_id, inv.fk_statut,"; - $sql .= " p.fk_soc,s.name_alias,"; - $sql .= " t.invoice_line_id"; - // Add fields from hooks - $parameters = array(); - $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - $sql .= $hookmanager->resPrint; - $sql = preg_replace('/,\s*$/', '', $sql); - - $sqlfields = $sql; // $sql fields to remove for count total - - $sql .= " FROM ".MAIN_DB_PREFIX."element_time as t"; + $sql .= " il.fk_facture as invoice_id, inv.fk_statut"; + $sql .= " FROM ".MAIN_DB_PREFIX."projet_task_time as t"; @@ -1574,94 +1041,14 @@ - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."facture as inv ON inv.rowid = il.fk_facture"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as prod ON prod.rowid = t.fk_product"; - $sql .= " INNER JOIN ".MAIN_DB_PREFIX."projet_task as pt ON pt.rowid = t.fk_element"; - $sql .= " INNER JOIN ".MAIN_DB_PREFIX."projet as p ON p.rowid = pt.fk_projet"; - $sql .= " INNER JOIN ".MAIN_DB_PREFIX."user as u ON t.fk_user = u.rowid"; - $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, $action); // Note that $action and $object may have been modified by hook - $sql .= $hookmanager->resPrint; - $sql .= " WHERE elementtype = 'task'"; - $sql .= " AND p.entity IN (".getEntity('project').")"; - if (empty($projectidforalltimes) && empty($allprojectforuser)) { - // Limit on one task - $sql .= " AND t.fk_element =".((int) $object->id); - } elseif (!empty($projectidforalltimes)) { - // Limit on one project - $sql .= " AND pt.fk_projet IN (" . $db->sanitize($projectidforalltimes) . ")"; - } elseif (!empty($allprojectforuser)) { - // Limit on on user - if (empty($search_user)) { - $search_user = $user->id; - } - if ($search_user > 0) { - $sql .= " AND t.fk_user = " . ((int) $search_user); - } - } - - if ($search_note) { - $sql .= natural_search('t.note', $search_note); - } - if ($search_task_ref) { - $sql .= natural_search('pt.ref', $search_task_ref); - } - if (empty($arrayfields['s.name_alias']['checked']) && $search_company) { - $sql .= natural_search(array("s.nom", "s.name_alias"), $search_company); - } else { - if ($search_company) { - $sql .= natural_search('s.nom', $search_company); - } - if ($search_company_alias) { - $sql .= natural_search('s.name_alias', $search_company_alias); - } - } - if ($search_project_ref) { - $sql .= natural_search('p.ref', $search_project_ref); - } - if ($search_project_label) { - $sql .= natural_search('p.title', $search_project_label); - } - if ($search_task_label) { - $sql .= natural_search('pt.label', $search_task_label); - } - if ($search_user > 0) { - $sql .= natural_search('t.fk_user', $search_user, 2); - } - if (!empty($search_product_ref)) { - $sql .= natural_search('prod.ref', $search_product_ref); - } - if ($search_valuebilled == '1') { - $sql .= ' AND t.invoice_id > 0'; - } - if ($search_valuebilled == '0') { - $sql .= ' AND (t.invoice_id = 0 OR t.invoice_id IS NULL)'; - } - - if ($search_date_start) { - $sql .= " AND t.element_date >= '".$db->idate($search_date_start)."'"; - } - if ($search_date_end) { - $sql .= " AND t.element_date <= '".$db->idate($search_date_end)."'"; - } - - if (!empty($arrayfields['t.element_duration']['checked'])) { - if ($search_timespent_starthour || $search_timespent_startmin) { - $timespent_duration_start = $search_timespent_starthour * 60 * 60; // We store duration in seconds - $timespent_duration_start += ($search_timespent_startmin ? $search_timespent_startmin : 0) * 60; // We store duration in seconds - $sql .= " AND t.element_duration >= " . $timespent_duration_start; - } - - if ($search_timespent_endhour || $search_timespent_endmin) { - $timespent_duration_end = $search_timespent_endhour * 60 * 60; // We store duration in seconds - $timespent_duration_end += ($search_timespent_endmin ? $search_timespent_endmin : 0) * 60; // We store duration in seconds - $sql .= " AND t.element_duration <= " . $timespent_duration_end; - } - } - - $sql .= dolSqlDateFilter('t.element_datehour', $search_day, $search_month, $search_year); - - // Add where from hooks - $parameters = array(); - $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - $sql .= $hookmanager->resPrint; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."facture as inv ON inv.rowid = il.fk_facture,"; + $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"; + if (empty($projectidforalltimes)) $sql .= " AND t.fk_task =".$object->id; + else $sql .= " AND pt.fk_projet IN (".$projectidforalltimes.")"; + if ($search_ref) $sql .= natural_search('c.ref', $search_ref); + if ($search_note) $sql .= natural_search('t.note', $search_note); + if ($search_task_ref) $sql .= natural_search('pt.ref', $search_task_ref); + if ($search_task_label) $sql .= natural_search('pt.label', $search_task_label); + if ($search_user > 0) $sql .= natural_search('t.fk_user', $search_user); + if ($search_valuebilled == '1') $sql .= ' AND t.invoice_id > 0'; + if ($search_valuebilled == '0') $sql .= ' AND (t.invoice_id = 0 OR t.invoice_id IS NULL)'; + $sql .= dolSqlDateFilter('t.task_datehour', $search_day, $search_month, $search_year); + $sql .= $db->order($sortfield, $sortorder); @@ -1671,13 +1058,6 @@ - if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) { - /* 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); - $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); - } - - if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller than the paging size (filtering), goto and load page 0 + if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) + { + $resql = $db->query($sql); + $nbtotalofrecords = $db->num_rows($resql); + if (($page * $limit) > $nbtotalofrecords) // if total of record found is smaller than page * limit, goto and load page 0 + { @@ -1687,6 +1067,8 @@ - $db->free($resql); - } - - // Complete request and execute it with limit - $sql .= $db->order($sortfield, $sortorder); - if ($limit) { + } + // 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) + { + $num = $nbtotalofrecords; + } + else + { @@ -1694,13 +1076,16 @@ - } - - $resql = $db->query($sql); - if (!$resql) { - dol_print_error($db); - exit; - } - - $num = $db->num_rows($resql); - - if ($num >= 0) { - if (!empty($projectidforalltimes)) { - print '' . "\n"; + + $resql = $db->query($sql); + if (!$resql) + { + dol_print_error($db); + exit; + } + + $num = $db->num_rows($resql); + } + + if ($num >= 0) + { + if (!empty($projectidforalltimes)) + { + print ''."\n"; @@ -1710,3 +1095,5 @@ - print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'clock', 0, $linktocreatetime, '', $limit, 0, 0, 1); - } else { - print '' . "\n"; + print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'generic', 0, $linktocreatetime, '', $limit); + } + else + { + print ''."\n"; @@ -1716 +1103 @@ - print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'clock', 0, $linktocreatetime, '', $limit, 0, 0, 1); + print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'generic', 0, $linktocreatetime, '', $limit); @@ -1720 +1107,2 @@ - while ($i < $num) { + while ($i < $num) + { @@ -1726 +1114,3 @@ - } else { + } + else + { @@ -1731 +1121 @@ - * Form to add a new line of time spent + * Form to add time spent @@ -1733,5 +1123,4 @@ - if ($action == 'createtime' && $user->hasRight('projet', 'time')) { - print '' . "\n"; - if (!empty($id)) { - print ''; - } + if ($action == 'createtime' && $user->rights->projet->lire) + { + print ''."\n"; + if (!empty($id)) print ''; @@ -1743,12 +1132,8 @@ - print '
' . $langs->trans("Date") . '' . $langs->trans("Project") . '' . $langs->trans("Task") . '' . $langs->trans("By") . '' . $langs->trans("Note") . '' . $langs->trans("NewTimeSpent") . '' . $langs->trans("ProgressDeclared") . ''.$langs->trans("Date").''.$langs->trans("Task").''.$langs->trans("By").''.$langs->trans("Note").''.$langs->trans("NewTimeSpent").''.$langs->trans("ProgressDeclared").''.$langs->trans("Product").''; - // Add project selector - print ''; - $durationtouse = (GETPOST('timespent_duration') ? GETPOST('timespent_duration') : ''); - if (GETPOSTISSET('timespent_durationhour') || GETPOSTISSET('timespent_durationmin')) { - $durationtouse = ((int) GETPOST('timespent_durationhour') * 3600 + (int) GETPOST('timespent_durationmin') * 60); + print ''; + $durationtouse = ($_POST['timespent_duration'] ? $_POST['timespent_duration'] : ''); + if (GETPOSTISSET('timespent_durationhour') || GETPOSTISSET('timespent_durationmin')) + { + $durationtouse = (GETPOST('timespent_durationhour') * 3600 + GETPOST('timespent_durationmin') * 60); @@ -1828 +1200 @@ - print $formother->select_percent(GETPOST('progress') ? GETPOST('progress') : $object->progress, 'progress', 0, 5, 0, 100, 1); + print $formother->select_percent(GETPOST('progress') ?GETPOST('progress') : $object->progress, 'progress', 0, 5, 0, 100, 1); @@ -1832 +1204,2 @@ - if (!getDolGlobalString('PROJECT_HIDE_TASKS') && getDolGlobalString('PROJECT_BILL_TIME_SPENT')) { + if (empty($conf->global->PROJECT_HIDE_TASKS) && !empty($conf->global->PROJECT_BILL_TIME_SPENT)) + { @@ -1835,13 +1208 @@ - - if (isModEnabled("service") && !empty($projectstatic->thirdparty) && $projectstatic->thirdparty->id > 0 && $projectstatic->usage_bill_time) { - print ''; - print img_picto('', 'service'); - print $form->select_produits((GETPOSTISSET('fk_product')?GETPOST("fk_product", 'int'):''), 'fk_product', '1', 0, $projectstatic->thirdparty->price_level, 1, 2, '', 1, array(), $projectstatic->thirdparty->id, 'None', 0, 'maxwidth150', 0, '', null, 1); - print '
' . "\n"; + print '
'."\n"; @@ -1885 +1242,0 @@ - // -------------------------------------------------------------------- @@ -1887,5 +1244,7 @@ - // Action column - if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { - print ''; - } - // Thirdparty - if (!empty($arrayfields['p.fk_soc']['checked'])) { - print ''; - } - - // Thirdparty alias - if (!empty($arrayfields['s.name_alias']['checked'])) { - print ''; - } - - if (!empty($allprojectforuser)) { - if (!empty($arrayfields['p.project_ref']['checked'])) { - print ''; - } - if (!empty($arrayfields['p.project_label']['checked'])) { - print ''; - } - } - // Task - if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) { // Not a dedicated task - if (!empty($arrayfields['t.element_ref']['checked'])) { - print ''; - } - if (!empty($arrayfields['t.element_label']['checked'])) { - print ''; - } + if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) // Not a dedicated task + { + if (!empty($arrayfields['t.task_ref']['checked'])) print ''; + if (!empty($arrayfields['t.task_label']['checked'])) print ''; @@ -1933,3 +1259 @@ - if (!empty($arrayfields['author']['checked'])) { - print ''; - } + if (!empty($arrayfields['author']['checked'])) print ''; @@ -1937,3 +1261 @@ - if (!empty($arrayfields['t.note']['checked'])) { - print ''; - } + if (!empty($arrayfields['t.note']['checked'])) print ''; @@ -1941,26 +1263 @@ - if (!empty($arrayfields['t.element_duration']['checked'])) { - // Duration - Time spent - print ''; - } - // Product - if (!empty($arrayfields['t.fk_product']['checked'])) { - print ''; - } + if (!empty($arrayfields['t.task_duration']['checked'])) print ''; @@ -1968,3 +1265 @@ - if (!empty($arrayfields['value']['checked'])) { - print ''; - } + if (!empty($arrayfields['value']['checked'])) print ''; @@ -1972,3 +1267 @@ - if (!empty($arrayfields['valuebilled']['checked'])) { - print ''; - } + if (!empty($arrayfields['valuebilled']['checked'])) print ''; @@ -1977,3 +1270,3 @@ - // Extra fields - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; - */ + // Extra fields + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; + */ @@ -1981,2 +1274,2 @@ - $parameters = array('arrayfields' => $arrayfields); - $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + $parameters = array('arrayfields'=>$arrayfields); + $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook @@ -1985,13 +1278,6 @@ - if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { - print ''; - } - print '' . "\n"; - - $totalarray = array(); - $totalarray['nbfield'] = 0; - - // Fields title label - // -------------------------------------------------------------------- + print ''; + print ''."\n"; + @@ -1999,61 +1285,11 @@ - if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { - print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch '); - $totalarray['nbfield']++; - } - 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); - $totalarray['nbfield']++; - } - 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); - $totalarray['nbfield']++; - } - 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); - $totalarray['nbfield']++; - } - if (!empty($allprojectforuser)) { - if (!empty($arrayfields['p.project_ref']['checked'])) { - print_liste_field_titre("Project", $_SERVER['PHP_SELF'], 'p.ref', '', $param, '', $sortfield, $sortorder); - $totalarray['nbfield']++; - } - if (!empty($arrayfields['p.project_label']['checked'])) { - 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($arrayfields['t.element_ref']['checked'])) { - 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'])) { - print_liste_field_titre($arrayfields['t.element_label']['label'], $_SERVER['PHP_SELF'], 'pt.label', '', $param, '', $sortfield, $sortorder); - $totalarray['nbfield']++; - } - } - if (!empty($arrayfields['author']['checked'])) { - print_liste_field_titre($arrayfields['author']['label'], $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder); - $totalarray['nbfield']++; - } - if (!empty($arrayfields['t.note']['checked'])) { - 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'])) { - 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'])) { - 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'])) { - print_liste_field_titre($arrayfields['value']['label'], $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder, 'right '); - $totalarray['nbfield']++; - } - 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")); - $totalarray['nbfield']++; - } + 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($id) && empty($ref)) || !empty($projectidforalltimes)) // Not a dedicated task + { + if (!empty($arrayfields['t.task_ref']['checked'])) print_liste_field_titre($arrayfields['t.task_ref']['label'], $_SERVER['PHP_SELF'], 'pt.ref', '', $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['t.task_label']['checked'])) print_liste_field_titre($arrayfields['t.task_label']['label'], $_SERVER['PHP_SELF'], 'pt.label', '', $param, '', $sortfield, $sortorder); + } + if (!empty($arrayfields['author']['checked'])) print_liste_field_titre($arrayfields['author']['label'], $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['t.note']['checked'])) print_liste_field_titre($arrayfields['t.note']['label'], $_SERVER['PHP_SELF'], 't.note', '', $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['t.task_duration']['checked'])) print_liste_field_titre($arrayfields['t.task_duration']['label'], $_SERVER['PHP_SELF'], 't.task_duration', '', $param, '', $sortfield, $sortorder, 'right '); + if (!empty($arrayfields['value']['checked'])) print_liste_field_titre($arrayfields['value']['label'], $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder, 'right '); + if (!empty($arrayfields['valuebilled']['checked'])) print_liste_field_titre($arrayfields['valuebilled']['label'], $_SERVER['PHP_SELF'], 'il.total_ht', '', $param, '', $sortfield, $sortorder, 'center '); @@ -2061,3 +1297,3 @@ - // Extra fields - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; - */ + // Extra fields + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; + */ @@ -2065,2 +1301,2 @@ - $parameters = array('arrayfields' => $arrayfields, 'param' => $param, 'sortfield' => $sortfield, 'sortorder' => $sortorder); - $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder); + $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook @@ -2068,4 +1304 @@ - if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { - print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', 'width="80"', $sortfield, $sortorder, 'center maxwidthsearch '); - $totalarray['nbfield']++; - } + print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', 'width="80"', $sortfield, $sortorder, 'center maxwidthsearch '); @@ -2077,0 +1311,3 @@ + + $childids = $user->getAllChildIds(); + @@ -2080,2 +1315,0 @@ - - $savnbfield = $totalarray['nbfield']; @@ -2083,48 +1317,24 @@ - $totalarray['nbfield'] = 0; - //$imaxinloop = ($limit ? min($num, $limit) : $num); - foreach ($tasks as $task_time) { - if ($i >= $limit) { - break; - } - - $date1 = $db->jdate($task_time->element_date); - $date2 = $db->jdate($task_time->element_datehour); - - // Show here line of result - $j = 0; - print ''; - - // Action column - if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { - print ''; + + $date1 = $db->jdate($task_time->task_date); + $date2 = $db->jdate($task_time->task_datehour); + + // Date + if (!empty($arrayfields['t.task_date']['checked'])) + { + print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Thirdparty - if (!empty($arrayfields['p.fk_soc']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Thirdparty alias - if (!empty($arrayfields['s.name_alias']['checked'])) { - if ($task_time->fk_soc > 0) { - 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]; - } - $valtoshow = $tmpsociete->name_alias; - } - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Project ref & label - if (!empty($allprojectforuser)) { - if (!empty($arrayfields['p.project_ref']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - if (!empty($arrayfields['p.project_label']['checked'])) { - if (empty($conf->cache['project'][$task_time->fk_projet])) { - $tmpproject = new Project($db); - $tmpproject->fetch($task_time->fk_projet); - $conf->cache['project'][$task_time->fk_projet] = $tmpproject; - } else { - $tmpproject = $conf->cache['project'][$task_time->fk_projet]; - } - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } + if (!$i) $totalarray['nbfield']++; @@ -2229,7 +1347,12 @@ - if (!empty($arrayfields['t.element_ref']['checked'])) { - if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) { // Not a dedicated task - print ''; + if (!$i) $totalarray['nbfield']++; + } + } else { + print ''; + } + + // Task label + if (!empty($arrayfields['t.task_label']['checked'])) + { + if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) // Not a dedicated task + { + print ''; - if (!$i) { - $totalarray['nbfield']++; - } + if (!$i) $totalarray['nbfield']++; @@ -2262,6 +1383,6 @@ - if (!empty($arrayfields['author']['checked'])) { - print ''; - } else { - print ''; - } - if (!$i) { - $totalarray['nbfield']++; - } - } elseif ($action == 'editline' && GETPOST('lineid', 'int') == $task_time->rowid) { - print ''; + if (!empty($arrayfields['t.note']['checked'])) + { + print ''; + if (!$i) $totalarray['nbfield']++; + } + elseif ($action == 'editline' && $_GET['lineid'] == $task_time->rowid) + { + print ''; @@ -2311,7 +1434,11 @@ - if (!empty($arrayfields['t.element_duration']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - if (!$i) { - $totalarray['pos'][$totalarray['nbfield']] = 'value'; - } - if (empty($totalarray['val']['value'])) { - $totalarray['val']['value'] = $value; - } else { - $totalarray['val']['value'] += $value; - } - if (!$i) { - $totalarray['totalvaluefield'] = $totalarray['nbfield']; - } - if (empty($totalarray['totalvalue'])) { - $totalarray['totalvalue'] = $value; - } else { - $totalarray['totalvalue'] += $value; - } + if (!$i) $totalarray['nbfield']++; + if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'value'; + $totalarray['val']['value'] += $value; + if (!$i) $totalarray['totalvaluefield'] = $totalarray['nbfield']; + $totalarray['totalvalue'] += $value; @@ -2394 +1469,2 @@ - if (!empty($arrayfields['valuebilled']['checked'])) { + if (!empty($arrayfields['valuebilled']['checked'])) + { @@ -2396,3 +1472,6 @@ - if (!getDolGlobalString('PROJECT_HIDE_TASKS') && getDolGlobalString('PROJECT_BILL_TIME_SPENT')) { - if ($projectstatic->usage_bill_time) { - if ($task_time->invoice_id) { + if (empty($conf->global->PROJECT_HIDE_TASKS) && !empty($conf->global->PROJECT_BILL_TIME_SPENT)) + { + if ($projectstatic->usage_bill_time) + { + if ($task_time->invoice_id) + { @@ -2400,14 +1479,3 @@ - if ($result > 0) { - if ($action=='editline' && $_GET['lineid'] == $task_time->rowid) { - print $formproject->selectInvoiceAndLine($task_time->invoice_id, $task_time->invoice_line_id, 'invoiceid', 'invoicelineid', 'maxwidth500', array('p.rowid'=>$projectstatic->id)); - } else { - print $tmpinvoice->getNomUrl(1); - if (!empty($task_time->invoice_line_id)) { - $invoiceLine = new FactureLigne($db); - $invoiceLine->fetch($task_time->invoice_line_id); - if (!empty($invoiceLine->id)) { - print '
'.$langs->trans('Qty').':'.$invoiceLine->qty; - print ' '.$langs->trans('TotalHT').':'.price($invoiceLine->total_ht); - } - } - } + if ($result > 0) + { + print $tmpinvoice->getNomUrl(1); @@ -2415 +1483,3 @@ - } else { + } + else + { @@ -2418,2 +1488,4 @@ - } else { - print '' . $langs->trans("NA") . ''; + } + else + { + print ''.$langs->trans("NA").''; @@ -2423,3 +1495,3 @@ - if (!$i) { - $totalarray['nbfield']++; - } + if (!$i) $totalarray['nbfield']++; + if (!$i) $totalarray['totalvaluebilledfield'] = $totalarray['nbfield']; + $totalarray['totalvaluebilled'] += $valuebilled; @@ -2429,3 +1501,3 @@ - // Extra fields - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; - */ + // Extra fields + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; + */ @@ -2434,2 +1506,2 @@ - $parameters = array('arrayfields' => $arrayfields, 'obj' => $task_time, 'i' => $i, 'totalarray' => &$totalarray); - $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$task_time, 'i'=>$i, 'totalarray'=>&$totalarray); + $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook @@ -2439,14 +1511,60 @@ - if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { - print ''; + if (!$i) $totalarray['nbfield']++; + + print "\n"; + + + // Add line to split + + if ($action == 'splitline' && $_GET['lineid'] == $task_time->rowid) + { + print ''; + + // Date + if (!empty($arrayfields['t.task_date']['checked'])) + { + print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - print "\n"; - - - // Add line to split - - if ($action == 'splitline' && GETPOST('lineid', 'int') == $task_time->rowid) { - print ''; - print ''; - - // Date - if (!empty($arrayfields['t.element_date']['checked'])) { - print ''; - } - - // Thirdparty alias - if (!empty($arrayfields['s.name_alias']['checked'])) { - print ''; - } - - // Project ref - if (!empty($allprojectforuser)) { - if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) { // Not a dedicated task + // Task ref + if (!empty($arrayfields['t.task_ref']['checked'])) + { + if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) // Not a dedicated task + { @@ -2519,9 +1587 @@ - print ''; - } - } - - // Task ref - if (!empty($arrayfields['t.element_ref']['checked'])) { - if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) { // Not a dedicated task - print ''; - } - - // Value billed - if (!empty($arrayfields['valuebilled']['checked'])) { - print ''; + print ''; @@ -2645 +1711,2 @@ - if (!empty($arrayfields['t.element_date']['checked'])) { + if (!empty($arrayfields['t.task_date']['checked'])) + { @@ -2647,2 +1714,4 @@ - if ($action == 'splitline' && GETPOST('lineid', 'int') == $task_time->rowid) { - if (empty($task_time->element_date_withhour)) { + if ($action == 'splitline' && $_GET['lineid'] == $task_time->rowid) + { + if (empty($task_time->task_date_withhour)) + { @@ -2650,2 +1718,0 @@ - } else { - print $form->selectDate(($date2 ? $date2 : $date1), 'timeline_2', 1, 1, 2, "timespent_date", 1, 0); @@ -2653,2 +1720,5 @@ - } else { - print dol_print_date(($date2 ? $date2 : $date1), ($task_time->element_date_withhour ? 'dayhour' : 'day')); + else print $form->selectDate(($date2 ? $date2 : $date1), 'timeline_2', 1, 1, 2, "timespent_date", 1, 0); + } + else + { + print dol_print_date(($date2 ? $date2 : $date1), ($task_time->task_date_withhour ? 'dayhour' : 'day')); @@ -2659,15 +1729,5 @@ - // Thirdparty - if (!empty($arrayfields['p.fk_soc']['checked'])) { - print ''; - } - - // Thirdparty alias - if (!empty($arrayfields['s.name_alias']['checked'])) { - print ''; - } - - // Project ref - if (!empty($allprojectforuser)) { - if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) { // Not a dedicated task + // Task ref + if (!empty($arrayfields['t.task_ref']['checked'])) + { + if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) // Not a dedicated task + { @@ -2675,9 +1735 @@ - print ''; - } - } - - // Task ref - if (!empty($arrayfields['t.element_ref']['checked'])) { - if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) { // Not a dedicated task - print ''; - } - @@ -2760 +1820,2 @@ - if (!empty($arrayfields['value']['checked'])) { + if (!empty($arrayfields['value']['checked'])) + { @@ -2762 +1822,0 @@ - print ''; @@ -2765 +1824,0 @@ - print ''; @@ -2770 +1829,2 @@ - if (!empty($arrayfields['valuebilled']['checked'])) { + if (!empty($arrayfields['valuebilled']['checked'])) + { @@ -2772,6 +1832,2 @@ - $valuebilled = price2num($task_time->total_ht, '', 1); - if (isset($task_time->total_ht)) { - print ''; - print price($valuebilled, 1, $langs, 1, -1, -1, $conf->currency); - print ''; - } + $valuebilled = price2num($task_time->total_ht); + if (isset($task_time->total_ht)) print price($valuebilled, 1, $langs, 1, -1, -1, $conf->currency); @@ -2787,2 +1843,2 @@ - $parameters = array('arrayfields' => $arrayfields, 'obj' => $task_time, 'mode' => 'split2'); - $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$task_time); + $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook @@ -2803 +1859,2 @@ - if (isset($totalarray['totaldurationfield']) || isset($totalarray['totalvaluefield'])) { + if (isset($totalarray['totaldurationfield']) || isset($totalarray['totalvaluefield'])) + { @@ -2806 +1863,2 @@ - while ($i < $totalarray['nbfield']) { + while ($i < $totalarray['nbfield']) + { @@ -2808,14 +1866,9 @@ - if ($i == 1) { - if ($num < $limit && empty($offset)) { - print ''; - } else { - print ''; - } - } elseif (isset($totalarray['totaldurationfield']) && $totalarray['totaldurationfield'] == $i) { - print ''; - } elseif (isset($totalarray['totalvaluefield']) && $totalarray['totalvaluefield'] == $i) { - print ''; - //} elseif ($totalarray['totalvaluebilledfield'] == $i) { print ''; - } else { - print ''; - } + if ($i == 1) + { + if ($num < $limit && empty($offset)) print ''; + else print ''; + } + elseif ($totalarray['totaldurationfield'] == $i) print ''; + elseif ($totalarray['totalvaluefield'] == $i) print ''; + //elseif ($totalarray['totalvaluebilledfield'] == $i) print ''; + else print ''; @@ -2826 +1879,2 @@ - if (!count($tasks)) { + if (!count($tasks)) + { @@ -2828,7 +1882,6 @@ - foreach ($arrayfields as $value) { - if (!empty($value['checked'])) { - $totalnboffields++; - } - } - print '
'; - $searchpicto = $form->showFilterButtons('left'); - print $searchpicto; + // Date + if (!empty($arrayfields['t.task_date']['checked'])) + { + print ''; + if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ''; + print ''; + $formother->select_year($search_year, 'search_year', 1, 20, 5); @@ -1894,37 +1253,4 @@ - // Date - if (!empty($arrayfields['t.element_date']['checked'])) { - print ''; - print '
'; - print $form->selectDate($search_date_start ? $search_date_start : -1, 'search_date_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From')); - print '
'; - print '
'; - print $form->selectDate($search_date_end ? $search_date_end : -1, 'search_date_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to')); - print '
'; - print '
'.$form->select_dolusers(($search_user > 0 ? $search_user : -1), 'search_user', 1, null, 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth150').''.$form->select_dolusers(($search_user > 0 ? $search_user : -1), 'search_user', 1, null, 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth200').''; - - $durationtouse_start = ''; - if ($search_timespent_starthour || $search_timespent_startmin) { - $durationtouse_start = ($search_timespent_starthour * 3600 + $search_timespent_startmin * 60); - } - print '
' . $langs->trans('from') . ' '; - print $form->select_duration('search_timespent_duration_start', $durationtouse_start, 0, 'text', 0, 1); - print '
'; - - $durationtouse_end = ''; - if ($search_timespent_endhour || $search_timespent_endmin) { - $durationtouse_end = ($search_timespent_endhour * 3600 + $search_timespent_endmin * 60); - } - print '
' . $langs->trans('at') . ' '; - print $form->select_duration('search_timespent_duration_end', $durationtouse_end, 0, 'text', 0, 1); - print '
'; - - print '
' . $form->selectyesno('search_valuebilled', $search_valuebilled, 1, false, 1) . ''.$form->selectyesno('search_valuebilled', $search_valuebilled, 1, false, 1).''; - $searchpicto = $form->showFilterButtons(); - print $searchpicto; - print '
'; + $searchpicto = $form->showFilterButtons(); + print $searchpicto; + print '
'; - if (($action == 'editline' || $action == 'splitline') && GETPOST('lineid', 'int') == $task_time->rowid) { - print ''; - print ''; - print '
'; - print ''; - } elseif ($user->hasRight('projet', 'time') || $user->hasRight('projet', 'all', 'creer')) { // Read project and enter time consumed on assigned tasks - if (in_array($task_time->fk_user, $childids) || $user->hasRight('projet', 'all', 'creer')) { - if (getDolGlobalString('MAIN_FEATURES_LEVEL') >= 2) { - print ' '; - print ''; - print img_split('', 'class="pictofixedwidth"'); - print ''; - } - - print 'rowid.$param.((empty($id) || $tab == 'timespent') ? '&tab=timespent' : '').'">'; - print img_edit('default', 0, 'class="pictofixedwidth paddingleft"'); - print ''; - - print 'rowid.$param.((empty($id) || $tab == 'timespent') ? '&tab=timespent' : '').'">'; - print img_delete('default', 'class="pictodelete paddingleft"'); - print ''; - - if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined - $selected = 0; - if (in_array($task_time->rowid, $arrayofselected)) { - $selected = 1; - } - print ' '; - print ''; - } - } + foreach ($tasks as $task_time) + { + if ($i >= $limit) break; + + print '
'; + if ($action == 'editline' && $_GET['lineid'] == $task_time->rowid) + { + if (empty($task_time->task_date_withhour)) + { + print $form->selectDate(($date2 ? $date2 : $date1), 'timeline', 3, 3, 2, "timespent_date", 1, 0); + } + else print $form->selectDate(($date2 ? $date2 : $date1), 'timeline', 1, 1, 2, "timespent_date", 1, 0); + } + else + { + print dol_print_date(($date2 ? $date2 : $date1), ($task_time->task_date_withhour ? 'dayhour' : 'day')); @@ -2133,93 +1343 @@ - if (!$i) { - $totalarray['nbfield']++; - } - } - // Date - if (!empty($arrayfields['t.element_date']['checked'])) { - print ''; - if ($action == 'editline' && GETPOST('lineid', 'int') == $task_time->rowid) { - if (empty($task_time->element_date_withhour)) { - print $form->selectDate(($date2 ? $date2 : $date1), 'timeline', 3, 3, 2, "timespent_date", 1, 0); - } else { - print $form->selectDate(($date2 ? $date2 : $date1), 'timeline', 1, 1, 2, "timespent_date", 1, 0); - } - } else { - print dol_print_date(($date2 ? $date2 : $date1), ($task_time->element_date_withhour ? 'dayhour' : 'day')); - } - print ''; - if ($task_time->fk_soc > 0) { - 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, '', 100, 0, 1, empty($arrayfields['s.name_alias']['checked']) ? 0 : 1); - } - print ''; - print $valtoshow; - print ''; - if (empty($conf->cache['project'][$task_time->fk_projet])) { - $tmpproject = new Project($db); - $tmpproject->fetch($task_time->fk_projet); - $conf->cache['project'][$task_time->fk_projet] = $tmpproject; - } else { - $tmpproject = $conf->cache['project'][$task_time->fk_projet]; - } - print $tmpproject->getNomUrl(1); - print ''; - print dol_escape_htmltag($tmpproject->title); - print ''; - if ($action == 'editline' && GETPOST('lineid', 'int') == $task_time->rowid) { - $formproject->selectTasks(-1, GETPOST('taskid', 'int') ? GETPOST('taskid', 'int') : $task_time->fk_element, 'taskid', 0, 0, 1, 1, 0, 0, 'maxwidth300', $projectstatic->id, ''); - } else { - $tasktmp->id = $task_time->fk_element; + if (!empty($arrayfields['t.task_ref']['checked'])) + { + if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) // Not a dedicated task + { + print ''; + if ($action == 'editline' && $_GET['lineid'] == $task_time->rowid) + { + $formproject->selectTasks(-1, GETPOST('taskid', 'int') ?GETPOST('taskid', 'int') : $task_time->fk_task, 'taskid', 0, 0, 1, 1, 0, 0, 'maxwidth300', $projectstatic->id, ''); + } + else + { + $tasktmp->id = $task_time->fk_task; @@ -2239,0 +1363,14 @@ + print ''; + print $task_time->label; @@ -2241,17 +1378 @@ - if (!$i) { - $totalarray['nbfield']++; - } - } - } elseif ($action !== 'createtime') { - print ''; - } - - // Task label - if (!empty($arrayfields['t.element_label']['checked'])) { - if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) { // Not a dedicated task - print ''; - print dol_escape_htmltag($task_time->label); - print ''; - if ($action == 'editline' && GETPOST('lineid', 'int') == $task_time->rowid) { - if (empty($object->id)) { - $object->fetch($id); - } + if (!empty($arrayfields['author']['checked'])) + { + print ''; + if ($action == 'editline' && $_GET['lineid'] == $task_time->rowid) + { + if (empty($object->id)) $object->fetch($id); @@ -2276,3 +1397,5 @@ - print img_error($langs->trans('FirstAddRessourceToAllocateTime')) . $langs->trans('FirstAddRessourceToAllocateTime'); - } - } else { + print img_error($langs->trans('FirstAddRessourceToAllocateTime')).$langs->trans('FirstAddRessourceToAllocateTime'); + } + } + else + { @@ -2283 +1406 @@ - $userstatic->status = $task_time->user_status; + $userstatic->statut = $task_time->user_status; @@ -2287,3 +1410 @@ - if (!$i) { - $totalarray['nbfield']++; - } + if (!$i) $totalarray['nbfield']++; @@ -2293,15 +1414,17 @@ - if (!empty($arrayfields['t.note']['checked'])) { - if ($action == 'editline' && GETPOST('lineid', 'int') == $task_time->rowid) { - print ''; - print ''; - print ''; - print dolGetFirstLineOfText($task_time->note); - print ''; + if ($action == 'editline' && $_GET['lineid'] == $task_time->rowid) + { + print ''; + } + else + { + print dol_nl2br($task_time->note); + } + print ''; - if ($action == 'editline' && GETPOST('lineid', 'int') == $task_time->rowid) { - print ''; - print $form->select_duration('new_duration', $task_time->element_duration, 0, 'text'); - } else { - print convertSecondToTime($task_time->element_duration, 'allhourmin'); + if (!empty($arrayfields['t.task_duration']['checked'])) + { + print ''; + if ($action == 'editline' && $_GET['lineid'] == $task_time->rowid) + { + print ''; + print $form->select_duration('new_duration', $task_time->task_duration, 0, 'text'); + } + else + { + print convertSecondToTime($task_time->task_duration, 'allhourmin'); @@ -2320,36 +1447,13 @@ - if (!$i) { - $totalarray['nbfield']++; - } - if (!$i) { - $totalarray['pos'][$totalarray['nbfield']] = 't.element_duration'; - } - if (empty($totalarray['val']['t.element_duration'])) { - $totalarray['val']['t.element_duration'] = $task_time->element_duration; - } else { - $totalarray['val']['t.element_duration'] += $task_time->element_duration; - } - if (!$i) { - $totalarray['totaldurationfield'] = $totalarray['nbfield']; - } - if (empty($totalarray['totalduration'])) { - $totalarray['totalduration'] = $task_time->element_duration; - } else { - $totalarray['totalduration'] += $task_time->element_duration; - } - } - - // Product - if (!empty($arrayfields['t.fk_product']['checked'])) { - print ''; - if ($action == 'editline' && $_GET['lineid'] == $task_time->rowid) { - print img_picto('', 'service'); - print $form->select_produits($task_time->fk_product, 'fk_product', '1', 0, $projectstatic->thirdparty->price_level, 1, 2, '', 1, array(), $projectstatic->thirdparty->id, 'None', 0, 'maxwidth500', 0, '', null, 1); - } elseif (!empty($task_time->fk_product)) { - $product = new Product($db); - $resultFetch = $product->fetch($task_time->fk_product); - if ($resultFetch < 0) { - setEventMessages($product->error, $product->errors, 'errors'); - } else { - print $product->getNomUrl(1); - } - } + if (!$i) $totalarray['nbfield']++; + if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 't.task_duration'; + $totalarray['val']['t.task_duration'] += $task_time->task_duration; + if (!$i) $totalarray['totaldurationfield'] = $totalarray['nbfield']; + $totalarray['totalduration'] += $task_time->task_duration; + } + + // Value spent + if (!empty($arrayfields['value']['checked'])) + { + print ''; + $value = price2num($task_time->thm * $task_time->task_duration / 3600); + print price($value, 1, $langs, 1, -1, -1, $conf->currency); @@ -2357,34 +1461,5 @@ - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Value spent - if (!empty($arrayfields['value']['checked'])) { - $langs->load("salaries"); - $value = price2num($task_time->thm * $task_time->element_duration / 3600, 'MT', 1); - - print ''; - print 'thm) . '">'; - print price($value, 1, $langs, 1, -1, -1, $conf->currency); - print ''; - print ''; - if (($action == 'editline' || $action == 'splitline') && GETPOST('lineid', 'int') == $task_time->rowid) { - print ''; - print ''; - print '
'; - print ''; - } elseif ($user->hasRight('projet', 'time') || $user->hasRight('projet', 'all', 'creer')) { // Read project and enter time consumed on assigned tasks - if (in_array($task_time->fk_user, $childids) || $user->hasRight('projet', 'all', 'creer')) { - if (getDolGlobalString('MAIN_FEATURES_LEVEL') >= 2) { - print ' '; - print ''; - print img_split('', 'class="pictofixedwidth"'); - print ''; + print '
'; + if (($action == 'editline' || $action == 'splitline') && $_GET['lineid'] == $task_time->rowid) + { + print ''; + print ''; + print '
'; + print ''; + } + elseif ($user->rights->projet->lire || $user->rights->projet->all->creer) // Read project and enter time consumed on assigned tasks + { + if ($task_time->fk_user == $user->id || in_array($task_time->fk_user, $childids) || $user->rights->projet->all->creer) + { + if ($conf->MAIN_FEATURES_LEVEL >= 2) + { + print ' '; + print 'rowid.$param.((empty($id) || $tab == 'timespent') ? '&tab=timespent' : '').'">'; + print img_split(); + print ''; + } + + print ' '; + print 'rowid.$param.((empty($id) || $tab == 'timespent') ? '&tab=timespent' : '').'">'; + print img_edit(); + print ''; + + print ' '; + print 'rowid.$param.((empty($id) || $tab == 'timespent') ? '&tab=timespent' : '').'">'; + print img_delete('default', 'class="pictodelete paddingleft"'); + print ''; + + if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined + { + $selected = 0; + if (in_array($task_time->rowid, $arrayofselected)) $selected = 1; + print ' '; + print ''; + } + } + } + print '
'; + if ($action == 'splitline' && $_GET['lineid'] == $task_time->rowid) + { + if (empty($task_time->task_date_withhour)) + { + print $form->selectDate(($date2 ? $date2 : $date1), 'timeline', 3, 3, 2, "timespent_date", 1, 0); @@ -2454,45 +1572,5 @@ - - print 'rowid.$param.((empty($id) || $tab == 'timespent') ? '&tab=timespent' : '').'">'; - print img_edit('default', 0, 'class="pictofixedwidth paddingleft"'); - print ''; - - print 'rowid.$param.((empty($id) || $tab == 'timespent') ? '&tab=timespent' : '').'">'; - print img_delete('default', 'class="pictodelete paddingleft"'); - print ''; - - if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined - $selected = 0; - if (in_array($task_time->rowid, $arrayofselected)) { - $selected = 1; - } - print ' '; - print ''; - } - } - } - print '
'; - if ($action == 'splitline' && GETPOST('lineid', 'int') == $task_time->rowid) { - if (empty($task_time->element_date_withhour)) { - print $form->selectDate(($date2 ? $date2 : $date1), 'timeline', 3, 3, 2, "timespent_date", 1, 0); - } else { - print $form->selectDate(($date2 ? $date2 : $date1), 'timeline', 1, 1, 2, "timespent_date", 1, 0); - } - } else { - print dol_print_date(($date2 ? $date2 : $date1), ($task_time->element_date_withhour ? 'dayhour' : 'day')); + else print $form->selectDate(($date2 ? $date2 : $date1), 'timeline', 1, 1, 2, "timespent_date", 1, 0); + } + else + { + print dol_print_date(($date2 ? $date2 : $date1), ($task_time->task_date_withhour ? 'dayhour' : 'day')); @@ -2503,15 +1581,5 @@ - // Thirdparty - if (!empty($arrayfields['p.fk_soc']['checked'])) { - print ''; - print ''; - print ''; - $tasktmp->id = $task_time->fk_element; + $tasktmp->id = $task_time->fk_task; @@ -2536,4 +1596,6 @@ - if (!empty($arrayfields['t.element_label']['checked'])) { - if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) { // Not a dedicated task - print ''; - print dol_escape_htmltag($task_time->label); + if (!empty($arrayfields['t.task_label']['checked'])) + { + if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) // Not a dedicated task + { + print ''; + print $task_time->label; @@ -2545,6 +1607,6 @@ - if (!empty($arrayfields['author']['checked'])) { - print ''; - if ($action == 'splitline' && GETPOST('lineid', 'int') == $task_time->rowid) { - if (empty($object->id)) { - $object->fetch($id); - } + if (!empty($arrayfields['author']['checked'])) + { + print ''; + if ($action == 'splitline' && $_GET['lineid'] == $task_time->rowid) + { + if (empty($object->id)) $object->fetch($id); @@ -2559 +1621 @@ - print img_error($langs->trans('FirstAddRessourceToAllocateTime')) . $langs->trans('FirstAddRessourceToAllocateTime'); + print img_error($langs->trans('FirstAddRessourceToAllocateTime')).$langs->trans('FirstAddRessourceToAllocateTime'); @@ -2561 +1623,3 @@ - } else { + } + else + { @@ -2566 +1630 @@ - $userstatic->status = $task_time->user_status; + $userstatic->statut = $task_time->user_status; @@ -2573,5 +1637,9 @@ - if (!empty($arrayfields['t.note']['checked'])) { - print ''; - if ($action == 'splitline' && GETPOST('lineid', 'int') == $task_time->rowid) { - print ''; - } else { + if (!empty($arrayfields['t.note']['checked'])) + { + print ''; + if ($action == 'splitline' && $_GET['lineid'] == $task_time->rowid) + { + print ''; + } + else + { @@ -2581,2 +1649,4 @@ - } elseif ($action == 'splitline' && GETPOST('lineid', 'int') == $task_time->rowid) { - print ''; + } + elseif ($action == 'splitline' && $_GET['lineid'] == $task_time->rowid) + { + print ''; @@ -2586 +1656,2 @@ - if (!empty($arrayfields['t.element_duration']['checked'])) { + if (!empty($arrayfields['t.task_duration']['checked'])) + { @@ -2588,5 +1659,8 @@ - if ($action == 'splitline' && GETPOST('lineid', 'int') == $task_time->rowid) { - print ''; - print $form->select_duration('new_duration', $task_time->element_duration, 0, 'text'); - } else { - print convertSecondToTime($task_time->element_duration, 'allhourmin'); + if ($action == 'splitline' && $_GET['lineid'] == $task_time->rowid) + { + print ''; + print $form->select_duration('new_duration', $task_time->task_duration, 0, 'text'); + } + else + { + print convertSecondToTime($task_time->task_duration, 'allhourmin'); @@ -2597,3 +1671,6 @@ - // Product - if (!empty($arrayfields['t.fk_product']['checked'])) { - print ''; + // Value spent + if (!empty($arrayfields['value']['checked'])) + { + print ''; + $value = price2num($task_time->thm * $task_time->task_duration / 3600); + print price($value, 1, $langs, 1, -1, -1, $conf->currency); @@ -2603,2 +1680,3 @@ - // Value spent - if (!empty($arrayfields['value']['checked'])) { + // Value billed + if (!empty($arrayfields['valuebilled']['checked'])) + { @@ -2606,14 +1684,2 @@ - print ''; - $value = price2num($task_time->thm * $task_time->element_duration / 3600, 'MT', 1); - print price($value, 1, $langs, 1, -1, -1, $conf->currency); - print ''; - print ''; - $valuebilled = price2num($task_time->total_ht, '', 1); - if (isset($task_time->total_ht)) { - print price($valuebilled, 1, $langs, 1, -1, -1, $conf->currency); - } + $valuebilled = price2num($task_time->total_ht); + if (isset($task_time->total_ht)) print price($valuebilled, 1, $langs, 1, -1, -1, $conf->currency); @@ -2629,2 +1695,2 @@ - $parameters = array('arrayfields' => $arrayfields, 'obj' => $task_time, 'mode' => 'split1'); - $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$task_time); + $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook @@ -2642 +1708 @@ - print '
'; - print ''; - print ''; - $tasktmp->id = $task_time->fk_element; + $tasktmp->id = $task_time->fk_task; @@ -2692,2 +1744,4 @@ - if (!empty($arrayfields['t.element_label']['checked'])) { - if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) { // Not a dedicated task + if (!empty($arrayfields['t.task_label']['checked'])) + { + if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) // Not a dedicated task + { @@ -2695 +1749 @@ - print dol_escape_htmltag($task_time->label); + print $task_time->label; @@ -2701,6 +1755,6 @@ - if (!empty($arrayfields['author']['checked'])) { - print ''; - if ($action == 'splitline' && GETPOST('lineid', 'int') == $task_time->rowid) { - if (empty($object->id)) { - $object->fetch($id); - } + if (!empty($arrayfields['author']['checked'])) + { + print ''; + if ($action == 'splitline' && $_GET['lineid'] == $task_time->rowid) + { + if (empty($object->id)) $object->fetch($id); @@ -2715 +1769 @@ - print img_error($langs->trans('FirstAddRessourceToAllocateTime')) . $langs->trans('FirstAddRessourceToAllocateTime'); + print img_error($langs->trans('FirstAddRessourceToAllocateTime')).$langs->trans('FirstAddRessourceToAllocateTime'); @@ -2717 +1771,3 @@ - } else { + } + else + { @@ -2722 +1778 @@ - $userstatic->status = $task_time->user_status; + $userstatic->statut = $task_time->user_status; @@ -2729,5 +1785,9 @@ - if (!empty($arrayfields['t.note']['checked'])) { - print ''; - if ($action == 'splitline' && GETPOST('lineid', 'int') == $task_time->rowid) { - print ''; - } else { + if (!empty($arrayfields['t.note']['checked'])) + { + print ''; + if ($action == 'splitline' && $_GET['lineid'] == $task_time->rowid) + { + print ''; + } + else + { @@ -2737,2 +1797,4 @@ - } elseif ($action == 'splitline' && GETPOST('lineid', 'int') == $task_time->rowid) { - print ''; + } + elseif ($action == 'splitline' && $_GET['lineid'] == $task_time->rowid) + { + print ''; @@ -2742 +1804,2 @@ - if (!empty($arrayfields['t.element_duration']['checked'])) { + if (!empty($arrayfields['t.task_duration']['checked'])) + { @@ -2744 +1807,2 @@ - if ($action == 'splitline' && GETPOST('lineid', 'int') == $task_time->rowid) { + if ($action == 'splitline' && $_GET['lineid'] == $task_time->rowid) + { @@ -2747,2 +1811,4 @@ - } else { - print convertSecondToTime($task_time->element_duration, 'allhourmin'); + } + else + { + print convertSecondToTime($task_time->task_duration, 'allhourmin'); @@ -2753,6 +1818,0 @@ - // Product - if (!empty($arrayfields['t.fk_product']['checked'])) { - print ''; - print '' . $langs->trans("Total") . ''.$form->textwithpicto($langs->trans("Total"), $langs->trans("Totalforthispage")).'' . convertSecondToTime($totalarray['totalduration'], 'allhourmin') . '' . price($totalarray['totalvalue']) . ''.price($totalarray['totalvaluebilled']).''.$langs->trans("Total").''.$langs->trans("Totalforthispage").''.convertSecondToTime($totalarray['totalduration'], 'allhourmin').''.price($totalarray['totalvalue']).''.price($totalarray['totalvaluebilled']).'
'; - print '' . $langs->trans("None") . ''; + foreach ($arrayfields as $value) + { + if ($value['checked']) $totalnboffields++; + } + print '
'; + print ''.$langs->trans("None").''; @@ -2838,3 +1890,0 @@ - $parameters = array('arrayfields' => $arrayfields, 'sql' => $sql); - $reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint;