From 5b1ae96ce9878def8998eafe6a8c9a8c0c596605 Mon Sep 17 00:00:00 2001 From: Guillaume Matheron Date: Sun, 29 Dec 2019 20:45:30 +0100 Subject: [PATCH 01/11] Added two new options when billing time spent on a project : - Create one invoice line per timespent entry - Create one invoice line per task --- htdocs/projet/tasks/time.php | 160 +++++++++++++++++++++++++++-------- 1 file changed, 125 insertions(+), 35 deletions(-) diff --git a/htdocs/projet/tasks/time.php b/htdocs/projet/tasks/time.php index 8e7856759a7..af37e3bfa5f 100644 --- a/htdocs/projet/tasks/time.php +++ b/htdocs/projet/tasks/time.php @@ -342,6 +342,8 @@ if ($action == 'confirm_generateinvoice') $db->begin(); $idprod = GETPOST('productid', 'int'); + $generateinvoicemode = GETPOST('generateinvoicemode', 'string'); + if ($idprod > 0) { $tmpproduct->fetch($idprod); @@ -373,45 +375,132 @@ if ($action == 'confirm_generateinvoice') if (!$error) { - $arrayoftasks = array(); - foreach ($toselect as $key => $value) - { - // Get userid, timepent - $object->fetchTimeSpent($value); - $arrayoftasks[$object->timespent_fk_user]['timespent'] += $object->timespent_duration; - $arrayoftasks[$object->timespent_fk_user]['totalvaluetodivideby3600'] += ($object->timespent_duration * $object->timespent_thm); - } + if ($generateinvoicemode=='onelineperuser') { + $arrayoftasks = array(); + foreach ($toselect as $key => $value) + { + // Get userid, timepent + $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) - { - $fuser->fetch($userid); - //$pu_ht = $value['timespent'] * $fuser->thm; - $username = $fuser->getFullName($langs); + foreach ($arrayoftasks as $userid => $value) + { + $fuser->fetch($userid); + //$pu_ht = $value['timespent'] * $fuser->thm; + $username = $fuser->getFullName($langs); - // Define qty per hour - $qtyhour = round($value['timespent'] / 3600, 2); - $qtyhourtext = convertSecondToTime($value['timespent'], 'all', $conf->global->MAIN_DURATION_OF_WORKDAY); + // Define qty per hour + $qtyhour = round($value['timespent'] / 3600, 2); + $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'); - } + // 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, $qtyhour, $txtva, $localtax1, $localtax2, ($idprod > 0 ? $idprod : 0)); + // Add lines + $lineid = $tmpinvoice->addline($langs->trans("TimeSpentForInvoice", $username).' : '.$qtyhourtext, $pu_ht, $qtyhour, $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; - } - } + // 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 = round($value['timespent'] / 3600, 2); + $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, $qtyhour, $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) + { + // Get userid, timepent + $object->fetchTimeSpent($value); + // $object->id is the task id + $arrayoftasks[$object->id]['timespent'] += $object->timespent_duration; + $arrayoftasks[$object->id]['totalvaluetodivideby3600'] += $object->timespent_duration * $object->timespent_thm; + } + + foreach ($arrayoftasks as $task_id => $value) + { + $ftask = new Task($db); + $ftask->fetch($task_id); + // Define qty per hour + $qtyhour = round($value['timespent'] / 3600, 2); + $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 + $lineName = $ftask->ref.' - '.$ftask->label; + $lineid = $tmpinvoice->addline($lineName, $pu_ht, $qtyhour, $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).')'; + $result = $db->query($sql); + if (!$result) + { + $error++; + setEventMessages($db->lasterror(), null, 'errors'); + break; + } + } + } } if (!$error) @@ -841,7 +930,8 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0) print ''; $tmparray = array( 'onelineperuser'=>'OneLinePerUser', - //'onelinepertask'=>'OneLinePerTask', + 'onelinepertask'=>'OneLinePerTask', + 'onelineperperiod'=>'OneLinePerPeriod', ); print $form->selectarray('generateinvoicemode', $tmparray, 'onelineperuser', 0, 0, 0, '', 1); print ''; From 84d8ca4b332ecb30ab95a99e4432af1cbb0c6406 Mon Sep 17 00:00:00 2001 From: Guillaume Matheron Date: Sun, 29 Dec 2019 20:47:18 +0100 Subject: [PATCH 02/11] Made spaces/tab usage more consistent --- htdocs/projet/tasks/time.php | 1868 +++++++++++++++++----------------- 1 file changed, 934 insertions(+), 934 deletions(-) diff --git a/htdocs/projet/tasks/time.php b/htdocs/projet/tasks/time.php index af37e3bfa5f..98bd7523605 100644 --- a/htdocs/projet/tasks/time.php +++ b/htdocs/projet/tasks/time.php @@ -4,7 +4,7 @@ * Copyright (C) 2010-2012 Regis Houssin * Copyright (C) 2011 Juanjo Menent * Copyright (C) 2018 Ferran Marcet - * Copyright (C) 2018 Frédéric France + * Copyright (C) 2018 Frédéric France * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -21,9 +21,9 @@ */ /** - * \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 */ require '../../main.inc.php'; @@ -38,18 +38,18 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; // Load translation files required by the page $langs->loadLangs(array('projects', 'bills', 'orders')); -$action = GETPOST('action', 'alpha'); +$action = GETPOST('action', 'alpha'); $massaction = GETPOST('massaction', 'alpha'); // The bulk action (combo box choice into lists) -$confirm = GETPOST('confirm', 'alpha'); -$cancel = GETPOST('cancel', 'alpha'); -$toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected into a list +$confirm = GETPOST('confirm', 'alpha'); +$cancel = GETPOST('cancel', 'alpha'); +$toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected into a list $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'myobjectlist'; // To manage different context of search $backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page -$optioncss = GETPOST('optioncss', 'alpha'); +$optioncss = GETPOST('optioncss', 'alpha'); -$id = GETPOST('id', 'int'); -$projectid = GETPOST('projectid', 'int'); -$ref = GETPOST('ref', 'alpha'); +$id = GETPOST('id', 'int'); +$projectid = GETPOST('projectid', 'int'); +$ref = GETPOST('ref', 'alpha'); $withproject = GETPOST('withproject', 'int'); $project_ref = GETPOST('project_ref', 'alpha'); @@ -68,14 +68,14 @@ $search_valuebilled = GETPOST('search_valuebilled', 'int'); // 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->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'); $page = GETPOST("page", 'int'); -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 $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; @@ -113,20 +113,20 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x' $search_month = ''; $search_year = ''; $search_date = ''; - $search_datehour = ''; - $search_datewithhour = ''; - $search_note = ''; - $search_duration = ''; - $search_value = ''; - $search_date_creation = ''; - $search_date_update = ''; - $search_task_ref = ''; - $search_task_label = ''; - $search_user = 0; - $search_valuebilled = ''; - $toselect = ''; - $search_array_options = array(); - $action = ''; + $search_datehour = ''; + $search_datewithhour = ''; + $search_note = ''; + $search_duration = ''; + $search_value = ''; + $search_date_creation = ''; + $search_date_update = ''; + $search_task_ref = ''; + $search_task_label = ''; + $search_user = 0; + $search_valuebilled = ''; + $toselect = ''; + $search_array_options = array(); + $action = ''; } if ($action == 'addtimespent' && $user->rights->projet->lire) @@ -149,61 +149,61 @@ if ($action == 'addtimespent' && $user->rights->projet->lire) if (!$error) { - if ($id || $ref) + if ($id || $ref) { $object->fetch($id, $ref); } else { - if (!GETPOST('taskid', 'int') || GETPOST('taskid', 'int') < 0) - { - setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Task")), null, 'errors'); - $action = 'createtime'; - $error++; - } - else - { - $object->fetch(GETPOST('taskid', 'int')); - } + if (!GETPOST('taskid', 'int') || GETPOST('taskid', 'int') < 0) + { + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Task")), null, 'errors'); + $action = 'createtime'; + $error++; + } + else + { + $object->fetch(GETPOST('taskid', 'int')); + } } if (!$error) { - $object->fetch_projet(); + $object->fetch_projet(); - if (empty($object->project->statut)) - { - setEventMessages($langs->trans("ProjectMustBeValidatedFirst"), null, 'errors'); - $action = 'createtime'; - $error++; - } - 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")); - $object->timespent_withhour = 1; - } - else - { - $object->timespent_date = dol_mktime(12, 0, 0, GETPOST("timemonth"), GETPOST("timeday"), GETPOST("timeyear")); - } - $object->timespent_fk_user = $_POST["userid"]; - $result = $object->addTimeSpent($user); - if ($result >= 0) - { - setEventMessages($langs->trans("RecordSaved"), null, 'mesgs'); - } - else - { - setEventMessages($langs->trans($object->error), null, 'errors'); - $error++; - } - } + if (empty($object->project->statut)) + { + setEventMessages($langs->trans("ProjectMustBeValidatedFirst"), null, 'errors'); + $action = 'createtime'; + $error++; + } + 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")); + $object->timespent_withhour = 1; + } + else + { + $object->timespent_date = dol_mktime(12, 0, 0, GETPOST("timemonth"), GETPOST("timeday"), GETPOST("timeyear")); + } + $object->timespent_fk_user = $_POST["userid"]; + $result = $object->addTimeSpent($user); + if ($result >= 0) + { + setEventMessages($langs->trans("RecordSaved"), null, 'mesgs'); + } + else + { + setEventMessages($langs->trans($object->error), null, 'errors'); + $error++; + } + } } } else @@ -233,12 +233,12 @@ if (($action == 'updateline' || $action == 'updatesplitline') && !$_POST["cancel $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"] * 60; // We store duration in seconds - if (GETPOST("timelinehour") != '' && GETPOST("timelinehour") >= 0) // If hour was entered - { + 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")); $object->timespent_withhour = 1; - } - else + } + else { $object->timespent_date = dol_mktime(12, 0, 0, GETPOST("timelinemonth"), GETPOST("timelineday"), GETPOST("timelineyear")); } @@ -305,24 +305,24 @@ if (GETPOST('projectid', 'int') > 0) $projectidforalltimes = GETPOST('projectid', 'int'); $result = $projectstatic->fetch($projectidforalltimes); - if (!empty($projectstatic->socid)) $projectstatic->fetch_thirdparty(); - $res = $projectstatic->fetch_optionals(); + if (!empty($projectstatic->socid)) $projectstatic->fetch_thirdparty(); + $res = $projectstatic->fetch_optionals(); } elseif (GETPOST('project_ref', 'alpha')) { - $projectstatic->fetch(0, GETPOST('project_ref', 'alpha')); - $projectidforalltimes = $projectstatic->id; - $withproject = 1; + $projectstatic->fetch(0, GETPOST('project_ref', 'alpha')); + $projectidforalltimes = $projectstatic->id; + $withproject = 1; } elseif ($id > 0) { - $object->fetch($id); - $result = $projectstatic->fetch($object->fk_project); + $object->fetch($id); + $result = $projectstatic->fetch($object->fk_project); } if ($action == 'confirm_generateinvoice') { - if (!empty($projectstatic->socid)) $projectstatic->fetch_thirdparty(); + if (!empty($projectstatic->socid)) $projectstatic->fetch_thirdparty(); if (!($projectstatic->thirdparty->id > 0)) @@ -356,10 +356,10 @@ if ($action == 'confirm_generateinvoice') } else { - $pu_ht = 0; - $txtva = get_default_tva($mysoc, $projectstatic->thirdparty); - $localtax1 = get_default_localtax($mysoc, $projectstatic->thirdparty, 1); - $localtax2 = get_default_localtax($mysoc, $projectstatic->thirdparty, 2); + $pu_ht = 0; + $txtva = get_default_tva($mysoc, $projectstatic->thirdparty); + $localtax1 = get_default_localtax($mysoc, $projectstatic->thirdparty, 1); + $localtax2 = get_default_localtax($mysoc, $projectstatic->thirdparty, 2); } $tmpinvoice->socid = $projectstatic->thirdparty->id; @@ -369,147 +369,147 @@ if ($action == 'confirm_generateinvoice') $result = $tmpinvoice->create($user); if ($result <= 0) { - $error++; - setEventMessages($tmpinvoice->error, $tmpinvoice->errors, 'errors'); + $error++; + setEventMessages($tmpinvoice->error, $tmpinvoice->errors, 'errors'); } if (!$error) { - if ($generateinvoicemode=='onelineperuser') { + if ($generateinvoicemode=='onelineperuser') { $arrayoftasks = array(); foreach ($toselect as $key => $value) { - // Get userid, timepent - $object->fetchTimeSpent($value); - $arrayoftasks[$object->timespent_fk_user]['timespent'] += $object->timespent_duration; - $arrayoftasks[$object->timespent_fk_user]['totalvaluetodivideby3600'] += ($object->timespent_duration * $object->timespent_thm); + // Get userid, timepent + $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) { - $fuser->fetch($userid); - //$pu_ht = $value['timespent'] * $fuser->thm; - $username = $fuser->getFullName($langs); + $fuser->fetch($userid); + //$pu_ht = $value['timespent'] * $fuser->thm; + $username = $fuser->getFullName($langs); - // Define qty per hour - $qtyhour = round($value['timespent'] / 3600, 2); - $qtyhourtext = convertSecondToTime($value['timespent'], 'all', $conf->global->MAIN_DURATION_OF_WORKDAY); + // Define qty per hour + $qtyhour = round($value['timespent'] / 3600, 2); + $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'); - } + // 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, $qtyhour, $txtva, $localtax1, $localtax2, ($idprod > 0 ? $idprod : 0)); + // Add lines + $lineid = $tmpinvoice->addline($langs->trans("TimeSpentForInvoice", $username).' : '.$qtyhourtext, $pu_ht, $qtyhour, $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; - } + // 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') { + } + 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; + // 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); + $userid = $value['user']; + $fuser->fetch($userid); + //$pu_ht = $value['timespent'] * $fuser->thm; + $username = $fuser->getFullName($langs); - // Define qty per hour - $qtyhour = round($value['timespent'] / 3600, 2); - $qtyhourtext = convertSecondToTime($value['timespent'], 'all', $conf->global->MAIN_DURATION_OF_WORKDAY); + // Define qty per hour + $qtyhour = round($value['timespent'] / 3600, 2); + $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'); - } + // 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, $qtyhour, $txtva, $localtax1, $localtax2, ($idprod > 0 ? $idprod : 0)); + // Add lines + $lineid = $tmpinvoice->addline($value['note'], $pu_ht, $qtyhour, $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; - } + // 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') { + } + elseif ($generateinvoicemode=='onelinepertask') { $arrayoftasks = array(); foreach ($toselect as $key => $value) { - // Get userid, timepent - $object->fetchTimeSpent($value); - // $object->id is the task id - $arrayoftasks[$object->id]['timespent'] += $object->timespent_duration; - $arrayoftasks[$object->id]['totalvaluetodivideby3600'] += $object->timespent_duration * $object->timespent_thm; + // Get userid, timepent + $object->fetchTimeSpent($value); + // $object->id is the task id + $arrayoftasks[$object->id]['timespent'] += $object->timespent_duration; + $arrayoftasks[$object->id]['totalvaluetodivideby3600'] += $object->timespent_duration * $object->timespent_thm; } foreach ($arrayoftasks as $task_id => $value) { - $ftask = new Task($db); - $ftask->fetch($task_id); - // Define qty per hour - $qtyhour = round($value['timespent'] / 3600, 2); - $qtyhourtext = convertSecondToTime($value['timespent'], 'all', $conf->global->MAIN_DURATION_OF_WORKDAY); + $ftask = new Task($db); + $ftask->fetch($task_id); + // Define qty per hour + $qtyhour = round($value['timespent'] / 3600, 2); + $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'); - } + // If no unit price known + if (empty($pu_ht)) + { + $pu_ht = price2num($value['totalvaluetodivideby3600'] / 3600, 'MU'); + } - // Add lines - $lineName = $ftask->ref.' - '.$ftask->label; - $lineid = $tmpinvoice->addline($lineName, $pu_ht, $qtyhour, $txtva, $localtax1, $localtax2, ($idprod > 0 ? $idprod : 0)); + // Add lines + $lineName = $ftask->ref.' - '.$ftask->label; + $lineid = $tmpinvoice->addline($lineName, $pu_ht, $qtyhour, $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).')'; - $result = $db->query($sql); - if (!$result) - { - $error++; - setEventMessages($db->lasterror(), null, 'errors'); - break; - } + // 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).')'; + $result = $db->query($sql); + if (!$result) + { + $error++; + setEventMessages($db->lasterror(), null, 'errors'); + break; + } } - } + } } if (!$error) { - $urltoinvoice = $tmpinvoice->getNomUrl(0); - setEventMessages($langs->trans("InvoiceGeneratedFromTimeSpent", $urltoinvoice), null, 'mesgs'); - //var_dump($tmpinvoice); + $urltoinvoice = $tmpinvoice->getNomUrl(0); + setEventMessages($langs->trans("InvoiceGeneratedFromTimeSpent", $urltoinvoice), null, 'mesgs'); + //var_dump($tmpinvoice); - $db->commit(); + $db->commit(); } else { @@ -536,14 +536,14 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0) { /* * Fiche projet en mode visu - */ - if ($projectidforalltimes > 0) - { - $result = $projectstatic->fetch($projectidforalltimes); - if (!empty($projectstatic->socid)) $projectstatic->fetch_thirdparty(); - $res = $projectstatic->fetch_optionals(); - } - elseif ($object->fetch($id, $ref) >= 0) + */ + if ($projectidforalltimes > 0) + { + $result = $projectstatic->fetch($projectidforalltimes); + if (!empty($projectstatic->socid)) $projectstatic->fetch_thirdparty(); + $res = $projectstatic->fetch_optionals(); + } + elseif ($object->fetch($id, $ref) >= 0) { if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_TASK) && method_exists($object, 'fetchComments') && empty($object->comments)) $object->fetchComments(); $result = $projectstatic->fetch($object->fk_project); @@ -552,10 +552,10 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0) $res = $projectstatic->fetch_optionals(); $object->project = clone $projectstatic; - } + } - $userRead = $projectstatic->restrictedProjectArea($user, 'read'); - $linktocreatetime = ''; + $userRead = $projectstatic->restrictedProjectArea($user, 'read'); + $linktocreatetime = ''; if ($projectstatic->id > 0) { @@ -571,122 +571,122 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0) // Project card - $linkback = ''.$langs->trans("BackToList").''; + $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 .= '
'; + $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').")"; - } + // 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); + dol_banner_tab($projectstatic, 'project_ref', $linkback, 1, 'ref', 'ref', $morehtmlref); - print '
'; - print '
'; - print '
'; + print '
'; + print '
'; + print '
'; - print ''; + print '
'; - // Usage - print ''; - print ''; + // Usage + print ''; + print ''; - // Visibility - print ''; + // Visibility + print ''; - // Date start - end - print ''; + // Date start - end + print ''; - // Budget - print ''; + // Budget + print ''; - // Other attributes - $cols = 2; - //include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; + // 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 '
'; + 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("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("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 '
'.$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 '
'; + print '
'; + print '
'; + print '
'; + print '
'; - print ''; + print '
'; - // Description - print ''; + // Description + print ''; - // Bill time - if (empty($conf->global->PROJECT_HIDE_TASKS) && !empty($conf->global->PROJECT_BILL_TIME_SPENT)) - { - print ''; - } + // Bill time + if (empty($conf->global->PROJECT_HIDE_TASKS) && !empty($conf->global->PROJECT_BILL_TIME_SPENT)) + { + print ''; + } - // Categories - if ($conf->categorie->enabled) { - print '"; - } + // Categories + if ($conf->categorie->enabled) { + print '"; + } - print '
'.$langs->trans("Description").''; - print nl2br($projectstatic->description); - print '
'.$langs->trans("Description").''; + print nl2br($projectstatic->description); + print '
'.$langs->trans("BillTime").''; - print yn($projectstatic->usage_bill_time); - print '
'.$langs->trans("BillTime").''; + print yn($projectstatic->usage_bill_time); + print '
'.$langs->trans("Categories").''; - print $form->showCategories($projectstatic->id, 'project', 1); - print "
'.$langs->trans("Categories").''; + print $form->showCategories($projectstatic->id, 'project', 1); + print "
'; + print ''; - print '
'; - print '
'; - print '
'; + print '
'; + print '
'; + print '
'; - print '
'; + print '
'; dol_fiche_end(); @@ -694,46 +694,46 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0) } // Link to create time - $linktocreatetimeBtnStatus = 0; - $linktocreatetimeUrl = ''; - $linktocreatetimeHelpText = ''; - if ($user->rights->projet->all->lire || $user->rights->projet->lire) // To enter time, read permission is enough + $linktocreatetimeBtnStatus = 0; + $linktocreatetimeUrl = ''; + $linktocreatetimeHelpText = ''; + if ($user->rights->projet->all->lire || $user->rights->projet->lire) // To enter time, read permission is enough { if ($projectstatic->public || $userRead > 0) - { - $linktocreatetimeBtnStatus = 1; + { + $linktocreatetimeBtnStatus = 1; - 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 - { - $linktocreatetimeBtnStatus = -2; - $linktocreatetimeHelpText = $langs->trans("NotOwnerOfProject"); - } + 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 + { + $linktocreatetimeBtnStatus = -2; + $linktocreatetimeHelpText = $langs->trans("NotOwnerOfProject"); + } } - $linktocreatetime = dolGetButtonTitle($langs->trans('AddTimeSpent'), $linktocreatetimeHelpText, 'fa fa-plus-circle', $linktocreatetimeUrl, '', $linktocreatetimeBtnStatus); - } + $linktocreatetime = dolGetButtonTitle($langs->trans('AddTimeSpent'), $linktocreatetimeHelpText, 'fa fa-plus-circle', $linktocreatetimeUrl, '', $linktocreatetimeBtnStatus); + } $massactionbutton = ''; 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); + $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); } // Show section with information of task. If id of task is not defined and project id defined, then $projectidforalltimes is not empty. @@ -762,17 +762,17 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0) // Project if (empty($withproject)) { - $morehtmlref .= '
'; - $morehtmlref .= $langs->trans("Project").': '; - $morehtmlref .= $projectstatic->getNomUrl(1); - $morehtmlref .= '
'; + $morehtmlref .= '
'; + $morehtmlref .= $langs->trans("Project").': '; + $morehtmlref .= $projectstatic->getNomUrl(1); + $morehtmlref .= '
'; - // Third party - $morehtmlref .= $langs->trans("ThirdParty").': '; - if (is_object($projectstatic->thirdparty)) { - $morehtmlref .= $projectstatic->thirdparty->getNomUrl(1); - } - $morehtmlref .= '
'; + // Third party + $morehtmlref .= $langs->trans("ThirdParty").': '; + if (is_object($projectstatic->thirdparty)) { + $morehtmlref .= $projectstatic->thirdparty->getNomUrl(1); + } + $morehtmlref .= '
'; } dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref, $param); @@ -780,7 +780,7 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0) print '
'; print '
'; - print '
'; + print '
'; print ''; // Date start - Date end @@ -846,127 +846,127 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0) 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); } - // Initialize technical object to manage hooks. Note that conf->hooks_modules contains array - $hookmanager->initHooks(array('tasktimelist')); + // Initialize technical object to manage hooks. Note that conf->hooks_modules contains array + $hookmanager->initHooks(array('tasktimelist')); - // Definition of fields for list - $arrayfields = array(); - $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)); - // Extra fields - 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])); - } - } - $arrayfields = dol_sort_array($arrayfields, 'position'); + // Definition of fields for list + $arrayfields = array(); + $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)); + // Extra fields + 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])); + } + } + $arrayfields = dol_sort_array($arrayfields, 'position'); - $param = ''; - 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); - /* - // Add $param from extra fields - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; - */ - if ($id) $param .= '&id='.urlencode($id); - if ($projectid) $param .= '&projectid='.urlencode($projectid); - if ($withproject) $param .= '&withproject='.urlencode($withproject); + $param = ''; + 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); + /* + // Add $param from extra fields + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; + */ + if ($id) $param .= '&id='.urlencode($id); + if ($projectid) $param .= '&projectid='.urlencode($projectid); + if ($withproject) $param .= '&withproject='.urlencode($withproject); - print ''; - if ($optioncss != '') print ''; - print ''; - 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 ''; + if ($optioncss != '') print ''; + print ''; + 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 ''; + print ''; + print ''; - if ($massaction == 'generateinvoice') - { - //var_dump($_REQUEST); - print ''; + if ($massaction == 'generateinvoice') + { + //var_dump($_REQUEST); + print ''; - print '
'; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - if ($conf->service->enabled) - { - 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('ServiceToUseOnLines'); - print ''; - $form->select_produits('', 'productid', '1', 0, 0, 1, 2, '', 0, array(), 0, 'None', 0, 'maxwidth500'); - print '
'; - print $langs->trans('ValidateInvoices'); - print ''; - print $form->selectyesno('validate_invoices', 0, 1); - print '
'; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + if ($conf->service->enabled) + { + 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('ServiceToUseOnLines'); + print ''; + $form->select_produits('', 'productid', '1', 0, 0, 1, 2, '', 0, array(), 0, 'None', 0, 'maxwidth500'); + print '
'; + print $langs->trans('ValidateInvoices'); + print ''; + print $form->selectyesno('validate_invoices', 0, 1); + print '
'; - print '
'; - print '
'; - print ' '; - print ''; - print '
'; - print '
'; - } + print '
'; + print '
'; + print ' '; + print ''; + print '
'; + print '
'; + } /* - * List of time spent + * List of time spent */ $tasks = array(); @@ -995,31 +995,31 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0) $nbtotalofrecords = ''; 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 - { - $page = 0; - $offset = 0; - } + $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 + { + $page = 0; + $offset = 0; + } } // 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; + $num = $nbtotalofrecords; } else { - $sql .= $db->plimit($limit + 1, $offset); + $sql .= $db->plimit($limit + 1, $offset); - $resql = $db->query($sql); - if (!$resql) - { - dol_print_error($db); - exit; - } + $resql = $db->query($sql); + if (!$resql) + { + dol_print_error($db); + exit; + } - $num = $db->num_rows($resql); + $num = $db->num_rows($resql); } if ($num >= 0) @@ -1034,11 +1034,11 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0) } else { - print ''."\n"; + print ''."\n"; - $title = $langs->trans("ListTaskTimeForTask"); + $title = $langs->trans("ListTaskTimeForTask"); - print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'generic', 0, $linktocreatetime, '', $limit); + print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'generic', 0, $linktocreatetime, '', $limit); } $i = 0; @@ -1061,9 +1061,9 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0) if ($action == 'createtime' && $user->rights->projet->lire) { print ''."\n"; - if (!empty($id)) print ''; + if (!empty($id)) print ''; - print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table + print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table print ''; print ''; @@ -1075,7 +1075,7 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0) print ''; if (empty($conf->global->PROJECT_HIDE_TASKS) && !empty($conf->global->PROJECT_BILL_TIME_SPENT)) { - print ''; + print ''; } print ''; print "\n"; @@ -1092,9 +1092,9 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0) // Task if (empty($id)) { - print ''; + print ''; } // Contributor @@ -1138,8 +1138,8 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0) // Invoiced if (empty($conf->global->PROJECT_HIDE_TASKS) && !empty($conf->global->PROJECT_BILL_TIME_SPENT)) { - print ''; + print ''; } print '
'.$langs->trans("ProgressDeclared").'
'; - $formproject->selectTasks(-1, GETPOST('taskid', 'int'), 'taskid', 0, 0, 1, 1, 0, 0, 'maxwidth300', $projectstatic->id, ''); - print ''; + $formproject->selectTasks(-1, GETPOST('taskid', 'int'), 'taskid', 0, 0, 1, 1, 0, 0, 'maxwidth300', $projectstatic->id, ''); + print ''; - print ''; + print ''; @@ -1163,16 +1163,16 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0) if (!empty($moreforfilter)) { - print '
'; - print $moreforfilter; - print '
'; + print '
'; + print $moreforfilter; + print '
'; } $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields $selectedfields .= (is_array($arrayofmassactions) && count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : ''); - print '
'; + print '
'; print ''."\n"; // Fields title search @@ -1186,23 +1186,23 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0) $formother->select_year($search_year, 'search_year', 1, 20, 5); 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 ''; - } - // Author - if (!empty($arrayfields['author']['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 ''; + } + // Author + if (!empty($arrayfields['author']['checked'])) print ''; // Note - if (!empty($arrayfields['t.note']['checked'])) print ''; + if (!empty($arrayfields['t.note']['checked'])) print ''; // Duration - if (!empty($arrayfields['t.task_duration']['checked'])) print ''; + if (!empty($arrayfields['t.task_duration']['checked'])) print ''; // Value in main currency - if (!empty($arrayfields['value']['checked'])) print ''; - // Value billed - if (!empty($arrayfields['valuebilled']['checked'])) print ''; + if (!empty($arrayfields['value']['checked'])) print ''; + // Value billed + if (!empty($arrayfields['valuebilled']['checked'])) print ''; - /* + /* // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; */ @@ -1218,26 +1218,26 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0) print ''."\n"; print ''; - 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_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 '); + 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 '); /* - // Extra fields + // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; */ - // Hook fields + // Hook fields $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 - print $hookmanager->resPrint; - print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', 'width="80"', $sortfield, $sortorder, 'center maxwidthsearch '); + $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', 'width="80"', $sortfield, $sortorder, 'center maxwidthsearch '); print "\n"; $tasktmp = new Task($db); @@ -1252,7 +1252,7 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0) $totalarray = array(); foreach ($tasks as $task_time) { - if ($i >= $limit) break; + if ($i >= $limit) break; print ''; @@ -1262,125 +1262,125 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0) // Date if (!empty($arrayfields['t.task_date']['checked'])) { - print ''; - if (!$i) $totalarray['nbfield']++; + print ''; + if (!$i) $totalarray['nbfield']++; } // Task ref - if (!empty($arrayfields['t.task_ref']['checked'])) - { - if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) // Not a dedicated task - { - print ''; - if (!$i) $totalarray['nbfield']++; - } - } + if (!empty($arrayfields['t.task_ref']['checked'])) + { + if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) // Not a dedicated task + { + print ''; + if (!$i) $totalarray['nbfield']++; + } + } // 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 (!empty($arrayfields['t.task_label']['checked'])) + { + if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) // Not a dedicated task + { + print ''; + if (!$i) $totalarray['nbfield']++; + } + } - // User - if (!empty($arrayfields['author']['checked'])) - { - print ''; - if (!$i) $totalarray['nbfield']++; - } + // User + if (!empty($arrayfields['author']['checked'])) + { + print ''; + if (!$i) $totalarray['nbfield']++; + } // Note - if (!empty($arrayfields['t.note']['checked'])) - { - print ''; - if (!$i) $totalarray['nbfield']++; - } - elseif ($action == 'editline' && $_GET['lineid'] == $task_time->rowid) - { - print ''; - } + if (!empty($arrayfields['t.note']['checked'])) + { + print ''; + if (!$i) $totalarray['nbfield']++; + } + elseif ($action == 'editline' && $_GET['lineid'] == $task_time->rowid) + { + print ''; + } // Time spent - if (!empty($arrayfields['t.task_duration']['checked'])) - { - print ''; - 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; - } + if (!empty($arrayfields['t.task_duration']['checked'])) + { + print ''; + 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'])) - { + if (!empty($arrayfields['value']['checked'])) + { print ''; - if (!$i) $totalarray['nbfield']++; - if (!$i) $totalarray['totalvaluebilledfield'] = $totalarray['nbfield']; - $totalarray['totalvaluebilled'] += $valuebilled; - } + // Invoiced + if (!empty($arrayfields['valuebilled']['checked'])) + { + print ''; + if (!$i) $totalarray['nbfield']++; + if (!$i) $totalarray['totalvaluebilledfield'] = $totalarray['nbfield']; + $totalarray['totalvaluebilled'] += $valuebilled; + } - /* - // 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'; + */ // Fields from hook $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$task_time); $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; - // Action column + // Action column print ''; - if (!$i) $totalarray['nbfield']++; + print ''; + if (!$i) $totalarray['nbfield']++; print "\n"; @@ -1483,298 +1483,298 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0) if ($action == 'splitline' && $_GET['lineid'] == $task_time->rowid) { - print ''; + print ''; - // Date - if (!empty($arrayfields['t.task_date']['checked'])) - { - print ''; - } + // Date + if (!empty($arrayfields['t.task_date']['checked'])) + { + print ''; + } - // Task ref - if (!empty($arrayfields['t.task_ref']['checked'])) - { - if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) // Not a dedicated task - { - print ''; - } - } + // Task ref + if (!empty($arrayfields['t.task_ref']['checked'])) + { + if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) // Not a dedicated task + { + print ''; + } + } - // Task label - if (!empty($arrayfields['t.task_label']['checked'])) - { - if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) // Not a dedicated task - { - print ''; - } - } + // Task label + if (!empty($arrayfields['t.task_label']['checked'])) + { + if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) // Not a dedicated task + { + print ''; + } + } - // User - if (!empty($arrayfields['author']['checked'])) - { - print ''; - } + // User + if (!empty($arrayfields['author']['checked'])) + { + print ''; + } - // Note - if (!empty($arrayfields['t.note']['checked'])) - { - print ''; - } - elseif ($action == 'splitline' && $_GET['lineid'] == $task_time->rowid) - { - print ''; - } + // Note + if (!empty($arrayfields['t.note']['checked'])) + { + print ''; + } + elseif ($action == 'splitline' && $_GET['lineid'] == $task_time->rowid) + { + print ''; + } - // Time spent - if (!empty($arrayfields['t.task_duration']['checked'])) - { - print ''; - } + // Time spent + if (!empty($arrayfields['t.task_duration']['checked'])) + { + print ''; + } - // Value spent - if (!empty($arrayfields['value']['checked'])) - { - print ''; - } + // Value spent + if (!empty($arrayfields['value']['checked'])) + { + print ''; + } - // Value billed - if (!empty($arrayfields['valuebilled']['checked'])) - { - print ''; - } + // Value billed + if (!empty($arrayfields['valuebilled']['checked'])) + { + print ''; + } - /* - // 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'; + */ - // Fields from hook - $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$task_time); - $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; + // Fields from hook + $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$task_time); + $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; - // Action column - print ''; + // Action column + print ''; - print "\n"; + print "\n"; - // Line for second dispatching + // Line for second dispatching - print ''; + print ''; - // Date - if (!empty($arrayfields['t.task_date']['checked'])) - { - print ''; - } + // Date + if (!empty($arrayfields['t.task_date']['checked'])) + { + print ''; + } - // Task ref - if (!empty($arrayfields['t.task_ref']['checked'])) - { - if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) // Not a dedicated task - { - print ''; - } - } + // Task ref + if (!empty($arrayfields['t.task_ref']['checked'])) + { + if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) // Not a dedicated task + { + print ''; + } + } - // Task label - if (!empty($arrayfields['t.task_label']['checked'])) - { - if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) // Not a dedicated task - { - print ''; - } - } + // Task label + if (!empty($arrayfields['t.task_label']['checked'])) + { + if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) // Not a dedicated task + { + print ''; + } + } - // User - if (!empty($arrayfields['author']['checked'])) - { - print ''; - } + // User + if (!empty($arrayfields['author']['checked'])) + { + print ''; + } - // Note - if (!empty($arrayfields['t.note']['checked'])) - { - print ''; - } - elseif ($action == 'splitline' && $_GET['lineid'] == $task_time->rowid) - { - print ''; - } + // Note + if (!empty($arrayfields['t.note']['checked'])) + { + print ''; + } + elseif ($action == 'splitline' && $_GET['lineid'] == $task_time->rowid) + { + print ''; + } - // Time spent - if (!empty($arrayfields['t.task_duration']['checked'])) - { - print ''; - } + // Time spent + if (!empty($arrayfields['t.task_duration']['checked'])) + { + print ''; + } - // Value spent - if (!empty($arrayfields['value']['checked'])) - { - print ''; - } + // Value spent + if (!empty($arrayfields['value']['checked'])) + { + print ''; + } - // Value billed - if (!empty($arrayfields['valuebilled']['checked'])) - { - print ''; - } + // Value billed + if (!empty($arrayfields['valuebilled']['checked'])) + { + print ''; + } - /* - // 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'; + */ - // Fields from hook - $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$task_time); - $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; + // Fields from hook + $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$task_time); + $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; - // Action column - print ''; + // Action column + print ''; - print "\n"; + print "\n"; } $i++; From 458c1e2174c5a9af21e7830e625682656a020002 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Sun, 29 Dec 2019 19:58:38 +0000 Subject: [PATCH 03/11] Fixing style errors. --- htdocs/projet/tasks/time.php | 228 +++++++++++++++++------------------ 1 file changed, 114 insertions(+), 114 deletions(-) diff --git a/htdocs/projet/tasks/time.php b/htdocs/projet/tasks/time.php index 98bd7523605..1f692386c74 100644 --- a/htdocs/projet/tasks/time.php +++ b/htdocs/projet/tasks/time.php @@ -375,132 +375,132 @@ if ($action == 'confirm_generateinvoice') if (!$error) { - if ($generateinvoicemode=='onelineperuser') { - $arrayoftasks = array(); - foreach ($toselect as $key => $value) - { - // Get userid, timepent - $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) - { - $fuser->fetch($userid); - //$pu_ht = $value['timespent'] * $fuser->thm; - $username = $fuser->getFullName($langs); - - // Define qty per hour - $qtyhour = round($value['timespent'] / 3600, 2); - $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'); + if ($generateinvoicemode=='onelineperuser') { + $arrayoftasks = array(); + foreach ($toselect as $key => $value) + { + // Get userid, timepent + $object->fetchTimeSpent($value); + $arrayoftasks[$object->timespent_fk_user]['timespent'] += $object->timespent_duration; + $arrayoftasks[$object->timespent_fk_user]['totalvaluetodivideby3600'] += ($object->timespent_duration * $object->timespent_thm); } - // Add lines - $lineid = $tmpinvoice->addline($langs->trans("TimeSpentForInvoice", $username).' : '.$qtyhourtext, $pu_ht, $qtyhour, $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) + foreach ($arrayoftasks as $userid => $value) { - $error++; - setEventMessages($db->lasterror(), null, 'errors'); - break; + $fuser->fetch($userid); + //$pu_ht = $value['timespent'] * $fuser->thm; + $username = $fuser->getFullName($langs); + + // Define qty per hour + $qtyhour = round($value['timespent'] / 3600, 2); + $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, $qtyhour, $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 = round($value['timespent'] / 3600, 2); - $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'); + } + 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; } - // Add lines - $lineid = $tmpinvoice->addline($value['note'], $pu_ht, $qtyhour, $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) + foreach ($arrayoftasks as $timespent_id => $value) { - $error++; - setEventMessages($db->lasterror(), null, 'errors'); - break; + $userid = $value['user']; + $fuser->fetch($userid); + //$pu_ht = $value['timespent'] * $fuser->thm; + $username = $fuser->getFullName($langs); + + // Define qty per hour + $qtyhour = round($value['timespent'] / 3600, 2); + $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, $qtyhour, $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) - { - // Get userid, timepent - $object->fetchTimeSpent($value); - // $object->id is the task id - $arrayoftasks[$object->id]['timespent'] += $object->timespent_duration; - $arrayoftasks[$object->id]['totalvaluetodivideby3600'] += $object->timespent_duration * $object->timespent_thm; - } - - foreach ($arrayoftasks as $task_id => $value) - { - $ftask = new Task($db); - $ftask->fetch($task_id); - // Define qty per hour - $qtyhour = round($value['timespent'] / 3600, 2); - $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'); + } + elseif ($generateinvoicemode=='onelinepertask') { + $arrayoftasks = array(); + foreach ($toselect as $key => $value) + { + // Get userid, timepent + $object->fetchTimeSpent($value); + // $object->id is the task id + $arrayoftasks[$object->id]['timespent'] += $object->timespent_duration; + $arrayoftasks[$object->id]['totalvaluetodivideby3600'] += $object->timespent_duration * $object->timespent_thm; } - // Add lines - $lineName = $ftask->ref.' - '.$ftask->label; - $lineid = $tmpinvoice->addline($lineName, $pu_ht, $qtyhour, $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).')'; - $result = $db->query($sql); - if (!$result) + foreach ($arrayoftasks as $task_id => $value) { - $error++; - setEventMessages($db->lasterror(), null, 'errors'); - break; + $ftask = new Task($db); + $ftask->fetch($task_id); + // Define qty per hour + $qtyhour = round($value['timespent'] / 3600, 2); + $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 + $lineName = $ftask->ref.' - '.$ftask->label; + $lineid = $tmpinvoice->addline($lineName, $pu_ht, $qtyhour, $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).')'; + $result = $db->query($sql); + if (!$result) + { + $error++; + setEventMessages($db->lasterror(), null, 'errors'); + break; + } } - } - } + } } if (!$error) From 4f65f8d0950d07f3bc78e772526e55b8364878a5 Mon Sep 17 00:00:00 2001 From: Guillaume Matheron Date: Thu, 2 Jan 2020 14:13:26 +0100 Subject: [PATCH 04/11] Fixed bug (missing include) in formmargin.class.php, affecting display of propal --- htdocs/core/class/html.formmargin.class.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/core/class/html.formmargin.class.php b/htdocs/core/class/html.formmargin.class.php index 345a94b3a62..1f091fc81fd 100644 --- a/htdocs/core/class/html.formmargin.class.php +++ b/htdocs/core/class/html.formmargin.class.php @@ -21,6 +21,8 @@ * \brief Fichier de la classe des fonctions predefinie de composants html autre */ +require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; + /** * Classe permettant la generation de composants html autre From e9e0aae1ce8634cf1b2769404734bde76d2669c1 Mon Sep 17 00:00:00 2001 From: Guillaume Matheron Date: Thu, 2 Jan 2020 14:59:53 +0100 Subject: [PATCH 05/11] Added option to bill time spent on a task to an existing draft invoice (for instance a recurrent bill) --- htdocs/core/class/html.form.class.php | 167 ++++++++++++++++++++++++++ htdocs/projet/tasks/time.php | 27 ++++- 2 files changed, 188 insertions(+), 6 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 6b0950b4f8d..4681a9f749a 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -7839,4 +7839,171 @@ class Form return $out; } + + /** + * Output a combo list with invoices qualified for a third party + * + * @param int $socid Id third party (-1=all, 0=only projects not linked to a third party, id=projects not linked or linked to third party id) + * @param int $selected Id invoice preselected + * @param string $htmlname Name of HTML select + * @param int $maxlength Maximum length of label + * @param int $option_only Return only html options lines without the select tag + * @param string $show_empty Add an empty line ('1' or string to show for empty line) + * @param int $discard_closed Discard closed projects (0=Keep,1=hide completely,2=Disable) + * @param int $forcefocus Force focus on field (works with javascript only) + * @param int $disabled Disabled + * @param string $morecss More css added to the select component + * @param string $projectsListId ''=Automatic filter on project allowed. List of id=Filter on project ids. + * @param string $showproject 'all' = Show project info, ''=Hide project info + * @param User $usertofilter User object to use for filtering + * @return int Nbr of project if OK, <0 if KO + */ + public function selectInvoice($socid = -1, $selected = '', $htmlname = 'invoiceid', $maxlength = 24, $option_only = 0, $show_empty = '1', $discard_closed = 0, $forcefocus = 0, $disabled = 0, $morecss = 'maxwidth500', $projectsListId = '', $showproject = 'all', $usertofilter = null) + { + global $user,$conf,$langs; + + require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; + + if (is_null($usertofilter)) + { + $usertofilter = $user; + } + + $out=''; + + $hideunselectables = false; + if (! empty($conf->global->PROJECT_HIDE_UNSELECTABLES)) $hideunselectables = true; + + if (empty($projectsListId)) + { + if (empty($usertofilter->rights->projet->all->lire)) + { + $projectstatic=new Project($this->db); + $projectsListId = $projectstatic->getProjectsAuthorizedForUser($usertofilter, 0, 1); + } + } + + // Search all projects + $sql = 'SELECT f.rowid, f.ref as fref, "nolabel" as flabel, p.rowid as pid, f.ref, + p.title, p.fk_soc, p.fk_statut, p.public,'; + $sql.= ' s.nom as name'; + $sql.= ' FROM '.MAIN_DB_PREFIX .'projet as p'; + $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe as s ON s.rowid = p.fk_soc,'; + $sql.= ' '.MAIN_DB_PREFIX.'facture as f'; + $sql.= " WHERE p.entity IN (".getEntity('project').")"; + $sql.= " AND f.fk_projet = p.rowid AND f.fk_statut=0"; //Brouillons seulement + //if ($projectsListId) $sql.= " AND p.rowid IN (".$projectsListId.")"; + //if ($socid == 0) $sql.= " AND (p.fk_soc=0 OR p.fk_soc IS NULL)"; + //if ($socid > 0) $sql.= " AND (p.fk_soc=".$socid." OR p.fk_soc IS NULL)"; + $sql.= " GROUP BY f.ref ORDER BY p.ref, f.ref ASC"; + + $resql=$this->db->query($sql); + if ($resql) + { + // Use select2 selector + if (! empty($conf->use_javascript_ajax)) + { + include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php'; + $comboenhancement = ajax_combobox($htmlname, '', 0, $forcefocus); + $out.=$comboenhancement; + $morecss='minwidth200imp maxwidth500'; + } + + if (empty($option_only)) { + $out.= ''; + } + + print $out; + + $this->db->free($resql); + return $num; + } + else + { + dol_print_error($this->db); + return -1; + } + } } diff --git a/htdocs/projet/tasks/time.php b/htdocs/projet/tasks/time.php index 1f692386c74..485ba8bf173 100644 --- a/htdocs/projet/tasks/time.php +++ b/htdocs/projet/tasks/time.php @@ -343,6 +343,7 @@ if ($action == 'confirm_generateinvoice') $db->begin(); $idprod = GETPOST('productid', 'int'); $generateinvoicemode = GETPOST('generateinvoicemode', 'string'); + $invoiceToUse = GETPOST('invoiceid', 'int'); if ($idprod > 0) { @@ -366,12 +367,17 @@ if ($action == 'confirm_generateinvoice') $tmpinvoice->date = dol_mktime(GETPOST('rehour', 'int'), GETPOST('remin', 'int'), GETPOST('resec', 'int'), GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int')); $tmpinvoice->fk_project = $projectstatic->id; - $result = $tmpinvoice->create($user); - if ($result <= 0) - { - $error++; - setEventMessages($tmpinvoice->error, $tmpinvoice->errors, 'errors'); - } + if ($invoiceToUse) { + $tmpinvoice->fetch($invoiceToUse); + } + else { + $result = $tmpinvoice->create($user); + if ($result <= 0) + { + $error++; + setEventMessages($tmpinvoice->error, $tmpinvoice->errors, 'errors'); + } + } if (!$error) { @@ -947,6 +953,15 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0) print ''; print ''; } + print ''; + print ''; + print ''; + print ''; /*print ''; print ''; print ''; print ''; /*print ''; From 19e69dc8690caa0a507b8d861f3358fa1f2fe7a3 Mon Sep 17 00:00:00 2001 From: Guillaume Matheron Date: Thu, 2 Jan 2020 15:18:18 +0100 Subject: [PATCH 07/11] Creating invoice from time spent now takes in to account the product duration to compute the quantity to bill --- htdocs/projet/tasks/time.php | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/htdocs/projet/tasks/time.php b/htdocs/projet/tasks/time.php index 485ba8bf173..e803d86f388 100644 --- a/htdocs/projet/tasks/time.php +++ b/htdocs/projet/tasks/time.php @@ -345,9 +345,23 @@ if ($action == 'confirm_generateinvoice') $generateinvoicemode = GETPOST('generateinvoicemode', 'string'); $invoiceToUse = GETPOST('invoiceid', 'int'); + $prodDurationHours = 1.0; if ($idprod > 0) { $tmpproduct->fetch($idprod); + 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; $dataforprice = $tmpproduct->getSellPrice($mysoc, $projectstatic->thirdparty, 0); $pu_ht = empty($dataforprice['pu_ht']) ? 0 : $dataforprice['pu_ht']; @@ -408,7 +422,7 @@ if ($action == 'confirm_generateinvoice') } // Add lines - $lineid = $tmpinvoice->addline($langs->trans("TimeSpentForInvoice", $username).' : '.$qtyhourtext, $pu_ht, $qtyhour, $txtva, $localtax1, $localtax2, ($idprod > 0 ? $idprod : 0)); + $lineid = $tmpinvoice->addline($langs->trans("TimeSpentForInvoice", $username).' : '.$qtyhourtext, $pu_ht, $qtyhour/$prodDurationHours, $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; @@ -452,7 +466,7 @@ if ($action == 'confirm_generateinvoice') } // Add lines - $lineid = $tmpinvoice->addline($value['note'], $pu_ht, $qtyhour, $txtva, $localtax1, $localtax2, ($idprod > 0 ? $idprod : 0)); + $lineid = $tmpinvoice->addline($value['note'], $pu_ht, $qtyhour/$prodDurationHours, $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; @@ -493,7 +507,7 @@ if ($action == 'confirm_generateinvoice') // Add lines $lineName = $ftask->ref.' - '.$ftask->label; - $lineid = $tmpinvoice->addline($lineName, $pu_ht, $qtyhour, $txtva, $localtax1, $localtax2, ($idprod > 0 ? $idprod : 0)); + $lineid = $tmpinvoice->addline($lineName, $pu_ht, $qtyhour/$prodDurationHours, $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; From 2c68b08e4f1759705c51ba9c195cc3abd202c742 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Thu, 2 Jan 2020 14:27:35 +0000 Subject: [PATCH 08/11] Fixing style errors. --- htdocs/projet/tasks/time.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/projet/tasks/time.php b/htdocs/projet/tasks/time.php index d08c7d4706d..7e16c83a71a 100644 --- a/htdocs/projet/tasks/time.php +++ b/htdocs/projet/tasks/time.php @@ -422,7 +422,7 @@ if ($action == 'confirm_generateinvoice') } // Add lines - $lineid = $tmpinvoice->addline($langs->trans("TimeSpentForInvoice", $username).' : '.$qtyhourtext, $pu_ht, round($qtyhour/$prodDurationHours,2), $txtva, $localtax1, $localtax2, ($idprod > 0 ? $idprod : 0)); + $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; @@ -466,7 +466,7 @@ if ($action == 'confirm_generateinvoice') } // Add lines - $lineid = $tmpinvoice->addline($value['note'], $pu_ht, round($qtyhour/$prodDurationHours,2), $txtva, $localtax1, $localtax2, ($idprod > 0 ? $idprod : 0)); + $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; @@ -507,7 +507,7 @@ if ($action == 'confirm_generateinvoice') // Add lines $lineName = $ftask->ref.' - '.$ftask->label; - $lineid = $tmpinvoice->addline($lineName, $pu_ht, round($qtyhour/$prodDurationHours,2), $txtva, $localtax1, $localtax2, ($idprod > 0 ? $idprod : 0)); + $lineid = $tmpinvoice->addline($lineName, $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; From d13e1ddcdf7d2b89fdc372a149679913173367ba Mon Sep 17 00:00:00 2001 From: Guillaume Matheron Date: Fri, 3 Jan 2020 11:21:33 +0100 Subject: [PATCH 09/11] Add document date instead of creation date when exporting FEC file --- htdocs/accountancy/class/accountancyexport.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/accountancy/class/accountancyexport.class.php b/htdocs/accountancy/class/accountancyexport.class.php index f36b98b15b1..e049d2b5bad 100644 --- a/htdocs/accountancy/class/accountancyexport.class.php +++ b/htdocs/accountancy/class/accountancyexport.class.php @@ -718,7 +718,7 @@ class AccountancyExport print $line->piece_num.$separator; // FEC:EcritureDate - print $date_creation.$separator; + print $date_doc.$separator; // FEC:CompteNum print $line->numero_compte.$separator; From 72b7e72f735aa6fdb048842f68c579f1b9d0402b Mon Sep 17 00:00:00 2001 From: Guillaume Matheron Date: Fri, 3 Jan 2020 16:20:29 +0100 Subject: [PATCH 10/11] Dates YYMMDD dans l'export FEC --- htdocs/accountancy/class/accountancyexport.class.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/accountancy/class/accountancyexport.class.php b/htdocs/accountancy/class/accountancyexport.class.php index e049d2b5bad..a702244b65b 100644 --- a/htdocs/accountancy/class/accountancyexport.class.php +++ b/htdocs/accountancy/class/accountancyexport.class.php @@ -704,9 +704,9 @@ class AccountancyExport print $end_line; foreach ($objectLines as $line) { - $date_creation = dol_print_date($line->date_creation, '%d%m%Y'); - $date_doc = dol_print_date($line->doc_date, '%d%m%Y'); - $date_valid = dol_print_date($line->date_validated, '%d%m%Y'); + $date_creation = dol_print_date($line->date_creation, '%Y%m%d'); + $date_doc = dol_print_date($line->doc_date, '%Y%m%d'); + $date_valid = dol_print_date($line->date_validated, '%Y%m%d'); // FEC:JournalCode print $line->code_journal.$separator; From b7e4d4904fb302ca3080f26c1d2b2abe31b1c22c Mon Sep 17 00:00:00 2001 From: Guillaume Matheron Date: Mon, 13 Jan 2020 14:34:38 +0100 Subject: [PATCH 11/11] Revert "Add document date instead of creation date when exporting FEC file" This reverts commit d13e1ddcdf7d2b89fdc372a149679913173367ba. --- htdocs/accountancy/class/accountancyexport.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/accountancy/class/accountancyexport.class.php b/htdocs/accountancy/class/accountancyexport.class.php index a702244b65b..46b7a532a35 100644 --- a/htdocs/accountancy/class/accountancyexport.class.php +++ b/htdocs/accountancy/class/accountancyexport.class.php @@ -718,7 +718,7 @@ class AccountancyExport print $line->piece_num.$separator; // FEC:EcritureDate - print $date_doc.$separator; + print $date_creation.$separator; // FEC:CompteNum print $line->numero_compte.$separator;
'.$form->select_dolusers(($search_user > 0 ? $search_user : -1), 'search_user', 1, null, 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth200').''.$form->select_dolusers(($search_user > 0 ? $search_user : -1), 'search_user', 1, null, 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth200').''.$form->selectyesno('search_valuebilled', $search_valuebilled, 1, false, 1).''.$form->selectyesno('search_valuebilled', $search_valuebilled, 1, false, 1).'
'; - 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')); - } - 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')); + } + print ''; - $tasktmp->id = $task_time->fk_task; - $tasktmp->ref = $task_time->ref; - $tasktmp->label = $task_time->label; - print $tasktmp->getNomUrl(1, 'withproject', 'time'); - print ''; + $tasktmp->id = $task_time->fk_task; + $tasktmp->ref = $task_time->ref; + $tasktmp->label = $task_time->label; + print $tasktmp->getNomUrl(1, 'withproject', 'time'); + print ''; - print $task_time->label; - print ''; + print $task_time->label; + print ''; - if ($action == 'editline' && $_GET['lineid'] == $task_time->rowid) - { - if (empty($object->id)) $object->fetch($id); - $contactsoftask = $object->getListContactId('internal'); - if (!in_array($task_time->fk_user, $contactsoftask)) { - $contactsoftask[] = $task_time->fk_user; - } - if (count($contactsoftask) > 0) { - print img_object('', 'user', 'class="hideonsmartphone"'); - print $form->select_dolusers($task_time->fk_user, 'userid_line', 0, '', 0, '', $contactsoftask); - } else { - print img_error($langs->trans('FirstAddRessourceToAllocateTime')).$langs->trans('FirstAddRessourceToAllocateTime'); - } - } - else - { - $userstatic->id = $task_time->fk_user; - $userstatic->lastname = $task_time->lastname; - $userstatic->firstname = $task_time->firstname; - $userstatic->photo = $task_time->photo; - $userstatic->statut = $task_time->user_status; - print $userstatic->getNomUrl(-1); - } - print ''; + if ($action == 'editline' && $_GET['lineid'] == $task_time->rowid) + { + if (empty($object->id)) $object->fetch($id); + $contactsoftask = $object->getListContactId('internal'); + if (!in_array($task_time->fk_user, $contactsoftask)) { + $contactsoftask[] = $task_time->fk_user; + } + if (count($contactsoftask) > 0) { + print img_object('', 'user', 'class="hideonsmartphone"'); + print $form->select_dolusers($task_time->fk_user, 'userid_line', 0, '', 0, '', $contactsoftask); + } else { + print img_error($langs->trans('FirstAddRessourceToAllocateTime')).$langs->trans('FirstAddRessourceToAllocateTime'); + } + } + else + { + $userstatic->id = $task_time->fk_user; + $userstatic->lastname = $task_time->lastname; + $userstatic->firstname = $task_time->firstname; + $userstatic->photo = $task_time->photo; + $userstatic->statut = $task_time->user_status; + print $userstatic->getNomUrl(-1); + } + print ''; - if ($action == 'editline' && $_GET['lineid'] == $task_time->rowid) - { - print ''; - } - else - { - print dol_nl2br($task_time->note); - } - print ''; + if ($action == 'editline' && $_GET['lineid'] == $task_time->rowid) + { + print ''; + } + else + { + print dol_nl2br($task_time->note); + } + 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'); - } - 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'); + } + print ''; $value = price2num($task_time->thm * $task_time->task_duration / 3600); print price($value, 1, $langs, 1, -1, -1, $conf->currency); @@ -1390,51 +1390,51 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0) $totalarray['val']['value'] += $value; if (!$i) $totalarray['totalvaluefield'] = $totalarray['nbfield']; $totalarray['totalvalue'] += $value; - } + } - // Invoiced - if (!empty($arrayfields['valuebilled']['checked'])) - { - print ''; // invoice_id and invoice_line_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) - { - $result = $tmpinvoice->fetch($task_time->invoice_id); - if ($result > 0) - { - print $tmpinvoice->getNomUrl(1); - } - } - else - { - print $langs->trans("No"); - } - } - else - { - print ''.$langs->trans("NA").''; - } - } - print ''; // invoice_id and invoice_line_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) + { + $result = $tmpinvoice->fetch($task_time->invoice_id); + if ($result > 0) + { + print $tmpinvoice->getNomUrl(1); + } + } + else + { + print $langs->trans("No"); + } + } + else + { + print ''.$langs->trans("NA").''; + } + } + print ''; if (($action == 'editline' || $action == 'splitline') && $_GET['lineid'] == $task_time->rowid) { @@ -1443,19 +1443,19 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0) print '
'; print ''; } - elseif ($user->rights->projet->lire || $user->rights->projet->all->creer) // Read project and enter time consumed on assigned tasks + 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.'">'; - print img_split(); - print ''; - } + if ($conf->MAIN_FEATURES_LEVEL >= 2) + { + print ' '; + print 'rowid.$param.'">'; + print img_split(); + print ''; + } - print ' '; + print ' '; print 'rowid.$param.'">'; print img_edit(); print ''; @@ -1465,17 +1465,17 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0) print img_delete(); print ''; - if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined + 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 ''; + $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); - } - 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')); - } - 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); + } + 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')); + } + print ''; - $tasktmp->id = $task_time->fk_task; - $tasktmp->ref = $task_time->ref; - $tasktmp->label = $task_time->label; - print $tasktmp->getNomUrl(1, 'withproject', 'time'); - print ''; + $tasktmp->id = $task_time->fk_task; + $tasktmp->ref = $task_time->ref; + $tasktmp->label = $task_time->label; + print $tasktmp->getNomUrl(1, 'withproject', 'time'); + print ''; - print $task_time->label; - print ''; + print $task_time->label; + print ''; - if ($action == 'splitline' && $_GET['lineid'] == $task_time->rowid) - { - if (empty($object->id)) $object->fetch($id); - $contactsoftask = $object->getListContactId('internal'); - if (!in_array($task_time->fk_user, $contactsoftask)) { - $contactsoftask[] = $task_time->fk_user; - } - if (count($contactsoftask) > 0) { - print img_object('', 'user', 'class="hideonsmartphone"'); - print $form->select_dolusers($task_time->fk_user, 'userid_line', 0, '', 0, '', $contactsoftask); - } else { - print img_error($langs->trans('FirstAddRessourceToAllocateTime')).$langs->trans('FirstAddRessourceToAllocateTime'); - } - } - else - { - $userstatic->id = $task_time->fk_user; - $userstatic->lastname = $task_time->lastname; - $userstatic->firstname = $task_time->firstname; - $userstatic->photo = $task_time->photo; - $userstatic->statut = $task_time->user_status; - print $userstatic->getNomUrl(-1); - } - print ''; + if ($action == 'splitline' && $_GET['lineid'] == $task_time->rowid) + { + if (empty($object->id)) $object->fetch($id); + $contactsoftask = $object->getListContactId('internal'); + if (!in_array($task_time->fk_user, $contactsoftask)) { + $contactsoftask[] = $task_time->fk_user; + } + if (count($contactsoftask) > 0) { + print img_object('', 'user', 'class="hideonsmartphone"'); + print $form->select_dolusers($task_time->fk_user, 'userid_line', 0, '', 0, '', $contactsoftask); + } else { + print img_error($langs->trans('FirstAddRessourceToAllocateTime')).$langs->trans('FirstAddRessourceToAllocateTime'); + } + } + else + { + $userstatic->id = $task_time->fk_user; + $userstatic->lastname = $task_time->lastname; + $userstatic->firstname = $task_time->firstname; + $userstatic->photo = $task_time->photo; + $userstatic->statut = $task_time->user_status; + print $userstatic->getNomUrl(-1); + } + print ''; - if ($action == 'splitline' && $_GET['lineid'] == $task_time->rowid) - { - print ''; - } - else - { - print dol_nl2br($task_time->note); - } - print ''; + if ($action == 'splitline' && $_GET['lineid'] == $task_time->rowid) + { + print ''; + } + else + { + print dol_nl2br($task_time->note); + } + print ''; - 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'); - } - print ''; + 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'); + } + print ''; - $value = price2num($task_time->thm * $task_time->task_duration / 3600); - print price($value, 1, $langs, 1, -1, -1, $conf->currency); - print ''; + $value = price2num($task_time->thm * $task_time->task_duration / 3600); + print price($value, 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); - print ''; + $valuebilled = price2num($task_time->total_ht); + if (isset($task_time->total_ht)) print price($valuebilled, 1, $langs, 1, -1, -1, $conf->currency); + 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_2', 3, 3, 2, "timespent_date", 1, 0); - } - 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')); - } - print ''; + if ($action == 'splitline' && $_GET['lineid'] == $task_time->rowid) + { + if (empty($task_time->task_date_withhour)) + { + print $form->selectDate(($date2 ? $date2 : $date1), 'timeline_2', 3, 3, 2, "timespent_date", 1, 0); + } + 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')); + } + print ''; - $tasktmp->id = $task_time->fk_task; - $tasktmp->ref = $task_time->ref; - $tasktmp->label = $task_time->label; - print $tasktmp->getNomUrl(1, 'withproject', 'time'); - print ''; + $tasktmp->id = $task_time->fk_task; + $tasktmp->ref = $task_time->ref; + $tasktmp->label = $task_time->label; + print $tasktmp->getNomUrl(1, 'withproject', 'time'); + print ''; - print $task_time->label; - print ''; + print $task_time->label; + print ''; - if ($action == 'splitline' && $_GET['lineid'] == $task_time->rowid) - { - if (empty($object->id)) $object->fetch($id); - $contactsoftask = $object->getListContactId('internal'); - if (!in_array($task_time->fk_user, $contactsoftask)) { - $contactsoftask[] = $task_time->fk_user; - } - if (count($contactsoftask) > 0) { - print img_object('', 'user', 'class="hideonsmartphone"'); - print $form->select_dolusers($task_time->fk_user, 'userid_line_2', 0, '', 0, '', $contactsoftask); - } else { - print img_error($langs->trans('FirstAddRessourceToAllocateTime')).$langs->trans('FirstAddRessourceToAllocateTime'); - } - } - else - { - $userstatic->id = $task_time->fk_user; - $userstatic->lastname = $task_time->lastname; - $userstatic->firstname = $task_time->firstname; - $userstatic->photo = $task_time->photo; - $userstatic->statut = $task_time->user_status; - print $userstatic->getNomUrl(-1); - } - print ''; + if ($action == 'splitline' && $_GET['lineid'] == $task_time->rowid) + { + if (empty($object->id)) $object->fetch($id); + $contactsoftask = $object->getListContactId('internal'); + if (!in_array($task_time->fk_user, $contactsoftask)) { + $contactsoftask[] = $task_time->fk_user; + } + if (count($contactsoftask) > 0) { + print img_object('', 'user', 'class="hideonsmartphone"'); + print $form->select_dolusers($task_time->fk_user, 'userid_line_2', 0, '', 0, '', $contactsoftask); + } else { + print img_error($langs->trans('FirstAddRessourceToAllocateTime')).$langs->trans('FirstAddRessourceToAllocateTime'); + } + } + else + { + $userstatic->id = $task_time->fk_user; + $userstatic->lastname = $task_time->lastname; + $userstatic->firstname = $task_time->firstname; + $userstatic->photo = $task_time->photo; + $userstatic->statut = $task_time->user_status; + print $userstatic->getNomUrl(-1); + } + print ''; - if ($action == 'splitline' && $_GET['lineid'] == $task_time->rowid) - { - print ''; - } - else - { - print dol_nl2br($task_time->note); - } - print ''; + if ($action == 'splitline' && $_GET['lineid'] == $task_time->rowid) + { + print ''; + } + else + { + print dol_nl2br($task_time->note); + } + print ''; - if ($action == 'splitline' && $_GET['lineid'] == $task_time->rowid) - { - print ''; - print $form->select_duration('new_duration_2', 0, 0, 'text'); - } - else - { - print convertSecondToTime($task_time->task_duration, 'allhourmin'); - } - print ''; + if ($action == 'splitline' && $_GET['lineid'] == $task_time->rowid) + { + print ''; + print $form->select_duration('new_duration_2', 0, 0, 'text'); + } + else + { + print convertSecondToTime($task_time->task_duration, 'allhourmin'); + } + print ''; - $value = 0; - print price($value, 1, $langs, 1, -1, -1, $conf->currency); - print ''; + $value = 0; + print price($value, 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); - print ''; + $valuebilled = price2num($task_time->total_ht); + if (isset($task_time->total_ht)) print price($valuebilled, 1, $langs, 1, -1, -1, $conf->currency); + print ''; - print ''; + 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'); From 92f50f635702b83b93352cabf99b4197807222a9 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Thu, 2 Jan 2020 14:00:39 +0000 Subject: [PATCH 06/11] Fixing style errors. --- htdocs/projet/tasks/time.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/projet/tasks/time.php b/htdocs/projet/tasks/time.php index 485ba8bf173..78eed257ce5 100644 --- a/htdocs/projet/tasks/time.php +++ b/htdocs/projet/tasks/time.php @@ -958,8 +958,8 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0) print $langs->trans('InvoiceToUse'); print ''; - $form->selectInvoice('invoice', '', 'invoiceid',24,0,$langs->trans('NewInvoice'), - 1,0,0,'maxwidth500','','all'); + $form->selectInvoice('invoice', '', 'invoiceid', 24, 0, $langs->trans('NewInvoice'), + 1, 0, 0, 'maxwidth500', '', 'all'); print '