Update Sd Librairies

This commit is contained in:
Michael RICOIS 2014-03-27 15:11:56 +00:00
commit 5b667ef58e
23 changed files with 2156 additions and 4109 deletions

View File

@ -88,6 +88,12 @@ class Metier_Infogreffe
*/
public $date_acte;
/**
*
* @var unknown
*/
public $type_acte;
/**
* AC : Numéro de l'acte
* @var string
@ -106,6 +112,11 @@ class Metier_Infogreffe
*/
protected $xml = '';
/**
* Cache delay
* @var unknown
*/
protected $cacheFiletime;
/**
* Initialize configuration
@ -118,12 +129,14 @@ class Metier_Infogreffe
if ( null === $this->config ) {
throw new Exception('Unable to load configuration file.');
}
$this->cacheFiletime = $c->profil->infogreffe->cache->time;
}
public function callRequest()
{
$fromCache = false;
if ( $this->mode_diffusion == 'XL' && $this->fileIsCache($name) ){
if ( $this->mode_diffusion == 'XL' && $this->fileIsCache() ){
$fromCache = true;
}
@ -131,15 +144,14 @@ class Metier_Infogreffe
$xml = $this->fileFromCache();
} else {
$xml = $this->getProduitsXML();
$this->error($xml);
}
$this->error($xml);
if ( $this->mode_diffusion == 'XL' ){
$this->fileTocache($xml);
}
$this->error($xml);
return $xml;
}
@ -168,10 +180,9 @@ class Metier_Infogreffe
/**
*
* @param string $xml
* @return boolean
*/
protected function fileIsCache($xml)
protected function fileIsCache()
{
$filename = $this->type_document . '-' . $this->siren . '.xml';
$file = $file = $this->config->cache->path . DIRECTORY_SEPARATOR . $filename;
@ -204,23 +215,20 @@ class Metier_Infogreffe
*/
protected function error($xml)
{
if (!empty($xml))
{
if ( !empty($xml) ) {
$doc = new DOMDocument();
$load = $doc->loadXML($xml, LIBXML_NOERROR | LIBXML_NOWARNING);
if (!$load) {
if ( !$load ) {
$tmp = explode('-', $xml);
$errNum = intval($tmp[0]);
$errMsg = $tmp[1];
if( $errNum == '5' ){
$errMsg = 'Service partenaire indisponible.';
}
throw new Exception($errNum . '-' . $errMsg);
throw new Exception($errMsg, $errNum);
}
}
else
{
throw new Exception('Fichier vide');
else {
throw new Exception('XML content is empty.');
}
}
@ -233,17 +241,24 @@ class Metier_Infogreffe
*/
protected function download($url, $filename)
{
$file = $file = $this->config->storage->path . DIRECTORY_SEPARATOR . $filename;
$fp = fopen($file, 'w');
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_FILE, $fp);
$data = curl_exec($ch);
if( curl_errno($ch) ) {
throw new Exception( curl_error($ch) );
$file = $this->config->storage->path . '/' . $filename;
try {
$client = new Zend_Http_Client($url);
$client->setStream();
$response = $client->request('GET');
if ( $response->isSuccessful() && substr($response->getBody(),0,4)=='%PDF' ) {
if ( copy($response->getStreamName(), $file) ) {
return $file;
} else {
throw new Exception( "Erreur lors de l'ecriture du fichier" );
}
} else {
throw new Exception( "Fichier non PDF" );
}
} catch (Zend_Http_Client_Exception $e) {
throw new Exception( $e->getMessage() );
}
curl_close($ch);
fclose($fp);
return $file;
}
/**
@ -288,8 +303,6 @@ class Metier_Infogreffe
$emetteur->addChild('code_abonne', $this->config->user);
$emetteur->addChild('mot_passe', $this->config->password);
//Set Command ID
$emetteur->addChild('reference_client', $this->reference_client);
$code_requete = $emetteur->addChild('code_requete');
$code_requete->addChild('type_profil', 'A');
$code_requete->addChild('origine_emetteur', 'IC');
@ -320,26 +333,32 @@ class Metier_Infogreffe
// Commande de documents : bilan saisie ou bilan complet
if ( ($this->type_document=='BS' || $this->type_document=='BI') )
{
$commande->addChild('greffe',$this->greffe);
$commande->addChild('dossier_millesime',$this->dossier_millesime);
$commande->addChild('dossier_statut',$this->dossier_statut);
$commande->addChild('dossier_chrono',$this->dossier_chrono);
$num_gest = $commande->addChild('num_gest');
$num_gest->addChild('greffe',$this->greffe);
$num_gest->addChild('dossier_millesime',$this->dossier_millesime);
$num_gest->addChild('dossier_statut',$this->dossier_statut);
$num_gest->addChild('dossier_chrono',$this->dossier_chrono);
$commande->addChild('num_depot',$this->num_depot);
//Date de cloture au format dd/MM/yyyy
$commande->addChild('date_cloture', $this->date_cloture);
}
// Commande de documents : actes
elseif ( $this->type_document=='AC' )
{
$commande->addChild('greffe',$this->greffe);
$commande->addChild('dossier_millesime',$this->dossier_millesime);
$commande->addChild('dossier_statut',$this->dossier_statut);
$commande->addChild('dossier_chrono',$this->dossier_chrono);
$num_gest = $commande->addChild('num_gest');
$num_gest->addChild('greffe',$this->greffe);
$num_gest->addChild('dossier_millesime',$this->dossier_millesime);
$num_gest->addChild('dossier_statut',$this->dossier_statut);
$num_gest->addChild('dossier_chrono',$this->dossier_chrono);
$commande->addChild('num_depot',$this->num_depot);
$liste_actes = $commande->addChild('liste_actes');
$liste_actes->addChild('acte')->addAttribute('num', $this->num);
}
}
//Set Command ID
$commande->addChild('reference_client', $this->reference_client);
$xml = str_replace('<?xml version="1.0"?>', '', $xml->asXML());
$this->xml = $xml;
@ -355,11 +374,10 @@ class Metier_Infogreffe
{
$this->setXML();
//Be sure it's in UTF-8
$req = utf8_encode($this->xml);
$req = $this->xml;
if ($this->debug) {
file_put_contents($this->type_document.'-'.$this->siren.'-'.$this->mode_diffusion.'.query');
file_put_contents($this->type_document.'-'.$this->siren.'-'.$this->mode_diffusion.'.query', $this->xml);
}
//Create XML request
@ -394,6 +412,10 @@ class Metier_Infogreffe
$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);
$response = str_replace('</return></ns0:getProduitsWebServicesXMLResponse></SOAP-ENV:Body></SOAP-ENV:Envelope>','', $response);
if ($this->debug) {
file_put_contents($this->type_document.'-'.$this->siren.'-'.$this->mode_diffusion.'.response', $response);
}
return $response;
}
}

View File

@ -19,8 +19,6 @@ class Metier_Infogreffe_Ac extends Metier_Infogreffe
*/
public function __construct($siren, $db = null)
{
//@todo : Inject db in batch
parent::__construct();
//Set type
@ -31,7 +29,7 @@ class Metier_Infogreffe_Ac extends Metier_Infogreffe
//Get defaut database adapter
if ($db === null) {
$this->db = Zend_Db_Table_Abstract::getDefaultAdapter();
$this->db = Zend_Db_Table_Abstract::getDefaultAdapter();
} else {
$this->db = $db;
}
@ -46,19 +44,31 @@ class Metier_Infogreffe_Ac extends Metier_Infogreffe
$this->mode_diffusion = 'XL';
$this->reference_client = 'list-' . $this->siren;
$actesM = new Application_Model_JoGreffesActes($this->db);
//Requete WebService
$actesXML = null;
if ( $onlyDb === false ) {
$this->debug = true;
//Infogreffe webservice
$xml = $this->callRequest();
$actesM->update(array('actif' => 0), 'siren='.$this->siren);
//Infogreffe webservice
try {
$xml = $this->callRequest();
} catch( Exception $e ) {
//file_put_contents('debug.log', $e->getMessage());
//@todo : get error message
//echo $e->getMessage();
return array();
}
$actesXML = $this->formatList($xml);
}
//Lecture de la base de données
$actesM = new Application_Model_JoGreffesActes($this->db);
$sql = $actesM->select()
->where('siren=?', $this->siren)
->where('actif=1')
->order('date_depot DESC')
->order('num_depot DESC')
->order('num_acte ASC')
->order('date_acte DESC');
$rows = $actesM->fetchAll($sql);
@ -71,7 +81,7 @@ class Metier_Infogreffe_Ac extends Metier_Infogreffe
$item->FileNumberOfPages = $row->pdfPage;
$item->DepotNum = $row->num_depot;
$item->DepotDate = $row->date_depot;
$item->ActeNum = $row->num_acte;
$item->ActeNum = str_pad($row->num_acte, 2, '0', STR_PAD_LEFT);
$item->ActeDate = $row->date_acte;
$item->ActeNumberOfPages = $row->nbpages_acte;
$item->ActeType = $row->type_acte;
@ -85,9 +95,8 @@ class Metier_Infogreffe_Ac extends Metier_Infogreffe
$item->infos[] = $decisions;
//@todo : si présence de fichier alors mode T
$mode_diffusion = explode(',', $row->mode_diffusion);
if (in_array('T',$mode_diffusion)) {
if (in_array('T',$mode_diffusion) || !empty($item->File)) {
$item->ModeDiffusion = 'T';
} elseif (in_array('C',$mode_diffusion)) {
$item->ModeDiffusion = 'C';
@ -109,20 +118,16 @@ class Metier_Infogreffe_Ac extends Metier_Infogreffe
* @param string $acteType
* @param string $acteDate
* @param int $acteNum
* @param int $orderId
* @throws Exception
* @return string
* Return the full path of the file
*/
public function getCommandeT($depotDate, $depotNum, $acteType, $acteDate, $acteNum)
public function getCommandeT($depotDate, $depotNum, $acteType, $acteDate, $acteNum, $orderId = null)
{
$this->mode_diffusion = 'T';
$this->reference_client = 'T'.date('YmdHis');
//Lire dans la base de données
$actesM = new Application_Model_JoGreffesActes($this->db);
//@todo : set vars
$sql = $actesM->select()
->where('siren=?', $this->siren)
->where('num_depot=?', $depotNum)
@ -136,40 +141,69 @@ class Metier_Infogreffe_Ac extends Metier_Infogreffe
throw new Exception('Not exist');
}
//Needed element for filename
$date = $row->date_acte;
$type = $row->type_acte;
$num = $row->num_acte;
$options = $row->numGreffe . '-' . substr($row->numR,0,2) . '-' . substr($row->numR,2,1) . '-' . substr($row->numR,3) . '-' . $row->num_depot;
$this->mode_diffusion = 'T';
$this->reference_client = 'T'.date('YmdHis');
$this->greffe = $row->numGreffe;
$this->dossier_millesime = substr($row->numRC,0,2);
$this->dossier_statut = substr($row->numRC,2,1);
$this->dossier_chrono = substr($row->numRC,3);
$this->date_depot = $row->date_depot;
$this->num_depot = $row->num_depot;
$this->date_acte = $row->date_acte;
$this->num = str_pad($row->num_acte, 2, '0', STR_PAD_LEFT);
//Needed element for filename
$date = $row->date_acte;
$type = $row->type_acte;
$num = $row->num_acte;
$options = $row->numGreffe . '-' . substr($row->numRC,0,2) . '-' . substr($row->numRC,2,1) . '-' . substr($row->numRC,3) . '-' . $row->num_depot;
//Set filename
$filename = $this->getFilePath($date) . '/' . $this->getFileName($date, $num, $type, $options);
if ( $row->pdfLink != '' ) {
//Set the filename
$filename = $this->getFilePath($date) . DIRECTORY_SEPARATOR . $this->getFileName($date, $num, $type, $options);
$filename = $this->getFilePath($date) . '/' . $row->pdfLink;
//Check if filename exist
if ( !file_exists($this->config->storage->path . DIRECTORY_SEPARATOR . $filename) ) {
if ( !file_exists($this->config->storage->path . '/' . $filename) ) {
throw new Exception('File not found');
}
} else {
} elseif ( file_exists($this->config->storage->path . '/' . $filename) ) {
//Analyser le fichier - Nombre de page et taille
$infos = $this->pdfInfos($this->config->storage->path . '/' . $filename);
//Enregistrer les infos du fichier dans la base de données
if (false !== $infos) {
$this->dbSetFile(basename($filename), $infos['size'], $infos['pages'], $infos['version']);
} else {
$this->dbSetFile(basename($filename));
}
} else {
try {
$xml = $this->callRequest();
} catch(Exception $e) {
throw new Exception($e->getMessage(), $e->getCode());
}
$xml = $this->callRequest();
$acte = $this->formatItem($xml);
$url = $acte['url_acces'];
$url = $acte['actes'][0]['url_acces'];
if (empty($url)) {
throw new Exception('File url not given');
}
//Set the filename
$filename = $this->getFilePath($date) . DIRECTORY_SEPARATOR . $this->getFileName($date, $num, $type, $options);
if ( $orderId !== null ) {
$commandeM = new Application_Model_Sdv1GreffeCommandesAc();
$commandeM->update(array(
'cmdUrl'=> $url,
'dateCommande' => date('YmdHis'),
), 'id='.$orderId);
}
//Récupérer le fichier
$getfile = $this->download($url, $filename);
@ -179,27 +213,66 @@ class Metier_Infogreffe_Ac extends Metier_Infogreffe
//Enregistrer les infos du fichier dans la base de données
if (false !== $infos) {
$this->dbSetFile($filename, $infos['size'], $infos['pages'], $infos['version']);
$this->dbSetFile(basename($filename), $infos['size'], $infos['pages'], $infos['version']);
} else {
$this->dbSetFile(basename($filename));
}
}
return $filename;
}
public function getCommandeC($id)
/**
*
* @param unknown $depotDate
* @param unknown $depotNum
* @param unknown $acteType
* @param unknown $acteDate
* @param unknown $acteNum
* @param string $reference
* @throws Exception
* @return boolean
*/
public function getCommandeC($depotDate, $depotNum, $acteType, $acteDate, $acteNum, $reference = '')
{
//Lire dans la base de données
$actesM = new Application_Model_JoGreffesActes();
$sql = $actesM->select()
->where('siren=?', $this->siren)
->where('num_depot=?', $depotNum)
->where('date_depot=?', $depotDate)
->where('num_acte=?', $acteNum)
->where('date_acte=?', $acteDate)
->where('type_acte=?', $acteType);
$row = $actesM->fetchRow($sql);
if ( null === $row ) {
throw new Exception('Not exist');
}
$this->mode_diffusion = 'C';
$this->reference_client = $reference;
//Générer les paramètres de commande depuis la base de données
$this->greffe = $row->numGreffe;
$this->dossier_millesime = substr($row->numRC,0,2);
$this->dossier_statut = substr($row->numRC,2,1);
$this->dossier_chrono = substr($row->numRC,3);
$this->num_depot = $row->num_depot;
$this->type_acte = $row->type_acte;
$this->date_acte = $row->date_acte;
$this->num = str_pad($row->num_acte, 2, '0', STR_PAD_LEFT);
//Enregistrer la commande dans la base de données
//Récupérer l'id de commande
$this->reference_client = 'G'.$id;
$xml = $this->callRequest();
//@todo :
//Faire la requete
try {
$xml = $this->callRequest();
} catch(Exception $e) {
//La prise en charge du courrier est effective
if ( $e->getCode() != 17 ) {
throw new Exception($e->getMessage());
}
}
return true;
}
/**
@ -227,7 +300,11 @@ class Metier_Infogreffe_Ac extends Metier_Infogreffe
*/
public function getFilePath($date)
{
return 'actes' . DIRECTORY_SEPARATOR . substr($date,0,4) . DIRECTORY_SEPARATOR . substr($date,5,2);
$dir = 'actes/' . substr($date,0,4) . '/' . substr($date,5,2);
if ( !file_exists( $this->config->storage->path . '/' . $dir ) ) {
mkdir($this->config->storage->path . '/' . $dir, 0777, true);
}
return $dir;
}
/**
@ -264,6 +341,9 @@ class Metier_Infogreffe_Ac extends Metier_Infogreffe
{
$actenum = array();
$actenum['date_acte'] = $infoActe->getElementsByTagName('date_acte')->item(0)->nodeValue;
if ($infoActe->getElementsByTagName('date_acte')->item(0)->nodeValue == '') {
$actenum['date_acte'] = '0000-00-00';
}
$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;
@ -370,61 +450,77 @@ class Metier_Infogreffe_Ac extends Metier_Infogreffe
*/
protected function dbUpdateItem($list)
{
//siren
//numRC
//numGreffe
//num_depot
//date_depot
//date_acte
//num_acte
//type_acte => Attention garder la version 1 et 2
//type_acte_libelle
//nbpages_acte
//decision_nature
//decision_libelle
//mode_diffusion
foreach ($list['depot'] as $depot) {
$data = array(
'siren' => $list['num_siren'],
'numRC' => $list['num_gest']['dossier_millesime'].
$list['num_gest']['dossier_statut'].$list['num_gest']['dossier_chrono'],
'numGreffe' => $list['num_gest']['greffe'],
'num_depot' => $list['num_depot'],
'date_depot' => $list['date_depot'],
'date_acte' => $depot['date_acte'],
'num_acte' => $depot['num_acte'],
'type_acte' => $depot['type_acte'],
'type_acte_libelle' => $depot['type_acte_libelle'],
'nbpages_acte' => $depot['nbpages_acte'],
'decision_nature' => empty($depot['decision']['nature']) ? '' : $depot['decision']['nature'] ,
'decision_libelle' => empty($depot['decision']['libelle']) ? '' : $depot['decision']['libelle'] ,
'mode_diffusion' => join(',',$depot['mode_diffusion']),
'actif' => 1,
);
$data = array(
'siren' => $list['siren'],
'numRC' => $list['num_gest']['dossier_millesime'].
$list['num_gest']['dossier_statut'].$list['num_gest']['dossier_chrono'],
'numGreffe' => $list['num_gest']['greffe'],
'num_depot' => $list['num_depot'],
'date_depot' => $list['date_depot'],
'date_acte' => $list['date_acte'],
'num_acte' => $list['num_acte'],
'type_acte' => $list['type_acte'],
'type_acte_libelle' => $list['type_acte_libelle'],
'nbpages_acte' => $list['nbpages_acte'],
'decision_nature' => $list['decision']['nature'],
'decision_libelle' => $list['decision']['libelle'],
'mode_diffusion' => join(',',$list['mode_diffusion']),
);
//Only new element are inserted
try {
$acteM = new Application_Model_JoGreffesActes($this->db);
$acteM->select()
->where('siren=?', $list['siren'])
->where('num_depot=?', $list['num_depot'])
->where('date_depot=?', $list['date_depot'])
->where('date_acte=?', $list['date_acte'])
->where('num_acte=?', $list['num_acte'])
->where('type_acte=?', $list['type_acte']); //Attention type lors du téléchargement
if ( null === $acteM->fetchRow($sql) ) {
$result = $acteM->insert($data);
//Only new element are inserted
try {
$acteM = new Application_Model_JoGreffesActes($this->db);
$sql = $acteM->select()
->where('siren=?', $list['num_siren'])
->where('num_depot=?', intval($list['num_depot']))
//->where('date_depot=?', $list['date_depot'])
//->where('date_acte=?', $depot['date_acte'])
->where('num_acte=?', intval($depot['num_acte']))
->order('dateInsert DESC');
$rows = $acteM->fetchAll($sql);
} catch(Zend_Db_Adapter_Exception $e) {
throw new Exception($e->getMessage());
}
} catch(Zend_Db_Adapter_Exception $e) {
throw new Exception($e->getMessage());
} catch(Zend_Db_Exception $e) {
throw new Exception($e->getMessage());
//Insert new element
if ( count($rows)==0 ) {
try {
//Add dateInsert
$data['dateInsert'] = date('YmdHis');
$result = $acteM->insert($data);
} catch(Zend_Exception $e) {
throw new Exception($e->getMessage());
}
}
//Update information
else {
//Correct multiple item
$item = $rows[0];
if ( count($rows) > 1 ) {
try {
$result = $acteM->delete(array(
'siren='.$this->siren,
'num_depot='.intval($list['num_depot']),
'num_acte='.intval($depot['num_acte']),
'id!='.$item->id,
));
} catch(Zend_Exception $e) {
throw new Exception($e->getMessage());
}
}
try {
$result = $acteM->update($data, 'id='.$item->id);
} catch(Zend_Exception $e) {
throw new Exception($e->getMessage());
}
}
}
if ($result) {
return true;
}
return false;
return true;
}
/**
@ -435,21 +531,22 @@ class Metier_Infogreffe_Ac extends Metier_Infogreffe
* @param string $version
* @return boolean
*/
protected function dbSetFile($filename, $size, $numberOfPage, $version)
protected function dbSetFile($filename, $size = 0, $numberOfPage = '', $version = '')
{
$data = array(
'pdfLink' => $filename,
'pdfSize' => $size,
'pdfPage' => $numberOfPage,
'pdfVer' => $version
'pdfVer' => $version,
'pdfDate' => date('Ymd'),
);
$where = array(
'siren="'.$this->siren."'",
'num_depot' => $this->num_depot,
'date_depot' => $this->date_depot,
'date_acte' => $this->date_acte,
'num_acte' => $this->num,
'siren='.$this->siren,
'num_depot='.$this->num_depot,
'date_depot="'.$this->date_depot.'"',
'date_acte="'.$this->date_acte.'"',
'num_acte='.$this->num,
);
try {

View File

@ -42,6 +42,7 @@ class Metier_Infogreffe_Bi extends Metier_Infogreffe
}
/**
*
* @param $onlyDb
* @return array
*/
@ -50,20 +51,33 @@ class Metier_Infogreffe_Bi extends Metier_Infogreffe
$this->mode_diffusion = 'XL';
$this->reference_client = 'list-' . $this->siren;
$bilansM = new Application_Model_JoGreffesBilans();
//Requete WebService
$bilansXML = null;
if ( $onlyDb === false ) {
$this->debug = true;
//Set All line state to 0
try {
$bilansM->update(array('actif' => 0), 'siren='.$this->siren);
} catch(Zend_Db_Exception $e) {}
//Infogreffe webservice
$xml = $this->callRequest();
try {
$xml = $this->callRequest();
} catch( Exception $e ) {
//@todo : get error message
return array();
}
$bilansXML = $this->formatList($xml);
}
//Lecture de la base de données
$bilansM = new Application_Model_JoGreffesBilans();
$sql = $bilansM->select()
->where('siren=?', $this->siren)
->order('date_cloture DESC');
->where('actif=1')
->order('date_cloture DESC')
->order('num_depot DESC')
->order('dateInsert DESC');
//GROUP BY type_comptes, date_cloture AND ORDER BY num_depot DESC
$rows = $bilansM->fetchAll($sql);
$bilans = array();
@ -76,11 +90,14 @@ class Metier_Infogreffe_Bi extends Metier_Infogreffe
$item->Millesime = $row->millesime;
$item->NumDepot = $row->num_depot;
$item->DateCloture = $row->date_cloture;
$item->Type = $row->type_comptes;
if ( empty($row->type_comptes) ) {
$item->Type = 'sociaux';
} else {
$item->Type = $row->type_comptes;
}
$mode_diffusion = explode(',', $row->mode_diffusion);
//@todo : si présence de fichier alors mode T
if (in_array('T',$mode_diffusion)) {
if (in_array('T', $mode_diffusion) || !empty($item->File)) {
$item->ModeDiffusion = 'T';
} elseif (in_array('C',$mode_diffusion)) {
$item->ModeDiffusion = 'C';
@ -88,6 +105,33 @@ class Metier_Infogreffe_Bi extends Metier_Infogreffe
$item->ModeDiffusion = '';
}
$item->DureeExercice = $row->duree_exercice;
$item->SaisieDate = $row->saisie_date;
$item->SaisieCode = $row->saisie_code;
switch ( $row->saisie_code ) {
case '00': $item->SaisieLabel = "Bilan saisi sans anomalie"; break;
case '01': $item->SaisieLabel = "Bilan saisi avec des incohérences comptables à la source du document (issues du remettant)"; break;
case '02': $item->SaisieLabel = "Bilan avec Actif, Passif ou Compte de Résultat nul"; break;
case '03': $item->SaisieLabel = "Bilan incomplet (des pages manquent)"; break;
case '04': $item->SaisieLabel = "Bilan complet non détaillé (seuls les totaux et sous totaux sont renseignés)"; break;
case '05': $item->SaisieLabel = "Bilan reçu en double exemplaire"; break;
case '06': $item->SaisieLabel = "Bilan intermédiaire - Situation provisoire"; break;
case '07': $item->SaisieLabel = "Bilan illisible"; break;
case 'A7': $item->SaisieLabel = "Bilan illisible, présentant un cadre gris très foncés (dans lesquels sont inscrits en général les totaux)"; break;
case 'B7': $item->SaisieLabel = "Bilan manuscrits"; break;
case 'C7': $item->SaisieLabel = "Bilan illisible, présentant des caractères trop gras"; break;
case 'D7': $item->SaisieLabel = "Bilan scanné en biais ou qui présentent des pages rognées"; break;
case 'E7': $item->SaisieLabel = "Bilan numérisés trop clairement (comme une imprimante dont la cartouche est presque vide)"; break;
case 'F7': $item->SaisieLabel = "Bilan illisible"; break;
case '08': $item->SaisieLabel = "Bilan consolidé"; break;
case '09': $item->SaisieLabel = "Déclaration d'impôts"; break;
case '10': $item->SaisieLabel = "Document autre que bilan"; break;
case '11': $item->SaisieLabel = "Bilan de clôture de liquidation"; break;
case '12': $item->SaisieLabel = "Bilan de Société financière"; break;
case '13': $item->SaisieLabel = "Bilan de Société d'assurance"; break;
case '14': $item->SaisieLabel = "Bilan de Société immobilière"; break;
case '15': $item->SaisieLabel = "Bilan de Société étrangère"; break;
default: $item->SaisieLabel = ""; break;
}
$bilans[] = $item;
}
}
@ -102,70 +146,86 @@ class Metier_Infogreffe_Bi extends Metier_Infogreffe
* Format AAAA-MM-DD
* @param string $type
* sociaux ou consolides
* @params int $orderId
* Id de commande pour l'enregistrement dans la table de gestion
* @throws Exception
* @return string
* Return path (not complete) and filename
*/
public function getCommandeT($dateCloture = null, $type = 'sociaux')
public function getCommandeT($dateCloture = null, $type = 'sociaux', $orderId = null)
{
$this->mode_diffusion = 'T';
$this->reference_client = 'T'.date('YmdHis');
//Lire dans la base de données
$bilansM = new Application_Model_JoGreffesBilans();
$sql = $bilansM->select()
->where('siren=?', $this->siren)
->where('date_cloture=?', $dateCloture);
if ( $type == 'sociaux' || $type == '' ) {
$sql->where("(type='sociaux' OR type='')");
$sql->where("(type_comptes='sociaux' OR type_comptes='')");
} else {
$sql->where('type=?',$type);
$sql->where('type_comptes=?',$type);
}
$sql->order('dateInsert DESC')->order('num_depot DESC')->limit(1);
$row = $bilansM->fetchRow($sql);
if ( null === $row ) {
throw new Exception('Not exist');
throw new Exception("Element doesn't exist");
}
$this->mode_diffusion = 'T';
$this->reference_client = 'T'.date('YmdHis');
$this->greffe = $row->numGreffe;
$this->dossier_millesime = substr($row->numRC,0,2);
$this->dossier_statut = substr($row->numRC,2,1);
$this->dossier_chrono = substr($row->numRC,3);
$this->num_depot = $row->num_depot;
$this->date_cloture = $row->date_cloture;
//Set the filename
$filename = $this->getFilePath($type, $dateCloture) . '/' . $this->getFileName($type, $dateCloture);
if ($row->pdfLink != '') {
//Set filename
$filename = $this->getFilePath($type, $dateCloture) .
DIRECTORY_SEPARATOR .
$this->getFileName($type, $dateCloture);
$filename = $this->getFilePath($type, $dateCloture) . '/' . $this->getFileName($type, $dateCloture);
//Check if filename exist
if ( !file_exists($this->config->storage->path . DIRECTORY_SEPARATOR . $filename) ) {
if ( !file_exists($this->config->storage->path . '/' . $filename) ) {
throw new Exception('File not found');
}
}elseif ( file_exists($this->config->storage->path . '/' . $filename) ) {
//Analyser le fichier - Nombre de page et taille
$infos = $this->pdfInfos($this->config->storage->path . '/' . $filename);
//Enregistrer les infos du fichier dans la base de données
if (false !== $infos) {
$this->dbSetFile(basename($filename), $infos['size'], $infos['pages'], $infos['version']);
} else {
$this->dbSetFile(basename($filename));
}
} else {
$this->greffe = $row->numGreffe;
$this->dossier_millesime = substr($row->numRC,0,2);
$this->dossier_statut = substr($row->numRC,2,1);
$this->dossier_chrono = substr($row->numRC,3);
$this->num_depot = $row->num_depot;
$this->date_cloture = $row->date_cloture;
try {
$xml = $this->callRequest();
} catch(Exception $e) {
//@todo : Error
//Erreur commande webservice
throw new Exception($e->getMessage(), $e->getCode());
}
$bilan = $this->formatItem($xml);
$url = $bilan['url_acces'];
if (empty($url)) {
if ( empty($url) ) {
throw new Exception('File url not given');
}
//Set the filename
$filename = $this->getFilePath($type, $dateCloture) .
DIRECTORY_SEPARATOR .
$this->getFileName($type, $dateCloture);
if ( $orderId !== null ) {
$commandeM = new Application_Model_Sdv1GreffeCommandesBi();
$commandeM->update(array(
'cmdUrl'=> $url,
'dateCommande' => date('YmdHis'),
), 'id='.$orderId);
}
//Récupérer le fichier
$getfile = $this->download($url, $filename);
@ -175,7 +235,9 @@ class Metier_Infogreffe_Bi extends Metier_Infogreffe
//Enregistrer les infos du fichier dans la base de données
if (false !== $infos) {
$this->dbSetFile($filename, $infos['size'], $infos['pages'], $infos['version']);
$this->dbSetFile(basename($filename), $infos['size'], $infos['pages'], $infos['version']);
} else {
$this->dbSetFile(basename($filename));
}
}
@ -200,9 +262,9 @@ class Metier_Infogreffe_Bi extends Metier_Infogreffe
->where('siren=?', $this->siren)
->where('date_cloture=?', $dateCloture);
if ($type=='sociaux') {
$sql->where("(type='sociaux' OR type='')");
$sql->where("(type_comptes='sociaux' OR type_comptes='')");
} else {
$sql->where('type=?',$type);
$sql->where('type_comptes=?',$type);
}
$row = $bilansM->fetchRow($sql);
if ( null === $row ) {
@ -223,8 +285,10 @@ class Metier_Infogreffe_Bi extends Metier_Infogreffe
try {
$xml = $this->callRequest();
} catch(Exception $e) {
//@todo : Gestion des erreurs
return false;
//La prise en charge du courrier est effective
if ( $e->getCode() != 17 ) {
throw new Exception($e->getMessage());
}
}
return true;
@ -234,7 +298,7 @@ class Metier_Infogreffe_Bi extends Metier_Infogreffe
* Name of file
* @param string $type
* @param string $dateCloture
* Format : AAAAMMJJ
* Format : AAAA-MM-JJ
* @return string
*/
public function getFileName($type, $dateCloture)
@ -242,7 +306,9 @@ class Metier_Infogreffe_Bi extends Metier_Infogreffe
if ($type=='') {
$type = 'sociaux';
}
return 'bilan-' . $this->siren . '-' . $type . '-' . $dateCloture . '.pdf';
$date = substr($dateCloture,0,4).substr($dateCloture,5,2).substr($dateCloture,8,2);
return 'bilan-' . $this->siren . '-' . $type . '-' . $date . '.pdf';
}
/**
@ -257,10 +323,13 @@ class Metier_Infogreffe_Bi extends Metier_Infogreffe
if ($type=='') {
$type = 'sociaux';
}
return 'bilans' . DIRECTORY_SEPARATOR . $type . DIRECTORY_SEPARATOR . substr($dateCloture,0,4);
$dir = 'bilans' . '/' . $type . '/' . substr($dateCloture,0,4);
if ( !file_exists( $this->config->storage->path . '/' . $dir ) ) {
mkdir($this->config->storage->path . '/' . $dir, 0777, true);
}
return $dir;
}
/**
* Format XML to Array for a list of items
* @param string $xml
@ -358,33 +427,69 @@ class Metier_Infogreffe_Bi extends Metier_Infogreffe
'numRC' => $list['num_gest']['dossier_millesime'].
$list['num_gest']['dossier_statut'].$list['num_gest']['dossier_chrono'],
//'numRC2' => '',
'numGreffe' => $list['num_gest']['greffe'],
'numGreffe' => intval($list['num_gest']['greffe']),
'millesime' => $list['millesime'],
'num_depot' => $list['num_depot'],
'date_cloture' => $list['date_cloture_iso'],
'type_comptes' => $list['type_comptes'],
'mode_diffusion' => join(',',$list['mode_diffusion']),
'actif' => 1,
);
$this->db->getProfiler()->setEnabled(true);
try {
$bilanM = new Application_Model_JoGreffesBilans();
$sql = $bilanM->select()
->where('siren=?', $this->siren)
->where('date_cloture=?', $list['date_cloture_iso']);
if ( null === $bilanM->fetchRow($sql) ) {
$result = $bilanM->insert($data);
} else {
$result = $bilanM->update($data, array(
'siren="'.$list['num_siren'].'"',
'date_cloture="'.$list['date_cloture_iso'].'"',
));
}
} catch(Zend_Db_Adapter_Exception $e) {
throw new Exception($e->getMessage());
->where('num_depot=?', $list['num_depot'])
->where('date_cloture=?', $list['date_cloture_iso'])
//->where('type_comptes=?', $list['type_comptes'])
->order('dateInsert ASC');
$rows = $bilanM->fetchAll($sql);
} catch(Zend_Db_Exception $e) {
/*echo $query = $this->db->getProfiler()->getLastQueryProfile()->getQuery();
echo "\n";
$queryParams = $this->db->getProfiler()->getLastQueryProfile()->getQueryParams();
print_r($queryParams);
echo "\n";*/
throw new Exception($e->getMessage());
}
$this->db->getProfiler()->setEnabled(false);
if ( count($rows) == 0 ) {
//Add dateInsert
$data['dateInsert'] = date('YmdHis');
try {
$result = $bilanM->insert($data);
} catch(Zend_Exception $e) {
throw new Exception($e->getMessage());
}
} else {
//Correct multiple item
$item = $rows[0];
if ( count($rows) > 1 ) {
try {
$result = $bilanM->delete(array(
$bilanM->getAdapter()->quoteInto('siren=?', $this->siren),
$bilanM->getAdapter()->quoteInto('num_depot=?', $list['num_depot']),
$bilanM->getAdapter()->quoteInto('date_cloture=?', $list['date_cloture_iso']),
$bilanM->getAdapter()->quoteInto('type_comptes=?', $list['type_comptes']),
'id!='.$item->id,
));
} catch(Zend_Exception $e) {
throw new Exception($e->getMessage());
}
}
try {
$result = $bilanM->update($data, 'id='.$item->id);
} catch(Zend_Exception $e) {
throw new Exception($e->getMessage());
}
}
if ($result) {
return true;
}
@ -400,7 +505,7 @@ class Metier_Infogreffe_Bi extends Metier_Infogreffe
* @param string $version
* @return boolean
*/
public function dbSetFile($filename, $size, $numberOfPage, $version)
public function dbSetFile($filename, $size = 0, $numberOfPage = '', $version = '')
{
$data = array(
'pdfLink' => $filename,
@ -412,7 +517,7 @@ class Metier_Infogreffe_Bi extends Metier_Infogreffe
$where = array(
'siren='.$this->siren,
'date_cloture="'.substr($this->date_cloture,0,4).'-'.substr($this->date_cloture,4,2).'-'.substr($this->date_cloture,6,2).'"',
'date_cloture="'.$this->date_cloture.'"',
'type_comptes="'.$this->type_comptes.'"',
);

View File

@ -0,0 +1,80 @@
<definitions
targetNamespace="java:com.experian.webserv.infogreffe"
xmlns="http://schemas.xmlsoap.org/wsdl/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:tns="java:com.experian.webserv.infogreffe"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>
<types>
<schema targetNamespace='java:com.experian.webserv.infogreffe'
xmlns='http://www.w3.org/2001/XMLSchema'>
</schema>
</types>
<message name="getProduitsWebServicesXMLRequest">
<part name="arg0" type="xsd:string" />
</message>
<message name="getProduitsWebServicesXMLResponse">
<part name="return" type="xsd:string" />
</message>
<message name="getProduitsWebServicesRequest">
<part name="arg0" type="xsd:string" />
<part name="arg1" type="xsd:string" />
<part name="arg2" type="xsd:string" />
<part name="arg3" type="xsd:string" />
<part name="arg4" type="xsd:string" />
<part name="arg5" type="xsd:string" />
<part name="arg6" type="xsd:string" />
<part name="arg7" type="xsd:string" />
<part name="arg8" type="xsd:string" />
<part name="arg9" type="xsd:string" />
<part name="arg10" type="xsd:string" />
</message>
<message name="getProduitsWebServicesResponse">
<part name="return" type="xsd:string" />
</message>
<message name="getVersionRequest">
</message>
<message name="getVersionResponse">
<part name="return" type="xsd:string" />
</message>
<portType name="WebServicesProduitsPortType">
<operation name="getProduitsWebServicesXML">
<input message="tns:getProduitsWebServicesXMLRequest"/>
<output message="tns:getProduitsWebServicesXMLResponse"/>
</operation>
<operation name="getProduitsWebServices">
<input message="tns:getProduitsWebServicesRequest"/>
<output message="tns:getProduitsWebServicesResponse"/>
</operation>
<operation name="getVersion">
<input message="tns:getVersionRequest"/>
<output message="tns:getVersionResponse"/>
</operation>
</portType>
<binding name="WebServicesProduitsBinding" type="tns:WebServicesProduitsPortType">
<soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="getProduitsWebServicesXML">
<soap:operation soapAction="urn:getProduitsWebServicesXML"/>
<input><soap:body use="encoded" namespace='urn:WebServicesProduits' encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/></input>
<output><soap:body use="encoded" namespace='urn:WebServicesProduits' encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/></output>
</operation>
<operation name="getProduitsWebServices">
<soap:operation soapAction="urn:getProduitsWebServices"/>
<input><soap:body use="encoded" namespace='urn:WebServicesProduits' encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/></input>
<output><soap:body use="encoded" namespace='urn:WebServicesProduits' encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/></output>
</operation>
<operation name="getVersion">
<soap:operation soapAction="urn:getVersion"/>
<input><soap:body use="encoded" namespace='urn:Version' encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/></input>
<output><soap:body use="encoded" namespace='urn:Version' encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/></output>
</operation>
</binding>
<service name="WebServicesProduits">
<documentation>Service Soap Experian, Service Produit</documentation>
<port name="WebServicesProduitsPort" binding="tns:WebServicesProduitsBinding">
<soap:address location="https://wsrcte.extelia.fr:80/WSContextInfogreffe/INFOGREFFE"/>
</port>
</service>
</definitions>

View File

@ -16,7 +16,7 @@ class Metier_Search_Engine
if ($version == 1){
require_once 'Vendors/sphinxapi/sphinxapi-0.9.9.php';
} elseif ($version == 2){
require_once 'Vendors/sphinxapi/sphinxapi-2.1.2.php';
require_once 'Vendors/sphinxapi/sphinxapi-2.1.5.php';
}
}

View File

@ -896,6 +896,20 @@ return array(
'Version' => 12,
'LienEtab' => 0,
),
'2103' => array(
'libEven' => "Transformation du capital fixe en variable",
'Bodacc_Code' => "BODB",
'Rubrique' => "mmd",
'Version' => 18,
'LienEtab' => 0,
),
'2104' => array(
'libEven' => "Transformation du capital variable en capital fixe",
'Bodacc_Code' => "BODB",
'Rubrique' => "mmd",
'Version' => 18,
'LienEtab' => 0,
),
'2200' => array(
'libEven' => "Cessation d'activité",
'Bodacc_Code' => "BODB",
@ -1561,6 +1575,13 @@ return array(
'Version' => 12,
'LienEtab' => 1,
),
'2893' => array(
'libEven' => "Location gérance relative à une partie du fonds",
'Bodacc_Code' => "BODB",
'Rubrique' => "mmd",
'Version' => 18,
'LienEtab' => 1,
),
'2900' => array(
'libEven' => "Transfert d'établissement",
'Bodacc_Code' => "BODB",
@ -1841,6 +1862,13 @@ return array(
'Version' => 12,
'LienEtab' => 1,
),
'5106' => array(
'libEven' => "Cession de l'exploitation agricole",
'Bodacc_Code' => "BODA",
'Rubrique' => "ventes",
'Version' => 18,
'LienEtab' => 1,
),
'5200' => array(
'libEven' => "Branche ou Partie d'activité",
'Bodacc_Code' => "BODA",
@ -1989,7 +2017,7 @@ return array(
'LienEtab' => 1,
),
'5600' => array(
'libEven' => "Entreprise « Précédent exploitant »",
'libEven' => "Entreprise « Précédent exploitant »",
'Bodacc_Code' => "BODA",
'Rubrique' => "ventes",
'Version' => 12,

File diff suppressed because it is too large Load Diff

View File

@ -2,8 +2,8 @@
ini_set('soap.wsdl_cache_enabled', 0);
ini_set('default_socket_timeout', 30);
class MAmabis {
class MAmabis
{
private $client;
function __construct()
@ -19,7 +19,8 @@ class MAmabis {
));
}
function getZonage($adrNum, $adrIndRep, $adrTypeVoie, $adrLibVoie, $cp, $ville='', $codeRivoli='', $rnvp=false, $raisonSociale='TEST', $debug=false) {
function getZonage($adrNum, $adrIndRep, $adrTypeVoie, $adrLibVoie, $cp, $ville='', $codeRivoli='', $rnvp=false, $raisonSociale='TEST', $debug=false)
{
$tabRep=array();
if (!$rnvp) {
if ($cp<10000) $cp='0'.$cp;
@ -27,7 +28,7 @@ class MAmabis {
$dep3=substr($cp,0,3)*1;
switch ($dep2) {
case 0:
case 5:
/*case 5:
case 9:
case 15:
case 19:
@ -35,7 +36,7 @@ class MAmabis {
case 32:
case 46:
case 48:
case 82:
case 82:*/
case 97: // DOM
case 98: // TOM
case 99: // Etranger
@ -50,10 +51,19 @@ class MAmabis {
$iDb=new WDB();
$adresse=addslashes(trim(preg_replace('/ +/',' ', "$adrNum $adrIndRep $adrTypeVoie $adrLibVoie")));
$ville=addslashes($ville);
$ret=$iDb->select( 'zonage', 'zus, zru, zfu, cucs', "address='$adresse' AND adr_cp='$cp' AND adr_ville='$ville'",false, MYSQL_ASSOC);
$majForcee=false;
$ret=$iDb->select( 'zonage', 'zus, zru, zfu, cucs, rnvpStatut, rnvpCorr, rnvpTrt, adr3, adr4, adr5, adr6, adr7, numVoieA, indRepA,
typeVoieAlong, typeVoieAcourt, corpVoie, motDir, motDirD, libVoieSec, adr4n32, adr4n38, clePostaleVoie,
secteur, cleRoutage, cpx, cleAd, codPaysIso2, codPaysIso3, libPays, codeInsee',
"address='$adresse' AND adr_cp='$cp' AND adr_ville='$ville'",false, MYSQL_ASSOC);
$zones=@$ret[0];
if (count($ret)>0) {
$zones=$ret[0];
if ($zones['rnvpStatut']===null && $rnvp) $majForcee=true;
$tabRep['ZUS']=$tabRep['ZFU']=$tabRep['ZRU']=$tabRep['CUCS']='NON';
//$tabRep['NZUS']=$tabRep['NZFU']=$tabRep['NZRU']=$tabRep['NCUCS']='';
if (trim($zones['zus'])<>'') {
if (trim($zones['zus'])=='NSP') $tabRep['ZUS']='NSP';
else $tabRep['ZUS']='OUI';
@ -74,9 +84,26 @@ class MAmabis {
else $tabRep['CUCS']='OUI';
$tabRep['NCUCS']=$zones['cucs'];
}
//return $tabRep;
} else {
/** Autres Informations de la RNVP
**/
if ($rnvp) {
//$tabRep['ADR1']=@trim($tabZones['ADR1']);
//$tabRep['ADR2']=@trim($tabZones['ADR2']);
if (strtoupper(@trim($zones['adr7']))=='FRANCE') $zones['adr7']='';
$tabRep['ADR3']=@trim($zones['adr3']);
$tabRep['ADR4']=@trim($zones['adr4']);
$tabRep['ADR5']=@trim($zones['adr5']);
$tabRep['ADR6']=@trim($zones['adr6']);
$tabRep['ADR7']=trim($zones['adr7']);
}
}
if (count($ret)==0 || $majForcee) {
try {
if (trim($raisonSociale)=='') $raisonSociale='TEST'; // Le RNVP ne fonctionne pas sans la Raison Sociale qui est la 1ère ligne d'adresse
$rep=$this->client->zonage( new SoapParam(strtr("$raisonSociale:$adresse:$cp:$ville",
@ -101,60 +128,137 @@ class MAmabis {
if (trim($tabTmp[0])<>'')
$tabRep[$tabTmp[0]]=$tabTmp[1];
}
if ($tabRep['ZUS']=='NSP') $tabRep['NZUS']='NSP';
if ($tabRep['ZRU']=='NSP') $tabRep['NZRU']='NSP';
if ($tabRep['ZFU']=='NSP') $tabRep['NZFU']='NSP';
if ($tabRep['CUCS']=='NSP') $tabRep['NCUCS']='NSP';
if (@$tabRep['ZUS']=='NSP') $tabRep['NZUS']='NSP';
if (@$tabRep['ZRU']=='NSP') $tabRep['NZRU']='NSP';
if (@$tabRep['ZFU']=='NSP') $tabRep['NZFU']='NSP';
if (@$tabRep['CUCS']=='NSP') $tabRep['NCUCS']='NSP';
$adresse=stripslashes(trim(preg_replace('/ +/',' ', "$adrNum $adrIndRep $adrTypeVoie $adrLibVoie")));
$ville=stripslashes($ville);
$tabInsert=array( 'address'=>$adresse,
'adr_cp'=>$cp,
'adr_ville'=>$ville,
'zus'=>$tabRep['NZUS'],
'zru'=>$tabRep['NZRU'],
'zfu'=>$tabRep['NZFU'],
'cucs'=>$tabRep['NCUCS'],
'adrNum'=>$adrNum,
'adrIndRep'=>$adrIndRep,
'adrTypeVoie'=>$adrTypeVoie,
'adrLibVoie'=>$adrLibVoie,
'rivoli'=>$codeRivoli,
);
$iDb->insert('zonage', $tabInsert);
$tabRepTmp=array();
$tabTmp=explode('=',utf8_decode($rep['objdesc']));
//print_r($tabTmp);
//die();
$tabZones=array();
foreach ($tabTmp as $iZone=>$zone) {
$pos=strrpos($zone,',');
if ($iZone==0) {
$nomZoneSuiv=$zone;
continue;
}
$tabZones[$nomZoneSuiv]=substr($zone,0,$pos);
$nomZoneSuiv=substr($zone,$pos+1);
}
if (strtoupper(@trim($tabZones['ADR7']))=='FRANCE') $tabZones['ADR7']='';
$tabTmp=explode('|', $tabZones['VOIEA']);
$typeVoieAcourt=@trim($tabTmp[1]);
$tabInsert=array(
'address'=>$adresse,
'adr_cp'=>$cp,
'adr_ville'=>$ville,
'zus'=>@$tabRep['NZUS'],
'zru'=>@$tabRep['NZRU'],
'zfu'=>@$tabRep['NZFU'],
'cucs'=>@$tabRep['NCUCS'],
);
$tabUpdate=array(
'adrNum'=>$adrNum,
'adrIndRep'=>$adrIndRep,
'adrTypeVoie'=>$adrTypeVoie,
'adrLibVoie'=>$adrLibVoie,
'rivoli'=>$codeRivoli,
// Ajouté le 16/12/2013
'rnvpStatut' => substr($tabZones['STATUTC'],0,2),
'rnvpCorr' => substr($tabZones['STATUTC'],2,1),
'rnvpTrt' => trim(substr($tabZones['STATUTC'],3,2)),
'adr3' => @trim($tabZones['ADR3']),
'adr4' => @trim($tabZones['ADR4']),
'adr5' => @trim($tabZones['ADR5']),
'adr6' => @trim($tabZones['ADR6']),
'adr7' => trim($tabZones['ADR7']),
'numVoieA' => @trim($tabZones['NUM1']),
'indRepA' => @trim($tabZones['BTQC1']),
'typeVoieAlong' => @trim($tabZones['TYPVOIEL']),
'typeVoieAcourt' => $typeVoieAcourt,
'corpVoie' => @trim($tabZones['CORPSVOIE']),
'motDir' => @trim($tabZones['MOTDIR']),
'motDirD' => @trim($tabZones['MOTDIRD']),
'libVoieSec' => @trim($tabZones['VOIREFLIBS']),
'adr4n32' => @trim($tabZones['VOIREFLIBPOS']),
'adr4n38' => @trim($tabZones['VOIREFLIBPOS2']),
'clePostaleVoie' => @trim($tabZones['VOIREFCLEPOST']),
'secteur' => @trim($tabZones['SECTEUR']),
'cleRoutage' => @trim($tabZones['CLER']),
'cpx' => @trim($tabZones['CPX']),
'cleAd' => @trim($tabZones['CLEAD']),
'codPaysIso2' => @trim($tabZones['NATREFISO2']),
'codPaysIso3' => @trim($tabZones['NATREFISO3']),
'libPays' => @trim($tabZones['NATREFLIB']),
'codeInsee' => @trim($tabZones['LOCREFCLEO']),
'source' => 'Amabis',
);
$dateInsert=0;
if ($majForcee) {
$adresseL=addslashes($adresse);
$villeL=addslashes($ville);
$ret=$iDb->select('zonage', 'dateInsert*1 as dateInsert', "address='$adresseL' AND adr_cp='$cp' AND adr_ville='$villeL'", false);
$dateInsert=@$ret[0]['dateInsert']*1;
$iDb->update('zonage', array_merge($tabUpdate,array('dateInsert'=>$dateInsert)), "address='$adresseL' AND adr_cp='$cp' AND adr_ville='$villeL'", false);
//echo "Mise à jour de l'adresse du $dateInsert pour address='$adresseL' AND adr_cp='$cp' AND adr_ville='$villeL'".EOL;
}
if ($dateInsert==0) {
$iDb->insert('zonage', array_merge($tabInsert,$tabUpdate), false);
//echo "Insertion de l'adresse (".$zones['rnvpStatut'].")!".EOL;
}
$tabTmp[0]=explode(',', $tabZones['LOCREFCLEP']);
$tabTmp[1]=explode(',', $tabZones['LOCREFCP']);
$tabTmp[2]=explode(',', $tabZones['LOCREFTYPP']);
$tabTmp[3]=explode(',', $tabZones['LOCREFLIBD']);
$tabTmp[4]=explode(',', $tabZones['LOCREFLIBD2']);
foreach($tabTmp[0] as $iCleP=>$cleP) {
$tabInsert=array(
'codeInsee' => @trim($tabZones['LOCREFCLEO']),
'villeLib' => @trim($tabZones['LOCREFLIBP']),
'villePopu' => @trim($tabZones['LOCREFPOP']),
'cleAchPost'=> $cleP,
'codePostal'=> $tabTmp[1][$iCleP],
'typePostal'=> $tabTmp[2][$iCleP],
'libAchP32' => @preg_replace('/^\//','',$tabTmp[3][$iCleP]),
'libAchP38' => @preg_replace('/^\//','',$tabTmp[4][$iCleP]),
'source' => 'Amabis',
'dateInsert'=> date('YmdHis'),
);
$iDb->insert('villesCP', $tabInsert);
//echo mysql_error().EOL;
}
/** Autres Informations de la RNVP
**/
if ($rnvp || $debug) {
$tabRepTmp=array();
$tabZones=explode(',',$rep['objdesc']);
foreach ($tabZones as $zone) {
$tabTmp=explode('=',$zone);
if (trim($tabTmp[0])<>'')
$tabRepTmp[$tabTmp[0]]=$tabTmp[1];
}
if (!$debug) {
$tabRep['ADR1']=@$tabRepTmp['ADR1'];
$tabRep['ADR2']=@$tabRepTmp['ADR2'];
$tabRep['ADR3']=@$tabRepTmp['ADR3'];
$tabRep['ADR4']=@$tabRepTmp['ADR4'];
$tabRep['ADR5']=@$tabRepTmp['ADR5'];
$tabRep['ADR6']=@$tabRepTmp['ADR6'];
$tabRep['ADR7']=@$tabRepTmp['ADR7'];
} else {
$tabRep=array_merge($tabRep, $tabRepTmp);
}
if ($rnvp) {
//$tabRep['ADR1']=@trim($tabZones['ADR1']);
//$tabRep['ADR2']=@trim($tabZones['ADR2']);
$tabRep['ADR3']=@trim($tabZones['ADR3']);
$tabRep['ADR4']=@trim($tabZones['ADR4']);
$tabRep['ADR5']=@trim($tabZones['ADR5']);
$tabRep['ADR6']=@trim($tabZones['ADR6']);
$tabRep['ADR7']=trim($tabZones['ADR7']);
}
} catch (SoapFault $fault) {
echo 'ERREUR SOAP :'.EOL;
print_r($fault);
echo $this->client->__getLastRequest()."\n";
echo $this->client->__getLastResponse()."\n";
//echo 'ERREUR SOAP :'.EOL;
//print_r($fault);
//echo $this->client->__getLastRequest()."\n";
//echo $this->client->__getLastResponse()."\n";
$fp=fopen(LOG_PATH.'/amabis.log', 'a');
fwrite($fp, date('d-m-Y H:i:s').' - ERREUR SOAP : Requete = '.$this->client->__getLastRequest()."\n Reponse = ".$this->client->__getLastResponse()."\n============================================================================\n");
fclose($fp);
}
//return $tabRep;
}
/** Zonages AFR et ZRR
**/
$codeInsee=substr($codeRivoli,0,5);
$ret=$iDb->select( 'zonageInsee', 'typeZone, arreteDate, decretDate, decretNum, decretModifieDate, decretModifieNum, dateDebut, dateFin', "codeInsee='$codeInsee'",false, MYSQL_ASSOC);
$tabRep['ZRR']=$tabRep['AFR']='NON';

View File

@ -115,6 +115,9 @@ class MLiens2
}
}
//Don't display deleted - anomaly
$sql->where('l.dateSuppr=?', '0000-00-00 00:00:00');
$liens = $this->db->fetchAll($sql, null, Zend_Db::FETCH_OBJ);
} catch (Zend_Db_Exception $e) {
throw new Exception(__METHOD__ . ': ' . $e->getMessage());
@ -171,6 +174,9 @@ class MLiens2
}
}
//Don't display deleted - anomaly
$sql->where('l.dateSuppr=?', '0000-00-00 00:00:00');
$liens = $this->db->fetchAll($sql, null, Zend_Db::FETCH_OBJ);
} catch (Zend_Db_Exception $e) {
throw new Exception(__METHOD__ . ': ' . $e->getMessage());

View File

@ -1,3 +1,17 @@
Problème à debugger
===================
Version 411 :
FRANCHISE AMO ET SOFT
Commentaires
Faire disparaitre <BLOC>
Code 34810 supprimé espace sur ' {NOMEN}'
Code 9995 ajouté fin de balise </I>
Code 396000, ligne 20 : apostrophe
Code 740160, ligne 10 : apostrophe sur "les frais d'établissement"
Code 770061, ligne 10 : apostrophe sur "la durée moyenne d'extinction"
Code 770221, ligne : apostrophe sur "l'article"
Code 770222, ligne : apostrophe sur "l'article"
Amélioration des scores
=======================

View File

@ -23,7 +23,7 @@ $tabCommentaires[8021][2][10] = "L'avis de Dissolution anticipée de la Sociét
$tabCommentaires[8101][2][10] = "<BR>{\"NOMEN\"} fait partie des 2000 plus grosses entreprises Françaises. La complexité de la structure du groupe limite la portée de l'analyse des Forces & Faiblesses de cette seule entité. L'analyse complète est désactivée mais nous conservons les tableaux synthétiques.";
$tabCommentaires[8102][2][10] = "<BR>{\"NOMEN\"} fait partie des 2000 plus grosses entreprises Françaises. La complexité de la structure du groupe limite la portée de l'analyse des Forces & Faiblesses de cette seule entité. L'analyse complète est désactivée mais nous conservons les tableaux synthétiques.";
$tabCommentaires[8103][2][10] = "<BR>{\"NOMEN\"} fait partie des 2000 plus grosses entreprises Françaises. La complexité de la structure du groupe limite la portée de l'analyse des Forces & Faiblesses de cette seule entité. L'analyse complète est désactivée mais nous conservons les tableaux synthétiques.";
$tabCommentaires[9995][2][1] = "L'objet social publié dans les annonces légales est libellé comme : <I>\"{ANNONCEOBJET}\".
$tabCommentaires[9995][2][1] = "L'objet social publié dans les annonces légales est libellé comme : <I>\"{ANNONCEOBJET}\"</I>.
";
$tabCommentaires[9996][2][1] = "Au répertoire national l'activité est codifiée {APEENT(5)}, ({APEENT}).
";
@ -71,7 +71,7 @@ $tabCommentaires[31070][2][0] = "Les activités principales des établissements
$tabCommentaires[34800][2][10] = "\" {NOMEN}\" est identifiée avec le n° SIREN: {SIREN}, son siège n'a pas changé d'adresse depuis sa création.";
$tabCommentaires[34801][2][10] = "\" {NOMEN}\" est identifiée avec le n° SIREN: {SIREN}, son siège a déjà changé d'adresse depuis sa création mais il est revenu à son adresse d'origine.";
$tabCommentaires[34802][2][10] = "\" {NOMEN}\" est identifiée avec le n° SIREN: {SIREN}, son siège, n'a pas changé d'adresse depuis sa création. Les opérations de fusions intervenues peuvent masquer d'éventuels changements d'adresse des sociétés absorbées.";
$tabCommentaires[34810][2][10] = "\" {NOMEN}\" est identifiée avec le n° SIREN: {SIREN}, son siège a déjà changé d'adresse depuis sa création.";
$tabCommentaires[34810][2][10] = "\"{NOMEN}\" est identifiée avec le n° SIREN: {SIREN}, son siège a déjà changé d'adresse depuis sa création.";
$tabCommentaires[34819][2][10] = "\" {NOMEN}\" est identifiée avec le n° SIREN: {SIREN}.";
$tabCommentaires[34820][2][10] = "Elle est aussi répertoriée au Registre des Intermédiaires en Assurance (ORIAS) avec le N° {ORIASID}, comme {ORIASCAT}.";
$tabCommentaires[34830][2][10] = "Elle est aussi répertoriée au Registre des Intermédiaires en Assurance (ORIAS) avec le N° {ORIASID}.";
@ -1035,7 +1035,7 @@ $tabCommentaires[770040][2][10] = "<TR CLASS=\"NORMAL\"><TD>Annuité/recettes
$tabCommentaires[770050][2][10] = "<TR CLASS=\"NORMAL\"><TD>Ratio de surendettement (en-cours de la dette/produits de fonctionnement) </TD><TD>{RQ[829]} </TD><TD><I></I> </TD> </TR>";
$tabCommentaires[770051][2][10] = "<TR CLASS=\"NORMAL\"><TD>Ratio de surendettement (en-cours de la dette/produits de fonctionnement) </TD><TD>{RQ[829]} </TD><TD><I>Indique les marges de manœuvre pour les années à venir. Le seuil d'alerte est à 121 %</I> </TD> </TR>";
$tabCommentaires[770060][2][10] = "<TR CLASS=\"NORMAL\"><TD>Durée d'extinction de la dette (dette/épargne brute) </TD><TD>{R[869]} </TD><TD><I> </I> </TD> </TR>";
$tabCommentaires[770061][2][10] = "<TR CLASS=\"NORMAL\"><TD>Durée d'extinction de la dette (dette/épargne brute) </TD><TD>{R[869]} </TD><TD><I> Pour les communes de plus de 10 000 hab , la durée moyenne d'extinction de la dette est de 5,8 années.</I> </TD> </TR>";
$tabCommentaires[770061][2][10] = "<TR   CLASS=\"NORMAL\"><TD>Durée d'extinction de la dette (dette/épargne brute) </TD><TD>{R[869]} </TD><TD><I> Pour les communes de plus de 10 000 hab , la durée moyenne d'extinction de la dette est de 5,8 années.</I> </TD> </TR>";
$tabCommentaires[770100][2][0] = "<H4>Analyse des charges";
$tabCommentaires[770100][2][1] = "<TABLE CLASS=\"TABLEAUSIMPLEDROITE\" id=\"ANACHARGES\">";
$tabCommentaires[770100][2][2] = "<TR CLASS=\"TITRES\"> <TH>année {COLLANNEE} </TH><TH>Ratio </TH><TH>Observations </TH></TR>";

View File

@ -1,226 +1,227 @@
<?php
/** Ratios pour les collectivités **/
global $tabZones2Ratios;
/** Tableau de conversion des communes **/
$tabZones2Ratios=array(
'R01a'=>'R[801]',
'R01b'=>'Rh[801]',
'R01c'=>'Rs[801]',
'R02a'=>'R[802]',
'R02b'=>'Rh[802]',
'R02c'=>'Rs[802]',
'R02d'=>'Rq[802]',
'R02e'=>'Rt[802]',
'R03a'=>'R[803]',
'R03b'=>'Rh[803]',
'R03c'=>'Rs[803]',
'R03d'=>'Rq[803]',
'R03e'=>'Rt[803]',
'R04a'=>'R[804]',
'R04b'=>'Rh[804]',
'R04c'=>'Rs[804]',
'R04d'=>'Rq[804]',
'R04e'=>'Rt[804]',
'R05a'=>'R[805]',
'R05b'=>'Rh[805]',
'R05c'=>'Rs[805]',
'R06a'=>'R[806]',
'R06b'=>'Rh[806]',
'R06c'=>'Rs[806]',
'R06d'=>'Rq[806]',
'R06e'=>'Rt[806]',
'R07a'=>'R[807]',
'R07b'=>'Rh[807]',
'R07c'=>'Rs[807]',
'R07d'=>'Rq[807]',
'R07e'=>'Rt[807]',
'R08a'=>'R[808]',
'R08b'=>'Rh[808]',
'R08c'=>'Rs[808]',
'R08d'=>'Rq[808]',
'R08e'=>'Rt[808]',
'R09a'=>'R[809]',
'R09b'=>'Rh[809]',
'R09c'=>'Rs[809]',
'R09d'=>'Rq[809]',
'R09e'=>'Rt[809]',
'R10a'=>'R[810]',
'R10b'=>'Rh[810]',
'R10c'=>'Rs[810]',
'R10d'=>'Rq[810]',
'R10e'=>'Rt[810]',
'R11a'=>'R[811]',
'R11b'=>'Rh[811]',
'R11c'=>'Rs[811]',
'R12a'=>'R[812]',
'R12b'=>'Rh[812]',
'R12c'=>'Rs[812]',
'R13a'=>'R[813]',
'R13b'=>'Rh[813]',
'R13c'=>'Rs[813]',
'R13d'=>'Rq[813]',
'R13e'=>'Rt[813]',
'R14a'=>'R[814]',
'R14b'=>'Rh[814]',
'R14c'=>'Rs[814]',
'R14d'=>'Rq[814]',
'R14e'=>'Rt[814]',
'R15a'=>'R[815]',
'R15b'=>'Rh[815]',
'R15c'=>'Rs[815]',
'R15d'=>'Rq[815]',
'R15e'=>'Rt[815]',
'R16a'=>'R[816]',
'R16b'=>'Rh[816]',
'R16c'=>'Rs[816]',
'R16d'=>'Rq[816]',
'R16e'=>'Rt[816]',
'R17a'=>'R[817]',
'R17b'=>'Rh[817]',
'R17c'=>'Rs[817]',
'R18a'=>'R[818]',
'R18b'=>'Rh[818]',
'R18c'=>'Rs[818]',
'R18d'=>'Rq[818]',
'R18e'=>'Rt[818]',
'R19a'=>'R[819]',
'R19b'=>'Rh[819]',
'R19c'=>'Rs[819]',
'R19d'=>'Rq[819]',
'R19e'=>'Rt[819]',
'R20a'=>'R[820]',
'R20b'=>'Rh[820]',
'R20c'=>'Rs[820]',
'R20d'=>'Rq[820]',
'R20e'=>'Rt[820]',
'R21a'=>'R[821]',
'R21b'=>'Rh[821]',
'R21c'=>'Rs[821]',
'R21d'=>'Rq[821]',
'R21e'=>'Rt[821]',
'R22a'=>'R[822]',
'R22b'=>'Rh[822]',
'R22c'=>'Rs[822]',
'R23a'=>'R[823]',
'R23b'=>'Rh[823]',
'R23c'=>'Rs[823]',
'R24a'=>'R[824]',
'R24b'=>'Rh[824]',
'R24c'=>'Rs[824]',
'R25a'=>'R[825]',
'R25b'=>'Rh[825]',
'R25c'=>'Rs[825]',
'R26a'=>'R[826]',
'R26b'=>'Rh[826]',
'R26c'=>'Rs[826]',
'R26d'=>'Rq[826]',
'R26e'=>'Rt[826]',
'R27a'=>'R[827]',
'R27b'=>'Rh[827]',
'R27c'=>'Rs[827]',
'R27d'=>'Rq[827]',
'R27e'=>'Rt[827]',
'R28a'=>'R[828]',
'R28b'=>'Rh[828]',
'R28c'=>'Rs[828]',
'R28d'=>'Rq[828]',
'R28e'=>'Rt[828]',
'R29a'=>'R[829]',
'R29b'=>'Rh[829]',
'R29c'=>'Rs[829]',
'R29d'=>'Rq[829]',
'R29e'=>'Rt[829]',
'R30a'=>'R[830]',
'R30b'=>'Rh[830]',
'R30c'=>'Rs[830]',
'R30d'=>'Rq[830]',
'R30e'=>'Rt[830]',
'R31a'=>'R[843]',
'R31b'=>'Rh[843]',
'R31c'=>'Rs[843]',
'R31d'=>'Rq[843]',
'R31e'=>'Rt[843]',
'R32a'=>'R[831]',
'R32b'=>'Rh[831]',
'R32c'=>'Rs[831]',
'R33a'=>'R[832]',
'R33b'=>'Rh[832]',
'R33c'=>'Rs[832]',
'R33d'=>'R[845]',
'R33e'=>'Rh[845]',
'R33f'=>'Rs[845]',
'R34a'=>'R[833]',
'R34b'=>'Rh[833]',
'R34c'=>'Rs[833]',
'R34d'=>'R[846]',
'R34e'=>'Rh[846]',
'R34f'=>'Rs[846]',
'R35a'=>'R[834]',
'R35b'=>'Rh[834]',
'R35c'=>'Rs[834]',
'R35d'=>'R[847]',
'R35e'=>'Rh[847]',
'R35f'=>'Rs[847]',
'R36a'=>'R[835]',
'R36b'=>'Rh[835]',
'R36c'=>'Rs[835]',
'R36d'=>'R[849]',
'R36e'=>'Rh[849]',
'R36f'=>'Rs[849]',
'R37a'=>'R[844]',
'R37b'=>'Rh[844]',
'R37c'=>'Rs[844]',
'R37d'=>'R[848]',
'R37e'=>'Rh[848]',
'R37f'=>'Rs[848]',
'R38a'=>'R[836]',
'R38b'=>'Rh[836]',
'R38c'=>'Rs[836]',
'R38d'=>'Rq[836]',
'R38e'=>'Rt[836]',
'R39a'=>'R[837]',
'R39b'=>'Rh[837]',
'R39c'=>'Rs[837]',
'R39d'=>'Rq[837]',
'R39e'=>'Rt[837]',
'R40a'=>'R[838]',
'R40b'=>'Rh[838]',
'R40c'=>'Rs[838]',
'R40d'=>'Rq[838]',
'R40e'=>'Rt[838]',
'R41a'=>'R[842]',
'R41b'=>'Rh[842]',
'R41c'=>'Rs[842]',
'R41d'=>'Rq[842]',
'R41e'=>'Rt[842]',
'R42a'=>'R[839]',
'R42b'=>'Rh[839]',
'R42c'=>'Rs[839]',
'R42d'=>'Rq[839]',
'R42e'=>'Rt[839]',
'R43a'=>'R[840]',
'R43b'=>'Rh[840]',
'R43c'=>'Rs[840]',
'R43d'=>'Rq[840]',
'R43e'=>'Rt[840]',
'R44a'=>'R[841]',
'R44b'=>'Rh[841]',
'R44c'=>'Rs[841]',
);
/** Conversion des zones pour les collectivités **/
function convertZones($codeR, $zonesDB) {
global $tabZones2Ratios;
foreach($tabZones2Ratios as $oldR=>$newR) {
if (preg_match('/(\D+)\[(\d+)\]/Uis', $newR, $matches) && $matches[1]==$codeR) {
$iRatio=$matches[2];
if ($codeR=='R')
$ret[$iRatio]=$zonesDB[$oldR]*1000;
else
$ret[$iRatio]=$zonesDB[$oldR];
}
}
return $ret;
}
?>
<?
/** Ratios pour les collectivités **/
global $tabZones2Ratios;
/** Tableau de conversion des communes **/
$tabZones2Ratios=array(
'R01a'=>'R[801]',
'R01b'=>'Rh[801]',
'R01c'=>'Rs[801]',
'R02a'=>'R[802]',
'R02b'=>'Rh[802]',
'R02c'=>'Rs[802]',
'R02d'=>'Rq[802]',
'R02e'=>'Rt[802]',
'R03a'=>'R[803]',
'R03b'=>'Rh[803]',
'R03c'=>'Rs[803]',
'R03d'=>'Rq[803]',
'R03e'=>'Rt[803]',
'R04a'=>'R[804]',
'R04b'=>'Rh[804]',
'R04c'=>'Rs[804]',
'R04d'=>'Rq[804]',
'R04e'=>'Rt[804]',
'R05a'=>'R[805]',
'R05b'=>'Rh[805]',
'R05c'=>'Rs[805]',
'R06a'=>'R[806]',
'R06b'=>'Rh[806]',
'R06c'=>'Rs[806]',
'R06d'=>'Rq[806]',
'R06e'=>'Rt[806]',
'R07a'=>'R[807]',
'R07b'=>'Rh[807]',
'R07c'=>'Rs[807]',
'R07d'=>'Rq[807]',
'R07e'=>'Rt[807]',
'R08a'=>'R[808]',
'R08b'=>'Rh[808]',
'R08c'=>'Rs[808]',
'R08d'=>'Rq[808]',
'R08e'=>'Rt[808]',
'R09a'=>'R[809]',
'R09b'=>'Rh[809]',
'R09c'=>'Rs[809]',
'R09d'=>'Rq[809]',
'R09e'=>'Rt[809]',
'R10a'=>'R[810]',
'R10b'=>'Rh[810]',
'R10c'=>'Rs[810]',
'R10d'=>'Rq[810]',
'R10e'=>'Rt[810]',
'R11a'=>'R[811]',
'R11b'=>'Rh[811]',
'R11c'=>'Rs[811]',
'R12a'=>'R[812]',
'R12b'=>'Rh[812]',
'R12c'=>'Rs[812]',
'R13a'=>'R[813]',
'R13b'=>'Rh[813]',
'R13c'=>'Rs[813]',
'R13d'=>'Rq[813]',
'R13e'=>'Rt[813]',
'R14a'=>'R[814]',
'R14b'=>'Rh[814]',
'R14c'=>'Rs[814]',
'R14d'=>'Rq[814]',
'R14e'=>'Rt[814]',
'R15a'=>'R[815]',
'R15b'=>'Rh[815]',
'R15c'=>'Rs[815]',
'R15d'=>'Rq[815]',
'R15e'=>'Rt[815]',
'R16a'=>'R[816]',
'R16b'=>'Rh[816]',
'R16c'=>'Rs[816]',
'R16d'=>'Rq[816]',
'R16e'=>'Rt[816]',
'R17a'=>'R[817]',
'R17b'=>'Rh[817]',
'R17c'=>'Rs[817]',
'R18a'=>'R[818]',
'R18b'=>'Rh[818]',
'R18c'=>'Rs[818]',
'R18d'=>'Rq[818]',
'R18e'=>'Rt[818]',
'R19a'=>'R[819]',
'R19b'=>'Rh[819]',
'R19c'=>'Rs[819]',
'R19d'=>'Rq[819]',
'R19e'=>'Rt[819]',
'R20a'=>'R[820]',
'R20b'=>'Rh[820]',
'R20c'=>'Rs[820]',
'R20d'=>'Rq[820]',
'R20e'=>'Rt[820]',
'R21a'=>'R[821]',
'R21b'=>'Rh[821]',
'R21c'=>'Rs[821]',
'R21d'=>'Rq[821]',
'R21e'=>'Rt[821]',
'R22a'=>'R[822]',
'R22b'=>'Rh[822]',
'R22c'=>'Rs[822]',
'R23a'=>'R[823]',
'R23b'=>'Rh[823]',
'R23c'=>'Rs[823]',
'R24a'=>'R[824]',
'R24b'=>'Rh[824]',
'R24c'=>'Rs[824]',
'R25a'=>'R[825]',
'R25b'=>'Rh[825]',
'R25c'=>'Rs[825]',
'R26a'=>'R[826]',
'R26b'=>'Rh[826]',
'R26c'=>'Rs[826]',
'R26d'=>'Rq[826]',
'R26e'=>'Rt[826]',
'R27a'=>'R[827]',
'R27b'=>'Rh[827]',
'R27c'=>'Rs[827]',
'R27d'=>'Rq[827]',
'R27e'=>'Rt[827]',
'R28a'=>'R[828]',
'R28b'=>'Rh[828]',
'R28c'=>'Rs[828]',
'R28d'=>'Rq[828]',
'R28e'=>'Rt[828]',
'R29a'=>'R[829]',
'R29b'=>'Rh[829]',
'R29c'=>'Rs[829]',
'R29d'=>'Rq[829]',
'R29e'=>'Rt[829]',
'R30a'=>'R[830]',
'R30b'=>'Rh[830]',
'R30c'=>'Rs[830]',
'R30d'=>'Rq[830]',
'R30e'=>'Rt[830]',
'R31a'=>'R[843]',
'R31b'=>'Rh[843]',
'R31c'=>'Rs[843]',
'R31d'=>'Rq[843]',
'R31e'=>'Rt[843]',
'R32a'=>'R[831]',
'R32b'=>'Rh[831]',
'R32c'=>'Rs[831]',
'R33a'=>'R[832]',
'R33b'=>'Rh[832]',
'R33c'=>'Rs[832]',
'R33d'=>'R[845]',
'R33e'=>'Rh[845]',
'R33f'=>'Rs[845]',
'R34a'=>'R[833]',
'R34b'=>'Rh[833]',
'R34c'=>'Rs[833]',
'R34d'=>'R[846]',
'R34e'=>'Rh[846]',
'R34f'=>'Rs[846]',
'R35a'=>'R[834]',
'R35b'=>'Rh[834]',
'R35c'=>'Rs[834]',
'R35d'=>'R[847]',
'R35e'=>'Rh[847]',
'R35f'=>'Rs[847]',
'R36a'=>'R[835]',
'R36b'=>'Rh[835]',
'R36c'=>'Rs[835]',
'R36d'=>'R[849]',
'R36e'=>'Rh[849]',
'R36f'=>'Rs[849]',
'R37a'=>'R[844]',
'R37b'=>'Rh[844]',
'R37c'=>'Rs[844]',
'R37d'=>'R[848]',
'R37e'=>'Rh[848]',
'R37f'=>'Rs[848]',
'R38a'=>'R[836]',
'R38b'=>'Rh[836]',
'R38c'=>'Rs[836]',
'R38d'=>'Rq[836]',
'R38e'=>'Rt[836]',
'R39a'=>'R[837]',
'R39b'=>'Rh[837]',
'R39c'=>'Rs[837]',
'R39d'=>'Rq[837]',
'R39e'=>'Rt[837]',
'R40a'=>'R[838]',
'R40b'=>'Rh[838]',
'R40c'=>'Rs[838]',
'R40d'=>'Rq[838]',
'R40e'=>'Rt[838]',
'R41a'=>'R[842]',
'R41b'=>'Rh[842]',
'R41c'=>'Rs[842]',
'R41d'=>'Rq[842]',
'R41e'=>'Rt[842]',
'R42a'=>'R[839]',
'R42b'=>'Rh[839]',
'R42c'=>'Rs[839]',
'R42d'=>'Rq[839]',
'R42e'=>'Rt[839]',
'R43a'=>'R[840]',
'R43b'=>'Rh[840]',
'R43c'=>'Rs[840]',
'R43d'=>'Rq[840]',
'R43e'=>'Rt[840]',
'R44a'=>'R[841]',
'R44b'=>'Rh[841]',
'R44c'=>'Rs[841]',
);
/** Conversion des zones pour les collectivités **/
function convertZones($codeR, $zonesDB) {
global $tabZones2Ratios;
foreach($tabZones2Ratios as $oldR=>$newR) {
if (preg_match('/(\D+)\[(\d+)\]/Uis', $newR, $matches) && $matches[1]==$codeR) {
$iRatio=$matches[2];
if ($codeR=='R')
$ret[$iRatio]=$zonesDB[$oldR]*1000;
else
$ret[$iRatio]=$zonesDB[$oldR];
}
}
return $ret;
}
?>

View File

@ -8,6 +8,8 @@ require_once 'Metier/scores/classMRegression.php';
require_once 'Metier/partenaires/classMLiens2.php';
require_once 'Metier/scores/classMSolvabilite.php';
require_once 'Metier/scores/Variables/configMRatios.php';
define('INDISCORE_DEBUG', false);
@ -254,7 +256,7 @@ function formatValeur($variable, $longeur=0, $fonction='')
return $variable;
} else {
if ($nomVar=='ZEMET') {
$strTmp=eval("return $valeur;");
global $RPEN;
if (isset($tabVariables['ZEMET'][$RPEN.$ZEMET]['art']))
return $tabVariables['ZEMET'][$RPEN.$ZEMET]['art'];
else
@ -637,7 +639,7 @@ function calculIndiScore($siren, $nic=0, $accesDist=false, $cycleClient=2, $mail
$tabCommentaires = $tabTri = $tabTriAff = array();
switch( $type ) {
case 'scores':
$version = '405';
$version = '411';
require_once 'Metier/scores/Variables/CommentsIndiscore'.$version.'.php';
break;
case 'valo':
@ -826,11 +828,11 @@ function calculIndiScore($siren, $nic=0, $accesDist=false, $cycleClient=2, $mail
$SOCIETE_COTE_ISIN=$tabIdentite['Isin'];
if ($SOCIETE_COTE_ISIN<>'') {
$SOCIETE_COTE=true;
$SOCIETE_COTE_PLACE=$tabRet['Bourse']['placeCotation'];
$SOCIETE_COTE_MARCHE=$tabRet['Bourse']['marche'];
$SOCIETE_COTE_CAPITALISATION=$tabRet['Bourse']['capitalisation']; // Afficher en KE
$SOCIETE_COTE_COURS=$tabRet['Bourse']['derCoursCloture'];
$SOCIETE_COTE_COURS_DATE=$tabRet['Bourse']['derCoursDate'];
$SOCIETE_COTE_PLACE=$tabIdentite['Bourse']['placeCotation'];
$SOCIETE_COTE_MARCHE=$tabIdentite['Bourse']['marche'];
$SOCIETE_COTE_CAPITALISATION=$tabIdentite['Bourse']['capitalisation']; // Afficher en KE
$SOCIETE_COTE_COURS=$tabIdentite['Bourse']['derCoursCloture'];
$SOCIETE_COTE_COURS_DATE=$tabIdentite['Bourse']['derCoursDate'];
$SOCIETE_COTE_COURS_MIN=0;//@todo:$tabRet['Bourse']['derCoursDate'];
$SOCIETE_COTE_COURS_MAX=0;//@todo:$tabRet['Bourse']['derCoursDate'];
}
@ -2981,7 +2983,7 @@ function calculIndiScore($siren, $nic=0, $accesDist=false, $cycleClient=2, $mail
|| $tabIdentite['SituationJuridique'] == 'P'
|| $tabIdentite['SituationJuridique'] == 'PL')
$classeRisque=9;
elseif ($ENCOURS=='N/A') $classeRisque=8;
elseif ($ENCOURS==='N/A') $classeRisque=8;
/** Fin note **/
$NOTE100=$noteSolvabilite; // Note finale sur 100

View File

@ -657,7 +657,7 @@ function clientSphinx(&$formR)
require_once 'Vendors/sphinxapi/sphinxapi-0.9.9.php';
break;
case 2:
require_once 'Vendors/sphinxapi/sphinxapi-2.1.2.php';
require_once 'Vendors/sphinxapi/sphinxapi-2.1.5.php';
break;
}
@ -770,6 +770,8 @@ function reponse(&$resSphinx, &$resDB, $criteres, $time, $formR, $form2crit,
}
}
$ret['reponses'][$i]['Pertinence'] = $pertinence;
$ret['reponses'][$i]['Source'] = $ligne['source'];
$ret['reponses'][$i]['SourceId'] = $ligne['source_id'];
$ret['reponses'][$i]['Siret'] = $ligne['siret'];
$ret['reponses'][$i]['Siren'] = $ligne['siren'];
$ret['reponses'][$i]['Nic'] = $ligne['nic'];
@ -784,11 +786,11 @@ function reponse(&$resSphinx, &$resDB, $criteres, $time, $formR, $form2crit,
} else {
$adresse = $ligne['adr_num'].' '.$ligne['adr_typeVoie'].' '.$ligne['adr_libVoie'];
}
$ret['reponses'][$i]['Adresse'] = $adresse;
$ret['reponses'][$i]['Adresse'] = $adresse;
$ret['reponses'][$i]['Adresse2'] = $ligne['adr_comp'];
$ret['reponses'][$i]['CP'] = $ligne['adr_cp'];
$ret['reponses'][$i]['Ville'] = $ligne['adr_ville'];
$ret['reponses'][$i]['Pays'] = $ligne['pays'];
$ret['reponses'][$i]['Pays'] = empty($ligne['pays']) ? 'France' : $ligne['pays'] ;
$ret['reponses'][$i]['Tel'] = $ligne['tel'];
$ret['reponses'][$i]['Fax'] = $ligne['fax'];
$ret['reponses'][$i]['FJ'] = $ligne['cj'];
@ -955,6 +957,8 @@ function rechercheDir(&$formR, $deb, $nbRep, $max)
d.naissance_lieu,
l.libelle AS fonction_lib,
e.id, CONCAT(e.siren,e.nic) AS siret,
e.source,
e.source_id,
e.siren,
e.nic,
e.siege,
@ -1596,7 +1600,7 @@ function rechercheEnt(&$formR, $deb, $nbRep, $max, $sirenValide = false)
afficheDB($resSphinx, $formR, $form2crit, 'etablissements', $base2form, $deb, $nbRep);
}
//file_put_contents('test.log', print_r($resSphinx,1));
//file_put_contents('test.log', print_r($resSphinx,1));
// Reponse
if ($gDatabaseJO == false) {
@ -1615,6 +1619,8 @@ function rechercheEnt(&$formR, $deb, $nbRep, $max, $sirenValide = false)
}
$requeteDB = 'SELECT
id,
source,
source_id,
CONCAT(siren,nic) AS siret,
siren,
nic,
@ -1648,6 +1654,8 @@ function rechercheEnt(&$formR, $deb, $nbRep, $max, $sirenValide = false)
$requeteDB.= ') ORDER BY sirenValide DESC, actif DESC, siege DESC, rang DESC';
//file_put_contents('test.log', $requeteDB);
debugln();
debugln("requeteDB='$requeteDB'");
$resDB = $gDatabaseJO->query($requeteDB);

View File

@ -1,93 +1,122 @@
<?php
class WDB
{
/**
* @var Zend_Db_Adapter_Abstract
*/
protected $db = null;
class WDB {
/**
*
* @var unknown
*/
protected $result = null;
private $host;
private $database;
private $user;
private $password;
private $con_id; // Connection ID with MySQL
private $result;
protected $errorCode;
public function __construct($database='', $host='', $user='', $password='') {
protected $errorMsg;
if ($host=='') $this->host=MYSQL_HOST;
else $this->host=$host;
if ($user=='') $this->user=MYSQL_USER;
else $this->user=$user;
if ($password=='') $this->password=MYSQL_PASS;
else $this->password=$password;
if ($database=='') $this->database=MYSQL_DEFAULT_DB;
else $this->database=$database;
public function __construct( $database = null, $host = null, $user = null, $password = null )
{
if ( $database === null ) {
$database = 'jo';
}
//if (defined(MYSQL_PORT)) $this->host = $this->host.':'.MYSQL_PORT;
$this->host = $this->host.':53336';
if ( $host === null ) {
$c = Zend_Registry::get('config');
$config = new Zend_Config(array(
'adapter' => $c->profil->db->metier->adapter,
'params' => array(
'host' => $c->profil->db->metier->params->host,
'username'=> $c->profil->db->metier->params->username,
'password'=> $c->profil->db->metier->params->password,
'dbname'=> $database,
'driver_options' => array(
MYSQLI_INIT_COMMAND => "SET NAMES utf8",
),
),
));
//Server is far away try to compress data
$flags = MYSQL_CLIENT_COMPRESS;
} else {
$config = new Zend_Config(array(
'adapter' => 'mysqli',
'params' => array(
'host' => $host,
'username'=> $user,
'password'=> $password,
'dbname'=> $database,
'driver_options' => array(
MYSQLI_INIT_COMMAND => "SET NAMES utf8",
),
),
));
}
$this->con_id = mysql_connect($this->host, $this->user, $this->password, false, $flags);
if (!($this->con_id === false)) {
if (mysql_select_db($this->database, $this->con_id) === false) {
echo date('Y/m/d - H:i:s') ." - ERREUR ".mysql_errno()." : Connection à la base de données impossible !".EOL;
echo date ('Y/m/d - H:i:s'). mysql_error();
die();
}
}
return mysql_query("SET NAMES 'utf8';", $this->con_id);
try {
$this->db = Zend_Db::factory($config);
} catch ( Exception $e ) {
file_put_contents('debug.log', $e->getMessage()."\n", FILE_APPEND);
exit;
}
}
public function setCharSet($charSet) {
return (mysql_query("SET CHARACTER SET $charSet;", $this->con_id));
}
private function setDB() {
return (mysql_query("USE $this->database;", $this->con_id));
}
/** INSERTION d'un tableau dans une table.
** Les index doivent avoir les mêmes noms que les champs.
** @param string Table
** @param array Valeurs insérer
** @return int Dernière valeur de l'auto-incrément, 1 si pas d'auto-incrément et 0 si erreur
**/
public function insert($table, $toAdd, $debug=false, $low_priority=false){
$this->setDB();
$fields = implode(array_keys($toAdd), '`,`');
/**
* INSERTION d'un tableau dans une table.
* Les index doivent avoir les mêmes noms que les champs.
* @param string Table
* @param array Valeurs insérer
* @return int Dernière valeur de l'auto-incrément, 1 si pas d'auto-incrément et 0 si erreur
*/
public function insert($table, $toAdd, $debug=false, $low_priority=false)
{
$fields = implode(array_keys($toAdd), '`,`');
foreach (array_values($toAdd) as $key=>$array_values)
$tmp[$key]=checkaddslashes($array_values);
$values = "'".implode(array_values($tmp), "','")."'"; # better
$values = str_replace("'NULL'", 'NULL', $values);
if ($low_priority)
$query = 'INSERT DELAYED INTO `'.$table.'` (`'.$fields.'`) VALUES ('.$values.');';
else
$query = 'INSERT INTO `'.$table.'` (`'.$fields.'`) VALUES ('.$values.');';
if ($low_priority)
$query = 'INSERT DELAYED INTO `'.$table.'` (`'.$fields.'`) VALUES ('.$values.');';
else
$query = 'INSERT INTO `'.$table.'` (`'.$fields.'`) VALUES ('.$values.');';
if ($debug) $tdeb=microtime_float();
try {
$stmt = $this->db->query($query);
$res = $this->db->lastInsertId();
if ( $res == 0 ) {
$res = true;
}
} catch(Zend_Db_Exception $e) {
$res = false;
}
if ($debug) $this->trace($query, $res, $tdeb);
if ($debug) $tdeb=microtime(true);
$res = mysql_query($query, $this->con_id);
if ($res!==false)
{
if (mysql_insert_id()>0)
$res=mysql_insert_id();
else
$res=true;
}
if ($debug) $this->trace($query, $res, $tdeb);
return $res;
}
public function update($table, $update, $where, $debug=false, $limit=0, $low_priority=false){
$this->setDB();
/**
*
* @param unknown $table
* @param unknown $update
* @param unknown $where
* @param string $debug
* @param number $limit
* @param string $low_priority
* @return resource
*/
public function update($table, $update, $where, $debug=false, $limit=0, $low_priority=false)
{
$fields = array_keys($update);
$values = array_values($update);
$i=0;
if ($low_priority)
$query='UPDATE LOW_PRIORITY `'.$table.'` SET ';
else
$query='UPDATE `'.$table.'` SET ';
if ($low_priority)
$query='UPDATE LOW_PRIORITY `'.$table.'` SET ';
else
$query='UPDATE `'.$table.'` SET ';
while(isset($fields[$i])){
if($i>0) { $query.=', '; }
$query.=' `'.$fields[$i]."`='".checkaddslashes($values[$i])."'";
@ -96,116 +125,209 @@ public function update($table, $update, $where, $debug=false, $limit=0, $low_pri
$query = str_replace("'NULL'", 'NULL', $query);
$query.=' WHERE '.$where;
if ($limit>0) $query.=" LIMIT $limit";
if ($debug) $tdeb=microtime(true);
$res=mysql_query($query, $this->con_id);
if ($debug) $this->trace($query, $res, $tdeb);
if ($debug) $tdeb=microtime_float();
try {
$stmt = $this->db->query($query);
$res = $this->db->lastInsertId();
if ( $res == 0 ) {
$res = true;
}
} catch(Zend_Db_Exception $e) {
$res = false;
}
if ($debug) $this->trace($query, $res, $tdeb);
return $res;
}
public function delete($table, $where, $debug=false, $low_priority=false) {
$this->setDB();
if ($low_priority)
$query='DELETE LOW_PRIORITY QUICK FROM `'.$table.'` WHERE '.$where.' LIMIT 1;';
else
$query='DELETE FROM `'.$table.'` WHERE '.$where.' LIMIT 1;';
if ($debug) $tdeb=microtime(true);
$res=mysql_query($query, $this->con_id);
if ($debug) $this->trace($query, $res, $tdeb);
/**
*
* @param unknown $table
* @param unknown $where
* @param string $debug
* @param string $low_priority
* @return resource
*/
public function delete($table, $where, $debug=false, $low_priority=false)
{
if ($low_priority)
$query='DELETE LOW_PRIORITY QUICK FROM `'.$table.'` WHERE '.$where.' LIMIT 1;';
else
$query='DELETE FROM `'.$table.'` WHERE '.$where.' LIMIT 1;';
if ($debug) $tdeb=microtime_float();
try {
$stmt = $this->db->query($query);
$res = $this->db->lastInsertId();
if ( $res == 0 ) {
$res = true;
}
} catch(Zend_Db_Exception $e) {
$this->errorCode = $e->getCode();
$this->errorMsg = $e->getMessage();
$res = false;
}
if ($debug) $this->trace($query, $res, $tdeb);
return $res;
}
public function select($table, $fields, $where, $debug=false, $assoc=MYSQL_BOTH, $huge=false) {
$this->setDB();
if (mysql_select_db($this->database, $this->con_id) === false) {
echo date('Y/m/d - H:i:s') ." - ERREUR ".mysql_errno()." : Connection à la base de données impossible !".EOL;
echo date ('Y/m/d - H:i:s'). mysql_error();
die();
}
/**
*
* @param unknown $table
* @param unknown $fields
* @param unknown $where
* @param string $debug
* @param string $assoc
* @param string $huge
* @return boolean|multitype:multitype: |number
*/
public function select($table, $fields, $where, $debug=false, $assoc=MYSQL_BOTH, $huge=false)
{
$query="SELECT $fields FROM $table WHERE $where;";
if ($debug) $tdeb=microtime(true);
$this->result=mysql_query($query, $this->con_id);// or die(mysql_error());
if (mysql_errno()) {
$fpErr=fopen(LOG_PATH.'/sqlerror.log','a');
fwrite($fpErr, date('YmdHis'). ' - '.$query .EOL);
fwrite($fpErr, date('YmdHis'). ' - '.mysql_errno() .' - '. mysql_error().EOL);
return false;
}
// echo ;
if (!$huge) {
$tab=array();
while ($ligne = mysql_fetch_array($this->result, $assoc))
$tab[]=$ligne;
if ($debug) $this->trace($query, sizeof($tab), $tdeb);
return $tab;
if ($debug) $tdeb=microtime_float();
try {
$stmt = $this->db->query($query);
} catch(Zend_Db_Exception $e) {
$this->errorCode = $e->getCode();
$this->errorMsg = $e->getMessage();
$fpErr = fopen(LOG_PATH.'/sqlerror.log','a');
fwrite($fpErr, date('YmdHis'). ' - '.$query .EOL);
fwrite($fpErr, date('YmdHis'). ' - '.$e->getCode().' - '. $e->getMessage().PHP_EOL);
return false;
}
if ( !$huge ) {
switch($assoc) {
case MYSQL_NUM:
$mode = Zend_Db::FETCH_NUM;
break;
case MYSQL_ASSOC:
$mode = Zend_Db::FETCH_ASSOC;
break;
case MYSQL_BOTH:
$mode = Zend_Db::FETCH_BOTH;
break;
}
$tab = $stmt->fetchAll($mode);
if ($debug) $this->trace($query, sizeof($tab), $tdeb);
return $tab;
} else {
$nbRows=mysql_num_rows($this->result);
if ($debug) $this->trace($query, $nbRows, $tdeb);
return $nbRows;
$nbRows = $stmt->rowCount();
if ($debug) $this->trace($query, $nbRows, $tdeb);
return $nbRows;
}
}
public function fetch($assoc=MYSQL_BOTH) {
return mysql_fetch_array($this->result, $assoc);
/**
*
* @param string $assoc
* @return multitype:
*/
public function fetch($assoc=MYSQL_BOTH)
{
switch($assoc) {
case MYSQL_NUM:
$mode = Zend_Db::FETCH_NUM;
break;
case MYSQL_ASSOC:
$mode = Zend_Db::FETCH_ASSOC;
break;
case MYSQL_BOTH:
$mode = Zend_Db::FETCH_BOTH;
break;
}
return $this->result->fetch($mode);
}
public function trace($query, $res='', $tdeb=-1) {
/*if (!$fp=fopen(LOG_PATH.'/mysql_insert.log', 'a'))
return false;
$errnum=mysql_errno($this->con_id);
if ($tdeb>-1) $duree=substr(''.microtime(true)-$tdeb, 0, 5);
else $duree='N/D';
if (!fwrite($fp, date('Y/m/d - H:i:s') ." - $errnum - $res - $duree - $query\n"))
return false;
if (!fclose($fp))
return false;
return true;*/
/**
*
* @param unknown $query
* @param string $res
* @param unknown $tdeb
* @return boolean
*/
public function trace($query, $res='', $tdeb=-1)
{
if (!$fp=fopen(LOG_PATH.'/mysql_insert.log', 'a'))
return false;
$errnum=mysql_errno($this->con_id);
if ($tdeb>-1) $duree=substr(''.microtime_float()-$tdeb, 0, 5);
else $duree='N/D';
if (!fwrite($fp, date('Y/m/d - H:i:s') ." - $errnum - $res - $duree - $query\n"))
return false;
if (!fclose($fp))
return false;
return true;
}
/** Exécute la requête passé en paramètre **/
public function query($query, $debug=false){
$this->setDB();
$this->result=mysql_query($query, $this->con_id);
/**
* Exécute la requête passé en paramètre
*/
public function query($query, $debug=false)
{
try {
$stmt = $this->db->query($query);
$this->result = $stmt;
} catch(Zend_Db_Exception $e) {
$this->errorCode = $e->getCode();
$this->errorMsg = $e->getMessage();
return false;
}
return $this->result;
}
/** Retourne le nombre de records de la dernière requête de sélection **
public function getNumRows() {
return mysql_num_rows($this->con_id);
}
*/
/** Retourne le libellé de la dernière erreur **/
public function getLastErrorMsg() {
return mysql_error($this->con_id);
public function getLastErrorMsg()
{
return $this->errorMsg;
}
/** Retourne le numéro de la dernière erreur **/
public function getLastErrorNum() {
return mysql_errno($this->con_id);
/**
* Retourne le numéro de la dernière erreur
*/
public function getLastErrorNum()
{
return $this->errorCode;
}
/** Retourne le libellé et le numéro de la dernière erreur **/
public function getLastError() {
return mysql_error($this->con_id).' ('.mysql_errno($this->con_id).')';
public function getLastError()
{
return $this->errorMsg.' ('.$this->errorCode.')';
}
/** Retourne le nombre de lignes modifiées par la dernière requête **/
public function getAffectedRows() {
return mysql_affected_rows($this->con_id);
public function getAffectedRows()
{
return $this->result->rowCount();
}
/** Génère le fichier CSV pour la requete SQL
**
** @param string $query
** @param string $fileCsv
** @return bool
/**
* Génère le fichier CSV pour la requete SQL
*
* @param string $query
* @param string $fileCsv
* @return bool
*/
public function exportCSV($query, $fileCsv, $sep=',', $eol=EOL) {
public function exportCSV($query, $fileCsv, $sep=',', $eol=EOL)
{
$i=$c=0;
$fp = fopen($fileCsv, 'w');
if (!$fp) return false;
$res=$this->query($query);
$nbLignes=mysql_num_rows($res);
$res = $this->query($query);
$nbLignes = $res->rowCount();;
while ($ligne=$this->fetch(MYSQL_ASSOC)) {
if ($i==0) {
@ -227,8 +349,8 @@ public function delete($table, $where, $debug=false, $low_priority=false) {
$i++;
}
fclose($fp);
return $nbLignes;//$this->getAffectedRows();
}
return $nbLignes;
}
}
?>

View File

@ -1,4 +1,4 @@
<?
<?php
require_once 'framework/common/mysql.php';
require_once 'framework/common/strings.php';
//include_once(FWK_PATH.'common/dates.php');
@ -135,7 +135,7 @@
$str = utf8_decode($str);
$str = strtr($str,$tabReplace);
return utf8_encode($str);
//require_once 'i18n/cleanchar.php';
//require_once 'i18n/cleanchar.php';
//return fixEncoding($str);
}

View File

@ -1,878 +0,0 @@
<?php
/**
) o------------------------------------------------------------------------------o
* | This is HTMLMimeMail5. It is dual licensed as GPL and a commercial license. |
* | If you use the code commercially (or if you don't want to be restricted by |
* | the GPL license), you will need the commercial license. It's only £49 (GBP - |
* | roughly $98 depending on the exchange rate) and helps me out a lot. Thanks. |
* o------------------------------------------------------------------------------o
*
* © Copyright 2005 Richard Heyes
*/
/**
* RFC 822 Email address list validation Utility
*
* What is it?
*
* This class will take an address string, and parse it into it's consituent
* parts, be that either addresses, groups, or combinations. Nested groups
* are not supported. The structure it returns is pretty straight forward,
* and is similar to that provided by the imap_rfc822_parse_adrlist(). Use
* print_r() to view the structure.
*
* How do I use it?
*
* $address_string = 'My Group: "Richard Heyes" <richard@localhost> (A comment), ted@example.com (Ted Bloggs), Barney;';
* $structure = Mail_RFC822::parseAddressList($address_string, 'example.com', TRUE)
* print_r($structure);
*/
class Mail_RFC822
{
/**
* The address being parsed by the RFC822 object.
* @private string $address
*/
private $address = '';
/**
* The default domain to use for unqualified addresses.
* @private string $default_domain
*/
private $default_domain = 'localhost';
/**
* Should we return a nested array showing groups, or flatten everything?
* @private boolean $nestGroups
*/
private $nestGroups = true;
/**
* Whether or not to validate atoms for non-ascii characters.
* @private boolean $validate
*/
private $validate = true;
/**
* The array of raw addresses built up as we parse.
* @private array $addresses
*/
private $addresses = array();
/**
* The final array of parsed address information that we build up.
* @private array $structure
*/
private $structure = array();
/**
* The current error message, if any.
* @private string $error
*/
private $error = null;
/**
* An internal counter/pointer.
* @private integer $index
*/
private $index = null;
/**
* The number of groups that have been found in the address list.
* @private integer $num_groups
* @access public
*/
private $num_groups = 0;
/**
* A variable so that we can tell whether or not we're inside a
* Mail_RFC822 object.
* @private boolean $mailRFC822
*/
private $mailRFC822 = true;
/**
* A limit after which processing stops
* @private int $limit
*/
private $limit = null;
/**
* Sets up the object. The address must either be set here or when
* calling parseAddressList(). One or the other.
*
* @access public
* @param string $address The address(es) to validate.
* @param string $default_domain Default domain/host etc. If not supplied, will be set to localhost.
* @param boolean $nest_groups Whether to return the structure with groups nested for easier viewing.
* @param boolean $validate Whether to validate atoms. Turn this off if you need to run addresses through before encoding the personal names, for instance.
*
* @return object Mail_RFC822 A new Mail_RFC822 object.
*/
function __construct($address = null, $default_domain = null, $nest_groups = null, $validate = null, $limit = null)
{
if (isset($address)) $this->address = $address;
if (isset($default_domain)) $this->default_domain = $default_domain;
if (isset($nest_groups)) $this->nestGroups = $nest_groups;
if (isset($validate)) $this->validate = $validate;
if (isset($limit)) $this->limit = $limit;
}
/**
* Starts the whole process. The address must either be set here
* or when creating the object. One or the other.
*
* @access public
* @param string $address The address(es) to validate.
* @param string $default_domain Default domain/host etc.
* @param boolean $nest_groups Whether to return the structure with groups nested for easier viewing.
* @param boolean $validate Whether to validate atoms. Turn this off if you need to run addresses through before encoding the personal names, for instance.
*
* @return array A structured array of addresses.
*/
function parseAddressList($address = null, $default_domain = null, $nest_groups = null, $validate = null, $limit = null)
{
if (!isset($this->mailRFC822)) {
$obj = new Mail_RFC822($address, $default_domain, $nest_groups, $validate, $limit);
return $obj->parseAddressList();
}
if (isset($address)) $this->address = $address;
if (isset($default_domain)) $this->default_domain = $default_domain;
if (isset($nest_groups)) $this->nestGroups = $nest_groups;
if (isset($validate)) $this->validate = $validate;
if (isset($limit)) $this->limit = $limit;
$this->structure = array();
$this->addresses = array();
$this->error = null;
$this->index = null;
while ($this->address = $this->_splitAddresses($this->address)) {
continue;
}
if ($this->address === false || isset($this->error)) {
return false;
}
// Reset timer since large amounts of addresses can take a long time to
// get here
set_time_limit(30);
// Loop through all the addresses
for ($i = 0; $i < count($this->addresses); $i++){
if (($return = $this->_validateAddress($this->addresses[$i])) === false
|| isset($this->error)) {
return false;
}
if (!$this->nestGroups) {
$this->structure = array_merge($this->structure, $return);
} else {
$this->structure[] = $return;
}
}
return $this->structure;
}
/**
* Splits an address into seperate addresses.
*
* @access private
* @param string $address The addresses to split.
* @return boolean Success or failure.
*/
function _splitAddresses($address)
{
if (!empty($this->limit) AND count($this->addresses) == $this->limit) {
return '';
}
if ($this->_isGroup($address) && !isset($this->error)) {
$split_char = ';';
$is_group = true;
} elseif (!isset($this->error)) {
$split_char = ',';
$is_group = false;
} elseif (isset($this->error)) {
return false;
}
// Split the string based on the above ten or so lines.
$parts = explode($split_char, $address);
$string = $this->_splitCheck($parts, $split_char);
// If a group...
if ($is_group) {
// If $string does not contain a colon outside of
// brackets/quotes etc then something's fubar.
// First check there's a colon at all:
if (strpos($string, ':') === false) {
$this->error = 'Invalid address: ' . $string;
return false;
}
// Now check it's outside of brackets/quotes:
if (!$this->_splitCheck(explode(':', $string), ':'))
return false;
// We must have a group at this point, so increase the counter:
$this->num_groups++;
}
// $string now contains the first full address/group.
// Add to the addresses array.
$this->addresses[] = array(
'address' => trim($string),
'group' => $is_group
);
// Remove the now stored address from the initial line, the +1
// is to account for the explode character.
$address = trim(substr($address, strlen($string) + 1));
// If the next char is a comma and this was a group, then
// there are more addresses, otherwise, if there are any more
// chars, then there is another address.
if ($is_group && substr($address, 0, 1) == ','){
$address = trim(substr($address, 1));
return $address;
} elseif (strlen($address) > 0) {
return $address;
} else {
return '';
}
// If you got here then something's off
return false;
}
/**
* Checks for a group at the start of the string.
*
* @access private
* @param string $address The address to check.
* @return boolean Whether or not there is a group at the start of the string.
*/
function _isGroup($address)
{
// First comma not in quotes, angles or escaped:
$parts = explode(',', $address);
$string = $this->_splitCheck($parts, ',');
// Now we have the first address, we can reliably check for a
// group by searching for a colon that's not escaped or in
// quotes or angle brackets.
if (count($parts = explode(':', $string)) > 1) {
$string2 = $this->_splitCheck($parts, ':');
return ($string2 !== $string);
} else {
return false;
}
}
/**
* A common function that will check an exploded string.
*
* @access private
* @param array $parts The exloded string.
* @param string $char The char that was exploded on.
* @return mixed False if the string contains unclosed quotes/brackets, or the string on success.
*/
function _splitCheck($parts, $char)
{
$string = $parts[0];
for ($i = 0; $i < count($parts); $i++) {
if ($this->_hasUnclosedQuotes($string)
|| $this->_hasUnclosedBrackets($string, '<>')
|| $this->_hasUnclosedBrackets($string, '[]')
|| $this->_hasUnclosedBrackets($string, '()')
|| substr($string, -1) == '\\') {
if (isset($parts[$i + 1])) {
$string = $string . $char . $parts[$i + 1];
} else {
$this->error = 'Invalid address spec. Unclosed bracket or quotes';
return false;
}
} else {
$this->index = $i;
break;
}
}
return $string;
}
/**
* Checks if a string has an unclosed quotes or not.
*
* @access private
* @param string $string The string to check.
* @return boolean True if there are unclosed quotes inside the string, false otherwise.
*/
function _hasUnclosedQuotes($string)
{
$string = explode('"', $string);
$string_cnt = count($string);
for ($i = 0; $i < (count($string) - 1); $i++)
if (substr($string[$i], -1) == '\\')
$string_cnt--;
return ($string_cnt % 2 === 0);
}
/**
* Checks if a string has an unclosed brackets or not. IMPORTANT:
* This function handles both angle brackets and square brackets;
*
* @access private
* @param string $string The string to check.
* @param string $chars The characters to check for.
* @return boolean True if there are unclosed brackets inside the string, false otherwise.
*/
function _hasUnclosedBrackets($string, $chars)
{
$num_angle_start = substr_count($string, $chars[0]);
$num_angle_end = substr_count($string, $chars[1]);
$this->_hasUnclosedBracketsSub($string, $num_angle_start, $chars[0]);
$this->_hasUnclosedBracketsSub($string, $num_angle_end, $chars[1]);
if ($num_angle_start < $num_angle_end) {
$this->error = 'Invalid address spec. Unmatched quote or bracket (' . $chars . ')';
return false;
} else {
return ($num_angle_start > $num_angle_end);
}
}
/**
* Sub function that is used only by hasUnclosedBrackets().
*
* @access private
* @param string $string The string to check.
* @param integer &$num The number of occurences.
* @param string $char The character to count.
* @return integer The number of occurences of $char in $string, adjusted for backslashes.
*/
function _hasUnclosedBracketsSub($string, &$num, $char)
{
$parts = explode($char, $string);
for ($i = 0; $i < count($parts); $i++){
if (substr($parts[$i], -1) == '\\' || $this->_hasUnclosedQuotes($parts[$i]))
$num--;
if (isset($parts[$i + 1]))
$parts[$i + 1] = $parts[$i] . $char . $parts[$i + 1];
}
return $num;
}
/**
* Function to begin checking the address.
*
* @access private
* @param string $address The address to validate.
* @return mixed False on failure, or a structured array of address information on success.
*/
function _validateAddress($address)
{
$is_group = false;
if ($address['group']) {
$is_group = true;
// Get the group part of the name
$parts = explode(':', $address['address']);
$groupname = $this->_splitCheck($parts, ':');
$structure = array();
// And validate the group part of the name.
if (!$this->_validatePhrase($groupname)){
$this->error = 'Group name did not validate.';
return false;
} else {
// Don't include groups if we are not nesting
// them. This avoids returning invalid addresses.
if ($this->nestGroups) {
$structure = new stdClass;
$structure->groupname = $groupname;
}
}
$address['address'] = ltrim(substr($address['address'], strlen($groupname . ':')));
}
// If a group then split on comma and put into an array.
// Otherwise, Just put the whole address in an array.
if ($is_group) {
while (strlen($address['address']) > 0) {
$parts = explode(',', $address['address']);
$addresses[] = $this->_splitCheck($parts, ',');
$address['address'] = trim(substr($address['address'], strlen(end($addresses) . ',')));
}
} else {
$addresses[] = $address['address'];
}
// Check that $addresses is set, if address like this:
// Groupname:;
// Then errors were appearing.
if (!isset($addresses)){
$this->error = 'Empty group.';
return false;
}
for ($i = 0; $i < count($addresses); $i++) {
$addresses[$i] = trim($addresses[$i]);
}
// Validate each mailbox.
// Format could be one of: name <geezer@domain.com>
// geezer@domain.com
// geezer
// ... or any other format valid by RFC 822.
array_walk($addresses, array($this, 'validateMailbox'));
// Nested format
if ($this->nestGroups) {
if ($is_group) {
$structure->addresses = $addresses;
} else {
$structure = $addresses[0];
}
// Flat format
} else {
if ($is_group) {
$structure = array_merge($structure, $addresses);
} else {
$structure = $addresses;
}
}
return $structure;
}
/**
* Function to validate a phrase.
*
* @access private
* @param string $phrase The phrase to check.
* @return boolean Success or failure.
*/
function _validatePhrase($phrase)
{
// Splits on one or more Tab or space.
$parts = preg_split('/[ \\x09]+/', $phrase, -1, PREG_SPLIT_NO_EMPTY);
$phrase_parts = array();
while (count($parts) > 0){
$phrase_parts[] = $this->_splitCheck($parts, ' ');
for ($i = 0; $i < $this->index + 1; $i++)
array_shift($parts);
}
for ($i = 0; $i < count($phrase_parts); $i++) {
// If quoted string:
if (substr($phrase_parts[$i], 0, 1) == '"') {
if (!$this->_validateQuotedString($phrase_parts[$i]))
return false;
continue;
}
// Otherwise it's an atom:
if (!$this->_validateAtom($phrase_parts[$i])) return false;
}
return true;
}
/**
* Function to validate an atom which from rfc822 is:
* atom = 1*<any CHAR except specials, SPACE and CTLs>
*
* If validation ($this->validate) has been turned off, then
* validateAtom() doesn't actually check anything. This is so that you
* can split a list of addresses up before encoding personal names
* (umlauts, etc.), for example.
*
* @access private
* @param string $atom The string to check.
* @return boolean Success or failure.
*/
function _validateAtom($atom)
{
if (!$this->validate) {
// Validation has been turned off; assume the atom is okay.
return true;
}
// Check for any char from ASCII 0 - ASCII 127
if (!preg_match('/^[\\x00-\\x7E]+$/i', $atom, $matches)) {
return false;
}
// Check for specials:
if (preg_match('/[][()<>@,;\\:". ]/', $atom)) {
return false;
}
// Check for control characters (ASCII 0-31):
if (preg_match('/[\\x00-\\x1F]+/', $atom)) {
return false;
}
return true;
}
/**
* Function to validate quoted string, which is:
* quoted-string = <"> *(qtext/quoted-pair) <">
*
* @access private
* @param string $qstring The string to check
* @return boolean Success or failure.
*/
function _validateQuotedString($qstring)
{
// Leading and trailing "
$qstring = substr($qstring, 1, -1);
// Perform check.
return !(preg_match('/(.)[\x0D\\\\"]/', $qstring, $matches) && $matches[1] != '\\');
}
/**
* Function to validate a mailbox, which is:
* mailbox = addr-spec ; simple address
* / phrase route-addr ; name and route-addr
*
* @access public
* @param string &$mailbox The string to check.
* @return boolean Success or failure.
*/
function validateMailbox(&$mailbox)
{
// A couple of defaults.
$phrase = '';
$comment = '';
// Catch any RFC822 comments and store them separately
$_mailbox = $mailbox;
while (strlen(trim($_mailbox)) > 0) {
$parts = explode('(', $_mailbox);
$before_comment = $this->_splitCheck($parts, '(');
if ($before_comment != $_mailbox) {
// First char should be a (
$comment = substr(str_replace($before_comment, '', $_mailbox), 1);
$parts = explode(')', $comment);
$comment = $this->_splitCheck($parts, ')');
$comments[] = $comment;
// +1 is for the trailing )
$_mailbox = substr($_mailbox, strpos($_mailbox, $comment)+strlen($comment)+1);
} else {
break;
}
}
for($i=0; $i<count(@$comments); $i++){
$mailbox = str_replace('('.$comments[$i].')', '', $mailbox);
}
$mailbox = trim($mailbox);
// Check for name + route-addr
if (substr($mailbox, -1) == '>' && substr($mailbox, 0, 1) != '<') {
$parts = explode('<', $mailbox);
$name = $this->_splitCheck($parts, '<');
$phrase = trim($name);
$route_addr = trim(substr($mailbox, strlen($name.'<'), -1));
if ($this->_validatePhrase($phrase) === false || ($route_addr = $this->_validateRouteAddr($route_addr)) === false)
return false;
// Only got addr-spec
} else {
// First snip angle brackets if present.
if (substr($mailbox,0,1) == '<' && substr($mailbox,-1) == '>')
$addr_spec = substr($mailbox,1,-1);
else
$addr_spec = $mailbox;
if (($addr_spec = $this->_validateAddrSpec($addr_spec)) === false)
return false;
}
// Construct the object that will be returned.
$mbox = new stdClass();
// Add the phrase (even if empty) and comments
$mbox->personal = $phrase;
$mbox->comment = isset($comments) ? $comments : array();
if (isset($route_addr)) {
$mbox->mailbox = $route_addr['local_part'];
$mbox->host = $route_addr['domain'];
$route_addr['adl'] !== '' ? $mbox->adl = $route_addr['adl'] : '';
} else {
$mbox->mailbox = $addr_spec['local_part'];
$mbox->host = $addr_spec['domain'];
}
$mailbox = $mbox;
return true;
}
/**
* This function validates a route-addr which is:
* route-addr = "<" [route] addr-spec ">"
*
* Angle brackets have already been removed at the point of
* getting to this function.
*
* @access private
* @param string $route_addr The string to check.
* @return mixed False on failure, or an array containing validated address/route information on success.
*/
function _validateRouteAddr($route_addr)
{
// Check for colon.
if (strpos($route_addr, ':') !== false) {
$parts = explode(':', $route_addr);
$route = $this->_splitCheck($parts, ':');
} else {
$route = $route_addr;
}
// If $route is same as $route_addr then the colon was in
// quotes or brackets or, of course, non existent.
if ($route === $route_addr){
unset($route);
$addr_spec = $route_addr;
if (($addr_spec = $this->_validateAddrSpec($addr_spec)) === false) {
return false;
}
} else {
// Validate route part.
if (($route = $this->_validateRoute($route)) === false) {
return false;
}
$addr_spec = substr($route_addr, strlen($route . ':'));
// Validate addr-spec part.
if (($addr_spec = $this->_validateAddrSpec($addr_spec)) === false) {
return false;
}
}
if (isset($route)) {
$return['adl'] = $route;
} else {
$return['adl'] = '';
}
$return = array_merge($return, $addr_spec);
return $return;
}
/**
* Function to validate a route, which is:
* route = 1#("@" domain) ":"
*
* @access private
* @param string $route The string to check.
* @return mixed False on failure, or the validated $route on success.
*/
function _validateRoute($route)
{
// Split on comma.
$domains = explode(',', trim($route));
for ($i = 0; $i < count($domains); $i++) {
$domains[$i] = str_replace('@', '', trim($domains[$i]));
if (!$this->_validateDomain($domains[$i])) return false;
}
return $route;
}
/**
* Function to validate a domain, though this is not quite what
* you expect of a strict internet domain.
*
* domain = sub-domain *("." sub-domain)
*
* @access private
* @param string $domain The string to check.
* @return mixed False on failure, or the validated domain on success.
*/
function _validateDomain($domain)
{
// Note the different use of $subdomains and $sub_domains
$subdomains = explode('.', $domain);
while (count($subdomains) > 0) {
$sub_domains[] = $this->_splitCheck($subdomains, '.');
for ($i = 0; $i < $this->index + 1; $i++)
array_shift($subdomains);
}
for ($i = 0; $i < count($sub_domains); $i++) {
if (!$this->_validateSubdomain(trim($sub_domains[$i])))
return false;
}
// Managed to get here, so return input.
return $domain;
}
/**
* Function to validate a subdomain:
* subdomain = domain-ref / domain-literal
*
* @access private
* @param string $subdomain The string to check.
* @return boolean Success or failure.
*/
function _validateSubdomain($subdomain)
{
if (preg_match('|^\[(.*)]$|', $subdomain, $arr)){
if (!$this->_validateDliteral($arr[1])) return false;
} else {
if (!$this->_validateAtom($subdomain)) return false;
}
// Got here, so return successful.
return true;
}
/**
* Function to validate a domain literal:
* domain-literal = "[" *(dtext / quoted-pair) "]"
*
* @access private
* @param string $dliteral The string to check.
* @return boolean Success or failure.
*/
function _validateDliteral($dliteral)
{
return !preg_match('/(.)[][\x0D\\\\]/', $dliteral, $matches) && $matches[1] != '\\';
}
/**
* Function to validate an addr-spec.
*
* addr-spec = local-part "@" domain
*
* @access private
* @param string $addr_spec The string to check.
* @return mixed False on failure, or the validated addr-spec on success.
*/
function _validateAddrSpec($addr_spec)
{
$addr_spec = trim($addr_spec);
// Split on @ sign if there is one.
if (strpos($addr_spec, '@') !== false) {
$parts = explode('@', $addr_spec);
$local_part = $this->_splitCheck($parts, '@');
$domain = substr($addr_spec, strlen($local_part . '@'));
// No @ sign so assume the default domain.
} else {
$local_part = $addr_spec;
$domain = $this->default_domain;
}
if (($local_part = $this->_validateLocalPart($local_part)) === false) return false;
if (($domain = $this->_validateDomain($domain)) === false) return false;
// Got here so return successful.
return array('local_part' => $local_part, 'domain' => $domain);
}
/**
* Function to validate the local part of an address:
* local-part = word *("." word)
*
* @access private
* @param string $local_part
* @return mixed False on failure, or the validated local part on success.
*/
function _validateLocalPart($local_part)
{
$parts = explode('.', $local_part);
// Split the local_part into words.
while (count($parts) > 0){
$words[] = $this->_splitCheck($parts, '.');
for ($i = 0; $i < $this->index + 1; $i++) {
array_shift($parts);
}
}
// Validate each word.
for ($i = 0; $i < count($words); $i++) {
if ($this->_validatePhrase(trim($words[$i])) === false) return false;
}
// Managed to get here, so return the input.
return $local_part;
}
/**
* Returns an approximate count of how many addresses are
* in the given string. This is APPROXIMATE as it only splits
* based on a comma which has no preceding backslash. Could be
* useful as large amounts of addresses will end up producing
* *large* structures when used with parseAddressList().
*
* @param string $data Addresses to count
* @return int Approximate count
*/
function approximateCount($data)
{
return count(preg_split('/(?<!\\\\),/', $data));
}
/**
* This is a email validating function seperate to the rest
* of the class. It simply validates whether an email is of
* the common internet form: <user>@<domain>. This can be
* sufficient for most people. Optional stricter mode can
* be utilised which restricts mailbox characters allowed
* to alphanumeric, full stop, hyphen and underscore.
*
* @param string $data Address to check
* @param boolean $strict Optional stricter mode
* @return mixed False if it fails, an indexed array
* username/domain if it matches
*/
function isValidInetAddress($data, $strict = false)
{
$regex = $strict ? '/^([.0-9a-z_-]+)@(([0-9a-z-]+\.)+[0-9a-z]{2,4})$/i' : '/^([*+!.&#$|\'\\%\/0-9a-z^_`{}=?~:-]+)@(([0-9a-z-]+\.)+[0-9a-z]{2,4})$/i';
if (preg_match($regex, trim($data), $matches)) {
return array($matches[1], $matches[2]);
} else {
return false;
}
}
}
?>

File diff suppressed because it is too large Load Diff

View File

@ -1,311 +0,0 @@
<?php
/**
* o------------------------------------------------------------------------------o
* | This is HTMLMimeMail5. It is dual licensed as GPL and a commercial license. |
* | If you use the code commercially (or if you don't want to be restricted by |
* | the GPL license), you will need the commercial license. It's only £49 (GBP - |
* | roughly $98 depending on the exchange rate) and helps me out a lot. Thanks. |
* o------------------------------------------------------------------------------o
*
* © Copyright Richard Heyes
*/
/**
*
* Raw mime encoding class
*
* What is it?
* This class enables you to manipulate and build
* a mime email from the ground up.
*
* Why use this instead of mime.php?
* mime.php is a userfriendly api to this class for
* people who aren't interested in the internals of
* mime mail. This class however allows full control
* over the email.
*
* Eg.
*
* // Since multipart/mixed has no real body, (the body is
* // the subpart), we set the body argument to blank.
*
* $params['content_type'] = 'multipart/mixed';
* $email = new Mail_mimePart('', $params);
*
* // Here we add a text part to the multipart we have
* // already. Assume $body contains plain text.
*
* $params['content_type'] = 'text/plain';
* $params['encoding'] = '7bit';
* $text = $email->addSubPart($body, $params);
*
* // Now add an attachment. Assume $attach is
* the contents of the attachment
*
* $params['content_type'] = 'application/zip';
* $params['encoding'] = 'base64';
* $params['disposition'] = 'attachment';
* $params['dfilename'] = 'example.zip';
* $attach =& $email->addSubPart($body, $params);
*
* // Now build the email. Note that the encode
* // function returns an associative array containing two
* // elements, body and headers. You will need to add extra
* // headers, (eg. Mime-Version) before sending.
*
* $email = $message->encode();
* $email['headers'][] = 'Mime-Version: 1.0';
*
*
* Further examples are available at http://www.phpguru.org
*
* TODO:
* - Set encode() to return the $obj->encoded if encode()
* has already been run. Unless a flag is passed to specifically
* re-build the message.
*
* @author Richard Heyes <richard@phpguru.org>
* @version $Revision: 1.3 $
* @package Mail
*/
class Mail_MIMEPart
{
/**
* The encoding type of this part
* @var string
*/
private $encoding;
/**
* An array of subparts
* @var array
*/
private $subparts;
/**
* The output of this part after being built
* @var string
*/
private $encoded;
/**
* Headers for this part
* @var array
*/
private $headers;
/**
* The body of this part (not encoded)
* @var string
*/
private $body;
/**
* Constructor.
*
* Sets up the object.
*
* @param $body - The body of the mime part if any.
* @param $params - An associative array of parameters:
* content_type - The content type for this part eg multipart/mixed
* encoding - The encoding to use, 7bit, 8bit, base64, or quoted-printable
* cid - Content ID to apply
* disposition - Content disposition, inline or attachment
* dfilename - Optional filename parameter for content disposition
* description - Content description
* charset - Character set to use
* @access public
*/
public function __construct($body = '', $params = array())
{
if (!defined('MAIL_MIMEPART_CRLF')) {
define('MAIL_MIMEPART_CRLF', defined('MAIL_MIME_CRLF') ? MAIL_MIME_CRLF : "\r\n", true);
}
foreach ($params as $key => $value) {
switch ($key) {
case 'content_type':
$headers['Content-Type'] = $value . (isset($charset) ? '; charset="' . $charset . '"' : '');
break;
case 'encoding':
$this->encoding = $value;
$headers['Content-Transfer-Encoding'] = $value;
break;
case 'cid':
$headers['Content-ID'] = '<' . $value . '>';
break;
case 'disposition':
$headers['Content-Disposition'] = $value . (isset($dfilename) ? '; filename="' . $dfilename . '"' : '');
break;
case 'dfilename':
if (isset($headers['Content-Disposition'])) {
$headers['Content-Disposition'] .= '; filename="' . $value . '"';
} else {
$dfilename = $value;
}
break;
case 'description':
$headers['Content-Description'] = $value;
break;
case 'charset':
if (isset($headers['Content-Type'])) {
$headers['Content-Type'] .= '; charset="' . $value . '"';
} else {
$charset = $value;
}
break;
}
}
// Default content-type
if (!isset($headers['Content-Type'])) {
$headers['Content-Type'] = 'text/plain';
}
// Default encoding
if (!isset($this->encoding)) {
$this->encoding = '7bit';
}
// Assign stuff to member variables
$this->encoded = array();
$this->headers = $headers;
$this->body = $body;
}
/**
* Encodes and returns the email. Also stores
* it in the encoded member variable
*
* @return An associative array containing two elements,
* body and headers. The headers element is itself
* an indexed array.
*/
public function encode()
{
$encoded =& $this->encoded;
if (!empty($this->subparts)) {
srand((double)microtime()*1000000);
$boundary = '=_' . md5(uniqid(rand()) . microtime());
$this->headers['Content-Type'] .= ';' . MAIL_MIMEPART_CRLF . "\t" . 'boundary="' . $boundary . '"';
// Add body parts to $subparts
for ($i = 0; $i < count($this->subparts); $i++) {
$headers = array();
$tmp = $this->subparts[$i]->encode();
foreach ($tmp['headers'] as $key => $value) {
$headers[] = $key . ': ' . $value;
}
$subparts[] = implode(MAIL_MIMEPART_CRLF, $headers) . MAIL_MIMEPART_CRLF . MAIL_MIMEPART_CRLF . $tmp['body'];
}
$encoded['body'] = '--' . $boundary . MAIL_MIMEPART_CRLF .
implode('--' . $boundary . MAIL_MIMEPART_CRLF, $subparts) .
'--' . $boundary.'--' . MAIL_MIMEPART_CRLF;
} else {
$encoded['body'] = $this->getEncodedData($this->body, $this->encoding) . MAIL_MIMEPART_CRLF;
}
// Add headers to $encoded
$encoded['headers'] =& $this->headers;
return $encoded;
}
/**
* Adds a subpart to current mime part and returns
* a reference to it
*
* @param $body The body of the subpart, if any.
* @param $params The parameters for the subpart, same
* as the $params argument for constructor.
* @return A reference to the part you just added.
*/
public function addSubPart($body, $params)
{
$this->subparts[] = new Mail_MIMEPart($body, $params);
return $this->subparts[count($this->subparts) - 1];
}
/**
* Returns encoded data based upon encoding passed to it
*
* @param $data The data to encode.
* @param $encoding The encoding type to use, 7bit, base64,
* or quoted-printable.
*/
private function getEncodedData($data, $encoding)
{
switch ($encoding) {
case '8bit':
case '7bit':
return $data;
break;
case 'quoted-printable':
return $this->quotedPrintableEncode($data);
break;
case 'base64':
return rtrim(chunk_split(base64_encode($data), 76, MAIL_MIMEPART_CRLF));
break;
default:
return $data;
}
}
/**
* Encodes data to quoted-printable standard.
*
* @param $input The data to encode
* @param $line_max Optional max line length. Should
* not be more than 76 chars
*/
private function quotedPrintableEncode($input , $line_max = 76)
{
$lines = preg_split("/\r?\n/", $input);
$eol = MAIL_MIMEPART_CRLF;
$escape = '=';
$output = '';
while(list(, $line) = each($lines)){
$linlen = strlen($line);
$newline = '';
for ($i = 0; $i < $linlen; $i++) {
$char = substr($line, $i, 1);
$dec = ord($char);
if (($dec == 32) AND ($i == ($linlen - 1))){ // convert space at eol only
$char = '=20';
} elseif($dec == 9) {
; // Do nothing if a tab.
} elseif(($dec == 61) OR ($dec < 32 ) OR ($dec > 126)) {
$char = $escape . strtoupper(sprintf('%02s', dechex($dec)));
}
if ((strlen($newline) + strlen($char)) >= $line_max) { // MAIL_MIMEPART_CRLF is not counted
$output .= $newline . $escape . $eol; // soft line break; " =\r\n" is okay
$newline = '';
}
$newline .= $char;
} // end of for
$output .= $newline . $eol;
}
$output = substr($output, 0, -1 * strlen($eol)); // Don't want last crlf
return $output;
}
} // End of class
?>

View File

@ -1,103 +1,49 @@
<?
function sendMail($from, $to, $subject, $text='', $html='', /*$priority='high', $tabImgFiles=array(), */$tabAttachedFiles=array())
{
//return true;
$to=preg_split("/[\s,;]+/", $to);
//die(print_r($to));
require_once('Mail.php');
require_once('Mail/mime.php');
$headers=array( 'From'=>$from,
'To'=>$to,
'Subject'=>$subject,
// 'Reply-To'=>$from,
// 'Return-Path'=>$from,
'Content-Transfer-Encoding'=>'8bit',
'MIME-Version'=>'1.0',
'Date'=>date('D, d M Y H:i:s O'),
'Message-ID'=>'<'.md5(date('YmdHis')).'@mail.scores-decisions.com>',
'X-Priority'=>3,
'X-Mailer'=>'PHP v'.phpversion(),
);
/*
# Boundry for marking the split & Multitype Headers
$mime_boundary=md5(time());
$headers .= ''.$eol;
$headers .= "Content-Type: multipart/related; boundary=\"".$mime_boundary."\"".$eol;
$msg = "";
*/
$mime = new Mail_mime();
$footer="";/*
<?php
_______________________________________________________________________
Ce message et toutes les pièces jointes (ci-après le \"message\") sont établis a l'intention exclusive de ses destinataires.Si vous recevez ce message par erreur, merci de le détruire et d'en avertir immédiatement l'expéditeur par e-mail. Toute utilisation de ce message non conforme a sa destination, toute diffusion ou toute publication, totale ou partielle, est interdite, sauf autorisation expresse. Les communications sur Internet n'étant pas sécurisées, SCORES & DECISIONS S.A.S. informe qu'elle ne peut accepter aucune responsabilite quant au contenu de ce message.
This mail message and attachments (the \"message\") are solely intended for the addressees. It is confidential in nature . If you receive this message in error, please delete it and immediately notify the sender by e-mail. Any use other than its intended purpose, dissemination or disclosure, either whole or partial, is prohibited except if formal approval is granted. As communication on the Internet is not secure, SCORES & DECISIONS S.A.S. does not accept responsability for the content of this message.
/**
*
* @param unknown $from
* @param unknown $to
* @param unknown $subject
* @param string $text
* @param string $html
* @param unknown $tabAttachedFiles
*/
function sendMail($from, $to, $subject, $text='', $html='', $tabAttachedFiles=array())
{
$to = preg_split("/[\s,;]+/", $to);
";*/
if ($text<>'') $mime->setTXTBody($text.$footer);
if ($html<>'') $mime->setHTMLBody($html);
foreach ($tabAttachedFiles as $file)
$mime->addAttachment($file);
//do not ever try to call these lines in reverse order
$body = $mime->get();
$headers = $mime->headers($headers);
$params=array( 'host'=>'smtpauth.online.net', // SMTP_HOST
'port'=>25, //SMTP_PORT,
);
$params=array( 'host'=>SMTP_HOST,
'port'=>SMTP_PORT,
//'debug'=>true,
//'persist'=>true,
);
if (SMTP_USER=='' && SMTP_PASS=='')
$params['auth'] = false;
else {
$params['username'] = SMTP_USER;
$params['password'] = SMTP_PASS;
}/*
$params['auth'] = true;
$params['username'] = 'buzuk@scores-decisions.com';
$params['password'] = 'catsysyo92';
*/
$nbEssais=0;
while (1) {
// Create the mail object using the Mail::factory method
$mail_object = Mail::factory('smtp', $params);
// Trying to send the mail
$send = $mail_object->send($to, $headers, $body);
$nbEssais++;
if (PEAR::isError($send)) {
/** @todo tester les différents codes erreur **/
echo date('Y-m-d H:i:s'). " sendMail.php - essai #$nbEssais : ".$send->getMessage().EOL;
if (preg_match('/too many connections|421/i', $send->getMessage()))
sleep($nbEssais);
else {
$strTo=implode(';', $to);
file_put_contents( LOG_PATH.'/sendMailError.log',
date('Y-m-d H:i:s')."\t#$nbEssais\t$strTo\t".$send->getMessage().EOL,
FILE_APPEND);
break;
}
} else {
/** Si nous sommes en mode CLI, alors on fait en sorte de ne pas atteindre
la limite des 25 mails par minute (ramené à 100 / minute)
**/
if (MODE_EXEC==MODE_CLI) usleep(500000);
break;
}
}
return true;
$mail = new Zend_Mail('ISO-8859-15');
$tr = new Zend_Mail_Transport_Smtp(SMTP_HOST, array('port'=>SMTP_PORT));
$mail->setDefaultTransport($tr);
$mail->setFrom($from);
if ( count($to) > 0 ) {
foreach ( $to as $item ) {
$mail->addTo($item);
}
}
?>
$mail->setSubject($subject);
if ($text!='') {
$mail->setBodyText(mb_convert_encoding($text, 'ISO-8859-15', 'UTF-8'));
}
if ($html!='') {
$mail->setBodyHtml(mb_convert_encoding($html, 'ISO-8859-15', 'UTF-8'));
}
if ( count($tabAttachedFiles) > 0 ) {
foreach ($tabAttachedFiles as $file) {
$at = new Zend_Mime_Part( file_get_contents( $file ) );
$mail->addAttachment($at);
}
}
try {
$mail->send();
} catch (Zend_Mail_Transport_Exception $e) {
file_put_contents(LOG_PATH.'/sendMailError.log',date('Y-m-d H:i:s')." - ".$e->getMessage().PHP_EOL, FILE_APPEND);
}
}
?>

View File

@ -1,33 +0,0 @@
<?
function sendMail($from, $to, $subject, $text='', $html='', $priority='high', $tabImgFiles=array(), $tabAttachedFiles=array())
{
require_once("Mail.php");
$headers["From"] = $from;
$headers["To"] = $to;
$headers["Subject"] = $subject;
$body = $text;
$params["host"] = SMTP_HOST;
$params["port"] = SMTP_PORT;
if (SMTP_USER=='' && SMTP_PASS=='')
$params["auth"] = false;
else {
$params["username"] = SMTP_USER;
$params["password"] = SMTP_PASS;
}
// Create the mail object using the Mail::factory method
$mail_object = Mail::factory("smtp", $params);
$mail_object->send($to, $headers, $body);
if (PEAR::isError($mail_object))
return $mail_object->getMessage();
return true;
}
?>

View File

@ -1,369 +0,0 @@
<?php
/**
) o------------------------------------------------------------------------------o
* | This is HTMLMimeMail5. It is dual licensed as GPL and a commercial license. |
* | If you use the code commercially (or if you don't want to be restricted by |
* | the GPL license), you will need the commercial license. It's only £49 (GBP - |
* | roughly $98 depending on the exchange rate) and helps me out a lot. Thanks. |
* o------------------------------------------------------------------------------o
*
* © Copyright 2005 Richard Heyes
*/
define('SMTP_STATUS_NOT_CONNECTED', 1, true);
define('SMTP_STATUS_CONNECTED', 2, true);
class smtp
{
private $authenticated;
private $connection;
private $recipients;
private $headers;
private $timeout;
private $errors;
private $status;
private $body;
private $from;
private $host;
private $port;
private $helo;
private $auth;
private $user;
private $pass;
/**
* Constructor function. Arguments:
* $params - An assoc array of parameters:
*
* host - The hostname of the smtp server Default: localhost
* port - The port the smtp server runs on Default: 25
* helo - What to send as the HELO command Default: localhost
* (typically the hostname of the
* machine this script runs on)
* auth - Whether to use basic authentication Default: FALSE
* user - Username for authentication Default: <blank>
* pass - Password for authentication Default: <blank>
* timeout - The timeout in seconds for the call Default: 5
* to fsockopen()
*/
public function __construct($params = array())
{
if(!defined('CRLF'))
define('CRLF', "\r\n", TRUE);
$this->authenticated = FALSE;
$this->timeout = 5;
$this->status = SMTP_STATUS_NOT_CONNECTED;
$this->host = 'smtp.free.fr';
$this->port = 25;
$this->helo = 'srvsd01';
$this->auth = FALSE;
$this->user = '';
$this->pass = '';
$this->errors = array();
foreach($params as $key => $value){
$this->$key = $value;
}
}
/**
* Connect function. This will, when called
* statically, create a new smtp object,
* call the connect function (ie this function)
* and return it. When not called statically,
* it will connect to the server and send
* the HELO command.
*/
public function connect($params = array())
{
if (!isset($this->status)) {
$obj = new smtp($params);
if($obj->connect()){
$obj->status = SMTP_STATUS_CONNECTED;
}
return $obj;
} else {
$this->connection = fsockopen($this->host, $this->port, $errno, $errstr, $this->timeout);
if (function_exists('socket_set_timeout')) {
@socket_set_timeout($this->connection, 5, 0);
}
$greeting = $this->get_data();
if (is_resource($this->connection)) {
return $this->auth ? $this->ehlo() : $this->helo();
} else {
$this->errors[] = 'Failed to connect to server: '.$errstr;
return FALSE;
}
}
}
/**
* Function which handles sending the mail.
* Arguments:
* $params - Optional assoc array of parameters.
* Can contain:
* recipients - Indexed array of recipients
* from - The from address. (used in MAIL FROM:),
* this will be the return path
* headers - Indexed array of headers, one header per array entry
* body - The body of the email
* It can also contain any of the parameters from the connect()
* function
*/
public function send($params = array())
{
foreach ($params as $key => $value) {
$this->set($key, $value);
}
if ($this->is_connected()) {
// Do we auth or not? Note the distinction between the auth variable and auth() function
if ($this->auth AND !$this->authenticated) {
if(!$this->auth())
return false;
}
$this->mail($this->from);
if (is_array($this->recipients)) {
foreach ($this->recipients as $value) {
$this->rcpt($value);
}
} else {
$this->rcpt($this->recipients);
}
if (!$this->data()) {
return false;
}
// Transparency
$headers = str_replace(CRLF.'.', CRLF.'..', trim(implode(CRLF, $this->headers)));
$body = str_replace(CRLF.'.', CRLF.'..', $this->body);
$body = substr($body, 0, 1) == '.' ? '.'.$body : $body;
$this->send_data($headers);
$this->send_data('');
$this->send_data($body);
$this->send_data('.');
$result = (substr(trim($this->get_data()), 0, 3) === '250');
//$this->rset();
return $result;
} else {
$this->errors[] = 'Not connected!';
return FALSE;
}
}
/**
* Function to implement HELO cmd
*/
private function helo()
{
if(is_resource($this->connection)
AND $this->send_data('HELO '.$this->helo)
AND substr(trim($error = $this->get_data()), 0, 3) === '250' ){
return true;
} else {
$this->errors[] = 'HELO command failed, output: ' . trim(substr(trim($error),3));
return false;
}
}
/**
* Function to implement EHLO cmd
*/
private function ehlo()
{
if (is_resource($this->connection)
AND $this->send_data('EHLO '.$this->helo)
AND substr(trim($error = $this->get_data()), 0, 3) === '250' ){
return true;
} else {
$this->errors[] = 'EHLO command failed, output: ' . trim(substr(trim($error),3));
return false;
}
}
/**
* Function to implement RSET cmd
*/
private function rset()
{
if (is_resource($this->connection)
AND $this->send_data('RSET')
AND substr(trim($error = $this->get_data()), 0, 3) === '250' ){
return true;
} else {
$this->errors[] = 'RSET command failed, output: ' . trim(substr(trim($error),3));
return false;
}
}
/**
* Function to implement QUIT cmd
*/
private function quit()
{
if(is_resource($this->connection)
AND $this->send_data('QUIT')
AND substr(trim($error = $this->get_data()), 0, 3) === '221' ){
fclose($this->connection);
$this->status = SMTP_STATUS_NOT_CONNECTED;
return true;
} else {
$this->errors[] = 'QUIT command failed, output: ' . trim(substr(trim($error),3));
return false;
}
}
/**
* Function to implement AUTH cmd
*/
private function auth()
{
if (is_resource($this->connection)
AND $this->send_data('AUTH LOGIN')
AND substr(trim($error = $this->get_data()), 0, 3) === '334'
AND $this->send_data(base64_encode($this->user)) // Send username
AND substr(trim($error = $this->get_data()),0,3) === '334'
AND $this->send_data(base64_encode($this->pass)) // Send password
AND substr(trim($error = $this->get_data()),0,3) === '235' ){
$this->authenticated = true;
return true;
} else {
$this->errors[] = 'AUTH command failed: ' . trim(substr(trim($error),3));
return false;
}
}
/**
* Function that handles the MAIL FROM: cmd
*/
private function mail($from)
{
if ($this->is_connected()
AND $this->send_data('MAIL FROM:<'.$from.'>')
AND substr(trim($this->get_data()), 0, 2) === '250' ) {
return true;
} else {
return false;
}
}
/**
* Function that handles the RCPT TO: cmd
*/
private function rcpt($to)
{
if($this->is_connected()
AND $this->send_data('RCPT TO:<'.$to.'>')
AND substr(trim($error = $this->get_data()), 0, 2) === '25' ){
return true;
} else {
$this->errors[] = trim(substr(trim($error), 3));
return false;
}
}
/**
* Function that sends the DATA cmd
*/
private function data()
{
if($this->is_connected()
AND $this->send_data('DATA')
AND substr(trim($error = $this->get_data()), 0, 3) === '354' ) {
return true;
} else {
$this->errors[] = trim(substr(trim($error), 3));
return false;
}
}
/**
* Function to determine if this object
* is connected to the server or not.
*/
private function is_connected()
{
return (is_resource($this->connection) AND ($this->status === SMTP_STATUS_CONNECTED));
}
/**
* Function to send a bit of data
*/
private function send_data($data)
{
if(is_resource($this->connection)){
return fwrite($this->connection, $data.CRLF, strlen($data)+2);
} else {
return false;
}
}
/**
* Function to get data.
*/
private function get_data()
{
$return = '';
$line = '';
$loops = 0;
if(is_resource($this->connection)){
while((strpos($return, CRLF) === FALSE OR substr($line,3,1) !== ' ') AND $loops < 100){
$line = fgets($this->connection, 512);
$return .= $line;
$loops++;
}
return $return;
}else
return false;
}
/**
* Sets a variable
*/
public function set($var, $value)
{
$this->$var = $value;
return true;
}
/**
* Function to return the errors array
*/
public function getErrors()
{
return $this->errors;
}
} // End of class
?>

View File

@ -259,6 +259,7 @@ $tabDico = array(
'multiple' => array(
'actionnaires',
'participations',
'annoncetxt',
),
);
@ -431,7 +432,7 @@ require_once 'Scores/Enrichissement.php';
$dico = new Enrichissement();
//Liste des champs SQL
foreach($tabExtract as $key)
foreach($tabExtract as $i => $key)
{
$strKey = false;
@ -504,15 +505,19 @@ foreach($tabExtract as $key)
break;
}
if ( $element == 'data' && in_array($key, $select) )
if ( in_array($element, array('data', 'multiple')) && in_array($key, $select) )
{
${$key.'Data'} = $values;
if ( $values ) {
$tabExtract[$i] = $key;
}
}
}
}
//Ajout colonne obligatoire
$tabEntete[] = 'nicSiege';
${'nicSiegeData'} = '';
$tabEntete[] = 'SiretValide';
if( null != $profilDoublon ) {
$tabEntete[] = 'Doublon';
@ -631,10 +636,10 @@ foreach($tabIdentifiant as $item)
//Vérifier les nic, ou sélectionner le nic du siege actif
$nicV = $nic; //Surcharge pour le nic
$strNic = '';
$sqlNic = 'SELECT nic AS nicTmp, cj AS cjTmp, IF(siege=1,1,0) AS triSiege FROM jo.etablissements WHERE siren='.$siren;
$sqlNic = 'SELECT LPAD(nic,5,0) AS nicTmp, cj AS cjTmp, IF(siege=1,1,0) AS triSiege FROM jo.etablissements WHERE siren='.$siren;
//Si identifiant est un siret, char(14) alors on vérifie que le NIC existe
if (strlen($item)==14 && intval($nic)>0){
if ( strlen($item)==14 && intval($nic)>0 ) {
$stmt = $dbMetier->query($sqlNic.' AND nic='.$nic);
$result = $stmt->fetchAll();
if (count($result)==0){
@ -646,7 +651,7 @@ foreach($tabIdentifiant as $item)
}
}
if (intval($nicV)==0){
if ( intval($nicV)==0 ) {
$strNic = ' AND nic>-1 AND actif>-1 ORDER BY triSiege DESC, actif DESC, nicTmp DESC LIMIT 0,1';
$stmt = $dbMetier->query($sqlNic.$strNic);
$result = $stmt->fetchAll();
@ -713,6 +718,7 @@ foreach($tabIdentifiant as $item)
//Retour lignes multiples
elseif ( $element == 'multiple' )
{
$values = false;
$isSelected = false;
foreach($select as $selectItem){
if ( in_array($selectItem, $tabExtract) ) {
@ -722,7 +728,10 @@ foreach($tabIdentifiant as $item)
}
$retour = array();
if ( $isSelected && function_exists($selectItem.'Multiple') ) {
$retour = call_user_func($selectItem.'Multiple', $siren, $nicV);
if( ${$selectItem.'Data'}!=false ){
$values = ${$selectItem.'Data'};
}
$retour = call_user_func($selectItem.'Multiple', $siren, $nicV, $values);
}
if (count($retour)>0) {
$originalLine = $tabNewData[$extendNbRow];
@ -791,7 +800,7 @@ if ($opts->id) {
function nicSiegeData($siren, $nic, $values = false)
{
$tabData['nicSiege'] = $nic;
$tabData['nicSiege'] = $nic;
return $tabData;
}
@ -1782,6 +1791,39 @@ function participationsMultiple($siren, $nic)
return $tabData;
}
function annoncetxtEntete()
{
return array(
'AnnonceLib',
'AnnonceDate',
'AnnonceDateParution',
'AnnonceTxt',
);
}
function annoncetxtMultiple($siren, $nic, $values = false)
{
$tabData = array();
if ( $values!==false ) {
$tabTmp = explode(',', $values);
$iInsee = new MInsee();
$response = $iInsee->getAnnoncesLegales($siren, 0, $tabTmp, false, true);
foreach ($response as $tabAnn){
foreach ($tabAnn['evenements'] as $codEve) {
$dateEven = $tabAnn['dateJugement'];
if ($dateEven=='0000-00-00') $dateEven=$tabAnn['dateEffet'];
if ($dateEven=='0000-00-00') $dateEven=$tabAnn['DateParution'];
$formatElement['AnnonceLib'] = strtr($codEve['LibEven'],array(','=>' ',"'"=>' ','"'=>' ',';'=>' '));
$formatElement['AnnonceDate'] = $dateEven;
$formatElement['AnnonceDateParution'] = $tabAnn['DateParution'];
$formatElement['AnnonceTxt'] = $tabAnn['texteAnnonce'];
$tabData[] = $formatElement;
}
}
}
return $tabData;
}
/* == FUNCTION == */