Use new configuration file
This commit is contained in:
parent
d97d6f8fdf
commit
6f003be55b
@ -1,13 +1,30 @@
|
||||
<?php
|
||||
class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
|
||||
{
|
||||
//Initialisation global des paramètres de vue
|
||||
protected function _initConfig()
|
||||
{
|
||||
$config = new Zend_Config($this->getOptions());
|
||||
Zend_Registry::set('config', $config);
|
||||
|
||||
//Load old config
|
||||
require_once 'WsScore/Configure.php';
|
||||
$oldconfig = new Configure();
|
||||
|
||||
/*echo "<pre>";
|
||||
print_r(get_defined_constants(true));
|
||||
echo "</pre>";
|
||||
exit;*/
|
||||
|
||||
return $config;
|
||||
}
|
||||
|
||||
//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->doctype('HTML5');
|
||||
$view->headMeta()
|
||||
->appendHttpEquiv('Content-Type', 'text/html; charset=UTF-8')
|
||||
->appendHttpEquiv('Content-Language', 'fr-FR');
|
||||
@ -24,19 +41,9 @@ class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
|
||||
protected function _initLogging()
|
||||
{
|
||||
$WsLogger = new Zend_Log();
|
||||
$WsFileWriter = new Zend_Log_Writer_Stream(LOG_PATH.'/wsentreprise.log');
|
||||
$WsFileWriter = new Zend_Log_Writer_Stream($config->profil->path->log.'/wsentreprise.log');
|
||||
$WsFileWriter->addFilter(Zend_Log::INFO);
|
||||
$WsLogger->addWriter($WsFileWriter);
|
||||
if (APPLICATION_ENV == 'production')
|
||||
{
|
||||
$WsMail = new Zend_Mail();
|
||||
$WsMail->setFrom('production@scores-decisions.com')
|
||||
->addTo('mricois@scores-decisions.com');
|
||||
$WsMailWriter = new Zend_Log_Writer_Mail($WsMail);
|
||||
$WsMailWriter->setSubjectPrependText('ERREUR');
|
||||
$WsMailWriter->addFilter(Zend_Log::ERR);
|
||||
$WsLogger->addWriter($WsMailWriter);
|
||||
}
|
||||
Zend_Registry::set('WsLogger', $WsLogger);
|
||||
}
|
||||
|
||||
@ -123,6 +130,11 @@ class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
|
||||
));
|
||||
$router->addRoute('client', $route);
|
||||
|
||||
$fichierRoute = new Zend_Controller_Router_Route('fichier/:action/:fichier', array(
|
||||
'controller' => 'fichier',
|
||||
'fichier' => '',
|
||||
));
|
||||
$router->addRoute('fichier', $fichierRoute);
|
||||
return $router;
|
||||
}
|
||||
|
||||
|
@ -5,10 +5,7 @@ phpSettings.display_errors = 0
|
||||
bootstrap.path = APPLICATION_PATH "/Bootstrap.php"
|
||||
bootstrap.class = "Bootstrap"
|
||||
appnamespace = "Application"
|
||||
;resources.session.save_path = APPLICATION_PATH "/../cache/sessions"
|
||||
;resources.session.gc_maxlifetime = 86400
|
||||
;resources.session.cookie_lifetime = 86400
|
||||
;resources.session.remember_me_seconds = 86400
|
||||
resources.session.save_path = APPLICATION_PATH "/../data/sessions"
|
||||
resources.frontController.controllerDirectory = APPLICATION_PATH "/controllers"
|
||||
resources.frontController.plugins.Auth = "Application_Controller_Plugin_Auth"
|
||||
resources.frontController.params.displayExceptions = 0
|
||||
@ -19,10 +16,72 @@ autoloaderNamespaces[] = "Application_"
|
||||
autoloaderNamespaces[] = "Scores_"
|
||||
autoloaderNamespaces[] = "Form_"
|
||||
|
||||
; Scores configuration
|
||||
profil.server.name = development
|
||||
profil.mail.method = smtp
|
||||
profil.mail.smtp_host = smtp.free.fr
|
||||
profil.mail.email.support = supportdev@scores-decisions.com
|
||||
profil.mail.email.supportdev = supportdev@scores-decisions.com
|
||||
profil.mail.email.contact = supportdev@scores-decisions.com
|
||||
profil.mail.email.production = supportdev@scores-decisions.com
|
||||
profil.wkhtmltopdf.path = "c:\Users\mricois\www\data\wkhtml"
|
||||
profil.wkhtmltopdf.arch = "amd64"
|
||||
profil.path.batch = APPLICATION_PATH "/../scripts/jobs"
|
||||
profil.path.cache = APPLICATION_PATH "/../data/cache"
|
||||
profil.path.files = APPLICATION_PATH "/../data/files"
|
||||
profil.path.log = APPLICATION_PATH "/../data/log"
|
||||
profil.path.data = "c:\Users\mricois\www\dataws"
|
||||
profil.path.secure = "c:\Users\mricois\www\dataws"
|
||||
|
||||
profil.sphinx.ent.host = "192.168.78.252"
|
||||
profil.sphinx.ent.port = 3312
|
||||
profil.sphinx.ent.version = 2
|
||||
profil.sphinx.dir.host = "192.168.78.252"
|
||||
profil.sphinx.dir.port = 3312
|
||||
profil.sphinx.dir.version = 2
|
||||
profil.sphinx.act.host = "192.168.78.252"
|
||||
profil.sphinx.act.port = 3312
|
||||
profil.sphinx.act.version = 2
|
||||
profil.sphinx.histo.host = "192.168.78.252"
|
||||
profil.sphinx.histo.port = 3312
|
||||
profil.sphinx.histo.version = 2
|
||||
|
||||
; For old configuration - see WsScores/Configure.php
|
||||
profil.db.default.adapter=mysqli
|
||||
profil.db.default.params.host=192.168.78.230
|
||||
profil.db.default.params.username=root
|
||||
profil.db.default.params.password=scores
|
||||
profil.db.default.params.driver_options.MYSQLI_INIT_COMMAND = "SET NAMES utf8"
|
||||
|
||||
; Complete database configuration
|
||||
profil.db.sdv1.adapter=mysqli
|
||||
profil.db.sdv1.params.host=192.168.78.230
|
||||
profil.db.sdv1.params.username=wsuser
|
||||
profil.db.sdv1.params.password=scores
|
||||
profil.db.sdv1.params.dbname=sdv1
|
||||
profil.db.sdv1.params.driver_options.MYSQLI_INIT_COMMAND = "SET NAMES utf8"
|
||||
profil.db.sdv1.params.persistent = true
|
||||
|
||||
profil.db.jo.adapter=mysqli
|
||||
profil.db.jo.params.host=192.168.78.230
|
||||
profil.db.jo.params.username=wsuser
|
||||
profil.db.jo.params.password=scores
|
||||
profil.db.jo.params.dbname=jo
|
||||
profil.db.jo.params.driver_options.MYSQLI_INIT_COMMAND = "SET NAMES utf8"
|
||||
profil.db.jo.params.persistent = true
|
||||
|
||||
profil.db.historiques.adapter=mysqli
|
||||
profil.db.historiques.params.host=192.168.78.230
|
||||
profil.db.historiques.params.username=wsuser
|
||||
profil.db.historiques.params.password=scores
|
||||
profil.db.historiques.params.dbname=historiques
|
||||
profil.db.historiques.params.driver_options.MYSQLI_INIT_COMMAND = "SET NAMES utf8"
|
||||
profil.db.historiques.params.persistent = true
|
||||
|
||||
|
||||
[staging : production]
|
||||
resources.frontController.params.displayExceptions = 1
|
||||
|
||||
|
||||
[development : production]
|
||||
phpSettings.display_startup_errors = 1
|
||||
phpSettings.display_errors = 1
|
||||
|
@ -11,8 +11,8 @@ class FichierController extends Zend_Controller_Action
|
||||
{
|
||||
$auth = Zend_Auth::getInstance();
|
||||
if ( $auth->hasIdentity() ) {
|
||||
|
||||
$directory = realpath(DOC_WEB_LOCAL).'/bodacc';
|
||||
|
||||
$directory = '/mnt/bodacc';
|
||||
|
||||
$q = $this->getRequest()->getParam('q');
|
||||
$file = base64_decode($q);
|
||||
@ -55,5 +55,45 @@ class FichierController extends Zend_Controller_Action
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public function logsAction()
|
||||
{
|
||||
$file = $this->getRequest()->getParam('fichier');
|
||||
$content_type = 'application/csv-tab-delimited-table';
|
||||
$c = Zend_Registry::get('config');
|
||||
$path = realpath($c->profil->path->files).'/';
|
||||
//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);
|
||||
}
|
||||
}
|
||||
|
||||
public function kbisAction()
|
||||
{
|
||||
$file = $this->getRequest()->getParam('fichier');
|
||||
$content_type = 'application/csv-tab-delimited-table';
|
||||
$c = Zend_Registry::get('config');
|
||||
$path = realpath($c->profil->path->secure).'/kbis/';
|
||||
//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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -11,12 +11,12 @@ class Application_Controller_Plugin_Auth extends Zend_Controller_Plugin_Abstract
|
||||
{
|
||||
$checkAuth = true;
|
||||
//Pas d'authentification sur la demande d'authentification
|
||||
if ($request->getControllerName()=='user' && $request->getActionName()=='login'){
|
||||
if ($request->getControllerName()=='user' && $request->getActionName()=='login') {
|
||||
$checkAuth = false;
|
||||
}
|
||||
|
||||
// Pas d'authentification sur ces services
|
||||
if (in_array($request->getControllerName(), array('service', 'import')) ) {
|
||||
if (in_array($request->getControllerName(), array('service', 'import', 'fichier')) ) {
|
||||
$checkAuth = false;
|
||||
}
|
||||
|
||||
@ -74,7 +74,7 @@ class Application_Controller_Plugin_Auth extends Zend_Controller_Plugin_Abstract
|
||||
//Authentifié => on met à jour la session
|
||||
} else {
|
||||
|
||||
$identity = $auth->getIdentity();
|
||||
$identity = $auth->getIdentity();
|
||||
$identity->time = time() + $identity->timeout;
|
||||
$auth->getStorage()->write($identity);
|
||||
|
||||
|
@ -36,5 +36,5 @@ class Infogreffe_Config
|
||||
* Directory where cache file are store
|
||||
* @var string
|
||||
*/
|
||||
protected $cachePath = '';
|
||||
protected $cachePath = '/cache/';
|
||||
}
|
@ -48,10 +48,10 @@ class Infogreffe extends Infogreffe_Config
|
||||
protected $vecteur;
|
||||
|
||||
/**
|
||||
* String which contain reference
|
||||
* @var string
|
||||
* Elements de référence
|
||||
* @var array
|
||||
*/
|
||||
protected $option;
|
||||
protected $option = array();
|
||||
|
||||
/**
|
||||
* Error number
|
||||
@ -71,7 +71,7 @@ class Infogreffe extends Infogreffe_Config
|
||||
/**
|
||||
* Define path where PDF file are store
|
||||
*/
|
||||
$this->dataPath = '';
|
||||
$this->dataPath = SECURE_STORAGE;
|
||||
|
||||
/**
|
||||
* Define path where XML cache file are store
|
||||
@ -124,65 +124,31 @@ class Infogreffe extends Infogreffe_Config
|
||||
$commande->addChild('num_siren', $this->siren);
|
||||
|
||||
// Commande de documents : bilan saisie ou bilan complet
|
||||
if ( ($this->typeCommande=='BS' || $this->typeCommande=='BI') && $this->option!='' )
|
||||
if ( ($this->typeCommande=='BS' || $this->typeCommande=='BI') && count($this->option)>0 )
|
||||
{
|
||||
|
||||
/* Format de la variable option pour la commande de type BI ou BS
|
||||
* 0 => millesime
|
||||
* 1 => date_cloture
|
||||
* 2 => greffe
|
||||
* 3 => dossier_millesime
|
||||
* 4 => dossier_statut
|
||||
* 5 => dossier_chrono
|
||||
* 6 => num_depot
|
||||
*/
|
||||
$ref = explode('-', $this->option);
|
||||
$commande->addChild('greffe',$ref[2]);
|
||||
$commande->addChild('dossier_millesime',$ref[3]);
|
||||
$commande->addChild('dossier_statut',$ref[4]);
|
||||
$commande->addChild('dossier_chrono',$ref[5]);
|
||||
$commande->addChild('num_depot',$ref[6]);
|
||||
$commande->addChild('date_cloture', WDate::dateT('Ymd','d/m/Y', $ref[1]));
|
||||
$commande->addChild('greffe',$this->option['greffe']);
|
||||
$commande->addChild('dossier_millesime',$this->option['dossier_millesime']);
|
||||
$commande->addChild('dossier_statut',$this->option['dossier_statut']);
|
||||
$commande->addChild('dossier_chrono',$this->option['dossier_chrono']);
|
||||
$commande->addChild('num_depot',$this->option['num_depot']);
|
||||
$commande->addChild('date_cloture', $this->option['date_cloture']);
|
||||
}
|
||||
// Commande de documents : actes
|
||||
elseif ( $this->typeCommande=='AC' && !empty($this->option) )
|
||||
elseif ( $this->typeCommande=='AC' && count($this->option)>0 )
|
||||
{
|
||||
/* Format de la variable option pour commande type AC
|
||||
* 0 => type_acte
|
||||
* 1 => date de référence
|
||||
* 2 => greffe
|
||||
* 3 => dossier_millesime
|
||||
* 4 => dossier_statut
|
||||
* 5 => dossier_chrono
|
||||
* 6 => num_depot
|
||||
* 7 => num_acte
|
||||
*/
|
||||
$ref = explode('-', $this->option);
|
||||
$num_actes = explode('|', $ref[7]);
|
||||
$commande->addChild('greffe',$ref[2]);
|
||||
$commande->addChild('dossier_millesime', $ref[3]);
|
||||
$commande->addChild('dossier_statut', $ref[4]);
|
||||
$commande->addChild('dossier_chrono', $ref[5]);
|
||||
$commande->addChild('num_depot', $ref[6]);
|
||||
$commande->addChild('greffe',$this->option['greffe']);
|
||||
$commande->addChild('dossier_millesime',$this->option['dossier_millesime']);
|
||||
$commande->addChild('dossier_statut',$this->option['dossier_statut']);
|
||||
$commande->addChild('dossier_chrono',$this->option['dossier_chrono']);
|
||||
$commande->addChild('num_depot',$this->option['num_depot']);
|
||||
$liste_actes = $commande->addChild('liste_actes');
|
||||
if(is_array($num_actes) && count($num_actes)>1)
|
||||
{
|
||||
foreach($num_actes as $num_acte)
|
||||
{
|
||||
$liste_actes->addChild('acte')->addAttribute('num', $num_acte);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$liste_actes->addChild('acte')->addAttribute('num', $ref[7]);
|
||||
$fichierOption = $this->option;
|
||||
}
|
||||
$liste_actes->addChild('acte')->addAttribute('num', $this->option['num_acte']);
|
||||
}
|
||||
|
||||
$xmlStr = str_replace('<?xml version="1.0"?>', '', $xml->asXML());
|
||||
|
||||
//Be sure it's in UTF-8
|
||||
$req = utf8_encode($xml);
|
||||
$req = utf8_encode($xmlStr);
|
||||
|
||||
//Create XML request
|
||||
$post = '<?xml version="1.0" encoding="UTF-8"?>'.
|
||||
@ -200,7 +166,7 @@ class Infogreffe extends Infogreffe_Config
|
||||
'</SOAP-ENV:Envelope>';
|
||||
|
||||
$ch = curl_init();
|
||||
curl_setopt($ch, CURLOPT_URL, $this->url);
|
||||
curl_setopt($ch, CURLOPT_URL, $this->config[$env]['URL']);
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
|
||||
curl_setopt($ch, CURLOPT_COOKIEFILE,TRUE);
|
||||
curl_setopt($ch, CURLOPT_POST, TRUE);
|
||||
@ -210,7 +176,7 @@ class Infogreffe extends Infogreffe_Config
|
||||
|
||||
//Remove SOAP part of XML
|
||||
$response = str_replace("<?xml version='1.0' encoding='UTF-8'?><SOAP-ENV:Envelope xmlns:SOAP-ENV='http://schemas.xmlsoap.org/soap/envelope/' xmlns:SOAP-ENC='http://schemas.xmlsoap.org/soap/encoding/' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:xsd='http://www.w3.org/2001/XMLSchema'><SOAP-ENV:Body><ns0:getProduitsWebServicesXMLResponse xmlns:ns0='urn:local' SOAP-ENV:encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'><return xsi:type='xsd:string'>", '', $response);
|
||||
$response = str_replace('</return></ns0:getProduitsWebServicesXMLResponse></SOAP-ENV:Body></SOAP-ENV:Envelope>','', $response);
|
||||
$response = str_replace('</return></ns0:getProduitsWebServicesXMLResponse></SOAP-ENV:Body></SOAP-ENV:Envelope>','', $response);
|
||||
|
||||
return $response;
|
||||
}
|
||||
@ -235,12 +201,12 @@ class Infogreffe extends Infogreffe_Config
|
||||
if( $errNum == '5' ){
|
||||
$errMsg = 'Service partenaire indisponible.';
|
||||
}
|
||||
throw new Exception($errNum . '-' . $errMsg, 'ERR');
|
||||
throw new Exception($errNum . '-' . $errMsg);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception('Fichier vide', 'ERR');
|
||||
throw new Exception('Fichier vide');
|
||||
}
|
||||
}
|
||||
|
||||
@ -248,6 +214,7 @@ class Infogreffe extends Infogreffe_Config
|
||||
* Return true if the file modification time is in the period of caching
|
||||
* @param string $file
|
||||
* Path of file
|
||||
* @return boolean
|
||||
*/
|
||||
protected function cachetimeover($file)
|
||||
{
|
||||
@ -259,7 +226,36 @@ class Infogreffe extends Infogreffe_Config
|
||||
return $timeover;
|
||||
}
|
||||
|
||||
public function download(){}
|
||||
protected function bilanFileName()
|
||||
{
|
||||
return 'bilan-'.$this->siren.'-';
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param unknown $url
|
||||
* @return boolean
|
||||
*/
|
||||
public function download($url)
|
||||
{
|
||||
$result = true;
|
||||
|
||||
|
||||
|
||||
$fp = fopen(SECURE_STORAGE . ''. $file, 'w');
|
||||
$ch = curl_init($url);
|
||||
curl_setopt($ch, CURLOPT_FILE, $fp);
|
||||
$data = curl_exec($ch);
|
||||
// Check if any error occured
|
||||
if(curl_errno($ch))
|
||||
{
|
||||
$result = false;
|
||||
}
|
||||
curl_close($ch);
|
||||
fclose($fp);
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function getStatut($siren, $typeCommande = '', $ref = '', $idCommande = 0)
|
||||
{
|
||||
@ -290,8 +286,8 @@ class Infogreffe extends Infogreffe_Config
|
||||
$this->vecteur = 'XL';
|
||||
$this->typeCommande = 'BI';
|
||||
|
||||
$cacheFile = $this->cachePath.'/'.$this->typeCommande.'-'.$siren.'.xml';
|
||||
|
||||
$cacheFile = APPLICATION_PATH . $this->cachePath.'/'.$this->typeCommande.'-'.$siren.'.xml';
|
||||
|
||||
//Get cache information
|
||||
if (file_exists($cacheFile) && $this->cachetimeover($cacheFile) )
|
||||
{
|
||||
@ -351,17 +347,199 @@ class Infogreffe extends Infogreffe_Config
|
||||
return $bilans;
|
||||
}
|
||||
|
||||
public function getBilan()
|
||||
/**
|
||||
* Commande d'un bilan image
|
||||
* @param string $siren
|
||||
* Siren
|
||||
* @param string $diffusion
|
||||
* Mode de diffusion (C|T)
|
||||
* @param array $option
|
||||
* Référence
|
||||
* @return string
|
||||
*/
|
||||
public function getBilan($siren, $diffusion, $option)
|
||||
{
|
||||
//Retourner la référence de commande interne, chez infogreffe
|
||||
$this->siren = $siren;
|
||||
$this->typeCommande = 'BI';
|
||||
$this->vecteur = $diffusion;
|
||||
$this->option = $option;
|
||||
$xml = $this->getProduitsXML();
|
||||
|
||||
$doc = new DOMDocument();
|
||||
$doc->loadXML($xml);
|
||||
$bilan_complet = $doc->getElementsByTagName('bilan_complet')->item(0);
|
||||
$bilan = array();
|
||||
$bilan['num_gest'] = array();
|
||||
$num_gest = $bilan_complet->getElementsByTagName('num_gest')->item(0);
|
||||
$bilan['num_gest']['greffe'] = $num_gest->getElementsByTagName('greffe')->item(0)->nodeValue;
|
||||
$bilan['num_gest']['dossier_millesime'] = $num_gest->getElementsByTagName('dossier_millesime')->item(0)->nodeValue;
|
||||
$bilan['num_gest']['dossier_statut'] = $num_gest->getElementsByTagName('dossier_statut')->item(0)->nodeValue;
|
||||
$bilan['num_gest']['dossier_chrono'] = $num_gest->getElementsByTagName('dossier_chrono')->item(0)->nodeValue;
|
||||
$bilan['num_siren'] = $bilan_complet->getElementsByTagName('num_siren')->item(0)->nodeValue;
|
||||
$bilan['date_cloture'] = $bilan_complet->getElementsByTagName('date_cloture')->item(0)->nodeValue;
|
||||
$bilan['date_cloture_iso'] = $bilan_complet->getElementsByTagName('date_cloture_iso')->item(0)->nodeValue;
|
||||
$bilan['millesime'] = $bilan_complet->getElementsByTagName('millesime')->item(0)->nodeValue;
|
||||
$bilan['num_depot'] = $bilan_complet->getElementsByTagName('num_depot')->item(0)->nodeValue;
|
||||
$bilan['type_comptes'] = $bilan_complet->getElementsByTagName('type_comptes')->item(0)->nodeValue;
|
||||
$bilan['url_acces'] = $bilan_complet->getElementsByTagName('url_acces')->item(0)->nodeValue;
|
||||
|
||||
return $bilan['url_acces'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Retourne la liste des actes
|
||||
* @param string $siren
|
||||
* @return array
|
||||
*/
|
||||
public function getActes($siren)
|
||||
{
|
||||
$this->siren = $siren;
|
||||
$this->vecteur = 'XL';
|
||||
$this->typeCommande = 'AC';
|
||||
|
||||
$cacheFile = APPLICATION_PATH . $this->cachePath.'/'.$this->typeCommande.'-'.$siren.'.xml';
|
||||
|
||||
//Get cache information
|
||||
if (file_exists($cacheFile) && $this->cachetimeover($cacheFile) )
|
||||
{
|
||||
$xml = file_get_contents($cacheFile);
|
||||
}
|
||||
//Make the request
|
||||
else
|
||||
{
|
||||
$xml = $this->getProduitsXML();
|
||||
$this->error($xml);
|
||||
|
||||
//Create file for the cache
|
||||
file_put_contents($cacheFile, $xml);
|
||||
}
|
||||
|
||||
//Parse XML to make tab
|
||||
$doc = new DOMDocument();
|
||||
$doc->loadXML($xml);
|
||||
$liste_depot_acte = $doc->getElementsByTagName('liste_depot_acte')->item(0);
|
||||
$depot_actes = $liste_depot_acte->getElementsByTagName('depot_acte');
|
||||
$actes = array();
|
||||
foreach($depot_actes as $depot_acte)
|
||||
{
|
||||
$acte = array();
|
||||
|
||||
$acte['num_gest'] = array();
|
||||
$num_gest = $depot_acte->getElementsByTagName('num_gest')->item(0);
|
||||
$acte['num_gest']['greffe'] = $num_gest->getElementsByTagName('greffe')->item(0)->nodeValue;
|
||||
$acte['num_gest']['dossier_millesime'] = $num_gest->getElementsByTagName('dossier_millesime')->item(0)->nodeValue;
|
||||
$acte['num_gest']['dossier_statut'] = $num_gest->getElementsByTagName('dossier_statut')->item(0)->nodeValue;
|
||||
$acte['num_gest']['dossier_chrono'] = $num_gest->getElementsByTagName('dossier_chrono')->item(0)->nodeValue;
|
||||
|
||||
$acte['num_siren'] = $depot_acte->getElementsByTagName('num_siren')->item(0)->nodeValue;
|
||||
$acte['num_depot'] = $depot_acte->getElementsByTagName('num_depot')->item(0)->nodeValue;
|
||||
$acte['date_depot'] = $depot_acte->getElementsByTagName('date_depot')->item(0)->nodeValue;
|
||||
|
||||
$infoActes = $depot_acte->getElementsByTagName('acte');
|
||||
$acte['depot'] = array();
|
||||
foreach($infoActes as $infoActe)
|
||||
{
|
||||
$actenum = array();
|
||||
$actenum['date_acte'] = $infoActe->getElementsByTagName('date_acte')->item(0)->nodeValue;
|
||||
$actenum['num_acte'] = $infoActe->getElementsByTagName('num_acte')->item(0)->nodeValue;
|
||||
$actenum['type_acte'] = $infoActe->getElementsByTagName('type_acte')->item(0)->nodeValue;
|
||||
$actenum['type_acte_libelle'] = $infoActe->getElementsByTagName('type_acte_libelle')->item(0)->nodeValue;
|
||||
$actenum['nbpages_acte'] = $infoActe->getElementsByTagName('nbpages_acte')->item(0)->nodeValue;
|
||||
$decision = $infoActe->getElementsByTagName('decision')->item(0);
|
||||
if($decision)
|
||||
{
|
||||
$actenum['decision'] = array();
|
||||
$actenum['decision']['nature'] = $decision->getElementsByTagName('nature')->item(0)->nodeValue;
|
||||
$actenum['decision']['libelle'] = $decision->getElementsByTagName('libelle')->item(0)->nodeValue;
|
||||
}
|
||||
|
||||
$actenum['mode_diffusion'] = array();
|
||||
$mode_diffusion = $infoActe->getElementsByTagName('mode_diffusion')->item(0)->getElementsByTagName('mode');
|
||||
foreach($mode_diffusion as $mode)
|
||||
{
|
||||
$actenum['mode_diffusion'][] = $mode->getAttribute('type');
|
||||
}
|
||||
$acte['depot'][] = $actenum;
|
||||
}//Fin listes des infos acte
|
||||
|
||||
//Génération de l'index pour le tri
|
||||
if(!empty($acte['date_depot'])){
|
||||
$date = $acte['date_depot'];
|
||||
} else {
|
||||
$date = '';
|
||||
}
|
||||
|
||||
if(!empty($date))
|
||||
{
|
||||
$datef = substr($date,0,4).substr($date,5,2).substr($date,8,2);
|
||||
$key = $datef.'-'.$acte['num_depot'];
|
||||
//Affectation liste générale avec un index permettant le tri
|
||||
$actes[$key] = $acte;
|
||||
}
|
||||
//Prise en compte de l'acte -1
|
||||
if($acte['num_depot']==-1)
|
||||
{
|
||||
$actes[0] = $acte;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//Tri suivant la date d'acte ou de depot
|
||||
krsort($actes);
|
||||
return $actes;
|
||||
|
||||
}
|
||||
|
||||
public function getActes(){}
|
||||
|
||||
public function getActe()
|
||||
public function getActe($siren, $diffusion, $option)
|
||||
{
|
||||
//Retourner la référence de commande interne, chez infogreffe
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
$doc = new DOMDocument();
|
||||
$doc->loadXML($xml);
|
||||
|
||||
$depot_acte = $doc->getElementsByTagName('depot_acte')->item(0);
|
||||
|
||||
$info = array();
|
||||
$info['num_gest'] = array();
|
||||
|
||||
$num_gest = $depot_acte->getElementsByTagName('num_gest')->item(0);
|
||||
|
||||
$info['num_gest']['greffe'] = $num_gest->getElementsByTagName('greffe')->item(0)->nodeValue;
|
||||
$info['num_gest']['dossier_millesime'] = $num_gest->getElementsByTagName('dossier_millesime')->item(0)->nodeValue;
|
||||
$info['num_gest']['dossier_statut'] = $num_gest->getElementsByTagName('dossier_statut')->item(0)->nodeValue;
|
||||
$info['num_gest']['dossier_chrono'] = $num_gest->getElementsByTagName('dossier_chrono')->item(0)->nodeValue;
|
||||
|
||||
$info['num_siren'] = $depot_acte->getElementsByTagName('num_siren')->item(0)->nodeValue;
|
||||
$info['num_depot'] = $depot_acte->getElementsByTagName('num_depot')->item(0)->nodeValue;
|
||||
$info['date_depot'] = $depot_acte->getElementsByTagName('date_depot')->item(0)->nodeValue;
|
||||
|
||||
$infoActes = $depot_acte->getElementsByTagName('acte');
|
||||
$info['actes'] = array();
|
||||
foreach($infoActes as $infoActe)
|
||||
{
|
||||
$actenum = array();
|
||||
$actenum['date_acte'] = $infoActe->getElementsByTagName('date_acte')->item(0)->nodeValue;
|
||||
$actenum['num_acte'] = $infoActe->getElementsByTagName('num_acte')->item(0)->nodeValue;
|
||||
$actenum['type_acte'] = $infoActe->getElementsByTagName('type_acte')->item(0)->nodeValue;
|
||||
$actenum['type_acte_libelle'] = $infoActe->getElementsByTagName('type_acte_libelle')->item(0)->nodeValue;
|
||||
$actenum['nbpages_acte'] = $infoActe->getElementsByTagName('nbpages_acte')->item(0)->nodeValue;
|
||||
|
||||
$decision = $infoActe->getElementsByTagName('decision')->item(0);
|
||||
if($decision)
|
||||
{
|
||||
$actenum['decision'] = array();
|
||||
$actenum['decision']['nature'] = $decision->getElementsByTagName('nature')->item(0)->nodeValue;
|
||||
$actenum['decision']['libelle'] = $decision->getElementsByTagName('libelle')->item(0)->nodeValue;
|
||||
}
|
||||
$actenum['url_acces'] = htmlspecialchars_decode($infoActe->getElementsByTagName('url_acces')->item(0)->nodeValue);
|
||||
$info['actes'][] = $actenum;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -33,7 +33,7 @@
|
||||
|
||||
public function getRefCodeVoie($sep=',', $eol=EOL) {
|
||||
$row = 1;
|
||||
$handle = fopen(DOC_WEB_LOCAL.'voies.csv', 'r');
|
||||
$handle = fopen(DOC_WEB_LOCAL.'tables/voies.csv', 'r');
|
||||
if (!$handle) die('Impossible d\'ouvrir le fichier de configuration des voies INSEE');
|
||||
$tabTmp=array();
|
||||
while (($data = fgetcsv($handle, 1000, ';')) !== FALSE) {
|
||||
|
@ -1,473 +0,0 @@
|
||||
<?
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
@ -67,7 +67,7 @@ function calculIndiScore($siren, $nic=0, $accesDist=false, $cycleClient=2, $mail
|
||||
|
||||
switch( $type ) {
|
||||
case 'scores':
|
||||
$version = '_405';
|
||||
$version = '_405'; //@todo : Version en RECETTE et en PROD
|
||||
$tableComments = 'scores_commentaires';
|
||||
break;
|
||||
case 'valo':
|
||||
|
101
library/WsScore/Configure.php
Normal file
101
library/WsScore/Configure.php
Normal file
@ -0,0 +1,101 @@
|
||||
<?php
|
||||
class Configure
|
||||
{
|
||||
/**
|
||||
* Configuration object
|
||||
* @var Zend_Config_Ini
|
||||
*/
|
||||
protected $profil;
|
||||
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->readConfig();
|
||||
$this->_defineDb();
|
||||
$this->_definePath();
|
||||
$this->_defineSphinx();
|
||||
$this->_defineMail();
|
||||
}
|
||||
|
||||
/**
|
||||
* Read config application.ini
|
||||
*/
|
||||
protected function readConfig()
|
||||
{
|
||||
if ( Zend_Registry::isRegistered('config') ) {
|
||||
$c = Zend_Registry::get('config');
|
||||
$this->profil = $c->profil;
|
||||
} else {
|
||||
$c = new Zend_Config_Ini(APPLICATION_PATH . '/configs/application.ini', 'production');
|
||||
$this->profil = $c->profil;
|
||||
}
|
||||
}
|
||||
|
||||
protected function _defineDb()
|
||||
{
|
||||
if ( $this->profil->db->default ) {
|
||||
define('MYSQL_HOST', $this->profil->db->default->params->host);
|
||||
define('MYSQL_USER', $this->profil->db->default->params->username);
|
||||
define('MYSQL_PASS', $this->profil->db->default->params->password);
|
||||
define('MYSQL_DEFAULT_DB', 'jo');
|
||||
define('MYSQL_SQL_LOG', 'NONE');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected function _definePath()
|
||||
{
|
||||
//Use of realpath
|
||||
|
||||
define('BODACC_LOCAL_DIR' , '/home/data/bodacc/');
|
||||
define('JAL_LOCAL_DIR' , '/home/data/jal/');
|
||||
define('HUGIN_LOCAL_DIR' , '/home/data/infosreg/hugin/');
|
||||
define('ACTUSNEWS_LOCAL_DIR' , '/home/data/infosreg/actusnews/');
|
||||
define('DIRELEASE_LOCAL_DIR' , '/home/data/infosreg/direlease/');
|
||||
define('LESECHOS_LOCAL_DIR' , '/home/data/infosreg/lesechos/');
|
||||
define('BUSINESSWIRE_LOCAL_DIR_INCOMING' , '/home/data/ftp/businesswire/');
|
||||
define('BUSINESSWIRE_LOCAL_DIR' , '/home/data/infosreg/businesswire/');
|
||||
|
||||
define('SECURE_STORAGE' , $this->profil->path->secure.'/');
|
||||
define('DOC_WEB_LOCAL' , $this->profil->path->files.'/');
|
||||
define('DOC_WEB_URL' , '/fichier/');
|
||||
define('LOG_PATH' , $this->profil->path->data.'/log');
|
||||
}
|
||||
|
||||
protected function _defineSphinx()
|
||||
{
|
||||
// Entreprise
|
||||
define('SPHINX_ENT_HOST', $this->profil->sphinx->ent->host);
|
||||
define('SPHINX_ENT_PORT', intval($this->profil->sphinx->ent->port));
|
||||
define('SPHINX_ENT_VERSION', $this->profil->sphinx->ent->version);
|
||||
|
||||
// Dirigeants
|
||||
define('SPHINX_DIR_HOST', $this->profil->sphinx->dir->host);
|
||||
define('SPHINX_DIR_PORT', intval($this->profil->sphinx->dir->port));
|
||||
define('SPHINX_DIR_VERSION', $this->profil->sphinx->dir->version);
|
||||
|
||||
// Historique
|
||||
define('SPHINX_HISTO_HOST', $this->profil->sphinx->histo->host);
|
||||
define('SPHINX_HISTO_PORT', intval($this->profil->sphinx->histo->port));
|
||||
define('SPHINX_HISTO_VERSION', $this->profil->sphinx->histo->version);
|
||||
|
||||
// Actionnaire
|
||||
define('SPHINX_ACT_HOST', $this->profil->sphinx->act->host);
|
||||
define('SPHINX_ACT_PORT', intval($this->profil->sphinx->act->port));
|
||||
define('SPHINX_ACT_VERSION', $this->profil->sphinx->act->version);
|
||||
|
||||
//Old
|
||||
define('SPHINX_HOST', $this->profil->sphinx->ent->host);
|
||||
define('SPHINX_PORT', intval($this->profil->sphinx->ent->port));
|
||||
}
|
||||
|
||||
protected function _defineMail()
|
||||
{
|
||||
//Messagerie
|
||||
define('SMTP_HOST', $this->profil->mail->smtp_host);
|
||||
define('SMTP_PORT', '');
|
||||
define('SMTP_USER', '');
|
||||
define('SMTP_PASS', '');
|
||||
}
|
||||
|
||||
}
|
@ -29,7 +29,7 @@ class Gestion extends WsScore
|
||||
debugLog('I',"getInfosLogin pour $login (IP=$ipUtilisateur)",__LINE__,__FILE__, __FUNCTION__, __CLASS__);
|
||||
|
||||
//L'utilisateur qui demande les informations est différent
|
||||
if ( $this->tabInfoUser['login']<>$login
|
||||
if ( $this->tabInfoUser['login']<>$login
|
||||
&& in_array($this->tabInfoUser['profil'], array('Administrateur', 'SuperAdministrateur') )
|
||||
) {
|
||||
/** Un administrateur veut il des infos sur un login ? **/
|
||||
@ -44,7 +44,7 @@ class Gestion extends WsScore
|
||||
if (count($rep)>0)
|
||||
{
|
||||
$timeOutSec = $tabRep['timeout'];
|
||||
if ($timeOutSec==0) $timeOutSec = 1800;
|
||||
if ($timeOutSec==0) $timeOutSec = 1800;
|
||||
$result->login = $login;
|
||||
$result->id = $tabRep['id'];
|
||||
$result->email = $tabRep['email'];
|
||||
@ -161,10 +161,10 @@ class Gestion extends WsScore
|
||||
$iDbCrm->insert('logs', $tabInsert);
|
||||
|
||||
//Date de dernière connexion
|
||||
$iDbCrm->update('utilisateurs',
|
||||
array('dateDerniereConnexion'=> date('Y-m-d H:i:s')),
|
||||
$iDbCrm->update('utilisateurs',
|
||||
array('dateDerniereConnexion'=> date('Y-m-d H:i:s')),
|
||||
"idClient=".$this->tabInfoUser['idClient']." AND login='".$this->tabInfoUser['login']."'"
|
||||
);
|
||||
);
|
||||
}
|
||||
|
||||
//Retour
|
||||
@ -194,7 +194,7 @@ class Gestion extends WsScore
|
||||
{
|
||||
case 'delete':
|
||||
|
||||
if ($this->tabInfoUser['profil']=='Administrateur'
|
||||
if ($this->tabInfoUser['profil']=='Administrateur'
|
||||
|| $this->tabInfoUser['profil']=='SuperAdministrateur') {
|
||||
$tabUpdate = array( 'deleted' => 1, 'dateUpdate' => date('Y-m-d H:i:s') );
|
||||
$iDbCrm = new WDB('sdv1');
|
||||
@ -209,7 +209,7 @@ class Gestion extends WsScore
|
||||
|
||||
case 'actif':
|
||||
case 'desactif':
|
||||
if ($this->tabInfoUser['profil']=='Administrateur'
|
||||
if ($this->tabInfoUser['profil']=='Administrateur'
|
||||
|| $this->tabInfoUser['profil']=='SuperAdministrateur'){
|
||||
if ($action=='actif') $actif = 1;
|
||||
if ($action=='desactif') $actif = 0;
|
||||
@ -243,7 +243,7 @@ class Gestion extends WsScore
|
||||
|
||||
case 'new':
|
||||
|
||||
if ($this->tabInfoUser['profil']=='Administrateur'
|
||||
if ($this->tabInfoUser['profil']=='Administrateur'
|
||||
|| $this->tabInfoUser['profil']=='SuperAdministrateur') {
|
||||
|
||||
$idClient = $this->tabInfoUser['idClient'];
|
||||
@ -252,7 +252,7 @@ class Gestion extends WsScore
|
||||
}
|
||||
|
||||
$typeCompte = 'PROD';
|
||||
if ( $this->tabInfoUser['profil']=='SuperAdministrateur' && $infos->typeCompte=='TEST'){
|
||||
if ( $this->tabInfoUser['profil']=='SuperAdministrateur' && $infos->typeCompte=='TEST'){
|
||||
$typeCompte = 'TEST';
|
||||
}
|
||||
|
||||
@ -340,29 +340,29 @@ class Gestion extends WsScore
|
||||
$this->authenticate();
|
||||
|
||||
if ($this->tabInfoUser['profil']!='SuperAdministrateur') {
|
||||
$this->sendError('0901');
|
||||
$this->sendError('0901');
|
||||
}
|
||||
if (empty($element)){
|
||||
throw new SoapFault('Error', 'Erreur dans les paramètres');
|
||||
throw new SoapFault('Error', 'Erreur dans les paramètres');
|
||||
}
|
||||
switch(strtolower($element)){
|
||||
switch(strtolower($element)){
|
||||
//Mettre à jour les ips des utilisateurs en fonction de celles du client
|
||||
case 'ip':
|
||||
$iDbCrm = new WDB('sdv1');
|
||||
$rep = $iDbCrm->select('clients', 'filtre_ip', "id='$idClient'", false, MYSQL_ASSOC);
|
||||
if (count($rep)==0){
|
||||
throw new SoapFault('Error', 'Client inexistant');
|
||||
}
|
||||
}
|
||||
$data = array(
|
||||
'filtre_ip' => $rep[0]['filtre_ip'],
|
||||
'dateUpdate' => date('Y-m-d H:i:s'),
|
||||
);
|
||||
$where = ' WHERE idClient='.$idClient;
|
||||
);
|
||||
$where = ' WHERE idClient='.$idClient;
|
||||
if (!empty($utilisateurs) && is_array($utilisateurs->item)){
|
||||
$where.= ' AND login IN ('.join(',',$utilisateurs->item).')';
|
||||
}
|
||||
if($iDbCrm->update('utilisateurs', $data, $where)){
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
break;
|
||||
@ -449,8 +449,8 @@ class Gestion extends WsScore
|
||||
|
||||
$iDbCrm = new WDB('sdv1');
|
||||
$rep = $iDbCrm->select('clients',
|
||||
'id, nom, actif, test, racineLogin, siren, nic, tva, editerFacture, fact_detail, fac_dest, fac_adr1, fac_adr2, fac_adr3, fac_email, fac_tel, fact_rib, liv_dest, liv_adr1, liv_adr2, liv_adr3, liv_email, liv_tel, droits, filtres_ip, dateInsert, dateUpdate, respComSD, typeContrat, dateSignature, typeAcces, typeScore, timeout, accesPieces, accesKbis, accesInvestigations, accesInternationnal, accesEnquetes, miseSousSurveillance, forfaitExtranetPeriode, forfaitExtranetMontant, reconductionAuto, remarque, forfaitPiecesNb, forfaitPiecesMt, forfaitPiecesDep, forfaitInvestigNb, forfaitInvestigMt, forfaitInvestigDep, tarifIndiscore',
|
||||
"1 $strClient",
|
||||
'id, nom, actif, test, racineLogin, siren, nic, tva, editerFacture, fact_detail, fac_dest, fac_adr1, fac_adr2, fac_adr3, fac_email, fac_tel, fact_rib, liv_dest, liv_adr1, liv_adr2, liv_adr3, liv_email, liv_tel, droits, filtres_ip, dateInsert, dateUpdate, respComSD, typeContrat, dateSignature, typeAcces, typeScore, timeout, accesPieces, accesKbis, accesInvestigations, accesInternationnal, accesEnquetes, miseSousSurveillance, forfaitExtranetPeriode, forfaitExtranetMontant, reconductionAuto, remarque, forfaitPiecesNb, forfaitPiecesMt, forfaitPiecesDep, forfaitInvestigNb, forfaitInvestigMt, forfaitInvestigDep, tarifIndiscore',
|
||||
"1 $strClient",
|
||||
false,
|
||||
MYSQL_ASSOC);
|
||||
$tabRet = array();
|
||||
@ -623,8 +623,8 @@ class Gestion extends WsScore
|
||||
|
||||
// Vue détaillée ou uniquement les infos payantes
|
||||
if ($detail==0) {
|
||||
$detail='Non';
|
||||
//$strDetail=" AND (page LIKE 'greffe_%' OR page LIKE 'inpi_%' OR page='kbis' OR page LIKE 'indiscore%' OR page='privileges' OR page='commandeAsso') AND (params<>'' OR page LIKE 'indiscore%' AND tarifIndiscore<>0) AND (params NOT LIKE '%erreur%' OR params LIKE '%erreur 17%') ";
|
||||
$detail='Non';
|
||||
//$strDetail=" AND (page LIKE 'greffe_%' OR page LIKE 'inpi_%' OR page='kbis' OR page LIKE 'indiscore%' OR page='privileges' OR page='commandeAsso') AND (params<>'' OR page LIKE 'indiscore%' AND tarifIndiscore<>0) AND (params NOT LIKE '%erreur%' OR params LIKE '%erreur 17%') ";
|
||||
$strDetail = ' AND ( ';
|
||||
$pages = array('greffe_actes', 'greffe_bilans', 'kbis', 'indiscore', 'indiscore2', 'indiscore3', 'rapport2', 'rapport3', 'privileges', 'privcumul');
|
||||
$totalPages = count($pages);
|
||||
@ -646,9 +646,9 @@ class Gestion extends WsScore
|
||||
$i++;
|
||||
if ( $i<$totalPages) {
|
||||
$strDetail.= ' OR ';
|
||||
}
|
||||
}
|
||||
}
|
||||
$strDetail.= ' ) ';
|
||||
$strDetail.= ' ) ';
|
||||
} elseif($detail==1) {
|
||||
$detail='Oui';
|
||||
}
|
||||
@ -679,7 +679,8 @@ class Gestion extends WsScore
|
||||
$dateDeb=date('Y-m-d', mktime(0,0,0,$mois,1,$annee));
|
||||
$dateFin=date('Y-m-t', mktime(0,0,0,$mois,15,$annee));
|
||||
|
||||
$fichierCsv=DOC_WEB_LOCAL."csv/logs-$annee-$mois-$detail-$idClient-$login-$all.csv";
|
||||
$c = Zend_Registry::get('config');
|
||||
$fichierCsv=$c->profil->path->files."/logs-$annee-$mois-$detail-$idClient-$login-$all.csv";
|
||||
|
||||
if (file_exists($fichierCsv) &&
|
||||
date('Ymd', filemtime($fichierCsv))==date('Ymd') &&
|
||||
@ -695,19 +696,19 @@ class Gestion extends WsScore
|
||||
WHERE 1 $strDetail $strClient $strLogin AND dateHeure BETWEEN '$dateDeb 00:00:00' AND '$dateFin 23:59:59' AND l.login=u.login AND u.idClient=c.id
|
||||
GROUP BY l.login, l.siren, l.page, date(dateHeure), l.params
|
||||
ORDER BY l.login ASC, l.dateHeure ASC";
|
||||
$fp = fopen(DOC_WEB_LOCAL."/csv/logs-$annee-$mois-$detail-$idClient-$login-$all.sql", 'w');
|
||||
$fp = fopen($c->profil->path->cache."/logs-$annee-$mois-$detail-$idClient-$login-$all.sql", 'w');
|
||||
fwrite($fp, $sql.EOL);
|
||||
fclose($fp);
|
||||
exec("php ".APPLICATION_PATH."/../batch/sql2csv.php sdv1 ".DOC_WEB_LOCAL."csv/logs-$annee-$mois-$detail-$idClient-$login-$all.sql $fichierCsv > /dev/null &");
|
||||
exec("php ".$c->profil->path->batch."/sql2csv.php sdv1 ".$c->profil->path->cache."/logs-$annee-$mois-$detail-$idClient-$login-$all.sql $fichierCsv > /dev/null &");
|
||||
$size = $cache = 0;
|
||||
}
|
||||
|
||||
|
||||
$hostname = 'http://'.$_SERVER['SERVER_NAME'];
|
||||
if ($_SERVER['SERVER_PORT']!='80'){
|
||||
$hostname.= ':'.$_SERVER['SERVER_PORT'];
|
||||
}
|
||||
$result = new LogsClients();
|
||||
$result->Url = $hostname.DOC_WEB_URL."csv/logs-$annee-$mois-$detail-$idClient-$login-$all.csv";
|
||||
$result->Url = $hostname."/fichier/logs/logs-$annee-$mois-$detail-$idClient-$login-$all.csv";
|
||||
$result->Taille = $size;
|
||||
$result->Cache = $cache;
|
||||
|
||||
@ -947,7 +948,7 @@ class Gestion extends WsScore
|
||||
$output->error = $error;
|
||||
$output->result = $result;
|
||||
return $output;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Création d'un modele pour le préremplisage des données utilisateurs
|
||||
|
@ -713,7 +713,8 @@ class Gestion extends WsScore
|
||||
$dateDeb=date('Y-m-d', mktime(0,0,0,$mois,1,$annee));
|
||||
$dateFin=date('Y-m-t', mktime(0,0,0,$mois,15,$annee));
|
||||
|
||||
$fichierCsv=DOC_WEB_LOCAL."csv/logs-$annee-$mois-$detail-$idClient-$login-$all.csv";
|
||||
$c = Zend_Registry::get('config');
|
||||
$fichierCsv=$c->profil->path->files."/logs-$annee-$mois-$detail-$idClient-$login-$all.csv";
|
||||
|
||||
if (file_exists($fichierCsv) &&
|
||||
date('Ymd', filemtime($fichierCsv))==date('Ymd') &&
|
||||
@ -729,10 +730,10 @@ class Gestion extends WsScore
|
||||
WHERE 1 $strDetail $strClient $strLogin AND dateHeure BETWEEN '$dateDeb 00:00:00' AND '$dateFin 23:59:59' AND l.login=u.login AND u.idClient=c.id
|
||||
GROUP BY l.login, l.siren, l.page, date(dateHeure), l.params
|
||||
ORDER BY l.login ASC, l.dateHeure ASC";
|
||||
$fp = fopen(DOC_WEB_LOCAL."/csv/logs-$annee-$mois-$detail-$idClient-$login-$all.sql", 'w');
|
||||
$fp = fopen($c->profil->path->cache."/logs-$annee-$mois-$detail-$idClient-$login-$all.sql", 'w');
|
||||
fwrite($fp, $sql.EOL);
|
||||
fclose($fp);
|
||||
exec("php ".APPLICATION_PATH."/../batch/sql2csv.php sdv1 ".DOC_WEB_LOCAL."csv/logs-$annee-$mois-$detail-$idClient-$login-$all.sql $fichierCsv > /dev/null &");
|
||||
exec("php ".$c->profil->path->batch."/sql2csv.php sdv1 ".$c->profil->path->cache."/logs-$annee-$mois-$detail-$idClient-$login-$all.sql $fichierCsv > /dev/null &");
|
||||
$size = $cache = 0;
|
||||
}
|
||||
|
||||
@ -741,7 +742,7 @@ class Gestion extends WsScore
|
||||
$hostname.= ':'.$_SERVER['SERVER_PORT'];
|
||||
}
|
||||
$result = new LogsClients();
|
||||
$result->Url = $hostname.DOC_WEB_URL."csv/logs-$annee-$mois-$detail-$idClient-$login-$all.csv";
|
||||
$result->Url = $hostname."/fichier/logs/logs-$annee-$mois-$detail-$idClient-$login-$all.csv";
|
||||
$result->Taille = $size;
|
||||
$result->Cache = $cache;
|
||||
|
||||
|
@ -751,11 +751,12 @@ class Gestion extends WsScore
|
||||
$dateDeb=date('Y-m-d', mktime(0,0,0,$mois,1,$annee));
|
||||
$dateFin=date('Y-m-t', mktime(0,0,0,$mois,15,$annee));
|
||||
|
||||
$fichierCsv=DOC_WEB_LOCAL."csv/logs-$annee-$mois-$detail-$idClient-$login-$all.csv";
|
||||
$c = Zend_Registry::get('config');
|
||||
$fichierCsv=$c->profil->path->files."/logs-$annee-$mois-$detail-$idClient-$login-$all.csv";
|
||||
|
||||
if (file_exists($fichierCsv) &&
|
||||
date('Ymd', filemtime($fichierCsv))==date('Ymd') &&
|
||||
filesize($fichierCsv)>60 ) {
|
||||
if (file_exists($fichierCsv)
|
||||
&& date('Ymd', filemtime($fichierCsv))==date('Ymd')
|
||||
&& filesize($fichierCsv)>60 ) {
|
||||
$size=filesize($fichierCsv);
|
||||
$erreur=false;
|
||||
$tabNom=array();
|
||||
@ -767,10 +768,10 @@ class Gestion extends WsScore
|
||||
WHERE 1 $strDetail $strClient $strLogin AND dateHeure BETWEEN '$dateDeb 00:00:00' AND '$dateFin 23:59:59' AND l.login=u.login AND u.idClient=c.id
|
||||
GROUP BY l.login, l.siren, l.page, date(dateHeure), l.params
|
||||
ORDER BY l.login ASC, l.dateHeure ASC";
|
||||
$fp = fopen(DOC_WEB_LOCAL."/csv/logs-$annee-$mois-$detail-$idClient-$login-$all.sql", 'w');
|
||||
$fp = fopen($c->profil->path->cache."/logs-$annee-$mois-$detail-$idClient-$login-$all.sql", 'w');
|
||||
fwrite($fp, $sql.EOL);
|
||||
fclose($fp);
|
||||
exec("php ".APPLICATION_PATH."/../batch/sql2csv.php sdv1 ".DOC_WEB_LOCAL."csv/logs-$annee-$mois-$detail-$idClient-$login-$all.sql $fichierCsv > /dev/null &");
|
||||
exec("php ".$c->profil->path->batch."/sql2csv.php sdv1 ".$c->profil->path->cache."/logs-$annee-$mois-$detail-$idClient-$login-$all.sql $fichierCsv > /dev/null &");
|
||||
$size = $cache = 0;
|
||||
}
|
||||
|
||||
@ -779,7 +780,7 @@ class Gestion extends WsScore
|
||||
$hostname.= ':'.$_SERVER['SERVER_PORT'];
|
||||
}
|
||||
$result = new LogsClients();
|
||||
$result->Url = $hostname.DOC_WEB_URL."csv/logs-$annee-$mois-$detail-$idClient-$login-$all.csv";
|
||||
$result->Url = $hostname."/fichier/logs/logs-$annee-$mois-$detail-$idClient-$login-$all.csv";
|
||||
$result->Taille = $size;
|
||||
$result->Cache = $cache;
|
||||
|
||||
|
@ -26,35 +26,37 @@ class Pieces extends WsScore
|
||||
if ($_SERVER['SERVER_PORT']!='80'){
|
||||
$hostname.= ':'.$_SERVER['SERVER_PORT'];
|
||||
}
|
||||
|
||||
$c = Zend_Registry::get('config');
|
||||
$path = realpath($c->profil->path->secure).'/kbis/';
|
||||
|
||||
//Le fichier existe avec une date de validité inférieure à 1 jour
|
||||
$filepdf = DOC_WEB_LOCAL.'kbis/'.$siren.'.pdf';
|
||||
$filepdf = $path.$siren.'.pdf';
|
||||
if ( file_exists($filepdf) && date('Ymd', filemtime($filepdf))==date('Ymd') ) {
|
||||
|
||||
$this->wsLog('kbis', $siren, basename($filepdf));
|
||||
|
||||
return $hostname.'/data/kbis/'.basename($filepdf);
|
||||
return $hostname.DOC_WEB_URL.'/kbis/'.basename($filepdf);
|
||||
|
||||
} else {
|
||||
|
||||
$file = null;
|
||||
|
||||
//On vérifie quand même si il n'existe pas une commande en html
|
||||
$dir = DOC_WEB_LOCAL.'kbis/'.date('Ymd');
|
||||
if (file_exists($dir)) {
|
||||
$dir = $path.date('Ymd');
|
||||
if ( file_exists($dir) ) {
|
||||
foreach ( glob($dir.'/'.$siren.'-*.html') as $file ) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($file)) {
|
||||
if ( empty($file) ) {
|
||||
//Téléchargement du KBIS
|
||||
$result = array();
|
||||
exec('php '.APPLICATION_PATH.'/../batch/getKbis.php --siren '.$siren, $result);
|
||||
exec('php '.$c->profil->path.batch.'/getKbis.php --siren '.$siren, $result);
|
||||
$result = end($result);
|
||||
if (substr($result,-5)=='.html')
|
||||
{
|
||||
$file = DOC_WEB_LOCAL.'kbis/'.date('Ymd').'/'.$result;
|
||||
$file = $path.'/kbis/'.date('Ymd').'/'.$result;
|
||||
$this->wsLog('kbis', $siren, $result);
|
||||
}
|
||||
elseif ( $result!='ERREUR')
|
||||
@ -83,7 +85,7 @@ class Pieces extends WsScore
|
||||
if ( !file_exists($filepdf) ) {
|
||||
throw new SoapFault('0000',"Fichier PDF introuvable");
|
||||
}
|
||||
return $hostname.'/data/kbis/'.basename($filepdf);
|
||||
return $hostname.DOC_WEB_URL.'/kbis/'.basename($filepdf);
|
||||
}
|
||||
}
|
||||
|
||||
@ -132,6 +134,8 @@ class Pieces extends WsScore
|
||||
'9300',
|
||||
);
|
||||
|
||||
$list = array();
|
||||
|
||||
//Liste des bilans association
|
||||
if ( in_array($fj, $assoFormeJuridique) ) {
|
||||
|
||||
@ -167,48 +171,43 @@ class Pieces extends WsScore
|
||||
->from($bilansM, array('dateCloture', 'Assoc_Date_Declaration', 'pdfLink', 'typeCompte', 'pdfSize', 'pdfPage'))
|
||||
->where('siren = ?', $siren)
|
||||
->order('dateCloture DESC')
|
||||
->limit($$nbRep, $position);
|
||||
->limit($nbRep, $position);
|
||||
$bilans = $bilansM->fetchAll($sql);
|
||||
}
|
||||
|
||||
$list = array();
|
||||
if( $bilans->count() > 0) {
|
||||
foreach ($bilans as $item) {
|
||||
|
||||
$filename = basename($item->pdfLink);
|
||||
$file = DOC_WEB_LOCAL . 'associations/bilans/' . $filename;
|
||||
|
||||
$bilansList = new Bilans();
|
||||
$bilansList->DateCloture = substr($item->dateCloture,0,4).substr($item->dateCloture,5,2).substr($item->dateCloture,8,2);
|
||||
$bilansList->DateDepot = substr($item->Assoc_Date_Declaration,0,4).substr($item->Assoc_Date_Declaration,5,2).substr($item->Assoc_Date_Declaration,8,2);
|
||||
$bilansList->DureeExercice = '';
|
||||
$bilansList->Type = $item->typeCompte;
|
||||
|
||||
//Chech file exist
|
||||
if ( file_exists($file) )
|
||||
{
|
||||
$bilansList->File = 'ASS_'.$filename;
|
||||
$bilansList->FileSize = $item->pdfSize;
|
||||
$bilansList->NumberOfPages = $item->pdfPage;
|
||||
$bilansList->ModeDiffusion = 'T';
|
||||
}
|
||||
|
||||
$list[] = $bilansList;
|
||||
if( $bilans->count() > 0) {
|
||||
foreach ($bilans as $item) {
|
||||
|
||||
$filename = basename($item->pdfLink);
|
||||
$file = SECURE_STORAGE . 'associations/bilans/' . $filename;
|
||||
|
||||
$bilansList = new Bilans();
|
||||
$bilansList->DateCloture = substr($item->dateCloture,0,4).substr($item->dateCloture,5,2).substr($item->dateCloture,8,2);
|
||||
$bilansList->DateDepot = substr($item->Assoc_Date_Declaration,0,4).substr($item->Assoc_Date_Declaration,5,2).substr($item->Assoc_Date_Declaration,8,2);
|
||||
$bilansList->DureeExercice = '';
|
||||
$bilansList->Type = $item->typeCompte;
|
||||
|
||||
//Chech file exist
|
||||
if ( file_exists($file) )
|
||||
{
|
||||
$bilansList->File = 'ASS_'.$filename;
|
||||
$bilansList->FileSize = $item->pdfSize;
|
||||
$bilansList->NumberOfPages = $item->pdfPage;
|
||||
$bilansList->ModeDiffusion = 'T';
|
||||
}
|
||||
$list[] = $bilansList;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
//Liste des bilans Infogreffe
|
||||
else
|
||||
{
|
||||
|
||||
//@todo : définition du chemin de stockage des fichiers infogreffe
|
||||
|
||||
/*
|
||||
require_once 'Infogreffe/Infogreffe.php';
|
||||
$infogreffe = new Infogreffe();
|
||||
$infogreffeListBilans = $infogreffe->getBilans($siren);
|
||||
|
||||
$infogreffeListBilans = array_slice($infogreffeListBilans, $position, $nbRep, true);
|
||||
|
||||
if ( $infogreffeListBilans > 0 )
|
||||
@ -216,32 +215,32 @@ class Pieces extends WsScore
|
||||
foreach ( $infogreffeListBilans as $item )
|
||||
{
|
||||
$bilansList = new Bilans();
|
||||
$bilansList->DateCloture = '';
|
||||
$bilansList->DateCloture = substr($item['date_cloture_iso'],0,4).substr($item['date_cloture_iso'],5,2).substr($item['date_cloture_iso'],8,2);
|
||||
$bilansList->DateDepot = '';
|
||||
$bilansList->DureeExercice = '';
|
||||
$bilansList->Type = '';
|
||||
$bilansList->Type = $item['type_comptes'];
|
||||
|
||||
$filename = basename($item->pdfLink);
|
||||
|
||||
if ( file_exists($filename) ) {
|
||||
|
||||
// @todo : Vérifier que le fichier existe
|
||||
/*
|
||||
$bilansList->File = basename($item->pdfLink);
|
||||
$bilansList->FileSize = $item->pdfSize;
|
||||
$bilansList->NumberOfPages = $item->pdfPage;
|
||||
$bilansList->ModeDiffusion = 'T';
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
// @todo : Vérifier que le fichier existe
|
||||
$bilansList->File = basename($item->pdfLink);
|
||||
$bilansList->FileSize = $item->pdfSize;
|
||||
$bilansList->NumberOfPages = $item->pdfPage;
|
||||
|
||||
$bilansList->ModeDiffusion = 'T';
|
||||
|
||||
$list[] = $bilansList;
|
||||
}
|
||||
}
|
||||
|
||||
*/
|
||||
//@todo : Regarder la table jo.greffes_bilans
|
||||
|
||||
//@todo : Lire la table jo.greffes_bilans
|
||||
//Comparer avec la liste infogreffe
|
||||
//Si différence enregistrer dans la base
|
||||
//Renvoyer le résultat
|
||||
//Infos :
|
||||
}
|
||||
|
||||
|
||||
@ -255,8 +254,8 @@ class Pieces extends WsScore
|
||||
|
||||
/**
|
||||
* Commande du fichier (URL ou Référence de commande)
|
||||
* @param string $siren
|
||||
* SIREN
|
||||
* @param string $identifiant
|
||||
* SIREN ou autre identifiant
|
||||
* @param string $diffusion
|
||||
* Mode de diffusion T, C
|
||||
* @param string $dateCloture
|
||||
@ -266,18 +265,18 @@ class Pieces extends WsScore
|
||||
* @return string
|
||||
* URL ou identifiant de commande
|
||||
*/
|
||||
public function getBilan($siren, $diffusion, $dateCloture, $reference)
|
||||
public function getBilan($identifiant, $diffusion, $dateCloture, $reference = '')
|
||||
{
|
||||
$this->authenticate();
|
||||
$this->permission('actes');
|
||||
|
||||
if ( strlen($siren)!=9 ) {
|
||||
if ( strlen($identifiant)!=9 ) {
|
||||
$this->sendError('1010');
|
||||
}
|
||||
|
||||
/*
|
||||
* Un bilan doit principalement s'identifier par
|
||||
* siren, date de cloture, type, mode de diffusion
|
||||
* siren, date de cloture, mode de diffusion
|
||||
*
|
||||
* Chemin fichier association
|
||||
* Monter dans /mnt/datafile/associations
|
||||
@ -299,19 +298,94 @@ class Pieces extends WsScore
|
||||
$controlSiren = $parseRef[1];
|
||||
$controlDate = substr($parseRef[2],4,4).substr($parseRef[2],2,2).substr($parseRef[2],0,2);
|
||||
if ( $controlSiren == $siren && $controlDate == $dateCloture) {
|
||||
$filename = substr($reference,4);
|
||||
$file = '/mnt/datafile/associations/bilans/' . $filename;
|
||||
$filename = substr($reference,4);
|
||||
//@todo : Emplacement des fichiers
|
||||
$file = SECURE_STORAGE . 'associations/bilans/' . $filename;
|
||||
$dest = DOC_WEB_LOCAL . 'associations/' . $reference;
|
||||
if ( file_exists($file) && copy($file, $dest)) {
|
||||
$hostname = 'http://'.$_SERVER['SERVER_NAME'];
|
||||
if ($_SERVER['SERVER_PORT']!='80'){
|
||||
if ($_SERVER['SERVER_PORT']!='80') {
|
||||
$hostname.= ':'.$_SERVER['SERVER_PORT'];
|
||||
}
|
||||
$output = $hostname . '/data/associations/' . basename($dest);
|
||||
$this->wsLog('greffe_bilans', $siren, 'Bilan association');
|
||||
$dateClotureD = substr($dateCloture,0,2).'/'.substr($dateCloture,2,2).'/'.substr($dateCloture,4,4);
|
||||
$this->wsLog('greffe_bilans', $siren, 'Bilan association au '.$dateClotureD);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
switch ( $diffusion )
|
||||
{
|
||||
case 'T':
|
||||
//Read the database to see if file exist
|
||||
try {
|
||||
$db = Zend_Db::factory($this->dbConfig->db->jo);
|
||||
$db->getConnection();
|
||||
} catch (Zend_Db_Adapter_Exception $e) {
|
||||
if ($this->tabInfoUser['idClient']!=1) {
|
||||
throw new SoapFault('ERR', "Application error");
|
||||
} else {
|
||||
throw new SoapFault('ERR', $e->getMessage());
|
||||
}
|
||||
} catch (Zend_Exception $e) {
|
||||
if ($this->tabInfoUser['idClient']!=1) {
|
||||
throw new SoapFault('ERR', "Application error");
|
||||
} else {
|
||||
throw new SoapFault('ERR', $e->getMessage());
|
||||
}
|
||||
}
|
||||
$bilansM = new Application_Model_JoGreffesBilans($db);
|
||||
$sql = $bilansM->select()
|
||||
->where('siren=?', $identifiant)
|
||||
->where('date_cloture=?', substr($dateCloture,0,4).'-'.substr($dateCloture,4,2).'-'.substr($dateCloture,6,2));
|
||||
$infos = $bilansM->fetchRow($sql);
|
||||
|
||||
if ( $infos===null ) {
|
||||
throw new SoapFault('ERR', 'Bilan indisponible');
|
||||
}
|
||||
|
||||
//Go to Infogreffe service
|
||||
if ( $infos->pdfLink=='' ) {
|
||||
require_once 'Infogreffe/Infogreffe.php';
|
||||
$infogreffe = new Infogreffe();
|
||||
$url = $infogreffe->getBilan($siren, $diffusion, array(
|
||||
'greffe' => $infos->numGreffe,
|
||||
'dossier_millesime' => substr($infos->numRC,0,2),
|
||||
'dossier_statut' => substr($infos->numRC,2,1),
|
||||
'dossier_chrono' => substr($infos->numRC,3),
|
||||
'num_depot' => $infos->num_depot,
|
||||
'date_cloture' => WDate::dateT('Ymd','d/m/Y',$infos->date_cloture)
|
||||
));
|
||||
$pdf = $infogreffe->download($url);
|
||||
|
||||
|
||||
} else {
|
||||
$pdf = $infos->pdfLink;
|
||||
}
|
||||
|
||||
if ( !empty($pdf) ) {
|
||||
$file = SECURE_STORAGE . 'greffes/bilans/' . $pdf;
|
||||
$dest = DOC_WEB_LOCAL . 'greffes/' . $pdf;
|
||||
if ( file_exists($file) && copy($file, $dest)) {
|
||||
$hostname = 'http://'.$_SERVER['SERVER_NAME'];
|
||||
if ($_SERVER['SERVER_PORT']!='80') {
|
||||
$hostname.= ':'.$_SERVER['SERVER_PORT'];
|
||||
}
|
||||
$output = $hostname . '/data/greffes/' . basename($dest);
|
||||
$this->wsLog('greffe_bilans', $siren, $dateCloture);
|
||||
} else {
|
||||
throw new SoapFault('ERR', 'Fichier introuvable');
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 'C':
|
||||
|
||||
// Renvoyer l'id de commande
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -321,7 +395,8 @@ class Pieces extends WsScore
|
||||
|
||||
protected function getActes($identifiant)
|
||||
{
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
protected function getActe(){}
|
||||
|
@ -1858,7 +1858,11 @@ class Saisie extends WsScore
|
||||
throw new SoapFault('ERR', $e->getMessage());
|
||||
}
|
||||
} catch (Zend_Exception $e) {
|
||||
throw new SoapFault('ERR', "Application error");
|
||||
if ($this->tabInfoUser['idClient']!=1) {
|
||||
throw new SoapFault('ERR', "Application error");
|
||||
} else {
|
||||
throw new SoapFault('ERR', $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
//Type = Entreprise => Search id by Siren
|
||||
|
@ -294,8 +294,10 @@ class WsScore
|
||||
define ('TIME', substr(DATETIME,8,6));
|
||||
define ('DATE_LISIBLE', substr(DATETIME,6,2).'/'.substr(DATETIME,4,2).'/'.substr(DATETIME,0,4));
|
||||
define ('TIME_LISIBLE', substr(DATETIME,8,2).':'.substr(DATETIME,10,2).':'.substr(DATETIME,12,2));
|
||||
|
||||
$this->dbConfig = new Zend_Config_Ini(APPLICATION_PATH . '/configs/databases.ini');
|
||||
|
||||
//Load database configuration
|
||||
$c = Zend_Registry::get('config');
|
||||
$this->dbConfig = $c->profil;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -26,6 +26,4 @@ $application = new Zend_Application(
|
||||
APPLICATION_PATH . '/configs/application.ini'
|
||||
);
|
||||
|
||||
require_once '../config/config.php';
|
||||
|
||||
$application->bootstrap()->run();
|
93
scripts/build/config/WebRecette/application.ini
Normal file
93
scripts/build/config/WebRecette/application.ini
Normal file
@ -0,0 +1,93 @@
|
||||
[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.session.save_path = APPLICATION_PATH "/../data/sessions"
|
||||
resources.frontController.controllerDirectory = APPLICATION_PATH "/controllers"
|
||||
resources.frontController.plugins.Auth = "Application_Controller_Plugin_Auth"
|
||||
resources.frontController.params.displayExceptions = 0
|
||||
resources.layout.layout = "main"
|
||||
resources.layout.layoutPath = APPLICATION_PATH "/views"
|
||||
resources.view.basePath = APPLICATION_PATH "/views"
|
||||
autoloaderNamespaces[] = "Application_"
|
||||
autoloaderNamespaces[] = "Scores_"
|
||||
autoloaderNamespaces[] = "Form_"
|
||||
|
||||
; Scores configuration
|
||||
profil.server.name = WebRecette
|
||||
profil.mail.method = smtp
|
||||
profil.mail.smtp_host = smtp.free.fr
|
||||
profil.mail.email.support = supportdev@scores-decisions.com
|
||||
profil.mail.email.supportdev = supportdev@scores-decisions.com
|
||||
profil.mail.email.contact = supportdev@scores-decisions.com
|
||||
profil.mail.email.production = supportdev@scores-decisions.com
|
||||
profil.wkhtmltopdf.path = "/home/vhosts/dataws/wkhtml"
|
||||
profil.wkhtmltopdf.arch = "amd64"
|
||||
profil.path.batch = APPLICATION_PATH "/../scripts/jobs"
|
||||
profil.path.cache = APPLICATION_PATH "/../data/cache"
|
||||
profil.path.files = APPLICATION_PATH "/../data/files" ; DOC_WEB_LOCAL
|
||||
profil.path.data = "/home/vhosts/dataws"
|
||||
profil.path.secure = "/mnt/datafile" ; SECURE_STORAGE
|
||||
|
||||
; For old configuration - see Configure.php
|
||||
profil.db.default.adapter=mysqli
|
||||
profil.db.default.params.host=127.0.0.1
|
||||
profil.db.default.params.username=wsuser
|
||||
profil.db.default.params.password=wspass2012
|
||||
profil.db.default.params.driver_options.MYSQLI_INIT_COMMAND = "SET NAMES utf8"
|
||||
|
||||
; Complete database configuration
|
||||
profil.db.sdv1.adapter=mysqli
|
||||
profil.db.sdv1.params.host=192.168.78.230
|
||||
profil.db.sdv1.params.username=wsuser
|
||||
profil.db.sdv1.params.password=wspass2012
|
||||
profil.db.sdv1.params.dbname=sdv1
|
||||
profil.db.sdv1.params.driver_options.MYSQLI_INIT_COMMAND = "SET NAMES utf8"
|
||||
profil.db.sdv1.params.persistent = true
|
||||
|
||||
profil.db.jo.adapter=mysqli
|
||||
profil.db.jo.params.host=192.168.78.230
|
||||
profil.db.jo.params.username=wsuser
|
||||
profil.db.jo.params.password=wspass2012
|
||||
profil.db.jo.params.dbname=jo
|
||||
profil.db.jo.params.driver_options.MYSQLI_INIT_COMMAND = "SET NAMES utf8"
|
||||
profil.db.jo.params.persistent = true
|
||||
|
||||
profil.db.historiques.adapter=mysqli
|
||||
profil.db.historiques.params.host=192.168.78.230
|
||||
profil.db.historiques.params.username=wsuser
|
||||
profil.db.historiques.params.password=wspass2012
|
||||
profil.db.historiques.params.dbname=historiques
|
||||
profil.db.historiques.params.driver_options.MYSQLI_INIT_COMMAND = "SET NAMES utf8"
|
||||
profil.db.historiques.params.persistent = true
|
||||
|
||||
profil.db.Commandes.adapter=mysqli
|
||||
profil.db.Commandes.params.host=127.0.0.1
|
||||
profil.db.Commandes.params.username=wsuser
|
||||
profil.db.Commandes.params.password=wspass2012
|
||||
profil.db.Commandes.params.dbname=commandes
|
||||
profil.db.Commandes.params.driver_options.MYSQLI_INIT_COMMAND = "SET NAMES utf8"
|
||||
profil.db.Commandes.params.persistent = true
|
||||
|
||||
profil.db.Webservice.adapter=mysqli
|
||||
profil.db.Webservice.params.host=127.0.0.1
|
||||
profil.db.Webservice.params.username=wsuser
|
||||
profil.db.Webservice.params.password=wspass2012
|
||||
profil.db.Webservice.params.dbname=webservice
|
||||
profil.db.Webservice.params.driver_options.MYSQLI_INIT_COMMAND = "SET NAMES utf8"
|
||||
profil.db.WebServices.params.persistent = true
|
||||
|
||||
[staging : production]
|
||||
resources.frontController.params.displayExceptions = 1
|
||||
|
||||
[development : production]
|
||||
phpSettings.display_startup_errors = 1
|
||||
phpSettings.display_errors = 1
|
||||
resources.frontController.params.displayExceptions = 1
|
||||
|
||||
[testing : production]
|
||||
phpSettings.display_startup_errors = 1
|
||||
phpSettings.display_errors = 1
|
93
scripts/build/config/WebService/application.ini
Normal file
93
scripts/build/config/WebService/application.ini
Normal file
@ -0,0 +1,93 @@
|
||||
[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.session.save_path = APPLICATION_PATH "/../data/sessions"
|
||||
resources.frontController.controllerDirectory = APPLICATION_PATH "/controllers"
|
||||
resources.frontController.plugins.Auth = "Application_Controller_Plugin_Auth"
|
||||
resources.frontController.params.displayExceptions = 0
|
||||
resources.layout.layout = "main"
|
||||
resources.layout.layoutPath = APPLICATION_PATH "/views"
|
||||
resources.view.basePath = APPLICATION_PATH "/views"
|
||||
autoloaderNamespaces[] = "Application_"
|
||||
autoloaderNamespaces[] = "Scores_"
|
||||
autoloaderNamespaces[] = "Form_"
|
||||
|
||||
; Scores configuration
|
||||
profil.server.name = WebService
|
||||
profil.mail.method = smtp
|
||||
profil.mail.smtp_host = smtp.free.fr
|
||||
profil.mail.email.support = supportdev@scores-decisions.com
|
||||
profil.mail.email.supportdev = supportdev@scores-decisions.com
|
||||
profil.mail.email.contact = supportdev@scores-decisions.com
|
||||
profil.mail.email.production = supportdev@scores-decisions.com
|
||||
profil.wkhtmltopdf.path = "/home/vhosts/dataws/wkhtml"
|
||||
profil.wkhtmltopdf.arch = "amd64"
|
||||
profil.path.batch = APPLICATION_PATH "/../scripts/jobs"
|
||||
profil.path.cache = APPLICATION_PATH "/../data/cache"
|
||||
profil.path.files = APPLICATION_PATH "/../data/files" ; DOC_WEB_LOCAL
|
||||
profil.path.data = "/home/vhosts/data"
|
||||
profil.path.secure = "/mnt/datafile" ; SECURE_STORAGE
|
||||
|
||||
; For old configuration - see Configure.php
|
||||
profil.db.default.adapter=mysqli
|
||||
profil.db.default.params.host=127.0.0.1
|
||||
profil.db.default.params.username=wsuser
|
||||
profil.db.default.params.password=wspass2012
|
||||
profil.db.default.params.driver_options.MYSQLI_INIT_COMMAND = "SET NAMES utf8"
|
||||
|
||||
; Complete database configuration
|
||||
profil.db.sdv1.adapter=mysqli
|
||||
profil.db.sdv1.params.host=192.168.78.230
|
||||
profil.db.sdv1.params.username=wsuser
|
||||
profil.db.sdv1.params.password=wspass2012
|
||||
profil.db.sdv1.params.dbname=sdv1
|
||||
profil.db.sdv1.params.driver_options.MYSQLI_INIT_COMMAND = "SET NAMES utf8"
|
||||
profil.db.sdv1.params.persistent = true
|
||||
|
||||
profil.db.jo.adapter=mysqli
|
||||
profil.db.jo.params.host=192.168.78.230
|
||||
profil.db.jo.params.username=wsuser
|
||||
profil.db.jo.params.password=wspass2012
|
||||
profil.db.jo.params.dbname=jo
|
||||
profil.db.jo.params.driver_options.MYSQLI_INIT_COMMAND = "SET NAMES utf8"
|
||||
profil.db.jo.params.persistent = true
|
||||
|
||||
profil.db.historiques.adapter=mysqli
|
||||
profil.db.historiques.params.host=192.168.78.230
|
||||
profil.db.historiques.params.username=wsuser
|
||||
profil.db.historiques.params.password=wspass2012
|
||||
profil.db.historiques.params.dbname=historiques
|
||||
profil.db.historiques.params.driver_options.MYSQLI_INIT_COMMAND = "SET NAMES utf8"
|
||||
profil.db.historiques.params.persistent = true
|
||||
|
||||
profil.db.Commandes.adapter=mysqli
|
||||
profil.db.Commandes.params.host=127.0.0.1
|
||||
profil.db.Commandes.params.username=wsuser
|
||||
profil.db.Commandes.params.password=wspass2012
|
||||
profil.db.Commandes.params.dbname=commandes
|
||||
profil.db.Commandes.params.driver_options.MYSQLI_INIT_COMMAND = "SET NAMES utf8"
|
||||
profil.db.Commandes.params.persistent = true
|
||||
|
||||
profil.db.Webservice.adapter=mysqli
|
||||
profil.db.Webservice.params.host=127.0.0.1
|
||||
profil.db.Webservice.params.username=wsuser
|
||||
profil.db.Webservice.params.password=wspass2012
|
||||
profil.db.Webservice.params.dbname=webservice
|
||||
profil.db.Webservice.params.driver_options.MYSQLI_INIT_COMMAND = "SET NAMES utf8"
|
||||
profil.db.WebServices.params.persistent = true
|
||||
|
||||
[staging : production]
|
||||
resources.frontController.params.displayExceptions = 1
|
||||
|
||||
[development : production]
|
||||
phpSettings.display_startup_errors = 1
|
||||
phpSettings.display_errors = 1
|
||||
resources.frontController.params.displayExceptions = 1
|
||||
|
||||
[testing : production]
|
||||
phpSettings.display_startup_errors = 1
|
||||
phpSettings.display_errors = 1
|
1110
scripts/build/config/_files/kbis/styles/infogreffe.css
Normal file
1110
scripts/build/config/_files/kbis/styles/infogreffe.css
Normal file
File diff suppressed because it is too large
Load Diff
1212
scripts/build/config/_files/kbis/styles/infogreffe_base.css
Normal file
1212
scripts/build/config/_files/kbis/styles/infogreffe_base.css
Normal file
File diff suppressed because it is too large
Load Diff
208
scripts/build/config/_files/tables/voies.csv
Normal file
208
scripts/build/config/_files/tables/voies.csv
Normal file
@ -0,0 +1,208 @@
|
||||
#CodeVoie;Libellé Voie;Export
|
||||
ABE;Abbaye;1
|
||||
AGL;Agglomération;1
|
||||
AIRE;Aire;1
|
||||
ALL;Allée;1
|
||||
ALL;Allee;0
|
||||
ACH;Ancien chemin;1
|
||||
ART;Ancienne route;1
|
||||
ANSE;Anse;1
|
||||
ARC;Arcade;1
|
||||
AUT;Autoroute;1
|
||||
AV;Avenue;1
|
||||
BRE;Barrière;1
|
||||
BCH;Bas chemin;1
|
||||
BSTD;Bastide;1
|
||||
BAST;Baston;1
|
||||
BEGI;Beguinage;1
|
||||
BER;Berge;1
|
||||
BOIS;Bois;1
|
||||
BCLE;Boucle;1
|
||||
BD;Boulevard;1
|
||||
BRG;Bourg;1
|
||||
BUT;Butte;1
|
||||
CALE;Cale;1
|
||||
CAMP;Camp;1
|
||||
CGNE;Campagne;1
|
||||
CPG;Camping;1
|
||||
CARR;Carré;1
|
||||
CAU;Carreau;1
|
||||
CAR;Carrefour;1
|
||||
CARE;Carrière;1
|
||||
CST;Castel;1
|
||||
CAV;Cavée;1
|
||||
CTRE;Central;1
|
||||
CTRE;Centre;1
|
||||
CHL;Chalet;1
|
||||
CHP;Chapelle;1
|
||||
CHI;Charmille;1
|
||||
CHT;Château;1
|
||||
CHS;Chaussée;1
|
||||
CHE;Chemin;1
|
||||
CHV;Chemin vicinaux;0
|
||||
CHV;Chemin vicinal;1
|
||||
CHEM;Cheminement;1
|
||||
#CHEZ;Chez;0
|
||||
CITE;Cîte;1
|
||||
CLOI;Cloître;1
|
||||
CLOS;Clos;1
|
||||
COL;Col;1
|
||||
COLI;Colline;1
|
||||
CTR;Contour;1
|
||||
COR;Corniche;1
|
||||
COTE;Côte;1
|
||||
COTT;Cottage;1
|
||||
COUR;Cour;1
|
||||
CRS;Cours;1
|
||||
DARS;Darse;1
|
||||
DEG;Degré;1
|
||||
DSG;Descente;1
|
||||
DSC;Descente;0
|
||||
DIG;Digue;1
|
||||
DOM;Domaine;1
|
||||
ECA;Ecart;1
|
||||
ECL;Ecluse;1
|
||||
EGL;Eglise;1
|
||||
EN;Enceinte;1
|
||||
ENV;Enclave;1
|
||||
ENC;Enclos;1
|
||||
ESC;Escalier;1
|
||||
ESPA;Espace;1
|
||||
ESP;Esplanade;1
|
||||
ETING;Etang;1
|
||||
FG;Faubourg;1
|
||||
FRM;Ferme;1
|
||||
FON;Fontaine;1
|
||||
FORT;Fort;1
|
||||
FORM;Forum;1
|
||||
FOS;Fosse;1
|
||||
FOYR;Foyer;1
|
||||
GAL;Galerie;1
|
||||
GARE;Gare;1
|
||||
GARN;Garenne;1
|
||||
GBD;Grand boulevard;1
|
||||
GDEN;Grande ensemble;1
|
||||
GR;Grande rue;1
|
||||
GRI;Grille;1
|
||||
GRIM;Grimpette;1
|
||||
GPE;Groupe;1
|
||||
GPT;Groupement;1
|
||||
HLE;Halle;1
|
||||
HAM;Hameau;1
|
||||
HCH;Haut chemin;1
|
||||
HIP;Hippodrome;1
|
||||
HLM;HLM;1
|
||||
ILE;Ile;1
|
||||
IMM;Immeuble;1
|
||||
IMP;Impasse;1
|
||||
JARD;Jardin;1
|
||||
JTE;Jetée;1
|
||||
LEVE;Levée;1
|
||||
LD;Lieu dit;1
|
||||
LD;Lieudit;0
|
||||
LOT;Lotissement;1
|
||||
MAIL;Mail;1
|
||||
MF;Maison forestière;1
|
||||
MAN;Manoir;1
|
||||
MAR;Marche;1
|
||||
MAS;Mas;1
|
||||
MET;Métro;1
|
||||
MET;Metro;0
|
||||
MTE;Montée;1
|
||||
MTE;Montee;1
|
||||
MLN;Moulin;1
|
||||
MUS;Musée;1
|
||||
MUS;Musee;0
|
||||
NTE;Nouvelle route;1
|
||||
PAL;Palais;1
|
||||
PARC;Parc;1
|
||||
PKG;Parking;1
|
||||
PRV;Parvis;1
|
||||
PAS;Passage;1
|
||||
PN;Passage à niveau;1
|
||||
PASS;Passe;1
|
||||
PLE;Passerelle;1
|
||||
PAT;Patio;1
|
||||
PAV;Pavillon;1
|
||||
PERI;Périphérique;1
|
||||
PERI;Peripherique;0
|
||||
PSTY;Péristyle;1
|
||||
PSTY;Peristyle;0
|
||||
PTA;Petites allée;1
|
||||
PTA;Petites allee;0
|
||||
PCH;Petit chemin;1
|
||||
PAE;Petite avenue;1
|
||||
PIM;Petite impasse;1
|
||||
PRT;Petite route;1
|
||||
PTR;Petite rue;1
|
||||
PL;Place;1
|
||||
PLCI;Placis;1
|
||||
PLAG;Plage;1
|
||||
PLN;Plaine;1
|
||||
PLAN;Plan;1
|
||||
PLT;Plateau;1
|
||||
PNT;Pointe;1
|
||||
PONT;Pont;1
|
||||
PCH;Porche;1
|
||||
PORT;Port;1
|
||||
PTE;Porte;1
|
||||
PORQ;Portique;1
|
||||
POT;Poterne;1
|
||||
POUR;Pourtour;1
|
||||
PRE;Pré;1
|
||||
PRE;Pre;0
|
||||
PRQ;Presqu'île;1
|
||||
PRQ;Presqu'ile;0
|
||||
PROM;Promenade;1
|
||||
QU;Quai;1
|
||||
QUAI;Quai;0
|
||||
QUA;Quartier;1
|
||||
RAC;Raccourci;1
|
||||
RAID;Raidillon;1
|
||||
RPE;Rampe;1
|
||||
REM;Rempart;1
|
||||
RES;Résidence;1
|
||||
RES;Residence;0
|
||||
ROC;Roc;1
|
||||
ROC;Rocade;1
|
||||
RPT;Rond point;1
|
||||
ROQT;Roquet;1
|
||||
RTD;Rotonde;1
|
||||
RTE;Route;1
|
||||
R;Rue;1
|
||||
RUE;Rue;0
|
||||
RLE;Ruelle;1
|
||||
SEN;Sente;1
|
||||
SEN;Sentier;1
|
||||
SQ;Square;1
|
||||
STDE;Stade;1
|
||||
STA;Station;1
|
||||
TPL;Terre plein;1
|
||||
TRN;Terrain;1
|
||||
TSSE;Terrasse;1
|
||||
TRT;Tertre;1
|
||||
TOUR;Tour;1
|
||||
TRA;Traverse;1
|
||||
VAL;Vallon;1
|
||||
VAL;Vallée;1
|
||||
VAL;Vallee;0
|
||||
VEN;Venelle;1
|
||||
VIA;Via;1
|
||||
VTE;Vieille route;1
|
||||
VCHE;Vieux chemin;1
|
||||
VLA;Villa;1
|
||||
VGE;Village;1
|
||||
VLGE;Village;0
|
||||
VOI;Voie;1
|
||||
VOIE;Voie;0
|
||||
ZONE;Zone;1
|
||||
ZAC;Zone d'aménagement concerté;1
|
||||
Z A C;Zone d'aménagement concerté;0
|
||||
ZAD;Zone d'aménagement différé;1
|
||||
Z A D;Zone d'aménagement différé;0
|
||||
ZA;Zone artisanale;1
|
||||
Z A;Zone artisanale;0
|
||||
ZI;Zone industrielle;1
|
||||
Z I;Zone industrielle;0
|
||||
ZUP;Zone à urbaniser en priorité;1
|
||||
Z U P;Zone à urbaniser en priorité;0
|
|
19
scripts/build/config/_sql/historiques.bilans.sql
Normal file
19
scripts/build/config/_sql/historiques.bilans.sql
Normal file
@ -0,0 +1,19 @@
|
||||
CREATE TABLE IF NOT EXISTS `bilans` (
|
||||
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`siren` int(9) unsigned zerofill NOT NULL,
|
||||
`dateProvPartenaire` int(8) unsigned NOT NULL,
|
||||
`dateExercice` int(8) unsigned NOT NULL,
|
||||
`dateExercicePre` int(8) unsigned NOT NULL,
|
||||
`dureeExercice` tinyint(2) unsigned NOT NULL DEFAULT '0',
|
||||
`dureeExercicePre` tinyint(2) unsigned NOT NULL DEFAULT '0',
|
||||
`monnaie` char(3) NOT NULL COMMENT 'Code devise du bilan stocké en base selon la ISO 4217 (3 lettres)',
|
||||
`typeBilan` char(1) NOT NULL DEFAULT '',
|
||||
`monnaieOrigine` char(3) NOT NULL COMMENT 'Code devise d''origine selon la ISO 4217 (3 lettres)',
|
||||
`unite` char(1) NOT NULL DEFAULT '',
|
||||
`postes` text NOT NULL,
|
||||
`partenaire` tinyint(1) unsigned NOT NULL DEFAULT '0',
|
||||
`confidentiel` tinyint(1) unsigned NOT NULL DEFAULT '0',
|
||||
`dateInsert` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `dateInsert` (`dateInsert`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COMMENT='Bilans';
|
14
scripts/build/config/_sql/jo.asso_actes.sql
Normal file
14
scripts/build/config/_sql/jo.asso_actes.sql
Normal file
@ -0,0 +1,14 @@
|
||||
CREATE TABLE IF NOT EXISTS `asso_actes` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`siren` varchar(9) DEFAULT NULL COMMENT 'Siren',
|
||||
`waldec` varchar(15) DEFAULT NULL COMMENT 'Numéro R.N.A',
|
||||
`pdfLink` varchar(50) NOT NULL COMMENT 'Nom du PDF',
|
||||
`pdfSize` int(11) NOT NULL COMMENT 'Taille du PDF en octets',
|
||||
`pdfVer` varchar(4) NOT NULL COMMENT 'Version du fichier PDF',
|
||||
`pdfPage` int(2) NOT NULL COMMENT 'Nombre de pages',
|
||||
`date_acte` date NOT NULL COMMENT 'Date de l''acte',
|
||||
`type_acte` varchar(5) NOT NULL COMMENT 'Type de l''acte (info)',
|
||||
`type_acte_libelle` varchar(100) NOT NULL COMMENT 'Libellé du type de l''acte',
|
||||
`dateInsert` datetime NOT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COMMENT='Statuts des associations' ;
|
10
scripts/build/config/_sql/jo.bilans_user.sql
Normal file
10
scripts/build/config/_sql/jo.bilans_user.sql
Normal file
@ -0,0 +1,10 @@
|
||||
CREATE TABLE IF NOT EXISTS `bilans_user` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`idUtilisateur` int(11) NOT NULL COMMENT 'Identifiant de l''opérateur ayant modifié le bilan',
|
||||
`login` varchar(20) NOT NULL COMMENT 'Login de l''opérateur ayant modifié le bilan',
|
||||
`siren` int(9) unsigned zerofill NOT NULL COMMENT 'Siren du bilan modifié',
|
||||
`dateExercice` int(8) NOT NULL COMMENT 'Date de clôture du bilan modifié',
|
||||
`typeBilan` char(1) NOT NULL COMMENT 'Type de bilan modifié',
|
||||
`dateAction` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COMMENT='Modifications de bilans faites par des opérateurs S&D';
|
14
scripts/build/config/_sql/logsCount.sql
Normal file
14
scripts/build/config/_sql/logsCount.sql
Normal file
@ -0,0 +1,14 @@
|
||||
--
|
||||
-- Structure de la table `logsCount`
|
||||
--
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `logsCount` (
|
||||
`jour` date NOT NULL COMMENT 'Jour de la consommation',
|
||||
`idClient` int(11) NOT NULL,
|
||||
`service` char(20) NOT NULL,
|
||||
`login` char(20) NOT NULL,
|
||||
`log` char(20) NOT NULL COMMENT 'Nom de l''élément consommé',
|
||||
`conso` int(11) NOT NULL COMMENT 'Nombre de consommation',
|
||||
`batchUpdate` datetime NOT NULL DEFAULT '0000-00-00 00:00:00' COMMENT 'Date de mise à jour par Batch',
|
||||
UNIQUE KEY `jour` (`jour`,`idClient`,`service`,`login`,`log`)
|
||||
) ENGINE=MyISAM COMMENT='Calcul des consommations';
|
6
scripts/build/config/_sql/sdv1.clients_services.sql
Normal file
6
scripts/build/config/_sql/sdv1.clients_services.sql
Normal file
@ -0,0 +1,6 @@
|
||||
CREATE TABLE IF NOT EXISTS `clients_services` (
|
||||
`code` varchar(20) NOT NULL COMMENT 'Code du service (elements texte sans espace ni caractères spéciaux)',
|
||||
`label` varchar(100) NOT NULL COMMENT 'Libellé du service',
|
||||
`idClient` int(11) NOT NULL,
|
||||
KEY `code` (`code`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
|
13
scripts/build/config/_sql/sdv1.clients_tarifs.sql
Normal file
13
scripts/build/config/_sql/sdv1.clients_tarifs.sql
Normal file
@ -0,0 +1,13 @@
|
||||
CREATE TABLE IF NOT EXISTS `clients_tarifs` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`idClient` int(11) NOT NULL,
|
||||
`service` char(20) NOT NULL,
|
||||
`log` char(20) NOT NULL COMMENT 'Element à facturer',
|
||||
`type` enum('Unitaire','ForfaitLimit','ForfaitNolimit') NOT NULL,
|
||||
`priceUnit` float NOT NULL DEFAULT '0' COMMENT 'Prix unitaire d''un élément',
|
||||
`limit` int(11) NOT NULL DEFAULT '0' COMMENT 'Nombre limite de consommation',
|
||||
`dateDebut` datetime NOT NULL DEFAULT '0000-00-00 00:00:00' COMMENT 'Date de debut du contrat',
|
||||
`duree` int(11) NOT NULL COMMENT 'Durée du contrat',
|
||||
`doublon` enum('jour','mois','period','') NOT NULL COMMENT 'Période de dédoublonnage',
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=MyISAM COMMENT='Définition des tarifs pour les clients et services';
|
31
scripts/build/config/_sql/sdv1.prestations.sql
Normal file
31
scripts/build/config/_sql/sdv1.prestations.sql
Normal file
@ -0,0 +1,31 @@
|
||||
--
|
||||
-- Structure de la table `prestations`
|
||||
--
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `prestations` (
|
||||
`id` int(11) NOT NULL,
|
||||
`typeprestation` varchar(50) NOT NULL,
|
||||
`source` varchar(50) NOT NULL,
|
||||
`datemiseenplace` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
|
||||
`datepremierefactu` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
|
||||
`freqfacturation` enum('Unitaire','Quotidien','Hebdo','Mensuel','Trimestriel','Annuel','Semestriel') NOT NULL,
|
||||
`datefinprestation` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
|
||||
`prestatest` tinyint(1) NOT NULL,
|
||||
`identifiantPrestation` varchar(100) NOT NULL,
|
||||
`passwordprestation` varchar(100) NOT NULL,
|
||||
`supportprestation` enum('FTP','Email','CD/DVD','CFT') NOT NULL,
|
||||
`identifiantCFT` varchar(100) NOT NULL,
|
||||
`dureecontrat` int(2) NOT NULL,
|
||||
`montantannuelfactu` varchar(10) NOT NULL,
|
||||
`freqenvois` enum('Unitaire','Quotidien','Hebdo','Mensuel','Trimestriel','Annuel','Semestriel') NOT NULL,
|
||||
`formatdesenvois` varchar(100) NOT NULL,
|
||||
`trtnumerotour` int(11) NOT NULL,
|
||||
`trtdatedeniereexec` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
|
||||
`optionsprestation` text NOT NULL,
|
||||
`prestationactive` enum('oui','non') NOT NULL,
|
||||
`optionsupport` text NOT NULL,
|
||||
`mailIN` varchar(100) NOT NULL,
|
||||
`mailOUT` varchar(100) NOT NULL,
|
||||
`osClient` int(11) NOT NULL,
|
||||
`compression` enum('none','zip','gzip','bzip2') NOT NULL
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COMMENT='Prestations Surveillance / Diffusion';
|
5
scripts/build/config/_sql/sdv1.utilisateurs_service.sql
Normal file
5
scripts/build/config/_sql/sdv1.utilisateurs_service.sql
Normal file
@ -0,0 +1,5 @@
|
||||
CREATE TABLE IF NOT EXISTS `utilisateurs_service` (
|
||||
`login` varchar(20) NOT NULL,
|
||||
`serviceCode` varchar(20) NOT NULL COMMENT 'Code du service',
|
||||
KEY `login` (`login`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
|
92
scripts/build/config/local/application.ini
Normal file
92
scripts/build/config/local/application.ini
Normal file
@ -0,0 +1,92 @@
|
||||
[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.session.save_path = APPLICATION_PATH "/../data/sessions"
|
||||
resources.frontController.controllerDirectory = APPLICATION_PATH "/controllers"
|
||||
resources.frontController.plugins.Auth = "Application_Controller_Plugin_Auth"
|
||||
resources.frontController.params.displayExceptions = 0
|
||||
resources.layout.layout = "main"
|
||||
resources.layout.layoutPath = APPLICATION_PATH "/views"
|
||||
resources.view.basePath = APPLICATION_PATH "/views"
|
||||
autoloaderNamespaces[] = "Application_"
|
||||
autoloaderNamespaces[] = "Scores_"
|
||||
autoloaderNamespaces[] = "Form_"
|
||||
|
||||
; Scores configuration
|
||||
profil.server.name = development
|
||||
profil.mail.method = smtp
|
||||
profil.mail.smtp_host = smtp.free.fr
|
||||
profil.mail.email.support = supportdev@scores-decisions.com
|
||||
profil.mail.email.supportdev = supportdev@scores-decisions.com
|
||||
profil.mail.email.contact = supportdev@scores-decisions.com
|
||||
profil.mail.email.production = supportdev@scores-decisions.com
|
||||
profil.wkhtmltopdf.path = "c:\Users\mricois\www\data\wkhtml"
|
||||
profil.wkhtmltopdf.arch = "amd64"
|
||||
profil.path.batch = APPLICATION_PATH "/../scripts/jobs"
|
||||
profil.path.cache = APPLICATION_PATH "/../data/cache"
|
||||
profil.path.files = APPLICATION_PATH "/../data/files"
|
||||
profil.path.log = APPLICATION_PATH "/../data/log"
|
||||
profil.path.data = "c:\Users\mricois\www\dataws"
|
||||
profil.path.secure = "c:\Users\mricois\www\dataws"
|
||||
|
||||
profil.sphinx.ent.host = "192.168.78.252"
|
||||
profil.sphinx.ent.port = 3312
|
||||
profil.sphinx.ent.version = 2
|
||||
profil.sphinx.dir.host = "192.168.78.252"
|
||||
profil.sphinx.dir.port = 3312
|
||||
profil.sphinx.dir.version = 2
|
||||
profil.sphinx.act.host = "192.168.78.252"
|
||||
profil.sphinx.act.port = 3312
|
||||
profil.sphinx.act.version = 2
|
||||
profil.sphinx.histo.host = "192.168.78.252"
|
||||
profil.sphinx.histo.port = 3312
|
||||
profil.sphinx.histo.version = 2
|
||||
|
||||
; For old configuration - see WsScores/Configure.php
|
||||
profil.db.default.adapter=mysqli
|
||||
profil.db.default.params.host=192.168.78.230
|
||||
profil.db.default.params.username=user
|
||||
profil.db.default.params.password=password
|
||||
profil.db.default.params.driver_options.MYSQLI_INIT_COMMAND = "SET NAMES utf8"
|
||||
|
||||
; Complete database configuration
|
||||
profil.db.sdv1.adapter=mysqli
|
||||
profil.db.sdv1.params.host=192.168.78.230
|
||||
profil.db.sdv1.params.username=user
|
||||
profil.db.sdv1.params.password=password
|
||||
profil.db.sdv1.params.dbname=sdv1
|
||||
profil.db.sdv1.params.driver_options.MYSQLI_INIT_COMMAND = "SET NAMES utf8"
|
||||
profil.db.sdv1.params.persistent = true
|
||||
|
||||
profil.db.jo.adapter=mysqli
|
||||
profil.db.jo.params.host=192.168.78.230
|
||||
profil.db.jo.params.username=user
|
||||
profil.db.jo.params.password=password
|
||||
profil.db.jo.params.dbname=jo
|
||||
profil.db.jo.params.driver_options.MYSQLI_INIT_COMMAND = "SET NAMES utf8"
|
||||
profil.db.jo.params.persistent = true
|
||||
|
||||
profil.db.historiques.adapter=mysqli
|
||||
profil.db.historiques.params.host=192.168.78.230
|
||||
profil.db.historiques.params.username=user
|
||||
profil.db.historiques.params.password=password
|
||||
profil.db.historiques.params.dbname=historiques
|
||||
profil.db.historiques.params.driver_options.MYSQLI_INIT_COMMAND = "SET NAMES utf8"
|
||||
profil.db.historiques.params.persistent = true
|
||||
|
||||
|
||||
[staging : production]
|
||||
resources.frontController.params.displayExceptions = 1
|
||||
|
||||
[development : production]
|
||||
phpSettings.display_startup_errors = 1
|
||||
phpSettings.display_errors = 1
|
||||
resources.frontController.params.displayExceptions = 1
|
||||
|
||||
[testing : production]
|
||||
phpSettings.display_startup_errors = 1
|
||||
phpSettings.display_errors = 1
|
93
scripts/build/config/sdsrvdev01/application.ini
Normal file
93
scripts/build/config/sdsrvdev01/application.ini
Normal file
@ -0,0 +1,93 @@
|
||||
[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.session.save_path = APPLICATION_PATH "/../data/sessions"
|
||||
resources.frontController.controllerDirectory = APPLICATION_PATH "/controllers"
|
||||
resources.frontController.plugins.Auth = "Application_Controller_Plugin_Auth"
|
||||
resources.frontController.params.displayExceptions = 0
|
||||
resources.layout.layout = "main"
|
||||
resources.layout.layoutPath = APPLICATION_PATH "/views"
|
||||
resources.view.basePath = APPLICATION_PATH "/views"
|
||||
autoloaderNamespaces[] = "Application_"
|
||||
autoloaderNamespaces[] = "Scores_"
|
||||
autoloaderNamespaces[] = "Form_"
|
||||
|
||||
; Scores configuration
|
||||
profil.server.name = development
|
||||
profil.mail.method = smtp
|
||||
profil.mail.smtp_host = smtp.free.fr
|
||||
profil.mail.email.support = supportdev@scores-decisions.com
|
||||
profil.mail.email.supportdev = supportdev@scores-decisions.com
|
||||
profil.mail.email.contact = supportdev@scores-decisions.com
|
||||
profil.mail.email.production = supportdev@scores-decisions.com
|
||||
profil.wkhtmltopdf.path = "c:\Users\mricois\www\data\wkhtml"
|
||||
profil.wkhtmltopdf.arch = "amd64"
|
||||
profil.path.batch = APPLICATION_PATH "/../scripts/jobs"
|
||||
profil.path.cache = APPLICATION_PATH "/../data/cache"
|
||||
profil.path.files = APPLICATION_PATH "/../data/files" ; DOC_WEB_LOCAL
|
||||
profil.path.data = "/home/vhosts/dataws/"
|
||||
profil.path.secure = "/mnt/datafile/" ; SECURE_STORAGE
|
||||
|
||||
; For old configuration - see Configure.php
|
||||
profil.db.default.adapter=mysqli
|
||||
profil.db.default.params.host=127.0.0.1
|
||||
profil.db.default.params.username=root
|
||||
profil.db.default.params.password=bj10sx
|
||||
profil.db.default.params.driver_options.MYSQLI_INIT_COMMAND = "SET NAMES utf8"
|
||||
|
||||
; Complete database configuration
|
||||
profil.db.sdv1.adapter=mysqli
|
||||
profil.db.sdv1.params.host=192.168.78.230
|
||||
profil.db.sdv1.params.username=wsuser
|
||||
profil.db.sdv1.params.password=scores
|
||||
profil.db.sdv1.params.dbname=sdv1
|
||||
profil.db.sdv1.params.driver_options.MYSQLI_INIT_COMMAND = "SET NAMES utf8"
|
||||
profil.db.sdv1.params.persistent = true
|
||||
|
||||
profil.db.jo.adapter=mysqli
|
||||
profil.db.jo.params.host=192.168.78.230
|
||||
profil.db.jo.params.username=wsuser
|
||||
profil.db.jo.params.password=scores
|
||||
profil.db.jo.params.dbname=jo
|
||||
profil.db.jo.params.driver_options.MYSQLI_INIT_COMMAND = "SET NAMES utf8"
|
||||
profil.db.jo.params.persistent = true
|
||||
|
||||
profil.db.historiques.adapter=mysqli
|
||||
profil.db.historiques.params.host=192.168.78.230
|
||||
profil.db.historiques.params.username=wsuser
|
||||
profil.db.historiques.params.password=scores
|
||||
profil.db.historiques.params.dbname=historiques
|
||||
profil.db.historiques.params.driver_options.MYSQLI_INIT_COMMAND = "SET NAMES utf8"
|
||||
profil.db.historiques.params.persistent = true
|
||||
|
||||
profil.db.Commandes.adapter=mysqli
|
||||
profil.db.Commandes.params.host=127.0.0.1
|
||||
profil.db.Commandes.params.username=wsuser
|
||||
profil.db.Commandes.params.password=wspass2012
|
||||
profil.db.Commandes.params.dbname=commandes
|
||||
profil.db.Commandes.params.driver_options.MYSQLI_INIT_COMMAND = "SET NAMES utf8"
|
||||
profil.db.Commandes.params.persistent = true
|
||||
|
||||
profil.db.Webservice.adapter=mysqli
|
||||
profil.db.Webservice.params.host=127.0.0.1
|
||||
profil.db.Webservice.params.username=wsuser
|
||||
profil.db.Webservice.params.password=wspass2012
|
||||
profil.db.Webservice.params.dbname=webservice
|
||||
profil.db.Webservice.params.driver_options.MYSQLI_INIT_COMMAND = "SET NAMES utf8"
|
||||
profil.db.WebServices.params.persistent = true
|
||||
|
||||
[staging : production]
|
||||
resources.frontController.params.displayExceptions = 1
|
||||
|
||||
[development : production]
|
||||
phpSettings.display_startup_errors = 1
|
||||
phpSettings.display_errors = 1
|
||||
resources.frontController.params.displayExceptions = 1
|
||||
|
||||
[testing : production]
|
||||
phpSettings.display_startup_errors = 1
|
||||
phpSettings.display_errors = 1
|
93
scripts/build/configure.php
Normal file
93
scripts/build/configure.php
Normal file
@ -0,0 +1,93 @@
|
||||
<?php
|
||||
//error_reporting(E_ALL & ~E_NOTICE);
|
||||
|
||||
// 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(),
|
||||
)));
|
||||
|
||||
//Copy configuration
|
||||
$configDir = realpath(dirname(__FILE__)).'/config';
|
||||
$appconfigDir = APPLICATION_PATH.'/configs';
|
||||
$hostname = exec('echo $(hostname)');
|
||||
|
||||
passthru('cp -fv '. $configDir.'/'.$hostname.'/application.ini' . ' ' .$appconfigDir.'/application.ini');
|
||||
|
||||
/** 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|?' => "Affiche les informations d'utilisation",
|
||||
'check' => "Vérifie la configuration suivant le fichier de config installé",
|
||||
'install' => "Installe et configure",
|
||||
)
|
||||
);
|
||||
$opts->parse();
|
||||
} catch (Zend_Console_Getopt_Exception $e) {
|
||||
echo $e->getUsageMessage();
|
||||
exit;
|
||||
}
|
||||
|
||||
//Usage
|
||||
if(isset($opts->help))
|
||||
{
|
||||
echo $opts->getUsageMessage();
|
||||
exit;
|
||||
}
|
||||
|
||||
$c = new Zend_Config($application->getOptions());
|
||||
|
||||
if(isset($opts->check))
|
||||
{
|
||||
|
||||
}
|
||||
elseif(isset($opts->install))
|
||||
{
|
||||
//Create data directory and all his children
|
||||
mkdir(APPLICATION_PATH.'/../data');
|
||||
mkdir(APPLICATION_PATH.'/../data/cache');
|
||||
mkdir(APPLICATION_PATH.'/../data/files');
|
||||
mkdir(APPLICATION_PATH.'/../data/log');
|
||||
mkdir(APPLICATION_PATH.'/../data/sessions');
|
||||
|
||||
//Copy files
|
||||
passthru('cp -v '.realpath(dirname(__FILE__)).'/_files/* '.$c->profil->path->files.'/');
|
||||
|
||||
//Modification des permissions
|
||||
passthru('chown -R www-data: '.APPLICATION_PATH.'/../');
|
||||
|
||||
//Création des liens symboliques pour l'impression
|
||||
if (!file_exists($c->profil->path->pages.'/themes/default/images'))
|
||||
passthru('ln -vs '.APPLICATION_PATH.'/../public/themes/default/images '.
|
||||
$c->profil->path->pages.'/themes/default/images');
|
||||
|
||||
if (!file_exists($c->profil->path->pages.'/themes/default/scripts'))
|
||||
passthru('ln -vs '.APPLICATION_PATH.'/../public/themes/default/scripts '.
|
||||
$c->profil->path->pages.'/themes/default/scripts');
|
||||
|
||||
if (!file_exists($c->profil->path->pages.'/fichier/imgcache'))
|
||||
passthru('ln -vs '.APPLICATION_PATH.'/../data/pages/imgcache'.' '.
|
||||
$c->profil->path->pages.'/fichier/imgcache');
|
||||
|
||||
if (!file_exists($c->profil->path->pages.'/fichier/logo'))
|
||||
passthru('ln -vs '.$c->profil->path.'/logos '.$c->profil->path->pages.'/fichier/logo');
|
||||
|
||||
}
|
284
scripts/jobs/calculRatios.php
Normal file
284
scripts/jobs/calculRatios.php
Normal file
@ -0,0 +1,284 @@
|
||||
<?php
|
||||
ini_set('memory_limit', '1024M');
|
||||
error_reporting(E_ALL & ~E_NOTICE);
|
||||
|
||||
// Define path to application directory
|
||||
defined('APPLICATION_PATH')
|
||||
|| define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../../application'));
|
||||
|
||||
// Ensure library/ is on include_path
|
||||
set_include_path(implode(PATH_SEPARATOR, array(
|
||||
realpath(APPLICATION_PATH . '/../library'),
|
||||
get_include_path(),
|
||||
)));
|
||||
|
||||
$c = new Zend_Config($application->getOptions());
|
||||
Zend_Registry::set('config', $c);
|
||||
|
||||
require_once 'WsScore/Configure.php';
|
||||
$oldconfig = new Configure();
|
||||
|
||||
require_once 'framework/fwk.php';
|
||||
require_once 'framework/common/chiffres.php';
|
||||
require_once 'framework/common/dates.php';
|
||||
require_once 'framework/mail/sendMail.php';
|
||||
require_once 'Metier/insee/classMInsee.php';
|
||||
require_once 'Metier/partenaires/classMGreffes.php';
|
||||
require_once 'Metier/partenaires/classMBilans.php';
|
||||
|
||||
$strInfoScript='Usage : '.basename($argv[0]). " [OPTION]
|
||||
Mise à jour des ratios en fonction de l'arrivée de nouveaux Bilans dans la base entreprise S&D.
|
||||
|
||||
Options :
|
||||
-t Calculer tous les ratios (*)
|
||||
-i:XXX Reprendre à la ligne XXX
|
||||
-c Mettre à jour le cache
|
||||
-d:SSAAMMJJhhiiss Forcer la date de dernière MAJ à ...
|
||||
|
||||
(*) Option par défaut si aucun argument n'est passé.
|
||||
";
|
||||
|
||||
$iDeb=0;
|
||||
$updateCache=false;
|
||||
|
||||
for ($i=1; isset($argv[$i]); $i++) {
|
||||
if (substr($argv[$i],0,1)=='-') {
|
||||
switch (strtolower(substr($argv[$i],1,1))) {
|
||||
case 't':
|
||||
break;
|
||||
case 'i':
|
||||
$iDeb=substr($argv[$i],3)*1;
|
||||
break;
|
||||
case 'd':
|
||||
$dateDeb=substr($argv[$i],3)*1;
|
||||
break;
|
||||
case 'c':
|
||||
$updateCache=true;
|
||||
break;
|
||||
case '-':
|
||||
case '?':
|
||||
die($strInfoScript);
|
||||
break;
|
||||
default:
|
||||
die('Option '. $argv[$i] . ' inconnue !'.EOL);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//$iDbI=new WDB('insee');
|
||||
$iDb=new WDB('jo');
|
||||
$iDb2=new WDB('jo');
|
||||
$iInsee=new MInsee();
|
||||
|
||||
if ($updateCache) {
|
||||
include_once 'Metier/scores/classMRatios.php';
|
||||
if (genereCacheRatios())
|
||||
echo date('Y/m/d - H:i:s') ." - Le cache des ratios a été généré avec succès !".EOL;
|
||||
else
|
||||
echo date('Y/m/d - H:i:s') ." - Erreur lors de la génération du cache des ratios !".EOL;
|
||||
die();
|
||||
}
|
||||
|
||||
echo date('Y/m/d - H:i:s') ." - DEBUT du programme de calcul des ratios...".EOL;
|
||||
|
||||
$tabLast=$iDb->select( 'ratios_formules',
|
||||
'max(dateUpdate) AS lastUpdate, max(dateInsert) AS lastInsert',
|
||||
'1');
|
||||
$lastUpdate=$tabLast[0]['lastInsert'];
|
||||
if ($tabLast[0]['lastUpdate']>$lastUpdate) $lastUpdate=$tabLast[0]['lastUpdate'];
|
||||
|
||||
/** On vérifie la présence du cache de calcul des ratios **/
|
||||
$pathMetier = realpath(APPLICATION_PATH . '/../library/Metier');
|
||||
if (!file_exists($pathMetier.'/tmp/configMRatios.php'))
|
||||
die(date('Y/m/d - H:i:s') ." - ERREUR FATALE : Le cache des calculs de ratio n'existe pas !".EOL);
|
||||
/** On vérifie qu'il n'y a pas de nouvelles formules à mettre dans le cache de calcul des ratios **/
|
||||
elseif (strtr($lastUpdate, array(':'=>'','-'=>'', ' '=>''))>date('YmdHis',filectime($pathMetier.'/tmp/configMRatios.php'))) {
|
||||
sendMail('production@scores-decisions.com', 'ylenaour@scores-decisions.com', "ERREUR FATALE, le cache ratio n'est pas à jour !", date('Y/m/d - H:i:s') ." - ERREUR FATALE : Le cache des calculs de ratio n'est pas à jour (nouvelles formules ?). Relancer à l'option -c !");
|
||||
die(date('Y/m/d - H:i:s') ." - ERREUR FATALE : Le cache des calculs de ratio n'est pas à jour (nouvelles formules ?). Relancer à l'option -c !".EOL);
|
||||
}
|
||||
/** On vérifie que le programme de MAJ du cache n'a pas été modifié **/
|
||||
elseif (date('YmdHis',filectime($pathMetier.'/scores/classMRatios.php'))>date('YmdHis',filectime($pathMetier.'/tmp/configMRatios.php'))) // Le fichier de cache est déprécié
|
||||
die(date('Y/m/d - H:i:s') ." - ERREUR FATALE : Le cache des calculs de ratio n'est pas à jour (programme modifié). Relancer à l'option -c !".EOL);
|
||||
|
||||
include_once 'Metier/tmp/configMRatios.php';
|
||||
|
||||
echo date('Y/m/d - H:i:s') ." - Formules de calcul des ratios déjà en cache.".EOL;
|
||||
|
||||
/** Recherche de la dernière mise à jour des ratios secteurs **/
|
||||
$tabLast=$iDb->select( 'ratios_secteurs',
|
||||
'max(dateUpdate) AS lastUpdate, max(dateInsert) AS lastInsert',
|
||||
'1');
|
||||
$lastUpdate=$tabLast[0]['lastInsert'];
|
||||
if ($tabLast[0]['lastUpdate']>$lastUpdate) $lastUpdate=$tabLast[0]['lastUpdate'];
|
||||
if ($dateDeb>20000101123000) $lastUpdate=$dateDeb;
|
||||
|
||||
echo(date('Y/m/d - H:i:s') ." - La dernière mise à jour des ratios secteurs date du $lastUpdate...".EOL);
|
||||
|
||||
$nbRows=$iDb->select( 'ratios_tmp', 'siren, lastUpdate', "1", false, MYSQL_ASSOC, true);
|
||||
if ($nbRows>0) {
|
||||
$modeSuite=true;
|
||||
echo date('Y/m/d - H:i:s') ." - Il reste $nbRows entreprises pour lesquels il faut mettre à jour les ratios secteurs...".EOL;
|
||||
} else {
|
||||
/** On met en table temporaire les siren en cas de plantage du script **/
|
||||
$modeSuite=false;
|
||||
|
||||
// Date du dernier bilan inseré
|
||||
$tabLast=$iDb->select( 'bilans',
|
||||
'MAX(dateInsert) AS lastDateInsert',
|
||||
"siren>100 AND dateInsert>='$lastUpdate' AND typeBilan IN ('N','',' ','A','B') ORDER BY dateInsert DESC");
|
||||
$lastDateBilan=strtr($tabLast[0]['lastDateInsert'],array(' '=>'',':'=>'','-'=>''));
|
||||
echo(date('Y/m/d - H:i:s') ." - Le dernier bilan inséré en base date du $lastDateBilan...".EOL);
|
||||
|
||||
// Liste des derniers Bilans insérés depuis le dernier calcul des ratios
|
||||
$nbRows=$iDb->select( 'bilans', 'DISTINCT siren', "siren>100 AND dateInsert>='$lastUpdate' AND typeBilan IN ('N','',' ','A','B') ORDER BY dateInsert DESC", false, MYSQL_ASSOC, true);
|
||||
$lastDate=strtr($lastUpdate,array(' '=>'',':'=>'','-'=>''));
|
||||
echo date('Y/m/d - H:i:s') ." - Il y a $nbRows entreprises avec nouveaux bilans pour calcul des ratios secteurs...".EOL;
|
||||
$iDb2->query('DROP TABLE IF EXISTS ratios_tmp;');
|
||||
if (mysql_errno()>0) echo date('Y/m/d - H:i:s') .' - ERREUR SQL lors de la création de la table temporaires, n°'.mysql_errno().' : '.mysql_error().EOL;
|
||||
$strSQL="CREATE TABLE IF NOT EXISTS ratios_tmp ( siren int(9) unsigned zerofill NOT NULL, lastUpdate bigint(14) unsigned zerofill NOT NULL, lastBilan bigint(14) unsigned zerofill NOT NULL, PRIMARY KEY(siren) ) ENGINE=MyISAM DEFAULT CHARSET=latin1;";
|
||||
$iDb2->query($strSQL);
|
||||
if (mysql_errno()>0) echo date('Y/m/d - H:i:s') .' - ERREUR SQL lors de la création de la table temporaires, n°'.mysql_errno().' : '.mysql_error().EOL;
|
||||
while($entrep=$iDb->fetch(MYSQL_ASSOC)) {
|
||||
$iDb2->insert('ratios_tmp', array('siren'=>$entrep['siren'], 'lastUpdate'=>$lastDate, 'lastBilan'=>$lastDateBilan));
|
||||
}
|
||||
echo date('Y/m/d - H:i:s') ." - Les éléments ont été mis en table temporaire en cas de reprise sur erreur !".EOL;
|
||||
$nbRows=$iDb->select( 'ratios_tmp', 'siren, lastUpdate, lastBilan', "1", false, MYSQL_ASSOC, true);
|
||||
}
|
||||
|
||||
$k=0; // Compteur d'entreprises
|
||||
$b=0; // Compteur total de bilans
|
||||
while($entrep=$iDb->fetch(MYSQL_ASSOC)) {
|
||||
if ($modeSuite && $k==0) $lastDate=$entrep['lastUpdate'];
|
||||
|
||||
$k++;
|
||||
if ($k<$iDeb) continue;
|
||||
|
||||
$siren=$entrep['siren'];
|
||||
if ($siren<100) continue;
|
||||
// else echo "$siren\n";
|
||||
$naf4=$naf5='';
|
||||
unset($mBil);
|
||||
|
||||
$mBil=new MBilans($siren);
|
||||
|
||||
/** Récupération des informations Identitaires **/
|
||||
$tabIdentite=@$iInsee->getIdentiteLight($siren);
|
||||
$naf=$tabIdentite['NafEnt'];
|
||||
$nafLib=$tabIdentite['NafEntLib'];
|
||||
$efftr=$tabIdentite['Effectif'];
|
||||
$fj=$tabIdentite['FJ'];
|
||||
|
||||
/** On Recherche le dernier Bilan mis à jour **/
|
||||
$tabBilans=$mBil->listeBilans();
|
||||
$nbBilansTot=count($tabBilans);
|
||||
$tabBilans2=array();
|
||||
foreach ($tabBilans as $mil=>$infosBilan) {
|
||||
/** On vérifie s'il n'y a pas de Bilans vides **/
|
||||
if ($infosBilan['dureeExercice']==0) {
|
||||
print_r($infosBilan);
|
||||
echo date('Y/m/d - H:i:s') ." - Erreur : Bilans vide en base pour le siren $siren !".EOL;
|
||||
continue(2);
|
||||
}
|
||||
/** On ne garde que les Bilans dont la date de provenance est > à la date de dernière Mise à jour
|
||||
** car les ratios secteurs des autres bilans on déjà été calculés ! **/
|
||||
if ($infosBilan['dateInsert']>=$lastDate)
|
||||
$tabBilans2[$mil]=$infosBilan;
|
||||
}
|
||||
|
||||
$nbBilans=count($tabBilans2);
|
||||
$tabBilan=$tabBil=array();
|
||||
if ($nbBilans==0) {
|
||||
print_r($tabBilans2);
|
||||
echo date('Y/m/d - H:i:s') ." - Erreur : Aucun nouveau bilan en base pour le siren $siren sur les $nbBilansTot bilans !".EOL;
|
||||
print_r($tabBilans);
|
||||
//die();
|
||||
continue;
|
||||
}
|
||||
|
||||
$tabRatios=@calculRatios($tabBilans2, $tabIdentite, false);
|
||||
if (strlen($naf)>4) $naf5=$naf; else $naf4=$naf;
|
||||
|
||||
if ($tabBilan[0]['CONSOLIDE']=='A') $naf4='ASSU';
|
||||
elseif ($tabBilan[0]['CONSOLIDE']=='B') $naf4='BANQ';
|
||||
|
||||
if ($naf4=='ASSU' || $naf4=='BANQ') {
|
||||
sendMail('production@scores-decisions.com', 'ylenaour@scores-decisions.com', "Calcul des ratios : Attention bilan de Banque ou Assurance", "Siren $siren, bilan $naf4".EOL.print_r($tabBilans));
|
||||
}
|
||||
|
||||
foreach ($tabFormules as $f=>$formule) {
|
||||
foreach ($tabRatios as $i=>$R) {
|
||||
if ($f==0) $b++;
|
||||
$id=$formule['id'];
|
||||
// Si on n'est pas une banque/assurance, on ne calcul pas les ratios 700 à 799
|
||||
if ($naf4<>'ASSU' && $naf4<>'BANQ' && $id>=700 && $id<800)
|
||||
continue;
|
||||
|
||||
$annee=substr($tabBilan[$i]['DATE_CLOTURE'],0,4);
|
||||
|
||||
if ($R[$id]==='NS' || $R[$id]===false )
|
||||
//echo "Le ratio n°$id est non significatif (".$R[$id].") pour le siren $siren et l'année $annee !".EOL;
|
||||
continue;
|
||||
|
||||
|
||||
/** Si c'est un ratio EUR, on le passe en K€ **/
|
||||
if ($formule['unite']=='EUR') $mt=$R[$id]/1000;
|
||||
else $mt=$R[$id];
|
||||
|
||||
/** On vérifie les bornes MIN et MAX **/
|
||||
if ($formule['min']<>'' && $mt<$formule['min']) {
|
||||
echo "Ratio n°$id, borne Mini non nulle (".$formule['min'].") et le montant est inférieur : $mt<".$formule['min']." pour le siren $siren et l'année $annee".EOL;
|
||||
continue;
|
||||
} elseif ($formule['max']<>'' && $mt>$formule['max']) {
|
||||
echo "Ratio n°$id, borne Maxi non nulle (".$formule['max'].") et le montant est supérieur : $mt>".$formule['max']." pour le siren $siren et l'année $annee".EOL;
|
||||
continue;
|
||||
} //else
|
||||
//echo "Ratio n°$id compris entre bornes ".$formule['min']." < $mt < ".$formule['max']." pour le siren $siren et l'année $annee".EOL;
|
||||
|
||||
/** Lecture des chiffres existants dans la table ratios_secteurs **/
|
||||
$tabTmp=$iDb2->select( 'ratios_secteurs',
|
||||
'montant, nombre, id, naf4, naf5, annee',
|
||||
"id=$id AND naf4='$naf4' AND naf5='$naf5' AND annee=$annee",
|
||||
false, MYSQL_ASSOC);
|
||||
if (count($tabTmp)>0) {
|
||||
$mt2=$mt+$tabTmp[0]['montant'];
|
||||
$nb2=$tabTmp[0]['nombre'] + 1;
|
||||
} else {
|
||||
$mt2=$mt;
|
||||
$nb2=1;
|
||||
}
|
||||
|
||||
$tabUpdate=array( 'montant' => $mt2,
|
||||
'nombre' => $nb2,
|
||||
);
|
||||
if (!$iDb2->update('ratios_secteurs', $tabUpdate, "id=$id AND naf4='$naf4' AND naf5='$naf5' AND annee=$annee") || $iDb2->getAffectedRows()==0 ) { // getAffectedRows ajouté le 14 mai 2009
|
||||
$tabInsert=array_merge($tabUpdate, array( 'id'=>$id,
|
||||
'naf4'=>$naf4,
|
||||
'naf5'=>$naf5,
|
||||
'annee'=>$annee,
|
||||
'dateInsert'=>$lastDateBilan,
|
||||
));
|
||||
if (!$iDb2->insert('ratios_secteurs', $tabInsert) && mysql_errno()<>1062) {
|
||||
$pct=round(($k/$nbRows)*100,2);
|
||||
echo date('Y/m/d - H:i:s') ." - $k entreprises ($pct %) dont les ratios ont été calculés pour un total de $b bilans ($siren)...".EOL;
|
||||
echo date('Y/m/d - H:i:s') .' - ERREUR SQL n°'.mysql_errno().' : '.mysql_error().EOL;
|
||||
die();
|
||||
}
|
||||
}
|
||||
|
||||
if ($k%1000==0 && $f==0 && $i==0) {
|
||||
$pct=round(($k/$nbRows)*100,2);
|
||||
echo date('Y/m/d - H:i:s') ." - $k entreprises ($pct %) dont les ratios ont été calculés pour un total de $b bilans ($siren)...".EOL;
|
||||
}
|
||||
}
|
||||
}
|
||||
$iDb2->delete('ratios_tmp', "siren=$siren");
|
||||
if (mysql_errno()>0) echo date('Y/m/d - H:i:s') .' - ERREUR SQL lors de la suppression des informations temporaires, n°'.mysql_errno().' : '.mysql_error().EOL;
|
||||
}
|
||||
echo date('Y/m/d - H:i:s') ." - Les ratios ont été mis à jour ; suppression des informations temporaires.".EOL;
|
||||
|
||||
$iDb2->query('DROP TABLE IF EXISTS jo.ratios_tmp;');
|
||||
|
||||
die(date('Y/m/d - H:i:s') ." - Fin du programme.".EOL);
|
||||
|
||||
?>
|
585
scripts/jobs/genCodeRatios.php
Normal file
585
scripts/jobs/genCodeRatios.php
Normal file
@ -0,0 +1,585 @@
|
||||
<?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') : 'development'));
|
||||
|
||||
// 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.",
|
||||
'indiscore-s' => "Génére le code tmp/indiscore_\$versions.php",
|
||||
'type-s' => "Choix du type d'indiScore : scores ou valo",
|
||||
'ratios' => "Génére le cache des ratios (tmp/configMRatios.php)"
|
||||
)
|
||||
);
|
||||
$opts->parse();
|
||||
} catch (Zend_Console_Getopt_Exception $e) {
|
||||
echo $e->getUsageMessage();
|
||||
exit;
|
||||
}
|
||||
|
||||
//Usage
|
||||
if( count($opts->getOptions())==0 || isset($opts->help))
|
||||
{
|
||||
echo $opts->getUsageMessage();
|
||||
exit;
|
||||
}
|
||||
|
||||
$c = new Zend_Config($application->getOptions());
|
||||
Zend_Registry::set('config', $c);
|
||||
|
||||
require_once 'WsScore/Configure.php';
|
||||
$oldconfig = new Configure();
|
||||
|
||||
require_once 'framework/fwk.php';
|
||||
require_once 'framework/common/chiffres.php';
|
||||
require_once 'framework/common/dates.php';
|
||||
require_once 'framework/mail/sendMail.php';
|
||||
require_once 'Metier/insee/classMInsee.php';
|
||||
require_once 'Metier/partenaires/classMGreffes.php';
|
||||
require_once 'Metier/partenaires/classMBilans.php';
|
||||
|
||||
if (isset($opts->ratios)){
|
||||
genereCacheRatios();
|
||||
}
|
||||
|
||||
if ( isset($opts->indiscore) ) {
|
||||
|
||||
if ( isset($opts->type) && in_array($opts->type, array('scores', 'valo')) ) {
|
||||
$type = $opts->type;
|
||||
} else {
|
||||
$type = 'scores';
|
||||
}
|
||||
|
||||
if (genereCacheIndiscore($opts->indiscore, $type) === true){
|
||||
echo "Code généré. \n";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Make the static data file cache configMRatios.tmp.php
|
||||
* Must be rename as configRatios.php
|
||||
*/
|
||||
function genereCacheRatios()
|
||||
{
|
||||
$tabMoy=array();
|
||||
$iDb=new WDB("jo");
|
||||
$tabTmp=$iDb->select("sdv1.inflation", "annee, infla", "annee>1990 ORDER BY annee", false, MYSQL_ASSOC);
|
||||
$strFonctions= "\$tabInfla=array();\n";
|
||||
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];
|
||||
}';
|
||||
|
||||
$configFileTmp = APPLICATION_PATH.'/../library/Metier/tmp/configMRatios.tmp.php';
|
||||
$configFile = APPLICATION_PATH.'/../library/Metier/tmp/configMRatios.php';
|
||||
|
||||
$fp=fopen($configFileTmp, 'w');
|
||||
fwrite($fp, '<?php'."\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;";
|
||||
}
|
||||
$formule2=$formule1;
|
||||
|
||||
fwrite($fp, "\t\t".$formule2."\n");
|
||||
//@eval($formule2);
|
||||
fwrite($fp, "\t\t".'if (!isset($R['.$id.'])) $R['.$id.']=\'NS\';'."\n");
|
||||
if (!isset($R[$id])) $R[$id]='NS';
|
||||
}
|
||||
|
||||
fwrite($fp, "\n\t\t".'$tabRatios[$numBil]=$R;'."\n");
|
||||
fwrite($fp, "\t\t".'$numBil++;'."\n");
|
||||
fwrite($fp, "\t\t".'}'."\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, "\t".'return $tabRatios;'."\n");
|
||||
fwrite($fp, '}'."\n");
|
||||
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)."\n");
|
||||
print_r($output);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Make the static file cache for indIscore
|
||||
* (indiscore.tmp.php, must be rename as indiscore$version.php)
|
||||
* @param string $version ex : "_XXX" where XXX is the number version to select the right table in
|
||||
* database
|
||||
* @param string $type
|
||||
* scores : Comments for the score version, valo : Comments for the "valorisation" version
|
||||
* @return string
|
||||
*/
|
||||
function genereCacheIndiscore($version, $type = 'scores')
|
||||
{
|
||||
$cycleClient = 2;
|
||||
|
||||
// Chargement des formules de commentaires
|
||||
$tabFormulesScore=array();
|
||||
|
||||
$iDb = new WDB("jo");
|
||||
|
||||
// Select the right table in database in function of type
|
||||
switch ($type) {
|
||||
case 'scores':
|
||||
$fileIndiscore = APPLICATION_PATH.'/../library/Metier/tmp/indiscore'.$version.'.php';
|
||||
$fileIndiscoreTmp = APPLICATION_PATH.'/../library/Metier/tmp/indiscore.tmp.php';
|
||||
$tableComments = 'scores_commentaires'.$version;
|
||||
$tableFormu = 'scores_formules'.$version;
|
||||
break;
|
||||
|
||||
case 'valo':
|
||||
$fileIndiscore = APPLICATION_PATH.'/../library/Metier/tmp/indiscorevalo'.$version.'.php';
|
||||
$fileIndiscoreTmp = APPLICATION_PATH.'/../library/Metier/tmp/indiscorevalo.tmp.php';
|
||||
$tableComments = 'valo_commentaires'.$version;
|
||||
$tableFormu = 'valo_formules'.$version;
|
||||
break;
|
||||
}
|
||||
|
||||
// Read comments text
|
||||
$tabTmp = $iDb->select(
|
||||
$tableComments,
|
||||
'code, langue, cycle, ligne, commentaire, tri, deleted',
|
||||
"deleted=0 AND cycle=$cycleClient AND ligne NOT LIKE '%*%' AND commentaire NOT LIKE '.*%' ORDER BY langue ASC, cycle ASC, code ASC, ligne ASC",
|
||||
false, MYSQL_ASSOC
|
||||
);
|
||||
|
||||
foreach ($tabTmp as $i => $commentaire) {
|
||||
$id = $commentaire['code']*1;
|
||||
$cycle = $commentaire['cycle']*1;
|
||||
$ligne = $commentaire['ligne']*1;
|
||||
$tabCommentaires[$id][$cycle][$ligne] = $commentaire['commentaire'];
|
||||
if ($commentaire['tri']) {
|
||||
$tabTri[$id] = $commentaire['tri'];
|
||||
$tabTriAff[$id] = ($commentaire['tri'].'.'.(10000000+(1*$commentaire['code'])))*1;
|
||||
}
|
||||
}
|
||||
|
||||
// Read formulas
|
||||
$tabTmp = $iDb->select(
|
||||
$tableFormu,
|
||||
'code, ligne, remarque, operande, ope1, operation, valeur',
|
||||
"deleted=0 AND ligne NOT LIKE '%*%' ORDER BY code ASC, ligne ASC",
|
||||
false, MYSQL_ASSOC
|
||||
);
|
||||
|
||||
|
||||
$idPre=$strFormule=false;
|
||||
//echo '<table border="1">';
|
||||
$debugFormule='';
|
||||
$fp2=fopen($fileIndiscoreTmp,'w');
|
||||
fwrite($fp2,'<?php'."\n");
|
||||
|
||||
$ECHANGE=array();
|
||||
foreach ($tabTmp as $i=>$formule) {
|
||||
|
||||
$id=$formule['code']*1;
|
||||
if ($idPre!=$id && $idPre!=false) {
|
||||
$debugFormule.=$strFormule.') { $C['.$idPre."]=true; $strAction } \t";
|
||||
//$strFormule=preg_replace('/\|(.+)\|/U', 'abs($1)', $strFormule);
|
||||
$strFormule=preg_replace('/\|([A-Z0-9\. \$\[\]]{1,12})\|/Ui', 'abs($1)', $strFormule);
|
||||
$strFormule=preg_replace('/\$R\[0+/', '$R[', $strFormule);
|
||||
$strFormule=preg_replace('/\$Ra\[0+/', '$Ra[', $strFormule);
|
||||
$strFormule=preg_replace('/\$Rap\[0+/', '$Rap[', $strFormule);
|
||||
$strFormule=preg_replace('/\$Rp\[0+/', '$Rp[', $strFormule);
|
||||
$strFormule=preg_replace('/\$Rs\[0+/', '$Rs[', $strFormule);
|
||||
$strFormule=preg_replace('/\$Rsp\[0+/', '$Rsp[', $strFormule);
|
||||
$strFormule=preg_replace('/\$Revol\[0+/', '$Revol[', $strFormule);
|
||||
$strFormule=preg_replace('/\$Revolp\[0+/', '$Revolp[', $strFormule);
|
||||
$strFormule=preg_replace('/\$Rdiff\[0+/', '$Rdiff[', $strFormule);
|
||||
for ($j=2;$j<5;$j++) {
|
||||
$strFormule=preg_replace('/\$Rp'.$j.'\[0+/', '$Rp'.$j.'[', $strFormule);
|
||||
$strFormule=preg_replace('/\$Rs'.$j.'\[0+/', '$Rs'.$j.'[', $strFormule);
|
||||
$strFormule=preg_replace('/\$Rsp'.$j.'\[0+/', '$Rsp'.$j.'[', $strFormule);
|
||||
$strFormule=preg_replace('/\$Revol'.$j.'\[0+/', '$Revol'.$j.'[', $strFormule);
|
||||
$strFormule=preg_replace('/\$Revolp'.$j.'\[0+/', '$Revolp'.$j.'[', $strFormule);
|
||||
}
|
||||
debugLog('W', 'Indiscore '.$strFormule.') $C['.$idPre.']='.$C[$idPre], __LINE__, __FILE__, __FUNCTION__, __CLASS__);
|
||||
//$fp2=fopen('/var/www/html/ws2/indiscore.tmp.php','a');
|
||||
// Cas particulier de la première lignde de commentaire
|
||||
//if ($i<=1) $remarque="// $id-".$formule['ligne'].' : '.trim($formule['remarque'].' '.$remarque);
|
||||
fwrite($fp2, $remarque."\n");
|
||||
fwrite($fp2, $strFormule.') { $C['.$idPre."]=true; $strAction } "."\n");
|
||||
//fclose($fp2);
|
||||
eval ($strFormule.') { $C['.$idPre."]=true; $strAction } ");
|
||||
$debugFormule.='$C['.$idPre.']='.$C[$idPre]."\r\n";
|
||||
$remarque="// $id-".$formule['ligne'].' : '.$formule['remarque'];
|
||||
$strAction='';
|
||||
} elseif (!$idPre)
|
||||
$remarque="// $id-".$formule['ligne'];
|
||||
else
|
||||
$remarque.=' '.$formule['remarque'];
|
||||
|
||||
$ligne=$formule['ligne']*1;
|
||||
|
||||
$operande=trim(strtr(strtoupper($formule['operande']),array(':'=>'')));
|
||||
$ope1=trim($formule['ope1']);
|
||||
/*P[xxx,+n] valeur Projection linéaire du ratio xxx sur n années Valeur du ratio au terme de l'année N +n années
|
||||
Pc[xxx,+n] ou Pc[xxx] Valeur du coefficient de corrélation de la régression linéaire Coef de 0 à 1 à transformer en % Pertinence de la corélation pour qu'elle soit bonne le coef doit > 0,75
|
||||
Pevol[xxx,n] Valeur du taux de progression au terme des N années Projection linéaire du ratio xxx sur N années Taux de progression entre la valeur du ratio en année N et sa valeur à +n années (même principe que Revol[xxx] pour les ratios)
|
||||
*/
|
||||
if (preg_match("/(PROJECTAUX|PROJECCOEF|PROJEC)\((.*)\)/Ui", $ope1, $matches))
|
||||
{
|
||||
$ope1=$matches[1].'($'.preg_replace('/R\[0+/', 'regR[', $matches[2]).')';
|
||||
}
|
||||
elseif (preg_match('/^LONG\(([A-Z0-9\_]{1,30})\)$/i', $ope1, $matches))
|
||||
{
|
||||
// Gestion du mot clef LONG
|
||||
$ope1=preg_replace('/^LONG\(([A-Z0-9\_]{1,30})\)$/i','strlen(\$$1)', $ope1);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Gestion du substr
|
||||
$ope1=preg_replace('/([A-Z0-9\_]{1,30})\((.*)\)$/i','substr(\$$1,$2)', $ope1);
|
||||
}
|
||||
|
||||
$operation=trim($formule['operation']);
|
||||
if ($operation=='=') $operation='==';
|
||||
|
||||
$valeur=trim(strtr($formule['valeur'], array('"'=>"'")));
|
||||
$tabFormulesScore[$id][$ligne]['operande']=$operande;
|
||||
$tabFormulesScore[$id][$ligne]['ope1']=$ope1;
|
||||
$tabFormulesScore[$id][$ligne]['operation']=$operation;
|
||||
$tabFormulesScore[$id][$ligne]['valeur']=$valeur;
|
||||
|
||||
if (preg_match("/^MOY\(R(.*),(.*)\)/Ui", $valeur, $matches)) {
|
||||
$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,30})\((.*)\)$/i','substr(\$$1,$2)', $valeur);
|
||||
}
|
||||
|
||||
|
||||
if ( !empty($valeur)
|
||||
|| substr($valeur,0,6)!='substr' && substr($valeur,0,1)!="'"
|
||||
|| !in_array($valeur, array('vrai', 'faux'))
|
||||
) {
|
||||
//file_put_contents('test.log', $valeur, FILE_APPEND);
|
||||
$valeur = preg_replace('/([A-Z][A-Z0-9\_]{1,29}|[A-Za-z0-9]{1,30}\[[0-9]+\])/' , '\$$1' , $valeur);
|
||||
//file_put_contents('test.log', " = ".$valeur."\n", FILE_APPEND);
|
||||
}
|
||||
|
||||
if (preg_match("/^substr|^projec|^strlen|^\||^'/i", $ope1)) {
|
||||
$ope1deb='';
|
||||
$ope1=strtr($ope1, array( '|R['=>'|$R[',
|
||||
'|Rp['=>'|$Rp[',
|
||||
'|Rp2['=>'|$Rp2[',
|
||||
'|Rp3['=>'|$Rp3[',
|
||||
'|Rs['=>'|$Rs[',
|
||||
'|Rsp['=>'|$Rsp[',
|
||||
'|Revol['=>'|$Revol[',
|
||||
'|Revolp['=>'|$Revolp[',
|
||||
'|Revols['=>'|$Revols[',
|
||||
'|Rdiff['=>'|$Rdiff[',
|
||||
));
|
||||
}
|
||||
else {
|
||||
$ope1deb='$';
|
||||
$ope1=strtr($ope1, array( '/R['=>'/$R[',
|
||||
'/Rp['=>'/$Rp[',
|
||||
'/Rp2['=>'/$Rp2[',
|
||||
'/Rp3['=>'/$Rp3[',
|
||||
'/Rs['=>'/$Rs[',
|
||||
'/Rsp['=>'/$Rsp[',
|
||||
'/Revol['=>'/$Revol[',
|
||||
'/Revolp['=>'/$Revolp[',
|
||||
'/Revols['=>'/$Revols[',
|
||||
'/Rdiff['=>'/$Rdiff[',
|
||||
));
|
||||
}
|
||||
//(C[5000100]àC[5000998])
|
||||
if (preg_match('/^C\[(.*)\]àC\[(.*)\]$/', $ope1, $matches)) {
|
||||
/** On veut savoir si des commentaires Cxx à Cyy sont chargés **/
|
||||
$tabTmp4=array();
|
||||
foreach ($tabTri as $idxC=>$t) {
|
||||
if ($idxC>=$matches[1] && $idxC<=$matches[2])
|
||||
$tabTmp4[]=' isset($C['.$idxC.']) ';
|
||||
}
|
||||
//@sendMail('production@scores-decisions.com', 'ylenaour@scores-decisions.com', "Indiscore sur $siren : Debug Code=$id, ligne=$ligne", print_r($matches, true).print_r($tabTmp4, true)."\n");
|
||||
$tmpFormule='true';
|
||||
// if (count($tabTmp4)>0 && preg_match('/NON/i',$operande))
|
||||
// $tmpFormule=' ('.implode(' && ', $tabTmp4).') ';
|
||||
//else
|
||||
if (count($tabTmp4)>0)
|
||||
$tmpFormule=' ('.implode(' || ', $tabTmp4).') ';
|
||||
} elseif (preg_match_all('/^\((C\[(.*)\];?)+\)$/', $ope1, $matches)) {
|
||||
//@sendMail('production@scores-decisions.com', 'ylenaour@scores-decisions.com', "Indiscore sur $siren : Debug", print_r($matches, true)."\n");
|
||||
$tabTmp5=explode(';', $matches[1][0]);// C[3255000];C[3260000];C[3265000]
|
||||
$tabTmp4=array();
|
||||
foreach ($tabTmp5 as $t)
|
||||
$tabTmp4[]=' isset($'.$t.') ';
|
||||
$tmpFormule='true';
|
||||
if (count($tabTmp4)>0 && preg_match('/NON/i',$operande))
|
||||
$tmpFormule=' ('.implode(' && ', $tabTmp4).') ';
|
||||
elseif (count($tabTmp4)>0)
|
||||
$tmpFormule=' ('.implode(' || ', $tabTmp4).') ';
|
||||
} elseif (($operation=='==' || $operation=='<>') && preg_match('/\(.*;.*\)/', $valeur)) {
|
||||
/** Gestion du point-virgule (correspond à un IN dans WHERE sql **/
|
||||
$tabTmp3=explode(';', $valeur);
|
||||
$tabTmp4=array();
|
||||
foreach ($tabTmp3 as $i3=>$svaleur)
|
||||
$tabTmp4[]=$ope1deb.$ope1.$operation.strtr($svaleur,array('('=>'', ')'=>'', ','=>'.'));
|
||||
if ($operation=='==') $tmpFormule=' ('.implode(' || ', $tabTmp4).') ';
|
||||
else $tmpFormule=implode(' && ', $tabTmp4);
|
||||
} elseif ($operande=='ET' && preg_match('/\(.*;.*\)/', $ope1)) {
|
||||
/** Gestion du point-virgule (correspond à un IN dans WHERE sql **/
|
||||
$tabTmp3=explode(';', $ope1);
|
||||
$tabTmp4=array();
|
||||
foreach ($tabTmp3 as $i3=>$ope1val)
|
||||
$tabTmp4[]=$ope1deb.strtr($ope1val,array('('=>'', ')'=>'', ','=>'.'));
|
||||
$tmpFormule=' ('.implode(' && ', $tabTmp4).') ';
|
||||
} elseif (preg_match('/(.*)à(.*)/', $valeur, $matches)) {
|
||||
/** Gestion du 'à' (correspond à min < xxx < max **/
|
||||
$tmpFormule=' ('.$ope1deb.$ope1.' >= '.$matches[1].' && '.$ope1deb.$ope1.' <= '.$matches[2].') ';
|
||||
} else {
|
||||
if (!preg_match("/^substr/", $valeur))
|
||||
$valeur=strtr($valeur,array(','=>'.'));
|
||||
|
||||
if ($operation=='' && $valeur=='')
|
||||
$tmpFormule=$ope1deb.$ope1;
|
||||
elseif ($operation<>'' && $valeur=='')
|
||||
$tmpFormule=$ope1deb.$ope1.$operation."''";
|
||||
elseif (strtoupper($valeur)==strtolower($valeur) && $valeur<>'')
|
||||
$tmpFormule=$ope1deb.$ope1.$operation.$valeur;
|
||||
elseif (strtolower($valeur)=='vrai')
|
||||
$tmpFormule=$ope1deb.$ope1.$operation.'true';
|
||||
elseif (strtolower($valeur)=='faux')
|
||||
$tmpFormule=$ope1deb.$ope1.$operation.'false';
|
||||
elseif (strtolower($valeur)=='nmp')
|
||||
$tmpFormule=$ope1deb.$ope1.$operation.'$nmp';
|
||||
else
|
||||
$tmpFormule=$ope1deb.$ope1.$operation.$valeur;
|
||||
|
||||
}
|
||||
|
||||
$strParentDeb=$strParentFin='';
|
||||
if (preg_match_all('/(\()/',$operande,$matches)) {
|
||||
$strParentDeb=implode(' ', $matches[1]);
|
||||
$operande=trim(strtr($operande,array('('=>'')));
|
||||
} elseif (preg_match_all('/(\))/',$operande,$matches)) {
|
||||
$strParentFin=implode(' ', $matches[1]);
|
||||
$operande=trim(strtr($operande,array(')'=>'')));
|
||||
}
|
||||
|
||||
switch ($operande) {
|
||||
case 'SI': $strFormule="if ( $strParentDeb $tmpFormule $strParentFin"; break;
|
||||
case 'SI NON': $strFormule="if ( $strParentDeb !($tmpFormule) $strParentFin"; break;
|
||||
case 'ET': $strFormule.=" && $strParentDeb $tmpFormule $strParentFin"; break;
|
||||
case 'ET NON': $strFormule.=" && $strParentDeb !($tmpFormule) $strParentFin"; break;
|
||||
case 'OU': $strFormule.=" || $strParentDeb $tmpFormule $strParentFin"; break;
|
||||
case 'OU NON': $strFormule.=" || $strParentDeb !($tmpFormule) $strParentFin"; break;
|
||||
case 'ACTION': $strAction.=str_replace('==','=', " $tmpFormule; "); break;
|
||||
case 'ECHANGE': $ECHANGE[]=$tmpFormule; break;
|
||||
default:
|
||||
debugLog('W', 'Indiscore '.$id.' OPERANDE INCONNUE '.$operande, __LINE__, __FILE__, __FUNCTION__, __CLASS__);
|
||||
break;
|
||||
}
|
||||
$idPre=$id;
|
||||
|
||||
debugLog('W', 'Indiscore '.$id.' '.$strFormule, __LINE__, __FILE__, __FUNCTION__, __CLASS__);
|
||||
}
|
||||
|
||||
/** Gestion de la dernière ligne de commentaire **/
|
||||
$debugFormule.=$strFormule.') ) $C['.$idPre.']=true;'."\t";
|
||||
$strFormule=preg_replace('/\|(.{1,12})\|/U', 'abs($1)', $strFormule);
|
||||
$strFormule=preg_replace('/\$R\[0+/', '$R[', $strFormule);
|
||||
$strFormule=preg_replace('/\$Ra\[0+/', '$Ra[', $strFormule);
|
||||
$strFormule=preg_replace('/\$Rap\[0+/', '$Rap[', $strFormule);
|
||||
$strFormule=preg_replace('/\$Rp\[0+/', '$Rp[', $strFormule);
|
||||
$strFormule=preg_replace('/\$Rs\[0+/', '$Rs[', $strFormule);
|
||||
$strFormule=preg_replace('/\$Rsp\[0+/', '$Rsp[', $strFormule);
|
||||
$strFormule=preg_replace('/\$Revol\[0+/', '$Revol[', $strFormule);
|
||||
$strFormule=preg_replace('/\$Revolp\[0+/', '$Revolp[', $strFormule);
|
||||
$strFormule=preg_replace('/\$Revols\[0+/', '$Revols[', $strFormule);
|
||||
$strFormule=preg_replace('/\$Rdiff\[0+/', '$Rdiff[', $strFormule);
|
||||
for ($j=2;$j<5;$j++) {
|
||||
$strFormule=preg_replace('/\$Rp'.$j.'\[0+/', '$Rp'.$j.'[', $strFormule);
|
||||
$strFormule=preg_replace('/\$Rs'.$j.'\[0+/', '$Rs'.$j.'[', $strFormule);
|
||||
$strFormule=preg_replace('/\$Rsp'.$j.'\[0+/', '$Rsp'.$j.'[', $strFormule);
|
||||
$strFormule=preg_replace('/\$Revol'.$j.'\[0+/', '$Revol'.$j.'[', $strFormule);
|
||||
$strFormule=preg_replace('/\$Revolp'.$j.'\[0+/', '$Revolp'.$j.'[', $strFormule);
|
||||
}
|
||||
debugLog('W', 'Indiscore '.$strFormule.') $C['.$idPre.']='.$C[$idPre], __LINE__, __FILE__, __FUNCTION__, __CLASS__);
|
||||
eval ($strFormule.') $C['.$idPre.']=true;');
|
||||
//$fp2=fopen('/var/www/html/ws2/indiscore.tmp.php','a');
|
||||
fwrite($fp2, $strFormule.') $C['.$idPre.']=true;'."\n");
|
||||
|
||||
fwrite($fp2, "\n".'$ECHANGE=\''.serialize($ECHANGE)."';"."\n");
|
||||
|
||||
fwrite($fp2, "\n".'?>'."\n");
|
||||
fclose($fp2);
|
||||
$debugFormule.='$C['.$idPre.']='.$C[$idPre]."\r\n";
|
||||
//echo '</table>';
|
||||
|
||||
$strOutput=exec('php -l '.$fileIndiscoreTmp, $output);
|
||||
if (preg_match('/^No syntax errors detected in /', $strOutput)) {
|
||||
echo "Aucune erreur\n";
|
||||
//move($fileIndiscoreTmp, $fileIndiscore);
|
||||
//@sendMail('production@scores-decisions.com', 'ylenaour@scores-decisions.com', "Indiscore sur $siren : Compilation OK '$strOutput'", print_r($output, true)."\n");
|
||||
} else {
|
||||
echo "Erreur : $strOutput\n";
|
||||
print_r($output);
|
||||
//@sendMail('production@scores-decisions.com', 'ylenaour@scores-decisions.com', "Indiscore sur $siren : Erreur de compilation '$strOutput'", print_r($output, true)."\n");
|
||||
}
|
||||
|
||||
}
|
||||
|
80
scripts/jobs/genwsdl.php
Normal file
80
scripts/jobs/genwsdl.php
Normal file
@ -0,0 +1,80 @@
|
||||
<?php
|
||||
//error_reporting(E_ALL & ~E_NOTICE);
|
||||
|
||||
// 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|?' => "Displays usage information.",
|
||||
'all' => "Créer les WSDL à l'installation.",
|
||||
'version=s' => "Re-Créer le WSDL associé à la version X.X.X",
|
||||
'host=s' => "Le nom de domaine à requéter pour générer les WSDL correctement (sans http://)."
|
||||
)
|
||||
);
|
||||
$opts->parse();
|
||||
} catch (Zend_Console_Getopt_Exception $e) {
|
||||
echo $e->getUsageMessage();
|
||||
exit;
|
||||
}
|
||||
|
||||
//Usage
|
||||
if(isset($opts->help))
|
||||
{
|
||||
echo $opts->getUsageMessage();
|
||||
exit;
|
||||
}
|
||||
|
||||
//Génération des WSDL
|
||||
if (isset($opts->all) && isset($opts->host))
|
||||
{
|
||||
$configServiceVersions = new Zend_Config_Ini('WsScore/Entreprise/Versions.ini');
|
||||
foreach( $configServiceVersions->toArray() as $section => $params ){
|
||||
$version = $section;
|
||||
echo "Version $version";
|
||||
if ($params['actif']==1){
|
||||
echo " Traitement...\n";
|
||||
echo genereWSDL($opts->host, $version);
|
||||
}
|
||||
echo "\n";
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($opts->version) && isset($opts->host)){
|
||||
echo genereWSDL($opts->host, $opts->version);
|
||||
echo "\n";
|
||||
}
|
||||
|
||||
function genereWSDL($host, $version){
|
||||
$uri = 'http://'.$host.'/entreprise/v'.$version.'?wsdl-generate';
|
||||
$client = new Zend_Http_Client($uri, array(
|
||||
'adapter' => 'Zend_Http_Client_Adapter_Curl',
|
||||
));
|
||||
$response = $client->request('GET');
|
||||
return $response->getBody();
|
||||
}
|
||||
|
||||
|
||||
|
142
scripts/jobs/getActesAsso.php
Normal file
142
scripts/jobs/getActesAsso.php
Normal file
@ -0,0 +1,142 @@
|
||||
<?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(),
|
||||
)));
|
||||
|
||||
$c = new Zend_Config($application->getOptions());
|
||||
Zend_Registry::set('config', $c);
|
||||
|
||||
require_once 'WsScore/Configure.php';
|
||||
$oldconfig = new Configure();
|
||||
|
||||
/** 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;
|
||||
}
|
||||
|
||||
function getFilePdf($url, $file)
|
||||
{
|
||||
$result = true;
|
||||
$fp = fopen($file, 'w');
|
||||
$ch = curl_init($url);
|
||||
curl_setopt($ch, CURLOPT_FILE, $fp);
|
||||
$data = curl_exec($ch);
|
||||
// Check if any error occured
|
||||
if(curl_errno($ch))
|
||||
{
|
||||
$result = false;
|
||||
}
|
||||
curl_close($ch);
|
||||
fclose($fp);
|
||||
return $result;
|
||||
}
|
||||
|
||||
$reportSubject = '';
|
||||
$reportMsg = '';
|
||||
|
||||
//Lire la base de données - Récupérer les éléments sans fichier
|
||||
//Connect to the database
|
||||
try {
|
||||
$db = Zend_Db::factory($this->dbConfig->db->jo);
|
||||
$db->getConnection();
|
||||
} catch (Zend_Db_Adapter_Exception $e) {
|
||||
|
||||
} catch (Zend_Exception $e) {
|
||||
|
||||
}
|
||||
|
||||
$baseUrl = 'http://extranetrec.scores-decisions.com/fichier/pdfassociation/actes/';
|
||||
$path = SECURE_STORAGE . 'associations/actes/';
|
||||
|
||||
//Lecture des données
|
||||
$acteM = new Application_Model_AssoActes($db);
|
||||
$sql = $acteM->select()->where('pdfLink=?', '');
|
||||
$acteList = $acteM->fetchAll($sql);
|
||||
if ($acteList->count()>0) {
|
||||
foreach ($acteList->toArray() as $item) {
|
||||
$date = substr($item['date_acte'],0,4).substr($item['date_acte'],5,2).substr($item['date_acte'],8,2);
|
||||
if (intval($item['siren'])==0) {
|
||||
$file = 'ST-'.$item['waldec'].'-'.$date;
|
||||
} else {
|
||||
$file = 'ST-'.$item['siren'].'-'.$date;
|
||||
}
|
||||
//Télécharger le fichier
|
||||
$isDownload = getFilePdf($baseUrl.$file, $path.$file);
|
||||
|
||||
if ($isDownload && file_exists($path.$file)) {
|
||||
//Récupérer les informations du PDF
|
||||
$pdfInfos = array();
|
||||
$pdfInfos['pdfLink'] = $file;
|
||||
$pdfInfos['pdfSize'] = filesize($path.$file);
|
||||
|
||||
//Get PDF version
|
||||
$handle = fopen($path.$file, 'r');
|
||||
if ($handle) {
|
||||
while (!feof($handle)) {
|
||||
$buffer = fgets($handle, 4096);
|
||||
if (preg_match("/^\%PDF\-(.*)\s/U", $buffer, $matches)) {
|
||||
$version = $matches[1];
|
||||
}
|
||||
break;
|
||||
}
|
||||
fclose($handle);
|
||||
}
|
||||
|
||||
$pdfInfos['pdfVer'] = $version;
|
||||
|
||||
//Get PDF number of pages
|
||||
$pdf = new Zend_Pdf($path.$file, null, true);
|
||||
$pdfInfos['pdfPage'] = count($pdf->pages);
|
||||
|
||||
//Modifier la ligne dans la base de données
|
||||
$acteM->update($pdfInfos, 'id='.$item['id']);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$reportMsg = "\nGénéré par getActesAsso.";
|
||||
|
||||
//Envoyer un mail de rapport
|
||||
$mail = new Zend_Mail();
|
||||
$tr = new Zend_Mail_Transport_Smtp('smtp.celeste.fr');
|
||||
$mail->setDefaultTransport($tr);
|
||||
$mail->setFrom('production@scores-decisions.com', 'Production');
|
||||
$mail->addTo('support@scores-decisions.com', 'Support');
|
||||
$mail->setSubject($reportSubject);
|
||||
$mail->setBodyText(mb_convert_encoding($reportMsg, 'ISO-8859-1', 'UTF-8'));
|
||||
$mail->send();
|
603
scripts/jobs/getKbis.php
Normal file
603
scripts/jobs/getKbis.php
Normal file
@ -0,0 +1,603 @@
|
||||
#!/usr/bin/php
|
||||
<?php
|
||||
// Define path to application directory
|
||||
defined('APPLICATION_PATH')
|
||||
|| define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../../application'));
|
||||
|
||||
// Define application environment
|
||||
define('APPLICATION_ENV', 'development');
|
||||
|
||||
// Ensure library/ is on include_path
|
||||
set_include_path(implode(PATH_SEPARATOR, array(
|
||||
realpath(APPLICATION_PATH . '/../library'),
|
||||
get_include_path(),
|
||||
)));
|
||||
|
||||
require_once realpath(dirname(__FILE__)).'/../config/config.php';
|
||||
|
||||
/** 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|?' => "Affiche l'aide.",
|
||||
'siren=s' => "Commander un kbis",
|
||||
'commandes' => "Liste les commandes passees (Reference), si reference alors recupere le kbis",
|
||||
'visu=s' => "Telechargement du kbis avec une reference (--commandes obligatoire)",
|
||||
'debug' => "Mode debug",
|
||||
)
|
||||
);
|
||||
$opts->parse();
|
||||
} catch (Zend_Console_Getopt_Exception $e) {
|
||||
echo $e->getUsageMessage();
|
||||
exit;
|
||||
}
|
||||
|
||||
$c = new Zend_Config($application->getOptions());
|
||||
Zend_Registry::set('config', $c);
|
||||
|
||||
if ( isset($opts->debug) ) {
|
||||
define('DEBUG', true);
|
||||
} else {
|
||||
define('DEBUG', false);
|
||||
}
|
||||
|
||||
//Usage
|
||||
if(count($opts->getOptions())==0 || isset($opts->help))
|
||||
{
|
||||
echo "Telecharge le kbis chez infogreffe.";
|
||||
echo "\n\n";
|
||||
echo $opts->getUsageMessage();
|
||||
echo "\n";
|
||||
exit;
|
||||
}
|
||||
|
||||
function getPageHeader($start,$end,$header)
|
||||
{
|
||||
$pattern = '/'. $start .'(.*)'. $end .'/';
|
||||
if (preg_match($pattern, $header, $result)) {
|
||||
return $result[1];
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function getPage($url, $curl_data = '', $override = null)
|
||||
{
|
||||
global $ckfile;
|
||||
|
||||
//$user_agent = 'Mozilla/5.0 (Windows NT 5.1; rv:9.0.1) Gecko/20100101 Firefox/9.0.1';
|
||||
//$user_agent = 'Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)';
|
||||
$user_agent = 'Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0)';
|
||||
|
||||
$verbose = false;
|
||||
$post = false;
|
||||
$fields = '';
|
||||
if (is_array($curl_data) && count($curl_data)>0) {
|
||||
foreach($curl_data as $key=>$value) {
|
||||
$fields .= $key.'='.$value.'&';
|
||||
}
|
||||
rtrim($fields,'&');
|
||||
$post = true;
|
||||
}
|
||||
|
||||
$options = array(
|
||||
CURLOPT_RETURNTRANSFER => true, // return web page
|
||||
CURLOPT_HEADER => false, // don't return headers
|
||||
CURLOPT_FOLLOWLOCATION => false, // follow redirects
|
||||
CURLOPT_ENCODING => "", // handle all encodings
|
||||
CURLOPT_USERAGENT => $user_agent, // who am i
|
||||
CURLOPT_AUTOREFERER => true, // set referer on redirect
|
||||
CURLOPT_CONNECTTIMEOUT => 120, // timeout on connect
|
||||
CURLOPT_TIMEOUT => 120, // timeout on response
|
||||
CURLOPT_MAXREDIRS => 10, // stop after 10 redirects
|
||||
CURLOPT_POST => $post, // i am sending post data
|
||||
CURLOPT_POSTFIELDS => $fields, // this are my post vars
|
||||
CURLOPT_SSL_VERIFYHOST => 0, // don't verify ssl
|
||||
CURLOPT_SSL_VERIFYPEER => false, //
|
||||
CURLOPT_VERBOSE => $verbose , //
|
||||
//CURLOPT_COOKIESESSION => true,
|
||||
CURLOPT_COOKIEFILE => $ckfile,
|
||||
CURLOPT_COOKIEJAR => $ckfile, // Stockage du cookie de session
|
||||
);
|
||||
|
||||
//Override define CURL option
|
||||
if (is_array($override) && count($override)>0 ) {
|
||||
$options = $override + $options;
|
||||
}
|
||||
|
||||
$ch = curl_init($url);
|
||||
curl_setopt_array($ch,$options);
|
||||
$content = curl_exec($ch);
|
||||
$err = curl_errno($ch);
|
||||
$errmsg = curl_error($ch) ;
|
||||
$header = curl_getinfo($ch);
|
||||
curl_close($ch);
|
||||
|
||||
//Rewrite encoding to UTF-8
|
||||
//text/html; charset=ISO-8859-1
|
||||
$encoding = getPageHeader('text\/html; charset=', '', $header['content_type']);
|
||||
//$encoding = 'ISO-8859-1';
|
||||
$content = iconv($encoding, 'UTF-8//IGNORE', $content);
|
||||
|
||||
// $header['errno'] = $err;
|
||||
// $header['errmsg'] = $errmsg;
|
||||
// $header['content'] = $content;
|
||||
return array('header'=>$header, 'content'=>$content);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Retourne l'url après une page 302
|
||||
* @param string $content
|
||||
* @return string|boolean
|
||||
*/
|
||||
function getUrl302($content)
|
||||
{
|
||||
$url = false;
|
||||
preg_match('/\<title\>(.*)\<\/title\>/', $content, $matches);
|
||||
if ($matches[1]=='302 Moved Temporarily') {
|
||||
preg_match('/\<a href="(.*)"\>/', $content, $matches);
|
||||
$url = $matches[1];
|
||||
}
|
||||
return $url;
|
||||
}
|
||||
|
||||
function infogreffeConnexion()
|
||||
{
|
||||
$url = "http://www.infogreffe.fr/infogreffe/index.jsp";
|
||||
$result = getPage($url);
|
||||
if (DEBUG) file_put_contents('kbis-connexion1.html', $result['content']);
|
||||
|
||||
$url = "http://www.infogreffe.fr/infogreffe/popupLog.jsp?type=0&url=index.jsp";
|
||||
$result = getPage($url);
|
||||
if (DEBUG) file_put_contents('kbis-connexion2.html', $result['content']);
|
||||
|
||||
$url = "https://www.infogreffe.fr/infogreffe/login.do?redirect=index.jsp";
|
||||
// 302 Moved Temporarily
|
||||
// => http://www.infogreffe.fr/infogreffe/index.jsp
|
||||
$data = array(
|
||||
'codeAbo'=>'2559',
|
||||
'codeClt'=>'0041',
|
||||
'log'=>'',
|
||||
'pwd'=>'69873',
|
||||
);
|
||||
$result = getPage($url, $data);
|
||||
if (DEBUG) file_put_contents('kbis-connexion3.html', $result['content']);
|
||||
|
||||
/*
|
||||
We need to have
|
||||
<div style="margin-top:2px; *margin-top:0px;" class="identBar">
|
||||
|
||||
<span class="name">Abonné</span> |
|
||||
<a href="/infogreffe/jsp/information/monCompte.jsp">Mon compte</a> |
|
||||
<a href="/infogreffe/afficherMesAchats.do?refCde=N">Documents Commandés</a>
|
||||
| <a href="/infogreffe/deconnexion.do">Se déconnecter</a>
|
||||
</div>
|
||||
*/
|
||||
}
|
||||
|
||||
function infogreffeKbis($ref)
|
||||
{
|
||||
/**************************************************
|
||||
afficheProduit
|
||||
**************************************************/
|
||||
$url = "http://www.infogreffe.fr/infogreffe/chargement.jsp?oups=".$ref."_0_V_0_";
|
||||
$result = getPage($url);
|
||||
if (DEBUG) file_put_contents('kbis-afficheproduit.html', $result['content']);
|
||||
|
||||
//Redirection javascript qui fait patienter
|
||||
sleep(1);
|
||||
/**************************************************
|
||||
serviceProduit
|
||||
**************************************************/
|
||||
$url = "http://www.infogreffe.fr/infogreffe/serviceProduit.do?cdePro=".$ref."_0_V_0_";
|
||||
$result = getPage($url);
|
||||
if (DEBUG) file_put_contents('kbis-serviceproduit.html', $result['content']);
|
||||
|
||||
$output = $result['content'];
|
||||
|
||||
//Modification du code HTML pour impression
|
||||
$output = removeTag('script', $output, true, true);
|
||||
|
||||
$output = str_replace('/infogreffe/styles/infogreffe_base.css', '../styles/infogreffe_base.css', $output);
|
||||
$output = str_replace('/infogreffe/styles/infogreffe.css', '../styles/infogreffe.css', $output);
|
||||
|
||||
$output = preg_replace(
|
||||
'/\<body onload="adapterDimensions(\'conteneur\');" class="simple preventSelection" style="background-color: rgb(241, 241, 241);">/',
|
||||
'<body class="simple preventSelection" style="background-color: rgb(241, 241, 241);">',
|
||||
$output
|
||||
);
|
||||
|
||||
//Récupération des informations dans le kbis
|
||||
//<td align="left" valign="top" class="label">Numéro d'identification :</td><td>509 536 371 R.C.S. PONTOISE</td>
|
||||
|
||||
preg_match('/([0-9]{3}\s[0-9]{3}\s[0-9]{3})\sR\.C\.S\./', $output, $matches);
|
||||
|
||||
if (count($matches)>1){
|
||||
$identifiant = str_replace(' ', '',$matches[1]);
|
||||
} else {
|
||||
$identifiant = 'unknown';
|
||||
}
|
||||
$fichier = $identifiant . '-' . $ref . '.html';
|
||||
|
||||
$dir = $c->profil->path->secure.'/kbis/'.date('Ymd');
|
||||
if (!file_exists($dir)) mkdir($dir);
|
||||
file_put_contents($dir . '/' . $fichier, $output);
|
||||
return ($identifiant!='unknown') ? $identifiant : false;
|
||||
}
|
||||
|
||||
function removeTag($balise, $content, $endOfTag = true, $removeContent = true)
|
||||
{
|
||||
if( $endOfTag )
|
||||
{
|
||||
if( $removeContent)
|
||||
$output = preg_replace(
|
||||
'@<'.$balise.'[^>]*?>.*?</'.$balise.'>@si',
|
||||
'',
|
||||
$content
|
||||
);
|
||||
else
|
||||
$output = preg_replace(
|
||||
array('@<'.$balise.'[^>]*?>@', '@</'.$balise.'>@'),
|
||||
'',
|
||||
$content
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
$output = preg_replace(
|
||||
'@<'.$balise.'[^>]*?>@',
|
||||
'',
|
||||
$content
|
||||
);
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
|
||||
function parseRef($document)
|
||||
{
|
||||
$doc = new DOMDocument();
|
||||
$doc->strictErrorChecking = false;
|
||||
$doc->preserveWhiteSpace = false;
|
||||
@$doc->loadHTML($document);
|
||||
$xpath = new DOMXpath($doc);
|
||||
|
||||
//Recherche des infos de la première commande
|
||||
$nodelist = $xpath->query("//a/img[@alt='visualiser']");
|
||||
foreach ($nodelist as $n){
|
||||
$href = $n->parentNode->getAttribute('href');
|
||||
preg_match("/javascript:afficheProduit\(\'(.*)_0_V_0_\'/", $href, $matches);
|
||||
$ref = $matches[1];
|
||||
}
|
||||
//Recherche Raison Sociale
|
||||
$nodelist = $xpath->query("//span[@class='text-company']/a");
|
||||
foreach ($nodelist as $n){
|
||||
$rs = $n->nodeValue;
|
||||
break;
|
||||
}
|
||||
//Recherche RCS
|
||||
$nodelist = $xpath->query("//span[@class='text-rcs']");
|
||||
foreach ($nodelist as $n){
|
||||
$rcs = $n->nodeValue;
|
||||
break;
|
||||
}
|
||||
return array(
|
||||
'ref' => $ref,
|
||||
'rs' => $rs,
|
||||
'rcs' => $rcs,
|
||||
);
|
||||
}
|
||||
|
||||
//Define cookie file for storage
|
||||
//@todo : Faire en sorte d'utiliser le cookie pendant un temps déterminé, ou nouvelle session à chaque fois
|
||||
$ckfile = __DIR__.'/'.uniqid('cookie-');
|
||||
if (file_exists($ckfile)) unlink($ckfile);
|
||||
|
||||
// Récupération de la liste des commandes et
|
||||
if ( $opts->commandes )
|
||||
{
|
||||
$referer = '';
|
||||
|
||||
/**************************************************
|
||||
Connexion
|
||||
**************************************************/
|
||||
infogreffeConnexion();
|
||||
|
||||
$url = "http://www.infogreffe.fr/infogreffe/jsp/information/monCompte.jsp";
|
||||
$result = getPage($url);
|
||||
if (DEBUG) file_put_contents('kbis-moncompte.html', $result['content']);
|
||||
|
||||
/**************************************************
|
||||
Documents commandés
|
||||
**************************************************/
|
||||
$url = "http://www.infogreffe.fr/infogreffe/afficherMesAchats.do?refCde=N";
|
||||
$result = getPage($url);
|
||||
if (DEBUG) file_put_contents('documents.html', $result['content']);
|
||||
|
||||
//On parse le document pour trouver les références de commandes
|
||||
$refs = array();
|
||||
|
||||
$tmp = parseRef($result['content']);
|
||||
$refs[] = $tmp;
|
||||
|
||||
//Liste des commandes
|
||||
$nodelist = $xpath->query("//a[@class='folded-fond-gris']");
|
||||
foreach ($nodelist as $n){
|
||||
$href = $n->getAttribute('href');
|
||||
preg_match("/javascript:reveal\(\'(.*)\'\)/", $href, $matches);
|
||||
$refs[] = array( 'ref' => $matches[1] );
|
||||
}
|
||||
|
||||
$listeRef = array();
|
||||
foreach($refs as $item){
|
||||
$listeRef[] = $item['ref'];
|
||||
}
|
||||
|
||||
if ( $opts->visu && in_array($opts->visu, $listeRef) )
|
||||
{
|
||||
//Pour toutes les commandes en dehors de la toute dernière
|
||||
if ( array_search($opts->visu, $listeRef)!=0 ){
|
||||
$url = "http://www.infogreffe.fr/infogreffe/chargerContenuCommande.do?refCde=".$opts->visu."&_=";
|
||||
$result = getPage($url);
|
||||
if (DEBUG) file_put_contents('documents-'.$ref['ref'].'.html', $result['content']);
|
||||
}
|
||||
|
||||
echo "Téléchargement du kbis...\n";
|
||||
infogreffeKbis($opts->visu);
|
||||
|
||||
//Lancer WKHTMLTOPDF pour le PDF
|
||||
|
||||
} elseif ( !$opts->visu ) {
|
||||
|
||||
/**************************************************
|
||||
Reveal : Ajax pour mettre à jour le div
|
||||
**************************************************/
|
||||
// Parcourir le fichier précédent et relevé toute les références de commandes
|
||||
// http://www.infogreffe.fr/infogreffe/chargerContenuCommande.do?refCde=XNDAE&_=
|
||||
// Dans javascript la requete est réalisé en GET
|
||||
$i = 0;
|
||||
foreach ( $refs as $ref )
|
||||
{
|
||||
if ($i!=0){
|
||||
$url = "http://www.infogreffe.fr/infogreffe/chargerContenuCommande.do?refCde=".$ref['ref']."&_=";
|
||||
$result = getPage($url);
|
||||
if (DEBUG) file_put_contents('documents-'.$ref['ref'].'.html', $result['content']);
|
||||
//@todo : Recup des informations
|
||||
$info = array();
|
||||
$info = parseRef($document);
|
||||
}
|
||||
echo $ref['ref'];
|
||||
if ( $info['ref']==$ref['ref'] ) {
|
||||
if ( !empty($info['rs']) ) echo " ".$info['rs'];
|
||||
if ( !empty($info['rcs']) ) echo " ".$info['rcs'];
|
||||
}
|
||||
echo "\n";
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Commande d'un kbis
|
||||
if ( $opts->siren )
|
||||
{
|
||||
//Vérification du siren
|
||||
if (strlen($opts->siren)!=9) {
|
||||
echo "Erreur SIREN invalide\n"; exit;
|
||||
}
|
||||
$referer = '';
|
||||
|
||||
/**************************************************
|
||||
Connexion
|
||||
**************************************************/
|
||||
infogreffeConnexion();
|
||||
|
||||
/**************************************************
|
||||
Affichage formulaire
|
||||
**************************************************/
|
||||
$url = "http://www.infogreffe.fr/infogreffe/index.jsp";
|
||||
$result = getPage($url);
|
||||
if (DEBUG) file_put_contents('kbis1.html', $result['content']);
|
||||
|
||||
/**************************************************
|
||||
Soumission formulaire
|
||||
**************************************************/
|
||||
$fields = array(
|
||||
'commune' => '',
|
||||
'denomination' => '',
|
||||
'departement' => '',
|
||||
//'elargirSecondaire' => 'on',
|
||||
'elargirRadie' => 'on',
|
||||
'siren' => $opts->siren,
|
||||
);
|
||||
$url = "http://www.infogreffe.fr/infogreffe/newRechercheEntreprise.xml";
|
||||
$result = getPage($url, $fields);
|
||||
if (DEBUG) file_put_contents('kbis2.html', $result['content']);
|
||||
|
||||
// 302 Moved Temporarily - But we always use this URL
|
||||
$url = 'http://www.infogreffe.fr/infogreffe/entrepRech.do';
|
||||
|
||||
/**************************************************
|
||||
Affichage identite entreprise
|
||||
**************************************************/
|
||||
//url defini plus haut
|
||||
$result = getPage($url, '', array(CURLOPT_FOLLOWLOCATION => true));
|
||||
if (DEBUG) file_put_contents('kbis3.html', $result['content']);
|
||||
|
||||
/*
|
||||
* !! Attention !! Elargir aux radiés peut retourner plusieurs résultats
|
||||
*/
|
||||
$doc = new DOMDocument();
|
||||
$doc->strictErrorChecking = false;
|
||||
$doc->preserveWhiteSpace = false;
|
||||
@$doc->loadHTML($result['content']);
|
||||
$xpath = new DOMXpath($doc);
|
||||
$nodelist = $xpath->query("//div[@id='includeEntrepListe']");
|
||||
if ($nodelist->length>0) {
|
||||
$entries = $xpath->query("//a[@class='company']");
|
||||
foreach ($entries as $n) {
|
||||
$url = 'http://www.infogreffe.fr'. $n->getAttribute('href');
|
||||
break;
|
||||
}
|
||||
$result = getPage($url);
|
||||
}
|
||||
|
||||
/*
|
||||
* Try to detect we can pass an order, else send message and exit
|
||||
*
|
||||
* Si la recherche a fonctionné
|
||||
* div[@id="libelleRcsGreffe"], nodeValue = "552 144 503 R.C.S. PARIS"
|
||||
*
|
||||
* Si pas de résultats lors de la recherche alors
|
||||
* table[@class='liste-res-rech']/tbody/tr[1]/td[1]/div/span[1]
|
||||
*/
|
||||
$doc = new DOMDocument();
|
||||
$doc->strictErrorChecking = false;
|
||||
$doc->preserveWhiteSpace = false;
|
||||
@$doc->loadHTML($result['content']);
|
||||
$xpath = new DOMXpath($doc);
|
||||
$nodelist = $xpath->query("//div[@id='libelleRcsGreffe']");
|
||||
if ($nodelist->length==0) {
|
||||
$entries = $xpath->query("//table[@class='liste-res-rech']/tbody/tr[1]/td[1]/div/span");
|
||||
if ($entries->length>0) {
|
||||
echo trim($entries->item(0)->nodeValue);
|
||||
} else {
|
||||
echo "ERREUR";
|
||||
}
|
||||
if (file_exists($ckfile)) unlink($ckfile);
|
||||
exit;
|
||||
}
|
||||
|
||||
/*
|
||||
* Si les documents sont disponibles
|
||||
* <a onclick="reveal('kbis');return false" href="#" id="a_kbis" class="folded">Extrait RCS (Kbis)</a>
|
||||
*
|
||||
* Sinon rechercher la valeur du message
|
||||
* "//div[@id='conteneur']/table/tbody/tr/td/table/tbody/tr[2]/td/table[2]/tbody/tr[last()-2]/td";
|
||||
*/
|
||||
$nodelist = $xpath->query("//a[@id='a_kbis']");
|
||||
if ($nodelist->length==0) {
|
||||
$div = $xpath->query("//div[@id='conteneur']");
|
||||
$context = $div->item(0);
|
||||
$entries = $xpath->query("table/tbody/tr/td/table/tbody/tr[2]/td/table[2]/tbody/tr[9]/td", $context);
|
||||
$message = $entries->item(0)->nodeValue;
|
||||
echo trim($message);
|
||||
if (file_exists($ckfile)) unlink($ckfile);
|
||||
exit;
|
||||
}
|
||||
|
||||
// 302 Moved Temporarily
|
||||
//http://www.infogreffe.fr/infogreffe/entrepListe.do?index=rcs
|
||||
if ( $result['header']['http_code']=='302' && array_key_exists('redirect_url', $result['header']) ) {
|
||||
$url = $result['header']['redirect_url'];
|
||||
$result = getPage($url);
|
||||
if (DEBUG) file_put_contents('kbis3-1.html', $result['content']);
|
||||
|
||||
// => /infogreffe/getEntrepDetail.do?docId=780308B042410000
|
||||
$doc = new DOMDocument();
|
||||
$doc->strictErrorChecking = false;
|
||||
$doc->preserveWhiteSpace = false;
|
||||
@$doc->loadHTML($result['content']);
|
||||
$xpath = new DOMXpath($doc);
|
||||
$nodelist = $xpath->query("//a[@class='company']");
|
||||
foreach ($nodelist as $n) {
|
||||
$url = 'http://www.infogreffe.fr'. $n->getAttribute('href');
|
||||
break;
|
||||
}
|
||||
$result = getPage($url);
|
||||
if (DEBUG) file_put_contents('kbis3-2.html', $result['content']);
|
||||
} elseif ( $result['header']['http_code']=='302' ) {
|
||||
$url = 'http://www.infogreffe.fr/weblogic/infogreffe/entrepListe.do?index=rcs';
|
||||
$result = getPage($url);
|
||||
if (DEBUG) file_put_contents('kbis3-1.html', print_r($result,1));
|
||||
|
||||
$doc = new DOMDocument();
|
||||
$doc->strictErrorChecking = false;
|
||||
$doc->preserveWhiteSpace = false;
|
||||
@$doc->loadHTML($result['content']);
|
||||
$xpath = new DOMXpath($doc);
|
||||
$nodelist = $xpath->query("//a[@class='company']");
|
||||
foreach ($nodelist as $n) {
|
||||
$url = 'http://www.infogreffe.fr'. $n->getAttribute('href');
|
||||
break;
|
||||
}
|
||||
$result = getPage($url);
|
||||
if (DEBUG) file_put_contents('kbis3-2.html', $result['content']);
|
||||
}
|
||||
|
||||
$fields = array();
|
||||
//Recherche des infos pour la validation du formulaire
|
||||
$doc = new DOMDocument();
|
||||
$doc->strictErrorChecking = false;
|
||||
$doc->preserveWhiteSpace = false;
|
||||
@$doc->loadHTML($result['content']);
|
||||
$xpath = new DOMXpath($doc);
|
||||
$nodelist = $xpath->query("//form[@name='FicheEntrepriseForm']/div[@id='conteneur']/input[@type='hidden']");
|
||||
foreach ($nodelist as $n) {
|
||||
$key = $n->getAttribute('name');
|
||||
$value = $n->getAttribute('value');
|
||||
$fields[$key] = $value;
|
||||
}
|
||||
$fields['montantTotalSelection'] = '5.44'; // 3.11 + 2.33
|
||||
$fields['extraitForm.visualisation'] = 'on'; // => Définit par javascript
|
||||
|
||||
$fields['extraitForm.formVisible'] = 'true';
|
||||
$fields['extraitForm.envoiPeriodiqueForm.periodicite'] = '1';
|
||||
$fields['extraitForm.envoiPeriodiqueForm.duree'] = '12';
|
||||
$fields['etatEndettementForm.formVisible'] = 'true';
|
||||
$fields['etatEndettementForm.etatComplet'] = 'false';
|
||||
$fields['listeActesForm.formVisible'] = 'true';
|
||||
$fields['historiqueModificationsForm.formVisible'] = 'true';
|
||||
$fields['historiqueModificationsForm.tri'] = '0';
|
||||
$fields['procedureCollectiveForm.formVisible'] = 'true';
|
||||
$fields['dossierCompletForm.formVisible'] = 'true';
|
||||
|
||||
if (DEBUG) print_r($fields);
|
||||
/**************************************************
|
||||
Validation de la selection
|
||||
**************************************************/
|
||||
$url = "http://www.infogreffe.fr/infogreffe/validerSelectionFicheEntreprise.xml";
|
||||
$result = getPage($url, $fields);
|
||||
if (DEBUG) file_put_contents('kbis4.html', print_r($result,1));
|
||||
|
||||
/**************************************************
|
||||
Valider la commande
|
||||
**************************************************/
|
||||
$url = "http://www.infogreffe.fr/infogreffe/validerPanierAbonne.do?forcerSaisieCoordonnees=false";
|
||||
$fields = array();
|
||||
$result = getPage($url, $fields);
|
||||
if (DEBUG) file_put_contents('kbis5.html', $result['content']);
|
||||
|
||||
/**************************************************
|
||||
Afficher mes achats et prendre la première commande
|
||||
**************************************************/
|
||||
$url = "http://www.infogreffe.fr/infogreffe/afficherMesAchats.do?refCde=N&pageAppel=validerPanier";
|
||||
$fields = array();
|
||||
$result = getPage($url, $fields);
|
||||
if (DEBUG) file_put_contents('kbis6.html', $result['content']);
|
||||
|
||||
$info = parseRef($result['content']);
|
||||
$ref = $info['ref'];
|
||||
|
||||
/**************************************************
|
||||
Visualiser
|
||||
**************************************************/
|
||||
$identifiant = infogreffeKbis($ref);
|
||||
|
||||
//Suppression fichier
|
||||
if (file_exists($ckfile)) unlink($ckfile);
|
||||
|
||||
if ($identifiant===false || $identifiant!=$opts->siren) {
|
||||
echo "ERREUR";
|
||||
exit;
|
||||
}
|
||||
echo $identifiant.'-'.$ref.'.html';
|
||||
}
|
84
scripts/jobs/removeTempFile.php
Normal file
84
scripts/jobs/removeTempFile.php
Normal file
@ -0,0 +1,84 @@
|
||||
<?php
|
||||
error_reporting(E_ALL & ~E_NOTICE);
|
||||
|
||||
// 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'
|
||||
);
|
||||
|
||||
$c = new Zend_Config($application->getOptions());
|
||||
Zend_Registry::set('config', $c);
|
||||
|
||||
require_once 'WsScore/Configure.php';
|
||||
$oldconfig = new Configure();
|
||||
|
||||
$typesFichier = array('csv', 'fichiers', 'clients', 'kbis');
|
||||
|
||||
try {
|
||||
$opts = new Zend_Console_Getopt(
|
||||
//Options
|
||||
array(
|
||||
'help|?' => 'Displays usage information.',
|
||||
'all' => 'Execute toutes les actions (cron).',
|
||||
'type=w' => 'Supprime uniquement les fichiers indiqués.',
|
||||
)
|
||||
);
|
||||
$opts->parse();
|
||||
} catch (Zend_Console_Getopt_Exception $e) {
|
||||
echo $e->getUsageMessage();
|
||||
exit;
|
||||
}
|
||||
|
||||
//Usage
|
||||
if(isset($opts->help))
|
||||
{
|
||||
echo $opts->getUsageMessage();
|
||||
?>
|
||||
|
||||
Types de fichier disponibles : <?php echo join(', ', $typesFichier)?>
|
||||
|
||||
<?php
|
||||
exit;
|
||||
}
|
||||
|
||||
if ($opts->all || $opts->type)
|
||||
{
|
||||
foreach ($typesFichier as $dir)
|
||||
{
|
||||
if ($opts->all || $opts->type==$dir ){
|
||||
removeFileInDir(LOG_PATH.'/'.$dir);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function removeFileInDir($dir)
|
||||
{
|
||||
if (is_dir($dir)) {
|
||||
if ($dh = opendir($dir)) {
|
||||
while (($file = readdir($dh)) !== false) {
|
||||
unlink($dir . $file);
|
||||
}
|
||||
closedir($dh);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
48
scripts/jobs/setLogsCount.php
Normal file
48
scripts/jobs/setLogsCount.php
Normal file
@ -0,0 +1,48 @@
|
||||
<?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.",
|
||||
'yesterday|y' => "Traitement logs du jour précédent",
|
||||
'jour' => "Date au format AAAA-MM-JJ",
|
||||
)
|
||||
);
|
||||
$opts->parse();
|
||||
} catch (Zend_Console_Getopt_Exception $e) {
|
||||
echo $e->getUsageMessage();
|
||||
exit;
|
||||
}
|
||||
|
||||
//Usage
|
||||
if(isset($opts->help) || !isset($opts->file))
|
||||
{
|
||||
echo $opts->getUsageMessage();
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
|
94
scripts/jobs/sql2csv.php
Normal file
94
scripts/jobs/sql2csv.php
Normal file
@ -0,0 +1,94 @@
|
||||
<?php
|
||||
ini_set('memory_limit', '1024M');
|
||||
|
||||
// Durée maximale du script
|
||||
$dureeMaxi = 300; // secondes (soit 5 minutes)
|
||||
// Interval entre chaque tentative de récupération des Kbis sur le FTP
|
||||
$dureeInterval = 5; // secondes
|
||||
set_time_limit(($dureeMaxi+10));
|
||||
|
||||
error_reporting(E_ALL & ~E_NOTICE);
|
||||
|
||||
// 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|?' => 'Displays usage information.',
|
||||
)
|
||||
);
|
||||
$opts->parse();
|
||||
} catch (Zend_Console_Getopt_Exception $e) {
|
||||
echo $e->getUsageMessage();
|
||||
exit;
|
||||
}
|
||||
|
||||
$c = new Zend_Config($application->getOptions());
|
||||
Zend_Registry::set('config', $c);
|
||||
|
||||
require_once 'WsScore/Configure.php';
|
||||
$oldconfig = new Configure();
|
||||
|
||||
//Usage
|
||||
if(isset($opts->help))
|
||||
{
|
||||
echo "\n";
|
||||
echo $opts->getUsageMessage();
|
||||
echo basename($argv[0]). " BASE FICHIER.SQL FICHIER.CSV\n";
|
||||
echo "Génération d'un fichier CSV à partir d'un fichier SQL sur la BASE en paramètre.";
|
||||
echo "\n";
|
||||
exit;
|
||||
}
|
||||
elseif (count($opts)==1 && $argc==4)
|
||||
{
|
||||
require_once 'framework/fwk.php';
|
||||
require_once 'framework/common/chiffres.php';
|
||||
require_once 'framework/common/dates.php';
|
||||
require_once 'framework/mail/sendMail.php';
|
||||
require_once 'Metier/insee/classMInsee.php';
|
||||
require_once 'Metier/partenaires/classMGreffes.php';
|
||||
require_once 'Metier/partenaires/classMBilans.php';
|
||||
|
||||
$base = $argv[1];
|
||||
$sql = $argv[2];
|
||||
$csv = $argv[3];
|
||||
|
||||
$heureDemande = date('Hi');
|
||||
|
||||
$iDb = new WDB($base);
|
||||
$nbLignes = $iDb->exportCSV(file_get_contents($sql), $csv.'.tmp');
|
||||
$fp = fopen(LOG_PATH.'/csv2sql.log', 'a');
|
||||
fwrite($fp, date('Y-m-d H:i:s')." - $base $sql $csv : $nbLignes lignes extraites".EOL);
|
||||
fclose($fp);
|
||||
move($csv.'.tmp', $csv);
|
||||
exit;
|
||||
} else {
|
||||
echo "Erreur !\n";
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user