Skip to content

Commit

Permalink
#231 [Timesheet] add: clean card
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolas-eoxia committed Jul 21, 2023
1 parent aeec91c commit 0412733
Showing 1 changed file with 27 additions and 31 deletions.
58 changes: 27 additions & 31 deletions view/timesheet/timesheet_card.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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';
Expand All @@ -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');
Expand All @@ -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');
Expand All @@ -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
Expand All @@ -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)) {
Expand Down Expand Up @@ -430,7 +434,7 @@
print '<input type="hidden" name="backtopage" value="' . $backtopage . '">';
}
if ($backtopageforcancel) {
print '<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.'">';
print '<input type="hidden" name="backtopageforcancel" value="'. $backtopageforcancel . '">';
}

print dol_get_fiche_head();
Expand Down Expand Up @@ -909,23 +913,15 @@
$action = 'presend';
}

if ($action != 'presend') {
print '<div class="fichecenter"><div class="fichehalfleft">';
print '<a name="builddoc"></a>'; // ancre
if ($action != 'presend') {
print '<div class="fichecenter"><div class="fichehalfleft">';
// 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 '</div><div class="fichehalfright">';

Expand Down

0 comments on commit 0412733

Please sign in to comment.