| Line 31... |
Line 31... |
| 31 |
public function __construct(Conteneur $conteneur = null) {
|
31 |
public function __construct(Conteneur $conteneur = null) {
|
| 32 |
$this->conteneur = $conteneur == null ? new Conteneur() : $conteneur;
|
32 |
$this->conteneur = $conteneur == null ? new Conteneur() : $conteneur;
|
| 33 |
$this->conteneur->chargerConfiguration('config_departements_bruts.ini');
|
33 |
$this->conteneur->chargerConfiguration('config_departements_bruts.ini');
|
| 34 |
$this->conteneur->chargerConfiguration('config_observations.ini');
|
34 |
$this->conteneur->chargerConfiguration('config_observations.ini');
|
| 35 |
$this->conteneur->chargerConfiguration('config_mapping_votes.ini');
|
35 |
$this->conteneur->chargerConfiguration('config_mapping_votes.ini');
|
| - |
|
36 |
$this->conteneur->chargerConfiguration('config_mapping_commentaires.ini');
|
| 36 |
$this->navigation = $conteneur->getNavigation();
|
37 |
$this->navigation = $conteneur->getNavigation();
|
| 37 |
$this->masque = $conteneur->getMasque();
|
38 |
$this->masque = $conteneur->getMasque();
|
| 38 |
$this->gestionBdd = $conteneur->getGestionBdd();
|
39 |
$this->gestionBdd = $conteneur->getGestionBdd();
|
| 39 |
$this->bdd = $this->gestionBdd->getBdd();
|
40 |
$this->bdd = $this->gestionBdd->getBdd();
|
| 40 |
}
|
41 |
}
|
| Line 108... |
Line 109... |
| 108 |
* */
|
109 |
* */
|
| 109 |
private function configurer() {
|
110 |
private function configurer() {
|
| 110 |
$this->mappingFiltre = $this->conteneur->getParametre('mapping_masque');
|
111 |
$this->mappingFiltre = $this->conteneur->getParametre('mapping_masque');
|
| 111 |
$this->mappingObservation = $this->conteneur->getParametre('mapping_observation');
|
112 |
$this->mappingObservation = $this->conteneur->getParametre('mapping_observation');
|
| 112 |
$this->mappingVotes = $this->conteneur->getParametre('mapping_votes');
|
113 |
$this->mappingVotes = $this->conteneur->getParametre('mapping_votes');
|
| - |
|
114 |
$this->mappingCommentaire = $this->conteneur->getParametre('mapping_commentaire');
|
| 113 |
}
|
115 |
}
|
| Line 114... |
Line 116... |
| 114 |
|
116 |
|
| 115 |
/**
|
117 |
/**
|
| 116 |
* Vérifier que le service est bien configuré
|
118 |
* Vérifier que le service est bien configuré
|
| Line 143... |
Line 145... |
| 143 |
$erreurs[] = '- le mapping du champ "'.$champ.'" pour l\'observation est manquant ;';
|
145 |
$erreurs[] = '- le mapping du champ "'.$champ.'" pour l\'observation est manquant ;';
|
| 144 |
}
|
146 |
}
|
| 145 |
}
|
147 |
}
|
| 146 |
}
|
148 |
}
|
| Line -... |
Line 149... |
| - |
|
149 |
|
| - |
|
150 |
if (empty($this->mappingCommentaire)) {
|
| - |
|
151 |
$erreurs[] = '- le fichier de configuration ne contient pas le tableau [mapping_commentaire] ou celui-ci est vide ;';
|
| - |
|
152 |
} else {
|
| - |
|
153 |
$champsMappingCom = array('id_commentaire', 'texte', 'ce_utilisateur', 'utilisateur_nom', 'utilisateur_prenom', 'utilisateur_courriel', 'date');
|
| - |
|
154 |
foreach ($champsMappingCom as $champ) {
|
| - |
|
155 |
if (!isset($this->mappingCommentaire[$champ])) {
|
| - |
|
156 |
$erreurs[] = '- le mapping du champ "'.$champ.'" pour le commentaire est manquant ;';
|
| - |
|
157 |
}
|
| - |
|
158 |
}
|
| - |
|
159 |
}
|
| 147 |
|
160 |
|
| 148 |
if (empty($this->mappingFiltre)) {
|
161 |
if (empty($this->mappingFiltre)) {
|
| 149 |
$erreurs[] = '- le fichier de configuration ne contient pas le tableau [mapping_masque] ou celui-ci est vide ;';
|
162 |
$erreurs[] = '- le fichier de configuration ne contient pas le tableau [mapping_masque] ou celui-ci est vide ;';
|
| 150 |
} else {
|
163 |
} else {
|
| 151 |
$champsMappingFiltre = array('famille', 'ns', 'nn', 'date', 'tag', 'commune');
|
164 |
$champsMappingFiltre = array('famille', 'ns', 'nn', 'date', 'tag', 'commune');
|
| Line 445... |
Line 458... |
| 445 |
$observations[$id]['commentaires'] = $this->formaterDeterminations($propositions);
|
458 |
$observations[$id]['commentaires'] = $this->formaterDeterminations($propositions);
|
| 446 |
}
|
459 |
}
|
| 447 |
return $observations;
|
460 |
return $observations;
|
| 448 |
}
|
461 |
}
|
| Line 449... |
Line -... |
| 449 |
|
- |
|
| 450 |
private function formaterDeterminations($listePropositions) {
|
- |
|
| 451 |
|
- |
|
| 452 |
$propositions_format = array();
|
- |
|
| 453 |
if ($listePropositions != array()) {
|
- |
|
| 454 |
foreach ($listePropositions as $id => $proposition) {
|
- |
|
| 455 |
$propositions_format[$proposition['id_commentaire']] = $proposition;
|
- |
|
| 456 |
$propositions_format[$proposition['id_commentaire']]['nb_commentaires'] = "0";
|
- |
|
| 457 |
$ids_proposition[] = $proposition['id_commentaire'];
|
- |
|
| 458 |
}
|
- |
|
| 459 |
|
- |
|
| 460 |
$propositions_format = $this->chargerVotes($ids_proposition, $propositions_format);
|
- |
|
| 461 |
$propositions_format = $this->chargerNombreCommentaire($ids_proposition, $propositions_format);
|
- |
|
| 462 |
|
- |
|
| 463 |
}
|
- |
|
| 464 |
return $propositions_format;
|
- |
|
| 465 |
}
|
462 |
|
| 466 |
/**
|
463 |
/**
|
| 467 |
* Charger les votes sur les déterminations
|
464 |
* Charger les votes sur les déterminations
|
| 468 |
* @param Array $observations le tableau des observations à mettre à jour
|
465 |
* @param Array $observations le tableau des observations à mettre à jour
|
| 469 |
* */
|
466 |
* */
|
| Line 472... |
Line 469... |
| 472 |
$this->gestionBdd->formaterTable('del_commentaire_vote').
|
469 |
$this->gestionBdd->formaterTable('del_commentaire_vote').
|
| 473 |
'WHERE ce_proposition IN ('.implode(', ', $ids_proposition).')';
|
470 |
'WHERE ce_proposition IN ('.implode(', ', $ids_proposition).')';
|
| Line 474... |
Line 471... |
| 474 |
|
471 |
|
| 475 |
$resultatsVotes = $this->bdd->recupererTous($requeteVotes);
|
472 |
$resultatsVotes = $this->bdd->recupererTous($requeteVotes);
|
| 476 |
foreach ($resultatsVotes as $vote) {
|
473 |
foreach ($resultatsVotes as $vote) {
|
| 477 |
$propositions[$vote['ce_proposition']]['votes'][$vote['id_vote']] = $this->formaterVotes($vote);
|
474 |
$propositions[$vote['ce_proposition']]['votes'][$vote['id_vote']] = $this->formaterVote($vote);
|
| 478 |
}
|
475 |
}
|
| 479 |
return $propositions;
|
476 |
return $propositions;
|
| Line 480... |
Line 477... |
| 480 |
}
|
477 |
}
|
| Line 538... |
Line 535... |
| 538 |
$observation['images'] = array();
|
535 |
$observation['images'] = array();
|
| Line 539... |
Line 536... |
| 539 |
|
536 |
|
| 540 |
return $observation;
|
537 |
return $observation;
|
| Line 541... |
Line -... |
| 541 |
}
|
- |
|
| 542 |
|
538 |
}
|
| 543 |
|
539 |
|
| 544 |
/**
|
540 |
/**
|
| 545 |
* Formater le lien de l'image en fonction du fichier de config et de l'identifiant de l'image
|
541 |
* Formater le lien de l'image en fonction du fichier de config et de l'identifiant de l'image
|
| 546 |
* */
|
542 |
* */
|
| Line 550... |
Line 546... |
| 550 |
$urlImage = str_replace('%s', $idImage, $url);
|
546 |
$urlImage = str_replace('%s', $idImage, $url);
|
| 551 |
return $urlImage;
|
547 |
return $urlImage;
|
| 552 |
}
|
548 |
}
|
| Line 553... |
Line 549... |
| 553 |
|
549 |
|
| - |
|
550 |
/**
|
| - |
|
551 |
*
|
| - |
|
552 |
* Formate une liste de proposition en fonction du fichier de configuration
|
| - |
|
553 |
*/
|
| - |
|
554 |
private function formaterDeterminations($listePropositions) {
|
| - |
|
555 |
|
| - |
|
556 |
$propositions_format = array();
|
| - |
|
557 |
if ($listePropositions != array()) {
|
| - |
|
558 |
foreach ($listePropositions as $id => $proposition) {
|
| - |
|
559 |
$ids_proposition[] = $proposition['id_commentaire'];
|
| - |
|
560 |
|
| - |
|
561 |
$proposition_formatee = array('nb_commentaires' => "0");
|
| - |
|
562 |
foreach ($this->mappingCommentaire as $nomOriginal => $nomFinal) {
|
| - |
|
563 |
$proposition_formatee[$nomFinal] = $proposition[$nomOriginal];
|
| - |
|
564 |
}
|
| - |
|
565 |
$propositions_format[$proposition['id_commentaire']] = $proposition_formatee;
|
| - |
|
566 |
}
|
| - |
|
567 |
|
| - |
|
568 |
$propositions_format = $this->chargerVotes($ids_proposition, $propositions_format);
|
| - |
|
569 |
$propositions_format = $this->chargerNombreCommentaire($ids_proposition, $propositions_format);
|
| - |
|
570 |
|
| - |
|
571 |
}
|
| - |
|
572 |
return $propositions_format;
|
| - |
|
573 |
}
|
| - |
|
574 |
|
| 554 |
/**
|
575 |
/**
|
| 555 |
* Formater un vote en fonction du fichier de configuration config_votes.ini
|
576 |
* Formater un vote en fonction du fichier de configuration config_votes.ini
|
| 556 |
* @param $votes array()
|
577 |
* @param $votes array()
|
| 557 |
* */
|
578 |
* */
|
| 558 |
private function formaterVotes($vote) {
|
579 |
private function formaterVote($vote) {
|
| 559 |
$retour = array();
|
580 |
$retour = array();
|
| 560 |
foreach ($vote as $param=>$valeur) {
|
581 |
foreach ($vote as $param=>$valeur) {
|
| 561 |
$retour[$this->mappingVotes[$param]] = $valeur;
|
582 |
$retour[$this->mappingVotes[$param]] = $valeur;
|
| 562 |
}
|
583 |
}
|