Skip to content

Commit

Permalink
#236 [Dashboard] add: hook for add custom view before dashboard
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolas-eoxia committed Jul 6, 2023
1 parent 65b9332 commit abdf291
Show file tree
Hide file tree
Showing 3 changed files with 90 additions and 14 deletions.
84 changes: 84 additions & 0 deletions class/actions_dolisirh.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -1124,4 +1124,88 @@ public function getNomUrl(array $parameters, CommonObject $object, string $actio
return 0;
}
}

/**
* Overloading the SaturneAdminObjectConst function : replacing the parent's function with the one below.
*
* @param array $parameters Hook metadata (context, etc...)
* @return void
*/
public function SaturneAdminObjectConst(array $parameters)
{
if ($parameters['currentcontext'] == 'timesheetadmin') {
$constArray['timesheet'] = [
'PrefillDate' => [
'name' => 'PrefillDate',
'description' => 'PrefillDateDescription',
'code' => 'DOLISIRH_TIMESHEET_PREFILL_DATE',
],
'AddAttendantsConf' => [
'name' => 'AddAttendantsConf',
'description' => 'AddAttendantsDescription',
'code' => 'DOLISIRH_TIMESHEET_ADD_ATTENDANTS',
],
'CheckDateEnd' => [
'name' => 'CheckDateEnd',
'description' => 'CheckDateEndDescription',
'code' => 'DOLISIRH_TIMESHEET_CHECK_DATE_END',
],
'ShowTasksWithTimespentOnTimeSheet' => [
'name' => 'ShowTasksWithTimespentOnTimeSheet',
'description' => 'ShowTasksWithTimespentOnTimeSheetDescription',
'code' => 'DOLISIRH_SHOW_TASKS_WITH_TIMESPENT_ON_TIMESHEET',
],
];

$this->results = $constArray;
}
}

/**
* Overloading the SaturneAdminDocumentData function : replacing the parent's function with the one below.
*
* @param array $parameters Hook metadata (context, etc...)
* @return void
*/
public function SaturneAdminDocumentData(array $parameters)
{
if ($parameters['currentcontext'] == 'dolisirhadmindocuments') {
$types = [
'TimeSheetDocument' => [
'documentType' => 'timesheetdocument',
'picto' => 'fontawesome_fa-calendar-check_fas_#d35968'
],
'CertificateDocument' => [
'documentType' => 'certificatedocument',
'picto' => 'fontawesome_fa-user-graduate_fas_#d35968'
]
];

$this->results = $types;
}
}

/**
* Overloading the SaturneIndex function : replacing the parent's function with the one below.
*
* @param array $parameters Hook metadata (context, etc...)
* @return void
*/
public function SaturneIndex(array $parameters)
{
global $conf, $langs;

if ($parameters['currentcontext'] == 'dolisirhindex') {
if ($conf->global->DOLISIRH_HR_PROJECT_SET == 0) {
$out = '<div class="wpeo-notice notice-info">';
$out .= '<div class="notice-content">';
$out .= '<div class="notice-title"><strong>' . $langs->trans('SetupDefaultDataNotCreated') . '</strong></div>';
$out .= '<div class="notice-subtitle"><strong>' . $langs->trans('HowToSetupDefaultData') . ' <a href="admin/setup.php">' . $langs->trans('ConfigDefaultData') . '</a></strong></div>';
$out .= '</div>';
$out .= '</div>';

$this->resprints = $out;
}
}
}
}
9 changes: 6 additions & 3 deletions core/modules/modDoliSIRH.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,12 @@ public function __construct($db)
'timesheetcard',
'actioncard',
'userihm',
'projectcard'
),
),
'timesheetadmin',
'dolisirhadmindocuments',
'dolisirhindex',
'projetcard'
],
],
'moduleforexternal' => 0,
);

Expand Down
11 changes: 0 additions & 11 deletions dolisirhindex.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,4 @@
$morehtmlright .= ' ' . img_picto($langs->trans('Filter') . ' ' . $langs->trans('User'), 'user', 'class="paddingright pictofixedwidth"') . $form->select_dolusers($userID, 'search_userid', '', null, 0, '', null, 0, 0, 0, ' AND u.employee = 1', 0, '', 'maxwidth300', 1);
$morehtmlright .= '<div class="wpeo-button button-primary button-square-30 select-dataset-dashboard-info" style="color: white !important;"><i class="button-icon fas fa-redo"></i></div>';

print load_fiche_titre($title . ' ' . $modDoliSIRH->version, $morehtmlright, 'dolisirh_red.png@dolisirh');

if ($conf->global->DOLISIRH_HR_PROJECT_SET == 0) : ?>
<div class="wpeo-notice notice-info">
<div class="notice-content">
<div class="notice-title"><strong><?php echo $langs->trans('SetupDefaultDataNotCreated'); ?></strong></div>
<div class="notice-subtitle"><strong><?php echo $langs->trans('HowToSetupDefaultData') . ' ' ?><a href="admin/setup.php"><?php echo $langs->trans('ConfigDefaultData'); ?></a></strong></div>
</div>
</div>
<?php endif;

require_once __DIR__ . '/../saturne/core/tpl/index/index_view.tpl.php';

0 comments on commit abdf291

Please sign in to comment.