Find this useful? Enter your email to receive occasional updates for securing PHP code.
Signing you up...
Thank you for signing up!
PHP Decode
<?php require_once("Recepisse.php"); class Declaration { /* TABLE DECLARATIO..
Decoded Output download
<?php
require_once("Recepisse.php");
class Declaration
{
/* TABLE DECLARATION */
public $idDeclaration,
$typeDeclaration,
$numConsultationTeleservice,
$numeroNationalDT,
$numeroNationalDICT,
$numeroNationalATU,
$noAffaireRDP,
$noAffaireExec,
$natureTravaux,
$techniquesUtilisees,
$profondeurMax,
$URLfichierXML,
$URLfichierPDF,
$URLfichierEML,
$description,
$adresse,
$nombreCommunes,
$codePostal,
$commune,
$dateDebutPrevue,
$dureeChantierPrevue,
$traceGML,
$techniquesSansTranchees,
$plansElectriquesAeriens,
$modificationProfilTerrain,
$personneContactTravaux,
$telephoneContactTravaux,
$faxContactTravaux,
$courrielContactTravaux,
$personneContactProjet,
$telephoneContactProjet,
$faxContactProjet,
$courrielContactProjet;
// Attributs spcifiques aux ATU :
public $chantierTermineOuAVenir,
$justificationUrgence;
public $dateReceptionDeclaration;
/* Attributs de la table Instruction */
public $instIdDeclaration,
$etat,
$idRecepisse,
$idAgentInstructeur,
$idAgentSignataire;
/* Attributs de la table Executant */
public $idExecutant,
$execDenomination,
$execNumSIRET,
$execComplement,
$execNumeroVoie,
$execVoie,
$execComplementAdresse,
$execCodePostal,
$execAdresse, // Pour l'ATU o l'adresse est en un seul attribut
$execCommune,
$execPays,
$execMail,
$execTelephone,
$execFax;
/* Attributs de la table ResponsableProjet */
public $idRDP,
$rdpDenomination,
$rdpNumSIRET,
$rdpComplement,
$rdpNumeroVoie,
$rdpVoie,
$rdpComplementAdresse,
$rdpCodePostal,
$rdpCommune,
$rdpPays,
$rdpMail,
$rdpFax,
$rdpTelephone;
public $XML; //Objet XML initialis avec le fichier XML de dclaration
private $pdo; // Objet PDO de connexion la base de donnes
private $namespace; // Namespace XML
/**
* Permet d'initialiser une dclaration partir d'un fichier XML pass en paramtre
* <ul>
*
* </ul>
* @param string $URLfichierXML URL du fichier XML de la dclaration
* @param timestamp $dateReceptionDeclaration Date de rception de la dclaration
*
* @return `true` si le traitement s'est bien pass `false` sinon (la dclaration est dj en base par exemple)
*/
public function initialiserDeclarationXML($URLfichierXML, $dateReceptionDeclaration = null){
// Chargement fichier XML dans l'objet XML
$this->XML = simplexml_load_file($URLfichierXML);
// Dfinition du namespace pour XPATH
$this->XML->registerXPathNamespace('t',"http://www.reseaux-et-canalisations.gouv.fr/schema-teleservice/2.2");
$this->namespace = 't:';
// Si $dateReception non renseigne, alors dfinie maintenant
if(is_null($dateReceptionDeclaration)){
$this->dateReceptionDeclaration = time();
} else{
$this->dateReceptionDeclaration = $dateReceptionDeclaration;
}
// On dtermine le type de dclaration
$this->determinerTypeDeclaration();
// On rcupre les numros de dclaration
$this->recupererNumerosDeclaration();
if($this->determinerDejaBase()){
// La dclaration est dj en base, on interrompt le traitement, on retourne false
return false;
}
// else : la dclaration n'est pas dj dans la base
// Recupre les diffrentes donnes du XML
$this->recuperer();
// Cre les diffrentes lignes dans la BD en fonction de la rcupration
$this->entrerDeclarationBD();
return true;
}
/**
* Dtermine le type de dclaration
* <ul>
* <li>dtDictConjointes</li>
* <li>DT</li>
* <li>DICT</li>
* <li>ATU</li>
* </ul>
* @return `true` si l'on a pu affecter le type de dclaration
`false` sinon
*/
public function determinerTypeDeclaration(){
/* On effectue des requtes XPath avec le nom de l'lment juste
* au dessus de la racine du fichier
*/
if(!empty($this->XML->xpath("//$this->namespace" . "dtDictConjointes"))){
$this->typeDeclaration = 'dtDictConjointes';
} else if(!empty($this->XML->xpath("//$this->namespace" ."DT"))){
$this->typeDeclaration = 'DT';
} else if(!empty($this->XML->xpath("//$this->namespace" ."DICT"))){
$this->typeDeclaration = 'DICT';
} else if(!empty($this->XML->xpath("//$this->namespace" . "ATU"))){
$this->typeDeclaration = 'ATU';
}
}
/**
* Rcupre les informations ncessaires en fonction du type de dclaration
*
*/
public function recuperer(){
switch($this->typeDeclaration){
case "dtDictConjointes":
// Attributs pour la table Declaration
// La dclaration est dj en base !
$this->recupererDescription();
$this->recupererNatureTravaux();
$this->recupererAdresse();
$this->recupererCodePostal();
$this->recupererCommune();
$this->recupererTraceGML();
$this->recupererNombreCommunes();
$this->recupererInformationsContactActeurs();
$this->recupererDateDebutPrevue();
$this->recupererDureeChantierPrevue();
/*
* Attributs pour les tables ResponsableProjet
* et Executant
*/
$this->recupererInfosActeurs();
/*
* Attributs "spciaux" uniquement prsents pour
* les DT-DICT, DT et DICT
*/
$this->recupererModificationProfilTerrain();
$this->recupererTechniquesSansTranchees();
$this->recupererPlansElectriquesAeriens();
$this->recupererTechniquesUtilisees();
$this->recupererNoAffaireDeclarant();
$this->recupererProfondeurMax();
break;
case "DT":
// Attributs pour la table Declaration
$this->recupererDescription();
$this->recupererNatureTravaux();
$this->recupererAdresse();
$this->recupererCodePostal();
$this->recupererCommune();
$this->recupererTraceGML();
$this->recupererNombreCommunes();
$this->recupererInformationsContactActeurs();
$this->recupererDateDebutPrevue();
$this->recupererDureeChantierPrevue();
/*
* Attributs pour les tables ResponsableProjet
* et Executant
*/
$this->recupererInfosActeurs();
/*
* Attributs "spciaux" uniquement prsents pour
* les DT-DICT, DT et DICT
*/
$this->recupererModificationProfilTerrain();
$this->recupererTechniquesSansTranchees();
$this->recupererPlansElectriquesAeriens();
$this->recupererTechniquesUtilisees();
$this->recupererNoAffaireDeclarant();
$this->recupererProfondeurMax();
break;
case "DICT":
// Attributs pour la table Declaration
$this->recupererDescription();
$this->recupererNatureTravaux();
$this->recupererAdresse();
$this->recupererCodePostal();
$this->recupererCommune();
$this->recupererTraceGML();
$this->recupererNombreCommunes();
$this->recupererInformationsContactActeurs();
$this->recupererDateDebutPrevue();
$this->recupererDureeChantierPrevue();
/*
* Attributs pour les tables ResponsableProjet
* et Executant
*/
$this->recupererInfosActeurs();
/*
* Attributs "spciaux" uniquement prsents pour
* les DT-DICT, DT et DICT
*/
$this->recupererModificationProfilTerrain();
$this->recupererTechniquesSansTranchees();
$this->recupererPlansElectriquesAeriens();
$this->recupererTechniquesUtilisees();
$this->recupererNoAffaireDeclarant();
$this->recupererProfondeurMax();
break;
case "ATU":
$this->recupererDescription();
$this->recupererAdresse();
$this->recupererCodePostal();
$this->recupererCommune();
$this->recupererTraceGML();
$this->recupererNombreCommunes();
$this->recupererInformationsContactActeurs();
$this->recupererDateDebutPrevue();
$this->recupererDureeChantierPrevue();
$this->recupererInfosActeurs();
$this->recupererJustificationUrgence();
$this->recupererChantierTermineOuAVenir();
break;
default:
/*
* Le type de dclaration ne correspond aucun type connu
* c'est une erreur, on retourne `false`
*/
return false;
}
return true; // le traitement s'est bien pass
}
/*
* Dtermine le numro de dclaration (numro de consultation du tlservice)
* et l'affecte aux champs correspondant la demande (`$numeroNationalDT`,
* `$numeroNationalDICT`, `$numeroNationalATU`)
* <ul>
* <li>Si la dclaration est une DT-DICT alors on affecte le numro aux
* deux champs `$numeroNationalDT` et `$numeroNationalDICT`</li>
* <li>Si la dclaration est une DT alors on affecte le numro au champ
* `$numeroNationalDT`</li>
* <li>Si la dclaration est une DICT alors on affecte le numro au champ
* `$numeroNationalDICT`</li>
* <li>Si la dclaration est une ATU alors on affecte le numro au champ
* `$numeroNationalATU`</li>
* </ul>
* @return bool `true` si l'on a affect la valeur, `false` si une erreur
* est survenue
*/
public function recupererNumerosDeclaration(){
$listeNumeros = $this->XML->xpath("//$this->namespace" . "noConsultationDuTeleservice");
/*
* Dans certains fichiers XML, le numro de consultation est nomm "noConsultationDuTeleserviceSeize"
* alors, si la premire requte XPath n'a rien retourn (a retourn la chane vide), alors on essaie avec
* le deuxime nom (noConsultationDuTeleserviceSeize)
*/
if(!$listeNumeros){
$listeNumeros = $this->XML->xpath("//$this->namespace" . "noConsultationDuTeleserviceSeize");
}
/* Il y a plusieurs occurences du mme numro dans le fichier,
* on prend le premier
*/
$numeroConsultationTeleservice = $listeNumeros[0];
$this->numConsultationTeleservice = $numeroConsultationTeleservice;
switch($this->typeDeclaration){
case "dtDictConjointes":
/* Prsence d'une DT-DICT, on fixe les deux numros DT et DICT
*/
$this->numeroNationalDT = $numeroConsultationTeleservice;
$this->numeroNationalDICT = $numeroConsultationTeleservice;
break;
case "DT":
/* Prsence DT, on fixe seulement le numro DT */
$this->numeroNationalDT = $numeroConsultationTeleservice;
break;
case "DICT":
/* Prsence DICT, on fixe seulement le numro DICT */
$this->numeroNationalDICT = $numeroConsultationTeleservice;
break;
case "ATU":
/* Prsence ATU, on fixe seulement le numro ATU */
$this->numeroNationalATU = $numeroConsultationTeleservice;
break;
default:
/*
* Le type de dclaration ne correspond aucun type connu
* c'est une erreur, on retourne `false`
*/
return false;
}
return true; // Le traitement s'est bien pass
}
/**
* Rcupre la description d'une Dclaration et l'affecte dans la variable
* `$description`
* <ul>
* <li>Si la dclaration est une DT-DICT alors on rcupre la
* description des travaux</li>
* <li>Si la dclaration est une DT alors on rcupre la description
* du projet</li>
* <li>Si la dclaration est une DICT alors on rcupre la
* description des travaux</li>
* <li>Si la dclaration est un ATU, alors on rcupre la seule
* description disponible</li>
* </ul>
* @return bool `true` si l'on a affect la valeur, `false` si une erreur
* est survenue
*/
public function recupererDescription(){
switch($this->typeDeclaration){
case "dtDictConjointes":
$this->description = $this->XML->xpath("//$this->namespace" . "decrivezLesTravaux")[0];
break;
case "DT":
$this->description = $this->XML->xpath("//$this->namespace" . "decrivezLeProjet")[0];
break;
case "DICT":
$this->description = $this->XML->xpath("//$this->namespace" . "decrivezLesTravaux")[0];
break;
case "ATU":
$this->description = $this->XML->xpath("//$this->namespace". "travauxEmplacementDureeDescription/". $this->namespace . "travauxEtMoyensMisEnOeuvre")[0];
default:
/*
* Le type de dclaration ne correspond aucun type connu
* c'est une erreur, on retourne `false`
*/
return false;
}
return true; // le traitement s'est bien pass
}
/**
* Rcupre la nature des travaux :
* Dans le formulaire, la nature des travaux est crite sous la forme d'une
* liste d'abrviations de 3 caractres (la signification de ces
* abrviations est disponible dans l'explication du formulaire DT-DICT,
* CERFA n14434*03)
* La liste est constuite sous la forme XXX , XXX , XXX , ...
* Par exemple : FOV , CHA , RBL , TER
*
* @return bool `true` si l'on a affect la valeur, `false` si une erreur
* est survenue
*/
public function recupererNatureTravaux(){
switch($this->typeDeclaration){
case "dtDictConjointes":
$tblNatures = $this->XML->xpath("//$this->namespace" . "travauxEtLeurCalendrier/". $this->namespace."natureDesTravaux");
$this->natureTravaux = implode(" , ", $tblNatures);
break;
case "DT":
$tblNatures = $this->XML->xpath("//$this->namespace" . "projetEtSonCalendrier/". $this->namespace. "natureDesTravaux");
$this->natureTravaux = implode(" , ", $tblNatures);
break;
case "DICT":
$tblNatures = $this->XML->xpath("//$this->namespace" . "travauxEtLeurCalendrier/". $this->namespace. "natureDesTravaux");
$this->natureTravaux = implode(" , ", $tblNatures);
break;
case "ATU":
break;
default:
/*
* Le type de dclaration ne correspond aucun type connu
* c'est une erreur, on retourne `false`
*/
return false;
}
}
/**
* Rcupre les techniques utilises pour les travaux :
* Dans le formulaire, les techniques utilises pour les travaux
* sont crites sous la forme d'une liste d'abrviations de 3 caractres
* (la signification de ces abrviations est disponible dans l'explication
* du formulaire DT-DICT, CERFA n14434*03)
*
* La liste est constuite sous la forme XXX , XXX , XXX , ...
* Par exemple : BTO , STA , TUN , ECL
*
* @return bool `true` si l'on a affect la valeur, `false` si une erreur
* est survenue
*/
public function recupererTechniquesUtilisees(){
switch($this->typeDeclaration){
case "dtDictConjointes":
$tblTechniques = $this->XML->xpath("//$this->namespace" . "travauxEtLeurCalendrier/". $this->namespace."techniquesUtilisees");
$this->techniquesUtilisees = implode(" , ", $tblTechniques);
break;
case "DT":
$tblTechniques = $this->XML->xpath("//$this->namespace" . "projetEtSonCalendrier/". $this->namespace. "techniquesUtilisees");
$this->techniquesUtilisees = implode(" , ", $tblTechniques);
break;
case "DICT":
$tblTechniques = $this->XML->xpath("//$this->namespace" . "travauxEtLeurCalendrier/". $this->namespace. "techniquesUtilisees");
$this->techniquesUtilisees = implode(" , ", $tblTechniques);
break;
case "ATU":
// La valeur n'est pas disponible dans un ATU
break;
default:
/*
* Le type de dclaration ne correspond aucun type connu
* c'est une erreur, on retourne `false`
*/
return false;
}
return true;
}
/**
* Rcupre l'adresse des travaux / du projet
*
* <ul>
* <li>Si la dclaration est une DT-DICT alors on rcupre l'adresse
* des travaux</li>
* <li>Si la dclaration est une DT alors on rcupre l'adresse
* du projet</li>
* <li>Si la dclaration est une DICT alors on rcupre l'adresse des
* travaux</li>
* <li>Si la dclaration est un ATU, alors on rcupre la seule
* description disponible</li>
* </ul>
*
* @return bool `true` si l'on a affect la valeur, `false` si une erreur
* est survenue
*/
public function recupererAdresse(){
/*
* On rcupre l'adresse en fonction du type de dclaration,
* car l'emplacement dans l'arborescence est diffrent pour chaque type
* de dclaration
*/
switch($this->typeDeclaration){
case "dtDictConjointes":
$this->adresse = $this->XML->xpath("//$this->namespace"."emplacementDesTravaux/". $this->namespace. "adresse")[0];
break;
case "DT":
$this->adresse = $this->XML->xpath("//$this->namespace"."emplacementDuProjet/". $this->namespace. "adresse")[0];
break;
case "DICT":
$this->adresse = $this->XML->xpath("//$this->namespace"."emplacementDesTravaux/". $this->namespace. "adresse")[0];
break;
case "ATU":
$this->adresse = $this->XML->xpath("//$this->namespace"."travauxEmplacementDureeDescription/". $this->namespace. "adresse")[0];
break;
default:
/*
* Le type de dclaration ne correspond aucun type connu
* c'est une erreur, on retourne `false`
*/
return false;
}
return true; // le traitement s'est bien pass
}
/**
* Rcupre le code postal du lieu des travaux / du projet
*
* @return bool `true` si l'on a affect la valeur, `false` si une erreur
* est survenue
*/
public function recupererCodePostal(){
switch($this->typeDeclaration){
case "dtDictConjointes":
$this->codePostal = $this->XML->xpath("//$this->namespace"."emplacementDesTravaux/". $this->namespace. "CP")[0];
break;
case "DT":
$this->codePostal = $this->XML->xpath("//$this->namespace"."emplacementDuProjet/". $this->namespace. "CP")[0];
break;
case "DICT":
$this->codePostal = $this->XML->xpath("//$this->namespace"."emplacementDesTravaux/". $this->namespace. "CP")[0];
break;
case "ATU":
$this->codePostal = $this->XML->xpath("//$this->namespace"."travauxEmplacementDureeDescription/". $this->namespace. "codePostal")[0];
break;
default:
/*
* Le type de dclaration ne correspond aucun type connu
* c'est une erreur, on retourne `false`
*/
return false;
}
return true; // le traitement s'est bien pass
}
/**
* Rcupre la commune des travaux / du projet
*
* @return bool `true` si l'on a affect la valeur, `false` si une erreur
* est survenue
*/
public function recupererCommune(){
switch($this->typeDeclaration){
case "dtDictConjointes":
$this->commune = $this->XML->xpath("//$this->namespace"."emplacementDesTravaux/". $this->namespace. "communePrincipale")[0];
break;
case "DT":
$this->commune = $this->XML->xpath("//$this->namespace"."emplacementDuProjet/". $this->namespace. "communePrincipale")[0];
break;
case "DICT":
$this->commune = $this->XML->xpath("//$this->namespace"."emplacementDesTravaux/". $this->namespace. "communePrincipale")[0];
break;
case "ATU":
$this->commune = $this->XML->xpath("//$this->namespace"."travauxEmplacementDureeDescription/". $this->namespace. "commune")[0];
break;
default:
/*
* Le type de dclaration ne correspond aucun type connu
* c'est une erreur, on retourne `false`
*/
return false;
}
return true; // le traitement s'est bien pass
}
/**
* Rcupre le polygone dcrivant la zone des travaux (au format GML)
* <ul>
* <li>Si la dclaration est une DT, on rcupre le polygone de
* la partie DT</li>
* <li>Si la dclaration est une DICT, on rcupre le polygone de
* la partie DICT</li>
* <li>Si la dclaration est une DT-DICT, on rcupre le polygone de
* la partie DICT</li>
* @return `bool true` si le traitement s'est bien pass, `false` sinon
* </ul>
*/
public function recupererTraceGML(){
switch($this->typeDeclaration){
case "dtDictConjointes":
$tblTraceGML = $this->XML->xpath("//$this->namespace". "emprise/". $this->namespace. "geometrie//*");
$this->traceGML = implode(" , ", $tblTraceGML);
break;
case "DT":
$tblTraceGML = $this->XML->xpath("//$this->namespace". "emprise/". $this->namespace. "geometrie//*");
$this->traceGML = implode(" , ", $tblTraceGML);
break;
case "DICT":
$tblTraceGML = $this->XML->xpath("//$this->namespace". "emprise/". $this->namespace. "geometrie//*");
$this->traceGML = implode(" , ", $tblTraceGML);
break;
case "ATU":
break;
default:
/*
* Le type de dclaration ne correspond aucun type connu
* c'est une erreur, on retourne `false`
*/
return false;
}
return true; // le traitement s'est bien pass
}
/**
* Rcupre les informations des acteurs de la dclaration :
*
* <ul>
* <li>Si la dclaration est une DT, on rcupre les informations
* du responsable de projet.</li>
* <li>Si la dclaration est une DICT, on rcupre les informations
* de l'excutant de travaux.</li>
* <li>Si la dclaration est une DT-DICT, alors on rcupre toutes
* les informations (responsable de projet
* et excutant de travaux).</li>
* <li>Si la dclaration est un ATU, alors on rcupre les informations
* disponibles sur le formulaire (le commanditaire de travaux)</li>
*
* @return bool `true` si l'on a affect la valeur, `false` si une erreur
* est survenue
*/
public function recupererInformationsContactActeurs(){
switch($this->typeDeclaration){
case "dtDictConjointes":
/* Rcupration des informations:
* - de la personne contacter (DICT, excutant de travaux)
* - du reprsentant du reponsable de projet (DT, Responsable de projet)
*/
$this->personneContactTravaux = trim($this->XML->xpath("//$this->namespace"."executantDesTravaux/". $this->namespace. "nomDeLaPersonneAContacter")[0]);
$this->telephoneContactTravaux = trim($this->XML->xpath("//$this->namespace"."executantDesTravaux/". $this->namespace. "tel")[0]);
$this->faxContactTravaux = trim($this->XML->xpath("//$this->namespace"."executantDesTravaux/". $this->namespace. "fax")[0]);
$this->courrielContactTravaux = trim($this->XML->xpath("//$this->namespace"."executantDesTravaux/". $this->namespace. "courriel")[0]);
$this->personneContactProjet = trim($this->XML->xpath("//$this->namespace"."representantDuResponsableDeProjet/". $this->namespace. "denomination")[0]);
$this->telephoneContactProjet = trim($this->XML->xpath("//$this->namespace"."representantDuResponsableDeProjet/". $this->namespace. "tel")[0]);
$this->faxContactProjet = trim($this->XML->xpath("//$this->namespace"."representantDuResponsableDeProjet/". $this->namespace. "fax")[0]);
$this->courrielContactProjet = trim($this->XML->xpath("//$this->namespace"."representantDuResponsableDeProjet/". $this->namespace. "courriel")[0]);
break;
case "DT":
$this->personneContactProjet = trim($this->XML->xpath("//$this->namespace"."representantDuResponsableDeProjet/". $this->namespace. "denomination")[0]);
$this->telephoneContactProjet = trim($this->XML->xpath("//$this->namespace"."representantDuResponsableDeProjet/". $this->namespace. "tel")[0]);
$this->faxContactProjet = trim($this->XML->xpath("//$this->namespace"."representantDuResponsableDeProjet/". $this->namespace. "fax")[0]);
$this->courrielContactProjet = trim($this->XML->xpath("//$this->namespace"."representantDuResponsableDeProjet/". $this->namespace. "courriel")[0]);
break;
case "DICT":
$this->personneContactTravaux = trim($this->XML->xpath("//$this->namespace"."executantDesTravaux/". $this->namespace. "nomDeLaPersonneAContacter")[0]);
$this->telephoneContactTravaux = trim($this->XML->xpath("//$this->namespace"."executantDesTravaux/". $this->namespace. "tel")[0]);
$this->faxContactTravaux = trim($this->XML->xpath("//$this->namespace"."executantDesTravaux/". $this->namespace. "fax")[0]);
$this->courrielContactTravaux = trim($this->XML->xpath("//$this->namespace"."executantDesTravaux/". $this->namespace. "courriel")[0]);
break;
case "ATU":
$this->personneContactTravaux = trim($this->XML->xpath("//$this->namespace"."personneOrdonnantLesTravauxUrgents/". $this->namespace. "nom")[0]);
$this->telephoneContactTravaux = trim($this->XML->xpath("//$this->namespace"."personneOrdonnantLesTravauxUrgents/". $this->namespace. "tel")[0]);
$this->faxContactTravaux = trim($this->XML->xpath("//$this->namespace"."personneOrdonnantLesTravauxUrgents/". $this->namespace. "fax")[0]);
$this->courrielContactTravaux = trim($this->XML->xpath("//$this->namespace"."personneOrdonnantLesTravauxUrgents/". $this->namespace. "courriel")[0]);
break;
default:
/*
* Le type de dclaration ne correspond aucun type connu
* c'est une erreur, on retourne `false`
*/
return false;
}
return true; // le traitement s'est bien pass
}
/**
* Permet de rcuprer les informations des diffrents acteurs prsents dans la dclaration en fonction de son type :
* <ul>
* <li>Si la dclaration est une DT, alors on rcupre les informations du responsable de projet.</li>
* <li>Si la dclaration est une DICT, alors on rcupre les informations de l'excutant de travaux.</li>
* <li>Si la dclaration est une DT-DICT, alors on rcupre les informations des deux.</li>
* <li>Si la dclaration est un ATU, alors on rcupre les informations de l'acteur prsent.</li>
* </ul>
* Ces informations ont vocation tre entres dans les tables `responsableProjet` et `executant`
*
*
* @return `bool true` si le traitement s'est bien pass, `false` sinon.
*/
public function recupererInfosActeurs(){
switch($this->typeDeclaration){
case "dtDictConjointes":
$this->recupererInformationsResponsableProjet();
$this->recupererInformationsExecutantTravaux();
/* $this->afficherAttributsExecTravaux();
$this->afficherAttributsRDP(); */
break;
case "DT":
$this->recupererInformationsResponsableProjet();
/* $this->afficherAttributsRDP(); */
break;
case "DICT":
$this->recupererInformationsExecutantTravaux();
/* $this->afficherAttributsExecTravaux(); */
break;
case "ATU":
$this->recupererInformationsATU();
/* $this->afficherAttributsExecTravaux();
$this->afficherAttributsRDP(); */
break;
default:
/*
* Le type de dclaration ne correspond aucun type connu
* c'est une erreur, on retourne `false`
*/
return false;
}
return true; // le traitement s'est bien pass
}
public function recupererInformationsResponsableProjet(){
$this->rdpDenomination = $this->XML->xpath("//$this->namespace"."responsableDuProjet/". $this->namespace. "denomination")[0];
$this->rdpNumSIRET = $this->XML->xpath("//$this->namespace"."responsableDuProjet/". $this->namespace. "noSIRET")[0];
$this->rdpComplement = $this->XML->xpath("//$this->namespace"."representantDuResponsableDeProjet/". $this->namespace. "complementService")[0];
$this->rdpNumeroVoie = $this->XML->xpath("//$this->namespace"."representantDuResponsableDeProjet/". $this->namespace. "numero")[0];
$this->rdpVoie = $this->XML->xpath("//$this->namespace"."representantDuResponsableDeProjet/". $this->namespace. "voie")[0];
$this->rdpComplementAdresse = $this->XML->xpath("//$this->namespace"."representantDuResponsableDeProjet/". $this->namespace. "complementAdresse")[0];
$this->rdpCodePostal = $this->XML->xpath("//$this->namespace"."representantDuResponsableDeProjet/". $this->namespace. "codePostal")[0];
$this->rdpCommune = $this->XML->xpath("//$this->namespace"."representantDuResponsableDeProjet/". $this->namespace. "commune")[0];
$this->rdpPays = $this->XML->xpath("//$this->namespace"."responsableDuProjet/". $this->namespace. "pays")[0];
$this->rdpMail = $this->XML->xpath("//$this->namespace"."representantDuResponsableDeProjet/". $this->namespace. "courriel")[0];
$this->rdpTelephone = $this->XML->xpath("//$this->namespace"."representantDuResponsableDeProjet/". $this->namespace. "tel")[0];
$this->rdpFax = $this->XML->xpath("//$this->namespace"."representantDuResponsableDeProjet/". $this->namespace. "fax")[0];
}
/**
* Rcupre les informations relatives un excutant de travaux
*
*
*
*/
public function recupererInformationsExecutantTravaux(){
$this->execDenomination = $this->XML->xpath("//$this->namespace"."executantDesTravaux/". $this->namespace. "denomination")[0];
$this->execNumSIRET = $this->XML->xpath("//$this->namespace"."executantDesTravaux/". $this->namespace. "noSIRET")[0];
$this->execComplement = $this->XML->xpath("//$this->namespace"."executantDesTravaux/". $this->namespace. "complementService")[0];
$this->execNumeroVoie = $this->XML->xpath("//$this->namespace"."executantDesTravaux/". $this->namespace. "numero")[0];
$this->execVoie = $this->XML->xpath("//$this->namespace"."executantDesTravaux/". $this->namespace. "voie")[0];
$this->execComplementAdresse = $this->XML->xpath("//$this->namespace"."executantDesTravaux/". $this->namespace. "complementAdresse")[0];
$this->execCodePostal = $this->XML->xpath("//$this->namespace"."executantDesTravaux/". $this->namespace. "codePostal")[0];
$this->execCommune = $this->XML->xpath("//$this->namespace"."executantDesTravaux/". $this->namespace. "commune")[0];
$this->execPays = $this->XML->xpath("//$this->namespace"."executantDesTravaux/". $this->namespace. "pays")[0];
$this->execMail = $this->XML->xpath("//$this->namespace"."executantDesTravaux/". $this->namespace. "courriel")[0];
$this->execTelephone =$this->XML->xpath("//$this->namespace"."executantDesTravaux/". $this->namespace. "tel")[0];
$this->execFax = $this->XML->xpath("//$this->namespace"."executantDesTravaux/". $this->namespace. "fax")[0];
}
public function recupererInformationsATU(){
/* Entreprise charge de l'excution des travaux */
$this->execDenomination = $this->XML->xpath("//$this->namespace"."entrepriseChargeeDeLExecutionDesTravaux/". $this->namespace. "nom")[0];
$this->execAdresse = $this->XML->xpath("//$this->namespace"."entrepriseChargeeDeLExecutionDesTravaux/". $this->namespace. "adresse")[0];
$this->execCodePostal = $this->XML->xpath("//$this->namespace"."entrepriseChargeeDeLExecutionDesTravaux/". $this->namespace. "codePostal")[0];
$this->execCommune = $this->execAdresse = $this->XML->xpath("//$this->namespace"."entrepriseChargeeDeLExecutionDesTravaux/". $this->namespace. "commune")[0];
/* Personne ordonnant les travaux (urgents) */
$this->rdpDenomination = $this->execAdresse = $this->XML->xpath("//$this->namespace"."personneOrdonnantLesTravauxUrgents/". $this->namespace. "nom")[0];
$this->rdpNumeroVoie = $this->execAdresse = $this->XML->xpath("//$this->namespace"."personneOrdonnantLesTravauxUrgents/". $this->namespace. "numero")[0];
$this->rdpVoie = $this->XML->xpath("//$this->namespace"."personneOrdonnantLesTravauxUrgents/". $this->namespace. "voie")[0];
$this->rdpCodePostal = $this->XML->xpath("//$this->namespace"."personneOrdonnantLesTravauxUrgents/". $this->namespace. "codePostal")[0];
$this->rdpCommune = $this->XML->xpath("//$this->namespace"."personneOrdonnantLesTravauxUrgents/". $this->namespace. "commune")[0];
$this->rdpPays = $this->XML->xpath("//$this->namespace"."personneOrdonnantLesTravauxUrgents/". $this->namespace. "pays")[0];
$this->rdpTelephone = $this->XML->xpath("//$this->namespace"."personneOrdonnantLesTravauxUrgents/". $this->namespace. "tel")[0];
$this->rdpFax = $this->XML->xpath("//$this->namespace"."personneOrdonnantLesTravauxUrgents/". $this->namespace. "fax")[0];
$this->rdpMail = $this->XML->xpath("//$this->namespace"."personneOrdonnantLesTravauxUrgents/". $this->namespace. "courriel")[0];
}
/**
* Rcupre le nombre de communes concernes par la dclaration
* <ul>
* <li>Si la dclaration est une DT, alors on rcupre la valeur
* de la partie DT</li>
* <li>Si la dclaration est une DICT, alors on rcupre la valeur
* de la partie DICT</li>
* <li>Si la dclaration est une DT-DICT, alors on rcupre la valeur
* de la partie DICT</li>
* </ul>
* @return `bool true` si le traitement s"est bien pass, `false` sinon
*/
public function recupererNombreCommunes(){
switch($this->typeDeclaration){
case "dtDictConjointes":
$this->nombreCommunes = $this->XML->xpath("//$this->namespace"."emplacementDesTravaux/". $this->namespace. "nombreDeCommunes")[0];
break;
case "DT":
$this->nombreCommunes = $this->XML->xpath("//$this->namespace" ."emplacementDuProjet/". $this->namespace. "nombreDeCommunes")[0];
break;
case "DICT":
$this->nombreCommunes = $this->XML->xpath("//$this->namespace"."emplacementDesTravaux/".$this->namespace."nombreDeCommunes")[0];
break;
case "ATU":
// La valeur n'est pas prsente dans un ATU
break;
default:
/*
* Le type de dclaration ne correspond aucun type connu
* c"est une erreur, on retourne `false`
*/
return false;
}
return true; // le traitement s"est bien pass
}
/**
* Rcupre la date de dbut prvue du chantier au format :
* AAAA-MM-JJ+HH:MiMi
* o HH:MiMi est le fuseau horaire par rapport UTC
* Pour la France mtropolitaine, en hiver +HH:MiMi vaut +01:00
* et en t +02:00
*
*
* <ul>
* <li>Si la dclaration est une DT, alors on rcupre la valeur
* de la partie DT</li>
* <li>Si la dclaration est une DICT, alors on rcupre la valeur
* de la partie DICT</li>
* <li>Si la dclaration est une DT-DICT, alors on rcupre la valeur
* de la partie DICT</li>
* <li>Si la dclaration est un ATU, alors on rcupre la valeur de
* dbut des travaux de la partie ATU</li>
* </ul>
* @return `bool true` si le traitement s"est bien pass, `false` sinon
*/
public function recupererDateDebutPrevue(){
switch($this->typeDeclaration){
case "dtDictConjointes":
$this->dateDebutPrevue = $this->XML->xpath("//$this->namespace"."travauxEtLeurCalendrier/".$this->namespace."datePrevuePourLeCommencementDesTravaux")[0];
break;
case "DT":
$this->dateDebutPrevue = $this->XML->xpath("//$this->namespace" ."projetEtSonCalendrier/".$this->namespace."datePrevuePourLeCommencementDesTravaux")[0];
break;
case "DICT":
$this->dateDebutPrevue = $this->XML->xpath("//$this->namespace". "travauxEtLeurCalendrier/".$this->namespace."datePrevuePourLeCommencementDesTravaux")[0];
break;
case "ATU":
// Date de dbut effective (ATU)
$this->dateDebutPrevue = $this->XML->xpath("//$this->namespace". "travauxEmplacementDureeDescription/".$this->namespace."dateDebutDesTravaux")[0];
break;
default:
/*
* Le type de dclaration ne correspond aucun type connu
* c"est une erreur, on retourne `false`
*/
return false;
}
return true; // le traitement s"est bien pass
}
/**
* Rcupre la dure prvue du chantier
* <ul>
* <li>Si la dclaration est une DT, alors on rcupre la valeur
* de la partie DT</li>
* <li>Si la dclaration est une DICT, alors on rcupre la valeur
* de la partie DICT</li>
* <li>Si la dclaration est une DT-DICT, alors on rcupre la valeur
* de la partie DICT</li>
* </ul>
* /!\ Pour les DT-DICT, DT et DICT, la dure est exprime en jours
* Pour les ATU, la dure est exprime en demi-journees
* @return `bool true` si le traitement s'est bien pass, `false` sinon
*/
public function recupererDureeChantierPrevue(){
switch($this->typeDeclaration){
case "dtDictConjointes":
// Dure exprime en jours
$this->dureeChantierPrevue = $this->XML->xpath("//$this->namespace"."travauxEtLeurCalendrier/".$this->namespace."dureeDuChantierEnJours")[0];
break;
case "DT":
// Dure exprime en jours
$this->dureeChantierPrevue = $this->XML->xpath("//$this->namespace"."projetEtSonCalendrier/".$this->namespace."dureeDuChantierEnJours")[0];
break;
case "DICT":
// Dure exprime en jours
$this->dureeChantierPrevue = $this->XML->xpath("//$this->namespace"."travauxEtLeurCalendrier/".$this->namespace."dureeDuChantierEnJours")[0];
break;
case "ATU":
// Dure exprime en demi-journes
$this->dureeChantierPrevue = $this->XML->xpath("//$this->namespace". "travauxEmplacementDureeDescription/".$this->namespace."dureeTravauxDemiJournees")[0];
break;
default:
/*
* Le type de dclaration ne correspond aucun type connu
* c"est une erreur, on retourne `false`
*/
return false;
}
return true; // le traitement s"est bien pass
}
/**
* Rcupre le boolen disant si le chantier va employer des techniques
* sans tranches ou pas
* <ul>
* <li>Si la dclaration est une DT, alors on rcupre la valeur
* de la partie DT</li>
* <li>Si la dclaration est une DICT, alors on rcupre la valeur
* de la partie DICT</li>
* <li>Si la dclaration est une DT-DICT, alors on rcupre la valeur
* de la partie DICT</li>
* </ul>*
* La valeur de sortie est caste en boolen :
* <ul>
* <li>`true` si le chantier va employer des techniques sans tranches</li>
* <li>`false` si le chantier ne va pas employer des techniques sans tranches</li>
* @return `bool true` si le traitement s"est bien pass, `false` sinon
*/
public function recupererTechniquesSansTranchees(){
switch($this->typeDeclaration){
case "dtDictConjointes":
$tmp =
$this->XML->xpath("//$this->namespace"."travauxEtLeurCalendrier/".$this->namespace."emploiDeTechniquesSansTranchees")[0];// === 'true' ? true : false;
$this->techniquesSansTranchees = empty($tmp) ? 'null' : $tmp;
break;
case "DT":
$tmp =
$this->XML->xpath("//$this->namespace"."projetEtSonCalendrier/".$this->namespace."emploiDeTechniquesSansTranchees")[0];// === 'true' ? true : false;
$this->techniquesSansTranchees = empty($tmp) ? 'null' : $tmp;
break;
case "DICT":
$tmp =
$this->XML->xpath("//$this->namespace"."travauxEtLeurCalendrier/".$this->namespace."emploiDeTechniquesSansTranchees")[0];// === 'true' ? true : false;
$this->techniquesSansTranchees = empty($tmp) ? 'null' : $tmp;
break;
case "ATU":
// Cette demande n'est pas disponible dans un ATU
break;
default:
/*
* Le type de dclaration ne correspond aucun type connu
* c'est une erreur, on retourne `false`
*/
return false;
}
return true; // le traitement s'est bien pass
}
/**
* Rcupre le boolen disant si le dclarant souhaite les plans des rseaux
* lectriques ariens
* <ul>
* <li>Si la dclaration est une DT, alors on rcupre la valeur
* de la partie DT</li>
* <li>Si la dclaration est une DICT, alors on rcupre la valeur
* de la partie DICT</li>
* <li>Si la dclaration est une DT-DICT, alors on rcupre la valeur
* de la partie DICT</li>
* <li>Dans la cas d'un ATU, la valeur est absente</li>
* </ul>
* @return `bool true` si le traitement s'est bien pass, `false` sinon
*/
public function recupererPlansElectriquesAeriens(){
switch($this->typeDeclaration){
case "dtDictConjointes":
$tmp =
$this->XML->xpath("//$this->namespace"."travauxEtLeurCalendrier/".$this->namespace."souhaitLesPlansDesReseauxElectriqueAeriens")[0];// === 'true' ? true : false;
$this->plansElectriquesAeriens = empty($tmp) ? 'null' : $tmp;
break;
case "DT":
$tmp =
$this->XML->xpath("//$this->namespace"."projetEtSonCalendrier/".$this->namespace."souhaitLesPlansDesReseauxElectriqueAeriens")[0];// === 'true' ? true : false;
$this->plansElectriquesAeriens = empty($tmp) ? 'null' : $tmp;
break;
case "DICT":
$tmp =
$this->XML->xpath("//$this->namespace"."travauxEtLeurCalendrier/".$this->namespace."souhaitLesPlansDesReseauxElectriqueAeriens")[0];// === 'true' ? true : false;
$this->plansElectriquesAeriens = empty($tmp) ? 'null' : $tmp;
break;
case "ATU":
// Cette demande n'est pas disponible dans un ATU
break;
default:
/*
* Le type de dclaration ne correspond aucun type connu
* c"est une erreur, on retourne `false`
*/
return false;
}
return true; // le traitement s'est bien pass
}
/**
* Rcupre la profondeur maximale d'excavation de la dclaration
* <ul>
* <li>Si la dclaration est une DT, alors on rcupre la valeur
* de la partie DT</li>
* <li>Si la dclaration est une DICT, alors on rcupre la valeur
* de la partie DICT</li>
* <li>Si la dclaration est une DT-DICT, alors on rcupre la valeur
* de la partie DICT</li>
* <li>Dans la cas d'un ATU, la valeur est absente</li>
* </ul>
* @return `bool true` si le traitement s'est bien pass, `false` sinon
*/
public function recupererProfondeurMax(){
switch($this->typeDeclaration){
case "dtDictConjointes":
$profMax = $this->XML->xpath("//$this->namespace"."travauxEtLeurCalendrier/".$this->namespace."profondeurMaxDExcavation")[0];
$this->profondeurMax = empty($profMax) ? -1 : $profMax;
break;
case "DT":
$profMax = $this->XML->xpath("//$this->namespace"."projetEtSonCalendrier/".$this->namespace."profondeurMaxDExcavation")[0];
$this->profondeurMax = empty($profMax) ? -1 : $profMax;
break;
case "DICT":
$profMax = $this->XML->xpath("//$this->namespace"."travauxEtLeurCalendrier/".$this->namespace."profondeurMaxDExcavation")[0];
$this->profondeurMax = empty($profMax) ? -1 : $profMax;
break;
case "ATU":
// Cette demande n'est pas disponible dans un ATU
break;
default:
/*
* Le type de dclaration ne correspond aucun type connu
* c"est une erreur, on retourne `false`
*/
return false;
}
return true; // le traitement s'est bien pass
}
/**
* Rcupre le boolen indiquant si il y aura une modification
* du profil du terrain aprs les travuax
*
*
*/
public function recupererModificationProfilTerrain(){
switch($this->typeDeclaration){
case "dtDictConjointes":
$this->tmp =
$this->XML->xpath("//$this->namespace"."travauxEtLeurCalendrier/".$this->namespace."modificationProfilTerrain")[0];// === 'true' ? true : false;
$this->modificationProfilTerrain = empty($tmp) ? 'null' : $tmp;
break;
case "DT":
$this->modificationProfilTerrain =
$this->XML->xpath("//$this->namespace"."projetEtSonCalendrier/".$this->namespace."modificationProfilTerrain")[0];// === 'true' ? true : false;
$this->modificationProfilTerrain = empty($tmp) ? 'null' : $tmp;
break;
case "DICT":
$tmp =
$this->XML->xpath("//$this->namespace"."travauxEtLeurCalendrier/".$this->namespace."modificationProfilTerrain")[0];// === 'true' ? true : false;
$this->modificationProfilTerrain = empty($tmp) ? 'null' : $tmp;
break;
case "ATU":
// Cette demande n'est pas disponible dans un ATU
break;
default:
/*
* Le type de dclaration ne correspond aucun type connu
* c"est une erreur, on retourne `false`
*/
return false;
}
return true; // le traitement s'est bien pass
}
/**
* Rcupre le numro d'affaire du dclarant (excutant ou responsable de projet)
* <ul>
* <li>Si la dclaration est une DT, alors on rcupre le numro d'affaire
* du responsable de projet</li>
* <li>Si la dclaration est une DICT, alors on rcupre le numro d'affaire
* de l'excutant.</li>
* <li>Si la dclaration est une DT-DICT, alors on rcupre le numro d'affaire
* de l'excutant et du responsable de projet.</li>
* </ul>
* @return `bool true` si le traitement s'est bien pass, `false` sinon
*/
public function recupererNoAffaireDeclarant(){
switch($this->typeDeclaration){
case "dtDictConjointes":
// dtDictConjointes, on rcupre les numros d'affaire de l'excutant et du responsable de projet
$this->noAffaireExec = $this->XML->xpath("//$this->namespace"."noAffaireDeLexecutantDesTravaux")[0];
$this->noAffaireRDP = $this->XML->xpath("//$this->namespace"."noAffaireDuResponsableDuProjet")[0];
break;
case "DT":
// DT, on rcupre le numro d'affaire du responsable de projet uniquement
$this->noAffaireRDP = $this->XML->xpath("//$this->namespace"."noAffaireDuResponsableDuProjet")[0];
break;
case "DICT":
// DICT, on rcupre le numro d'affaire de l'excutant
$this->noAffaireExec = $this->XML->xpath("//$this->namespace"."noAffaireDeLexecutantDesTravaux")[0];
break;
case "ATU":
// Pas de numro d'affaire prsent dans un ATU
break;
default:
/*
* Le type de dclaration ne correspond aucun type connu
* c'est une erreur, on retourne `false`
*/
return false;
}
return true; // le traitement s'est bien pass
}
/**
* Rcupre la justification de l'urgence pour l'ATU
* Diffrentes cases sont cochables.
* si la case est coche (boolen true),
* alors on dfinit une variable avec un acronyme :
* <ul>
* <li>Scurit : SECU</li>
* <li>Continuit du service public : SVCE</li>
* <li>Sauvegarde des personnes et des biens : SAUV</li>
* <li>Cas de force majeure : FOMA</li>
* </ul>
* Le rsultat est la concatnation des diffrents choix
* Par exemple : SECU , SVCE
* @return `bool true` si le traitement s'est bien pass, `false` sinon
*/
public function recupererJustificationUrgence(){
// On rcupre uniquement en cas d'ATU
if($this->typeDeclaration == "ATU"){
/* On rcupre les valeurs dans le XML :
* Si la valeur est `true`, alors on dfinit une variable
* avec un acronyme tel que list au pralable
*/
$tblJustif = array();
$i = 0;
$securite = strcmp($this->XML->xpath("//$this->namespace" . "securite")[0], 'true') == 0 ? 'SECU' : 'NSECU';
$continuiteServicePublic = strcmp($this->XML->xpath("//$this->namespace" . "continuiteDuServicePublic")[0], 'true') == 0 ? 'SVCE' : 'NSVCE';
$sauvegardePersonnes = strcmp($this->XML->xpath("//$this->namespace" . "sauvegardeDesPersonnesEtDesBiens")[0], 'true') == 0 ? 'SAUV' : 'NSAUV';
$forceMajeure = strcmp($this->XML->xpath("//$this->namespace" . "casDeForceMajeure")[0], 'true') == 0 ? 'FOMA' : 'NFOMA';
/*
* On cre un tableau, si la valeur est prsente (c'est--dire pas null)
* alors on la rajoute dans le tableau
*
*/
if(strcmp($securite, 'NSECU')){
$tblJustif[$i] = $securite;
$i++;
}
if(strcmp($continuiteServicePublic, 'NSVCE')){
$tblJustif[$i] = $continuiteServicePublic;
$i++;
}
if(strcmp($sauvegardePersonnes, 'NSAUV')){
$tblJustif[$i] = $sauvegardePersonnes;
$i++;
}
if(strcmp($forceMajeure, 'NFOMA')){
$tblJustif[$i] = $forceMajeure;
$i++;
}
// On cre une liste partir du tableau
$this->justificationUrgence = implode(" , ", $tblJustif);
return true; // Le traitement s'est bien pass
} else return false; // Nous ne sommes pas dans le cas d'un ATU, alors on retourne false
}
/*
* Rcupre, dans le cas d'un ATU, la valeur disant si le chantier est
* termin ou est venir.
* Si le boolen `reponseAttendueChantierAVenir` est `true`, alors le
* champ `chantierTermineOuAVenir` est mis 'A venir', sinon, le chantier
* est termin
* @return `bool true` si le traitement s'est bien pass, `false` sinon
*/
public function recupererChantierTermineOuAVenir(){
// Fonction uniquement utilisable si on est avec un ATU
if($this->typeDeclaration == "ATU"){
/*
* Requte XPath :
* Si le boolen de chantier venir est true, alors le chantier est venir
* Sinon, alors le chantier est termin
*
*/
$this->chantierTermineOuAVenir =
$this->XML->xpath("//$this->namespace"."chantierTermineOuChantierAVenir/".$this->namespace."reponseAttendueChantierAVenir")[0] === 'true' ? 'A venir' : 'Termin';
} else return false; // Nous ne sommes pas dans le cas d'un ATU, alors on retourne false
}
/* - - - - - - - - Fonctions d'affichage - - - - - - - - */
public function afficherAttributsVarDump(){
echo "Type dclaration : ";
var_dump($this->typeDeclaration);
echo "<br/>";
echo "Num DT : ";
var_dump($this->numeroNationalDT);
echo "<br/>";
echo "Num DICT : ";
var_dump($this->numeroNationalDICT);
echo "<br/>";
echo "Num ATU : ";
var_dump($this->numeroNationalATU);
echo "<br/>";
echo "Nature : ";
var_dump($this->natureTravaux);
echo "<br/>";
echo "Description : ";
var_dump($this->description);
echo "<br/>";
echo "Trace GML : ";
var_dump($this->traceGML);
echo "<br/>";
echo "Adresse : ";
var_dump($this->adresse);
echo "<br/>";
echo "Nombre communes : ";
var_dump($this->nombreCommunes);
echo "<br/>";
echo "Code postal : ";
var_dump($this->codePostal);
echo "<br/>";
echo "Commune : ";
var_dump($this->commune);
echo "<br/>";
echo "Date debut prvue : ";
var_dump($this->dateDebutPrevue);
echo "<br/>";
echo "Dure chantier prvue :";
var_dump($this->dureeChantierPrevue);
echo "<br/>";
echo "Techniques sans tranchees : ";
var_dump($this->techniquesSansTranchees);
echo "<br/>";
}
public function afficherAttributsEcho(){
echo "Type dclaration : ";
echo "$this->typeDeclaration";
echo "<br/>";
echo "Num DT : ";
echo "$this->numeroNationalDT";
echo "<br/>";
echo "Num DICT : ";
echo "$this->numeroNationalDICT";
echo "<br/>";
echo "Num ATU : ";
echo "$this->numeroNationalATU";
echo "<br/>";
echo "Nature : ";
echo "$this->natureTravaux";
echo "<br/>";
echo "Description : ";
echo "$this->description";
echo "<br/>";
echo "Trace GML : ";
echo "$this->traceGML";
echo "<br/>";
echo "Adresse : ";
echo "$this->adresse";
echo "<br/>";
echo "Nombre communes : ";
echo "$this->nombreCommunes";
echo "<br/>";
echo "Code postal : ";
echo "$this->codePostal";
echo "<br/>";
echo "Commune : ";
echo "$this->commune";
echo "<br/>";
echo "Date de dbut prvue :";
echo "$this->dateDebutPrevue";
echo "<br/>";
echo "Dure chantier prvue :";
echo "$this->dureeChantierPrevue";
echo "<br/>";
echo "Techniques sans tranchees : ";
echo ($this->techniquesSansTranchees) ?'true':'false';
echo "<br/>";
}
public function afficherAttributsRDP(){
echo "<hr/>";
echo "<center><h1> Informations relatives au responsable de projet </h1></center>";
echo "Denomination : ";
echo "$this->rdpDenomination";
echo "<br/>";
echo "Num. SIRET : ";
echo "$this->rdpNumSIRET";
echo "<br/>";
echo "Complment (service) : ";
echo "$this->rdpComplement";
echo "<br/>";
echo "Numro voie : ";
echo "$this->rdpNumeroVoie";
echo "<br/>";
echo "Voie : ";
echo "$this->rdpVoie";
echo "<br/>";
echo "Complment adresse : ";
echo "$this->rdpComplementAdresse";
echo "<br/>";
echo "Code Postal : ";
echo "$this->rdpCodePostal";
echo "<br/>";
echo "Commune : ";
echo "$this->rdpCommune";
echo "<br/>";
echo "Pays : ";
echo "$this->rdpPays";
echo "<br/>";
echo "Mail : ";
echo "$this->rdpMail";
echo "<br/>";
echo "Tlphone : ";
echo "$this->rdpTelephone";
echo "<br/>";
echo "Fax : ";
echo "$this->rdpFax";
echo "<br/>";
}
public function afficherAttributsExecTravaux(){
echo "<hr/>";
echo "<center><h1> Informations relatives l'excutant de travaux </h1></center>";
echo "Denomination : ";
echo "$this->execDenomination";
echo "<br/>";
echo "Num. SIRET : ";
echo "$this->execNumSIRET";
echo "<br/>";
echo "Complment (service) : ";
echo "$this->execComplement";
echo "<br/>";
echo "Numro voie : ";
echo "$this->execNumeroVoie";
echo "<br/>";
echo "Voie : ";
echo "$this->execVoie";
echo "<br/>";
echo "Complment adresse : ";
echo "$this->execComplementAdresse";
echo "<br/>";
echo "Code Postal : ";
echo "$this->execCodePostal";
echo "<br/>";
echo "Commune : ";
echo "$this->execCommune";
echo "<br/>";
echo "Pays : ";
echo "$this->execPays";
echo "<br/>";
echo "Mail : ";
echo "$this->execMail";
echo "<br/>";
echo "Tlphone : ";
echo "$this->execTelephone";
echo "<br/>";
echo "Fax : ";
echo "$this->execFax";
echo "<br/>";
}
/* - - - - - - - - Fonctions lies l'Instruction - - - - - - - - */
/**
* Dbute l'instruction de la Dclaration:
* Cre une ligne dans la table Instruction avec l'idDeclaration.
* On place l'tat de l'instruction 0
*
*/
public function debuterInstruction(){
// On rcupre l'id de la Dclaration
$this->recupererIdDeclaration();
// Connexion au SGBD
$cnx = $this->connexionBD();
$sqlInstruction = "INSERT INTO \"instruction\" (\"idDeclaration\", \"etat\",\"idAgentInstructeur\", \"idAgentSignataire\")
VALUES ($this->idDeclaration, 0, 1, 2);";
$cnx->exec($sqlInstruction);
}
/**
* Cre l'objet `Recepisse` relatif la `Declaration` courante
* Egalement,
* @return Recepisse Objet Recepisse
*/
public function creerRecepisse(){
// Requte SQL de cration du Rcpiss avec l'id de dclaration en cl trangre
// Egalement, on spcifie le numro de rfrence de rseau pour lequel on cre le Rcpiss
// /!\ Pour les tests, ici, on initialise le numro de rseau 1
$sqlRecepisse = "INSERT INTO \"recepisse\" (\"idDeclaration\", \"idReseau\")
VALUES($this->idDeclaration, 1);";
// Requte de rcupration de l'id de Rcpisse
$sqlRecupRecep = "SELECT MAX(\"idRecepisse\") FROM \"recepisse\";";
// Cration de la connexion BD
$cnx = $this->connexionBD();
$cnx->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
// On cre la ligne dans la table Recepisse avec l'id de Dclaration
$cnx->exec($sqlRecepisse);
// On rcupre l'id de rcpiss
$reponseRecup = $cnx->query($sqlRecupRecep);
$this->idRecepisse = $reponseRecup->fetch()[0];
// Requte de mise jour de la ligne de la table Rcpisse
$sqlUpdateInstruction = "UPDATE \"instruction\"
SET \"idRecepisse\" = $this->idRecepisse
WHERE \"idDeclaration\" = $this->idDeclaration;";
$cnx->exec($sqlUpdateInstruction);
// On cre l'objet Recepisse, on le retourne
return new Recepisse($this->idRecepisse);
}
/* - - - - - - - - Fonctions lies aux BD - - - - - - - - */
/**
* Cre une connexion la base de donnes
* @param $SGBD string Le SGBD utilis. Paramtre sous une forme spcifique.
* @see http://php.net/manual/fr/pdo.drivers.php
* @param $hote string Nom de l'hte / IP de connexion au SGBD
* @param $port string Port utilis par le SGBD
* @param $nomBD string Nom de la base de donnes utilise par l'application
* @param $util string Nom d'utilisateur dans le SGBD
* @param $mdp string Mot de passe d'accs
*
* @return $pdo PDO Si la connexion est tablie, sinon retourne `null` si la
* connexion n'a pas pu tre tablie.
*/
public function connexionBD(/*$SGBD, $hote, $port, $nomBD, $util, $mdp*/){
$SGBD = 'pgsql';
$hote = 'localhost';
$port = '5432';
$nomBD = 'adicttests';
$util = 'adicttests';
$mdp = 'adicttests';
try{
$pdo = new PDO("$SGBD:host=$hote;port=$port;dbname=$nomBD", $util, $mdp);
} catch(PDOException $e){
echo "<br/>";
echo "<hr/>";
echo 'Connexion choue' . $e->getMessage();
return null;
}
return $pdo;
}
/**
* Rcupre l'id de la Dclaration courante (rentre dernirement en base de donnes)
*
*/
public function recupererIdDeclaration(){
$cnx = $this->connexionBD();
$cnx->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$sqlRecupDecl = "SELECT MAX(\"idDeclaration\") FROM \"declaration\";";
$reponseRecup = $cnx->query($sqlRecupDecl);
$this->idDeclaration = $reponseRecup->fetch()[0];
}
/**
* Dtermine si la dclaration courante est dj entre dans la base de donnes
*
* @return `true` si la dclaration est dj dans la base, `false sinon`
*/
public function determinerDejaBase(){
$cnx = $this->connexionBD();
$sqlDejaBase = "SELECT \"declaration\".\"numeroNationalDT\", \"declaration\".\"numeroNationalDICT\", \"declaration\".\"numeroNationalATU\"
FROM \"declaration\"";
$reponse = $cnx->query($sqlDejaBase);
$tblReponse = $reponse->fetchAll();
// Cette fonction retourne true si le numro de consultation courant est prsent dans le tableau retourn par la requte
return $this->in_array_r($this->numConsultationTeleservice, $tblReponse);
}
/**
* Permet d'entrer en Base de Donnes une dclaration pralablement initialise
* avec la fonction `initialiserDeclarationXML()`
* Cette fonction, en fonction du type de dclaration, appelle une fonction spcifique
* permettant d'entrer en base de donnes les donnes ncessaires
*
*/
public function entrerDeclarationBD(){
switch($this->typeDeclaration){
case "dtDictConjointes":
$this->entrerDTDICT();
break;
case "DT":
$this->entrerDT();
break;
case "DICT":
$this->entrerDICT();
break;
case "ATU":
$this->entrerATU();
break;
default:
/*
* Le type de dclaration ne correspond aucun type connu
* c'est une erreur, on retourne `false`
*/
return false;
}
return true; // le traitement s'est bien pass
}
/**
* Fonction permettant de rentrer une DT-DICT conjointe (dtDictConjointes) dans la
* base de donnees:
* <ul>
* <li>Les informations relatives au responsable de projet sont
* stockes dans la table `responsableProjet`</li>
* <li>Les informations relatives l'excutant de travaux sont
* stockes dans la table `executant`</li>
* </ul>
*/
private function entrerDTDICT(){
$cnx = $this->connexionBD();
$cnx->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
/*
* On "trime" (on retire les caractres invisibles en dbut et fin de chane)
* les chanes que l'on a extrait du XML
* On utilise la fonction PDO::quote place des guillemets simples autour de la
* si ncessaire et protge les caractres spciaux ventuellement prsents.
* en fonction du SGBD utilis par l'instance PDO.
*/
$dateReceptionDeclarationESC = trim($cnx->quote($this->dateReceptionDeclaration));
$typeDeclarationESC = trim($cnx->quote($this->typeDeclaration));
$numeroNationalDTESC = trim($cnx->quote($this->numeroNationalDT));
$numeroNationalDICTESC = trim($cnx->quote($this->numeroNationalDICT));
$numeroNationalATUESC = trim($cnx->quote($this->numeroNationalATU));
$natureTravauxESC = trim($cnx->quote($this->natureTravaux));
$URLfichierXMLESC = trim($cnx->quote($this->URLfichierXML));
$URLfichierPDFESC = trim($cnx->quote($this->URLfichierPDF));
$URLfichierEMLESC = trim($cnx->quote($this->URLfichierEML));
$descriptionESC = trim($cnx->quote($this->description));
$adresseESC = trim($cnx->quote($this->adresse));
$nombreCommunesESC = trim($cnx->quote($this->nombreCommunes));
$codePostalESC = trim($cnx->quote($this->codePostal));
$communeESC = trim($cnx->quote($this->commune));
$dateDebutPrevueESC = trim($cnx->quote($this->dateDebutPrevue));
$dureeChantierPrevueESC = trim($cnx->quote($this->dureeChantierPrevue));
$traceGMLESC = trim($cnx->quote($this->traceGML));
$personneContactProjetESC = trim($cnx->quote($this->personneContactProjet));
$telephoneContactProjetESC = trim($cnx->quote($this->telephoneContactProjet));
$faxContactProjetESC = trim($cnx->quote($this->faxContactProjet));
$courrielContactProjetESC = trim($cnx->quote($this->courrielContactProjet));
$personneContactTravauxESC = trim($cnx->quote($this->personneContactTravaux));
$telephoneContactTravauxESC = trim($cnx->quote($this->telephoneContactTravaux));
$faxContactTravauxESC = trim($cnx->quote($this->faxContactTravaux));
$courrielContactTravauxESC = trim($cnx->quote($this->courrielContactTravaux));
$techniquesUtiliseesESC = trim($cnx->quote($this->techniquesUtilisees));
$noAffaireExecESC = trim($cnx->quote($this->noAffaireExec));
$noAffaireRDPESC = trim($cnx->quote($this->noAffaireRDP));
$profondeurMaxESC = trim($cnx->quote($this->profondeurMax));
$techniquesSansTrancheesESC = $this->techniquesSansTranchees;
$plansElectriquesAeriensESC = $this->plansElectriquesAeriens;
$modificationProfilTerrainESC = $this->modificationProfilTerrain;
$execDenominationESC = trim($cnx->quote($this->execDenomination));
$execNumSIRETESC = trim($cnx->quote($this->execNumSIRET));
$execComplementESC = trim($cnx->quote($this->execComplement));
$execNumeroVoieESC = trim($cnx->quote($this->execNumeroVoie));
$execVoieESC = trim($cnx->quote($this->execVoie));
$execComplementAdresseESC = trim($cnx->quote($this->execComplementAdresse));
$execCodePostalESC = trim($cnx->quote($this->execCodePostal));
$execAdresseESC = trim($cnx->quote($this->execAdresse));
$execCommuneESC = trim($cnx->quote($this->execCommune));
$execPaysESC = trim($cnx->quote($this->execPays));
$execMailESC = trim($cnx->quote($this->execMail));
$execTelephoneESC = trim($cnx->quote($this->execTelephone));
$execFaxESC = trim($cnx->quote($this->execFax));
$rdpDenominationESC = trim($cnx->quote($this->rdpDenomination));
$rdpNumSIRETESC = trim($cnx->quote($this->rdpNumSIRET));
$rdpComplementESC = trim($cnx->quote($this->rdpComplement));
$rdpNumeroVoieESC = trim($cnx->quote($this->rdpNumeroVoie));
$rdpVoieESC = trim($cnx->quote($this->rdpVoie));
$rdpComplementAdresseESC = trim($cnx->quote($this->rdpComplementAdresse));
$rdpCodePostalESC = trim($cnx->quote($this->rdpCodePostal));
$rdpCommuneESC = trim($cnx->quote($this->rdpCommune));
$rdpPaysESC = trim($cnx->quote($this->rdpPays));
$rdpMailESC = trim($cnx->quote($this->rdpMail));
$rdpFaxESC = trim($cnx->quote($this->rdpFax));
$rdpTelephoneESC = trim($cnx->quote($this->rdpTelephone));
$sqlExec = "INSERT INTO executant (\"denomination\", \"numSIRET\", \"complement\", \"numeroVoie\", \"voie\", \"complementAdresse\",
\"codePostal\", \"commune\", \"pays\", \"mail\", \"telephone\", \"fax\")
VALUES ($execDenominationESC, $execNumSIRETESC, $execComplementESC, $execNumeroVoieESC, $execVoieESC,
$execComplementAdresseESC, $execCodePostalESC, $execCommuneESC, $execPaysESC, $execMailESC, $execTelephoneESC, $execFaxESC);";
$sqlRDP = "INSERT INTO \"responsableProjet\" (\"denomination\", \"numSIRET\", \"complement\", \"numeroVoie\", \"voie\", \"complementAdresse\",
\"codePostal\", \"commune\", \"pays\", \"mail\", \"telephone\", \"fax\")
VALUES($rdpDenominationESC,$rdpNumSIRETESC, $rdpComplementESC, $rdpNumeroVoieESC, $rdpVoieESC,
$rdpComplementAdresseESC, $rdpCodePostalESC, $rdpCommuneESC, $rdpPaysESC, $rdpMailESC, $rdpTelephoneESC, $rdpFaxESC);";
$sqlDernierRDP = "SELECT MAX(\"idRDP\") FROM \"responsableProjet\";";
$sqlDernierExecutant = "SELECT MAX(\"idExecutant\") FROM \"executant\";";
// On entre les
$cnx->exec($sqlRDP);
$cnx->exec($sqlExec);
/*
* On dtermine quel est le numro du dernier responsable de projet
* et du dernier excutant rentre en base.
* Cela permet de crer les cls trangres dans la table Declaration
*/
$reponseRDP = $cnx->query($sqlDernierRDP);
$idDernierResponsableProjetRentre = $reponseRDP->fetch()[0];
$reponseExecutant = $cnx->query($sqlDernierExecutant);
$idDernierExecutantRentre = $reponseExecutant->fetch()[0];
$sqlDeclDTDICT = "INSERT INTO declaration (\"techniquesUtilisees\", \"noAffaireExecutant\", \"noAffaireRDP\", \"techniquesSansTranchees\", \"profondeurMax\", \"plansElectriquesAeriens\",
\"modificationProfilTerrain\",
\"dateReceptionDeclaration\", \"typeDeclaration\", \"numeroNationalDT\", \"numeroNationalDICT\", \"nature\", \"description\", \"adresse\",
\"nombreCommunes\", \"codePostal\", \"commune\", \"dateDebutPrevue\", \"dureeChantierPrevue\", \"traceGML\", \"personneContactTravaux\",
\"telephoneContactTravaux\", \"faxContactTravaux\", \"courrielContactTravaux\", \"personneContactProjet\",
\"telephoneContactProjet\", \"faxContactProjet\", \"courrielContactProjet\", \"idRDP\", \"idExecutant\")
VALUES ($techniquesUtiliseesESC, $noAffaireExecESC, $noAffaireRDPESC, $techniquesSansTrancheesESC, $profondeurMaxESC, $plansElectriquesAeriensESC, $modificationProfilTerrainESC,
to_timestamp($dateReceptionDeclarationESC), $typeDeclarationESC, $numeroNationalDTESC, $numeroNationalDICTESC, $natureTravauxESC, $descriptionESC, $adresseESC,
$nombreCommunesESC, $codePostalESC, $communeESC, $dateDebutPrevueESC, $dureeChantierPrevueESC, $traceGMLESC,
$personneContactTravauxESC, $telephoneContactTravauxESC, $faxContactTravauxESC, $courrielContactTravauxESC,
$personneContactProjetESC, $telephoneContactProjetESC, $faxContactProjetESC, $courrielContactProjetESC,
$idDernierResponsableProjetRentre, $idDernierExecutantRentre);";
$cnx->exec($sqlDeclDTDICT);
}
/**
* Fonction permettant de rentrer une Demande de Travaux (DT) dans la
* base de donnees:
* <ul>
* <li>Les informations relatives au responsable de projet sont
* stockes dans la table `responsableProjet`</li>
* </ul>
*
*/
private function entrerDT(){
$cnx = $this->connexionBD();
$cnx->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$dateReceptionDeclarationESC = trim($cnx->quote($this->dateReceptionDeclaration));
$typeDeclarationESC = trim($cnx->quote($this->typeDeclaration));
$numeroNationalDTESC = trim($cnx->quote($this->numeroNationalDT));
$natureTravauxESC = trim($cnx->quote($this->natureTravaux));
$URLfichierXMLESC = trim($cnx->quote($this->URLfichierXML));
$URLfichierPDFESC = trim($cnx->quote($this->URLfichierPDF));
$URLfichierEMLESC = trim($cnx->quote($this->URLfichierEML));
$descriptionESC = trim($cnx->quote($this->description));
$adresseESC = trim($cnx->quote($this->adresse));
$nombreCommunesESC = trim($cnx->quote($this->nombreCommunes));
$codePostalESC = trim($cnx->quote($this->codePostal));
$communeESC = trim($cnx->quote($this->commune));
$dateDebutPrevueESC = trim($cnx->quote($this->dateDebutPrevue));
$dureeChantierPrevueESC = trim($cnx->quote($this->dureeChantierPrevue));
$traceGMLESC = trim($cnx->quote($this->traceGML));
$personneContactProjetESC = trim($cnx->quote($this->personneContactProjet));
$telephoneContactProjetESC = trim($cnx->quote($this->telephoneContactProjet));
$faxContactProjetESC = trim($cnx->quote($this->faxContactProjet));
$courrielContactProjetESC = trim($cnx->quote($this->courrielContactProjet));
$techniquesUtiliseesESC = trim($cnx->quote($this->techniquesUtilisees));
$noAffaireExecESC = trim($cnx->quote($this->noAffaireExec));
$noAffaireRDPESC = trim($cnx->quote($this->noAffaireRDP));
$profondeurMaxESC = trim($cnx->quote($this->profondeurMax));
$techniquesSansTrancheesESC = $this->techniquesSansTranchees;
$plansElectriquesAeriensESC = $this->plansElectriquesAeriens;
$modificationProfilTerrainESC = $this->modificationProfilTerrain;
$rdpDenominationESC = trim($cnx->quote($this->rdpDenomination));
$rdpNumSIRETESC = trim($cnx->quote($this->rdpNumSIRET));
$rdpComplementESC = trim($cnx->quote($this->rdpComplement));
$rdpNumeroVoieESC = trim($cnx->quote($this->rdpNumeroVoie));
$rdpVoieESC = trim($cnx->quote($this->rdpVoie));
$rdpComplementAdresseESC = trim($cnx->quote($this->rdpComplementAdresse));
$rdpCodePostalESC = trim($cnx->quote($this->rdpCodePostal));
$rdpCommuneESC = trim($cnx->quote($this->rdpCommune));
$rdpPaysESC = trim($cnx->quote($this->rdpPays));
$rdpMailESC = trim($cnx->quote($this->rdpMail));
$rdpFaxESC = trim($cnx->quote($this->rdpFax));
$rdpTelephoneESC = trim($cnx->quote($this->rdpTelephone));
$sqlRDP = "INSERT INTO \"responsableProjet\" (\"denomination\", \"numSIRET\", \"complement\", \"numeroVoie\", \"voie\", \"complementAdresse\",
\"codePostal\", \"commune\", \"pays\", \"mail\", \"telephone\", \"fax\")
VALUES($rdpDenominationESC, $rdpNumSIRETESC, $rdpComplementESC, $rdpNumeroVoieESC, $rdpVoieESC,
$rdpComplementAdresseESC, $rdpCodePostalESC, $rdpCommuneESC, $rdpPaysESC, $rdpMailESC, $rdpTelephoneESC, $rdpFaxESC);";
$sqlDernierRDP = "SELECT MAX(\"idRDP\") FROM \"responsableProjet\";";
$cnx->exec($sqlRDP);
/*
* On dtermine quel est le numro du dernier responsable
* de projet rentr en base
* Cela permet de crer la cl trangre dans la table Declaration
*/
$reponse = $cnx->query($sqlDernierRDP);
$idDernierResponsableProjetRentre = $reponse->fetch()[0];
$sqlDeclDT = "INSERT INTO declaration (\"techniquesUtilisees\",
\"noAffaireRDP\",
\"techniquesSansTranchees\",
\"profondeurMax\",
\"plansElectriquesAeriens\",
\"modificationProfilTerrain\",
\"dateReceptionDeclaration\",
\"typeDeclaration\",
\"numeroNationalDT\",
\"nature\",
\"description\",
\"adresse\",
\"nombreCommunes\",
\"codePostal\",
\"commune\",
\"dateDebutPrevue\",
\"dureeChantierPrevue\",
\"traceGML\",
\"personneContactProjet\",
\"telephoneContactProjet\",
\"faxContactProjet\",
\"courrielContactProjet\",
\"idRDP\")
VALUES ($techniquesUtiliseesESC,
$noAffaireRDPESC,
$techniquesSansTrancheesESC,
$profondeurMaxESC,
$plansElectriquesAeriensESC,
$modificationProfilTerrainESC,
to_timestamp($dateReceptionDeclarationESC),
$typeDeclarationESC,
$numeroNationalDTESC,
$natureTravauxESC,
$descriptionESC,
$adresseESC,
$nombreCommunesESC,
$codePostalESC,
$communeESC,
$dateDebutPrevueESC,
$dureeChantierPrevueESC,
$traceGMLESC,
$personneContactProjetESC,
$telephoneContactProjetESC,
$faxContactProjetESC,
$courrielContactProjetESC,
$idDernierResponsableProjetRentre);";
$cnx->exec($sqlDeclDT);
}
/**
* Fonction permettant de rentrer une Dclaration d'Intention de Commencement de Travaux
* (DICT) dans la base de donnees:
* <ul>
* <li>Les informations relatives au responsable de projet sont
* stockes dans la table `responsableProjet`</li>
* <li>Les informations relatives l'excutant de travaux sont
* stockes dans la table `executant`</li>
* </ul>
*
*/
private function entrerDICT(){
$cnx = $this->connexionBD();
$cnx->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
/*
* On chappe proprement les variables (attributs) que l'on souhaite insrer
* dans la base de donnes
*/
// Table Declaration
$dateReceptionDeclarationESC = trim($cnx->quote($this->dateReceptionDeclaration));
$typeDeclarationESC = trim($cnx->quote($this->typeDeclaration));
$numeroNationalDICTESC = trim($cnx->quote($this->numeroNationalDICT));
$natureTravauxESC = trim($cnx->quote($this->natureTravaux));
$URLfichierXMLESC = trim($cnx->quote($this->URLfichierXML));
$URLfichierPDFESC = trim($cnx->quote($this->URLfichierPDF));
$URLfichierEMLESC = trim($cnx->quote($this->URLfichierEML));
$descriptionESC = trim($cnx->quote($this->description));
$adresseESC = trim($cnx->quote($this->adresse));
$nombreCommunesESC = trim($cnx->quote($this->nombreCommunes));
$codePostalESC = trim($cnx->quote($this->codePostal));
$communeESC = trim($cnx->quote($this->commune));
$dateDebutPrevueESC = trim($cnx->quote($this->dateDebutPrevue));
$dureeChantierPrevueESC = trim($cnx->quote($this->dureeChantierPrevue));
$traceGMLESC = trim($cnx->quote($this->traceGML));
$personneContactTravauxESC = trim($cnx->quote($this->personneContactTravaux));
$telephoneContactTravauxESC = trim($cnx->quote($this->telephoneContactTravaux));
$faxContactTravauxESC = trim($cnx->quote($this->faxContactTravaux));
$courrielContactTravauxESC = trim($cnx->quote($this->courrielContactTravaux));
$techniquesSansTrancheesESC = $this->techniquesSansTranchees;
$plansElectriquesAeriensESC = $this->plansElectriquesAeriens;
$modificationProfilTerrainESC = $this->modificationProfilTerrain;
$techniquesUtiliseesESC = trim($cnx->quote($this->techniquesUtilisees));
$noAffaireExecESC = trim($cnx->quote($this->noAffaireExec));
$noAffaireRDPESC = trim($cnx->quote($this->noAffaireRDP));
$profondeurMaxESC = trim($cnx->quote($this->profondeurMax));
// Table Executant
$execDenominationESC = trim($cnx->quote($this->execDenomination));
$execNumSIRETESC = trim($cnx->quote($this->execNumSIRET));
$execComplementESC = trim($cnx->quote($this->execComplement));
$execNumeroVoieESC = trim($cnx->quote($this->execNumeroVoie));
$execVoieESC = trim($cnx->quote($this->execVoie));
$execComplementAdresseESC = trim($cnx->quote($this->execComplementAdresse));
$execCodePostalESC = trim($cnx->quote($this->execCodePostal));
$execAdresseESC = trim($cnx->quote($this->execAdresse));
$execCommuneESC = trim($cnx->quote($this->execCommune));
$execPaysESC = trim($cnx->quote($this->execPays));
$execMailESC = trim($cnx->quote($this->execMail));
$execTelephoneESC = trim($cnx->quote($this->execTelephone));
$execFaxESC = trim($cnx->quote($this->execFax));
/*
* Requte SQL d'insertion de la partie "Excutant de travaux" dans la base de donnes
* Donnes entres dans la table `executant`
*
*/
$sqlExec = "INSERT INTO executant (\"denomination\", \"numSIRET\", \"complement\", \"numeroVoie\", \"voie\", \"complementAdresse\",
\"codePostal\", \"commune\", \"pays\", \"mail\", \"telephone\", \"fax\")
VALUES ($execDenominationESC,$execNumSIRETESC, $execComplementESC, $execNumeroVoieESC, $execVoieESC,
$execComplementAdresseESC, $execCodePostalESC, $execCommuneESC, $execPaysESC, $execMailESC, $execTelephoneESC, $execFaxESC);";
$sqlDernierExecutant = "SELECT MAX(\"idExecutant\") FROM \"executant\";";
$cnx->exec($sqlExec);
/*
* On dtermine quel est le numro du dernier excutant rentr en base
* Cela permet de crer la cl trangre dans la table Declaration
*/
$reponse = $cnx->query($sqlDernierExecutant);
$idDernierExecutantRentre = $reponse->fetch()[0];
$sqlDeclDICT = "INSERT INTO declaration (\"techniquesUtilisees\", \"noAffaireExecutant\",
\"techniquesSansTranchees\", \"profondeurMax\", \"plansElectriquesAeriens\",
\"modificationProfilTerrain\",
\"dateReceptionDeclaration\", \"typeDeclaration\", \"numeroNationalDICT\",
\"nature\", \"description\", \"adresse\",
\"nombreCommunes\", \"codePostal\", \"commune\",\"dateDebutPrevue\",
\"dureeChantierPrevue\", \"traceGML\", \"personneContactTravaux\",
\"telephoneContactTravaux\", \"faxContactTravaux\",
\"courrielContactTravaux\", \"idExecutant\")
VALUES ($techniquesUtiliseesESC, $noAffaireExecESC, $techniquesSansTrancheesESC,
$profondeurMaxESC, $plansElectriquesAeriensESC, $modificationProfilTerrainESC,
to_timestamp($dateReceptionDeclarationESC), $typeDeclarationESC,
$numeroNationalDICTESC, $natureTravauxESC, $descriptionESC,
$adresseESC, $nombreCommunesESC, $codePostalESC, $communeESC,
$dateDebutPrevueESC, $dureeChantierPrevueESC, $traceGMLESC,
$personneContactTravauxESC, $telephoneContactTravauxESC, $faxContactTravauxESC,
$courrielContactTravauxESC, $idDernierExecutantRentre);";
$cnx->exec($sqlDeclDICT);
}
/**
* Permet d'entrer un Avis de Travaux Urgents (ATU) dans la
* base de donnes
*/
private function entrerATU(){
$cnx = $this->connexionBD();
$cnx->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
/*
* On chappe proprement les variables (attributs) que l'on souhaite insrer
* dans la base de donnes
*/
$dateReceptionDeclarationESC = trim($cnx->quote($this->dateReceptionDeclaration));
$typeDeclarationESC = trim($cnx->quote($this->typeDeclaration));
$numeroNationalATUESC = trim($cnx->quote($this->numeroNationalATU));
$natureTravauxESC = trim($cnx->quote($this->natureTravaux));
$URLfichierXMLESC = trim($cnx->quote($this->URLfichierXML));
$URLfichierPDFESC = trim($cnx->quote($this->URLfichierPDF));
$URLfichierEMLESC = trim($cnx->quote($this->URLfichierEML));
$descriptionESC = trim($cnx->quote($this->description));
$adresseESC = trim($cnx->quote($this->adresse));
$codePostalESC = trim($cnx->quote($this->codePostal));
$communeESC = trim($cnx->quote($this->commune));
$dateDebutPrevueESC = trim($cnx->quote($this->dateDebutPrevue));
$dureeChantierPrevueESC = trim($cnx->quote($this->dureeChantierPrevue));
$traceGMLESC = trim($cnx->quote($this->traceGML));
$personneContactTravauxESC = trim($cnx->quote($this->personneContactTravaux));
$telephoneContactTravauxESC = trim($cnx->quote($this->telephoneContactTravaux));
$faxContactTravauxESC = trim($cnx->quote($this->faxContactTravaux));
$courrielContactTravauxESC = trim($cnx->quote($this->courrielContactTravaux));
$techniquesSansTrancheesESC = $this->techniquesSansTranchees;
$plansElectriquesAeriensESC = $this->plansElectriquesAeriens;
$modificationProfilTerrainESC = $this->modificationProfilTerrain;
$techniquesUtiliseesESC = trim($cnx->quote($this->techniquesUtilisees));
$noAffaireExecESC = trim($cnx->quote($this->noAffaireExec));
$noAffaireRDPESC = trim($cnx->quote($this->noAffaireRDP));
$profondeurMaxESC = trim($cnx->quote($this->profondeurMax));
$execDenominationESC = trim($cnx->quote($this->execDenomination));
$execCodePostalESC = trim($cnx->quote($this->execCodePostal));
$execAdresseESC = trim($cnx->quote($this->execAdresse));
$execCommuneESC = trim($cnx->quote($this->execCommune));
$rdpDenominationESC = trim($cnx->quote($this->rdpDenomination));
$rdpNumSIRETESC = trim($cnx->quote($this->rdpNumSIRET));
$rdpNumeroVoieESC = trim($cnx->quote($this->rdpNumeroVoie));
$rdpVoieESC = trim($cnx->quote($this->rdpVoie));
$rdpComplementAdresseESC = trim($cnx->quote($this->rdpComplementAdresse));
$rdpCodePostalESC = trim($cnx->quote($this->rdpCodePostal));
$rdpCommuneESC = trim($cnx->quote($this->rdpCommune));
$rdpPaysESC = trim($cnx->quote($this->rdpPays));
$rdpMailESC = trim($cnx->quote($this->rdpMail));
$rdpFaxESC = trim($cnx->quote($this->rdpFax));
$rdpTelephoneESC = trim($cnx->quote($this->rdpTelephone));
$chantierTermineOuAVenirESC = trim($cnx->quote($this->chantierTermineOuAVenir));
$justificationUrgenceESC = trim($cnx->quote($this->justificationUrgence));
$sqlExec = "INSERT INTO executant(\"denomination\", \"adresse\",
\"codePostal\", \"commune\", \"mail\", \"telephone\")
VALUES ($execDenominationESC, $execAdresseESC, $execCodePostalESC,
$execCommuneESC, $courrielContactTravauxESC,
$telephoneContactTravauxESC)";
$sqlRDP = "INSERT INTO \"responsableProjet\" (\"denomination\", \"numSIRET\", \"numeroVoie\", \"voie\", \"complementAdresse\",
\"codePostal\", \"commune\", \"pays\", \"mail\", \"telephone\", \"fax\")
VALUES($rdpDenominationESC, $rdpNumSIRETESC, $rdpNumeroVoieESC, $rdpVoieESC,
$rdpComplementAdresseESC, $rdpCodePostalESC, $rdpCommuneESC, $rdpPaysESC, $rdpMailESC, $rdpTelephoneESC, $rdpFaxESC);";
$sqlDernierRDP = "SELECT MAX(\"idRDP\") FROM \"responsableProjet\";";
$sqlDernierExecutant = "SELECT MAX(\"idExecutant\") FROM \"executant\";";
$cnx->exec($sqlRDP);
$cnx->exec($sqlExec);
$reponseRDP = $cnx->query($sqlDernierRDP);
$idDernierReponsableProjetRentre = $reponseRDP->fetch()[0];
$reponseExecutant = $cnx->query($sqlDernierExecutant);
$idDernierExecutantRentre = $reponseExecutant->fetch()[0];
$sqlATU = "INSERT INTO declaration (\"justificationUrgence\",
\"chantierTermineOuAVenir\",
\"dateReceptionDeclaration\",
\"typeDeclaration\",
\"numeroNationalATU\",
\"nature\",
\"description\",
\"adresse\",
\"commune\",
\"codePostal\",
\"dateDebutPrevue\",
\"dureeChantierPrevue\",
\"personneContactTravaux\",
\"telephoneContactTravaux\",
\"faxContactTravaux\",
\"courrielContactTravaux\",
\"idExecutant\",
\"idRDP\")
VALUES ($justificationUrgenceESC,
$chantierTermineOuAVenirESC,
to_timestamp($dateReceptionDeclarationESC),
$typeDeclarationESC,
$numeroNationalATUESC,
$natureTravauxESC,
$descriptionESC,
$adresseESC,
$communeESC,
$codePostalESC,
$dateDebutPrevueESC,
$dureeChantierPrevueESC,
$personneContactTravauxESC,
$telephoneContactTravauxESC,
$faxContactTravauxESC,
$courrielContactTravauxESC,
$idDernierExecutantRentre,
$idDernierReponsableProjetRentre);";
$cnx->exec($sqlATU);
}
function in_array_r($needle, $haystack, $strict = false) {
foreach ($haystack as $item) {
if (($strict ? $item === $needle : $item == $needle) || (is_array($item) && $this->in_array_r($needle, $item, $strict))) {
return true;
}
}
return false;
}
}
?>
Did this file decode correctly?
Original Code
<?php
require_once("Recepisse.php");
class Declaration
{
/* TABLE DECLARATION */
public $idDeclaration,
$typeDeclaration,
$numConsultationTeleservice,
$numeroNationalDT,
$numeroNationalDICT,
$numeroNationalATU,
$noAffaireRDP,
$noAffaireExec,
$natureTravaux,
$techniquesUtilisees,
$profondeurMax,
$URLfichierXML,
$URLfichierPDF,
$URLfichierEML,
$description,
$adresse,
$nombreCommunes,
$codePostal,
$commune,
$dateDebutPrevue,
$dureeChantierPrevue,
$traceGML,
$techniquesSansTranchees,
$plansElectriquesAeriens,
$modificationProfilTerrain,
$personneContactTravaux,
$telephoneContactTravaux,
$faxContactTravaux,
$courrielContactTravaux,
$personneContactProjet,
$telephoneContactProjet,
$faxContactProjet,
$courrielContactProjet;
// Attributs spcifiques aux ATU :
public $chantierTermineOuAVenir,
$justificationUrgence;
public $dateReceptionDeclaration;
/* Attributs de la table Instruction */
public $instIdDeclaration,
$etat,
$idRecepisse,
$idAgentInstructeur,
$idAgentSignataire;
/* Attributs de la table Executant */
public $idExecutant,
$execDenomination,
$execNumSIRET,
$execComplement,
$execNumeroVoie,
$execVoie,
$execComplementAdresse,
$execCodePostal,
$execAdresse, // Pour l'ATU o l'adresse est en un seul attribut
$execCommune,
$execPays,
$execMail,
$execTelephone,
$execFax;
/* Attributs de la table ResponsableProjet */
public $idRDP,
$rdpDenomination,
$rdpNumSIRET,
$rdpComplement,
$rdpNumeroVoie,
$rdpVoie,
$rdpComplementAdresse,
$rdpCodePostal,
$rdpCommune,
$rdpPays,
$rdpMail,
$rdpFax,
$rdpTelephone;
public $XML; //Objet XML initialis avec le fichier XML de dclaration
private $pdo; // Objet PDO de connexion la base de donnes
private $namespace; // Namespace XML
/**
* Permet d'initialiser une dclaration partir d'un fichier XML pass en paramtre
* <ul>
*
* </ul>
* @param string $URLfichierXML URL du fichier XML de la dclaration
* @param timestamp $dateReceptionDeclaration Date de rception de la dclaration
*
* @return `true` si le traitement s'est bien pass `false` sinon (la dclaration est dj en base par exemple)
*/
public function initialiserDeclarationXML($URLfichierXML, $dateReceptionDeclaration = null){
// Chargement fichier XML dans l'objet XML
$this->XML = simplexml_load_file($URLfichierXML);
// Dfinition du namespace pour XPATH
$this->XML->registerXPathNamespace('t',"http://www.reseaux-et-canalisations.gouv.fr/schema-teleservice/2.2");
$this->namespace = 't:';
// Si $dateReception non renseigne, alors dfinie maintenant
if(is_null($dateReceptionDeclaration)){
$this->dateReceptionDeclaration = time();
} else{
$this->dateReceptionDeclaration = $dateReceptionDeclaration;
}
// On dtermine le type de dclaration
$this->determinerTypeDeclaration();
// On rcupre les numros de dclaration
$this->recupererNumerosDeclaration();
if($this->determinerDejaBase()){
// La dclaration est dj en base, on interrompt le traitement, on retourne false
return false;
}
// else : la dclaration n'est pas dj dans la base
// Recupre les diffrentes donnes du XML
$this->recuperer();
// Cre les diffrentes lignes dans la BD en fonction de la rcupration
$this->entrerDeclarationBD();
return true;
}
/**
* Dtermine le type de dclaration
* <ul>
* <li>dtDictConjointes</li>
* <li>DT</li>
* <li>DICT</li>
* <li>ATU</li>
* </ul>
* @return `true` si l'on a pu affecter le type de dclaration
`false` sinon
*/
public function determinerTypeDeclaration(){
/* On effectue des requtes XPath avec le nom de l'lment juste
* au dessus de la racine du fichier
*/
if(!empty($this->XML->xpath("//$this->namespace" . "dtDictConjointes"))){
$this->typeDeclaration = 'dtDictConjointes';
} else if(!empty($this->XML->xpath("//$this->namespace" ."DT"))){
$this->typeDeclaration = 'DT';
} else if(!empty($this->XML->xpath("//$this->namespace" ."DICT"))){
$this->typeDeclaration = 'DICT';
} else if(!empty($this->XML->xpath("//$this->namespace" . "ATU"))){
$this->typeDeclaration = 'ATU';
}
}
/**
* Rcupre les informations ncessaires en fonction du type de dclaration
*
*/
public function recuperer(){
switch($this->typeDeclaration){
case "dtDictConjointes":
// Attributs pour la table Declaration
// La dclaration est dj en base !
$this->recupererDescription();
$this->recupererNatureTravaux();
$this->recupererAdresse();
$this->recupererCodePostal();
$this->recupererCommune();
$this->recupererTraceGML();
$this->recupererNombreCommunes();
$this->recupererInformationsContactActeurs();
$this->recupererDateDebutPrevue();
$this->recupererDureeChantierPrevue();
/*
* Attributs pour les tables ResponsableProjet
* et Executant
*/
$this->recupererInfosActeurs();
/*
* Attributs "spciaux" uniquement prsents pour
* les DT-DICT, DT et DICT
*/
$this->recupererModificationProfilTerrain();
$this->recupererTechniquesSansTranchees();
$this->recupererPlansElectriquesAeriens();
$this->recupererTechniquesUtilisees();
$this->recupererNoAffaireDeclarant();
$this->recupererProfondeurMax();
break;
case "DT":
// Attributs pour la table Declaration
$this->recupererDescription();
$this->recupererNatureTravaux();
$this->recupererAdresse();
$this->recupererCodePostal();
$this->recupererCommune();
$this->recupererTraceGML();
$this->recupererNombreCommunes();
$this->recupererInformationsContactActeurs();
$this->recupererDateDebutPrevue();
$this->recupererDureeChantierPrevue();
/*
* Attributs pour les tables ResponsableProjet
* et Executant
*/
$this->recupererInfosActeurs();
/*
* Attributs "spciaux" uniquement prsents pour
* les DT-DICT, DT et DICT
*/
$this->recupererModificationProfilTerrain();
$this->recupererTechniquesSansTranchees();
$this->recupererPlansElectriquesAeriens();
$this->recupererTechniquesUtilisees();
$this->recupererNoAffaireDeclarant();
$this->recupererProfondeurMax();
break;
case "DICT":
// Attributs pour la table Declaration
$this->recupererDescription();
$this->recupererNatureTravaux();
$this->recupererAdresse();
$this->recupererCodePostal();
$this->recupererCommune();
$this->recupererTraceGML();
$this->recupererNombreCommunes();
$this->recupererInformationsContactActeurs();
$this->recupererDateDebutPrevue();
$this->recupererDureeChantierPrevue();
/*
* Attributs pour les tables ResponsableProjet
* et Executant
*/
$this->recupererInfosActeurs();
/*
* Attributs "spciaux" uniquement prsents pour
* les DT-DICT, DT et DICT
*/
$this->recupererModificationProfilTerrain();
$this->recupererTechniquesSansTranchees();
$this->recupererPlansElectriquesAeriens();
$this->recupererTechniquesUtilisees();
$this->recupererNoAffaireDeclarant();
$this->recupererProfondeurMax();
break;
case "ATU":
$this->recupererDescription();
$this->recupererAdresse();
$this->recupererCodePostal();
$this->recupererCommune();
$this->recupererTraceGML();
$this->recupererNombreCommunes();
$this->recupererInformationsContactActeurs();
$this->recupererDateDebutPrevue();
$this->recupererDureeChantierPrevue();
$this->recupererInfosActeurs();
$this->recupererJustificationUrgence();
$this->recupererChantierTermineOuAVenir();
break;
default:
/*
* Le type de dclaration ne correspond aucun type connu
* c'est une erreur, on retourne `false`
*/
return false;
}
return true; // le traitement s'est bien pass
}
/*
* Dtermine le numro de dclaration (numro de consultation du tlservice)
* et l'affecte aux champs correspondant la demande (`$numeroNationalDT`,
* `$numeroNationalDICT`, `$numeroNationalATU`)
* <ul>
* <li>Si la dclaration est une DT-DICT alors on affecte le numro aux
* deux champs `$numeroNationalDT` et `$numeroNationalDICT`</li>
* <li>Si la dclaration est une DT alors on affecte le numro au champ
* `$numeroNationalDT`</li>
* <li>Si la dclaration est une DICT alors on affecte le numro au champ
* `$numeroNationalDICT`</li>
* <li>Si la dclaration est une ATU alors on affecte le numro au champ
* `$numeroNationalATU`</li>
* </ul>
* @return bool `true` si l'on a affect la valeur, `false` si une erreur
* est survenue
*/
public function recupererNumerosDeclaration(){
$listeNumeros = $this->XML->xpath("//$this->namespace" . "noConsultationDuTeleservice");
/*
* Dans certains fichiers XML, le numro de consultation est nomm "noConsultationDuTeleserviceSeize"
* alors, si la premire requte XPath n'a rien retourn (a retourn la chane vide), alors on essaie avec
* le deuxime nom (noConsultationDuTeleserviceSeize)
*/
if(!$listeNumeros){
$listeNumeros = $this->XML->xpath("//$this->namespace" . "noConsultationDuTeleserviceSeize");
}
/* Il y a plusieurs occurences du mme numro dans le fichier,
* on prend le premier
*/
$numeroConsultationTeleservice = $listeNumeros[0];
$this->numConsultationTeleservice = $numeroConsultationTeleservice;
switch($this->typeDeclaration){
case "dtDictConjointes":
/* Prsence d'une DT-DICT, on fixe les deux numros DT et DICT
*/
$this->numeroNationalDT = $numeroConsultationTeleservice;
$this->numeroNationalDICT = $numeroConsultationTeleservice;
break;
case "DT":
/* Prsence DT, on fixe seulement le numro DT */
$this->numeroNationalDT = $numeroConsultationTeleservice;
break;
case "DICT":
/* Prsence DICT, on fixe seulement le numro DICT */
$this->numeroNationalDICT = $numeroConsultationTeleservice;
break;
case "ATU":
/* Prsence ATU, on fixe seulement le numro ATU */
$this->numeroNationalATU = $numeroConsultationTeleservice;
break;
default:
/*
* Le type de dclaration ne correspond aucun type connu
* c'est une erreur, on retourne `false`
*/
return false;
}
return true; // Le traitement s'est bien pass
}
/**
* Rcupre la description d'une Dclaration et l'affecte dans la variable
* `$description`
* <ul>
* <li>Si la dclaration est une DT-DICT alors on rcupre la
* description des travaux</li>
* <li>Si la dclaration est une DT alors on rcupre la description
* du projet</li>
* <li>Si la dclaration est une DICT alors on rcupre la
* description des travaux</li>
* <li>Si la dclaration est un ATU, alors on rcupre la seule
* description disponible</li>
* </ul>
* @return bool `true` si l'on a affect la valeur, `false` si une erreur
* est survenue
*/
public function recupererDescription(){
switch($this->typeDeclaration){
case "dtDictConjointes":
$this->description = $this->XML->xpath("//$this->namespace" . "decrivezLesTravaux")[0];
break;
case "DT":
$this->description = $this->XML->xpath("//$this->namespace" . "decrivezLeProjet")[0];
break;
case "DICT":
$this->description = $this->XML->xpath("//$this->namespace" . "decrivezLesTravaux")[0];
break;
case "ATU":
$this->description = $this->XML->xpath("//$this->namespace". "travauxEmplacementDureeDescription/". $this->namespace . "travauxEtMoyensMisEnOeuvre")[0];
default:
/*
* Le type de dclaration ne correspond aucun type connu
* c'est une erreur, on retourne `false`
*/
return false;
}
return true; // le traitement s'est bien pass
}
/**
* Rcupre la nature des travaux :
* Dans le formulaire, la nature des travaux est crite sous la forme d'une
* liste d'abrviations de 3 caractres (la signification de ces
* abrviations est disponible dans l'explication du formulaire DT-DICT,
* CERFA n14434*03)
* La liste est constuite sous la forme XXX , XXX , XXX , ...
* Par exemple : FOV , CHA , RBL , TER
*
* @return bool `true` si l'on a affect la valeur, `false` si une erreur
* est survenue
*/
public function recupererNatureTravaux(){
switch($this->typeDeclaration){
case "dtDictConjointes":
$tblNatures = $this->XML->xpath("//$this->namespace" . "travauxEtLeurCalendrier/". $this->namespace."natureDesTravaux");
$this->natureTravaux = implode(" , ", $tblNatures);
break;
case "DT":
$tblNatures = $this->XML->xpath("//$this->namespace" . "projetEtSonCalendrier/". $this->namespace. "natureDesTravaux");
$this->natureTravaux = implode(" , ", $tblNatures);
break;
case "DICT":
$tblNatures = $this->XML->xpath("//$this->namespace" . "travauxEtLeurCalendrier/". $this->namespace. "natureDesTravaux");
$this->natureTravaux = implode(" , ", $tblNatures);
break;
case "ATU":
break;
default:
/*
* Le type de dclaration ne correspond aucun type connu
* c'est une erreur, on retourne `false`
*/
return false;
}
}
/**
* Rcupre les techniques utilises pour les travaux :
* Dans le formulaire, les techniques utilises pour les travaux
* sont crites sous la forme d'une liste d'abrviations de 3 caractres
* (la signification de ces abrviations est disponible dans l'explication
* du formulaire DT-DICT, CERFA n14434*03)
*
* La liste est constuite sous la forme XXX , XXX , XXX , ...
* Par exemple : BTO , STA , TUN , ECL
*
* @return bool `true` si l'on a affect la valeur, `false` si une erreur
* est survenue
*/
public function recupererTechniquesUtilisees(){
switch($this->typeDeclaration){
case "dtDictConjointes":
$tblTechniques = $this->XML->xpath("//$this->namespace" . "travauxEtLeurCalendrier/". $this->namespace."techniquesUtilisees");
$this->techniquesUtilisees = implode(" , ", $tblTechniques);
break;
case "DT":
$tblTechniques = $this->XML->xpath("//$this->namespace" . "projetEtSonCalendrier/". $this->namespace. "techniquesUtilisees");
$this->techniquesUtilisees = implode(" , ", $tblTechniques);
break;
case "DICT":
$tblTechniques = $this->XML->xpath("//$this->namespace" . "travauxEtLeurCalendrier/". $this->namespace. "techniquesUtilisees");
$this->techniquesUtilisees = implode(" , ", $tblTechniques);
break;
case "ATU":
// La valeur n'est pas disponible dans un ATU
break;
default:
/*
* Le type de dclaration ne correspond aucun type connu
* c'est une erreur, on retourne `false`
*/
return false;
}
return true;
}
/**
* Rcupre l'adresse des travaux / du projet
*
* <ul>
* <li>Si la dclaration est une DT-DICT alors on rcupre l'adresse
* des travaux</li>
* <li>Si la dclaration est une DT alors on rcupre l'adresse
* du projet</li>
* <li>Si la dclaration est une DICT alors on rcupre l'adresse des
* travaux</li>
* <li>Si la dclaration est un ATU, alors on rcupre la seule
* description disponible</li>
* </ul>
*
* @return bool `true` si l'on a affect la valeur, `false` si une erreur
* est survenue
*/
public function recupererAdresse(){
/*
* On rcupre l'adresse en fonction du type de dclaration,
* car l'emplacement dans l'arborescence est diffrent pour chaque type
* de dclaration
*/
switch($this->typeDeclaration){
case "dtDictConjointes":
$this->adresse = $this->XML->xpath("//$this->namespace"."emplacementDesTravaux/". $this->namespace. "adresse")[0];
break;
case "DT":
$this->adresse = $this->XML->xpath("//$this->namespace"."emplacementDuProjet/". $this->namespace. "adresse")[0];
break;
case "DICT":
$this->adresse = $this->XML->xpath("//$this->namespace"."emplacementDesTravaux/". $this->namespace. "adresse")[0];
break;
case "ATU":
$this->adresse = $this->XML->xpath("//$this->namespace"."travauxEmplacementDureeDescription/". $this->namespace. "adresse")[0];
break;
default:
/*
* Le type de dclaration ne correspond aucun type connu
* c'est une erreur, on retourne `false`
*/
return false;
}
return true; // le traitement s'est bien pass
}
/**
* Rcupre le code postal du lieu des travaux / du projet
*
* @return bool `true` si l'on a affect la valeur, `false` si une erreur
* est survenue
*/
public function recupererCodePostal(){
switch($this->typeDeclaration){
case "dtDictConjointes":
$this->codePostal = $this->XML->xpath("//$this->namespace"."emplacementDesTravaux/". $this->namespace. "CP")[0];
break;
case "DT":
$this->codePostal = $this->XML->xpath("//$this->namespace"."emplacementDuProjet/". $this->namespace. "CP")[0];
break;
case "DICT":
$this->codePostal = $this->XML->xpath("//$this->namespace"."emplacementDesTravaux/". $this->namespace. "CP")[0];
break;
case "ATU":
$this->codePostal = $this->XML->xpath("//$this->namespace"."travauxEmplacementDureeDescription/". $this->namespace. "codePostal")[0];
break;
default:
/*
* Le type de dclaration ne correspond aucun type connu
* c'est une erreur, on retourne `false`
*/
return false;
}
return true; // le traitement s'est bien pass
}
/**
* Rcupre la commune des travaux / du projet
*
* @return bool `true` si l'on a affect la valeur, `false` si une erreur
* est survenue
*/
public function recupererCommune(){
switch($this->typeDeclaration){
case "dtDictConjointes":
$this->commune = $this->XML->xpath("//$this->namespace"."emplacementDesTravaux/". $this->namespace. "communePrincipale")[0];
break;
case "DT":
$this->commune = $this->XML->xpath("//$this->namespace"."emplacementDuProjet/". $this->namespace. "communePrincipale")[0];
break;
case "DICT":
$this->commune = $this->XML->xpath("//$this->namespace"."emplacementDesTravaux/". $this->namespace. "communePrincipale")[0];
break;
case "ATU":
$this->commune = $this->XML->xpath("//$this->namespace"."travauxEmplacementDureeDescription/". $this->namespace. "commune")[0];
break;
default:
/*
* Le type de dclaration ne correspond aucun type connu
* c'est une erreur, on retourne `false`
*/
return false;
}
return true; // le traitement s'est bien pass
}
/**
* Rcupre le polygone dcrivant la zone des travaux (au format GML)
* <ul>
* <li>Si la dclaration est une DT, on rcupre le polygone de
* la partie DT</li>
* <li>Si la dclaration est une DICT, on rcupre le polygone de
* la partie DICT</li>
* <li>Si la dclaration est une DT-DICT, on rcupre le polygone de
* la partie DICT</li>
* @return `bool true` si le traitement s'est bien pass, `false` sinon
* </ul>
*/
public function recupererTraceGML(){
switch($this->typeDeclaration){
case "dtDictConjointes":
$tblTraceGML = $this->XML->xpath("//$this->namespace". "emprise/". $this->namespace. "geometrie//*");
$this->traceGML = implode(" , ", $tblTraceGML);
break;
case "DT":
$tblTraceGML = $this->XML->xpath("//$this->namespace". "emprise/". $this->namespace. "geometrie//*");
$this->traceGML = implode(" , ", $tblTraceGML);
break;
case "DICT":
$tblTraceGML = $this->XML->xpath("//$this->namespace". "emprise/". $this->namespace. "geometrie//*");
$this->traceGML = implode(" , ", $tblTraceGML);
break;
case "ATU":
break;
default:
/*
* Le type de dclaration ne correspond aucun type connu
* c'est une erreur, on retourne `false`
*/
return false;
}
return true; // le traitement s'est bien pass
}
/**
* Rcupre les informations des acteurs de la dclaration :
*
* <ul>
* <li>Si la dclaration est une DT, on rcupre les informations
* du responsable de projet.</li>
* <li>Si la dclaration est une DICT, on rcupre les informations
* de l'excutant de travaux.</li>
* <li>Si la dclaration est une DT-DICT, alors on rcupre toutes
* les informations (responsable de projet
* et excutant de travaux).</li>
* <li>Si la dclaration est un ATU, alors on rcupre les informations
* disponibles sur le formulaire (le commanditaire de travaux)</li>
*
* @return bool `true` si l'on a affect la valeur, `false` si une erreur
* est survenue
*/
public function recupererInformationsContactActeurs(){
switch($this->typeDeclaration){
case "dtDictConjointes":
/* Rcupration des informations:
* - de la personne contacter (DICT, excutant de travaux)
* - du reprsentant du reponsable de projet (DT, Responsable de projet)
*/
$this->personneContactTravaux = trim($this->XML->xpath("//$this->namespace"."executantDesTravaux/". $this->namespace. "nomDeLaPersonneAContacter")[0]);
$this->telephoneContactTravaux = trim($this->XML->xpath("//$this->namespace"."executantDesTravaux/". $this->namespace. "tel")[0]);
$this->faxContactTravaux = trim($this->XML->xpath("//$this->namespace"."executantDesTravaux/". $this->namespace. "fax")[0]);
$this->courrielContactTravaux = trim($this->XML->xpath("//$this->namespace"."executantDesTravaux/". $this->namespace. "courriel")[0]);
$this->personneContactProjet = trim($this->XML->xpath("//$this->namespace"."representantDuResponsableDeProjet/". $this->namespace. "denomination")[0]);
$this->telephoneContactProjet = trim($this->XML->xpath("//$this->namespace"."representantDuResponsableDeProjet/". $this->namespace. "tel")[0]);
$this->faxContactProjet = trim($this->XML->xpath("//$this->namespace"."representantDuResponsableDeProjet/". $this->namespace. "fax")[0]);
$this->courrielContactProjet = trim($this->XML->xpath("//$this->namespace"."representantDuResponsableDeProjet/". $this->namespace. "courriel")[0]);
break;
case "DT":
$this->personneContactProjet = trim($this->XML->xpath("//$this->namespace"."representantDuResponsableDeProjet/". $this->namespace. "denomination")[0]);
$this->telephoneContactProjet = trim($this->XML->xpath("//$this->namespace"."representantDuResponsableDeProjet/". $this->namespace. "tel")[0]);
$this->faxContactProjet = trim($this->XML->xpath("//$this->namespace"."representantDuResponsableDeProjet/". $this->namespace. "fax")[0]);
$this->courrielContactProjet = trim($this->XML->xpath("//$this->namespace"."representantDuResponsableDeProjet/". $this->namespace. "courriel")[0]);
break;
case "DICT":
$this->personneContactTravaux = trim($this->XML->xpath("//$this->namespace"."executantDesTravaux/". $this->namespace. "nomDeLaPersonneAContacter")[0]);
$this->telephoneContactTravaux = trim($this->XML->xpath("//$this->namespace"."executantDesTravaux/". $this->namespace. "tel")[0]);
$this->faxContactTravaux = trim($this->XML->xpath("//$this->namespace"."executantDesTravaux/". $this->namespace. "fax")[0]);
$this->courrielContactTravaux = trim($this->XML->xpath("//$this->namespace"."executantDesTravaux/". $this->namespace. "courriel")[0]);
break;
case "ATU":
$this->personneContactTravaux = trim($this->XML->xpath("//$this->namespace"."personneOrdonnantLesTravauxUrgents/". $this->namespace. "nom")[0]);
$this->telephoneContactTravaux = trim($this->XML->xpath("//$this->namespace"."personneOrdonnantLesTravauxUrgents/". $this->namespace. "tel")[0]);
$this->faxContactTravaux = trim($this->XML->xpath("//$this->namespace"."personneOrdonnantLesTravauxUrgents/". $this->namespace. "fax")[0]);
$this->courrielContactTravaux = trim($this->XML->xpath("//$this->namespace"."personneOrdonnantLesTravauxUrgents/". $this->namespace. "courriel")[0]);
break;
default:
/*
* Le type de dclaration ne correspond aucun type connu
* c'est une erreur, on retourne `false`
*/
return false;
}
return true; // le traitement s'est bien pass
}
/**
* Permet de rcuprer les informations des diffrents acteurs prsents dans la dclaration en fonction de son type :
* <ul>
* <li>Si la dclaration est une DT, alors on rcupre les informations du responsable de projet.</li>
* <li>Si la dclaration est une DICT, alors on rcupre les informations de l'excutant de travaux.</li>
* <li>Si la dclaration est une DT-DICT, alors on rcupre les informations des deux.</li>
* <li>Si la dclaration est un ATU, alors on rcupre les informations de l'acteur prsent.</li>
* </ul>
* Ces informations ont vocation tre entres dans les tables `responsableProjet` et `executant`
*
*
* @return `bool true` si le traitement s'est bien pass, `false` sinon.
*/
public function recupererInfosActeurs(){
switch($this->typeDeclaration){
case "dtDictConjointes":
$this->recupererInformationsResponsableProjet();
$this->recupererInformationsExecutantTravaux();
/* $this->afficherAttributsExecTravaux();
$this->afficherAttributsRDP(); */
break;
case "DT":
$this->recupererInformationsResponsableProjet();
/* $this->afficherAttributsRDP(); */
break;
case "DICT":
$this->recupererInformationsExecutantTravaux();
/* $this->afficherAttributsExecTravaux(); */
break;
case "ATU":
$this->recupererInformationsATU();
/* $this->afficherAttributsExecTravaux();
$this->afficherAttributsRDP(); */
break;
default:
/*
* Le type de dclaration ne correspond aucun type connu
* c'est une erreur, on retourne `false`
*/
return false;
}
return true; // le traitement s'est bien pass
}
public function recupererInformationsResponsableProjet(){
$this->rdpDenomination = $this->XML->xpath("//$this->namespace"."responsableDuProjet/". $this->namespace. "denomination")[0];
$this->rdpNumSIRET = $this->XML->xpath("//$this->namespace"."responsableDuProjet/". $this->namespace. "noSIRET")[0];
$this->rdpComplement = $this->XML->xpath("//$this->namespace"."representantDuResponsableDeProjet/". $this->namespace. "complementService")[0];
$this->rdpNumeroVoie = $this->XML->xpath("//$this->namespace"."representantDuResponsableDeProjet/". $this->namespace. "numero")[0];
$this->rdpVoie = $this->XML->xpath("//$this->namespace"."representantDuResponsableDeProjet/". $this->namespace. "voie")[0];
$this->rdpComplementAdresse = $this->XML->xpath("//$this->namespace"."representantDuResponsableDeProjet/". $this->namespace. "complementAdresse")[0];
$this->rdpCodePostal = $this->XML->xpath("//$this->namespace"."representantDuResponsableDeProjet/". $this->namespace. "codePostal")[0];
$this->rdpCommune = $this->XML->xpath("//$this->namespace"."representantDuResponsableDeProjet/". $this->namespace. "commune")[0];
$this->rdpPays = $this->XML->xpath("//$this->namespace"."responsableDuProjet/". $this->namespace. "pays")[0];
$this->rdpMail = $this->XML->xpath("//$this->namespace"."representantDuResponsableDeProjet/". $this->namespace. "courriel")[0];
$this->rdpTelephone = $this->XML->xpath("//$this->namespace"."representantDuResponsableDeProjet/". $this->namespace. "tel")[0];
$this->rdpFax = $this->XML->xpath("//$this->namespace"."representantDuResponsableDeProjet/". $this->namespace. "fax")[0];
}
/**
* Rcupre les informations relatives un excutant de travaux
*
*
*
*/
public function recupererInformationsExecutantTravaux(){
$this->execDenomination = $this->XML->xpath("//$this->namespace"."executantDesTravaux/". $this->namespace. "denomination")[0];
$this->execNumSIRET = $this->XML->xpath("//$this->namespace"."executantDesTravaux/". $this->namespace. "noSIRET")[0];
$this->execComplement = $this->XML->xpath("//$this->namespace"."executantDesTravaux/". $this->namespace. "complementService")[0];
$this->execNumeroVoie = $this->XML->xpath("//$this->namespace"."executantDesTravaux/". $this->namespace. "numero")[0];
$this->execVoie = $this->XML->xpath("//$this->namespace"."executantDesTravaux/". $this->namespace. "voie")[0];
$this->execComplementAdresse = $this->XML->xpath("//$this->namespace"."executantDesTravaux/". $this->namespace. "complementAdresse")[0];
$this->execCodePostal = $this->XML->xpath("//$this->namespace"."executantDesTravaux/". $this->namespace. "codePostal")[0];
$this->execCommune = $this->XML->xpath("//$this->namespace"."executantDesTravaux/". $this->namespace. "commune")[0];
$this->execPays = $this->XML->xpath("//$this->namespace"."executantDesTravaux/". $this->namespace. "pays")[0];
$this->execMail = $this->XML->xpath("//$this->namespace"."executantDesTravaux/". $this->namespace. "courriel")[0];
$this->execTelephone =$this->XML->xpath("//$this->namespace"."executantDesTravaux/". $this->namespace. "tel")[0];
$this->execFax = $this->XML->xpath("//$this->namespace"."executantDesTravaux/". $this->namespace. "fax")[0];
}
public function recupererInformationsATU(){
/* Entreprise charge de l'excution des travaux */
$this->execDenomination = $this->XML->xpath("//$this->namespace"."entrepriseChargeeDeLExecutionDesTravaux/". $this->namespace. "nom")[0];
$this->execAdresse = $this->XML->xpath("//$this->namespace"."entrepriseChargeeDeLExecutionDesTravaux/". $this->namespace. "adresse")[0];
$this->execCodePostal = $this->XML->xpath("//$this->namespace"."entrepriseChargeeDeLExecutionDesTravaux/". $this->namespace. "codePostal")[0];
$this->execCommune = $this->execAdresse = $this->XML->xpath("//$this->namespace"."entrepriseChargeeDeLExecutionDesTravaux/". $this->namespace. "commune")[0];
/* Personne ordonnant les travaux (urgents) */
$this->rdpDenomination = $this->execAdresse = $this->XML->xpath("//$this->namespace"."personneOrdonnantLesTravauxUrgents/". $this->namespace. "nom")[0];
$this->rdpNumeroVoie = $this->execAdresse = $this->XML->xpath("//$this->namespace"."personneOrdonnantLesTravauxUrgents/". $this->namespace. "numero")[0];
$this->rdpVoie = $this->XML->xpath("//$this->namespace"."personneOrdonnantLesTravauxUrgents/". $this->namespace. "voie")[0];
$this->rdpCodePostal = $this->XML->xpath("//$this->namespace"."personneOrdonnantLesTravauxUrgents/". $this->namespace. "codePostal")[0];
$this->rdpCommune = $this->XML->xpath("//$this->namespace"."personneOrdonnantLesTravauxUrgents/". $this->namespace. "commune")[0];
$this->rdpPays = $this->XML->xpath("//$this->namespace"."personneOrdonnantLesTravauxUrgents/". $this->namespace. "pays")[0];
$this->rdpTelephone = $this->XML->xpath("//$this->namespace"."personneOrdonnantLesTravauxUrgents/". $this->namespace. "tel")[0];
$this->rdpFax = $this->XML->xpath("//$this->namespace"."personneOrdonnantLesTravauxUrgents/". $this->namespace. "fax")[0];
$this->rdpMail = $this->XML->xpath("//$this->namespace"."personneOrdonnantLesTravauxUrgents/". $this->namespace. "courriel")[0];
}
/**
* Rcupre le nombre de communes concernes par la dclaration
* <ul>
* <li>Si la dclaration est une DT, alors on rcupre la valeur
* de la partie DT</li>
* <li>Si la dclaration est une DICT, alors on rcupre la valeur
* de la partie DICT</li>
* <li>Si la dclaration est une DT-DICT, alors on rcupre la valeur
* de la partie DICT</li>
* </ul>
* @return `bool true` si le traitement s"est bien pass, `false` sinon
*/
public function recupererNombreCommunes(){
switch($this->typeDeclaration){
case "dtDictConjointes":
$this->nombreCommunes = $this->XML->xpath("//$this->namespace"."emplacementDesTravaux/". $this->namespace. "nombreDeCommunes")[0];
break;
case "DT":
$this->nombreCommunes = $this->XML->xpath("//$this->namespace" ."emplacementDuProjet/". $this->namespace. "nombreDeCommunes")[0];
break;
case "DICT":
$this->nombreCommunes = $this->XML->xpath("//$this->namespace"."emplacementDesTravaux/".$this->namespace."nombreDeCommunes")[0];
break;
case "ATU":
// La valeur n'est pas prsente dans un ATU
break;
default:
/*
* Le type de dclaration ne correspond aucun type connu
* c"est une erreur, on retourne `false`
*/
return false;
}
return true; // le traitement s"est bien pass
}
/**
* Rcupre la date de dbut prvue du chantier au format :
* AAAA-MM-JJ+HH:MiMi
* o HH:MiMi est le fuseau horaire par rapport UTC
* Pour la France mtropolitaine, en hiver +HH:MiMi vaut +01:00
* et en t +02:00
*
*
* <ul>
* <li>Si la dclaration est une DT, alors on rcupre la valeur
* de la partie DT</li>
* <li>Si la dclaration est une DICT, alors on rcupre la valeur
* de la partie DICT</li>
* <li>Si la dclaration est une DT-DICT, alors on rcupre la valeur
* de la partie DICT</li>
* <li>Si la dclaration est un ATU, alors on rcupre la valeur de
* dbut des travaux de la partie ATU</li>
* </ul>
* @return `bool true` si le traitement s"est bien pass, `false` sinon
*/
public function recupererDateDebutPrevue(){
switch($this->typeDeclaration){
case "dtDictConjointes":
$this->dateDebutPrevue = $this->XML->xpath("//$this->namespace"."travauxEtLeurCalendrier/".$this->namespace."datePrevuePourLeCommencementDesTravaux")[0];
break;
case "DT":
$this->dateDebutPrevue = $this->XML->xpath("//$this->namespace" ."projetEtSonCalendrier/".$this->namespace."datePrevuePourLeCommencementDesTravaux")[0];
break;
case "DICT":
$this->dateDebutPrevue = $this->XML->xpath("//$this->namespace". "travauxEtLeurCalendrier/".$this->namespace."datePrevuePourLeCommencementDesTravaux")[0];
break;
case "ATU":
// Date de dbut effective (ATU)
$this->dateDebutPrevue = $this->XML->xpath("//$this->namespace". "travauxEmplacementDureeDescription/".$this->namespace."dateDebutDesTravaux")[0];
break;
default:
/*
* Le type de dclaration ne correspond aucun type connu
* c"est une erreur, on retourne `false`
*/
return false;
}
return true; // le traitement s"est bien pass
}
/**
* Rcupre la dure prvue du chantier
* <ul>
* <li>Si la dclaration est une DT, alors on rcupre la valeur
* de la partie DT</li>
* <li>Si la dclaration est une DICT, alors on rcupre la valeur
* de la partie DICT</li>
* <li>Si la dclaration est une DT-DICT, alors on rcupre la valeur
* de la partie DICT</li>
* </ul>
* /!\ Pour les DT-DICT, DT et DICT, la dure est exprime en jours
* Pour les ATU, la dure est exprime en demi-journees
* @return `bool true` si le traitement s'est bien pass, `false` sinon
*/
public function recupererDureeChantierPrevue(){
switch($this->typeDeclaration){
case "dtDictConjointes":
// Dure exprime en jours
$this->dureeChantierPrevue = $this->XML->xpath("//$this->namespace"."travauxEtLeurCalendrier/".$this->namespace."dureeDuChantierEnJours")[0];
break;
case "DT":
// Dure exprime en jours
$this->dureeChantierPrevue = $this->XML->xpath("//$this->namespace"."projetEtSonCalendrier/".$this->namespace."dureeDuChantierEnJours")[0];
break;
case "DICT":
// Dure exprime en jours
$this->dureeChantierPrevue = $this->XML->xpath("//$this->namespace"."travauxEtLeurCalendrier/".$this->namespace."dureeDuChantierEnJours")[0];
break;
case "ATU":
// Dure exprime en demi-journes
$this->dureeChantierPrevue = $this->XML->xpath("//$this->namespace". "travauxEmplacementDureeDescription/".$this->namespace."dureeTravauxDemiJournees")[0];
break;
default:
/*
* Le type de dclaration ne correspond aucun type connu
* c"est une erreur, on retourne `false`
*/
return false;
}
return true; // le traitement s"est bien pass
}
/**
* Rcupre le boolen disant si le chantier va employer des techniques
* sans tranches ou pas
* <ul>
* <li>Si la dclaration est une DT, alors on rcupre la valeur
* de la partie DT</li>
* <li>Si la dclaration est une DICT, alors on rcupre la valeur
* de la partie DICT</li>
* <li>Si la dclaration est une DT-DICT, alors on rcupre la valeur
* de la partie DICT</li>
* </ul>*
* La valeur de sortie est caste en boolen :
* <ul>
* <li>`true` si le chantier va employer des techniques sans tranches</li>
* <li>`false` si le chantier ne va pas employer des techniques sans tranches</li>
* @return `bool true` si le traitement s"est bien pass, `false` sinon
*/
public function recupererTechniquesSansTranchees(){
switch($this->typeDeclaration){
case "dtDictConjointes":
$tmp =
$this->XML->xpath("//$this->namespace"."travauxEtLeurCalendrier/".$this->namespace."emploiDeTechniquesSansTranchees")[0];// === 'true' ? true : false;
$this->techniquesSansTranchees = empty($tmp) ? 'null' : $tmp;
break;
case "DT":
$tmp =
$this->XML->xpath("//$this->namespace"."projetEtSonCalendrier/".$this->namespace."emploiDeTechniquesSansTranchees")[0];// === 'true' ? true : false;
$this->techniquesSansTranchees = empty($tmp) ? 'null' : $tmp;
break;
case "DICT":
$tmp =
$this->XML->xpath("//$this->namespace"."travauxEtLeurCalendrier/".$this->namespace."emploiDeTechniquesSansTranchees")[0];// === 'true' ? true : false;
$this->techniquesSansTranchees = empty($tmp) ? 'null' : $tmp;
break;
case "ATU":
// Cette demande n'est pas disponible dans un ATU
break;
default:
/*
* Le type de dclaration ne correspond aucun type connu
* c'est une erreur, on retourne `false`
*/
return false;
}
return true; // le traitement s'est bien pass
}
/**
* Rcupre le boolen disant si le dclarant souhaite les plans des rseaux
* lectriques ariens
* <ul>
* <li>Si la dclaration est une DT, alors on rcupre la valeur
* de la partie DT</li>
* <li>Si la dclaration est une DICT, alors on rcupre la valeur
* de la partie DICT</li>
* <li>Si la dclaration est une DT-DICT, alors on rcupre la valeur
* de la partie DICT</li>
* <li>Dans la cas d'un ATU, la valeur est absente</li>
* </ul>
* @return `bool true` si le traitement s'est bien pass, `false` sinon
*/
public function recupererPlansElectriquesAeriens(){
switch($this->typeDeclaration){
case "dtDictConjointes":
$tmp =
$this->XML->xpath("//$this->namespace"."travauxEtLeurCalendrier/".$this->namespace."souhaitLesPlansDesReseauxElectriqueAeriens")[0];// === 'true' ? true : false;
$this->plansElectriquesAeriens = empty($tmp) ? 'null' : $tmp;
break;
case "DT":
$tmp =
$this->XML->xpath("//$this->namespace"."projetEtSonCalendrier/".$this->namespace."souhaitLesPlansDesReseauxElectriqueAeriens")[0];// === 'true' ? true : false;
$this->plansElectriquesAeriens = empty($tmp) ? 'null' : $tmp;
break;
case "DICT":
$tmp =
$this->XML->xpath("//$this->namespace"."travauxEtLeurCalendrier/".$this->namespace."souhaitLesPlansDesReseauxElectriqueAeriens")[0];// === 'true' ? true : false;
$this->plansElectriquesAeriens = empty($tmp) ? 'null' : $tmp;
break;
case "ATU":
// Cette demande n'est pas disponible dans un ATU
break;
default:
/*
* Le type de dclaration ne correspond aucun type connu
* c"est une erreur, on retourne `false`
*/
return false;
}
return true; // le traitement s'est bien pass
}
/**
* Rcupre la profondeur maximale d'excavation de la dclaration
* <ul>
* <li>Si la dclaration est une DT, alors on rcupre la valeur
* de la partie DT</li>
* <li>Si la dclaration est une DICT, alors on rcupre la valeur
* de la partie DICT</li>
* <li>Si la dclaration est une DT-DICT, alors on rcupre la valeur
* de la partie DICT</li>
* <li>Dans la cas d'un ATU, la valeur est absente</li>
* </ul>
* @return `bool true` si le traitement s'est bien pass, `false` sinon
*/
public function recupererProfondeurMax(){
switch($this->typeDeclaration){
case "dtDictConjointes":
$profMax = $this->XML->xpath("//$this->namespace"."travauxEtLeurCalendrier/".$this->namespace."profondeurMaxDExcavation")[0];
$this->profondeurMax = empty($profMax) ? -1 : $profMax;
break;
case "DT":
$profMax = $this->XML->xpath("//$this->namespace"."projetEtSonCalendrier/".$this->namespace."profondeurMaxDExcavation")[0];
$this->profondeurMax = empty($profMax) ? -1 : $profMax;
break;
case "DICT":
$profMax = $this->XML->xpath("//$this->namespace"."travauxEtLeurCalendrier/".$this->namespace."profondeurMaxDExcavation")[0];
$this->profondeurMax = empty($profMax) ? -1 : $profMax;
break;
case "ATU":
// Cette demande n'est pas disponible dans un ATU
break;
default:
/*
* Le type de dclaration ne correspond aucun type connu
* c"est une erreur, on retourne `false`
*/
return false;
}
return true; // le traitement s'est bien pass
}
/**
* Rcupre le boolen indiquant si il y aura une modification
* du profil du terrain aprs les travuax
*
*
*/
public function recupererModificationProfilTerrain(){
switch($this->typeDeclaration){
case "dtDictConjointes":
$this->tmp =
$this->XML->xpath("//$this->namespace"."travauxEtLeurCalendrier/".$this->namespace."modificationProfilTerrain")[0];// === 'true' ? true : false;
$this->modificationProfilTerrain = empty($tmp) ? 'null' : $tmp;
break;
case "DT":
$this->modificationProfilTerrain =
$this->XML->xpath("//$this->namespace"."projetEtSonCalendrier/".$this->namespace."modificationProfilTerrain")[0];// === 'true' ? true : false;
$this->modificationProfilTerrain = empty($tmp) ? 'null' : $tmp;
break;
case "DICT":
$tmp =
$this->XML->xpath("//$this->namespace"."travauxEtLeurCalendrier/".$this->namespace."modificationProfilTerrain")[0];// === 'true' ? true : false;
$this->modificationProfilTerrain = empty($tmp) ? 'null' : $tmp;
break;
case "ATU":
// Cette demande n'est pas disponible dans un ATU
break;
default:
/*
* Le type de dclaration ne correspond aucun type connu
* c"est une erreur, on retourne `false`
*/
return false;
}
return true; // le traitement s'est bien pass
}
/**
* Rcupre le numro d'affaire du dclarant (excutant ou responsable de projet)
* <ul>
* <li>Si la dclaration est une DT, alors on rcupre le numro d'affaire
* du responsable de projet</li>
* <li>Si la dclaration est une DICT, alors on rcupre le numro d'affaire
* de l'excutant.</li>
* <li>Si la dclaration est une DT-DICT, alors on rcupre le numro d'affaire
* de l'excutant et du responsable de projet.</li>
* </ul>
* @return `bool true` si le traitement s'est bien pass, `false` sinon
*/
public function recupererNoAffaireDeclarant(){
switch($this->typeDeclaration){
case "dtDictConjointes":
// dtDictConjointes, on rcupre les numros d'affaire de l'excutant et du responsable de projet
$this->noAffaireExec = $this->XML->xpath("//$this->namespace"."noAffaireDeLexecutantDesTravaux")[0];
$this->noAffaireRDP = $this->XML->xpath("//$this->namespace"."noAffaireDuResponsableDuProjet")[0];
break;
case "DT":
// DT, on rcupre le numro d'affaire du responsable de projet uniquement
$this->noAffaireRDP = $this->XML->xpath("//$this->namespace"."noAffaireDuResponsableDuProjet")[0];
break;
case "DICT":
// DICT, on rcupre le numro d'affaire de l'excutant
$this->noAffaireExec = $this->XML->xpath("//$this->namespace"."noAffaireDeLexecutantDesTravaux")[0];
break;
case "ATU":
// Pas de numro d'affaire prsent dans un ATU
break;
default:
/*
* Le type de dclaration ne correspond aucun type connu
* c'est une erreur, on retourne `false`
*/
return false;
}
return true; // le traitement s'est bien pass
}
/**
* Rcupre la justification de l'urgence pour l'ATU
* Diffrentes cases sont cochables.
* si la case est coche (boolen true),
* alors on dfinit une variable avec un acronyme :
* <ul>
* <li>Scurit : SECU</li>
* <li>Continuit du service public : SVCE</li>
* <li>Sauvegarde des personnes et des biens : SAUV</li>
* <li>Cas de force majeure : FOMA</li>
* </ul>
* Le rsultat est la concatnation des diffrents choix
* Par exemple : SECU , SVCE
* @return `bool true` si le traitement s'est bien pass, `false` sinon
*/
public function recupererJustificationUrgence(){
// On rcupre uniquement en cas d'ATU
if($this->typeDeclaration == "ATU"){
/* On rcupre les valeurs dans le XML :
* Si la valeur est `true`, alors on dfinit une variable
* avec un acronyme tel que list au pralable
*/
$tblJustif = array();
$i = 0;
$securite = strcmp($this->XML->xpath("//$this->namespace" . "securite")[0], 'true') == 0 ? 'SECU' : 'NSECU';
$continuiteServicePublic = strcmp($this->XML->xpath("//$this->namespace" . "continuiteDuServicePublic")[0], 'true') == 0 ? 'SVCE' : 'NSVCE';
$sauvegardePersonnes = strcmp($this->XML->xpath("//$this->namespace" . "sauvegardeDesPersonnesEtDesBiens")[0], 'true') == 0 ? 'SAUV' : 'NSAUV';
$forceMajeure = strcmp($this->XML->xpath("//$this->namespace" . "casDeForceMajeure")[0], 'true') == 0 ? 'FOMA' : 'NFOMA';
/*
* On cre un tableau, si la valeur est prsente (c'est--dire pas null)
* alors on la rajoute dans le tableau
*
*/
if(strcmp($securite, 'NSECU')){
$tblJustif[$i] = $securite;
$i++;
}
if(strcmp($continuiteServicePublic, 'NSVCE')){
$tblJustif[$i] = $continuiteServicePublic;
$i++;
}
if(strcmp($sauvegardePersonnes, 'NSAUV')){
$tblJustif[$i] = $sauvegardePersonnes;
$i++;
}
if(strcmp($forceMajeure, 'NFOMA')){
$tblJustif[$i] = $forceMajeure;
$i++;
}
// On cre une liste partir du tableau
$this->justificationUrgence = implode(" , ", $tblJustif);
return true; // Le traitement s'est bien pass
} else return false; // Nous ne sommes pas dans le cas d'un ATU, alors on retourne false
}
/*
* Rcupre, dans le cas d'un ATU, la valeur disant si le chantier est
* termin ou est venir.
* Si le boolen `reponseAttendueChantierAVenir` est `true`, alors le
* champ `chantierTermineOuAVenir` est mis 'A venir', sinon, le chantier
* est termin
* @return `bool true` si le traitement s'est bien pass, `false` sinon
*/
public function recupererChantierTermineOuAVenir(){
// Fonction uniquement utilisable si on est avec un ATU
if($this->typeDeclaration == "ATU"){
/*
* Requte XPath :
* Si le boolen de chantier venir est true, alors le chantier est venir
* Sinon, alors le chantier est termin
*
*/
$this->chantierTermineOuAVenir =
$this->XML->xpath("//$this->namespace"."chantierTermineOuChantierAVenir/".$this->namespace."reponseAttendueChantierAVenir")[0] === 'true' ? 'A venir' : 'Termin';
} else return false; // Nous ne sommes pas dans le cas d'un ATU, alors on retourne false
}
/* - - - - - - - - Fonctions d'affichage - - - - - - - - */
public function afficherAttributsVarDump(){
echo "Type dclaration : ";
var_dump($this->typeDeclaration);
echo "<br/>";
echo "Num DT : ";
var_dump($this->numeroNationalDT);
echo "<br/>";
echo "Num DICT : ";
var_dump($this->numeroNationalDICT);
echo "<br/>";
echo "Num ATU : ";
var_dump($this->numeroNationalATU);
echo "<br/>";
echo "Nature : ";
var_dump($this->natureTravaux);
echo "<br/>";
echo "Description : ";
var_dump($this->description);
echo "<br/>";
echo "Trace GML : ";
var_dump($this->traceGML);
echo "<br/>";
echo "Adresse : ";
var_dump($this->adresse);
echo "<br/>";
echo "Nombre communes : ";
var_dump($this->nombreCommunes);
echo "<br/>";
echo "Code postal : ";
var_dump($this->codePostal);
echo "<br/>";
echo "Commune : ";
var_dump($this->commune);
echo "<br/>";
echo "Date debut prvue : ";
var_dump($this->dateDebutPrevue);
echo "<br/>";
echo "Dure chantier prvue :";
var_dump($this->dureeChantierPrevue);
echo "<br/>";
echo "Techniques sans tranchees : ";
var_dump($this->techniquesSansTranchees);
echo "<br/>";
}
public function afficherAttributsEcho(){
echo "Type dclaration : ";
echo "$this->typeDeclaration";
echo "<br/>";
echo "Num DT : ";
echo "$this->numeroNationalDT";
echo "<br/>";
echo "Num DICT : ";
echo "$this->numeroNationalDICT";
echo "<br/>";
echo "Num ATU : ";
echo "$this->numeroNationalATU";
echo "<br/>";
echo "Nature : ";
echo "$this->natureTravaux";
echo "<br/>";
echo "Description : ";
echo "$this->description";
echo "<br/>";
echo "Trace GML : ";
echo "$this->traceGML";
echo "<br/>";
echo "Adresse : ";
echo "$this->adresse";
echo "<br/>";
echo "Nombre communes : ";
echo "$this->nombreCommunes";
echo "<br/>";
echo "Code postal : ";
echo "$this->codePostal";
echo "<br/>";
echo "Commune : ";
echo "$this->commune";
echo "<br/>";
echo "Date de dbut prvue :";
echo "$this->dateDebutPrevue";
echo "<br/>";
echo "Dure chantier prvue :";
echo "$this->dureeChantierPrevue";
echo "<br/>";
echo "Techniques sans tranchees : ";
echo ($this->techniquesSansTranchees) ?'true':'false';
echo "<br/>";
}
public function afficherAttributsRDP(){
echo "<hr/>";
echo "<center><h1> Informations relatives au responsable de projet </h1></center>";
echo "Denomination : ";
echo "$this->rdpDenomination";
echo "<br/>";
echo "Num. SIRET : ";
echo "$this->rdpNumSIRET";
echo "<br/>";
echo "Complment (service) : ";
echo "$this->rdpComplement";
echo "<br/>";
echo "Numro voie : ";
echo "$this->rdpNumeroVoie";
echo "<br/>";
echo "Voie : ";
echo "$this->rdpVoie";
echo "<br/>";
echo "Complment adresse : ";
echo "$this->rdpComplementAdresse";
echo "<br/>";
echo "Code Postal : ";
echo "$this->rdpCodePostal";
echo "<br/>";
echo "Commune : ";
echo "$this->rdpCommune";
echo "<br/>";
echo "Pays : ";
echo "$this->rdpPays";
echo "<br/>";
echo "Mail : ";
echo "$this->rdpMail";
echo "<br/>";
echo "Tlphone : ";
echo "$this->rdpTelephone";
echo "<br/>";
echo "Fax : ";
echo "$this->rdpFax";
echo "<br/>";
}
public function afficherAttributsExecTravaux(){
echo "<hr/>";
echo "<center><h1> Informations relatives l'excutant de travaux </h1></center>";
echo "Denomination : ";
echo "$this->execDenomination";
echo "<br/>";
echo "Num. SIRET : ";
echo "$this->execNumSIRET";
echo "<br/>";
echo "Complment (service) : ";
echo "$this->execComplement";
echo "<br/>";
echo "Numro voie : ";
echo "$this->execNumeroVoie";
echo "<br/>";
echo "Voie : ";
echo "$this->execVoie";
echo "<br/>";
echo "Complment adresse : ";
echo "$this->execComplementAdresse";
echo "<br/>";
echo "Code Postal : ";
echo "$this->execCodePostal";
echo "<br/>";
echo "Commune : ";
echo "$this->execCommune";
echo "<br/>";
echo "Pays : ";
echo "$this->execPays";
echo "<br/>";
echo "Mail : ";
echo "$this->execMail";
echo "<br/>";
echo "Tlphone : ";
echo "$this->execTelephone";
echo "<br/>";
echo "Fax : ";
echo "$this->execFax";
echo "<br/>";
}
/* - - - - - - - - Fonctions lies l'Instruction - - - - - - - - */
/**
* Dbute l'instruction de la Dclaration:
* Cre une ligne dans la table Instruction avec l'idDeclaration.
* On place l'tat de l'instruction 0
*
*/
public function debuterInstruction(){
// On rcupre l'id de la Dclaration
$this->recupererIdDeclaration();
// Connexion au SGBD
$cnx = $this->connexionBD();
$sqlInstruction = "INSERT INTO \"instruction\" (\"idDeclaration\", \"etat\",\"idAgentInstructeur\", \"idAgentSignataire\")
VALUES ($this->idDeclaration, 0, 1, 2);";
$cnx->exec($sqlInstruction);
}
/**
* Cre l'objet `Recepisse` relatif la `Declaration` courante
* Egalement,
* @return Recepisse Objet Recepisse
*/
public function creerRecepisse(){
// Requte SQL de cration du Rcpiss avec l'id de dclaration en cl trangre
// Egalement, on spcifie le numro de rfrence de rseau pour lequel on cre le Rcpiss
// /!\ Pour les tests, ici, on initialise le numro de rseau 1
$sqlRecepisse = "INSERT INTO \"recepisse\" (\"idDeclaration\", \"idReseau\")
VALUES($this->idDeclaration, 1);";
// Requte de rcupration de l'id de Rcpisse
$sqlRecupRecep = "SELECT MAX(\"idRecepisse\") FROM \"recepisse\";";
// Cration de la connexion BD
$cnx = $this->connexionBD();
$cnx->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
// On cre la ligne dans la table Recepisse avec l'id de Dclaration
$cnx->exec($sqlRecepisse);
// On rcupre l'id de rcpiss
$reponseRecup = $cnx->query($sqlRecupRecep);
$this->idRecepisse = $reponseRecup->fetch()[0];
// Requte de mise jour de la ligne de la table Rcpisse
$sqlUpdateInstruction = "UPDATE \"instruction\"
SET \"idRecepisse\" = $this->idRecepisse
WHERE \"idDeclaration\" = $this->idDeclaration;";
$cnx->exec($sqlUpdateInstruction);
// On cre l'objet Recepisse, on le retourne
return new Recepisse($this->idRecepisse);
}
/* - - - - - - - - Fonctions lies aux BD - - - - - - - - */
/**
* Cre une connexion la base de donnes
* @param $SGBD string Le SGBD utilis. Paramtre sous une forme spcifique.
* @see http://php.net/manual/fr/pdo.drivers.php
* @param $hote string Nom de l'hte / IP de connexion au SGBD
* @param $port string Port utilis par le SGBD
* @param $nomBD string Nom de la base de donnes utilise par l'application
* @param $util string Nom d'utilisateur dans le SGBD
* @param $mdp string Mot de passe d'accs
*
* @return $pdo PDO Si la connexion est tablie, sinon retourne `null` si la
* connexion n'a pas pu tre tablie.
*/
public function connexionBD(/*$SGBD, $hote, $port, $nomBD, $util, $mdp*/){
$SGBD = 'pgsql';
$hote = 'localhost';
$port = '5432';
$nomBD = 'adicttests';
$util = 'adicttests';
$mdp = 'adicttests';
try{
$pdo = new PDO("$SGBD:host=$hote;port=$port;dbname=$nomBD", $util, $mdp);
} catch(PDOException $e){
echo "<br/>";
echo "<hr/>";
echo 'Connexion choue' . $e->getMessage();
return null;
}
return $pdo;
}
/**
* Rcupre l'id de la Dclaration courante (rentre dernirement en base de donnes)
*
*/
public function recupererIdDeclaration(){
$cnx = $this->connexionBD();
$cnx->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$sqlRecupDecl = "SELECT MAX(\"idDeclaration\") FROM \"declaration\";";
$reponseRecup = $cnx->query($sqlRecupDecl);
$this->idDeclaration = $reponseRecup->fetch()[0];
}
/**
* Dtermine si la dclaration courante est dj entre dans la base de donnes
*
* @return `true` si la dclaration est dj dans la base, `false sinon`
*/
public function determinerDejaBase(){
$cnx = $this->connexionBD();
$sqlDejaBase = "SELECT \"declaration\".\"numeroNationalDT\", \"declaration\".\"numeroNationalDICT\", \"declaration\".\"numeroNationalATU\"
FROM \"declaration\"";
$reponse = $cnx->query($sqlDejaBase);
$tblReponse = $reponse->fetchAll();
// Cette fonction retourne true si le numro de consultation courant est prsent dans le tableau retourn par la requte
return $this->in_array_r($this->numConsultationTeleservice, $tblReponse);
}
/**
* Permet d'entrer en Base de Donnes une dclaration pralablement initialise
* avec la fonction `initialiserDeclarationXML()`
* Cette fonction, en fonction du type de dclaration, appelle une fonction spcifique
* permettant d'entrer en base de donnes les donnes ncessaires
*
*/
public function entrerDeclarationBD(){
switch($this->typeDeclaration){
case "dtDictConjointes":
$this->entrerDTDICT();
break;
case "DT":
$this->entrerDT();
break;
case "DICT":
$this->entrerDICT();
break;
case "ATU":
$this->entrerATU();
break;
default:
/*
* Le type de dclaration ne correspond aucun type connu
* c'est une erreur, on retourne `false`
*/
return false;
}
return true; // le traitement s'est bien pass
}
/**
* Fonction permettant de rentrer une DT-DICT conjointe (dtDictConjointes) dans la
* base de donnees:
* <ul>
* <li>Les informations relatives au responsable de projet sont
* stockes dans la table `responsableProjet`</li>
* <li>Les informations relatives l'excutant de travaux sont
* stockes dans la table `executant`</li>
* </ul>
*/
private function entrerDTDICT(){
$cnx = $this->connexionBD();
$cnx->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
/*
* On "trime" (on retire les caractres invisibles en dbut et fin de chane)
* les chanes que l'on a extrait du XML
* On utilise la fonction PDO::quote place des guillemets simples autour de la
* si ncessaire et protge les caractres spciaux ventuellement prsents.
* en fonction du SGBD utilis par l'instance PDO.
*/
$dateReceptionDeclarationESC = trim($cnx->quote($this->dateReceptionDeclaration));
$typeDeclarationESC = trim($cnx->quote($this->typeDeclaration));
$numeroNationalDTESC = trim($cnx->quote($this->numeroNationalDT));
$numeroNationalDICTESC = trim($cnx->quote($this->numeroNationalDICT));
$numeroNationalATUESC = trim($cnx->quote($this->numeroNationalATU));
$natureTravauxESC = trim($cnx->quote($this->natureTravaux));
$URLfichierXMLESC = trim($cnx->quote($this->URLfichierXML));
$URLfichierPDFESC = trim($cnx->quote($this->URLfichierPDF));
$URLfichierEMLESC = trim($cnx->quote($this->URLfichierEML));
$descriptionESC = trim($cnx->quote($this->description));
$adresseESC = trim($cnx->quote($this->adresse));
$nombreCommunesESC = trim($cnx->quote($this->nombreCommunes));
$codePostalESC = trim($cnx->quote($this->codePostal));
$communeESC = trim($cnx->quote($this->commune));
$dateDebutPrevueESC = trim($cnx->quote($this->dateDebutPrevue));
$dureeChantierPrevueESC = trim($cnx->quote($this->dureeChantierPrevue));
$traceGMLESC = trim($cnx->quote($this->traceGML));
$personneContactProjetESC = trim($cnx->quote($this->personneContactProjet));
$telephoneContactProjetESC = trim($cnx->quote($this->telephoneContactProjet));
$faxContactProjetESC = trim($cnx->quote($this->faxContactProjet));
$courrielContactProjetESC = trim($cnx->quote($this->courrielContactProjet));
$personneContactTravauxESC = trim($cnx->quote($this->personneContactTravaux));
$telephoneContactTravauxESC = trim($cnx->quote($this->telephoneContactTravaux));
$faxContactTravauxESC = trim($cnx->quote($this->faxContactTravaux));
$courrielContactTravauxESC = trim($cnx->quote($this->courrielContactTravaux));
$techniquesUtiliseesESC = trim($cnx->quote($this->techniquesUtilisees));
$noAffaireExecESC = trim($cnx->quote($this->noAffaireExec));
$noAffaireRDPESC = trim($cnx->quote($this->noAffaireRDP));
$profondeurMaxESC = trim($cnx->quote($this->profondeurMax));
$techniquesSansTrancheesESC = $this->techniquesSansTranchees;
$plansElectriquesAeriensESC = $this->plansElectriquesAeriens;
$modificationProfilTerrainESC = $this->modificationProfilTerrain;
$execDenominationESC = trim($cnx->quote($this->execDenomination));
$execNumSIRETESC = trim($cnx->quote($this->execNumSIRET));
$execComplementESC = trim($cnx->quote($this->execComplement));
$execNumeroVoieESC = trim($cnx->quote($this->execNumeroVoie));
$execVoieESC = trim($cnx->quote($this->execVoie));
$execComplementAdresseESC = trim($cnx->quote($this->execComplementAdresse));
$execCodePostalESC = trim($cnx->quote($this->execCodePostal));
$execAdresseESC = trim($cnx->quote($this->execAdresse));
$execCommuneESC = trim($cnx->quote($this->execCommune));
$execPaysESC = trim($cnx->quote($this->execPays));
$execMailESC = trim($cnx->quote($this->execMail));
$execTelephoneESC = trim($cnx->quote($this->execTelephone));
$execFaxESC = trim($cnx->quote($this->execFax));
$rdpDenominationESC = trim($cnx->quote($this->rdpDenomination));
$rdpNumSIRETESC = trim($cnx->quote($this->rdpNumSIRET));
$rdpComplementESC = trim($cnx->quote($this->rdpComplement));
$rdpNumeroVoieESC = trim($cnx->quote($this->rdpNumeroVoie));
$rdpVoieESC = trim($cnx->quote($this->rdpVoie));
$rdpComplementAdresseESC = trim($cnx->quote($this->rdpComplementAdresse));
$rdpCodePostalESC = trim($cnx->quote($this->rdpCodePostal));
$rdpCommuneESC = trim($cnx->quote($this->rdpCommune));
$rdpPaysESC = trim($cnx->quote($this->rdpPays));
$rdpMailESC = trim($cnx->quote($this->rdpMail));
$rdpFaxESC = trim($cnx->quote($this->rdpFax));
$rdpTelephoneESC = trim($cnx->quote($this->rdpTelephone));
$sqlExec = "INSERT INTO executant (\"denomination\", \"numSIRET\", \"complement\", \"numeroVoie\", \"voie\", \"complementAdresse\",
\"codePostal\", \"commune\", \"pays\", \"mail\", \"telephone\", \"fax\")
VALUES ($execDenominationESC, $execNumSIRETESC, $execComplementESC, $execNumeroVoieESC, $execVoieESC,
$execComplementAdresseESC, $execCodePostalESC, $execCommuneESC, $execPaysESC, $execMailESC, $execTelephoneESC, $execFaxESC);";
$sqlRDP = "INSERT INTO \"responsableProjet\" (\"denomination\", \"numSIRET\", \"complement\", \"numeroVoie\", \"voie\", \"complementAdresse\",
\"codePostal\", \"commune\", \"pays\", \"mail\", \"telephone\", \"fax\")
VALUES($rdpDenominationESC,$rdpNumSIRETESC, $rdpComplementESC, $rdpNumeroVoieESC, $rdpVoieESC,
$rdpComplementAdresseESC, $rdpCodePostalESC, $rdpCommuneESC, $rdpPaysESC, $rdpMailESC, $rdpTelephoneESC, $rdpFaxESC);";
$sqlDernierRDP = "SELECT MAX(\"idRDP\") FROM \"responsableProjet\";";
$sqlDernierExecutant = "SELECT MAX(\"idExecutant\") FROM \"executant\";";
// On entre les
$cnx->exec($sqlRDP);
$cnx->exec($sqlExec);
/*
* On dtermine quel est le numro du dernier responsable de projet
* et du dernier excutant rentre en base.
* Cela permet de crer les cls trangres dans la table Declaration
*/
$reponseRDP = $cnx->query($sqlDernierRDP);
$idDernierResponsableProjetRentre = $reponseRDP->fetch()[0];
$reponseExecutant = $cnx->query($sqlDernierExecutant);
$idDernierExecutantRentre = $reponseExecutant->fetch()[0];
$sqlDeclDTDICT = "INSERT INTO declaration (\"techniquesUtilisees\", \"noAffaireExecutant\", \"noAffaireRDP\", \"techniquesSansTranchees\", \"profondeurMax\", \"plansElectriquesAeriens\",
\"modificationProfilTerrain\",
\"dateReceptionDeclaration\", \"typeDeclaration\", \"numeroNationalDT\", \"numeroNationalDICT\", \"nature\", \"description\", \"adresse\",
\"nombreCommunes\", \"codePostal\", \"commune\", \"dateDebutPrevue\", \"dureeChantierPrevue\", \"traceGML\", \"personneContactTravaux\",
\"telephoneContactTravaux\", \"faxContactTravaux\", \"courrielContactTravaux\", \"personneContactProjet\",
\"telephoneContactProjet\", \"faxContactProjet\", \"courrielContactProjet\", \"idRDP\", \"idExecutant\")
VALUES ($techniquesUtiliseesESC, $noAffaireExecESC, $noAffaireRDPESC, $techniquesSansTrancheesESC, $profondeurMaxESC, $plansElectriquesAeriensESC, $modificationProfilTerrainESC,
to_timestamp($dateReceptionDeclarationESC), $typeDeclarationESC, $numeroNationalDTESC, $numeroNationalDICTESC, $natureTravauxESC, $descriptionESC, $adresseESC,
$nombreCommunesESC, $codePostalESC, $communeESC, $dateDebutPrevueESC, $dureeChantierPrevueESC, $traceGMLESC,
$personneContactTravauxESC, $telephoneContactTravauxESC, $faxContactTravauxESC, $courrielContactTravauxESC,
$personneContactProjetESC, $telephoneContactProjetESC, $faxContactProjetESC, $courrielContactProjetESC,
$idDernierResponsableProjetRentre, $idDernierExecutantRentre);";
$cnx->exec($sqlDeclDTDICT);
}
/**
* Fonction permettant de rentrer une Demande de Travaux (DT) dans la
* base de donnees:
* <ul>
* <li>Les informations relatives au responsable de projet sont
* stockes dans la table `responsableProjet`</li>
* </ul>
*
*/
private function entrerDT(){
$cnx = $this->connexionBD();
$cnx->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$dateReceptionDeclarationESC = trim($cnx->quote($this->dateReceptionDeclaration));
$typeDeclarationESC = trim($cnx->quote($this->typeDeclaration));
$numeroNationalDTESC = trim($cnx->quote($this->numeroNationalDT));
$natureTravauxESC = trim($cnx->quote($this->natureTravaux));
$URLfichierXMLESC = trim($cnx->quote($this->URLfichierXML));
$URLfichierPDFESC = trim($cnx->quote($this->URLfichierPDF));
$URLfichierEMLESC = trim($cnx->quote($this->URLfichierEML));
$descriptionESC = trim($cnx->quote($this->description));
$adresseESC = trim($cnx->quote($this->adresse));
$nombreCommunesESC = trim($cnx->quote($this->nombreCommunes));
$codePostalESC = trim($cnx->quote($this->codePostal));
$communeESC = trim($cnx->quote($this->commune));
$dateDebutPrevueESC = trim($cnx->quote($this->dateDebutPrevue));
$dureeChantierPrevueESC = trim($cnx->quote($this->dureeChantierPrevue));
$traceGMLESC = trim($cnx->quote($this->traceGML));
$personneContactProjetESC = trim($cnx->quote($this->personneContactProjet));
$telephoneContactProjetESC = trim($cnx->quote($this->telephoneContactProjet));
$faxContactProjetESC = trim($cnx->quote($this->faxContactProjet));
$courrielContactProjetESC = trim($cnx->quote($this->courrielContactProjet));
$techniquesUtiliseesESC = trim($cnx->quote($this->techniquesUtilisees));
$noAffaireExecESC = trim($cnx->quote($this->noAffaireExec));
$noAffaireRDPESC = trim($cnx->quote($this->noAffaireRDP));
$profondeurMaxESC = trim($cnx->quote($this->profondeurMax));
$techniquesSansTrancheesESC = $this->techniquesSansTranchees;
$plansElectriquesAeriensESC = $this->plansElectriquesAeriens;
$modificationProfilTerrainESC = $this->modificationProfilTerrain;
$rdpDenominationESC = trim($cnx->quote($this->rdpDenomination));
$rdpNumSIRETESC = trim($cnx->quote($this->rdpNumSIRET));
$rdpComplementESC = trim($cnx->quote($this->rdpComplement));
$rdpNumeroVoieESC = trim($cnx->quote($this->rdpNumeroVoie));
$rdpVoieESC = trim($cnx->quote($this->rdpVoie));
$rdpComplementAdresseESC = trim($cnx->quote($this->rdpComplementAdresse));
$rdpCodePostalESC = trim($cnx->quote($this->rdpCodePostal));
$rdpCommuneESC = trim($cnx->quote($this->rdpCommune));
$rdpPaysESC = trim($cnx->quote($this->rdpPays));
$rdpMailESC = trim($cnx->quote($this->rdpMail));
$rdpFaxESC = trim($cnx->quote($this->rdpFax));
$rdpTelephoneESC = trim($cnx->quote($this->rdpTelephone));
$sqlRDP = "INSERT INTO \"responsableProjet\" (\"denomination\", \"numSIRET\", \"complement\", \"numeroVoie\", \"voie\", \"complementAdresse\",
\"codePostal\", \"commune\", \"pays\", \"mail\", \"telephone\", \"fax\")
VALUES($rdpDenominationESC, $rdpNumSIRETESC, $rdpComplementESC, $rdpNumeroVoieESC, $rdpVoieESC,
$rdpComplementAdresseESC, $rdpCodePostalESC, $rdpCommuneESC, $rdpPaysESC, $rdpMailESC, $rdpTelephoneESC, $rdpFaxESC);";
$sqlDernierRDP = "SELECT MAX(\"idRDP\") FROM \"responsableProjet\";";
$cnx->exec($sqlRDP);
/*
* On dtermine quel est le numro du dernier responsable
* de projet rentr en base
* Cela permet de crer la cl trangre dans la table Declaration
*/
$reponse = $cnx->query($sqlDernierRDP);
$idDernierResponsableProjetRentre = $reponse->fetch()[0];
$sqlDeclDT = "INSERT INTO declaration (\"techniquesUtilisees\",
\"noAffaireRDP\",
\"techniquesSansTranchees\",
\"profondeurMax\",
\"plansElectriquesAeriens\",
\"modificationProfilTerrain\",
\"dateReceptionDeclaration\",
\"typeDeclaration\",
\"numeroNationalDT\",
\"nature\",
\"description\",
\"adresse\",
\"nombreCommunes\",
\"codePostal\",
\"commune\",
\"dateDebutPrevue\",
\"dureeChantierPrevue\",
\"traceGML\",
\"personneContactProjet\",
\"telephoneContactProjet\",
\"faxContactProjet\",
\"courrielContactProjet\",
\"idRDP\")
VALUES ($techniquesUtiliseesESC,
$noAffaireRDPESC,
$techniquesSansTrancheesESC,
$profondeurMaxESC,
$plansElectriquesAeriensESC,
$modificationProfilTerrainESC,
to_timestamp($dateReceptionDeclarationESC),
$typeDeclarationESC,
$numeroNationalDTESC,
$natureTravauxESC,
$descriptionESC,
$adresseESC,
$nombreCommunesESC,
$codePostalESC,
$communeESC,
$dateDebutPrevueESC,
$dureeChantierPrevueESC,
$traceGMLESC,
$personneContactProjetESC,
$telephoneContactProjetESC,
$faxContactProjetESC,
$courrielContactProjetESC,
$idDernierResponsableProjetRentre);";
$cnx->exec($sqlDeclDT);
}
/**
* Fonction permettant de rentrer une Dclaration d'Intention de Commencement de Travaux
* (DICT) dans la base de donnees:
* <ul>
* <li>Les informations relatives au responsable de projet sont
* stockes dans la table `responsableProjet`</li>
* <li>Les informations relatives l'excutant de travaux sont
* stockes dans la table `executant`</li>
* </ul>
*
*/
private function entrerDICT(){
$cnx = $this->connexionBD();
$cnx->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
/*
* On chappe proprement les variables (attributs) que l'on souhaite insrer
* dans la base de donnes
*/
// Table Declaration
$dateReceptionDeclarationESC = trim($cnx->quote($this->dateReceptionDeclaration));
$typeDeclarationESC = trim($cnx->quote($this->typeDeclaration));
$numeroNationalDICTESC = trim($cnx->quote($this->numeroNationalDICT));
$natureTravauxESC = trim($cnx->quote($this->natureTravaux));
$URLfichierXMLESC = trim($cnx->quote($this->URLfichierXML));
$URLfichierPDFESC = trim($cnx->quote($this->URLfichierPDF));
$URLfichierEMLESC = trim($cnx->quote($this->URLfichierEML));
$descriptionESC = trim($cnx->quote($this->description));
$adresseESC = trim($cnx->quote($this->adresse));
$nombreCommunesESC = trim($cnx->quote($this->nombreCommunes));
$codePostalESC = trim($cnx->quote($this->codePostal));
$communeESC = trim($cnx->quote($this->commune));
$dateDebutPrevueESC = trim($cnx->quote($this->dateDebutPrevue));
$dureeChantierPrevueESC = trim($cnx->quote($this->dureeChantierPrevue));
$traceGMLESC = trim($cnx->quote($this->traceGML));
$personneContactTravauxESC = trim($cnx->quote($this->personneContactTravaux));
$telephoneContactTravauxESC = trim($cnx->quote($this->telephoneContactTravaux));
$faxContactTravauxESC = trim($cnx->quote($this->faxContactTravaux));
$courrielContactTravauxESC = trim($cnx->quote($this->courrielContactTravaux));
$techniquesSansTrancheesESC = $this->techniquesSansTranchees;
$plansElectriquesAeriensESC = $this->plansElectriquesAeriens;
$modificationProfilTerrainESC = $this->modificationProfilTerrain;
$techniquesUtiliseesESC = trim($cnx->quote($this->techniquesUtilisees));
$noAffaireExecESC = trim($cnx->quote($this->noAffaireExec));
$noAffaireRDPESC = trim($cnx->quote($this->noAffaireRDP));
$profondeurMaxESC = trim($cnx->quote($this->profondeurMax));
// Table Executant
$execDenominationESC = trim($cnx->quote($this->execDenomination));
$execNumSIRETESC = trim($cnx->quote($this->execNumSIRET));
$execComplementESC = trim($cnx->quote($this->execComplement));
$execNumeroVoieESC = trim($cnx->quote($this->execNumeroVoie));
$execVoieESC = trim($cnx->quote($this->execVoie));
$execComplementAdresseESC = trim($cnx->quote($this->execComplementAdresse));
$execCodePostalESC = trim($cnx->quote($this->execCodePostal));
$execAdresseESC = trim($cnx->quote($this->execAdresse));
$execCommuneESC = trim($cnx->quote($this->execCommune));
$execPaysESC = trim($cnx->quote($this->execPays));
$execMailESC = trim($cnx->quote($this->execMail));
$execTelephoneESC = trim($cnx->quote($this->execTelephone));
$execFaxESC = trim($cnx->quote($this->execFax));
/*
* Requte SQL d'insertion de la partie "Excutant de travaux" dans la base de donnes
* Donnes entres dans la table `executant`
*
*/
$sqlExec = "INSERT INTO executant (\"denomination\", \"numSIRET\", \"complement\", \"numeroVoie\", \"voie\", \"complementAdresse\",
\"codePostal\", \"commune\", \"pays\", \"mail\", \"telephone\", \"fax\")
VALUES ($execDenominationESC,$execNumSIRETESC, $execComplementESC, $execNumeroVoieESC, $execVoieESC,
$execComplementAdresseESC, $execCodePostalESC, $execCommuneESC, $execPaysESC, $execMailESC, $execTelephoneESC, $execFaxESC);";
$sqlDernierExecutant = "SELECT MAX(\"idExecutant\") FROM \"executant\";";
$cnx->exec($sqlExec);
/*
* On dtermine quel est le numro du dernier excutant rentr en base
* Cela permet de crer la cl trangre dans la table Declaration
*/
$reponse = $cnx->query($sqlDernierExecutant);
$idDernierExecutantRentre = $reponse->fetch()[0];
$sqlDeclDICT = "INSERT INTO declaration (\"techniquesUtilisees\", \"noAffaireExecutant\",
\"techniquesSansTranchees\", \"profondeurMax\", \"plansElectriquesAeriens\",
\"modificationProfilTerrain\",
\"dateReceptionDeclaration\", \"typeDeclaration\", \"numeroNationalDICT\",
\"nature\", \"description\", \"adresse\",
\"nombreCommunes\", \"codePostal\", \"commune\",\"dateDebutPrevue\",
\"dureeChantierPrevue\", \"traceGML\", \"personneContactTravaux\",
\"telephoneContactTravaux\", \"faxContactTravaux\",
\"courrielContactTravaux\", \"idExecutant\")
VALUES ($techniquesUtiliseesESC, $noAffaireExecESC, $techniquesSansTrancheesESC,
$profondeurMaxESC, $plansElectriquesAeriensESC, $modificationProfilTerrainESC,
to_timestamp($dateReceptionDeclarationESC), $typeDeclarationESC,
$numeroNationalDICTESC, $natureTravauxESC, $descriptionESC,
$adresseESC, $nombreCommunesESC, $codePostalESC, $communeESC,
$dateDebutPrevueESC, $dureeChantierPrevueESC, $traceGMLESC,
$personneContactTravauxESC, $telephoneContactTravauxESC, $faxContactTravauxESC,
$courrielContactTravauxESC, $idDernierExecutantRentre);";
$cnx->exec($sqlDeclDICT);
}
/**
* Permet d'entrer un Avis de Travaux Urgents (ATU) dans la
* base de donnes
*/
private function entrerATU(){
$cnx = $this->connexionBD();
$cnx->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
/*
* On chappe proprement les variables (attributs) que l'on souhaite insrer
* dans la base de donnes
*/
$dateReceptionDeclarationESC = trim($cnx->quote($this->dateReceptionDeclaration));
$typeDeclarationESC = trim($cnx->quote($this->typeDeclaration));
$numeroNationalATUESC = trim($cnx->quote($this->numeroNationalATU));
$natureTravauxESC = trim($cnx->quote($this->natureTravaux));
$URLfichierXMLESC = trim($cnx->quote($this->URLfichierXML));
$URLfichierPDFESC = trim($cnx->quote($this->URLfichierPDF));
$URLfichierEMLESC = trim($cnx->quote($this->URLfichierEML));
$descriptionESC = trim($cnx->quote($this->description));
$adresseESC = trim($cnx->quote($this->adresse));
$codePostalESC = trim($cnx->quote($this->codePostal));
$communeESC = trim($cnx->quote($this->commune));
$dateDebutPrevueESC = trim($cnx->quote($this->dateDebutPrevue));
$dureeChantierPrevueESC = trim($cnx->quote($this->dureeChantierPrevue));
$traceGMLESC = trim($cnx->quote($this->traceGML));
$personneContactTravauxESC = trim($cnx->quote($this->personneContactTravaux));
$telephoneContactTravauxESC = trim($cnx->quote($this->telephoneContactTravaux));
$faxContactTravauxESC = trim($cnx->quote($this->faxContactTravaux));
$courrielContactTravauxESC = trim($cnx->quote($this->courrielContactTravaux));
$techniquesSansTrancheesESC = $this->techniquesSansTranchees;
$plansElectriquesAeriensESC = $this->plansElectriquesAeriens;
$modificationProfilTerrainESC = $this->modificationProfilTerrain;
$techniquesUtiliseesESC = trim($cnx->quote($this->techniquesUtilisees));
$noAffaireExecESC = trim($cnx->quote($this->noAffaireExec));
$noAffaireRDPESC = trim($cnx->quote($this->noAffaireRDP));
$profondeurMaxESC = trim($cnx->quote($this->profondeurMax));
$execDenominationESC = trim($cnx->quote($this->execDenomination));
$execCodePostalESC = trim($cnx->quote($this->execCodePostal));
$execAdresseESC = trim($cnx->quote($this->execAdresse));
$execCommuneESC = trim($cnx->quote($this->execCommune));
$rdpDenominationESC = trim($cnx->quote($this->rdpDenomination));
$rdpNumSIRETESC = trim($cnx->quote($this->rdpNumSIRET));
$rdpNumeroVoieESC = trim($cnx->quote($this->rdpNumeroVoie));
$rdpVoieESC = trim($cnx->quote($this->rdpVoie));
$rdpComplementAdresseESC = trim($cnx->quote($this->rdpComplementAdresse));
$rdpCodePostalESC = trim($cnx->quote($this->rdpCodePostal));
$rdpCommuneESC = trim($cnx->quote($this->rdpCommune));
$rdpPaysESC = trim($cnx->quote($this->rdpPays));
$rdpMailESC = trim($cnx->quote($this->rdpMail));
$rdpFaxESC = trim($cnx->quote($this->rdpFax));
$rdpTelephoneESC = trim($cnx->quote($this->rdpTelephone));
$chantierTermineOuAVenirESC = trim($cnx->quote($this->chantierTermineOuAVenir));
$justificationUrgenceESC = trim($cnx->quote($this->justificationUrgence));
$sqlExec = "INSERT INTO executant(\"denomination\", \"adresse\",
\"codePostal\", \"commune\", \"mail\", \"telephone\")
VALUES ($execDenominationESC, $execAdresseESC, $execCodePostalESC,
$execCommuneESC, $courrielContactTravauxESC,
$telephoneContactTravauxESC)";
$sqlRDP = "INSERT INTO \"responsableProjet\" (\"denomination\", \"numSIRET\", \"numeroVoie\", \"voie\", \"complementAdresse\",
\"codePostal\", \"commune\", \"pays\", \"mail\", \"telephone\", \"fax\")
VALUES($rdpDenominationESC, $rdpNumSIRETESC, $rdpNumeroVoieESC, $rdpVoieESC,
$rdpComplementAdresseESC, $rdpCodePostalESC, $rdpCommuneESC, $rdpPaysESC, $rdpMailESC, $rdpTelephoneESC, $rdpFaxESC);";
$sqlDernierRDP = "SELECT MAX(\"idRDP\") FROM \"responsableProjet\";";
$sqlDernierExecutant = "SELECT MAX(\"idExecutant\") FROM \"executant\";";
$cnx->exec($sqlRDP);
$cnx->exec($sqlExec);
$reponseRDP = $cnx->query($sqlDernierRDP);
$idDernierReponsableProjetRentre = $reponseRDP->fetch()[0];
$reponseExecutant = $cnx->query($sqlDernierExecutant);
$idDernierExecutantRentre = $reponseExecutant->fetch()[0];
$sqlATU = "INSERT INTO declaration (\"justificationUrgence\",
\"chantierTermineOuAVenir\",
\"dateReceptionDeclaration\",
\"typeDeclaration\",
\"numeroNationalATU\",
\"nature\",
\"description\",
\"adresse\",
\"commune\",
\"codePostal\",
\"dateDebutPrevue\",
\"dureeChantierPrevue\",
\"personneContactTravaux\",
\"telephoneContactTravaux\",
\"faxContactTravaux\",
\"courrielContactTravaux\",
\"idExecutant\",
\"idRDP\")
VALUES ($justificationUrgenceESC,
$chantierTermineOuAVenirESC,
to_timestamp($dateReceptionDeclarationESC),
$typeDeclarationESC,
$numeroNationalATUESC,
$natureTravauxESC,
$descriptionESC,
$adresseESC,
$communeESC,
$codePostalESC,
$dateDebutPrevueESC,
$dureeChantierPrevueESC,
$personneContactTravauxESC,
$telephoneContactTravauxESC,
$faxContactTravauxESC,
$courrielContactTravauxESC,
$idDernierExecutantRentre,
$idDernierReponsableProjetRentre);";
$cnx->exec($sqlATU);
}
function in_array_r($needle, $haystack, $strict = false) {
foreach ($haystack as $item) {
if (($strict ? $item === $needle : $item == $needle) || (is_array($item) && $this->in_array_r($needle, $item, $strict))) {
return true;
}
}
return false;
}
}
Function Calls
| None |
Stats
| MD5 | 998184bfce2c80dcf603030d925980f4 |
| Eval Count | 0 |
| Decode Time | 372 ms |