Skip to content

Commit

Permalink
#2503 [Hook] add: tooltip info on nb_employees/nb_workedhours conf
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolas-eoxia committed Oct 5, 2022
1 parent 98c6822 commit ff37426
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 27 deletions.
2 changes: 1 addition & 1 deletion admin/setup.php
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@
print $langs->trans('ManuelInputNBEmployeesDescription');
print '</td>';
print '<td class="center">';
print ajax_constantonoff('DIGIRISKDOLIBARR_MANUEL_INPUT_NB_EMPLOYEES');
print ajax_constantonoff('DIGIRISKDOLIBARR_MANUAL_INPUT_NB_EMPLOYEES');
print '</td>';
print '</tr>';

Expand Down
2 changes: 1 addition & 1 deletion class/accident.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,7 @@ public function load_dashboard()
'label' => array($langs->transnoentities("FrequencyIndex"), $langs->transnoentities("FrequencyRate"), $langs->transnoentities("GravityRate")),
'content' => array($arrayFrequencyIndex['frequencyindex'], $arrayFrequencyRate['frequencyrate'], $arrayGravityRate['gravityrate']),
'tooltip' => array(
(($conf->global->DIGIRISKDOLIBARR_NB_EMPLOYEES > 0 && $conf->global->DIGIRISKDOLIBARR_MANUEL_INPUT_NB_EMPLOYEES) ? $langs->transnoentities("FrequencyIndexTooltip") . '<br>' . $langs->transnoentities("NbEmployeesConfTooltip") : $langs->transnoentities("FrequencyIndexTooltip")),
(($conf->global->DIGIRISKDOLIBARR_NB_EMPLOYEES > 0 && $conf->global->DIGIRISKDOLIBARR_MANUAL_INPUT_NB_EMPLOYEES) ? $langs->transnoentities("FrequencyIndexTooltip") . '<br>' . $langs->transnoentities("NbEmployeesConfTooltip") : $langs->transnoentities("FrequencyIndexTooltip")),
(($conf->global->DIGIRISKDOLIBARR_NB_WORKED_HOURS > 0 && $conf->global->DIGIRISKDOLIBARR_MANUAL_INPUT_NB_WORKED_HOURS) ? $langs->transnoentities("FrequencyRateTooltip") . '<br>' . $langs->transnoentities("NbWorkedHoursTooltip") : $langs->transnoentities("FrequencyRateTooltip")),
(($conf->global->DIGIRISKDOLIBARR_NB_WORKED_HOURS > 0 && $conf->global->DIGIRISKDOLIBARR_MANUAL_INPUT_NB_WORKED_HOURS) ? $langs->transnoentities("GravityRateTooltip") . '<br>' . $langs->transnoentities("NbWorkedHoursTooltip") : $langs->transnoentities("GravityRateTooltip"))
),
Expand Down
32 changes: 10 additions & 22 deletions class/actions_digiriskdolibarr.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public function __construct($db)
*/
public function printCommonFooter($parameters)
{
global $db, $conf, $langs;
global $conf, $db, $form, $langs;

/* print_r($parameters); print_r($object); echo "action: " . $action; */
if ($parameters['currentcontext'] == 'admincompany') { // do something only for the context 'somecontext1' or 'somecontext2'
Expand All @@ -84,12 +84,8 @@ public function printCommonFooter($parameters)
$idcc_form = digirisk_select_dictionary('DIGIRISKDOLIBARR_COLLECTIVE_AGREEMENT_TITLE', 'c_conventions_collectives', 'code', 'libelle', $conf->global->DIGIRISKDOLIBARR_COLLECTIVE_AGREEMENT_TITLE, 1, '', '', 'minwidth100');
$pee_input = '<input type="checkbox" name="DIGIRISKDOLIBARR_PEE_ENABLED" '. ($conf->global->DIGIRISKDOLIBARR_PEE_ENABLED ? 'checked' : '') .'>';
$perco_input = '<input type="checkbox" name="DIGIRISKDOLIBARR_PERCO_ENABLED" '. ($conf->global->DIGIRISKDOLIBARR_PERCO_ENABLED ? 'checked' : '') .'>';
if ($conf->global->DIGIRISKDOLIBARR_MANUEL_INPUT_NB_EMPLOYEES) {
$nbemployees_input = '<input type="number" name="DIGIRISKDOLIBARR_NB_EMPLOYEES" class="minwidth200" value="' . $conf->global->DIGIRISKDOLIBARR_NB_EMPLOYEES . '">';
}
if ($conf->global->DIGIRISKDOLIBARR_MANUAL_INPUT_NB_WORKED_HOURS) {
$nbworkedhours_input = '<input type="number" name="DIGIRISKDOLIBARR_NB_WORKED_HOURS" class="minwidth200" value="' . $conf->global->DIGIRISKDOLIBARR_NB_WORKED_HOURS . '">';
}
$nbemployees_input = '<input type="number" name="DIGIRISKDOLIBARR_NB_EMPLOYEES" class="minwidth200" value="' . $conf->global->DIGIRISKDOLIBARR_NB_EMPLOYEES . '"' . ($conf->global->DIGIRISKDOLIBARR_MANUAL_INPUT_NB_EMPLOYEES ? '' : 'disabled') . '>';
$nbworkedhours_input = '<input type="number" name="DIGIRISKDOLIBARR_NB_WORKED_HOURS" class="minwidth200" value="' . $conf->global->DIGIRISKDOLIBARR_NB_WORKED_HOURS . '"' . ($conf->global->DIGIRISKDOLIBARR_MANUAL_INPUT_NB_WORKED_HOURS ? '' : 'disabled') . '>';
?>
<script>
let collectiveAgreementDictionary = $('<tr class="oddeven"><td><label for="selectidcc_id"><?php print $pictoDigirisk . $form->textwithpicto($langs->trans('IDCC'), $langs->trans('IDCCTooltip'));?></label></td>');
Expand All @@ -101,23 +97,15 @@ public function printCommonFooter($parameters)
let percoInput = $('<tr class="oddeven"><td><label for="perco"><?php print $pictoDigirisk . $form->textwithpicto($langs->trans('PERCO'), $langs->trans('PERCOTooltip'));?></label></td>');
percoInput.append('<td>' + <?php echo json_encode($perco_input) ; ?> + '</td></tr>');

<?php if ($conf->global->DIGIRISKDOLIBARR_MANUEL_INPUT_NB_EMPLOYEES) : ?>
let nbemployeesInput = $('<tr class="oddeven"><td><label for="nbemployees"><?php print $pictoDigirisk . $langs->transnoentities('NbEmployees'); ?></label></td>');
nbemployeesInput.append('<td><i class="fas fa-users"></i> ' + <?php echo json_encode($nbemployees_input); ?> + '</td></tr>');
<?php endif; ?>
let nbemployeesInput = $('<tr class="oddeven"><td><label for="nbemployees"><?php print $pictoDigirisk . $form->textwithpicto($langs->transnoentities('NbEmployees'), $langs->transnoentities('HowToConfigureSetupConf')); ?></label></td>');
nbemployeesInput.append('<td><i class="fas fa-users"></i> ' + <?php echo json_encode($nbemployees_input); ?> + '</td></tr>');

<?php if ($conf->global->DIGIRISKDOLIBARR_MANUAL_INPUT_NB_WORKED_HOURS) : ?>
let nbworkedhoursInput = $('<tr class="oddeven"><td><label for="nbworkedhours"><?php print $pictoDigirisk . $langs->transnoentities('NbWorkedHours'); ?></label></td>');
nbworkedhoursInput.append('<td><i class="fas fa-clock"></i> ' + <?php echo json_encode($nbworkedhours_input); ?> + '</td></tr>');
<?php endif; ?>
let nbworkedhoursInput = $('<tr class="oddeven"><td><label for="nbworkedhours"><?php print $pictoDigirisk . $form->textwithpicto($langs->transnoentities('NbWorkedHours'), $langs->transnoentities('HowToConfigureSetupConf')); ?></label></td>');
nbworkedhoursInput.append('<td><i class="fas fa-clock"></i> ' + <?php echo json_encode($nbworkedhours_input); ?> + '</td></tr>');

let currentOtherElement = $('table:nth-child(3) .oddeven:last-child');
<?php if ($conf->global->DIGIRISKDOLIBARR_MANUAL_INPUT_NB_WORKED_HOURS) : ?>
currentOtherElement.after(nbworkedhoursInput);
<?php endif; ?>
<?php if ($conf->global->DIGIRISKDOLIBARR_MANUEL_INPUT_NB_EMPLOYEES) : ?>
currentOtherElement.after(nbemployeesInput);
<?php endif; ?>
currentOtherElement.after(nbworkedhoursInput);
currentOtherElement.after(nbemployeesInput);

let currentElement = $('table:nth-child(7) .oddeven:last-child');
currentElement.after(collectiveAgreementDictionary);
Expand Down Expand Up @@ -453,7 +441,7 @@ public function doActions($parameters, $object, $action)
dolibarr_set_const($db, "DIGIRISKDOLIBARR_COLLECTIVE_AGREEMENT_TITLE", GETPOST("DIGIRISKDOLIBARR_COLLECTIVE_AGREEMENT_TITLE", 'nohtml'), 'chaine', 0, '', $conf->entity);
dolibarr_set_const($db, "DIGIRISKDOLIBARR_PEE_ENABLED", GETPOST("DIGIRISKDOLIBARR_PEE_ENABLED") == 'on' ? 1 : 0, 'integer', 0, '', $conf->entity);
dolibarr_set_const($db, "DIGIRISKDOLIBARR_PERCO_ENABLED", GETPOST("DIGIRISKDOLIBARR_PERCO_ENABLED") == 'on' ? 1 : 0, 'integer', 0, '', $conf->entity);
if ($conf->global->DIGIRISKDOLIBARR_MANUEL_INPUT_NB_EMPLOYEES) {
if ($conf->global->DIGIRISKDOLIBARR_MANUAL_INPUT_NB_EMPLOYEES) {
dolibarr_set_const($db, "DIGIRISKDOLIBARR_NB_EMPLOYEES", GETPOST("DIGIRISKDOLIBARR_NB_EMPLOYEES"), 'integer', 0, '', $conf->entity);
}
if ($conf->global->DIGIRISKDOLIBARR_MANUAL_INPUT_NB_WORKED_HOURS) {
Expand Down
4 changes: 2 additions & 2 deletions class/evaluator.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ public function load_dashboard()
DashboardDigiriskStats::DASHBOARD_EVALUATOR => array(
'label' => array($langs->transnoentities("NbEmployeesInvolved"), $langs->transnoentities("NbEmployees")),
'content' => array($arrayNbEmployeesInvolved['nbemployeesinvolved'], $arrayNbEmployees['nbemployees']),
'tooltip' => array($langs->transnoentities("NbEmployeesInvolvedTooltip"), (($conf->global->DIGIRISKDOLIBARR_NB_EMPLOYEES > 0 && $conf->global->DIGIRISKDOLIBARR_MANUEL_INPUT_NB_EMPLOYEES) ? $langs->transnoentities("NbEmployeesConfTooltip") : $langs->transnoentities("NbEmployeesTooltip"))),
'tooltip' => array($langs->transnoentities("NbEmployeesInvolvedTooltip"), (($conf->global->DIGIRISKDOLIBARR_NB_EMPLOYEES > 0 && $conf->global->DIGIRISKDOLIBARR_MANUAL_INPUT_NB_EMPLOYEES) ? $langs->transnoentities("NbEmployeesConfTooltip") : $langs->transnoentities("NbEmployeesTooltip"))),
'picto' => 'fas fa-user-check',
'widgetName' => $langs->transnoentities('Evaluator')
)
Expand Down Expand Up @@ -382,7 +382,7 @@ public function getNbEmployees() {
global $conf;

// Number employees
if ($conf->global->DIGIRISKDOLIBARR_NB_EMPLOYEES > 0 && $conf->global->DIGIRISKDOLIBARR_MANUEL_INPUT_NB_EMPLOYEES) {
if ($conf->global->DIGIRISKDOLIBARR_NB_EMPLOYEES > 0 && $conf->global->DIGIRISKDOLIBARR_MANUAL_INPUT_NB_EMPLOYEES) {
$array['nbemployees'] = $conf->global->DIGIRISKDOLIBARR_NB_EMPLOYEES;
} else {
$user = new User($this->db);
Expand Down
2 changes: 1 addition & 1 deletion core/modules/modDigiriskDolibarr.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -667,7 +667,7 @@ public function __construct($db)
282 => array('DIGIRISKDOLIBARR_MEDIA_MAX_WIDTH_LARGE', 'integer', 1280, '', 0, 'current'),
283 => array('DIGIRISKDOLIBARR_MEDIA_MAX_HEIGHT_LARGE', 'integer', 720, '', 0, 'current'),
284 => array('DIGIRISKDOLIBARR_CUSTOM_DOCUMENTS_SET', 'integer', 0, '', 0, 'current'),
285 => array('DIGIRISKDOLIBARR_MANUEL_INPUT_NB_EMPLOYEES', 'integer', 0, '', 0, 'current'),
285 => array('DIGIRISKDOLIBARR_MANUAL_INPUT_NB_EMPLOYEES', 'integer', 0, '', 0, 'current'),
286 => array('DIGIRISKDOLIBARR_MANUAL_INPUT_NB_WORKED_HOURS', 'integer', 0, '', 0, 'current'),

//CONST TICKET & REGISTERS
Expand Down
1 change: 1 addition & 0 deletions langs/fr_FR/digiriskdolibarr.lang
Original file line number Diff line number Diff line change
Expand Up @@ -1595,3 +1595,4 @@ ManuelInputNBEmployees = Saisir manuellement le nombre de salariés
ManuelInputNBEmployeesDescription = Si l'option est activée, vous pouvez saisir manuellement le nombre de salariés dans la configuration de la société.<br>Sinon le nombre de salariés est calculé.<br>Consulter la documentation pour plus d'informations.
ManuelInputNBWorkedHours = Saisir manuellement le nombre d'heures travaillées
ManuelInputNBWorkedHoursDescription = Si l'option est activée, vous pouvez saisir manuellement le nombre d'heures travaillées dans la configuration de la société.<br>Sinon le nombre d'heures travaillées est calculé.<br>Consulter la documentation pour plus d'informations.
HowToConfigureSetupConf = Pour configurer les donnés de la société lié à Digirisk,<br>veuillez vous rendre sur Digirisk - Configuration - Réglages

0 comments on commit ff37426

Please sign in to comment.