diff --git a/view/timesheet/timesheet_card.php b/view/timesheet/timesheet_card.php index eaba6e4..84feb6f 100644 --- a/view/timesheet/timesheet_card.php +++ b/view/timesheet/timesheet_card.php @@ -16,9 +16,9 @@ */ /** - * \file view/timesheet/timesheet_card.php - * \ingroup dolisirh - * \brief Page to create/edit/view timesheet + * \file view/timesheet/timesheet_card.php + * \ingroup dolisirh + * \brief Page to create/edit/view timesheet */ // Load DoliSIRH environment @@ -31,11 +31,15 @@ } // 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'; +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 Saturne libraries. +require_once __DIR__ . '/../../../saturne/class/saturnesignature.class.php'; + +// load DoliSIRH libraries. require_once __DIR__ . '/../../class/timesheet.class.php'; require_once __DIR__ . '/../../class/dolisirhdocuments/timesheetdocument.class.php'; require_once __DIR__ . '/../../class/workinghours.class.php'; @@ -50,7 +54,7 @@ // Load translation files required by the page saturne_load_langs(); -// Get parameters +// Get parameters. $id = GETPOST('id', 'int'); $ref = GETPOST('ref', 'alpha'); $action = GETPOST('action', 'aZ09'); @@ -64,7 +68,7 @@ $month = (GETPOST('month', 'int') ? GETPOST('month', 'int') : date('m')); $day = (GETPOST('day', 'int') ? GETPOST('day', 'int') : date('d')); -// Initialize technical objects +// Initialize technical objects. $object = new TimeSheet($db); $objectline = new TimeSheetLine($db); $signatory = new SaturneSignature($db, 'dolisirh'); @@ -91,13 +95,13 @@ $search_all = 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'); + } } if (empty($action) && empty($id) && empty($ref)) { - $action = 'view'; + $action = 'view'; } // Load object @@ -118,7 +122,7 @@ $parameters = []; $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'); + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); } if (empty($reshook)) { @@ -430,7 +434,7 @@ print ''; } if ($backtopageforcancel) { - print ''; + print ''; } print dol_get_fiche_head(); @@ -909,23 +913,15 @@ $action = 'presend'; } - if ($action != 'presend') { - print '
'; - print ''; // ancre + if ($action != 'presend') { + print '
'; + // Documents + $objRef = dol_sanitizeFileName($object->ref); + $dirFiles = $object->element . 'document/' . $objRef; + $fileDir = $upload_dir . '/' . $dirFiles; + $urlSource = $_SERVER['PHP_SELF'] . '?id=' . $object->id; - $includedocgeneration = 1; - - // Documents - if ($includedocgeneration) { - $objref = dol_sanitizeFileName($object->ref); - $dir_files = $object->element . 'document/' . $objref; - $filedir = $upload_dir . '/' . $dir_files; - $urlsource = $_SERVER['PHP_SELF']. '?id=' .$object->id; - $genallowed = $permissiontoadd; // If you can read, you can build the PDF to read content - $delallowed = $permissiontodelete; // If you can create/edit, you can remove a file on card - - print saturne_show_documents('dolisirh:TimeSheetDocument', $dir_files, $filedir, $urlsource, $genallowed, $object->status == $object::STATUS_LOCKED ? $delallowed : 0, $conf->global->DOLISIRH_TIMESHEETDOCUMENT_DEFAULT_MODEL, 1, 0, 0, 0, 0, '', '', '', $langs->defaultlang, $object, 0, 'removefile', $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 == $object::STATUS_LOCKED && empty(dol_dir_list($fileDir)), $langs->trans('TimeSheetMustBeLocked')); print '
';