Batch / Scripts dans bin

This commit is contained in:
Michael RICOIS 2017-02-28 12:26:29 +01:00
parent 13c993ecb2
commit b2e40da0bf
27 changed files with 100 additions and 5010 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)) {

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 {
'version=s' => "Version des régles",
));
$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,23 +27,6 @@ if ($displayUsage) {
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) ) {

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

@ -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,421 +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.",
'list' => "List item.",
'generate|g=s' => "Generate the specify cache.",
));
$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 "\nGénération Table Static Metier\n\n";
echo $opts->getUsageMessage();
exit;
}
if ( $opts->list ) {
$tabItems = array(
'Tribunaux' => "Tribunaux",
'FctDir' => "Fonctions de direction",
'Evenements' => "Table des evenements bodacc",
'Devises' => "Table des devises bodacc",
'RncsTribunaux' => "Table des tribunaux",
'DevisesInpi' => "Devises Inpi",
'Jugements' => "Jugements",
'PaysInpi' => "PaysInpi",
'CodesNaf' => "Codes Naf",
'CodesNace' => "Codes Nace",
'CodesNafa' => "Codes Nafa",
'CodesFJ' => "Codes Formes Juridiques",
'AffairesTypes' => "Codes natures des contentieux",
'ProcolDelete' => "Codes effacement de procol",
);
echo "\n";
foreach ( $tabItems as $code => $label ) {
echo "\t" . $code . " => ". $label . PHP_EOL;
}
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
*/
if( $opts->generate == 'Tribunaux' ) {
$sql = "SELECT triCode, triNom, LPAD(triCP,5,0) AS triCP, triSiret FROM jo.tribunaux WHERE triCode IS NOT NULL";
$stmt = $conn->prepare($sql);
$stmt->execute();
$result = $stmt->fetchAll(\PDO::FETCH_OBJ);
$fp = fopen(APPLICATION_PATH . '/../library/Metier/Table/BodaccTribunaux.php','w');
fwrite($fp, "<?php\n");
fwrite($fp, "return array(\n");
if ($stmt->rowCount() > 0) {
foreach($result as $item) {
$dep = substr($item->triCP, 0, 2);
if ($dep == 97 || $dep == 98) {
$dep = substr($item->triCP, 0, 3);
}
fwrite($fp, "\t'" . $item->triCode . "' => array(");
fwrite($fp, "'nom'=>\"" . $item->triNom . "\", 'siret'=>\"".$item->triSiret."\", 'dep'=>\"".$dep."\"");
fwrite($fp, "),\n");
}
}
fwrite($fp, ");\n");
}
/**
* Cache Fonctions de Direction
*/
if ( $opts->generate == 'FctDir' ) {
$sql = "SELECT codeFct, libelle FROM jo.bodacc_fonctions";
$stmt = $conn->prepare($sql);
$stmt->execute();
$result = $stmt->fetchAll(\PDO::FETCH_OBJ);
$fp=fopen(APPLICATION_PATH . '/../library/Metier/Table/FctDir.php','w');
fwrite($fp, "<?php\n");
fwrite($fp, "return array(\n");
if ($stmt->rowCount() > 0) {
foreach($result as $item) {
fwrite($fp, "\t'" . intval($item->codeFct) . "' => \"". $item->libelle . "\",\n");
}
}
fwrite($fp, ");\n");
}
/**
* Cache Evenements
*/
if ( $opts->generate == 'Evenements' ) {
$sql = "SELECT codEven, libEven, Bodacc_Code, Rubrique, version, lienEtab FROM jo.tabEvenements";
$stmt = $conn->prepare($sql);
$stmt->execute();
$result = $stmt->fetchAll(\PDO::FETCH_OBJ);
$fp = fopen(APPLICATION_PATH . '/../library/Metier/Table/Evenements.php','w');
fwrite($fp, "<?php\n");
fwrite($fp, "return array(\n");
if ($stmt->rowCount() > 0) {
foreach($result as $item) {
fwrite($fp, "\t'" . intval($item->codEven) . "' => array(\n");
fwrite($fp, "\t\t'libEven' => \"" . $item->libEven . "\",\n");
fwrite($fp, "\t\t'Bodacc_Code' => \"" . $item->Bodacc_Code . "\",\n");
fwrite($fp, "\t\t'Rubrique' => \"" . $item->Rubrique . "\",\n");
fwrite($fp, "\t\t'Version' => " . $item->version . ",\n");
fwrite($fp, "\t\t'LienEtab' => " . $item->lienEtab . ",\n");
fwrite($fp, "\t),\n");
}
}
fwrite($fp, ");\n");
}
/**
* Cache des devises Bodacc
*/
if ( $opts->generate == 'Devises' ) {
$sql = "SELECT libDeviseBodacc, devIso FROM jo.bodacc_devises";
$stmt = $conn->prepare($sql);
$stmt->execute();
$result = $stmt->fetchAll(\PDO::FETCH_OBJ);
$fp = fopen(APPLICATION_PATH . '/../library/Metier/Table/Devises.php','w');
fwrite($fp, "<?php\n");
fwrite($fp, "return array(\n");
if ($stmt->rowCount() > 0) {
foreach($result as $item) {
fwrite($fp, "\t\"" . $item->libDeviseBodacc . "\" => \"" . $item->devIso ."\",\n");
}
}
fwrite($fp, ");\n");
}
/**
* Cache Tribunaux RNCS
*/
if ( $opts->generate == 'RncsTribunaux' ) {
$sql = "SELECT triNumGreffe, triNom, triId, triCode FROM jo.tribunaux WHERE triNumGreffe IS NOT NULL";
$stmt = $conn->prepare($sql);
$stmt->execute();
$result = $stmt->fetchAll(\PDO::FETCH_OBJ);
$fp = fopen(APPLICATION_PATH . '/../library/Metier/Table/RncsTribunaux.php','w');
fwrite($fp, "<?php\n");
fwrite($fp, "return array(\n");
if ($stmt->rowCount() > 0) {
foreach($result as $item) {
fwrite($fp, "\t" . intval($item->triNumGreffe) . " => array(");
fwrite($fp, "'Id'=>\"" . intval($item->triId) . "\", 'Nom'=>\"".$item->triNom."\", 'Code'=>\"".$item->triCode."\"");
fwrite($fp, "),\n");
}
}
fwrite($fp, ");\n");
}
/**
* Cache Devises Inpi
*/
if ( $opts->generate == 'DevisesInpi' ) {
$sql = "SELECT devInpi, devIso FROM jo.tabDevises WHERE devInpi>0 ORDER BY devInpi ASC";
$stmt = $conn->prepare($sql);
$stmt->execute();
$result = $stmt->fetchAll(\PDO::FETCH_OBJ);
$fp = fopen(APPLICATION_PATH . '/../library/Metier/Table/DevisesInpi.php','w');
fwrite($fp, "<?php\n");
fwrite($fp, "return array(\n");
if ($stmt->rowCount() > 0) {
foreach($result as $item) {
fwrite($fp, "\t" . intval($item->devInpi) . " => \"" . $item->devIso . "\",\n");
}
}
fwrite($fp, ");\n");
}
/**
* Cache Jugements
*/
if ( $opts->generate == 'Jugements' ) {
$sql = "SELECT codJugement, codEven FROM jo.tabJugeRncs";
$stmt = $conn->prepare($sql);
$stmt->execute();
$result = $stmt->fetchAll(\PDO::FETCH_OBJ);
$fp = fopen(APPLICATION_PATH . '/../library/Metier/Table/Jugements.php','w');
fwrite($fp, "<?php\n");
fwrite($fp, "return array(\n");
if ($stmt->rowCount() > 0) {
foreach($result as $item) {
fwrite($fp, "\t" . intval($item->codJugement) . " => " . $item->codEven . ",\n");
}
}
fwrite($fp, ");\n");
}
/**
* Cache PaysInpi
*/
if ( $opts->generate == 'PaysInpi' ) {
$sql = "SELECT codePaysInpi, codPays FROM jo.tabPays WHERE codePaysInpi>0 ORDER BY codePaysInpi ASC";
$stmt = $conn->prepare($sql);
$stmt->execute();
$result = $stmt->fetchAll(\PDO::FETCH_OBJ);
$fp = fopen(APPLICATION_PATH . '/../library/Metier/Table/PaysInpi.php','w');
fwrite($fp, "<?php\n");
fwrite($fp, "return array(\n");
if ($stmt->rowCount() > 0) {
foreach($result as $item) {
fwrite($fp, "\t" . intval($item->codePaysInpi) . " => \"" . $item->codPays . "\",\n");
}
}
fwrite($fp, ");\n");
}
/**
* Cache CodesNaf
*/
if ( $opts->generate == 'CodesNaf' ) {
$sql = "SELECT codNaf700 AS naf, libNaf700 AS LibNaf FROM jo.tabNaf4";
$stmt = $conn->prepare($sql);
$stmt->execute();
$result = $stmt->fetchAll(\PDO::FETCH_OBJ);
$fp = fopen(APPLICATION_PATH . '/../library/Metier/Table/CodesNaf.php','w');
fwrite($fp, "<?php\n");
fwrite($fp, "return array(\n");
if ($stmt->rowCount() > 0) {
foreach($result as $item) {
fwrite($fp, "\t'" . $item->naf . "' => \"" . $item->LibNaf . "\",\n");
}
}
$sql = "SELECT codNaf5 AS naf, libNaf5 AS LibNaf FROM jo.tabNaf5";
$stmt = $conn->prepare($sql);
$stmt->execute();
$result = $stmt->fetchAll(\PDO::FETCH_OBJ);
if ($stmt->rowCount() > 0) {
foreach($result as $item) {
fwrite($fp, "\t'" . $item->naf . "' => \"" . $item->LibNaf. "\",\n");
}
}
fwrite($fp, ");\n");
}
/**
* Cache CodesNace
*/
if ( $opts->generate == 'CodesNace' ) {
$sql = "SELECT codNaf5 AS naf, libNaf5 AS LibNaf, codNaf1 FROM jo.tabNaf5";
$stmt = $conn->prepare($sql);
$stmt->execute();
$result = $stmt->fetchAll(\PDO::FETCH_OBJ);
$fp = fopen(APPLICATION_PATH . '/../library/Metier/Table/CodesNace.php','w');
fwrite($fp, "<?php\n");
fwrite($fp, "return array(\n");
if ($stmt->rowCount() > 0) {
foreach($result as $item) {
fwrite($fp, "\t'" . $item->naf . "' => \"" . $item->codNaf1 . preg_replace('/^0/','',substr($item->naf,0,4)) . "\",\n");
}
}
fwrite($fp, ");\n");
}
/**
* Cache CodesNafa
*/
if ( $opts->generate == 'CodesNafa' ) {
$sql = "SELECT codNafa AS nafa, libNafa FROM jo.tabNafa";
$stmt = $conn->prepare($sql);
$stmt->execute();
$result = $stmt->fetchAll(\PDO::FETCH_OBJ);
$fp = fopen(APPLICATION_PATH . '/../library/Metier/Table/CodesNafa.php','w');
fwrite($fp, "<?php\n");
fwrite($fp, "return array(\n");
if ($stmt->rowCount() > 0) {
foreach($result as $item) {
fwrite($fp, "\t'" . $item->nafa . "' => \"" . $item->libNafa ."\",\n");
}
}
fwrite($fp, ");\n");
}
/**
* Cache CodesFJ
*/
if ( $opts->generate == 'CodesFJ' ) {
$sql = "SELECT code AS FJ, libelle AS libFJ FROM jo.tabFJur WHERE code>=1000";
$stmt = $conn->prepare($sql);
$stmt->execute();
$result = $stmt->fetchAll(\PDO::FETCH_OBJ);
$fp = fopen(APPLICATION_PATH . '/../library/Metier/Table/CodesFJ.php','w');
fwrite($fp, "<?php\n");
fwrite($fp, "return array(\n");
if ($stmt->rowCount() > 0) {
foreach($result as $item) {
fwrite($fp, "\t" . $item->FJ . " => \"" . str_replace('"','\"',$item->libFJ) ."\",\n");
}
}
fwrite($fp, ");\n");
}
/**
* Cache AffairesTypes
* Code Nature des contentieux
*/
if ( $opts->generate == 'AffairesTypes' ) {
$sql = "SELECT code, label FROM jo.greffes_affaires_nature";
$stmt = $conn->prepare($sql);
$stmt->execute();
$result = $stmt->fetchAll(\PDO::FETCH_OBJ);
$fp = fopen(APPLICATION_PATH . '/../library/Metier/Table/AffairesTypes.php','w');
fwrite($fp, "<?php\n");
fwrite($fp, "return array(\n");
if ($stmt->rowCount() > 0) {
foreach($result as $item) {
fwrite($fp, "\t'" . $item->code . "' => \"" . $item->label ."\",\n");
}
}
fwrite($fp, ");\n");
}
/**
* Procol Delete
*/
if ( $opts->generate == 'ProcolDelete' ) {
$sql = "SELECT codEven, affProcol, libEven FROM jo.tabEvenements WHERE affProcol>0";
$stmt = $conn->prepare($sql);
$stmt->execute();
$result = $stmt->fetchAll(\PDO::FETCH_OBJ);
$fp = fopen(APPLICATION_PATH . '/../library/Metier/Defaillance/ProcolDelete.php', 'w');
fwrite($fp, "<?php\n");
fwrite($fp, "return array(\n");
if ($stmt->rowCount() > 0) {
foreach($result as $item) {
fwrite($fp, "\t" . $item->codEven . " => " . $item->affProcol .", //".$item->libEven." \n");
}
}
fwrite($fp, ");\n");
}

File diff suppressed because it is too large Load Diff

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,87 +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.",
'log' => "",
));
$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 "\nLog\n\n";
echo $opts->getUsageMessage();
exit;
}
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();
$outPath = APPLICATION_PATH . '/../library/Scores/Account/Log/List.php';
$outFile = $outPath . '/Config.php';
if ($stmt->rowCount() > 0) {
$result = $stmt->fetchAll(\PDO::FETCH_OBJ);
file_put_contents($outFile, "<?php\n");
file_put_contents($outFile, "/* Auto generated ".date('Y-m-d H:i:s')." */\n");
file_put_contents($outFile, "return array(\n", FILE_APPEND);
foreach ($result as $c) {
file_put_contents($outFile, "\t'". $c->Code . "' => array(,\n", FILE_APPEND);
file_put_contents($outFile, "\t\t'Label' => ". $c->Label . ",\n", FILE_APPEND);
file_put_contents($outFile, "\t\'Description' => ". $c->Description . ",\n", FILE_APPEND);
file_put_contents($outFile, "\t\t'Category' => ". $c->Category . ",\n", FILE_APPEND);
file_put_contents($outFile, "\t),\n", FILE_APPEND);
}
file_put_contents($outFile, ");\n", FILE_APPEND);
}
}

View File

@ -1,61 +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.",
'path=s' => "{Service Name}/{version}",
));
$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 "\nType Service\n\n";
echo $opts->getUsageMessage();
exit;
}
$wsPath = APPLICATION_PATH . '/../library/WsScore/';
require_once $wsPath . $opts->path . '/Types.php';
$detect = new Zend_Reflection_File($wsPath . $opts->path . '/Types.php');
$result = $detect->getClasses();
$outPath = dirname($wsPath . $opts->path . '/Types.php');
$outFile = $outPath . '/Config.php';
if (count($result) > 0) {
file_put_contents($outFile, "<?php\n");
file_put_contents($outFile, "return array(\n", FILE_APPEND);
foreach ($result as $c) {
file_put_contents($outFile, "\t'". $c->name . "' => '" . $c->name ."',\n", FILE_APPEND);
}
file_put_contents($outFile, ");\n", FILE_APPEND);
}

View File

@ -1,636 +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');
try {
$opts = new Zend_Console_Getopt(
//Options
array(
'help|?' => "Aide.",
'fichier=s' => "Nom du fichier complet : version ",
'affiche=s' => "Affiche resultat traitement "
));
$opts->parse();
}
catch (Zend_Console_Getopt_Exception $e)
{
echo $opts->getUsageMessage();
exit;
}
//Usage
if( count($opts->getOptions())==0 || isset($opts->help))
{
echo $opts->getUsageMessage();
exit;
}
#########################################################
##### Presence te taille du fichier #####
#########################################################
$fichier = $opts->fichier; // $fichier contient chemin/qqchose.csv
$nomfichier = basename($fichier); // $nomfichier contient qqchose.csv, basename retourne un array donc un tableau ayant comme valeur chacun des
// fichiers (chemain absolu) contenu dans le repertoir $directory, ici le repertoir contient normalement une seul fichier a la fois , donc $fichier[]
$fic = $fichier ; // On definti notre variable $fic comme etant notre fichier.
#########################################################
##### Teste de validité du nom du fichier #####
#########################################################
$detect1 = strstr($nomfichier, 'valo_commentaires_');
$detect2 = strstr($nomfichier, 'valo_formules_');
$detect3 = strstr($nomfichier, 'scores_formules_');
$detect4 = strstr($nomfichier, 'scores_commentaires_');
if ($detect1 !== false or $detect2 !== false or $detect3 !== false or $detect4 !== false)
{
echo "\n"." Nom du fichier ok"."\n" ;
}
else
{
echo "\n" . "le nom du fichier est incorrect" . "\n";
echo "\n" . "le nom du fichier doit obliqatoirement etre compose de la sorte :" . "\n";
echo "\n" . 'valo_commentaires_' . "\n";
echo "\n" ."ou"."\n";
echo "\n" . 'valo_formules_' . "\n";
echo "\n" ."ou"."\n";
echo "\n" . 'scores_formules_' . "\n";
echo "\n" ."ou"."\n";
echo "\n" . 'scores_commentaires_' . "\n";
Exit;
}
#########################################################
##### On indique si le fichier est present ou non #####
#########################################################
if ((file_exists($fichier)))
{
echo "\n Fichier $nomfichier au format csv trouve a l'emplacement prevu : \n";
echo "\n"." La taille du fichier est de :".filesize($fic)." octets"."\n";
$file = true;
}
else
{
echo "\n". "Pas de fichier .csv present a l'endroit indique"."\n";
$file = false;
exit;
}
#########################################################
##### taille du contenu du fichier #####
#########################################################
# déclaration variables :
$fileopen = fopen($fic, 'r');
$contenufichier = fgetcsv($fileopen);
$nblignes=0;
$cnbl = count($nblignes);
$fific = file($fic); // retourner le contenu du fichier dans une chaîne de caractères.
foreach ($fific as $line_num => $line)
{
$nblignes++;
}
echo "\n"." le fichier contient " . $nblignes . " lignes."."\n" ;
#########################################################
##### Routage vers commentaires ou formules #####
#########################################################
#variables :
$doublon = 0; // On initialise la variable doublon.
$row = 0 ; // On initialise les lignes.
$verif = array() ; // creation d'un tableau
$nom_fic = basename($fic) ;
$col3= 0;
#########################################################
##### Identification du type de fichier #####
#########################################################
//On commance rechercher si le nom du fichier contient "COMMENTAIRE" pour 4 colonnes sinon 2 colonnes
if (strstr($nom_fic, 'commentaires'))
{
$nbcol_cle = 4;
}
else
{
$nbcol_cle = 2;
}
// Si $fic est bien ouvert on commence le traitement.
if ($file = true )
{
$fileopen2 = fopen($fic, "r+");
if($fileopen2)
{
$contenufichier=fgetcsv($fileopen2);
$nblignes = file($fic);
// Tant qu'il y a des lignes, lis les et fait en un tableau.
while (($data = fgetcsv($fileopen2,0,';','"')) !== FALSE)
{
$num = count($row); //compte nombre de partits dans la phrase
$row++;
// On fait une concatenation des colonnes de $fic dans un nouveau tableau nomme $cle.
// Cela nous permettera de dedoublonner par la suite.
if ($nbcol_cle == 4) // si nbcol = 4 alors notre clé sera composée de 4 colonnes sinon 3
{
$cle = $data[0].$data[1].$data[2].$data[3];
}
else
{
$cle = $data[0].$data[1].$data[2];
}
#########################################################
##### Dédoublonnage #####
#########################################################
// On regarde si on retrouve les valeurs de $verif dans $cle
if (in_array($cle, $verif, TRUE))
{
$doublon = $doublon + 1; // On définit un compteur qui nous indiquera le nombre de doublons
echo "\n"."Attention vous avez $doublon doublon(s) dans votre fichier !\n";
echo "\n"."il semblerait qu'il soit present a la ligne $row contenant $cle "."\n";
}
else
{
// Ajout de la cle au tableau indexe numeriquement
$verif[] = $cle ;
}
#########################################################
##### Routage commentaires ou formules #####
##### et verification des champs #####
#########################################################
if (strstr ($nom_fic , 'commentaires'))// le nom du fichier contient 'commentaires' alors ...
{
// On teste les champs vide
if (strlen($data[0])== 0 or strlen($data[1]) == 0
or strlen($data[2]) == 0 or strlen($data[3]) == 0)
{
echo "\n"."Erreur ! Vous avez des champs vides commentaires , sur la ligne $num"."\n"."contenant $data[1].$data[2].$data[3].$data[4].$data[5].$data[6].$data[7]";
}
if ($data[0] == 0)
{
echo "\n"."erreur code commentaire ". $data[0] ." null"."\n";
exit;
}
if($data[2] < 0)
{
echo "\n"."erreur code ligne " . $data[2] . "null"."\n";
exit;
}
}
elseif (strstr ($nom_fic , 'formules'))
{
if (strlen($data[0]) == 0 or strlen($data[1]) == 0 )
{
echo "\n"." Erreur vous avez des champs vides formules , sur la ligne $row"."\n"."contenant $data[0].$data[1]. . ";
exit;
}
if ($data[0] == 0)
{
echo "\n"."erreur code commentaire " . $data[0] . " null"."\n";
exit;
}
if($data[1] < 0)
{
echo "\n"."erreur code code ligne". $data[1] ."null"."\n";
exit;
}
}
}
}
}
if ($doublon >= 1)
{
$ok = false;
echo "\n"." $doublon Doublons détectés dans le fichier."."\n";
// Quitte avec un code d'erreur: doublon détecté.
exit(1);
}
elseif ($doublon == 0 && !file_exists($fic))
{
$ok = false;
exit;
}
else
{
// le script appelant continue.
$ok = true; // petit marqueur de fonctionnement du script jusqu'a présent
echo "\n Le fichier ne comporte pas de doublon. \n";
}
fclose($fileopen);
echo "\n Bon, maintenant on va passer a la base de donnee \n";
#########################################################
##### ________ ____ ____ #####
### | __ \ | \ | \ ###
# | / | |\ \ | |\ \ #
### | __ \ | |/ / | |/ / ###
##### |_______/ |___/ |___/ #####
#########################################################
// si notre scripte est bon on passe a la suite
$c = new Zend_Config($application->getOptions());
try {
$db = Zend_Db::factory($c->profil->db->metier);
$db->getConnection();
// print_r (get_class_methods($db));
}
catch (Zend_Exception $e)
{
echo $e->getMessage();
}
if ($db->isConnected())
{
echo "\n***********************************************\n";
echo "\n Connection a la BDD ok \n";
echo "\n***********************************************\n";
}
else
{
echo "\n***********************************************\n";
echo "\n !!!! Erreur / ! Pas connecte a la BDD !!!! \n";
echo "\n***********************************************\n";
}
$pathCache = APPLICATION_PATH . '/../library/Metier/Scores/Variables';
$copy_fic = $nomfichier;
if($nomfichier) // Si le nom du fichier comprend 'scores' ou 'valo'...
{
// On découpe la chaine de caractère à chaque "/" et on fait un array.
$token = basename($copy_fic);
// On prend ce qui se trouve avant le point
$token1 = strtok($token, ".");
// On effece '_utf8' et '.csv'
$nomtabletemp =(str_replace('_utf8', '', $token));
$nomtable =(str_replace('.csv','', $nomtabletemp));
// Affichage du nom de la table
echo "\n Le nom de la table est : $nomtable . \n";
}
####################################################
##### // Création de la Table Ccmmentaires \\ #####
####################################################
if (strstr($nomtable,"commentaires"))
{
try
{
// Création d'une table "TEXTE"
$sql_ctc_query = $db->query("CREATE TABLE $nomtable
(
code int(8) NOT NULL,
langue char(2) NOT NULL,
cycle smallint(3) NOT NULL,
ligne char(4) NOT NULL,
commentaire longtext,
tri varchar(5) DEFAULT NULL,
deleted varchar(2) DEFAULT NULL,
idUser varchar(0) DEFAULT NULL,
dateInsert varchar(15) DEFAULT NULL,
dateUpdate varchar(0) DEFAULT NULL,
PRIMARY KEY (code,langue,cycle,ligne)
)
ENGINE = MyISAM DEFAULT CHARSET=latin1 COMMENT= 'Commentaires Valorisation - Liste des commentaires';");
}
catch (Zend_Exception $e)
{
echo $e->getMessage()."\n";
echo "\n"."!!!!! ERREUR ! / CHARGEMENT ARRETE !!!!!"."\n"."\n";
}
echo "\n" . " Table $nomtable cree." ."\n";
}
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
$fileopen2 = fopen($fic, "r+");
$nbr=0;
if($fileopen2)
{
$contenufichier=fgetcsv($fileopen2);
$nblignes = file($fic);
$vide = "";
$null = null;
$zero = 0;
}
else
{
exit;
echo "\n"."Erreur a l'ouverture du fichier"."\n";
}
if(strstr($nomtable,"commentaires"))
{
// Tant qu'il y a des lignes, lis les et fait en un tableau.
while (($data = fgetcsv($fileopen2,0,';','"')) !== FALSE)
{
####################################################
##### encodage et remplacement du contenu #####
####################################################
$data[4] = str_replace(chr(93), "]", $data[4]); // crochet fermant
$data[4] = str_replace(chr(92), "\\" , $data[4]); // anti slash
$data[4] = str_replace(chr(128), '€', $data[4]); // devise euros
$data[4] = str_replace(chr(130), ',', $data[4]); // baseline single quote
$data[4] = str_replace(chr(132), '"', $data[4]); // baseline double quote
$data[4] = str_replace(chr(133), '...', $data[4]); // ellipsis
$data[4] = str_replace(chr(145), "'", $data[4]); // left single quote
$data[4] = str_replace(chr(146), "'", $data[4]); // right single quote
$data[4] = str_replace(chr(147), '"', $data[4]); // left double quote
$data[4] = str_replace(chr(148), '"', $data[4]); // right double quote
$data[4] = str_replace(chr(150), '', $data[4]); // tiret du 6
$data[5] = str_replace(chr(93), "]", $data[5]); // crochet fermant
$data[5] = str_replace(chr(92), "\\" , $data[5]); // anti slash
$data[5] = str_replace(chr(128), '€', $data[5]); // devise euros
$data[5] = str_replace(chr(130), ',', $data[5]); // baseline single quote
$data[5] = str_replace(chr(132), '"', $data[5]); // baseline double quote
$data[5] = str_replace(chr(133), '...', $data[5]); // ellipsis
$data[5] = str_replace(chr(145), "'", $data[5]); // left single quote
$data[5] = str_replace(chr(146), "'", $data[5]); // right single quote
$data[5] = str_replace(chr(147), '"', $data[5]); // left double quote
$data[5] = str_replace(chr(148), '"', $data[5]); // right double quote
$data[5] = str_replace(chr(150), '', $data[5]); // tiret du 6
$encode = mb_detect_encoding($data[4]); // detection de l'encodage.
$encode = mb_detect_encoding($data[5]); // detection de l'encodage.
$data[4] = mb_convert_encoding($data[4], $encode, 'UTF-8');
$data[5] = mb_convert_encoding($data[5], $encode, 'UTF-8');
// $Zdata4 = '"'.$db->->real_escape_string($data[4]);
// $Zdata4 = $db->quote($data[4]);
//$Zdata4 = mysqli_real_escape_string($db, $data[4]);
if ($data[5] == null)
{
$data[5] = 0;
}
$zdata4= $db->quote($data[4]);
$nbr++;
// ESSAI 1
$sql_insert = array
(
'code' => "$data[0]",
'langue' => "$data[1]",
'cycle' => "$data[2]",
'ligne' => "$data[3]",
'commentaire' => "$data[4]",
'tri' => "$data[5]",
'deleted' => "$null",
'idUser' => "$null",
'dateInsert' => "$null",
'dateUpdate' => "$null"
);
try
{
# $num = count($row); // On compte nombre de parti dans la phrase
# $row++; // à chaques tour de boucle j'ajoute 1 à $row
// ESSAI 2
/*
$sql_itc = $db->query("INSERT INTO $nomtable
(
code, langue, cycle, ligne, commentaire, tri, deleted, idUser, dateInsert, dateUpdate)
VALUES
(
".$data[0].",".$data[1].",".$data[2].",".$data[3].",".$Zdata4.",".$data[5].",'','','',)
");
*/
$db->insert($nomtable, $sql_insert);
//`
// Astuce !! La structure de $data[0] étant un int on retire les "
// Astuce !! La colonne 5 contenant des apostrophs étant interprété par le sql comme un nouveau champ il est necessaire de protéger ce champs, du coup in ajoute la fonction mysql_real_escape_string() pour insérer un antislash devant les caractères " NULL, \x00, \n, \r, \, ', " et \x1a. "
}
// Renseignement sur les erreurs possibles
#echo ("$sql_itt");
catch(Zend_Exception $e)
{
echo "\n" . $e->getMessage()."\n";
//echo "\n"."!!!!!!!!!!!!!!!!!!!!! Import de la table $nomtable echouee. !!!!!!!!!!!!!!!!!!!!!"."\n"."\n";
//$sql_erase = $db->query("DROP TABLE $nomtable;");
//echo "La table $nomtable a ete effacee !! \n ";
}
}
echo "\n"."Import de la table $nomtable . ok". "\n";
// comptage sql
$comptage = count($sql_itc_query);
echo "\n"."Nombre de lignes importees : "."$nbr"."\n";
exit;
}
elseif(strstr($nomtable,"formules"))
{
####################################################
// Création de la Table formules \\
####################################################
try{
$sql_ctf_query = $db->query("CREATE TABLE $nomtable
(
code int(8) NOT NULL DEFAULT '0',
ligne char(4) NOT NULL DEFAULT '',
remarque varchar(120) DEFAULT NULL,
operande varchar(7) DEFAULT NULL,
ope1 varchar(255) DEFAULT NULL,
operation varchar(9) DEFAULT NULL,
valeur varchar(255) DEFAULT NULL,
tri varchar(0) DEFAULT NULL,
deleted varchar(0) DEFAULT NULL,
idUser varchar(0) DEFAULT NULL,
dateInsert varchar(0) DEFAULT NULL,
dateUpdate varchar(0) DEFAULT NULL,
PRIMARY KEY (code,ligne)
)
ENGINE=MyISAM DEFAULT CHARSET=latin1 COMMENT='Criteres Valorisation - Formules de calculs' ;");
}
catch (Zend_Exception $e)
{
echo $e->getMessage()."\n";
echo "\n"."!!!!!!!!!!!!!!!!!!!!! CHARGEMENT ARRETE !!!!!!!!!!!!!!!!!!!!!"."\n"."\n";
}
echo "\n Table $nomtable cree.\n";
// Tant qu'il y a des lignes, lis les et fait en un tableau.
while (($data = fgetcsv($fileopen2,0,';','"')) !== FALSE)
{
####################################################
##### encodage et remplacement du contenu #####
####################################################
$data[2] = str_replace(chr(93), "]", $data[2]); // crochet fermant
$data[2] = str_replace(chr(92), "\\" , $data[2]); // anti slash
$data[2] = str_replace(chr(128), '€', $data[2]); // devise euros
$data[2] = str_replace(chr(130), ',', $data[2]); // baseline single quote
$data[2] = str_replace(chr(132), '"', $data[2]); // baseline double quote
$data[2] = str_replace(chr(133), '...', $data[2]); // ellipsis
$data[2] = str_replace(chr(145), "'", $data[2]); // left single quote
$data[2] = str_replace(chr(146), "'", $data[2]); // right single quote
$data[2] = str_replace(chr(147), '"', $data[2]); // left double quote
$data[2] = str_replace(chr(148), '"', $data[2]); // right double quote
$data[2] = str_replace(chr(150), '', $data[2]); // tiret du 6
$data[4] = str_replace(chr(93), "]", $data[4]); // crochet fermant
$data[4] = str_replace(chr(92), "\\" , $data[4]); // anti slash
$data[4] = str_replace(chr(128), '€', $data[4]); // devise euros
$data[4] = str_replace(chr(130), ',', $data[4]); // baseline single quote
$data[4] = str_replace(chr(132), '"', $data[4]); // baseline double quote
$data[4] = str_replace(chr(133), '...', $data[4]); // ellipsis
$data[4] = str_replace(chr(145), "'", $data[4]); // left single quote
$data[4] = str_replace(chr(146), "'", $data[4]); // right single quote
$data[4] = str_replace(chr(147), '"', $data[4]); // left double quote
$data[4] = str_replace(chr(148), '"', $data[4]); // right double quote
$data[4] = str_replace(chr(150), '', $data[4]); // tiret du 6
$data[5] = str_replace(chr(93), "]", $data[5]); // crochet fermant
$data[5] = str_replace(chr(92), "\\" , $data[5]); // anti slash
$data[5] = str_replace(chr(128), '€', $data[5]); // devise euros
$data[5] = str_replace(chr(130), ',', $data[5]); // baseline single quote
$data[5] = str_replace(chr(132), '"', $data[5]); // baseline double quote
$data[5] = str_replace(chr(133), '...', $data[5]); // ellipsis
$data[5] = str_replace(chr(145), "'", $data[5]); // left single quote
$data[5] = str_replace(chr(146), "'", $data[5]); // right single quote
$data[5] = str_replace(chr(147), '"', $data[5]); // left double quote
$data[5] = str_replace(chr(148), '"', $data[5]); // right double quote
$data[5] = str_replace(chr(150), '', $data[5]); // tiret du 6
$data[6] = str_replace(chr(93), "]", $data[6]); // crochet fermant
$data[6] = str_replace(chr(92), "\\" , $data[6]); // anti slash
$data[6] = str_replace(chr(128), '€', $data[6]); // devise euros
$data[6] = str_replace(chr(130), ',', $data[6]); // baseline single quote
$data[6] = str_replace(chr(132), '"', $data[6]); // baseline double quote
$data[6] = str_replace(chr(133), '...', $data[6]); // ellipsis
$data[6] = str_replace(chr(145), "'", $data[6]); // left single quote
$data[6] = str_replace(chr(146), "'", $data[6]); // right single quote
$data[6] = str_replace(chr(147), '"', $data[6]); // left double quote
$data[6] = str_replace(chr(148), '"', $data[6]); // right double quote
$data[6] = str_replace(chr(150), '', $data[6]); // tiret du 6
$encode = mb_detect_encoding($data[2]); // detection de l'encodage.
$encode = mb_detect_encoding($data[5]); // detection de l'encodage.
$encode = mb_detect_encoding($data[4]); // detection de l'encodage.
$encode = mb_detect_encoding($data[6]); // detection de l'encodage.
$data[2] = mb_convert_encoding($data[2], $encode, 'UTF-8');
$data[4] = mb_convert_encoding($data[4], $encode, 'UTF-8');
$data[5] = mb_convert_encoding($data[5], $encode, 'UTF-8');
$data[6] = mb_convert_encoding($data[6], $encode, 'UTF-8');
$sql_insert = array(
'code' => "$data[0]",
'ligne' => "$data[1]",
'remarque' => "$data[2]",
'operande' => "$data[3]",
'ope1' => "$data[4]",
'operation' => "$data[5]",
'valeur' => "$data[6]",
'tri' => "$null",
'deleted' => "$null",
'idUser' => "$null",
'dateInsert' => "$null",
'dateUpdate' => "$null"
);
$nbr++;
try{
$db->insert($nomtable, $sql_insert);
}
catch (Zend_Exception $e)
{
echo $e->getMessage()."\n";
echo "\n"."!!!!! ERREUR ! / CHARGEMENT ARRETE !!!!!"."\n"."\n";
}
}
echo "\n"." Import de la table $nomtable ok."."\n";
// comptage sql
$comptage = count($sql_insert);
echo "\n"." Nombre de lignes importees : "."$nbr"."\n";
fclose($fileopen2);
exit;
}
// Exécution de la requête
//$result = $db->query($sql_ctt);
// Renseignement sur les erreurs possibles
// echo "<strong>" . $Erreur . "</strong> <br /> <br />\n";
//
// if ($sql_ctt_query) // si code retour OK
// {
// echo "Création de la table $nomtable ok.<br />";
// }
// else
// {
// echo "Création de la table $nomtable échouée.<br />";
// }

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";
}
}
}

View File

@ -1,580 +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.",
'list' => "Liste les actes en attente disponible sur le FTP et affiche les informations",
'get-s' => "Recupère seulement les actes du FTP (un seul document si la référence est spécifier G<NNN> )",
'send-s' => "Récupère les actes et envoi un mail à chaque client (un seul acte si la référence est spécifier G<NNN>)",
'type-s' => "Type de document : bilan, acte",
'control' => "Control",
));
$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 "Vérifie les actes numérisés reçus en provenance des Greffes.";
echo "\n\n";
echo $opts->getUsageMessage();
echo "\n";
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;
if (isset($opts->list)){
$test = true;
}
$types = array('bi', 'ac');
//Configuration FTP
define ('ACTES_IGNUM_FTP_URL', '192.168.3.202');
define ('ACTES_IGNUM_FTP_USER', 'mpc2500');
define ('ACTES_IGNUM_FTP_PASS', 'passmpc78');
define ('ACTES_IGNUM_LOCAL_DIR', $c->profil->path->shared.'/files/');
define ('PATH_DATA', $c->profil->infogreffe->storage->path);
$report_email = $c->profil->mail->email->support;
$report_subject = 'Traitement des actes '.date('Y-m-d H:i:s');
$report_txt = '';
function sendMail($commande, $type){
$subject = "Actes ou Statuts disponible pour ".$commande->raisonSociale.' ('.$commande->siren.')';
$message = "Bonjour,\n\n";
$message.= "Le document commandé pour ".$commande->raisonSociale." (siren ".$commande->siren.") est disponible en téléchargement sur le site de Scores & Décisions.\r\n\r\n";
if ($commande->refClient!='') {
$message = "Votre référence : ".$commande->refClient."\r\n\r\n";
}
switch ( $type ) {
case 'BI':
$dateBilan = substr($commande->bilanCloture,8,2).'/'.substr($commande->bilanCloture,5,2).'/'.substr($commande->bilanCloture,0,4);
$message.= "Bilan cloturé le ".$dateBilan;
break;
case 'AC':
$dateActe = substr($commande->acteDate,8,2).'/'.substr($commande->acteDate,5,2).'/'.substr($commande->acteDate,0,4);
$dateDepot = substr($commande->depotDate,8,2).'/'.substr($commande->depotDate,5,2).'/'.substr($commande->depotDate,0,4);
$message.= "Acte n°".$commande->acteNum." du ".$dateActe." (Dépot n°".$commande->depotNum." du ".$dateDepot.") ";
break;
}
$message.= "\n\n";
$message.= "Consulter la fiche identité http://extranet.scores-decisions.com/identite/fiche/siret/".$commande->siren.", puis rubrique \"Pieces Officielles\"\n";
$message.= "ou directement depuis la page suivante http://extranet.scores-decisions.com/pieces";
switch ( $type ) {
case 'BI':
$message.= "/bilans/siret/".$commande->siren;
break;
case 'AC':
$message.= "/actes/siret/".$commande->siren;
break;
}
$message.= "\n\n";
$message.= "Bien cordialement, \n";
$message.= "Le service support.\n";
$message.= "\n";
$message.= "--";
$message.= "\n\n";
$message.= "SCORES & DECISIONS";
$message.= "\n";
$message.= "Service support";
$message.= "\n";
$message.= "1, rue de Clairefontaine - 78120 RAMBOUILLET";
$message.= "\n";
$message.= "tél : 0 811 261 216";
$message.= "\n";
$message.= "fax : 33 (0)1 75 43 85 74";
$message.= "\n";
$message.= "support@scores-decisions.com";
$message.= "\n";
$message.= "http://www.scores-decisions.com/";
$message.= "\n";
$message.= "Scores & Décisions est l'acteur nouvelle génération de l'information et de l'évaluation des entreprises";
$message.= "\n\n";
$message.= "Pensez à l'environnement avant d'imprimer ce message !";
$message.= "\n";
$message.= "Save paper - think before you print";
$message.= "\n";
$headers = 'From: infoslegales@scores-decisions.com' . "\r\n" .
'Reply-To: infoslegales@scores-decisions.com';
if ( mail(strtolower($commande->email), $subject, utf8_decode($message), $headers) ){
echo date ('Y/m/d - H:i:s').' - Un email a été envoyé à '.$commande->email." pour la commande ".$commande->id.".\n";
return true;
} else {
echo date ('Y/m/d - H:i:s').' - ERREUR : Impossible d\'envoyer l\'email à '.$commande->email." pour la commande ".$commande->id.".\n";
return false;
}
}
/**
* Connexion à la base de données
*/
$db = Zend_Db::factory($c->profil->db->metier);
Zend_Db_Table_Abstract::setDefaultAdapter($db);
/**
* List actes files and check if an entry exist in the database
* greffes/actes/AAAA/MM
* preg_match('/^acte-([0-9]{9})-(ST)-([0-9]{8})-.*\.pdf/', $fichier, $matches)
* preg_match('/^acte-([0-9]{9})-([0-9a-zA-Z]{1,})-([0-9]{8})-.*-([0-9]{2})\.pdf/', $fichier, $matches)
*/
if ($opts->control) {
$dir = PATH_DATA.'/greffes/actes';
if (is_dir($dir)) {
if ($dh = opendir($dir)) {
//Annee
while (($anneeDir = readdir($dh)) !== false) {
if ($anneeDir != '.' || $anneeDir != '..') {
echo "Dir ".$dir . DIRECTORY_SEPARATOR . $anneeDir."\n";
if ($dhAnneeDir = opendir($dir . DIRECTORY_SEPARATOR . $anneeDir)) {
//Mois
while (($moisDir = readdir($dhAnneeDir)) !== false) {
echo "Dir ".$dir . DIRECTORY_SEPARATOR . $anneeDir . DIRECTORY_SEPARATOR . $moisDir."\n";
if ($moisDir != '.' || $moisDir != '..') {
//Fichier
if ($dhFile = opendir($dir . DIRECTORY_SEPARATOR . $anneeDir . DIRECTORY_SEPARATOR . $moisDir)) {
while (($file = readdir($dhFile)) !== false) {
if ($file != '.' || $file != '..') {
if (preg_match('/^acte-([0-9]{9})-([0-9a-zA-Z]{1,})-([0-9]{8})-.*-([0-9]{2})\.pdf/', $file, $matches)) {
$siren = $matches[1];
$type = $matches[2];
$date = $matches[3];
$num = $matches[4];
$actesM = new Application_Model_ActesFiles();
$sql = $actesM->select()
->where('siren=?', $siren)
->where('type=?', $type)
->where('date=?', $date)
->where('num=?', $num);
$result = $actesM->fetchRow($sql);
if ( null === $result ) {
echo "Insert $file\n";
$actesM->insert(array(
'siren' => $siren,
'type' => $type,
'date' => $date,
'num' => $num,
'file' => $file,
));
}
}
}
}
closedir($dhFile);
}
}
}
closedir($dhAnneeDir);
}
}
}
closedir($dh);
}
}
exit;
}
/**
* Liste des commandes non traités depuis la base de données
*/
$acM = new Application_Model_Sdv1GreffeCommandesAc();
$biM = new Application_Model_Sdv1GreffeCommandesBi();
$tabCommandes = array();
if (in_array('ac', $types)) {
$sql = $acM->select()
->where('mode=?','C')
->where('dateCommande!=?', '0000-00-00 00:00:00')
->where('dateEnvoi=?', '0000-00-00 00:00:00');
$rows = $acM->fetchAll($sql);
if (count($rows)>0) {
foreach ($rows as $row) {
$tabCommandes['G-AC-'.$row->id] = $row;
}
}
}
if (in_array('bi', $types)) {
$sql = $biM->select()
->where('mode=?','C')
->where('dateCommande!=?', '0000-00-00 00:00:00')
->where('dateEnvoi=?', '0000-00-00 00:00:00');
$rows = $biM->fetchAll($sql);
if (count($rows)>0) {
foreach ($rows as $row) {
$tabCommandes['G-BI-'.$row->id] = $row;
}
}
}
$nbCommandes = count($tabCommandes);
echo date('Y/m/d - H:i:s') ." - Il y a $nbCommandes commandes en attente de réception courrier ou numérisation !\n";
/**
* Connexion au site FTP pour la récupération de la liste des fichiers au format pdf
*/
$conn_id = ftp_connect(ACTES_IGNUM_FTP_URL);
if (!$conn_id) {
echo date ('Y/m/d - H:i:s')." - ERREUR : Impossible de se connecter au serveur FTP (".ACTES_IGNUM_FTP_URL.") !\n";
exit;
}
$login_result = ftp_login($conn_id, ACTES_IGNUM_FTP_USER, ACTES_IGNUM_FTP_PASS);
if (!$login_result) {
echo date ('Y/m/d - H:i:s')." - ERREUR : Impossible de s'authentifier sur le serveur FTP (".ACTES_IGNUM_FTP_URL.")!\n";
exit;
}
$contents = ftp_nlist($conn_id, "*.pdf");
/**
* Liste de tout les fichiers disponible dans le repertoire
* et associe une clé pour faciliter le tri
*/
$tabFichiersFtp = array();
foreach ($contents as $filename){
$indice = 0;
$f = strtolower($filename);
if (preg_match('/g-(ac|bi)-[0-9]+\.pdf/', $f)
|| preg_match('/g-(ac|bi)-[0-9]+-[0-9]{1,2}\.pdf/', $f)){
$part = substr(str_replace('.pdf', '', $f), 5);
$p = strpos($part, '-');
if ( $p === false ) {
$ref = substr($f, 0, 5) . $part;
$indice = 0;
} else {
$ref = substr($f, 0, 5) . substr($part, 0, $p);
$indice = substr($part, $p+1);
}
$tabFichiersFtp[strtoupper($ref).'-'.$indice] = $filename;
// Fichiers en anomalies
} else {
if ($test){
echo "Erreur : Anomalie fichier numérisé $filename\n";
} else {
$subject = "Erreur : Anomalie fichier numérisé";
$message = "Le fichier $filename a été trouvé et ne correspond pas au format attendu";
$headers = 'From: supportdev@scores-decisions.com' . "\r\n" .
'Reply-To: supportdev@scores-decisions.com';
mail('supportdev@scores-decisions.com', $subject, $message, $headers);
}
}
}
/**
* Tri des fichiers par ordre décroissant
* Les noms des fichiers sont incrémenté par 1
*/
krsort($tabFichiersFtp);
/**
* Dans le cas ou il y a eu une erreur de scan, la production passe a nouveau le
* document dans le scanner et le fichier est envoyé sur le ftp
* Le document est nommé G[ref],G[ref]-1,G[ref]-2,.....pdf.
* On garde donc le dernier document scanné.
*/
$lastRef = '';
$tabFichiersTemp = array();
foreach($tabFichiersFtp as $k => $val)
{
$part = substr($k, 5);
$p = strpos($part, '-');
if ( $p === false ) {
$ref = substr($k, 0, 5) . $part;
} else {
$ref = substr($k, 0, 5) . substr($part, 0, $p);
}
if( $lastRef != $ref ) {
$tabFichiersTemp[$ref] = $val;
}
$lastRef = $ref;
}
$tabFichiers = $tabFichiersTemp;
unset($tabFichiersTemp);
/**
* Pour chaque commande, test de la présence d'un fichier associé
* Si le fichier correspond téléchargement du fichier
*/
foreach ( $tabCommandes as $ref => $commande ) {
foreach ( $tabFichiers as $refAssocie => $fichier ) {
if ( $ref == $refAssocie ) {
echo date ('Y/m/d - H:i:s')." - Traitement de la commande $ref\n";
if ( $test ) {
echo date ('Y/m/d - H:i:s')." - Fichier $fichier \n";
} else {
// Récupération du fichier depuis le FTP (s'il n'existe pas déjà)
if ( !file_exists(ACTES_IGNUM_LOCAL_DIR.$fichier) ) {
if (ftp_get($conn_id, ACTES_IGNUM_LOCAL_DIR.$fichier, $fichier, FTP_BINARY, 0)) {
echo date ('Y/m/d - H:i:s')." - Fichier $fichier téléchargé depuis le serveur FTP.\n";
} else {
echo date ('Y/m/d - H:i:s')." - ERREUR : Impossible de télécharger le fichier $fichier !\n";
}
}
switch ( substr($ref,2,2) ) {
case 'BI':
$infogreffe = new Metier_Infogreffe_DocBI();
$infogreffe->setSiren($commande->siren);
//Format date cloture
$dateCloture = substr($commande->bilanCloture,0,4) . '-' .
substr($commande->bilanCloture,5,2) . '-' .
substr($commande->bilanCloture,8,2);
$path = $infogreffe->getFilePath($commande->bilanType, $dateCloture);
$nomCible = $infogreffe->getFileName($commande->bilanType, $dateCloture);
$fileOut = PATH_DATA.'/'.$path.'/'.$nomCible;
$isFileOnStorage = false;
if ( file_exists($fileOut) ) {
$isFileOnStorage = true;
echo date ('Y/m/d - H:i:s')." - Fichier ".ACTES_IGNUM_LOCAL_DIR.$fichier." déjà présent en ".$fileOut.".\n";
} else {
if ( copy(ACTES_IGNUM_LOCAL_DIR.$fichier, $fileOut) ) {
$isFileOnStorage = true;
echo date ('Y/m/d - H:i:s')." - Fichier ".ACTES_IGNUM_LOCAL_DIR.$fichier." déplacé en ".$fileOut.".\n";
} else {
echo date ('Y/m/d - H:i:s')." ERREUR - Impossible de déplacer ".ACTES_IGNUM_LOCAL_DIR.$fichier." en ".$fileOut." !\n";
}
}
// --- 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' ) {
$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();
}
}
}
break;
case 'AC':
$acteM = new Application_Model_JoGreffesActes();
$sql = $acteM->select()
->from($acteM, array(
'id',
'siren',
'numRC',
'LPAD(numGreffe,4,0) AS numGreffe',
'pdfLink',
'pdfSize',
'pdfPage',
'pdfDate',
'num_depot',
'date_depot',
'date_acte',
'LPAD(num_acte,2,0) AS num_acte',
'type_acte',
'type_acte_libelle',
'nbpages_acte',
'decision_nature',
'decision_libelle',
'mode_diffusion'
))
->where('siren=?', $commande->siren)
->where('num_depot=?', $commande->depotNum)
->where('num_acte=?', $commande->acteNum)
->where('type_acte=?',$commande->acteType);
$item = $acteM->fetchRow($sql);
$infogreffe = new Metier_Infogreffe_DocAC();
$infogreffe->setSiren($commande->siren);
$date = $commande->acteDate;
if ( $date == '0000-00-00' ) {
$date = $commande->depotDate;
}
$path = $infogreffe->getFilePath($date);
//(Numéro du Greffe)-(dossier_millesime)-(dossier_statut)-(dossier_chrono)-(num_depot)
$options = $item->numGreffe . '-' . substr($item->numRC,0,2) . '-' . substr($item->numRC,2,1) . '-' . substr($item->numRC,3) . '-' . $item->num_depot;
$nomCible = $infogreffe->getFileName($date, $commande->acteNum, $commande->acteType, $options);
$fileOut = PATH_DATA.'/'.$path.'/'.$nomCible;
$isFileOnStorage = false;
if ( file_exists($fileOut) ) {
$isFileOnStorage = true;
echo date ('Y/m/d - H:i:s')." - Fichier ".ACTES_IGNUM_LOCAL_DIR.$fichier." déjà présent en ".$fileOut.".\n";
} else {
if ( copy(ACTES_IGNUM_LOCAL_DIR.$fichier, $fileOut) ) {
$isFileOnStorage = true;
echo date ('Y/m/d - H:i:s')." - Fichier ".ACTES_IGNUM_LOCAL_DIR.$fichier." déplacé en ".$fileOut.".\n";
} else {
echo date ('Y/m/d - H:i:s')." ERREUR - Impossible de déplacer ".ACTES_IGNUM_LOCAL_DIR.$fichier." en ".$fileOut." !\n";
}
}
if ( $isFileOnStorage && $item->pdfDate == '0000-00-00' ) {
$infos = $infogreffe->pdfInfos($fileOut);
if ( false !== $infos ) {
$data = array(
'pdfLink' => $nomCible,
'pdfSize' => $infos['size'],
'pdfPage' => $infos['pages'],
'pdfVer' => $infos['version'],
'pdfDate' => date('Ymd'),
);
try {
$result = $acteM->update($data, 'id='.$item->id);
echo " = enregistrement.\n";
} catch(Zend_Db_Adapter_Exception $e) {
echo $e->getMessage();
} catch(Zend_Db_Exception $e) {
echo $e->getMessage();
}
}
}
break;
}
//Envoi du mail et Mise à jour de la commande
if ( file_exists($fileOut) ) {
if ( $testMail ) {
echo "Envoi fichier $nomCible ($ref) à ".$commande->email;
} else {
$report_txt.= "$ref intégré à l'extranet";
$isMailSent = false;
if (trim($commande->email)!=''){
$isMailSent = sendMail($commande, substr($ref,2,2));
} else {
$isMailSent = true;
}
if ( $isMailSent ) {
$data = array( 'dateEnvoi' => date('YmdHis'));
switch ( substr($ref,2,2) ) {
case 'BI':
$commandesM = new Application_Model_Sdv1GreffeCommandesBi();
break;
case 'AC':
$commandesM = new Application_Model_Sdv1GreffeCommandesAc();
break;
}
$commandesM->update($data, 'id='.$commande->id);
echo date ('Y/m/d - H:i:s')." - Commande $ref mise à jour\n";
$report_txt.= ' - Email envoyé à '.$commande->email;
} else {
$report_txt.= ' - Email non envoyé !';
echo date ('Y/m/d - H:i:s')." ERREUR - Email non envoyé et commande $ref non mise à jour\n";
}
$report_txt.= "\n";
}
} // Fin envoi mail
}
} // Fin condition ref
}
}
ftp_close($conn_id);
if (empty($report_txt)) {
$report_txt = "Aucun envoi.";
}
//Envoi du mail de rapport
if (!$test && !$testMail){
if (mail($report_email, $report_subject, utf8_decode($report_txt))){
echo date ('Y/m/d - H:i:s')." - Rapport envoyé.\n";
} else {
echo date ('Y/m/d - H:i:s')." - Erreur lors de l'envoir du rapport !\n";
}
}
?>

View File

@ -1,613 +0,0 @@
#!/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');
// --- Options
$displayUsage = false;
try {
$opts = new Zend_Console_Getopt(
//Options
array(
'help|?' => "Affiche l'aide.",
'siren=s' => "Commander un kbis",
'commandes' => "Liste les commandes passees (Reference), si reference alors recupere le kbis",
'visu=s' => "Telechargement du kbis avec une reference (--commandes obligatoire)",
'debug' => "Mode debug",
)
);
$opts->parse();
} catch (Zend_Console_Getopt_Exception $e) {
$displayUsage = true;
}
// --- Aide / Options
if (count($opts->getOptions())==0 || isset($opts->help)) {
$displayUsage = true;
}
// --- Usage
if ($displayUsage) {
echo "Telecharge le kbis chez infogreffe.";
echo "\n\n";
echo $opts->getUsageMessage();
echo "\n";
exit;
}
$c = new Zend_Config($application->getOptions());
Zend_Registry::set('config', $c);
if ( isset($opts->debug) ) {
define('DEBUG', true);
} else {
define('DEBUG', false);
}
function getPageHeader($start,$end,$header)
{
$pattern = '/'. $start .'(.*)'. $end .'/';
if (preg_match($pattern, $header, $result)) {
return $result[1];
} else {
return false;
}
}
function getPage($url, $curl_data = '', $override = null)
{
global $ckfile;
//$user_agent = 'Mozilla/5.0 (Windows NT 5.1; rv:9.0.1) Gecko/20100101 Firefox/9.0.1';
//$user_agent = 'Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)';
$user_agent = 'Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0)';
$verbose = false;
$post = false;
$fields = '';
if (is_array($curl_data) && count($curl_data)>0) {
foreach($curl_data as $key=>$value) {
$fields .= $key.'='.$value.'&';
}
rtrim($fields,'&');
$post = true;
}
$options = array(
CURLOPT_RETURNTRANSFER => true, // return web page
CURLOPT_HEADER => false, // don't return headers
CURLOPT_FOLLOWLOCATION => false, // follow redirects
CURLOPT_ENCODING => "", // handle all encodings
CURLOPT_USERAGENT => $user_agent, // who am i
CURLOPT_AUTOREFERER => true, // set referer on redirect
CURLOPT_CONNECTTIMEOUT => 120, // timeout on connect
CURLOPT_TIMEOUT => 120, // timeout on response
CURLOPT_MAXREDIRS => 10, // stop after 10 redirects
CURLOPT_POST => $post, // i am sending post data
CURLOPT_POSTFIELDS => $fields, // this are my post vars
CURLOPT_SSL_VERIFYHOST => 0, // don't verify ssl
CURLOPT_SSL_VERIFYPEER => false, //
CURLOPT_VERBOSE => $verbose , //
//CURLOPT_COOKIESESSION => true,
CURLOPT_COOKIEFILE => $ckfile,
CURLOPT_COOKIEJAR => $ckfile, // Stockage du cookie de session
);
//Override define CURL option
if (is_array($override) && count($override)>0 ) {
$options = $override + $options;
}
$ch = curl_init($url);
curl_setopt_array($ch,$options);
$content = curl_exec($ch);
$err = curl_errno($ch);
$errmsg = curl_error($ch) ;
$header = curl_getinfo($ch);
curl_close($ch);
//Rewrite encoding to UTF-8
//text/html; charset=ISO-8859-1
//$encoding = getPageHeader('text\/html; charset=', '', $header['content_type']);
//$encoding = 'ISO-8859-1';
//$content = iconv($encoding, 'UTF-8//TRANSLIT', $content);
// $header['errno'] = $err;
// $header['errmsg'] = $errmsg;
// $header['content'] = $content;
return array('header'=>$header, 'content'=>$content);
}
/**
* Retourne l'url après une page 302
* @param string $content
* @return string|boolean
*/
function getUrl302($content)
{
$url = false;
preg_match('/\<title\>(.*)\<\/title\>/', $content, $matches);
if ($matches[1]=='302 Moved Temporarily') {
preg_match('/\<a href="(.*)"\>/', $content, $matches);
$url = $matches[1];
}
return $url;
}
//Define Main URL
$siteUrl = "https://www2.infogreffe.fr";
function infogreffeConnexion()
{
global $siteUrl;
$url = $siteUrl . "/infogreffe/index.jsp";
$result = getPage($url);
if (DEBUG) file_put_contents('kbis-connexion1.html', $result['content']);
$url = $siteUrl . "/infogreffe/popupLog.jsp?type=0&url=index.jsp";
$result = getPage($url);
if (DEBUG) file_put_contents('kbis-connexion2.html', $result['content']);
$url = $siteUrl . "/infogreffe/login.do?redirect=index.jsp";
// 302 Moved Temporarily
// => http://www.infogreffe.fr/infogreffe/index.jsp
$data = array(
'codeAbo'=>'2559',
'codeClt'=>'0041',
'log'=>'',
'pwd'=>'69873',
);
$result = getPage($url, $data);
if (DEBUG) file_put_contents('kbis-connexion3.html', $result['content']);
/*
We need to have
<div style="margin-top:2px; *margin-top:0px;" class="identBar">
<span class="name">Abonn&eacute;</span> |
<a href="/infogreffe/jsp/information/monCompte.jsp">Mon compte</a> |
<a href="/infogreffe/afficherMesAchats.do?refCde=N">Documents Command&eacute;s</a>
| <a href="/infogreffe/deconnexion.do">Se d&eacute;connecter</a>
</div>
*/
}
function infogreffeKbis($ref)
{
global $siteUrl;
/**************************************************
afficheProduit
**************************************************/
$url = $siteUrl . "/infogreffe/chargement.jsp?oups=".$ref."_0_V_0_";
$result = getPage($url);
if (DEBUG) file_put_contents('kbis-afficheproduit.html', $result['content']);
//Redirection javascript qui fait patienter
sleep(1);
/**************************************************
serviceProduit
**************************************************/
$url = $siteUrl . "/infogreffe/serviceProduit.do?cdePro=".$ref."_0_V_0_";
$result = getPage($url);
if (DEBUG) file_put_contents('kbis-serviceproduit.html', $result['content']);
$output = $result['content'];
//Modification du code HTML pour impression
$output = removeTag('script', $output, true, true);
$output = str_replace('/infogreffe/styles/infogreffe_base.css', '../styles/infogreffe_base.css', $output);
$output = str_replace('/infogreffe/styles/infogreffe.css', '../styles/infogreffe.css', $output);
$output = preg_replace(
'/\<body onload="adapterDimensions(\'conteneur\');" class="simple preventSelection" style="background-color: rgb(241, 241, 241);">/',
'<body class="simple preventSelection" style="background-color: rgb(241, 241, 241);">',
$output
);
//Récupération des informations dans le kbis
//<td align="left" valign="top" class="label">Numéro d'identification :</td><td>509 536 371 R.C.S. PONTOISE</td>
preg_match('/([0-9]{3}\s[0-9]{3}\s[0-9]{3})\sR\.C\.S\./', $output, $matches);
if (count($matches)>1){
$identifiant = str_replace(' ', '',$matches[1]);
} else {
$identifiant = 'unknown';
}
$fichier = $identifiant . '-' . $ref . '.html';
global $c;
$dir = realpath($c->profil->path->shared).'/datafile/kbis/'.date('Ymd');
if (!file_exists($dir)) mkdir($dir);
file_put_contents($dir . '/' . $fichier, $output);
return ($identifiant!='unknown') ? $identifiant : false;
}
function removeTag($balise, $content, $endOfTag = true, $removeContent = true)
{
if( $endOfTag )
{
if( $removeContent)
$output = preg_replace(
'@<'.$balise.'[^>]*?>.*?</'.$balise.'>@si',
'',
$content
);
else
$output = preg_replace(
array('@<'.$balise.'[^>]*?>@', '@</'.$balise.'>@'),
'',
$content
);
}
else
{
$output = preg_replace(
'@<'.$balise.'[^>]*?>@',
'',
$content
);
}
return $output;
}
function parseRef($document)
{
$doc = new DOMDocument();
$doc->strictErrorChecking = false;
$doc->preserveWhiteSpace = false;
@$doc->loadHTML($document);
$xpath = new DOMXpath($doc);
//Recherche des infos de la première commande
$nodelist = $xpath->query("//a/img[@alt='visualiser']");
foreach ($nodelist as $n){
$href = $n->parentNode->getAttribute('href');
preg_match("/javascript:afficheProduit\(\'(.*)_0_V_0_\'/", $href, $matches);
$ref = $matches[1];
}
//Recherche Raison Sociale
$nodelist = $xpath->query("//span[@class='text-company']/a");
foreach ($nodelist as $n){
$rs = $n->nodeValue;
break;
}
//Recherche RCS
$nodelist = $xpath->query("//span[@class='text-rcs']");
foreach ($nodelist as $n){
$rcs = $n->nodeValue;
break;
}
return array(
'ref' => $ref,
'rs' => $rs,
'rcs' => $rcs,
);
}
//Define cookie file for storage
//@todo : Faire en sorte d'utiliser le cookie pendant un temps déterminé, ou nouvelle session à chaque fois
$ckfile = __DIR__.'/'.uniqid('cookie-');
if (file_exists($ckfile)) unlink($ckfile);
// Récupération de la liste des commandes et
if ( $opts->commandes )
{
$referer = '';
/**************************************************
Connexion
**************************************************/
infogreffeConnexion();
$url = $siteUrl . "/infogreffe/jsp/information/monCompte.jsp";
$result = getPage($url);
if (DEBUG) file_put_contents('kbis-moncompte.html', $result['content']);
/**************************************************
Documents commandés
**************************************************/
$url = $siteUrl . "/infogreffe/afficherMesAchats.do?refCde=N";
$result = getPage($url);
if (DEBUG) file_put_contents('documents.html', $result['content']);
//On parse le document pour trouver les références de commandes
$refs = array();
$tmp = parseRef($result['content']);
$refs[] = $tmp;
//Liste des commandes
$nodelist = $xpath->query("//a[@class='folded-fond-gris']");
foreach ($nodelist as $n){
$href = $n->getAttribute('href');
preg_match("/javascript:reveal\(\'(.*)\'\)/", $href, $matches);
$refs[] = array( 'ref' => $matches[1] );
}
$listeRef = array();
foreach($refs as $item){
$listeRef[] = $item['ref'];
}
if ( $opts->visu && in_array($opts->visu, $listeRef) )
{
//Pour toutes les commandes en dehors de la toute dernière
if ( array_search($opts->visu, $listeRef)!=0 ){
$url = $siteUrl . "/infogreffe/chargerContenuCommande.do?refCde=".$opts->visu."&_=";
$result = getPage($url);
if (DEBUG) file_put_contents('documents-'.$ref['ref'].'.html', $result['content']);
}
echo "Téléchargement du kbis...\n";
infogreffeKbis($opts->visu);
} elseif ( !$opts->visu ) {
/**************************************************
Reveal : Ajax pour mettre à jour le div
**************************************************/
// Parcourir le fichier précédent et relevé toute les références de commandes
// http://www.infogreffe.fr/infogreffe/chargerContenuCommande.do?refCde=XNDAE&_=
// Dans javascript la requete est réalisé en GET
$i = 0;
foreach ( $refs as $ref )
{
if ($i!=0){
$url = $siteUrl . "/infogreffe/chargerContenuCommande.do?refCde=".$ref['ref']."&_=";
$result = getPage($url);
if (DEBUG) file_put_contents('documents-'.$ref['ref'].'.html', $result['content']);
//@todo : Recup des informations
$info = array();
$info = parseRef($document);
}
echo $ref['ref'];
if ( $info['ref']==$ref['ref'] ) {
if ( !empty($info['rs']) ) echo " ".$info['rs'];
if ( !empty($info['rcs']) ) echo " ".$info['rcs'];
}
echo "\n";
$i++;
}
}
}
// Commande d'un kbis
if ( $opts->siren )
{
//Vérification du siren
if (strlen($opts->siren)!=9 && strlen($opts->siren)!=14) {
echo "Erreur SIREN invalide\n"; exit;
}
$referer = '';
/**************************************************
Connexion
**************************************************/
infogreffeConnexion();
/**************************************************
Affichage formulaire
**************************************************/
$url = $siteUrl . "/infogreffe/index.jsp";
$result = getPage($url);
if (DEBUG) file_put_contents('kbis1.html', $result['content']);
/**************************************************
Soumission formulaire
**************************************************/
$fields = array(
'commune' => '',
'denomination' => '',
'departement' => '',
//'elargirSecondaire' => 'on',
'elargirRadie' => 'on',
'siren' => $opts->siren,
);
$url = $siteUrl . "/infogreffe/newRechercheEntreprise.xml";
$result = getPage($url, $fields);
if (DEBUG) file_put_contents('kbis2.html', $result['content']);
// 302 Moved Temporarily - But we always use this URL
$url = $siteUrl . '/infogreffe/entrepRech.do';
/**************************************************
Affichage identite entreprise
**************************************************/
//url defini plus haut
$result = getPage($url, '', array(CURLOPT_FOLLOWLOCATION => true));
if (DEBUG) file_put_contents('kbis3.html', $result['content']);
/*
* !! Attention !! Elargir aux radiés peut retourner plusieurs résultats
*/
$doc = new DOMDocument();
$doc->strictErrorChecking = false;
$doc->preserveWhiteSpace = false;
@$doc->loadHTML($result['content']);
$xpath = new DOMXpath($doc);
$nodelist = $xpath->query("//div[@id='includeEntrepListe']");
if ($nodelist->length>0) {
$entries = $xpath->query("//a[@class='company']");
foreach ($entries as $n) {
$url = $siteUrl . $n->getAttribute('href');
break;
}
$result = getPage($url);
}
/*
* Try to detect we can pass an order, else send message and exit
*
* Si la recherche a fonctionné
* div[@id="libelleRcsGreffe"], nodeValue = "552 144 503 R.C.S. PARIS"
*
* Si pas de résultats lors de la recherche alors
* table[@class='liste-res-rech']/tbody/tr[1]/td[1]/div/span[1]
*/
$doc = new DOMDocument();
$doc->strictErrorChecking = false;
$doc->preserveWhiteSpace = false;
@$doc->loadHTML($result['content']);
$xpath = new DOMXpath($doc);
$nodelist = $xpath->query("//div[@id='libelleRcsGreffe']");
if ($nodelist->length==0) {
$entries = $xpath->query("//table[@class='liste-res-rech']/tbody/tr[1]/td[1]/div/span");
if ($entries->length>0) {
echo trim($entries->item(0)->nodeValue);
} else {
echo "ERREUR";
}
if (file_exists($ckfile)) unlink($ckfile);
exit;
}
/*
* Si les documents sont disponibles
* <a onclick="reveal('kbis');return false" href="#" id="a_kbis" class="folded">Extrait RCS (Kbis)</a>
*
* Sinon rechercher la valeur du message
* "//div[@id='conteneur']/table/tbody/tr/td/table/tbody/tr[2]/td/table[2]/tbody/tr[last()-2]/td";
*/
$nodelist = $xpath->query("//a[@id='a_kbis']");
if ($nodelist->length==0) {
$div = $xpath->query("//div[@id='conteneur']");
$context = $div->item(0);
$entries = $xpath->query("table/tbody/tr/td/table/tbody/tr[2]/td/table[2]/tbody/tr[9]/td", $context);
if ($entries->length!=0) {
$message = $entries->item(0)->nodeValue;
echo trim($message);
} else {
$entries = $xpath->query("//span[@class='texte-standard']", $context);
if ($entries->length!=0) {
$message = $entries->item(0)->nodeValue;
echo trim($message);
}
}
if (file_exists($ckfile)) unlink($ckfile);
exit;
}
// 302 Moved Temporarily
//http://www.infogreffe.fr/infogreffe/entrepListe.do?index=rcs
if ( $result['header']['http_code']=='302' && array_key_exists('redirect_url', $result['header']) ) {
$url = $result['header']['redirect_url'];
$result = getPage($url);
if (DEBUG) file_put_contents('kbis3-1.html', $result['content']);
// => /infogreffe/getEntrepDetail.do?docId=780308B042410000
$doc = new DOMDocument();
$doc->strictErrorChecking = false;
$doc->preserveWhiteSpace = false;
@$doc->loadHTML($result['content']);
$xpath = new DOMXpath($doc);
$nodelist = $xpath->query("//a[@class='company']");
foreach ($nodelist as $n) {
$url = $siteUrl . $n->getAttribute('href');
break;
}
$result = getPage($url);
if (DEBUG) file_put_contents('kbis3-2.html', $result['content']);
} elseif ( $result['header']['http_code']=='302' ) {
$url = $siteUrl . '/weblogic/infogreffe/entrepListe.do?index=rcs';
$result = getPage($url);
if (DEBUG) file_put_contents('kbis3-1.html', print_r($result,1));
$doc = new DOMDocument();
$doc->strictErrorChecking = false;
$doc->preserveWhiteSpace = false;
@$doc->loadHTML($result['content']);
$xpath = new DOMXpath($doc);
$nodelist = $xpath->query("//a[@class='company']");
foreach ($nodelist as $n) {
$url = $siteUrl . $n->getAttribute('href');
break;
}
$result = getPage($url);
if (DEBUG) file_put_contents('kbis3-2.html', $result['content']);
}
$fields = array();
//Recherche des infos pour la validation du formulaire
$doc = new DOMDocument();
$doc->strictErrorChecking = false;
$doc->preserveWhiteSpace = false;
@$doc->loadHTML($result['content']);
$xpath = new DOMXpath($doc);
$nodelist = $xpath->query("//form[@name='FicheEntrepriseForm']/div[@id='conteneur']/input[@type='hidden']");
foreach ($nodelist as $n) {
$key = $n->getAttribute('name');
$value = $n->getAttribute('value');
$fields[$key] = $value;
}
$fields['montantTotalSelection'] = '5.44'; // 3.11 + 2.33
$fields['extraitForm.visualisation'] = 'on'; // => Définit par javascript
$fields['extraitForm.formVisible'] = 'true';
$fields['extraitForm.envoiPeriodiqueForm.periodicite'] = '1';
$fields['extraitForm.envoiPeriodiqueForm.duree'] = '12';
$fields['etatEndettementForm.formVisible'] = 'true';
$fields['etatEndettementForm.etatComplet'] = 'false';
$fields['listeActesForm.formVisible'] = 'true';
$fields['historiqueModificationsForm.formVisible'] = 'true';
$fields['historiqueModificationsForm.tri'] = '0';
$fields['procedureCollectiveForm.formVisible'] = 'true';
$fields['dossierCompletForm.formVisible'] = 'true';
if (DEBUG) print_r($fields);
/**************************************************
Validation de la selection
**************************************************/
$url = $siteUrl . "/infogreffe/validerSelectionFicheEntreprise.xml";
$result = getPage($url, $fields);
if (DEBUG) file_put_contents('kbis4.html', print_r($result,1));
/**************************************************
Valider la commande
**************************************************/
$url = $siteUrl . "/infogreffe/validerPanierAbonne.do?forcerSaisieCoordonnees=false";
$fields = array();
$result = getPage($url, $fields);
if (DEBUG) file_put_contents('kbis5.html', $result['content']);
/**************************************************
Afficher mes achats et prendre la première commande
**************************************************/
$url = $siteUrl . "/infogreffe/afficherMesAchats.do?refCde=N&pageAppel=validerPanier";
$fields = array();
$result = getPage($url, $fields);
if (DEBUG) file_put_contents('kbis6.html', $result['content']);
$info = parseRef($result['content']);
$ref = $info['ref'];
/**************************************************
Visualiser
**************************************************/
$identifiant = infogreffeKbis($ref);
//Suppression fichier
if (file_exists($ckfile)) unlink($ckfile);
if ($identifiant===false || $identifiant!=substr($opts->siren,0,9)) {
echo "ERREUR";
exit;
}
echo $identifiant.'-'.$ref.'.html';
}

View File

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

View File

@ -1,77 +0,0 @@
<?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
$displayUsage = false;
try {
$opts = new Zend_Console_Getopt(array(
'help|?' => 'Displays usage information.',
'all' => 'Execute toutes les actions (cron).',
'type=w' => 'Supprime uniquement les fichiers indiqués.',
));
$opts->parse();
} catch (Zend_Console_Getopt_Exception $e) {
$displayUsage = true;
}
// --- Aide / Options
if (count($opts->getOptions())==0 || isset($opts->help)) {
$displayUsage = true;
}
// --- Usage
if ($displayUsage) {
echo $opts->getUsageMessage();
?>
Types de fichier disponibles : <?php echo join(', ', $typesFichier)?>
<?php
exit;
}
if ($opts->all || $opts->type)
{
foreach ($typesFichier as $dir)
{
if ($opts->all || $opts->type==$dir ){
removeFileInDir(LOG_PATH.'/'.$dir);
}
}
}
function removeFileInDir($dir)
{
if (is_dir($dir)) {
if ($dh = opendir($dir)) {
while (($file = readdir($dh)) !== false) {
unlink($dir . $file);
}
closedir($dh);
}
}
}

View File

@ -1,86 +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|?' => "Displays usage information.",
'sqlfile=s' => "",
'csvfile=s' => "",
));
$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 "Génération d'un fichier CSV à partir d'un fichier SQL.\n";
echo $opts->getUsageMessage();
exit;
}
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
$stmt = $conn->executeQuery($sql);
if ($stmt->rowCount() == 0) {
file_put_contents($opts->csvfile, "");
}
else {
$rows = $stmt->fetchAll(\PDO::FETCH_ASSOC);
// Create the CSV
$csv = Writer::createFromPath($opts->csvfile.'.tmp', 'w');
$csv->setNewline("\r\n");
$csv->setOutputBOM(Writer::BOM_UTF8);
// Insert the CSV header
$csv->insertOne(array_keys($rows[0]));
// Insert all data
$csv->insertAll($rows);
// Set the real name of file
rename($opts->csvfile.'.tmp', $opts->csvfile);
}