Skip to content
This repository has been archived by the owner on Jul 22, 2022. It is now read-only.

Commit

Permalink
type d'absence optionnel (#894)
Browse files Browse the repository at this point in the history
* désactivation des types de congé individuellement

* formulaire desactivation
  • Loading branch information
wouldsmina authored Jul 6, 2020
1 parent 4174850 commit 82b25ea
Show file tree
Hide file tree
Showing 20 changed files with 94 additions and 108 deletions.
5 changes: 0 additions & 5 deletions App/Libraries/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -359,11 +359,6 @@ public function canGrandResponsableAjouteConge()
return $this->getGroupeFonctionnementEtablissementValeur('grand_resp_ajout_conges');
}

public function isCongesExceptionnelsActive()
{
return $this->getGroupeFonctionnementEtablissementValeur('gestion_conges_exceptionnels');
}

public function canSoldeNegatif()
{
return !$this->getGroupeFonctionnementEtablissementValeur('solde_toujours_positif');
Expand Down
6 changes: 5 additions & 1 deletion App/Patchs/Maj/1.14.2.sql
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
ALTER TABLE `conges_solde_user` ADD UNIQUE( `su_login`, `su_abs_id`);
# Création champ option type absence
ALTER TABLE `conges_type_absence` ADD `ta_actif` TINYINT(1) NOT NULL DEFAULT '1';
# Retrait option globale congés exceptionnels
DELETE FROM `conges_config` WHERE `conf_nom` = 'gestion_conges_exceptionnels';
ALTER TABLE `conges_solde_user` ADD UNIQUE( `su_login`, `su_abs_id`);
5 changes: 3 additions & 2 deletions App/ProtoControllers/Conge.php
Original file line number Diff line number Diff line change
Expand Up @@ -306,9 +306,10 @@ public static function getTypesAbsences(\includes\SQL $sql, $type = null)
{
$typesConges = [];
$req = 'SELECT ta_id, ta_libelle, ta_type
FROM conges_type_absence';
FROM conges_type_absence
WHERE ta_actif = 1';
if (null != $type) {
$req .= ' WHERE ta_type=\'' . $type . '\'';
$req .= ' AND ta_type=\'' . $type . '\'';
}
$data = $sql->query($req);

Expand Down
2 changes: 1 addition & 1 deletion App/ProtoControllers/HautResponsable/ClotureExercice.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public static function traitementClotureEmploye($employes, $typeConges, &$error,
private static function updateSoldesEmploye($employe, $typeConges, $comment, \includes\SQL $sql, \App\Libraries\Configuration $config)
{
$return = true;
$soldesEmploye = \App\ProtoControllers\Utilisateur::getSoldesEmploye($sql, $config, $employe);
$soldesEmploye = \App\ProtoControllers\Utilisateur::getSoldesEmploye($sql, $employe);
if (!empty($soldesEmploye)) {
foreach ($typeConges as $idType => $libelle) {
$soldeRestant = $soldesEmploye[$idType]['su_solde'];
Expand Down
33 changes: 15 additions & 18 deletions App/ProtoControllers/HautResponsable/Utilisateur.php
Original file line number Diff line number Diff line change
Expand Up @@ -191,10 +191,9 @@ public static function getFormUser($userId = NIL_INT)
private static function getFormUserSoldes($data, $userId)
{
$sql = \includes\SQL::singleton();
$config = new \App\Libraries\Configuration($sql);
$typeAbsencesConges = \App\ProtoControllers\Conge::getTypesAbsences($sql, 'conges');
if (NIL_INT !== $userId) {
$soldesByType = \App\ProtoControllers\Utilisateur::getSoldesEmploye($sql, $config, $userId);
$soldesByType = \App\ProtoControllers\Utilisateur::getSoldesEmploye($sql, $userId);
foreach ($soldesByType as $typeId => $infos) {
$data['joursAn'][$typeId] = $infos['su_nb_an'];
$data['soldes'][$typeId] = $infos['su_solde'];
Expand Down Expand Up @@ -235,8 +234,8 @@ private static function getFormUserSoldes($data, $userId)
$childTable .= '</tr>';
$i = !$i;
}
if ($config->isCongesExceptionnelsActive()) {
$typeAbsencesExceptionnels = \App\ProtoControllers\Conge::getTypesAbsences($sql, 'conges_exceptionnels');
$typeAbsencesExceptionnels = \App\ProtoControllers\Conge::getTypesAbsences($sql, 'conges_exceptionnels');
if(!empty($typeAbsencesExceptionnels)){
foreach ($typeAbsencesExceptionnels as $typeId => $infoType) {
$childTable .= '<tr class="'.($i?'i':'p').'">';
$solde = ( isset($data['soldes'][$typeId]) ? $data['soldes'][$typeId] : 0 );
Expand Down Expand Up @@ -737,20 +736,18 @@ private static function updateSoldeUtilisateur($data, \includes\SQL $sql)
$returnStd = $sql->query($req);

$returnExc = true;
if ($config->isCongesExceptionnelsActive()) {
$typeAbsencesExceptionnels = \App\ProtoControllers\Conge::getTypesAbsences($sql, 'conges_exceptionnels');
if(empty($typeAbsencesExceptionnels)){
return $returnStd;
}
foreach ($typeAbsencesExceptionnels as $typeId => $info) {
$valuesExc[] = '(0, \''
. $data['soldes'][$typeId] . '\', 0, "'
. $data['oldLogin'] . '", '
. (int) $typeId . ')';
}
$req = 'REPLACE INTO conges_solde_user (su_nb_an, su_solde, su_reliquat, su_login, su_abs_id) VALUES ' . implode(",", $valuesExc);
$returnExc = $sql->query($req);
}
$typeAbsencesExceptionnels = \App\ProtoControllers\Conge::getTypesAbsences($sql, 'conges_exceptionnels');
if(empty($typeAbsencesExceptionnels)){
return $returnStd;
}
foreach ($typeAbsencesExceptionnels as $typeId => $info) {
$valuesExc[] = '(0, \''
. $data['soldes'][$typeId] . '\', 0, "'
. $data['oldLogin'] . '", '
. (int) $typeId . ')';
}
$req = 'REPLACE INTO conges_solde_user (su_nb_an, su_solde, su_reliquat, su_login, su_abs_id) VALUES ' . implode(",", $valuesExc);
$returnExc = $sql->query($req);

return $returnStd && $returnExc;
}
Expand Down
10 changes: 4 additions & 6 deletions App/ProtoControllers/Utilisateur.php
Original file line number Diff line number Diff line change
Expand Up @@ -248,17 +248,15 @@ public static function getSoldeconge($login, $typeId)
*
* @return array
*/
public static function getSoldesEmploye(\includes\SQL $sql, \App\Libraries\Configuration $config, $login)
public static function getSoldesEmploye(\includes\SQL $sql, $login)
{
$soldes = [];
$req = 'SELECT ta_id, ta_libelle, su_nb_an, su_solde, su_reliquat
FROM conges_solde_user, conges_type_absence
WHERE conges_type_absence.ta_id = conges_solde_user.su_abs_id
AND su_login = "' . $login . '" ';
if (!$config->isCongesExceptionnelsActive()) {
$req .= 'AND conges_type_absence.ta_type != \'conges_exceptionnels\'';
}
$req .= 'ORDER BY su_abs_id ASC;';
AND su_login = "' . $login . '"
AND conges_type_absence.ta_actif = 1
ORDER BY su_abs_id ASC;';
$res = $sql->query($req);

while ($infos = $res->fetch_assoc()) {
Expand Down
5 changes: 0 additions & 5 deletions App/Views/Configuration/Type_Absence/Liste.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
* $nouveauType
* $traductions
* $url
* $isCongesExceptionnelsActive
* $classesConges
*/
?>
Expand Down Expand Up @@ -80,7 +79,6 @@
nouveauLibelleCourt : '<?= $nouveauLibelleCourt ?>',
nouveauType : '<?= $nouveauType ?>',
traductions : <?= json_encode($traductions) ?>,
isCongesExceptionnelsActive: 'true' == "<?= $isCongesExceptionnelsActive ? 'true' : 'false' ?>",
axios : instance,
classesConges : <?= json_encode($classesConges) ?>
},
Expand Down Expand Up @@ -123,9 +121,6 @@ classesConges : <?= json_encode($classesConges) ?>
}
organisedTypes[absenceType.type].push(absenceType);
}
if (!vm.isCongesExceptionnelsActive && undefined != organisedTypes['conges_exceptionnels']) {
delete organisedTypes['conges_exceptionnels'];
}

// Finally hide loader and show var
document.getElementById('loader-bar').classList.add('hidden');
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"jasig/phpcas": "1.3.8",
"yohang/calendr": "^2.0",
"guzzlehttp/guzzle": "6.5.2",
"libertempo/api": "1.9.0",
"libertempo/api": "1.10.0",
"rollbar/rollbar": "1.8.1"
},
"require-dev": {
Expand Down
5 changes: 3 additions & 2 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 28 additions & 1 deletion config/Fonctions.php
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,26 @@ public static function commit_suppr($id_to_update)
return $return;
}

public static function commit_desac($id)
{
$PHP_SELF = filter_input(INPUT_SERVER, 'REQUEST_URI', FILTER_SANITIZE_URL);
$return = '';

$URL = $PHP_SELF;

// delete dans la table conges_type_absence
$req='UPDATE FROM conges_type_absence set ta_actif = 0 WHERE ta_id='. \includes\SQL::quote($id);
\includes\SQL::query($req);

$return .= '<span class="messages">' . _('form_modif_ok') . '</span><br>';

$comment_log = "config : desactivation type absence ($id) ";
log_action(0, "", "", $comment_log);
$return .= '<META HTTP-EQUIV=REFRESH CONTENT="2; URL=' . $URL . '">';

return $return;
}

public static function supprimer($id_to_update)
{
$PHP_SELF = filter_var($_SERVER['REQUEST_URI'], FILTER_SANITIZE_URL);
Expand Down Expand Up @@ -461,8 +481,15 @@ public static function supprimer($id_to_update)

$return .= '<br>';
$return .= '<form action="' . $URL . '" method="POST">';
$return .= '<input type="submit" value="' . _('form_redo') . '" >';
$return .= '<input type="submit" value="' . _('form_annul') . '" >';
$return .= '</form>';
if ($absenceType['typeActif']) {
$return .= '<form action="' . $URL . '" method="POST">';
$return .= '<input type="hidden" name="action" value="commit_desac">';
$return .= '<input type="hidden" name="id_to_update" value="' . $id_to_update . '">';
$return .= '<input type="submit" value="' . _('form_desactive') . '" >';
$return .= '</form>';
}
$return .= '<br><br>';
$return .= '</center>';
} else {
Expand Down
6 changes: 4 additions & 2 deletions config/config_type_absence.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,12 @@
case 'commit_suppr':
echo \config\Fonctions::commit_suppr($id_to_update);
break;
case 'commit_desac':
echo \config\Fonctions::commit_desac($id_to_update);
break;
default:
$sql = \includes\SQL::singleton();
$config = new \App\Libraries\Configuration($sql);
$isCongesExceptionnelsActive = $config->isCongesExceptionnelsActive();
$titres = [
'conges' => _('divers_conges_maj_1'),
'absences' => _('divers_absences_maj_1'),
Expand All @@ -54,7 +56,7 @@
'commentaires' => $comments,
];
$offsetCongesExceptionnels = array_search('conges_exceptionnels', $classesConges);
if (!$isCongesExceptionnelsActive && is_int($offsetCongesExceptionnels)) {
if (is_int($offsetCongesExceptionnels)) {
unset($classesConges[$offsetCongesExceptionnels]);
}
$url = $PHP_SELF;
Expand Down
14 changes: 2 additions & 12 deletions edition/Fonctions.php
Original file line number Diff line number Diff line change
Expand Up @@ -297,11 +297,7 @@ private static function edition_papier($login, $edit_id)
// recup du tableau des types de conges exceptionnels (seulement les conge sexceptionnels )
$tab_type_cong=recup_tableau_types_conges();
// recup du tableau des types de conges (seulement les conges)
if ($config->isCongesExceptionnelsActive()) {
$tab_type_conges_exceptionnels=recup_tableau_types_conges_exceptionnels();
} else {
$tab_type_conges_exceptionnels=array();
}
$tab_type_conges_exceptionnels=recup_tableau_types_conges_exceptionnels();
// recup du tableau de tous les types de conges
$tab_type_all_cong=recup_tableau_tout_types_abs();

Expand Down Expand Up @@ -835,11 +831,7 @@ private static function edition_pdf($login, $edit_id)
// recup du tableau des types de conges (seulement les conges)
$tab_type_cong=recup_tableau_types_conges();
// recup du tableau des types de conges exceptionnels (seulement les conges exceptionnels)
if ($config->isCongesExceptionnelsActive()) {
$tab_type_conges_exceptionnels=recup_tableau_types_conges_exceptionnels();
} else {
$tab_type_conges_exceptionnels = [];
}
$tab_type_conges_exceptionnels=recup_tableau_types_conges_exceptionnels();
// recup du tableau de tous les types de conges
$tab_type_all_cong=recup_tableau_tout_types_abs();

Expand Down Expand Up @@ -1182,7 +1174,6 @@ private static function enregistrement_edition($login)
SET se_id_edition=$new_edition_id, se_id_absence=$id_abs, se_solde=$tab_solde_user[$id_abs] ";
$result_insert_2 = \includes\SQL::query($sql_insert_2);
}
if ($config->isCongesExceptionnelsActive()) {
$tab_type_conges_exceptionnels=recup_tableau_types_conges_exceptionnels();
foreach ($tab_type_conges_exceptionnels as $id_abs => $libelle) {
if (!isset($tab_solde_user[$id_abs])) {
Expand All @@ -1191,7 +1182,6 @@ private static function enregistrement_edition($login)
$sql_insert_3 = "INSERT INTO conges_solde_edition SET se_id_edition=$new_edition_id, se_id_absence=$id_abs, se_solde=$tab_solde_user[$id_abs] ";
$result_insert_3 = \includes\SQL::query($sql_insert_3);
}
}

/********************************************************************************************/
/* Update du num edition dans la table periode pour les Conges et demandes de cette edition */
Expand Down
5 changes: 1 addition & 4 deletions hr/Fonctions.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,7 @@ private static function affiche_all_demandes_en_cours($tab_type_conges) : string
$count1=0;
$count2=0;

$typeAbsence = \App\ProtoControllers\Conge::getTypesAbsences($db, 'conges');
if ($config->isCongesExceptionnelsActive()) {
$typeAbsence += \App\ProtoControllers\Conge::getTypesAbsences($db, 'conges_exceptionnels');
}
$typeAbsence = \App\ProtoControllers\Conge::getTypesAbsences($db);

/*********************************/
// Récupération des informations
Expand Down
6 changes: 1 addition & 5 deletions hr/hr_ajout_conges.php
Original file line number Diff line number Diff line change
Expand Up @@ -208,11 +208,7 @@ function get_list_groupes_pour_rh() : string
$PHP_SELF = filter_var($_SERVER['REQUEST_URI'], FILTER_SANITIZE_URL);

// recup du tableau des types de conges (seulement les congesexceptionnels )
if ($config->isCongesExceptionnelsActive()) {
$tab_type_conges_exceptionnels = recup_tableau_types_conges_exceptionnels();
} else {
$tab_type_conges_exceptionnels = [];
}
$tab_type_conges_exceptionnels = recup_tableau_types_conges_exceptionnels();

// recup de la liste de TOUS les users pour le RH
// (prend en compte le resp direct, les groupes, le resp virtuel, etc ...)
Expand Down
21 changes: 9 additions & 12 deletions hr/hr_ajout_user.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,8 @@
$optLdap = 'onkeyup="searchLdapUser()" autocomplete="off"';
}

if ($config->isCongesExceptionnelsActive()) {
$typeAbsencesExceptionnels = \App\ProtoControllers\Conge::getTypesAbsences($sql, 'conges_exceptionnels');
}
$typeAbsencesExceptionnels = \App\ProtoControllers\Conge::getTypesAbsences($sql, 'conges_exceptionnels');

/**
* Nettoyage des données postés par le formulaire
*
Expand Down Expand Up @@ -203,17 +202,15 @@ function insertSoldeUtilisateur(array $data, \includes\SQL $sql) : bool
$req = "INSERT INTO conges_solde_user (su_id, su_login, su_abs_id, su_nb_an, su_solde, su_reliquat) VALUES " . implode(",", $valuesStd);
$returnStd = $sql->query($req);
$returnExc = 1;
if ($config->isCongesExceptionnelsActive()) {
$typeAbsencesExceptionnels = \App\ProtoControllers\Conge::getTypesAbsences($sql, 'conges_exceptionnels');
foreach ($typeAbsencesExceptionnels as $typeId => $info) {
$valuesExc[] = "(DEFAULT, '" . $data['login'] . "' ,"
. $typeId . ", 0, "
. $data['soldes'][$typeId] . ", 0)" ;
$typeAbsencesExceptionnels = \App\ProtoControllers\Conge::getTypesAbsences($sql, 'conges_exceptionnels');
foreach ($typeAbsencesExceptionnels as $typeId => $info) {
$valuesExc[] = "(DEFAULT, '" . $data['login'] . "' ,"
. $typeId . ", 0, "
. $data['soldes'][$typeId] . ", 0)" ;

}
$req = "INSERT INTO conges_solde_user (su_id, su_login, su_abs_id, su_nb_an, su_solde, su_reliquat) VALUES " . implode(",", $valuesExc);
$returnExc = $sql->query($req);
}
$req = "INSERT INTO conges_solde_user (su_id, su_login, su_abs_id, su_nb_an, su_solde, su_reliquat) VALUES " . implode(",", $valuesExc);
$returnExc = $sql->query($req);

return $returnStd && $returnExc;
}
Expand Down
8 changes: 2 additions & 6 deletions hr/hr_page_principale.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,7 @@
$titre = _('admin_onglet_gestion_user');

$typeAbsencesConges = \App\ProtoControllers\Conge::getTypesAbsences($sql, 'conges');
$typeAbsencesExceptionnels = [];

if ($config->isCongesExceptionnelsActive()) {
$typeAbsencesExceptionnels = \App\ProtoControllers\Conge::getTypesAbsences($sql, 'conges_exceptionnels');
}
$typeAbsencesExceptionnels = \App\ProtoControllers\Conge::getTypesAbsences($sql, 'conges_exceptionnels');

$infoUsers = \App\ProtoControllers\Utilisateur::getDonneesTousUtilisateurs($config);
asort($infoUsers);
Expand All @@ -57,7 +53,7 @@

$infoUsers[$login]['rights'] = $rights;
$infoUsers[$login]['responsables'] = \App\ProtoControllers\Responsable::getResponsablesUtilisateur($login);
$infoUsers[$login]['soldes'] = \App\ProtoControllers\Utilisateur::getSoldesEmploye($sql, $config, $login);
$infoUsers[$login]['soldes'] = \App\ProtoControllers\Utilisateur::getSoldesEmploye($sql, $login);
}

/**
Expand Down
Loading

0 comments on commit 82b25ea

Please sign in to comment.