Subversion Repositories Applications.gtt

Rev

Rev 16 | Rev 35 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 16 Rev 33
Line 203... Line 203...
203
 
203
 
204
		}
204
		}
205
		//+-------------------------------------------------------------------------------------------------+
205
		//+-------------------------------------------------------------------------------------------------+
206
		// GESTION DES ABSENCES
206
		// GESTION DES ABSENCES
-
 
207
		//+-------------------------------------------------------------------------------------------------+
-
 
208
		// Récupération des motifs d'absence
-
 
209
		$AbsenceMotif = new AbsenceMotif();
-
 
210
		$cmd = AbsenceMotif::GAM_TOUS;
-
 
211
		$tab_am = $AbsenceMotif->consulter($cmd);
-
 
212
		if ($tab_am && count($tab_am) == 1) {
-
 
213
			$tab_am = array($tab_am);
-
 
214
		}
207
		//+-------------------------------------------------------------------------------------------------+
215
 
208
		// Récupération des absences pour un utilisateur à une date donnée
216
		// Récupération des absences pour un utilisateur à une date donnée
209
    	$Absence = new Absence();
217
    	$Absence = new Absence();
210
		$cmd = Absence::GA_ID_UTILISATEUR_DATE_DEB_FIN;
218
		$cmd = Absence::GA_ID_UTILISATEUR_DATE_DEB_FIN;
211
		$param = array($GLOBALS['_GTT_']['Utilisateur']->getIdUtilisateur(), $aso_gestion['sj_1']['mysql'], $aso_gestion['sj_7']['mysql']);
219
		$param = array($GLOBALS['_GTT_']['Utilisateur']->getIdUtilisateur(), $aso_gestion['sj_1']['mysql'], $aso_gestion['sj_7']['mysql']);
212
		$tab_a = $Absence->consulter($cmd, $param);
220
		$tab_a = $Absence->consulter($cmd, $param);
213
		if ($tab_a && count($tab_a) == 1) {
221
		if ($tab_a && count($tab_a) == 1) {
214
			$tab_a = array($tab_a);
222
			$tab_a = array($tab_a);
-
 
223
		}
215
		}
224
 
-
 
225
		$aso_gestion['ab_total'] = $aso_tps_w_vide;
-
 
226
		if ($tab_am) {
-
 
227
			foreach ($tab_am as $AM) {
216
		$aso_gestion['cp'] = $aso_tps_w_vide;
228
				$aso_gestion['ab_libelle'][$AM->getIdAbsenceMotif()] = $AM->getLibelle();
217
		$aso_gestion['rtt'] = $aso_tps_w_vide;
229
				$aso_gestion['ab'][$AM->getIdAbsenceMotif()] = $aso_tps_w_vide;
218
		if ($tab_a) {
230
				if ($tab_a) {
-
 
231
					foreach ($tab_a as $A) {
219
			foreach ($tab_a as $A) {
232
						if ($A->getIdAbsenceMotif() == $AM->getIdAbsenceMotif()) {
220
				$num = $aso_jours[$A->getIdDateAbsence()];
233
							$num = $aso_jours[$A->getIdDateAbsence()];
221
				switch ($A->getIdAbsenceMotif()) {
234
							$aso_gestion['ab'][$AM->getIdAbsenceMotif()][$num] = $A->getDuree();
222
					case GTT_ABSCENCE_ID_CP :
235
							$aso_gestion['ab_total'][$num] += $A->getDuree();
223
						$aso_gestion['cp'][$num] = $A->getDuree();
236
							$aso_gestion['totaux'][$num] += $A->getDuree();
224
						break;
-
 
225
					case GTT_ABSCENCE_ID_RTT :
-
 
226
						$aso_gestion['rtt'][$num] = $A->getDuree();
237
						}
227
						break;
238
					}
228
				}
239
				}
229
			}
240
			}
Line 230... Line 241...
230
		}
241
		}
231
 
242
 
Line 232... Line 243...
232
		// Création de l'url de réponse du formulaire
243
		// Création de l'url de réponse du formulaire
233
		$aso_gestion['url_gestion_valider'] = 'index.php?action='.GTT_ACTION_GESTION_VALIDER.$url_sc_param_date;
244
		$aso_gestion['url_gestion_valider'] = 'index.php?action='.GTT_ACTION_GESTION_VALIDER.$url_sc_param_date;
234
 
245
 
Line 235... Line 246...
235
    	//echo '<pre>'.print_r($aso_gestion, true).'</pre>';
246
    	//echo '<pre>ici '.print_r($aso_gestion['ab'], true).'la</pre>';
236
		$this->getRegistre()->ajouterDonnee('gestion', $aso_gestion);
247
		$this->getRegistre()->ajouterDonnee('gestion', $aso_gestion);
Line 262... Line 273...
262
		$tab_tp = $TravailProjet->consulter($cmd, $param);
273
		$tab_tp = $TravailProjet->consulter($cmd, $param);
263
		if ($tab_tp && count($tab_tp) == 1) {
274
		if ($tab_tp && count($tab_tp) == 1) {
264
			$tab_tp = array($tab_tp);
275
			$tab_tp = array($tab_tp);
265
		}
276
		}
Line -... Line 277...
-
 
277
 
-
 
278
		// Ajout ou Mise à jour des durées de travail
266
 
279
		if (isset($_POST['pr'])) {
267
		foreach($_POST['pr'] as $projet_id => $jours) {
280
			foreach($_POST['pr'] as $projet_id => $jours) {
268
			//echo '<pre>'.print_r($jours, true).'</pre>';
281
				//echo '<pre>'.print_r($jours, true).'</pre>';
269
			foreach($jours as $jour_num => $nbr_heure) {
282
				foreach($jours as $jour_num => $nbr_heure) {
-
 
283
					$bool_ajouter = true;
270
				$bool_ajouter = true;
284
					if (!empty($tab_tp)) {
271
				foreach ($tab_tp as $TP) {
285
						foreach ($tab_tp as $TP) {
272
					if ($TP->getIdDateTravail() == $aso_semaine[$jour_num]['mysql']) {
286
							if ($TP->getIdDateTravail() == $aso_semaine[$jour_num]['mysql']) {
273
						if ($TP->getIdProjet() == $projet_id) {
287
								if ($TP->getIdProjet() == $projet_id) {
274
							$bool_ajouter = false;
288
									$bool_ajouter = false;
275
							if ($TP->getDuree() != $nbr_heure && $TP->getIdProjet() == $projet_id) {
289
									if ($TP->getDuree() != $nbr_heure) {
276
								if (empty($nbr_heure)) {
290
										if (empty($nbr_heure)) {
277
									$TP->supprimer();
291
											$TP->supprimer();
278
								} else {
292
										} else {
279
									$TP->setDuree($nbr_heure);
293
											$TP->setDuree($nbr_heure);
-
 
294
											$TP->modifier();
-
 
295
										}
280
									$TP->modifier();
296
									}
281
								}
297
								}
282
							}
298
							}
283
						}
299
						}
-
 
300
					}
-
 
301
					if ($bool_ajouter && !empty($nbr_heure)) {
-
 
302
						$TP = new TravailProjet();
-
 
303
						$TP->setDuree((float)$nbr_heure);
-
 
304
						$TP->setIdUtilisateur($GLOBALS['_GTT_']['Utilisateur']->getIdUtilisateur());
-
 
305
						$TP->setIdProjet($projet_id);
-
 
306
						$TP->setIdDateTravail((string)$aso_semaine[$jour_num]['mysql']);
-
 
307
						$TP->ajouter();
284
					}
308
					}
-
 
309
				}
-
 
310
			}
-
 
311
		}
-
 
312
 
-
 
313
		// Récupération des absences pour un utilisateur à une date donnée
-
 
314
    	$Absence = new Absence();
-
 
315
		$cmd = Absence::GA_ID_UTILISATEUR_DATE_DEB_FIN;
-
 
316
		$param = array($GLOBALS['_GTT_']['Utilisateur']->getIdUtilisateur(), $aso_semaine[1]['mysql'], $aso_semaine[7]['mysql']);
-
 
317
		$tab_a = $Absence->consulter($cmd, $param);
-
 
318
		if ($tab_a && count($tab_a) == 1) {
-
 
319
			$tab_a = array($tab_a);
-
 
320
		}
-
 
321
 
-
 
322
		// Ajout ou Mise à jour des durées d'absences pour congés payés
-
 
323
		if (isset($_POST['ab'])) {
-
 
324
			//echo '<pre>'.print_r($_POST['ab'], true).'</pre>';
-
 
325
			foreach($_POST['ab'] as $ab_id => $tab_num_j) {
-
 
326
				foreach($tab_num_j as $num_j => $ab_duree) {
-
 
327
					$bool_ajouter = true;
-
 
328
					if (!empty($tab_a)) {
-
 
329
						foreach ($tab_a as $A) {
-
 
330
							if ($A->getIdDateAbsence() == $aso_semaine[$num_j]['mysql']) {
-
 
331
 
-
 
332
								if ($A->getIdAbsenceMotif() == $ab_id) {
-
 
333
									$bool_ajouter = false;
-
 
334
 
-
 
335
									if ($A->getDuree() != $ab_duree) {
-
 
336
										echo 'ici'.$ab_duree;
-
 
337
										if (empty($ab_duree)) {
-
 
338
											$A->supprimer();
-
 
339
										} else {
-
 
340
											$A->setDuree($ab_duree);
-
 
341
											$A->modifier();
-
 
342
										}
-
 
343
									}
-
 
344
								}
-
 
345
							}
-
 
346
						}
285
				}
347
					}
286
				if ($bool_ajouter && !empty($nbr_heure)) {
348
					if ($bool_ajouter && !empty($ab_duree)) {
287
					$TP = new TravailProjet();
349
						$A = new Absence();
288
					$TP->setDuree((float)$nbr_heure);
350
						$A->setDuree((float)$ab_duree);
289
					$TP->setIdUtilisateur($GLOBALS['_GTT_']['Utilisateur']->getIdUtilisateur());
351
						$A->setIdUtilisateur($GLOBALS['_GTT_']['Utilisateur']->getIdUtilisateur());
290
					$TP->setIdProjet($projet_id);
352
						$A->setIdAbsenceMotif($ab_id);
291
					$TP->setIdDateTravail((string)$aso_semaine[$jour_num]['mysql']);
353
						$A->setIdDateAbsence((string)$aso_semaine[$num_j]['mysql']);
-
 
354
						$A->ajouter();
292
					$TP->ajouter();
355
					}
293
				}
356
				}
294
			}
357
			}
Line 295... Line 358...
295
		}
358
		}