/**
  * methode de creation de l'architecture de WebServices
  */
 function dolLaodServices()
 {
     $param = array("in0" => $this->userId, "in1" => "");
     $ws = new WebservicesCompte($this->typeExecution);
     if (!$ws->connectIdent()) {
         $content = "ERROR:" . $ws->getErrorMessage();
         $content = "L'espace privé est momentanément indisponible, veuillez nous excuser de ce désagrément.";
         return $content;
     }
     $this->personne = $ws->getPersonneByLogin($param)->out;
     //print_r($this->personne);
     if ($ws->getErrorMessage() != "") {
         echo "<font color='red'>ERROR RECUPERATION PERSONNE CID (WS:findPersonneByLogin) :" . $ws->getErrorMessage() . "</font><br/>";
     }
     /**
      * recuperation du nombre de naissance, de lieux de detention
      */
     /*$paramCid = array (
     			"login" => $this->userId,
     			"ctx" => null
     		);*/
     $paramCid = array("login" => $this->userId, "ctx" => "");
     $wsCid = new WebservicesCompte($this->typeExecution);
     if (!$wsCid->connectCid()) {
         //$content="ERROR:".$wsCid->getErrorMessage();
         $content = "L'espace priv&eacute; est momentan&eacute;ment indisponible, veuillez nous excuser de ce d&eacute;sagr&eacute;ment.";
         return $content;
     }
     $this->nbreNaissance = $wsCid->getNbrNaissanceAnneeEnCours4User($paramCid)->getNbrNaissanceAnneeEnCoursReturn;
     if ($wsCid->getErrorMessage() != "") {
         echo "<font color='red'>ERROR RECUPERATION NOMBRE DE NAISSANCE CID (WS:getNbrNaissanceAnneeEnCours):" . $wsCid->getErrorMessage() . "</font><br/>";
     }
     $this->nbreLieudetention = $wsCid->getNbrLieuDetention4User($paramCid)->getNbrLieuDetentionReturn;
     if ($wsCid->getErrorMessage() != "") {
         echo "<font color='red'>ERROR RECUPERATION NOMBRE LIEU DE DETENTION CID (WS:getNbrLieuDetention):" . $wsCid->getErrorMessage() . "</font><br/>";
     }
     $this->nbreChevaux = $wsCid->getNbrChevaux4User($paramCid)->getNbrChevauxReturn;
     if ($wsCid->getErrorMessage() != "") {
         echo "<font color='red'>ERROR RECUPERATION NOMBRE DE CHEVAUX CID (WS:getNbrChevaux):" . $wsCid->getErrorMessage() . "</font><br/>";
     }
     /**
      * recuperation du nombre de factures et le montant total
      */
     if ($this->personne->key->numeroPersonne != "") {
         $paramPsi[] = $this->personne->key->numeroPersonne;
         $paramPsi[] = $this->personne->key->numeroOrdreAdresse;
         $wsPsi = new WebservicesCompte($this->typeExecution);
         if (!$wsPsi->connectPsi()) {
             //$content="ERROR:".$wsPsi->getErrorMessage();
             $content = "L'espace priv&eacute; est momentan&eacute;ment indisponible, veuillez nous excuser de ce d&eacute;sagr&eacute;ment.";
             return $content;
         } else {
             //Nombre de factures
             $this->nbreFactures = $wsPsi->getNbrFactureARegler4User($paramPsi);
             $this->montantFactures = $wsPsi->getMontantFactureARegler4User($paramPsi);
         }
     }
     /**
      * Recup des centres tech du departement
      */
     if ($this->personne->adresse->commune->codePostal != "" && $this->personne->adresse->commune->codePostal > 0) {
         $ws = new WebservicesAccess($this->typeExecution);
         if ($ws->connect()) {
             $objTransfert = new ObjectTransfertWS();
             $objTransfert->setKey("codeDepartement");
             $objTransfert->setValue(substr($this->personne->adresse->commune->codePostal, 0, 2));
             $paramCT[] = $objTransfert;
             $result = $ws->getCentresTEchniques($paramCT);
             //if(!$result && $ws->getErrorMessage()!="") echo "[error resultat:]".$ws->getErrorMessage();
             /**
              * Calcul du centre le plus proche
              */
             $precTot = 10000000000;
             foreach ($result as $centre) {
                 if ($centre["codePostal"] > $this->personne->adresse->commune->codePostal) {
                     $result = $centre["codePostal"] - $this->personne->adresse->commune->codePostal;
                 } else {
                     $result = $this->personne->adresse->commune->codePostal - $centre["codePostal"];
                 }
                 if ($result < $precTot) {
                     $precTot = $result;
                     $this->ct = $centre;
                 }
             }
         }
     }
     /**
      * On regarde si l'utilisateur est abonne aux news et alertes
      */
     if ($this->personne->coordonnees->email != "") {
         $query = "SELECT * FROM tx_fabformmail_abonne where email='" . $this->personne->coordonnees->email . "'";
         $res = mysql(TYPO3_db, $query) or die("req invalide : {$query}");
         if (mysql_num_rows($res) > 0) {
             $row = mysql_fetch_array($res);
             if ($row['newsletter'] == "1") {
                 $this->isAbonNews = true;
             }
             if ($row['hidden'] == "0") {
                 $this->isAbonAlert = true;
             }
         }
     }
     /**
      * chargement des infos liees a l'etalonnier'
      */
     if ($this->personne->profil->id == 3) {
         $wsDPS = new WebservicesCompte($this->typeExecution);
         if ($wsDPS->connectDPS()) {
             $paramDPS = array();
             if ($this->typeExecution == "dev" || $this->typeExecution == "dev_ext") {
                 $paramDPS = array("serv" => "DEV", "nuPerso" => $this->personne->key->numeroPersonne, "anMonte" => date("Y"));
             } else {
                 $paramDPS = array("serv" => "PROD", "nuPerso" => $this->personne->key->numeroPersonne, "anMonte" => date("Y"));
             }
             $return = $wsDPS->getNbrSurPlace($paramDPS);
             $this->nombreEtalonSaillie = isset($return->getNbSurPlaceReturn) && $return->getNbSurPlaceReturn != "" ? $return->getNbSurPlaceReturn : 0;
             $return = $wsDPS->getNbrIA($paramDPS);
             $this->nombreEtalonSaillieIA = isset($return->getNbIAReturn) && $return->getNbIAReturn != "" ? $return->getNbIAReturn : 0;
         }
     }
 }