Merge branch 'develop' of ssh://git@gogs.sd.lan:10022/SCORES/webservice.git into inextenso

This commit is contained in:
Claire DELBOS 2017-03-07 15:37:29 +01:00
commit 0dbfe9e7f4
23 changed files with 192 additions and 942 deletions

View File

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

View File

@ -1,17 +1,5 @@
<?php
// --- Define path to application directory
defined('APPLICATION_PATH')
|| define('APPLICATION_PATH', realpath(__DIR__ . '/../../application'));
// --- Define application environment
defined('APPLICATION_ENV')
|| define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'production'));
// --- Composer autoload
require_once realpath(__DIR__ . '/../../vendor/autoload.php');
// --- Create application, bootstrap, and run
$application = new Zend_Application(APPLICATION_ENV, APPLICATION_PATH . '/configs/application.ini');
require_once __DIR__ . '/../application/bin.bootstrap.php';
// --- Options
$displayUsage = false;
@ -22,12 +10,13 @@ try {
'generate|g=s' => "Generate the specify cache.",
));
$opts->parse();
$optionsNb = count($opts->getOptions());
} catch (Zend_Console_Getopt_Exception $e) {
$displayUsage = true;
}
// --- Aide / Options
if (count($opts->getOptions())==0 || isset($opts->help)) {
if ($optionsNb == 0 || isset($opts->help)) {
$displayUsage = true;
}
@ -62,25 +51,6 @@ if ( $opts->list ) {
exit;
}
// Database
$c = new Zend_Config($application->getOptions());
$config = new \Doctrine\DBAL\Configuration();
$connectionParams = array(
'dbname' => $c->profil->db->metier->params->dbname,
'user' => $c->profil->db->metier->params->username,
'password' => $c->profil->db->metier->params->password,
'host' => $c->profil->db->metier->params->host,
'charset' => 'utf8',
'driver' => 'pdo_mysql',
);
try {
$conn = \Doctrine\DBAL\DriverManager::getConnection($connectionParams, $config);
} catch (\Doctrine\DBAL\DBALException $e) {
echo "Connection Database impossible.\n";
exit;
}
/**
* Cache des Tribunaux Bodacc
*/

View File

@ -1,17 +1,5 @@
<?php
// --- Define path to application directory
defined('APPLICATION_PATH')
|| define('APPLICATION_PATH', realpath(__DIR__ . '/../../application'));
// --- Define application environment
defined('APPLICATION_ENV')
|| define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'production'));
// --- Composer autoload
require_once realpath(__DIR__ . '/../../vendor/autoload.php');
// --- Create application, bootstrap, and run
$application = new Zend_Application(APPLICATION_ENV, APPLICATION_PATH . '/configs/application.ini');
require_once __DIR__ . '/../application/bin.bootstrap.php';
error_reporting(E_ALL & ~E_NOTICE);
@ -28,12 +16,13 @@ try {
'tabcache' => "Tab in cache",
));
$opts->parse();
$optionsNb = count($opts->getOptions());
} catch (Zend_Console_Getopt_Exception $e) {
$displayUsage = true;
}
// --- Aide / Options
if (count($opts->getOptions())==0 || isset($opts->help)) {
if ($optionsNb == 0 || isset($opts->help)) {
$displayUsage = true;
}
@ -44,27 +33,6 @@ if ($displayUsage) {
exit;
}
$c = new Zend_Config($application->getOptions());
Zend_Registry::set('config', $c);
// Database
$config = new \Doctrine\DBAL\Configuration();
$connectionParams = array(
'dbname' => $c->profil->db->metier->params->dbname,
'user' => $c->profil->db->metier->params->username,
'password' => $c->profil->db->metier->params->password,
'host' => $c->profil->db->metier->params->host,
'charset' => 'utf8',
'driver' => 'pdo_mysql',
);
try {
$conn = \Doctrine\DBAL\DriverManager::getConnection($connectionParams, $config);
} catch (\Doctrine\DBAL\DBALException $e) {
echo "Connection Database impossible.\n";
exit;
}
// Fichier MRatios
if (isset($opts->ratios)) {

47
bin/buildCodeSfr.php Normal file
View File

@ -0,0 +1,47 @@
<?php
require_once __DIR__ . '/../application/bin.bootstrap.php';
// --- Options
$displayUsage = false;
try {
$opts = new Zend_Console_Getopt(array(
'help|?' => "Aide.",
'compile-s' => "Génére le cache des règles, sans paramètres (tout), avec paramètres (VORD, VORP, PO)",
'version=s' => "Version des régles",
));
$opts->parse();
$optionsNb = count($opts->getOptions());
} catch (Zend_Console_Getopt_Exception $e) {
$displayUsage = true;
}
// --- Aide / Options
if ($optionsNb == 0 || isset($opts->help)) {
$displayUsage = true;
}
// --- Usage
if ($displayUsage) {
echo "\nRegles SFR\n\n";
echo $opts->getUsageMessage();
exit;
}
$types = array('VORD', 'VORP', 'PO');
if ( $opts->compile!='' && in_array($opts->compile, $types) ) {
$types = array($opts->compile);
}
if ( count($types) > 0 ) {
foreach ( $types as $type ) {
$ruleSfrM = new Metier_Sfr_Compile($conn);
$ruleSfrM->setVersion($opts->version);
$ruleSfrM->construct($type);
}
}

View File

@ -1,17 +1,5 @@
<?php
// --- Define path to application directory
defined('APPLICATION_PATH')
|| define('APPLICATION_PATH', realpath(__DIR__ . '/../../application'));
// --- Define application environment
defined('APPLICATION_ENV')
|| define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'production'));
// --- Composer autoload
require_once realpath(__DIR__ . '/../../vendor/autoload.php');
// --- Create application, bootstrap, and run
$application = new Zend_Application(APPLICATION_ENV, APPLICATION_PATH . '/configs/application.ini');
require_once __DIR__ . '/../application/bin.bootstrap.php';
// --- Options
$displayUsage = false;
@ -21,12 +9,13 @@ try {
'log' => "",
));
$opts->parse();
$optionsNb = count($opts->getOptions());
} catch (Zend_Console_Getopt_Exception $e) {
$displayUsage = true;
}
// --- Aide / Options
if (count($opts->getOptions())==0 || isset($opts->help)) {
if ($optionsNb == 0 || isset($opts->help)) {
$displayUsage = true;
}
@ -38,25 +27,6 @@ if ($displayUsage) {
}
if ($opts->log) {
// Database
$c = new Zend_Config($application->getOptions());
$config = new \Doctrine\DBAL\Configuration();
$connectionParams = array(
'dbname' => $c->profil->db->metier->params->dbname,
'user' => $c->profil->db->metier->params->username,
'password' => $c->profil->db->metier->params->password,
'host' => $c->profil->db->metier->params->host,
'charset' => 'utf8',
'driver' => 'pdo_mysql',
);
try {
$conn = \Doctrine\DBAL\DriverManager::getConnection($connectionParams, $config);
} catch (\Doctrine\DBAL\DBALException $e) {
echo "Connection Database impossible.\n";
exit;
}
$sql = "SELECT * FROM sdv1.logs_item";
$stmt = $conn->prepare($sql);
$stmt->execute();

View File

@ -1,17 +1,5 @@
<?php
// --- Define path to application directory
defined('APPLICATION_PATH')
|| define('APPLICATION_PATH', realpath(__DIR__ . '/../../application'));
// --- Define application environment
defined('APPLICATION_ENV')
|| define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'production'));
// --- Composer autoload
require_once realpath(__DIR__ . '/../../vendor/autoload.php');
// --- Create application, bootstrap, and run
$application = new Zend_Application(APPLICATION_ENV, APPLICATION_PATH . '/configs/application.ini');
require_once __DIR__ . '/../application/bin.bootstrap.php';
// --- Options
$displayUsage = false;
@ -21,12 +9,13 @@ try {
'path=s' => "{Service Name}/{version}",
));
$opts->parse();
$optionsNb = count($opts->getOptions());
} catch (Zend_Console_Getopt_Exception $e) {
$displayUsage = true;
}
// --- Aide / Options
if (count($opts->getOptions())==0 || isset($opts->help)) {
if ($optionsNb == 0 || isset($opts->help)) {
$displayUsage = true;
}

View File

@ -1,26 +1,8 @@
<?php
require_once __DIR__ . '/../application/bin.bootstrap.php';
error_reporting(E_ALL & ~E_NOTICE);
// --- Define path to application directory
defined('APPLICATION_PATH')
|| define('APPLICATION_PATH', realpath(__DIR__ . '/../../application'));
// --- Define application environment
defined('APPLICATION_ENV')
|| define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'production'));
// --- Composer autoload
require_once realpath(__DIR__ . '/../../vendor/autoload.php');
// --- Create application, bootstrap, and run
$application = new Zend_Application(APPLICATION_ENV, APPLICATION_PATH . '/configs/application.ini');
$c = new Zend_Config($application->getOptions());
Zend_Registry::set('config', $c);
require_once 'WsScore/Configure.php';
$oldconfig = new Configure();
$typesFichier = array('csv', 'fichiers', 'clients', 'kbis');
// --- Options
@ -32,12 +14,13 @@ try {
'type=w' => 'Supprime uniquement les fichiers indiqués.',
));
$opts->parse();
$optionsNb = count($opts->getOptions());
} catch (Zend_Console_Getopt_Exception $e) {
$displayUsage = true;
}
// --- Aide / Options
if (count($opts->getOptions())==0 || isset($opts->help)) {
if ($optionsNb == 0 || isset($opts->help)) {
$displayUsage = true;
}

View File

@ -1,17 +1,5 @@
<?php
// --- Define path to application directory
defined('APPLICATION_PATH')
|| define('APPLICATION_PATH', realpath(__DIR__ . '/../../application'));
// --- Define application environment
defined('APPLICATION_ENV')
|| define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'production'));
// --- Composer autoload
require_once realpath(__DIR__ . '/../../vendor/autoload.php');
// --- Create application, bootstrap, and run
$application = new Zend_Application(APPLICATION_ENV, APPLICATION_PATH . '/configs/application.ini');
require_once __DIR__ . '/../application/bin.bootstrap.php';
// --- Options
$displayUsage = false;
@ -25,12 +13,13 @@ try {
'control' => "Control",
));
$opts->parse();
$optionsNb = count($opts->getOptions());
} catch (Zend_Console_Getopt_Exception $e) {
$displayUsage = true;
}
// --- Aide / Options
if (count($opts->getOptions())==0 || isset($opts->help)) {
if ($optionsNb == 0 || isset($opts->help)) {
$displayUsage = true;
}
@ -43,32 +32,6 @@ if ($displayUsage) {
exit;
}
$c = new Zend_Config($application->getOptions());
Zend_Registry::set('config', $c);
// Doctrine conn
$config = new \Doctrine\DBAL\Configuration();
$connectionParams = array(
'dbname' => $c->profil->db->metier->params->dbname,
'user' => $c->profil->db->metier->params->username,
'password' => $c->profil->db->metier->params->password,
'host' => $c->profil->db->metier->params->host,
'charset' => 'utf8',
'driver' => 'pdo_mysql',
);
try {
$conn = \Doctrine\DBAL\DriverManager::getConnection($connectionParams, $config);
} catch (\Doctrine\DBAL\DBALException $e) {
if (APPLICATION_ENV == 'development') {
echo '<pre>'; print_r($e); echo '</pre>';
} else {
echo "Le service rencontre actuellement un problème technique.";
}
exit;
}
Zend_Registry::set('doctrine', $conn);
$testMail = false;
$test = false;

View File

@ -1,18 +1,6 @@
#!/usr/bin/php
<?php
// --- Define path to application directory
defined('APPLICATION_PATH')
|| define('APPLICATION_PATH', realpath(__DIR__ . '/../../application'));
// --- Define application environment
defined('APPLICATION_ENV')
|| define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'production'));
// --- Composer autoload
require_once realpath(__DIR__ . '/../../vendor/autoload.php');
// --- Create application, bootstrap, and run
$application = new Zend_Application(APPLICATION_ENV, APPLICATION_PATH . '/configs/application.ini');
require_once __DIR__ . '/../application/bin.bootstrap.php';
// --- Options
$displayUsage = false;
@ -28,12 +16,13 @@ try {
)
);
$opts->parse();
$optionsNb = count($opts->getOptions());
} catch (Zend_Console_Getopt_Exception $e) {
$displayUsage = true;
}
// --- Aide / Options
if (count($opts->getOptions())==0 || isset($opts->help)) {
if ($optionsNb == 0 || isset($opts->help)) {
$displayUsage = true;
}
@ -46,9 +35,6 @@ if ($displayUsage) {
exit;
}
$c = new Zend_Config($application->getOptions());
Zend_Registry::set('config', $c);
if ( isset($opts->debug) ) {
define('DEBUG', true);
} else {

View File

@ -1,4 +1,6 @@
<?php
require_once __DIR__ . '/../application/bin.bootstrap.php';
/**
* User-Agent
* IE 11.0 : Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko
@ -7,20 +9,6 @@
*
*/
// --- Define path to application directory
defined('APPLICATION_PATH')
|| define('APPLICATION_PATH', realpath(__DIR__ . '/../../application'));
// --- Define application environment
defined('APPLICATION_ENV')
|| define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'production'));
// --- Composer autoload
require_once realpath(__DIR__ . '/../../vendor/autoload.php');
// --- Create application, bootstrap, and run
$application = new Zend_Application(APPLICATION_ENV, APPLICATION_PATH . '/configs/application.ini');
try {
$opts = new Zend_Console_Getopt(
//Options
@ -33,23 +21,19 @@ try {
)
);
$opts->parse();
$optionsNb = count($opts->getOptions());
} catch (Zend_Console_Getopt_Exception $e) {
echo $e->getUsageMessage();
exit;
}
$c = new Zend_Config($application->getOptions());
Zend_Registry::set('config', $c);
if ( isset($opts->debug) ) {
define('DEBUG', true);
} else {
define('DEBUG', false);
// --- Aide / Options
if ($optionsNb == 0 || isset($opts->help)) {
$displayUsage = true;
}
//Usage
if(count($opts->getOptions())==0 || isset($opts->help))
{
// --- Usage
if ($displayUsage) {
echo "Telecharge le kbis chez infogreffe.";
echo "\n\n";
echo $opts->getUsageMessage();
@ -57,6 +41,12 @@ if(count($opts->getOptions())==0 || isset($opts->help))
exit;
}
if ( isset($opts->debug) ) {
define('DEBUG', true);
} else {
define('DEBUG', false);
}
/*
338 437 189

View File

@ -1,17 +1,5 @@
<?php
// --- Define path to application directory
defined('APPLICATION_PATH')
|| define('APPLICATION_PATH', realpath(__DIR__ . '/../../application'));
// --- Define application environment
defined('APPLICATION_ENV')
|| define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'production'));
// --- Composer autoload
require_once realpath(__DIR__ . '/../../vendor/autoload.php');
// --- Create application, bootstrap, and run
$application = new Zend_Application(APPLICATION_ENV, APPLICATION_PATH . '/configs/application.ini');
require_once __DIR__ . '/../application/bin.bootstrap.php';
try {
$opts = new Zend_Console_Getopt(
@ -22,21 +10,29 @@ try {
'affiche=s' => "Affiche resultat traitement "
));
$opts->parse();
$optionsNb = count($opts->getOptions());
}
catch (Zend_Console_Getopt_Exception $e)
{
$displayUsage = true;
}
// --- Aide / Options
if ($optionsNb == 0 || isset($opts->help)) {
$displayUsage = true;
}
// --- Usage
if ($displayUsage) {
echo "Charge les commentaires ratios à partir de CSV.";
echo "\n\n";
echo $opts->getUsageMessage();
echo "\n";
exit;
}
//Usage
if( count($opts->getOptions())==0 || isset($opts->help))
{
echo $opts->getUsageMessage();
exit;
}
#########################################################
#########################################################
##### Presence te taille du fichier #####
#########################################################

View File

@ -1,17 +1,5 @@
<?php
// --- Define path to application directory
defined('APPLICATION_PATH')
|| define('APPLICATION_PATH', realpath(__DIR__ . '/../../application'));
// --- Define application environment
defined('APPLICATION_ENV')
|| define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'production'));
// --- Composer autoload
require_once realpath(__DIR__ . '/../../vendor/autoload.php');
// --- Create application, bootstrap, and run
$application = new Zend_Application(APPLICATION_ENV, APPLICATION_PATH . '/configs/application.ini');
require_once __DIR__ . '/../application/bin.bootstrap.php';
// --- Options
$displayUsage = false;
@ -22,6 +10,7 @@ try {
'csvfile=s' => "",
));
$opts->parse();
$optionsNb = count($opts->getOptions());
} catch (Zend_Console_Getopt_Exception $e) {
$displayUsage = true;
}
@ -40,25 +29,6 @@ if ($displayUsage) {
use League\Csv\Writer;
// Database
$c = new Zend_Config($application->getOptions());
$config = new \Doctrine\DBAL\Configuration();
$connectionParams = array(
'dbname' => 'sdv1',
'user' => 'wsuser',
'password' => 'wspass2012',
'host' => '195.154.170.169',
'charset' => 'utf8',
'driver' => 'pdo_mysql',
);
try {
$conn = \Doctrine\DBAL\DriverManager::getConnection($connectionParams, $config);
} catch (\Doctrine\DBAL\DBALException $e) {
echo "Connection Database impossible.\n";
exit;
}
$sql = file_get_contents($opts->sqlfile);
//we fetch the info from a DB using a PDO object

View File

@ -4966,13 +4966,9 @@ class Metier_Insee_MInsee extends Metier_Insee_Table
// --- Liste des jugements principaux - Tri chronologique par date de jugement
foreach ($tabRet as $i => $ann) {
$item = new stdClass();
$dateEff = str_replace('-', '', $ann['dateEffet'])*1;
$dateJug = str_replace('-', '', $ann['dateJugement'])*1;
$datePar = str_replace('-', '', $ann['DateParution'])*1;
if ($dateEff > 0) {
$item->date = $dateEff;
$item->dateISO8601 = $ann['dateEffet'];
} elseif ($dateJug > 0) {
if ($dateJug > 0) {
$item->date = $dateJug;
$item->dateISO8601 = $ann['dateJugement'];
} elseif ($datePar > 0) {

View File

@ -417,7 +417,7 @@ class Metier_Sfr_Scoring
$this->conn = $conn;
}
//Charger les Rules (dans l'ordre)
// Charger les Rules (dans l'ordre)
$this->RulesVORP = include realpath(dirname(__FILE__)) . '/RulesVorp-'.$this->version.'.php';
$this->RulesVORD = include realpath(dirname(__FILE__)) . '/RulesVord-'.$this->version.'.php';
$this->RulesPO = include realpath(dirname(__FILE__)) . '/RulesPo-'.$this->version.'.php';
@ -433,7 +433,7 @@ class Metier_Sfr_Scoring
file_put_contents('sfr.log', "SIREN = $siren\n", FILE_APPEND);
}
//Set ValContratAge
// Set ValContratAge
if (!empty($this->ValContratDate)) {
$dateContrat = DateTime::createFromFormat('Ymd', $this->ValContratDate);
$dateNow = new DateTime();

View File

@ -90,14 +90,14 @@ class Scores_Ws_Server
* @var array
*/
protected $listePrefs = array(
'NAF4' => "Afficher les anciens NAF",
'NACE' => "Afficher les codes NACES",
'NEWS' => "Afficher les news Google&copy;",
'MAPPY' => "Afficher les fa&ccedil;ades d'immeubles",
'NAF4' => "Afficher les anciens NAF",
'NACE' => "Afficher les codes NACES",
'NEWS' => "Afficher les news Google&copy;",
'MAPPY' => "Afficher les fa&ccedil;ades d'immeubles",
'CARTES' => "Afficher les cartes et les plans",
'VOIRSURV' => "Afficher les entités sous surveillances",
'VOIRSURV' => "Afficher les entités sous surveillances",
'DEMANDEREF' => "Demande de référence par defaut",
'RECHREF' => "Afficher le formulaire de recherche par référence",
'RECHREF' => "Afficher le formulaire de recherche par référence",
);
/**

View File

@ -40,6 +40,22 @@ class Entreprise extends Scores_Ws_Server
$sfrM = new Metier_Sfr_Scoring();
$sfrM->setVersion('1.4');
$sfrM->forceIdentite = true;
// Data SFR
try {
$sql = "SELECT sfr.DateContrat, sfr.IR FROM jo.sfr_data AS sfr
WHERE sfr.error=0 AND sfr.siren=:siren ORDER BY sfr.dateInsert DESC LIMIT 0,1";
$stmt = $this->conn->prepare($sql);
$stmt->bindValue('siren', $siren);
$stmt->execute();
if ($stmt->rowCount() > 0) {
$contrat = $stmt->fetch(\PDO::FETCH_OBJ);
//Set Values
$sfrM->setVal('ContratDate', $contrat->DateContrat);
$sfrM->setVal('IR', $contrat->IR);
}
} catch(\Doctrine\DBAL\DBALException $e) {}
$sfrM->evaluate($siren);
//Calculate

View File

@ -40,6 +40,22 @@ class Entreprise extends Scores_Ws_Server
$sfrM = new Metier_Sfr_Scoring();
$sfrM->setVersion('1.4');
$sfrM->forceIdentite = true;
// Data SFR
try {
$sql = "SELECT sfr.DateContrat, sfr.IR FROM jo.sfr_data AS sfr
WHERE sfr.error=0 AND sfr.siren=:siren ORDER BY sfr.dateInsert DESC LIMIT 0,1";
$stmt = $this->conn->prepare($sql);
$stmt->bindValue('siren', $siren);
$stmt->execute();
if ($stmt->rowCount() > 0) {
$contrat = $stmt->fetch(\PDO::FETCH_OBJ);
//Set Values
$sfrM->setVal('ContratDate', $contrat->DateContrat);
$sfrM->setVal('IR', $contrat->IR);
}
} catch(\Doctrine\DBAL\DBALException $e) {}
$sfrM->evaluate($siren);
//Calculate

View File

@ -2254,11 +2254,17 @@ class Entreprise extends Scores_Ws_Server
$tabRet = array();
$this->logger->info("IndiScore demandée pour $siren en niveau $niveau");
if (strlen($siren)>9 || (substr($siren,0,9)*1)<100 ){
if (strlen($siren) > 9 || (substr($siren,0,9)*1) < 100 ){
$this->logger->warning( "Siren $siren incorrect");
$this->sendError('1010');
}
$iInsee = new Metier_Insee_MInsee();
$result = $iInsee->getIdentiteLight($siren);
if (count($result) == 0) {
throw new SoapFault('ERR', "SIREN invalid");
}
$tDeb = microtime(true);
require_once 'Metier/Scores/MScores.php';
$tabRet = calculIndiScore($siren, $nic, $accesDist, $niveau, false, 'scores');

View File

@ -940,7 +940,7 @@ class Gestion extends Scores_Ws_Server
AND l.login=u.login AND u.idClient=c.id
ORDER BY l.login ASC, l.dateHeure ASC";
file_put_contents($c->profil->path->shared."/files/logs-$annee-$mois-$detail-$idClient-$login-$all.sql", $sql);
exec("php ".APPLICATION_PATH."/../scripts/jobs/sql2csv.php --sqlfile ".$c->profil->path->shared."/files/logs-$annee-$mois-$detail-$idClient-$login-$all.sql --csvfile $fichierCsv > /dev/null &");
exec("php ".APPLICATION_PATH."/../bin/sql2csv.php --sqlfile ".$c->profil->path->shared."/files/logs-$annee-$mois-$detail-$idClient-$login-$all.sql --csvfile $fichierCsv > /dev/null &");
$size = $cache = 0;
}

View File

@ -1338,7 +1338,7 @@ class Interne extends Scores_Ws_Server
$c = Zend_Registry::get('config');
$path = $c->profil->path->shared.'/files';
file_put_contents($path."/listesurv-$source-$login-$idClient.sql", $sql);
exec("php ".APPLICATION_PATH."/../scripts/jobs/sql2csv.php --sqlfile ".$path."/listesurv-$source-$login-$idClient.sql --csvfile $fichierCsv > /dev/null &");
exec("php ".APPLICATION_PATH."/../bin/sql2csv.php --sqlfile ".$path."/listesurv-$source-$login-$idClient.sql --csvfile $fichierCsv > /dev/null &");
$size=$cache=0;
}

View File

@ -115,7 +115,7 @@ class Pieces extends Scores_Ws_Server
//Téléchargement du KBIS
$result = array();
exec('php '.APPLICATION_PATH.'/../scripts/jobs/getKbis.php --siren '.$siren, $result);
exec('php '.APPLICATION_PATH.'/../bin/kbis.php --siren '.$siren, $result);
$result = end($result);
if (substr($result,-5) == '.html') {
$file = $dir.'/'.$result;

View File

@ -1,75 +0,0 @@
<?php
// --- Define path to application directory
defined('APPLICATION_PATH')
|| define('APPLICATION_PATH', realpath(__DIR__ . '/../../application'));
// --- Define application environment
defined('APPLICATION_ENV')
|| define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'production'));
// --- Composer autoload
require_once realpath(__DIR__ . '/../../vendor/autoload.php');
// --- Create application, bootstrap, and run
$application = new Zend_Application(APPLICATION_ENV, APPLICATION_PATH . '/configs/application.ini');
// --- Options
$displayUsage = false;
try {
$opts = new Zend_Console_Getopt(array(
'help|?' => "Aide.",
'compile-s' => "Génére le cache des règles, sans paramètres (tout), avec paramètres (VORD, VORP, PO)",
'version=s' => "Version des régles",
));
$opts->parse();
} catch (Zend_Console_Getopt_Exception $e) {
$displayUsage = true;
}
// --- Aide / Options
if (count($opts->getOptions())==0 || isset($opts->help)) {
$displayUsage = true;
}
// --- Usage
if ($displayUsage) {
echo "\nRegles SFR\n\n";
echo $opts->getUsageMessage();
exit;
}
// Doctrine conn
$config = new \Doctrine\DBAL\Configuration();
$connectionParams = array(
'dbname' => $application->profil->db->metier->params->dbname,
'user' => $application->profil->db->metier->params->username,
'password' => $application->profil->db->metier->params->password,
'host' => $application->profil->db->metier->params->host,
'charset' => 'utf8',
'driver' => 'pdo_mysql',
);
try {
$conn = \Doctrine\DBAL\DriverManager::getConnection($connectionParams, $config);
} catch (\Doctrine\DBAL\DBALException $e) {
exit;
}
$types = array('VORD', 'VORP', 'PO');
if ( $opts->compile!='' && in_array($opts->compile, $types) ) {
$types = array($opts->compile);
}
if ( count($types) > 0 ) {
foreach ( $types as $type ) {
$ruleSfrM = new Metier_Sfr_Compile($conn);
$ruleSfrM->setVersion($opts->version);
$ruleSfrM->construct($type);
}
}

View File

@ -1,581 +0,0 @@
<?php
// --- Define path to application directory
defined('APPLICATION_PATH')
|| define('APPLICATION_PATH', realpath(__DIR__ . '/../../application'));
// --- Define application environment
defined('APPLICATION_ENV')
|| define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'production'));
// --- Composer autoload
require_once realpath(__DIR__ . '/../../vendor/autoload.php');
// --- Create application, bootstrap, and run
$application = new Zend_Application(APPLICATION_ENV, APPLICATION_PATH . '/configs/application.ini');
// --- Options
$displayUsage = false;
try {
$opts = new Zend_Console_Getopt(array(
'help|?' => "Affiche l'aide.",
'acte' => "Traitement des actes ",
'bilan-s' => "Traitement des bilans (année millesime à traiter)",
'siren=s' => "Ecrase les données du fichier pour les éléments du siren",
'max=s' => "Nombre d'unités maximum à traités",
'part=s' => "Offset",
'total' => "Get total",
'files' => "Lister les fichiers puis intégration",
'numdepot=s' => "Specifier repetoire pour integrer fichier nommé (SIREN_MILLESIME_NUMDEPOT_BilanComplet.pdf) ",
'debug' => "Debug",
));
$opts->parse();
} catch (Zend_Console_Getopt_Exception $e) {
$displayUsage = true;
}
// --- Aide / Options
if (count($opts->getOptions())==0 || isset($opts->help)) {
$displayUsage = true;
}
// --- Usage
if ($displayUsage) {
echo "Set informations in database for greffe files.";
echo "\n\n";
echo $opts->getUsageMessage();
echo "\n";
exit;
}
$c = new Zend_Config($application->getOptions());
//@todo : Remove the use of registry
Zend_Registry::set('config', $c);
// Doctrine conn
$config = new \Doctrine\DBAL\Configuration();
$connectionParams = array(
'dbname' => $c->profil->db->metier->params->dbname,
'user' => $c->profil->db->metier->params->username,
'password' => $c->profil->db->metier->params->password,
'host' => $c->profil->db->metier->params->host,
'charset' => 'utf8',
'driver' => 'pdo_mysql',
);
try {
$conn = \Doctrine\DBAL\DriverManager::getConnection($connectionParams, $config);
} catch (\Doctrine\DBAL\DBALException $e) {
if (APPLICATION_ENV == 'development') {
echo '<pre>'; print_r($e); echo '</pre>';
} else {
echo "Le service rencontre actuellement un problème technique.";
}
exit;
}
Zend_Registry::set('doctrine', $conn);
/**
* Connexion à la base de données
*/
$db = Zend_Db::factory($c->profil->db->metier);
Zend_Db_Table_Abstract::setDefaultAdapter($db);
// Bilans
if ($opts->bilan) {
if ($opts->files) {
$nbBilans = 0;
//Type de bilan
$types = array('consolides', 'sociaux');
foreach ( $types as $type ) {
$path = $c->profil->infogreffe->storage->path . '/' . 'bilans';
echo "Bilans ".$type.PHP_EOL;
//AAAA
echo "Liste des années...".PHP_EOL;
$dirYears = array();
$path = $path . '/' . $type;
if ($handle = opendir($path)) {
while (false !== ($file = readdir($handle))) {
if ( $file != '..' && $file != '.' && is_dir($path . '/' . $file)) {
$dirYears[] = $file;
}
}
sort($dirYears);
}
//Fichier
foreach ($dirYears as $year) {
echo "Traitement des fichiers $type $year".PHP_EOL;
$pathFile = $path . '/' . $year;
if ($handle = opendir($pathFile)) {
while (false !== ($file = readdir($handle))) {
if ( $file != '..' && $file != '.' ) {
//'bilan-' . $this->siren . '-' . $type . '-' . $dateCloture . '.pdf';
if (preg_match('/^bilan-([0-9]{9})-(sociaux|consolides)-([0-9]{8})\.pdf/', $file, $matches)) {
echo "Fichier ".$file;
$siren = $matches[1];
$typeComptes = $matches[2];
$dateCloture = substr($matches[3],0,4).'-'.substr($matches[3],4,2).'-'.substr($matches[3],6,2);
//Recherche dans la bdd
$bilanM = new Application_Model_JoGreffesBilans();
$sql = $bilanM->select()
->where('siren=?',$siren)
->where('date_cloture=?', $dateCloture);
if ($typeComptes=='sociaux') {
$sql->where('type_comptes="" OR type_comptes="sociaux"');
} else {
$sql->where('type_comptes="consolides"');
}
$sql->where('actif=1');
$sql->order('dateInsert DESC')->order('num_depot DESC')->limit(1);
$item = $bilanM->fetchRow($sql);
if ($item === null) {
//If not find write the database
$infogreffe = new Metier_Infogreffe_DocBI();
$infogreffe->setSiren($siren);
$infogreffe->getList();
//And get again the item in database
$item = $bilanM->fetchRow($sql);
}
if ($item === null) {
echo " = non trouvé.";
} else {
if ($item->pdfDate == '0000-00-00') {
$infogreffe = new Metier_Infogreffe_DocBI();
$infogreffe->setSiren($siren);
$infos = $infogreffe->pdfInfos($pathFile . '/' . $file);
if (false !== $infos) {
$data = array(
'pdfLink' => $file,
'pdfSize' => $infos['size'],
'pdfPage' => $infos['pages'],
'pdfVer' => $infos['version'],
'pdfDate' => date('Ymd'),
);
try {
$result = $bilanM->update($data, 'id='.$item->id);
echo " = enregistrement.";
} catch(Zend_Db_Adapter_Exception $e) {
echo $e->getMessage();
} catch(Zend_Db_Exception $e) {
echo $e->getMessage();
}
}
} else {
echo " = présent.";
}
}
echo PHP_EOL;
}
$nbBilans++;
}
}
}
}
}
echo "Nombre de fichier : ".$nbBilans.PHP_EOL;
}
/**
* Lecture des fichiers depuis un répertoire
* siren_YYYY_NUMDEPOT_BilanComplet.pdf
*/
elseif ($opts->numdepot) {
echo $opts->numdepot."\n";
if( !is_dir($opts->numdepot) ) {
echo "Répertoire inexistant !\n"; exit;
}
if ($handle = opendir($opts->numdepot)) {
while (false !== ($file = readdir($handle))) {
if ( $file != '..' && $file != '.' ) {
if (preg_match('/^([0-9]{9})_([0-9]{4})_([0-9]{1,})_(.*)\.pdf/', $file, $matches)) {
echo $file;
$siren = $matches[1];
$millesime = $matches[2];
$depot = $matches[3];
$bilanM = new Application_Model_JoGreffesBilans();
$sql = $bilanM->select()
->from($bilanM, array('id','siren','millesime', 'date_cloture','type_comptes', 'pdfDate'))
->where('siren=?', $siren)
->where('millesime=?', $millesime)
->where('num_depot=?', $depot);
$item = $bilanM->fetchRow($sql);
if ($item === null) {
//If not find write the database
$infogreffe = new Metier_Infogreffe_DocBI();
$infogreffe->setSiren($siren);
$infogreffe->getList();
//And get again the item in database
$item = $bilanM->fetchRow($sql);
}
if ($item === null) {
echo " = non trouvé.";
} else {
if ($item->pdfDate == '0000-00-00') {
$infogreffe = new Metier_Infogreffe_DocBI();
$infogreffe->setSiren($siren);
$type = "sociaux";
if ( !empty($item->type_comptes) ) {
$type = $item->type_comptes;
}
//File path - 2012_sociaux-20121231-7501-55-B-14450-0035567
$newfile = $infogreffe->getFileName($type, $item->date_cloture);
$filepath = $c->profil->infogreffe->storage->path . '/' .
$infogreffe->getFilePath($type, $item->date_cloture) . '/' . $newfile;
if (copy($opts->numdepot . '/' .$file, $filepath)) {
$infos = $infogreffe->pdfInfos($filepath);
if (false !== $infos) {
$data = array(
'pdfLink' => $file,
'pdfSize' => $infos['size'],
'pdfPage' => $infos['pages'],
'pdfVer' => $infos['version'],
'pdfDate' => date('Ymd'),
);
try {
$result = $bilanM->update($data, 'id='.$item->id);
echo " = enregistrement.";
} catch(Zend_Db_Adapter_Exception $e) {
echo $e->getMessage();
} catch(Zend_Db_Exception $e) {
echo $e->getMessage();
}
}
} else {
echo " = copie du fichier impossible.";
}
} else {
echo " = présent.";
}
}
echo PHP_EOL;
}
}
}
}
}
//Lecture de toute la base de données
else {
//Lire la base de données
$bilanM = new Application_Model_JoGreffesBilans();
$sql = $bilanM->select()
->from($bilanM, array('siren','millesime', 'date_cloture','type_comptes'))
->order('millesime DESC');
if ( is_numeric($opts->bilan) ){
$sql->where('millesime=?', $opts->bilan);
}
if ( $opts->total ) {
$nbTotal = $bilanM->fetchAll($sql)->count();
echo "Total : ".$nbTotal.PHP_EOL;
exit;
}
if ( $opts->max && $opts->part ) {
$sql->limit($opts->max, $opts->part);
} elseif ($opts->max) {
$sql->limit($opts->max);
}
//$nbTotal = $bilanM->fetchAll($sql)->count();
if ( $opts->siren ) {
$sql->where('siren=?',$opts->siren);
} else {
$sql->where('pdfDate=?','0000-00-00');
}
$sql->where('actif=1');
$result = $bilanM->fetchAll($sql);
$NbLignes = $result->count();
echo "Nb Lignes à traiter : ".$NbLignes.PHP_EOL;
if ( $NbLignes > 0 ) {
$cpt = 1;
foreach ( $result as $item ) {
$siren = str_pad($item->siren, 9, '0', STR_PAD_LEFT);
echo "Ligne ".$cpt."/".$NbLignes." - siren = ".$siren." , millesime = ".$item->millesime;
// Lire les informations du fichier
$infogreffe = new Metier_Infogreffe_DocBI();
$infogreffe->setSiren($siren);
$type = 'sociaux';
if ( !empty($item->type_comptes) ) {
$type = $item->type_comptes;
}
//File path - 2012_sociaux-20121231-7501-55-B-14450-0035567
$file = $infogreffe->getFileName($type, $item->date_cloture);
$filepath = $c->profil->infogreffe->storage->path . '/' .
$infogreffe->getFilePath($type, $item->date_cloture) . '/' . $file;
echo " Fichier : ".$filepath;
if ( file_exists($filepath) ) {
echo " lecture.";
//Analyser le fichier - Nombre de page et taille
$infos = $infogreffe->pdfInfos($filepath);
//Enregistrer les infos du fichier dans la base de données
if (false !== $infos) {
$infogreffe->type_comptes = $item->type_comptes;
$infogreffe->date_cloture = $item->date_cloture;
$infogreffe->dbSetFile($file, $infos['size'], $infos['pages'], $infos['version']);
}
} else {
echo " non trouvé.";
}
echo PHP_EOL;
$cpt++;
}
} else {
echo "Aucun enregistrement !".PHP_EOL;
}
}
exit;
}
// Actes
if ($opts->acte) {
if ($opts->files) {
$path = $c->profil->infogreffe->storage->path . '/' . 'actes';
$months = array('01','02','03','04','05','06','07','08','09','10','11','12');
$nbActes = 0;
//AAAA
echo "Liste des années...".PHP_EOL;
$dirYears = array();
if ($handle = opendir($path)) {
while (false !== ($file = readdir($handle))) {
if ( $file != '..' && $file != '.' && is_dir($path . '/' . $file)) {
$dirYears[] = $file;
}
}
sort($dirYears);
}
//Fichier
foreach ($dirYears as $year) {
foreach ($months as $month) {
$pathFile = $path . '/' . $year . '/' . $month;
echo "Traitement des fichiers $year/$month".PHP_EOL;
if ( is_dir($pathFile) ) {
if ($handle = opendir($pathFile)) {
while (false !== ($file = readdir($handle))) {
if ( $file != '..' && $file != '.' ) {
//acte-347614984-TB-2012-03-15-1402-00-D-50625-4-1.pdf
if (preg_match('/^acte-([0-9]{9})-(.*)-(.*)-(.*)-(.*)-(.*)-(.*)-(.*)-(.*)-(.*)-(.*)\.pdf/', $file, $matches)) {
$outfile = 'acte-'.$matches[1].'-'.$matches[2].'-'.
$matches[3].$matches[4].$matches[5].'-'.
$matches[6].'-'.$matches[7].'-'.$matches[8].'-'.$matches[9].'-'.$matches[10].'-'.$matches[11].'.pdf';
echo "Fichier ".$file;
if ( rename($pathFile.'/'.$file, $pathFile.'/'.$outfile) ) {
$data = array(
'pdfLink' => $outfile,
);
try {
$acteM = new Application_Model_JoGreffesActes();
$result = $acteM->update($data, array(
'pdfLink="'.$file.'"',
'siren='.$matches[1],
));
echo " = " . $outfile . " = enregistrement.";
} catch(Zend_Db_Adapter_Exception $e) {
echo $e->getMessage();
} catch(Zend_Db_Exception $e) {
echo $e->getMessage();
}
}
echo "\n";
continue;
}
//'acte-' . $this->siren . '-' . $type . '-' . $date . '-' . $options . '-' . $num . '.pdf';
//with options = NumGreffe - NumRC - NumRC - NumRC - NumDepot
//acte-876580325-XB-20120427-5602-65-B-00032-18-01.pdf
if (preg_match('/^acte-([0-9]{9})-(.*)-(.*)-(.*)-(.*)-(.*)-(.*)-(.*)-(.*)\.pdf/', $file, $matches)) {
echo "Fichier ".$file;
$siren = $matches[1];
$type = $matches[2];
$date = substr($matches[3],0,4).'-'.substr($matches[3],4,2).'-'.substr($matches[3],6,2);
$depot = $matches[8];
$num = $matches[9];
$acteM = new Application_Model_JoGreffesActes();
$sql = $acteM->select()
->where('siren=?', $siren)
->where('num_depot=?', $depot)
->where('date_acte=?', $date)
->where('num_acte=?', intval($num));
//->where('type_acte=?', $type);
//GROUP BY type_acte_libelle
$sql->where('actif=1');
$items = $acteM->fetchAll($sql);
if (count($items)==0) {
//If not find write the database
$infogreffe = new Metier_Infogreffe_DocBI();
$infogreffe->setSiren($siren);
$infogreffe->getList();
//And get again the item in database
$items = $acteM->fetchAll($sql);
}
if (count($items)==0) {
echo " = non trouvé.";
} else {
foreach($items as $item) {
if ($item->pdfDate == '0000-00-00') {
$infogreffe = new Metier_Infogreffe_DocBI();
$infogreffe->setSiren($siren);
$infos = $infogreffe->pdfInfos($pathFile . '/' . $file);
if (false !== $infos) {
$data = array(
'pdfLink' => $file,
'pdfSize' => $infos['size'],
'pdfPage' => $infos['pages'],
'pdfVer' => $infos['version'],
'pdfDate' => date('Ymd'),
);
try {
$result = $acteM->update($data, 'id='.$item->id);
echo " = enregistrement.";
} catch(Zend_Db_Adapter_Exception $e) {
echo $e->getMessage();
} catch(Zend_Db_Exception $e) {
echo $e->getMessage();
}
}
} else {
echo " = présent.";
}
}
}
echo PHP_EOL;
}
$nbActes++;
}
}
}
}
}
}
echo "Nombre de fichier : ".$nbActes.PHP_EOL;
} else {
//Lire la base de données
$acteM = new Application_Model_JoGreffesActes();
$sql = $acteM->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'
))
->order('date_depot ASC');
if ( $opts->siren ) {
$sql->where('siren=?',$opts->siren);
} else {
$sql->where('pdfLink=?','');
}
$result = $acteM->fetchAll($sql);
if ( $result->count() > 0 ) {
$cpt = 1;
foreach ( $result as $item ) {
$date = $item->date_acte;
$num = $item->num_acte;
$type = $item->type_acte;
$infogreffe = new Metier_Infogreffe_DocAC();
$infogreffe->setSiren($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);
$path = $c->profil->path->shared . '/datafile/' . $infogreffe->getFilePath($date) . '/' . $file;
if ( file_exists($filepath) ) {
//Analyser le fichier - Nombre de page et taille
$infos = $infogreffe->pdfInfos($filepath);
//Enregistrer les infos du fichier dans la base de données
if (false !== $infos) {
$infogreffe->dbSetFile($file, $infos['size'], $infos['pages'], $infos['version']);
}
}
}
} else {
echo "Aucun enregistrement !\n";
}
}
}