/branches/v1.3-beryllium/scripts/modules/adeterminer/Adeterminer.php |
---|
15,7 → 15,8 |
class Adeterminer extends DelScript { |
protected $parametres_autorises = array( |
'-t' => array(false, true, 'pour tester le script indiquer votre e-mail')); |
'-t' => array(false, true, 'Indiquez votre e-mail pour tester le script.'), |
'-d' => array(false, true, "Indiquer une date au format yyyy-mm-dd pour renvoyer l'alerte de cette date.")); |
public function executer() { |
try { |
/branches/v1.3-beryllium/scripts/modules/adeterminer/AlerteMailADeterminer.php |
---|
20,6 → 20,8 |
private $recapitulatifAdmin = []; |
private $messageRecapitulatif = null; |
private $dateRenvoi = null; |
private $observations_concernees = array(); |
private $messageHtml = null; |
private $messageTxt = null; |
32,6 → 34,7 |
public function executer() { |
try { |
$this->verifierModeUtilisation(); |
$this->verifierDateRenvoi(); |
$observations = $this->chargerObsADeterminer(); |
if (!empty($observations)) { |
$this->formaterObservations($observations); |
55,8 → 58,21 |
} |
} |
private function verifierDateRenvoi() { |
$dateRenvoi = $this->conteneur->getParametre('d'); |
if ($dateRenvoi) { |
if (preg_match('/^[0-9]{4}-[0-1][0-9]-[0-3][0-9]$/', $dateRenvoi)) { |
$this->dateRenvoi = $dateRenvoi; |
} else { |
$msg = "Veuillez indiquer une date au format yyyy-mm-dd valide à la suite du paramètre «-d»."; |
new Exception($msg); |
} |
} |
} |
protected function chargerObsADeterminer() { |
//TODO: optimiser la requête si beaucoup de mails sont envoyés |
$date = ($this->dateRenvoi == null) ? 'CURDATE()' : "'$this->dateRenvoi'"; |
$requete = "SELECT * ". |
"FROM del_obs_image AS doi ". |
" INNER JOIN del_observation AS do ON doi.id_observation = do.id_observation ". |
65,9 → 81,9 |
' OR nom_sel IS NULL OR nom_sel = "" '. |
' OR nom_ret IS NULL OR nom_ret = "") '. |
' AND ('. |
' do.date_transmission > DATE_SUB(CURDATE(), INTERVAL 1 DAY) '. |
' OR do.date_creation > DATE_SUB(CURDATE(), INTERVAL 1 DAY) '. |
' OR do.date_modification > DATE_SUB(CURDATE(), INTERVAL 1 DAY) '. |
" do.date_transmission > DATE_SUB($date, INTERVAL 1 DAY) ". |
" OR do.date_creation > DATE_SUB($date, INTERVAL 1 DAY) ". |
" OR do.date_modification > DATE_SUB($date, INTERVAL 1 DAY) ". |
' ) '. |
"ORDER BY do.id_observation "; |
$obs = $this->conteneur->getBdd()->recupererTous($requete); |
/branches/v1.3-beryllium/scripts/modules/commentaires/AlerteMailCommentaires.php |
---|
20,6 → 20,8 |
private $recapitulatifAdmin = []; |
private $messageRecapitulatif = null; |
private $dateRenvoi = null; |
private $observations_concernees = array(); |
private $correspondance_id_obs_auteurs = array(); |
private $utilisateursInfos = array(); |
31,6 → 33,7 |
public function executer() { |
try { |
$this->verifierModeUtilisation(); |
$this->verifierDateRenvoi(); |
$observations = $this->chargerObservationsCommentees(); |
if (!empty($observations)) { |
$this->formaterObservations($observations); |
55,9 → 58,23 |
} |
} |
private function verifierDateRenvoi() { |
$dateRenvoi = $this->conteneur->getParametre('d'); |
if ($dateRenvoi) { |
if (preg_match('/^[0-9]{4}-[0-1][0-9]-[0-3][0-9]$/', $dateRenvoi)) { |
$this->dateRenvoi = $dateRenvoi; |
} else { |
$msg = "Veuillez indiquer une date au format yyyy-mm-dd valide à la suite du paramètre «-d»."; |
new Exception($msg); |
} |
} |
} |
private function chargerObservationsCommentees() { |
// Seuls les utilisateurs ayant explicitement refusé le mail sont ignorés |
$preferences = $this->conteneur->getBdd()->proteger('%"mail_notification_mes_obs":"0"%'); |
$date = ($this->dateRenvoi == null) ? 'NOW()' : "'$this->dateRenvoi'"; |
//TODO: optimiser la requête si beaucoup de mails sont envoyés |
$requete = "SELECT * FROM del_observation AS do ". |
"WHERE do.id_observation IN ". |
74,7 → 91,7 |
" AND dc.ce_utilisateur = dob.ce_utilisateur ". |
" AND dc.ce_observation = dob.id_observation ". |
") ". |
"AND TO_DAYS(NOW()) - TO_DAYS(dc.date) <= 1 ". |
"AND TO_DAYS($date) - TO_DAYS(dc.date) <= 1 ". |
") ". |
"AND do.ce_utilisateur NOT IN ". |
"( ". |
157,6 → 174,8 |
protected function chargerCommentairesDuJour() { |
$preferences = $this->conteneur->getBdd()->proteger('%"mail_notification_mes_obs":"0"%'); |
$date = ($this->dateRenvoi == null) ? 'NOW()' : "'$this->dateRenvoi'"; |
// TODO: optimiser la requête si beaucoup de mails sont envoyés |
$requete = "SELECT * ". |
"FROM del_commentaire AS dc ". |
175,7 → 194,7 |
" FROM del_utilisateur_infos ". |
" WHERE preferences LIKE $preferences ". |
") ". |
"AND TO_DAYS(NOW()) - TO_DAYS(dc.date) <= 1 ". |
"AND TO_DAYS($date) - TO_DAYS(dc.date) <= 1 ". |
"ORDER BY dc.ce_observation"; |
$commentaires = $this->conteneur->getBdd()->recupererTous($requete); |
return $commentaires; |
/branches/v1.3-beryllium/scripts/modules/commentaires/Commentaires.php |
---|
15,7 → 15,8 |
class Commentaires extends DelScript { |
protected $parametres_autorises = array( |
'-t' => array(false, true, 'pour tester le script indiquer votre e-mail')); |
'-t' => array(false, true, 'Indiquez votre e-mail pour tester le script.'), |
'-d' => array(false, true, "Indiquer une date au format yyyy-mm-dd pour renvoyer l'alerte de cette date.")); |
public function executer() { |
try { |