Subversion Repositories eFlore/Applications.del

Rev

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

Rev 1741 Rev 1742
Line 18... Line 18...
18
	private $conteneur;
18
	private $conteneur;
19
	private $testeurCourriel = null;
19
	private $testeurCourriel = null;
20
	private $recapitulatifAdmin = [];
20
	private $recapitulatifAdmin = [];
21
	private $messageRecapitulatif = null;
21
	private $messageRecapitulatif = null;
Line -... Line 22...
-
 
22
 
-
 
23
	private $dateRenvoi = null;
22
 
24
 
23
	private $observations_concernees = array();
25
	private $observations_concernees = array();
24
	private $messageHtml = null;
26
	private $messageHtml = null;
25
	private $messageTxt = null;
27
	private $messageTxt = null;
Line 30... Line 32...
30
	}
32
	}
Line 31... Line 33...
31
 
33
 
32
	public function executer() {
34
	public function executer() {
33
		try {
35
		try {
-
 
36
			$this->verifierModeUtilisation();
34
			$this->verifierModeUtilisation();
37
			$this->verifierDateRenvoi();
35
			$observations = $this->chargerObsADeterminer();
38
			$observations = $this->chargerObsADeterminer();
36
			if (!empty($observations)) {
39
			if (!empty($observations)) {
37
				$this->formaterObservations($observations);
40
				$this->formaterObservations($observations);
38
				$this->genererMessage();
41
				$this->genererMessage();
Line 53... Line 56...
53
				new Exception($msg);
56
				new Exception($msg);
54
			}
57
			}
55
		}
58
		}
56
	}
59
	}
Line -... Line 60...
-
 
60
 
-
 
61
	private function verifierDateRenvoi() {
-
 
62
		$dateRenvoi = $this->conteneur->getParametre('d');
-
 
63
		if ($dateRenvoi) {
-
 
64
			if (preg_match('/^[0-9]{4}-[0-1][0-9]-[0-3][0-9]$/', $dateRenvoi)) {
-
 
65
				$this->dateRenvoi = $dateRenvoi;
-
 
66
			} else {
-
 
67
				$msg = "Veuillez indiquer une date au format yyyy-mm-dd valide à la suite du paramètre «-d».";
-
 
68
				new Exception($msg);
-
 
69
			}
-
 
70
		}
-
 
71
	}
57
 
72
 
58
	protected function chargerObsADeterminer() {
73
	protected function chargerObsADeterminer() {
-
 
74
		//TODO: optimiser la requête si beaucoup de mails sont envoyés
59
		//TODO: optimiser la requête si beaucoup de mails sont envoyés
75
		$date = ($this->dateRenvoi == null) ? 'CURDATE()' : "'$this->dateRenvoi'";
60
		$requete = "SELECT * ".
76
		$requete = "SELECT * ".
61
			"FROM del_obs_image AS doi ".
77
			"FROM del_obs_image AS doi ".
62
			"	INNER JOIN del_observation AS do ON doi.id_observation = do.id_observation ".
78
			"	INNER JOIN del_observation AS do ON doi.id_observation = do.id_observation ".
63
			"	LEFT JOIN del_utilisateur AS du ON do.ce_utilisateur = du.id_utilisateur AND do.ce_utilisateur != 0 ".
79
			"	LEFT JOIN del_utilisateur AS du ON do.ce_utilisateur = du.id_utilisateur AND do.ce_utilisateur != 0 ".
64
			'WHERE (do.mots_cles_texte LIKE "%aDeterminer%" '.
80
			'WHERE (do.mots_cles_texte LIKE "%aDeterminer%" '.
65
			'		OR nom_sel IS NULL OR nom_sel = "" '.
81
			'		OR nom_sel IS NULL OR nom_sel = "" '.
66
			'		OR nom_ret IS NULL OR nom_ret = "") '.
82
			'		OR nom_ret IS NULL OR nom_ret = "") '.
67
			'	AND ('.
83
			'	AND ('.
68
			'		do.date_transmission > DATE_SUB(CURDATE(), INTERVAL 1 DAY) '.
84
			"		do.date_transmission > DATE_SUB($date, INTERVAL 1 DAY) ".
69
			'		OR do.date_creation > DATE_SUB(CURDATE(), INTERVAL 1 DAY) '.
85
			"		OR do.date_creation > DATE_SUB($date, INTERVAL 1 DAY) ".
70
			'		OR do.date_modification > DATE_SUB(CURDATE(), INTERVAL 1 DAY) '.
86
			"		OR do.date_modification > DATE_SUB($date, INTERVAL 1 DAY) ".
71
			'	) '.
87
			'	) '.
72
			"ORDER BY do.id_observation ";
88
			"ORDER BY do.id_observation ";
73
		$obs = $this->conteneur->getBdd()->recupererTous($requete);
89
		$obs = $this->conteneur->getBdd()->recupererTous($requete);
74
		return $obs;
90
		return $obs;