public function afficheFormulaire($tabTravail = array(), $idAdresse = 0, $idHistoriqueAdresse = 0) { $pays = 0; $ville = 0; $quartier = 0; $sousQuartier = 0; $rue = 0; $formulaire = new formGenerator(); $t = new Template('modules/archi/templates/'); $t->set_filenames(array('adresseFormulaire' => 'adresseFormulaire.tpl')); if ($formulaire->estChiffre($idHistoriqueAdresse)) { if (count($tabTravail) == 0) { // copie pure et dure de la version un peu plus bas avec champ idAdresse // À simplifier en changeant juste la requête ! // À simplifier en changeant juste la requête ! // À simplifier en changeant juste la requête ! // À simplifier en changeant juste la requête ! // recuperation des donnees enregistree en cas de modification d'une adresse $resAdresse = $this->connexionBdd->requete("\n\t\t\t\t\t\tSELECT a.idAdresse as idAdresse, DATE_FORMAT(a.date,'%d/%m/%Y') as date, a.description as description, a.nom as nom, a.idHistoriqueAdresse as idHistoriqueAdresse,\n\t\t\t\t\t\ta.idRue as idRue, a.numero as numero, a.idQuartier as idQuartier, a.idSousQuartier as idSousQuartier, a.idPays as idPays,\n\t\t\t\t\t\ta.idVille as idVille\n\t\t\t\t\t\tFROM historiqueAdresse a, historiqueAdresse b\n\t\t\t\t\t\tWHERE a.idHistoriqueAdresse = '" . $idHistoriqueAdresse . "'\n\t\t\t\t\t\tLIMIT 1\n\t\t\t\t\t\t"); $tabTravail = array(); if (mysql_num_rows($resAdresse) == 1) { $fetchAdresse = mysql_fetch_array($resAdresse); $tabTravail = array('nom' => array('value' => $fetchAdresse['nom'], 'error' => ''), 'description' => array('value' => $fetchAdresse['description'], 'error' => ''), 'date' => array('value' => $fetchAdresse['date'], 'error' => ''), 'numero' => array('value' => $fetchAdresse['numero'], 'error' => ''), 'pays' => array('value' => $fetchAdresse['idPays'], 'error' => ''), 'ville' => array('value' => $fetchAdresse['idVille'], 'error' => ''), 'quartier' => array('value' => $fetchAdresse['idQuartier'], 'error' => ''), 'sousQuartier' => array('value' => $fetchAdresse['idSousQuartier'], 'error' => ''), 'rue' => array('value' => $fetchAdresse['idRue'], 'error' => '')); $pays = $fetchAdresse['idPays']; $ville = $fetchAdresse['idVille']; $quartier = $fetchAdresse['idQuartier']; $sousQuartier = $fetchAdresse['idSousQuartier']; $rue = $fetchAdresse['idRue']; $arrayAdresse = array(); if ($rue != 0) { $arrayAdresse = $this->getArrayAdresseFrom($rue, 'rue'); } elseif ($sousQuartier != 0) { // recuperation des infos du quartier, ville, pays du sousQuartier $arrayAdresse = $this->getArrayAdresseFrom($sousQuartier, 'sousQuartier'); } elseif ($quartier != 0) { // recuperation des infos ville, pays du quartier $arrayAdresse = $this->getArrayAdresseFrom($quartier, 'quartier'); } elseif ($ville != 0) { // recuperation des infos du pays de la ville $arrayAdresse = $this->getArrayAdresseFrom($ville, 'ville'); } elseif ($pays != 0) { $arrayAdresse = $this->getArrayAdresseFrom($pays, 'pays'); } if (count($arrayAdresse) > 0) { $pays = $arrayAdresse['pays']; $ville = $arrayAdresse['ville']; $quartier = $arrayAdresse['quartier']; $sousQuartier = $arrayAdresse['sousQuartier']; $rue = $arrayAdresse['rue']; } } } // assignation du bouton modifier $t->assign_vars(array('boutonSubmit' => 'Modifier')); $t->assign_vars(array('idAdresseModification' => $idAdresse)); $t->assign_vars(array('formAction' => $this->creerUrl('modifAdresse'))); } else { if ($formulaire->estChiffre($idAdresse)) { if (count($tabTravail) == 0) { // recuperation des donnees enregistree en cas de modification d'une adresse $resAdresse = $this->connexionBdd->requete("\n\t\t\t\t\t\tSELECT a.idAdresse as idAdresse, DATE_FORMAT(a.date,'%d/%m/%Y') as date, a.description as description, a.nom as nom, a.idHistoriqueAdresse as idHistoriqueAdresse,\n\t\t\t\t\t\ta.idRue as idRue, a.numero as numero, a.idQuartier as idQuartier, a.idSousQuartier as idSousQuartier, a.idPays as idPays,\n\t\t\t\t\t\ta.idVille as idVille\n\t\t\t\t\t\tFROM historiqueAdresse a, historiqueAdresse b\n\t\t\t\t\t\tWHERE b.idAdresse = a.idAdresse\n\t\t\t\t\t\tAND a.idAdresse = '" . $idAdresse . "'\n\t\t\t\t\t\tGROUP BY a.idAdresse,a.idHistoriqueAdresse\n\t\t\t\t\t\tHAVING a.idHistoriqueAdresse = max(b.idHistoriqueAdresse)\n\t\t\t\t\t\t"); $tabTravail = array(); if (mysql_num_rows($resAdresse) == 1) { $fetchAdresse = mysql_fetch_array($resAdresse); $tabTravail = array('nom' => array('value' => $fetchAdresse['nom'], 'error' => ''), 'description' => array('value' => $fetchAdresse['description'], 'error' => ''), 'date' => array('value' => $fetchAdresse['date'], 'error' => ''), 'numero' => array('value' => $fetchAdresse['numero'], 'error' => ''), 'pays' => array('value' => $fetchAdresse['idPays'], 'error' => ''), 'ville' => array('value' => $fetchAdresse['idVille'], 'error' => ''), 'quartier' => array('value' => $fetchAdresse['idQuartier'], 'error' => ''), 'sousQuartier' => array('value' => $fetchAdresse['idSousQuartier'], 'error' => ''), 'rue' => array('value' => $fetchAdresse['idRue'], 'error' => '')); $pays = $fetchAdresse['idPays']; $ville = $fetchAdresse['idVille']; $quartier = $fetchAdresse['idQuartier']; $sousQuartier = $fetchAdresse['idSousQuartier']; $rue = $fetchAdresse['idRue']; $arrayAdresse = array(); if ($rue != 0) { $arrayAdresse = $this->getArrayAdresseFrom($rue, 'rue'); } elseif ($sousQuartier != 0) { // recuperation des infos du quartier, ville, pays du sousQuartier $arrayAdresse = $this->getArrayAdresseFrom($sousQuartier, 'sousQuartier'); } elseif ($quartier != 0) { // recuperation des infos ville, pays du quartier $arrayAdresse = $this->getArrayAdresseFrom($quartier, 'quartier'); } elseif ($ville != 0) { // recuperation des infos du pays de la ville $arrayAdresse = $this->getArrayAdresseFrom($ville, 'ville'); } elseif ($pays != 0) { $arrayAdresse = $this->getArrayAdresseFrom($pays, 'pays'); } if (count($arrayAdresse) > 0) { $pays = $arrayAdresse['pays']; $ville = $arrayAdresse['ville']; $quartier = $arrayAdresse['quartier']; $sousQuartier = $arrayAdresse['sousQuartier']; $rue = $arrayAdresse['rue']; } } } // assignation du bouton modifier $t->assign_vars(array('boutonSubmit' => 'Modifier')); $t->assign_vars(array('idAdresseModification' => $idAdresse)); $t->assign_vars(array('formAction' => $this->creerUrl('modifAdresse'))); } else { // assignation du bouton ajout $t->assign_vars(array('boutonSubmit' => 'Ajouter')); $t->assign_vars(array('idAdresseModification' => '')); $t->assign_vars(array('formAction' => $this->creerUrl('ajoutAdresse'))); } } if (isset($this->variablesPost['pays'])) { $pays = $this->variablesPost['pays']; } if (isset($this->variablesPost['ville'])) { $ville = $this->variablesPost['ville']; } if (isset($this->variablesPost['quartier'])) { $quartier = $this->variablesPost['quartier']; } if (isset($this->variablesPost['sousQuartier'])) { $sousQuartier = $this->variablesPost['sousQuartier']; } if (isset($this->variablesPost['rue'])) { $rue = $this->variablesPost['rue']; } // recuperation des variables POST pour les passer au sous formulaire des adresses ( rue , pays ...) $arrayChoixAdresse = array(); if ($pays != '0') { $arrayChoixAdresse = array_merge(array('idPaysChoixAdresse' => $pays), $arrayChoixAdresse); } if ($ville != '0') { $arrayChoixAdresse = array_merge(array('idVilleChoixAdresse' => $ville), $arrayChoixAdresse); } if ($quartier != '0') { $arrayChoixAdresse = array_merge(array('idQuartierChoixAdresse' => $quartier), $arrayChoixAdresse); } if ($sousQuartier != '0') { $arrayChoixAdresse = array_merge(array('idSousQuartierChoixAdresse' => $sousQuartier), $arrayChoixAdresse); } if ($rue != '0') { $arrayChoixAdresse = array_merge(array('idRueChoixAdresse' => $rue), $arrayChoixAdresse); } $t->assign_vars(array('appelAjaxJavascript' => "<script >appelAjax('" . $this->creerUrl('', 'afficheChoixAdresse', array_merge(array('noHeaderNoFooter' => '1'), $arrayChoixAdresse)) . "','choixAdresse');</script>")); foreach ($tabTravail as $name => $value) { $t->assign_vars(array($name => $value["value"])); if ($value["error"] != '') { $t->assign_vars(array($name . "-error" => $value["error"] . ' : ' . $name)); } } ob_start(); $t->pparse('adresseFormulaire'); $html = ob_get_contents(); ob_end_clean(); return $html; }
public function afficherHistorique($idEvenement) { // // affiche la liste des modifications faites sur un événement // $html = ''; $formulaire = new formGenerator(); $string = new stringObject(); if ($formulaire->estChiffre($idEvenement)) { $sqlHistorique = 'SELECT titre, description, dateCreationEvenement, idHistoriqueEvenement FROM historiqueEvenement WHERE idEvenement=' . $idEvenement . ' ORDER BY dateCreationEvenement DESC'; if ($rep = $this->connexionBdd->requete($sqlHistorique)) { $t = new Template('modules/archi/templates'); $t->set_filenames(array('historiqueEvenement' => 'historiqueEvenement.tpl')); while ($res = mysql_fetch_object($rep)) { $t->assign_block_vars('historique', array('titre' => htmlspecialchars($res->titre), 'description' => pia_substr($string->sansBalises($res->description), 0, 50), 'url' => $this->creerUrl('', 'historiqueEvenementDetail', array('idHistoriqueEvenement' => $res->idHistoriqueEvenement)), 'dateModif' => $this->date->toFrench($res->dateCreationEvenement))); } ob_start(); $t->pparse('historiqueEvenement'); $html .= ob_get_contents(); ob_end_clean(); } } else { $html .= 'erreur chiffre'; } return $html; }
/** * Fonction qui affiche la liste des photos suivant les criteres fournis dans le tableau 'criteres' * * @param array $criteres Critères * * @return string HTML * */ public function afficherListe($criteres = array()) { $html = ''; $html .= $this->afficherFormulaireRecherche(); $formulaire = new formGenerator(); $t = new Template('modules/archi/templates/'); $t->set_filenames(array('detailImage' => 'listeImages.tpl')); $tabParametresAutorises = array('ordre', 'tri', 'nbEnregistrements', 'selection', 'id', "motCle", "dateUploadDu", "dateUploadAu", "datePriseDeVueDu", "datePriseDeVueAu", "pageCourante"); // lien pour l'ajout d'une ou plusieur images dans la bibliotheque , sans préciser si celle(s) ci appartient (iennent) à une adresse ou un evenement $t->assign_vars(array('lienAjoutImage' => $this->creerUrl('', 'ajoutImageBibliotheque'))); foreach ($tabParametresAutorises as $param) { if (isset($this->variablesPost[$param]) and !isset($criteres[$param])) { $criteres[$param] = $this->variablesPost[$param]; } } foreach ($tabParametresAutorises as $param) { if (isset($this->variablesGet[$param]) and !isset($criteres[$param])) { $criteres[$param] = $this->variablesGet[$param]; } } if (!isset($criteres['pageCourante'])) { $criteres['pageCourante'] = 1; } if (!isset($criteres['selection']) or !isset($criteres['id']) or $formulaire->estChiffre($criteres['id']) != 1) { $sqlWhere = '1=1'; } else { switch ($criteres['selection']) { case 'utilisateur': $sqlWhere = 'hI.idUtilisateur=' . $criteres['id']; break; default: $sqlWhere = '1=1'; } } if (!isset($criteres['ordre'])) { $sqlOrdre = 'hI.nom'; } else { switch ($criteres['ordre']) { case 'nom': $sqlOrdre = 'hI.nom'; break; case 'description': $sqlOrdre = 'hI.description'; break; case 'source': $sqlOrdre = 'nomSource'; break; case 'dateAjout': $sqlOrdre = 'hI.dateUpload'; break; default: $sqlOrdre = 'hI.nom'; } } if (isset($criteres['tri'])) { if ($criteres['tri'] == 'desc') { $sqlTri = 'DESC'; } else { $sqlTri = 'ASC'; } } else { $sqlTri = 'ASC'; } // *********************************** // criteres sur les dates // ********************************** $sqlRecherche = ""; // criteres sur les dates d'upload if (isset($criteres['dateUploadDu']) && $criteres['dateUploadDu'] != '' && (!isset($criteres['dateUploadAu']) || $criteres['dateUploadAu'] == '')) { $sqlRecherche .= " and hI.dateUpload='" . $this->date->toBdd($criteres['dateUploadDu']) . "' "; } if (isset($criteres['dateUploadDu']) && $criteres['dateUploadDu'] != '' && (!isset($criteres['dateUploadAu']) || $criteres['dateUploadAu'] == '')) { $sqlRecherche .= " and hI.dateUpload='" . $this->date->toBdd($criteres['dateUploadDu']) . "' "; } if (isset($criteres['dateUploadDu']) && $criteres['dateUploadDu'] != '' && isset($criteres['dateUploadAu']) && $criteres['dateUploadAu'] != '') { $sqlRecherche .= " and hI.dateUpload>='" . $this->date->toBdd($criteres['dateUploadDu']) . "' and hI.dateUpload<='" . $criteres['dateUploadAu'] . "' "; } // criteres sur les dates de prises de vues if (isset($criteres['datePriseDeVueDu']) && $criteres['datePriseDeVueDu'] != '' && (!isset($criteres['datePriseDeVuAu']) || $criteres['datePriseDeVuAu'] == '')) { $sqlRecherche .= " and hI.dateCliche='" . $this->date->toBdd($criteres['datePriseDeVueDu']) . "' "; } if (isset($criteres['datePriseDeVueDu']) && $criteres['datePriseDeVueDu'] != '' && (!isset($criteres['datePriseDeVueAu']) || $criteres['datePriseDeVueAu'] == '')) { $sqlRecherche .= " and hI.dateCliche='" . $this->date->toBdd($criteres['datePriseDeVueDu']) . "' "; } if (isset($criteres['datePriseDeVueDu']) && $criteres['datePriseDeVueDu'] != '' && isset($criteres['datePriseDeVueAu']) && $criteres['datePriseDeVueAu'] != '') { $sqlRecherche .= " and hI.dateCliche>='" . $criteres['datePriseDeVueDu'] . "' and hI.dateCliche<='" . $criteres['datePriseDeVueAu'] . "' "; } // criteres sur le nom/description if (isset($criteres['motCle']) && $criteres['motCle'] != '') { $sqlRecherche .= " and ( "; $arrayListeMots = explode(" ", $criteres['motCle']); foreach ($arrayListeMots as $indice => $value) { $sqlRecherche .= " hI.nom LIKE \"%" . $value . "%\" or hI.description LIKE \"%" . $value . "%\" or "; } if (count($arrayListeMots) > 0) { $sqlRecherche = substr($sqlRecherche, 0, pia_strlen($sqlRecherche) - 3); } $sqlRecherche .= ") "; } // ********************************** // nombre d'images totales //$sqlNbEnregistrements = "SELECT distinct idImage from historiqueImage WHERE ".$sqlWhere.; $sqlNbEnregistrements = "SELECT hI.nom, hI.idImage, CONCAT(hI.dateUpload, '/', hI.idHistoriqueImage) AS urlImage, hI.description, s.nom AS nomSource\n FROM historiqueImage hI2, historiqueImage hI\n LEFT JOIN source s USING (idSource)\n WHERE " . $sqlWhere . " AND hI.idImage = hI2.idImage\n " . $sqlRecherche . "\n GROUP BY hI.idImage, hI.idHistoriqueImage HAVING hI.idHistoriqueImage=MAX(hI2.idHistoriqueImage)\n ORDER BY " . $sqlOrdre . " " . $sqlTri; $resNbEnregistrements = $this->connexionBdd->requete($sqlNbEnregistrements); $nbEnregistrementTotaux = mysql_num_rows($resNbEnregistrements); // nombre d'images affichées sur une page $nbEnregistrementsParPage = 5; $arrayPagination = $this->pagination(array('nomParamPageCourante' => 'pageCourante', 'nbEnregistrementsParPage' => $nbEnregistrementsParPage, 'nbEnregistrementsTotaux' => $nbEnregistrementTotaux, 'typeLiens' => 'formulaire', 'champPageCourante' => 'pageCourante', 'idFormulaire' => 'rechercheImages')); echo $arrayPagination['html']; $sql = "SELECT hI.nom, hI.idImage, CONCAT(hI.dateUpload, '/', hI.idHistoriqueImage) AS urlImage, hI.description, s.nom AS nomSource\n FROM historiqueImage hI2, historiqueImage hI\n LEFT JOIN source s USING (idSource)\n WHERE " . $sqlWhere . " AND hI.idImage = hI2.idImage\n " . $sqlRecherche . "\n GROUP BY hI.idImage, hI.idHistoriqueImage HAVING hI.idHistoriqueImage=MAX(hI2.idHistoriqueImage)\n ORDER BY " . $sqlOrdre . " " . $sqlTri . " LIMIT " . $arrayPagination['limitSqlDebut'] . ", " . $nbEnregistrementsParPage; $rep = $this->connexionBdd->requete($sql); $t->assign_vars(array('nbReponses' => $nbEnregistrementTotaux)); if ($nbEnregistrementTotaux > 0) { $tabLiens = array(array('titre' => 'Image', 'url' => '', 'urlOnClick' => '', 'urlDesc' => '', 'urlDescOnClick' => '', 'urlAsc' => '', 'urlAscOnClick' => ''), array('titre' => 'nom', 'url' => $this->creerUrl('', '', array_merge($this->variablesGet, array('ordre' => 'nom', 'pageCourante' => 1))), 'urlOnClick' => '', 'urlDesc' => $this->creerUrl('', '', array_merge($this->variablesGet, array('ordre' => 'nom', 'pageCourante' => 1, 'tri' => 'desc'))), 'urlDescOnClick' => '', 'urlAsc' => $this->creerUrl('', '', array_merge($this->variablesGet, array('ordre' => 'nom', 'pageCourante' => 1, 'tri' => 'asc'))), 'urlAscOnClick' => ''), array('titre' => 'description', 'url' => $this->creerUrl('', '', array_merge($this->variablesGet, array('ordre' => 'description', 'pageCourante' => 1))), 'urlOnClick' => '', 'urlDesc' => $this->creerUrl('', '', array_merge($this->variablesGet, array('ordre' => 'description', 'pageCourante' => 1, 'tri' => 'desc'))), 'urlDescOnClick' => '', 'urlAsc' => $this->creerUrl('', '', array_merge($this->variablesGet, array('ordre' => 'description', 'pageCourante' => 1, 'tri' => 'asc'))), 'urlAscOnClick' => ''), array('titre' => 'source', 'url' => $this->creerUrl('', '', array_merge($this->variablesGet, array('ordre' => 'source', 'pageCourante' => 1))), 'urlOnClick' => '', 'urlDesc' => $this->creerUrl('', '', array_merge($this->variablesGet, array('ordre' => 'source', 'pageCourante' => 1, 'tri' => 'desc'))), 'urlDescOnClick' => '', 'urlAsc' => $this->creerUrl('', '', array_merge($this->variablesGet, array('ordre' => 'source', 'pageCourante' => 1, 'tri' => 'asc'))), 'urlAscOnClick' => '')); $nbLiens = count($tabLiens); for ($i = 0; $i < $nbLiens; $i++) { $t->assign_block_vars('liens', $tabLiens[$i]); } while ($res = mysql_fetch_object($rep)) { $t->assign_block_vars('image', array('url' => $this->creerUrl('', 'imageDetail', array('archiIdImage' => $res->idImage)), 'urlImage' => $this->getUrlImage("mini") . $res->urlImage, 'nom' => htmlspecialchars(stripslashes($res->nom)), 'description' => htmlspecialchars(stripslashes($res->description)), 'source' => $res->nomSource)); } } ob_start(); $t->pparse('detailImage'); $html .= ob_get_contents(); ob_end_clean(); return $html; }
/** * Affiche une source * * @param int $id ID de la source * * @return string HTML * */ public function afficher($id) { $html = ''; $formulaire = new formGenerator(); $bbCode = new bbCodeObject(); if ($formulaire->estChiffre($id) == 1) { $sqlId = $id; } else { echo _("Erreur, l'id n'est pas valide ! Id automatiquement défini"); $sqlId = '(SELECT MAX(idSource) FROM source)'; } $sql = "SELECT s.idSource, s.nom AS nomSource, s.idTypeSource, s.description, tS.nom AS nomTypeSource\n FROM source s \n LEFT JOIN typeSource tS USING (idTypeSource) \n WHERE idSource = " . $sqlId . " LIMIT 1"; if ($rep = $this->connexionBdd->requete($sql)) { $res = mysql_fetch_object($rep); $t = new Template('modules/archi/templates/'); $t->set_filenames(array('ev' => 'source.tpl')); $e = new archiEvenement(); $retourEvenement = $e->afficherListe(array('selection' => 'source', 'id' => $res->idSource)); $t->assign_vars(array('nom' => stripslashes($res->nomSource), 'nomType' => $res->nomTypeSource, 'description' => stripslashes($res->description), 'urlAjout' => $this->creerUrl('ajouterSource'), 'evenementLies' => $retourEvenement['html'])); ob_start(); $t->pparse('ev'); $html .= ob_get_contents(); ob_end_clean(); } else { echo _("Erreur, aucun résultat"); } return $html; }
/** * Afficher une personne * * @param int $id ID * * @return string HTML * */ public function afficher($id) { $html = ''; $formulaire = new formGenerator(); if ($formulaire->estChiffre($id) == 1) { $sql = 'SELECT p.nom as nom, p.prenom as prenom, m.nom as metier, p.idPersonne as idPersonne, p.dateNaissance as dateNaissance, p.dateDeces as dateDeces, p.description as description FROM personne p LEFT JOIN metier m ON m.idMetier = p.idMetier WHERE p.idPersonne=' . $id . ' LIMIT 1'; $rep = $this->connexionBdd->requete($sql); if (mysql_num_rows($rep) == 1) { $res = mysql_fetch_object($rep); $t = new Template('modules/archi/templates/'); $t->set_filenames(array('pe' => 'personne.tpl')); $e = new archiEvenement(); $t->assign_vars(array('prenom' => $res->prenom, 'nom' => $res->nom, 'metier' => $res->metier, 'dateNaissance' => $this->date->toFrench($res->dateNaissance), 'dateDeces' => $this->date->toFrench($res->dateDeces), 'description' => $res->description, 'urlAjout' => $this->creerUrl('ajouterPersonne'), 'evenementLies' => $e->afficherListe(array('selection' => 'personne', 'id' => $res->idPersonne)))); ob_start(); $t->pparse('pe'); $html .= ob_get_contents(); ob_end_clean(); } else { $html .= 'ERREUR aucun résultat !'; } } else { $html .= 'ERREUR mauvais ID!'; } return $html; }