2.4 rev 1821

This commit is contained in:
Michael RICOIS 2013-11-05 11:18:30 +00:00
parent 0a68210584
commit 5a72bd68cb
3639 changed files with 1027020 additions and 0 deletions

187
application/Bootstrap.php Normal file
View File

@ -0,0 +1,187 @@
<?php
class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
protected function _initConfig()
{
$config = new Zend_Config($this->getOptions());
Zend_Registry::set('config', $config);
//Load old config
require_once 'WsScore/Configure.php';
$oldconfig = new Configure();
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()
->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');
}
//Initialisation global des paramètres de log
protected function _initLogging()
{
$c = Zend_Registry::get('config');
$WsLogger = new Zend_Log();
$WsFileWriter = new Zend_Log_Writer_Stream($c->profil->path->log.'/wsentreprise.log');
$WsFileWriter->addFilter(Zend_Log::INFO);
$WsLogger->addWriter($WsFileWriter);
Zend_Registry::set('WsLogger', $WsLogger);
}
protected function _initNavigation()
{
$view = $this->bootstrap('layout')->getResource('layout')->getView();
//@todo : gérer les versions et les clients
$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();
//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);
$route = new Zend_Controller_Router_Route('jsonrpc/'.$section.'/:version', array(
'controller' => 'jsonrpc',
'action' => 'index',
'service' => $section,
'version' => '',
));
$router->addRoute('jsonrpc-'.$section, $route);
}
}
//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);
$fichierRoute = new Zend_Controller_Router_Route('fichier/:action/:fichier', array(
'controller' => 'fichier',
'fichier' => '',
));
$router->addRoute('fichier', $fichierRoute);
return $router;
}
protected function _initDb()
{
$c = Zend_Registry::get('config');
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;
}
/**
* 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');
$options = array(
'plugins' => array(
'Exception',
),
);
$debug = new WsDebug_Controller_Plugin_Debug($options);
$this->bootstrap('frontController');
$frontController = $this->getResource('frontController');
$frontController->registerPlugin($debug);
}
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);
}
}
}

View File

@ -0,0 +1,20 @@
[production]
webservice.scores.wsdl = ""
webservice.scores.options.location = "http://192.168.3.2/ws2/"
webservice.scores.options.uri = "http://192.168.3.2/"
webservice.scores.options.trace = 1
webservice.scores.options.soap_version = SOAP_1_1
[staging]
webservice.scores.wsdl = ""
webservice.scores.options.location = "http://78.31.45.206/ws2/"
webservice.scores.options.uri = "http://78.31.45.206/"
webservice.scores.options.trace = 1
webservice.scores.options.soap_version = SOAP_1_1
[development]
webservice.scores.wsdl = ""
webservice.scores.options.location = "http://78.31.45.206/ws2/"
webservice.scores.options.uri = "http://78.31.45.206/"
webservice.scores.options.trace = 1
webservice.scores.options.soap_version = SOAP_1_1

View File

@ -0,0 +1,105 @@
<?php
class DemoController extends Zend_Controller_Action
{
protected $_username;
protected $_hash;
protected $methods = array(
'getIdentite' => array(
'ws' => 'entreprise/v0.7?wsdl',
'form' => 'getIdentite',
),
);
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()
{
//Liste
$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 = '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 !");
}
}
}
public function requeteAction()
{
if ($this->_request->isPost()) {
$formData = $this->_request->getPost();
$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

@ -0,0 +1,197 @@
<?php
class DocumentationController extends Zend_Controller_Action
{
/**
* Affichage de la documentation des webservices
*/
public function indexAction()
{
$request = $this->getRequest();
$ws = strtolower($request->getParam('ws','Entreprise'));
$auth = Zend_Auth::getInstance();
//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
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 = strtolower($request->getParam('nom'));
$ws = 'entreprise';
// Gestion des versions
$clients = include APPLICATION_PATH . '/../library/WsScore/Clients/ClientsConfig.php';
$configServiceVersions = $clients[$client]['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/Clients/'.ucfirst($client).'/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.= '/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(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()
{
}
/**
* Affichage exemple de code avec coloration syntaxique
* Le code doit être placé dans public/code et doit être nommé
* [nom de la méthode]-langage.txt
*/
public function codeAction()
{
$langage = strtolower($this->_getParam('langage',''));
$element = $this->_getParam('element','');
$fichier = APPLICATION_PATH .
'/../public/code/' . $element . '-' . $langage . '.txt';
if (file_exists($fichier)){
$sourceCode = file_get_contents($fichier);
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.');
}
}
/**
* Affichage de la liste des erreurs avec leur code
*/
public function erreurAction()
{
require_once 'WsScore/WsScore.php';
$ws = new WsScore();
$erreurs = $ws->listError;
$this->view->assign('erreurs', $erreurs);
}
}

View File

@ -0,0 +1,47 @@
<?php
class ErrorController extends Zend_Controller_Action
{
public function errorAction()
{
$errors = $this->_getParam('error_handler');
switch ($errors->type) {
case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ROUTE:
case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_CONTROLLER:
case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ACTION:
// 404 error -- controller or action not found
$this->getResponse()->setHttpResponseCode(404);
$this->view->message = 'Page not found';
break;
default:
// application error
$this->getResponse()->setHttpResponseCode(500);
$this->view->message = 'Application error';
break;
}
// Log exception, if logger available
if ($log = $this->getLog()) {
$log->crit($this->view->message, $errors->exception);
}
// conditionally display exceptions
if ($this->getInvokeArg('displayExceptions') == true) {
$this->view->exception = $errors->exception;
}
$this->view->request = $errors->request;
}
public function getLog()
{
$bootstrap = $this->getInvokeArg('bootstrap');
if (!$bootstrap->hasPluginResource('Log')) {
return false;
}
$log = $bootstrap->getResource('Log');
return $log;
}
}

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

@ -0,0 +1,139 @@
<?php
class FichierController extends Zend_Controller_Action
{
public function init()
{
$this->_helper->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
}
public function bodaccAction()
{
$auth = Zend_Auth::getInstance();
if ( $auth->hasIdentity() ) {
$directory = '/mnt/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 {
echo "Authentification échoué.";
}
}
public function logsAction()
{
$file = $this->getRequest()->getParam('fichier');
$content_type = 'application/csv-tab-delimited-table';
$c = Zend_Registry::get('config');
$path = realpath($c->profil->path->files).'/';
//Envoi du fichier sur la sortie standard
if ( file_exists($path.$file) ) {
header('Content-Transfer-Encoding: none');
header('Content-type: ' . $content_type.'');
header('Content-Length: ' . filesize($path.$file));
header('Content-MD5: ' . base64_encode(md5_file($path.$file)));
header('Content-Disposition: filename="' . basename($path.$file) . '"');
header('Cache-Control: private, max-age=0, must-revalidate');
header('Pragma: public');
ini_set('zlib.output_compression', '0');
echo file_get_contents($path.$file);
}
}
public function csvAction()
{
$file = $this->getRequest()->getParam('fichier');
$content_type = 'application/csv-tab-delimited-table';
$c = Zend_Registry::get('config');
$path = realpath($c->profil->path->files).'/';
//Envoi du fichier sur la sortie standard
if ( file_exists($path.$file) ) {
header('Content-Transfer-Encoding: none');
header('Content-type: ' . $content_type.'');
header('Content-Length: ' . filesize($path.$file));
header('Content-MD5: ' . base64_encode(md5_file($path.$file)));
header('Content-Disposition: filename="' . basename($path.$file) . '"');
header('Cache-Control: private, max-age=0, must-revalidate');
header('Pragma: public');
ini_set('zlib.output_compression', '0');
echo file_get_contents($path.$file);
}
}
public function kbisAction()
{
$file = $this->getRequest()->getParam('fichier');
$content_type = 'application/pdf';
$c = Zend_Registry::get('config');
$path = realpath($c->profil->path->secure).'/kbis/';
//Envoi du fichier sur la sortie standard
if ( file_exists($path.$file) ) {
header('Content-Transfer-Encoding: none');
header('Content-type: ' . $content_type.'');
header('Content-Length: ' . filesize($path.$file));
header('Content-MD5: ' . base64_encode(md5_file($path.$file)));
header('Content-Disposition: filename="' . basename($path.$file) . '"');
header('Cache-Control: private, max-age=0, must-revalidate');
header('Pragma: public');
ini_set('zlib.output_compression', '0');
echo file_get_contents($path.$file);
}
}
public function associationsAction()
{
$file = $this->getRequest()->getParam('fichier');
$content_type = 'application/pdf';
$c = Zend_Registry::get('config');
$path = realpath($c->profil->path->files).'/associations/';
//Envoi du fichier sur la sortie standard
if ( file_exists($path.$file) ) {
header('Content-Transfer-Encoding: none');
header('Content-type: ' . $content_type.'');
header('Content-Length: ' . filesize($path.$file));
header('Content-MD5: ' . base64_encode(md5_file($path.$file)));
header('Content-Disposition: filename="' . basename($path.$file) . '"');
header('Cache-Control: private, max-age=0, must-revalidate');
header('Pragma: public');
ini_set('zlib.output_compression', '0');
echo file_get_contents($path.$file);
}
}
}

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

@ -0,0 +1,90 @@
<?php
class IndexController extends Zend_Controller_Action
{
protected $serviceList = array();
protected $serviceClientList = array();
public function init()
{
$auth = Zend_Auth::getInstance();
if ( $auth->hasIdentity() ) {
//Lecture des webservices normaux
$services = include APPLICATION_PATH . '/../library/WsScore/ServicesConfig.php';
foreach( $services 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)
{
$serviceVersions = array();
$configServiceVersions = $wsServices[$serviceName]['versions'];
foreach( $configServiceVersions as $section => $params )
{
$serviceVersions[$section] = $params;
$this->serviceList[$serviceName]['version'] = $serviceVersions;
}
}
}
//Lecture des webservices Clients
$clients = include APPLICATION_PATH . '/../library/WsScore/Clients/ClientsConfig.php';
foreach( $clients 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']) )
{
$serviceVersions = array();
$configServiceVersions = $wsClients[$serviceName]['versions'];
foreach( $configServiceVersions 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 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

@ -0,0 +1,108 @@
<?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();
}
}
}

View File

@ -0,0 +1,119 @@
<?php
class RefController extends Zend_Controller_Action
{
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();
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('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 !');
}
}
/**
* 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
$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;
}
$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 !');
}
}
}

View File

@ -0,0 +1,173 @@
<?php
require_once 'framework/fwk.php';
class ServiceController extends Zend_Controller_Action
{
public function indexAction()
{
$this->_helper->layout->disableLayout();
$this->_helper->viewRenderer->setNoRender();
$request = $this->getRequest();
//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);
//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'];
}
else
{
//Service versions
$services = include APPLICATION_PATH . '/../library/WsScore/ServicesConfig.php';
$configServiceVersions = $services[$serviceName]['versions'];
}
// 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);
// 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 ('clients' == $serviceName) {
$pathServiceClassIni = 'WsScore/Clients/'.$clientClassName.'/v'.$version.'/Config.php';
$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.'/Config.php';
$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';
}
//Get map of WSDL type to PHP Classes
$classmap = include $pathServiceClassIni;
//Inclusion des classes de données
require_once $pathServiceClassPhp;
// Fourniture du wsdl
if ( isset($_GET['wsdl']) && file_exists($fichierWsdl) ) {
if (!headers_sent()) {
header('Content-Type: text/xml');
}
echo file_get_contents($fichierWsdl);
} elseif ( isset($_GET['wsdl']) && !file_exists($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);
// 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é";
//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);
// 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 (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

@ -0,0 +1,67 @@
<?php
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 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_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;
//Ecrit un cookie persistant valide pendant le temps definit
Zend_Session::rememberMe($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);
}
$this->_redirect('/');
}
}
}
}
public function logoutAction()
{
Zend_Auth::getInstance()->clearIdentity();
}
}

View File

@ -0,0 +1,16 @@
<?php
class Application_Model_AssoActes extends Zend_Db_Table_Abstract
{
protected $_name = 'asso_actes';
protected $_schema = 'jo';
public function insert(array $data)
{
// Ajout d'un timestamp
if (empty($data['dateInsert'])) {
$data['dateInsert'] = date('Y-m-d H:i:s');
}
return parent::insert($data);
}
}

View File

@ -0,0 +1,6 @@
<?php
class Application_Model_BopiMarques extends Zend_Db_Table_Abstract
{
protected $_name = 'marques';
protected $_schema = 'bopi';
}

View File

@ -0,0 +1,21 @@
<?php
class Application_Model_Commandes extends Zend_Db_Table_Abstract
{
protected $_name = 'commandes';
protected $_dependentTables = array(
'Application_Model_CommandesEven',
'Application_Model_CommandesPieces',
);
public function insert(array $data)
{
// Ajout d'un timestamp
if (empty($data['date_added'])) {
$data['date_added'] = date('Y-m-d H:i:s');
}
return parent::insert($data);
}
}

View File

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

View File

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

View File

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

View File

@ -0,0 +1,21 @@
<?php
class Application_Model_CommandesEven extends Zend_Db_Table_Abstract
{
protected $_name = 'commandes_even';
protected $_referenceMap = array(
'CommandesEven' => array(
'columns' => array('commande_id'),
'refTableClass' => 'Application_Model_Commandes',
'refColumns' => array('id'),
),
);
public function insert(array $data)
{
if (empty($data['date_added'])) {
$data['date_added'] = date('Y-m-d H:i:s');
}
return parent::insert($data);
}
}

View File

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

View File

@ -0,0 +1,13 @@
<?php
class Application_Model_CommandesPieces extends Zend_Db_Table_Abstract
{
protected $_name = 'commandes_pieces';
protected $_referenceMap = array(
'CommandesPieces' => array(
'columns' => array('commande_id'),
'refTableClass' => 'Application_Model_Commandes',
'refColumns' => array('id'),
),
);
}

View File

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

View File

@ -0,0 +1,16 @@
<?php
class Application_Model_ExtractionCommandes extends Zend_Db_Table_Abstract
{
protected $_name = 'commandes';
public function insert(array $data)
{
// Ajout d'un timestamp
if (empty($data['dateAdded'])) {
$data['dateAdded'] = date('Y-m-d H:i:s');
}
return parent::insert($data);
}
}

View File

@ -0,0 +1,6 @@
<?php
class Application_Model_FedasoBilans extends Zend_Db_Table_Abstract
{
protected $_name = 'fedaso_bilans';
protected $_schema = 'sdv1';
}

View File

@ -0,0 +1,6 @@
<?php
class Application_Model_HistoriquesBilans extends Zend_Db_Table_Abstract
{
protected $_name = 'bilans';
protected $_schema = 'historiques';
}

View File

@ -0,0 +1,6 @@
<?php
class Application_Model_JoAssoBilans extends Zend_Db_Table_Abstract
{
protected $_name = 'asso_bilans';
protected $_schema = 'jo';
}

View File

@ -0,0 +1,6 @@
<?php
class Application_Model_JoBilans extends Zend_Db_Table_Abstract
{
protected $_name = 'bilans';
protected $_schema = 'jo';
}

View File

@ -0,0 +1,6 @@
<?php
class Application_Model_JoBilansUser extends Zend_Db_Table_Abstract
{
protected $_name = 'bilans_user';
protected $_schema = 'jo';
}

View File

@ -0,0 +1,6 @@
<?php
class Application_Model_JoBoampLots extends Zend_Db_Table_Abstract
{
protected $_name = 'boamp_lots';
protected $_schema = 'jo';
}

View File

@ -0,0 +1,6 @@
<?php
class Application_Model_JoBodaccDetail extends Zend_Db_Table_Abstract
{
protected $_name = 'bodacc_detail';
protected $_schema = 'jo';
}

View File

@ -0,0 +1,6 @@
<?php
class Application_Model_JoBodaccFonctions extends Zend_Db_Table_Abstract
{
protected $_name = 'bodacc_fonctions';
protected $_schema = 'jo';
}

View File

@ -0,0 +1,6 @@
<?php
class Application_Model_JoGreffesActes extends Zend_Db_Table_Abstract
{
protected $_name = 'greffes_actes';
protected $_schema = 'jo';
}

View File

@ -0,0 +1,6 @@
<?php
class Application_Model_JoGreffesBilans extends Zend_Db_Table_Abstract
{
protected $_name = 'greffes_bilans';
protected $_schema = 'jo';
}

View File

@ -0,0 +1,6 @@
<?php
class Application_Model_JoLiens extends Zend_Db_Table_Abstract
{
protected $_name = 'liens2';
protected $_schema = 'jo';
}

View File

@ -0,0 +1,6 @@
<?php
class Application_Model_JoLiensDoc extends Zend_Db_Table_Abstract
{
protected $_name = 'liensDoc';
protected $_schema = 'jo';
}

View File

@ -0,0 +1,16 @@
<?php
class Application_Model_JoLiensRef extends Zend_Db_Table_Abstract
{
protected $_name = 'liensRef';
protected $_schema = 'jo';
public function insert(array $data)
{
// Ajout d'un timestamp
if (empty($data['dateInsert'])) {
$data['dateInsert'] = date('YmdHis');
}
return parent::insert($data);
}
}

View File

@ -0,0 +1,6 @@
<?php
class Application_Model_JoRncsDirigeants extends Zend_Db_Table_Abstract
{
protected $_name = 'rncs_dirigeants';
protected $_schema = 'jo';
}

View File

@ -0,0 +1,6 @@
<?php
class Application_Model_JoScoresCutoff extends Zend_Db_Table_Abstract
{
protected $_name = 'scores_cutoff';
protected $_schema = 'jo';
}

View File

@ -0,0 +1,6 @@
<?php
class Application_Model_JoScoresCutoffMvt extends Zend_Db_Table_Abstract
{
protected $_name = 'scores_cutoff_mvt';
protected $_schema = 'jo';
}

View File

@ -0,0 +1,7 @@
<?php
class Application_Model_JoScoresSurveillance extends Zend_Db_Table_Abstract
{
protected $_name = 'scores_surveillance';
protected $_schema = 'jo';
protected $_primary = 'siren';
}

View File

@ -0,0 +1,6 @@
<?php
class Application_Model_JoSurveillancesSite extends Zend_Db_Table_Abstract
{
protected $_name = 'surveillances_site';
protected $_schema = 'jo';
}

View File

@ -0,0 +1,7 @@
<?php
class Application_Model_JoTabDevises extends Zend_Db_Table_Abstract
{
protected $_name = 'tabDevises';
protected $_schema = 'jo';
protected $_primary = 'devIso';
}

View File

@ -0,0 +1,6 @@
<?php
class Application_Model_JoTabEvenements extends Zend_Db_Table_Abstract
{
protected $_name = 'tabEvenements';
protected $_schema = 'jo';
}

View File

@ -0,0 +1,6 @@
<?php
class Application_Model_JoTabFJur extends Zend_Db_Table_Abstract
{
protected $_name = 'tabFJur';
protected $_schema = 'jo';
}

View File

@ -0,0 +1,6 @@
<?php
class Application_Model_JoTabNaf5 extends Zend_Db_Table_Abstract
{
protected $_name = 'tabNaf5';
protected $_schema = 'jo';
}

View File

@ -0,0 +1,6 @@
<?php
class Application_Model_JoTabPays extends Zend_Db_Table_Abstract
{
protected $_name = 'tabPays';
protected $_schema = 'jo';
}

View File

@ -0,0 +1,6 @@
<?php
class Application_Model_JoTelephonie extends Zend_Db_Table_Abstract
{
protected $_name = 'telephonie';
protected $_schema = 'jo';
}

View File

@ -0,0 +1,6 @@
<?php
class Application_Model_Sdv1BourseIsin extends Zend_Db_Table_Abstract
{
protected $_name = 'bourse_isin';
protected $_schema = 'sdv1';
}

View File

@ -0,0 +1,6 @@
<?php
class Application_Model_Sdv1Clients extends Zend_Db_Table_Abstract
{
protected $_name = 'clients';
protected $_schema = 'sdv1';
}

View File

@ -0,0 +1,14 @@
<?php
class Application_Model_Sdv1ClientsServices extends Zend_Db_Table_Abstract
{
protected $_name = 'clients_services';
protected $_schema = 'sdv1';
protected $_referenceMap = array(
'Login' => array(
'columns' => array('code'),
'refTableClass' => 'Application_Model_Sdv1UtilistateursService',
'refColumns' => array('serviceCode')
)
);
}

View File

@ -0,0 +1,6 @@
<?php
class Application_Model_Sdv1ClientsTarifs extends Zend_Db_Table_Abstract
{
protected $_name = 'clients_tarifs';
protected $_schema = 'sdv1';
}

View File

@ -0,0 +1,6 @@
<?php
class Application_Model_Sdv1GreffeCommandes extends Zend_Db_Table_Abstract
{
protected $_name = 'greffe_commandes';
protected $_schema = 'sdv1';
}

View File

@ -0,0 +1,6 @@
<?php
class Application_Model_Sdv1Prestations extends Zend_Db_Table_Abstract
{
protected $_name = 'prestations';
protected $_schema = 'sdv1';
}

View File

@ -0,0 +1,6 @@
<?php
class Application_Model_Sdv1TabIdLocal extends Zend_Db_Table_Abstract
{
protected $_name = 'tabIdLocal';
protected $_schema = 'sdv1';
}

View File

@ -0,0 +1,18 @@
<?php
class Application_Model_Sdv1Utilisateurs extends Zend_Db_Table_Abstract
{
protected $_name = 'utilisateurs';
protected $_schema = 'sdv1';
protected $_referenceMap = array(
'Client' => array(
'columns' => 'idClient',
'refTableClass' => 'Sdv1Clients',
'refColumns' => 'id'
),
'Service' => array(
'columns' => 'login',
'refTableClass' => 'Sdv1UtilisateursService',
'refColumns' => 'login'
),
);
}

View File

@ -0,0 +1,6 @@
<?php
class Application_Model_Sdv1UtilisateursService extends Zend_Db_Table_Abstract
{
protected $_name = 'utilisateurs_service';
protected $_schema = 'sdv1';
}

View File

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

View File

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

View File

@ -0,0 +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#'
);
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

@ -0,0 +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 = '';
$returnType = $method['return'];
$methodName = $method['name'];
$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;
}
}
}

View File

@ -0,0 +1,81 @@
<?php
class Zend_View_Helper_DocParameter extends Zend_View_Helper_Abstract
{
protected $serviceTypes;
protected $types = array(
'string', 'str',
'boolean', 'bool',
'int', 'integer', 'long',
'float', 'double',
'array', 'object', 'mixed'
);
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;
}
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 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;
}
}
}

View File

@ -0,0 +1,74 @@
<?php
class Zend_View_Helper_DocReturn extends Zend_View_Helper_Abstract
{
protected $serviceTypes;
protected $types = array(
'string', 'str',
'boolean', 'bool',
'integer', 'int', 'long',
'float', 'double',
'array', 'object', 'mixed'
);
protected $_transcodeType = array(
'str' => 'string',
'bool' => 'boolean',
'integer' => 'int',
);
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 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 transcodeType($type)
{
if(array_key_exists($type, $this->_transcodeType)){
return $this->_transcodeType[$type];
} else {
return $type;
}
}
}

View File

@ -0,0 +1,17 @@
<?php
class Zend_View_Helper_ProfileLink extends Zend_View_Helper_Abstract
{
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.'" alt="Se déconnecter">Déconnexion : ' . $username . '</a>';
}
}
}

View File

@ -0,0 +1,13 @@
<h1>Démonstration - Liste des méthodes</h1>
<ul>
<?php
foreach($this->methods as $method){
?>
<li>
<a href="<?php echo $method['url'];?>">
<?php echo $method['nom'];?></a>
</li>
<?php
}
?>
</ul>

View File

@ -0,0 +1,5 @@
<h2><?php echo $this->method;?></h2>
<p><?php echo $this->message;?></p>
<div>
<?php echo $this->form;?>
</div>

View File

@ -0,0 +1,20 @@
<h2>SOAP</h2>
<p>Requete</p>
<textarea rows="10" cols="100" name="soap-requete">
<?php print_r($this->soap['requete']);?>
</textarea>
<p>Réponse</p>
<textarea rows="10" cols="100" name="soap-reponse">
<?php print_r($this->soap['reponse']);?>
</textarea>
<h2>XML</h2>
<p>Requete</p>
<textarea rows="10" cols="100" name="xml-requete">
<?php echo $this->xml['requete'];?>
</textarea>
<p>Réponse</p>
<textarea rows="10" cols="100" name="xml-reponse">
<?php echo $this->xml['reponse'];?>
</textarea>

View File

@ -0,0 +1,42 @@
<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>
<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="op-detail">
<h1>Détails :</h1>
<?php foreach ($this->serviceMethods as $method) {?>
<div class="function">
<a name="<?php echo $method['name'];?>">&nbsp;</a>
<h2><?php echo $method['name'];?></h2>
<div><u>Description : </u></div>
<div class="description"><?=$this->docDescription($method)?></div>
<div class="complement"><?=$this->docComplement($method)?></div>
<div class="function-detail" id="<?=$method['name']?>">
<p><?php echo $this->docMethod($method);?></p>
<div><u>Paramètres : </u></div>
<div class="parameters">
<?php echo $this->docParameter($method['params'], $this->serviceTypes);?>
</div>
<div><u>Retour : </u></div>
<div class="return">
<?php echo $this->docReturn($method['return'], $this->serviceTypes);?>
</div>
</div>
<p>Exemple : <?php echo $this->docExemple($method['name']);?></p>
</div>
<?php } ?>
</div>

View File

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

View File

@ -0,0 +1,10 @@
<div>
<h1>Liste des code erreurs/messages :</h1>
<ul>
<?php foreach ($this->erreurs as $code => $message) {?>
<li>
<b><?php echo $code?></b> : <?php echo $message?>
</li>
<?php } ?>
</ul>
</div>

View File

@ -0,0 +1,2 @@
<h2>Liste des exemples</h2>

View File

@ -0,0 +1,46 @@
<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>
<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="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

@ -0,0 +1 @@
Erreur

View File

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

View File

@ -0,0 +1 @@
<?php

View File

@ -0,0 +1,12 @@
<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

@ -0,0 +1,53 @@
<div>
<h2>Intégration d'un fichier</h2>
<p>Taille maximale d'un fichier : <?=$this->filesize?></p>
<form enctype="multipart/form-data" name="sendfile" action="<?=$this->url(array('controller'=>'import','action'=>'fileupload'))?>" method="post">
<input type="hidden" name="APC_UPLOAD_PROGRESS" id="key" value="<?=uniqid()?>"/>
<input type="hidden" name="idClient" value="<?=$this->idClient?>" />
<input type="hidden" name="login" value="<?=$this->login?>" />
<div class="fieldgrp">
<label>Fichier</label>
<div class="field">
<input type="file" id="fichier" name="fichier"/>
<input type="submit" value="Envoi"/>
<div id="progressbar"></div>
<div id="output"></div>
</div>
</div>
</form>
</div>
<?=$this->inlineScript()?>
<script>
var timer;
$('form[name=sendfile]').ajaxForm({
beforeSubmit: function() {
timer = setInterval(checkProgress,200);
$('#progressbar').reportprogress(0);
$('#output').html('Envoi en cours...');
},
success: function(data) {
clearInterval(timer);
$('#progressbar').remove();
$('#output').html('<strong>' + data + '</strong>');
}
});
function checkProgress() {
$.get('<?=$this->url(array('controller'=>'import', 'action'=>'fileprogress'))?>',
{key: $('#key').val()}, function(data) {
var percent = data.current/data.total*100;
$('#progressbar').reportprogress(percent);
}, 'json');
}
</script>

View File

@ -0,0 +1,82 @@
<h1>Liste des services disponibles</h1>
<ul>
<?php foreach ($this->ws as $key => $ws) {?>
<li>
<?php if (array_key_exists('type', $ws) && $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) { ?>
<?php if ($versionElement['actif']) { ?>
<li>
<?php if (array_key_exists('type', $ws) && $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 } ?>
<?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>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

@ -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

@ -0,0 +1 @@
<?= $this->message ?>

View File

@ -0,0 +1 @@
<?php

View File

@ -0,0 +1 @@
<?= $this->message ?>

View File

@ -0,0 +1 @@

View File

@ -0,0 +1,2 @@
<p>Identifiez-vous pour accèder aux ressources</p>
<?=$this->form?>

View File

@ -0,0 +1 @@
Vous avez été déconnecté.

View File

@ -0,0 +1,55 @@
Le fichier Zend/Soap/Wsdl/Strategy/DefaultComplexType.php a été modifié pour
générer la documentation automatiquement.
/**
* Traitement éléments de documentation à placer dans le WSDL
* Supprime les retours chariots.
* Récupére les éléments de documentation
*/
$comment = '';
$docBlock = preg_replace('/\n/', '', $property->getDocComment() );
if (preg_match('/\/\*\*(.+) \* @var\s+[^\s]+\s+(?:\*|@)/m', $docBlock, $docBlockMatches)) {
$comment.= preg_replace(
array('/\r/', '/\t\s\*/'),
array('', ''), $docBlockMatches[1]
);
}
/**
* Ajout des éléments de documentation au WSDL
*/
if (!empty($comment)){
$annotation = $dom->createElement('xsd:annotation');
$documentation = $dom->createElement('xsd:documentation', trim($comment));
$annotation->appendChild($documentation);
$element->appendChild($annotation);
}
===============================================================================>
Le fichier Zend/Soap/AutoDiscover.php a été modifié
function _addFunctionToWsdl
$sequenceElement = array(
'name' => $param->getName(),
'type' => $wsdl->getType($param->getType()),
'desc' => $param->getDescription()
);
===============================================================================>
Le fichier Zend/Soap/Wsdl.php a été modifié
function _parseElement
} elseif ($key == 'desc') {
if (!empty($value)) {
$annotation = $this->_dom->createElement('xsd:annotation');
$documentation = $this->_dom->createElement('xsd:documentation', trim($value));
$annotation->appendChild($documentation);
$elementXml->appendChild($annotation);
}
} else {

179
docs/README.txt Normal file
View File

@ -0,0 +1,179 @@
README
======
Le webservice est basé sur le ZendFramework pour générer les WSDLs.
Fichier de configuration
========================
La configuration est décomposé en plusieurs fichiers,
avec adaptation suivant la machine
- mysql.php
- smtp.php
- sphinx.php
- stockage.php
sans adaptation suivant la machine
- partenaires.php
Fonctionnement
==============
Obtenir les WSDL
Pour le service Entreprise
- En mode développement : http://hostname/entreprise/version?wsdl-auto
- Générer le WSDL : http://hostname/entreprise/version?wsdl-generate
- Utiliser le WSDL généré : http://hostname/entreprise/version?wsdl
Pour le service Interne
http://hostname/interne/version?wsdl
Pour les clients
http://hostname/clients/nom_du_client/version?wsdl
N.B : Le fichier WSDL est généré automatiquement en appelant
http://hostname/service?wsdl afin de ne pas provoquer d'erreur
après une mise en production
Pour définir le mode (vhost d'apache)
SetEnv APPLICATION_ENV "development"
SetEnv APPLICATION_ENV "production"
SetEnv APPLICATION_ENV "staging"
En appelant l'url http://hostname/service, le contoller de l'application,
"service" est automatiquement utiliser.
Tout ce qui est visible dans la class est utilisé par le controller et se
retrouve visible dans le service (wsdl, requête)
Si des fonctions ne doivent pas être rendu visible il faut donc les séparer
dans un autre controller utilisant une autre class.
Documentation des méthodes et ajout spécial
===========================================
La documentation est géneré en automatique.
Voici comment définir simplement la documentation d'une méthode
/**
* Retourne les informations identitaires de l'entreprise ou de l'établissement demandé
* @param string $key Siren de l'entreprise ou siret de l'établissement
* @return Identite
*/
public function test($key)
{
}
Attention ces informations servent aussi pour la structure du WSDL
Pour spécifier un lien vers un fichier ou pour générer un fichier depuis une
requête SQL à partir de la documentation du service.
Ajouter dans le docblock :
- Pour un fichier
@ref fichier:libellé:{nom_du_fichier.ext}
- Pour une requête SQL
@ref mysql:libellé:{nom_du_fichier.sql}
Les fichiers a télécharger sont à placer dans le répértoire public/fichier et
les fichiers sql dans public/sql
Pour spécifier des éléments de taille (non pris en compte sur le WSDL)
@xsd minLength=9
@xsd maxLength=15
Configuration PHP
=================
apt-get install php5-mysql
apt-get install php-apc
apt-get install php5-curl
apt-get install php5-xmlrpc
Paquet PEAR
- Mail
- Mail_Mime
WKHTMLTOPDF
===========
apt-get install libXrender1
apt-get install libfontconfig
Configuration VHOST
===================
a2enmod rewrite
Exemple de vhost en mode développement
<VirtualHost *:80>
ServerName scoresws.sd.dev
AddDefaultCharset utf-8
# Pour la gestion des ports : $_SERVER['SERVER_NAME'], $_SERVER['SERVER_PORT']
UseCanonicalName On
UseCanonicalPhysicalPort On
DocumentRoot "D:/www/webservice/public"
SetEnv APPLICATION_ENV "development"
<Directory "D:/www/webservice/public/">
DirectoryIndex index.php
AllowOverride All
Order allow,deny
Allow from all
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/favicon.ico$ [OR]
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]
</IfModule>
</Directory>
# Possible values include: debug, info, notice, warn, error, crit, alert, emerg.
LogLevel debug
ErrorLog "logs/scoresws.sd.dev-error.log"
CustomLog "logs/scoresws.sd.dev-access.log" common
</VirtualHost>
Vhost réel
<VirtualHost *:8081>
ServerName wse.scores-decisions.com
ServerAlias wse1.scores-decisions.com
# Pour la gestion des ports : $_SERVER['SERVER_NAME'], $_SERVER['SERVER_PORT']
UseCanonicalName On
UseCanonicalPhysicalPort On
ServerSignature Off
AddDefaultCharset utf-8
DocumentRoot /home/vhosts/webservice/public
SetEnv APPLICATION_ENV "production"
<Directory /home/vhosts/webservice/public/>
DirectoryIndex index.php
AllowOverride All
Order allow,deny
Allow from all
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/favicon.ico$ [OR]
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]
</IfModule>
</Directory>
# Possible values include: debug, info, notice, warn, error, crit, alert, emerg.
LogLevel error
ErrorLog /var/log/apache2/webservice-error.log
CustomLog /var/log/apache2/webservice-access.log common
</VirtualHost>

8
docs/logrotate.txt Normal file
View File

@ -0,0 +1,8 @@
Créer un fichier "webservice" dans /etc/logrotate.d
/var/log/webservice/*.log {
weekly
missingok
compress
notifempty
}

View File

@ -0,0 +1,100 @@
<?php
class Application_Controller_Plugin_Auth extends Zend_Controller_Plugin_Abstract
{
/**
* Vérifie les autorisations
* Utilise _request et _response hérités et injectés par le FC
*
* @param Zend_Controller_Request_Abstract $request : non utilisé, mais demandé par l'héritage
*/
public function preDispatch(Zend_Controller_Request_Abstract $request)
{
$controller = $request->getControllerName();
$action = $request->getActionName();
$checkAuth = true;
//Pas d'authentification sur la demande d'authentification
if ( $controller == 'user' && $action == 'login' ) {
$checkAuth = false;
}
// Pas d'authentification sur ces services
if ( in_array($controller, array('service', 'import'))
|| ( $controller == 'fichier' && $action == 'logs' )
|| ( $controller == 'fichier' && $action == 'kbis' )
|| ( $controller == 'fichier' && $action == 'csv' )
|| ( $controller == 'fichier' && $action == 'associations' )) {
$checkAuth = false;
}
$checkWs = true;
if ( $controller == 'fichier' ) {
$checkWs = false;
}
if ($checkAuth) {
$login = $request->getParam('login');
$pass = $request->getParam('pass', '');
$hach = $request->getParam('hach');
if (!empty($hach)) {
$pass = $hach;
}
$auth = Zend_Auth::getInstance();
//On vérifie le tout lors d'une connexion par url
if ( !empty($login) && !empty($pass) ) {
$authAdapter = new Scores_AuthAdapter($login, $pass, $checkWs);
$result = $auth->authenticate($authAdapter);
if (!$result->isValid()) {
$layout = Zend_Layout::getMVCInstance();
if ( !$layout->isEnabled() ){
echo "Identification incorrect ou périmé.";
} else {
$request->setModuleName('default')
->setControllerName('user')
->setActionName('logout');
}
} else {
$storage = new Zend_Auth_Storage_Session();
$session = new Zend_Session_Namespace($storage->getNamespace());
//$session->setExpirationSeconds(86400);
$auth->setStorage($storage);
}
//Sinon on reste sur le standard
} else {
//Pas authentifié
if ( !$auth->hasIdentity() || time() > $auth->getIdentity()->time ) {
$auth->clearIdentity();
$session = new Zend_Session_Namespace('login');
$session->url = $_SERVER['REQUEST_URI'];
$layout = Zend_Layout::getMVCInstance();
if (!$layout->isEnabled()){
echo "Identification incorrect ou périmé.";
} else {
$this->_response->setRedirect('/user/login')->sendResponse();
}
//Authentifié => on met à jour la session
} else {
$identity = $auth->getIdentity();
$identity->time = time() + $identity->timeout;
$auth->getStorage()->write($identity);
if (Zend_Session::namespaceIsset('login')){
Zend_Session::namespaceUnset('login');
}
}
}
}
}
}

View File

@ -0,0 +1,28 @@
<?php
class Application_Form_Login extends Zend_Form {
public function init()
{
$this->setName('login');
$this->setAction('login');
$this->setMethod('post');
$this->addElement('text', 'login', array(
'filters' => array('StringTrim'),
'label' => 'Identifiant : ',
'required' => 'true',
)
);
$this->addElement('password', 'pass',
array(
'label' => 'Mot de passe : ',
'required' => 'true',
)
);
$this->addElement('submit', 'submit',
array(
'label' => 'Identification',
'ignore' => true,
));
}
}

View File

@ -0,0 +1,399 @@
<?php
/**
* Infogreffe provider
*/
class Metier_Infogreffe
{
/**
* Activate debug mode
* @var boolean
*/
public $debug = false;
/**
* Config definition
* @var Zend_Config
*/
public $config;
/**
* Reference client - customer reference
* G[Number]
* @var string
*/
public $reference_client;
/**
* Type de document
* @var string
*/
public $type_document;
/**
* Mode de diffusion
* XL : XML
* M : Mail
* C : Courrier
* T : Téléchargement
* @var string
*/
public $mode_diffusion;
/**
*
* @var string
*/
public $greffe;
/**
*
* @var string
*/
public $dossier_millesime;
/**
*
* @var string
*/
public $dossier_statut;
/**
*
* @var string
*/
public $dossier_chrono;
/**
*
* @var unknown
*/
public $date_depot;
/**
*
* @var string
*/
public $num_depot;
/**
* BI : Date de cloture
* @var string
*/
public $date_cloture;
/**
*
* @var unknown
*/
public $date_acte;
/**
* AC : Numéro de l'acte
* @var string
*/
public $num;
/**
* SIREN
* @var string
*/
public $siren;
/**
* Request XML
* @var string
*/
protected $xml = '';
/**
* Initialize configuration
*/
public function __construct()
{
//Load configuration
$c = Zend_Registry::get('config');
$this->config = $c->profil->infogreffe;
if ( null === $this->config ) {
throw new Exception('Unable to load configuration file.');
}
}
public function callRequest()
{
$fromCache = false;
if ( $this->mode_diffusion == 'XL' && $this->fileIsCache($name) ){
$fromCache = true;
}
if ($fromCache) {
$xml = $this->fileFromCache();
} else {
$xml = $this->getProduitsXML();
$this->error($xml);
}
if ( $this->mode_diffusion == 'XL' ){
$this->fileTocache($xml);
}
$this->error($xml);
return $xml;
}
/**
* Save data in cache
* @param string $xml
*/
protected function fileTocache($xml)
{
$filename = $this->type_document . '-' . $this->siren . '.xml';
$file = $this->config->cache->path . DIRECTORY_SEPARATOR . $filename;
file_put_contents($file, $xml);
}
/**
*
* @param string $xml
* @return string
*/
protected function fileFromCache()
{
$filename = $this->type_document . '-' . $this->siren . '.xml';
$file = $file = $this->config->cache->path . DIRECTORY_SEPARATOR . $filename;
return file_get_contents($file);
}
/**
*
* @param string $xml
* @return boolean
*/
protected function fileIsCache($xml)
{
$filename = $this->type_document . '-' . $this->siren . '.xml';
$file = $file = $this->config->cache->path . DIRECTORY_SEPARATOR . $filename;
if ( !file_exists($file) ) {
return false;
}
$dateFile = filemtime($file);
$now = mktime(date('G'), date('i'), date('s'), date('m') , date('d'), date('Y'));
$maxTime = mktime(
date('G',$dateFile)+$this->cacheFiletime,
date('i',$dateFile),
date('s',$dateFile),
date("m",$dateFile),
date("d",$dateFile),
date("Y",$dateFile)
);
if ( $now>$maxTime ) {
return true;
}
return false;
}
/**
* Detect error
* @param string $xml
* @throws Exception
*/
protected function error($xml)
{
if (!empty($xml))
{
$doc = new DOMDocument();
$load = $doc->loadXML($xml, LIBXML_NOERROR | LIBXML_NOWARNING);
if (!$load) {
$tmp = explode('-', $xml);
$errNum = intval($tmp[0]);
$errMsg = $tmp[1];
if( $errNum == '5' ){
$errMsg = 'Service partenaire indisponible.';
}
throw new Exception($errNum . '-' . $errMsg);
}
}
else
{
throw new Exception('Fichier vide');
}
}
/**
* Download file from URL
* @param string $url
* @param string $filename
* @throws Exception
* @return string
*/
protected function download($url, $filename)
{
$file = $file = $this->config->storage->path . DIRECTORY_SEPARATOR . $filename;
$fp = fopen($file, 'w');
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_FILE, $fp);
$data = curl_exec($ch);
if( curl_errno($ch) ) {
throw new Exception( curl_error($ch) );
}
curl_close($ch);
fclose($fp);
return $file;
}
/**
* Pdf information
* @param string $pdf
* @return array
* pages => number of pages
* version => pdf version
* size => pdf filesize
*/
public function pdfInfos($pdf)
{
if ( false !== ( $file = file_get_contents( $pdf ) ) ) {
//Number of page
$pages = preg_match_all( "/\/Page\W/", $file, $matches );
//Pdf Version
preg_match("/^\%PDF\-(.*)\s/U", $file, $matches);
$version = $matches[1];
//Pdf size
$size = filesize($pdf);
return array(
'pages' => $pages,
'version' => $version,
'size' => $size,
);
}
return false;
}
/**
* Define XML for the request
*/
protected function setXML()
{
//Construct the request
$xml = new SimpleXMLElement('<demande></demande>');
$emetteur = $xml->addChild('emetteur');
$emetteur->addChild('code_abonne', $this->config->user);
$emetteur->addChild('mot_passe', $this->config->password);
//Set Command ID
$emetteur->addChild('reference_client', $this->reference_client);
$code_requete = $emetteur->addChild('code_requete');
$code_requete->addChild('type_profil', 'A');
$code_requete->addChild('origine_emetteur', 'IC');
// C = Commande de documents
$code_requete->addChild('nature_requete', 'C');
$code_requete->addChild('type_document', $this->type_document);
$code_requete->addChild('type_requete', 'S'); // S = Simple
// Mode de diffusion : C = Courrier, T = Téléchargement, M = Mail, XL = XML
$mode_diffusion = $code_requete->addChild('mode_diffusion');
if ( $this->mode_diffusion=='XL' )
{
//On ajoute tout les types de diffusions pour XL
$mode_diffusion->addChild('mode')->addAttribute('type', 'C');
$mode_diffusion->addChild('mode')->addAttribute('type', 'T');
}
$mode_diffusion->addChild('mode')->addAttribute('type', $this->mode_diffusion);
$code_requete->addChild('media', 'WS');
$commande = $xml->addChild('commande');
$commande->addChild('num_siren', $this->siren);
if ( $this->mode_diffusion!='XL' )
{
// Commande de documents : bilan saisie ou bilan complet
if ( ($this->type_document=='BS' || $this->type_document=='BI') )
{
$commande->addChild('greffe',$this->greffe);
$commande->addChild('dossier_millesime',$this->dossier_millesime);
$commande->addChild('dossier_statut',$this->dossier_statut);
$commande->addChild('dossier_chrono',$this->dossier_chrono);
$commande->addChild('num_depot',$this->num_depot);
$commande->addChild('date_cloture', $this->date_cloture);
}
// Commande de documents : actes
elseif ( $this->type_document=='AC' )
{
$commande->addChild('greffe',$this->greffe);
$commande->addChild('dossier_millesime',$this->dossier_millesime);
$commande->addChild('dossier_statut',$this->dossier_statut);
$commande->addChild('dossier_chrono',$this->dossier_chrono);
$commande->addChild('num_depot',$this->num_depot);
$liste_actes = $commande->addChild('liste_actes');
$liste_actes->addChild('acte')->addAttribute('num', $this->num);
}
}
$xml = str_replace('<?xml version="1.0"?>', '', $xml->asXML());
$this->xml = $xml;
}
/**
* Send XML Request
* We have some problem to use SOAP so we use CURL
* @throws Exception
* @return string XML Response
*/
protected function getProduitsXML()
{
$this->setXML();
//Be sure it's in UTF-8
$req = utf8_encode($this->xml);
if ($this->debug) {
file_put_contents($this->type_document.'-'.$this->siren.'-'.$this->mode_diffusion.'.query');
}
//Create XML request
$post = '<?xml version="1.0" encoding="UTF-8"?>'.
'<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" '.
'xmlns:ns1="https://webservices.infogreffe.fr/" '.
'xmlns:xsd="http://www.w3.org/2001/XMLSchema" '.
'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" '.
'xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" '.
'SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">'.
'<SOAP-ENV:Body>'.
'<ns1:getProduitsWebServicesXML>'.
'<param0 xsi:type="xsd:string">'.$req.'</param0>'.
'</ns1:getProduitsWebServicesXML>'.
'</SOAP-ENV:Body>'.
'</SOAP-ENV:Envelope>';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $this->config->url);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_COOKIEFILE,TRUE);
curl_setopt($ch, CURLOPT_POST, TRUE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
$response = curl_exec($ch);
if ( curl_errno($ch) ) {
throw new Exception( curl_error($ch) );
}
//Remove SOAP part of XML
$response = str_replace("<?xml version='1.0' encoding='UTF-8'?><SOAP-ENV:Envelope xmlns:SOAP-ENV='http://schemas.xmlsoap.org/soap/envelope/' xmlns:SOAP-ENC='http://schemas.xmlsoap.org/soap/encoding/' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:xsd='http://www.w3.org/2001/XMLSchema'><SOAP-ENV:Body><ns0:getProduitsWebServicesXMLResponse xmlns:ns0='urn:local' SOAP-ENV:encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'><return xsi:type='xsd:string'>", '', $response);
$response = str_replace('</return></ns0:getProduitsWebServicesXMLResponse></SOAP-ENV:Body></SOAP-ENV:Envelope>','', $response);
return $response;
}
}

View File

@ -0,0 +1,472 @@
<?php
require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'Infogreffe.php';
/**
* Infogreffe : Document Acte
*/
class Metier_Infogreffe_Ac extends Metier_Infogreffe
{
/**
* Db Adapter
* @var Zend_Db_Adapter_Abstract
*/
public $db;
/**
*
* @param string $siren
*/
public function __construct($siren, $db = null)
{
//@todo : Inject db in batch
parent::__construct();
//Set type
$this->type_document = 'AC';
//Set Siren
$this->siren = $siren;
//Get defaut database adapter
if ($db === null) {
$this->db = Zend_Db_Table_Abstract::getDefaultAdapter();
} else {
$this->db = $db;
}
}
/**
* @param $onlyDb
* @return array
*/
public function getList($onlyDb = false)
{
$this->mode_diffusion = 'XL';
$this->reference_client = 'list-' . $this->siren;
//Requete WebService
$actesXML = null;
if ( $onlyDb === false ) {
$this->debug = true;
//Infogreffe webservice
$xml = $this->callRequest();
$actesXML = $this->formatList($xml);
}
//Lecture de la base de données
$actesM = new Application_Model_JoGreffesActes($this->db);
$sql = $actesM->select()
->where('siren=?', $this->siren)
->order('date_acte DESC');
$rows = $actesM->fetchAll($sql);
$actes = array();
if ( count($rows)>0 ) {
foreach ( $rows as $row ) {
$item = new stdClass();
$item->File = $row->pdfLink;
$item->FileSize = $row->pdfSize;
$item->FileNumberOfPages = $row->pdfPage;
$item->DepotNum = $row->num_depot;
$item->DepotDate = $row->date_depot;
$item->ActeNum = $row->num_acte;
$item->ActeDate = $row->date_acte;
$item->ActeNumberOfPages = $row->nbpages_acte;
$item->ActeType = $row->type_acte;
$item->ActeTypeLabel = $row->type_acte_libelle;
$decisions = $row->decision_nature;
if (!empty($row->decision_nature) && !empty($row->decision_libelle)) {
$decisions.= ' : ';
}
$decisions.= $row->decision_libelle;
$item->infos[] = $decisions;
//@todo : si présence de fichier alors mode T
$mode_diffusion = explode(',', $row->mode_diffusion);
if (in_array('T',$mode_diffusion)) {
$item->ModeDiffusion = 'T';
} elseif (in_array('C',$mode_diffusion)) {
$item->ModeDiffusion = 'C';
} else {
$item->ModeDiffusion = '';
}
$actes[] = $item;
}
}
return $actes;
}
/**
* @todo : En cours
* @param string $depotDate
* @param int $depotNum
* @param string $acteType
* @param string $acteDate
* @param int $acteNum
* @throws Exception
* @return string
* Return the full path of the file
*/
public function getCommandeT($depotDate, $depotNum, $acteType, $acteDate, $acteNum)
{
$this->mode_diffusion = 'T';
$this->reference_client = 'T'.date('YmdHis');
//Lire dans la base de données
$actesM = new Application_Model_JoGreffesActes($this->db);
//@todo : set vars
$sql = $actesM->select()
->where('siren=?', $this->siren)
->where('num_depot=?', $depotNum)
->where('date_depot=?', $depotDate)
->where('num_acte=?', $acteNum)
->where('date_acte=?', $acteDate)
->where('type_acte=?', $acteType);
$row = $actesM->fetchRow($sql);
if ( null === $row ) {
throw new Exception('Not exist');
}
//Needed element for filename
$date = $row->date_acte;
$type = $row->type_acte;
$num = $row->num_acte;
$options = $row->numGreffe . '-' . substr($row->numR,0,2) . '-' . substr($row->numR,2,1) . '-' . substr($row->numR,3) . '-' . $row->num_depot;
$this->greffe = $row->numGreffe;
$this->dossier_millesime = substr($row->numRC,0,2);
$this->dossier_statut = substr($row->numRC,2,1);
$this->dossier_chrono = substr($row->numRC,3);
$this->num_depot = $row->num_depot;
if ( $row->pdfLink != '' ) {
//Set the filename
$filename = $this->getFilePath($date) . DIRECTORY_SEPARATOR . $this->getFileName($date, $num, $type, $options);
//Check if filename exist
if ( !file_exists($this->config->storage->path . DIRECTORY_SEPARATOR . $filename) ) {
throw new Exception('File not found');
}
} else {
$xml = $this->callRequest();
$acte = $this->formatItem($xml);
$url = $acte['url_acces'];
if (empty($url)) {
throw new Exception('File url not given');
}
//Set the filename
$filename = $this->getFilePath($date) . DIRECTORY_SEPARATOR . $this->getFileName($date, $num, $type, $options);
//Récupérer le fichier
$getfile = $this->download($url, $filename);
//Analyser le fichier - Nombre de page et taille
$infos = $this->pdfInfos($getfile);
//Enregistrer les infos du fichier dans la base de données
if (false !== $infos) {
$this->dbSetFile($filename, $infos['size'], $infos['pages'], $infos['version']);
}
}
return $filename;
}
public function getCommandeC($id)
{
$this->mode_diffusion = 'C';
//Enregistrer la commande dans la base de données
//Récupérer l'id de commande
$this->reference_client = 'G'.$id;
$xml = $this->callRequest();
//@todo :
}
/**
*
* @param string $date
* Date de l'acte au format AAAAMMJJ
* @param string $num
* Numéro de l'acte
* @param string $type
* Type de l'acte
* @param string $options
* (Numéro du Greffe)-(dossier_millesime)-(dossier_statut)-(dossier_chrono)-(num_depot)
* @return string
*/
public function getFileName($date, $num, $type, $options)
{
return 'acte-' . $this->siren . '-' . $type . '-' . $date . '-' . $options . '-' . $num . '.pdf';
}
/**
*
* @param string $date
* Date de l'acte au format AAAA-MM-JJ
* @return string
*/
public function getFilePath($date)
{
return 'actes' . DIRECTORY_SEPARATOR . substr($date,0,4) . DIRECTORY_SEPARATOR . substr($date,5,2);
}
/**
* Format XML to Array for a list of items
* @param string $xml
* @return array
*/
protected function formatList($xml)
{
$doc = new DOMDocument();
$doc->loadXML($xml);
$liste_depot_acte = $doc->getElementsByTagName('liste_depot_acte')->item(0);
$depot_actes = $liste_depot_acte->getElementsByTagName('depot_acte');
$actes = array();
foreach($depot_actes as $depot_acte)
{
$acte = array();
$acte['num_gest'] = array();
$num_gest = $depot_acte->getElementsByTagName('num_gest')->item(0);
$acte['num_gest']['greffe'] = $num_gest->getElementsByTagName('greffe')->item(0)->nodeValue;
$acte['num_gest']['dossier_millesime'] = $num_gest->getElementsByTagName('dossier_millesime')->item(0)->nodeValue;
$acte['num_gest']['dossier_statut'] = $num_gest->getElementsByTagName('dossier_statut')->item(0)->nodeValue;
$acte['num_gest']['dossier_chrono'] = $num_gest->getElementsByTagName('dossier_chrono')->item(0)->nodeValue;
$acte['num_siren'] = $depot_acte->getElementsByTagName('num_siren')->item(0)->nodeValue;
$acte['num_depot'] = $depot_acte->getElementsByTagName('num_depot')->item(0)->nodeValue;
$acte['date_depot'] = $depot_acte->getElementsByTagName('date_depot')->item(0)->nodeValue;
$infoActes = $depot_acte->getElementsByTagName('acte');
$acte['depot'] = array();
foreach($infoActes as $infoActe)
{
$actenum = array();
$actenum['date_acte'] = $infoActe->getElementsByTagName('date_acte')->item(0)->nodeValue;
$actenum['num_acte'] = $infoActe->getElementsByTagName('num_acte')->item(0)->nodeValue;
$actenum['type_acte'] = $infoActe->getElementsByTagName('type_acte')->item(0)->nodeValue;
$actenum['type_acte_libelle'] = $infoActe->getElementsByTagName('type_acte_libelle')->item(0)->nodeValue;
$actenum['nbpages_acte'] = $infoActe->getElementsByTagName('nbpages_acte')->item(0)->nodeValue;
$decision = $infoActe->getElementsByTagName('decision')->item(0);
if($decision)
{
$actenum['decision'] = array();
$actenum['decision']['nature'] = $decision->getElementsByTagName('nature')->item(0)->nodeValue;
$actenum['decision']['libelle'] = $decision->getElementsByTagName('libelle')->item(0)->nodeValue;
}
$actenum['mode_diffusion'] = array();
$mode_diffusion = $infoActe->getElementsByTagName('mode_diffusion')->item(0)->getElementsByTagName('mode');
foreach($mode_diffusion as $mode)
{
$actenum['mode_diffusion'][] = $mode->getAttribute('type');
}
$acte['depot'][] = $actenum;
}
//Fin listes des infos acte
//Enregistrer dans la bdd
$this->dbUpdateItem($acte);
//Génération de l'index pour le tri
if(!empty($acte['date_depot'])){ $date = $acte['date_depot']; }
else { $date = ''; }
if(!empty($date))
{
$datef = substr($date,0,4).substr($date,5,2).substr($date,8,2);
$key = $datef.'-'.$acte['num_depot'];
//Affectation liste générale avec un index permettant le tri
$actes[$key] = $acte;
}
//Prise en compte de l'acte -1
if($acte['num_depot']==-1)
{
$actes[0] = $acte;
}
}
//Tri suivant la date d'acte ou de depot
krsort($actes);
return $actes;
}
/**
* Format XML to Array for one item
* @param string $xml
* @return array
*/
protected function formatItem($xml)
{
$doc = new DOMDocument();
$doc->loadXML($xml);
$depot_acte = $doc->getElementsByTagName('depot_acte')->item(0);
$info = array();
$info['num_gest'] = array();
$num_gest = $depot_acte->getElementsByTagName('num_gest')->item(0);
$info['num_gest']['greffe'] = $num_gest->getElementsByTagName('greffe')->item(0)->nodeValue;
$info['num_gest']['dossier_millesime'] = $num_gest->getElementsByTagName('dossier_millesime')->item(0)->nodeValue;
$info['num_gest']['dossier_statut'] = $num_gest->getElementsByTagName('dossier_statut')->item(0)->nodeValue;
$info['num_gest']['dossier_chrono'] = $num_gest->getElementsByTagName('dossier_chrono')->item(0)->nodeValue;
$info['num_siren'] = $depot_acte->getElementsByTagName('num_siren')->item(0)->nodeValue;
$info['num_depot'] = $depot_acte->getElementsByTagName('num_depot')->item(0)->nodeValue;
$info['date_depot'] = $depot_acte->getElementsByTagName('date_depot')->item(0)->nodeValue;
$infoActes = $depot_acte->getElementsByTagName('acte');
$info['actes'] = array();
foreach($infoActes as $infoActe)
{
$actenum = array();
$actenum['date_acte'] = $infoActe->getElementsByTagName('date_acte')->item(0)->nodeValue;
$actenum['num_acte'] = $infoActe->getElementsByTagName('num_acte')->item(0)->nodeValue;
$actenum['type_acte'] = $infoActe->getElementsByTagName('type_acte')->item(0)->nodeValue;
$actenum['type_acte_libelle'] = $infoActe->getElementsByTagName('type_acte_libelle')->item(0)->nodeValue;
$actenum['nbpages_acte'] = $infoActe->getElementsByTagName('nbpages_acte')->item(0)->nodeValue;
$decision = $infoActe->getElementsByTagName('decision')->item(0);
if($decision)
{
$actenum['decision'] = array();
$actenum['decision']['nature'] = $decision->getElementsByTagName('nature')->item(0)->nodeValue;
$actenum['decision']['libelle'] = $decision->getElementsByTagName('libelle')->item(0)->nodeValue;
}
$actenum['url_acces'] = htmlspecialchars_decode($infoActe->getElementsByTagName('url_acces')->item(0)->nodeValue);
$info['actes'][] = $actenum;
}
return $info;
}
/**
* Update informations about an item in database
* @param array $list
*/
protected function dbUpdateItem($list)
{
//siren
//numRC
//numGreffe
//num_depot
//date_depot
//date_acte
//num_acte
//type_acte => Attention garder la version 1 et 2
//type_acte_libelle
//nbpages_acte
//decision_nature
//decision_libelle
//mode_diffusion
$data = array(
'siren' => $list['siren'],
'numRC' => $list['num_gest']['dossier_millesime'].
$list['num_gest']['dossier_statut'].$list['num_gest']['dossier_chrono'],
'numGreffe' => $list['num_gest']['greffe'],
'num_depot' => $list['num_depot'],
'date_depot' => $list['date_depot'],
'date_acte' => $list['date_acte'],
'num_acte' => $list['num_acte'],
'type_acte' => $list['type_acte'],
'type_acte_libelle' => $list['type_acte_libelle'],
'nbpages_acte' => $list['nbpages_acte'],
'decision_nature' => $list['decision']['nature'],
'decision_libelle' => $list['decision']['libelle'],
'mode_diffusion' => join(',',$list['mode_diffusion']),
);
//Only new element are inserted
try {
$acteM = new Application_Model_JoGreffesActes($this->db);
$acteM->select()
->where('siren=?', $list['siren'])
->where('num_depot=?', $list['num_depot'])
->where('date_depot=?', $list['date_depot'])
->where('date_acte=?', $list['date_acte'])
->where('num_acte=?', $list['num_acte'])
->where('type_acte=?', $list['type_acte']); //Attention type lors du téléchargement
if ( null === $acteM->fetchRow($sql) ) {
$result = $acteM->insert($data);
}
} catch(Zend_Db_Adapter_Exception $e) {
throw new Exception($e->getMessage());
} catch(Zend_Db_Exception $e) {
throw new Exception($e->getMessage());
}
if ($result) {
return true;
}
return false;
}
/**
* Set file informations in database
* @param string $filename
* @param int $size
* @param int $numberOfPage
* @param string $version
* @return boolean
*/
protected function dbSetFile($filename, $size, $numberOfPage, $version)
{
$data = array(
'pdfLink' => $filename,
'pdfSize' => $size,
'pdfPage' => $numberOfPage,
'pdfVer' => $version
);
$where = array(
'siren="'.$this->siren."'",
'num_depot' => $this->num_depot,
'date_depot' => $this->date_depot,
'date_acte' => $this->date_acte,
'num_acte' => $this->num,
);
try {
$acteM = new Application_Model_JoGreffesActes();
$result = $acteM->update($data, $where);
} catch(Zend_Db_Adapter_Exception $e) {
throw new Exception($e->getMessage());
} catch(Zend_Db_Exception $e) {
throw new Exception($e->getMessage());
}
if ($result) {
return true;
}
return false;
}
}

View File

@ -0,0 +1,434 @@
<?php
require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'Infogreffe.php';
/**
* Infogreffe : Document Bilan
*/
class Metier_Infogreffe_Bi extends Metier_Infogreffe
{
/**
* Db Adapter
* @var Zend_Db_Adapter_Abstract
*/
public $db;
/**
* consolides|sociaux
* @var string
*/
public $type_comptes;
/**
*
* @param string $siren
*/
public function __construct($siren, $db = null)
{
parent::__construct();
//Set type
$this->type_document = 'BI';
//Set Siren
$this->siren = $siren;
//Get defaut database adapter
if ($db === null) {
$this->db = Zend_Db_Table_Abstract::getDefaultAdapter();
} else {
$this->db = $db;
}
}
/**
* @param $onlyDb
* @return array
*/
public function getList($onlyDb = false)
{
$this->mode_diffusion = 'XL';
$this->reference_client = 'list-' . $this->siren;
//Requete WebService
$bilansXML = null;
if ( $onlyDb === false ) {
$this->debug = true;
//Infogreffe webservice
$xml = $this->callRequest();
$bilansXML = $this->formatList($xml);
}
//Lecture de la base de données
$bilansM = new Application_Model_JoGreffesBilans();
$sql = $bilansM->select()
->where('siren=?', $this->siren)
->order('date_cloture DESC');
$rows = $bilansM->fetchAll($sql);
$bilans = array();
if ( count($rows)>0 ) {
foreach ( $rows as $row ) {
$item = new stdClass();
$item->File = $row->pdfLink;
$item->FileSize = $row->pdfSize;
$item->NumberOfPages = $row->pdfPage;
$item->Millesime = $row->millesime;
$item->NumDepot = $row->num_depot;
$item->DateCloture = $row->date_cloture;
$item->Type = $row->type_comptes;
$mode_diffusion = explode(',', $row->mode_diffusion);
//@todo : si présence de fichier alors mode T
if (in_array('T',$mode_diffusion)) {
$item->ModeDiffusion = 'T';
} elseif (in_array('C',$mode_diffusion)) {
$item->ModeDiffusion = 'C';
} else {
$item->ModeDiffusion = '';
}
$item->DureeExercice = $row->duree_exercice;
$bilans[] = $item;
}
}
return $bilans;
}
/**
* Download file
* @param string $dateCloture
* Format AAAA-MM-DD
* @param string $type
* sociaux ou consolides
* @throws Exception
* @return string
* Return path (not complete) and filename
*/
public function getCommandeT($dateCloture = null, $type = 'sociaux')
{
$this->mode_diffusion = 'T';
$this->reference_client = 'T'.date('YmdHis');
//Lire dans la base de données
$bilansM = new Application_Model_JoGreffesBilans();
$sql = $bilansM->select()
->where('siren=?', $this->siren)
->where('date_cloture=?', $dateCloture);
if ( $type == 'sociaux' || $type == '' ) {
$sql->where("(type='sociaux' OR type='')");
} else {
$sql->where('type=?',$type);
}
$row = $bilansM->fetchRow($sql);
if ( null === $row ) {
throw new Exception('Not exist');
}
if ($row->pdfLink != '') {
//Set filename
$filename = $this->getFilePath($type, $dateCloture) .
DIRECTORY_SEPARATOR .
$this->getFileName($type, $dateCloture);
//Check if filename exist
if ( !file_exists($this->config->storage->path . DIRECTORY_SEPARATOR . $filename) ) {
throw new Exception('File not found');
}
} else {
$this->greffe = $row->numGreffe;
$this->dossier_millesime = substr($row->numRC,0,2);
$this->dossier_statut = substr($row->numRC,2,1);
$this->dossier_chrono = substr($row->numRC,3);
$this->num_depot = $row->num_depot;
$this->date_cloture = $row->date_cloture;
try {
$xml = $this->callRequest();
} catch(Exception $e) {
//@todo : Error
//Erreur commande webservice
throw new Exception($e->getMessage(), $e->getCode());
}
$bilan = $this->formatItem($xml);
$url = $bilan['url_acces'];
if (empty($url)) {
throw new Exception('File url not given');
}
//Set the filename
$filename = $this->getFilePath($type, $dateCloture) .
DIRECTORY_SEPARATOR .
$this->getFileName($type, $dateCloture);
//Récupérer le fichier
$getfile = $this->download($url, $filename);
//Analyser le fichier - Nombre de page et taille
$infos = $this->pdfInfos($getfile);
//Enregistrer les infos du fichier dans la base de données
if (false !== $infos) {
$this->dbSetFile($filename, $infos['size'], $infos['pages'], $infos['version']);
}
}
return $filename;
}
/**
* @todo : Vérifier fonctionnement
* @param string $dateCloture
* @param string $type
* @param string $reference
* @throws Exception
* @return boolean
*/
public function getCommandeC($dateCloture = null, $type = 'sociaux', $reference = '')
{
$this->mode_diffusion = 'C';
//Lire dans la base de données
$bilansM = new Application_Model_JoGreffesBilans();
$sql = $bilansM->select()
->where('siren=?', $this->siren)
->where('date_cloture=?', $dateCloture);
if ($type=='sociaux') {
$sql->where("(type='sociaux' OR type='')");
} else {
$sql->where('type=?',$type);
}
$row = $bilansM->fetchRow($sql);
if ( null === $row ) {
throw new Exception('Not exist');
}
$this->reference_client = $reference;
//Générer les paramètres de commande depuis la base de données
$this->greffe = $row->numGreffe;
$this->dossier_millesime = substr($row->numRC,0,2);
$this->dossier_statut = substr($row->numRC,2,1);
$this->dossier_chrono = substr($row->numRC,3);
$this->num_depot = $row->num_depot;
$this->date_cloture = $row->date_cloture;
//Faire la requete
try {
$xml = $this->callRequest();
} catch(Exception $e) {
//@todo : Gestion des erreurs
return false;
}
return true;
}
/**
* Name of file
* @param string $type
* @param string $dateCloture
* Format : AAAAMMJJ
* @return string
*/
public function getFileName($type, $dateCloture)
{
if ($type=='') {
$type = 'sociaux';
}
return 'bilan-' . $this->siren . '-' . $type . '-' . $dateCloture . '.pdf';
}
/**
* Path of file
* @param string $type
* @param string $dateCloture
* Format : AAAAMMJJ
* @return string
*/
public function getFilePath($type, $dateCloture)
{
if ($type=='') {
$type = 'sociaux';
}
return 'bilans' . DIRECTORY_SEPARATOR . $type . DIRECTORY_SEPARATOR . substr($dateCloture,0,4);
}
/**
* Format XML to Array for a list of items
* @param string $xml
* @return array
*/
protected function formatList($xml)
{
//Parse XML to make an array
$doc = new DOMDocument();
$doc->loadXML($xml);
$liste_bilan_complet = $doc->getElementsByTagName('liste_bilan_complet')->item(0);
$bilan_complet = $liste_bilan_complet->getElementsByTagName('bilan_complet');
$bilans = array();
if ( count($bilan_complet)>0 )
{
foreach( $bilan_complet as $element )
{
$bilan = array();
$num_gest = $element->getElementsByTagName('num_gest')->item(0);
$bilan['num_gest']['greffe'] = $num_gest->getElementsByTagName('greffe')->item(0)->nodeValue;
$bilan['num_gest']['dossier_millesime'] = $num_gest->getElementsByTagName('dossier_millesime')->item(0)->nodeValue;
$bilan['num_gest']['dossier_statut'] = $num_gest->getElementsByTagName('dossier_statut')->item(0)->nodeValue;
$bilan['num_gest']['dossier_chrono'] = $num_gest->getElementsByTagName('dossier_chrono')->item(0)->nodeValue;
$bilan['dossier_millesime'] = $num_gest->getElementsByTagName('dossier_millesime')->item(0)->nodeValue;
$bilan['dossier_statut'] = $num_gest->getElementsByTagName('dossier_statut')->item(0)->nodeValue;
$bilan['dossier_chrono'] = $num_gest->getElementsByTagName('dossier_chrono')->item(0)->nodeValue;
$bilan['num_siren'] = $element->getElementsByTagName('num_siren')->item(0)->nodeValue;
$bilan['date_cloture'] = $element->getElementsByTagName('date_cloture')->item(0)->nodeValue;
$bilan['date_cloture_iso'] = $element->getElementsByTagName('date_cloture_iso')->item(0)->nodeValue;
$bilan['millesime'] = $element->getElementsByTagName('millesime')->item(0)->nodeValue;
$bilan['num_depot'] = $element->getElementsByTagName('num_depot')->item(0)->nodeValue;
$bilan['type_comptes'] = $element->getElementsByTagName('type_comptes')->item(0)->nodeValue;
$mode_diffusion = $element->getElementsByTagName('mode_diffusion')->item(0)->getElementsByTagName('mode');
foreach($mode_diffusion as $mode)
{
$bilan['mode_diffusion'][] = $mode->getAttribute('type');
}
//Enregistrer dans la bdd
$this->dbUpdateItem($bilan);
//Génération de l'index pour le tri
$date = $bilan['date_cloture_iso'];
if( !empty($date) )
{
$key = substr($date,0,4).substr($date,5,2).substr($date,8,2).'-'.$bilan['num_depot'];
//Affectation liste générale avec un index permettant le tri
$bilans[$key] = $bilan;
}
}
}
krsort($bilans);
return $bilans;
}
/**
* Format XML to Array for one item
* @param string $xml
* @return array
*/
protected function formatItem($xml)
{
$doc = new DOMDocument();
$doc->loadXML($xml);
$bilan_complet = $doc->getElementsByTagName('bilan_complet')->item(0);
$bilan = array();
$bilan['num_gest'] = array();
$num_gest = $bilan_complet->getElementsByTagName('num_gest')->item(0);
$bilan['num_gest']['greffe'] = $num_gest->getElementsByTagName('greffe')->item(0)->nodeValue;
$bilan['num_gest']['dossier_millesime'] = $num_gest->getElementsByTagName('dossier_millesime')->item(0)->nodeValue;
$bilan['num_gest']['dossier_statut'] = $num_gest->getElementsByTagName('dossier_statut')->item(0)->nodeValue;
$bilan['num_gest']['dossier_chrono'] = $num_gest->getElementsByTagName('dossier_chrono')->item(0)->nodeValue;
$bilan['num_siren'] = $bilan_complet->getElementsByTagName('num_siren')->item(0)->nodeValue;
$bilan['date_cloture'] = $bilan_complet->getElementsByTagName('date_cloture')->item(0)->nodeValue;
$bilan['date_cloture_iso'] = $bilan_complet->getElementsByTagName('date_cloture_iso')->item(0)->nodeValue;
$bilan['millesime'] = $bilan_complet->getElementsByTagName('millesime')->item(0)->nodeValue;
$bilan['num_depot'] = $bilan_complet->getElementsByTagName('num_depot')->item(0)->nodeValue;
$bilan['type_comptes'] = $bilan_complet->getElementsByTagName('type_comptes')->item(0)->nodeValue;
$bilan['url_acces'] = $bilan_complet->getElementsByTagName('url_acces')->item(0)->nodeValue;
return $bilan;
}
/**
* Update informations about an item in database
* @param array $list
* @return boolean
*/
protected function dbUpdateItem($list)
{
//Insert or Update
$data = array(
'siren' => $list['num_siren'],
'numRC' => $list['num_gest']['dossier_millesime'].
$list['num_gest']['dossier_statut'].$list['num_gest']['dossier_chrono'],
//'numRC2' => '',
'numGreffe' => $list['num_gest']['greffe'],
'millesime' => $list['millesime'],
'num_depot' => $list['num_depot'],
'date_cloture' => $list['date_cloture_iso'],
'type_comptes' => $list['type_comptes'],
'mode_diffusion' => join(',',$list['mode_diffusion']),
);
try {
$bilanM = new Application_Model_JoGreffesBilans();
$sql = $bilanM->select()
->where('siren=?', $this->siren)
->where('date_cloture=?', $list['date_cloture_iso']);
if ( null === $bilanM->fetchRow($sql) ) {
$result = $bilanM->insert($data);
} else {
$result = $bilanM->update($data, array(
'siren="'.$list['num_siren'].'"',
'date_cloture="'.$list['date_cloture_iso'].'"',
));
}
} catch(Zend_Db_Adapter_Exception $e) {
throw new Exception($e->getMessage());
} catch(Zend_Db_Exception $e) {
throw new Exception($e->getMessage());
}
if ($result) {
return true;
}
return false;
}
/**
* Set file informations in database
* @param string $filename
* @param int $size
* @param int $numberOfPage
* @param string $version
* @return boolean
*/
public function dbSetFile($filename, $size, $numberOfPage, $version)
{
$data = array(
'pdfLink' => $filename,
'pdfSize' => $size,
'pdfPage' => $numberOfPage,
'pdfVer' => $version,
'pdfDate' => date('Ymd'),
);
$where = array(
'siren='.$this->siren,
'date_cloture="'.substr($this->date_cloture,0,4).'-'.substr($this->date_cloture,4,2).'-'.substr($this->date_cloture,6,2).'"',
'type_comptes="'.$this->type_comptes.'"',
);
try {
$bilanM = new Application_Model_JoGreffesBilans();
$result = $bilanM->update($data, $where);
} catch(Zend_Db_Adapter_Exception $e) {
throw new Exception($e->getMessage());
} catch(Zend_Db_Exception $e) {
throw new Exception($e->getMessage());
}
if ($result) {
return true;
}
return false;
}
}

View File

@ -0,0 +1 @@
<?php

View File

@ -0,0 +1,54 @@
INFOGREFFE
----------
Document
AC =>
BI =>
ST =>
File name pattern
AC => acte-[siren]-[type]-[YYYYMMdd]-[num].pdf
siren = [0-9]{9}
type =
num = [0-9]{2}
Files are store in actes/YYYY/MM/filename.pdf
BI => bilan-[siren]-[type]-[YYYYMMdd].pdf
siren = [0-9]{9}
type = [consolide|sociaux]
Files are store in bilans/[type]/[YYYY];
ST => statut-
Files are store in status/
Configuration
-------------
Add to the main configuration (application.ini), these keys :
- infogreffe.cache.path => path for storing cache file
- infogreffe.cache.time => define end of life for the cache in hours
- infogreffe.storage.path =>
- infogreffe.wsdl = infogreffe.wsdl
- infogreffe.url = https://webservices.infogreffe.fr/WSContextInfogreffe/INFOGREFFE
- infogreffe.uri = https://webservices.infogreffe.fr/
- infogreffe.user = 85000109
- infogreffe.password = 166
- Rattraper l'historique des documents et les liés à jo.greffes_bilans et jo.greffes_actes
Attention : Type de document 1 et 2
Vérifier que nous possèdons le maximum d'infos sur l'association type 1 et 2
Sinon passer une moulinette, pour chaque siren, récupérer la liste et analyse avec la table actes_files
jo.greffes_actes : Ajout d'une colonne type_acte2
Il est possible sans le type de trouver le fichier
SELECT siren, count(siren) as nb FROM `actes_files` WHERE `type_libelle` = '' GROUP BY siren ORDER BY nb DESC

View File

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

View File

@ -0,0 +1,93 @@
<?php
class Metier_Sfr_Compile
{
/**
* Database adaptater
* @var Zend_Db_Adapter_Abstract
*/
protected $db;
/**
*
* @var string
*/
protected $version = null;
protected $compileTxt = "<?php\n";
public function __construct($db = null)
{
if ( null === $db) {
$this->db = Zend_Db_Table_Abstract::getDefaultAdapter();
} else {
$this->db = $db;
}
}
public function setVersion($version)
{
$this->version = $version;
}
public function getRulesFromDb($type)
{
$version = str_replace('.','',$this->version);
$sql = "SELECT * FROM jo.sfr_rules_".$version." AS r WHERE r.type='".$type."' ORDER BY r.ordre";
$result = $this->db->fetchAll($sql, array(), Zend_Db::FETCH_OBJ);
return $result;
}
public function getParamsFromDb($type, $codif)
{
$version = str_replace('.','',$this->version);
$sql = "SELECT * FROM jo.sfr_params_".$version." AS p WHERE p.type='".$type."' AND p.codif='".$codif."' ORDER BY p.ordre";
$result = $this->db->fetchAll($sql, array(), Zend_Db::FETCH_OBJ);
return $result;
}
public function construct($type)
{
$rules = $this->getRulesFromDb($type);
if ( count($rules) > 0 ) {
$this->compileTxt.= "return array(\n";
$this->addRules($rules);
$this->compileTxt.= ");\n";
}
$filename = realpath(__DIR__).'/Rules'.ucfirst(strtolower($type)).'-'.$this->version.'.php';
file_put_contents($filename, $this->compileTxt);
}
public function addRules($rules)
{
foreach ( $rules as $i => $rule ) {
$this->compileTxt.= "\t".$i." => array(\n";
$this->compileTxt.= "\t\t'name' => '".$rule->label."',\n";
$this->compileTxt.= "\t\t'value' => '".$rule->value."',\n";
$this->compileTxt.= "\t\t'po' => ".$rule->po.",\n";
$this->compileTxt.= "\t\t'comment' => \"".$rule->comment."\",\n";
$this->compileTxt.= "\t\t'params' => array(\n";
$this->addParams($rule->type, $rule->codif);
$this->compileTxt.= "\t\t),\n";
$this->compileTxt.= "\t),\n";
}
}
public function addParams($type, $codif)
{
$params = $this->getParamsFromDb($type, $codif);
if ( count($params) > 0 ) {
foreach ( $params as $i => $param ) {
if ( $param->define == '') {
$this->compileTxt.= "\t\t\t".$i." => array( 'var' => '".$param->var."', 'type' => '".$param->cond."', 'value' => '".$param->value."'),\n";
} else {
$this->compileTxt.= "\t\t\t".$i." => array( 'var' => '".$param->var."', 'type' => '".$param->cond."', 'value' => '".$param->value."', 'define' => array( 'var' => '".$param->define."', 'value' => '".$param->define_value."')),\n";
}
}
}
}
}

View File

@ -0,0 +1,492 @@
<?php
return array(
0 => array(
'name' => 'PO-NAF-GE',
'value' => '6000',
'comment' => "",
'params' => array(
0 => array( 'var' => 'NAF', 'type' => 'LIST', 'value' => 'TabNafSFR'),
1 => array( 'var' => 'Indiscore', 'type' => 'EGAL', 'value' => '6'),
2 => array( 'var' => 'TypeEntrep', 'type' => 'EGAL', 'value' => 'GE'),
),
),
1 => array(
'name' => 'PO-NAF-GE',
'value' => '12000',
'comment' => "",
'params' => array(
0 => array( 'var' => 'NAF', 'type' => 'LIST', 'value' => 'TabNafSFR'),
1 => array( 'var' => 'Indiscore', 'type' => 'EGAL', 'value' => '7'),
2 => array( 'var' => 'TypeEntrep', 'type' => 'EGAL', 'value' => 'GE'),
),
),
2 => array(
'name' => 'PO-NAF-GE',
'value' => '25000',
'comment' => "",
'params' => array(
0 => array( 'var' => 'NAF', 'type' => 'LIST', 'value' => 'TabNafSFR'),
1 => array( 'var' => 'Indiscore', 'type' => 'EGAL', 'value' => '8'),
2 => array( 'var' => 'TypeEntrep', 'type' => 'EGAL', 'value' => 'GE'),
),
),
3 => array(
'name' => 'PO-NAF-GE',
'value' => '45000',
'comment' => "",
'params' => array(
0 => array( 'var' => 'NAF', 'type' => 'LIST', 'value' => 'TabNafSFR'),
1 => array( 'var' => 'Indiscore', 'type' => 'EGAL', 'value' => '9'),
2 => array( 'var' => 'TypeEntrep', 'type' => 'EGAL', 'value' => 'GE'),
),
),
4 => array(
'name' => 'PO-NAF-PME',
'value' => '4600',
'comment' => "",
'params' => array(
0 => array( 'var' => 'NAF', 'type' => 'LIST', 'value' => 'TabNafSFR'),
1 => array( 'var' => 'Indiscore', 'type' => 'EGAL', 'value' => '6'),
2 => array( 'var' => 'TypeEntrep', 'type' => 'EGAL', 'value' => 'PME'),
),
),
5 => array(
'name' => 'PO-NAF-PME',
'value' => '5700',
'comment' => "",
'params' => array(
0 => array( 'var' => 'NAF', 'type' => 'LIST', 'value' => 'TabNafSFR'),
1 => array( 'var' => 'Indiscore', 'type' => 'EGAL', 'value' => '7'),
2 => array( 'var' => 'TypeEntrep', 'type' => 'EGAL', 'value' => 'PME'),
),
),
6 => array(
'name' => 'PO-NAF-PME',
'value' => '14000',
'comment' => "",
'params' => array(
0 => array( 'var' => 'NAF', 'type' => 'LIST', 'value' => 'TabNafSFR'),
1 => array( 'var' => 'Indiscore', 'type' => 'EGAL', 'value' => '8'),
2 => array( 'var' => 'TypeEntrep', 'type' => 'EGAL', 'value' => 'PME'),
),
),
7 => array(
'name' => 'PO-NAF-PME',
'value' => '19000',
'comment' => "",
'params' => array(
0 => array( 'var' => 'NAF', 'type' => 'LIST', 'value' => 'TabNafSFR'),
1 => array( 'var' => 'Indiscore', 'type' => 'EGAL', 'value' => '9'),
2 => array( 'var' => 'TypeEntrep', 'type' => 'EGAL', 'value' => 'PME'),
),
),
8 => array(
'name' => 'PO-NAF-PME',
'value' => '700',
'comment' => "",
'params' => array(
0 => array( 'var' => 'NAF', 'type' => 'LIST', 'value' => 'TabNafSFR'),
1 => array( 'var' => 'Indiscore', 'type' => 'EGAL', 'value' => '6'),
2 => array( 'var' => 'TypeEntrep', 'type' => 'EGAL', 'value' => 'TPE'),
),
),
9 => array(
'name' => 'PO-NAF-PME',
'value' => '1000',
'comment' => "",
'params' => array(
0 => array( 'var' => 'NAF', 'type' => 'LIST', 'value' => 'TabNafSFR'),
1 => array( 'var' => 'Indiscore', 'type' => 'EGAL', 'value' => '7'),
2 => array( 'var' => 'TypeEntrep', 'type' => 'EGAL', 'value' => 'TPE'),
),
),
10 => array(
'name' => 'PO-NAF-PME',
'value' => '1100',
'comment' => "",
'params' => array(
0 => array( 'var' => 'NAF', 'type' => 'LIST', 'value' => 'TabNafSFR'),
1 => array( 'var' => 'Indiscore', 'type' => 'EGAL', 'value' => '8'),
2 => array( 'var' => 'TypeEntrep', 'type' => 'EGAL', 'value' => 'TPE'),
),
),
11 => array(
'name' => 'PO-NAF-PME',
'value' => '2800',
'comment' => "",
'params' => array(
0 => array( 'var' => 'NAF', 'type' => 'LIST', 'value' => 'TabNafSFR'),
1 => array( 'var' => 'Indiscore', 'type' => 'EGAL', 'value' => '9'),
2 => array( 'var' => 'TypeEntrep', 'type' => 'EGAL', 'value' => 'TPE'),
),
),
12 => array(
'name' => 'PO-Date-GE',
'value' => '3000',
'comment' => "",
'params' => array(
0 => array( 'var' => 'InseeAge', 'type' => 'MAX', 'value' => '37'),
1 => array( 'var' => 'Indiscore', 'type' => 'EGAL', 'value' => '6'),
2 => array( 'var' => 'TypeEntrep', 'type' => 'EGAL', 'value' => 'GE'),
),
),
13 => array(
'name' => 'PO-Date-GE',
'value' => '3000',
'comment' => "",
'params' => array(
0 => array( 'var' => 'InseeAge', 'type' => 'MAX', 'value' => '4'),
1 => array( 'var' => 'Indiscore', 'type' => 'EGAL', 'value' => '7'),
2 => array( 'var' => 'TypeEntrep', 'type' => 'EGAL', 'value' => 'GE'),
),
),
14 => array(
'name' => 'PO-Date-GE',
'value' => '3000',
'comment' => "",
'params' => array(
0 => array( 'var' => 'InseeAge', 'type' => 'MAX', 'value' => '37'),
1 => array( 'var' => 'Indiscore', 'type' => 'EGAL', 'value' => '8'),
2 => array( 'var' => 'TypeEntrep', 'type' => 'EGAL', 'value' => 'GE'),
),
),
15 => array(
'name' => 'PO-Date-GE',
'value' => '5000',
'comment' => "",
'params' => array(
0 => array( 'var' => 'InseeAge', 'type' => 'MAX', 'value' => '37'),
1 => array( 'var' => 'Indiscore', 'type' => 'EGAL', 'value' => '9'),
2 => array( 'var' => 'TypeEntrep', 'type' => 'EGAL', 'value' => 'GE'),
),
),
16 => array(
'name' => 'PO-Date-GE',
'value' => '5000',
'comment' => "",
'params' => array(
0 => array( 'var' => 'InseeAge', 'type' => 'MAX', 'value' => '37'),
1 => array( 'var' => 'Indiscore', 'type' => 'EGAL', 'value' => '10'),
2 => array( 'var' => 'TypeEntrep', 'type' => 'EGAL', 'value' => 'GE'),
),
),
17 => array(
'name' => 'PO-Date-GE',
'value' => '5000',
'comment' => "",
'params' => array(
0 => array( 'var' => 'InseeAge', 'type' => 'MAX', 'value' => '37'),
1 => array( 'var' => 'Indiscore', 'type' => 'EGAL', 'value' => '11'),
2 => array( 'var' => 'TypeEntrep', 'type' => 'EGAL', 'value' => 'GE'),
),
),
18 => array(
'name' => 'PO-Date-GE',
'value' => '10000',
'comment' => "",
'params' => array(
0 => array( 'var' => 'InseeAge', 'type' => 'MAX', 'value' => '37'),
1 => array( 'var' => 'Indiscore', 'type' => 'EGAL', 'value' => '12'),
2 => array( 'var' => 'TypeEntrep', 'type' => 'EGAL', 'value' => 'GE'),
),
),
19 => array(
'name' => 'PO-Date-GE',
'value' => '10000',
'comment' => "",
'params' => array(
0 => array( 'var' => 'InseeAge', 'type' => 'MAX', 'value' => '37'),
1 => array( 'var' => 'Indiscore', 'type' => 'EGAL', 'value' => '13'),
2 => array( 'var' => 'TypeEntrep', 'type' => 'EGAL', 'value' => 'GE'),
),
),
20 => array(
'name' => 'PO-Date-GE',
'value' => '10000',
'comment' => "",
'params' => array(
0 => array( 'var' => 'InseeAge', 'type' => 'MAX', 'value' => '37'),
1 => array( 'var' => 'Indiscore', 'type' => 'EGAL', 'value' => '14'),
2 => array( 'var' => 'TypeEntrep', 'type' => 'EGAL', 'value' => 'GE'),
),
),
21 => array(
'name' => 'PO-Date-PME',
'value' => '1500',
'comment' => "",
'params' => array(
0 => array( 'var' => 'InseeAge', 'type' => 'MAX', 'value' => '37'),
1 => array( 'var' => 'Indiscore', 'type' => 'EGAL', 'value' => '6'),
2 => array( 'var' => 'TypeEntrep', 'type' => 'EGAL', 'value' => 'PME'),
),
),
22 => array(
'name' => 'PO-Date-PME',
'value' => '1500',
'comment' => "",
'params' => array(
0 => array( 'var' => 'InseeAge', 'type' => 'MAX', 'value' => '37'),
1 => array( 'var' => 'Indiscore', 'type' => 'EGAL', 'value' => '7'),
2 => array( 'var' => 'TypeEntrep', 'type' => 'EGAL', 'value' => 'PME'),
),
),
23 => array(
'name' => 'PO-Date-PME',
'value' => '1500',
'comment' => "",
'params' => array(
0 => array( 'var' => 'InseeAge', 'type' => 'MAX', 'value' => '37'),
1 => array( 'var' => 'Indiscore', 'type' => 'EGAL', 'value' => '8'),
2 => array( 'var' => 'TypeEntrep', 'type' => 'EGAL', 'value' => 'PME'),
),
),
24 => array(
'name' => 'PO-Date-PME',
'value' => '6000',
'comment' => "",
'params' => array(
0 => array( 'var' => 'InseeAge', 'type' => 'MAX', 'value' => '37'),
1 => array( 'var' => 'Indiscore', 'type' => 'EGAL', 'value' => '9'),
2 => array( 'var' => 'TypeEntrep', 'type' => 'EGAL', 'value' => 'PME'),
),
),
25 => array(
'name' => 'PO-Date-PME',
'value' => '6000',
'comment' => "",
'params' => array(
0 => array( 'var' => 'InseeAge', 'type' => 'MAX', 'value' => '4'),
1 => array( 'var' => 'Indiscore', 'type' => 'EGAL', 'value' => '10'),
2 => array( 'var' => 'TypeEntrep', 'type' => 'EGAL', 'value' => 'PME'),
),
),
26 => array(
'name' => 'PO-Date-PME',
'value' => '6000',
'comment' => "",
'params' => array(
0 => array( 'var' => 'InseeAge', 'type' => 'MAX', 'value' => '37'),
1 => array( 'var' => 'Indiscore', 'type' => 'EGAL', 'value' => '11'),
2 => array( 'var' => 'TypeEntrep', 'type' => 'EGAL', 'value' => 'PME'),
),
),
27 => array(
'name' => 'PO-Date-PME',
'value' => '9000',
'comment' => "",
'params' => array(
0 => array( 'var' => 'InseeAge', 'type' => 'MAX', 'value' => '37'),
1 => array( 'var' => 'Indiscore', 'type' => 'EGAL', 'value' => '12'),
2 => array( 'var' => 'TypeEntrep', 'type' => 'EGAL', 'value' => 'PME'),
),
),
28 => array(
'name' => 'PO-Date-PME',
'value' => '9000',
'comment' => "",
'params' => array(
0 => array( 'var' => 'InseeAge', 'type' => 'MAX', 'value' => '37'),
1 => array( 'var' => 'Indiscore', 'type' => 'EGAL', 'value' => '13'),
2 => array( 'var' => 'TypeEntrep', 'type' => 'EGAL', 'value' => 'PME'),
),
),
29 => array(
'name' => 'PO-Date-PME',
'value' => '9000',
'comment' => "",
'params' => array(
0 => array( 'var' => 'InseeAge', 'type' => 'MAX', 'value' => '37'),
1 => array( 'var' => 'Indiscore', 'type' => 'EGAL', 'value' => '14'),
2 => array( 'var' => 'TypeEntrep', 'type' => 'EGAL', 'value' => 'PME'),
),
),
30 => array(
'name' => 'PO-Date-TPE',
'value' => '500',
'comment' => "",
'params' => array(
0 => array( 'var' => 'InseeAge', 'type' => 'MAX', 'value' => '37'),
1 => array( 'var' => 'Indiscore', 'type' => 'EGAL', 'value' => '6'),
2 => array( 'var' => 'TypeEntrep', 'type' => 'EGAL', 'value' => 'TPE'),
),
),
31 => array(
'name' => 'PO-Date-TPE',
'value' => '500',
'comment' => "",
'params' => array(
0 => array( 'var' => 'InseeAge', 'type' => 'MAX', 'value' => '37'),
1 => array( 'var' => 'Indiscore', 'type' => 'EGAL', 'value' => '7'),
2 => array( 'var' => 'TypeEntrep', 'type' => 'EGAL', 'value' => 'TPE'),
),
),
32 => array(
'name' => 'PO-Date-TPE',
'value' => '500',
'comment' => "",
'params' => array(
0 => array( 'var' => 'InseeAge', 'type' => 'MAX', 'value' => '37'),
1 => array( 'var' => 'Indiscore', 'type' => 'EGAL', 'value' => '8'),
2 => array( 'var' => 'TypeEntrep', 'type' => 'EGAL', 'value' => 'TPE'),
),
),
33 => array(
'name' => 'PO-Date-TPE',
'value' => '1000',
'comment' => "",
'params' => array(
0 => array( 'var' => 'InseeAge', 'type' => 'MAX', 'value' => '37'),
1 => array( 'var' => 'Indiscore', 'type' => 'EGAL', 'value' => '9'),
2 => array( 'var' => 'TypeEntrep', 'type' => 'EGAL', 'value' => 'TPE'),
),
),
34 => array(
'name' => 'PO-Date-TPE',
'value' => '1000',
'comment' => "",
'params' => array(
0 => array( 'var' => 'InseeAge', 'type' => 'MAX', 'value' => '4'),
1 => array( 'var' => 'Indiscore', 'type' => 'EGAL', 'value' => '10'),
2 => array( 'var' => 'TypeEntrep', 'type' => 'EGAL', 'value' => 'TPE'),
),
),
35 => array(
'name' => 'PO-Date-TPE',
'value' => '1000',
'comment' => "",
'params' => array(
0 => array( 'var' => 'InseeAge', 'type' => 'MAX', 'value' => '37'),
1 => array( 'var' => 'Indiscore', 'type' => 'EGAL', 'value' => '11'),
2 => array( 'var' => 'TypeEntrep', 'type' => 'EGAL', 'value' => 'TPE'),
),
),
36 => array(
'name' => 'PO-Date-TPE',
'value' => '1500',
'comment' => "",
'params' => array(
0 => array( 'var' => 'InseeAge', 'type' => 'MAX', 'value' => '37'),
1 => array( 'var' => 'Indiscore', 'type' => 'EGAL', 'value' => '12'),
2 => array( 'var' => 'TypeEntrep', 'type' => 'EGAL', 'value' => 'TPE'),
),
),
37 => array(
'name' => 'PO-Date-TPE',
'value' => '1500',
'comment' => "",
'params' => array(
0 => array( 'var' => 'InseeAge', 'type' => 'MAX', 'value' => '37'),
1 => array( 'var' => 'Indiscore', 'type' => 'EGAL', 'value' => '13'),
2 => array( 'var' => 'TypeEntrep', 'type' => 'EGAL', 'value' => 'TPE'),
),
),
38 => array(
'name' => 'PO-Date-TPE',
'value' => '1500',
'comment' => "",
'params' => array(
0 => array( 'var' => 'InseeAge', 'type' => 'MAX', 'value' => '37'),
1 => array( 'var' => 'Indiscore', 'type' => 'EGAL', 'value' => '14'),
2 => array( 'var' => 'TypeEntrep', 'type' => 'EGAL', 'value' => 'TPE'),
),
),
39 => array(
'name' => 'PO-STD-GE',
'value' => '6000',
'comment' => "",
'params' => array(
0 => array( 'var' => 'Indiscore', 'type' => 'EGAL', 'value' => '6'),
1 => array( 'var' => 'TypeEntrep', 'type' => 'EGAL', 'value' => 'GE'),
),
),
40 => array(
'name' => 'PO-STD-GE',
'value' => '10000',
'comment' => "",
'params' => array(
0 => array( 'var' => 'Indiscore', 'type' => 'EGAL', 'value' => '7'),
1 => array( 'var' => 'TypeEntrep', 'type' => 'EGAL', 'value' => 'GE'),
),
),
41 => array(
'name' => 'PO-STD-GE',
'value' => '20000',
'comment' => "",
'params' => array(
0 => array( 'var' => 'Indiscore', 'type' => 'EGAL', 'value' => '8'),
1 => array( 'var' => 'TypeEntrep', 'type' => 'EGAL', 'value' => 'GE'),
),
),
42 => array(
'name' => 'PO-STD-PME',
'value' => '3000',
'comment' => "",
'params' => array(
0 => array( 'var' => 'Indiscore', 'type' => 'EGAL', 'value' => '6'),
1 => array( 'var' => 'TypeEntrep', 'type' => 'EGAL', 'value' => 'PME'),
),
),
43 => array(
'name' => 'PO-STD-PME',
'value' => '3700',
'comment' => "",
'params' => array(
0 => array( 'var' => 'Indiscore', 'type' => 'EGAL', 'value' => '7'),
1 => array( 'var' => 'TypeEntrep', 'type' => 'EGAL', 'value' => 'PME'),
),
),
44 => array(
'name' => 'PO-STD-PME',
'value' => '5000',
'comment' => "",
'params' => array(
0 => array( 'var' => 'Indiscore', 'type' => 'EGAL', 'value' => '8'),
1 => array( 'var' => 'TypeEntrep', 'type' => 'EGAL', 'value' => 'PME'),
),
),
45 => array(
'name' => 'PO-STD-PME',
'value' => '9000',
'comment' => "",
'params' => array(
0 => array( 'var' => 'Indiscore', 'type' => 'EGAL', 'value' => '9'),
1 => array( 'var' => 'TypeEntrep', 'type' => 'EGAL', 'value' => 'PME'),
),
),
46 => array(
'name' => 'PO-STD-TPE',
'value' => '500',
'comment' => "",
'params' => array(
0 => array( 'var' => 'Indiscore', 'type' => 'EGAL', 'value' => '6'),
1 => array( 'var' => 'TypeEntrep', 'type' => 'EGAL', 'value' => 'TPE'),
),
),
47 => array(
'name' => 'PO-STD-TPE',
'value' => '600',
'comment' => "",
'params' => array(
0 => array( 'var' => 'Indiscore', 'type' => 'EGAL', 'value' => '7'),
1 => array( 'var' => 'TypeEntrep', 'type' => 'EGAL', 'value' => 'TPE'),
),
),
48 => array(
'name' => 'PO-STD-TPE',
'value' => '1000',
'comment' => "",
'params' => array(
0 => array( 'var' => 'Indiscore', 'type' => 'EGAL', 'value' => '8'),
1 => array( 'var' => 'TypeEntrep', 'type' => 'EGAL', 'value' => 'TPE'),
),
),
49 => array(
'name' => 'PO-STD-TPE',
'value' => '1300',
'comment' => "",
'params' => array(
0 => array( 'var' => 'Indiscore', 'type' => 'EGAL', 'value' => '9'),
1 => array( 'var' => 'TypeEntrep', 'type' => 'EGAL', 'value' => 'TPE'),
),
),
);

View File

@ -0,0 +1,168 @@
<?php
return array(
0 => array(
'name' => 'VORd-11.1',
'value' => 'STOP',
'comment' => "",
'po' => 0,
'params' => array(
0 => array( 'var' => 'ContratAge', 'type' => 'EGAL', 'value' => 'UNDEFINE'),
1 => array( 'var' => 'IR', 'type' => 'EGAL', 'value' => 'UNDEFINE'),
),
),
1 => array(
'name' => 'VORd-11.2',
'value' => 'CONTINUE',
'comment' => "",
'po' => 0,
'params' => array(
0 => array( 'var' => 'ContratAge', 'type' => 'EGAL', 'value' => 'UNDEFINE'),
1 => array( 'var' => 'IR', 'type' => 'MIN', 'value' => '-1', 'define' => array( 'var' => 'ContratAge', 'value' => '24')),
),
),
2 => array(
'name' => 'VORd-11.3',
'value' => 'CONTINUE',
'comment' => "",
'po' => 0,
'params' => array(
0 => array( 'var' => 'ContratAge', 'type' => 'MIN', 'value' => '-1'),
1 => array( 'var' => 'IR', 'type' => 'EGAL', 'value' => 'UNDEFINE', 'define' => array( 'var' => 'IR', 'value' => '8')),
),
),
3 => array(
'name' => 'VORd-10.1',
'value' => 'ROUGE',
'comment' => "Société dont la solvabilité est limitée et qui rencontre des difficultés de paiement : Faire une DEC pour tout acte éligible",
'po' => 0,
'params' => array(
0 => array( 'var' => 'FEU', 'type' => 'EGAL', 'value' => 'VERT'),
1 => array( 'var' => 'IR', 'type' => 'MIN', 'value' => '4.9'),
2 => array( 'var' => 'IR', 'type' => 'MAX', 'value' => '7.1'),
3 => array( 'var' => 'ContratAge', 'type' => 'MAX', 'value' => '25'),
4 => array( 'var' => 'Indiscore', 'type' => 'MIN', 'value' => '9'),
5 => array( 'var' => 'Indiscore', 'type' => 'MAX', 'value' => '12'),
),
),
4 => array(
'name' => 'VORd-10.2',
'value' => 'ORANGE',
'comment' => "",
'po' => 0,
'params' => array(
0 => array( 'var' => 'FEU', 'type' => 'EGAL', 'value' => 'VERT'),
1 => array( 'var' => 'IR', 'type' => 'MIN', 'value' => '4.9'),
2 => array( 'var' => 'IR', 'type' => 'MAX', 'value' => '7.1'),
3 => array( 'var' => 'ContratAge', 'type' => 'MIN', 'value' => '24'),
4 => array( 'var' => 'ContratAge', 'type' => 'MAX', 'value' => '36'),
5 => array( 'var' => 'Indiscore', 'type' => 'MIN', 'value' => '9'),
6 => array( 'var' => 'Indiscore', 'type' => 'MAX', 'value' => '12'),
),
),
5 => array(
'name' => 'VORd-10.3',
'value' => 'ORANGE',
'comment' => "",
'po' => 0,
'params' => array(
0 => array( 'var' => 'FEU', 'type' => 'EGAL', 'value' => 'VERT'),
1 => array( 'var' => 'IR', 'type' => 'MIN', 'value' => '4.9'),
2 => array( 'var' => 'IR', 'type' => 'MAX', 'value' => '7.1'),
3 => array( 'var' => 'ContratAge', 'type' => 'MAX', 'value' => '25'),
4 => array( 'var' => 'Indiscore', 'type' => 'MIN', 'value' => '11'),
5 => array( 'var' => 'Indiscore', 'type' => 'MAX', 'value' => '14'),
),
),
6 => array(
'name' => 'VORd-10.4',
'value' => 'ROUGE',
'comment' => "Société dont la solvabilité est limitée et qui rencontre des difficultés de paiement : Faire une DEC pour tout acte éligible",
'po' => 0,
'params' => array(
0 => array( 'var' => 'FEU', 'type' => 'EGAL', 'value' => 'ORANGE'),
1 => array( 'var' => 'IR', 'type' => 'MAX', 'value' => '2.1'),
2 => array( 'var' => 'ContratAge', 'type' => 'MIN', 'value' => '35'),
),
),
7 => array(
'name' => 'VORd-10.5',
'value' => 'VERT',
'comment' => "",
'po' => 0,
'params' => array(
0 => array( 'var' => 'FEU', 'type' => 'EGAL', 'value' => 'ORANGE'),
1 => array( 'var' => 'IR', 'type' => 'MIN', 'value' => '2'),
2 => array( 'var' => 'IR', 'type' => 'MAX', 'value' => '5'),
3 => array( 'var' => 'ContratAge', 'type' => 'MIN', 'value' => '36'),
4 => array( 'var' => 'Indiscore', 'type' => 'MIN', 'value' => '7'),
),
),
8 => array(
'name' => 'VORd-10.6',
'value' => 'ROUGE',
'comment' => "Société dont la solvabilité est limitée et qui rencontre des difficultés de paiement : Faire une DEC pour tout acte éligible",
'po' => 0,
'params' => array(
0 => array( 'var' => 'FEU', 'type' => 'EGAL', 'value' => 'ORANGE'),
1 => array( 'var' => 'EntrepRecente', 'type' => 'EGAL', 'value' => '1'),
2 => array( 'var' => 'IR', 'type' => 'MAX', 'value' => '2.1'),
3 => array( 'var' => 'ContratAge', 'type' => 'MAX', 'value' => '36'),
),
),
9 => array(
'name' => 'VORd-10.7',
'value' => 'ROUGE',
'comment' => "Société dont la solvabilité est limitée et qui rencontre des difficultés de paiement : Faire une DEC pour tout acte éligible",
'po' => 0,
'params' => array(
0 => array( 'var' => 'FEU', 'type' => 'EGAL', 'value' => 'ORANGE'),
1 => array( 'var' => 'EntrepRecente', 'type' => 'EGAL', 'value' => '1'),
2 => array( 'var' => 'ContratAge', 'type' => 'MAX', 'value' => '25'),
3 => array( 'var' => 'IR', 'type' => 'MIN', 'value' => '4.9'),
4 => array( 'var' => 'IR', 'type' => 'MAX', 'value' => '7.1'),
5 => array( 'var' => 'Indiscore', 'type' => 'MIN', 'value' => '9'),
6 => array( 'var' => 'Indiscore', 'type' => 'MAX', 'value' => '12'),
),
),
10 => array(
'name' => 'VORd-10.8',
'value' => 'VERT',
'comment' => "",
'po' => 0,
'params' => array(
0 => array( 'var' => 'FEU', 'type' => 'EGAL', 'value' => 'ORANGE'),
1 => array( 'var' => 'EntrepRecente', 'type' => 'EGAL', 'value' => '1'),
2 => array( 'var' => 'IR', 'type' => 'MIN', 'value' => '4.9'),
3 => array( 'var' => 'IR', 'type' => 'MAX', 'value' => '7.1'),
4 => array( 'var' => 'ContratAge', 'type' => 'MIN', 'value' => '36'),
5 => array( 'var' => 'Indiscore', 'type' => 'MIN', 'value' => '11'),
),
),
11 => array(
'name' => 'VORd-10.8-2',
'value' => 'VERT',
'comment' => "",
'po' => 0,
'params' => array(
0 => array( 'var' => 'FEU', 'type' => 'EGAL', 'value' => 'ORANGE'),
1 => array( 'var' => 'EntrepRecente', 'type' => 'EGAL', 'value' => '1'),
2 => array( 'var' => 'IR', 'type' => 'MIN', 'value' => '4.9'),
3 => array( 'var' => 'IR', 'type' => 'MAX', 'value' => '7.1'),
4 => array( 'var' => 'ContratAge', 'type' => 'MIN', 'value' => '24'),
5 => array( 'var' => 'Indiscore', 'type' => 'MIN', 'value' => '13'),
),
),
12 => array(
'name' => 'VORd-10.9',
'value' => 'ORANGE',
'comment' => "Faire une DEC si dépassement de la PO proposée",
'po' => 0,
'params' => array(
0 => array( 'var' => 'FEU', 'type' => 'EGAL', 'value' => 'ROUGE'),
1 => array( 'var' => 'IR', 'type' => 'MIN', 'value' => '2'),
2 => array( 'var' => 'IR', 'type' => 'MAX', 'value' => '5'),
3 => array( 'var' => 'ContratAge', 'type' => 'MIN', 'value' => '36'),
4 => array( 'var' => 'Indiscore', 'type' => 'MIN', 'value' => '3'),
),
),
);

View File

@ -0,0 +1,164 @@
<?php
return array(
0 => array(
'name' => 'VORp-1.0',
'value' => 'DEFINE',
'comment' => "",
'po' => 0,
'params' => array(
0 => array( 'var' => 'IsCAC', 'type' => 'EGAL', 'value' => '1', 'define' => array( 'var' => 'TypeEntrep', 'value' => 'CAC')),
1 => array( 'var' => 'Effectif', 'type' => 'MIN', 'value' => '499', 'define' => array( 'var' => 'TypeEntrep', 'value' => 'GE')),
2 => array( 'var' => 'Effectif', 'type' => 'MIN', 'value' => '3', 'define' => array( 'var' => 'TypeEntrep', 'value' => 'PME')),
3 => array( 'var' => 'Effectif', 'type' => 'MIN', 'value' => '-1', 'define' => array( 'var' => 'TypeEntrep', 'value' => 'TPE')),
4 => array( 'var' => 'Effectif', 'type' => 'EGAL', 'value' => 'UNDEFINE', 'define' => array( 'var' => 'TypeEntrep', 'value' => 'TPE')),
),
),
1 => array(
'name' => 'VORp-2.1',
'value' => 'VERT',
'comment' => "",
'po' => 0,
'params' => array(
0 => array( 'var' => 'NAF', 'type' => 'LIST', 'value' => 'TabAdminNaf', 'define' => array( 'var' => 'IsAdmin', 'value' => '1')),
),
),
2 => array(
'name' => 'VORp-2.2',
'value' => 'VERT',
'comment' => "",
'po' => 0,
'params' => array(
0 => array( 'var' => 'FJ', 'type' => 'LIST', 'value' => 'TabAdminFj', 'define' => array( 'var' => 'IsAdmin', 'value' => '1')),
),
),
3 => array(
'name' => 'VORp-3.1',
'value' => 'ROUGE',
'comment' => "Société de droit étranger : faire une DEC si volonté de poursuivre l'affaire",
'po' => 0,
'params' => array(
0 => array( 'var' => 'NAF', 'type' => 'LIST', 'value' => 'TabEtrangerNaf', 'define' => array( 'var' => 'IsEtranger', 'value' => '1')),
),
),
4 => array(
'name' => 'VORp-3.2',
'value' => 'ROUGE',
'comment' => "Société de droit étranger : faire une DEC si volonté de poursuivre l'affaire",
'po' => 0,
'params' => array(
0 => array( 'var' => 'FJ', 'type' => 'LIST', 'value' => 'TabEtrangerFj', 'define' => array( 'var' => 'IsEtranger', 'value' => '1')),
),
),
5 => array(
'name' => 'VORp-4.1',
'value' => 'ROUGE',
'comment' => "Cette société fait l'objet d'un Redressement Judiciaire : faire une DEC si volonté de poursuivre l'affaire",
'po' => 0,
'params' => array(
0 => array( 'var' => 'Indiscore', 'type' => 'MAX', 'value' => '6'),
1 => array( 'var' => 'RJ', 'type' => 'EGAL', 'value' => '1'),
),
),
6 => array(
'name' => 'VORp-4.2',
'value' => 'ROUGE',
'comment' => "Cette société fait l'objet d'une liquidation judiciaire : pas d'entrée en relation possible",
'po' => 0,
'params' => array(
0 => array( 'var' => 'Indiscore', 'type' => 'MAX', 'value' => '6'),
1 => array( 'var' => 'LJ', 'type' => 'EGAL', 'value' => '1'),
),
),
7 => array(
'name' => 'VORp-4.3',
'value' => 'ROUGE',
'comment' => "Cette société fait l'objet d'une Sauvegarde Judiciaire : faire une DEC si volonté de poursuivre l'affaire",
'po' => 0,
'params' => array(
0 => array( 'var' => 'Indiscore', 'type' => 'MAX', 'value' => '6'),
1 => array( 'var' => 'SV', 'type' => 'EGAL', 'value' => '1'),
),
),
8 => array(
'name' => 'VORp-4.4',
'value' => 'ROUGE',
'comment' => "Cette entreprise n'est pas active à l'INSEE : pas d'entrée en relation possible",
'po' => 0,
'params' => array(
0 => array( 'var' => 'Indiscore', 'type' => 'MAX', 'value' => '6'),
1 => array( 'var' => 'InseeActif', 'type' => 'EGAL', 'value' => '0'),
),
),
9 => array(
'name' => 'VORp-5.0',
'value' => 'ORANGE',
'comment' => "Faire une DEC si dépassement de la PO proposée",
'po' => 1,
'params' => array(
0 => array( 'var' => 'Indiscore', 'type' => 'MAX', 'value' => '16'),
1 => array( 'var' => 'Indiscore', 'type' => 'MIN', 'value' => '9'),
2 => array( 'var' => 'InseeAge', 'type' => 'MAX', 'value' => '37', 'define' => array( 'var' => 'EntrepRecente', 'value' => '1')),
3 => array( 'var' => 'TypeEntrep', 'type' => 'MIN', 'value' => 'PME'),
),
),
10 => array(
'name' => 'VORp-7.0',
'value' => 'ORANGE',
'comment' => "Cette entreprise fait l'objet d'une sauvegarde : faire une DEC si dépassement de la PO",
'po' => 1,
'params' => array(
0 => array( 'var' => 'FEU', 'type' => 'EGAL', 'value' => 'ROUGE'),
1 => array( 'var' => 'SV', 'type' => 'EGAL', 'value' => '1'),
2 => array( 'var' => 'Indiscore', 'type' => 'MIN', 'value' => '4'),
),
),
11 => array(
'name' => 'VORp-8.0',
'value' => 'VERT',
'comment' => "",
'po' => 0,
'params' => array(
0 => array( 'var' => 'TypeEntrep', 'type' => 'EGAL', 'value' => 'GE'),
1 => array( 'var' => 'Indiscore', 'type' => 'EGAL', 'value' => '9'),
),
),
12 => array(
'name' => 'VORp-9.0',
'value' => 'VERT',
'comment' => "",
'po' => 0,
'params' => array(
0 => array( 'var' => 'TypeEntrep', 'type' => 'EGAL', 'value' => 'CAC'),
1 => array( 'var' => 'Indiscore', 'type' => 'MIN', 'value' => '5'),
),
),
13 => array(
'name' => 'VORp-6.1',
'value' => 'ROUGE',
'comment' => "Solvabilité et pérennité compromise : faire une DEC si volonté de poursuivre l'affaire",
'po' => 0,
'params' => array(
0 => array( 'var' => 'Indiscore', 'type' => 'MAX', 'value' => '6'),
),
),
14 => array(
'name' => 'VORp-6.2',
'value' => 'ORANGE',
'comment' => "Faire une DEC si dépassement de la PO proposée",
'po' => 1,
'params' => array(
0 => array( 'var' => 'Indiscore', 'type' => 'MAX', 'value' => '10'),
1 => array( 'var' => 'Indiscore', 'type' => 'MIN', 'value' => '5'),
),
),
15 => array(
'name' => 'VORp-6.3',
'value' => 'VERT',
'comment' => "",
'po' => 0,
'params' => array(
0 => array( 'var' => 'Indiscore', 'type' => 'MAX', 'value' => '21'),
1 => array( 'var' => 'Indiscore', 'type' => 'MIN', 'value' => '9'),
),
),
);

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