Subversion Repositories eFlore/Applications.cel

Rev

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

Rev 562 Rev 563
Line 50... Line 50...
50
			$this->envoyer($info);
50
			$this->envoyer($info);
51
		}
51
		}
52
	}
52
	}
Line 53... Line 53...
53
 
53
 
-
 
54
	private function getEvolImgLieesParMois($param) {
-
 
55
		$utilisateur = isset($_GET['utilisateur']) ? $this->bdd->quote($_GET['utilisateur']) : null;
54
	private function getEvolImgLieesParMois($param) {
56
		
55
		// Récupération des données
57
		// Récupération des données
56
		$requete = 	"SELECT DATE_FORMAT(ci_meta_date_ajout, '%Y%m') AS periode, COUNT(ci_id_image) AS nbre ".
58
		$requete = 	"SELECT DATE_FORMAT(ci_meta_date_ajout, '%Y%m') AS periode, COUNT(ci_id_image) AS nbre ".
57
			"FROM cel_obs_images LEFT JOIN cel_images ON (coi_ce_image = ci_id_image) ".
59
			"FROM cel_obs_images LEFT JOIN cel_images ON (coi_ce_image = ci_id_image) ".
-
 
60
			"WHERE ci_meta_date_ajout != '0000-00-00 00:00:00' ".
58
			"WHERE ci_meta_date_ajout != '0000-00-00 00:00:00' ".
61
			((isset($utilisateur)) ? " AND ci_ce_utilisateur = $utilisateur " : '').
59
			'GROUP BY periode '.
62
			'GROUP BY periode '.
60
			'ORDER BY periode ';
63
			'ORDER BY periode ';
Line 61... Line 64...
61
		$resulats = $this->executerRequete($requete);
64
		$resulats = $this->executerRequete($requete);
Line 117... Line 120...
117
			'chxs'	=> '0,007F00|4,99CC00');
120
			'chxs'	=> '0,007F00|4,99CC00');
118
		return $graph;
121
		return $graph;
119
	}
122
	}
Line 120... Line 123...
120
 
123
 
-
 
124
	private function getEvolImgParMois($param) {
-
 
125
		$utilisateur = isset($_GET['utilisateur']) ? $this->bdd->quote($_GET['utilisateur']) : null;
121
	private function getEvolImgParMois($param) {
126
		
122
		// Récupération des données
127
		// Récupération des données
123
		$requete = 	"SELECT DATE_FORMAT(ci_meta_date_ajout, '%Y%m') AS periode, COUNT(ci_id_image) AS nbre ".
128
		$requete = 	"SELECT DATE_FORMAT(ci_meta_date_ajout, '%Y%m') AS periode, COUNT(ci_id_image) AS nbre ".
124
			"FROM cel_images ".
129
			"FROM cel_images ".
-
 
130
			"WHERE ci_meta_date_ajout != '0000-00-00 00:00:00' ".
125
			"WHERE ci_meta_date_ajout != '0000-00-00 00:00:00' ".
131
			((isset($utilisateur)) ? " AND ci_ce_utilisateur = $utilisateur " : '').
126
			'GROUP BY periode '.
132
			'GROUP BY periode '.
127
			'ORDER BY periode ';
133
			'ORDER BY periode ';
Line 128... Line 134...
128
		$resulats = $this->executerRequete($requete);
134
		$resulats = $this->executerRequete($requete);
Line 507... Line 513...
507
			'chts'	=> '000000,12');
513
			'chts'	=> '000000,12');
508
		return $graph;
514
		return $graph;
509
	}
515
	}
Line 510... Line 516...
510
 
516
 
511
	private function getNbreObsAvecIndicationGeo($param) {
-
 
512
		$utilisateur = isset($_GET['utilisateur']) ? ' AND identifiant = '.$this->bdd->quote($_GET['utilisateur']) : '';
-
 
513
		
517
	private function getNbreObsAvecIndicationGeo($param) {
514
		// Récupération des données
518
		// Récupération des données
515
		$total = $this->executerRequeteNombre('cel_inventory', 'id', $utilisateur);
519
		$total = $this->executerRequeteNombre('cel_inventory', 'id');
516
		$where_commune = "location != '000null' AND location != '' AND location IS NOT NULL";
520
		$where_commune = $this->creerWhereIndicationGeo('location');
-
 
521
		$obs['commune'] = $this->executerRequeteNombre('cel_inventory', 'id', $where_commune);
517
		$obs['commune'] = $this->executerRequeteNombre('cel_inventory', 'id', $where_commune);
522
		$where_commune_id = $this->creerWhereIndicationGeo('id_location');
-
 
523
		$obs['commune identifiée'] = $this->executerRequeteNombre('cel_inventory', 'id', $where_commune_id);
518
		$obs['commune identifiée'] = $this->executerRequeteNombre('cel_inventory', 'id', "id_location != '000null' AND id_location != '' AND id_location IS NOT NULL");
524
		$where_lieudit = $this->creerWhereIndicationGeo('lieudit');
-
 
525
		$obs['lieu-dit'] = $this->executerRequeteNombre('cel_inventory', 'id', $where_lieudit);
519
		$obs['lieu-dit'] = $this->executerRequeteNombre('cel_inventory', 'id', "lieudit != '000null' AND lieudit != '' AND lieudit IS NOT NULL");
526
		$where_station = $this->creerWhereIndicationGeo('station');
-
 
527
		$obs['station'] = $this->executerRequeteNombre('cel_inventory', 'id', $where_station);
520
		$obs['station'] = $this->executerRequeteNombre('cel_inventory', 'id', "station != '000null' AND station != '' AND station IS NOT NULL");
528
		$where_milieu = $this->creerWhereIndicationGeo('milieu');
-
 
529
		$obs['milieu'] = $this->executerRequeteNombre('cel_inventory', 'id', $where_milieu);
521
		$obs['milieu'] = $this->executerRequeteNombre('cel_inventory', 'id', "milieu != '000null' AND milieu != '' AND milieu IS NOT NULL");
530
		$where_xy = $this->creerWhereIndicationGeo('coord_x').' AND '.$this->creerWhereIndicationGeo('coord_y');
Line 522... Line 531...
522
		$obs['coordonnée'] = $this->executerRequeteNombre('cel_inventory', 'id', "coord_x != '000null' AND coord_x != '' AND coord_x IS NOT NULL AND coord_y != '000null' AND coord_y != '' AND coord_y IS NOT NULL");
531
		$obs['coordonnée'] = $this->executerRequeteNombre('cel_inventory', 'id', $where_xy);
523
 
532
 
524
		$donnees = array();
533
		$donnees = array();
525
		$num = 1;
534
		$num = 1;
Line 550... Line 559...
550
			'chxl'	=> "0:|$etiquettes",
559
			'chxl'	=> "0:|$etiquettes",
551
			//'chxp'	=> '1,0,20,40,60,80,100',// Grille sous forme de cible
560
			//'chxp'	=> '1,0,20,40,60,80,100',// Grille sous forme de cible
552
			'chm'	=> 'B,FF000080,0,1.0,5.0');
561
			'chm'	=> 'B,FF000080,0,1.0,5.0');
553
		return $graph;
562
		return $graph;
554
	}
563
	}
-
 
564
	
-
 
565
	private function creerWhereIndicationGeo($champ) {
-
 
566
		$where = null;
-
 
567
		if (isset($champ)) {
-
 
568
			$where = "$champ != '000null' ".
-
 
569
				"AND $champ != '' ".
-
 
570
				"AND $champ IS NOT NULL ";
-
 
571
		}
-
 
572
		return $where;
-
 
573
	}
Line 555... Line 574...
555
 
574
 
556
	private function getUtilisationJournaliere($param) {
575
	private function getUtilisationJournaliere($param) {
557
		// Sur quel jour, voulons nous estimer l'utilisation
576
		// Sur quel jour, voulons nous estimer l'utilisation
558
		$aujourdhui = date('Y-m-d');
577
		$aujourdhui = date('Y-m-d');
Line 568... Line 587...
568
		$max_obs[] = $this->executerRequeteEvol('cel_inventory', 'id', '%Y%m%d',
587
		$max_obs[] = $this->executerRequeteEvol('cel_inventory', 'id', '%Y%m%d',
569
			"date_modification NOT LIKE '$aujourdhui%' ", 'date_modification');
588
			"date_modification NOT LIKE '$aujourdhui%' ", 'date_modification');
570
		$max_obs[] = $this->executerRequeteEvol('cel_inventory', 'id', '%Y%m%d',
589
		$max_obs[] = $this->executerRequeteEvol('cel_inventory', 'id', '%Y%m%d',
571
			"date_transmission NOT LIKE '$aujourdhui%' ", 'date_transmission');
590
			"date_transmission NOT LIKE '$aujourdhui%' ", 'date_transmission');
572
		$obs_aujourdhui = $this->executerRequeteNombre('cel_inventory', 'id',
591
		$obs_aujourdhui = $this->executerRequeteNombre('cel_inventory', 'id',
573
			"date_creation LIKE '$aujourdhui%'
592
			"(date_creation LIKE '$aujourdhui%'
574
				OR date_modification LIKE '$aujourdhui%'
593
				OR date_modification LIKE '$aujourdhui%'
575
				OR date_transmission LIKE '$aujourdhui%' ");
594
				OR date_transmission LIKE '$aujourdhui%') ");
576
 
595
		
577
		// Cummul des obs crées, modifiées, transmises par jour
596
		// Cummul des obs crées, modifiées, transmises par jour
578
		$donnees = array();
597
		$donnees = array();
579
		foreach ($max_obs as $obs_par_jour) {
598
		foreach ($max_obs as $obs_par_jour) {
580
			foreach ($obs_par_jour as $annee_mois_jour => $nbre) {
599
			foreach ($obs_par_jour as $annee_mois_jour => $nbre) {
581
				if (!isset($donnees[$annee_mois_jour])) {
600
				if (!isset($donnees[$annee_mois_jour])) {
Line 586... Line 605...
586
			}
605
			}
587
		}
606
		}
Line 588... Line 607...
588
 
607
 
589
		// Post traitement des données
608
		// Post traitement des données
590
		$valeur = $obs_aujourdhui;
609
		$valeur = $obs_aujourdhui;
591
		$valeur_max = 400;max($donnees);
610
		$valeur_max = 400;
592
		if ($valeur > $valeur_max) {
611
		if ($valeur > $valeur_max) {
593
			$pourcentage = 100;
612
			$pourcentage = 100;
594
		} else {
613
		} else {
595
			$pourcentage = round(($valeur / ($valeur_max / 100)), 0);
614
			$pourcentage = round(($valeur / ($valeur_max / 100)), 0);
Line 907... Line 926...
907
		$utilisateur = isset($_GET['utilisateur']) ? $this->bdd->quote($_GET['utilisateur']) : false;
926
		$utilisateur = isset($_GET['utilisateur']) ? $this->bdd->quote($_GET['utilisateur']) : false;
Line 908... Line 927...
908
		
927
		
909
		$requete = 	"SELECT DATE_FORMAT($champ_date, '$format_date') AS periode, COUNT($champ) AS nbre ".
928
		$requete = 	"SELECT DATE_FORMAT($champ_date, '$format_date') AS periode, COUNT($champ) AS nbre ".
910
					"FROM $table ".
929
					"FROM $table ".
911
					"WHERE $champ_date != '0000-00-00 00:00:00' ".
930
					"WHERE $champ_date != '0000-00-00 00:00:00' ".
912
					($utilisateur ? "	AND identifiant = $utilisateur " : '').
931
					(($utilisateur != false) ? " AND identifiant = $utilisateur " : '').
913
					((is_null($where)) ? '' : " AND $where ").
932
					((is_null($where)) ? '' : " AND $where ").
914
					'GROUP BY periode '.
933
					'GROUP BY periode '.
915
					((is_null($order_by)) ? '' : "ORDER BY $order_by ");
934
					((is_null($order_by)) ? '' : "ORDER BY $order_by ");
916
					((is_null($limit)) ? '' : "LIMIT $limit ");
935
					((is_null($limit)) ? '' : "LIMIT $limit ");
Line 924... Line 943...
924
 
943
 
925
		return $donnees_traitees;
944
		return $donnees_traitees;
Line 926... Line 945...
926
	}
945
	}
-
 
946
 
-
 
947
	private function executerRequeteNombre($table, $champ, $where = null) {
-
 
948
		$utilisateur = null;
-
 
949
		if (isset($_GET['utilisateur'])) {
-
 
950
			$utilisateur = $this->bdd->quote($_GET['utilisateur']);
-
 
951
			$where .= isset($where) ? ' AND ' : '';
-
 
952
			$where .= "identifiant = $utilisateur ";
927
 
953
		}
928
	private function executerRequeteNombre($table, $champ, $where = null) {
954
		
929
		$requete = 	"SELECT COUNT($champ) AS nbre ".
955
		$requete = 	"SELECT COUNT($champ) AS nbre ".
-
 
956
					"FROM $table ".
930
					"FROM $table ".
957
					((isset($where)) ? "WHERE $where " : '');
931
					((is_null($where)) ? '' : "WHERE $where ");
958
		
932
		$nbre = $this->executerRequete($requete, 'Column');
959
		$nbre = $this->executerRequete($requete, 'Column');
933
		return $nbre;
960
		return $nbre;
934
	}
961
	}