Get change following merge in trunk
This commit is contained in:
commit
ee763e8c49
@ -1,23 +1,23 @@
|
||||
<?php
|
||||
// Generated by ZF's ./bin/classmap_generator.php
|
||||
return array(
|
||||
'Bootstrap' => dirname(__FILE__) . '/Bootstrap.php',
|
||||
'DemoController' => dirname(__FILE__) . '/controllers/DemoController.php',
|
||||
'DocumentationController' => dirname(__FILE__) . '/controllers/DocumentationController.php',
|
||||
'ErrorController' => dirname(__FILE__) . '/controllers/ErrorController.php',
|
||||
'ExportController' => dirname(__FILE__) . '/controllers/ExportController.php',
|
||||
'FichierController' => dirname(__FILE__) . '/controllers/FichierController.php',
|
||||
'ImportController' => dirname(__FILE__) . '/controllers/ImportController.php',
|
||||
'IndexController' => dirname(__FILE__) . '/controllers/IndexController.php',
|
||||
'JsonrpcController' => dirname(__FILE__) . '/controllers/JsonrpcController.php',
|
||||
'RefController' => dirname(__FILE__) . '/controllers/RefController.php',
|
||||
'ServiceController' => dirname(__FILE__) . '/controllers/ServiceController.php',
|
||||
'UserController' => dirname(__FILE__) . '/controllers/UserController.php',
|
||||
'Zend_View_Helper_DocComplement' => dirname(__FILE__) . '/views/helpers/DocComplement.php',
|
||||
'Zend_View_Helper_DocDescription' => dirname(__FILE__) . '/views/helpers/DocDescription.php',
|
||||
'Zend_View_Helper_DocExemple' => dirname(__FILE__) . '/views/helpers/DocExemple.php',
|
||||
'Zend_View_Helper_DocMethod' => dirname(__FILE__) . '/views/helpers/DocMethod.php',
|
||||
'Zend_View_Helper_DocParameter' => dirname(__FILE__) . '/views/helpers/DocParameter.php',
|
||||
'Zend_View_Helper_DocReturn' => dirname(__FILE__) . '/views/helpers/DocReturn.php',
|
||||
'Zend_View_Helper_ProfileLink' => dirname(__FILE__) . '/views/helpers/ProfileLink.php',
|
||||
'Bootstrap' => dirname(__FILE__) . '//Bootstrap.php',
|
||||
'DemoController' => dirname(__FILE__) . '//controllers/DemoController.php',
|
||||
'DocumentationController' => dirname(__FILE__) . '//controllers/DocumentationController.php',
|
||||
'ErrorController' => dirname(__FILE__) . '//controllers/ErrorController.php',
|
||||
'ExportController' => dirname(__FILE__) . '//controllers/ExportController.php',
|
||||
'FichierController' => dirname(__FILE__) . '//controllers/FichierController.php',
|
||||
'ImportController' => dirname(__FILE__) . '//controllers/ImportController.php',
|
||||
'IndexController' => dirname(__FILE__) . '//controllers/IndexController.php',
|
||||
'JsonrpcController' => dirname(__FILE__) . '//controllers/JsonrpcController.php',
|
||||
'RefController' => dirname(__FILE__) . '//controllers/RefController.php',
|
||||
'ServiceController' => dirname(__FILE__) . '//controllers/ServiceController.php',
|
||||
'UserController' => dirname(__FILE__) . '//controllers/UserController.php',
|
||||
'Zend_View_Helper_DocComplement' => dirname(__FILE__) . '//views/helpers/DocComplement.php',
|
||||
'Zend_View_Helper_DocDescription' => dirname(__FILE__) . '//views/helpers/DocDescription.php',
|
||||
'Zend_View_Helper_DocExemple' => dirname(__FILE__) . '//views/helpers/DocExemple.php',
|
||||
'Zend_View_Helper_DocMethod' => dirname(__FILE__) . '//views/helpers/DocMethod.php',
|
||||
'Zend_View_Helper_DocParameter' => dirname(__FILE__) . '//views/helpers/DocParameter.php',
|
||||
'Zend_View_Helper_DocReturn' => dirname(__FILE__) . '//views/helpers/DocReturn.php',
|
||||
'Zend_View_Helper_ProfileLink' => dirname(__FILE__) . '//views/helpers/ProfileLink.php',
|
||||
);
|
||||
|
@ -15,18 +15,18 @@ class ServiceController extends Zend_Controller_Action
|
||||
|
||||
$request = $this->getRequest();
|
||||
|
||||
//Get the service name, make sure the string is in lower case
|
||||
// --- 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
|
||||
// --- ClassName and Directory with first letter capitalized
|
||||
$serviceClassName = ucfirst($serviceName);
|
||||
|
||||
//Customize service for customers
|
||||
// --- Customize service for customers
|
||||
if ( 'clients' == $serviceName )
|
||||
{
|
||||
$client = strtolower($request->getParam('client', ''));
|
||||
$clientClassName = ucfirst($client);
|
||||
//Get list of customers
|
||||
// --- Get list of customers
|
||||
$clients = array();
|
||||
$listeClients = include APPLICATION_PATH . '/../library/WsScore/Clients/ClientsConfig.php';
|
||||
foreach ( $listeClients as $section => $params )
|
||||
@ -45,12 +45,12 @@ class ServiceController extends Zend_Controller_Action
|
||||
}
|
||||
else
|
||||
{
|
||||
//Service versions
|
||||
// --- Service versions
|
||||
$services = include APPLICATION_PATH . '/../library/WsScore/ServicesConfig.php';
|
||||
$configServiceVersions = $services[$serviceName]['versions'];
|
||||
}
|
||||
|
||||
// Check versions
|
||||
// --- Check versions
|
||||
foreach( $configServiceVersions as $section => $params )
|
||||
{
|
||||
$serviceVersions[$section] = $params;
|
||||
@ -61,25 +61,25 @@ class ServiceController extends Zend_Controller_Action
|
||||
$version = $request->getParam('version', 'v'.$defautVersion);
|
||||
$version = substr($version, 1);
|
||||
|
||||
// Version inexistante
|
||||
// --- Version inexistante
|
||||
if ( !array_key_exists($version, $serviceVersions) )
|
||||
{
|
||||
echo "Version inexistante.";
|
||||
exit;
|
||||
}
|
||||
// Version désactivé
|
||||
// --- 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
|
||||
// --- 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
|
||||
// --- Gestion du mode de génération du wsdl
|
||||
if ( APPLICATION_ENV == 'development'
|
||||
|| array_key_exists('mode', $serviceVersions[$version])
|
||||
&& $serviceVersions[$version]['mode']=='auto') {
|
||||
@ -87,7 +87,7 @@ class ServiceController extends Zend_Controller_Action
|
||||
} else {
|
||||
$pathServiceUrl = 'clients/'.$client.'/v'.$version.'?wsdl';
|
||||
}
|
||||
//On redéfini le nom du service
|
||||
// --- On redéfini le nom du service
|
||||
$serviceClassName = 'Entreprise';
|
||||
$fichierWsdl = $clientClassName.'-'.$serviceClassName.'-'.$version.'.wsdl';
|
||||
}
|
||||
@ -107,18 +107,18 @@ class ServiceController extends Zend_Controller_Action
|
||||
|
||||
}
|
||||
|
||||
//Get map of WSDL type to PHP Classes
|
||||
// --- Get map of WSDL type to PHP Classes
|
||||
$classmap = include $pathServiceClassIni;
|
||||
|
||||
//Inclusion des classes de données
|
||||
// --- Inclusion des classes de données
|
||||
require_once $pathServiceClassPhp;
|
||||
|
||||
//Get hostname - add compatibility with Reverse Proxy
|
||||
// --- Get hostname - add compatibility with Reverse Proxy
|
||||
$hostName = $this->getRequest()->getHttpHost();
|
||||
$fichierWsdl = $hostName . '-' . $fichierWsdl;
|
||||
$wsdlPath = APPLICATION_PATH.'/../data/wsdl';
|
||||
|
||||
// Fourniture du wsdl
|
||||
// --- Fourniture du wsdl
|
||||
if ( isset($_GET['wsdl']) && file_exists($wsdlPath . '/' . $fichierWsdl) )
|
||||
{
|
||||
if (!headers_sent()) {
|
||||
@ -131,14 +131,14 @@ class ServiceController extends Zend_Controller_Action
|
||||
|| isset($_GET['wsdl-generate'])
|
||||
|| isset($_GET['wsdl-auto']) )
|
||||
{
|
||||
// Définition du webservice
|
||||
// --- 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
|
||||
// --- Enregistrement du WSDL dans un fichier
|
||||
if ( isset($_GET['wsdl-generate']) ) {
|
||||
if (file_exists($wsdlPath . '/' . $fichierWsdl)) {
|
||||
unlink($wsdlPath . '/' . $fichierWsdl);
|
||||
@ -146,7 +146,7 @@ class ServiceController extends Zend_Controller_Action
|
||||
$wsdl->dump($wsdlPath . '/' . $fichierWsdl);
|
||||
echo "Le fichier $fichierWsdl a été généré";
|
||||
|
||||
//Génération/Fourniture du wsdl
|
||||
// --- Génération/Fourniture du wsdl
|
||||
} elseif (isset($_GET['wsdl']) && !file_exists($wsdlPath . '/' . $fichierWsdl)) {
|
||||
$wsdl->dump($wsdlPath . '/' . $fichierWsdl);
|
||||
if (!headers_sent()) {
|
||||
@ -154,23 +154,22 @@ class ServiceController extends Zend_Controller_Action
|
||||
}
|
||||
echo file_get_contents($wsdlPath . '/' . $fichierWsdl);
|
||||
|
||||
// Envoi sur la sortie standard le wsdl sans enregistrement dans un fichier
|
||||
// --- Envoi sur la sortie standard le wsdl sans enregistrement dans un fichier
|
||||
} elseif ( isset($_GET['wsdl-auto']) ){
|
||||
$wsdl->handle();
|
||||
}
|
||||
}
|
||||
// Fourniture du service
|
||||
// --- Fourniture du service
|
||||
else
|
||||
{
|
||||
|
||||
// Traitement
|
||||
// --- Traitement
|
||||
if (in_array(APPLICATION_ENV, array('production', 'staging')) && file_exists($wsdlPath . '/' . $fichierWsdl)) {
|
||||
$server = new Zend_Soap_Server($wsdlPath . '/' . $fichierWsdl);
|
||||
} else {
|
||||
$server = new Zend_Soap_Server('http://'.$hostName.'/'.$pathServiceUrl);
|
||||
}
|
||||
|
||||
//Sonde paramètres server
|
||||
// --- Sonde paramètres server
|
||||
$debug = false;
|
||||
$debugUser = '';
|
||||
if ($debug && $_SERVER['PHP_AUTH_USER'] == $debugUser)
|
||||
@ -181,7 +180,7 @@ class ServiceController extends Zend_Controller_Action
|
||||
);
|
||||
}
|
||||
|
||||
//Options et traitement de la requete
|
||||
// --- Options et traitement de la requete
|
||||
$server->setSoapFeatures(SOAP_USE_XSI_ARRAY_TYPE + SOAP_SINGLE_ELEMENT_ARRAYS);
|
||||
$server->setClassmap($classmap);
|
||||
$server->setEncoding('UTF-8');
|
||||
@ -189,8 +188,8 @@ class ServiceController extends Zend_Controller_Action
|
||||
$server->setWsiCompliant(true);
|
||||
$server->setObject(new $serviceClassName());
|
||||
$server->handle();
|
||||
|
||||
//Pour débuggage ultime
|
||||
|
||||
// --- Pour débuggage ultime
|
||||
$debug = false;
|
||||
$debugUser = '';
|
||||
if ($debug && $_SERVER['PHP_AUTH_USER'] == $debugUser)
|
||||
|
@ -13,12 +13,12 @@ class Application_Controller_Plugin_Auth extends Zend_Controller_Plugin_Abstract
|
||||
$action = $request->getActionName();
|
||||
|
||||
$checkAuth = true;
|
||||
//Pas d'authentification sur la demande d'authentification
|
||||
// --- Pas d'authentification sur la demande d'authentification
|
||||
if ( $controller == 'user' && $action == 'login' ) {
|
||||
$checkAuth = false;
|
||||
}
|
||||
|
||||
// Pas d'authentification sur ces services
|
||||
// --- Pas d'authentification sur ces services
|
||||
if ( in_array($controller, array('service', 'import'))
|
||||
|| ( $controller == 'fichier' && $action == 'logs' )
|
||||
|| ( $controller == 'fichier' && $action == 'kbis' )
|
||||
@ -44,12 +44,14 @@ class Application_Controller_Plugin_Auth extends Zend_Controller_Plugin_Abstract
|
||||
|
||||
$auth = Zend_Auth::getInstance();
|
||||
|
||||
//On vérifie le tout lors d'une connexion par url
|
||||
// --- On vérifie le tout lors d'une connexion par url
|
||||
if ( !empty($login) && !empty($pass) ) {
|
||||
|
||||
$authAdapter = new Scores_Auth_Adapter_Db($login, $pass, $checkWs);
|
||||
$result = $auth->authenticate($authAdapter);
|
||||
|
||||
if (!$result->isValid()) {
|
||||
|
||||
$layout = Zend_Layout::getMVCInstance();
|
||||
if ( !$layout->isEnabled() ){
|
||||
echo "Identification incorrect ou périmé.";
|
||||
|
6
library/Application/Model/InseeIdentite.php
Normal file
6
library/Application/Model/InseeIdentite.php
Normal file
@ -0,0 +1,6 @@
|
||||
<?php
|
||||
class Application_Model_InseeIdentite extends Zend_Db_Table_Abstract
|
||||
{
|
||||
protected $_name = 'identite';
|
||||
protected $_schema = 'insee';
|
||||
}
|
6
library/Application/Model/JoEtablissements.php
Normal file
6
library/Application/Model/JoEtablissements.php
Normal file
@ -0,0 +1,6 @@
|
||||
<?php
|
||||
class Application_Model_JoEtablissements extends Zend_Db_Table_Abstract
|
||||
{
|
||||
protected $_name = 'etablissements';
|
||||
protected $_schema = 'jo';
|
||||
}
|
6
library/Application/Model/JoZonageXY.php
Normal file
6
library/Application/Model/JoZonageXY.php
Normal file
@ -0,0 +1,6 @@
|
||||
<?php
|
||||
class Application_Model_JoZonageXY extends Zend_Db_Table_Abstract
|
||||
{
|
||||
protected $_name = 'zonageXY';
|
||||
protected $_schema = 'jo';
|
||||
}
|
@ -1,6 +0,0 @@
|
||||
<?php
|
||||
class Application_Model_Sdv1BilanCommandeEnter extends Zend_Db_Table_Abstract
|
||||
{
|
||||
protected $_name = 'bilan_commande_enter';
|
||||
protected $_schema = 'sdv1';
|
||||
}
|
6
library/Application/Model/Sdv1OrderAssoStatut.php
Normal file
6
library/Application/Model/Sdv1OrderAssoStatut.php
Normal file
@ -0,0 +1,6 @@
|
||||
<?php
|
||||
class Application_Model_Sdv1OrderAssoStatut extends Zend_Db_Table_Abstract
|
||||
{
|
||||
protected $_name = 'order_asso_statut';
|
||||
protected $_schema = 'sdv1';
|
||||
}
|
6
library/Application/Model/Sdv1OrderBilanInput.php
Normal file
6
library/Application/Model/Sdv1OrderBilanInput.php
Normal file
@ -0,0 +1,6 @@
|
||||
<?php
|
||||
class Application_Model_Sdv1OrderBilanInput extends Zend_Db_Table_Abstract
|
||||
{
|
||||
protected $_name = 'order_bilan_input';
|
||||
protected $_schema = 'sdv1';
|
||||
}
|
6
library/Application/Model/Sdv1OrderPrivileges.php
Normal file
6
library/Application/Model/Sdv1OrderPrivileges.php
Normal file
@ -0,0 +1,6 @@
|
||||
<?php
|
||||
class Application_Model_Sdv1OrderPrivileges extends Zend_Db_Table_Abstract
|
||||
{
|
||||
protected $_name = 'order_privileges';
|
||||
protected $_schema = 'sdv1';
|
||||
}
|
6
library/Application/Model/VillesRnvpSources.php
Normal file
6
library/Application/Model/VillesRnvpSources.php
Normal file
@ -0,0 +1,6 @@
|
||||
<?php
|
||||
class Application_Model_VillesRnvpSources extends Zend_Db_Table_Abstract
|
||||
{
|
||||
protected $_name = 'rnvpSources';
|
||||
protected $_schema = 'villes';
|
||||
}
|
@ -1,68 +1,75 @@
|
||||
<?php
|
||||
// Generated by ZF's ./bin/classmap_generator.php
|
||||
return array(
|
||||
'Application_Controller_Plugin_Auth' => dirname(__FILE__) . '/Controller/Plugin/Auth.php',
|
||||
'Application_Controller_Plugin_Menu' => dirname(__FILE__) . '/Controller/Plugin/Menu.php',
|
||||
'Application_Controller_Plugin_Services' => dirname(__FILE__) . '/Controller/Plugin/Services.php',
|
||||
'Application_Form_Login' => dirname(__FILE__) . '/Form/Login.php',
|
||||
'Application_Model_AssoActes' => dirname(__FILE__) . '/Model/AssoActes.php',
|
||||
'Application_Model_BopiMarques' => dirname(__FILE__) . '/Model/BopiMarques.php',
|
||||
'Application_Model_Commandes' => dirname(__FILE__) . '/Model/Commandes.php',
|
||||
'Application_Model_CommandesActe' => dirname(__FILE__) . '/Model/CommandesActe.php',
|
||||
'Application_Model_CommandesAsso' => dirname(__FILE__) . '/Model/CommandesAsso.php',
|
||||
'Application_Model_CommandesBilan' => dirname(__FILE__) . '/Model/CommandesBilan.php',
|
||||
'Application_Model_CommandesEven' => dirname(__FILE__) . '/Model/CommandesEven.php',
|
||||
'Application_Model_CommandesKbis' => dirname(__FILE__) . '/Model/CommandesKbis.php',
|
||||
'Application_Model_CommandesPieces' => dirname(__FILE__) . '/Model/CommandesPieces.php',
|
||||
'Application_Model_CommandesStatut' => dirname(__FILE__) . '/Model/CommandesStatut.php',
|
||||
'Application_Model_ExtractionCommandes' => dirname(__FILE__) . '/Model/ExtractionCommandes.php',
|
||||
'Application_Model_FedasoBilans' => dirname(__FILE__) . '/Model/FedasoBilans.php',
|
||||
'Application_Model_HistoriquesBilans' => dirname(__FILE__) . '/Model/HistoriquesBilans.php',
|
||||
'Application_Model_InseeDepartements' => dirname(__FILE__) . '/Model/InseeDepartements.php',
|
||||
'Application_Model_InseeTabVilles' => dirname(__FILE__) . '/Model/InseeTabVilles.php',
|
||||
'Application_Model_JoAssoBilans' => dirname(__FILE__) . '/Model/JoAssoBilans.php',
|
||||
'Application_Model_JoAssoSubventions' => dirname(__FILE__) . '/Model/JoAssoSubventions.php',
|
||||
'Application_Model_JoBilans' => dirname(__FILE__) . '/Model/JoBilans.php',
|
||||
'Application_Model_JoBilansUser' => dirname(__FILE__) . '/Model/JoBilansUser.php',
|
||||
'Application_Model_JoBoampLots' => dirname(__FILE__) . '/Model/JoBoampLots.php',
|
||||
'Application_Model_JoBodaccDetail' => dirname(__FILE__) . '/Model/JoBodaccDetail.php',
|
||||
'Application_Model_JoBodaccFonctions' => dirname(__FILE__) . '/Model/JoBodaccFonctions.php',
|
||||
'Application_Model_JoGreffesActes' => dirname(__FILE__) . '/Model/JoGreffesActes.php',
|
||||
'Application_Model_JoGreffesBilans' => dirname(__FILE__) . '/Model/JoGreffesBilans.php',
|
||||
'Application_Model_JoLiens' => dirname(__FILE__) . '/Model/JoLiens.php',
|
||||
'Application_Model_JoLiensDoc' => dirname(__FILE__) . '/Model/JoLiensDoc.php',
|
||||
'Application_Model_JoLiensRef' => dirname(__FILE__) . '/Model/JoLiensRef.php',
|
||||
'Application_Model_JoRncsDirigeants' => dirname(__FILE__) . '/Model/JoRncsDirigeants.php',
|
||||
'Application_Model_JoRncsEtab' => dirname(__FILE__) . '/Model/JoRncsEtab.php',
|
||||
'Application_Model_JoScoresCutoff' => dirname(__FILE__) . '/Model/JoScoresCutoff.php',
|
||||
'Application_Model_JoScoresCutoffMvt' => dirname(__FILE__) . '/Model/JoScoresCutoffMvt.php',
|
||||
'Application_Model_JoScoresSurveillance' => dirname(__FILE__) . '/Model/JoScoresSurveillance.php',
|
||||
'Application_Model_JoSurveillancesSite' => dirname(__FILE__) . '/Model/JoSurveillancesSite.php',
|
||||
'Application_Model_JoTabDevises' => dirname(__FILE__) . '/Model/JoTabDevises.php',
|
||||
'Application_Model_JoTabEvenements' => dirname(__FILE__) . '/Model/JoTabEvenements.php',
|
||||
'Application_Model_JoTabFJur' => dirname(__FILE__) . '/Model/JoTabFJur.php',
|
||||
'Application_Model_JoTabMandataires' => dirname(__FILE__) . '/Model/JoTabMandataires.php',
|
||||
'Application_Model_JoTabNaf5' => dirname(__FILE__) . '/Model/JoTabNaf5.php',
|
||||
'Application_Model_JoTabPays' => dirname(__FILE__) . '/Model/JoTabPays.php',
|
||||
'Application_Model_JoTelephonie' => dirname(__FILE__) . '/Model/JoTelephonie.php',
|
||||
'Application_Model_Sdv1BilanCommandeEnter' => dirname(__FILE__) . '/Model/Sdv1BilanCommandeEnter.php',
|
||||
'Application_Model_Sdv1BourseIsin' => dirname(__FILE__) . '/Model/Sdv1BourseIsin.php',
|
||||
'Application_Model_Sdv1Clients' => dirname(__FILE__) . '/Model/Sdv1Clients.php',
|
||||
'Application_Model_Sdv1ClientsServices' => dirname(__FILE__) . '/Model/Sdv1ClientsServices.php',
|
||||
'Application_Model_Sdv1ClientsServicesDroits' => dirname(__FILE__) . '/Model/Sdv1ClientsServicesDroits.php',
|
||||
'Application_Model_Sdv1ClientsServicesIP' => dirname(__FILE__) . '/Model/Sdv1ClientsServicesIP.php',
|
||||
'Application_Model_Sdv1ClientsServicesTrigger' => dirname(__FILE__) . '/Model/Sdv1ClientsServicesTrigger.php',
|
||||
'Application_Model_Sdv1ClientsTarifs' => dirname(__FILE__) . '/Model/Sdv1ClientsTarifs.php',
|
||||
'Application_Model_Sdv1DirigeantsOp' => dirname(__FILE__) . '/Model/Sdv1DirigeantsOp.php',
|
||||
'Application_Model_Sdv1GreffeCommandesAc' => dirname(__FILE__) . '/Model/Sdv1GreffeCommandesAc.php',
|
||||
'Application_Model_Sdv1GreffeCommandesBi' => dirname(__FILE__) . '/Model/Sdv1GreffeCommandesBi.php',
|
||||
'Application_Model_Sdv1GreffeCommandesKb' => dirname(__FILE__) . '/Model/Sdv1GreffeCommandesKb.php',
|
||||
'Application_Model_Sdv1Logs' => dirname(__FILE__) . '/Model/Sdv1Logs.php',
|
||||
'Application_Model_Sdv1Prestations' => dirname(__FILE__) . '/Model/Sdv1Prestations.php',
|
||||
'Application_Model_Sdv1TabIdLocal' => dirname(__FILE__) . '/Model/Sdv1TabIdLocal.php',
|
||||
'Application_Model_Sdv1Utilisateurs' => dirname(__FILE__) . '/Model/Sdv1Utilisateurs.php',
|
||||
'Application_Model_Sdv1UtilisateursAuthLog' => dirname(__FILE__) . '/Model/Sdv1UtilisateursAuthLog.php',
|
||||
'Application_Model_Sdv1UtilisateursBrowserLog' => dirname(__FILE__) . '/Model/Sdv1UtilisateursBrowserLog.php',
|
||||
'Application_Model_Sdv1UtilisateursEmails' => dirname(__FILE__) . '/Model/Sdv1UtilisateursEmails.php',
|
||||
'Application_Model_Sdv1UtilisateursService' => dirname(__FILE__) . '/Model/Sdv1UtilisateursService.php',
|
||||
'Application_Controller_Plugin_Auth' => dirname(__FILE__) . '//Controller/Plugin/Auth.php',
|
||||
'Application_Controller_Plugin_Menu' => dirname(__FILE__) . '//Controller/Plugin/Menu.php',
|
||||
'Application_Controller_Plugin_Services' => dirname(__FILE__) . '//Controller/Plugin/Services.php',
|
||||
'Application_Form_Login' => dirname(__FILE__) . '//Form/Login.php',
|
||||
'Application_Model_AssoActes' => dirname(__FILE__) . '//Model/AssoActes.php',
|
||||
'Application_Model_BopiMarques' => dirname(__FILE__) . '//Model/BopiMarques.php',
|
||||
'Application_Model_Commandes' => dirname(__FILE__) . '//Model/Commandes.php',
|
||||
'Application_Model_CommandesActe' => dirname(__FILE__) . '//Model/CommandesActe.php',
|
||||
'Application_Model_CommandesAsso' => dirname(__FILE__) . '//Model/CommandesAsso.php',
|
||||
'Application_Model_CommandesBilan' => dirname(__FILE__) . '//Model/CommandesBilan.php',
|
||||
'Application_Model_CommandesEven' => dirname(__FILE__) . '//Model/CommandesEven.php',
|
||||
'Application_Model_CommandesKbis' => dirname(__FILE__) . '//Model/CommandesKbis.php',
|
||||
'Application_Model_CommandesPieces' => dirname(__FILE__) . '//Model/CommandesPieces.php',
|
||||
'Application_Model_CommandesStatut' => dirname(__FILE__) . '//Model/CommandesStatut.php',
|
||||
'Application_Model_ExtractionCommandes' => dirname(__FILE__) . '//Model/ExtractionCommandes.php',
|
||||
'Application_Model_FedasoBilans' => dirname(__FILE__) . '//Model/FedasoBilans.php',
|
||||
'Application_Model_HistoriquesBilans' => dirname(__FILE__) . '//Model/HistoriquesBilans.php',
|
||||
'Application_Model_InseeDepartements' => dirname(__FILE__) . '//Model/InseeDepartements.php',
|
||||
'Application_Model_InseeIdentite' => dirname(__FILE__) . '//Model/InseeIdentite.php',
|
||||
'Application_Model_InseeTabVilles' => dirname(__FILE__) . '//Model/InseeTabVilles.php',
|
||||
'Application_Model_JoAssoBilans' => dirname(__FILE__) . '//Model/JoAssoBilans.php',
|
||||
'Application_Model_JoAssoSubventions' => dirname(__FILE__) . '//Model/JoAssoSubventions.php',
|
||||
'Application_Model_JoBilans' => dirname(__FILE__) . '//Model/JoBilans.php',
|
||||
'Application_Model_JoBilansUser' => dirname(__FILE__) . '//Model/JoBilansUser.php',
|
||||
'Application_Model_JoBoampLots' => dirname(__FILE__) . '//Model/JoBoampLots.php',
|
||||
'Application_Model_JoBodaccDetail' => dirname(__FILE__) . '//Model/JoBodaccDetail.php',
|
||||
'Application_Model_JoBodaccFonctions' => dirname(__FILE__) . '//Model/JoBodaccFonctions.php',
|
||||
'Application_Model_JoEtablissements' => dirname(__FILE__) . '//Model/JoEtablissements.php',
|
||||
'Application_Model_JoGreffesActes' => dirname(__FILE__) . '//Model/JoGreffesActes.php',
|
||||
'Application_Model_JoGreffesBilans' => dirname(__FILE__) . '//Model/JoGreffesBilans.php',
|
||||
'Application_Model_JoLiens' => dirname(__FILE__) . '//Model/JoLiens.php',
|
||||
'Application_Model_JoLiensDoc' => dirname(__FILE__) . '//Model/JoLiensDoc.php',
|
||||
'Application_Model_JoLiensRef' => dirname(__FILE__) . '//Model/JoLiensRef.php',
|
||||
'Application_Model_JoRncsDirigeants' => dirname(__FILE__) . '//Model/JoRncsDirigeants.php',
|
||||
'Application_Model_JoRncsEtab' => dirname(__FILE__) . '//Model/JoRncsEtab.php',
|
||||
'Application_Model_JoScoresCutoff' => dirname(__FILE__) . '//Model/JoScoresCutoff.php',
|
||||
'Application_Model_JoScoresCutoffMvt' => dirname(__FILE__) . '//Model/JoScoresCutoffMvt.php',
|
||||
'Application_Model_JoScoresSurveillance' => dirname(__FILE__) . '//Model/JoScoresSurveillance.php',
|
||||
'Application_Model_JoSurveillancesListes' => dirname(__FILE__) . '//Model/JoSurveillancesListes.php',
|
||||
'Application_Model_JoSurveillancesSite' => dirname(__FILE__) . '//Model/JoSurveillancesSite.php',
|
||||
'Application_Model_JoTabDevises' => dirname(__FILE__) . '//Model/JoTabDevises.php',
|
||||
'Application_Model_JoTabEvenements' => dirname(__FILE__) . '//Model/JoTabEvenements.php',
|
||||
'Application_Model_JoTabFJur' => dirname(__FILE__) . '//Model/JoTabFJur.php',
|
||||
'Application_Model_JoTabMandataires' => dirname(__FILE__) . '//Model/JoTabMandataires.php',
|
||||
'Application_Model_JoTabNaf5' => dirname(__FILE__) . '//Model/JoTabNaf5.php',
|
||||
'Application_Model_JoTabPays' => dirname(__FILE__) . '//Model/JoTabPays.php',
|
||||
'Application_Model_JoTelephonie' => dirname(__FILE__) . '//Model/JoTelephonie.php',
|
||||
'Application_Model_JoZonageXY' => dirname(__FILE__) . '//Model/JoZonageXY.php',
|
||||
'Application_Model_Sdv1BourseIsin' => dirname(__FILE__) . '//Model/Sdv1BourseIsin.php',
|
||||
'Application_Model_Sdv1Clients' => dirname(__FILE__) . '//Model/Sdv1Clients.php',
|
||||
'Application_Model_Sdv1ClientsServices' => dirname(__FILE__) . '//Model/Sdv1ClientsServices.php',
|
||||
'Application_Model_Sdv1ClientsServicesDroits' => dirname(__FILE__) . '//Model/Sdv1ClientsServicesDroits.php',
|
||||
'Application_Model_Sdv1ClientsServicesIP' => dirname(__FILE__) . '//Model/Sdv1ClientsServicesIP.php',
|
||||
'Application_Model_Sdv1ClientsServicesTrigger' => dirname(__FILE__) . '//Model/Sdv1ClientsServicesTrigger.php',
|
||||
'Application_Model_Sdv1ClientsTarifs' => dirname(__FILE__) . '//Model/Sdv1ClientsTarifs.php',
|
||||
'Application_Model_Sdv1DirigeantsOp' => dirname(__FILE__) . '//Model/Sdv1DirigeantsOp.php',
|
||||
'Application_Model_Sdv1GreffeCommandesAc' => dirname(__FILE__) . '//Model/Sdv1GreffeCommandesAc.php',
|
||||
'Application_Model_Sdv1GreffeCommandesBi' => dirname(__FILE__) . '//Model/Sdv1GreffeCommandesBi.php',
|
||||
'Application_Model_Sdv1GreffeCommandesKb' => dirname(__FILE__) . '//Model/Sdv1GreffeCommandesKb.php',
|
||||
'Application_Model_Sdv1Logs' => dirname(__FILE__) . '//Model/Sdv1Logs.php',
|
||||
'Application_Model_Sdv1OrderAssoStatut' => dirname(__FILE__) . '//Model/Sdv1OrderAssoStatut.php',
|
||||
'Application_Model_Sdv1OrderBilanInput' => dirname(__FILE__) . '//Model/Sdv1OrderBilanInput.php',
|
||||
'Application_Model_Sdv1OrderPrivileges' => dirname(__FILE__) . '//Model/Sdv1OrderPrivileges.php',
|
||||
'Application_Model_Sdv1Prestations' => dirname(__FILE__) . '//Model/Sdv1Prestations.php',
|
||||
'Application_Model_Sdv1TabIdLocal' => dirname(__FILE__) . '//Model/Sdv1TabIdLocal.php',
|
||||
'Application_Model_Sdv1Utilisateurs' => dirname(__FILE__) . '//Model/Sdv1Utilisateurs.php',
|
||||
'Application_Model_Sdv1UtilisateursAuthLog' => dirname(__FILE__) . '//Model/Sdv1UtilisateursAuthLog.php',
|
||||
'Application_Model_Sdv1UtilisateursBrowserLog' => dirname(__FILE__) . '//Model/Sdv1UtilisateursBrowserLog.php',
|
||||
'Application_Model_Sdv1UtilisateursEmails' => dirname(__FILE__) . '//Model/Sdv1UtilisateursEmails.php',
|
||||
'Application_Model_Sdv1UtilisateursService' => dirname(__FILE__) . '//Model/Sdv1UtilisateursService.php',
|
||||
'Application_Model_VillesRnvpSources' => dirname(__FILE__) . '//Model/VillesRnvpSources.php',
|
||||
);
|
||||
|
@ -1666,7 +1666,7 @@ class MInsee
|
||||
|
||||
$limit="LIMIT $deb, $nbRep";
|
||||
|
||||
$sqlInfo="e.id, e.source, e.source_id, e.triCode, e.autre_id, LPAD(e.siren, 9, 0) as siren, LPAD(e.nic, 5, 0) as nic, e.siege, ".
|
||||
$sqlInfo="e.id, e.source, e.source_id, e.triCode, e.autre_id, LPAD(e.siren, 9, 0) AS siren, LPAD(e.nic, 5, 0) AS nic, e.siege, ".
|
||||
"e.raisonSociale, e.enseigne, e.sigle, LPAD(e.adr_num,4,0) AS adr_num, e.adr_btq, e.adr_typeVoie, e.adr_libVoie, ".
|
||||
"e.adr_comp, LPAD(e.adr_cp,5,0) AS adr_cp, e.adr_ville, e.adr_dep, LPAD(e.adr_com,3,0) AS adr_com, LPAD(e.tel,10,0) AS tel, LPAD(e.fax,10,0) AS fax, e.cj, e.ape_etab, e.ape_entrep, e.teff_etab, ".
|
||||
"CONCAT(siren, nic) as siret, e.actif, e.identite_pre, IF(e.siege=2,0.5,e.siege) AS triSiege";
|
||||
@ -1836,7 +1836,7 @@ class MInsee
|
||||
$tabTmp=$this->iDb->select('etablissements', 'count(*)', "TEL=$id OR FAX=$id $filtreActif");
|
||||
$nbTot=$tabTmp[0][0];
|
||||
$listeEtab=$this->iDb->select('etablissements e',
|
||||
"'Etab' as Loc, e.id, e.source, e.source_id, e.triCode, e.autre_id, LPAD(e.siren, 9, 0) as siren, LPAD(e.nic, 5, 0), e.siege, ".
|
||||
"'Etab' as Loc, e.id, e.source, e.source_id, e.triCode, e.autre_id, LPAD(e.siren, 9, 0) AS siren, LPAD(e.nic, 5, 0) AS nic, e.siege, ".
|
||||
"e.raisonSociale, e.enseigne, e.sigle, LPAD(e.adr_num,4,0) AS adr_num, e.adr_btq, e.adr_typeVoie, e.adr_libVoie, ".
|
||||
"e.adr_comp, LPAD(e.adr_cp,5,0) AS adr_cp, e.adr_ville, e.adr_dep, LPAD(e.adr_com,3,0) AS adr_com, LPAD(e.tel,10,0) AS tel, LPAD(e.fax,10,0) AS fax, e.cj, e.ape_etab, e.ape_entrep,".
|
||||
"CONCAT(e.siren, e.nic) as siret, e.actif",
|
||||
@ -1870,7 +1870,7 @@ class MInsee
|
||||
$tabTmp=$this->iDb->select('etablissements', 'count(*)', "autre_id IN ('$strId') $filtreActif $strDep");
|
||||
$nbTot=$tabTmp[0][0];
|
||||
$listeEtab=$this->iDb->select('etablissements e',
|
||||
"'Etab' as Loc, e.id, e.source, e.source_id, e.triCode, e.autre_id, e.siren, e.nic, e.siege, ".
|
||||
"'Etab' as Loc, e.id, e.source, e.source_id, e.triCode, e.autre_id, LPAD(e.siren, 9, 0) AS siren, LPAD(e.nic, 5, 0) AS nic, e.siege, ".
|
||||
"e.raisonSociale, e.enseigne, e.sigle, LPAD(e.adr_num,4,0) AS adr_num, e.adr_btq, e.adr_typeVoie, e.adr_libVoie, ".
|
||||
"e.adr_comp, LPAD(e.adr_cp,5,0) AS adr_cp, e.adr_ville, e.adr_dep, LPAD(e.adr_com,3,0) AS adr_com, LPAD(e.tel,10,0) AS tel, LPAD(e.fax,10,0) AS fax, e.cj, e.ape_etab, e.ape_entrep, e.teff_etab, ".
|
||||
"CONCAT(e.siren, e.nic) as siret, e.actif",
|
||||
@ -3082,7 +3082,7 @@ class MInsee
|
||||
}
|
||||
if ($tabRet['CapitalDev']<>'' && $tabRet['CapitalDev']<>'EUR') {
|
||||
$dev=$tabRet['CapitalDev'];
|
||||
$devise=$this->iDb->select('sdv1.devise_liste l, devise_cours c', 'c.devise, c.valeur, c.date, l.devNom, l.devNomPays, l.devPaysIso', "c.devise='$dev' and l.devIso='$dev' ORDER BY c.date DESC LIMIT 0,1", false, MYSQL_ASSOC);
|
||||
$devise=$this->iDb->select('sdv1.devise_liste l, sdv1.devise_cours c', 'c.devise, c.valeur, c.date, l.devNom, l.devNomPays, l.devPaysIso', "c.devise='$dev' and l.devIso='$dev' ORDER BY c.date DESC LIMIT 0,1", false, MYSQL_ASSOC);
|
||||
$dev=@$devise[0];
|
||||
//die(print_r($dev));
|
||||
$devise=$tabRet['Capital']*$dev['valeur']*1;
|
||||
@ -6341,7 +6341,7 @@ class MInsee
|
||||
{
|
||||
$tabRet=array();
|
||||
$ret=$this->iDb->select('insee.insee_even',
|
||||
'insSIREN, insNIC, insDATEVE, insEVE, insAPET700, insSIEGE, insLIBCOM, insL1_NOMEN, insL2_COMP, insL4_VOIE, insL3_CADR, insL5_DISP, insL6_POST, insCODPOS, insL7_ETRG, insDEPCOM, insCODEVOIE, insNICTRAN, insSIRETPS, insDATEMAJ, idFlux, insSIRETASS, insDESTINAT, insTYPETAB, insORIGINE, insTRAN, insNOMEN, insENSEIGNE, insNUMVOIE, insINDREP, insTYPVOIE, insLIBVOIE, sirVersion',
|
||||
'LPAD(insSIREN,9,0) AS insSIREN, LPAD(insNIC,5,0) AS insNIC, insDATEVE, insEVE, insAPET700, insSIEGE, insLIBCOM, insL1_NOMEN, insL2_COMP, insL4_VOIE, insL3_CADR, insL5_DISP, insL6_POST, insCODPOS, insL7_ETRG, insDEPCOM, insCODEVOIE, insNICTRAN, insSIRETPS, insDATEMAJ, idFlux, insSIRETASS, insDESTINAT, insTYPETAB, insORIGINE, insTRAN, insNOMEN, insENSEIGNE, insNUMVOIE, insINDREP, insTYPVOIE, insLIBVOIE, sirVersion',
|
||||
"insSIREN=$siren AND insNIC<>$nic AND (insEVE IN ('510','520','530','540', 'CTS','CTE','STS','STE','MTDS','MTDE','MTAS','MTAE') OR insEVE LIKE 'T%') AND insDATEMAJ IN (
|
||||
SELECT insDATEMAJ FROM insee.insee_even WHERE insSIREN=$siren AND insNIC=$nic AND (insEVE IN ('510','520','530','540', 'CTS','CTE','STS','STE','MTDS','MTDE','MTAS','MTAE') OR insEVE LIKE 'T%')
|
||||
)", false, MYSQL_ASSOC);
|
||||
@ -6601,48 +6601,50 @@ class MInsee
|
||||
|
||||
/**
|
||||
* Code Voie Rivoli
|
||||
* @param unknown $codeCommune
|
||||
* @param unknown $adrTypVoie
|
||||
* @param unknown $adrLibVoie
|
||||
* @return string|Ambigous <string, unknown>
|
||||
* @param string $codeCommune
|
||||
* @param string $adrTypVoie
|
||||
* @param string $adrLibVoie
|
||||
* @return string
|
||||
*/
|
||||
public function getCodeVoieRivoli($codeCommune, $adrTypVoie, $adrLibVoie)
|
||||
{
|
||||
$codeVoie='';
|
||||
$adrTypVoie=strtoupper($adrTypVoie);
|
||||
$adrLibVoie=strtoupper($adrLibVoie);
|
||||
$adrLibVoie2=addslashes($adrLibVoie);
|
||||
$tDeb=microtime(1);
|
||||
$tabVoiesNoff=array(
|
||||
'LD'=> '',
|
||||
'R'=> 'RUE',
|
||||
'CITE'=>'CTE',
|
||||
'FG'=> 'FBG',
|
||||
'PL'=> 'PCE',
|
||||
'QU'=> 'QUAI',
|
||||
'QUA'=> 'QRT',
|
||||
//'QUA'=>'QUR',
|
||||
'SQ'=> 'SQR',
|
||||
'VLGE'=>'VGE',
|
||||
'VOI'=>'VOIE'
|
||||
$codeVoie = '';
|
||||
$adrTypVoie = strtoupper($adrTypVoie);
|
||||
$adrLibVoie = strtoupper($adrLibVoie);
|
||||
$adrLibVoie2 = addslashes($adrLibVoie);
|
||||
|
||||
$tabVoiesNoff = array(
|
||||
'LD' => '',
|
||||
'R' => 'RUE',
|
||||
'CITE' => 'CTE',
|
||||
'FG' => 'FBG',
|
||||
'PL' => 'PCE',
|
||||
'QU' => 'QUAI',
|
||||
'QUA' => 'QRT',
|
||||
'SQ' => 'SQR',
|
||||
'VLGE' => 'VGE',
|
||||
'VOI' => 'VOIE'
|
||||
);
|
||||
|
||||
if (array_key_exists($adrTypVoie, $tabVoiesNoff) || in_array($adrTypVoie, $tabVoiesNoff)) {
|
||||
$typeVoieNoff=$adrTypVoie;
|
||||
$typeVoieOff=@$tabVoiesNoff[$adrTypVoie];
|
||||
if ($typeVoieOff=='QUA')
|
||||
$strTypesVoies=" AND voieNature IN('QUA','QRT','QUR') ";
|
||||
else
|
||||
$strTypesVoies=" AND voieNature IN('$typeVoieNoff','$typeVoieOff') ";
|
||||
$typeVoieNoff = $adrTypVoie;
|
||||
$typeVoieOff = $tabVoiesNoff[$adrTypVoie];
|
||||
if ($typeVoieOff == 'QUA') {
|
||||
$strTypesVoies = " AND voieNature IN('QUA','QRT','QUR') ";
|
||||
} else {
|
||||
$strTypesVoies = " AND voieNature IN('$typeVoieNoff','$typeVoieOff') ";
|
||||
}
|
||||
} else {
|
||||
$typeVoieOff=$typeVoieNoff=$adrTypVoie;
|
||||
$strTypesVoies=" AND voieNature='$typeVoieOff' ";
|
||||
$typeVoieOff = $typeVoieNoff = $adrTypVoie;
|
||||
$strTypesVoies =" AND voieNature='$typeVoieOff' ";
|
||||
}
|
||||
$ret=$this->iDb->select(
|
||||
'insee.fantoirVoi', "codComInsee, idVoieCom, cleRivoli, voieNature, voieLib, 1 AS score",
|
||||
"codComInsee='$codeCommune' $strTypesVoies AND voieLib='$adrLibVoie2'",false, MYSQL_ASSOC);
|
||||
$nbRet=count($ret);
|
||||
if ($nbRet==0) return '';//'Aucune correspondance Rivoli'.EOL;
|
||||
else {
|
||||
|
||||
$ret = $this->iDb->select('insee.fantoirVoi', "codComInsee, idVoieCom, cleRivoli, voieNature, voieLib, 1 AS score",
|
||||
"codComInsee='$codeCommune' $strTypesVoies AND voieLib='$adrLibVoie2'", false, MYSQL_ASSOC);
|
||||
$nbRet = count($ret);
|
||||
if ($nbRet==0) {
|
||||
return '';//'Aucune correspondance Rivoli'.EOL;
|
||||
} else {
|
||||
foreach($ret as $i=>$iRet) {
|
||||
if (($iRet['voieNature']==$typeVoieOff || $iRet['voieNature']==$typeVoieNoff) && $iRet['voieLib']==$adrLibVoie) {
|
||||
$codeVoie=$iRet['idVoieCom'];
|
||||
|
@ -1780,12 +1780,10 @@ class MGreffes
|
||||
"VILLE DE" => "7210",
|
||||
);
|
||||
|
||||
require_once 'i18n/cleanchar.php';
|
||||
|
||||
$search = strtoupper(cleanutf8($txt));
|
||||
|
||||
require_once 'Scores/Locale/String.php';
|
||||
$search = strtoupper(Scores_Locale_String::cleanutf8($txt));
|
||||
foreach ( $list as $item => $code ) {
|
||||
if ( $search == strtoupper(cleanutf8($item)) ) {
|
||||
if ( $search == strtoupper(Scores_Locale_String::cleanutf8($item)) ) {
|
||||
return $code;
|
||||
break;
|
||||
}
|
||||
@ -2170,15 +2168,12 @@ class MGreffes
|
||||
|
||||
$label = $xpath->query("span[@class='label']", $n);
|
||||
|
||||
require_once 'i18n/cleanchar.php';
|
||||
switch ( strtoupper(cleanutf8( trim($label) )) ) {
|
||||
require_once 'Scores/Locale/String.php';
|
||||
switch ( strtoupper(Scores_Locale_String::cleanutf8( trim($label) )) ) {
|
||||
case 'CATEGORIE JURIDIQUE :':
|
||||
//Catégorie juridique
|
||||
//<p> <span class="label">Catégorie juridique :</span> <span class="data">Artisan</span> </p>
|
||||
$data = $xpath->query("span[@class='data']", $n);
|
||||
|
||||
|
||||
|
||||
break;
|
||||
case 'ADRESSE :':
|
||||
//Adresse
|
||||
|
@ -950,13 +950,13 @@ class MMap {
|
||||
**/
|
||||
public function geoCodeAdresse($adrNum, $adrIndRep, $adrTypeVoieCourt, $adrTypeVoieLong, $adrLibVoie, $cp, $ville='', $pays='France', $codeRivoli='')
|
||||
{
|
||||
$tabRep=array();
|
||||
$adresse=addslashes(trim(preg_replace('/ +/',' ', "$adrNum $adrIndRep $adrTypeVoieLong $adrLibVoie")));
|
||||
$ville=addslashes($ville);
|
||||
$ret = $this->iDb->select('zonageXY',
|
||||
'lat, lon, l93_x, l93_y, alt, precis, adresseValidee, dateInsert',
|
||||
$tabRep = array();
|
||||
$adrNum = str_pad($adrNum, 4, 0, STR_PAD_LEFT);
|
||||
$adresse = addslashes(trim(preg_replace('/ +/',' ', "$adrNum $adrIndRep $adrTypeVoieLong $adrLibVoie")));
|
||||
$ville = addslashes($ville);
|
||||
$ret = $this->iDb->select('zonageXY', 'lat, lon, l93_x, l93_y, alt, precis, adresseValidee, dateInsert',
|
||||
"address='$adresse' AND adr_cp='$cp' AND adr_ville='$ville'", false, MYSQL_ASSOC);
|
||||
|
||||
|
||||
//Existe dans la base
|
||||
if (count($ret)>0) {
|
||||
$zonage=$ret[0];
|
||||
|
@ -926,6 +926,7 @@ function calculIndiScore($siren, $nic=0, $accesDist=false, $cycleClient=2, $mail
|
||||
|
||||
if (strtoupper(substr($tabIdentite['AutreId'],0,1))=='W') $WALDEC=$tabIdentite['AutreId'];
|
||||
else $WALDEC='';
|
||||
|
||||
// AGE en mois
|
||||
if ($tabIdentite['DateCreaEt']>0 && $tabIdentite['DateCreaEt']<$tabIdentite['DateCreaEn'])
|
||||
$dateCrea=$tabIdentite['DateCreaEt'];
|
||||
@ -935,7 +936,6 @@ function calculIndiScore($siren, $nic=0, $accesDist=false, $cycleClient=2, $mail
|
||||
$dateCrea=str_replace('-','',$DIMMAT);
|
||||
else {
|
||||
$dateCrea=0;
|
||||
//@sendMail('production@scores-decisions.com', 'ylenaour@scores-decisions.com', "Indiscore sur $siren : Attention 'dateCrea'",'Corriger les tests de la valeur !');
|
||||
}
|
||||
$DCREN=$dateCrea;
|
||||
$DCREN_AA=substr($dateCrea,0,4);
|
||||
@ -1612,7 +1612,7 @@ function calculIndiScore($siren, $nic=0, $accesDist=false, $cycleClient=2, $mail
|
||||
}
|
||||
}
|
||||
|
||||
// Annonces BODACC Poursuite de l'activité malgré la perte de plus de plus de la moitié du capital social
|
||||
// Annonces BODACC Poursuite de l'activité malgré la perte de plus de la moitié du capital social
|
||||
$tabDepotCpt=$iInsee->getAnnoncesLegales($siren, 0, array(2314,2319), false);
|
||||
if (is_array($tabDepotCpt) && count($tabDepotCpt)>0){
|
||||
foreach ($tabDepotCpt as $iDep=>$depot) {
|
||||
@ -2292,9 +2292,10 @@ function calculIndiScore($siren, $nic=0, $accesDist=false, $cycleClient=2, $mail
|
||||
$SCORECONF-=5;
|
||||
//$tabCommentaires['gen'][]=prepareString("Cette affaire personnelle à demandée son retrait du champs de diffusion commercial de la base SIRENE.");
|
||||
$PPNONDIFF=true;
|
||||
} else
|
||||
} else {
|
||||
$PPNONDIFF=false;
|
||||
|
||||
}
|
||||
|
||||
/** Entreprise en Zone Prioritaire ? **/
|
||||
$ZONEPRI=false;
|
||||
$ZONEPRIZUS=$ZONEPRIAFR=$ZONEPRICUCS=$ZONEPRIZFU=$ZONEPRIZRR=$ZONEPRIZRU='';
|
||||
@ -2711,10 +2712,7 @@ function calculIndiScore($siren, $nic=0, $accesDist=false, $cycleClient=2, $mail
|
||||
} elseif ($tabIdentite['SituationJuridique']=='D'){
|
||||
$noteSolvabilite=$SCORECONF=$SCOREDIRI=0;
|
||||
$analyseConf='L\'entreprise est dissoute';
|
||||
} /*elseif ($tabIdentite['SituationJuridique']=='R'){
|
||||
$noteSolvabilite=$SCORECONF=$SCOREDIRI=0;
|
||||
$analyseConf='L\'entreprise est radiée';
|
||||
} */elseif ($tabIdentite['Actif']==0){
|
||||
} elseif ($tabIdentite['Actif']==0){
|
||||
$noteSolvabilite=$SCORECONF=$SCOREDIRI=0;
|
||||
$analyseConf='L\'entreprise n\'est pas en activité';
|
||||
} elseif ($SCORECONF>=70)
|
||||
|
@ -968,11 +968,11 @@ function rechercheDir(&$formR, $deb, $nbRep, $max)
|
||||
d.naissance_date,
|
||||
d.naissance_lieu,
|
||||
l.libelle AS fonction_lib,
|
||||
e.id, CONCAT(e.siren,e.nic) AS siret,
|
||||
e.id, CONCAT(LPAD(e.siren,9,0),LPAD(e.nic,5,0)) AS siret,
|
||||
e.source,
|
||||
e.source_id,
|
||||
e.siren,
|
||||
e.nic,
|
||||
LPAD(e.siren,9,0) AS siren,
|
||||
LPAD(e.nic,5,0) AS nic,
|
||||
e.siege,
|
||||
e.raisonSociale,
|
||||
e.sigle,
|
||||
@ -1159,9 +1159,9 @@ function rechercheAct($formR, $deb, $nbRep, $max)
|
||||
IF(l.dateUpdate>l.dateInsert,l.dateUpdate,l.dateInsert) AS date,
|
||||
|
||||
/*Participation*/
|
||||
CONCAT(LPAD(e.siren,9,'000000000'), LPAD(e.nic,5,'00000')) AS siret,
|
||||
LPAD(par.siren,9,'000000000') AS siren,
|
||||
LPAD(e.nic,5,'00000') AS nic,
|
||||
CONCAT(LPAD(e.siren,9,0), LPAD(e.nic,5,0)) AS siret,
|
||||
LPAD(par.siren,9,0) AS siren,
|
||||
LPAD(e.nic,5,0) AS nic,
|
||||
e.siege,
|
||||
par.RS AS raisonSociale,
|
||||
/*sigle*/
|
||||
@ -1210,9 +1210,9 @@ function rechercheAct($formR, $deb, $nbRep, $max)
|
||||
IF(l.dateUpdate>l.dateInsert,l.dateUpdate,l.dateInsert) AS date,
|
||||
|
||||
/*Participation*/
|
||||
CONCAT(LPAD(e.siren,9,'000000000'), LPAD(e.nic,5,'00000')) AS siret,
|
||||
LPAD(par.siren,9,'000000000') AS siren,
|
||||
LPAD(e.nic,5,'00000') AS nic,
|
||||
CONCAT(LPAD(e.siren,9,0), LPAD(e.nic,5,0)) AS siret,
|
||||
LPAD(par.siren,9,0) AS siren,
|
||||
LPAD(e.nic,5,0) AS nic,
|
||||
e.siege,
|
||||
par.RS AS raisonSociale,
|
||||
/*sigle*/
|
||||
@ -1634,9 +1634,9 @@ function rechercheEnt(&$formR, $deb, $nbRep, $max, $sirenValide = false)
|
||||
id,
|
||||
source,
|
||||
source_id,
|
||||
CONCAT(siren,nic) AS siret,
|
||||
siren,
|
||||
nic,
|
||||
CONCAT(LPAD(siren,9,0),LPAD(nic,5,0)) AS siret,
|
||||
LPAD(siren,9,0) AS siren,
|
||||
LPAD(nic,5,0) AS nic,
|
||||
siege,
|
||||
raisonSociale,
|
||||
sigle,
|
||||
|
87
library/Scores/Locale/String.php
Normal file
87
library/Scores/Locale/String.php
Normal file
@ -0,0 +1,87 @@
|
||||
<?php
|
||||
/**
|
||||
* Miscellaneous functions to clean string.
|
||||
*/
|
||||
class Scores_Locale_String
|
||||
{
|
||||
/**
|
||||
* Clean up a string value.
|
||||
*
|
||||
* Resulting string contains only alphanumerics and separators.
|
||||
*
|
||||
* @param $string
|
||||
* A string to clean.
|
||||
* @param $clean_slash
|
||||
* Whether to clean slashes from the given string.
|
||||
* @return
|
||||
* The cleaned string.
|
||||
*/
|
||||
public static function cleanstring($string)
|
||||
{
|
||||
$transliterate = TRUE;
|
||||
$reduce_ascii = FALSE;
|
||||
$output = $string;
|
||||
|
||||
// Remove accents and transliterate
|
||||
if ($transliterate) {
|
||||
static $i18n_loaded = false;
|
||||
static $translations = array();
|
||||
if (!$i18n_loaded) {
|
||||
$path = realpath(dirname(__FILE__));
|
||||
if (is_file($path .'/i18n-ascii.txt')) {
|
||||
$translations = parse_ini_file($path .'/String/i18n-ascii.txt');
|
||||
}
|
||||
$i18n_loaded = true;
|
||||
}
|
||||
|
||||
$output = strtr($output, $translations);
|
||||
}
|
||||
|
||||
// Reduce to the subset of ASCII96 letters and numbers
|
||||
if ($reduce_ascii) {
|
||||
$pattern = '/[^a-zA-Z0-9\/]+/ ';
|
||||
$output = preg_replace($pattern, $separator, $output);
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
|
||||
public static function cleanutf8($string)
|
||||
{
|
||||
$transliterate = TRUE;
|
||||
$output = $string;
|
||||
|
||||
// Remove accents and transliterate
|
||||
if ($transliterate) {
|
||||
static $i18n_loaded = false;
|
||||
static $translations = array();
|
||||
if (!$i18n_loaded) {
|
||||
$path = realpath(dirname(__FILE__));
|
||||
if (is_file($path .'/i18n-ascii.txt')) {
|
||||
$translations = parse_ini_file($path .'/String/i18n-ascii.txt');
|
||||
}
|
||||
$i18n_loaded = true;
|
||||
}
|
||||
|
||||
$output = strtr($output, $translations);
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
|
||||
// Fixes the encoding to uf8
|
||||
public static function fixEncoding($in_str)
|
||||
{
|
||||
$cur_encoding = mb_detect_encoding($in_str) ;
|
||||
if($cur_encoding == "UTF-8" && mb_check_encoding($in_str,"UTF-8"))
|
||||
return $in_str;
|
||||
else
|
||||
return utf8_encode($in_str);
|
||||
} // fixEncoding
|
||||
|
||||
public static function cleanstring_deep($value)
|
||||
{
|
||||
$value = is_array($value) ?
|
||||
array_map('self::cleanstring_deep', $value) :
|
||||
cleanstring($value);
|
||||
return $value;
|
||||
}
|
||||
}
|
@ -1,13 +1,14 @@
|
||||
<?php
|
||||
// Generated by ZF's ./bin/classmap_generator.php
|
||||
return array(
|
||||
'Scores_Auth_Adapter_Db' => dirname(__FILE__) . '/Auth/Adapter/Db.php',
|
||||
'Scores_Auth_Adapter_Ws' => dirname(__FILE__) . '/Auth/Adapter/Ws.php',
|
||||
'Scores_Validate_IpInNetwork' => dirname(__FILE__) . '/Validate/IpInNetwork.php',
|
||||
'Scores_Wkhtml_Pdf' => dirname(__FILE__) . '/Wkhtml/Pdf.php',
|
||||
'Scores_Ws_Doc' => dirname(__FILE__) . '/Ws/Doc.php',
|
||||
'Scores_Ws_Exception' => dirname(__FILE__) . '/Ws/Exception.php',
|
||||
'Scores_Ws_Form_GetIdentite' => dirname(__FILE__) . '/Ws/Form/GetIdentite.php',
|
||||
'Scores_Ws_Server' => dirname(__FILE__) . '/Ws/Server.php',
|
||||
'Scores_Ws_Trigger' => dirname(__FILE__) . '/Ws/Trigger.php',
|
||||
'Scores_Auth_Adapter_Db' => dirname(__FILE__) . '//Auth/Adapter/Db.php',
|
||||
'Scores_Auth_Adapter_Ws' => dirname(__FILE__) . '//Auth/Adapter/Ws.php',
|
||||
'Scores_Locale_String' => dirname(__FILE__) . '//Locale/String.php',
|
||||
'Scores_Validate_IpInNetwork' => dirname(__FILE__) . '//Validate/IpInNetwork.php',
|
||||
'Scores_Wkhtml_Pdf' => dirname(__FILE__) . '//Wkhtml/Pdf.php',
|
||||
'Scores_Ws_Doc' => dirname(__FILE__) . '//Ws/Doc.php',
|
||||
'Scores_Ws_Exception' => dirname(__FILE__) . '//Ws/Exception.php',
|
||||
'Scores_Ws_Form_GetIdentite' => dirname(__FILE__) . '//Ws/Form/GetIdentite.php',
|
||||
'Scores_Ws_Server' => dirname(__FILE__) . '//Ws/Server.php',
|
||||
'Scores_Ws_Trigger' => dirname(__FILE__) . '//Ws/Trigger.php',
|
||||
);
|
||||
|
625
library/SdMetier/Infogreffe/DocAC.php
Normal file
625
library/SdMetier/Infogreffe/DocAC.php
Normal file
@ -0,0 +1,625 @@
|
||||
<?php
|
||||
require_once dirname(__FILE__) . '/Service.php';
|
||||
|
||||
/**
|
||||
* Infogreffe : Document Acte
|
||||
*/
|
||||
class SdMetier_Infogreffe_DocAC extends SdMetier_Infogreffe_Service
|
||||
{
|
||||
|
||||
const INT = 1000;
|
||||
|
||||
/**
|
||||
* Db Adapter
|
||||
* @var Zend_Db_Adapter_Abstract
|
||||
*/
|
||||
public $db;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param string $siren
|
||||
*/
|
||||
public function __construct($siren, $db = null)
|
||||
{
|
||||
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;
|
||||
|
||||
$actesM = new Application_Model_JoGreffesActes($this->db);
|
||||
|
||||
//Requete WebService
|
||||
$actesXML = null;
|
||||
if ( $onlyDb === false ) {
|
||||
//Infogreffe webservice
|
||||
try {
|
||||
$xml = $this->callRequest();
|
||||
$requestOk = true;
|
||||
} catch( Exception $e ) {
|
||||
$requestOk = false;
|
||||
//file_put_contents('debug.log', $e->getMessage());
|
||||
//@todo : get error message
|
||||
//echo $e->getMessage();
|
||||
}
|
||||
if ( $requestOk === true ) {
|
||||
try {
|
||||
$actesM->update(array('actif' => 0), 'siren='.$this->siren);
|
||||
} catch(Zend_Db_Exception $e) {
|
||||
|
||||
}
|
||||
$actesXML = $this->formatList($xml);
|
||||
}
|
||||
}
|
||||
|
||||
//Lecture de la base de données
|
||||
$sql = $actesM->select()
|
||||
->from($actesM, array(
|
||||
'siren',
|
||||
'numRC',
|
||||
'LPAD(numGreffe,4,0) AS numGreffe',
|
||||
'pdfLink',
|
||||
'pdfSize',
|
||||
'pdfPage',
|
||||
'num_depot',
|
||||
'date_depot',
|
||||
'date_acte',
|
||||
'LPAD(num_acte,2,0) AS num_acte',
|
||||
'type_acte',
|
||||
'type_acte_libelle',
|
||||
'nbpages_acte',
|
||||
'decision_nature',
|
||||
'decision_libelle',
|
||||
'mode_diffusion'
|
||||
))
|
||||
->where('siren=?', $this->siren)
|
||||
->where('actif=1')
|
||||
->order('date_depot DESC')
|
||||
->order('num_depot DESC')
|
||||
->order('num_acte ASC')
|
||||
->order('date_acte DESC');
|
||||
$rows = $actesM->fetchAll($sql);
|
||||
|
||||
$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;
|
||||
$item->ActeDecisionNature = $row->decision_nature;
|
||||
$item->ActeDecisionLabel = $row->decision_libelle;
|
||||
|
||||
$decisions = $row->decision_nature;
|
||||
if (!empty($row->decision_nature) && !empty($row->decision_libelle)) {
|
||||
$decisions.= ' : ';
|
||||
}
|
||||
$decisions.= $row->decision_libelle;
|
||||
|
||||
$item->infos[] = $decisions;
|
||||
|
||||
$mode_diffusion = explode(',', $row->mode_diffusion);
|
||||
if (in_array('T',$mode_diffusion) || !empty($item->File)) {
|
||||
$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
|
||||
* @param int $orderId
|
||||
* @throws Exception
|
||||
* @return string
|
||||
* Return the full path of the file
|
||||
*/
|
||||
public function getCommandeT($depotDate, $depotNum, $acteType, $acteDate, $acteNum, $orderId = null)
|
||||
{
|
||||
//Lire dans la base de données
|
||||
$actesM = new Application_Model_JoGreffesActes($this->db);
|
||||
|
||||
$sql = $actesM->select()
|
||||
->from($actesM, array(
|
||||
'siren',
|
||||
'numRC',
|
||||
'LPAD(numGreffe,4,0) AS numGreffe',
|
||||
'pdfLink',
|
||||
'num_depot',
|
||||
'date_depot',
|
||||
'date_acte',
|
||||
'LPAD(num_acte,2,0) AS num_acte',
|
||||
'type_acte',
|
||||
))
|
||||
->where('siren=?', $this->siren)
|
||||
->where('num_depot=?', $depotNum)
|
||||
->where('date_depot=?', $depotDate)
|
||||
->where('num_acte=?', $acteNum)
|
||||
->where('date_acte=?', $acteDate)
|
||||
->where('type_acte=?', $acteType);
|
||||
|
||||
$row = $actesM->fetchRow($sql);
|
||||
if ( null === $row ) {
|
||||
throw new Exception('Not exist');
|
||||
}
|
||||
|
||||
$this->mode_diffusion = 'T';
|
||||
$this->reference_client = 'T'.date('YmdHis');
|
||||
$this->greffe = $row->numGreffe;
|
||||
$this->dossier_millesime = substr($row->numRC,0,2);
|
||||
$this->dossier_statut = substr($row->numRC,2,1);
|
||||
$this->dossier_chrono = substr($row->numRC,3);
|
||||
$this->date_depot = $row->date_depot;
|
||||
$this->num_depot = $row->num_depot;
|
||||
$this->date_acte = $row->date_acte;
|
||||
$this->num = $row->num_acte;
|
||||
|
||||
//Needed element for filename
|
||||
$date = $row->date_acte;
|
||||
if ( $date == '0000-00-00' ) {
|
||||
$date = $row->date_depot;
|
||||
}
|
||||
$type = $row->type_acte;
|
||||
$num = $row->num_acte;
|
||||
$options = $row->numGreffe . '-' . substr($row->numRC,0,2) . '-' . substr($row->numRC,2,1) . '-' . substr($row->numRC,3) . '-' . $row->num_depot;
|
||||
|
||||
//Set filename
|
||||
$filename = $this->getFilePath($date) . '/' . $this->getFileName($date, $num, $type, $options);
|
||||
|
||||
if ( $row->pdfLink != '' ) {
|
||||
|
||||
//Set the filename
|
||||
$filename = $this->getFilePath($date) . '/' . $row->pdfLink;
|
||||
|
||||
//Check if filename exist
|
||||
if ( !file_exists($this->config->storage->path . '/' . $filename) ) {
|
||||
throw new Exception('File not found', self::INT);
|
||||
}
|
||||
|
||||
} elseif ( file_exists($this->config->storage->path . '/' . $filename) ) {
|
||||
|
||||
//Analyser le fichier - Nombre de page et taille
|
||||
$infos = $this->pdfInfos($this->config->storage->path . '/' . $filename);
|
||||
|
||||
//Enregistrer les infos du fichier dans la base de données
|
||||
if (false !== $infos) {
|
||||
$this->dbSetFile(basename($filename), $infos['size'], $infos['pages'], $infos['version']);
|
||||
} else {
|
||||
$this->dbSetFile(basename($filename));
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
try {
|
||||
$xml = $this->callRequest();
|
||||
} catch(Exception $e) {
|
||||
throw new Exception($e->getMessage(), $e->getCode());
|
||||
}
|
||||
|
||||
$acte = $this->formatItem($xml);
|
||||
$url = $acte['actes'][0]['url_acces'];
|
||||
if (empty($url)) {
|
||||
throw new Exception('File url not given');
|
||||
}
|
||||
|
||||
if ( $orderId !== null ) {
|
||||
$commandeM = new Application_Model_Sdv1GreffeCommandesAc();
|
||||
$commandeM->update(array(
|
||||
'cmdUrl'=> $url,
|
||||
'dateCommande' => date('YmdHis'),
|
||||
), 'id='.$orderId);
|
||||
}
|
||||
|
||||
//Récupérer le fichier
|
||||
$getfile = $this->download($url, $filename);
|
||||
|
||||
//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(basename($filename), $infos['size'], $infos['pages'], $infos['version']);
|
||||
} else {
|
||||
$this->dbSetFile(basename($filename));
|
||||
}
|
||||
}
|
||||
|
||||
return $filename;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param unknown $depotDate
|
||||
* @param unknown $depotNum
|
||||
* @param unknown $acteType
|
||||
* @param unknown $acteDate
|
||||
* @param unknown $acteNum
|
||||
* @param string $reference
|
||||
* @throws Exception
|
||||
* @return boolean
|
||||
*/
|
||||
public function getCommandeC($depotDate, $depotNum, $acteType, $acteDate, $acteNum, $reference = '')
|
||||
{
|
||||
//Lire dans la base de données
|
||||
$actesM = new Application_Model_JoGreffesActes();
|
||||
$sql = $actesM->select()
|
||||
->from($actesM, array(
|
||||
'siren',
|
||||
'numRC',
|
||||
'LPAD(numGreffe,4,0) AS numGreffe',
|
||||
'pdfLink',
|
||||
'num_depot',
|
||||
'date_depot',
|
||||
'date_acte',
|
||||
'LPAD(num_acte,2,0) AS num_acte',
|
||||
'type_acte',
|
||||
))
|
||||
->where('siren=?', $this->siren)
|
||||
->where('num_depot=?', $depotNum)
|
||||
->where('date_depot=?', $depotDate)
|
||||
->where('num_acte=?', $acteNum)
|
||||
->where('date_acte=?', $acteDate)
|
||||
->where('type_acte=?', $acteType);
|
||||
$row = $actesM->fetchRow($sql);
|
||||
if ( null === $row ) {
|
||||
throw new Exception('Not exist');
|
||||
}
|
||||
|
||||
$this->mode_diffusion = 'C';
|
||||
$this->reference_client = $reference;
|
||||
|
||||
//Générer les paramètres de commande depuis la base de données
|
||||
$this->greffe = $row->numGreffe;
|
||||
$this->dossier_millesime = substr($row->numRC,0,2);
|
||||
$this->dossier_statut = substr($row->numRC,2,1);
|
||||
$this->dossier_chrono = substr($row->numRC,3);
|
||||
$this->num_depot = $row->num_depot;
|
||||
$this->type_acte = $row->type_acte;
|
||||
$this->date_acte = $row->date_acte;
|
||||
$this->num = $row->num_acte;
|
||||
|
||||
//Faire la requete
|
||||
try {
|
||||
$xml = $this->callRequest();
|
||||
} catch(Exception $e) {
|
||||
//La prise en charge du courrier est effective
|
||||
if ( $e->getCode() != 17 ) {
|
||||
throw new Exception($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param string $date
|
||||
* Date de l'acte au format AAAA-MM-JJ
|
||||
* @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)
|
||||
{
|
||||
$date = substr($date,0,4) . substr($date,5,2) . substr($date,8,2);
|
||||
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)
|
||||
{
|
||||
$dir = 'actes/' . substr($date,0,4) . '/' . substr($date,5,2);
|
||||
if ( !file_exists( $this->config->storage->path . '/' . $dir ) ) {
|
||||
mkdir($this->config->storage->path . '/' . $dir, 0777, true);
|
||||
}
|
||||
return $dir;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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;
|
||||
if ($infoActe->getElementsByTagName('date_acte')->item(0)->nodeValue == '') {
|
||||
$actenum['date_acte'] = '0000-00-00';
|
||||
}
|
||||
$actenum['num_acte'] = $infoActe->getElementsByTagName('num_acte')->item(0)->nodeValue;
|
||||
$actenum['type_acte'] = $infoActe->getElementsByTagName('type_acte')->item(0)->nodeValue;
|
||||
$actenum['type_acte_libelle'] = $infoActe->getElementsByTagName('type_acte_libelle')->item(0)->nodeValue;
|
||||
$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)
|
||||
{
|
||||
foreach ($list['depot'] as $depot) {
|
||||
$data = array(
|
||||
'siren' => $list['num_siren'],
|
||||
'numRC' => $list['num_gest']['dossier_millesime'].
|
||||
$list['num_gest']['dossier_statut'].$list['num_gest']['dossier_chrono'],
|
||||
'numGreffe' => $list['num_gest']['greffe'],
|
||||
'num_depot' => $list['num_depot'],
|
||||
'date_depot' => $list['date_depot'],
|
||||
'date_acte' => $depot['date_acte'],
|
||||
'num_acte' => $depot['num_acte'],
|
||||
'type_acte' => $depot['type_acte'],
|
||||
'type_acte_libelle' => $depot['type_acte_libelle'],
|
||||
'nbpages_acte' => $depot['nbpages_acte'],
|
||||
'decision_nature' => empty($depot['decision']['nature']) ? '' : $depot['decision']['nature'] ,
|
||||
'decision_libelle' => empty($depot['decision']['libelle']) ? '' : $depot['decision']['libelle'] ,
|
||||
'mode_diffusion' => join(',',$depot['mode_diffusion']),
|
||||
'actif' => 1,
|
||||
);
|
||||
|
||||
//Only new element are inserted
|
||||
try {
|
||||
$acteM = new Application_Model_JoGreffesActes($this->db);
|
||||
$sql = $acteM->select()
|
||||
->where('siren=?', $list['num_siren'])
|
||||
->where('num_depot=?', intval($list['num_depot']))
|
||||
->where('date_depot=?', $list['date_depot'])
|
||||
//->where('date_acte=?', $depot['date_acte'])
|
||||
->where('num_acte=?', intval($depot['num_acte']))
|
||||
->order('dateInsert DESC');
|
||||
$rows = $acteM->fetchAll($sql);
|
||||
} catch(Zend_Db_Adapter_Exception $e) {
|
||||
throw new Exception($e->getMessage());
|
||||
}
|
||||
|
||||
//Insert new element
|
||||
if ( count($rows)==0 ) {
|
||||
try {
|
||||
//Add dateInsert
|
||||
$data['dateInsert'] = date('YmdHis');
|
||||
$result = $acteM->insert($data);
|
||||
} catch(Zend_Exception $e) {
|
||||
throw new Exception($e->getMessage());
|
||||
}
|
||||
}
|
||||
//Update information
|
||||
else {
|
||||
//Correct multiple item
|
||||
$item = $rows[0];
|
||||
if ( count($rows) > 1 ) {
|
||||
try {
|
||||
$result = $acteM->delete(array(
|
||||
'siren='.$this->siren,
|
||||
'num_depot='.intval($list['num_depot']),
|
||||
'date_depot="'.$list['date_depot'].'"',
|
||||
'num_acte='.intval($depot['num_acte']),
|
||||
'id!='.$item->id,
|
||||
));
|
||||
} catch(Zend_Exception $e) {
|
||||
throw new Exception($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
$result = $acteM->update($data, 'id='.$item->id);
|
||||
} catch(Zend_Exception $e) {
|
||||
throw new Exception($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set file informations in database
|
||||
* @param string $filename
|
||||
* @param int $size
|
||||
* @param int $numberOfPage
|
||||
* @param string $version
|
||||
* @return boolean
|
||||
*/
|
||||
protected function dbSetFile($filename, $size = 0, $numberOfPage = '', $version = '')
|
||||
{
|
||||
$data = array(
|
||||
'pdfLink' => $filename,
|
||||
'pdfSize' => $size,
|
||||
'pdfPage' => $numberOfPage,
|
||||
'pdfVer' => $version,
|
||||
'pdfDate' => date('Ymd'),
|
||||
);
|
||||
|
||||
$where = array(
|
||||
'siren='.$this->siren,
|
||||
'num_depot='.$this->num_depot,
|
||||
'date_depot="'.$this->date_depot.'"',
|
||||
'date_acte="'.$this->date_acte.'"',
|
||||
'num_acte='.$this->num,
|
||||
);
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
}
|
586
library/SdMetier/Infogreffe/DocBI.php
Normal file
586
library/SdMetier/Infogreffe/DocBI.php
Normal file
@ -0,0 +1,586 @@
|
||||
<?php
|
||||
require_once dirname(__FILE__) . '/Service.php';
|
||||
|
||||
/**
|
||||
* Infogreffe : Document Bilan
|
||||
*/
|
||||
class SdMetier_Infogreffe_DocBI extends SdMetier_Infogreffe_Service
|
||||
{
|
||||
|
||||
const INT = 1000;
|
||||
|
||||
/**
|
||||
* 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;
|
||||
|
||||
$bilansM = new Application_Model_JoGreffesBilans();
|
||||
|
||||
//Requete WebService
|
||||
$bilansXML = null;
|
||||
if ( $onlyDb === false ) {
|
||||
//Infogreffe webservice
|
||||
try {
|
||||
$xml = $this->callRequest();
|
||||
$requestOk = true;
|
||||
} catch( Exception $e ) {
|
||||
$requestOk = false;
|
||||
//@todo : get error message
|
||||
}
|
||||
if ( $requestOk === true ) {
|
||||
//Set All line state to 0
|
||||
try {
|
||||
$bilansM->update(array('actif' => 0), 'siren='.$this->siren);
|
||||
} catch(Zend_Db_Exception $e) {
|
||||
|
||||
}
|
||||
$bilansXML = $this->formatList($xml);
|
||||
}
|
||||
}
|
||||
|
||||
//Lecture de la base de données
|
||||
$sql = $bilansM->select()
|
||||
->from($bilansM, array(
|
||||
'siren',
|
||||
'numRC',
|
||||
'LPAD(numGreffe,4,0) AS numGreffe',
|
||||
'pdfLink',
|
||||
'pdfSize',
|
||||
'pdfPage',
|
||||
'millesime',
|
||||
'num_depot',
|
||||
'date_cloture',
|
||||
'type_comptes',
|
||||
'mode_diffusion',
|
||||
'duree_exercice',
|
||||
'saisie_date',
|
||||
'saisie_code',
|
||||
'pages',
|
||||
))
|
||||
->where('siren=?', $this->siren)
|
||||
->where('actif=1')
|
||||
->order('date_cloture DESC')
|
||||
->order('num_depot DESC')
|
||||
->order('dateInsert DESC');
|
||||
//GROUP BY type_comptes, date_cloture AND ORDER BY num_depot DESC
|
||||
$rows = $bilansM->fetchAll($sql);
|
||||
|
||||
$bilans = array();
|
||||
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;
|
||||
if ( empty($row->type_comptes) ) {
|
||||
$item->Type = 'sociaux';
|
||||
} else {
|
||||
$item->Type = $row->type_comptes;
|
||||
}
|
||||
$mode_diffusion = explode(',', $row->mode_diffusion);
|
||||
|
||||
if (in_array('T', $mode_diffusion) || !empty($item->File)) {
|
||||
$item->ModeDiffusion = 'T';
|
||||
} elseif (in_array('C',$mode_diffusion)) {
|
||||
$item->ModeDiffusion = 'C';
|
||||
} else {
|
||||
$item->ModeDiffusion = '';
|
||||
}
|
||||
$item->DureeExercice = $row->duree_exercice;
|
||||
|
||||
/**
|
||||
* Following data are not as expected as the type and other data could change
|
||||
* Only num depot don't change.
|
||||
*/
|
||||
$item->SaisieDate = $row->saisie_date;
|
||||
$item->SaisieCode = $row->saisie_code;
|
||||
switch ( $row->saisie_code ) {
|
||||
case '00': $item->SaisieLabel = "Bilan saisi sans anomalie"; break;
|
||||
case '01': $item->SaisieLabel = "Bilan saisi avec des incohérences comptables à la source du document (issues du remettant)"; break;
|
||||
case '02': $item->SaisieLabel = "Bilan avec Actif, Passif ou Compte de Résultat nul"; break;
|
||||
case '03': $item->SaisieLabel = "Bilan incomplet (des pages manquent)"; break;
|
||||
case '04': $item->SaisieLabel = "Bilan complet non détaillé (seuls les totaux et sous totaux sont renseignés)"; break;
|
||||
case '05': $item->SaisieLabel = "Bilan reçu en double exemplaire"; break;
|
||||
case '06': $item->SaisieLabel = "Bilan intermédiaire - Situation provisoire"; break;
|
||||
case '07': $item->SaisieLabel = "Bilan illisible"; break;
|
||||
case 'A7': $item->SaisieLabel = "Bilan illisible, présentant un cadre gris très foncés (dans lesquels sont inscrits en général les totaux)"; break;
|
||||
case 'B7': $item->SaisieLabel = "Bilan manuscrits"; break;
|
||||
case 'C7': $item->SaisieLabel = "Bilan illisible, présentant des caractères trop gras"; break;
|
||||
case 'D7': $item->SaisieLabel = "Bilan scanné en biais ou qui présentent des pages rognées"; break;
|
||||
case 'E7': $item->SaisieLabel = "Bilan numérisés trop clairement (comme une imprimante dont la cartouche est presque vide)"; break;
|
||||
case 'F7': $item->SaisieLabel = "Bilan illisible"; break;
|
||||
case '08': $item->SaisieLabel = "Bilan consolidé"; break;
|
||||
case '09': $item->SaisieLabel = "Déclaration d'impôts"; break;
|
||||
case '10': $item->SaisieLabel = "Document autre que bilan"; break;
|
||||
case '11': $item->SaisieLabel = "Bilan de clôture de liquidation"; break;
|
||||
case '12': $item->SaisieLabel = "Bilan de Société financière"; break;
|
||||
case '13': $item->SaisieLabel = "Bilan de Société d'assurance"; break;
|
||||
case '14': $item->SaisieLabel = "Bilan de Société immobilière"; break;
|
||||
case '15': $item->SaisieLabel = "Bilan de Société étrangère"; break;
|
||||
default: $item->SaisieLabel = ""; break;
|
||||
}
|
||||
$bilans[] = $item;
|
||||
}
|
||||
}
|
||||
|
||||
return $bilans;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Download file
|
||||
* @param string $dateCloture
|
||||
* Format AAAA-MM-DD
|
||||
* @param string $type
|
||||
* sociaux ou consolides
|
||||
* @params int $orderId
|
||||
* Id de commande pour l'enregistrement dans la table de gestion
|
||||
* @throws Exception
|
||||
* @return string
|
||||
* Return path (not complete) and filename
|
||||
*/
|
||||
public function getCommandeT($dateCloture = null, $type = 'sociaux', $orderId = null)
|
||||
{
|
||||
//Lire dans la base de données
|
||||
$bilansM = new Application_Model_JoGreffesBilans();
|
||||
$sql = $bilansM->select()
|
||||
->from($bilansM, array(
|
||||
'siren',
|
||||
'numRC',
|
||||
'LPAD(numGreffe,4,0) AS numGreffe',
|
||||
'pdfLink',
|
||||
'millesime',
|
||||
'num_depot',
|
||||
'date_cloture',
|
||||
'type_comptes',
|
||||
))
|
||||
->where('siren=?', $this->siren)
|
||||
->where('date_cloture=?', $dateCloture);
|
||||
if ( $type == 'sociaux' || $type == '' ) {
|
||||
$sql->where("(type_comptes='sociaux' OR type_comptes='')");
|
||||
} else {
|
||||
$sql->where('type_comptes=?',$type);
|
||||
}
|
||||
$sql->order('dateInsert DESC')->order('num_depot DESC')->limit(1);
|
||||
|
||||
$row = $bilansM->fetchRow($sql);
|
||||
if ( null === $row ) {
|
||||
throw new Exception("Element doesn't exist");
|
||||
}
|
||||
|
||||
$this->mode_diffusion = 'T';
|
||||
$this->reference_client = 'T'.date('YmdHis');
|
||||
$this->greffe = $row->numGreffe;
|
||||
$this->dossier_millesime = substr($row->numRC,0,2);
|
||||
$this->dossier_statut = substr($row->numRC,2,1);
|
||||
$this->dossier_chrono = substr($row->numRC,3);
|
||||
$this->num_depot = $row->num_depot;
|
||||
$this->date_cloture = $row->date_cloture;
|
||||
$this->type_comptes = $row->type_comptes;
|
||||
|
||||
//Set the filename
|
||||
$filename = $this->getFilePath($type, $dateCloture) . '/' . $this->getFileName($type, $dateCloture);
|
||||
|
||||
if ($row->pdfLink != '') {
|
||||
|
||||
//Check if filename exist
|
||||
if ( !file_exists($this->config->storage->path . '/' . $filename) ) {
|
||||
throw new Exception('File not found', self::INT);
|
||||
}
|
||||
|
||||
} elseif ( file_exists($this->config->storage->path . '/' . $filename) ) {
|
||||
|
||||
//Analyser le fichier - Nombre de page et taille
|
||||
$infos = $this->pdfInfos($this->config->storage->path . '/' . $filename);
|
||||
|
||||
//Enregistrer les infos du fichier dans la base de données
|
||||
if (false !== $infos) {
|
||||
$this->dbSetFile(basename($filename), $infos['size'], $infos['pages'], $infos['version']);
|
||||
} else {
|
||||
$this->dbSetFile(basename($filename));
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
try {
|
||||
$xml = $this->callRequest();
|
||||
} catch(Exception $e) {
|
||||
throw new Exception($e->getMessage(), $e->getCode());
|
||||
}
|
||||
|
||||
$bilan = $this->formatItem($xml);
|
||||
$url = $bilan['url_acces'];
|
||||
if ( empty($url) ) {
|
||||
throw new Exception('File url not given');
|
||||
}
|
||||
|
||||
if ( $orderId !== null ) {
|
||||
$commandeM = new Application_Model_Sdv1GreffeCommandesBi();
|
||||
$commandeM->update(array(
|
||||
'cmdUrl'=> $url,
|
||||
'dateCommande' => date('YmdHis'),
|
||||
), 'id='.$orderId);
|
||||
}
|
||||
|
||||
//Récupérer le fichier
|
||||
$getfile = $this->download($url, $filename);
|
||||
|
||||
//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(basename($filename), $infos['size'], $infos['pages'], $infos['version']);
|
||||
} else {
|
||||
$this->dbSetFile(basename($filename));
|
||||
}
|
||||
}
|
||||
|
||||
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()
|
||||
->from($bilansM, array(
|
||||
'siren',
|
||||
'numRC',
|
||||
'LPAD(numGreffe,4,0) AS numGreffe',
|
||||
'pdfLink',
|
||||
'millesime',
|
||||
'num_depot',
|
||||
'date_cloture',
|
||||
'type_comptes',
|
||||
))
|
||||
->where('siren=?', $this->siren)
|
||||
->where('date_cloture=?', $dateCloture);
|
||||
if ($type=='sociaux') {
|
||||
$sql->where("(type_comptes='sociaux' OR type_comptes='')");
|
||||
} else {
|
||||
$sql->where('type_comptes=?',$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) {
|
||||
//La prise en charge du courrier est effective
|
||||
if ( $e->getCode() != 17 ) {
|
||||
throw new Exception($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Name of file
|
||||
* @param string $type
|
||||
* @param string $dateCloture
|
||||
* Format : AAAA-MM-JJ
|
||||
* @return string
|
||||
*/
|
||||
public function getFileName($type, $dateCloture)
|
||||
{
|
||||
if ($type=='') {
|
||||
$type = 'sociaux';
|
||||
}
|
||||
$date = substr($dateCloture,0,4).substr($dateCloture,5,2).substr($dateCloture,8,2);
|
||||
|
||||
return 'bilan-' . $this->siren . '-' . $type . '-' . $date . '.pdf';
|
||||
}
|
||||
|
||||
/**
|
||||
* Path of file
|
||||
* @param string $type
|
||||
* @param string $dateCloture
|
||||
* Format : AAAA-MM-JJ
|
||||
* @return string
|
||||
*/
|
||||
public function getFilePath($type, $dateCloture)
|
||||
{
|
||||
if ($type=='') {
|
||||
$type = 'sociaux';
|
||||
}
|
||||
$dir = 'bilans' . '/' . $type . '/' . substr($dateCloture,0,4);
|
||||
if ( !file_exists( $this->config->storage->path . '/' . $dir ) ) {
|
||||
mkdir($this->config->storage->path . '/' . $dir, 0777, true);
|
||||
}
|
||||
return $dir;
|
||||
}
|
||||
|
||||
/**
|
||||
* Format XML to Array for a list of items
|
||||
* @param string $xml
|
||||
* @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' => intval($list['num_gest']['greffe']),
|
||||
'millesime' => $list['millesime'],
|
||||
'num_depot' => $list['num_depot'],
|
||||
'date_cloture' => $list['date_cloture_iso'],
|
||||
'type_comptes' => $list['type_comptes'],
|
||||
'mode_diffusion' => join(',',$list['mode_diffusion']),
|
||||
'actif' => 1,
|
||||
);
|
||||
|
||||
$this->db->getProfiler()->setEnabled(true);
|
||||
|
||||
try {
|
||||
$bilanM = new Application_Model_JoGreffesBilans();
|
||||
$sql = $bilanM->select()
|
||||
->where('siren=?', $this->siren)
|
||||
->where('num_depot=?', $list['num_depot'])
|
||||
->where('date_cloture=?', $list['date_cloture_iso'])
|
||||
//->where('type_comptes=?', $list['type_comptes'])
|
||||
->order('dateInsert ASC');
|
||||
$rows = $bilanM->fetchAll($sql);
|
||||
} catch(Zend_Db_Exception $e) {
|
||||
/*echo $query = $this->db->getProfiler()->getLastQueryProfile()->getQuery();
|
||||
echo "\n";
|
||||
$queryParams = $this->db->getProfiler()->getLastQueryProfile()->getQueryParams();
|
||||
print_r($queryParams);
|
||||
echo "\n";*/
|
||||
throw new Exception($e->getMessage());
|
||||
}
|
||||
|
||||
$this->db->getProfiler()->setEnabled(false);
|
||||
|
||||
if ( count($rows) == 0 ) {
|
||||
//Add dateInsert
|
||||
$data['dateInsert'] = date('YmdHis');
|
||||
try {
|
||||
$result = $bilanM->insert($data);
|
||||
} catch(Zend_Exception $e) {
|
||||
throw new Exception($e->getMessage());
|
||||
}
|
||||
} else {
|
||||
//Correct multiple item
|
||||
$item = $rows[0];
|
||||
if ( count($rows) > 1 ) {
|
||||
try {
|
||||
$result = $bilanM->delete(array(
|
||||
$bilanM->getAdapter()->quoteInto('siren=?', $this->siren),
|
||||
$bilanM->getAdapter()->quoteInto('num_depot=?', $list['num_depot']),
|
||||
$bilanM->getAdapter()->quoteInto('date_cloture=?', $list['date_cloture_iso']),
|
||||
$bilanM->getAdapter()->quoteInto('type_comptes=?', $list['type_comptes']),
|
||||
'id!='.$item->id,
|
||||
));
|
||||
} catch(Zend_Exception $e) {
|
||||
throw new Exception($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
$result = $bilanM->update($data, 'id='.$item->id);
|
||||
} catch(Zend_Exception $e) {
|
||||
throw new Exception($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
if ($result) {
|
||||
return true;
|
||||
}
|
||||
|
||||
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 = 0, $numberOfPage = '', $version = '')
|
||||
{
|
||||
$data = array(
|
||||
'pdfLink' => $filename,
|
||||
'pdfSize' => $size,
|
||||
'pdfPage' => $numberOfPage,
|
||||
'pdfVer' => $version,
|
||||
'pdfDate' => date('Ymd'),
|
||||
);
|
||||
|
||||
$where = array(
|
||||
'siren='.$this->siren,
|
||||
'date_cloture="'.$this->date_cloture.'"',
|
||||
'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;
|
||||
}
|
||||
}
|
167
library/SdMetier/Infogreffe/DocST.php
Normal file
167
library/SdMetier/Infogreffe/DocST.php
Normal file
@ -0,0 +1,167 @@
|
||||
<?php
|
||||
require_once dirname(__FILE__) . '/Service.php';
|
||||
|
||||
/**
|
||||
* Infogreffe : Document Statut
|
||||
*/
|
||||
class SdMetier_Infogreffe_DocST extends SdMetier_Infogreffe_Service
|
||||
{
|
||||
|
||||
/**
|
||||
* Db Adapter
|
||||
* @var Zend_Db_Adapter_Abstract
|
||||
*/
|
||||
public $db;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param string $siren
|
||||
*/
|
||||
public function __construct($siren, $db = null)
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
//Set type
|
||||
$this->type_document = 'ST';
|
||||
|
||||
//Set Siren
|
||||
$this->siren = $siren;
|
||||
|
||||
//Get defaut database adapter
|
||||
if ($db === null) {
|
||||
$this->db = Zend_Db_Table_Abstract::getDefaultAdapter();
|
||||
} else {
|
||||
$this->db = $db;
|
||||
}
|
||||
}
|
||||
|
||||
public function getList()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function getCommandeT()
|
||||
{
|
||||
|
||||
$this->mode_diffusion = 'T';
|
||||
$this->reference_client = 'T'.date('YmdHis');
|
||||
|
||||
//Set the filename
|
||||
$filename = $this->getFilePath($type, $dateCloture) . '/' . $this->getFileName($type, $dateCloture);
|
||||
|
||||
try {
|
||||
$xml = $this->callRequest();
|
||||
} catch(Exception $e) {
|
||||
throw new Exception($e->getMessage(), $e->getCode());
|
||||
}
|
||||
|
||||
$item = $this->formatItem($xml);
|
||||
$url = $item['url_acces'];
|
||||
if ( empty($url) ) {
|
||||
throw new Exception('File url not given');
|
||||
}
|
||||
|
||||
if ( $orderId !== null ) {
|
||||
$commandeM = new Application_Model_Sdv1GreffeCommandesBi();
|
||||
$commandeM->update(array(
|
||||
'cmdUrl'=> $url,
|
||||
'dateCommande' => date('YmdHis'),
|
||||
), 'id='.$orderId);
|
||||
}
|
||||
|
||||
//Récupérer le fichier
|
||||
$getfile = $this->download($url, $filename);
|
||||
|
||||
//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(basename($filename), $infos['size'], $infos['pages'], $infos['version']);
|
||||
} else {
|
||||
$this->dbSetFile(basename($filename));
|
||||
}
|
||||
|
||||
|
||||
return $filename;
|
||||
}
|
||||
|
||||
/**
|
||||
* Name of file
|
||||
* @param string $type
|
||||
* @param string $dateCloture
|
||||
* Format : AAAA-MM-JJ
|
||||
* @return string
|
||||
*/
|
||||
public function getFileName($type, $dateCloture)
|
||||
{
|
||||
if ($type=='') {
|
||||
$type = 'sociaux';
|
||||
}
|
||||
$date = substr($dateCloture,0,4).substr($dateCloture,5,2).substr($dateCloture,8,2);
|
||||
|
||||
return 'ST-' . $this->siren . '-' . $type . '-' . $date . '.pdf';
|
||||
}
|
||||
|
||||
/**
|
||||
* Path of file
|
||||
* @param string $type
|
||||
* @param string $dateCloture
|
||||
* Format : AAAA-MM-JJ
|
||||
* @return string
|
||||
*/
|
||||
public function getFilePath($type, $dateCloture)
|
||||
{
|
||||
if ($type=='') {
|
||||
$type = 'sociaux';
|
||||
}
|
||||
$dir = 'bilans' . '/' . $type . '/' . substr($dateCloture,0,4);
|
||||
if ( !file_exists( $this->config->storage->path . '/' . $dir ) ) {
|
||||
mkdir($this->config->storage->path . '/' . $dir, 0777, true);
|
||||
}
|
||||
return $dir;
|
||||
}
|
||||
|
||||
/**
|
||||
* Format XML to Array for a list of items
|
||||
* @param string $xml
|
||||
* @return array
|
||||
*/
|
||||
protected function formatList($xml)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Format XML to Array for one item
|
||||
* @param string $xml
|
||||
* @return array
|
||||
*/
|
||||
protected function formatItem($xml)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Update informations about an item in database
|
||||
* @param array $list
|
||||
* @return boolean
|
||||
*/
|
||||
protected function dbUpdateItem($list)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Set file informations in database
|
||||
* @param string $filename
|
||||
* @param int $size
|
||||
* @param int $numberOfPage
|
||||
* @param string $version
|
||||
* @return boolean
|
||||
*/
|
||||
public function dbSetFile($filename, $size = 0, $numberOfPage = '', $version = '')
|
||||
{
|
||||
|
||||
}
|
||||
}
|
54
library/SdMetier/Infogreffe/README
Normal file
54
library/SdMetier/Infogreffe/README
Normal 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
|
425
library/SdMetier/Infogreffe/Service.php
Normal file
425
library/SdMetier/Infogreffe/Service.php
Normal file
@ -0,0 +1,425 @@
|
||||
<?php
|
||||
/**
|
||||
* Infogreffe provider
|
||||
*/
|
||||
class SdMetier_Infogreffe_Service
|
||||
{
|
||||
|
||||
/**
|
||||
* 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;
|
||||
|
||||
/**
|
||||
*
|
||||
* @var unknown
|
||||
*/
|
||||
public $type_acte;
|
||||
|
||||
/**
|
||||
* AC : Numéro de l'acte
|
||||
* @var string
|
||||
*/
|
||||
public $num;
|
||||
|
||||
/**
|
||||
* SIREN
|
||||
* @var string
|
||||
*/
|
||||
public $siren;
|
||||
|
||||
/**
|
||||
* Request XML
|
||||
* @var string
|
||||
*/
|
||||
protected $xml = '';
|
||||
|
||||
/**
|
||||
* Cache delay
|
||||
* @var unknown
|
||||
*/
|
||||
protected $cacheFiletime;
|
||||
|
||||
/**
|
||||
* Initialize configuration
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
//Load configuration
|
||||
if ( Zend_Registry::isRegistered('config') ){
|
||||
$c = Zend_Registry::get('config');
|
||||
} else {
|
||||
$c = new Zend_Config_Ini(APPLICATION_PATH . '/configs/application.ini', 'production');
|
||||
}
|
||||
$this->config = $c->profil->infogreffe;
|
||||
if ( null === $this->config ) {
|
||||
throw new Exception('Unable to load configuration file.');
|
||||
}
|
||||
|
||||
$this->cacheFiletime = $c->profil->infogreffe->cache->time;
|
||||
}
|
||||
|
||||
public function callRequest()
|
||||
{
|
||||
$fromCache = false;
|
||||
if ( $this->mode_diffusion == 'XL' && $this->fileIsCache() ){
|
||||
$fromCache = true;
|
||||
}
|
||||
|
||||
if ($fromCache) {
|
||||
$xml = $this->fileFromCache();
|
||||
} else {
|
||||
$xml = $this->getProduitsXML();
|
||||
}
|
||||
|
||||
$this->error($xml);
|
||||
|
||||
if ( $this->mode_diffusion == 'XL' ){
|
||||
$this->fileTocache($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);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
protected function fileIsCache()
|
||||
{
|
||||
$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];
|
||||
throw new Exception($errMsg, $errNum);
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
throw new Exception('XML content is empty.');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Download file from URL
|
||||
* @param string $url
|
||||
* @param string $filename
|
||||
* @throws Exception
|
||||
* @return string
|
||||
*/
|
||||
protected function download($url, $filename)
|
||||
{
|
||||
$file = $this->config->storage->path . '/' . $filename;
|
||||
|
||||
try {
|
||||
$client = new Zend_Http_Client($url);
|
||||
$client->setStream();
|
||||
$response = $client->request('GET');
|
||||
if ( $response->isSuccessful() && substr($response->getBody(),0,4)=='%PDF' ) {
|
||||
if ( copy($response->getStreamName(), $file) ) {
|
||||
return $file;
|
||||
} else {
|
||||
throw new Exception( "Erreur lors de l'ecriture du fichier" );
|
||||
}
|
||||
} else {
|
||||
throw new Exception( "Fichier non PDF" );
|
||||
}
|
||||
} catch (Zend_Http_Client_Exception $e) {
|
||||
throw new Exception( $e->getMessage() );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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);
|
||||
|
||||
$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') )
|
||||
{
|
||||
$num_gest = $commande->addChild('num_gest');
|
||||
$num_gest->addChild('greffe',$this->greffe);
|
||||
$num_gest->addChild('dossier_millesime',$this->dossier_millesime);
|
||||
$num_gest->addChild('dossier_statut',$this->dossier_statut);
|
||||
$num_gest->addChild('dossier_chrono',$this->dossier_chrono);
|
||||
$commande->addChild('num_depot',$this->num_depot);
|
||||
//Date de cloture au format dd/MM/yyyy
|
||||
$commande->addChild('date_cloture', $this->date_cloture);
|
||||
}
|
||||
// Commande de documents : actes
|
||||
elseif ( $this->type_document=='AC' )
|
||||
{
|
||||
$num_gest = $commande->addChild('num_gest');
|
||||
$num_gest->addChild('greffe',$this->greffe);
|
||||
$num_gest->addChild('dossier_millesime',$this->dossier_millesime);
|
||||
$num_gest->addChild('dossier_statut',$this->dossier_statut);
|
||||
$num_gest->addChild('dossier_chrono',$this->dossier_chrono);
|
||||
$commande->addChild('num_depot',$this->num_depot);
|
||||
$liste_actes = $commande->addChild('liste_actes');
|
||||
$liste_actes->addChild('acte')->addAttribute('num', $this->num);
|
||||
}
|
||||
}
|
||||
|
||||
//Set Command ID
|
||||
$commande->addChild('reference_client', $this->reference_client);
|
||||
|
||||
$xml = str_replace('<?xml version="1.0"?>', '', $xml->asXML());
|
||||
|
||||
$this->xml = $xml;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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();
|
||||
|
||||
$req = $this->xml;
|
||||
|
||||
if ($this->debug) {
|
||||
file_put_contents($this->type_document.'-'.$this->siren.'-'.$this->mode_diffusion.'.query', $this->xml);
|
||||
}
|
||||
|
||||
//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);
|
||||
|
||||
if ($this->debug) {
|
||||
file_put_contents($this->type_document.'-'.$this->siren.'-'.$this->mode_diffusion.'.response', $response);
|
||||
}
|
||||
|
||||
return $response;
|
||||
}
|
||||
}
|
80
library/SdMetier/Infogreffe/wsdl/prod.wsdl
Normal file
80
library/SdMetier/Infogreffe/wsdl/prod.wsdl
Normal 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>
|
80
library/SdMetier/Infogreffe/wsdl/test.wsdl
Normal file
80
library/SdMetier/Infogreffe/wsdl/test.wsdl
Normal file
@ -0,0 +1,80 @@
|
||||
|
||||
<definitions
|
||||
targetNamespace="java:com.experian.webserv.infogreffe"
|
||||
xmlns="http://schemas.xmlsoap.org/wsdl/"
|
||||
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
|
||||
xmlns:tns="java:com.experian.webserv.infogreffe"
|
||||
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
>
|
||||
<types>
|
||||
<schema targetNamespace='java:com.experian.webserv.infogreffe'
|
||||
xmlns='http://www.w3.org/2001/XMLSchema'>
|
||||
</schema>
|
||||
</types>
|
||||
<message name="getProduitsWebServicesXMLRequest">
|
||||
<part name="arg0" type="xsd:string" />
|
||||
</message>
|
||||
<message name="getProduitsWebServicesXMLResponse">
|
||||
<part name="return" type="xsd:string" />
|
||||
</message>
|
||||
<message name="getProduitsWebServicesRequest">
|
||||
<part name="arg0" type="xsd:string" />
|
||||
<part name="arg1" type="xsd:string" />
|
||||
<part name="arg2" type="xsd:string" />
|
||||
<part name="arg3" type="xsd:string" />
|
||||
<part name="arg4" type="xsd:string" />
|
||||
<part name="arg5" type="xsd:string" />
|
||||
<part name="arg6" type="xsd:string" />
|
||||
<part name="arg7" type="xsd:string" />
|
||||
<part name="arg8" type="xsd:string" />
|
||||
<part name="arg9" type="xsd:string" />
|
||||
<part name="arg10" type="xsd:string" />
|
||||
</message>
|
||||
<message name="getProduitsWebServicesResponse">
|
||||
<part name="return" type="xsd:string" />
|
||||
</message>
|
||||
<message name="getVersionRequest">
|
||||
</message>
|
||||
<message name="getVersionResponse">
|
||||
<part name="return" type="xsd:string" />
|
||||
</message>
|
||||
<portType name="WebServicesProduitsPortType">
|
||||
<operation name="getProduitsWebServicesXML">
|
||||
<input message="tns:getProduitsWebServicesXMLRequest"/>
|
||||
<output message="tns:getProduitsWebServicesXMLResponse"/>
|
||||
</operation>
|
||||
<operation name="getProduitsWebServices">
|
||||
<input message="tns:getProduitsWebServicesRequest"/>
|
||||
<output message="tns:getProduitsWebServicesResponse"/>
|
||||
</operation>
|
||||
<operation name="getVersion">
|
||||
<input message="tns:getVersionRequest"/>
|
||||
<output message="tns:getVersionResponse"/>
|
||||
</operation>
|
||||
</portType>
|
||||
<binding name="WebServicesProduitsBinding" type="tns:WebServicesProduitsPortType">
|
||||
<soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
|
||||
<operation name="getProduitsWebServicesXML">
|
||||
<soap:operation soapAction="urn:getProduitsWebServicesXML"/>
|
||||
<input><soap:body use="encoded" namespace='urn:WebServicesProduits' encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/></input>
|
||||
<output><soap:body use="encoded" namespace='urn:WebServicesProduits' encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/></output>
|
||||
</operation>
|
||||
<operation name="getProduitsWebServices">
|
||||
<soap:operation soapAction="urn:getProduitsWebServices"/>
|
||||
<input><soap:body use="encoded" namespace='urn:WebServicesProduits' encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/></input>
|
||||
<output><soap:body use="encoded" namespace='urn:WebServicesProduits' encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/></output>
|
||||
</operation>
|
||||
<operation name="getVersion">
|
||||
<soap:operation soapAction="urn:getVersion"/>
|
||||
<input><soap:body use="encoded" namespace='urn:Version' encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/></input>
|
||||
<output><soap:body use="encoded" namespace='urn:Version' encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/></output>
|
||||
</operation>
|
||||
</binding>
|
||||
<service name="WebServicesProduits">
|
||||
<documentation>Service Soap Experian, Service Produit</documentation>
|
||||
<port name="WebServicesProduitsPort" binding="tns:WebServicesProduitsBinding">
|
||||
<soap:address location="https://wsrcte.extelia.fr:80/WSContextInfogreffe/INFOGREFFE"/>
|
||||
</port>
|
||||
</service>
|
||||
</definitions>
|
77
library/SdMetier/Search/README
Normal file
77
library/SdMetier/Search/README
Normal file
@ -0,0 +1,77 @@
|
||||
Objectif :
|
||||
|
||||
- Réaliser plusieurs recherches et renvoyer le meilleur résultat
|
||||
- Algorithme pour déterminer le meilleur résultat
|
||||
|
||||
|
||||
Utiliser les différents mode de recherche en supprimant des critères
|
||||
Utiliser les critères en mode texte ou en tant que filtre
|
||||
|
||||
Utilisation de SphinxQL
|
||||
|
||||
Syntaxe d'un select
|
||||
SELECT
|
||||
select_expr [, select_expr ...]
|
||||
FROM index [, index2 ...]
|
||||
[WHERE where_condition]
|
||||
[GROUP [N] BY {col_name | expr_alias} [, {col_name | expr_alias}]]
|
||||
[WITHIN GROUP ORDER BY {col_name | expr_alias} {ASC | DESC}]
|
||||
[HAVING having_condition]
|
||||
[ORDER BY {col_name | expr_alias} {ASC | DESC} [, ...]]
|
||||
[LIMIT [offset,] row_count]
|
||||
[OPTION opt_name = opt_value [, ...]]
|
||||
[FACET facet_options[ FACET facet_options][ ...]]
|
||||
|
||||
SELECT * FROM test WHERE MATCH('@title hello @body world')
|
||||
OPTION ranker=bm25, max_matches=3000,
|
||||
field_weights=(title=10, body=3), agent_query_timeout=10000
|
||||
|
||||
OPTION
|
||||
field_weights
|
||||
index_weights
|
||||
max_matches
|
||||
ranker
|
||||
|
||||
WHERE clause. This clause will map both to fulltext query and filters.
|
||||
Comparison operators (=, !=, <, >, <=, >=), IN, AND, NOT, and BETWEEN are all supported
|
||||
and map directly to filters. OR is not supported yet but will be in the future.
|
||||
MATCH('query') is supported and maps to fulltext query. Query will be interpreted
|
||||
according to full-text query language rules. There must be at most one MATCH() in the clause.
|
||||
|
||||
|
||||
|
||||
Liste des opérateurs possible dans "select_expr"
|
||||
|
||||
Retour du select
|
||||
Liste des éléments indexés hors fulltext
|
||||
|
||||
|
||||
|
||||
mysql -h0 -P9306
|
||||
SELECT *, WEIGHT() weight FROM ent, ent_phx WHERE MATCH('peugeot') ORDER BY rang DESC;
|
||||
|
||||
mysql> SHOW META;
|
||||
+---------------+---------+
|
||||
| Variable_name | Value |
|
||||
+---------------+---------+
|
||||
| total | 1000 |
|
||||
| total_found | 2451 |
|
||||
| time | 0.022 |
|
||||
| keyword[0] | peugeot |
|
||||
| docs[0] | 2451 |
|
||||
| hits[0] | 3907 |
|
||||
+---------------+---------+
|
||||
6 rows in set (0.00 sec)
|
||||
|
||||
Multi-statement queries
|
||||
SELECT follow by SHOW META
|
||||
|
||||
|
||||
|
||||
SELECT * FROM myindex
|
||||
WHERE MATCH('@(title,content) find me fast');
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -1,9 +1,13 @@
|
||||
<?php
|
||||
// Generated by ZF's ./bin/classmap_generator.php
|
||||
return array(
|
||||
'SdMetier_Graydon_Service' => dirname(__FILE__) . '/Graydon/Service.php',
|
||||
'SdMetier_Scoring_Vars' => dirname(__FILE__) . '/Scoring/Vars.php',
|
||||
'SdMetier_Search_Engine' => dirname(__FILE__) . '/Search/Engine.php',
|
||||
'SdMetier_Sfr_Compile' => dirname(__FILE__) . '/Sfr/Compile.php',
|
||||
'SdMetier_Sfr_Scoring' => dirname(__FILE__) . '/Sfr/Scoring.php',
|
||||
'SdMetier_Graydon_Service' => dirname(__FILE__) . '//Graydon/Service.php',
|
||||
'SdMetier_Infogreffe_DocAC' => dirname(__FILE__) . '//Infogreffe/DocAC.php',
|
||||
'SdMetier_Infogreffe_DocBI' => dirname(__FILE__) . '//Infogreffe/DocBI.php',
|
||||
'SdMetier_Infogreffe_DocST' => dirname(__FILE__) . '//Infogreffe/DocST.php',
|
||||
'SdMetier_Infogreffe_Service' => dirname(__FILE__) . '//Infogreffe/Service.php',
|
||||
'SdMetier_Scoring_Vars' => dirname(__FILE__) . '//Scoring/Vars.php',
|
||||
'SdMetier_Search_Engine' => dirname(__FILE__) . '//Search/Engine.php',
|
||||
'SdMetier_Sfr_Compile' => dirname(__FILE__) . '//Sfr/Compile.php',
|
||||
'SdMetier_Sfr_Scoring' => dirname(__FILE__) . '//Sfr/Scoring.php',
|
||||
);
|
||||
|
1832
library/Vendors/sphinxapi/sphinxapi-2.2.7.php
Normal file
1832
library/Vendors/sphinxapi/sphinxapi-2.2.7.php
Normal file
File diff suppressed because it is too large
Load Diff
@ -213,8 +213,6 @@ class Entreprise extends Scores_Ws_Server
|
||||
if (empty($nbRep)) { $nbRep = 20; }
|
||||
if (empty($maxRep)) { $maxRep = 200; }
|
||||
|
||||
require_once 'i18n/cleanchar.php';
|
||||
|
||||
$entCriteres = new EntrepriseCriteres();
|
||||
$entCriteres = $criteres;
|
||||
$identifiant = $entCriteres->identifiant;
|
||||
@ -312,10 +310,10 @@ class Entreprise extends Scores_Ws_Server
|
||||
} else {
|
||||
|
||||
$O = $this->searchNomAdr(
|
||||
cleanstring($entCriteres->raisonSociale),
|
||||
cleanstring($entCriteres->adresse),
|
||||
Scores_Locale_String::cleanstring($entCriteres->raisonSociale),
|
||||
Scores_Locale_String::cleanstring($entCriteres->adresse),
|
||||
$entCriteres->codePostal,
|
||||
cleanstring($entCriteres->ville),
|
||||
Scores_Locale_String::cleanstring($entCriteres->ville),
|
||||
empty($entCriteres->siege) ? false : $entCriteres->siege,
|
||||
empty($entCriteres->actif) ? false : $entCriteres->actif,
|
||||
empty($position) ? 0 : $position,
|
||||
|
@ -213,8 +213,6 @@ class Entreprise extends Scores_Ws_Server
|
||||
if (empty($nbRep)) { $nbRep = 20; }
|
||||
if (empty($maxRep)) { $maxRep = 200; }
|
||||
|
||||
require_once 'i18n/cleanchar.php';
|
||||
|
||||
$entCriteres = new EntrepriseCriteres();
|
||||
$entCriteres = $criteres;
|
||||
$identifiant = $entCriteres->identifiant;
|
||||
@ -312,10 +310,10 @@ class Entreprise extends Scores_Ws_Server
|
||||
} else {
|
||||
|
||||
$O = $this->searchNomAdr(
|
||||
cleanstring($entCriteres->raisonSociale),
|
||||
cleanstring($entCriteres->adresse),
|
||||
Scores_Locale_String::cleanstring($entCriteres->raisonSociale),
|
||||
Scores_Locale_String::cleanstring($entCriteres->adresse),
|
||||
$entCriteres->codePostal,
|
||||
cleanstring($entCriteres->ville),
|
||||
Scores_Locale_String::cleanstring($entCriteres->ville),
|
||||
empty($entCriteres->siege) ? false : $entCriteres->siege,
|
||||
empty($entCriteres->actif) ? false : $entCriteres->actif,
|
||||
empty($position) ? 0 : $position,
|
||||
|
@ -126,8 +126,6 @@ class Entreprise extends Scores_Ws_Server
|
||||
if (empty($nbRep)) { $nbRep = 20; }
|
||||
if (empty($maxRep)) { $maxRep = 200; }
|
||||
|
||||
require_once 'i18n/cleanchar.php';
|
||||
|
||||
$entCriteres = new EntrepriseCriteres();
|
||||
$entCriteres = $criteres;
|
||||
$identifiant = $entCriteres->identifiant;
|
||||
@ -225,10 +223,10 @@ class Entreprise extends Scores_Ws_Server
|
||||
} else {
|
||||
|
||||
$O = $this->searchNomAdr(
|
||||
cleanstring($entCriteres->raisonSociale),
|
||||
cleanstring($entCriteres->adresse),
|
||||
Scores_Locale_String::cleanstring($entCriteres->raisonSociale),
|
||||
Scores_Locale_String::cleanstring($entCriteres->adresse),
|
||||
$entCriteres->codePostal,
|
||||
cleanstring($entCriteres->ville),
|
||||
Scores_Locale_String::cleanstring($entCriteres->ville),
|
||||
empty($entCriteres->siege) ? false : $entCriteres->siege,
|
||||
empty($entCriteres->actif) ? false : $entCriteres->actif,
|
||||
empty($position) ? 0 : $position,
|
||||
|
@ -122,7 +122,7 @@ class Entreprise extends Scores_Ws_Server
|
||||
$iDb = new WDB('sdv1');
|
||||
$sql = "SELECT count(*) AS nbPriv FROM ge_cs2 WHERE cs = 'P' AND dateFin >= NOW() AND dateSuppr=0 AND siren=$siren;";
|
||||
$ret = $iDb->query($sql);
|
||||
if ($ret['nbPriv']>0) {
|
||||
if ($ret[0]['nbPriv']>0) {
|
||||
$identite->Privileges = true;
|
||||
}
|
||||
}
|
||||
@ -207,8 +207,6 @@ class Entreprise extends Scores_Ws_Server
|
||||
if (empty($nbRep)) { $nbRep = 20; }
|
||||
if (empty($maxRep)) { $maxRep = 200; }
|
||||
|
||||
require_once 'i18n/cleanchar.php';
|
||||
|
||||
$entCriteres = new EntrepriseCriteres();
|
||||
$entCriteres = $criteres;
|
||||
$identifiant = $entCriteres->identifiant;
|
||||
@ -310,10 +308,10 @@ class Entreprise extends Scores_Ws_Server
|
||||
} else {
|
||||
|
||||
$O = $this->searchNomAdr(
|
||||
cleanstring($entCriteres->raisonSociale),
|
||||
cleanstring($entCriteres->adresse),
|
||||
Scores_Locale_String::cleanstring($entCriteres->raisonSociale),
|
||||
Scores_Locale_String::cleanstring($entCriteres->adresse),
|
||||
$entCriteres->codePostal,
|
||||
cleanstring($entCriteres->ville),
|
||||
Scores_Locale_String::cleanstring($entCriteres->ville),
|
||||
empty($entCriteres->siege) ? false : $entCriteres->siege,
|
||||
($entCriteres->actif==false) ? 2 : 1,
|
||||
empty($position) ? 0 : $position,
|
||||
|
@ -1356,7 +1356,6 @@ class Entreprise extends Scores_Ws_Server
|
||||
Zend_Registry::get('WsLogger')->info("rechercheEntreprise - ip : ".
|
||||
$_SERVER['REMOTE_ADDR'].", login:".$_SERVER['PHP_AUTH_USER']);
|
||||
|
||||
require_once 'i18n/cleanchar.php';
|
||||
switch ($type)
|
||||
{
|
||||
case 'ent':
|
||||
@ -1426,10 +1425,10 @@ class Entreprise extends Scores_Ws_Server
|
||||
|
||||
try {
|
||||
$O = $client->searchNomAdr(
|
||||
cleanstring($entCriteres->raisonSociale),
|
||||
cleanstring($entCriteres->adresse),
|
||||
Scores_Locale_String::cleanstring($entCriteres->raisonSociale),
|
||||
Scores_Locale_String::cleanstring($entCriteres->adresse),
|
||||
$entCriteres->codePostal,
|
||||
cleanstring($entCriteres->ville),
|
||||
Scores_Locale_String::cleanstring($entCriteres->ville),
|
||||
empty($entCriteres->siege) ? false : $entCriteres->siege,
|
||||
empty($entCriteres->actif) ? false : $entCriteres->actif,
|
||||
empty($position) ? 0 : $position,
|
||||
@ -1453,10 +1452,10 @@ class Entreprise extends Scores_Ws_Server
|
||||
$client = new SoapClient($this->wsdl, $this->wsdlOptions);
|
||||
try {
|
||||
$O = $client->searchDir(
|
||||
cleanstring($dirCriteres->nom),
|
||||
cleanstring($dirCriteres->prenom),
|
||||
Scores_Locale_String::cleanstring($dirCriteres->nom),
|
||||
Scores_Locale_String::cleanstring($dirCriteres->prenom),
|
||||
$dirCriteres->dateNaiss,
|
||||
cleanstring($dirCriteres->lieuNaiss),
|
||||
Scores_Locale_String::cleanstring($dirCriteres->lieuNaiss),
|
||||
empty($position) ? 0 : $position,
|
||||
empty($nbRep) ? 20 : $nbRep,
|
||||
empty($maxRep) ? 200 : $maxRep,
|
||||
@ -2568,8 +2567,6 @@ class Entreprise extends Scores_Ws_Server
|
||||
elseif ($cp>=98000) $dep=substr($cp,0,3);
|
||||
elseif ($cp>=97100 && $cp<97700) $dep=substr($cp,0,3);
|
||||
|
||||
require_once 'i18n/cleanchar.php';
|
||||
|
||||
if ($type=='pre'){
|
||||
|
||||
$iDb = new WDB('jo');
|
||||
@ -2676,9 +2673,9 @@ class Entreprise extends Scores_Ws_Server
|
||||
$competence->IdSup = $tribunal['triIdSup'];
|
||||
$competence->Code = $tribunal['triCode'];
|
||||
$competence->Type = $tribunal['triType'];
|
||||
$competence->Nom = strtoupper(cleanstring($tribunal['triNom']));
|
||||
$competence->Nom = strtoupper(Scores_Locale_String::cleanstring($tribunal['triNom']));
|
||||
$competence->Siret = $tribunal['triSiret'];
|
||||
$competence->Adr = strtoupper(cleanstring(preg_replace('/ +/',' ',
|
||||
$competence->Adr = strtoupper(Scores_Locale_String::cleanstring(preg_replace('/ +/',' ',
|
||||
$tribunal['triAdrNum'].' '.
|
||||
$tribunal['triAdrIndRep'].' '.
|
||||
$tribunal['triAdrTypeVoie'].' '.
|
||||
|
@ -1292,8 +1292,7 @@ class Entreprise extends Scores_Ws_Server
|
||||
|
||||
$tab = array();
|
||||
foreach($value as $comment) {
|
||||
require_once 'i18n/cleanchar.php';
|
||||
$tab[] = fixEncoding($comment);
|
||||
$tab[] = Scores_Locale_String::fixEncoding($comment);
|
||||
}
|
||||
$output->tabCommentaires = $tab;
|
||||
|
||||
@ -1419,8 +1418,6 @@ class Entreprise extends Scores_Ws_Server
|
||||
Zend_Registry::get('WsLogger')->info(__FUNCTION__."- ip : ".
|
||||
$_SERVER['REMOTE_ADDR'].", login:".$_SERVER['PHP_AUTH_USER']);
|
||||
|
||||
require_once 'i18n/cleanchar.php';
|
||||
|
||||
$entCriteres = new EntrepriseCriteres();
|
||||
$entCriteres = $criteres;
|
||||
$identifiant = $entCriteres->identifiant;
|
||||
@ -1516,10 +1513,10 @@ class Entreprise extends Scores_Ws_Server
|
||||
} else {
|
||||
|
||||
$O = $this->searchNomAdr(
|
||||
cleanstring($entCriteres->raisonSociale),
|
||||
cleanstring($entCriteres->adresse),
|
||||
Scores_Locale_String::cleanstring($entCriteres->raisonSociale),
|
||||
Scores_Locale_String::cleanstring($entCriteres->adresse),
|
||||
$entCriteres->codePostal,
|
||||
cleanstring($entCriteres->ville),
|
||||
Scores_Locale_String::cleanstring($entCriteres->ville),
|
||||
empty($entCriteres->siege) ? false : $entCriteres->siege,
|
||||
empty($entCriteres->actif) ? false : $entCriteres->actif,
|
||||
empty($position) ? 0 : $position,
|
||||
@ -2958,8 +2955,6 @@ class Entreprise extends Scores_Ws_Server
|
||||
elseif ($cp>=98000) $dep=substr($cp,0,3);
|
||||
elseif ($cp>=97100 && $cp<97700) $dep=substr($cp,0,3);
|
||||
|
||||
require_once 'i18n/cleanchar.php';
|
||||
|
||||
if ($type=='pre'){
|
||||
|
||||
$iDb = new WDB('jo');
|
||||
@ -3066,9 +3061,9 @@ class Entreprise extends Scores_Ws_Server
|
||||
$competence->IdSup = $tribunal['triIdSup'];
|
||||
$competence->Code = $tribunal['triCode'];
|
||||
$competence->Type = $tribunal['triType'];
|
||||
$competence->Nom = strtoupper(cleanstring($tribunal['triNom']));
|
||||
$competence->Nom = strtoupper(Scores_Locale_String::cleanstring($tribunal['triNom']));
|
||||
$competence->Siret = $tribunal['triSiret'];
|
||||
$competence->Adr = strtoupper(cleanstring(preg_replace('/ +/',' ',
|
||||
$competence->Adr = strtoupper(Scores_Locale_String::cleanstring(preg_replace('/ +/',' ',
|
||||
$tribunal['triAdrNum'].' '.
|
||||
$tribunal['triAdrIndRep'].' '.
|
||||
$tribunal['triAdrTypeVoie'].' '.
|
||||
|
@ -1294,8 +1294,7 @@ class Entreprise extends Scores_Ws_Server
|
||||
|
||||
$tab = array();
|
||||
foreach($value as $comment) {
|
||||
require_once 'i18n/cleanchar.php';
|
||||
$tab[] = fixEncoding($comment);
|
||||
$tab[] = Scores_Locale_String::fixEncoding($comment);
|
||||
}
|
||||
$output->tabCommentaires = $tab;
|
||||
|
||||
@ -1431,8 +1430,6 @@ class Entreprise extends Scores_Ws_Server
|
||||
if (empty($nbRep)) { $nbRep = 20; }
|
||||
if (empty($maxRep)) { $maxRep = 200; }
|
||||
|
||||
require_once 'i18n/cleanchar.php';
|
||||
|
||||
$entCriteres = new EntrepriseCriteres();
|
||||
$entCriteres = $criteres;
|
||||
$identifiant = $entCriteres->identifiant;
|
||||
@ -1530,10 +1527,10 @@ class Entreprise extends Scores_Ws_Server
|
||||
} else {
|
||||
|
||||
$O = $this->searchNomAdr(
|
||||
cleanstring($entCriteres->raisonSociale),
|
||||
cleanstring($entCriteres->adresse),
|
||||
Scores_Locale_String::cleanstring($entCriteres->raisonSociale),
|
||||
Scores_Locale_String::cleanstring($entCriteres->adresse),
|
||||
$entCriteres->codePostal,
|
||||
cleanstring($entCriteres->ville),
|
||||
Scores_Locale_String::cleanstring($entCriteres->ville),
|
||||
empty($entCriteres->siege) ? false : $entCriteres->siege,
|
||||
empty($entCriteres->actif) ? false : $entCriteres->actif,
|
||||
empty($position) ? 0 : $position,
|
||||
@ -2996,8 +2993,6 @@ class Entreprise extends Scores_Ws_Server
|
||||
elseif ($cp>=98000) $dep=substr($cp,0,3);
|
||||
elseif ($cp>=97100 && $cp<97700) $dep=substr($cp,0,3);
|
||||
|
||||
require_once 'i18n/cleanchar.php';
|
||||
|
||||
if ($type=='pre'){
|
||||
|
||||
$iDb = new WDB('jo');
|
||||
@ -3104,9 +3099,9 @@ class Entreprise extends Scores_Ws_Server
|
||||
$competence->IdSup = $tribunal['triIdSup'];
|
||||
$competence->Code = $tribunal['triCode'];
|
||||
$competence->Type = $tribunal['triType'];
|
||||
$competence->Nom = strtoupper(cleanstring($tribunal['triNom']));
|
||||
$competence->Nom = strtoupper(Scores_Locale_String::cleanstring($tribunal['triNom']));
|
||||
$competence->Siret = $tribunal['triSiret'];
|
||||
$competence->Adr = strtoupper(cleanstring(preg_replace('/ +/',' ',
|
||||
$competence->Adr = strtoupper(Scores_Locale_String::cleanstring(preg_replace('/ +/',' ',
|
||||
$tribunal['triAdrNum'].' '.
|
||||
$tribunal['triAdrIndRep'].' '.
|
||||
$tribunal['triAdrTypeVoie'].' '.
|
||||
|
@ -1299,8 +1299,7 @@ class Entreprise extends Scores_Ws_Server
|
||||
|
||||
$tab = array();
|
||||
foreach($value as $comment) {
|
||||
require_once 'i18n/cleanchar.php';
|
||||
$tab[] = fixEncoding($comment);
|
||||
$tab[] = Scores_Locale_String::fixEncoding($comment);
|
||||
}
|
||||
$output->tabCommentaires = $tab;
|
||||
|
||||
@ -1436,8 +1435,6 @@ class Entreprise extends Scores_Ws_Server
|
||||
if (empty($nbRep)) { $nbRep = 20; }
|
||||
if (empty($maxRep)) { $maxRep = 200; }
|
||||
|
||||
require_once 'i18n/cleanchar.php';
|
||||
|
||||
$entCriteres = new EntrepriseCriteres();
|
||||
$entCriteres = $criteres;
|
||||
$identifiant = $entCriteres->identifiant;
|
||||
@ -1535,10 +1532,10 @@ class Entreprise extends Scores_Ws_Server
|
||||
} else {
|
||||
|
||||
$O = $this->searchNomAdr(
|
||||
cleanstring($entCriteres->raisonSociale),
|
||||
cleanstring($entCriteres->adresse),
|
||||
Scores_Locale_String::cleanstring($entCriteres->raisonSociale),
|
||||
Scores_Locale_String::cleanstring($entCriteres->adresse),
|
||||
$entCriteres->codePostal,
|
||||
cleanstring($entCriteres->ville),
|
||||
Scores_Locale_String::cleanstring($entCriteres->ville),
|
||||
empty($entCriteres->siege) ? false : $entCriteres->siege,
|
||||
empty($entCriteres->actif) ? false : $entCriteres->actif,
|
||||
empty($position) ? 0 : $position,
|
||||
@ -3112,8 +3109,6 @@ class Entreprise extends Scores_Ws_Server
|
||||
elseif ($cp>=98000) $dep=substr($cp,0,3);
|
||||
elseif ($cp>=97100 && $cp<97700) $dep=substr($cp,0,3);
|
||||
|
||||
require_once 'i18n/cleanchar.php';
|
||||
|
||||
if ($type=='pre'){
|
||||
|
||||
$iDb = new WDB('jo');
|
||||
@ -3220,9 +3215,9 @@ class Entreprise extends Scores_Ws_Server
|
||||
$competence->IdSup = $tribunal['triIdSup'];
|
||||
$competence->Code = $tribunal['triCode'];
|
||||
$competence->Type = $tribunal['triType'];
|
||||
$competence->Nom = strtoupper(cleanstring($tribunal['triNom']));
|
||||
$competence->Nom = strtoupper(Scores_Locale_String::cleanstring($tribunal['triNom']));
|
||||
$competence->Siret = $tribunal['triSiret'];
|
||||
$competence->Adr = strtoupper(cleanstring(preg_replace('/ +/',' ',
|
||||
$competence->Adr = strtoupper(Scores_Locale_String::cleanstring(preg_replace('/ +/',' ',
|
||||
$tribunal['triAdrNum'].' '.
|
||||
$tribunal['triAdrIndRep'].' '.
|
||||
$tribunal['triAdrTypeVoie'].' '.
|
||||
|
@ -1288,8 +1288,7 @@ class Entreprise extends Scores_Ws_Server
|
||||
|
||||
$tab = array();
|
||||
foreach($value as $comment) {
|
||||
require_once 'i18n/cleanchar.php';
|
||||
$tab[] = fixEncoding($comment);
|
||||
$tab[] = Scores_Locale_String::fixEncoding($comment);
|
||||
}
|
||||
$output->tabCommentaires = $tab;
|
||||
|
||||
@ -1427,8 +1426,6 @@ class Entreprise extends Scores_Ws_Server
|
||||
if (empty($nbRep)) { $nbRep = 20; }
|
||||
if (empty($maxRep)) { $maxRep = 200; }
|
||||
|
||||
require_once 'i18n/cleanchar.php';
|
||||
|
||||
$entCriteres = new EntrepriseCriteres();
|
||||
$entCriteres = $criteres;
|
||||
$identifiant = $entCriteres->identifiant;
|
||||
@ -1526,10 +1523,10 @@ class Entreprise extends Scores_Ws_Server
|
||||
} else {
|
||||
|
||||
$O = $this->searchNomAdr(
|
||||
cleanstring($entCriteres->raisonSociale),
|
||||
cleanstring($entCriteres->adresse),
|
||||
Scores_Locale_String::cleanstring($entCriteres->raisonSociale),
|
||||
Scores_Locale_String::cleanstring($entCriteres->adresse),
|
||||
$entCriteres->codePostal,
|
||||
cleanstring($entCriteres->ville),
|
||||
Scores_Locale_String::cleanstring($entCriteres->ville),
|
||||
empty($entCriteres->siege) ? false : $entCriteres->siege,
|
||||
empty($entCriteres->actif) ? false : $entCriteres->actif,
|
||||
empty($position) ? 0 : $position,
|
||||
@ -3192,8 +3189,6 @@ class Entreprise extends Scores_Ws_Server
|
||||
elseif ($cp>=98000) $dep=substr($cp,0,3);
|
||||
elseif ($cp>=97100 && $cp<97700) $dep=substr($cp,0,3);
|
||||
|
||||
require_once 'i18n/cleanchar.php';
|
||||
|
||||
if ($type=='pre'){
|
||||
|
||||
$iDb = new WDB('jo');
|
||||
@ -3300,9 +3295,9 @@ class Entreprise extends Scores_Ws_Server
|
||||
$competence->IdSup = $tribunal['triIdSup'];
|
||||
$competence->Code = $tribunal['triCode'];
|
||||
$competence->Type = $tribunal['triType'];
|
||||
$competence->Nom = strtoupper(cleanstring($tribunal['triNom']));
|
||||
$competence->Nom = strtoupper(Scores_Locale_String::cleanstring($tribunal['triNom']));
|
||||
$competence->Siret = $tribunal['triSiret'];
|
||||
$competence->Adr = strtoupper(cleanstring(preg_replace('/ +/',' ',
|
||||
$competence->Adr = strtoupper(Scores_Locale_String::cleanstring(preg_replace('/ +/',' ',
|
||||
$tribunal['triAdrNum'].' '.
|
||||
$tribunal['triAdrIndRep'].' '.
|
||||
$tribunal['triAdrTypeVoie'].' '.
|
||||
|
@ -1744,8 +1744,7 @@ class Entreprise extends Scores_Ws_Server
|
||||
|
||||
$tab = array();
|
||||
foreach($value as $comment) {
|
||||
require_once 'i18n/cleanchar.php';
|
||||
$tab[] = fixEncoding($comment);
|
||||
$tab[] = Scores_Locale_String::fixEncoding($comment);
|
||||
}
|
||||
$output->tabCommentaires = $tab;
|
||||
|
||||
@ -2003,8 +2002,7 @@ class Entreprise extends Scores_Ws_Server
|
||||
|
||||
$tab = array();
|
||||
foreach($value as $comment) {
|
||||
require_once 'i18n/cleanchar.php';
|
||||
$tab[] = fixEncoding($comment);
|
||||
$tab[] = Scores_Locale_String::fixEncoding($comment);
|
||||
}
|
||||
$output->tabCommentaires = $tab;
|
||||
|
||||
@ -2136,8 +2134,6 @@ class Entreprise extends Scores_Ws_Server
|
||||
if (empty($nbRep)) { $nbRep = 20; }
|
||||
if (empty($maxRep)) { $maxRep = 200; }
|
||||
|
||||
require_once 'i18n/cleanchar.php';
|
||||
|
||||
$entCriteres = new EntrepriseCriteres();
|
||||
$entCriteres = $criteres;
|
||||
$identifiant = $entCriteres->identifiant;
|
||||
@ -2238,10 +2234,10 @@ class Entreprise extends Scores_Ws_Server
|
||||
} else {
|
||||
|
||||
$O = $this->searchNomAdr(
|
||||
cleanstring($entCriteres->raisonSociale),
|
||||
cleanstring($entCriteres->adresse),
|
||||
Scores_Locale_String::cleanstring($entCriteres->raisonSociale),
|
||||
Scores_Locale_String::cleanstring($entCriteres->adresse),
|
||||
$entCriteres->codePostal,
|
||||
cleanstring($entCriteres->ville),
|
||||
Scores_Locale_String::cleanstring($entCriteres->ville),
|
||||
empty($entCriteres->siege) ? false : $entCriteres->siege,
|
||||
$entCriteres->actif,
|
||||
empty($position) ? 0 : $position,
|
||||
@ -3914,8 +3910,6 @@ class Entreprise extends Scores_Ws_Server
|
||||
elseif ($cp>=98000) $dep=substr($cp,0,3);
|
||||
elseif ($cp>=97100 && $cp<97700) $dep=substr($cp,0,3);
|
||||
|
||||
require_once 'i18n/cleanchar.php';
|
||||
|
||||
if ($type=='pre'){
|
||||
|
||||
$iDb = new WDB('jo');
|
||||
@ -4022,9 +4016,9 @@ class Entreprise extends Scores_Ws_Server
|
||||
$competence->IdSup = $tribunal['triIdSup'];
|
||||
$competence->Code = $tribunal['triCode'];
|
||||
$competence->Type = $tribunal['triType'];
|
||||
$competence->Nom = strtoupper(cleanstring($tribunal['triNom']));
|
||||
$competence->Nom = strtoupper(Scores_Locale_String::cleanstring($tribunal['triNom']));
|
||||
$competence->Siret = $tribunal['triSiret'];
|
||||
$competence->Adr = strtoupper(cleanstring(preg_replace('/ +/',' ',
|
||||
$competence->Adr = strtoupper(Scores_Locale_String::cleanstring(preg_replace('/ +/',' ',
|
||||
$tribunal['triAdrNum'].' '.
|
||||
$tribunal['triAdrIndRep'].' '.
|
||||
$tribunal['triAdrTypeVoie'].' '.
|
||||
|
@ -337,7 +337,7 @@ class Entreprise extends Scores_Ws_Server
|
||||
}
|
||||
$output->CapitalType = $infosEtab['capitalType'];
|
||||
|
||||
$output->SiegeAdresseNum = $infosEtab['adrNumVoie'];
|
||||
$output->SiegeAdresseNum = intval($infosEtab['adrNumVoie']);
|
||||
$output->SiegeAdresseBtq = $infosEtab['adrIndRep'];
|
||||
$output->SiegeAdresseVoieType = $infosEtab['adrTypeVoie'] ;
|
||||
$output->SiegeAdresseVoieLabel = $infosEtab['adrVoie'];
|
||||
@ -400,6 +400,7 @@ class Entreprise extends Scores_Ws_Server
|
||||
$output->BodaccActivite = $insee['Activite'];
|
||||
|
||||
//Date de création à l'insee - getIdentiteEntreprise - insee
|
||||
//@todo : Aller cherche dans les annonces bodacc création + acquisition
|
||||
$output->ActiviteDate = substr($insee['DateCreaEn'],0,4).'-'.substr($insee['DateCreaEn'],4,2).'-'.substr($insee['DateCreaEn'],6,2);
|
||||
|
||||
//Type d'exploitation - getIdentiteEntreprise - insee
|
||||
@ -416,9 +417,8 @@ class Entreprise extends Scores_Ws_Server
|
||||
|
||||
//Liste des dépots
|
||||
$output->Depots = array();
|
||||
require_once 'Metier/Infogreffe/InfogreffeAc.php';
|
||||
$infogreffe = new Metier_Infogreffe_Ac($siren);
|
||||
$depots = $infogreffe->getList(true);
|
||||
$infogreffe = new SdMetier_Infogreffe_DocAC($siren);
|
||||
$depots = $infogreffe->getList();
|
||||
if ( count($depots)>0 ) {
|
||||
$i = 0;
|
||||
$listNumDepot = array();
|
||||
@ -439,6 +439,7 @@ class Entreprise extends Scores_Ws_Server
|
||||
}
|
||||
|
||||
//Acte constitutif - Statut
|
||||
//@todo : STATUTS CONSTITUTIFS
|
||||
$date = substr($depot->ActeDate,0,4);
|
||||
if ( in_array($depot->ActeType, array('04')) && intval($date)>1995 ) {
|
||||
$output->ConstitutionActeDate = $depot->ActeDate;
|
||||
@ -1539,15 +1540,15 @@ class Entreprise extends Scores_Ws_Server
|
||||
$annsB=$iInsee->getAnnoncesBalo($siren);
|
||||
$annsA=$iInsee->getAnnoncesAsso($siren);
|
||||
$annsM=$iInsee->getAnnoncesBoamp($siren, $idAnn);
|
||||
} elseif ($filtre==1)
|
||||
$anns=$iInsee->getAnnoncesLegales($siren, $idAnn);
|
||||
elseif ($filtre==2)
|
||||
$annsB=$iInsee->getAnnoncesBalo($siren, $idAnn);
|
||||
elseif ($filtre==3)
|
||||
$annsA=$iInsee->getAnnoncesAsso($siren, $idAnn);
|
||||
elseif ($filtre==4)
|
||||
$annsM=$iInsee->getAnnoncesBoamp($siren, $idAnn);
|
||||
|
||||
} elseif ($filtre==1) {
|
||||
$anns=$iInsee->getAnnoncesLegales($siren, $idAnn);
|
||||
} elseif ($filtre==2) {
|
||||
$annsB=$iInsee->getAnnoncesBalo($siren, $idAnn);
|
||||
} elseif ($filtre==3) {
|
||||
$annsA=$iInsee->getAnnoncesAsso($siren, $idAnn);
|
||||
} elseif ($filtre==4) {
|
||||
$annsM=$iInsee->getAnnoncesBoamp($siren, $idAnn);
|
||||
}
|
||||
//debugLog('W', print_r($entrep, true), __LINE__, __FILE__, __FUNCTION__, __CLASS__);
|
||||
if (empty($anns) && empty($annsB) && empty($annsA) && empty($annsM))
|
||||
{
|
||||
@ -1887,7 +1888,7 @@ class Entreprise extends Scores_Ws_Server
|
||||
$annonce->TribunalSiret = $ann['TribunalSiret'];
|
||||
$annonce->Rubrique = $ann['Rubrique'];
|
||||
$annonce->typeAnnonce = $ann['typeAnnonce'];
|
||||
$annonce->texteAnnonce = prepareString($ann['texteAnnonce']);
|
||||
$annonce->texteAnnonce = $ann['texteAnnonce'];
|
||||
$annonce->dateEffet = $ann['dateEffet']; //@todo : date
|
||||
$annonce->dateJugement = $ann['dateJugement']; //@todo : date
|
||||
$annonce->dateInsertionSD = $ann['dateInsertionSD']; //@todo : date
|
||||
@ -2418,8 +2419,7 @@ class Entreprise extends Scores_Ws_Server
|
||||
$tab = array();
|
||||
if (count($value)>0) {
|
||||
foreach($value as $comment) {
|
||||
require_once 'i18n/cleanchar.php';
|
||||
$tab[] = fixEncoding($comment);
|
||||
$tab[] = Scores_Locale_String::fixEncoding($comment);
|
||||
}
|
||||
}
|
||||
$output->tabCommentaires = $tab;
|
||||
@ -2660,8 +2660,7 @@ class Entreprise extends Scores_Ws_Server
|
||||
|
||||
$tab = array();
|
||||
foreach($value as $comment) {
|
||||
require_once 'i18n/cleanchar.php';
|
||||
$tab[] = fixEncoding($comment);
|
||||
$tab[] = Scores_Locale_String::fixEncoding($comment);
|
||||
}
|
||||
$Indiscore->tabCommentaires = $tab;
|
||||
|
||||
@ -2976,8 +2975,6 @@ class Entreprise extends Scores_Ws_Server
|
||||
if (empty($nbRep)) { $nbRep = 20; }
|
||||
if (empty($maxRep)) { $maxRep = 200; }
|
||||
|
||||
require_once 'i18n/cleanchar.php';
|
||||
|
||||
$entCriteres = new EntrepriseCriteres();
|
||||
$entCriteres = $criteres;
|
||||
$identifiant = $entCriteres->identifiant;
|
||||
@ -3076,12 +3073,12 @@ class Entreprise extends Scores_Ws_Server
|
||||
return $output;
|
||||
|
||||
} else {
|
||||
|
||||
|
||||
$O = $this->searchNomAdr(
|
||||
cleanstring($entCriteres->raisonSociale),
|
||||
cleanstring($entCriteres->adresse),
|
||||
Scores_Locale_String::cleanstring($entCriteres->raisonSociale),
|
||||
Scores_Locale_String::cleanstring($entCriteres->adresse),
|
||||
$entCriteres->codePostal,
|
||||
cleanstring($entCriteres->ville),
|
||||
Scores_Locale_String::cleanstring($entCriteres->ville),
|
||||
empty($entCriteres->siege) ? false : $entCriteres->siege,
|
||||
$entCriteres->actif,
|
||||
empty($position) ? 0 : $position,
|
||||
@ -4943,8 +4940,6 @@ class Entreprise extends Scores_Ws_Server
|
||||
elseif ($cp>=99000) $dep=substr($cp,0,2);
|
||||
elseif ($cp>=98000) $dep=substr($cp,0,3);
|
||||
elseif ($cp>=97100 && $cp<97700) $dep=substr($cp,0,3);
|
||||
|
||||
require_once 'i18n/cleanchar.php';
|
||||
|
||||
if ($type=='pre') {
|
||||
|
||||
@ -5052,9 +5047,9 @@ class Entreprise extends Scores_Ws_Server
|
||||
$competence->IdSup = $tribunal['triIdSup'];
|
||||
$competence->Code = $tribunal['triCode'];
|
||||
$competence->Type = $tribunal['triType'];
|
||||
$competence->Nom = strtoupper(cleanstring($tribunal['triNom']));
|
||||
$competence->Nom = strtoupper(Scores_Locale_String::cleanstring($tribunal['triNom']));
|
||||
$competence->Siret = $tribunal['triSiret'];
|
||||
$competence->Adr = strtoupper(cleanstring(preg_replace('/ +/',' ',
|
||||
$competence->Adr = strtoupper(Scores_Locale_String::cleanstring(preg_replace('/ +/',' ',
|
||||
$tribunal['triAdrNum'].' '.
|
||||
$tribunal['triAdrIndRep'].' '.
|
||||
$tribunal['triAdrTypeVoie'].' '.
|
||||
|
@ -982,7 +982,7 @@ class Gestion extends Scores_Ws_Server
|
||||
}
|
||||
break;
|
||||
case 'filtres_ip':
|
||||
$tabInfos['filtres_ip'] = $value;
|
||||
$tabInfos['filtres_ip'] = trim($value, ';');
|
||||
break;
|
||||
case 'typeContrat':
|
||||
if (in_array($value, array('Contrat','Marché'))){
|
||||
@ -2060,12 +2060,12 @@ class Gestion extends Scores_Ws_Server
|
||||
$strLogin = '';
|
||||
|
||||
//Modification sur les droits des services
|
||||
if ( count(toDelete)>0 ) {
|
||||
/*if ( count(toDelete)>0 ) {
|
||||
foreach ($toDelete as $droit) {
|
||||
$query = "UPDATE clients_services SET droits=TRIM(REPLACE(droits, ' $droit ', ' ')) WHERE idClient='$idClient'";
|
||||
$iDbCrm->query($query);
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
if (null !== $service) {
|
||||
//Récupération des logins utilisateurs du service
|
||||
|
@ -2437,9 +2437,8 @@ class Interne extends Scores_Ws_Server
|
||||
$tabRet = array();
|
||||
$k=0;
|
||||
if(count($liste)>0) {
|
||||
require_once 'i18n/cleanchar.php';
|
||||
foreach ($liste as $n=>$etab) {
|
||||
$texte = cleanutf8($etab['Texte']);
|
||||
$texte = Scores_Locale_String::cleanutf8($etab['Texte']);
|
||||
$pattern = '/[^a-zA-Z0-9\/]+/ ';
|
||||
$texte = preg_replace($pattern, ' ', $texte);
|
||||
$posMin=100000;
|
||||
|
@ -2395,9 +2395,8 @@ class Interne extends Scores_Ws_Server
|
||||
$tabRet = array();
|
||||
$k=0;
|
||||
if(count($liste)>0) {
|
||||
require_once 'i18n/cleanchar.php';
|
||||
foreach ($liste as $n=>$etab) {
|
||||
$texte = cleanutf8($etab['Texte']);
|
||||
$texte = Scores_Locale_String::cleanutf8($etab['Texte']);
|
||||
$pattern = '/[^a-zA-Z0-9\/]+/ ';
|
||||
$texte = preg_replace($pattern, ' ', $texte);
|
||||
$posMin=100000;
|
||||
|
@ -1319,9 +1319,8 @@ class Interne extends Scores_Ws_Server
|
||||
$tabRet = array();
|
||||
$k=0;
|
||||
if(count($liste)>0) {
|
||||
require_once 'i18n/cleanchar.php';
|
||||
foreach ($liste as $n=>$etab) {
|
||||
$texte = cleanutf8($etab['Texte']);
|
||||
$texte = Scores_Locale_String::cleanutf8($etab['Texte']);
|
||||
$pattern = '/[^a-zA-Z0-9\/]+/ ';
|
||||
$texte = preg_replace($pattern, ' ', $texte);
|
||||
$posMin=100000;
|
||||
|
@ -1079,7 +1079,7 @@ class Interne extends Scores_Ws_Server
|
||||
$iDb = new WDB();
|
||||
$login = $this->User->login;
|
||||
|
||||
$strSelect = 's.email, s.siren, s.nic, s.ref, s.dateAjout, s.rs, s.cp, s.ville, s.dateDerEnvoi, s.encoursClient, c.actif, c.procol, c.indiScore, c.indiScore20, c.encours, c.indiScoreDate, c.dateBilan, c.indiScorePre, c.indiScore20Pre, c.encoursPre, c.indiScoreDatePre, c.sourceModif, c.scoreSolv, c.scoreSolvPre, c.scoreDir, c.scoreDirPre, c.scoreConf, c.scoreConfPre, c.scoreZ, c.scoreZPre, c.scoreCH, c.scoreCHPre, c.scoreAfdcc2, c.scoreAfdcc2Pre, c.situFi, c.situFiPre, c.infoNote, c.infoNotePre, c.noteStruct, c.noteStructPre, c.noteFin, c.noteFinPre, c.tendance, c.tendancePre, c.dateUpdate';
|
||||
$strSelect = 's.email, LPAD(s.siren,9,0) AS siren, LPAD(s.nic,5,0) AS nic, s.ref, s.dateAjout, s.rs, s.cp, s.ville, s.dateDerEnvoi, s.encoursClient, c.actif, c.procol, c.indiScore, c.indiScore20, c.encours, c.indiScoreDate, c.dateBilan, c.indiScorePre, c.indiScore20Pre, c.encoursPre, c.indiScoreDatePre, c.sourceModif, c.scoreSolv, c.scoreSolvPre, c.scoreDir, c.scoreDirPre, c.scoreConf, c.scoreConfPre, c.scoreZ, c.scoreZPre, c.scoreCH, c.scoreCHPre, c.scoreAfdcc2, c.scoreAfdcc2Pre, c.situFi, c.situFiPre, c.infoNote, c.infoNotePre, c.noteStruct, c.noteStructPre, c.noteFin, c.noteFinPre, c.tendance, c.tendancePre, c.dateUpdate';
|
||||
|
||||
$strFiltre = '';
|
||||
if (intval($siren)>0) $strFiltre.= " AND s.siren=$siren ";
|
||||
@ -1257,9 +1257,8 @@ class Interne extends Scores_Ws_Server
|
||||
$tabRet = array();
|
||||
$k=0;
|
||||
if(count($liste)>0) {
|
||||
require_once 'i18n/cleanchar.php';
|
||||
foreach ($liste as $n=>$etab) {
|
||||
$texte = cleanutf8($etab['Texte']);
|
||||
$texte = Scores_Locale_String::cleanutf8($etab['Texte']);
|
||||
$pattern = '/[^a-zA-Z0-9\/]+/ ';
|
||||
$texte = preg_replace($pattern, ' ', $texte);
|
||||
$posMin=100000;
|
||||
@ -2865,7 +2864,7 @@ class Interne extends Scores_Ws_Server
|
||||
$adresse = $iInsee->getIdentiteLight($siren, $etab['Nic']);
|
||||
require_once 'Metier/partenaires/classMMap.php';
|
||||
$mMap = new MMap(false, $iDb);
|
||||
$mMap->geoCodeAdresse($adresse['AdresseNum'],'',$adresse['AdresseVoie'],
|
||||
$mMap->geoCodeAdresse($adresse['AdresseNum'], '', $adresse['AdresseVoie'],
|
||||
$iInsee->getCodeVoie($adresse['AdresseVoie']), $adresse['AdresseRue'],
|
||||
$etab['CP'], $adresse['Ville'], 'France');
|
||||
|
||||
|
5
library/WsScore/Order/v0.1/Config.php
Normal file
5
library/WsScore/Order/v0.1/Config.php
Normal file
@ -0,0 +1,5 @@
|
||||
<?php
|
||||
return array(
|
||||
'BilanInput' => 'BilanInput',
|
||||
'PieceKbis' => 'PieceKbis',
|
||||
);
|
440
library/WsScore/Order/v0.1/Order.php
Normal file
440
library/WsScore/Order/v0.1/Order.php
Normal file
@ -0,0 +1,440 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/Types.php';
|
||||
|
||||
class Order extends Scores_Ws_Server
|
||||
{
|
||||
/**
|
||||
* Financial account : Place an order to have number enter in database
|
||||
* @param string $siren
|
||||
* @param string $date
|
||||
* @param string $type N:Normal, S:Simplifié, C:Consolidé
|
||||
* @param string $source
|
||||
* @param integer $private
|
||||
* @throws SoapFault
|
||||
* @return string
|
||||
*/
|
||||
public function setBilanInput($siren, $date, $type, $source, $private = 0)
|
||||
{
|
||||
$this->authenticate();
|
||||
$this->permission('UPLOADBILAN');
|
||||
|
||||
//Check siren
|
||||
|
||||
$refCommande = uniqid();
|
||||
|
||||
$data = array(
|
||||
'refCommande' => $refCommande,
|
||||
'siren' => $siren,
|
||||
'userId' => $this->User->id,
|
||||
'bilanConfidentiel' => $private,
|
||||
'bilanSource' => $source,
|
||||
'bilanCloture' => $date,
|
||||
'bilanType' => $type,
|
||||
'dateInsert' => date('YmdHis'),
|
||||
);
|
||||
try {
|
||||
$commandeM = new Application_Model_Sdv1OrderBilanInput();
|
||||
$commandeM->insert($data);
|
||||
return $refCommande;
|
||||
} catch (Zend_Db_Exception $e) {
|
||||
if ($this->User->idClient==1) {
|
||||
throw new SoapFault('ERR', $e->getMessage());
|
||||
} else {
|
||||
throw new SoapFault('ERR', "Application error");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Financial account : Tag file is sent
|
||||
* @param string $ref
|
||||
* @param string $filename
|
||||
* @throws SoapFault
|
||||
* @return boolean
|
||||
*/
|
||||
public function setBilanInputFile($ref, $filename)
|
||||
{
|
||||
$this->authenticate();
|
||||
$this->permission('UPLOADBILAN');
|
||||
|
||||
$data = array(
|
||||
'bilanFileSent' => date('YmdHis'),
|
||||
'bilanFile' => $filename,
|
||||
);
|
||||
try {
|
||||
$commandeM = new Application_Model_Sdv1OrderBilanInput();
|
||||
$commandeM->update($data, 'refCommande="'.$ref.'"');
|
||||
return true;
|
||||
} catch (Zend_Db_Exception $e) {
|
||||
if ($this->User->idClient==1) {
|
||||
throw new SoapFault('ERR', $e->getMessage());
|
||||
} else {
|
||||
throw new SoapFault('ERR', "Application error");
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Liste des commandes de saisie de bilan
|
||||
* @param string $month
|
||||
* @throws SoapFault
|
||||
* @return BilanInput[]
|
||||
*/
|
||||
public function getBilanInputList($month = null)
|
||||
{
|
||||
$this->authenticate();
|
||||
|
||||
if ($month === null) {
|
||||
$month = date('Y-m');
|
||||
}
|
||||
$dateStart = $month.'-01 00:00:00';
|
||||
$dateEnd = $month.'-31 23:59:59';
|
||||
|
||||
$list = array();
|
||||
|
||||
try {
|
||||
$commandeM = new Application_Model_Sdv1OrderBilanInput();
|
||||
$sql = $commandeM->select()->where('userId=?', $this->User->id);
|
||||
$result = $commandeM->fetchAll($sql);
|
||||
if (count($result) > 0) {
|
||||
foreach($result as $item) {
|
||||
$cmd = new BilanInput();
|
||||
$cmd->Reference = $item->refCommande;
|
||||
$cmd->Siren = $item->siren;
|
||||
$cmd->BilanFileRecv = $item->bilanFileRecv;
|
||||
$cmd->BilanCloture = $item->bilanCloture;
|
||||
$cmd->BilanType = $item->bilanType;
|
||||
$cmd->ErreurDate = $item->erreurDate;
|
||||
$cmd->ErreurLabel = $item->erreurTxt;
|
||||
$cmd->DateInsert = $item->dateInsert;
|
||||
$cmd->DateSaisie = $item->dateSaisie;
|
||||
$list[] = $cmd;
|
||||
}
|
||||
}
|
||||
} catch (Zend_Db_Exception $e) {
|
||||
if ($this->User->idClient == 1) {
|
||||
throw new SoapFault('ERR', $e->getMessage());
|
||||
} else {
|
||||
throw new SoapFault('ERR', "Application error");
|
||||
}
|
||||
}
|
||||
|
||||
return $list;
|
||||
}
|
||||
|
||||
/**
|
||||
* Détail d'un bilan en commande saisie
|
||||
* @param string $ref
|
||||
* @throws SoapFault
|
||||
* @return BilanInput|NULL
|
||||
*/
|
||||
protected function getBilanInputDetail($ref)
|
||||
{
|
||||
$this->authenticate();
|
||||
|
||||
try {
|
||||
$commandeM = new Application_Model_Sdv1OrderBilanInput();
|
||||
$sql = $commandeM->select()->where('userId=?', $this->User->id)->where('refCommande=?', $ref);
|
||||
$item = $commandeM->fetchRow($sql);
|
||||
if ($item !== null) {
|
||||
$cmd = new BilanInput();
|
||||
$cmd->Reference = $item->refCommande;
|
||||
$cmd->Siren = $item->siren;
|
||||
$cmd->BilanFileRecv = $item->bilanFileRecv;
|
||||
$cmd->BilanCloture = $item->bilanCloture;
|
||||
$cmd->BilanType = $item->bilanType;
|
||||
$cmd->ErreurDate = $item->erreurDate;
|
||||
$cmd->ErreurLabel = $item->erreurTxt;
|
||||
$cmd->DateInsert = $item->dateInsert;
|
||||
$cmd->DateSaisie = $item->dateSaisie;
|
||||
return $cmd;
|
||||
}
|
||||
} catch (Zend_Db_Exception $e) {
|
||||
if ($this->User->idClient == 1) {
|
||||
throw new SoapFault('ERR', $e->getMessage());
|
||||
} else {
|
||||
throw new SoapFault('ERR', "Application error");
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Liste des commandes KBIS
|
||||
* @param string $month
|
||||
* @throws SoapFault
|
||||
* @return PieceKbis[]
|
||||
*/
|
||||
public function getKbisList($month = null)
|
||||
{
|
||||
$this->authenticate();
|
||||
|
||||
if ($month === null) {
|
||||
$month = date('Y-m');
|
||||
}
|
||||
$dateStart = $month.'-01 00:00:00';
|
||||
$dateEnd = $month.'-31 23:59:59';
|
||||
|
||||
$list = array();
|
||||
|
||||
try {
|
||||
$commandeM = new Application_Model_Sdv1GreffeCommandesKb();
|
||||
$sql = $commandeM->select()->where('login=?', $this->User->login);
|
||||
$result = $commandeM->fetchAll($sql);
|
||||
if (count($result) > 0) {
|
||||
foreach($result as $item) {
|
||||
$cmd = new PieceKbis();
|
||||
$cmd->Reference = $item->refCommande;
|
||||
$cmd->Mode = $item->mode;
|
||||
$cmd->Error = $item->cmdError;
|
||||
$cmd->CompanyName = $item->raisonSociale;
|
||||
$cmd->CompanySiren = $item->siren;
|
||||
$cmd->DateInsert = $item->dateInsert;
|
||||
$cmd->DateEnvoi = $item->dateEnvoi;
|
||||
$list[] = $cmd;
|
||||
}
|
||||
}
|
||||
} catch (Zend_Db_Exception $e) {
|
||||
if ($this->User->idClient == 1) {
|
||||
throw new SoapFault('ERR', $e->getMessage());
|
||||
} else {
|
||||
throw new SoapFault('ERR', "Application error");
|
||||
}
|
||||
}
|
||||
|
||||
return $list;
|
||||
}
|
||||
|
||||
/**
|
||||
* Detail de la commande d'un KBIS
|
||||
* @param unknown $ref
|
||||
* @throws SoapFault
|
||||
* @return BilanInput|NULL
|
||||
*/
|
||||
protected function getKbisDetail($ref)
|
||||
{
|
||||
$this->authenticate();
|
||||
|
||||
try {
|
||||
$commandeM = new Application_Model_Sdv1GreffeCommandesKb();
|
||||
$sql = $commandeM->select()->where('login=?', $this->User->login)->where('refCommande=?', $ref);
|
||||
$item = $commandeM->fetchRow($sql);
|
||||
if ($item !== null) {
|
||||
$cmd = new BilanInput();
|
||||
$cmd->Reference = $item->refCommande;
|
||||
$cmd->Mode = $item->mode;
|
||||
$cmd->Error = $item->cmdError;
|
||||
$cmd->CompanyName = $item->raisonSociale;
|
||||
$cmd->CompanySiren = $item->siren;
|
||||
$cmd->DateInsert = $item->dateInsert;
|
||||
$cmd->DateEnvoi = $item->dateEnvoi;
|
||||
return $cmd;
|
||||
}
|
||||
} catch (Zend_Db_Exception $e) {
|
||||
if ($this->User->idClient == 1) {
|
||||
throw new SoapFault('ERR', $e->getMessage());
|
||||
} else {
|
||||
throw new SoapFault('ERR', "Application error");
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
protected function getKbisFile($ref)
|
||||
{
|
||||
$this->authenticate();
|
||||
|
||||
// --- Paramètres
|
||||
$hostname = 'http://'.$_SERVER['SERVER_NAME'];
|
||||
if ($_SERVER['SERVER_PORT']!='80'){
|
||||
$hostname.= ':'.$_SERVER['SERVER_PORT'];
|
||||
}
|
||||
$c = Zend_Registry::get('config');
|
||||
$path = realpath($c->profil->path->secure).'/kbis';
|
||||
$file = null;
|
||||
|
||||
// --- Lecture des informations de la commande
|
||||
try {
|
||||
$commandeM = new Application_Model_Sdv1GreffeCommandesKb();
|
||||
$sql = $commandeM->select()->where('login=?', $this->User->login)->where('refCommande=?', $ref);
|
||||
$item = $commandeM->fetchRow($sql);
|
||||
if ($item !== null) {
|
||||
|
||||
|
||||
|
||||
$cmd = new BilanInput();
|
||||
$cmd->Reference = $item->refCommande;
|
||||
$cmd->Mode = $item->mode;
|
||||
$cmd->Error = $item->cmdError;
|
||||
$cmd->CompanyName = $item->raisonSociale;
|
||||
$cmd->CompanySiren = $item->siren;
|
||||
$cmd->DateInsert = $item->dateInsert;
|
||||
$cmd->DateEnvoi = $item->dateEnvoi;
|
||||
return $cmd;
|
||||
}
|
||||
} catch (Zend_Db_Exception $e) {
|
||||
if ($this->User->idClient == 1) {
|
||||
throw new SoapFault('ERR', $e->getMessage());
|
||||
} else {
|
||||
throw new SoapFault('ERR', "Application error");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
protected function getActeList($month = null)
|
||||
{
|
||||
$this->authenticate();
|
||||
|
||||
if ($month === null) {
|
||||
$month = date('Y-m');
|
||||
}
|
||||
$dateStart = $month.'-01 00:00:00';
|
||||
$dateEnd = $month.'-31 23:59:59';
|
||||
|
||||
$list = array();
|
||||
|
||||
try {
|
||||
$commandeM = new Application_Model_Sdv1GreffeCommandesAc();
|
||||
$sql = $commandeM->select()->where('login=?', $this->User->login);
|
||||
$result = $commandeM->fetchAll($sql);
|
||||
if (count($result) > 0) {
|
||||
foreach($result as $item) {
|
||||
$cmd = new BilanInput();
|
||||
$cmd->Reference = $item->refCommande;
|
||||
$cmd->Mode = $item->mode;
|
||||
$cmd->Error = $item->cmdError;
|
||||
|
||||
//@todo : Génére le libellé du document
|
||||
$cmd->DocDepotNum;
|
||||
$cmd->DocDepotDate;
|
||||
$cmd->DocActeNum;
|
||||
$cmd->DocActeType;
|
||||
$cmd->DocActeDate;
|
||||
|
||||
$cmd->CompanyName = $item->raisonSociale;
|
||||
$cmd->CompanySiren = $item->siren;
|
||||
$cmd->DateInsert = $item->dateInsert;
|
||||
$cmd->DateEnvoi = $item->dateEnvoi;
|
||||
$list[] = $cmd;
|
||||
}
|
||||
}
|
||||
} catch (Zend_Db_Exception $e) {
|
||||
if ($this->User->idClient == 1) {
|
||||
throw new SoapFault('ERR', $e->getMessage());
|
||||
} else {
|
||||
throw new SoapFault('ERR', "Application error");
|
||||
}
|
||||
}
|
||||
|
||||
return $list;
|
||||
}
|
||||
|
||||
protected function getActeDetail($ref){}
|
||||
protected function getActeFile($ref){}
|
||||
|
||||
/**
|
||||
* Liste des commandes de bilan infogreffe
|
||||
* @param string $month
|
||||
* @throws SoapFault
|
||||
* @return multitype:BilanInput
|
||||
*/
|
||||
protected function getBilanList($month = null)
|
||||
{
|
||||
$this->authenticate();
|
||||
|
||||
if ($month === null) {
|
||||
$month = date('Y-m');
|
||||
}
|
||||
$dateStart = $month.'-01 00:00:00';
|
||||
$dateEnd = $month.'-31 23:59:59';
|
||||
|
||||
$list = array();
|
||||
|
||||
try {
|
||||
$commandeM = new Application_Model_Sdv1GreffeCommandesBi();
|
||||
$sql = $commandeM->select()->where('login=?', $this->User->login);
|
||||
$result = $commandeM->fetchAll($sql);
|
||||
if (count($result) > 0) {
|
||||
foreach($result as $item) {
|
||||
$cmd = new BilanInput();
|
||||
$cmd->Reference = $item->refCommande;
|
||||
$cmd->Mode = $item->mode;
|
||||
$cmd->Error = $item->cmdError;
|
||||
$cmd->DocBilanCloture = $item->bilanCloture;
|
||||
$cmd->DocBilanType = $item->bilanType;
|
||||
$cmd->CompanyName = $item->raisonSociale;
|
||||
$cmd->CompanySiren = $item->siren;
|
||||
$cmd->DateInsert = $item->dateInsert;
|
||||
$cmd->DateEnvoi = $item->dateEnvoi;
|
||||
$list[] = $cmd;
|
||||
}
|
||||
}
|
||||
} catch (Zend_Db_Exception $e) {
|
||||
if ($this->User->idClient == 1) {
|
||||
throw new SoapFault('ERR', $e->getMessage());
|
||||
} else {
|
||||
throw new SoapFault('ERR', "Application error");
|
||||
}
|
||||
}
|
||||
|
||||
return $list;
|
||||
}
|
||||
|
||||
/**
|
||||
* Détail de la commande de bilan Infogreffe
|
||||
* @param unknown $ref
|
||||
* @throws SoapFault
|
||||
* @return BilanInput|NULL
|
||||
*/
|
||||
protected function getBilanDetail($ref)
|
||||
{
|
||||
$this->authenticate();
|
||||
|
||||
try {
|
||||
$commandeM = new Application_Model_Sdv1GreffeCommandesKb();
|
||||
$sql = $commandeM->select()->where('login=?', $this->User->login)->where('refCommande=?', $ref);
|
||||
$item = $commandeM->fetchRow($sql);
|
||||
if ($item !== null) {
|
||||
$cmd = new BilanInput();
|
||||
$cmd->Reference = $item->refCommande;
|
||||
$cmd->Mode = $item->mode;
|
||||
$cmd->Error = $item->cmdError;
|
||||
$cmd->DocBilanCloture = $item->bilanCloture;
|
||||
$cmd->DocBilanType = $item->bilanType;
|
||||
$cmd->CompanyName = $item->raisonSociale;
|
||||
$cmd->CompanySiren = $item->siren;
|
||||
$cmd->DateInsert = $item->dateInsert;
|
||||
$cmd->DateEnvoi = $item->dateEnvoi;
|
||||
return $cmd;
|
||||
}
|
||||
} catch (Zend_Db_Exception $e) {
|
||||
if ($this->User->idClient == 1) {
|
||||
throw new SoapFault('ERR', $e->getMessage());
|
||||
} else {
|
||||
throw new SoapFault('ERR', "Application error");
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
protected function getBilanFile($ref){}
|
||||
|
||||
protected function setInvestigation()
|
||||
{
|
||||
$this->authenticate();
|
||||
$this->permission('enquetec');
|
||||
|
||||
//Table pour le stockage des demandes d'investigation
|
||||
|
||||
}
|
||||
|
||||
}
|
201
library/WsScore/Order/v0.1/Types.php
Normal file
201
library/WsScore/Order/v0.1/Types.php
Normal file
@ -0,0 +1,201 @@
|
||||
<?php
|
||||
class BilanInput
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $Reference;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $Siren;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $BilanFileRecv;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $BilanCloture;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $BilanType;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $ErreurDate;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $ErreurLabel;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $DateInsert;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $DateSaisie;
|
||||
}
|
||||
|
||||
class PieceKbis
|
||||
{
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $Reference;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $Mode;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $Error;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $CompanyName;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $CompanySiren;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $DateInsert;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $DateEnvoi;
|
||||
}
|
||||
|
||||
class PieceBilan
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $Reference;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $Mode;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $Error;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $DocBilanCloture;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $DocBilanType;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $CompanyName;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $CompanySiren;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $DateInsert;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $DateEnvoi;
|
||||
}
|
||||
|
||||
class PieceActe
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $Reference;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $Mode;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $Error;
|
||||
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $DocDepotNum;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $DocDepotDate;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $DocActeNum;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $DocActeType;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $DocActeDate;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $CompanyName;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $CompanySiren;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $DateInsert;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $DateEnvoi;
|
||||
}
|
||||
|
||||
|
@ -261,8 +261,7 @@ class Pieces extends Scores_Ws_Server
|
||||
//Liste des bilans Infogreffe
|
||||
else
|
||||
{
|
||||
require_once 'Metier/Infogreffe/InfogreffeBi.php';
|
||||
$infogreffe = new Metier_Infogreffe_Bi($identifiant);
|
||||
$infogreffe = new SdMetier_Infogreffe_DocBI($identifiant);
|
||||
try {
|
||||
$list = $infogreffe->getList();
|
||||
} catch (Exception $e) {
|
||||
@ -449,8 +448,7 @@ class Pieces extends Scores_Ws_Server
|
||||
case 'T':
|
||||
|
||||
//Passer la commande chez infogreffe
|
||||
require_once 'Metier/Infogreffe/InfogreffeBi.php';
|
||||
$infogreffe = new Metier_Infogreffe_Bi($identifiant);
|
||||
$infogreffe = new SdMetier_Infogreffe_DocBI($identifiant);
|
||||
//$infogreffe->debug = true;
|
||||
try {
|
||||
$pdf = $infogreffe->getCommandeT($dateCloture, $type, $id);
|
||||
@ -488,8 +486,7 @@ class Pieces extends Scores_Ws_Server
|
||||
|
||||
//Commande chez Infogreffe
|
||||
if ( $diffusion == 'C' ) {
|
||||
require_once 'Metier/Infogreffe/InfogreffeBi.php';
|
||||
$infogreffe = new Metier_Infogreffe_Bi($identifiant);
|
||||
$infogreffe = new SdMetier_Infogreffe_DocBI($identifiant);
|
||||
try {
|
||||
$infogreffe->getCommandeC($dateCloture, $type, 'G-BI-'.$id);
|
||||
$commandeM->update(array('dateCommande'=> date('YmdHis')), 'id='.$id);
|
||||
@ -539,8 +536,7 @@ class Pieces extends Scores_Ws_Server
|
||||
$this->sendError('1020');
|
||||
}
|
||||
|
||||
require_once 'Metier/Infogreffe/InfogreffeAc.php';
|
||||
$infogreffe = new Metier_Infogreffe_Ac($identifiant);
|
||||
$infogreffe = new SdMetier_Infogreffe_DocAC($identifiant);
|
||||
$list = $infogreffe->getList();
|
||||
$nbActes = count($list);
|
||||
|
||||
@ -631,8 +627,7 @@ class Pieces extends Scores_Ws_Server
|
||||
case 'T':
|
||||
|
||||
//Passer la commande chez Infogreffe
|
||||
require_once 'Metier/Infogreffe/InfogreffeAc.php';
|
||||
$infogreffe = new Metier_Infogreffe_Ac($identifiant);
|
||||
$infogreffe = new SdMetier_Infogreffe_DocAC($identifiant);
|
||||
try {
|
||||
$pdf = $infogreffe->getCommandeT($depotDate, $depotNum, $acteType, $acteDate, $acteNum, $id);
|
||||
$commandeM->update(array('dateEnvoi'=> date('YmdHis')), 'id='.$id);
|
||||
@ -675,8 +670,7 @@ class Pieces extends Scores_Ws_Server
|
||||
|
||||
if ( $diffusion == 'C' ) {
|
||||
//Commande chez Infogreffe
|
||||
require_once 'Metier/Infogreffe/InfogreffeAc.php';
|
||||
$infogreffe = new Metier_Infogreffe_Ac($identifiant);
|
||||
$infogreffe = new SdMetier_Infogreffe_DocAC($identifiant);
|
||||
try {
|
||||
$infogreffe->getCommandeC($depotDate, $depotNum, $acteType, $acteDate, $acteNum, 'G-AC-'.$id);
|
||||
$commandeM->update(array('dateCommande'=> date('YmdHis')), 'id='.$id);
|
||||
@ -779,7 +773,7 @@ class Pieces extends Scores_Ws_Server
|
||||
if ( is_int($email) ) {
|
||||
//Id of secondary email
|
||||
} else {
|
||||
$dateUpdate = array('email' => $email);
|
||||
$dataUpdate = array('email' => $email);
|
||||
try {
|
||||
$commandeM->update($dataUpdate, "refCommande='".$id."'");
|
||||
return true;
|
||||
@ -829,7 +823,7 @@ class Pieces extends Scores_Ws_Server
|
||||
if ( is_int($email) ) {
|
||||
//Id of secondary email
|
||||
} else {
|
||||
$dateUpdate = array('email' => $email);
|
||||
$dataUpdate = array('email' => $email);
|
||||
try {
|
||||
$commandeM->update($dataUpdate, "refCommande='".$id."'");
|
||||
return true;
|
||||
@ -873,7 +867,120 @@ class Pieces extends Scores_Ws_Server
|
||||
}
|
||||
}
|
||||
if ( $result !== null ) {
|
||||
$dateUpdate = array('infos' => $infos);
|
||||
$dataUpdate = array('infos' => $infos);
|
||||
try {
|
||||
$commandeM->update($dataUpdate, "refCommande='".$id."'");
|
||||
return true;
|
||||
} catch (Zend_Db_Exception $e) {
|
||||
if ($this->User->idClient == 1) {
|
||||
throw new SoapFault('ERR', $e->getMessage());
|
||||
} else {
|
||||
throw new SoapFault('ERR', "Application error");
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Commande de statut association
|
||||
* @param string $companyId
|
||||
* @param string $type (siren|waldec)
|
||||
* @throws SoapFault
|
||||
* @return mixed
|
||||
*/
|
||||
public function setAssoStatut($companyId, $type = null)
|
||||
{
|
||||
$this->authenticate();
|
||||
$this->permission('actes');
|
||||
|
||||
$inseeM = new MInsee();
|
||||
if ($type == 'siren') {
|
||||
$result = $inseeM->getIdentiteLight($companyId);
|
||||
$companyName = $result['Nom'];
|
||||
} elseif ($type == 'waldec') {
|
||||
$result = $inseeM->getEtablissementsParId('AUTRE', $companyId);
|
||||
$companyName = $result['Nom'];
|
||||
}
|
||||
|
||||
$refCommande = uniqid();
|
||||
|
||||
try {
|
||||
$commandeM = new Application_Model_Sdv1OrderAssoStatut();
|
||||
$commandeM->insert(array(
|
||||
'refCommande' => $refCommande,
|
||||
'companyId' => $companyId,
|
||||
'typeId' => $type,
|
||||
'companyName' => $companyName,
|
||||
'userId' => $this->User->id,
|
||||
'userLogin' => $this->User->login,
|
||||
'userEmail' => $this->USer->email,
|
||||
'dateInsert' => date('YmdHis'),
|
||||
));
|
||||
return $refCommande;
|
||||
} catch (Zend_Db_Exception $e) {
|
||||
if ($this->User->idClient == 1) {
|
||||
throw new SoapFault('ERR', $e->getMessage());
|
||||
} else {
|
||||
throw new SoapFault('ERR', "Application error");
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Modifier une commande de statut association
|
||||
* @param string $id
|
||||
* Référence de commande
|
||||
* @param string $data
|
||||
* Objet json (email, reference)
|
||||
* @throws SoapFault
|
||||
* @return boolean
|
||||
*/
|
||||
public function setAssoStatutDetail($id, $data)
|
||||
{
|
||||
$this->authenticate();
|
||||
$this->permission('actes');
|
||||
|
||||
// --- Vérification que la commande existe
|
||||
try {
|
||||
$commandeM = new Application_Model_Sdv1OrderAssoStatut();
|
||||
$sql = $commandeM->select()
|
||||
->where('userLogin=?', $this->User->login)
|
||||
->where('refCommande=?', $id);
|
||||
$result = $commandeM->fetchRow($sql);
|
||||
} catch (Zend_Db_Exception $e) {
|
||||
if ($this->User->idClient == 1) {
|
||||
throw new SoapFault('ERR', $e->getMessage());
|
||||
} else {
|
||||
throw new SoapFault('ERR', "Application error");
|
||||
}
|
||||
}
|
||||
|
||||
// --- Paramètres envoyés
|
||||
$params = json_decode($data, true);
|
||||
$dataUpdate = array();
|
||||
if (count($params) > 0) {
|
||||
foreach ($params as $k => $v) {
|
||||
switch ($k) {
|
||||
case 'email':
|
||||
// --- Vérification email
|
||||
$validator = new Zend_Validate_EmailAddress();
|
||||
if ( !$validator->isValid($v) ){
|
||||
throw new SoapFault('ERR', "Adresse email invalide.");
|
||||
}
|
||||
$dataUpdate['email'] = $v;
|
||||
break;
|
||||
case 'reference':
|
||||
$dataUpdate['reference'] = $v;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// --- Mise à jour de la commande
|
||||
if (count($dataUpdate) > 0) {
|
||||
try {
|
||||
$commandeM->update($dataUpdate, "refCommande='".$id."'");
|
||||
return true;
|
||||
@ -884,43 +991,77 @@ class Pieces extends Scores_Ws_Server
|
||||
throw new SoapFault('ERR', "Application error");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Financial account : Place an order to have number enter in database
|
||||
* @param string $siren
|
||||
* @param string $date
|
||||
* @param string $type N:Normal, S:Simplifié, C:Consolidé
|
||||
* @param string $source
|
||||
* @param integer $private
|
||||
* @throws SoapFault
|
||||
* @return string
|
||||
*/
|
||||
public function setBilanEnterCmd($siren, $date, $type, $source, $private = 0)
|
||||
|
||||
/**
|
||||
* Commande de privileges
|
||||
* @param string $companyId
|
||||
* Siren
|
||||
* @param string $doc
|
||||
* Type de privilege (privsecu, privtres, nantfond, declcrea)
|
||||
* @throws SoapFault
|
||||
* @return mixed
|
||||
*/
|
||||
public function setPrivileges($companyId, $doc = null)
|
||||
{
|
||||
$this->authenticate();
|
||||
$this->permission('UPLOADBILAN');
|
||||
|
||||
//Check siren
|
||||
|
||||
$this->permission('privileges');
|
||||
|
||||
$inseeM = new MInsee();
|
||||
$result = $inseeM->getIdentiteLight($companyId);
|
||||
$companyName = $result['Nom'];
|
||||
|
||||
$refCommande = uniqid();
|
||||
|
||||
$data = array(
|
||||
'refCommande' => $refCommande,
|
||||
'siren' => $siren,
|
||||
'userId' => $this->User->id,
|
||||
'bilanConfidentiel' => $private,
|
||||
'bilanSource' => $source,
|
||||
'bilanCloture' => $date,
|
||||
'bilanType' => $type,
|
||||
'dateInsert' => date('YmdHis'),
|
||||
);
|
||||
|
||||
try {
|
||||
$commandeM = new Application_Model_Sdv1BilanCommandeEnter();
|
||||
$commandeM->insert($data);
|
||||
$commandeM = new Application_Model_Sdv1OrderPrivileges();
|
||||
$commandeM->insert(array(
|
||||
'refCommande' => $refCommande,
|
||||
'docType' => $doc,
|
||||
'companyId' => $companyId,
|
||||
'companyName' => $companyName,
|
||||
'userId' => $this->User->id,
|
||||
'userLogin' => $this->User->login,
|
||||
'userEmail' => $this->User->email,
|
||||
'dateInsert' => date('YmdHis'),
|
||||
));
|
||||
return $refCommande;
|
||||
} catch (Zend_Db_Exception $e) {
|
||||
if ($this->User->idClient == 1) {
|
||||
throw new SoapFault('ERR', $e->getMessage());
|
||||
} else {
|
||||
throw new SoapFault('ERR', "Application error");
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Défini un email pour la commande de privilege
|
||||
* @param string $id
|
||||
* @param string $email
|
||||
* @throws SoapFault
|
||||
* @return boolean
|
||||
*/
|
||||
public function setPrivilegesEmail($id, $email)
|
||||
{
|
||||
$this->authenticate();
|
||||
|
||||
$validator = new Zend_Validate_EmailAddress();
|
||||
if ( !$validator->isValid($email) ){
|
||||
throw new SoapFault('ERR', "Adresse email invalide.");
|
||||
}
|
||||
|
||||
$commandeM = new Application_Model_Sdv1OrderPrivileges();
|
||||
$sql = $commandeM->select()
|
||||
->where('login=?', $this->User->login)
|
||||
->where('refCommande=?', $id);
|
||||
try {
|
||||
$result = $commandeM->fetchRow($sql);
|
||||
} catch (Zend_Db_Exception $e) {
|
||||
if ($this->User->idClient==1) {
|
||||
throw new SoapFault('ERR', $e->getMessage());
|
||||
@ -928,35 +1069,24 @@ class Pieces extends Scores_Ws_Server
|
||||
throw new SoapFault('ERR', "Application error");
|
||||
}
|
||||
}
|
||||
if ( $result !== null ) {
|
||||
if ( is_int($email) ) {
|
||||
//Id of secondary email
|
||||
} else {
|
||||
$dataUpdate = array('email' => $email);
|
||||
try {
|
||||
$commandeM->update($dataUpdate, "refCommande='".$id."'");
|
||||
return true;
|
||||
} catch (Zend_Db_Exception $e) {
|
||||
if ($this->User->idClient == 1) {
|
||||
throw new SoapFault('ERR', $e->getMessage());
|
||||
} else {
|
||||
throw new SoapFault('ERR', "Application error");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Financial account : Tag file is sent
|
||||
* @param string $ref
|
||||
* @throws SoapFault
|
||||
* @return boolean
|
||||
*/
|
||||
public function setBilanEnterFile($ref)
|
||||
{
|
||||
$this->authenticate();
|
||||
$this->permission('UPLOADBILAN');
|
||||
|
||||
$data = array(
|
||||
'bilanFileSent' => date('YmdHis'),
|
||||
);
|
||||
try {
|
||||
$commandeM = new Application_Model_Sdv1BilanCommandeEnter();
|
||||
$commandeM->update($data, "refCommande=$ref");
|
||||
return true;
|
||||
} catch (Zend_Db_Exception $e) {
|
||||
if ($this->User->idClient==1) {
|
||||
throw new SoapFault('ERR', $e->getMessage());
|
||||
} else {
|
||||
throw new SoapFault('ERR', "Application error");
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -1408,8 +1408,6 @@ class Saisie extends Scores_Ws_Server
|
||||
$this->sendError('1010');
|
||||
}
|
||||
|
||||
$intervalCalc = 10;
|
||||
|
||||
$tabPostes = array();
|
||||
|
||||
// --- Control des valeurs
|
||||
@ -2620,106 +2618,196 @@ class Saisie extends Scores_Ws_Server
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Saisie des coordonnées GPS
|
||||
* @param string $siret
|
||||
* @param string $latitude
|
||||
* @param string $longitude
|
||||
* @param string $altitude
|
||||
* @param string $precis
|
||||
* @param string $returnadresse
|
||||
* @return boolean
|
||||
* Set geocode from web application
|
||||
* @param string $companyId
|
||||
* @param string $type
|
||||
* @param string $data
|
||||
* JSON string containing formatted data
|
||||
* source, lat, lng, alt, address, precis
|
||||
* @param string $override
|
||||
* @throws SoapFault
|
||||
* @return int
|
||||
*/
|
||||
public function setEtablissementGeoCode($siret, $latitude, $longitude, $altitude, $precis, $returnadresse)
|
||||
public function setGeoCode($companyId, $type = null, $data, $override = false)
|
||||
{
|
||||
$this->authenticate();
|
||||
$this->authenticate();
|
||||
$siren = null;
|
||||
|
||||
// --- Identifiant SD : source + id
|
||||
if ($type === null) {
|
||||
|
||||
/**
|
||||
"results" : [
|
||||
"geometry" : {
|
||||
"location" : {
|
||||
"lat" : 37.42291810,
|
||||
"lng" : -122.08542120
|
||||
},
|
||||
"location_type" : "ROOFTOP",
|
||||
],
|
||||
"status" : "OK"
|
||||
*/
|
||||
|
||||
$iDb = new WDB();
|
||||
$iInsee = new MInsee($iDb);
|
||||
$result = $iInsee->getEtablissements($siren, $nic);
|
||||
$etab = $result['reponses'];
|
||||
|
||||
if (count($etab)>0) {
|
||||
//Mise à jour des coordonnées GPS
|
||||
if ( !empty($longitude) && !empty($latitude) ) {
|
||||
$adresse = addslashes(trim(preg_replace('/ +/',' ', $etab['adr_num'] . '' . $iInsee->getCodeVoie($etab['adr_typeVoie']) . $etab['adr_libVoie'])));
|
||||
$ville = addslashes($ville);
|
||||
$cp = $etab['adr_cp'];
|
||||
$ret = $iDb->select('zonageXY',
|
||||
'lat, lon, l93_x, l93_y, alt, precis, adresseValidee, dateInsert',
|
||||
"address='$adresse' AND adr_cp='$cp' AND adr_ville='$ville'",false, MYSQL_ASSOC);
|
||||
|
||||
if ( count($ret) == 0 ) {
|
||||
|
||||
require_once 'Metier/partenaires/classMMap.php';
|
||||
$tmp = geos2lambert93($latitude, $longitude);
|
||||
$l93x = $tmp['x_93'];
|
||||
$l93y = $tmp['y_93'];
|
||||
|
||||
switch($precis) {
|
||||
case 'ROOFTOP': $precision=8; break;
|
||||
case 'RANGE_INTERPOLATED': $precision=7; break;
|
||||
case 'GEOMETRIC_CENTER': $precision=6; break;
|
||||
case 'APPROXIMATE': $precision=4; break;
|
||||
default: $precision=0; break;
|
||||
}
|
||||
|
||||
$tabInsert=array(
|
||||
'address' => $adresse,
|
||||
'adr_cp' => $cp,
|
||||
'adr_ville' => $ville,
|
||||
'adrNum' => $etab['adr_num'],
|
||||
'adrIndRep' => $etab['adrIndRep'],
|
||||
'adrTypeVoie' => $etab['adr_typeVoie'],
|
||||
'adrLibVoie' => $etab['adr_libVoie'],
|
||||
'rivoli' => '',
|
||||
'adresseValidee' => strtoupper(str_replace(''', "'", htmlspecialchars_decode($returnadresse))),
|
||||
'lat' => $latitude,
|
||||
'lon' => $longitude,
|
||||
'l93_x' => $l93x,
|
||||
'l93_y' => $l93y,
|
||||
/**
|
||||
* http://maps.googleapis.com/maps/api/elevation/json?locations=39.7391536,-104.9847034
|
||||
*{
|
||||
"results" : [
|
||||
{
|
||||
"elevation" : 1608.637939453125,
|
||||
"location" : {
|
||||
"lat" : 39.73915360,
|
||||
"lng" : -104.98470340
|
||||
},
|
||||
"resolution" : 4.771975994110107
|
||||
}
|
||||
],
|
||||
"status" : "OK"
|
||||
}
|
||||
*/
|
||||
'alt' => $altitude,
|
||||
'precis' => $precision,
|
||||
'source' => 'Google',
|
||||
'dateInsert'=> date('Y-m-d H:i:s'),
|
||||
);
|
||||
$output = $iDb->insert('zonageXY', $tabInsert);
|
||||
return $output;
|
||||
|
||||
}
|
||||
}
|
||||
// --- Siren
|
||||
elseif (strtolower($type) == 'siren') {
|
||||
if (strlen($companyId) != 14) {
|
||||
throw new SoapFault('ERR', 'SIRET invalide.');
|
||||
}
|
||||
}
|
||||
// Erreur
|
||||
else {
|
||||
throw new SoapFault('ERR', 'Type identifiant inconnu.');
|
||||
}
|
||||
|
||||
// --- Lecture de l'adresse
|
||||
try {
|
||||
$etablissementM = new Application_Model_JoEtablissements();
|
||||
$sql = $etablissementM->select(true)->columns(array(
|
||||
'LPAD(adr_num,4,0) AS adr_num',
|
||||
'adr_btq',
|
||||
'adr_typeVoie',
|
||||
'adr_libVoie',
|
||||
'adr_comp',
|
||||
'LPAD(adr_cp,5,0) AS adr_cp',
|
||||
'adr_ville'
|
||||
))->where('siren=?', substr($companyId, 0, 9))->where('nic=?', substr($companyId, 9, 5));
|
||||
$result = $etablissementM->fetchRow($sql);
|
||||
} catch (Zend_Db_Exception $e) {
|
||||
if ($this->User->idClient==1) {
|
||||
throw new SoapFault('ERR', $e->getMessage());
|
||||
} else {
|
||||
throw new SoapFault('ERR', "Application error");
|
||||
}
|
||||
}
|
||||
if ($result === null) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// --- Result from database
|
||||
$AdresseNum = $result->adr_num;
|
||||
$AdresseTypeVoie = $result->adr_typeVoie;
|
||||
$AdresseLibVoie = $result->adr_libVoie;
|
||||
$AdresseCP = $result->adr_cp;
|
||||
$AdresseVille = $result->adr_ville;
|
||||
|
||||
$insee = new MInsee();
|
||||
$AdresseTypeVoieLong = $insee->getCodeVoie($AdresseTypeVoie);
|
||||
|
||||
// --- Format adress
|
||||
$adressPrimary = trim(preg_replace('/ +/',' ', "$AdresseNum $AdresseTypeVoieLong $AdresseLibVoie"));
|
||||
|
||||
// --- Code Rivoli
|
||||
$codeRivoli = '';
|
||||
try {
|
||||
$inseeidentiteM = new Application_Model_InseeIdentite();
|
||||
$sql = $inseeidentiteM->select(true)
|
||||
->columns(array('ADR_DEP', 'LPAD(ADR_COM,3,0) AS ADR_COM', 'CODEVOIE', 'ADR_TYPVOIE', 'ADR_LIBVOIE'))
|
||||
->where('SIREN=?', substr($companyId, 0, 9))
|
||||
->where('NIC=?', substr($companyId, 9, 5));
|
||||
$result = $inseeidentiteM->fetchRow($sql);
|
||||
} catch (Zend_Db_Exception $e) {
|
||||
if ($this->User->idClient==1) {
|
||||
throw new SoapFault('ERR', $e->getMessage());
|
||||
} else {
|
||||
throw new SoapFault('ERR', "Application error");
|
||||
}
|
||||
}
|
||||
if ($result !== null) {
|
||||
if (empty($result->CODEVOIE)) {
|
||||
$codeRivoli = $insee->getCodeVoieRivoli(
|
||||
$result->ADR_DEP.$result->ADR_COM,
|
||||
empty($result->ADR_TYPEVOIE) ? '' : $result->ADR_TYPEVOIE,
|
||||
empty($result->ADR_LIBVOIE) ? '' : $result->ADR_LIBVOIE
|
||||
);
|
||||
} else {
|
||||
$codeRivoli = $result->ADR_DEP.$result->ADR_COM.$result->CODEVOIE;
|
||||
}
|
||||
}
|
||||
|
||||
// --- Prepare geocoding
|
||||
try {
|
||||
$zonageM = new Application_Model_JoZonageXY();
|
||||
$sql = $zonageM->select()
|
||||
->where('address=?', $adressPrimary)
|
||||
->where('adr_cp=?', $AdresseCP)
|
||||
->where('adr_ville=?', $AdresseVille);
|
||||
$result = $zonageM->fetchRow($sql);
|
||||
} catch (Zend_Db_Exception $e) {
|
||||
if ($this->User->idClient==1) {
|
||||
throw new SoapFault('ERR', $e->getMessage());
|
||||
} else {
|
||||
throw new SoapFault('ERR', "Application error");
|
||||
}
|
||||
}
|
||||
if ($result === null) {
|
||||
$tableModif = 'insert';
|
||||
} else {
|
||||
$tableModif = 'update';
|
||||
}
|
||||
|
||||
$output = 0;
|
||||
$data = json_decode($data);
|
||||
if (!empty($data->lat) && !empty($data->lng)) {
|
||||
if ( strtolower($data->source) == 'google' ) {
|
||||
$precision = 0;
|
||||
switch($data->precis) {
|
||||
/**
|
||||
* Precise geocode for which we have location information accurate down to street address precision.
|
||||
*/
|
||||
case 'ROOFTOP':
|
||||
$precision = 8;
|
||||
break;
|
||||
/**
|
||||
* Approximation (usually on a road) interpolated between two precise points (such as intersections).
|
||||
* Interpolated results are generally returned when rooftop geocodes are unavailable for a street address.
|
||||
*/
|
||||
case 'RANGE_INTERPOLATED':
|
||||
$precision = 7;
|
||||
break;
|
||||
/**
|
||||
* Geometric center of a result such as a polyline (for example, a street) or polygon (region).
|
||||
*/
|
||||
case 'GEOMETRIC_CENTER':
|
||||
$precision = 6;
|
||||
break;
|
||||
/**
|
||||
* indicates that the returned result is approximate.
|
||||
*/
|
||||
case 'APPROXIMATE':
|
||||
$precision = 4;
|
||||
break;
|
||||
}
|
||||
|
||||
require_once 'Metier/partenaires/classMMap.php';
|
||||
$lambert = geos2lambert93($data->lat, $data->lng);
|
||||
$dataGeocode = array(
|
||||
'address' => $adressPrimary,
|
||||
'adr_cp' => $AdresseCP,
|
||||
'adr_ville' => $AdresseVille,
|
||||
'adrNum' => $AdresseNum,
|
||||
'adrIndRep' => '',
|
||||
'adrTypeVoie' => $AdresseTypeVoie,
|
||||
'adrLibVoie' => $AdresseLibVoie,
|
||||
'rivoli' => $codeRivoli,
|
||||
'adresseValidee' => $data->address,
|
||||
'lat' => $data->lat,
|
||||
'lon' => $data->lng,
|
||||
'l93_x' => $lambert['x_93'],
|
||||
'l93_y' => $lambert['y_93'],
|
||||
'alt' => intval($data->alt),
|
||||
'precis' => $precision,
|
||||
'source' => 'Google',
|
||||
);
|
||||
}
|
||||
|
||||
return false;
|
||||
try {
|
||||
if ($tableModif == 'insert') {
|
||||
$dataGeocode['dateInsert'] = date('YmdHis');
|
||||
$output = $zonageM->insert($dataGeocode);
|
||||
} else {
|
||||
$output = $zonageM->update($dataGeocode, array('address=?'=>$adressPrimary));
|
||||
}
|
||||
} catch (Zend_Db_Exception $e) {
|
||||
if ($this->User->idClient==1) {
|
||||
throw new SoapFault('ERR', $e->getMessage());
|
||||
} else {
|
||||
throw new SoapFault('ERR', "Application error");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
}
|
@ -33,6 +33,13 @@ return array(
|
||||
),
|
||||
'idClient' => array(1),
|
||||
),
|
||||
'order' => array(
|
||||
'actif' => true,
|
||||
'versions' => array(
|
||||
'0.1' => array( 'actif' => true, 'defaut' => true ),
|
||||
),
|
||||
'idClient' => array(1),
|
||||
),
|
||||
'catalog' => array(
|
||||
'actif' => true,
|
||||
'versions' => array(
|
||||
|
@ -1,763 +1,48 @@
|
||||
<?
|
||||
<?php
|
||||
class WChiffes
|
||||
{
|
||||
private static $tabChiffresEnLEttres = array(
|
||||
0=>'zéro',
|
||||
1=>'un',
|
||||
2=>'deux',
|
||||
3=>'trois',
|
||||
4=>'quatre',
|
||||
5=>'cinq',
|
||||
6=>'six',
|
||||
7=>'sept',
|
||||
8=>'huit',
|
||||
9=>'neuf',
|
||||
10=>'dix',
|
||||
11=>'onze',
|
||||
12=>'douze',
|
||||
13=>'treize',
|
||||
14=>'quatorze',
|
||||
15=>'quinze',
|
||||
16=>'seize',
|
||||
17=>'dix sept',
|
||||
18=>'dix huit',
|
||||
19=>'dix neuf',
|
||||
20=>'vingt',
|
||||
21=>'vingt et un',
|
||||
22=>'vingt deux',
|
||||
23=>'vingt trois',
|
||||
24=>'vingt quatre',
|
||||
25=>'vingt cinq',
|
||||
26=>'vingt six',
|
||||
27=>'vingt sept',
|
||||
28=>'vingt huit',
|
||||
29=>'vingt neuf',
|
||||
30=>'trente',
|
||||
40=>'quarante',
|
||||
50=>'cinquante',
|
||||
60=>'soixante',
|
||||
70=>'soixante dix',
|
||||
80=>'quatre vingt',
|
||||
90=>'quatre vingt dix'
|
||||
);
|
||||
|
||||
class WChiffes {
|
||||
|
||||
private static $tabChiffresEnLEttres = array( 0=>'zéro',
|
||||
1=>'un',
|
||||
2=>'deux',
|
||||
3=>'trois',
|
||||
4=>'quatre',
|
||||
5=>'cinq',
|
||||
6=>'six',
|
||||
7=>'sept',
|
||||
8=>'huit',
|
||||
9=>'neuf',
|
||||
10=>'dix',
|
||||
11=>'onze',
|
||||
12=>'douze',
|
||||
13=>'treize',
|
||||
14=>'quatorze',
|
||||
15=>'quinze',
|
||||
16=>'seize',
|
||||
17=>'dix sept',
|
||||
18=>'dix huit',
|
||||
19=>'dix neuf',
|
||||
20=>'vingt',
|
||||
21=>'vingt et un',
|
||||
22=>'vingt deux',
|
||||
23=>'vingt trois',
|
||||
24=>'vingt quatre',
|
||||
25=>'vingt cinq',
|
||||
26=>'vingt six',
|
||||
27=>'vingt sept',
|
||||
28=>'vingt huit',
|
||||
29=>'vingt neuf',
|
||||
30=>'trente',
|
||||
40=>'quarante',
|
||||
50=>'cinquante',
|
||||
60=>'soixante',
|
||||
70=>'soixante dix',
|
||||
80=>'quatre vingt',
|
||||
90=>'quatre vingt dix');
|
||||
|
||||
public function ChiffresEnLettres($chiffre) {
|
||||
public function ChiffresEnLettres($chiffre)
|
||||
{
|
||||
return array_search($chiffre, self::$tabChiffresEnLEttres);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
define('NEL_SEPTANTE', 0x0001);
|
||||
define('NEL_HUITANTE', 0x0002);
|
||||
define('NEL_OCTANTE', 0x0004);
|
||||
define('NEL_NONANTE', 0x0008);
|
||||
define('NEL_BELGIQUE', NEL_SEPTANTE|NEL_NONANTE);
|
||||
define('NEL_VVF', NEL_SEPTANTE|NEL_HUITANTE|NEL_NONANTE);
|
||||
define('NEL_ARCHAIQUE', NEL_SEPTANTE|NEL_OCTANTE|NEL_NONANTE);
|
||||
define('NEL_SANS_MILLIARD', 0x0010);
|
||||
define('NEL_AVEC_ZILLIARD', 0x0020);
|
||||
define('NEL_TOUS_ZILLIONS', 0x0040);
|
||||
define('NEL_RECTIF_1990', 0x0100);
|
||||
define('NEL_ORDINAL', 0x0200);
|
||||
define('NEL_NIEME', 0x0400);
|
||||
|
||||
|
||||
# Le tableau associatif $NEL contient toutes les variables utilisées
|
||||
# de façon globale dans ce module. ATTENTION : ce nom est assez court,
|
||||
# et cela pourrait poser des problèmes de collision avec une autre
|
||||
# variable si plusieurs modules sont inclus dans le même programme.
|
||||
|
||||
$NEL = array(
|
||||
'1-99' => array(
|
||||
# 0-19
|
||||
'', 'un', 'deux', 'trois', 'quatre', 'cinq', 'six', 'sept',
|
||||
'huit', 'neuf', 'dix', 'onze', 'douze', 'treize', 'quatorze',
|
||||
'quinze', 'seize', 'dix-sept', 'dix-huit', 'dix-neuf',
|
||||
# 20-29
|
||||
'vingt', 'vingt et un', 'vingt-deux', 'vingt-trois',
|
||||
'vingt-quatre', 'vingt-cinq', 'vingt-six',
|
||||
'vingt-sept', 'vingt-huit', 'vingt-neuf',
|
||||
# 30-39
|
||||
'trente', 'trente et un', 'trente-deux', 'trente-trois',
|
||||
'trente-quatre', 'trente-cinq', 'trente-six',
|
||||
'trente-sept', 'trente-huit', 'trente-neuf',
|
||||
# 40-49
|
||||
'quarante', 'quarante et un', 'quarante-deux', 'quarante-trois',
|
||||
'quarante-quatre', 'quarante-cinq', 'quarante-six',
|
||||
'quarante-sept', 'quarante-huit', 'quarante-neuf',
|
||||
# 50-59
|
||||
'cinquante', 'cinquante et un', 'cinquante-deux', 'cinquante-trois',
|
||||
'cinquante-quatre', 'cinquante-cinq', 'cinquante-six',
|
||||
'cinquante-sept', 'cinquante-huit', 'cinquante-neuf',
|
||||
# 60-69
|
||||
'soixante', 'soixante et un', 'soixante-deux', 'soixante-trois',
|
||||
'soixante-quatre', 'soixante-cinq', 'soixante-six',
|
||||
'soixante-sept', 'soixante-huit', 'soixante-neuf',
|
||||
# 70-79
|
||||
'septante', 'septante et un', 'septante-deux', 'septante-trois',
|
||||
'septante-quatre', 'septante-cinq', 'septante-six',
|
||||
'septante-sept', 'septante-huit', 'septante-neuf',
|
||||
# 80-89
|
||||
'huitante', 'huitante et un', 'huitante-deux', 'huitante-trois',
|
||||
'huitante-quatre', 'huitante-cinq', 'huitante-six',
|
||||
'huitante-sept', 'huitante-huit', 'huitante-neuf',
|
||||
# 90-99
|
||||
'nonante', 'nonante et un', 'nonante-deux', 'nonante-trois',
|
||||
'nonante-quatre', 'nonante-cinq', 'nonante-six',
|
||||
'nonante-sept', 'nonante-huit', 'nonante-neuf'
|
||||
),
|
||||
|
||||
'illi' => array('', 'm', 'b', 'tr', 'quatr', 'quint', 'sext'),
|
||||
'maxilli' => 0, # voir plus loin
|
||||
'de_maxillions' => '', # voir plus loin
|
||||
|
||||
'septante' => false, # valeurs possibles : (false|true)
|
||||
'huitante' => false, # valeurs possibles : (false|true|'octante')
|
||||
'nonante' => false, # valeurs possibles : (false|true)
|
||||
'zillions' => false, # valeurs possibles : (false|true)
|
||||
'zilliard' => 1, # valeurs possibles : (0|1|2)
|
||||
'rectif' => false, # valeurs possibles : (false|true)
|
||||
'ordinal' => false, # valeurs possibles : (false|true|'nieme')
|
||||
|
||||
'separateur' => ' '
|
||||
);
|
||||
|
||||
# Si le tableau $NEL['illi'] s'arrête à 'sext', alors les deux valeurs
|
||||
# suivantes sont respectivement '6' et ' de sextillions'.
|
||||
$NEL['maxilli'] = count($NEL['illi']) - 1;
|
||||
$NEL['de_maxillions'] = " de {$NEL['illi'][$NEL['maxilli']]}illions";
|
||||
|
||||
function enlettres_options($options, $separateur=NULL)
|
||||
{
|
||||
global $NEL;
|
||||
|
||||
if ($options !== NULL) {
|
||||
$NEL['septante'] = ($options & NEL_SEPTANTE) ? true : false;
|
||||
$NEL['huitante'] =
|
||||
($options & NEL_OCTANTE) ? 'octante' :
|
||||
(($options & NEL_HUITANTE) ? true : false);
|
||||
$NEL['nonante'] = ($options & NEL_NONANTE) ? true : false;
|
||||
$NEL['zillions'] = ($options & NEL_TOUS_ZILLIONS) ? true : false;
|
||||
$NEL['zilliard'] =
|
||||
($options & NEL_AVEC_ZILLIARD) ? 2 :
|
||||
(($options & NEL_SANS_MILLIARD) ? 0 : 1);
|
||||
$NEL['rectif'] = ($options & NEL_RECTIF_1990) ? true : false;
|
||||
$NEL['ordinal'] =
|
||||
($options & NEL_NIEME) ? 'nieme' :
|
||||
(($options & NEL_ORDINAL) ? true : false);
|
||||
}
|
||||
|
||||
if ($separateur !== NULL) {
|
||||
$NEL['separateur'] = $separateur;
|
||||
}
|
||||
}
|
||||
|
||||
function enlettres_par3($par3)
|
||||
{
|
||||
global $NEL;
|
||||
|
||||
if ($par3 == 0) return '';
|
||||
|
||||
$centaine = floor($par3 / 100);
|
||||
$par2 = $par3 % 100;
|
||||
$dizaine = floor($par2 / 10);
|
||||
|
||||
# On traite à part les particularités du français de référence
|
||||
# 'soixante-dix', 'quatre-vingts' et 'quatre-vingt-dix'.
|
||||
$nom_par2 = NULL;
|
||||
switch ($dizaine) {
|
||||
case 7:
|
||||
if ($NEL['septante'] === false) {
|
||||
if ($par2 == 71) $nom_par2 = 'soixante et onze';
|
||||
else $nom_par2 = 'soixante-' . $NEL['1-99'][$par2 - 60];
|
||||
}
|
||||
break;
|
||||
case 8:
|
||||
if ($NEL['huitante'] === false) {
|
||||
if ($par2 == 80) $nom_par2 = 'quatre-vingts';
|
||||
else $nom_par2 = 'quatre-vingt-' . $NEL['1-99'][$par2 - 80];
|
||||
}
|
||||
break;
|
||||
case 9:
|
||||
if ($NEL['nonante'] === false) {
|
||||
$nom_par2 = 'quatre-vingt-' . $NEL['1-99'][$par2 - 80];
|
||||
}
|
||||
break;
|
||||
}
|
||||
if ($nom_par2 === NULL) {
|
||||
$nom_par2 = $NEL['1-99'][$par2];
|
||||
if (($dizaine == 8) and ($NEL['huitante'] === 'octante')) {
|
||||
$nom_par2 = str_replace('huitante', 'octante', $nom_par2);
|
||||
}
|
||||
}
|
||||
|
||||
# Après les dizaines et les unités, il reste à voir les centaines
|
||||
switch ($centaine) {
|
||||
case 0: return $nom_par2;
|
||||
case 1: return rtrim("cent {$nom_par2}");
|
||||
}
|
||||
|
||||
# Assertion : $centaine = 2 .. 9
|
||||
$nom_centaine = $NEL['1-99'][$centaine];
|
||||
if ($par2 == 0) return "{$nom_centaine} cents";
|
||||
return "{$nom_centaine} cent {$nom_par2}";
|
||||
}
|
||||
|
||||
function enlettres_zilli($idx)
|
||||
{
|
||||
# Noms des 0ème à 9ème zillions
|
||||
static $petit = array(
|
||||
'n', 'm', 'b', 'tr', 'quatr', 'quint', 'sext', 'sept', 'oct', 'non'
|
||||
);
|
||||
# Composantes des 10ème à 999ème zillions
|
||||
static $unite = array(
|
||||
'<', 'un<', 'duo<', 'tre<sé',
|
||||
'quattuor<', 'quin<', 'se<xsé',
|
||||
'septe<mné', 'octo<', 'nove<mné'
|
||||
);
|
||||
static $dizaine = array(
|
||||
'', 'né>déci<', 'ms>viginti<', 'ns>triginta<',
|
||||
'ns>quadraginta<', 'ns>quinquaginta<', 'né>sexaginta<',
|
||||
'né>septuaginta<', 'mxs>octoginta<', 'é>nonaginta<'
|
||||
);
|
||||
static $centaine = array(
|
||||
'>', 'nxs>cent', 'né>ducent', 'ns>trécent',
|
||||
'ns>quadringent', 'ns>quingent', 'né>sescent',
|
||||
'né>septingent', 'mxs>octingent', 'é>nongent'
|
||||
);
|
||||
|
||||
# Règles d'assimilation aux préfixes latins, modifiées pour accentuer
|
||||
# un éventuel 'é' de fin de préfixe.
|
||||
# (1) Si on trouve une lettre deux fois entre < > on la garde.
|
||||
# S'il y a plusieurs lettres dans ce cas, on garde la première.
|
||||
# (2) Sinon on efface tout ce qui est entre < >.
|
||||
# (3) On remplace "treé" par "tré", "seé" par "sé", "septeé" par "septé"
|
||||
# et "noveé" par "nové".
|
||||
# (4) En cas de dizaine sans centaine, on supprime la voyelle en trop.
|
||||
# Par exemple "déciilli" devient "décilli" et "trigintailli" devient
|
||||
# "trigintilli".
|
||||
#
|
||||
# Il est à noter que ces règles PERL (en particulier la première qui
|
||||
# est la plus complexe) sont *très* fortement inspirées du programme
|
||||
# de Nicolas Graner. On pourrait même parler de plagiat s'il n'avait
|
||||
# pas été au courant que je reprenais son code.
|
||||
# Voir <http://www.graner.net/nicolas/nombres/nom.php>
|
||||
# et <http://www.graner.net/nicolas/nombres/nom-exp.php>
|
||||
#
|
||||
static $recherche = array(
|
||||
'/<[a-zé]*?([a-zé])[a-zé]*\1[a-zé]*>/', # (1)
|
||||
'/<[a-zé]*>/', # (2)
|
||||
'/eé/', # (3)
|
||||
'/[ai]illi/' # (4)
|
||||
);
|
||||
static $remplace = array(
|
||||
'\\1', # (1)
|
||||
'', # (2)
|
||||
'é', # (3)
|
||||
'illi' # (4)
|
||||
);
|
||||
|
||||
$nom = '';
|
||||
while ($idx > 0) {
|
||||
$p = $idx % 1000;
|
||||
$idx = floor($idx/1000);
|
||||
|
||||
if ($p < 10) {
|
||||
$nom = $petit[$p] . 'illi' . $nom;
|
||||
} else {
|
||||
$nom = $unite[$p % 10] . $dizaine[floor($p/10) % 10]
|
||||
. $centaine[floor($p/100)] . 'illi' . $nom;
|
||||
}
|
||||
}
|
||||
return preg_replace($recherche, $remplace, $nom);
|
||||
}
|
||||
|
||||
function enlettres_illions($idx)
|
||||
{
|
||||
global $NEL;
|
||||
|
||||
if ($idx == 0) {
|
||||
return '';
|
||||
}
|
||||
|
||||
if ($NEL['zillions']) {
|
||||
return enlettres_zilli($idx) . 'ons';
|
||||
}
|
||||
|
||||
$suffixe = '';
|
||||
while ($idx > $NEL['maxilli']) {
|
||||
$idx -= $NEL['maxilli'];
|
||||
$suffixe .= $NEL['de_maxillions'];
|
||||
}
|
||||
return "{$NEL['illi'][$idx]}illions{$suffixe}";
|
||||
}
|
||||
|
||||
function enlettres_avec_illiards($idx)
|
||||
{
|
||||
global $NEL;
|
||||
|
||||
if ($idx == 0) return false;
|
||||
switch ($NEL['zilliard']) {
|
||||
case 0: return false;
|
||||
case 2: return true;
|
||||
}
|
||||
return ($idx == 1);
|
||||
}
|
||||
|
||||
function enlettres($nombre, $options=NULL, $separateur=NULL)
|
||||
{
|
||||
global $NEL;
|
||||
|
||||
if ($options !== NULL or $separateur !== NULL) {
|
||||
$NELsave = $NEL;
|
||||
enlettres_options($options, $separateur);
|
||||
$nom = enlettres($nombre);
|
||||
$NEL = $NELsave;
|
||||
return $nom;
|
||||
}
|
||||
|
||||
# On ne garde que les chiffres, puis on supprime les 0 du début
|
||||
$nombre = preg_replace('/[^0-9]/', '', $nombre);
|
||||
$nombre = ltrim($nombre, '0');
|
||||
|
||||
if ($nombre == '') {
|
||||
if ($NEL['ordinal'] === 'nieme') return 'zéroïème';
|
||||
else return 'zéro';
|
||||
}
|
||||
|
||||
$table_noms = array();
|
||||
for ($idx = 0; $nombre != ''; $idx++) {
|
||||
$par6 = (int)((strlen($nombre) < 6) ? $nombre : substr($nombre, -6));
|
||||
$nombre = substr($nombre, 0, -6);
|
||||
|
||||
if ($par6 == 0) continue;
|
||||
|
||||
$nom_par3_sup = enlettres_par3(floor($par6 / 1000));
|
||||
$nom_par3_inf = enlettres_par3($par6 % 1000);
|
||||
|
||||
$illions = enlettres_illions($idx);
|
||||
if (enlettres_avec_illiards($idx)) {
|
||||
if ($nom_par3_inf != '') {
|
||||
$table_noms[$illions] = $nom_par3_inf;
|
||||
}
|
||||
if ($nom_par3_sup != '') {
|
||||
$illiards = preg_replace('/illion/', 'illiard', $illions, 1);
|
||||
$table_noms[$illiards] = $nom_par3_sup;
|
||||
}
|
||||
} else {
|
||||
switch($nom_par3_sup) {
|
||||
case '':
|
||||
$nom_par6 = $nom_par3_inf;
|
||||
break;
|
||||
case 'un':
|
||||
$nom_par6 = rtrim("mille {$nom_par3_inf}");
|
||||
break;
|
||||
default:
|
||||
$nom_par3_sup = preg_replace('/(vingt|cent)s/', '\\1', $nom_par3_sup);
|
||||
$nom_par6 = rtrim("{$nom_par3_sup} mille {$nom_par3_inf}");
|
||||
break;
|
||||
}
|
||||
$table_noms[$illions] = $nom_par6;
|
||||
}
|
||||
}
|
||||
|
||||
$nom_enlettres = '';
|
||||
foreach ($table_noms as $nom => $nombre) {
|
||||
##
|
||||
# $nombre est compris entre 'un' et
|
||||
# 'neuf cent nonante-neuf mille neuf cent nonante-neuf'
|
||||
# (ou variante avec 'quatre-vingt-dix-neuf')
|
||||
##
|
||||
# $nom peut valoir '', 'millions', 'milliards', 'billions', ...
|
||||
# 'sextillions', 'sextilliards', 'millions de sextillions',
|
||||
# 'millions de sextilliards', etc.
|
||||
##
|
||||
|
||||
# Rectifications orthographiques de 1990
|
||||
if ($NEL['rectif']) {
|
||||
$nombre = str_replace(' ', '-', $nombre);
|
||||
}
|
||||
|
||||
# Nom (éventuel) et accord (éventuel) des substantifs
|
||||
$nom = rtrim("{$nombre} {$nom}");
|
||||
if ($nombre == 'un') {
|
||||
# Un seul million, milliard, etc., donc au singulier
|
||||
# noter la limite de 1 remplacement, pour ne supprimer que le premier 's'
|
||||
# dans 'billions de sextillions de sextillions'
|
||||
$nom = preg_replace('/(illion|illiard)s/', '\\1', $nom, 1);
|
||||
}
|
||||
|
||||
# Ajout d'un séparateur entre chaque partie
|
||||
if ($nom_enlettres == '') {
|
||||
$nom_enlettres = $nom;
|
||||
} else {
|
||||
$nom_enlettres = $nom . $NEL['separateur'] . $nom_enlettres;
|
||||
}
|
||||
}
|
||||
|
||||
if ($NEL['ordinal'] === false) {
|
||||
# Nombre cardinal : le traitement est fini
|
||||
return $nom_enlettres;
|
||||
}
|
||||
|
||||
# Aucun pluriel dans les ordinaux
|
||||
$nom_enlettres =
|
||||
preg_replace('/(cent|vingt|illion|illiard)s/', '\\1', $nom_enlettres);
|
||||
|
||||
if ($NEL['ordinal'] !== 'nieme') {
|
||||
# Nombre ordinal simple (sans '-ième')
|
||||
return $nom_enlettres;
|
||||
}
|
||||
|
||||
if ($nom_enlettres === 'un') {
|
||||
# Le féminin n'est pas traité ici. On fait la supposition
|
||||
# qu'il est plus facile de traiter ce cas à part plutôt
|
||||
# que de rajouter une option rien que pour ça.
|
||||
return 'premier';
|
||||
}
|
||||
|
||||
switch (substr($nom_enlettres, -1)) {
|
||||
case 'e':
|
||||
# quatre, onze à seize, trente à nonante, mille
|
||||
# exemple : quatre -> quatrième
|
||||
return substr($nom_enlettres, 0, -1) . 'ième';
|
||||
case 'f':
|
||||
# neuf -> neuvième
|
||||
return substr($nom_enlettres, 0, -1) . 'vième';
|
||||
case 'q':
|
||||
# cinq -> cinquième
|
||||
return $nom_enlettres . 'uième';
|
||||
}
|
||||
|
||||
# Tous les autres cas.
|
||||
# Exemples: deuxième, troisième, vingtième, trente et unième,
|
||||
# neuf centième, un millionième, quatre-vingt milliardième.
|
||||
return $nom_enlettres . 'ième';
|
||||
}
|
||||
|
||||
function enchiffres_petit($mot)
|
||||
{
|
||||
static $petit = array(
|
||||
# 1-16
|
||||
'un' => 1,
|
||||
'deux' => 2,
|
||||
'trois' => 3,
|
||||
'quatre' => 4,
|
||||
'cinq' => 5,
|
||||
'six' => 6,
|
||||
'sept' => 7,
|
||||
'huit' => 8,
|
||||
'neuf' => 9,
|
||||
'dix' => 10,
|
||||
'onze' => 11,
|
||||
'douze' => 12,
|
||||
'treize' => 13,
|
||||
'quatorze' => 14,
|
||||
'quinze' => 15,
|
||||
'seize' => 16,
|
||||
# 20-90
|
||||
'vingt' => 20,
|
||||
'vingts' => 20,
|
||||
'trente' => 30,
|
||||
'quarante' => 40,
|
||||
'cinquante' => 50,
|
||||
'soixante' => 60,
|
||||
'septante' => 70,
|
||||
'huitante' => 80,
|
||||
'octante' => 80,
|
||||
'nonante' => 90,
|
||||
# 100, 1000
|
||||
'cent' => 100,
|
||||
'cents' => 100,
|
||||
'mil' => 1000,
|
||||
'mille' => 1000
|
||||
);
|
||||
|
||||
if (! isset($petit[$mot]))
|
||||
return false;
|
||||
|
||||
return $petit[$mot];
|
||||
}
|
||||
|
||||
function enchiffres_zilli($mot)
|
||||
{
|
||||
# Noms des 0ème à 9ème zillions
|
||||
static $petits = array(
|
||||
'n', 'm', 'b', 'tr', 'quadr', 'quint', 'sext', 'sept', 'oct', 'non'
|
||||
);
|
||||
# Composantes des 10ème à 999ème zillions
|
||||
static $unites = array(
|
||||
'', 'un', 'duo', 'tre', 'quattuor', 'quin', 'se', 'septe', 'octo', 'nove'
|
||||
);
|
||||
static $dizaines = array(
|
||||
'', 'dec', 'vigint', 'trigint', 'quadragint',
|
||||
'quinquagint', 'sexagint', 'septuagint', 'octogint', 'nonagint'
|
||||
);
|
||||
static $centaines = array(
|
||||
'', 'cent', 'ducent', 'trecent', 'quadringent',
|
||||
'quingent', 'sescent', 'septingent', 'octingent', 'nongent'
|
||||
);
|
||||
# Expressions rationnelles pour extraire les composantes
|
||||
static $um =
|
||||
'(|un|duo|tre(?!c)|quattuor|quin|se(?!p)(?!sc)|septe|octo|nove)[mnsx]?';
|
||||
static $dm =
|
||||
'(|dec|(?:v|tr|quadr|quinqu|sex|septu|oct|non)[aio]gint)[ai]?';
|
||||
static $cm =
|
||||
'(|(?:|du|tre|ses)cent|(?:quadri|qui|septi|octi|no)ngent)';
|
||||
|
||||
$u = array_search($mot, $petits);
|
||||
if ($u !== false) {
|
||||
return '00' . $u;
|
||||
}
|
||||
|
||||
if (preg_match('/^'.$um.$dm.$cm.'$/', $mot, $resultat) < 1) {
|
||||
return false;
|
||||
}
|
||||
$u = array_search($resultat[1], $unites);
|
||||
$d = array_search($resultat[2], $dizaines);
|
||||
$c = array_search($resultat[3], $centaines);
|
||||
if ($u === false or $d === false or $c === false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $c.$d.$u;
|
||||
}
|
||||
|
||||
function enchiffres_grand($mot)
|
||||
{
|
||||
# Quelques remplacements initiaux pour simplifier (les 'é' ont déjà
|
||||
# été tous transformés en 'e').
|
||||
# (1) Je supprime le 's' final de '-illions' ou '-illiards' pour ne
|
||||
# tester que '-illion' ou '-illiard'.
|
||||
# (2) Les deux orthographes étant possibles pour quadrillion ou
|
||||
# quatrillion, je teste les deux. Noter que j'aurais pu changer
|
||||
# 'quadr' en 'quatr' au lieu de l'inverse, mais alors cela aurait
|
||||
# aussi changé 'quadragintillion' en 'quatragintillion', ce qui
|
||||
# n'est pas franchement le but recherché.
|
||||
# (3) En latin, on trouve parfois 'quatuor' au lieu de 'quattuor'. De même,
|
||||
# avec google on trouve quelques 'quatuordecillions' au milieu des
|
||||
# 'quattuordecillions' (environ 1 sur 10).
|
||||
# (4) La règle de John Conway et Allan Wechsler préconisait le préfixe
|
||||
# 'quinqua' au lieu de 'quin' que j'ai choisi. Pour accepter les deux,
|
||||
# je remplace 'quinqua' par 'quin', sauf dans 'quinquaginta' (50)
|
||||
# et dans 'quinquadraginta' (45).
|
||||
static $recherche = array(
|
||||
'/s$/', # (1)
|
||||
'/quatr/', # (2)
|
||||
'/quatuor/', # (3)
|
||||
'/quinqua(?!(dra)?gint)/' # (4)
|
||||
);
|
||||
static $remplace = array(
|
||||
'', # (1)
|
||||
'quadr', # (2)
|
||||
'quattuor', # (3)
|
||||
'quin' # (4)
|
||||
);
|
||||
|
||||
$mot = preg_replace($recherche, $remplace, $mot);
|
||||
if ($mot == 'millier') return 1;
|
||||
if ($mot == 'millinillion') return 2000;
|
||||
|
||||
$prefixes = explode('illi', $mot);
|
||||
if (count($prefixes) < 2) {
|
||||
# Il faut au moins un 'illi' dans le nom
|
||||
return false;
|
||||
}
|
||||
switch (array_pop($prefixes)) {
|
||||
case 'on':
|
||||
# zillion : nombre pair de milliers
|
||||
$ard = 0;
|
||||
break;
|
||||
case 'ard':
|
||||
# zilliard : nombre impair de milliers
|
||||
$ard = 1;
|
||||
break;
|
||||
default:
|
||||
# Ce n'est ni un zillion, ni un zilliard
|
||||
return false;
|
||||
}
|
||||
|
||||
$nombre = '';
|
||||
foreach ($prefixes as $prefixe) {
|
||||
$par3 = enchiffres_zilli($prefixe);
|
||||
if ($par3 === false) return false;
|
||||
$nombre .= $par3;
|
||||
}
|
||||
if (strlen($nombre) > 3) {
|
||||
# On n'accepte que les nombres inférieurs au millinillion
|
||||
# pour limiter le temps de calcul
|
||||
return 0;
|
||||
}
|
||||
return 2*$nombre + $ard;
|
||||
}
|
||||
|
||||
class enchiffres_struct
|
||||
{
|
||||
var $valeur;
|
||||
var $discr;
|
||||
|
||||
function enchiffres_struct($mul, $val)
|
||||
{
|
||||
$this->valeur = $this->discr = $val;
|
||||
if ($mul != 0) {
|
||||
$this->valeur *= $mul;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function enchiffres_ajouter_petit(&$table_petits, $petit)
|
||||
{
|
||||
$somme = 0;
|
||||
while (($elem = array_pop($table_petits)) !== NULL) {
|
||||
if ($elem->discr > $petit) {
|
||||
array_push($table_petits, $elem);
|
||||
break;
|
||||
}
|
||||
$somme += $elem->valeur;
|
||||
}
|
||||
$elem = new enchiffres_struct($somme, $petit);
|
||||
array_push($table_petits, $elem);
|
||||
}
|
||||
|
||||
function enchiffres_somme_petits($table_petits)
|
||||
{
|
||||
$somme = 0;
|
||||
foreach ($table_petits as $elem) {
|
||||
$somme += $elem->valeur;
|
||||
}
|
||||
return $somme;
|
||||
}
|
||||
|
||||
function enchiffres_ajouter_grand(&$table_grands, $mantisse, $exposant)
|
||||
{
|
||||
while ($mantisse > 0) {
|
||||
if (isset($table_grands[$exposant])) {
|
||||
$mantisse += $table_grands[$exposant];
|
||||
}
|
||||
$table_grands[$exposant] = $mantisse % 1000;
|
||||
$mantisse = floor($mantisse / 1000);
|
||||
$exposant++;
|
||||
}
|
||||
}
|
||||
|
||||
function enchiffres($nom)
|
||||
{
|
||||
$nom = preg_replace('/[éèÉÈ]/', 'e', $nom);
|
||||
$nom = strtolower($nom);
|
||||
$table_mots = preg_split('/[^a-z]+/', $nom);
|
||||
|
||||
$table_petits = array();
|
||||
$mantisse = $exposant = 0;
|
||||
$table_grands = array();
|
||||
|
||||
foreach ($table_mots as $mot) {
|
||||
$petit = enchiffres_petit($mot);
|
||||
if ($petit !== false) {
|
||||
if ($mantisse != 0) {
|
||||
enchiffres_ajouter_grand($table_grands, $mantisse, $exposant);
|
||||
$mantisse = $exposant = 0;
|
||||
}
|
||||
enchiffres_ajouter_petit($table_petits, $petit);
|
||||
continue;
|
||||
}
|
||||
|
||||
$grand = enchiffres_grand($mot);
|
||||
if ($grand === false) {
|
||||
# Ce n'est pas un nombre
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($grand == 0) {
|
||||
# Ce nombre était trop grand (millinillion et plus) : on annule le
|
||||
# tout pour limiter le temps de calcul.
|
||||
$mantisse = 0;
|
||||
$exposant = 0;
|
||||
$table_petits = array();
|
||||
} else {
|
||||
if (count($table_petits) > 0) {
|
||||
$mantisse = enchiffres_somme_petits($table_petits);
|
||||
$exposant = 0;
|
||||
$table_petits = array();
|
||||
}
|
||||
if ($mantisse != 0) {
|
||||
$exposant += $grand;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (count($table_petits) > 0) {
|
||||
$mantisse = enchiffres_somme_petits($table_petits);
|
||||
$exposant = 0;
|
||||
}
|
||||
if ($mantisse != 0) {
|
||||
enchiffres_ajouter_grand($table_grands, $mantisse, $exposant);
|
||||
}
|
||||
|
||||
$nombre = "";
|
||||
for ($exposant = 0; count($table_grands) > 0; $exposant++) {
|
||||
if (isset($table_grands[$exposant])) {
|
||||
$par3 = $table_grands[$exposant];
|
||||
unset($table_grands[$exposant]);
|
||||
} else {
|
||||
$par3 = 0;
|
||||
}
|
||||
$nombre = sprintf("%03d", $par3) . $nombre;
|
||||
}
|
||||
$nombre = ltrim($nombre, '0');
|
||||
if ($nombre === '') $nombre = '0';
|
||||
return $nombre;
|
||||
}
|
||||
|
||||
function enchiffres_aerer($nombre, $blanc=' ', $virgule=',', $tranche=3)
|
||||
{
|
||||
# Si c'est un nombre à virgule, on traite séparément les deux parties
|
||||
if ($virgule !== NULL) {
|
||||
$ent_dec = preg_split("/$virgule/", $nombre);
|
||||
if (count($ent_dec) >= 2) {
|
||||
$ent = enchiffres_aerer($ent_dec[0], $blanc, NULL, $tranche);
|
||||
$dec = enchiffres_aerer($ent_dec[1], $blanc, NULL, -$tranche);
|
||||
return $ent . $virgule . $dec;
|
||||
}
|
||||
}
|
||||
|
||||
# On ne garde que les chiffres
|
||||
$nombre = preg_replace('/[^0-9]/', '', $nombre);
|
||||
|
||||
# Il est plus logique d'avoir un nombre positif pour les entiers,
|
||||
# donc négatif pour la partie décimale, mais plus pratique de
|
||||
# faire le contraire pour les substr().
|
||||
$tranche = - (int)$tranche;
|
||||
|
||||
if ($tranche == 0) {
|
||||
# on voulait juste supprimer les caractères en trop, pas en rajouter
|
||||
return $nombre;
|
||||
}
|
||||
|
||||
$nombre_aere = '';
|
||||
if ($tranche < 0) {
|
||||
# entier, ou partie entière d'un nombre décimal
|
||||
while ($nombre != '') {
|
||||
$par3 = substr($nombre, $tranche);
|
||||
$nombre = substr($nombre, 0, $tranche);
|
||||
if ($nombre_aere == '') {
|
||||
$nombre_aere = $par3;
|
||||
} else {
|
||||
$nombre_aere = $par3 . $blanc . $nombre_aere;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
# partie décimale
|
||||
while ($nombre != '') {
|
||||
$par3 = substr($nombre, 0, $tranche);
|
||||
$nombre = substr($nombre, $tranche);
|
||||
if ($nombre_aere == '') {
|
||||
$nombre_aere = $par3;
|
||||
} else {
|
||||
$nombre_aere .= $blanc . $par3;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $nombre_aere;
|
||||
}
|
||||
|
||||
*/
|
||||
?>
|
||||
}
|
@ -5,29 +5,29 @@ define ('TODAY', date('Ymd'));
|
||||
/**
|
||||
* Classe de gestion des méthodes relatives à la date et à l'heure
|
||||
*/
|
||||
|
||||
class WDate
|
||||
{
|
||||
class WDate
|
||||
{
|
||||
private static $tabMoisEnLettres = array(
|
||||
1=>'Janvier',
|
||||
2=>'Février',
|
||||
3=>'Mars',
|
||||
4=>'Avril',
|
||||
5=>'Mai',
|
||||
6=>'Juin',
|
||||
7=>'Juillet',
|
||||
8=>'Août',
|
||||
9=>'Septembre',
|
||||
10=>'Octobre',
|
||||
11=>'Novembre',
|
||||
12=>'Décembre'
|
||||
1 => 'Janvier',
|
||||
2 => 'Février',
|
||||
3 => 'Mars',
|
||||
4 => 'Avril',
|
||||
5 => 'Mai',
|
||||
6 => 'Juin',
|
||||
7 => 'Juillet',
|
||||
8 => 'Août',
|
||||
9 => 'Septembre',
|
||||
10 => 'Octobre',
|
||||
11 => 'Novembre',
|
||||
12 => 'Décembre'
|
||||
);
|
||||
|
||||
/** Retourne le numéro du mois donné au format texte (janvier, mars, etc...)
|
||||
* @param string Mois en toute lettres (janvier, mars, etc...)
|
||||
* @return string Mois en Chiffe (1, 3, 12) / false en cas d'erreur
|
||||
*/
|
||||
public function getNumMois($moisEnLettres) {
|
||||
public function getNumMois($moisEnLettres)
|
||||
{
|
||||
foreach (self::$tabMoisEnLettres as $num=>$mois)
|
||||
$tabMoisSansAccents[$num]=strtr($mois, 'ééûÉÉÛ','eeueeu');
|
||||
return array_search(ucfirst(strtolower(strtr($moisEnLettres, 'ééûÉÉÛ','eeuEEU'))), $tabMoisSansAccents);
|
||||
@ -37,7 +37,8 @@ define ('TODAY', date('Ymd'));
|
||||
* @param int $moisEnChiffre
|
||||
* @return string Libellé du mois / false si le mois passé en paramètre est invalide
|
||||
*/
|
||||
public function getLibelleMois($moisEnChiffre) {
|
||||
public function getLibelleMois($moisEnChiffre)
|
||||
{
|
||||
if ($moisEnChiffre>0 && $moisEnChiffre<13)
|
||||
return self::$tabMoisEnLettres[$moisEnChiffre];
|
||||
|
||||
@ -50,7 +51,8 @@ define ('TODAY', date('Ymd'));
|
||||
** @param int $dateFin Date de fin (ultérieur à la date de début) au format Ymd
|
||||
** @return int Nombre de mois
|
||||
**/
|
||||
function nbMoisEntre($dateDeb, $dateFin=TODAY) {
|
||||
function nbMoisEntre($dateDeb, $dateFin=TODAY)
|
||||
{
|
||||
$dDeb=explode('-', Wdate::dateT('Ymd','Y-m-d', $dateDeb));
|
||||
$dFin=explode('-', Wdate::dateT('Ymd','Y-m-d', $dateFin));
|
||||
return ($dFin[0]*12+$dFin[1])-($dDeb[0]*12+$dDeb[1]);
|
||||
@ -63,7 +65,8 @@ define ('TODAY', date('Ymd'));
|
||||
* @param string Date d'entrée
|
||||
* @return string Date formatée
|
||||
*/
|
||||
public function dateT($formatIN, $formatOUT, $date) {
|
||||
public function dateT($formatIN, $formatOUT, $date)
|
||||
{
|
||||
$M='';
|
||||
switch ($formatIN) {
|
||||
case 'd M Y': $tmp=explode(' ', $date); $d=str_replace('1er', '1', $tmp[0]); $m=self::getNumMois($tmp[1]); $Y=$tmp[2]; break;
|
||||
@ -116,7 +119,8 @@ define ('TODAY', date('Ymd'));
|
||||
* @param string $period (ex : cinq mois, six ans, un jour, 3 mois)
|
||||
* @return date
|
||||
*/
|
||||
function period2Days($dateIN, $period, $inThePast=false) {
|
||||
function period2Days($dateIN, $period, $inThePast=false)
|
||||
{
|
||||
$dateV=self::dateT('Ymd', 'Ymd', $dateIN);
|
||||
if ($dateV<>$dateIN) return NULL;
|
||||
$d=substr($dateIN,6,2);
|
||||
@ -145,7 +149,8 @@ define ('TODAY', date('Ymd'));
|
||||
* @param bool $weekend Considérer les WeekEnd comme feriés ? 1=Oui
|
||||
* @return bool
|
||||
**/
|
||||
function jourFerie($date, $weekend=false) {
|
||||
function jourFerie($date, $weekend=false)
|
||||
{
|
||||
$date =str_replace('-','',strtr($date, '/.:','---'));
|
||||
$jour =self::dateT('Ymd', 'd', $date);
|
||||
$mois =self::dateT('Ymd', 'm', $date);
|
||||
|
@ -21,9 +21,9 @@ class WDB
|
||||
if ( $database === null ) {
|
||||
$database = 'jo';
|
||||
}
|
||||
|
||||
|
||||
if ( $host === null ) {
|
||||
$c = Zend_Registry::get('config');
|
||||
$c = Zend_Registry::get('config');
|
||||
$config = new Zend_Config(array(
|
||||
'adapter' => $c->profil->db->metier->adapter,
|
||||
'params' => array(
|
||||
@ -51,13 +51,13 @@ class WDB
|
||||
),
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
$this->db = Zend_Db::factory($config);
|
||||
} catch ( Exception $e ) {
|
||||
file_put_contents('debug.log', $e->getMessage()."\n", FILE_APPEND);
|
||||
exit;
|
||||
file_put_contents(LOG_PATH . '/mysql.log', date('Y-m-d H:i:s') . ' - Erreur : ' . $e->getMessage()."\n", FILE_APPEND);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -69,7 +69,10 @@ class WDB
|
||||
*/
|
||||
public function insert($table, $toAdd, $debug=false, $low_priority=false)
|
||||
{
|
||||
$fields = implode(array_keys($toAdd), '`,`');
|
||||
$this->errorCode = 0;
|
||||
$this->errorMsg = '';
|
||||
|
||||
$fields = implode(array_keys($toAdd), ',');
|
||||
foreach (array_values($toAdd) as $key=>$array_values)
|
||||
$tmp[$key]=checkaddslashes($array_values);
|
||||
|
||||
@ -77,32 +80,32 @@ class WDB
|
||||
$values = str_replace("'NULL'", 'NULL', $values);
|
||||
|
||||
if ($low_priority)
|
||||
$query = 'INSERT DELAYED INTO `'.$table.'` (`'.$fields.'`) VALUES ('.$values.');';
|
||||
$query = 'INSERT DELAYED INTO '.$table.' ('.$fields.') VALUES ('.$values.');';
|
||||
else
|
||||
$query = 'INSERT INTO `'.$table.'` (`'.$fields.'`) VALUES ('.$values.');';
|
||||
$query = 'INSERT INTO '.$table.' ('.$fields.') VALUES ('.$values.');';
|
||||
|
||||
if ($debug) $tdeb=microtime_float();
|
||||
|
||||
try {
|
||||
$stmt = $this->db->query($query, $debug);
|
||||
$stmt = $this->db->query($query);
|
||||
$res = $this->db->lastInsertId();
|
||||
if ($debug) $this->trace($query, $res, $tdeb);
|
||||
if ( $res == 0 ) {
|
||||
$res = true;
|
||||
return true;
|
||||
}
|
||||
return $res;
|
||||
} catch(Zend_Db_Exception $e) {
|
||||
$this->errorCode = $e->getCode();
|
||||
$this->errorMsg = $e->getMessage();
|
||||
|
||||
$res = false;
|
||||
$this->trace($query, $res, $tdeb);
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($debug) $this->trace($query, $res, $tdeb);
|
||||
|
||||
return $res;
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Database Update
|
||||
* @param unknown $table
|
||||
* @param unknown $update
|
||||
* @param unknown $where
|
||||
@ -113,16 +116,19 @@ class WDB
|
||||
*/
|
||||
public function update($table, $update, $where, $debug=false, $limit=0, $low_priority=false)
|
||||
{
|
||||
$fields = array_keys($update);
|
||||
$this->errorCode = 0;
|
||||
$this->errorMsg = '';
|
||||
|
||||
$fields = array_keys($update);
|
||||
$values = array_values($update);
|
||||
$i=0;
|
||||
if ($low_priority)
|
||||
$query='UPDATE LOW_PRIORITY `'.$table.'` SET ';
|
||||
$query='UPDATE LOW_PRIORITY '.$table.' SET ';
|
||||
else
|
||||
$query='UPDATE `'.$table.'` SET ';
|
||||
$query='UPDATE '.$table.' SET ';
|
||||
while(isset($fields[$i])){
|
||||
if($i>0) { $query.=', '; }
|
||||
$query.=' `'.$fields[$i]."`='".checkaddslashes($values[$i])."'";
|
||||
$query.=' '.$fields[$i]."=".$this->db->quote($values[$i]);
|
||||
$i++;
|
||||
}
|
||||
$query = str_replace("'NULL'", 'NULL', $query);
|
||||
@ -132,25 +138,25 @@ class WDB
|
||||
if ($debug) $tdeb=microtime_float();
|
||||
|
||||
try {
|
||||
$stmt = $this->db->query($query, $debug);
|
||||
$stmt = $this->db->query($query);
|
||||
$res = $this->db->lastInsertId();
|
||||
if ($debug) $this->trace($query, $res, $tdeb);
|
||||
if ( $res == 0 ) {
|
||||
$res = true;
|
||||
return true;
|
||||
}
|
||||
return $res;
|
||||
} catch(Zend_Db_Exception $e) {
|
||||
$this->errorCode = $e->getCode();
|
||||
$this->errorMsg = $e->getMessage();
|
||||
|
||||
$res = false;
|
||||
$this->trace($query, $res, $tdeb);
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($debug) $this->trace($query, $res, $tdeb);
|
||||
|
||||
return $res;
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Database delete
|
||||
* @param unknown $table
|
||||
* @param unknown $where
|
||||
* @param string $debug
|
||||
@ -159,6 +165,9 @@ class WDB
|
||||
*/
|
||||
public function delete($table, $where, $debug=false, $low_priority=false)
|
||||
{
|
||||
$this->errorCode = 0;
|
||||
$this->errorMsg = '';
|
||||
|
||||
if ($low_priority)
|
||||
$query='DELETE LOW_PRIORITY QUICK FROM `'.$table.'` WHERE '.$where.' LIMIT 1;';
|
||||
else
|
||||
@ -167,25 +176,25 @@ class WDB
|
||||
if ($debug) $tdeb=microtime_float();
|
||||
|
||||
try {
|
||||
$stmt = $this->db->query($query, $debug);
|
||||
$stmt = $this->db->query($query);
|
||||
$res = $this->db->lastInsertId();
|
||||
if ($debug) $this->trace($query, $res, $tdeb);
|
||||
if ( $res == 0 ) {
|
||||
$res = true;
|
||||
}
|
||||
return $res;
|
||||
} catch(Zend_Db_Exception $e) {
|
||||
$this->errorCode = $e->getCode();
|
||||
$this->errorMsg = $e->getMessage();
|
||||
|
||||
$res = false;
|
||||
$this->trace($query, $res, $tdeb);
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($debug) $this->trace($query, $res, $tdeb);
|
||||
|
||||
return $res;
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Database select
|
||||
* @param string $table
|
||||
* @param string $fields
|
||||
* @param string $where
|
||||
@ -196,6 +205,9 @@ class WDB
|
||||
*/
|
||||
public function select($table, $fields, $where, $debug=false, $assoc=MYSQL_BOTH, $huge=false)
|
||||
{
|
||||
$this->errorCode = 0;
|
||||
$this->errorMsg = '';
|
||||
|
||||
$query="SELECT $fields FROM $table WHERE $where;";
|
||||
|
||||
if ($debug) $tdeb=microtime_float();
|
||||
@ -205,11 +217,7 @@ class WDB
|
||||
} catch(Zend_Db_Exception $e) {
|
||||
$this->errorCode = $e->getCode();
|
||||
$this->errorMsg = $e->getMessage();
|
||||
|
||||
$fpErr = fopen(LOG_PATH.'/sqlerror.log','a');
|
||||
fwrite($fpErr, date('YmdHis'). ' - '.$query .EOL);
|
||||
fwrite($fpErr, date('YmdHis'). ' - '.$e->getCode().' - '. $e->getMessage().PHP_EOL);
|
||||
|
||||
$this->trace($query);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -264,13 +272,12 @@ class WDB
|
||||
*/
|
||||
public function trace($query, $res='', $tdeb = null)
|
||||
{
|
||||
|
||||
if ( $tdeb === null) {
|
||||
$duree = substr(''.microtime_float()-$tdeb, 0, 5);
|
||||
} else {
|
||||
$duree = 'N/D';
|
||||
}
|
||||
file_put_contents(LOG_PATH . '/mysql_debug.log', date('Y/m/d - H:i:s') ." - ".$this->errorCode.":".$this->errorMsg." - $duree - $query\n", FILE_APPEND);
|
||||
file_put_contents(LOG_PATH . '/mysql.log', date('Y-m-d H:i:s') ." - ".$query." - ".$this->errorCode.":".$this->errorMsg." - ".$duree."\n", FILE_APPEND);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -278,17 +285,20 @@ class WDB
|
||||
*/
|
||||
public function query($query, $debug=false)
|
||||
{
|
||||
try {
|
||||
$this->errorCode = 0;
|
||||
$this->errorMsg = '';
|
||||
|
||||
try {
|
||||
$stmt = $this->db->query($query);
|
||||
$this->result = $stmt;
|
||||
} catch(Zend_Db_Exception $e) {
|
||||
$this->errorCode = $e->getCode();
|
||||
$this->errorMsg = $e->getMessage();
|
||||
|
||||
$this->trace($query);
|
||||
return false;
|
||||
}
|
||||
|
||||
return $this->result;
|
||||
return $this->result->fetchAll(Zend_Db::FETCH_ASSOC);
|
||||
}
|
||||
|
||||
/** Retourne le libellé de la dernière erreur **/
|
||||
|
@ -1,7 +1,6 @@
|
||||
<?php
|
||||
|
||||
class WDB {
|
||||
|
||||
class WDB
|
||||
{
|
||||
private $host;
|
||||
private $database;
|
||||
private $user;
|
||||
@ -9,8 +8,8 @@ class WDB {
|
||||
private $con_id; // Connection ID with MySQL
|
||||
private $result;
|
||||
|
||||
public function __construct($database='', $host='', $user='', $password='') {
|
||||
|
||||
public function __construct($database='', $host='', $user='', $password='')
|
||||
{
|
||||
if ($host=='') $this->host=MYSQL_HOST;
|
||||
else $this->host=$host;
|
||||
if ($user=='') $this->user=MYSQL_USER;
|
||||
@ -45,20 +44,19 @@ class WDB {
|
||||
** @param array Valeurs insérer
|
||||
** @return int Dernière valeur de l'auto-incrément, 1 si pas d'auto-incrément et 0 si erreur
|
||||
**/
|
||||
public function insert($table, $toAdd, $debug=false, $low_priority=false){
|
||||
$this->setDB();
|
||||
public function insert($table, $toAdd, $debug=false, $low_priority=false)
|
||||
{
|
||||
$fields = implode(array_keys($toAdd), '`,`');
|
||||
foreach (array_values($toAdd) as $key=>$array_values)
|
||||
$tmp[$key]=checkaddslashes($array_values);
|
||||
|
||||
$values = "'".implode(array_values($tmp), "','")."'"; # better
|
||||
$values = str_replace("'NULL'", 'NULL', $values);
|
||||
|
||||
if ($low_priority)
|
||||
$query = 'INSERT DELAYED INTO `'.$table.'` (`'.$fields.'`) VALUES ('.$values.');';
|
||||
else
|
||||
$query = 'INSERT INTO `'.$table.'` (`'.$fields.'`) VALUES ('.$values.');';
|
||||
|
||||
if ($low_priority)
|
||||
$query = 'INSERT DELAYED INTO `'.$table.'` (`'.$fields.'`) VALUES ('.$values.');';
|
||||
else
|
||||
$query = 'INSERT INTO `'.$table.'` (`'.$fields.'`) VALUES ('.$values.');';
|
||||
|
||||
if ($debug) $tdeb=microtime_float();
|
||||
$res = mysql_query($query, $this->con_id);
|
||||
@ -73,15 +71,15 @@ public function insert($table, $toAdd, $debug=false, $low_priority=false){
|
||||
return $res;
|
||||
}
|
||||
|
||||
public function update($table, $update, $where, $debug=false, $limit=0, $low_priority=false){
|
||||
$this->setDB();
|
||||
public function update($table, $update, $where, $debug=false, $limit=0, $low_priority=false)
|
||||
{
|
||||
$fields = array_keys($update);
|
||||
$values = array_values($update);
|
||||
$i=0;
|
||||
if ($low_priority)
|
||||
$query='UPDATE LOW_PRIORITY `'.$table.'` SET ';
|
||||
else
|
||||
$query='UPDATE `'.$table.'` SET ';
|
||||
if ($low_priority)
|
||||
$query='UPDATE LOW_PRIORITY `'.$table.'` SET ';
|
||||
else
|
||||
$query='UPDATE `'.$table.'` SET ';
|
||||
while(isset($fields[$i])){
|
||||
if($i>0) { $query.=', '; }
|
||||
$query.=' `'.$fields[$i]."`='".checkaddslashes($values[$i])."'";
|
||||
@ -96,12 +94,12 @@ public function update($table, $update, $where, $debug=false, $limit=0, $low_pri
|
||||
return $res;
|
||||
}
|
||||
|
||||
public function delete($table, $where, $debug=false, $low_priority=false) {
|
||||
$this->setDB();
|
||||
if ($low_priority)
|
||||
$query='DELETE LOW_PRIORITY QUICK FROM `'.$table.'` WHERE '.$where.' LIMIT 1;';
|
||||
else
|
||||
$query='DELETE FROM `'.$table.'` WHERE '.$where.' LIMIT 1;';
|
||||
public function delete($table, $where, $debug=false, $low_priority=false)
|
||||
{
|
||||
if ($low_priority)
|
||||
$query='DELETE LOW_PRIORITY QUICK FROM `'.$table.'` WHERE '.$where.' LIMIT 1;';
|
||||
else
|
||||
$query='DELETE FROM `'.$table.'` WHERE '.$where.' LIMIT 1;';
|
||||
if ($debug) $tdeb=microtime_float();
|
||||
$res=mysql_query($query, $this->con_id);
|
||||
if ($debug) $this->trace($query, $res, $tdeb);
|
||||
@ -109,7 +107,6 @@ public function delete($table, $where, $debug=false, $low_priority=false) {
|
||||
}
|
||||
|
||||
public function select($table, $fields, $where, $debug=false, $assoc=MYSQL_BOTH, $huge=false) {
|
||||
$this->setDB();
|
||||
if (mysql_select_db($this->database, $this->con_id) === false) {
|
||||
echo date('Y/m/d - H:i:s') ." - ERREUR ".mysql_errno()." : Connection à la base de données impossible !".EOL;
|
||||
echo date ('Y/m/d - H:i:s'). mysql_error();
|
||||
@ -140,25 +137,25 @@ public function delete($table, $where, $debug=false, $low_priority=false) {
|
||||
}
|
||||
|
||||
public function fetch($assoc=MYSQL_BOTH) {
|
||||
return mysql_fetch_array($this->result, $assoc);
|
||||
return mysql_fetch_array($this->result, $assoc);
|
||||
}
|
||||
|
||||
public function trace($query, $res='', $tdeb=-1) {
|
||||
if (!$fp=fopen(LOG_PATH.'/mysql_insert.log', 'a'))
|
||||
return false;
|
||||
$errnum=mysql_errno($this->con_id);
|
||||
if ($tdeb>-1) $duree=substr(''.microtime_float()-$tdeb, 0, 5);
|
||||
else $duree='N/D';
|
||||
if (!fwrite($fp, date('Y/m/d - H:i:s') ." - $errnum - $res - $duree - $query\n"))
|
||||
return false;
|
||||
if (!fclose($fp))
|
||||
return false;
|
||||
return true;
|
||||
if (!$fp=fopen(LOG_PATH.'/mysql_insert.log', 'a'))
|
||||
return false;
|
||||
$errnum=mysql_errno($this->con_id);
|
||||
if ($tdeb>-1) $duree=substr(''.microtime_float()-$tdeb, 0, 5);
|
||||
else $duree='N/D';
|
||||
if (!fwrite($fp, date('Y/m/d - H:i:s') ." - $errnum - $res - $duree - $query\n"))
|
||||
return false;
|
||||
if (!fclose($fp))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
/** Exécute la requête passé en paramètre **/
|
||||
public function query($query, $debug=false){
|
||||
$this->setDB();
|
||||
public function query($query, $debug=false)
|
||||
{
|
||||
$this->result=mysql_query($query, $this->con_id);
|
||||
return $this->result;
|
||||
}
|
||||
@ -173,17 +170,20 @@ public function delete($table, $where, $debug=false, $low_priority=false) {
|
||||
return mysql_error($this->con_id);
|
||||
}
|
||||
/** Retourne le numéro de la dernière erreur **/
|
||||
public function getLastErrorNum() {
|
||||
public function getLastErrorNum()
|
||||
{
|
||||
return mysql_errno($this->con_id);
|
||||
}
|
||||
|
||||
/** Retourne le libellé et le numéro de la dernière erreur **/
|
||||
public function getLastError() {
|
||||
public function getLastError()
|
||||
{
|
||||
return mysql_error($this->con_id).' ('.mysql_errno($this->con_id).')';
|
||||
}
|
||||
|
||||
/** Retourne le nombre de lignes modifiées par la dernière requête **/
|
||||
public function getAffectedRows() {
|
||||
public function getAffectedRows()
|
||||
{
|
||||
return mysql_affected_rows($this->con_id);
|
||||
}
|
||||
|
||||
|
@ -1,52 +1,78 @@
|
||||
<?php
|
||||
class WDB
|
||||
{
|
||||
private $host;
|
||||
private $database;
|
||||
private $user;
|
||||
private $password;
|
||||
private $con_id; // Connection ID with MySQL
|
||||
private $result;
|
||||
/**
|
||||
* @var Zend_Db_Adapter_Abstract
|
||||
*/
|
||||
protected $db = null;
|
||||
|
||||
public function __construct($database='', $host='', $user='', $password='')
|
||||
/**
|
||||
*
|
||||
* @var unknown
|
||||
*/
|
||||
protected $result = null;
|
||||
|
||||
protected $errorCode = 0;
|
||||
|
||||
protected $errorMsg = '';
|
||||
|
||||
public function __construct( $database = null, $host = null, $user = null, $password = null )
|
||||
{
|
||||
if ($host=='') $this->host=MYSQL_HOST;
|
||||
else $this->host=$host;
|
||||
if ($user=='') $this->user=MYSQL_USER;
|
||||
else $this->user=$user;
|
||||
if ($password=='') $this->password=MYSQL_PASS;
|
||||
else $this->password=$password;
|
||||
if ($database=='') $this->database=MYSQL_DEFAULT_DB;
|
||||
else $this->database=$database;
|
||||
if ( $database === null ) {
|
||||
$database = 'jo';
|
||||
}
|
||||
|
||||
if ( $host === null ) {
|
||||
$c = Zend_Registry::get('config');
|
||||
$config = new Zend_Config(array(
|
||||
'adapter' => $c->profil->db->metier->adapter,
|
||||
'params' => array(
|
||||
'host' => $c->profil->db->metier->params->host,
|
||||
'username'=> $c->profil->db->metier->params->username,
|
||||
'password'=> $c->profil->db->metier->params->password,
|
||||
'dbname'=> $database,
|
||||
'driver_options' => array(
|
||||
MYSQLI_INIT_COMMAND => "SET NAMES utf8",
|
||||
),
|
||||
),
|
||||
));
|
||||
|
||||
} else {
|
||||
$config = new Zend_Config(array(
|
||||
'adapter' => 'mysqli',
|
||||
'params' => array(
|
||||
'host' => $host,
|
||||
'username'=> $user,
|
||||
'password'=> $password,
|
||||
'dbname'=> $database,
|
||||
'driver_options' => array(
|
||||
MYSQLI_INIT_COMMAND => "SET NAMES utf8",
|
||||
),
|
||||
),
|
||||
));
|
||||
}
|
||||
|
||||
try {
|
||||
$this->db = Zend_Db::factory($config);
|
||||
} catch ( Exception $e ) {
|
||||
file_put_contents(LOG_PATH . '/mysql.log', date('Y-m-d H:i:s') . ' - Erreur : ' . $e->getMessage()."\n", FILE_APPEND);
|
||||
}
|
||||
|
||||
$this->con_id = mysql_pconnect($this->host, $this->user, $this->password);
|
||||
if (!($this->con_id === false)) {
|
||||
if (mysql_select_db($this->database, $this->con_id) === false) {
|
||||
echo date('Y/m/d - H:i:s') ." - ERREUR ".mysql_errno()." : Connection à la base de données impossible !".EOL;
|
||||
echo date ('Y/m/d - H:i:s'). mysql_error();
|
||||
die();
|
||||
}
|
||||
}
|
||||
return mysql_query("SET NAMES 'utf8';", $this->con_id);
|
||||
}
|
||||
|
||||
public function setCharSet($charSet) {
|
||||
return (mysql_query("SET CHARACTER SET $charSet;", $this->con_id));
|
||||
}
|
||||
|
||||
private function setDB() {
|
||||
return (mysql_query("USE $this->database;", $this->con_id));
|
||||
}
|
||||
|
||||
/** INSERTION d'un tableau dans une table.
|
||||
** Les index doivent avoir les mêmes noms que les champs.
|
||||
** @param string Table
|
||||
** @param array Valeurs insérer
|
||||
** @return int Dernière valeur de l'auto-incrément, 1 si pas d'auto-incrément et 0 si erreur
|
||||
**/
|
||||
/**
|
||||
* INSERTION d'un tableau dans une table.
|
||||
* Les index doivent avoir les mêmes noms que les champs.
|
||||
* @param string Table
|
||||
* @param array Valeurs insérer
|
||||
* @return int Dernière valeur de l'auto-incrément, 1 si pas d'auto-incrément et 0 si erreur
|
||||
*/
|
||||
public function insert($table, $toAdd, $debug=false, $low_priority=false)
|
||||
{
|
||||
$fields = implode(array_keys($toAdd), '`,`');
|
||||
$this->errorCode = 0;
|
||||
$this->errorMsg = '';
|
||||
|
||||
$fields = implode(array_keys($toAdd), ',');
|
||||
foreach (array_values($toAdd) as $key=>$array_values)
|
||||
$tmp[$key]=checkaddslashes($array_values);
|
||||
|
||||
@ -54,175 +80,292 @@ class WDB
|
||||
$values = str_replace("'NULL'", 'NULL', $values);
|
||||
|
||||
if ($low_priority)
|
||||
$query = 'INSERT DELAYED INTO `'.$table.'` (`'.$fields.'`) VALUES ('.$values.');';
|
||||
$query = 'INSERT DELAYED INTO '.$table.' ('.$fields.') VALUES ('.$values.');';
|
||||
else
|
||||
$query = 'INSERT INTO `'.$table.'` (`'.$fields.'`) VALUES ('.$values.');';
|
||||
$query = 'INSERT INTO '.$table.' ('.$fields.') VALUES ('.$values.');';
|
||||
|
||||
if ($debug) $tdeb=microtime_float();
|
||||
$res = mysql_query($query, $this->con_id);
|
||||
if ($res!==false)
|
||||
{
|
||||
if (mysql_insert_id()>0)
|
||||
$res=mysql_insert_id();
|
||||
else
|
||||
$res=true;
|
||||
}
|
||||
if ($debug) $this->trace($query, $res, $tdeb);
|
||||
return $res;
|
||||
|
||||
try {
|
||||
$stmt = $this->db->query($query);
|
||||
$res = $this->db->lastInsertId();
|
||||
if ($debug) $this->trace($query, $res, $tdeb);
|
||||
if ( $res == 0 ) {
|
||||
return true;
|
||||
}
|
||||
return $res;
|
||||
} catch(Zend_Db_Exception $e) {
|
||||
$this->errorCode = $e->getCode();
|
||||
$this->errorMsg = $e->getMessage();
|
||||
$this->trace($query, $res, $tdeb);
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Database Update
|
||||
* @param unknown $table
|
||||
* @param unknown $update
|
||||
* @param unknown $where
|
||||
* @param string $debug
|
||||
* @param number $limit
|
||||
* @param string $low_priority
|
||||
* @return resource
|
||||
*/
|
||||
public function update($table, $update, $where, $debug=false, $limit=0, $low_priority=false)
|
||||
{
|
||||
$fields = array_keys($update);
|
||||
$this->errorCode = 0;
|
||||
$this->errorMsg = '';
|
||||
|
||||
$fields = array_keys($update);
|
||||
$values = array_values($update);
|
||||
$i=0;
|
||||
if ($low_priority)
|
||||
$query='UPDATE LOW_PRIORITY `'.$table.'` SET ';
|
||||
$query='UPDATE LOW_PRIORITY '.$table.' SET ';
|
||||
else
|
||||
$query='UPDATE `'.$table.'` SET ';
|
||||
$query='UPDATE '.$table.' SET ';
|
||||
while(isset($fields[$i])){
|
||||
if($i>0) { $query.=', '; }
|
||||
$query.=' `'.$fields[$i]."`='".checkaddslashes($values[$i])."'";
|
||||
$query.=' '.$fields[$i]."=".$this->db->quote($values[$i]);
|
||||
$i++;
|
||||
}
|
||||
$query = str_replace("'NULL'", 'NULL', $query);
|
||||
$query.=' WHERE '.$where;
|
||||
if ($limit>0) $query.=" LIMIT $limit";
|
||||
|
||||
if ($debug) $tdeb=microtime_float();
|
||||
$res=mysql_query($query, $this->con_id);
|
||||
if ($debug) $this->trace($query, $res, $tdeb);
|
||||
return $res;
|
||||
|
||||
try {
|
||||
$stmt = $this->db->query($query);
|
||||
$res = $this->db->lastInsertId();
|
||||
if ($debug) $this->trace($query, $res, $tdeb);
|
||||
if ( $res == 0 ) {
|
||||
return true;
|
||||
}
|
||||
return $res;
|
||||
} catch(Zend_Db_Exception $e) {
|
||||
$this->errorCode = $e->getCode();
|
||||
$this->errorMsg = $e->getMessage();
|
||||
$this->trace($query, $res, $tdeb);
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Database delete
|
||||
* @param unknown $table
|
||||
* @param unknown $where
|
||||
* @param string $debug
|
||||
* @param string $low_priority
|
||||
* @return resource
|
||||
*/
|
||||
public function delete($table, $where, $debug=false, $low_priority=false)
|
||||
{
|
||||
$this->errorCode = 0;
|
||||
$this->errorMsg = '';
|
||||
|
||||
if ($low_priority)
|
||||
$query='DELETE LOW_PRIORITY QUICK FROM `'.$table.'` WHERE '.$where.' LIMIT 1;';
|
||||
else
|
||||
$query='DELETE FROM `'.$table.'` WHERE '.$where.' LIMIT 1;';
|
||||
if ($debug) $tdeb=microtime_float();
|
||||
$res=mysql_query($query, $this->con_id);
|
||||
if ($debug) $this->trace($query, $res, $tdeb);
|
||||
return $res;
|
||||
|
||||
if ($debug) $tdeb=microtime_float();
|
||||
|
||||
try {
|
||||
$stmt = $this->db->query($query);
|
||||
$res = $this->db->lastInsertId();
|
||||
if ($debug) $this->trace($query, $res, $tdeb);
|
||||
if ( $res == 0 ) {
|
||||
$res = true;
|
||||
}
|
||||
return $res;
|
||||
} catch(Zend_Db_Exception $e) {
|
||||
$this->errorCode = $e->getCode();
|
||||
$this->errorMsg = $e->getMessage();
|
||||
$this->trace($query, $res, $tdeb);
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public function select($table, $fields, $where, $debug=false, $assoc=MYSQL_BOTH, $huge=false) {
|
||||
if (mysql_select_db($this->database, $this->con_id) === false) {
|
||||
echo date('Y/m/d - H:i:s') ." - ERREUR ".mysql_errno()." : Connection à la base de données impossible !".EOL;
|
||||
echo date ('Y/m/d - H:i:s'). mysql_error();
|
||||
die();
|
||||
}
|
||||
/**
|
||||
* Database select
|
||||
* @param string $table
|
||||
* @param string $fields
|
||||
* @param string $where
|
||||
* @param string $debug
|
||||
* @param string $assoc
|
||||
* @param string $huge
|
||||
* @return boolean|multitype:multitype: |number
|
||||
*/
|
||||
public function select($table, $fields, $where, $debug=false, $assoc=MYSQL_BOTH, $huge=false)
|
||||
{
|
||||
$this->errorCode = 0;
|
||||
$this->errorMsg = '';
|
||||
|
||||
$query="SELECT $fields FROM $table WHERE $where;";
|
||||
|
||||
if ($debug) $tdeb=microtime_float();
|
||||
$this->result=mysql_query($query, $this->con_id);// or die(mysql_error());
|
||||
if (mysql_errno()) {
|
||||
$fpErr=fopen(LOG_PATH.'/sqlerror.log','a');
|
||||
fwrite($fpErr, date('YmdHis'). ' - '.$query .EOL);
|
||||
fwrite($fpErr, date('YmdHis'). ' - '.mysql_errno() .' - '. mysql_error().EOL);
|
||||
return false;
|
||||
}
|
||||
// echo ;
|
||||
if (!$huge) {
|
||||
$tab=array();
|
||||
while ($ligne = mysql_fetch_array($this->result, $assoc))
|
||||
$tab[]=$ligne;
|
||||
|
||||
if ($debug) $this->trace($query, sizeof($tab), $tdeb);
|
||||
return $tab;
|
||||
try {
|
||||
$stmt = $this->db->query($query);
|
||||
} catch(Zend_Db_Exception $e) {
|
||||
$this->errorCode = $e->getCode();
|
||||
$this->errorMsg = $e->getMessage();
|
||||
$this->trace($query);
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( !$huge ) {
|
||||
switch($assoc) {
|
||||
case MYSQL_NUM:
|
||||
$mode = Zend_Db::FETCH_NUM;
|
||||
break;
|
||||
case MYSQL_ASSOC:
|
||||
$mode = Zend_Db::FETCH_ASSOC;
|
||||
break;
|
||||
case MYSQL_BOTH:
|
||||
$mode = Zend_Db::FETCH_BOTH;
|
||||
break;
|
||||
}
|
||||
$tab = $stmt->fetchAll($mode);
|
||||
if ($debug) $this->trace($query, sizeof($tab), $tdeb);
|
||||
return $tab;
|
||||
} else {
|
||||
$nbRows=mysql_num_rows($this->result);
|
||||
if ($debug) $this->trace($query, $nbRows, $tdeb);
|
||||
return $nbRows;
|
||||
$nbRows = $stmt->rowCount();
|
||||
if ($debug) $this->trace($query, $nbRows, $tdeb);
|
||||
return $nbRows;
|
||||
}
|
||||
}
|
||||
|
||||
public function fetch($assoc=MYSQL_BOTH) {
|
||||
return mysql_fetch_array($this->result, $assoc);
|
||||
/**
|
||||
*
|
||||
* @param string $assoc
|
||||
* @return multitype:
|
||||
*/
|
||||
public function fetch($assoc=MYSQL_BOTH)
|
||||
{
|
||||
switch($assoc) {
|
||||
case MYSQL_NUM:
|
||||
$mode = Zend_Db::FETCH_NUM;
|
||||
break;
|
||||
case MYSQL_ASSOC:
|
||||
$mode = Zend_Db::FETCH_ASSOC;
|
||||
break;
|
||||
case MYSQL_BOTH:
|
||||
$mode = Zend_Db::FETCH_BOTH;
|
||||
break;
|
||||
}
|
||||
return $this->result->fetch($mode);
|
||||
}
|
||||
|
||||
public function trace($query, $res='', $tdeb=-1) {
|
||||
if (!$fp=fopen(LOG_PATH.'/mysql_insert.log', 'a'))
|
||||
return false;
|
||||
$errnum=mysql_errno($this->con_id);
|
||||
if ($tdeb>-1) $duree=substr(''.microtime_float()-$tdeb, 0, 5);
|
||||
else $duree='N/D';
|
||||
if (!fwrite($fp, date('Y/m/d - H:i:s') ." - $errnum - $res - $duree - $query\n"))
|
||||
return false;
|
||||
if (!fclose($fp))
|
||||
return false;
|
||||
return true;
|
||||
/**
|
||||
* Trace
|
||||
* @param string $query
|
||||
* @param string $error
|
||||
* @param int $tdeb
|
||||
*/
|
||||
public function trace($query, $res='', $tdeb = null)
|
||||
{
|
||||
if ( $tdeb === null) {
|
||||
$duree = substr(''.microtime_float()-$tdeb, 0, 5);
|
||||
} else {
|
||||
$duree = 'N/D';
|
||||
}
|
||||
file_put_contents(LOG_PATH . '/mysql.log', date('Y-m-d H:i:s') ." - ".$query." - ".$this->errorCode.":".$this->errorMsg." - ".$duree."\n", FILE_APPEND);
|
||||
}
|
||||
|
||||
/** Exécute la requête passé en paramètre **/
|
||||
/**
|
||||
* Exécute la requête passé en paramètre
|
||||
*/
|
||||
public function query($query, $debug=false)
|
||||
{
|
||||
$this->result=mysql_query($query, $this->con_id);
|
||||
return $this->result;
|
||||
$this->errorCode = 0;
|
||||
$this->errorMsg = '';
|
||||
|
||||
try {
|
||||
$stmt = $this->db->query($query);
|
||||
$this->result = $stmt;
|
||||
} catch(Zend_Db_Exception $e) {
|
||||
$this->errorCode = $e->getCode();
|
||||
$this->errorMsg = $e->getMessage();
|
||||
$this->trace($query);
|
||||
return false;
|
||||
}
|
||||
|
||||
return $this->result->fetchAll(Zend_Db::FETCH_ASSOC);
|
||||
}
|
||||
|
||||
/** Retourne le nombre de records de la dernière requête de sélection **
|
||||
public function getNumRows() {
|
||||
return mysql_num_rows($this->con_id);
|
||||
}
|
||||
*/
|
||||
/** Retourne le libellé de la dernière erreur **/
|
||||
public function getLastErrorMsg() {
|
||||
return mysql_error($this->con_id);
|
||||
public function getLastErrorMsg()
|
||||
{
|
||||
return $this->errorMsg;
|
||||
}
|
||||
/** Retourne le numéro de la dernière erreur **/
|
||||
/**
|
||||
* Retourne le numéro de la dernière erreur
|
||||
*/
|
||||
public function getLastErrorNum()
|
||||
{
|
||||
return mysql_errno($this->con_id);
|
||||
return $this->errorCode;
|
||||
}
|
||||
|
||||
/** Retourne le libellé et le numéro de la dernière erreur **/
|
||||
public function getLastError()
|
||||
{
|
||||
return mysql_error($this->con_id).' ('.mysql_errno($this->con_id).')';
|
||||
return $this->errorMsg.' ('.$this->errorCode.')';
|
||||
}
|
||||
|
||||
/** Retourne le nombre de lignes modifiées par la dernière requête **/
|
||||
public function getAffectedRows()
|
||||
{
|
||||
return mysql_affected_rows($this->con_id);
|
||||
return $this->result->rowCount();
|
||||
}
|
||||
|
||||
/** Génère le fichier CSV pour la requete SQL
|
||||
**
|
||||
** @param string $query
|
||||
** @param string $fileCsv
|
||||
** @return bool
|
||||
/**
|
||||
* Génère le fichier CSV pour la requete SQL
|
||||
*
|
||||
* @param string $query
|
||||
* @param string $fileCsv
|
||||
* @return bool
|
||||
*/
|
||||
public function exportCSV($query, $fileCsv, $sep=',', $eol=EOL) {
|
||||
$i=$c=0;
|
||||
public function exportCSV($query, $fileCsv, $sep=',', $eol=EOL)
|
||||
{
|
||||
$i = 0;
|
||||
$fp = fopen($fileCsv, 'w');
|
||||
if (!$fp) return false;
|
||||
|
||||
$res=$this->query($query);
|
||||
$nbLignes=mysql_num_rows($res);
|
||||
|
||||
$res = $this->query($query);
|
||||
$nbLignes = mysql_num_rows($res);
|
||||
while ($ligne=$this->fetch(MYSQL_ASSOC)) {
|
||||
if ($i==0) {
|
||||
$nbCols=count($ligne);
|
||||
//Header
|
||||
if ($i==0) {
|
||||
$nbCols = count($ligne);
|
||||
$fields = array();
|
||||
$header = array();
|
||||
foreach ($ligne as $libCol=>$col) {
|
||||
$c++;
|
||||
if ($c<$nbCols) fwrite($fp, str_replace($sep,' ', $libCol).$sep);
|
||||
else fwrite($fp, str_replace($sep,' ', $libCol));
|
||||
$header[] = $libCol;
|
||||
$fields[] = $col;
|
||||
}
|
||||
fwrite($fp, $eol);
|
||||
fputcsv($fp, $header, $sep, '"');
|
||||
fputcsv($fp, $fields, $sep, '"');
|
||||
}
|
||||
$c=0;
|
||||
foreach ($ligne as $libCol=>$col) {
|
||||
$c++;
|
||||
if ($c<$nbCols) fwrite($fp, str_replace($sep,' ', $col).$sep);
|
||||
else fwrite($fp, str_replace($sep,' ', $col));
|
||||
//Content
|
||||
else {
|
||||
$fields = array();
|
||||
foreach ($ligne as $libCol=>$col) {
|
||||
$fields[] = $col;
|
||||
}
|
||||
fputcsv($fp, $fields, $sep, '"');
|
||||
}
|
||||
fwrite($fp, $eol);
|
||||
$i++;
|
||||
}
|
||||
fclose($fp);
|
||||
return $nbLignes;//$this->getAffectedRows();
|
||||
}
|
||||
|
||||
return $nbLignes;
|
||||
}
|
||||
}
|
||||
?>
|
@ -271,8 +271,8 @@ class csoundex2 {
|
||||
'KN' => 'NN',
|
||||
'PF' => 'FF',
|
||||
'PH' => 'FF',
|
||||
'SCH' => 'SSS'
|
||||
);
|
||||
'SCH' => 'SSS'
|
||||
);
|
||||
|
||||
/**
|
||||
* endings replacement array
|
||||
@ -282,7 +282,7 @@ class csoundex2 {
|
||||
'T',
|
||||
'D',
|
||||
'S'
|
||||
);
|
||||
);
|
||||
|
||||
/**
|
||||
* public function build
|
||||
|
@ -135,8 +135,6 @@
|
||||
$str = utf8_decode($str);
|
||||
$str = strtr($str,$tabReplace);
|
||||
return utf8_encode($str);
|
||||
//require_once 'i18n/cleanchar.php';
|
||||
//return fixEncoding($str);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,92 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* @file
|
||||
* Miscellaneous functions to clean string.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Clean up a string value.
|
||||
*
|
||||
* Resulting string contains only alphanumerics and separators.
|
||||
*
|
||||
* @param $string
|
||||
* A string to clean.
|
||||
* @param $clean_slash
|
||||
* Whether to clean slashes from the given string.
|
||||
* @return
|
||||
* The cleaned string.
|
||||
*/
|
||||
function cleanstring($string) {
|
||||
$transliterate = TRUE;
|
||||
$reduce_ascii = FALSE;
|
||||
$output = $string;
|
||||
|
||||
// Remove accents and transliterate
|
||||
if ($transliterate) {
|
||||
static $i18n_loaded = false;
|
||||
static $translations = array();
|
||||
if (!$i18n_loaded) {
|
||||
$path = realpath(dirname(__FILE__));
|
||||
if (is_file($path .'/i18n-ascii.txt')) {
|
||||
$translations = parse_ini_file($path .'/i18n-ascii.txt');
|
||||
}
|
||||
$i18n_loaded = true;
|
||||
}
|
||||
|
||||
$output = strtr($output, $translations);
|
||||
}
|
||||
|
||||
// Reduce to the subset of ASCII96 letters and numbers
|
||||
if ($reduce_ascii) {
|
||||
$pattern = '/[^a-zA-Z0-9\/]+/ ';
|
||||
$output = preg_replace($pattern, $separator, $output);
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
|
||||
function cleanutf8($string) {
|
||||
$transliterate = TRUE;
|
||||
$output = $string;
|
||||
|
||||
// Remove accents and transliterate
|
||||
if ($transliterate) {
|
||||
static $i18n_loaded = false;
|
||||
static $translations = array();
|
||||
if (!$i18n_loaded) {
|
||||
$path = realpath(dirname(__FILE__));
|
||||
if (is_file($path .'/i18n-ascii.txt')) {
|
||||
$translations = parse_ini_file($path .'/i18n-ascii.txt');
|
||||
}
|
||||
$i18n_loaded = true;
|
||||
}
|
||||
|
||||
$output = strtr($output, $translations);
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
|
||||
// Fixes the encoding to uf8
|
||||
function fixEncoding($in_str)
|
||||
{
|
||||
$cur_encoding = mb_detect_encoding($in_str) ;
|
||||
if($cur_encoding == "UTF-8" && mb_check_encoding($in_str,"UTF-8"))
|
||||
return $in_str;
|
||||
else
|
||||
return utf8_encode($in_str);
|
||||
} // fixEncoding
|
||||
|
||||
|
||||
function cleanstring_deep($value)
|
||||
{
|
||||
$value = is_array($value) ?
|
||||
array_map('cleanstring_deep', $value) :
|
||||
cleanstring($value);
|
||||
return $value;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
?>
|
@ -92,8 +92,6 @@ if ($opts->bilan) {
|
||||
|
||||
if ($opts->files) {
|
||||
|
||||
require_once 'Metier/Infogreffe/InfogreffeBi.php';
|
||||
|
||||
$nbBilans = 0;
|
||||
|
||||
//Type de bilan
|
||||
@ -149,7 +147,7 @@ if ($opts->bilan) {
|
||||
|
||||
if ($item === null) {
|
||||
//If not find write the database
|
||||
$infogreffe = new Metier_Infogreffe_Bi($siren);
|
||||
$infogreffe = new SdMetier_Infogreffe_DocBI($siren);
|
||||
$infogreffe->getList();
|
||||
//And get again the item in database
|
||||
$item = $bilanM->fetchRow($sql);
|
||||
@ -160,7 +158,7 @@ if ($opts->bilan) {
|
||||
} else {
|
||||
if ($item->pdfDate == '0000-00-00') {
|
||||
|
||||
$infogreffe = new Metier_Infogreffe_Bi($siren);
|
||||
$infogreffe = new SdMetier_Infogreffe_DocBI($siren);
|
||||
$infos = $infogreffe->pdfInfos($pathFile. DIRECTORY_SEPARATOR . $file);
|
||||
|
||||
if (false !== $infos) {
|
||||
@ -203,8 +201,6 @@ if ($opts->bilan) {
|
||||
*/
|
||||
elseif ($opts->numdepot) {
|
||||
|
||||
require_once 'Metier/Infogreffe/InfogreffeBi.php';
|
||||
|
||||
echo $opts->numdepot."\n";
|
||||
|
||||
if( !is_dir($opts->numdepot) ) {
|
||||
@ -232,7 +228,7 @@ if ($opts->bilan) {
|
||||
|
||||
if ($item === null) {
|
||||
//If not find write the database
|
||||
$infogreffe = new Metier_Infogreffe_Bi($siren);
|
||||
$infogreffe = new SdMetier_Infogreffe_DocBI($siren);
|
||||
$infogreffe->getList();
|
||||
//And get again the item in database
|
||||
$item = $bilanM->fetchRow($sql);
|
||||
@ -243,7 +239,7 @@ if ($opts->bilan) {
|
||||
} else {
|
||||
if ($item->pdfDate == '0000-00-00') {
|
||||
|
||||
$infogreffe = new Metier_Infogreffe_Bi($siren);
|
||||
$infogreffe = new SdMetier_Infogreffe_DocBI($siren);
|
||||
|
||||
$type = "sociaux";
|
||||
if ( !empty($item->type_comptes) ) {
|
||||
@ -333,7 +329,6 @@ if ($opts->bilan) {
|
||||
echo "Nb Lignes à traiter : ".$NbLignes.PHP_EOL;
|
||||
|
||||
if ( $NbLignes > 0 ) {
|
||||
require_once 'Metier/Infogreffe/InfogreffeBi.php';
|
||||
$cpt = 1;
|
||||
foreach ( $result as $item ) {
|
||||
$siren = str_pad($item->siren, 9, '0', STR_PAD_LEFT);
|
||||
@ -341,7 +336,7 @@ if ($opts->bilan) {
|
||||
echo "Ligne ".$cpt."/".$NbLignes." - siren = ".$siren." , millesime = ".$item->millesime;
|
||||
|
||||
//Lire les informations du fichier
|
||||
$infogreffe = new Metier_Infogreffe_Bi($siren);
|
||||
$infogreffe = new SdMetier_Infogreffe_DocBI($siren);
|
||||
$type = 'sociaux';
|
||||
if ( !empty($item->type_comptes) ) {
|
||||
$type = $item->type_comptes;
|
||||
@ -386,8 +381,6 @@ if ($opts->acte) {
|
||||
|
||||
if ($opts->files) {
|
||||
|
||||
require_once 'Metier/Infogreffe/InfogreffeAc.php';
|
||||
|
||||
$path = $c->profil->infogreffe->storage->path . DIRECTORY_SEPARATOR . 'actes';
|
||||
$months = array('01','02','03','04','05','06','07','08','09','10','11','12');
|
||||
|
||||
@ -470,7 +463,7 @@ if ($opts->acte) {
|
||||
|
||||
if (count($items)==0) {
|
||||
//If not find write the database
|
||||
$infogreffe = new Metier_Infogreffe_Ac($siren);
|
||||
$infogreffe = new SdMetier_Infogreffe_DocBI($siren);
|
||||
$infogreffe->getList();
|
||||
//And get again the item in database
|
||||
$items = $acteM->fetchAll($sql);
|
||||
@ -482,7 +475,7 @@ if ($opts->acte) {
|
||||
foreach($items as $item) {
|
||||
if ($item->pdfDate == '0000-00-00') {
|
||||
|
||||
$infogreffe = new Metier_Infogreffe_Ac($siren);
|
||||
$infogreffe = new SdMetier_Infogreffe_DocBI($siren);
|
||||
$infos = $infogreffe->pdfInfos($pathFile. DIRECTORY_SEPARATOR . $file);
|
||||
|
||||
if (false !== $infos) {
|
||||
@ -562,7 +555,7 @@ if ($opts->acte) {
|
||||
$num = $item->num_acte;
|
||||
$type = $item->type_acte;
|
||||
|
||||
$infogreffe = new Metier_Infogreffe_Ac($siren);
|
||||
$infogreffe = new SdMetier_Infogreffe_DocAC($siren);
|
||||
|
||||
$options = $item->numGreffe . '-' . substr($item->numRC,0,2) . '-' . substr($item->numRC,2,1) . '-' . substr($item->numRC,3) . '-' . $item->num_depot;
|
||||
$file = $infogreffe->getFileName($date, $num, $type, $options);
|
||||
|
@ -143,7 +143,7 @@ function sendMail($commande, $type){
|
||||
$message.= "\n";
|
||||
$message.= "1, rue de Clairefontaine - 78120 RAMBOUILLET";
|
||||
$message.= "\n";
|
||||
$message.= "tél : 33 (0)1 75 43 80 10";
|
||||
$message.= "tél : 0 811 261 216";
|
||||
$message.= "\n";
|
||||
$message.= "fax : 33 (0)1 75 43 85 74";
|
||||
$message.= "\n";
|
||||
@ -391,10 +391,11 @@ foreach ( $tabCommandes as $ref => $commande ) {
|
||||
|
||||
case 'BI':
|
||||
|
||||
require_once 'Metier/Infogreffe/InfogreffeBi.php';
|
||||
$infogreffe = new Metier_Infogreffe_Bi($commande->siren);
|
||||
$infogreffe = new SdMetier_Infogreffe_DocBI($commande->siren);
|
||||
//Format date cloture
|
||||
$dateCloture = substr($commande->bilanCloture,0,4) . substr($commande->bilanCloture,5,2) . substr($commande->bilanCloture,8,2);
|
||||
$dateCloture = substr($commande->bilanCloture,0,4) . '-' .
|
||||
substr($commande->bilanCloture,5,2) . '-' .
|
||||
substr($commande->bilanCloture,8,2);
|
||||
$path = $infogreffe->getFilePath($commande->bilanType, $dateCloture);
|
||||
$nomCible = $infogreffe->getFileName($commande->bilanType, $dateCloture);
|
||||
|
||||
@ -414,34 +415,35 @@ foreach ( $tabCommandes as $ref => $commande ) {
|
||||
}
|
||||
}
|
||||
|
||||
// --- Lecture présence référence bilan
|
||||
$bilanM = new Application_Model_JoGreffesBilans();
|
||||
$sql = $bilanM->select()
|
||||
->where('siren=?',$commande->siren)
|
||||
->where('date_cloture=?', $dateCloture);
|
||||
if ($commande->bilanType=='sociaux') {
|
||||
$sql->where('type_comptes="" OR type_comptes="sociaux"');
|
||||
} else {
|
||||
$sql->where('type_comptes="consolides"');
|
||||
}
|
||||
$item = $bilanM->fetchRow($sql);
|
||||
|
||||
// --- Enregistrement
|
||||
if ( $isFileOnStorage && $item->pdfDate == '0000-00-00' ) {
|
||||
$bilanM = new Application_Model_JoGreffesBilans();
|
||||
$sql = $bilanM->select()
|
||||
->where('siren=?',$commande->siren)
|
||||
->where('date_cloture=?', $dateCloture);
|
||||
if ($commande->bilanType=='sociaux') {
|
||||
$sql->where('type_comptes="" OR type_comptes="sociaux"');
|
||||
} else {
|
||||
$sql->where('type_comptes="consolides"');
|
||||
}
|
||||
$item = $bilanM->fetchRow($sql);
|
||||
if ($item->pdfDate == '0000-00-00') {
|
||||
$infos = $infogreffe->pdfInfos($fileOut);
|
||||
if (false !== $infos) {
|
||||
$data = array(
|
||||
'pdfLink' => $nomCible,
|
||||
'pdfSize' => $infos['size'],
|
||||
$infos = $infogreffe->pdfInfos($fileOut);
|
||||
if (false !== $infos) {
|
||||
$data = array(
|
||||
'pdfLink' => $nomCible,
|
||||
'pdfSize' => $infos['size'],
|
||||
'pdfPage' => $infos['pages'],
|
||||
'pdfVer' => $infos['version'],
|
||||
'pdfDate' => date('Ymd'),
|
||||
);
|
||||
try {
|
||||
$result = $bilanM->update($data, 'id='.$item->id);
|
||||
} catch(Zend_Db_Adapter_Exception $e) {
|
||||
echo $e->getMessage();
|
||||
} catch(Zend_Db_Exception $e) {
|
||||
echo $e->getMessage();
|
||||
}
|
||||
);
|
||||
try {
|
||||
$result = $bilanM->update($data, 'id='.$item->id);
|
||||
} catch(Zend_Db_Adapter_Exception $e) {
|
||||
echo $e->getMessage();
|
||||
} catch(Zend_Db_Exception $e) {
|
||||
echo $e->getMessage();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -477,8 +479,7 @@ foreach ( $tabCommandes as $ref => $commande ) {
|
||||
->where('type_acte=?',$commande->acteType);
|
||||
$item = $acteM->fetchRow($sql);
|
||||
|
||||
require_once 'Metier/Infogreffe/InfogreffeAc.php';
|
||||
$infogreffe = new Metier_Infogreffe_Ac($commande->siren);
|
||||
$infogreffe = new SdMetier_Infogreffe_DocAC($commande->siren);
|
||||
$date = $commande->acteDate;
|
||||
if ( $date == '0000-00-00' ) {
|
||||
$date = $commande->depotDate;
|
||||
|
Loading…
Reference in New Issue
Block a user