New file |
0,0 → 1,219 |
<?php |
|
// +------------------------------------------------------------------------------------------------------+ |
// | PHP version 4.1 | |
// +------------------------------------------------------------------------------------------------------+ |
// | Copyright (C) 2004 Tela Botanica (accueil@tela-botanica.org) | |
// +------------------------------------------------------------------------------------------------------+ |
// | This library is free software; you can redistribute it and/or | |
// | modify it under the terms of the GNU Lesser General Public | |
// | License as published by the Free Software Foundation; either | |
// | version 2.1 of the License, or (at your option) any later version. | |
// | | |
// | This library is distributed in the hope that it will be useful, | |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
// | Lesser General Public License for more details. | |
// | | |
// | You should have received a copy of the GNU Lesser General Public | |
// | License along with this library; if not, write to the Free Software | |
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
// +------------------------------------------------------------------------------------------------------+ |
|
// |@author ABDOOL RAHEEM shaheen shaheenar50@hotmail.com | |
// |@version 3 | |
|
|
/* |
*gere la table contenant les motifs d'absence |
*/ |
|
class Motif |
{ |
|
|
/**Attributes: */ |
|
|
var $_id_motif =null; |
|
var $_libelle_motif=null; |
|
var $_type_rtt=null; |
|
/**le type de rtt est ègale à si la condition d'absence occasionne |
*une réduction du temps de travail |
*et est égale à 0 sinon |
*/ |
|
function Motif($id) |
{ |
$this->_id_motif= $id; |
} |
|
|
/* Construit un motif à partir des paramètres passés dans le tableau*/ |
function ConstruireMotif($tableau) |
{ |
$this->_id_motif =$tableau[GEST_CHAMPS_ID_MOTIF]; |
$this->_libelle_motif = $tableau[GEST_CHAMPS_LIBELLE_MOTIF]; |
$this->_type_rtt = $tableau[GEST_CHAMPS_TYPE_RTT]; |
} |
|
/** |
* enregistre les motifs d'absence |
*renvoi 1 si enregistrement effectué |
*renvoi message d'erreur sinon |
*/ |
function enregistrerMotif() |
{ |
$table = GEST_MOTIF_ABSENCE; |
$i=$this->nextId(); |
$this->_id_motif=$i; |
$champs = array ( |
GEST_CHAMPS_ID_MOTIF => $this->_id_motif, |
GEST_CHAMPS_LIBELLE_MOTIF => "$this->_libelle_motif", |
GEST_CHAMPS_TYPE_RTT=> $this->_type_rtt |
); |
|
$resultat = $GLOBALS['db']->autoExecute($table, $champs, DB_AUTOQUERY_INSERT); |
|
if (DB::isError($resultat)) { |
die($resultat->getMessage()); |
} |
|
$j=$GLOBALS['db']->affectedRows(); |
if($j==1) |
{ |
return 1; |
}else return 0; |
|
} |
|
|
/** |
* recupere tous les motifs de la bse de donnees |
*et les renvoie sous forme d'un tableau avec 2 champs |
*: champs identifiant et champs libelle |
*/ |
function recupererTableauMotif() |
{ |
$tableau = array(); |
$i =0; |
$requete="SELECT ".GEST_CHAMPS_ID_MOTIF." , ".GEST_CHAMPS_LIBELLE_MOTIF.",".GEST_CHAMPS_TYPE_RTT |
." FROM ".GEST_MOTIF_ABSENCE.""; |
|
$resultat = $GLOBALS['db']->query($requete); |
|
while ($ligne= $resultat->fetchRow(DB_FETCHMODE_ASSOC)) |
{ |
$case = array(GEST_CHAMPS_ID_MOTIF => $ligne[GEST_CHAMPS_ID_MOTIF], |
GEST_CHAMPS_LIBELLE_MOTIF =>$ligne[GEST_CHAMPS_LIBELLE_MOTIF], |
GEST_CHAMPS_TYPE_RTT =>$ligne[GEST_CHAMPS_TYPE_RTT]); |
$tableau[$i]=$case; |
$i=$i+1; |
} |
|
return $tableau; |
} |
/** |
* supprime un motif de la bse de donnees et detruit l'instance |
*renvoie 1 si motif supprimé |
*renvoie 0 si motif inexistant |
*-1 si erreur |
*/ |
function supprimerMotif($id) |
{ |
$requete = "DELETE FROM ".GEST_MOTIF_ABSENCE. |
" WHERE ".GEST_CHAMPS_ID_MOTIF."= $id"; |
|
$resultat = $GLOBALS['db'] ->query($requete); |
|
(DB::isError($resultat)) ? |
die (BOG_afficherErreurSql(__FILE__, __LINE__, $resultat->getMessage(), $requete)) : '' ; |
|
$int=$GLOBALS['db']->affectedRows(); |
|
if($int==1) |
{ |
return 1; |
}elseif($int==0){ |
return 0; |
}else return-1; |
|
} |
|
/** |
fonction retournant l'idntifiant suivant de la base de donnees |
*/ |
|
function nextId() |
{ |
|
$requete = 'SELECT MAX('.GEST_CHAMPS_ID_MOTIF.') AS maxi FROM '.GEST_MOTIF_ABSENCE; |
$resultat = $GLOBALS['db']->query($requete); |
if (DB::isError($resultat) || $resultat->numRows() > 1) { |
return false; |
} |
|
$ligne = $resultat->fetchRow(DB_FETCHMODE_OBJECT); |
return $ligne->maxi + 1; |
} |
|
|
|
/** |
*modifie le type de rtt |
*/ |
function setRtt($typeRtt) |
{ |
$requete = " UPDATE ".GEST_MOTIF_ABSENCE." SET " |
.GEST_CHAMPS_TYPE_RTT." =$typeRtt WHERE ".GEST_CHAMPS_ID_MOTIF." = $this->_id_motif"; |
|
|
$resultat = $GLOBALS['db']->query($requete); |
(DB::isError($resultat)) ? |
die (BOG_afficherErreurSql(__FILE__, __LINE__, $resultat->getMessage(), $requete)) : '' ; |
|
$this->_type_rtt = $typeRtt; |
} |
/** |
*fonction verifiant si le motif d'absence est en cours d'utilisation |
*la suppression sera interdite dans ce cas afin de maintenir la cohérence de |
*de la base de donnees |
*renvoie 1 si le motif est utilisé |
*-1 sinon |
*/ |
|
function motifUtilise($id) |
{ |
$requete="SELECT ".GEST_CHAMPS_ID_UTILISATEUR. |
" FROM ".GEST_ABSENCE. |
" WHERE ". GEST_CHAMPS_ID_MOTIF." = $id"; |
$ligne= $GLOBALS['db']->query($requete); |
|
(DB::isError($ligne)) ? |
die (BOG_afficherErreurSql(__FILE__, __LINE__, $ligne->getMessage(), $requete)) : '' ; |
$j= $ligne->numRows(); |
if ($j==0){ |
return -1; |
}else { |
return 1; |
} |
} |
|
|
/*afficher un motif */ |
|
function afficherMotif() |
{ |
echo "Motif : \n"; |
echo "id :"; |
echo "$this->_id_motif <BR>"; |
echo "libelle :"; |
echo "$this->_libelle_motif <BR>"; |
echo "type rtt :"; |
echo "$this->_type_rtt <BR>"; |
} |
} |
?> |
Property changes: |
Added: svn:executable |