Subversion Repositories Applications.gtt

Rev

Rev 28 | Rev 48 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 28 Rev 44
1
<?php
1
<?php
2
// +------------------------------------------------------------------------------------------------------+
2
// +------------------------------------------------------------------------------------------------------+
3
// | PHP version 4.1                                                                                      |
3
// | PHP version 4.1                                                                                      |
4
// +------------------------------------------------------------------------------------------------------+
4
// +------------------------------------------------------------------------------------------------------+
5
// | Copyright (C) 2004 Tela Botanica (accueil@tela-botanica.org)                                         |
5
// | Copyright (C) 2004 Tela Botanica (accueil@tela-botanica.org)                                         |
6
// +------------------------------------------------------------------------------------------------------+
6
// +------------------------------------------------------------------------------------------------------+
7
// | This library is free software; you can redistribute it and/or                                        |
7
// | This library is free software; you can redistribute it and/or                                        |
8
// | modify it under the terms of the GNU Lesser General Public                                           |
8
// | modify it under the terms of the GNU Lesser General Public                                           |
9
// | License as published by the Free Software Foundation; either                                         |
9
// | License as published by the Free Software Foundation; either                                         |
10
// | version 2.1 of the License, or (at your option) any later version.                                   |
10
// | version 2.1 of the License, or (at your option) any later version.                                   |
11
// |                                                                                                      |
11
// |                                                                                                      |
12
// | This library is distributed in the hope that it will be useful,                                      |
12
// | This library is distributed in the hope that it will be useful,                                      |
13
// | but WITHOUT ANY WARRANTY; without even the implied warranty of                                       |
13
// | but WITHOUT ANY WARRANTY; without even the implied warranty of                                       |
14
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU                                    |
14
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU                                    |
15
// | Lesser General Public License for more details.                                                      |
15
// | Lesser General Public License for more details.                                                      |
16
// |                                                                                                      |
16
// |                                                                                                      |
17
// | You should have received a copy of the GNU Lesser General Public                                     |
17
// | You should have received a copy of the GNU Lesser General Public                                     |
18
// | License along with this library; if not, write to the Free Software                                  |
18
// | License along with this library; if not, write to the Free Software                                  |
19
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                            |
19
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                            |
20
// +------------------------------------------------------------------------------------------------------+
20
// +------------------------------------------------------------------------------------------------------+
21
// |@author ABDOOL RAHEEM shaheen   shaheenar50@hotmail.com                                                 |
21
// |@author ABDOOL RAHEEM shaheen   shaheenar50@hotmail.com                                                 |
22
// |@version 3                                                                                            |
22
// |@version 3                                                                                            |
23
 
23
 
24
// +------------------------------------------------------------------------------------------------------+
24
// +------------------------------------------------------------------------------------------------------+
25
/*
25
/*
26
*fichier contenant le menu principal de l'application de gestion du temps de travail
26
*fichier contenant le menu principal de l'application de gestion du temps de travail
27
*@package gtt_general
27
*@package gtt_general
28
//Auteur original :
28
//Auteur original :
29
*@author        Dorian Bannier <dbannier@aol.com>
29
*@author        Dorian Bannier <dbannier@aol.com>
30
//Autres auteurs :
30
//Autres auteurs :
31
*@author        Jean-Pascal MILCENT <jpm@tela-botanica.org>
31
*@author        Jean-Pascal MILCENT <jpm@tela-botanica.org>
32
*@copyright     Copyright (C) 2003 Tela-Botanica
32
*@copyright     Copyright (C) 2003 Tela-Botanica
33
*/
33
*/
34
// +------------------------------------------------------------------------------------------------------+
34
// +------------------------------------------------------------------------------------------------------+
35
// |                                            INCLUSION DE FICHIERS                                       |
35
// |                                            INCLUSION DE FICHIERS                                       |
36
// +------------------------------------------------------------------------------------------------------+
36
// +------------------------------------------------------------------------------------------------------+
37
 
37
 
38
// Fichiers de la bibliotheque PEAR
38
// Fichiers de la bibliotheque PEAR
39
include 'Auth/Auth.php';
39
include 'Auth/Auth.php';
40
include 'DB.php';
40
include 'DB.php';
41
include 'HTML/QuickForm.php';
-
 
42
include 'gtt_config.inc.php';
41
include 'gtt_config.inc.php';
43
include CHEMIN_LANGUES.'gtt_langue_fr.inc.php';
42
include CHEMIN_LANGUES.'gtt_langue_fr.inc.php';
44
 
43
 
45
// Test des choix de menu a afficher
44
// Test des choix de menu a afficher
46
$action = 1;
45
$action = 'gestion';
47
if (!empty($_GET['action'])) {
46
if (!empty($_GET['action'])) {
48
	$action = $_GET['action'];
47
	$action = $_GET['action'];
49
}
48
}
50
if (!preg_match('/^\d+$/', $action)) {
49
if (!preg_match('/^\d+$/', $action)) {
-
 
50
	/**
-
 
51
	* La fonction __autoload() charge dynamiquement les classes trouvées dans le code.
-
 
52
	*
-
 
53
	* Cette fonction est appelée par php5 quand il trouve une instanciation de classe dans le code.
-
 
54
	*
-
 
55
	*@param string le nom de la classe appelée.
-
 
56
	*@return void le fichier contenant la classe doit être inclu par la fonction.
-
 
57
	*/
-
 
58
	function __autoload($classe)
-
 
59
	{
-
 
60
		foreach ($GLOBALS['_GTT_']['tab_chemin_autoload'] as $chemin) {
-
 
61
			$fichier = $chemin.$classe.'.class.php';
-
 
62
			if (file_exists($fichier)) {
-
 
63
				require_once $fichier;
-
 
64
			}
-
 
65
		}
-
 
66
	}
-
 
67
 
51
	// Connexion a la base de donnees
68
	// Connexion a la base de donnees
52
	$GLOBALS['db'] = DB::connect(GTT_BDD_DSN);
69
	$GLOBALS['db'] = DB::connect(GTT_BDD_DSN);
53
	if (PEAR::isError($GLOBALS['db'])) {
70
	if (PEAR::isError($GLOBALS['db'])) {
54
		trigger_error("Echec connexion a la base de donnees : ".$GLOBALS['db']->getMessage(), E_USER_ERROR);
71
		trigger_error("Echec connexion a la base de donnees : ".$GLOBALS['db']->getMessage(), E_USER_ERROR);
55
	}
72
	}
56
	$params = array('dsn' => GTT_BDD_DSN,
-
 
57
					'table' => 'gestion_utilisateur',
-
 
58
					'usernamecol' => 'gu_email',
-
 
59
					'passwordcol' => 'gu_password',
-
 
60
					'cryptype' => 'md5',
-
 
61
					'db_fields' => '*');
-
 
62
	// Création de l'objet auth
-
 
63
	$a = new Auth('DB', $params, null, false);
-
 
64
	$a->setSessionname(GTT_AUTH_SESSION_NOM);
-
 
65
	$a->setExpire(time()+(int)GTT_AUTH_SESSION_DUREE);
-
 
66
	$a->start();
-
 
67
	setcookie(session_name(),session_id(), time()+(int)GTT_AUTH_SESSION_DUREE, "/");
-
 
68
	if (!$a->getAuth()) {
-
 
69
		$action = GTT_ACTION_DECONNEXION;
-
 
70
	}
-
 
71
	
73
 
72
	// Récuperation d'informations générales
74
	// Récuperation d'informations générales
73
	require_once GTT_CHEMIN_CLASSE.'GestionnaireErreur.class.php';
75
	require_once GTT_CHEMIN_CLASSE.'GestionnaireErreur.class.php';
74
	require_once GTT_CHEMIN_METIER.'aGttSql.class.php';
76
	require_once GTT_CHEMIN_METIER.'aGttSql.class.php';
75
	require_once GTT_CHEMIN_METIER.'Utilisateur.class.php';
-
 
76
	$GLOBALS['_GTT_']['Utilisateur'] = new Utilisateur(Utilisateur::GU_MAIL, array($a->getUserName()));
-
 
77
	$GLOBALS['_GTT_']['auth'] = $a;
-
 
78
 
77
 
79
	// Utilisation du mécanisme MVC avec Squelette PHP et objet
78
	// Utilisation du mécanisme MVC avec Squelette PHP et objet
80
	require_once GTT_CHEMIN_CLASSE.'aControlleurAction.class.php';
79
	require_once GTT_CHEMIN_CLASSE.'aControlleurAction.class.php';
81
	require_once GTT_CHEMIN_CLASSE.'Registre.class.php';
80
	require_once GTT_CHEMIN_CLASSE.'Registre.class.php';
82
	$module = 'Gestion';
-
 
83
	if (isset($_GET['module']) && !empty($_GET['module'])) {
-
 
84
		$module = $_GET['module'];
-
 
85
	}
-
 
86
	$nom_module = 'GttControlleur'.$module;
-
 
87
	$fichier_module = GTT_CHEMIN_MODULE.$nom_module.'.class.php';
-
 
88
	$nom_module_general = 'ControlleurFrontal';
81
	$nom_module_general = 'ControlleurFrontal';
89
	$fichier_module_general = GTT_CHEMIN_CLASSE.$nom_module_general.'.class.php';
82
	$fichier_module_general = GTT_CHEMIN_CLASSE.$nom_module_general.'.class.php';
90
	if (file_exists($fichier_module)) {
-
 
91
		require_once $fichier_module;
-
 
92
		$Controlleur = new $nom_module;
-
 
93
	} else if (file_exists($fichier_module_general)) {
83
	if (file_exists($fichier_module_general)) {
94
		require_once $fichier_module_general;
84
		require_once $fichier_module_general;
95
		$Controlleur = new $nom_module_general;
85
		$Controlleur = new $nom_module_general;
96
	}
86
	}
97
	echo $Controlleur->executer($action);
87
	echo $Controlleur->executer($action);
98
} else {
88
} else {
-
 
89
	include 'HTML/QuickForm.php';
99
	include_once CHEMIN_CLASSES.'gtt_authentification.php';
90
	include_once CHEMIN_CLASSES.'gtt_authentification.php';
100
	include_once CHEMIN_PRESENTATION.'gtt_fonctions_generique_affichage.php';
91
	include_once CHEMIN_PRESENTATION.'gtt_fonctions_generique_affichage.php';
101
	// Connexion a la base de donnees
92
	// Connexion a la base de donnees
102
	$GLOBALS['db'] = DB::connect($GLOBALS['dsn_v3']);
93
	$GLOBALS['db'] = DB::connect($GLOBALS['dsn_v3']);
103
	if (DB::isError($GLOBALS['db'])) {
94
	if (DB::isError($GLOBALS['db'])) {
104
		$GLOBALS['db']->getMessage();
95
		$GLOBALS['db']->getMessage();
105
		echo "Echec connexion a la base de donnees";
96
		echo "Echec connexion a la base de donnees";
106
	}
97
	}
107
 
98
 
108
	// Création de l'objet auth
99
	// Création de l'objet auth
109
	$params = array('dsn'=>$GLOBALS['dsn_v3'],
100
	$params = array('dsn'=>$GLOBALS['dsn_v3'],
110
					'table'=>GEST_UTILISATEUR,
101
					'table'=>GEST_UTILISATEUR,
111
					'usernamecol'=>GEST_CHAMPS_EMAIL,
102
					'usernamecol'=>GEST_CHAMPS_EMAIL,
112
					'passwordcol'=>GEST_CHAMPS_PASSWORD,
103
					'passwordcol'=>GEST_CHAMPS_PASSWORD,
113
					'cryptype'=>'md5',
104
					'cryptype'=>'md5',
114
					'db_fields'=>'*');
105
					'db_fields'=>'*');
115
	$a = new Auth('DB', $params, 'afficherMenuConnexion', true);
106
	$a = new Auth('DB', $params, 'afficherMenuConnexion', true);
116
	$a->setSessionname('temps_travail');
107
	$a->setSessionname('temps_travail');
117
	$a->setExpire(3600*24*30);
108
	$a->setExpire(3600*24*30);
118
	$a->start();
109
	$a->start();
119
	echo $a->getStatus();
110
	echo $a->getStatus();
120
	if ($a->getAuth()) {
111
	if ($a->getAuth()) {
121
		// Récuperation de l'identifiant de la personne
112
		// Récuperation de l'identifiant de la personne
122
		$mail = $a->getUserName();
113
		$mail = $a->getUserName();
123
		$utilisateur = Utilisateur::recupIDUtilisateurMail($mail);
114
		$utilisateur = Utilisateur::recupIDUtilisateurMail($mail);
124
		$GLOBALS['idCurrentUser'] = $utilisateur;
115
		$GLOBALS['idCurrentUser'] = $utilisateur;
125
 
116
 
126
		// Utilisation de l'ancien mécanisme
117
		// Utilisation de l'ancien mécanisme
127
		switch ($action) {
118
		switch ($action) {
128
			// Cas affichage menu travail 1
119
			// Cas affichage menu travail 1
129
			case GESTION_TRAVAIL :
120
			case GESTION_TRAVAIL :
130
				include_once CHEMIN_MENU.'gtt_menu_travail.php';
121
				include_once CHEMIN_MENU.'gtt_menu_travail.php';
131
				include_once CHEMIN_CONTROLEUR.'gtt_controleur_travail.php';
122
				include_once CHEMIN_CONTROLEUR.'gtt_controleur_travail.php';
132
	       		if (!isset($semaine)) {
123
	       		if (!isset($semaine)) {
133
					$semaine = date('W',mktime(0, 0, 0, date('m'), date('d') ,date('Y')));
124
					$semaine = date('W',mktime(0, 0, 0, date('m'), date('d') ,date('Y')));
134
				}
125
				}
135
		 		if (!isset($annee)) {
126
		 		if (!isset($annee)) {
136
					$annee = date('Y');
127
					$annee = date('Y');
137
				}
128
				}
138
	        	$text = traiterAdminTravail($_SERVER['PHP_SELF'], $semaine, $annee, $utilisateur);
129
	        	$text = traiterAdminTravail($_SERVER['PHP_SELF'], $semaine, $annee, $utilisateur);
139
				break;
130
				break;
140
 
131
 
141
			// Cas affichage du menu ajout autilisateurss 13
132
			// Cas affichage du menu ajout autilisateurss 13
142
			case GESTION_ADMIN_UTILISATEUR :
133
			case GESTION_ADMIN_UTILISATEUR :
143
				include_once CHEMIN_MENU.'gtt_menu_admin_utilisateur.php';
134
				include_once CHEMIN_MENU.'gtt_menu_admin_utilisateur.php';
144
				include_once CHEMIN_CONTROLEUR.'gtt_controleur_admin_utilisateur.php';
135
				include_once CHEMIN_CONTROLEUR.'gtt_controleur_admin_utilisateur.php';
145
				$text = traiterAdminUtilisateur('',0);
136
				$text = traiterAdminUtilisateur('',0);
146
				break;
137
				break;
147
 
138
 
148
			// Cas editer des utilisateurs 14
139
			// Cas editer des utilisateurs 14
149
			case GESTION_EDITER_UTILISATEUR :
140
			case GESTION_EDITER_UTILISATEUR :
150
				include_once CHEMIN_MENU.'gtt_menu_admin_utilisateur.php';
141
				include_once CHEMIN_MENU.'gtt_menu_admin_utilisateur.php';
151
				include_once CHEMIN_CONTROLEUR.'gtt_controleur_admin_utilisateur.php';
142
				include_once CHEMIN_CONTROLEUR.'gtt_controleur_admin_utilisateur.php';
152
				$text = traiterAdminUtilisateur(renvoyerDonneesUser(),1);
143
				$text = traiterAdminUtilisateur(renvoyerDonneesUser(),1);
153
				break;
144
				break;
154
 
145
 
155
			// Cas afficher menu administration projet 15
146
			// Cas afficher menu administration projet 15
156
			case GESTION_ADMIN_PROJET :
147
			case GESTION_ADMIN_PROJET :
157
				include_once CHEMIN_CONTROLEUR.'gtt_controleur_admin_projet.php';
148
				include_once CHEMIN_CONTROLEUR.'gtt_controleur_admin_projet.php';
158
				$text = traiterAdminProjet();
149
				$text = traiterAdminProjet();
159
				break;
150
				break;
160
 
151
 
161
			// Cas afficher menu administration categorie 16
152
			// Cas afficher menu administration categorie 16
162
			case GESTION_ADMIN_CATEGORIE :
153
			case GESTION_ADMIN_CATEGORIE :
163
				include_once CHEMIN_CONTROLEUR.'gtt_controleur_admin_categorie.php';
154
				include_once CHEMIN_CONTROLEUR.'gtt_controleur_admin_categorie.php';
164
				$text = traiterAdminCategorie();
155
				$text = traiterAdminCategorie();
165
				break;
156
				break;
166
 
157
 
167
			// Cas afficher menu admin motif absence 17
158
			// Cas afficher menu admin motif absence 17
168
			case GESTION_ADMIN_MOTIF_ABSENCE :
159
			case GESTION_ADMIN_MOTIF_ABSENCE :
169
				include_once CHEMIN_CONTROLEUR.'gtt_controleur_admin_motif_absence.php';
160
				include_once CHEMIN_CONTROLEUR.'gtt_controleur_admin_motif_absence.php';
170
				$text = traiterAdminMotif();
161
				$text = traiterAdminMotif();
171
				break;
162
				break;
172
 
163
 
173
			// Cas afficher menu admin statut 18
164
			// Cas afficher menu admin statut 18
174
			case GESTION_ADMIN_STATUT :
165
			case GESTION_ADMIN_STATUT :
175
				include_once CHEMIN_CONTROLEUR.'gtt_controleur_admin_statut.php';
166
				include_once CHEMIN_CONTROLEUR.'gtt_controleur_admin_statut.php';
176
				$text = traiterAdminStatut();
167
				$text = traiterAdminStatut();
177
				break;
168
				break;
178
 
169
 
179
			// Cas afficher admin editer frais 19
170
			// Cas afficher admin editer frais 19
180
			case GESTION_ADMIN_FRAIS :
171
			case GESTION_ADMIN_FRAIS :
181
 
172
 
182
				$text = '';
173
				$text = '';
183
				break;
174
				break;
184
 
175
 
185
			// Cas afficher admin editer taches 20
176
			// Cas afficher admin editer taches 20
186
			case GESTION_ADMIN_TACHE :
177
			case GESTION_ADMIN_TACHE :
187
				$text = '';
178
				$text = '';
188
				break;
179
				break;
189
 
180
 
190
			// Cas editer preferences d'un utilisateur 21
181
			// Cas editer preferences d'un utilisateur 21
191
			case GESTION_EDITER_PREFERENCES :
182
			case GESTION_EDITER_PREFERENCES :
192
				include_once CHEMIN_MENU.'gtt_menu_editer_preferences.php';
183
				include_once CHEMIN_MENU.'gtt_menu_editer_preferences.php';
193
				include_once CHEMIN_CONTROLEUR.'gtt_controleur_editer_preferences.php';
184
				include_once CHEMIN_CONTROLEUR.'gtt_controleur_editer_preferences.php';
194
				$text = traiterEditerPreferences($GLOBALS['idCurrentUser']);
185
				$text = traiterEditerPreferences($GLOBALS['idCurrentUser']);
195
				break;
186
				break;
196
 
187
 
197
			// Cas deconnexion 22
188
			// Cas deconnexion 22
198
			case GESTION_DECONNEXION :
189
			case GESTION_DECONNEXION :
199
				$a->logout();
190
				$a->logout();
200
				$text = afficherMenuConnexion();
191
				$text = afficherMenuConnexion();
201
				//$GLOBALS['db']->disconnect();
192
				//$GLOBALS['db']->disconnect();
202
				break;
193
				break;
203
		}
194
		}
204
		$text .= fermerBalisesFin();
195
		$text .= fermerBalisesFin();
205
		echo $text;
196
		echo $text;
206
	} else {
197
	} else {
207
		echo afficherMenuConnexion();
198
		echo afficherMenuConnexion();
208
	}
199
	}
209
}
200
}
210
?>
201
?>