Compare commits
135 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
fc3b76e327 | ||
|
486007e5c1 | ||
|
69f09a510c | ||
|
f8f6e9dfa3 | ||
|
1d7eaf9d06 | ||
|
ae6eefdb17 | ||
|
b8f646c1d2 | ||
|
ab819c5c6e | ||
|
406dff7629 | ||
|
5b9a742b3f | ||
|
179b7e51ac | ||
|
9667819051 | ||
|
fab41ebdf0 | ||
|
798c2defb2 | ||
|
f0e05f752c | ||
|
1268d534be | ||
|
ce65a3718c | ||
|
315a49c7b5 | ||
|
e93a9b2283 | ||
|
4af0eedba2 | ||
|
5dae9355fc | ||
|
524376b896 | ||
|
47d7ba32e4 | ||
|
ba761881d0 | ||
|
afde6c739c | ||
|
00440c460a | ||
|
4111692b0e | ||
|
949e097146 | ||
|
94748d4ea0 | ||
|
1cbec888f6 | ||
|
1e7c0c929d | ||
|
68b1e7eb15 | ||
|
e7b3cbb56f | ||
|
21c7ddff17 | ||
|
24b194251d | ||
|
277467012f | ||
|
d972d9d545 | ||
|
72d3750960 | ||
|
15e830b00e | ||
|
bd66d2350b | ||
|
86cfe1e141 | ||
|
689566d34c | ||
|
2da9a49174 | ||
|
ad36ad7f1e | ||
|
a2c26500ea | ||
|
a52c0f0647 | ||
|
c7d00e6e34 | ||
|
a59c3dc0d4 | ||
|
4f6e428b24 | ||
|
efb7f27c39 | ||
|
24546077c2 | ||
|
17c9b69058 | ||
|
fa05294b71 | ||
|
fcd0df8095 | ||
|
acf4490c22 | ||
|
625471e2c7 | ||
|
4e2aa5a0e8 | ||
|
77d9827278 | ||
|
f6fa2fb57a | ||
|
8e19dde88e | ||
|
b1ac5bb6f2 | ||
|
684a851804 | ||
|
e1ec08be89 | ||
|
a06e4f4785 | ||
|
d20e31cd61 | ||
|
5f99e570e1 | ||
|
53f0a7033b | ||
|
a252e974fd | ||
|
3555bb2cb0 | ||
|
101ab6dc5f | ||
|
66142be518 | ||
|
53080e1f62 | ||
|
741e0704be | ||
|
1b45991ab2 | ||
|
c1514c0cd0 | ||
|
72454a1f2c | ||
|
5ddbce7e70 | ||
|
c891e32acb | ||
|
fba1feccd4 | ||
|
5bf67ddaf9 | ||
|
2298aa1957 | ||
|
ae3d8595dd | ||
|
ff45c9f73f | ||
|
29f441596d | ||
|
268aa802c0 | ||
|
011fb14516 | ||
|
e86cacf90b | ||
|
63f22974cf | ||
|
bec115bae9 | ||
|
08284a2263 | ||
|
29c341cc6d | ||
|
db9d30e788 | ||
|
b428e8af4d | ||
|
7ccd624de1 | ||
|
1c274a7610 | ||
|
5cf121b4ab | ||
|
3f1af2f7c5 | ||
|
d1c1cbed21 | ||
|
95c066038f | ||
|
8503cc2d8f | ||
|
6ddc67f012 | ||
|
a8122270bf | ||
|
6ae974d5ac | ||
|
8506f8099a | ||
|
211c8c46b3 | ||
|
60294bb48b | ||
|
5801065732 | ||
|
1a787444c3 | ||
|
33ba681ce3 | ||
|
8b34000c85 | ||
|
8f3fdb16d9 | ||
|
4c14e3e2e0 | ||
|
9641988ba4 | ||
|
69a27b1732 | ||
|
a0aaeb43ee | ||
|
1f8f41f377 | ||
|
7df5bd0a76 | ||
|
b358f40f9c | ||
|
b67e766f45 | ||
|
0023f87458 | ||
|
4ba20418c6 | ||
|
d3c68f3f00 | ||
|
793162719f | ||
|
db2238406e | ||
|
e36a8d52dd | ||
|
b0281df4f7 | ||
|
5a497ee0a8 | ||
|
cab2ee9440 | ||
|
53b30e39af | ||
|
223eae4784 | ||
|
e0bf62b8fa | ||
|
73ceb9e48d | ||
|
94bf9b4e21 | ||
|
ebf6e07607 | ||
|
e459d43665 |
63
application/Bootstrap.php
Normal file
63
application/Bootstrap.php
Normal file
@ -0,0 +1,63 @@
|
||||
<?php
|
||||
class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
|
||||
{
|
||||
//Initialisation global des paramètres de vue
|
||||
protected function _initViewSettings()
|
||||
{
|
||||
$this->bootstrap('view');
|
||||
$view = $this->getResource('view');
|
||||
$view->setEncoding('UTF-8');
|
||||
$view->doctype('XHTML1_STRICT');
|
||||
$view->headMeta()
|
||||
->appendHttpEquiv('Content-Type', 'text/html; charset=UTF-8')
|
||||
->appendHttpEquiv('Content-Language', 'fr-FR');
|
||||
$view->headTitle()->setSeparator(' - ');
|
||||
|
||||
$view->headLink()
|
||||
->appendStylesheet('/styles/reset.css', 'all')
|
||||
->appendStylesheet('/styles/main.css', 'all')
|
||||
->appendStylesheet('/jqueryui/jquery-ui.css', 'all');
|
||||
|
||||
$view->headScript()
|
||||
->appendFile('/scripts/jquery.js', 'text/javascript')
|
||||
->appendFile('/scripts/jquery-ui.js', 'text/javascript')
|
||||
->appendFile('/scripts/enrichissement.js', 'text/javascript');
|
||||
|
||||
$view->headTitle()->setSeparator(' - ');
|
||||
|
||||
$view->headTitle('Enrichissement de fichier');
|
||||
}
|
||||
|
||||
protected function _initDb()
|
||||
{
|
||||
$dbConfig = new Zend_Config_Ini(APPLICATION_PATH . '/configs/configuration.ini', 'databases');
|
||||
try {
|
||||
$db = Zend_Db::factory($dbConfig->db);
|
||||
Zend_Db_Table::setDefaultAdapter ($db);
|
||||
} catch ( Exception $e ) {
|
||||
exit ( $e->getMessage() );
|
||||
}
|
||||
Zend_Registry::set('db', $db);
|
||||
}
|
||||
|
||||
//Initialisation global des paramètres de log
|
||||
protected function _initLogging()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
protected function _initCache()
|
||||
{
|
||||
//MetadataCache pour la base de données
|
||||
$frontendOptions = array(
|
||||
'lifetime' => 14400,
|
||||
'automatic_serialization' => true
|
||||
);
|
||||
$backendOptions = array();
|
||||
$cache = Zend_Cache::factory('Core','Apc', $frontendOptions, $backendOptions);
|
||||
Zend_Db_Table_Abstract::setDefaultMetadataCache($cache);
|
||||
|
||||
//Cache pour les données de la base à stocker
|
||||
}
|
||||
}
|
||||
|
27
application/configs/application.ini
Normal file
27
application/configs/application.ini
Normal file
@ -0,0 +1,27 @@
|
||||
[production]
|
||||
phpSettings.date.timezone = "Europe/Paris"
|
||||
phpSettings.display_startup_errors = 0
|
||||
phpSettings.display_errors = 0
|
||||
bootstrap.path = APPLICATION_PATH "/Bootstrap.php"
|
||||
bootstrap.class = "Bootstrap"
|
||||
appnamespace = "Application"
|
||||
resources.frontController.controllerDirectory = APPLICATION_PATH "/controllers"
|
||||
resources.frontController.params.displayExceptions = 0
|
||||
autoloaderNamespaces[] = "Application_"
|
||||
resources.layout.layout = "main"
|
||||
resources.layout.layoutPath = APPLICATION_PATH "/views"
|
||||
resources.view.basePath = APPLICATION_PATH "/views"
|
||||
|
||||
[staging : production]
|
||||
resources.frontController.params.displayExceptions = 0
|
||||
phpSettings.soap.wsdl_cache_enabled = 0
|
||||
|
||||
[development : production]
|
||||
phpSettings.display_startup_errors = 1
|
||||
phpSettings.display_errors = 1
|
||||
phpSettings.soap.wsdl_cache_enabled = 0
|
||||
resources.frontController.params.displayExceptions = 1
|
||||
|
||||
[testing : production]
|
||||
phpSettings.display_startup_errors = 1
|
||||
phpSettings.display_errors = 1
|
6
application/controllers/EnrichissementController.php
Normal file
6
application/controllers/EnrichissementController.php
Normal file
@ -0,0 +1,6 @@
|
||||
<?php
|
||||
class EnrichissementController extends Zend_Controller_Action
|
||||
{
|
||||
|
||||
|
||||
}
|
150
application/controllers/EnvoiController.php
Normal file
150
application/controllers/EnvoiController.php
Normal file
@ -0,0 +1,150 @@
|
||||
<?php
|
||||
class EnvoiController extends Zend_Controller_Action
|
||||
{
|
||||
|
||||
public function init()
|
||||
{
|
||||
$this->view->headScript()->appendFile('/scripts/enrichissement.js', 'text/javascript');
|
||||
$this->view->headLink()->appendStylesheet('/styles/enrichissement.css');
|
||||
}
|
||||
|
||||
/**
|
||||
* Enter description here ...
|
||||
*/
|
||||
public function indexAction(){}
|
||||
|
||||
public function fileformAction()
|
||||
{
|
||||
$this->view->headScript()->appendFile('/scripts/jquery.form.js', 'text/javascript');
|
||||
$this->view->headScript()->appendFile('/scripts/jqueryprogressbar.js', 'text/javascript');
|
||||
$this->view->assign('filesize', ini_get('upload_max_filesize'));
|
||||
|
||||
//Récupérer les clients
|
||||
$dbConfig = array(
|
||||
'host' => MYSQL_HOST,
|
||||
'port' => MYSQL_PORT,
|
||||
'username' => MYSQL_USER,
|
||||
'password' => MYSQL_PASS,
|
||||
'dbname' => MYSQL_DEFAULT_DB,
|
||||
'driver_options' => array(MYSQLI_INIT_COMMAND => 'SET NAMES UTF8;'),
|
||||
//'driver_options' => array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES UTF8;')
|
||||
);
|
||||
$sqlmetier = Zend_Db::factory('Mysqli', $dbConfig);
|
||||
$sql = $sqlmetier->select()
|
||||
->from('sdv1.clients', array('id', 'nom'))
|
||||
->where("actif = 'Oui'");
|
||||
$clients = $sqlmetier->fetchAll($sql, null, Zend_Db::FETCH_OBJ);
|
||||
|
||||
$this->view->assign('clients', $clients);
|
||||
}
|
||||
|
||||
public function fileuploadAction()
|
||||
{
|
||||
$this->_helper->layout()->disableLayout();
|
||||
$this->_helper->viewRenderer->setNoRender(true);
|
||||
|
||||
$request = $this->getRequest();
|
||||
|
||||
$name = $request->getParam('ref', '');
|
||||
$idClient = $request->getParam('client');
|
||||
if (empty($name)) {
|
||||
echo "Référence non définie.";
|
||||
}
|
||||
else
|
||||
{
|
||||
$config = new Zend_Config_Ini(APPLICATION_PATH . '/configs/configuration.ini', 'path');
|
||||
$path = realpath($config->data).'/validation';
|
||||
if(!file_exists($path)) mkdir($path);
|
||||
|
||||
if ( isset($_FILES) && count($_FILES)==1 ){
|
||||
$n = $_FILES['fichier']['name'];
|
||||
$s = $_FILES['fichier']['size'];
|
||||
$tmp_name = $_FILES['fichier']['tmp_name'];
|
||||
|
||||
$extValide = array('csv');
|
||||
$extension = strrchr($n,'.');
|
||||
$extension = substr($extension,1);
|
||||
//Vérifier l'extension du fichier
|
||||
if(!in_array($extension, $extValide)){
|
||||
echo "Extension de fichier incorrect !";
|
||||
} elseif (move_uploaded_file($tmp_name, $path.'/'.$idClient.'-'.$name.'.'.$extension)){
|
||||
echo "Fichier envoyé, <a href=\"".
|
||||
$this->view->url(array(
|
||||
'controller' => 'envoi',
|
||||
'action' => 'checkfile',
|
||||
'file' => $idClient.'-'.$name.'.'.$extension,
|
||||
))
|
||||
."\">Vérifier le format</a>";
|
||||
} else {
|
||||
echo "Erreur : ".$_FILES['fichier']['error'];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Etat de progression de l'upload du fichier
|
||||
*/
|
||||
public function fileprogressAction()
|
||||
{
|
||||
$this->_helper->layout()->disableLayout();
|
||||
$this->_helper->viewRenderer->setNoRender(true);
|
||||
|
||||
$request = $this->getRequest();
|
||||
$key = $request->getParam('key', '');
|
||||
if (!empty($key)) {
|
||||
//$rep sera égal à false si la clef n'existe pas dans le cache apc
|
||||
$rep = apc_fetch('upload_'.$key);
|
||||
echo json_encode($rep);
|
||||
}
|
||||
}
|
||||
|
||||
public function checkfileAction()
|
||||
{
|
||||
$request = $this->getRequest();
|
||||
$file = $request->getParam('file');
|
||||
|
||||
$config = new Zend_Config_Ini(APPLICATION_PATH . '/configs/configuration.ini', 'path');
|
||||
|
||||
$pathIn = $config->data.'/validation';
|
||||
$pathOut = $config->data.'/clients';
|
||||
if(!file_exists($pathOut)) mkdir($pathOut);
|
||||
|
||||
//Vérifier le format du fichier
|
||||
require_once 'Scores/Enrichissement.php';
|
||||
$data = new Enrichissement();
|
||||
|
||||
$result = $data->checkFileEntete($pathIn.'/'.$file);
|
||||
if ($result===FALSE)
|
||||
{
|
||||
$this->view->assign('errors',array("Impossible de lire le fichier !"));
|
||||
//Supprimer le fichier
|
||||
unlink($pathIn.'/'.$file);
|
||||
}
|
||||
elseif (is_array($result))
|
||||
{
|
||||
$this->view->assign('errors',$result);
|
||||
//Supprimer le fichier
|
||||
unlink($pathIn.'/'.$file);
|
||||
}
|
||||
elseif (is_int($result))
|
||||
{
|
||||
//Enregistrer dans la bdd
|
||||
$commandesM = new Application_Model_Commandes();
|
||||
$data = array(
|
||||
'fichier' => $file,
|
||||
'idProfil' => 0,
|
||||
'nbLigne' => $result,
|
||||
'nbLigneT' => 0,
|
||||
'error' => '',
|
||||
'dateAdded' => date('Y-m-d H:i:s'),
|
||||
);
|
||||
if ($commandesM->insert($data)){
|
||||
//Déplacer le fichier
|
||||
rename($pathIn.'/'.$file, $pathOut.'/'.$file);
|
||||
}
|
||||
$this->view->assign('nb', $result);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
47
application/controllers/ErrorController.php
Normal file
47
application/controllers/ErrorController.php
Normal file
@ -0,0 +1,47 @@
|
||||
<?php
|
||||
class ErrorController extends Zend_Controller_Action
|
||||
{
|
||||
public function errorAction()
|
||||
{
|
||||
$errors = $this->_getParam('error_handler');
|
||||
|
||||
switch ($errors->type) {
|
||||
case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ROUTE:
|
||||
case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_CONTROLLER:
|
||||
case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ACTION:
|
||||
|
||||
// 404 error -- controller or action not found
|
||||
$this->getResponse()->setHttpResponseCode(404);
|
||||
$this->view->message = 'Page not found';
|
||||
break;
|
||||
default:
|
||||
// application error
|
||||
$this->getResponse()->setHttpResponseCode(500);
|
||||
$this->view->message = 'Application error';
|
||||
break;
|
||||
}
|
||||
|
||||
// Log exception, if logger available
|
||||
if ($log = $this->getLog()) {
|
||||
$log->crit($this->view->message, $errors->exception);
|
||||
}
|
||||
|
||||
// conditionally display exceptions
|
||||
if ($this->getInvokeArg('displayExceptions') == true) {
|
||||
$this->view->exception = $errors->exception;
|
||||
}
|
||||
|
||||
$this->view->request = $errors->request;
|
||||
}
|
||||
|
||||
public function getLog()
|
||||
{
|
||||
$bootstrap = $this->getInvokeArg('bootstrap');
|
||||
if (!$bootstrap->hasPluginResource('Log')) {
|
||||
return false;
|
||||
}
|
||||
$log = $bootstrap->getResource('Log');
|
||||
return $log;
|
||||
}
|
||||
}
|
||||
|
107
application/controllers/IndexController.php
Normal file
107
application/controllers/IndexController.php
Normal file
@ -0,0 +1,107 @@
|
||||
<?php
|
||||
class IndexController extends Zend_Controller_Action
|
||||
{
|
||||
|
||||
public function indexAction()
|
||||
{
|
||||
//Liste des profils
|
||||
$profilM = new Application_Model_Profil();
|
||||
$sql = $profilM->select();
|
||||
$this->view->assign('listProfil', $profilM->fetchAll($sql));
|
||||
|
||||
$commandesM = new Application_Model_Commandes($db);
|
||||
|
||||
//Liste des fichiers en attente de profil
|
||||
$sql = $commandesM->select()->where('idProfil = ?', 0);
|
||||
$this->view->assign('fileAttenteProfil', $commandesM->fetchAll($sql));
|
||||
|
||||
//Liste des enrichissements en cours
|
||||
$sql = $commandesM->select()
|
||||
->where('idProfil != ?', 0)
|
||||
->where("dateStop = '0000-00-00 00:00:00'");
|
||||
$this->view->assign('fileEnCours', $commandesM->fetchAll($sql));
|
||||
|
||||
//Liste des enrichissements terminé
|
||||
$sql = $commandesM->select()
|
||||
->where("dateStop != '0000-00-00 00:00:00'")
|
||||
->where("error = ''");
|
||||
$this->view->assign('fileFinish', $commandesM->fetchAll($sql));
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function getinfoAction()
|
||||
{
|
||||
$this->_helper->layout()->disableLayout();
|
||||
$this->_helper->viewRenderer->setNoRender(true);
|
||||
|
||||
$request = $this->getRequest();
|
||||
$id = $request->getParam('id');
|
||||
if (!empty($id)){
|
||||
$commandesM = new Application_Model_Commandes();
|
||||
$result = $commandesM->find($id);
|
||||
$info = $result->current();
|
||||
$output = array(
|
||||
'nbLigneT' => $info->nbLigneT,
|
||||
);
|
||||
echo json_encode($output);
|
||||
}
|
||||
}
|
||||
|
||||
public function getfileAction()
|
||||
{
|
||||
$this->_helper->layout()->disableLayout();
|
||||
$this->_helper->viewRenderer->setNoRender(true);
|
||||
$request = $this->getRequest();
|
||||
$file = $request->getParam('file', '');
|
||||
$content_type = 'application/csv-tab-delimited-table';
|
||||
$path = '/sites/dataenrichissement/export/';
|
||||
//Envoi du fichier sur la sortie standard
|
||||
if ( file_exists($path.$file) ) {
|
||||
header('Content-Transfer-Encoding: none');
|
||||
header('Content-type: ' . $content_type.'');
|
||||
header('Content-Length: ' . filesize($path.$file));
|
||||
header('Content-MD5: ' . base64_encode(md5_file($path.$file)));
|
||||
header('Content-Disposition: filename="' . basename($path.$file) . '"');
|
||||
header('Cache-Control: private, max-age=0, must-revalidate');
|
||||
header('Pragma: public');
|
||||
ini_set('zlib.output_compression', '0');
|
||||
echo file_get_contents($path.$file);
|
||||
} else {
|
||||
echo 'Impossible de charger le fichier.';
|
||||
}
|
||||
}
|
||||
|
||||
public function restartAction()
|
||||
{
|
||||
$request = $this->getRequest();
|
||||
$id = $request->getParam('id');
|
||||
if (!empty($id)){
|
||||
$commandesM = new Application_Model_Commandes();
|
||||
$data = array(
|
||||
'nbLigneT' => 0,
|
||||
'error' => '',
|
||||
'dateStart' => '0000-00-00 00:00:00',
|
||||
'fichierOut' => '',
|
||||
);
|
||||
$commandesM->update($data, "id=$id");
|
||||
}
|
||||
}
|
||||
|
||||
public function repriseAction()
|
||||
{
|
||||
$this->_helper->layout()->disableLayout();
|
||||
$this->_helper->viewRenderer->setNoRender(true);
|
||||
$request = $this->getRequest();
|
||||
$id = $request->getParam('id');
|
||||
if (!empty($id)){
|
||||
$commandesM = new Application_Model_Commandes();
|
||||
$data = array(
|
||||
'error' => '',
|
||||
);
|
||||
$commandesM->update($data, "id=$id");
|
||||
}
|
||||
exec("php ".APPLICATION_PATH."/../batch/enrichissement.php --reprise --id ".$id." &");
|
||||
}
|
||||
|
||||
}
|
126
application/controllers/ProfilController.php
Normal file
126
application/controllers/ProfilController.php
Normal file
@ -0,0 +1,126 @@
|
||||
<?php
|
||||
class ProfilController extends Zend_Controller_Action
|
||||
{
|
||||
|
||||
public function indexAction()
|
||||
{
|
||||
$db = Zend_Registry::get('db');
|
||||
|
||||
$profilM = new Application_Model_Profil($db);
|
||||
$sql = $profilM->select()->order('reference ASC');
|
||||
$rows = $profilM->fetchAll($sql);
|
||||
$this->view->assign('profils', $rows);
|
||||
}
|
||||
|
||||
public function detailAction()
|
||||
{
|
||||
$request = $this->getRequest();
|
||||
$id = $request->getParam('id', null);
|
||||
|
||||
require_once 'Scores/Enrichissement.php';
|
||||
$data = new Enrichissement();
|
||||
if ( $id != null ) {
|
||||
$profilM = new Application_Model_Profil();
|
||||
$profil = $profilM->find($id);
|
||||
$criteres = json_decode($profil->current()->criteres, true);
|
||||
$tmp = array();
|
||||
foreach ($criteres as $critere) {
|
||||
$tmp[] = $data->getDicoLib($critere);
|
||||
}
|
||||
$this->view->assign('profil', $tmp);
|
||||
$this->view->assign('reference', $profil->current()->reference);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function createAction()
|
||||
{
|
||||
$request = $this->getRequest();
|
||||
$id = $request->getParam('id', null);
|
||||
|
||||
require_once 'Scores/Enrichissement.php';
|
||||
$data = new Enrichissement();
|
||||
if ( $id != null ) {
|
||||
|
||||
$profilM = new Application_Model_Profil();
|
||||
$profil = $profilM->find($id);
|
||||
$criteres = json_decode($profil->current()->criteres, true);
|
||||
$tmp = array();
|
||||
foreach ($criteres as $critere) {
|
||||
$values = false;
|
||||
if (preg_match('/(.*)\((.*)\)/', $critere, $matches))
|
||||
{
|
||||
$values = $matches[2];
|
||||
}
|
||||
|
||||
$tmp[$critere] = array(
|
||||
'lib' => $data->getDicoLib($critere),
|
||||
'values' => $values,
|
||||
);
|
||||
}
|
||||
$this->view->assign('criteres', $tmp);
|
||||
$this->view->assign('reference', $profil->current()->reference);
|
||||
}
|
||||
$this->view->assign('id', $id);
|
||||
$this->view->assign('edit', true);
|
||||
$this->view->assign('elements', $data->getDico());
|
||||
|
||||
}
|
||||
|
||||
public function saveAction()
|
||||
{
|
||||
$this->_helper->layout()->disableLayout();
|
||||
$this->_helper->viewRenderer->setNoRender(true);
|
||||
|
||||
$request = $this->getRequest();
|
||||
$reference = $request->getParam('reference');
|
||||
$criteres = $request->getParam('criteres');
|
||||
|
||||
$db = Zend_Registry::get('db');
|
||||
$profilM = new Application_Model_Profil($db);
|
||||
$data = array(
|
||||
'reference' => $reference,
|
||||
'criteres' => json_encode($criteres),
|
||||
);
|
||||
|
||||
$id = $request->getParam('id', null);
|
||||
if ( $id != null ) {
|
||||
if ( $profilM->update($data, 'id='.$id) ){
|
||||
echo '';
|
||||
} else {
|
||||
echo 'Erreur';
|
||||
}
|
||||
} else {
|
||||
if ( $profilM->insert($data) ){
|
||||
echo '';
|
||||
} else {
|
||||
echo 'Erreur';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function setAction()
|
||||
{
|
||||
$this->_helper->layout()->disableLayout();
|
||||
$this->_helper->viewRenderer->setNoRender(true);
|
||||
|
||||
$request = $this->getRequest();
|
||||
$idprofil = $request->getParam('idprofil');
|
||||
$idfile = $request->getParam('idfile');
|
||||
|
||||
$db = Zend_Registry::get('db');
|
||||
|
||||
$commandesM = new Application_Model_Commandes($db);
|
||||
|
||||
$data = array(
|
||||
'idProfil' => $idprofil,
|
||||
);
|
||||
|
||||
if ( $commandesM->update($data, "id=$idfile") ){
|
||||
echo '';
|
||||
} else {
|
||||
echo 'Erreur';
|
||||
}
|
||||
}
|
||||
|
||||
}
|
5
application/models/Commandes.php
Normal file
5
application/models/Commandes.php
Normal file
@ -0,0 +1,5 @@
|
||||
<?php
|
||||
class Application_Model_Commandes extends Zend_Db_Table_Abstract
|
||||
{
|
||||
protected $_name = 'commandes';
|
||||
}
|
6
application/models/Profil.php
Normal file
6
application/models/Profil.php
Normal file
@ -0,0 +1,6 @@
|
||||
<?php
|
||||
class Application_Model_Profil extends Zend_Db_Table_Abstract
|
||||
{
|
||||
protected $_name = 'profil';
|
||||
}
|
||||
|
0
application/views/footer.phtml
Normal file
0
application/views/footer.phtml
Normal file
0
application/views/header.phtml
Normal file
0
application/views/header.phtml
Normal file
20
application/views/main.phtml
Normal file
20
application/views/main.phtml
Normal file
@ -0,0 +1,20 @@
|
||||
<?php echo $this->doctype();?>
|
||||
<html>
|
||||
<head>
|
||||
<?php echo $this->headMeta();?>
|
||||
<?php echo $this->headTitle();?>
|
||||
<?php echo $this->headStyle();?>
|
||||
<?php echo $this->headLink();?>
|
||||
<?php echo $this->headScript();?>
|
||||
</head>
|
||||
<body>
|
||||
<div id="global">
|
||||
<div id="header">
|
||||
<?php echo $this->render('header.phtml') ?>
|
||||
</div>
|
||||
<div id="content">
|
||||
<?php echo $this->layout()->content;?>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
16
application/views/scripts/envoi/checkfile.phtml
Normal file
16
application/views/scripts/envoi/checkfile.phtml
Normal file
@ -0,0 +1,16 @@
|
||||
<div>
|
||||
<?php if (count($this->errors)>0) {?>
|
||||
<?php foreach($this->errors as $error) {?>
|
||||
<p><?=$error?></p>
|
||||
<?php }?>
|
||||
<?php }?>
|
||||
</div>
|
||||
|
||||
<?php if ($this->nb) {?>
|
||||
<div>
|
||||
<p>Votre fichier contient <?=$this->nb?> identifiants</p>
|
||||
</div>
|
||||
<?php }?>
|
||||
<div>
|
||||
<a href="<?=$this->url(array('controller'=>'index', 'action'=>'index'), null, true)?>">Accueil</a>
|
||||
</div>
|
65
application/views/scripts/envoi/fileform.phtml
Normal file
65
application/views/scripts/envoi/fileform.phtml
Normal file
@ -0,0 +1,65 @@
|
||||
<div>
|
||||
|
||||
<h2>Intégration d'un fichier</h2>
|
||||
|
||||
<p>Taille maximale d'un fichier : <?=$this->filesize?></p>
|
||||
|
||||
<form enctype="multipart/form-data" name="sendfile" action="<?=$this->url(array('controller'=>'envoi','action'=>'fileupload'))?>" method="post">
|
||||
<input type="hidden" name="APC_UPLOAD_PROGRESS" id="key" value="<?=uniqid()?>"/>
|
||||
|
||||
<div class="fieldgrp">
|
||||
<label>Sélection d'un client</label>
|
||||
<div class="field">
|
||||
<select name="client">
|
||||
<?php foreach ($this->clients as $client) {?>
|
||||
<option value="<?=$client->id?>"><?=$client->nom?></option>
|
||||
<?php }?>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="fieldgrp">
|
||||
<label>Référence</label>
|
||||
<div class="field"><input type="text" name="ref" /></div>
|
||||
</div>
|
||||
|
||||
<div class="fieldgrp">
|
||||
<label>Fichier</label>
|
||||
<div class="field">
|
||||
<input type="file" id="fichier" name="fichier"/>
|
||||
<input type="submit" value="Envoi"/>
|
||||
|
||||
<div id="progressbar"></div>
|
||||
<div id="output"></div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
|
||||
</div>
|
||||
|
||||
<script>
|
||||
var timer;
|
||||
|
||||
$('form[name=sendfile]').ajaxForm({
|
||||
beforeSubmit: function() {
|
||||
timer = setInterval(checkProgress,200);
|
||||
$('#progressbar').reportprogress(0);
|
||||
$('#output').html('Envoi en cours...');
|
||||
},
|
||||
success: function(data) {
|
||||
clearInterval(timer);
|
||||
$('#progressbar').remove();
|
||||
$('#output').html('<strong>' + data + '</strong>');
|
||||
}
|
||||
});
|
||||
|
||||
function checkProgress() {
|
||||
$.get('<?=$this->url(array('controller'=>'envoi', 'action'=>'fileprogress'))?>',
|
||||
{key: $('#key').val()}, function(data) {
|
||||
var percent = data.current/data.total*100;
|
||||
$('#progressbar').reportprogress(percent);
|
||||
}, 'json');
|
||||
}
|
||||
</script>
|
28
application/views/scripts/error/error.phtml
Normal file
28
application/views/scripts/error/error.phtml
Normal file
@ -0,0 +1,28 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<title>Zend Framework Default Application</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>An error occurred</h1>
|
||||
<h2><?php echo $this->message ?></h2>
|
||||
|
||||
<?php if (isset($this->exception)): ?>
|
||||
|
||||
<h3>Exception information:</h3>
|
||||
<p>
|
||||
<b>Message:</b> <?php echo $this->exception->getMessage() ?>
|
||||
</p>
|
||||
|
||||
<h3>Stack trace:</h3>
|
||||
<pre><?php echo $this->exception->getTraceAsString() ?>
|
||||
</pre>
|
||||
|
||||
<h3>Request Parameters:</h3>
|
||||
<pre><?php echo var_export($this->request->getParams(), true) ?>
|
||||
</pre>
|
||||
<?php endif ?>
|
||||
|
||||
</body>
|
||||
</html>
|
103
application/views/scripts/index/index.phtml
Normal file
103
application/views/scripts/index/index.phtml
Normal file
@ -0,0 +1,103 @@
|
||||
<h1>Enrichissement</h1>
|
||||
|
||||
<p>
|
||||
<a href="<?=$this->url(array('controller'=>'envoi', 'action'=>'fileform'))?>">Envoi d'un fichier CSV</a>
|
||||
</p>
|
||||
<p>
|
||||
<a href="<?=$this->url(array('controller'=>'profil', 'action'=>'index'))?>">Gestion des profils d'enrichissement</a>
|
||||
</p>
|
||||
|
||||
<h2>En attente de profil</h2>
|
||||
<div>
|
||||
<?php if (count($this->fileAttenteProfil)) {?>
|
||||
<table>
|
||||
<thead>
|
||||
<tr><th>Fichier</th><th>Profil</th></tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach($this->fileAttenteProfil as $file) {?>
|
||||
<tr><td><?=$file->fichier?></td>
|
||||
<td>
|
||||
<select name="profil">
|
||||
<option value="" selected>-</option>
|
||||
<?php if (count($this->listProfil)>0) { ?>
|
||||
<?php foreach($this->listProfil as $profil) {?>
|
||||
<option value="<?=$profil->id?>"><?=$profil->reference?></option>
|
||||
<?php }?>
|
||||
<?php }?>
|
||||
</select>
|
||||
<a class="setprofil" href="<?=$this->url(array('controller'=>'profil', 'action'=>'set', 'idfile'=>$file->id))?>">Ok</a>
|
||||
</td>
|
||||
</tr>
|
||||
<?php }?>
|
||||
</tbody>
|
||||
</table>
|
||||
<?php } else {?>
|
||||
<p>Vide</p>
|
||||
<?php }?>
|
||||
</div>
|
||||
|
||||
<h2>Enrichissements en cours</h2>
|
||||
<div>
|
||||
<?php if (count($this->fileEnCours)) {?>
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Fichier</th>
|
||||
<th>Date Ajout</th>
|
||||
<th>Lignes Traités</th>
|
||||
<th>Lignes Total</th>
|
||||
<th>Message d'erreur</th>
|
||||
<th>Action</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach($this->fileEnCours as $file) {?>
|
||||
<tr id="<?=$file->id?>" class="encours">
|
||||
<td><?=$file->fichier?></td>
|
||||
<td><?=$file->dateAdded?></td>
|
||||
<td class="ligne"><?=$file->nbLigneT?></td>
|
||||
<td><?=$file->nbLigne?></td>
|
||||
<td><?=$file->error?></td>
|
||||
<td>
|
||||
<a class="restart" href="<?=$this->url(array('action'=>'restart', 'id'=>$file->id))?>">Remise à zéro et redémarrage</a>
|
||||
<?php if ( !empty($file->error) ) {?>
|
||||
| <a class="reprise" href="<?=$this->url(array('action'=>'reprise', 'id'=>$file->id))?>">Reprise manuelle sur erreur</a>
|
||||
<?php }?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php }?>
|
||||
</tbody>
|
||||
</table>
|
||||
<?php } else {?>
|
||||
<p>Vide</p>
|
||||
<?php }?>
|
||||
</div>
|
||||
|
||||
<h2>Enrichissements terminés</h2>
|
||||
<div>
|
||||
<?php if (count($this->fileFinish)) {?>
|
||||
|
||||
<table>
|
||||
<thead>
|
||||
<tr><th>Fichier</th><th>Date</th><th>Date Fin</th><th>Lignes total</th><th>Fichier enrichi</th></tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach($this->fileFinish as $file) {?>
|
||||
<tr>
|
||||
<td><?=$file->fichier?></td>
|
||||
<td><?=$file->dateAdded?></td>
|
||||
<td><?=$file->dateStop?></td>
|
||||
<td><?=$file->nbLigneT?></td>
|
||||
<td>
|
||||
<a href="<?=$this->url(array('controller'=>'index','action'=>'getfile', 'file'=>$file->fichierOut))?>">
|
||||
<?=$file->fichierOut?></a>
|
||||
</td>
|
||||
</tr>
|
||||
<?php }?>
|
||||
</tbody>
|
||||
</table>
|
||||
<?php } else {?>
|
||||
<p>Vide</p>
|
||||
<?php }?>
|
||||
</div>
|
1
application/views/scripts/index/restart.phtml
Normal file
1
application/views/scripts/index/restart.phtml
Normal file
@ -0,0 +1 @@
|
||||
<a href="<?=$this->url(array('controller'=>'index', 'action'=>'index'))?>">Retour</a>
|
146
application/views/scripts/profil/create.phtml
Normal file
146
application/views/scripts/profil/create.phtml
Normal file
@ -0,0 +1,146 @@
|
||||
<style>
|
||||
div#entete {
|
||||
width:45%;
|
||||
float:left;
|
||||
border:1px solid #bebebe;
|
||||
height:500px;
|
||||
overflow:auto;
|
||||
margin:5px 0;
|
||||
}
|
||||
|
||||
div#entete li {
|
||||
background-color:#4D90FE;
|
||||
border-top:2px solid #ffffff;
|
||||
border-bottom:2px solid #ffffff;
|
||||
line-height:20px;
|
||||
font-weight:bold;
|
||||
color:#000000;
|
||||
margin-left:30px;
|
||||
padding:5px 10px;
|
||||
}
|
||||
|
||||
div#dico {
|
||||
width:45%;
|
||||
height:500px;
|
||||
float:right;
|
||||
border:1px solid #bebebe;
|
||||
overflow:auto;
|
||||
margin:5px 0;
|
||||
}
|
||||
|
||||
div#dico li {
|
||||
list-style-type:none;
|
||||
padding:5px 10px;
|
||||
background-color:#4D90FE;
|
||||
border-top:2px solid #ffffff;
|
||||
border-bottom:2px solid #ffffff;
|
||||
line-height:20px;
|
||||
font-weight:bold;
|
||||
color:#000000;
|
||||
}
|
||||
|
||||
input[type="text"] {
|
||||
border:1px solid;
|
||||
}
|
||||
</style>
|
||||
|
||||
<div id="entete">
|
||||
<h1 class="ui-widget-header">Entete</h1>
|
||||
<div class="ui-widget-content">
|
||||
<ol>
|
||||
<?php if (count($this->criteres)==0) {?>
|
||||
<span class="placeholder">Placer les elements ici</span>
|
||||
<?php } else {?>
|
||||
<?php foreach($this->criteres as $key => $element) {?>
|
||||
<li id="<?=$key?>">
|
||||
<?php if (isset($element['lib'])) { echo $element['lib']; } else { echo $key; }?>
|
||||
<?php if (isset($element['values']) && $element['values']!==false ) {
|
||||
echo "<input type=\"text\" name=\"".$key."\" value=\"".$element['values']."\"/>"; }?>
|
||||
</li>
|
||||
<?php }?>
|
||||
<?php }?>
|
||||
</ol>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="dico">
|
||||
<h1 class="ui-widget-header">Elements disponibles</h1>
|
||||
<ul>
|
||||
<?php foreach($this->elements as $key => $element) {?>
|
||||
<li id="<?=$key?>">
|
||||
<?php if (isset($element['lib'])) { echo $element['lib']; } else { echo $key; }?>
|
||||
<?php if (isset($element['values'])) { echo "<input type=\"text\" name=\"".$key."\" value=\"\"/>"; }?>
|
||||
</li>
|
||||
<?php }?>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div style="clear:both;">
|
||||
Référence <input type="text" name="profil" value="<?=$this->reference?>" />
|
||||
|
||||
<?php if ($this->edit) { ?>
|
||||
<a id="save" href="<?=$this->url(array('controller'=>'profil', 'action'=>'save', 'id'=>$this->id))?>">Modifier</a>
|
||||
<?php } else {?>
|
||||
<a id="save" href="<?=$this->url(array('controller'=>'profil', 'action'=>'save'))?>">Sauvegarder</a>
|
||||
<?php }?>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
$(function() {
|
||||
$("#dico li").draggable({
|
||||
appendTo: "body",
|
||||
helper: "clone"
|
||||
});
|
||||
$("#entete ol").droppable({
|
||||
activeClass: "ui-state-default",
|
||||
hoverClass: "ui-state-hover",
|
||||
accept: ":not(.ui-sortable-helper)",
|
||||
drop: function( e, ui ) {
|
||||
e.preventDefault();
|
||||
$( this ).find( ".placeholder" ).remove();
|
||||
var id = ui.draggable.attr('id');
|
||||
$('<li id="'+id+'"></li>').html( ui.draggable.html() ).appendTo( this );
|
||||
}
|
||||
}).sortable({
|
||||
items: "li:not(.placeholder)",
|
||||
sort: function() {
|
||||
$( this ).removeClass( "ui-state-default" );
|
||||
}
|
||||
});
|
||||
|
||||
$("#entete").delegate("a.delete","click", function(e){
|
||||
e.preventDefault();
|
||||
$(this).parent().remove();
|
||||
});
|
||||
|
||||
$("#entete ol").delegate("li" , "hover", function(e) {
|
||||
e.preventDefault();
|
||||
if (e.type === 'mouseenter') {
|
||||
var html = $(this).html();
|
||||
$(this).html(html+'<a href="#" style="float:right;" class="delete">Supprimer</a>');
|
||||
} else {
|
||||
$( this ).find( ".delete" ).remove();
|
||||
}
|
||||
});
|
||||
|
||||
$('#save').click(function(e){
|
||||
e.preventDefault();
|
||||
var url = $(this).attr('href');
|
||||
var list = new Array();
|
||||
$('#entete ol li').each(function(index){
|
||||
var id = $(this).attr('id');
|
||||
if($('input[name='+id+']', this).length>0){
|
||||
id = id + '(' + $('input[name='+id+']', this).val() + ')';
|
||||
}
|
||||
list.push(id);
|
||||
});
|
||||
var ref = $('input[name=profil]').val();
|
||||
if (ref!='') {
|
||||
$.post(url, { reference: ref, criteres: list }, function(data){
|
||||
if (data!='Erreur'){ window.location.href = '/'; }
|
||||
}, 'json');
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
</script>
|
8
application/views/scripts/profil/detail.phtml
Normal file
8
application/views/scripts/profil/detail.phtml
Normal file
@ -0,0 +1,8 @@
|
||||
<div>
|
||||
<h2>Profil : <?=$this->reference?></h2>
|
||||
<ol>
|
||||
<?php foreach ($this->profil as $item) {?>
|
||||
<li><?=$item?></li>
|
||||
<?php }?>
|
||||
</ol>
|
||||
</div>
|
29
application/views/scripts/profil/index.phtml
Normal file
29
application/views/scripts/profil/index.phtml
Normal file
@ -0,0 +1,29 @@
|
||||
<div>
|
||||
<h2>Gestion des profils</h2>
|
||||
<?php if (count($this->profils)>0) {?>
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Référence</th>
|
||||
<th>Action</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach($this->profils as $profil) {?>
|
||||
<tr>
|
||||
<td><a href="<?=$this->url(array('controller'=>'profil', 'action'=>'detail', 'id'=>$profil->id))?>"><?=$profil->reference?></a></td>
|
||||
<td><a href="<?=$this->url(array('controller'=>'profil', 'action'=>'create', 'id'=>$profil->id))?>">Edition</a></td>
|
||||
</tr>
|
||||
<?php }?>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<?php } else {?>
|
||||
Aucun profils d'enrichissement.
|
||||
<?php }?>
|
||||
</div>
|
||||
|
||||
<p>
|
||||
<a href="<?=$this->url(array('controller'=>'profil', 'action'=>'create'))?>">Créer un nouveau profil</a>
|
||||
</p>
|
||||
|
0
application/views/scripts/profil/save.phtml
Normal file
0
application/views/scripts/profil/save.phtml
Normal file
75
batch/cron.php
Normal file
75
batch/cron.php
Normal file
@ -0,0 +1,75 @@
|
||||
#!/usr/bin/php
|
||||
<?php
|
||||
// Define path to application directory
|
||||
defined('APPLICATION_PATH')
|
||||
|| define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../application'));
|
||||
|
||||
// Define application environment
|
||||
defined('APPLICATION_ENV')
|
||||
|| define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'production'));
|
||||
|
||||
// Ensure library/ is on include_path
|
||||
set_include_path(implode(PATH_SEPARATOR, array(
|
||||
realpath(APPLICATION_PATH . '/../library'),
|
||||
get_include_path(),
|
||||
)));
|
||||
|
||||
/** Zend_Application */
|
||||
require_once 'Zend/Application.php';
|
||||
|
||||
// Create application, bootstrap, and run
|
||||
$application = new Zend_Application(
|
||||
APPLICATION_ENV,
|
||||
APPLICATION_PATH . '/configs/application.ini'
|
||||
);
|
||||
|
||||
try {
|
||||
$opts = new Zend_Console_Getopt(
|
||||
//Options
|
||||
array(
|
||||
'help|?' => "Aide.",
|
||||
)
|
||||
);
|
||||
$opts->parse();
|
||||
} catch (Zend_Console_Getopt_Exception $e) {
|
||||
echo $e->getUsageMessage();
|
||||
exit;
|
||||
}
|
||||
|
||||
//Usage
|
||||
if(isset($opts->help))
|
||||
{
|
||||
echo $opts->getUsageMessage();
|
||||
exit;
|
||||
}
|
||||
|
||||
$dbConfig = new Zend_Config_Ini(APPLICATION_PATH . '/configs/configuration.ini', 'databases');
|
||||
$db = Zend_Db::factory($dbConfig->db);
|
||||
|
||||
$commandesM = new Application_Model_Commandes($db);
|
||||
|
||||
$sql = $commandesM->select()
|
||||
->where('idProfil != ?', 0)
|
||||
->where("dateStart != '0000-00-00 00:00:00'")
|
||||
->where("dateStop = '0000-00-00 00:00:00'");
|
||||
$result = $commandesM->fetchAll($sql);
|
||||
if ( count($result)>0 ) {
|
||||
|
||||
|
||||
|
||||
} else {
|
||||
|
||||
//Si pas de traitement en cours alors on lance
|
||||
$sql = $commandesM->select()
|
||||
->where('idProfil != ?', 0)
|
||||
->where("dateStart = '0000-00-00 00:00:00'")
|
||||
->where("dateStop = '0000-00-00 00:00:00'")
|
||||
->order('dateAdded ASC')->limit(1);
|
||||
$result = $commandesM->fetchAll($sql);
|
||||
if (count($result)>0) {
|
||||
$info = $result->current();
|
||||
echo "Lancement enrichissement $info->id\n";
|
||||
exec(realpath(dirname(__FILE__))."/enrichissement.php --id ".$info->id." &");
|
||||
}
|
||||
|
||||
}
|
1275
batch/enrichissement.php
Normal file
1275
batch/enrichissement.php
Normal file
File diff suppressed because it is too large
Load Diff
14
config/_sql/commandes.sql
Normal file
14
config/_sql/commandes.sql
Normal file
@ -0,0 +1,14 @@
|
||||
CREATE TABLE IF NOT EXISTS `commandes` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`fichier` varchar(100) NOT NULL,
|
||||
`idProfil` int(11) NOT NULL,
|
||||
`nbLigne` int(11) NOT NULL,
|
||||
`nbLigneT` int(11) NOT NULL,
|
||||
`uniteInsee` int(11) NOT NULL DEFAULT '0',
|
||||
`error` varchar(100) NOT NULL,
|
||||
`dateAdded` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
|
||||
`dateStart` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
|
||||
`dateStop` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
|
||||
`fichierOut` varchar(100) NOT NULL DEFAULT '',
|
||||
PRIMARY KEY (`id`)
|
||||
) DEFAULT CHARSET=utf8;
|
6
config/_sql/profil.sql
Normal file
6
config/_sql/profil.sql
Normal file
@ -0,0 +1,6 @@
|
||||
CREATE TABLE IF NOT EXISTS `profil` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`reference` varchar(50) NOT NULL,
|
||||
`criteres` longtext NOT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
) DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
|
3
config/config.php
Normal file
3
config/config.php
Normal file
@ -0,0 +1,3 @@
|
||||
<?php
|
||||
require_once realpath(dirname(__FILE__)).'/mysql.php';
|
||||
require_once realpath(dirname(__FILE__)).'/stockage.php';
|
75
config/configure.php
Normal file
75
config/configure.php
Normal file
@ -0,0 +1,75 @@
|
||||
#!/usr/bin/php
|
||||
<?php
|
||||
|
||||
// Paramètres
|
||||
if ( $argc < 1 || in_array($argv[1], array('--help', '-help', '-h', '-?')) ) {
|
||||
?>
|
||||
Installation
|
||||
Avec les options --help, -help, -h, et -?, vous obtiendrez cette aide.
|
||||
|
||||
Utilisation : <?php echo $argv[0]; ?> [action]
|
||||
|
||||
action :
|
||||
--install : Configuration
|
||||
|
||||
<?php
|
||||
exit;
|
||||
}
|
||||
|
||||
$action = $argv[1];
|
||||
$hostname = exec('echo $(hostname)');
|
||||
$wwwroot = realpath(dirname(__FILE__).'/../../');
|
||||
|
||||
switch ($action)
|
||||
{
|
||||
case '--install':
|
||||
writeConfig();
|
||||
changePermission();
|
||||
break;
|
||||
}
|
||||
|
||||
/**
|
||||
* Vérfie si l'utilisateur est ROOT
|
||||
*/
|
||||
function isRoot()
|
||||
{
|
||||
$uid = exec('echo $(id -u)');
|
||||
if ((int) $uid == 0){
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function changePermission()
|
||||
{
|
||||
passthru('chown -R www-data: '.realpath(dirname(__FILE__).'/../'));
|
||||
passthru('chmod -R +x '.realpath(dirname(__FILE__).'/../batch/').'/*.php');
|
||||
}
|
||||
|
||||
function changePrimarySymlink()
|
||||
{
|
||||
global $wwwroot;
|
||||
passthru('rm '.$wwwroot.'/webservice');
|
||||
passthru('ln -s '.realpath(dirname(__FILE__).'/../').' '.$wwwroot.'/webservice');
|
||||
}
|
||||
|
||||
function writeConfig()
|
||||
{
|
||||
global $hostname;
|
||||
|
||||
$arrayConfig = array(
|
||||
'mysql.php',
|
||||
'stockage.php',
|
||||
);
|
||||
foreach($arrayConfig as $config) {
|
||||
passthru('cp -v '.
|
||||
realpath(dirname(__FILE__)).'/'.$hostname.'/'.$config.' ' .
|
||||
realpath(dirname(__FILE__)).'/'.$config);
|
||||
}
|
||||
passthru('cp -v '.
|
||||
realpath(dirname(__FILE__)).'/'.$hostname.'/configuration.ini'.' '.
|
||||
realpath(dirname(__FILE__)).'/../application/configs/configuration.ini');
|
||||
|
||||
}
|
||||
|
22
config/local/configuration.ini
Normal file
22
config/local/configuration.ini
Normal file
@ -0,0 +1,22 @@
|
||||
[server]
|
||||
name = sdsrvdev01
|
||||
|
||||
[databases]
|
||||
db.adapter=mysqli
|
||||
db.params.host=127.0.0.1
|
||||
db.params.username=root
|
||||
db.params.password=password
|
||||
db.params.dbname=enrichissement
|
||||
db.params.driver_options.MYSQLI_INIT_COMMAND = "SET NAMES utf8"
|
||||
|
||||
[mail]
|
||||
method = smtp
|
||||
smpt_port =
|
||||
smtp_host = smtp.free.fr
|
||||
support = mricois@scores-decisions.com
|
||||
supportdev = mricois@scores-decisions.com
|
||||
contact = mricois@scores-decisions.com
|
||||
production = mricois@scores-decisions.com
|
||||
|
||||
[path]
|
||||
data = "d:\www\dataenrichissement"
|
9
config/local/mysql.php
Normal file
9
config/local/mysql.php
Normal file
@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
// Base de données de S&D
|
||||
define('MYSQL_HOST', '88.190.14.56');
|
||||
define('MYSQL_PORT', '53336');
|
||||
define('MYSQL_USER', 'wsuser');
|
||||
define('MYSQL_PASS', 'wspass2012');
|
||||
define('MYSQL_DEFAULT_DB', 'jo');
|
||||
define('MYSQL_SQL_LOG', 'NONE');
|
22
config/sdsrvdev01/configuration.ini
Normal file
22
config/sdsrvdev01/configuration.ini
Normal file
@ -0,0 +1,22 @@
|
||||
[server]
|
||||
name = sdsrvdev01
|
||||
|
||||
[databases]
|
||||
db.adapter=mysqli
|
||||
db.params.host=127.0.0.1
|
||||
db.params.username=enrichissement
|
||||
db.params.password=aY5EWvtMmXrqKwK8
|
||||
db.params.dbname=enrichissement
|
||||
db.params.driver_options.MYSQLI_INIT_COMMAND = "SET NAMES utf8"
|
||||
|
||||
[mail]
|
||||
method = smtp
|
||||
smpt_port =
|
||||
smtp_host = smtp.free.fr
|
||||
support = mricois@scores-decisions.com
|
||||
supportdev = mricois@scores-decisions.com
|
||||
contact = mricois@scores-decisions.com
|
||||
production = mricois@scores-decisions.com
|
||||
|
||||
[path]
|
||||
data = "/sites/dataenrichissement"
|
9
config/sdsrvdev01/mysql.php
Normal file
9
config/sdsrvdev01/mysql.php
Normal file
@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
// Base de données de S&D
|
||||
define('MYSQL_HOST', '88.190.14.56');
|
||||
define('MYSQL_PORT', '53336');
|
||||
define('MYSQL_USER', 'wsuser');
|
||||
define('MYSQL_PASS', 'wspass2012');
|
||||
define('MYSQL_DEFAULT_DB', 'jo');
|
||||
define('MYSQL_SQL_LOG', 'NONE');
|
8
config/sdsrvdev01/stockage.php
Normal file
8
config/sdsrvdev01/stockage.php
Normal file
@ -0,0 +1,8 @@
|
||||
<?php
|
||||
/** Dossiers locaux pour les documents a telecharger (PDF kbis, marques, etc...) **/
|
||||
define('DOC_WEB_LOCAL', '/sites/dataenrichissement/');
|
||||
define('DOC_WEB_URL', '/data/');
|
||||
|
||||
/** LOGGING **/
|
||||
define('LOG_PATH', '/sites/dataenrichissement/log');
|
||||
|
8
config/stockage.php
Normal file
8
config/stockage.php
Normal file
@ -0,0 +1,8 @@
|
||||
<?php
|
||||
/** Dossiers locaux pour les documents a telecharger (PDF kbis, marques, etc...) **/
|
||||
define('DOC_WEB_LOCAL', realpath('d:/www/dataenrichissement/').'/');
|
||||
define('DOC_WEB_URL', '/data/');
|
||||
|
||||
/** LOGGING **/
|
||||
define('LOG_PATH', realpath('d:/www/dataenrichissement/log/'));
|
||||
|
85
library/Metier/bodacc/classMBalo.php
Normal file
85
library/Metier/bodacc/classMBalo.php
Normal file
@ -0,0 +1,85 @@
|
||||
<?
|
||||
class MBalo {
|
||||
|
||||
function getLibEven($strEven) {
|
||||
$even=9015;
|
||||
$strEven=trim($strEven);
|
||||
if (preg_match("/AUTRES OP.RATIONS . Décisions prises par des assemblées d'obligataires et homologation de résolutions/i", $strEven)) $even=9001;
|
||||
elseif (preg_match("/AUTRES OP.RATIONS . Désignation de teneurs? de comptes de titres nominatifs/i", $strEven)) $even=9002;
|
||||
elseif (preg_match("/AUTRES OP.RATIONS . Fusions et scissions/i", $strEven)) $even=9003;
|
||||
elseif (preg_match("/AUTRES OP.RATIONS . Liquidations/i", $strEven)) $even=9004;
|
||||
elseif (preg_match("/AUTRES OP.RATIONS . Offre de remboursement d'obligations/i", $strEven)) $even=9005;
|
||||
elseif (preg_match("/AUTRES OP.RATIONS . Réduction de capital/i", $strEven)) $even=9006;
|
||||
elseif (preg_match("/AUTRES OP.RATIONS . Regroupement d'actions/i", $strEven)) $even=9007;
|
||||
elseif (preg_match("/AUTRES OP.RATIONS/i", $strEven)) $even=9000;
|
||||
elseif (preg_match("/BULLETIN OFFICIEL de l'AMF/i", $strEven)) $even=9010;
|
||||
elseif (preg_match("/BULLETIN OFFICIEL du CMF/i", $strEven)) $even=9011;
|
||||
elseif (preg_match("/CONVOCATIONS . Assemblées? d'actionnaires et de porteurs de parts/i", $strEven)) $even=9020;
|
||||
elseif (preg_match("/CONVOCATIONS . Assemblées? d'obligataires ou de porteurs de titres d'emprunt/i", $strEven)) $even=9021;
|
||||
elseif (preg_match("/CONVOCATIONS . Assemblées? de porteurs de certificats d'investissement/i", $strEven)) $even=9022;
|
||||
elseif (preg_match("/CONVOCATIONS . Assemblées? de porteurs de parts de fondateur/i", $strEven)) $even=9023;
|
||||
elseif (preg_match("/CONVOCATIONS . Assemblées? de porteurs de titres participatifs/i", $strEven)) $even=9024;
|
||||
elseif (preg_match("/MISSIONS ET COTATIONS - Organismes internationaux - Bons, obligations et autres titres/i", $strEven)) $even=9030;
|
||||
elseif (preg_match("/MISSIONS ET COTATIONS . Valeurs étrangères . Actions et parts/i", $strEven)) $even=9031;
|
||||
elseif (preg_match("/MISSIONS ET COTATIONS . Valeurs étrangères . Bons d'options? sur titres et sur indices/i", $strEven)) $even=9032;
|
||||
elseif (preg_match("/MISSIONS ET COTATIONS . Valeurs étrangères . Bons, obligations et autres titres/i", $strEven)) $even=9033;
|
||||
elseif (preg_match("/MISSIONS ET COTATIONS . Valeurs européennes . Actions et parts/i", $strEven)) $even=9034;
|
||||
elseif (preg_match("/MISSIONS ET COTATIONS . Valeurs françaises . Actions et parts/i", $strEven)) $even=9035;
|
||||
elseif (preg_match("/MISSIONS ET COTATIONS . Valeurs françaises . Bons d'options? sur titres et sur indices/i", $strEven)) $even=9036;
|
||||
elseif (preg_match("/MISSIONS ET COTATIONS . Valeurs françaises . Bons, obligations et autres titres/i", $strEven)) $even=9037;
|
||||
elseif (preg_match("/MISSIONS ET COTATIONS . Valeurs françaises . Certificats d'investissement/i", $strEven)) $even=9038;
|
||||
elseif (preg_match("/PUBLICATIONS P.RIODIQUES . Entreprises d'assurances et organismes de retraites/i", $strEven)) $even=9040;
|
||||
elseif (preg_match("/PUBLICATIONS P.RIODIQUES . Sociétés commerciales et industrielles/i", $strEven)) $even=9041;
|
||||
elseif (preg_match("/PUBLICATIONS P.RIODIQUES . Sociétés commerciales et industrielles (Chiffres d'affaires)/i", $strEven)) $even=9042;
|
||||
elseif (preg_match("/PUBLICATIONS P.RIODIQUES . Sociétés commerciales et industrielles (comptes annuels)/i", $strEven)) $even=9045;
|
||||
elseif (preg_match("/PUBLICATIONS P.RIODIQUES . Sociétés commerciales et industrielles (Tableaux d'activités et résultats)/i", $strEven)) $even=9044;
|
||||
elseif (preg_match("/PUBLICATIONS P.RIODIQUES . Sociétés commerciales et industrielles (Chiffres d'affaires et situations trimestrielles)/i", $strEven))$even=9043;
|
||||
elseif (preg_match("/PUBLICATIONS P.RIODIQUES . Sociétés commerciales et industrielles (Comptes intermédiaires)/i", $strEven)) $even=9046;
|
||||
//else/*if (preg_match("/AVIS DIVERS/i", $strEven))*/ $even=9015;
|
||||
|
||||
return $even;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class MBoamp {
|
||||
|
||||
function getCodEvenSd($codEvenBoamp, $strEvenBoamp='') {
|
||||
$codEvenBoamp=str_replace('R','',$codEvenBoamp)*1;
|
||||
switch ($codEvenBoamp) {
|
||||
case 10: $libEvenSd='Annulation'; break;
|
||||
case 11: $libEvenSd='Annulation - Rectificatif'; break;
|
||||
case 20: $libEvenSd='Rectificatif'; break;
|
||||
case 22: $libEvenSd='Procédures accélérées'; break;
|
||||
case 30: $libEvenSd='Avis d\'appel public à la concurrence - Délai d\'urgence'; break;
|
||||
case 33: $libEvenSd='Avis de mise en concurrence'; break;
|
||||
case 44: $libEvenSd='Concessions'; break;
|
||||
case 50: $libEvenSd='Avis d\'appel public à la concurrence'; break;
|
||||
case 51: $libEvenSd='Avis informatifs'; break;
|
||||
case 55: $libEvenSd='Avis d\'appel public à la concurrence'; break;
|
||||
case 6 : $libEvenSd='Avis d\'attribution'; break;
|
||||
case 8 : $libEvenSd='Avis d\'attribution'; break;
|
||||
case 81: $libEvenSd='Avis d\'attribution - Annulation'; break;
|
||||
case 82: $libEvenSd='Avis d\'attribution - Rectificatif'; break;
|
||||
case 83: $libEvenSd='Avis d\'attribution - Rectificatif'; break;
|
||||
case 84: $libEvenSd='Avis d\'attribution comportant des lots infructueux'; break;
|
||||
case 9 : $libEvenSd='Résultat de marché'; break;
|
||||
case 91: $libEvenSd='Résultat de marché - Annulation'; break;
|
||||
case 92: $libEvenSd='Résultat de marché - Rectificatif'; break;
|
||||
case 93: $libEvenSd='Résultat de marché Infructueux/Sans suite'; break;
|
||||
case 94: $libEvenSd='Résultat de marché comportant des lots infructueux'; break;
|
||||
case 96: $libEvenSd='Annulation/Rectificatif/Sans suite/Infructueux'; break;
|
||||
default: $libEvenSd=$strEvenBoamp; break;
|
||||
}
|
||||
if ($strEvenBoamp<>'') return $libEvenSd;
|
||||
|
||||
return substr('95'.$codEvenBoamp.'00',0,4)*1;
|
||||
}
|
||||
|
||||
function getLibEvenBoamp($codEvenBoamp, $strEvenBoamp='') {
|
||||
return $this->getCodEvenSd($codEvenBoamp, $strEvenBoamp);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
1249
library/Metier/bodacc/classMBodacc.php
Normal file
1249
library/Metier/bodacc/classMBodacc.php
Normal file
File diff suppressed because it is too large
Load Diff
3355
library/Metier/bodacc/configMBodacc.php
Normal file
3355
library/Metier/bodacc/configMBodacc.php
Normal file
File diff suppressed because it is too large
Load Diff
302
library/Metier/common/ICotation.inc
Normal file
302
library/Metier/common/ICotation.inc
Normal file
@ -0,0 +1,302 @@
|
||||
<?php
|
||||
|
||||
class ICotation {
|
||||
|
||||
var $reTrtAuto;
|
||||
var $tabBilan;
|
||||
|
||||
var $tabNotation;
|
||||
var $tabLibActivite;
|
||||
var $tabActivite;
|
||||
var $tabR;
|
||||
|
||||
|
||||
function ICotation ($tabBilan, $retraitementAutomatique=true) {
|
||||
$this->reTrtAuto = $retraitementAutomatique;
|
||||
$this->tabBilan = $tabBilan;
|
||||
|
||||
include ('paramCotation.inc');
|
||||
}
|
||||
|
||||
function calculProvisionsPourRisque () {
|
||||
if ( !$this->reTrtAuto )
|
||||
return $this->tabBilan['DP'] + $this->tabBilan['DQ'] - $this->tabBilan['X04'];
|
||||
else
|
||||
return (1/2*$this->tabBilan['DP'])+(1/2*$this->tabBilan['DQ']);
|
||||
}
|
||||
|
||||
function calculEBE () {
|
||||
return $this->tabBilan['FC'] + $this->tabBilan['FF'] + $this->tabBilan['FI'] + $this->tabBilan['FOB']
|
||||
+ $this->tabBilan['FM'] + $this->tabBilan['FN'] - $this->tabBilan['FC'] + $this->tabBilan['FC']
|
||||
- ( $this->tabBilan['FS'] + $this->tabBilan['FT'] + $this->tabBilan['FU'] + $this->tabBilan['FV'] )
|
||||
- ( $this->tabBilan['FW'] - $this->tabBilan['HP'] - $this->tabBilan['HQ'] - $this->tabBilan['HP2'] - $this->tabBilan['HQ2'] )
|
||||
- $this->tabBilan['FX'] - ( $this->tabBilan['FY'] + $this->tabBilan['FZ'] ) + ( $this->tabBilan['FO'] - $this->tabBilan['FOB'] ) ;
|
||||
}
|
||||
|
||||
function calculChiffreAffaires () {
|
||||
return $this->tabBilan['FC']
|
||||
+ $this->tabBilan['FF']
|
||||
+ $this->tabBilan['FI']
|
||||
+ $this->tabBilan['FO']
|
||||
- $this->tabBilan['FOB'] ;
|
||||
}
|
||||
|
||||
function calculMargeCommerciale () {
|
||||
return $this->tabBilan['FC'] - ( $this->tabBilan['FS'] + $this->tabBilan['FT'] ) ;
|
||||
}
|
||||
|
||||
function calculProduction () {
|
||||
return $this->tabBilan['FF'] + $this->tabBilan['FI'] + $this->tabBilan['FM'] + $this->tabBilan['FN'] ;
|
||||
}
|
||||
|
||||
function calculValeurAjoutee () {
|
||||
return $this->calculMargeCommerciale() + $this->calculProduction()
|
||||
- ( $this->tabBilan['FU'] + $this->tabBilan['FV'] + $this->tabBilan['FW'] ) ;
|
||||
}
|
||||
|
||||
function calculEBEnonCASA () {
|
||||
return $this->calculValeurAjoutee() + $this->tabBilan['FO'] - $this->tabBilan['FX'] - ( $this->tabBilan['FY'] + $this->tabBilan['FZ'] ) ;
|
||||
}
|
||||
|
||||
function calculFondsPropresNetsCorriges() {
|
||||
return $this->tabBilan['DA'] + $this->tabBilan['DC'] + $this->tabBilan['DB'] + $this->tabBilan['DD'] + $this->tabBilan['DE'] + $this->tabBilan['DF'] + $this->tabBilan['DG'] + $this->tabBilan['DK'] - (1/3*$this->tabBilan['X01'])
|
||||
+ $this->tabBilan['DH'] + $this->tabBilan['DI'] + $this->tabBilan['DJ']
|
||||
- $this->tabBilan['CL'] - $this->tabBilan['AB'] + $this->tabBilan['AC'] - $this->tabBilan['AA'] - $this->tabBilan['CB'] + $this->tabBilan['CC'] - $this->tabBilan['X02'] - $this->tabBilan['CM'] - $this->tabBilan['CN']
|
||||
+ $this->tabBilan['DM'] + $this->tabBilan['DN']
|
||||
- $this->tabBilan['X03'] + $this->calculProvisionsPourRisque() - $this->tabBilan['RAD'] ;
|
||||
}
|
||||
|
||||
function calculDettesFinancieresBancairesBrutes () {
|
||||
return $this->tabBilan['DS'] - $this->tabBilan['CM1'] + $this->tabBilan['EI'] - $this->tabBilan['CM2']
|
||||
+ $this->tabBilan['DT'] - $this->tabBilan['CM3'] + $this->tabBilan['DU'] - $this->tabBilan['EH']
|
||||
+ (3/4*$this->tabBilan['YQ']) + (2/3*$this->tabBilan['YR'])
|
||||
+ (3/4*$this->tabBilan['YQ2']) + (2/3*$this->tabBilan['YR2'])
|
||||
+ $this->tabBilan['DV'] - $this->tabBilan['EI'] - $this->tabBilan['DVI1'] - $this->tabBilan['CM2']
|
||||
+ $this->tabBilan['YS'] + $this->tabBilan['X08']
|
||||
+ $this->tabBilan['EH'] + $this->tabBilan['VI1'] - ( $this->tabBilan['X20'] + $this->tabBilan['X21'] ) ;
|
||||
}
|
||||
|
||||
|
||||
|
||||
function noteCapitalisation () {
|
||||
if ( !$this->reTrtAuto ) {
|
||||
$autresDettesExploit = $this->tabBilan['EA'] - $this->tabBilan['EAVI1'] - $this->tabBilan['EAB'] + $this->tabBilan['EB'] + $this->tabBilan['X01'] + $this->tabBilan['X04'] ;
|
||||
$dettesFiscalesSociales = $this->tabBilan['DY'] - $this->tabBilan['DYA'];
|
||||
} else {
|
||||
$autresDettesExploit = $this->tabBilan['EA'] - $this->tabBilan['EAVI1'] - $this->tabBilan['EAB'] + $this->tabBilan['EB'] + $this->tabBilan['X01'] + 2/3*((1/2*$this->tabBilan['DP'])+(1/2*$this->tabBilan['DQ']));
|
||||
$dettesFiscalesSociales = $this->tabBilan['DY'] + 1/3*((1/2*$this->tabBilan['DP'])+(1/2*$this->tabBilan['DQ'])) - $this->tabBilan['DYA'] ;
|
||||
}
|
||||
|
||||
$numerateur = $this->calculFondsPropresNetsCorriges();
|
||||
|
||||
$denominateur = $numerateur + $this->tabBilan['DS'] - $this->tabBilan['CM1'] + $this->tabBilan['EI'] - $this->tabBilan['CM2'] + $this->tabBilan['DU'] - $this->tabBilan['EH']
|
||||
+ $this->tabBilan['DV'] - $this->tabBilan['DVI1'] - $this->tabBilan['EI'] + $this->tabBilan['DT'] - $this->tabBilan['CM3'] + 3/4*$this->tabBilan['YQ'] + 2/3*$this->tabBilan['YR']
|
||||
+ 3/4*$this->tabBilan['YQ2'] + 2/3*$this->tabBilan['YR2']
|
||||
+ $this->tabBilan['DW'] + $this->tabBilan['DX'] + $dettesFiscalesSociales
|
||||
+ $autresDettesExploit + $this->tabBilan['DZ'] + $this->tabBilan['DIA'] + $this->tabBilan['ED'] + $this->tabBilan['EAB'] + $this->tabBilan['DYA']
|
||||
+ $this->tabBilan['EH'] + $this->tabBilan['YS'] + $this->tabBilan['VI1'];
|
||||
// + $this->tabBilan['X08']
|
||||
// - $this->tabBilan['X20'] + $this->tabBilan['YS'] - $this->tabBilan['X08'];
|
||||
|
||||
if ($denominateur==0)
|
||||
return array('NUMERATEUR'=>$numerateur*100,'DENOMINATEUR'=>$denominateur,'NOTE'=>0);
|
||||
|
||||
return array('NUMERATEUR'=>$numerateur* 100,'DENOMINATEUR'=>$denominateur,'NOTE'=>($numerateur* 100)/$denominateur);
|
||||
}
|
||||
|
||||
function noteLevierEndettement () {
|
||||
|
||||
$numerateur = $this->calculDettesFinancieresBancairesBrutes();
|
||||
|
||||
$denominateur = $this->calculFondsPropresNetsCorriges();
|
||||
|
||||
if ($denominateur==0)
|
||||
return array('NUMERATEUR'=>$numerateur,'DENOMINATEUR'=>$denominateur,'NOTE'=>0);
|
||||
|
||||
return array('NUMERATEUR'=>$numerateur,'DENOMINATEUR'=>$denominateur,'NOTE'=>$numerateur/$denominateur);
|
||||
}
|
||||
|
||||
function noteCapaciteRemboursement () {
|
||||
|
||||
$numerateur = $this->calculDettesFinancieresBancairesBrutes();
|
||||
|
||||
$denominateur = $this->calculEBE();
|
||||
|
||||
if ($denominateur==0)
|
||||
return array('NUMERATEUR'=>$numerateur,'DENOMINATEUR'=>$denominateur,'NOTE'=>0);
|
||||
|
||||
return array('NUMERATEUR'=>$numerateur,'DENOMINATEUR'=>$denominateur,'NOTE'=>$numerateur/$denominateur);
|
||||
}
|
||||
|
||||
function noteCouvChargesFi () {
|
||||
|
||||
$numerateur = $this->calculEBE();
|
||||
|
||||
$denominateur = $this->tabBilan['GR'] + ( 1/4*$this->tabBilan['HP'] + 1/3*$this->tabBilan['HQ'] )
|
||||
+ ( 1/4*$this->tabBilan['HP2'] + 1/3*$this->tabBilan['HQ2'] )
|
||||
+ $this->tabBilan['GS']
|
||||
+ $this->tabBilan['GT']
|
||||
- $this->tabBilan['GJ']
|
||||
- $this->tabBilan['GK']
|
||||
- $this->tabBilan['GL']
|
||||
- $this->tabBilan['GN']
|
||||
- $this->tabBilan['GO']
|
||||
- $this->tabBilan['GH']
|
||||
+ $this->tabBilan['GI'] ;
|
||||
|
||||
if ($denominateur==0)
|
||||
return array('NUMERATEUR'=>$numerateur,'DENOMINATEUR'=>$denominateur,'NOTE'=>0);
|
||||
|
||||
return array('NUMERATEUR'=>$numerateur,'DENOMINATEUR'=>$denominateur,'NOTE'=>$numerateur/$denominateur);
|
||||
}
|
||||
|
||||
function noteTresorerie () {
|
||||
|
||||
$numerateur = $this->tabBilan['CD'] - $this->tabBilan['CE'] + $this->tabBilan['CF'] - $this->tabBilan['CG']
|
||||
- $this->tabBilan['EH'] - ( $this->tabBilan['YS'] + $this->tabBilan['X08'] ) ;
|
||||
|
||||
$denominateur = $this->calculChiffreAffaires();
|
||||
if ($denominateur==0)
|
||||
return array('NUMERATEUR'=>$numerateur*360,'DENOMINATEUR'=>$denominateur,'NOTE'=>0);
|
||||
|
||||
return array('NUMERATEUR'=>$numerateur*360,'DENOMINATEUR'=>$denominateur,'NOTE'=>$numerateur*360/$denominateur);
|
||||
|
||||
}
|
||||
|
||||
function noteMargeExploitation () {
|
||||
|
||||
$numerateur = $this->calculEBE();
|
||||
|
||||
$denominateur = $this->calculChiffreAffaires();
|
||||
|
||||
if ($denominateur==0)
|
||||
return array('NUMERATEUR'=>$numerateur*100,'DENOMINATEUR'=>$denominateur,'NOTE'=>0);
|
||||
|
||||
return array('NUMERATEUR'=>$numerateur*100,'DENOMINATEUR'=>$denominateur,'NOTE'=>$numerateur*100/$denominateur);
|
||||
}
|
||||
|
||||
|
||||
|
||||
function getSecteurActivite($naf) {
|
||||
|
||||
$nbSecteurs=count($this->tabActivite);
|
||||
|
||||
while (strlen($naf) > 1)
|
||||
{
|
||||
for ($i=1; $i<$nbSecteurs; $i++)
|
||||
{
|
||||
for ($j=0; isset($this->tabActivite[$i][$j]); $j++)
|
||||
{
|
||||
if ($this->tabActivite[$i][$j]==$naf)
|
||||
// echo 'NAF '.$naf.' TROUVÉ !<br>';
|
||||
return $i;
|
||||
}
|
||||
}
|
||||
// echo 'NAF '.$naf.' non trouvé !<br>';
|
||||
$naf=substr($naf,0,strlen($naf)-1);
|
||||
}
|
||||
return 17; // Secteur d'activité par défaut si non trouvé
|
||||
}
|
||||
|
||||
function getBorne($note, $borne, $secteur) {
|
||||
|
||||
// print_array($this->tabR[$borne][$secteur],0);
|
||||
for ($j=0; $j<10; $j++)
|
||||
{
|
||||
$tabMinMax=explode(':',$this->tabR[$borne][$secteur][$j]);
|
||||
if ($tabMinMax[0]!='') $min=$tabMinMax[0];
|
||||
else $min=-1E99;
|
||||
if ($tabMinMax[1]!='') $max=$tabMinMax[1];
|
||||
else $max=1E99;
|
||||
|
||||
if ( ( $note>$min && $note<=$max ) )
|
||||
{
|
||||
// echo "TROUVE ++++ $note > ".$tabMinMax[0]." et $note <= ". $tabMinMax[1].'<br/>';
|
||||
if ($j==0) return 3;
|
||||
elseif ($j<4) return $j+4;
|
||||
else return $j*2+1;
|
||||
}
|
||||
// echo "NOK $note < ".$tabMinMax[0]." ou $note > ". $tabMinMax[1].'<br/>';
|
||||
}
|
||||
return 3; // On retourne la plus basse note par défaut
|
||||
}
|
||||
|
||||
|
||||
function getNoteBorne($note, $borne, $secteur, $numerateur, $denominateur) {
|
||||
|
||||
$noteBorneBrute=$this->getBorne($note, $borne, $secteur);
|
||||
|
||||
switch($borne)
|
||||
{
|
||||
case 1:
|
||||
if ($numerateur<0) return 3;
|
||||
else return $noteBorneBrute;
|
||||
break;
|
||||
case 2:
|
||||
if ($numerateur==0) return 19;
|
||||
else return $noteBorneBrute;
|
||||
break;
|
||||
case 3:
|
||||
if ($numerateur==0 && $denominateur>0) return 19;
|
||||
elseif ($denominateur<0) return 3;
|
||||
else return $noteBorneBrute;
|
||||
break;
|
||||
case 4:
|
||||
if ($note<0) return 19;
|
||||
else return $noteBorneBrute;
|
||||
break;
|
||||
default:
|
||||
return $noteBorneBrute;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function getNotationFin ($coteMoy) {
|
||||
if( $coteMoy > 18.5 )
|
||||
return 'A';
|
||||
elseif( $coteMoy > 16 )
|
||||
return 'B+';
|
||||
elseif( $coteMoy > 14 )
|
||||
return 'B';
|
||||
elseif( $coteMoy > 12.5 )
|
||||
return 'C+';
|
||||
elseif( $coteMoy > 11 )
|
||||
return 'C';
|
||||
elseif( $coteMoy > 10 )
|
||||
return 'C-';
|
||||
elseif( $coteMoy > 9 )
|
||||
return 'D+';
|
||||
elseif( $coteMoy > 8 )
|
||||
return 'D';
|
||||
elseif( $coteMoy > 7 )
|
||||
return 'D-';
|
||||
elseif( $coteMoy > 6 )
|
||||
return 'E+';
|
||||
elseif( $coteMoy > 4.5 )
|
||||
return 'E';
|
||||
elseif( $coteMoy > 3 )
|
||||
return 'E-';
|
||||
else
|
||||
return 'E--';
|
||||
}
|
||||
|
||||
|
||||
function getInfosNotation ($notation, $csv=false) {
|
||||
if ($csv) {
|
||||
$str =$this->tabNotation[$notation][1].';'.
|
||||
$this->tabNotation[$notation][2].';'.
|
||||
$this->tabNotation[$notation][3].';'.
|
||||
$this->tabNotation[$notation][4].';';
|
||||
return $str;
|
||||
} else {
|
||||
$str ='Notation : '. $this->tabNotation[$notation][0]."\r\n";
|
||||
$str.='Equivalence BDF : '. $this->tabNotation[$notation][1]."\r\n";
|
||||
$str.='Grades Moody\'s : '. $this->tabNotation[$notation][2]."\r\n";
|
||||
$str.='Grades S&P : '. $this->tabNotation[$notation][3]."\r\n";
|
||||
$str.='Probabilité de défaillance : '. $this->tabNotation[$notation][4]." %\r\n";
|
||||
return $str;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
47
library/Metier/common/controles.php
Normal file
47
library/Metier/common/controles.php
Normal file
@ -0,0 +1,47 @@
|
||||
<?
|
||||
|
||||
function isinPoidsLettre($lettre) {
|
||||
$ascii=ord($lettre);
|
||||
if ($ascii>64 && $ascii<91 )
|
||||
/* En ASCII : A=65 et Z=90
|
||||
En ISIN... A=10 et Z=35 */
|
||||
return ($ascii-55);
|
||||
return false;
|
||||
}
|
||||
|
||||
/** Test si un code ISIN donné est valable à partir de son algo de contrôle.
|
||||
** @param string $isin Code ISIN à vérifier
|
||||
** @return bool
|
||||
**/
|
||||
function isValidIsin($isin) {
|
||||
|
||||
$pays=substr($isin, 0,2);
|
||||
$nsin=''.substr($isin, 2,9);
|
||||
$clef=substr($isin,11,1)*1;
|
||||
|
||||
$calcul=''.isinPoidsLettre($pays[0]).isinPoidsLettre($pays[1]).$nsin;
|
||||
//echo "Etape 1 = $calcul".EOL;
|
||||
|
||||
$sommeImpair=$sommePair=0;
|
||||
for ($impair=0; $impair<12; $impair=$impair+2) {
|
||||
$strImpair=''.$calcul[$impair]*2;
|
||||
if (isset($strImpair[1])) $reste=$strImpair[1]*1;
|
||||
else $reste=0;
|
||||
$sommeImpair+=$strImpair[0]*1+$reste;
|
||||
}
|
||||
|
||||
for ($pair=1; $pair<12; $pair=$pair+2)
|
||||
$sommePair+=$calcul[$pair]*1;
|
||||
|
||||
$totalcalcul=$sommeImpair+$sommePair;
|
||||
//echo "Etape 3 = $sommeImpair + $sommePair = $totalcalcul".EOL;
|
||||
|
||||
$dizSuperieur=ceil($totalcalcul/10)*10;
|
||||
$delta=$dizSuperieur-$totalcalcul;
|
||||
//echo "Etape 4 = $dizSuperieur - $totalcalcul = $delta".EOL;
|
||||
|
||||
if ($delta==$clef) return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
?>
|
339
library/Metier/common/fonctions.php
Normal file
339
library/Metier/common/fonctions.php
Normal file
@ -0,0 +1,339 @@
|
||||
<?
|
||||
/** Parse une page Html et retourne son contenu dans un tableau :
|
||||
** "code" => Code réponse Serveur
|
||||
** "header" => Headers du serveur
|
||||
** "body" => Page HTML
|
||||
**/
|
||||
function parse_response($this_response) {
|
||||
|
||||
|
||||
// Split response into header and body sections
|
||||
list($response_headers, $response_body) = explode("\r\n\r\n", $this_response, 2);
|
||||
$response_header_lines = explode("\r\n", $response_headers);
|
||||
|
||||
// First line of headers is the HTTP response code
|
||||
$http_response_line = array_shift($response_header_lines);
|
||||
if(preg_match('@^HTTP/[0-9]\.[0-9] ([0-9]{3})@',$http_response_line, $matches)) { $response_code = $matches[1]; }
|
||||
|
||||
// put the rest of the headers in an array
|
||||
$response_header_array = array();
|
||||
$nbRMID=0;
|
||||
foreach($response_header_lines as $header_line)
|
||||
{
|
||||
list($header,$value) = explode(': ', $header_line, 2);
|
||||
|
||||
if ($header=='Set-cookie' && substr($value,0,5)=='RMID=' && $nbRMID<5)//{
|
||||
$nbRMID++;
|
||||
// echo ("Je gicle le RMID n°$nbRMID\r\n");}
|
||||
else
|
||||
$response_header_array[$header] .= $value."\n";
|
||||
}
|
||||
return array('code' => $response_code, 'header' => $response_header_array, 'body' => $response_body);
|
||||
}
|
||||
|
||||
/** Récupère une page HTML en fonction des paramètres :
|
||||
** $url Url distante de la page à récupérer
|
||||
** $strCookies Chaine de caractère contenant les cookies
|
||||
** $postData Tableau des données à passer en POST uniquement
|
||||
** $referer Referer à indiquer lors de l'appel de la page
|
||||
** $debug Activer le débogage (True/False)
|
||||
**
|
||||
** ... et retourne son contenu dans un tableau :
|
||||
** "code" => Code réponse Serveur
|
||||
** "header" => Headers du serveur
|
||||
** "body" => Page HTML
|
||||
**/
|
||||
function getUrl($url, $strCookies='', $postData='', $referer='', $debug=false, $host='') {
|
||||
|
||||
|
||||
$ch = curl_init();
|
||||
|
||||
if ($host=='')
|
||||
$this_header = array('Host: '. HOST_INSEE);
|
||||
else
|
||||
$this_header = array('Host: '. $host);
|
||||
|
||||
curl_setopt($ch, CURLOPT_URL, $url);
|
||||
curl_setopt($ch, CURLOPT_HEADER, 1);
|
||||
//curl_setopt($ch, CURLOPT_PROXY, '10.142.10.254:80');
|
||||
//curl_setopt($ch, CURLOPT_PROXYUSERPWD, 'username:password'); // Pas nécessaire en authentification NT
|
||||
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
||||
//curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
|
||||
//curl_setopt($ch, CURLOPT_MAXREDIRS, 1);
|
||||
|
||||
$user_agent = 'Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)';
|
||||
curl_setopt($ch, CURLOPT_USERAGENT, $user_agent);
|
||||
curl_setopt($ch, CURLOPT_REFERER, $referer);
|
||||
|
||||
// Add each cookie that has been returned in the response
|
||||
// If cookies need to be added/deleted or value changed, then add code here
|
||||
if ($strCookies!='') {
|
||||
//die('"'.$strCookies.'"');
|
||||
//echo $strCookies."\r\n";
|
||||
$cookies = explode("\n", $strCookies);
|
||||
// Create the basic header
|
||||
foreach($cookies as $this_cookie) {
|
||||
if (trim($this_cookie)<>'')
|
||||
array_push($this_header, 'Cookie: '.$this_cookie);
|
||||
}
|
||||
}
|
||||
|
||||
if ($postData!='') {
|
||||
if (is_array($postData))
|
||||
$post_data=$postData;
|
||||
|
||||
$o="";
|
||||
foreach ($post_data as $k=>$v)
|
||||
{
|
||||
$o.= "$k=".utf8_encode($v)."&";
|
||||
}
|
||||
$post_data=substr($o,0,-1);
|
||||
|
||||
curl_setopt($ch, CURLOPT_POST, 1);
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
|
||||
//if in_array('',$this_header
|
||||
/*array_push($this_header, "Content-type: application/x-www-form-urlencoded");
|
||||
array_push($this_header, "Content-Length: 44");*/
|
||||
}
|
||||
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, $this_header);
|
||||
//print_r($this_header);
|
||||
|
||||
$page=curl_exec($ch);
|
||||
$response = parse_response($page);
|
||||
if ($debug){
|
||||
$url2=str_replace('http://', '', $url);
|
||||
$url2=str_replace('/', '_', $url2);
|
||||
$url2=str_replace('?', '(param)', $url2);
|
||||
$url2=str_replace('&', '(et)', $url2);
|
||||
|
||||
|
||||
$fp=fopen('/var/www/_includes/partenaires/insee/'. date('Ymd-His') .'-'. microtime_float(true) .'-'. $url2 . '.html', 'a');
|
||||
fwrite($fp, $url."\r\n");
|
||||
fwrite($fp, $page);
|
||||
fclose($fp);
|
||||
//echo strip_tags(html_entity_decode($response['body']), '<td>');
|
||||
}
|
||||
//print_r(curl_getinfo($ch));
|
||||
curl_close($ch);
|
||||
return $response;
|
||||
}
|
||||
|
||||
|
||||
function rechercheTelephone($raisonSociale='', $adresse='', $localite='', $departement='', $activite='') {
|
||||
|
||||
$response1=getUrl(SITE_PJ.'pj.cgi?', '', '', '', true, HOST_PJ);
|
||||
//print_r($response1['header']['Set-cookie']);
|
||||
$pageHtml=$response1['body'];
|
||||
$SESSION_ID=getTextInHtml($pageHtml, '<input type="hidden" name="SESSION_ID" value="', ' value="', '">');
|
||||
$VID=getTextInHtml($pageHtml, '<input type="hidden" name="VID" value="', ' value="', '">');
|
||||
$e_cookie=getTextInHtml($pageHtml, '<noscript><img ALT="" src="http://e.pagesjaunes.fr/m/web/', 'src="', '" BORDER=0 width=1 height=1></noscript>');
|
||||
|
||||
$response=getUrl(SITE_PJ.'files/look2002/FR/commun/pji.css', '', '', SITE_PJ.'pj.cgi?', false, HOST_PJ);
|
||||
$response=getUrl(SITE_PJ.'files/look2002/FR/commun/pji_PJ.css', '', '', SITE_PJ.'pj.cgi?', false, HOST_PJ);
|
||||
$response=getUrl(SITE_PJ.'files/look2002/FR/commun/script_open.js', '', '', SITE_PJ.'pj.cgi?', false, HOST_PJ);
|
||||
$response=getUrl(SITE_PJ.'files/look2002/FR/commun/alerte.js', '', '', SITE_PJ.'pj.cgi?', false, HOST_PJ);
|
||||
$response=getUrl(SITE_PJ.'files/look2002/FR/commun/script_VED.js', '', '', SITE_PJ.'pj.cgi?', false, HOST_PJ);
|
||||
$response=getUrl(SITE_PJ.'sitecrm/popup.js', '', '', SITE_PJ.'pj.cgi?', false, HOST_PJ);
|
||||
$response=getUrl('http://sbx.pagesjaunes.fr/RealMedia/ads/Creatives/OasDefault/AUTOPROMO_PJ_banniere_activite/hotel_pj.swf?clickTAG=http://sbx.pagesjaunes.fr/RealMedia/ads/click_lx.ads/www.pagesjaunes.fr/GENERAL/GENERAL/PJ/1238513556/Top/OasDefault/AUTOPROMO_PJ_banniere_activite/hotel_pj.html/61633130323433353434346339306330?', '', '', SITE_PJ.'pj.cgi?', false, HOST_PJ);
|
||||
$response=getUrl(SITE_PJ.'files/look2002/FR/commun/script_VED.js', '', '', SITE_PJ.'pj.cgi?', false, HOST_PJ);
|
||||
$response=getUrl('http://sbx.pagesjaunes.fr/RealMedia/ads/Creatives/OasDefault/EDITO_HOME_RIGHT/anim_HP_v2-04-2006.swf', '', '', SITE_PJ.'pj.cgi?', false, HOST_PJ);
|
||||
$response=getUrl('http://sbx.pagesjaunes.fr/RealMedia/ads/Creatives/OasDefault/EDITO_HOME_RIGHT/visuels_webcam.swf', '', '', SITE_PJ.'pj.cgi?', false, HOST_PJ);
|
||||
$response=getUrl('http://sbx.pagesjaunes.fr/RealMedia/ads/Creatives/OasDefault/EDITO_HOME_RIGHT/visuels_photo.swf', '', '', SITE_PJ.'pj.cgi?', false, HOST_PJ);
|
||||
$response=getUrl('http://sbx.pagesjaunes.fr/RealMedia/ads/Creatives/OasDefault/EDITO_HOME_RIGHT/visuels_trafic.swf', '', '', SITE_PJ.'pj.cgi?', false, HOST_PJ);
|
||||
$response=getUrl('http://sbx.pagesjaunes.fr/RealMedia/ads/Creatives/OasDefault/Edito_webcams/new_04-2006.jpg', '', '', SITE_PJ.'pj.cgi?', false, HOST_PJ);
|
||||
$response=getUrl('http://e.pagesjaunes.fr/js/m.js', '', '', SITE_PJ.'pj.cgi?', false, HOST_PJ);
|
||||
|
||||
$response2=getUrl($e_cookie, $response1['header']['Set-cookie'], '', SITE_PJ, true, HOST_PJ);
|
||||
|
||||
$cookies=$response1['header']['Set-cookie'] . $response2['header']['Set-Cookie'];
|
||||
|
||||
$input_image=$VALID_ARR=$NUM_RUE=$NEW_DEPARTEMENT=$OBJ_GEO='';
|
||||
|
||||
// Requête d'interrogation
|
||||
$postData=array(
|
||||
'ACTIVITE_VALIDATED_ASCII'=>'',
|
||||
'ID_THEME_SDE'=>'',
|
||||
'LISTE_RUB_AVEC_THEME'=>'',
|
||||
'input_image'=>$input_image,
|
||||
|
||||
'FRM_ACTIVITE'=>$activite,
|
||||
'FRM_NOM'=>$raisonSociale,
|
||||
'FRM_ADRESSE'=>$adresse,
|
||||
'FRM_LOCALITE'=>$localite,
|
||||
'FRM_DEPARTEMENT'=>$departement,
|
||||
|
||||
'JF_INSCRIPTIONS_REQ.x'=>'25',
|
||||
'JF_INSCRIPTIONS_REQ.y'=>'4',
|
||||
'faire'=>'decode_input_image',
|
||||
'DEFAULT_ACTION'=>'jf_inscriptions_req',
|
||||
'SESSION_ID'=>$SESSION_ID,
|
||||
'VID'=>$VID,
|
||||
'INFO_VILLE'=>'non',
|
||||
'CODE_LOC_INFO_VILLE'=>'00000000',
|
||||
'IV_ACTIVATION'=>'oui',
|
||||
'lang'=>'FR',
|
||||
'pays'=>'FR',
|
||||
'srv'=>'PJ',
|
||||
'TYPE_RECHERCHE'=>'ZZZ');
|
||||
//print_r($postData);//die();
|
||||
sleep(1);
|
||||
$response=getUrl(SITE_PJ, $cookies, $postData, SITE_PJ, true, HOST_PJ);
|
||||
$pageHtml=$response['body'];
|
||||
|
||||
if (count($tabNT=getTabListeNonTrouve($pageHtml))>0)
|
||||
{
|
||||
// Pas de réponses pour ces critères
|
||||
// Il faut élargir la recherche !
|
||||
$tabNTk=array_keys($tabNT);
|
||||
$input_image=$tabNT[0];
|
||||
$DEFAULT_ACTION='inscriptions_req';
|
||||
$NEW_DEPARTEMENT=getTextInHtml($pageHtml, '<input type="hidden" name="NEW_DEPARTEMENT" value="', 'value="', '">');
|
||||
$OBJ_GEO=getTextInHtml($pageHtml, '<input type=hidden name=OBJ_GEO value="', 'value="', '">');
|
||||
}
|
||||
elseif (count($tabGU=getTabListeGU($pageHtml))>0)
|
||||
{
|
||||
// Plusieurs Adresses possibles pour l'adresse donnée
|
||||
// print_r($tabGU);
|
||||
$input_image=getBonneAdresse($adresse, $tabGU);
|
||||
$DEFAULT_ACTION='jf_inscriptions_req';
|
||||
$VALID_ARR=getTextInHtml($pageHtml, '<input type=hidden name=VALID_ARR value="', 'value="', '">');
|
||||
$NUM_RUE=getTextInHtml($pageHtml, '<input type=hidden name=NUM_RUE value="', 'value="', '">');
|
||||
}
|
||||
|
||||
if ($input_image<>'') {
|
||||
$CODE_LOC_INFO_VILLE=getTextInHtml($pageHtml, '<input type="hidden" name="CODE_LOC_INFO_VILLE" value="', 'value="', '">');
|
||||
|
||||
$postData=array(
|
||||
'GEO_DEP'=>'', // New
|
||||
'faire'=>'decode_input_image',
|
||||
'DEFAULT_ACTION'=>$DEFAULT_ACTION,
|
||||
'input_image'=>$input_image,// diff
|
||||
'SESSION_ID'=>$SESSION_ID,
|
||||
'VID'=>$VID,
|
||||
'INFO_VILLE'=>'oui', // non dans la recherche préc.
|
||||
'CODE_LOC_INFO_VILLE'=>$CODE_LOC_INFO_VILLE, // diff
|
||||
'IV_ACTIVATION'=>'oui',
|
||||
'lang'=>'FR',
|
||||
'pays'=>'FR',
|
||||
'srv'=>'PJ',
|
||||
'TYPE_RECHERCHE'=>'CLOC', // ZZZ
|
||||
'SAV_ADRESSE'=>$adresse, //
|
||||
'SAV_LOCALITE'=>$localite, // New
|
||||
'SAV_DEPARTEMENT'=>$departement, //
|
||||
'FRM_NOM'=>$raisonSociale,
|
||||
'FRM_ADRESSE'=>$adresse,
|
||||
'FRM_LOCALITE'=>$localite,
|
||||
'FRM_DEPARTEMENT'=>$departement,
|
||||
|
||||
'FRM_TYPE_PUB'=>'TOUS',
|
||||
'RP_FORM'=>'',
|
||||
'VALID_LOC'=>$CODE_LOC_INFO_VILLE,
|
||||
'VALID_ARR'=>$VALID_ARR,
|
||||
'NUM_RUE'=>$NUM_RUE,
|
||||
'test_flash'=>'',
|
||||
'ESPLUS'=>'',
|
||||
'NEW_DEPARTEMENT'=>$NEW_DEPARTEMENT,
|
||||
'OBJ_GEO'=>$OBJ_GEO,
|
||||
);
|
||||
print_r($postData);
|
||||
sleep(1);
|
||||
$response=getUrl(SITE_PJ, $cookies, $postData, SITE_PJ, true, HOST_PJ);
|
||||
$pageHtml=$response['body'];
|
||||
}
|
||||
|
||||
$nbReponses=trim(getTextInHtml($pageHtml, '<tr><td align="left" class=txtrequetetotal valign=middle nowrap><b>', '<b>', 'réponse(s)</b></td>'));
|
||||
$tabRep=getTabResponses($pageHtml);
|
||||
|
||||
if (count($tabRep)==$nbReponses)
|
||||
return $tabRep;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
function getTabResponses($pageHtml) {
|
||||
|
||||
$tabRepTmp=explode ('class=fdinscr', $pageHtml);
|
||||
$tabRep=array();
|
||||
foreach($tabRepTmp as $key => $value)
|
||||
{
|
||||
if ($key>0) {
|
||||
$raisonSociale=getTextInHtml($value, 'class=fdrsinscr', '<b>', '</b>');
|
||||
$ligneAdresse=html_entity_decode(getTextInHtml($value, '<td align="left" class=txtinscr ><b>', '<b>', '|'));
|
||||
$tabligneAdresse=explode('<br>', $ligneAdresse);
|
||||
$ligneAdresse1=strip_tags($tabligneAdresse[0]);
|
||||
$ligneAdresse2=strip_tags($tabligneAdresse[1]);
|
||||
$dispoPlan =(bool)(strpos($value, '<b>Plan</b>'));
|
||||
$dispoIti =(bool)(strpos($value, '<b>Itinéraire</b>'));
|
||||
$dispoPhoto =(bool)(strpos($value, '<b>Photo</b>'));
|
||||
$dispoWeb =(bool)(strpos($value, '<b>Site</b></a> '));
|
||||
$lienWeb=getTextInHtml($value, '<a target="_blank" href="http://www.pagesjaunes.fr/CGI/MOD?', 'href="', '" ');
|
||||
$page=getUrl($lienWeb, '', '', '', true);
|
||||
$lienWeb=$page['header']['Location'];
|
||||
|
||||
/*echo "Enreg n°$key : RS='$raisonSociale'\r\n";
|
||||
echo "Enreg n°$key : Adresse1='$ligneAdresse1'\r\n";
|
||||
echo "Enreg n°$key : Adresse2='$ligneAdresse2'\r\n";
|
||||
echo "Enreg n°$key : Plan ?='$dispoPlan'\r\n";
|
||||
echo "Enreg n°$key : Itineraire ?='$dispoIti'\r\n";
|
||||
echo "Enreg n°$key : Photo ?='$dispoPhoto'\r\n";
|
||||
echo "Enreg n°$key : Web ?='$dispoWeb'\r\n";
|
||||
echo "Enreg n°$key : Site WEB='$lienWeb'\r\n\r\n";*/
|
||||
array_push($tabRep, array( 'raisonSociale' =>$raisonSociale,
|
||||
'AdresseLigne1' =>$ligneAdresse1,
|
||||
'AdresseLigne2' =>$ligneAdresse2,
|
||||
'Dispo_Plan' =>$dispoPlan,
|
||||
'Dispo_Iti' =>$dispoIti,
|
||||
'Dispo_Photo' =>$dispoPhoto,
|
||||
'Dispo_Web' =>$dispoWeb,
|
||||
'LienWeb' =>$lienWeb));
|
||||
}
|
||||
}
|
||||
return $tabRep;
|
||||
}
|
||||
|
||||
function getBonneAdresse($adresse, $tabGU) {
|
||||
|
||||
// tableau de mots à vérifier
|
||||
$words = array_keys($tabGU);
|
||||
|
||||
// aucune distance de trouvée pour le moment
|
||||
$shortest = -1;
|
||||
|
||||
// boucle sur les des mots pour trouver le plus près
|
||||
foreach ($words as $word) {
|
||||
|
||||
// calcule la distance avec le mot mis en entrée,
|
||||
// et le mot courant
|
||||
$lev = levenshtein($adresse, $word);
|
||||
|
||||
// cherche une correspondance exacte
|
||||
if ($lev == 0) {
|
||||
|
||||
// le mot le plus près est celui-ci (correspondance exacte)
|
||||
$closest = $word;
|
||||
$shortest = 0;
|
||||
|
||||
// on sort de la boucle ; nous avons trouvé une correspondance exacte
|
||||
break;
|
||||
}
|
||||
|
||||
// Si la distance est plus petite que la prochaine distance trouvée
|
||||
// OU, si le prochain mot le plus près n'a pas encore été trouvé
|
||||
if ($lev <= $shortest || $shortest < 0) {
|
||||
// définission du mot le plus près ainsi que la distance
|
||||
$closest = $word;
|
||||
$shortest = $lev;
|
||||
}
|
||||
}
|
||||
/*
|
||||
echo "Mot entré : $adresse\n";
|
||||
if ($shortest == 0) {
|
||||
echo "Correspondance exacte trouvée : $closest\n";
|
||||
} else {
|
||||
echo "Vous voulez dire : $closest ?\n";
|
||||
}*/
|
||||
return $tabGU[$closest];
|
||||
}
|
||||
?>
|
548
library/Metier/common/insee.class.php
Normal file
548
library/Metier/common/insee.class.php
Normal file
@ -0,0 +1,548 @@
|
||||
<?
|
||||
class Insee {
|
||||
}
|
||||
|
||||
function getDataEtablissement($pageHtml)
|
||||
{
|
||||
global $libelleErreur;
|
||||
|
||||
$responseSiege=$pageHtml;
|
||||
$tabRet=array();
|
||||
|
||||
// On recherche si on est sur un établissement siège ou secondaire
|
||||
$pos=strpos($pageHtml, '<table cols="2" width="100%"><tr><td bgcolor="#FFCC33" align="left"><font face="Arial" size="2"><B>Fiche Etablissement</B>');
|
||||
if ($pos>0)
|
||||
$tabRet['typeEtablissement']='secondaire';
|
||||
|
||||
$pos=strpos($pageHtml, '<table cols="2" width="100%"><tr><td bgcolor="#FFCC33" align="left"><font face="Arial" size="2"><B>Fiche siège</B>');
|
||||
if ($pos>0)
|
||||
$tabRet['typeEtablissement']='siège';
|
||||
|
||||
// Recherche Dernière MAJ / Activité
|
||||
$pos=strpos($responseSiege, '<font face="Arial" size="2">(dernière mise à jour :');
|
||||
if ($pos>0) {
|
||||
$tabRet['dateMAJ']=substr($responseSiege, $pos+51, 10);
|
||||
$tabRet['dateAbsActivite']='';
|
||||
$tabRet['active']='O';
|
||||
} else {
|
||||
$tabRet['active']='N';
|
||||
$tabRet['dateMAJ']='';
|
||||
$pos=strpos($responseSiege, '<font face="Arial" size="2">Absence d\'activité notée le : ');
|
||||
if ($pos>0) $tabRet['dateAbsActivite']=substr($responseSiege, $pos+78, 10);
|
||||
else {
|
||||
$pos=strpos($responseSiege, '<font face="Arial" size="2">Absence d\'activité');
|
||||
if ($pos>0) $tabRet['dateAbsActivite']='';
|
||||
}
|
||||
}
|
||||
|
||||
$pos=strpos($responseSiege, ' size="-1"> <B>n° SIRET :</B></FONT></td><td valign="top"><font face="Arial" size="-1">');
|
||||
$tabRet['siret']=str_replace(' ', '', html_entity_decode(substr($responseSiege, $pos+97, 32)));
|
||||
|
||||
$pos=strpos($responseSiege, 'size="-1"> <B>Date de création :</B></FONT></td><td valign="top"><font face="Arial" size="-1">');
|
||||
if ($pos>0) {
|
||||
$posFin=strpos($responseSiege, '</font>', $pos+109);
|
||||
$tabRet['dateCreation']=str_replace(' ', '', html_entity_decode(substr($responseSiege, $pos+109, $posFin-($pos+109))));
|
||||
}
|
||||
else $tabRet['dateCreation']='';
|
||||
|
||||
$pos=strpos($responseSiege, ' size="-1"> <B>Raison sociale et Enseigne :</B></FONT></td><td valign="top" colspan="3"><font face="Arial" size="-1">');
|
||||
$len=127;
|
||||
if ($pos==0){
|
||||
$pos=strpos($responseSiege, ' size="-1"> <B>Raison sociale et Enseigne :</B></FONT></td><td valign="top" colspan="3"><font face="Arial" size="-1">');
|
||||
$len=122;
|
||||
if ($pos==0){
|
||||
$pos=strpos($responseSiege, ' size="-1"> <B>Raison sociale et Enseigne :</B></FONT></td><td valign="top" colspan="3"><font face="Arial" size="-1">');
|
||||
$len=126;
|
||||
$libelleErreur='Informations INSEE non diffusables';
|
||||
}
|
||||
}
|
||||
if ($libelleErreur=='') {
|
||||
//LARGE*DOMINIQUE MICHEL/ <BR>GERANT SARL BIMAGIQUE </font>
|
||||
$posFin=strpos($responseSiege, '</font>', $pos+$len);
|
||||
$raisonSocialeStr=trim(substr($responseSiege, $pos+$len, $posFin-($pos+$len)));
|
||||
$raisonSocialeTabLigne=explode('<BR>', $raisonSocialeStr);
|
||||
$tabRet['raisonSociale']=trim(str_replace(' ', '', html_entity_decode($raisonSocialeTabLigne[0])));
|
||||
$tabRet['Enseigne']=trim(str_replace(' ', '', html_entity_decode($raisonSocialeTabLigne[1])));
|
||||
|
||||
$pos=strpos($responseSiege, ' size="-1"> <B>Activité principale :</B></FONT></td><td valign="top" colspan="3"><font face="Arial" size="-1">');
|
||||
$tabRet['NafCode']=substr($responseSiege, $pos+120, 4);
|
||||
$tabRet['NafLib']=trim(substr($responseSiege, $pos+137, 70));
|
||||
|
||||
$pos=strpos($responseSiege, ' size="-1"> <B>Adresse :</B></FONT></td><td valign="top" colspan="3"><font face="Arial" size="-1">');
|
||||
$posFin=strpos($responseSiege, '</font>', $pos+103);
|
||||
$AdresseStr=substr($responseSiege, $pos+103, $posFin-($pos+103));
|
||||
$AdresseTabLigne=explode('<BR>', $AdresseStr);//'
|
||||
$tabRet['AdresseLigne1']=str_replace(' ', '/', $AdresseTabLigne[0]);
|
||||
$tabRet['AdresseLigne2']=str_replace(' ', '/', $AdresseTabLigne[1]);
|
||||
$tabRet['AdresseLigne3']=str_replace(' ', '/', $AdresseTabLigne[2]);
|
||||
/*
|
||||
$AdresseNum=$AdresseTabLigne1[0];
|
||||
$AdresseVoi=$AdresseTabLigne1[1];
|
||||
$AdresseRue=$AdresseTabLigne1[2];
|
||||
$AdresseCP=$AdresseTabLigne2[0];
|
||||
$AdresseVille=$AdresseTabLigne2[1];
|
||||
*/
|
||||
$pos=strpos($responseSiege, '<font face="Arial" size="-1"><b>L\'entreprise est connue au répertoire comme ');
|
||||
if ($pos>0) {
|
||||
$posFin=strpos($responseSiege, '</b>', $pos+106);
|
||||
$tabRet['etatJuridique']=html_entity_decode(substr($responseSiege, $pos+106, $posFin-($pos+106)));
|
||||
$tabRet['dateEtatJuridique']='';
|
||||
} else {
|
||||
$pos=strpos($responseSiege, '<font face="Arial" size="-1"><b>L\'entreprise est cessée le : ');
|
||||
$tabRet['dateEtatJuridique']=substr($responseSiege, $pos+86, 10);
|
||||
$tabRet['etatJuridique']='cessée';
|
||||
}
|
||||
//echo 'GetDataEtab="'.$libelleErreur."\"\r\n";
|
||||
|
||||
return $tabRet;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function getDataEntreprise($pageHtml)
|
||||
{
|
||||
global $libelleErreur;
|
||||
|
||||
$responseEntreprise=$pageHtml;
|
||||
$tabRet=array();
|
||||
|
||||
if ($libelleErreur=='') {
|
||||
|
||||
$pos=strpos($responseEntreprise, 'size="-1"> <B>Date de création :</B></FONT></td><td valign="top"><font face="Arial" size="-1">');
|
||||
if ($pos>0)
|
||||
$tabRet['dateCreationEntrep']=substr($responseEntreprise, $pos+109, 10);
|
||||
else
|
||||
$tabRet['dateCreationEntrep']='';
|
||||
|
||||
// Raison sociale et Sigle
|
||||
$pos=strpos($responseEntreprise, ' size="-1"> <B>Raison sociale et Sigle :</B></FONT></td><td valign="top" colspan="3"><font face="Arial" size="-1">');
|
||||
$posFin=strpos($responseEntreprise, '</font>', $pos+123);
|
||||
$raisonSocialeStr=trim(substr($responseEntreprise, $pos+123, $posFin-($pos+123)));
|
||||
$raisonSocialeTabLigne=explode('<BR>', $raisonSocialeStr);
|
||||
$tabRet['raisonSocialeEntrep']=trim(str_replace(' ', '', html_entity_decode($raisonSocialeTabLigne[0])));
|
||||
$tabRet['sigle']=trim(str_replace(' ', '', html_entity_decode($raisonSocialeTabLigne[1])));
|
||||
|
||||
// Activité prinicpale Entrep
|
||||
$pos=strpos($responseEntreprise, ' size="-1"> <B>Activité principale :</B></FONT></td><td valign="top" colspan="3"><font face="Arial" size="-1">');
|
||||
$tabRet['NafCodeEntrep']=substr($responseEntreprise, $pos+120, 4);
|
||||
$tabRet['NafLibEntrep']=trim(substr($responseEntreprise, $pos+137, 70));
|
||||
|
||||
// Forme Juridique
|
||||
$pos=strpos($responseEntreprise, ' size="-1"> <B>Forme juridique :</B></FONT></td><td valign="top" colspan="3"><font face="Arial" size="-1">');
|
||||
$tabRet['FJCodeEntrep']=substr($responseEntreprise, $pos+116, 4);
|
||||
$tabRet['FJLibEntrep']=trim(substr($responseEntreprise, $pos+133, 70));
|
||||
|
||||
// Nb Etab Actifs
|
||||
$pos=strpos($responseEntreprise, ' size="-1"> <B>Nb établissements actifs :</B></FONT></td><td valign="top"><font face="Arial" size="-1">');
|
||||
$posFin=strpos($responseEntreprise, '</font>', $pos+118);
|
||||
$tabRet['nbEtabActifs']=trim(str_replace(' ', '', html_entity_decode(substr($responseEntreprise, $pos+118, $posFin-($pos+118)))));
|
||||
}
|
||||
return $tabRet;
|
||||
}
|
||||
|
||||
/*
|
||||
* parseHtml.php
|
||||
* Author: Carlos Costa Jordao
|
||||
* Email: carlosjordao@yahoo.com
|
||||
*
|
||||
* My notation of variables:
|
||||
* i_ = integer, ex: i_count
|
||||
* a_ = array, a_html
|
||||
* b_ = boolean,
|
||||
* s_ = string
|
||||
*
|
||||
* What it does:
|
||||
* - parses a html string and get the tags
|
||||
* - exceptions: html tags like <br> <hr> </a>, etc
|
||||
* - At the end, the array will look like this:
|
||||
* ["IMG"][0]["SRC"] = "xxx"
|
||||
* ["IMG"][1]["SRC"] = "xxx"
|
||||
* ["IMG"][1]["ALT"] = "xxx"
|
||||
* ["A"][0]["HREF"] = "xxx"
|
||||
*
|
||||
*/
|
||||
function parseHtml( $s_str )
|
||||
{
|
||||
$i_indicatorL = 0;
|
||||
$i_indicatorR = 0;
|
||||
$s_tagOption = '';
|
||||
$i_arrayCounter = 0;
|
||||
$a_html = array();
|
||||
// Search for a tag in string
|
||||
while( is_int(($i_indicatorL=strpos($s_str,'<',$i_indicatorR))) ) {
|
||||
// Get everything into tag...
|
||||
$i_indicatorL++;
|
||||
$i_indicatorR = strpos($s_str,'>', $i_indicatorL);
|
||||
$s_temp = substr($s_str, $i_indicatorL, ($i_indicatorR-$i_indicatorL) );
|
||||
$a_tag = explode( ' ', $s_temp );
|
||||
// Here we get the tag's name
|
||||
list( ,$s_tagName,, ) = each($a_tag);
|
||||
$s_tagName = strtoupper($s_tagName);
|
||||
// Well, I am not interesting in <br>, </font> or anything else like that...
|
||||
// So, this is false for tags without options.
|
||||
$b_boolOptions = is_array(($s_tagOption=each($a_tag))) && $s_tagOption[1];
|
||||
if( $b_boolOptions ) {
|
||||
// Without this, we will mess up the array
|
||||
$i_arrayCounter = (int)count($a_html[$s_tagName]);
|
||||
// get the tag options, like src="htt://". Here, s_tagTokOption is 'src' and s_tagTokValue is '"http://"'
|
||||
|
||||
do {
|
||||
$s_tagTokOption = strtoupper(strtok($s_tagOption[1], "="));
|
||||
$s_tagTokValue = trim(strtok("="));
|
||||
$a_html[$s_tagName][$i_arrayCounter][$s_tagTokOption] =
|
||||
$s_tagTokValue;
|
||||
$b_boolOptions = is_array(($s_tagOption=each($a_tag))) &&
|
||||
$s_tagOption[1];
|
||||
} while( $b_boolOptions );
|
||||
}
|
||||
}
|
||||
return $a_html;
|
||||
}
|
||||
|
||||
function getDataEntrepriseRNCS($pageHtml) {
|
||||
|
||||
global $libelleErreur;
|
||||
|
||||
$tabRet=array();
|
||||
|
||||
// Liste et liens vers les Bilans
|
||||
$tabRet['tabListeBilans']=getTabListeBilans($pageHtml);
|
||||
$tabRet['raisonSociale']=getTextInHtml($pageHtml, '<td align="left" valign="top"><span class="boldred"><br>', '<br>', '</span>');
|
||||
$tabRet['RCS']=getTextInHtml($pageHtml, '<span class="textarial">RCS ', 'RCS ', '</span>', true);
|
||||
$tabRet['activite']=getTextInHtml($pageHtml, '<td width="185" align="left" valign="top" bgcolor="#FFFFFF" class="boldtextarial">Activité</td>', 'class="basictext">', '</td>');
|
||||
$tabRet['adresseSiege']=getTextInHtml($pageHtml, '<td align="left" valign="top" bgcolor="#FFFFFF" class="boldtextarial">Siège
|
||||
social</td>', 'class="basictext">', '</td>');
|
||||
print_r($tabRet);
|
||||
die();
|
||||
// Capital social
|
||||
|
||||
// Chiffre d'affaires
|
||||
|
||||
// Date CA
|
||||
|
||||
// Effectif
|
||||
|
||||
// Forme Juridique
|
||||
|
||||
// Nationalité
|
||||
|
||||
// Activité
|
||||
|
||||
// Siège social
|
||||
/*
|
||||
<tr>
|
||||
<td bgcolor="#336699"><img src="../images/shim.gif" width="2" height="2"></td>
|
||||
<td align="left" valign="top" bgcolor="#FFFFFF" class="boldtextarial">Siège
|
||||
social</td>
|
||||
<td bgcolor="#336699"><img src="../images/shim.gif" width="2" height="2"></td>
|
||||
|
||||
<td align="left" valign="top" bgcolor="#EBF0F5" class="basictext">75 Avenue la Grande Armee<br>
|
||||
75116 PARIS 16 </td>
|
||||
</tr>
|
||||
</table>
|
||||
<div align="center"><img src="../images/degrade580grey.jpg" width="580" height="12"><br>
|
||||
<br>
|
||||
</div>
|
||||
<table width="600" border="0" cellspacing="0" cellpadding="0">
|
||||
|
||||
<tr>
|
||||
<td align="left" valign="top"><img src="../images/arrowsmallblue.gif" width="9" height="10"><span class="boldtextarialblue15">Renseignements
|
||||
juridiques</span></td>
|
||||
<td> </td>
|
||||
</tr>
|
||||
</table>
|
||||
<table width="580" border="0" align="center" cellpadding="1" cellspacing="2">
|
||||
|
||||
|
||||
<tr align="left" valign="top">
|
||||
<td width="5" bgcolor="#336699"><img src="../images/shim.gif" width="2" height="2"></td>
|
||||
|
||||
<td width="185" bgcolor="#FFFFFF" class="boldtextarial">Forme
|
||||
juridique</td>
|
||||
<td width="5" bgcolor="#336699"><img src="../images/shim.gif" width="2" height="2"></td>
|
||||
<td width="385" bgcolor="#EBF0F5" class="basictext">SA à conseil d'administration</td>
|
||||
</tr>
|
||||
|
||||
<tr align="left" valign="top">
|
||||
<td width="5" bgcolor="#336699"><img src="../images/shim.gif" width="2" height="2"></td>
|
||||
<td width="185" bgcolor="#FFFFFF" class="boldtextarial">Capital social</td>
|
||||
|
||||
<td width="5" bgcolor="#336699"><img src="../images/shim.gif" width="2" height="2"></td>
|
||||
<td width="385" bgcolor="#EBF0F5" class="basictext">171.285.000,00
|
||||
EURO</td>
|
||||
</tr>
|
||||
|
||||
<tr align="left" valign="top">
|
||||
<td width="5" bgcolor="#336699"><img src="../images/shim.gif" width="2" height="2"></td>
|
||||
<td width="185" bgcolor="#FFFFFF" class="boldtextarial">Nationalité</td>
|
||||
<td width="5" bgcolor="#336699"><img src="../images/shim.gif" width="2" height="2"></td>
|
||||
<td bgcolor="#EBF0F5" class="basictext">France</td>
|
||||
|
||||
</tr>
|
||||
|
||||
</table>
|
||||
<div align="center"><img src="../images/degrade580grey.jpg" width="580" height="12"><br>
|
||||
<br>
|
||||
</div>
|
||||
<div align="center">
|
||||
<table width="588" border="0" cellpadding="0" cellspacing="0">
|
||||
<tr>
|
||||
<td width="210" align="left" valign="top"><img src="../images/arrowsmallblue.gif" width="9" height="10"><span class="boldtextarialblue15">Chiffres
|
||||
clés</span></td>
|
||||
|
||||
<td width="378" align="left" valign="top" class="smalltext">au 31-12-2004</td>
|
||||
</tr>
|
||||
</table>
|
||||
<table width="580" border="0" align="center" cellpadding="1" cellspacing="2">
|
||||
<tr>
|
||||
<td width="5" bgcolor="#336699"><img src="../images/shim.gif" width="2" height="2"></td>
|
||||
<td width="185" align="left" valign="top" bgcolor="#FFFFFF" class="boldtextarial">Chiffre
|
||||
d'affaires</td>
|
||||
<td width="5" bgcolor="#336699"><img src="../images/shim.gif" width="2" height="2"></td>
|
||||
|
||||
<td width="385" align="left" valign="top" bgcolor="#EBF0F5" class="basictext">18.049.000.000
|
||||
EU</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td width="5" bgcolor="#336699"><img src="../images/shim.gif" width="2" height="2"></td>
|
||||
<td width="185" align="left" valign="top" bgcolor="#FFFFFF" class="boldtextarial">Effectif</td>
|
||||
<td width="5" bgcolor="#336699"><img src="../images/shim.gif" width="2" height="2"></td>
|
||||
<td width="385" align="left" valign="top" bgcolor="#EBF0F5" class="basictext">De 5150 à 5720</td>
|
||||
|
||||
</tr>
|
||||
</table>
|
||||
<div align="center"><img src="../images/degrade580grey.jpg" width="580" height="12"><br>
|
||||
<br>
|
||||
<br>
|
||||
</div>
|
||||
</div>
|
||||
<table width="600" border="0" cellspacing="2" cellpadding="0">*/
|
||||
return $tabRet;
|
||||
}
|
||||
|
||||
function getDataEcoCoface($pageHtml) {
|
||||
|
||||
global $libelleErreur;
|
||||
|
||||
$tabRet=array();
|
||||
|
||||
// SIREN
|
||||
$pos=strpos($pageHtml, '<b><font class="nota">La forme juridique ou la date de création trop récente de l\'entreprise ne nous permettant pas d\'obtenir suffisamment d\'informations, nous vous offrons ce produit.</font></b>');
|
||||
if ($pos>0) {
|
||||
$tabRet['infoEco']='OUI';
|
||||
$tabRet['societeInactive']=@getTextInHtml($pageHtml, '<td bgcolor="#F3E5CC" class="tabligne" > Société inactive</td>', '<td bgcolor="#FFF3DE" class="tabval" > ', '</td>');
|
||||
$strCapital=@getTextInHtml($pageHtml, '<td bgcolor="#F3E5CC" class="tabligne" > Capital   (', '(', '</tr><tr>');
|
||||
$tabTmp=explode('</td>', $strCapital);
|
||||
$tabRet['capital_source']=str_replace(')', '', $tabTmp[0]);
|
||||
$tabTmp=explode(' ', $tabTmp[1]);
|
||||
$tabRet['capital_montant']=str_replace(chr(160), '', trim(strip_tags($tabTmp[0])));
|
||||
$tabRet['capital_devise']=trim(strip_tags($tabTmp[1]));
|
||||
$tabRet['dateCreation']=@getTextInHtml($pageHtml, '<td bgcolor="#F3E5CC" class="tabligne" > Date de création</td>', '<td bgcolor="#FFF3DE" class="tabval" > ', '</td>');
|
||||
$tabRet['formeJuridique']=@getTextInHtml($pageHtml, '<td bgcolor="#F3E5CC" class="tabligne" > Forme juridique</td>', '<td bgcolor="#FFF3DE" class="tabval" > ', '</td>');
|
||||
$tabRet['cotationBourse']=@getTextInHtml($pageHtml, '<td bgcolor="#F3E5CC" class="tabligne" > Cotation en bourse</td>', '<td bgcolor="#FFF3DE" class="tabval" > ', '</td>');
|
||||
$tabRet['effectifSociete']=@getTextInHtml($pageHtml, '<td bgcolor="#F3E5CC" class="tabligne" > Effectif société</td>', '<td bgcolor="#FFF3DE" class="tabval" > ', '</td>');
|
||||
$tabRet['activite']=@getTextInHtml($pageHtml, '<td bgcolor="#F3E5CC" class="tabligne" > Activité</td>', '<td bgcolor="#FFF3DE" class="tabval" > ', '</td>');
|
||||
|
||||
$tabRet['sigle']=@getTextInHtml($pageHtml, '<td bgcolor="#F3E5CC" class="tabligne" > Sigle</td>', '<td bgcolor="#FFF3DE" class="tabval" > ', '</td>');
|
||||
$tabRet['enseigne']=@getTextInHtml($pageHtml, '<td bgcolor="#F3E5CC" class="tabligne" > Enseigne</td>', '<td bgcolor="#FFF3DE" class="tabval" > ', '</td>');
|
||||
|
||||
// Dirigeants
|
||||
$strDir=@getTextInHtml($pageHtml, '<td class="tabtot">IDENTITE</td>', '<td> </td>', '</table>');
|
||||
$tabDir=explode('</tr>', $strDir);
|
||||
$nbDir=1;
|
||||
foreach ($tabDir as $key => $dir)
|
||||
{
|
||||
$tabTmp=explode('<td bgcolor="#FFF3DE" class="tabval" > ', $dir);
|
||||
$typeDir=trim(strip_tags($tabTmp[0]));
|
||||
$nomDir=trim(strip_tags($tabTmp[1]));
|
||||
if ($typeDir<>'' && $typeDir<>'Date de création' && $typeDir<>'Forme juridique' && $typeDir<>'Cotation en bourse'
|
||||
&& $typeDir<>'Effectif société' && $typeDir<>'Société inactive' && $typeDir<>'Activité'
|
||||
&& $typeDir<>'Sigle' && $typeDir<>'Enseigne'
|
||||
&& substr($typeDir, 0, 8) <>'Capital ' )
|
||||
{
|
||||
//$tabDir['Produits'].=$produit.'/';
|
||||
//$produit=str_replace(' ','_',$produit);
|
||||
$tabRet['Dirigeant'.$nbDir.'Type']=trim($typeDir);
|
||||
$tabTmp=explode(' ', $nomDir);
|
||||
$tabRet['Dirigeant'.$nbDir.'Genre']=trim($tabTmp[0]);
|
||||
$tabRet['Dirigeant'.$nbDir.'Prenom']=trim($tabTmp[1]);
|
||||
$tabRet['Dirigeant'.$nbDir.'Nom']=trim($tabTmp[2]);
|
||||
$nbDir++;
|
||||
}
|
||||
}
|
||||
$tabRet['NbDirigeants']=$nbDir-1;
|
||||
|
||||
// Liens Financiers
|
||||
$strTmp=@getTextInHtml($pageHtml, '<td class="tabtot">LIENS FINANCIERS</td>', '<td> </td>', '</table>');
|
||||
if (strpos($strTmp, 'Néant')>0)
|
||||
$tabRet['LiensFinanciers']='Néant';
|
||||
else
|
||||
$tabRet['LiensFinanciers']='Présence liens';
|
||||
|
||||
// ELEMENTS FINANCIERS
|
||||
$strTmp=@getTextInHtml($pageHtml, '<td class="tabtot">ELEMENTS FINANCIERS</td>', '<td> </td>', '</table>');
|
||||
if (strpos($strTmp, 'Néant')>0)
|
||||
$tabRet['ElementsFinanciers']='Néant';
|
||||
else
|
||||
$tabRet['ElementsFinanciers']='Présence El.Fi.';
|
||||
}
|
||||
else
|
||||
$tabRet['infoEco']='NON';
|
||||
|
||||
//echo $pageHtml;
|
||||
//print_r($tabRet);
|
||||
//die();
|
||||
|
||||
return $tabRet;
|
||||
}
|
||||
|
||||
|
||||
function getDataEntrepriseCoface($pageHtml) {
|
||||
|
||||
global $libelleErreur;
|
||||
|
||||
$tabRet=array();
|
||||
|
||||
// SIREN
|
||||
$tabRet['siren']=@getTextInHtml($pageHtml, 'portail/entreprise_identite/identite.asp?nsiren=', '?nsiren=', '&IMPRESSION=OUI');
|
||||
//$tabRet['siren']=@getTextInHtml($pageHtml, '<a href="http://www.coface.fr" target="_blank"> Qui sommes nous </a>-<a href="javascript:;" onClick="MM_openBrWindow(\'../mod_cofacescrl/part_recherche.asp?nscrl=18452&metier=ALL&geo=ALL&idnav=168d25840396c5f38f4
|
||||
$tabRet['nscrl']=@getTextInHtml($pageHtml, 'Plan du site </a>-<a href="http://www.coface.fr" target="_blank"> Qui sommes nous </a>-<a href="javascript:;" onClick="MM_openBrWindow(\'../mod_cofacescrl/part_recherche.asp?nscrl=', '?nscrl=', '&metier=ALL&geo=ALL&idnav=');
|
||||
|
||||
// Raison Sociale, Adresse et lien vers Géoloc
|
||||
$strRS_Adr=@getTextInHtml($pageHtml, '<td WIDTH="40%" bgcolor="#F3E5CC" class="tabligne"> <b> Raison sociale<br>', '<td WIDTH="60%" bgcolor="#FFF3DE" class="tabval"><b>', '</b></td>');
|
||||
$tabRS_Adr=explode('<br>', $strRS_Adr);
|
||||
$tabRet['raisonSociale']=trim($tabRS_Adr[0]);
|
||||
$tabRS_Adr1=explode(' ', $tabRS_Adr[1]);
|
||||
$tabRet['AdresseLigne1']=trim($tabRS_Adr1[0]);
|
||||
$tabRet['AdresseLigne2']=trim($tabRS_Adr1[1]);
|
||||
$tabRS_Adr1=explode(' ', $tabRS_Adr[2]);
|
||||
$tabRet['codePostal']=trim($tabRS_Adr1[0]);
|
||||
$tabRet['ville']=trim($tabRS_Adr1[1]);
|
||||
$tabRet['UrlGeoLoc']=@getTextInHtml($pageHtml, '<td WIDTH="60%" bgcolor="#FFF3DE" class="tabval"><a href="javascript:;" onClick="MM_openBrWindow(\'', 'onClick="MM_openBrWindow(\'', '\',\'Planfax');
|
||||
|
||||
// Téléphone / Fax
|
||||
$strTelFax=@getTextInHtml($pageHtml, '<td bgcolor="#F3E5CC" class="tabligne"><b>Téléphone<br>', '<td bgcolor="#FFF3DE" class="tabval" valign="top">', '</td>');
|
||||
$tabTelFax=explode('<br>', $strTelFax);
|
||||
$tabRet['tel']=trim($tabTelFax[0]);
|
||||
$tabRet['fax']=trim($tabTelFax[1]);
|
||||
|
||||
// Adresse Internet / Email
|
||||
$strInet=@getTextInHtml($pageHtml, '<td bgcolor="#F3E5CC" class="tabligne"><b>Adresse internet <br>', '<td bgcolor="#FFF3DE" class="tabval"><a class="tabval" HREF="', '</a></td>');
|
||||
$tabInet=explode('<br>', $strInet);
|
||||
$tabRet['web']=trim( @getTextInHtml($tabInet[0], ' target="_new">', '>', '</a>') );
|
||||
$tabRet['mail']=trim( @getTextInHtml($tabInet[1], ' href="mailto:', ':', '">') );
|
||||
|
||||
// Bourse
|
||||
$strBourse=@getTextInHtml($pageHtml, '<td bgcolor="#F3E5CC" class="tabligne"> <b>'."\r\n".' Code Sicovam<br>', '<td bgcolor="#FFF3DE" class="tabval">', '</td>');
|
||||
$tabBourse=explode('<br>', $strBourse);
|
||||
$tabRet['bourse_isin']=trim($tabBourse[0]);
|
||||
$tabRet['bourse_marche']=trim($tabBourse[1]);
|
||||
$tabRet['bourse_ville']=trim($tabBourse[2]);
|
||||
|
||||
// Activité
|
||||
$tabRet['activite']=trim(str_replace(' ', ' ', @getTextInHtml($pageHtml, '<td WIDTH="40%" bgcolor="#F3E5CC" class="tabligne" valign="top"><b>Libellé code activité </b></td>', '<td WIDTH="60%" bgcolor="#FFF3DE" class="tabval">', '</td>')));
|
||||
|
||||
// Produits disponibles
|
||||
$strDispos=@getTextInHtml($pageHtml, '<table border="0" cellpadding="0" cellspacing="0" width="98%"><tr><td class="normal"><b>Produits disponibles</b></td></tr><tr><td bgcolor="#E1D0B6"><img src="../images/vide.gif" border="0" height="1"><br></td></tr><tr><td><img src="../images/vide.gif" border="0" height="5"><br></td></tr></table>', '<table border="0" cellpadding="5" cellspacing="0" width="100%">', '</table>');
|
||||
$tabDispos=explode('<td align="left" width="25%"', $strDispos);
|
||||
$tabRet['Produits']='';
|
||||
foreach ($tabDispos as $key => $produit)
|
||||
{
|
||||
$produit=trim(str_replace('>', '', str_replace('nowrap>', '', strip_tags($produit))));
|
||||
if ($produit<>'' && $produit<>' ') {
|
||||
$tabRet['Produits'].=$produit.'/';
|
||||
$produit=str_replace(' ','_',$produit);
|
||||
$tabRet['Produit_'.$produit]='Oui';
|
||||
}
|
||||
}
|
||||
// print_r($tabRet);
|
||||
// die();
|
||||
|
||||
return $tabRet;
|
||||
}
|
||||
|
||||
|
||||
function getTabListeBilans($pageHtml) {
|
||||
$tabUrl=array();
|
||||
$deb=$fin=0;
|
||||
while( is_int(($deb=strpos($pageHtml,'<a href="http://www.societe.com/cgi-bin/bilan?bil=',$fin))) ) {
|
||||
$deb=$deb+9;
|
||||
$fin = strpos($pageHtml,'</a>', $deb);
|
||||
$s_temp = substr($pageHtml, $deb, ($fin-$deb));
|
||||
//echo $s_temp."\r\n";
|
||||
$a_temp = explode('" class="basic">', $s_temp);
|
||||
$tabUrl[$a_temp[1]]=$a_temp[0];
|
||||
}
|
||||
return $tabUrl;
|
||||
}
|
||||
|
||||
function getTabListeGU($pageHtml) {
|
||||
$tabGU=array();
|
||||
$deb=$fin=0;
|
||||
/* <tr><td><img alt="" src="b.gi onMouseOver="javascript:mOvr(this);" onMouseOut="javascript:mOut(this);"><a class=txt9px href="javascript:ChoixGeo('CP_PDR_SUP_LOC_REQ')">Lancer la recherche dans toute la localité</td></tr>
|
||||
<tr><td><img src="b.gif" alt="" border=0></td><td align="left" onMouseOver="javascript:mOvr(this);" onMouseOut="javascript:mOut(this);"><a class=txt9px href="javascript:ChoixGeo('CP_INSCRIPTIONS_REQ')">Lancer la recherche sans l'adresse</td></tr>
|
||||
*/
|
||||
while( is_int(($deb=strpos($pageHtml,'<td onMouseOver="javascript:mOvr(this);" onMouseOut="javascript:mOut(this);"><a class="txt9px" href="javascript:ChoixGeo(\'',$fin))) ) {
|
||||
$deb=$deb+122;
|
||||
$fin = strpos($pageHtml,'</td></tr>', $deb);
|
||||
$s_temp = substr($pageHtml, $deb, ($fin-$deb));
|
||||
//echo $s_temp."\r\n";
|
||||
$a_temp = explode('\')">', $s_temp);
|
||||
$tabGU[$a_temp[1]]=$a_temp[0];
|
||||
}
|
||||
return $tabGU;
|
||||
}
|
||||
|
||||
function getTabListeNonTrouve($pageHtml) {
|
||||
$tabGU=array();
|
||||
$deb=$fin=0;
|
||||
/* onMouseOver="javascript:mOvr(this);" onMouseOut="javascript:mOut(this);"><a class=txt9px href="javascript:ChoixGeo('CP_PDR_SUP_LOC_REQ')">Lancer la recherche dans toute la localité</td></tr>
|
||||
onMouseOver="javascript:mOvr(this);" onMouseOut="javascript:mOut(this);"><a class=txt9px href="javascript:ChoixGeo('CP_INSCRIPTIONS_REQ')">Lancer la recherche sans l'adresse</td></tr>
|
||||
*/
|
||||
while( is_int(($deb=strpos($pageHtml,'onMouseOver="javascript:mOvr(this);" onMouseOut="javascript:mOut(this);"><a class=txt9px href="javascript:ChoixGeo(\'',$fin))) ) {
|
||||
$deb=$deb+116;
|
||||
$fin = strpos($pageHtml,'</td></tr>', $deb);
|
||||
$s_temp = substr($pageHtml, $deb, ($fin-$deb));
|
||||
//echo $s_temp."\r\n";
|
||||
$a_temp = explode('\')">', $s_temp);
|
||||
$tabGU[$a_temp[1]]=$a_temp[0];
|
||||
}
|
||||
return $tabGU;
|
||||
}
|
||||
/** Recherche un texte dans une page HTML
|
||||
**
|
||||
**/
|
||||
function getTextInHtml($pageHtml, $strToFind, $strDeb, $strEnd, $include_strDeb=false, $include_strEnd=false, $ltrim=true, $rtrim=true, &$fin, $nbOcc=1) {
|
||||
$tabRet=array();
|
||||
$deb=$nbOccTrouve=0;
|
||||
while( is_int(($deb=strpos($pageHtml,$strToFind,$fin))) ) {
|
||||
$deb++;
|
||||
$deb2 = strpos($pageHtml,$strDeb, $deb);
|
||||
$fin = strpos($pageHtml,$strEnd, $deb2);
|
||||
if (!$include_strDeb)
|
||||
$deb2+=strlen($strDeb);
|
||||
$s_temp = substr($pageHtml, $deb2, ($fin-$deb2));
|
||||
|
||||
if ($ltrim) $s_temp=ltrim($s_temp);
|
||||
if ($rtrim) $s_temp=rtrim($s_temp);
|
||||
|
||||
if ($nbOcc==1) return $s_temp;
|
||||
//echo $s_temp."\r\n";
|
||||
//$a_temp = explode('" class="basic">', $s_temp);
|
||||
$tabUrl[$nbOccTrouve]=$s_temp;
|
||||
$nbOccTrouve++;
|
||||
|
||||
if ($nbOcc==$nbOccTrouve) {
|
||||
// echo "j'ai trouvé le nb demandé, je sort\r\n";
|
||||
break;
|
||||
};
|
||||
}
|
||||
|
||||
return $tabUrl;
|
||||
/*<span class="mongrasvert">
|
||||
<li>Le type de voie a été modifié<br>
|
||||
<li>L'orthographe du mot directeur a été modifiée<br>
|
||||
<li>Le code postal a été forcé à partir du département et de la localité<br> </span>
|
||||
*/
|
||||
}
|
||||
?>
|
89
library/Metier/common/normad.class.php
Normal file
89
library/Metier/common/normad.class.php
Normal file
@ -0,0 +1,89 @@
|
||||
<?
|
||||
//include('fonctions.php');
|
||||
//include('insee.class.php');
|
||||
define('HOST_NORMAD', 'www.normad.fr');
|
||||
define('SITE_NORMAD', 'http://'. HOST_NORMAD .'/');
|
||||
|
||||
//$normad2=new Normad('SCI BRYGE', 'Kervegant', '', '', '', '29', 'SCAER');
|
||||
|
||||
class Normad {
|
||||
/** Normalise l'adresse postale donnée en paramètre. Seule la ligne 1 qui devrait comporter la Raison Sociale ou le nom de l'expéditeur reste inchangée !
|
||||
** @param $adrL1 Obligatoirement le Nom ou la Raison Sociale du destinataire
|
||||
** @param $adrL2 Normalisation = Appart.,Bâtiment...
|
||||
** @param $adrL3 Normalisation = Résidence,Cité...
|
||||
** @param $adrL4 Normalisation = Num./Bis/Type voie/Nom voie
|
||||
** @param $adrL5 Normalisation = BP,TSA,Lieu-dit...
|
||||
** @param $codPos Code Postal (ou département)
|
||||
** @param $ville Ville (orthographe correcte si possible si pas de CP)
|
||||
** @return array
|
||||
**/
|
||||
function Normad ($adrL1, $adrL2, $adrL3, $adrL4, $adrL5, $codPos, $ville) {
|
||||
$adrL1 =substr(trim($adrL1) , 0, 40);
|
||||
$adrL2 =substr(trim($adrL2) , 0, 40);
|
||||
$adrL3 =substr(trim($adrL3) , 0, 40);
|
||||
$adrL4 =substr(trim($adrL4) , 0, 40);
|
||||
$adrL5 =substr(trim($adrL5) , 0, 40);
|
||||
$codPos=substr(trim($codPos), 0, 5);
|
||||
$ville =substr(trim($ville) , 0, 33);
|
||||
$postData=array( 'ad1'=>$adrL2, //htmlentities($adrL2),
|
||||
'ad2'=>$adrL3, //htmlentities($adrL3),
|
||||
'ad3'=>$adrL4, //htmlentities($adrL4),
|
||||
'ad4'=>$adrL5, //htmlentities($adrL5),
|
||||
'cod'=>$codPos,
|
||||
'loc'=>htmlentities($ville),
|
||||
'hiddenField'=>'GEN',);
|
||||
$tabHtml=getUrl(SITE_NORMAD.'traiter_adresse.php', '', $postData, SITE_NORMAD.'validez.php', true, HOST_NORMAD);
|
||||
$page=$tabHtml['body'];
|
||||
$posInHtml=0;
|
||||
$tabRet=array();
|
||||
|
||||
$retour=trim(str_replace(chr(173), '', getTextInHtml($page, '<td colspan=2><font face="Arial" size="2" color="#3F5A80"><b>', '<b>', '</b></font>', false, true, true, true, $posInHtml)));
|
||||
$retour=explode('[*', $retour);
|
||||
$tabRet['retour_code']=str_replace(']','',$retour[1]);
|
||||
$tabRet['retour_libelle']=trim($retour[0]);
|
||||
$tabRet['retour_messages']=getTextInHtml($page, '<li>', 'i>', '<br>', false, false, true, true, $posInHtml, 0);
|
||||
|
||||
// Récupération des Lignes d'adresse
|
||||
$tabRet['ligne1']=$adrL1;
|
||||
$tabRet['ligne2']=getTextInHtml($page, '<td class="gris2"><span class=grasnoir>Adresse en sortie :</span>', '<td class=gras nowrap>', '</td>', false, false, true, true, $posInHtml);
|
||||
$tabRet['ligne3']=getTextInHtml($page, '<td class=pet align=right nowrap> Volet 2 : </td>', '<td class=gras nowrap>', '</td>', false, false, true, true, $posInHtml);
|
||||
$tabRet['ligne4']=getTextInHtml($page, '<td class=pet align=right nowrap> Volet ', '<td class=gras nowrap>', '</td>', false, false, true, true, $posInHtml);
|
||||
$tabRet['ligne5']=getTextInHtml($page, '<td class=pet align=right nowrap> Volet 4 : </td>', '<td class=gras nowrap>', '</td>', false, false, true, true, $posInHtml);
|
||||
$tabRet['CP']=getTextInHtml($page, '<td class=pet align=right nowrap> CP : </td>', '<td class=gras nowrap>', '</td>', false, false, true, true, $posInHtml);
|
||||
$tabRet['ville']=getTextInHtml($page, '<td class=pet align=right nowrap> Localité : </td>', '<td class=gras nowrap>', '</td>', false, false, true, true, $posInHtml);
|
||||
$tabRet['ligne6']=$tabRet['CP'] .' '. $tabRet['ville'];
|
||||
|
||||
// Découpage de la rue
|
||||
$tabRet['voie_num']=getTextInHtml($page, '<span class=pet>Numéro ', '<span class=gras>', '</span><br>', false, false, true, true, $posInHtml);
|
||||
$tabRet['voie_btq']=getTextInHtml($page, '<span class=pet>Bis/Ter/Quater/...', '<span class=gras>', '</span><br>', false, false, true, true, $posInHtml);
|
||||
$tabRet['voie_type']=getTextInHtml($page, '<span class=pet>Type', '<span class=gras>', '</span><br>', false, false, true, true, $posInHtml);
|
||||
$tabRet['voie_denom']=getTextInHtml($page, '<span class=pet>Dénomination', '<span class=gras>', '</span><br>', false, false, true, true, $posInHtml);
|
||||
$tabRet['voie_motDir']=getTextInHtml($page, 'directeur :</span> ', '<span class=gras>', '</span><br>', false, false, true, true, $posInHtml);
|
||||
$tabRet['voie_matric']=getTextInHtml($page, '<span class=pet>Matricule voie :</span>', '</span>', '<br>', false, true, true, true, $posInHtml);
|
||||
$tabRet['code_insee_commune']=getTextInHtml($page, '<span class=pet>Code INSEE commune :</span>', '</span>', '<br>', false, true, true, true, $posInHtml);
|
||||
|
||||
print_r($tabRet);
|
||||
//echo "$voie_num\r\n$voie_btq\r\n$voie_type\r\n$voie_denom\r\n$voie_motDir\r\n$voie_matric\r\n$code_insee_commune\r\n";
|
||||
}
|
||||
|
||||
/*
|
||||
<td class="gris2" valign=top><span class=grasnoir>Détails :</span><br>
|
||||
|
||||
00441644 <br>
|
||||
|
||||
28074 <br>
|
||||
<br>
|
||||
<br>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<hr size=1>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan=3><p class="gris2" align="justify"> </p>
|
||||
<p class="mongrasvert" align="right"> Référentiels
|
||||
d'avril 2006 </p>
|
||||
*/
|
||||
|
||||
} ?>
|
170
library/Metier/common/paramCotation.inc
Normal file
170
library/Metier/common/paramCotation.inc
Normal file
@ -0,0 +1,170 @@
|
||||
<?PHP
|
||||
|
||||
$this->tabNotation['A+']=array('Exceptionnel', 'A3++', 'Aaa' ,'AAA' ,'0.001');
|
||||
$this->tabNotation['A'] =array('Excellent', 'A3+', 'Aa1 Aa2 Aa3' ,'AA+ AA AA-' ,'0.01');
|
||||
$this->tabNotation['B+']=array('Très bon', '3++', 'A1' ,'A+' ,'0.02');
|
||||
$this->tabNotation['B'] =array('Bon', '3+', 'A2 A3' ,'A A-' ,'0.04');
|
||||
$this->tabNotation['C+']=array('Assez bon', '3', 'Baa1' ,'BBB+' ,'0.15');
|
||||
$this->tabNotation['C'] =array('Acceptable', '3', 'Baa2' ,'BBB' ,'0.30');
|
||||
$this->tabNotation['C-']=array('Moyen', '3', 'Baa3' ,'BBB-' ,'0.60');
|
||||
$this->tabNotation['D+']=array('Passable', '4+', 'Ba1' ,'BB+' ,'0.90');
|
||||
$this->tabNotation['D'] =array('Médiocre', '4', 'Ba2' ,'BB' ,'1.25');
|
||||
$this->tabNotation['D-']=array('Très médiocre', '4', 'Ba3' ,'BB-' ,'1.60');
|
||||
$this->tabNotation['E+']=array('Mauvais (sous surveillance)', '5', 'B1 B2 B3', 'B+ B B-', '5.00');
|
||||
$this->tabNotation['E'] =array('Très mauvais (sensible, sans incident)', '6', 'Caa', 'CCC', '14.00');
|
||||
$this->tabNotation['E-']=array('Très mauvais (sensible avec incidents)', '8', 'Ca C', 'CC C', '17.00');
|
||||
$this->tabNotation['F'] =array('En défaut, hors procédures judiciaires (douteux)', '8 9', 'D', 'D', 'Défaut');
|
||||
$this->tabNotation['Z'] =array('En défaut, avec procédures judiciaires ou contentieuses (douteux)', 'P', '', '', 'Défaut');
|
||||
|
||||
$this->tabLibActivite[0]='';
|
||||
$this->tabLibActivite[15]='Industries Alimentaires : Collecte Appro';
|
||||
$this->tabLibActivite[3]='Industries Alimentaires : Collecte et 1ère transformation';
|
||||
$this->tabLibActivite[5]='Industries Alimentaires : Eaux de vie et Champagne';
|
||||
$this->tabLibActivite[2]='Industries Alimentaires : Autres activités';
|
||||
$this->tabLibActivite[6]='Industries extractives / Production Distribution : Énergie Eau';
|
||||
$this->tabLibActivite[7]='Construction - BTP';
|
||||
$this->tabLibActivite[1]='Industries Manufacturières';
|
||||
$this->tabLibActivite[8]='Négoce';
|
||||
$this->tabLibActivite[4]='Commerce de Gros';
|
||||
$this->tabLibActivite[9]='Commerce Distribution';
|
||||
$this->tabLibActivite[10]='Grande Distribution';
|
||||
$this->tabLibActivite[12]='Transports';
|
||||
$this->tabLibActivite[13]='Media Technologie de l\'information';
|
||||
$this->tabLibActivite[14]='Services';
|
||||
$this->tabLibActivite[11]='Hôtellerie et Loisirs / Activités immobilières';
|
||||
$this->tabLibActivite[16]='Banques. Assurances. Activités financières';
|
||||
$this->tabLibActivite[17]='Agriculture. Sylviculture. Pêche. Aquaculture';
|
||||
|
||||
$this->tabActivite[15]=array('512A');
|
||||
$this->tabActivite[3]=array('151A','151C','152','153E','155','157','159G','159J','159N','159Q');
|
||||
$this->tabActivite[5]=array('159A','159F');
|
||||
$this->tabActivite[2]=array('151E','151F','153A','153C','153F','154','156','158','159B','159D','159L','159S','159T');
|
||||
$this->tabActivite[6]=array('11','10','12','13','14','401','402','403','410');
|
||||
$this->tabActivite[7]=array('451','452','453','454','455');
|
||||
$this->tabActivite[1]=array('251','252','241','242','243','245','246','247','261','262','263','264','265','266','267','268','244','297','300','311','312','313','314','315','316','321','322','323','17','18','19','20','21','271','272','273','274','275','281','282','283','284','285','286','287','291','292','293','294','295','296','341','342','343','353','351','352','354','355','223','331','332','333','334','335','361','362','363','364','365','366','231','232','233','222','371','372');
|
||||
$this->tabActivite[8]=array();
|
||||
$this->tabActivite[4]=array('511A','511N','511P','512C','512E','512G','512J','513','511C','515A','515C','511E','511G','511J','511L','511R','511T','511U','514','515E','515F','515H','515J','515L','515N','515Q','516','517');
|
||||
$this->tabActivite[9]=array('501','502','503','504','505','521A','521B','521C','521J','522','523','524A','524C','524E','524F','524H','524J','524L','524N','524R','524T','524U','524V','524W','524X','524Y','524Z','525','526');
|
||||
$this->tabActivite[10]=array('521D','521E','521F','521H','524P');
|
||||
$this->tabActivite[12]=array('621','622','623','611','612','602','603','631','632','634','634B','634C','634A','641');
|
||||
$this->tabActivite[13]=array('221','722','721','723','724','725','726','924','642','922','921');
|
||||
$this->tabActivite[14]=array('703','712E','711','712A','713','714','712C','741A','741C','741E','741G','742','743','741J','744','745','746','747','748','900','633','801','802','803','804','851','852','853','930','911','912','913','527','950');
|
||||
$this->tabActivite[11]=array('923','925','926','927','551','552','553','554','555','702');
|
||||
$this->tabActivite[16]=array('651','660','672','652E','652A','652C','652F','671');
|
||||
$this->tabActivite[17]=array('751','990','752','990','701');
|
||||
|
||||
$this->tabR[1][0]=array();
|
||||
$this->tabR[1][1]=array('0:15.5','15.5:21.7','21.7:25','25:29.1','29.1:33.4','33.4:37','37:40','40:42.6','42.6:44.9','44.9:100');
|
||||
$this->tabR[1][2]=array('0:18.7','18.7:22.8','22.8:25','25:27.7','27.7:30.6','30.6:33','33:35','35:36.7','36.7:38.3','38.3:100');
|
||||
$this->tabR[1][3]=array('0:18.7','18.7:22.8','22.8:25','25:27.7','27.7:30.6','30.6:33','33:35','35:36.7','36.7:38.3','38.3:100');
|
||||
$this->tabR[1][4]=array('0:8.7','8.7:12.8','12.8:15','15:17.7','17.7:20.6','20.6:23','23:25','25:26.7','26.7:28.3','28.3:100');
|
||||
$this->tabR[1][5]=array('0:18.7','18.7:22.8','22.8:25','25:27.7','27.7:30.6','30.6:33','33:35','35:36.7','36.7:38.3','38.3:100');
|
||||
$this->tabR[1][6]=array('0:20.5','20.5:26.7','26.7:30','30:34.1','34.1:38.4','38.4:42','42:45','45:47.6','47.6:49.9','49.9:100');
|
||||
$this->tabR[1][7]=array('0:13.7','13.7:17.8','17.8:20','20:22.7','22.7:25.6','25.6:28','28:30','30:31.7','31.7:33.3','33.3:100');
|
||||
$this->tabR[1][8]=array('0:3.7','3.7:7.8','7.8:10','10:12.7','12.7:15.6','15.6:18','18:20','20:21.7','21.7:23.3','23.3:100');
|
||||
$this->tabR[1][9]=array('0:13.7','13.7:17.8','17.8:20','20:22.7','22.7:25.6','25.6:28','28:30','30:31.7','31.7:33.3','33.3:100');
|
||||
$this->tabR[1][10]=array('0:5.7','5.7:9.8','9.8:12','12:14.7','14.7:17.6','17.6:20','20:22','22:23.7','23.7:25.3','25.3:100');
|
||||
$this->tabR[1][11]=array('0:18.7','18.7:22.8','22.8:25','25:27.7','27.7:30.6','30.6:33','33:35','35:36.7','36.7:38.3','38.3:100');
|
||||
$this->tabR[1][12]=array('0:13.7','13.7:17.8','17.8:20','20:22.7','22.7:25.6','25.6:28','28:30','30:31.7','31.7:33.3','33.3:100');
|
||||
$this->tabR[1][13]=array('0:23.7','23.7:27.8','27.8:30','30:32.7','32.7:35.6','35.6:38','38:40','40:41.7','41.7:43.3','43.3:100');
|
||||
$this->tabR[1][14]=array('0:18.7','18.7:22.8','22.8:25','25:27.7','27.7:30.6','30.6:33','33:35','35:36.7','36.7:38.3','38.3:100');
|
||||
$this->tabR[1][15]=array('0:15.5','15.5:21.7','21.7:25','25:29.1','29.1:33.4','33.4:37','37:40','40:42.6','42.6:44.9','44.9:100');
|
||||
$this->tabR[1][16]=array('0:6.8','6.8:8.9','8.9:10','10:11.4','11.4:12.8','12.8:14','14:15','15:15.9','15.9:16.6','16.6:100');
|
||||
$this->tabR[1][17]=array('0:18.7','18.7:22.8','22.8:25','25:27.7','27.7:30.6','30.6:33','33:35','35:36.7','36.7:38.3','38.3:100');
|
||||
|
||||
$this->tabR[2][0]=array();
|
||||
$this->tabR[2][1]=array('1.8:','1.6:1.8','1.5:1.6','1.4:1,5','1.2:1.4','1.0:1.2','0.9:1.0','0.8:0,9','0.7:0,8','0:0.7');
|
||||
$this->tabR[2][2]=array('2.2:','1.9:2.2','1.8:1.9','1.6:1.8','1.4:1.6','1.2:1.4','1.0:1.2','0.9:1.0','0.7:0.9','0:0.7');
|
||||
$this->tabR[2][3]=array('2.2:','1.9:2.2','1.8:1.9','1.6:1.8','1.4:1.6','1.2:1.4','1.0:1.2','0.9:1.0','0.7:0.9','0:0.7');
|
||||
$this->tabR[2][4]=array('3.0:','2.7:3.0','2.5:2.7','2.3:2.5','2.0:2.3','1.7:2.0','1.5:1.7','1.3:1.5','1.1:1.3','0:1.1');
|
||||
$this->tabR[2][5]=array('2.6:','2.4:2.6','2.2:2.4','2.0:2.2','1.7:2.0','1.5:1.7','1.3:1.5','1.1:1.3','1.0:1.1','0:1');
|
||||
$this->tabR[2][6]=array('1.7:','1.6:1.7','1.5:1.6','1.4:1.5','1.2:1.4','1.1:1.2','1.0:1.1','0.9:1.0','0.8:0.9','0:0.8');
|
||||
$this->tabR[2][7]=array('1.5:','1.4:1.5','1.3:1.4','1.1:1.3','1.0:1.2','0.9:1.0','0.8:0.9','0.7:0.8','0.6:0.7','0:0.6');
|
||||
$this->tabR[2][8]=array('10.1:','8.8:10.1','8:8.8','7:8','5.8:7','4.8:5.8','4:4.8','3.3:4','2.8:3.3','0:2.8');
|
||||
$this->tabR[2][9]=array('3:','2.7:3','2.5:2.7','2.3:2.5','2:2.3','1.7:2','1.5:1.7','1.3:1.5','1.1:1.3','0:1.1');
|
||||
$this->tabR[2][10]=array('3.8:','3.3:3.8','3.0:3.3','2.6:3.0','2.2:2.6','1.8:2.2','1.5:1.8','1.2:1.5','1.0:1.2','0:1');
|
||||
$this->tabR[2][11]=array('2.3:','2.1:2.3','2:2.1','1.8:2','1.6:1.8','1.5:1.6','1.3:1.5','1.2:1.3','1:1.2','0:1');
|
||||
$this->tabR[2][12]=array('2.3:','2.1:2.3','2:2.1','1.8:2','1.6:1.8','1.5:1.6','1.3:1.5','1.2:1.3','1:1.2','0:1');
|
||||
$this->tabR[2][13]=array('1.8:','1.6:1.8','1.5:1.6','1.4:1.5','1.2:1.4','1:1.2','0.9:1','0.8:0.9','0.7:0.8','0:0.7');
|
||||
$this->tabR[2][14]=array('1.8:','1.6:1.8','1.5:1.6','1.4:1.5','1.2:1.4','1:1.2','0.9:1','0.8:0.9','0.7:0.8','0:0.7');
|
||||
$this->tabR[2][15]=array('2.2:','1.9:2.2','1.7:1.9','1.5:1.7','1.2:1.5','1.0:1.2','0.8:1.0','0.7:0.8','0.5:0.7','0:0.5');
|
||||
$this->tabR[2][16]=array('10.1:','8.8:10.1','8:8.8','7:8','5.8:7','4.8:5.8','4:4.8','3.3:4','2.8:3.3','0:2.8');
|
||||
$this->tabR[2][17]=array('2.2:','1.9:2.2','1.8:1.9','1.6:1.8','1.4:1.6','1.2:1.4','1:1.2','0.9:1','0.7:0.9','0:0.7');
|
||||
|
||||
$this->tabR[3][0]=array();
|
||||
$this->tabR[3][1]=array('4.4:','4:4.4','3.8:4','3.5:3.8','3.1:3.5','2.8:3.1','2.5:2.8','2.2:2.5','2:2.2','0:2');
|
||||
$this->tabR[3][2]=array('5.2:','4.7:5.2','4.5:4.7','4.1:4.5','3.7:4.1','3.3:3.7','3:3.3','2.7:3','2.4:2.7','0:2.4');
|
||||
$this->tabR[3][3]=array('5.2:','4.7:5.2','4.5:4.7','4.1:4.5','3.7:4.1','3.3:3.7','3:3.3','2.7:3','2.4:2.7','0:2.4');
|
||||
$this->tabR[3][4]=array('5.2:','4.7:5.2','4.5:4.7','4.1:4.5','3.7:4.1','3.3:3.7','3:3.3','2.7:3','2.4:2.7','0:2.4');
|
||||
$this->tabR[3][5]=array('8.6:','7.9:8.6','7.5:7.9','6.9:7.5','6.2:6.9','5.6:6.2','5:5.6','4.5:5','4:4.5','0:4');
|
||||
$this->tabR[3][6]=array('4.4:','4:4.4','3.8:4','3.5:3.8','3.1:3.5','2.8:3.1','2.5:2.8','2.2:2.5','2:2.2','0:2');
|
||||
$this->tabR[3][7]=array('4.4:','4:4.4','3.8:4','3.5:3.8','3.1:3.5','2.8:3.1','2.5:2.8','2.2:2.5','2:2.2','0:2');
|
||||
$this->tabR[3][8]=array('10.9:','9.7:10.9','9:9.7','8:9','6.8:8','5.8:6.8','5:5.8','4.3:5','3.7:4.3','0:3.7');
|
||||
$this->tabR[3][9]=array('5.2:','4.7:5.2','4.5:4.7','4.1:4.5','3.7:4.1','3.3:3.7','3:3.3','2.7:3','2.4:2.7','0:2.4');
|
||||
$this->tabR[3][10]=array('5.2:','4.7:5.2','4.5:4.7','4.1:4.5','3.7:4.1','3.3:3.7','3:3.3','2.7:3','2.4:2.7','0:2.4');
|
||||
$this->tabR[3][11]=array('5.2:','4.7:5.2','4.5:4.7','4.1:4.5','3.7:4.1','3.3:3.7','3:3.3','2.7:3','2.4:2.7','0:2.4');
|
||||
$this->tabR[3][12]=array('5.9:','5.4:5.9','5:5.4','4.5:5','3.9:4.5','3.4:3.9','3:3.4','2.6:3','2.3:2.6','0:2.3');
|
||||
$this->tabR[3][13]=array('4.2:','3.8:4.2','3.5:3.8','3.1:3.5','2.7:3.1','2.3:2.7','2:2.3','1.7:2','1.5:1.7','0:1.5');
|
||||
$this->tabR[3][14]=array('4.2:','3.8:4.2','3.5:3.8','3.1:3.5','2.7:3.1','2.3:2.7','2:2.3','1.7:2','1.5:1.7','0:1.5');
|
||||
$this->tabR[3][15]=array('6.9:','6.3:6.9','6.0:6.3','5.5:6.0','5.0:5.5','4.5:5.0','4.0:4.5','3.6:4.0','3.2:3.6','0:3.2');
|
||||
$this->tabR[3][16]=array('10.9:','9.7:10.9','9:9.7','8:9','6.8:8','5.8:6.8','5:5.8','4.3:5','3.7:4.3','0:3.7');
|
||||
$this->tabR[3][17]=array('5.2:','4.7:5.2','4.5:4.7','4.1:4.5','3.7:4.1','3.3:3.7','3:3.3','2.7:3','2.4:2.7','0:2.4');
|
||||
|
||||
$this->tabR[4][0]=array();
|
||||
$this->tabR[4][1]=array('0:2','2:2.3','2.3:2.5','2.5:2.9','2.9:3.5','3.5:4.2','4.2:5','5:6','6:7.2','7.2:');
|
||||
$this->tabR[4][2]=array('0:2','2:2.3','2.3:2.5','2.5:2.9','2.9:3.5','3.5:4.2','4.2:5','5:6','6:7.2','7.2:');
|
||||
$this->tabR[4][3]=array('0:2','2:2.3','2.3:2.5','2.5:2.9','2.9:3.5','3.5:4.2','4.2:5','5:6','6:7.2','7.2:');
|
||||
$this->tabR[4][4]=array('0:2','2:2.3','2.3:2.5','2.5:2.9','2.9:3.5','3.5:4.2','4.2:5','5:6','6:7.2','7.2:');
|
||||
$this->tabR[4][5]=array('0:1.36','1.36:1.44','1.44:1.5','1.5:1.58','1.58:1.71','1.71:1.85','1.85:2','2:2.16','2.16:2.33','2.33:');
|
||||
$this->tabR[4][6]=array('0:2','2:2.3','2.3:2.5','2.5:2.9','2.9:3.5','3.5:4.2','4.2:5','5:6','6:7.2','7.2:');
|
||||
$this->tabR[4][7]=array('0:2','2:2.3','2.3:2.5','2.5:2.9','2.9:3.5','3.5:4.2','4.2:5','5:6','6:7.2','7.2:');
|
||||
$this->tabR[4][8]=array('0:1.1','1.1:1.2','1.2:1.3','1.3:1.4','1.4:1.6','1.6:1.8','1.8:2','2:2.2','2.2:2.5','2.5:');
|
||||
$this->tabR[4][9]=array('0:2','2:2.3','2.3:2.5','2.5:2.9','2.9:3.5','3.5:4.2','4.2:5','5:6','6:7.2','7.2:');
|
||||
$this->tabR[4][10]=array('0:2','2:2.3','2.3:2.5','2.5:2.9','2.9:3.5','3.5:4.2','4.2:5','5:6','6:7.2','7.2:');
|
||||
$this->tabR[4][11]=array('0:2','2:2.3','2.3:2.5','2.5:2.9','2.9:3.5','3.5:4.2','4.2:5','5:6','6:7.2','7.2:');
|
||||
$this->tabR[4][12]=array('0:2','2:2.3','2.3:2.5','2.5:2.9','2.9:3.5','3.5:4.2','4.2:5','5:6','6:7.2','7.2:');
|
||||
$this->tabR[4][13]=array('0:2.4','2.4:2.7','2.7:3','3:3.4','3.4:4.1','4.1:5','5:6','6:7.2','7.2:8.7','8.7:');
|
||||
$this->tabR[4][14]=array('0:2.4','2.4:2.7','2.7:3','3:3.4','3.4:4.1','4.1:5','5:6','6:7.2','7.2:8.7','8.7:');
|
||||
$this->tabR[4][15]=array('0:2.9','2.9:3.4','3.4:3.7','3.7:4.3','4.3:5.2','5.2:6.2','6.2:7.5','7.5:9.1','9.1:10.9','10.9:');
|
||||
$this->tabR[4][16]=array('0:1.1','1.1:1.2','1.2:1.3','1.3:1.4','1.4:1.6','1.6:1.8','1.8:2','2:2.2','2.2:2.5','2.5:');
|
||||
$this->tabR[4][17]=array('0:2','2:2.3','2.3:2.5','2.5:2.9','2.9:3.5','3.5:4.2','4.2:5','5:6','6:7.2','7.2:');
|
||||
|
||||
$this->tabR[5][0]=array();
|
||||
$this->tabR[5][1]=array('-99:-40','-40:-34','-34:-30','-30:-24','-24:-16','-16:-8','-8:0','0:8.1','8.1:16.1','16.1:');
|
||||
$this->tabR[5][2]=array('-99:-40','-40:-34','-34:-30','-30:-24','-24:-16','-16:-8','-8:0','0:8.1','8.1:16.1','16.1:');
|
||||
$this->tabR[5][3]=array('-99:-40','-40:-34','-34:-30','-30:-24','-24:-16','-16:-8','-8:0','0:8.1','8.1:16.1','16.1:');
|
||||
$this->tabR[5][4]=array('-99:-16.7','-16.7:-12.7','-12.7:-10','-10:-6','-6:-0.7','-0.7:4.7','4.7:10','10:15.3','15.3:20.7','20.7:');
|
||||
$this->tabR[5][5]=array('-999:-420','-420:-384','-384:-360','-360:-324','-324:-276','-276:-228','-228:-180','-180:-132','-132:-84','-84:');
|
||||
$this->tabR[5][6]=array('-99:-40','-40:-34','-34:-30','-30:-24','-24:-16','-16:-8','-8:0','0:8.1','8.1:16.1','16.1:');
|
||||
$this->tabR[5][7]=array('-99:-30','-30:-24','-24:-20','-20:-14','-14:-6','-6:2','2:10','10:18','18:26','26:');
|
||||
$this->tabR[5][8]=array('-99:-41.7','-41.7:-34.7','-34.7:-30','-30:-23','-23:-13.7','-13.7:-4.3','-4.3:5','5:14.3','14.3:23.7','23.7:');
|
||||
$this->tabR[5][9]=array('-99:-16.7','-16.7:-12.7','-12.7:-10','-10:-6','-6:-0.7','-0.7:4.7','4.7:10','10:15.3','15.3:20.7','20.7:');
|
||||
$this->tabR[5][10]=array('-99:-5','-5:-2','-2:0','0:3','3:7','7:11','11:15','15:19','19:23','23:');
|
||||
$this->tabR[5][11]=array('-99:-6.7','-6.7:-2.7','-2.7:0','0:4','4:9.3','9.3:14.7','14.7:20','20:25.3','25.3:30.7','30.7:');
|
||||
$this->tabR[5][12]=array('-99:-6.7','-6.7:-2.7','-2.7:0','0:4','4:9.3','9.3:14.7','14.7:20','20:25.3','25.3:30.7','30.7:');
|
||||
$this->tabR[5][13]=array('-99:-6.7','-6.7:-2.7','-2.7:0','0:4','4:9.3','9.3:14.7','14.7:20','20:25.3','25.3:30.7','30.7:');
|
||||
$this->tabR[5][14]=array('-99:-6.7','-6.7:-2.7','-2.7:0','0:4','4:9.3','9.3:14.7','14.7:20','20:25.3','25.3:30.7','30.7:');
|
||||
$this->tabR[5][15]=array('-99:-38.3','-38.3:-36.3','-36.3:-35.0','-35:-33','-33.0:-30','-30:-27.7','-27.7:-25.0','-25.0:-22.3','-22.3:-19.7','-19.7:');
|
||||
$this->tabR[5][16]=array('-99:-41.7','-41.7:-34.7','-34.7:-30','-30:-23','-23:-13.7','-13.7:-4.3','-4.3:5','5:14.3','14.3:23.7','23.7:');
|
||||
$this->tabR[5][17]=array(':-58.3','-58.3:53.3','-53.3:-50','-50:-45','-45:-38.3','-38.3:-31.7','-31.7:-25','-25:-18.3','-18.3:-11.7','-11.7:');
|
||||
|
||||
$this->tabR[6][0]=array();
|
||||
$this->tabR[6][1]=array('0:6','6:6.6','6.6:7','7:7.6','7.6:8.4','8.4:9.2','9.2:10','10:10.8','10.8:11.6','11.6:');
|
||||
$this->tabR[6][2]=array('0:6','6:6.6','6.6:7','7:7.6','7.6:8.4','8.4:9.2','9.2:10','10:10.8','10.8:11.6','11.6:');
|
||||
$this->tabR[6][3]=array('0:1.5','1.5:2.1','2.1:2.5','2.5:3.1','3.1:3.9','3.9:4.7','4.7:5.5','5.5:6.3','6.3:7.1','7.1:');
|
||||
$this->tabR[6][4]=array('0:1.8','1.8:2.2','2.2:2.5','2.5:2.9','2.9:3.4','3.4:4','4:4.5','4.5:5','5:5.6','5.6:');
|
||||
$this->tabR[6][5]=array('0:6.7','6.7:7.5','7.5:8','8:8.8','8.8:9.9','9.9:10.9','10.9:12','12:13.1','13.1:14.1','14.1:');
|
||||
$this->tabR[6][6]=array('0:7.7','7.7:8.5','8.5:9','9:9.8','9.8:10.9','10.9:11.9','11.9:13','13:14.1','14.1:15.1','15.1:');
|
||||
$this->tabR[6][7]=array('0:3','3:3.6','3.6:4','4:4.6','4.6:5.4','5.4:6.2','6.2:7','7:7.8','7.8:8.6','8.6:');
|
||||
$this->tabR[6][8]=array('0:1.3','1.3:1.7','1.7:2','2:2.4','2.4:2.9','2.9:3.5','3.5:4','4:4.5','4.5:5.1','5.1:');
|
||||
$this->tabR[6][9]=array('0:1.8','1.8:2.2','2.2:2.5','2.5:2.9','2.9:3.4','3.4:4','4:4.5','4.5:5','5:5.6','5.6:');
|
||||
$this->tabR[6][10]=array('0:1.3','1.3:1.7','1.7:2','2:2.4','2.4:2.9','2.9:3.5','3.5:4','4:4.5','4.5:5.1','5.1:');
|
||||
$this->tabR[6][11]=array('0:8.3','8.3:9.3','9.3:10','10:11','11:12.3','12.3:13.7','13.7:15','15:16.3','16.3:17.7','17.7:');
|
||||
$this->tabR[6][12]=array('0:4.7','4.7:5.5','5.5:6','6:6.8','6.8:7.9','7.9:8.9','8.9:10','10:11.1','11.1:12.1','12.1:');
|
||||
$this->tabR[6][13]=array('0:3','3:4.8','4.8:6','6:7.8','7.8:10.2','10.2:12.6','12.6:15','15:17.4','17.4:19.8','19.8:');
|
||||
$this->tabR[6][14]=array('0:3','3:4.8','4.8:6','6:7.8','7.8:10.2','10.2:12.6','12.6:15','15:17.4','17.4:19.8','19.8:');
|
||||
$this->tabR[6][15]=array('0:2','2:2.3','2.3:2.5','2.5:2.8','2.8:3.2','3.2:3.6','3.6:4.0','4.0:4.4','4.4:4.8','4.8:');
|
||||
$this->tabR[6][16]=array('0:1.7','1.7:1.9','1.9:2','2:2.2','2.2:2.5','2.5:2.7','2.7:3','3:3.3','3.3:3.5','3.5:');
|
||||
$this->tabR[6][17]=array('0:4.7','4.7:5.5','5.5:6','6:6.8','6.8:7.9','7.9:8.9','8.9:10','10:11.1','11.1:12.1','12.1:');
|
||||
|
||||
?>
|
9
library/Metier/common/rncs.class.php
Normal file
9
library/Metier/common/rncs.class.php
Normal file
@ -0,0 +1,9 @@
|
||||
<?
|
||||
class Rncs {
|
||||
|
||||
function Rncs () {}
|
||||
|
||||
|
||||
|
||||
}
|
||||
?>
|
795
library/Metier/conversion/bilAltares.php
Normal file
795
library/Metier/conversion/bilAltares.php
Normal file
@ -0,0 +1,795 @@
|
||||
<?php
|
||||
require_once 'framework/common/chiffres.php';
|
||||
require_once 'framework/common/dates.php';
|
||||
require_once 'Metier/bodacc/classMBodacc.php';
|
||||
require_once 'Metier/insee/classMInsee.php';
|
||||
require_once 'Metier/partenaires/classMRncs.php';
|
||||
require_once 'Metier/partenaires/classMBilans.php';
|
||||
require_once 'Metier/partenaires/classMBourse.php';
|
||||
require_once 'Metier/partenaires/classMLiens.php';
|
||||
require_once 'Metier/scores/classMFinancier.php';
|
||||
require_once 'Metier/scores/classMSolvabilite.php';
|
||||
require_once 'Metier/scores/classMScores.php';
|
||||
require_once 'Metier/partenaires/classMTva.php';
|
||||
require_once 'Metier/partenaires/classMMap.php';
|
||||
require_once 'Metier/partenaires/classMGreffes.php';
|
||||
require_once 'Metier/partenaires/classMPrivileges.php';
|
||||
require_once 'Metier/tmp/configMRatios.php';
|
||||
|
||||
require_once 'framework/mail/sendMail.php';
|
||||
|
||||
global $tabEvenSolib;
|
||||
global $tabEven2SO;
|
||||
global $tabEven2RO;
|
||||
|
||||
$tabEvenSolib=array(1=>'CR',
|
||||
11=>'CR',
|
||||
13=>'CR',
|
||||
14=>'CR',
|
||||
15=>'CR',
|
||||
16=>'CR',
|
||||
17=>'CR',
|
||||
18=>'CR',
|
||||
19=>'CR',
|
||||
2=>'VT',
|
||||
21=>'VT',
|
||||
22=>'VT',
|
||||
24=>'VT',
|
||||
25=>'VT',
|
||||
3=>'CE',
|
||||
31=>'ME',
|
||||
32=>'ME',
|
||||
33=>'ME',
|
||||
34=>'ME',
|
||||
35=>'Rec',
|
||||
36=>'MAF',
|
||||
37=>'LG',
|
||||
38=>'LG',
|
||||
39=>'MD',
|
||||
4=>'RD',
|
||||
41=>'DIS',
|
||||
42=>'FLG',
|
||||
51=>'RJ',
|
||||
52=>'RJ',
|
||||
53=>'RA',
|
||||
56=>'PIE',
|
||||
57=>'SAUVJ',
|
||||
58=>'SAUVP',
|
||||
59=>'RR',
|
||||
6=>'R&L',
|
||||
61=>'LB',
|
||||
62=>'LJ',
|
||||
63=>'FP',
|
||||
64=>'INT',
|
||||
65=>'LQ',
|
||||
69=>'RL',
|
||||
7=>'Suite',
|
||||
71=>'SRJ',
|
||||
72=>'SRLJ',
|
||||
73=>'SP',
|
||||
74=>'AP',
|
||||
75=>'MP',
|
||||
76=>'EP',
|
||||
77=>'PRO',
|
||||
78=>'DC',
|
||||
79=>'CIA',
|
||||
8=>'INFR',
|
||||
91=>'DC',
|
||||
92=>'CP',
|
||||
);
|
||||
|
||||
$tabEven2SO=array( // PROCOL
|
||||
1010=>92, // Déclaration de cessation de paiement
|
||||
1050=>7, // Homologation de la conciliation
|
||||
1055=>7, // Résolution de la conciliation
|
||||
1100=>57, // Jugement de sauvegarde
|
||||
1101=>58, // Plan de sauvegarde
|
||||
1200=>52, // Redressement Judiciaire
|
||||
1201=>52, // Conversion sauvegarde en Redressement Judiciaire
|
||||
1202=>75, // Renouv. Periode Observation
|
||||
1203=>78, // Avis de dépot de l'état de collocation
|
||||
1204=>78, // Dépôt des créances
|
||||
1205=>78,
|
||||
1206=>78,
|
||||
1207=>53, // Règlemement amiable
|
||||
1208=>78,
|
||||
1209=>51, // Règlement Judiciaire
|
||||
1210=>77, // Production
|
||||
1211=>52, // Redressement Judiciaire par extension au(x) gérant(s)
|
||||
1212=>69, // Rectif ou Annul.LJ
|
||||
1214=>78, // Avis de dépôt de l'état des créances (Loi de 1985)
|
||||
1215=>7, // Jugement de désignation des organes de la procédure
|
||||
1216=>78, // Autre avis de dépôt
|
||||
1300=>62, // Conversion Redressement Judiciaire en Liquidation
|
||||
1301=>62, // Ouverture Liquidation Judiciaire
|
||||
1302=>66, // Ouverture Liquidation Judiciaire Simplifiée
|
||||
1303=>62, // Ouverture Liquidation Judiciaire sur résolution
|
||||
1304=>62, // Réouverture Liquidation Judiciaire
|
||||
1305=>62, // Liquidation Judiciaire
|
||||
1306=>66, // Liquidation Judiciaire simplifiée
|
||||
1307=>62, // Conversion sauvegarde en Liquidation Judiciaire
|
||||
1308=>62, // Fin du régime de Liquidation Judiciaire Simplifiée
|
||||
1309=>62, // Conversion Liquidation Judiciaire en Liquidation
|
||||
1310=>56, // Procédure d'Insolvabilité Européenne
|
||||
1311=>62, // Liquidation Judiciaire par extension au(x) gérants
|
||||
1312=>62, // Liquidation Judiciaire avec continuation d'exploitation
|
||||
1313=>62, // Liquidation Judiciaire sans remise des accessoires
|
||||
1346=>7, // Procédure d'insolvabilité (Règlement 1346/2000 du Conseil Européen)
|
||||
1400=>7, // Nomination d'un administrateur judiciaire
|
||||
1401=>7, // Nomination d'un mandataire judiciaire
|
||||
1402=>7, // Nomination d'un représentant des créanciers
|
||||
1403=>7, // Nominnation/Remplacement de commissaire à l'exécution du plan
|
||||
1404=>7, // Prolongement de la mission du commissaire à l'exécution du plan
|
||||
1405=>7, // Nomination d'un juge commissaire
|
||||
1406=>7, // Changement de SYNDIC
|
||||
1407=>75, // Modif. de Plan
|
||||
1408=>75, // Modification du plan de cession
|
||||
1409=>75, // Modif. de de continuation
|
||||
1410=>75, // Suite de jugement/règlement/liquidation
|
||||
1411=>75, // Arrêt du plan de cession
|
||||
1412=>75, // Arrêt du plan de cession partielle
|
||||
1413=>75, // Arrêt du plan de continuation
|
||||
1414=>75, // Arrêt du plan de redressement
|
||||
1415=>75, // Prolongement du plan cession
|
||||
1416=>75, // Jugement constatant la bonne exécution du plan
|
||||
1417=>62, // Jugement d'extension de liquidation judiciaire
|
||||
1418=>52, // Jugement d'extension d'une procédure de redressement judiciaire
|
||||
1419=>57, // Jugement d'extension d'une procédure de sauvegarde
|
||||
1420=>7, // Nomination d'un liquidateur judiciaire
|
||||
1421=>7, // Jugement prorogeant le plan de redressement
|
||||
1425=>7, // Plan de cession avec location gérance
|
||||
1430=>7, // Jugement autorisant la poursuite d'activité
|
||||
1431=>7, // Jugement de cessation partielle d'activité
|
||||
1435=>7, // Suspension de l'exécution provisoire
|
||||
1436=>7, // Suspension provisoire des poursuites
|
||||
1440=>7, // Jugement accordant un délai pour déposer la liste des créances
|
||||
1445=>7, // Concordat
|
||||
1450=>92, //Cessation paiement
|
||||
1455=>7, // Jugement arrêtant le plan d'apurement du passif
|
||||
1460=>7, // Homologation du plan
|
||||
1470=>7, // Fin de mission d'administrateur judiciaire
|
||||
1480=>7, // Jugement ordonnant la jonction des procédures
|
||||
1500=>79, // Clôture de la procédure
|
||||
1501=>79, // Clôture de la procédure après cession totale
|
||||
1502=>76, // Clôture de la procédure pour extinction du passif
|
||||
1503=>79, // Cloture insuf.Actif
|
||||
1504=>79, // Clôture sauvegarde pour absence de projet de plan
|
||||
1505=>74, // Appel de jugement
|
||||
1506=>59, // Rectif ou Annulation RJ
|
||||
1507=>74, // Appel de jugement
|
||||
1508=>7, // Extinction du plan de sauvegarde
|
||||
1509=>7, // Extinction du plan de redressement
|
||||
1510=>74, // Rejet du plan
|
||||
1511=>7, // Résolution du plan de cession
|
||||
1512=>7, // Résolution du plan de continuation
|
||||
1513=>7, // Résolution du plan de sauvegarde
|
||||
1515=>74, // Arrêt divers
|
||||
1517=>59, // Rectification d'une erreur matérielle
|
||||
1520=>7, // Ordonnance
|
||||
1525=>74, // Appel du ministère public
|
||||
1530=>7, // Jugement constatant l'impécuniosité de la procédure de liquidation
|
||||
1540=>7, // Ordonnance statuant sur les contestations du projet de répartition
|
||||
1541=>74, // Rétractation de prononcé de liquidation judiciaire sur tierce opposition
|
||||
1542=>74, // Rétractation de jugement d'ouverture d'une procédure de sauvegarde sur tierce opposition
|
||||
1543=>74, // Rétractation de jugement d'ouverture d'une procédure de redressement judiciaire sur tierce opposition
|
||||
1544=>74, // Rétractation de jugement d'ouverture d'une procédure de liquidation judiciaire sur tierce opposition
|
||||
1545=>74, // Rétractation de jugement d'ouverture sur tierce opposition
|
||||
1546=>74, // Autre rétractation sur tierce opposition
|
||||
1550=>7, // Suites de jugements
|
||||
1580=>7, // Jugement prononçant la continuation de l'activité par apurement du passif
|
||||
1600=>63, // Faillite personnelle
|
||||
1601=>64, // Interdiction de gérer
|
||||
1602=>7, // Jugement de réhabilitation
|
||||
1603=>61, // Liquidation de Biens
|
||||
1604=>8, // Banqueroute
|
||||
1605=>7, // Jugement autorisant la reprise des poursuites individuelles
|
||||
1610=>8, // Faillite personnelle (Loi de 1985)
|
||||
1611=>8, // Interdiction de gérer (Loi de 1985)
|
||||
1620=>7, // Jugement condamnant le dirigeant en comblement du passif
|
||||
1650=>8, // Rétablissement Personnel
|
||||
1700=>7, // Décision soumise à publicité
|
||||
1900=>8, // Interdiction temporaire d'exercice de la profession de CAC
|
||||
1901=>8, // Radiation de la liste des CAC
|
||||
1999=>7, // Autre procédure collective
|
||||
// MMD
|
||||
2000=>4, // Mention d'office
|
||||
2100=>39, // Chg.Capital/Cess.apport de parts
|
||||
2101=>39, // Chg.Capital/Cess.apport de parts
|
||||
2102=>39, // Chg.Capital/Cess.apport de parts
|
||||
2200=>4, // Cessation d'activité
|
||||
2201=>4, // Cessation d'activité temporaire
|
||||
2202=>41, // Dissolution
|
||||
2203=>41, // Dissolution de la société
|
||||
2204=>41, // Cessation d'activité avec dissolution
|
||||
2205=>4, // Fermeture du fonds
|
||||
2206=>39, // Mise en sommeil de la société
|
||||
2207=>39, // Suppression d'une branche d'activité
|
||||
2208=>39, // Suppression de l'établissement principal
|
||||
2209=>39, // Vente du fonds
|
||||
2210=>39, // Déclaration de dissolution par l'associé unique.
|
||||
2211=>39, // Clôture de la liquidation
|
||||
2212=>39, // Liquidation amiable
|
||||
2300=>39, // Changement d'Adresse
|
||||
2301=>39, // Modification de l'adresse du siège
|
||||
2302=>39, // Modification de l'enseigne
|
||||
2303=>39, // Modification de la date de clôture de l'exercice
|
||||
2304=>39, // Modification de la date de début d'activité
|
||||
2305=>39, // Modification de la dénomination
|
||||
2306=>39, // Modification de la durée de la société
|
||||
2307=>39, // Modification de la forme juridique
|
||||
2308=>39, // Modification du nom
|
||||
2309=>39, // Modification du nom commercial
|
||||
2310=>39, // Modification du pseudonyme
|
||||
2311=>39, // Modification sur l'exploitation
|
||||
2312=>39, // Modification(s) diverse(s)
|
||||
2313=>39, // Modification de l'activité
|
||||
2314=>39, // Poursuite de l'activité
|
||||
2315=>39, // Modification de l'administration
|
||||
2316=>39, // Mise en activité de la société
|
||||
2317=>39, // Modification du sigle
|
||||
2318=>39, // Modifications diverses
|
||||
2319=>39, // Poursuite de l'activité malgré la perte de plus de...
|
||||
2320=>39, // Reconsitution de l'actif net
|
||||
2321=>39, // Reconsitution de la moitié de l'actif net
|
||||
2350=>39, // Déclaration des associés (loi du 1er février 2005)
|
||||
2401=>39, // Changement de régime matrimonial
|
||||
2402=>39, // Changement de régime matrimonial (divorce)
|
||||
2403=>39, // Changement de régime matrimonial (mariage)
|
||||
2404=>39, // Changement de régime matrimonial (veuvage)
|
||||
2405=>39, // Changement de régime matrimonial (contrat de maria...
|
||||
2406=>39, // Reprise du fonds par le conjoint
|
||||
2407=>39, // Mention du conjoint collaborateur
|
||||
2408=>39, // Radiation du conjoint collaborateur
|
||||
2500=>3, // Confirmation établissement principal ou secondaire
|
||||
2510=>39, // L'établissement secondaire devient principal
|
||||
2520=>39, // Extension de l'établissement principal
|
||||
2600=>39, // Décès
|
||||
2610=>39, // Décision de l'unique actionnaire
|
||||
2620=>39, // Transmission universelle du patrimoine
|
||||
2630=>39, // Donation/Partage
|
||||
2635=>39, // Cession de parts
|
||||
2639=>39, // Nantissement de parts sociales
|
||||
2640=>39, // Changement de domicile personnel
|
||||
2650=>39, // Changement de nationalité
|
||||
2660=>39, // Réalisation de l'apport partiel d'actif
|
||||
2661=>39, // Apport partiel
|
||||
2700=>39, // Fusion/Absorption (entitée absorbante)
|
||||
2701=>39, // Fusion/Absorption (Entitée absorbante. Entité abso...
|
||||
2702=>39, // Fusion/Absorption (Entitée absorbante. Entité abso...
|
||||
2703=>39, // Fusion/Absorption (Entitée absorbante. Entité abso...
|
||||
2710=>39, // Projet de fusion (entitée absorbante)
|
||||
2720=>39, // Fusion/Absorption (entitée absorbée)
|
||||
2721=>39, // Fusion/Absorption (entitée absorbée non identifiée...
|
||||
2725=>39, // Fusion/Absorption
|
||||
2726=>39, // Projet de Fusion/Absorption
|
||||
2730=>39, // Projet de fusion (entitée absorbée)
|
||||
2740=>39, // Scission
|
||||
2750=>39, // Société participation
|
||||
2800=>37, // Location gérance reçue
|
||||
2840=>38, // Location/Gérance
|
||||
2850=>38, // Location gérance donnée : Précédent propriétaire e...
|
||||
2851=>38, // Location gérance donnée : Précédent propriétaire
|
||||
2860=>38, // Location gérance donnée : Précédent exploitant
|
||||
2870=>38, // Location gérance donnée
|
||||
2875=>38, // Gérance/Mandat
|
||||
2880=>38, // Renouvellement de location gérance
|
||||
2881=>38, // Changement de location gérance
|
||||
2885=>42, // Fin de location gérance
|
||||
2890=>38, // Location gérance relative à une branche
|
||||
2891=>39, // Location gérance relative à un établissement
|
||||
2892=>39, // Location gérance relative à un fond
|
||||
2900=>32, // Transfert d'établissement
|
||||
2901=>32, // Transfert de siège
|
||||
2902=>32, // Transfert du fonds
|
||||
2903=>32, // Projet de transfert du siège
|
||||
2904=>32, // Transfert du siège à l'étranger
|
||||
2950=>32, // Création de fonds
|
||||
2980=>32, // Transfert entre tribunaux
|
||||
// DEPOTS DES COMPTES
|
||||
3100=>91,
|
||||
3200=>91,
|
||||
3300=>91,
|
||||
3999=>91,
|
||||
// CREATIONS
|
||||
4000=>1, // Création d'entreprise
|
||||
4050=>1, // Création d'entreprise sans activité
|
||||
4100=>1, // Création d'entreprise sans établissement
|
||||
4200=>17, // Création d'établissement
|
||||
4250=>17, // Création suite à transfert
|
||||
4300=>17, // Création suite à reprise d'activité
|
||||
4350=>1, // Création suite à fin de location-gérance
|
||||
4355=>1, // Création suite à prise en location-gérance
|
||||
4360=>1, // Reprise d'activité par suite de la résolution de v
|
||||
4400=>1, // Création suite à changement de FJ
|
||||
4410=>1, // Création suite à héritage ou donation
|
||||
4450=>1, // Création suite à reprise par le conjoint
|
||||
4500=>17, // Fonds acquis dans le cadre d'une PC
|
||||
4501=>17, // Fonds acquis par achat
|
||||
4502=>17, // Fonds acquis par apport
|
||||
4600=>1, // Immatriculation d'une société de droit européen
|
||||
4999=>1, // Création
|
||||
|
||||
// ventes !!!
|
||||
5500=>2, // Entreprise réalisant la vente
|
||||
5501=>2, // Entreprise réalisant la vente : Ancien propriétair... BODA ventes 12 0000-00-00 00:00:00
|
||||
5502=>2, // Entreprise réalisant la vente : Ancien propriétair... BODA ventes 12 0000-00-00 00:00:00
|
||||
5503=>2, // Entreprise réalisant la vente : Ancien propriétair... BODA ventes 12 0000-00-00 00:00:00
|
||||
5510=>2, // Entreprise réalisant la vente : Co-propriétaire BODA ventes 12 0000-00-00 00:00:00
|
||||
5600=>2, // Entreprise réalisant l'acquisition BODA ventes 12 0000-00-00 00:00:00
|
||||
5650=>2,
|
||||
5700=>2, // Entreprise réalisant l'acquisition BODA ventes 12 0000-00-00 00:00:00
|
||||
5999=>2,
|
||||
|
||||
// RADIATIONS
|
||||
6000=>4, //Radiation pour cause de clôture de la liquidation (amiable/simplifié/général)
|
||||
6001=>4, //Radiation pour cause de clôture de la liquidation amiable
|
||||
6002=>4, //Radiation pour cause de clôture de la liquidation judiciaire pour IA
|
||||
6003=>4, //Radiation pour cause de clôture de la liquidation judiciaire
|
||||
6004=>4, //Radiation pour cause de clôture de la liquidation judiciaire simplifié
|
||||
6005=>4, //Radiation pour clôture du plan de cession
|
||||
6100=>4, //Radiation pour cause de décès
|
||||
6200=>4, //Radiation pour cause de mention d'office
|
||||
6201=>4, //Radiation pour cause de cessation d'activité
|
||||
6300=>4, //Radiation pour cause de non-exercice
|
||||
6400=>4, //Radiation pour cause de transfert
|
||||
6500=>4, //Radiation pour cause de jugement de clôture du plan de cession
|
||||
6600=>4, //Radiation d'un établissement
|
||||
6700=>4, //Radiation
|
||||
);
|
||||
$tabEven2RO=array( 2305=>'a',
|
||||
2308=>'a', // Chg de dénomination(RS,Ens,Sigle)
|
||||
2309=>'a', // Modification du nom commercial BODB mmd 12 0000-00-00 00:00:00
|
||||
2310=>'a', // Modification du pseudonyme
|
||||
2300=>'b', // Changement d'Adresse
|
||||
2301=>'b',
|
||||
2900=>'b', // Transfert d'établissement
|
||||
2901=>'b', // Transfert de siège
|
||||
2902=>'b', // Transfert du fonds
|
||||
2903=>'b', // Projet de transfert du siège
|
||||
2904=>'b', // Transfert du siège à l'étranger
|
||||
2950=>'b', // Création de fonds
|
||||
2980=>'b', // Transfert entre tribunaux
|
||||
2101=>'c', // Chg.Capital/Cess.apport de parts
|
||||
2315=>'d', // Changement de Dirigeants
|
||||
2313=>'e', // Mod Act/obj.soc./Cess./Mise somm.
|
||||
2307=>'f', // Changement de Forme juridique
|
||||
2318=>'g', // Opération sur Participations
|
||||
2725=>'h', // Fusion Absorption
|
||||
2318=>'i', // Mod.garantie financière/Caution
|
||||
2401=>'j', // Changement de régime matrimonial
|
||||
2319=>'k', // Non dissolution anticipée
|
||||
2318=>'l', // Non dissolution anticipée
|
||||
2318=>'m', // Dissolution anticipée (ou non)
|
||||
2303=>'n', // Mod.date cloture exercice social
|
||||
5500=>'V', // Entreprise réalisant la vente
|
||||
5501=>'V', // Entreprise réalisant la vente : Ancien propriétair... BODA ventes 12 0000-00-00 00:00:00
|
||||
5502=>'V', // Entreprise réalisant la vente : Ancien propriétair... BODA ventes 12 0000-00-00 00:00:00
|
||||
5503=>'V', // Entreprise réalisant la vente : Ancien propriétair... BODA ventes 12 0000-00-00 00:00:00
|
||||
5510=>'V', // Entreprise réalisant la vente : Co-propriétaire BODA ventes 12 0000-00-00 00:00:00
|
||||
5600=>'V',
|
||||
5650=>'V',
|
||||
5700=>'A', // Entreprise réalisant l'acquisition BODA ventes 12 0000-00-00 00:00:00
|
||||
1411=>'F', // Arrêt du plan de cession
|
||||
1408=>'G', // Modification du plan de cession
|
||||
1409=>'N', // Modification du plan de continuation
|
||||
1414=>'M', // Arrêt du plan de redressement
|
||||
|
||||
);
|
||||
|
||||
|
||||
function exporte($txt, $lon, $sep='') {
|
||||
$txt=strtr(trim($txt),array('''=>"'",'&'=>'&', '²'=>'²', "\r"=>'', "\n"=>'', "\t"=>''));
|
||||
|
||||
if ($sep=='') return sprintf("%-".$lon.'.'.$lon."s", $txt);
|
||||
|
||||
return trim(sprintf("%-".$lon.'.'.$lon."s", $txt)).$sep;
|
||||
}
|
||||
|
||||
|
||||
function conversionSd2So2000($nomFichierIn, $numeroAbonneBil='000960030', $nomFichierOut='', $optionFicheId='S') {
|
||||
|
||||
$message='';
|
||||
$iDb=new WDB();
|
||||
$iBodacc=new MBodacc();
|
||||
$iInsee=new MInsee();
|
||||
$iRncs=new MRncs();
|
||||
|
||||
global $tabEvenSolib;
|
||||
global $tabEven2SO;
|
||||
global $tabEven2RO;
|
||||
|
||||
$tabLignes=file($nomFichierIn);
|
||||
//print_r($tabLignes);
|
||||
//die();
|
||||
|
||||
$ligne001=$ligne100=$ligne104=$ligne999=0;
|
||||
if ($nomFichierOut=='') $nomFichierOut=$nomFichierIn.'.bil';
|
||||
|
||||
$fp=fopen($nomFichierOut, 'w');
|
||||
$dateJ=date('Ymd');
|
||||
$ecrireLignePre=false;
|
||||
|
||||
/** Codes/Variables à gérer **/
|
||||
$depPar=0;
|
||||
$SOSTAE='';
|
||||
$typeFicheId='I'; // Fiche Identifiant
|
||||
$optExtInsee=$optScore=false;
|
||||
|
||||
/** Type de fiche Id **/
|
||||
if (strpos($optionFicheId, 'S')==true) $typeFicheId='S'; // Fiche Standard
|
||||
elseif (strpos($optionFicheId, 'C')==true) $typeFicheId='C'; // Fiche Complète
|
||||
if (strpos($optionFicheId, 'E')==true) $optExtInsee=true; // Option Extension INSEE
|
||||
if (strpos($optionFicheId, 'N')==true) $optScore=true; // Option Score
|
||||
|
||||
foreach ($tabLignes as $i=>$ligne) {
|
||||
$typeLigne=substr($ligne, 0, 3)*1;
|
||||
switch ($typeLigne) {
|
||||
case 1: // Ligne ignorée
|
||||
// Ecriture de l'entête
|
||||
$ligne001++;
|
||||
break;
|
||||
case 100: // Structure Bodacc
|
||||
case 999: // Fin
|
||||
$strTxt=wordwrap($txtAnn, 39, EOL);
|
||||
$tabTxt=explode(EOL, $strTxt);
|
||||
foreach($tabTxt as $j=>$txt) {
|
||||
$SOSEQ++;
|
||||
if($j%16==0) {
|
||||
// Type d'enregistrement 1=EntConf, 2=Rejet, 4=Multipropo, 5=Suivi MAJ Entrep, 7=Infos, 8=Envoi documen, 9=Annonce
|
||||
$typEnr=9;
|
||||
if ($j==0) $ligneTXT =initstr($SONABO, 9, '0', ALIGN_RIGHT); // Numéro d'abonné BIL ?
|
||||
else $ligneTXT.=EOL.initstr($SONABO, 9, '0', ALIGN_RIGHT); // Numéro d'abonné BIL ?
|
||||
$ligneTXT.=initstr($SONUME, 9, '0', ALIGN_RIGHT); // Numéro d'entreprise BIL ?
|
||||
$ligneTXT.=initstr($SONUS, 9, '0', ALIGN_RIGHT); // Numéro d'UFS BIL ?
|
||||
$ligneTXT.=initstr($nann, 9, '0', ALIGN_RIGHT); // Numéro d'annonce BIL ?
|
||||
$ligneTXT.=initstr($siren, 9, '0', ALIGN_RIGHT); // Siren
|
||||
$ligneTXT.=initstr($nic, 5, '0', ALIGN_RIGHT); // Nic
|
||||
$ligneTXT.=exporte('SE', 2); // Code produit BIL ? SE, DE, DI, SJ
|
||||
$ligneTXT.=initstr($SOSEQ, 5, '0', ALIGN_RIGHT); // Numéro dans la séquence
|
||||
$ligneTXT.=initstr($dateJ, 8, '0', ALIGN_RIGHT); // Numéro dans la séquence
|
||||
$ligneTXT.=exporte($typEnr, 1); // Type d'enregistrement 1=EntConf, 2=Rejet, 4=Multipropo, 5=Suivi MAJ Entrep, 7=Infos, 8=Envoi documen, 9=Annonce
|
||||
$ligneTXT.=exporte('TXT', 3); // Structure identité
|
||||
$ligneTXT.=exporte('A', 1); // Confirmation 'A'uto ou 'C' pour manuelle
|
||||
$ligneTXT.=exporte($ref, 30); // Réf. Client
|
||||
$ligneTXT.=exporte($SOORIG, 1); // 1:Insee actif, 2=Ufs, 3=Annonce, 4=Manuelle, 5=Asso, 7=RCS actif, 8=Insee cessa eco, 9=Insee/RCS radié
|
||||
$ligneTXT.=exporte($SOJAL, 3); // 001=Bodacc A, 200=Bodacc B, 300=Bodacc C
|
||||
$ligneTXT.=initstr($datePar, 8, '0', ALIGN_RIGHT); // Date de parution
|
||||
$ligneTXT.=initstr(0, 5, '0', ALIGN_RIGHT); // Page
|
||||
$ligneTXT.=exporte($codeEve, 2); //
|
||||
$ligneTXT.=initstr($depPar, 2, '0', ALIGN_RIGHT);
|
||||
$ligneTXT.=initstr($numAnn, 6, '0', ALIGN_RIGHT);
|
||||
$ligneTXT.=exporte($codeRol, 1); //
|
||||
$ligneTXT.=exporte('T', 1);
|
||||
}
|
||||
$ligneTXT.=exporte($txt, 40);
|
||||
}
|
||||
$codeEve=$codeRol='';
|
||||
$ligneOut=$ligneID.EOL.$ligneANN.EOL.$ligneTXT;
|
||||
if ($ligne100>1) $ecrireLignePre=true;
|
||||
if($typeLigne==999) {
|
||||
$ligne999++;
|
||||
break;
|
||||
}
|
||||
|
||||
$nann = trim(substr($ligne, 3 , 10 ))*1; // N° d'annonce
|
||||
$siren = substr($ligne, 13 , 9 ); // Siren de l'entreprise concernée par l'annonce
|
||||
$tabIdentite=@$iInsee->getIdentiteEntreprise($siren);
|
||||
$nic = trim(substr($ligne, 22, 5 ))*1; // Nic
|
||||
$ref = trim(substr($ligne, 71, 18 )); // Référence Client
|
||||
$numPar = substr($ligne, 27 , 3 ); // Numéro de parution du Bodacc dans l'année
|
||||
$bodacc = substr($ligne, 30 , 1 ); // Code Bodacc (A, B ou C) A, B ou C
|
||||
$datePar= substr($ligne, 31 , 8 )*1; // Date de parution du Bodacc Format AAAAMMJJ
|
||||
$numAnn = substr($ligne, 39 , 5 ); // Numéro de l'annonce dans le Bodacc
|
||||
$typeAnn= substr($ligne, 47 , 1 ); // Type d'annonce Bodacc I=Insertion (publication d'une annonce), A=Additif (ajout à une précédente annonce), (1) R=Rectificatif (correction d'une annonce), S=Suppression d'une annonce
|
||||
$corNumA= substr($ligne, 48 , 5 ); // Numéro de l'annonce corrigée Si annonce différent de Insertion
|
||||
$corDate= substr($ligne, 53 , 8 ); // Date du Bodacc de l'annonce corrigée Si annonce différent de Insertion. Format AAAAMMJJ
|
||||
$corPage= substr($ligne, 61 , 6 ); // Première page du Bodacc de l'annonce corrigée Si annonce différent de Insertion
|
||||
$corNumP= substr($ligne, 67 , 4 ); // Numéro parution du Bodacc dans l'année de l'annonce corrigée Si annonce différent de Insertion
|
||||
$numRC = trim(substr($ligne,95 , 9 )); // Numéro de RC (Registre du Commerce) de l'entreprise
|
||||
$rs = trim(substr($ligne,104, 150 )); // Raison sociale de l'entreprise
|
||||
$nomCom = trim(substr($ligne,254, 100 )); // Nom Commerciale
|
||||
$ens = trim(substr($ligne,354, 100 )); // Enseigne
|
||||
$fj = trim(substr($ligne,484, 4 ))*1; // FJ
|
||||
$fjLib = trim(substr($ligne,488, 90 )); // FJ libellé
|
||||
$capMnt = trim(substr($ligne,578, 15 )); // Capital
|
||||
$capDev = trim(substr($ligne,593, 3 )); // Capital Devise
|
||||
$adrNum = trim(substr($ligne,596, 4 )); //
|
||||
$adrBtq = trim(substr($ligne,600, 1 )); // FJ libellé
|
||||
$adrVoi = trim(substr($ligne,601, 5 )); // FJ libellé
|
||||
$adrLib = trim(substr($ligne,606, 50 )); // FJ libellé
|
||||
$adrL2 = trim(substr($ligne,656, 50 )); // FJ libellé
|
||||
$adrL3 = trim(substr($ligne,706, 40 )); // FJ libellé
|
||||
$adrCP = trim(substr($ligne,746, 5 ))*1; // FJ libellé
|
||||
$adrVil = trim(substr($ligne,751, 45 )); // FJ libellé
|
||||
if ($adrCP==0) {
|
||||
$adrNum = trim(substr($ligne,796, 4 )); // FJ libellé
|
||||
$adrBtq = trim(substr($ligne,800, 1 )); // FJ libellé
|
||||
$adrVoi = trim(substr($ligne,801, 5 )); // FJ libellé
|
||||
$adrLib = trim(substr($ligne,806, 50 )); // FJ libellé
|
||||
$adrL2 = trim(substr($ligne,856, 50 )); // FJ libellé
|
||||
$adrL3 = trim(substr($ligne,906, 40 )); // FJ libellé
|
||||
$adrCP = trim(substr($ligne,946, 5 ))*1; // FJ libellé
|
||||
$adrVil = trim(substr($ligne,951, 45 )); // FJ libellé
|
||||
}
|
||||
$even=array();
|
||||
$even[7]= substr($ligne, 996 , 4 )*1; // Code Evènement Bodacc n°1 Cf. Table EVEN
|
||||
$even[6]= substr($ligne, 1000, 4 )*1; // Code Evènement Bodacc n°2 Cf. Table EVEN
|
||||
$even[5]= substr($ligne, 1004, 4 )*1; // Code Evènement Bodacc n°3 Cf. Table EVEN
|
||||
$even[4]= substr($ligne, 1008, 4 )*1; // Code Evènement Bodacc n°4 Cf. Table EVEN
|
||||
$even[3]= substr($ligne, 1012, 4 )*1; // Code Evènement Bodacc n°5 Cf. Table EVEN
|
||||
$even[2]= substr($ligne, 1016, 4 )*1; // Code Evènement Bodacc n°6 Cf. Table EVEN
|
||||
$even[1]= substr($ligne, 1020, 4 )*1; // Code Evènement Bodacc n°7 Cf. Table EVEN
|
||||
$even[0]= substr($ligne, 1024, 4 )*1; // Code Evènement Bodacc n°8 Cf. Table EVEN
|
||||
$txtEven='';
|
||||
foreach ($even as $codeEven)
|
||||
if ($codeEven<>0) {
|
||||
if (@$codeEve=='') $codeEve=$tabEven2SO[$codeEven];
|
||||
if (@$codeRol=='') $codeRol=$tabEven2RO[$codeEven];
|
||||
$txtEven.=$iBodacc->getEvenement($codeEven).', ';
|
||||
$catEven=$iBodacc->getChapitreEvenement($codeEven);
|
||||
}
|
||||
else
|
||||
$txtEven.='';
|
||||
$txtEven=substr($txtEven,0,strlen($txtEven)-2);
|
||||
$dateCess= substr($ligne, 1136, 8 )*1; // Date de cessat° des paiements
|
||||
$dateJuge= substr($ligne, 1144, 8 )*1; // Date de jugement
|
||||
$dateEffet=substr($ligne, 1161, 8 )*1; // Date d'effet
|
||||
if ($dateEffet*1==0) $dateEffet=$dateJuge;
|
||||
|
||||
$vteMnt=trim(substr($ligne, 1169, 15 ))*1; // Montant de la vente
|
||||
$vteDev=substr($ligne, 1184, 3 ); // Devise de la vente
|
||||
|
||||
|
||||
if ($nic*1==0) $nic=$tabIdentite['Nic'];
|
||||
|
||||
$SONABO=$numeroAbonneBil;
|
||||
if ($tabIdentite['Actif']==1) $SOORIG=1;
|
||||
elseif (!isset($tabIdentite['Actif'])) $SOORIG=3;
|
||||
elseif ($tabIdentite['Actif']==0 && ($tabIdentite['EntActiveRCS']==1||$tabIdentite['EtabActifRCS']==1)) $SOORIG=7;
|
||||
elseif ($tabIdentite['Actif']==0 && $tabIdentite['EntActiveRCS']==0 && $tabIdentite['EtabActifRCS']==0) $SOORIG=9;
|
||||
else $SOORIG=8;
|
||||
|
||||
if ($tabIdentite['Civilite']==1) $SOTSEX='M';
|
||||
elseif ($tabIdentite['Civilite']==2) $SOTSEX='F';
|
||||
else $SOTSEX='';
|
||||
$SONUME=''.preg_replace('/^0+/','', $tabIdentite['Source']).$tabIdentite['SourceId'];
|
||||
$SONUS='000000000';
|
||||
$SOSEQ=1;
|
||||
if ($adrCP==0) {
|
||||
$adrNum = $tabIdentite['AdresseNum'];
|
||||
$adrBtq = $tabIdentite['AdresseBtq'];
|
||||
$adrVoi = $tabIdentite['AdresseVoie'];
|
||||
$adrLib = $tabIdentite['AdresseRue'];
|
||||
$adrL2 = $tabIdentite['Adresse2'];
|
||||
$adrL3 = '';
|
||||
$adrCP = $tabIdentite['CP'];
|
||||
$adrVil = $tabIdentite['Ville'];
|
||||
}
|
||||
$typEnr=1;
|
||||
$DBILS2 =initstr($SONABO, 9, '0', ALIGN_RIGHT); // Numéro d'abonné BIL ?
|
||||
$DBILS2.=initstr($SONUME, 9, '0', ALIGN_RIGHT); // Numéro d'entreprise BIL ?
|
||||
$DBILS2.=initstr($SONUS, 9, '0', ALIGN_RIGHT); // Numéro d'UFS BIL ?
|
||||
$DBILS2.=initstr($nann, 9, '0', ALIGN_RIGHT); // Numéro d'annonce BIL ?
|
||||
$DBILS2.=initstr($siren, 9, '0', ALIGN_RIGHT); // Siren
|
||||
$DBILS2.=initstr($nic, 5, '0', ALIGN_RIGHT); // Nic
|
||||
$DBILS2.=exporte('SE', 2); // Code produit BIL ? SE, DE, DI, SJ
|
||||
$DBILS2.=initstr($SOSEQ, 5, '0', ALIGN_RIGHT); // Numéro dans la séquence dans le groupe
|
||||
$DBILS2.=initstr($dateJ, 8, '0', ALIGN_RIGHT); // Date d'envoi de l'info
|
||||
$DBILS2.=exporte($typEnr, 1); // Type d'enregistrement 1=EntConf, 2=Rejet, 4=Multipropo, 5=Suivi MAJ Entrep, 7=Infos, 8=Envoi documen, 9=Annonce
|
||||
$DBILS2.=exporte('ID', 3); // Structure identité
|
||||
$DBILS2.=exporte('A', 1); // Confirmation 'A'uto ou 'C' pour manuelle
|
||||
$DBILS2.=exporte($ref, 30); // Réf. Client
|
||||
//($annonce['codePostalSiege'], 5, '0', ALIGN_RIGHT)
|
||||
$DBILS2.=exporte($SOORIG, 1); // 1:Insee actif, 2=Ufs, 3=Annonce, 4=Manuelle, 5=Asso, 7=RCS actif, 8=Insee cessa eco, 9=Insee/RCS radié
|
||||
$DBILS2.=exporte('', 1); // D=Siren douteux
|
||||
$DBILS2.=exporte('', 9); // Témoin de MAJ
|
||||
$DBILS2.=exporte($rs, 60); //
|
||||
$DBILS2.=exporte(substr($rs,60),30); //
|
||||
$DBILS2.=exporte($tabIdentite['Sigle'], 30); // Vide !
|
||||
$DBILS2.=exporte($ens, 60); //
|
||||
$DBILS2.=initstr($adrNum, 4, '0', ALIGN_RIGHT); //
|
||||
$DBILS2.=exporte($adrBtq, 1); //
|
||||
$DBILS2.=exporte(preg_replace('/ +/',' ',$adrVoi.' '.$adrLib), 33); //
|
||||
$DBILS2.=exporte($adrVil, 32); //
|
||||
$DBILS2.=initstr($adrCP, 5, '0', ALIGN_RIGHT); //
|
||||
$DBILS2.=exporte(preg_replace('/ +/',' ',$adrL2.' '.$adrL3), 30); //
|
||||
$DBILS2.=initstr($tabIdentite['DateCreaEn'], 8, '0', ALIGN_RIGHT); // Date créa ENT
|
||||
$DBILS2.=exporte($tabIdentite['Siege'], 1); // Statut de l'établissement
|
||||
$DBILS2.=initstr($tabIdentite['FJ'], 4, 0, ALIGN_RIGHT);
|
||||
$DBILS2.=exporte($SOTSEX, 1); // Sexe M/F
|
||||
|
||||
$DBILS2.=initstr($tabIdentite['NbEtab']*1, 4, 0, ALIGN_RIGHT);
|
||||
$DBILS2.=exporte($SOSTAE, 4); // NAF4 ENT
|
||||
$DBILS2.=exporte('', 4); // Famille ENT
|
||||
$DBILS2.=exporte($SOSTAE, 4); // NAF4 ETAB
|
||||
$DBILS2.=exporte('', 4); // Famille ETAB
|
||||
$DBILS2.=exporte('', 1); // Indicateur Procol
|
||||
$DBILS2.=exporte('', 2); // Code monnaie
|
||||
$DBILS2.=initstr(0, 13, '0', ALIGN_RIGHT); // Montant du capital
|
||||
$DBILS2.=exporte('', 7); // Effectif
|
||||
$DBILS2.=exporte('', 9); // Num RC
|
||||
$DBILS2.=initstr(strtr($tabIdentite['Tel'],array('.'=>'','+'=>'00',' '=>'','-'=>'','/'=>'')), 10, '0', ALIGN_RIGHT);
|
||||
$DBILS2.=initstr(strtr($tabIdentite['Fax'],array('.'=>'','+'=>'00',' '=>'','-'=>'','/'=>'')), 10, '0', ALIGN_RIGHT);
|
||||
//5630Z5630Z RUE 00000000 00000000 2901929019
|
||||
$DBILS2.=exporte($tabIdentite['Web'], 40);
|
||||
$DBILS2.=exporte('', 3); // Qualité du dirigeant
|
||||
$DBILS2.=exporte('', 60); // NOM, Prénom du dirigeant
|
||||
$DBILS2.=initstr(0, 8, '0', ALIGN_RIGHT); // Date Naiss Diri
|
||||
// $DBILS2.=exporte('', 79);
|
||||
$DBILS2.=exporte('', 35); // Lieu de Naissance
|
||||
if ($optScore) {
|
||||
$tabTmp=$iDb->select('scores_surveillance',
|
||||
'siren, actif, procol, indiScore, indiScore20, encours, indiScoreDate, dateBilan, indiScorePre, indiScore20Pre, encoursPre, indiScoreDatePre, sourceModif, nbModifs, dateUpdate',
|
||||
"siren=$siren AND indiScoreDate>0", false, MYSQL_ASSOC);
|
||||
if (@$tabTmp[0]['siren']*1==$siren) {
|
||||
echo "$siren, parution Annonce le $datePar, calcul le ".@$tabTmp[0]['dateUpdate'].EOL;
|
||||
$tabScore=$tabTmp[0];
|
||||
$note=$tabScore['indiScore20'];
|
||||
$encours=round($tabScore['encours']/1000);
|
||||
} else {
|
||||
echo "$siren, parution Annonce le $datePar, pas de calcul !".EOL;
|
||||
$tabScore=@calculIndiScore($siren, $nic, false, 0, false);
|
||||
$note=$tabScore['Indiscore20'];
|
||||
$encours=round($tabScore['encours']/1000);
|
||||
}
|
||||
$encoursDev='EUR';
|
||||
} else
|
||||
$note=$encours=$encoursDev='';
|
||||
$DBILS2.=initstr($note, 2, '0', ALIGN_RIGHT); //37 Note sur 20
|
||||
$DBILS2.=initstr($encours, 7, '0', ALIGN_RIGHT); //44 Encours KE KF
|
||||
$DBILS2.=exporte('', 1); //45 Code paiement
|
||||
$DBILS2.=exporte('', 1); //46 Code situfi
|
||||
$DBILS2.=exporte('', 1); //47 Code Avis
|
||||
$DBILS2.=exporte($encoursDev,3); //47 Encours de la devise
|
||||
$DBILS2.=exporte('', 6); // Code Sicovam
|
||||
$DBILS2.=exporte('', 2); // Type de marché RM, CT, SM, HC, MO, NM, ML, AL, MR
|
||||
$DBILS2.=exporte('', 12); // Code ISIN
|
||||
$DBILS2.=exporte('', 9); // Filler Bil anciennement sur 83, 32 puis 9
|
||||
$DBILS2.=exporte($tabIdentite['NafEnt'], 5);
|
||||
$DBILS2.=exporte($tabIdentite['NafEtab'], 5);//
|
||||
$DBILS2.=exporte('', 18); //60 Filler
|
||||
$DBILS2.=exporte('', 4); // Filler RUE ?
|
||||
$DBILS2.=exporte('', 5); // Nic source cible de l'étab
|
||||
$DBILS2.=initstr(0, 8, '0', ALIGN_RIGHT); // Date de MAJ du capital
|
||||
$DBILS2.=exporte('', 3); // Monnaie d'origine du capital
|
||||
$DBILS2.=exporte('', 3); // Monnaie de livraison du capital (fin de l'ancien filler)
|
||||
$DBILS2.=initstr(0, 8, '0', ALIGN_RIGHT); // Date de création de l'établissement
|
||||
$DBILS2.=exporte('', 1); // Origine création
|
||||
$DBILS2.=exporte('', 2); // Tr Eff Ent
|
||||
$DBILS2.=exporte('', 2); // Tr Eff Etab
|
||||
$DBILS2.=exporte('', 2); // NAP 40 Entrep
|
||||
$DBILS2.=exporte('', 2); // NAP 40 Etab
|
||||
$DBILS2.=exporte('', 5); // Act Artisanale Etab
|
||||
$DBILS2.=exporte('', 1); // Modalité activité entrep
|
||||
$DBILS2.=exporte('', 1); // Modalité activité etab
|
||||
$DBILS2.=exporte('', 2); // Code Région Entrep
|
||||
$DBILS2.=exporte('', 2); // Code Région Etab
|
||||
$DBILS2.=exporte($tabIdentite['Dept'], 2); // Département du siège
|
||||
$DBILS2.=exporte($tabIdentite['codeCommune'], 3); // Localité
|
||||
$DBILS2.=exporte($tabIdentite['Dept'], 2); // Département de l'étab
|
||||
$DBILS2.=exporte($tabIdentite['codeCommune'], 3); // Localité
|
||||
$DBILS2.=exporte('', 1); // Dept Outre Mer
|
||||
$DBILS2.=exporte('', 1); // Arrondissement
|
||||
$DBILS2.=exporte('', 1); // Canton Dom ?
|
||||
$DBILS2.=exporte('', 2); // Canton
|
||||
$DBILS2.=exporte('', 8); // Code Ilot
|
||||
$DBILS2.=exporte('', 2); // ZEMET
|
||||
$DBILS2.=exporte('', 2); // Tranche Comm Etab
|
||||
$DBILS2.=exporte('', 2); // Dept Unite urbaine
|
||||
$DBILS2.=exporte('', 1); // Taille UU
|
||||
$DBILS2.=exporte('', 2); // UU etab
|
||||
$DBILS2.=exporte('', 5); // Code rivoli
|
||||
$DBILS2.=exporte('', 2); // PPale région entrep
|
||||
$DBILS2.=exporte('', 1); // Code monoreg
|
||||
$DBILS2.=exporte('', 1); // Code monoact
|
||||
$DBILS2.=exporte('', 1); // Code tranche CA
|
||||
$DBILS2.=exporte('', 1); // Tranche part CA export
|
||||
$DBILS2.=exporte('', 1); // RECME
|
||||
$DBILS2.=exporte('', 1); // Ordinarité
|
||||
$DBILS2.=exporte('', 2); // Code nature étab
|
||||
$DBILS2.=exporte('', 2); // Sigularité étab
|
||||
|
||||
$ligneID=$DBILS2;
|
||||
$ligne100++;
|
||||
$cor='';
|
||||
if ($typeAnn<>'I')
|
||||
$cor=" - Annonce n°$corNumA $corNumP, page $corPage, du ".WDate::dateT('Ymd','d/M/Y',$corDate);
|
||||
switch($typeAnn) {
|
||||
case 'I': $cor='Insertion'.$cor; break;
|
||||
case 'A': $cor='Additif'.$cor; break;
|
||||
case 'R': $cor='Rectificatif'.$cor; break;
|
||||
case 'S': $cor='Suppression'.$cor; break;
|
||||
default: break;
|
||||
}
|
||||
$codeTri= substr($ligne, 89 , 6 ); // Code Tribunal Codification interne utilisée par le Bodacc
|
||||
$libTri=$iBodacc->getTribunalNom($codeTri);
|
||||
|
||||
$SOSEQ++;
|
||||
if ($bodacc=='A') $SOJAL='001';
|
||||
elseif ($bodacc=='B') $SOJAL='200';
|
||||
elseif ($bodacc=='C') $SOJAL='300';
|
||||
else $SOJAL='999';
|
||||
$DBILS2 =initstr($SONABO, 9, '0', ALIGN_RIGHT); // Numéro d'abonné BIL ?
|
||||
$DBILS2.=initstr($SONUME, 9, '0', ALIGN_RIGHT); // Numéro d'entreprise BIL ?
|
||||
$DBILS2.=initstr($SONUS, 9, '0', ALIGN_RIGHT); // Numéro d'UFS BIL ?
|
||||
$DBILS2.=initstr($nann, 9, '0', ALIGN_RIGHT); // Numéro d'annonce BIL ?
|
||||
$DBILS2.=initstr($siren, 9, '0', ALIGN_RIGHT); // Siren
|
||||
$DBILS2.=initstr($nic, 5, '0', ALIGN_RIGHT); // Nic
|
||||
$DBILS2.=exporte('SE', 2); // Code produit BIL ? SE, DE, DI, SJ
|
||||
$DBILS2.=initstr($SOSEQ, 5, '0', ALIGN_RIGHT); // Numéro dans la séquence
|
||||
$DBILS2.=initstr($dateJ, 8, '0', ALIGN_RIGHT); // Numéro dans la séquence
|
||||
$DBILS2.=exporte('9', 1); // Type d'enregistrement 1=EntConf, 2=Rejet, 4=Multipropo, 5=Suivi MAJ Entrep, 7=Infos, 8=Envoi documen, 9=Annonce
|
||||
$DBILS2.=exporte('ANN', 3); // Structure identité
|
||||
$DBILS2.=exporte('A', 1); // Confirmation 'A'uto ou 'C' pour manuelle
|
||||
$DBILS2.=exporte($ref, 30); // Réf. Client
|
||||
//($annonce['codePostalSiege'], 5, '0', ALIGN_RIGHT)
|
||||
$DBILS2.=exporte($SOORIG, 1); // 1:Insee actif, 2=Ufs, 3=Annonce, 4=Manuelle, 5=Asso, 7=RCS actif, 8=Insee cessa eco, 9=Insee/RCS radié
|
||||
$DBILS2.=exporte($SOJAL, 3); // 001=Bodacc A, 200=Bodacc B, 300=Bodacc C
|
||||
$DBILS2.=initstr($datePar, 8, '0', ALIGN_RIGHT); // Date de parution
|
||||
$DBILS2.=initstr(0, 5, '0', ALIGN_RIGHT); // Page
|
||||
if ($codeEve=='') {
|
||||
$message.="Siren : $siren, Bodacc $bodacc, code évènement non géré : '$codeEven'".EOL;
|
||||
/*$nann = trim(substr($ligne, 3 , 10 ))*1; // N° d'annonce
|
||||
$siren = substr($ligne, 13 , 9 ); // Siren de l'entreprise concernée par l'annonce
|
||||
$tabIdentite=@$iInsee->getIdentiteEntreprise($siren);
|
||||
$nic = trim(substr($ligne, 22, 5 ))*1; // Nic
|
||||
$ref = trim(substr($ligne, 71, 18 )); // Référence Client
|
||||
$numPar = substr($ligne, 27 , 3 ); // Numéro de parution du Bodacc dans l'année
|
||||
= substr($ligne, 30 , 1 ); // Code Bodacc (A, B ou C) A, B ou C
|
||||
$datePar= substr($ligne, 31 , 8 )*1; // Date de parution du Bodacc Format AAAAMMJJ
|
||||
$numAnn*/
|
||||
sendMail('infoslegales@scores-decisions.com', 'ylenaour@scores-decisions.com', "Surveillance Annonces Legales SOFID (ERREUR)", $message);
|
||||
return $message;
|
||||
}
|
||||
$DBILS2.=exporte($codeEve, 2); //
|
||||
$DBILS2.=initstr($depPar, 2, '0', ALIGN_RIGHT);
|
||||
$DBILS2.=initstr($numAnn, 6, '0', ALIGN_RIGHT);
|
||||
$DBILS2.=exporte($codeRol, 1); //
|
||||
$DBILS2.=exporte($tabEvenSolib[$codeEve], 5);
|
||||
$DBILS2.=exporte($codeTri, 6); //
|
||||
$DBILS2.=exporte($numPar, 3); //
|
||||
$DBILS2.=initstr($dateJuge, 8, '0', ALIGN_RIGHT); // Date de jugement
|
||||
$DBILS2.=initstr($dateEffet, 8, '0', ALIGN_RIGHT); // Date d'effet
|
||||
$DBILS2.=initstr($dateCess, 8, '0', ALIGN_RIGHT); // Date de cessat° des paiements
|
||||
$DBILS2.=exporte($vteDev, 2); // Devise de la vente
|
||||
$DBILS2.=initstr($vteMnt, 11, '0', ALIGN_RIGHT); // Montant de la vente
|
||||
$DBILS2.=exporte('', 33); // Particularité
|
||||
$DBILS2.=exporte('', 4); // Code rubrique du Bodacc A1xx
|
||||
$DBILS2.=exporte('', 6); // Code lib injecté
|
||||
|
||||
$tabJuge=$iRncs->getIntervenants($siren);
|
||||
foreach ($tabJuge as $iDepot=>$depot) {
|
||||
$DBILS2.=exporte($depot['admid'], 5); // Mot clé Nom
|
||||
$DBILS2.=exporte($depot['admtype'], 1); // Type officier ministeriel
|
||||
$DBILS2.=initstr($depot['admid'], 7, '0', ALIGN_RIGHT); // Code Bil
|
||||
$DBILS2.=exporte($depot['admnom'], 30); // Nom syndic
|
||||
$DBILS2.=initstr($depot['admadrNum'], 4, '0', ALIGN_RIGHT); // N° rue
|
||||
$DBILS2.=exporte($depot['admadrInd'], 1); // Bis
|
||||
$DBILS2.=exporte($depot['admadrType'], 3); // Type Voie
|
||||
$DBILS2.=exporte($depot['admadrVoie'], 33); // Lib Voie
|
||||
$DBILS2.=exporte($depot['admadr2'], 32); // Lieu
|
||||
$DBILS2.=exporte($depot['admadrCP'], 5); // CP
|
||||
$DBILS2.=exporte($depot['admadrVille'], 32); // Ville
|
||||
$DBILS2.=exporte('', 10); // Tel
|
||||
if ($iDepot==1) break;
|
||||
}
|
||||
|
||||
$ligneANN=$DBILS2;
|
||||
$txtAnn='';
|
||||
//if ($ligne100>1) $ecrireLignePre=true;
|
||||
break;
|
||||
case 104: // Annonce
|
||||
$ligne104++;
|
||||
$txtAnn=trim($txtAnn.' '.trim(substr($ligne, 89 , 1910))); // Texte Annonce
|
||||
break;
|
||||
default: // Ligne non gérée
|
||||
break;
|
||||
}
|
||||
if ($ecrireLignePre) {
|
||||
fwrite($fp, $ligneOut.EOL);
|
||||
$ecrireLignePre=false;
|
||||
}
|
||||
}
|
||||
fclose($fp);
|
||||
return true;
|
||||
}
|
5930
library/Metier/insee/classMInsee.php
Normal file
5930
library/Metier/insee/classMInsee.php
Normal file
File diff suppressed because it is too large
Load Diff
456
library/Metier/insee/classMSirene.php
Normal file
456
library/Metier/insee/classMSirene.php
Normal file
@ -0,0 +1,456 @@
|
||||
<?
|
||||
|
||||
require_once 'framework/common/curl.php';
|
||||
|
||||
define('HOST_INSEE', 'avis-situation-sirene.insee.fr');
|
||||
define('SITE_INSEE', 'http://'. HOST_INSEE .'/');
|
||||
|
||||
class MSirene {
|
||||
|
||||
private $response1;
|
||||
|
||||
function __construct() {
|
||||
|
||||
/** Etape de connexion au site de l'INSEE pour simuler correctement un utilisateur WEB
|
||||
**/
|
||||
$this->response1=getUrl(SITE_INSEE,'','','',false,HOST_INSEE);
|
||||
$response=getUrl(SITE_INSEE .'REPERTOIRE/Interrogation/frame_interrogation.asp?ACTION=nouvelle&Niveau=siren', $this->response1["header"]["Set-Cookie"], '', SITE_INSEE .'SIRENET_Script/Accueil/script_page_accueil.asp',false, HOST_INSEE);
|
||||
$response=getUrl(SITE_INSEE .'SIRENET_Script/Interrogation/script_recherche_menu.asp?niveau=siren', $this->response1["header"]["Set-Cookie"], '', SITE_INSEE .'REPERTOIRE/Interrogation/frame_interrogation.asp?ACTION=nouvelle&Niveau=siren',false, HOST_INSEE);
|
||||
$response=getUrl(SITE_INSEE .'SIRENET_Script/Interrogation/script_recherche_barre_haut.asp?niveau=siren', $this->response1["header"]["Set-Cookie"], '', SITE_INSEE .'REPERTOIRE/Interrogation/frame_interrogation.asp?ACTION=nouvelle&Niveau=siren',false, HOST_INSEE);
|
||||
$response=getUrl(SITE_INSEE .'REPERTOIRE/Interrogation/Interrogation_haut.asp?grille=siren&action=nouvelle', $this->response1["header"]["Set-Cookie"], '', SITE_INSEE .'REPERTOIRE/Interrogation/frame_interrogation.asp?ACTION=nouvelle&Niveau=siren',false, HOST_INSEE);
|
||||
$response=getUrl(SITE_INSEE .'REPERTOIRE/Interrogation/Interrogation_principal.asp?grille=siren&action=nouvelle', $this->response1["header"]["Set-Cookie"], '', SITE_INSEE .'REPERTOIRE/Interrogation/frame_interrogation.asp?ACTION=nouvelle&Niveau=siren',false, HOST_INSEE);
|
||||
$response=getUrl(SITE_INSEE .'REPERTOIRE/Interrogation/Interrogation_bas.asp?grille=siren&action=nouvelle', $this->response1["header"]["Set-Cookie"], '', SITE_INSEE .'REPERTOIRE/Interrogation/frame_interrogation.asp?ACTION=nouvelle&Niveau=siren',false, HOST_INSEE);
|
||||
$response=getUrl(SITE_INSEE .'REPERTOIRE/Interrogation/Interrogation_haut.asp?grille=siren&action=nouvelle', $this->response1["header"]["Set-Cookie"], '', SITE_INSEE .'REPERTOIRE/Interrogation/Interrogation_principal.asp?grille=siren&action=nouvelle',false, HOST_INSEE);
|
||||
$response=getUrl(SITE_INSEE .'REPERTOIRE/Interrogation/Interrogation_bas.asp?grille=siren&action=nouvelle', $this->response1["header"]["Set-Cookie"], '', SITE_INSEE .'REPERTOIRE/Interrogation/Interrogation_principal.asp?grille=siren&action=nouvelle',false, HOST_INSEE);
|
||||
//sleep(1);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Récupère les informations relatives à un établissement et son entreprise (par défaut le siège si pas de NIC)
|
||||
*
|
||||
* @param unknown_type $sirenLu
|
||||
* @param unknown_type $nicLu
|
||||
*/
|
||||
function getInfoEtab($sirenLu, $nicLu='') //if ($argv[1]=='id' || $argv[1]=='pj')
|
||||
{
|
||||
$tabRet=array();
|
||||
|
||||
/** Paramètre de requête "option" à l'insee :
|
||||
** 1: Fiche du siège + Données entreprises
|
||||
** 2: Tous les établissements de l'entreprise
|
||||
** 3: Un établissement particulier
|
||||
** 4: Département
|
||||
**/
|
||||
if ($nicLu<>'') $option=3;
|
||||
else $option=1;
|
||||
|
||||
// Requête d'interrogation
|
||||
$postData=array('siren'=>$sirenLu,
|
||||
'option'=>$option,
|
||||
'nic'=>$nicLu,
|
||||
'dep'=>'',
|
||||
'listeDep'=>'');
|
||||
|
||||
$response=getUrl(SITE_INSEE .'REPERTOIRE/Interrogation/Interrogation_principal.asp?action=valider&grille=siren&waitframe=false', $this->response1["header"]["Set-Cookie"], $postData, SITE_INSEE .'REPERTOIRE/Interrogation/Interrogation_principal.asp?grille=siren&action=nouvelle',false, HOST_INSEE);
|
||||
$responseQ=getUrl(SITE_INSEE .'REPERTOIRE/reponse/question.asp?action=nouveau', $this->response1["header"]["Set-Cookie"], '', SITE_INSEE .'REPERTOIRE/Interrogation/Interrogation_principal.asp?action=valider&grille=siren&waitframe=false',false,HOST_INSEE);
|
||||
if ($responseQ['code']==302)
|
||||
{
|
||||
//$libelleErreur='Erreur INSEE inconnue 1';
|
||||
|
||||
// Siren Invalide ou autre erreur non répertoriée !
|
||||
$header=$responseQ['header'];
|
||||
if (trim($header['Location'])=='/REPERTOIRE/Reponse/Frame_Reponse.asp?dest=erreur')
|
||||
{
|
||||
$responseQ=getUrl(SITE_INSEE .'REPERTOIRE/Reponse/Frame_Reponse.asp?dest=erreur', $this->response1["header"]["Set-Cookie"], '', SITE_INSEE .'REPERTOIRE/Interrogation/Interrogation_principal.asp?action=valider&grille=siren&waitframe=false',false,HOST_INSEE);
|
||||
$responseErreur=getUrl(SITE_INSEE .'REPERTOIRE/Reponse/Erreur_principal.asp', $this->response1["header"]["Set-Cookie"], '', SITE_INSEE .'REPERTOIRE/Reponse/Frame_Reponse.asp?dest=erreur',false,HOST_INSEE);
|
||||
$pos=strpos($responseErreur['body'], '<td valign=top bgcolor="#FFCC33"><font face=Arial size=2><b>');
|
||||
if ($pos>0){
|
||||
$posFin=strpos($responseErreur['body'], '</b></font></td>', $pos+60);
|
||||
$libelleErreur=trim(substr($responseErreur['body'], $pos+60, $posFin-($pos+60)));
|
||||
} else
|
||||
$tabRet['erreur']='Erreur INSEE inconnue';
|
||||
}
|
||||
else
|
||||
{ if (trim($header['Location'])=='/REPERTOIRE/Reponse/Frame_Reponse.asp?dest=detail&niveau=siege')
|
||||
// L'établissement demandé est un siège !
|
||||
$option=1;
|
||||
|
||||
if ($option==3)
|
||||
{
|
||||
// On déroule les URLs d'appels établissement
|
||||
$responseQ=getUrl(SITE_INSEE .'REPERTOIRE/Reponse/Frame_Reponse.asp?dest=detail&niveau=etablissement', $this->response1["header"]["Set-Cookie"], '', SITE_INSEE .'REPERTOIRE/Interrogation/Interrogation_principal.asp?action=valider&grille=siren&waitframe=false',false,HOST_INSEE);
|
||||
//sleep(1);
|
||||
// Frames réponse niveau Etab
|
||||
$responseQ=getUrl(SITE_INSEE .'SIRENET_Script/Interrogation/script_recherche_menu.asp?niveau=siren', $this->response1["header"]["Set-Cookie"], '', SITE_INSEE .'REPERTOIRE/Reponse/Frame_Reponse.asp?dest=detail&niveau=etablissement',false,HOST_INSEE);
|
||||
$responseQ=getUrl(SITE_INSEE .'SIRENET_Script/Interrogation/script_recherche_barre_haut.asp?niveau=siren', $this->response1["header"]["Set-Cookie"], '', SITE_INSEE .'REPERTOIRE/Reponse/Frame_Reponse.asp?dest=detail&niveau=etablissement',false,HOST_INSEE);
|
||||
$responseQ=getUrl(SITE_INSEE .'REPERTOIRE/Reponse/Reponse_haut.asp', $this->response1["header"]["Set-Cookie"], '', SITE_INSEE .'REPERTOIRE/Reponse/Frame_Reponse.asp?dest=detail&niveau=etablissement',false,HOST_INSEE);
|
||||
$responseEtab=getUrl(SITE_INSEE .'REPERTOIRE/Reponse/Detail_principal.asp?niveau=etablissement', $this->response1["header"]["Set-Cookie"], '', SITE_INSEE .'REPERTOIRE/Reponse/Frame_Reponse.asp?dest=detail&niveau=etablissement', false,HOST_INSEE);
|
||||
$responseQ=getUrl(SITE_INSEE .'REPERTOIRE/Reponse/Detail_bas.asp?niveau=etablissement', $this->response1["header"]["Set-Cookie"], '', SITE_INSEE .'REPERTOIRE/Reponse/Frame_Reponse.asp?dest=detail&niveau=etablissement',false,HOST_INSEE);
|
||||
$responseEtab=$responseEtab['body'];
|
||||
// On recherche si on est bien sur un fiche établissement
|
||||
$pos=strpos($responseEtab, '<table cols="2" width="100%"><tr><td bgcolor="#FFCC33" align="left"><font face="Arial" size="2"><B>Fiche Etablissement</B>');
|
||||
if ($pos<1)
|
||||
$tabRet['erreur']='Erreur SCRIPT Fiche Etablissement non trouvée';
|
||||
$responseSiege=$responseEtab;
|
||||
}
|
||||
else
|
||||
{
|
||||
// On déroule les URLs d'appels Sièges
|
||||
$responseQ=getUrl(SITE_INSEE .'REPERTOIRE/Reponse/Frame_Reponse.asp?dest=detail&niveau=siege', $this->response1["header"]["Set-Cookie"], '', SITE_INSEE .'REPERTOIRE/Interrogation/Interrogation_principal.asp?action=valider&grille=siren&waitframe=false',false,HOST_INSEE);
|
||||
//sleep(1);
|
||||
// Frames réponse niveau sièges
|
||||
$responseQ=getUrl(SITE_INSEE .'SIRENET_Script/Interrogation/script_recherche_menu.asp?niveau=siren', $this->response1["header"]["Set-Cookie"], '', SITE_INSEE .'REPERTOIRE/Reponse/Frame_Reponse.asp?dest=detail&niveau=siege',false,HOST_INSEE);
|
||||
$responseQ=getUrl(SITE_INSEE .'SIRENET_Script/Interrogation/script_recherche_barre_haut.asp?niveau=siren', $this->response1["header"]["Set-Cookie"], '', SITE_INSEE .'REPERTOIRE/Reponse/Frame_Reponse.asp?dest=detail&niveau=siege',false,HOST_INSEE);
|
||||
$responseQ=getUrl(SITE_INSEE .'REPERTOIRE/Reponse/Reponse_haut.asp', $this->response1["header"]["Set-Cookie"], '', SITE_INSEE .'REPERTOIRE/Reponse/Frame_Reponse.asp?dest=detail&niveau=siege',false,HOST_INSEE);
|
||||
$responseSiege=getUrl(SITE_INSEE .'REPERTOIRE/Reponse/Detail_principal.asp?niveau=siege', $this->response1["header"]["Set-Cookie"], '', SITE_INSEE .'REPERTOIRE/Reponse/Frame_Reponse.asp?dest=detail&niveau=siege', false,HOST_INSEE);
|
||||
$responseQ=getUrl(SITE_INSEE .'REPERTOIRE/Reponse/Detail_bas.asp?niveau=siege', $this->response1["header"]["Set-Cookie"], '', SITE_INSEE .'REPERTOIRE/Reponse/Frame_Reponse.asp?dest=detail&niveau=siege',false,HOST_INSEE);
|
||||
$responseSiege=$responseSiege['body'];//strip_tags(html_entity_decode(), '<td>');
|
||||
// On recherche si on est bien sur un fiche siège
|
||||
$pos=strpos($responseSiege, '<table cols="2" width="100%"><tr><td bgcolor="#FFCC33" align="left"><font face="Arial" size="2"><B>Fiche siège</B>');
|
||||
if ($pos<1)
|
||||
$tabRet['erreur']='Erreur SCRIPT Fiche Siège non trouvée';
|
||||
}
|
||||
|
||||
// Niveau entreprise
|
||||
$responseQ=getUrl(SITE_INSEE .'REPERTOIRE/reponse/frame_reponse.asp?niveau=entreprise&dest=detail', $this->response1["header"]["Set-Cookie"], '', SITE_INSEE .'REPERTOIRE/Reponse/Detail_principal.asp?niveau=siege',false,HOST_INSEE);
|
||||
|
||||
$responseQ=getUrl(SITE_INSEE .'SIRENET_Script/Interrogation/script_recherche_menu.asp?niveau=siren', $this->response1["header"]["Set-Cookie"], '', SITE_INSEE .'REPERTOIRE/reponse/frame_reponse.asp?niveau=entreprise&dest=detail',false,HOST_INSEE);
|
||||
$responseQ=getUrl(SITE_INSEE .'SIRENET_Script/Interrogation/script_recherche_barre_haut.asp?niveau=siren', $this->response1["header"]["Set-Cookie"], '', SITE_INSEE .'REPERTOIRE/Reponse/Frame_Reponse.asp?dest=detail&niveau=entreprise',false,HOST_INSEE);
|
||||
$responseQ=getUrl(SITE_INSEE .'REPERTOIRE/Reponse/Reponse_haut.asp', $this->response1["header"]["Set-Cookie"], '', SITE_INSEE .'REPERTOIRE/reponse/frame_reponse.asp?niveau=entreprise&dest=detail',false,HOST_INSEE);
|
||||
$responseEntreprise=getUrl(SITE_INSEE .'REPERTOIRE/Reponse/Detail_principal.asp?niveau=entreprise', $this->response1["header"]["Set-Cookie"], '', SITE_INSEE .'REPERTOIRE/reponse/frame_reponse.asp?niveau=entreprise&dest=detail', false,HOST_INSEE);
|
||||
$responseQ=getUrl(SITE_INSEE .'REPERTOIRE/Reponse/Detail_bas.asp?niveau=entreprise', $this->response1["header"]["Set-Cookie"], '', SITE_INSEE .'REPERTOIRE/reponse/frame_reponse.asp?niveau=entreprise&dest=detail',false,HOST_INSEE);
|
||||
$responseEntreprise=$responseEntreprise['body'];
|
||||
$pos=strpos($responseEntreprise, '<table cols="2" width="100%"><tr><td bgcolor="#FFCC33" align="left"><font face="Arial" size="2"><B>Fiche Entreprise</B>');
|
||||
if ($pos<1) {
|
||||
$tabRet['erreur']='Erreur SCRIPT Fiche Entreprise non trouvée';
|
||||
}
|
||||
|
||||
/** Recherche des données établissement
|
||||
**/
|
||||
$tabRet['etablissement']=$this->getDataEtablissement($responseSiege);
|
||||
|
||||
/** Recherche des données entreprise
|
||||
**/
|
||||
$tabRet['entreprise']=$this->getDataEntreprise($responseEntreprise);
|
||||
|
||||
return $tabRet;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Récupère la liste de tous les établissements d'une entreprise
|
||||
*
|
||||
* @param unknown_type $sirenLu
|
||||
*/
|
||||
function getListeEtabs($sirenLu)
|
||||
{
|
||||
// Requête d'interrogation
|
||||
$postData=array('siren'=>$sirenLu,
|
||||
'option'=>2,
|
||||
'nic'=>'',
|
||||
'dep'=>'',
|
||||
'listeDep'=>'');
|
||||
|
||||
$response=getUrl(SITE_INSEE .'REPERTOIRE/Interrogation/Interrogation_principal.asp?action=valider&grille=siren&waitframe=false', $this->response1["header"]["Set-Cookie"], $postData, SITE_INSEE .'REPERTOIRE/Interrogation/Interrogation_principal.asp?grille=siren&action=nouvelle', false, HOST_INSEE);
|
||||
$action='nouveau';
|
||||
$referer=SITE_INSEE .'REPERTOIRE/Interrogation/Interrogation_principal.asp?action=valider&grille=siren&waitframe=false';
|
||||
$nbRepTot=$pageCour=$nbTotPage=$nbRepParPage=$numEtab=0;
|
||||
$tabInfoEtab=array();
|
||||
$tabRet=array();
|
||||
|
||||
while(true)
|
||||
{
|
||||
$responseQ=getUrl(SITE_INSEE .'REPERTOIRE/reponse/question.asp?action='.$action, $this->response1["header"]["Set-Cookie"], '', $referer, false, HOST_INSEE);
|
||||
if ($responseQ['code']==302)
|
||||
{
|
||||
//$libelleErreur='Erreur INSEE inconnue 1';
|
||||
|
||||
// Siren Invalide ou autre erreur non répertoriée !
|
||||
$header=$responseQ['header'];
|
||||
if (trim($header['Location'])=='/REPERTOIRE/Reponse/Frame_Reponse.asp?dest=erreur')
|
||||
{
|
||||
$responseQ=getUrl(SITE_INSEE .'REPERTOIRE/Reponse/Frame_Reponse.asp?dest=erreur', $this->response1["header"]["Set-Cookie"], '', SITE_INSEE .'REPERTOIRE/Interrogation/Interrogation_principal.asp?action=valider&grille=siren&waitframe=false', false, HOST_INSEE);
|
||||
$responseErreur=getUrl(SITE_INSEE .'REPERTOIRE/Reponse/Erreur_principal.asp', $this->response1["header"]["Set-Cookie"], '', SITE_INSEE .'REPERTOIRE/Reponse/Frame_Reponse.asp?dest=erreur', false, HOST_INSEE);
|
||||
$pos=strpos($responseErreur['body'], '<td valign=top bgcolor="#FFCC33"><font face=Arial size=2><b>');
|
||||
if ($pos>0){
|
||||
$posFin=strpos($responseErreur['body'], '</b></font></td>', $pos+60);
|
||||
$libelleErreur=trim(substr($responseErreur['body'], $pos+60, $posFin-($pos+60)));
|
||||
} else
|
||||
$libelleErreur='Erreur INSEE inconnue';
|
||||
}
|
||||
|
||||
// On déroule les URLs d'appels liste des établissements
|
||||
$responseQ=getUrl(SITE_INSEE .'REPERTOIRE/Reponse/Frame_Reponse.asp?dest=liste', $this->response1["header"]["Set-Cookie"], '', SITE_INSEE .'REPERTOIRE/Interrogation/Interrogation_principal.asp?action=valider&grille=siren&waitframe=false', false, HOST_INSEE);
|
||||
//sleep(1);
|
||||
// Frames réponse niveau Etab
|
||||
$responseQ=getUrl(SITE_INSEE .'SIRENET_Script/Interrogation/script_recherche_menu.asp?niveau=siren', $this->response1["header"]["Set-Cookie"], '', SITE_INSEE .'REPERTOIRE/Reponse/Frame_Reponse.asp?dest=liste', false, HOST_INSEE);
|
||||
$responseQ=getUrl(SITE_INSEE .'SIRENET_Script/Interrogation/script_recherche_barre_haut.asp?niveau=siren', $this->response1["header"]["Set-Cookie"], '', SITE_INSEE .'REPERTOIRE/Reponse/Frame_Reponse.asp?dest=liste', false, HOST_INSEE);
|
||||
$responseQ=getUrl(SITE_INSEE .'REPERTOIRE/Reponse/Reponse_haut.asp', $this->response1["header"]["Set-Cookie"], '', SITE_INSEE .'REPERTOIRE/Reponse/Frame_Reponse.asp?dest=liste', false, HOST_INSEE);
|
||||
$responseListe=getUrl(SITE_INSEE .'REPERTOIRE/Reponse/Liste_principal.asp', $this->response1["header"]["Set-Cookie"], '', SITE_INSEE .'REPERTOIRE/Reponse/Frame_Reponse.asp?dest=liste', false, HOST_INSEE);
|
||||
$responseQ=getUrl(SITE_INSEE .'REPERTOIRE/Reponse/Liste_bas.asp', $this->response1["header"]["Set-Cookie"], '', SITE_INSEE .'REPERTOIRE/Reponse/Frame_Reponse.asp?dest=liste', false, HOST_INSEE);
|
||||
$responseListe=$responseListe['body'];
|
||||
|
||||
$pos=strpos($responseListe, 'Nombre total de réponses : '."\r\n\t\t\t".'<font face="Arial" size="2"><b>');
|
||||
if ($pos>0) {
|
||||
$posFin=strpos($responseListe, '</b></font>', $pos+73);
|
||||
$nbRepTot=trim(substr($responseListe, $pos+73, $posFin-($pos+73)));
|
||||
}
|
||||
$pos=strpos($responseListe, ' - Affichage de la page '."\r\n\t\t\t".'<font face="Arial" size="2"><b>');
|
||||
if ($pos>0) {
|
||||
$posFin=strpos($responseListe, ' - </b></font>', $pos+75);
|
||||
$strPages=trim(substr($responseListe, $pos+75, $posFin-($pos+75)));
|
||||
$tabPages=explode(' / ', $strPages);
|
||||
$pageCour=$tabPages[0];
|
||||
$nbTotPage=$tabPages[1];
|
||||
}
|
||||
$pos=strpos($responseListe, ' - </b></font>'."\r\n\t\t\t".'<font face="Arial" size="2"><b>');
|
||||
if ($pos>0) {
|
||||
$posFin=strpos($responseListe, '</b></font>', $pos+60);
|
||||
$nbRepParPage=trim(substr($responseListe, $pos+60, $posFin-($pos+60)));
|
||||
}
|
||||
|
||||
/* TODO = Récupérer les infos étab + entrep pour chaque ligne du tableau !!!*
|
||||
*/
|
||||
if ($libelleErreur=='Erreur SCRIPT Inconnue')
|
||||
$libelleErreur='';
|
||||
for ($i=1;$i<11; $i++)
|
||||
{
|
||||
if ($numEtab==$nbRepTot)
|
||||
break; // Il n'y a pas plus d'établissement à récupérer ! On sort...
|
||||
|
||||
$responseQ=getUrl(SITE_INSEE .'REPERTOIRE/reponse/question.asp?action=detail&numtableau='.$i, $this->response1["header"]["Set-Cookie"], '', SITE_INSEE .'REPERTOIRE/Reponse/Liste_principal.asp', false, HOST_INSEE);
|
||||
if ($responseQ['code']==302)
|
||||
{
|
||||
// Siren Invalide ou autre erreur non répertoriée !
|
||||
$header=$responseQ['header'];
|
||||
if (trim($header['Location'])=='/REPERTOIRE/Reponse/Frame_Reponse.asp?origine=liste&dest=detail&niveau=siege&numtableau='.$i)
|
||||
{
|
||||
// On déroule les URLs d'appels fiche siège
|
||||
$responseQ=getUrl(SITE_INSEE .'REPERTOIRE/Reponse/Frame_Reponse.asp?dest=detail&niveau=siege&numtableau='.$i, $this->response1["header"]["Set-Cookie"], '', SITE_INSEE .'REPERTOIRE/Interrogation/Interrogation_principal.asp?action=valider&grille=siren&waitframe=false', false, HOST_INSEE);
|
||||
//sleep(1);
|
||||
// Frames réponse niveau Etab
|
||||
$responseQ=getUrl(SITE_INSEE .'SIRENET_Script/Interrogation/script_recherche_menu.asp?niveau=siren', $this->response1["header"]["Set-Cookie"], '', SITE_INSEE .'REPERTOIRE/Reponse/Frame_Reponse.asp?dest=detail&niveau=siege', false, HOST_INSEE);
|
||||
$responseQ=getUrl(SITE_INSEE .'SIRENET_Script/Interrogation/script_recherche_barre_haut.asp?niveau=siren', $this->response1["header"]["Set-Cookie"], '', SITE_INSEE .'REPERTOIRE/Reponse/Frame_Reponse.asp?dest=detail&niveau=siege', false, HOST_INSEE);
|
||||
$responseQ=getUrl(SITE_INSEE .'REPERTOIRE/Reponse/Reponse_haut.asp', $this->response1["header"]["Set-Cookie"], '', SITE_INSEE .'REPERTOIRE/Reponse/Frame_Reponse.asp?dest=detail&niveau=siege', false, HOST_INSEE);
|
||||
$responseEtab=getUrl(SITE_INSEE .'REPERTOIRE/Reponse/Detail_principal.asp?niveau=siege&numtableau='.$i.'&origine=liste', $this->response1["header"]["Set-Cookie"], '', SITE_INSEE .'REPERTOIRE/Reponse/Frame_Reponse.asp?origine=liste&dest=detail&niveau=siege&numtableau='.$i, false, HOST_INSEE);
|
||||
$responseQ=getUrl(SITE_INSEE .'REPERTOIRE/Reponse/Detail_bas.asp?niveau=siege&numtableau='.$i.'&origine=liste', $this->response1["header"]["Set-Cookie"], '', SITE_INSEE .'REPERTOIRE/Reponse/Frame_Reponse.asp?origine=liste&dest=detail&niveau=siege&numtableau='.$i, false, HOST_INSEE);
|
||||
$responseEtab=$responseEtab['body'];
|
||||
|
||||
// Récupération de la fiche entreprise INSEE
|
||||
$responseQ=getUrl(SITE_INSEE .'REPERTOIRE/reponse/frame_reponse.asp?niveau=entreprise&dest=detail&origine=liste&numtableau='.$i, $this->response1["header"]["Set-Cookie"], '', SITE_INSEE .'REPERTOIRE/Reponse/Detail_principal.asp?niveau=siege&numtableau='.$i.'&origine=liste', false, HOST_INSEE);
|
||||
$responseQ=getUrl(SITE_INSEE .'SIRENET_Script/Interrogation/script_recherche_menu.asp?niveau=siren', $this->response1["header"]["Set-Cookie"], '', SITE_INSEE .'REPERTOIRE/reponse/frame_reponse.asp?niveau=entreprise&dest=detail&origine=liste&numtableau='.$i, false, HOST_INSEE);
|
||||
$responseQ=getUrl(SITE_INSEE .'SIRENET_Script/Interrogation/script_recherche_barre_haut.asp?niveau=siren', $this->response1["header"]["Set-Cookie"], '', SITE_INSEE .'REPERTOIRE/Reponse/Frame_Reponse.asp?niveau=entreprise&dest=detail&origine=liste&numtableau='.$i, false, HOST_INSEE);
|
||||
$responseQ=getUrl(SITE_INSEE .'REPERTOIRE/Reponse/Reponse_haut.asp', $this->response1["header"]["Set-Cookie"], '', SITE_INSEE .'REPERTOIRE/reponse/frame_reponse.asp?niveau=entreprise&dest=detail&origine=liste&numtableau='.$i, false, HOST_INSEE);
|
||||
$responseEntreprise=getUrl(SITE_INSEE .'REPERTOIRE/Reponse/Detail_principal.asp?niveau=entreprise&numtableau='.$i.'&origine=liste', $this->response1["header"]["Set-Cookie"], '', SITE_INSEE .'REPERTOIRE/reponse/Frame_Reponse.asp?niveau=entreprise&dest=detail&origine=liste&numtableau='.$i, false, HOST_INSEE);
|
||||
$responseQ=getUrl(SITE_INSEE .'REPERTOIRE/Reponse/Detail_bas.asp?niveau=entreprise&numtableau='.$i.'&origine=liste', $this->response1["header"]["Set-Cookie"], '', SITE_INSEE .'REPERTOIRE/reponse/Frame_Reponse.asp?niveau=entreprise&dest=detail&origine=liste&numtableau='.$i, false, HOST_INSEE);
|
||||
$responseEntreprise=$responseEntreprise['body'];
|
||||
}
|
||||
elseif (trim($header['Location'])=='/REPERTOIRE/Reponse/Frame_Reponse.asp?origine=liste&dest=detail&niveau=etablissement&numtableau='.$i)
|
||||
{
|
||||
// On déroule les URLs d'appels établissement
|
||||
$responseQ=getUrl(SITE_INSEE .'REPERTOIRE/Reponse/Frame_Reponse.asp?dest=detail&niveau=etablissement&numtableau='.$i, $this->response1["header"]["Set-Cookie"], '', SITE_INSEE .'REPERTOIRE/Interrogation/Interrogation_principal.asp?action=valider&grille=siren&waitframe=false', false, HOST_INSEE);
|
||||
//sleep(1);
|
||||
// Frames réponse niveau Etab
|
||||
$responseQ=getUrl(SITE_INSEE .'SIRENET_Script/Interrogation/script_recherche_menu.asp?niveau=siren', $this->response1["header"]["Set-Cookie"], '', SITE_INSEE .'REPERTOIRE/Reponse/Frame_Reponse.asp?dest=detail&niveau=etablissement', false, HOST_INSEE);
|
||||
$responseQ=getUrl(SITE_INSEE .'SIRENET_Script/Interrogation/script_recherche_barre_haut.asp?niveau=siren', $this->response1["header"]["Set-Cookie"], '', SITE_INSEE .'REPERTOIRE/Reponse/Frame_Reponse.asp?dest=detail&niveau=etablissement', false, HOST_INSEE);
|
||||
$responseQ=getUrl(SITE_INSEE .'REPERTOIRE/Reponse/Reponse_haut.asp', $this->response1["header"]["Set-Cookie"], '', SITE_INSEE .'REPERTOIRE/Reponse/Frame_Reponse.asp?dest=detail&niveau=etablissement', false, HOST_INSEE);
|
||||
$responseEtab=getUrl(SITE_INSEE .'REPERTOIRE/Reponse/Detail_principal.asp?niveau=etablissement&numtableau='.$i.'&origine=liste', $this->response1["header"]["Set-Cookie"], '', SITE_INSEE .'REPERTOIRE/Reponse/Frame_Reponse.asp?origine=liste&dest=detail&niveau=etablissement&numtableau='.$i, false, HOST_INSEE);
|
||||
$responseQ=getUrl(SITE_INSEE .'REPERTOIRE/Reponse/Detail_bas.asp?niveau=etablissement&numtableau='.$i.'&origine=liste', $this->response1["header"]["Set-Cookie"], '', SITE_INSEE .'REPERTOIRE/Reponse/Frame_Reponse.asp?origine=liste&dest=detail&niveau=etablissement&numtableau='.$i, false, HOST_INSEE);
|
||||
$responseEtab=$responseEtab['body'];
|
||||
}
|
||||
$tabRet['etablissements'][$numEtab]=$this->getDataEtablissement($responseEtab);
|
||||
$tabRet['entreprise']=$this->getDataEntreprise($responseEntreprise);
|
||||
|
||||
if ($libelleErreur<>'' && $tabInfoEtab['siret'] =='') $siret=$sirenLu . $nicLu;
|
||||
else $siret=$tabInfoEtab['siret'];
|
||||
|
||||
/*$str= date('d/m/Y à H:i:s') .';'.
|
||||
$libelleErreur .';'.
|
||||
// Siège
|
||||
$siret .';'.
|
||||
$tabInfoEtab['active'] .';'.
|
||||
$tabInfoEtab['dateAbsActivite'] .';'.
|
||||
$tabInfoEtab['typeEtablissement'] .';'.
|
||||
$tabInfoEtab['dateMAJ'] .';'.
|
||||
$tabInfoEtab['dateCreation'] .';'.
|
||||
$tabInfoEtab['raisonSociale'] .';'.
|
||||
$tabInfoEtab['Enseigne'] .';'.
|
||||
$tabInfoEtab['NafCode'] .';'.
|
||||
$tabInfoEtab['NafLib'] .';'.
|
||||
$tabInfoEtab['AdresseLigne1'] .';'.
|
||||
$tabInfoEtab['AdresseLigne2'] .';'.
|
||||
$tabInfoEtab['AdresseLigne3'] .';'.
|
||||
$tabInfoEtab['etatJuridique'] .';'.
|
||||
$tabInfoEtab['dateEtatJuridique'] .';'.
|
||||
// Entreprise
|
||||
$tabInfoEntrep['dateCreationEntrep'] .';'.
|
||||
$tabInfoEntrep['raisonSocialeEntrep'] .';'.
|
||||
$tabInfoEntrep['sigle'] .';'.
|
||||
$tabInfoEntrep['NafCodeEntrep'] .';'.
|
||||
$tabInfoEntrep['NafLibEntrep'] .';'.
|
||||
$tabInfoEntrep['FJCodeEntrep'] .';'.
|
||||
$tabInfoEntrep['FJLibEntrep'] .';'.
|
||||
$tabInfoEntrep['nbEtabActifs'] .';';
|
||||
*/
|
||||
//fwrite($fpOUT, $str."\r\n");
|
||||
$numEtab++;
|
||||
$num=$key+1;
|
||||
$typeEtablissement=$tabInfoEtab['typeEtablissement'];
|
||||
//echo "Question $num/$nbLignes : Demande=$sirenLu$nicLu Etablissement $numEtab/$nbRepTot $typeEtablissement=$siret $libelleErreur\r\n";
|
||||
flush();
|
||||
sleep(1);
|
||||
|
||||
}//end for
|
||||
}//end if
|
||||
if ($pageCour==$nbTotPage) {
|
||||
// On sort de la boucle de passage à la page de liste suivante car il n'y a plus d'autres pages
|
||||
break;
|
||||
} else {
|
||||
$action='listeplus';
|
||||
$referer=SITE_INSEE .'REPERTOIRE/Reponse/Liste_principal.asp';
|
||||
}
|
||||
}
|
||||
} //Fin While
|
||||
return $tabRet;
|
||||
}
|
||||
|
||||
private function getDataEtablissement($pageHtml)
|
||||
{
|
||||
global $libelleErreur;
|
||||
|
||||
$responseSiege=$pageHtml;
|
||||
$tabRet=array();
|
||||
|
||||
// On recherche si on est sur un établissement siège ou secondaire
|
||||
$pos=strpos($pageHtml, '<table cols="2" width="100%"><tr><td bgcolor="#FFCC33" align="left"><font face="Arial" size="2"><B>Fiche Etablissement</B>');
|
||||
if ($pos>0)
|
||||
$tabRet['typeEtablissement']='secondaire';
|
||||
|
||||
$pos=strpos($pageHtml, '<table cols="2" width="100%"><tr><td bgcolor="#FFCC33" align="left"><font face="Arial" size="2"><B>Fiche siège</B>');
|
||||
if ($pos>0)
|
||||
$tabRet['typeEtablissement']='siège';
|
||||
|
||||
// Recherche Dernière MAJ / Activité
|
||||
$pos=strpos($responseSiege, '<font face="Arial" size="2">(dernière mise à jour :');
|
||||
if ($pos>0) {
|
||||
$tabRet['dateMAJ']=substr($responseSiege, $pos+51, 10);
|
||||
$tabRet['dateAbsActivite']='';
|
||||
$tabRet['active']='O';
|
||||
} else {
|
||||
$tabRet['active']='N';
|
||||
$tabRet['dateMAJ']='';
|
||||
$pos=strpos($responseSiege, '<font face="Arial" size="2">Absence d\'activité notée le : ');
|
||||
if ($pos>0) $tabRet['dateAbsActivite']=substr($responseSiege, $pos+78, 10);
|
||||
else {
|
||||
$pos=strpos($responseSiege, '<font face="Arial" size="2">Absence d\'activité');
|
||||
if ($pos>0) $tabRet['dateAbsActivite']='';
|
||||
}
|
||||
}
|
||||
|
||||
$pos=strpos($responseSiege, ' size="-1"> <B>n° SIRET :</B></FONT></td><td valign="top"><font face="Arial" size="-1">');
|
||||
$tabRet['siret']=str_replace(' ', '', html_entity_decode(substr($responseSiege, $pos+97, 32)));
|
||||
|
||||
$pos=strpos($responseSiege, 'size="-1"> <B>Date de création :</B></FONT></td><td valign="top"><font face="Arial" size="-1">');
|
||||
if ($pos>0) {
|
||||
$posFin=strpos($responseSiege, '</font>', $pos+109);
|
||||
$tabRet['dateCreation']=str_replace(' ', '', html_entity_decode(substr($responseSiege, $pos+109, $posFin-($pos+109))));
|
||||
}
|
||||
else $tabRet['dateCreation']='';
|
||||
|
||||
$pos=strpos($responseSiege, ' size="-1"> <B>Raison sociale et Enseigne :</B></FONT></td><td valign="top" colspan="3"><font face="Arial" size="-1">');
|
||||
$len=127;
|
||||
if ($pos==0){
|
||||
$pos=strpos($responseSiege, ' size="-1"> <B>Raison sociale et Enseigne :</B></FONT></td><td valign="top" colspan="3"><font face="Arial" size="-1">');
|
||||
$len=122;
|
||||
if ($pos==0){
|
||||
$pos=strpos($responseSiege, ' size="-1"> <B>Raison sociale et Enseigne :</B></FONT></td><td valign="top" colspan="3"><font face="Arial" size="-1">');
|
||||
$len=126;
|
||||
$libelleErreur='Informations INSEE non diffusables';
|
||||
}
|
||||
}
|
||||
if ($libelleErreur=='') {
|
||||
//LARGE*DOMINIQUE MICHEL/ <BR>GERANT SARL BIMAGIQUE </font>
|
||||
$posFin=strpos($responseSiege, '</font>', $pos+$len);
|
||||
$raisonSocialeStr=trim(substr($responseSiege, $pos+$len, $posFin-($pos+$len)));
|
||||
$raisonSocialeTabLigne=explode('<BR>', $raisonSocialeStr);
|
||||
$tabRet['raisonSociale']=trim(str_replace(' ', '', html_entity_decode($raisonSocialeTabLigne[0])));
|
||||
$tabRet['Enseigne']=trim(str_replace(' ', '', html_entity_decode(@$raisonSocialeTabLigne[1])));
|
||||
$pos=strpos($responseSiege, ' size="-1"> <B>Activité principale :</B></FONT></td><td valign="top" colspan="3"><font face="Arial" size="-1">');
|
||||
$tabRet['NafCode']=substr($responseSiege, $pos+120, 4);
|
||||
$tabRet['NafLib']=trim(substr($responseSiege, $pos+137, 70));
|
||||
|
||||
$pos=strpos($responseSiege, ' size="-1"> <B>Adresse :</B></FONT></td><td valign="top" colspan="3"><font face="Arial" size="-1">');
|
||||
$posFin=strpos($responseSiege, '</font>', $pos+103);
|
||||
$AdresseStr=substr($responseSiege, $pos+103, $posFin-($pos+103));
|
||||
$AdresseTabLigne=explode('<BR>', $AdresseStr);//'
|
||||
$tabRet['AdresseLigne1']=str_replace(' ', '/', $AdresseTabLigne[0]);
|
||||
$tabRet['AdresseLigne2']=str_replace(' ', '/', $AdresseTabLigne[1]);
|
||||
$tabRet['AdresseLigne3']=str_replace(' ', '/', $AdresseTabLigne[2]);
|
||||
/*
|
||||
$AdresseNum=$AdresseTabLigne1[0];
|
||||
$AdresseVoi=$AdresseTabLigne1[1];
|
||||
$AdresseRue=$AdresseTabLigne1[2];
|
||||
$AdresseCP=$AdresseTabLigne2[0];
|
||||
$AdresseVille=$AdresseTabLigne2[1];
|
||||
*/
|
||||
$pos=strpos($responseSiege, '<font face="Arial" size="-1"><b>L\'entreprise est connue au répertoire comme ');
|
||||
if ($pos>0) {
|
||||
$posFin=strpos($responseSiege, '</b>', $pos+106);
|
||||
$tabRet['etatJuridique']=html_entity_decode(substr($responseSiege, $pos+106, $posFin-($pos+106)));
|
||||
$tabRet['dateEtatJuridique']='';
|
||||
} else {
|
||||
$pos=strpos($responseSiege, '<font face="Arial" size="-1"><b>L\'entreprise est cessée le : ');
|
||||
$tabRet['dateEtatJuridique']=substr($responseSiege, $pos+86, 10);
|
||||
$tabRet['etatJuridique']='cessée';
|
||||
}
|
||||
//echo 'GetDataEtab="'.$libelleErreur."\"\r\n";
|
||||
return $tabRet;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private function getDataEntreprise($pageHtml)
|
||||
{
|
||||
global $libelleErreur;
|
||||
|
||||
$responseEntreprise=$pageHtml;
|
||||
$tabRet=array();
|
||||
|
||||
if ($libelleErreur=='') {
|
||||
|
||||
$pos=strpos($responseEntreprise, 'size="-1"> <B>Date de création :</B></FONT></td><td valign="top"><font face="Arial" size="-1">');
|
||||
if ($pos>0)
|
||||
$tabRet['dateCreationEntrep']=substr($responseEntreprise, $pos+109, 10);
|
||||
else
|
||||
$tabRet['$dateCreationEntrep']='';
|
||||
|
||||
// Raison sociale et Sigle
|
||||
$pos=strpos($responseEntreprise, ' size="-1"> <B>Raison sociale et Sigle :</B></FONT></td><td valign="top" colspan="3"><font face="Arial" size="-1">');
|
||||
$posFin=strpos($responseEntreprise, '</font>', $pos+123);
|
||||
$raisonSocialeStr=trim(substr($responseEntreprise, $pos+123, $posFin-($pos+123)));
|
||||
$raisonSocialeTabLigne=explode('<BR>', $raisonSocialeStr);
|
||||
$tabRet['raisonSocialeEntrep']=trim(str_replace(' ', '', html_entity_decode($raisonSocialeTabLigne[0])));
|
||||
$tabRet['sigle']=trim(str_replace(' ', '', html_entity_decode(@$raisonSocialeTabLigne[1])));
|
||||
|
||||
// Activité prinicpale Entrep
|
||||
$pos=strpos($responseEntreprise, ' size="-1"> <B>Activité principale :</B></FONT></td><td valign="top" colspan="3"><font face="Arial" size="-1">');
|
||||
$tabRet['NafCodeEntrep']=substr($responseEntreprise, $pos+120, 4);
|
||||
$tabRet['NafLibEntrep']=trim(substr($responseEntreprise, $pos+137, 70));
|
||||
|
||||
// Forme Juridique
|
||||
$pos=strpos($responseEntreprise, ' size="-1"> <B>Forme juridique :</B></FONT></td><td valign="top" colspan="3"><font face="Arial" size="-1">');
|
||||
$tabRet['FJCodeEntrep']=substr($responseEntreprise, $pos+116, 4);
|
||||
$tabRet['FJLibEntrep']=trim(substr($responseEntreprise, $pos+133, 70));
|
||||
|
||||
// Nb Etab Actifs
|
||||
$tabRet['nbEtabActifs']=trim(str_replace(' ', '', html_entity_decode(@getTextInHtml($responseEntreprise, '<B>Nb établissements actifs :</B>', '<font face="Arial" size="-1">', '</font>'))));
|
||||
}
|
||||
return $tabRet;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
223
library/Metier/partenaires/classMAmabis.php
Normal file
223
library/Metier/partenaires/classMAmabis.php
Normal file
@ -0,0 +1,223 @@
|
||||
<?php
|
||||
|
||||
ini_set('soap.wsdl_cache_enabled', 0);
|
||||
|
||||
class AmaSoapClient extends SoapClient {
|
||||
|
||||
function __doRequest($request, $location, $action, $version) {
|
||||
/* $request = strtr($request, array('<ns1:'=>'<ama:',
|
||||
'</ns1:'=>'</ama:',
|
||||
// '<param0 xsi:type="xsd:string">'=>'',
|
||||
'xmlns:ns1="http://www.amabis.com/ama.xsd"'=>'xmlns:ama="http://www.amabis.com/ama.xsd"',
|
||||
// '</param0>'=>'',
|
||||
// '<'=>'<',
|
||||
// '>'=>'>',
|
||||
)
|
||||
);*/
|
||||
return parent::__doRequest($request, $location, $action, $version);
|
||||
}
|
||||
}
|
||||
|
||||
class MAmabis {
|
||||
|
||||
private $client;
|
||||
|
||||
function __construct() {
|
||||
/* $this->client = new AmaSoapClient(null, //'http://www.amabis.com/ama.wsdl',//null, //
|
||||
array( 'location' => AMABIS_WS_URL,//'http://sw4.amabis.com:5101',
|
||||
'uri' => AMABIS_WS_URI,//'http://sw4.amabis.com:5101',
|
||||
'soap_version' => SOAP_1_1,
|
||||
'trace' => 1,
|
||||
'style' => SOAP_RPC,
|
||||
'use' => SOAP_ENCODED,
|
||||
'connection_timeout'=> 2,
|
||||
)
|
||||
);
|
||||
*/
|
||||
$this->client = new AmaSoapClient(null,
|
||||
array( //'location' => 'http://sw4.amabis.com:5100',
|
||||
'location' => 'http://sw2.amabis.com:5100/',
|
||||
'uri' => 'http://www.amabis.com/ns.xsd',
|
||||
'connection_timeout' => 2,
|
||||
'default_socket_timeout'=> 2,
|
||||
'soap_version' => SOAP_1_1,
|
||||
'trace' => 1,
|
||||
'style' => SOAP_RPC,
|
||||
'use' => SOAP_ENCODED,
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
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;
|
||||
$dep2=substr($cp,0,2)*1;
|
||||
$dep3=substr($cp,0,3)*1;
|
||||
switch ($dep2) {
|
||||
case 0:
|
||||
case 5:
|
||||
case 9:
|
||||
case 15:
|
||||
case 19:
|
||||
case 23:
|
||||
case 32:
|
||||
case 46:
|
||||
case 48:
|
||||
case 82:
|
||||
case 97: // DOM
|
||||
case 98: // TOM
|
||||
case 99: // Etranger
|
||||
return $tabRep;
|
||||
break;
|
||||
default:
|
||||
//if ($dep3==975) return $tabRep;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$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);
|
||||
if (count($ret)>0) {
|
||||
$zones=$ret[0];
|
||||
$tabRep['ZUS']=$tabRep['ZFU']=$tabRep['ZRU']=$tabRep['CUCS']='NON';
|
||||
if (trim($zones['zus'])<>'') {
|
||||
if (trim($zones['zus'])=='NSP') $tabRep['ZUS']='NSP';
|
||||
else $tabRep['ZUS']='OUI';
|
||||
$tabRep['NZUS']=$zones['zus'];
|
||||
}
|
||||
if (trim($zones['zru'])<>'') {
|
||||
if (trim($zones['zru'])=='NSP') $tabRep['ZRU']='NSP';
|
||||
else $tabRep['ZRU']='OUI';
|
||||
$tabRep['NZRU']=$zones['zru'];
|
||||
}
|
||||
if (trim($zones['zfu'])<>'') {
|
||||
if (trim($zones['zfu'])=='NSP') $tabRep['ZFU']='NSP';
|
||||
else $tabRep['ZFU']='OUI';
|
||||
$tabRep['NZFU']=$zones['zfu'];
|
||||
}
|
||||
if (trim($zones['cucs'])<>'') {
|
||||
if (trim($zones['cucs'])=='NSP') $tabRep['CUCS']='NSP';
|
||||
else $tabRep['CUCS']='OUI';
|
||||
$tabRep['NCUCS']=$zones['cucs'];
|
||||
}
|
||||
//return $tabRep;
|
||||
} else {
|
||||
|
||||
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",
|
||||
'¿°ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûýýþÿ??',
|
||||
' aaaaaaaceeeeiiiidnoooooouuuuybsaaaaaaaceeeeiiiidnoooooouuuyybyRr'),'adresse'),
|
||||
new SoapParam(':','separateur'),
|
||||
new SoapParam('type=M','options')
|
||||
);
|
||||
/*$rep=$this->client->zonage( "<adresse></adresse>".
|
||||
"<separateur>:</separateur>".
|
||||
"<options>type=M</options>");*/
|
||||
|
||||
/** Découpage des ZFU, CUCS etcs...
|
||||
**/
|
||||
$fp=fopen(LOG_PATH.'/amabis.log', 'a');
|
||||
fwrite($fp, date('d-m-Y H:i:s').' - '.implode("\n", $rep)."\n============================================================================\n");
|
||||
fclose($fp);
|
||||
|
||||
$tabZones=explode(',',$rep['zonage']); // ZUS=OUI,NZUS=1127020,ZFU=OUI,NZFU=11270ZF,CUCS=OUI,NCUCS=1127020
|
||||
foreach ($tabZones as $zone) {
|
||||
$tabTmp=explode('=',$zone);
|
||||
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';
|
||||
$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);
|
||||
|
||||
/** 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);
|
||||
}
|
||||
}
|
||||
} catch (SoapFault $fault) {
|
||||
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;
|
||||
}
|
||||
$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';
|
||||
foreach ($ret as $zones)
|
||||
switch ($zones['typeZone']) {
|
||||
case 'ZRR': $tabRep['ZRR']='OUI'; $tabRep['NZRR']=$codeInsee; break;
|
||||
case 'ZAFR': $tabRep['AFR']='OUI'; $tabRep['NAFR']=$codeInsee; break;
|
||||
default: break;
|
||||
}
|
||||
|
||||
return $tabRep;
|
||||
}
|
||||
|
||||
function searchByTelFax($tel) {
|
||||
return $this->getTelFax('','','','',$tel);
|
||||
}
|
||||
|
||||
function getTelFax($nom, $cp, $ville='', $prenom='', $tel='') {
|
||||
if (trim($tel)<>'')
|
||||
$query="<telep>$tel</telep><scoremini>10</scoremini><distinction>30</distinction>";
|
||||
elseif (trim($prenom)=='')
|
||||
$query="<rs>$nom</rs><cpville>$cp $ville</cpville><scoremini>90</scoremini><distinction>30</distinction>";
|
||||
else
|
||||
$query="<nom>$nom</nom><prenom>$prenom</prenom><cpville>$cp $ville</cpville><scoremini>90</scoremini><distinction>30</distinction>";
|
||||
|
||||
$rep=$this->client->rechtel($query);
|
||||
|
||||
$fp=fopen(LOG_PATH.'/amabis.log', 'a');
|
||||
fwrite($fp, date('d-m-Y H:i:s')." - $query - ".implode("\n", $rep)."\n============================================================================\n");
|
||||
fwrite($fp, "Requête : ".$this->client->__getLastRequest()."\n");
|
||||
fwrite($fp, "Réponse : ".$this->client->__getLastResponse()."\n");
|
||||
fclose($fp);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
304
library/Metier/partenaires/classMArtisanat.php
Normal file
304
library/Metier/partenaires/classMArtisanat.php
Normal file
@ -0,0 +1,304 @@
|
||||
<?
|
||||
define ('ARTISANAT_DISPO_WEB', 1);
|
||||
include_once(FWK_PATH.'common/curl.php');
|
||||
|
||||
class MArtisanat {
|
||||
|
||||
public $body = '';
|
||||
public $header = '';
|
||||
public $codeRetour = 0;
|
||||
public $referer='';
|
||||
public $libErreur='';
|
||||
public $cookie='';
|
||||
public $iDb;
|
||||
public $enCache=false;
|
||||
|
||||
function __construct() {
|
||||
$this->iDb=new WDB();
|
||||
}
|
||||
|
||||
function getIdentite($siren, $refresh=false) {
|
||||
$siren=$siren*1;
|
||||
$res=$this->iDb->select('artisanat', 'id, siren, actif, numRM, denomination, sigle, nomCommercial, enseigne, fj, effectif, aprm, debutActivite, activite, adresse, cp, ville, cessation, radiation, nbInscriptions, nom, prenom, nomUsage, dateNaiss, lieuNaiss, natio, qualite, qualif, dateQualif, dateFctDeb, dateFctFin, IF(dateInsert>dateUpdate,dateInsert,dateUpdate) AS dateUpdate', "siren=$siren", false, MYSQL_ASSOC);
|
||||
if (count($res)>0 && !$refresh) {
|
||||
$this->enCache=true;
|
||||
$tabInsert=$res[0];
|
||||
} elseif (ARTISANAT_DISPO_WEB) {
|
||||
$this->enCache=false;
|
||||
$url='http://www.cma-paris.fr/CMP/rm_recherche.php?dom=Gerer&fonction=recherche';
|
||||
$page=getUrl($url, '', '', $this->referer, false, 'www.cma-paris.fr', false, '', '', 21);
|
||||
$this->body=$page['body'];
|
||||
$this->codeRetour=$page['code'];
|
||||
if ($this->codeRetour<>'200') {
|
||||
$this->libErreur='Erreur Artisanat 200a !';
|
||||
return false;
|
||||
}
|
||||
$this->cookie=$page['header']['Set-Cookie'];
|
||||
$this->referer=$url;
|
||||
|
||||
$url='http://www.cma-paris.fr/CMP/rm_recherche.php?dom=Gerer&fonction=cherche';
|
||||
$postData=array( 'siren_op'=>'%3D',
|
||||
'siren'=>$siren,
|
||||
'den_rent_op'=>'%25',
|
||||
'den_rent'=>'',
|
||||
'adresse_op'=>'contient',
|
||||
'adresse'=>'',
|
||||
'bde_rent_op'=>'%25',
|
||||
'bde_rent'=>'',
|
||||
'nom_rdir_op'=>'%25',
|
||||
'nom_rdir'=>'',
|
||||
'pren_rdir_op'=>'%25',
|
||||
'pren_rdir'=>'',
|
||||
'table'=>'rentreprise',//'rentrad',
|
||||
'x'=>56,
|
||||
'y'=>14,
|
||||
);
|
||||
randsleep(1,2);
|
||||
$page=getUrl($url, $this->cookie, $postData, $this->referer, false, 'www.cma-paris.fr', false, '', '', 21);
|
||||
$this->body=$page['body'];
|
||||
$this->codeRetour=$page['code'];
|
||||
if ($this->codeRetour<>'200') {
|
||||
$this->libErreur='Erreur Artisanat 200b !';
|
||||
return false;
|
||||
}
|
||||
$this->referer=$url;
|
||||
|
||||
if (preg_match('/<span.class="rouge">aucune.entreprise.ne.correspond(?:.*)vos.crit(?:.*)de.recherche<\/span>/Uis', $this->body, $matches)) {
|
||||
$url='http://www.cma-paris.fr/CMP/rm_recherche.php?dom=Gerer&fonction=cherche';
|
||||
$postData=array( 'siren_op'=>'%3D',
|
||||
'siren'=>$siren,
|
||||
'den_rent_op'=>'%25',
|
||||
'den_rent'=>'',
|
||||
'adresse_op'=>'contient',
|
||||
'adresse'=>'',
|
||||
'bde_rent_op'=>'%25',
|
||||
'bde_rent'=>'',
|
||||
'nom_rdir_op'=>'%25',
|
||||
'nom_rdir'=>'',
|
||||
'pren_rdir_op'=>'%25',
|
||||
'pren_rdir'=>'',
|
||||
'table'=>'rentrad',
|
||||
'x'=>56,
|
||||
'y'=>14,
|
||||
);
|
||||
randsleep(1,2);
|
||||
$page=getUrl($url, $this->cookie, $postData, $this->referer, false, 'www.cma-paris.fr', false, '', '', 21);
|
||||
$this->body=$page['body'];
|
||||
$this->codeRetour=$page['code'];
|
||||
if ($this->codeRetour<>'200') {
|
||||
$this->libErreur='Erreur Artisanat 200c !';
|
||||
return false;
|
||||
}
|
||||
$this->referer=$url;
|
||||
}
|
||||
|
||||
/** Gestion des multi-inscriptions au RM **/
|
||||
if (preg_match('/<b class="gris">(.*)entreprises.correspondent(?:.*)vos.crit(?:.*)de.recherche<\/span>/Uis', $this->body, $matches))
|
||||
{
|
||||
$nbRep=trim($matches[1])*1;
|
||||
$iRadMax=-1;
|
||||
if (preg_match_all('/<a class="turquoise" href="(rm\.php\?dom=Gerer&fonction=dossier&(.*))">/Uis', $this->body, $matches)) {
|
||||
$tabUrls=array_unique($matches[1]);
|
||||
$anRadMax=0;
|
||||
// Recherche de la dernière inscription
|
||||
foreach ($tabUrls as $iUrl=>$url) {
|
||||
// On prend la dernière inscription
|
||||
$tabTmp=explode('&',$url);
|
||||
if (substr($tabTmp[3],0,8)=='an_rera=') {
|
||||
$anRad=substr($tabTmp[3],8);
|
||||
if ($anRad>$anRadMax) {
|
||||
$anRadMax=$anRad;
|
||||
$iRadMax=$iUrl;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($iRadMax==-1) die('$iRadMax==-1 Cas impossible !'.EOL.print_r($tabUrls,true).EOL.print_r($matches,true));
|
||||
// Accès à la dernière fiche
|
||||
$url='http://www.cma-paris.fr/CMP/'.strtr(trim($tabUrls[$iRadMax]),array('&'=>'&'));
|
||||
randsleep(1,2);
|
||||
$page=getUrl($url, $this->cookie, '', $this->referer, false, 'www.cma-paris.fr', false, '', '', 21);
|
||||
$this->body=$page['body'];
|
||||
$this->codeRetour=$page['code'];
|
||||
if ($this->codeRetour<>'200') {
|
||||
$this->libErreur='Erreur Artisanat 200c !';
|
||||
return false;
|
||||
}
|
||||
$this->referer=$url;
|
||||
}
|
||||
|
||||
$tabInsert=array();
|
||||
|
||||
if (preg_match('/n° d\'identification \(SIREN\)<\/span><\/td>(?:.*)<td align="left" nowrap>(.*) <\/td>((?:.*)n° de gestion rm<\/span><\/td>(?:.*)<td align="left" nowrap>(.*)<\/td>)?/Uis', $this->body, $matches)) {
|
||||
$sirenLu=$matches[1]*1;
|
||||
if ($siren==$sirenLu) {
|
||||
$tabInsert['siren']=$matches[1];
|
||||
$tabInsert['numRM']=@$matches[2];
|
||||
} else {
|
||||
$this->libErreur='Erreur Siren $sirenLu<>$siren !';
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
$this->libErreur='Erreur Siren absent dans la page !';
|
||||
return false;
|
||||
}
|
||||
|
||||
$actif=null;
|
||||
if (preg_match("/Renseignements.relatif(?:.*)entreprise(.*)<\/b>/Uis", $this->body, $matches)) {
|
||||
switch (trim(strtr($matches[1],array(chr(160)=>'')))) {
|
||||
case 'en activité': $actif=1; break;
|
||||
case 'radiée': $actif=0; break;
|
||||
default: print_r($matches);die(); break;
|
||||
}
|
||||
//die(EOL.'$actif='.$actif.EOL.print_r($matches));
|
||||
}
|
||||
$tabInsert['actif']=$actif;
|
||||
if ($actif===null) {
|
||||
//die("siren=$siren".EOL."sirenLu=$sirenLu".EOL.$this->body);
|
||||
$this->libErreur='Erreur Actif/Radié non trouvé !';
|
||||
return false;
|
||||
}
|
||||
if (preg_match('/<td background="inter\/pix3_turquoise\.gif" align="right"><span class="turquoise">dénomination<\/span><\/td>(?:.*)<td align="left" colspan="5">(.*)<\/td>/Uis', $this->body, $matches)) {
|
||||
$tabInsert['denomination']=$matches[1];
|
||||
}
|
||||
if (preg_match('/<td background="inter\/pix3_turquoise\.gif" align="right"><span class="turquoise">dénomination<\/span><\/td>(?:.*)<td align="left" colspan="5">(.*)<\/td>/Uis', $this->body, $matches))
|
||||
$tabInsert['denomination']=$matches[1];
|
||||
if (preg_match('/<td background="inter\/pix3_turquoise\.gif" align="right"><span class="turquoise">sigle<\/span><\/td>(?:.*)<td align="left">(.*)<\/td>/Uis', $this->body, $matches))
|
||||
$tabInsert['sigle']=$matches[1];
|
||||
if (preg_match('/<td background="inter\/pix3_turquoise\.gif" align="right"><span class="turquoise"> nom commercial<\/span><\/td>(?:.*)<td align="left">(.*)<\/td>/Uis', $this->body, $matches))
|
||||
$tabInsert['nomCommercial']=$matches[1];
|
||||
if (preg_match('/<td background="inter\/pix3_turquoise\.gif" align="right"><span class="turquoise">enseigne<\/span><\/td>(?:.*)<td align="left" colspan="4">(.*)<\/td>/Uis', $this->body, $matches))
|
||||
$tabInsert['enseigne']=$matches[1];
|
||||
if (preg_match('/<td background="inter\/pix3_turquoise\.gif" align="right"><span class="turquoise">forme juridique<\/span><\/td>(?:.*)<td align="left" colspan="5">(.*)<\/td>/Uis', $this->body, $matches))
|
||||
$tabInsert['fj']=$matches[1];
|
||||
if (preg_match('/<td background="inter\/pix3_turquoise\.gif" align="right"><span class="turquoise">effectif<\/span><\/td>(?:.*)<td align="left">(.*)<\/td>/Uis', $this->body, $matches))
|
||||
$tabInsert['effectif']=$matches[1];
|
||||
if (preg_match('/<td background="inter\/pix3_turquoise\.gif" align="right"><span class="turquoise">code APRM<\/span><\/td>(?:.*)<td align="left">(?:.*)<td align="left">(.*)<\/td>/Uis', $this->body, $matches))
|
||||
$tabInsert['aprm']=$matches[1];
|
||||
if (preg_match('/<td background="inter\/pix3_turquoise\.gif" align="right"><span class="turquoise">début d\'activité<\/span><\/td>(?:.*)<td align="left">(.*)<\/td>/Uis', $this->body, $matches))
|
||||
$tabInsert['debutActivite']=WDate::dateT('d/m/Y', 'Y-m-d', trim(strtr(html_entity_decode($matches[1]),chr(160),' ')));
|
||||
if (preg_match('/<td background="inter\/pix3_turquoise\.gif" align="right"><span class="turquoise"> activité\(s\) exercée\(s\) donnant lieu à immatriculation<\/span>(?:.*)<td colspan="5">(.*)<\/td>/Uis', $this->body, $matches))
|
||||
$tabInsert['activite']=trim($matches[1]);
|
||||
if (preg_match('/<td background="inter\/pix3_turquoise\.gif" align="right"><span class="turquoise">adresse de l\'entreprise<\/span><\/td>(?:.*)<td align="left" colspan="5">(.*)<\/td>/Uis', $this->body, $matches))
|
||||
$tabInsert['adresse']=trim($matches[1]);
|
||||
if (preg_match('/<td background="inter\/pix3_turquoise\.gif" align="right"><span class="turquoise">code postal<\/span><\/td>(?:.*)<td align="left">(.*)<\/td>/Uis', $this->body, $matches))
|
||||
$tabInsert['cp']=trim($matches[1]);
|
||||
if (preg_match('/<td background="inter\/pix3_turquoise\.gif" align="right"><span class="turquoise">ville<\/span><\/td>(?:.*)<td align="left">(.*)<\/td>/Uis', $this->body, $matches))
|
||||
$tabInsert['ville']=trim($matches[1]);
|
||||
if (preg_match('/<td background="inter\/pix3_turquoise\.gif" align="right"><span class="turquoise">cessation d\'activité<\/span><\/td>(?:.*)<td align="left">(.*)<\/td>/Uis', $this->body, $matches))
|
||||
$tabInsert['cessation']=WDate::dateT('d/m/Y', 'Y-m-d', trim(strtr(html_entity_decode($matches[1]),chr(160),' ')));
|
||||
if (preg_match('/<td background="inter\/pix3_turquoise\.gif" align="right"><span class="turquoise">radiation du RM<\/span><\/td>(?:.*)<td align="left">(.*)<\/td>/Uis', $this->body, $matches))
|
||||
$tabInsert['radiation']=WDate::dateT('d/m/Y', 'Y-m-d', trim(strtr(html_entity_decode($matches[1]),chr(160),' ')));
|
||||
$tabEtabs=array();
|
||||
if (preg_match('/<!--deb Etablissements secondaires-->(?:.*)<b class="gris">Aucune inscription complémentaire<\/b>(?:.*)<!--fin Etablissements secondaires-->/Uis', $this->body, $matches))
|
||||
$tabInsert['nbInscriptions']=0;
|
||||
elseif (preg_match('/<!--deb Etablissements secondaires-->(?:.*)<b class="gris">Inscription complémentaire<\/b>(.*)<!--fin Etablissements secondaires-->/Uis', $this->body, $matches)) {
|
||||
$tabInsert['nbInscriptions']=0;
|
||||
if (preg_match_all('/<tr>(?:.*)<td><img alt="" src="inter\/pixtrans\.gif" width="30" height="1"><\/td>(?:.*)<td nowrap>(?:.*)<!-- adresse -->(.*)<\/td>(?:.*)<td nowrap>(?:.*)<!-- code postal et ville -->(.*)<\/td>(?:.*)<td nowrap>(?:.*)<!-- enseigne -->(.*)<\/td>(?:.*)<td>(?:.*)<!-- debut activite -->(.*)<\/td>(?:.*)<td>(?:.*)<!-- fin activite -->(.*)<\/td>(?:.*)<\/tr>/Uis', $matches[1], $matches2)) {
|
||||
foreach ($matches2[1] as $i=>$adresse) {
|
||||
$tabEtabs[$i]['siren'] =$siren;
|
||||
$tabEtabs[$i]['num'] =$i;
|
||||
$tabEtabs[$i]['adresse'] =trim(strtr(html_entity_decode($adresse),chr(160),' '));
|
||||
$tabEtabs[$i]['cpVille'] =trim(strtr(html_entity_decode($matches2[2][$i]),chr(160),' '));
|
||||
$tabEtabs[$i]['enseigne']=trim(strtr(html_entity_decode($matches2[3][$i]),chr(160),' '));
|
||||
$tabEtabs[$i]['actDeb'] =WDate::dateT('d/m/Y', 'Y-m-d', trim(strtr(html_entity_decode($matches2[4][$i]),chr(160),' ')));
|
||||
$tabEtabs[$i]['actFin'] =WDate::dateT('d/m/Y', 'Y-m-d', trim(strtr(html_entity_decode($matches2[5][$i]),chr(160),' ')));
|
||||
$tabInsert['nbInscriptions']++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** Informations sur la Personne Physique **/
|
||||
if (preg_match('/<a class="turquoise" href="(rm\.php\?dom=Gerer&fonction=dirigeant&dept_re(.*))" onclick="window\.open\(this\.href/Uis', $this->body, $matches)) {
|
||||
$urlDir='http://www.cma-paris.fr/CMP/'.strtr(trim($matches[1]),array('&'=>'&'));
|
||||
//die($urlDir);
|
||||
randsleep(1,2);
|
||||
$page=getUrl($urlDir, $this->cookie, '', $this->referer, false, 'www.cma-paris.fr', false, '', '', 21);
|
||||
$this->body=$page['body'];
|
||||
$this->codeRetour=$page['code'];
|
||||
if ($this->codeRetour<>'200') {
|
||||
$this->libErreur='Erreur Artisanat 200d !';
|
||||
return false;
|
||||
}
|
||||
$this->referer=$url;
|
||||
|
||||
if (preg_match('/<td background="inter\/pix3_turquoise\.gif" align="right"><span class="turquoise">nom<\/span><\/td>(?:.*)<td align="left" nowrap>(.*)<\/td>/Uis', $this->body, $matches))
|
||||
$tabInsert['nom']=trim(strtr(html_entity_decode($matches[1]),chr(160),' '));
|
||||
if (preg_match('/<td background="inter\/pix3_turquoise\.gif" align="right"><span class="turquoise">prénom<\/span><\/td>(?:.*)<td align="left" nowrap>(.*)<\/td>/Uis', $this->body, $matches))
|
||||
$tabInsert['prenom']=trim(strtr(html_entity_decode($matches[1]),chr(160),' '));
|
||||
if (preg_match('/<td background="inter\/pix3_turquoise\.gif" align="right"><span class="turquoise">nom d\'usage<\/span><\/td>(?:.*)<td align="left" nowrap>(.*)<\/td>/Uis', $this->body, $matches))
|
||||
$tabInsert['nomUsage']=trim(strtr(html_entity_decode($matches[1]),chr(160),' '));
|
||||
if (preg_match('/<td background="inter\/pix3_turquoise\.gif" align="right"(?:.*)<span class="turquoise"> date de naissance<\/span><\/td>(?:.*)-->(?:.*)<td(?: +)align="left">(.*)<\/td>/Uis', $this->body, $matches))
|
||||
$tabInsert['dateNaiss']=WDate::dateT('d/m/Y', 'Y-m-d', trim(strtr(html_entity_decode($matches[1]),chr(160),' ')));
|
||||
// if (preg_match('/date de naissance(.*)<td background="inter\/pix3_turquoise\.gif" align="right"/Uis', $this->body, $matches))
|
||||
// die(print_r($matches));
|
||||
if (preg_match('/<td background="inter\/pix3_turquoise\.gif" align="right"><span class="turquoise"> lieu de naissance<\/span><\/td>(?:.*)<td align="left">(.*)<\/td>/Uis', $this->body, $matches))
|
||||
$tabInsert['lieuNaiss']=trim(strtr(html_entity_decode($matches[1]),chr(160),' '));
|
||||
if (preg_match('/<td background="inter\/pix3_turquoise\.gif" align="right"><span class="turquoise">nationalité<\/span><\/td>(?:.*)<td align="left">(.*)<\/td>/Uis', $this->body, $matches))
|
||||
$tabInsert['natio']=trim(strtr(html_entity_decode($matches[1]),chr(160),' '));
|
||||
if (preg_match('/<td background="inter\/pix3_turquoise\.gif" align="right"><span class="turquoise">qualité<\/span><\/td>(?:.*)<td align="left">(.*)<\/td>/Uis', $this->body, $matches))
|
||||
$tabInsert['qualite']=trim(strtr(html_entity_decode($matches[1]),chr(160),' '));
|
||||
if (preg_match('/<td background="inter\/pix3_turquoise\.gif" align="right" nowrap><span class="turquoise">qualification artisanale<\/span><\/td>(?:.*)<td align="left">(.*)<\/td>/Uis', $this->body, $matches))
|
||||
$tabInsert['qualif']=trim(strtr(html_entity_decode($matches[1]),chr(160),' '));
|
||||
if (preg_match('/<td background="inter\/pix3_turquoise\.gif" align="right"><span class="turquoise">date d\'obtention<\/span><\/td>(?:.*)<td align="left">(.*)<\/td>/Uis', $this->body, $matches))
|
||||
$tabInsert['datequalif']=WDate::dateT('d/m/Y', 'Y-m-d', trim(strtr(html_entity_decode($matches[1]),chr(160),' ')));
|
||||
|
||||
if (preg_match('/<td background="inter\/pix3_turquoise\.gif" align="right"><span class="turquoise">prise de fonction<\/span><\/td>(?:.*)<td align="left">(.*)<\/td>/Uis', $this->body, $matches))
|
||||
$tabInsert['dateFctDeb']=WDate::dateT('d/m/Y', 'Y-m-d', trim(strtr(html_entity_decode($matches[1]),chr(160),' ')));
|
||||
if (preg_match('/<td background="inter\/pix3_turquoise\.gif" align="right"><span class="turquoise">fin de fonction<\/span><\/td>(?:.*)<td align="left">(.*)<\/td>/Uis', $this->body, $matches))
|
||||
$tabInsert['dateFctFin']=WDate::dateT('d/m/Y', 'Y-m-d', trim(strtr(html_entity_decode($matches[1]),chr(160),' ')));
|
||||
|
||||
}
|
||||
|
||||
// Insertion en base de données
|
||||
$tabInsert['dateInsert']=date('Y-m-d H:i:s');
|
||||
$id=$this->iDb->insert('artisanat', $tabInsert, true);
|
||||
$tabInsert['id']=$id;
|
||||
foreach ($tabEtabs as $tabInsert2) {
|
||||
$tabInsert2['dateInsert']=$tabInsert['dateInsert'];
|
||||
$id2=$this->iDb->insert('artisanat_etab', $tabInsert2, true);
|
||||
}
|
||||
|
||||
$tabInsert['dateUpdate']=substr($tabInsert['dateInsert'],0,10);
|
||||
unset($tabInsert['dateInsert']);
|
||||
|
||||
/*
|
||||
$tabRet=array( 'id' => $id,// A calculer après insert
|
||||
'Pertinence' => 100,
|
||||
'Siret' => $siren.'00000',
|
||||
'Siege' => $siege,
|
||||
'Nom' => $nom,
|
||||
'Nom2' => $nomCom,
|
||||
'Sigle' => '',//prepareString($etab['Sigle']),
|
||||
'Enseigne' => $ens,
|
||||
'Adresse' => $adr,
|
||||
'Adresse2' => $adr2,//prepareString($etab['Adresse2']),
|
||||
'CP' => $cp,
|
||||
'Ville' => $ville,
|
||||
'Tel' => '',//$etab['Tel'],
|
||||
'Fax' => '',//$etab['Fax'],
|
||||
'FJ' => $cj,
|
||||
'FJLib' => $cjLib,
|
||||
'Siren' => $siren,
|
||||
'Nic' => '00000',
|
||||
'Actif' => 0,
|
||||
'NafEtab' => $naf,
|
||||
'NafEtabLib' => $nafLib,
|
||||
'NafEnt' => $naf,
|
||||
'NafEntLib' => $nafLib,
|
||||
'NumRC' => $numRC,
|
||||
'NumRC2' => $numRC2,
|
||||
'NumGreffe' => $greffe_num,
|
||||
'DateCreation' => $dateCre,
|
||||
'DateRadiation' => $dateRad,
|
||||
'DateCloture' => $dateCloture,
|
||||
'DateUpdate' => substr($dateInsert,0,10),
|
||||
);
|
||||
return $tabRet;
|
||||
*/
|
||||
}
|
||||
return $tabInsert;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
135
library/Metier/partenaires/classMBanques.php
Normal file
135
library/Metier/partenaires/classMBanques.php
Normal file
@ -0,0 +1,135 @@
|
||||
<?
|
||||
|
||||
require_once 'framework/common/dates.php';
|
||||
|
||||
class MBanques {
|
||||
|
||||
public $tabActivite=array( 0=>'établissements et services autorisés à effectuer des opérations de banque',
|
||||
1=>'banques',
|
||||
2=>'banques mutualistes ou coopératives',
|
||||
4=>'caisses de crédit municipal',
|
||||
5=>'sociétés financières 5', // la distinction entre les codes 5 et 6 ne concerne que les
|
||||
6=>'sociétés financières 6', // applications internes à la Banque de France
|
||||
7=>'institutions financières spécialisées',
|
||||
9=>'entreprises d\'investissement');
|
||||
|
||||
public $tabNatureGuichet=array( 1=>'Guichet permanent de plein exercice domiciliataire (ouvert au public)',
|
||||
2=>'Identifiant de domiciliation (adresse active 5 jours par semaine)',
|
||||
3=>'Guichet permanent non domiciliataire (ouvert au public)',
|
||||
4=>'Libre Prestation de services (LPS)',
|
||||
'A'=>'Guichet fictif',
|
||||
'P'=>'Guichet fictif');
|
||||
|
||||
public $tabOrgane=array( 0=>'Association française des établissements de crédit et des entreprises d\'investissement',
|
||||
11=>'Association française des sociétés financières',
|
||||
12=>'Groupement des institutions financières spécialisées',
|
||||
13=>'Conférence permanente des caisses de crédit municipal',
|
||||
14=>'Association française des entreprises d\'investissement',
|
||||
15=>'Association française des entreprises d\'investissement-courtiers',
|
||||
16=>'Association française des fonds et sociétés d\'investissements et de gestion d\'actifs financiers',
|
||||
17=>'Association française des intermédiaires transmetteurs d\'ordres ',
|
||||
18=>'Fédération bancaire française',
|
||||
19=>'Ass Franc Marchés Financiers',
|
||||
20=>'Caisse nationale de crédit agricole',
|
||||
21=>'Chambre syndicale des banques populaires',
|
||||
22=>'Confédération nationale du crédit mutuel',
|
||||
23=>'Caisse centrale de crédit coopératif',
|
||||
25=>'Caisse nationale des caisses d\'épargne et de prévoyance',
|
||||
27=>'Chambre syndicale des SACI',
|
||||
28=>'Double affiliation CNCE-BFBP',
|
||||
29=>'Crédit Immobilier France Développement',
|
||||
30=>'BPCE',
|
||||
98=>'non concerné',
|
||||
99=>'en instance d\'adhésion');
|
||||
private $iDb;
|
||||
|
||||
function __construct() {
|
||||
$this->iDb=new WDB('insee');
|
||||
}
|
||||
|
||||
function __destruct() {}
|
||||
|
||||
function getInfoBanque($codeBanque) {
|
||||
$ret=$this->iDb->select( 'BDF_Etabs',
|
||||
'bdfFibCodeEtab, bdfFibCodeSituation, bdfFibDenom40, bdfFibDenom10, bdfFibCodeActivite, bdfFibCodeOrganeRepr, bdfFibDateAgrement, bdfFibDateRetraitAgr, bdfFibDateFinDiffus, bdfFibAdresse1, bdfFibAdresse2, bdfFibAdresse3, CP, Ville, bdfFibCodeEtabAbsorb, bdfFibOptionIdInvar, bdfFibDateOptIdInvar',
|
||||
"bdfFibCodeEtab=$codeBanque",false, MYSQL_ASSOC);
|
||||
//echo mysql_error();
|
||||
$tabRet=$ret[0];
|
||||
return $tabRet;
|
||||
}
|
||||
|
||||
function getInfoGuichet($codeBanque, $codeGuichet) {
|
||||
$tabBanque=$this->getInfoBanque($codeBanque);
|
||||
$tabTel=$this->getTelGuichet($codeBanque,$codeGuichet);
|
||||
$ret=$this->iDb->select( 'BDF_Guichets',
|
||||
'bdfFibCodeEtab, bdfFibCodeGuichet, bdfFibCodeSituation AS guichetCodeSituation, bdfFibDenom40 AS guichetDenom40, bdfFibDenom20 AS guichetDenom20, bdfFibCodeEtabCible, bdfFibCodeGuichetRepr, bdfFibCodeGeoInsee, bdfFibCodeLocalite1, bdfFibCodeLocalite2, bdfFibComptoirBDF, bdfFibAdresse1 AS guichetAdresse1, bdfFibAdresse2 AS guichetAdresse2, bdfFibAdresse3 AS guichetAdresse3, CP AS guichetCP, Ville AS guichetVille, bdfFibAdresseSWIFT, bdfFibDateOuverture, bdfFibDateFermeture, bdfFibDateFinDiffus, bdfFibCodeRoutage, bdfFibLibelleRIB, bdfFibNatureGuichet, bdfFibCodeAchOperBDF, bdfFibNomComptoirBDF',
|
||||
"bdfFibCodeEtab=$codeBanque AND bdfFibCodeGuichet=$codeGuichet",false, MYSQL_ASSOC);
|
||||
//echo mysql_error();
|
||||
if (isset($ret[0]))
|
||||
$tabRet=@$ret[0];
|
||||
else
|
||||
$tabRet=array();
|
||||
|
||||
return array_merge($tabRet, $tabBanque, $tabTel);
|
||||
}
|
||||
|
||||
function getTelGuichet($codeBanque, $codeGuichet) {
|
||||
$ret=$this->iDb->select( 'Mandel_banques',
|
||||
'Tel, Fax',
|
||||
"CodeB=$codeBanque AND CodeG=$codeGuichet",false, MYSQL_ASSOC);
|
||||
if (isset($ret[0]))
|
||||
return $ret[0];
|
||||
else
|
||||
return array();
|
||||
}
|
||||
|
||||
function getListeBanques($siren) {
|
||||
$tabRet=array();
|
||||
if ($siren*1>1000) {
|
||||
$res=$this->iDb->select('banques', 'codeBanque, codeGuichet, libBanqueGuichet, precis, dateSource*1 AS dateSource', "siren=$siren", false, MYSQL_ASSOC);
|
||||
$tmp=$this->iDb->select('fedRib', "codeBanque, codeGuichet, CONCAT(libBanque,' ',libGuichet) AS libBanqueGuichet, 0 AS precis, IF (dateInfo='0000-00-00', dateDispo*1, dateInfo*1) AS dateSource", "siren=$siren", false, MYSQL_ASSOC);
|
||||
$res=array_merge($res, $tmp);
|
||||
foreach ($res as $tabBanque) {
|
||||
$dateSource=$tabBanque['dateSource'];
|
||||
$codBanque=$tabBanque['codeBanque'];
|
||||
$codGuichet=$tabBanque['codeGuichet'];
|
||||
$libBanque=trim($tabBanque['libBanqueGuichet']);
|
||||
$found=false;
|
||||
$adrBanque1=$adrBanque2=$adrBanqueCP=$adrBanqueVille='';
|
||||
|
||||
if ($codBanque>0 && $codGuichet>0 && $dateSource>(date('Y')-4)*10000+101 && $dateSource<date('Ymd')) {
|
||||
$tmp=$this->iDb->select('insee.BDF_Etabs b, insee.BDF_Guichets g', 'g.bdfFibCodeEtab AS banque, g.bdfFibCodeGuichet AS guichet, b.bdfFibDenom40 AS nomBanque, b.bdfFibDenom10 AS sigleBanque, g.bdfFibDenom20 AS nomGuichet, g.bdfFibAdresse1 AS adresse1, g.bdfFibAdresse2 AS adresse2, g.bdfFibAdresse3 AS adresse3, g.CP, g.Ville', "g.bdfFibCodeEtab=$codBanque AND g.bdfFibCodeGuichet=$codGuichet AND b.bdfFibCodeEtab=g.bdfFibCodeEtab", false, MYSQL_ASSOC);
|
||||
if (isset($tmp[0])) {
|
||||
$libBanque=trim($tmp[0]['nomBanque'].' '.$tmp[0]['nomGuichet']);
|
||||
$adrBanque1=$tmp[0]['adresse1'];
|
||||
$adrBanque2=trim($tmp[0]['adresse2'].' '.$tmp[0]['adresse3']);
|
||||
$adrBanqueCP=$tmp[0]['CP'];
|
||||
$adrBanqueVille=$tmp[0]['Ville'];
|
||||
$found=true;
|
||||
};
|
||||
}
|
||||
if (!$found && $codBanque>0 && $dateSource>(date('Y')-4)*10000+101 && $dateSource<date('Ymd')) {
|
||||
$tmp=$this->iDb->select('insee.BDF_Etabs', "bdfFibCodeEtab AS banque, '' AS guichet, bdfFibDenom40 AS nomBanque, '' AS nomGuichet, '' AS adresse1, '' AS adresse2, '' AS adresse3, '' AS CP, '' AS Ville", "bdfFibCodeEtab=$codBanque", false, MYSQL_ASSOC);
|
||||
if (isset($tmp[0])) {
|
||||
$libBanque=trim($tmp[0]['nomBanque'].' '.$tmp[0]['nomGuichet']);
|
||||
$adrBanque1=$tmp[0]['adresse1'];
|
||||
$adrBanque2=trim($tmp[0]['adresse2'].' '.$tmp[0]['adresse3']);
|
||||
$adrBanqueCP=$tmp[0]['CP'];
|
||||
$adrBanqueVille=$tmp[0]['Ville'];
|
||||
} else continue;
|
||||
} else continue;
|
||||
|
||||
$tabRet[]=array('codeBanque' => $codBanque,
|
||||
'codeGuichet' => $codGuichet,
|
||||
'libBanque' => $libBanque,
|
||||
'adresse1' => $adrBanque1,
|
||||
'adresse2' => $adrBanque2,
|
||||
'cp' => $adrBanqueCP,
|
||||
'ville' => $adrBanqueVille,
|
||||
);
|
||||
}
|
||||
}
|
||||
return $tabRet;
|
||||
}
|
||||
}
|
||||
?>
|
965
library/Metier/partenaires/classMBilans.php
Normal file
965
library/Metier/partenaires/classMBilans.php
Normal file
@ -0,0 +1,965 @@
|
||||
<?php
|
||||
require_once 'framework/common/curl.php';
|
||||
require_once 'framework/common/dates.php';
|
||||
//require_once 'Metier/partenaires/classMEuridile.php';
|
||||
//require_once 'Metier/partenaires/classMRncsFlux.php';
|
||||
require_once 'Metier/partenaires/classMGreffes.php';
|
||||
|
||||
define ('ECART_CTRL_MAX', 5); // Ecart maximal acceptable dans la saisie +/-5 entre les calculs et la saisie !
|
||||
|
||||
global $tabCtrl;
|
||||
$tabCtrl=array(
|
||||
/** Bilans Réel Normal **/
|
||||
'S'=>array(
|
||||
// Actif Simplifié
|
||||
'010-012=013'=>'Fonds commercial (Brut,Amor/Prov et Net incohérents)',
|
||||
'014-016=017'=>'Immos incorpo. autres (Brut,Amor/Prov et Net incohérents)',
|
||||
'028-030=031'=>'Immos corpo. (Brut,Amor/Prov et Net incohérents)',
|
||||
'040-042=043'=>'Immos finan. (Brut,Amor/Prov et Net incohérents)',
|
||||
'044-048=049'=>'Total (I) Actif Immos (Brut,Amor/Prov et Net incohérents)',
|
||||
'010+014+028+040=044'=>'Total Actif immobilisé Brut',
|
||||
'012+016+030+042=048'=>'Total Actif immobilisé Amor/Prov',
|
||||
'013+017+031+043=049'=>'Total Actif immobilisé Net',
|
||||
'050-052=053'=>'Stocks MP (Brut,Amor/Prov et Net incohérents)',
|
||||
'060-062=063'=>'Stocks Marchandises (Brut,Amor/Prov et Net incohérents)',
|
||||
'064-066=067'=>'Avances et acomptes/cmds (Brut,Amor/Prov et Net incohérents)',
|
||||
'068-070=071'=>'Créances clients et CR (Brut,Amor/Prov et Net incohérents)',
|
||||
'072-074=075'=>'Autres créances (Brut,Amor/Prov et Net incohérents)',
|
||||
'080-082=083'=>'VMP (Brut,Amor/Prov et Net incohérents)',
|
||||
'084-086=087'=>'Disponibilités (Brut,Amor/Prov et Net incohérents)',
|
||||
'088-090=091'=>' (Brut,Amor/Prov et Net incohérents)',
|
||||
'092-094=095'=>'Ch. constatées d\'avance (Brut,Amor/Prov et Net incohérents)',
|
||||
'096-098=099'=>'Total (II) Actif Circulant (Brut,Amor/Prov et Net incohérents)',
|
||||
'110-112=113'=>'Total ACTIF (Brut,Amor/Prov et Net incohérents)',
|
||||
'050+060+064+068+072+080+084+088+092=096'=>'Total Actif circulant Brut',
|
||||
'052+062+066+070+074+082+086+090+094=098'=>'Total Actif circulant Amor/Prov',
|
||||
'053+063+067+071+075+083+087+091+092=099'=>'Total Actif circulant Net',
|
||||
'044+096=110'=>'Total ACTIF Brut',
|
||||
'048+098=112'=>'Total ACTIF Amor/Prov',
|
||||
'049+099=113'=>'Total ACTIF Net',
|
||||
// Passif Simplifié
|
||||
'120+124+126+130+132+134+136+140=142'=>'Total Capitaux Propres',
|
||||
'156+164+166+172+174=176'=>'Total Dettes',
|
||||
'142+154+176=180'=>'Total Passif',
|
||||
'113=180'=>'Actif=Passif',
|
||||
// CDR Simplifié
|
||||
'210+214+218+222+224+226+230=232'=>'Total des produits d\'exploitation',
|
||||
'234+236+238+240+242+244+250+252+254+256+262=264'=>'Total des charges d\'exploitation',
|
||||
'210+214+218+222+224+226+230=232'=>'Total des produits d\'exploitation',
|
||||
'232-264=270'=>'Résultat d\'exploitation',
|
||||
'232+280+290-264-294-300-306=310'=>'Résultat d\'exploitation',
|
||||
),
|
||||
'N'=>array(
|
||||
// Actif immobilisé
|
||||
'AA=AA2'=>'Capital souscrit non appelé',
|
||||
'AB-AC=AC1'=>'Frais d\'étab. (Brut,Amor/Prov et Net incohérents)',
|
||||
'AD-AE=AE1'=>'Frais de R&D (Brut,Amor/Prov et Net incohérents)',
|
||||
'AF-AG=AG1'=>'Brevets (Brut,Amor/Prov et Net incohérents)',
|
||||
'AH-AI=AI1'=>'Fonds commercial (Brut,Amor/Prov et Net incohérents)',
|
||||
'AJ-AK=AK1'=>'Autres immo inc. (Brut,Amor/Prov et Net incohérents)',
|
||||
'AL-AM=AM1'=>'Acomptes immo inc. (Brut,Amor/Prov et Net incohérents)',
|
||||
'AN-AO=AO1'=>'Terrains (Brut,Amor/Prov et Net incohérents)',
|
||||
'AP-AQ=AQ1'=>'Constructions (Brut,Amor/Prov et Net incohérents)',
|
||||
'AR-AS=AS1'=>'Installations (Brut,Amor/Prov et Net incohérents)',
|
||||
'AT-AU=AU1'=>'Autres immo corp. (Brut,Amor/Prov et Net incohérents)',
|
||||
'AV-AW=AW1'=>'Immos en cours (Brut,Amor/Prov et Net incohérents)',
|
||||
'AX-AY=AY1'=>'Acomptes immo corp. (Brut,Amor/Prov et Net incohérents)',
|
||||
'CS-CT=CT1'=>'Immo Fi participations/équiv. (Brut,Amor/Prov et Net incohérents)',
|
||||
'CU-CV=CV1'=>'Autres participations (Brut,Amor/Prov et Net incohérents)',
|
||||
'BB-BC=BC1'=>'Créances rattachées à des particip. (Brut,Amor/Prov et Net incohérents)',
|
||||
'BD-BE=BE1'=>'Autres titres immo. (Brut,Amor/Prov et Net incohérents)',
|
||||
'BF-BG=BG1'=>'Prêts (Brut,Amor/Prov et Net incohérents)',
|
||||
'BH-BI=BI1'=>'Autres Immo Financières (Brut,Amor/Prov et Net incohérents)',
|
||||
'BJ-BK=BK1'=>'Total de l\'Actif Immobilisé (Brut,Amor/Prov et Net incohérents)',
|
||||
'AB+AD+AF+AH+AJ+AL+AN+AP+AR+AT+AV+AX+CS+CU+BB+BD+BF+BH=BJ'=>'Total des Immobilisations (Brut)',
|
||||
'AC+AE+AG+AI+AK+AM+AO+AQ+AS+AU+AW+AY+CT+CV+BC+BE+BG+BI=BK'=>'Total des Immobilisations (Amor.)',
|
||||
'AC1+AE1+AG1+AI1+AK1+AM1+AO1+AQ1+AS1+AU1+AW1+AY1+CT1+CV1+BC1+BE1+BG1+BI1=BK1'=>'Total des Immobilisations (Net)',
|
||||
// Actif circulant
|
||||
'BL-BM=BM1'=>'Stocks de MP (Brut,Amor/Prov et Net incohérents)',
|
||||
'BN-BO=BO1'=>'Stocks en cours de prod. biens (Brut,Amor/Prov et Net incohérents)',
|
||||
'BP-BQ=BQ1'=>'Stocks en cours de prod. services (Brut,Amor/Prov et Net incohérents)',
|
||||
'BR-BS=BS1'=>'Stocks produits finis (Brut,Amor/Prov et Net incohérents)',
|
||||
'BT-BU=BU1'=>'Stocks de marchandises (Brut,Amor/Prov et Net incohérents)',
|
||||
'BV-BW=BW1'=>'Avances et acomptes/cmds (Brut,Amor/Prov et Net incohérents)',
|
||||
'BX-BY=BY1'=>'Créances clients (Brut,Amor/Prov et Net incohérents)',
|
||||
'BZ-CA=CA1'=>'Autres créances (Brut,Amor/Prov et Net incohérents)',
|
||||
'CB-CC=CC1'=>'Capital souscrit appelé non versé (Brut,Amor/Prov et Net incohérents)',
|
||||
'CD-CE=CE1'=>'VMP (Brut,Amor/Prov et Net incohérents)',
|
||||
'CF-CG=CG1'=>'Disponibilités (Brut,Amor/Prov et Net incohérents)',
|
||||
'CH-CI=CI1'=>'Charges Const. d\'avance(Brut,Amor/Prov et Net incohérents)',
|
||||
'CJ-CK=CK1'=>'Total de l\'Actif Circulant (Brut,Amor/Prov et Net incohérents)',
|
||||
'BL+BN+BP+BR+BT+BV+BX+BZ+CB+CD+CF+CH=CJ'=>'Total l\'Actif Circulant (Brut)',
|
||||
'BM+BO+BQ+BS+BU+BW+BY+CA+CC+CE+CG+CI=CK'=>'Total l\'Actif Circulant (Amor.)',
|
||||
'BM1+BO1+BQ1+BS1+BU1+BW1+BY1+CA1+CC1+CE1+CG1+CI1=CK1'=>'Total l\'Actif Circulant (Net)',
|
||||
'CL=CL2'=>'Charges / plus. ex. (Brut<>Net)',
|
||||
'CM=CM2'=>'Primes de Rbt obligations (Brut<>Net)',
|
||||
'CN=CN2'=>'Ecarts de conversion d\'actif (Brut<>Net)',
|
||||
'CO-1A=1A1'=>'Total Actif (Brut,Amor/Prov et Net incohérents)',
|
||||
'AA+BJ+CJ+CL+CM+CN=CO'=>'Total Actif Brut',
|
||||
'BK+CK=1A'=>'Total Actif (Amor.)',
|
||||
'AA2+BK1+CK1+CL2+CM2+CN2=1A1'=>'Total Actif Net',
|
||||
// PASSIF
|
||||
'DA+DB+DC+DD+DE+DF+DG+DH+DI+DJ+DK=DL'=>'Passif : s/total I (Capitaux Propres)',
|
||||
'DM+DN=DO'=>'Passif : s/total II (Autres fonds propres)',
|
||||
'DP+DQ=DR'=>'Passif : s/total III (Provisions)',
|
||||
'DS+DT+DU+DV+DW+DX+DY+DZ+EA+EB=EC'=>'Passif : s/total IV (Dettes+Cpt régul. PCA)',
|
||||
'DL+DO+DR+EC+ED=EE'=>'Total Passif',
|
||||
'EE=1A1'=>'Total Actif=Total Passif',
|
||||
// CDR
|
||||
'FA+FB=FC'=>'Total Ventes de marchandises',
|
||||
'FD+FE=FF'=>'Total Production vendue de biens',
|
||||
'FG+FH=FI'=>'Total Production vendue de services',
|
||||
'FJ+FK=FL'=>'Total Chiffe d\'Affaires France+Export',
|
||||
'FA+FD+FG=FJ'=>'Total C.A. France',
|
||||
'FB+FE+FH=FK'=>'Total C.A. Export',
|
||||
'FC+FF+FI=FL'=>'Total C.A. Total (Vtes+Biens+Services)',
|
||||
'FL+FM+FN+FO+FP+FQ=FR'=>'Total I : Produits d\'Exploitation',
|
||||
'FS+FT+FU+FV+FW+FX+FY+FZ+GA+GB+GC+GD+GE=GF'=>'Total II :Charges d\'Exploitation',
|
||||
'FR-GF=GG'=>'1 - Résultat d\'Exploitation',
|
||||
'GJ+GK+GL+GM+GN+GO=GP'=>'Total V : Produits Financiers',
|
||||
'GQ+GR+GS+GT=GU'=>'Total VI : Charges Financières',
|
||||
'GP-GU=GV'=>'2 - Résultat Financier',
|
||||
'GG+GH-GI+GV=GW'=>'3 - R.C.A.I.',
|
||||
'HA+HB+HC=HD'=>'Total VII : Produits Exceptionnels',
|
||||
'HE+HF+HG=HH'=>'Total VIII : Charges Exceptionnels',
|
||||
'HD-HH=HI'=>'4 - Résultat Exceptionnel',
|
||||
'FR+GH+GP+HD=HL'=>'CDR : Total des Produits',
|
||||
'GF+GI+GU+HH+HJ+HK=HM'=>'CDR : Total des Charges',
|
||||
'HL-HM=HN'=>'5 - Résultat de l\'exercice',
|
||||
// Immobilisations
|
||||
/* 'LY+MB+ME+MH+MK+MN+MQ+MT+MW+NA+NE=NH'=>'2054: Immos Total III Brut fin ex. incohérent',
|
||||
'0V+0Y+2C+2F=NK'=>'2054: Immos Total IV Brut fin ex. incohérent',
|
||||
'LU+LW+NH+NK=0L'=>'2054: Immos Total Général Brut fin ex. incohérent',
|
||||
'0L=BJ'=>'Immos Total Général Brut du 2054 <> BJ du 2050',*/
|
||||
),
|
||||
);
|
||||
|
||||
$tabLibCodeSaisie=array(
|
||||
'_00'=>'Bilan saisi sans anomalie',
|
||||
'_01'=>'Bilan saisi avec des incohérences comptables à la source du document (issues du remettant)',
|
||||
'_02'=>'Bilan avec Actif, Passif ou Compte de Résultat nul',
|
||||
'_03'=>'Bilan incomplet (des pages manquent)',
|
||||
'_04'=>'Bilan complet non détaillé (seuls les totaux et sous totaux sont renseignés)',
|
||||
'_05'=>'Bilan reçu en double exemplaire',
|
||||
'_06'=>'Bilan intermédiaire - Situation provisoire',
|
||||
'_07'=>'Bilan illisible',
|
||||
'_A7'=>'Bilan illisible, présentant un cadre gris très foncés (dans lesquels sont inscrits en général les totaux)',
|
||||
'_B7'=>'Bilan manuscrits',
|
||||
'_C7'=>'Bilan illisible, présentant des caractères trop gras',
|
||||
'_D7'=>'Bilan scanné en biais ou qui présentent des pages rognées',
|
||||
'_E7'=>'Bilan numérisés trop clairement (comme une imprimante dont la cartouche est presque vide)',
|
||||
'_F7'=>'Bilan illisible',
|
||||
'_08'=>'Bilan consolidé',
|
||||
'_09'=>'Déclaration d\'impôts',
|
||||
'_10'=>'Document autre que bilan',
|
||||
'_11'=>'Bilan de clôture de liquidation',
|
||||
'_12'=>'Bilan de Société financière',
|
||||
'_13'=>'Bilan de Société d\'assurance',
|
||||
'_14'=>'Bilan de Société immobilière',
|
||||
'_15'=>'Bilan de Société étrangère',
|
||||
);
|
||||
|
||||
class MBilans {
|
||||
|
||||
public $siren;
|
||||
public $dernierExerciceDepose=0;
|
||||
public $dernierExerciceDeposeLe=0;
|
||||
// public $rncs;
|
||||
public $igreffe;
|
||||
|
||||
function __construct($siren) {
|
||||
$this->siren=$siren;
|
||||
//$this->rncs=new MRncsFlux();
|
||||
$this->igreffe=new MGreffes();
|
||||
}
|
||||
|
||||
function __destruct() {}
|
||||
|
||||
/** Liste les bilans disponibles */
|
||||
function listeBilans($accesPartenaire=false, $nbMaxBilans=0) {
|
||||
$iDb2=new WDB();
|
||||
if ($nbMaxBilans>0) $limit="LIMIT 0, $nbMaxBilans";
|
||||
else $limit='';
|
||||
$ret=$iDb2->select( 'bilans',
|
||||
'typeBilan, dateProvPartenaire, dateExercice, dateExercicePre, dureeExercice, dureeExercicePre, monnaieOrigine, dateInsert, partenaire',
|
||||
"siren='$this->siren' ORDER BY dateExercice DESC $limit",false, MYSQL_ASSOC);
|
||||
//@sendMail('production@scores-decisions.com', 'ylenaour@scores-decisions.com', "listeBilans sur $this->siren en base", print_r($ret, true));
|
||||
$tabRet=array();
|
||||
$iDb=new WDB('jo');
|
||||
$ret2=$iDb->select( 'bodacc_detail',
|
||||
'Bodacc_Date_Parution, dateEffet, typeEven',
|
||||
"siren='$this->siren' AND Rubrique='comptes' ORDER BY dateEffet DESC",false, MYSQL_ASSOC);
|
||||
$dateDerDepot=WDate::dateT('Y-m-d','Ymd',@$ret2[0]['dateEffet'])*1;
|
||||
$dateDerExercice=$ret[0]['dateExercice']*1;
|
||||
if ($dateDerDepot<>0) {
|
||||
$this->dernierExerciceDepose = WDate::dateT('Y-m-d','d/m/Y',@$ret2[0]['dateEffet']);
|
||||
$this->dernierExerciceDeposeLe = WDate::dateT('Y-m-d','d/m/Y',@$ret2[0]['Bodacc_Date_Parution']);
|
||||
}
|
||||
if ($accesPartenaire)
|
||||
$tabRet=$tabRet2=$this->igreffe->getListeBilans($this->siren);
|
||||
else
|
||||
$tabRet=$tabRet2=array();
|
||||
|
||||
if ($ENV=='PRD') { // A supprimer le jour ou on vire l'ancien serveur car curl plantait sur Infogreffe !!!
|
||||
$tabRefXml=$tabRefPdf=array();
|
||||
// Tableau des références de bilans XML Infogreffe
|
||||
foreach ($tabRet as $idxTmp=>$bilanTmp) {
|
||||
if ((substr($idxTmp,-4)*1)>(date(Y)-4))
|
||||
$tabRefXml[]=$bilanTmp['ref'];
|
||||
}
|
||||
|
||||
$tabImg=$this->igreffe->getBilansImages($this->siren);
|
||||
// Tableau des références de bilans PDF Infogreffe
|
||||
foreach ($tabImg as $idxTmp=>$bilanTmp) {
|
||||
if ($bilanTmp['annee']>(date(Y)-4))
|
||||
$tabRefPdf[]=$bilanTmp['ref'];
|
||||
}
|
||||
|
||||
$tabDiff=array_diff($tabRefPdf, $tabRefXml);
|
||||
if (count($tabDiff)>0) {
|
||||
$strMillesimes='';
|
||||
foreach ($tabDiff as $value) {
|
||||
$tabTmp=explode('-',$value);
|
||||
$strMillesimes.=$tabTmp[0].', ';
|
||||
}
|
||||
@sendMail('production@scores-decisions.com', 'ylenaour@scores-decisions.com', "Bilans non saisit sur $this->siren pour $strMillesimes",
|
||||
'Différence :'.EOL.print_r($tabDiff,true) .EOL.
|
||||
'Liste XML:'.EOL.print_r($tabRefXml, true) .EOL.
|
||||
'Liste PDF:'.EOL.print_r($tabRefPdf,true) .EOL
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$tabTri=array();
|
||||
foreach ($tabRet as $millesime=>$bil) {
|
||||
$typeBilan=substr($millesime,0,1);
|
||||
$dateExercice=WDate::dateT('d/m/Y','Ymd',substr($millesime,1,10));
|
||||
$tabTri[''.$dateExercice.'-'.$typeBilan]=$millesime;
|
||||
}
|
||||
//@sendMail('production@scores-decisions.com', 'ylenaour@scores-decisions.com', "listeBilans sur $this->siren après accès partenaire", print_r($tabRet2, true));
|
||||
|
||||
foreach ($ret as $i=>$bil) {
|
||||
$millesime=WDate::dateT('Ymd','d/m/Y',$bil['dateExercice']);
|
||||
$tabRet[''.$bil['typeBilan'].$millesime]=array(
|
||||
'dateProvPartenaire'=>$bil['dateProvPartenaire'],
|
||||
'dateInsert' =>strtr($bil['dateInsert'],
|
||||
array(' '=>'',':'=>'','-'=>'')),
|
||||
'typeBilan' =>$bil['typeBilan'], // NEW
|
||||
'dureeExercice' =>$bil['dureeExercice'],// NEW
|
||||
'dateExercice' =>$bil['dateExercice'],
|
||||
'millesime' =>substr($bil['dateExercice'],0,4),
|
||||
'dateExercicePre' =>$bil['dateExercicePre'],
|
||||
'dureeExercicePre' =>$bil['dureeExercicePre'],
|
||||
'monnaie' =>$bil['monnaieOrigine'],
|
||||
'source' =>$bil['partenaire'],
|
||||
);
|
||||
$tabTri[''.$bil['dateExercice'].'-'.$bil['typeBilan']]=$bil['typeBilan'].$millesime;
|
||||
}
|
||||
krsort($tabTri);
|
||||
//@sendMail('production@scores-decisions.com', 'ylenaour@scores-decisions.com', "listeBilans sur $this->siren avant le tri", print_r($tabTri, true));
|
||||
$exercicePre=$typePre=$tmpPre=false;
|
||||
$refPre='';
|
||||
$strInfos='';
|
||||
foreach ($tabTri as $tmp=>$typeMillesime) {
|
||||
$exercice=substr($tmp,0,8);
|
||||
$type=substr($tmp,9,1);
|
||||
$ref=$tabRet[''.$typeMillesime]['ref'];
|
||||
if ($exercice==$exercicePre && $type=='N' && $typePre=='S' && $refPre=='') {
|
||||
// Suppression du bilan RN de la liste si Réel Normal et Réel Simplifiés présents en base
|
||||
unset($tabTri[$tmp]);
|
||||
$strInfos.="Suppression de '$tmp'".EOL;
|
||||
}
|
||||
elseif ($exercice==$exercicePre && $type=='N' && $typePre=='S' && $refPre<>'') {
|
||||
// Suppression du bilan RS de la liste si Réel Normal Présent en base et réel simplifié non encore en base
|
||||
if ($tmpPre<>false) {
|
||||
unset($tabTri[$tmpPre]);
|
||||
$strInfos.="Suppression de '$tmpPre'".EOL;
|
||||
}
|
||||
}
|
||||
$exercicePre=$exercice;
|
||||
$typePre=$type;
|
||||
$refPre=@trim($ref);
|
||||
$tmpPre=$tmp;
|
||||
}
|
||||
krsort($tabTri);
|
||||
|
||||
//@sendMail('production@scores-decisions.com', 'ylenaour@scores-decisions.com', "listeBilans sur $this->siren après le tri", print_r($tabTri, true).EOL.$strInfos.EOL);
|
||||
$tabRet3=array();
|
||||
foreach ($tabTri as $tmp=>$typeMillesime)
|
||||
$tabRet3[''.$typeMillesime]=$tabRet[''.$typeMillesime];
|
||||
|
||||
//@sendMail('production@scores-decisions.com', 'ylenaour@scores-decisions.com', "listeBilans sur $this->siren après le tri / retour", print_r($tabRet3, true));
|
||||
|
||||
return $tabRet3;
|
||||
}
|
||||
|
||||
function getBilan($millesime='', $typeBilan='N', $refPart=0, $accesPartenaire=false) {
|
||||
$millesimeDB=WDate::dateT('d/m/Y','Ymd',$millesime);
|
||||
$iDb2=new WDB();
|
||||
if ($accesPartenaire)
|
||||
// On ne veut pas de bilans "Téléchargés" directement sur Internet
|
||||
$strSansBilansWeb=' AND partenaire<>7 ';
|
||||
else
|
||||
$strSansBilansWeb='';
|
||||
$ret=$iDb2->select('bilans', 'dateProvPartenaire, dateExercice, dateExercicePre, dureeExercice, dureeExercicePre, monnaie, typeBilan, monnaieOrigine, unite, postes, partenaire', "siren='$this->siren' AND typeBilan='$typeBilan' AND dateExercice='$millesimeDB' $strSansBilansWeb", true, MYSQL_ASSOC);
|
||||
$bilan=$ret[0];
|
||||
if (count($ret)==0 && $accesPartenaire) {
|
||||
if ($refPart=='' || $refPart==0) {
|
||||
$tabTmp=$this->igreffe->getListeBilans($this->siren);
|
||||
foreach ($tabTmp as $idx=>$bil) {
|
||||
$typeBil=substr($idx,0,1);
|
||||
$millBil=substr($idx,1,10);
|
||||
if ($typeBil==$typeBilan && $millBil==$millesime) {
|
||||
$refPart=$bil['ref'];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
// $rncs=new MEuridile($this->siren);
|
||||
// $tabBilan=$rncs->getBilan($refPart);
|
||||
$tabBilan=$this->igreffe->getBilan($this->siren, $refPart);
|
||||
//getBilan(479974115,'2008_sociaux-20081231-7803-04-B-03876-0013849'));
|
||||
|
||||
// print_r($tabBilan);
|
||||
// die ("On veut le bilan $millesime $typeBilan $refPart");
|
||||
$fp=fopen(LOG_PATH.'/bilans.log', 'a');
|
||||
fwrite($fp, "Bilan pour ".$this->siren." :\n".print_r($tabBilan,true)."\n\n\n");
|
||||
fclose($fp);
|
||||
if ($tabBilan) {
|
||||
$strPostes='';
|
||||
foreach ($tabBilan['POSTES'] as $poste=>$valeur)
|
||||
$strPostes.="$poste=$valeur;";
|
||||
$tabInsert=array( 'siren' =>$this->siren,
|
||||
'dateProvPartenaire'=>$tabBilan['DATE_FRAICHE_BILAN'],
|
||||
'dateExercice' =>WDate::dateT('d/m/Y','Ymd',$tabBilan['DATE_CLOTURE']),
|
||||
'dateExercicePre' =>WDate::dateT('d/m/Y','Ymd',$tabBilan['DATE_CLOTURE_PRE']),
|
||||
'dureeExercice' =>$tabBilan['DUREE_MOIS'],
|
||||
'dureeExercicePre' =>$tabBilan['DUREE_MOIS_PRE'],
|
||||
'monnaie' =>$tabBilan['MONNAIE'],
|
||||
'typeBilan' =>$tabBilan['TYPE_BILAN'],
|
||||
'monnaieOrigine' =>$tabBilan['MONNAIE_ORI'],
|
||||
'unite' =>$tabBilan['MONNAIE_LIV_UNITE'],
|
||||
'postes' =>$strPostes,
|
||||
'partenaire' =>$tabBilan['SOURCE'],
|
||||
);
|
||||
if (!$iDb2->insert('bilans', $tabInsert, true))
|
||||
$iDb2->update('bilans', $tabInsert, "siren='$this->siren' AND typeBilan='$typeBilan' AND dateExercice='$millesimeDB'");
|
||||
$ret=$iDb2->select('bilans', 'dateProvPartenaire, dateExercice, dateExercicePre, dureeExercice, dureeExercicePre, monnaie, typeBilan, monnaieOrigine, unite, postes', "siren='$this->siren' AND typeBilan='$typeBilan' AND dateExercice='$millesimeDB'", true);
|
||||
$bilan=$ret[0];
|
||||
}
|
||||
}
|
||||
$tabBilan=$tabBilanPre=$bilanPre=array();
|
||||
$tabBilan['SIREN'] = $this->siren;
|
||||
$tabBilan['DATE_FRAICHE_BILAN'] = $bilan['dateProvPartenaire']; // SSAAMMJJ
|
||||
$tabBilan['DATE_CLOTURE'] = $bilan['dateExercice']; // SSAAMMJJ
|
||||
$tabBilan['DATE_CLOTURE_PRE'] = $bilan['dateExercicePre']; // SSAAMMJJ
|
||||
$tabBilan['DUREE_MOIS'] = $bilan['dureeExercice'];
|
||||
$tabBilan['DUREE_MOIS_PRE'] = $bilan['dureeExercicePre'];
|
||||
$tabBilan['MONNAIE'] = $bilan['monnaie'];
|
||||
$tabBilan['CONSOLIDE'] = $bilan['typeBilan']; // C = Bilan consolidé
|
||||
$tabBilan['MONNAIE_ORI'] = $bilan['monnaieOrigine'];
|
||||
$tabBilan['MONNAIE_LIV_UNITE'] = $bilan['unite'];
|
||||
$tabBilan['SOURCE'] = $bilan['partenaire'];
|
||||
|
||||
// Devise et Unité
|
||||
if ($bilan['monnaie']=='EUR') $monnaie='€'; else $monnaie=$bilan['monnaie'];
|
||||
switch (strtoupper($bilan['unite'])) {
|
||||
case 'K': $unite='K'; break;
|
||||
case 'U':
|
||||
case ' ':
|
||||
case '' : $unite=''; break;
|
||||
case 'M': $unite='M'; break;
|
||||
default: die('Unite Bilan ('. $bilan['unite'] .') non prise en charge !'); break;
|
||||
}
|
||||
$tabBilan['devise'] = /*$unite.*/$monnaie;
|
||||
|
||||
/** Remplissage du tableau des postes du Bilan avec prise en compte de l'unité de la monnaie
|
||||
**/
|
||||
$tabTmp=explode(';', $bilan['postes']);
|
||||
foreach ($tabTmp as $i=>$strTmp) {
|
||||
$tabTmp2=explode('=', $strTmp);
|
||||
if (isset($tabTmp2[1]))
|
||||
if ($unite=='K' && $tabTmp2[0]<>'YP' && $tabTmp2[0]<>'YP1' && $tabTmp2[0]<>'376' // Effectifs 2033 et 2050
|
||||
&& $tabTmp2[0]<>'M2G' && $tabTmp2[0]<>'M2H' // Autres effectifs
|
||||
&& $tabTmp2[0]<>'ZK' && $tabTmp2[0]<>'ZK1' // Taux
|
||||
&& $tabTmp2[0]<>'IJ' && $tabTmp2[0]<>'JH' && $tabTmp2[0]<>'ZR' // pour holding/ste mere
|
||||
)
|
||||
$tabBilan[$tabTmp2[0]]=$tabTmp2[1]*1000;
|
||||
elseif ($unite=='M' && $tabTmp2[0]<>'YP' && $tabTmp2[0]<>'YP1' && $tabTmp2[0]<>'376' // Effectifs 2033 et 2050
|
||||
&& $tabTmp2[0]<>'M2G' && $tabTmp2[0]<>'M2H' // Autres effectifs
|
||||
&& $tabTmp2[0]<>'ZK' && $tabTmp2[0]<>'ZK1' // Taux
|
||||
&& $tabTmp2[0]<>'IJ' && $tabTmp2[0]<>'JH' && $tabTmp2[0]<>'ZR' // pour holding/ste mere
|
||||
)
|
||||
$tabBilan[$tabTmp2[0]]=$tabTmp2[1]*1000000;
|
||||
else $tabBilan[$tabTmp2[0]]=$tabTmp2[1];
|
||||
}
|
||||
|
||||
/** Calcul des valeures NET si l'information est absente en base
|
||||
**/
|
||||
if ($tabBilan['CONSOLIDE']=='N' || $tabBilan['CONSOLIDE']=='C') {
|
||||
if (!isset($tabBilan['AA2']) && isset($tabBilan['AA'])) $tabBilan['AA2']=$tabBilan['AA'];
|
||||
if (!isset($tabBilan['AC1']) && (isset($tabBilan['AB'])||isset($tabBilan['AC']))) $tabBilan['AC1']=$tabBilan['AB']-$tabBilan['AC'];
|
||||
if (!isset($tabBilan['AE1']) && (isset($tabBilan['AD'])||isset($tabBilan['AE']))) $tabBilan['AE1']=$tabBilan['AD']-$tabBilan['AE'];
|
||||
if (!isset($tabBilan['AG1']) && (isset($tabBilan['AF'])||isset($tabBilan['AG']))) $tabBilan['AG1']=$tabBilan['AF']-$tabBilan['AG'];
|
||||
if (!isset($tabBilan['AI1']) && (isset($tabBilan['AH'])||isset($tabBilan['AI']))) $tabBilan['AI1']=$tabBilan['AH']-$tabBilan['AI'];
|
||||
if (!isset($tabBilan['AK1']) && (isset($tabBilan['AJ'])||isset($tabBilan['AK']))) $tabBilan['AK1']=$tabBilan['AJ']-$tabBilan['AK'];
|
||||
if (!isset($tabBilan['AM1']) && (isset($tabBilan['AL'])||isset($tabBilan['AM']))) $tabBilan['AM1']=$tabBilan['AL']-$tabBilan['AM'];
|
||||
if (!isset($tabBilan['AO1']) && (isset($tabBilan['AN'])||isset($tabBilan['AO']))) $tabBilan['AO1']=$tabBilan['AN']-$tabBilan['AO'];
|
||||
if (!isset($tabBilan['AQ1']) && (isset($tabBilan['AP'])||isset($tabBilan['AQ']))) $tabBilan['AQ1']=$tabBilan['AP']-$tabBilan['AQ'];
|
||||
if (!isset($tabBilan['AS1']) && (isset($tabBilan['AR'])||isset($tabBilan['AS']))) $tabBilan['AS1']=$tabBilan['AR']-$tabBilan['AS'];
|
||||
if (!isset($tabBilan['AU1']) && (isset($tabBilan['AT'])||isset($tabBilan['AU']))) $tabBilan['AU1']=$tabBilan['AT']-$tabBilan['AU'];
|
||||
if (!isset($tabBilan['AW1']) && (isset($tabBilan['AV'])||isset($tabBilan['AW']))) $tabBilan['AW1']=$tabBilan['AV']-$tabBilan['AW'];
|
||||
if (!isset($tabBilan['AY1']) && (isset($tabBilan['AX'])||isset($tabBilan['AY']))) $tabBilan['AY1']=$tabBilan['AX']-$tabBilan['AY'];
|
||||
if (!isset($tabBilan['CT1']) && (isset($tabBilan['CS'])||isset($tabBilan['CT']))) $tabBilan['CT1']=$tabBilan['CS']-$tabBilan['CT'];
|
||||
if (!isset($tabBilan['CV1']) && (isset($tabBilan['CU'])||isset($tabBilan['CV']))) $tabBilan['CV1']=$tabBilan['CU']-$tabBilan['CV'];
|
||||
if (!isset($tabBilan['BC1']) && (isset($tabBilan['BB'])||isset($tabBilan['BC']))) $tabBilan['BC1']=$tabBilan['BB']-$tabBilan['BC'];
|
||||
if (!isset($tabBilan['BE1']) && (isset($tabBilan['BD'])||isset($tabBilan['BE']))) $tabBilan['BE1']=$tabBilan['BD']-$tabBilan['BE'];
|
||||
if (!isset($tabBilan['BG1']) && (isset($tabBilan['BF'])||isset($tabBilan['BG']))) $tabBilan['BG1']=$tabBilan['BF']-$tabBilan['BG'];
|
||||
if (!isset($tabBilan['BI1']) && (isset($tabBilan['BH'])||isset($tabBilan['BI']))) $tabBilan['BI1']=$tabBilan['BH']-$tabBilan['BI'];
|
||||
if (!isset($tabBilan['BK1']) && (isset($tabBilan['BJ'])||isset($tabBilan['BK']))) $tabBilan['BK1']=$tabBilan['BJ']-$tabBilan['BK'];
|
||||
if (!isset($tabBilan['BM1']) && (isset($tabBilan['BL'])||isset($tabBilan['BM']))) $tabBilan['BM1']=$tabBilan['BL']-$tabBilan['BM'];
|
||||
if (!isset($tabBilan['BO1']) && (isset($tabBilan['BN'])||isset($tabBilan['BO']))) $tabBilan['BO1']=$tabBilan['BN']-$tabBilan['BO'];
|
||||
if (!isset($tabBilan['BQ1']) && (isset($tabBilan['BP'])||isset($tabBilan['BQ']))) $tabBilan['BQ1']=$tabBilan['BP']-$tabBilan['BQ'];
|
||||
if (!isset($tabBilan['BS1']) && (isset($tabBilan['BR'])||isset($tabBilan['BS']))) $tabBilan['BS1']=$tabBilan['BR']-$tabBilan['BS'];
|
||||
if (!isset($tabBilan['BU1']) && (isset($tabBilan['BT'])||isset($tabBilan['BU']))) $tabBilan['BU1']=$tabBilan['BT']-$tabBilan['BU'];
|
||||
if (!isset($tabBilan['BW1']) && (isset($tabBilan['BV'])||isset($tabBilan['BW']))) $tabBilan['BW1']=$tabBilan['BV']-$tabBilan['BW'];
|
||||
if (!isset($tabBilan['BY1']) && (isset($tabBilan['BX'])||isset($tabBilan['BY']))) $tabBilan['BY1']=$tabBilan['BX']-$tabBilan['BY'];
|
||||
if (!isset($tabBilan['CA1']) && (isset($tabBilan['BZ'])||isset($tabBilan['CA']))) $tabBilan['CA1']=$tabBilan['BZ']-$tabBilan['CA'];
|
||||
if (!isset($tabBilan['CC1']) && (isset($tabBilan['CB'])||isset($tabBilan['CC']))) $tabBilan['CC1']=$tabBilan['CB']-$tabBilan['CC'];
|
||||
if (!isset($tabBilan['CE1']) && (isset($tabBilan['CD'])||isset($tabBilan['CE']))) $tabBilan['CE1']=$tabBilan['CD']-$tabBilan['CE'];
|
||||
if (!isset($tabBilan['CG1']) && (isset($tabBilan['CF'])||isset($tabBilan['CG']))) $tabBilan['CG1']=$tabBilan['CF']-$tabBilan['CG'];
|
||||
if (!isset($tabBilan['CI1']) && (isset($tabBilan['CH'])||isset($tabBilan['CI']))) $tabBilan['CI1']=$tabBilan['CH']-$tabBilan['CI'];
|
||||
if (!isset($tabBilan['CK1']) && (isset($tabBilan['CJ'])||isset($tabBilan['CK']))) $tabBilan['CK1']=$tabBilan['CJ']-$tabBilan['CK'];
|
||||
|
||||
if (!isset($tabBilan['CL2']) && isset($tabBilan['CL'])) $tabBilan['CL2']=$tabBilan['CL'];
|
||||
if (!isset($tabBilan['CM2']) && isset($tabBilan['CM'])) $tabBilan['CM2']=$tabBilan['CM'];
|
||||
if (!isset($tabBilan['CN2']) && isset($tabBilan['CN'])) $tabBilan['CN2']=$tabBilan['CN'];
|
||||
|
||||
if (!isset($tabBilan['1A1']) && (isset($tabBilan['CO'])||isset($tabBilan['1A']))) $tabBilan['1A1']=$tabBilan['CO']-$tabBilan['1A'];
|
||||
} elseif ($tabBilan['CONSOLIDE']=='S') {
|
||||
//if (!isset($tabBilan['AC1']) && (isset($tabBilan['AB'])||isset($tabBilan['AC']))) $tabBilan['AC1']=$tabBilan['AB']-$tabBilan['AC'];
|
||||
if (!isset($tabBilan['013']) && (isset($tabBilan['010'])||isset($tabBilan['012']))) $tabBilan['013']=$tabBilan['010']-$tabBilan['012'];
|
||||
if (!isset($tabBilan['017']) && (isset($tabBilan['014'])||isset($tabBilan['016']))) $tabBilan['017']=$tabBilan['014']-$tabBilan['016'];
|
||||
if (!isset($tabBilan['031']) && (isset($tabBilan['028'])||isset($tabBilan['030']))) $tabBilan['031']=$tabBilan['028']-$tabBilan['030'];
|
||||
if (!isset($tabBilan['043']) && (isset($tabBilan['040'])||isset($tabBilan['042']))) $tabBilan['043']=$tabBilan['040']-$tabBilan['042'];
|
||||
if (!isset($tabBilan['049']) && (isset($tabBilan['044'])||isset($tabBilan['048']))) $tabBilan['049']=$tabBilan['044']-$tabBilan['048'];
|
||||
if (!isset($tabBilan['053']) && (isset($tabBilan['050'])||isset($tabBilan['052']))) $tabBilan['053']=$tabBilan['050']-$tabBilan['052'];
|
||||
if (!isset($tabBilan['063']) && (isset($tabBilan['060'])||isset($tabBilan['062']))) $tabBilan['063']=$tabBilan['060']-$tabBilan['062'];
|
||||
if (!isset($tabBilan['067']) && (isset($tabBilan['064'])||isset($tabBilan['066']))) $tabBilan['067']=$tabBilan['064']-$tabBilan['066'];
|
||||
if (!isset($tabBilan['071']) && (isset($tabBilan['068'])||isset($tabBilan['070']))) $tabBilan['071']=$tabBilan['068']-$tabBilan['070'];
|
||||
if (!isset($tabBilan['075']) && (isset($tabBilan['072'])||isset($tabBilan['074']))) $tabBilan['075']=$tabBilan['072']-$tabBilan['074'];
|
||||
if (!isset($tabBilan['083']) && (isset($tabBilan['080'])||isset($tabBilan['082']))) $tabBilan['083']=$tabBilan['080']-$tabBilan['082'];
|
||||
if (!isset($tabBilan['087']) && (isset($tabBilan['084'])||isset($tabBilan['086']))) $tabBilan['087']=$tabBilan['084']-$tabBilan['086'];
|
||||
if (!isset($tabBilan['091']) && (isset($tabBilan['088'])||isset($tabBilan['090']))) $tabBilan['091']=$tabBilan['088']-$tabBilan['090'];
|
||||
if (!isset($tabBilan['095']) && (isset($tabBilan['092'])||isset($tabBilan['094']))) $tabBilan['095']=$tabBilan['092']-$tabBilan['094'];
|
||||
if (!isset($tabBilan['099']) && (isset($tabBilan['096'])||isset($tabBilan['098']))) $tabBilan['099']=$tabBilan['096']-$tabBilan['098'];
|
||||
if (!isset($tabBilan['113']) && (isset($tabBilan['110'])||isset($tabBilan['112']))) $tabBilan['113']=$tabBilan['110']-$tabBilan['112'];
|
||||
}
|
||||
/** Y a t'il suffisament d'informations sur le bilan précédent
|
||||
**/
|
||||
if ($bilan['dateExercicePre']*1==0 || $bilan['dureeExercicePre']*1==0 ||
|
||||
(($tabBilan['FL1']*1==0 || $tabBilan['EE1']*1==0) && ($tabBilan['CONSOLIDE']=='N' || $tabBilan['CONSOLIDE']=='C')) || // Réel Normal ou Consolidé
|
||||
(($tabBilan['NA3']*1==0 || $tabBilan['NP3']*1==0) && ($tabBilan['CONSOLIDE']=='A' || $tabBilan['CONSOLIDE']=='B')) || // Banque ou Assurance
|
||||
(($tabBilan['N15']*1==0 || $tabBilan['N32']*1==0) && $tabBilan['CONSOLIDE']=='S') // Réel Simplifié
|
||||
) {
|
||||
/** Il n'y a aucune information sur le bilan précédent
|
||||
**/
|
||||
$ret=$iDb2->select('bilans', 'dateProvPartenaire, dateExercice, dateExercicePre, dureeExercice, dureeExercicePre, monnaie, typeBilan, monnaieOrigine, unite, postes', "siren='$this->siren' AND typeBilan='$typeBilan' AND dateExercice<'$millesimeDB' ORDER BY dateExercice DESC LIMIT 0,1", true);
|
||||
$bilanPre=$ret[0];
|
||||
$tabBilan['DATE_CLOTURE_PRE'] = $bilanPre['dateExercice']; // SSAAMMJJ
|
||||
$tabBilan['DUREE_MOIS_PRE'] = $bilanPre['dureeExercice'];
|
||||
if ($bilanPre['monnaie']=='EUR') $monnaiePre='€'; else $monnaiePre=$bilanPre['monnaie'];
|
||||
switch (strtoupper($bilanPre['unite'])) {
|
||||
case 'K': $unitePre='K'; break;
|
||||
case 'U':
|
||||
case ' ':
|
||||
case '' : $unitePre=''; break;
|
||||
case 'M': $unitePre='M'; break;
|
||||
default: die('Unite Bilan ('. $bilanPre['unite'] .') non prise en charge !'); break;
|
||||
}
|
||||
$tabBilanPre['devise'] = /*$unite.*/$monnaiePre;
|
||||
|
||||
$tabTmp=explode(';', $bilanPre['postes']);
|
||||
/* foreach ($tabTmp as $i=>$strTmp) {
|
||||
$tabTmp2=explode('=', $strTmp);
|
||||
if (isset($tabTmp2[1]))
|
||||
if ($unitePre=='K' && $tabTmp2[0]<>'YP' && $tabTmp2[0]<>'YP1' && $tabTmp2[0]<>'376')
|
||||
$tabBilanPre[$tabTmp2[0]]=$tabTmp2[1]*1000;
|
||||
elseif ($unitePre=='M' && $tabTmp2[0]<>'YP' && $tabTmp2[0]<>'YP1' && $tabTmp2[0]<>'376')
|
||||
$tabBilanPre[$tabTmp2[0]]=$tabTmp2[1]*1000000;
|
||||
else $tabBilanPre[$tabTmp2[0]]=$tabTmp2[1];
|
||||
}*/
|
||||
foreach ($tabTmp as $i=>$strTmp) {
|
||||
$tabTmp2=explode('=', $strTmp);
|
||||
if (isset($tabTmp2[1]))
|
||||
if ($unite=='K' && $tabTmp2[0]<>'YP' && $tabTmp2[0]<>'YP1' && $tabTmp2[0]<>'376' // Effectifs 2033 et 2050
|
||||
&& $tabTmp2[0]<>'M2G' && $tabTmp2[0]<>'M2H' // Autres effectifs
|
||||
&& $tabTmp2[0]<>'ZK' && $tabTmp2[0]<>'ZK1' && $tabTmp2[0]<>'ZR' // Taux et infos Filliales
|
||||
)
|
||||
$tabBilanPre[$tabTmp2[0]]=$tabTmp2[1]*1000;
|
||||
elseif ($unite=='M' && $tabTmp2[0]<>'YP' && $tabTmp2[0]<>'YP1' && $tabTmp2[0]<>'376' // Effectifs 2033 et 2050
|
||||
&& $tabTmp2[0]<>'M2G' && $tabTmp2[0]<>'M2H' // Autres effectifs
|
||||
&& $tabTmp2[0]<>'ZK' && $tabTmp2[0]<>'ZK1' && $tabTmp2[0]<>'ZR' // Taux et infos Filliales
|
||||
)
|
||||
$tabBilanPre[$tabTmp2[0]]=$tabTmp2[1]*1000000;
|
||||
else $tabBilanPre[$tabTmp2[0]]=$tabTmp2[1];
|
||||
}
|
||||
|
||||
/** Calcul des valeures NET N-1 si l'information est absente du bilan N-1 en base **/
|
||||
if ($tabBilan['CONSOLIDE']=='N' || $tabBilan['CONSOLIDE']=='C') {
|
||||
if (!isset($tabBilanPre['AA2']) && isset($tabBilanPre['AA'])) $tabBilanPre['AA2']=$tabBilanPre['AA'];
|
||||
if (!isset($tabBilanPre['AC1']) && (isset($tabBilanPre['AB'])||isset($tabBilanPre['AC']))) $tabBilanPre['AC1']=$tabBilanPre['AB']-$tabBilanPre['AC'];
|
||||
if (!isset($tabBilanPre['AE1']) && (isset($tabBilanPre['AD'])||isset($tabBilanPre['AE']))) $tabBilanPre['AE1']=$tabBilanPre['AD']-$tabBilanPre['AE'];
|
||||
if (!isset($tabBilanPre['AG1']) && (isset($tabBilanPre['AF'])||isset($tabBilanPre['AG']))) $tabBilanPre['AG1']=$tabBilanPre['AF']-$tabBilanPre['AG'];
|
||||
if (!isset($tabBilanPre['AI1']) && (isset($tabBilanPre['AH'])||isset($tabBilanPre['AI']))) $tabBilanPre['AI1']=$tabBilanPre['AH']-$tabBilanPre['AI'];
|
||||
if (!isset($tabBilanPre['AK1']) && (isset($tabBilanPre['AJ'])||isset($tabBilanPre['AK']))) $tabBilanPre['AK1']=$tabBilanPre['AJ']-$tabBilanPre['AK'];
|
||||
if (!isset($tabBilanPre['AM1']) && (isset($tabBilanPre['AL'])||isset($tabBilanPre['AM']))) $tabBilanPre['AM1']=$tabBilanPre['AL']-$tabBilanPre['AM'];
|
||||
if (!isset($tabBilanPre['AO1']) && (isset($tabBilanPre['AN'])||isset($tabBilanPre['AO']))) $tabBilanPre['AO1']=$tabBilanPre['AN']-$tabBilanPre['AO'];
|
||||
if (!isset($tabBilanPre['AQ1']) && (isset($tabBilanPre['AP'])||isset($tabBilanPre['AQ']))) $tabBilanPre['AQ1']=$tabBilanPre['AP']-$tabBilanPre['AQ'];
|
||||
if (!isset($tabBilanPre['AS1']) && (isset($tabBilanPre['AR'])||isset($tabBilanPre['AS']))) $tabBilanPre['AS1']=$tabBilanPre['AR']-$tabBilanPre['AS'];
|
||||
if (!isset($tabBilanPre['AU1']) && (isset($tabBilanPre['AT'])||isset($tabBilanPre['AU']))) $tabBilanPre['AU1']=$tabBilanPre['AT']-$tabBilanPre['AU'];
|
||||
if (!isset($tabBilanPre['AW1']) && (isset($tabBilanPre['AV'])||isset($tabBilanPre['AW']))) $tabBilanPre['AW1']=$tabBilanPre['AV']-$tabBilanPre['AW'];
|
||||
if (!isset($tabBilanPre['AY1']) && (isset($tabBilanPre['AX'])||isset($tabBilanPre['AY']))) $tabBilanPre['AY1']=$tabBilanPre['AX']-$tabBilanPre['AY'];
|
||||
if (!isset($tabBilanPre['CT1']) && (isset($tabBilanPre['CS'])||isset($tabBilanPre['CT']))) $tabBilanPre['CT1']=$tabBilanPre['CS']-$tabBilanPre['CT'];
|
||||
if (!isset($tabBilanPre['CV1']) && (isset($tabBilanPre['CU'])||isset($tabBilanPre['CV']))) $tabBilanPre['CV1']=$tabBilanPre['CU']-$tabBilanPre['CV'];
|
||||
if (!isset($tabBilanPre['BC1']) && (isset($tabBilanPre['BB'])||isset($tabBilanPre['BC']))) $tabBilanPre['BC1']=$tabBilanPre['BB']-$tabBilanPre['BC'];
|
||||
if (!isset($tabBilanPre['BE1']) && (isset($tabBilanPre['BD'])||isset($tabBilanPre['BE']))) $tabBilanPre['BE1']=$tabBilanPre['BD']-$tabBilanPre['BE'];
|
||||
if (!isset($tabBilanPre['BG1']) && (isset($tabBilanPre['BF'])||isset($tabBilanPre['BG']))) $tabBilanPre['BG1']=$tabBilanPre['BF']-$tabBilanPre['BG'];
|
||||
if (!isset($tabBilanPre['BI1']) && (isset($tabBilanPre['BH'])||isset($tabBilanPre['BI']))) $tabBilanPre['BI1']=$tabBilanPre['BH']-$tabBilanPre['BI'];
|
||||
if (!isset($tabBilanPre['BK1']) && (isset($tabBilanPre['BJ'])||isset($tabBilanPre['BK']))) $tabBilanPre['BK1']=$tabBilanPre['BJ']-$tabBilanPre['BK'];
|
||||
if (!isset($tabBilanPre['BM1']) && (isset($tabBilanPre['BL'])||isset($tabBilanPre['BM']))) $tabBilanPre['BM1']=$tabBilanPre['BL']-$tabBilanPre['BM'];
|
||||
if (!isset($tabBilanPre['BO1']) && (isset($tabBilanPre['BN'])||isset($tabBilanPre['BO']))) $tabBilanPre['BO1']=$tabBilanPre['BN']-$tabBilanPre['BO'];
|
||||
if (!isset($tabBilanPre['BQ1']) && (isset($tabBilanPre['BP'])||isset($tabBilanPre['BQ']))) $tabBilanPre['BQ1']=$tabBilanPre['BP']-$tabBilanPre['BQ'];
|
||||
if (!isset($tabBilanPre['BS1']) && (isset($tabBilanPre['BR'])||isset($tabBilanPre['BS']))) $tabBilanPre['BS1']=$tabBilanPre['BR']-$tabBilanPre['BS'];
|
||||
if (!isset($tabBilanPre['BU1']) && (isset($tabBilanPre['BT'])||isset($tabBilanPre['BU']))) $tabBilanPre['BU1']=$tabBilanPre['BT']-$tabBilanPre['BU'];
|
||||
if (!isset($tabBilanPre['BW1']) && (isset($tabBilanPre['BV'])||isset($tabBilanPre['BW']))) $tabBilanPre['BW1']=$tabBilanPre['BV']-$tabBilanPre['BW'];
|
||||
if (!isset($tabBilanPre['BY1']) && (isset($tabBilanPre['BX'])||isset($tabBilanPre['BY']))) $tabBilanPre['BY1']=$tabBilanPre['BX']-$tabBilanPre['BY'];
|
||||
if (!isset($tabBilanPre['CA1']) && (isset($tabBilanPre['BZ'])||isset($tabBilanPre['CA']))) $tabBilanPre['CA1']=$tabBilanPre['BZ']-$tabBilanPre['CA'];
|
||||
if (!isset($tabBilanPre['CC1']) && (isset($tabBilanPre['CB'])||isset($tabBilanPre['CC']))) $tabBilanPre['CC1']=$tabBilanPre['CB']-$tabBilanPre['CC'];
|
||||
if (!isset($tabBilanPre['CE1']) && (isset($tabBilanPre['CD'])||isset($tabBilanPre['CE']))) $tabBilanPre['CE1']=$tabBilanPre['CD']-$tabBilanPre['CE'];
|
||||
if (!isset($tabBilanPre['CG1']) && (isset($tabBilanPre['CF'])||isset($tabBilanPre['CG']))) $tabBilanPre['CG1']=$tabBilanPre['CF']-$tabBilanPre['CG'];
|
||||
if (!isset($tabBilanPre['CI1']) && (isset($tabBilanPre['CH'])||isset($tabBilanPre['CI']))) $tabBilanPre['CI1']=$tabBilanPre['CH']-$tabBilanPre['CI'];
|
||||
if (!isset($tabBilanPre['CK1']) && (isset($tabBilanPre['CJ'])||isset($tabBilanPre['CK']))) $tabBilanPre['CK1']=$tabBilanPre['CJ']-$tabBilanPre['CK'];
|
||||
|
||||
if (!isset($tabBilanPre['CL2']) && isset($tabBilanPre['CL'])) $tabBilanPre['CL2']=$tabBilanPre['CL'];
|
||||
if (!isset($tabBilanPre['CM2']) && isset($tabBilanPre['CM'])) $tabBilanPre['CM2']=$tabBilanPre['CM'];
|
||||
if (!isset($tabBilanPre['CN2']) && isset($tabBilanPre['CN'])) $tabBilanPre['CN2']=$tabBilanPre['CN'];
|
||||
|
||||
if (!isset($tabBilanPre['1A1']) && (isset($tabBilanPre['CO'])||isset($tabBilanPre['1A']))) $tabBilanPre['1A1']=$tabBilanPre['CO']-$tabBilanPre['1A'];
|
||||
|
||||
/** Reprises des valeures N-1 si l'information est absente en base
|
||||
**/
|
||||
// Actif
|
||||
if (!isset($tabBilan['AA3']) && isset($tabBilanPre['AA2'])) $tabBilan['AA3']=$tabBilanPre['AA2'];
|
||||
if (!isset($tabBilan['AC2']) && isset($tabBilanPre['AC1'])) $tabBilan['AC2']=$tabBilanPre['AC1'];
|
||||
if (!isset($tabBilan['AE2']) && isset($tabBilanPre['AE1'])) $tabBilan['AE2']=$tabBilanPre['AE1'];
|
||||
if (!isset($tabBilan['AG2']) && isset($tabBilanPre['AG1'])) $tabBilan['AG2']=$tabBilanPre['AG1'];
|
||||
if (!isset($tabBilan['AI2']) && isset($tabBilanPre['AI1'])) $tabBilan['AI2']=$tabBilanPre['AI1'];
|
||||
if (!isset($tabBilan['AK2']) && isset($tabBilanPre['AK1'])) $tabBilan['AK2']=$tabBilanPre['AK1'];
|
||||
if (!isset($tabBilan['AM2']) && isset($tabBilanPre['AM1'])) $tabBilan['AM2']=$tabBilanPre['AM1'];
|
||||
if (!isset($tabBilan['AO2']) && isset($tabBilanPre['AO1'])) $tabBilan['AO2']=$tabBilanPre['AO1'];
|
||||
if (!isset($tabBilan['AQ2']) && isset($tabBilanPre['AQ1'])) $tabBilan['AQ2']=$tabBilanPre['AQ1'];
|
||||
if (!isset($tabBilan['AS2']) && isset($tabBilanPre['AS1'])) $tabBilan['AS2']=$tabBilanPre['AS1'];
|
||||
if (!isset($tabBilan['AU2']) && isset($tabBilanPre['AU1'])) $tabBilan['AU2']=$tabBilanPre['AU1'];
|
||||
if (!isset($tabBilan['AW2']) && isset($tabBilanPre['AW1'])) $tabBilan['AW2']=$tabBilanPre['AW1'];
|
||||
if (!isset($tabBilan['AY2']) && isset($tabBilanPre['AY1'])) $tabBilan['AY2']=$tabBilanPre['AY1'];
|
||||
if (!isset($tabBilan['CT2']) && isset($tabBilanPre['CT1'])) $tabBilan['CT2']=$tabBilanPre['CT1'];
|
||||
if (!isset($tabBilan['CV2']) && isset($tabBilanPre['CV1'])) $tabBilan['CV2']=$tabBilanPre['CV1'];
|
||||
if (!isset($tabBilan['BC2']) && isset($tabBilanPre['BC1'])) $tabBilan['BC2']=$tabBilanPre['BC1'];
|
||||
if (!isset($tabBilan['BE2']) && isset($tabBilanPre['BE1'])) $tabBilan['BE2']=$tabBilanPre['BE1'];
|
||||
if (!isset($tabBilan['BG2']) && isset($tabBilanPre['BG1'])) $tabBilan['BG2']=$tabBilanPre['BG1'];
|
||||
if (!isset($tabBilan['BI2']) && isset($tabBilanPre['BI1'])) $tabBilan['BI2']=$tabBilanPre['BI1'];
|
||||
if (!isset($tabBilan['BK2']) && isset($tabBilanPre['BK1'])) $tabBilan['BK2']=$tabBilanPre['BK1'];
|
||||
if (!isset($tabBilan['BM2']) && isset($tabBilanPre['BM1'])) $tabBilan['BM2']=$tabBilanPre['BM1'];
|
||||
if (!isset($tabBilan['BO2']) && isset($tabBilanPre['BO1'])) $tabBilan['BO2']=$tabBilanPre['BO1'];
|
||||
if (!isset($tabBilan['BQ2']) && isset($tabBilanPre['BQ1'])) $tabBilan['BQ2']=$tabBilanPre['BQ1'];
|
||||
if (!isset($tabBilan['BS2']) && isset($tabBilanPre['BS1'])) $tabBilan['BS2']=$tabBilanPre['BS1'];
|
||||
if (!isset($tabBilan['BU2']) && isset($tabBilanPre['BU1'])) $tabBilan['BU2']=$tabBilanPre['BU1'];
|
||||
if (!isset($tabBilan['BW2']) && isset($tabBilanPre['BW1'])) $tabBilan['BW2']=$tabBilanPre['BW1'];
|
||||
if (!isset($tabBilan['BY2']) && isset($tabBilanPre['BY1'])) $tabBilan['BY2']=$tabBilanPre['BY1'];
|
||||
if (!isset($tabBilan['CA2']) && isset($tabBilanPre['CA1'])) $tabBilan['CA2']=$tabBilanPre['CA1'];
|
||||
if (!isset($tabBilan['CC2']) && isset($tabBilanPre['CC1'])) $tabBilan['CC2']=$tabBilanPre['CC1'];
|
||||
if (!isset($tabBilan['CE2']) && isset($tabBilanPre['CE1'])) $tabBilan['CE2']=$tabBilanPre['CE1'];
|
||||
if (!isset($tabBilan['CG2']) && isset($tabBilanPre['CG1'])) $tabBilan['CG2']=$tabBilanPre['CG1'];
|
||||
if (!isset($tabBilan['CI2']) && isset($tabBilanPre['CI1'])) $tabBilan['CI2']=$tabBilanPre['CI1'];
|
||||
if (!isset($tabBilan['CK2']) && isset($tabBilanPre['CK1'])) $tabBilan['CK2']=$tabBilanPre['CK1'];
|
||||
if (!isset($tabBilan['CL3']) && isset($tabBilanPre['CL2'])) $tabBilan['CL3']=$tabBilanPre['CL2'];
|
||||
if (!isset($tabBilan['CM3']) && isset($tabBilanPre['CM2'])) $tabBilan['CM3']=$tabBilanPre['CM2'];
|
||||
if (!isset($tabBilan['CN3']) && isset($tabBilanPre['CN2'])) $tabBilan['CN3']=$tabBilanPre['CN2'];
|
||||
if (!isset($tabBilan['1A2']) && isset($tabBilanPre['1A1'])) $tabBilan['1A2']=$tabBilanPre['1A1'];
|
||||
// Passif
|
||||
if (!isset($tabBilan['DA1']) && isset($tabBilanPre['DA'])) $tabBilan['DA1']=$tabBilanPre['DA'];
|
||||
if (!isset($tabBilan['DB1']) && isset($tabBilanPre['DB'])) $tabBilan['DB1']=$tabBilanPre['DB'];
|
||||
if (!isset($tabBilan['DC1']) && isset($tabBilanPre['DC'])) $tabBilan['DC1']=$tabBilanPre['DC'];
|
||||
if (!isset($tabBilan['DD1']) && isset($tabBilanPre['DD'])) $tabBilan['DD1']=$tabBilanPre['DD'];
|
||||
if (!isset($tabBilan['DE1']) && isset($tabBilanPre['DE'])) $tabBilan['DE1']=$tabBilanPre['DE'];
|
||||
if (!isset($tabBilan['DF1']) && isset($tabBilanPre['DF'])) $tabBilan['DF1']=$tabBilanPre['DF'];
|
||||
if (!isset($tabBilan['DG1']) && isset($tabBilanPre['DG'])) $tabBilan['DG1']=$tabBilanPre['DG'];
|
||||
if (!isset($tabBilan['DH1']) && isset($tabBilanPre['DH'])) $tabBilan['DH1']=$tabBilanPre['DH'];
|
||||
if (!isset($tabBilan['DI1']) && isset($tabBilanPre['DI'])) $tabBilan['DI1']=$tabBilanPre['DI'];
|
||||
if (!isset($tabBilan['DJ1']) && isset($tabBilanPre['DJ'])) $tabBilan['DJ1']=$tabBilanPre['DJ'];
|
||||
if (!isset($tabBilan['DK1']) && isset($tabBilanPre['DK'])) $tabBilan['DK1']=$tabBilanPre['DK'];
|
||||
if (!isset($tabBilan['DL1']) && isset($tabBilanPre['DL'])) $tabBilan['DL1']=$tabBilanPre['DL'];
|
||||
if (!isset($tabBilan['DM1']) && isset($tabBilanPre['DM'])) $tabBilan['DM1']=$tabBilanPre['DM'];
|
||||
if (!isset($tabBilan['DN1']) && isset($tabBilanPre['DN'])) $tabBilan['DN1']=$tabBilanPre['DN'];
|
||||
if (!isset($tabBilan['DO1']) && isset($tabBilanPre['DO'])) $tabBilan['DO1']=$tabBilanPre['DO'];
|
||||
if (!isset($tabBilan['DP1']) && isset($tabBilanPre['DP'])) $tabBilan['DP1']=$tabBilanPre['DP'];
|
||||
if (!isset($tabBilan['DQ1']) && isset($tabBilanPre['DQ'])) $tabBilan['DQ1']=$tabBilanPre['DQ'];
|
||||
if (!isset($tabBilan['DR1']) && isset($tabBilanPre['DR'])) $tabBilan['DR1']=$tabBilanPre['DR'];
|
||||
if (!isset($tabBilan['DS1']) && isset($tabBilanPre['DS'])) $tabBilan['DS1']=$tabBilanPre['DS'];
|
||||
if (!isset($tabBilan['DT1']) && isset($tabBilanPre['DT'])) $tabBilan['DT1']=$tabBilanPre['DT'];
|
||||
if (!isset($tabBilan['DU1']) && isset($tabBilanPre['DU'])) $tabBilan['DU1']=$tabBilanPre['DU'];
|
||||
if (!isset($tabBilan['DV1']) && isset($tabBilanPre['DV'])) $tabBilan['DV1']=$tabBilanPre['DV'];
|
||||
if (!isset($tabBilan['DW1']) && isset($tabBilanPre['DW'])) $tabBilan['DW1']=$tabBilanPre['DW'];
|
||||
if (!isset($tabBilan['DX1']) && isset($tabBilanPre['DX'])) $tabBilan['DX1']=$tabBilanPre['DX'];
|
||||
if (!isset($tabBilan['DY1']) && isset($tabBilanPre['DY'])) $tabBilan['DY1']=$tabBilanPre['DY'];
|
||||
if (!isset($tabBilan['DZ1']) && isset($tabBilanPre['DZ'])) $tabBilan['DZ1']=$tabBilanPre['DZ'];
|
||||
if (!isset($tabBilan['EA1']) && isset($tabBilanPre['EA'])) $tabBilan['EA1']=$tabBilanPre['EA'];
|
||||
if (!isset($tabBilan['EB1']) && isset($tabBilanPre['EB'])) $tabBilan['EB1']=$tabBilanPre['EB'];
|
||||
if (!isset($tabBilan['EC1']) && isset($tabBilanPre['EC'])) $tabBilan['EC1']=$tabBilanPre['EC'];
|
||||
if (!isset($tabBilan['ED1']) && isset($tabBilanPre['ED'])) $tabBilan['ED1']=$tabBilanPre['ED'];
|
||||
if (!isset($tabBilan['EE1']) && isset($tabBilanPre['EE'])) $tabBilan['EE1']=$tabBilanPre['EE'];
|
||||
if (!isset($tabBilan['1B1']) && isset($tabBilanPre['1B'])) $tabBilan['1B1']=$tabBilanPre['1B'];
|
||||
if (!isset($tabBilan['1C1']) && isset($tabBilanPre['1C'])) $tabBilan['1C1']=$tabBilanPre['1C'];
|
||||
if (!isset($tabBilan['1D1']) && isset($tabBilanPre['1D'])) $tabBilan['1D1']=$tabBilanPre['1D'];
|
||||
if (!isset($tabBilan['1E1']) && isset($tabBilanPre['1E'])) $tabBilan['1E1']=$tabBilanPre['1E'];
|
||||
if (!isset($tabBilan['EF1']) && isset($tabBilanPre['EF'])) $tabBilan['EF1']=$tabBilanPre['EF'];
|
||||
if (!isset($tabBilan['EG1']) && isset($tabBilanPre['EG'])) $tabBilan['EG1']=$tabBilanPre['EG'];
|
||||
if (!isset($tabBilan['EH1']) && isset($tabBilanPre['EH'])) $tabBilan['EH1']=$tabBilanPre['EH'];
|
||||
// Compte de Résultats
|
||||
if (!isset($tabBilan['FC1']) && isset($tabBilanPre['FC'])) $tabBilan['FC1']=$tabBilanPre['FC'];
|
||||
if (!isset($tabBilan['FF1']) && isset($tabBilanPre['FF'])) $tabBilan['FF1']=$tabBilanPre['FF'];
|
||||
if (!isset($tabBilan['FI1']) && isset($tabBilanPre['FI'])) $tabBilan['FI1']=$tabBilanPre['FI'];
|
||||
if (!isset($tabBilan['FL1']) && isset($tabBilanPre['FL'])) $tabBilan['FL1']=$tabBilanPre['FL'];
|
||||
if (!isset($tabBilan['FM1']) && isset($tabBilanPre['FM'])) $tabBilan['FM1']=$tabBilanPre['FM'];
|
||||
if (!isset($tabBilan['FN1']) && isset($tabBilanPre['FN'])) $tabBilan['FN1']=$tabBilanPre['FN'];
|
||||
if (!isset($tabBilan['FO1']) && isset($tabBilanPre['FO'])) $tabBilan['FO1']=$tabBilanPre['FO'];
|
||||
if (!isset($tabBilan['FP1']) && isset($tabBilanPre['FP'])) $tabBilan['FP1']=$tabBilanPre['FP'];
|
||||
if (!isset($tabBilan['FQ1']) && isset($tabBilanPre['FQ'])) $tabBilan['FQ1']=$tabBilanPre['FQ'];
|
||||
if (!isset($tabBilan['FR1']) && isset($tabBilanPre['FR'])) $tabBilan['FR1']=$tabBilanPre['FR'];
|
||||
if (!isset($tabBilan['FS1']) && isset($tabBilanPre['FS'])) $tabBilan['FS1']=$tabBilanPre['FS'];
|
||||
if (!isset($tabBilan['FT1']) && isset($tabBilanPre['FT'])) $tabBilan['FT1']=$tabBilanPre['FT'];
|
||||
if (!isset($tabBilan['FU1']) && isset($tabBilanPre['FU'])) $tabBilan['FU1']=$tabBilanPre['FU'];
|
||||
if (!isset($tabBilan['FV1']) && isset($tabBilanPre['FV'])) $tabBilan['FV1']=$tabBilanPre['FV'];
|
||||
if (!isset($tabBilan['FW1']) && isset($tabBilanPre['FW'])) $tabBilan['FW1']=$tabBilanPre['FW'];
|
||||
if (!isset($tabBilan['FX1']) && isset($tabBilanPre['FX'])) $tabBilan['FX1']=$tabBilanPre['FX'];
|
||||
if (!isset($tabBilan['FY1']) && isset($tabBilanPre['FY'])) $tabBilan['FY1']=$tabBilanPre['FY'];
|
||||
if (!isset($tabBilan['FZ1']) && isset($tabBilanPre['FZ'])) $tabBilan['FZ1']=$tabBilanPre['FZ'];
|
||||
if (!isset($tabBilan['GA1']) && isset($tabBilanPre['GA'])) $tabBilan['GA1']=$tabBilanPre['GA'];
|
||||
if (!isset($tabBilan['GB1']) && isset($tabBilanPre['GB'])) $tabBilan['GB1']=$tabBilanPre['GB'];
|
||||
if (!isset($tabBilan['GC1']) && isset($tabBilanPre['GC'])) $tabBilan['GC1']=$tabBilanPre['GC'];
|
||||
if (!isset($tabBilan['GD1']) && isset($tabBilanPre['GD'])) $tabBilan['GD1']=$tabBilanPre['GD'];
|
||||
if (!isset($tabBilan['GE1']) && isset($tabBilanPre['GE'])) $tabBilan['GE1']=$tabBilanPre['GE'];
|
||||
if (!isset($tabBilan['GF1']) && isset($tabBilanPre['GF'])) $tabBilan['GF1']=$tabBilanPre['GF'];
|
||||
if (!isset($tabBilan['GG1']) && isset($tabBilanPre['GG'])) $tabBilan['GG1']=$tabBilanPre['GG'];
|
||||
if (!isset($tabBilan['GH1']) && isset($tabBilanPre['GH'])) $tabBilan['GH1']=$tabBilanPre['GH'];
|
||||
if (!isset($tabBilan['GI1']) && isset($tabBilanPre['GI'])) $tabBilan['GI1']=$tabBilanPre['GI'];
|
||||
if (!isset($tabBilan['GJ1']) && isset($tabBilanPre['GJ'])) $tabBilan['GJ1']=$tabBilanPre['GJ'];
|
||||
if (!isset($tabBilan['GK1']) && isset($tabBilanPre['GK'])) $tabBilan['GK1']=$tabBilanPre['GK'];
|
||||
if (!isset($tabBilan['GL1']) && isset($tabBilanPre['GL'])) $tabBilan['GL1']=$tabBilanPre['GL'];
|
||||
if (!isset($tabBilan['GM1']) && isset($tabBilanPre['GM'])) $tabBilan['GM1']=$tabBilanPre['GM'];
|
||||
if (!isset($tabBilan['GN1']) && isset($tabBilanPre['GN'])) $tabBilan['GN1']=$tabBilanPre['GN'];
|
||||
if (!isset($tabBilan['GO1']) && isset($tabBilanPre['GO'])) $tabBilan['GO1']=$tabBilanPre['GO'];
|
||||
if (!isset($tabBilan['GP1']) && isset($tabBilanPre['GP'])) $tabBilan['GP1']=$tabBilanPre['GP'];
|
||||
if (!isset($tabBilan['GQ1']) && isset($tabBilanPre['GQ'])) $tabBilan['GQ1']=$tabBilanPre['GQ'];
|
||||
if (!isset($tabBilan['GR1']) && isset($tabBilanPre['GR'])) $tabBilan['GR1']=$tabBilanPre['GR'];
|
||||
if (!isset($tabBilan['GS1']) && isset($tabBilanPre['GS'])) $tabBilan['GS1']=$tabBilanPre['GS'];
|
||||
if (!isset($tabBilan['GT1']) && isset($tabBilanPre['GT'])) $tabBilan['GT1']=$tabBilanPre['GT'];
|
||||
if (!isset($tabBilan['GU1']) && isset($tabBilanPre['GU'])) $tabBilan['GU1']=$tabBilanPre['GU'];
|
||||
if (!isset($tabBilan['GV1']) && isset($tabBilanPre['GV'])) $tabBilan['GV1']=$tabBilanPre['GV'];
|
||||
if (!isset($tabBilan['GW1']) && isset($tabBilanPre['GW'])) $tabBilan['GW1']=$tabBilanPre['GW'];
|
||||
if (!isset($tabBilan['HA1']) && isset($tabBilanPre['HA'])) $tabBilan['HA1']=$tabBilanPre['HA'];
|
||||
if (!isset($tabBilan['HB1']) && isset($tabBilanPre['HB'])) $tabBilan['HB1']=$tabBilanPre['HB'];
|
||||
if (!isset($tabBilan['HC1']) && isset($tabBilanPre['HC'])) $tabBilan['HC1']=$tabBilanPre['HC'];
|
||||
if (!isset($tabBilan['HD1']) && isset($tabBilanPre['HD'])) $tabBilan['HD1']=$tabBilanPre['HD'];
|
||||
if (!isset($tabBilan['HE1']) && isset($tabBilanPre['HE'])) $tabBilan['HE1']=$tabBilanPre['HE'];
|
||||
if (!isset($tabBilan['HF1']) && isset($tabBilanPre['HF'])) $tabBilan['HF1']=$tabBilanPre['HF'];
|
||||
if (!isset($tabBilan['HG1']) && isset($tabBilanPre['HG'])) $tabBilan['HG1']=$tabBilanPre['HG'];
|
||||
if (!isset($tabBilan['HH1']) && isset($tabBilanPre['HH'])) $tabBilan['HH1']=$tabBilanPre['HH'];
|
||||
if (!isset($tabBilan['HI1']) && isset($tabBilanPre['HI'])) $tabBilan['HI1']=$tabBilanPre['HI'];
|
||||
if (!isset($tabBilan['HJ1']) && isset($tabBilanPre['HJ'])) $tabBilan['HJ1']=$tabBilanPre['HJ'];
|
||||
if (!isset($tabBilan['HK1']) && isset($tabBilanPre['HK'])) $tabBilan['HK1']=$tabBilanPre['HK'];
|
||||
if (!isset($tabBilan['HL1']) && isset($tabBilanPre['HL'])) $tabBilan['HL1']=$tabBilanPre['HL'];
|
||||
if (!isset($tabBilan['HM1']) && isset($tabBilanPre['HM'])) $tabBilan['HM1']=$tabBilanPre['HM'];
|
||||
if (!isset($tabBilan['HN1']) && isset($tabBilanPre['HN'])) $tabBilan['HN1']=$tabBilanPre['HN'];
|
||||
if (!isset($tabBilan['HO1']) && isset($tabBilanPre['HO'])) $tabBilan['HO1']=$tabBilanPre['HO'];
|
||||
if (!isset($tabBilan['HY1']) && isset($tabBilanPre['HY'])) $tabBilan['HY1']=$tabBilanPre['HY'];
|
||||
if (!isset($tabBilan['1G1']) && isset($tabBilanPre['1G'])) $tabBilan['1G1']=$tabBilanPre['1G'];
|
||||
if (!isset($tabBilan['HP1']) && isset($tabBilanPre['HP'])) $tabBilan['HP1']=$tabBilanPre['HP'];
|
||||
if (!isset($tabBilan['HQ1']) && isset($tabBilanPre['HQ'])) $tabBilan['HQ1']=$tabBilanPre['HQ'];
|
||||
if (!isset($tabBilan['1H1']) && isset($tabBilanPre['1H'])) $tabBilan['1H1']=$tabBilanPre['1H'];
|
||||
if (!isset($tabBilan['1J1']) && isset($tabBilanPre['1J'])) $tabBilan['1J1']=$tabBilanPre['1J'];
|
||||
if (!isset($tabBilan['1K1']) && isset($tabBilanPre['1K'])) $tabBilan['1K1']=$tabBilanPre['1K'];
|
||||
if (!isset($tabBilan['HX1']) && isset($tabBilanPre['HX'])) $tabBilan['HX1']=$tabBilanPre['HX'];
|
||||
if (!isset($tabBilan['A11']) && isset($tabBilanPre['A1'])) $tabBilan['A11']=$tabBilanPre['A1'];
|
||||
if (!isset($tabBilan['A21']) && isset($tabBilanPre['A2'])) $tabBilan['A21']=$tabBilanPre['A2'];
|
||||
if (!isset($tabBilan['A31']) && isset($tabBilanPre['A3'])) $tabBilan['A31']=$tabBilanPre['A3'];
|
||||
if (!isset($tabBilan['A41']) && isset($tabBilanPre['A4'])) $tabBilan['A41']=$tabBilanPre['A4'];
|
||||
} elseif ($tabBilan['CONSOLIDE']=='S') {
|
||||
// Calcul des chiffres net N-1 si absent 2033
|
||||
if (!isset($tabBilanPre['013']) && (isset($tabBilanPre['010'])||isset($tabBilanPre['012'])))$tabBilanPre['013']=$tabBilanPre['010']-$tabBilanPre['012'];
|
||||
if (!isset($tabBilanPre['017']) && (isset($tabBilanPre['014'])||isset($tabBilanPre['016'])))$tabBilanPre['017']=$tabBilanPre['014']-$tabBilanPre['016'];
|
||||
if (!isset($tabBilanPre['031']) && (isset($tabBilanPre['028'])||isset($tabBilanPre['030'])))$tabBilanPre['031']=$tabBilanPre['028']-$tabBilanPre['030'];
|
||||
if (!isset($tabBilanPre['043']) && (isset($tabBilanPre['040'])||isset($tabBilanPre['042'])))$tabBilanPre['043']=$tabBilanPre['040']-$tabBilanPre['042'];
|
||||
if (!isset($tabBilanPre['049']) && (isset($tabBilanPre['044'])||isset($tabBilanPre['048'])))$tabBilanPre['049']=$tabBilanPre['044']-$tabBilanPre['048'];
|
||||
if (!isset($tabBilanPre['053']) && (isset($tabBilanPre['050'])||isset($tabBilanPre['052'])))$tabBilanPre['053']=$tabBilanPre['050']-$tabBilanPre['052'];
|
||||
if (!isset($tabBilanPre['063']) && (isset($tabBilanPre['060'])||isset($tabBilanPre['062'])))$tabBilanPre['063']=$tabBilanPre['060']-$tabBilanPre['062'];
|
||||
if (!isset($tabBilanPre['067']) && (isset($tabBilanPre['064'])||isset($tabBilanPre['066'])))$tabBilanPre['067']=$tabBilanPre['064']-$tabBilanPre['066'];
|
||||
if (!isset($tabBilanPre['071']) && (isset($tabBilanPre['068'])||isset($tabBilanPre['070'])))$tabBilanPre['071']=$tabBilanPre['068']-$tabBilanPre['070'];
|
||||
if (!isset($tabBilanPre['075']) && (isset($tabBilanPre['072'])||isset($tabBilanPre['074'])))$tabBilanPre['075']=$tabBilanPre['072']-$tabBilanPre['074'];
|
||||
if (!isset($tabBilanPre['083']) && (isset($tabBilanPre['080'])||isset($tabBilanPre['082'])))$tabBilanPre['083']=$tabBilanPre['080']-$tabBilanPre['082'];
|
||||
if (!isset($tabBilanPre['087']) && (isset($tabBilanPre['084'])||isset($tabBilanPre['086'])))$tabBilanPre['087']=$tabBilanPre['084']-$tabBilanPre['086'];
|
||||
if (!isset($tabBilanPre['091']) && (isset($tabBilanPre['088'])||isset($tabBilanPre['090'])))$tabBilanPre['091']=$tabBilanPre['088']-$tabBilanPre['090'];
|
||||
if (!isset($tabBilanPre['095']) && (isset($tabBilanPre['092'])||isset($tabBilanPre['094'])))$tabBilanPre['095']=$tabBilanPre['092']-$tabBilanPre['094'];
|
||||
if (!isset($tabBilanPre['099']) && (isset($tabBilanPre['096'])||isset($tabBilanPre['098'])))$tabBilanPre['099']=$tabBilanPre['096']-$tabBilanPre['098'];
|
||||
if (!isset($tabBilanPre['113']) && (isset($tabBilanPre['110'])||isset($tabBilanPre['112'])))$tabBilanPre['113']=$tabBilanPre['110']-$tabBilanPre['112'];
|
||||
// Récupération des chiffres N-1 si absent du bilan N
|
||||
// ACTIF 2033
|
||||
if (!isset($tabBilan['N00']) && isset($tabBilanPre['013'])) $tabBilan['N00']=$tabBilanPre['013'];
|
||||
if (!isset($tabBilan['N01']) && isset($tabBilanPre['017'])) $tabBilan['N01']=$tabBilanPre['017'];
|
||||
if (!isset($tabBilan['N02']) && isset($tabBilanPre['031'])) $tabBilan['N02']=$tabBilanPre['031'];
|
||||
if (!isset($tabBilan['N03']) && isset($tabBilanPre['043'])) $tabBilan['N03']=$tabBilanPre['043'];
|
||||
if (!isset($tabBilan['N04']) && isset($tabBilanPre['049'])) $tabBilan['N04']=$tabBilanPre['049'];
|
||||
if (!isset($tabBilan['N05']) && isset($tabBilanPre['053'])) $tabBilan['N05']=$tabBilanPre['053'];
|
||||
if (!isset($tabBilan['N06']) && isset($tabBilanPre['063'])) $tabBilan['N06']=$tabBilanPre['063'];
|
||||
if (!isset($tabBilan['N07']) && isset($tabBilanPre['067'])) $tabBilan['N07']=$tabBilanPre['067'];
|
||||
if (!isset($tabBilan['N08']) && isset($tabBilanPre['071'])) $tabBilan['N08']=$tabBilanPre['071'];
|
||||
if (!isset($tabBilan['N09']) && isset($tabBilanPre['075'])) $tabBilan['N09']=$tabBilanPre['075'];
|
||||
if (!isset($tabBilan['N10']) && isset($tabBilanPre['083'])) $tabBilan['N10']=$tabBilanPre['083'];
|
||||
if (!isset($tabBilan['N11']) && isset($tabBilanPre['087'])) $tabBilan['N11']=$tabBilanPre['087'];
|
||||
if (!isset($tabBilan['N12']) && isset($tabBilanPre['091'])) $tabBilan['N12']=$tabBilanPre['091'];
|
||||
if (!isset($tabBilan['N13']) && isset($tabBilanPre['095'])) $tabBilan['N13']=$tabBilanPre['095'];
|
||||
if (!isset($tabBilan['N14']) && isset($tabBilanPre['099'])) $tabBilan['N14']=$tabBilanPre['099'];
|
||||
if (!isset($tabBilan['N15']) && isset($tabBilanPre['113'])) $tabBilan['N15']=$tabBilanPre['113'];
|
||||
// PASSIF 2033
|
||||
if (!isset($tabBilan['N16']) && isset($tabBilanPre['120'])) $tabBilan['N16']=$tabBilanPre['120'];
|
||||
if (!isset($tabBilan['N17']) && isset($tabBilanPre['124'])) $tabBilan['N17']=$tabBilanPre['124'];
|
||||
if (!isset($tabBilan['N18']) && isset($tabBilanPre['126'])) $tabBilan['N18']=$tabBilanPre['126'];
|
||||
if (!isset($tabBilan['N19']) && isset($tabBilanPre['130'])) $tabBilan['N19']=$tabBilanPre['130'];
|
||||
if (!isset($tabBilan['N20']) && isset($tabBilanPre['132'])) $tabBilan['N20']=$tabBilanPre['132'];
|
||||
if (!isset($tabBilan['N21']) && isset($tabBilanPre['134'])) $tabBilan['N21']=$tabBilanPre['134'];
|
||||
if (!isset($tabBilan['N22']) && isset($tabBilanPre['136'])) $tabBilan['N22']=$tabBilanPre['136'];
|
||||
if (!isset($tabBilan['N23']) && isset($tabBilanPre['140'])) $tabBilan['N23']=$tabBilanPre['140'];
|
||||
if (!isset($tabBilan['N24']) && isset($tabBilanPre['142'])) $tabBilan['N24']=$tabBilanPre['142'];
|
||||
if (!isset($tabBilan['N25']) && isset($tabBilanPre['154'])) $tabBilan['N25']=$tabBilanPre['154'];
|
||||
if (!isset($tabBilan['N26']) && isset($tabBilanPre['156'])) $tabBilan['N26']=$tabBilanPre['156'];
|
||||
if (!isset($tabBilan['N27']) && isset($tabBilanPre['164'])) $tabBilan['N27']=$tabBilanPre['164'];
|
||||
if (!isset($tabBilan['N28']) && isset($tabBilanPre['166'])) $tabBilan['N28']=$tabBilanPre['166'];
|
||||
if (!isset($tabBilan['N29']) && isset($tabBilanPre['172'])) $tabBilan['N29']=$tabBilanPre['172'];
|
||||
if (!isset($tabBilan['N30']) && isset($tabBilanPre['174'])) $tabBilan['N30']=$tabBilanPre['174'];
|
||||
if (!isset($tabBilan['N31']) && isset($tabBilanPre['176'])) $tabBilan['N31']=$tabBilanPre['176'];
|
||||
if (!isset($tabBilan['N32']) && isset($tabBilanPre['180'])) $tabBilan['N32']=$tabBilanPre['180'];
|
||||
// COMPTE DE RESULTAT 2033
|
||||
if (!isset($tabBilan['N33']) && isset($tabBilanPre['210'])) $tabBilan['N33']=$tabBilanPre['210'];
|
||||
if (!isset($tabBilan['N34']) && isset($tabBilanPre['214'])) $tabBilan['N34']=$tabBilanPre['214'];
|
||||
if (!isset($tabBilan['N35']) && isset($tabBilanPre['218'])) $tabBilan['N35']=$tabBilanPre['218'];
|
||||
if (!isset($tabBilan['N36']) && isset($tabBilanPre['222'])) $tabBilan['N36']=$tabBilanPre['222'];
|
||||
if (!isset($tabBilan['N37']) && isset($tabBilanPre['224'])) $tabBilan['N37']=$tabBilanPre['224'];
|
||||
if (!isset($tabBilan['N38']) && isset($tabBilanPre['226'])) $tabBilan['N38']=$tabBilanPre['226'];
|
||||
if (!isset($tabBilan['N39']) && isset($tabBilanPre['230'])) $tabBilan['N39']=$tabBilanPre['230'];
|
||||
if (!isset($tabBilan['N40']) && isset($tabBilanPre['232'])) $tabBilan['N40']=$tabBilanPre['232'];
|
||||
if (!isset($tabBilan['N41']) && isset($tabBilanPre['234'])) $tabBilan['N41']=$tabBilanPre['234'];
|
||||
if (!isset($tabBilan['N42']) && isset($tabBilanPre['236'])) $tabBilan['N42']=$tabBilanPre['236'];
|
||||
if (!isset($tabBilan['N43']) && isset($tabBilanPre['238'])) $tabBilan['N43']=$tabBilanPre['238'];
|
||||
if (!isset($tabBilan['N44']) && isset($tabBilanPre['240'])) $tabBilan['N44']=$tabBilanPre['240'];
|
||||
if (!isset($tabBilan['N45']) && isset($tabBilanPre['242'])) $tabBilan['N45']=$tabBilanPre['242'];
|
||||
if (!isset($tabBilan['N46']) && isset($tabBilanPre['244'])) $tabBilan['N46']=$tabBilanPre['244'];
|
||||
if (!isset($tabBilan['N47']) && isset($tabBilanPre['250'])) $tabBilan['N47']=$tabBilanPre['250'];
|
||||
if (!isset($tabBilan['N48']) && isset($tabBilanPre['252'])) $tabBilan['N48']=$tabBilanPre['252'];
|
||||
if (!isset($tabBilan['N49']) && isset($tabBilanPre['254'])) $tabBilan['N49']=$tabBilanPre['254'];
|
||||
if (!isset($tabBilan['N50']) && isset($tabBilanPre['256'])) $tabBilan['N50']=$tabBilanPre['256'];
|
||||
if (!isset($tabBilan['N51']) && isset($tabBilanPre['262'])) $tabBilan['N51']=$tabBilanPre['262'];
|
||||
if (!isset($tabBilan['N52']) && isset($tabBilanPre['264'])) $tabBilan['N52']=$tabBilanPre['264'];
|
||||
if (!isset($tabBilan['N53']) && isset($tabBilanPre['270'])) $tabBilan['N53']=$tabBilanPre['270'];
|
||||
if (!isset($tabBilan['N54']) && isset($tabBilanPre['280'])) $tabBilan['N54']=$tabBilanPre['280'];
|
||||
if (!isset($tabBilan['N55']) && isset($tabBilanPre['290'])) $tabBilan['N55']=$tabBilanPre['290'];
|
||||
if (!isset($tabBilan['N56']) && isset($tabBilanPre['294'])) $tabBilan['N56']=$tabBilanPre['294'];
|
||||
if (!isset($tabBilan['N57']) && isset($tabBilanPre['300'])) $tabBilan['N57']=$tabBilanPre['300'];
|
||||
if (!isset($tabBilan['N58']) && isset($tabBilanPre['306'])) $tabBilan['N58']=$tabBilanPre['306'];
|
||||
if (!isset($tabBilan['N59']) && isset($tabBilanPre['310'])) $tabBilan['N59']=$tabBilanPre['310'];
|
||||
} elseif ($tabBilan['CONSOLIDE']=='A' || $tabBilan['CONSOLIDE']=='B') {
|
||||
// BANQUES
|
||||
if (!isset($tabBilan['NA1']) && isset($tabBilanPre['AA1'])) $tabBilan['NA1']=$tabBilanPre['AA1'];
|
||||
if (!isset($tabBilan['NA2']) && isset($tabBilanPre['AA2'])) $tabBilan['NA2']=$tabBilanPre['AA2'];
|
||||
if (!isset($tabBilan['NA3']) && isset($tabBilanPre['AA3'])) $tabBilan['NA3']=$tabBilanPre['AA3'];
|
||||
if (!isset($tabBilan['NP1']) && isset($tabBilanPre['AP1'])) $tabBilan['NP1']=$tabBilanPre['AP1'];
|
||||
if (!isset($tabBilan['NP2']) && isset($tabBilanPre['AP2'])) $tabBilan['NP2']=$tabBilanPre['AP2'];
|
||||
if (!isset($tabBilan['NP3']) && isset($tabBilanPre['AP3'])) $tabBilan['NP3']=$tabBilanPre['AP3'];
|
||||
if (!isset($tabBilan['NP4']) && isset($tabBilanPre['AP4'])) $tabBilan['NP4']=$tabBilanPre['AP4'];
|
||||
if (!isset($tabBilan['NP5']) && isset($tabBilanPre['AP5'])) $tabBilan['NP5']=$tabBilanPre['AP5'];
|
||||
if (!isset($tabBilan['NP6']) && isset($tabBilanPre['AP6'])) $tabBilan['NP6']=$tabBilanPre['AP6'];
|
||||
if (!isset($tabBilan['NP7']) && isset($tabBilanPre['AP7'])) $tabBilan['NP7']=$tabBilanPre['AP7'];
|
||||
if (!isset($tabBilan['NP8']) && isset($tabBilanPre['AP8'])) $tabBilan['NP8']=$tabBilanPre['AP8'];
|
||||
if (!isset($tabBilan['NP9']) && isset($tabBilanPre['AP9'])) $tabBilan['NP9']=$tabBilanPre['AP9'];
|
||||
if (!isset($tabBilan['NR1']) && isset($tabBilanPre['AR1'])) $tabBilan['NR1']=$tabBilanPre['AR1'];
|
||||
if (!isset($tabBilan['NR2']) && isset($tabBilanPre['AR2'])) $tabBilan['NR2']=$tabBilanPre['AR2'];
|
||||
if (!isset($tabBilan['NR3']) && isset($tabBilanPre['AR3'])) $tabBilan['NR3']=$tabBilanPre['AR3'];
|
||||
// ASSURANCE
|
||||
if (!isset($tabBilan['NR4']) && isset($tabBilanPre['AR4'])) $tabBilan['AR4']=$tabBilanPre['AR4'];
|
||||
}
|
||||
}
|
||||
return $tabBilan;
|
||||
}
|
||||
|
||||
|
||||
function bilanSimplifie2Normal($bilanRS) {
|
||||
|
||||
$tabBS2BN=array('AH'=>'010',
|
||||
'AI'=>'012',
|
||||
'AI1'=>'013',
|
||||
'AJ'=>'014',
|
||||
'AK'=>'016',
|
||||
'AK1'=>'017',
|
||||
'AT'=>'028',
|
||||
'AU'=>'030',
|
||||
'AU1'=>'031',
|
||||
'BH'=>'040',
|
||||
'BI'=>'042',
|
||||
'BI1'=>'043',
|
||||
'BJ'=>'044',
|
||||
'BK'=>'048',
|
||||
'BK1'=>'049',
|
||||
'BL'=>'050',
|
||||
'BM'=>'052',
|
||||
'BM1'=>'053',
|
||||
'BT'=>'060',
|
||||
'BU'=>'062',
|
||||
'BU1'=>'063',
|
||||
'BV'=>'064',
|
||||
'BW'=>'066',
|
||||
'BW1'=>'067',
|
||||
'BX'=>'068',
|
||||
'BY'=>'070',
|
||||
'BY1'=>'071',
|
||||
'BZ'=>'072',
|
||||
'CA'=>'074',
|
||||
'CA1'=>'075',
|
||||
'CD'=>'080',
|
||||
'CE'=>'082',
|
||||
'CE1'=>'083',
|
||||
'CF'=>'084',
|
||||
'CG'=>'086',
|
||||
'CG1'=>'087',
|
||||
'CH'=>'092',
|
||||
'CI'=>'094',
|
||||
'CI1'=>'095',
|
||||
'CJ'=>'096',
|
||||
'CK'=>'098',
|
||||
'CK1'=>'099',
|
||||
'CO'=>'110',
|
||||
'1A'=>'112',
|
||||
'1A1'=>'113',
|
||||
'DA'=>'120',
|
||||
'DC'=>'124',
|
||||
'DD'=>'126',
|
||||
'DF'=>'130',
|
||||
'DG'=>'132',
|
||||
'DH'=>'134',
|
||||
'DI'=>'136',
|
||||
'DK'=>'140',
|
||||
'DL'=>'142',
|
||||
'DR'=>'154',
|
||||
'DP'=>'154',
|
||||
'DU'=>'156',
|
||||
'DV'=>'169',
|
||||
'DW'=>'164',
|
||||
'DX'=>'166',
|
||||
'EA'=>'172-169',
|
||||
'EB'=>'174',
|
||||
'EC'=>'176',
|
||||
'EE'=>'180',
|
||||
'EH'=>'156-195',
|
||||
'FA'=>'210-209',
|
||||
'FB'=>'209',
|
||||
'FC'=>'210',
|
||||
'FD'=>'214-215',
|
||||
'FE'=>'215',
|
||||
'FF'=>'214',
|
||||
'FH'=>'217',
|
||||
'FI'=>'218',
|
||||
'FK'=>'209+215+217',
|
||||
'FL'=>'210+214+218',
|
||||
'FM'=>'222',
|
||||
'FN'=>'224',
|
||||
'FO'=>'226',
|
||||
'FQ'=>'230',
|
||||
'FR'=>'232',
|
||||
'FS'=>'234',
|
||||
'FT'=>'236',
|
||||
'FU'=>'238',
|
||||
'FV'=>'240',
|
||||
'FW'=>'242',
|
||||
'FX'=>'244',
|
||||
'FY'=>'250',
|
||||
'FZ'=>'252',
|
||||
'GA'=>'254',
|
||||
'GE'=>'262',
|
||||
'GF'=>'264',
|
||||
'GG'=>'270',
|
||||
'GP'=>'280',
|
||||
'GU'=>'294',
|
||||
'GW'=>'270+280+294',
|
||||
'HD'=>'290',
|
||||
'HH'=>'300',
|
||||
'HI'=>'290-300',
|
||||
'HK'=>'306',
|
||||
'HL'=>'232+280+290',
|
||||
'HM'=>'264+294+300+306',
|
||||
'HN'=>'310',
|
||||
'YY'=>'374',
|
||||
'YZ'=>'378',
|
||||
'YP'=>'376',
|
||||
);
|
||||
|
||||
$bilanRN=array();
|
||||
foreach ($tabBS2BN as $posteRN => $formule) {
|
||||
if (preg_match('/\+|\-/', $formule)) {
|
||||
$tabTmp=preg_split('/\+|\-/', $formule, -1, PREG_SPLIT_OFFSET_CAPTURE);
|
||||
//$bilanRN[$posteRN]=0;
|
||||
$scalc='';
|
||||
foreach ($tabTmp as $i=>$tab) {
|
||||
if ($i==0) {
|
||||
$bilanRN[$posteRN]=$bilanRS[$tab[0]];
|
||||
$scalc.=$bilanRS[$tab[0]];
|
||||
}
|
||||
else {
|
||||
$signe=$formule[$tab[1]-1];
|
||||
$scalc.=$signe;
|
||||
if ($signe=='+') $bilanRN[$posteRN]+=$bilanRS[$tab[0]];
|
||||
elseif ($signe=='-') $bilanRN[$posteRN]-=$bilanRS[$tab[0]];
|
||||
$scalc.=$bilanRS[$tab[0]];
|
||||
}
|
||||
}
|
||||
$bilanRN[$posteRN]=$bilanRN[$posteRN];
|
||||
}
|
||||
else $bilanRN[$posteRN]=$bilanRS[$formule];
|
||||
}
|
||||
if ($bilanRS['240']<>0) {
|
||||
$bilanRN['BL']=$bilanRS['050'];
|
||||
$bilanRN['BM']=$bilanRS['052'];
|
||||
} else {
|
||||
$bilanRN['BN']=$bilanRS['050'];
|
||||
$bilanRN['BO']=$bilanRS['052'];
|
||||
}
|
||||
|
||||
if ($bilanRS['070']<>0 || $bilanRS['074']<>0 || $bilanRS['052']<>0 || $bilanRS['062']<>0)
|
||||
$bilanRN['GC']=$bilanRS['256'];
|
||||
elseif ($bilanRS['070']==0 && $bilanRS['074']==0 && $bilanRS['052']==0 && $bilanRS['062']==0 && $bilanRS['254']<>0)
|
||||
$bilanRN['GD']=$bilanRS['256'];
|
||||
|
||||
if ($bilanRS['584']<>0) {
|
||||
$bilanRN['HB']=$bilanRS['584'];
|
||||
$bilanRN['HA']=$bilanRS['290']-$bilanRS['584'];
|
||||
} else
|
||||
$bilanRN['HA']=$bilanRS['290'];
|
||||
|
||||
if ($bilanRS['582']<>0) {
|
||||
$bilanRN['HF']=$bilanRS['582'];
|
||||
$bilanRN['HE']=$bilanRS['582']-$bilanRS['300'];
|
||||
} else
|
||||
$bilanRN['HE']=$bilanRS['300'];
|
||||
|
||||
return $bilanRN;
|
||||
}
|
||||
}
|
||||
?>
|
287
library/Metier/partenaires/classMBilansBil.php
Normal file
287
library/Metier/partenaires/classMBilansBil.php
Normal file
@ -0,0 +1,287 @@
|
||||
<?
|
||||
require_once 'framework/common/curl.php';
|
||||
|
||||
class MBilans {
|
||||
|
||||
private $body = '';
|
||||
private $header = '';
|
||||
private $codeRetour = 0;
|
||||
private $cookie='';
|
||||
private $reference = 0;
|
||||
private $timeOut=0;
|
||||
private $url='';
|
||||
private $referer='';
|
||||
private $curPage='';
|
||||
|
||||
public $siren;
|
||||
public $dernierExerciceDepose=0;
|
||||
public $dernierExerciceDeposeLe=0;
|
||||
|
||||
function __construct($siren) {
|
||||
$this->partGetSession();
|
||||
$this->siren=$siren;
|
||||
}
|
||||
|
||||
function __destruct() {
|
||||
$this->partSaveSession();
|
||||
}
|
||||
|
||||
|
||||
function listeBilans($uniquementEnBase=true) {
|
||||
//if ($siren<>0) $this->siren=$siren;
|
||||
$iDb2=new WDB('insee');
|
||||
$ret=$iDb2->select( 'bilans', 'dateProvPartenaire, dateExercice, dateExercicePre, dureeExercice, dureeExercicePre, monnaieOrigine',
|
||||
"siren='$this->siren' ORDER BY dateExercice DESC");
|
||||
// if (count($ret)==0) return array(); // Pas de bilan disponible !
|
||||
// else {
|
||||
$tabRet=array();
|
||||
if (!$uniquementEnBase) {
|
||||
$iDb=new WDB('jo');
|
||||
$ret2=$iDb->select( 'bodacc_detail', 'Bodacc_Date_Parution, dateEffet, Bodacc_Num, Bodacc_Date_Parution, Num_Annonce, RC, raisonSociale, FJ, adrSiegeNum, adrSiegeIndRep, adrSiegeTypVoie, adrSiegeLibVoie, adrSiegeComp1, adrSiegeComp2, codePostalSiege, villeSiege', "siren='$this->siren' AND Rubrique='comptes' ORDER BY dateEffet DESC");
|
||||
$dateDerDepot=WDate::dateT('Y-m-d','Ymd',@$ret2[0]['dateEffet'])*1;
|
||||
$dateDerExercice=$ret[0]['dateExercice']*1;
|
||||
if ($dateDerDepot<>0) {
|
||||
$this->dernierExerciceDepose = WDate::dateT('Y-m-d','d/m/Y',@$ret2[0]['dateEffet']);
|
||||
$this->dernierExerciceDeposeLe = WDate::dateT('Y-m-d','d/m/Y',@$ret2[0]['Bodacc_Date_Parution']);
|
||||
}
|
||||
echo date('Y/m/d - H:i:s') ." - Dernier depot le ". $ret2[0]['Bodacc_Date_Parution'] .", dernier en base = $dateDerExercice !<br/>\n";
|
||||
if ( $dateDerDepot>$dateDerExercice ||
|
||||
( $dateDerDepot==0 && $dateDerExercice<date('Ymd', mktime(0,0,0, date('m')-16, date('d'), date('Y'))) ) ) {
|
||||
$tabRet=$this->partListeBilans();
|
||||
}
|
||||
}
|
||||
foreach ($ret as $i=>$bil) {
|
||||
$tabRet[$bil['dateExercice']]=array('dateProvPartenaire'=>$bil['dateProvPartenaire'],
|
||||
'dureeExercice' =>$bil['dureeExercice'],
|
||||
'dateExercicePre' =>$bil['dateExercicePre'],
|
||||
'dureeExercicePre' =>$bil['dureeExercicePre'],
|
||||
'monnaie' =>$bil['monnaieOrigine'],
|
||||
'source' =>1,
|
||||
);
|
||||
}
|
||||
return $tabRet;
|
||||
// }
|
||||
}
|
||||
|
||||
function getBilan($millesime='', $source=1) {
|
||||
|
||||
$iDb2=new WDB('insee');
|
||||
$ret=$iDb2->select('bilans', 'dateProvPartenaire, dateExercice, dateExercicePre, dureeExercice, dureeExercicePre, monnaie, typeBilan, monnaieOrigine, unite, postes', "siren='$this->siren' AND dateExercice='$millesime'", true);
|
||||
/*echo $this->siren.'<br/>';
|
||||
echo $millesime.'<br/>';
|
||||
print_r($ret[0]);die();*/
|
||||
$bilan=$ret[0];
|
||||
if (count($ret)==0) {
|
||||
$tabBilan=$this->partGetBilan(WDate::dateT('Ymd','d/m/Y',$millesime));
|
||||
if ($tabBilan) {
|
||||
$tabInsert=array( 'siren' =>$this->siren,
|
||||
'dateProvPartenaire'=>$tabBilan['DATE_FRAICHE_BILAN'],
|
||||
'dateExercice' =>$tabBilan['DATE_CLOTURE'],
|
||||
'dateExercicePre' =>$tabBilan['DATE_CLOTURE_PRE'],
|
||||
'dureeExercice' =>$tabBilan['DUREE_MOIS'],
|
||||
'dureeExercicePre' =>$tabBilan['DUREE_MOIS_PRE'],
|
||||
'monnaie' =>$tabBilan['MONNAIE'],
|
||||
'typeBilan' =>$tabBilan['CONSOLIDE'],
|
||||
'monnaieOrigine' =>$tabBilan['MONNAIE_ORI'],
|
||||
'unite' =>$tabBilan['MONNAIE_LIV_UNITE'],
|
||||
'postes' =>$tabBilan['POSTES'],
|
||||
'partenaire' =>1,
|
||||
);
|
||||
$iDb2->insert('bilans', $tabInsert);
|
||||
$ret=$iDb2->select('bilans', 'dateProvPartenaire, dateExercice, dateExercicePre, dureeExercice, dureeExercicePre, monnaie, typeBilan, monnaieOrigine, unite, postes', "siren='$this->siren' AND dateExercice='$millesime'");
|
||||
$bilan=$ret[0];
|
||||
}
|
||||
}
|
||||
$tabBilan=array();
|
||||
$tabBilan['SIREN'] = $this->siren;
|
||||
$tabBilan['DATE_FRAICHE_BILAN'] = $bilan['dateProvPartenaire']; // SSAAMMJJ
|
||||
$tabBilan['DATE_CLOTURE'] = $bilan['dateExercice']; // SSAAMMJJ
|
||||
$tabBilan['DATE_CLOTURE_PRE'] = $bilan['dateExercicePre']; // SSAAMMJJ
|
||||
$tabBilan['DUREE_MOIS'] = $bilan['dureeExercice'];
|
||||
$tabBilan['DUREE_MOIS_PRE'] = $bilan['dureeExercicePre'];
|
||||
$tabBilan['MONNAIE'] = $bilan['monnaie'];
|
||||
$tabBilan['CONSOLIDE'] = $bilan['typeBilan']; // C = Bilan consolidé
|
||||
$tabBilan['MONNAIE_ORI'] = $bilan['monnaieOrigine'];
|
||||
$tabBilan['MONNAIE_LIV_UNITE'] = $bilan['unite'];
|
||||
if ($bilan['monnaie']=='EUR') $monnaie='€'; else $monnaie=$bilan['monnaie'];
|
||||
switch (strtoupper($bilan['unite'])) {
|
||||
case 'K': $unite='K'; break;
|
||||
case 'U':
|
||||
case ' ':
|
||||
case '' : $unite=''; break;
|
||||
case 'M': $unite='M'; break;
|
||||
default: die('Unite Bilan ('. $bilan['unite'] .') non prise en charge !'); break;
|
||||
}
|
||||
$tabBilan['devise'] = /*$unite.*/$monnaie;
|
||||
|
||||
$tabTmp=explode(';', $bilan['postes']);
|
||||
foreach ($tabTmp as $i=>$strTmp) {
|
||||
$tabTmp2=explode('=', $strTmp);
|
||||
if (isset($tabTmp2[1]))
|
||||
if ($unite=='K' && $tabTmp2[0]<>'YP') $tabBilan[$tabTmp2[0]]=$tabTmp2[1]*1000;
|
||||
elseif ($unite=='M' && $tabTmp2[0]<>'YP') $tabBilan[$tabTmp2[0]]=$tabTmp2[1]*1000000;
|
||||
else $tabBilan[$tabTmp2[0]]=$tabTmp2[1];
|
||||
}
|
||||
return $tabBilan;
|
||||
}
|
||||
|
||||
private function partConnection() {
|
||||
if (!$this->cookie || time()>$this->timeOut) {
|
||||
$this->timeOut=time()+600;
|
||||
/** Recherche de machine dispo **/
|
||||
$this->referer='http://hyperbil.bil.fr/';
|
||||
$page=getUrl($this->referer, '', '', '', false, 'hyperbil.bil.fr');
|
||||
$this->body=$page['body'];
|
||||
$this->codeRetour=$page['code'];
|
||||
$this->header=$page['header'];
|
||||
|
||||
/** Redirection sur la bonne machine**/
|
||||
$this->url=trim(str_replace('https://', 'http://', $this->header['Location']));
|
||||
if (substr($this->url,-1)=='/') $this->url=substr($this->url, 0, strlen($this->url)-1);
|
||||
|
||||
$this->domaine=str_replace('/', '', str_replace('http:/', '', $this->url));
|
||||
//echo "Redirection sur $this->url<br/>Domaine = $this->domaine<br/>Referer = $this->referer<br/>";
|
||||
$page=getUrl($this->url, '', '', $this->referer, false, $this->domaine);
|
||||
$this->body=$page['body'];
|
||||
$this->codeRetour=$page['code'];
|
||||
$this->header=$page['header'];
|
||||
|
||||
/** Connexion LOGIN PASSWORD **/
|
||||
//print_r($this->header);
|
||||
$this->cookie=$this->header['Set-Cookie'];
|
||||
$postData=array('rq'=>'hbilabon', 'QPABO'=>'101001002', 'QPPAS'=>'otY66');
|
||||
$urlConn=$this->url.'/cgi-bin/h2r';
|
||||
//echo "Connexion à $urlConn<br/>";
|
||||
$page=getUrl($urlConn, $this->cookie, $postData, $this->url, false, $this->domaine);
|
||||
$this->body=$page['body'];
|
||||
$this->codeRetour=$page['code'];
|
||||
$this->header=$page['header'];
|
||||
$this->cookie=$this->header['Set-Cookie'];
|
||||
|
||||
/** Base entreprise **/
|
||||
// print_r($this->header);
|
||||
$urlEntrep=$this->url.'/cgi-bin/h2r?rq=hbilcrit&QPABO=101001002';///cgi-bin/h2r?rq=hbilcrit"
|
||||
sleep(1);
|
||||
$page=getUrl($urlEntrep, $this->cookie, '', $this->url, false, $this->domaine);
|
||||
$this->body=$page['body'];
|
||||
$this->codeRetour=$page['code'];
|
||||
$this->header=$page['header'];
|
||||
}
|
||||
}
|
||||
|
||||
private function partVitrine() {
|
||||
//echo "Recherche du siren $this->siren<br/>\n";
|
||||
$this->partConnection();
|
||||
|
||||
/** Liste des établissements **/
|
||||
$urlEntrep=$this->url .'/cgi-bin/h2r?rq=hbilentl&QEREC=B&QESIR='.$this->siren
|
||||
.'&QENOM=&QEPRN=&QENAIA=&QENAIM=&QECP=&QESIEG=A&QEVIL=&QENRU=&QERUE=&QEAPE=&QETEL=&QENAOB&wi=1';
|
||||
/* QESIEG :
|
||||
"" = Tous les étab
|
||||
"A" = Dernier Siège Actif connu
|
||||
"S" = Historique des Sièges
|
||||
"E" = Historique des établissements secondaires
|
||||
*/
|
||||
//sleep(1);
|
||||
$page=getUrl($urlEntrep, $this->cookie, '', $this->url, false, $this->domaine);
|
||||
$bil=$page['body'];
|
||||
preg_match_all('/"\/cgi-bin\/h2r\?rq=hbiliden&QINUME=(\d*)&QISIR=(\d*)&(.*)"/', $bil, $matches);
|
||||
//print_r($matches);
|
||||
/** Fiche d'identité du siège **/
|
||||
$urlEntrep=$url. str_replace('"', '', $matches[0][0]);
|
||||
sleep(1);
|
||||
$page=getUrl($urlEntrep, $this->cookie, '', $this->url, false, $this->domaine);
|
||||
$bil=$page['body'];
|
||||
$this->reference=$matches[1][0];
|
||||
//echo "QINUME = $this->reference<br/>\n";
|
||||
}
|
||||
|
||||
private function partListeBilans() {
|
||||
$this->partVitrine();
|
||||
$urlEntrep=$this->url."/cgi-bin/h2r?rq=hbilbill&QINUME=$this->reference&QISIR=$this->siren&wi=1&wc=N";
|
||||
$page=getUrl($urlEntrep, $this->cookie, '', $this->url, false, $this->domaine);
|
||||
echo date('Y/m/d - H:i:s') ." - Liste des bilans de notre partenaire : $urlEntrep<br/>\n";
|
||||
$tabRet=array();
|
||||
if (preg_match_all("/NAME=\"QBDTCN\" VALUE=\"(.*)\"><B>(?:.*)Durée : <B>(.*) mois/i", $page['body'], $matches)) {
|
||||
foreach ($matches[1] as $num=>$millesime) {
|
||||
$millesime=WDate::dateT('d/m/Y','Ymd',$millesime);
|
||||
$tabRet[$millesime]=array( 'dateProvPartenaire'=>date('Ymd'),
|
||||
'dureeExercice' =>$matches[2][$num],
|
||||
'dateExercicePre' =>WDate::dateT('d/m/Y','Ymd',$matches[1][$num+1]),
|
||||
'dureeExercicePre' =>$matches[2][$num+1],
|
||||
'monnaie' =>'EUR',
|
||||
'source' =>0,
|
||||
);
|
||||
}
|
||||
}
|
||||
return $tabRet;
|
||||
}
|
||||
|
||||
private function partGetBilan($millesime) {
|
||||
$this->partConnection();
|
||||
|
||||
$urlEntrep=$this->url."/cgi-bin/h2r?rq=hbilsobi&QINUME=$this->reference&QISIR=$this->siren&wi=1&wc=N&QIMONN=EU&QIDLIM=".urlencode($millesime);
|
||||
|
||||
$page=getUrl($urlEntrep, $this->cookie, '', $this->url, false, $this->domaine);
|
||||
echo date('Y/m/d - H:i:s') ." - Bilan $millesime de notre partenaire : $urlEntrep<br/>\n";
|
||||
|
||||
$bil=strip_tags($page['body']);
|
||||
$fcontents=explode("\n",$bil);
|
||||
$tabBilan=array();
|
||||
$i=1;
|
||||
$tabBilan['SIRET'] =substr($fcontents[1], 36, 14);
|
||||
$tabBilan['DATE_FRAICHE_BILAN'] =trim(substr($fcontents[1], 57, 8)); // SSAAMMJJ
|
||||
if ($tabBilan['DATE_FRAICHE_BILAN']=='') return false;
|
||||
$tabBilan['DATE_CLOTURE'] =trim(substr($fcontents[1], 101, 8)); // SSAAMMJJ
|
||||
$tabBilan['DATE_CLOTURE_PRE'] =trim(substr($fcontents[1], 109, 8)); // SSAAMMJJ
|
||||
$tabBilan['DUREE_MOIS'] =trim(substr($fcontents[1], 117, 2));
|
||||
$tabBilan['DUREE_MOIS_PRE'] =trim(substr($fcontents[1], 119, 2));
|
||||
$type =trim(substr($fcontents[1], 123, 1)); // C = Bilan consolidé
|
||||
if ($type=='') $tabBilan['CONSOLIDE']='N';
|
||||
elseif ($type=='C') $tabBilan['CONSOLIDE']='C';
|
||||
else { $tabBilan['CONSOLIDE']=$type;
|
||||
echo ("Type de bilan inconnu en provenance de notre partenaire B='$type' !");
|
||||
}
|
||||
$tabBilan['MONNAIE_ORI'] =trim(substr($fcontents[1], 793, 3));
|
||||
$tabBilan['MONNAIE_UNITE'] =trim(substr($fcontents[1], 796, 1));
|
||||
$tabBilan['MONNAIE'] =trim(substr($fcontents[1], 797, 3));
|
||||
$tabBilan['POSTES'] ='';
|
||||
|
||||
while (substr($fcontents[$i], 65, 1)=='7') {
|
||||
for ($j=0; $j<30; $j++)
|
||||
{
|
||||
$code =rtrim(substr($fcontents[$i], 124+$j*20, 4));
|
||||
if ($code!='')
|
||||
{
|
||||
$colonneLiasse=(int)substr($code,2,1);
|
||||
$signe =substr($fcontents[$i], 128+$j*20, 1);
|
||||
$valeur =(double)substr($fcontents[$i], 129+$j*20, 15);
|
||||
if ($signe=='-')
|
||||
$valeur*=-1;
|
||||
$tabBilan['POSTES'].="$code=$valeur;";
|
||||
//$tabBilan['POSTES'][$code]=$valeur;
|
||||
}
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
return $tabBilan;
|
||||
}
|
||||
|
||||
private function partSaveSession() {
|
||||
$fp=fopen('/tmp/php_bil_session.id', 'w');
|
||||
fwrite($fp,$this->cookie.'^'.$this->timeOut.'^'.$this->url.'^'.$this->siren.'^'.$this->reference);
|
||||
fclose($fp);
|
||||
}
|
||||
|
||||
private function partGetSession() {
|
||||
$strTmp=file_get_contents('/tmp/php_bil_session.id');
|
||||
$tabTmp=explode('^', $strTmp);
|
||||
$this->cookie=$tabTmp[0];
|
||||
$this->timeOut=$tabTmp[1];
|
||||
$this->url=$tabTmp[2];
|
||||
$this->siren=$tabTmp[3];
|
||||
$this->reference=$tabTmp[4];
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
205
library/Metier/partenaires/classMBourse.php
Normal file
205
library/Metier/partenaires/classMBourse.php
Normal file
@ -0,0 +1,205 @@
|
||||
<?
|
||||
|
||||
require_once 'framework/common/curl.php';
|
||||
|
||||
class MBourse {
|
||||
|
||||
var $siren=false;
|
||||
|
||||
public function __construct($siren=0) {
|
||||
$this->siren=$siren;
|
||||
}
|
||||
|
||||
public function getLibSource($source) {
|
||||
switch ($source) {
|
||||
case 'B': return 'Business Wire'; break;
|
||||
case 'H': return 'Hugin'; break;
|
||||
case 'A': return 'ActusNews'; break;
|
||||
case 'D': return 'DiRelease'; break;
|
||||
case 'E': return 'Les Echos'; break;
|
||||
default: return 'N/C'; break;
|
||||
}
|
||||
}
|
||||
|
||||
/** Obtenir le code ISIN à partir d'un siren
|
||||
**
|
||||
** @param integer $siren
|
||||
** @return string
|
||||
**/
|
||||
function getCodeIsin($siren=false) {
|
||||
$iDb=new WDB();
|
||||
if (!$siren)
|
||||
$siren=$this->siren;
|
||||
|
||||
$tabTmp=$iDb->select('infos_entrep', 'isin', "siren=$siren AND isin<>''", false, MYSQL_ASSOC);
|
||||
return trim(@$tabTmp[0]['isin']);
|
||||
}
|
||||
|
||||
/** Obtenir le SIREN à partir d'un code ISIN
|
||||
**
|
||||
** @param string $isin Code ISIN
|
||||
** @return integer
|
||||
**/
|
||||
function getCodeSiren($isin) {
|
||||
$iDb=new WDB();
|
||||
$tabTmp=$iDb->select('infos_entrep', 'siren', "isin='$isin' AND siren<>0", false, MYSQL_ASSOC);
|
||||
return trim($tabTmp[0]['siren']);
|
||||
}
|
||||
|
||||
/** A partir d'un siren, récupère les informations règlementés
|
||||
**
|
||||
** @param integer $siren
|
||||
** @param integer $id
|
||||
** @return unknown
|
||||
**/
|
||||
function getInfosReg($siren=false, $id=false) {
|
||||
|
||||
if (!$siren)
|
||||
$siren=$this->siren;
|
||||
|
||||
$isin=$this->getCodeIsin($siren);
|
||||
unset($iDb);
|
||||
$tabRet=array();
|
||||
if ($isin<>'') {
|
||||
$iDb=new WDB('presse');
|
||||
if ($id) $sqlID=" AND id=$id ";
|
||||
else $sqlID='';
|
||||
|
||||
$bodacc=$iDb->select( 'articles',
|
||||
'id, companyName, companyIsin, companySiren, companyWebSite, pressReleaseDate, pressReleaseTitle, '.
|
||||
'pressReleaseText, pressReleaseHtml, pressReleaseAttachments, pressReleaseUrl, source, dateInsert',
|
||||
"companyIsin='$isin' $sqlID ORDER BY pressReleaseDate DESC", false, MYSQL_ASSOC);
|
||||
if (count($bodacc)>0) {
|
||||
foreach ($bodacc as $k=>$ann) {
|
||||
if ($id)
|
||||
$tabRet[$k]=array( 'id'=>$ann['id'],
|
||||
'source'=>$this->getLibSource($ann['source']),
|
||||
'DateParution'=>$ann['pressReleaseDate'],
|
||||
'raisonSociale'=>$ann['companyName'],
|
||||
'titre'=>$ann['pressReleaseTitle'],
|
||||
'communique'=>$ann['pressReleaseText'],
|
||||
'communiqueHtml'=>$ann['pressReleaseHtml'],
|
||||
'pj'=>$ann['pressReleaseAttachments'],
|
||||
'url'=>$ann['pressReleaseUrl'],
|
||||
'dateInsertionSD'=>$ann['dateInsert'],
|
||||
);
|
||||
else
|
||||
$tabRet[$k]=array( 'id'=>$ann['id'],
|
||||
'source'=>$this->getLibSource($ann['source']),
|
||||
'DateParution'=>$ann['pressReleaseDate'],
|
||||
'raisonSociale'=>$ann['companyName'],
|
||||
'titre'=>$ann['pressReleaseTitle'],
|
||||
'pj'=>$ann['pressReleaseAttachments'],
|
||||
'url'=>$ann['pressReleaseUrl'],
|
||||
'dateInsertionSD'=>$ann['dateInsert'],
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
return $tabRet;
|
||||
}
|
||||
|
||||
/** A partir d'un siren, récupère les informations boursières
|
||||
**
|
||||
** @param integer $siren
|
||||
** @return unknown
|
||||
**/
|
||||
function getInfosBourse($siren=false) {
|
||||
global $timer;
|
||||
$iDb=new WDB('sdv1');
|
||||
|
||||
if (!$siren)
|
||||
$siren=$this->siren;
|
||||
|
||||
$isin=$this->getCodeIsin($siren);
|
||||
$timer['infosBoursieres-getCodeIsin']=microtime(true);
|
||||
$tabRet=array();
|
||||
if ($isin<>'') {
|
||||
$datePre=date('Y-m').'-01';
|
||||
$tabRes=$iDb->select( 'bourse_isin b, bourse_cours c',
|
||||
'siren, raisonSociale, adresse, effectif, code_sicovam, code_mnemo, code_bloomberg, code_datastream, code_isin, logo, code_ric, '.
|
||||
'dateIntroduction, dateDerAG, dateRadiation, autre_isin, eligibleSRD, eligiblePEA, nombreTitres, tel1, tel2, fax1, fax2, web, mail, '.
|
||||
'marche, placeCotation, description, secteur, activite, activiteDet, dirigeants, actionnaires, chiffresTrim, '.
|
||||
'c.autre, c.`date`, c.`heure`, c.`open` , c.`high` , c.`low` , c.`close` , c.`volume`',
|
||||
"code_isin='$isin' /*OR siren=$siren)*/ AND b.code_isin=c.isin AND c.autre IN('','e','f','g','m','s','u') AND c.`date`>='$datePre' ORDER BY b.dateUpdate DESC, c.dateInsert DESC LIMIT 0,1", false, MYSQL_ASSOC);
|
||||
$tabRet=$tabRes[0];
|
||||
$timer['infosBoursieres-infosIsin']=microtime(true);
|
||||
|
||||
$tabRes=$iDb->select( 'bourse_cours',
|
||||
'min(close) AS coursMin, avg(close) AS coursMoy, max(close) AS coursMax',
|
||||
"isin='$isin' GROUP BY isin", false, MYSQL_ASSOC);
|
||||
$tabTmp=$tabRes[0];
|
||||
$tabRet['coursMin']=$tabTmp['coursMin'];
|
||||
$tabRet['coursMoy']=$tabTmp['coursMoy'];
|
||||
$tabRet['coursMax']=$tabTmp['coursMax'];
|
||||
$timer['infosBoursieres-derniersCours']=microtime(true);
|
||||
/*
|
||||
$tabRes=$iDb->select( 'bourse_cours',
|
||||
'`date`, close',
|
||||
"isin='$isin' AND autre IN('','e','f','g','m','s','u') AND heure=9999 AND ( ".
|
||||
"`date`=DATE_SUB(CURDATE(), INTERVAL 6 DAY) OR ".
|
||||
"`date`=DATE_SUB(CURDATE(), INTERVAL 7 DAY) OR ".
|
||||
"`date`=DATE_SUB(CURDATE(), INTERVAL 8 DAY) OR ".
|
||||
"`date`='".date('Y')."-01-02' OR ".
|
||||
"`date`='".date('Y')."-01-03' OR ".
|
||||
"`date`='".date('Y')."-01-04' OR ".
|
||||
"`date`=DATE_SUB(CURDATE(), INTERVAL 365 DAY) OR ".
|
||||
"`date`=DATE_SUB(CURDATE(), INTERVAL 366 DAY) OR ".
|
||||
"`date`=DATE_SUB(CURDATE(), INTERVAL 367 DAY) OR ".
|
||||
"`date`=MIN(`date`) ) GROUP BY `date` ORDER BY `date` DESC", false, MYSQL_ASSOC);
|
||||
$tabTmp=$tabRes[0];
|
||||
print_r($tabTmp);
|
||||
*/
|
||||
/* Variations en clôture du 07/03/2008
|
||||
Variation 5 jours -2.03%
|
||||
Variation au 1 janvier +9.36%
|
||||
Variation 1 an +13.84%
|
||||
Variation 10 ans NC
|
||||
Volumes
|
||||
Volume séance 2 253
|
||||
Volume moy. 20 séances 16 326
|
||||
Ratio volumes 13.80%
|
||||
Nombre de titres 113 038 156
|
||||
Capital échangé séance 0.00%
|
||||
Extrêmes
|
||||
Plus haut 10 ans (14/02/2008) 78.5
|
||||
Plus bas 10 ans (18/04/2005) 41.12*/
|
||||
/*$tabRet[]=array( 'siren'=>$tabBourse,
|
||||
'raisonSociale',
|
||||
'adresse',
|
||||
'effectif',
|
||||
'code_sicovam',
|
||||
'code_mnemo',
|
||||
'code_bloomberg',
|
||||
'code_datastream',
|
||||
'code_isin',
|
||||
'logo',
|
||||
'code_ric',
|
||||
'dateIntroduction',
|
||||
'dateDerAG',
|
||||
'dateRadiation',
|
||||
'autre_isin',
|
||||
'eligibleSRD',
|
||||
'eligiblePEA',
|
||||
'nombreTitres',
|
||||
'tel1',
|
||||
'tel2',
|
||||
'fax1',
|
||||
'fax2',
|
||||
'web',
|
||||
'mail',
|
||||
'marche',
|
||||
'placeCotation',
|
||||
'description',
|
||||
'secteur',
|
||||
'activite',
|
||||
'activiteDet',
|
||||
'dirigeants',
|
||||
'actionnaires',
|
||||
'chiffresTrim'
|
||||
);*/
|
||||
}
|
||||
return $tabRet;
|
||||
}
|
||||
}
|
||||
?>
|
266
library/Metier/partenaires/classMCadastre.php
Normal file
266
library/Metier/partenaires/classMCadastre.php
Normal file
@ -0,0 +1,266 @@
|
||||
<?php
|
||||
|
||||
class MCadastre {
|
||||
|
||||
var $siren=false;
|
||||
var $iDb;
|
||||
|
||||
/** Droits des locaux **/
|
||||
private static $tabCodeDroit=array(
|
||||
'P'=>'Propriétaire',
|
||||
'U'=>'Usufruitier', // (associé avec N)
|
||||
'N'=>'Nu-propriétaire', // (associé avec U)
|
||||
'B'=>'Bailleur à construction', // (associé avec R)
|
||||
'R'=>'Preneur à construction', // (associé avec B)
|
||||
'F'=>'Foncier', // (associé avec D ou T)
|
||||
'T'=>'Tenuyer', // (associé avec F)
|
||||
'D'=>'Domanier', // (associé avec F)
|
||||
'V'=>'Bailleur d\'un bail à réhabilitation', // (associé avec W)
|
||||
'W'=>'Preneur d\'un bail à réhabilitation', // (associé avec V)
|
||||
'A'=>'Locataire-Attributaire', // (associé avec P)
|
||||
'E'=>'Emphytéote', // (associé avec P)
|
||||
'K'=>'Antichrésiste', // (associé avec P)
|
||||
'L'=>'Fonctionnaire logé',
|
||||
'G'=>'Gérant, mandataire, gestionnaire',
|
||||
'S'=>'Syndic de copropriété',
|
||||
'H'=>'Associé dans une société en transparence fiscale',// (associé avec P)
|
||||
'O'=>'Autorisation d\'occupation temporaire (70 ans)',
|
||||
'J'=>'Jeune agriculteur',
|
||||
'Q'=>'Gestionnaire taxe sur les bureaux (Ile-de-France)',
|
||||
'X'=>'La Poste Occupant et propriétaire',
|
||||
'Y'=>'La Poste Occupant et non propriétaire',
|
||||
'C'=>'Fiduciaire',
|
||||
);
|
||||
|
||||
/** Nature des locaux **/
|
||||
private static $tabNatureLoc=array(
|
||||
'AP'=>'Appartement',
|
||||
'AT'=>'Antenne téléphone',
|
||||
'AU'=>'Autoroute',
|
||||
'CA'=>'Commerce sans boutique',
|
||||
'CB'=>'Local divers',
|
||||
'CD'=>'Dépendance commerciale',
|
||||
'CH'=>'Chantier',
|
||||
'CM'=>'Commerce avec boutique',
|
||||
'DC'=>'Dépendance lieux communs',
|
||||
'DE'=>'Dépendance bâtie isolée',
|
||||
'LC'=>'Local commun',
|
||||
'MA'=>'Maison',
|
||||
'ME'=>'Maison exceptionnelle',
|
||||
'MP'=>'Maison partagée par une limite territoriale',
|
||||
'SM'=>'Sol de maison',
|
||||
'U' =>'Etablissement industriel',
|
||||
'U1'=>'Gare',
|
||||
'U2'=>'Gare - Triage',
|
||||
'U3'=>'Gare - Atelier matériel',
|
||||
'U4'=>'Gare - Atelier magasin',
|
||||
'U5'=>'Gare - Dépôt Titulaire',
|
||||
'U6'=>'Gare - Dépôt Réel',
|
||||
'U7'=>'Gare - Matériel transport',
|
||||
'U8'=>'Gare - Entretien matériel roulant',
|
||||
'U9'=>'Gare - Station usine',
|
||||
'UE'=>'Transformateur électrique',
|
||||
'UG'=>'Appareil à gaz',
|
||||
'UN'=>'Usine nucléaire',
|
||||
'US'=>'Etablissement industriel',
|
||||
);
|
||||
|
||||
/** Code Affectation des PEV (Partie d'EValuation) **/
|
||||
private static $tabCodePEV=array(
|
||||
'B'=>'Bâtiment industriel',
|
||||
'C'=>'Commerce',
|
||||
'H'=>'Habitation',
|
||||
'K'=>'Locaux administratifs non passibles de la Taxe d\'Habitation',
|
||||
'L'=>'Hôtel',
|
||||
'P'=>'Professionnel',
|
||||
'S'=>'Biens divers passibles de la Taxe d\'Habitation',
|
||||
'T'=>'Terrain industriel',
|
||||
);
|
||||
|
||||
/** Code Groupes Personnes Morales **/
|
||||
private static $tabGrpPerMor=array(
|
||||
0=>'Personne morale', // non remarquable
|
||||
1=>'Etat',
|
||||
2=>'Région',
|
||||
3=>'Département',
|
||||
4=>'Commune',
|
||||
5=>'Office HLM',
|
||||
6=>'Personne morale représentant des sociétés',
|
||||
7=>'Copropriétaire',
|
||||
8=>'Associé',
|
||||
9=>'Etablissement public ou organismes assimilés',
|
||||
|
||||
);
|
||||
|
||||
/** Nature des parcelles (cultures) **/
|
||||
private static $tabNaturePar=array(
|
||||
'AB'=>'Terrains à batir',
|
||||
'AG'=>'Terrains d\'agrément',
|
||||
'B' =>'Bois',
|
||||
'BF'=>'Futaies feuillues',
|
||||
'BM'=>'Futaies mixtes',
|
||||
'BO'=>'Oseraies',
|
||||
'BP'=>'Peupleraies',
|
||||
'BR'=>'Futaies résineuses',
|
||||
'BS'=>'Taillies sous futaies',
|
||||
'BT'=>'Taillies simples',
|
||||
'CA'=>'Carrières',
|
||||
'CH'=>'Chemins de fer, Canaux de Navigation',
|
||||
'E' =>'Eaux',
|
||||
'J' =>'Jardins',
|
||||
'L' =>'Landes',
|
||||
'LB'=>'Landes Boisées',
|
||||
'P' =>'Prés',
|
||||
'PA'=>'Pâtures ou Pâturages',
|
||||
'PC'=>'Pacages ou Pâtis',
|
||||
'PE'=>'Prés d\'embouche',
|
||||
'PH'=>'Herbages',
|
||||
'PP'=>'Prés, Pâtures ou Herbages plantes',
|
||||
'S' =>'Sols',
|
||||
'T' =>'Terre',
|
||||
'TP'=>'Terres plantées',
|
||||
'VE'=>'Vergers',
|
||||
'VI'=>'Vignes',
|
||||
);
|
||||
|
||||
public function __construct($siren=0) {
|
||||
$this->siren=$siren;
|
||||
$this->iDb=new WDb('sdv1');
|
||||
}
|
||||
|
||||
function getLocaux($siren=false) {
|
||||
if (!$siren)
|
||||
$siren=$this->siren;
|
||||
|
||||
$tabTmp=$this->iDb->select(
|
||||
'cad_perloc l, cad_permor e',
|
||||
'e.INTCIF, e.DNUPER, e.CCOGRM, e.DDENPM, e.DSIPMO, e.DFORME, e.FILLER, e.DSIREN, e.DLIGN3, e.DLIGN4, e.DLIGN5, e.DLIGN6, e.CCODEP, e.CCOCOM,
|
||||
l.CCODRO, l.CCOCOM, l.CCOPRF, l.CCOSEC, l.DNUPLA, l.DNUBAT, l.DESC, l.DNIV, l.DPOR, l.CCONLC, l.CCOAFF0, l.DSUPOD0, l.CCOAFF1, l.DSUPOD1, l.CCOAFF2, l.DSUPOD2, l.CCOAFF3, l.DSUPOD3, l.CCOAFF4, l.DSUPOD4, l.CCOAFF5, l.DSUPOD5, l.CCOAFF6, l.DSUPOD6, l.CCOAFF7, l.DSUPOD7, l.CCOAFF8, l.DSUPOD8, l.CCOAFF9, l.DSUPOD9, l.CCODEP, l.DLICOM, l.CCORIV, l.CNAVOI, l.DLIVOI, l.DNUVOI, l.DLTNUV',
|
||||
"e.DSIREN=$siren AND e.INTCIF=l.INTCIF AND e.DNUPER=l.DNUPER", false, MYSQL_ASSOC);
|
||||
$tabRet=array();
|
||||
foreach ($tabTmp as $i=>$loc) {
|
||||
$tabLoc=array( 'idCentre'=>$loc['INTCIF'],
|
||||
'idPmMajic'=>$loc['DNUPER'],
|
||||
'pmGroupe'=>trim($loc['CCOGRM']),
|
||||
'pmGroupeLib'=>self::$tabGrpPerMor[trim($loc['CCOGRM'])],
|
||||
'pmNom'=>trim($loc['DDENPM']),
|
||||
'pmSigle'=>trim($loc['DSIPMO']),
|
||||
'pmFJ'=>$loc['DFORME'], // $loc['FILLER'],
|
||||
'siren'=>trim($loc['DSIREN']),
|
||||
'pmAdrL3'=>trim($loc['DLIGN3']),
|
||||
'pmAdrL4'=>trim($loc['DLIGN4']),
|
||||
'pmAdrL5'=>trim($loc['DLIGN5']),
|
||||
'pmAdrL6'=>trim($loc['DLIGN6']),
|
||||
'pmAdrDep'=>trim($loc['CCODEP']),
|
||||
'pmAdrCom'=>trim($loc['CCOCOM']),
|
||||
'localDroit'=>trim($loc['CCODRO']),
|
||||
'localDroitLib'=>self::$tabCodeDroit[trim($loc['CCODRO'])],
|
||||
'localDep'=>trim($loc['CCODEP']),
|
||||
'localCom'=>trim($loc['CCOCOM']),
|
||||
'localComLib'=>trim($loc['DLICOM']),
|
||||
'localComAbs'=>trim($loc['CCOPRF']),
|
||||
'localRivoli'=>trim($loc['CCORIV']),
|
||||
'localNumVoie'=>trim($loc['DNUVOI']),
|
||||
'localIndVoie'=>trim($loc['DLTNUV']),
|
||||
'localTypVoie'=>trim($loc['CNAVOI']),
|
||||
'localLibVoie'=>trim($loc['DLIVOI']),
|
||||
'localSection'=>trim($loc['CCOSEC']),
|
||||
'localNumPlan'=>trim($loc['DNUPLA']),
|
||||
'localNumBat'=>trim($loc['DNUBAT']),
|
||||
'localEntEsc'=>trim($loc['DESC']),
|
||||
'localNumPlan'=>trim($loc['DNIV']),
|
||||
'localNumBat'=>trim($loc['DPOR']),
|
||||
'localEntEsc'=>trim($loc['CCONLC']),
|
||||
'localPEV'=>array(),
|
||||
);
|
||||
$surface=0;
|
||||
for($j=0;$j<10;$j++) {
|
||||
$pevCode=trim($loc['CCOAFF'.$j]);
|
||||
$pevSurf=trim($loc['DSUPOD'.$j])*1;
|
||||
if ($pevCode<>'' && $pevSurf>0) {
|
||||
$tabLoc['localPEV'][$j]=array( 'pevCode'=>$pevCode,
|
||||
'pevType'=>self::$tabCodePEV[$pevCode],
|
||||
'pevSurface'=>$pevSurf,
|
||||
);
|
||||
$surface+=$pevSurf;
|
||||
}
|
||||
}
|
||||
$tabLoc['localSurface']=$surface;
|
||||
$tabRet[]=$tabLoc;
|
||||
/*CADBAT_NB_TOT nombre Cadastre nombre de postes BATIMENT du SIREN toutes addresses
|
||||
CADTER_NB_TOT nombre Cadastre nombre de postes TERRAIN du SIREN toutes addresses
|
||||
CADBAT_NB_PROP nombre Cadastre nombre de postes BATIMENT à l'adresse dont elle est propriétaire
|
||||
CADTER_NB_PROP nombre Cadastre nombre de postes TERRAIN à l'adresse dont elle est propriétaire
|
||||
CADBAT_NB_NONPROP nombre Cadastre nombre de postes BATIMENT à l'adresse dont elle n'est pas propriétaire
|
||||
CADTER_NB_NONPROP nombre Cadastre nombre de postes TERRAINS à l'adresse dont elle n'est pas propriétaire
|
||||
CADBAT_SURF_CUM nombre Cadastre Cumul Surfaces des batiments à l'addresse
|
||||
CADBAT_SURF_TOT nombre Cadastre Surface totale des batiments du SIREN
|
||||
CADTER_SURF_CUM nombre Cadastre Cumul Surfaces des terrains à l'addresse
|
||||
CADTER_SURF_TOT nombre Cadastre Surface totale des terrains du SIREN
|
||||
*/
|
||||
}
|
||||
return $tabRet;
|
||||
}
|
||||
|
||||
function getParcelles($siren=false) {
|
||||
if (!$siren)
|
||||
$siren=$this->siren;
|
||||
|
||||
$tabTmp=$this->iDb->select(
|
||||
'cad_perpar p, cad_permor e',
|
||||
'e.INTCIF, e.DNUPER, e.CCOGRM, e.DDENPM, e.DSIPMO, e.DFORME, e.FILLER, e.DSIREN, e.DLIGN3, e.DLIGN4, e.DLIGN5, e.DLIGN6, e.CCODEP, e.CCOCOM,
|
||||
p.CCODRO, p.CCOCOM, p.CCOPRF, p.CCOSEC, p.DNUPLA, p.DCNPAR, p.DSGRPF0, p.DCNSUF0, p.DSGRPF1, p.DCNSUF1, p.DSGRPF2, p.DCNSUF2, p.DSGRPF3, p.DCNSUF3, p.DSGRPF4, p.DCNSUF4, p.DSGRPF5, p.DCNSUF5, p.DSGRPF6, p.DCNSUF6, p.DSGRPF7, p.DCNSUF7, p.DSGRPF8, p.DCNSUF8, p.DSGRPF9, p.DCNSUF9, p.CCODEP, p.DLICOM, p.CCORIV, p.CNAVOI, p.DLIVOI, p.DNUVOI, p.DLTNUV',
|
||||
"e.DSIREN=$siren AND e.INTCIF=p.INTCIF AND e.DNUPER=p.DNUPER", false, MYSQL_ASSOC);
|
||||
$tabRet=array();
|
||||
foreach ($tabTmp as $i=>$loc) {
|
||||
$tabLoc=array( 'idCentre'=>$loc['INTCIF'],
|
||||
'idPmMajic'=>$loc['DNUPER'],
|
||||
'pmGroupe'=>trim($loc['CCOGRM']),
|
||||
'pmGroupeLib'=>self::$tabGrpPerMor[trim($loc['CCOGRM'])],
|
||||
'pmNom'=>trim($loc['DDENPM']),
|
||||
'pmSigle'=>trim($loc['DSIPMO']),
|
||||
'pmFJ'=>$loc['DFORME'], // $loc['FILLER'],
|
||||
'siren'=>trim($loc['DSIREN']),
|
||||
'pmAdrL3'=>trim($loc['DLIGN3']),
|
||||
'pmAdrL4'=>trim($loc['DLIGN4']),
|
||||
'pmAdrL5'=>trim($loc['DLIGN5']),
|
||||
'pmAdrL6'=>trim($loc['DLIGN6']),
|
||||
'pmAdrDep'=>trim($loc['CCODEP']),
|
||||
'pmAdrCom'=>trim($loc['CCOCOM']),
|
||||
'parcelDroit'=>trim($loc['CCODRO']),
|
||||
'parcelDroitLib'=>self::$tabCodeDroit[trim($loc['CCODRO'])],
|
||||
'parcelDep'=>trim($loc['CCODEP']),
|
||||
'parcelCom'=>trim($loc['CCOCOM']),
|
||||
'parcelComLib'=>trim($loc['DLICOM']),
|
||||
'parcelComAbs'=>trim($loc['CCOPRF']),
|
||||
'parcelRivoli'=>trim($loc['CCORIV']),
|
||||
'parcellNumVoie'=>trim($loc['DNUVOI']),
|
||||
'parcelIndVoie'=>trim($loc['DLTNUV']),
|
||||
'parcelTypVoie'=>trim($loc['CNAVOI']),
|
||||
'parcelLibVoie'=>trim($loc['DLIVOI']),
|
||||
'parcelSection'=>trim($loc['CCOSEC']),
|
||||
'parcelNumPlan'=>trim($loc['DNUPLA']),
|
||||
'parcelSurface'=>trim($loc['DCNPAR'])*1,
|
||||
'parcelTer'=>array(),
|
||||
);
|
||||
$surface=0;
|
||||
for($j=0;$j<10;$j++) {
|
||||
$pevCode=trim($loc['DSGRPF'.$j]);
|
||||
$pevSurf=trim($loc['DCNSUF'.$j])*1;
|
||||
if ($pevCode<>'' && $pevSurf>0) {
|
||||
$tabLoc['parcelTer'][$j]=array( 'terCode'=>$pevCode,
|
||||
'terType'=>self::$tabCodePEV[$pevCode],
|
||||
'terSurface'=>$pevSurf,
|
||||
);
|
||||
$surface+=$pevSurf;
|
||||
}
|
||||
}
|
||||
$tabLoc['parcelSurfaceCalc']=$surface;
|
||||
$tabRet[]=$tabLoc;
|
||||
}
|
||||
return $tabRet;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
391
library/Metier/partenaires/classMCoface.php
Normal file
391
library/Metier/partenaires/classMCoface.php
Normal file
@ -0,0 +1,391 @@
|
||||
<?
|
||||
|
||||
require_once 'framework/common/curl.php';
|
||||
|
||||
class MCoface {
|
||||
|
||||
public $body = '';
|
||||
public $header = '';
|
||||
public $codeRetour = 0;
|
||||
|
||||
public $nscrl = 0; // Numéro interne SCRL
|
||||
public $rcsVille='';
|
||||
public $rcsType='';
|
||||
|
||||
public $rSocAdrCPVille=''; // RaisonSocialeAdresseVille (utile pour le débug)
|
||||
public $raisonSociale=''; // Raison Sociale
|
||||
public $adresse=''; // Adresse complète (avec CP et Cille)
|
||||
|
||||
public $sigle='';
|
||||
public $enseigne='';
|
||||
public $nbEtab='';
|
||||
|
||||
public $adrNumVoie;
|
||||
public $adrIndRep;
|
||||
public $adrTypeVoie;
|
||||
public $adrLibVoie;
|
||||
public $adrCP;
|
||||
public $adrVille;
|
||||
|
||||
public $tel='';
|
||||
public $fax='';
|
||||
public $web='';
|
||||
public $mail='';
|
||||
public $activite=''; // Activité Déclarée au bodacc
|
||||
public $naf=''; // NAF
|
||||
public $nafLib='';
|
||||
|
||||
public $bourseIsin='';
|
||||
public $bourseMarche='';
|
||||
public $bourseVille='';
|
||||
|
||||
public $tabInfos=array();
|
||||
public $tabBilans=array();
|
||||
|
||||
public $infoEco=false;
|
||||
public $capitalType='';
|
||||
public $capitalMontant='';
|
||||
public $capitalDevise ='';
|
||||
public $steInactive = '';
|
||||
public $dateCreation=''; // Notion INSEE
|
||||
public $dateImmatriculation=''; // Notion Greffe et RNCS uniquement
|
||||
public $fj='';
|
||||
public $nationalite='';
|
||||
public $enBourse='';
|
||||
public $effectif='';
|
||||
public $tabDirigeants=array();
|
||||
public $strLiensFi='';
|
||||
public $strElemsFi='';
|
||||
|
||||
public $derExerciceAnnee='';
|
||||
public $derExerciceDuree='';
|
||||
public $derExerciceDClot='';
|
||||
public $derExerciceCA='';
|
||||
public $derExerciceResultat='';
|
||||
public $derExerciceDevise='';
|
||||
|
||||
public $dateFermeture='';
|
||||
public $score_pouey='';
|
||||
public $score_conan='';
|
||||
public $score_afdcc='';
|
||||
public $vigilance='';
|
||||
public $tabJug=array();
|
||||
public $tabAct=array();
|
||||
public $tabFil=array();
|
||||
public $tabEtab=array();
|
||||
|
||||
function __construct($siren) {
|
||||
|
||||
// $iDb=new WDB();
|
||||
|
||||
$referer='';
|
||||
$url='http://www.cofacerating.fr/portail/entreprise_identite/identite.asp?ip=pagespro&lg=fr&nsiren='.$siren;
|
||||
$page=getUrl($url, '', '', $referer, false, 'www.cofacerating.fr', '', 10);
|
||||
$this->body=$page['body'];
|
||||
$this->codeRetour=$page['code'];
|
||||
$this->header=$page['header'];
|
||||
$this->nscrl=@getTextInHtml($this->body, '&nscrl=', '=','&');
|
||||
$this->rSocAdrCPVille=trim(str_replace(chr(160), ' ', html_entity_decode(utf8_encode(@getTextInHtml($this->body, '<td WIDTH="40%" bgcolor="#F3E5CC" class="tabligne"> <b> Raison sociale<br>', '<td WIDTH="60%" bgcolor="#FFF3DE" class="tabval"><b>','</tr>')))));
|
||||
$tmp=explode('<br>', $this->rSocAdrCPVille);
|
||||
$this->raisonSociale=trim($tmp[0]);
|
||||
unset($tmp[0]);
|
||||
$this->adresse=trim(strip_tags(implode(',', $tmp)));
|
||||
$this->tel=trim(@getTextInHtml($this->body, '<td bgcolor="#F3E5CC" class="tabligne"><b>Téléphone<br>', '<td bgcolor="#FFF3DE" class="tabval" valign="top">', '<br>'));
|
||||
$this->fax=trim(@getTextInHtml($this->body, 'Télécopie</b></td>', '<br>', '</td>'));
|
||||
$this->web=trim(@getTextInHtml($this->body, '<td bgcolor="#F3E5CC" class="tabligne"><b>Adresse internet <br>', ' class="tabval"><a class="tabval" HREF="', '" target="_new">'));
|
||||
$this->mail=trim(@getTextInHtml($this->body, '<a class="tabval" href="mailto:', ':', '">'));
|
||||
|
||||
$bourse=trim(@getTextInHtml($this->body, 'Ville Bourse</b></td>', 'class="tabval">', '</td>'));
|
||||
$tmp=explode('<br>', $bourse);
|
||||
$this->bourseIsin=trim($tmp[0]);
|
||||
$this->bourseMarche=trim($tmp[1]);
|
||||
$this->bourseVille=trim($tmp[2]);
|
||||
|
||||
$infosDispo=trim(@getTextInHtml($this->body, '<b>Liste Produits</b><br></td>', '<br></td><td class="menu3"><img src="../images/vide.gif" border="0"><br></td><td colspan="2" class="menu3">', 'Un secteur ou une région en France</a><br></td>'));
|
||||
$tabTmp=explode('<a href="', $infosDispo);
|
||||
foreach ($tabTmp as $k=>$lien) {
|
||||
preg_match('/^(.*)">(.*)<\/a>/i', $lien, $matches);
|
||||
if ($matches[2]<>'') $this->tabInfos[$matches[2]]=$matches[1];
|
||||
if (substr($matches[2], 0, 12)=='rapport éco.') $this->infoEco='http://www.cofacerating.fr/portail/entreprise_identite/'.$matches[1];//ip=pagespro&
|
||||
elseif (substr($matches[2], 0, 6)=='bilan ') $this->tabBilans[]=substr($matches[2], 6,strlen($matches[2])-6);
|
||||
}
|
||||
$this->activite=trim(str_replace(chr(160), ' ', html_entity_decode(utf8_encode(@getTextInHtml($this->body, '<td WIDTH="40%" bgcolor="#F3E5CC" class="tabligne" valign="top"><b>Libellé code activité </b></td>', '<td WIDTH="60%" bgcolor="#FFF3DE" class="tabval">', '</td>')))));
|
||||
$this->naf=trim(@getTextInHtml($this->body, '<a href="../chaineeco_dynaeco/DynaEco.asp?cnaf=', 'cnaf=', '&'));
|
||||
|
||||
/**
|
||||
** Recherche du NIC sur Société .com
|
||||
**/
|
||||
|
||||
/*
|
||||
$refererS='http://www.societe.com/';
|
||||
$urlS='http://www.societe.com/cgi-bin/recherche?rncs='.$siren.'&vu=1';
|
||||
$page=getUrl($urlS, '', '', $refererS, false, 'www.societe.com');
|
||||
$ste=$page['body'];
|
||||
$this->nic=trim(@getTextInHtml($ste, 'SIRET</div><div class="ficheAltCol2 size11">', $siren, '</div>'));
|
||||
|
||||
$strTmp=trim(@getTextInHtml($ste, '<b><span class="size10">RCS', 'RCS ', ' '.substr($siren,0,3)));
|
||||
$tabTmp=explode(' ', $strTmp);
|
||||
$this->rcsVille=$tabTmp[0];//<td class="txtBlanc" align="left"><b><span class="size10">RCS Paris B 552 144 503<br></span></b></td>
|
||||
$this->rcsType=$tabTmp[1];
|
||||
|
||||
$strTmp=trim(@getTextInHtml($ste, '<div class="ficheAltCol1 size11">Code activité</div>', '<div class="ficheAltCol2 size11">', '</div>'));
|
||||
$tabTmp=explode(' - ', $strTmp);
|
||||
$this->naf=$tabTmp[0];
|
||||
$this->nafLib=$tabTmp[1];
|
||||
|
||||
// <div class="ficheAltCol1 size11">Siège social</div><div class="ficheAltCol2 size11">75 Avenue la Grande Armee - 75116 PARIS 16</div>
|
||||
|
||||
$strTmp=trim(@getTextInHtml($ste, '<div class="ficheAltCol1 size11">Capital social', '<div class="ficheAltCol2 size11">', '</div>'));
|
||||
$this->capitalType='social';
|
||||
$tabTmp=explode(' ', $strTmp);
|
||||
$this->capitalMontant=str_replace(',', '.', str_replace('.', '', $tabTmp[0]));
|
||||
$this->capitalDevise =$tabTmp[1];
|
||||
|
||||
$this->fj=trim(@getTextInHtml($ste, '<div class="ficheAltCol1 size11">Forme juridique', '<div class="ficheAltCol2 size11">', '</div>'));
|
||||
$this->nationalite=trim(@getTextInHtml($ste, '<div class="ficheAltCol1 size11">Nationalité</div>', '<div class="ficheAltCol2 size11">', '</div>'));
|
||||
|
||||
$strTmp=trim(@getTextInHtml($ste, ' DIRIGEANT(S) </span></span></div>', '<div class="ficheCadre" style="min-height:85px;">', '<div class="spacer"></div>'));
|
||||
$tabTmp=explode('<div class="h1bleu2"></div>', $strTmp);
|
||||
foreach ($tabTmp as $k=>$dir) {
|
||||
if (trim($dir)=='') break;
|
||||
$tabTmp1=explode('</div><div class="ficheAltCol2 size11">', $dir);
|
||||
$tabTmp2=explode('représenté par', $tabTmp1[1]);
|
||||
if (isset($tabTmp2[1]) && $tabTmp2[1]<>'') {
|
||||
$soc=trim($tabTmp2[0]);
|
||||
$diri=trim($tabTmp2[1]);
|
||||
} else {
|
||||
$soc='';
|
||||
$diri=trim($tabTmp1[1]);
|
||||
}
|
||||
preg_match("/^(Mme|M\.|Mlle|Mle|M) ([A-Z\s]*) ([A-Z][a-z\s]*)/", $diri, $matches);
|
||||
//print_r($matches);
|
||||
$this->tabDirigeants[]=array('FONCTION'=>trim(strip_tags($tabTmp1[0])), 'SOCIETE'=>$soc, 'GENRE'=>$matches[1], 'PRENOM'=>trim($matches[3]), 'NOM'=>trim($matches[2]));
|
||||
}
|
||||
|
||||
$this->dateImmatriculation=trim(@getTextInHtml($ste, '<div class="ficheAltCol1 size11"> Immatriculation', '<div class="ficheAltCol2 size11">', '</div>'));
|
||||
//06-03-2007</div>
|
||||
/* Date Creation = ""
|
||||
En bourse = ""
|
||||
Effectif societe = ""
|
||||
Dirigeants :
|
||||
**/
|
||||
$urlRacine='http://infobilan.decideur.com/';
|
||||
$tabPost=array( 'choix'=>'1',
|
||||
'pagePrecedente'=>'recherche_entreprise.html',
|
||||
'nomsocRech'=>'',
|
||||
'cpRech'=>'',
|
||||
'villeRech'=>'',
|
||||
'nomdirRech'=>'',
|
||||
'predirRech'=>'',
|
||||
'sirenRech'=>$siren,
|
||||
'telRech'=>'',);
|
||||
// 'Rechercher'=>'',
|
||||
$url=$urlRacine.'liste_result.html';
|
||||
$referer=$urlRacine.'recherche_entreprise.html';
|
||||
$page=getUrl($url,'', $tabPost, $referer, false, 'infobilan.decideur.com');
|
||||
$this->body=$page['body'];
|
||||
$strCookie=$page['header']['Set-Cookie'];
|
||||
$refererInfoD=$url;
|
||||
|
||||
if(preg_match_all('/<a href="choix_pdt\.html\?(.*)" class="tt1">(.*)<\/a><\/span><br>/i', $page['body'], $matches))
|
||||
$urlInfoD=$urlRacine.'choix_pdt.html?'.$matches[1][0];
|
||||
else
|
||||
$urlInfoD='';
|
||||
|
||||
$page=getUrl($this->infoEco, '', '', $url, false, 'www.cofacerating.fr');
|
||||
if (strpos($page['body'], '<b>Choix du mode de paiement</b>')===false) { // Le rapport éco. est cadeau !!!
|
||||
$this->infoEco=true;
|
||||
$eco=$page['body'];
|
||||
//die ($eco);
|
||||
$strTmp=strip_tags(@getTextInHtml($eco, ' class="tabligne" > Capital   (', '(', '</tr><tr>'));
|
||||
$tabTmp=explode(')', $strTmp);
|
||||
$this->capitalType=$tabTmp[0];
|
||||
$tabTmp=explode(' ', $tabTmp[1]);
|
||||
$this->capitalMontant=trim(str_replace(chr(160), '', $tabTmp[0]));
|
||||
$this->capitalDevise =trim(str_replace(chr(160), '', $tabTmp[1]));
|
||||
|
||||
$this->steInactive=trim(@getTextInHtml($eco, ' class="tabligne" > Société inactive</td>', 'class="tabval" >', '</td>'));
|
||||
|
||||
$this->dateCreation=trim(@getTextInHtml($eco, ' class="tabligne" > Date de création</td>', 'class="tabval" >', '</td>'));
|
||||
$this->fj=trim(@getTextInHtml($eco, ' class="tabligne" > Forme juridique</td>', 'class="tabval" >', '</td>'));
|
||||
$this->effectif=trim(@getTextInHtml($eco, ' class="tabligne" > Effectif', 'class="tabval" >', '</td>'));
|
||||
|
||||
if (count($this->tabDirigeants)==0) { // Si il y a déjà des dirigeants on garde ceux de Société.com !!!
|
||||
$strTmp=trim(@getTextInHtml($eco, ' class="tabligne" > Cotation en bourse</td>', '<td bgcolor="#F3E5CC" class="tabligne" >', '<td bgcolor="#F3E5CC" class="tabligne" > Effectif'));
|
||||
$tabTmp=explode('<td bgcolor="#F3E5CC" class="tabligne" >', $strTmp);
|
||||
foreach ($tabTmp as $k=>$dir) {
|
||||
$tabTmp1=explode('<td bgcolor="#FFF3DE" class="tabval" >', $dir);
|
||||
$tabTmp2=explode(' ', trim(strip_tags($tabTmp1[1])));
|
||||
$this->tabDirigeants[]=array('FONCTION'=>trim(strip_tags($tabTmp1[0])), 'GENRE'=>trim($tabTmp2[0]), 'PRENOM'=>trim($tabTmp2[1]), 'NOM'=>trim($tabTmp2[2]));
|
||||
}
|
||||
}
|
||||
|
||||
$this->strLiensFi=trim(strip_tags(@getTextInHtml($eco, '<td class="tabtot">LIENS FINANCIERS</td>', '<tr>', '</td></tr>')));
|
||||
$this->strElemsFi=trim(strip_tags(@getTextInHtml($eco, '<td class="tabtot">ELEMENTS FINANCIERS</td>', '<tr>', '</td></tr>')));
|
||||
}
|
||||
|
||||
$refererP='http://www.score3.fr/';
|
||||
$urlP='http://www.score3.fr/entreprise.shtml?siren='.$siren;
|
||||
$page=getUrl($urlP, '', '', $refererP, false, 'www.score3.fr');
|
||||
$pou=$page['body'];
|
||||
$fp=fopen('./pouet.html', 'w');
|
||||
fwrite($fp, $pou);
|
||||
fclose($fp);
|
||||
|
||||
if ($urlInfoD<>'') {
|
||||
$page=getUrl($urlInfoD,$strCookie,'', $refererInfoD, false, 'infobilan.decideur.com');
|
||||
$referer=$urlInfoD;
|
||||
if ($this->nscrl==0) $this->nscrl=@getTextInHtml($url, 'nscrlP=', '=','&');
|
||||
|
||||
$url=$urlRacine.'fiche_ident.html';
|
||||
$page=getUrl($url,$strCookie,'', $referer, false, 'infobilan.decideur.com');
|
||||
$this->body=$page['body'];
|
||||
|
||||
if ($this->raisonSociale=='')
|
||||
$this->raisonSociale=trim(@getTextInHtml($this->body, '<span class="libelle2">Société', ' :', '</span>'));
|
||||
|
||||
if ($this->adresse=='')
|
||||
$this->adresse=trim(@getTextInHtml($this->body, '<span class="libelle2">Adresse</span> <strong>:', '</strong>', '</td>'));
|
||||
|
||||
if ($this->tel=='')
|
||||
$this->tel=trim(@getTextInHtml($this->body, '<td valign="top"><span class="libelle2">Tél', '</span>', '<br>'));
|
||||
if ($this->fax=='')
|
||||
$this->fax=trim(@getTextInHtml($this->body, '<span class="libelle2">Fax</span>', ' :', '<br>'));
|
||||
if ($this->web=='')
|
||||
$this->web=trim(@getTextInHtml($this->body, '<span class="libelle2">Site Web</span>', '<a href="', '" target="_blank">'));
|
||||
if ($this->mail=='')
|
||||
$this->mail=trim(@getTextInHtml($this->body, '<span class="libelle2">E-mail</span>', '<a href="mailto:', '">'));
|
||||
if ($this->naf=='')
|
||||
$this->naf=trim(@getTextInHtml($this->body, '<span class="libelle2">Code NAF</span>', ' :', '</td>'));
|
||||
|
||||
if(preg_match('/<td valign="top"><span class="libelle2">Capital social<\/span> : (\d*)(.*)<br>/isU', $this->body, $matches)
|
||||
&& ($this->capitalMontant=='' || $this->capitalDevise=='')) {
|
||||
$this->capitalMontant=trim($matches[1]);
|
||||
$this->capitalDevise=trim($matches[2]);
|
||||
}
|
||||
|
||||
if ($this->fj=='')
|
||||
$this->fj=trim(@getTextInHtml($this->body, '<span class="libelle2">Forme juridique</span>', ' :', '<br>'));
|
||||
if ($this->nationalite=='')
|
||||
$this->nationalite=trim(@getTextInHtml($this->body, '<span class="libelle2">Nationalité</span>', ' :', '</td>'));
|
||||
if ($this->effectif=='')
|
||||
$this->effectif=trim(@getTextInHtml($this->body, '<td valign="top"><span class="libelle2">Effectif</span>', ' :', '<br>'));
|
||||
if ($this->activite=='')
|
||||
$this->activite=trim(@getTextInHtml($this->body, '<span class="libelle2">Activité</span>', ' :', '<br>'));
|
||||
|
||||
/** Actionnaires **/
|
||||
$strTmp=trim(@getTextInHtml($this->body, 'ACTIONNAIRES<br>', '</div></h1>', '<h1>'));
|
||||
if(preg_match_all('/<p><span class="libelle2">(.*)<\/span> - <span class="libelle2">Participation<\/span> : (.*) %<br>(.*)<\/p>/isU', $strTmp, $matches)) {
|
||||
foreach ($matches[1] as $i=>$nom) {
|
||||
$this->tabAct[$i]['nom']=trim($nom);
|
||||
$this->tabAct[$i]['pct']=trim($matches[2][$i]);
|
||||
$this->tabAct[$i]['rcs']=trim(str_replace('RCS : ','',strip_tags($matches[3][$i])));
|
||||
}
|
||||
}
|
||||
|
||||
/** Filiales **/
|
||||
$strTmp=trim(@getTextInHtml($this->body, 'FILIALES<br>', '</div></h1>', '<h1>'));
|
||||
if(preg_match_all('/<p><span class="libelle2">(.*)<\/span> - <span class="libelle2">Participation<\/span> :(.*)%<br>(.*)<\/p>/isU', $strTmp, $matches)) {
|
||||
foreach ($matches[1] as $i=>$nom) {
|
||||
$this->tabFil[$i]['nom']=trim($nom);
|
||||
$this->tabFil[$i]['pct']=trim($matches[2][$i]);
|
||||
$this->tabFil[$i]['rcs']=trim(str_replace('RCS :','',strip_tags($matches[3][$i])));
|
||||
}
|
||||
}
|
||||
|
||||
/** CA et Résultat **/
|
||||
$strTmp=trim(@getTextInHtml($this->body, '<h1>PRINCIPAUX ELEMENTS FINANCIERS<br>', '</div></h1>', '</p>'));
|
||||
if(preg_match('/<p><span class="libelle2">CA (.*)<\/span>(.*)<br>/isU', $strTmp, $matches)) {
|
||||
$this->derExerciceAnnee=trim($matches[1]);
|
||||
$this->derExerciceCA=trim(str_replace(':',' ', $matches[2]));
|
||||
}
|
||||
if(preg_match('/<span class="libelle2">Résultat(.*)<\/span>(.*)$/isU', $strTmp, $matches)) {
|
||||
$this->derExerciceResultat=trim(str_replace(':',' ', $matches[2]));
|
||||
}
|
||||
|
||||
$infoBilan=print_r($page, true);
|
||||
$fp=fopen('./infobilan.html', 'w');
|
||||
fwrite($fp, $infoBilan);
|
||||
fclose($fp);
|
||||
}
|
||||
|
||||
if ($this->nbEtab=='' || $this->nbEtab=='0') {
|
||||
$this->nbEtab=trim(strip_tags(str_replace('afficher la liste...', '', @getTextInHtml($pou, '<tr><td class="ligne1_2">Etablissements </td>', '<td class="ligne2_2">', '</td></tr>'))));
|
||||
$urlPEtab='http://www.score3.fr/etablissements.shtml?page=1&siren='.$siren;
|
||||
$refererPEtab=$urlP;
|
||||
$page=getUrl($urlPEtab, '', '', $refererPEtab, false, 'www.score3.fr');
|
||||
$pou2=$page['body'];
|
||||
if(preg_match_all('/<tr bgcolor="(?:\S*)"><td class="ligne1b" align="center" width="10%">(\d*)<\/td><td class="ligne2" height="50"><table cellpadding="0" cellspacing="0" border="0" width="100%"><tr><td class="infos">(.*)<\/td><\/tr><\/table>/isU', $pou2, $matches)) {
|
||||
foreach ($matches[1] as $i=>$nic) {
|
||||
$strEtab=$matches[2][$i];
|
||||
$this->tabEtab[$i]['siren']=$siren;
|
||||
$this->tabEtab[$i]['nic']=$nic;
|
||||
$this->tabEtab[$i]['siret']=$siren.$nic;
|
||||
|
||||
$this->tabEtab[$i]['enseigne']=trim(str_replace(chr(160),' ',utf8_decode(strip_tags(@getTextInHtml($strEtab, '<span class="titre3">', '">', '</span>')))));
|
||||
$this->tabEtab[$i]['adresse']=trim(str_replace(chr(160),' ',utf8_decode(strip_tags(@getTextInHtml($strEtab, '<span class="infos">', '">', '<br>')))));
|
||||
$strTmp=trim(str_replace(chr(160),' ',utf8_decode(strip_tags(@getTextInHtml($strEtab, '<span class="infos">', '<br>', '</span>')))));
|
||||
$tabTmp=explode(' ', $strTmp);
|
||||
$this->tabEtab[$i]['cp']=$tabTmp[0];
|
||||
unset($tabTmp[0]);
|
||||
$this->tabEtab[$i]['ville']=implode(' ',$tabTmp);
|
||||
$strTmp=trim(strip_tags(@getTextInHtml($strEtab, '<td class="infos" align="right" valign="top">', '">', ')')));
|
||||
$tabTmp=explode('(', $strTmp);
|
||||
$this->tabEtab[$i]['naf_code']=$tabTmp[1];
|
||||
$this->tabEtab[$i]['naf_lib']=trim(str_replace(chr(160),' ',utf8_decode($tabTmp[0])));
|
||||
if (preg_match('/<br>T.l\.(.*)$/i',$strEtab,$matches2))
|
||||
$this->tabEtab[$i]['tel']=trim(str_replace(chr(160),' ',utf8_decode($matches2[1])));
|
||||
else $this->tabEtab[$i]['tel']='';
|
||||
}
|
||||
}
|
||||
$this->nbEtab=count($this->tabEtab);
|
||||
$fp=fopen('./pouet_etab.html', 'w');
|
||||
fwrite($fp, $pou2);
|
||||
fclose($fp);
|
||||
}
|
||||
|
||||
if ($this->effectif=='' || $this->effectif=='0' || $this->effectif=='NC')
|
||||
$this->effectif=trim(@getTextInHtml($pou, '<tr><td class="ligne1_2">Effectifs</td>', '<td class="ligne2_2">', '</td></tr>'));
|
||||
|
||||
if ($this->dateImmatriculation=='' || $this->dateImmatriculation=='0')
|
||||
$this->dateImmatriculation=trim(@getTextInHtml($pou, '<tr><td class="ligne1_2">Date d\'immatriculation</td>', '<td class="ligne2_2">', '</td></tr>'));
|
||||
if ($this->dateFermeture=='' || $this->dateFermeture=='0')
|
||||
$this->dateFermeture=trim(@getTextInHtml($pou, '<tr><td class="ligne1_2">Date de fin d\'exploitation</td>', '<td class="ligne2_2">', '</td></tr>'));
|
||||
|
||||
if ($this->tel=='' || $this->tel=='0')
|
||||
$this->tel=trim(@getTextInHtml($pou, '<tr><td class="ligne1_2">Téléphone</td>', '<td class="ligne2_2">', '</td></tr>'));
|
||||
|
||||
if ($this->fax=='' || $this->fax=='0')
|
||||
$this->fax=trim(@getTextInHtml($pou, '<tr><td class="ligne1_2">Fax</td>', '<td class="ligne2_2">', '</td></tr>'));
|
||||
|
||||
$strTmp=trim(@getTextInHtml($pou, 'Procédures collectives</td></tr>', '</table></td>', '</td><td background'));
|
||||
if(preg_match_all('/<tr><td class="ligne1_2">(.*)<\/td><td class="ligne2_2">(.*)<\/td><\/tr>/isU', $strTmp, $matches)) {
|
||||
foreach ($matches[1] as $i=>$jug) {
|
||||
$this->tabJug[$i]['date']=$matches[1][$i];
|
||||
$this->tabJug[$i]['juge']=$matches[2][$i];
|
||||
}
|
||||
}
|
||||
|
||||
$this->score_pouey=trim(@getTextInHtml($pou, '<param name="movie" value="cadran.swf?rotation=', '&type=pouey&valeur=', '">'));
|
||||
$this->score_conan=trim(@getTextInHtml($pou, '<param name="movie" value="cadran.swf?rotation=', '&type=ch&valeur=', '">'));
|
||||
$this->score_afdcc=trim(@getTextInHtml($pou, '<param name="movie" value="cadran.swf?rotation=', '&type=afdcc&valeur=', '">'));
|
||||
$this->vigilance =trim(@getTextInHtml($pou, '<param name="movie" value="vigilance.swf', 'degre=', '">'));
|
||||
|
||||
if(preg_match('/Date de l\'exercice<\/td><td class="ligne2_2">(.*) sur (\d*) mois<\/td><\/tr>/isU', $pou, $matches)) {
|
||||
$this->derExerciceDClot=trim($matches[1]);
|
||||
$this->derExerciceDuree=trim($matches[2]);
|
||||
}
|
||||
|
||||
/* Siret SIEGE
|
||||
2 Fonction, Nom Prénoù ET Date NAissance du PP
|
||||
5 Liste des actes
|
||||
*/
|
||||
if ($this->codeRetour==200)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
282
library/Metier/partenaires/classMCsf.php
Normal file
282
library/Metier/partenaires/classMCsf.php
Normal file
@ -0,0 +1,282 @@
|
||||
<?
|
||||
|
||||
define('CREDITSAFE_WS_URL', 'https://www.creditsafe.fr/getdata/service/CSFRServices.asmx');
|
||||
define('CREDITSAFE_WS_URI', 'https://www.creditsafe.fr/getdata/service/');
|
||||
|
||||
define('CREDITSAFE_WS_USER', 'scores_decisions');
|
||||
define('CREDITSAFE_WS_PASS', 'yoann1306');
|
||||
|
||||
define('CREDITSAFE_WS_REF', 'ref');
|
||||
|
||||
|
||||
if (!$_SESSION['connected']) die();
|
||||
|
||||
function formatPct($pct) {
|
||||
$pct=round($pct/10,0)*10;
|
||||
if ($pct==0) $pct=10;
|
||||
return $pct;
|
||||
}
|
||||
|
||||
$siret=trim(preg_replace('/[^0-9]/', '', $_REQUEST['siret']));
|
||||
if (strlen($siret)<>9 && strlen($siret)<>14) die('Paramètres incorrects !');
|
||||
if (strlen($siret)==9) $siret=$tabInfo['entrep']['siret'];
|
||||
|
||||
$id=trim(preg_replace('/[^0-9]/', '', $_REQUEST['id']))*1; // Si id=0 alors non communiqué
|
||||
if (($siret*1)==0 && $id==0) die('Paramètres incorrects !');
|
||||
$siren=substr($siret,0,9);
|
||||
|
||||
$action=$_REQUEST['action'];
|
||||
if ($action<>'' && $action<>'commande') die('Paramètres incorrects !');
|
||||
|
||||
$raisonSociale=$tabInfo['entrep']['raisonSociale'];
|
||||
|
||||
require_once 'Metier/partenaires/classMTva.php';
|
||||
require_once 'Metier/partenaires/classMMap.php';
|
||||
require_once 'Metier/partenaires/classMCoface.php';
|
||||
require_once 'framework/common/dates.php';
|
||||
|
||||
/** Utilisation du WS **/
|
||||
|
||||
$client = new SoapClient(null, array( 'trace' => 1,
|
||||
'soap_version' => SOAP_1_1,
|
||||
'location' => WEBSERVICE_URL,
|
||||
'uri' => WEBSERVICE_URI,
|
||||
'login' => $_SESSION['tabInfo']['login'],
|
||||
'password' => $_SESSION['tabInfo']['password']));
|
||||
|
||||
/*$client = new SoapClient('https://www.creditsafe.fr/getdata/service/CSFRServices.asmx?WSDL',
|
||||
array( 'location' => CREDITSAFE_WS_URL,
|
||||
'uri' => CREDITSAFE_WS_URI,
|
||||
'soap_version' => SOAP_1_1,
|
||||
'trace' => 1,
|
||||
//'style' => SOAP_RPC,
|
||||
//'use' => SOAP_ENCODED,
|
||||
));
|
||||
*/
|
||||
|
||||
$req='<xmlrequest>'.
|
||||
'<header>'.
|
||||
'<username>'.CREDITSAFE_WS_USER.'</username>'.
|
||||
'<password>'.CREDITSAFE_WS_PASS.'</password>'.
|
||||
//'<operation>getcompanyinformation</operation>'.
|
||||
'<operation>getratinglimit</operation>'.
|
||||
'<country>FR</country>'.
|
||||
'<language>FR</language>'.
|
||||
'<chargereference>'.CREDITSAFE_WS_REF.'</chargereference>'.
|
||||
'</header>'.
|
||||
'<body>'.
|
||||
//'<package>standard</package>'.
|
||||
'<package>ratinglimit</package>'.
|
||||
"<companynumber>$siret</companynumber>".
|
||||
'</body>'.
|
||||
'</xmlrequest>';
|
||||
|
||||
$success=true;
|
||||
$date=date('Ymd');
|
||||
$fichier="$siret-$date.xml";
|
||||
|
||||
if (!file_exists('/var/www/site_extranet/www/creditsafe/xml/'.$fichier)) {
|
||||
/* try {
|
||||
$O=$client->GetData('<RequestXmlString><xmlrequest>'.
|
||||
'<header>'.
|
||||
'<username>'.CREDITSAFE_WS_USER.'</username>'.
|
||||
'<password>'.CREDITSAFE_WS_PASS.'</password>'.
|
||||
'<operation>getcompanyinformation</operation>'.
|
||||
'<country>FR</country>'.
|
||||
'<language>FR</language>'.
|
||||
'<chargereference>'.CREDITSAFE_WS_REF.'</chargereference>'.
|
||||
'</header>'.
|
||||
'<body>'.
|
||||
'<package>standard</package>'.
|
||||
"<companynumber>$siret</companynumber>".
|
||||
'</body>'.
|
||||
'</xmlrequest></RequestXmlString>');
|
||||
//die(print_r($O));
|
||||
$xml=implode('', (array)$O);
|
||||
}
|
||||
catch (SoapFault $soapFault) {// echo "ERROR :\n", var_dump($soapFault), "\n"; echo "Request :\n", $client->__getLastRequest(), "\n";
|
||||
$success=false;
|
||||
$response=$client->__getLastResponse();
|
||||
$response=str_replace("<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);
|
||||
$xml=str_replace('</return></ns0:getProduitsWebServicesXMLResponse></SOAP-ENV:Body></SOAP-ENV:Envelope>','', $response);
|
||||
}*/
|
||||
//https://www.creditsafe.fr/getdata/service/CSFRServices.asmx/GetData
|
||||
//$url='https://www.creditsafe.fr/getdata/service/CSFRServices.asmx/GetData?RequestXmlString='.$req;
|
||||
$url='https://www.creditsafe.fr/getdata/service/CSFRServices.asmx/GetData?RequestXmlStr='.$req;//.'&RequestXmlString='.$req;
|
||||
//requestXmlStr.
|
||||
$referer=$cookie='';
|
||||
$page=getUrl($url, $cookie, '', $referer, false, '', '');
|
||||
$referer=$url;
|
||||
$xml=html_entity_decode($page['body'], ENT_QUOTES, 'UTF-8');
|
||||
|
||||
/** Enregistrement du fichier XML en provenance des greffes
|
||||
**/
|
||||
$fp=@fopen('/var/www/site_extranet/www/creditsafe/xml/'.$fichier, 'w');
|
||||
@fwrite($fp, $xml);
|
||||
@fclose($fp);
|
||||
|
||||
$O = $client->setLog('scorecsf', $siret);
|
||||
|
||||
} else {
|
||||
/** Lecture du fichier XML en provenance des greffes
|
||||
**/
|
||||
$xml=file_get_contents('/var/www/site_extranet/www/creditsafe/xml/'.$fichier);
|
||||
$O = $client->setLog('scorecsf', $siret, 0, 'local');
|
||||
}
|
||||
/*<>100</rating>
|
||||
2000000</creditlimit>*/
|
||||
|
||||
$dom_object = new DomDocument2();
|
||||
$dom_object->load('/var/www/site_extranet/www/creditsafe/xml/'.$fichier);
|
||||
/* create DOMXPath object with our DOMObject
|
||||
$xpath = new Domxpath($dom_object);
|
||||
$result = $xpath->query("//liste_depot_acte/depot_acte/.");
|
||||
foreach ($result as $annonce) {
|
||||
// N° Gestion
|
||||
$title = $xpath->query ("num_gest/greffe", $annonce);
|
||||
$num_gest_greffe=$title->item(0)->nodeValue;
|
||||
*/
|
||||
$companyname=$dom_object->getValueFromTag('companyname');
|
||||
$rating=$dom_object->getValueFromTag('rating');
|
||||
$ratingdesc1=str_replace('?',"'",$dom_object->getValueFromTag('ratingdesc1'));
|
||||
$ratingdesc2=str_replace('?',"'",$dom_object->getValueFromTag('ratingdesc2'));
|
||||
$creditlimit=$dom_object->getValueFromTag('creditlimit');
|
||||
$libelle='';
|
||||
if (strtoupper($creditlimit)<>strtolower($creditlimit) || $creditlimit=='')
|
||||
$strCreditlimit=$creditlimit;
|
||||
else
|
||||
$strCreditlimit=number_format($creditlimit,null,null,' '). ' €';
|
||||
|
||||
if ($rating>=40) {
|
||||
$fontColor='green';
|
||||
$imgFeux='<img src="/creditsafe/img/feux_vert.png"/>';
|
||||
if ($rating>=71) $libelle='Très bonne cote de crédit/solvabilité';
|
||||
elseif ($rating>=51) $libelle='Bonne cote de crédit/solvabilité';
|
||||
else $libelle='Solvable';
|
||||
|
||||
} elseif ($rating>=20) {
|
||||
$fontColor='yellow';//#f2be2c';
|
||||
$imgFeux='<img src="/creditsafe/img/feux_orange.png"/>';
|
||||
$libelle='Précautions recommandées';
|
||||
} elseif (strtoupper($rating)<>strtolower($rating)) {
|
||||
$fontColor='black';
|
||||
$imgFeux=' ';
|
||||
}
|
||||
elseif ($rating=='') {
|
||||
$fontColor='black';
|
||||
$imgFeux=' ';
|
||||
}
|
||||
else {
|
||||
$fontColor='red';
|
||||
$imgFeux='<img src="/creditsafe/img/feux_rouge.png"/>';
|
||||
if ($rating==0) $libelle='Entreprise en situation de défaillance et ayant un très fort risque de radiation';
|
||||
else $libelle='Avertissement - Crédit à votre discrétion';
|
||||
}
|
||||
|
||||
?><table width="580" border="0" align="left" bgcolor="#FFFFFF">
|
||||
<tr>
|
||||
<td colspan="3"><img src="./img/rub_evaluation.png" width="577" height="36"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td width="30"> </td>
|
||||
<td width="200" class="StyleInfoLib">Numéro identifiant Siren</td>
|
||||
<td width="350" class="StyleInfoData"><?=substr($siret,0,3).' '.substr($siret,3,3).' '.substr($siret,6,3)?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td width="30"> </td>
|
||||
<td width="200" class="StyleInfoLib">Raison Sociale</td>
|
||||
<td width="350" class="StyleInfoData"><?if ($companyname<>'') echo $companyname;
|
||||
else echo $raisonSociale;
|
||||
?></td>
|
||||
</tr>
|
||||
<? if ($etab['NumRC']*1<>0) { ?>
|
||||
<tr>
|
||||
<td width="30"> </td>
|
||||
<td width="200" class="StyleInfoLib">Numéro R.C.</td>
|
||||
<td width="350" class="StyleInfoData"><?=$etab['NumRC']?></td>
|
||||
</tr>
|
||||
<? } ?>
|
||||
<tr>
|
||||
<td colspan="3"> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="3"><img src="./img/srub_scorescf.png" width="576" height="27"></td>
|
||||
</tr>
|
||||
|
||||
<!--#a5a5a5; }
|
||||
.grey_gradiant .v20 { background: #bcbcbc; }
|
||||
.grey_gradiant .v10 { background: #c8c8c8;-->
|
||||
<tr><td colspan="3">
|
||||
|
||||
<table cellspacing="0">
|
||||
<tr>
|
||||
<td width="20"> </td>
|
||||
<td width="10" bgcolor="#bebebe"> </td>
|
||||
<td width="200" bgcolor="#bebebe"><font size="2"><b>Note à ce jour [0 - 100]</b></font></td>
|
||||
<td width="250" bgcolor="#bebebe"><font color="<?=$fontColor?>" size="2"><?=$rating;?></font></td>
|
||||
<td width="100" bgcolor="#bebebe"><?=$imgFeux?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td width="20"> </td>
|
||||
<td width="10" bgcolor="#e7e7e7"> </td>
|
||||
<td width="200" bgcolor="#e7e7e7"><font size="2"><b>Limite à ce jour [€]</b></font></td>
|
||||
<td width="350" colspan="2" bgcolor="#e7e7e7"><font size="2"><?=$strCreditlimit?></font></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td width="20"> </td>
|
||||
<td width="10" bgcolor="#bebebe"> </td>
|
||||
<td width="200" bgcolor="#bebebe"><font size="2"><b>Informations complémentaires</b></font></td>
|
||||
<td width="350" colspan="2" bgcolor="#bebebe"><font color="<?=$fontColor?>" size="2"><?=$libelle.'<br/>'.$ratingdesc1; if (trim($ratingdesc2)<>'') echo '<br/>'.$ratingdesc2;?></font></td>
|
||||
</tr>
|
||||
<!-- <tr>
|
||||
<td colspan="5" align="right"><img src="/creditsafe/img/logo_creditsafe.png"/></td>
|
||||
</tr>-->
|
||||
</table>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
<?
|
||||
if ($action<>'commande') {
|
||||
?>
|
||||
<tr>
|
||||
<td width="30"> </td>
|
||||
<td width="550" colspan="2" class="StyleInfoData"><br/><br/><form action="./?page=scorescf&action=commande&siret=<?=$siret?>&id=<?=$id?>" method="POST"><input type="checkbox"/> Mettre cette entreprise sous surveillance scoring partenaire<br/><br/>Adresse email du destinataire <input name="email" type="text" value="<? if ($_SESSION['tabInfo']['login']<>'testreunica' && $_SESSION['tabInfo']['login']<>'reunicacsf') echo $tabInfo['email']?>" size="20"/> <input class="imgButton" type="image" src="./img/boutton_valider_off.gif" name="submit" onmouseover="this.src='./img/boutton_valider_on.gif'" onmouseout="this.src='./img/boutton_valider_off.gif'" title="Surveiller le score partenaire de cette entreprise..."></form></td>
|
||||
</tr>
|
||||
</table>
|
||||
<?
|
||||
} else {
|
||||
if (preg_match('#^[\w.-]+@[\w.-]+\.[a-zA-Z]{2,5}$#',$_REQUEST['email'])) {
|
||||
$message='Entreprise mise sous surveillance scoring partenaire !';
|
||||
mail( 'contact@scores-decisions.com',"Demande de surveillance score CreditSafe pour $siren à ".$_REQUEST['email'],
|
||||
'REQUEST='.EOL.print_r($_REQUEST,true).'EOL'.
|
||||
'SERVER='.EOL.print_r($_SERVER,true).'EOL'.
|
||||
'SESSION='.EOL.print_r($_SESSION,true).'EOL'.
|
||||
'ENV='.EOL.print_r($_ENV,true).'EOL'.
|
||||
'tabInfo='.print_r($tabInfo,true));
|
||||
$fp=fopen(PATH_LOGS.'surveillance_scf.csv', 'a');
|
||||
fwrite($fp, date('Y/m/d H:i:s').";$siren;".$_REQUEST['email'].';'.$tabInfo['login'].';'.$tabInfo['email'].';'.$tabInfo['ip']."\n");
|
||||
fclose($fp);
|
||||
} else {
|
||||
$message="ERREUR : Veuillez saisir une adresse email valide pour la mise sous surveillance";
|
||||
}
|
||||
?>
|
||||
<tr>
|
||||
<td width="30"> </td>
|
||||
<td width="550" colspan="2" class="StyleInfoData"><br/><br/><h3><?=$message;?></h3></td>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
|
||||
class DomDocument2 extends DOMDocument {
|
||||
|
||||
function getValueFromTag($tagName) {
|
||||
$items=$this->getElementsByTagName($tagName);
|
||||
foreach ($items as $item) {
|
||||
|
||||
return utf8_decode($item->nodeValue);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
123
library/Metier/partenaires/classMDirigeants.php
Normal file
123
library/Metier/partenaires/classMDirigeants.php
Normal file
@ -0,0 +1,123 @@
|
||||
<?
|
||||
require_once 'framework/common/curl.php';
|
||||
require_once 'framework/common/dates.php';
|
||||
require_once 'Metier/partenaires/classMEuridile.php';
|
||||
|
||||
class MBilans {
|
||||
|
||||
public $siren;
|
||||
|
||||
function __construct($siren) {
|
||||
$this->siren=$siren;
|
||||
}
|
||||
|
||||
function __destruct() {}
|
||||
|
||||
/** Adapter cette classe pour qu'elle utilise la classe MEuridile et la base Bilans Local **/
|
||||
|
||||
/** Liste des dirigeants actifs
|
||||
**/
|
||||
function listeDirigeants() {
|
||||
$iDb2=new WDB('jo');
|
||||
$ret=$iDb2->select( 'bilans',
|
||||
'typeBilan, dateProvPartenaire, dateExercice, dateExercicePre, dureeExercice, dureeExercicePre, monnaieOrigine',
|
||||
"siren='$this->siren' ORDER BY dateExercice DESC");
|
||||
$tabRet=array();
|
||||
$iDb=new WDB('jo');
|
||||
$ret2=$iDb->select( 'bodacc_detail',
|
||||
'Bodacc_Date_Parution, dateEffet, typeEven',
|
||||
//Num_Annonce, RC, raisonSociale, FJ, adrSiegeNum, adrSiegeIndRep, adrSiegeTypVoie, adrSiegeLibVoie, adrSiegeComp1, adrSiegeComp2, codePostalSiege, villeSiege, Bodacc_Num
|
||||
"siren='$this->siren' AND Rubrique='comptes' ORDER BY dateEffet DESC");
|
||||
$dateDerDepot=WDate::dateT('Y-m-d','Ymd',@$ret2[0]['dateEffet'])*1;
|
||||
$dateDerExercice=$ret[0]['dateExercice']*1;
|
||||
if ($dateDerDepot<>0) {
|
||||
$this->dernierExerciceDepose = WDate::dateT('Y-m-d','d/m/Y',@$ret2[0]['dateEffet']);
|
||||
$this->dernierExerciceDeposeLe = WDate::dateT('Y-m-d','d/m/Y',@$ret2[0]['Bodacc_Date_Parution']);
|
||||
}
|
||||
/*
|
||||
//echo date('Y/m/d - H:i:s') ." - Dernier depot le ". $ret2[0]['Bodacc_Date_Parution'] .", dernier en base = $dateDerExercice !<br/>\n";
|
||||
if ( $dateDerDepot>$dateDerExercice ||
|
||||
( $dateDerDepot==0 && $dateDerExercice<date('Ymd', mktime(0,0,0, date('m')-18, date('d'), date('Y'))) ) ) {*/
|
||||
$rncs=new MEuridile();
|
||||
$tabRet=$rncs->listBilans($this->siren);
|
||||
//}
|
||||
foreach ($ret as $i=>$bil) {
|
||||
$millesime=WDate::dateT('Ymd','d/m/Y',$bil['dateExercice']);
|
||||
$tabRet[$bil['typeBilan'].$millesime]=array(
|
||||
'dateProvPartenaire'=>$bil['dateProvPartenaire'],
|
||||
'dureeExercice' =>$bil['dureeExercice'],
|
||||
'dateExercicePre' =>$bil['dateExercicePre'],
|
||||
'dureeExercicePre' =>$bil['dureeExercicePre'],
|
||||
'monnaie' =>$bil['monnaieOrigine'],
|
||||
'source' =>1,
|
||||
);
|
||||
}
|
||||
return $tabRet;
|
||||
}
|
||||
|
||||
function getBilan($millesime='', $typeBilan='N', $refPart=0) {
|
||||
$millesime=WDate::dateT('d/m/Y','Ymd',$millesime);
|
||||
$iDb2=new WDB('insee');
|
||||
$ret=$iDb2->select('bilans', 'dateProvPartenaire, dateExercice, dateExercicePre, dureeExercice, dureeExercicePre, monnaie, typeBilan, monnaieOrigine, unite, postes', "siren='$this->siren' AND typeBilan='$typeBilan' AND dateExercice='$millesime'", true);
|
||||
$bilan=$ret[0];
|
||||
if (count($ret)==0) {
|
||||
$rncs=new MEuridile($this->siren);
|
||||
$tabBilan=$rncs->getBilan($refPart);
|
||||
|
||||
if ($tabBilan) {
|
||||
$strPostes='';
|
||||
foreach ($tabBilan['POSTES'] as $poste=>$valeur)
|
||||
$strPostes.="$poste=$valeur;";
|
||||
$tabInsert=array( 'siren' =>$this->siren,
|
||||
'dateProvPartenaire'=>$tabBilan['DATE_FRAICHE_BILAN'],
|
||||
'dateExercice' =>WDate::dateT('d/m/Y','Ymd',$tabBilan['DATE_CLOTURE']),
|
||||
'dateExercicePre' =>WDate::dateT('d/m/Y','Ymd',$tabBilan['DATE_CLOTURE_PRE']),
|
||||
'dureeExercice' =>$tabBilan['DUREE_MOIS'],
|
||||
'dureeExercicePre' =>$tabBilan['DUREE_MOIS_PRE'],
|
||||
'monnaie' =>$tabBilan['MONNAIE'],
|
||||
'typeBilan' =>$tabBilan['TYPE_BILAN'],
|
||||
'monnaieOrigine' =>$tabBilan['MONNAIE_ORI'],
|
||||
'unite' =>$tabBilan['MONNAIE_LIV_UNITE'],
|
||||
'postes' =>$strPostes,
|
||||
'partenaire' =>2,
|
||||
);
|
||||
$iDb2->insert('bilans', $tabInsert);
|
||||
$ret=$iDb2->select('bilans', 'dateProvPartenaire, dateExercice, dateExercicePre, dureeExercice, dureeExercicePre, monnaie, typeBilan, monnaieOrigine, unite, postes', "siren='$this->siren' AND typeBilan='$typeBilan' AND dateExercice='$millesime'");
|
||||
$bilan=$ret[0];
|
||||
}
|
||||
}
|
||||
$tabBilan=array();
|
||||
$tabBilan['SIREN'] = $this->siren;
|
||||
$tabBilan['DATE_FRAICHE_BILAN'] = $bilan['dateProvPartenaire']; // SSAAMMJJ
|
||||
$tabBilan['DATE_CLOTURE'] = $bilan['dateExercice']; // SSAAMMJJ
|
||||
$tabBilan['DATE_CLOTURE_PRE'] = $bilan['dateExercicePre']; // SSAAMMJJ
|
||||
$tabBilan['DUREE_MOIS'] = $bilan['dureeExercice'];
|
||||
$tabBilan['DUREE_MOIS_PRE'] = $bilan['dureeExercicePre'];
|
||||
$tabBilan['MONNAIE'] = $bilan['monnaie'];
|
||||
$tabBilan['CONSOLIDE'] = $bilan['typeBilan']; // C = Bilan consolidé
|
||||
$tabBilan['MONNAIE_ORI'] = $bilan['monnaieOrigine'];
|
||||
$tabBilan['MONNAIE_LIV_UNITE'] = $bilan['unite'];
|
||||
if ($bilan['monnaie']=='EUR') $monnaie='€'; else $monnaie=$bilan['monnaie'];
|
||||
switch (strtoupper($bilan['unite'])) {
|
||||
case 'K': $unite='K'; break;
|
||||
case 'U':
|
||||
case ' ':
|
||||
case '' : $unite=''; break;
|
||||
case 'M': $unite='M'; break;
|
||||
default: die('Unite Bilan ('. $bilan['unite'] .') non prise en charge !'); break;
|
||||
}
|
||||
$tabBilan['devise'] = /*$unite.*/$monnaie;
|
||||
|
||||
$tabTmp=explode(';', $bilan['postes']);
|
||||
foreach ($tabTmp as $i=>$strTmp) {
|
||||
$tabTmp2=explode('=', $strTmp);
|
||||
if (isset($tabTmp2[1]))
|
||||
if ($unite=='K' && $tabTmp2[0]<>'YP' && $tabTmp2[0]<>'YP1') $tabBilan[$tabTmp2[0]]=$tabTmp2[1]*1000;
|
||||
elseif ($unite=='M' && $tabTmp2[0]<>'YP' && $tabTmp2[0]<>'YP1') $tabBilan[$tabTmp2[0]]=$tabTmp2[1]*1000000;
|
||||
else $tabBilan[$tabTmp2[0]]=$tabTmp2[1];
|
||||
}
|
||||
return $tabBilan;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
0
library/Metier/partenaires/classMEnquetes.php
Normal file
0
library/Metier/partenaires/classMEnquetes.php
Normal file
1425
library/Metier/partenaires/classMEuridile.php
Normal file
1425
library/Metier/partenaires/classMEuridile.php
Normal file
File diff suppressed because it is too large
Load Diff
391
library/Metier/partenaires/classMFacto.php
Normal file
391
library/Metier/partenaires/classMFacto.php
Normal file
@ -0,0 +1,391 @@
|
||||
<?
|
||||
/*
|
||||
2. Concernant la date de fin de CS, devons nous comprendre les cas suivants de la sorte :
|
||||
A. 026 820 043 I 2009-10-31 La CS était valide jusq'au 31/10/2009... L'entreprise n'a plus de CS ? ou la CS est encore à prendre en compte ?
|
||||
Lorsqu'une cs manuelle arrive à échéance, elle est soumise à l'examen de l'analyste chaque mois. Si l'analyste n'intervient pas l'acheteur reste en cs.
|
||||
B. 077 250 025 I 0000-00-00 La CS I n'est plus à prendre en compte ou au contraire, elle n'a pas de date de fin ?
|
||||
L'acheteur a été sorti de cs entre le traitement de fin de mois et l'extraction ( qui a été déclenchée tardivement à la main ). L'acheteur n'est donc plus en cs.
|
||||
C. 067 103 598 I 2999-12-31 La CS I n'a pas de date de fin sauf changement ultérieur de CS
|
||||
Ce cas fait partie des nettoyages à faire par le Crédit ( échéance illimitée sur une cs qui ne le justifie pas ).
|
||||
D. 067 200 329 I 2010-06-30 La CS est valide jusq'au 30/06/2010... Quid après ?
|
||||
Cette cs ayant été positionnée par l'analyste, elle sera de nouveau soumise à son examen.
|
||||
|
||||
3. Globalement, j'ai l'impression que la CS "Paiements" à une durée de 6-12 mois et la CS "Privilèges" de 12-24 mois ?
|
||||
La cs paiement a une durée de 6 ou 12 mois pour les cas graves.
|
||||
La cs privilège a une durée de 27 mois ( sauf bien sur les cs manuelles qui sont à la convenance de l'analyste, en général 12 mois ).
|
||||
*/
|
||||
class MFacto {
|
||||
|
||||
public $risqueImpaye=false; // Y a t'il un risque d'impayé ?
|
||||
public $risqueImpayeMois=0;
|
||||
public $profilPayeur=0; // 0:N/D, 1:Excellent, 2=Bon, 3=Normal, 4=Lent, 5=Mauvais ou Défaut
|
||||
|
||||
private $typeFlux = 0; // Type de flux en chargement 0:Acheteur, 1=CS, 2=Paiements
|
||||
private $iDb;
|
||||
|
||||
public $DELAIPAY=0;
|
||||
public $DELAIPAYp='';
|
||||
public $DELAIPAY_MMAA='';
|
||||
|
||||
private $tabInfoCS=array(
|
||||
'_00'=>array('risque'=>0,'type'=>'OK', 'libInt'=>'Néant', 'libExt'=>'Aucune difficulté significative ne nous a été signalée'),
|
||||
'_10'=>array('risque'=>3,'type'=>'IP', 'libInt'=>'Impayé BDF', 'libExt'=>"A surveiller. Présence d'impayé(s)"),
|
||||
'_11'=>array('risque'=>3,'type'=>'IP', 'libInt'=>'Retard de paiement - Prorogation', 'libExt'=>'A suivre. Retard(s) de paiement(s) signalé(s)'),
|
||||
'_12'=>array('risque'=>3,'type'=>'IP', 'libInt'=>'Impayé Groupe Facto', 'libExt'=>"A surveiller. Présence d'impayé(s)"),
|
||||
'_13'=>array('risque'=>3,'type'=>'IP', 'libInt'=>'Impayé BDF (sup. à limite)', 'libExt'=>"A surveiller. Présence d'impayé(s)"),
|
||||
'_15'=>array('risque'=>3,'type'=>'PR', 'libInt'=>'PRIVILEGES URSSAF', 'libExt'=>'A surveiller. Présence de privilèges'),
|
||||
'_16'=>array('risque'=>3,'type'=>'PR', 'libInt'=>'AUTRES PRIVILEGES', 'libExt'=>'A surveiller. Présence de Privilèges'),
|
||||
'_20'=>array('risque'=>4,'type'=>'BL', 'libInt'=>'LIQUIDATION JUDICIAIRE', 'libExt'=>'Liquidation Judiciaire'),
|
||||
'_21'=>array('risque'=>1,'type'=>'BC', 'libInt'=>'CESSATION D\'ACTIVITE', 'libExt'=>'A suivre. Informations terrain. Risque de fermeture'),
|
||||
'_22'=>array('risque'=>1,'type'=>'BD', 'libInt'=>'RADIATION RCS', 'libExt'=>'Radiation du RCS'),
|
||||
'_23'=>array('risque'=>1,'type'=>'BG', 'libInt'=>'LOCATION GERANCE', 'libExt'=>'Prise en location Gérance'),
|
||||
'_24'=>array('risque'=>2,'type'=>'RG', 'libInt'=>'GROUPE EN DIFFICULTE', 'libExt'=>'A suivre. Entreprise(s) du groupe signalée(s) en difficulté(s)'),
|
||||
'_25'=>array('risque'=>2,'type'=>'DEF', 'libInt'=>'INFORMATIONS NEGATIVES', 'libExt'=>'A suivre. Informations terrain récentes négatives'),
|
||||
'_26'=>array('risque'=>4,'type'=>'BP', 'libInt'=>'PLAN DE CESSION / DE REDRESSEMENT ', 'libExt'=>'Plan de cession/redressement'),
|
||||
'_27'=>array('risque'=>4,'type'=>'BR', 'libInt'=>'REDRESSEMENT JUDICIAIRE', 'libExt'=>'Redressement Judiciaire'),
|
||||
'_28'=>array('risque'=>4,'type'=>'BH', 'libInt'=>'HOMOLOGATION CONCILIATION / REG.AMIABLE', 'libExt'=>'Conciliation, Homologation ou règlement amiable'),
|
||||
'_29'=>array('risque'=>1,'type'=>'BF', 'libInt'=>'FUSION - ABSORPTION', 'libExt'=>'Fusion/Absorption'),
|
||||
'_30'=>array('risque'=>3,'type'=>'IP', 'libInt'=>'MAUVAISE COTE BDF : .8 ou .9', 'libExt'=>"Présence d'impayé(s)"),
|
||||
'_31'=>array('risque'=>1,'type'=>'TC', 'libInt'=>'CESSATION ANNONCEE', 'libExt'=>'Fin d\'activité programmée'),
|
||||
'_33'=>array('risque'=>4,'type'=>'BS', 'libInt'=>'PROCEDURE DE SAUVEGARDE JUGEMENT', 'libExt'=>'Procédure de Sauvegarde'),
|
||||
'_34'=>array('risque'=>4,'type'=>'BV', 'libInt'=>'PLAN DE SAUVEGARDE', 'libExt'=>'Plan de sauvegarde'),
|
||||
'_35'=>array('risque'=>2,'type'=>'DEF', 'libInt'=>'ANALYSE FINANCIERE NEGATIVE', 'libExt'=>'A suivre. Informations terrain récentes négatives'),
|
||||
'_36'=>array('risque'=>2,'type'=>'DEF', 'libInt'=>'BILAN NEGATIF', 'libExt'=>'A suivre. Informations terrain récentes négatives'),
|
||||
'_37'=>array('risque'=>2,'type'=>'DEF', 'libInt'=>'TRESORERIE SERREE', 'libExt'=>'A suivre. Informations terrain récentes négatives'),
|
||||
'_39'=>array('risque'=>2,'type'=>'DEF', 'libInt'=>'PREVISIONS NEGATIVES', 'libExt'=>'A suivre. Informations terrain récentes négatives'),
|
||||
'_43'=>array('risque'=>2,'type'=>'LC', 'libInt'=>'LC SFAC', 'libExt'=>"A suivre. Garantie d'assurance crédit limitée"),
|
||||
'_45'=>array('risque'=>2,'type'=>'LC', 'libInt'=>'REFUS SFAC DOM-TOM', 'libExt'=>"A suivre. Garantie d'assurance crédit limitée"),
|
||||
// '_47'=>array('risque'=>2,'type'=>'LC', 'libInt'=>'LISTE CONFIDENTIELLE LEASER', 'libExt'=>"A suivre. Garantie d'assurance crédit limitée"),
|
||||
'_50'=>array('risque'=>2,'type'=>'KO', 'libInt'=>'LIENS AVEC UNE ORGANISATION TERRORISTE', 'libExt'=>'Attention, liens internationaux très risqués'),
|
||||
// Nouveaux regroupements GE
|
||||
'_I' =>array('risque'=>3,'type'=>'IP', 'libInt'=>'Impayés', 'libExt'=>"A surveiller. Présence d'impayé(s) dans les 12 derniers mois"),
|
||||
'_P' =>array('risque'=>3,'type'=>'PR', 'libInt'=>'PRIVILEGES', 'libExt'=>'A surveiller. Présence de privilèges dans les 24 derniers mois'),
|
||||
'_D' =>array('risque'=>2,'type'=>'DEF', 'libInt'=>'PREVISIONS NEGATIVES', 'libExt'=>'A suivre. Informations terrain récentes négatives'),
|
||||
'_T' =>array('risque'=>2,'type'=>'LC', 'libInt'=>'LC Quelconque', 'libExt'=>"Nombreuses demandes d'avis de crédit"),
|
||||
);
|
||||
|
||||
private $tabTranches=array( 0=>6,
|
||||
30=>36,
|
||||
60=>66,
|
||||
90=>96,
|
||||
120=>126,
|
||||
150=>156,
|
||||
180=>999);
|
||||
|
||||
private $tabMontants=array( 1=>500,
|
||||
2=>2000,
|
||||
10=>10000,
|
||||
20=>20000,
|
||||
50=>50000,
|
||||
100=>100000,
|
||||
200=>200000,
|
||||
999=>999999);
|
||||
|
||||
// private $siren=0;
|
||||
// private $tabPaiements=array();
|
||||
|
||||
function __construct() {
|
||||
$this->iDb=new WDB('sdv1');
|
||||
}
|
||||
|
||||
function __destruct() {
|
||||
}
|
||||
|
||||
public function setTypeFic($typeFic) {
|
||||
$this->typeFlux=$typeFic;
|
||||
}
|
||||
|
||||
public function readFic($a) {
|
||||
switch ($this->typeFlux) {
|
||||
case 0: // Acheteur
|
||||
$tab=array( 'NUMACH'=> trim(substr($a, 0, 6)),
|
||||
'SIRENE'=> trim(substr($a, 6, 9)),
|
||||
'RAISOC'=> trim(substr($a, 15, 35)),
|
||||
'NUMVOI'=> trim(substr($a, 50, 4)),
|
||||
'TYPVOI'=> trim(substr($a, 54, 3)),
|
||||
'LIBVOI'=> trim(substr($a, 57, 30)),
|
||||
'VILLE' => trim(substr($a, 87, 26)),
|
||||
'CODPOS'=> trim(substr($a,113, 5)),
|
||||
'FILLER'=> trim(substr($a,118, 2)));
|
||||
break;
|
||||
case 1: // CS
|
||||
/*$tab=array( 'DATMAJ1'=> WDate::dateT('ymd','Y-m-d', substr($a, 0, 6)),
|
||||
'NUMGFH'=> trim(substr($a, 6, 6)),
|
||||
'CSAVAN'=> trim(substr($a, 12, 2)),
|
||||
'CSAPRE'=> trim(substr($a, 14, 2)),
|
||||
'INDAUT'=> trim(substr($a, 16, 1)),
|
||||
'CODUTI'=> trim(substr($a, 17, 6)),
|
||||
'INIMAJ'=> trim(substr($a, 23, 3)),
|
||||
'ANAACH'=> trim(substr($a, 25, 2)),
|
||||
'ANAPOR'=> trim(substr($a, 27, 2)));*/
|
||||
$tab=array( 'siren' => trim(substr($a, 0, 9)),
|
||||
'cs' => trim(substr($a, 9, 2)),
|
||||
'dateFin'=> trim(substr($a, 11, 8)));
|
||||
break;
|
||||
case 2: // Paiements
|
||||
$tab=array( 'NUMACH'=> trim(substr($a, 0, 6)),
|
||||
'DATPIE'=> substr($a, 6, 8),
|
||||
'DATECH'=> substr($a, 14, 8),
|
||||
'DATPAI'=> substr($a, 22, 8),
|
||||
'MNTPIE'=> trim(substr($a, 30, 13)),
|
||||
'MNTFRF'=> trim(substr($a, 43, 13)),
|
||||
'MNTLIT'=> trim(substr($a, 56, 13)),
|
||||
'CODDEV'=> trim(substr($a, 69, 3)));
|
||||
break;
|
||||
}
|
||||
return $tab;
|
||||
}
|
||||
|
||||
|
||||
public function getCoteSpeciale($siren) {
|
||||
$ret=$this->iDb->select( 'ge_cs2',
|
||||
'siren, cs, dateFin, dateInsert, dateConf',
|
||||
"siren=$siren AND (dateSuppr=0 OR dateConf>dateSuppr) AND (dateFin=0 OR dateFin>NOW()) AND cs NOT IN (20,22,27,33,34) ORDER BY dateConf DESC, dateInsert DESC", false, MYSQL_ASSOC);
|
||||
$tabRet=array();
|
||||
foreach ($ret as $i=>$tabCS) {
|
||||
$dateEven=$tabCS['dateConf'];
|
||||
if ($dateEven=='0000-00-00') $dateEven=$tabCS['dateInsert'];
|
||||
$tabRet[]=array('DateEven' => $dateEven,
|
||||
'DateFin' => $tabCS['dateFin'],
|
||||
'CoteCS' => $tabCS['cs'],
|
||||
// 'CoteCSpre' => $tabCS['CSAVAN'],
|
||||
'LibCS' => $this->tabInfoCS['_'.$tabCS['cs']]['libExt'],
|
||||
// 'LibCSpre' => $this->tabInfoCS[$tabCS['CSAVAN']*1]['libExt'],
|
||||
'NivRisque' => $this->tabInfoCS['_'.$tabCS['cs']]['risque'],
|
||||
//'NivRisquePre' => $this->tabInfoCS[$tabCS['CSAVAN']*1]['risque'],
|
||||
'CodeRisque' => $this->tabInfoCS['_'.$tabCS['cs']]['type'],
|
||||
);
|
||||
}
|
||||
return $tabRet;
|
||||
}
|
||||
|
||||
public function getCoteSpecialeOld($siren) {
|
||||
$ret=$this->iDb->select( 'ge_cs c LEFT JOIN ge_acheteurs a ON a.NUMACH=c.NUMGFH',
|
||||
'DATMAJ1, NUMGFH, CSAVAN, CSAPRE, SIRENE',
|
||||
"a.SIRENE=$siren ORDER BY a.SIRENE ASC, c.DATMAJ1 DESC", false, MYSQL_ASSOC);
|
||||
$tabRet=array();
|
||||
foreach ($ret as $i=>$tabCS) {
|
||||
$tabRet[]=array('DateEven' => $tabCS['DATMAJ1'],
|
||||
'CoteCS' => $tabCS['CSAPRE'],
|
||||
'CoteCSpre' => $tabCS['CSAVAN'],
|
||||
'LibCS' => $this->tabInfoCS[$tabCS['CSAPRE']*1]['libExt'],
|
||||
'LibCSpre' => $this->tabInfoCS[$tabCS['CSAVAN']*1]['libExt'],
|
||||
'NivRisque' => $this->tabInfoCS[$tabCS['CSAPRE']*1]['risque'],
|
||||
'NivRisquePre' => $this->tabInfoCS[$tabCS['CSAVAN']*1]['risque'],
|
||||
'CodeRisque' => $this->tabInfoCS[$tabCS['CSAPRE']*1]['type'],
|
||||
);
|
||||
}
|
||||
return $tabRet;
|
||||
}
|
||||
|
||||
public function getPaiements($siren, $echelle='mois') {
|
||||
|
||||
if ($echelle=='jour')
|
||||
$strGroupBy="GROUP BY p.DATPIE ";
|
||||
elseif ($echelle=='' || $echelle=='mois')
|
||||
$strGroupBy="GROUP BY mois HAVING nbPieces>2 ";
|
||||
elseif ($echelle=='trim')
|
||||
$strGroupBy="GROUP BY trimestre HAVING nbPieces>2 ";
|
||||
else // En mois par défaut
|
||||
$strGroupBy="GROUP BY mois HAVING nbPieces>2 ";
|
||||
|
||||
$ret=$this->iDb->select( 'ge_paiements p LEFT JOIN ge_acheteurs a ON a.NUMACH=p.NUMACH',
|
||||
"p.NUMACH, DATE_FORMAT(p.DATPIE, '%Y-%m') AS mois,
|
||||
CONCAT(DATE_FORMAT(p.DATPIE,'%Y'),'-',IF(DATE_FORMAT(p.DATPIE,'%m')<4,1,IF(DATE_FORMAT(p.DATPIE,'%m')<7,2,IF(DATE_FORMAT(p.DATPIE,'%m')<10,3,4)))) AS trimestre,
|
||||
count(*) AS nbPieces,
|
||||
AVG(DATEDIFF(NOW(), p.DATECH)) AS nbJourRetard, AVG(DATEDIFF(p.DATPAI, p.DATECH)) AS nbJourPaiement,
|
||||
ROUND(AVG(DATEDIFF(NOW(), p.DATECH) - DATEDIFF(p.DATPAI, p.DATECH))) AS nbJourMoyens,
|
||||
IF(AVG(DATEDIFF(NOW(), p.DATECH) - DATEDIFF( p.DATPAI, p.DATECH ) ) <6, 0, if( AVG( DATEDIFF( NOW( ) , p.DATECH ) - DATEDIFF( p.DATPAI, p.DATECH ) ) <36, 30, if( AVG( DATEDIFF( NOW( ) , p.DATECH ) - DATEDIFF( p.DATPAI, p.DATECH ) ) <66, 60, if( AVG( DATEDIFF( NOW( ) , p.DATECH ) - DATEDIFF( p.DATPAI, p.DATECH ) ) <96, 90, 120 ) ) ) ) AS nbJours,
|
||||
SUM(p.MNTPIE) AS mtPieces, SUM(p.MNTFRF) AS mtPaiements, SUM(p.MNTLIT) AS mtLitiges,
|
||||
p.CODDEV, a.SIRENE, a.RAISOC, a.CODPOS, a.VILLE",
|
||||
"a.SIRENE=$siren AND DATEDIFF(NOW(),p.DATECH)<736 AND p.DATECH<NOW() $strGroupBy ORDER BY p.DATPIE DESC", false, MYSQL_ASSOC);
|
||||
$tabRet=array();
|
||||
foreach ($ret as $i=>$tabPai) {
|
||||
$nbJoursMoyen=$tabPai['nbJourRetard']-$tabPai['nbJourPaiement'];
|
||||
if ($nbJoursMoyen<6) $tranche=0;
|
||||
elseif ($nbJoursMoyen<36) $tranche=30;
|
||||
elseif ($nbJoursMoyen<66) $tranche=60;
|
||||
elseif ($nbJoursMoyen<96) $tranche=90;
|
||||
elseif ($nbJoursMoyen<126) $tranche=120;
|
||||
elseif ($nbJoursMoyen<156) $tranche=150;
|
||||
else $tranche=180;
|
||||
|
||||
$tabRet[]=array('trimestre' => $tabPai['trimestre'],
|
||||
'mois' => $tabPai['mois'],
|
||||
'nbPieces' => $tabPai['nbPieces'],
|
||||
'nbJourRetard' => $tabPai['nbJourRetard'],
|
||||
'nbJourPaiement'=> $tabPai['nbJourPaiement'],
|
||||
'nbJourMoyen' => $nbJoursMoyen,
|
||||
'nbJourMoyen2' => $tabPai['nbJourMoyens'],
|
||||
'tranchePaiement'=>$tranche,
|
||||
'tranchePaie90' =>$tabPai['nbJours'],
|
||||
'mtPieces' => $tabPai['mtPieces'],
|
||||
'mtPaiements' => $tabPai['mtPaiements'],
|
||||
'mtLitiges' => $tabPai['mtLitiges'],
|
||||
'devise' => $tabPai['CODDEV'],
|
||||
);
|
||||
}
|
||||
//$this->tabPaiements=$tabRet;
|
||||
/*@sendMail('production@scores-decisions.com', 'ylenaour@scores-decisions.com', "Indiscore sur $siren : Paiements", "SELECT p.NUMACH, DATE_FORMAT(p.DATPIE, '%Y-%m') AS mois,
|
||||
CONCAT(DATE_FORMAT(p.DATPIE,'%Y'),'-',IF(DATE_FORMAT(p.DATPIE,'%m')<4,1,IF(DATE_FORMAT(p.DATPIE,'%m')<7,2,IF(DATE_FORMAT(p.DATPIE,'%m')<10,3,4)))) AS trimestre,
|
||||
count(*) AS nbPieces,
|
||||
AVG(DATEDIFF(NOW(), p.DATECH)) AS nbJourRetard, AVG(DATEDIFF(p.DATPAI, p.DATECH)) AS nbJourPaiement,
|
||||
ROUND(AVG(DATEDIFF(NOW(), p.DATECH) - DATEDIFF(p.DATPAI, p.DATECH))) AS nbJourMoyens,
|
||||
IF(AVG(DATEDIFF(NOW(), p.DATECH) - DATEDIFF( p.DATPAI, p.DATECH ) ) <6, 0, if( AVG( DATEDIFF( NOW( ) , p.DATECH ) - DATEDIFF( p.DATPAI, p.DATECH ) ) <36, 30, if( AVG( DATEDIFF( NOW( ) , p.DATECH ) - DATEDIFF( p.DATPAI, p.DATECH ) ) <66, 60, if( AVG( DATEDIFF( NOW( ) , p.DATECH ) - DATEDIFF( p.DATPAI, p.DATECH ) ) <96, 90, 120 ) ) ) ) AS nbJours,
|
||||
SUM(p.MNTPIE) AS mtPieces, SUM(p.MNTFRF) AS mtPaiements, SUM(p.MNTLIT) AS mtLitiges,
|
||||
p.CODDEV, a.SIRENE, a.RAISOC, a.CODPOS, a.VILLE
|
||||
FROM ge_paiements p LEFT JOIN ge_acheteurs a ON a.NUMACH=p.NUMACH
|
||||
WHERE a.SIRENE=$siren AND DATEDIFF(NOW(),p.DATECH)<736 AND p.DATECH<NOW() $strGroupBy ORDER BY p.DATPIE DESC".EOL.EOL.print_r($tabRet, true).EOL);
|
||||
*/
|
||||
|
||||
return $tabRet;
|
||||
}
|
||||
|
||||
public function getProfilPayeur($siren) {
|
||||
if ($siren<1000) return '';
|
||||
$libProfil='';
|
||||
/*if ($this->siren==$siren)
|
||||
$tabPaie=$this->tabPaiements;
|
||||
else*/
|
||||
$tabPaie=$this->getPaiements($siren);
|
||||
if (count($tabPaie)>=3) {
|
||||
$tabProfil=array();
|
||||
$paie_min=180;
|
||||
$paie_max=$totFactures=$totPaiements=$totLitiges=0;
|
||||
foreach ($tabPaie as $i=>$tabPai) {
|
||||
if ($i==0) { $this->risqueImpayeMois=$tabPai['mois'];
|
||||
// Dernier délai de paiement en jour
|
||||
$this->DELAIPAY=$tabPai['tranchePaiement'];
|
||||
} elseif ($this->DELAIPAYp=='' && $tabPai['tranchePaiement']<>$this->DELAIPAY ) {
|
||||
$this->DELAIPAYp=$tabPai['tranchePaiement'];
|
||||
$this->DELAIPAY_MMAA=$tabPai['mois'];
|
||||
}
|
||||
$tabProfil[$i]=$tabPai['tranchePaiement'];
|
||||
$totFactures+=$tabPai['mtPieces'];
|
||||
$totPaiements+=$tabPai['mtPaiements'];
|
||||
$totLitiges+=$tabPai['mtLitiges'];
|
||||
if ($tabPai['tranchePaiement']<$paie_min) $paie_min=$tabPai['tranchePaiement'];
|
||||
if ($tabPai['tranchePaiement']>$paie_max) $paie_max=$tabPai['tranchePaiement'];
|
||||
}
|
||||
$tauxLitige=$totLitiges/$totFactures;
|
||||
|
||||
if ($tauxLitige>=0.5) $libProfil.='Litiges très importants. ';
|
||||
elseif ($tauxLitige>0.25) $libProfil.='Litiges importants. ';
|
||||
elseif ($tauxLitige>0.05) $libProfil.='Présence de litiges. ';
|
||||
|
||||
if ($tabProfil[0]==$tabProfil[1] && $tabProfil[1]==$tabProfil[2]) {
|
||||
if ($tranche=0) { $libProfil.='Paiements à échéance'; $this->profilPayeur=1; }
|
||||
elseif ($tranche<=30) { $libProfil.='Paiements à 30 jours maximum'; $this->profilPayeur=2; }
|
||||
elseif ($tranche<=60) { $libProfil.='Paiements à 60 jours maximum'; $this->profilPayeur=3; }
|
||||
elseif ($tranche<=90) { $libProfil.='Paiements à 90 jours maximum'; $this->profilPayeur=4; $this->risqueImpaye=true;}
|
||||
else { $libProfil.='Paiements à plus de 90 jours'; $this->profilPayeur=4; $this->risqueImpaye=true;}
|
||||
} elseif ( ($tabProfil[0]<>$tabProfil[1] && $tabProfil[1]==$tabProfil[2]) ||
|
||||
($tabProfil[0]==$tabProfil[1] && $tabProfil[1]<>$tabProfil[2]) ) {
|
||||
// Récent changement de profil payeur
|
||||
$tranche=$tabProfil[0];
|
||||
$tr_prec=$tabProfil[1];
|
||||
$tr_prec2=$tabProfil[2];
|
||||
if ($tranche<$tr_prec) $libProfil.='Amélioration des délais. ';
|
||||
elseif ($tranche==$tr_prec && $tr_prec<$tr_prec2) $libProfil.='Amélioration des délais. ';
|
||||
else { $this->risqueImpaye=true; $libProfil.='Allongement des délais. '; }
|
||||
|
||||
if ($tranche=0) { $libProfil.='Paiements à échéance'; $this->profilPayeur=1; }
|
||||
elseif ($tranche<=30) { $libProfil.='Paiements à 30 jours maximum'; $this->profilPayeur=2; }
|
||||
elseif ($tranche<=60) { $libProfil.='Paiements à 60 jours maximum'; $this->profilPayeur=3; }
|
||||
elseif ($tranche<=90) { $libProfil.='Paiements à 90 jours maximum'; $this->profilPayeur=4; $this->risqueImpaye=true;}
|
||||
else { $libProfil.='Paiements à plus de 90 jours'; $this->profilPayeur=4; $this->risqueImpaye=true;}
|
||||
} else {
|
||||
if ($paie_max<=30) $this->profilPayeur=1;
|
||||
elseif ($paie_max<=60) $this->profilPayeur=2;
|
||||
elseif ($paie_max<=90) $this->profilPayeur=3;
|
||||
elseif ($paie_max>90) $this->profilPayeur=4;
|
||||
$libProfil.="Paiements entre $paie_min et $paie_max jour(s)";
|
||||
}
|
||||
}
|
||||
|
||||
if (trim($libProfil)=='' && $siren<>552100554 && $siren<>552144503 && $siren<>479974115
|
||||
&& $siren<>0 && $siren<>494967938 ) {
|
||||
$ret=$this->iDb->select('jo.surveillances_listes',
|
||||
'ref, dateAjout, dateConf, dateSuppr, dateDerEnvoi',
|
||||
"idClient='SURBODPRDFTSRECOCASH' AND siren=$siren AND dateSuppr=0
|
||||
AND ABS(DATEDIFF(dateAjout, NOW()))<365
|
||||
ORDER BY dateConf DESC, dateAjout DESC", false, MYSQL_ASSOC);
|
||||
foreach ($ret as $i=>$tabCS) {
|
||||
$dateMAJ=WDate::dateT('Y-m-d', 'M Y', $tabCS['dateAjout']);
|
||||
$libProfil="En date du $dateMAJ : Contentieux importants.";
|
||||
$this->risqueImpaye=true;
|
||||
$this->risqueImpayeMois=WDate::dateT('Y-m', 'Ym', $tabCS['dateAjout']);
|
||||
$this->profilPayeur=4;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//@sendMail('production@scores-decisions.com', 'ylenaour@scores-decisions.com', "Indiscore sur $siren : Paiements", $libProfil.EOL.'Profil payeur = '. $this->profilPayeur .EOL.print_r($tabPaie, true).EOL);
|
||||
|
||||
return $libProfil;
|
||||
}
|
||||
|
||||
public function getTabPaiements($siren) {
|
||||
if ($siren<1000) return false;
|
||||
|
||||
$tabNbr=array(); // Tableau de travail du nombre de factures par trimestre et par tranches de délais de paiements
|
||||
$tabMtAn=array(); // Tableau de travail du nombre de factures par montant et par tranches de délais de paiements
|
||||
|
||||
$tabNbr2=array(); // Tableau retour du nombre de factures par trimestre et par tranches de délais de paiements
|
||||
$tabMtAn2=array(); // Tableau retour du nombre de factures par montant et par tranches de délais de paiements
|
||||
|
||||
$tabPaie=$this->getPaiements($siren, 'jour');
|
||||
foreach ($tabPaie as $i=>$tabPai) {
|
||||
@$tabNbr[$tabPai['trimestre']]['d='.$tabPai['tranchePaiement']]+=$tabPai['nbPieces'];
|
||||
@$tabNbr[$tabPai['trimestre']]['all']+=$tabPai['nbPieces'];
|
||||
$mt=$tabPai['mtPieces']/$tabPai['nbPieces'];
|
||||
// echo "$i\t".$tabPai['trimestre']." (".$tabPai['tranchePaiement']." j)\t$mt=".$tabPai['mtPieces'].'/'.$tabPai['nbPieces'].EOL;
|
||||
if ($mt<500) { @$tabMtAn[1]['d='.$tabPai['tranchePaiement']]++; @$tabMtAn[1]['all']++; }
|
||||
elseif ($mt<2000) { @$tabMtAn[2]['d='.$tabPai['tranchePaiement']]++; @$tabMtAn[2]['all']++; }
|
||||
elseif ($mt<10000) { @$tabMtAn[10]['d='.$tabPai['tranchePaiement']]++; @$tabMtAn[10]['all']++; }
|
||||
elseif ($mt<20000) { @$tabMtAn[20]['d='.$tabPai['tranchePaiement']]++; @$tabMtAn[20]['all']++; }
|
||||
elseif ($mt<50000) { @$tabMtAn[50]['d='.$tabPai['tranchePaiement']]++; @$tabMtAn[50]['all']++; }
|
||||
elseif ($mt<100000) { @$tabMtAn[100]['d='.$tabPai['tranchePaiement']]++; @$tabMtAn[100]['all']++; }
|
||||
elseif ($mt<200000) { @$tabMtAn[200]['d='.$tabPai['tranchePaiement']]++; @$tabMtAn[200]['all']++; }
|
||||
else { @$tabMtAn[999]['d='.$tabPai['tranchePaiement']]++; @$tabMtAn[999]['all']++; }
|
||||
//@$tabMtAn['all'][$tabPai['tranchePaiement']]++;
|
||||
}
|
||||
|
||||
// Recalcul des délais par Trimestre
|
||||
foreach ($tabNbr as $trim=>$tabTranche) {
|
||||
ksort($tabTranche);
|
||||
// Initialisation des tranches à 0
|
||||
foreach ($this->tabTranches as $tranche=>$vide)
|
||||
$tabNbr2[$trim]['nb']=$tabNbr2[$trim]['d='.$tranche]=0;
|
||||
foreach ($tabTranche as $tranche=>$mt3) {
|
||||
$tranche=str_replace('d=','',$tranche);
|
||||
if ($tranche=='all') $tabNbr2[$trim]['nb']=$mt3;
|
||||
else $tabNbr2[$trim]['d='.$tranche]=round(($mt3/$tabNbr2[$trim]['nb'])*100,1);
|
||||
}
|
||||
}
|
||||
|
||||
// Initialisation des tranches à 0 par Montants
|
||||
foreach ($this->tabMontants as $mt=>$vide) {
|
||||
$tabMtAn2['_'.$mt]['nb']=0;
|
||||
foreach ($this->tabTranches as $tranche=>$vide)
|
||||
$tabMtAn2['_'.$mt]['d='.$tranche]=0;
|
||||
}
|
||||
// Recalcul des délais par Montants
|
||||
ksort($tabMtAn);
|
||||
foreach ($tabMtAn as $mt=>$tabTranche) {
|
||||
ksort($tabTranche);
|
||||
foreach ($tabTranche as $tranche=>$mt2) {
|
||||
$tranche=str_replace('d=','',$tranche);
|
||||
if ($tranche=='all') $tabMtAn2['_'.$mt]['nb']=$mt2;
|
||||
else $tabMtAn2['_'.$mt]['d='.$tranche]=round(($mt2/$tabMtAn2['_'.$mt]['nb'])*100,1);
|
||||
}
|
||||
}
|
||||
|
||||
//@sendMail('production@scores-decisions.com', 'ylenaour@scores-decisions.com', "Indiscore sur $siren : Tableaux des Paiements", 'Paiements par montants :'.EOL.print_r($tabMtAn2, true).EOL.EOL.'Paiements par trimestres :'.EOL.print_r($tabNbr2, true).EOL.print_r($tabNbr, true).EOL.print_r($tabMtAn, true).EOL);
|
||||
return array('parMont'=>$tabMtAn2,
|
||||
'parTrim'=>$tabNbr2);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
52
library/Metier/partenaires/classMFedaso.php
Normal file
52
library/Metier/partenaires/classMFedaso.php
Normal file
@ -0,0 +1,52 @@
|
||||
<?
|
||||
class MFedaso {
|
||||
|
||||
private $tabCodeRetour=array(0 => 'Traitement OK',
|
||||
100 => 'Document illisible',
|
||||
101 => 'Document partiellement lisible',
|
||||
102 => 'Document inattendu',
|
||||
103 => 'Page blanche',
|
||||
104 => 'Fichier absent',
|
||||
105 => 'page partiellement scannée',
|
||||
106 => 'Document complémentaire concernant une autre société',
|
||||
107 => 'Page(s) manquante(s)',//NEW
|
||||
108 => 'Document(s) non Francophone',
|
||||
200 => 'Aucune information dirigeants',
|
||||
210 => 'Aucune information actionnaire',
|
||||
211 => 'Aucune information capitalistique',
|
||||
220 => 'Aucune information RIB',
|
||||
221 => 'Code guichet inconnu',
|
||||
250 => 'Raison Sociale absente',//NEW
|
||||
251 => 'Raison Sociale en double : entête retenue',//NEW
|
||||
252 => 'Raison Sociale en double : entête non retenue',//NEW
|
||||
300 => 'Code pays absent du réferentiel',
|
||||
301 => 'Code devise absent du référentiel',
|
||||
201 => 'Code fonction inexistant',
|
||||
);
|
||||
|
||||
public function getRefCodeRetour($sep=',', $eol=EOL) {
|
||||
$str='codRetour'.$sep.'libRetour'.$eol;
|
||||
foreach ($this->tabCodeRetour as $key=>$value)
|
||||
$str.=$key.$sep.$value.$eol;
|
||||
return $str;
|
||||
}
|
||||
|
||||
public function getRefCodeVoie($sep=',', $eol=EOL) {
|
||||
$row = 1;
|
||||
$handle = fopen(DOC_WEB_LOCAL.'voies.csv', 'r');
|
||||
if (!$handle) die('Impossible d\'ouvrir le fichier de configuration des voies INSEE');
|
||||
$tabTmp=array();
|
||||
while (($data = fgetcsv($handle, 1000, ';')) !== FALSE) {
|
||||
if ($row==1)
|
||||
$str='codVoie'.$sep.'libVoie'.$eol;
|
||||
elseif (substr($data[0],0,1)<>'#' && $data[2]==1) // Ligne en commentaires CSV
|
||||
$str.=$data[0].$sep.$data[1].$eol;
|
||||
$row++;
|
||||
}
|
||||
fclose($handle);
|
||||
return $str;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
355
library/Metier/partenaires/classMGlobal.php
Normal file
355
library/Metier/partenaires/classMGlobal.php
Normal file
@ -0,0 +1,355 @@
|
||||
<?
|
||||
|
||||
require_once 'framework/common/curl.php';
|
||||
|
||||
class MGlobal {
|
||||
|
||||
function __construct($siren) {
|
||||
|
||||
$timeout=5;
|
||||
|
||||
$c_cof = curl_init();
|
||||
$c_soc = curl_init();
|
||||
$c_pou = curl_init();
|
||||
|
||||
// Définit l'URL ainsi que d'autres options
|
||||
curl_setopt($c_cof, CURLOPT_URL, 'http://www.cofacerating.fr/portail/entreprise_identite/identite.asp?ip=pagespro&lg=fr&nsiren='.$siren);
|
||||
curl_setopt($c_cof, CURLOPT_HEADER, 0);
|
||||
curl_setopt($c_cof, CURLOPT_TIMEOUT, $timeout);
|
||||
curl_setopt($c_cof, CURLOPT_REFERER, '');
|
||||
|
||||
curl_setopt($ch2, CURLOPT_URL, "http://www.php.net/");
|
||||
curl_setopt($ch2, CURLOPT_HEADER, 0);
|
||||
|
||||
// Création du gestionnaire multiple
|
||||
$mh = curl_multi_init();
|
||||
|
||||
// Ajoute les deux gestionnaires
|
||||
curl_multi_add_handle($mh,$ch1);
|
||||
curl_multi_add_handle($mh,$ch2);
|
||||
|
||||
$running=null;
|
||||
// Exécute le gestionnaire
|
||||
do {
|
||||
curl_multi_exec($mh,$running);
|
||||
} while($running > 0);
|
||||
|
||||
// Ferme tous les gestionnaires
|
||||
curl_multi_remove_handle($ch1);
|
||||
curl_multi_remove_handle($ch2);
|
||||
curl_multi_close($mh);
|
||||
|
||||
// $iDb=new WDB();
|
||||
|
||||
$referer='';
|
||||
$url='http://www.cofacerating.fr/portail/entreprise_identite/identite.asp?ip=pagespro&lg=fr&nsiren='.$siren;
|
||||
$page=getUrl($url, '', '', $referer, false, 'www.cofacerating.fr', '', 10);
|
||||
$this->body=$page['body'];
|
||||
$this->codeRetour=$page['code'];
|
||||
$this->header=$page['header'];
|
||||
$this->nscrl=@getTextInHtml($this->body, '&nscrl=', '=','&');
|
||||
$this->rSocAdrCPVille=trim(str_replace(chr(160), ' ', html_entity_decode(utf8_encode(@getTextInHtml($this->body, '<td WIDTH="40%" bgcolor="#F3E5CC" class="tabligne"> <b> Raison sociale<br>', '<td WIDTH="60%" bgcolor="#FFF3DE" class="tabval"><b>','</tr>')))));
|
||||
$tmp=explode('<br>', $this->rSocAdrCPVille);
|
||||
$this->raisonSociale=trim($tmp[0]);
|
||||
unset($tmp[0]);
|
||||
$this->adresse=trim(strip_tags(implode(',', $tmp)));
|
||||
$this->tel=trim(@getTextInHtml($this->body, '<td bgcolor="#F3E5CC" class="tabligne"><b>Téléphone<br>', '<td bgcolor="#FFF3DE" class="tabval" valign="top">', '<br>'));
|
||||
$this->fax=trim(@getTextInHtml($this->body, 'Télécopie</b></td>', '<br>', '</td>'));
|
||||
$this->web=trim(@getTextInHtml($this->body, '<td bgcolor="#F3E5CC" class="tabligne"><b>Adresse internet <br>', ' class="tabval"><a class="tabval" HREF="', '" target="_new">'));
|
||||
$this->mail=trim(@getTextInHtml($this->body, '<a class="tabval" href="mailto:', ':', '">'));
|
||||
|
||||
$bourse=trim(@getTextInHtml($this->body, 'Ville Bourse</b></td>', 'class="tabval">', '</td>'));
|
||||
$tmp=explode('<br>', $bourse);
|
||||
$this->bourseIsin=trim($tmp[0]);
|
||||
$this->bourseMarche=trim($tmp[1]);
|
||||
$this->bourseVille=trim($tmp[2]);
|
||||
|
||||
$infosDispo=trim(@getTextInHtml($this->body, '<b>Liste Produits</b><br></td>', '<br></td><td class="menu3"><img src="../images/vide.gif" border="0"><br></td><td colspan="2" class="menu3">', 'Un secteur ou une région en France</a><br></td>'));
|
||||
$tabTmp=explode('<a href="', $infosDispo);
|
||||
foreach ($tabTmp as $k=>$lien) {
|
||||
preg_match('/^(.*)">(.*)<\/a>/i', $lien, $matches);
|
||||
if ($matches[2]<>'') $this->tabInfos[$matches[2]]=$matches[1];
|
||||
if (substr($matches[2], 0, 12)=='rapport éco.') $this->infoEco='http://www.cofacerating.fr/portail/entreprise_identite/'.$matches[1];//ip=pagespro&
|
||||
elseif (substr($matches[2], 0, 6)=='bilan ') $this->tabBilans[]=substr($matches[2], 6,strlen($matches[2])-6);
|
||||
}
|
||||
$this->activite=trim(str_replace(chr(160), ' ', html_entity_decode(utf8_encode(@getTextInHtml($this->body, '<td WIDTH="40%" bgcolor="#F3E5CC" class="tabligne" valign="top"><b>Libellé code activité </b></td>', '<td WIDTH="60%" bgcolor="#FFF3DE" class="tabval">', '</td>')))));
|
||||
$this->naf=trim(@getTextInHtml($this->body, '<a href="../chaineeco_dynaeco/DynaEco.asp?cnaf=', 'cnaf=', '&'));
|
||||
|
||||
/**
|
||||
** Recherche du NIC sur Société .com
|
||||
**/
|
||||
|
||||
/*
|
||||
$refererS='http://www.societe.com/';
|
||||
$urlS='http://www.societe.com/cgi-bin/recherche?rncs='.$siren.'&vu=1';
|
||||
$page=getUrl($urlS, '', '', $refererS, false, 'www.societe.com');
|
||||
$ste=$page['body'];
|
||||
$this->nic=trim(@getTextInHtml($ste, 'SIRET</div><div class="ficheAltCol2 size11">', $siren, '</div>'));
|
||||
|
||||
$strTmp=trim(@getTextInHtml($ste, '<b><span class="size10">RCS', 'RCS ', ' '.substr($siren,0,3)));
|
||||
$tabTmp=explode(' ', $strTmp);
|
||||
$this->rcsVille=$tabTmp[0];//<td class="txtBlanc" align="left"><b><span class="size10">RCS Paris B 552 144 503<br></span></b></td>
|
||||
$this->rcsType=$tabTmp[1];
|
||||
|
||||
$strTmp=trim(@getTextInHtml($ste, '<div class="ficheAltCol1 size11">Code activité</div>', '<div class="ficheAltCol2 size11">', '</div>'));
|
||||
$tabTmp=explode(' - ', $strTmp);
|
||||
$this->naf=$tabTmp[0];
|
||||
$this->nafLib=$tabTmp[1];
|
||||
|
||||
// <div class="ficheAltCol1 size11">Siège social</div><div class="ficheAltCol2 size11">75 Avenue la Grande Armee - 75116 PARIS 16</div>
|
||||
|
||||
$strTmp=trim(@getTextInHtml($ste, '<div class="ficheAltCol1 size11">Capital social', '<div class="ficheAltCol2 size11">', '</div>'));
|
||||
$this->capitalType='social';
|
||||
$tabTmp=explode(' ', $strTmp);
|
||||
$this->capitalMontant=str_replace(',', '.', str_replace('.', '', $tabTmp[0]));
|
||||
$this->capitalDevise =$tabTmp[1];
|
||||
|
||||
$this->fj=trim(@getTextInHtml($ste, '<div class="ficheAltCol1 size11">Forme juridique', '<div class="ficheAltCol2 size11">', '</div>'));
|
||||
$this->nationalite=trim(@getTextInHtml($ste, '<div class="ficheAltCol1 size11">Nationalité</div>', '<div class="ficheAltCol2 size11">', '</div>'));
|
||||
|
||||
$strTmp=trim(@getTextInHtml($ste, ' DIRIGEANT(S) </span></span></div>', '<div class="ficheCadre" style="min-height:85px;">', '<div class="spacer"></div>'));
|
||||
$tabTmp=explode('<div class="h1bleu2"></div>', $strTmp);
|
||||
foreach ($tabTmp as $k=>$dir) {
|
||||
if (trim($dir)=='') break;
|
||||
$tabTmp1=explode('</div><div class="ficheAltCol2 size11">', $dir);
|
||||
$tabTmp2=explode('représenté par', $tabTmp1[1]);
|
||||
if (isset($tabTmp2[1]) && $tabTmp2[1]<>'') {
|
||||
$soc=trim($tabTmp2[0]);
|
||||
$diri=trim($tabTmp2[1]);
|
||||
} else {
|
||||
$soc='';
|
||||
$diri=trim($tabTmp1[1]);
|
||||
}
|
||||
preg_match("/^(Mme|M\.|Mlle|Mle|M) ([A-Z\s]*) ([A-Z][a-z\s]*)/", $diri, $matches);
|
||||
//print_r($matches);
|
||||
$this->tabDirigeants[]=array('FONCTION'=>trim(strip_tags($tabTmp1[0])), 'SOCIETE'=>$soc, 'GENRE'=>$matches[1], 'PRENOM'=>trim($matches[3]), 'NOM'=>trim($matches[2]));
|
||||
}
|
||||
|
||||
$this->dateImmatriculation=trim(@getTextInHtml($ste, '<div class="ficheAltCol1 size11"> Immatriculation', '<div class="ficheAltCol2 size11">', '</div>'));
|
||||
//06-03-2007</div>
|
||||
/* Date Creation = ""
|
||||
En bourse = ""
|
||||
Effectif societe = ""
|
||||
Dirigeants :
|
||||
**/
|
||||
$urlRacine='http://infobilan.decideur.com/';
|
||||
$tabPost=array( 'choix'=>'1',
|
||||
'pagePrecedente'=>'recherche_entreprise.html',
|
||||
'nomsocRech'=>'',
|
||||
'cpRech'=>'',
|
||||
'villeRech'=>'',
|
||||
'nomdirRech'=>'',
|
||||
'predirRech'=>'',
|
||||
'sirenRech'=>$siren,
|
||||
'telRech'=>'',
|
||||
'Rechercher.x'=>round(79),
|
||||
'Rechercher.y'=>round(19),);
|
||||
$url=$urlRacine.'liste_result.html';
|
||||
$referer=$urlRacine.'recherche_entreprise.html';
|
||||
$page=getUrl($url,'', $tabPost, $referer, false, 'infobilan.decideur.com');
|
||||
$this->body=$page['body'];
|
||||
$strCookie=$page['header']['Set-Cookie'];
|
||||
$refererInfoD=$url;
|
||||
|
||||
if(preg_match_all('/<a href="choix_pdt\.html\?(.*)" class="tt1">(.*)<\/a><\/span><br>/i', $page['body'], $matches))
|
||||
$urlInfoD=$urlRacine.'choix_pdt.html?'.$matches[1][0];
|
||||
else
|
||||
$urlInfoD='';
|
||||
|
||||
$page=getUrl($this->infoEco, '', '', $url, false, 'www.cofacerating.fr');
|
||||
if (strpos($page['body'], '<b>Choix du mode de paiement</b>')===false) { // Le rapport éco. est cadeau !!!
|
||||
$this->infoEco=true;
|
||||
$eco=$page['body'];
|
||||
//die ($eco);
|
||||
$strTmp=strip_tags(@getTextInHtml($eco, ' class="tabligne" > Capital   (', '(', '</tr><tr>'));
|
||||
$tabTmp=explode(')', $strTmp);
|
||||
$this->capitalType=$tabTmp[0];
|
||||
$tabTmp=explode(' ', $tabTmp[1]);
|
||||
$this->capitalMontant=trim(str_replace(chr(160), '', $tabTmp[0]));
|
||||
$this->capitalDevise =trim(str_replace(chr(160), '', $tabTmp[1]));
|
||||
|
||||
$this->steInactive=trim(@getTextInHtml($eco, ' class="tabligne" > Société inactive</td>', 'class="tabval" >', '</td>'));
|
||||
|
||||
$this->dateCreation=trim(@getTextInHtml($eco, ' class="tabligne" > Date de création</td>', 'class="tabval" >', '</td>'));
|
||||
$this->fj=trim(@getTextInHtml($eco, ' class="tabligne" > Forme juridique</td>', 'class="tabval" >', '</td>'));
|
||||
$this->effectif=trim(@getTextInHtml($eco, ' class="tabligne" > Effectif', 'class="tabval" >', '</td>'));
|
||||
|
||||
if (count($this->tabDirigeants)==0) { // Si il y a déjà des dirigeants on garde ceux de Société.com !!!
|
||||
$strTmp=trim(@getTextInHtml($eco, ' class="tabligne" > Cotation en bourse</td>', '<td bgcolor="#F3E5CC" class="tabligne" >', '<td bgcolor="#F3E5CC" class="tabligne" > Effectif'));
|
||||
$tabTmp=explode('<td bgcolor="#F3E5CC" class="tabligne" >', $strTmp);
|
||||
foreach ($tabTmp as $k=>$dir) {
|
||||
$tabTmp1=explode('<td bgcolor="#FFF3DE" class="tabval" >', $dir);
|
||||
$tabTmp2=explode(' ', trim(strip_tags($tabTmp1[1])));
|
||||
$this->tabDirigeants[]=array('FONCTION'=>trim(strip_tags($tabTmp1[0])), 'GENRE'=>trim($tabTmp2[0]), 'PRENOM'=>trim($tabTmp2[1]), 'NOM'=>trim($tabTmp2[2]));
|
||||
}
|
||||
}
|
||||
|
||||
$this->strLiensFi=trim(strip_tags(@getTextInHtml($eco, '<td class="tabtot">LIENS FINANCIERS</td>', '<tr>', '</td></tr>')));
|
||||
$this->strElemsFi=trim(strip_tags(@getTextInHtml($eco, '<td class="tabtot">ELEMENTS FINANCIERS</td>', '<tr>', '</td></tr>')));
|
||||
}
|
||||
|
||||
$refererP='http://www.score3.fr/';
|
||||
$urlP='http://www.score3.fr/entreprise.shtml?siren='.$siren;
|
||||
$page=getUrl($urlP, '', '', $refererP, false, 'www.score3.fr');
|
||||
$pou=$page['body'];
|
||||
$fp=fopen('./pouet.html', 'w');
|
||||
fwrite($fp, $pou);
|
||||
fclose($fp);
|
||||
|
||||
if ($urlInfoD<>'') {
|
||||
$page=getUrl($urlInfoD,$strCookie,'', $refererInfoD, false, 'infobilan.decideur.com');
|
||||
$referer=$urlInfoD;
|
||||
if ($this->nscrl==0) $this->nscrl=@getTextInHtml($url, 'nscrlP=', '=','&');
|
||||
|
||||
$url=$urlRacine.'fiche_ident.html';
|
||||
$page=getUrl($url,$strCookie,'', $referer, false, 'infobilan.decideur.com');
|
||||
$this->body=$page['body'];
|
||||
|
||||
if ($this->raisonSociale=='')
|
||||
$this->raisonSociale=trim(@getTextInHtml($this->body, '<span class="libelle2">Société', ' :', '</span>'));
|
||||
|
||||
if ($this->adresse=='')
|
||||
$this->adresse=trim(@getTextInHtml($this->body, '<span class="libelle2">Adresse</span> <strong>:', '</strong>', '</td>'));
|
||||
|
||||
if ($this->tel=='')
|
||||
$this->tel=trim(@getTextInHtml($this->body, '<td valign="top"><span class="libelle2">Tél', '</span>', '<br>'));
|
||||
if ($this->fax=='')
|
||||
$this->fax=trim(@getTextInHtml($this->body, '<span class="libelle2">Fax</span>', ' :', '<br>'));
|
||||
if ($this->web=='')
|
||||
$this->web=trim(@getTextInHtml($this->body, '<span class="libelle2">Site Web</span>', '<a href="', '" target="_blank">'));
|
||||
if ($this->mail=='')
|
||||
$this->mail=trim(@getTextInHtml($this->body, '<span class="libelle2">E-mail</span>', '<a href="mailto:', '">'));
|
||||
if ($this->naf=='')
|
||||
$this->naf=trim(@getTextInHtml($this->body, '<span class="libelle2">Code NAF</span>', ' :', '</td>'));
|
||||
|
||||
if(preg_match('/<td valign="top"><span class="libelle2">Capital social<\/span> : (\d*)(.*)<br>/isU', $this->body, $matches)
|
||||
&& ($this->capitalMontant=='' || $this->capitalDevise=='')) {
|
||||
$this->capitalMontant=trim($matches[1]);
|
||||
$this->capitalDevise=trim($matches[2]);
|
||||
}
|
||||
|
||||
if ($this->fj=='')
|
||||
$this->fj=trim(@getTextInHtml($this->body, '<span class="libelle2">Forme juridique</span>', ' :', '<br>'));
|
||||
if ($this->nationalite=='')
|
||||
$this->nationalite=trim(@getTextInHtml($this->body, '<span class="libelle2">Nationalité</span>', ' :', '</td>'));
|
||||
if ($this->effectif=='')
|
||||
$this->effectif=trim(@getTextInHtml($this->body, '<td valign="top"><span class="libelle2">Effectif</span>', ' :', '<br>'));
|
||||
if ($this->activite=='')
|
||||
$this->activite=trim(@getTextInHtml($this->body, '<span class="libelle2">Activité</span>', ' :', '<br>'));
|
||||
|
||||
/** Actionnaires **/
|
||||
$strTmp=trim(@getTextInHtml($this->body, 'ACTIONNAIRES<br>', '</div></h1>', '<h1>'));
|
||||
if(preg_match_all('/<p><span class="libelle2">(.*)<\/span> - <span class="libelle2">Participation<\/span> : (.*) %<br>(.*)<\/p>/isU', $strTmp, $matches)) {
|
||||
foreach ($matches[1] as $i=>$nom) {
|
||||
$this->tabAct[$i]['nom']=trim($nom);
|
||||
$this->tabAct[$i]['pct']=trim($matches[2][$i]);
|
||||
$this->tabAct[$i]['rcs']=trim(str_replace('RCS : ','',strip_tags($matches[3][$i])));
|
||||
}
|
||||
}
|
||||
|
||||
/** Filiales **/
|
||||
$strTmp=trim(@getTextInHtml($this->body, 'FILIALES<br>', '</div></h1>', '<h1>'));
|
||||
if(preg_match_all('/<p><span class="libelle2">(.*)<\/span> - <span class="libelle2">Participation<\/span> :(.*)%<br>(.*)<\/p>/isU', $strTmp, $matches)) {
|
||||
foreach ($matches[1] as $i=>$nom) {
|
||||
$this->tabFil[$i]['nom']=trim($nom);
|
||||
$this->tabFil[$i]['pct']=trim($matches[2][$i]);
|
||||
$this->tabFil[$i]['rcs']=trim(str_replace('RCS :','',strip_tags($matches[3][$i])));
|
||||
}
|
||||
}
|
||||
|
||||
/** CA et Résultat **/
|
||||
$strTmp=trim(@getTextInHtml($this->body, '<h1>PRINCIPAUX ELEMENTS FINANCIERS<br>', '</div></h1>', '</p>'));
|
||||
if(preg_match('/<p><span class="libelle2">CA (.*)<\/span>(.*)<br>/isU', $strTmp, $matches)) {
|
||||
$this->derExerciceAnnee=trim($matches[1]);
|
||||
$this->derExerciceCA=trim(str_replace(':',' ', $matches[2]));
|
||||
}
|
||||
if(preg_match('/<span class="libelle2">Résultat(.*)<\/span>(.*)$/isU', $strTmp, $matches)) {
|
||||
$this->derExerciceResultat=trim(str_replace(':',' ', $matches[2]));
|
||||
}
|
||||
|
||||
$infoBilan=print_r($page, true);
|
||||
$fp=fopen('./infobilan.html', 'w');
|
||||
fwrite($fp, $infoBilan);
|
||||
fclose($fp);
|
||||
}
|
||||
|
||||
if ($this->nbEtab=='' || $this->nbEtab=='0') {
|
||||
$this->nbEtab=trim(strip_tags(str_replace('afficher la liste...', '', @getTextInHtml($pou, '<tr><td class="ligne1_2">Etablissements </td>', '<td class="ligne2_2">', '</td></tr>'))));
|
||||
$urlPEtab='http://www.score3.fr/etablissements.shtml?page=1&siren='.$siren;
|
||||
$refererPEtab=$urlP;
|
||||
$page=getUrl($urlPEtab, '', '', $refererPEtab, false, 'www.score3.fr');
|
||||
$pou2=$page['body'];
|
||||
if(preg_match_all('/<tr bgcolor="(?:\S*)"><td class="ligne1b" align="center" width="10%">(\d*)<\/td><td class="ligne2" height="50"><table cellpadding="0" cellspacing="0" border="0" width="100%"><tr><td class="infos">(.*)<\/td><\/tr><\/table>/isU', $pou2, $matches)) {
|
||||
foreach ($matches[1] as $i=>$nic) {
|
||||
$strEtab=$matches[2][$i];
|
||||
$this->tabEtab[$i]['siren']=$siren;
|
||||
$this->tabEtab[$i]['nic']=$nic;
|
||||
$this->tabEtab[$i]['siret']=$siren.$nic;
|
||||
|
||||
$this->tabEtab[$i]['enseigne']=trim(str_replace(chr(160),' ',utf8_decode(strip_tags(@getTextInHtml($strEtab, '<span class="titre3">', '">', '</span>')))));
|
||||
$this->tabEtab[$i]['adresse']=trim(str_replace(chr(160),' ',utf8_decode(strip_tags(@getTextInHtml($strEtab, '<span class="infos">', '">', '<br>')))));
|
||||
$strTmp=trim(str_replace(chr(160),' ',utf8_decode(strip_tags(@getTextInHtml($strEtab, '<span class="infos">', '<br>', '</span>')))));
|
||||
$tabTmp=explode(' ', $strTmp);
|
||||
$this->tabEtab[$i]['cp']=$tabTmp[0];
|
||||
unset($tabTmp[0]);
|
||||
$this->tabEtab[$i]['ville']=implode(' ',$tabTmp);
|
||||
$strTmp=trim(strip_tags(@getTextInHtml($strEtab, '<td class="infos" align="right" valign="top">', '">', ')')));
|
||||
$tabTmp=explode('(', $strTmp);
|
||||
$this->tabEtab[$i]['naf_code']=$tabTmp[1];
|
||||
$this->tabEtab[$i]['naf_lib']=trim(str_replace(chr(160),' ',utf8_decode($tabTmp[0])));
|
||||
if (preg_match('/<br>T.l\.(.*)$/i',$strEtab,$matches2))
|
||||
$this->tabEtab[$i]['tel']=trim(str_replace(chr(160),' ',utf8_decode($matches2[1])));
|
||||
else $this->tabEtab[$i]['tel']='';
|
||||
}
|
||||
}
|
||||
$this->nbEtab=count($this->tabEtab);
|
||||
$fp=fopen('./pouet_etab.html', 'w');
|
||||
fwrite($fp, $pou2);
|
||||
fclose($fp);
|
||||
}
|
||||
|
||||
if ($this->effectif=='' || $this->effectif=='0' || $this->effectif=='NC')
|
||||
$this->effectif=trim(@getTextInHtml($pou, '<tr><td class="ligne1_2">Effectifs</td>', '<td class="ligne2_2">', '</td></tr>'));
|
||||
|
||||
if ($this->dateImmatriculation=='' || $this->dateImmatriculation=='0')
|
||||
$this->dateImmatriculation=trim(@getTextInHtml($pou, '<tr><td class="ligne1_2">Date d\'immatriculation</td>', '<td class="ligne2_2">', '</td></tr>'));
|
||||
if ($this->dateFermeture=='' || $this->dateFermeture=='0')
|
||||
$this->dateFermeture=trim(@getTextInHtml($pou, '<tr><td class="ligne1_2">Date de fin d\'exploitation</td>', '<td class="ligne2_2">', '</td></tr>'));
|
||||
|
||||
if ($this->tel=='' || $this->tel=='0')
|
||||
$this->tel=trim(@getTextInHtml($pou, '<tr><td class="ligne1_2">Téléphone</td>', '<td class="ligne2_2">', '</td></tr>'));
|
||||
|
||||
if ($this->fax=='' || $this->fax=='0')
|
||||
$this->fax=trim(@getTextInHtml($pou, '<tr><td class="ligne1_2">Fax</td>', '<td class="ligne2_2">', '</td></tr>'));
|
||||
|
||||
$strTmp=trim(@getTextInHtml($pou, 'Procédures collectives</td></tr>', '</table></td>', '</td><td background'));
|
||||
if(preg_match_all('/<tr><td class="ligne1_2">(.*)<\/td><td class="ligne2_2">(.*)<\/td><\/tr>/isU', $strTmp, $matches)) {
|
||||
foreach ($matches[1] as $i=>$jug) {
|
||||
$this->tabJug[$i]['date']=$matches[1][$i];
|
||||
$this->tabJug[$i]['juge']=$matches[2][$i];
|
||||
}
|
||||
}
|
||||
|
||||
$this->score_pouey=trim(@getTextInHtml($pou, '<param name="movie" value="cadran.swf?rotation=', '&type=pouey&valeur=', '">'));
|
||||
$this->score_conan=trim(@getTextInHtml($pou, '<param name="movie" value="cadran.swf?rotation=', '&type=ch&valeur=', '">'));
|
||||
$this->score_afdcc=trim(@getTextInHtml($pou, '<param name="movie" value="cadran.swf?rotation=', '&type=afdcc&valeur=', '">'));
|
||||
$this->vigilance =trim(@getTextInHtml($pou, '<param name="movie" value="vigilance.swf', 'degre=', '">'));
|
||||
|
||||
if(preg_match('/Date de l\'exercice<\/td><td class="ligne2_2">(.*) sur (\d*) mois<\/td><\/tr>/isU', $pou, $matches)) {
|
||||
$this->derExerciceDClot=trim($matches[1]);
|
||||
$this->derExerciceDuree=trim($matches[2]);
|
||||
}
|
||||
|
||||
/* Siret SIEGE
|
||||
2 Fonction, Nom Prénoù ET Date NAissance du PP
|
||||
5 Liste des actes
|
||||
*/
|
||||
if ($this->codeRetour==200)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
3139
library/Metier/partenaires/classMGreffes.php
Normal file
3139
library/Metier/partenaires/classMGreffes.php
Normal file
File diff suppressed because it is too large
Load Diff
365
library/Metier/partenaires/classMIntersud.php
Normal file
365
library/Metier/partenaires/classMIntersud.php
Normal file
@ -0,0 +1,365 @@
|
||||
<?php
|
||||
require_once 'framework/common/curl.php';
|
||||
/** @todo A faire et sortir du coup la méthode de commande d'enquêtes du WS **/
|
||||
class MIntersud {
|
||||
|
||||
private $body = '';
|
||||
private $header = '';
|
||||
private $codeRetour = 0;
|
||||
private $cookie=false;
|
||||
private $reference = 0;
|
||||
private $timeOut=0;
|
||||
private $url='';
|
||||
private $urlRacine='http://www.intersud.fr';
|
||||
private $referer='';
|
||||
private $curPage='';
|
||||
public $siren;
|
||||
|
||||
function __construct() {
|
||||
$this->partGetSession();
|
||||
$this->partConnection();
|
||||
}
|
||||
|
||||
function __destruct() {
|
||||
$this->partSaveSession();
|
||||
}
|
||||
|
||||
function getInfosDisponbiles($siren) {
|
||||
$this->siren=$siren;
|
||||
$this->partConnection();
|
||||
return $this->partVitrine(true);
|
||||
}
|
||||
|
||||
private function partConnection() {
|
||||
if (!$this->wrncsrv2 || time()>$this->timeOut) {
|
||||
$this->timeOut=time()+900;
|
||||
|
||||
$this->url=$this->urlRacine.'/index.ow';
|
||||
$page=getUrl($this->url, '', '', $this->urlRacine, false, 'www.euridile.com');
|
||||
$this->referer=$this->url;
|
||||
$this->body=$page['body'];
|
||||
$this->codeRetour=$page['code'];
|
||||
$this->header=$page['header'];
|
||||
//echo date('Y/m/d - H:i:s') ." - Initialisation URL = $this->url (Code retour = $this->codeRetour)<br/>".EOL;
|
||||
$fp=fopen('./euridile_connexion1.log', 'w');
|
||||
fwrite($fp,print_r($page,true));
|
||||
fclose($fp);
|
||||
if (preg_match('/<META HTTP-EQUIV="Refresh" CONTENT="0; URL=(.*)">/i', $this->body, $matches))
|
||||
$this->url=$this->urlRacine.'/'.$matches[1];
|
||||
else debugLog('E',"Erreur de communication - Redirection impossible sur ".$this->url,__LINE__,__FILE__,__FUNCTION__,__CLASS__);
|
||||
debugLog('I','Redirection trouv<75>e sur la page '.$this->url,__LINE__,__FILE__,__FUNCTION__,__CLASS__);
|
||||
|
||||
if (preg_match('/\.ow\?WRNCSRV2=(.*)$/i', $matches[1], $matches)) {
|
||||
$this->wrncsrv2=$matches[1];
|
||||
debugLog('I','Session partenaire WRNCSRV2='.$this->wrncsrv2,__LINE__,__FILE__,__FUNCTION__,__CLASS__);
|
||||
}
|
||||
else debugLog('E','Impossible d\'identifier le num<75>ro de session partenaire',__LINE__,__FILE__,__FUNCTION__,__CLASS__);
|
||||
|
||||
$page=getUrl($this->url, '', '',$this->referer, false, 'www.euridile.com');
|
||||
$this->referer=$this->url;
|
||||
$this->body=$page['body'];
|
||||
$this->codeRetour=$page['code'];
|
||||
$this->header=$page['header'];
|
||||
debugLog('D',"Page d'accueil URL = $this->url (Code retour = $this->codeRetour)",__LINE__,__FILE__,__FUNCTION__,__CLASS__);
|
||||
$fp=fopen('./euridile_connexion2.log', 'w');
|
||||
fwrite($fp,print_r($page,true));
|
||||
fclose($fp);
|
||||
|
||||
if (preg_match('/<form method="POST" name="abonnement" ACTION="(.*)" /i', $this->body, $matches)) {
|
||||
$postData=array('IDENT'=>'OK',
|
||||
'MDP'=>'3180',
|
||||
'cliref'=>'K5K3X5',
|
||||
'PASS'=>'3180',
|
||||
'WRNCSRV2'=>$this->wrncsrv2);
|
||||
/** @todo Fair une fonction qui g<EFBFBD>re les URL commen<EFBFBD>ant par ./ ou ../ ou / afin de pouvoir les concatener
|
||||
**/
|
||||
$this->url=$this->urlRacine.str_replace('..','',$matches[1]);
|
||||
debugLog('D',"Authentification possible vers $this->url",__LINE__,__FILE__,__FUNCTION__,__CLASS__);
|
||||
}
|
||||
else debugLog('E',"Authentification impossible car formulaire indisponible",__LINE__,__FILE__,__FUNCTION__,__CLASS__);
|
||||
|
||||
sleep(1);
|
||||
$page=getUrl($this->url,'', $postData, $this->referer, false, 'www.euridile.com');
|
||||
$this->referer=$this->url;
|
||||
$this->body=$page['body'];
|
||||
$this->codeRetour=$page['code'];
|
||||
$this->header=$page['header'];
|
||||
//echo date('Y/m/d - H:i:s') ." - Apr<70>s authentification = $this->url (Code retour = $this->codeRetour)<br/>".EOL;
|
||||
$fp=fopen('./euridile_connexion3.log', 'w');
|
||||
fwrite($fp,print_r($page,true));
|
||||
fclose($fp);
|
||||
|
||||
if(preg_match('/\/'.$this->weur.'\/iden_evaluation_type_(.*)/i', $this->body, $matches))
|
||||
{ $tabTmp=explode('"', $matches[0]);
|
||||
$this->url=$this->urlRacine.$tabTmp[0];
|
||||
debugLog('D',"Page de recherche recherche trouv<75>e = $this->url>",__LINE__,__FILE__,__FUNCTION__,__CLASS__);
|
||||
} else debugLog('E',"Erreur de communication - Recherche introuvable !",__LINE__,__FILE__,__FUNCTION__,__CLASS__);
|
||||
|
||||
$this->curPage='recherche';
|
||||
} //else echo date('Y/m/d - H:i:s') ." - Deja connecte !<br/>".EOL;
|
||||
return true;
|
||||
}
|
||||
|
||||
private function partIdentite() {
|
||||
if ($this->curPage<>'vitrine')
|
||||
$this->partVitrine();
|
||||
|
||||
$iDb=new WDB('jo');
|
||||
$ret=$iDb->select( 'rncs_entrep',
|
||||
'siren, rcs, nom, adresse1, adresse2, adresse3, cp, ville, naiss_date, naiss_lieu, sexe, enseigne, sigle, '.
|
||||
'fj_lib, naf_code, naf_lib, date_crea, date_imma, greffe, num_gestion, capital_mnt, capital_dev, nationalite, '.
|
||||
'nb_etab, indRadiation, date_radiation, indProcol, dateUpdate, procedures, dirigeants, etablissements',
|
||||
"siren=$this->siren ORDER BY dateUpdate DESC LIMIT 0,1", false, MYSQL_ASSOC);
|
||||
if (count($ret)) {
|
||||
/** On v<EFBFBD>rifie qu'aucune annonce n'a <EFBFBD>t<EFBFBD> publi<EFBFBD> depuis au bodacc
|
||||
**/
|
||||
$tabRet=$ret[0];
|
||||
$ret=$iDb->select( 'bodacc_detail', 'count(*)',
|
||||
"siren=$this->siren AND Bodacc_Date_Parution>='".$tabRet['dateUpdate']."'");
|
||||
if ($ret[0][0]==0) {
|
||||
$tabRet['procedures']=unserialize($tabRet['procedures']);
|
||||
$tabRet['dirigeants']=unserialize($tabRet['dirigeants']);
|
||||
$tabRet['etablissements']=unserialize($tabRet['etablissements']);
|
||||
return $tabRet;
|
||||
}
|
||||
}
|
||||
|
||||
$url=$this->urlRacine.'/'.$this->weur.'/paie_abonnes_livraison_directe_informations.ow?flag_type_acces_direct_infos=FIC&WRNCSRV2='.$this->wrncsrv2;
|
||||
$page=getUrl($url, '', '', $this->referer, false, 'www.euridile.com');
|
||||
$this->body=$page['body'];
|
||||
$this->codeRetour=$page['code'];
|
||||
$this->header=$page['header'];
|
||||
//echo date('Y/m/d - H:i:s') ." - Fiche d'identit<69> = $url (Code retour = $this->codeRetour)<br/>".EOL;
|
||||
//$this->curPage='vitrine';
|
||||
$tabRet=array();
|
||||
|
||||
/**@todo Traiter le cas donn<EFBFBD>es provisoires :
|
||||
<TR><TD bgcolor='#fff0d0'><FONT COLOR=#100070 FACE=ARIAL SIZE=2><B><!-- Donn<6E>es provisoires --> En cours d'immatriculation, donn<6E>es provisoires</B></FONT></TD></TR><TR><TD bgcolor=#fff0d0><FONT COLOR=#100070 FACE=ARIAL SIZE=2>Nombre d'<27>tablissements : <FONT COLOR=#100070 FACE=ARIAL SIZE=2><B></B></TD></TR>
|
||||
</TABLE>
|
||||
*/
|
||||
// Identit<69>
|
||||
$tabRet['siren']=$this->siren;
|
||||
$tabRet['codeRetour']=$this->codeRetour;
|
||||
$tabRet['rcs']=@getTextInHtml($this->body, 'FACE="ARIAL,HELVETICA" SIZE=2>RCS : ', '<b>','</b>');
|
||||
$strTmp=@getTextInHtml($this->body, 'FACE="ARIAL,HELVETICA" SIZE=2>RCS : <b>', 'FACE="ARIAL,HELVETICA" SIZE=2><b>', '<img src=\'images/rouge.gif\'');
|
||||
$tabTmp=explode('</TD>', $strTmp);
|
||||
$tabRet['nom']=strip_tags($tabTmp[0]);
|
||||
// ... adresse
|
||||
for ($i=1; $i<5; $i++) {
|
||||
if (strpos($tabTmp[$i], 'Nom commercial - Enseigne :')===false &&
|
||||
strpos($tabTmp[$i], 'Sigle :')===false ) {
|
||||
$ligne=trim(strip_tags($tabTmp[$i]));
|
||||
if (preg_match("/^([0-9]{5,5})([\D]*)/i", $ligne, $matches)) {
|
||||
$tabRet['cp']=trim($matches[1]);
|
||||
$tabRet['ville']=trim($matches[2]);
|
||||
break;
|
||||
} else $tabRet['adresse'.$i]=$ligne;
|
||||
}
|
||||
}
|
||||
|
||||
$pp_nais=trim(strip_tags(@getTextInHtml($this->body, 'FACE=\'ARIAL,HELVETICA\' SIZE=2>Date et lieu de naissance :', '<B>','</B>')));
|
||||
$tabTmp=explode(' <20> ', $pp_nais);
|
||||
$tabRet['naiss_date']=trim(str_replace('N<>(e) le ', '', strip_tags($tabTmp[0])));
|
||||
$tabRet['naiss_lieu']=trim(strip_tags($tabTmp[1]));
|
||||
$tabRet['sexe']=trim(strip_tags(@getTextInHtml($this->body, 'FACE=\'ARIAL,HELVETICA\' SIZE=2>Sexe :', '<B>','</B>')));
|
||||
|
||||
$tabRet['enseigne']=trim(strip_tags(@getTextInHtml($this->body, 'FACE=ARIAL SIZE=2>Nom commercial - Enseigne :', '<B>','</B>')));
|
||||
$tabRet['sigle']=trim(strip_tags(@getTextInHtml($this->body, 'FACE=ARIAL SIZE=2>Sigle :', '<B>','</B>')));
|
||||
$tabRet['fj_lib']=@getTextInHtml($this->body, 'FACE=\'ARIAL,HELVETICA\' SIZE=2>Forme juridique :', '<B>','</B>');
|
||||
$strTmp=@getTextInHtml($this->body, 'FACE=\'ARIAL,HELVETICA\' SIZE=2>Activité :', '<B>','</B>');
|
||||
$tabTmp=explode(' - ', $strTmp);
|
||||
$tabRet['naf_code']=$tabTmp[0];
|
||||
$tabRet['naf_lib']=$tabTmp[1];
|
||||
$tabRet['date_crea']=trim(strip_tags(@getTextInHtml($this->body, 'FACE=ARIAL SIZE=2>Date de création :', '<B>','</B>')));
|
||||
$tabRet['date_imma']=trim(strip_tags(@getTextInHtml($this->body, 'FACE=ARIAL SIZE=2>Date d\'immatriculation :', '<B>','</B>')));
|
||||
$tabRet['greffe']=trim(strip_tags(@getTextInHtml($this->body, 'FACE=ARIAL SIZE=2>Greffe :', '<B>','</B>')));
|
||||
$tabRet['num_gestion']=trim(strip_tags(@getTextInHtml($this->body, 'FACE=ARIAL SIZE=2>N<>de gestion :', '<B>','</B>')));
|
||||
$strTmp=@getTextInHtml($this->body, 'FACE=ARIAL SIZE=2>Capital :', '<B>','</B>');
|
||||
if (preg_match('/([0-9\.,\s]*)([\D]*)/i', $strTmp, $matches)) {
|
||||
$tabRet['capital_mnt']=trim(str_replace(' ','',str_replace(',','.',$matches[1])));
|
||||
$tabRet['capital_dev']=$matches[2];
|
||||
}
|
||||
else {
|
||||
$tabRet['capital_mnt']=0;
|
||||
$tabRet['capital_dev']='';
|
||||
}
|
||||
$tabRet['nationalite']=trim(strip_tags(@getTextInHtml($this->body, 'FACE=ARIAL SIZE=2>Nationalité :', '<B>','</B>')));
|
||||
$tabRet['nb_etab']=trim(strip_tags(@getTextInHtml($this->body, 'FACE=ARIAL SIZE=2>Nombre d\'<27>tablissements :', '<B>','</B>')));
|
||||
if (strpos($this->body,'FACE=ARIAL SIZE=2><B>Radiation</B>')>0) {
|
||||
$tabRet['indRadiation']=true;
|
||||
$tabRet['date_radiation']=trim(strip_tags(@getTextInHtml($this->body, 'FACE=ARIAL SIZE=2>Entreprise radi<64>e le :', '<B>','</B>')));
|
||||
} else
|
||||
$tabRet['indRadiation']=false;
|
||||
|
||||
// Proc<6F>dures collectives
|
||||
if (strpos($this->body,'FACE=ARIAL SIZE=2><B>Les proc<6F>dures collectives</B>')>0) {
|
||||
$tabRet['indProcol']=true;
|
||||
$strTmp=@getTextInHtml($this->body, '<B>Les proc<6F>dures collectives</B></FONT>', "<img src='./images/rouge.gif' width=4 height=4 border='0'>",
|
||||
'</TABLE>');
|
||||
$tabTmp=explode("<img src='./images/rouge.gif' width=4 height=4 border='0'>", $strTmp);
|
||||
foreach ($tabTmp as $nproc=>$proc) {
|
||||
$tabTmp2=explode('</TD></TR>', $proc);
|
||||
$tabTmp3=explode(' du ', $tabTmp2[0]);
|
||||
$tabTmp2=explode('<TD WIDTH=99% ALIGN=LEFT BGCOLOR=#fff0d0 colspan=2><FONT COLOR=#100070 FACE=ARIAL SIZE=2>', $proc);
|
||||
$tabInter=array();
|
||||
for($nInter=1; isset($tabTmp2[$nInter]); $nInter++) {
|
||||
$tabTmp4=explode('</TD></TR>', $tabTmp2[$nInter]);
|
||||
$tabInter[]=array( 'type'=>trim(strip_tags($tabTmp4[0])),
|
||||
'nom'=>trim(str_replace(' ','',strip_tags($tabTmp4[1]))),
|
||||
'adresse'=>trim(str_replace(' ','',strip_tags($tabTmp4[2]))),
|
||||
'cpVille'=>trim(str_replace(' ','',strip_tags($tabTmp4[3]))));
|
||||
}
|
||||
$tabRet['procedures'][$nproc]=array('type'=>trim(strip_tags($tabTmp3[0])),
|
||||
'date'=>trim(strip_tags($tabTmp3[1])),
|
||||
'intervenant'=>$tabInter);
|
||||
}
|
||||
}
|
||||
else $tabRet['indProcol']=false;
|
||||
|
||||
// Dirigeants
|
||||
$strTmp=@getTextInHtml($this->body, '<B>Les dirigeants</B></FONT>', "<img src='./images/rouge.gif' width=4 height=4 border='0'>",'</TABLE>');
|
||||
$tabTmp=explode("<img src='./images/rouge.gif' width=4 height=4 border='0'>", $strTmp);
|
||||
foreach ($tabTmp as $ndir=>$dir) {
|
||||
$tabTmp2=explode('</TD>', $dir);
|
||||
$tabTmp3=explode('</B> ', $tabTmp2[1]);
|
||||
$nom=trim(strip_tags($tabTmp3[0]));
|
||||
$prenom=trim(strip_tags($tabTmp3[1]));
|
||||
$naiss=trim(strip_tags($tabTmp2[3]));
|
||||
if (strpos($naiss, 'N<>(e) le')===false) {
|
||||
$fonction=$naiss;
|
||||
} else {
|
||||
$tabTmp3=explode(' <20> ', $naiss);
|
||||
$naiss_date=trim(str_replace('N<>(e) le ', '', strip_tags($tabTmp3[0])));
|
||||
$naiss=trim(strip_tags($tabTmp3[1]));
|
||||
$tabTmp3=explode('(', $naiss);
|
||||
$naiss_ville=trim(strip_tags($tabTmp3[0]));
|
||||
$naiss_depPays=trim(str_replace(')','', strip_tags($tabTmp3[1])));
|
||||
$fonction=trim(strip_tags($tabTmp2[5]));
|
||||
}
|
||||
$tabTmp=explode(' n<>e ', $prenom);
|
||||
$prenom=$tabTmp[0];
|
||||
$naiss_nom=$tabTmp[1];
|
||||
$tabRet['dirigeants'][$ndir]=array( 'nom'=>$nom,
|
||||
'prenom'=>$prenom,
|
||||
'naiss_nom'=>$naiss_nom,
|
||||
'naiss_date'=>$naiss_date,
|
||||
'naiss_ville'=>$naiss_ville,
|
||||
'naiss_depPays'=>$naiss_depPays,
|
||||
'fonction'=>$fonction);
|
||||
}
|
||||
|
||||
// Dirigeants - Administrateurs
|
||||
$strTmp=trim(@getTextInHtml($this->body, '<B>Les administrateurs</B></FONT>', "<img src='./images/rouge.gif' width=4 height=4 border='0'>",'</TABLE>'));
|
||||
if ($strTmp<>'') {
|
||||
$tabTmp=explode("<img src='./images/rouge.gif' width=4 height=4 border='0'>", $strTmp);
|
||||
foreach ($tabTmp as $nadm=>$dir) {
|
||||
$tabTmp2=explode('</TD>', $dir);
|
||||
$tabTmp3=explode('</B> ', $tabTmp2[1]);
|
||||
$nom=trim(strip_tags($tabTmp3[0]));
|
||||
$prenom=trim(strip_tags($tabTmp3[1]));
|
||||
$naiss=trim(strip_tags($tabTmp2[3]));
|
||||
if (strpos($naiss, 'N<>(e) le')===false) {
|
||||
$naiss_date=$naiss_ville=$naiss_depPays='';
|
||||
$fonction=$naiss;
|
||||
} else {
|
||||
$tabTmp3=explode(' <20> ', $naiss);
|
||||
$naiss_date=trim(str_replace('N<>(e) le ', '', strip_tags($tabTmp3[0])));
|
||||
$naiss=trim(strip_tags($tabTmp3[1]));
|
||||
$tabTmp3=explode('(', $naiss);
|
||||
$naiss_ville=trim(strip_tags($tabTmp3[0]));
|
||||
$naiss_depPays=trim(str_replace(')','', strip_tags($tabTmp3[1])));
|
||||
$fonction=trim(strip_tags($tabTmp2[5]));
|
||||
}
|
||||
$tabTmp=explode(' n<>e ', $prenom);
|
||||
$prenom=$tabTmp[0];
|
||||
$naiss_nom=$tabTmp[1];
|
||||
$tabRet['dirigeants'][$nadm+$ndir+1]=array( 'nom'=>$nom,
|
||||
'prenom'=>$prenom,
|
||||
'naiss_nom'=>$naiss_nom,
|
||||
'naiss_date'=>$naiss_date,
|
||||
'naiss_ville'=>$naiss_ville,
|
||||
'naiss_depPays'=>$naiss_depPays,
|
||||
'fonction'=>$fonction);
|
||||
}
|
||||
}
|
||||
|
||||
// Etablissements
|
||||
$strTmp=@getTextInHtml($this->body, '<B>Les <20>tablissements</B></FONT>', "<img src='./images/rouge.gif' width=4 height=4 border='0'>",'</TABLE>');
|
||||
$tabTmp=explode("<img src='./images/rouge.gif' width=4 height=4 border='0'>", $strTmp);
|
||||
foreach ($tabTmp as $netab=>$dir) {
|
||||
$cp=$ville=$ensEtab=''; $j=0;
|
||||
$tabTmp2=explode('</TD>', $dir);
|
||||
for($i=1; $i<=9; $i=$i+2) {
|
||||
$next=$i+2;
|
||||
$strTmp=trim(strip_tags($tabTmp2[$i]));
|
||||
if (preg_match("/^([0-9]{5,5})([\D]*)/i", $strTmp, $matches)) {
|
||||
$adresse[$j]='';
|
||||
$cp=trim($matches[1]);
|
||||
$ville=trim($matches[2]);
|
||||
break;
|
||||
} else
|
||||
$adresse[$j]=$strTmp;
|
||||
|
||||
$j++;
|
||||
}
|
||||
/** Gestion des cas o<> la 1<>re ligne d'adresse contient l'enseigne de l'<27>tablissement */
|
||||
if (strtoupper($adresse[0])==strtoupper($tabRet['enseigne'])) {
|
||||
$ensEtab=$adresse[0];
|
||||
array_shift($adresse);
|
||||
}
|
||||
$strTmp=trim(strip_tags($tabTmp2[$next]));
|
||||
$tabTmp3=explode(' - ', $strTmp);
|
||||
$tabRet['etablissements'][$netab]=array( 'enseigne'=>$ensEtab,
|
||||
'adresse1'=>$adresse[0],
|
||||
'adresse2'=>$adresse[1],
|
||||
'adresse3'=>$adresse[2],
|
||||
'cp'=>$cp,
|
||||
'ville'=>$ville,
|
||||
'naf_code'=>$tabTmp3[0],
|
||||
'naf_lib'=>$tabTmp3[1]);
|
||||
}
|
||||
|
||||
$fp=fopen('./euridile_identite.log', 'w');
|
||||
fwrite($fp,print_r($page,true));
|
||||
fclose($fp);
|
||||
|
||||
$tabInsert=$tabRet;
|
||||
$tabInsert['procedures']=serialize($tabRet['procedures']);
|
||||
$tabInsert['dirigeants']=serialize($tabRet['dirigeants']);
|
||||
$tabInsert['etablissements']=serialize($tabRet['etablissements']);
|
||||
|
||||
$iDb->insert( 'rncs_entrep', $tabInsert);
|
||||
|
||||
return $tabRet;
|
||||
}
|
||||
|
||||
private function partSaveSession() {
|
||||
$fp=fopen('/tmp/php_rncs_session.id', 'w');
|
||||
fwrite($fp,$this->wrncsrv2.'^'.$this->timeOut.'^'.$this->curPage.'^'.$this->siren.'^'.$this->url.'^'.$this->referer);
|
||||
fclose($fp);
|
||||
}
|
||||
|
||||
private function partGetSession() {
|
||||
$strTmp=@file_get_contents('/tmp/php_rncs_session.id');
|
||||
if ($strTmp) {
|
||||
$tabTmp=explode('^', $strTmp);
|
||||
$this->wrncsrv2=$tabTmp[0];
|
||||
$this->timeOut=$tabTmp[1];
|
||||
$this->curPage=$tabTmp[2];
|
||||
$this->siren=$tabTmp[3];
|
||||
$this->url=$tabTmp[4];
|
||||
$this->referer=$tabTmp[5];
|
||||
} else $this->timeOut=0;
|
||||
}
|
||||
|
||||
private function logEuridileError($message) {
|
||||
$fp=fopen('./euridile_error.log', 'w');
|
||||
fwrite($fp,date('Y/m/d H:i:s')." - Erreur : $message (".$this->wrncsrv2.'^'.$this->timeOut.'^'.$this->curPage.'^'.$this->siren.'^'.$this->url.'^'.$this->referer.')'.EOL);
|
||||
fwrite($fp,$this->body.EOL.'-------------------------------------------------------------------------------------'.EOL);
|
||||
fclose($fp);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
?>
|
889
library/Metier/partenaires/classMLiens.php
Normal file
889
library/Metier/partenaires/classMLiens.php
Normal file
@ -0,0 +1,889 @@
|
||||
<?
|
||||
|
||||
class MLiens {
|
||||
|
||||
public $siren=0;
|
||||
private $iDb;
|
||||
private $iInsee;
|
||||
public $tabSirenVisites;
|
||||
|
||||
private $tabChars=array('é'=>'é', 'ç'=>'ç','è'=>'è','à '=>'à');
|
||||
|
||||
private static $tabFct=array( 'ADM'=>'Administrateur',
|
||||
'ASS'=>'Associé',
|
||||
'COG'=>'Co-gérant',
|
||||
'CON'=>'Contrôleur de gestion',
|
||||
'DID'=>'Directeur Général Délégué',
|
||||
'DIR'=>'Directeur',
|
||||
'GER'=>'Gérant',
|
||||
'PCS'=>'Président du Conseil de Surveillance',
|
||||
'PDG'=>'Président Directeur Général',
|
||||
'PP'=>'Personne Physique',
|
||||
'PRD'=>'Président du directoire',
|
||||
'PRE'=>'Président du Conseil d\'Administration',
|
||||
'VIC'=>'Vice président du CA ou Surv.',
|
||||
);
|
||||
|
||||
private $tabSources=array( 0=>'Presse', // Old liens
|
||||
1000=>'Presse', // 4 ?
|
||||
1500=>'Actes', // Fedaso
|
||||
1600=>'Actes', // S&D : 69642, Associé-Gérant
|
||||
1700=>'SED',
|
||||
1800=>'Collecte', // Infolégales
|
||||
1900=>'Collecte');
|
||||
|
||||
|
||||
public function __construct($siren) {
|
||||
$this->siren=$siren;
|
||||
$this->iDb=new WDB();
|
||||
$this->iInsee=new MInsee();
|
||||
}
|
||||
|
||||
/** Retourne les actionnaires du siren
|
||||
** @param int Siren de l'entreprise
|
||||
** @return array Tableau d'actionnaires
|
||||
**/
|
||||
public function getActionnaires($siren=false, $actifsUniquement=true) {
|
||||
if (!$siren) $siren=$this->siren;
|
||||
$tabIdentite=$this->iInsee->getIdentiteLight($siren);
|
||||
//echo $siren;
|
||||
//print_r($tabIdentite);
|
||||
$nic=$tabIdentite['Nic'];
|
||||
$tab=$this->iDb->select('liens',
|
||||
'Siren1, ActionPart, Pmin, Pmax, MajMin, PpPm, Siren2, RaisonSociale, Pays, actif, source, dateLien*1 AS dateLien, DATE(dateInsert)*1 AS dateInsert, DATE(dateUpdate)*1 AS dateUpdate',
|
||||
"Siren1='$siren' AND ActionPart=1 ORDER BY source DESC, actif DESC, Pmin DESC", true, MYSQL_ASSOC);
|
||||
//$tabActiDB=mysql_select('dbo_liens_fi', 'SirenEntite, NomAdresse, PourcentageDetenu, Ville, Lien, MAJLien, MAJImport', "Siren='$siren' AND CodeLien='AC' ORDER BY PourcentageDetenu DESC");
|
||||
//@sendMail('production@scores-decisions.com', 'ylenaour@scores-decisions.com', "Debug $siren ($actifsUniquement)", print_r($tab,true)) ;
|
||||
$sourcePre=$unique=false;
|
||||
$pctTot=0;
|
||||
$tabRet=array();
|
||||
foreach ($tab as $i=>$lien) {
|
||||
if ($lien['source']>=1700) $source=1700;
|
||||
else $source=$lien['source']*1;
|
||||
if ($i>0 && $sourcePre<>$source) break;
|
||||
/*if ($actifsUniquement && $lien['actif']==0) continue;
|
||||
else
|
||||
$tabRet[]=array('Pmin' => number_format($lien['Pmin']*1,2,',',''),
|
||||
'MajMin' => $lien['MajMin'],
|
||||
'RaisonSociale' => strtr($lien['RaisonSociale'],$this->tabChars),
|
||||
'Pays' => $lien['libPays'],
|
||||
'Siren' => $lien['Siren2'],
|
||||
'Actif' => $lien['actif']);*/
|
||||
if ($actifsUniquement && $lien['actif']==0) continue;
|
||||
else {
|
||||
$codPays=strtoupper($lien['Pays']);
|
||||
$libPays='';
|
||||
if ($codPays<>'' && $codPays<>'FRA') {
|
||||
$tmp=$this->iDb->select('tabPays', 'libPays', "codPays3='$codPays'", true, MYSQL_ASSOC);
|
||||
$libPays=$tmp[0]['libPays'];
|
||||
}
|
||||
if ($lien['MajMin']=='F') $majMin='A';
|
||||
else $majMin=$lien['MajMin'];
|
||||
switch ($tabIdentite['FJ']*1) {
|
||||
case 5488: // Entreprise Unipersonnelle à Responsabilité Limitée
|
||||
case 5498: // SARL unipersonnelle
|
||||
case 5720: // Société par actions simplifiée à associé unique
|
||||
$lien['Pmin']=100;
|
||||
$unique=true;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
$dateMaj=$lien['dateLien'];
|
||||
$pctLien=$lien['Pmin']*1;
|
||||
$pctTot+=$pctLien;
|
||||
// On évite d'afficher des totaux de détention > à 100%
|
||||
if($pctTot>100) $pctLien=0;
|
||||
|
||||
if ($lien['dateInsert']>$dateMaj) $dateMaj=$lien['dateInsert'];
|
||||
if ($lien['dateUpdate']>$dateMaj) $dateMaj=$lien['dateUpdate'];
|
||||
$tabRet[]=array( 'Pmin' => number_format($pctLien,2,',',''),
|
||||
'PminNum' => $pctLien,
|
||||
'MajMin' => $majMin,
|
||||
'RaisonSociale' => strtr($lien['RaisonSociale'],$this->tabChars),
|
||||
'Pays' => $libPays,
|
||||
'Siren' => $lien['Siren2'],
|
||||
'Actif' => $lien['actif'],
|
||||
'Source' => $this->tabSources[$source],
|
||||
'DateLien' => Wdate::dateT('Ymd','Y-m-d', $lien['dateLien']),
|
||||
'DateMaj' => Wdate::dateT('Ymd','Y-m-d', $dateMaj));
|
||||
if ($unique) break;
|
||||
}
|
||||
$sourcePre=$source;
|
||||
}
|
||||
|
||||
if (count($tabRet)==0) {
|
||||
switch ($tabIdentite['FJ']*1) {
|
||||
case 7112: // Autorité administrative indépendante
|
||||
case 7160: // Service déconcentré à compétence nation. D'un ministère (hors Défense)
|
||||
case 7171: // Service déconcentré de l'État à compétence (inter) régionale
|
||||
case 7172: // Service déconcentré de l'État à compétence (inter) départementale
|
||||
case 7179: // (Autre) Service déconcentré de l'État à compétence territoriale
|
||||
case 7381: // Organisme consulaire
|
||||
/** Ces établissements sont dans le fichier des tribunaux **/
|
||||
$tmp=$this->iDb->select('tribunaux', 'triSiret, triNom, dateUpdate', "triId=(SELECT triIdSup FROM tribunaux WHERE triSiret LIKE '$siren%' LIMIT 1)", true, MYSQL_ASSOC);
|
||||
$tabCC=$tmp[0];
|
||||
//$sirenCC=substr(,0,9);
|
||||
//if ($siren*1<>$sirenCC*1)
|
||||
if ($tabCC['triSiret']*1<>0) //$siren*1<>$sirenCC*1)
|
||||
$tabRet[]=array('Pmin' => 0,
|
||||
'PminNum' => 0,
|
||||
'MajMin' => '+',
|
||||
'RaisonSociale' => $tabCC['triNom'],
|
||||
'Pays' => '',
|
||||
'Siren' => $tabCC['triSiret'],
|
||||
'Actif' => 1,
|
||||
'Source' => $this->tabSources[1800],
|
||||
'DateLien' => Wdate::dateT('Ymd','Y-m-d', $tabCC['dateUpdate']),
|
||||
'DateMaj' => Wdate::dateT('Ymd','Y-m-d', $tabCC['dateUpdate']),
|
||||
);
|
||||
case 7111: // Autorité constitutionnelle
|
||||
case 7113: // Ministère
|
||||
case 7120: // Service central d'un ministère
|
||||
case 7150: // Service du ministère de la Défense
|
||||
|
||||
case 7190: // Ecole nationale non dotée de la personnalité morale
|
||||
// case 7210: // COMMUNE (traité après)
|
||||
// case 7220: // DEPARTEMENT (traité après)
|
||||
case 7225: // Territoire d'Outre-mer
|
||||
case 7229: // (Autre) Collectivité territoriale
|
||||
// case 7312: // Commune associée
|
||||
// case 7313: // Section de commune
|
||||
// case 7314: // Ensemble urbain
|
||||
case 7230: // Région
|
||||
case 7321: // Association syndicale autorisée
|
||||
case 7322: // Association foncière urbaine
|
||||
case 7323: // Association foncière de remembrement
|
||||
case 7331: // Établissement public local d'enseignement
|
||||
// case 7341: // Secteur de commune
|
||||
// case 7342: // District urbain
|
||||
// case 7343: // Communauté urbaine
|
||||
// case 7345: // Syndicat intercommunal à vocation multiple (SIVOM)
|
||||
// case 7346: // Communauté de communes
|
||||
// case 7347: // Communauté de villes
|
||||
// case 7348: // Communauté d'agglomération
|
||||
case 7349: // Autre établissement public local de coopération non spécialisé ou entente
|
||||
case 7351: // Institution interdépartemental ou entente
|
||||
case 7352: // Institution interrégionale ou entente
|
||||
// case 7353: // Syndicat intercommunal à vocation unique (SIVU)
|
||||
// case 7354: // Syndicat mixte communal
|
||||
// case 7355: // Autre syndicat mixte
|
||||
case 7356: // Commission syndicale pour la gestion des biens indivis des communes
|
||||
// case 7361: // Centre communal d'action sociale
|
||||
// case 7362: // Caisse des écoles
|
||||
// case 7363: // Caisse de crédit municipal
|
||||
case 7364: // Établissement d'hospitalisation
|
||||
case 7365: // Syndicat inter hospitalier
|
||||
case 7366: // Établissement public local social et médico-social
|
||||
case 7371: // Office public d'habitation à loyer modéré (OPHLM)
|
||||
case 7372: // Service départemental d'incendie
|
||||
case 7373: // Établissement public local culturel
|
||||
case 7378: // Régie d'une collectivité locale à caractère administratif
|
||||
case 7379: // (Autre) Établissement public administratif local
|
||||
case 7382: // Établissement public national ayant fonction d'administration centrale
|
||||
case 7383: // Établissement public national à caractère scientifique culturel et professionnel
|
||||
case 7384: // Autre établissement public national d'enseignement
|
||||
case 7385: // Autre établissement public national administratif à compétence territoriale limitée
|
||||
case 7389: // Établissement public national à caractère administratif
|
||||
case 7410: // Groupement d'intérêt public (GIP)
|
||||
case 7430: // Établissement public des cultes d'Alsace-Lorraine
|
||||
case 7450: // Cercle et foyer dans les armées
|
||||
case 7490: // Autre personne morale de droit administratif
|
||||
if (count($tabRet)==0)
|
||||
$tabRet[]=array('Pmin' => 0,
|
||||
'PminNum' => 0,
|
||||
'MajMin' => '+',
|
||||
'RaisonSociale' => 'ETAT FRANCAIS',
|
||||
'Pays' => '',
|
||||
'Siren' => 0,
|
||||
'Actif' => 1,
|
||||
'Source' => $this->tabSources[1800],
|
||||
'DateLien' => date('Y-m-').'01',
|
||||
'DateMaj' => date('Y-m-').'01',
|
||||
);
|
||||
break;
|
||||
case 7210: // Communes
|
||||
// Siren Commune du Lamentin : 219 722 139
|
||||
// ~~~ ~~~~
|
||||
$dept=substr($siren,2,2);
|
||||
$comm=substr($siren,5,3);
|
||||
$codeInsee=$dept.$comm;
|
||||
if ($dept<>'20') // Corse
|
||||
$strCodeInsee="codeInsee='$codeInsee'";
|
||||
else
|
||||
$strCodeInsee="codeInsee IN ('2A$comm','2B$comm','20$comm') ";
|
||||
|
||||
$tmp=$this->iDb->select('insee.insee_tabVillesEpci', 'typEPCI, codEPCI, libEPCI, libCommune', $strCodeInsee, true, MYSQL_ASSOC);
|
||||
$tabCC=$tmp[0];
|
||||
switch($tabCC['typEPCI']) {
|
||||
case 'CA': $typeCC="Communauté d'agglomérations"; break; // CJ=7348
|
||||
case 'CC': $typeCC="Communauté de communes"; break; // CJ=7346
|
||||
case 'CU': $typeCC="Communauté urbaine"; break; // CJ=73
|
||||
case 'SAN': $typeCC="Syndicat d'agglomérations nouvelles"; break; // CJ=73
|
||||
default: $typeCC='';
|
||||
}
|
||||
$tabRet[]=array('Pmin' => 0,
|
||||
'PminNum' => 0,
|
||||
'MajMin' => '+',
|
||||
'RaisonSociale' => strtoupper($typeCC.' '.preg_replace('/^(CA|CC|CU|SAN) /Uis', '',$tabCC['libEPCI'])),
|
||||
'Pays' => '',
|
||||
'Siren' => $tabCC['codEPCI'],
|
||||
'Actif' => 1,
|
||||
'Source' => $this->tabSources[1800],
|
||||
'DateLien' => date('Y-m-').'01',
|
||||
'DateMaj' => date('Y-m-').'01',
|
||||
);
|
||||
break;
|
||||
case 7220: // Département
|
||||
// Siren du 29 22 290001 1 => Région 233 500 016
|
||||
// Siren du 28 22 280001 3 => Région 234 500 023
|
||||
// Siren du 75 22 750001 => Région 237 500 079
|
||||
// Siren du 972 22 972001 6 => Région 239 720 014
|
||||
$dept=substr($siren,2,2);
|
||||
if ($dept*1>95)
|
||||
$dept=substr($siren,2,3);
|
||||
$tmp=$this->iDb->select('insee.departements d, insee.insee_tabRegions r',
|
||||
'd.codeRegionInsee, r.REGION, r.CHEFLIEU, r.NC',
|
||||
"numdep='$dept' AND d.codeRegionInsee=r.REGION", true, MYSQL_ASSOC);
|
||||
$tabCC=$tmp[0];
|
||||
$dept3=substr($tabCC['CHEFLIEU'],0,2).'0';
|
||||
if ($dept3*1>960)
|
||||
$dept3=substr($tabCC['CHEFLIEU'],0,3);
|
||||
for ($iSir=0; $iSir<100; $iSir++) {
|
||||
if ($iSir<10) $iSir2='0'.$iSir;
|
||||
else $iSir2=$iSir;
|
||||
// 23 350 00 16 => Bon
|
||||
// 23 350 00 00 => Mauvais
|
||||
$sirenCom='23'.$dept3.'00'.$iSir2;
|
||||
if ($this->iInsee->valideSiren($sirenCom)) {
|
||||
if ($this->iInsee->sirenExiste($sirenCom)) {
|
||||
// @sendMail('production@scores-decisions.com', 'ylenaour@scores-decisions.com', "Debug Fin $siren ($actifsUniquement) $sirenCom existe !", '') ;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
$tabRet[]=array('Pmin' => 0,
|
||||
'PminNum' => 0,
|
||||
'MajMin' => '+',
|
||||
'RaisonSociale' => 'REGION '.strtoupper($tabCC['NC']),
|
||||
'Pays' => '',
|
||||
'Siren' => $sirenCom,
|
||||
'Actif' => 1,
|
||||
'Source' => $this->tabSources[1800],
|
||||
'DateLien' => date('Y-m-').'01',
|
||||
'DateMaj' => date('Y-m-').'01',
|
||||
);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (count($tabRet)==0) {
|
||||
$fj=$tabIdentite['FJ']*1;
|
||||
if ($fj==5498) $strFonctions=",'Gérant'";
|
||||
else $strFonctions='';
|
||||
$adresse=end(explode(' ', $tabIdentite['AdresseVoie']));
|
||||
$codePostal=$tabIdentite['CP'];
|
||||
$tab=$this->iDb->select('rncs_dirigeants', 'typeDir, raisonSociale, dirSiren, dirRS, civilite, nom, prenom, actif, naissance_nom, naissance_date, naissance_lieu, nat, adresse, fonction_code, fonction_lib, source, cinf, dateInsert, dateUpdate',
|
||||
"siren='$siren' AND fonction_lib IN ('Associé-gérant' $strFonctions)", true, MYSQL_ASSOC);
|
||||
$majMin='+';
|
||||
if (count($tab)>1) $majMin='-';
|
||||
foreach ($tab as $i=>$lien) {
|
||||
if ($actifsUniquement && $lien['actif']==0) continue;
|
||||
else {
|
||||
$ville=$siege=$actif='';
|
||||
$deb=$siren2=0;
|
||||
$nbRep=$maxRep=200;
|
||||
$pertinence=$avecSiren=true;
|
||||
|
||||
$etabs=$this->iInsee->rechercheEtab($lien['nom'].' '.$lien['prenom'], $adresse, $codePostal, $ville, $siege, $actif, $deb, $nbRep, $maxRep, $pertinence, $avecSiren);
|
||||
$tabSiren=array();
|
||||
foreach ($etabs['reponses'] as $etab) {
|
||||
$tabTmp=preg_split('/( +|\/|\*)/', $etab['Nom']);
|
||||
$rsEtab=$tabTmp[0];
|
||||
$tabTmp=preg_split('/( +|\/|\*)/', $lien['nom']);
|
||||
$rsLien=$tabTmp[0];
|
||||
if ($etab['FJ']==1800 && $rsEtab==$rsLien)
|
||||
$tabSiren[]=$etab['Siren'];
|
||||
}
|
||||
$tabSiren2=array_unique($tabSiren);
|
||||
if (count($tabSiren2==1)) $siren2=end($tabSiren2);
|
||||
else $siren2=$lien['dirSiren'];
|
||||
if ($lien['civilite']=='MME') $genre='Madame';
|
||||
elseif ($lien['civilite']=='M') $genre='Monsieur';
|
||||
else $genre='';
|
||||
$dateMaj=$lien['dateInsert'];
|
||||
if ($lien['dateUpdate']>$dateMaj) $dateMaj=$lien['dateUpdate'];
|
||||
$tabRet[]=array( 'Pmin' => 0,
|
||||
'PminNum' => 0,
|
||||
'MajMin' => $majMin,
|
||||
'RaisonSociale' => trim(preg_replace('/ +/', ' ', $lien['dirRS'].' '.$genre.' '.$lien['nom'].' '.$lien['prenom'])),
|
||||
'Pays' => '',
|
||||
'Siren' => $siren2,
|
||||
'Actif' => $lien['actif'],
|
||||
'Source' => $this->tabSources[1600],
|
||||
'DateLien' => Wdate::dateT('Y-m-d','Y-m-d', $dateMaj),
|
||||
'DateMaj' => Wdate::dateT('Y-m-d','Y-m-d', $dateMaj),
|
||||
);
|
||||
if ($unique) break;
|
||||
/**/
|
||||
if ($siren2*1>0) {
|
||||
/** Insertion du lien en base **/
|
||||
$nom=$pays=$dateMAJ='';
|
||||
$ppPm='P';
|
||||
$pct=0;
|
||||
$entrep2=$this->iInsee->getIdentiteLight($siren);
|
||||
$nom2=$entrep2['Nom'];
|
||||
$pays2='FRA';
|
||||
if (substr($entrep2['FJ'],0,1)*1<>1) $ppPm='M';
|
||||
$entrep=$this->iInsee->getIdentiteLight($siren2);
|
||||
$nom=strtr($entrep['Nom'],'/*',' ');
|
||||
$pays='FRA';
|
||||
$tabUpdate=array( 'Pmin'=> $pct,
|
||||
'Pmax'=> $pct,
|
||||
'MajMin'=> $majMin,
|
||||
'PpPm'=> $ppPm,
|
||||
'dateLien'=> $dateMAJ,
|
||||
);
|
||||
/* Insertion de l'actionnaire */
|
||||
$tabInsert1=array_merge($tabUpdate, array( 'ActionPart'=>1),
|
||||
array( 'Siren1'=> $siren,
|
||||
'Siren2'=> $siren2,
|
||||
'RaisonSociale'=> $nom,
|
||||
'Pays'=> $pays,
|
||||
'actif'=> 1,
|
||||
'source'=> 1600,
|
||||
'dateInsert'=> date('YmdHis')));
|
||||
$res=$this->iDb->select('liens', 'count(*)', "Siren1=$siren AND (Siren2=$siren2 OR (RaisonSociale='".addslashes($nom)."' AND Pays='$pays'))");
|
||||
if ($res[0][0]>0) {
|
||||
if (!$this->iDb->update('liens', array_merge($tabUpdate,array('ActionPart'=>1)), "siren=$siren AND (Siren2=$siren2 OR (RaisonSociale='".addslashes($nom)."' AND Pays='$pays'))", true))
|
||||
$errMaj=1016166;
|
||||
} else {
|
||||
if (!$this->iDb->insert('liens', $tabInsert1, true))
|
||||
$errMaj=1016167;
|
||||
}
|
||||
|
||||
/* Insertion de la participation pour l'actionnaire précédent */
|
||||
$tabInsert2=array_merge($tabUpdate, array( 'ActionPart'=>2),
|
||||
array( 'Siren1'=> $siren2,
|
||||
'Siren2'=> $siren,
|
||||
'RaisonSociale'=> $nom2,
|
||||
'Pays'=> $pays2,
|
||||
'actif'=> 1,
|
||||
'source'=> 1600,
|
||||
'dateInsert'=> date('YmdHis')));
|
||||
$res=$this->iDb->select('liens', 'count(*)', "Siren1=$siren2 AND (Siren2=$siren OR (RaisonSociale='$nom2' AND Pays='$pays2'))");
|
||||
if ($res[0][0]>0) {
|
||||
if (!$this->iDb->update('liens', array_merge($tabUpdate,array('ActionPart'=>2)), "siren=$siren2 AND (Siren2=$siren OR (RaisonSociale='".addslashes($nom2)."' AND Pays='$pays2'))", true))
|
||||
$errMaj=1016168;
|
||||
} else {
|
||||
if (!$this->iDb->insert('liens', $tabInsert2, true))
|
||||
$errMaj=1016169;
|
||||
}
|
||||
|
||||
/** Insertion du dirigeant pour l'actionnaire en base **/
|
||||
$dirs=$this->iDb->select('rncs_dirigeants','siren', "siren=$siren2", true, MYSQL_ASSOC);
|
||||
if (count($dirs)==0) {
|
||||
$this->iDb->insert('rncs_dirigeants', array( 'siren' => $siren2,
|
||||
'raisonSociale' => $nom,
|
||||
'civilite' => $lien['civilite'],
|
||||
'typeDir' => $lien['typeDir'],
|
||||
'dirRS' => $siren2,
|
||||
'nom' => $lien['nom'],
|
||||
'prenom' => $lien['prenom'],
|
||||
'naissance_nom' => $lien['naissance_nom'],
|
||||
'naissance_date'=> $lien['naissance_date'],
|
||||
'naissance_lieu'=> $lien['naissance_lieu'],
|
||||
'nat' => $lien['nat'],
|
||||
'fonction_code' => 0,
|
||||
'fonction_lib' => 'Personne Physique',
|
||||
'actif' => 1,
|
||||
'dateInsert' => date('YmdHis'),
|
||||
'source' => 'lag', // Lien Associé Gérant
|
||||
'cinf' => $lien['cinf'],
|
||||
), true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if (count($tabRet)==0) {
|
||||
$tabNotice=$this->iInsee->getInfosNotice($siren, $nic);
|
||||
if ($tabNotice['insRECME']*1>0) {
|
||||
$tabRet[]=array('Pmin' => 0,
|
||||
'PminNum' => 0,
|
||||
'MajMin' => '+',
|
||||
'RaisonSociale' => 'ETAT FRANCAIS',
|
||||
'Pays' => '',
|
||||
'Siren' => 0,
|
||||
'Actif' => 1,
|
||||
'Source' => $this->tabSources[1800],
|
||||
'DateLien' => date('Y-m-').'01',
|
||||
'DateMaj' => date('Y-m-').'01',
|
||||
);
|
||||
}
|
||||
}
|
||||
//@sendMail('production@scores-decisions.com', 'ylenaour@scores-decisions.com', "Debug Fin $siren ($actifsUniquement)", print_r($tabRet,true)) ;
|
||||
return $tabRet;
|
||||
}
|
||||
|
||||
/** Retourne les participations du siren
|
||||
** @param int Siren de l'entreprise
|
||||
** @return array Tableau de participations
|
||||
**/
|
||||
public function getParticipations($siren=false, $actifsUniquement=true) {
|
||||
if (!$siren) $siren=$this->siren;
|
||||
$tab=$this->iDb->select(
|
||||
'liens l LEFT JOIN tabPays ON codPays3=Pays',
|
||||
'Siren1, ActionPart, Pmin, Pmax, MajMin, PpPm, Siren2, RaisonSociale, Pays, libPays, actif, source, dateLien*1 AS dateLien, DATE(l.dateInsert)*1 AS dateInsert, DATE(l.dateUpdate)*1 AS dateUpdate',
|
||||
"Siren1='$siren' AND ActionPart=2 ORDER BY source DESC, actif DESC, Pmin DESC", true, MYSQL_ASSOC); // OR Siren2='$siren
|
||||
$tabRet=array();
|
||||
$sourcePre=false;
|
||||
foreach ($tab as $i=>$lien) {
|
||||
if ($lien['source']>=1700) $source=1700;
|
||||
//if ($lien['source']>=1700 && $lien['source']<=1720) $source=1700;
|
||||
else $source=$lien['source']*1;
|
||||
|
||||
$dateMaj=$lien['dateLien'];
|
||||
if ($lien['dateInsert']>$dateMaj) $dateMaj=$lien['dateInsert'];
|
||||
if ($lien['dateUpdate']>$dateMaj) $dateMaj=$lien['dateUpdate'];
|
||||
if ($i>0 && $sourcePre<>$source) break;
|
||||
if ($actifsUniquement && $lien['actif']==0) continue;
|
||||
else {
|
||||
if ($lien['MajMin']=='F') $majMin='A';
|
||||
else $majMin=$lien['MajMin'];
|
||||
$tabRet[]=array('Pmin' => number_format($lien['Pmin']*1,2,',',''),
|
||||
'PminNum' => $lien['Pmin']*1,
|
||||
'MajMin' => $majMin,
|
||||
'RaisonSociale' => strtr($lien['RaisonSociale'],$this->tabChars),
|
||||
'Pays' => $lien['libPays'],
|
||||
'Siren' => $lien['Siren2'],
|
||||
'Actif' => $lien['actif'],
|
||||
'Source' => $this->tabSources[$source],
|
||||
'DateLien' => Wdate::dateT('Ymd','Y-m-d', $lien['dateLien']),
|
||||
'DateMaj' => Wdate::dateT('Ymd','Y-m-d', $dateMaj),
|
||||
);
|
||||
}
|
||||
$sourcePre=$source;
|
||||
}
|
||||
|
||||
// if (count($tabRet)==0) {
|
||||
$tabTmp=$this->iInsee->getIdentiteLight($siren);
|
||||
switch ($tabTmp['FJ']*1) {
|
||||
case 7112: // Autorité administrative indépendante
|
||||
case 7160: // Service déconcentré à compétence nation. D'un ministère (hors Défense)
|
||||
case 7171: // Service déconcentré de l'État à compétence (inter) régionale
|
||||
case 7172: // Service déconcentré de l'État à compétence (inter) départementale
|
||||
case 7179: // (Autre) Service déconcentré de l'État à compétence territoriale
|
||||
case 7381: // Organisme consulaire
|
||||
/** Ces établissements sont dans le fichier des tribunaux **/
|
||||
$tmp=$this->iDb->select('tribunaux t1', 't1.triSiret, t1.triNom', "t1.triIdSup=(SELECT t2.triId FROM tribunaux t2 WHERE t2.triSiret LIKE '$siren%' AND t2.triId<>t1.triId LIMIT 1)", true, MYSQL_ASSOC);
|
||||
foreach ($tmp as $tabCC) {
|
||||
// $sirenCC=substr($tabCC['triSiret'],0,9);
|
||||
if ($tabCC['triSiret']*1<>0) //$siren*1<>$sirenCC*1)
|
||||
$tabRet[]=array('Pmin' => 0,
|
||||
'PminNum' => 0,
|
||||
'MajMin' => '+',
|
||||
'RaisonSociale' => $tabCC['triNom'],
|
||||
'Pays' => '',
|
||||
'Siren' => $tabCC['triSiret'],
|
||||
'Actif' => 1,
|
||||
'Source' => $this->tabSources[1800],
|
||||
'DateLien' => Wdate::dateT('Ymd','Y-m-d', $tabCC['dateUpdate']),
|
||||
'DateMaj' => Wdate::dateT('Ymd','Y-m-d', $tabCC['dateUpdate']),
|
||||
);
|
||||
}
|
||||
break;
|
||||
case 7346: // Communaute de communes
|
||||
case 7348: // Communaute d'agglomeration
|
||||
//case 'CC': $typeCC="Communauté de communes"; break; // CJ=73
|
||||
//case 'CU': $typeCC="Communauté urbaine"; break; // CJ=73
|
||||
//case 'SAN': $typeCC="Syndicat d'agglomérations nouvelles"; break; // CJ=73
|
||||
$tmp=$this->iDb->select('insee.insee_tabVillesEpci', 'typEPCI, libEPCI, codeInsee, libCommune', "codEPCI='$siren'", true, MYSQL_ASSOC);
|
||||
foreach ($tmp as $tabCom) {
|
||||
$dept=substr($tabCom['codeInsee'],0,2);
|
||||
if ($dept=='2A' || $dept=='2B' || $dept=='20')
|
||||
$dept='200';
|
||||
elseif ($dept*1>95)
|
||||
$dept=substr($tabCom['codeInsee'],0,3);
|
||||
else
|
||||
$dept=$dept.'0';
|
||||
$comm=substr($tabCom['codeInsee'],2,3);
|
||||
for ($iSir=0; $iSir<10; $iSir++) {
|
||||
$sirenCom='21'.$dept.$comm.$iSir;
|
||||
if ($this->iInsee->valideSiren($sirenCom)) break;
|
||||
}
|
||||
$tabRet[]=array('Pmin' => 0,
|
||||
'PminNum' => 0,
|
||||
'MajMin' => '+',
|
||||
'RaisonSociale' => 'COMMUNE DE '.strtoupper($tabCom['libCommune']),
|
||||
'Pays' => '',
|
||||
'Siren' => $sirenCom,
|
||||
'Actif' => 1,
|
||||
'Source' => $this->tabSources[1800],
|
||||
'DateLien' => date('Y-m-').'01',
|
||||
'DateMaj' => date('Y-m-').'01',
|
||||
);
|
||||
}
|
||||
break;
|
||||
case 7230: // Région
|
||||
// Siren du 29 22 290001 1 => Région 233 500 016
|
||||
// Siren du 28 22 280001 3 => Région 234 500 023
|
||||
// Siren du 75 22 750001 => Région 237 500 079
|
||||
// Siren du 972 22 972001 6 => Région 239 720 014
|
||||
$dept=substr($siren,2,2);
|
||||
$deptD=$dept.'000';
|
||||
$deptF=$dept.'999';
|
||||
if ($dept*1>95) {
|
||||
$dept=substr($siren,2,3);
|
||||
$deptD=$dept.'00';
|
||||
$deptF=$dept.'99';
|
||||
}
|
||||
$tmp=$this->iDb->select('insee.departements d, insee.insee_tabRegions r',
|
||||
'd.numDep, d.libdep, d.codeRegionInsee, r.REGION, r.CHEFLIEU, r.NC',
|
||||
"r.CHEFLIEU BETWEEN '$deptD' AND '$deptF' AND d.codeRegionInsee=r.REGION", true, MYSQL_ASSOC);
|
||||
foreach ($tmp as $tabCom) {
|
||||
$dept=$tabCom['numDep'];
|
||||
if ($dept>960) $dept3=$dept;
|
||||
else $dept3=$dept.'0';
|
||||
for ($iSir=0; $iSir<10; $iSir++) {
|
||||
$sirenCom='22'.$dept3.'001'.$iSir;
|
||||
if ($this->iInsee->valideSiren($sirenCom)) break;
|
||||
}
|
||||
$tabRet[]=array('Pmin' => 0,
|
||||
'PminNum' => 0,
|
||||
'MajMin' => '+',
|
||||
'RaisonSociale' => 'DEPARTEMENT '.strtoupper($tabCom['libdep']),
|
||||
'Pays' => '',
|
||||
'Siren' => $sirenCom,
|
||||
'Actif' => 1,
|
||||
'Source' => $this->tabSources[1800],
|
||||
'DateLien' => date('Y-m-').'01',
|
||||
'DateMaj' => date('Y-m-').'01',
|
||||
);
|
||||
}
|
||||
break;
|
||||
}
|
||||
// }
|
||||
//@sendMail('production@scores-decisions.com', 'ylenaour@scores-decisions.com', "Debug Liens $siren", print_r($tabRet,true)) ;
|
||||
|
||||
return $tabRet;
|
||||
}
|
||||
|
||||
public function getLiens($siren=false) {
|
||||
$tabA=$this->getActionnaires($siren);
|
||||
$tabP=$this->getParticipations($siren);
|
||||
return array( 'actionnaires'=>$tabA,
|
||||
'participations'=>$tabP);
|
||||
}
|
||||
|
||||
|
||||
public function getMaisonMereFr($siren, $debug=false, $tabSirenVisites=array()) {
|
||||
$this->tabSirenVisites=$tabSirenVisites;
|
||||
$this->tabSirenVisites[]=$siren;
|
||||
$tabA=$this->getActionnaires($siren, true);
|
||||
$majTrouve=false;
|
||||
foreach ($tabA as $i=>$lien) {
|
||||
$sirenMere=$lien['Siren'];
|
||||
// Afin de ne pas boucler à l'infini si le siren est déjà dans la sructure !
|
||||
//echo "je cherche $sirenMere dans ";
|
||||
//print_r($tabSirenVisites);
|
||||
if (in_array($sirenMere, $this->tabSirenVisites)) {
|
||||
//echo "TROUVE !!!".EOL;
|
||||
continue;
|
||||
}// else
|
||||
//echo "inconnu".EOL;
|
||||
|
||||
if ($debug && $sirenMere>1000) $tabIdentiteA=$this->iInsee->getIdentiteLight($sirenMere);
|
||||
else $tabIdentiteA['Nom']='';
|
||||
if ($siren*1==$sirenMere*1) {
|
||||
if ($debug) echo "D. $siren détenu à ".$lien['Pmin']." (".$lien['MajMin'].") par ".$tabIdentiteA['Nom']." ($sirenMere)".EOL;
|
||||
return $siren;
|
||||
}
|
||||
elseif($sirenMere>100 && $lien['PminNum']>50) {
|
||||
if ($debug) echo "A. $siren détenu à ".$lien['Pmin']." (".$lien['MajMin'].") par ".$tabIdentiteA['Nom']." ($sirenMere)".EOL;
|
||||
$majTrouve=true;
|
||||
return $this->getMaisonMereFr($sirenMere, $debug, $this->tabSirenVisites);
|
||||
}
|
||||
elseif($sirenMere>100 && $lien['MajMin']=='+' && !$majTrouve) {
|
||||
if ($debug) echo "B. $siren détenu à ".$lien['Pmin']." (".$lien['MajMin'].") par ".$tabIdentiteA['Nom']." ($sirenMere)".EOL;
|
||||
$majTrouve=true;
|
||||
return $this->getMaisonMereFr($sirenMere, $debug, $this->tabSirenVisites);
|
||||
}
|
||||
elseif ($sirenMere<100) {
|
||||
if ($debug) echo "C. $siren détenu à ".$lien['Pmin']." (".$lien['MajMin'].") par ".$tabIdentiteA['Nom']." ($sirenMere)".EOL;
|
||||
return $siren;
|
||||
}
|
||||
else {
|
||||
if ($debug) echo "E. $siren détenu à ".$lien['Pmin']." (".$lien['MajMin'].") par ".$tabIdentiteA['Nom']." ($sirenMere)".EOL;
|
||||
//die("Cas pas prévue $siren, $sirenMere, ".$lien['Pmin'].', '.$lien['MajMin'].EOL);
|
||||
return $siren;
|
||||
}
|
||||
}
|
||||
if ($i==0) return $siren;
|
||||
}
|
||||
|
||||
public function getAllParticipations($siren, $pctMin=33, $nbNiveaux=15, $niveauCour=1, $tabSiren=array(), $sirenIni=0, $sirenMere=0, $appel=0, $actifsUniquement=true) {
|
||||
$appel++;
|
||||
$tabP=$this->getParticipations($siren, $actifsUniquement);
|
||||
//if ($siren*1==692004807) die(print_r($tabP,true));
|
||||
foreach ($tabP as $i=>$lien) {
|
||||
$sirenFille=$lien['Siren']*1;
|
||||
if ($sirenFille>1000) {
|
||||
$tabIdentiteP=$this->iInsee->getIdentiteLight($sirenFille);
|
||||
$nomP=$tabIdentiteP['Nom'];
|
||||
} else {
|
||||
$nomP=$lien['RaisonSociale'];
|
||||
}
|
||||
$codPays=$lien['Pays'];
|
||||
$libPays='';
|
||||
if ($codPays<>'' && $codPays<>'France')
|
||||
$libPays=" ($codPays)";
|
||||
|
||||
for($j=0;$j<$appel; $j++) echo "|\t";
|
||||
|
||||
if ($lien['PminNum']>0)
|
||||
$pct=$lien['PminNum'].'%';
|
||||
elseif ($lien['MajMin']=='+')
|
||||
$pct='major';
|
||||
elseif ($lien['MajMin']=='-')
|
||||
$pct='minor';
|
||||
else
|
||||
$pct=$lien['MajMin'];
|
||||
|
||||
echo "+ $sirenFille ($pct) : ".$nomP.$libPays;
|
||||
|
||||
if ($siren*1==$sirenFille*1) {
|
||||
echo "[D]".EOL;
|
||||
$tabSiren[]=$siren;
|
||||
}
|
||||
elseif($sirenFille>100 && ($lien['PminNum']>=$pctMin || $lien['MajMin']=='+') && $appel<=$nbNiveaux) {
|
||||
$tabSiren[]=$siren;
|
||||
if (in_array($sirenFille,$tabSiren))
|
||||
echo "[Adeja]".EOL;
|
||||
else {
|
||||
echo "[A]".EOL;
|
||||
$niveauCour++;
|
||||
$tabSiren=$this->getAllParticipations($sirenFille, $pctMin, $nbNiveaux, $niveauCour, $tabSiren, $sirenIni, $sirenMere, $appel, $actifsUniquement, $format);
|
||||
}
|
||||
}
|
||||
elseif($sirenFille>100 && ($lien['PminNum']<$pctMin || $lien['MajMin']=='-')) {
|
||||
echo "[B]".EOL;
|
||||
$tabSiren[]=$siren;
|
||||
}
|
||||
elseif ($sirenFille<100) {
|
||||
echo "[C]".EOL;
|
||||
$tabSiren[]=$siren;
|
||||
}
|
||||
else {
|
||||
|
||||
/**1) {
|
||||
echo "[D]".EOL;
|
||||
$tabSiren[]=$siren;
|
||||
}
|
||||
elseif($sirenFille>100 && ($lien['PminNum']>=$pctMin || $lien['MajMin']=='+') && $niveauCour<=$nbNiveaux) { */
|
||||
|
||||
echo "[E]".EOL;// $siren, $sirenFille, ".$lien['PminNum'].">=$pctMin, ".$lien['MajMin'].", $niveauCour<=$nbNiveaux".EOL;
|
||||
$tabSiren[]=$siren;
|
||||
}
|
||||
}
|
||||
|
||||
return array_unique($tabSiren);
|
||||
}
|
||||
|
||||
/** Recherche d'entreprise par leur actionnaire
|
||||
**
|
||||
** @param string $nom Raison sociale / Nom de l'actionnaire (obligatoire)
|
||||
** @param string $cpVille CP, Ville
|
||||
** @param integer $siren Siren de l'actionnaire
|
||||
** @param string $pays Pays de l'actionnaire
|
||||
** @param string $detention Niveau de détention de l'actionnaire
|
||||
** @param integer $deb Position du curseur dans la liste des réponses (0 par défaut)
|
||||
** @param integer $nbRep Nombre de réponses retournées au maximum par cette requete (20 par défaut)
|
||||
** @param integer $maxRep Nombre de réponses recherchées au maximum (200 par défaut)
|
||||
** @param bool $pertinence Recherche orthographique stricte sur les noms et prénoms (si true)
|
||||
** @return Liste des entreprises trouvées
|
||||
**/
|
||||
public function rechercheActionnaire($nom, $cpVille='', $siren=0, $pays='', $pctMin=0, $pctMax=100, $deb=0, $nbRep=20, $maxRep=200, $pertinence=false)
|
||||
{
|
||||
debugLog('I',"rechercheActionnaire de $nom, $cpVille, $pays, $siren entre $pctMin et $pctMax% (Max Rep=$nbRep)",__LINE__,__FILE__, __FUNCTION__, __CLASS__);
|
||||
$formR = array(
|
||||
'type' => 'act',
|
||||
'siren' => $siren,
|
||||
'actNomRS' => join(' ', array($nom, $cpVille)),
|
||||
'pays' => $pays,
|
||||
'pctMin' => $pctMin,
|
||||
'pctMax' => $pctMax,
|
||||
);
|
||||
|
||||
$version = defined('SPHINX_ACT_VERSION') ? SPHINX_ACT_VERSION : 1;
|
||||
switch($version)
|
||||
{
|
||||
case 1:
|
||||
require_once 'Metier/sphinx/rechercheFonc.php';
|
||||
$result = rechercheAct($formR, $deb, $nbRep, $maxRep);
|
||||
break;
|
||||
case 2:
|
||||
require_once 'Metier/sphinx2/rechercheFonc.php';
|
||||
$recherche = new rechercheFonc();
|
||||
$result = $recherche->rechercheAct($formR, $deb, $nbRep, $maxRep);
|
||||
break;
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
/** Retourne les informations relatives au groupe du siren donné
|
||||
** @param string $siren Siren de l'entreprise
|
||||
**/
|
||||
public function getInfoGroupe($siren) {
|
||||
if ($siren<1000) return false;
|
||||
$tmp=$this->iDb->select('etablissements_act',
|
||||
'raisonSociale, enseigne, sigle, identite_pre, adr_num, adr_btq, adr_typeVoie, adr_libVoie, adr_comp, adr_cp, adr_ville, adr_dep, adr_com, tel, fax, siren, sirenGrp',
|
||||
"siren=(SELECT distinct sirenGrp FROM etablissements_act WHERE siren=$siren AND siege=1) LIMIT 0,1", false, MYSQL_ASSOC);
|
||||
$tabEnt=$tmp[0];
|
||||
$sirenGrp=$tabEnt['siren'];
|
||||
|
||||
if ($sirenGrp<1000) return false;
|
||||
/** Table des Nafs5 => Secteurs **/
|
||||
$tmp=$this->iDb->select('tabNaf5', 'codNaf2, codNaf1', '1 GROUP BY codNAf2', false, MYSQL_ASSOC);
|
||||
$tabNAf2=array();
|
||||
foreach ($tmp as $tmp2) {
|
||||
$tabNAf2[$tmp2['codNaf2']]=$tmp2['codNaf1'];
|
||||
}
|
||||
|
||||
$tabNaf2Lib=array( 'A'=>'Agriculture, sylviculture et pêche',
|
||||
'B'=>'Industries extractives',
|
||||
'C'=>'Industrie manufacturière',
|
||||
'D'=>'Production et distribution d\'électricité, de gaz, de vapeur et d\'air conditionné',
|
||||
'E'=>'Production et distribution d\'eau ; assainissement, gestion des déchets et dépollution',
|
||||
'F'=>'Construction',
|
||||
'G'=>'Commerce ; réparation d\'automobiles et de motocycles',
|
||||
'H'=>'Transports et entreposage',
|
||||
'I'=>'Hébergement et restauration',
|
||||
'J'=>'Information et communication',
|
||||
'K'=>'Activités financières et d\'assurance',
|
||||
'L'=>'Activités immobilières',
|
||||
'M'=>'Activités spécialisées, scientifiques et techniques',
|
||||
'N'=>'Activités de services administratifs et de soutien',
|
||||
'O'=>'Administration publique',
|
||||
'P'=>'Enseignement',
|
||||
'Q'=>'Santé humaine et action sociale',
|
||||
'R'=>'Arts, spectacles et activités récréatives',
|
||||
'S'=>'Autres activités de services',
|
||||
'T'=>'Activités des ménages en tant qu\'employeurs ; activités indifférenciées des ménages en tant que producteurs de biens et services pour usage propre',
|
||||
'U'=>'Activités extra-territoriales',
|
||||
);
|
||||
|
||||
$tabId=$this->iInsee->getIdentiteEntreprise($sirenGrp);
|
||||
/*
|
||||
[SiretSiege] => 54205118000066
|
||||
[dir1Titre] => Président du conseil d'administration
|
||||
[dir1NomPrenom] => JACQUIN DE MARGERIE Christophe
|
||||
[Activite] => la recherche et l' exploitation des gisements miniers et notamment d'hydrocarbures sous toutes leurs formes, l'industrie, le raffinage, la transformation et le commerce de ces matières ainsi que leurs dérivés et sous-produits, ainsi que toutes activités relevant de l' énergie et de la chimie
|
||||
[dir1Code] => 1306
|
||||
[dir1Nom] => JACQUIN DE MARGERIE
|
||||
[dir1Prenom] => Christophe
|
||||
[dir1DateFct] =>
|
||||
[dir1DateNaiss] => 1951-08-06
|
||||
[dir1LieuNaiss] => MAREUIL-SUR-LAY-DISSAIS
|
||||
[dir2Code] => 0709
|
||||
[dir2Titre] => Directeur général
|
||||
[dir2NomPrenom] => JACQUIN DE MARGERIE Christophe
|
||||
[dir2Nom] => JACQUIN DE MARGERIE
|
||||
[dir2Prenom] => Christophe
|
||||
[dir2DateFct] =>
|
||||
[dir2DateNaiss] => 1951-08-06
|
||||
[dir2LieuNaiss] => MAREUIL-SUR-LAY-DISSAIS
|
||||
[dateImmat] => 1954-08-20
|
||||
[dateRad] => 0000-00-00
|
||||
[Bourse] => Array
|
||||
[placeCotation] => Euronext Paris (France)
|
||||
[capitalisation] => 87020810003.675
|
||||
[derCoursDate] => 2011-10-17
|
||||
[derCoursCloture] => 37.055
|
||||
*/
|
||||
$tabRet=array( 'grpNom' => $tabEnt['raisonSociale'],
|
||||
'grpEnseigne' => $tabEnt['enseigne'],
|
||||
'grpSigle' => $tabEnt['sigle'],
|
||||
//'grpEnseigne' => $tabEnt['identite_pre'],
|
||||
'grpAdrNum' => $tabEnt['adr_num'],
|
||||
'grpAdrBtq' => $tabEnt['adr_btq'],
|
||||
'grpAdrTypeVoie'=> $tabEnt['adr_typeVoie'],
|
||||
'grpadrLibVoie' => $tabEnt['adr_libVoie'],
|
||||
'grpAdrComp' => $tabEnt['adr_comp'],
|
||||
'grpAdrCP' => $tabEnt['adr_cp'],
|
||||
'grpAdrVille' => $tabEnt['adr_ville'],
|
||||
'grpAdrDep' => $tabEnt['adr_dep'],
|
||||
'grpAdrCom' => $tabEnt['adr_com'],
|
||||
'grpTel' => $tabEnt['tel'],
|
||||
'grpFax' => $tabEnt['fax'],
|
||||
'grpSiren' => $tabEnt['siren'],
|
||||
//'grpSirenGrp' => $tabEnt['sirenGrp'],
|
||||
'grpTva' => $tabId['TvaNumero'],
|
||||
'grpIsin' => $tabId['Isin'],
|
||||
'grpNumRC' => $tabId['numRC'],
|
||||
'grpTribunal' => $tabId['TribunalLib'],
|
||||
'grpWeb' => $tabId['Web'],
|
||||
//'grpTVA' => $tabId['TvaNumero'],
|
||||
);
|
||||
$tmp=$this->iDb->select('jo.etablissements_act e',
|
||||
'e.siren, e.eff_entrep, e.dateCrea_ent AS dateCrea, e.dateImmat*1 AS dateImmat, e.bilFK, e.bilFL, e.bilYP, e.ape_entrep, e.avisCs, e.procolHisto',
|
||||
"e.sirenGrp=$sirenGrp AND e.siege=1", false, MYSQL_ASSOC);
|
||||
$grpNbEnt=$grpEffectif=$grpCAExp=$grpCA=$nbProcol=0;
|
||||
$grpDateCrea=$grpDateImmat=date('Ymd');
|
||||
$tabSirenGrp=array();
|
||||
foreach ($tmp as $tabEnt) {
|
||||
$tabSirenGrp[]=$tabEnt['siren'];
|
||||
$grpNbEnt++;
|
||||
if ($tabEnt['bilYP']>$tabEnt['eff_entrep']) $grpEffectif+=$tabEnt['bilYP'];
|
||||
else $grpEffectif+=$tabEnt['eff_entrep'];
|
||||
if ($tabEnt['procolHisto']*1==1) $nbProcol++;
|
||||
if ($grpDateCrea>$tabEnt['dateCrea'] && $tabEnt['dateCrea']>=19000101) $grpDateCrea=$tabEnt['dateCrea'];
|
||||
if ($grpDateImmat>$tabEnt['dateImmat'] && $tabEnt['dateImmat']>=19000101) $grpDateImmat=$tabEnt['dateImmat'];
|
||||
$grpCAExp+=$tabEnt['bilFK'];
|
||||
$grpCA+=$tabEnt['bilFL'];
|
||||
/* @$tabApe5[''.$tabEnt['ape_entrep']]['nb']++;
|
||||
@$tabApe5[''.$tabEnt['ape_entrep']]['ca']+=$tabEnt['bilFL'];
|
||||
@$tabApe5[''.$tabEnt['ape_entrep']]['eff']+=$tabEnt['eff_entrep'];*/
|
||||
@$tabSecteur[$tabNAf2[''.substr($tabEnt['ape_entrep'],0,2)]]['nb']++;
|
||||
@$tabSecteur[$tabNAf2[''.substr($tabEnt['ape_entrep'],0,2)]]['ca']+=$tabEnt['bilFL'];
|
||||
@$tabSecteur[$tabNAf2[''.substr($tabEnt['ape_entrep'],0,2)]]['eff']+=$tabEnt['eff_entrep'];
|
||||
|
||||
@$tabAvis[$tabEnt['avisCs']]++;
|
||||
}
|
||||
foreach ($tabSecteur as $secteur=>$tmp) {
|
||||
$tabSecteur2[$secteur]['activite']=$tabNaf2Lib[$secteur];
|
||||
$tabSecteur2[$secteur]['nb']=$tmp['nb'];
|
||||
$tabSecteur2[$secteur]['nb_tx']=round($tmp['nb']*100/$grpNbEnt,2);
|
||||
$tabSecteur2[$secteur]['ca']=$tmp['ca'];
|
||||
$tabSecteur2[$secteur]['ca_tx']=round($tmp['ca']*100/$grpCA,2);
|
||||
$tabSecteur2[$secteur]['eff']=$tmp['eff'];
|
||||
$tabSecteur2[$secteur]['eff_tx']=round($tmp['eff']*100/$grpEffectif,2);
|
||||
}
|
||||
$tabRet['grpNbEntrep']=$grpNbEnt;
|
||||
$tabRet['grpEffectif']=$grpEffectif;
|
||||
if ($grpDateCrea<$grpDateImmat)
|
||||
$tabRet['grpAnneCreation']=substr($grpDateCrea,0,4);
|
||||
else
|
||||
$tabRet['grpAnneCreation']=substr($grpDateImmat,0,4);
|
||||
$tabRet['grpCAExport']=$grpCAExp;
|
||||
$tabRet['grpCA']=$grpCA;
|
||||
if ($grpCA>=500000000) $tabRet['grpGrandGroupeFr']=1; else $tabRet['grpGrandGroupeFr']=0;
|
||||
// $tabRet['ape5']=$tabApe5;
|
||||
$tabRet['secteur']=$tabSecteur2;
|
||||
$tabRet['avisCs']=$tabAvis; // Vérifier les procol
|
||||
|
||||
$strSiren=implode(',', $tabSirenGrp);
|
||||
/*$tmp=$this->iDb->select('insee.insee_notices',
|
||||
'insSIREN, insNIC, dateNotice',
|
||||
"insSIREN IN($strSiren) AND insRECME>0 GROUP BY insSIREN, insNIC, dateNotice ORDER BY dateNotice DESC", false, MYSQL_ASSOC);
|
||||
if (count($tmp)>0) $tabRet['grpRecme']=1;
|
||||
else $tabRet['grpRecme']=0;*/
|
||||
$tabRet['grpNbProcolHisto']=$nbProcol;
|
||||
|
||||
return $tabRet;
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
473
library/Metier/partenaires/classMLiensPre.php
Normal file
473
library/Metier/partenaires/classMLiensPre.php
Normal file
@ -0,0 +1,473 @@
|
||||
<?
|
||||
|
||||
class MLiens {
|
||||
|
||||
public $siren=0;
|
||||
|
||||
private $tabChars=array('é'=>'é', 'ç'=>'ç','è'=>'è','à '=>'à');
|
||||
|
||||
private static $tabFct=array( 'ADM'=>'Administrateur',
|
||||
'ASS'=>'Associé',
|
||||
'COG'=>'Co-gérant',
|
||||
'CON'=>'Contrôleur de gestion',
|
||||
'DID'=>'Directeur Général Délégué',
|
||||
'DIR'=>'Directeur',
|
||||
'GER'=>'Gérant',
|
||||
'PCS'=>'Président du Conseil de Surveillance',
|
||||
'PDG'=>'Président Directeur Général',
|
||||
'PP'=>'Personne Physique',
|
||||
'PRD'=>'Président du directoire',
|
||||
'PRE'=>'Président du Conseil d\'Administration',
|
||||
'VIC'=>'Vice président du CA ou Surv.',
|
||||
);
|
||||
|
||||
public function __construct($siren) {
|
||||
$this->siren=$siren;
|
||||
}
|
||||
|
||||
/** Retourne les actionnaires du siren
|
||||
** @param int Siren de l'entreprise
|
||||
** @return array Tableau d'actionnaires
|
||||
**/
|
||||
public function getActionnaires($siren=false, $actifsUniquement=true) {
|
||||
if (!$siren) $siren=$this->siren;
|
||||
$iDb=new WDB();
|
||||
$tab=$iDb->select('liens', 'Siren1, ActionPart, Pmin, Pmax, MajMin, PpPm, Siren2, RaisonSociale, Pays, actif, source', "Siren1='$siren' AND ActionPart=1 ORDER BY source DESC, actif DESC, Pmin DESC", true, MYSQL_ASSOC);
|
||||
//$tabActiDB=mysql_select('dbo_liens_fi', 'SirenEntite, NomAdresse, PourcentageDetenu, Ville, Lien, MAJLien, MAJImport', "Siren='$siren' AND CodeLien='AC' ORDER BY PourcentageDetenu DESC");
|
||||
//@sendMail('production@scores-decisions.com', 'ylenaour@scores-decisions.com', "Debug $siren ($actifsUniquement)", print_r($tab,true)) ;
|
||||
$sourcePre=false;
|
||||
$tabRet=array();
|
||||
foreach ($tab as $i=>$lien) {
|
||||
if ($lien['source']>=1700 && $lien['source']<=1720) $source=1700;
|
||||
else $source=$lien['source'];
|
||||
if ($i>0 && $sourcePre<>$source) break;
|
||||
/*if ($actifsUniquement && $lien['actif']==0) continue;
|
||||
else
|
||||
$tabRet[]=array('Pmin' => number_format($lien['Pmin']*1,2,',',''),
|
||||
'MajMin' => $lien['MajMin'],
|
||||
'RaisonSociale' => strtr($lien['RaisonSociale'],$this->tabChars),
|
||||
'Pays' => $lien['libPays'],
|
||||
'Siren' => $lien['Siren2'],
|
||||
'Actif' => $lien['actif']);*/
|
||||
if ($actifsUniquement && $lien['actif']==0) continue;
|
||||
else {
|
||||
$codPays=strtoupper($lien['Pays']);
|
||||
$libPays='';
|
||||
if ($codPays<>'' && $codPays<>'FRA') {
|
||||
$tmp=$iDb->select('tabPays', 'libPays', "codPays3='$codPays'", true, MYSQL_ASSOC);
|
||||
$libPays=$tmp[0]['libPays'];
|
||||
}
|
||||
if ($lien['MajMin']=='F') $majMin='A';
|
||||
else $majMin=$lien['MajMin'];
|
||||
$tabRet[]=array( 'Pmin' => number_format($lien['Pmin']*1,2,',',''),
|
||||
'MajMin' => $majMin,
|
||||
'RaisonSociale' => strtr($lien['RaisonSociale'],$this->tabChars),
|
||||
'Pays' => $libPays,
|
||||
'Siren' => $lien['Siren2'],
|
||||
'Actif' => $lien['actif']);
|
||||
}
|
||||
$sourcePre=$source;
|
||||
}
|
||||
|
||||
if (count($tabRet)==0) {
|
||||
$iInsee=new MInsee();
|
||||
$tabTmp=$iInsee->getIdentiteLight($siren);
|
||||
switch ($tabTmp['FJ']*1) {
|
||||
case 7111:
|
||||
case 7113:
|
||||
case 7120:
|
||||
case 7150:
|
||||
case 7160:
|
||||
case 7171:
|
||||
case 7172:
|
||||
case 7179:
|
||||
case 7190:
|
||||
case 7229:
|
||||
case 7331:
|
||||
case 7349:
|
||||
case 7351:
|
||||
case 7352:
|
||||
case 7364:
|
||||
case 7365:
|
||||
case 7366:
|
||||
case 7371:
|
||||
case 7372:
|
||||
case 7373:
|
||||
case 7379:
|
||||
case 7381:
|
||||
case 7382:
|
||||
case 7383:
|
||||
case 7384:
|
||||
case 7385:
|
||||
case 7389:
|
||||
case 7410:
|
||||
case 7430:
|
||||
case 7450:
|
||||
case 7490:
|
||||
$tabRet[]=array('Pmin' => 0,
|
||||
'MajMin' => '+',
|
||||
'RaisonSociale' => 'ETAT FRANCAIS',
|
||||
'Pays' => '',
|
||||
'Siren' => 0,
|
||||
'Actif' => 1);
|
||||
break;
|
||||
case 7210: // Communes
|
||||
// Siren Commune du Lamentin : 219 722 139
|
||||
// ~~~ ~~~~
|
||||
$dept=substr($siren,2,2);
|
||||
$comm=substr($siren,5,3);
|
||||
$codeInsee=$dept.$comm;
|
||||
if ($dept<>'20') // Corse
|
||||
$strCodeInsee="codeInsee='$codeInsee'";
|
||||
else
|
||||
$strCodeInsee="codeInsee IN ('2A$comm','2B$comm','20$comm') ";
|
||||
|
||||
$tmp=$iDb->select('insee.insee_tabVillesEpci', 'typEPCI, codEPCI, libEPCI, libCommune', $strCodeInsee, true, MYSQL_ASSOC);
|
||||
$tabCC=$tmp[0];
|
||||
switch($tabCC['typEPCI']) {
|
||||
case 'CA': $typeCC="Communauté d'agglomérations"; break; // CJ=7348
|
||||
case 'CC': $typeCC="Communauté de communes"; break; // CJ=7346
|
||||
case 'CU': $typeCC="Communauté urbaine"; break; // CJ=73
|
||||
case 'SAN': $typeCC="Syndicat d'agglomérations nouvelles"; break; // CJ=73
|
||||
default: $typeCC='';
|
||||
}
|
||||
$tabRet[]=array('Pmin' => 0,
|
||||
'MajMin' => '+',
|
||||
'RaisonSociale' => strtoupper($typeCC.' '.preg_replace('/^(CA|CC|CU|SAN) /Uis', '',$tabCC['libEPCI'])),
|
||||
'Pays' => '',
|
||||
'Siren' => $tabCC['codEPCI'],
|
||||
'Actif' => 1);
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if (count($tabRet)==0) {
|
||||
$iInsee=new MInsee();
|
||||
$tabTmp=$iInsee->getIdentiteLight($siren);
|
||||
$fj=$tabTmp['FJ']*1;
|
||||
if ($fj==5498) $strFonctions=",'Gérant'";
|
||||
else $strFonctions='';
|
||||
$adresse=end(explode(' ', $tabTmp['AdresseVoie']));
|
||||
$codePostal=$tabTmp['CP'];
|
||||
$tab=$iDb->select('rncs_dirigeants', 'typeDir, raisonSociale, dirSiren, dirRS, civilite, nom, prenom, actif, naissance_nom, naissance_date, naissance_lieu, nat, adresse, fonction_code, fonction_lib, source, cinf',
|
||||
"siren='$siren' AND fonction_lib IN ('Associé-gérant' $strFonctions)", true, MYSQL_ASSOC);
|
||||
$majMin='+';
|
||||
if (count($tab)>1) $majMin='-';
|
||||
foreach ($tab as $i=>$lien) {
|
||||
if ($actifsUniquement && $lien['actif']==0) continue;
|
||||
else {
|
||||
$ville=$siege=$actif='';
|
||||
$deb=$siren2=0;
|
||||
$nbRep=$maxRep=200;
|
||||
$pertinence=$avecSiren=true;
|
||||
|
||||
$etabs=$iInsee->rechercheEtab($lien['nom'].' '.$lien['prenom'], $adresse, $codePostal, $ville, $siege, $actif, $deb, $nbRep, $maxRep, $pertinence, $avecSiren);
|
||||
$tabSiren=array();
|
||||
foreach ($etabs['reponses'] as $etab) {
|
||||
$tabTmp=preg_split('/( +|\/|\*)/', $etab['Nom']);
|
||||
$rsEtab=$tabTmp[0];
|
||||
$tabTmp=preg_split('/( +|\/|\*)/', $lien['nom']);
|
||||
$rsLien=$tabTmp[0];
|
||||
if ($etab['FJ']==1800 && $rsEtab==$rsLien)
|
||||
$tabSiren[]=$etab['Siren'];
|
||||
}
|
||||
/*
|
||||
'Nom'=>prepareString(strtr($etab['Nom'],'/*',' ')),
|
||||
'Nom2'=>prepareString($etab['Nom2']),
|
||||
'Sigle'=>prepareString($etab['Sigle']),
|
||||
'Enseigne'=>prepareString($etab['Enseigne']),
|
||||
'Adresse'=>prepareString($etab['Adresse']),
|
||||
'CP'=>$etab['CP'],
|
||||
'Ville'=>prepareString($etab['Ville']),
|
||||
'Tel'=>$etab['Tel'],
|
||||
'Fax'=>$etab['Fax'],
|
||||
'Nic'=>$etab['Nic'],
|
||||
'Actif'=>$etab['Actif'],
|
||||
'NafEtab'=>$etab['NafEtab'], // Etablissement
|
||||
'NafEtabLib'=>prepareString($etab['NafEtabLib']),
|
||||
'NafEnt'=>$etab['NafEnt'], // Entreprise
|
||||
'NafEntLib'=>prepareString($etab['NafEntLib']),*/
|
||||
$tabSiren2=array_unique($tabSiren);
|
||||
if (count($tabSiren2==1)) $siren2=end($tabSiren2);
|
||||
else $siren2=$lien['dirSiren'];
|
||||
if ($lien['civilite']=='MME') $genre='Madame';
|
||||
elseif ($lien['civilite']=='M') $genre='Monsieur';
|
||||
else $genre='';
|
||||
$tabRet[]=array( 'Pmin' => 0,
|
||||
'MajMin' => $majMin,
|
||||
'RaisonSociale' => trim(preg_replace('/ +/', ' ', $lien['dirRS'].' '.$genre.' '.$lien['nom'].' '.$lien['prenom'])),
|
||||
'Pays' => '',
|
||||
'Siren' => $siren2,
|
||||
'Actif' => $lien['actif']);
|
||||
if ($siren2*1>0) {
|
||||
/** Insertion du lien en base **/
|
||||
$nom=$pays=$dateMAJ='';
|
||||
$ppPm='P';
|
||||
$pct=0;
|
||||
$entrep2=$iInsee->getIdentiteLight($siren);
|
||||
$nom2=$entrep2['Nom'];
|
||||
$pays2='FRA';
|
||||
if (substr($entrep2['FJ'],0,1)*1<>1) $ppPm='M';
|
||||
$entrep=$iInsee->getIdentiteLight($siren2);
|
||||
$nom=strtr($entrep['Nom'],'/*',' ');
|
||||
$pays='FRA';
|
||||
$tabUpdate=array( 'Pmin'=> $pct,
|
||||
'Pmax'=> $pct,
|
||||
'MajMin'=> $majMin,
|
||||
'PpPm'=> $ppPm,
|
||||
'dateLien'=> $dateMAJ,
|
||||
);
|
||||
/* Insertion de l'actionnaire */
|
||||
$tabInsert1=array_merge($tabUpdate, array( 'ActionPart'=>1),
|
||||
array( 'Siren1'=> $siren,
|
||||
'Siren2'=> $siren2,
|
||||
'RaisonSociale'=> $nom,
|
||||
'Pays'=> $pays,
|
||||
'actif'=> 1,
|
||||
'source'=> 1600,
|
||||
'dateInsert'=> date('YmdHis')));
|
||||
$res=$iDb->select('liens', 'count(*)', "Siren1=$siren AND (Siren2=$siren2 OR (RaisonSociale='".addslashes($nom)."' AND Pays='$pays'))");
|
||||
if ($res[0][0]>0) {
|
||||
if (!$iDb->update('liens', array_merge($tabUpdate,array('ActionPart'=>1)), "siren=$siren AND (Siren2=$siren2 OR (RaisonSociale='".addslashes($nom)."' AND Pays='$pays'))", true))
|
||||
$errMaj=1016166;
|
||||
} else {
|
||||
if (!$iDb->insert('liens', $tabInsert1, true))
|
||||
$errMaj=1016167;
|
||||
}
|
||||
|
||||
/* Insertion de la participation pour l'actionnaire précédent */
|
||||
$tabInsert2=array_merge($tabUpdate, array( 'ActionPart'=>2),
|
||||
array( 'Siren1'=> $siren2,
|
||||
'Siren2'=> $siren,
|
||||
'RaisonSociale'=> $nom2,
|
||||
'Pays'=> $pays2,
|
||||
'actif'=> 1,
|
||||
'source'=> 1600,
|
||||
'dateInsert'=> date('YmdHis')));
|
||||
$res=$iDb->select('liens', 'count(*)', "Siren1=$siren2 AND (Siren2=$siren OR (RaisonSociale='$nom2' AND Pays='$pays2'))");
|
||||
if ($res[0][0]>0) {
|
||||
if (!$iDb->update('liens', array_merge($tabUpdate,array('ActionPart'=>2)), "siren=$siren2 AND (Siren2=$siren OR (RaisonSociale='".addslashes($nom2)."' AND Pays='$pays2'))", true))
|
||||
$errMaj=1016168;
|
||||
} else {
|
||||
if (!$iDb->insert('liens', $tabInsert2, true))
|
||||
$errMaj=1016169;
|
||||
}
|
||||
|
||||
/** Insertion du dirigeant pour l'actionnaire en base **/
|
||||
$dirs=$iDb->select('rncs_dirigeants','siren', "siren=$siren2", true, MYSQL_ASSOC);
|
||||
if (count($dirs)==0) {
|
||||
$iDb->insert('rncs_dirigeants', array( 'siren' => $siren2,
|
||||
'raisonSociale' => $nom,
|
||||
'civilite' => $lien['civilite'],
|
||||
'typeDir' => $lien['typeDir'],
|
||||
'dirRS' => $siren2,
|
||||
'nom' => $lien['nom'],
|
||||
'prenom' => $lien['prenom'],
|
||||
'naissance_nom' => $lien['naissance_nom'],
|
||||
'naissance_date'=> $lien['naissance_date'],
|
||||
'naissance_lieu'=> $lien['naissance_lieu'],
|
||||
'nat' => $lien['nat'],
|
||||
'fonction_code' => 0,
|
||||
'fonction_lib' => 'Personne Physique',
|
||||
'actif' => 1,
|
||||
'dateInsert' => date('YmdHis'),
|
||||
'source' => 'lag', // Lien Associé Gérant
|
||||
'cinf' => $lien['cinf'],
|
||||
), true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
//@sendMail('production@scores-decisions.com', 'ylenaour@scores-decisions.com', "Debug Fin $siren ($actifsUniquement)", print_r($tabRet,true)) ;
|
||||
return $tabRet;
|
||||
}
|
||||
|
||||
/** Retourne les participations du siren
|
||||
** @param int Siren de l'entreprise
|
||||
** @return array Tableau de participations
|
||||
**/
|
||||
public function getParticipations($siren=false, $actifsUniquement=true) {
|
||||
if (!$siren) $siren=$this->siren;
|
||||
$iDb=new WDB();
|
||||
$tab=$iDb->select('liens LEFT JOIN tabPays ON codPays3=Pays', 'Siren1, ActionPart, Pmin, Pmax, MajMin, PpPm, Siren2, RaisonSociale, Pays, libPays, actif, source', "Siren1='$siren' AND ActionPart=2 ORDER BY source DESC, actif DESC, Pmin DESC", true, MYSQL_ASSOC); // OR Siren2='$siren
|
||||
// $tabPartDB=mysql_select('dbo_liens_fi', 'SirenEntite, NomAdresse, PourcentageDetenu, Ville, Lien, MAJLien, MAJImport', "Siren='$siren' AND CodeLien='PA' ORDER BY PourcentageDetenu DESC");
|
||||
$tabRet=array();
|
||||
$sourcePre=false;
|
||||
foreach ($tab as $i=>$lien) {
|
||||
if ($lien['source']>=500 && $lien['source']<=520) $source=500;
|
||||
else $source=$lien['source'];
|
||||
if ($i>0 && $sourcePre<>$source) break;
|
||||
if ($actifsUniquement && $lien['actif']==0) continue;
|
||||
else
|
||||
$tabRet[]=array('Pmin' => number_format($lien['Pmin']*1,2,',',''),
|
||||
'MajMin' => $lien['MajMin'],
|
||||
'RaisonSociale' => strtr($lien['RaisonSociale'],$this->tabChars),
|
||||
'Pays' => $lien['libPays'],
|
||||
'Siren' => $lien['Siren2'],
|
||||
'Actif' => $lien['actif']);
|
||||
$sourcePre=$source;
|
||||
}
|
||||
|
||||
if (count($tabRet)==0) {
|
||||
$iInsee=new MInsee();
|
||||
$tabTmp=$iInsee->getIdentiteLight($siren);
|
||||
switch ($tabTmp['FJ']*1) {
|
||||
case 7346: // Communaute de communes
|
||||
case 7348: // Communaute d'agglomeration
|
||||
//case 'CC': $typeCC="Communauté de communes"; break; // CJ=73
|
||||
//case 'CU': $typeCC="Communauté urbaine"; break; // CJ=73
|
||||
//case 'SAN': $typeCC="Syndicat d'agglomérations nouvelles"; break; // CJ=73
|
||||
$tmp=$iDb->select('insee.insee_tabVillesEpci', 'typEPCI, libEPCI, codeInsee, libCommune', "codEPCI='$siren'", true, MYSQL_ASSOC);
|
||||
|
||||
@sendMail('production@scores-decisions.com', 'ylenaour@scores-decisions.com', "Debug Fin $siren ($actifsUniquement)", print_r($tmp, true)) ;
|
||||
|
||||
foreach ($tmp as $tabCom) {
|
||||
$dept=substr($tabCom['codeInsee'],0,2);
|
||||
if ($dept=='2A' || $dept=='2B' || $dept=='20')
|
||||
$dept='200';
|
||||
elseif ($dept*1>95)
|
||||
$dept=substr($tabCom['codeInsee'],0,3);
|
||||
else
|
||||
$dept=$dept.'0';
|
||||
$comm=substr($tabCom['codeInsee'],2,3);
|
||||
for ($iSir=0; $iSir<10; $iSir++) {
|
||||
$sirenCom='21'.$dept.$comm.$iSir;
|
||||
if ($iInsee->valideSiren($sirenCom)) break;
|
||||
}
|
||||
$tabRet[]=array('Pmin' => 0,
|
||||
'MajMin' => '+',
|
||||
'RaisonSociale' => 'COMMUNE DE '.strtoupper($tabCom['libCommune']),
|
||||
'Pays' => '',
|
||||
'Siren' => $sirenCom,
|
||||
'Actif' => 1);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return $tabRet;
|
||||
}
|
||||
|
||||
public function getLiens($siren=false) {
|
||||
$tabA=$this->getActionnaires($siren);
|
||||
$tabP=$this->getParticipations($siren);
|
||||
return array( 'actionnaires'=>$tabA,
|
||||
'participations'=>$tabP);
|
||||
}
|
||||
|
||||
|
||||
private function getLiensPartenaires($siren=false) {
|
||||
if (!$siren) $siren=$this->siren;
|
||||
/** Le partenaire pour les liens Actionnaires/Participations est infobilan.decideur.com
|
||||
**/
|
||||
$urlRacine='http://infobilan.decideur.com/';
|
||||
$tabPost=array( 'choix'=>'1',
|
||||
'pagePrecedente'=>'recherche_entreprise.html',
|
||||
'nomsocRech'=>'',
|
||||
'cpRech'=>'',
|
||||
'villeRech'=>'',
|
||||
'nomdirRech'=>'',
|
||||
'predirRech'=>'',
|
||||
'sirenRech'=>$this->siren,
|
||||
'telRech'=>'',
|
||||
'Rechercher.x'=>round(79),
|
||||
'Rechercher.y'=>round(19),);
|
||||
$url=$urlRacine.'liste_result.html';
|
||||
$referer=$urlRacine.'recherche_entreprise.html';
|
||||
$page=getUrl($url,'', $tabPost, $referer, false, 'infobilan.decideur.com');
|
||||
$this->body=$page['body'];
|
||||
$strCookie=$page['header']['Set-Cookie'];
|
||||
$refererInfoD=$url;
|
||||
|
||||
if(preg_match_all('/<a href="choix_pdt\.html\?(.*)" class="tt1">(.*)<\/a><\/span><br>/i', $page['body'], $matches))
|
||||
{
|
||||
$urlInfoD=$urlRacine.'choix_pdt.html?'.$matches[1][0];
|
||||
$page=getUrl($urlInfoD,$strCookie,'', $refererInfoD, false, 'infobilan.decideur.com');
|
||||
$referer=$urlInfoD;
|
||||
if ($this->nscrl==0) $this->nscrl=@getTextInHtml($url, 'nscrlP=', '=','&');
|
||||
|
||||
$url=$urlRacine.'fiche_ident.html';
|
||||
$page=getUrl($url,$strCookie,'', $referer, false, 'infobilan.decideur.com');
|
||||
$this->body=$page['body'];
|
||||
|
||||
if ($this->raisonSociale=='')
|
||||
$this->raisonSociale=trim(@getTextInHtml($this->body, '<span class="libelle2">Société', ' :', '</span>'));
|
||||
|
||||
if ($this->adresse=='')
|
||||
$this->adresse=trim(@getTextInHtml($this->body, '<span class="libelle2">Adresse</span> <strong>:', '</strong>', '</td>'));
|
||||
|
||||
if ($this->tel=='')
|
||||
$this->tel=trim(@getTextInHtml($this->body, '<td valign="top"><span class="libelle2">Tél', '</span>', '<br>'));
|
||||
if ($this->fax=='')
|
||||
$this->fax=trim(@getTextInHtml($this->body, '<span class="libelle2">Fax</span>', ' :', '<br>'));
|
||||
if ($this->web=='')
|
||||
$this->web=trim(@getTextInHtml($this->body, '<span class="libelle2">Site Web</span>', '<a href="', '" target="_blank">'));
|
||||
if ($this->mail=='')
|
||||
$this->mail=trim(@getTextInHtml($this->body, '<span class="libelle2">E-mail</span>', '<a href="mailto:', '">'));
|
||||
if ($this->naf=='')
|
||||
$this->naf=trim(@getTextInHtml($this->body, '<span class="libelle2">Code NAF</span>', ' :', '</td>'));
|
||||
|
||||
if(preg_match('/<td valign="top"><span class="libelle2">Capital social<\/span> : (\d*)(.*)<br>/isU', $this->body, $matches)
|
||||
&& ($this->capitalMontant=='' || $this->capitalDevise=='')) {
|
||||
$this->capitalMontant=trim($matches[1]);
|
||||
$this->capitalDevise=trim($matches[2]);
|
||||
}
|
||||
|
||||
if ($this->fj=='')
|
||||
$this->fj=trim(@getTextInHtml($this->body, '<span class="libelle2">Forme juridique</span>', ' :', '<br>'));
|
||||
if ($this->nationalite=='')
|
||||
$this->nationalite=trim(@getTextInHtml($this->body, '<span class="libelle2">Nationalité</span>', ' :', '</td>'));
|
||||
if ($this->effectif=='')
|
||||
$this->effectif=trim(@getTextInHtml($this->body, '<td valign="top"><span class="libelle2">Effectif</span>', ' :', '<br>'));
|
||||
if ($this->activite=='')
|
||||
$this->activite=trim(@getTextInHtml($this->body, '<span class="libelle2">Activité</span>', ' :', '<br>'));
|
||||
|
||||
/** Actionnaires **/
|
||||
$strTmp=trim(@getTextInHtml($this->body, 'ACTIONNAIRES<br>', '</div></h1>', '<h1>'));
|
||||
if(preg_match_all('/<p><span class="libelle2">(.*)<\/span> - <span class="libelle2">Participation<\/span> : (.*) %<br>(.*)<\/p>/isU', $strTmp, $matches)) {
|
||||
foreach ($matches[1] as $i=>$nom) {
|
||||
$this->tabAct[$i]['nom']=trim($nom);
|
||||
$this->tabAct[$i]['pct']=trim($matches[2][$i]);
|
||||
$this->tabAct[$i]['rcs']=trim(str_replace('RCS : ','',strip_tags($matches[3][$i])));
|
||||
}
|
||||
}
|
||||
|
||||
/** Filiales **/
|
||||
$strTmp=trim(@getTextInHtml($this->body, 'FILIALES<br>', '</div></h1>', '<h1>'));
|
||||
if(preg_match_all('/<p><span class="libelle2">(.*)<\/span> - <span class="libelle2">Participation<\/span> :(.*)%<br>(.*)<\/p>/isU', $strTmp, $matches)) {
|
||||
foreach ($matches[1] as $i=>$nom) {
|
||||
$this->tabFil[$i]['nom']=trim($nom);
|
||||
$this->tabFil[$i]['pct']=trim($matches[2][$i]);
|
||||
$this->tabFil[$i]['rcs']=trim(str_replace('RCS :','',strip_tags($matches[3][$i])));
|
||||
}
|
||||
}
|
||||
|
||||
/** CA et Résultat **/
|
||||
$strTmp=trim(@getTextInHtml($this->body, '<h1>PRINCIPAUX ELEMENTS FINANCIERS<br>', '</div></h1>', '</p>'));
|
||||
if(preg_match('/<p><span class="libelle2">CA (.*)<\/span>(.*)<br>/isU', $strTmp, $matches)) {
|
||||
$this->derExerciceAnnee=trim($matches[1]);
|
||||
$this->derExerciceCA=trim(str_replace(':',' ', $matches[2]));
|
||||
}
|
||||
if(preg_match('/<span class="libelle2">Résultat(.*)<\/span>(.*)$/isU', $strTmp, $matches)) {
|
||||
$this->derExerciceResultat=trim(str_replace(':',' ', $matches[2]));
|
||||
}
|
||||
|
||||
/*
|
||||
$infoBilan=print_r($page, true);
|
||||
$fp=fopen('./infobilan.html', 'w');
|
||||
fwrite($fp, $infoBilan);
|
||||
fclose($fp);
|
||||
*/
|
||||
}
|
||||
|
||||
$tabA=$this->getActionnaires($siren);
|
||||
$tabP=$this->getParticipations($siren);
|
||||
return array( 'actionnaires'=>$tabA,
|
||||
'participations'=>$tabP);
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
798
library/Metier/partenaires/classMMap.php
Normal file
798
library/Metier/partenaires/classMMap.php
Normal file
@ -0,0 +1,798 @@
|
||||
<?
|
||||
if ( !function_exists('htmlspecialchars_decode') )
|
||||
{
|
||||
function htmlspecialchars_decode($text)
|
||||
{
|
||||
return strtr($text, array_flip(get_html_translation_table(HTML_SPECIALCHARS)));
|
||||
}
|
||||
}
|
||||
|
||||
require_once 'framework/common/curl.php';
|
||||
|
||||
function supprDecimales($dec) {
|
||||
if ($dec>0 )
|
||||
return floor($dec);
|
||||
else
|
||||
return ceil($dec);
|
||||
}
|
||||
|
||||
function dec2dms($dec) {
|
||||
$d = supprDecimales($dec);
|
||||
$m = supprDecimales(($dec - $d) * 60);
|
||||
$s = abs(round(((($dec - $d) * 60) - $m) * 60));
|
||||
$m = abs($m);
|
||||
return $d.'°'.$m."'".$s.'"';
|
||||
}
|
||||
|
||||
function ALG0001($phi,$e) {
|
||||
$temp = ( 1 - ( $e * sin( $phi ) ) ) / ( 1 + ( $e * sin( $phi ) ) );
|
||||
$L = log ( tan ( (pi()/4) + ($phi/2) ) * pow ($temp, ($e/2) ));
|
||||
return $L;
|
||||
}
|
||||
|
||||
|
||||
function ALG0002($L,$e,$epsilon) {
|
||||
$phi[0] = 2 * atan(exp($L)) - (pi()/2);
|
||||
|
||||
$i=0;
|
||||
do
|
||||
{
|
||||
$i++;
|
||||
$temp = ( 1 + ( $e * sin( $phi[$i-1] ) ) ) / ( 1 - ( $e * sin( $phi[$i-1] ) ) );
|
||||
$phi[$i] = 2 * atan ( pow ($temp, ($e/2)) * exp ($L) ) - pi()/2;
|
||||
}
|
||||
while (abs($phi[$i] - $phi[$i - 1]) >= $epsilon);
|
||||
|
||||
return $phi[$i];
|
||||
}
|
||||
|
||||
function ALG0004($X,$Y,$n,$c,$Xs,$Ys,$lambdac,$e,$epsilon) {
|
||||
$R = sqrt( pow(($X - $Xs),2) + pow(($Y - $Ys),2) );
|
||||
$gamma = atan(($X - $Xs)/($Ys - $Y));
|
||||
|
||||
$lambda = $lambdac + ($gamma / $n);
|
||||
|
||||
$L = (-1 / $n) * log(abs($R/$c));
|
||||
|
||||
$phi = ALG0002($L,$e,$epsilon);
|
||||
|
||||
$coords['lambda']=$lambda;
|
||||
$coords['phi']=$phi;
|
||||
|
||||
return $coords;
|
||||
}
|
||||
|
||||
function ALG0009($lambda,$phi,$he,$a,$e) {
|
||||
$N = ALG0021($phi,$a,$e);
|
||||
|
||||
$X = ($N + $he) * cos($phi) * cos($lambda);
|
||||
|
||||
$Y = ($N + $he) * cos($phi) * sin($lambda);
|
||||
|
||||
$Z = ($N * (1 - $e*$e) + $he) * sin ($phi);
|
||||
|
||||
$coords['X']=$X;
|
||||
$coords['Y']=$Y;
|
||||
$coords['Z']=$Z;
|
||||
|
||||
return $coords;
|
||||
}
|
||||
|
||||
|
||||
function ALG0012($X,$Y,$Z,$a,$e,$epsilon) {
|
||||
$lambda = atan ($Y/$X);
|
||||
|
||||
$P = sqrt($X*$X + $Y*$Y);
|
||||
$phi[0] = atan ($Z/ ($P * (1 - ( ($a*$e*$e)/sqrt($X*$X + $Y*$Y + $Z*$Z) ) ) ) );
|
||||
|
||||
$i = 0;
|
||||
do
|
||||
{
|
||||
$i++;
|
||||
$temp = pow((1 - ( $a * $e*$e * cos($phi[$i - 1] )/( $P * sqrt(1 - $e*$e * sin($phi[$i - 1])*sin($phi[$i - 1]))))),-1);
|
||||
$phi[$i] = atan( $temp * $Z / $P );
|
||||
}
|
||||
while (abs($phi[$i] - $phi[$i - 1]) >= $epsilon);
|
||||
|
||||
$phix = $phi[$i];
|
||||
|
||||
$he = ($P/cos($phix)) - ($a/sqrt(1 - $e*$e * sin($phix)*sin($phix)));
|
||||
|
||||
$coords['lambda']=$lambda;
|
||||
$coords['phi']=$phix;
|
||||
$coords['he']=$he;
|
||||
|
||||
return $coords;
|
||||
}
|
||||
|
||||
function ALG0013($Tx,$Ty,$Tz,$D,$Rx,$Ry,$Rz,$U) {
|
||||
$V['X'] = $Tx + $U['X'] * (1 + $D) + $U['Z'] * $Ry - $U['Y'] * $Rz;
|
||||
$V['Y'] = $Ty + $U['Y'] * (1 + $D) + $U['X'] * $Rz - $U['Z'] * $Rx;
|
||||
$V['Z'] = $Tz + $U['Z'] * (1 + $D) + $U['Y'] * $Rx - $U['X'] * $Ry;
|
||||
|
||||
return $V;
|
||||
}
|
||||
|
||||
function ALG0019($lambda0,$phi0,$k0,$X0,$Y0,$a,$e) {
|
||||
$lambdac = $lambda0;
|
||||
$n = sin($phi0);
|
||||
$C = $k0 * ALG0021($phi0,$a,$e) * tan (pi()/2 - $phi0) * exp ( $n * ALG0001($phi0,$e) );
|
||||
$Xs = $X0;
|
||||
$Ys = $Y0 + $k0 * ALG0021($phi0,$a,$e) * tan (pi()/2 - $phi0) ;
|
||||
|
||||
$tab ['e'] = $e;
|
||||
$tab ['n'] = $n;
|
||||
$tab ['C'] = $C;
|
||||
$tab ['lambdac'] = $lambdac;
|
||||
$tab ['Xs'] = $Xs;
|
||||
$tab ['Ys'] = $Ys;
|
||||
|
||||
return $tab;
|
||||
|
||||
}
|
||||
|
||||
function ALG0021($phi,$a,$e) {
|
||||
$N = $a/sqrt( 1 - $e * $e * sin($phi) * sin($phi) );
|
||||
return $N;
|
||||
|
||||
}
|
||||
|
||||
function ALG0054($lambda0,$phi0,$X0,$Y0,$phi1,$phi2,$a,$e) {
|
||||
$lambdac = $lambda0;
|
||||
$n = ( (log( (ALG0021($phi2,$a,$e)*cos($phi2))/(ALG0021($phi1,$a,$e)*cos($phi1)) ))/(ALG0001($phi1,$e) - ALG0001($phi2,$e) ));
|
||||
$C = ((ALG0021($phi1,$a,$e)* cos($phi1))/$n) * exp($n * ALG0001($phi1,$e));
|
||||
|
||||
|
||||
if ($phi0 == (pi()/2))
|
||||
{
|
||||
$Xs = $X0;
|
||||
$Ys = $Y0;
|
||||
}
|
||||
else
|
||||
{
|
||||
echo ('coucou');
|
||||
$Xs = $X0;
|
||||
$Ys = $Y0 + $C * exp(-1 * $n * ALG0001($phi0,$e));
|
||||
}
|
||||
|
||||
$tab ['e'] = $e;
|
||||
$tab ['n'] = $n;
|
||||
$tab ['C'] = $C;
|
||||
$tab ['lambdac'] = $lambdac;
|
||||
$tab ['Xs'] = $Xs;
|
||||
$tab ['Ys'] = $Ys;
|
||||
|
||||
return $tab;
|
||||
|
||||
}
|
||||
|
||||
function Lambert2WGS84($X,$Y,$orig='LIIe') {
|
||||
$epsilon = 0.00000000001;
|
||||
|
||||
switch ($orig)
|
||||
{
|
||||
case 'LII' :
|
||||
$n = 0.7289686274;
|
||||
$c = 11745793.39;
|
||||
$Xs = 600000;
|
||||
$Ys = 6199695.768;
|
||||
$lambdac = 0.04079234433; // pour greenwich
|
||||
|
||||
$e = 0.08248325676; //(première excentricité de l ellipsoïde Clarke 1880 français)
|
||||
|
||||
$he = 100;
|
||||
$a = 6378249.2;
|
||||
|
||||
$Tx = -168;
|
||||
$Ty = -60;
|
||||
$Tz = +320;
|
||||
$D = 0;
|
||||
$Rx = $Ry = $Rz = 0;
|
||||
break;
|
||||
|
||||
case 'L93' :
|
||||
$n = 0.7256077650;
|
||||
$c = 11745255.426;
|
||||
$Xs = 700000;
|
||||
$Ys = 12655612.050;
|
||||
$lambdac = 0.04079234433; // pour greenwich
|
||||
|
||||
$e = 0.08248325676; //(première excentricité de l ellipsoïde Clarke 1880 français)
|
||||
|
||||
$he = 100;
|
||||
$a = 6378249.2;
|
||||
|
||||
$Tx = -168;
|
||||
$Ty = -60;
|
||||
$Tz = +320;
|
||||
$D = 0;
|
||||
$Rx = $Ry = $Rz = 0;
|
||||
break;
|
||||
|
||||
case 'LIIe' :
|
||||
default:
|
||||
$n = 0.7289686274;
|
||||
$c = 11745793.39;
|
||||
$Xs = 600000;
|
||||
$Ys = 8199695.768;
|
||||
$lambdac = 0.04079234433; // pour greenwich
|
||||
|
||||
$e = 0.08248325676; //(première excentricité de l ellipsoïde Clarke 1880 français)
|
||||
|
||||
$he = 100;
|
||||
$a = 6378249.2;
|
||||
|
||||
$Tx = -168;
|
||||
$Ty = -60;
|
||||
$Tz = +320;
|
||||
$D = 0;
|
||||
$Rx = $Ry = $Rz = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
$coords = ALG0004($X,$Y,$n,$c,$Xs,$Ys,$lambdac,$e,$epsilon);
|
||||
|
||||
$coords = ALG0009($coords['lambda'],$coords['phi'],$he,$a,$e);
|
||||
|
||||
$coords = ALG0013($Tx,$Ty,$Tz,$D,$Rx,$Ry,$Rz,$coords);
|
||||
|
||||
$a = 6378137.0; // ellipsoïdes WGS84
|
||||
$f = 1/298.257223563;
|
||||
$b = $a*(1-$f);
|
||||
$e = sqrt(($a*$a - $b*$b)/($a*$a));
|
||||
|
||||
$X = $coords['X'];
|
||||
$Y = $coords['Y'];
|
||||
$Z = $coords['Z'];
|
||||
$coords = ALG0012($X,$Y,$Z,$a,$e,$epsilon);
|
||||
|
||||
$xy['long'] = rad2deg($coords['lambda']);
|
||||
$xy['lat'] = rad2deg($coords['phi']);
|
||||
return $xy;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to convert geographic coordinates to "lambert 2 etendue" coordinates
|
||||
* from: http://www.forumsig.org/showthread.php?p=64050#post64050
|
||||
**/
|
||||
function geos2lambert($latitude,$longitude) {
|
||||
//0)degres-minutes-secondes + orientation (d,m,s,o) en radian
|
||||
$lambda_w = $longitude * pi()/180 ;
|
||||
$phi_w = $latitude * pi()/180 ;
|
||||
|
||||
//1) coordonnées géographiques WGS84 (phi_w,lambda_w) en coordonnées cartésiennes WGS84 (X_w,Y_w,Z_w)
|
||||
$a_w = 6378137.0;
|
||||
$b_w = 6356752.314;
|
||||
|
||||
$e2_w = ($a_w*$a_w-$b_w*$b_w)/($a_w*$a_w);
|
||||
|
||||
//et on a la grande normale de l'ellipsoide WGS84
|
||||
$N = $a_w/sqrt(1-$e2_w*pow(sin($phi_w),2));
|
||||
|
||||
//ainsi on obtient
|
||||
$X_w = $N * cos($phi_w) * cos($lambda_w);
|
||||
$Y_w = $N * cos($phi_w) * sin($lambda_w);
|
||||
$Z_w = $N * (1-$e2_w) * sin($phi_w);
|
||||
//Ref.: http://www.ign.fr/telechargement/MPr...RCE/NTG_80.pdf and http://de.wikipedia.org/wiki/WGS84
|
||||
|
||||
//2) coordonnées cartésiennes WGS84 (X_w,Y_w,Z_w) en coordonnées cartésiennes NTF (X_n,Y_n,Z_n)
|
||||
|
||||
$dX = 168.0;
|
||||
$dY = 60.0;
|
||||
$dZ = -320.0;
|
||||
|
||||
$X_n = $X_w + $dX;
|
||||
$Y_n = $Y_w + $dY;
|
||||
$Z_n = $Z_w + $dZ;
|
||||
//ref.: http://support.esrifrance.fr/Documents/Generalites/Projections/Generalites/Generalites.htm#2
|
||||
|
||||
//3) coordonnées cartésiennes NTF (X_n,Y_n,Z_n) en coordonnées géographiques NTF (phi_n,lambda_n)
|
||||
$a_n = 6378249.2;
|
||||
$b_n = 6356515.0;
|
||||
|
||||
$e2_n = ($a_n*$a_n-$b_n*$b_n)/($a_n*$a_n);
|
||||
//on définit une tolérance de convergence
|
||||
$epsilon = pow(10,-10);
|
||||
|
||||
//puis on amorce une boucle de calcul
|
||||
$p0=atan($Z_n/sqrt($X_n*$X_n+$Y_n*$Y_n)*(1-($a_n*$e2_n)/(sqrt($X_n*$X_n+$Y_n*$Y_n+$Z_n*$Z_n))));
|
||||
$p1=atan(($Z_n/sqrt($X_n*$X_n+$Y_n*$Y_n))/(1-($a_n*$e2_n*cos($p0))/(sqrt(($X_n*$X_n+$Y_n*$Y_n)*(1-$e2_n*pow(sin($p0),2))))));
|
||||
while(!(abs($p1-$p0)<$epsilon)){
|
||||
$p0 = $p1;
|
||||
$p1 = atan(($Z_n/sqrt($X_n*$X_n+$Y_n*$Y_n))/(1-($a_n*$e2_n*cos($p0))/(sqrt(($X_n*$X_n+$Y_n*$Y_n)*(1-$e2_n*pow(sin($p0),2))))));
|
||||
}
|
||||
$phi_n = $p1;
|
||||
$lambda_n = atan($Y_n/$X_n);
|
||||
|
||||
//4) coordonnées géographiques NTF (phi_n,lambda_n) en coordonnées projetées en Lambert II étendu (X_l2e, Y_l2e)
|
||||
$n = 0.7289686274;
|
||||
$c = 11745793.39;
|
||||
$Xs = 600000.0;
|
||||
$Ys = 8199695.768;
|
||||
|
||||
$e_n = sqrt($e2_n);
|
||||
$lambda0 = 0.04079234433198; //correspond à la longitude en radian de Paris (2°20'14.025" E) par rapport à Greenwich
|
||||
//puis on calcule la latitude isométrique
|
||||
$L = log(tan(pi()/4 + $phi_n/2) * pow(((1-$e_n*sin($phi_n))/(1+$e_n*sin($phi_n))),($e_n/2)));
|
||||
|
||||
//enfin on projette
|
||||
$X_l2e = $Xs + $c*exp((-$n*$L))*sin($n*($lambda_n-$lambda0));
|
||||
$Y_l2e = $Ys - $c*exp((-$n*$L))*cos($n*($lambda_n-$lambda0));
|
||||
|
||||
return array("x_l2e"=>$X_l2e,"y_l2e"=>$Y_l2e);
|
||||
}
|
||||
|
||||
|
||||
/** Conversion WGS84 en Lambert93
|
||||
** NTG_71.pdf
|
||||
** http://www.ign.fr/affiche_rubrique.asp?rbr_id=1700&lng_id=FR
|
||||
**/
|
||||
function geos2lambert93($latitude,$longitude) {
|
||||
|
||||
// Système WGS84
|
||||
$a=6378137; // demi grand axe de l'ellipsoide (m)
|
||||
$e=0.08181919106; // première excentricitè de l'ellipsoide
|
||||
|
||||
// Paramètres de projections
|
||||
$l0=$lc=deg2rad(3); // longitude de référence
|
||||
$phi0=deg2rad(46.5); // latitude d'origine en radian
|
||||
$phi1=deg2rad(44); // 1er parallele automécoïque
|
||||
$phi2=deg2rad(49); // 2eme parallele automécoïque
|
||||
|
||||
$x0=700000; //coordonnées à l'origine
|
||||
$y0=6600000; //coordonnées à l'origine
|
||||
|
||||
// coordonnées du point à traduire
|
||||
$phi=deg2rad($latitude);
|
||||
$l=deg2rad($longitude);
|
||||
|
||||
// calcul des grandes normales
|
||||
$gN1=$a/sqrt(1-$e*$e*sin($phi1)*sin($phi1));
|
||||
$gN2=$a/sqrt(1-$e*$e*sin($phi2)*sin($phi2));
|
||||
|
||||
//calculs de slatitudes isométriques
|
||||
$gl1=log(tan(pi()/4+$phi1/2)*pow((1-$e*sin($phi1))/(1+$e*sin($phi1)),$e/2));
|
||||
$gl2=log(tan(pi()/4+$phi2/2)*pow((1-$e*sin($phi2))/(1+$e*sin($phi2)),$e/2));
|
||||
$gl0=log(tan(pi()/4+$phi0/2)*pow((1-$e*sin($phi0))/(1+$e*sin($phi0)),$e/2));
|
||||
$gl=log(tan(pi()/4+$phi/2)*pow((1-$e*sin($phi))/(1+$e*sin($phi)),$e/2));
|
||||
|
||||
//calcul de l'exposant de la projection
|
||||
$n=(log(($gN2*cos($phi2))/($gN1*cos($phi1))))/($gl1-$gl2);//ok
|
||||
|
||||
//calcul de la constante de projection
|
||||
$c=(($gN1*cos($phi1))/$n)*exp($n*$gl1);//ok
|
||||
|
||||
//calcul des coordonnées
|
||||
$ys=$y0+$c*exp(-1*$n*$gl0);
|
||||
|
||||
//calcul des coordonnées lambert
|
||||
$x93=$x0+$c*exp(-1*$n*$gl)*sin($n*($l-$lc));
|
||||
$y93=$ys-$c*exp(-1*$n*$gl)*cos($n*($l-$lc));
|
||||
|
||||
return array("x_93"=>$x93,"y_93"=>$y93);
|
||||
}
|
||||
|
||||
|
||||
//http://www.ign.fr/telechargement/MPro/geodesie/CIRCE/transfo.pdf
|
||||
//http://www.ign.fr/telechargement/MPro/geodesie/CIRCE/NTG_80.pdf
|
||||
//http://www.ign.fr/telechargement/MPro/geodesie/CIRCE/NTG_71.pdf
|
||||
/**
|
||||
print_r(Lambert2WGS84(591647.56,2426659.65));
|
||||
print_r(geos2lambert(48.838245134184 ,2.2227849815878));
|
||||
**/
|
||||
|
||||
|
||||
class MMap {
|
||||
|
||||
private $accesDist = true;
|
||||
private $referer ='';
|
||||
private $body = '';
|
||||
private $header = '';
|
||||
private $cookie = '';
|
||||
private $codeRetour = 0;
|
||||
private $codeRetourG = 0; // Code retour de l'api Google
|
||||
private $codeRetourY = 0; // Code retour de l'api Yahoo
|
||||
private $codeRetourM = 0; // Code retour de l'api Mappy
|
||||
|
||||
public $geocodeur='';
|
||||
|
||||
public $latitudeDec= 0; // Latitude en Décimal
|
||||
public $latitudeDeg= 0; // Latitude en Dégrés
|
||||
public $longitudeDec= 0; // Longitude en Décimal
|
||||
public $longitudeDeg= 0; // Longitude en Dégrés
|
||||
|
||||
public $precision = 0;
|
||||
public $adresseValidee='';
|
||||
public $enCache=false;
|
||||
|
||||
private $apiKeyG='ABQIAAAAuKBtUyFonYJBl1fqfc78tRQvADPcxwXf3Q2QIE-M32vuSkrxiBRLUHDB_YSLeTscTDeWRKM_wILaaw';
|
||||
// private $apiKey='ABQIAAAAuKBtUyFonYJBl1fqfc78tRT4Qe_2x2fax4Crd4sBzQI-tDkl3BRm2l2feTV5Lnx0Ah-aTIlwHtglpA';
|
||||
private $apiKeyY='klII0gzV34Ho2TCsN3XiXeh4No033AifxMeDXfFXj8TDCXO3WAtOLj9c74VsV45HcII-';
|
||||
|
||||
function __construct($accesDist=true) {// $adresse, $cp, $ville, $pays='France') {
|
||||
$this->accesDist=$accesDist;
|
||||
}
|
||||
|
||||
/*
|
||||
http://platform.beta.mapquest.com/geocoding/v1/address?key=YOUR_KEY_HERE&location=Lancaster,PA&callback=renderGeocode
|
||||
http://platform.beta.mapquest.com/geocoding/v1/address?key=YOUR_KEY_HERE&callback=renderOptions&inFormat=kvp&outFormat=json&location=77 rue lost al lann, 29000 quimper,france
|
||||
|
||||
Client ID: 83955
|
||||
Email Address: buzuk77@aim.com
|
||||
Registry Password: tU2cA4qV
|
||||
Forums User Name:
|
||||
JS/AS3 Key: Fmjtd%7Clu61nuuzlu%2Cr0%3Do5-5a1sd
|
||||
*/
|
||||
|
||||
/*
|
||||
GeoCodingHandler.ashx?addr=
|
||||
<wsdl:import namespace="http://dev.virtualearth.net/webservices/v1/imagery/contracts" location="http://dev.virtualearth.net/webservices/v1/metadata/imageryservice/imageryservice1.wsdl" />
|
||||
API keybing = 56D6CBA671C986D3EA11B1B48F97507BE9B46999
|
||||
*/
|
||||
public function geoCodeAdrCpVilleM($adresse,$cp,$ville,$pays='') {
|
||||
|
||||
if ($pays=='') $pays='France';
|
||||
if (preg_match('/^([0-9]{1,4} )(.*)$/', $adresse, $matches)) {
|
||||
$adresseVoie=trim($matches[2]);
|
||||
$adresseNum=trim($matches[1]);
|
||||
} else {
|
||||
$adresseVoie=trim($adresse);
|
||||
$adresseNum='';
|
||||
}
|
||||
$url='http://axe.mappy.com/services/loc/get.aspx?countryName='.urlencode($pays).'&townName='.urlencode($ville).'&wayName='.urlencode($adresseVoie).'&number='.urlencode($adresseNum).'&namedPlaceSearch=0&interactive=1&auth=maiaTest&format=json';
|
||||
|
||||
$page=getUrl($url, '', '', '', false, '', '', 3);
|
||||
|
||||
$res=json_decode($page['body']);
|
||||
$result=$res->geocode->answer;
|
||||
//print_r($result);die();
|
||||
//$this->codeRetourM=
|
||||
|
||||
switch ($result->geocode_level->code) {
|
||||
case 0: $this->precision=0; break; // No geocoding
|
||||
case 1: $this->precision=1; break; // Country level geocoding
|
||||
case 2: $this->precision=4; break; // Town level geocoding
|
||||
case 3: $this->precision=6; break; // Way level geocoding
|
||||
case 4: $this->precision=8; break; // Road element level geocoding
|
||||
default: die('Precisions Inconnue : "'.$result->geocode_level->code.'"='.$result->geocode_level->label.EOL.$page['body']); break;
|
||||
}
|
||||
|
||||
$this->adresseValidee=@preg_replace('/ +/', ' ', strtoupper(str_replace(''', "'", trim(htmlspecialchars_decode($result->road_element->number.' '.$result->way->name,ENT_QUOTES)))));
|
||||
|
||||
$this->codeRetourM=@$result->global_score;
|
||||
/*
|
||||
$result->postal_code->postal_code
|
||||
$result->subcountry->iso_code // 11
|
||||
$result->subcountry->language
|
||||
$result->subcountry->Ile-de-France
|
||||
|
||||
$result->town->language] => FRE
|
||||
$result->town->name] => Nanterre
|
||||
$result->town->official_code] => 92050
|
||||
$result->town->postal_codes->postal_code] => 92000
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
0 Unknown location. (Since 2.59)
|
||||
1 Country level accuracy. (Since 2.59)
|
||||
2 Region (state, province, prefecture, etc.) level accuracy. (Since 2.59)
|
||||
3 Sub-region (county, municipality, etc.) level accuracy. (Since 2.59)
|
||||
4 Town (city, village) level accuracy. (Since 2.59)
|
||||
5 Post code (zip code) level accuracy. (Since 2.59)
|
||||
6 Street level accuracy. (Since 2.59)
|
||||
7 Intersection level accuracy. (Since 2.59)
|
||||
8 Address level accuracy. (Since 2.59)
|
||||
*/
|
||||
$this->latitudeDec=@$result->location->coordinates->y;
|
||||
$this->longitudeDec=@$result->location->coordinates->x;
|
||||
$this->latitudeDeg=dec2dms($this->latitudeDec);
|
||||
$this->longitudeDeg=dec2dms($this->longitudeDec);
|
||||
|
||||
$this->geocodeur='Mappy';
|
||||
|
||||
//if ($this->codeRetourM>0)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
private function geoCodeAdrCpVilleY($address) {
|
||||
$_url = 'http://api.local.yahoo.com/MapsService/V1/geocode';
|
||||
$_url .= sprintf('?appid=%s&location=%s',$this->apiKeyY,rawurlencode($address));
|
||||
$_result = false;
|
||||
$page=getUrl($_url, '', '', '', false, '', '', 3);
|
||||
$_result=$page['body'];
|
||||
// die("URL='$_url'".EOL.print_r($page));
|
||||
$try=1;
|
||||
while ($page['code']!=200 && $page['code']!=403) {
|
||||
$page=getUrl($_url, '', '', '', false, '', '', 3);
|
||||
$_result=$page['body'];
|
||||
echo 'Yahoo '.$page['code']." : $address... Attente...".EOL;
|
||||
$try++;
|
||||
if ($try>=4) break;
|
||||
sleep(1);
|
||||
}
|
||||
if ($page['code']==400 && preg_match('/<Message>unable to parse location<\/Message>/', $_result)) {
|
||||
$this->latitudeDec=$this->longitudeDec=0;
|
||||
$this->latitudeDeg=$this->longitudeDeg=0;
|
||||
$this->geocodeur='Yahoo';
|
||||
$this->precision=0;
|
||||
return false;
|
||||
} elseif ($page['code']==403 && preg_match('/<Message>limit exceeded<\/Message>/', $_result)) {
|
||||
$this->latitudeDec=$this->longitudeDec=0;
|
||||
$this->latitudeDeg=$this->longitudeDeg=0;
|
||||
$this->geocodeur='Yahoo';
|
||||
$this->precision=0;
|
||||
$this->codeRetourY=620; // On adopte les codes Google
|
||||
} elseif ($page['code']==408) { // Connexion impossible au site du partenaire
|
||||
$this->latitudeDec=$this->longitudeDec=0;
|
||||
$this->latitudeDeg=$this->longitudeDeg=0;
|
||||
$this->geocodeur='Yahoo';
|
||||
$this->precision=0;
|
||||
$this->codeRetourY=500; // On adopte les codes Google
|
||||
} elseif ($page['code']==200) {
|
||||
preg_match('!<Latitude>(.*)</Latitude><Longitude>(.*)</Longitude>!U', $_result, $_match);
|
||||
$lng = $_match[2];
|
||||
$lat = $_match[1];
|
||||
preg_match('/warning="(.*)"/Ui', $_result, $_match);
|
||||
/*
|
||||
1 Country level accuracy. (Since 2.59)
|
||||
2 Region (state, province, prefecture, etc.) level accuracy. (Since 2.59)
|
||||
7 Intersection level accuracy. (Since 2.59)
|
||||
*/
|
||||
$this->precision=0; // Unknown location
|
||||
switch(@$_match[1]) {
|
||||
case "The exact location could not be found. Here is a nearby county.": $this->precision=3; break; // Sub-region
|
||||
case "The city could not be found. Here is the state/province.": $this->precision=3; break; // Sub-region
|
||||
case "The exact location could not be found. Here is a nearby neighorhood.": $this->precision=4; break; // Town level
|
||||
case "The exact location could not be found. Here is the center of the ZIP code.":
|
||||
case "The street could not be found. Here is the center of the city.": $this->precision=5; break; // Post code (zip code)
|
||||
case "The street number could not be found. Here is a nearby location.":
|
||||
case "The Street name might have been changed": $this->precision=6; break; // Street level accuracy
|
||||
case '': $this->precision=8; break; // Address level
|
||||
default:
|
||||
if (preg_match('/The exact location could not be found, here is the closest match/', @$_match[1]))
|
||||
$this->precision=6;
|
||||
else
|
||||
die('Precisions Inconnue : "'.$_match[1].'"'.EOL.$_result);
|
||||
break;
|
||||
}
|
||||
|
||||
preg_match('!<Address>(.*)</Address>(?:|.*)<City>(.*)</City>(?:|.*)<State>(.*)</State>!Ui', $_result, $_match);
|
||||
$adrValide=utf8_decode($_match[1].', '.$_match[2].', '.$_match[3]);
|
||||
$this->adresseValidee=strtoupper(str_replace(''', "'", htmlspecialchars_decode($adrValide,ENT_QUOTES)));
|
||||
$this->latitudeDec=$lat;
|
||||
$this->longitudeDec=$lng;
|
||||
$this->latitudeDeg=dec2dms($this->latitudeDec);
|
||||
$this->longitudeDeg=dec2dms($this->longitudeDec);
|
||||
$this->geocodeur='Yahoo';
|
||||
if ($lat==0 && $lng==0 || $this->precision==0) die('Réponse Yahoo = '.$_result.EOL);
|
||||
return true;//array("lat"=>$lat,"lng"=>$lng,"address"=>$address);
|
||||
}
|
||||
else {die("URL='$_url'".EOL.print_r($page));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private function geoCodeAdrCpVilleG($adresse,$cp,$ville,$pays, $proxy='') {
|
||||
|
||||
$url='http://maps.google.com/maps/geo?q='.urlencode($adresse.', '.$cp.' '. $ville.', '.$pays).'&output=xml&key='.$this->apiKeyG;
|
||||
|
||||
$page=getUrl($url, '', '', $this->referer, false, 'maps.google.com', $proxy,3);
|
||||
//getUrl($url, $strCookies='', $postData='', $referer='', $debug=false, $host='', $proxy='', $timeout=0) {
|
||||
$this->body=$page['body'];
|
||||
$this->codeRetour=$page['code'];
|
||||
$this->header=$page['header'];
|
||||
|
||||
// REVERSE GEOCODING
|
||||
// http://maps.google.com/maps/geo?oe=utf-8&ll=48.808955,2.34227&output=xml&key=ABQIAAAAuKBtUyFonYJBl1fqfc78tRQvADPcxwXf3Q2QIE-M32vuSkrxiBRLUHDB_YSLeTscTDeWRKM_wILaaw
|
||||
|
||||
//die($this->body=$page['body']);
|
||||
//{"name":"3 rue viète, 75017 paris, france","Status":{"code":200,"request":"geocode"},"Placemark":[{"id":"p1","address":"3, Rue Viète, 75017 17ème Arrondissement, Paris, France","AddressDetails":{"Country":{"CountryNameCode":"FR","AdministrativeArea":{"AdministrativeAreaName":"Ile-de-France","SubAdministrativeArea":{"SubAdministrativeAreaName":"Paris","Locality":{"LocalityName":"Paris","DependentLocality":{"DependentLocalityName":"17ème Arrondissement","Thoroughfare":{"ThoroughfareName":"3, Rue Viète"},"PostalCode":{"PostalCodeNumber":"75017"}}}}}},"Accuracy": 8},"Point":{"coordinates":[2.306174,48.883705,0]}}]}
|
||||
/*<?xml version="1.0" encoding="UTF-8"?><kml xmlns="http://earth.google.com/kml/2.0"><Response><name>3 rue viète, 75017 paris, france</name><Status><code>200</code><request>geocode</request></Status><Placemark id="p1"><address>3, Rue Viète, 75017 17ème Arrondissement, Paris, France</address><AddressDetails Accuracy="8" xmlns="urn:oasis:names:tc:ciq:xsdschema:xAL:2.0"><Country><CountryNameCode>FR</CountryNameCode><AdministrativeArea><AdministrativeAreaName>Ile-de-France</AdministrativeAreaName><SubAdministrativeArea><SubAdministrativeAreaName>Paris</SubAdministrativeAreaName><Locality><LocalityName>Paris</LocalityName><DependentLocality><DependentLocalityName>17ème Arrondissement</DependentLocalityName><Thoroughfare><ThoroughfareName>3, Rue Viète</ThoroughfareName></Thoroughfare><PostalCode><PostalCodeNumber>75017</PostalCodeNumber></PostalCode></DependentLocality></Locality></SubAdministrativeArea></AdministrativeArea></Country></AddressDetails><Point><coordinates>2.306174,48.883705,0</coordinates></Point></Placemark></Response></kml>*/
|
||||
|
||||
/*
|
||||
0 Unknown location. (Since 2.59)
|
||||
1 Country level accuracy. (Since 2.59)
|
||||
2 Region (state, province, prefecture, etc.) level accuracy. (Since 2.59)
|
||||
3 Sub-region (county, municipality, etc.) level accuracy. (Since 2.59)
|
||||
4 Town (city, village) level accuracy. (Since 2.59)
|
||||
5 Post code (zip code) level accuracy. (Since 2.59)
|
||||
6 Street level accuracy. (Since 2.59)
|
||||
7 Intersection level accuracy. (Since 2.59)
|
||||
8 Address level accuracy. (Since 2.59)
|
||||
*/
|
||||
$this->codeRetourG=@getTextInHtml($this->body, '<Status>', '<code>', '/code>');
|
||||
$this->precision=@getTextInHtml($this->body, '<AddressDetails Accuracy', '="', '" ');
|
||||
|
||||
$this->adresseValidee=strtoupper(str_replace(''', "'", htmlspecialchars_decode(@getTextInHtml($this->body, '<Placemark', '<address>', '</address>'),ENT_QUOTES)));
|
||||
$strTmp=@getTextInHtml($this->body, '<Point><coordinates>', '<coordinates>', '</coordinates>');
|
||||
$tabTmp=explode(',', $strTmp);
|
||||
$this->latitudeDec=@$tabTmp[1];
|
||||
$this->longitudeDec=$tabTmp[0];
|
||||
$this->latitudeDeg=dec2dms($this->latitudeDec);
|
||||
$this->longitudeDeg=dec2dms($this->longitudeDec);
|
||||
|
||||
$this->geocodeur='Google';
|
||||
|
||||
/*
|
||||
200 G_GEO_SUCCESS No errors occurred; the address was successfully parsed and its geocode has been returneds->geocodeur='Google';
|
||||
|
||||
.
|
||||
400 G_GEO_BAD_REQUEST A directions request could not be successfully parsed.
|
||||
500 G_GEO_SERVER_ERROR A geocoding or directions request could not be successfully processed, yet the exact reason for the failure is not known.
|
||||
601 G_GEO_MISSING_QUERY The HTTP q parameter was either missing or had no value. For geocoding requests, this means that an empty address was
|
||||
specified as input. For directions requests, this means that no query was specified in the input.
|
||||
602 G_GEO_UNKNOWN_ADDRESS No corresponding geographic location could be found for the specified address. This may be due to the fact that the address
|
||||
is relatively new, or it may be incorrect.
|
||||
603 G_GEO_UNAVAILABLE_ADDRESS The geocode for the given address or the route for the given directions query cannot be returned due to legal or contractual
|
||||
reasons.
|
||||
604 G_GEO_UNKNOWN_DIRECTIONS The GDirections object could not compute directions between the points mentioned in the query. This is usually because
|
||||
there is no route available between the two points, or because we do not have data for routing in that region.
|
||||
610 G_GEO_BAD_KEY The given key is either invalid or does not match the domain for which it was given.
|
||||
620 G_GEO_TOO_MANY_QUERIES The given key has gone over the requests limit in the 24 hour period.
|
||||
*/
|
||||
if ($this->codeRetourG==200)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
function geoCodeAdresse($adrNum, $adrIndRep, $adrTypeVoieCourt, $adrTypeVoieLong, $adrLibVoie, $cp, $ville='', $pays='France', $codeRivoli='') {
|
||||
$iDb=new WDB();
|
||||
$tabRep=array();
|
||||
$adresse=addslashes(trim(preg_replace('/ +/',' ', "$adrNum $adrIndRep $adrTypeVoieLong $adrLibVoie")));
|
||||
$ville=addslashes($ville);
|
||||
$ret=$iDb->select( 'zonageXY', 'lat, lon, precis, adresseValidee, dateInsert', "address='$adresse' AND adr_cp='$cp' AND adr_ville='$ville'",false, MYSQL_ASSOC);
|
||||
if (count($ret)>0) {
|
||||
$zonage=$ret[0];
|
||||
$this->precision=$zonage['precis']*1;
|
||||
$this->adresseValidee=strtoupper($zonage['adresseValidee']);
|
||||
$this->latitudeDec=$zonage['lat']*1;
|
||||
$this->longitudeDec=$zonage['lon']*1;
|
||||
$this->latitudeDeg=dec2dms($this->latitudeDec);
|
||||
$this->longitudeDeg=dec2dms($this->longitudeDec);
|
||||
$this->enCache=true;
|
||||
$ligne='En base : '.print_r($zonage, true);
|
||||
} else {
|
||||
$this->enCache=false;
|
||||
$retM=$retY=false;
|
||||
if (substr($codeRivoli,0,3)*1==971) $pays='Guadeloupe';
|
||||
elseif (substr($codeRivoli,0,3)*1==972) $pays='Martinique';
|
||||
elseif (substr($codeRivoli,0,3)*1==973) $pays='Guyane';
|
||||
elseif (substr($codeRivoli,0,3)*1==974) $pays='La Réunion';
|
||||
elseif (substr($codeRivoli,0,3)*1==975) $pays='Saint-Pierre-et-Miquelon';
|
||||
elseif (substr($codeRivoli,0,3)*1==976) $pays='Mayotte';
|
||||
elseif (substr($codeRivoli,0,3)*1==977) $pays='Saint-Martin';
|
||||
elseif (substr($codeRivoli,0,3)*1==978) $pays='Saint-Barthélémy';
|
||||
elseif (substr($codeRivoli,0,3)*1==985) $pays='Saint-Pierre-et-Miquelon';//98501 à 98502 St Pierre et Miquelon (anciens codes non compatibles 97501 à 97502)
|
||||
elseif (substr($codeRivoli,0,3)*1==986) $pays='Wallis-et-Futuna'; // 98601 à 98617 Mayotte (anciens codes non compatibles : 98501 à 98517)
|
||||
elseif (substr($codeRivoli,0,3)*1==987) $pays='Polynésie française'; // 98711 à 98758,98799 Polynésie française (sans changement)
|
||||
elseif (substr($codeRivoli,0,3)*1==988) $pays='Nouvelle Calédonie'; // 98801 à 98832 Nouvelle Calédonie (sans changement)
|
||||
elseif (substr($codeRivoli,0,3)*1==989) $pays='Wallis-et-Futuna'; // 98911 à 98913 Wallis et Futuna (anciens codes non compatibles : 98611 à 98613)
|
||||
elseif (substr($codeRivoli,0,2)*1>96 && substr($codeRivoli,0,2)*1<99)
|
||||
die("Code Rivoli non géré : '$codeRivoli'".EOL);
|
||||
|
||||
$retG=$this->geoCodeAdrCpVilleG($adresse, $cp, $ville, $pays);
|
||||
/* if ($this->codeRetourG==620 || $this->precision==0)
|
||||
if ($this->codeRetourG==620)
|
||||
$retY=$this->geoCodeAdrCpVilleY("$adresse, $cp $ville");*/
|
||||
|
||||
if ($this->codeRetourY==620 || $this->codeRetourY==503 || $this->precision==0)
|
||||
$retM=$this->geoCodeAdrCpVilleM($adresse, $cp, $ville, $pays);
|
||||
|
||||
if ($retG || $retY || $retM) {
|
||||
$adresse=stripslashes(strtoupper(trim(preg_replace('/ +/',' ', "$adrNum $adrIndRep $adrTypeVoieLong $adrLibVoie"))));
|
||||
$ville=stripslashes($ville);
|
||||
$tabInsert=array( 'address'=>$adresse,
|
||||
'adr_cp'=>$cp,
|
||||
'adr_ville'=>$ville,
|
||||
'adrNum'=>$adrNum,
|
||||
'adrIndRep'=>$adrIndRep,
|
||||
'adrTypeVoie'=>$adrTypeVoieCourt,
|
||||
'adrLibVoie'=>$adrLibVoie,
|
||||
'rivoli'=>$codeRivoli,
|
||||
'adresseValidee'=>$this->adresseValidee,
|
||||
'lat'=>$this->latitudeDec,
|
||||
'lon'=>$this->longitudeDec,
|
||||
'precis'=>$this->precision,
|
||||
'source'=>$this->geocodeur,
|
||||
'dateInsert'=>DATETIME,
|
||||
);
|
||||
/** Insertion de l'adresse que si elle est possible
|
||||
**/
|
||||
if ($this->latitudeDec<>0 && $this->longitudeDec<>0)
|
||||
$iDb->insert('zonageXY', $tabInsert);
|
||||
|
||||
$ligne='Accès Google : '.print_r($tabInsert, true);
|
||||
}
|
||||
else {
|
||||
$this->precision=$this->latitudeDec=$this->longitudeDec=0;
|
||||
$this->adresseValidee='';
|
||||
$this->latitudeDeg=$this->longitudeDeg='';
|
||||
$ligne="Erreur : $adrNum, $adrIndRep, $adrTypeVoieCourt, $adrTypeVoieLong, $adrLibVoie, $cp, $ville, $pays, $codeRivoli, ".$this->body;
|
||||
}
|
||||
}
|
||||
/*$fp=fopen(LOG_PATH.'/accesGMap.log', 'a');
|
||||
fwrite($fp,$ligne.EOL);
|
||||
fclose($fp);*/
|
||||
}
|
||||
/* if (latnorth == 'S') latdir='-'
|
||||
if (lonwest == 'W') longdir='-'
|
||||
latdec=Math.round(lat1)+lat2/60
|
||||
londec=Math.round(long1)+long2/60
|
||||
gmdatalat=latdir+latdec.toFixed(6)
|
||||
gmdatalon=longdir+londec.toFixed(6)
|
||||
//GM_log( 'Latdec:'+gmdatalat+' LongDec:'+gmdatalon)
|
||||
gmx=gmdatalat*Math.pow(10,6)
|
||||
gmy=gmdatalon*Math.pow(10,6)
|
||||
if (gmx < 0) gmx=gmx+Math.pow(2,32)*/
|
||||
|
||||
|
||||
/** Retourne la distance en kilomètres entre 2 points à la surface de la terre
|
||||
** Calcul effectué avec la sphère « GRS80 » de rayon R = 6378,187 km
|
||||
** Autre sphère possible : « Picard » de rayon R = 6371,598 km
|
||||
**
|
||||
** @param double $latA Latitude du point A en décimal
|
||||
** @param double $lonA Longitude du point A en décimal
|
||||
** @param double $latB Latitude du point B en décimal
|
||||
** @param double $lonB Longitude du point B en décimal
|
||||
** @return unknown
|
||||
**/
|
||||
function distance($latA=0, $lonA=0, $latB=0, $lonB=0) {
|
||||
//s(AB) = arc cos (sinjA sinjB + cos jA cosjB cosdl)
|
||||
// avec dl = lB - lA
|
||||
$a=pi()/180;
|
||||
$e=$latA*$a;
|
||||
$f=$lonA*$a;
|
||||
$g=$latB*$a;
|
||||
$h=$lonB*$a;
|
||||
|
||||
$j=acos(cos($e)*cos($g)*cos($f)*cos($h) + cos($e)*sin($f)*cos($g)*sin($h) + sin($e)*sin($g));
|
||||
|
||||
return round(6378.187*$j,3); // div par 1.852 ==> résultat en miles nautiques
|
||||
}
|
||||
/*function distance(lat_a, lon_a, lat_b, lon_b)
|
||||
{
|
||||
a = Math.PI / 180;
|
||||
lat1 = lat_a * a;
|
||||
lat2 = lat_b * a;
|
||||
lon1 = lon_a * a;
|
||||
lon2 = lon_b * a;
|
||||
|
||||
t1 = Math.sin(lat1) * Math.sin(lat2);
|
||||
t2 = Math.cos(lat1) * Math.cos(lat2);
|
||||
t3 = Math.cos(lon1 - lon2);
|
||||
t4 = t2 * t3;
|
||||
t5 = t1 + t4;
|
||||
rad_dist = Math.atan(-t5/Math.sqrt(-t5 * t5 +1)) + 2 * Math.atan(1);
|
||||
|
||||
return (rad_dist * 3437.74677 * 1.1508) * 1.6093470878864446;
|
||||
}
|
||||
*/
|
||||
|
||||
}
|
||||
if ( !function_exists('json_decode') ){
|
||||
function json_decode($content, $assoc=false){
|
||||
require_once 'Services/JSON.php';
|
||||
if ( $assoc ){
|
||||
$json = new Services_JSON(SERVICES_JSON_LOOSE_TYPE);
|
||||
} else {
|
||||
$json = new Services_JSON;
|
||||
}
|
||||
return $json->decode($content);
|
||||
}
|
||||
}
|
||||
|
||||
if ( !function_exists('json_encode') ){
|
||||
function json_encode($content){
|
||||
require_once 'Services/JSON.php';
|
||||
$json = new Services_JSON;
|
||||
|
||||
return $json->encode($content);
|
||||
}
|
||||
}
|
||||
?>
|
112
library/Metier/partenaires/classMMapi_bing.php
Normal file
112
library/Metier/partenaires/classMMapi_bing.php
Normal file
@ -0,0 +1,112 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>Imagery Service example in PHP (with Geocode)</title>
|
||||
</head>
|
||||
<body>
|
||||
This example currently accesses the staging environment only. Username, password, and address are required.<br>
|
||||
In order to run this example, the php_soap extension must be enabled. This was built and tested using PHP 5.3.0.<br><br>
|
||||
<form action="imageryservicesample.php" method="post">
|
||||
Username: <input type="text" name="username" value="<?php echo (isset($_POST['username'])?$_POST['username']:'') ?>">
|
||||
Password: <input type="text" name="password" value="<?php echo (isset($_POST['password'])?$_POST['password']:'') ?>"><br>
|
||||
Address: <input type="text" name="address" value="<?php echo (isset($_POST['address'])?$_POST['address']:'') ?>"><br>
|
||||
Zoom: <input type="text" name="zoomlevel" value="<?php echo (isset($_POST['zoomlevel'])?$_POST['zoomlevel']:'') ?>"><br>
|
||||
<input type="submit" value="Submit">
|
||||
</form>
|
||||
<?php
|
||||
if(isset($_POST['username']) && isset($_POST['password']))
|
||||
{
|
||||
$UserName = $_POST['username'];
|
||||
$Password = $_POST['password'];
|
||||
|
||||
// Url to the token service wsdl (for now it's a local file)
|
||||
$TokenServiceWsdl = "tokenreference.wsdl";
|
||||
|
||||
// Create the service client object
|
||||
//trace allows us to see last response and request for debugging
|
||||
$tokenClient = new SoapClient($TokenServiceWsdl, array('login' => $UserName, 'password' => $Password, 'trace' => true));
|
||||
|
||||
// TokenSpecification "object"
|
||||
$tokenSpec = array(
|
||||
'ClientIPAddress' => '0.0.0.0',
|
||||
'TokenValidityDurationMinutes' => '60'
|
||||
);
|
||||
|
||||
try {
|
||||
// Get the client token
|
||||
$tokenResponse = $tokenClient->GetClientToken(array('specification' => $tokenSpec));
|
||||
}
|
||||
catch(SoapFault $e)
|
||||
{
|
||||
die('Fault occurred using Web Service: '.$e->getMessage());//.print_r($res,true));
|
||||
}
|
||||
|
||||
// Get the token from the response object
|
||||
$token = $tokenResponse->GetClientTokenResult;
|
||||
|
||||
// URLs to the Imagery and Geocode services
|
||||
$imageryServiceWsdl = 'imageryservice.wsdl';
|
||||
$geocodeServiceWsdl = 'geocodeservice.wsdl';
|
||||
|
||||
// Credentials "object"
|
||||
$credentials = array('Token' => $token);
|
||||
|
||||
// Create the geocode service and imagery service clients
|
||||
$geocodeClient = new SoapClient($geocodeServiceWsdl, array('trace' => 1));
|
||||
$imageryClient = new SoapClient($imageryServiceWsdl, array('trace' => 1));
|
||||
|
||||
// GeocodeRequest "object"
|
||||
$geocodeRequest = array(
|
||||
'Credentials' => $credentials,
|
||||
'Query' => $_POST['address']
|
||||
);
|
||||
|
||||
try {
|
||||
if(isset($_POST['address']))
|
||||
$geocodeResponse = $geocodeClient->Geocode(array('request' => $geocodeRequest));
|
||||
}
|
||||
catch(SoapFault $e)
|
||||
{
|
||||
die('Fault occurred using Web Service: '.$e->getMessage());
|
||||
}
|
||||
|
||||
// Retrieve the latitude and longitude from the response object
|
||||
$lat = $geocodeResponse->GeocodeResult->Results->GeocodeResult->Locations->GeocodeLocation->Latitude;
|
||||
$lon = $geocodeResponse->GeocodeResult->Results->GeocodeResult->Locations->GeocodeLocation->Longitude;
|
||||
|
||||
// Location "object"
|
||||
$location = array(
|
||||
'Latitude' => $lat,
|
||||
'Longitude' => $lon
|
||||
);
|
||||
|
||||
if($_POST['zoomlevel'] == '')
|
||||
$_POST['zoomlevel'] = null;
|
||||
|
||||
// MapUriOptions "object"
|
||||
$options = array(
|
||||
'ZoomLevel' => $_POST['zoomlevel']
|
||||
);
|
||||
|
||||
// MapUriRequest "object"
|
||||
$mapUriRequest = array(
|
||||
'Credentials' => $credentials,
|
||||
'Center' => $location,
|
||||
'Options' => $options
|
||||
);
|
||||
|
||||
try {
|
||||
// GetMapUri method call
|
||||
$mapUriResponse = $imageryClient->GetMapUri(array('request' => $mapUriRequest));
|
||||
}
|
||||
catch(SoapFault $e)
|
||||
{
|
||||
die('Fault occurred using Web Service: '.$e->getMessage());
|
||||
}
|
||||
|
||||
// Display the URI and lat/lon returned from the service call
|
||||
echo '<img src="' . $mapUriResponse->GetMapUriResult->Uri . '"><br>';
|
||||
echo 'Latitude: '.$lat.' Longitude: '.$lon;
|
||||
}
|
||||
?>
|
||||
</body>
|
||||
</html>
|
1808
library/Metier/partenaires/classMMarques.php
Normal file
1808
library/Metier/partenaires/classMMarques.php
Normal file
File diff suppressed because it is too large
Load Diff
283
library/Metier/partenaires/classMOrias.php
Normal file
283
library/Metier/partenaires/classMOrias.php
Normal file
@ -0,0 +1,283 @@
|
||||
<?
|
||||
|
||||
class MOrias {
|
||||
|
||||
private $referer ='';
|
||||
private $body = '';
|
||||
private $header = '';
|
||||
private $cookie = '';
|
||||
private $codeRetour = 0;
|
||||
private $accesDist=true;
|
||||
private $iDb;
|
||||
|
||||
public $enCache=false;
|
||||
public $force=false;
|
||||
public $annee=0;
|
||||
public $erreur='';
|
||||
|
||||
function __construct($accesDist=true) {// $adresse, $cp, $ville, $pays='France') {
|
||||
$this->accesDist=$accesDist;
|
||||
$this->iDb=new WDb('sdv1');
|
||||
}
|
||||
|
||||
public function getMaxOrias($annee=0) {
|
||||
if ($annee*1>0 && $annee*1<100) {
|
||||
$this->annee='20'.$annee;
|
||||
$annee++;
|
||||
$strWhere="(numOrias/1000000)<=$annee";
|
||||
} elseif ($annee*1>1900 && $annee*1<9999) {
|
||||
$this->annee=$annee;
|
||||
$annee=substr(''.$annee,2,2)*1+1;
|
||||
$strWhere="(numOrias/1000000)<=$annee";
|
||||
} else {
|
||||
$strWhere='1';
|
||||
$this->annee=date('Y')*1;
|
||||
}
|
||||
|
||||
$ret=$this->iDb->select('orias','MAX(numOrias) AS numOrias', $strWhere, false, MYSQL_ASSOC);
|
||||
//die($strWhere);
|
||||
return sprintf('%08d',$ret[0]['numOrias']);
|
||||
}
|
||||
|
||||
public function getInfosOrias($siren, $numOrias=0) {
|
||||
//die('numOrias 1:"'.$numOrias.'"');
|
||||
if ($siren*1>1000)
|
||||
$strWhere="siren=$siren";
|
||||
elseif ($numOrias*1>0) {
|
||||
// $numOrias=preg_replace('/[^0-9]/','',$numOrias);
|
||||
// $numOrias=substr($numOrias,0,2).' '.substr($numOrias,2,3).' '.substr($numOrias,5,3);
|
||||
$strWhere="numOrias=$numOrias";
|
||||
// die($strWhere);
|
||||
//die('numOrias 2:"'.$numOrias.'"');
|
||||
} else return false;
|
||||
|
||||
/* echo "=================================================================================================".EOL;
|
||||
echo "==== SELECT siren, id, nom, cp, ville, adresse, numOrias FROM orias WHERE $strWhere;".EOL;
|
||||
echo "=================================================================================================".EOL;
|
||||
*/
|
||||
$ret=$this->iDb->select('orias','siren, id, nom, cp, ville, adresse, numOrias, numOriasAttribue', $strWhere, false, MYSQL_ASSOC);
|
||||
if (!$this->force && count($ret)>0) {
|
||||
$this->enCache=true;
|
||||
$tabRet=$ret[0];//array();
|
||||
$ret=$this->iDb->select('orias','categorie, cat, dateInscription, typeStatut, rcsVille, rcsCode, rcsSiren, contact, encaissement, nature, paysPresta, paysEtab',$strWhere, false, MYSQL_ASSOC);
|
||||
foreach ($ret as $i=>$tabTmp)
|
||||
$tabRet['categories'][]=$tabTmp;
|
||||
//die('numOrias 3:"'.$numOrias.'"');
|
||||
} elseif ($this->accesDist==true) {
|
||||
$this->enCache=false;
|
||||
|
||||
// Initialisation Cookies
|
||||
if ($numOrias>0) $this->referer='http://www.orias.fr/orias/public/index.jsp';
|
||||
else $this->referer='http://www.orias.fr/orias/public/rechercheavance.html';
|
||||
$page=getUrl($this->referer, '', '', '', false, '', '', 15);
|
||||
//print_r($page);
|
||||
if ($page['code']==200) {
|
||||
$this->cookie=str_replace(' Path=/orias', '',$page['header']['Set-Cookie']);
|
||||
if(preg_match('/id="javax\.faces\.ViewState" value="(.*)"/Ui', $page['body'], $matches))
|
||||
$this->codeRetour=$matches[1];
|
||||
else {
|
||||
echo 'Erreur Url='.$this->referer.EOL;
|
||||
print_r($page['body']);
|
||||
return false;
|
||||
}
|
||||
} else return false;
|
||||
|
||||
if ($numOrias>0) {
|
||||
$url='http://www.orias.fr/orias/public/index.html';
|
||||
$post=array('menu%3AiasSearchForm'=>'menu%3AiasSearchForm',
|
||||
'menu%3AiasSearchForm%3AiasInputText'=>sprintf('%08s',$numOrias),
|
||||
'javax.faces.ViewState'=>$this->codeRetour,
|
||||
'menu%3AiasSearchForm%3AiasSearch'=>'menu%3AiasSearchForm%3AiasSearch',
|
||||
);
|
||||
} else {
|
||||
// Recherche avec Siren
|
||||
$url='http://www.orias.fr/orias/public/rechercheavance.html';
|
||||
$post=array('j_id_id45'=>'j_id_id45',
|
||||
'j_id_id45%3Aj_id_id52'=>'',
|
||||
'j_id_id45%3AtagRCS'=>'',
|
||||
'j_id_id45%3AtagSIREN'=>$siren,//441921574,
|
||||
'j_id_id45%3Aj_id_id160'=>'',
|
||||
'j_id_id45%3Aj_id_id167'=>'',
|
||||
'j_id_id45%3Aj_id_id175'=>'',
|
||||
'javax.faces.ViewState'=>$this->codeRetour,
|
||||
'j_id_id45%3Aj_id_id203'=>'j_id_id45%3Aj_id_id203');
|
||||
$this->referer='http://www.orias.fr/orias/public/list.html';
|
||||
}
|
||||
randsleep(1,2);
|
||||
$page=getUrl($url, $this->cookie, $post, $this->referer, false, '', '', 15);
|
||||
$this->referer=$url;
|
||||
if ($page['code']==302) $url=$page['header']['Location'];
|
||||
else {
|
||||
if (preg_match("/Le numéro d'immatriculation n'existe pas/", $page['body'])) {
|
||||
$tabInsert=array( 'actif'=>0,
|
||||
'numOrias'=>$numOrias,
|
||||
'numOriasAttribue'=>0,
|
||||
'dateInsert'=>date('YmdHis'));
|
||||
$this->erreur='Numéro Orias inexistant';
|
||||
// On enregistre ce numéro comme non attribué si < au dernier numéro attribué
|
||||
if ($numOrias<$this->getMaxOrias())
|
||||
$this->iDb->insert('orias', $tabInsert);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($url=='http://www.orias.fr/orias/public/intermediaire.html') {
|
||||
$page=getUrl($url, $this->cookie, '', $this->referer, false, '', '', 24);
|
||||
$this->referer=$url;
|
||||
$this->body=$page['body'];
|
||||
echo "Recherche par Orias : url=$url".EOL;
|
||||
die(print_r($page));
|
||||
} /* else { */
|
||||
|
||||
// Liste contenant l'entreprise
|
||||
$url='http://www.orias.fr/orias/public/list.html';
|
||||
randsleep(1,2);
|
||||
$page=getUrl($url, $this->cookie, '', $this->referer, false, '', '', 24);
|
||||
$this->referer=$url;
|
||||
$this->body=$page['body'];
|
||||
|
||||
if (preg_match('/<td>R\é\;sultat\(s\) de votre recherche \:(?:.*)<strong>(.*)<(?:.*)Interm\é\;diaire\(s\)/Uis',$this->body, $matches)) {
|
||||
$nbInter=trim($matches[1])*1;
|
||||
if ($nbInter==0) return false;
|
||||
if ($nbInter>1) {
|
||||
@sendMail('production@scores-decisions.com', 'ylenaour@scores-decisions.com', "classMOrias::getInfosOrias sur $siren", "Plus de 1 intermédiaire recensé... Merci de gérer le cas !");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Initalisation du tableau retour
|
||||
$tabRet=array('siren'=>$siren);
|
||||
|
||||
//id="formResult:intermediariesList:13910
|
||||
|
||||
if (preg_match('/<td class="dr-table-cell rich-table-cell haut " id="formResult\:intermediariesList\:(.*)\:j_id_id117">(?:.*)<center>(.*)<\/center>/Uis',$this->body, $matches)) {
|
||||
$tabRet['id']=trim($matches[1]);
|
||||
$tabRet['nom']=html_entity_decode(trim($matches[2]));
|
||||
}
|
||||
if (preg_match('/<td class="dr-table-cell rich-table-cell r.cp_ville " id="formResult\:intermediariesList\:(?:.*)\:j_id_id124">(?:.*)<center>(.*)<\/center>/Uis',$this->body, $matches)) {
|
||||
$tabTmp=explode(' ',$matches[1]);
|
||||
$tabRet['cp']=trim($tabTmp[0]);
|
||||
$tabRet['ville']=html_entity_decode(trim($tabTmp[1]));
|
||||
//$tabRet['cpVille']=explotrim(str_replace(' ',' ',$matches[1]));
|
||||
}
|
||||
if (preg_match('/<td class="dr-table-cell rich-table-cell r.adresse " id="formResult\:intermediariesList\:(?:.*)\:j_id_id133">(.*)<\/td>/Uis',$this->body, $matches))
|
||||
$tabRet['adresse']=html_entity_decode(trim($matches[1]));
|
||||
|
||||
$tabRet['actif']=1;
|
||||
$tabRet['numOriasAttribue']=1;
|
||||
if (preg_match('/<td class="dr-table-cell rich-table-cell r.immat " id="formResult\:intermediariesList\:(?:.*)\:j_id_id138">(?:.*|)(<span style="white-space\: no-wrap;">|Radi\é\; le \:)(.*)(?:<\/span>|<\/td>)/Uis',$this->body, $matches)) {
|
||||
$str=trim(strtr($matches[2],array(' '=>'',' '=>'')));
|
||||
if (html_entity_decode(trim(str_replace(':','', $matches[1])))=='Radié le') {
|
||||
$tabRet['actif']=0;
|
||||
$tabRet['numOrias']=$numOrias;
|
||||
$tabRet['dateRadiation']=$str;
|
||||
}
|
||||
else
|
||||
$tabRet['numOrias']=$str;
|
||||
}
|
||||
|
||||
if (preg_match('/ id="javax\.faces\.ViewState" value="(.*)" /Uis',$this->body, $matches))
|
||||
$this->codeRetour=$matches[1];
|
||||
|
||||
$tabTmp=explode("<a href=\"#\" onclick=\"if(typeof jsfcljs == 'function'){jsfcljs(document.getElementById('formResult'),{'", $this->body);
|
||||
// die($this->body);
|
||||
|
||||
foreach ($tabTmp as $i=>$strCat) {
|
||||
if ($i==0) {
|
||||
if (count($tabTmp)==1) {
|
||||
$tabInsert=array_merge($tabRet, array('dateInsert'=>date('YmdHis')));
|
||||
//print_r($tabInsert);
|
||||
$this->iDb->insert('orias', $tabInsert);
|
||||
}
|
||||
$tabRet['categories']=array();
|
||||
continue;
|
||||
}
|
||||
$tabCat=array();
|
||||
//echo "$i:$strCat";
|
||||
//die();
|
||||
//:formResult:intermediariesList:107501:j_id_id159:0:j_id_id166':'formResult:intermediariesList:107501:j_id_id159:0:j_id_id166','intermediaryIdParam':'107501','intermediaryRoleIdParam':'Mia'},'');}return false">
|
||||
|
||||
if (preg_match('/<span style="text-align\: left">(.*)<\/span>/Ui',$strCat, $matches))
|
||||
$tabCat['categorie']=html_entity_decode(trim($matches[1]));
|
||||
if (preg_match('/intermediaryRoleIdParam\'\:\'(.*)\'/Uis',$strCat, $matches))
|
||||
$tabCat['cat']=$matches[1];
|
||||
//print_r($tabCat);
|
||||
|
||||
if ($i==1) { // Tout est dans la même page Html
|
||||
// Construction du lien vers la fiche d'identité de l'entreprise
|
||||
$url='http://www.orias.fr/orias/public/list.html';
|
||||
$post=array('formResult'=>'formResult',
|
||||
'formResult%3AajaxLoadingModalBoxOpenedState'=>'',
|
||||
'javax.faces.ViewState'=>$this->codeRetour,
|
||||
'intermediaryIdParam'=>$tabRet['id'],
|
||||
'intermediaryRoleIdParam'=>$tabCat['cat'],
|
||||
);
|
||||
if (preg_match('/(formResult\:intermediariesList\:(?:.*)),intermediaryIdParam,/Ui',$strCat, $matches)) {
|
||||
$tabTmp2=explode(',', $matches[1]);
|
||||
$post[urlencode($tabTmp2[0])]=urlencode($tabTmp2[1]);
|
||||
/* echo "$i";
|
||||
print_r($tabCat);
|
||||
print_r($matches);*/
|
||||
}
|
||||
randsleep(1,2);
|
||||
$page=getUrl($url, $this->cookie, $post, $this->referer, false, '', '', 24);
|
||||
//$this->referer=$url;
|
||||
$tmpCat=explode('class="dr-tbpnl-cntnt-pstn rich-tabpanel-content-position"', $page['body']);
|
||||
//die(print_r($page,1));
|
||||
}
|
||||
|
||||
if (preg_match('/<dd class="col3">Date d\'inscription \: <strong>(.*)<\/strong><\/dd>/Uis',$tmpCat[$i], $matches))
|
||||
$tabCat['dateInscription']=/*Wdate::dateT('d/m/y', 'Y-m-d', */trim($matches[1]);//);
|
||||
if (preg_match('/<td align="right"(?: |)>Statut \:<\/td>(.*)<\/strong>/Uis',$tmpCat[$i], $matches))
|
||||
$tabCat['typeStatut']=trim(strip_tags($matches[1]));
|
||||
if (preg_match('/<td align="right">RCS \:<\/td>(?:.*)<td width="5%"><\/td>(?:.*)<td width="70%"><strong>(.*)<\/strong>(.*)SIREN \:(?:.*)<strong>(.*)<\/strong>/Uis',$tmpCat[$i], $matches)) {
|
||||
$tabCat['rcsVille']=trim($matches[1]);
|
||||
$tabCat['rcsCode']=trim(strtr(strip_tags($matches[2]), array(' '=>'',' '=>'',chr(160)=>'',"\r"=>'',"\n"=>'')));
|
||||
$tabCat['rcsSiren']=trim($matches[3]);
|
||||
if ($siren==0) $tabRet['siren']=$tabCat['rcsSiren'];
|
||||
}
|
||||
/*<td align="right">Contact</td>
|
||||
<td></td>
|
||||
<td><strong> François Meunier
|
||||
</strong></td>
|
||||
*/
|
||||
if (preg_match('/<td align="right">Contact<\/td>(.*)<\/tr>/Uis',$tmpCat[$i], $matches)) {
|
||||
$tabCat['contact']=html_entity_decode(trim(strip_tags($matches[1])));
|
||||
/* <td></td>
|
||||
<td>
|
||||
<strong>
|
||||
JEAN-PIERRE CHAUSSAT
|
||||
</strong>
|
||||
</td>
|
||||
</table>*/
|
||||
}
|
||||
//print_r($tmpCat[$i]);
|
||||
if (preg_match("/<strong>(.*)Cet intermédiaire n'est pas autorisé à encaisser les primes ou cotisations d'assurances(.*)<\/strong>/Uis", $tmpCat[$i]))
|
||||
$tabCat['encaissement']=0;
|
||||
else
|
||||
$tabCat['encaissement']=1;
|
||||
|
||||
if (preg_match('/<span class="txt_ssTitre">(?:.*)Nature de l\'activit\é\; d\'interm\é\;diation(.*)<\/dd>/Uis',$tmpCat[$i], $matches))
|
||||
$tabCat['nature']=html_entity_decode(trim(strip_tags($matches[1])));
|
||||
|
||||
if (preg_match('/<td width="50%" valign="top" align="left">\- Etats dans lesquels cet interm\é\;diaire exerce en libre prestation de service(.*)<\/table>(.*)<\/tr>/Uis',$tmpCat[$i], $matches))
|
||||
$tabCat['paysPresta']=trim(strip_tags($matches[1]));
|
||||
|
||||
if (preg_match('/<td width="222" align="left">\- Etats dans lesquels cet interm\é\;diaire exerce en libert\é\; d\'\é\;tablissement(.*)<\/table>(.*)<\/tr>/Uis',$tmpCat[$i], $matches))
|
||||
$tabCat['paysEtab']=trim(strip_tags($matches[1]));
|
||||
|
||||
$tabRet['categories'][]=$tabCat;
|
||||
|
||||
$tabInsert=$tabRet;
|
||||
unset($tabInsert['categories']);
|
||||
$tabInsert=array_merge($tabInsert, $tabCat, array('dateInsert'=>date('YmdHis')));
|
||||
//print_r($tabInsert);
|
||||
$this->iDb->insert('orias', $tabInsert);
|
||||
//echo $tmpCat[$i];
|
||||
}
|
||||
}
|
||||
return $tabRet;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
154
library/Metier/partenaires/classMPrivileges.php
Normal file
154
library/Metier/partenaires/classMPrivileges.php
Normal file
@ -0,0 +1,154 @@
|
||||
<?
|
||||
|
||||
class MPrivileges {
|
||||
|
||||
private $iDb;
|
||||
public $tabCodeAR=array(
|
||||
'00'=>"Surveillance RCS posée/Demande de suppression acceptée/Surveillance PRIV posée : pas d'inscription existante sur le dossier",
|
||||
'01'=>"Surveillance PRIV posée : inscription existante sur le dossier",
|
||||
'02'=>"GAGI,GREFTEL,INTERGREFFE-code 1-surveillance acceptée mais qui n'a pas encore fait l'objet d'un AR",
|
||||
'03'=>"GAGI,GREFTEL,INTERGREFFE-code 2 - surveillance acceptée avec CREATION d'une fiche débiteur, qui n'a pas fait l'objet d'un AR",
|
||||
'04'=>"GAGI-surveillance en attente envoyée au GAGI",
|
||||
'05'=>"Surveillance en attente de validation au greffe",
|
||||
'06'=>"Erreur de chargement",
|
||||
'10'=>"Surveillance impossible car société radiée",
|
||||
'11'=>"Surveillance impossible car société transférée dans un autre greffe",
|
||||
'12'=>"SIREN inconnu",
|
||||
'13'=>"Raison sociale erronée",
|
||||
'14'=>"Adresse erronée",
|
||||
'15'=>"Surveillance impossible sur un établissement secondaire",
|
||||
'16'=>"Demande incomplète ou incorrecte",
|
||||
'17'=>"Surveillance Privilège impossible",
|
||||
'18'=>"Surveillance impossible par le greffe",
|
||||
'19'=>"Surveillance RCS impossible",
|
||||
'20'=>"Cette surveillance concerne un autre Greffe",
|
||||
'21'=>"Surveillance BILAN impossible car la ste n'est pas tenue de déposer ses Comptes Annuels (ste de droit étranger)",
|
||||
'22'=>"Plusieurs Bottins (débiteurs) (GAGI)",
|
||||
'23'=>"Société de fait (GAGI) : Société non enregistrée au Registre du Commerce",
|
||||
'24'=>"Surveillance impossible car société en liquidation judiciaire",
|
||||
'25'=>"Greffe inconnu",
|
||||
'26'=>"Millésime bilan à surveiller incorrect",
|
||||
'27'=>"Références EXTELIA erronées ou incomplètes (ces reférences sont obligatoires en cas de demande de suppression)",
|
||||
'28'=>"Surveillance impossible sur un dossier non informatisé (dossier dit non repris ou figé)",
|
||||
'30'=>"Siren absent (ne concerne que les surveillances de type WebService)",
|
||||
'31'=>"Surveillance BILAN impossible sur une société non commerciale (statut <> B)",
|
||||
'50'=>"Ce greffe ne traite pas les surveillances car le groupement de ce greffe n'est pas surveillé",
|
||||
'51'=>"Etablissement non trouvé",
|
||||
'52'=>"Code catalogue de la surveillance non renseigné ou incorrect",
|
||||
'53'=>"le siren est déjà sous surveillance",
|
||||
'54'=>"DOSSIER AGORA : votre prestation ne comprend pas la couverture de ce groupement",
|
||||
'55'=>"DOSSIER INTERGREFFE : votre prestation ne comprend pas la couverture de ce groupement de greffes",
|
||||
'56'=>"Le siren est déjà en attente de validation par le greffe",
|
||||
'57'=>"Surveillance impossible sur un dossier dit non inscrit au RCS (statut F:artisan)",
|
||||
'58'=>"Surveillance impossible sur un agent commercial (statut P ou M)",
|
||||
'88'=>"Rejet temporaire : surveillance sur un greffe absorbé rejetée pendant la phase de rechargement",
|
||||
'99'=>"Surveillance impossible pour raisons à examiner",
|
||||
);
|
||||
|
||||
public $tabTypePriv=array(
|
||||
'01'=>"NANTISSEMENTS DU FONDS DE COMMERCE",
|
||||
'02'=>"PRIVILEGES DE VENDEUR ET ACTION RESOLUTOIRE",
|
||||
'03'=>"PRIVILEGES DE LA SECURITE SOCIALE ET DES REGIMES COMPLEMENTAIRES",
|
||||
'04'=>"PRIVILEGES DU TRESOR PUBLIC",
|
||||
'05'=>"OPERATIONS DE CREDIT-BAIL EN MATIERE MOBILIERE",
|
||||
'06'=>"PROTETS",
|
||||
'07'=>"NANTISSEMENTS DE L'OUTILLAGE, MATERIEL ET EQUIPEMENT",
|
||||
'08'=>"WARRANTS (HOTELIER, PETROLIER, INDUSTRIEL OU AGRICOLE)",
|
||||
'10'=>"NANTISSEMENTS DE PARTS DE SOCIETE CIVILE",
|
||||
'17'=>"PUBLICITES DE CONTRATS DE LOCATION",
|
||||
'18'=>"PUBLICITES DE CLAUSES DE RESERVE DE PROPRIETE",
|
||||
'19'=>"PRETS ET DELAIS",
|
||||
'20'=>"DECLARATIONS DE CREANCES",
|
||||
'21'=>"NANTISSEMENTS JUDICIAIRES",
|
||||
'23'=>"BIENS INALIENABLES",
|
||||
'24'=>"HYPOTHEQUES FLUVIALES",
|
||||
'25'=>"NANTISSEMENTS DU FONDS ARTISANAL",
|
||||
'27'=>"GAGE SANS DEPOSSESSION",
|
||||
'28'=>"GAGE DES STOCKS",
|
||||
);
|
||||
|
||||
function __construct() {
|
||||
$this->iDb=new WDB();
|
||||
}
|
||||
|
||||
function getPrivilegesDetail($siren, $tabTypes=array('03','04')) {
|
||||
|
||||
$strTypes=implode("','", $tabTypes);
|
||||
if ($strTypes<>'') $strTypes=" AND i.insType IN ('$strTypes') ";
|
||||
$fields="i.id, i.dateEven, i.greffe , i.numDebiteur, i.sirenage, i.typeEven, i.dateFraiche, i.codeRev , i.debRaisonSociale , i.debSigle , i.debCiv , i.debNom , i.debPrenom , i.debConjoint , i.debUsage , i.debEnseigne , i.debActivite , i.debFj , i.debFjLib , i.debResidence , i.debNumVoie , i.debTypVoie , i.debLibVoie , i.debAdrComp , i.debCP , i.debVille , i.debPays , i.insType , i.insLib , i.insNum , i.insDate , i.insObjet , i.insMontant , i.insDev , i.insDateEch , i.insDateFin , i.insNanTx , i.insNanTitre , i.insNanOppo , i.insProNat , i.insProHui , i.insProRep , i.insNSCA , i.insNSCParts , i.insNSCSigni , i.creNom , i.creNumVoi, i.creTypVoi, i.creLibVoi, i.creAdrComp1, i.creAdrComp2, i.creCP, i.creVille, i.crePays, i.creAutres, i.radDate, i.radMention, i.radPartiel, i.radPartMt, i.radDev, i.radDiv, i.idFichier, i.dateInsert";
|
||||
$where ="i.siren=$siren $strTypes AND ( (i.insType='03' AND DATEDIFF(NOW(),i.insDate)<=900) /** Durée de vie PRIV Sécu **/ OR (i.insType='04' AND DATEDIFF(NOW(),i.insDate)<=1460) /** Durée de vie PRIV Trésor **/ )";
|
||||
$where.=" ORDER BY i.dateFraiche DESC, i.insType ASC, i.insDate ASC;";
|
||||
$tables="greffes_privileges i";
|
||||
|
||||
$iRncs=new MRncs();
|
||||
$tabRet=array();
|
||||
$tabPriv=$this->iDb->select($tables, $fields, $where, true, MYSQL_ASSOC);
|
||||
foreach ($tabPriv as $i=>$priv) {
|
||||
if ($i>0 && $priv['dateFraiche']<>$dateFraiche) break;
|
||||
$tabRet[]=array(
|
||||
'numDebiteur' =>$priv['numDebiteur'],
|
||||
'greffe' =>$priv['greffe'],
|
||||
'greffeLib' =>$iRncs->getLibTribunal($priv['greffe']),
|
||||
'dateEven' =>$priv['dateEven'],
|
||||
'dateFraiche' =>$priv['dateFraiche'],
|
||||
'dateSD' =>$priv['dateInsert'],
|
||||
'insType' =>$priv['insType'],
|
||||
'insTypeLib' =>prepareString($this->tabTypePriv[$priv['insType']]),
|
||||
'insNum' =>$priv['insNum'],
|
||||
'insDate' =>$priv['insDate'],
|
||||
'insDateEch' =>$priv['insDateEch'],
|
||||
'insObjet' =>prepareString($priv['insObjet']),
|
||||
'insMontant' =>$priv['insMontant'],
|
||||
'insDev' =>$priv['insDev'],
|
||||
'insDateFin' =>$priv['insDateFin'],
|
||||
'radDate' =>$priv['radDate'],
|
||||
'radMention' =>$priv['radMention'],
|
||||
'radPartiel' =>prepareString($priv['radPartiel']),
|
||||
'radPartMt' =>$priv['radPartMt'],
|
||||
'radDev' =>$priv['radDev'],
|
||||
'creNom' =>prepareString($priv['creNom']),
|
||||
'creAdresse1' =>prepareString(trim(preg_replace('/ +/', ' ', $priv['creNumVoi'].' '.$priv['creTypVoi'].' '.$priv['creLibVoi']))),
|
||||
'creAdresse2' =>prepareString($priv['creAdrComp1']),
|
||||
'creAdresse3' =>prepareString($priv['creAdrComp2']),
|
||||
'creCP' =>$priv['creCP'],
|
||||
'creVille' =>prepareString($priv['creVille']),
|
||||
'crePays' =>prepareString($priv['crePays']),
|
||||
'creAutres' =>prepareString($priv['creAutres']),
|
||||
);
|
||||
/* debRaisonSociale , debSigle, debEnseigne
|
||||
debCiv, debNom, debPrenom , debConjoint, debUsage,
|
||||
debActivite , debFj, debFjLib
|
||||
debResidence, debNumVoie, debTypVoie, debLibVoie
|
||||
debAdrComp , debCP, debVille, debPays
|
||||
|
||||
insNanTx, insNanTitre, insNanOppo,
|
||||
insProNat, insProHui, insProRep , insNSCA, insNSCParts, insNSCSigni
|
||||
*/
|
||||
$dateFraiche=$priv['dateFraiche'];
|
||||
}
|
||||
return $tabRet;
|
||||
}
|
||||
|
||||
function getPrivilegesCumul($siren, $tabTypes=array('03','04')) {
|
||||
$iRncs=new MRncs();
|
||||
$tabRet=array();
|
||||
$tabTmp=$this->getPrivilegesDetail($siren, $tabTypes);
|
||||
foreach($tabTmp as $i=>$priv) {
|
||||
@$tabRet[$priv['insType']]['nb']++;
|
||||
$tabRet[$priv['insType']]['insTypeLib'] =$priv['insTypeLib'];
|
||||
$tabRet[$priv['insType']]['dateFraiche']=$priv['dateFraiche'];
|
||||
$tabRet[$priv['insType']]['dateDerInsc']=$priv['insDate'];
|
||||
$tabRet[$priv['insType']]['nomDerCre'] =$priv['creNom'];
|
||||
$tabRet[$priv['insType']]['numDebiteur']=$priv['numDebiteur'];
|
||||
$tabRet[$priv['insType']]['greffeLib'] =$iRncs->getLibTribunal($priv['greffe']);
|
||||
$tabRet[$priv['insType']]['dateMajSD'] =$priv['dateSD'];
|
||||
@$tabRet[$priv['insType']]['insCumul']+=$priv['insMontant'];
|
||||
}
|
||||
|
||||
|
||||
|
||||
return $tabRet;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
343
library/Metier/partenaires/classMQualibat.php
Normal file
343
library/Metier/partenaires/classMQualibat.php
Normal file
@ -0,0 +1,343 @@
|
||||
<?
|
||||
|
||||
class MQualibat {
|
||||
|
||||
private $referer ='';
|
||||
private $body = '';
|
||||
private $header = '';
|
||||
private $cookie = '';
|
||||
private $codeRetour = 0;
|
||||
private $accesDist=true;
|
||||
private $iDb;
|
||||
private $iBodacc;
|
||||
private $iInsee;
|
||||
|
||||
public $enCache=false;
|
||||
public $force=false;
|
||||
public $annee=0;
|
||||
|
||||
function __construct($accesDist=true) {// $adresse, $cp, $ville, $pays='France') {
|
||||
$this->accesDist=$accesDist;
|
||||
$this->iDb=new WDb('sdv1');
|
||||
$this->iBodacc=new MBodacc();
|
||||
$this->$iInsee=new MInsee();
|
||||
}
|
||||
|
||||
private function getCodeFctDirigeant($strLibDirigeant, $siren=0) {
|
||||
$tabTmp=$this->iBodacc->getDirigeants($strLibDirigeant);
|
||||
if (isset($tabTmp[0]['fonction']) && $tabTmp[0]['fonction']>0)
|
||||
return $tabTmp[0]['fonction'];
|
||||
else {
|
||||
if (preg_match("/directeur.{1,6}agence/i")) return 8;
|
||||
elseif (preg_match("/directeur.{1,6}ETABLISSEMENT/i")) return 8;
|
||||
elseif (preg_match("/directeur.{1,6}technique/i")) return 19;
|
||||
elseif (preg_match("/chef.{1,8}agence/i")) return 38;
|
||||
elseif (preg_match("/cadre.{1,8}Comptable/i")) return 55;
|
||||
elseif (preg_match("/Charg.{1,6}affair/i")) return 60;
|
||||
elseif (preg_match("/chef.{1,8}Atelier/i")) return 60;
|
||||
elseif (preg_match("/(conducteur|chef).{1,9}travaux/i")) return 61;
|
||||
elseif (preg_match("/directeur.{1,6}technique/i")) return 19;
|
||||
elseif (preg_match("/resp.{1,16}technique/i")) return 49;
|
||||
elseif (preg_match("/resp.{1,16}Expl/i")) return 37;
|
||||
elseif (preg_match("/di.{1,16}Expl/i")) return 7;
|
||||
elseif (preg_match("/Chef.{1,6}Ent/i")) {
|
||||
$tabTmp=$this->iInsee->getIdentiteLight($siren);
|
||||
if ($tabTmp['FJ']>=1000 && $tabTmp['FJ']<2000) return 1050;
|
||||
else die($tabTmp);
|
||||
}
|
||||
else return false;
|
||||
}
|
||||
|
||||
/*
|
||||
"1","- DIRECTEUR GENERAL"
|
||||
"1","- P.d.g."
|
||||
"1","- PRESIDENT CONSEIL D''ADMINISTRATION"
|
||||
"2","-co-gerant"
|
||||
"1","Administrateur"
|
||||
"2","Artisan"
|
||||
"1","AssociÉ"
|
||||
"1","Associes"
|
||||
"24","Co Gerant"
|
||||
"1","Co Gerante"
|
||||
"1","CO GERANTS"
|
||||
"109","Co-gérant"
|
||||
"12","Co-gérante"
|
||||
"1","Dg Delegue"
|
||||
"1","Dir. General Delegue"
|
||||
"32","Directeur"
|
||||
"1","Directeur Adjoint"
|
||||
"1","Directeur Administratif et Financier"
|
||||
"1","Directeur Gal DÉlÉguÉ"
|
||||
"61","Directeur Général"
|
||||
"11","DIRECTEUR GENERAL DELEGUE"
|
||||
"1","Directeur Général Unique"
|
||||
"1","Directrice"
|
||||
"2","DIRIG."
|
||||
"4","Dirigeant"
|
||||
"38","Gér"
|
||||
"857","Gerant"
|
||||
"3","Gerant -"
|
||||
"13","Gérant Associé"
|
||||
"1","Gérant Associé En Non Collectif"
|
||||
"1","GERANT MAJORITAIRE"
|
||||
"2","Gérant Non Associé"
|
||||
"56","Gérante"
|
||||
"4","P D G"
|
||||
"1","P.d.g"
|
||||
"1","PCA"
|
||||
"168","PRESIDENT"
|
||||
"1","President Conseil De Surveillance"
|
||||
"1","PRESIDENT CONSEIL SURVEILLANCE"
|
||||
"63","Président Directeur Général"
|
||||
"1","PRESIDENT DIRECTOIRE"
|
||||
"16","Président du conseil d'administration"
|
||||
"1","Président Du Conseil De Surveillance"
|
||||
"5","President Du Directoire"
|
||||
"10","Presidente"
|
||||
"1","ReprÉsentant SociÉtÉ PrÉsidente"
|
||||
"1","Vice-président"
|
||||
|
||||
Gérer en fonction du code CJ
|
||||
"128","Chef D'entreprise"
|
||||
"2","Chef Ent."
|
||||
"3","Chef Entr."
|
||||
|
||||
"1","Conjoint Collaborateur"=>0500
|
||||
|
||||
|
||||
|
||||
"1","Metreur"
|
||||
"1","Président De Commission"
|
||||
*/
|
||||
}
|
||||
|
||||
public function getMaxQualibat() {
|
||||
$ret=$this->iDb->select('qualibat','MAX(id) AS id', '1', false, MYSQL_ASSOC);
|
||||
return $ret[0]['id'];
|
||||
}
|
||||
|
||||
public function getTabQualibatManquants() {
|
||||
$tabRet=$tabQualibatCalc=$tabQualibatBase=array();
|
||||
// Liste des Qualibat Calculés
|
||||
$maxQualibat=$this->getMaxQualibat();
|
||||
for($i=1; $i<=$maxQualibat; $i++)
|
||||
$tabQualibatCalc[]=$i;
|
||||
|
||||
// Liste des Qualibat en base
|
||||
$ret=$this->iDb->select('qualibat','id', '1 ORDER BY id ASC', false, MYSQL_ASSOC);
|
||||
foreach ($ret as $i=>$res)
|
||||
$tabQualibatBase[]=$res['id'];
|
||||
|
||||
return array_diff($tabQualibatCalc, $tabQualibatBase);
|
||||
}
|
||||
|
||||
public function getInfosQualibat($siren, $idQualibat=0) {
|
||||
if ($siren*1>1000)
|
||||
$strWhere="siren=$siren";
|
||||
elseif ($idQualibat*1>0) {
|
||||
$strWhere="id=$idQualibat";
|
||||
} else return false;
|
||||
|
||||
$ret=$this->iDb->select('qualibat','siren, actif, id, nom, adresse, cp, ville, tel, fax, email, web,
|
||||
eff, teff, ca, tca, libFJ, nace, dateFondation, dateDeb, dateFin, dateInsert', $strWhere, false, MYSQL_ASSOC);
|
||||
if (!$this->force && count($ret)>0) {
|
||||
$this->enCache=true;
|
||||
$tabRet=$ret[0];//array();
|
||||
|
||||
// Ajout des qualifications
|
||||
$ret=$this->iDb->select('qualibatqualif','code, periodQualif, niveauQualif, mentions, nomQualif, dateAttrib, dateEch', $strWhere, false, MYSQL_ASSOC);
|
||||
foreach ($ret as $i=>$tabTmp)
|
||||
$tabRet['qualifications'][]=$tabTmp;
|
||||
|
||||
// Ajout des dirigeants
|
||||
$ret=$this->iDb->select('qualibatdir','civNomPrenom, civilite, nom, prenom, fonction', $strWhere, false, MYSQL_ASSOC);
|
||||
foreach ($ret as $i=>$tabTmp)
|
||||
$tabRet['dirigeants'][]=$tabTmp;
|
||||
} elseif ($this->accesDist==true) {
|
||||
$this->enCache=false;
|
||||
|
||||
// Initialisation Cookies
|
||||
$this->referer='http://www.qualibat.com/Views/EntreprisesRechercheDetail.aspx?id='.$idQualibat;
|
||||
$page=getUrl($this->referer, '', '', '', false, '', '', 3);
|
||||
if ($page['code']<>200) {
|
||||
if ($page['code']==500) {
|
||||
$tabInsert=array( 'actif'=>0,
|
||||
'id'=>$idQualibat,
|
||||
'idQualibatAttribue'=>0,
|
||||
'dateInsert'=>date('YmdHis'));
|
||||
$this->erreur='Numéro Qualibat inexistant';
|
||||
// On enregistre ce numéro comme non attribué si < au dernier numéro attribué
|
||||
if ($idQualibat<$this->getMaxQualibat())
|
||||
$this->iDb->insert('qualibat', $tabInsert);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
$body=$page['body'];
|
||||
//die($body);
|
||||
$tabRet['id']=$idQualibat;
|
||||
|
||||
if (preg_match('/<th>(?:.*)Raison sociale(?:.*)<\/th>(?:.*)<td>(.*)<\/td>/Uis',$body, $matches))
|
||||
$tabRet['nom']=utf8_decode(trim(strip_tags($matches[1])));
|
||||
|
||||
if (preg_match('/<th>(?:.*)Adresse(?:.*)<\/th>(?:.*)<td>(.*)<br \/>(.*)<\/td>/Uis',$body, $matches)) {
|
||||
$tabRet['adresse']=strtoupper(utf8_decode(trim($matches[1])));
|
||||
$adresse2=trim(preg_replace('/ +/',' ',strtr(strip_tags($matches[2]),"\r\n\t".chr(160),' ')));
|
||||
$tabRet['cp']=substr($adresse2,0,5);
|
||||
$tabRet['ville']=utf8_decode(trim(substr($adresse2,5)));
|
||||
}
|
||||
|
||||
if (preg_match('/<th>(?:.*)Téléphone(?:.*)<\/th>(?:.*)<td>(.*)<\/td>/Uis',$body, $matches))
|
||||
$tabRet['tel']=trim(str_replace(' ','',$matches[1]));
|
||||
|
||||
if (preg_match('/<th>(?:.*)Fax(?:.*)<\/th>(?:.*)<td>(.*)<\/td>/Uis',$body, $matches))
|
||||
$tabRet['fax']=trim(str_replace(' ','',$matches[1]));
|
||||
|
||||
if (preg_match('/<th>E-mail<\/th><td>(?:.*)<a href= "mailto\:(.*)">/Uis',$body, $matches))
|
||||
$tabRet['email']=utf8_decode(trim($matches[1]));
|
||||
|
||||
if (preg_match('/<th>(?:.*)SIREN(?:.*)<\/th>(?:.*)<td>(.*)<\/td>/Uis',$body, $matches))
|
||||
$tabRet['siren']=$siren=trim(str_replace(' ','',$matches[1]));
|
||||
|
||||
if (preg_match('/<th>(?:.*)Effectif total(?:.*)<\/th>(?:.*)<td>(.*)\(Classification - (.*)\)(?:.*)<\/td>/Uis',$body, $matches)) {
|
||||
$tabRet['eff']=trim(str_replace(' ','',$matches[1]));
|
||||
$tabRet['teff']=trim($matches[2]);
|
||||
}
|
||||
|
||||
if (preg_match('/<th>(?:.*)CA total(?:.*)<\/th>(?:.*)<td >(.*)\(Classification - (.*)\)(?:.*)<\/td>/Uis',$body, $matches)) {
|
||||
$tabRet['ca']=trim(str_replace(' ','',$matches[1]));
|
||||
if ($tabRet['ca']=='') $tabRet['ca']=NULL;
|
||||
$tabRet['tca']=trim($matches[2]);
|
||||
if ($tabRet['tca']=='') $tabRet['tca']=NULL;
|
||||
}
|
||||
|
||||
if (preg_match('/<th>(?:.*)Forme Juridique(?:.*)<\/th>(?:.*)<td>(.*)<\/td>/Uis',$body, $matches))
|
||||
$tabRet['libFJ']=utf8_decode(trim($matches[1]));
|
||||
|
||||
if (preg_match('/<th>(?:.*)NACE(?:.*)<\/th>(?:.*)<td>(.*)<\/td>/Uis',$body, $matches))
|
||||
$tabRet['nace']=trim($matches[1]);
|
||||
|
||||
if (preg_match('/<th>(?:.*)Fondation(?:.*)<\/th>(?:.*)<td>(.*)<\/td>/Uis',$body, $matches))
|
||||
$tabRet['dateFondation']=Wdate::dateT('d/m/Y', 'Y-m-d', trim($matches[1]));
|
||||
|
||||
if (preg_match('/<tr><td align="center"><img src="(?:.*)internet_contact\.gif(?:.*)<\/td><td> <a href= "(.*)" target="_blank">/Uis',$body, $matches))
|
||||
$tabRet['web']=utf8_decode(trim($matches[1]));
|
||||
|
||||
/** Qualifications ? **/
|
||||
$qualifs='';
|
||||
if (preg_match('/<table class="recherche_entreprise_detail">(?:.*)<th colspan="4">(?:.*)(Qualifications professionnelles|Certifications m..tier)(?:.*)<tbody>(.*)<\/table>/Uis',$body, $matches)) {
|
||||
$typeQualifs=trim(utf8_decode($matches[1]));
|
||||
$qualifs=trim($matches[2]);
|
||||
}
|
||||
|
||||
if (preg_match('/<th>(?:.*)Fondation(?:.*)<\/th>(?:.*)<td>(.*)<\/td>(.*)<div class="buttons">/Uis',$body, $matches)) {
|
||||
$tabRet['tmpDirQualif']=trim($matches[2]);
|
||||
$tabRet['tmpLenDirQualif']=strlen(trim($matches[2]));
|
||||
}
|
||||
|
||||
$tabDateAttrib=$tabDateFin=array();
|
||||
if (preg_match_all('/<tr>(?:.*)<td>(.*)<\/td>(?:.*)<td>(.*)<\/td>(?:.*)<td>(.*)<\/td>(?:.*)<td>(.*)<\/td>(?:.*)<\/tr>/Uis',$qualifs, $matches)) {
|
||||
foreach ($matches[1] as $i=>$code) {
|
||||
$tabTmp=explode(' ',trim($code));
|
||||
$nomQualif=utf8_decode(trim($matches[2][$i]));
|
||||
if (preg_match("/\(Tech?nicit. (.*)\)/Ui", $nomQualif, $matches2))
|
||||
$niveau=trim($matches2[1]);
|
||||
else $niveau='';
|
||||
$tabMentions=array();
|
||||
if (preg_match_all('/Mention (.*)(?:,|$)/Uis',$nomQualif, $matches2)) {
|
||||
foreach ($matches2[1] as $i2=>$mention)
|
||||
$tabMentions[]=$mention;
|
||||
}
|
||||
$tabRet['qualifications'][$i]=array(
|
||||
'code'=>trim($tabTmp[0]),
|
||||
'periodQualif'=>trim($tabTmp[1]),
|
||||
'nomQualif'=>$nomQualif,
|
||||
'niveauQualif'=>$niveau,
|
||||
'typeQualif'=>$typeQualifs,
|
||||
'mentions'=>implode(', ', $tabMentions),
|
||||
'dateAttrib'=>Wdate::dateT('d/m/Y', 'Y-m-d', trim($matches[3][$i])),
|
||||
'dateEch'=>Wdate::dateT('d/m/Y', 'Y-m-d', trim($matches[4][$i])));
|
||||
$tabDateAttrib[]=Wdate::dateT('d/m/Y', 'Ymd', trim($matches[3][$i]))*1;
|
||||
$tabDateFin[]=Wdate::dateT('d/m/Y', 'Ymd', trim($matches[4][$i]))*1;
|
||||
}
|
||||
}
|
||||
sort($tabDateAttrib);
|
||||
rsort($tabDateFin);
|
||||
|
||||
/** Dirigeants ? **/
|
||||
$dirs='';
|
||||
if (preg_match('/<table class="recherche_entreprise_detail">(?:.*)<th colspan="2">(?:.*)Dirigeants(?:.*)<tbody>(.*)<\/table>/Uis',$body, $matches))
|
||||
$dirs=trim($matches[1]);
|
||||
/* <tr>
|
||||
<td>
|
||||
Monsieur EPP Olivier
|
||||
</td>
|
||||
<td>
|
||||
Gérant
|
||||
</td>
|
||||
</tr>*/
|
||||
if (preg_match_all('/<tr>(?:.*)<td>(.*)<\/td>(?:.*)<td>(.*)<\/td>(?:.*)<\/tr>/Uis',$dirs, $matches)) {
|
||||
foreach ($matches[1] as $i=>$nom) {
|
||||
$strNom=utf8_decode(trim($nom));
|
||||
switch(strtoupper(substr($strNom,0,6))) {
|
||||
case 'MONSIE': $civ='M'; $pDeb=8; break;
|
||||
case 'MADAME': $civ='MME'; $pDeb=6; break;
|
||||
case 'MADEMO': $civ='MLLE';$pDeb=12; break;
|
||||
default: $civ=''; $pDeb=0; break;
|
||||
}
|
||||
$libFonction=ucwords(strtolower(utf8_decode(trim($matches[2][$i]))));
|
||||
$tabRet['dirigeants'][$i]=array(
|
||||
'civNomPrenom'=>$strNom,
|
||||
'civilite'=>$civ,
|
||||
'nom'=>strtoupper(trim(substr($strNom,$pDeb,65))),
|
||||
'prenom'=>ucwords(strtolower(trim(substr($strNom,$pDeb+66)))),
|
||||
'fonction'=>$libFonction,
|
||||
'fonctionCode'=>$this->getCodeFctDirigeant($libFonction, $siren),
|
||||
);
|
||||
}
|
||||
//print_r($tabRet['dirigeants']);
|
||||
//die();
|
||||
}
|
||||
|
||||
/** Insertion de l'entreprise
|
||||
**/
|
||||
$tabInsert=array_merge($tabRet,
|
||||
array( 'idQualibatAttribue'=>1,
|
||||
'dateInsert'=>date('YmdHis'),
|
||||
'dateDeb'=>@$tabDateAttrib[0],
|
||||
'dateFin'=>@$tabDateFin[0]));
|
||||
unset($tabInsert['qualifications']);
|
||||
if (!$this->iDb->insert('qualibat', $tabInsert)) {
|
||||
$this->iDb->update('qualibat', $tabInsert, "id=$idQualibat");
|
||||
}
|
||||
|
||||
|
||||
/** Insertion des qualifications
|
||||
**/
|
||||
if (isset($tabRet['qualifications']) && count($tabRet['qualifications'])>0)
|
||||
foreach ($tabRet['qualifications'] as $i=>$tabInsert) {
|
||||
$tabInsert['id']=$idQualibat;
|
||||
$tabInsert['siren']=$siren;
|
||||
$tabInsert['dateInsert']=date('YmdHis');
|
||||
if (!$this->iDb->insert('qualibatqualif', $tabInsert)) {
|
||||
$this->iDb->update('qualibatqualif', $tabInsert, "id=$idQualibat AND code='".$tabInsert['code']."' AND periodQualif='".$tabInsert['periodQualif']."'");
|
||||
}
|
||||
}
|
||||
|
||||
/** Insertion des dirigeants
|
||||
**/
|
||||
if (isset($tabRet['dirigeants']) && count($tabRet['dirigeants'])>0)
|
||||
foreach ($tabRet['dirigeants'] as $i=>$tabInsert) {
|
||||
$tabInsert['id']=$idQualibat;
|
||||
$tabInsert['siren']=$siren;
|
||||
$tabInsert['dateInsert']=date('YmdHis');
|
||||
if (!$this->iDb->insert('qualibatdir', $tabInsert)) {
|
||||
$this->iDb->update('qualibatdir', $tabInsert, "id=$idQualibat AND civNomPrenom='".addslashes($tabInsert['civNomPrenom'])."' AND fonction='".addslashes($tabInsert['fonction'])."'");
|
||||
}
|
||||
unset($tabRet['dirigeants'][$i]['civNomPrenom']);
|
||||
}
|
||||
}
|
||||
return $tabRet;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
0
library/Metier/partenaires/classMRefAsso.php
Normal file
0
library/Metier/partenaires/classMRefAsso.php
Normal file
826
library/Metier/partenaires/classMRncs.php
Normal file
826
library/Metier/partenaires/classMRncs.php
Normal file
@ -0,0 +1,826 @@
|
||||
<?
|
||||
|
||||
class MRncs {
|
||||
|
||||
public $tabFctDir=array( 100 =>array('codeSd'=>'1300', 'lib'=>'Président'),
|
||||
110 =>array('codeSd'=>'1306', 'lib'=>'Président du conseil d\'administration'),
|
||||
120 =>array('codeSd'=>'1301', 'lib'=>'Président directeur Général'),
|
||||
140 =>array('codeSd'=>'1650', 'lib'=>'Gouverneur'),
|
||||
150 =>array('codeSd'=>'1651', 'lib'=>'Sous-gouverneur'),
|
||||
200 =>array('codeSd'=>'0900', 'lib'=>'Gérant'),
|
||||
210 =>array('codeSd'=>'0912', 'lib'=>'Gérant non associé'),
|
||||
300 =>array('codeSd'=>'0400', 'lib'=>'Co-gérant'),
|
||||
400 =>array('codeSd'=>'0709', 'lib'=>'Directeur général'),
|
||||
410 =>array('codeSd'=>'0713', 'lib'=>'Directeur général non administrateur'),
|
||||
420 =>array('codeSd'=>'0708', 'lib'=>'Directeur général unique'),
|
||||
430 =>array('codeSd'=>'0704', 'lib'=>'Directeur général délégué'),
|
||||
500 =>array('codeSd'=>'1800', 'lib'=>'Vice-président'),
|
||||
600 =>array('codeSd'=>'0100', 'lib'=>'Administrateur'),
|
||||
610 =>array('codeSd'=>'0101', 'lib'=>'Administrateur délégué'),
|
||||
700 =>array('codeSd'=>'1308', 'lib'=>'Président du directoire'),
|
||||
900 =>array('codeSd'=>'1307', 'lib'=>'Président du conseil de surveillance'),
|
||||
1200=>array('codeSd'=>'0209', 'lib'=>'Associé-gérant'),
|
||||
1300=>array('codeSd'=>'0603', 'lib'=>'Contrôleur de gestion'),
|
||||
4000=>array('codeSd'=>'A', 'lib'=>'Administrateur judiciaire'),
|
||||
4100=>array('codeSd'=>'1900', 'lib'=>'Liquidateur'),
|
||||
4300=>array('codeSd'=>'0108', 'lib'=>'Administrateur provisoire'),
|
||||
4400=>array('codeSd'=>'1401', 'lib'=>'Représentant en France d\'une société étrangère'),
|
||||
7000=>array('codeSd'=>'U', 'lib'=>'Curateur'),
|
||||
7100=>array('codeSd'=>'C', 'lib'=>'Commissaire au plan'),
|
||||
7200=>array('codeSd'=>'S', 'lib'=>'Syndic'),
|
||||
7300=>array('codeSd'=>'D', 'lib'=>'Commissaire au concordat'),
|
||||
7500=>array('codeSd'=>'R', 'lib'=>'Représentant des créanciers'),
|
||||
7600=>array('codeSd'=>'M', 'lib'=>'Mandataire judiciaire'),
|
||||
7800=>array('codeSd'=>'M', 'lib'=>'Mandataire judiciaire'),
|
||||
9100=>array('codeSd'=>'T', 'lib'=>'Conciliateur'),
|
||||
);
|
||||
|
||||
public $tabDevises=array();
|
||||
public $tabPays=array();
|
||||
public $tabTribunaux=array();
|
||||
public $tabMandataires=array();
|
||||
public $tabJugements=array();
|
||||
private $iDb;
|
||||
|
||||
/** Partie Extranet IMR Infogreffe **/
|
||||
public $body='';
|
||||
public $referer='';
|
||||
public $codeRetour='';
|
||||
public $libErreur='';
|
||||
public $cookie='';
|
||||
public $infoIMR=array();
|
||||
public $maxDemJour=10;
|
||||
|
||||
function __construct() {
|
||||
$this->iDb=new WDB();
|
||||
$this->tabDevises=$this->getTabDevisesInpi();
|
||||
$this->tabPays=$this->getTabPaysInpi();
|
||||
$this->tabTribunaux=$this->getTabTribunaux();
|
||||
$this->tabMandataires=$this->getTabMandataires();
|
||||
$this->tabJugements=$this->getTabJugements();
|
||||
}
|
||||
|
||||
public function getLibFctDir($codeFonctionDirectionRncs) {
|
||||
$codeFonctionDirectionRncs=$codeFonctionDirectionRncs*1;
|
||||
return $this->tabFctDir[$codeFonctionDirectionRncs]['lib'];
|
||||
}
|
||||
|
||||
public function getCodFctBodaccFctDir($codeFonctionDirectionRncs) {
|
||||
$codeFonctionDirectionRncs=$codeFonctionDirectionRncs*1;
|
||||
return $this->tabFctDir[$codeFonctionDirectionRncs]['codeSd'];
|
||||
}
|
||||
|
||||
/** Initialisation du tableau privé des devises Inpi <=> ISO **/
|
||||
private function getTabDevisesInpi() {
|
||||
$rep=$this->iDb->select('tabDevises', 'devInpi, devIso', 'devInpi>0', false, MYSQL_ASSOC);
|
||||
$tabDevises=array();
|
||||
foreach($rep as $k=>$dev)
|
||||
$tabDevises[$dev['devInpi']*1]=$dev['devIso'];
|
||||
|
||||
return $tabDevises;
|
||||
}
|
||||
|
||||
/** Récupération du code ISO de la devise numérique de l'Inpi
|
||||
**
|
||||
** @param integer $devise
|
||||
** @return string Devise ISO
|
||||
**/
|
||||
public function getDeviseInpi($numDeviseInpi) {
|
||||
if ($numDeviseInpi*1>0 && isset($this->tabDevises[$numDeviseInpi*1]))
|
||||
return $this->tabDevises[$numDeviseInpi*1];
|
||||
else
|
||||
return '';
|
||||
}
|
||||
|
||||
public function getTabJugements() {
|
||||
$rep=$this->iDb->select('tabJugeRncs', 'codJugement, codEven', '1', false, MYSQL_ASSOC);
|
||||
$tabJug=array();
|
||||
foreach($rep as $k=>$dev)
|
||||
$tabJug[$dev['codJugement']*1]=$dev['codEven'];
|
||||
|
||||
return $tabJug;
|
||||
}
|
||||
|
||||
public function getCodeEvenJugementInpi($codJugementInpi) {
|
||||
if ($codJugementInpi*1>0 && isset($this->tabJugements[$codJugementInpi*1]))
|
||||
return $this->tabJugements[$codJugementInpi*1];
|
||||
else
|
||||
return $codJugementInpi;
|
||||
}
|
||||
|
||||
/** Initialisation du tableau privé des pays Inpi <=> ISO **/
|
||||
private function getTabPaysInpi() {
|
||||
$rep=$this->iDb->select('tabPays', 'codePaysInpi, codPays', 'codePaysInpi>0', false, MYSQL_ASSOC);
|
||||
$tabPays=array();
|
||||
foreach($rep as $k=>$dev)
|
||||
$tabPays[$dev['codePaysInpi']*1]=$dev['codPays'];
|
||||
|
||||
return $tabPays;
|
||||
}
|
||||
|
||||
/** Tableau des mandataires suceptibles d'être tranmis par l'INPI
|
||||
**/
|
||||
private function getTabMandataires() {
|
||||
$tabTmp=$this->iDb->select('tabMandataires', "UPPER(CONCAT(SUBSTRING(Nom,1,4),'-',SUBSTRING(Prenom,1,3))) AS NomPre, SUBSTRING(cp,1,2) AS dep, COUNT(*) AS Nb, sirenMand, id, sirenGrp, Nom, Prenom, type, coursAppel, tribunal, Statut, adresse, adresseComp, cp, ville, tel, fax, email, web, contact", "TYPE IN ('A', 'M') GROUP BY NomPre, dep, sirenMand ORDER BY NomPre ASC", true, MYSQL_ASSOC);
|
||||
$tabMandSD=array();
|
||||
foreach ($tabTmp as $mand) {
|
||||
$tabMandSD[]=array( 'id' => $mand['id'],
|
||||
'siren' => $mand['sirenMand'],
|
||||
'nom' => $mand['Nom'],
|
||||
'prenom'=> $mand['Prenom'],
|
||||
'type' => $mand['type'],
|
||||
'adr1' => $mand['adresse'],
|
||||
'adr2' => $mand['adresseComp'],
|
||||
'cp' => $mand['cp'],
|
||||
'ville' => $mand['ville'],
|
||||
'tel' => $mand['tel'],
|
||||
'fax' => $mand['fax'],
|
||||
'email' => $mand['email'],
|
||||
);
|
||||
}
|
||||
return $tabMandSD;
|
||||
}
|
||||
|
||||
/** Donne l'id du mandataire en fonction de son libellé INPI
|
||||
** @param string $strNomPrenom Nom et Prénom du mandataire
|
||||
** @return int $id Identifiant du mandataire
|
||||
**/
|
||||
public function getIdMandataireInpi($strNomPrenom) {
|
||||
if (trim($strNomPrenom)=='') return false;
|
||||
if (preg_match('/^(.*) (?:Me|Ma.tre) (.*)$/i', $strNomPrenom, $matches)) {
|
||||
$nomPrenomToFind=strtr($matches[1],'àáâãäåæçèéêëìíîïðñòóôõöùúûüýÿ…‘-\' ', "aaaaaaaceeeeiiiionooooouuuuyy.....");
|
||||
$nomToFind=strtr($matches[2],'àáâãäåæçèéêëìíîïðñòóôõöùúûüýÿ…‘-\' ', "aaaaaaaceeeeiiiionooooouuuuyy.....");
|
||||
} else {
|
||||
$nomPrenomToFind=strtr($strNomPrenom,'àáâãäåæçèéêëìíîïðñòóôõöùúûüýÿ…‘-\' ', "aaaaaaaceeeeiiiionooooouuuuyy.....");
|
||||
$nomToFind='';
|
||||
}
|
||||
$id=false;
|
||||
//echo "Recherche de $nomPrenomToFind ($nomToFind) : ";
|
||||
if ($strNomPrenom=='SCP BELAT DESPRAT') return 48;
|
||||
if ($strNomPrenom=='DU BUIT') return 170;
|
||||
if ($strNomPrenom=='SELARL MALMEZAT PRAT') return 312;
|
||||
if ($strNomPrenom=='SELARL DUQUESNOY & ASSOCIES') return 176;
|
||||
if ($strNomPrenom=='- SELARL DUQUESNOY & ASSOCIES') return 176;
|
||||
if ($strNomPrenom=='SOUCHON ALAIN') return 412;
|
||||
if ($strNomPrenom=='SELARL GRAVE WALLYN RANDOUX Me RANDOUX Guillaume') return 8621;
|
||||
if ($strNomPrenom=='SCP SILVESTRI BAUJET') return 35;
|
||||
if ($strNomPrenom=='ROGEAU') return 385;
|
||||
if ($strNomPrenom=='SCP BIHR-LE CARRER') return 64;
|
||||
if ($strNomPrenom=='- SCP BIHR-LE CARRER') return 64;
|
||||
if ($strNomPrenom=='SCP GUYON DAVAL') return 144;
|
||||
if ($strNomPrenom=='COURTOUX') return 134;
|
||||
if ($strNomPrenom=='SCP B.T.S.G. ME GORRIAS') return 44;
|
||||
if ($strNomPrenom=='MONTRAVERS') return 340;
|
||||
if ($strNomPrenom=='SCP OUIZILLE DE KEATING Me DE KEATING') return 351;
|
||||
if ($strNomPrenom=='DOUTRESSOULLE') return 169;
|
||||
if ($strNomPrenom=='SCP LECLERC MASSELON') return 286;
|
||||
if ($strNomPrenom=='AUSSEL Vincent') return 17;
|
||||
if ($strNomPrenom=='SCP BROUARD DAUDE Me DAUDE Florence') return 95;
|
||||
if ($strNomPrenom=='SELARL T.C.A') return 423;
|
||||
//if ($strNomPrenom=='BEDNAWSKI CORNELIUS,MAXIME') return 0;
|
||||
//if ($strNomPrenom=='LECA Pierre Alexandre') return 0;
|
||||
if ($strNomPrenom=='SELAFA MJA Maître LELOUP THOMAS' ||
|
||||
$strNomPrenom=='- SELAFA MJA ME LELOUP THOMAS') return 290;
|
||||
if ($strNomPrenom=='SELAFA MJA Maître LEVY' ||
|
||||
$strNomPrenom=='- SELAFA MJA Maître LEVY') return 297;
|
||||
if ($strNomPrenom=='SELAFA MJA Maître FRECHOU' ||
|
||||
$strNomPrenom=='- SELAFA MJA Maître FRECHOU') return 194;
|
||||
if ($strNomPrenom=='SELAFA MJA Maître PIERREL' ||
|
||||
$strNomPrenom=='- SELAFA MJA Maître PIERREL') return 368;
|
||||
if ($strNomPrenom=='SELAFA MJA Maître PENET- WEILLER' ||
|
||||
$strNomPrenom=='- SELAFA MJA ME PENET-WEILLER') return 357;
|
||||
if ($strNomPrenom=='HUILLE PASCALE') return 244;
|
||||
if ($strNomPrenom=='SCP B.T.S.G. ME BECHERET') return 42;
|
||||
if ($strNomPrenom=='SELARL MB ASSOCIES ME CORRE') return 129;
|
||||
if ($strNomPrenom=='PERNAUD PHILIPPE') return 361;
|
||||
if ($strNomPrenom=='MARGOTTIN Eric') return 23;
|
||||
if ($strNomPrenom=='MARGOTTIN Eric') return 23;
|
||||
|
||||
if ($strNomPrenom=='SCP GUERIN DIESBECQ ME DIESBEC') return 163;
|
||||
if ($strNomPrenom=='SCP DOLLEY-COLLET') return 165;
|
||||
if ($strNomPrenom=='SCP B.T.S.G. ME SENECHAL') return 45;
|
||||
if ($strNomPrenom=='AVEZOU') return 20;
|
||||
if ($strNomPrenom=='SOINNE') return 409;
|
||||
|
||||
/* if ($strNomPrenom=='SCP LE DORTZ B. ET BODELET G.') return 361;
|
||||
if ($strNomPrenom=='SCP P. DURAN ET E. FLATRES') return 361;
|
||||
if ($strNomPrenom=='CHABAL MAX-HENRI') return 361;
|
||||
if ($strNomPrenom=='ROUSSELOT GEGOUE Marie Adeline') return 361;*/
|
||||
|
||||
foreach ($this->tabMandataires as $mand) {
|
||||
$nomToTest=strtr($mand['nom'],'àáâãäåæçèéêëìíîïðñòóôõöùúûüýÿ…‘-\' ', "aaaaaaaceeeeiiiionooooouuuuyy.....");
|
||||
$tabTmp=preg_split('/( |-)/', $mand['prenom']);
|
||||
$preToTest=strtr($tabTmp[0],'àáâãäåæçèéêëìíîïðñòóôõöùúûüýÿ…‘-\' ', "aaaaaaaceeeeiiiionooooouuuuyy.....");
|
||||
if (preg_match("/$nomToTest/i", $nomPrenomToFind)) {
|
||||
//echo "$nomToTest $preToTest TROUVE".EOL;
|
||||
// Cas des mandataires en SCP
|
||||
if ($nomToFind<>'' && preg_match("/$nomToTest/i", $nomToFind) && preg_match("/$preToTest/i", $nomToFind)) {
|
||||
//if (!$id)
|
||||
$id=$mand['id'];
|
||||
//else return false; // Afin de ne pas renvoyer d'id si plusieurs mandataires trouvés
|
||||
}
|
||||
elseif ($nomToFind<>'' && preg_match("/$nomToTest/i", $nomToFind)) {
|
||||
//if (!$id)
|
||||
$id=$mand['id'];
|
||||
//else return false; // Afin de ne pas renvoyer d'id si plusieurs mandataires trouvés
|
||||
}
|
||||
elseif (!$nomToFind && preg_match("/$preToTest/i", $nomPrenomToFind)) {
|
||||
//if (!$id)
|
||||
$id=$mand['id'];
|
||||
//else return false; // Afin de ne pas renvoyer d'id si plusieurs mandataires trouvés
|
||||
}
|
||||
} elseif (preg_match("/$nomToTest/i", $nomToFind) && preg_match("/$preToTest/i", $nomToFind)) {
|
||||
//if (!$id)
|
||||
$id=$mand['id'];
|
||||
//else return false; // Afin de ne pas renvoyer d'id si plusieurs mandataires trouvés
|
||||
}
|
||||
}
|
||||
return $id;
|
||||
}
|
||||
|
||||
/** Récupération du code ISO du code pays numérique de l'Inpi
|
||||
**
|
||||
** @param integer $pays
|
||||
** @return string Devise ISO
|
||||
**/
|
||||
public function getPaysInpi($numPays) {
|
||||
if ($numPays*1>0)
|
||||
return $this->tabPays[$numPays*1];
|
||||
else
|
||||
return '';
|
||||
}
|
||||
|
||||
/** Initialisation du tableau privé des codes tribunaux Greffes/Inpi avec le libellé Bodacc **/
|
||||
private function getTabTribunaux() {
|
||||
$rep=$this->iDb->select('tribunaux', 'triNumGreffe, triNom, triId, triCode', 'triNumGreffe IS NOT NULL', false, MYSQL_ASSOC);
|
||||
$tabTribunaux=array();
|
||||
foreach($rep as $k=>$dev) {
|
||||
$tabTribunaux[$dev['triNumGreffe']*1]['Id']=$dev['triId'];
|
||||
$tabTribunaux[$dev['triNumGreffe']*1]['Nom']=$dev['triNom'];
|
||||
$tabTribunaux[$dev['triNumGreffe']*1]['Code']=$dev['triCode'];
|
||||
}
|
||||
return $tabTribunaux;
|
||||
}
|
||||
|
||||
private function getLibelleFJ($code_forme_juridique) {
|
||||
$fj=$code_forme_juridique*1;
|
||||
if ($fj>0 && $fj<10000) {
|
||||
$tmp=$this->iDb->select( 'tabFJur', 'libelle AS LibFJ', "code=$fj");
|
||||
return @$tmp[0][0];
|
||||
} else
|
||||
return 'En instance de chiffrement';
|
||||
}
|
||||
|
||||
private function getLibelleNaf($codeNaf) {
|
||||
$ret=$this->iDb->query("SELECT libNaf700 AS LibNaf FROM tabNaf4 WHERE codNaf700='$codeNaf' UNION
|
||||
SELECT libNaf5 AS LibNaf FROM tabNaf5 WHERE codNaf5='$codeNaf'");
|
||||
$res=$this->iDb->fetch(MYSQL_ASSOC);
|
||||
return $res['LibNaf'];
|
||||
}
|
||||
|
||||
/** Récupération du libellé du code numérique du tribunal Greffe ou Inpi
|
||||
**
|
||||
** @param integer $numTribunal
|
||||
** @return string Nom du tribunal
|
||||
**/
|
||||
public function getLibTribunal($numTribunal) {
|
||||
if ($numTribunal*1>0)
|
||||
return $this->tabTribunaux[$numTribunal*1]['Nom'];
|
||||
else
|
||||
return '';
|
||||
}
|
||||
|
||||
/** Récupération du code Bodacc du code numérique du tribunal Greffe ou Inpi
|
||||
**
|
||||
** @param integer $numTribunal
|
||||
** @return string Code Bodacc du tribunal
|
||||
**/
|
||||
public function getCodeBodaccTribunal($numTribunal) {
|
||||
if ($numTribunal*1>0)
|
||||
return $this->tabTribunaux[$numTribunal*1]['Code'];
|
||||
else
|
||||
return '';
|
||||
}
|
||||
|
||||
/** Récupération de l'identifiant S&D du code numérique du tribunal Greffe ou Inpi
|
||||
**
|
||||
** @param integer $numTribunal
|
||||
** @return string Numéro interne de tribunal S&D
|
||||
**/
|
||||
public function getIdTribunal($numTribunal) {
|
||||
if ($numTribunal*1>0)
|
||||
return $this->tabTribunaux[$numTribunal*1]['Id'];
|
||||
else
|
||||
return '';
|
||||
}
|
||||
|
||||
/** Retourne les informations de l'établissements demandé ou du siège actif ou dernier siège inactif
|
||||
*
|
||||
* @param integer $siren Siren de l'entreprise
|
||||
* @param integer $nic Nic de l'établissement. Si absent, renvoi les informations du siège actif ou du dernier siège actif
|
||||
* @return array
|
||||
*/
|
||||
public function getIdentiteEtab($siren, $nic=0) {
|
||||
$siren=$siren*1;
|
||||
$nic=$nic*1;
|
||||
if ($nic>0) $strSql=" AND nic=$nic";
|
||||
else $strSql=" AND siege=1 ORDER BY actif DESC, nic DESC";
|
||||
|
||||
$rep=$this->iDb->select('rncs_etab', 'siren, nic, siege, actif, enseigne, nomCommercial, adrNumVoie, adrIndRep, adrLibVoie, adrTypeVoie, adrVoie, cp, commune, adrComp, adresse1, adresse2, adresse3, naf, dateFermeture, flux, DATE(dateUpdate) AS jourUpdate', "siren=$siren $strSql", false, MYSQL_ASSOC);
|
||||
$entrep=$rep[0];
|
||||
|
||||
if ($entrep['jourUpdate']<>'0000-00-00') $dateMaj=$entrep['jourUpdate'];
|
||||
else $dateMaj=$entrep['flux'];
|
||||
|
||||
if (trim($entrep['adresse1'])=='') $adresse1=trim(preg_replace('/ +/',' ', $entrep['adrNumVoie'].' '.strtoupper($entrep['adrIndRep']).' '. strtoupper($entrep['adrLibVoie'])));
|
||||
else $adresse1=trim(strtoupper($entrep['adresse1']));
|
||||
if (trim($entrep['adresse2'])=='') $adresse2=trim(strtoupper($entrep['adrComp']));
|
||||
else $adresse2=trim(strtoupper($entrep['adresse2']));
|
||||
if (trim($entrep['adresse3'])=='') $adresse3='';
|
||||
else $adresse3=trim(strtoupper($entrep['adresse3']));
|
||||
$tabIdentite=array( 'siren' => $entrep['siren'],
|
||||
'nic' => $entrep['nic'],
|
||||
'siret' => $entrep['siren'].$entrep['nic'],
|
||||
'actif' => $entrep['actif'],
|
||||
'siege' => $entrep['siege'],
|
||||
'enseigne' => strtoupper($entrep['enseigne']),
|
||||
'nomCommercial' => strtoupper($entrep['nomCommercial']),
|
||||
'adrNumVoie' => $entrep['adrNumVoie'],
|
||||
'adrIndRep' => strtoupper($entrep['adrIndRep']),
|
||||
'adrTypeVoie' => strtoupper($entrep['adrTypeVoie']),
|
||||
'adrVoie' => strtoupper($entrep['adrVoie']),
|
||||
'adrComp' => strtoupper($entrep['adrComp']),
|
||||
'cp' => strtoupper($entrep['cp']),
|
||||
'commune' => strtoupper($entrep['commune']),
|
||||
'adresse1' => $adresse1,
|
||||
'adresse2' => $adresse2,
|
||||
'adresse3' => $adresse3,
|
||||
'nafEtab' => $entrep['naf'],
|
||||
'nafEtabLib' => $this->getLibelleNaf($entrep['naf']),
|
||||
'dateFerEtab' => $entrep['dateFermeture'],
|
||||
'dateMajEtab' => $dateMaj,
|
||||
);
|
||||
return array_merge($tabIdentite, $this->getInfosEntrep($siren));
|
||||
}
|
||||
|
||||
|
||||
public function getInfosEntrep($siren) {
|
||||
$siren=$siren*1;
|
||||
$rep=$this->iDb->select('rncs_entrep', 'siren, sirenValide, actif, numGreffe, triCode, triId, numRC, numRC2, raisonSociale, nom, prenom, nomUsage, sigle, dateNaiss, lieuNaiss, sexe, nationalite, pays, naf, cj, capitalMontant, capitalDevise, capitalDevIso, dateImma, dateRad, capitalType, capitalCent, provisoires, flux, DATE(dateUpdate) AS jourUpdate', "siren=$siren", false, MYSQL_ASSOC);
|
||||
$entrep=$rep[0];
|
||||
|
||||
if ($entrep['jourUpdate']<>'0000-00-00') $dateMaj=$entrep['jourUpdate'];
|
||||
else $dateMaj=$entrep['flux'];
|
||||
|
||||
$tabIdentite=array( 'siren' => $entrep['siren'],
|
||||
'sirenValide' => $entrep['sirenValide'],
|
||||
'actif' => $entrep['actif'],
|
||||
'numGreffe' => $entrep['numGreffe'],
|
||||
'triCode' => $entrep['triCode'],
|
||||
'triId' => $entrep['triId'],
|
||||
'libGreffe' => preg_replace('/^(TC |TGI |TGIcc |TMX |Tribunal Inconnu)/Ui','', $this->getLibTribunal($entrep['numGreffe']*1)),
|
||||
'numRC' => $entrep['numRC2'],
|
||||
'raisonSociale' => strtoupper($entrep['raisonSociale']),
|
||||
'nom' => strtoupper($entrep['nom']),
|
||||
'prenom' => strtoupper($entrep['prenom']),
|
||||
'nomUsage' => strtoupper($entrep['nomUsage']),
|
||||
'sigle' => strtoupper($entrep['sigle']),
|
||||
'dateNaiss' => $entrep['dateNaiss'],
|
||||
'lieuNaiss' => strtoupper($entrep['lieuNaiss']),
|
||||
'sexe' => $entrep['sexe'],
|
||||
'pays' => $entrep['pays'],
|
||||
'cj' => $entrep['cj'],
|
||||
'cjLib' => $this->getLibelleFJ($entrep['cj']),
|
||||
'nafEnt' => $entrep['naf'],
|
||||
'nafEntLib' => $this->getLibelleNaf($entrep['naf']),
|
||||
'capital' => $entrep['capitalMontant']+($entrep['capitalCent']/100),
|
||||
'capitalDev' => $entrep['capitalDevIso'],
|
||||
'capitalType' => $entrep['capitalType'],
|
||||
'dateImma' => $entrep['dateImma'],
|
||||
'dateRad' => $entrep['dateRad'],
|
||||
'provisoires' => $entrep['provisoires'],
|
||||
'dateMajEnt' => $dateMaj,
|
||||
);
|
||||
|
||||
return $tabIdentite;
|
||||
}
|
||||
|
||||
public function getListeDepots($siren) {
|
||||
$siren=$siren*1;
|
||||
$rep=$this->iDb->select('rncs_even e LEFT JOIN tabEvenRncs l ON e.codeEven=l.codeEven',
|
||||
'e.siren, e.codeInterne, e.dateDepot, e.codeEven, l.libEven, e.flux, DATE(e.dateInsert) AS dateInsert',
|
||||
"e.siren=$siren ORDER BY e.dateDepot DESC", false, MYSQL_ASSOC);
|
||||
$tabDepots=array();
|
||||
foreach ($rep as $iDepot=>$depot) {
|
||||
$tabDepots[]=array( 'codDepot' => $depot['codeEven'],
|
||||
'libDepot' => $depot['libEven'],
|
||||
'datDepot' => $depot['dateDepot'],
|
||||
'refDepot' => $depot['codeInterne'],
|
||||
'datRncs' => $depot['flux'],
|
||||
'datSed' => $depot['dateInsert'],
|
||||
);
|
||||
}
|
||||
return $tabDepots;
|
||||
}
|
||||
|
||||
public function getListeJugements($siren) {
|
||||
$siren=$siren*1;
|
||||
$rep=$this->iDb->select('rncs_jugements j, tabJugeRncs l, tabEvenements e',
|
||||
'siren, j.dateEffet, j.codeJugement, j.flux, l.libJugement, e.codEven, e.libEven,
|
||||
adm1id, adm1codeFct, adm1type, adm1nom, adm1adrNum, adm1adrInd, adm1adrType, adm1adrLibVoie, adm1adrVoie, adm1adr1, adm1adr2, adm1adr3, adm1adrCP, adm1adrVille,
|
||||
adm2id, adm2codeFct, adm2type, adm2nom, adm2adrNum, adm2adrInd, adm2adrType, adm2adrLibVoie, adm2adrVoie, adm2adr1, adm2adr2, adm2adr3, adm2adrCP, adm2adrVille',
|
||||
"j.siren=$siren AND j.codeJugement=l.codJugement AND l.codEven=e.codEven ORDER BY j.dateEffet DESC", false, MYSQL_ASSOC);
|
||||
/*adm1adrNum adm1adrInd adm1adrType adm1adrLibVoie adm1adrVoie adm1adr1 adm1adr2 adm1adr3 adm1adrCP adm1adrVille adm2codeFct adm2type adm2id adm2nom adm2adrNum adm2adrInd adm2adrType adm2adrLibVoie adm2adrVoie adm2adr1 adm2adr2 adm2adr3 adm2adrCP adm2adrVille flux dateSuppr dateInsert
|
||||
Modifier Effacer 490524055 2010-12-20 11 1 1200 4000 A 0 ME TULIER 0000 IMM LE MAZIERE 4EME ETAGE Immeuble le Mazière - 4ème étage rue René Cassin */
|
||||
$tabDepots=array();
|
||||
foreach ($rep as $iDepot=>$depot) {
|
||||
$tabDepots[]=array( 'codEven' => $depot['codEven'],
|
||||
'libEven' => $depot['libEven'],
|
||||
'dateEffet' => $depot['dateEffet'],
|
||||
'adm1id' => $depot['adm1id'],
|
||||
'adm1code' => $depot['adm1codeFct'],
|
||||
'adm1type' => $depot['adm1type'],
|
||||
'adm1fonction' => @$this->getLibFctDir($depot['adm1codeFct']),
|
||||
'adm1nom' => $depot['adm1nom'],
|
||||
'adm1adrNum' => $depot['adm1adrNum'],
|
||||
'adm1adrInd' => $depot['adm1adrInd'],
|
||||
'adm1adrType' => $depot['adm1adrType'],
|
||||
'adm1adrVoie' => $depot['adm1adrLibVoie'], // @todo : adm1adr1, , adm1adr3,
|
||||
'adm1adr2' => $depot['adm1adr2'],
|
||||
'adm1adrCP' => $depot['adm1adrCP'],
|
||||
'adm1adrVille' => $depot['adm1adrVille'],
|
||||
'adm2id' => $depot['adm2id'],
|
||||
'adm2code' => $depot['adm2codeFct'],
|
||||
'adm2type' => $depot['adm2type'],
|
||||
'adm2fonction' => @$this->getLibFctDir($depot['adm2codeFct']),
|
||||
'adm2nom' => $depot['adm2nom'],
|
||||
'adm2adrNum' => $depot['adm2adrNum'],
|
||||
'adm2adrInd' => $depot['adm2adrInd'],
|
||||
'adm2adrType' => $depot['adm2adrType'],
|
||||
'adm2adrVoie' => $depot['adm2adrLibVoie'], // @todo : adm1adr1, adm1adr2, adm1adr3,
|
||||
'adm2adr2' => $depot['adm2adr2'],
|
||||
'adm2adrCP' => $depot['adm2adrCP'],
|
||||
'adm2adrVille' => $depot['adm2adrVille'],
|
||||
);
|
||||
}
|
||||
return $tabDepots;
|
||||
}
|
||||
|
||||
public function getEvenements($siren, $nic=0, $type='', $dateDeb='', $dateFin='') {
|
||||
$tabEven=array( 'p120'=>'Réactivation de l\'entreprise',
|
||||
'p410'=>'Cessation juridique de l\'entreprise',
|
||||
'pCAP'=>'Modification du capital social',
|
||||
'pCAT'=>'Modification du type de capital',
|
||||
'pCJ' =>'Modification de la forme juridique',
|
||||
'pIMM'=>'Modification de la date d\'immatriculation',
|
||||
'pRAD'=>'Modification de la date de radiation',
|
||||
'pNTR'=>'Modification du greffe d\'enregistrement',
|
||||
'pNRC'=>'Modification du numéro du RC',
|
||||
'pNOM'=>'Modification de la dénomination',
|
||||
);
|
||||
$tabRet=array();
|
||||
$siren=$siren*1;
|
||||
if ($nic>0) $strNic =" AND nic=$nic ";
|
||||
if ($type<>'') $strType=" AND champs='$type' ";
|
||||
if ($dateDeb<>'') $strDateDeb=" AND flux>='$dateDeb' ";
|
||||
if ($dateFin<>'') $strDateFin=" AND flux<='$dateFin' ";
|
||||
|
||||
$rep=$this->iDb->select('rncs_modifs',
|
||||
'siren, nic, `table`, champs, valeur, flux, dateInsert',
|
||||
"siren=$siren $strNic $strType $strDateDeb $strDateFin AND `table`='rncs_entrep' ORDER BY flux DESC", false, MYSQL_ASSOC);
|
||||
foreach ($rep as $iModif=>$modif) {
|
||||
$codEve=array();
|
||||
switch($modif['champs']) {
|
||||
case 'actif':
|
||||
if ($modif['valeur']*1==0) $codEve[]='410'; // Cessation
|
||||
elseif ($modif['valeur']*1==1) $codEve[]='120'; // Réactivation
|
||||
break;
|
||||
case 'raisonSociale': $codEve[]='NOM'; break;
|
||||
case 'capitalMontant': $codEve[]='CAP'; break;
|
||||
case 'capitalType': $codEve[]='CAT'; break;
|
||||
case 'cj': $codEve[]='CJ'; break;
|
||||
case 'dateImma': $codEve[]='IMM'; break;
|
||||
case 'dateRad': $codEve[]='RAD'; break;
|
||||
case 'numGreffe': $codEve[]='NTR'; break;
|
||||
case 'numRC2': $codEve[]='NRC'; break;
|
||||
}
|
||||
foreach ($codEve as $even)
|
||||
$tabRet[]=array('codeEven' => 'P'.$even,
|
||||
'nic' => 0,
|
||||
'siretAssocie'=>0,
|
||||
'typeSiretAss'=>0,
|
||||
'siege' => 1,
|
||||
'libEven' => $tabEven['p'.trim($even)],
|
||||
'libEvenDet'=> '',
|
||||
'dateMAJ' => $modif['dateInsert'],
|
||||
'dateEven' => $modif['flux'],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public function getIntervenants($siren) {
|
||||
$tabJuge=$this->getListeJugements($siren);
|
||||
$tabDepots=$tabDeja=array();
|
||||
$tabAdm=array( 'A'=>'Administrateur judiciaire',
|
||||
'C'=>'Commissaire au plan',
|
||||
'D'=>'Commissaire au concordat',
|
||||
'H'=>'Huissier',
|
||||
'J'=>'Juge Commissaire',
|
||||
'K'=>'Juge Commissaire suppléant',
|
||||
'L'=>'Liquidateur',
|
||||
'M'=>'Mandataire judiciaire',
|
||||
'N'=>'Notaire',
|
||||
'O'=>'Opposition',
|
||||
'R'=>'Représentant des créanciers',
|
||||
'S'=>'Syndic',
|
||||
'T'=>'Conciliateur',
|
||||
'U'=>'Curateur',
|
||||
'V'=>'Avocat',
|
||||
);
|
||||
foreach ($tabJuge as $iDepot=>$depot) {
|
||||
if ($depot['adm1code']>0 && !in_array($depot['adm1code'], $tabDeja)) {
|
||||
$tabDepots[]=array( 'codEven' => $depot['codEven'],
|
||||
'libEven' => $depot['libEven'],
|
||||
'dateEffet' => $depot['dateEffet'],
|
||||
'admid' => $depot['adm1id'],
|
||||
'admcode' => $depot['adm1code'],
|
||||
'admtype' => $depot['adm1type'],
|
||||
'admfonction' => $depot['adm1fonction'],
|
||||
'admnom' => $depot['adm1nom'],
|
||||
'admadrNum' => $depot['adm1adrNum'],
|
||||
'admadrInd' => $depot['adm1adrInd'],
|
||||
'admadrType' => $depot['adm1adrType'],
|
||||
'admadrVoie' => $depot['adm1adrVoie'], // @todo : adm1adr1, adm1adr2, adm1adr3,
|
||||
'admadr2' => $depot['adm1adr2'],
|
||||
'admadrCP' => $depot['adm1adrCP'],
|
||||
'admadrVille' => $depot['adm1adrVille'],
|
||||
);
|
||||
$tabDeja[]=$depot['adm1code'];
|
||||
}
|
||||
if ($depot['adm2code']>0 && !in_array($depot['adm2code'], $tabDeja)) {
|
||||
$tabDepots[]=array( 'codEven' => $depot['codEven'],
|
||||
'libEven' => $depot['libEven'],
|
||||
'dateEffet' => $depot['dateEffet'],
|
||||
'admid' => $depot['adm2id'],
|
||||
'admcode' => $depot['adm2code'],
|
||||
'admtype' => $depot['adm2type'],
|
||||
'admfonction' => $depot['adm2fonction'],
|
||||
'admnom' => $depot['adm2nom'],
|
||||
'admadrNum' => $depot['adm2adrNum'],
|
||||
'admadrInd' => $depot['adm2adrInd'],
|
||||
'admadrType' => $depot['adm2adrType'],
|
||||
'admadrVoie' => $depot['adm2adrVoie'], // @todo : adm1adr1, adm1adr2, adm1adr3,
|
||||
'admadr2' => $depot['adm2adr2'],
|
||||
'admadrCP' => $depot['adm2adrCP'],
|
||||
'admadrVille' => $depot['adm2adrVille'],
|
||||
);
|
||||
$tabDeja[]=$depot['adm2code'];
|
||||
}
|
||||
}
|
||||
if (count($tabDepots)>0) {
|
||||
$strTypes="IN ('J','K','H','V','N')";
|
||||
$forceRecherche=false;
|
||||
$strDates="AND ABS(DATEDIFF(dateJugement, '".$depot['dateEffet']."'))<60 ";
|
||||
} else {
|
||||
$strTypes="<>''";
|
||||
$forceRecherche=true;
|
||||
$strDates='';
|
||||
}
|
||||
|
||||
$tabTmp=$this->iDb->select('annonces', 'id, siren, typeEven, dateJugement, dateCessationPaiement, inter1type, inter1id, inter1nom, inter2type, inter2id, inter2nom, inter3type, inter3id, inter3nom, inter4type, inter4id, inter4nom,
|
||||
dateSource, dateInsert, source, tribunal, raisonSociale',"siren=$siren $strDates AND ( inter1type $strTypes OR inter2type $strTypes OR inter3type $strTypes OR inter4type $strTypes ) AND typeEven BETWEEN 1000 AND 2000 ORDER BY dateJugement DESC", false, MYSQL_ASSOC);
|
||||
if (isset($tabTmp[0])) {
|
||||
$depot=$tabTmp[0];
|
||||
$tabRet['dateCessationPaiement']=$depot['dateCessationPaiement'];
|
||||
for($i=1; $i<4; $i++) {
|
||||
if ( ($forceRecherche && !in_array($tabTmp['inter'.$i.'type'], $tabDeja)) ||
|
||||
( $tabTmp['inter'.$i.'type']=='J' || $tabTmp['inter'.$i.'type']=='K' ||
|
||||
$tabTmp['inter'.$i.'type']=='H' || $tabTmp['inter'.$i.'type']=='V' ||
|
||||
$tabTmp['inter'.$i.'type']=='N') ) {
|
||||
$tabDepots[]=array( 'codEven' => $depot['typeEven'],
|
||||
'libEven' => $depot['typeEven'],
|
||||
'dateEffet' => $depot['dateJugement'],
|
||||
'admid' => $depot['inter'.$i.'id'],
|
||||
'admcode' => $depot['inter'.$i.'id'],
|
||||
'admtype' => $depot['inter'.$i.'type'],
|
||||
'admfonction' => $tabAdm[$depot['inter'.$i.'type']],
|
||||
'admnom' => $depot['inter'.$i.'nom'],
|
||||
'admadrNum' => '',
|
||||
'admadrInd' => '',
|
||||
'admadrType' => '',
|
||||
'admadrVoie' => '',
|
||||
'admadr2' => '',
|
||||
'admadrCP' => '',
|
||||
'admadrVille' => '',
|
||||
);
|
||||
$tabDeja[]=$tabTmp['inter'.$i.'type'];
|
||||
}
|
||||
}
|
||||
}
|
||||
return $tabDepots;
|
||||
}
|
||||
|
||||
/** Mettre à jour un dossier IMR dans le prochain Flux
|
||||
* @param $siren Siren de l'entreprise à mettre à jour dans les IMR
|
||||
* @param $origineDemande Origine de la demande ('client', 'interne', 'privileges', 'ancienort')
|
||||
* @param $focerMAJ Forcer la mise à jour même si dossier déjà transmit
|
||||
*/
|
||||
public function majDossierIMR($siren, $origineDemande='', $focerMAJ=false) {
|
||||
|
||||
$this->infoIMR=array();
|
||||
if ($siren*1==0) {
|
||||
$this->libErreur='Siren invalide !';
|
||||
return false;
|
||||
}
|
||||
$query_timeout=5;
|
||||
$query_proxy='221.130.13.39';
|
||||
$query_proxy='61.35.191.250:8080';
|
||||
$query_proxy='198.7.242.41:3128';
|
||||
$query_proxy='';
|
||||
if (INFOGREFFE_DISPO_WEB) {
|
||||
/** Accueil **/
|
||||
$url='http://www.infogreffe.fr/ged-extranet/accueil.do';
|
||||
while (1) {
|
||||
//echo date('YmdHis')." - 1. Deb $url ".$this->codeRetour.EOL;
|
||||
$page=getUrl($url, '', '', $this->referer, false, 'www.infogreffe.fr', false, '', $query_proxy, $query_timeout);
|
||||
$this->codeRetour=$page['code'];
|
||||
//echo date('YmdHis')." - 1. FIN $url ".$this->codeRetour.EOL;
|
||||
if ($this->codeRetour<>'400') break;
|
||||
sleep(1);
|
||||
}
|
||||
$this->body=$page['body'];
|
||||
if ($this->codeRetour<>'200') {
|
||||
print_r($page);
|
||||
$this->libErreur='Erreur Infogreffe 200a !';
|
||||
return false;
|
||||
}
|
||||
$this->cookie=$page['header']['Set-Cookie'];
|
||||
$this->referer=$url;
|
||||
sleep(1);
|
||||
|
||||
/** Formulaire de login **/
|
||||
$url='http://www.infogreffe.fr/ged-extranet/connexion.do';
|
||||
while (1) {
|
||||
//echo date('YmdHis')." - 2. Deb $url ".$this->codeRetour.EOL;
|
||||
$page=getUrl($url, '', '', $this->referer, false, 'www.infogreffe.fr', false, '', $query_proxy, $query_timeout);
|
||||
//echo date('YmdHis')." - 2. FIN $url ".$this->codeRetour.EOL;
|
||||
$this->codeRetour=$page['code'];
|
||||
if ($this->codeRetour<>'400') break;
|
||||
sleep(1);
|
||||
}
|
||||
$this->body=$page['body'];
|
||||
if ($this->codeRetour<>'200') {
|
||||
print_r($page);
|
||||
$this->libErreur='Erreur Infogreffe 200b !';
|
||||
return false;
|
||||
}
|
||||
$this->referer=$url;
|
||||
sleep(1);
|
||||
|
||||
/** Etape de logon **/
|
||||
$url='http://www.infogreffe.fr/ged-extranet/login.do';
|
||||
$postData=array('codeClient'=>'0034',
|
||||
'codeAbonne'=>'0002',
|
||||
'password'=>'369852',
|
||||
);
|
||||
while (1) {
|
||||
//echo date('YmdHis')." - 3. Deb $url ".$this->codeRetour.EOL;
|
||||
$page=getUrl($url, $this->cookie, $postData, $this->referer, false, 'www.infogreffe.fr', false, '', $query_proxy, $query_timeout);
|
||||
$this->codeRetour=$page['code'];
|
||||
//echo date('YmdHis')." - 3. FIN $url ".$this->codeRetour.EOL;
|
||||
if ($this->codeRetour<>'400') break;
|
||||
sleep(1);
|
||||
}
|
||||
$this->body=$page['body'];
|
||||
if ($this->codeRetour<>'200') {
|
||||
print_r($page);
|
||||
$this->libErreur='Erreur Infogreffe 200c !';
|
||||
return false;
|
||||
}
|
||||
if (!preg_match('/Bienvenue SCORES ET DECISIONS/', $this->body)) {
|
||||
$this->libErreur='Erreur Infogreffe Extranet : Connexion incorrecte !';
|
||||
return false;
|
||||
}
|
||||
$this->referer=$url;
|
||||
sleep(1);
|
||||
|
||||
/** Page de formulaire de demande de réémission de dossier IMR **/
|
||||
$url='http://www.infogreffe.fr/ged-extranet/demandeReemissions.do';
|
||||
while (1) {
|
||||
//echo date('YmdHis')." - 4. Deb $url ".$this->codeRetour.EOL;
|
||||
$page=getUrl($url, $this->cookie, '', $this->referer, false, 'www.infogreffe.fr', false, '', $query_proxy, $query_timeout);
|
||||
$this->codeRetour=$page['code'];
|
||||
//echo date('YmdHis')." - 4. FIN $url ".$this->codeRetour.EOL;
|
||||
if ($this->codeRetour<>'400') break;
|
||||
sleep(1);
|
||||
}
|
||||
$this->body=$page['body'];
|
||||
if ($this->codeRetour<>'200') {
|
||||
print_r($page);
|
||||
$this->libErreur='Erreur Infogreffe 200d !';
|
||||
return false;
|
||||
}
|
||||
$this->referer=$url;
|
||||
sleep(1);
|
||||
|
||||
/** Saisie du siren à contrôler dans le formulaire AJAX adéquat **/
|
||||
$url='http://www.infogreffe.fr/ged-extranet/rechercheReemissions.do';
|
||||
$postData=array('siren'=>$siren);
|
||||
//$page=getUrl($url, $this->cookie, $postData, $this->referer, false, 'www.infogreffe.fr', false, '', '', 5);
|
||||
while (1) {
|
||||
//echo date('YmdHis')." - 5. Deb $url ".$this->codeRetour.EOL;
|
||||
$page=getUrl($url, $this->cookie, $postData, $this->referer, false, 'www.infogreffe.fr', false, '', $query_proxy, $query_timeout);
|
||||
$this->codeRetour=$page['code'];
|
||||
//echo date('YmdHis')." - 5. FIN $url ".$this->codeRetour.EOL;
|
||||
if ($this->codeRetour<>'400') break;
|
||||
sleep(1);
|
||||
}
|
||||
$this->body=$page['body'];
|
||||
if ($this->codeRetour<>'200') {
|
||||
print_r($page);
|
||||
$this->libErreur='Erreur Infogreffe 200e !';
|
||||
return false;
|
||||
}
|
||||
$this->referer=$url;
|
||||
|
||||
// Le retour AJAX est il positif ?
|
||||
if (preg_match('/<div class="message-erreur">(.*)<\/div>/Uis', $this->body, $matches))
|
||||
$this->infoIMR['message-erreur']=trim(preg_replace('/ +/',' ',strip_tags($matches[1])));
|
||||
|
||||
if (preg_match('/<div class="titreEntreprise">(?:.*)<b>(.*)<\/b>(?:.*)<\/div>/Uis', $this->body, $matches))
|
||||
$this->infoIMR['titreEntreprise']=trim(preg_replace('/ +/',' ',strip_tags($matches[1])));
|
||||
|
||||
if (preg_match('/<div id="adresse">(.*)<\/div>/Uis', $this->body, $matches))
|
||||
$this->infoIMR['adresse']=trim(preg_replace('/ +/',' ',strip_tags($matches[1])));
|
||||
|
||||
if (preg_match('/<div class="struct-erreur">(?:.*)<b>(.*)<\/b>(?:.*)<\/div>/Uis', $this->body, $matches))
|
||||
$this->infoIMR['struct-erreur']=trim(preg_replace('/ +/',' ',strtr(strip_tags($matches[1]),"\r\n\t".chr(160),' ')));
|
||||
|
||||
if (preg_match('/Cliquez sur le bouton VALIDER pour confirmer votre demande de/', $this->body, $matches))
|
||||
$this->infoIMR['validation']=true;
|
||||
else {
|
||||
$this->infoIMR['validation']=false;
|
||||
if (preg_match('/Aucune entreprise trouv.e pour ce num.ro SIREN/', $this->body)) {
|
||||
$tabInsert=$this->infoIMR;
|
||||
$tabInsert['siren']=$siren;
|
||||
$tabInsert['dateDemande']=date('Ymd');
|
||||
if ($origineDemande<>'')
|
||||
$tabInsert['origineDemande']=$origineDemande;
|
||||
$this->iDb->insert('rncs_demandes', $tabInsert, false);
|
||||
}
|
||||
}
|
||||
|
||||
if (preg_match('/atteint le nombre maximal de(.*)Veuillez renouveler votre demande demain/',
|
||||
$this->infoIMR['message-erreur']))
|
||||
return false;
|
||||
|
||||
if ($this->infoIMR['validation'] && $this->infoIMR['message-erreur']=='') {
|
||||
/** Doit on forcer la maj si l'entreprise a été transmise récemment ? **/
|
||||
if ($this->infoIMR['struct-erreur']<>'' && !$focerMAJ)
|
||||
return true;
|
||||
|
||||
sleep(1);
|
||||
/** Validation du siren à réémettre en IMR **/
|
||||
$url='http://www.infogreffe.fr/ged-extranet/validerDemandeReemission.do';
|
||||
$postData=array('numIdentification'=>$siren);
|
||||
//$page=getUrl($url, $this->cookie, $postData, $this->referer, false, 'www.infogreffe.fr', false, '', '', 5);
|
||||
while (1) {
|
||||
//echo date('YmdHis')." - 6. Deb $url ".$this->codeRetour.EOL;
|
||||
$page=getUrl($url, $this->cookie, $postData, $this->referer, false, 'www.infogreffe.fr', false, '', $query_proxy, $query_timeout);
|
||||
$this->codeRetour=$page['code'];
|
||||
//echo date('YmdHis')." - 6. FIN $url ".$this->codeRetour.EOL;
|
||||
if ($this->codeRetour<>'400') break;
|
||||
sleep(1);
|
||||
}
|
||||
$this->body=$page['body'];
|
||||
$this->codeRetour=$page['code'];
|
||||
if ($this->codeRetour<>'200') {
|
||||
$this->libErreur='Erreur Infogreffe 200f !';
|
||||
return false;
|
||||
}
|
||||
$this->referer=$url;
|
||||
// Lecture du retour
|
||||
if (preg_match('/<div class="message-erreur">(.*)<\/div>/Uis', $this->body, $matches))
|
||||
$this->infoIMR['validation-erreur']=trim(preg_replace('/ +/',' ',strip_tags($matches[1])));
|
||||
if (preg_match('/<b class="texte-bleu">(.*)<\/b>/Uis', $this->body, $matches))
|
||||
$this->infoIMR['validation-ok']=trim(preg_replace('/ +/',' ',strip_tags($matches[1])));
|
||||
|
||||
$tabInsert=$this->infoIMR;
|
||||
$tabInsert['siren']=$siren;
|
||||
$tabInsert['dateDemande']=date('Ymd');
|
||||
if ($origineDemande<>'')
|
||||
$tabInsert['origineDemande']=$origineDemande;
|
||||
$this->iDb->insert('rncs_demandes', $tabInsert, false);
|
||||
|
||||
// Une erreur ?
|
||||
if ($this->infoIMR['validation-erreur']<>'')
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
} else
|
||||
$this->libErreur='Infogreffe indisponible !';
|
||||
return false;
|
||||
}
|
||||
}
|
||||
?>
|
1028
library/Metier/partenaires/classMRncsFlux.php
Normal file
1028
library/Metier/partenaires/classMRncsFlux.php
Normal file
File diff suppressed because it is too large
Load Diff
922
library/Metier/partenaires/classMRncsFlux2.php
Normal file
922
library/Metier/partenaires/classMRncsFlux2.php
Normal file
@ -0,0 +1,922 @@
|
||||
<?
|
||||
global $tabOrt2Sd;
|
||||
$tabOrt2Sd=array( '_130000001'=>'SIREN',
|
||||
'_103000040'=>'CONSOLIDE',
|
||||
'_103000033'=>'DATE_CLOTURE',
|
||||
'_103000023'=>'DUREE_MOIS',
|
||||
'_103000202'=>'MONNAIE_ORI',
|
||||
'_103000205'=>'MONNAIE_ORI_UNITE',
|
||||
'_103000211'=>'MONNAIE',
|
||||
'_103000214'=>'MONNAIE_LIV_UNITE',
|
||||
'_103000029'=>'AVIS_CAC',
|
||||
'_130000009'=>'CODE_NAF',
|
||||
'_103101001'=>'AA',
|
||||
'_103101002'=>'AB',
|
||||
'_103101003'=>'AC',
|
||||
'_103101004'=>'AC1',
|
||||
'_103101005'=>'AD',
|
||||
'_103101006'=>'AE',
|
||||
'_103101007'=>'AE1',
|
||||
'_103101008'=>'AF',
|
||||
'_103101009'=>'AG',
|
||||
'_103101010'=>'AG1',
|
||||
'_103101011'=>'AH',
|
||||
'_103101012'=>'AI',
|
||||
'_103101013'=>'AI1',
|
||||
'_103101014'=>'AJ',
|
||||
'_103101015'=>'AK',
|
||||
'_103101016'=>'AK1',
|
||||
'_103101017'=>'AL',
|
||||
'_103101018'=>'AM',
|
||||
'_103101019'=>'AM1',
|
||||
'_103101020'=>'AN',
|
||||
'_103101021'=>'AO',
|
||||
'_103101022'=>'AO1',
|
||||
'_103101023'=>'AP',
|
||||
'_103101024'=>'AQ',
|
||||
'_103101025'=>'AQ1',
|
||||
'_103101026'=>'AR',
|
||||
'_103101027'=>'AS',
|
||||
'_103101028'=>'AS1',
|
||||
'_103101029'=>'AT',
|
||||
'_103101030'=>'AU',
|
||||
'_103101031'=>'AU1',
|
||||
'_103101032'=>'AV',
|
||||
'_103101033'=>'AW',
|
||||
'_103101034'=>'AW1',
|
||||
'_103101035'=>'AX',
|
||||
'_103101036'=>'AY',
|
||||
'_103101037'=>'AY1',
|
||||
'_103101038'=>'CS',
|
||||
'_103101039'=>'CT',
|
||||
'_103101040'=>'CT1',
|
||||
'_103101041'=>'CU',
|
||||
'_103101042'=>'CV',
|
||||
'_103101043'=>'CV1',
|
||||
'_103101044'=>'BB',
|
||||
'_103101045'=>'BC',
|
||||
'_103101046'=>'BC1',
|
||||
'_103101047'=>'BD',
|
||||
'_103101048'=>'BE',
|
||||
'_103101049'=>'BE1',
|
||||
'_103101050'=>'BF',
|
||||
'_103101051'=>'BG',
|
||||
'_103101052'=>'BG1',
|
||||
'_103101053'=>'BH',
|
||||
'_103101054'=>'BI',
|
||||
'_103101055'=>'BI1',
|
||||
'_103101056'=>'BJ',
|
||||
'_103101057'=>'BK',
|
||||
'_103101058'=>'BK1',
|
||||
'_103101059'=>'BL',
|
||||
'_103101060'=>'BM',
|
||||
'_103101061'=>'BM1',
|
||||
'_103101062'=>'BN',
|
||||
'_103101063'=>'BO',
|
||||
'_103101064'=>'BO1',
|
||||
'_103101065'=>'BP',
|
||||
'_103101066'=>'BQ',
|
||||
'_103101067'=>'BQ1',
|
||||
'_103101068'=>'BR',
|
||||
'_103101069'=>'BS',
|
||||
'_103101070'=>'BS1',
|
||||
'_103101071'=>'BT',
|
||||
'_103101072'=>'BU',
|
||||
'_103101073'=>'BU1',
|
||||
'_103101074'=>'BV',
|
||||
'_103101075'=>'BW',
|
||||
'_103101076'=>'BW1',
|
||||
'_103101077'=>'BX',
|
||||
'_103101078'=>'BY',
|
||||
'_103101079'=>'BY1',
|
||||
'_103101080'=>'BZ',
|
||||
'_103101081'=>'CA',
|
||||
'_103101082'=>'CA1',
|
||||
'_103101083'=>'CB',
|
||||
'_103101084'=>'CC',
|
||||
'_103101085'=>'CC1',
|
||||
'_103101086'=>'CD',
|
||||
'_103101087'=>'CE',
|
||||
'_103101088'=>'CE1',
|
||||
'_103101089'=>'CF',
|
||||
'_103101090'=>'CG',
|
||||
'_103101091'=>'CG1',
|
||||
'_103101092'=>'CH',
|
||||
'_103101093'=>'CI',
|
||||
'_103101094'=>'CI1',
|
||||
'_103101095'=>'CJ',
|
||||
'_103101096'=>'CK',
|
||||
'_103101097'=>'CK1',
|
||||
'_103101098'=>'CL',
|
||||
'_103101099'=>'CM',
|
||||
'_103101100'=>'CN',
|
||||
'_103101101'=>'CO',
|
||||
'_103101102'=>'1A',
|
||||
'_103101103'=>'1A1',
|
||||
'_103101104'=>'CP',
|
||||
'_103101105'=>'CR',
|
||||
'_103102001'=>'DA',
|
||||
'_103102002'=>'DB',
|
||||
'_103102003'=>'EK',
|
||||
'_103102004'=>'DC',
|
||||
'_103102005'=>'DD',
|
||||
'_103102006'=>'DE',
|
||||
'_103102007'=>'DF',
|
||||
'_103102008'=>'DG',
|
||||
'_103102009'=>'DH',
|
||||
'_103102010'=>'DI',
|
||||
'_103102011'=>'DJ',
|
||||
'_103102012'=>'DK',
|
||||
'_103102013'=>'DL',
|
||||
'_103102014'=>'DM',
|
||||
'_103102015'=>'DN',
|
||||
'_103102016'=>'DO',
|
||||
'_103102017'=>'DP',
|
||||
'_103102018'=>'DQ',
|
||||
'_103102019'=>'DR',
|
||||
'_103102020'=>'DS',
|
||||
'_103102021'=>'DT',
|
||||
'_103102022'=>'DU',
|
||||
'_103102023'=>'DV',
|
||||
'_103102024'=>'DW',
|
||||
'_103102025'=>'DX',
|
||||
'_103102026'=>'DY',
|
||||
'_103102027'=>'DZ',
|
||||
'_103102028'=>'EA',
|
||||
'_103102029'=>'EB',
|
||||
'_103102030'=>'EC',
|
||||
'_103102031'=>'ED',
|
||||
'_103102032'=>'EE',
|
||||
'_103102033'=>'EF',
|
||||
'_103102034'=>'EG',
|
||||
'_103102035'=>'EH',
|
||||
'_103102036'=>'EI',
|
||||
'_103103001'=>'FA',
|
||||
'_103103002'=>'FB',
|
||||
'_103103003'=>'FC',
|
||||
'_103103004'=>'FD',
|
||||
'_103103005'=>'FE',
|
||||
'_103103006'=>'FF',
|
||||
'_103103007'=>'FG',
|
||||
'_103103008'=>'FH',
|
||||
'_103103009'=>'FI',
|
||||
'_103103010'=>'FJ',
|
||||
'_103103011'=>'FK',
|
||||
'_103103012'=>'FL',
|
||||
'_103103013'=>'FM',
|
||||
'_103103014'=>'FN',
|
||||
'_103103015'=>'FO',
|
||||
'_103103016'=>'FP',
|
||||
'_103103017'=>'FQ',
|
||||
'_103103018'=>'FR',
|
||||
'_103103019'=>'FS',
|
||||
'_103103020'=>'FT',
|
||||
'_103103021'=>'FU',
|
||||
'_103103022'=>'FV',
|
||||
'_103103023'=>'FW',
|
||||
'_103103024'=>'FX',
|
||||
'_103103025'=>'FY',
|
||||
'_103103026'=>'FZ',
|
||||
'_103103027'=>'GA',
|
||||
'_103103028'=>'GB',
|
||||
'_103103029'=>'GC',
|
||||
'_103103030'=>'GD',
|
||||
'_103103031'=>'GE',
|
||||
'_103103032'=>'GF',
|
||||
'_103103033'=>'GG',
|
||||
'_103103034'=>'GH',
|
||||
'_103103035'=>'GI',
|
||||
'_103103036'=>'GJ',
|
||||
'_103103037'=>'GK',
|
||||
'_103103038'=>'GL',
|
||||
'_103103039'=>'GM',
|
||||
'_103103040'=>'GN',
|
||||
'_103103041'=>'GO',
|
||||
'_103103042'=>'GP',
|
||||
'_103103043'=>'GQ',
|
||||
'_103103044'=>'GR',
|
||||
'_103103045'=>'GS',
|
||||
'_103103046'=>'GT',
|
||||
'_103103047'=>'GU',
|
||||
'_103103048'=>'GV',
|
||||
'_103103049'=>'GW',
|
||||
'_103103050'=>'HA',
|
||||
'_103103051'=>'HB',
|
||||
'_103103052'=>'HC',
|
||||
'_103103053'=>'HD',
|
||||
'_103103054'=>'HE',
|
||||
'_103103055'=>'HF',
|
||||
'_103103056'=>'HG',
|
||||
'_103103057'=>'HH',
|
||||
'_103103058'=>'HI',
|
||||
'_103103059'=>'HJ',
|
||||
'_103103060'=>'HK',
|
||||
'_103103061'=>'HL',
|
||||
'_103103062'=>'HM',
|
||||
'_103103063'=>'HN',
|
||||
'_103103064'=>'HP',
|
||||
'_103103065'=>'HQ',
|
||||
'_103104077'=>'A1',
|
||||
'_103104078'=>'A2',
|
||||
'_103104079'=>'A3',
|
||||
'_103104080'=>'A4',
|
||||
'_103104001'=>'KF',
|
||||
'_103104002'=>'LP',
|
||||
'_103104003'=>'0J',
|
||||
'_103104004'=>'MY',
|
||||
'_103104005'=>'NC',
|
||||
'_103104006'=>'2E',
|
||||
'_103104007'=>'0K',
|
||||
'_103104008'=>'PD',
|
||||
'_103104009'=>'PH',
|
||||
'_103104010'=>'QX',
|
||||
'_103104011'=>'ON',
|
||||
'_103104012'=>'OP',
|
||||
'_103104013'=>'OQ',
|
||||
'_103104014'=>'OR',
|
||||
'_103104015'=>'SM',
|
||||
'_103104016'=>'SP',
|
||||
'_103104017'=>'5R',
|
||||
'_103104018'=>'5S',
|
||||
'_103104019'=>'5T',
|
||||
'_103104020'=>'5U',
|
||||
'_103104021'=>'7B',
|
||||
'_103104022'=>'TY',
|
||||
'_103104023'=>'TZ',
|
||||
'_103104024'=>'UA',
|
||||
'_103104025'=>'UF',
|
||||
'_103104026'=>'UH',
|
||||
'_103104027'=>'UK',
|
||||
'_103104028'=>'UM',
|
||||
'_103104029'=>'UR',
|
||||
'_103104030'=>'UV',
|
||||
'_103104031'=>'VA',
|
||||
'_103104032'=>'UY',
|
||||
'_103104033'=>'UZ',
|
||||
'_103104034'=>'VB',
|
||||
'_103104035'=>'VN',
|
||||
'_103104036'=>'VT',
|
||||
'_103104037'=>'VU',
|
||||
'_103104038'=>'VV',
|
||||
'_103104039'=>'7Y1',
|
||||
'_103104040'=>'7Z1',
|
||||
'_103104041'=>'VG',
|
||||
'_103104042'=>'VG1',
|
||||
'_103104043'=>'VH',
|
||||
'_103104044'=>'VH1',
|
||||
'_103104045'=>'8A1',
|
||||
'_103104046'=>'8B1',
|
||||
'_103104047'=>'8C',
|
||||
'_103104048'=>'8C1',
|
||||
'_103104049'=>'8D',
|
||||
'_103104050'=>'8D1',
|
||||
'_103104051'=>'8E1',
|
||||
'_103104052'=>'VW',
|
||||
'_103104053'=>'VW1',
|
||||
'_103104054'=>'VX',
|
||||
'_103104055'=>'VX1',
|
||||
'_103104056'=>'VQ',
|
||||
'_103104057'=>'VQ1',
|
||||
'_103104058'=>'8J1',
|
||||
'_103104059'=>'VI',
|
||||
'_103104060'=>'VI1',
|
||||
'_103104061'=>'8K1',
|
||||
'_103104062'=>'SZ1',
|
||||
'_103104063'=>'8L1',
|
||||
'_103104064'=>'VY',
|
||||
'_103104065'=>'VZ',
|
||||
'_103104066'=>'VZ1',
|
||||
'_103104067'=>'VZ2',
|
||||
'_103104068'=>'YQ',
|
||||
'_103104069'=>'YR',
|
||||
'_103104070'=>'YS',
|
||||
'_103104071'=>'YT',
|
||||
'_103104072'=>'YU',
|
||||
'_103104073'=>'YV',
|
||||
'_103104074'=>'YY',
|
||||
'_103104075'=>'YZ',
|
||||
'_103104076'=>'YP',
|
||||
'_103104081'=>'CZ',
|
||||
'_103104082'=>'KB',
|
||||
'_103104083'=>'KC',
|
||||
'_103104084'=>'KD',
|
||||
'_103104085'=>'KE',
|
||||
'_103104086'=>'LN',
|
||||
'_103104087'=>'LO',
|
||||
'_103104088'=>'LQ',
|
||||
'_103104089'=>'LR',
|
||||
'_103104090'=>'LS',
|
||||
'_103104091'=>'0G',
|
||||
'_103104092'=>'0H',
|
||||
'_103104093'=>'NL',
|
||||
'_103104094'=>'LT',
|
||||
'_103104095'=>'LU',
|
||||
'_103104096'=>'NO',
|
||||
'_103104097'=>'LV',
|
||||
'_103104098'=>'LW',
|
||||
'_103104099'=>'NN',
|
||||
'_103104100'=>'NG',
|
||||
'_103104101'=>'NH',
|
||||
'_103104102'=>'NM',
|
||||
'_103104103'=>'NJ',
|
||||
'_103104104'=>'NK',
|
||||
'_103104105'=>'NP',
|
||||
'_103104106'=>'0L',
|
||||
'_103104107'=>'PA',
|
||||
'_103104108'=>'PB',
|
||||
'_103104109'=>'PC',
|
||||
'_103104110'=>'PE',
|
||||
'_103104111'=>'PF',
|
||||
'_103104112'=>'PG',
|
||||
'_103104113'=>'QU',
|
||||
'_103104114'=>'QV',
|
||||
'_103104115'=>'QW',
|
||||
'_103104116'=>'Z91',
|
||||
'_103104117'=>'Z92',
|
||||
'_103104118'=>'SN',
|
||||
'_103104119'=>'SP_1',
|
||||
'_103104120'=>'SP_2',
|
||||
'_103104121'=>'SR',
|
||||
'_103104122'=>'TO',
|
||||
'_103104123'=>'3Z',
|
||||
'_103104124'=>'TS',
|
||||
'_103104125'=>'TT',
|
||||
'_103104126'=>'TU',
|
||||
'_103104127'=>'4D',
|
||||
'_103104128'=>'4H',
|
||||
'_103104129'=>'4M',
|
||||
'_103104130'=>'4S',
|
||||
'_103104131'=>'4W',
|
||||
'_103104132'=>'5A',
|
||||
'_103104133'=>'5E',
|
||||
'_103104134'=>'5K',
|
||||
'_103104135'=>'5P',
|
||||
'_103104136'=>'5Y',
|
||||
'_103104137'=>'5Z',
|
||||
'_103104138'=>'TV',
|
||||
'_103104139'=>'TW',
|
||||
'_103104140'=>'TX',
|
||||
'_103104141'=>'6A',
|
||||
'_103104142'=>'6B',
|
||||
'_103104143'=>'6C',
|
||||
'_103104144'=>'6D',
|
||||
'_103104145'=>'6E',
|
||||
'_103104146'=>'6F',
|
||||
'_103104147'=>'6G',
|
||||
'_103104148'=>'6H',
|
||||
'_103104149'=>'02',
|
||||
'_103104150'=>'03',
|
||||
'_103104151'=>'04',
|
||||
'_103104152'=>'05',
|
||||
'_103104153'=>'06',
|
||||
'_103104154'=>'07',
|
||||
'_103104155'=>'08',
|
||||
'_103104156'=>'09',
|
||||
'_103104157'=>'6N',
|
||||
'_103104158'=>'6P',
|
||||
'_103104159'=>'6R',
|
||||
'_103104160'=>'6S',
|
||||
'_103104161'=>'6T',
|
||||
'_103104162'=>'6U',
|
||||
'_103104163'=>'6V',
|
||||
'_103104164'=>'6W',
|
||||
'_103104165'=>'6X',
|
||||
'_103104166'=>'6Y',
|
||||
'_103104167'=>'6Z',
|
||||
'_103104168'=>'7A',
|
||||
'_103104169'=>'7C',
|
||||
'_103104170'=>'UB',
|
||||
'_103104171'=>'UC',
|
||||
'_103104172'=>'UD',
|
||||
'_103104173'=>'UE',
|
||||
'_103104174'=>'UG',
|
||||
'_103104175'=>'UJ',
|
||||
'_103104176'=>'UL',
|
||||
'_103104177'=>'UP',
|
||||
'_103104178'=>'UT',
|
||||
'_103104179'=>'UX',
|
||||
'_103104180'=>'UQ',
|
||||
'_103104181'=>'UU',
|
||||
'_103104182'=>'VM',
|
||||
'_103104183'=>'VP',
|
||||
'_103104184'=>'VC',
|
||||
'_103104185'=>'VR',
|
||||
'_103104186'=>'VS',
|
||||
'_103104187'=>'7Y',
|
||||
'_103104188'=>'7Y2',
|
||||
'_103104189'=>'7Z',
|
||||
'_103104190'=>'7Z2',
|
||||
'_103104191'=>'VG2',
|
||||
'_103104192'=>'VH2',
|
||||
'_103104193'=>'8A',
|
||||
'_103104194'=>'8A2',
|
||||
'_103104195'=>'8B',
|
||||
'_103104196'=>'8B2',
|
||||
'_103104197'=>'8C2',
|
||||
'_103104198'=>'8D2',
|
||||
'_103104199'=>'8E',
|
||||
'_103104200'=>'8E2',
|
||||
'_103104201'=>'VW2',
|
||||
'_103104202'=>'VX2',
|
||||
'_103104203'=>'VQ2',
|
||||
'_103104204'=>'8J',
|
||||
'_103104205'=>'8J2',
|
||||
'_103104206'=>'8J3',
|
||||
'_103104207'=>'VI2',
|
||||
'_103104208'=>'VI3',
|
||||
'_103104209'=>'8K',
|
||||
'_103104210'=>'8K2',
|
||||
'_103104211'=>'SZ',
|
||||
'_103104212'=>'SZ2',
|
||||
'_103104213'=>'8L',
|
||||
'_103104214'=>'8L2',
|
||||
'_103104215'=>'VJ',
|
||||
'_103104216'=>'VK',
|
||||
'_103104217'=>'ZE',
|
||||
'_103104218'=>'XQ',
|
||||
'_103104219'=>'SS',
|
||||
'_103104220'=>'ST',
|
||||
'_103104221'=>'ZJ',
|
||||
'_103104222'=>'YW',
|
||||
'_103104223'=>'9Z',
|
||||
'_103104224'=>'YX',
|
||||
'_103104225'=>'9X',
|
||||
'_103102037'=>'B1',
|
||||
'_103102038'=>'EJ',
|
||||
);
|
||||
|
||||
require_once 'framework/common/curl.php';
|
||||
|
||||
define('RNCS_WS_URL', 'http://www.services.ort.fr/ProtocoleRNCS/access');
|
||||
define('RNCS_WS_USER', '167260');
|
||||
define('RNCS_WS_PASS', '100356');
|
||||
|
||||
class MRncsFlux {
|
||||
|
||||
public $body = '';
|
||||
public $header = '';
|
||||
public $codeRetour = 0;
|
||||
public $errMsgInpi='';
|
||||
public $errNumInpi='';
|
||||
public $cookie='';
|
||||
public $iDb;
|
||||
public $tabVitrine=array();
|
||||
|
||||
|
||||
public $tabErreurInpi=array(0=>"Aucune erreur",
|
||||
10=>"Erreur de protocole avec système distant",
|
||||
11=>"Système distant inaccessible",
|
||||
101=>"Type de requête invalide",
|
||||
102=>"Code d'erreur appelant invalide",
|
||||
103=>"Identification non reconnue",
|
||||
107=>"Date invalide",
|
||||
108=>"Heure invalide",
|
||||
110=>"Code produit inconnu",
|
||||
115=>"Numéro de champ invalide",
|
||||
116=>"Longueur de champ invalide",
|
||||
121=>"Code de protocole invalide",
|
||||
122=>"Code base de données invalide",
|
||||
900=>"Erreur applicative",
|
||||
990100=>"+ de 50 entreprises trouvées",
|
||||
990101=>"Recherche complexe",
|
||||
990102=>"Critères saisis insuffisants",
|
||||
990103=>"Requête trop imprécise",
|
||||
990104=>"Dénomination non significative",
|
||||
990105=>"Critère commune non générall",
|
||||
990106=>"Critère voie trop général",
|
||||
990107=>"Commune obligatoire avec rue",
|
||||
990108=>"Commune non identifiée",
|
||||
990109=>"Entreprise non identifiée",
|
||||
990110=>"Erreur système",
|
||||
990111=>"Devise incorrecte",
|
||||
990112=>"Autre erreur",
|
||||
990113=>"Donnée incorrecte",
|
||||
990114=>"Valeur incohérente",
|
||||
990115=>"Surveillance impossible",
|
||||
990116=>"Entreprise non surveillée",
|
||||
990117=>"Entreprise déjà surveillée",
|
||||
990118=>"Produit indisponible",
|
||||
990119=>"Erreur base de données",
|
||||
990120=>"Erreur facturation",
|
||||
);
|
||||
|
||||
function __construct() {
|
||||
$this->iDb=new WDB();
|
||||
}
|
||||
|
||||
function getVitrine($siren) {
|
||||
$this->tabVitrine=$this->query($siren, array('Type'=>'QVIT'));
|
||||
return $this->tabVitrine;
|
||||
}
|
||||
|
||||
/*
|
||||
$cmdPages=$cmdNom='';
|
||||
|
||||
if (isset($_REQUEST['pages'])) $cmdPages=$_REQUEST['pages'];
|
||||
if (isset($_REQUEST['nom'])) $cmdNom=$_REQUEST['nom'];
|
||||
if (isset($_REQUEST['vue'])) $vue=$_REQUEST['vue'];
|
||||
|
||||
if ($vue=='bilans') $presta='12004';
|
||||
else $presta='12003';
|
||||
|
||||
if ($cmdNom && $cmdPages) $type='QDOC';
|
||||
else $type='QVIT';
|
||||
$prod=array('Type'=>$type,
|
||||
'Presta'=>$presta,
|
||||
'Num'=>'2',//2,
|
||||
'Ver'=>'2',//2,
|
||||
'Siren'=>$siren,
|
||||
'CmdNom'=>$cmdNom,
|
||||
'CmdPages'=>$cmdPages,
|
||||
'CmdBilan'=>'',
|
||||
);
|
||||
|
||||
$ref='';
|
||||
*/
|
||||
|
||||
public function query($siren, $prod=array()) {
|
||||
/*$prod=array('Type'=>$type,
|
||||
'Presta'=>$presta,
|
||||
'Siren'=>$siren,
|
||||
'CmdNom'=>$cmdNom,
|
||||
'CmdPages'=>$cmdPages,
|
||||
'CmdBilan'=>'',
|
||||
'Ref'=>'',
|
||||
);
|
||||
*/
|
||||
$option='';
|
||||
if ( ($prod['Type']=='QDOC' || $prod['Presta']==12004 || $prod['Presta']==12003) && !isset($prod['Num'])) {
|
||||
$prod['Num']=2;
|
||||
$prod['Ver']=2;
|
||||
} elseif (!isset($prod['Num'])) {
|
||||
$prod['Num']=1;
|
||||
$prod['Ver']=3;
|
||||
}
|
||||
|
||||
$req= '<?xml version="1.0" ?>'. "\n".
|
||||
'<ort:message xmlns:ort="http://www.ort.fr/NEWPORT/V2">'. "\n".
|
||||
' <ort:_1 type="110">'. "\n".
|
||||
' <ort:_7 type="010">NPORT</ort:_7>'. "\n".
|
||||
' <ort:_8 type="010">2</ort:_8>'. "\n". // Version du protocole
|
||||
' <ort:_9 type="010">1</ort:_9>'. "\n". // Version du dictionnaire
|
||||
' <ort:_10 type="010">1</ort:_10>'. "\n". // Code protocole/version application
|
||||
' <ort:_11 type="010">PROTORNCS</ort:_11>'. "\n".
|
||||
' <ort:_12 type="010">'.$prod['Type'].'</ort:_12>'. "\n". // Prestation souhaitée QVIT / QDOC
|
||||
' <ort:_13 type="010">0</ort:_13>'. "\n". // Code retour/erreur
|
||||
' <ort:_14 type="010">'.RNCS_WS_USER.RNCS_WS_PASS.'</ort:_14>'."\n". // User Password concaténés
|
||||
' <ort:_15 type="010">'.$prod['Ref'].'</ort:_15>'. "\n". // Réf.
|
||||
' <ort:_16 type="010">'.date('Ymd').'</ort:_16>'. "\n". // Date SSAAMMJJ
|
||||
' <ort:_17 type="010">'.date('His').'</ort:_17>'. "\n". // Heure HHMMSS
|
||||
' <ort:_19 type="010">ORT</ort:_19>'. "\n".
|
||||
' </ort:_1>'. "\n".
|
||||
' <ort:_2 type="110">'. "\n".
|
||||
' <ort:_1 type="110">'. "\n".
|
||||
' <ort:_26 type="010">'.$prod['Prod'].'</ort:_26>'. "\n". // Type de produit (vide pour QVIT)
|
||||
' <ort:_27 type="010">'.$prod['Num'].'</ort:_27>'. "\n". // Numéro de produit souhaité 1 2
|
||||
' <ort:_28 type="010">'.$prod['Ver'].'</ort:_28>'. "\n". // Version du produit 3 2
|
||||
' <ort:_31 type="010">'.$prod['Presta'].'</ort:_31>'. "\n". // Code prestation (vide pour QVIT)
|
||||
' </ort:_1>'. "\n";
|
||||
if ($prod['Presta']==12004 || $prod['Presta']==12003) {
|
||||
$req.='
|
||||
<ort:_2 type="110">
|
||||
<ort:_100 type="111">
|
||||
<ort:_101 type="110">
|
||||
<ort:_120000031 type="010">'.$prod['Presta'].'</ort:_120000031>
|
||||
<ort:_100700010 type="010">FTP</ort:_100700010>
|
||||
<ort:_100701000 type="010">NTIF</ort:_100701000>
|
||||
<ort:_120000015 type="010" />
|
||||
</ort:_101>
|
||||
</ort:_100>
|
||||
<ort:_200 type="111">
|
||||
<ort:_210 type="110">
|
||||
<ort:_130000001 type="010">'.$siren.'</ort:_130000001>
|
||||
<ort:_103000402 type="010">'.$prod['CmdNom'].'</ort:_103000402>
|
||||
<ort:_103000403 type="010">'.$prod['CmdPages'].'</ort:_103000403>
|
||||
<ort:_190000025 type="010">'.$prod['CmdBilan'].'</ort:_190000025>
|
||||
</ort:_210>
|
||||
</ort:_200>
|
||||
</ort:_2>'; //
|
||||
$option=$prod['CmdNom'].'-'.$prod['CmdPages'].'-'.$prod['CmdBilan'];
|
||||
} elseif ($prod['Type']=='QINF') {
|
||||
$req.=' <ort:_2 type="110">'."\n".'<ort:_130000001 type="010">'.$siren.'</ort:_130000001>';
|
||||
if ($prod['Presta']=='2000' || $prod['Presta']=='2001' || $prod['Presta']=='2002' || $prod['Presta']=='2003') {
|
||||
// Liste années bilans
|
||||
$req.='<ort:_190000025 type="010">'.$prod['Millesime'].'</ort:_190000025>'."\n";
|
||||
$option=$prod['Millesime'];
|
||||
}
|
||||
elseif ($prod['Presta']=='12001')
|
||||
// Flag limitation du nombre détablissement
|
||||
$req.='<ort:_109105002 type="010">N</ort:_109105002>'."\n";
|
||||
$req.='</ort:_2>';
|
||||
} else {
|
||||
$req.=' <ort:_2 type="110">
|
||||
<ort:_130000001 type="010">'.$siren.'</ort:_130000001>
|
||||
<ort:_120000031 type="010">'.$prod['Presta'].'</ort:_120000031>
|
||||
</ort:_2>';// 12003 Actes et statuts 12004 Bilans
|
||||
}
|
||||
$req.=' </ort:_2>
|
||||
</ort:message>';
|
||||
echo $req.'<hr/>';
|
||||
$postData=array(''=>$req);
|
||||
$cookie=$referer='';
|
||||
$enCache=false;
|
||||
$params=md5(serialize($prod));
|
||||
//die($params);
|
||||
/*if ($prod['CmdNom']<>'' || $prod['CmdPages']<>'' || $prod['CmdBilan']<>'' || $prod['Millesime']<>'')
|
||||
$strOption=*/
|
||||
//AND params='$params'
|
||||
$res=$this->iDb->select('rncs_requetes', 'dateRequete, strXml, codeErreur, libErreur', "siren=$siren AND params='$params' ORDER BY dateRequete DESC");
|
||||
//type='".$prod['Type']."' AND presta ='".$prod['Presta']."' $strOption ORDER BY dateRequete DESC");
|
||||
if (count($res)>0) {
|
||||
$tabRes=$res[0];
|
||||
$dateReq=$tabRes['dateRequete'];
|
||||
$this->body=$tabRes['strXml'];
|
||||
$this->errNumInpi=$tabRes['codeErreur'];
|
||||
$this->errMsgInpi=$tabRes['libErreur'];
|
||||
$enCache=true;
|
||||
echo 'Une requête dans le cache <br/>';
|
||||
//die();
|
||||
} else {
|
||||
echo 'Pas de requête dans le cache <br/>';
|
||||
//die();
|
||||
$page=getUrl(RNCS_WS_URL, $cookie, $postData, $referer, false, 'www.services.ort.fr');
|
||||
$this->body=$page['body'];
|
||||
/**
|
||||
** ERREUR PROTOCOL
|
||||
**/
|
||||
preg_match('/<ort:_13 type="020">(.*)<\/ort:_13>/Uis',$this->body, $matches);
|
||||
if ($matches[1]*1<>0) {
|
||||
$this->errNumInpi=$matches[1];
|
||||
$this->errMsgInpi=$tabErreurInpi[$this->errNumInpi];
|
||||
//echo "<!-- ERREUR INPI 13 n°$errNumInpi = $errMsgInpi !!! -->\n";
|
||||
}
|
||||
|
||||
/**
|
||||
** ERREUR APPLICATIVES NUMERIQUES
|
||||
**/
|
||||
preg_match('/<ort:_96 type="020">(.*)<\/ort:_96>/Uis',$this->body, $matches);
|
||||
if ($matches[1]*1<>0) {
|
||||
$this->errNumInpi=$matches[1];
|
||||
$this->errMsgInpi=$tabErreurInpi[$this->errNumInpi];
|
||||
//echo "<!-- ERREUR INPI 96 n°$errNumInpi = $errMsgInpi !!! -->\n";
|
||||
}
|
||||
|
||||
/**
|
||||
** ERREUR APPLICATIVES TEXTE
|
||||
**/
|
||||
preg_match('/<ort:_97 type="010">(.*)<\/ort:_97>/Uis',$this->body, $matches);
|
||||
if ($matches[1]*1<>0) {
|
||||
$this->errMsgInpi=$matches[1];
|
||||
//echo "<!-- ERREUR INPI 97 : $errMsgInpi !!! -->\n";
|
||||
}
|
||||
|
||||
$tabInsert=array( 'siren' => $siren,
|
||||
'dateRequete' => date('YmdHis'),
|
||||
'strXml' => $this->body,
|
||||
'params' => md5(serialize($prod)),
|
||||
'type' => $prod['Type'],
|
||||
'presta' => $prod['Presta'],
|
||||
'option' => $option,
|
||||
'codeErreur' => $this->errNumInpi,
|
||||
'libErreur' => $this->errMsgInpi,
|
||||
);
|
||||
$this->iDb->insert('rncs_requetes', $tabInsert, true);
|
||||
}
|
||||
|
||||
if ($prod['Presta']==12004)
|
||||
// bilans image
|
||||
$pregmatch=preg_match_all('/<ort\:_201 type="110">(?:.*)<ort\:_103000040 type="010">(.*)<\/ort:_103000040>(?:.*)<ort\:_103000452 type="010">(.*)<\/ort:_103000452>(?:.*)<ort\:_103000402 type="010">(.*)<\/ort:_103000402>(?:.*)<ort\:_103000403 type="010">(.*)<\/ort:_103000403>(?:.*)<ort\:_103000404 type="010">(.*)<\/ort:_103000404>(?:.*)<\/ort:_201>/Uis',$this->body, $matches);
|
||||
elseif ($prod['Presta']==12003)
|
||||
// actes image
|
||||
$pregmatch=preg_match_all('/<ort\:_201 type="110">(?:.*)<ort\:_103000452 type="010">(.*)<\/ort:_103000452>(?:.*)<ort\:_103000402 type="010">(.*)<\/ort:_103000402>(?:.*)<ort\:_103000403 type="010">(.*)<\/ort:_103000403>(?:.*)<ort\:_103000404 type="010">(.*)<\/ort:_103000404>(?:.*)<\/ort:_201>/Uis',$this->body, $matches);
|
||||
elseif ($prod['Presta']==2000)
|
||||
// bilan simplifiés ou normaux saisi
|
||||
$pregmatch=preg_match('/<ort\:_2 type="110">(?:.*)<ort\:_2 type="110">(.*)<\/ort\:_2>(?:.*)<\/ort\:_2>/Uis',$this->body, $matches);
|
||||
elseif ($prod['Presta']==12001)
|
||||
// Fiche Identite
|
||||
$pregmatch=preg_match('/<ort\:_2 type="110">(?:.*)<ort\:_2 type="110">(.*)<\/ort\:_2>(?:.*)<\/ort\:_2>/Uis',$this->body, $matches);
|
||||
else {
|
||||
// Prestation Vitrine
|
||||
$tabVitrine=array();
|
||||
|
||||
// Bilans dispos
|
||||
$tabBilans=array();
|
||||
// Type de Bilans saisis disponible
|
||||
for ($typeBilan=2000; $typeBilan<2004; $typeBilan++) {
|
||||
$pregmatch=preg_match('/<ort:_'.$typeBilan.' type="110">(?:.*)<ort\:_120000026 type="010">(.*)<\/ort\:_120000026>(?:.*)<ort\:_120000027 type="010">(.*)<\/ort\:_120000027>(?:.*)<ort\:_120000028 type="010">(.*)<\/ort\:_120000028>(?:.*)<ort\:_120000029 type="010">(.*)<\/ort:_120000029>(?:.*)<ort\:_120000031 type="010">(.*)<\/ort\:_120000031>(?:.*)<ort\:_109104002 type="010">(.*)<\/ort\:_109104002>(?:.*)<ort\:_109104003 type="010">(.*)<\/ort\:_109104003>(.*)<\/ort:_'.$typeBilan.'>/Uis',$this->body, $matches);
|
||||
$numProduit=$matches[1]; // 52
|
||||
$numProduit=$matches[2]; // 52
|
||||
$verProduit=$matches[3]; // 1
|
||||
$libProduit=$matches[4]; // Comptes sociaux
|
||||
$typProduit=$matches[5]; // 2000 : Bilans sociaux
|
||||
// 2001 : Bilans consolidés (70)
|
||||
// 2002 : Bilans de banques (71)
|
||||
// 2003 : Bilans d'assurances (72)
|
||||
$synProduit=$matches[6]; // 109104002 : Disponibilité synchrone
|
||||
$asyProduit=$matches[7]; // 109104003 : Disponibilité asynchrone
|
||||
$pregmatch=preg_match_all('/<ort\:_103000038 type="010">(.*)<\/ort:_103000038>/Uis',$matches[8], $matches);
|
||||
if ($typeBilan==2000) $tabBilans['N']=$matches[1]; // Réel normal SC
|
||||
elseif ($typeBilan==2001) $tabBilans['C']=$matches[1]; // Consolidé CC
|
||||
elseif ($typeBilan==2002) $tabBilans['B']=$matches[1]; // Banque SB
|
||||
elseif ($typeBilan==2003) $tabBilans['A']=$matches[1]; // Assurance SA
|
||||
else $tabBilans['S']=$matches[1]; // Réel Simplifié SS
|
||||
}
|
||||
$tabVitrine['bilans']=$tabBilans;
|
||||
|
||||
// Fiche d'identité
|
||||
$pregmatch=preg_match('/<ort:_12001 type="110">(?:.*)<ort\:_120000027 type="010">(.*)<\/ort\:_120000027>(?:.*)<ort\:_120000028 type="010">(.*)<\/ort\:_120000028>(?:.*)<ort\:_120000029 type="010">(.*)<\/ort:_120000029>(?:.*)<ort\:_120000031 type="010">(.*)<\/ort\:_120000031>(?:.*)<ort\:_109104002 type="010">(.*)<\/ort\:_109104002>(?:.*)<ort\:_109104003 type="010">(.*)<\/ort\:_109104003>(?:.*)<ort\:_130000401 type="010">(.*)<\/ort\:_130000401>(?:.*)<\/ort:_12001>/Uis',$this->body, $matches);
|
||||
$numProduit=$matches[1]; // 52
|
||||
$verProduit=$matches[2]; // 1
|
||||
$libProduit=$matches[3]; // Comptes sociaux
|
||||
$typProduit=$matches[4]; // 2000 : Bilans sociaux
|
||||
$synProduit=$matches[5]; // 109104002 : Disponibilité synchrone
|
||||
$asyProduit=$matches[6]; // 109104003 : Disponibilité asynchrone
|
||||
$nbEtab=$matches[7]; // Nombre d'établissements recensés
|
||||
$tabVitrine['identite']=array( 'numProduit'=>$numProduit,
|
||||
'verProduit'=>$verProduit,
|
||||
'libProduit'=>$libProduit,
|
||||
'typProduit'=>$typProduit,
|
||||
'synProduit'=>$synProduit,
|
||||
'asyProduit'=>$asyProduit,
|
||||
'nbEtab' =>$nbEtab);
|
||||
|
||||
return $tabVitrine;
|
||||
}
|
||||
|
||||
echo $this->body;
|
||||
|
||||
//print_r($tabBilans);
|
||||
return $matches;
|
||||
}
|
||||
|
||||
function getListeBilans($siren, $type='*') {
|
||||
$tabVitrine=$this->getVitrine($siren);
|
||||
foreach ($tabVitrine['bilans'] as $type => $tabMillesime) {
|
||||
foreach ($tabMillesime as $num=>$millesime) {
|
||||
$delta1=round((Wdate::dateT('d/m/Y','Y',$millesime)-Wdate::dateT('d/m/Y','Y',$tabMillesime[$num+1]))*12)
|
||||
+round(Wdate::dateT('d/m/Y','m',$millesime)-Wdate::dateT('d/m/Y','m',$tabMillesime[$num+1]));
|
||||
if ($delta1>23) $delta1=0;
|
||||
$delta2=round((Wdate::dateT('d/m/Y','Y',$tabMillesime[$num+1])-Wdate::dateT('d/m/Y','Y',$tabMillesime[$num+2]))*12)
|
||||
+round(Wdate::dateT('d/m/Y','m',$tabMillesime[$num+1])-Wdate::dateT('d/m/Y','m',$tabMillesime[$num+2]));
|
||||
if ($delta2>23) $delta2=0;
|
||||
$tabRet[$type.$millesime]=array( 'dateProvPartenaire'=>date('Ymd'),
|
||||
'dureeExercice' =>$delta1,
|
||||
'dateExercicePre' =>Wdate::dateT('d/m/Y','Ymd',$tabMillesime[$num+1]),
|
||||
'dureeExercicePre' =>$delta2,
|
||||
'monnaie' =>'EUR',
|
||||
'source' =>100,
|
||||
'ref' =>'',
|
||||
);
|
||||
}
|
||||
}
|
||||
return $tabRet;
|
||||
}
|
||||
|
||||
function getBilan($siren, $millesime, $type='N') {
|
||||
global $tabOrt2Sd;
|
||||
$tabRet=$tabPostes=array();
|
||||
if ($type=='N') $presta=2000;
|
||||
elseif ($type=='C') $presta=2001;
|
||||
elseif ($type=='B') $presta=2002;
|
||||
elseif ($type=='A') $presta=2003;
|
||||
$prod=array( 'Prod'=>'RNCS',
|
||||
'Num'=>'52',
|
||||
'Ver'=>'1',
|
||||
'Presta'=>$presta,
|
||||
'Millesime'=>Wdate::dateT('d/m/Y','mY',$millesime),
|
||||
'Type'=>'QINF');
|
||||
$ret=$this->query($siren, $prod);
|
||||
|
||||
/* $fp=fopen(LOG_PATH.'/debugBilansRncs.log','a');
|
||||
fwrite($fp, print_r($ret,true));
|
||||
fclose($fp);*/
|
||||
|
||||
$pregmatch=preg_match_all('/<ort\:_(.*) type="010">(.*)<\/ort\:_(.*)>/Uis', $ret[1], $matches);
|
||||
foreach ($matches[1] as $i=>$poste) {
|
||||
//echo "$i : $poste<br/>";
|
||||
if ('_'.$poste=='_103000040') { // CONSOLIDE
|
||||
switch ($matches[2][$i]) {
|
||||
case 'SC': $tabRet[$tabOrt2Sd['_'.$poste]]='N'; break;
|
||||
case 'CC': $tabRet[$tabOrt2Sd['_'.$poste]]='C'; break;
|
||||
case 'SB': $tabRet[$tabOrt2Sd['_'.$poste]]='B'; break;
|
||||
case 'SA': $tabRet[$tabOrt2Sd['_'.$poste]]='A'; break;
|
||||
case 'SS': $tabRet[$tabOrt2Sd['_'.$poste]]='S'; break;
|
||||
default: break;
|
||||
}
|
||||
} elseif ('_'.$poste=='_103000214') { // MONNAIE_LIV_UNITE
|
||||
switch ($matches[2][$i]*1) {
|
||||
case 0: $tabRet[$tabOrt2Sd['_'.$poste]]=''; break;
|
||||
case 3: $tabRet[$tabOrt2Sd['_'.$poste]]='k'; break;
|
||||
case 6: $tabRet[$tabOrt2Sd['_'.$poste]]='m'; break;
|
||||
default: break;
|
||||
}
|
||||
} elseif ('_'.$poste=='_130000001' || // SIREN
|
||||
'_'.$poste=='_103000033' || // DATE_CLOTURE
|
||||
'_'.$poste=='_103000023' || // DUREE_MOIS
|
||||
'_'.$poste=='_103000202' || // MONNAIE_ORI
|
||||
'_'.$poste=='_103000205' || // MONNAIE_ORI_UNITE
|
||||
'_'.$poste=='_103000211' || // MONNAIE
|
||||
'_'.$poste=='_103000029' || // AVIS_CAC
|
||||
'_'.$poste=='_130000009') { // CODE_NAF
|
||||
$tabRet[$tabOrt2Sd['_'.$poste]]=$matches[2][$i];
|
||||
} else
|
||||
$tabPostes[$tabOrt2Sd['_'.$poste]]=$matches[2][$i];
|
||||
}
|
||||
$tabRet['POSTES']=$tabPostes;
|
||||
$tabRet['DATE_FRAICHE_BILAN']=date('Ymd');
|
||||
$tabRet['TYPE_BILAN']=$tabRet['CONSOLIDE'];
|
||||
//$tabRet['DATE_CLOTURE_PRE']
|
||||
//$tabRet['DUREE_MOIS_PRE']
|
||||
$fp=fopen(LOG_PATH.'/debugBilansRncs.log','a');
|
||||
fwrite($fp, print_r($tabRet,true));
|
||||
fclose($fp);
|
||||
|
||||
return $tabRet;
|
||||
}
|
||||
|
||||
function getIdentite($siren) {
|
||||
$tabVitrine=$this->getVitrine($siren);
|
||||
|
||||
$fp=fopen(LOG_PATH.'/debugVitrineRncs.log','a');
|
||||
fwrite($fp, print_r($tabVitrine,true));
|
||||
fclose($fp);
|
||||
|
||||
$prod=array( 'Prod'=>'RNCS',
|
||||
'Num'=>$tabVitrine['identite']['numProduit'],
|
||||
'Ver'=>$tabVitrine['identite']['verProduit'],
|
||||
'Presta'=>12001,
|
||||
'Type'=>'QINF');
|
||||
$ret=$this->query($siren, $prod);
|
||||
if ($this->errNumInpi>0 && $this->errMsgInpi<>'') {
|
||||
return false;
|
||||
} else {
|
||||
$pregmatch=preg_match_all('/<ort\:_((?:1300|13011|13016|130100403).*) type="010">(.*)<\/ort\:_((?:1300|13011|13016|130100403).*)>/Uis', $ret[1], $matchesIden);
|
||||
foreach ($matchesIden[1] as $i=>$rubrique) {
|
||||
if ($rubrique==130000300) $tabIdentite['Nom']=$matchesIden[2][$i];
|
||||
elseif ($rubrique==130000008) $tabIdentite['FJ']=$matchesIden[2][$i];
|
||||
elseif ($rubrique==130000303) $tabIdentite['Sigle']=$matchesIden[2][$i];
|
||||
elseif ($rubrique==130100015) $tabIdentite['Enseigne']=$matchesIden[2][$i];
|
||||
elseif ($rubrique==130000500) $tabIdentite['CapitalMont']=$matchesIden[2][$i];
|
||||
elseif ($rubrique==130000501) $tabIdentite['CapitalType']=$matchesIden[2][$i];
|
||||
elseif ($rubrique==130000508) $tabIdentite['CapitalDev']=$matchesIden[2][$i];
|
||||
elseif ($rubrique==130000509) $tabIdentite['CapitalUnite']=$matchesIden[2][$i];
|
||||
elseif ($rubrique==130000513) $tabIdentite['CapitalMontCts']=$matchesIden[2][$i];
|
||||
elseif ($rubrique==130000102) $tabIdentite['DateCrea']=$matchesIden[2][$i];
|
||||
elseif ($rubrique==130001002) $tabIdentite['DateImma']=$matchesIden[2][$i];
|
||||
elseif ($rubrique==130000013) $tabIdentite['CodeGreffe']=$matchesIden[2][$i];
|
||||
elseif ($rubrique==130000014) $tabIdentite['NumRC']=$matchesIden[2][$i];
|
||||
elseif ($rubrique==130001102) $tabIdentite['DateRad']=$matchesIden[2][$i];
|
||||
elseif ($rubrique==130000025) $tabIdentite['Provisoire']=$matchesIden[2][$i];
|
||||
elseif ($rubrique==130000401) $tabIdentite['NbEtab']=$matchesIden[2][$i];
|
||||
}
|
||||
|
||||
/** DIRIGEANTS **/
|
||||
$tabDir=array();
|
||||
if (preg_match('/<ort\:_130300015 type="010">(.*)<\/ort:_130300015>(?:.*)<ort:_200 type="111">(.*)<\/ort\:_200>/Uis', $ret[1], $matchesDirs)) {
|
||||
$nbDirs=$matchesDirs[1];
|
||||
$strDir=$matchesDirs[2];
|
||||
$strMatch= '<ort\:_210 type="110">(?:.*)'.
|
||||
'<ort\:_130300005 type="010">(.*)<\/ort\:_130300005>(?:.*)'.
|
||||
'<ort\:_130301003 type="010">(.*)<\/ort\:_130301003>(?:.*)'.
|
||||
'<ort\:_130300016 type="010">(.*)<\/ort\:_130300016>(?:.*)'.
|
||||
'<ort\:_130301006 type="010">(.*)<\/ort\:_130301006>(?:.*)'.
|
||||
'<ort\:_130301007 type="010">(.*)<\/ort\:_130301007>(?:.*)'.
|
||||
'<ort\:_130301009 type="010">(.*)<\/ort\:_130301009>(?:.*)'.
|
||||
'<ort\:_130301004 type="010">(.*)<\/ort\:_130301004>(?:.*)'.
|
||||
'<ort\:_130301008 type="010">(.*)<\/ort\:_130301008>(?:.*)'.
|
||||
'<ort\:_130301012 type="010">(.*)<\/ort\:_130301012>(?:.*)'.
|
||||
'<ort\:_130301100 type="010">(.*)<\/ort\:_130301100>(?:.*)'.
|
||||
'<ort\:_130301102 type="010">(.*)<\/ort\:_130301102>(?:.*)'.
|
||||
'<ort\:_130302002 type="010">(.*)<\/ort\:_130302002>(?:.*)'.
|
||||
'<ort\:_130302003 type="010">(.*)<\/ort\:_130302003>(?:.*)'.
|
||||
'<ort\:_130302004 type="010">(.*)<\/ort\:_130302004>(?:.*)<\/ort\:_210>';
|
||||
$pregmatch=preg_match_all("/$strMatches/Uis", $strDir, $matchesDirs);
|
||||
foreach ($matchesDirs[1] as $i=>$dir) {
|
||||
$tabDir[$i]=array( 'Fonc'=>$dir[1],
|
||||
'Sexe'=>$dir[2],
|
||||
'Nom'=>$dir[3],
|
||||
'Prenom'=>$dir[4],
|
||||
'Prenom2'=>$dir[5],
|
||||
'NomJF'=>$dir[6],
|
||||
'NaissDept'=>$dir[7],
|
||||
'NaissLieu'=>$dir[8],
|
||||
'NaissNati'=>$dir[9],
|
||||
'NaissDate'=>$dir[10],
|
||||
'ReprNom'=>$dir[11],
|
||||
'ReprPrenom'=>$dir[12],
|
||||
'ReprPrenom2'=>$dir[13],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$fp=fopen(LOG_PATH.'/debugIdentiteRncs.log','a');
|
||||
fwrite($fp, print_r($matchesIden,true).EOL.print_r($matchesEtab,true).EOL.print_r($matchesDirs,true));
|
||||
fclose($fp);
|
||||
|
||||
return $tabIdentite;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
244
library/Metier/partenaires/classMSigVille.php
Normal file
244
library/Metier/partenaires/classMSigVille.php
Normal file
@ -0,0 +1,244 @@
|
||||
<?php
|
||||
|
||||
ini_set('soap.wsdl_cache_enabled', 0);
|
||||
|
||||
class AmaSoapClient extends SoapClient {
|
||||
|
||||
function __doRequest($request, $location, $action, $version) {
|
||||
/* $request = strtr($request, array('<ns1:'=>'<ama:',
|
||||
'</ns1:'=>'</ama:',
|
||||
// '<param0 xsi:type="xsd:string">'=>'',
|
||||
'xmlns:ns1="http://www.amabis.com/ama.xsd"'=>'xmlns:ama="http://www.amabis.com/ama.xsd"',
|
||||
// '</param0>'=>'',
|
||||
// '<'=>'<',
|
||||
// '>'=>'>',
|
||||
)
|
||||
);*/
|
||||
return parent::__doRequest($request, $location, $action, $version);
|
||||
}
|
||||
}
|
||||
|
||||
class classMSigVille {
|
||||
|
||||
private $client;
|
||||
|
||||
private $url='http://sig.ville.gouv.fr/recherche-adresses-zus-zfu-quartiers-des-cucs';
|
||||
private $referer='';
|
||||
private $codeRetour;
|
||||
private $page;
|
||||
private $body;
|
||||
private $cookie='';
|
||||
private $timeout=5;
|
||||
private $duree=false;
|
||||
|
||||
function __construct() {
|
||||
if ($this->cookie=='') {
|
||||
$tdeb=microtime(1);
|
||||
$this->page=getUrl($this->url, $this->cookie, '', $this->referer, false, 'sig.ville.gouv.fr', '', $this->timeout);
|
||||
$this->duree=round(microtime(1)-$tdeb,3);
|
||||
$this->referer=$this->url;
|
||||
$this->body=$page['body'];
|
||||
$this->codeRetour=$page['code'];
|
||||
$this->header=$page['header'];
|
||||
$this->cookie=$this->header['Cookie'];
|
||||
if ($this->codeRetour<>200) return false;
|
||||
}
|
||||
}
|
||||
|
||||
function getZonage($adrNum, $adrIndRep, $adrTypeVoie, $adrLibVoie, $cp, $ville='', $codeRivoli='', $rnvp=false, $raisonSociale='TEST', $debug=false) {
|
||||
if ($this->cookie<>'') {
|
||||
$tdeb=microtime(1);
|
||||
$post=array('insee_com'=>'01053',
|
||||
'code_postal'=>'01000',
|
||||
'nom_commune'=>'Bourg-en-Bresse',
|
||||
'num_adresse'=>'8',
|
||||
'id_voie'=>28,
|
||||
'nom_voie'=>'RUE+DES+BLANCHISSERIES',
|
||||
'x'=>33,
|
||||
'y'=>19,
|
||||
);
|
||||
$this->page=getUrl($this->url, $this->cookie, $post, $this->referer, false, 'sig.ville.gouv.fr', '', $this->timeout);
|
||||
$this->duree=round(microtime(1)-$tdeb,3);
|
||||
$this->referer=$this->url;
|
||||
$this->body=$page['body'];
|
||||
$this->codeRetour=$page['code'];
|
||||
$this->header=$page['header'];
|
||||
$this->cookie=$this->header['Cookie'];
|
||||
if ($this->codeRetour<>200) return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
$tabRep=array();
|
||||
if (!$rnvp) {
|
||||
if ($cp<10000) $cp='0'.$cp;
|
||||
$dep2=substr($cp,0,2)*1;
|
||||
$dep3=substr($cp,0,3)*1;
|
||||
switch ($dep2) {
|
||||
case 0:
|
||||
case 5:
|
||||
case 9:
|
||||
case 15:
|
||||
case 19:
|
||||
case 23:
|
||||
case 32:
|
||||
case 46:
|
||||
case 48:
|
||||
case 82:
|
||||
case 97: // DOM
|
||||
case 98: // TOM
|
||||
case 99: // Etranger
|
||||
return $tabRep;
|
||||
break;
|
||||
default:
|
||||
//if ($dep3==975) return $tabRep;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$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);
|
||||
if (count($ret)>0) {
|
||||
$zones=$ret[0];
|
||||
$tabRep['ZUS']=$tabRep['ZFU']=$tabRep['ZRU']=$tabRep['CUCS']='NON';
|
||||
if (trim($zones['zus'])<>'') {
|
||||
if (trim($zones['zus'])=='NSP') $tabRep['ZUS']='NSP';
|
||||
else $tabRep['ZUS']='OUI';
|
||||
$tabRep['NZUS']=$zones['zus'];
|
||||
}
|
||||
if (trim($zones['zru'])<>'') {
|
||||
if (trim($zones['zru'])=='NSP') $tabRep['ZRU']='NSP';
|
||||
else $tabRep['ZRU']='OUI';
|
||||
$tabRep['NZRU']=$zones['zru'];
|
||||
}
|
||||
if (trim($zones['zfu'])<>'') {
|
||||
if (trim($zones['zfu'])=='NSP') $tabRep['ZFU']='NSP';
|
||||
else $tabRep['ZFU']='OUI';
|
||||
$tabRep['NZFU']=$zones['zfu'];
|
||||
}
|
||||
if (trim($zones['cucs'])<>'') {
|
||||
if (trim($zones['cucs'])=='NSP') $tabRep['CUCS']='NSP';
|
||||
else $tabRep['CUCS']='OUI';
|
||||
$tabRep['NCUCS']=$zones['cucs'];
|
||||
}
|
||||
//return $tabRep;
|
||||
} else {
|
||||
|
||||
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",
|
||||
'¿°ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûýýþÿ??',
|
||||
' aaaaaaaceeeeiiiidnoooooouuuuybsaaaaaaaceeeeiiiidnoooooouuuyybyRr'),'adresse'),
|
||||
new SoapParam(':','separateur'),
|
||||
new SoapParam('type=M','options')
|
||||
);
|
||||
/*$rep=$this->client->zonage( "<adresse></adresse>".
|
||||
"<separateur>:</separateur>".
|
||||
"<options>type=M</options>");*/
|
||||
|
||||
/** Découpage des ZFU, CUCS etcs...
|
||||
**/
|
||||
$fp=fopen(LOG_PATH.'amabis.log', 'a');
|
||||
fwrite($fp, date('d-m-Y H:i:s').' - '.implode("\n", $rep)."\n============================================================================\n");
|
||||
fclose($fp);
|
||||
|
||||
$tabZones=explode(',',$rep['zonage']); // ZUS=OUI,NZUS=1127020,ZFU=OUI,NZFU=11270ZF,CUCS=OUI,NCUCS=1127020
|
||||
foreach ($tabZones as $zone) {
|
||||
$tabTmp=explode('=',$zone);
|
||||
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';
|
||||
$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);
|
||||
|
||||
/** 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);
|
||||
}
|
||||
}
|
||||
} catch (SoapFault $fault) {
|
||||
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;
|
||||
}
|
||||
$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';
|
||||
foreach ($ret as $zones)
|
||||
switch ($zones['typeZone']) {
|
||||
case 'ZRR': $tabRep['ZRR']='OUI'; $tabRep['NZRR']=$codeInsee; break;
|
||||
case 'ZAFR': $tabRep['AFR']='OUI'; $tabRep['NAFR']=$codeInsee; break;
|
||||
default: break;
|
||||
}
|
||||
|
||||
return $tabRep;
|
||||
}
|
||||
|
||||
function searchByTelFax($tel) {
|
||||
return $this->getTelFax('','','','',$tel);
|
||||
}
|
||||
|
||||
function getTelFax($nom, $cp, $ville='', $prenom='', $tel='') {
|
||||
if (trim($tel)<>'')
|
||||
$query="<telep>$tel</telep><scoremini>10</scoremini><distinction>30</distinction>";
|
||||
elseif (trim($prenom)=='')
|
||||
$query="<rs>$nom</rs><cpville>$cp $ville</cpville><scoremini>90</scoremini><distinction>30</distinction>";
|
||||
else
|
||||
$query="<nom>$nom</nom><prenom>$prenom</prenom><cpville>$cp $ville</cpville><scoremini>90</scoremini><distinction>30</distinction>";
|
||||
|
||||
$rep=$this->client->rechtel($query);
|
||||
|
||||
$fp=fopen(LOG_PATH.'amabis.log', 'a');
|
||||
fwrite($fp, date('d-m-Y H:i:s')." - $query - ".implode("\n", $rep)."\n============================================================================\n");
|
||||
fwrite($fp, "Requête : ".$this->client->__getLastRequest()."\n");
|
||||
fwrite($fp, "Réponse : ".$this->client->__getLastResponse()."\n");
|
||||
fclose($fp);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
279
library/Metier/partenaires/classMTel.php
Normal file
279
library/Metier/partenaires/classMTel.php
Normal file
@ -0,0 +1,279 @@
|
||||
<?
|
||||
|
||||
class MTel {
|
||||
|
||||
public $body = '';
|
||||
public $header = '';
|
||||
public $codeRetour = 0;
|
||||
|
||||
public $cookie='';
|
||||
public $urlBase='http://www.pagespro.com/recherche.php';
|
||||
public $url='';
|
||||
public $referer='';
|
||||
public $enCache=false;
|
||||
private $accesDistant=false;
|
||||
|
||||
public $iDb;
|
||||
|
||||
public function __construct($accesDistant=false) {
|
||||
$this->accesDistant=$accesDistant;
|
||||
if ($this->accesDistant) {
|
||||
$this->url=$this->urlBase;
|
||||
$page=getUrl($this->url,$this->cookie,'',$this->referer, false, '', '', 3);
|
||||
$this->referer=$this->url;
|
||||
$this->cookie=$page['header']['Set-Cookie'];
|
||||
$this->body=$page['body'];
|
||||
$this->codeRetour=$page['code'];
|
||||
}
|
||||
$this->iDb=new WDB('jo');
|
||||
}
|
||||
|
||||
/**
|
||||
* @todo :
|
||||
* 1. Faire une fonction qui récupère les Logos
|
||||
* 2. Envoyer les logos par le WS
|
||||
* 3. Permettre la recherche par Tel
|
||||
*/
|
||||
|
||||
public function getTel($siret, $nic=0) {
|
||||
|
||||
$tabRet=array();
|
||||
|
||||
if (strlen($siret)>9) {
|
||||
$nic=substr($siret,-5)*1;
|
||||
$siren=round($siret/100000)*1;
|
||||
} else
|
||||
$siren=$siret*1;
|
||||
|
||||
if (strlen($siren)<=9) {
|
||||
/** Si le siren est de taille < à 9, on ajoute des 0 significatifs **/
|
||||
switch (strlen($siren)) {
|
||||
case 1: $siren='00000000'.$siren; break;
|
||||
case 2: $siren='0000000'.$siren; break;
|
||||
case 3: $siren='000000'.$siren; break;
|
||||
case 4: $siren='00000'.$siren; break;
|
||||
case 5: $siren='0000'.$siren; break;
|
||||
case 6: $siren='000'.$siren; break;
|
||||
case 7: $siren='00'.$siren; break;
|
||||
case 8: $siren='0'.$siren; break;
|
||||
}
|
||||
}
|
||||
if (strlen($nic)>0) {
|
||||
switch (strlen($nic)) {
|
||||
case 1: $nic='0000'.$nic; break;
|
||||
case 2: $nic='000'.$nic; break;
|
||||
case 3: $nic='00'.$nic; break;
|
||||
case 4: $nic='0'.$nic; break;
|
||||
}
|
||||
}
|
||||
|
||||
$strNic='';
|
||||
if ($nic*1>0) $strNic="AND (nic=$nic OR nic=0)";
|
||||
$ret=$this->iDb->select('telephonie',
|
||||
'siren,nic,dateProvPartenaire,typeTel,infoTel,telephone,actif,partenaire,dateInsert',
|
||||
"siren=$siren $strNic", false, MYSQL_ASSOC);
|
||||
if (count($ret)>0) {
|
||||
$this->enCache=true;
|
||||
foreach ($ret as $tabTel) {
|
||||
if ($tabTel['typeTel']=='an8' && $tabTel['infoTel']*1>0) {
|
||||
$an8=$tabTel['infoTel']*1;
|
||||
$retTmp=$this->iDb->select('tabAn8', 'libAn8', "codAn8='$an8'", false, MYSQL_ASSOC);
|
||||
$infoTel=ucfirst(strtolower($retTmp[0]['libAn8']));
|
||||
} else
|
||||
$infoTel=$tabTel['infoTel'];
|
||||
$tabRet[]=array('siren'=>$siren,
|
||||
'nic'=>$tabTel['nic'],
|
||||
'typeTel'=>$tabTel['typeTel'],
|
||||
'infoTel'=>$infoTel,
|
||||
'telephone'=>$tabTel['telephone'],
|
||||
'actif'=>$tabTel['actif'],
|
||||
);
|
||||
}
|
||||
//sendMail('production@scores-decisions.com', 'ylenaour@scores-decisions.com', "classMTel::getTel($siret,$nic)", print_r($tabRet,true));
|
||||
} elseif ($this->accesDistant) {
|
||||
$this->enCache=false;
|
||||
$tabPost=array( 'p_ACTION'=>'',
|
||||
'p_ORDRE'=>'AfficheRes',
|
||||
'a_PAGE'=>'1',
|
||||
'a_TAG'=>'',
|
||||
'a_OccRecherche'=>'',
|
||||
'typeRecherche'=>'express',
|
||||
'satellite'=>'siret',
|
||||
'a_activ'=>'',
|
||||
'a_rai_soc'=>'',
|
||||
'a_naf'=>'',
|
||||
'a_siren'=>$siret,
|
||||
'a_tel'=>'',
|
||||
'a_geo'=>'',
|
||||
'typeTri'=>'',
|
||||
'ordreTri'=>'',
|
||||
'a_session'=>'',
|
||||
);
|
||||
//$page=getUrl($this->url,$this->cookie,'',$this->referer, false, '', '', 3);
|
||||
$page=getUrl($this->url,$this->cookie,$tabPost,$this->referer,false,'','',3);
|
||||
$this->referer=$this->url;
|
||||
$this->body=$page['body'];
|
||||
$this->codeRetour=$page['code'];
|
||||
|
||||
$nbResults=0;
|
||||
if (preg_match('/<b class="total_responses_nr">(.*)réponses<\/b>/Uis', $this->body, $matches))
|
||||
$nbResults=trim(strtr(strip_tags($matches[1]), array(' '=>'','–'=>'')));
|
||||
|
||||
if ($nbResults>0) {
|
||||
$tabResultsHtml=explode('<div class="results_part1">', $this->body);
|
||||
for ($i=1; isset($tabResultsHtml[$i]);$i++) {
|
||||
$res=$tabTel=array();
|
||||
$body=$tabResultsHtml[$i];
|
||||
$res['nom']=trim(htm2txt(@getTextInHtml($body, '<div class="results_title">', '_title">', '</div>')));
|
||||
$res['adresse']=trim(htm2txt(@getTextInHtml($body, '<div class="coordonnees">','<div>','<table id="t_coord_')));
|
||||
|
||||
$res['urlSite']=trim(htm2txt(@getTextInHtml($body, '<b class="siteweb">Site Web :</b> ', "javascript:SiteURL('", "','")));
|
||||
$res['urlMail']=trim(htm2txt(@getTextInHtml($body, '<b>E-mail :</b>', "&mail=", "', ")));
|
||||
$res['urlLogo']=trim(htm2txt(@getTextInHtml($body, '<div class="results_inset_logo">', '" src="', '" border="')));
|
||||
$res['tefet']=trim(htm2txt(@getTextInHtml($body, '<b>Effectif établ : </b>','</b>','</div>')));
|
||||
|
||||
$res['tefet']=trim(htm2txt(@getTextInHtml($body, '<b>Effectif établ : </b>','</b>','</div>')));
|
||||
$res['siret']=trim(htm2txt(@getTextInHtml($body, '<b>Siret : </b>','</b>','</div>')));
|
||||
$res['nafet']=trim(htm2txt(strip_tags(@getTextInHtml($body, '<b>Code NAF : </b>','</b>','</div>'))));
|
||||
|
||||
$res['domaines']=trim(preg_replace('/ +/', ' ', preg_replace('/\r+|\n+|\s+/',' ',htm2txt(strip_tags(@getTextInHtml($body, '<div class="puce_domaine">','<strong>','</div>'))))));
|
||||
|
||||
if ($res['urlSite']<>'') {
|
||||
$this->iDb->insert('telephonie', array( 'siren'=>$siren,
|
||||
'nic'=>substr($res['siret'],-5),
|
||||
'dateProvPartenaire'=>date('Ymd'),
|
||||
'typeTel'=>'web',
|
||||
'infoTel'=>$res['urlSite'],
|
||||
'telephone'=>0,
|
||||
'actif'=>1,
|
||||
'partenaire'=>253,
|
||||
)
|
||||
);
|
||||
$tabRet[]=array('siren'=>$siren,
|
||||
'nic'=>substr($res['siret'],-5),
|
||||
'typeTel'=>'web',
|
||||
'infoTel'=>$res['urlSite'],
|
||||
'telephone'=>0,
|
||||
);
|
||||
}
|
||||
if ($res['urlLogo']<>'') {
|
||||
$this->iDb->insert('telephonie', array( 'siren'=>$siren,
|
||||
'nic'=>substr($res['siret'],-5),
|
||||
'dateProvPartenaire'=>date('Ymd'),
|
||||
'typeTel'=>'logo',
|
||||
'infoTel'=>$res['urlLogo'],
|
||||
'telephone'=>0,
|
||||
'actif'=>1,
|
||||
'partenaire'=>253,
|
||||
)
|
||||
);
|
||||
$tabRet[]=array('siren'=>$siren,
|
||||
'nic'=>substr($res['siret'],-5),
|
||||
'typeTel'=>'logo',
|
||||
'infoTel'=>$res['urlLogo'],
|
||||
'telephone'=>0,
|
||||
);
|
||||
}
|
||||
if ($res['domaines']<>'') {
|
||||
$this->iDb->insert('telephonie', array( 'siren'=>$siren,
|
||||
'nic'=>substr($res['siret'],-5),
|
||||
'dateProvPartenaire'=>date('Ymd'),
|
||||
'typeTel'=>'domaines',
|
||||
'infoTel'=>$res['domaines'],
|
||||
'telephone'=>0,
|
||||
'actif'=>1,
|
||||
'partenaire'=>253,
|
||||
)
|
||||
);
|
||||
$tabRet[]=array('siren'=>$siren,
|
||||
'nic'=>substr($res['siret'],-5),
|
||||
'typeTel'=>'domaines',
|
||||
'infoTel'=>$res['domaines'],
|
||||
'telephone'=>0,
|
||||
);
|
||||
}
|
||||
if ($res['urlMail']<>'') {
|
||||
$this->iDb->insert('telephonie', array( 'siren'=>$siren,
|
||||
'nic'=>substr($res['siret'],-5),
|
||||
'dateProvPartenaire'=>date('Ymd'),
|
||||
'typeTel'=>'mail',
|
||||
'infoTel'=>$res['urlMail'],
|
||||
'telephone'=>0,
|
||||
'actif'=>1,
|
||||
'partenaire'=>253,
|
||||
)
|
||||
);
|
||||
$tabRet[]=array('siren'=>$siren,
|
||||
'nic'=>substr($res['siret'],-5),
|
||||
'typeTel'=>'mail',
|
||||
'infoTel'=>$res['urlMail'],
|
||||
'telephone'=>0,
|
||||
);
|
||||
}
|
||||
|
||||
if (preg_match_all('/<tr>(?:.*)<th>(?:.*)<span>(.*)(tél|fax)(?:.*)<\/span>(?:.*)<\/th>(?:.*)<td>(?:.*)<span>(.*)<\/span>(?:.*)<\/td>(?:.*)<\/tr>/Uis', $body, $matches)) {
|
||||
foreach ($matches[2] as $j=>$tmp) {
|
||||
$lib=$tmp;
|
||||
$precis=trim(strtr($matches[1][$j], array('-'=>' ')));
|
||||
$num=trim(strtr($matches[3][$j],array(' '=>'','<br />'=>'')));
|
||||
$tabTel["$lib-$num"]=array('telFax'=>$lib,'type'=>$precis, 'telNum'=>$num);
|
||||
}
|
||||
$tabTel=array_values($tabTel);
|
||||
|
||||
|
||||
foreach ($tabTel as $tabT) {
|
||||
$tabRet[]=array('siren'=>$siren,
|
||||
'nic'=>substr($res['siret'],-5),
|
||||
'typeTel'=>trimAccent($tabT['telFax']),
|
||||
'infoTel'=>$tabT['type'],
|
||||
'telephone'=>$tabT['telNum'],
|
||||
'actif'=>1,
|
||||
);
|
||||
$this->iDb->insert('telephonie', array( 'siren'=>$siren,
|
||||
'nic'=>substr($res['siret'],-5),
|
||||
'dateProvPartenaire'=>date('Ymd'),
|
||||
'typeTel'=>trimAccent($tabT['telFax']),
|
||||
'infoTel'=>$tabT['type'],
|
||||
'telephone'=>$tabT['telNum'],
|
||||
'actif'=>1,
|
||||
'partenaire'=>253,
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
} /*else {
|
||||
//http://www.annuaire.com/uploads/504/284/504284159/logo.jpg
|
||||
//http://www.annuaire.com/email/491314266/
|
||||
$url="http://www.annuaire.com/societe/-$siren/";
|
||||
//$page=getUrl($this->url,$this->cookie,'',$this->referer, false, '', '', 3);
|
||||
$page=getUrl($url,'','','',false,'','',3);
|
||||
|
||||
if ($page['code']<>301) return false;
|
||||
$url2=$page['header']['Location'];
|
||||
$page=getUrl($url2,'','',$url,false,'','',3);
|
||||
|
||||
if (!preg_match('/<a href="http:\/\/www\.annuaire\.com\/inscription\/1\/\?companyid=(.*)&go=next"/Uis', $page['body'], $matches)) {
|
||||
print_r($page);
|
||||
die($siren);
|
||||
}
|
||||
}*/
|
||||
}
|
||||
return $tabRet;
|
||||
}
|
||||
|
||||
function getOperateur($tel) {
|
||||
/*http://www.arcep.fr/index.php?id=interactivenumeros
|
||||
Données POST:
|
||||
ctrl_flag[do_ctrl]
|
||||
bloc[017543]
|
||||
CMD[RESULTS_NUMEROTATION]
|
||||
http://www.arcep.fr/index.php?id=interactivenumeros&CMD=DETAILS_SOC&uid=158757&bloc=017543&cHash=0c29e39859
|
||||
http://www.arcep.fr/uploads/tx_gsavis/05-0233.pdf
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
329
library/Metier/partenaires/classMTva.php
Normal file
329
library/Metier/partenaires/classMTva.php
Normal file
@ -0,0 +1,329 @@
|
||||
<?php
|
||||
|
||||
//ini_set('soap.wsdl_cache_enabled', 1); // 0 en dév
|
||||
|
||||
class MTvaOld {
|
||||
|
||||
public $vatNumber=''; // Numéro de TVA retourné
|
||||
public $vatDefined=false; // Le numéro de TVA est il validé ?
|
||||
public $errnum=0; // Numéro de l'erreur en cas d'erreur
|
||||
public $errmsg=''; // Message de l'erreur en cas d'erreur
|
||||
|
||||
private $siren;
|
||||
|
||||
function __construct($siren, $accesDist=true) {
|
||||
//$accesDist=false;
|
||||
if ($accesDist==true) {
|
||||
|
||||
/*$fp=fopen('/var/www/log/infoVat.log', 'a');
|
||||
fwrite($fp, "MTva->__construct pour $siren $accesDist\n");
|
||||
fclose($fp);
|
||||
*/
|
||||
$this->siren=$siren;
|
||||
$client = new SoapClient('http://ws1.scores-decisions.com/entreprise/vat.wsdl',
|
||||
array( 'trace' => 1, 'soap_version' => SOAP_1_1,
|
||||
'login' => 'TESTTVA', 'password' => 'TVATESTPW'));
|
||||
try {
|
||||
$O = $client->getCompanyVat($this->siren);
|
||||
if ($O->error->errnum) {
|
||||
//echo 'Erreur : '. $O->error->errmsg .' ('. $O->error->errnum .")\n";
|
||||
//echo $client->__getLastResponse()."\n";
|
||||
$this->errnum=$O->error->errnum;
|
||||
$this->errmsg=$O->error->errmsg;
|
||||
return false;
|
||||
} else {
|
||||
$val=$O->result;
|
||||
$this->vatNumber=$val->vatNumber;
|
||||
$this->vatDefined=$val->vatDefined;
|
||||
}
|
||||
} catch (SoapFault $fault) {
|
||||
//echo $client->__getLastResponse()."\n";
|
||||
//echo 'ERREUR SOAP :'.EOL;
|
||||
//print_r($fault);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else {
|
||||
$this->errnum=999;
|
||||
$this->errmsg="Pas d'accès à la base TVA";
|
||||
$this->vatNumber='';
|
||||
$this->vatDefined=false;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
class MTva {
|
||||
|
||||
public $vatNumber=''; // Numéro de TVA retourné
|
||||
public $vatDefined=false; // Le numéro de TVA est il validé ?
|
||||
public $errnum=0; // Numéro de l'erreur en cas d'erreur
|
||||
public $errmsg=''; // Message de l'erreur en cas d'erreur
|
||||
|
||||
private $siren;
|
||||
|
||||
function __construct($siren, $accesDist=true) {
|
||||
|
||||
$sirenIn=$siren*1;
|
||||
if ($sirenIn<000001000) {
|
||||
/* $this->errnum=0;
|
||||
$this->errmsg=$O->error->errmsg;
|
||||
return false;
|
||||
} else {
|
||||
$val=$O->result;
|
||||
$this->vatNumber=$val->vatNumber;
|
||||
$this->vatDefined=$val->vatDefined;*/
|
||||
$this->vatNumber='FR00000000000';
|
||||
$this->vatDefined=false;
|
||||
return false;
|
||||
}elseif($sirenIn<000010000) $siren='00000'.$sirenIn;
|
||||
elseif ($sirenIn<000100000) $siren='0000'.$sirenIn;
|
||||
elseif ($sirenIn<001000000) $siren='000'.$sirenIn;
|
||||
elseif ($sirenIn<010000000) $siren='00'.$sirenIn;
|
||||
elseif ($sirenIn<100000000) $siren='0'.$sirenIn;
|
||||
else $siren=''.$sirenIn;
|
||||
|
||||
$this->siren=$siren;
|
||||
$cleAlgo=$this->genereCleFr();
|
||||
|
||||
if ($cleAlgo<10) $cleAlgo='0'.$cleAlgo;
|
||||
else $cleAlgo=''.$cleAlgo;
|
||||
$tabRep=array();
|
||||
if (!$this->valideSiren($siren) && substr($siren,0,4)<>'0000') {
|
||||
$this->errnum=102;
|
||||
$this->errmsg='Siren invalide';
|
||||
return false;
|
||||
}
|
||||
$iDb=new WDB('sdv1');
|
||||
$info=$iDb->select('siren_tva', "cle, DATE_FORMAT(dateMod,'%Y%m%d') as DateMAJ", "siren=$siren", false, MYSQL_ASSOC);
|
||||
$tab=$info[0];
|
||||
if (count($tab)>0) {
|
||||
//sendMail('production@scores-decisions.com', 'ylenaour@scores-decisions.com', "classMTva sur $siren en cache", print_r($tab, true));
|
||||
if ( $tab['cle']<>NULL || ( $tab['cle']==NULL && $tab['DateMAJ']>=date('Ymd',mktime(0,0,0,date('m')-6,date('d'),date('Y'))) )) {
|
||||
$cle=$tab['cle'];
|
||||
if ($cle==NULL) { $attribue=false; $cle=$cleAlgo; }
|
||||
else $attribue=true;
|
||||
$this->vatNumber="FR$cle$siren";
|
||||
$this->vatDefined=$attribue;
|
||||
return true;
|
||||
}
|
||||
//sendMail('production@scores-decisions.com', 'ylenaour@scores-decisions.com', "classMTva sur $siren REVALIDATION", print_r($tab, true));
|
||||
}
|
||||
$cle=$cleAlgo;
|
||||
$nbIndispo=0;
|
||||
if ($accesDist) {
|
||||
while(true) {
|
||||
$postData=array( //'Lang'=>'FR',
|
||||
'ms'=>'FR',
|
||||
'iso'=>'FR',
|
||||
'vat'=>$cle.$siren,
|
||||
'BtnSubmitVat'=>'Verify');
|
||||
/* $postData=array( 'Lang'=>'FR',
|
||||
'VAT'=>$cle.$siren,
|
||||
'ISO'=>'FR',
|
||||
'MS'=>'FR');*/
|
||||
$tdeb = microtime_float();
|
||||
// $url='http://ec.europa.eu/taxation_customs/vies/cgi-bin/viesquer';
|
||||
// $referer='http://ec.europa.eu/taxation_customs/vies/fr/vieshome.htm';
|
||||
$url='http://ec.europa.eu/taxation_customs/vies/viesquer.do';
|
||||
$referer='http://ec.europa.eu/taxation_customs/vies/';
|
||||
|
||||
$page=getUrl($url, '', $postData, $referer, false, 'ec.europa.eu', '', 15);
|
||||
$duree = round(microtime_float()-$tdeb, 3);
|
||||
//sendMail('production@scores-decisions.com', 'ylenaour@scores-decisions.com', "classMTva sur $siren en $duree", print_r($page, true));
|
||||
|
||||
if ($page['err_num']<>0) {
|
||||
debugLog('W', 'TVA Erreur CURL n°'. $page['err_num'] .', '. $page['err_msg'] ." sur le Siren $siren, numéro de TVA = FR $cle $siren. Durée = $duree s !", __LINE__, __FILE__, __FUNCTION__, __CLASS__);
|
||||
$this->vatNumber="FR$cle$siren";
|
||||
$this->vatDefined=false;
|
||||
return true;
|
||||
}
|
||||
$code=$page['code'];// Code réponse Serveur
|
||||
$body=$page['body'];
|
||||
$header=$page['header'];
|
||||
if (preg_match('/Yes, valid VAT number/i', $body)) {
|
||||
$tabInsert=array('siren'=>$siren,'cle'=>$cle, 'duree'=>$duree);
|
||||
$tabUpdate=array('cle'=>$cle, 'duree'=>$duree);
|
||||
if (!$iDb->insert('siren_tva', $tabInsert))
|
||||
if (!$iDb->update('siren_tva', $tabUpdate, "siren=$siren"))
|
||||
debugLog('W', "Siren $siren, numéro de TVA = FR $cle $siren, impossible de MAJ la clef ($duree s) - ERREUR MySql n°". mysql_errno() .' : '. mysql_error(), __LINE__, __FILE__, __FUNCTION__, __CLASS__);
|
||||
//echo date ('Y/m/d - H:i:s') ." - Ligne $k/$nbk, N°TVA FR $cle $siren validé .".$eol;
|
||||
debugLog('I', "Siren $siren, numéro de TVA = FR $cle $siren ($duree s)", __LINE__, __FILE__, __FUNCTION__, __CLASS__);
|
||||
$this->vatNumber="FR$cle$siren";
|
||||
$this->vatDefined=true;
|
||||
return true;
|
||||
//return array('error'=>array('errnum'=>0, 'errmsg'=>''), 'result'=>array('siren'=>$siren, 'vatNumber'=>"FR$cle$siren", 'vatDefined'=>true));
|
||||
} elseif (strpos($body, 'Service non disponible')>0 ||
|
||||
strpos($body, 'ponse trop long.')>0) {
|
||||
$nbIndispo++;
|
||||
if ($nbIndispo<3) {
|
||||
//echo date ('Y/m/d - H:i:s') .' - '.$eol;
|
||||
debugLog('I', "TVA Siren $siren, Service de l'état membre indisponible. Mise en sommeil...", __LINE__, __FILE__, __FUNCTION__, __CLASS__);
|
||||
randsleep(1,2);
|
||||
$nbIndispo=0;
|
||||
//echo date ('Y/m/d - H:i:s') .' - Reprise du Siren = '. $siren . $eol;
|
||||
} else {
|
||||
$tabInsert=array('siren'=>$siren,'cle'=>'NULL', 'duree'=>$duree);
|
||||
$tabUpdate=array('cle'=>'NULL', 'duree'=>$duree);
|
||||
if (!$iDb->insert('siren_tva', $tabInsert))
|
||||
if (!$iDb->update('siren_tva', $tabUpdate, "siren=$siren"))
|
||||
debugLog('W', "Siren $siren, numéro de TVA = FR $cle $siren, impossible de MAJ la clef ($duree s) - ERREUR MySql n°". mysql_errno() .' : '. mysql_error(), __LINE__, __FILE__, __FUNCTION__, __CLASS__);
|
||||
debugLog('I', "Siren $siren, numéro de TVA = FR $cle $siren vérification non disponible ($duree s)", __LINE__, __FILE__, __FUNCTION__, __CLASS__);
|
||||
$this->vatNumber="FR$cle$siren";
|
||||
$this->vatDefined=false;
|
||||
return true;
|
||||
}
|
||||
//echo date ('Y/m/d - H:i:s') .' - Temporisation n°'.$nbIndispo . $eol;
|
||||
} else {
|
||||
$tabInsert=array('siren'=>$siren,'cle'=>'NULL', 'duree'=>$duree);
|
||||
$tabUpdate=array('cle'=>'NULL', 'duree'=>$duree);
|
||||
if (!$iDb->insert('siren_tva', $tabInsert))
|
||||
if (!$iDb->update('siren_tva', $tabUpdate, "siren=$siren"))
|
||||
debugLog('W', "Siren $siren, numéro de TVA = FR $cle $siren, impossible de MAJ la clef ($duree s) - ERREUR MySql n°". mysql_errno() .' : '. mysql_error(), __LINE__, __FILE__, __FUNCTION__, __CLASS__);
|
||||
debugLog('I', "Siren $siren, numéro de TVA = FR $cle $siren non attribué ($duree s)", __LINE__, __FILE__, __FUNCTION__, __CLASS__);
|
||||
$this->vatNumber="FR$cle$siren";
|
||||
$this->vatDefined=false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$this->errnum=999;
|
||||
$this->errmsg="Pas d'accès à la base TVA";
|
||||
$this->vatNumber="FR$cle$siren";
|
||||
$this->vatDefined=false;
|
||||
return true;
|
||||
}
|
||||
debugLog('W', "Erreur impossible (car l'algo ne devrait pas passer par ici) sur le Siren $siren, numéro de TVA = FR $cle $siren. Durée = $duree s. Cas impossible !", __LINE__, __FILE__, __FUNCTION__, __CLASS__);
|
||||
return true;//array('error'=>array('errnum'=>800, 'errmsg'=>'Erreur SGBDR'), 'result'=>$tabRet);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
** Génère la clé du numéro de TVA pour le siren fournit
|
||||
** (la validité du numéro de siren et son existance n'est pas effectué par cette méthode)
|
||||
**
|
||||
** @param integer $siren Siren dont il faut générer la clé
|
||||
** @return La clé du numéro de TVA
|
||||
**/
|
||||
private function genereCleFr() {
|
||||
|
||||
$siren=$this->siren;
|
||||
|
||||
// Position du chiffre SIREN (1 à 9)
|
||||
$tabFirst=array();
|
||||
$tabFirst[0]=array( 0, 0, 0, 0, 0, 0, 0, 0, 0);
|
||||
$tabFirst[1]=array(62,47,94,89,40,06,22,43,16);
|
||||
$tabFirst[2]=array(14,81,78,68,67,96,31,73,19);
|
||||
$tabFirst[3]=array(63,18,62,47,94,89,40,06,22);
|
||||
$tabFirst[4]=array(15,52,46,26,24,82,49,36,25);
|
||||
$tabFirst[5]=array(64,86,30,05,51,75,58,66,28);
|
||||
$tabFirst[6]=array(16,23,14,81,78,68,67,96,31);
|
||||
$tabFirst[7]=array(65,57,95,60,08,61,76,29,34);
|
||||
$tabFirst[8]=array(17,91,79,39,35,54,85,59,37);
|
||||
$tabFirst[9]=array(66,28,63,18,62,47,94,89,40);
|
||||
|
||||
// Chiffre 0 à 9
|
||||
$tabPoids=array(1,34,-16,-21,27,-7,9,30,3);
|
||||
$cle=$first=0;
|
||||
for($pos=0; $pos<9; $pos++) {
|
||||
$chiffre=$siren[$pos];
|
||||
if ($first==0) {
|
||||
$first=$cle=$tabFirst[$chiffre][$pos];
|
||||
} else {
|
||||
$cle+=$tabPoids[$pos]*$chiffre;
|
||||
}
|
||||
}
|
||||
while(true) {
|
||||
if ($cle>96) $cle=$cle-97;
|
||||
elseif ($cle<0) $cle=$cle+97;
|
||||
else break;
|
||||
}
|
||||
if ($cle==0) return 96;
|
||||
return ($cle-1);
|
||||
}
|
||||
|
||||
|
||||
/** Test de la validité du siren demandé
|
||||
** @param int SIREN à tester
|
||||
** @param int NIC (facultatif)
|
||||
** @param mixed Message textuel d'erreur à afficher en cas d'erreur ou false
|
||||
** @return mixed true, false ou Message d'erreur passé en paramètre
|
||||
**/
|
||||
private function valideSiren($siren, $nic='', $erreur=false) {
|
||||
|
||||
/** Si le siren est de taille < à 9, on ajoute des 0 significatifs **/
|
||||
switch (strlen($siren)) {
|
||||
case 1: $siren='00000000'.$siren; break;
|
||||
case 2: $siren='0000000'.$siren; break;
|
||||
case 3: $siren='000000'.$siren; break;
|
||||
case 4: $siren='00000'.$siren; break;
|
||||
case 5: $siren='0000'.$siren; break;
|
||||
case 6: $siren='000'.$siren; break;
|
||||
case 7: $siren='00'.$siren; break;
|
||||
case 8: $siren='0'.$siren; break;
|
||||
}
|
||||
|
||||
if (strlen($nic)>0) {
|
||||
switch (strlen($nic)) {
|
||||
case 1: $nic='0000'.$nic; break;
|
||||
case 2: $nic='000'.$nic; break;
|
||||
case 3: $nic='00'.$nic; break;
|
||||
case 4: $nic='0'.$nic; break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!valideData($siren, 9, 9,'N')) //Siren non précisé ou incorrect.
|
||||
return $erreur;
|
||||
elseif ($siren*1==0) // Siren vide
|
||||
return $erreur;
|
||||
else
|
||||
{
|
||||
if (!isset($nic) || trim($nic)=='')
|
||||
{
|
||||
$somme=0;
|
||||
for ($i=0; $i<=8; $i+=2) // Traitement IMPAIR
|
||||
$somme+=(integer)substr($siren,$i,1);
|
||||
|
||||
for ($i=1; $i<=7; $i+=2)
|
||||
{ // Traitement PAIR
|
||||
$var_tmp=(string)(2*((integer)substr($siren,$i,1)));
|
||||
$som_tmp=0;
|
||||
for($j=0;$j<strlen($var_tmp);$j++)
|
||||
$som_tmp+=(integer)substr($var_tmp,$j,1);
|
||||
$somme+=$som_tmp;
|
||||
}
|
||||
|
||||
if ((integer)($somme/10)!=($somme/10))
|
||||
{ // Le Siren est faux
|
||||
if (substr($siren,0,3)!='200') // Les siren débutant par 200 sont toujours valides (sirens provisoires de la BDF?!)
|
||||
return $erreur;
|
||||
}
|
||||
} else {
|
||||
if (!valideData($nic,1,5,'N')) // Nic de format incorrect.
|
||||
return $erreur;
|
||||
|
||||
$SIRET=$siren.$nic;
|
||||
$somme=0;
|
||||
for ($i=0; $i<=12; $i+=2)
|
||||
{ // Traitement PAIR
|
||||
$var_tmp=(string)(2*((integer)substr($SIRET,$i,1)));
|
||||
$som_tmp=0;
|
||||
for($j=0;$j<strlen($var_tmp);$j++)
|
||||
$som_tmp+=(integer)substr($var_tmp,$j,1);
|
||||
$somme+=$som_tmp;
|
||||
}
|
||||
for ($i=1; $i<=13; $i+=2) // Traitement IMPAIR
|
||||
$somme+=(integer)substr($SIRET,$i,1);
|
||||
|
||||
if ((integer)($somme/10)!=($somme/10))// Le Siret est faux
|
||||
return $erreur;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
772
library/Metier/partenaires/classMWeb.php
Normal file
772
library/Metier/partenaires/classMWeb.php
Normal file
@ -0,0 +1,772 @@
|
||||
<?
|
||||
|
||||
class MSitesWeb {
|
||||
|
||||
private $whois_serveurs = array(
|
||||
"ac" => "whois.nic.ac",
|
||||
"al" => "whois.ripe.net",
|
||||
"am" => "whois.amnic.net",
|
||||
"as" => "whois.nic.as",
|
||||
"at" => "whois.ripe.net",
|
||||
"au" => "whois.aunic.net",
|
||||
"az" => "whois.ripe.net",
|
||||
"ba" => "whois.ripe.net",
|
||||
"be" => "whois.ripe.net",
|
||||
"bg" => "whois.ripe.net",
|
||||
"biz" => "whois.nic.biz",
|
||||
"br" => "whois.registro.br",
|
||||
"by" => "whois.ripe.net",
|
||||
"ca" => "whois.cira.ca",
|
||||
"cc" => "whois.nic.cc",
|
||||
"ch" => "whois.nic.ch",
|
||||
"ck" => "whois.ck-nic.org.ck",
|
||||
"cn" => "whois.cnnic.net.cn",
|
||||
"com" => "whois.crsnic.net",
|
||||
"cx" => "whois.nic.cx",
|
||||
"cy" => "whois.ripe.net",
|
||||
"cz" => "whois.nic.cz",
|
||||
"de" => "whois.denic.de",
|
||||
"dk" => "whois.dk-hostmaster.dk",
|
||||
"dz" => "whois.ripe.net",
|
||||
"edu" => "rs.internic.net",
|
||||
"ee" => "whois.ripe.net",
|
||||
"eg" => "whois.ripe.net",
|
||||
"es" => "whois.ripe.net",
|
||||
"eu" => "whois.eu",
|
||||
"fi" => "whois.ripe.net",
|
||||
"fj" => "whois.usp.ac.fj",
|
||||
"fo" => "whois.ripe.net",
|
||||
"fr" => "whois.nic.fr",
|
||||
"gb" => "whois.ripe.net",
|
||||
"ge" => "whois.ripe.net",
|
||||
"gov" => "whois.nic.gov",
|
||||
"gr" => "whois.ripe.net",
|
||||
"gs" => "whois.adamsnames.tc",
|
||||
"hk" => "whois.hknic.net.hk",
|
||||
"hm" => "whois.registry.hm",
|
||||
"hr" => "whois.ripe.net",
|
||||
"hu" => "whois.ripe.net",
|
||||
"id" => "whois.idnic.net.id",
|
||||
"ie" => "whois.domainregistry.ie",
|
||||
"info" => "whois.afilias.net",
|
||||
"int" => "whois.isi.edu",
|
||||
"il" => "whois.ripe.net",
|
||||
"is" => "whois.isnet.is",
|
||||
"it" => "whois.nic.it",
|
||||
"jp" => "whois.nic.ad.jp",
|
||||
"ke" => "whois.rg.net",
|
||||
"kg" => "whois.domain.kg",
|
||||
"kr" => "whois.nic.or.kr",
|
||||
"kz" => "whois.domain.kz",
|
||||
"li" => "whois.nic.li",
|
||||
"lk" => "whois.nic.lk",
|
||||
"lt" => "whois.ripe.net",
|
||||
"lu" => "whois.ripe.net",
|
||||
"lv" => "whois.ripe.net",
|
||||
"ma" => "whois.ripe.net",
|
||||
"md" => "whois.ripe.net",
|
||||
"mil" => "whois.nic.mil",
|
||||
"mk" => "whois.ripe.net",
|
||||
"mm" => "whois.nic.mm",
|
||||
"ms" => "whois.adamsnames.tc",
|
||||
"mt" => "whois.ripe.net",
|
||||
"mx" => "whois.nic.mx",
|
||||
"net" => "rs.internic.net",
|
||||
"nl" => "whois.domain-registry.nl",
|
||||
"no" => "whois.norid.no",
|
||||
"nu" => "whois.nic.nu",
|
||||
"nz" => "whois.domainz.net.nz",
|
||||
"org" => "whois.pir.org",
|
||||
"pl" => "whois.ripe.net",
|
||||
"pk" => "whois.pknic.net.pk",
|
||||
"pt" => "whois.ripe.net",
|
||||
"ro" => "whois.ripe.net",
|
||||
"ru" => "whois.ripn.ru",
|
||||
"se" => "whois.nic-se.se",
|
||||
"sg" => "whois.nic.net.sg",
|
||||
"si" => "whois.ripe.net",
|
||||
"sh" => "whois.nic.sh",
|
||||
"sk" => "whois.ripe.net",
|
||||
"sm" => "whois.ripe.net",
|
||||
"st" => "whois.nic.st",
|
||||
"su" => "whois.ripe.net",
|
||||
"tc" => "whois.adamsnames.tc",
|
||||
"tf" => "whois.adamsnames.tc",
|
||||
"tj" => "whois.nic.tj",
|
||||
"th" => "whois.thnic.net",
|
||||
"tm" => "whois.nic.tm",
|
||||
"tn" => "whois.ripe.net",
|
||||
"to" => "whois.tonic.to",
|
||||
"tr" => "whois.ripe.net",
|
||||
"tw" => "whois.twnic.net",
|
||||
"ua" => "whois.ripe.net",
|
||||
"uk" => "whois.nic.uk",
|
||||
"us" => "whois.isi.edu",
|
||||
"va" => "whois.ripe.net",
|
||||
"vg" => "whois.adamsnames.tc",
|
||||
"ws" => "whois.nic.ws",
|
||||
"yu" => "whois.ripe.net",
|
||||
"za" => "whois.frd.ac.za");
|
||||
|
||||
private $iInsee;
|
||||
private $iDb;
|
||||
|
||||
function __construct(/*$siren, $accesDist=true*/) {
|
||||
$this->iInsee=new MInsee();
|
||||
$this->iDb=new WDB('jo');
|
||||
}
|
||||
|
||||
/** L'adresse IP est elle valide ?
|
||||
* @param $ip Adresse IP v4
|
||||
*/
|
||||
function isIpValide($ip) {
|
||||
$ip_explode = explode('.',$ip);
|
||||
$nb_valide = 0;
|
||||
foreach ($ip_explode as $element)
|
||||
if ($element>=0 && $element<255)
|
||||
$nb_valide++;
|
||||
if ($nb_valide==4) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
function getInfosSiteWeb($url) {
|
||||
$tabRet=array('url'=>$url, 'url_valide'=>0);
|
||||
// Est-ce une URL valide en paramètre ?
|
||||
if(preg_match('|^(http(s)?://)?[a-z0-9-]+(.[a-z0-9-]+)*(:[0-9]+)?(/.*)?$|i', $url)) {
|
||||
//$tabRet['url']=preg_replace('/^http\/\//', 'http://', $url);
|
||||
$tabRet['url_valide']=1;
|
||||
$info=parse_url($url);
|
||||
$host=@preg_replace('/\/$/','',$info['host']);
|
||||
$ext=getFileExtension($host);
|
||||
$domaine=getFileExtension(preg_replace("/\.$ext$/",'','.'.$host));
|
||||
$tabRet['url_scheme']=@$info['scheme'];
|
||||
$tabRet['url_host']=@$info['host'];
|
||||
$tabRet['url_path']=@$info['path'];
|
||||
$tabRet['url_query']=@$info['query'];
|
||||
$tabRet['url_fragment']=@$info['fragment'];
|
||||
|
||||
$tabRet['domaine']="$domaine.$ext";
|
||||
$tabRet['domaine_valide']=0;
|
||||
// Le nom de domaine est il actif ?
|
||||
if (checkdnsrr("$domaine.$ext")) {
|
||||
$tabRet['domaine_valide']=1;
|
||||
$ip=gethostbyname("$domaine.$ext");
|
||||
if ($this->isIpValide($ip)) $tabRet['ip']=$ip;
|
||||
$page=getUrl("http://$host", '', '', '', false, "$domaine.$ext", '', 3, 0);
|
||||
// Le site est il actif ?
|
||||
if ($page['code']==400 || $page['code']==408) {
|
||||
$tabRet['erreur_num']=@$page['header']['curl_errno'];
|
||||
$tabRet['erreur_txt']=@$page['header']['curl_error'];
|
||||
} else {
|
||||
/** @todo Vérifier les pages de parking et les sites non encore terminés **/
|
||||
$tabRet['code']=$page['code'];
|
||||
//$tabRet['header']=$page['header'];
|
||||
$tabRet['header_server']=trim($page['header']['Server']);
|
||||
$tabRet['header_location']=trim($page['header']['Location']);
|
||||
$tabRet['header_powerby']=trim($page['header']['X-Powered-By']);
|
||||
$tabRet['header_content']=trim($page['header']['Content-Type']);
|
||||
$tabRet['html_size']=strlen($page['body']);
|
||||
if (preg_match('/<head>(.*)<\/head>/Uis',$page['body'],$matches)) {
|
||||
$html_head=$matches[1];
|
||||
$tabRet['html_head']=$html_head;
|
||||
if (preg_match('/<title>(.*)<\/title>/Uis',$html_head,$matches))
|
||||
$tabRet['html_title']=utf8_decode(trim($matches[1]));
|
||||
if (preg_match_all('/<meta\s+name(?:\s+|)=(.*)\scontent(?:\s+|)=(.*)>/Uis',$html_head,$matches)) {
|
||||
foreach ($matches[1] as $i=>$metaName) {
|
||||
$meta=strtolower(trim(strtr($metaName, array('"'=>'', "'"=>''))));
|
||||
$content=utf8_decode(preg_replace('/^(?:\s+|)("|\')/Uis','',
|
||||
preg_replace('/("|\')(?:\s+|)(?:\/|)$/Uis','',
|
||||
$matches[2][$i])));
|
||||
switch ($meta) {
|
||||
case 'title':
|
||||
$meta='metatitle';
|
||||
case 'content-language':
|
||||
$meta='language';
|
||||
case 'languages':
|
||||
$meta='language';
|
||||
case 'language':
|
||||
case 'revisit-after':
|
||||
case 'coverage':
|
||||
case 'copyright':
|
||||
case 'author':
|
||||
case 'rating':
|
||||
case 'resource-type':
|
||||
case 'classification':
|
||||
case 'distribution':
|
||||
case 'doc-rights':
|
||||
case 'doc-type':
|
||||
case 'robots':
|
||||
case 'keywords':
|
||||
case 'description':
|
||||
case 'generator':
|
||||
case 'category':
|
||||
case 'owner':
|
||||
case 'identifier-url':
|
||||
$tabRet['html_'.$meta]=utf8_decode(trim($content));
|
||||
break;
|
||||
default:
|
||||
echo "$meta='$content'".EOL;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return $tabRet;
|
||||
}
|
||||
|
||||
function getInfosAfnic($siteWeb) {
|
||||
$referer='http://www.afnic.fr/';
|
||||
$url='http://www.afnic.fr/outils/whois/'.$siteWeb;
|
||||
$page=getUrl($url, '', '', $referer);
|
||||
if ($page['code']==200) {
|
||||
$tabRet=array();
|
||||
if (preg_match('/<b>Bureau d’enregistrement \: <\/b>.*">(.*)<\/a><br>/Uis',$page['body'],$matches))
|
||||
$tabRet['registrar']=$matches[1];
|
||||
if (preg_match('/<\/noscript><b>État \:<\/b>(.*)<\/b>/Uis',$page['body'],$matches)) {
|
||||
$tabRet['etat']=trim($matches[1]); /*
|
||||
Actif (consultez aussi le <b><a href="http://www.decideo.fr" class="ext" target="_BLANC">Site web</a>*/
|
||||
if (preg_match('/<b><a href="(.*)"/Uis',$tabRet['etat'],$matches))
|
||||
$tabRet['siteWeb']=trim($matches[1]);
|
||||
$tmp=explode(' (', $tabRet['etat']);
|
||||
$tabRet['etat']=$tmp[0];
|
||||
}
|
||||
if (preg_match('/<b>Date de création \: <\/b>(.*)<br>/Uis',$page['body'],$matches))
|
||||
$tabRet['dateCrea']=$matches[1];
|
||||
if (preg_match('/<b>Date anniversaire \: <\/b>(.*)<br>/Uis',$page['body'],$matches))
|
||||
$tabRet['dateAnniv']=trim($matches[1]);
|
||||
|
||||
if (preg_match("/<span class=h1>Titulaire \: <\/span>(.*)<br><div style='clear\: both;'><\/div>/Uis",$page['body'],$matches)) {
|
||||
$strTitu=trim($matches[1]);
|
||||
if (preg_match("/<span class=bleuvif>(.*)<\/span><\/h2>/Uis",$strTitu,$matches))
|
||||
$tabRet['tituNom']=trim($matches[1]);
|
||||
if (preg_match("/<noscript><div id='Layer2' style='display\: block;'><\/noscript>(.*)<b>/Uis",$strTitu,$matches)) {
|
||||
$tabRet['tituAdr']=strip_tags(trim($matches[1]));
|
||||
$tmp=$this->iInsee->structureVoie($tabRet['tituAdr']);
|
||||
$tabRet['tituAdrNum']=$tmp['num'];
|
||||
$tabRet['tituAdrCp']=$tmp['cp'];
|
||||
$tabRet['tituAdrVille']=preg_replace('/ FRANCE$/','',trim($tmp['ville']));
|
||||
$tabRet['tituAdrTypVoie']=$tmp['typeVoie'];
|
||||
$tabRet['tituAdrLibVoie']=$tmp['libVoie'];
|
||||
$tabRet['tituAdrComp']=$tmp['adrComp0'];
|
||||
}
|
||||
if (preg_match("/<b>Téléphone \: <\/b>(.*)<br>/Uis",$strTitu,$matches))
|
||||
$tabRet['tituTel']=trim($matches[1]);
|
||||
if (preg_match('/<b>Courrier électronique \: <\/b> <a href="mailto:(.*)">/Uis',$strTitu,$matches))
|
||||
$tabRet['tituMel']=trim($matches[1]);
|
||||
}
|
||||
|
||||
if(preg_match('/<li>Identifié grâce au numéro de SIREN <a href="(?:.*) target="_blank" class="ext">(.*)<\/a><\/li>/Uis', $page['body'], $matches))
|
||||
$tabRet['siren']=html_entity_decode($matches[1]);
|
||||
elseif (preg_match('/<li>Identifié grâce à la marque française \((.*)\) <\/li>/Uis', $page['body'], $matches))
|
||||
$tabRet['marquefr']=html_entity_decode($matches[1]);
|
||||
} else
|
||||
return $page['code'];
|
||||
|
||||
return $tabRet;
|
||||
}
|
||||
|
||||
function findSiteWeb($siren, $nomEntrep='') {
|
||||
// Recherche BING
|
||||
$appId = '56D6CBA671C986D3EA11B1B48F97507BC5A00D51';
|
||||
$numResults = 50;
|
||||
$cultureInfo = 'fr-FR';
|
||||
|
||||
$siren2=implode(' ', str_split($siren, 3));
|
||||
if ($nomEntrep<>'') $rs2="OR \"$nomEntrep\"";
|
||||
$tabSitesExclus=array('societe.com','bilans.net','gouv.fr','info-financiere.fr','bodacc.fr','manageo.fr','bilansgratuits.fr','lesechos.fr','google.fr');
|
||||
|
||||
$rs="$siren OR \"$siren2\" $rs2 -site:".implode(' -site:', $tabSitesExclus);
|
||||
|
||||
$query=stripslashes(urlencode($rs));
|
||||
|
||||
$tabSources=array( 'web'=>'Web page results',
|
||||
/*'image'=>'Full-size image and thumbnail image information, including the file size in bytes (if available), height and width in pixels (if available), and the URI to the full-size image or thumbnail',
|
||||
'instantAnswer'=>'Answers. The result fields returned for requests that specify InstantAnswer vary based on the value or values specified for the Query property. InstantAnswer results can include Encarta, FlightStatus, Finance, Music, Sports, Weather, and Movie ShowTimes. For the Version 2.0 release, results include Encarta and FlightStatus only. Other results are available by invitation',
|
||||
'mobileWeb'=>'Mobile Web page results (primarily Extensible Hypertext Markup Language (XHTML) and Wireless Markup Language (WML)',
|
||||
'phoneBook'=>'Results from online White Pages (residential) and Yellow Pages (commercial) entries',
|
||||
'relatedSearch'=>'Suggestions for other searches related to the query term or terms',
|
||||
'spell'=>'Spelling suggestions',
|
||||
'translation'=>'Translated results for a queried',
|
||||
'video'=>'Video results',*/
|
||||
//'news'=>'Results from online news services',
|
||||
);
|
||||
$source=implode('+', array_keys($tabSources));
|
||||
|
||||
$url="http://api.bing.net/json.aspx?AppId=$appId&Version=2.2&Market=$cultureInfo&Query=$query&Sources=$source&Web.Count=$numResults&JsonType=raw";
|
||||
$page=getUrl($url, '', '', $referer, false);
|
||||
$json=$page['body'];
|
||||
|
||||
$tabJson=json_decode($json, true);
|
||||
$tabJson=$tabJson['SearchResponse'];
|
||||
|
||||
$levMin=100;
|
||||
$pctMin=0;
|
||||
$urlLev=$urlPct='';
|
||||
$urlapprox="http://www.$nomEntrep.fr/";
|
||||
|
||||
foreach ($tabJson['Web']['Results'] as $i=> $result) {
|
||||
|
||||
$title=utf8_decode($result['Title']); // SCORES & DECISIONS - Accueil
|
||||
$desc=utf8_decode($result['Description']); // Scores et Décisions - Le nouvel acteur de l'information sur les entreprises et leurs dirigeants avec une approche innovante
|
||||
$url=$result['Url']; // http://www3.scores-decisions.com/
|
||||
|
||||
$lev=@levenshtein ($urlapprox,$url);
|
||||
if ($lev>0 && $lev<$levMin) {
|
||||
$levMin=$lev;
|
||||
$urlLev=$url;
|
||||
}
|
||||
$sim=similar_text($urlapprox,$url,$pct);
|
||||
if ($pct>$pctMin && strpos($url, 'zonebourse')===false) {
|
||||
$pctMin=$pct;
|
||||
$urlPct=$url;
|
||||
}
|
||||
if (preg_match('/\.(.*\.fr)\//', $url, $matches2)) {
|
||||
}
|
||||
|
||||
$info=parse_url($url);
|
||||
$host=preg_replace('/\/$/','',$info['host']);
|
||||
$ext=getFileExtension($host);
|
||||
$domaine=getFileExtension(preg_replace("/\.$ext$/",'','.'.$host));
|
||||
echo "RECHERCHE DE '$nomEntrep' ($siren) : Trouvé $domaine.$ext".EOL;
|
||||
if ($ext=='fr') {
|
||||
$rep=$this->iDb->select('sitesWeb', 'siren, web', "web=$url");
|
||||
if (@$rep[0]['siren']*1==0) {
|
||||
$tabAfnic=$this->getInfosAfnic("$domaine.$ext");
|
||||
$siren=$tabAfnic['siren']*1;
|
||||
if ($siren>0) {
|
||||
$tabInsert=array('siren'=>$siren,
|
||||
'web'=>$url,
|
||||
'dateInsert'=>date('YmdHis'));
|
||||
$this->iDb->insert('sitesWeb', $tabInsert);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($levMin<15 && $pctMin>44 && $urlLev==$urlPct) {
|
||||
echo date('Y-m-d H:i:s') .' - '. $page['code'] . " - $rs - $i - $lev (Min=$levMin) - $pct (Min=$pctMin) - $urlLev - $urlPct - $url !!! RETURNED !!!".EOL;
|
||||
return $urlLev;
|
||||
}
|
||||
|
||||
}
|
||||
/*
|
||||
[0] => Array
|
||||
(
|
||||
[Title] => SCORES & DECISIONS - Accueil
|
||||
[Description] => Scores et Décisions - Le nouvel acteur de l'information sur les entreprises et leurs dirigeants avec une approche innovante
|
||||
[Url] => http://www3.scores-decisions.com/
|
||||
[CacheUrl] => http://cc.bingj.com/cache.aspx?q=scores+decisions&d=5004075153885515&mkt=fr-FR&w=881d2897,4f2fff68
|
||||
[DisplayUrl] => www3.scores-decisions.com
|
||||
[DateTime] => 2011-02-14T12:24:00Z
|
||||
[DeepLinks] => Array
|
||||
(
|
||||
[0] => Array
|
||||
(
|
||||
[Title] => Partenaires
|
||||
[Url] => http://www3.scores-decisions.com/partenaires.php
|
||||
)
|
||||
[1] => Array
|
||||
(
|
||||
[Title] => Contact
|
||||
[Url] => http://www3.scores-decisions.com/contact.php
|
||||
)
|
||||
)
|
||||
)
|
||||
[1] => Array
|
||||
(
|
||||
[Title] => SCORES & DECISIONS - Société
|
||||
[Description] => Scores et Décisions - Le nouvel acteur de l'information sur les entreprises et leurs dirigeants avec une approche innovante
|
||||
[Url] => http://www3.scores-decisions.com/societe.php
|
||||
[CacheUrl] => http://cc.bingj.com/cache.aspx?q=scores+decisions&d=4747772983970513&mkt=fr-FR&w=10f5cd33,9b81f773
|
||||
[DisplayUrl] => www3.scores-decisions.com/societe.php
|
||||
[DateTime] => 2011-02-13T02:17:00Z
|
||||
)*/
|
||||
return false;
|
||||
}
|
||||
|
||||
function whois($domaine) {
|
||||
$parseur=explode(".", $domaine);
|
||||
$hote=$this->whois_serveurs[strtolower($parseur[count($parseur)-1])];
|
||||
$msg='';
|
||||
|
||||
if (empty($hote)) {
|
||||
$msg="Extension du domaine '$domaine' inconnue";
|
||||
} else {
|
||||
$fp = fsockopen($hote, 43, $errno, $errstr, 10);
|
||||
if (!$fp) {
|
||||
$msg="Erreur de socket no$errno : $errstr";
|
||||
} else {
|
||||
fputs($fp, $domaine . "\r\n");
|
||||
$buf=$server='';
|
||||
while (!feof($fp)) {
|
||||
$row=fgets($fp, 128);
|
||||
$buf.=$row;
|
||||
if (eregi("Whois Server:", $row))
|
||||
$server = trim(str_replace('Whois Server:', '', $row));
|
||||
}
|
||||
fclose($fp);
|
||||
if (ereg("No match for", $buf) ||
|
||||
ereg("NOT FOUND", $buf) ||
|
||||
ereg("Status: FREE", $buf) ||
|
||||
ereg("No entries found", $buf) ||
|
||||
ereg("Not found", $buf) ||
|
||||
ereg("AVAIL", $buf)) {
|
||||
$msg="Domaine '$domaine' libre";
|
||||
} else {
|
||||
//echo "<p><strong>Le nom de domaine <font color=\"red\">" . $_POST['domaine'] . "</font> est déjà pris</strong></p>";
|
||||
if ($server<>'') {
|
||||
$msg="Domaine '$domaine' enregistré chez '$server'";
|
||||
$fp = fsockopen($server, 43, $errno, $errstr, 10);
|
||||
fputs($fp, $domaine."\r\n");
|
||||
$buf2='';
|
||||
while (!feof($fp))
|
||||
$buf2.=fgets($fp, 128);
|
||||
fclose($fp);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return array( 'error'=>$msg,
|
||||
'whoisSrv'=>$hote,
|
||||
'whoisSrv2'=>$server,
|
||||
'whoisTxt'=>$buf,
|
||||
'whoisTxt2'=>$buf2);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/** Retourne l'extension d'un domaine ou du fichier !!! **/
|
||||
function getFileExtension($filepath) {
|
||||
preg_match('/[^?]*/', $filepath, $matches);
|
||||
$string = $matches[0];
|
||||
$pattern = preg_split('/\./', $string, -1, PREG_SPLIT_OFFSET_CAPTURE);
|
||||
|
||||
// check if there is any extension
|
||||
if(count($pattern) == 1)
|
||||
return false;
|
||||
|
||||
if(count($pattern)>1) {
|
||||
$filenamepart = $pattern[count($pattern)-1][0];
|
||||
preg_match('/[^?]*/', $filenamepart, $matches);
|
||||
return $matches[0];
|
||||
}
|
||||
}
|
||||
|
||||
function ShowFileName($filepath)
|
||||
{
|
||||
preg_match('/[^?]*/', $filepath, $matches);
|
||||
$string = $matches[0];
|
||||
#split the string by the literal dot in the filename
|
||||
$pattern = preg_split('/\./', $string, -1, PREG_SPLIT_OFFSET_CAPTURE);
|
||||
#get the last dot position
|
||||
$lastdot = $pattern[count($pattern)-1][1];
|
||||
#now extract the filename using the basename function
|
||||
$filename = basename(substr($string, 0, $lastdot-1));
|
||||
#return the filename part
|
||||
return $filename;
|
||||
}
|
||||
|
||||
|
||||
/********************************************************************************
|
||||
* @proto (array) $page get_web_file( (string) $url[, (string) $user_agent ] )
|
||||
|
||||
* @desc cURL va chercher $url en temps que $user_agent
|
||||
* @desc et retourne entre autre $page['content']
|
||||
|
||||
* @comm -régler le timeout
|
||||
* @comm a du mal à renvoyer des bin dans $header['content']
|
||||
********************************************************************************/
|
||||
|
||||
function get_web_file( $url, $user_agent = 'Opera/9.64 (X11; Linux i686; U; en) Presto/2.1.1' )
|
||||
{
|
||||
$options = array(
|
||||
//CURLOPT_SSL_VERIFYPEER => false, // Ne vérifie pas les certificats
|
||||
CURLOPT_RETURNTRANSFER => true, // return plutôt que echo|print
|
||||
CURLOPT_HEADER => true, // Renvoie les headers
|
||||
//CURLOPT_FOLLOWLOCATION => true, // Suivre les redirections, limité par...
|
||||
CURLOPT_MAXREDIRS => 500, // ...le max de redirections
|
||||
CURLOPT_ENCODING => '', // Accepte tous les encodages
|
||||
CURLOPT_USERAGENT => $user_agent,// Qui Je Suis (avec Jackie Chan)
|
||||
CURLOPT_AUTOREFERER => true, // Set referer on redirect
|
||||
CURLOPT_CONNECTTIMEOUT => 5,
|
||||
CURLOPT_TIMEOUT => 3, // Temps maximum d'utilisation de cURL (s)
|
||||
);
|
||||
|
||||
$ch = curl_init($url);
|
||||
curl_setopt_array($ch, $options);
|
||||
$content = curl_exec($ch); // contenu de la page
|
||||
$page['errno'] = curl_errno($ch); // code d'erreur cURL
|
||||
$page['errmsg'] = curl_error($ch); // message d'erreur cURL
|
||||
$curl = curl_getinfo($ch);
|
||||
curl_close($ch);
|
||||
|
||||
$page['url'] = $curl['url']; // possibles redirections = dernière url
|
||||
$page['http_code'] = $curl['http_code'];
|
||||
$page['total_time'] = $curl['total_time'];
|
||||
$page['redirect_count'] = $curl['redirect_count'];
|
||||
$page['content'] = $content;
|
||||
|
||||
return $page;
|
||||
}
|
||||
/* $page return as below:
|
||||
Array
|
||||
(
|
||||
[url] => l'url
|
||||
[http_code] => l'erreur http
|
||||
[redirect_count] => nombre de redirections
|
||||
[total_time] => temps d'execution
|
||||
[errno] => numéro d'erreur cURL
|
||||
[errmsg] => message d'erreur
|
||||
[content] => fichier en string :p
|
||||
)
|
||||
*/
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/********************************************************************************
|
||||
* @proto (integer) $http_error get_http_error( (string) $url )
|
||||
********************************************************************************/
|
||||
|
||||
function get_http_error( $url )
|
||||
{
|
||||
$options = array(
|
||||
//CURLOPT_SSL_VERIFYPEER => false,
|
||||
CURLOPT_RETURNTRANSFER => true,
|
||||
CURLOPT_HEADER => true,
|
||||
CURLOPT_NOBODY => true, // get_http_error() doit être faster than get_web_file()
|
||||
//CURLOPT_FOLLOWLOCATION => true,
|
||||
CURLOPT_MAXREDIRS => 500,
|
||||
CURLOPT_ENCODING => '',
|
||||
CURLOPT_USERAGENT => 'Opera/9.64 (X11; Linux i686; U; en) Presto/2.1.1',
|
||||
CURLOPT_AUTOREFERER => true,
|
||||
CURLOPT_CONNECTTIMEOUT => 120,
|
||||
CURLOPT_TIMEOUT => 0,
|
||||
);
|
||||
|
||||
$ch = curl_init($url);
|
||||
curl_setopt_array($ch, $options);
|
||||
curl_exec($ch);
|
||||
$errmsg = curl_error($ch);
|
||||
$curl = curl_getinfo($ch);
|
||||
curl_close($ch);
|
||||
|
||||
return ( $curl['http_code'] === 0 ) ? $errmsg : $curl['http_code'];
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/********************************************************************************
|
||||
* @proto (string) $cleansed_url resolve_url( (string) $raw_url, (string) $url )
|
||||
* @link http://en.wikipedia.org/wiki/Uniform_Resource_Locator
|
||||
* @desc reconstruit $raw_url à partir de $url et en déduit des $res['url']
|
||||
* @comm gère les mails
|
||||
********************************************************************************/
|
||||
|
||||
function resolve_url( $raw_url, $url )
|
||||
{
|
||||
$cleansed_url = '';
|
||||
|
||||
// Met un slash à la fin des racines si yen a pas
|
||||
if ( preg_match('#^[^:/]+:/+[^/]+$#', $url) ) $url = $url.'/';
|
||||
if ( preg_match('#^[^:/]+:/+[^/]+$#', $raw_url) ) $raw_url = $raw_url.'/';
|
||||
|
||||
// Racine du site
|
||||
preg_match('#^([^:/]+:/+[^/]+/)#', $url, $preg_racine);
|
||||
$racine = $preg_racine[1];
|
||||
// Dossier courant
|
||||
preg_match('#(.+/)[^/]*$#', $url, $preg_courant);
|
||||
$courant = $preg_courant[1];
|
||||
/* On sait qu'un dossier en est un quand il se termine par un /
|
||||
Pour cette même raison, on ne peut déterminer avec certitude si on a un fichier plutôt qu'un dossier.
|
||||
Sauf (dans un contexte initial : sans URL-Rewriting) quand il y a une ancre : c'est un fichier. */
|
||||
// Non-dossier courant
|
||||
$sub_nondir_courant = substr($url, strlen($courant) - 1);
|
||||
$nondir_courant = ( $sub_nondir_courant === false ) ? '' : $sub_nondir_courant;
|
||||
//Scheme et slashs
|
||||
|
||||
|
||||
/* Modif's */
|
||||
|
||||
if ( $raw_url[0] == '/' ) // Si $raw_url commence par un /
|
||||
$cleansed_url = $racine . substr($raw_url, 1); // substr() empêche le double slash
|
||||
|
||||
else if ( $raw_url[0] == '.' ) // Pour ./ et ../
|
||||
$cleansed_url = $courant . $raw_url;
|
||||
|
||||
else if ( $raw_url[0] == '?' || $raw_url[0] == '&' ) // Si c'est une query
|
||||
$cleansed_url = $url . $raw_url; // Le '&' : espoir
|
||||
|
||||
else if ( $raw_url[0] == '#' ) // Si c'est une ancre et que n'en a pas déjà une
|
||||
$cleansed_url = ( !preg_match('%#[^#]*$%', $url) ) ? $url.$raw_url : '';
|
||||
|
||||
else if ( preg_match('#^javascript\s*:#i', $raw_url) ) // Quand du javascript est déclaré
|
||||
$cleansed_url = '';
|
||||
|
||||
else if ( preg_match('#^mailto\s*:\s*((?:[^i]|i)+)$#i', $raw_url, $mail) ) // Quand c'est un mail
|
||||
$cleansed_url = '';
|
||||
|
||||
else if ( preg_match('#^[^:/]+:/#', $raw_url) ) // Quand raw_url est une url normale
|
||||
$cleansed_url = $raw_url;
|
||||
|
||||
else if ( !preg_match('#^[^:/]+:/#', $raw_url) ) // Quand c'est tout sauf ce qu'on a dit et une url
|
||||
$cleansed_url = $courant . $raw_url;
|
||||
|
||||
else { } // Tous les autres cas ne conviennent pas
|
||||
|
||||
|
||||
/* Après toutes les modif's */
|
||||
|
||||
// Supprime les résultats qui ne commencent pas par xxx://
|
||||
if (
|
||||
!preg_match('#^[^:/]+:/+#', $cleansed_url) //$cleansed_url != ^http://$
|
||||
//|| $raw_url[0] == '#' //$raw_url ^#
|
||||
|| preg_match('#^[^:/]+:/+\s*$#', $cleansed_url) //$cleansed_url == ^http:// $
|
||||
|| !is_string($cleansed_url)
|
||||
)
|
||||
$cleansed_url = '';
|
||||
|
||||
if ( !empty($cleansed_url) )
|
||||
{
|
||||
$cleansed_url = trim($cleansed_url);
|
||||
|
||||
/*** remplace /./ par / ***/
|
||||
$cleansed_url = str_replace('/./', '/', $cleansed_url);
|
||||
|
||||
/*** remplace // par / s'ils ne commencent pas par : comme dans 'file:///' ***/
|
||||
$cleansed_url = preg_replace('#(?<!\:)//#', '/', $cleansed_url); //does work!!!
|
||||
|
||||
/*** supprime les /../ ***/
|
||||
while ( substr_count($cleansed_url, "../") ) //tant qu'il y a des /../
|
||||
{
|
||||
$cleansed_url = preg_replace('#/[^/]+/\.\.#', '', $cleansed_url); // But : see PHP.net online manual comment
|
||||
}
|
||||
}
|
||||
|
||||
return $cleansed_url;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/********************************************************************************
|
||||
* @proto (array) $urls get_urls( (string) $raw_page_content, (string) $url )
|
||||
* @desc extrait les urls de $raw_page_content et les reconstruits à l'aide de $url
|
||||
********************************************************************************/
|
||||
|
||||
function get_urls( $raw_page_content, $url )
|
||||
{
|
||||
$raw_page_content .= PHP_EOL;
|
||||
$matches = $urls = array();
|
||||
|
||||
$regexs = array( // À réécrire avec % ... %x et % ... %u
|
||||
/* Fais chier : un jour que j'améliorais *grave* mes regexs, le ventirad s'est décroché et mon /home/ est devenu illisible...
|
||||
Tout marchait *très bien* et j'avais rajouté des captures ! Me disant même "Heureusement que je l'ai vu ça, ça aurait pu m'échapper !" */
|
||||
|
||||
// (string) '#regex#Z' => (int) parenthesized subpattern,
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
/// Catch Abstrait Symétrique
|
||||
// Cas général - ko
|
||||
// '%(["\'])([^\1:/\s]+:/+[^\1]+)\1#%' => 2,
|
||||
// Thèmes récurrents en (x)?HTML - ok
|
||||
'%(?:href|src|ur[li]|path|action|role|xmlns(?::[^:=]+)?)\s*=\s*(["\'])\s*([^\1]+)\s*\1%Ui' => 2,
|
||||
|
||||
/// Exceptions
|
||||
// Instructions de robots.txt - ok
|
||||
'%(?:Disallow|Sitemap)\s*:\s+(\S+)\s*%i' => 1,
|
||||
// Image en CSS - ok - ok
|
||||
'%url\s*\((["\']|)(?(1)([^\1]+)\1|([^()]+))\)%Ui' => 2,
|
||||
'%url\s*(["\'])([^\1])\1%iU' => 2,
|
||||
// Meta refresh - ok
|
||||
'%content=(["\'])[^\1\D]*;\s*url=([^\1]+)\1%iU' => 2,
|
||||
|
||||
/// Catch Abstrait Asymétrique
|
||||
// Parenthèses
|
||||
/// '\( , ... \)' => ,
|
||||
// XML - (antislash pour php-> ?\>) . Ungreedy réduit l'execution - ok
|
||||
'%<([^<>\s]+)(?:\s+[^>]+)?\>\s*([^>\s:/]+:/+[^<]+)\s*</\1>%' => 2,
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// '' => ,
|
||||
);
|
||||
|
||||
foreach ( $regexs as $regex => $parenthesized_subpattern )
|
||||
{
|
||||
preg_match_all($regex, $raw_page_content, $reg_sult, PREG_PATTERN_ORDER); // Éxécute les regular expressions
|
||||
$matches = array_merge($matches, $reg_sult[ $parenthesized_subpattern ]); // Regroupe les résultats des regex
|
||||
}
|
||||
|
||||
$matches = array_unique($matches); // Supprime les doubles
|
||||
$matches = array_values($matches); // Repart de zéro
|
||||
|
||||
$url = trim($url); // Enlève les espaces des côtés
|
||||
$nbUrl_=count($matches);
|
||||
foreach ( $matches as $iUrl_=>$raw_url )
|
||||
{
|
||||
$raw_url = trim($raw_url);
|
||||
|
||||
if ( !empty($raw_url) ) // Supprime les cases vides
|
||||
{
|
||||
$res = resolve_url($raw_url, $url); // Résoud massivement les URL trouvées
|
||||
|
||||
/* Déduit des urls : énumère l'arborescence */
|
||||
if ( !empty($res) ) // URL néttoyées
|
||||
{
|
||||
preg_match('#^([^:/]+:/+[^/]+/)(.*)$#', $res, $preg_url);
|
||||
if (!isset($preg_url[1])) {
|
||||
echo ("$iUrl_/$nbUrl_: Type d'URL non gérée : '$res'".EOL);
|
||||
break;
|
||||
}
|
||||
$str = $preg_url[1]; // = début de l'url suivie d'un slash
|
||||
|
||||
$urls[] = $str; // Enregistre déjà ce début (utile de le mettre ici au cas ou la condition sur \2 serait false)
|
||||
|
||||
if ( !empty($preg_url[2]) ) // Si il y a un path (!= root | host)
|
||||
{
|
||||
// Éclate le path par le slash (-> array)
|
||||
$exp = explode('/', $preg_url[2]); // Compte à partir de 0
|
||||
$k = count($exp); // Compte à partir de 1
|
||||
|
||||
for ( $i = 0; $i < $k; $i++ ) // Déduit des urls
|
||||
{
|
||||
// Si on est au dernier, on ne met pas de slash à la fin (: cela peut-être un fichier)
|
||||
$str .= ($i == $k -1) ? $exp[$i] : $exp[$i].'/';
|
||||
|
||||
$urls[] = $str; // Enregistre
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$urls = array_unique($urls); //moins doubles
|
||||
$urls = array_values($urls); //orde num (des key)
|
||||
if ( empty($urls[ count($urls) - 1 ]) ) // Si il y a une URL vide, elle est à la fin du tableau
|
||||
array_pop($urls);
|
||||
|
||||
return $urls;
|
||||
}
|
||||
function crawler($q) {
|
||||
if ( preg_match('#[^:/\s]://.+#', $q) && !preg_match('#[<>"\']#', $q) ) // Si l'URL semble correcte
|
||||
{
|
||||
$urls = array();
|
||||
if ( preg_match('#^[^:/]+:/+[^/]+$#', $q) )
|
||||
$q .= '/'; // Rajoute le slash si c'est le root et qu'il est sans / à la fin
|
||||
|
||||
/* if ( !empty($c) ) /* HTTP ERROR */ /*** Ne pas echo avant cette ligne ***
|
||||
{
|
||||
header("Content-Type: text/plain");
|
||||
echo get_http_error($q); // get_http_error() devrait moins consommer que curl_web_file()
|
||||
die;
|
||||
}
|
||||
*/
|
||||
$curl = get_web_file($q); // Met l'élément du Web ciblé dans une variable
|
||||
$urls = get_urls($curl['content'], $q); // URL trouvées
|
||||
|
||||
natcasesort($urls); // Tri par ordre alphanumérique
|
||||
$nombresult = count($urls);
|
||||
}
|
||||
return $urls;
|
||||
}
|
||||
|
||||
?>
|
404
library/Metier/partenaires/insee.php
Normal file
404
library/Metier/partenaires/insee.php
Normal file
@ -0,0 +1,404 @@
|
||||
<?
|
||||
define('HOST_INSEE', 'avis-situation-sirene.insee.fr');
|
||||
define('SITE_INSEE', 'http://'. HOST_INSEE .'/');
|
||||
define('HOST_PJ', 'www.pagesjaunes.fr');
|
||||
define('SITE_PJ', 'http://'. HOST_PJ .'/');
|
||||
define('SITE_SOCIETE', 'http://www.societe.com/');
|
||||
|
||||
include('/var/www/_includes/includes/insee.class.php');
|
||||
//include('includes/normad.class.php');
|
||||
include('/var/www/_includes/includes/fonctions.php');
|
||||
|
||||
/* v0.1 Extraction d'informations INSEE en ligne de commande.
|
||||
|
||||
Usage: <?=$argv[0]?> <extract type> <fileIn> <fileInFmt> <fileOut> <fileOutFmt>
|
||||
|
||||
Where <extract type> is :
|
||||
id siren.tm.fr : Fiche d'identite INSEE (établissement+entreprise)
|
||||
lst siren.tm.fr : Liste des etablissements du SIREN (+infos entreprise)
|
||||
rncs societe.com : Informations du RNCS
|
||||
pj pagesjaunes.fr : Données des pages jaunes
|
||||
coface cofacerating.fr : Coface
|
||||
|
||||
Where <fileInFmt> is :
|
||||
csv Fichier IN au format CSV (; ou ,) SIREN;NIC;REF
|
||||
plat Fichier IN au format plat (blancs significatifs) SIREN_____NIC__REF______________
|
||||
|
||||
Where <fileOutFmt> is : csv / todo
|
||||
|
||||
Le fichier en entrée doit être au format <fileInFmt> et contenir le SIREN en première colonne.
|
||||
*/
|
||||
|
||||
$insee=&new Insee();
|
||||
function getInfosSirene($sirenLu, $nicLu='') {
|
||||
$tabRet=array();
|
||||
|
||||
$invalide=false;
|
||||
if (valideSiren($sirenLu)==false) {
|
||||
$libelleErreur='SIREN invalide';
|
||||
$invalide=true;
|
||||
}
|
||||
if ( $nicLu<>'' && valideSiren($sirenLu, $nicLu)==false) {
|
||||
$libelleErreur='SIRET invalide';
|
||||
$invalide=true;
|
||||
}
|
||||
if ($invalide==true)
|
||||
{
|
||||
$siret=$sirenLu.$nicLu;
|
||||
$str=date('d/m/Y à H:i:s') .';'. $libelleErreur .';'. $siret .';;;;;;;;;;;;;;;;;;;;;;;';
|
||||
$fp=fopen('/var/www/_includes/partenaires/insee/debug.csv', 'a');
|
||||
fwrite($fp, $str."\r\n");
|
||||
fclose($fp);
|
||||
$num=$key+1;
|
||||
flush();
|
||||
} else { // La demande est valide on va à l'INSEE
|
||||
/** Paramètre de requête "option" à l'insee :
|
||||
** 1: Fiche du siège + Données entreprises
|
||||
** 2: Tous les établissements de l'entreprise
|
||||
** 3: Un établissement particulier
|
||||
** 4: Département
|
||||
**/
|
||||
if ($nicLu<>'') $option=3;
|
||||
else $option=1;
|
||||
|
||||
$libelleErreur='Erreur SCRIPT Inconnue';
|
||||
$tabInfoEtab=array();
|
||||
$tabInfoEntrep=array();
|
||||
|
||||
/** Etape de connexion au site de l'INSEE pour simuler correctement un utilisateur WEB
|
||||
**/
|
||||
$response1=getUrl(SITE_INSEE);
|
||||
$response=getUrl(SITE_INSEE .'REPERTOIRE/Interrogation/frame_interrogation.asp?ACTION=nouvelle&Niveau=siren', $response1["header"]["Set-Cookie"], '', SITE_INSEE .'SIRENET_Script/Accueil/script_page_accueil.asp');
|
||||
|
||||
$response=getUrl(SITE_INSEE .'SIRENET_Script/Interrogation/script_recherche_menu.asp?niveau=siren', $response1["header"]["Set-Cookie"], '', SITE_INSEE .'REPERTOIRE/Interrogation/frame_interrogation.asp?ACTION=nouvelle&Niveau=siren');
|
||||
$response=getUrl(SITE_INSEE .'SIRENET_Script/Interrogation/script_recherche_barre_haut.asp?niveau=siren', $response1["header"]["Set-Cookie"], '', SITE_INSEE .'REPERTOIRE/Interrogation/frame_interrogation.asp?ACTION=nouvelle&Niveau=siren');
|
||||
|
||||
$response=getUrl(SITE_INSEE .'REPERTOIRE/Interrogation/Interrogation_haut.asp?grille=siren&action=nouvelle', $response1["header"]["Set-Cookie"], '', SITE_INSEE .'REPERTOIRE/Interrogation/frame_interrogation.asp?ACTION=nouvelle&Niveau=siren');
|
||||
$response=getUrl(SITE_INSEE .'REPERTOIRE/Interrogation/Interrogation_principal.asp?grille=siren&action=nouvelle', $response1["header"]["Set-Cookie"], '', SITE_INSEE .'REPERTOIRE/Interrogation/frame_interrogation.asp?ACTION=nouvelle&Niveau=siren');
|
||||
$response=getUrl(SITE_INSEE .'REPERTOIRE/Interrogation/Interrogation_bas.asp?grille=siren&action=nouvelle', $response1["header"]["Set-Cookie"], '', SITE_INSEE .'REPERTOIRE/Interrogation/frame_interrogation.asp?ACTION=nouvelle&Niveau=siren');
|
||||
|
||||
$response=getUrl(SITE_INSEE .'REPERTOIRE/Interrogation/Interrogation_haut.asp?grille=siren&action=nouvelle', $response1["header"]["Set-Cookie"], '', SITE_INSEE .'REPERTOIRE/Interrogation/Interrogation_principal.asp?grille=siren&action=nouvelle');
|
||||
$response=getUrl(SITE_INSEE .'REPERTOIRE/Interrogation/Interrogation_bas.asp?grille=siren&action=nouvelle', $response1["header"]["Set-Cookie"], '', SITE_INSEE .'REPERTOIRE/Interrogation/Interrogation_principal.asp?grille=siren&action=nouvelle');
|
||||
|
||||
if ($nicLu=='') //Faire une boucle de recherche de tous les établissement et y inclure le reste du traitement
|
||||
{
|
||||
// Requête d'interrogation
|
||||
$postData=array(
|
||||
'siren'=>$sirenLu,
|
||||
'option'=>2,
|
||||
'nic'=>'',
|
||||
'dep'=>'',
|
||||
'listeDep'=>'');
|
||||
|
||||
$response=getUrl(SITE_INSEE .'REPERTOIRE/Interrogation/Interrogation_principal.asp?action=valider&grille=siren&waitframe=false', $response1["header"]["Set-Cookie"], $postData, SITE_INSEE .'REPERTOIRE/Interrogation/Interrogation_principal.asp?grille=siren&action=nouvelle');
|
||||
$action='nouveau';
|
||||
$referer=SITE_INSEE .'REPERTOIRE/Interrogation/Interrogation_principal.asp?action=valider&grille=siren&waitframe=false';
|
||||
$nbRepTot=$pageCour=$nbTotPage=$nbRepParPage=$numEtab=0;
|
||||
$tabInfoEtab=array();
|
||||
|
||||
while(true)
|
||||
{
|
||||
$responseQ=getUrl(SITE_INSEE .'REPERTOIRE/reponse/question.asp?action='.$action, $response1["header"]["Set-Cookie"], '', $referer);
|
||||
if ($responseQ['code']==302)
|
||||
{
|
||||
//$libelleErreur='Erreur INSEE inconnue 1';
|
||||
|
||||
// Siren Invalide ou autre erreur non répertoriée !
|
||||
$header=$responseQ['header'];
|
||||
if (trim($header['Location'])=='/REPERTOIRE/Reponse/Frame_Reponse.asp?dest=erreur')
|
||||
{
|
||||
$responseQ=getUrl(SITE_INSEE .'REPERTOIRE/Reponse/Frame_Reponse.asp?dest=erreur', $response1["header"]["Set-Cookie"], '', SITE_INSEE .'REPERTOIRE/Interrogation/Interrogation_principal.asp?action=valider&grille=siren&waitframe=false');
|
||||
$responseErreur=getUrl(SITE_INSEE .'REPERTOIRE/Reponse/Erreur_principal.asp', $response1["header"]["Set-Cookie"], '', SITE_INSEE .'REPERTOIRE/Reponse/Frame_Reponse.asp?dest=erreur',true);
|
||||
$pos=strpos($responseErreur['body'], '<td valign=top bgcolor="#FFCC33"><font face=Arial size=2><b>');
|
||||
if ($pos>0){
|
||||
$posFin=strpos($responseErreur['body'], '</b></font></td>', $pos+60);
|
||||
$libelleErreur=trim(substr($responseErreur['body'], $pos+60, $posFin-($pos+60)));
|
||||
} else
|
||||
$libelleErreur='Erreur INSEE inconnue';
|
||||
}
|
||||
|
||||
// On déroule les URLs d'appels liste des établissements
|
||||
$responseQ=getUrl(SITE_INSEE .'REPERTOIRE/Reponse/Frame_Reponse.asp?dest=liste', $response1["header"]["Set-Cookie"], '', SITE_INSEE .'REPERTOIRE/Interrogation/Interrogation_principal.asp?action=valider&grille=siren&waitframe=false');
|
||||
//sleep(1);
|
||||
// Frames réponse niveau Etab
|
||||
$responseQ=getUrl(SITE_INSEE .'SIRENET_Script/Interrogation/script_recherche_menu.asp?niveau=siren', $response1["header"]["Set-Cookie"], '', SITE_INSEE .'REPERTOIRE/Reponse/Frame_Reponse.asp?dest=liste');
|
||||
$responseQ=getUrl(SITE_INSEE .'SIRENET_Script/Interrogation/script_recherche_barre_haut.asp?niveau=siren', $response1["header"]["Set-Cookie"], '', SITE_INSEE .'REPERTOIRE/Reponse/Frame_Reponse.asp?dest=liste');
|
||||
$responseQ=getUrl(SITE_INSEE .'REPERTOIRE/Reponse/Reponse_haut.asp', $response1["header"]["Set-Cookie"], '', SITE_INSEE .'REPERTOIRE/Reponse/Frame_Reponse.asp?dest=liste');
|
||||
$responseListe=getUrl(SITE_INSEE .'REPERTOIRE/Reponse/Liste_principal.asp', $response1["header"]["Set-Cookie"], '', SITE_INSEE .'REPERTOIRE/Reponse/Frame_Reponse.asp?dest=liste', true);
|
||||
$responseQ=getUrl(SITE_INSEE .'REPERTOIRE/Reponse/Liste_bas.asp', $response1["header"]["Set-Cookie"], '', SITE_INSEE .'REPERTOIRE/Reponse/Frame_Reponse.asp?dest=liste');
|
||||
$responseListe=$responseListe['body'];
|
||||
|
||||
$pos=strpos($responseListe, 'Nombre total de réponses : '."\r\n\t\t\t".'<font face="Arial" size="2"><b>');
|
||||
if ($pos>0) {
|
||||
$posFin=strpos($responseListe, '</b></font>', $pos+73);
|
||||
$nbRepTot=trim(substr($responseListe, $pos+73, $posFin-($pos+73)));
|
||||
}
|
||||
$pos=strpos($responseListe, ' - Affichage de la page '."\r\n\t\t\t".'<font face="Arial" size="2"><b>');
|
||||
if ($pos>0) {
|
||||
$posFin=strpos($responseListe, ' - </b></font>', $pos+75);
|
||||
$strPages=trim(substr($responseListe, $pos+75, $posFin-($pos+75)));
|
||||
$tabPages=explode(' / ', $strPages);
|
||||
$pageCour=$tabPages[0];
|
||||
$nbTotPage=$tabPages[1];
|
||||
}
|
||||
$pos=strpos($responseListe, ' - </b></font>'."\r\n\t\t\t".'<font face="Arial" size="2"><b>');
|
||||
if ($pos>0) {
|
||||
$posFin=strpos($responseListe, '</b></font>', $pos+60);
|
||||
$nbRepParPage=trim(substr($responseListe, $pos+60, $posFin-($pos+60)));
|
||||
}
|
||||
|
||||
/* TODO = Récupérer les infos étab + entrep pour chaque ligne du tableau !!!*
|
||||
*/
|
||||
if ($libelleErreur=='Erreur SCRIPT Inconnue')
|
||||
$libelleErreur='';
|
||||
for ($i=1;$i<11; $i++)
|
||||
{
|
||||
if ($numEtab==$nbRepTot)
|
||||
break; // Il n'y a pas plus d'établissement à récupérer ! On sort...
|
||||
|
||||
$responseQ=getUrl(SITE_INSEE .'REPERTOIRE/reponse/question.asp?action=detail&numtableau='.$i, $response1["header"]["Set-Cookie"], '', SITE_INSEE .'REPERTOIRE/Reponse/Liste_principal.asp');
|
||||
if ($responseQ['code']==302)
|
||||
{
|
||||
// Siren Invalide ou autre erreur non répertoriée !
|
||||
$header=$responseQ['header'];
|
||||
if (trim($header['Location'])=='/REPERTOIRE/Reponse/Frame_Reponse.asp?origine=liste&dest=detail&niveau=siege&numtableau='.$i)
|
||||
{
|
||||
// On déroule les URLs d'appels fiche siège
|
||||
$responseQ=getUrl(SITE_INSEE .'REPERTOIRE/Reponse/Frame_Reponse.asp?dest=detail&niveau=siege&numtableau='.$i, $response1["header"]["Set-Cookie"], '', SITE_INSEE .'REPERTOIRE/Interrogation/Interrogation_principal.asp?action=valider&grille=siren&waitframe=false');
|
||||
//sleep(1);
|
||||
// Frames réponse niveau Etab
|
||||
$responseQ=getUrl(SITE_INSEE .'SIRENET_Script/Interrogation/script_recherche_menu.asp?niveau=siren', $response1["header"]["Set-Cookie"], '', SITE_INSEE .'REPERTOIRE/Reponse/Frame_Reponse.asp?dest=detail&niveau=siege');
|
||||
$responseQ=getUrl(SITE_INSEE .'SIRENET_Script/Interrogation/script_recherche_barre_haut.asp?niveau=siren', $response1["header"]["Set-Cookie"], '', SITE_INSEE .'REPERTOIRE/Reponse/Frame_Reponse.asp?dest=detail&niveau=siege');
|
||||
$responseQ=getUrl(SITE_INSEE .'REPERTOIRE/Reponse/Reponse_haut.asp', $response1["header"]["Set-Cookie"], '', SITE_INSEE .'REPERTOIRE/Reponse/Frame_Reponse.asp?dest=detail&niveau=siege');
|
||||
$responseEtab=getUrl(SITE_INSEE .'REPERTOIRE/Reponse/Detail_principal.asp?niveau=siege&numtableau='.$i.'&origine=liste', $response1["header"]["Set-Cookie"], '', SITE_INSEE .'REPERTOIRE/Reponse/Frame_Reponse.asp?origine=liste&dest=detail&niveau=siege&numtableau='.$i, true);
|
||||
$responseQ=getUrl(SITE_INSEE .'REPERTOIRE/Reponse/Detail_bas.asp?niveau=siege&numtableau='.$i.'&origine=liste', $response1["header"]["Set-Cookie"], '', SITE_INSEE .'REPERTOIRE/Reponse/Frame_Reponse.asp?origine=liste&dest=detail&niveau=siege&numtableau='.$i);
|
||||
$responseEtab=$responseEtab['body'];
|
||||
|
||||
// Récupération de la fiche entreprise INSEE
|
||||
$responseQ=getUrl(SITE_INSEE .'REPERTOIRE/reponse/frame_reponse.asp?niveau=entreprise&dest=detail&origine=liste&numtableau='.$i, $response1["header"]["Set-Cookie"], '', SITE_INSEE .'REPERTOIRE/Reponse/Detail_principal.asp?niveau=siege&numtableau='.$i.'&origine=liste');
|
||||
$responseQ=getUrl(SITE_INSEE .'SIRENET_Script/Interrogation/script_recherche_menu.asp?niveau=siren', $response1["header"]["Set-Cookie"], '', SITE_INSEE .'REPERTOIRE/reponse/frame_reponse.asp?niveau=entreprise&dest=detail&origine=liste&numtableau='.$i);
|
||||
$responseQ=getUrl(SITE_INSEE .'SIRENET_Script/Interrogation/script_recherche_barre_haut.asp?niveau=siren', $response1["header"]["Set-Cookie"], '', SITE_INSEE .'REPERTOIRE/Reponse/Frame_Reponse.asp?niveau=entreprise&dest=detail&origine=liste&numtableau='.$i);
|
||||
$responseQ=getUrl(SITE_INSEE .'REPERTOIRE/Reponse/Reponse_haut.asp', $response1["header"]["Set-Cookie"], '', SITE_INSEE .'REPERTOIRE/reponse/frame_reponse.asp?niveau=entreprise&dest=detail&origine=liste&numtableau='.$i);
|
||||
$responseEntreprise=getUrl(SITE_INSEE .'REPERTOIRE/Reponse/Detail_principal.asp?niveau=entreprise&numtableau='.$i.'&origine=liste', $response1["header"]["Set-Cookie"], '', SITE_INSEE .'REPERTOIRE/reponse/Frame_Reponse.asp?niveau=entreprise&dest=detail&origine=liste&numtableau='.$i, true);
|
||||
$responseQ=getUrl(SITE_INSEE .'REPERTOIRE/Reponse/Detail_bas.asp?niveau=entreprise&numtableau='.$i.'&origine=liste', $response1["header"]["Set-Cookie"], '', SITE_INSEE .'REPERTOIRE/reponse/Frame_Reponse.asp?niveau=entreprise&dest=detail&origine=liste&numtableau='.$i);
|
||||
$responseEntreprise=$responseEntreprise['body'];
|
||||
$tabInfoEntrep=getDataEntreprise($responseEntreprise);
|
||||
}
|
||||
elseif (trim($header['Location'])=='/REPERTOIRE/Reponse/Frame_Reponse.asp?origine=liste&dest=detail&niveau=etablissement&numtableau='.$i)
|
||||
{
|
||||
// On déroule les URLs d'appels établissement
|
||||
$responseQ=getUrl(SITE_INSEE .'REPERTOIRE/Reponse/Frame_Reponse.asp?dest=detail&niveau=etablissement&numtableau='.$i, $response1["header"]["Set-Cookie"], '', SITE_INSEE .'REPERTOIRE/Interrogation/Interrogation_principal.asp?action=valider&grille=siren&waitframe=false');
|
||||
//sleep(1);
|
||||
// Frames réponse niveau Etab
|
||||
$responseQ=getUrl(SITE_INSEE .'SIRENET_Script/Interrogation/script_recherche_menu.asp?niveau=siren', $response1["header"]["Set-Cookie"], '', SITE_INSEE .'REPERTOIRE/Reponse/Frame_Reponse.asp?dest=detail&niveau=etablissement');
|
||||
$responseQ=getUrl(SITE_INSEE .'SIRENET_Script/Interrogation/script_recherche_barre_haut.asp?niveau=siren', $response1["header"]["Set-Cookie"], '', SITE_INSEE .'REPERTOIRE/Reponse/Frame_Reponse.asp?dest=detail&niveau=etablissement');
|
||||
$responseQ=getUrl(SITE_INSEE .'REPERTOIRE/Reponse/Reponse_haut.asp', $response1["header"]["Set-Cookie"], '', SITE_INSEE .'REPERTOIRE/Reponse/Frame_Reponse.asp?dest=detail&niveau=etablissement');
|
||||
$responseEtab=getUrl(SITE_INSEE .'REPERTOIRE/Reponse/Detail_principal.asp?niveau=etablissement&numtableau='.$i.'&origine=liste', $response1["header"]["Set-Cookie"], '', SITE_INSEE .'REPERTOIRE/Reponse/Frame_Reponse.asp?origine=liste&dest=detail&niveau=etablissement&numtableau='.$i, true);
|
||||
$responseQ=getUrl(SITE_INSEE .'REPERTOIRE/Reponse/Detail_bas.asp?niveau=etablissement&numtableau='.$i.'&origine=liste', $response1["header"]["Set-Cookie"], '', SITE_INSEE .'REPERTOIRE/Reponse/Frame_Reponse.asp?origine=liste&dest=detail&niveau=etablissement&numtableau='.$i);
|
||||
$responseEtab=$responseEtab['body'];
|
||||
}
|
||||
|
||||
$tabInfoEtab=getDataEtablissement($responseEtab);
|
||||
$tabRet[]=array_merge($tabInfoEtab, $tabInfoEntrep);
|
||||
|
||||
if ($libelleErreur<>'' && $tabInfoEtab['siret'] =='') $siret=$sirenLu . $nicLu;
|
||||
else $siret=$tabInfoEtab['siret'];
|
||||
|
||||
$str= date('d/m/Y à H:i:s') .';'.
|
||||
$libelleErreur .';'.
|
||||
// Siège
|
||||
$siret .';'.
|
||||
$tabInfoEtab['active'] .';'.
|
||||
$tabInfoEtab['dateAbsActivite'] .';'.
|
||||
$tabInfoEtab['typeEtablissement'] .';'.
|
||||
$tabInfoEtab['dateMAJ'] .';'.
|
||||
$tabInfoEtab['dateCreation'] .';'.
|
||||
$tabInfoEtab['raisonSociale'] .';'.
|
||||
$tabInfoEtab['Enseigne'] .';'.
|
||||
$tabInfoEtab['NafCode'] .';'.
|
||||
$tabInfoEtab['NafLib'] .';'.
|
||||
$tabInfoEtab['AdresseLigne1'] .';'.
|
||||
$tabInfoEtab['AdresseLigne2'] .';'.
|
||||
$tabInfoEtab['AdresseLigne3'] .';'.
|
||||
$tabInfoEtab['etatJuridique'] .';'.
|
||||
$tabInfoEtab['dateEtatJuridique'] .';'.
|
||||
// Entreprise
|
||||
$tabInfoEntrep['dateCreationEntrep'] .';'.
|
||||
$tabInfoEntrep['raisonSocialeEntrep'] .';'.
|
||||
$tabInfoEntrep['sigle'] .';'.
|
||||
$tabInfoEntrep['NafCodeEntrep'] .';'.
|
||||
$tabInfoEntrep['NafLibEntrep'] .';'.
|
||||
$tabInfoEntrep['FJCodeEntrep'] .';'.
|
||||
$tabInfoEntrep['FJLibEntrep'] .';'.
|
||||
$tabInfoEntrep['nbEtabActifs'] .';';
|
||||
|
||||
$fp=fopen('/var/www/_includes/partenaires/insee/debug.csv', 'a');
|
||||
fwrite($fp, $str."\r\n");
|
||||
fclose($fp);
|
||||
|
||||
$numEtab++;
|
||||
$num=$key+1;
|
||||
$typeEtablissement=$tabInfoEtab['typeEtablissement'];
|
||||
// echo "Question $num/$nbLignes : Demande=$sirenLu$nicLu Etablissement $numEtab/$nbRepTot $typeEtablissement=$siret $libelleErreur\r\n";
|
||||
flush();
|
||||
sleep(1);
|
||||
|
||||
}//end for
|
||||
}//end if
|
||||
if ($pageCour==$nbTotPage) {
|
||||
// On sort de la boucle de passage à la page de liste suivante car il n'y a plus d'autres pages
|
||||
break;
|
||||
} else {
|
||||
$action='listeplus';
|
||||
$referer=SITE_INSEE .'REPERTOIRE/Reponse/Liste_principal.asp';
|
||||
}
|
||||
}
|
||||
} //Fin While
|
||||
// die('Boucle');
|
||||
} /* Fin de la boucle option 'lst' */ else
|
||||
{
|
||||
// Requête d'interrogation
|
||||
$postData=array('siren'=>$sirenLu,
|
||||
'option'=>$option,
|
||||
'nic'=>$nicLu,
|
||||
'dep'=>'',
|
||||
'listeDep'=>'');
|
||||
|
||||
$response=getUrl(SITE_INSEE .'REPERTOIRE/Interrogation/Interrogation_principal.asp?action=valider&grille=siren&waitframe=false', $response1["header"]["Set-Cookie"], $postData, SITE_INSEE .'REPERTOIRE/Interrogation/Interrogation_principal.asp?grille=siren&action=nouvelle');
|
||||
$responseQ=getUrl(SITE_INSEE .'REPERTOIRE/reponse/question.asp?action=nouveau', $response1["header"]["Set-Cookie"], '', SITE_INSEE .'REPERTOIRE/Interrogation/Interrogation_principal.asp?action=valider&grille=siren&waitframe=false');
|
||||
if ($responseQ['code']==302)
|
||||
{
|
||||
//$libelleErreur='Erreur INSEE inconnue 1';
|
||||
|
||||
// Siren Invalide ou autre erreur non répertoriée !
|
||||
$header=$responseQ['header'];
|
||||
if (trim($header['Location'])=='/REPERTOIRE/Reponse/Frame_Reponse.asp?dest=erreur')
|
||||
{
|
||||
$responseQ=getUrl(SITE_INSEE .'REPERTOIRE/Reponse/Frame_Reponse.asp?dest=erreur', $response1["header"]["Set-Cookie"], '', SITE_INSEE .'REPERTOIRE/Interrogation/Interrogation_principal.asp?action=valider&grille=siren&waitframe=false');
|
||||
$responseErreur=getUrl(SITE_INSEE .'REPERTOIRE/Reponse/Erreur_principal.asp', $response1["header"]["Set-Cookie"], '', SITE_INSEE .'REPERTOIRE/Reponse/Frame_Reponse.asp?dest=erreur',true);
|
||||
$pos=strpos($responseErreur['body'], '<td valign=top bgcolor="#FFCC33"><font face=Arial size=2><b>');
|
||||
if ($pos>0){
|
||||
$posFin=strpos($responseErreur['body'], '</b></font></td>', $pos+60);
|
||||
$libelleErreur=trim(substr($responseErreur['body'], $pos+60, $posFin-($pos+60)));
|
||||
} else
|
||||
$libelleErreur='Erreur INSEE inconnue';
|
||||
}
|
||||
else
|
||||
{ if (trim($header['Location'])=='/REPERTOIRE/Reponse/Frame_Reponse.asp?dest=detail&niveau=siege')
|
||||
// L'établissement demandé est un siège !
|
||||
$option=1;
|
||||
|
||||
if ($option==3)
|
||||
{
|
||||
// On déroule les URLs d'appels établissement
|
||||
$responseQ=getUrl(SITE_INSEE .'REPERTOIRE/Reponse/Frame_Reponse.asp?dest=detail&niveau=etablissement', $response1["header"]["Set-Cookie"], '', SITE_INSEE .'REPERTOIRE/Interrogation/Interrogation_principal.asp?action=valider&grille=siren&waitframe=false');
|
||||
//sleep(1);
|
||||
// Frames réponse niveau Etab
|
||||
$responseQ=getUrl(SITE_INSEE .'SIRENET_Script/Interrogation/script_recherche_menu.asp?niveau=siren', $response1["header"]["Set-Cookie"], '', SITE_INSEE .'REPERTOIRE/Reponse/Frame_Reponse.asp?dest=detail&niveau=etablissement');
|
||||
$responseQ=getUrl(SITE_INSEE .'SIRENET_Script/Interrogation/script_recherche_barre_haut.asp?niveau=siren', $response1["header"]["Set-Cookie"], '', SITE_INSEE .'REPERTOIRE/Reponse/Frame_Reponse.asp?dest=detail&niveau=etablissement');
|
||||
$responseQ=getUrl(SITE_INSEE .'REPERTOIRE/Reponse/Reponse_haut.asp', $response1["header"]["Set-Cookie"], '', SITE_INSEE .'REPERTOIRE/Reponse/Frame_Reponse.asp?dest=detail&niveau=etablissement');
|
||||
$responseEtab=getUrl(SITE_INSEE .'REPERTOIRE/Reponse/Detail_principal.asp?niveau=etablissement', $response1["header"]["Set-Cookie"], '', SITE_INSEE .'REPERTOIRE/Reponse/Frame_Reponse.asp?dest=detail&niveau=etablissement', true);
|
||||
$responseQ=getUrl(SITE_INSEE .'REPERTOIRE/Reponse/Detail_bas.asp?niveau=etablissement', $response1["header"]["Set-Cookie"], '', SITE_INSEE .'REPERTOIRE/Reponse/Frame_Reponse.asp?dest=detail&niveau=etablissement');
|
||||
$responseEtab=$responseEtab['body'];
|
||||
// On recherche si on est bien sur un fiche établissement
|
||||
$pos=strpos($responseEtab, '<table cols="2" width="100%"><tr><td bgcolor="#FFCC33" align="left"><font face="Arial" size="2"><B>Fiche Etablissement</B>');
|
||||
if ($pos<1)
|
||||
$libelleErreur='Erreur SCRIPT Fiche Etablissement non trouvée';
|
||||
else
|
||||
$libelleErreur='';
|
||||
$responseSiege=$responseEtab;
|
||||
}
|
||||
else
|
||||
{
|
||||
// On déroule les URLs d'appels Sièges
|
||||
$responseQ=getUrl(SITE_INSEE .'REPERTOIRE/Reponse/Frame_Reponse.asp?dest=detail&niveau=siege', $response1["header"]["Set-Cookie"], '', SITE_INSEE .'REPERTOIRE/Interrogation/Interrogation_principal.asp?action=valider&grille=siren&waitframe=false');
|
||||
//sleep(1);
|
||||
// Frames réponse niveau sièges
|
||||
$responseQ=getUrl(SITE_INSEE .'SIRENET_Script/Interrogation/script_recherche_menu.asp?niveau=siren', $response1["header"]["Set-Cookie"], '', SITE_INSEE .'REPERTOIRE/Reponse/Frame_Reponse.asp?dest=detail&niveau=siege');
|
||||
$responseQ=getUrl(SITE_INSEE .'SIRENET_Script/Interrogation/script_recherche_barre_haut.asp?niveau=siren', $response1["header"]["Set-Cookie"], '', SITE_INSEE .'REPERTOIRE/Reponse/Frame_Reponse.asp?dest=detail&niveau=siege');
|
||||
$responseQ=getUrl(SITE_INSEE .'REPERTOIRE/Reponse/Reponse_haut.asp', $response1["header"]["Set-Cookie"], '', SITE_INSEE .'REPERTOIRE/Reponse/Frame_Reponse.asp?dest=detail&niveau=siege');
|
||||
$responseSiege=getUrl(SITE_INSEE .'REPERTOIRE/Reponse/Detail_principal.asp?niveau=siege', $response1["header"]["Set-Cookie"], '', SITE_INSEE .'REPERTOIRE/Reponse/Frame_Reponse.asp?dest=detail&niveau=siege', true);
|
||||
$responseQ=getUrl(SITE_INSEE .'REPERTOIRE/Reponse/Detail_bas.asp?niveau=siege', $response1["header"]["Set-Cookie"], '', SITE_INSEE .'REPERTOIRE/Reponse/Frame_Reponse.asp?dest=detail&niveau=siege');
|
||||
$responseSiege=$responseSiege['body'];//strip_tags(html_entity_decode(), '<td>');
|
||||
// On recherche si on est bien sur un fiche siège
|
||||
$pos=strpos($responseSiege, '<table cols="2" width="100%"><tr><td bgcolor="#FFCC33" align="left"><font face="Arial" size="2"><B>Fiche siège</B>');
|
||||
if ($pos<1)
|
||||
$libelleErreur='Erreur SCRIPT Fiche Siège non trouvée';
|
||||
else
|
||||
$libelleErreur='';
|
||||
}
|
||||
|
||||
// Niveau entreprise
|
||||
$responseQ=getUrl(SITE_INSEE .'REPERTOIRE/reponse/frame_reponse.asp?niveau=entreprise&dest=detail', $response1["header"]["Set-Cookie"], '', SITE_INSEE .'REPERTOIRE/Reponse/Detail_principal.asp?niveau=siege');
|
||||
|
||||
$responseQ=getUrl(SITE_INSEE .'SIRENET_Script/Interrogation/script_recherche_menu.asp?niveau=siren', $response1["header"]["Set-Cookie"], '', SITE_INSEE .'REPERTOIRE/reponse/frame_reponse.asp?niveau=entreprise&dest=detail');
|
||||
$responseQ=getUrl(SITE_INSEE .'SIRENET_Script/Interrogation/script_recherche_barre_haut.asp?niveau=siren', $response1["header"]["Set-Cookie"], '', SITE_INSEE .'REPERTOIRE/Reponse/Frame_Reponse.asp?dest=detail&niveau=entreprise');
|
||||
$responseQ=getUrl(SITE_INSEE .'REPERTOIRE/Reponse/Reponse_haut.asp', $response1["header"]["Set-Cookie"], '', SITE_INSEE .'REPERTOIRE/reponse/frame_reponse.asp?niveau=entreprise&dest=detail');
|
||||
$responseEntreprise=getUrl(SITE_INSEE .'REPERTOIRE/Reponse/Detail_principal.asp?niveau=entreprise', $response1["header"]["Set-Cookie"], '', SITE_INSEE .'REPERTOIRE/reponse/frame_reponse.asp?niveau=entreprise&dest=detail', true);
|
||||
$responseQ=getUrl(SITE_INSEE .'REPERTOIRE/Reponse/Detail_bas.asp?niveau=entreprise', $response1["header"]["Set-Cookie"], '', SITE_INSEE .'REPERTOIRE/reponse/frame_reponse.asp?niveau=entreprise&dest=detail');
|
||||
$responseEntreprise=$responseEntreprise['body'];
|
||||
$pos=strpos($responseEntreprise, '<table cols="2" width="100%"><tr><td bgcolor="#FFCC33" align="left"><font face="Arial" size="2"><B>Fiche Entreprise</B>');
|
||||
if ($pos<1) {
|
||||
$libelleErreur='Erreur SCRIPT Fiche Entreprise non trouvée';
|
||||
}
|
||||
|
||||
/** Recherche des données établissement
|
||||
**/
|
||||
$tabInfoEtab=getDataEtablissement($responseSiege);
|
||||
|
||||
/** Recherche des données entreprise
|
||||
**/
|
||||
$tabInfoEntrep=getDataEntreprise($responseEntreprise);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if ($libelleErreur<>'' && $tabInfoEtab['siret'] =='') $siret=$sirenLu . $nicLu;
|
||||
else $siret=$tabInfoEtab['siret'];
|
||||
|
||||
$str= date('d/m/Y à H:i:s') .';'.
|
||||
$libelleErreur .';'.
|
||||
// Siège
|
||||
$siret .';'.
|
||||
$tabInfoEtab['active'] .';'.
|
||||
$tabInfoEtab['dateAbsActivite'] .';'.
|
||||
$tabInfoEtab['typeEtablissement'] .';'.
|
||||
$tabInfoEtab['dateMAJ'] .';'.
|
||||
$tabInfoEtab['dateCreation'] .';'.
|
||||
$tabInfoEtab['raisonSociale'] .';'.
|
||||
$tabInfoEtab['Enseigne'] .';'.
|
||||
$tabInfoEtab['NafCode'] .';'.
|
||||
$tabInfoEtab['NafLib'] .';'.
|
||||
$tabInfoEtab['AdresseLigne1'] .';'.
|
||||
$tabInfoEtab['AdresseLigne2'] .';'.
|
||||
$tabInfoEtab['AdresseLigne3'] .';'.
|
||||
$tabInfoEtab['etatJuridique'] .';'.
|
||||
$tabInfoEtab['dateEtatJuridique'] .';'.
|
||||
// Entreprise
|
||||
$tabInfoEntrep['dateCreationEntrep'] .';'.
|
||||
$tabInfoEntrep['raisonSocialeEntrep'] .';'.
|
||||
$tabInfoEntrep['sigle'] .';'.
|
||||
$tabInfoEntrep['NafCodeEntrep'] .';'.
|
||||
$tabInfoEntrep['NafLibEntrep'] .';'.
|
||||
$tabInfoEntrep['FJCodeEntrep'] .';'.
|
||||
$tabInfoEntrep['FJLibEntrep'] .';'.
|
||||
$tabInfoEntrep['nbEtabActifs'] .';'.
|
||||
//echo $str.'<br/>';
|
||||
|
||||
$fp=fopen('/var/www/_includes/partenaires/insee/debug.csv', 'a');
|
||||
fwrite($fp, $str."\r\n");
|
||||
fclose($fp);
|
||||
|
||||
$num=$key+1;
|
||||
$typeEtablissement=$tabInfoEtab['typeEtablissement'];
|
||||
// echo "Ligne $num/$nbLignes : Question=$sirenLu$nicLu Retour $typeEtablissement=$siret $libelleErreur (PJ=$nbPJ)\r\n";
|
||||
//echo $str."<br/>";
|
||||
|
||||
flush();
|
||||
$tabRet=array(0=>array_merge($tabInfoEntrep, $tabInfoEtab));
|
||||
}
|
||||
}
|
||||
|
||||
return $tabRet;
|
||||
}
|
||||
?>
|
2685
library/Metier/scores/classMFinancier.php
Normal file
2685
library/Metier/scores/classMFinancier.php
Normal file
File diff suppressed because it is too large
Load Diff
197
library/Metier/scores/classMRatios.php
Normal file
197
library/Metier/scores/classMRatios.php
Normal file
@ -0,0 +1,197 @@
|
||||
<?
|
||||
|
||||
function genereCacheRatios() {
|
||||
$tabMoy=array();
|
||||
|
||||
$strFonctions='$tabInfla=array();
|
||||
';
|
||||
|
||||
$iDb=new WDB("jo");
|
||||
$tabTmp=$iDb->select("sdv1.inflation", "annee, infla", "annee>1990 ORDER BY annee", false, MYSQL_ASSOC);
|
||||
foreach ($tabTmp as $tabTmp2) {
|
||||
$strFonctions.='$tabInfla['.$tabTmp2['annee'].']='.$tabTmp2['infla'].";\n";
|
||||
}
|
||||
|
||||
$strFonctions.='
|
||||
/** Donne le taux d\'inflation pour une année donnée **/
|
||||
function getInflation($annee) {
|
||||
global $tabInfla;
|
||||
if (!isset($tabInfla[$annee]))
|
||||
sendMail("production@scores-decisions.com", "ylenaour@scores-decisions.com", "ERREUR, il manque le taux d\'inflation pour l\'année $annee", "il manque le taux d\'inflation pour l\'année $annee dans la table sdv1.inflation");
|
||||
return $tabInfla[$annee];
|
||||
}
|
||||
';
|
||||
|
||||
|
||||
$iDb=new WDB('jo');
|
||||
|
||||
$configFileTmp = realpath(dirname(__FILE__)).'/../tmp/configMRatios.tmp.php';
|
||||
$configFile = realpath(dirname(__FILE__)).'/../tmp/configMRatios.php';
|
||||
|
||||
$fp=fopen($configFileTmp, 'w');
|
||||
fwrite($fp, '<?'."\n");
|
||||
fwrite($fp, 'error_reporting(E_ALL ^ E_NOTICE);' ."\n");
|
||||
|
||||
fwrite($fp, '$tva=19.6;' ."\n");
|
||||
fwrite($fp, $strFonctions ."\n");
|
||||
|
||||
fwrite($fp, '$tabFormules=array();' ."\n"."\n");
|
||||
$tabFormules=$iDb->select( 'ratios_formules',
|
||||
'id, libelle, formule, unite, commentaires, borneMin, borneMax, deleted',
|
||||
'deleted=0');
|
||||
|
||||
foreach ($tabFormules as $i=>$formule) {
|
||||
$id=$formule['id']*1;
|
||||
fwrite($fp, '$tabFormules['.$i.'][\'id\']='.$id.';' ."\n");
|
||||
fwrite($fp, '$tabFormules['.$i.'][\'libelle\']="'.trim(str_replace('"','\"',$formule['libelle'])).'";' ."\n");
|
||||
fwrite($fp, '$tabFormules['.$i.'][\'commentaires\']="'.trim(str_replace('"','\"',$formule['commentaires'])).'";' ."\n");
|
||||
fwrite($fp, '$tabFormules['.$i.'][\'unite\']=\''.$formule['unite'].'\';' ."\n");
|
||||
fwrite($fp, '$tabFormules['.$i.'][\'borneMin\']=\''.$formule['borneMin'].'\';' ."\n");
|
||||
fwrite($fp, '$tabFormules['.$i.'][\'borneMax\']=\''.$formule['borneMax'].'\';' ."\n");
|
||||
fwrite($fp, '$tabFormules['.$i.'][\'formule\']=\''.$formule['formule'].'\';' ."\n");
|
||||
}
|
||||
fwrite($fp, "\n".'function calculRatios($tabBilans, $tabIdentite, $accesPartenaire) {' ."\n");
|
||||
fwrite($fp, ' global $tva, $tabFormules, $mBil, $tabBilan, $efftr;' ."\n");
|
||||
fwrite($fp, ' $numBil=0;' ."\n");
|
||||
fwrite($fp, ' $numBilType=array();' ."\n");
|
||||
fwrite($fp, ' foreach ($tabBilans as $millesime=>$bil) {' ."\n");
|
||||
fwrite($fp, ' $tabTmp=@$mBil->getBilan(substr($millesime,-10), substr($millesime,0,1), @$bil[\'ref\'], $accesPartenaire);' ."\n");
|
||||
|
||||
fwrite($fp, ' $numBilType[substr($millesime,0,1)]++;' ."\n");
|
||||
fwrite($fp, ' if (substr($millesime,0,1)==\'S\') {' ."\n");
|
||||
fwrite($fp, ' if ($numBilType[\'S\']>5) continue;' ."\n");
|
||||
fwrite($fp, ' $tabTmp2=$mBil->bilanSimplifie2Normal($tabTmp);' ."\n");
|
||||
fwrite($fp, ' $tabBilan[$numBil]=array_merge($tabTmp2, $tabTmp);' ."\n");
|
||||
fwrite($fp, ' } elseif (substr($millesime,0,1)==\'N\') {' ."\n");
|
||||
fwrite($fp, ' if ($numBilType[\'N\']>5) continue;' ."\n");
|
||||
fwrite($fp, ' $tabBilan[$numBil]=$tabTmp;' ."\n");
|
||||
fwrite($fp, ' } elseif (substr($millesime,0,1)==\'C\') {' ."\n");
|
||||
fwrite($fp, ' if ($numBilType[\'C\']>5) continue;' ."\n");
|
||||
fwrite($fp, ' $tabBilan[$numBil]=$tabTmp;' ."\n");
|
||||
fwrite($fp, ' } elseif (substr($millesime,0,1)==\'A\') {' ."\n");
|
||||
fwrite($fp, ' if ($numBilType[\'A\']>5) continue;' ."\n");
|
||||
fwrite($fp, ' $tabBilan[$numBil]=$tabTmp;' ."\n");
|
||||
fwrite($fp, ' //return(array());' ."\n");
|
||||
fwrite($fp, ' } elseif (substr($millesime,0,1)==\'B\') {' ."\n");
|
||||
fwrite($fp, ' if ($numBilType[\'B\']>5) continue;' ."\n");
|
||||
fwrite($fp, ' $tabBilan[$numBil]=$tabTmp;' ."\n");
|
||||
fwrite($fp, ' //return(array());' ."\n");
|
||||
fwrite($fp, ' }' ."\n");
|
||||
fwrite($fp, ' unset($tabTmp); unset($tabTmp2);' ."\n");
|
||||
fwrite($fp, ' if ($numBil>10) break;' ."\n");
|
||||
fwrite($fp, ' $p=$tabBilan[$numBil];' ."\n");
|
||||
fwrite($fp, ' $nm=$p[\'DUREE_MOIS\'];' ."\n");
|
||||
fwrite($fp, ' $nmp=$p[\'DUREE_MOIS_PRE\'];' ."\n");
|
||||
fwrite($fp, ' $R=array();' ."\n"."\n");
|
||||
|
||||
foreach ($tabFormules as $i=>$formule) {
|
||||
$id=$formule['id']*1;
|
||||
$libelle=$formule['libelle'];
|
||||
$unite=$formule['unite'];
|
||||
$formule=$formule['formule'];
|
||||
|
||||
if (preg_match("/^MOY\(R\[(.*)\],(.*)\)/Ui", $formule, $matches)) {
|
||||
$tabMoy[$id]=array( 'ratio'=>$matches[1]*1,
|
||||
'nbExo'=>$matches[2]*1,
|
||||
);
|
||||
continue;
|
||||
}
|
||||
|
||||
// Gestion des variables minuscules de 1 à 8 caractères alphanumériques
|
||||
$formule1=preg_replace('/([a-z]{1,8})/','\$$1', $formule);
|
||||
// Gestion des postes du BILAN AX, BX, YP, FL1, etc...
|
||||
$formule1=preg_replace('/\b([A-Z]{2,2}[1-9]{0,1})\b/','\$p[\'$1\']', $formule1);
|
||||
// Gestion des ratios précédent
|
||||
$formule1=preg_replace('/\bR\[(.*)\]/U', '\$R['."'\\1'*1".']', $formule1);
|
||||
// Gestion des valeurs Absolues
|
||||
$formule1=preg_replace('/\|(.*)\|/U', 'abs($1)', $formule1);
|
||||
// Gestion de l'inflation pour l'année du bilan
|
||||
$formule1=preg_replace('/\INFLATION/U', 'getInflation(substr($millesime,-4))', $formule1);
|
||||
|
||||
// Ecriture de la formule
|
||||
$formule1="\$R[$id]=".$formule1.';';
|
||||
|
||||
/** fonction ou **/
|
||||
if (preg_match('/ \$ou (.*)/', $formule1, $matches)) {
|
||||
$formule1=preg_replace('/ \$ou (.*)/',';', $formule1);
|
||||
$alternative=$matches[1];
|
||||
$formule1.="if (\$R[$id]==0) \$R[$id]=$alternative";
|
||||
}
|
||||
|
||||
/** Bornage des résultats en cas de dépassement **/
|
||||
if (preg_match('/;BORN\((.*)\)/U', $formule1, $matches)) {
|
||||
$formule1=preg_replace('/(;BORN\(.*\))/U','', $formule1);
|
||||
$tabBornes=explode(':', $matches[1]);
|
||||
if (trim($tabBornes[0])<>'') {
|
||||
$bMin=trim($tabBornes[0])*1;
|
||||
$formule1.="if (\$R[$id]<$bMin) \$R[$id]=$bMin;";
|
||||
}
|
||||
if (isset($tabBornes[1]) && trim(@$tabBornes[1])<>'') {
|
||||
$bMax=trim($tabBornes[1])*1;
|
||||
$formule1.="if (\$R[$id]>$bMax) \$R[$id]=$bMax;";
|
||||
}
|
||||
}
|
||||
|
||||
/** Bornage des résultats en cas de dépassement **/
|
||||
if (preg_match('/;LIM\((.*)\)/U', $formule1, $matches)) {
|
||||
$formule1=preg_replace('/(;LIM\(.*\))/U','', $formule1);
|
||||
$bMax=trim($matches[1])*1;
|
||||
$formule1.="if (\$R[$id]>$bMax) \$R[$id]=$bMax;";
|
||||
}
|
||||
|
||||
/** Mémorisation des formules pour les moyennes **
|
||||
*
|
||||
$valeur='( (R'.$matches[1];
|
||||
for($iMoy=0; $iMoy<$matches[2]; $iMoy++) {
|
||||
if ($iMoy==1)
|
||||
$valeur.='+Rp'.$matches[1];
|
||||
else
|
||||
$valeur.='+Rp'.$iMoy.$matches[1];
|
||||
}
|
||||
$valeur.=')/'.$matches[2].')';
|
||||
}
|
||||
else
|
||||
$valeur=preg_replace('/([A-Z\_]{1,20})\((.*)\)$/i','substr(\$$1,$2)', $valeur);
|
||||
|
||||
*/
|
||||
$formule2=$formule1;
|
||||
|
||||
fwrite($fp, $formule2."\n");
|
||||
//@eval($formule2);
|
||||
fwrite($fp, 'if (!isset($R['.$id.'])) $R['.$id.']=\'NS\';'."\n");
|
||||
if (!isset($R[$id])) $R[$id]='NS';
|
||||
}
|
||||
|
||||
fwrite($fp, "\n".' $tabRatios[$numBil]=$R;'."\n");
|
||||
fwrite($fp, ' $numBil++;'."\n");
|
||||
fwrite($fp, ' }'."\n"."\n");
|
||||
|
||||
|
||||
foreach($tabMoy as $iRatio=>$tMoy) {
|
||||
$irMoy=$tMoy['ratio'];
|
||||
$nbExo=$tMoy['nbExo'];
|
||||
fwrite($fp, ' for($i=0; $i<$numBil; $i++) {'."\n");
|
||||
fwrite($fp, ' $tabRatios[$i]['.$iRatio.']=($tabRatios[$i]['.$irMoy.']');
|
||||
for($i=1; $i<$nbExo; $i++)
|
||||
fwrite($fp, '+$tabRatios[$i+'.$i.']['.$irMoy.']');
|
||||
fwrite($fp, ')/'.$nbExo.';');
|
||||
fwrite($fp, ' }'."\n"."\n");
|
||||
}
|
||||
|
||||
fwrite($fp, 'return $tabRatios;'."\n");
|
||||
fwrite($fp, '}'."\n");
|
||||
fwrite($fp, ' ?>');
|
||||
fclose ($fp);
|
||||
|
||||
$strOutput=exec('php -l '.$configFileTmp, $output);
|
||||
if (preg_match('/^No syntax errors detected in /', $strOutput)) {
|
||||
move($configFileTmp, $configFile);
|
||||
} else {
|
||||
@sendMail('production@scores-decisions.com', 'ylenaour@scores-decisions.com', "classMRatios sur $siren : Erreur de compilation '$strOutput'", print_r($output, true).EOL);
|
||||
print_r($output);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
?>
|
285
library/Metier/scores/classMRegression.php
Normal file
285
library/Metier/scores/classMRegression.php
Normal file
@ -0,0 +1,285 @@
|
||||
<?php
|
||||
class Regression{
|
||||
/*
|
||||
But: Fournir un objet assez complet permettant d'opérer facilement une régression
|
||||
linéaire, plus connu sur le nom de courbe de tendance sous Excel.
|
||||
Usage: 0- Dans votre fichier PHP insérer include ("CrbTendance.php");
|
||||
1- Déclarer l'objet RegLin
|
||||
ex: $oReg= new RegLin($tDonnees) ou $oReg= new RegLin($tY, $tX)
|
||||
Les deux syntaxe sont disponible, si une seul tableau est fourni
|
||||
alors le second est initialisé du même nombre d'occurence commençant à 0
|
||||
avec un pas de 1
|
||||
2- Lancer le calcul, avec méthodes fournie de 0 à 4, par défaut 0 sera pris. Pour
|
||||
tout élément supérieur à 4, la cinquième sera prise.
|
||||
Cette méthode retourne un tableau à Trois positions,
|
||||
-avec dans la case "A" le coef directeur de la droite,
|
||||
-dans la case "B" le positionnement vertical
|
||||
-dans la case "Cor" le coef de corrélation
|
||||
-et dans la case "Meth" le numéro de la méthode utlisée
|
||||
|
||||
Ex: print_r($oReg0->OptMV(0));
|
||||
==>Array ( [A] => -649.029426204
|
||||
[B] => 3037796.68186
|
||||
[Cor] => -0.143065138366
|
||||
[Meth] => 0 )
|
||||
3- De manière optionnel vous pouvez lancer la méthode GetOpt();,
|
||||
qui vous fournira le point de votre droite en fonction de votre
|
||||
tableau d'abscisses, si ce dernier n'est pas fourni
|
||||
vous aurez un tableau de 0 à nb-1 d'occurence du premier tableau
|
||||
|
||||
Ex: print_r($oReg1->GetOpt());
|
||||
==>Array ( [1] => 3037147.65243
|
||||
[7] => 3033253.47587
|
||||
[20] => 3024816.09333
|
||||
[21] => 3024167.06391
|
||||
[22] => 3023518.03448)
|
||||
|
||||
*/
|
||||
|
||||
//champ de l'objet
|
||||
private $tDonnees;
|
||||
private $tAbscisse;
|
||||
private $vNbElt; //Nombre déléments des tableaux
|
||||
|
||||
private $vMoyX; //Moyenne des X
|
||||
private $vMoyY; //Moyenne des Y
|
||||
private $vSumXY;
|
||||
private $vSumX;
|
||||
private $vSumY;
|
||||
private $vSumX2;
|
||||
private $tPtG; //Le point moyen G est un tableau tPtG(X,Y)=(vMoyX,vMoyY)
|
||||
//La variance, c'est la moyenne des carrés soustrait du carré de la moyenne
|
||||
Private $vVarianceX;
|
||||
Private $vVarianceY;
|
||||
//L'écart Type, c'est la racine carrée de la variance
|
||||
Private $vEcartTX;
|
||||
Private $vEcartTY;
|
||||
//La covariance, la moyenne des produits moins le produit des moyennes
|
||||
Private $vCovariance;
|
||||
|
||||
|
||||
Private $vA; //Coef directeur de la droite liée à la régression
|
||||
Private $vB; //Coef B de la droite liée à la régression
|
||||
public $vCoefCorLin;//Coef de corrélation linéaire
|
||||
|
||||
public $tTest;
|
||||
|
||||
public function __construct($tDataY,$tDataX=NULL) {
|
||||
$this->tDonnees = $tDataY;
|
||||
$this->tAbscisse = $tDataX;
|
||||
$this->vNbElt = $n=count($this->tDonnees); // Nombres d'éléments
|
||||
|
||||
//Mise en place des abscisses
|
||||
if (isset($tDataX))
|
||||
for($i=0;$i<$this->vNbElt;$i++)
|
||||
$this->tAbscisse[$i]=$i;
|
||||
|
||||
//parcours des donnees pour récupération formule nécessaire au calcul des éléments
|
||||
$sumX=0; //somme des X
|
||||
$sumY=0; //somme des Y
|
||||
$sumX2=0; //somme des X²
|
||||
$sumY2=0; //somme des y²
|
||||
$sumXY=0; //somme des x*y
|
||||
|
||||
for ($i=0;$i<$n;$i++) {
|
||||
$xVal=$this->tAbscisse[$i];
|
||||
$yVal=$this->tDonnees[$i];
|
||||
$sumX+=$xVal;
|
||||
$sumY+=$yVal;
|
||||
$sumX2+=$xVal*$xVal;
|
||||
$sumY2+=$yVal*$yVal;
|
||||
$sumXY+=$xVal*$yVal;
|
||||
}
|
||||
|
||||
$this->vMoyX=$sumX/$n; //moyenne X
|
||||
$this->vMoyY=$sumY/$n; //moyenne Y
|
||||
|
||||
$this->vSumXY=$sumXY;
|
||||
$this->vSumX=$sumX;
|
||||
$this->vSumY=$sumY;
|
||||
$this->vSumX2=$sumX2;
|
||||
|
||||
$this->tPtG=array('X'=>$this->vMoyX,'Y'=>$this->vMoyY); //point moyen G
|
||||
|
||||
//La variance, c'est la moyenne des carrés soustrait du carré de la moyenne: Rappel
|
||||
$this->vVarianceX=($sumX2/$n)-($this->vMoyX*$this->vMoyX);
|
||||
$this->vVarianceY=($sumY2/$n)-($this->vMoyY*$this->vMoyY);
|
||||
|
||||
//L'écart Type, c'est la racine carrée de la variance: Rappel
|
||||
$this->vEcartTX=sqrt(abs($this->vVarianceX));
|
||||
$this->vEcartTY=sqrt(abs($this->vVarianceY));
|
||||
|
||||
//La covariance, la moyenne des produits moins le produit des moyennes
|
||||
$this->vCovariance=($sumXY/$n)-($this->vMoyX*$this->vMoyY);
|
||||
|
||||
// coef de coorélation linéaire: Covariance que divise l'écart Type X multiplié par l'écart Type de Y
|
||||
$this->vCoefCorLin=$this->vCovariance/($this->vEcartTX*$this->vEcartTY);
|
||||
|
||||
// Calcul de la droite
|
||||
$this->CoefsDroite(0);
|
||||
|
||||
$this->tTest=array(
|
||||
'vMoyX'=>$this->vMoyX,
|
||||
'vMoyY'=>$this->vMoyY,
|
||||
'vA'=>$this->vA, // Coef directeur de la droite liée à la régression
|
||||
'vB'=>$this->vB, // Coef B de la droite liée à la régression
|
||||
'tPtG'=>$this->tPtG,
|
||||
'vVarianceX'=>$this->vVarianceX,
|
||||
'vVarianceY'=>$this->vVarianceY,
|
||||
'vEcartTX'=>$this->vEcartTX,
|
||||
'vEcartTY'=>$this->vEcartTY,
|
||||
'vCovariance'=>$this->vCovariance,
|
||||
'vCoefCorLin'=>$this->vCoefCorLin,
|
||||
);
|
||||
}
|
||||
|
||||
/** Calcul de la droite
|
||||
** (calcul de coef directeur de la régression par théorie de la régression linéaire
|
||||
** le coef a est obtenu des manières suivantes avec 5 variantes disponibles)
|
||||
**/
|
||||
Private function CoefsDroite($met=0)
|
||||
{
|
||||
switch ($met) {
|
||||
case 0:
|
||||
$this->vA=$this->vCovariance/$this->vVarianceX;
|
||||
break;
|
||||
case 1:
|
||||
$this->vA=$this->vVarianceY/$this->vCovariance;
|
||||
break;
|
||||
case 2:
|
||||
$this->vA=($this->vCovariance*$this->vEcartTY)/(abs($this->vCovariance)*$this->vEcartTX);
|
||||
break;
|
||||
/*
|
||||
case 4:
|
||||
$this->vA=($this->vSumXY-(($this->vSumX*$this->vSumY)/$this->vNbElt)/($this->vSumX2-(pow(2,$this->vSumX)/$this->vNbElt)));
|
||||
break; */
|
||||
case 3:
|
||||
$this->vA=($this->vVarianceY-$this->vVarianceX+sqrt(pow($this->vVarianceY-$this->vVarianceX,2)+pow(2*$this->vCovariance,2)))/(2*$this->vCovariance);
|
||||
break;
|
||||
case 4:
|
||||
$this->vA=($this->vSumXY-($this->vSumX*$this->vSumY/$this->vNbElt))/($this->vSumX2-(pow($this->vSumX,2)/$this->vNbElt));
|
||||
break;
|
||||
}
|
||||
$this->vB=$this->vMoyY-($this->vA*$this->vMoyX);
|
||||
}
|
||||
|
||||
/** Calcul la régression Linéaire **/
|
||||
function OptMV($meth=0){
|
||||
$this->CoefsDroite($meth);
|
||||
$this->CoefCorLin();
|
||||
return array("A"=>$this->vA,"B"=>$this->vB,"Cor"=>$this->vCoefCorLin,"Meth"=>$meth,"TauxProg"=>(1-$this->vA)*100);
|
||||
}
|
||||
|
||||
/** Renvoi le tableau des points optimisés
|
||||
**/
|
||||
function GetOpt() {
|
||||
$tOpt=array();
|
||||
foreach($this->tAbscisse as $i)
|
||||
$tOpt[$i]=$this->vA*$i+$this->vB;
|
||||
return $tOpt;
|
||||
}
|
||||
|
||||
function GetProjection($nbPeriodes) {
|
||||
$iMax=end($this->tAbscisse)+$nbPeriodes+1;
|
||||
$tOpt=array();
|
||||
for ($i=end($this->tAbscisse); $i<$iMax; $i++)
|
||||
$tOpt[$i]=$this->vA*$i+$this->vB;
|
||||
return $tOpt;
|
||||
}
|
||||
|
||||
function GetProjectionDebut($nbPeriodes) {
|
||||
$iMax=end($this->tAbscisse)+$nbPeriodes+1;
|
||||
$tOpt=array();
|
||||
reset($this->tAbscisse);
|
||||
for ($i=current($this->tAbscisse); $i<$iMax; $i++)
|
||||
$tOpt[$i]=$this->vA*$i+$this->vB;
|
||||
return $tOpt;
|
||||
}
|
||||
|
||||
function TauxProgression($nbPeriodes) {
|
||||
$tOpt=$this->GetProjection($nbPeriodes);
|
||||
reset($tOpt);
|
||||
print_r($tOpt);
|
||||
|
||||
$deb=abs(current($tOpt));
|
||||
$fin=abs(end($tOpt));
|
||||
// echo 'Deb='.$deb.EOL;
|
||||
// echo 'Fin='.$fin.EOL;
|
||||
return (($fin-$deb)*100)/$deb;
|
||||
}
|
||||
}
|
||||
|
||||
function PROJECCOEF($tabRegY,$nbAnnees) {
|
||||
global $tabRegX;
|
||||
if (count($tabRegX)==0 || count($tabRegY)==0) return false;
|
||||
|
||||
$oReg= new Regression($tabRegY,$tabRegX);
|
||||
// echo 'fonction PROJECCOEF'.EOL;
|
||||
// print_r($oReg->tTest);
|
||||
|
||||
return $oReg->vCoefCorLin;
|
||||
}
|
||||
|
||||
function PROJEC($tabRegY,$nbAnnees) {
|
||||
|
||||
global $tabRegX; // Tableau des années de millesime de bilans
|
||||
global $Y, $Yaff; // Tableau des années en paramètres + $nbAnnees Projetées
|
||||
global $PROJECTAUX; // Taux de projection de n à n+$nbAnnees
|
||||
global $PROJECCOEF; // Coef de corélation linéaire
|
||||
global $SIREN;
|
||||
if (count($tabRegX)==0 || count($tabRegY)==0) return false;
|
||||
|
||||
/*@sendMail('production@scores-decisions.com', 'ylenaour@scores-decisions.com', "Indiscore sur $SIREN : Regression Début", ''.
|
||||
'$tabRegX='.print_r($tabRegX,true).
|
||||
'$Y='.print_r($Y,true).
|
||||
'$Yaff='.print_r($Yaff,true).
|
||||
'$PROJECTAUX='.$PROJECTAUX.EOL.
|
||||
'$PROJECCOEF='.$PROJECCOEF.EOL
|
||||
);*/
|
||||
|
||||
$oReg= new Regression($tabRegY,$tabRegX);
|
||||
$tab=$oReg->GetProjectionDebut($nbAnnees);
|
||||
|
||||
$Y=$Yaff=array();
|
||||
$nbRegX=count($tabRegX);
|
||||
// Début des clés pour le tableau Y des critères
|
||||
$j=0-$nbRegX;
|
||||
foreach($tab as $i=>$valeur) {
|
||||
$j++;
|
||||
if (isset($tabRegX[$i])) {
|
||||
$Yaff[''.$tabRegX[$i].' ']=$Y[$j]=$tab[$i];
|
||||
$lastX=$tabRegX[$i];
|
||||
} else {
|
||||
$lastX++;
|
||||
$Yaff[''.$lastX.' ']=$Y[$j]=$tab[$i];
|
||||
}
|
||||
}
|
||||
/*print_r($Yaff);
|
||||
print_r($Y);
|
||||
*/
|
||||
$PROJECTAUX=$oReg->TauxProgression($nbAnnees);
|
||||
$PROJECCOEF=$oReg->vCoefCorLin*100;
|
||||
/*
|
||||
@sendMail('production@scores-decisions.com', 'ylenaour@scores-decisions.com', "Indiscore sur $SIREN : Regression Fin",
|
||||
'$nbAnnees='.$nbAnnees." ($tabRegY)".EOL.
|
||||
'$tabRegX='.print_r($tabRegX,true).EOL.
|
||||
'$tabRegY='.print_r($tabRegY,true).EOL.
|
||||
'Régression $tab='.print_r($tab,true).EOL.
|
||||
EOL.
|
||||
'$Yaff='.print_r($Yaff,true).EOL.
|
||||
'$Y='.print_r($Y,true).EOL.
|
||||
'$PROJECTAUX='.$PROJECTAUX.EOL.
|
||||
'$PROJECCOEF='.$PROJECCOEF.EOL);
|
||||
*/
|
||||
return end($tab);
|
||||
}
|
||||
|
||||
function PROJECTAUX($tabRegY,$nbAnnees) {
|
||||
global $tabRegX;
|
||||
if (count($tabRegX)==0 || count($tabRegY)==0) return false;
|
||||
|
||||
$oReg= new Regression($tabRegY,$tabRegX);
|
||||
return $oReg->TauxProgression($nbAnnees);
|
||||
}
|
||||
|
||||
?>
|
3914
library/Metier/scores/classMScores.php
Normal file
3914
library/Metier/scores/classMScores.php
Normal file
File diff suppressed because it is too large
Load Diff
1253
library/Metier/scores/classMSolvabilite.php
Normal file
1253
library/Metier/scores/classMSolvabilite.php
Normal file
File diff suppressed because it is too large
Load Diff
34
library/Metier/scores/config.php
Normal file
34
library/Metier/scores/config.php
Normal file
@ -0,0 +1,34 @@
|
||||
<?
|
||||
define('INCLUDE_PATH', '/var/www/includes/');
|
||||
|
||||
/** BATCH
|
||||
**/
|
||||
define('FILLER','');
|
||||
define('LONGUEUR_LIGNE_SORTIE', 2000);
|
||||
|
||||
|
||||
/** Paramétres du FTP des JO
|
||||
**/
|
||||
define('BODACC_FTP_URL', 'ftp.journal-officiel.gouv.fr');
|
||||
define('BODACC_FTP_USER', 'SCORE');
|
||||
define('BODACC_FTP_PASS', 'SD075');
|
||||
define('BODACC_LOCAL_DIR', '/home/data/bodacc/');
|
||||
|
||||
/** Paramétres du FTP de Hugin : Communiqués de presse
|
||||
**/
|
||||
define('HUGIN_FTP_URL', 'ftp.companynews.fr');
|
||||
define('HUGIN_FTP_USER', 'scores');
|
||||
define('HUGIN_FTP_PASS', 'scores_632');
|
||||
define('HUGIN_LOCAL_DIR', '/home/data/hugin/');
|
||||
|
||||
/** Base de données de S&D
|
||||
**/
|
||||
|
||||
define ('MYSQL_HOST', 'localhost');
|
||||
define ('MYSQL_USER', 'root');
|
||||
define ('MYSQL_PASS', 'bzh4231*');
|
||||
define ('MYSQL_DEFAULT_DB', 'jo');
|
||||
|
||||
define ('MYSQL_SQL_LOG', 'NONE');
|
||||
|
||||
?>
|
1612
library/Metier/scores/configMFinancier.php
Normal file
1612
library/Metier/scores/configMFinancier.php
Normal file
File diff suppressed because it is too large
Load Diff
1612
library/Metier/scores/configMRatios.php
Normal file
1612
library/Metier/scores/configMRatios.php
Normal file
File diff suppressed because it is too large
Load Diff
586
library/Metier/scores/globalCommentaires.php
Normal file
586
library/Metier/scores/globalCommentaires.php
Normal file
@ -0,0 +1,586 @@
|
||||
<?php
|
||||
$tabVar = array(
|
||||
'ACTIFINSEE',
|
||||
'ACTIFRNCS',
|
||||
'ACTISURF',
|
||||
'ACTIVNAT',
|
||||
'ACTIVREG',
|
||||
'ADRDOM',
|
||||
'AGE',
|
||||
'ANNEEp3',
|
||||
'ANNEEp2',
|
||||
'ANNEEp1',
|
||||
'ANNEE',
|
||||
'ANNEE1',
|
||||
'ANNEE2',
|
||||
'ANNEE3',
|
||||
'ANNEE4',
|
||||
'ANNEE5',
|
||||
'ANNONCEADR',
|
||||
'ANNONCEADRDATE',
|
||||
'ANNONCEBOD',
|
||||
'ANNONCEBODA',
|
||||
'ANNONCEBODADATE',
|
||||
'ANNONCEBODB',
|
||||
'ANNONCEBODBDATE',
|
||||
'ANNONCEBODC',
|
||||
'ANNONCEBODCDATE',
|
||||
'ANNONCEBODCMANQDATE',
|
||||
'ANNONCEBODCMANQ_AA',
|
||||
'ANNONCEBODCREGUL',
|
||||
'ANNONCEBODDATE',
|
||||
'ANNONCECAC',
|
||||
'ANNONCECAC2',
|
||||
'ANNONCECAC3',
|
||||
'ANNONCECACDATE',
|
||||
'ANNONCECAP',
|
||||
'ANNONCECAPAUG',
|
||||
'ANNONCECAPAUGDATE',
|
||||
'ANNONCECAPAUGDIM',
|
||||
'ANNONCECAPAUG_AAD',
|
||||
'ANNONCECAPAUG_AAF',
|
||||
'ANNONCECAPDATE',
|
||||
'ANNONCECAPDIM',
|
||||
'ANNONCECAPDIMAUG',
|
||||
'ANNONCECAPDIMDATE',
|
||||
'ANNONCECAPDIM_AAD',
|
||||
'ANNONCECAPDIM_AAF',
|
||||
'ANNONCECAPSIG',
|
||||
'ANNONCECLODELAI',
|
||||
'ANNONCEDATE',
|
||||
'ANNONCEDER',
|
||||
'ANNONCEDERDATE',
|
||||
'ANNONCEDERSOURCE',
|
||||
'ANNONCEDERTEXTE',
|
||||
'ANNONCEDIR',
|
||||
'ANNONCEDIRDATE',
|
||||
'ANNONCEDISSO',
|
||||
'ANNONCEDISSODATE',
|
||||
'ANNONCEDISSONON',
|
||||
'ANNONCEDISSONONDATE',
|
||||
'ANNONCEFJUR',
|
||||
'ANNONCEFJURDATE',
|
||||
'ANNONCEFUS',
|
||||
'ANNONCEFUSDATE',
|
||||
'ANNONCEHISTDATE',
|
||||
'ANNONCEHOM',
|
||||
'ANNONCEHOMDATE',
|
||||
'ANNONCEINTERDIT',
|
||||
'ANNONCEINTERDITDATE',
|
||||
'ANNONCELIM',
|
||||
'ANNONCELJ',
|
||||
'ANNONCELJDATE',
|
||||
'ANNONCELJDELAI',
|
||||
'ANNONCELOC',
|
||||
'ANNONCELOCDATE',
|
||||
'ANNONCEOBJET',
|
||||
'ANNONCEPC',
|
||||
'ANNONCEPCDATE',
|
||||
'ANNONCEPCHISTO',
|
||||
'ANNONCEPC_CESDATE',
|
||||
'ANNONCEPC_INT1',
|
||||
'ANNONCEPC_INT1_TIT',
|
||||
'ANNONCEPC_INT2',
|
||||
'ANNONCEPC_INT2_TIT',
|
||||
'ANNONCEPC_NUM',
|
||||
'ANNONCEPC_OBS',
|
||||
'ANNONCEPLAN',
|
||||
'ANNONCEPLANDATE',
|
||||
'ANNONCEPLANDUREE',
|
||||
'ANNONCEPLANFINDATE',
|
||||
'ANNONCEPLANMODIFDATE',
|
||||
'ANNONCEPOURS',
|
||||
'ANNONCEPOURSDATE',
|
||||
'ANNONCEPUB',
|
||||
'ANNONCERECON',
|
||||
'ANNONCERECONDATE',
|
||||
'ANNONCERJ',
|
||||
'ANNONCERJDATE',
|
||||
'ANNONCESOMM',
|
||||
'ANNONCESOMMDATE',
|
||||
'ANNONCESV',
|
||||
'ANNONCESVDATE',
|
||||
'ANNONCEVC',
|
||||
'ANNONCEVCDATE',
|
||||
'ANNONCEVC_MT',
|
||||
'ANNONCEVC_OBJ',
|
||||
'APE4',
|
||||
'APE5',
|
||||
'APEAGRICPAC',
|
||||
'APEENT',
|
||||
'APEETAB',
|
||||
'APEINSEE',
|
||||
'APERNCS',
|
||||
'AUXILT',
|
||||
'AVIS3ANS',
|
||||
'BILAN',
|
||||
'BILANANNEE',
|
||||
'BILANANNEE1',
|
||||
'BILANANNEE2',
|
||||
'BILANANNEE3',
|
||||
'BILANANNEE4',
|
||||
'BILANANNEE5',
|
||||
'BILANANNEEp',
|
||||
'BILANANNEEp2',
|
||||
'BILANANNEEp3',
|
||||
'BILANANNEEp4',
|
||||
'BILANDATE',
|
||||
'BILANDATEp',
|
||||
'BILANDATEp2',
|
||||
'BILANDATEp3',
|
||||
'BILANDATEp4',
|
||||
'BILANDERANNEE',
|
||||
'BILANFACULT',
|
||||
'BILANFJU',
|
||||
'BILANMANQUE',
|
||||
'BILANNONDIF',
|
||||
'BILANVIEUX',
|
||||
'BILANp',
|
||||
'BILANp2',
|
||||
'BILANp3',
|
||||
'BILANp4',
|
||||
'CABILAN',
|
||||
'CABIOUES',
|
||||
'CAESTIME',
|
||||
'CADBAT_NB_TOT',
|
||||
'CADTER_NB_TOT',
|
||||
'CADBAT_NB_PROP',
|
||||
'CADTER_NB_PROP',
|
||||
'CADBAT_NB_NONPROP',
|
||||
'CADTER_NB_NONPROP',
|
||||
'CADBAT_SURF_CUM',
|
||||
'CADBAT_SURF_TOT',
|
||||
'CADTER_SURF_CUM',
|
||||
'CADTER_SURF_TOT',
|
||||
'CALCUL1',
|
||||
'CALCUL2',
|
||||
'CALCUL3',
|
||||
'CALCUL4',
|
||||
'CALCUL5',
|
||||
'CALCUL6',
|
||||
'CALCUL7',
|
||||
'CALCUL8',
|
||||
'CALCUL9',
|
||||
'CAPITAL',
|
||||
'CAPITAL_CREA',
|
||||
'CAPITAL_PRE',
|
||||
'CAPITAL_NBACTION',
|
||||
'CAPITAL_MTACTION',
|
||||
'CAPITAL_TYPE',
|
||||
'CA_COEF',
|
||||
'CA_TAUX',
|
||||
'CA_Y',
|
||||
'COTELIM',
|
||||
'COTEOK',
|
||||
'COTEOK_MMAA',
|
||||
'COTETYPEHIS',
|
||||
'COTETYPE_MMAA',
|
||||
'CSFACTO',
|
||||
'CSFACTO_MMAA',
|
||||
'DEPARTEMENT',
|
||||
'DEPARTEMENT_DE',
|
||||
'DCREN',
|
||||
'DCREN_AA',
|
||||
'DEFAUT_MMAA',
|
||||
'DELAIPAY',
|
||||
'DELAIPAY_MMAA',
|
||||
'DELAIPAYp',
|
||||
'DEPSIE',
|
||||
'DEPSIE_DE',
|
||||
'DIMMAT',
|
||||
'DIMMAT_AA',
|
||||
'DIR1_AGE',
|
||||
'DIR1_FONC',
|
||||
'DIR1_NOM',
|
||||
'DIR1_TYPE',
|
||||
'DIR2_AGE',
|
||||
'DIR2_FONC',
|
||||
'DIR2_NOM',
|
||||
'DIR2_TYPE',
|
||||
'DIR_NB',
|
||||
'DOM_NB',
|
||||
'DOM_NOM',
|
||||
'DOM_SIREN',
|
||||
'EFFBILAN',
|
||||
'EFFECTIF',
|
||||
'EFFECTIF_POPU',
|
||||
'ELIMINE',
|
||||
'ENCOURSDEM',
|
||||
'ENCOURS', // Encours final attribué
|
||||
'ENCOURSCALC', // Encours calculé sans cut-off
|
||||
'ENQUETE',
|
||||
'ENQUETELIM',
|
||||
'ENQUETEMAXI',
|
||||
'ETATINSEE',
|
||||
'ETATINSEE_MMAA',
|
||||
'EXPLEN',
|
||||
'EXPLET',
|
||||
'EXPORTRANG',
|
||||
'EXPORTRANG_ARR',
|
||||
'FJUR',
|
||||
'FJUR1',
|
||||
'FJUR2',
|
||||
'FJUR4',
|
||||
'FJURINSEE',
|
||||
'FJURPUB',
|
||||
'FJURRNCS',
|
||||
'FJUR_PRE',
|
||||
'FRANCHISE',
|
||||
'FUSIONPROJET',
|
||||
'FUSIONPROJET_DATE',
|
||||
'FUSIONPROJET_SIREN',
|
||||
'GERANTMAJ',
|
||||
'GRANDGROUPE',
|
||||
'HOLDING',
|
||||
'IMPAYELOURD_MMAA',
|
||||
'IMPAYE_MMAA',
|
||||
'IMPORTRANG',
|
||||
'IMPORTRANG_ARR',
|
||||
'INFLA',
|
||||
'INFLAMOY1',
|
||||
'INFLAMOY2',
|
||||
'INFLAMOY3',
|
||||
'INFLATION',
|
||||
'INFOCESSATION_MMAA',
|
||||
'INFOFACTO',
|
||||
'JOUR_DATE',
|
||||
'JOUR_HEURE',
|
||||
'LCASSUR_MMAA',
|
||||
'LIBARTDEPSIE',
|
||||
'LIEUACT',
|
||||
'LISTEPRODUIT',
|
||||
'MARCHE',
|
||||
'MARCHEPART',
|
||||
'MARCHEPARTEVOL',
|
||||
'MARCHEPARTp',
|
||||
'MARCHEPLACE',
|
||||
'MARCHEPLACE_DEP',
|
||||
'MARCHEVOL',
|
||||
'MARCHEVOLUMEVOL',
|
||||
'MARCHEp',
|
||||
'MARCHESAL',
|
||||
'MARCHESALp',
|
||||
'MARCHENBENT',
|
||||
'MARCHENBENTp',
|
||||
'MARCHENBENT_DEP',
|
||||
'MARCHENBENT_VILLE',
|
||||
'MARCHEPUBLIC3_NB',
|
||||
'MARCHEPUBLIC3_MT',
|
||||
'MARCHEPUBLIC3_POURC',
|
||||
'MARCHEPUBLICAPP3_NB', // Nombre d'avis de marchés attribués par une administration sur les 3 dernières années
|
||||
'MARCHEPUBLIC3APP_MT', // Montant des avis de marchés attribués par une administration sur les 3 dernières années
|
||||
'MARCHEPUBLIC3APP_POURC', // % Par rapport au total des produits de fonctionnement
|
||||
'MARCHEPUBLICDER_OBJ',
|
||||
'MARCHEPUBLICDER_CLI',
|
||||
'MARCHEPUBLICDER_MT',
|
||||
'MARCHEPUBLICDER_DATE',
|
||||
'MARCHEPUBLICDERAPP_OBJ', // @todo
|
||||
'MARCHEPUBLICDERAPP_BEN', // Bénéficiaire
|
||||
'MARCHEPUBLICDERAPP_MT', // ..
|
||||
'MARCHEPUBLICDERAPP_DATE', // ..
|
||||
'MARQUENB',
|
||||
'MARQUENB_INT',
|
||||
'MARQUENB_EUR',
|
||||
'MARQUENB_FR',
|
||||
'MARQUELISTE_INT',
|
||||
'MARQUELISTE_EUR',
|
||||
'MARQUELISTE_FR',
|
||||
'MODEN',
|
||||
'MODIFBILDATE',
|
||||
'MODIFDERDATE',
|
||||
'MODIFINSEE',
|
||||
'MODIFINSEEDATE',
|
||||
'MODIFPAIDATE',
|
||||
'MODIFRNCS',
|
||||
'MODIFRNCSDATE',
|
||||
'MONOACT',
|
||||
'MONOREG',
|
||||
'NBBILAN',
|
||||
'NBBILANMANQUE',
|
||||
'NBBILANSEC',
|
||||
'NBDIRLIEN',
|
||||
'NBDIRSCI',
|
||||
'NBDIRSCIADR',
|
||||
'NBETEXPL',
|
||||
'NBFILLE',
|
||||
'NBINTERRO1',
|
||||
'NBINTERRO12',
|
||||
'NBINTERRO3',
|
||||
'NBINTERRO6',
|
||||
'NBNIC',
|
||||
'NBSOCSEC',
|
||||
'NBSOCSECPUB',
|
||||
'NBSUIVICLI',
|
||||
'NIC',
|
||||
'NICFILLE',
|
||||
'NICMERE',
|
||||
'NIVEAU',
|
||||
'NOMEN',
|
||||
'NOMFILLE',
|
||||
'NOMFUSION',
|
||||
'NOMMERE',
|
||||
'NOTE100',
|
||||
'NOTECAP20',
|
||||
'NOTECFI20',
|
||||
'NOTEDEFPRO',
|
||||
'NOTEDEFSEC',
|
||||
'NOTELED20',
|
||||
'NOTEMEX20',
|
||||
'NOTERBT20',
|
||||
'NOTESBRUTE',
|
||||
'NOTESCORE',
|
||||
'NOTETRES20',
|
||||
'ORIASCAT',
|
||||
'ORIASID',
|
||||
'ORIASID_DATE',
|
||||
'ORIGINE',
|
||||
'PLAN',
|
||||
'PLANMODIF',
|
||||
'POPULATION',
|
||||
'PPNONDIFF',
|
||||
'PRESENTINSEE',
|
||||
'PRESENTRNCS',
|
||||
'PRIVILEGES',
|
||||
'PRIVILEGESECU',
|
||||
'PRIVILEGESECU_MT',
|
||||
'PRIVILEGESURSSAF_MMAA',
|
||||
'PRIVILEGES_MMAA',
|
||||
'PRIVILEGETRES',
|
||||
'PRIVILEGETRES_MT',
|
||||
'PRODPART',
|
||||
'R',
|
||||
'RCAI_COEF',
|
||||
'RCAI_TAUX',
|
||||
'RCAI_Y',
|
||||
'RECME',
|
||||
'REGIMP',
|
||||
'RISQUEACT',
|
||||
'RISQUEACTBASSIN',
|
||||
'RISQUEACT_NB',
|
||||
'RISQUEANALYSE_MMAA',
|
||||
'RISQUEGEO',
|
||||
'RISQUEGEOARRETE',
|
||||
'RISQUEGEOARRETE_AA',
|
||||
'RISQUEGEOARRETE_DATE',
|
||||
'RISQUEGEOARRETE_EVTDATE',
|
||||
'RISQUEGEOARRETE_JODATE',
|
||||
'RISQUEGEOARRETE_NB',
|
||||
'RISQUEGEOARRETE_VILLE',
|
||||
'RISQUEGEO_NB',
|
||||
'RISQUEGROUPE_MMAA',
|
||||
'RISQUEIMPAYE_MMAA',
|
||||
'RJFILLE',
|
||||
'RJMERE',
|
||||
'ROUEDELARELANCE',
|
||||
'RPEN',
|
||||
'RPS_ACCORDDATE',
|
||||
'RPS_INFODATE',
|
||||
'RPS_NEGO',
|
||||
'RPS_PLAN',
|
||||
'Ra',
|
||||
'Rap',
|
||||
'Rdiff',
|
||||
'Revol',
|
||||
'Revolp',
|
||||
'Revolp2',
|
||||
'Revolp3',
|
||||
'Revols',
|
||||
'Rp',
|
||||
'Rp2',
|
||||
'Rp3',
|
||||
'Rp4',
|
||||
'Rs',
|
||||
'Rsp',
|
||||
'Rsp1',
|
||||
'Rsp2',
|
||||
'Rsp3',
|
||||
'SAISONAT',
|
||||
'SCORECONF',
|
||||
'SCOREDEFTAUX',
|
||||
'SCOREDIRI',
|
||||
'SIREN',
|
||||
'SIRENFILLE',
|
||||
'SIRENMERE',
|
||||
'SIRET',
|
||||
'SIRETFILLE',
|
||||
'SIRETMERE',
|
||||
'SITUACT',
|
||||
'SOCIETE_COTE',
|
||||
'SOCIETE_COTE_CAPITALISATION',
|
||||
'SOCIETE_COTE_COURS',
|
||||
'SOCIETE_COTE_COURS_DATE',
|
||||
'SOCIETE_COTE_COURS_MAX',
|
||||
'SOCIETE_COTE_COURS_MIN',
|
||||
'SOCIETE_COTE_ISIN',
|
||||
'SOCIETE_COTE_MARCHE',
|
||||
'SOCIETE_COTE_MARCHE_MERE',
|
||||
'SOCIETE_COTE_PLACE',
|
||||
'T',
|
||||
'TCAEXP',
|
||||
'TEMOINACT',
|
||||
'TEMOINACT_MAX',
|
||||
'TEMOINATT',
|
||||
'TEMOINATT_MAX',
|
||||
'TEMOINAVI',
|
||||
'TEMOINAVI_MAX',
|
||||
'TEMOINCAPFAIBLE',
|
||||
'TEMOINCAPFAIBLE_MAX',
|
||||
'TEMOINCLES',
|
||||
'TEMOINCLES_MAX',
|
||||
'TEMOINCONF',
|
||||
'TEMOINCONF_MAX',
|
||||
'TEMOINCYANO',
|
||||
'TEMOINCYANO_MAX',
|
||||
'TEMOINCYC',
|
||||
'TEMOINCYC_MAX',
|
||||
'TEMOINDEF',
|
||||
'TEMOINDEF_MAX',
|
||||
'TEMOINDIAG',
|
||||
'TEMOINDIAG_MAX',
|
||||
'TEMOINDIR',
|
||||
'TEMOINDIR_MAX',
|
||||
'TEMOINEXP',
|
||||
'TEMOINEXP_MAX',
|
||||
'TEMOINFAV',
|
||||
'TEMOINFAV_MAX',
|
||||
'TEMOINFIL',
|
||||
'TEMOINFIL_MAX',
|
||||
'TEMOINFIN',
|
||||
'TEMOINFIN_MAX',
|
||||
'TEMOINFLANO',
|
||||
'TEMOINFLANO_MAX',
|
||||
'TEMOINFLUX',
|
||||
'TEMOINFLUX_MAX',
|
||||
'TEMOINGRAPH',
|
||||
'TEMOINGRAPH_MAX',
|
||||
'TEMOINHIST',
|
||||
'TEMOINHIST_MAX',
|
||||
'TEMOINLOC',
|
||||
'TEMOINLOC_MAX',
|
||||
'TEMOINMAR',
|
||||
'TEMOINMAR_MAX',
|
||||
'TEMOINMARPUB',
|
||||
'TEMOINMARPUB_MAX',
|
||||
'TEMOINMOIN',
|
||||
'TEMOINMOIN_MAX',
|
||||
'TEMOINNORM',
|
||||
'TEMOINNORM_MAX',
|
||||
'TEMOINOBS',
|
||||
'TEMOINOBS_MAX',
|
||||
'TEMOINPAY',
|
||||
'TEMOINPAY_MAX',
|
||||
'TEMOINPLUS',
|
||||
'TEMOINPLUS_MAX',
|
||||
'TEMOINPROF',
|
||||
'TEMOINPROF_MAX',
|
||||
'TEMOINPROJ',
|
||||
'TEMOINPROJ_MAX',
|
||||
'TEMOINREPA',
|
||||
'TEMOINREPA_MAX',
|
||||
'TEMOINRES',
|
||||
'TEMOINRES_MAX',
|
||||
'TEMOINRIS',
|
||||
'TEMOINRIS_MAX',
|
||||
'TEMOINSTACTIF',
|
||||
'TEMOINSTACTIF_MAX',
|
||||
'TEMOINSTANO',
|
||||
'TEMOINSTANO_MAX',
|
||||
'TEMOINSTPASS',
|
||||
'TEMOINSTPASS_MAX',
|
||||
'TEMOINSTRUCT',
|
||||
'TEMOINSTRUCT_MAX',
|
||||
'TEMOINSTSYNT',
|
||||
'TEMOINSTSYNT_MAX',
|
||||
'TEMOINVUL',
|
||||
'TEMOINVUL_MAX',
|
||||
'TEMOINADIZES',
|
||||
'TEMOINADIZES_MAX',
|
||||
'TEMOINMRQ',
|
||||
'TEMOINMRQ_MAX',
|
||||
'TEMOINMRQLIST',
|
||||
'TEMOINMRQLIST_MAX',
|
||||
'TRIBUNAL_ACTUEL',
|
||||
'TRIBUNAL_CREATION',
|
||||
'TRIBUNAL_PROCOL',
|
||||
'TU',
|
||||
'TVAINTRA',
|
||||
'TVAINTRAFACULT',
|
||||
'TYPEMERE',
|
||||
'VILLE',
|
||||
'VENTEMAX_VILLE_MT',
|
||||
'VENTEMOY_VILLE_MT',
|
||||
'VENTEMIN_VILLE_MT',
|
||||
'VENTE_VILLE_NB',
|
||||
'VENTEMAX_DEP_MT',
|
||||
'VENTEMOY_DEP_MT',
|
||||
'VENTEMIN_DEP_MT',
|
||||
'VENTE_DEP_NB',
|
||||
'VENTEMAX_FRA_MT',
|
||||
'VENTEMOY_FRA_MT',
|
||||
'VENTEMIN_FRA_MT',
|
||||
'VENTE_FRA_NB',
|
||||
'VENTEMAX_MT', // A supprimer après la 4.02
|
||||
'VENTEMIN_MT', // A supprimer après la 4.02
|
||||
'VENTE_NB', // A supprimer après la 4.02
|
||||
'WALDEC',
|
||||
'Y',
|
||||
'ZEMET',
|
||||
'ZONEPRI',
|
||||
'ZONEPRIAFR',
|
||||
'ZONEPRICUCS',
|
||||
'ZONEPRIZFU',
|
||||
'ZONEPRIZRR',
|
||||
'ZONEPRIZRU',
|
||||
'ZONEPRIZUS',
|
||||
'nm',
|
||||
'nmp',
|
||||
'nmp2',
|
||||
'nmp3',
|
||||
'nmp4',
|
||||
'regR',
|
||||
'regRs',
|
||||
);
|
||||
|
||||
foreach ($tabVar as $var)
|
||||
global $$var;
|
||||
|
||||
if (!function_exists('unsetGlobals')) {
|
||||
function unsetGlobals() {
|
||||
foreach ($tabVar as $var)
|
||||
unset ($$var);
|
||||
unset ($tva);
|
||||
unset ($tabFormules);
|
||||
unset ($tabFormulesRatios);
|
||||
unset ($mBil);
|
||||
unset ($tabBilan);
|
||||
unset ($efftr);
|
||||
unset ($tabRatiosInfos);
|
||||
unset ($R);
|
||||
unset ($Rp);
|
||||
unset ($Rp2);
|
||||
unset ($Rp3);
|
||||
unset ($Rp4);
|
||||
unset ($Rs);
|
||||
unset ($Rsp);
|
||||
unset ($Rsp2);
|
||||
unset ($Rsp3);
|
||||
unset ($Rsp4);
|
||||
unset ($Revol);
|
||||
unset ($Revolp);
|
||||
unset ($Revolp2);
|
||||
unset ($Revolp3);
|
||||
unset ($regR);
|
||||
unset ($regRs);
|
||||
unset ($Ra);
|
||||
unset ($Rap);
|
||||
unset ($Rdiff);
|
||||
unset ($tabRegX);
|
||||
unset ($Y);
|
||||
unset ($Yaff);
|
||||
unset ($PROJECTAUX);
|
||||
unset ($PROJECCOEF);
|
||||
unset ($idx);
|
||||
unset ($tabVariables);
|
||||
}
|
||||
}
|
||||
?>
|
47
library/Metier/sphinx/comb2crit.txt
Normal file
47
library/Metier/sphinx/comb2crit.txt
Normal file
@ -0,0 +1,47 @@
|
||||
00
|
||||
11 IT
|
||||
12 I
|
||||
13 T
|
||||
21 D NR
|
||||
22 D VNR
|
||||
23 DL N
|
||||
24 DL NR
|
||||
25 P NR
|
||||
26 P VN
|
||||
27 PD VNR
|
||||
28 PD N
|
||||
30 S
|
||||
31 SE
|
||||
32 SE R
|
||||
33 SE N
|
||||
34 SE NR
|
||||
35 SE V
|
||||
36 SE V R
|
||||
37 SE VNR
|
||||
40 SE D
|
||||
41 SE D N
|
||||
42 SE D V
|
||||
43 SE D V R
|
||||
44 SE D VN
|
||||
45 SE D VNR
|
||||
46 SE DL
|
||||
47 SE DL R
|
||||
48 SE DL N
|
||||
49 SE DL NR
|
||||
60 SEP
|
||||
61 SEP N
|
||||
62 SEP NR
|
||||
63 SEP V
|
||||
64 SEP V R
|
||||
65 SEP VNR
|
||||
71 SEPD
|
||||
72 SEPD R
|
||||
73 SEPD N
|
||||
74 SEPD NR
|
||||
75 SEPD V
|
||||
76 SEPD V R
|
||||
77 SEPD VN
|
||||
78 SEPD VNR
|
||||
81 SEPDL R
|
||||
82 SEPDL N
|
||||
83 SEPDL NR
|
45
library/Metier/sphinx/cpVilles.php
Normal file
45
library/Metier/sphinx/cpVilles.php
Normal file
@ -0,0 +1,45 @@
|
||||
<?php
|
||||
include_once('listeCpVilles.php');
|
||||
|
||||
// --------------------------------------------------------------------------- //
|
||||
// bsearch
|
||||
// --------------------------------------------------------------------------- //
|
||||
function bsearch(&$tab, $a, $b, $s, $l)
|
||||
{
|
||||
if ($a > $b) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
$m = ($a + $b) >> 1;
|
||||
|
||||
$c = strcmp($s, substr($tab[$m], 0, $l));
|
||||
if ($c == 0) {
|
||||
return $m;
|
||||
} else if ($c < 0) {
|
||||
return bsearch($tab, $a, $m - 1, $s, $l);
|
||||
} else {
|
||||
return bsearch($tab, $m + 1, $b, $s, $l);
|
||||
}
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------- //
|
||||
// Main
|
||||
// --------------------------------------------------------------------------- //
|
||||
$completion = array();
|
||||
$strlen = strlen($_GET['val']);
|
||||
$upper = strtoupper($_GET['val']) ;
|
||||
$i = bsearch($cpVilles, 0, sizeof($cpVilles) - 1, $upper, $strlen);
|
||||
if ($i >= 0) {
|
||||
while ($i > 0 && substr($cpVilles[$i - 1], 0, $strlen) == $upper) {
|
||||
--$i;
|
||||
}
|
||||
while ($i < sizeof($cpVilles) &&
|
||||
substr($cpVilles[$i], 0, $strlen) == $upper) {
|
||||
$completion[] = '"'.$cpVilles[$i].'"';
|
||||
++$i;
|
||||
}
|
||||
}
|
||||
|
||||
// Envoi au javascript au format JSON ['valeur1','valeur2', ...]
|
||||
print '['.join(',', $completion).']';
|
||||
?>
|
114
library/Metier/sphinx/crit2seq.prn
Normal file
114
library/Metier/sphinx/crit2seq.prn
Normal file
@ -0,0 +1,114 @@
|
||||
; COMBINAISON de DEPART
|
||||
; (présence 1 ou +mots critère)
|
||||
;sITSEPDLVNR CODES COMBINAISONS DE CRITERES + P=phonétique ou O=Orthographique
|
||||
1 IT 12
|
||||
1 I 00
|
||||
1 I SEP 12
|
||||
1 T 00
|
||||
1 TSEP 13 61 61o61p
|
||||
1 D VNR 24 45o24o24p
|
||||
1 D NR 21o21p
|
||||
1 DL NR 21 21o21p
|
||||
1 DLVNR 45 24 45o24o24p
|
||||
1 P VNR 74 78o74o74p
|
||||
1 PD VNR 74 78o74o74p
|
||||
1 PDL NR 78 83o74 74o74p
|
||||
1 PDLV R 78 81 82 77 71
|
||||
1 PDLVN 78 82 75 28 71
|
||||
1 PDLVNR 78 74 82 78o74o82o82p
|
||||
1 S 30o30p
|
||||
1 S R 72o71 71o71p
|
||||
1 S N 31
|
||||
1 S NR 77 43 71
|
||||
1 S V 35o35p30
|
||||
1 S VN 75 77o75o77p75p
|
||||
1 S V R 75 83
|
||||
1 S VNR 43 44 75 83 61 71
|
||||
1 S D 40p40o61p61
|
||||
1 S D R 45o77 77o77p
|
||||
1 S D N 71
|
||||
1 S D NR 77 43 71 31
|
||||
1 S D V 77o40 40o
|
||||
1 S D V R 75 72 71
|
||||
1 S D VN 43 41 77 71
|
||||
1 S D VNR 44 43 49 73 75 72 71
|
||||
1 S DL 78 78p61p61p
|
||||
1 S DL R 82 78 77 71
|
||||
1 S DL N 41 71
|
||||
1 S DL NR 78 82 81 78p77 43 71 31
|
||||
1 S DLV 78 78p71
|
||||
1 S DLV R 78 83 82 75 72 40 71
|
||||
1 S DLVN 78 82 78p43 71
|
||||
1 S DLVNR 78 49 77 43 78p75 41 72 71 22
|
||||
1 S P 60o60p31 31o31p
|
||||
1 S P R 45 77 41
|
||||
1 S P N 71 71o45 45p
|
||||
1 S P NR 77 72 33 32
|
||||
1 S P V 63o45 45o45p
|
||||
1 S P VN 45 43 61 64
|
||||
1 S P V R 75 83 45 35
|
||||
1 S P VNR 77 45 44 43 73 75 72 71 41 42 40
|
||||
1 S PD 45 71p71o
|
||||
1 S PD R 77 45 71
|
||||
1 S PD N 71 71o45 45o
|
||||
1 S PD NR 77 76 45 41 43 40
|
||||
1 S PD V 45 45o71 42 42p
|
||||
1 S PD V R 77 83 43 71 41
|
||||
1 S PD VN 83 75 71 44 83o75o71o44o43 41 40 40o40p
|
||||
1 S PD VNR 77 74 45 44 43 75 71 61 63 60 40
|
||||
1 S PDL 71 71o71p45 45o
|
||||
1 S PDL R 78 82 75 45 44
|
||||
1 S PDL N 73 48 41
|
||||
1 S PDL NR 78 82 81 49 77 65 44 43 75 60 31
|
||||
1 S PDLV 78 45 45o71 42 42p40
|
||||
1 S PDLV R 78 83 82 75 45 49 46 42 71 40
|
||||
1 S PDLVN 78 83 77 45 71 42 41 40
|
||||
1 S PDLVNR 78 83 27 74 45 44 43 42 40
|
||||
1 SE 31o31p
|
||||
1 SE R 72o71 71o71p
|
||||
1 SE N 31
|
||||
1 SE NR 77 43 71
|
||||
1 SE V 35o35p30
|
||||
1 SE V R 75 83
|
||||
1 SE VN 75 77
|
||||
1 SE VNR 43 44 75 83 61 71
|
||||
1 SE D 40o30
|
||||
1 SE D R 45o77
|
||||
1 SE D N 71
|
||||
1 SE D NR 77 43 71 31
|
||||
1 SE D V 77o40
|
||||
1 SE D V R 75 72 71
|
||||
1 SE D VN 43 41 77
|
||||
1 SE D VNR 44 43 49 73 75 72 71
|
||||
1 SE DL 40
|
||||
1 SE DL R 82 78 77
|
||||
1 SE DL N 45 43 82o45o43o43p
|
||||
1 SE DL NR 78 82 81 46 77 43 71 31
|
||||
1 SE DLV 78 78o71 71o71p
|
||||
1 SE DLV R 78 83 82 75 72 40
|
||||
1 SE DLVN 78 82 46 43 71
|
||||
1 SE DLVNR 78 49 77 43 46 75 41 72 71 22
|
||||
1 SEP 61p31 31p30
|
||||
1 SEP R 45 77 41
|
||||
1 SEP N 71 71o45 45p
|
||||
1 SEP NR 77 72 33 32
|
||||
1 SEP V 63o45
|
||||
1 SEP V R 75 83 45 35
|
||||
1 SEP VN 45 43 61 64
|
||||
1 SEP VNR 77 45 44 43 73 75 72 71 41 42 40
|
||||
1 SEPD 45 71p
|
||||
1 SEPD R 77 45
|
||||
1 SEPD N 71 71o45 40
|
||||
1 SEPD NR 77 76 45 41 43 40
|
||||
1 SEPD V 45 71p71o40
|
||||
1 SEPD V R 77 83 43 71 41 40
|
||||
1 SEPD VN 83 75 71 44 83o75o71o44o43 41 40 40o40p
|
||||
1 SEPD VNR 77 74 45 44 43 75 71 61 63 60 40
|
||||
1 SEPDL 45 71p40
|
||||
1 SEPDL R 78 82 75 45 44 40
|
||||
1 SEPDL N 73 48 41 40
|
||||
1 SEPDL NR 78 82 81 49 77 65 44 43 75 60 31
|
||||
1 SEPDLV 78 45 45o71 42 42p
|
||||
1 SEPDLV R 78 83 82 75 45 49 46 42 71 40
|
||||
1 SEPDLVN 78 83 77 45 71 42 41 40
|
||||
1 SEPDLVNR 78 83 27 74 45 44 43 42 40
|
94
library/Metier/sphinx/criteresFonc.php
Normal file
94
library/Metier/sphinx/criteresFonc.php
Normal file
@ -0,0 +1,94 @@
|
||||
<?php
|
||||
// --------------------------------------------------------------------------- //
|
||||
// Fonctions sur les criteres
|
||||
// --------------------------------------------------------------------------- //
|
||||
if (defined('DEBUG') == false) {
|
||||
define( 'DEBUG', 0);
|
||||
}
|
||||
if (defined('LOCAL') == false) {
|
||||
define( 'LOCAL', 0);
|
||||
}
|
||||
|
||||
if (LOCAL) {
|
||||
require_once('../sphinx/api/sphinxapi.php');
|
||||
} else {
|
||||
require_once 'Metier/sphinx/sphinxapi.php';
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------- //
|
||||
// Nouvelle sequence
|
||||
// --------------------------------------------------------------------------- //
|
||||
function nouvelleSequence(&$criteres)
|
||||
{
|
||||
if (LOCAL == true) {
|
||||
$crit2seq = file('crit2seq.prn');
|
||||
} else {
|
||||
$crit2seq = file(realpath(dirname(__FILE__)).'/crit2seq.prn');
|
||||
}
|
||||
foreach ($crit2seq as $ligne) {
|
||||
if (($pos = strpos($ligne, ';')) != false) {
|
||||
$ligne = substr($ligne, 0, $pos);
|
||||
}
|
||||
if (strstr(substr($ligne, 2, 10), $criteres) != false) {
|
||||
return str_split(substr($ligne, 13, -1), 3);
|
||||
}
|
||||
}
|
||||
return array();
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------- //
|
||||
// Nouvelle combinaison
|
||||
// --------------------------------------------------------------------------- //
|
||||
function nouvelleCombinaison(&$sequence, &$sequencePos, $pass, &$index, &$mode)
|
||||
{
|
||||
for (;;) {
|
||||
if (isset($sequence[$sequencePos]) == false) {
|
||||
return '';
|
||||
}
|
||||
$combinaison = trim($sequence[$sequencePos]);
|
||||
++$sequencePos;
|
||||
|
||||
if (strlen($combinaison) == 2) {
|
||||
return $combinaison;
|
||||
}
|
||||
|
||||
// Passage en phonetique ou en orthographique
|
||||
if (strlen($combinaison) == 3) {
|
||||
if ($pass == 2 ||
|
||||
$pass == 3) {
|
||||
continue;
|
||||
}
|
||||
$car = strtolower(substr($combinaison, 2, 1));
|
||||
switch($car) {
|
||||
case 'p':
|
||||
$index = 'ent_phx';
|
||||
$mode = SPH_MATCH_EXTENDED2;
|
||||
break;
|
||||
case 'o':
|
||||
$index = 'ent_mns';
|
||||
$mode = SPH_MATCH_ISPELL;
|
||||
break;
|
||||
default:
|
||||
debugln("attention: mode inconnu: '$car'");
|
||||
}
|
||||
} else if ($pass == 1) {
|
||||
$index = 'ent_mns';
|
||||
}
|
||||
|
||||
return $combinaison;
|
||||
}
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------- //
|
||||
// Nouveaux criteres
|
||||
// --------------------------------------------------------------------------- //
|
||||
function nouveauxCriteres(&$comb2crit, &$combinaison)
|
||||
{
|
||||
foreach ($comb2crit as $ligne) {
|
||||
if (strstr($ligne, $combinaison) != false) {
|
||||
return substr($ligne, 3, -1);
|
||||
}
|
||||
}
|
||||
return '';
|
||||
}
|
||||
?>
|
338
library/Metier/sphinx/recherche.php
Normal file
338
library/Metier/sphinx/recherche.php
Normal file
@ -0,0 +1,338 @@
|
||||
<?php
|
||||
// --------------------------------------------------------------------------- //
|
||||
// Formulaire de recherche Sphinx
|
||||
// --------------------------------------------------------------------------- //
|
||||
define('DEBUG', 1);
|
||||
define('LOCAL', 0);
|
||||
define('NBREP', 25);
|
||||
|
||||
include_once('/var/www/includes/config.php');
|
||||
require_once('rechercheFonc.php');
|
||||
|
||||
$vue = $_GET['vue'];
|
||||
if (isset($_POST['formR']) == true) {
|
||||
$formR = $_POST['formR'];
|
||||
} else {
|
||||
$formR = array('type' => $vue);
|
||||
}
|
||||
if (isset($_GET['deb']) == true) {
|
||||
$deb = $_GET['deb'];
|
||||
} else {
|
||||
$deb = 0;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------- //
|
||||
// Affiche un champs dans le formulaire
|
||||
// --------------------------------------------------------------------------- //
|
||||
function afficheChamps(&$form, $nomForm, $nom, $size, $maxlength, $extra = '')
|
||||
{
|
||||
print '<input type="text" name="'.$nomForm.'['.$nom.']" size="'.$size.
|
||||
'" maxlength="'.$maxlength.'" '.$extra;
|
||||
if (empty($form[$nom]) == false) {
|
||||
$valeur = str_replace('"', '"', $form[$nom]);
|
||||
print ' value="'.$valeur.'"';
|
||||
}
|
||||
print ' />';
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------- //
|
||||
// Affiche un libelle dans le formulaire
|
||||
// --------------------------------------------------------------------------- //
|
||||
function afficheLibelle($nom)
|
||||
{
|
||||
print '<td width="208" align="right" class="StyleRechercheLib"><b>'.
|
||||
$nom.'</b></td>';
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
||||
<title>Extranet Scores & Décisions - Recherche</title>
|
||||
|
||||
<script language="javascript">
|
||||
var http = null;
|
||||
if (window.XMLHttpRequest) {
|
||||
// Firefox
|
||||
http = new XMLHttpRequest();
|
||||
} else if (window.ActiveXObject) {
|
||||
// Internet Explorer
|
||||
http = new ActiveXObject("Microsoft.XMLHTTP");
|
||||
} else {
|
||||
alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest.");
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------- //
|
||||
// selectCompletion
|
||||
// --------------------------------------------------------------------------- //
|
||||
function selectCompletion()
|
||||
{
|
||||
if (http == null) {
|
||||
return;
|
||||
}
|
||||
val = document.completion_form.completion_text.value;
|
||||
if (val.length >= 3) {
|
||||
http.open("GET", "cpVilles.php?&val=" + escape(val), true);
|
||||
http.onreadystatechange = selectVilles;
|
||||
http.send(null);
|
||||
} else {
|
||||
var sel = document.completion_form.completion_select;
|
||||
sel.style.display = 'none';
|
||||
}
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------- //
|
||||
// selectVilles
|
||||
// --------------------------------------------------------------------------- //
|
||||
function selectVilles()
|
||||
{
|
||||
if (http.readyState == 4) {
|
||||
villes = eval('(' + http.responseText + ')'); // [id1,id2, ...]
|
||||
|
||||
var sel = document.completion_form.completion_select;
|
||||
if (villes.length <= 10) {
|
||||
sel.attributes['size'].value = villes.length;
|
||||
} else {
|
||||
sel.attributes['size'].value = 10;
|
||||
}
|
||||
|
||||
while (sel.options.length > 0) {
|
||||
sel.options[0] = null;
|
||||
}
|
||||
for (i = 0; i < villes.length; ++i) {
|
||||
sel.options[sel.options.length] = new Option(villes[i], villes[i]);
|
||||
}
|
||||
|
||||
if (sel.options.length) {
|
||||
sel.style.display = 'block';
|
||||
} else {
|
||||
sel.style.display = 'none';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------- //
|
||||
// selectClic
|
||||
// --------------------------------------------------------------------------- //
|
||||
function selectClic()
|
||||
{
|
||||
var sel = document.completion_form.completion_select ;
|
||||
document.completion_form.completion_text.value =
|
||||
sel.options[sel.selectedIndex].value ;
|
||||
sel.style.display = 'none';
|
||||
}
|
||||
</script>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<form method="post" name="completion_form">
|
||||
|
||||
<table cellpadding="0" cellspacing="0">
|
||||
<tr>
|
||||
<td valign="top" width="580" height="200" align="center">
|
||||
|
||||
<?php
|
||||
if ($vue == 'ent') {
|
||||
?>
|
||||
|
||||
<input type="hidden" name="formR[type]" value="ent" />
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<td align="center">
|
||||
<h2>RECHERCHE ENTREPRISE V2</h2>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<?php afficheLibelle('SIREN'); ?>
|
||||
<td width="300" align="left">
|
||||
<?php afficheChamps($formR, 'formR', 'siret', 25, 20,
|
||||
'style=vertical-align:middle;'); ?>
|
||||
</td>
|
||||
<td width="72"> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<?php afficheLibelle('RAISON SOCIALE<br/>ENSEIGNE / SIGLE'); ?>
|
||||
<td width="300" align="left">
|
||||
<?php afficheChamps($formR, 'formR', 'raisonSociale', 25, 250); ?>
|
||||
</td>
|
||||
<td width="72"> </td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<br/>
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<?php afficheLibelle('N° & VOIE'); ?>
|
||||
<td width="300" align="left">
|
||||
<?php afficheChamps($formR, 'formR', 'numVoie', 4, 4); ?>
|
||||
<?php afficheChamps($formR, 'formR', 'voie', 17, 250); ?>
|
||||
</td>
|
||||
<td width="72"> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<?php afficheLibelle('CP OU DÉP. / VILLE'); ?>
|
||||
<td width="300" align="left">
|
||||
<?php afficheChamps($formR, 'formR', 'cpVille', 25, 250,
|
||||
'onkeyup="selectCompletion();"'.
|
||||
' id="completion_text"'); ?>
|
||||
</td>
|
||||
<td width="72"> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td width="208"> </td>
|
||||
<td width="300" align="left">
|
||||
<select id="completion_select"
|
||||
size="1"
|
||||
onclick="selectClic();"
|
||||
style="display:none;">
|
||||
</select>
|
||||
</td>
|
||||
<td width="72"> </td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<br/>
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<?php afficheLibelle('TÉL / FAX'); ?>
|
||||
<td width="300" align="left">
|
||||
<?php afficheChamps($formR, 'formR', 'telFax', 15, 15); ?>
|
||||
</td>
|
||||
<td width="72"> </td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<?php afficheLibelle('NAF'); ?>
|
||||
<td width="300" align="left">
|
||||
<?php afficheChamps($formR, 'formR', 'naf', 15, 666); ?>
|
||||
</td>
|
||||
<td width="72"> </td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<?php
|
||||
} else if ($vue == 'dir') {
|
||||
?>
|
||||
|
||||
<input type="hidden" name="formR[type]" value="dir" />
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<td align="center">
|
||||
<h2>RECHERCHE PAR DIRIGEANT V2</h2>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<?php afficheLibelle('NOM'); ?>
|
||||
<td width="300" align="left">
|
||||
<?php afficheChamps($formR, 'formR', 'nom', 25, 40,
|
||||
'style=vertical-align:middle;'); ?>
|
||||
</td>
|
||||
<td width="72"> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<?php afficheLibelle('PRENOM'); ?>
|
||||
<td width="300" align="left">
|
||||
<?php afficheChamps($formR, 'formR', 'prenom', 25, 40); ?>
|
||||
</td>
|
||||
<td width="72"> </td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<br/>
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<?php afficheLibelle('DATE NAISSANCE'); ?>
|
||||
<td width="300" align="left">
|
||||
<?php afficheChamps($formR, 'formR', 'dirDateNaissJJ', 2, 2); ?>/
|
||||
<?php afficheChamps($formR, 'formR', 'dirDateNaissMM', 2, 2); ?>/
|
||||
<?php afficheChamps($formR, 'formR', 'dirDateNaissAAAA', 4, 4); ?>
|
||||
</td>
|
||||
<td width="72"> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<?php afficheLibelle('CP OU DÉP. / VILLE DE NAISSANCE'); ?>
|
||||
<td width="300" align="left">
|
||||
<?php afficheChamps($formR, 'formR', 'cpVille', 25, 40,
|
||||
'onkeyup="selectCompletion();"'.
|
||||
' id="completion_text"'); ?>
|
||||
</td>
|
||||
<td width="72"> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td width="208"> </td>
|
||||
<td width="300" align="left">
|
||||
<select id="completion_select"
|
||||
size="1"
|
||||
onclick="selectClic();"
|
||||
style="display:none;">
|
||||
</select>
|
||||
</td>
|
||||
<td width="72"> </td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<table width="580">
|
||||
<tr>
|
||||
<td align="center" valign="top">
|
||||
<input type="submit" value="Envoyer" />
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
</form>
|
||||
|
||||
<?php
|
||||
if (count($formR) > 1) {
|
||||
print '<form method="post" action="?vue='.$vue.'&deb='.($deb + NBREP).'">';
|
||||
foreach ($formR as $label => $valeur) {
|
||||
print '<input type="hidden" name="formR['.$label.']"'.
|
||||
'value="'.$valeur.'" />';
|
||||
}
|
||||
print '<input type="submit" value="Suite" />';
|
||||
print '</form>';
|
||||
}
|
||||
|
||||
if (empty($formR['siret']) == false) {
|
||||
$liste = verificationDuSiret($formR['siret']);
|
||||
if (DEBUG && $liste != false) {
|
||||
print 'Essayez :<br/>';
|
||||
foreach ($liste as $s) {
|
||||
if (sommeDeControle($s) != 0) {
|
||||
print 'erreur somme de controle sur '.$s.
|
||||
' ('.sommeDeControle($s).')<br/>';
|
||||
} else {
|
||||
print $s.'<br/>';
|
||||
}
|
||||
}
|
||||
// TODO: utilisation de la liste
|
||||
exit;
|
||||
}
|
||||
}
|
||||
recherche($formR, $deb, NBREP);
|
||||
?>
|
||||
|
||||
</body>
|
||||
</html>
|
260
library/Metier/sphinx/recherche2.php
Normal file
260
library/Metier/sphinx/recherche2.php
Normal file
@ -0,0 +1,260 @@
|
||||
<?php
|
||||
require_once 'framework/common/strings.php';
|
||||
require_once realpath(dirname(__FILE__)).'/sphinxapi2.php';
|
||||
|
||||
function search2($index, $findMe, $tabFiltres=array(), $deb=0, $nbRep=20, $max=200, $any=false) {
|
||||
$deb=$deb*1;
|
||||
$nbRep=$nbRep*1;
|
||||
$max=$max*1;
|
||||
|
||||
debugLog('I',"Search Sphinx dans $index de $findMe ($deb, $nbRep, $max) avec ".implode(',',$tabFiltres),__LINE__,__FILE__, __FUNCTION__, __CLASS__);
|
||||
|
||||
$iDb=new WDB();
|
||||
|
||||
//$any = false; // si false $index='xxx'
|
||||
$cl = new SphinxClient2();
|
||||
if ($index == 'histo'){
|
||||
$cl->SetServer (SPHINX_HISTO_HOST, SPHINX_HISTO_PORT);
|
||||
} else {
|
||||
$cl->SetServer (SPHINX_HOST, SPHINX_PORT);
|
||||
}
|
||||
$cl->SetConnectTimeout ( 1 );
|
||||
$cl->SetLimits ($deb, $nbRep, $max);//0, $nbRep*10);
|
||||
//$cl->SetSortMode(SPH_SORT_ATTR_DESC, 'actif');//siege');
|
||||
if (substr($index,0,4)=='etab')
|
||||
$cl->SetSortMode(SPH_SORT_EXTENDED, 'rang DESC, actif DESC, siege DESC');//, nic DESC
|
||||
|
||||
//$cl->SetWeights ( array ( 100, 1 ) );
|
||||
//$cl->SetMatchMode ( $any ? SPH_MATCH_ANY : SPH_MATCH_ALL );
|
||||
$cl->SetMatchMode (SPH_MATCH_EXTENDED);
|
||||
foreach ($tabFiltres as $nomFiltre => $valFiltre)
|
||||
$cl->SetFilter($nomFiltre, array(0=>$valFiltre));
|
||||
|
||||
$cl->SetRankingMode ( SPH_RANK_PROXIMITY_BM25 );
|
||||
//$cl->SetArrayResult ( true );
|
||||
|
||||
$res = $cl->Query ( $findMe, $index );
|
||||
//@sendMail('production@scores-decisions.com', 'ylenaour@scores-decisions.com', "Debug", print_r($res,true)) ;
|
||||
if ($res===false) {
|
||||
debugLog('I',"Search Sphinx : Pas de réponse pour $findMe avec ".implode(',',$tabFiltres).' ('.$cl->GetLastError() .')',__LINE__,__FILE__, __FUNCTION__, __CLASS__);
|
||||
return array( 'results'=>false,
|
||||
'nbRet'=>0,
|
||||
'nbTot'=>0,
|
||||
'error'=>$cl->GetLastError(),
|
||||
'warning'=>$cl->GetLastWarning(),
|
||||
'duration'=>$res[time]);//return false;
|
||||
|
||||
} else { // Le moteur est op<6F>rationel
|
||||
if ( $cl->GetLastWarning() ) {
|
||||
debugLog('I',"Search Sphinx : Warning pour $findMe - ".$cl->GetLastWarning(),__LINE__,__FILE__, __FUNCTION__, __CLASS__);
|
||||
print "WARNING: " . $cl->GetLastWarning() . "\n\n";
|
||||
}
|
||||
/* print "Query '$findMe' retrieved $res[total] of $res[total_found] matches in $res[time] sec.\n";
|
||||
print "Query stats :\n";
|
||||
if ( is_array($res["words"]) )
|
||||
foreach ( $res["words"] as $word => $info )
|
||||
print " - '$word' found $info[hits] times in $info[docs] documents\n";
|
||||
print "\n";*/
|
||||
debugLog('I',"'Search Sphinx dans $index de $findMe (Filtre=".implode(',',$tabFiltres)."), Deb=$deb, nbRep=$nbRep, max=$max, any=$any",__LINE__,__FILE__, __FUNCTION__, __CLASS__);
|
||||
// debugLog('I',"Search Sphinx dans $index ". print_r($tabFiltres, true));
|
||||
|
||||
$tabRet=array();
|
||||
if ( @is_array($res['matches'])) { // il y a des donn<6E>es <20> renvoyer
|
||||
if (substr($index,0,4)=='etab') { // Recherche par <20>tab
|
||||
foreach ( $res['matches'] as $doc => $docinfo ) { // On balaye chaque ligne
|
||||
$listeEtab=$iDb->select('etablissements e',
|
||||
"'Etab' as Loc, e.id, e.source, e.source_id, e.triCode, e.autre_id, e.siren, e.nic, e.siege, ".
|
||||
"e.raisonSociale, e.enseigne, e.sigle, e.adr_num, e.adr_btq, e.adr_typeVoie, e.adr_libVoie, ".
|
||||
"e.adr_comp, e.adr_cp, e.adr_ville, e.tel, e.fax, e.cj, e.ape_etab, e.ape_entrep, ".
|
||||
"CONCAT(e.siren, e.nic) as siret, e.actif",
|
||||
"id=$doc LIMIT 0,1", true);
|
||||
$etab=$listeEtab[0];
|
||||
$tabRet[]=array( 'Localisation'=>$etab['Loc'],
|
||||
'id'=>$doc,
|
||||
'Pertinence'=>$docinfo['weight'],
|
||||
'Siret'=>$etab['siret'],
|
||||
'Siege'=>$etab['siege'],
|
||||
'Nom'=>$etab['raisonSociale'],
|
||||
'Sigle'=>$etab['sigle'],
|
||||
'Enseigne'=>$etab['enseigne'],
|
||||
'Adresse'=>trim($etab['adr_num'] .' '.
|
||||
$etab['adr_btq'] .' '.
|
||||
$etab['adr_typeVoie'] .' '.
|
||||
$etab['adr_libVoie'] .' '.
|
||||
$etab['adr_comp']),
|
||||
'CP'=>$etab['adr_cp'],
|
||||
'Ville'=>$etab['adr_ville'],
|
||||
'Tel'=>$etab['tel'],
|
||||
'Fax'=>$etab['fax'],
|
||||
'FJ'=>$etab['cj'],
|
||||
'Siren'=>$etab['siren'],
|
||||
'Nic'=>$etab['nic'],
|
||||
'Actif'=>$etab['actif'],
|
||||
'NafEtab'=>$etab['ape_etab'], // Etablissement
|
||||
//'NafEtabLib'=>$etab['LibNafEt'],
|
||||
'NafEnt'=>$etab['ape_entrep'], // Entreprise
|
||||
//'NafEntLib'=>$etab['LibNafEt'],
|
||||
);
|
||||
}
|
||||
} elseif ($index=='histo') {
|
||||
foreach ( $res['matches'] as $doc => $docinfo ) {
|
||||
$listeEtab=$iDb->select('histobodacc.bodacc_ocr',
|
||||
"'Histo' as Loc, id, nomFichier, annee1, bod, texte",
|
||||
"id=$doc");
|
||||
$etab=$listeEtab[0];
|
||||
$tabRet[]=array( 'Localisation'=>$etab['Loc'],
|
||||
'id'=>$doc,
|
||||
'Pertinence'=>$docinfo['weight'],
|
||||
'Fichier'=>$etab['nomFichier'],
|
||||
'Annee'=>$etab['annee1'],
|
||||
'Code'=>$etab['bod'],
|
||||
'Texte'=>$etab['texte'],
|
||||
);
|
||||
}
|
||||
} else { // Recherche par dirigeant
|
||||
$findMe4=trim(substr($findMe,0,4));
|
||||
foreach ( $res['matches'] as $doc => $docinfo ) { // On balaye chaque ligne dirigeant
|
||||
$listeEtab=$iDb->select('rncs_dirigeants d, etablissements e',
|
||||
"'Etab' as Loc, e.id, e.source, e.source_id, e.triCode, e.autre_id, e.siren, e.nic, e.siege, ".
|
||||
"e.raisonSociale, e.enseigne, e.sigle, e.adr_num, e.adr_btq, e.adr_typeVoie, e.adr_libVoie, ".
|
||||
"e.adr_comp, e.adr_cp, e.adr_ville, e.tel, e.fax, e.cj, e.ape_etab, e.ape_entrep, ".
|
||||
"CONCAT(e.siren, e.nic) as siret, /*d.rs,*/ d.nom, d.prenom, /*d.nomUsage,*/ d.naissance_date, d.naissance_lieu, ".
|
||||
"d.fonction_lib, /*d.depart,*/ e.actif",
|
||||
"d.id=$doc AND d.siren=e.siren AND e.siege=1 ORDER BY e.actif DESC LIMIT 0,1", true);
|
||||
//die(print_r($listeEtab));
|
||||
$etab=$listeEtab[0];
|
||||
$tabRet[]=array( 'Localisation'=>$etab['Loc'],
|
||||
'id'=>$doc,
|
||||
'Pertinence'=>$docinfo['weight'],
|
||||
'Siret'=>$etab['siret'],
|
||||
'Siege'=>$etab['siege'],
|
||||
'Nom'=>$etab['raisonSociale'],
|
||||
'Sigle'=>$etab['sigle'],
|
||||
'Enseigne'=>$etab['enseigne'],
|
||||
'Adresse'=>trim($etab['adr_num'] .' '.
|
||||
$etab['adr_btq'] .' '.
|
||||
$etab['adr_typeVoie'] .' '.
|
||||
$etab['adr_libVoie'] .' '.
|
||||
$etab['adr_comp']),
|
||||
'CP'=>$etab['adr_cp'],
|
||||
'Ville'=>$etab['adr_ville'],
|
||||
'Tel'=>$etab['tel'],
|
||||
'Fax'=>$etab['fax'],
|
||||
'FJ'=>$etab['cj'],
|
||||
'Siren'=>$etab['siren'],
|
||||
'Nic'=>$etab['nic'],
|
||||
'Actif'=>$etab['actif'],
|
||||
'NafEtab'=>$etab['ape_etab'], // Etablissement
|
||||
'NafEnt'=>$etab['ape_entrep'], // Entreprise
|
||||
'rs'=>'',//$etab['rs'],
|
||||
'nomD'=>$etab['nom'],
|
||||
'prenom'=>$etab['prenom'],
|
||||
'nomUsage'=>'',//$etab['nomUsage'],
|
||||
'dateEffet'=>'',//$etab['dateEffet'],
|
||||
'fonction'=>$etab['fonction_lib'],
|
||||
'depart'=>0,//$etab['depart'],
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
debugLog('I','Search Sphinx : Retourne '. $res[total].'/'. $res[total_found] .' en '.$res[time] .'secondes',__LINE__,__FILE__, __FUNCTION__, __CLASS__);
|
||||
return array( 'results'=>$tabRet,
|
||||
'nbRet'=>$res[total],
|
||||
'nbTot'=>$res[total_found],
|
||||
'duration'=>$res[time],
|
||||
'words'=>$res['words'],
|
||||
);
|
||||
}
|
||||
|
||||
/*
|
||||
<nafen>7020z<
|
||||
|
||||
*/
|
||||
function comptage($findMe, $tabFiltres=array(), $deb=0, $nbRep=20, $max=1000, $any=false, $fichierCsv=false) {
|
||||
$deb=$deb*1;
|
||||
$nbRep=$nbRep*1;
|
||||
$max=$max*1;
|
||||
$index='comptage';
|
||||
$iDb=new WDB();
|
||||
/*
|
||||
$cl = new SphinxClient ();
|
||||
$cl->SetServer ( $host, $port );
|
||||
$cl->SetWeights ( array ( 100, 1 ) );
|
||||
$cl->SetMatchMode ( $mode );
|
||||
if ( count($filtervals) ) $cl->SetFilter ( $filter, $filtervals );
|
||||
if ( $groupby ) $cl->SetGroupBy ( $groupby, SPH_GROUPBY_ATTR, $groupsort );
|
||||
if ( $sortby ) $cl->SetSortMode ( SPH_SORT_EXTENDED, $sortby );
|
||||
if ( $sortexpr ) $cl->SetSortMode ( SPH_SORT_EXPR, $sortexpr );
|
||||
if ( $distinct ) $cl->SetGroupDistinct ( $distinct );
|
||||
if ( $limit ) $cl->SetLimits ( 0, $limit, ( $limit>1000 ) ? $limit : 1000 );
|
||||
$res = $cl->Query ( $q, $index );
|
||||
*/
|
||||
$cl = new SphinxClient ();
|
||||
$cl->SetServer ('192.168.3.24', 3312);
|
||||
$cl->SetConnectTimeout(1);
|
||||
$cl->SetLimits ($deb, $nbRep, $max);
|
||||
// if (substr($index,0,4)=='etab')
|
||||
// $cl->SetSortMode(SPH_SORT_EXTENDED, 'rang DESC, actif DESC, siege DESC');//, nic DESC
|
||||
//$cl->SetWeights ( array ( 100, 1 ) );
|
||||
//$cl->SetMatchMode ( $any ? SPH_MATCH_ANY : SPH_MATCH_ALL );
|
||||
$cl->SetMatchMode (SPH_MATCH_EXTENDED);
|
||||
foreach ($tabFiltres as $nomFiltre => $valFiltre)
|
||||
$cl->SetFilter($nomFiltre, $valFiltre);
|
||||
/*8.4.3. SetFilterRange
|
||||
Prototype: function SetFilterRange ( $attribute, $min, $max, $exclude=false )
|
||||
Adds new integer range filter. */
|
||||
|
||||
$cl->SetRankingMode ( SPH_RANK_PROXIMITY_BM25 );
|
||||
//$cl->SetArrayResult ( true );
|
||||
|
||||
$res = $cl->Query ( $findMe, $index );
|
||||
if ($res===false) {
|
||||
// debugLog('I',"Search Sphinx : Pas de r<>ponse pour $findMe avec ".implode(',',$tabFiltres).' ('.$cl->GetLastError() .')',__LINE__,__FILE__, __FUNCTION__, __CLASS__);
|
||||
return array( 'results'=>false,
|
||||
'nbRet'=>0,
|
||||
'nbTot'=>0,
|
||||
'error'=>$cl->GetLastError(),
|
||||
'warning'=>$cl->GetLastWarning(),
|
||||
'durationCpt'=>$res[time],
|
||||
'durationExp'=>0);//return false;);//return false;
|
||||
|
||||
} else { // Le moteur est op<6F>rationel
|
||||
$tdeb=microtime(1);
|
||||
if ( $cl->GetLastWarning() ) {
|
||||
//debugLog('I',"Search Sphinx : Warning pour $findMe - ".$cl->GetLastWarning(),__LINE__,__FILE__, __FUNCTION__, __CLASS__);
|
||||
print "WARNING: " . $cl->GetLastWarning() . "\n\n";
|
||||
}
|
||||
|
||||
$tabRet=array();
|
||||
if ( @is_array($res['matches'])) { // il y a des donn<6E>es <20> renvoyer
|
||||
$tabIdDoc=array();
|
||||
foreach ( $res['matches'] as $doc => $docinfo ) //{ // On balaye chaque ligne
|
||||
$tabIdDoc[]=$doc;
|
||||
$strDoc='('.implode(',',$tabIdDoc).')';
|
||||
$tabTmp=$iDb->select( 'etablissements_act',
|
||||
'id,ape_etab,ape_entrep,source,siren,nic,actif,siege,adr_cp,adr_dep,adr_com,tel,fax,cj,capital,age_entrep,age_etab,tca,tcaexp,teff_entrep,teff_etab,rang,dateCrea_etab,eff_entrep,eff_etab,nbEtab,bilType,bilAnnee,bilTca,bilCA,bilCAexp,bilRN',
|
||||
"id IN $strDoc", false, MYSQL_ASSOC);
|
||||
if ($fichierCsv) {
|
||||
$fp=fopen($fichierCsv, 'w');
|
||||
foreach ($tabTmp as $iTmp=>$tmp) {
|
||||
$tabRet[]=$tmp;
|
||||
fwrite($fp, implode("\t", $tmp).EOL);
|
||||
}
|
||||
fclose($fp);
|
||||
}
|
||||
}
|
||||
}
|
||||
return array( 'results'=>$tabRet,
|
||||
'nbRet'=>$res[total],
|
||||
'nbTot'=>$res[total_found],
|
||||
'durationCpt'=>$res[time],
|
||||
'durationExp'=>round(microtime(1)-$tdeb,3),
|
||||
'error'=>$cl->GetLastError(),
|
||||
'warning'=>$cl->GetLastWarning(),
|
||||
'words'=>$res['words'],
|
||||
);
|
||||
}
|
||||
|
||||
?>
|
1600
library/Metier/sphinx/rechercheFonc.php
Normal file
1600
library/Metier/sphinx/rechercheFonc.php
Normal file
File diff suppressed because it is too large
Load Diff
171
library/Metier/sphinx/rechercheTest.php
Normal file
171
library/Metier/sphinx/rechercheTest.php
Normal file
@ -0,0 +1,171 @@
|
||||
<?php
|
||||
// --------------------------------------------------------------------------- //
|
||||
// Teste la recherche avec les criteres contenus dans un fichier
|
||||
// --------------------------------------------------------------------------- //
|
||||
define('LOCAL', 1);
|
||||
|
||||
if (isset($_GET['fichier']) == true) {
|
||||
$fichier = $_GET['fichier'];
|
||||
} else {
|
||||
$fichier = 'nontrouves.txt';
|
||||
}
|
||||
if (isset($_GET['num']) == true) {
|
||||
define('DEBUG', 1);
|
||||
$num = $_GET['num'];
|
||||
} else {
|
||||
define('DEBUG', 0);
|
||||
$num = '';
|
||||
}
|
||||
if (isset($_GET['page']) == true) {
|
||||
$page = intval($_GET['page']);
|
||||
} else {
|
||||
$page = 1;
|
||||
}
|
||||
require_once('rechercheFonc.php');
|
||||
|
||||
function rechercheTest($fichierLog, $num, $page)
|
||||
{
|
||||
$NB_PAR_PAGE = 40;
|
||||
$crit2form = array('S' => 'raisonSociale',
|
||||
'N' => 'numVoie',
|
||||
'R' => 'voie',
|
||||
'L' => 'cpVille',
|
||||
'V' => 'cpVille');
|
||||
|
||||
$liste = file($fichierLog);
|
||||
if ($num != '') {
|
||||
$n = intval($num);
|
||||
$indices = array($n);
|
||||
} else {
|
||||
$n = ($page - 1) * $NB_PAR_PAGE;
|
||||
$indices = range($n, min($n + $NB_PAR_PAGE - 1, count($liste) - 1));
|
||||
}
|
||||
foreach ($indices as $i) {
|
||||
$ligne = explode('#', $liste[$i], 2);
|
||||
++$n;
|
||||
$formR = array();
|
||||
$criteres = explode(',', $ligne[0]);
|
||||
unset($nb_rep);
|
||||
$siret = '';
|
||||
// Nombre de resultats et siret
|
||||
foreach ($criteres as $c) {
|
||||
$labelvaleur = explode('=', $c);
|
||||
$label = trim($labelvaleur[0]);
|
||||
if ($label == 'NbRep' && isset($labelvaleur[1]) == true) {
|
||||
$nb_rep = intval(trim($labelvaleur[1]));
|
||||
}
|
||||
if ($label == 'SiretTrouve' && isset($labelvaleur[1]) == true) {
|
||||
$siret = trim($labelvaleur[1]);
|
||||
}
|
||||
}
|
||||
// Restrictions
|
||||
if (isset($nb_rep) == false || $nb_rep != 1 || $siret == '') {
|
||||
//continue;
|
||||
}
|
||||
// Criteres
|
||||
foreach ($criteres as $c) {
|
||||
$labelvaleur = explode('=', $c, 2);
|
||||
$label = trim($labelvaleur[0]);
|
||||
if (isset($labelvaleur[1]) == false) {
|
||||
continue;
|
||||
}
|
||||
$valeur = trim($labelvaleur[1]);
|
||||
if (isset($crit2form[$label]) == false) {
|
||||
continue;
|
||||
}
|
||||
if ($label == 'R' &&
|
||||
preg_match('/[0-9]+/', $valeur, $arrayValeur) > 0) {
|
||||
$formR['numVoie'] = $arrayValeur[0];
|
||||
$valeur = str_replace($arrayValeur[0].' ', '', $valeur);
|
||||
print 'N='.$arrayValeur[0].', ';
|
||||
}
|
||||
if (isset($formR[$crit2form[$label]]) == false) {
|
||||
$formR[$crit2form[$label]] = $valeur;
|
||||
} else {
|
||||
$formR[$crit2form[$label]] .= ' '.$valeur;
|
||||
}
|
||||
print $label.'='.$valeur.', ';
|
||||
}
|
||||
// Recherche
|
||||
$formR['type'] = 'ent';
|
||||
$res = recherche($formR, 0, 100);
|
||||
$total = 0;
|
||||
$siren = 0;
|
||||
$nic = 0;
|
||||
$resSiret = '00000000000000';
|
||||
if (isset($res['nbReponsesTotal'])) {
|
||||
$total = $res['nbReponsesTotal'];
|
||||
if ($total == 1) {
|
||||
$siren = $res['reponses'][0]['Siren'];
|
||||
$nic = $res['reponses'][0]['Nic'];
|
||||
$resSiret = sprintf("%09d%05d", $siren, $nic);
|
||||
} else if (isset($nb_rep) != false &&
|
||||
($nb_rep < $total) &&
|
||||
($nb_rep == 10 ||
|
||||
$nb_rep == 20)) {
|
||||
$total = $nb_rep;
|
||||
}
|
||||
}
|
||||
if ($siret != '') {
|
||||
if ($siret != '00000000000000' &&
|
||||
$siret != $resSiret) {
|
||||
print '<font color=#FF0000>'.$siret.' </font>';
|
||||
} else {
|
||||
print $siret.' ';
|
||||
}
|
||||
print $resSiret.' ';
|
||||
}
|
||||
if (($siret != '' &&
|
||||
$siret != '00000000000000' &&
|
||||
$siret != $resSiret) ||
|
||||
(isset($nb_rep) != false &&
|
||||
$nb_rep != 0 &&
|
||||
$nb_rep != $total) ||
|
||||
(isset($nb_rep) == false &&
|
||||
$total == 0)) {
|
||||
print '<font color=#FF0000>pass'.$res['pass'].' </font>';
|
||||
} else {
|
||||
print '<font color=#00FF00>pass'.$res['pass'].' </font>';
|
||||
}
|
||||
if (isset($nb_rep) != false) {
|
||||
if ($nb_rep != 0 &&
|
||||
$nb_rep != $total) {
|
||||
print '<font color=#FF0000>'.$nb_rep.' </font>';
|
||||
} else {
|
||||
print $nb_rep;
|
||||
}
|
||||
}
|
||||
print ' <a href=?fichier='.$fichierLog.'&num='.($n-1).'>'.
|
||||
$total.'</a>';
|
||||
if (count($ligne) == 2) {
|
||||
print ' #'.$ligne[1];
|
||||
}
|
||||
print '<br/>';
|
||||
}
|
||||
if ($num == '') {
|
||||
print '<br/>pages: ';
|
||||
for ($p = 1; $p < $page; ++$p) {
|
||||
print '<a href=?fichier='.$fichierLog.
|
||||
'&page='.$p.'>'.$p.'</a> ';
|
||||
}
|
||||
print '<b>'.$page.'</b> ';
|
||||
for ($p = $page + 1; ($p - 1) * $NB_PAR_PAGE < count($liste); ++$p) {
|
||||
print '<a href=?fichier='.$fichierLog.
|
||||
'&page='.$p.'>'.$p.'</a> ';
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<?php
|
||||
rechercheTest($fichier, $num, $page);
|
||||
?>
|
||||
|
||||
</body>
|
||||
</html>
|
1628
library/Metier/sphinx/sphinxapi.php
Normal file
1628
library/Metier/sphinx/sphinxapi.php
Normal file
File diff suppressed because it is too large
Load Diff
1187
library/Metier/sphinx/sphinxapi2.php
Normal file
1187
library/Metier/sphinx/sphinxapi2.php
Normal file
File diff suppressed because it is too large
Load Diff
130
library/Metier/sphinx/sphinxsearch.php
Normal file
130
library/Metier/sphinx/sphinxsearch.php
Normal file
@ -0,0 +1,130 @@
|
||||
<?php
|
||||
require_once 'framework/common/strings.php';
|
||||
require_once realpath(dirname(__FILE__)).'/sphinxapi.php';
|
||||
|
||||
class SphinxCriteres
|
||||
{
|
||||
var $findMe = '';
|
||||
var $tabFiltres = array();
|
||||
var $position = 0;
|
||||
var $nbRep = 20;
|
||||
var $max = 200;
|
||||
var $any = false;
|
||||
}
|
||||
|
||||
class SphinxSearch
|
||||
{
|
||||
/**
|
||||
* Effectue une recherche en interrogeant le moteur Sphinx
|
||||
*
|
||||
* @param string $index
|
||||
* @param SphinxCriteres $criteres Critères de recherche
|
||||
* @return array $return Tableau des résultats
|
||||
*/
|
||||
public function search($index, $criteres)
|
||||
{
|
||||
debugLog('I',"Search Sphinx dans $name de ".$criteres->findMe." (".$criteres->deb.", ".$criteres->nbRep.", ".$criteres->max.") avec ".implode(',',$criteres->tabFiltres),__LINE__,__FILE__, __FUNCTION__, __CLASS__);
|
||||
$cl = new SphinxClient();
|
||||
switch (strtolower($index)) {
|
||||
case 'entrep':
|
||||
|
||||
|
||||
break;
|
||||
case 'dir':
|
||||
|
||||
|
||||
|
||||
break;
|
||||
case 'histo':
|
||||
$cl->SetServer (SPHINX_HISTO_HOST, SPHINX_HISTO_PORT);
|
||||
$cl->SetConnectTimeout ( 1 );
|
||||
$cl->SetLimits ($criteres->position, $criteres->nbRep, $criteres->max);
|
||||
$cl->SetMatchMode (SPH_MATCH_EXTENDED);
|
||||
foreach ($criteres->tabFiltres as $nomFiltre => $valFiltre) {
|
||||
$cl->SetFilter($nomFiltre, array(0=>$valFiltre));
|
||||
}
|
||||
$cl->SetRankingMode ( SPH_RANK_PROXIMITY_BM25 );
|
||||
$res = $cl->Query ( $criteres->findMe, 'histo' );
|
||||
if ($res===false) {
|
||||
//Erreur
|
||||
debugLog('I',"Search Sphinx : Pas de réponse pour ".$criteres->findMe." avec ".implode(',',$criteres->tabFiltres).' ('.$cl->GetLastError() .')',__LINE__,__FILE__, __FUNCTION__, __CLASS__);
|
||||
return array(
|
||||
'results' => false,
|
||||
'nbRet' => 0,
|
||||
'nbTot' => 0,
|
||||
'duration' => 0);
|
||||
} else {
|
||||
|
||||
if ( $cl->GetLastWarning() ) {
|
||||
debugLog('I',"Search Sphinx : Warning pour $criteres->findMe - ".$cl->GetLastWarning(),__LINE__,__FILE__, __FUNCTION__, __CLASS__);
|
||||
print "WARNING: " . $cl->GetLastWarning() . "\n\n";
|
||||
}
|
||||
|
||||
debugLog('I',"'Search Sphinx dans $index de $criteres->findMe (Filtre=".implode(',',$criteres->tabFiltres)."), Deb=".$criteres->position.", nbRep=".$criteres->nbRep.", max=".$criteres->max.", any=".$criteres->any,__LINE__,__FILE__, __FUNCTION__, __CLASS__);
|
||||
$tabRet = array();
|
||||
if ( is_array($res['matches'])) {
|
||||
$iDb = new WDB('histobodacc');
|
||||
$iDb->query("SET NAMES 'latin1';");
|
||||
foreach ( $res['matches'] as $doc => $docinfo ) {
|
||||
$listeEtab = $iDb->select(
|
||||
'bodacc_ocr',
|
||||
"'Histo' as Loc, id, nomFichier, annee1, bod, texte",
|
||||
"id=$doc");
|
||||
$etab = $listeEtab[0];
|
||||
$tabRet[] = array(
|
||||
'Localisation' => $etab['Loc'],
|
||||
'id' => $doc,
|
||||
'Pertinence' => $docinfo['weight'],
|
||||
'Fichier' => $etab['nomFichier'],
|
||||
'Annee' => $etab['annee1'],
|
||||
'Code' => $etab['bod'],
|
||||
'Texte' => $etab['texte'],
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
debugLog('I','Search Sphinx : Retourne '. $res[total].'/'. $res[total_found] .' en '.$res[time] .'secondes',__LINE__,__FILE__, __FUNCTION__, __CLASS__);
|
||||
return array(
|
||||
'results' => $tabRet,
|
||||
'nbRet' => $res[total],
|
||||
'nbTot' => $res[total_found],
|
||||
'duration' => $res[time],
|
||||
'words' => $res['words'],
|
||||
);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Méthode magique __call() permettant d'appeller une méthode virtuelle
|
||||
* du type searchByEnt(), searchByDir() ou searchByHisto()...
|
||||
*
|
||||
* @param string $method Nom de la méthode virtuelle appelée
|
||||
* @param array $args Tableau des critères de recherche
|
||||
* @return array|null $return Tableau des résultats ou NULL
|
||||
*/
|
||||
public function __call($method, $args)
|
||||
{
|
||||
if(preg_match('#^searchBy#i',$method))
|
||||
{
|
||||
$name = str_replace('searchBy','',$method);
|
||||
$criteres = array(
|
||||
0 => 'findMe',
|
||||
1 => 'tabFiltres',
|
||||
2 => 'position',
|
||||
3 => 'nbRep',
|
||||
4 => 'max',
|
||||
5 => 'any',
|
||||
);
|
||||
$searchArgs = new stdClass();
|
||||
$i = 0;
|
||||
foreach($args as $argument) {
|
||||
$searchArgs->{$criteres[$i]} = $argument;
|
||||
$i++;
|
||||
}
|
||||
return $this->search($name, $searchArgs);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user