2012-01-06 16:39:14 +00:00
|
|
|
|
<?php
|
2012-08-08 14:38:11 +00:00
|
|
|
|
|
2012-01-06 16:39:14 +00:00
|
|
|
|
/**
|
2012-08-08 14:38:11 +00:00
|
|
|
|
* Configuration of provider
|
2012-01-06 16:39:14 +00:00
|
|
|
|
*/
|
2012-08-08 14:38:11 +00:00
|
|
|
|
require_once realpath(dirname(__FILE__)).'/Config.php';
|
2012-01-06 16:39:14 +00:00
|
|
|
|
|
2012-08-08 14:38:11 +00:00
|
|
|
|
/**
|
|
|
|
|
* Infogreffe Provider
|
|
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
class Infogreffe extends Infogreffe_Config
|
|
|
|
|
{
|
2012-01-06 16:39:14 +00:00
|
|
|
|
|
|
|
|
|
/**
|
2012-08-08 14:38:11 +00:00
|
|
|
|
* Where pdf file are store
|
|
|
|
|
* @var string
|
2012-01-06 16:39:14 +00:00
|
|
|
|
*/
|
2012-08-08 14:38:11 +00:00
|
|
|
|
protected $dataPath = '';
|
2012-01-06 16:39:14 +00:00
|
|
|
|
|
|
|
|
|
/**
|
2012-08-08 14:38:11 +00:00
|
|
|
|
* SIREN
|
|
|
|
|
* @var string
|
2012-01-06 16:39:14 +00:00
|
|
|
|
*/
|
2012-08-08 14:38:11 +00:00
|
|
|
|
protected $siren;
|
2012-01-06 16:39:14 +00:00
|
|
|
|
|
|
|
|
|
/**
|
2012-08-08 14:38:11 +00:00
|
|
|
|
* Internal Command ID
|
|
|
|
|
* @var string
|
2012-01-06 16:39:14 +00:00
|
|
|
|
*/
|
2012-08-08 14:38:11 +00:00
|
|
|
|
protected $idCommande;
|
2012-01-06 16:39:14 +00:00
|
|
|
|
|
|
|
|
|
/**
|
2012-08-08 14:38:11 +00:00
|
|
|
|
* KB = Kbis, PN = privilèges et nantissements, BI = Bilan complet, BS = bilan saisi,
|
|
|
|
|
* ST = Dernier Statut à jour, AC = Acte, SD = Surveillance Demande et Accusé,
|
|
|
|
|
* SR = Surveillance Révélation, SP = Surveillance Portefeuille, FA = Recherche PCL,
|
|
|
|
|
* FI = Inventaire, FJ = Jugement, FO = Ordonnance, FD = Dépôt divers,
|
|
|
|
|
* LE = Liste Etablissements
|
|
|
|
|
* @var string
|
2012-01-06 16:39:14 +00:00
|
|
|
|
*/
|
2012-08-08 14:38:11 +00:00
|
|
|
|
protected $typeCommande;
|
2012-01-06 16:39:14 +00:00
|
|
|
|
|
|
|
|
|
/**
|
2012-08-08 14:38:11 +00:00
|
|
|
|
* Mode de diffusion : C = Courrier, T = Téléchargement, M = Mail, XL = XML
|
|
|
|
|
* @var string
|
2012-01-06 16:39:14 +00:00
|
|
|
|
*/
|
2012-08-08 14:38:11 +00:00
|
|
|
|
protected $vecteur;
|
2012-01-06 16:39:14 +00:00
|
|
|
|
|
|
|
|
|
/**
|
2012-11-30 13:51:48 +00:00
|
|
|
|
* Elements de référence
|
|
|
|
|
* @var array
|
2012-01-06 16:39:14 +00:00
|
|
|
|
*/
|
2012-11-30 13:51:48 +00:00
|
|
|
|
protected $option = array();
|
2012-01-06 16:39:14 +00:00
|
|
|
|
|
|
|
|
|
/**
|
2012-08-08 14:38:11 +00:00
|
|
|
|
* Error number
|
|
|
|
|
* @var int
|
2012-01-06 16:39:14 +00:00
|
|
|
|
*/
|
2012-08-08 14:38:11 +00:00
|
|
|
|
protected $errorNum;
|
2012-01-06 16:39:14 +00:00
|
|
|
|
|
|
|
|
|
/**
|
2012-08-08 14:38:11 +00:00
|
|
|
|
* Error message
|
|
|
|
|
* @var string
|
2012-01-06 16:39:14 +00:00
|
|
|
|
*/
|
2012-08-08 14:38:11 +00:00
|
|
|
|
protected $errorMsg;
|
2012-01-06 16:39:14 +00:00
|
|
|
|
|
|
|
|
|
|
2012-08-08 14:38:11 +00:00
|
|
|
|
public function __construct()
|
2012-01-06 16:39:14 +00:00
|
|
|
|
{
|
2012-08-08 14:38:11 +00:00
|
|
|
|
/**
|
|
|
|
|
* Define path where PDF file are store
|
|
|
|
|
*/
|
2012-11-30 13:51:48 +00:00
|
|
|
|
$this->dataPath = SECURE_STORAGE;
|
2012-08-08 14:38:11 +00:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Define path where XML cache file are store
|
|
|
|
|
*/
|
|
|
|
|
$this->cachePath = '';
|
|
|
|
|
|
2012-01-06 16:39:14 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2012-08-08 14:38:11 +00:00
|
|
|
|
* Send XML Request
|
|
|
|
|
* We have some problem to use SOAP so we use CURL
|
|
|
|
|
* @return string XML Response
|
2012-01-06 16:39:14 +00:00
|
|
|
|
*/
|
2012-08-08 14:38:11 +00:00
|
|
|
|
protected function getProduitsXML()
|
2012-01-06 16:39:14 +00:00
|
|
|
|
{
|
2012-08-08 14:38:11 +00:00
|
|
|
|
$xmlStr = '';
|
|
|
|
|
$env = 'PRD';
|
|
|
|
|
|
|
|
|
|
//Construct the request
|
|
|
|
|
$xml = new SimpleXMLElement('<demande></demande>');
|
|
|
|
|
$emetteur = $xml->addChild('emetteur');
|
|
|
|
|
$emetteur->addChild('code_abonne', $this->config[$env]['USER']);
|
|
|
|
|
$emetteur->addChild('mot_passe', $this->config[$env]['PASS']);
|
|
|
|
|
|
|
|
|
|
//Set Command ID
|
|
|
|
|
$emetteur->addChild('reference_client', 'G'.$this->idCommande);
|
|
|
|
|
$code_requete = $emetteur->addChild('code_requete');
|
|
|
|
|
$code_requete->addChild('type_profil', 'A');
|
|
|
|
|
$code_requete->addChild('origine_emetteur', 'IC');
|
|
|
|
|
|
|
|
|
|
// C = Commande de documents
|
|
|
|
|
$code_requete->addChild('nature_requete', 'C');
|
2012-01-06 16:39:14 +00:00
|
|
|
|
|
2012-08-08 14:38:11 +00:00
|
|
|
|
$code_requete->addChild('type_document', $this->typeCommande);
|
|
|
|
|
$code_requete->addChild('type_requete', 'S'); // S = Simple
|
|
|
|
|
|
|
|
|
|
$mode_diffusion = $code_requete->addChild('mode_diffusion');
|
|
|
|
|
// Mode de diffusion : C = Courrier, T = Téléchargement, M = Mail, XL = XML
|
|
|
|
|
if ($this->vecteur=='XL' && $this->option=='')
|
|
|
|
|
{
|
|
|
|
|
//On ajoute tout les types de diffusions pour $vecteur = XL
|
|
|
|
|
$mode_diffusion->addChild('mode')->addAttribute('type', 'C');
|
|
|
|
|
$mode_diffusion->addChild('mode')->addAttribute('type', 'T');
|
|
|
|
|
}
|
|
|
|
|
$mode_diffusion->addChild('mode')->addAttribute('type', $this->vecteur);
|
|
|
|
|
|
|
|
|
|
$code_requete->addChild('media', 'WS');
|
|
|
|
|
|
|
|
|
|
$commande = $xml->addChild('commande');
|
|
|
|
|
$commande->addChild('num_siren', $this->siren);
|
|
|
|
|
|
|
|
|
|
// Commande de documents : bilan saisie ou bilan complet
|
2012-11-30 13:51:48 +00:00
|
|
|
|
if ( ($this->typeCommande=='BS' || $this->typeCommande=='BI') && count($this->option)>0 )
|
2012-08-08 14:38:11 +00:00
|
|
|
|
{
|
2012-11-30 13:51:48 +00:00
|
|
|
|
$commande->addChild('greffe',$this->option['greffe']);
|
|
|
|
|
$commande->addChild('dossier_millesime',$this->option['dossier_millesime']);
|
|
|
|
|
$commande->addChild('dossier_statut',$this->option['dossier_statut']);
|
|
|
|
|
$commande->addChild('dossier_chrono',$this->option['dossier_chrono']);
|
|
|
|
|
$commande->addChild('num_depot',$this->option['num_depot']);
|
|
|
|
|
$commande->addChild('date_cloture', $this->option['date_cloture']);
|
2012-08-08 14:38:11 +00:00
|
|
|
|
}
|
|
|
|
|
// Commande de documents : actes
|
2012-11-30 13:51:48 +00:00
|
|
|
|
elseif ( $this->typeCommande=='AC' && count($this->option)>0 )
|
2012-08-08 14:38:11 +00:00
|
|
|
|
{
|
2012-11-30 13:51:48 +00:00
|
|
|
|
$commande->addChild('greffe',$this->option['greffe']);
|
|
|
|
|
$commande->addChild('dossier_millesime',$this->option['dossier_millesime']);
|
|
|
|
|
$commande->addChild('dossier_statut',$this->option['dossier_statut']);
|
|
|
|
|
$commande->addChild('dossier_chrono',$this->option['dossier_chrono']);
|
|
|
|
|
$commande->addChild('num_depot',$this->option['num_depot']);
|
2012-08-08 14:38:11 +00:00
|
|
|
|
$liste_actes = $commande->addChild('liste_actes');
|
2012-11-30 13:51:48 +00:00
|
|
|
|
$liste_actes->addChild('acte')->addAttribute('num', $this->option['num_acte']);
|
2012-08-08 14:38:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$xmlStr = str_replace('<?xml version="1.0"?>', '', $xml->asXML());
|
|
|
|
|
|
|
|
|
|
//Be sure it's in UTF-8
|
2012-11-30 13:51:48 +00:00
|
|
|
|
$req = utf8_encode($xmlStr);
|
2012-08-08 14:38:11 +00:00
|
|
|
|
|
|
|
|
|
//Create XML request
|
|
|
|
|
$post = '<?xml version="1.0" encoding="UTF-8"?>'.
|
|
|
|
|
'<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" '.
|
|
|
|
|
'xmlns:ns1="https://webservices.infogreffe.fr/" '.
|
|
|
|
|
'xmlns:xsd="http://www.w3.org/2001/XMLSchema" '.
|
|
|
|
|
'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" '.
|
|
|
|
|
'xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" '.
|
|
|
|
|
'SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">'.
|
|
|
|
|
'<SOAP-ENV:Body>'.
|
|
|
|
|
'<ns1:getProduitsWebServicesXML>'.
|
|
|
|
|
'<param0 xsi:type="xsd:string">'.$req.'</param0>'.
|
|
|
|
|
'</ns1:getProduitsWebServicesXML>'.
|
|
|
|
|
'</SOAP-ENV:Body>'.
|
|
|
|
|
'</SOAP-ENV:Envelope>';
|
|
|
|
|
|
|
|
|
|
$ch = curl_init();
|
2012-11-30 13:51:48 +00:00
|
|
|
|
curl_setopt($ch, CURLOPT_URL, $this->config[$env]['URL']);
|
2012-08-08 14:38:11 +00:00
|
|
|
|
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
|
|
|
|
|
curl_setopt($ch, CURLOPT_COOKIEFILE,TRUE);
|
|
|
|
|
curl_setopt($ch, CURLOPT_POST, TRUE);
|
|
|
|
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
|
|
|
|
|
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
|
|
|
|
|
$response = curl_exec($ch);
|
|
|
|
|
|
|
|
|
|
//Remove SOAP part of XML
|
|
|
|
|
$response = str_replace("<?xml version='1.0' encoding='UTF-8'?><SOAP-ENV:Envelope xmlns:SOAP-ENV='http://schemas.xmlsoap.org/soap/envelope/' xmlns:SOAP-ENC='http://schemas.xmlsoap.org/soap/encoding/' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:xsd='http://www.w3.org/2001/XMLSchema'><SOAP-ENV:Body><ns0:getProduitsWebServicesXMLResponse xmlns:ns0='urn:local' SOAP-ENV:encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'><return xsi:type='xsd:string'>", '', $response);
|
2012-11-30 13:51:48 +00:00
|
|
|
|
$response = str_replace('</return></ns0:getProduitsWebServicesXMLResponse></SOAP-ENV:Body></SOAP-ENV:Envelope>','', $response);
|
2012-08-08 14:38:11 +00:00
|
|
|
|
|
|
|
|
|
return $response;
|
2012-01-06 16:39:14 +00:00
|
|
|
|
}
|
2012-08-08 14:38:11 +00:00
|
|
|
|
|
|
|
|
|
protected function log(){}
|
|
|
|
|
|
2012-01-06 16:39:14 +00:00
|
|
|
|
/**
|
2012-08-08 14:38:11 +00:00
|
|
|
|
* Detect error
|
2012-01-06 16:39:14 +00:00
|
|
|
|
* @param string $xml
|
2012-08-08 14:38:11 +00:00
|
|
|
|
* @throws Exception
|
2012-01-06 16:39:14 +00:00
|
|
|
|
*/
|
2012-08-08 14:38:11 +00:00
|
|
|
|
protected function error($xml)
|
2012-01-06 16:39:14 +00:00
|
|
|
|
{
|
2012-08-08 14:38:11 +00:00
|
|
|
|
if (!empty($xml))
|
|
|
|
|
{
|
|
|
|
|
$doc = new DOMDocument();
|
|
|
|
|
$load = $doc->loadXML($xml, LIBXML_NOERROR | LIBXML_NOWARNING);
|
|
|
|
|
if (!$load) {
|
|
|
|
|
$tmp = explode('-', $xml);
|
|
|
|
|
$errNum = intval($tmp[0]);
|
|
|
|
|
$errMsg = $tmp[1];
|
|
|
|
|
if( $errNum == '5' ){
|
|
|
|
|
$errMsg = 'Service partenaire indisponible.';
|
|
|
|
|
}
|
2012-11-30 13:51:48 +00:00
|
|
|
|
throw new Exception($errNum . '-' . $errMsg);
|
2012-08-08 14:38:11 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2012-11-30 13:51:48 +00:00
|
|
|
|
throw new Exception('Fichier vide');
|
2012-08-08 14:38:11 +00:00
|
|
|
|
}
|
2012-01-06 16:39:14 +00:00
|
|
|
|
}
|
2012-08-08 14:38:11 +00:00
|
|
|
|
|
2012-01-06 16:39:14 +00:00
|
|
|
|
/**
|
2012-08-08 14:38:11 +00:00
|
|
|
|
* Return true if the file modification time is in the period of caching
|
|
|
|
|
* @param string $file
|
|
|
|
|
* Path of file
|
2012-11-30 13:51:48 +00:00
|
|
|
|
* @return boolean
|
2012-01-06 16:39:14 +00:00
|
|
|
|
*/
|
2012-08-08 14:38:11 +00:00
|
|
|
|
protected function cachetimeover($file)
|
2012-01-06 16:39:14 +00:00
|
|
|
|
{
|
2012-08-08 14:38:11 +00:00
|
|
|
|
$timeover = false;
|
|
|
|
|
$dateFile = filemtime($file);
|
|
|
|
|
$now = mktime(date('G'), date('i'), date('s'), date('m') , date('d'), date('Y'));
|
|
|
|
|
$maxTime = mktime(date('G',$dateFile)+$this->cacheFiletime, date('i',$dateFile), date('s',$dateFile), date("m",$dateFile), date("d",$dateFile), date("Y",$dateFile));
|
|
|
|
|
if($now>$maxTime) $timeover = true;
|
|
|
|
|
return $timeover;
|
2012-01-06 16:39:14 +00:00
|
|
|
|
}
|
2012-08-08 14:38:11 +00:00
|
|
|
|
|
2012-11-30 13:51:48 +00:00
|
|
|
|
protected function bilanFileName()
|
|
|
|
|
{
|
|
|
|
|
return 'bilan-'.$this->siren.'-';
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
|
* @param unknown $url
|
|
|
|
|
* @return boolean
|
|
|
|
|
*/
|
|
|
|
|
public function download($url)
|
|
|
|
|
{
|
|
|
|
|
$result = true;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$fp = fopen(SECURE_STORAGE . ''. $file, 'w');
|
|
|
|
|
$ch = curl_init($url);
|
|
|
|
|
curl_setopt($ch, CURLOPT_FILE, $fp);
|
|
|
|
|
$data = curl_exec($ch);
|
|
|
|
|
// Check if any error occured
|
|
|
|
|
if(curl_errno($ch))
|
|
|
|
|
{
|
|
|
|
|
$result = false;
|
|
|
|
|
}
|
|
|
|
|
curl_close($ch);
|
|
|
|
|
fclose($fp);
|
|
|
|
|
return $result;
|
|
|
|
|
}
|
2012-08-08 14:38:11 +00:00
|
|
|
|
|
|
|
|
|
public function getStatut($siren, $typeCommande = '', $ref = '', $idCommande = 0)
|
2012-01-06 16:39:14 +00:00
|
|
|
|
{
|
2012-08-08 14:38:11 +00:00
|
|
|
|
$this->typeCommande = 'ST';
|
|
|
|
|
$this->vecteur = 'C';
|
|
|
|
|
|
|
|
|
|
$reponse = $this->getProduitsXML();
|
|
|
|
|
|
|
|
|
|
//Gestion du retour infogreffe
|
|
|
|
|
if($this->erreur($xmlReponse))
|
|
|
|
|
{
|
|
|
|
|
$error = $this->erreurMsg($xmlReponse);
|
|
|
|
|
}
|
|
|
|
|
//@todo result non définie
|
2012-01-06 16:39:14 +00:00
|
|
|
|
return array('error' => $error , 'result' => $result );
|
2012-08-08 14:38:11 +00:00
|
|
|
|
|
|
|
|
|
|
2012-01-06 16:39:14 +00:00
|
|
|
|
}
|
2012-08-08 14:38:11 +00:00
|
|
|
|
|
2012-01-06 16:39:14 +00:00
|
|
|
|
/**
|
2012-08-08 14:38:11 +00:00
|
|
|
|
* Retourne la liste des bilans
|
|
|
|
|
* @param string $siren
|
|
|
|
|
* @return array
|
2012-01-06 16:39:14 +00:00
|
|
|
|
*/
|
2012-08-08 14:38:11 +00:00
|
|
|
|
public function getBilans($siren)
|
2012-01-06 16:39:14 +00:00
|
|
|
|
{
|
2012-08-08 14:38:11 +00:00
|
|
|
|
$this->siren = $siren;
|
|
|
|
|
$this->vecteur = 'XL';
|
|
|
|
|
$this->typeCommande = 'BI';
|
|
|
|
|
|
2012-11-30 13:51:48 +00:00
|
|
|
|
$cacheFile = APPLICATION_PATH . $this->cachePath.'/'.$this->typeCommande.'-'.$siren.'.xml';
|
|
|
|
|
|
2012-08-08 14:38:11 +00:00
|
|
|
|
//Get cache information
|
|
|
|
|
if (file_exists($cacheFile) && $this->cachetimeover($cacheFile) )
|
2012-01-06 16:39:14 +00:00
|
|
|
|
{
|
2012-08-08 14:38:11 +00:00
|
|
|
|
$xml = file_get_contents($cacheFile);
|
2012-01-06 16:39:14 +00:00
|
|
|
|
}
|
2012-08-08 14:38:11 +00:00
|
|
|
|
//Make the request
|
2012-01-06 16:39:14 +00:00
|
|
|
|
else
|
|
|
|
|
{
|
2012-08-08 14:38:11 +00:00
|
|
|
|
$xml = $this->getProduitsXML();
|
|
|
|
|
$this->error($xml);
|
|
|
|
|
|
|
|
|
|
//Create file for the cache
|
|
|
|
|
file_put_contents($cacheFile, $xml);
|
2012-01-06 16:39:14 +00:00
|
|
|
|
}
|
2012-08-08 14:38:11 +00:00
|
|
|
|
|
|
|
|
|
//Parse XML to make tab
|
|
|
|
|
$doc = new DOMDocument();
|
|
|
|
|
$doc->loadXML($xml);
|
|
|
|
|
$liste_bilan_complet = $doc->getElementsByTagName('liste_bilan_complet')->item(0);
|
|
|
|
|
$bilan_complet = $liste_bilan_complet->getElementsByTagName('bilan_complet');
|
|
|
|
|
|
|
|
|
|
$bilans = array();
|
|
|
|
|
if (count($bilan_complet)>0)
|
|
|
|
|
{
|
|
|
|
|
foreach($bilan_complet as $element)
|
|
|
|
|
{
|
|
|
|
|
$bilan = array();
|
|
|
|
|
$num_gest = $element->getElementsByTagName('num_gest')->item(0);
|
|
|
|
|
$bilan['greffe'] = $num_gest->getElementsByTagName('greffe')->item(0)->nodeValue;
|
|
|
|
|
$bilan['dossier_millesime'] = $num_gest->getElementsByTagName('dossier_millesime')->item(0)->nodeValue;
|
|
|
|
|
$bilan['dossier_statut'] = $num_gest->getElementsByTagName('dossier_statut')->item(0)->nodeValue;
|
|
|
|
|
$bilan['dossier_chrono'] = $num_gest->getElementsByTagName('dossier_chrono')->item(0)->nodeValue;
|
|
|
|
|
$bilan['num_siren'] = $element->getElementsByTagName('num_siren')->item(0)->nodeValue;
|
|
|
|
|
$bilan['date_cloture'] = $element->getElementsByTagName('date_cloture')->item(0)->nodeValue;
|
|
|
|
|
$bilan['date_cloture_iso'] = $element->getElementsByTagName('date_cloture_iso')->item(0)->nodeValue;
|
|
|
|
|
$bilan['millesime'] = $element->getElementsByTagName('millesime')->item(0)->nodeValue;
|
|
|
|
|
$bilan['num_depot'] = $element->getElementsByTagName('num_depot')->item(0)->nodeValue;
|
|
|
|
|
$bilan['type_comptes'] = $element->getElementsByTagName('type_comptes')->item(0)->nodeValue;
|
|
|
|
|
$mode_diffusion = $element->getElementsByTagName('mode_diffusion')->item(0)->getElementsByTagName('mode');
|
|
|
|
|
foreach($mode_diffusion as $mode)
|
|
|
|
|
{
|
|
|
|
|
$bilan['mode_diffusion'][] = $mode->getAttribute('type');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//Génération de l'index pour le tri
|
|
|
|
|
$date = $bilan['date_cloture_iso'];
|
|
|
|
|
if(!empty($date))
|
|
|
|
|
{
|
|
|
|
|
$datef = substr($date,0,4).substr($date,5,2).substr($date,8,2);
|
|
|
|
|
//Affectation liste générale avec un index permettant le tri
|
|
|
|
|
$bilans[$datef] = $bilan;
|
2012-01-06 16:39:14 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2012-08-08 14:38:11 +00:00
|
|
|
|
}
|
|
|
|
|
krsort($bilans);
|
|
|
|
|
|
|
|
|
|
return $bilans;
|
2012-01-06 16:39:14 +00:00
|
|
|
|
}
|
2012-08-08 14:38:11 +00:00
|
|
|
|
|
2012-11-30 13:51:48 +00:00
|
|
|
|
/**
|
|
|
|
|
* Commande d'un bilan image
|
|
|
|
|
* @param string $siren
|
|
|
|
|
* Siren
|
|
|
|
|
* @param string $diffusion
|
|
|
|
|
* Mode de diffusion (C|T)
|
|
|
|
|
* @param array $option
|
|
|
|
|
* Référence
|
|
|
|
|
* @return string
|
|
|
|
|
*/
|
|
|
|
|
public function getBilan($siren, $diffusion, $option)
|
2012-01-06 16:39:14 +00:00
|
|
|
|
{
|
2012-11-30 13:51:48 +00:00
|
|
|
|
$this->siren = $siren;
|
|
|
|
|
$this->typeCommande = 'BI';
|
|
|
|
|
$this->vecteur = $diffusion;
|
|
|
|
|
$this->option = $option;
|
|
|
|
|
$xml = $this->getProduitsXML();
|
|
|
|
|
|
|
|
|
|
$doc = new DOMDocument();
|
|
|
|
|
$doc->loadXML($xml);
|
|
|
|
|
$bilan_complet = $doc->getElementsByTagName('bilan_complet')->item(0);
|
|
|
|
|
$bilan = array();
|
|
|
|
|
$bilan['num_gest'] = array();
|
|
|
|
|
$num_gest = $bilan_complet->getElementsByTagName('num_gest')->item(0);
|
|
|
|
|
$bilan['num_gest']['greffe'] = $num_gest->getElementsByTagName('greffe')->item(0)->nodeValue;
|
|
|
|
|
$bilan['num_gest']['dossier_millesime'] = $num_gest->getElementsByTagName('dossier_millesime')->item(0)->nodeValue;
|
|
|
|
|
$bilan['num_gest']['dossier_statut'] = $num_gest->getElementsByTagName('dossier_statut')->item(0)->nodeValue;
|
|
|
|
|
$bilan['num_gest']['dossier_chrono'] = $num_gest->getElementsByTagName('dossier_chrono')->item(0)->nodeValue;
|
|
|
|
|
$bilan['num_siren'] = $bilan_complet->getElementsByTagName('num_siren')->item(0)->nodeValue;
|
|
|
|
|
$bilan['date_cloture'] = $bilan_complet->getElementsByTagName('date_cloture')->item(0)->nodeValue;
|
|
|
|
|
$bilan['date_cloture_iso'] = $bilan_complet->getElementsByTagName('date_cloture_iso')->item(0)->nodeValue;
|
|
|
|
|
$bilan['millesime'] = $bilan_complet->getElementsByTagName('millesime')->item(0)->nodeValue;
|
|
|
|
|
$bilan['num_depot'] = $bilan_complet->getElementsByTagName('num_depot')->item(0)->nodeValue;
|
|
|
|
|
$bilan['type_comptes'] = $bilan_complet->getElementsByTagName('type_comptes')->item(0)->nodeValue;
|
|
|
|
|
$bilan['url_acces'] = $bilan_complet->getElementsByTagName('url_acces')->item(0)->nodeValue;
|
|
|
|
|
|
|
|
|
|
return $bilan['url_acces'];
|
2012-01-06 16:39:14 +00:00
|
|
|
|
}
|
2012-08-08 14:38:11 +00:00
|
|
|
|
|
2012-11-30 13:51:48 +00:00
|
|
|
|
/**
|
|
|
|
|
* Retourne la liste des actes
|
|
|
|
|
* @param string $siren
|
|
|
|
|
* @return array
|
|
|
|
|
*/
|
|
|
|
|
public function getActes($siren)
|
|
|
|
|
{
|
|
|
|
|
$this->siren = $siren;
|
|
|
|
|
$this->vecteur = 'XL';
|
|
|
|
|
$this->typeCommande = 'AC';
|
|
|
|
|
|
|
|
|
|
$cacheFile = APPLICATION_PATH . $this->cachePath.'/'.$this->typeCommande.'-'.$siren.'.xml';
|
|
|
|
|
|
|
|
|
|
//Get cache information
|
|
|
|
|
if (file_exists($cacheFile) && $this->cachetimeover($cacheFile) )
|
|
|
|
|
{
|
|
|
|
|
$xml = file_get_contents($cacheFile);
|
|
|
|
|
}
|
|
|
|
|
//Make the request
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
$xml = $this->getProduitsXML();
|
|
|
|
|
$this->error($xml);
|
|
|
|
|
|
|
|
|
|
//Create file for the cache
|
|
|
|
|
file_put_contents($cacheFile, $xml);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//Parse XML to make tab
|
|
|
|
|
$doc = new DOMDocument();
|
|
|
|
|
$doc->loadXML($xml);
|
|
|
|
|
$liste_depot_acte = $doc->getElementsByTagName('liste_depot_acte')->item(0);
|
|
|
|
|
$depot_actes = $liste_depot_acte->getElementsByTagName('depot_acte');
|
|
|
|
|
$actes = array();
|
|
|
|
|
foreach($depot_actes as $depot_acte)
|
|
|
|
|
{
|
|
|
|
|
$acte = array();
|
|
|
|
|
|
|
|
|
|
$acte['num_gest'] = array();
|
|
|
|
|
$num_gest = $depot_acte->getElementsByTagName('num_gest')->item(0);
|
|
|
|
|
$acte['num_gest']['greffe'] = $num_gest->getElementsByTagName('greffe')->item(0)->nodeValue;
|
|
|
|
|
$acte['num_gest']['dossier_millesime'] = $num_gest->getElementsByTagName('dossier_millesime')->item(0)->nodeValue;
|
|
|
|
|
$acte['num_gest']['dossier_statut'] = $num_gest->getElementsByTagName('dossier_statut')->item(0)->nodeValue;
|
|
|
|
|
$acte['num_gest']['dossier_chrono'] = $num_gest->getElementsByTagName('dossier_chrono')->item(0)->nodeValue;
|
|
|
|
|
|
|
|
|
|
$acte['num_siren'] = $depot_acte->getElementsByTagName('num_siren')->item(0)->nodeValue;
|
|
|
|
|
$acte['num_depot'] = $depot_acte->getElementsByTagName('num_depot')->item(0)->nodeValue;
|
|
|
|
|
$acte['date_depot'] = $depot_acte->getElementsByTagName('date_depot')->item(0)->nodeValue;
|
|
|
|
|
|
|
|
|
|
$infoActes = $depot_acte->getElementsByTagName('acte');
|
|
|
|
|
$acte['depot'] = array();
|
|
|
|
|
foreach($infoActes as $infoActe)
|
|
|
|
|
{
|
|
|
|
|
$actenum = array();
|
|
|
|
|
$actenum['date_acte'] = $infoActe->getElementsByTagName('date_acte')->item(0)->nodeValue;
|
|
|
|
|
$actenum['num_acte'] = $infoActe->getElementsByTagName('num_acte')->item(0)->nodeValue;
|
|
|
|
|
$actenum['type_acte'] = $infoActe->getElementsByTagName('type_acte')->item(0)->nodeValue;
|
|
|
|
|
$actenum['type_acte_libelle'] = $infoActe->getElementsByTagName('type_acte_libelle')->item(0)->nodeValue;
|
|
|
|
|
$actenum['nbpages_acte'] = $infoActe->getElementsByTagName('nbpages_acte')->item(0)->nodeValue;
|
|
|
|
|
$decision = $infoActe->getElementsByTagName('decision')->item(0);
|
|
|
|
|
if($decision)
|
|
|
|
|
{
|
|
|
|
|
$actenum['decision'] = array();
|
|
|
|
|
$actenum['decision']['nature'] = $decision->getElementsByTagName('nature')->item(0)->nodeValue;
|
|
|
|
|
$actenum['decision']['libelle'] = $decision->getElementsByTagName('libelle')->item(0)->nodeValue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$actenum['mode_diffusion'] = array();
|
|
|
|
|
$mode_diffusion = $infoActe->getElementsByTagName('mode_diffusion')->item(0)->getElementsByTagName('mode');
|
|
|
|
|
foreach($mode_diffusion as $mode)
|
|
|
|
|
{
|
|
|
|
|
$actenum['mode_diffusion'][] = $mode->getAttribute('type');
|
|
|
|
|
}
|
|
|
|
|
$acte['depot'][] = $actenum;
|
|
|
|
|
}//Fin listes des infos acte
|
|
|
|
|
|
|
|
|
|
//Génération de l'index pour le tri
|
|
|
|
|
if(!empty($acte['date_depot'])){
|
|
|
|
|
$date = $acte['date_depot'];
|
|
|
|
|
} else {
|
|
|
|
|
$date = '';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(!empty($date))
|
|
|
|
|
{
|
|
|
|
|
$datef = substr($date,0,4).substr($date,5,2).substr($date,8,2);
|
|
|
|
|
$key = $datef.'-'.$acte['num_depot'];
|
|
|
|
|
//Affectation liste générale avec un index permettant le tri
|
|
|
|
|
$actes[$key] = $acte;
|
|
|
|
|
}
|
|
|
|
|
//Prise en compte de l'acte -1
|
|
|
|
|
if($acte['num_depot']==-1)
|
|
|
|
|
{
|
|
|
|
|
$actes[0] = $acte;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//Tri suivant la date d'acte ou de depot
|
|
|
|
|
krsort($actes);
|
|
|
|
|
return $actes;
|
|
|
|
|
|
|
|
|
|
}
|
2012-08-08 14:38:11 +00:00
|
|
|
|
|
2012-11-30 13:51:48 +00:00
|
|
|
|
public function getActe($siren, $diffusion, $option)
|
2012-01-06 16:39:14 +00:00
|
|
|
|
{
|
2012-08-08 14:38:11 +00:00
|
|
|
|
//Retourner la référence de commande interne, chez infogreffe
|
2012-11-30 13:51:48 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$doc = new DOMDocument();
|
|
|
|
|
$doc->loadXML($xml);
|
|
|
|
|
|
|
|
|
|
$depot_acte = $doc->getElementsByTagName('depot_acte')->item(0);
|
|
|
|
|
|
|
|
|
|
$info = array();
|
|
|
|
|
$info['num_gest'] = array();
|
|
|
|
|
|
|
|
|
|
$num_gest = $depot_acte->getElementsByTagName('num_gest')->item(0);
|
|
|
|
|
|
|
|
|
|
$info['num_gest']['greffe'] = $num_gest->getElementsByTagName('greffe')->item(0)->nodeValue;
|
|
|
|
|
$info['num_gest']['dossier_millesime'] = $num_gest->getElementsByTagName('dossier_millesime')->item(0)->nodeValue;
|
|
|
|
|
$info['num_gest']['dossier_statut'] = $num_gest->getElementsByTagName('dossier_statut')->item(0)->nodeValue;
|
|
|
|
|
$info['num_gest']['dossier_chrono'] = $num_gest->getElementsByTagName('dossier_chrono')->item(0)->nodeValue;
|
|
|
|
|
|
|
|
|
|
$info['num_siren'] = $depot_acte->getElementsByTagName('num_siren')->item(0)->nodeValue;
|
|
|
|
|
$info['num_depot'] = $depot_acte->getElementsByTagName('num_depot')->item(0)->nodeValue;
|
|
|
|
|
$info['date_depot'] = $depot_acte->getElementsByTagName('date_depot')->item(0)->nodeValue;
|
|
|
|
|
|
|
|
|
|
$infoActes = $depot_acte->getElementsByTagName('acte');
|
|
|
|
|
$info['actes'] = array();
|
|
|
|
|
foreach($infoActes as $infoActe)
|
|
|
|
|
{
|
|
|
|
|
$actenum = array();
|
|
|
|
|
$actenum['date_acte'] = $infoActe->getElementsByTagName('date_acte')->item(0)->nodeValue;
|
|
|
|
|
$actenum['num_acte'] = $infoActe->getElementsByTagName('num_acte')->item(0)->nodeValue;
|
|
|
|
|
$actenum['type_acte'] = $infoActe->getElementsByTagName('type_acte')->item(0)->nodeValue;
|
|
|
|
|
$actenum['type_acte_libelle'] = $infoActe->getElementsByTagName('type_acte_libelle')->item(0)->nodeValue;
|
|
|
|
|
$actenum['nbpages_acte'] = $infoActe->getElementsByTagName('nbpages_acte')->item(0)->nodeValue;
|
|
|
|
|
|
|
|
|
|
$decision = $infoActe->getElementsByTagName('decision')->item(0);
|
|
|
|
|
if($decision)
|
|
|
|
|
{
|
|
|
|
|
$actenum['decision'] = array();
|
|
|
|
|
$actenum['decision']['nature'] = $decision->getElementsByTagName('nature')->item(0)->nodeValue;
|
|
|
|
|
$actenum['decision']['libelle'] = $decision->getElementsByTagName('libelle')->item(0)->nodeValue;
|
|
|
|
|
}
|
|
|
|
|
$actenum['url_acces'] = htmlspecialchars_decode($infoActe->getElementsByTagName('url_acces')->item(0)->nodeValue);
|
|
|
|
|
$info['actes'][] = $actenum;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2012-01-06 16:39:14 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|