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

Commit

Permalink
Merge branch 'develop' into beta
Browse files Browse the repository at this point in the history
  • Loading branch information
wouldsmina committed Apr 5, 2017
2 parents f6dfd8d + c703e7f commit 57446cd
Show file tree
Hide file tree
Showing 23 changed files with 308 additions and 218 deletions.
2 changes: 1 addition & 1 deletion App/Helpers/Formatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public static function timestamp2Duree($timestamp)
$heures = abs($timestamp/3600);
$duree = sprintf('%02d:%02d', $heures, $secondes);

return (0 < $timestamp)
return (0 <= $timestamp)
? $duree
: '-' . $duree
;
Expand Down
4 changes: 3 additions & 1 deletion App/ProtoControllers/Employe/AHeure.php
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,9 @@ protected function transformChampsRecherche(array $post)
$champs['timestampDebut'] = \utilisateur\Fonctions::getTimestampPremierJourAnnee($value);
$champs['timestampFin'] = \utilisateur\Fonctions::getTimestampDernierJourAnnee($value);
} else {
$champs[$key] = (int) $value;
if ($value !== "all") { // si la valeur est différent de "all" le paramètres est passé au champ pour la futur requête sql
$champs[$key] = (int) $value;
}
}
}

Expand Down
107 changes: 53 additions & 54 deletions App/ProtoControllers/Employe/Conge.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ class Conge
public function getListe()
{
$return = '';
$errorsLst=[];
if($_SESSION['config']['where_to_find_user_email']=="ldap"){
include_once CONFIG_PATH .'config_ldap.php';
$errorsLst = [];
if ($_SESSION['config']['where_to_find_user_email'] == "ldap") {
include_once CONFIG_PATH . 'config_ldap.php';
}

if(!empty($_POST) && !$this->isSearch($_POST)) {
if (!empty($_POST) && !$this->isSearch($_POST)) {
if (0 < (int) \utilisateur\Fonctions::postDemandeCongesHeure($_POST, $errorsLst)) {
$return .= '<div class="alert alert-info">'._('suppr_succes').'</div>';
$return .= '<div class="alert alert-info">' . _('suppr_succes') . '</div>';
}
}
// on initialise le tableau global des jours fériés s'il ne l'est pas déjà :
Expand All @@ -38,20 +38,15 @@ public function getListe()

if (!empty($_POST) && $this->isSearch($_POST)) {
$champsRecherche = $_POST['search'];
$champsSql = $this->transformChampsRecherche($_POST);
$champsSql = $this->transformChampsRecherche($_POST);
} else {
$champsRecherche = [
'type' => 'cp',
];
$champsSql = [];
$champsRecherche = [];
$champsSql = [];
}
$params = $champsSql + [
'p_login' => $_SESSION['userlogin'],
'type' => 'cp',
'p_etat' => 'demande',
]; // champs par défaut écrasés par postés

$return.= $this->getFormulaireRecherche($champsRecherche);
]; // champs par défaut écrasés par posté
$return .= $this->getFormulaireRecherche($champsRecherche);

$table = new \App\Libraries\Structure\Table();
$table->addClasses([
Expand All @@ -61,14 +56,14 @@ public function getListe()
'table-condensed',
'table-striped',
]);
$childTable = '<thead><tr><th>' . _('divers_debut_maj_1') . '</th><th>'. _('divers_fin_maj_1') .'</th><th>'. _('divers_type_maj_1') .'</th><th>'. _('divers_nb_jours_pris_maj_1') .'</th><th>Statut</th><th></th><th></th>';
$childTable = '<thead><tr><th>' . _('divers_debut_maj_1') . '</th><th>' . _('divers_fin_maj_1') . '</th><th>' . _('divers_type_maj_1') . '</th><th>' . _('divers_nb_jours_pris_maj_1') . '</th><th>Statut</th><th></th><th></th>';
$childTable .= '</tr>';
$childTable .= '</thead><tbody>';
$listId = $this->getListeId($params);
$session = session_id();
if (empty($listId)) {
$colonnes = 8;
$childTable .= '<tr><td colspan="' . $colonnes . '"><center>' . _('aucun_resultat') .'</center></td></tr>';
$childTable .= '<tr><td colspan="' . $colonnes . '"><center>' . _('aucun_resultat') . '</center></td></tr>';
} else {
$i = true;
$listeConges = $this->getListeSQL($listId);
Expand All @@ -83,7 +78,7 @@ public function getListe()
list($date, $heure) = explode(' ', $conges["p_date_demande"]);
$dateDemande = '(' . \App\Helpers\Formatter::dateIso2Fr($date) . ' ' . $heure . ') ';
}
if(null != $conges["p_date_traitement"]) {
if (null != $conges["p_date_traitement"]) {
list($date, $heure) = explode(' ', $conges["p_date_traitement"]);
$dateReponse = '(' . \App\Helpers\Formatter::dateIso2Fr($date) . ' ' . $heure . ') ';
}
Expand All @@ -101,38 +96,39 @@ public function getListe()
$messageReponse = '';
}

$demi_j_deb = ($conges["p_demi_jour_deb"]=="am") ? 'matin' : 'après-midi';
$demi_j_deb = ($conges["p_demi_jour_deb"] == "am") ? 'matin' : 'après-midi';
$demi_j_fin = ($conges["p_demi_jour_fin"] == "am") ? 'matin' : 'après-midi';

$demi_j_fin = ($conges["p_demi_jour_fin"] =="am") ? 'matin' : 'après-midi';
$childTable .= '<tr class="' . ($i ? 'i' : 'p') . '">';

$childTable .= '<tr class="'.($i?'i':'p').'">';
$childTable .= '<td class="histo">' . \App\Helpers\Formatter::dateIso2Fr($conges["p_date_deb"]) . ' <span class="demi">' . schars($demi_j_deb) . '</span></td>';
$childTable .= '<td class="histo">' . \App\Helpers\Formatter::dateIso2Fr($conges["p_date_fin"]) . ' <span class="demi">' . schars($demi_j_fin) . '</span></td>' ;
$childTable .= '<td class="histo">'.schars($conges["ta_libelle"]).'</td>' ;
$childTable .= '<td class="histo">'.affiche_decimal($conges["p_nb_jours"]).'</td>' ;
$childTable .= '<td class="histo">' . \App\Helpers\Formatter::dateIso2Fr($conges["p_date_fin"]) . ' <span class="demi">' . schars($demi_j_fin) . '</span></td>';
$childTable .= '<td class="histo">' . schars($conges["ta_libelle"]) . '</td>';
$childTable .= '<td class="histo">' . affiche_decimal($conges["p_nb_jours"]) . '</td>';
$childTable .= '<td>' . \App\Models\Conge::statusText($conges["p_etat"]) . '</td>';
$childTable .= '<td class="histo">';
if (!empty($messageDemande) || !empty($messageReponse)) {
$childTable .= '<i class="fa fa-comments" aria-hidden="true" title="' . $messageDemande . "\n\n" . $messageReponse . '"></i>';
}
$childTable .= '</td>' ;
$childTable .= '</td>';
$childTable .= '<td class="histo">';

$user_modif_demande = '<i class="fa fa-pencil disabled"></i>';
$user_suppr_demande = '<i class="fa fa-times-circle disabled"></i>';

// si on peut modifier une demande on defini le lien à afficher
if($conges["p_etat"] == \App\Models\Conge::STATUT_DEMANDE) {
if(!$interdictionModification){
$user_modif_demande = '<a href="user_index.php?session=' . $session . '&p_num=' . $conges['p_num'] . '&onglet=modif_demande"><i class="fa fa-pencil"></i></a>' ;
if ($conges["p_etat"] == \App\Models\Conge::STATUT_DEMANDE) {
if (!$interdictionModification) {
$user_modif_demande = '<a href="user_index.php?session=' . $session . '&p_num=' . $conges['p_num'] . '&onglet=modif_demande"><i class="fa fa-pencil"></i></a>';
}
$user_suppr_demande = '<a href="user_index.php?session=' . $session . '&p_num=' . $conges['p_num'] . '&onglet=suppr_demande"><i class="fa fa-times-circle"></i></a>';
}
if(!$interdictionModification) {

if (!$interdictionModification) {
$childTable .= $user_modif_demande . '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';

}
$childTable .= ($user_suppr_demande) . '</td>'."\n" ;
$childTable .= ($user_suppr_demande) . '</td>' . "\n";
$childTable .= '</tr>';
$i = !$i;
}
Expand Down Expand Up @@ -171,6 +167,7 @@ protected function getFormulaireRecherche(array $champs)
$form = '';
$form = '<form method="post" action="" class="form-inline search" role="form">';
$form .= '<div class="form-group"><label class="control-label col-md-4" for="statut">Statut&nbsp;:</label><div class="col-md-8"><select class="form-control" name="search[p_etat]" id="statut">';
$form .= '<option value="all">' . _('tous') . '</option>';
foreach (\App\Models\Conge::getOptionsStatuts() as $key => $value) {
$selected = (isset($champs['p_etat']) && $key == $champs['p_etat'])
? 'selected="selected"'
Expand All @@ -179,21 +176,22 @@ protected function getFormulaireRecherche(array $champs)
}
$form .= '</select></div></div>';
$form .= '<div class="form-group "><label class="control-label col-md-4" for="type">Type&nbsp;:</label><div class="col-md-8"><select class="form-control" name="search[type]" id="type">';
$form .= '<option value="all">' . _('tous') . '</option>';
foreach (\utilisateur\Fonctions::getOptionsTypeConges() as $key => $value) {
$selected = (isset($champs['type']) && $key == $champs['type'])
? 'selected="selected"'
: '';
? 'selected="selected"'
: '';
$form .= '<option value="' . $key . '" ' . $selected . '>' . $value . '</option>';
}
$form .= '</select></div></div>';
$form .= '<div class="form-group"><label class="control-label col-md-4" for="annee">Année&nbsp;:</label><div class="col-md-8"><select class="form-control" name="search[annee]" id="sel1">';
foreach (\utilisateur\Fonctions::getOptionsAnnees() as $key => $value) {
$selected = (isset($champs['annee']) && $key == $champs['annee'])
? 'selected="selected"'
: '';
? 'selected="selected"'
: '';
$form .= '<option value="' . $key . '" ' . $selected . '>' . $value . '</option>';
}
$form .= '</select></div></div><div class="form-group"><div class="input-group"><button type="submit" class="btn btn-default"><i class="fa fa-search" aria-hidden="true"></i></button>&nbsp;<a href="' . ROOT_PATH . 'utilisateur/user_index.php?session='. $session . '&onglet=liste_conge" type="reset" class="btn btn-default">Reset</a></div></div></form>';
$form .= '</select></div></div><div class="form-group"><div class="input-group"><button type="submit" class="btn btn-default"><i class="fa fa-search" aria-hidden="true"></i></button>&nbsp;<a href="' . ROOT_PATH . 'utilisateur/user_index.php?session=' . $session . '&onglet=liste_conge" type="reset" class="btn btn-default">Reset</a></div></div></form>';

return $form;
}
Expand All @@ -212,9 +210,12 @@ protected function transformChampsRecherche(array $post)
foreach ($search as $key => $value) {
if ('annee' === $key) {
$champs['dateDebut'] = ((int) $value) . '-01-01';
$champs['dateFin'] = ((int) $value) . '-12-31';
$champs['dateFin'] = ((int) $value) . '-12-31';
} else {
$champs[$key] = $value;
if ($value !== "all") {
// si la valeur est différent de tout le paramètres est passé au champ pour la futur requête sql
$champs[$key] = $value;
}
}
}

Expand All @@ -225,13 +226,13 @@ protected function transformChampsRecherche(array $post)
* SQL
*/

/**
* Retourne une liste d'id de congés
*
* @param array $params Paramètres de recherche
*
* @return array
*/
/**
* Retourne une liste d'id de congés
*
* @param array $params Paramètres de recherche
*
* @return array
*/
protected function getListeId(array $params)
{
$sql = \includes\SQL::singleton();
Expand Down Expand Up @@ -294,14 +295,15 @@ protected function getListeSQL(array $listId)
* Retourne les demandes d'un employé
*
*/
public static function getIdDemandesUtilisateur($user) {
public static function getIdDemandesUtilisateur($user)
{

$ids = [];
$sql = \includes\SQL::singleton();
$req = 'SELECT p_num AS id
FROM conges_periode
WHERE p_login = \'' . $sql->quote($user) . '\'
AND p_etat = \''. \App\Models\Conge::STATUT_DEMANDE.'\'';
AND p_etat = \'' . \App\Models\Conge::STATUT_DEMANDE . '\'';
$res = $sql->query($req);
while ($data = $res->fetch_array()) {
$ids[] = (int) $data['id'];
Expand All @@ -310,7 +312,6 @@ public static function getIdDemandesUtilisateur($user) {
return $ids;
}


/**
* Vérifie l'existence de congé basée sur les critères fournis
*
Expand Down Expand Up @@ -351,7 +352,7 @@ public function exists(array $params)
public function isChevauchement($user, $dateDebut, $typeCreneauDebut, $dateFin, $typeCreneauFin)
{
return $this->isChevauchementHeuresRepos($user, $dateDebut, $typeCreneauDebut, $dateFin, $typeCreneauFin)
|| $this->isChevauchementHeuresAdditionnelles($user, $dateDebut, $typeCreneauDebut, $dateFin, $typeCreneauFin);
|| $this->isChevauchementHeuresAdditionnelles($user, $dateDebut, $typeCreneauDebut, $dateFin, $typeCreneauFin);
}

/**
Expand Down Expand Up @@ -402,14 +403,12 @@ private function isChevauchementHeures($user, $dateDebut, $typeCreneauDebut, $da
{
$sql = \includes\SQL::singleton();
$filtresDates[] = '(dateDebutHeure > "' . $dateDebut . '" AND dateDebutHeure < "' . $dateFin . '")';
if (Creneau::TYPE_PERIODE_MATIN_APRES_MIDI
=== $typeCreneauDebut) {
if (Creneau::TYPE_PERIODE_MATIN_APRES_MIDI === $typeCreneauDebut) {
$filtresDates[] = '(dateDebutHeure = "' . $dateDebut . '")';
} else {
$filtresDates[] = '(dateDebutHeure = "' . $dateDebut . '" AND type_periode IN (' . $typeCreneauDebut . ',' . Creneau::TYPE_PERIODE_MATIN_APRES_MIDI . '))';
}
if (Creneau::TYPE_PERIODE_MATIN_APRES_MIDI
=== $typeCreneauFin) {
if (Creneau::TYPE_PERIODE_MATIN_APRES_MIDI === $typeCreneauFin) {
$filtresDates[] = '(dateDebutHeure = "' . $dateFin . '")';
} else {
$filtresDates[] = '(dateDebutHeure = "' . $dateFin . '" AND type_periode IN (' . $typeCreneauFin . ',' . Creneau::TYPE_PERIODE_MATIN_APRES_MIDI . '))';
Expand All @@ -424,7 +423,7 @@ private function isChevauchementHeures($user, $dateDebut, $typeCreneauDebut, $da
SELECT *
FROM
(SELECT *, DATE_FORMAT(FROM_UNIXTIME(debut), "%Y-%m-%d") AS dateDebutHeure
FROM ' . $typeHeure . ') tmp
FROM ' . $typeHeure . ') tmp
WHERE statut IN ("' . implode('","', $etats) . '")
AND login = "' . $sql->quote($user) . '"
AND (' . implode(' OR ', $filtresDates) . ')
Expand Down
3 changes: 2 additions & 1 deletion App/ProtoControllers/Employe/Heure/Additionnelle.php
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ public function getListe()
}
$champsRecherche = (!empty($_POST) && $this->isSearch($_POST))
? $this->transformChampsRecherche($_POST)
: ['statut' => AHeure::STATUT_DEMANDE];
: [];
$params = $champsRecherche + [
'login' => $_SESSION['userlogin'],
];
Expand Down Expand Up @@ -329,6 +329,7 @@ public function getListe()
protected function getFormulaireRecherche(array $champs)
{
$form = '<form method="post" action="" class="form-inline search" role="form"><div class="form-group"><label class="control-label col-md-4" for="statut">Statut&nbsp;:</label><div class="col-md-8"><select class="form-control" name="search[statut]" id="statut">';
$form .= '<option value="all">' . _('tous') . '</option>';
foreach (\App\Models\AHeure::getOptionsStatuts() as $key => $value) {
$selected = (isset($champs['statut']) && $key === $champs['statut'])
? 'selected="selected"'
Expand Down
3 changes: 2 additions & 1 deletion App/ProtoControllers/Employe/Heure/Repos.php
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ public function getListe()
}
$champsRecherche = (!empty($_POST) && $this->isSearch($_POST))
? $this->transformChampsRecherche($_POST)
: ['statut' => AHeure::STATUT_DEMANDE];
: [];
$params = $champsRecherche + [
'login' => $_SESSION['userlogin'],
];
Expand Down Expand Up @@ -327,6 +327,7 @@ public function getListe()
protected function getFormulaireRecherche(array $champs)
{
$form = '<form method="post" action="" class="form-inline search" role="form"><div class="form-group"><label class="control-label col-md-4" for="statut">Statut&nbsp;:</label><div class="col-md-8"><select class="form-control" name="search[statut]" id="statut">';
$form .= '<option value="all">' . _('tous') . '</option>';
foreach (AHeure::getOptionsStatuts() as $key => $value) {
$selected = (isset($champs['statut']) && $key == $champs['statut'])
? 'selected="selected"'
Expand Down
14 changes: 14 additions & 0 deletions Tests/Units/App/Helpers/Formatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,20 @@ public function testPositifTimestamp2Duree()
$this->string($time)->isIdenticalTo('01:00');
}

/**
* Test la transformation d'un timestamp équivalent à 0
*
* @since 1.9
*/
public function testZeroTimestamp2Duree()
{
$ts = '0';

$time = _Formatter::timestamp2Duree($ts);

$this->string($time)->isIdenticalTo('00:00');
}

/**
* Test la transformation d'un nombre de secondes négatif en hh:ii
*
Expand Down
Loading

0 comments on commit 57446cd

Please sign in to comment.