From a381421e26c68400d1f4251e4666314bc3ac9ad0 Mon Sep 17 00:00:00 2001 From: Nicolas Domenech Date: Thu, 20 Jul 2023 23:15:00 +0200 Subject: [PATCH] #417 [TimeSheet] clean timesheet view --- class/timesheet.class.php | 10 +- langs/fr_FR/dolisirh.lang | 15 +- view/timesheet/timesheet_card.php | 1414 ++++++++++++++--------------- 3 files changed, 687 insertions(+), 752 deletions(-) diff --git a/class/timesheet.class.php b/class/timesheet.class.php index 0f8db74..57d401f 100644 --- a/class/timesheet.class.php +++ b/class/timesheet.class.php @@ -459,19 +459,19 @@ class TimeSheetLine extends SaturneObject public $date_creation; /** - * @var float Quantity. + * @var float|null Quantity. */ - public float $qty; + public ?float $qty; /** - * @var int Rang. + * @var int|null Rang. */ - public int $rang; + public ?int $rang; /** * @var string Description. */ - public string $description; + public string $description = ''; /** * @var int|null Product type. diff --git a/langs/fr_FR/dolisirh.lang b/langs/fr_FR/dolisirh.lang index cbda5d1..ad04591 100644 --- a/langs/fr_FR/dolisirh.lang +++ b/langs/fr_FR/dolisirh.lang @@ -180,20 +180,8 @@ InvoicesCategoriesArea = Espace des tags/catégories des factures # # SetEventMessage - Notice info -TimeSheetMustBeDraft = La navette doit être en brouillon pour accéder à cette fonctionnalité -TimeSheetMustBeDraftToValidate = La navette est déjà validée -TimeSheetMustBeValidated = La navette doit être validée pour la rouvrir -TimeSheetMustBeValidatedToSign = La navette doit être validée pour que les signataires puissent signer AllSignatoriesMustHaveSignedAndDiffTimeSetAt0 = Tous les signataires doivent avoir signé et l'utilisateur assigné doit avoir consommée toutes ses heures de travail pour verrouiller la navette -TimeSheetMustBeLockedToSendEmail = La navette doit être verrouillée pour envoyer un email -TimeSheetMustBeLocked = La navette doit être verrouillée afin de permettre la génération -TimeSheetMustBeLockedGenerated = La navette doit être verrouillée et le document généré afin de pouvoir l'archiver -ValidateTimeSheet = Valider la navette -ConfirmValidateTimeSheet = Êtes-vous sûr de vouloir valider la navette ?
La validation permet aux signataires de signer le document mais empêche l'ajout de nouveaux signataires ou la modification de la navette.

N'oubliez pas de vérifier les quantités des produits ou services liés. -ReOpenTimeSheet = Ouvrir à nouveau la navette -ConfirmReOpenTimeSheet = Êtes-vous sûr de vouloir rouvrir la navette ? La réouverture permet la modification de la navette et l'ajout de nouveaux signataires mais toutes les signatures du document seront perdues. -LockTimeSheet = Verrouiller la navette -ConfirmLockTimeSheet = Êtes-vous sûr de vouloir verrouiller la navette ?
Ce verrouillage permet de figer les données et la génération du document. +ConfirmValidateTimeSheet =

N'oubliez pas de vérifier les quantités des produits ou services liés. TimeSpentPerfect = Parfait, toutes tes heures de travail ont été consommées TimeSpentMustBeCompleted = Attention, toutes tes heures de travail n'ont pas été consommées (%s - %s)
Va sur ton pointage de temps du mois de %s pour arranger cela TimeSpentDiff = Attention, tu as consommé trop d'heures de travail (%s - %s)
Va sur ton pointage de temps du mois de %s pour arranger cela @@ -211,6 +199,7 @@ GoToConfigProjectPage = Aller sur la page de configurati # Data - Donnée TimeSheet = Navette Timesheet = Navette +TheTimesheet = La navette NewTimeSheet = Nouvelle navette NewTimesheet = Nouvelle navette ModifyTimeSheet = Modifier la navette diff --git a/view/timesheet/timesheet_card.php b/view/timesheet/timesheet_card.php index 37c6dc2..06b929a 100644 --- a/view/timesheet/timesheet_card.php +++ b/view/timesheet/timesheet_card.php @@ -18,10 +18,10 @@ /** * \file view/timesheet/timesheet_card.php * \ingroup dolisirh - * \brief Page to create/edit/view timesheet + * \brief Page to create/edit/view timesheet. */ -// Load DoliSIRH environment +// Load DoliSIRH environment. if (file_exists('../../dolisirh.main.inc.php')) { require_once __DIR__ . '/../../dolisirh.main.inc.php'; } elseif (file_exists('../../../dolisirh.main.inc.php')) { @@ -30,28 +30,25 @@ die('Include of dolisirh main fails'); } -// Libraries -require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; -require_once DOL_DOCUMENT_ROOT.'/holiday/class/holiday.class.php'; +// Load Dolibarr libraries. +require_once DOL_DOCUMENT_ROOT . '/core/lib/functions2.lib.php'; +require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php'; // Load Saturne libraries. require_once __DIR__ . '/../../../saturne/class/saturnesignature.class.php'; // load DoliSIRH libraries. +require_once __DIR__ . '/../../lib/dolisirh_function.lib.php'; +require_once __DIR__ . '/../../lib/dolisirh_timespent.lib.php'; +require_once __DIR__ . '/../../lib/dolisirh_timesheet.lib.php'; require_once __DIR__ . '/../../class/timesheet.class.php'; require_once __DIR__ . '/../../class/dolisirhdocuments/timesheetdocument.class.php'; require_once __DIR__ . '/../../class/workinghours.class.php'; -require_once __DIR__ . '/../../lib/dolisirh_timesheet.lib.php'; -require_once __DIR__ . '/../../lib/dolisirh_function.lib.php'; -require_once __DIR__ . '/../../../saturne/class/saturnesignature.class.php'; - -// Global variables definitions -global $conf, $db, $hookmanager, $langs, $mysoc, $user; +// Global variables definitions. +global $conf, $db, $hookmanager, $langs, $moduleNameLowerCase, $mysoc, $user; -// Load translation files required by the page +// Load translation files required by the page. saturne_load_langs(); // Get parameters. @@ -60,7 +57,7 @@ $action = GETPOST('action', 'aZ09'); $confirm = GETPOST('confirm', 'alpha'); $cancel = GETPOST('cancel', 'aZ09'); -$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'timesheetcard'; // To manage different context of search +$contextPage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'timesheetcard'; // To manage different context of search. $backtopage = GETPOST('backtopage', 'alpha'); $backtopageforcancel = GETPOST('backtopageforcancel', 'alpha'); $lineid = GETPOST('lineid', 'int'); @@ -69,34 +66,32 @@ $day = (GETPOST('day', 'int') ? GETPOST('day', 'int') : date('d')); // Initialize technical objects. -$object = new TimeSheet($db); -$objectline = new TimeSheetLine($db); -$signatory = new SaturneSignature($db); -$timesheetdocument = new TimeSheetDocument($db); -$extrafields = new ExtraFields($db); -$project = new Project($db); -$product = new Product($db); -$workinghours = new Workinghours($db); -$holiday = new Holiday($db); -$task = new Task($db); -$usertmp = new User($db); +$object = new TimeSheet($db); +$objectLine = new TimeSheetLine($db); +$signatory = new SaturneSignature($db, $moduleNameLowerCase, $object->element); +$document = new TimeSheetDocument($db); +$extraFields = new ExtraFields($db); +$product = new Product($db); +$workingHours = new Workinghours($db); +$task = new Task($db); +$userTmp = new User($db); // Initialize view objects $form = new Form($db); -$hookmanager->initHooks(['timesheetcard', 'globalcard']); // Note that conf->hooks_modules contains array +$hookmanager->initHooks(['timesheetcard', 'globalcard']); // Note that conf->hooks_modules contains array. // Fetch optionals attributes and labels -$extrafields->fetch_name_optionals_label($object->table_element); +$extraFields->fetch_name_optionals_label($object->table_element); -$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); +$search_array_options = $extraFields->getOptionalsFromPost($object->table_element, '', 'search_'); // Initialize array of search criterias -$search_all = GETPOST('search_all', 'alpha'); -$search = []; +$searchAll = GETPOST('search_all', 'alpha'); +$search = []; foreach ($object->fields as $key => $val) { - if (GETPOST('search_'.$key, 'alpha')) { - $search[$key] = GETPOST('search_'.$key, 'alpha'); + if (GETPOST('search_' . $key, 'alpha')) { + $search[$key] = GETPOST('search_' . $key, 'alpha'); } } @@ -105,312 +100,237 @@ } // Load object -include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be included, not include_once. +require_once DOL_DOCUMENT_ROOT . '/core/actions_fetchobject.inc.php'; // Must be included, not include_once. $upload_dir = $conf->dolisirh->multidir_output[$object->entity ?? 1]; +$now = dol_now(); + // Security check - Protection if external user -$permissiontoread = $user->rights->dolisirh->timesheet->read; +$permissionToRead = $user->rights->dolisirh->timesheet->read; $permissiontoadd = $user->rights->dolisirh->timesheet->write; -$permissiontodelete = $user->rights->dolisirh->timesheet->delete || ($permissiontoadd && isset($object->status) && $object->status == $object::STATUS_DRAFT); -saturne_check_access($permissiontoread); +$permissiontodelete = $user->rights->dolisirh->timesheet->delete || ($permissiontoadd && isset($object->status) && $object->status == TimeSheet::STATUS_DRAFT); +saturne_check_access($permissionToRead); /* - * Actions + * Actions. */ $parameters = []; -$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks +$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks. if ($reshook < 0) { setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); } if (empty($reshook)) { - $error = 0; - - $backurlforlist = dol_buildpath('/dolisirh/view/timesheet/timesheet_list.php', 1); - - if (empty($backtopage) || ($cancel && empty($id))) { - if (empty($backtopage) || ($cancel && strpos($backtopage, '__ID__'))) { - if (empty($id) && (($action != 'add' && $action != 'create') || $cancel)) { - $backtopage = $backurlforlist; - } else { - $backtopage = dol_buildpath('/dolisirh/view/timesheet/timesheet_card.php', 1).'?id='.((!empty($id) && $id > 0) ? $id : '__ID__'); - } - } - } - - $triggermodname = 'TIMESHEET_MODIFY'; // Name of trigger action code to execute when we modify record - - if (($action == 'add' || $action == 'update') && $permissiontoadd && !$cancel) { - $usertmp->fetch(GETPOST('fk_user_assign')); - $date_start = dol_mktime(0, 0, 0, GETPOST('date_startmonth', 'int'), GETPOST('date_startday', 'int'), GETPOST('date_startyear', 'int')); - $date_end = dol_mktime(0, 0, 0, GETPOST('date_endmonth', 'int'), GETPOST('date_endday', 'int'), GETPOST('date_endyear', 'int')); - $filter = ' AND ptt.task_date BETWEEN ' . "'" .dol_print_date($date_start, 'dayrfc') . "'" . ' AND ' . "'" . dol_print_date($date_end, 'dayrfc'). "'"; - $alltimespent = $task->fetchAllTimeSpent($usertmp, $filter); - foreach ($alltimespent as $timespent) { - $task->fetchObjectLinked(null, '', $timespent->timespent_id, 'project_task_time'); - if (isset($task->linkedObjects['dolisirh_timesheet'])) { - $error++; - } - } - - if ($date_start > $date_end) { - setEventMessages($langs->trans('ErrorDateTimeSheet', dol_print_date($date_start, 'dayreduceformat'), dol_print_date($date_end, 'dayreduceformat')), null, 'errors'); - if ($action == 'add') { - $action = 'create'; - } elseif ($action == 'update') { - $action = 'edit'; - } - } - - if ($conf->global->DOLISIRH_TIMESHEET_CHECK_DATE_END > 0) { - if ($date_end > dol_now()) { - setEventMessages($langs->trans('ErrorDateEndTimeSheet', dol_print_date($date_end, 'dayreduceformat'), dol_print_date(dol_now(), 'dayreduceformat')), null, 'errors'); - if ($action == 'add') { - $action = 'create'; - } elseif ($action == 'update') { - $action = 'edit'; - } - } - } - - if ($error > 0) { - setEventMessages($langs->trans('ErrorLinkedElementTimeSheetTimeSpent', $usertmp->getFullName($langs), dol_print_date($date_start, 'dayreduceformat'), dol_print_date($date_end, 'dayreduceformat')), null, 'errors'); - if ($action == 'add') { - $action = 'create'; - } elseif ($action == 'update') { - $action = 'edit'; - } - } - } - - // Actions cancel, add, update, update_extras, confirm_validate, confirm_delete, confirm_deleteline, confirm_clone, confirm_close, confirm_setdraft, confirm_reopen - $conf->global->MAIN_DISABLE_PDF_AUTOUPDATE = 1; - include DOL_DOCUMENT_ROOT.'/core/actions_addupdatedelete.inc.php'; - - // Action to build doc - if ($action == 'builddoc' && $permissiontoadd) { - $outputlangs = $langs; - $newlang = ''; - - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); - if ( ! empty($newlang)) { - $outputlangs = new Translate('', $conf); - $outputlangs->setDefaultLang($newlang); + $error = 0; + + $backurlforlist = dol_buildpath('/dolisirh/view/timesheet/timesheet_list.php', 1); + + if (empty($backtopage) || ($cancel && empty($id))) { + if (empty($backtopage) || ($cancel && strpos($backtopage, '__ID__'))) { + if (empty($id) && (($action != 'add' && $action != 'create') || $cancel)) { + $backtopage = $backurlforlist; + } else { + $backtopage = dol_buildpath('/dolisirh/view/timesheet/timesheet_card.php', 1) . '?id=' . ((!empty($id) && $id > 0) ? $id : '__ID__'); + } } + } - // To be sure vars is defined - if (empty($hidedetails)) $hidedetails = 0; - if (empty($hidedesc)) $hidedesc = 0; - if (empty($hideref)) $hideref = 0; - if (empty($moreparams)) $moreparams = null; + if (($action == 'add' || $action == 'update') && $permissiontoadd && !$cancel) { + $userTmp->fetch(GETPOST('fk_user_assign')); + $dateStart = dol_mktime(0, 0, 0, GETPOST('date_startmonth', 'int'), GETPOST('date_startday', 'int'), GETPOST('date_startyear', 'int')); + $dateEnd = dol_mktime(0, 0, 0, GETPOST('date_endmonth', 'int'), GETPOST('date_endday', 'int'), GETPOST('date_endyear', 'int')); + $filter = ' AND ptt.task_date BETWEEN ' . "'" . dol_print_date($dateStart, 'dayrfc') . "'" . ' AND ' . "'" . dol_print_date($dateEnd, 'dayrfc') . "'"; + $timeSpents = $task->fetchAllTimeSpent($userTmp, $filter); + foreach ($timeSpents as $timespent) { + $task->fetchObjectLinked(null, '', $timespent->timespent_id, 'project_task_time'); + if (isset($task->linkedObjects['dolisirh_timesheet'])) { + $error++; + } + } - $model = GETPOST('model', 'alpha'); + if ($dateStart > $dateEnd) { + setEventMessages($langs->trans('ErrorDateTimeSheet', dol_print_date($dateStart, 'dayreduceformat'), dol_print_date($dateEnd, 'dayreduceformat')), [], 'errors'); + if ($action == 'add') { + $action = 'create'; + } elseif ($action == 'update') { + $action = 'edit'; + } + } - $moreparams['object'] = $object; - $moreparams['user'] = $user; + if (getDolGlobalInt('DOLISIRH_TIMESHEET_CHECK_DATE_END')) { + if ($dateEnd > $now) { + setEventMessages($langs->trans('ErrorDateEndTimeSheet', dol_print_date($dateEnd, 'dayreduceformat'), dol_print_date($now, 'dayreduceformat')), [], 'errors'); + if ($action == 'add') { + $action = 'create'; + } elseif ($action == 'update') { + $action = 'edit'; + } + } + } - $result = $timesheetdocument->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams); - if ($result <= 0) { - setEventMessages($object->error, $object->errors, 'errors'); - $action = ''; - } else { - if (empty($donotredirect)) { - setEventMessages($langs->trans('FileGenerated') . ' - ' . $timesheetdocument->last_main_doc, null); - $urltoredirect = $_SERVER['REQUEST_URI']; - $urltoredirect = preg_replace('/#builddoc$/', '', $urltoredirect); - $urltoredirect = preg_replace('/action=builddoc&?/', '', $urltoredirect); // To avoid infinite loop - header('Location: ' . $urltoredirect . '#builddoc'); - exit; + if ($error > 0) { + setEventMessages($langs->trans('ErrorLinkedElementTimeSheetTimeSpent', $userTmp->getFullName($langs), dol_print_date($dateStart, 'dayreduceformat'), dol_print_date($dateEnd, 'dayreduceformat')), [], 'errors'); + if ($action == 'add') { + $action = 'create'; + } elseif ($action == 'update') { + $action = 'edit'; } } } - // Delete file in doc form - if ($action == 'remove_file' && $permissiontodelete) { - if ( ! empty($upload_dir)) { - require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; + // Actions cancel, add, update, update_extras, confirm_validate, confirm_delete, confirm_deleteline, confirm_clone, confirm_close, confirm_setdraft, confirm_reopen. + $conf->global->MAIN_DISABLE_PDF_AUTOUPDATE = 1; + $triggermodname = 'TIMESHEET_MODIFY'; // Name of trigger action code to execute when we modify record. + require_once DOL_DOCUMENT_ROOT . '/core/actions_addupdatedelete.inc.php'; + + // Actions save_project. + require_once __DIR__ . '/../../../saturne/core/tpl/actions/edit_project_action.tpl.php'; + + // Actions builddoc, forcebuilddoc, remove_file. + require_once __DIR__ . '/../../../saturne/core/tpl/documents/documents_action.tpl.php'; + + // Action to generate pdf from odt file. + require_once __DIR__ . '/../../../saturne/core/tpl/documents/saturne_manual_pdf_generation_action.tpl.php'; + + // Action to add line. + if ($action == 'addline' && $permissiontoadd) { + // Get parameters. + $qty = GETPOST('qty'); + $prodEntryMode = GETPOST('prod_entry_mode'); - $langs->load('other'); - $filetodelete = GETPOST('file', 'alpha'); - $file = $upload_dir . '/' . $filetodelete; - $ret = dol_delete_file($file, 0, 0, 0, $object); - if ($ret) setEventMessages($langs->trans('FileWasRemoved', $filetodelete), null, 'mesgs'); - else setEventMessages($langs->trans('ErrorFailToDeleteFile', $filetodelete), null, 'errors'); + if ($prodEntryMode == 'free') { + $productType = GETPOST('type'); + $description = GETPOST('dp_desc', 'restricthtml'); - // Make a redirect to avoid to keep the remove_file into the url that create side effects - $urltoredirect = $_SERVER['REQUEST_URI']; - $urltoredirect = preg_replace('/#builddoc$/', '', $urltoredirect); - $urltoredirect = preg_replace('/action=remove_file&?/', '', $urltoredirect); + // Check parameters. + if ($productType < 0) { + setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Type')), [], 'errors'); + $error++; + } + if (dol_strlen($description) < 0) { + setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Description')), [], 'errors'); + $error++; + } - header('Location: ' . $urltoredirect); - exit; + $objectLine->description = $description; + $objectLine->product_type = $productType; + } elseif ($prodEntryMode == 'predef') { + $productID = GETPOST('idprod'); + if ($productID > 0) { + $product->fetch($productID); + $objectLine->fk_product = $productID; + $objectLine->product_type = 0; + } else { + $error++; + } } else { - setEventMessages('BugFoundVarUploaddirnotDefined', null, 'errors'); + $error++; + } + + // Initialize object timesheet line. + $objectLine->date_creation = $object->db->idate($now); + $objectLine->qty = $qty; + $objectLine->rang = 0; + $objectLine->fk_timesheet = $id; + $objectLine->fk_parent_line = 0; + + if (!$error) { + $result = $objectLine->create($user); + if ($result > 0) { + // Creation timesheet line OK. + $urlToGo = str_replace('__ID__', $result, $backtopage); + $urlToGo = preg_replace('/--IDFORBACKTOPAGE--/', $id, $urlToGo); // New method to autoselect project after a New on another form object creation. + header('Location: ' . $urlToGo); + exit; + } elseif (!empty($objectLine->errors)) { + // Creation timesheet line KO. + setEventMessages('', $objectLine->errors, 'errors'); + } else { + setEventMessages($objectLine->error, [], 'errors'); + } + } + } + + // Action to edit line. + if ($action == 'updateline' && $permissiontoadd) { + // Get parameters. + $qty = GETPOST('qty'); + $description = GETPOST('product_desc', 'restricthtml'); + + $objectLine->fetch($lineid); + + // Initialize object timesheet line. + $objectLine->qty = $qty; + $objectLine->description = $description; + + if (!$error) { + $result = $objectLine->update($user); + if ($result > 0) { + // Update timesheet line OK. + $urlToGo = str_replace('__ID__', $result, $backtopage); + $urlToGo = preg_replace('/--IDFORBACKTOPAGE--/', $id, $urlToGo); // New method to autoselect project after a New on another form object creation. + header('Location: ' . $urlToGo); + exit; + } elseif (!empty($objectLine->errors)) { + // Update timesheet line KO. + setEventMessages('', $objectLine->errors, 'errors'); + } else { + setEventMessages($objectLine->error, [], 'errors'); + } + } + } + + // Action to set status STATUS_LOCKED. + if ($action == 'confirm_set_Lock' && $permissiontoadd) { + $errorLinked = 0; + $object->fetch($id); + if (!$error) { + $userTmp->fetch($object->fk_user_assign); + $filter = ' AND ptt.task_date BETWEEN ' . "'" . dol_print_date($object->date_start, 'dayrfc') . "'" . ' AND ' . "'" . dol_print_date($object->date_end, 'dayrfc') . "'"; + $timeSpents = $task->fetchAllTimeSpent($userTmp, $filter); + foreach ($timeSpents as $timespent) { + $task->fetchObjectLinked(null, '', $timespent->timespent_id, 'project_task_time'); + if (!isset($task->linkedObjects['dolisirh_timesheet'])) { + $task->id = $timespent->timespent_id; + $task->element = 'project_task_time'; + $task->add_object_linked('dolisirh_timesheet', $object->id); + } else { + $errorLinked++; + } + } + if ($errorLinked == 0) { + $object->setLocked($user, false); + // Set locked OK + $urlToGo = str_replace('__ID__', $id, $backtopage); + $urlToGo = preg_replace('/--IDFORBACKTOPAGE--/', $id, $urlToGo); // New method to autoselect project after a New on another form object creation. + header('Location: ' . $urlToGo); + exit; + } + } elseif (!empty($object->errors)) { + // Set locked KO. + setEventMessages('', $object->errors, 'errors'); + } else { + setEventMessages($object->error, [], 'errors'); + } + + if ($errorLinked > 0) { + setEventMessages($langs->trans('ErrorLinkedElementTimeSheetTimeSpent', $userTmp->getFullName($langs), dol_print_date($object->date_start, 'dayreduceformat'), dol_print_date($object->date_end, 'dayreduceformat')), [], 'errors'); } } - if ($action == 'set_thirdparty' && $permissiontoadd) { - $object->setValueFrom('fk_soc', GETPOST('fk_soc', 'int'), '', '', 'date', '', $user, $triggermodname); - } - - if ($action == 'classin' && $permissiontoadd) { - $object->setProject(GETPOST('projectid', 'int')); - } - - // Action to add line - if ($action == 'addline' && $permissiontoadd) { - // Get parameters - $qty = GETPOST('qty'); - $prod_entry_mode = GETPOST('prod_entry_mode'); - - $now = dol_now(); - - if ($prod_entry_mode == 'free') { - $product_type = GETPOST('type'); - $description = GETPOST('dp_desc', 'restricthtml'); - - // Check parameters - if ($product_type < 0) { - setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Type')), null, 'errors'); - $error++; - } - if (empty($description)) { - setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Description')), null, 'errors'); - $error++; - } - - $objectline->description = $description; - $objectline->product_type = $product_type; - } elseif ($prod_entry_mode == 'predef') { - $product_id = GETPOST('idprod'); - if ($product_id > 0) { - $product->fetch($product_id); - $objectline->fk_product = $product_id; - $objectline->product_type = 0; - } else { - $error++; - } - } else { - $error++; - } - - // Initialize object timesheet line - $objectline->date_creation = $object->db->idate($now); - $objectline->qty = $qty; - $objectline->rang = 0; - $objectline->fk_timesheet = $id; - $objectline->fk_parent_line = 0; - - if ( ! $error) { - $result = $objectline->create($user); - if ($result > 0) { - // Creation timesheet line OK - $urltogo = str_replace('__ID__', $result, $backtopage); - $urltogo = preg_replace('/--IDFORBACKTOPAGE--/', $id, $urltogo); // New method to autoselect project after a New on another form object creation - header('Location: ' . $urltogo); - exit; - } else { - // Creation timesheet line KO - if ( ! empty($objectline->errors)) setEventMessages(null, $objectline->errors, 'errors'); - else setEventMessages($objectline->error, null, 'errors'); - } - } - } - - // Action to edit line - if ($action == 'updateline' && $permissiontoadd) { - // Get parameters - $qty = GETPOST('qty'); - $description = GETPOST('product_desc', 'restricthtml'); - - $objectline->fetch($lineid); - - // Initialize object timesheet line - $objectline->qty = $qty; - $objectline->description = $description; - - if ( ! $error) { - $result = $objectline->update($user, false); - if ($result > 0) { - // Update timesheet line OK - $urltogo = str_replace('__ID__', $result, $backtopage); - $urltogo = preg_replace('/--IDFORBACKTOPAGE--/', $parent_id, $urltogo); // New method to autoselect project after a New on another form object creation - header('Location: ' . $urltogo); - exit; - } else { - // Update timesheet line KO - if ( ! empty($objectline->errors)) setEventMessages(null, $objectline->errors, 'errors'); - else setEventMessages($objectline->error, null, 'errors'); - } - } - } - - // Action to set status STATUS_LOCKED - if ($action == 'confirm_setLocked' && $permissiontoadd) { - $errorlinked = 0; - $object->fetch($id); - if ( ! $error) { - $usertmp->fetch($object->fk_user_assign); - $filter = ' AND ptt.task_date BETWEEN ' . "'" .dol_print_date($object->date_start, 'dayrfc') . "'" . ' AND ' . "'" . dol_print_date($object->date_end, 'dayrfc'). "'"; - $alltimespent = $task->fetchAllTimeSpent($usertmp, $filter); - foreach ($alltimespent as $timespent) { - $task->fetchObjectLinked(null, '', $timespent->timespent_id, 'project_task_time'); - if (!isset($task->linkedObjects['dolisirh_timesheet'])) { - $task->id = $timespent->timespent_id; - $task->element = 'project_task_time'; - $task->add_object_linked('dolisirh_timesheet', $object->id); - } else { - $errorlinked++; - } - } - if ($errorlinked == 0) { - $object->setLocked($user, false); - // Set locked OK - $urltogo = str_replace('__ID__', $result, $backtopage); - $urltogo = preg_replace('/--IDFORBACKTOPAGE--/', $id, $urltogo); // New method to autoselect project after a New on another form object creation - header('Location: ' . $urltogo); - exit; - } - } else { - // Set locked KO - if ( ! empty($object->errors)) setEventMessages(null, $object->errors, 'errors'); - else setEventMessages($object->error, null, 'errors'); - } - - if ($errorlinked > 0) { - setEventMessages($langs->trans('ErrorLinkedElementTimeSheetTimeSpent', $usertmp->getFullName($langs), dol_print_date($object->date_start, 'dayreduceformat'), dol_print_date($object->date_end, 'dayreduceformat')), null, 'errors'); - } - } - - // Action to set status STATUS_ARCHIVED - if ($action == 'setArchived' && $permissiontoadd) { - $object->fetch($id); - if ( ! $error) { - $result = $object->setArchived($user, false); - if ($result > 0) { - // Set Archived OK - $urltogo = str_replace('__ID__', $result, $backtopage); - $urltogo = preg_replace('/--IDFORBACKTOPAGE--/', $id, $urltogo); // New method to autoselect project after a New on another form object creation - header('Location: ' . $urltogo); - exit; - } else { - // Set Archived KO - if ( ! empty($object->errors)) setEventMessages(null, $object->errors, 'errors'); - else setEventMessages($object->error, null, 'errors'); - } - } - } - - // Actions to send emails - $triggersendname = strtoupper($object->element) . '_SENTBYMAIL'; - $autocopy = 'MAIN_MAIL_AUTOCOPY_' . strtoupper($object->element) . '_TO'; - include DOL_DOCUMENT_ROOT . '/core/actions_sendmails.inc.php'; + // Action confirm_archive. + require_once __DIR__ . '/../../../saturne/core/tpl/signature/signature_action_workflow.tpl.php'; + + // Actions to send emails. + $triggersendname = strtoupper($object->element) . '_SENTBYMAIL'; + $autocopy = 'MAIN_MAIL_AUTOCOPY_' . strtoupper($object->element) . '_TO'; + require_once DOL_DOCUMENT_ROOT . '/core/actions_sendmails.inc.php'; } /* - * View + * View. */ $title = $langs->trans(ucfirst($object->element)); @@ -418,106 +338,107 @@ saturne_header(0, '', $title, $help_url); -// Part to create +// Part to create; if ($action == 'create') { - if (empty($permissiontoadd)) { - accessforbidden($langs->trans('NotEnoughPermissions'), 0); - exit; - } + if (empty($permissiontoadd)) { + accessforbidden($langs->trans('NotEnoughPermissions'), 0); + exit; + } - print load_fiche_titre($langs->trans('New' . ucfirst($object->element)), '', 'object_' . $object->picto); + print load_fiche_titre($langs->trans('New' . ucfirst($object->element)), '', 'object_' . $object->picto); - print '
'; - print ''; - print ''; - if ($backtopage) { - print ''; - } - if ($backtopageforcancel) { - print ''; - } + print ''; + print ''; + print ''; + if ($backtopage) { + print ''; + } + if ($backtopageforcancel) { + print ''; + } - print dol_get_fiche_head(); + print dol_get_fiche_head(); - print ''; + print '
'; - if ($conf->global->DOLISIRH_TIMESHEET_PREFILL_DATE) { + $specialCaseMonth = 0; + if (getDolGlobalInt('DOLISIRH_TIMESHEET_PREFILL_DATE')) { if ($month == 01) { $specialCaseMonth = 12; $year--; } } - $object->fields['label']['default'] = $langs->trans('TimeSheet') . ' ' . dol_print_date(dol_mktime(0, 0, 0, (!empty($conf->global->DOLISIRH_TIMESHEET_PREFILL_DATE) ? (($month != 01) ? $month - 1 : $specialCaseMonth) : $month), $day, $year), "%B %Y") . ' ' . $user->getFullName($langs, 0, 0); - $object->fields['fk_project']['default'] = $conf->global->DOLISIRH_HR_PROJECT; - $object->fields['fk_user_assign']['default'] = $user->id; + $object->fields['label']['default'] = $langs->trans('TimeSheet') . ' ' . dol_print_date(dol_mktime(0, 0, 0, (!empty($conf->global->DOLISIRH_TIMESHEET_PREFILL_DATE) ? (($month != 01) ? $month - 1 : $specialCaseMonth) : $month), $day, $year), '%B %Y') . ' ' . $user->getFullName($langs, 0, 0); + $object->fields['fk_project']['default'] = $conf->global->DOLISIRH_HR_PROJECT; + $object->fields['fk_user_assign']['default'] = $user->id; - $date_start = dol_mktime(0, 0, 0, GETPOST('date_startmonth', 'int'), GETPOST('date_startday', 'int'), GETPOST('date_startyear', 'int')); - $date_end = dol_mktime(0, 0, 0, GETPOST('date_endmonth', 'int'), GETPOST('date_endday', 'int'), GETPOST('date_endyear', 'int')); + $dateStart = dol_mktime(0, 0, 0, GETPOST('date_startmonth', 'int'), GETPOST('date_startday', 'int'), GETPOST('date_startyear', 'int')); + $dateEnd = dol_mktime(0, 0, 0, GETPOST('date_endmonth', 'int'), GETPOST('date_endday', 'int'), GETPOST('date_endyear', 'int')); - $_POST['date_start'] = $date_start; - $_POST['date_end'] = $date_end; + $_POST['date_start'] = $dateStart; + $_POST['date_end'] = $dateEnd; - if ($conf->global->DOLISIRH_TIMESHEET_PREFILL_DATE && empty($_POST['date_start']) && empty($_POST['date_end'])) { - $firstday = dol_get_first_day($year, (($month != 01) ? $month - 1 : $specialCaseMonth)); - $firstday = dol_getdate($firstday); + if (getDolGlobalInt('DOLISIRH_TIMESHEET_PREFILL_DATE') && empty($_POST['date_start']) && empty($_POST['date_end'])) { + $firstDay = dol_get_first_day($year, (($month != 01) ? $month - 1 : $specialCaseMonth)); + $firstDay = dol_getdate($firstDay); - $_POST['date_startday'] = $firstday['mday']; - $_POST['date_startmonth'] = $firstday['mon']; - $_POST['date_startyear'] = $firstday['year']; + $_POST['date_startday'] = $firstDay['mday']; + $_POST['date_startmonth'] = $firstDay['mon']; + $_POST['date_startyear'] = $firstDay['year']; - $lastday = dol_get_last_day($year, (($month != 01) ? $month - 1 : $specialCaseMonth)); - $lastday = dol_getdate($lastday); + $lastDay = dol_get_last_day($year, (($month != 01) ? $month - 1 : $specialCaseMonth)); + $lastDay = dol_getdate($lastDay); - $_POST['date_endday'] = $lastday['mday']; - $_POST['date_endmonth'] = $lastday['mon']; - $_POST['date_endyear'] = $lastday['year']; - } + $_POST['date_endday'] = $lastDay['mday']; + $_POST['date_endmonth'] = $lastDay['mon']; + $_POST['date_endyear'] = $lastDay['year']; + } - // Common attributes - include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_add.tpl.php'; + // Common attributes. + require_once DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_add.tpl.php'; - // Categories - if (isModEnabled('categorie')) { - print ''; - } + // Categories. + if (isModEnabled('categorie')) { + print ''; + } - // Other attributes - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_add.tpl.php'; + // Other attributes. + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_add.tpl.php'; - print '
'.$langs->trans('Categories').''; - $cate_arbo = $form->select_all_categories('timesheet', '', 'parent', 64, 0, 1); - print img_picto('', 'category') . $form->multiselectarray('categories', $cate_arbo, GETPOST('categories', 'array'), '', 0, 'quatrevingtpercent widthcentpercentminusx'); - print '
' . $langs->trans('Categories') . ''; + $cateArbo = $form->select_all_categories($object->element, '', 'parent', 64, 0, 1); + print img_picto('', 'category') . $form::multiselectarray('categories', $cateArbo, GETPOST('categories', 'array'), '', 0, 'quatrevingtpercent widthcentpercentminusx'); + print '
'; + print ''; - print dol_get_fiche_end(); + print dol_get_fiche_end(); - print $form->buttonsSaveCancel('Create'); + print $form->buttonsSaveCancel('Create'); - print '
'; + print ''; } -// Part to edit record +// Part to edit record. if (($id || $ref) && $action == 'edit') { - print load_fiche_titre($langs->trans('Modify' . ucfirst($object->element)), '', 'object_' . $object->picto); - - print '
'; - print ''; - print ''; - print ''; - if ($backtopage) { - print ''; - } - if ($backtopageforcancel) { - print ''; - } + print load_fiche_titre($langs->trans('Modify' . ucfirst($object->element)), '', 'object_' . $object->picto); + + print ''; + print ''; + print ''; + print ''; + if ($backtopage) { + print ''; + } + if ($backtopageforcancel) { + print ''; + } - print dol_get_fiche_head(); + print dol_get_fiche_head(); - print ''; + print '
'; - $dateStart = dol_mktime(0, 0, 0, GETPOST('date_startmonth', 'int'), GETPOST('date_startday', 'int'), GETPOST('date_startyear', 'int')); - $dateEnd = dol_mktime(0, 0, 0, GETPOST('date_endmonth', 'int'), GETPOST('date_endday', 'int'), GETPOST('date_endyear', 'int')); + $dateStart = dol_mktime(0, 0, 0, GETPOST('date_startmonth', 'int'), GETPOST('date_startday', 'int'), GETPOST('date_startyear', 'int')); + $dateEnd = dol_mktime(0, 0, 0, GETPOST('date_endmonth', 'int'), GETPOST('date_endday', 'int'), GETPOST('date_endyear', 'int')); $dateStart = (!empty($dateStart) ? $dateStart : $object->date_start); $dateEnd = (!empty($dateEnd) ? $dateEnd : $object->date_end); @@ -533,424 +454,449 @@ $_POST['date_endmonth'] = $dateEnd['mon']; $_POST['date_endyear'] = $dateEnd['year']; - $object->fields['note_public']['visible'] = 1; - $object->fields['note_private']['visible'] = 1; - - // Common attributes - include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_edit.tpl.php'; - - // Tags-Categories - if (isModEnabled('categorie')) { - print ''; - } + // Common attributes. + require_once DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_edit.tpl.php'; + + // Tags-Categories. + if (isModEnabled('categorie')) { + print ''; + } - // Other attributes - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_edit.tpl.php'; + // Other attributes. + require_once DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_edit.tpl.php'; - print '
' . $langs->trans('Categories') . ''; - $cate_arbo = $form->select_all_categories('timesheet', '', 'parent', 64, 0, 1); - $c = new Categorie($db); - $cats = $c->containing($object->id, 'timesheet'); - $arrayselected = []; - if (is_array($cats)) { - foreach ($cats as $cat) { - $arrayselected[] = $cat->id; - } - } - print img_picto('', 'category').$form->multiselectarray('categories', $cate_arbo, $arrayselected, '', 0, 'quatrevingtpercent widthcentpercentminusx'); - print '
' . $langs->trans('Categories') . ''; + $cate_arbo = $form->select_all_categories($object->element, '', 'parent', 64, 0, 1); + $categorie = new Categorie($db); + $cats = $categorie->containing($object->id, $object->element); + $arraySelected = []; + if (is_array($cats)) { + foreach ($cats as $cat) { + $arraySelected[] = $cat->id; + } + } + print img_picto('', 'category') . $form::multiselectarray('categories', $cate_arbo, $arraySelected, '', 0, 'quatrevingtpercent widthcentpercentminusx'); + print '
'; + print ''; - print dol_get_fiche_end(); + print dol_get_fiche_end(); - print $form->buttonsSaveCancel(); + print $form->buttonsSaveCancel(); - print '
'; + print ''; } -// Part to show record +// Part to show record. if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create'))) { - $res = $object->fetch_optionals(); + $object->fetch_optionals(); saturne_get_fiche_head($object, 'card', $title); saturne_banner_tab($object); - $formconfirm = ''; - - // setDraft confirmation - if (($action == 'setDraft' && (empty($conf->use_javascript_ajax) || !empty($conf->dol_use_jmobile))) || (!empty($conf->use_javascript_ajax) && empty($conf->dol_use_jmobile))) { - $formconfirm .= $form->formconfirm($_SERVER['PHP_SELF'] . '?id=' . $object->id, $langs->trans('ReOpenTimeSheet'), $langs->trans('ConfirmReOpenTimeSheet', $object->ref), 'confirm_setdraft', '', 'yes', 'actionButtonInProgress', 350, 600); - } - // setPendingSignature confirmation - if (($action == 'setPendingSignature' && (empty($conf->use_javascript_ajax) || !empty($conf->dol_use_jmobile))) || (!empty($conf->use_javascript_ajax) && empty($conf->dol_use_jmobile))) { - $formconfirm .= $form->formconfirm($_SERVER['PHP_SELF'] . '?id=' . $object->id, $langs->trans('ValidateTimeSheet'), $langs->trans('ConfirmValidateTimeSheet', $object->ref), 'confirm_validate', '', 'yes', 'actionButtonPendingSignature', 350, 600); - } - // setLocked confirmation - if (($action == 'setLocked' && (empty($conf->use_javascript_ajax) || !empty($conf->dol_use_jmobile))) || (!empty($conf->use_javascript_ajax) && empty($conf->dol_use_jmobile))) { - $formconfirm .= $form->formconfirm($_SERVER['PHP_SELF'] . '?id=' . $object->id, $langs->trans('LockTimeSheet'), $langs->trans('ConfirmLockTimeSheet', $object->ref), 'confirm_setLocked', '', 'yes', 'actionButtonLock', 350, 600); - } - // Confirmation to delete - if ($action == 'delete') { - $formconfirm = $form->formconfirm($_SERVER['PHP_SELF'] . '?id=' . $object->id, $langs->trans('DeleteTimeSheet'), $langs->trans('ConfirmDeleteObject'), 'confirm_delete', '', 'yes', 1); - } - // Confirmation to delete line - if ($action == 'ask_deleteline') { - $formconfirm = $form->formconfirm($_SERVER['PHP_SELF'] . '?id=' . $object->id . '&lineid=' . $lineid, $langs->trans('DeleteProductLine'), $langs->trans('ConfirmDeleteProductLine'), 'confirm_deleteline', '', 0, 1); - } - // Confirmation remove file - if ($action == 'removefile') { - $formconfirm = $form->formconfirm($_SERVER['PHP_SELF'] . '?id=' . $object->id . '&file=' . GETPOST('file') . '&entity=' . $conf->entity, $langs->trans('RemoveFileTimeSheet'), $langs->trans('ConfirmRemoveFileTimeSheet'), 'remove_file', '', 'yes', 1, 350, 600); - } - - // Call Hook formConfirm - $parameters = ['formConfirm' => $formconfirm, 'lineid' => $lineid]; - $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - if (empty($reshook)) { - $formconfirm .= $hookmanager->resPrint; - } elseif ($reshook > 0) { - $formconfirm = $hookmanager->resPrint; - } - - // Print form confirm - print $formconfirm; - - print '
'; - print '
'; - print ''; - - // Common attributes + $formConfirm = ''; + + // Draft confirmation + if (($action == 'draft' && (empty($conf->use_javascript_ajax) || !empty($conf->dol_use_jmobile))) || (!empty($conf->use_javascript_ajax) && empty($conf->dol_use_jmobile))) { + $formConfirm .= $form->formconfirm($_SERVER['PHP_SELF'] . '?id=' . $object->id, $langs->trans('ReOpenObject', $langs->transnoentities('The' . ucfirst($object->element))), $langs->trans('ConfirmReOpenObject', $langs->transnoentities('The' . ucfirst($object->element)), $langs->transnoentities('The' . ucfirst($object->element))), 'confirm_setdraft', '', 'yes', 'actionButtonInProgress', 350, 600); + } + // Pending signature confirmation + if (($action == 'pending_signature' && (empty($conf->use_javascript_ajax) || !empty($conf->dol_use_jmobile))) || (!empty($conf->use_javascript_ajax) && empty($conf->dol_use_jmobile))) { + $formConfirm .= $form->formconfirm($_SERVER['PHP_SELF'] . '?id=' . $object->id, $langs->trans('ValidateObject', $langs->transnoentities('The' . ucfirst($object->element))), $langs->trans('ConfirmValidateObject', $langs->transnoentities('The' . ucfirst($object->element)), $langs->transnoentities('The' . ucfirst($object->element))) . $langs->trans('ConfirmValidateTimeSheet'), 'confirm_validate', '', 'yes', 'actionButtonPendingSignature', 350, 600); + } + // Lock confirmation + if (($action == 'lock' && (empty($conf->use_javascript_ajax) || !empty($conf->dol_use_jmobile))) || (!empty($conf->use_javascript_ajax) && empty($conf->dol_use_jmobile))) { + $formConfirm .= $form->formconfirm($_SERVER['PHP_SELF'] . '?id=' . $object->id, $langs->trans('LockObject', $langs->transnoentities('The' . ucfirst($object->element))), $langs->trans('ConfirmLockObject', $langs->transnoentities('The' . ucfirst($object->element))), 'confirm_set_Lock', '', 'yes', 'actionButtonLock', 350, 600); + } + // Delete confirmation + if ($action == 'delete') { + $formConfirm = $form->formconfirm($_SERVER['PHP_SELF'] . '?id=' . $object->id, $langs->trans('DeleteObject', $langs->transnoentities('The' . ucfirst($object->element))), $langs->trans('ConfirmDeleteObject', $langs->transnoentities('The' . ucfirst($object->element))), 'confirm_delete', '', 'yes', 1); + } + // Delete line confirmation + if ($action == 'ask_deleteline') { + $formConfirm = $form->formconfirm($_SERVER['PHP_SELF'] . '?id=' . $object->id . '&lineid=' . $lineid, $langs->trans('DeleteProductLine'), $langs->trans('ConfirmDeleteProductLine'), 'confirm_deleteline', '', 0, 1); + } + // Remove file confirmation + if ($action == 'removefile') { + $formConfirm = $form->formconfirm($_SERVER['PHP_SELF'] . '?id=' . $object->id . '&file=' . GETPOST('file') . '&entity=' . $conf->entity, $langs->trans('RemoveFileTimeSheet'), $langs->trans('ConfirmRemoveFileTimeSheet'), 'remove_file', '', 'yes', 1, 350, 600); + } + + // Call Hook formConfirm. + $parameters = ['formConfirm' => $formConfirm, 'lineid' => $lineid]; + $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook. + if (empty($reshook)) { + $formConfirm .= $hookmanager->resPrint; + } elseif ($reshook > 0) { + $formConfirm = $hookmanager->resPrint; + } + + // Print form confirm. + print $formConfirm; + + if ($conf->browser->layout == 'phone') { + $onPhone = 1; + } else { + $onPhone = 0; + } + + print '
'; + print '
'; + print '
'; + + // Common attributes unset($object->fields['label']); // Hide field already shown in banner - unset($object->fields['fk_project']); // Hide field already shown in banner - unset($object->fields['fk_soc']); // Hide field already shown in banner - - include DOL_DOCUMENT_ROOT . '/core/tpl/commonfields_view.tpl.php'; - - // Categories - if (isModEnabled('categorie')) { - print ''; - } - - $now = dol_now(); - $datestart = dol_getdate($object->date_start, false, 'Europe/Paris'); - - // Due to Dolibarr issue in common field add we do substract 12 hours in timestamp - $firstdaytoshow = $object->date_start - 12 * 3600; - $lastdaytoshow = $object->date_end - 12 * 3600; - - $start_date = dol_print_date($firstdaytoshow, 'dayreduceformat'); - $end_date = dol_print_date($lastdaytoshow, 'dayreduceformat'); - - $daysInRange = dolisirh_num_between_days($firstdaytoshow, $lastdaytoshow, 1); - - $isavailable = array(); - for ($idw = 0; $idw < $daysInRange; $idw++) { - $dayInLoop = dol_time_plus_duree($firstdaytoshow, $idw, 'd'); - if (is_day_available($dayInLoop, $user->id)) { - $isavailable[$dayInLoop] = array('morning'=>1, 'afternoon'=>1); - } else if (date('N', $dayInLoop) >= 6) { - $isavailable[$dayInLoop] = array('morning'=>false, 'afternoon'=>false, 'morning_reason'=>'week_end', 'afternoon_reason'=>'week_end'); - } else { - $isavailable[$dayInLoop] = array('morning'=>false, 'afternoon'=>false, 'morning_reason'=>'public_holiday', 'afternoon_reason'=>'public_holiday'); - } - } - - $workingHours = $workinghours->fetchCurrentWorkingHours($object->fk_user_assign, 'user'); - - $timeSpendingInfos = load_time_spending_infos_within_range($firstdaytoshow, dol_time_plus_duree($lastdaytoshow, 1, 'd'), $workingHours, $isavailable, $object->fk_user_assign); - - // Planned working time - $planned_working_time = $timeSpendingInfos['planned']; - - print ''; - - // Hours passed - $passed_working_time = $timeSpendingInfos['passed']; - - print ''; - - //Difference between passed and working hours - $difftotaltime = $timeSpendingInfos['difference']; - - if ($difftotaltime < 0) { - $morecssHours = colorStringToArray($conf->global->DOLISIRH_EXCEEDED_TIME_SPENT_COLOR); - $morecssnotice = 'error'; - $noticetitle = $langs->trans('TimeSpentDiff', dol_print_date($firstdaytoshow, 'dayreduceformat'), dol_print_date($lastdaytoshow, 'dayreduceformat'), dol_print_date(dol_mktime(0, 0, 0, $datestart['mon'], $datestart['mday'], $datestart['year']), '%B %Y')); - } elseif ($difftotaltime > 0) { - $morecssHours = colorStringToArray($conf->global->DOLISIRH_NOT_EXCEEDED_TIME_SPENT_COLOR); - $morecssnotice = 'warning'; - $noticetitle = $langs->trans('TimeSpentMustBeCompleted', dol_print_date($firstdaytoshow, 'dayreduceformat'), dol_print_date($lastdaytoshow, 'dayreduceformat'), dol_print_date(dol_mktime(0, 0, 0, $datestart['mon'], $datestart['mday'], $datestart['year']), '%B %Y')); - } elseif ($difftotaltime == 0) { - $morecssHours = colorStringToArray($conf->global->DOLISIRH_PERFECT_TIME_SPENT_COLOR); - $morecssnotice = 'success'; - $noticetitle = $langs->trans('TimeSpentPerfect'); - } - - //Working hours - $working_time = $timeSpendingInfos['spent']; - - if ($planned_working_time['days'] > $working_time['days']) { - $morecssDays = colorStringToArray($conf->global->DOLISIRH_EXCEEDED_TIME_SPENT_COLOR); - } else if ($planned_working_time['days'] < $working_time['days']){ - $morecssDays = colorStringToArray($conf->global->DOLISIRH_NOT_EXCEEDED_TIME_SPENT_COLOR); - } else { - $morecssDays = colorStringToArray($conf->global->DOLISIRH_PERFECT_TIME_SPENT_COLOR); - } - - print ''; - - //Difference between working hours & planned working hours - print ''; - - // Other attributes. Fields from hook formObjectOptions and Extrafields. - include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; - - print '
' . $langs->trans('Categories') . ''; - print $form->showCategories($object->id, 'timesheet', 1); - print '
'; - print $langs->trans('Total'); - print ' - '; - print $langs->trans('ExpectedWorkingHoursMonthTimeSheet', $start_date, $end_date); - print ' : '; - print (($planned_working_time['minutes'] != 0) ? convertSecondToTime($planned_working_time['minutes'] * 60, 'allhourmin') : '00:00') . ''; - print '' . ' - ' . $langs->trans('ExpectedWorkingDayMonth') . ' ' . $planned_working_time['days'] . ''; - print ''; - print '
'; - print $langs->trans('Total'); - print ' - '; - print $langs->trans('SpentWorkingHoursMonth', $start_date, $end_date); - print ' : ' . (($passed_working_time['minutes'] != 0) ? convertSecondToTime($passed_working_time['minutes'] * 60, 'allhourmin') : '00:00') . ''; - print '
'; - print $langs->trans('Total'); - print ' - '; - print $langs->trans('ConsumedWorkingHoursMonth', $start_date, $end_date); - print ' : '.convertSecondToTime($working_time['total'], 'allhourmin').''; - print '' . ' - ' . $langs->trans('ConsumedWorkingDayMonth') . ' '; - print $working_time['days'] . ''; - print ''; - print '
'; - print $langs->trans('Total'); - print ' - '; - print $langs->trans('DiffSpentAndConsumedWorkingHoursMonth', $start_date, $end_date); - print ' : '; - print (($difftotaltime != 0) ? convertSecondToTime(abs($difftotaltime * 60), 'allhourmin') : '00:00').''; - print ''; - print '
'; - print '
'; - print '
'; - - $usertmp->fetch($object->fk_user_assign); - - print '
'; ?> - - -
-
-
trans('ErrorConfigWorkingHours') ?>
-
- trans('GoToWorkingHours', $usertmp->getFullName($langs)) ?> -
- -
-
-
-
- trans('GoToTimeSpent', dol_print_date(dol_mktime(0, 0, 0, $datestart['mon'], $datestart['mday'], $datestart['year']), '%B %Y')) ?> -
- + unset($object->fields['fk_project']); // Hide field already shown in banner + unset($object->fields['fk_soc']); // Hide field already shown in banner + + require_once DOL_DOCUMENT_ROOT . '/core/tpl/commonfields_view.tpl.php'; + + // Categories. + if (isModEnabled('categorie')) { + print '' . $langs->trans('Categories') . ''; + print $form->showCategories($object->id, $object->element, 1); + print ''; + } + + $dateStart = dol_getdate($object->date_start, false, 'Europe/Paris'); + + // Due to Dolibarr issue in common field add we do substract 12 hours in timestamp. + $firstDayToShow = $object->date_start - 12 * 3600; + $lastDayToShow = $object->date_end - 12 * 3600; + + $startDate = dol_print_date($firstDayToShow, 'dayreduceformat'); + $endDate = dol_print_date($lastDayToShow, 'dayreduceformat'); + + $daysInRange = dolisirh_num_between_days($firstDayToShow, $lastDayToShow, 1); + + $isAvailable = []; + for ($idw = 0; $idw < $daysInRange; $idw++) { + $dayInLoop = dol_time_plus_duree($firstDayToShow, $idw, 'd'); + if (is_day_available($dayInLoop, $user->id)) { + $isAvailable[$dayInLoop] = ['morning' => 1, 'afternoon' => 1]; + } elseif (date('N', $dayInLoop) >= 6) { + $isAvailable[$dayInLoop] = ['morning' => false, 'afternoon' => false, 'morning_reason' => 'week_end', 'afternoon_reason' => 'week_end']; + } else { + $isAvailable[$dayInLoop] = ['morning' => false, 'afternoon' => false, 'morning_reason' => 'public_holiday', 'afternoon_reason' => 'public_holiday']; + } + } + + $workingHours = $workingHours->fetchCurrentWorkingHours($object->fk_user_assign, 'user'); + + $timeSpendingInfos = load_time_spending_infos_within_range($firstDayToShow, dol_time_plus_duree($lastDayToShow, 1, 'd'), $workingHours, $isAvailable, $object->fk_user_assign); + + // Planned working time. + $plannedWorkingTime = $timeSpendingInfos['planned']; + + print ''; + print $langs->trans('Total'); + print ' - '; + print $langs->trans('ExpectedWorkingHoursMonthTimeSheet', $startDate, $endDate); + print ' : '; + print (($plannedWorkingTime['minutes'] != 0) ? convertSecondToTime($plannedWorkingTime['minutes'] * 60, 'allhourmin') : '00:00') . ''; + print '' . ' - ' . $langs->trans('ExpectedWorkingDayMonth') . ' ' . $plannedWorkingTime['days'] . ''; + print ''; + print ''; + + // Hours passed. + $passedWorkingTime = $timeSpendingInfos['passed']; + + print ''; + print $langs->trans('Total'); + print ' - '; + print $langs->trans('SpentWorkingHoursMonth', $startDate, $endDate); + print ' : ' . (($passedWorkingTime['minutes'] != 0) ? convertSecondToTime($passedWorkingTime['minutes'] * 60, 'allhourmin') : '00:00') . ''; + print ''; + + // Difference between passed and working hours. + $diffTotalTime = $timeSpendingInfos['difference']; + + if ($diffTotalTime < 0) { + $moreCssHours = colorStringToArray($conf->global->DOLISIRH_EXCEEDED_TIME_SPENT_COLOR); + $moreCssNotice = 'error'; + $noticeTitle = $langs->trans('TimeSpentDiff', dol_print_date($firstDayToShow, 'dayreduceformat'), dol_print_date($lastDayToShow, 'dayreduceformat'), dol_print_date(dol_mktime(0, 0, 0, $dateStart['mon'], $dateStart['mday'], $dateStart['year']), '%B %Y')); + } elseif ($diffTotalTime > 0) { + $moreCssHours = colorStringToArray($conf->global->DOLISIRH_NOT_EXCEEDED_TIME_SPENT_COLOR); + $moreCssNotice = 'warning'; + $noticeTitle = $langs->trans('TimeSpentMustBeCompleted', dol_print_date($firstDayToShow, 'dayreduceformat'), dol_print_date($lastDayToShow, 'dayreduceformat'), dol_print_date(dol_mktime(0, 0, 0, $dateStart['mon'], $dateStart['mday'], $dateStart['year']), '%B %Y')); + } elseif ($diffTotalTime == 0) { + $moreCssHours = colorStringToArray($conf->global->DOLISIRH_PERFECT_TIME_SPENT_COLOR); + $moreCssNotice = 'success'; + $noticeTitle = $langs->trans('TimeSpentPerfect'); + } else { + $moreCssHours = ''; + $moreCssNotice = ''; + $noticeTitle = ''; + } + + // Working hours. + $workingTime = $timeSpendingInfos['spent']; + + if ($plannedWorkingTime['days'] > $workingTime['days']) { + $morecssDays = colorStringToArray($conf->global->DOLISIRH_EXCEEDED_TIME_SPENT_COLOR); + } elseif ($plannedWorkingTime['days'] < $workingTime['days']){ + $morecssDays = colorStringToArray($conf->global->DOLISIRH_NOT_EXCEEDED_TIME_SPENT_COLOR); + } else { + $morecssDays = colorStringToArray($conf->global->DOLISIRH_PERFECT_TIME_SPENT_COLOR); + } + + print ''; + print $langs->trans('Total'); + print ' - '; + print $langs->trans('ConsumedWorkingHoursMonth', $startDate, $endDate); + print ' : '.convertSecondToTime($workingTime['total'], 'allhourmin') . ''; + print '' . ' - ' . $langs->trans('ConsumedWorkingDayMonth') . ' '; + print $workingTime['days'] . ''; + print ''; + print ''; + + // Difference between working hours & planned working hours. + print ''; + print $langs->trans('Total'); + print ' - '; + print $langs->trans('DiffSpentAndConsumedWorkingHoursMonth', $startDate, $endDate); + print ' : '; + print (($diffTotalTime != 0) ? convertSecondToTime(abs($diffTotalTime * 60), 'allhourmin') : '00:00') . ''; + print ''; + print ''; + + // Other attributes. Fields from hook formObjectOptions and Extrafields. + require_once DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; + + print ''; + print ''; + print ''; + + $userTmp->fetch($object->fk_user_assign); + + print '
'; ?> + + +
+
+
trans('ErrorConfigWorkingHours') ?>
+
+ trans('GoToWorkingHours', $userTmp->getFullName($langs)) ?> +
+ +
+
+
+
+ trans('GoToTimeSpent', dol_print_date(dol_mktime(0, 0, 0, $dateStart['mon'], $dateStart['mday'], $dateStart['year']), '%B %Y')) ?> +
+ global->DOLISIRH_HR_PROJECT) || empty($conf->global->DOLISIRH_HOLIDAYS_TASK) || empty($conf->global->DOLISIRH_PAID_HOLIDAYS_TASK) || empty($conf->global->DOLISIRH_PAID_HOLIDAYS_TASK) || empty($conf->global->DOLISIRH_PAID_HOLIDAYS_TASK) - || empty($conf->global->DOLISIRH_PUBLIC_HOLIDAY_TASK) || empty($conf->global-> DOLISIRH_RTT_TASK) || empty($conf->global->DOLISIRH_INTERNAL_MEETING_TASK) || empty($conf->global->DOLISIRH_INTERNAL_TRAINING_TASK) || empty($conf->global->DOLISIRH_EXTERNAL_TRAINING_TASK) - || empty($conf->global->DOLISIRH_AUTOMATIC_TIMESPENDING_TASK) || empty($conf->global->DOLISIRH_MISCELLANEOUS_TASK)) : ?> + || empty($conf->global->DOLISIRH_PUBLIC_HOLIDAY_TASK) || empty($conf->global-> DOLISIRH_RTT_TASK) || empty($conf->global->DOLISIRH_INTERNAL_MEETING_TASK) || empty($conf->global->DOLISIRH_INTERNAL_TRAINING_TASK) || empty($conf->global->DOLISIRH_EXTERNAL_TRAINING_TASK) + || empty($conf->global->DOLISIRH_AUTOMATIC_TIMESPENDING_TASK) || empty($conf->global->DOLISIRH_MISCELLANEOUS_TASK)) : ?>
trans('ErrorConfigProjectPage') ?>
- trans('GoToConfigProjectPage') ?> + trans('GoToConfigProjectPage') ?>
- table_element_line)) { - // Show object lines - $result = $object->getLinesArray(); - - print '
- - - - - - '; - - if (!empty($conf->use_javascript_ajax) && $object->status == 0) { - include DOL_DOCUMENT_ROOT.'/core/tpl/ajaxrow.tpl.php'; - } - - print '
'; - if (!empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action != 'selectlines' && $action != 'editline')) { - print ''; - } - - if (!empty($object->lines)) { - if ($permissiontoadd) { - $user->rights->timesheet = new stdClass(); - $user->rights->timesheet->creer = 1; - $object->statut = $object::STATUS_DRAFT; - if ($object->status >= $object::STATUS_VALIDATED) { - $disableedit = 1; - $disableremove = 1; - $disablemove = 1; - } - } - $object->printObjectLines($action, $mysoc, null, GETPOST('lineid', 'int'), 1); ?> - - status == 0 && $permissiontoadd && $action != 'selectlines') { - if ($action != 'editline') { - // Add products/services form - $object->socid = 0; - $parameters = array(); - $reshook = $hookmanager->executeHooks('formAddObjectLine', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); - if (empty($reshook)) $object->formAddObjectLine(1, $mysoc, $soc); ?> - - lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action != 'selectlines' && $action != 'editline')) { - print '
'; - } - print '
'; - - print "
\n"; - } - - // Buttons for actions - if ($action != 'presend' && $action != 'editline') { - print '
'."\n"; - $parameters = array(); - $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - if ($reshook < 0) { - setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); - } - - if (empty($reshook) && $permissiontoadd) { - // Modify - if ($object->status == $object::STATUS_DRAFT) { - print '' . $langs->trans('Modify') . ''; + table_element_line)) { + // Show object lines. + $result = $object->getLinesArray(); + + print '
+ + + + + + '; + + if (!empty($conf->use_javascript_ajax) && $object->status == 0) { + include DOL_DOCUMENT_ROOT . '/core/tpl/ajaxrow.tpl.php'; + } + + print '
'; + if (!empty($object->lines) || ($object->status == TimeSheet::STATUS_DRAFT && $permissiontoadd && $action != 'selectlines' && $action != 'editline')) { + print ''; + } + + if (!empty($object->lines)) { + if ($permissiontoadd) { + $user->rights->timesheet = new stdClass(); + $user->rights->timesheet->creer = 1; + $object->statut = TimeSheet::STATUS_DRAFT; + if ($object->status >= TimeSheet::STATUS_VALIDATED) { + $disableedit = 1; + $disableremove = 1; + $disablemove = 1; + } + } + $object->printObjectLines($action, $mysoc, null, $lineid, 1); ?> + + status == TimeSheet::STATUS_DRAFT && $permissiontoadd && $action != 'selectlines') { + if ($action != 'editline') { + // Add products/services form. + $parameters = []; + $reshook = $hookmanager->executeHooks('formAddObjectLine', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + } + if (empty($reshook)) { + $object->formAddObjectLine(1, $mysoc, $mysoc); + } ?> + + lines) || ($object->status == TimeSheet::STATUS_DRAFT && $permissiontoadd && $action != 'selectlines' && $action != 'editline')) { + print '
'; + } + print '
'; + + print '
'; + } + + // Buttons for actions. + if ($action != 'presend' && $action != 'editline') { + print '
'; + $parameters = []; + $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook. + if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + } + + if (empty($reshook) && $permissiontoadd) { + // Modify. + $displayButton = $onPhone ? '' : '' . ' ' . $langs->trans('Modify'); + if ($object->status == TimeSheet::STATUS_DRAFT) { + print '' . $displayButton . ''; } else { - print '' . $langs->trans('Modify') . ''; + print '' . $displayButton . ''; } - // Validate - if ($object->status == $object::STATUS_DRAFT && $planned_working_time['minutes'] != 0) { - print '' . $langs->trans('Validate') . ''; + // Validate. + $displayButton = $onPhone ? '' : '' . ' ' . $langs->trans('Validate'); + if ($object->status == TimeSheet::STATUS_DRAFT && $plannedWorkingTime['minutes'] != 0) { + print '' . $displayButton . ''; } else { - print '' . $langs->trans('Validate') . ''; + print '' . $displayButton . ''; } - // ReOpen - if ($object->status == $object::STATUS_VALIDATED) { - print '' . $langs->trans('ReOpenDoli') . ''; + // ReOpen. + $displayButton = $onPhone ? '' : '' . ' ' . $langs->trans('ReOpenDoli'); + if ($object->status == TimeSheet::STATUS_VALIDATED) { + print '' . $displayButton . ''; } else { - print '' . $langs->trans('ReOpenDoli') . ''; + print '' . $displayButton . ''; } - // Sign - if ($object->status == $object::STATUS_VALIDATED && !$signatory->checkSignatoriesSignatures($object->id, 'timesheet')) { - print '' . $langs->trans('Sign') . ''; + // Sign. + $displayButton = $onPhone ? '' : '' . ' ' . $langs->trans('Sign'); + if ($object->status == TimeSheet::STATUS_VALIDATED && !$signatory->checkSignatoriesSignatures($object->id, $object->element)) { + print '' . $displayButton . ''; } else { - print '' . $langs->trans('Sign') . ''; + print '' . $displayButton . ''; } - // Lock - if ($object->status == $object::STATUS_VALIDATED && $signatory->checkSignatoriesSignatures($object->id, 'timesheet') && $difftotaltime == 0 && $diffworkinghoursMonth == 0) { - print '' . $langs->trans('Lock') . ''; + // Lock. + $displayButton = $onPhone ? '' : '' . ' ' . $langs->trans('Lock'); + if ($object->status == TimeSheet::STATUS_VALIDATED && $signatory->checkSignatoriesSignatures($object->id, $object->element) && $diffTotalTime == 0) { + print '' . $displayButton . ''; } else { - print '' . $langs->trans('Lock') . ''; + print '' . $displayButton . ''; } - // Send - //@TODO changer le send to - //print '' . $langs->trans('SendMail') . ''; + // Send email. + $displayButton = $onPhone ? '' : '' . ' ' . $langs->trans('SendMail') . ' '; + if ($object->status == TimeSheet::STATUS_LOCKED) { + $fileParams = dol_most_recent_file($upload_dir . '/' . $object->element . 'document' . '/' . $object->ref); + $file = $fileParams['fullname']; + if (file_exists($file) && !strstr($fileParams['name'], 'specimen')) { + $forcebuilddoc = 0; + } else { + $forcebuilddoc = 1; + } + print dolGetButtonAction($displayButton, '', 'default', $_SERVER['PHP_SELF'] . '?id=' . $object->id . '&action=presend&forcebuilddoc=' . $forcebuilddoc . '&mode=init#formmailbeforetitle'); + } else { + print '' . $displayButton . ''; + } - // Archive - if ($object->status == $object::STATUS_LOCKED && !empty(dol_dir_list($upload_dir . '/timesheetdocument/' . dol_sanitizeFileName($object->ref)))) { - print '' . $langs->trans('Archive') . ''; + // Archive. + $displayButton = $onPhone ? '' : '' . ' ' . $langs->trans('Archive'); + if ($object->status == TimeSheet::STATUS_LOCKED && !empty(dol_dir_list($upload_dir . '/timesheetdocument/' . dol_sanitizeFileName($object->ref)))) { + print '' . $displayButton . ''; } else { - print '' . $langs->trans('Archive') . ''; + print '' . $displayButton . ''; } - // Delete (need delete permission, or if draft, just need create/modify permission) - //print dolGetButtonAction($langs->trans('Delete'), '', 'delete', $_SERVER['PHP_SELF'].'?id='.$object->id.'&action=delete&token='.newToken(), '', $permissiontodelete || ($object->status == $object::STATUS_DRAFT && $permissiontoadd)); - } - print '
'."\n"; - } + // Delete (need delete permission, or if draft, just need create/modify permission). + $displayButton = $onPhone ? '' : '' . ' ' . $langs->trans('Delete'); + print dolGetButtonAction($displayButton, '', 'delete', $_SERVER['PHP_SELF'] . '?id=' . $object->id . '&action=delete&token=' . newToken(), '', $permissiontodelete || ($object->status == TimeSheet::STATUS_DRAFT)); + } + print '
'; + } - // Select mail models is same action as presend - if (GETPOST('modelselected')) { - $action = 'presend'; - } + // Select mail models is same action as presend. + if (GETPOST('modelselected')) { + $action = 'presend'; + } if ($action != 'presend') { print '
'; - // Documents + // Documents. $objRef = dol_sanitizeFileName($object->ref); $dirFiles = $object->element . 'document/' . $objRef; $fileDir = $upload_dir . '/' . $dirFiles; $urlSource = $_SERVER['PHP_SELF'] . '?id=' . $object->id; - print saturne_show_documents('dolisirh:' . ucfirst($object->element) . 'Document', $dirFiles, $fileDir, $urlSource, $permissiontoadd, $permissiontodelete, $conf->global->DOLISIRH_TIMESHEETDOCUMENT_DEFAULT_MODEL, 1, 0, 0, 0, 0, '', '', '', $langs->defaultlang, $object, 0, 'remove_file', $object->status == $object::STATUS_LOCKED && empty(dol_dir_list($fileDir)), $langs->trans('TimeSheetMustBeLocked')); + print saturne_show_documents('dolisirh:' . ucfirst($object->element) . 'Document', $dirFiles, $fileDir, $urlSource, $permissiontoadd, $permissiontodelete, $conf->global->DOLISIRH_TIMESHEETDOCUMENT_DEFAULT_MODEL, 1, 0, 0, 0, 0, '', '', '', $langs->defaultlang, $object, 0, 'remove_file', $object->status == TimeSheet::STATUS_LOCKED && empty(dol_dir_list($fileDir)), $langs->trans('ObjectMustBeLockedToGenerate', ucfirst($langs->transnoentities('The' . ucfirst($object->element))))); - print '
'; + print '
'; - $MAXEVENT = 10; + $moreHtmlCenter = dolGetButtonTitle($langs->trans('SeeAll'), '', 'fa fa-list-alt imgforviewmode', dol_buildpath('/dolisirh/view/timesheet/timesheet_agenda.php', 1) . '?id='. $object->id); - $morehtmlcenter = dolGetButtonTitle($langs->trans('SeeAll'), '', 'fa fa-list-alt imgforviewmode', dol_buildpath('/dolisirh/view/timesheet/timesheet_agenda.php', 1).'?id='.$object->id); + // List of actions on element. + require_once DOL_DOCUMENT_ROOT . '/core/class/html.formactions.class.php'; + $formActions = new FormActions($db); + $formActions->showactions($object, $object->element . '@' . $object->module, 0, 1, '', 10, '', $moreHtmlCenter); - // List of actions on element - include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'; - $formactions = new FormActions($db); - $somethingshown = $formactions->showactions($object, $object->element.'@'.$object->module, (is_object($object->thirdparty) ? $object->thirdparty->id : 0), 1, '', $MAXEVENT, '', $morehtmlcenter); - - print '
'; - } + print ''; + } - //Select mail models is same action as presend - if (GETPOST('modelselected')) { - $action = 'presend'; - } + //Select mail models is same action as presend. + if (GETPOST('modelselected')) { + $action = 'presend'; + } - // Presend form - $modelmail = 'timesheet'; - $defaulttopic = 'InformationMessage'; - $diroutput = $conf->dolisirh->dir_output; - $trackid = 'timesheet'.$object->id; + // Presend form. + $modelmail = $object->element; + $defaulttopic = 'InformationMessage'; + $diroutput = $conf->dolisirh->dir_output; + $trackid = $object->element . $object->id; - include DOL_DOCUMENT_ROOT.'/core/tpl/card_presend.tpl.php'; + require_once DOL_DOCUMENT_ROOT.'/core/tpl/card_presend.tpl.php'; } -// End of page +// End of page. llxFooter(); $db->close();