Compare commits

...

No commits in common. "master" and "2.2" have entirely different histories.
master ... 2.2

3618 changed files with 990688 additions and 45682 deletions

5
.gitignore vendored
View File

@ -1,5 +0,0 @@
/.settings/
/.buildpath
/.project
/vendor/
/composer-develop.lock

View File

@ -1,22 +0,0 @@
# WebService
## Installation du projet
1. Création de la configuration du VHOST apache
2. Référencer le domaine virtuel dans le fichier host de la machine
* ex : 192.168.33.10 webservice.sd.dev
3. Executer composer install pour charger les librairies externes dans vendor
4. Configurer l'application (application.ini)
* exemple fourni - `docs/config` ou projet `ansible`
Voir le fichier `docs/README` pour plus d'éléments
## Mode développement pour les librairies externes
Utiliser la branche `develop` de `scores/library`
`$ COMPOSER=composer-develop.json composer install`

View File

@ -1,218 +1,163 @@
<?php
use Monolog\Logger;
use Monolog\Handler\StreamHandler;
use Monolog\Processor\IntrospectionProcessor;
class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
protected function _initConfig()
{
$config = new Zend_Config($this->getOptions());
Zend_Registry::set('config', $config);
define('MYSQL_HOST', $config->profil->db->metier->params->host);
define('MYSQL_USER', $config->profil->db->metier->params->username);
define('MYSQL_PASS', $config->profil->db->metier->params->password);
define('LOG_PATH', $config->profil->path->shared.'/log');
// Entreprise
define('SPHINX_ENT_HOST', $config->profil->sphinx->ent->host);
define('SPHINX_ENT_PORT', intval($config->profil->sphinx->ent->port));
define('SPHINX_ENT_VERSION', $config->profil->sphinx->ent->version);
// Dirigeants
define('SPHINX_DIR_HOST', $config->profil->sphinx->dir->host);
define('SPHINX_DIR_PORT', intval($config->profil->sphinx->dir->port));
define('SPHINX_DIR_VERSION', $config->profil->sphinx->dir->version);
// Historique
define('SPHINX_HISTO_HOST', $config->profil->sphinx->histo->host);
define('SPHINX_HISTO_PORT', intval($config->profil->sphinx->histo->port));
define('SPHINX_HISTO_VERSION', $config->profil->sphinx->histo->version);
// Actionnaire
define('SPHINX_ACT_HOST', $config->profil->sphinx->act->host);
define('SPHINX_ACT_PORT', intval($config->profil->sphinx->act->port));
define('SPHINX_ACT_VERSION', $config->profil->sphinx->act->version);
//Old
define('SPHINX_HOST', $config->profil->sphinx->ent->host);
define('SPHINX_PORT', intval($config->profil->sphinx->ent->port));
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('HTML5');
$view->headMeta()
->appendName('viewport', 'width=device-width, initial-scale=1.0')
->appendHttpEquiv('X-UA-Compatible', 'IE=edge')
->appendHttpEquiv('Content-Type', 'text/html; charset=UTF-8')
//Initialisation global des paramètres de vue
protected function _initViewSettings()
{
$this->bootstrap('view');
$view = $this->getResource('view');
$view->setEncoding('UTF-8');
$view->doctype('XHTML1_STRICT');
$view->headMeta()
->appendHttpEquiv('Content-Type', 'text/html; charset=UTF-8')
->appendHttpEquiv('Content-Language', 'fr-FR');
$view->headLink()
->appendStylesheet('/styles/reset.css', 'all')
->appendStylesheet('/styles/main.css', 'all');
$view->headScript()->appendFile('/scripts/jquery.js', 'text/javascript');
$view->headScript()->appendFile('/scripts/scripts.js', 'text/javascript');
$view->headTitle()->setSeparator(' - ');
$view->headTitle('WebService Scores & Decisions');
}
//Favicon - Touch icon for iOS 2.0+ and Android 2.1+
$view->headLink()->headLink(array(
'rel' => 'apple-touch-icon-precomposed',
'href' => '/favicon-152.png'
));
//Favicon - targeted to any additional png size
$view->headLink()->headLink(array(
'rel' => 'icon',
'type' => 'image/png',
'href' => '/favicon-32.png'
));
$view->headLink()->headLink(array(
'rel' => 'shortcut icon',
'type' => 'image/x-icon',
'href' => '/favicon.ico')
);
//Initialisation global des paramètres de log
protected function _initLogging()
{
require_once 'Zend/Log.php';
require_once 'Zend/Mail.php';
$WsLogger = new Zend_Log();
$WsFileWriter = new Zend_Log_Writer_Stream(LOG_PATH.'/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);
}
$view->headLink()
->appendStylesheet('/assets/libs/bootstrap-3.3.7/css/bootstrap.min.css', 'all')
->appendStylesheet('/assets/themes/default/css/docs.css', 'all')
->appendStylesheet('/assets/themes/default/css/main.css', 'all');
protected function _initNavigation()
{
$view = $this->bootstrap('layout')->getResource('layout')->getView();
$view->headScript()
->appendFile('/assets/libs/html5shiv.min.js', 'text/javascript', array('conditional' => 'lt IE 9'))
->appendFile('/assets/libs/respond.min.js', 'text/javascript', array('conditional' => 'lt IE 9'))
->appendFile('/assets/libs/jquery-1.12.4.min.js', 'text/javascript')
->appendFile('/assets/libs/bootstrap-3.3.7/js/bootstrap.min.js', 'text/javascript');
//@todo : gérer les versions et les clients
$view->headTitle()->setSeparator(' - ');
$view->headTitle('Web Service API - Scores & Decisions');
}
$menu = array(
array(
'label' => 'Accueil',
'controller' => 'index',
'action' => 'index',
),
array(
'label' => 'Documentation',
'controller' => 'documentation',
'action' => 'index',
'pages' => array(
array(
'label' => 'Entreprise',
'controller' => 'documentation',
'action' => 'index',
),
array(
'label' => 'Code erreurs/messages',
'controller' => 'documentation',
'action' => 'erreur',
),
array(
'label' => 'Exemples',
'controller' => 'documentation',
'action' => 'exemples',
),
),
),
array(
'label' => 'Démonstration',
'controller' => 'demo',
'action' => 'index',
),
);
$view->navigation(new Zend_Navigation($menu));
}
protected function _initRouter()
{
$this->bootstrap('frontController');
$front = $this->getResource('frontController');
$router = $front->getRouter();
protected function _initDb(){}
// Lire les services disponibles et créer les routes
$services = require_once APPLICATION_PATH . '/../library/WsScore/ServicesConfig.php';
foreach ($services as $section => $params) {
if ($params['actif']) {
$route = new Zend_Controller_Router_Route($section.'/:version', array(
'controller' => 'service',
'action' => 'index',
'service' => $section,
'version' => '',
));
$router->addRoute($section, $route);
}
}
protected function _initRouter()
{
$this->bootstrap('frontController');
$front = $this->getResource('frontController');
$router = $front->getRouter();
// Route pour WS Clients
$route = new Zend_Controller_Router_Route('clients/:client/:version', array(
'controller' => 'service',
'action' => 'index',
'service' => 'clients',
'client' => '',
'version' => ''
));
$router->addRoute('client', $route);
//Lire les services disponibles et créer les routes
$services = new Zend_Config_Ini('WsScore/Services.ini');
foreach( $services->toArray() as $section => $params ){
if ($params['actif']) {
$route = new Zend_Controller_Router_Route($section.'/:version', array(
'controller' => 'service',
'action' => 'index',
'service' => $section,
'version' => '',
));
$router->addRoute($section, $route);
$route = new Zend_Controller_Router_Route('jsonrpc/'.$section.'/:version', array(
'controller' => 'jsonrpc',
'action' => 'index',
'service' => $section,
'version' => '',
));
$router->addRoute('jsonrpc-'.$section, $route);
}
}
$fichierRoute = new Zend_Controller_Router_Route('fichier/:action/:fichier', array(
'controller' => 'fichier',
'fichier' => '',
));
$router->addRoute('fichier', $fichierRoute);
return $router;
}
//Route pour WS Clients
$route = new Zend_Controller_Router_Route('clients/:client/:version', array(
'controller' => 'service',
'action' => 'index',
'service' => 'clients',
'client' => '',
'version' => ''
));
$router->addRoute('client', $route);
protected function _initDb()
{
$c = new Zend_Config($this->getOptions());
try {
$db = Zend_Db::factory($c->profil->db->metier);
} catch (Exception $e) {
if (APPLICATION_ENV == 'development') {
echo '<pre>';
print_r($e);
echo '</pre>';
} else {
echo "Le service rencontre actuellement un problème technique.";
}
exit;
}
return $router;
}
/**
* Set the default adapter to use with all model
*/
Zend_Db_Table::setDefaultAdapter($db);
}
protected function _initWsDebug()
{
$autoloader = Zend_Loader_Autoloader::getInstance();
$autoloader->registerNamespace('WsDebug');
protected function _initDoctrine()
{
$c = new Zend_Config($this->getOptions());
$options = array(
'plugins' => array(
'Exception',
),
);
$config = new \Doctrine\DBAL\Configuration();
$debug = new WsDebug_Controller_Plugin_Debug($options);
if (APPLICATION_ENV == 'development') {
$logger = new Scores_Logger_Sql();
$config->setSQLLogger($logger);
}
$this->bootstrap('frontController');
$frontController = $this->getResource('frontController');
$frontController->registerPlugin($debug);
}
$connectionParams = array(
'dbname' => $c->profil->db->metier->params->dbname,
'user' => $c->profil->db->metier->params->username,
'password' => $c->profil->db->metier->params->password,
'host' => $c->profil->db->metier->params->host,
'charset' => 'utf8',
'driver' => 'pdo_mysql',
);
protected function _initCache()
{
//MetadataCache pour la base de données
$frontendOptions = array(
'lifetime' => 14400,
'automatic_serialization' => true
);
$backendOptions = array();
$cache = Zend_Cache::factory('Core','Apc', $frontendOptions, $backendOptions);
Zend_Db_Table_Abstract::setDefaultMetadataCache($cache);
//Cache pour les données de la base à stocker
try {
$conn = \Doctrine\DBAL\DriverManager::getConnection($connectionParams, $config);
} catch (\Doctrine\DBAL\DBALException $e) {
if (APPLICATION_ENV == 'development') {
echo '<pre>';
print_r($e);
echo '</pre>';
} else {
echo "Le service rencontre actuellement un problème technique.";
}
exit;
}
Zend_Registry::set('doctrine', $conn);
}
protected function _initCache()
{
if (APPLICATION_ENV!='development') {
//MetadataCache pour la base de données
$frontendOptions = array(
'lifetime' => 14400,
'automatic_serialization' => true
);
$backendOptions = array();
$cache = Zend_Cache::factory('Core', 'Apc', $frontendOptions, $backendOptions);
Zend_Db_Table_Abstract::setDefaultMetadataCache($cache);
}
}
protected function _initLogger()
{
$config = new Zend_Config($this->getOptions());
$logFile = $config->profil->path->shared.'/log/application.log';
$log = new Logger('APP');
if (APPLICATION_ENV == 'development') {
$level = Logger::DEBUG;
} else {
$level = Logger::NOTICE;
}
$log->pushHandler(new StreamHandler($logFile, $level));
$log->pushProcessor(new IntrospectionProcessor());
Zend_Registry::set('logger', $log);
}
}
}
}

View File

@ -1,40 +0,0 @@
<?php
// --- Define path to application directory
defined('APPLICATION_PATH')
|| define('APPLICATION_PATH', realpath(__DIR__ . '/../application'));
// --- Define application environment
defined('APPLICATION_ENV')
|| define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'production'));
// --- Composer autoload
require_once realpath(__DIR__ . '/../vendor/autoload.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);
// Database - Zend Style
$db = Zend_Db::factory($c->profil->db->metier);
Zend_Db_Table_Abstract::setDefaultAdapter($db);
// Database - Doctrine Style
$config = new \Doctrine\DBAL\Configuration();
$connectionParams = array(
'dbname' => $c->profil->db->metier->params->dbname,
'user' => $c->profil->db->metier->params->username,
'password' => $c->profil->db->metier->params->password,
'host' => $c->profil->db->metier->params->host,
'charset' => 'utf8',
'driver' => 'pdo_mysql',
);
try {
$conn = \Doctrine\DBAL\DriverManager::getConnection($connectionParams, $config);
Zend_Registry::set('doctrine', $conn);
} catch (\Doctrine\DBAL\DBALException $e) {
echo "Connection Database impossible.\n";
exit;
}

View File

@ -1 +0,0 @@
/application.ini

View File

@ -0,0 +1,33 @@
[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 "/../cache/sessions"
;resources.session.gc_maxlifetime = 86400
;resources.session.cookie_lifetime = 86400
;resources.session.remember_me_seconds = 86400
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_"
[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

View File

@ -1,55 +0,0 @@
<?php
return array(
array(
'label'=> "Accueil",
'controller' => 'index',
'action' => 'index',
'pages' => array(),
),
array(
'label'=> "Documentation",
'controller' => 'documentation',
'action' => 'index',
'pages' => array(
array(
'label'=> "Information générale",
'controller' => 'documentation',
'action' => 'index',
'pages' => array(),
),
array(
'uri' => '#',
),
array(
'label'=> "Liste des services",
'controller' => 'documentation',
'action' => 'services',
'pages' => array(),
),
),
),
array(
'label'=> "Démonstration",
'controller' => 'demo',
'action' => 'index',
'pages' => array(),
),
array(
'label'=> "Contact",
'controller' => 'index',
'action' => 'contact',
'pages' => array(),
),
array(
'label'=> "Paramètres",
'controller' => 'user',
'action' => 'params',
'pages' => array(),
),
array(
'label'=> "A propos",
'controller' => 'index',
'action' => 'about',
'pages' => array(),
),
);

View File

@ -1,107 +1,102 @@
<?php
class DemoController extends Zend_Controller_Action
{
protected $_username;
protected $_hash;
protected $_username;
protected $_hash;
protected $methods = array(
'getIdentite' => array(
'ws' => 'entreprise/v0.8?wsdl',
'form' => 'getIdentite',
),
);
protected $methods = array(
'getIdentite' => array(
'ws' => 'entreprise/v0.4?wsdl',
'form' => 'getIdentite',
),
);
public function init()
public function init()
{
require_once 'Web/demo/getIdentite.php';
$auth = Zend_Auth::getInstance();
$this->_username = $auth->getIdentity()->username;
$this->_hash = $auth->getIdentity()->hash;
}
public function indexAction()
{
$auth = Zend_Auth::getInstance();
$this->_username = $auth->getIdentity()->username;
$this->_hash = $auth->getIdentity()->hash;
$tabMethods = array();
foreach($this->methods as $method => $element){
$url = $this->view->url(array(
'controller' => 'demo',
'action' => 'method',
'name' => $method,
));
$tabMethods[] = array(
'nom' => $method,
'url' => $url,
);
}
$this->view->assign('methods', $tabMethods);
}
public function indexAction()
{
//Liste
public function methodAction()
{
$method = $this->_getParam('name','');
$this->view->assign('method', $method);
//Affichage du formulaire
if (array_key_exists($method, $this->methods)){
$class = 'Form_'.$method;
if (class_exists($class)){
$form = new $class;
$form->addElement('hidden', 'method', array(
'value' => $method,
));
if ($this->_request->isPost()) {
$formData = $this->_request->getPost();
$form->populate($formData);
}
$this->view->assign('form', $form);
} else {
$this->view->assign('message',"Impossible d'afficher le formulaire !");
}
}
}
$tabMethods = array();
foreach ($this->methods as $method => $element) {
$url = $this->view->url(array(
'controller' => 'demo',
'action' => 'method',
'name' => $method,
));
$tabMethods[] = array(
'nom' => $method,
'url' => $url,
);
}
$this->view->assign('methods', $tabMethods);
}
public function methodAction()
{
$method = $this->_getParam('name', '');
$this->view->assign('method', $method);
//Affichage du formulaire
if (array_key_exists($method, $this->methods)) {
$class = 'Scores_Ws_Form_'.ucfirst($method);
if (class_exists($class)) {
$form = new $class;
$form->addElement('hidden', 'method', array(
'value' => $method,
));
if ($this->_request->isPost()) {
$formData = $this->_request->getPost();
$form->populate($formData);
}
$this->view->assign('form', $form);
} else {
$this->view->assign('message', "Impossible d'afficher le formulaire !");
}
}
}
public function requeteAction()
{
public function requeteAction()
{
if ($this->_request->isPost()) {
$formData = $this->_request->getPost();
$method = $formData['method'];
$class = 'Scores_Ws_Form_'.ucfirst($method);
if (class_exists($class)) {
$form = new $class;
if ($form->isValid($formData)) {
$method = $formData['method'];
$siret = $formData['siret'];
$accesWs = $this->methods[$method]['ws'];
$hostName = $this->getRequest()->getHttpHost();
$options = array(
'login' => $this->_username,
'password' => $this->_hash,
'features' => SOAP_USE_XSI_ARRAY_TYPE + SOAP_SINGLE_ELEMENT_ARRAYS
);
$client = new Zend_Soap_Client('http://'.$hostName.'/'.$accesWs, $options);
$params = new StdClass();
$params->siret = $siret;
try {
$reponse = $client->getIdentite($params);
} catch (Zend_Soap_Client_Exception $e) {
$reponse = $e->getMessage();
}
$soap = array(
'requete' => $params,
'reponse' => $reponse,
);
$this->view->assign('soap', $soap);
$xml = array(
'requete' => $client->getLastRequest(),
'reponse' => $client->getLastResponse()
);
$this->view->assign('xml', $xml);
} else {
$this->_forward('method', 'demo', null, array('name'=> 'getIdentite'));
}
}
$method = $formData['method'];
$class = 'Form_'.$method;
if (class_exists($class)) {
$form = new $class;
if ($form->isValid($formData)) {
$method = $formData['method'];
$siret = $formData['siret'];
$accesWs = $this->methods[$method]['ws'];
$hostName = $this->getRequest()->getHttpHost();
$options = array(
'login' => $this->_username,
'password' => $this->_hash,
'features' => SOAP_USE_XSI_ARRAY_TYPE + SOAP_SINGLE_ELEMENT_ARRAYS
);
$client = new Zend_Soap_Client('http://'.$hostName.'/'.$accesWs, $options);
$params = new StdClass();
$params->siret = $siret;
$soap = array(
'requete' => $params,
'reponse' => $client->getIdentite($params)
);
$this->view->assign('soap',$soap);
$xml = array(
'requete' => $client->getLastRequest(),
'reponse' => $client->getLastResponse()
);
$this->view->assign('xml',$xml);
} else {
$this->_forward('method', 'demo', null, array('name'=> 'getIdentite'));
}
}
}
}
}
}

View File

@ -2,188 +2,168 @@
class DocumentationController extends Zend_Controller_Action
{
/**
/**
* Affichage de la documentation des webservices
*/
public function indexAction()
{
//Do nothing
}
$request = $this->getRequest();
$ws = $request->getParam('ws','Entreprise');
$auth = Zend_Auth::getInstance();
//Si client possède un webservice particulier alors on redirige vers la doc clients
$clients = new Zend_Config_Ini('WsScore/Clients/Clients.ini');
foreach( $clients->toArray() as $section => $params ){
if ($params['actif']) {
$wsClients[$params['idClient']] = $section;
}
}
if (array_key_exists($auth->getIdentity()->idClient, $wsClients)){
/**
* Liste des services
*/
public function servicesAction()
$this->_forward('clients', 'documentation', null, array(
'nom' => $wsClients[$auth->getIdentity()->idClient]
));
} else {
// Liste des webservices
$services = new Zend_Config_Ini('WsScore/Services.ini');
foreach( $services->toArray() as $section => $params ){
if ($params['actif']) {
$wsServices[$section] = $params;
}
}
// On vérifie que l'utilisateur peut accèder à la documentation
$username = $auth->getIdentity()->username;
$idClient = $auth->getIdentity()->idClient;
if ( array_key_exists($ws, $wsServices) )
{
if ( isset($wsServices['idClient']) && $idClient!=$wsServices['idClient'] )
{
$this->renderScript('documentation/nodoc.phtml');
exit;
}
if ( isset($wsServices['user']) && !in_array($username, $wsServices['user']) )
{
$this->renderScript('documentation/nodoc.phtml');
exit;
}
}
// Gestion des versions
$configServiceVersions = new Zend_Config_Ini('WsScore/'.ucfirst($ws).'/Versions.ini');
foreach( $configServiceVersions->toArray() as $section => $params ){
$serviceVersions[$section] = $params;
if ($params['defaut']) {
$defautVersion = $section;
}
}
$version = $request->getParam('version', $defautVersion);
// Charger les classes et les types pour le service suivant la version
$pathClassService = 'WsScore/'.ucfirst($ws).'/v'.$version.'/';
//Génération du tableau de mapping
$classmap = array();
$wsConfig = new Zend_Config_Ini($pathClassService.ucfirst($ws).'.ini');
if ( $wsConfig->count()>0 ) {
foreach($wsConfig->Type->toArray() as $Type){
$classmap[$Type] = $Type;
}
}
//Définir l'url d'accès au WSDL
$wsdl_url = $this->view->baseUrl();
if (APPLICATION_ENV == 'production'){
$wsdl_url.= '/'.$ws.'/v'.$version.'?wsdl';
} else {
$wsdl_url.= '/'.$ws.'/v'.$version.'?wsdl-auto';
}
// Affichage de la documentation
require_once 'Web/WebClassDoc.php';
$doc = new WebClassDoc(ucfirst($ws), $classmap, $pathClassService);
$tabServiceMethods = $doc->getServiceMethods();
// Tri des méthodes par ordre alphabétique
$tabServiceMethodsK = array();
foreach($tabServiceMethods as $method) {
$tabServiceMethodsK[$method['name']] = $method;
}
ksort($tabServiceMethodsK);
$tabServiceTypes = $doc->getServiceTypes();
$this->view->assign('wsdl', $wsdl_url);
$this->view->assign('serviceMethods', $tabServiceMethodsK);
$this->view->assign('serviceTypes', $tabServiceTypes);
}
}
public function clientsAction()
{
$request = $this->getRequest();
$client = $request->getParam('nom');
$ws = 'Entreprise';
// Gestion des versions
$configServiceVersions = new Zend_Config_Ini('WsScore/Clients/'.ucfirst($client).'/Versions.ini');
foreach( $configServiceVersions->toArray() as $section => $params ){
$serviceVersions[$section] = $params;
if ($params['defaut']) {
$defautVersion = $section;
}
}
$version = $request->getParam('version', $defautVersion);
// Charger les classes et les types pour le service suivant la version
$pathClassService = 'WsScore/Clients/'.ucfirst($client).'/v'.$version.'/';
//Génération du tableau de mapping
$classmap = array();
$wsConfig = new Zend_Config_Ini($pathClassService.$ws.'.ini');
if ( $wsConfig->count()>0 ) {
foreach($wsConfig->Type->toArray() as $Type){
$classmap[$Type] = $Type;
}
}
//Définir l'url d'accès au WSDL
$wsdl_url = $this->view->baseUrl();
if (APPLICATION_ENV == 'production'){
$wsdl_url.= '/clients/'.$client.'/v'.$version.'?wsdl';
} else {
$wsdl_url.= '/clients/'.$client.'/v'.$version.'?wsdl-auto';
}
// Affichage de la documentation
require_once 'Web/WebClassDoc.php';
$doc = new WebClassDoc($ws, $classmap, $pathClassService);
$tabServiceMethods = $doc->getServiceMethods();
// Tri des méthodes par ordre alphabétique
$tabServiceMethodsK = array();
foreach($tabServiceMethods as $method) {
$tabServiceMethodsK[$method['name']] = $method;
}
ksort($tabServiceMethodsK);
$tabServiceTypes = $doc->getServiceTypes();
$this->view->assign('wsdl', $wsdl_url);
$this->view->assign('serviceMethods', $tabServiceMethodsK);
$this->view->assign('serviceTypes', $tabServiceTypes);
}
/**
* Liste des version par service
*/
public function servicevAction()
{
$request = $this->getRequest();
$name = $request->getParam('name');
$this->view->key = $name;
}
public function serviceAction()
{
$request = $this->getRequest();
$type = $request->getParam('type', 'sd');
$ws = strtolower($request->getParam('name', 'entreprise'));
$myService = $this->view->WsServices[$ws];
// Gestion des versions
$serviceVersions = array();
$configServiceVersions = $myService['versions'];
foreach ($configServiceVersions as $section => $params) {
$serviceVersions[$section] = $params;
if ($params['defaut']) {
$defautVersion = $section;
}
}
$version = $request->getParam('version', $defautVersion);
$this->view->assign('serviceName', $myService['name']);
$this->view->assign('serviceVersion', $version);
$isDeprecated = false;
if ($myService['versions'][$version]['defaut'] == '') {
$isDeprecated = true;
}
$this->view->assign('isDeprecated', $isDeprecated);
if ($type == 'client') {
$client = $ws;
$ws = 'entreprise';
}
// Charger les classes et les types pour le service suivant la version
if ($type == 'client') {
$pathClassService = 'WsScore/Clients/'.ucfirst($client).'/v'.$version.'/';
} else {
$pathClassService = 'WsScore/'.ucfirst($ws).'/v'.$version.'/';
}
//Génération du tableau de mapping
$classmap = include $pathClassService.'Config.php';
//Définir l'url d'accès au WSDL
$wsdl_url = $this->view->baseUrl();
if ($type == 'client') {
$wsdl_url.= '/clients/'.$client.'/v'.$version;
} else {
$wsdl_url.= '/'.$ws.'/v'.$version;
}
if (APPLICATION_ENV == 'production') {
$wsdl_url.= '?wsdl';
} else {
$wsdl_url.= '?wsdl-auto';
}
// Affichage de la documentation
$doc = new Scores_Ws_Doc(ucfirst($ws), $classmap, $pathClassService);
$tabServiceMethods = $doc->getServiceMethods();
// Tri des méthodes par ordre alphabétique
$tabServiceMethodsK = array();
foreach ($tabServiceMethods as $method) {
$tabServiceMethodsK[$method['name']] = $method;
}
ksort($tabServiceMethodsK);
$tabServiceTypes = $doc->getServiceTypes();
$this->view->assign('wsdl', $wsdl_url);
$this->view->assign('serviceMethods', $tabServiceMethodsK);
$this->view->assign('serviceTypes', $tabServiceTypes);
}
/**
* Liste les exemples de code disponible pour chaque méthode
*/
public function exemplesAction()
{
$request = $this->getRequest();
$ws = strtolower($request->getParam('ws', 'Entreprise'));
$auth = Zend_Auth::getInstance();
public function exemplesAction()
{
//Si client possède un webservice particulier alors on redirige vers la doc clients
$clients = include APPLICATION_PATH . '/../library/WsScore/Clients/ClientsConfig.php';
foreach ($clients as $section => $params) {
if ($params['actif']) {
$wsClients[$params['idClient']] = $section;
}
}
if (array_key_exists($auth->getIdentity()->idClient, $wsClients)) {
$this->_forward('clients', 'documentation', null, array(
'nom' => $wsClients[$auth->getIdentity()->idClient]
));
} else {
// Liste des webservices
$services = include APPLICATION_PATH . '/../library/WsScore/ServicesConfig.php';
foreach ($services as $section => $params) {
if ($params['actif']) {
$wsServices[$section] = $params;
}
}
// On vérifie que l'utilisateur peut accèder à la documentation
$username = $auth->getIdentity()->username;
$idClient = $auth->getIdentity()->idClient;
if (array_key_exists($ws, $wsServices)) {
if (isset($wsServices['idClient']) && $idClient!=$wsServices['idClient']) {
$this->renderScript('documentation/nodoc.phtml');
exit;
}
if (isset($wsServices['user']) && !in_array($username, $wsServices['user'])) {
$this->renderScript('documentation/nodoc.phtml');
exit;
}
}
// Gestion des versions
$serviceVersions = array();
$configServiceVersions = $wsServices[$ws]['versions'];
foreach ($configServiceVersions as $section => $params) {
$serviceVersions[$section] = $params;
if ($params['defaut']) {
$defautVersion = $section;
}
}
$version = $request->getParam('version', $defautVersion);
// Charger les classes et les types pour le service suivant la version
$pathClassService = 'WsScore/'.ucfirst($ws).'/v'.$version.'/';
//Génération du tableau de mapping
$classmap = include $pathClassService.'Config.php';
//Définir l'url d'accès au WSDL
$wsdl_url = $this->view->baseUrl();
if (APPLICATION_ENV == 'production') {
$wsdl_url.= '/'.$ws.'/v'.$version.'?wsdl';
} else {
$wsdl_url.= '/'.$ws.'/v'.$version.'?wsdl-auto';
}
// Affichage de la documentation
$doc = new Scores_Ws_Doc(ucfirst($ws), $classmap, $pathClassService);
$tabServiceMethods = $doc->getServiceMethods();
// Tri des méthodes par ordre alphabétique
$tabServiceMethodsK = array();
foreach ($tabServiceMethods as $method) {
$tabServiceMethodsK[$method['name']] = $method;
}
ksort($tabServiceMethodsK);
$tabServiceTypes = $doc->getServiceTypes();
$this->view->assign('wsdl', $wsdl_url);
$this->view->assign('serviceMethods', $tabServiceMethodsK);
$this->view->assign('serviceTypes', $tabServiceTypes);
}
}
}
/**
* Affichage exemple de code avec coloration syntaxique
@ -192,32 +172,36 @@ class DocumentationController extends Zend_Controller_Action
*/
public function codeAction()
{
$langage = strtolower($this->_getParam('langage', ''));
$element = $this->_getParam('element', '');
$langage = strtolower($this->_getParam('langage',''));
$element = $this->_getParam('element','');
$fichier = APPLICATION_PATH . '/../public/assets/code/' . $element . '-' . $langage . '.txt';
if (file_exists($fichier)) {
$sourceCode = file_get_contents($fichier);
$fichier = APPLICATION_PATH .
'/../public/code/' . $element . '-' . $langage . '.txt';
if (file_exists($fichier)){
$sourceCode = file_get_contents($fichier);
$geshi = new GeSHi($sourceCode, $langage);
$geshi->enable_line_numbers(GESHI_NORMAL_LINE_NUMBERS);
$sourceHighlight = $geshi->parse_code();
require_once 'geshi/geshi.php';
$geshi = new GeSHi($sourceCode, $langage);
$geshi->enable_line_numbers(GESHI_NORMAL_LINE_NUMBERS);
$sourceHighlight = $geshi->parse_code();
$this->view->assign('langage', strtoupper($langage));
$this->view->assign('code', $sourceHighlight);
} else {
$this->view->assign('langage',
'Element non traités, Vous pouvez aussi nous fournir des exemples.');
}
$this->view->assign('langage', strtoupper($langage));
$this->view->assign('code', $sourceHighlight);
} else {
$this->view->assign('langage',
'Element non traités, Vous pouvez aussi nous fournir des exemples.');
}
}
/**
* Affichage de la liste des erreurs avec leur code
*/
public function erreurAction()
{
$ws = new Scores_Ws_Server();
$erreurs = $ws->listError;
$this->view->assign('erreurs', $erreurs);
require_once 'WsScore/WsScore.php';
$ws = new WsScore();
$erreurs = $ws->listError;
$this->view->assign('erreurs', $erreurs);
}
}

View File

@ -1,7 +1,7 @@
<?php
class ErrorController extends Zend_Controller_Action
{
public function errorAction()
public function errorAction()
{
$errors = $this->_getParam('error_handler');
@ -44,3 +44,4 @@ class ErrorController extends Zend_Controller_Action
return $log;
}
}

View File

@ -0,0 +1,20 @@
<?php
class ExportController extends Zend_Controller_Action
{
public function init()
{
$this->_helper->layout->disableLayout();
$this->_helper->viewRenderer->setNoRender();
}
public function indexAction()
{
echo "Export";
}
protected function checkFile($path)
{
}
}

View File

@ -1,261 +1,59 @@
<?php
class FichierController extends Zend_Controller_Action
{
/**
* PDO Connection with Doctrine
* @var \Doctrine\DBAL\Connection
*/
protected $conn;
public function init()
{
$this->_helper->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
$this->conn = Zend_Registry::get('doctrine');
}
public function bodaccAction()
{
$auth = Zend_Auth::getInstance();
if ($auth->hasIdentity()) {
$c = Zend_Registry::get('config');
$directory = $c->profil->path->shared.'/datafile/bodacc/histo';
$q = $this->getRequest()->getParam('q');
$filename = base64_decode($q);
$file = $directory.'/'.$filename;
if (file_exists($file) && filesize($file) > 0) {
//Log de la requete
$data = array(
'login' => $auth->getIdentity()->username,
'idClient' => $auth->getIdentity()->idClient,
'page' => 'histobodacc',
'siren' => '',
'nic' => '',
'params' => $file,
'test' => 0,
'raisonSociale' => '',
'cp' => '',
'ville' => '',
'ipClient' => $_SERVER['REMOTE_ADDR'],
);
$this->conn->insert('sdv1.logs', $data);
$content_type = 'application/pdf';
// --- Envoi du fichier sur la sortie standard
$modules = array(); //apache_get_modules();
if (in_array('mod_xsendfile', $modules)) {
header('X-Sendfile: ' . $file);
header('Content-Type: ' . $content_type);
header('Content-Disposition: inline; filename="' . $content_type . '"');
exit;
} else {
ini_set('zlib.output_compression', '0');
header('Content-Transfer-Encoding: none');
header('Content-Type: ' . $content_type.'');
header('Content-Length: ' . filesize($file));
header('Content-MD5: ' . base64_encode(md5_file($file)));
header('Content-Disposition: inline; filename="' . basename($file) . '"');
header('Cache-Control: private, max-age=0, must-revalidate');
header('Pragma: public');
readfile($file);
exit;
}
} else {
echo "Erreur lors de l'affichage du fichier.";
}
} else {
echo "Authentification échoué.";
}
}
public function logsAction()
{
$content_type = 'application/csv-tab-delimited-table';
$filename = $this->getRequest()->getParam('fichier');
$c = Zend_Registry::get('config');
$file = $c->profil->path->shared . '/files/'.$filename;
// --- Envoi du fichier sur la sortie standard
if (file_exists($file)) {
$modules = array(); //apache_get_modules();
if (in_array('mod_xsendfile', $modules)) {
header('X-Sendfile: ' . $file);
header('Content-Type: ' . $content_type);
header('Content-Disposition: inline; filename="' . $content_type . '"');
exit;
} else {
ini_set('zlib.output_compression', '0');
header('Content-Transfer-Encoding: none');
header('Content-Type: ' . $content_type.'');
header('Content-Length: ' . filesize($file));
header('Content-MD5: ' . base64_encode(md5_file($file)));
header('Content-Disposition: inline; filename="' . basename($file) . '"');
header('Cache-Control: private, max-age=0, must-revalidate');
header('Pragma: public');
readfile($file);
exit;
}
} else {
$this->getResponse()->setHttpResponseCode(404);
}
}
public function csvAction()
{
$content_type = 'application/csv-tab-delimited-table';
$filename = $this->getRequest()->getParam('fichier');
$c = Zend_Registry::get('config');
$file = $c->profil->path->shared . '/files/'. $filename;
// --- Envoi du fichier sur la sortie standard
if (file_exists($file)) {
$modules = array(); //apache_get_modules();
if (in_array('mod_xsendfile', $modules)) {
header('X-Sendfile: ' . $file);
header('Content-Type: ' . $content_type);
header('Content-Disposition: inline; filename="' . $content_type . '"');
exit;
} else {
ini_set('zlib.output_compression', '0');
header('Content-Transfer-Encoding: none');
header('Content-Type: ' . $content_type.'');
header('Content-Length: ' . filesize($file));
header('Content-MD5: ' . base64_encode(md5_file($file)));
header('Content-Disposition: inline; filename="' . basename($file) . '"');
header('Cache-Control: private, max-age=0, must-revalidate');
header('Pragma: public');
readfile($file);
exit;
}
} else {
$this->getResponse()->setHttpResponseCode(404);
}
}
public function kbisAction()
{
$content_type = 'application/pdf';
$filename = $this->getRequest()->getParam('fichier');
$c = Zend_Registry::get('config');
$file = realpath($c->profil->path->shared).'/datafile/kbis/'.$filename;
// --- Envoi du fichier sur la sortie standard
if (file_exists($file)) {
$modules = array(); //apache_get_modules();
if (in_array('mod_xsendfile', $modules)) {
header('X-Sendfile: ' . $file);
header('Content-Type: ' . $content_type);
header('Content-Disposition: inline; filename="' . $content_type . '"');
exit;
} else {
ini_set('zlib.output_compression', '0');
header('Content-Transfer-Encoding: none');
header('Content-Type: ' . $content_type.'');
header('Content-Length: ' . filesize($file));
header('Content-MD5: ' . base64_encode(md5_file($file)));
header('Content-Disposition: inline; filename="' . basename($file) . '"');
header('Cache-Control: private, max-age=0, must-revalidate');
header('Pragma: public');
readfile($file);
exit;
}
} else {
$this->getResponse()->setHttpResponseCode(404);
}
}
public function associationsAction()
{
$content_type = 'application/pdf';
$filename = $this->getRequest()->getParam('fichier');
$c = Zend_Registry::get('config');
$file = $c->profil->path->shared . '/files/' . $filename;
// --- Envoi du fichier sur la sortie standard
if (file_exists($file)) {
$modules = array(); //apache_get_modules();
if (in_array('mod_xsendfile', $modules)) {
header('X-Sendfile: ' . $file);
header('Content-Type: ' . $content_type);
header('Content-Disposition: inline; filename="' . $content_type . '"');
exit;
} else {
ini_set('zlib.output_compression', '0');
header('Content-Transfer-Encoding: none');
header('Content-Type: ' . $content_type.'');
header('Content-Length: ' . filesize($file));
header('Content-MD5: ' . base64_encode(md5_file($file)));
header('Content-Disposition: inline; filename="' . basename($file) . '"');
header('Cache-Control: private, max-age=0, must-revalidate');
header('Pragma: public');
readfile($file);
exit;
}
} else {
$this->getResponse()->setHttpResponseCode(404);
}
}
public function greffesAction()
{
$content_type = 'application/pdf';
$filename = $this->getRequest()->getParam('fichier');
$c = Zend_Registry::get('config');
$file = $c->profil->path->shared . '/files/' .$filename;
// --- Envoi du fichier sur la sortie standard
if (file_exists($file)) {
$modules = array(); //apache_get_modules();
if (in_array('mod_xsendfile', $modules)) {
header('X-Sendfile: ' . $file);
header('Content-Type: ' . $content_type);
header('Content-Disposition: inline; filename="' . $content_type . '"');
exit;
} else {
ini_set('zlib.output_compression', '0');
header('Content-Transfer-Encoding: none');
header('Content-Type: ' . $content_type.'');
header('Content-Length: ' . filesize($file));
header('Content-MD5: ' . base64_encode(md5_file($file)));
header('Content-Disposition: inline; filename="' . basename($file) . '"');
header('Cache-Control: private, max-age=0, must-revalidate');
header('Pragma: public');
readfile($file);
exit;
}
} else {
$this->getResponse()->setHttpResponseCode(404);
}
}
public function crmAction()
{
$content_type = 'application/x-bzip';
$filename = $this->getRequest()->getParam('fichier');
$c = Zend_Registry::get('config');
$file = $c->profil->path->shared . '/files/' .$filename;
// --- Envoi du fichier sur la sortie standard
if (file_exists($file)) {
$modules = array(); //apache_get_modules();
if (in_array('mod_xsendfile', $modules)) {
header('X-Sendfile: ' . $file);
header('Content-Type: ' . $content_type);
header('Content-Disposition: inline; filename="' . $content_type . '"');
exit;
} else {
ini_set('zlib.output_compression', '0');
header('Content-Transfer-Encoding: none');
header('Content-Type: ' . $content_type.'');
header('Content-Length: ' . filesize($file));
header('Content-MD5: ' . base64_encode(md5_file($file)));
header('Content-Disposition: inline; filename="' . basename($file) . '"');
header('Cache-Control: private, max-age=0, must-revalidate');
header('Pragma: public');
readfile($file);
exit;
}
} else {
$this->getResponse()->setHttpResponseCode(404);
}
}
}
public function init()
{
$this->_helper->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
}
public function bodaccAction()
{
$auth = Zend_Auth::getInstance();
if ( $auth->hasIdentity() ) {
$directory = realpath(DOC_WEB_LOCAL).'/bodacc';
$q = $this->getRequest()->getParam('q');
$file = base64_decode($q);
$output_file = $directory.'/'.$file;
if (file_exists($output_file) && filesize($output_file)>0) {
$content_type = 'application/pdf';
header('Content-type: '.$content_type.'');
header('Content-Length: '.filesize($output_file));
header('Content-MD5: '.base64_encode(md5_file($output_file)));
header('Content-Disposition: inline; filename="'.basename($output_file).'"');
header('Cache-Control: private, max-age=0, must-revalidate');
header('Pragma: public');
ini_set('zlib.output_compression','0');
echo file_get_contents($output_file);
//Log de la requete
$tabInsert = array(
'login' => $auth->getIdentity()->username,
'idClient' => $auth->getIdentity()->idClient,
'page' => 'histobodacc',
'siren' => '',
'nic' => '',
'params' => $file,
'test' => 0,
'raisonSociale' => '',
'cp' => '',
'ville' => '',
'ipClient' => $_SERVER['REMOTE_ADDR'],
);
require_once 'framework/common/mysql.php';
$iDbCrm = new WDB('sdv1');
$rep = $iDbCrm->insert('logs', array_merge($tabInsert,$tabRdvInsee), false, true);
} else {
echo "Erreur lors de l'affichage du fichier.";
}
} else {
}
}
}

View File

@ -0,0 +1,78 @@
<?php
class ImportController extends Zend_Controller_Action
{
public function fileformAction()
{
$this->_helper->layout()->disableLayout();
$this->view->inlineScript()->appendFile('/scripts/jquery.form.js');
$this->view->inlineScript()->appendFile('/scripts/jqueryprogressbar.js');
$this->view->assign('filesize', ini_get('upload_max_filesize'));
$request = $this->getRequest();
$idClient = $request->getParam('idClient', null);
$login = $request->getParam('login', null);
$this->view->assign('idClient', $idClient);
$this->view->assign('login', $login);
}
public function fileuploadAction()
{
$this->_helper->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
$request = $this->getRequest();
$idClient = $request->getParam('idClient');
$login = $request->getParam('login');
$config = new Zend_Config_Ini(APPLICATION_PATH . '/configs/configuration.ini', 'path');
$path = realpath($config->data).'/validation';
if(!file_exists($path)) mkdir($path);
if ( isset($_FILES) && count($_FILES)==1 ){
$n = $_FILES['fichier']['name'];
$s = $_FILES['fichier']['size'];
$tmp_name = $_FILES['fichier']['tmp_name'];
$extValide = array('csv');
$extension = strrchr($n,'.');
$extension = substr($extension,1);
//Vérifier l'extension du fichier
if(!in_array($extension, $extValide)){
echo "Extension de fichier incorrect !";
} elseif (move_uploaded_file($tmp_name, $path.'/'.$idClient.'-'.$name.'.'.$extension)){
echo "Fichier envoyé, <a href=\"".
$this->view->url(array(
'controller' => 'import',
'action' => 'checkfile',
'file' => $idClient.'-'.$name.'.'.$extension,
))."\">Vérifier le format</a>";
} else {
echo "Erreur : ".$_FILES['fichier']['error'];
}
}
}
/**
* Etat de progression de l'upload du fichier
*/
public function fileprogressAction()
{
$this->_helper->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
$request = $this->getRequest();
$key = $request->getParam('key', '');
if (!empty($key)) {
//$rep sera égal à false si la clef n'existe pas dans le cache apc
$rep = apc_fetch('upload_'.$key);
echo json_encode($rep);
}
}
}

View File

@ -1,15 +1,85 @@
<?php
class IndexController extends Zend_Controller_Action
{
protected $serviceList = array();
protected $serviceClientList = array();
public function init()
{
$auth = Zend_Auth::getInstance();
//Lecture des webservices normaux
$services = new Zend_Config_Ini('WsScore/Services.ini');
foreach( $services->toArray() as $section => $params ){
if ($params['actif']) {
$wsServices[$section] = $params;
}
}
//Parcourir les webservices
foreach($wsServices as $serviceName => $serviceInfo)
{
if ( !isset($wsServices[$serviceName]['idClient']) || $wsServices[$serviceName]['idClient'] == $auth->getIdentity()->idClient)
{
$configServiceVersions = new Zend_Config_Ini('WsScore/'.ucfirst($serviceName).'/Versions.ini', null);
$serviceVersions = array();
foreach( $configServiceVersions->toArray() as $section => $params )
{
$serviceVersions[$section] = $params;
$this->serviceList[$serviceName]['version'] = $serviceVersions;
}
}
}
//Lecture des webservices Clients
$clients = new Zend_Config_Ini('WsScore/Clients/Clients.ini');
foreach( $clients->toArray() as $section => $params ){
if ($params['actif']) {
$wsClients[$section] = $params;
}
}
//Parcourir les webservices clients
foreach($wsClients as $serviceName => $serviceInfo)
{
if ($wsClients[$serviceName]['idClient'] == $auth->getIdentity()->idClient) {
$this->serviceList = array();
}
if ($wsClients[$serviceName]['idClient'] == $auth->getIdentity()->idClient || in_array($auth->getIdentity()->username, $wsClients[$serviceName]['user']) )
{
$configServiceVersions = new Zend_Config_Ini('WsScore/Clients/'.ucfirst($serviceName).'/Versions.ini', null);
$serviceVersions = array();
foreach( $configServiceVersions->toArray() as $section => $params )
{
$serviceVersions[$section] = $params;
$this->serviceList[$serviceName]['version'] = $serviceVersions;
$this->serviceList[$serviceName]['type'] = 'client';
}
}
}
}
public function indexAction()
{
$displayWs = array();
if (count($this->serviceList)>0)
{
foreach($this->serviceList as $key => $ws)
{
$displayWs[$key] = $ws;
}
}
$this->view->assign('ws', $displayWs);
}
public function contactAction()
{
}
public function aboutAction()
public function testAction()
{
//Connexion au service - Faire comme ci on charger le WSDL de l'extérieur
//getFunctions / getTypes
//Pour chaque Function, identifier les Types puis proposer les champs associés
//Valider les formulaires pour executer la requête du service
//Utiliser le jeux de tests disponible
}
}

View File

@ -1,106 +1,110 @@
<?php
class JsonrpcController extends Zend_Controller_Action
{
public function indexAction()
{
$this->_helper->layout->disableLayout();
$this->_helper->viewRenderer->setNoRender();
$request = $this->getRequest();
//Nom du service
$serviceName = strtolower($request->getParam('service', 'Entreprise'));
//Service spécifique client
if ($serviceName == 'clients') {
$client = $request->getParam('client', '');
//Liste des clients
$clients = array();
$listeClients = include APPLICATION_PATH . '/../library/WsScore/Clients/ClientsConfig.php';
foreach ($listeClients as $section => $params) {
if ($params['actif']) {
$clients[] = $section;
}
}
if (!in_array($client, $clients)) {
echo 'Service clients introuvable !';
exit;
}
$configServiceVersions = $clients[$client]['versions'];
} else {
//Service versions
$services = include APPLICATION_PATH . '/../library/WsScore/ServicesConfig.php';
$configServiceVersions = $services[$serviceName]['versions'];
}
//Liste des versions
foreach ($configServiceVersions as $section => $params) {
$serviceVersions[$section] = $params;
if ($params['defaut']) {
$defautVersion = $section;
}
}
$version = $request->getParam('version', 'v'.$defautVersion);
$version = substr($version, 1);
// Version inexistante
if (!array_key_exists($version, $serviceVersions)) {
echo "Version inexistante.";
exit;
}
// Version désactivé
if (!$serviceVersions[$version]['actif']) {
echo "Version désactivée.";
exit;
}
// Charger les classes et les types pour le service suivant la version
if ($serviceName == 'clients') {
$pathServiceClassIni = 'WsScore/Clients/'.ucfirst($client).'/v'.$version.'/Entreprise.ini';
$pathServiceClassPhp = 'WsScore/Clients/'.ucfirst($client).'/v'.$version.'/Entreprise.php';
$pathServiceUrl = 'clients/'.$client.'/v'.$version.'?wsdl-auto';
//On redéfini le nom du service
$serviceName = 'Entreprise';
$fichierWsdl = ucfirst($client).'-'.$serviceName.'-'.$version.'.wsdl';
} else {
$pathServiceClassIni = 'WsScore/'.ucfirst($serviceName).'/v'.$version.'/'.ucfirst($serviceName).'.ini';
$pathServiceClassPhp = 'WsScore/'.ucfirst($serviceName).'/v'.$version.'/'.ucfirst($serviceName).'.php';
$pathServiceUrl = $serviceName.'/v'.$version.'?wsdl-auto';
$fichierWsdl = ucfirst($serviceName).'-'.$version.'.wsdl';
}
//Génération du tableau de mapping
$wsConfig = new Zend_Config_Ini($pathServiceClassIni);
foreach ($wsConfig->Type->toArray() as $Type) {
$classmap[$Type] = $Type;
}
//Inclusion des classes de données
require_once $pathServiceClassPhp;
// Instance du server
$server = new Zend_Json_Server();
// Define class name
$server->setClass(ucfirst($serviceName));
// Gestion du SMD
if ($this->getRequest()->isGet()) {
// Indiquer URL endpoint
//$this->getHelper('url')->url(array('controller'=>'', 'action'=>'' ));
$server->setTarget('/jsonrpc/'.$serviceName.'/'.$version.'/')
->setEnvelope(Zend_Json_Server_Smd::ENV_JSONRPC_2);
// Grab the SMD
$smd = $server->getServiceMap();
//Return the SMD to the client
if (!headers_sent()) {
header('Content-Type: application/json');
}
echo $smd;
return;
} else {
$server->setAutoEmitResponse(true);
$server->handle();
}
}
}
public function init(){}
public function indexAction()
{
$this->_helper->layout->disableLayout();
$this->_helper->viewRenderer->setNoRender();
$request = $this->getRequest();
//Nom du service
$serviceName = $request->getParam('service', 'Entreprise');
//Chemin
$pathServiceVersion = 'WsScore/'.ucfirst($serviceName).'/Versions.ini';
//Service spécifique client
if (strtolower($serviceName) == 'clients') {
$client = $request->getParam('client', '');
//Liste des clients
$clients = array();
$listeClients = new Zend_Config_Ini('WsScore/Clients/Clients.ini');
foreach ( $listeClients->toArray() as $section => $params ){
if ($params['actif']){
$clients[] = $section;
}
}
if (!in_array($client, $clients)){
echo 'Service clients introuvable !';
exit;
}
$pathServiceVersion = 'WsScore/Clients/'.ucfirst($client).'/Versions.ini';
}
// Liste des versions
$configServiceVersions = new Zend_Config_Ini($pathServiceVersion);
foreach( $configServiceVersions->toArray() as $section => $params ){
$serviceVersions[$section] = $params;
if ($params['defaut']) {
$defautVersion = $section;
}
}
$version = $request->getParam('version', 'v'.$defautVersion);
$version = substr($version, 1);
// Version inexistante
if ( !array_key_exists($version, $serviceVersions) ) {
echo "Version inexistante.";
exit;
}
// Version désactivé
if ( !$serviceVersions[$version]['actif'] ) {
echo "Version désactivée.";
exit;
}
// Charger les classes et les types pour le service suivant la version
if (strtolower($serviceName) == 'clients') {
$pathServiceClassIni = 'WsScore/Clients/'.ucfirst($client).'/v'.$version.'/Entreprise.ini';
$pathServiceClassPhp = 'WsScore/Clients/'.ucfirst($client).'/v'.$version.'/Entreprise.php';
$pathServiceUrl = 'clients/'.$client.'/v'.$version.'?wsdl-auto';
//On redéfini le nom du service
$serviceName = 'Entreprise';
$fichierWsdl = ucfirst($client).'-'.$serviceName.'-'.$version.'.wsdl';
} else {
$pathServiceClassIni = 'WsScore/'.ucfirst($serviceName).'/v'.$version.'/'.ucfirst($serviceName).'.ini';
$pathServiceClassPhp = 'WsScore/'.ucfirst($serviceName).'/v'.$version.'/'.ucfirst($serviceName).'.php';
$pathServiceUrl = $serviceName.'/v'.$version.'?wsdl-auto';
$fichierWsdl = ucfirst($serviceName).'-'.$version.'.wsdl';
}
//Génération du tableau de mapping
$wsConfig = new Zend_Config_Ini($pathServiceClassIni);
foreach($wsConfig->Type->toArray() as $Type){
$classmap[$Type] = $Type;
}
//Inclusion des classes de données
require_once $pathServiceClassPhp;
// Instance du server
$server = new Zend_Json_Server();
// Define class name
$server->setClass(ucfirst($serviceName));
// Gestion du SMD
if($this->getRequest()->isGet()){
// Indiquer URL endpoint
//$this->getHelper('url')->url(array('controller'=>'', 'action'=>'' ));
$server->setTarget('/jsonrpc/'.$serviceName.'/'.$version.'/')
->setEnvelope(Zend_Json_Server_Smd::ENV_JSONRPC_2);
// Grab the SMD
$smd = $server->getServiceMap();
//Return the SMD to the client
if (!headers_sent()) {
header('Content-Type: application/json');
}
echo $smd;
return;
} else {
$server->setAutoEmitResponse(true);
$server->handle();
}
}
}

View File

@ -1,128 +1,119 @@
<?php
use League\Csv\Writer;
class RefController extends Zend_Controller_Action
{
public function indexAction()
{
//Ne fait rien...
}
public function indexAction ()
{
//Ne fait rien...
}
/**
* Donne accès au fichier
*/
public function fichierAction()
{
//Lecture du nom du fichier
$fichier = $this->_getParam('q', '');
$fichier = $fichier . '.csv';
if (!empty($fichier) && file_exists('fichiers/'.$fichier)) {
$this->_helper->layout->disableLayout();
$this->_helper->viewRenderer->setNoRender();
/**
* Donne accès au fichier
*/
public function fichierAction ()
{
//Lecture du nom du fichier
$fichier = $this->_getParam('q','');
$fichier = $fichier . '.csv';
if (!empty($fichier) && file_exists('fichiers/'.$fichier))
{
$this->_helper->layout->disableLayout();
$this->_helper->viewRenderer->setNoRender();
list($nomFichier, $extFichier) = explode('.', $fichier);
//Distribution du fichier sur la sortie standard
switch ($extFichier) {
case 'png': $content_type = 'image/png'; break;
case 'gif': $content_type = 'image/gif'; break;
case 'jpeg':
case 'jpg': $content_type = 'image/jpeg'; break;
case 'pdf': $content_type = 'application/pdf'; break;
case 'csv': $content_type = 'application/csv-tab-delimited-table'; break;
}
$this->getResponse()->setHeader('Content-Type', $content_type);
$contentDisposition = 'attachment';
switch ($contentDisposition) {
case 'inline':
$this->getResponse()->setHeader('Content-Disposition', 'inline');
break;
case 'attachment':
$this->getResponse()->setHeader('Content-Disposition', "attachment; filename=\"$fichier\"");
break;
}
list($nomFichier, $extFichier) = explode('.',$fichier);
//Distribution du fichier sur la sortie standard
switch ($extFichier) {
case 'png' : $content_type = 'image/png'; break;
case 'gif' : $content_type = 'image/gif'; break;
case 'jpeg':
case 'jpg' : $content_type = 'image/jpeg'; break;
case 'pdf' : $content_type = 'application/pdf'; break;
case 'csv' : $content_type = 'application/csv-tab-delimited-table'; break;
}
$this->getResponse()->setHeader('Content-Type', $content_type);
$contentDisposition = 'attachment';
switch ($contentDisposition) {
case 'inline':
$this->getResponse()->setHeader('Content-Disposition', 'inline');
break;
case 'attachment':
$this->getResponse()->setHeader('Content-Disposition', "attachment; filename=\"$fichier\"");
break;
}
$data = file_get_contents('assets/fichiers/'.$fichier);
$data = file_get_contents('fichiers/'.$fichier);
$this->getResponse()->setHeader('Content-Length', strlen($data))
->setHeader('Cache-Control', 'private, max-age=0, must-revalidate')
->setHeader('Pragma', 'public')
->setBody($data);
} else {
$this->view->assign('message', 'Fichier introuvable !');
}
}
$this->getResponse()->setHeader('Content-Length', strlen($data))
->setHeader('Cache-Control', 'private, max-age=0, must-revalidate')
->setHeader('Pragma', 'public')
->setBody($data);
} else {
$this->view->assign('message', 'Fichier introuvable !');
}
}
/**
* Donne accès aux données contenues dans une table de base de données
*/
public function tableAction()
{
$request = $this->getRequest();
$requetesql = $request->getParam('q', '');
$fichierCsv = $requetesql.'.csv';
$fichierSql = $requetesql.'.sql';
/**
* Donne accès aux données contenues dans une table de base de données
*/
public function tableAction ()
{
$requetesql = $this->_getParam('q','');
$fichierCsv = $requetesql.'.csv';
$fichierSql = $requetesql.'.sql';
//Emplacement des fichiers générés - lien symbolique en PRODUCTION
$c = Zend_Registry::get('config');
$path = $c->profil->path->shared . '/files/fichiers/';
if (!is_dir($path)) {
mkdir($path);
}
if (!empty($requetesql)) {
if (!file_exists($path . $fichierCsv)) {
if (file_exists('assets/sql/'.$fichierSql)) {
/**
* @var \Doctrine\DBAL\Connection $conn
*/
$conn = Zend_Registry::get('doctrine');
$sql = file_get_contents('assets/sql/'.$fichierSql);
$stmt = $conn->prepare($sql);
$stmt->setFetchMode(\PDO::FETCH_ASSOC);
$stmt->execute();
if ($stmt->rowCount() > 0) {
$csv = Writer::createFromPath($path . $fichierCsv.'.tmp', 'w');
$csv->setNewline("\r\n");
$headers = array_keys($stmt->fetch());
$csv->insertOne($headers);
$csv->insertAll($stmt);
}
rename($path . $fichierCsv.'.tmp', $path . $fichierCsv);
}
}
//Emplacement des fichiers générés - lien symbolique en PRODUCTION
$path = DOC_WEB_LOCAL . 'fichiers/';
if (!is_dir($path)) { mkdir($path); }
if (!empty($requetesql))
{
if (!file_exists($path . $fichierCsv))
{
if (file_exists('sql/'.$fichierSql))
{
//Connexion mysql
$sql = file_get_contents('sql/'.$fichierSql);
require_once 'framework/common/mysql.php';
$db = new WDB();
$db->exportCSV($sql, $path . $fichierCsv, ',', "\n");
}
}
if (file_exists($path . $fichierCsv)) {
$this->_helper->layout->disableLayout();
$this->_helper->viewRenderer->setNoRender();
//Distribution du fichier sur la sortie standard
list($nomFichier, $extFichier) = explode('.', $fichierCsv);
switch ($extFichier) {
case 'png': $content_type = 'image/png'; break;
case 'gif': $content_type = 'image/gif'; break;
case 'jpeg':
case 'jpg': $content_type = 'image/jpeg'; break;
case 'pdf': $content_type = 'application/pdf'; break;
case 'csv': $content_type = 'application/csv-tab-delimited-table'; break;
}
$this->getResponse()->setHeader('Content-Type', $content_type);
$contentDisposition = 'attachment';
switch ($contentDisposition) {
case 'inline':
$this->getResponse()->setHeader('Content-Disposition', 'inline');
break;
case 'attachment':
$this->getResponse()->setHeader('Content-Disposition', "attachment; filename=\"$fichierCsv\"");
break;
}
if (file_exists($path . $fichierCsv))
{
$this->_helper->layout->disableLayout();
$this->_helper->viewRenderer->setNoRender();
//Distribution du fichier sur la sortie standard
list($nomFichier, $extFichier) = explode('.',$fichierCsv);
switch ($extFichier)
{
case 'png' : $content_type = 'image/png'; break;
case 'gif' : $content_type = 'image/gif'; break;
case 'jpeg':
case 'jpg' : $content_type = 'image/jpeg'; break;
case 'pdf' : $content_type = 'application/pdf'; break;
case 'csv' : $content_type = 'application/csv-tab-delimited-table'; break;
}
$this->getResponse()->setHeader('Content-Type', $content_type);
$contentDisposition = 'attachment';
switch ($contentDisposition)
{
case 'inline':
$this->getResponse()->setHeader('Content-Disposition', 'inline');
break;
case 'attachment':
$this->getResponse()->setHeader('Content-Disposition', "attachment; filename=\"$fichierCsv\"");
break;
}
$data = file_get_contents($path . $fichierCsv);
$data = file_get_contents($path . $fichierCsv);
$this->getResponse()->setHeader('Content-Length', strlen($data))
->setHeader('Cache-Control', 'private, max-age=0, must-revalidate')
->setHeader('Pragma', 'public')
->setBody($data);
}
} else {
$this->view->assign('message', 'Paramètres incorrects !');
}
}
}
$this->getResponse()->setHeader('Content-Length', strlen($data))
->setHeader('Cache-Control', 'private, max-age=0, must-revalidate')
->setHeader('Pragma', 'public')
->setBody($data);
}
} else {
$this->view->assign('message', 'Paramètres incorrects !');
}
}
}

View File

@ -1,202 +1,172 @@
<?php
/**
* Distribute all SOAP based Web Services
*
*/
require_once 'framework/fwk.php';
class ServiceController extends Zend_Controller_Action
{
public function indexAction()
{
/**
* Be sure we don't make any render
*/
$this->_helper->layout->disableLayout();
$this->_helper->viewRenderer->setNoRender();
$this->_helper->layout->disableLayout();
$this->_helper->viewRenderer->setNoRender();
$request = $this->getRequest();
$request = $this->getRequest();
// --- Get the service name, make sure the string is in lower case
$serviceName = strtolower($request->getParam('service', 'Entreprise'));
//Get the service name, make sure the string is in lower case
$serviceName = strtolower($request->getParam('service', 'Entreprise'));
// --- ClassName and Directory with first letter capitalized
$serviceClassName = ucfirst($serviceName);
//ClassName and Directory with first letter capitalized
$serviceClassName = ucfirst($serviceName);
// --- Customize service for customers
if ('clients' == $serviceName) {
$client = strtolower($request->getParam('client', ''));
$clientClassName = ucfirst($client);
// --- Get list of customers
$clients = array();
$listeClients = include APPLICATION_PATH . '/../library/WsScore/Clients/ClientsConfig.php';
foreach ($listeClients as $section => $params) {
if ($params['actif']) {
$clients[$section] = $params;
}
}
if (!array_key_exists($client, $clients)) {
echo 'Service clients introuvable !';
exit;
}
$configServiceVersions = $clients[$client]['versions'];
}
// --- Service versions
else {
$services = include APPLICATION_PATH . '/../library/WsScore/ServicesConfig.php';
$configServiceVersions = $services[$serviceName]['versions'];
}
//path of file where versions of service is store
$pathServiceVersion = 'WsScore/'.$serviceClassName.'/Versions.ini';
// --- Check versions
foreach ($configServiceVersions as $section => $params) {
$serviceVersions[$section] = $params;
if ($params['defaut']) {
$defautVersion = $section;
}
}
$version = $request->getParam('version', 'v'.$defautVersion);
$version = substr($version, 1);
//Customize service for customers
if ('clients' == $serviceName ) {
$client = strtolower($request->getParam('client', ''));
$clientClassName = ucfirst($client);
//Get list of customers
$clients = array();
$listeClients = new Zend_Config_Ini('WsScore/Clients/Clients.ini');
foreach ( $listeClients->toArray() as $section => $params ){
if ($params['actif']) {
$clients[] = $section;
}
}
if (!in_array($client, $clients)){
echo 'Service clients introuvable !';
exit;
}
$pathServiceVersion = 'WsScore/Clients/'.$clientClassName.'/Versions.ini';
}
// --- Version inexistante
if (!array_key_exists($version, $serviceVersions)) {
echo "Version inexistante.";
exit;
}
// --- Version désactivé
if (!$serviceVersions[$version]['actif']) {
echo "Version désactivée.";
exit;
}
// Liste des versions
$configServiceVersions = new Zend_Config_Ini($pathServiceVersion);
foreach( $configServiceVersions->toArray() as $section => $params ){
$serviceVersions[$section] = $params;
if ($params['defaut']) {
$defautVersion = $section;
}
}
$version = $request->getParam('version', 'v'.$defautVersion);
$version = substr($version, 1);
// --- Charger les classes et les types pour le service suivant la version
if ('clients' == $serviceName) {
$pathServiceClassIni = 'WsScore/Clients/'.$clientClassName.'/v'.$version.'/Config.php';
$pathServiceClassPhp = 'WsScore/Clients/'.$clientClassName.'/v'.$version.'/Service.php';
// --- Gestion du mode de génération du wsdl
if (APPLICATION_ENV == 'development'
|| array_key_exists('mode', $serviceVersions[$version])
&& $serviceVersions[$version]['mode']=='auto') {
$pathServiceUrl = 'clients/'.$client.'/v'.$version.'?wsdl-auto';
} else {
$pathServiceUrl = 'clients/'.$client.'/v'.$version.'?wsdl';
}
$pathServiceUri = 'clients/'.$client.'/v'.$version;
// --- On redéfini le nom du service
$serviceClassName = 'Entreprise';
$fichierWsdl = $clientClassName.'-'.$serviceClassName.'-'.$version.'.wsdl';
} else {
$pathServiceClassIni = 'WsScore/'.$serviceClassName.'/v'.$version.'/Config.php';
$pathServiceClassPhp = 'WsScore/'.$serviceClassName.'/v'.$version.'/Service.php';
// --- Gestion du mode de génération du wsdl
if (APPLICATION_ENV == 'development'
|| array_key_exists('mode', $serviceVersions[$version])
&& $serviceVersions[$version]['mode']=='auto') {
$pathServiceUrl = $serviceName.'/v'.$version.'?wsdl-auto';
} else {
$pathServiceUrl = $serviceName.'/v'.$version.'?wsdl';
}
$pathServiceUri = $serviceName.'/v'.$version;
$fichierWsdl = $serviceClassName.'-'.$version.'.wsdl';
}
// Version inexistante
if ( !array_key_exists($version, $serviceVersions) ) {
echo "Version inexistante.";
exit;
}
// Version désactivé
if ( !$serviceVersions[$version]['actif'] ) {
echo "Version désactivée.";
exit;
}
// --- Get map of WSDL type to PHP Classes
$classmap = include $pathServiceClassIni;
// Charger les classes et les types pour le service suivant la version
if ('clients' == $serviceName) {
$pathServiceClassIni = 'WsScore/Clients/'.$clientClassName.'/v'.$version.'/Entreprise.ini';
$pathServiceClassPhp = 'WsScore/Clients/'.$clientClassName.'/v'.$version.'/Entreprise.php';
//Gestion du mode de génération du wsdl
if ( APPLICATION_ENV == 'development'
|| array_key_exists('mode', $serviceVersions[$version])
&& $serviceVersions[$version]['mode']=='auto') {
$pathServiceUrl = 'clients/'.$client.'/v'.$version.'?wsdl-auto';
} else {
$pathServiceUrl = 'clients/'.$client.'/v'.$version.'?wsdl';
}
//On redéfini le nom du service
$serviceClassName = 'Entreprise';
$fichierWsdl = $clientClassName.'-'.$serviceClassName.'-'.$version.'.wsdl';
} else {
$pathServiceClassIni = 'WsScore/'.$serviceClassName.'/v'.$version.'/'.$serviceClassName.'.ini';
$pathServiceClassPhp = 'WsScore/'.$serviceClassName.'/v'.$version.'/'.$serviceClassName.'.php';
//Gestion du mode de génération du wsdl
if ( APPLICATION_ENV == 'development'
|| array_key_exists('mode', $serviceVersions[$version])
&& $serviceVersions[$version]['mode']=='auto') {
$pathServiceUrl = $serviceName.'/v'.$version.'?wsdl-auto';
} else {
$pathServiceUrl = $serviceName.'/v'.$version.'?wsdl';
}
$fichierWsdl = $serviceClassName.'-'.$version.'.wsdl';
}
// --- Inclusion des classes de données
require_once $pathServiceClassPhp;
//Génération du tableau de mapping
$classmap = array();
$wsConfig = new Zend_Config_Ini($pathServiceClassIni);
if ( $wsConfig->count()>0 ) {
foreach($wsConfig->Type->toArray() as $Type){
$classmap[$Type] = $Type;
}
}
//Inclusion des classes de données
require_once $pathServiceClassPhp;
// --- Get hostname - add compatibility with Reverse Proxy
$hostName = $request->getHttpHost();
$hostScheme = $request->getScheme();
$http = new Zend_Controller_Request_Http();
$proxyScheme = $http->getHeader('X-Forwarded-Proto');
if ($proxyScheme == 'https') {
$hostScheme = 'https';
}
$fichierWsdl = $hostName . '-' . $hostScheme . '-' . $fichierWsdl;
$c = Zend_registry::get('config');
$wsdlPath = $c->profil->path->shared . '/wsdl';
// Fourniture du wsdl
if ( isset($_GET['wsdl']) && file_exists($fichierWsdl) ) {
// --- Fourniture du wsdl
if (isset($_GET['wsdl']) && file_exists($wsdlPath . '/' . $fichierWsdl)) {
if (!headers_sent()) {
header('Content-Type: text/xml');
}
readfile($wsdlPath . '/' . $fichierWsdl);
} elseif (isset($_GET['wsdl']) && !file_exists($wsdlPath . '/' . $fichierWsdl)
|| isset($_GET['wsdl-generate'])
|| isset($_GET['wsdl-auto'])) {
// --- Définition du webservice
$wsdl = new Zend_Soap_AutoDiscover();
$wsdl->setComplexTypeStrategy('Zend_Soap_Wsdl_Strategy_ArrayOfTypeSequence');
$wsdl->setOperationBodyStyle(array('use' => 'literal'));
$wsdl->setBindingStyle(array('style' => 'document'));
$wsdl->setClass($serviceClassName);
if (!headers_sent()) {
header('Content-Type: text/xml');
}
echo file_get_contents($fichierWsdl);
if ($hostScheme == 'https') {
$wsdl->setUri($hostScheme.'://'.$hostName.'/'.$pathServiceUri);
}
} elseif ( isset($_GET['wsdl']) && !file_exists($fichierWsdl)
|| isset($_GET['wsdl-generate'])
|| isset($_GET['wsdl-auto']) ) {
// --- Enregistrement du WSDL dans un fichier
if (isset($_GET['wsdl-generate'])) {
if (file_exists($wsdlPath . '/' . $fichierWsdl)) {
unlink($wsdlPath . '/' . $fichierWsdl);
}
$wsdl->dump($wsdlPath . '/' . $fichierWsdl);
echo "Le fichier $fichierWsdl a été généré";
// --- Génération/Fourniture du wsdl
} elseif (isset($_GET['wsdl']) && !file_exists($wsdlPath . '/' . $fichierWsdl)) {
$wsdl->dump($wsdlPath . '/' . $fichierWsdl);
if (!headers_sent()) {
header('Content-Type: text/xml');
}
readfile($wsdlPath . '/' . $fichierWsdl);
}
// --- Envoi sur la sortie standard le wsdl sans enregistrement dans un fichier
elseif (isset($_GET['wsdl-auto'])) {
$wsdl->handle();
}
}
// --- Fourniture du service
else {
// --- Traitement
if (in_array(APPLICATION_ENV, array('production', 'staging'))
&& file_exists($wsdlPath . '/' . $fichierWsdl)) {
$server = new Zend_Soap_Server($wsdlPath . '/' . $fichierWsdl);
} else {
$server = new Zend_Soap_Server($hostScheme.'://'.$hostName.'/'.$pathServiceUrl);
}
// Définition du webservice
$wsdl = new Zend_Soap_AutoDiscover();
$wsdl->setComplexTypeStrategy('Zend_Soap_Wsdl_Strategy_ArrayOfTypeSequence');
$wsdl->setOperationBodyStyle( array('use' => 'literal') );
$wsdl->setBindingStyle( array('style' => 'document') );
$wsdl->setClass($serviceClassName);
// --- Sonde paramètres server
$debug = false;
$debugUser = '';
if ($debug && $_SERVER['PHP_AUTH_USER'] == $debugUser) {
file_put_contents(APPLICATION_PATH . '/../debugserver.log',
"FichierWSDL : ".$fichierWsdl."\n".
"Hostname : ".$hostName."\n"
);
}
// Enregistrement du WSDL dans un fichier
if ( isset($_GET['wsdl-generate']) ) {
if (file_exists($fichierWsdl)) {
unlink($fichierWsdl);
}
$wsdl->dump($fichierWsdl);
echo "Le fichier $fichierWsdl a été généré";
// --- Options et traitement de la requete
$server->setSoapFeatures(SOAP_USE_XSI_ARRAY_TYPE + SOAP_SINGLE_ELEMENT_ARRAYS);
$server->setClassmap($classmap);
$server->setEncoding('UTF-8');
$server->registerFaultException(array('Scores_Ws_Exception'));
$server->setWsiCompliant(true);
//Génération/Fourniture du wsdl
} elseif (isset($_GET['wsdl']) && !file_exists($fichierWsdl)) {
$wsdl->dump($fichierWsdl);
if (!headers_sent()) {
header('Content-Type: text/xml');
}
echo file_get_contents($fichierWsdl);
// --- Création du service
$server->setObject(new $serviceClassName());
$server->handle();
// Envoi sur la sortie standard le wsdl sans enregistrement dans un fichier
} elseif ( isset($_GET['wsdl-auto']) ){
$wsdl->handle();
}
// --- Pour débuggage ultime
$debug = false;
$debugUser = '';
if ($debug && $_SERVER['PHP_AUTH_USER'] == $debugUser) {
file_put_contents(APPLICATION_PATH . '/../debugcall.log',
"FichierWSDL : ".$fichierWsdl."\n"."Hostname : ".$hostName."\n");
$request = $server->getLastRequest();
file_put_contents(APPLICATION_PATH . '/../debugcall.log', $request . "\n", FILE_APPEND);
$response = $server->getLastResponse();
file_put_contents(APPLICATION_PATH . '/../debugcall.log', $response. "\n", FILE_APPEND);
}
}
// Fourniture du service
} else {
// Traitement
if (APPLICATION_ENV == 'production' && file_exists($fichierWsdl)) {
$server = new Zend_Soap_Server($fichierWsdl);
} else {
$hostName = $this->getRequest()->getHttpHost();
$server = new Zend_Soap_Server('http://'.$hostName.'/'.$pathServiceUrl);
}
$server->setSoapFeatures(SOAP_USE_XSI_ARRAY_TYPE + SOAP_SINGLE_ELEMENT_ARRAYS);
$server->setClassmap($classmap);
$server->setEncoding('UTF-8');
$server->registerFaultException(array('WsScores_Exception'));
$server->setWsiCompliant(true);
$server->setObject(new $serviceClassName());
$server->handle();
//Pour débuggage ultime
$debug = false;
if ($debug){
$request = $server->getLastRequest();
file_put_contents(APPLICATION_PATH . '/../request.log', $request);
$response = $server->getLastResponse();
file_put_contents(APPLICATION_PATH . '/../response.log', $response);
}
}
}
}
}

View File

@ -1,133 +1,68 @@
<?php
class UserController extends Zend_Controller_Action
{
public function indexAction()
class UserController extends Zend_Controller_Action {
public function init()
{
$activeNav = $this->view->navigation();
$activeNav->removePages();
}
public function indexAction()
{
}
public function loginAction()
{
}
$this->view->headTitle()->append('Connexion');
$form = new Form_Login();
$this->view->form = $form;
$request = $this->getRequest();
if ($request->isPost()) {
$formData = $request->getPost ();
if ($form->isValid($formData)) {
$login = $form->getValue('login');
$pass = $form->getValue('pass');
public function loginAction()
{
$this->_helper->layout()->disableLayout();
$auth = Zend_Auth::getInstance();
$authAdapter = new Scores_AuthAdapter($login, $pass);
$result = $auth->authenticate($authAdapter);
if (!$result->isValid()){
$this->view->message = '';
foreach ($result->getMessages() as $message) {
$this->view->message.= $message."<br/>";
}
} else {
$timeout = $auth->getIdentity()->timeout;
$this->view->headLink()->appendStylesheet('/assets/themes/default/css/signin.css', 'all');
//Ecrit un cookie persistant valide pendant le temps definit
Zend_Session::rememberMe($timeout);
$this->view->headTitle()->append('Connexion');
$form = new Application_Form_Login();
$this->view->form = $form;
$request = $this->getRequest();
if ($request->isPost()) {
$formData = $request->getPost();
if ($form->isValid($formData)) {
$login = $form->getValue('login');
$pass = $form->getValue('pass');
$auth = Zend_Auth::getInstance();
$authAdapter = new Scores_Auth_Adapter_Db($login, $pass, true);
$result = $auth->authenticate($authAdapter);
if ($result->isValid()) {
$timeout = $auth->getIdentity()->timeout;
$storage = new Zend_Auth_Storage_Session();
$sessionNamespace = new Zend_Session_Namespace($storage->getNamespace());
$sessionNamespace->setExpirationSeconds($timeout);
$auth->setStorage($storage);
$url = '';
if (Zend_Session::namespaceIsset('login')){
$session = new Zend_Session_Namespace('login');
if (isset($session->url)) {
$url = $session->url;
}
}
if (!empty($url)){
$this->_redirect($url);
}
//Ecrit un cookie persistant valide pendant le temps definit
Zend_Session::rememberMe($timeout);
$this->_redirect('/');
}
$storage = new Zend_Auth_Storage_Session();
$sessionNamespace = new Zend_Session_Namespace($storage->getNamespace());
$sessionNamespace->setExpirationSeconds($timeout);
$auth->setStorage($storage);
$this->redirect('/');
} else {
$this->view->message = '';
foreach ($result->getMessages() as $message) {
$this->view->message.= $message."<br/>";
}
}
}
}
}
}
}
public function logoutAction()
{
$this->_helper->layout()->disableLayout();
Zend_Auth::getInstance()->clearIdentity();
Zend_Auth::getInstance()->clearIdentity();
}
public function paramsAction()
{
$auth = Zend_Auth::getInstance();
$identity = $auth->getIdentity();
$login = $identity->username;
$pass = $identity->hash;
$this->view->login = $login;
$this->view->authorizationHeader = base64_encode($login.':'.$pass);
/**
* @var \Doctrine\DBAL\Connection $conn
*/
$conn = Zend_Registry::get('doctrine');
$userSql = "SELECT * FROM sdv1.utilisateurs WHERE id=:id";
$stmt = $conn->prepare($userSql);
$stmt->bindValue('id', $identity->id);
$stmt->execute();
$user = $stmt->fetch(\PDO::FETCH_OBJ);
$this->view->IdFullName = $user->civilite . ' ' . $user->nom . ' ' . $user->prenom;
$this->view->IdEmail = $user->email;
//Liste des droits
$listdroit = explode(' ', $user->droits);
//Association méthodes - droits
$assoc = array(
'getAnnoncesAsso' => array('ANNONCES'),
'getAnnoncesBalo' => array('ANNONCES'),
'getAnnoncesBoamp' => array('ANNONCES'),
'getAnnoncesLegales' => array('ANNONCES'),
'getAnnoncesNum' => array('ANNONCES'),
'getAvisRncs' => array('AVISRNCS'),
'getBanques' => array('BANQUES'),
'getBilan' => array('LIASSE'),
'getDirigeants' => array('DIRIGEANTS'),
'getIdentite' => array('IDENTITE'),
'getIdentiteProcol' => array('IDPROCOL'),
'getIndiScore' => array('INDISCORE1', 'INDISCORE2', 'INDISCORE3'),
'getInfosBourse' => array('BOURSE'),
'getInfosReg' => array('INFOSREG'),
'getLiasseInfos' => array(),
'getLienRef' => array('LIENS'),
'getLiens' => array('LIENS'),
'getLiensById' => array('LIENS'),
'getListeBilans' => array('LIASSE'),
'getListeCompetences' => array('COMPETENCES'),
'getListeEtablissements' => array('ETABLISSEMENTS'),
'getListeEvenements' => array('EVENINSEE'),
'getRapport' => array('INDISCORE3'),
'getRatios' => array('RATIOS'),
'getSubventionDetail' => array(''),
'getSubventionList' => array(''),
'getTVA' => array(''),
'getValo' => array('VALORISATION'),
'isSirenExistant' => array(''),
'searchAutreId' => array('SEARCHENT'),
'searchDir' => array('SEARCHDIR'),
'searchEntreprise' => array('SEARCHENT'),
'searchNomAdr' => array('SEARCHENT'),
'searchRefClient' => array(),
'searchSiren' => array('SEARCHENT'),
'searchTelFax' => array('SEARCHENT'),
);
$display = array();
foreach ($listdroit as $droit) {
foreach ($assoc as $l => $d) {
if (in_array(strtoupper($droit), $d)) {
$display[] = array(
'label' => $l,
'droit' => $droit,
);
}
}
}
$this->view->display = $display;
}
}
}

View File

@ -1,8 +1,7 @@
<?php
class Application_Model_AssoActes extends Zend_Db_Table_Abstract
{
protected $_name = 'asso_actes';
protected $_schema = 'jo';
protected $_name = 'asso_actes';
public function insert(array $data)
{

View File

@ -0,0 +1,5 @@
<?php
class Application_Model_ClientsTarif extends Zend_Db_Table_Abstract
{
protected $_name = 'clientsTarif';
}

View File

@ -2,5 +2,4 @@
class Application_Model_FedasoBilans extends Zend_Db_Table_Abstract
{
protected $_name = 'fedaso_bilans';
protected $_schema = 'sdv1';
}

View File

@ -0,0 +1,5 @@
<?php
class Application_Model_Utilisateurs extends Zend_Db_Table_Abstract
{
protected $_name = 'utilisateurs';
}

View File

@ -1,7 +1,8 @@
<?php
class Zend_View_Helper_DocComplement extends Zend_View_Helper_Abstract
{
public function docComplement($method)
{
}
}
public function docComplement($method)
{
}
}

View File

@ -1,8 +1,8 @@
<?php
class Zend_View_Helper_DocDescription extends Zend_View_Helper_Abstract
{
public function docDescription($method)
{
return $method['desc'];
}
}
public function docDescription($method)
{
return $method['desc'];
}
}

View File

@ -1,31 +1,32 @@
<?php
class Zend_View_Helper_DocExemple extends Zend_View_Helper_Abstract
{
public function docExemple($method)
{
$exemple = '';
$langages = array(
'php' => 'PHP',
'java' => 'Java',
'perl' => 'Perl',
'python' => 'Python',
'csharp' => 'C#'
);
public function docExemple($method)
{
$exemple = '';
$langages = array(
'php' => 'PHP',
'java' => 'Java',
'perl' => 'Perl',
'python' => 'Python',
'csharp' => 'C#'
);
foreach ($langages as $langage => $lib) {
$fichier = 'assets/code/'.$method.'-'.$langage.'.txt';
if (file_exists($fichier)) {
$url = $this->view->url(
array(
'controller' => 'documentation',
'action' => 'code',
'langage' => $langage,
'element' => $method,
), null, true);
$exemple.= '<a href="'.$url.'">' . $lib . '</a>';
$exemple.= '&nbsp;';
}
}
return $exemple;
}
}
foreach ($langages as $langage => $lib){
$fichier = 'code/'.$method.'-'.$langage.'.txt';
if (file_exists($fichier)){
$url = $this->view->url(
array(
'controller' => 'documentation',
'action' => 'code',
'langage' => $langage,
'element' => $method,
)
);
$exemple.= '<a href="'.$url.'">' . $lib . '</a>';
$exemple.= '&nbsp;';
}
}
return $exemple;
}
}

View File

@ -1,59 +1,61 @@
<?php
class Zend_View_Helper_DocMethod extends Zend_View_Helper_Abstract
{
protected $_transcodeType = array(
'str' => 'string',
'bool' => 'boolean',
'integer' => 'int',
);
public function docMethod($method)
{
$output = '';
protected $_transcodeType = array(
'str' => 'string',
'bool' => 'boolean',
'integer' => 'int',
);
$returnType = $method['return'];
$methodName = $method['name'];
public function docMethod($method)
{
$output = '';
$cptParameters = 0;
$parameters = '';
foreach ($method['params'] as $param) {
if (isset($param['optional'])) {
$parameters.= '[';
}
$parameters.= '<i>' . $this->transcodeType($param['type']) . '</i>';
$parameters.= '&nbsp;';
$parameters.= '<b>' . $param['name'] . '</b>';
$returnType = $method['return'];
$methodName = $method['name'];
if (isset($param['optional'])) {
if (isset($param['defaultValue'])) {
$parameters.= ' = ';
if (is_bool($param['defaultValue'])) {
$parameters.= ($param['defaultValue'] === false) ? 'false' : 'true' ;
} elseif (is_string($param['defaultValue']) && $param['defaultValue']=='') {
$parameters.= "''";
} else {
$parameters.= $param['defaultValue'];
}
}
$parameters.= ']';
}
$cptParameters++;
if ($cptParameters < count($method['params'])) {
$parameters.= ', ';
}
}
$output = '<i>' . $this->transcodeType($returnType) . '</i>';
$output.= ' ';
$output.= '<b>' . $methodName . '</b>' . ' <b>(</b> ' . $parameters . ' <b>)</b>';
return $output;
}
$cptParameters = 0;
$parameters = '';
foreach ($method['params'] as $param) {
if (isset($param['optional'])) {
$parameters.= '[';
}
$parameters.= '<i>' . $this->transcodeType($param['type']) . '</i>';
$parameters.= '&nbsp;';
$parameters.= '<b>' . $param['name'] . '</b>';
if (isset($param['optional'])) {
if (isset($param['defaultValue'])) {
$parameters.= ' = ';
if (is_bool($param['defaultValue'])){
$parameters.= ($param['defaultValue'] === false) ? 'false' : 'true' ;
} elseif (is_string($param['defaultValue']) && $param['defaultValue']==''){
$parameters.= "''";
} else {
$parameters.= $param['defaultValue'];
}
}
$parameters.= ']';
}
$cptParameters++;
if ($cptParameters < count($method['params'])){
$parameters.= ', ';
}
}
$output = '<i>' . $this->transcodeType($returnType) . '</i>';
$output.= ' ';
$output.= '<b>' . $methodName . '</b>' . ' <b>(</b> ' . $parameters . ' <b>)</b>';
return $output;
}
private function transcodeType($type)
{
if(array_key_exists($type, $this->_transcodeType)){
return $this->_transcodeType[$type];
} else {
return $type;
}
}
private function transcodeType($type)
{
if (array_key_exists($type, $this->_transcodeType)) {
return $this->_transcodeType[$type];
} else {
return $type;
}
}
}

View File

@ -1,80 +1,86 @@
<?php
class Zend_View_Helper_DocParameter extends Zend_View_Helper_Abstract
{
protected $serviceTypes;
protected $serviceTypes;
protected $types = array(
'string', 'str',
'boolean', 'bool',
'int', 'integer', 'long',
'float', 'double',
'array', 'object', 'mixed'
);
protected $types = array(
'string', 'str',
'boolean', 'bool',
'int', 'integer',
'float', 'double',
'array', 'object', 'mixed'
);
protected $_transcodeType = array(
'str' => 'string',
'bool' => 'boolean',
'integer' => 'int',
);
protected $_transcodeType = array(
'str' => 'string',
'bool' => 'boolean',
'integer' => 'int',
);
public function docParameter($params, $serviceTypes)
{
$this->serviceTypes = $serviceTypes;
$output = '';
if (count($params)>0) {
$output.= '<ul>';
foreach ($params as $param) {
$output.= $this->formatParam($param);
}
$output.= '</ul>';
}
return $output;
}
public function docParameter($params, $serviceTypes)
{
$this->serviceTypes = $serviceTypes;
$output = '';
if (count($params)>0) {
$output.= '<ul>';
foreach ($params as $param) {
$output.= $this->formatParam($param);
}
$output.= '</ul>';
}
return $output;
}
private function parseType($type)
{
$output = '';
$type = str_replace('[]', '', $type);
if (array_key_exists($type, $this->serviceTypes)) {
$types = $this->serviceTypes[$type];
$output.= '<ul>';
foreach ($types as $param) {
$output.= $this->formatParam($param);
}
$output.= '</ul>';
} elseif (in_array($type, $this->types)) {
$output.= '';
} elseif ($type == 'void') {
$output.= 'Void';
} else {
$output.= ' => <b>Type '.$type.' inconnu</b>';
}
return $output;
}
private function parseType($type)
{
$output = '';
$type = str_replace('[]', '', $type);
if (array_key_exists($type, $this->serviceTypes)) {
$types = $this->serviceTypes[$type];
$output.= '<ul>';
foreach ($types as $param) {
$output.= $this->formatParam($param);
}
$output.= '</ul>';
} elseif (in_array($type, array(
'string', 'str',
'boolean', 'bool',
'integer', 'int',
'float', 'double',
'array', 'object', 'mixed'))) {
$output.= '';
} elseif ($type == 'void'){
$output.= 'Void';
} else {
$output.= ' => <b>Type '.$type.' Inconnu</b>';
}
return $output;
}
private function formatParam($param)
{
$output = '';
$output.= '<li>';
$output.= '<i>' . $this->transcodeType($param['type']) . '</i>';
$output.= ' ';
$output.= '<b>' . $param['name'] . '</b>';
if (isset($param['description']) && !empty($param['description'])) {
$output.= ' - '.$param['description'];
}
if (!in_array($param['type'], $this->types)) {
$output.= $this->parseType($param['type']);
}
$output.= '</li>';
return $output;
}
private function formatParam($param)
{
$output = '';
$output.= '<li>';
$output.= '<i>' . $this->transcodeType($param['type']) . '</i>';
$output.= ' ';
$output.= '<b>' . $param['name'] . '</b>';
if (isset($param['description']) && !empty($param['description'])) {
$output.= ' - '.$param['description'];
}
if (!in_array($param['type'], $this->types)) {
$output.= $this->parseType($param['type']);
}
$output.= '</li>';
return $output;
}
private function transcodeType($type)
{
if (array_key_exists($type, $this->_transcodeType)) {
return $this->_transcodeType[$type];
} else {
return $type;
}
}
}
private function transcodeType($type)
{
if(array_key_exists($type, $this->_transcodeType)){
return $this->_transcodeType[$type];
} else {
return $type;
}
}
}

View File

@ -1,73 +1,78 @@
<?php
class Zend_View_Helper_DocReturn extends Zend_View_Helper_Abstract
{
protected $serviceTypes;
protected $serviceTypes;
protected $types = array(
'string', 'str',
'boolean', 'bool',
'integer', 'int', 'long',
'float', 'double',
'array', 'object', 'mixed'
);
protected $types = array(
'string', 'str',
'boolean', 'bool',
'integer', 'int',
'float', 'double',
'array', 'object', 'mixed'
);
protected $_transcodeType = array(
'str' => 'string',
'bool' => 'boolean',
'integer' => 'int',
);
protected $_transcodeType = array(
'str' => 'string',
'bool' => 'boolean',
'integer' => 'int',
);
public function docReturn($type, $serviceTypes)
{
$this->serviceTypes = $serviceTypes;
return $this->parseType($type);
}
public function docReturn($type, $serviceTypes)
{
$this->serviceTypes = $serviceTypes;
return $this->parseType($type);
}
private function parseType($type)
{
$output = '';
$type = str_replace('[]', '', $type);
if (array_key_exists($type, $this->serviceTypes)) {
$types = $this->serviceTypes[$type];
$output.= '<ul>';
foreach ($types as $param) {
$output.= $this->formatParam($param);
}
$output.= '</ul>';
} elseif (in_array($type, $this->types)) {
$output.= '<i>' . $type . '</i> ';
} elseif ($type == 'void') {
$output.= 'Void';
} else {
$output.= ' => <b>Type '.$type.' inconnu</b>';
}
return $output;
}
private function parseType($type)
{
$output = '';
$type = str_replace('[]', '', $type);
if (array_key_exists($type, $this->serviceTypes)) {
$types = $this->serviceTypes[$type];
$output.= '<ul>';
foreach ($types as $param) {
$output.= $this->formatParam($param);
}
$output.= '</ul>';
} elseif (in_array($type, array(
'string', 'str',
'boolean', 'bool',
'integer', 'int',
'float', 'double',
'array', 'object', 'mixed'))) {
$output.= '<i>' . $type . '</i> ';
} elseif ($type == 'void'){
$output.= 'Void';
} else {
$output.= ' => <b>Type '.$type.' Inconnu</b>';
}
return $output;
}
private function formatParam($param)
{
$output = '';
$output.= '<li>';
$output.= '<i>' . $this->transcodeType($param['type']) . '</i>';
$output.= ' ';
$output.= '<b>'. $param['name'] . '</b>';
if (isset($param['description']) && !empty($param['description'])) {
$output.= ' - '.$param['description'];
}
$type = str_replace('[]', '', $param['type']);
if (!in_array($type, $this->types)) {
$output.= $this->parseType($param['type']);
}
$output.= '</li>';
return $output;
}
private function formatParam($param)
{
$output = '';
$output.= '<li>';
$output.= '<i>' . $this->transcodeType($param['type']) . '</i>';
$output.= ' ';
$output.= '<b>'. $param['name'] . '</b>';
if (isset($param['description']) && !empty($param['description'])) {
$output.= ' - '.$param['description'];
}
if (!in_array($param['type'], $this->types)) {
$output.= $this->parseType($param['type']);
}
$output.= '</li>';
return $output;
}
private function transcodeType($type)
{
if(array_key_exists($type, $this->_transcodeType)){
return $this->_transcodeType[$type];
} else {
return $type;
}
}
private function transcodeType($type)
{
if (array_key_exists($type, $this->_transcodeType)) {
return $this->_transcodeType[$type];
} else {
return $type;
}
}
}

View File

@ -2,16 +2,16 @@
class Zend_View_Helper_ProfileLink extends Zend_View_Helper_Abstract
{
public function profileLink()
{
$auth = Zend_Auth::getInstance();
public function profileLink()
{
$auth = Zend_Auth::getInstance();
if ($auth->hasIdentity()) {
$username = $auth->getIdentity()->username;
$logoutUrl = $this->view->url(array(
'controller' => 'user',
'action' => 'logout'
), null, true);
return '<a href="'.$logoutUrl.'" title="Se déconnecter" class="navbar-link">Déconnexion : ' . $username . '</a>';
'controller' => 'user',
'action' => 'logout'
));
return '<a href="'.$logoutUrl.'" alt="Se déconnecter">Déconnexion : ' . $username . '</a>';
}
}
}
}
}

View File

@ -1,12 +1,13 @@
<h1>Démonstration - Liste des méthodes</h1>
<p class="bg-info">Uniquement disponible à titre d'information. Se référer à la documentation pour réaliser des tests.</p>
<ul>
<?php foreach($this->methods as $method){ ?>
<?php
foreach($this->methods as $method){
?>
<li>
<a href="<?php echo $method['url'];?>">
<?php echo $method['nom'];?></a>
</li>
<?php } ?>
<?php
}
?>
</ul>

View File

@ -1,2 +1,2 @@
<h2><?=$this->langage?></h2>
<?=$this->code?>
<pre><?=$this->code?></pre>

View File

@ -1,48 +1,46 @@
<div class="page-header"><h1>Authentification</h1></div>
<p>
Le WebService utilise une authentification http basic.
Il s'agit donc de transmettre comme paramètres d'authentification
</p>
<p><code>http://{login}:{password}@url</code></p>
<p>
- <code>{password}</code> est une chaine construite de cette façon md5({login}|{pass}) <br/>
- <code>{login}</code> est l'identifiant fournit <br/>
- <code>{pass}</code> le mot de passe fournit.
</p>
<div class="bs-callout bs-callout-warning">
Authentification basic<br/>
<br/>
Le client HTTP envoi une requête avec l'en-tête HTTP "Authorization". Celui-ci doit contenir la méthode utilisée
(Basic) suivi de la représentation en Base64 du nom de l'utilisateur et du mot de passe séparés par
le caractère ":" (deux-points).<br/>
<br/>
Par exemple :<br/>
<br/>
Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==
<div id="wsdl">
<h1>WSDL</h1>
<p><a href="<?=$this->wsdl?>">Télécharger le WSDL</a></p>
<i>Le fichier est accessible sans authentification.</i>
</div>
<p>
Vous trouverez dans ces exemples les prérequis pour s'authentifier et suivant
les outils et langage la possibilité de générer le code à partir du WSDL.<br/>
Exemple : <?=$this->docExemple('authentication')?>
</p>
<div class="op-list">
<h1>Liste des opérations :</h1>
<ol>
<?php foreach ($this->serviceMethods as $method) {?>
<li>
<b><?php echo $method['name'];?></b>
<a href="#<?php echo $method['name'];?>"><i>Détail</i></a>
</li>
<?php } ?>
</ol>
</div>
<div class="page-header"><h1>Compatibilité</h1></div>
<p>Notre service web a été testé avec ces langages/librairies</p>
<ul>
<li>C# : .Net Framework</li>
<li>PHP : PHP5 SOAP Extension</li>
<li>Perl : SOAP::Lite</li>
<li>Java : JAX-WS</li>
<li>Python : SOAPpy</li>
<li>VB.Net : .Net Framework</li>
<li>C++ : gSOAP</li>
</ul>
<br/>
<p>
Pour toutes remarques ou question merci d'adresser un email à
<a href="mailto:support@scores-decisions.com">support@scores-decisions.com</a>
</p>
<div class="op-detail">
<h1>Détails :</h1>
<?php foreach ($this->serviceMethods as $method) {?>
<div class="function">
<a name="<?=$method['name']?>">&nbsp;</a>
<h2><?=$method['name']?></h2>
<div class="titre">Description :</div>
<div class="description"><?=$this->docDescription($method)?></div>
<div class="titre">Empreinte :</div>
<div class="complement"><?=$this->docComplement($method)?></div>
<div class="function-detail" id="<?=$method['name']?>">
<p><?=$this->docMethod($method)?></p>
<div class="titre">Paramètres :</div>
<div class="parameters">
<?=$this->docParameter($method['params'], $this->serviceTypes);?>
</div>
<div class="titre">Retour :</div>
<div class="return">
<?=$this->docReturn($method['return'], $this->serviceTypes);?>
</div>
</div>
<?php $exemple = $this->docExemple($method['name'])?>
<?php if (!empty($exemple)) {?>
<p>Exemple : <?=$exemple?></p>
<?php }?>
</div>
<?php } ?>
</div>

View File

@ -1,78 +0,0 @@
<div class="page-header"><h1>Service <?=$this->serviceName?> v<?=$this->serviceVersion?></h1></div>
<?php if ( $this->isDeprecated === true) {?>
<p class="bg-danger">Cette version est déprécié. Elle est désactivé.</p>
<?php }?>
<?php if ( $this->Info ) {?>
<p class="bg-info"><?=$this->Info?></p>
<?php }?>
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">WSDL</h3>
</div>
<div class="panel-body">
<p><a href="<?=$this->wsdl?>">Télécharger le WSDL</a></p>
<i>Le fichier est accessible sans authentification.</i>
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">Liste des opérations</h3>
</div>
<div class="panel-body">
<ol>
<?php foreach ($this->serviceMethods as $method) {?>
<li>
<b><?php echo $method['name'];?></b>
<a href="#<?php echo $method['name'];?>"><i>Détail</i></a>
</li>
<?php }?>
</ol>
</div>
</div>
<div class="page-header">
<h2>Détails</h2>
</div>
<?php foreach ($this->serviceMethods as $method) {?>
<div class="panel panel-default" id="<?=$method['name']?>">
<div class="panel-heading">
<h3 class="panel-title"><h4><?=$method['name']?></h4></h3>
</div>
<div class="panel-body">
<h5>Description</h5>
<div class="bs-callout bs-callout-php">
<h4><code><?=$this->docMethod($method)?></code></h4>
<p><?=$this->docComplement($method)?></p>
<p><?=$this->docDescription($method)?></p>
</div>
<h5>Paramètres</h5>
<div class="bs-callout bs-callout-php">
<?=$this->docParameter($method['params'], $this->serviceTypes);?>
</div>
<h5>Retour</h5>
<div class="bs-callout bs-callout-php">
<?php if ($method['returnDesc'] != '') {?><?=$method['returnDesc']?><br/><br/><?php }?>
<?=$this->docReturn($method['return'], $this->serviceTypes);?>
</div>
<?php $exemple = $this->docExemple($method['name'])?>
<?php if ( !empty($exemple) ) {?>
<h5>Exemple</h5>
<div class="bs-callout bs-callout-php">
<?=$exemple?>
</div>
<?php }?>
</div>
</div>
<?php } ?>

View File

@ -1,51 +0,0 @@
<div class="page-header"><h1>Liste des services disponibles</h1></div>
<p class="lead">Ci-dessous la liste des services disponibles, personnalisés ou standards.</code>.</p>
<?php foreach ($this->WsServices as $service => $params) {?>
<div class="panel panel-default">
<!-- Default panel contents -->
<div class="panel-heading">
<a href="<?=$this->url(array(
'controller'=>'documentation',
'action'=>'servicev',
'name'=>$service,
'type'=>$params['type']),null,true)?>">
<?=$params['name']?>
</a>
</div>
<div class="panel-body">
<p>Informations</p>
</div>
<?php if (isset($params['versions'])) { ?>
<ul class="list-group">
<?php foreach ($params['versions'] as $version => $versionElement) { ?>
<li class="list-group-item">
<a href="<?=$this->url(array(
'controller'=>'documentation',
'action'=>'service',
'name'=>$service,
'type'=>$params['type'],
'version'=>$version),null,true)?>">
Version <?=$version?></a>
<div class="pull-right">
<?php if ( $versionElement['defaut'] === true ) { ?>
<span class="label label-success">Actuel</span>
<?php } elseif ( $versionElement['defaut'] === false ) {?>
<span class="label label-danger">Déprécié</span>
<?php } elseif ( $versionElement['defaut'] == 'beta') {?>
<span class="label label-warning">Beta</span>
<?php }?>
<?php if ( $versionElement['actif'] === true ) { ?>
<span class="label label-info">Actif</span>
<?php } else {?>
<span class="label label-info">Inactif</span>
<?php }?>
</div>
</li>
<?php } ?>
</ul>
<?php } ?>
</div>
<?php } ?>

View File

@ -1,40 +0,0 @@
<?php
$service = null;
if ( array_key_exists($this->key, $this->WsServices) ) {
$service = $this->WsServices[$this->key];
}
?>
<?php if ( $service === null ) {?>
<?php } else {?>
<div class="page-header"><h1>Versions du service <?=$service['name']?></h1></div>
<p class="lead">...</p>
<?php if (isset($service['versions'])) { ?>
<?php foreach ($service['versions'] as $version => $versionElement) { ?>
<div class="panel panel-default">
<div class="panel-heading">
<a href="<?=$this->url(array(
'controller'=>'documentation',
'action'=>'service',
'name'=>$this->key,
'type'=>$service['type'],
'version'=>$version))?>">
Version <?=$version?></a>
<?php if ( $versionElement['defaut'] === true ) { ?>
<span style="float:right;" class="label label-success">Défaut</span>
<?php } elseif ( $versionElement['defaut'] === false ) {?>
<span style="float:right;" class="label label-danger">Déprécié</span>
<?php } elseif ( $versionElement['defaut'] == 'beta') {?>
<span style="float:right;" class="label label-warning">Beta</span>
<?php }?>
</div>
<div class="panel-body">
<p>Information</p>
</div>
</div>
<?php }?>
<?php }?>
<?php } ?>

View File

@ -1,18 +1,28 @@
<h1>An error occurred</h1>
<h2><?php echo $this->message ?></h2>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Zend Framework Default Application</title>
</head>
<body>
<h1>An error occurred</h1>
<h2><?php echo $this->message ?></h2>
<?php if (isset($this->exception)): ?>
<?php if (isset($this->exception)): ?>
<h3>Exception information:</h3>
<p>
<b>Message:</b> <?php echo $this->exception->getMessage() ?>
</p>
<h3>Exception information:</h3>
<p>
<b>Message:</b> <?php echo $this->exception->getMessage() ?>
</p>
<h3>Stack trace:</h3>
<pre><?php echo $this->exception->getTraceAsString() ?>
</pre>
<h3>Stack trace:</h3>
<pre><?php echo $this->exception->getTraceAsString() ?>
</pre>
<h3>Request Parameters:</h3>
<pre><?php echo var_export($this->request->getParams(), true) ?>
</pre>
<?php endif ?>
<h3>Request Parameters:</h3>
<pre><?php echo var_export($this->request->getParams(), true) ?>
</pre>
<?php endif ?>
</body>
</html>

View File

@ -1,3 +1 @@
<div class="container">
<p class="text-muted credit"> &copy; <?=date('Y')?> <a href="http://www.scores-decisions.com">Scores & Décisions SAS</a>.</p>
</div>
<?php

View File

@ -1,38 +1,12 @@
<!-- Fixed navbar -->
<div class="navbar navbar-default navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">Web Service API</a>
</div>
<div class="collapse navbar-collapse">
<ul class="nav navbar-nav">
<?php foreach ($this->navigation()->getContainer() as $page) {?>
<?php if ( $page->hasPages() ) {?>
<li class="dropdown<?php if ( $page->isActive(true) ) { echo ' active'; } ?>">
<a href="#" class="dropdown-toggle" data-toggle="dropdown"><?=$page->label?> <b class="caret"></b></a>
<ul class="dropdown-menu">
<li><a href="<?=$page->getHref()?>">Accueil</a></li>
<li class="divider"></li>
<?php foreach ( $page->getPages() as $child ) {?>
<?php if ( $child->getHref() == '#') {?>
<li class="divider"></li>
<?php } else {?>
<li<?php if ( $child->isActive(true) ) { echo ' class="active"'; } ?>><a href="<?=$child->getHref()?>"><?=$child->label?></a></li>
<?php }?>
<?php }?>
</ul>
</li>
<?php } else {?>
<li<?php if ( $page->isActive(true) ) { echo ' class="active"'; } ?>><a href="<?=$page->getHref()?>"><?=$page->label?></a></li>
<?php }?>
<?php }?>
</ul>
<p class="navbar-text pull-right"><?=$this->profileLink()?></p>
</div><!--/.nav-collapse -->
</div>
<h1>WebService Scores & Décisions</h1>
<div>
<div id="menu">
<?php echo $this->navigation()->menu(); ?>
</div>
<div style="float:right;">
<?php echo $this->profileLink(); ?>
</div>
<div id="breadcrumbs" style="clear:both;">
<?php /*echo $this->navigation()->breadcrumbs()->setMinDepth(0)->setLinkLast(true)->setSeparator(" >> ");*/ ?>
</div>
</div>

View File

@ -1,6 +0,0 @@
<div class="page-header"><h1>Contact</h1></div>
<p class="lead"></p>
<p>Pour toutes questions concernant les paramètres techniques ou une explication des données, vous pouvez contactez
votre commercial ou le service support (<a href="mailto:support@scores-decisions.com">support@scores-decisions.com</a>).</p>
<p>Merci de rappeler pour référence le login utilisé pour l'accès au WebService.</p>

View File

@ -1,6 +0,0 @@
<div class="page-header"><h1>Contact</h1></div>
<p class="lead"></p>
<p>Pour toutes questions concernant les paramètres techniques ou une explication des données, vous pouvez contactez
votre commercial ou le service support (<a href="mailto:support@scores-decisions.com">support@scores-decisions.com</a>).</p>
<p>Merci de rappeler pour référence le login utilisé pour l'accès au WebService.</p>

View File

@ -1,7 +1,86 @@
<div class="page-header"><h1>Web Service API</h1></div>
<p class="lead">Scores & Décisions fournit un ensemble d'information sous la forme d'une API
compatible avec le protocole SOAP permettant la communication et l'échange de données avec vos
applications métier.
<h1>Liste des services disponibles</h1>
<ul>
<?php foreach ($this->ws as $key => $ws) {?>
<li>
<?php if ($ws['type'] == 'client'){?>
<a href="<?=$this->url(array('controller' => 'documentation', 'action' => 'clients', 'nom' => strtolower($key)))?>">
<?=ucfirst($key)?>
</a>
<?php } else {?>
<a href="<?=$this->url(array('controller' => 'documentation', 'ws' => $key))?>">
<?=ucfirst($key)?>
</a>
<?php }?>
</li>
<?php if (isset($ws['version'])){ ?>
<ul>
<?php
foreach ($ws['version'] as $version => $versionElement){
if ($versionElement['actif']) {
?>
<li>
<?php if ($ws['type'] == 'client'){?>
<a href="<?=$this->url(array(
'controller' => 'documentation',
'action' => 'clients',
'nom' => strtolower($key),
'version' => $version,
))?>">Version <?=$version?></a>
<?php } else {?>
<a href="<?=$this->url(array(
'controller' => 'documentation',
'ws' => $key,
'version' => $version,
))?>">Version <?=$version?></a>
<?php }?>
<?php echo ( $versionElement['defaut']) ? '(défaut)' : '';?>
</li>
<?php
}
}
?>
</ul>
<?php } ?>
<?php } ?>
</ul>
<br/>
<h1>Authentification</h1>
<p>
Le WebService utilise une authentification http basique.
Il s'agit donc de transmettre comme paramètres d'authentification
</p>
<p>La documentation vous fournira les éléments techniques relatifs aux <em>paramètres de connexion</em>,
<em>structure des données</em>, ...</p>
<p>http://{login}:{password}@url</p>
<p>
{password} est une chaine construite de cette façon md5({login}|{pass}) <br/>
ou {login} est l'identifiant fournit <br/>
et {pass} le mot de passe fournit.
</p>
<p>
Vous trouverez dans ces exemples les prérequis pour s'authentifier et suivant
les outils et langage la possibilité de générer le code à partir du WSDL.<br/>
Exemple : <?=$this->docExemple('authentication')?>
</p>
<br/>
<h1>Compatibilité</h1>
<p>Notre service web a été testé avec ces langages/librairies</p>
<ul>
<li>PHP : PHP5 SOAP Extension</li>
<li>Perl : SOAP::Lite</li>
<li>Java : JAX-WS</li>
<li>(En cours de test) - Python : SOAPpy</li>
<li>(En cours de test) - C# : .Net Framework</li>
<li>(En cours de test) - VB.Net : .Net Framework</li>
<li>(En cours de test) - C++ : gSOAP</li>
</ul>
<br/>
<p>
Pour toutes remarques ou question merci d'adresser un email à
<a href="mailto:support@scores-decisions.com">support@scores-decisions.com</a>
</p>

View File

@ -1,26 +0,0 @@
<?php echo $this->doctype(); ?>
<html>
<head>
<?php echo $this->headMeta(); ?>
<?php echo $this->headTitle(); ?>
<?php echo $this->headStyle(); ?>
<?php echo $this->headLink(); ?>
<?php echo $this->headScript(); ?>
</head>
<body>
<div id="wrap">
<?php echo $this->render('header.phtml') ?>
<div class="container">
<?php echo $this->layout()->content; ?>
</div>
</div>
<div id="footer">
<?php echo $this->render('footer.phtml'); ?>
</div>
<?php echo $this->inlineScript(); ?>
</body>
</html>

View File

@ -0,0 +1,23 @@
<?php echo $this->doctype(); ?>
<html>
<head>
<?php echo $this->headMeta(); ?>
<?php echo $this->headTitle(); ?>
<?php echo $this->headStyle(); ?>
<?php echo $this->headLink(); ?>
<?php echo $this->headScript(); ?>
</head>
<body>
<div id="global">
<div id="header">
<?php echo $this->render('header.phtml') ?>
</div>
<div id="content" style="clear:both;">
<?php echo $this->layout()->content; ?>
</div>
<div id="footer">
<?php echo $this->render('footer.phtml'); ?>
</div>
</div>
</body>
</html>

View File

@ -1,33 +1,2 @@
<?php echo $this->doctype(); ?>
<html>
<head>
<?php echo $this->headMeta(); ?>
<?php echo $this->headTitle(); ?>
<?php echo $this->headStyle(); ?>
<?php echo $this->headLink(); ?>
<?php echo $this->headScript(); ?>
</head>
<body>
<div id="wrap">
<div class="container">
<form class="form-signin" method="<?=$this->form->getMethod()?>" action="<?=$this->form->getAction()?>">
<h2 class="form-signin-heading">Web Service API</h2>
<div style="text-align:center;"><p class="text-danger"><span><?=$this->message?></span></p></div>
<input name="login" value="<?=$this->form->getValue('login')?>" type="text" class="form-control" placeholder="Identifiant" autofocus>
<input name="pass" value="<?=$this->form->getValue('pass')?>" type="password" class="form-control" placeholder="Mot de passe">
<button class="btn btn-lg btn-primary btn-block" type="submit">Connexion</button>
</form>
</div>
</div>
<div id="footer">
<?php echo $this->render('footer.phtml'); ?>
</div>
<?php echo $this->inlineScript(); ?>
</body>
</html>
<p>Identifiez-vous pour accèder aux ressources</p>
<?=$this->form?>

View File

@ -1,24 +1 @@
<?php echo $this->doctype(); ?>
<html>
<head>
<?php echo $this->headMeta(); ?>
<?php echo $this->headTitle(); ?>
<?php echo $this->headStyle(); ?>
<?php echo $this->headLink(); ?>
</head>
<body>
<div id="wrap">
<div class="container">
<p>Vous avez été déconnecté.</p>
</div>
</div>
<div id="footer">
<?php echo $this->render('footer.phtml'); ?>
</div>
</body>
</html>
Vous avez été déconnecté.

View File

@ -1,36 +0,0 @@
<div class="page-header"><h1>Identifiant</h1></div>
<h2>Identité</h2>
<address>
<p>Login : <?=$this->login?></p>
<strong><?=$this->IdFullName?></strong><br>
<a href="mailto:#"><?=$this->IdEmail?></a>
</address>
<h2>Authorization Header</h2>
<div class="bs-callout bs-callout-warning">
Authorization: Basic <?=$this->authorizationHeader;?>
</div>
<div>
Base64("<?=$this->login?>:*****") = "<?=$this->authorizationHeader;?>"
</div>
<div class="page-header"><h1>Paramètres</h1></div>
<table class="table">
<thead>
<tr>
<th>Méthode</th>
<th>Droit</th>
</tr>
</thead>
<tbody>
<?php if ( count($this->display)>0 ) {?>
<?php foreach ( $this->display as $d ) {?>
<tr>
<td><?=$d['label']?></td>
<td><?=$d['droit']?></td>
</tr>
<?php }?>
<?php }?>
</tbody>
</table>

280
batch/calculRatios.php Normal file
View File

@ -0,0 +1,280 @@
#!/usr/bin/php
<?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(),
)));
require_once realpath(dirname(__FILE__)).'/../config/config.php';
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);
?>

918
batch/enrichissement.php Normal file
View File

@ -0,0 +1,918 @@
#!/usr/bin/php
<?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'));
// 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.",
'ignore=i' => "Nombre de ligne à ignoré.",
'file=s' => "Définir le chemin du fichier",
)
);
$opts->parse();
} catch (Zend_Console_Getopt_Exception $e) {
echo $e->getUsageMessage();
exit;
}
//Usage
if(isset($opts->help) || !isset($opts->file))
{
echo $opts->getUsageMessage();
exit;
}
//Traiter la demande en créant les requetes sql nécessaires
$tabDico = array(
'etablissements' => array(
'db' => 'jo.etablissements',
'cle' => array(
'idSd' => "CONCAT(source,'-',source_id) AS idSd",
'source' => '',
'triCode' => '',
'autre_id' => '',
'actif' => '',
'siege' => '',
'raisonSociale' => '',
'enseigne' => '',
'sigle' => '',
'marques' => '',
'adr_num' => '',
'adr_btq' => '',
'adr_typeVoie' => '',
'adr_libVoie' => '',
'adr_comp' => '',
'adr_cp' => '',
'adr_ville' => '',
'adr_dep' => '',
'adr_codeCom' => 'CONCAT(if (adr_dep>100,round(adr_dep/10),adr_dep*1),adr_com) AS adr_codeCom',
'telEtab' => 'tel as telEtab',
'faxEtab' => 'fax as faxEtab',
'cj' => '',
'capital' => '',
'capitalDev' => '',
'ape_etab' => '',
'ape_entrep' => '',
'SiretEnBase' => 'nic>0 as SiretEnBase',
),
'where' => ' WHERE siren=$siren AND nic=$nicV',
),
'identite' => array(
'db' => 'insee.identite',
'cle' => array(
'etActifInsee' => 'ACTIF as etActifInsee',
'nomInsee' => 'NOM as nomInsee',
'nomInsee2' => 'NOM2 as nomInsee2',
'sigleInsee' => 'SIGLE as sigleInsee',
'enseigneInsee' => 'ENSEIGNE as enseigneInsee',
'adrNumVoieInsee' => 'ADR_NUMVOIE as adrNumVoieInsee',
'adrBtqInsee' => 'ADR_BTQ as adrBtqInsee',
'adrTypeVoieInsee' => 'ADR_TYPVOIE as adrTypeVoieInsee',
'adrVoieInsee' => 'ADR_LIBVOIE as adrVoieInsee',
'adrCompInsee' => 'ADR_COMP as adrCompInsee',
'adrCPInsee' => 'ADR_CP as adrCPInsee',
'adrVilleInsee' => 'ADR_LIBCOM as adrVilleInsee',
'adrDistSPInsee' => 'ADR_DISTSP as adrDistSPInsee',
'CjInsee' => 'CJ as CjInsee',
'nafEnInsee' => 'APE_ENT as nafEnInsee',
'nafEtInsee' => 'APE_ETAB as nafEtInsee',
'APRM' => '',
'ACTIVNAT' => '',
'ORIGINE' => '',
'MODET' => '',
'EXPLET' => '',
'LIEUACT' => '',
'ACTISURF' => '',
'MODEN' => '',
'PRODPART' => '',
'EXPLEN' => '',
'MONOREG' => '',
'REGIMP' => '',
'MONOACT' => '',
'DCREN' => '',
'AUXILT' => '',
'SAISONAT' => '',
'CIVILITE' => '',
'TCA' => '',
'TCAEXP' => '',
'EFF_ENT' => '',
'DCRET' => '',
'EFF_ET' => '',
'CODEVOIE' => '',
'dateMajInsee' => 'dateUpdate as dateMajInsee',
),
'where' => ' WHERE SIREN=$siren AND NIC=$nicV',
),
'notice' => array(
'db' => 'insee.insee_notices',
'cle' => array(
'insRPET' => '',
'insDEPCOMEN' => '',
'insRPEN' => '',
'insARRONET' => '',
'insCTONET' => '',
'insTCD' => '',
'insZEMET' => '',
'insDU' => '',
'insTU' => '',
'insUU' => '',
'insRECME' => '',
'insEAEANT' => '',
'insEAEAPET' => '',
'insEAESEC1T' => '',
'insEAESEC2T' => '',
'insEAEANN' => '',
'insEAEAPEN' => '',
'insEAESEC1N' => '',
'insEAESEC2N' => '',
'insEAESEC3N' => '',
'insEAESEC4N' => '',
'dateMajNotice' => 'dateNotice as dateMajNotice',
),
'where' => ' WHERE insSIREN=$siren AND insNIC=$nicV',
),
'rncs_entrep' => array(
'db' => 'jo.rncs_entrep',
'cle' => array(
'entActiveRncs' => 'actif AS entActiveRncs',
'numRC2' => 'numRC2',
'raisonSocialeRncs' => 'raisonSociale AS raisonSocialeRncs',
'sigleRncs' => 'sigle AS sigleRncs',
'dateNaiss' => 'dateNaiss',
'lieuNaiss' => 'lieuNaiss',
'nationalite' => 'nationalite',
'pays' => 'pays',
'nafEnRncs' => 'naf AS nafEnRncs',
'cjRncs' => 'cj AS cjRncs',
'dateImma' => 'dateImma',
'dateRad' => 'dateRad',
'capitalType' => 'capitalType',
'dateMajEnRncs' => 'flux AS dateMajEnRncs',
),
'where' => ' WHERE siren=$siren',
),
'rncs_etab' => array(
'db' => 'jo.rncs_etab',
'cle' => array(
'etActifRncs' => 'actif AS etActifRncs',
'siegeRncs' => 'siege AS siegeRncs',
'enseigneRncs' => 'enseigne AS enseigneRncs',
'nomCommercialRncs' => 'nomCommercial AS nomCommercialRncs',
'adrNumVoieRncs' => 'adrNumVoie AS adrNumVoieRncs',
'adrIndRepRncs' => 'adrIndRep AS adrIndRepRncs',
'adrLibVoieRncs' => 'adrLibVoie AS adrLibVoieRncs',
'adrTypeVoieRncs' => 'adrTypeVoie AS adrTypeVoieRncs',
'adrVoieRncs' => 'adrVoie AS adrVoieRncs',
'cpRncs' => 'cp AS cpRncs',
'villeRncs' => 'commune AS villeRncs',
'adrCompRncs' => 'adrComp AS adrCompRncs',
'nafEtRncs' => 'naf AS nafEtRncs',
'dateMajEtRncs' => 'flux AS dateMajEtRncs',
),
'where' => ' WHERE siren=$siren AND nic=$nicV',
),
'infos_entrep' => array(
'db' => 'jo.infos_entrep',
'cle' => array(
'isin' => '',
'tel' => '',
'fax' => '',
'web' => '',
'mail' => '',
),
'where' => ' WHERE siren=$siren',
),
'data' => array(
'nicSiege',
'tva',
'dateFermetureEn',
'dateFermetureEt',
'activite',
'situationJuridique',
'situationParution',
'situationDernCode',
'situationDernEven',
'indiScore',
'dirigeant',
'encours',
'dateBilan',
'bilanN',
'bilanN1',
'bilanN2',
'annonces',
),
);
$file = basename($opts->file);
$extension = strrchr($file,'.');
$file = str_replace($extension, '', $file);
$outFile = $file.'-'.date('YmdHis').'.csv';
define('MYSQL_HOST', '192.168.78.230');
define('MYSQL_USER', 'wsuser');
define('MYSQL_PASS', 'scores');
define('MYSQL_DEFAULT_DB', 'jo');
//Définition bdd
$dbConfig = array(
'host' => MYSQL_HOST,
'username' => MYSQL_USER,
'password' => MYSQL_PASS,
'dbname' => MYSQL_DEFAULT_DB,
);
$db = Zend_Db::factory('PDO_MYSQL', $dbConfig);
//Chargement des classes metier
require_once realpath(dirname(__FILE__)).'/../config/config.php';
require_once 'Metier/insee/classMInsee.php';
require_once 'framework/common/mysql.php';
$tabExtract = array();
$tabEntete = array();
$tabIdentifiant = array();
$tabData = array();
$posKeySiren = $posKeySiret = $posKeyNic = false;
//Lire le fichier csv
$row = 0;
if (($handle = fopen($opts->file, 'r')) !== FALSE) {
while (($data = fgetcsv($handle, 0, ',', '"')) !== FALSE) {
$num = count($data);
//Traitement de la première ligne
if ($row == 0) {
for ($c=0; $c < $num; $c++) {
//Détection clé importante
switch(strtolower($data[$c])) {
case 'siren':
$posKeySiren = $c;
break;
case 'nic':
$posKeyNic = $c;
break;
case 'siret':
$posKeySiret = $c;
break;
}
$tabExtract[] = $data[$c];
}
if ($posKeySiren!==false && $posKeyNic!==false && $posKeySiret!==false || $posKeySiren!==false && $posKeySiret!==false ){
die("Trop de clé!");
}
if ($posKeySiren===false && $posKeySiret===false){
die("Aucune clé détecté!");
}
//Traitement des identifiants
} else {
if ( $posKeySiret!==false ){
$tabIdentifiant[] = $data[$posKeySiret];
} elseif ( $posKeySiren!==false && $posKeyNic!==false ){
$tabIdentifiant[] = $data[$posKeySiren].$data[$posKeyNic];
} elseif ( $posKeySiren !==false ){
$tabIdentifiant[] = $data[$posKeySiren];
}
for ($c=0; $c < $num; $c++) {
$colname = $tabExtract[$c];
if (!in_array(strtolower($colname), array('siren', 'siret', 'nic'))){
$tabData[$row-1][$colname] = $data[$c];
}
}
}
$row++;
}
fclose($handle);
}
$nbIdentifiant = count($tabIdentifiant);
echo "Chargement de $row lignes dont $nbIdentifiant lignes avec identifiants.\n";
$rowTotal = $nbIdentifiant;
//Liste des champs SQL
foreach($tabExtract as $key)
{
$strKey = false;
//Détection element(VAL1,VAL2)
$values = false;
if (preg_match('/(.*)\((.*)\)/', $key, $matches))
{
$key = $matches[1];
$values = $matches[2];
}
//Traitement spécial pour le champs, ajout et remplacement sur entete
if (function_exists($key.'Entete')){
$keys = call_user_func($key.'Entete', $values);
foreach($keys as $item){
$tabEntete[] = $item;
}
} else {
$tabEntete[] = $key;
}
//Ajout à la requete SQL
foreach($tabDico as $element => $select)
{
if ( array_key_exists('db', $select) && array_key_exists($key, $select['cle']) )
{
if (isset(${$element.'Fields'})){ ${$element.'Fields'}.= ', '; }
if ($select['cle'][$key]!=''){
$strKey = $select['cle'][$key];
}
if ($strKey!==false){
${$element.'Fields'}.= $strKey;
} else {
${$element.'Fields'}.= $key;
}
break;
}
if ( $element == 'data' && in_array($key, $select) )
{
${$key.'Data'} = $values;
}
}
}
//Ajout colonne obligatoire SiretValide
$tabEntete[] = 'SiretValide';
unset($tabExtract);
//Vérification et création des données
$row = 0;
foreach($tabIdentifiant as $item)
{
echo "Lignes ".($row+1)." / $rowTotal";
$siretValide = false;
$sirenValide = false;
$siren = substr($item, 0, 9);
$nic = substr($item, 9);
//Vérification par algorithme
$siretValide = siretValide($item);
if ($posKeySiret!==false){
if ($siretValide===false){
$sirenValide = sirenValide($siren);
} else {
$sirenValide = true;
}
}
if ($posKeySiren!==false && $posKeyNic!==false) {
$sirenValide = sirenValide($siren);
}
//On définit le tableau de retour
if ( $posKeySiret!==false ){
$tabData[$row]['siret'] = $item;
} elseif ( $posKeySiren!==false && $posKeyNic!==false ){
$tabData[$row]['siren'] = $siren;
$tabData[$row]['nic'] = $nic;
} elseif ( $posKeySiren !==false ){
$tabData[$row]['siren'] = $siren;
}
$tabData[$row]['SiretValide'] = ($siretValide===true) ? 1 : 0;
if ( $sirenValide===false || intval($siren)==0 ){
echo " - Siren Invalide -";
echo "\n";
$row++;
continue;
}
//Vérifier les nic, ou sélectionner le nic du siege actif
$nicV = $nic; //Surcharge pour le nic
$strNic = '';
$sqlNic = 'SELECT nic as nicTmp, cj as cjTmp FROM jo.etablissements WHERE siren='.$siren;
if (strlen($item)==14 && intval($nic)>0){
$stmt = $db->query($sqlNic.' AND nic='.$nic);
$result = $stmt->fetchAll();
if (count($result)==0){
$nicV = 0;
$fJur = '0000';
} else {
//nic : On considère qu'il est vrai si on a un résultat
$fJur = $result[0]['cjTmp'];
}
}
if (intval($nicV)==0){
$strNic = ' AND nic>-1 AND actif>-1 ORDER BY siege DESC, actif DESC, nicTmp DESC LIMIT 0,1';
$stmt = $db->query($sqlNic.$strNic);
$result = $stmt->fetchAll();
if (count($result)>0){
$nicV = $result[0]['nicTmp'];
$fJur = $result[0]['cjTmp'];
} else {
$nicV = '00000';
$fJur = '0000';
}
}
if ( $posKeySiren!==false && $posKeyNic!==false ){
$tabData[$row]['siren'] = $siren;
$tabData[$row]['nic'] = $nic;
}
//Récupération des données
foreach($tabDico as $element => $select)
{
//Traitement par requete SQL
if (isset(${$element.'Fields'})){
$where = $select['where'];
eval( "\$where = \"$where\";" );
${$element.'SQL'} = 'SELECT '.${$element.'Fields'}.' FROM '.$select['db'].$where;
$stmt = $db->query(${$element.'SQL'});
$result = $stmt->fetchAll();
if (count($result)>0){
$tabData[$row] = array_merge( $tabData[$row] , $result[0]);
}
}
//Traitement par fonction
if( $element == 'data' )
{
foreach($select as $item)
{
if (isset(${$item.'Data'}))
{
$values = false;
if( ${$item.'Data'}!=false ){
//$values = explode(',', ${$item.'Data'});
$values = ${$item.'Data'};
}
$tabData[$row] = array_merge($tabData[$row], call_user_func($item.'Data', $siren, $nicV, $values));
}
}
}
}
echo "\n";
$row++;
}
//Mettre dans l'ordre les données
$tabSortie = array();
$row = 0;
foreach($tabData as $data){
foreach($tabEntete as $key){
$tabSortie[$row][] = isset($tabData[$row][$key]) ? $tabData[$row][$key] : '';
}
$row++;
}
writeCSV($tabSortie, $tabEntete, $outFile);
/* == FUNCTION DATA == */
function nicSiegeData($siren, $nic, $values = false)
{
$tabData['nicSiege'] = $nic;
return $tabData;
}
function tvaData($siren, $nic, $values = false)
{
require_once 'Metier/partenaires/classMTva.php';
$iTva = @new MTva($siren, false);
$tabData['tva'] = isset($iTva->vatNumber) ? $iTva->vatNumber : '';
return $tabData;
}
function dateFermetureEtEntete($values)
{
return array(
'dateFermetureEt',
'codeFermetureEt',
);
}
function dateFermetureEtData($siren, $nic, $values = false)
{
$iDb = new WDB();
$ret = $iDb->select('insee.insee_even', 'insEVE, insDATEVE', 'insSIREN='.$siren.' AND insNIC='.$nic." AND insEVE IN('FF','OF','400','410','420','425','430','435') ORDER BY insDATEVE DESC LIMIT 1", false, MYSQL_ASSOC);
if (mysql_errno()>0) die( 'Erreur B2 '.mysql_errno().' : '.mysql_error() );
if (count($ret)==0) {
$siret = $siren.$nic;
$ret = $iDb->select('insee.insee_even', 'insEVE, insDATEVE', "insSIRETPS=$siret AND insEVE IN('510','530') ORDER BY insDATEVE DESC LIMIT 1", false, MYSQL_ASSOC);
}
$tabData['dateFermetureEt'] = isset($ret[0]['insDATEVE']) ? $ret[0]['insDATEVE'] : '';
$tabData['codeFermetureEt'] = isset($ret[0]['insEVE']) ? $ret[0]['insEVE'] : '';
return $tabData;
}
function dateFermetureEnEntete($values)
{
return array(
'dateFermetureEn',
'codeFermetureEn',
);
}
function dateFermetureEnData($siren, $nic, $values = false)
{
$iDb = new WDB();
$ret = @$iDb->select('insee.insee_even', 'insEVE, insDATEVE', 'insSIREN='.$siren." AND insEVE IN('FF','410','420','425') ORDER BY insDATEVE DESC", false, MYSQL_ASSOC);
if (mysql_errno()>0) die( 'Erreur B3 '.mysql_errno().' : '.mysql_error() );
$tabData['dateFermetureEn'] = isset($ret[0]['insDATEVE']) ? $ret[0]['insDATEVE'] : '';
$tabData['codeFermetureEn'] = isset($ret[0]['insEVE']) ? $ret[0]['insEVE'] : '';
return $tabData;
}
function activiteData($siren, $nic, $values = false)
{
global $fJur;
$tmp = @$iBodacc->getActiviteReelle($siren, $fJur);
$tabData['activite'] = @preg_replace('/ +/', ' ', strtr($tmp,array("\r"=>' ',"\n"=>' ',"\t"=>' ',','=>' ',';'=>' ','"'=>' ',"'"=>' ')));
return $tabData;
}
function situationJuridiqueEntete($values)
{
return array(
'situationJuridique',
'situationParution',
'situationDernCode',
'situationDernEven',
);
}
function situationJuridiqueData($siren, $nic, $values = false)
{
$tabTmp = array('P','A','D');
$tabData['situationJuridique']='';
foreach ($tabTmp as $sit) {
$iInsee = new MInsee();
$tmp = $iInsee->getAnnoncesLegales($cel[$pos['SIREN']], 0, $sit, false);
if (count($tmp)>0) {
$tmp=$tmp[0];
$tabData['situationJuridique']=$sit;
$tabData['situationParution']=@$tmp['DateParution'];
$tabData['situationDernCode']=@$tmp[0]['CodeEven'];
$tabData['situationDernEven']=@preg_replace('/ +/', ' ', strtr($tmp[0]['LibEven'],array("\r"=>' ',"\n"=>' ',"\t"=>' ',','=>' ',';'=>' ','"'=>' ',"'"=>' ')));
break;
}
}
if ($tabData['situationJuridique']=='') {
$iDb = new WDB();
$rep = $iDb->select('rncs_entrep', 'actif, dateRad', "siren=".$cel[$pos['SIREN']], false, MYSQL_ASSOC);
$entrep = @$rep[0];
if (isset($entrep['actif']) && $entrep['actif']*1==0)
$tabData['situationJuridique']='R';
$tabData['situationParution']=@$entrep['dateRad'];
$tabData['situationDernCode']='';
$tabData['situationDernEven']='';
}
return $tabData;
}
function dirigeantEntete($values)
{
return array(
'dirigeant1Nom',
'dirigeant1Fonction',
'dirigeant1DateNaiss',
'dirigeant1LieuNaiss',
'dirigeant2Nom',
'dirigeant2Fonction',
'dirigeant2DateNaiss',
'dirigeant2LieuNaiss',
);
}
function dirigeantData($siren, $nic, $values = false)
{
$iInsee = new MInsee();
$tmp = $iInsee->getDirigeants($siren, false);
$tabData['dirigeant1Nom'] = '';
$tabData['dirigeant1Fonction'] = '';
$tabData['dirigeant1DateNaiss'] = '';
$tabData['dirigeant1LieuNaiss'] = '';
$tabData['dirigeant2Nom'] = '';
$tabData['dirigeant2Fonction'] = '';
$tabData['dirigeant2DateNaiss'] = '';
$tabData['dirigeant2LieuNaiss'] = '';
if (count($tmp)>0 ) {
$dir = $tmp[0];
if ($dir['Societe']<>'') $tabData['dirigeant1Nom'].= $dir['Societe'].' repr. par ';
$tabData['dirigeant1Nom'].= trim($dir['Civilite'].' '.$dir['Nom'].' '.$dir['Prenom']);
$tabData['dirigeant1Fonction'] = $dir['Titre'];
$tabData['dirigeant1DateNaiss'] = $dir['NaissDate'];
$tabData['dirigeant1LieuNaiss'] = $dir['NaissVille'];
}
if (count($tmp)>1) {
$dir = $tmp[1];
if ($dir['Societe']<>'') $tabData['dirigeant2Nom'].=$dir['Societe'].' repr. par ';
$tabData['dirigeant2Nom'].= trim($dir['Civilite'].' '.$dir['Nom'].' '.$dir['Prenom']);
$tabData['dirigeant2Fonction'] = $dir['Titre'];
$tabData['dirigeant2DateNaiss'] = $dir['NaissDate'];
$tabData['dirigeant2LieuNaiss'] = $dir['NaissVille'];
}
return $tabData;
}
function bilanNEntete($values)
{
if ($values!==false) {
$values = explode(',', $values);
$tmp = array();
foreach($values as $value){
$tmp[] = 'bilanN'.$value;
}
return array_merge(
array('bilanNdateCloture', 'bilanNdureeMois')
, $tmp
);
} else {
return array('bilanNdateCloture', 'bilanNdureeMois');
}
}
function bilanNData($siren, $nic, $values = false)
{
require_once 'Metier/partenaires/classMBilans.php';
$tabPostes = explode(',', $values);
$tabData = array();
$annee = 0;
$mBil = new MBilans($siren);
$tabBilans = $mBil->listeBilans(false, 3);
if (count($tabBilans)>0) {
$tabBil = array();
foreach ($tabBilans as $typeMil=>$bilan) {
$tabBil[] = $mBil->getBilan(substr($typeMil,1), substr($typeMil,0,1));
}
$tabBi = $tabBil[$annee];
$tabData['bilanNdateCloture'] = $tabBi['DATE_CLOTURE'];
$tabData['bilanNdureeMois'] = $tabBi['DUREE_MOIS'];
if (count($tabPostes)>0){
foreach ($tabPostes as $poste) {
if (isset($tabBi[$poste])){
$tabData['bilanN'.$poste] = $tabBi[$poste];
}
}
}
}
return $tabData;
}
function bilanN1Entete($values)
{
if ($values!==false) {
$values = explode(',', $values);
$tmp = array();
foreach($values as $value){
$tmp[] = 'bilanN1'.$value;
}
return array_merge(
array('bilanN1dateCloture', 'bilanN1dureeMois')
, $tmp
);
} else {
return array('bilanN1dateCloture', 'bilanN1dureeMois');
}
}
function bilanN1Data($siren, $nic, $values = false)
{
require_once 'Metier/partenaires/classMBilans.php';
$tabPostes = explode(',', $values);
$tabData = array();
$annee = 1;
$mBil = new MBilans($siren);
$tabBilans = $mBil->listeBilans(false, 3);
if (count($tabBilans)>0) {
$tabBil = array();
foreach ($tabBilans as $typeMil=>$bilan) {
$tabBil[] = $mBil->getBilan(substr($typeMil,1), substr($typeMil,0,1));
}
$tabBi = $tabBil[$annee];
$tabData['bilanN1dateCloture'] = $tabBi['DATE_CLOTURE'];
$tabData['bilanN1dureeMois'] = $tabBi['DUREE_MOIS'];
if (count($tabPostes)>0){
foreach ($tabPostes as $poste) {
if (isset($tabBi[$poste])){
$tabData['bilanN1'.$poste] = $tabBi[$poste];
}
}
}
}
return $tabData;
}
function bilanN2Entete($values)
{
if ($values!==false) {
$values = explode(',', $values);
$tmp = array();
foreach($values as $value){
$tmp[] = 'bilanN2'.$value;
}
return array_merge(
array('bilanN2dateCloture', 'bilanN2dureeMois')
, $tmp
);
} else {
return array('bilanN2dateCloture', 'bilanN2dureeMois');
}
}
function bilanN2Data($siren, $nic, $values = false)
{
require_once 'Metier/partenaires/classMBilans.php';
$tabPostes = explode(',', $values);
$tabData = array();
$annee = 2;
$mBil = new MBilans($siren);
$tabBilans = $mBil->listeBilans(false, 3);
if (count($tabBilans)>0) {
$tabBil = array();
foreach ($tabBilans as $typeMil=>$bilan) {
$tabBil[] = $mBil->getBilan(substr($typeMil,1), substr($typeMil,0,1));
}
$tabBi = $tabBil[$annee];
$tabData['bilanN2dateCloture'] = $tabBi['DATE_CLOTURE'];
$tabData['bilanN2dureeMois'] = $tabBi['DUREE_MOIS'];
if (count($tabPostes)>0){
foreach ($tabPostes as $poste) {
if (isset($tabBi[$poste])){
$tabData['bilanN2'.$poste] = $tabBi[$poste];
}
}
}
}
return $tabData;
}
function annoncesEntete($values)
{
if ($values!==false) {
$values = explode(',', $values);
$tmp = array();
foreach($values as $value){
$tmp[] = 'Annonce'.$value.'Lib';
$tmp[] = 'Annonce'.$value.'Date';
$tmp[] = 'Annonce'.$value.'DateParution';
}
return $tmp;
} else {
return array();
}
}
function annoncesData($siren, $nic, $values = false)
{
if ($values!==false) {
$tabDeja = array();
$tabTmp = explode(',', $values);
$iInsee = new MInsee();
$tabEven = $iInsee->getAnnoncesLegales($siren, 0, $tabTmp);
foreach ($tabTmp as $even){
foreach ($tabEven as $tabAnn){
foreach ($tabAnn['evenements'] as $codEve){
if ($even==$codEve['CodeEven'] && !in_array($even, $tabDeja)) {
$tabDeja[] = $even;
$dateEven = $tabAnn['dateJugement'];
if ($dateEven=='0000-00-00') $dateEven=$tabAnn['dateEffet'];
if ($dateEven=='0000-00-00') $dateEven=$tabAnn['DateParution'];
$tabData['Annonce'.$even.'Lib'] = strtr($codEve['LibEven'],array(','=>' ',"'"=>' ','"'=>' ',';'=>' '));
$tabData['Annonce'.$even.'Date'] = $dateEven;
$tabData['Annonce'.$even.'DateParution'] = $tabAnn['DateParution'];
}
}
}
}
return $tabData();
} else {
return $tabData();
}
}
/* == FUNCTION == */
/**
* Verifie si un SIREN est valide
* @param Le code SIREN dont on veut vérifier la validité.
* @return Un booléen qui vaut 'true' si le code SIREN passé en
* paramètre est valide, false sinon.
*/
function sirenValide($siren) {
if ( (strlen($siren) != 9) || (is_nan($siren)) )
$estValide = false;
else {
// Donc le SIREN est un numérique à 9 chiffres
$somme = 0;
$tmp = 0;
for ($cpt = 0; $cpt<strlen($siren); $cpt++) {
if (($cpt % 2) == 1) { // Les positions paires : 2ème, 4ème, 6ème et 8ème chiffre
$tmp = substr($siren, $cpt, 1) * 2; // On le multiplie par 2
if ($tmp > 9)
$tmp-= 9; // Si le résultat est supérieur à 9, on lui soustrait 9
}
else
$tmp = substr($siren, $cpt, 1);
$somme+= intval($tmp);
}
if (($somme % 10) == 0)
$estValide = true; // Si la somme est un multiple de 10 alors le SIREN est valide
else
$estValide = false;
}
return $estValide;
}
/**
* Verifie si un SIRET est valide
* @param Le code SIRET dont on veut vérifier la validité.
* @return Un booléen qui vaut 'true' si le code SIRET passé en
* paramètre est valide, false sinon.
*/
function siretValide($siret) {
if ( (strlen($siret) != 14) || (is_nan($siret)) )
$estValide = false;
else {
// Donc le SIRET est un numérique à 14 chiffres
// Les 9 premiers chiffres sont ceux du SIREN (ou RCS), les 4 suivants
// correspondent au numéro d'établissement
// et enfin le dernier chiffre est une clef de LUHN.
$somme = 0;
$tmp = 0;
for ($cpt = 0; $cpt<strlen($siret); $cpt++) {
if (($cpt % 2) == 0) { // Les positions impaires : 1er, 3è, 5è, etc...
$tmp = substr($siret, $cpt, 1) * 2; // On le multiplie par 2
if ($tmp > 9)
$tmp-= 9; // Si le résultat est supérieur à 9, on lui soustrait 9
}
else
$tmp = substr($siret, $cpt, 1);
$somme+= intval($tmp);
}
if (($somme % 10) == 0)
$estValide = true; // Si la somme est un multiple de 10 alors le SIRET est valide
else
$estValide = false;
}
return $estValide;
}
/**
* writeCSV
* @param array $list
* @param array $entete
* @param string $filename
*/
function writeCSV($list, $entete, $filename)
{
$fp = fopen($filename, 'w');
if (count($entete)>0){
fputcsv($fp, $entete, ',', '"');
}
foreach ($list as $fields) {
fputcsv($fp, $fields, ',', '"');
}
fclose($fp);
}

581
batch/genCodeRatios.php Normal file
View File

@ -0,0 +1,581 @@
#!/usr/bin/php
<?php
// Define path to application directory
defined('APPLICATION_PATH')
|| define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../application'));
// Define application environment
defined('APPLICATION_ENV')
|| define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : '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;
}
require_once realpath(dirname(__FILE__)).'/../config/config.php';
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");
}
}

83
batch/genwsdl.php Normal file
View File

@ -0,0 +1,83 @@
#!/usr/bin/php
<?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'
);
require_once realpath(dirname(__FILE__)).'/../config/config.php';
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();
}

View File

@ -1,9 +1,29 @@
#!/usr/bin/php
<?php
require_once __DIR__ . '/../application/bin.bootstrap.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'
);
// --- Options
$displayUsage = false;
try {
$opts = new Zend_Console_Getopt(
//Options
@ -16,60 +36,45 @@ try {
)
);
$opts->parse();
$optionsNb = count($opts->getOptions());
} catch (Zend_Console_Getopt_Exception $e) {
$displayUsage = true;
echo $e->getUsageMessage();
exit;
}
// --- Aide / Options
if ($optionsNb == 0 || isset($opts->help)) {
$displayUsage = true;
if ( isset($opts->debug) ) {
define('DEBUG', true);
} else {
define('DEBUG', false);
}
// --- Usage
if ($displayUsage) {
echo "Telecharge le kbis chez infogreffe.";
//Usage
if(count($opts->getOptions())==0 || isset($opts->help))
{
echo "Telecharge le kbis chez infogreffe.";
echo "\n\n";
echo $opts->getUsageMessage();
echo "\n";
exit;
}
if ( isset($opts->debug) ) {
define('DEBUG', true);
} else {
define('DEBUG', false);
}
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)
function getPage($url, $curl_data = '', $verbose=false)
{
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.'&';
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
@ -89,12 +94,7 @@ function getPage($url, $curl_data = '', $override = null)
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);
@ -103,51 +103,23 @@ function getPage($url, $curl_data = '', $override = null)
$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//TRANSLIT', $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;
}
//Define Main URL
$siteUrl = "https://www2.infogreffe.fr";
function infogreffeConnexion()
{
global $siteUrl;
$url = $siteUrl . "/infogreffe/index.jsp";
$url = "http://www.infogreffe.fr/infogreffe/index.jsp";
$result = getPage($url);
if (DEBUG) file_put_contents('kbis-connexion1.html', $result['content']);
$url = $siteUrl . "/infogreffe/popupLog.jsp?type=0&url=index.jsp";
$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 = $siteUrl . "/infogreffe/login.do?redirect=index.jsp";
$url = "https://www.infogreffe.fr/infogreffe/login.do?redirect=index.jsp";
// 302 Moved Temporarily
// => http://www.infogreffe.fr/infogreffe/index.jsp
$data = array(
@ -158,11 +130,11 @@ function infogreffeConnexion()
);
$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&eacute;</span> |
<a href="/infogreffe/jsp/information/monCompte.jsp">Mon compte</a> |
<a href="/infogreffe/afficherMesAchats.do?refCde=N">Documents Command&eacute;s</a>
@ -173,51 +145,49 @@ function infogreffeConnexion()
function infogreffeKbis($ref)
{
global $siteUrl;
/**************************************************
afficheProduit
**************************************************/
$url = $siteUrl . "/infogreffe/chargement.jsp?oups=".$ref."_0_V_0_";
$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 = $siteUrl . "/infogreffe/serviceProduit.do?cdePro=".$ref."_0_V_0_";
$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';
global $c;
$dir = realpath($c->profil->path->shared).'/datafile/kbis/'.date('Ymd');
$dir = DOC_WEB_LOCAL.'kbis/'.date('Ymd');
if (!file_exists($dir)) mkdir($dir);
file_put_contents($dir . '/' . $fichier, $output);
return ($identifiant!='unknown') ? $identifiant : false;
@ -258,7 +228,7 @@ function parseRef($document)
$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){
@ -294,29 +264,29 @@ if (file_exists($ckfile)) unlink($ckfile);
if ( $opts->commandes )
{
$referer = '';
/**************************************************
Connexion
**************************************************/
infogreffeConnexion();
$url = $siteUrl . "/infogreffe/jsp/information/monCompte.jsp";
$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 = $siteUrl . "/infogreffe/afficherMesAchats.do?refCde=N";
$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){
@ -324,7 +294,7 @@ if ( $opts->commandes )
preg_match("/javascript:reveal\(\'(.*)\'\)/", $href, $matches);
$refs[] = array( 'ref' => $matches[1] );
}
$listeRef = array();
foreach($refs as $item){
$listeRef[] = $item['ref'];
@ -334,14 +304,16 @@ if ( $opts->commandes )
{
//Pour toutes les commandes en dehors de la toute dernière
if ( array_search($opts->visu, $listeRef)!=0 ){
$url = $siteUrl . "/infogreffe/chargerContenuCommande.do?refCde=".$opts->visu."&_=";
$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 ) {
/**************************************************
@ -354,7 +326,7 @@ if ( $opts->commandes )
foreach ( $refs as $ref )
{
if ($i!=0){
$url = $siteUrl . "/infogreffe/chargerContenuCommande.do?refCde=".$ref['ref']."&_=";
$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
@ -376,23 +348,26 @@ if ( $opts->commandes )
if ( $opts->siren )
{
//Vérification du siren
if (strlen($opts->siren)!=9 && strlen($opts->siren)!=14) {
echo "Erreur SIREN invalide\n"; exit;
echo "Verfication du siren ...";
if (strlen($opts->siren)!=9) {
echo "Erreur\n"; exit;
}
echo "OK";
echo "\n";
$referer = '';
/**************************************************
Connexion
**************************************************/
infogreffeConnexion();
/**************************************************
Affichage formulaire
**************************************************/
$url = $siteUrl . "/infogreffe/index.jsp";
$url = "http://www.infogreffe.fr/infogreffe/index.jsp";
$result = getPage($url);
if (DEBUG) file_put_contents('kbis1.html', $result['content']);
/**************************************************
Soumission formulaire
**************************************************/
@ -400,103 +375,33 @@ if ( $opts->siren )
'commune' => '',
'denomination' => '',
'departement' => '',
//'elargirSecondaire' => 'on',
'elargirRadie' => 'on',
'siren' => $opts->siren,
);
$url = $siteUrl . "/infogreffe/newRechercheEntreprise.xml";
$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 = $siteUrl . '/infogreffe/entrepRech.do';
// 302 Moved Temporarily
$url='http://www.infogreffe.fr/infogreffe/entrepRech.do';
if ( $result['header']['http_code']=='302' ) {
//$url = $result['header']['redirect_url'];
$url='http://www.infogreffe.fr/weblogic/infogreffe/entrepRech.do';
}
/**************************************************
Affichage identite entreprise
**************************************************/
//url defini plus haut
$result = getPage($url, '', array(CURLOPT_FOLLOWLOCATION => true));
$result = getPage($url);
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 = $siteUrl . $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);
if ($entries->length!=0) {
$message = $entries->item(0)->nodeValue;
echo trim($message);
} else {
$entries = $xpath->query("//span[@class='texte-standard']", $context);
if ($entries->length!=0) {
$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;
@ -505,37 +410,38 @@ if ( $opts->siren )
$xpath = new DOMXpath($doc);
$nodelist = $xpath->query("//a[@class='company']");
foreach ($nodelist as $n) {
$url = $siteUrl . $n->getAttribute('href');
$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 = $siteUrl . '/weblogic/infogreffe/entrepListe.do?index=rcs';
$result = getPage($url);
$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 = $siteUrl . $n->getAttribute('href');
break;
}
$result = getPage($url);
$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);
$fields = array();
//Recherche des infos pour la validation du formulaire
$nodelist = $xpath->query("//form[@name='FicheEntrepriseForm']/div[@id='conteneur']/input[@type='hidden']");
foreach ($nodelist as $n) {
$key = $n->getAttribute('name');
@ -555,19 +461,19 @@ if ( $opts->siren )
$fields['historiqueModificationsForm.tri'] = '0';
$fields['procedureCollectiveForm.formVisible'] = 'true';
$fields['dossierCompletForm.formVisible'] = 'true';
if (DEBUG) print_r($fields);
/**************************************************
Validation de la selection
**************************************************/
$url = $siteUrl . "/infogreffe/validerSelectionFicheEntreprise.xml";
$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 = $siteUrl . "/infogreffe/validerPanierAbonne.do?forcerSaisieCoordonnees=false";
$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']);
@ -575,23 +481,23 @@ if ( $opts->siren )
/**************************************************
Afficher mes achats et prendre la première commande
**************************************************/
$url = $siteUrl . "/infogreffe/afficherMesAchats.do?refCde=N&pageAppel=validerPanier";
$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
//Suppression fichier
if (file_exists($ckfile)) unlink($ckfile);
if ($identifiant===false || $identifiant!=substr($opts->siren,0,9)) {
if ($identifiant===false || $identifiant!=$opts->siren) {
echo "ERREUR";
exit;
}

264
batch/getPieces.php Normal file
View File

@ -0,0 +1,264 @@
#!/usr/bin/php
<?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(),
)));
require_once realpath(dirname(__FILE__)).'/../config/config.php';
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]). " SIREN [PIECE='kbis'] [TYPE=''] [VISU=1] [COURRIER=0] [REF='']
Récupération d'une pièce (kbis par défaut) pour un SIREN.
[PIECE]
kbis Seul pièce possible pour l'instant
";
$siren=0;
$piece='kbis';
$type='';
$visu=1;
$courrier=0;
$ref='';
$heureDemande = date('Hi');
$iInsee = new MInsee();
for ($i=1; isset($argv[$i]); $i++) {
if (substr($argv[$i],0,1)=='-') {
switch (strtolower(substr($argv[$i],1,1))) {
case '-':
case '?':
die($strInfoScript);
break;
default:
die('Option '. $argv[$i] . ' inconnue !'.EOL);
break;
}
}
elseif ($i==1) $siren=$argv[$i]*1;
elseif ($i==2) $piece=$argv[$i];
elseif ($i==3) $type=$argv[$i];
elseif ($i==4) $visu=$argv[$i];
elseif ($i==5) $courrier=$argv[$i];
elseif ($i==6) $ref=$argv[$i];
}
function kbisLog($siren,$piece,$message,$typeLog='DEBUG')
{
global $heureDemande;
if ($typeLog=='DEBUG') {
$fp = fopen("kbis.log", 'a');
fwrite($fp, date('Y-m-d H:i:s')." - $siren ($heureDemande) $piece $message".EOL);
fclose($fp);
} else {
$fp = fopen("kbis-error.log", 'a');
fwrite($fp, date('Y-m-d H:i:s')." - $siren ($heureDemande) $piece $message".EOL);
fclose($fp);
}
}
function checkSiren($siren, $str)
{
$pattern = "/((?:\s[0-9]{9,9})|(?:\s[0-9]{3,3}\s[0-9]{3,3}\s[0-9]{3,3})|(?:\s[0-9]{3,3}\.[0-9]{3,3}\.[0-9]{3,3})|(?:\s[0-9]{3,3}-[0-9]{3,3}-[0-9]{3,3}))/U";
if (preg_match($pattern, $str, $matches))
{
$sirenLu = trim(str_replace(' ','', $matches[1]));
if ($sirenLu == $siren)
{
return $sirenLu;
}
}
return false;
}
if ($siren<100 || !$iInsee->valideSiren($siren)) {
kbisLog($siren, $piece, "IN : Siren $siren Invalide !");
exit;
} else {
switch (strlen($siren)) {
case 1: $siren='00000000'.$siren; break;
case 2: $siren='0000000'.$siren; break;
case 3: $siren='000000'.$siren; break;
case 4: $siren='00000'.$siren; break;
case 5: $siren='0000'.$siren; break;
case 6: $siren='000'.$siren; break;
case 7: $siren='00'.$siren; break;
case 8: $siren='0'.$siren; break;
}
}
if ($piece<>'kbis') {
kbisLog($siren, $piece, "IN : Piece $piece inexistante !");
exit;
}
define('FORMAT', 'PDF'); //HTML ou PDF
define('PKBIS_HOST', '192.168.3.4');
define('PKBIS_USER', 'kbis');
define('PKBIS_PASS', 'kbis');
define('PDFTOTEXT', '/usr/bin/pdftotext'); // Vérifier que l'executable existe
define('WKHTMLTOPDF', '/usr/bin/wkhtmltopdf'); // Vérifier que l'executable existe....
/*
Principe de fonctionnement
- Vérifier en local que le fichier n'existe pas déjà et qu'il a moins d'un jour
- Envoi dun fichier portant le nom de $pieces-$siren.txt sur le ftp pour le
début de la récupération du kbis
- Vérifier sur le FTP que le fichier est disponible
Comparaison avec un ftp_nlist sur dossier /pdf ou /html
- Vérifier la date du fichier HTML (qui est le fichier source) afin d'écrire dans les logs
- Vérifier que le fichier PDF ou HTML correspond bien au SIREN demandé
Pour le fichier PDF, transformation avec pdftotext, et on parcours le fichier
texte à la recherche du SIREN
Pour le fichier HTML, on parcours le fichier à la recherche du siren et
on le tranforme en PDF grâce à wkhtmltopdf
*/
$kbisLocalPDF = DOC_WEB_LOCAL."kbis/$piece-$siren.pdf";
$kbisLocalHTML = DOC_WEB_LOCAL."kbis/$piece-$siren.html";
$kbisLocalTXT = DOC_WEB_LOCAL."kbis/$piece-$siren.txt";
if (file_exists($kbisLocalPDF)
&& date('Ymd',filectime($kbisLocalPDF))==date('Ymd')){
exit;
} else {
if (file_exists($kbisLocalHTML)) unlink($kbisLocalHTML);
if (file_exists($kbisLocalPDF)) unlink($kbisLocalPDF);
if (file_exists($kbisLocalTXT)) unlink($kbisLocalTXT);
}
// Ouverture de la connexion FTP
$conn_id = ftp_connect(PKBIS_HOST);
$login_result = ftp_login($conn_id, PKBIS_USER, PKBIS_PASS);
$tabListInit = ftp_nlist($conn_id, strtolower(FORMAT).'/');
$nbList = count($tabListInit);
$nbEssais = 0; // Nombre de tentatives de récupération
// Fichier à déposer sur le FTP pour débuter la commande
$fp = fopen(DOC_WEB_LOCAL."kbis/$piece-$siren", 'w+');
fwrite($fp, "$siren;$piece;$type;$visu;$courrier;$ref");
rewind($fp);
if (!ftp_fput($conn_id, "in/$piece-$siren.txt", $fp, FTP_ASCII)){
//Envoi mail pour erreur
exit;
}
fclose($fp);
kbisLog($siren, $piece, "IN : Fichier déposé en commande sur le FTP");
// Surveillance du FTP pour récupération du fichier
while (true)
{
$nbEssais++;
sleep($dureeInterval);
$tabList = ftp_nlist($conn_id, strtolower(FORMAT).'/');
if (count($tabList)>$nbList)
{
kbisLog($siren, $piece, "WAIT : Essai $nbEssais, des nouveaux fichiers sont disponibles sur le FTP !");
sleep($dureeInterval); // Laisse le temps au serveur de K-Bis de finir le fichier PDF !!!
$tabNom = array_diff($tabList,$tabListInit);
//Récupération du fichier
ftp_chdir($conn_id, strtolower(FORMAT));
$ficDist = str_replace(strtolower(FORMAT).'/', '', reset($tabNom));
if (!ftp_get($conn_id,DOC_WEB_LOCAL."kbis/$piece-$siren.".strtolower(FORMAT), $ficDist, FTP_BINARY))
{
// Problème FTP --> STOP
kbisLog($siren, $piece, "OUT : Problème FTP");
exit;
}
//Traitement en fonction du format
if (FORMAT == 'PDF')
{
shell_exec(PDFTOTEXT.' '.$kbisLocalPDF.' '.$kbisLocalTXT);
$str = file_get_contents($kbisLocalTXT);
$sirenLu = checkSiren($siren, $str);
if ($sirenLu){
kbisLog($siren, $piece, "OUT : Le nouveau fichier est celui attendu ($sirenLu=$siren)");
} else {
kbisLog($siren, $piece, "OUT : Le nouveau fichier n'est pas celui attendu ($sirenLu<>$siren)");
unlink($kbisLocalPDF);
}
break;
}
elseif (FORMAT == 'HTML')
{
$str = file_get_contents($kbisLocalHTML);
$str = preg_replace('@<DIV class=no-print>.*?</DIV>@si', '', $str);
file_put_contents($kbisLocalHTML, $str);
$sirenLu = checkSiren($siren, $str);
if ($sirenLu){
kbisLog($siren, $piece, "OUT : Le nouveau fichier est celui attendu ($sirenLu=$siren)");
shell_exec(WKHTMLTOPDF.' '.$kbisLocalHTML.' '.$kbisLocalPDF);
} else {
kbisLog($siren, $piece, "OUT : Le nouveau fichier n'est pas celui attendu ($sirenLu<>$siren)");
unlink($kbisLocalHTML);
}
break;
}
//Log ?
ftp_chdir($conn_id, '/html');
$tabListHtml = ftp_nlist($conn_id, $siren.'*');
foreach ($tabListHtml as $fichierHtml)
{
$ficDist2 = str_replace('html/', '', $fichierHtml);
$buff = ftp_mdtm($conn_id, $ficDist2);
if ($buff!=-1 && date("Ymd", $buff)==date("Ymd")) {
$fp = fopen(LOG_PATH."/$piece-commande.log", 'a+');
fwrite($fp, date('Y/m/d H:i:s')." - $siren - Nb fichier HTML : ".count($tabListHtml).print_r($tabListHtml));
fclose($fp);
}
}
}
else
{
kbisLog($siren, $piece, "WAIT : Essai $nbEssais, aucun nouveau fichier disponible sur le FTP !");
if (($nbEssais*$dureeInterval)>$dureeMaxi) {
kbisLog($siren, $piece, "OUT : Essai $nbEssais, ERREUR aucun kbis trouvé en $dureeMaxi secondes sur le FTP !");
kbisLog($siren, $piece, "OUT : Essai $nbEssais, ERREUR aucun kbis trouvé en $dureeMaxi secondes sur le FTP !", 'ERROR');
$message="ERREUR lors de la récupération du '$piece' pour le siren $siren (aucun PDF sur le serveur FTP au bout de $nbEssais essais en $dureeMaxi secondes)".EOL;
$message.=EOL."Si vous obtenez régulièrement ce message avec des siren différents, il faut probablement relancer la passerelle de commandes de pièces officielles.".EOL;
sendMail('production@scores-decisions.com', 'ylenaour@scores-decisions.com,mricois@scores-decisions.com', 'ERREUR KBIS entre la passerelle et le WebService', $message);
exit;
}
}
}
// Fermeture de la connexion et du pointeur de fichier
ftp_close($conn_id);
kbisLog($siren, $piece, "OUT : Fin normale de la récupération du kbis".EOL);

81
batch/removeTempFile.php Normal file
View File

@ -0,0 +1,81 @@
#!/usr/bin/php
<?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'
);
require_once realpath(dirname(__FILE__)).'/../config/config.php';
$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);
}
}
}

135
batch/setCacheTables.php Normal file
View File

@ -0,0 +1,135 @@
#!/usr/bin/php
<?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'));
// 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(),
)));
function wsLog() {}
require_once realpath(dirname(__FILE__)).'/../config/config.php';
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/scores/classMRegression.php';
$strInfoScript='Usage : '.basename($argv[0]). " <option> [FICHIERS]
Génération du cache des variables courantes si nécessaire.
Options :
-d Mode debug (Verbosité au maximum)
-f Forcer la re-Génération du cache
";
$modeDebug=$modeGeneration=false;
$argv=$_SERVER['argv'];
for ($i=1,$j=0; isset($argv[$i]); $i++) {
if (substr($argv[$i],0,1)=='-') {
switch (substr($argv[$i],1,1)) {
case 'd': $modeDebug=true; break;
case 'f': $modeGeneration=true; break;
case '-':
case '?': die($strInfoScript); break;
default: die('Option '. $argv[$i] . ' inconnue !'.EOL); break;
}
}
}
$iDb=new WDB();
$tdeb=microtime(true);
if (!$modeGeneration &&
file_exists(DOC_WEB_LOCAL.'tables/tables.bin') &&
file_exists(DOC_WEB_LOCAL.'tables/tables.ini') &&
filemtime(DOC_WEB_LOCAL.'tables/tables.bin')>filemtime(DOC_WEB_LOCAL.'tables/tables.ini')) {
if ($modeDebug) echo date('Y/m/d - H:i:s') ." - Lecture du cache...".EOL;
$tabVariables=unserialize(file_get_contents(DOC_WEB_LOCAL.'tables/tables.bin'));
$nb=count($tabVariables);
$duree=round((microtime(true)-$tdeb)*1000,1);
if ($modeDebug) {
$tailleM=round(memory_get_usage(true)/1024,1);
$tailleF=round(filesize(DOC_WEB_LOCAL.'tables/tables.bin')/1024,1);
$strFin=" (bin=$tailleF Ko, mem=$tailleM Ko).";
} else
$strFin='.';
echo date('Y/m/d - H:i:s') ." - Lecture du cache en $duree ms : $nb variables$strFin".EOL;
} else {
// Analyse avec les sections
$ini_array = parse_ini_file(DOC_WEB_LOCAL.'tables/tables.ini', TRUE);
$tabVariables=array();
foreach ($ini_array as $idVar => $tabVar) {
$idVar=strtoupper($idVar); // Nom= de la variable
$source=trim(strtoupper($tabVar['source']));
if ($modeDebug) echo date('Y/m/d - H:i:s') ." - [$idVar] Source='$source'...".EOL;
switch ($source) {
case 'SQL':
if (!isset($tabVar['sql'])) die("ERREUR : Requête SQL non définie pour [$idVar]");
$nbRecords=$iDb->query($tabVar['sql']);
if ($iDb->getLastErrorNum()>0) die("ERREUR : Requête SQL non fonctionnelle pour [$idVar] (".$iDb->getLastError().')');
if ($modeDebug) echo date('Y/m/d - H:i:s') ." - [$idVar] Source='$source' SQL: $nbRecords enregistrements...".EOL;
while ($ret=$iDb->fetch(MYSQL_ASSOC)) {
// Traitement de la zone libelle
if (strtoupper($ret['libelleCase'])=='MAJ')
$libelle=trim(ucfirst(strtolower($ret['libelle'])));
else
$libelle=trim($ret['libelle']);
// Traitement de la zone article
$article=trim($ret['article']);
if ($article=='') {
if (isset($tabVar['articles']) && strtolower($tabVar['articles'])=='auto') {
if (preg_match('/^(a|e|i|o|u|y)/i', $libelle))
$article='d\''.$libelle;
else
$article='de '.$libelle;
} else
$article=$libelle;
} elseif (preg_match('/^(.*)\$/', $article, $matches)) // en $
{ $article=trim(preg_replace('/ +/',' ', $matches[1].' '.$libelle));
$article=strtr($article, array("' "=>"'"));
}
$tabVariables[$idVar][trim($ret['code'])]=array('lib'=>$libelle,
'art'=>$article,
);
}
break;
default: // si <> de blanc, recopie de tableau existant
if ($source=='') die("ERREUR : Source non renseignée pour [$idVar]");
if (!isset($tabVariables[$source])) die("ERREUR : Source '$source' inexistante pour [$idVar]");
$tabVariables[$idVar]=$tabVariables[$source];
break;
}
}
$nb=count($tabVariables);
$duree=round((microtime(true)-$tdeb)*1000,1);
echo date('Y/m/d - H:i:s') ." - Génération du cache en $duree ms : $nb variables.".EOL;
if ($modeDebug) {
$tailleM=round(memory_get_usage(true)/1024,1);
$tailleF=round(filesize(DOC_WEB_LOCAL.'tables/tables.bin')/1024,1);
$strFin=" (bin=$tailleF Ko, mem=$tailleM Ko).";
} else
$strFin='.';
if (file_put_contents(DOC_WEB_LOCAL.'tables/tables.bin',serialize($tabVariables)))
echo date('Y/m/d - H:i:s') ." - Cache des tables associées généré$strFin".EOL;
}
die();
?>

48
batch/setLogsCount.php Normal file
View 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;
}

90
batch/sql2csv.php Normal file
View File

@ -0,0 +1,90 @@
#!/usr/bin/php
<?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;
}
//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 realpath(dirname(__FILE__)).'/../config/config.php';
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";
}

View File

@ -1,50 +0,0 @@
<?php
require_once __DIR__ . '/../application/bin.bootstrap.php';
// --- Options
$displayUsage = false;
try {
$opts = new Zend_Console_Getopt(array(
'help|?' => "Aide.",
'path=s' => "{Service Name}/{version}",
));
$opts->parse();
$optionsNb = count($opts->getOptions());
} catch (Zend_Console_Getopt_Exception $e) {
$displayUsage = true;
}
// --- Aide / Options
if ($optionsNb == 0 || isset($opts->help)) {
$displayUsage = true;
}
// --- Usage
if ($displayUsage) {
echo "\nType Service\n\n";
echo $opts->getUsageMessage();
exit;
}
$wsPath = APPLICATION_PATH . '/../library/WsScore/';
require_once $wsPath . $opts->path . '/Types.php';
$detect = new Zend_Reflection_File($wsPath . $opts->path . '/Types.php');
$result = $detect->getClasses();
$outPath = dirname($wsPath . $opts->path . '/Types.php');
$outFile = $outPath . '/Config.php';
if (count($result) > 0) {
file_put_contents($outFile, "<?php\n");
file_put_contents($outFile, "return array(\n", FILE_APPEND);
foreach ($result as $c) {
file_put_contents($outFile, "\t'". $c->name . "' => '" . $c->name ."',\n", FILE_APPEND);
}
file_put_contents($outFile, ");\n", FILE_APPEND);
}

View File

@ -1,60 +0,0 @@
<?php
require_once __DIR__ . '/../application/bin.bootstrap.php';
error_reporting(E_ALL & ~E_NOTICE);
$typesFichier = array('csv', 'fichiers', 'clients', 'kbis');
// --- Options
$displayUsage = false;
try {
$opts = new Zend_Console_Getopt(array(
'help|?' => 'Displays usage information.',
'all' => 'Execute toutes les actions (cron).',
'type=w' => 'Supprime uniquement les fichiers indiqués.',
));
$opts->parse();
$optionsNb = count($opts->getOptions());
} catch (Zend_Console_Getopt_Exception $e) {
$displayUsage = true;
}
// --- Aide / Options
if ($optionsNb == 0 || isset($opts->help)) {
$displayUsage = true;
}
// --- Usage
if ($displayUsage) {
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);
}
}
}

View File

@ -1,443 +0,0 @@
<?php
require_once __DIR__ . '/../application/bin.bootstrap.php';
// --- Options
$displayUsage = false;
try {
$opts = new Zend_Console_Getopt(array(
'help|?' => "Affiche l'aide.",
'list' => "Liste les actes en attente disponible sur le FTP et affiche les informations",
'get-s' => "Recupère seulement les actes du FTP (un seul document si la référence est spécifier G<NNN> )",
'send-s' => "Récupère les actes et envoi un mail à chaque client (un seul acte si la référence est spécifier G<NNN>)",
'type-s' => "Type de document : bilan, acte",
));
$opts->parse();
$optionsNb = count($opts->getOptions());
} catch (Zend_Console_Getopt_Exception $e) {
$displayUsage = true;
}
// --- Aide / Options
if ($optionsNb == 0 || isset($opts->help)) {
$displayUsage = true;
}
// --- Usage
if ($displayUsage) {
echo "Vérifie les actes numérisés reçus en provenance des Greffes.";
echo "\n\n";
echo $opts->getUsageMessage();
echo "\n";
exit;
}
$testMail = false;
$test = false;
if (isset($opts->list)){
$test = true;
}
$types = array('bi', 'ac');
// Configuration FTP
define ('ACTES_IGNUM_FTP_URL', 'ftp.scores-decisions.com');
define ('ACTES_IGNUM_FTP_USER', 'mpc2500');
define ('ACTES_IGNUM_FTP_PASS', 'passmpc78');
$pathIn = $c->profil->path->shared.'/files';
$report_email = $c->profil->mail->email->support;
$report_subject = 'Traitement des actes '.date('Y-m-d H:i:s');
$report_txt = '';
function sendMail($commande, $type){
$subject = "Actes ou Statuts disponible pour ".$commande->raisonSociale.' ('.$commande->siren.')';
$message = "Bonjour,\n\n";
$message.= "Le document commandé pour ".$commande->raisonSociale." (siren ".$commande->siren.") est disponible en téléchargement sur le site de Scores & Décisions.\r\n\r\n";
if ($commande->refClient!='') {
$message = "Votre référence : ".$commande->refClient."\r\n\r\n";
}
switch ( $type ) {
case 'BI':
$dateBilan = substr($commande->bilanCloture,8,2).'/'.substr($commande->bilanCloture,5,2).'/'.substr($commande->bilanCloture,0,4);
$message.= "Bilan cloturé le ".$dateBilan;
break;
case 'AC':
$dateActe = substr($commande->acteDate,8,2).'/'.substr($commande->acteDate,5,2).'/'.substr($commande->acteDate,0,4);
$dateDepot = substr($commande->depotDate,8,2).'/'.substr($commande->depotDate,5,2).'/'.substr($commande->depotDate,0,4);
$message.= "Acte n°".$commande->acteNum." du ".$dateActe." (Dépot n°".$commande->depotNum." du ".$dateDepot.") ";
break;
}
$message.= "\n\n";
$message.= "Consulter la fiche identité http://extranet.scores-decisions.com/identite/fiche/siret/".$commande->siren.", puis rubrique \"Pieces Officielles\"\n";
$message.= "ou directement depuis la page suivante http://extranet.scores-decisions.com/pieces";
switch ( $type ) {
case 'BI':
$message.= "/bilans/siret/".$commande->siren;
break;
case 'AC':
$message.= "/actes/siret/".$commande->siren;
break;
}
$message.= "\n\n";
$message.= "Bien cordialement, \n";
$message.= "Le service support.\n";
$message.= "\n";
$message.= "--";
$message.= "\n\n";
$message.= "SCORES & DECISIONS";
$message.= "\n";
$message.= "Service support";
$message.= "\n";
$message.= "1, rue de Clairefontaine - 78120 RAMBOUILLET";
$message.= "\n";
$message.= "tél : 0 811 261 216";
$message.= "\n";
$message.= "fax : 33 (0)1 75 43 85 74";
$message.= "\n";
$message.= "support@scores-decisions.com";
$message.= "\n";
$message.= "http://www.scores-decisions.com/";
$message.= "\n";
$message.= "Scores & Décisions est l'acteur nouvelle génération de l'information et de l'évaluation des entreprises";
$message.= "\n\n";
$message.= "Pensez à l'environnement avant d'imprimer ce message !";
$message.= "\n";
$message.= "Save paper - think before you print";
$message.= "\n";
$headers = 'From: support@scores-decisions.com' . "\r\n" .
'Reply-To: support@scores-decisions.com';
if ( mail(strtolower($commande->email), $subject, utf8_decode($message), $headers) ){
echo date ('Y/m/d - H:i:s').' - Un email a été envoyé à '.$commande->email." pour la commande ".$commande->id.".\n";
return true;
} else {
echo date ('Y/m/d - H:i:s').' - ERREUR : Impossible d\'envoyer l\'email à '.$commande->email." pour la commande ".$commande->id.".\n";
return false;
}
}
/**
* Liste des commandes non traités depuis la base de données
*/
$tabCommandes = array();
if (in_array('ac', $types)) {
$sql = "SELECT * FROM sdv1.greffe_commandes_ac WHERE mode=:mode AND dateCommande!=:commande AND dateEnvoi=:envoi";
$stmt = $conn->prepare($sql);
$stmt->bindValue('mode', 'C');
$stmt->bindValue('commande', '0000-00-00 00:00:00');
$stmt->bindValue('envoi', '0000-00-00 00:00:00');
$stmt->execute();
if ($stmt->rowCount() > 0) {
while ($row = $stmt->fetch(\PDO::FETCH_OBJ)) {
$tabCommandes['G-AC-'.$row->id] = $row;
}
}
}
if (in_array('bi', $types)) {
$sql = "SELECT * FROM sdv1.greffe_commandes_bi WHERE mode=:mode AND dateCommande!=:commande AND dateEnvoi=:envoi";
$stmt = $conn->prepare($sql);
$stmt->bindValue('mode', 'C');
$stmt->bindValue('commande', '0000-00-00 00:00:00');
$stmt->bindValue('envoi', '0000-00-00 00:00:00');
$stmt->execute();
if ($stmt->rowCount() > 0) {
while ($row = $stmt->fetch(\PDO::FETCH_OBJ)) {
$tabCommandes['G-BI-'.$row->id] = $row;
}
}
}
$nbCommandes = count($tabCommandes);
echo date('Y/m/d - H:i:s') ." - Il y a $nbCommandes commandes en attente de réception courrier ou numérisation !\n";
/**
* Connexion au site FTP pour la récupération de la liste des fichiers au format pdf
*/
$conn_id = ftp_connect(ACTES_IGNUM_FTP_URL);
if (!$conn_id) {
echo date ('Y/m/d - H:i:s')." - ERREUR : Impossible de se connecter au serveur FTP (".ACTES_IGNUM_FTP_URL.") !\n";
exit;
}
$login_result = ftp_login($conn_id, ACTES_IGNUM_FTP_USER, ACTES_IGNUM_FTP_PASS);
if (!$login_result) {
echo date ('Y/m/d - H:i:s')." - ERREUR : Impossible de s'authentifier sur le serveur FTP (".ACTES_IGNUM_FTP_URL.")!\n";
exit;
}
ftp_pasv($conn_id, true);
$contents = ftp_nlist($conn_id, "*.pdf");
if ($contents === false) {
echo date ('Y/m/d - H:i:s')." - ERREUR : Impossible de se connecter au serveur FTP (".ACTES_IGNUM_FTP_URL.") !\n";
exit;
}
/**
* Liste de tout les fichiers disponible dans le repertoire
* et associe une clé pour faciliter le tri
*/
$tabFichiersFtp = array();
foreach ($contents as $filename){
$indice = 0;
$f = strtolower($filename);
if (preg_match('/g-(ac|bi)-[0-9]+\.pdf/', $f)
|| preg_match('/g-(ac|bi)-[0-9]+-[0-9]{1,2}\.pdf/', $f)) {
$part = substr(str_replace('.pdf', '', $f), 5);
$p = strpos($part, '-');
if ( $p === false ) {
$ref = substr($f, 0, 5) . $part;
$indice = 0;
} else {
$ref = substr($f, 0, 5) . substr($part, 0, $p);
$indice = substr($part, $p+1);
}
$tabFichiersFtp[strtoupper($ref).'-'.$indice] = $filename;
}
// Fichiers en anomalies
else {
if ($test) {
echo "Erreur : Anomalie fichier numérisé $filename\n";
} else {
$subject = "Erreur : Anomalie fichier numérisé";
$message = "Le fichier $filename a été trouvé et ne correspond pas au format attendu";
$headers = 'From: supportdev@scores-decisions.com' . "\r\n" .
'Reply-To: supportdev@scores-decisions.com';
mail('supportdev@scores-decisions.com', $subject, $message, $headers);
}
}
}
/**
* Tri des fichiers par ordre décroissant
* Les noms des fichiers sont incrémenté par 1
*/
krsort($tabFichiersFtp);
/**
* Dans le cas ou il y a eu une erreur de scan, la production passe a nouveau le
* document dans le scanner et le fichier est envoyé sur le ftp
* Le document est nommé G[ref],G[ref]-1,G[ref]-2,.....pdf.
* On garde donc le dernier document scanné.
*/
$lastRef = '';
$tabFichiersTemp = array();
foreach($tabFichiersFtp as $k => $val) {
$part = substr($k, 5);
$p = strpos($part, '-');
if ($p === false) {
$ref = substr($k, 0, 5) . $part;
} else {
$ref = substr($k, 0, 5) . substr($part, 0, $p);
}
if( $lastRef != $ref ) {
$tabFichiersTemp[$ref] = $val;
}
$lastRef = $ref;
}
$tabFichiers = $tabFichiersTemp;
unset($tabFichiersTemp);
/**
* Pour chaque commande, test de la présence d'un fichier associé
* Si le fichier correspond téléchargement du fichier
*/
foreach ($tabCommandes as $ref => $commande) {
foreach ($tabFichiers as $refAssocie => $fichier) {
if ($ref == $refAssocie) {
echo date ('Y/m/d - H:i:s')." - Traitement de la commande $ref\n";
if ($test) {
echo date ('Y/m/d - H:i:s')." - Fichier $fichier \n";
} else {
// Récupération du fichier depuis le FTP (s'il n'existe pas déjà)
if (!file_exists($pathIn.'/'.$fichier)) {
if (ftp_get($conn_id, $pathIn.'/'.$fichier, $fichier, FTP_BINARY, 0)) {
echo date ('Y/m/d - H:i:s')." - Fichier $fichier téléchargé depuis le serveur FTP.\n";
} else {
echo date ('Y/m/d - H:i:s')." - ERREUR : Impossible de télécharger le fichier $fichier !\n";
}
}
switch (substr($ref,2,2)) {
case 'BI':
$infogreffe = new Metier_Infogreffe_DocBI();
$infogreffe->setSiren($commande->siren);
//Format date cloture
$dateCloture = substr($commande->bilanCloture,0,4) . '-' .
substr($commande->bilanCloture,5,2) . '-' .
substr($commande->bilanCloture,8,2);
$path = $infogreffe->getFilePath($commande->bilanType, $dateCloture);
$nomCible = $infogreffe->getFileName($commande->bilanType, $dateCloture);
$fileOut = $c->profil->infogreffe->storage->path.'/'.$path.'/'.$nomCible;
$isFileOnStorage = false;
if (file_exists($fileOut)) {
$isFileOnStorage = true;
echo date ('Y/m/d - H:i:s')." - Fichier ".$pathIn.'/'.$fichier." déjà présent en ".$fileOut.".\n";
} else {
if (copy($pathIn.'/'.$fichier, $fileOut)) {
$isFileOnStorage = true;
echo date ('Y/m/d - H:i:s')." - Fichier ".$pathIn.'/'.$fichier." déplacé en ".$fileOut.".\n";
} else {
echo date ('Y/m/d - H:i:s')." ERREUR - Impossible de déplacer ".$pathIn.'/'.$fichier." en ".$fileOut." !\n";
}
}
// --- Lecture présence référence bilan
if ($commande->bilanType=='sociaux') {
$sql = "SELECT * FROM jo.greffes_bilans WHERE siren=:siren AND date_cloture=:cloture AND type_comptes='' OR type_comptes='sociaux'";
} else {
$sql = "SELECT * FROM jo.greffes_bilans WHERE siren=:siren AND date_cloture=:cloture AND type_comptes='consolides'";
}
$stmt = $conn->prepare($sql);
$stmt->bindValue('siren', $commande->siren);
$stmt->bindValue('cloture', $dateCloture);
$stmt->execute();
$item = $stmt->fetch(\PDO::FETCH_OBJ);
// --- Enregistrement
if ($isFileOnStorage && $item->pdfDate == '0000-00-00') {
$infos = $infogreffe->pdfInfos($fileOut);
if (false !== $infos) {
$data = array(
'pdfLink' => $nomCible,
'pdfSize' => $infos['size'],
'pdfPage' => $infos['pages'],
'pdfVer' => $infos['version'],
'pdfDate' => date('Ymd'),
);
try {
$conn->update('jo.greffes_bilans', $data, array('id' => $item->id));
} catch(\Doctrine\DBAL\DBALException $e) {
echo $e->getMessage();
}
}
}
break;
case 'AC':
$sql = "SELECT id, siren, numRC, LPAD(numGreffe,4,0) AS numGreffe, pdfLink,
pdfSize, pdfPage, pdfDate, num_depot, date_depot, date_acte,
LPAD(num_acte,2,0) AS num_acte, type_acte, type_acte_libelle,
nbpages_acte, decision_nature, decision_libelle FROM jo.greffes_actes
WHERE siren=:siren AND num_depot=:depot AND num_acte=:acte AND type_acte=:type";
$stmt = $conn->prepare($sql);
$stmt->bindValue('siren', $commande->siren);
$stmt->bindValue('depot', $commande->depotNum);
$stmt->bindValue('acte', $commande->acteNum);
$stmt->bindValue('type', $commande->acteType);
$stmt->execute();
$item = $stmt->fetch(\PDO::FETCH_OBJ);
$infogreffe = new Metier_Infogreffe_DocAC();
$infogreffe->setSiren($commande->siren);
$date = $commande->acteDate;
if ($date == '0000-00-00') {
$date = $commande->depotDate;
}
$path = $infogreffe->getFilePath($date);
//(Numéro du Greffe)-(dossier_millesime)-(dossier_statut)-(dossier_chrono)-(num_depot)
$options = $item->numGreffe . '-' . substr($item->numRC,0,2) . '-' . substr($item->numRC,2,1) . '-' . substr($item->numRC,3) . '-' . $item->num_depot;
$nomCible = $infogreffe->getFileName($date, $commande->acteNum, $commande->acteType, $options);
$fileOut = $c->profil->infogreffe->storage->path.'/'.$path.'/'.$nomCible;
$isFileOnStorage = false;
if (file_exists($fileOut)) {
$isFileOnStorage = true;
echo date ('Y/m/d - H:i:s')." - Fichier ".$pathIn.'/'.$fichier." déjà présent en ".$fileOut.".\n";
} else {
if (copy($pathIn.'/'.$fichier, $fileOut)) {
$isFileOnStorage = true;
echo date ('Y/m/d - H:i:s')." - Fichier ".$pathIn.'/'.$fichier." déplacé en ".$fileOut.".\n";
} else {
echo date ('Y/m/d - H:i:s')." ERREUR - Impossible de déplacer ".$pathIn.'/'.$fichier." en ".$fileOut." !\n";
}
}
if ($isFileOnStorage && $item->pdfDate == '0000-00-00') {
$infos = $infogreffe->pdfInfos($fileOut);
if ( false !== $infos ) {
$data = array(
'pdfLink' => $nomCible,
'pdfSize' => $infos['size'],
'pdfPage' => $infos['pages'],
'pdfVer' => $infos['version'],
'pdfDate' => date('Ymd'),
);
try {
$conn->update('jo.greffes_actes', $data, array('id' => $item->id));
echo " = enregistrement.\n";
} catch(\Doctrine\DBAL\DBALException $e) {
echo $e->getMessage();
}
}
}
break;
}
// Envoi du mail et Mise à jour de la commande
if (file_exists($fileOut)) {
if ( $testMail ) {
echo "Envoi fichier $nomCible ($ref) à ".$commande->email;
} else {
$report_txt.= "$ref intégré à l'extranet";
$isMailSent = false;
if (trim($commande->email)!=''){
$isMailSent = sendMail($commande, substr($ref,2,2));
} else {
$isMailSent = true;
}
if ( $isMailSent ) {
$data = array( 'dateEnvoi' => date('YmdHis'));
switch ( substr($ref,2,2) ) {
case 'BI':
$conn->update('sdv1.greffe_commandes_bi', $data, array('id' => $commande->id));
break;
case 'AC':
$conn->update('sdv1.greffe_commandes_ac', $data, array('id' => $commande->id));
break;
}
echo date ('Y/m/d - H:i:s')." - Commande $ref mise à jour\n";
$report_txt.= ' - Email envoyé à '.$commande->email;
} else {
$report_txt.= ' - Email non envoyé !';
echo date ('Y/m/d - H:i:s')." ERREUR - Email non envoyé et commande $ref non mise à jour\n";
}
$report_txt.= "\n";
}
} // Fin envoi mail
}
} // Fin condition ref
}
}
ftp_close($conn_id);
if (empty($report_txt)) {
$report_txt = "Aucun envoi.";
}
//Envoi du mail de rapport
if (!$test && !$testMail){
$headers = 'From: supportdev@scores-decisions.com';
if (mail($report_email, $report_subject, utf8_decode($report_txt))){
echo date ('Y/m/d - H:i:s')." - Rapport envoyé.\n";
} else {
echo date ('Y/m/d - H:i:s')." - Erreur lors de l'envoir du rapport !\n";
}
}
?>

View File

@ -1,378 +0,0 @@
<?php
require_once __DIR__ . '/../application/bin.bootstrap.php';
/**
* User-Agent
* IE 11.0 : Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko
*
*
*
*/
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();
$optionsNb = count($opts->getOptions());
} catch (Zend_Console_Getopt_Exception $e) {
echo $e->getUsageMessage();
exit;
}
// --- Aide / Options
if ($optionsNb == 0 || isset($opts->help)) {
$displayUsage = true;
}
// --- Usage
if ($displayUsage) {
echo "Telecharge le kbis chez infogreffe.";
echo "\n\n";
echo $opts->getUsageMessage();
echo "\n";
exit;
}
if ( isset($opts->debug) ) {
define('DEBUG', true);
} else {
define('DEBUG', false);
}
/*
338 437 189
552 144 503
https://www.infogreffe.fr/societes/
Se connecter
Form
Var client : 0041
Var utilisateur : 2559
Var password : 69873
1 - GET https://www.infogreffe.fr/societes/
2 - POST https://www.infogreffe.fr/sso/identity/authenticate
password 69873
uri realm=abonnes
username 00412559
token.id=AQIC5wM2LY4Sfcy_Nc7YNNc2BtJVjZr-CrTMfnMxDw1iSvw.*AAJTSQACMDIAAlMxAAIwNA..*
3 - GET https://www.infogreffe.fr/societes/
4 - GET https://www.infogreffe.fr/services/entreprise/rest/recherche/parPhrase?nbIdRetournes=100&surveillanceVisible=true&miseAuPanierVisible=true&typeProduitMisEnAvant=EXTRAIT&phrase=338437189
miseAuPanierVisible true
nbIdRetournes 100
phrase 338437189
surveillanceVisible true
typeProduitMisEnAvant EXTRAIT
{"critereRecherchePrincipal":"338437189","critereRecherche":null,"entrepRechInfosComplementaires":null
,"entrepRCSStoreResponse":{"success":true,"identifier":"id","label":"deno","loadedAttr":"numeroDossier"
,"idRecherche":"ENTREP_RCS_ACTIF","nbTotalResultats":1,"items":[{"id":8143039,"numeroDossier":"130586B20094"
,"etablissementChrono":"0000","libelleEntreprise":{"denomination":"PROVENCE PLOMBERIE","denominationEirl"
:null,"enseigne":"PROVENCE PLOMBERIE","nomCommercial":null,"sigle":null},"siren":338437189,"nic":"00016"
,"adresse":{"lignes":["QUARTIER LA MARIANNE "],"codePostal":"13560","bureauDistributeur":"SÉNAS"},"codePaysRegistreEtranger"
:null,"greffe":{"numero":"1305","nom":"TARASCON","codeGroupement":"05","codeEDI":"G1305","nomGreffeMin"
:null},"typeEtab":"SIE","produitAuPanier":"AJOUTABLE","typeInscription":1,"sourceDonnees":"GTC","radie"
:false,"dateRadiation":null,"nbEtablissements":1,"activite":{"codeNAF":"4322A","libelleNAF":"Travaux
d'installation d'eau et de gaz en tous locaux"},"etatSurveillance":"SURVEILLABLE"}],"typeProduitMisEnAvant"
:"EXTRAIT","critereRecherchePrincipal":null,"entrepRechInfosComplementaires":null},"entrepMultiStoreResponse"
:{"success":true,"identifier":"id","label":"deno","loadedAttr":"numeroDossier","idRecherche":null,"nbTotalResultats"
:0,"items":null,"typeProduitMisEnAvant":"EXTRAIT","critereRecherchePrincipal":null,"entrepRechInfosComplementaires"
:null},"entrepRadieeStoreResponse":null,"entrepHorsRCSStoreResponse":{"success":true,"identifier":"id"
,"label":"deno","loadedAttr":"numeroDossier","idRecherche":"ENTREP_HORS_RCS_ACTIFS","nbTotalResultats"
:0,"items":[],"typeProduitMisEnAvant":"EXTRAIT","critereRecherchePrincipal":null,"entrepRechInfosComplementaires"
:null},"reprStoreResponse":{"success":true,"identifier":"id","label":"deno","loadedAttr":"numeroDossier"
,"idRecherche":"REPRESENTANT","nbTotalResultats":0,"items":[],"typeProduitMisEnAvant":"EXTRAIT","critereRecherchePrincipal"
:"338437189","critereRecherche":null,"entrepRechInfosComplementaires":null},"typeProduitMisEnAvant":"EXTRAIT"
}
5 - GET https://www.infogreffe.fr/societes/entreprise-societe/338437189-provence-plomberie-130586B200940000.html?typeProduitOnglet=EXTRAIT&afficherretour=false
afficherretour false
typeProduitOnglet EXTRAIT
<title>PROVENCE PLOMBERIE à SÉNAS (338437189) - Infogreffe</title>
5 - GET https://www.infogreffe.fr/services/produits/rest/catalogue/dossier/130586B20094/0000
{"ordrePresentationParProduit":{"BILAN_SAISI":6,"EXTRAIT":1,"ETAT_ENDETEMENT":2,"DOSSIER_COMPLET":9,"HISTO_MODIFS_RCS"
:7,"CERTIF_PROC_COLLECTIVE":8,"ACTE":5},"cataloguePrix":{"ETAT_ENDETEMENT":{"typeProduit":"ETAT_ENDETEMENT"
,"prixBaseTTC":46.8,"prixFraisEnvoiPostalTTC":1.42,"prixFraisEnvoiElectroniqueTTC":2.34,"prixBaseTTCParTypeInscription"
:3.12,"prixFraisEnvoiPostalTTCParTypeInscription":0.89},"BILAN_SAISI":{"typeProduit":"BILAN_SAISI","prixBaseTTC"
:3.6,"prixFraisEnvoiPostalTTC":0.0,"prixFraisEnvoiElectroniqueTTC":2.34},"STATUT_A_JOUR":{"typeProduit"
:"STATUT_A_JOUR","prixBaseTTC":9.36,"prixFraisEnvoiPostalTTC":2.15,"prixFraisEnvoiElectroniqueTTC":2
.34},"HISTO_MODIFS_RCS":{"typeProduit":"HISTO_MODIFS_RCS","prixBaseTTC":7.8,"prixFraisEnvoiPostalTTC"
:0.0,"prixFraisEnvoiElectroniqueTTC":2.34},"BILAN_COMPLET":{"typeProduit":"BILAN_COMPLET","prixBaseTTC"
:9.36,"prixFraisEnvoiPostalTTC":2.15,"prixFraisEnvoiElectroniqueTTC":2.34},"EXTRAIT":{"typeProduit":"EXTRAIT"
,"prixBaseTTC":3.12,"prixFraisEnvoiPostalTTC":0.89,"prixFraisEnvoiElectroniqueTTC":0.78},"DOSSIER_COMPLET"
:{"typeProduit":"DOSSIER_COMPLET","prixBaseTTC":70.19999999999999,"prixFraisEnvoiPostalTTC":7.499999999999999
,"prixFraisEnvoiElectroniqueTTC":2.34},"ACTE":{"typeProduit":"ACTE","prixBaseTTC":9.36,"prixFraisEnvoiPostalTTC"
:2.15,"prixFraisEnvoiElectroniqueTTC":2.34},"CERTIF_PROC_COLLECTIVE":{"typeProduit":"CERTIF_PROC_COLLECTIVE"
,"prixBaseTTC":1.56,"prixFraisEnvoiPostalTTC":0.89,"prixFraisEnvoiElectroniqueTTC":2.34}},"produits"
:[{"modesDeDiffusionDispos":["V","C","M","T"],"produit":{"typeProduit":"EXTRAIT","modifiable":true,"identifiant"
:{"codeGreffe":"1305","dossierMillesime":"86","dossierStatut":"B","dossierChrono":"20094"},"kbisPeriodique"
:true},"miseAuPanier":null},{"modesDeDiffusionDispos":["V","C"],"produit":{"typeProduit":"ETAT_ENDETEMENT"
,"modifiable":true,"identifiant":{"codeGreffe":"1305","dossierMillesime":"86","dossierStatut":"B","dossierChrono"
:"20094"},"categoriesInscription":[{"code":"C1","libelle":"Catégorie 1","typesInscription":[{"code":"PRIV_SECU"
,"libelle":"Privilège de la sécurité sociale et des régimes complémentaires"},{"code":"PRIV_TRESOR","libelle"
:"Privilège du Trésor Public"},{"code":"PROTET","libelle":"Protêts"},{"code":"PRIV_ANAEM","libelle":"Agence
Nationale de l'Accueil des Etrangers et des Migrations"}]},{"code":"C2","libelle":"Catégorie 2","typesInscription"
:[{"code":"NAN_FOND_COMM","libelle":"Nantissements du fonds de commerce"},{"code":"PRIV_VENDEUR","libelle"
:"Privilèges du vendeur de fonds de commerce et d'action résolutoire"},{"code":"NAN_OUTIL","libelle"
:"Nantissements de l'outillage, matériel et équipement"},{"code":"DECL_CREANCES","libelle":"Déclaration
de créance"}]},{"code":"C3","libelle":"Catégorie 3","typesInscription":[{"code":"OP_CREDIT_BAIL","libelle"
:"Opérations de crédit-bail en matière mobilière"},{"code":"PUB_CONTRAT_LOC","libelle":"Publicité de
contrats de location"},{"code":"PUB_RESEV_PROPR","libelle":"Publicité de clauses de réserve de propri
été"}]},{"code":"C4","libelle":"Catégorie 4","typesInscription":[{"code":"GAGE_STOCKS","libelle":"Gage
des stocks"},{"code":"WARRANTS_CAT","libelle":"Warrants"}]},{"code":"C5","libelle":"Catégorie 5","typesInscription"
:[{"code":"PRETS_DELAIS","libelle":"Prêts et délais"},{"code":"BIENS_INALIENABLES","libelle":"Biens inali
énables"}]}]},"miseAuPanier":null},{"modesDeDiffusionDispos":["V","C","T"],"produit":{"typeProduit":"STATUT_A_JOUR"
,"modifiable":true,"identifiant":{"codeGreffe":"1305","dossierMillesime":"86","dossierStatut":"B","dossierChrono"
:"20094","depotActeNumero":4,"acteChrono":2},"dateActe":1418770800000,"typeActe":{"code":"STAJh","libelle"
:"Statuts mis à jour"},"nbPages":16,"decisions":[],"depot":{"numeroDepot":"4","numeroDepotManu":3459
,"dateDepot":1419980400000}},"miseAuPanier":null},{"modesDeDiffusionDispos":["C"],"produit":{"typeProduit"
:"ACTE","modifiable":true,"identifiant":{"codeGreffe":"1305","dossierMillesime":"86","dossierStatut"
:"B","dossierChrono":"20094","depotActeNumero":1,"acteChrono":1},"dateActe":652485600000,"typeActe":
{"code":"ORDPREh","libelle":"Ordonnance du président"},"nbPages":0,"decisions":[{"natureDecision":{"code"
:"AGPRh","libelle":"Prorogation du délai de réunion de l'A.G. chargée d'approuver les comptes"},"libelle"
:null}],"depot":{"numeroDepot":"1","numeroDepotManu":16,"dateDepot":655686000000}},"miseAuPanier":null
},{"modesDeDiffusionDispos":["V","C","T"],"produit":{"typeProduit":"ACTE","modifiable":true,"identifiant"
:{"codeGreffe":"1305","dossierMillesime":"86","dossierStatut":"B","dossierChrono":"20094","depotActeNumero"
:2,"acteChrono":1},"dateActe":807832800000,"typeActe":{"code":"PVAh","libelle":"Procès-verbal d'assembl
ée"},"nbPages":19,"decisions":[],"depot":{"numeroDepot":"2","numeroDepotManu":814,"dateDepot":812156400000
}},"miseAuPanier":null},{"modesDeDiffusionDispos":["V","C","T"],"produit":{"typeProduit":"ACTE","modifiable"
:true,"identifiant":{"codeGreffe":"1305","dossierMillesime":"86","dossierStatut":"B","dossierChrono"
:"20094","depotActeNumero":2,"acteChrono":2},"dateActe":807832800000,"typeActe":{"code":"STAJh","libelle"
:"Statuts mis à jour"},"nbPages":19,"decisions":[],"depot":{"numeroDepot":"2","numeroDepotManu":814,"dateDepot"
:812156400000}},"miseAuPanier":null},{"modesDeDiffusionDispos":["V","C","T"],"produit":{"typeProduit"
:"ACTE","modifiable":true,"identifiant":{"codeGreffe":"1305","dossierMillesime":"86","dossierStatut"
:"B","dossierChrono":"20094","depotActeNumero":2,"acteChrono":3},"dateActe":807832800000,"typeActe":
{"code":"DIVERSh","libelle":"Divers"},"nbPages":19,"decisions":[{"natureDecision":{"code":"ZDIVh","libelle"
:"Divers"},"libelle":"EXTENSION OBJET SOCIAL & ACTIVITE"}],"depot":{"numeroDepot":"2","numeroDepotManu"
:814,"dateDepot":812156400000}},"miseAuPanier":null},{"modesDeDiffusionDispos":["V","C","T"],"produit"
:{"typeProduit":"ACTE","modifiable":true,"identifiant":{"codeGreffe":"1305","dossierMillesime":"86","dossierStatut"
:"B","dossierChrono":"20094","depotActeNumero":3,"acteChrono":1},"dateActe":1216072800000,"typeActe"
:{"code":"PVAh","libelle":"Procès-verbal d'assemblée"},"nbPages":4,"decisions":[{"natureDecision":{"code"
:"ZDIVh","libelle":"Divers"},"libelle":"MODIFICATION DE L'AFFECTATION DU RESULTAT - EXERCICE CLOS LE
31.12.2007"}],"depot":{"numeroDepot":"3","numeroDepotManu":1373,"dateDepot":1219960800000}},"miseAuPanier"
:null},{"modesDeDiffusionDispos":["V","C","T"],"produit":{"typeProduit":"ACTE","modifiable":true,"identifiant"
:{"codeGreffe":"1305","dossierMillesime":"86","dossierStatut":"B","dossierChrono":"20094","depotActeNumero"
:4,"acteChrono":1},"dateActe":1418770800000,"typeActe":{"code":"PVAGEXh","libelle":"Procès-verbal d'assembl
ée générale extraordinaire"},"nbPages":3,"decisions":[{"natureDecision":{"code":"EXCLOTh","libelle":"Changement
relatif à la date de clôture de l'exercice social"},"libelle":null}],"depot":{"numeroDepot":"4","numeroDepotManu"
:3459,"dateDepot":1419980400000}},"miseAuPanier":null},{"modesDeDiffusionDispos":["V","M","T"],"produit"
:{"typeProduit":"BILAN_SAISI","modifiable":true,"identifiant":{"codeGreffe":"1305","dossierMillesime"
:"86","dossierStatut":"B","dossierChrono":"20094","bilanMillesime":2013,"bilanNumero":1427},"type":"BS"
,"sousCode":"SP","dateClotureExercice":1388444400000,"denominationEIRL":null,"disponibleXbrl":false}
,"miseAuPanier":null},{"modesDeDiffusionDispos":["V","C","T"],"produit":{"typeProduit":"BILAN_COMPLET"
,"modifiable":true,"identifiant":{"codeGreffe":"1305","dossierMillesime":"86","dossierStatut":"B","dossierChrono"
:"20094","bilanMillesime":2013,"bilanNumero":1427},"type":"BS","sousCode":"BL","dateClotureExercice"
:1388444400000,"denominationEIRL":null,"disponibleXbrl":false},"miseAuPanier":null},{"modesDeDiffusionDispos"
:["V","M","T"],"produit":{"typeProduit":"BILAN_SAISI","modifiable":true,"identifiant":{"codeGreffe":"1305"
,"dossierMillesime":"86","dossierStatut":"B","dossierChrono":"20094","bilanMillesime":2012,"bilanNumero"
:2537},"type":"BS","sousCode":"SP","dateClotureExercice":1356908400000,"denominationEIRL":null,"disponibleXbrl"
:false},"miseAuPanier":null},{"modesDeDiffusionDispos":["V","C","T"],"produit":{"typeProduit":"BILAN_COMPLET"
,"modifiable":true,"identifiant":{"codeGreffe":"1305","dossierMillesime":"86","dossierStatut":"B","dossierChrono"
:"20094","bilanMillesime":2012,"bilanNumero":2537},"type":"BS","sousCode":"BL","dateClotureExercice"
:1356908400000,"denominationEIRL":null,"disponibleXbrl":false},"miseAuPanier":null},{"modesDeDiffusionDispos"
:["V","M","T"],"produit":{"typeProduit":"BILAN_SAISI","modifiable":true,"identifiant":{"codeGreffe":"1305"
,"dossierMillesime":"86","dossierStatut":"B","dossierChrono":"20094","bilanMillesime":2011,"bilanNumero"
:1672},"type":"BS","sousCode":"SP","dateClotureExercice":1325286000000,"denominationEIRL":null,"disponibleXbrl"
:false},"miseAuPanier":null},{"modesDeDiffusionDispos":["V","C","T"],"produit":{"typeProduit":"BILAN_COMPLET"
,"modifiable":true,"identifiant":{"codeGreffe":"1305","dossierMillesime":"86","dossierStatut":"B","dossierChrono"
:"20094","bilanMillesime":2011,"bilanNumero":1672},"type":"BS","sousCode":"BL","dateClotureExercice"
:1325286000000,"denominationEIRL":null,"disponibleXbrl":false},"miseAuPanier":null},{"modesDeDiffusionDispos"
:["V","M","T"],"produit":{"typeProduit":"BILAN_SAISI","modifiable":true,"identifiant":{"codeGreffe":"1305"
,"dossierMillesime":"86","dossierStatut":"B","dossierChrono":"20094","bilanMillesime":2010,"bilanNumero"
:2196},"type":"BS","sousCode":"SP","dateClotureExercice":1293750000000,"denominationEIRL":null,"disponibleXbrl"
:false},"miseAuPanier":null},{"modesDeDiffusionDispos":["V","C","T"],"produit":{"typeProduit":"BILAN_COMPLET"
,"modifiable":true,"identifiant":{"codeGreffe":"1305","dossierMillesime":"86","dossierStatut":"B","dossierChrono"
:"20094","bilanMillesime":2010,"bilanNumero":2196},"type":"BS","sousCode":"BL","dateClotureExercice"
:1293750000000,"denominationEIRL":null,"disponibleXbrl":false},"miseAuPanier":null},{"modesDeDiffusionDispos"
:["V","M","T"],"produit":{"typeProduit":"BILAN_SAISI","modifiable":true,"identifiant":{"codeGreffe":"1305"
,"dossierMillesime":"86","dossierStatut":"B","dossierChrono":"20094","bilanMillesime":2009,"bilanNumero"
:969},"type":"BS","sousCode":"SP","dateClotureExercice":1262214000000,"denominationEIRL":null,"disponibleXbrl"
:false},"miseAuPanier":null},{"modesDeDiffusionDispos":["V","C","T"],"produit":{"typeProduit":"BILAN_COMPLET"
,"modifiable":true,"identifiant":{"codeGreffe":"1305","dossierMillesime":"86","dossierStatut":"B","dossierChrono"
:"20094","bilanMillesime":2009,"bilanNumero":969},"type":"BS","sousCode":"BL","dateClotureExercice":1262214000000
,"denominationEIRL":null,"disponibleXbrl":false},"miseAuPanier":null},{"modesDeDiffusionDispos":["V"
,"M","T"],"produit":{"typeProduit":"BILAN_SAISI","modifiable":true,"identifiant":{"codeGreffe":"1305"
,"dossierMillesime":"86","dossierStatut":"B","dossierChrono":"20094","bilanMillesime":2008,"bilanNumero"
:1427},"type":"BS","sousCode":"SP","dateClotureExercice":1230678000000,"denominationEIRL":null,"disponibleXbrl"
:false},"miseAuPanier":null},{"modesDeDiffusionDispos":["V","C","T"],"produit":{"typeProduit":"BILAN_COMPLET"
,"modifiable":true,"identifiant":{"codeGreffe":"1305","dossierMillesime":"86","dossierStatut":"B","dossierChrono"
:"20094","bilanMillesime":2008,"bilanNumero":1427},"type":"BS","sousCode":"BL","dateClotureExercice"
:1230678000000,"denominationEIRL":null,"disponibleXbrl":false},"miseAuPanier":null},{"modesDeDiffusionDispos"
:["V","M","T"],"produit":{"typeProduit":"BILAN_SAISI","modifiable":true,"identifiant":{"codeGreffe":"1305"
,"dossierMillesime":"86","dossierStatut":"B","dossierChrono":"20094","bilanMillesime":2007,"bilanNumero"
:902},"type":"BS","sousCode":"SP","dateClotureExercice":1199055600000,"denominationEIRL":null,"disponibleXbrl"
:false},"miseAuPanier":null},{"modesDeDiffusionDispos":["V","C","T"],"produit":{"typeProduit":"BILAN_COMPLET"
,"modifiable":true,"identifiant":{"codeGreffe":"1305","dossierMillesime":"86","dossierStatut":"B","dossierChrono"
:"20094","bilanMillesime":2007,"bilanNumero":902},"type":"BS","sousCode":"BL","dateClotureExercice":1199055600000
,"denominationEIRL":null,"disponibleXbrl":false},"miseAuPanier":null},{"modesDeDiffusionDispos":["V"
,"M","T"],"produit":{"typeProduit":"BILAN_SAISI","modifiable":true,"identifiant":{"codeGreffe":"1305"
,"dossierMillesime":"86","dossierStatut":"B","dossierChrono":"20094","bilanMillesime":2006,"bilanNumero"
:891},"type":"BS","sousCode":"SP","dateClotureExercice":1167519600000,"denominationEIRL":null,"disponibleXbrl"
:false},"miseAuPanier":null},{"modesDeDiffusionDispos":["V","C","T"],"produit":{"typeProduit":"BILAN_COMPLET"
,"modifiable":true,"identifiant":{"codeGreffe":"1305","dossierMillesime":"86","dossierStatut":"B","dossierChrono"
:"20094","bilanMillesime":2006,"bilanNumero":891},"type":"BS","sousCode":"BL","dateClotureExercice":1167519600000
,"denominationEIRL":null,"disponibleXbrl":false},"miseAuPanier":null},{"modesDeDiffusionDispos":["V"
,"M","T"],"produit":{"typeProduit":"BILAN_SAISI","modifiable":true,"identifiant":{"codeGreffe":"1305"
,"dossierMillesime":"86","dossierStatut":"B","dossierChrono":"20094","bilanMillesime":2005,"bilanNumero"
:769},"type":"BS","sousCode":"SP","dateClotureExercice":1135983600000,"denominationEIRL":null,"disponibleXbrl"
:false},"miseAuPanier":null},{"modesDeDiffusionDispos":["V","C","T"],"produit":{"typeProduit":"BILAN_COMPLET"
,"modifiable":true,"identifiant":{"codeGreffe":"1305","dossierMillesime":"86","dossierStatut":"B","dossierChrono"
:"20094","bilanMillesime":2005,"bilanNumero":769},"type":"BS","sousCode":"BL","dateClotureExercice":1135983600000
,"denominationEIRL":null,"disponibleXbrl":false},"miseAuPanier":null},{"modesDeDiffusionDispos":["V"
,"M","T"],"produit":{"typeProduit":"BILAN_SAISI","modifiable":true,"identifiant":{"codeGreffe":"1305"
,"dossierMillesime":"86","dossierStatut":"B","dossierChrono":"20094","bilanMillesime":2004,"bilanNumero"
:704},"type":"BS","sousCode":"SP","dateClotureExercice":1104447600000,"denominationEIRL":null,"disponibleXbrl"
:false},"miseAuPanier":null},{"modesDeDiffusionDispos":["V","T"],"produit":{"typeProduit":"BILAN_COMPLET"
,"modifiable":true,"identifiant":{"codeGreffe":"1305","dossierMillesime":"86","dossierStatut":"B","dossierChrono"
:"20094","bilanMillesime":2004,"bilanNumero":704},"type":"BS","sousCode":"BL","dateClotureExercice":1104447600000
,"denominationEIRL":null,"disponibleXbrl":false},"miseAuPanier":null},{"modesDeDiffusionDispos":["V"
,"M","T"],"produit":{"typeProduit":"BILAN_SAISI","modifiable":true,"identifiant":{"codeGreffe":"1305"
,"dossierMillesime":"86","dossierStatut":"B","dossierChrono":"20094","bilanMillesime":2003,"bilanNumero"
:850},"type":"BS","sousCode":"SP","dateClotureExercice":1072825200000,"denominationEIRL":null,"disponibleXbrl"
:false},"miseAuPanier":null},{"modesDeDiffusionDispos":["V","T"],"produit":{"typeProduit":"BILAN_COMPLET"
,"modifiable":true,"identifiant":{"codeGreffe":"1305","dossierMillesime":"86","dossierStatut":"B","dossierChrono"
:"20094","bilanMillesime":2003,"bilanNumero":850},"type":"BS","sousCode":"BL","dateClotureExercice":1072825200000
,"denominationEIRL":null,"disponibleXbrl":false},"miseAuPanier":null},{"modesDeDiffusionDispos":["V"
,"M","T"],"produit":{"typeProduit":"BILAN_SAISI","modifiable":true,"identifiant":{"codeGreffe":"1305"
,"dossierMillesime":"86","dossierStatut":"B","dossierChrono":"20094","bilanMillesime":2002,"bilanNumero"
:959},"type":"BS","sousCode":"SP","dateClotureExercice":1041289200000,"denominationEIRL":null,"disponibleXbrl"
:false},"miseAuPanier":null},{"modesDeDiffusionDispos":["V","T"],"produit":{"typeProduit":"BILAN_COMPLET"
,"modifiable":true,"identifiant":{"codeGreffe":"1305","dossierMillesime":"86","dossierStatut":"B","dossierChrono"
:"20094","bilanMillesime":2002,"bilanNumero":959},"type":"BS","sousCode":"BL","dateClotureExercice":1041289200000
,"denominationEIRL":null,"disponibleXbrl":false},"miseAuPanier":null},{"modesDeDiffusionDispos":["V"
,"M","T"],"produit":{"typeProduit":"BILAN_SAISI","modifiable":true,"identifiant":{"codeGreffe":"1305"
,"dossierMillesime":"86","dossierStatut":"B","dossierChrono":"20094","bilanMillesime":2001,"bilanNumero"
:561},"type":"BS","sousCode":"SP","dateClotureExercice":1009753200000,"denominationEIRL":null,"disponibleXbrl"
:false},"miseAuPanier":null},{"modesDeDiffusionDispos":["V","T"],"produit":{"typeProduit":"BILAN_COMPLET"
,"modifiable":true,"identifiant":{"codeGreffe":"1305","dossierMillesime":"86","dossierStatut":"B","dossierChrono"
:"20094","bilanMillesime":2001,"bilanNumero":561},"type":"BS","sousCode":"BL","dateClotureExercice":1009753200000
,"denominationEIRL":null,"disponibleXbrl":false},"miseAuPanier":null},{"modesDeDiffusionDispos":["V"
,"M","T"],"produit":{"typeProduit":"BILAN_SAISI","modifiable":true,"identifiant":{"codeGreffe":"1305"
,"dossierMillesime":"86","dossierStatut":"B","dossierChrono":"20094","bilanMillesime":2000,"bilanNumero"
:644},"type":"BS","sousCode":"SP","dateClotureExercice":978217200000,"denominationEIRL":null,"disponibleXbrl"
:false},"miseAuPanier":null},{"modesDeDiffusionDispos":["V","T"],"produit":{"typeProduit":"BILAN_COMPLET"
,"modifiable":true,"identifiant":{"codeGreffe":"1305","dossierMillesime":"86","dossierStatut":"B","dossierChrono"
:"20094","bilanMillesime":2000,"bilanNumero":644},"type":"BS","sousCode":"BL","dateClotureExercice":978217200000
,"denominationEIRL":null,"disponibleXbrl":false},"miseAuPanier":null},{"modesDeDiffusionDispos":["V"
,"T"],"produit":{"typeProduit":"BILAN_COMPLET","modifiable":true,"identifiant":{"codeGreffe":"1305","dossierMillesime"
:"86","dossierStatut":"B","dossierChrono":"20094","bilanMillesime":1999,"bilanNumero":986},"type":"BS"
,"sousCode":"BL","dateClotureExercice":946594800000,"denominationEIRL":null,"disponibleXbrl":false},"miseAuPanier"
:null},{"modesDeDiffusionDispos":["V","T"],"produit":{"typeProduit":"BILAN_COMPLET","modifiable":true
,"identifiant":{"codeGreffe":"1305","dossierMillesime":"86","dossierStatut":"B","dossierChrono":"20094"
,"bilanMillesime":1998,"bilanNumero":614},"type":"BS","sousCode":"BL","dateClotureExercice":915058800000
,"denominationEIRL":null,"disponibleXbrl":false},"miseAuPanier":null},{"modesDeDiffusionDispos":["V"
,"T"],"produit":{"typeProduit":"HISTO_MODIFS_RCS","modifiable":true,"identifiant":{"codeGreffe":"1305"
,"dossierMillesime":"86","dossierStatut":"B","dossierChrono":"20094"}},"miseAuPanier":null},{"modesDeDiffusionDispos"
:["V","C"],"produit":{"typeProduit":"CERTIF_PROC_COLLECTIVE","modifiable":true,"identifiant":{"codeGreffe"
:"1305","dossierMillesime":"86","dossierStatut":"B","dossierChrono":"20094"}},"miseAuPanier":null},{"modesDeDiffusionDispos"
:["V","C"],"produit":{"typeProduit":"DOSSIER_COMPLET","modifiable":true,"identifiant":{"codeGreffe":"1305"
,"dossierMillesime":"86","dossierStatut":"B","dossierChrono":"20094"},"detailProduits":[{"typeProduit"
:"EXTRAIT","modesDeDiffusionDispos":["V","C","M","T"]},{"typeProduit":"ETAT_ENDETEMENT","modesDeDiffusionDispos"
:["V","C"]},{"typeProduit":"BILAN_COMPLET","modesDeDiffusionDispos":["V","C","T"],"dateClotureExercice"
:1388444400000},{"typeProduit":"STATUT_A_JOUR","modesDeDiffusionDispos":["V","C","T"]},{"typeProduit"
:"CERTIF_PROC_COLLECTIVE","modesDeDiffusionDispos":["V","C"]}]},"miseAuPanier":null}]}
ordrePresentationParProduit.EXTRAIT = 1 (+ cataloguePrix)
6 - POST AJAX https://www.infogreffe.fr/services/produits/rest/panier/extrait
idDossier 130586B20094
modesDeDiffusion V
modesDeDiffusion T
nbExemplaires 0
{"nbDocuments":1,"nbDocumentsParTypeProduit":1,"total":3.9,"totalReduit":3.9,"hasCourrier":false,"cartoucheTotal"
:3.9,"cartoucheReduitTotal":3.9,"produitTotal":3.9,"produitReduitTotal":3.9}
7 - https://www.infogreffe.fr/services/produits/rest/panier
{"panier":{"panierCartouches":[{"prixCartouche":{"totalTtc":3.9},"identite":{"dossier":{"idDossier":
{"codeGreffe":"1305","dossierMillesime":"86","dossierStatut":"B","dossierChrono":"20094"},"nomGreffeImmat"
:"TARASCON","siren":338437189,"denomination":"PROVENCE PLOMBERIE","etatposeSurveillance":null},"debiteur"
:null,"listeEntreprises":null,"affaire":null,"nomGreffeImmat":"TARASCON"},"ordrePresentationParProduit"
:{"EXTRAIT":1},"produits":[{"produit":{"typeProduit":"EXTRAIT","modifiable":true,"identifiant":{"codeGreffe"
:"1305","dossierMillesime":"86","dossierStatut":"B","dossierChrono":"20094"},"kbisPeriodique":true},"miseAuPanier"
:{"prixProduit":{"totalTtc":3.9},"modesDeDiffusionSelectionnes":["V","T"],"nbExemplaires":null,"envoiPeriodique"
:{"periodicite":0,"duree":0},"modifiable":true},"libelleProduit":"Extrait RCS (K bis)"}],"prixTotalActes"
:0.0,"prixTotalDap":0.0}],"prixTotal":{"totalTtc":3.9},"hasCourrier":false}}
8 - https://www.infogreffe.fr/services/produits/rest/panier/resume
{"nbDocuments":1,"nbDocumentsParTypeProduit":0,"total":3.9,"totalReduit":3.9,"hasCourrier":false}
9 - GET https://www.infogreffe.fr/services/achatclient/rest/achat/createCmdAbonne
{"numCommande":"173829445","modeDiffusionCourrier":false}
10 - GET https://www.infogreffe.fr/services/commandeclient/rest/client/recapCommande?numeroCommande=173829445
numeroCommande 173829445
{"commande":{"idCommande":"173829445","date":1433493693000,"totalTTC":3.9,"totalTVA":0.65,"totalHT":null
,"refCommande":"YGWJN","moyenPaiement":"COMPTE_ABONNE","numeroCartePrepayee":null,"cartouches":[{"intitule"
:{"dossier":{"idDossier":{"codeGreffe":"1305","dossierMillesime":"86","dossierStatut":"B","dossierChrono"
:"20094"},"nomGreffeImmat":"TARASCON","siren":338437189,"denomination":"PROVENCE PLOMBERIE","etatposeSurveillance"
:"SURVEILLABLE"},"debiteur":null,"listeEntreprises":null,"affaire":null,"nomGreffeImmat":"TARASCON"}
,"produitsEntreprise":[{"ligneCommande":1,"document":"EXCP","produitTTC":3.9000000000000004,"produitHT"
:0.0,"fraisDePortHT":0.0,"documentsProduit":[{"modeDiffusion":"V","nbExemplaires":1,"urlTelechargement"
:null,"codeSuiviLivraison":null},{"modeDiffusion":"T","nbExemplaires":1,"urlTelechargement":null,"codeSuiviLivraison"
:null}],"inDossierComplet":null,"envoiPeriodique":{"periodicite":0,"duree":0},"refEnvoiPeriodique":null
}]}],"refCommandeClient":null,"refEnvoiPeriodique":null,"denominationSociete":null,"nomClient":"SCORES
ET DECISIONS SAS","abNume":"0041","abAbonne":"2559","email":"CONTACT@SCORES-DECISIONS.COM","solde":null
,"nbDocuments":null,"fraisDePortHT":0.0}}
11 - GET https://www.infogreffe.fr/services/commandeclient/rest/client/recapCommande?numeroCommande=173829445
numeroCommande 173829445
{"commande":{"idCommande":"173829445","date":1433493693000,"totalTTC":3.9,"totalTVA":0.65,"totalHT":null
,"refCommande":"YGWJN","moyenPaiement":"COMPTE_ABONNE","numeroCartePrepayee":null,"cartouches":[{"intitule"
:{"dossier":{"idDossier":{"codeGreffe":"1305","dossierMillesime":"86","dossierStatut":"B","dossierChrono"
:"20094"},"nomGreffeImmat":"TARASCON","siren":338437189,"denomination":"PROVENCE PLOMBERIE","etatposeSurveillance"
:"SURVEILLABLE"},"debiteur":null,"listeEntreprises":null,"affaire":null,"nomGreffeImmat":"TARASCON"}
,"produitsEntreprise":[{"ligneCommande":1,"document":"EXCP","produitTTC":3.9000000000000004,"produitHT"
:0.0,"fraisDePortHT":0.0,"documentsProduit":[{"modeDiffusion":"V","nbExemplaires":1,"urlTelechargement"
:null,"codeSuiviLivraison":null},{"modeDiffusion":"T","nbExemplaires":1,"urlTelechargement":null,"codeSuiviLivraison"
:null}],"inDossierComplet":null,"envoiPeriodique":{"periodicite":0,"duree":0},"refEnvoiPeriodique":null
}]}],"refCommandeClient":null,"refEnvoiPeriodique":null,"denominationSociete":null,"nomClient":"SCORES
ET DECISIONS SAS","abNume":"0041","abAbonne":"2559","email":"CONTACT@SCORES-DECISIONS.COM","solde":null
,"nbDocuments":null,"fraisDePortHT":0.0}}
12 - GET https://www.infogreffe.fr/societes/panier/confirmation?numCommande=173829445&typeClient=AB&etapeCoord=false
etapeCoord false
numCommande 173829445
typeClient AB
=> HTML
Téléchargement du KBIS
<tbody class="commandeDocs">
<a href="javascript:void(0);" class="voirRouge" style="color: red;">Télécharger</a>
https://www.infogreffe.fr/services/commandeclient/rest/client/visupdf?numeroCommande=173829445&ligneCommande=1&visualisation=undefined
13 - GET https://www.infogreffe.fr/services/commandeclient/rest/client/recapCommande?numeroCommande=173829445
=> Voir 10
14 -
*/

View File

@ -1,56 +0,0 @@
<?php
require_once __DIR__ . '/../application/bin.bootstrap.php';
// --- Options
$displayUsage = false;
try {
$opts = new Zend_Console_Getopt(array(
'help|?' => "Displays usage information.",
'sqlfile=s' => "",
'csvfile=s' => "",
));
$opts->parse();
$optionsNb = count($opts->getOptions());
} catch (Zend_Console_Getopt_Exception $e) {
$displayUsage = true;
}
// --- Aide / Options
if (count($opts->getOptions())==0 || isset($opts->help)) {
$displayUsage = true;
}
// --- Usage
if ($displayUsage) {
echo "Génération d'un fichier CSV à partir d'un fichier SQL.\n";
echo $opts->getUsageMessage();
exit;
}
use League\Csv\Writer;
$sql = file_get_contents($opts->sqlfile);
//we fetch the info from a DB using a PDO object
$stmt = $conn->executeQuery($sql);
if ($stmt->rowCount() == 0) {
file_put_contents($opts->csvfile, "");
}
else {
$rows = $stmt->fetchAll(\PDO::FETCH_ASSOC);
// Create the CSV
$csv = Writer::createFromPath($opts->csvfile.'.tmp', 'w');
$csv->setNewline("\r\n");
$csv->setOutputBOM(Writer::BOM_UTF8);
// Insert the CSV header
$csv->insertOne(array_keys($rows[0]));
// Insert all data
$csv->insertAll($rows);
// Set the real name of file
rename($opts->csvfile.'.tmp', $opts->csvfile);
}

View File

@ -1,33 +0,0 @@
{
"name": "scores/webservice",
"description": "Webservice API",
"require": {
"zendframework/zendframework1": "^1.12",
"geshi/geshi": "dev-master",
"league/csv": "^8.1",
"doctrine/dbal": "^2.5",
"mikehaertl/phpwkhtmltopdf": "^2.2",
"guzzlehttp/guzzle": "^6.2",
"monolog/monolog": "^1.22",
"scores/library": "dev-develop"
},
"repositories": [
{
"type": "git",
"url": "git@gitlab.factory.insight.doubletrade.com:scores/library.git"
}
],
"include-path": ["library/"],
"autoload": {
"classmap": [
"application/",
"library/Application/"
]
},
"authors": [
{
"name": "Scores et Decisions",
"email": "supportdev@scores-decisions.com"
}
]
}

View File

@ -1,33 +0,0 @@
{
"name": "scores/webservice",
"description": "Webservice API",
"require": {
"zendframework/zendframework1": "^1.12",
"geshi/geshi": "dev-master",
"league/csv": "^8.1",
"doctrine/dbal": "^2.5",
"mikehaertl/phpwkhtmltopdf": "^2.2",
"guzzlehttp/guzzle": "^6.2",
"monolog/monolog": "^1.22",
"scores/library": "dev-master"
},
"repositories": [
{
"type": "git",
"url": "git@gitlab.factory.insight.doubletrade.com:scores/library.git"
}
],
"include-path": ["library/"],
"autoload": {
"classmap": [
"application/",
"library/Application/"
]
},
"authors": [
{
"name": "Scores et Decisions",
"email": "supportdev@scores-decisions.com"
}
]
}

1151
composer.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,31 @@
db.sdv1.adapter=mysqli
db.sdv1.params.host=192.168.3.30
db.sdv1.params.username=wsuser
db.sdv1.params.password=wspass2012
db.sdv1.params.dbname=sdv1
db.sdv1.params.driver_options.MYSQLI_INIT_COMMAND = "SET NAMES utf8"
db.sdv1.params.persistent = true
db.jo.adapter=mysqli
db.jo.params.host=192.168.3.30
db.jo.params.username=wsuser
db.jo.params.password=wspass2012
db.jo.params.dbname=jo
db.jo.params.driver_options.MYSQLI_INIT_COMMAND = "SET NAMES utf8"
db.jo.params.persistent = true
db.Commandes.adapter=mysqli
db.Commandes.params.host=127.0.0.1
db.Commandes.params.username=wsuser
db.Commandes.params.password=wspass2012
db.Commandes.params.dbname=commandes
db.Commandes.params.driver_options.MYSQLI_INIT_COMMAND = "SET NAMES utf8"
db.Commandes.params.persistent = true
db.Webservice.adapter=mysqli
db.Webservice.params.host=127.0.0.1
db.Webservice.params.username=wsuser
db.Webservice.params.password=wspass2012
db.Webservice.params.dbname=webservice
db.Webservice.params.driver_options.MYSQLI_INIT_COMMAND = "SET NAMES utf8"
db.WebServices.params.persistent = true

View File

@ -0,0 +1,8 @@
<?php
// Base de données de S&D
define('MYSQL_HOST', '192.168.3.30');
define('MYSQL_USER', 'wsuser');
define('MYSQL_PASS', 'wspass2012');
define('MYSQL_DEFAULT_DB', 'jo');
define('MYSQL_SQL_LOG', 'NONE');

View File

@ -0,0 +1,6 @@
<?php
/** SERVEUR DE MESSAGERIE **/
define ('SMTP_HOST', 'smtp.celeste.fr');
define ('SMTP_PORT', 25);
define ('SMTP_USER', '');
define ('SMTP_PASS', '');

View File

@ -0,0 +1,24 @@
<?php
// Entreprise
define('SPHINX_ENT_HOST', '192.168.3.32');
define('SPHINX_ENT_PORT', 9312);
define('SPHINX_ENT_VERSION', 1);
// Dirigeants
define('SPHINX_DIR_HOST', '192.168.3.25');
define('SPHINX_DIR_PORT', 3312);
define('SPHINX_DIR_VERSION', 1);
// Historique
define('SPHINX_HISTO_HOST', '192.168.3.25');
define('SPHINX_HISTO_PORT', 3312);
define('SPHINX_HISTO_VERSION', 1);
// Actionnaire
define('SPHINX_ACT_HOST', '192.168.3.25');
define('SPHINX_ACT_PORT', 3312);
define('SPHINX_ACT_VERSION', 1);
//Old
define('SPHINX_HOST', '192.168.3.25');
define('SPHINX_PORT', 3312);

View File

@ -0,0 +1,23 @@
<?php
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/');
/** Paramètres du FTP de BusinessWire : Communiqués de presse **/
define('BUSINESSWIRE_LOCAL_DIR_INCOMING', '/home/data/ftp/businesswire/');
define('BUSINESSWIRE_LOCAL_DIR', '/home/data/infosreg/businesswire/');
/** Dossiers locaux pour les documents a telecharger (PDF kbis, marques, etc...) **/
define ('DOC_WEB_LOCAL', '/home/vhosts/dataws/');
define ('DOC_WEB_URL', '/data/');
/** LOGGING **/
define('LOG_PATH', '/home/vhosts/dataws/log');

View File

@ -0,0 +1,31 @@
db.sdv1.adapter=mysqli
db.sdv1.params.host=192.168.3.30
db.sdv1.params.username=wsuser
db.sdv1.params.password=wspass2012
db.sdv1.params.dbname=sdv1
db.sdv1.params.driver_options.MYSQLI_INIT_COMMAND = "SET NAMES utf8"
db.sdv1.params.persistent = true
db.jo.adapter=mysqli
db.jo.params.host=192.168.3.30
db.jo.params.username=wsuser
db.jo.params.password=wspass2012
db.jo.params.dbname=jo
db.jo.params.driver_options.MYSQLI_INIT_COMMAND = "SET NAMES utf8"
db.jo.params.persistent = true
db.Commandes.adapter=mysqli
db.Commandes.params.host=127.0.0.1
db.Commandes.params.username=wsuser
db.Commandes.params.password=wspass2012
db.Commandes.params.dbname=commandes
db.Commandes.params.driver_options.MYSQLI_INIT_COMMAND = "SET NAMES utf8"
db.Commandes.params.persistent = true
db.Webservice.adapter=mysqli
db.Webservice.params.host=127.0.0.1
db.Webservice.params.username=wsuser
db.Webservice.params.password=wspass2012
db.Webservice.params.dbname=webservice
db.Webservice.params.driver_options.MYSQLI_INIT_COMMAND = "SET NAMES utf8"
db.WebServices.params.persistent = true

View File

@ -0,0 +1,8 @@
<?php
// Base de données de S&D
define('MYSQL_HOST', '192.168.3.30');
define('MYSQL_USER', 'wsuser');
define('MYSQL_PASS', 'wspass2012');
define('MYSQL_DEFAULT_DB', 'jo');
define('MYSQL_SQL_LOG', 'NONE');

View File

@ -0,0 +1,6 @@
<?php
/** SERVEUR DE MESSAGERIE **/
define ('SMTP_HOST', 'smtp.celeste.fr');
define ('SMTP_PORT', 25);
define ('SMTP_USER', '');
define ('SMTP_PASS', '');

View File

@ -0,0 +1,24 @@
<?php
// Entreprise
define('SPHINX_ENT_HOST', '192.168.3.32');
define('SPHINX_ENT_PORT', 9312);
define('SPHINX_ENT_VERSION', 1);
// Dirigeants
define('SPHINX_DIR_HOST', '192.168.3.25');
define('SPHINX_DIR_PORT', 3312);
define('SPHINX_DIR_VERSION', 1);
// Historique
define('SPHINX_HISTO_HOST', '192.168.3.25');
define('SPHINX_HISTO_PORT', 3312);
define('SPHINX_HISTO_VERSION', 1);
// Actionnaire
define('SPHINX_ACT_HOST', '192.168.3.25');
define('SPHINX_ACT_PORT', 3312);
define('SPHINX_ACT_VERSION', 1);
//Old
define('SPHINX_HOST', '192.168.3.25');
define('SPHINX_PORT', 3312);

View File

@ -0,0 +1,23 @@
<?php
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/');
/** Paramètres du FTP de BusinessWire : Communiqués de presse **/
define('BUSINESSWIRE_LOCAL_DIR_INCOMING', '/home/data/ftp/businesswire/');
define('BUSINESSWIRE_LOCAL_DIR', '/home/data/infosreg/businesswire/');
/** Dossiers locaux pour les documents a telecharger (PDF kbis, marques, etc...) **/
define ('DOC_WEB_LOCAL', '/home/vhosts/data/');
define ('DOC_WEB_URL', '/data/');
/** LOGGING **/
define('LOG_PATH', '/home/vhosts/data/log');

View File

@ -0,0 +1,18 @@
--
-- Structure de la table `clientsTarif`
--
CREATE TABLE IF NOT EXISTS `clientsTarif` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`idClient` int(11) NOT NULL,
`service` char(20) NOT NULL,
`login` char(20) NOT NULL,
`log` char(20) NOT NULL COMMENT 'Element à facturer',
`type` enum('Unitaire','ForfaitLimit','ForfaitIllimit') 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';

14
config/_sql/logsCount.sql Normal file
View 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
config/config.php Normal file
View File

@ -0,0 +1,6 @@
<?php
require_once realpath(dirname(__FILE__)).'/partenaires.php';
require_once realpath(dirname(__FILE__)).'/mysql.php';
require_once realpath(dirname(__FILE__)).'/stockage.php';
require_once realpath(dirname(__FILE__)).'/smtp.php';
require_once realpath(dirname(__FILE__)).'/sphinx.php';

117
config/configure.php Normal file
View File

@ -0,0 +1,117 @@
#!/usr/bin/php
<?php
// Paramètres
if ( $argc < 1 || in_array($argv[1], array('--help', '-help', '-h', '-?')) ) {
?>
Installation
Avec les options --help, -help, -h, et -?, vous obtiendrez cette aide.
Utilisation : <?php echo $argv[0]; ?> [action]
action :
--install : Configuration
<?php
exit;
}
$action = $argv[1];
$hostname = exec('echo $(hostname)');
$wwwroot = realpath(dirname(__FILE__).'/../../');
switch ($action)
{
case '--install':
writeConfig();
check();
copyFiles();
changePermission();
break;
}
/**
* Vérfie si l'utilisateur est ROOT
*/
function isRoot()
{
$uid = exec('echo $(id -u)');
if ((int) $uid == 0){
return true;
} else {
return false;
}
}
function changePermission()
{
passthru('chown -R www-data: '.realpath(dirname(__FILE__).'/../'));
passthru('chmod -R +x '.realpath(dirname(__FILE__).'/../batch/').'/*.php');
}
function copyFiles()
{
passthru('cp -Rv '.realpath(dirname(__FILE__)).'/_files/kbis/styles '.
realpath(dirname(__FILE__)).'/../public/data/kbis/');
}
function check()
{
//Vérifier le lien symbolique de data dans public
if ( !is_link(realpath(dirname(__FILE__)).'/../public/data') ) {
echo "Erreur lien symbolique 'data'\n"; exit;
}
//Répertoire dans data
$directories = array(
'bodacc',
'csv',
'fichiers',
'kbis',
'log',
'marques',
'pdf',
'tables',
'wkhtml');
foreach ( $directories as $dir ) {
if ( !file_exists(realpath(dirname(__FILE__)).'/../public/data/'.$dir) ) {
echo "Erreur dossier ".$dir."\n";
}
}
//Répertoire temporaire
if ( !file_exists(realpath(dirname(__FILE__)).'/../cache') ) {
mkdir(realpath(dirname(__FILE__)).'/../cache');
}
if ( !file_exists(realpath(dirname(__FILE__)).'/../cache/sessions') ) {
mkdir(realpath(dirname(__FILE__)).'/../cache/sessions');
}
}
function writeConfig()
{
global $hostname;
$arrayConfig = array(
'mysql.php',
'smtp.php',
'sphinx.php',
'stockage.php',
);
foreach($arrayConfig as $config) {
passthru('cp -v '.
realpath(dirname(__FILE__)).'/'.$hostname.'/'.$config.' ' .
realpath(dirname(__FILE__)).'/'.$config);
}
passthru('cp -v '.realpath(dirname(__FILE__)).'/'.$hostname.'/databases.ini '.
realpath(dirname(__FILE__).'/../application/configs').'/');
require_once realpath(dirname(__FILE__)).'/config.php';
if ( !file_exists(realpath(dirname(__FILE__)).'/../public/data/') )
passthru('ln -s '.DOC_WEB_LOCAL.' '.realpath(dirname(__FILE__)).'/../public/data');
}

View File

@ -0,0 +1,31 @@
db.sdv1.adapter=mysqli
db.sdv1.params.host=192.168.78.230
db.sdv1.params.username=wsuser
db.sdv1.params.password=scores
db.sdv1.params.dbname=sdv1
db.sdv1.params.driver_options.MYSQLI_INIT_COMMAND = "SET NAMES utf8"
db.sdv1.params.persistent = true
db.jo.adapter=mysqli
db.jo.params.host=192.168.78.230
db.jo.params.username=wsuser
db.jo.params.password=scores
db.jo.params.dbname=jo
db.jo.params.driver_options.MYSQLI_INIT_COMMAND = "SET NAMES utf8"
db.jo.params.persistent = true
db.Commandes.adapter=mysqli
db.Commandes.params.host=127.0.0.1
db.Commandes.params.username=wsuser
db.Commandes.params.password=wspass2012
db.Commandes.params.dbname=commandes
db.Commandes.params.driver_options.MYSQLI_INIT_COMMAND = "SET NAMES utf8"
db.Commandes.params.persistent = true
db.Webservice.adapter=mysqli
db.Webservice.params.host=127.0.0.1
db.Webservice.params.username=wsuser
db.Webservice.params.password=wspass2012
db.Webservice.params.dbname=webservice
db.Webservice.params.driver_options.MYSQLI_INIT_COMMAND = "SET NAMES utf8"
db.WebServices.params.persistent = true

8
config/local/mysql.php Normal file
View File

@ -0,0 +1,8 @@
<?php
// Base de données de S&D
define('MYSQL_HOST', '192.168.78.230');
define('MYSQL_USER', 'wsuser');
define('MYSQL_PASS', 'scores');
define('MYSQL_DEFAULT_DB', 'jo');
define('MYSQL_SQL_LOG', 'NONE');

6
config/local/smtp.php Normal file
View File

@ -0,0 +1,6 @@
<?php
/** SERVEUR DE MESSAGERIE **/
define('SMTP_HOST', 'smtp.free.fr');
define('SMTP_PORT', 25);
define('SMTP_USER', '');
define('SMTP_PASS', '');

24
config/local/sphinx.php Normal file
View File

@ -0,0 +1,24 @@
<?php
// Entreprise
define('SPHINX_ENT_HOST', '192.168.78.252');
define('SPHINX_ENT_PORT', 3312);
define('SPHINX_ENT_VERSION', 2);
// Dirigeants
define('SPHINX_DIR_HOST', '192.168.78.252');
define('SPHINX_DIR_PORT', 3312);
define('SPHINX_DIR_VERSION', 2);
// Historique
define('SPHINX_HISTO_HOST', '192.168.78.252');
define('SPHINX_HISTO_PORT', 3312);
define('SPHINX_DIR_VERSION', 2);
// Actionnaire
define('SPHINX_ACT_HOST', '192.168.78.252');
define('SPHINX_ACT_PORT', 3312);
define('SPHINX_DIR_VERSION', 2);
//Old
define('SPHINX_HOST', '192.168.78.252');
define('SPHINX_PORT', 3312);

23
config/local/stockage.php Normal file
View File

@ -0,0 +1,23 @@
<?php
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/');
/** Paramètres du FTP de BusinessWire : Communiqués de presse **/
define('BUSINESSWIRE_LOCAL_DIR_INCOMING', '/home/data/ftp/businesswire/');
define('BUSINESSWIRE_LOCAL_DIR', '/home/data/infosreg/businesswire/');
/** Dossiers locaux pour les documents a telecharger (PDF kbis, marques, etc...) **/
define('DOC_WEB_LOCAL', realpath('d:/www/dataws/').'/');
define('DOC_WEB_URL', '/data/');
/** LOGGING **/
define('LOG_PATH', realpath('d:/www/dataws/log/'));

43
config/partenaires.php Normal file
View File

@ -0,0 +1,43 @@
<?php
/** BATCH **/
define('FILLER',' ');
define('VERSION_FICHIER_BODACC','0106');
define('LONGUEUR_LIGNE_SORTIE', 2000);
/** Paramètres du FTP des JO **/
define('BODACC_FTP_URL', 'ftp.journal-officiel.gouv.fr');
define('BODACC_FTP_USER', 'SCORE');
define('BODACC_FTP_PASS', 'SD075');
/** Paramètres du FTP de Hugin : Communiqués de presse **/
define('HUGIN_FTP_URL', 'ftp.companynews.fr');
define('HUGIN_FTP_USER', 'scores');
define('HUGIN_FTP_PASS', 'scores_632');
/** Paramètres du FTP de ActusNews : Communiqués de presse **/
define('ACTUSNEWS_FTP_URL', 'ftp.actusnews.com');
define('ACTUSNEWS_FTP_USER', 'scores_act');
define('ACTUSNEWS_FTP_PASS', '6_etIwL');
/** Paramètres du FTP de Di Release : Communiqués de presse **/
define('DIRELEASE_FTP_URL', 'ftp.actusnews.com');
define('DIRELEASE_FTP_USER', 'scores_dir');
define('DIRELEASE_FTP_PASS', '-gT52sQ');
/** Paramètres du FTP des Echos: Communiqués de presse **/
define('LESECHOS_FTP_URL', 'ftp.webdisclosure.com');
define('LESECHOS_FTP_USER', 'Scores');
define('LESECHOS_FTP_PASS', 'scores2001');
/** INFOGREFFE **/
define('INFOGREFFE_DISPO', true);
define('INFOGREFFE_DISPO_WS', true);
define('INFOGREFFE_DISPO_WEB', true);
define('INFOGREFFE_WS_URL', 'https://webservices.infogreffe.fr/WSContextInfogreffe/INFOGREFFE');
define('INFOGREFFE_WS_URI', 'https://webservices.infogreffe.fr/');
define('INFOGREFFE_WS_USER', '85000109');
define('INFOGREFFE_WS_PASS', '166');
/** AMABIS **/
define('AMABIS_WS_URL', 'http://sw4.amabis.com:5101');
define('AMABIS_WS_URI', 'http://sw4.amabis.com:5101');

View File

@ -0,0 +1,31 @@
db.sdv1.adapter=mysqli
db.sdv1.params.host=192.168.78.230
db.sdv1.params.username=wsuser
db.sdv1.params.password=scores
db.sdv1.params.dbname=sdv1
db.sdv1.params.driver_options.MYSQLI_INIT_COMMAND = "SET NAMES utf8"
db.sdv1.params.persistent = true
db.jo.adapter=mysqli
db.jo.params.host=192.168.78.230
db.jo.params.username=wsuser
db.jo.params.password=scores
db.jo.params.dbname=jo
db.jo.params.driver_options.MYSQLI_INIT_COMMAND = "SET NAMES utf8"
db.jo.params.persistent = true
db.Commandes.adapter=mysqli
db.Commandes.params.host=127.0.0.1
db.Commandes.params.username=wsuser
db.Commandes.params.password=wspass2012
db.Commandes.params.dbname=commandes
db.Commandes.params.driver_options.MYSQLI_INIT_COMMAND = "SET NAMES utf8"
db.Commandes.params.persistent = true
db.Webservice.adapter=mysqli
db.Webservice.params.host=127.0.0.1
db.Webservice.params.username=wsuser
db.Webservice.params.password=wspass2012
db.Webservice.params.dbname=webservice
db.Webservice.params.driver_options.MYSQLI_INIT_COMMAND = "SET NAMES utf8"
db.WebServices.params.persistent = true

View File

@ -0,0 +1,8 @@
<?php
// Base de données de S&D
define('MYSQL_HOST', '192.168.78.230');
define('MYSQL_USER', 'wsuser');
define('MYSQL_PASS', 'scores');
define('MYSQL_DEFAULT_DB', 'jo');
define('MYSQL_SQL_LOG', 'NONE');

View File

@ -0,0 +1,6 @@
<?php
/** SERVEUR DE MESSAGERIE **/
define('SMTP_HOST', 'smtp.free.fr');
define('SMTP_PORT', 25);
define('SMTP_USER', '');
define('SMTP_PASS', '');

View File

@ -0,0 +1,24 @@
<?php
// Entreprise
define('SPHINX_ENT_HOST', '192.168.78.252');
define('SPHINX_ENT_PORT', 3312);
define('SPHINX_ENT_VERSION', 2);
// Dirigeants
define('SPHINX_DIR_HOST', '192.168.78.252');
define('SPHINX_DIR_PORT', 3312);
define('SPHINX_DIR_VERSION', 2);
// Historique
define('SPHINX_HISTO_HOST', '192.168.78.252');
define('SPHINX_HISTO_PORT', 3312);
define('SPHINX_HISTO_VERSION', 2);
// Actionnaire
define('SPHINX_ACT_HOST', '192.168.78.252');
define('SPHINX_ACT_PORT', 3312);
define('SPHINX_ACT_VERSION', 2);
//Old
define('SPHINX_HOST', '192.168.78.252');
define('SPHINX_PORT', 3312);

View File

@ -0,0 +1,23 @@
<?php
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/');
/** Paramètres du FTP de BusinessWire : Communiqués de presse **/
define('BUSINESSWIRE_LOCAL_DIR_INCOMING', '/home/data/ftp/businesswire/');
define('BUSINESSWIRE_LOCAL_DIR', '/home/data/infosreg/businesswire/');
/** Dossiers locaux pour les documents a telecharger (PDF kbis, marques, etc...) **/
define('DOC_WEB_LOCAL', '/sites/dataws/');
define('DOC_WEB_URL', '/data/');
/** LOGGING **/
define('LOG_PATH', '/sites/dataws/log/');

Some files were not shown because too many files have changed in this diff Show More