429 lines
12 KiB
PHP
429 lines
12 KiB
PHP
<?php
|
|
// Define path to application directory
|
|
defined('APPLICATION_PATH')
|
|
|| define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../../application'));
|
|
|
|
// Define application environment
|
|
defined('APPLICATION_ENV')
|
|
|| define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'development'));
|
|
|
|
// Ensure library/ is on include_path
|
|
set_include_path(implode(PATH_SEPARATOR, array(
|
|
realpath(APPLICATION_PATH . '/../library'),
|
|
get_include_path(),
|
|
)));
|
|
|
|
//Use classmap autoloader - useful with opcode and realpath cache
|
|
require_once 'Zend/Loader/AutoloaderFactory.php';
|
|
require_once 'Zend/Loader/ClassMapAutoloader.php';
|
|
Zend_Loader_AutoloaderFactory::factory(array(
|
|
'Zend_Loader_ClassMapAutoloader' => array(
|
|
__DIR__ . '/../../library/Zend/autoload_classmap.php',
|
|
__DIR__ . '/../../library/Application/autoload_classmap.php',
|
|
__DIR__ . '/../../application/autoload_classmap.php',
|
|
__DIR__ . '/../../library/Scores/autoload_classmap.php',
|
|
__DIR__ . '/../../library/SdMetier/autoload_classmap.php',
|
|
),
|
|
'Zend_Loader_StandardAutoloader' => array(
|
|
'prefixes' => array(
|
|
'Zend' => __DIR__ . '/../../library/Zend',
|
|
'Application' => __DIR__ . '/../../library/Application',
|
|
'Scores' => __DIR__ . '/../../library/Scores',
|
|
'SdMetier' => __DIR__ . '/../../library/SdMetier',
|
|
'Metier' => __DIR__ . '/../../library/Metier',
|
|
),
|
|
'fallback_autoloader' => true
|
|
)
|
|
));
|
|
|
|
// Zend_Application - Use it if you don't have autoloaders
|
|
//require_once 'Zend/Application.php';
|
|
|
|
// Create application, bootstrap, and run
|
|
$application = new Zend_Application(
|
|
APPLICATION_ENV,
|
|
APPLICATION_PATH . '/configs/application.ini'
|
|
);
|
|
|
|
try {
|
|
$opts = new Zend_Console_Getopt(
|
|
//Options
|
|
array(
|
|
'help|?' => "Aide.",
|
|
'list' => "List item.",
|
|
'generate|g=s' => "Generate the specify cache.",
|
|
)
|
|
);
|
|
$opts->parse();
|
|
} catch (Zend_Console_Getopt_Exception $e) {
|
|
echo $e->getUsageMessage();
|
|
exit;
|
|
}
|
|
|
|
//Usage
|
|
if( count($opts->getOptions())==0 || isset($opts->help))
|
|
{
|
|
echo $opts->getUsageMessage();
|
|
exit;
|
|
}
|
|
|
|
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",
|
|
);
|
|
echo "\n";
|
|
foreach ( $tabItems as $code => $label ) {
|
|
echo "\t" . $code . " => ". $label . PHP_EOL;
|
|
}
|
|
exit;
|
|
}
|
|
|
|
/**
|
|
* Cache des Tribunaux Bodacc
|
|
* Metier / Bodacc / Cache
|
|
*/
|
|
if( $opts->generate == 'Tribunaux' ) {
|
|
|
|
$c = new Zend_Config($application->getOptions());
|
|
$db = Zend_Db::factory($c->profil->db->metier);
|
|
|
|
$result = $db->query("SELECT triCode, triNom, triCP, triSiret FROM jo.tribunaux WHERE triCode IS NOT NULL");
|
|
$result->setFetchMode(Zend_Db::FETCH_OBJ);
|
|
$rows = $result->fetchAll();
|
|
|
|
$fp=fopen(APPLICATION_PATH . '/../library/Metier/bodacc/Cache' . DIRECTORY_SEPARATOR . 'Tribunaux.php','w');
|
|
fwrite($fp, "<?php\n");
|
|
fwrite($fp, "return array(\n");
|
|
|
|
if ( count($rows) > 0 ) {
|
|
foreach($rows as $item) {
|
|
$dep = intval(substr($item->triCP,0,2));
|
|
if ($dep==97 || $dep==98) $dep=intval(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
|
|
* Metier / bodacc / Cache
|
|
*/
|
|
if ( $opts->generate == 'FctDir' ) {
|
|
|
|
$c = new Zend_Config($application->getOptions());
|
|
$db = Zend_Db::factory($c->profil->db->metier);
|
|
|
|
$result = $db->query("SELECT codeFct, libelle FROM jo.bodacc_fonctions");
|
|
$result->setFetchMode(Zend_Db::FETCH_OBJ);
|
|
$rows = $result->fetchAll();
|
|
|
|
$fp=fopen(APPLICATION_PATH . '/../library/Metier/bodacc/Cache' . DIRECTORY_SEPARATOR . 'FctDir.php','w');
|
|
fwrite($fp, "<?php\n");
|
|
fwrite($fp, "return array(\n");
|
|
|
|
if ( count($rows) > 0 ) {
|
|
foreach($rows as $item) {
|
|
fwrite($fp, "\t'" . intval($item->codeFct) . "' => \"". $item->libelle . "\",\n");
|
|
}
|
|
}
|
|
fwrite($fp, ");\n");
|
|
|
|
}
|
|
|
|
/**
|
|
* Cache Evenements
|
|
* Metier / bodacc / Cache
|
|
*/
|
|
if ( $opts->generate == 'Evenements' ) {
|
|
|
|
$c = new Zend_Config($application->getOptions());
|
|
$db = Zend_Db::factory($c->profil->db->metier);
|
|
|
|
$result = $db->query("SELECT codEven, libEven, Bodacc_Code, Rubrique, version, lienEtab FROM jo.tabEvenements");
|
|
$result->setFetchMode(Zend_Db::FETCH_OBJ);
|
|
$rows = $result->fetchAll();
|
|
|
|
$fp=fopen(APPLICATION_PATH . '/../library/Metier/bodacc/Cache' . DIRECTORY_SEPARATOR . 'Evenements.php','w');
|
|
fwrite($fp, "<?php\n");
|
|
fwrite($fp, "return array(\n");
|
|
|
|
if ( count($rows) > 0 ) {
|
|
foreach($rows 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
|
|
* Metier / bodacc / Cache
|
|
*/
|
|
if ( $opts->generate == 'Devises' ) {
|
|
|
|
$c = new Zend_Config($application->getOptions());
|
|
$db = Zend_Db::factory($c->profil->db->metier);
|
|
|
|
$result = $db->query("SELECT libDeviseBodacc, devIso FROM jo.bodacc_devises");
|
|
$result->setFetchMode(Zend_Db::FETCH_OBJ);
|
|
$rows = $result->fetchAll();
|
|
|
|
$fp=fopen(APPLICATION_PATH . '/../library/Metier/bodacc/Cache' . DIRECTORY_SEPARATOR . 'Devises.php','w');
|
|
fwrite($fp, "<?php\n");
|
|
fwrite($fp, "return array(\n");
|
|
|
|
if ( count($rows) > 0 ) {
|
|
foreach($rows as $item) {
|
|
fwrite($fp, "\t\"" . $item->libDeviseBodacc . "\" => \"" . $item->devIso ."\",\n");
|
|
}
|
|
}
|
|
fwrite($fp, ");\n");
|
|
|
|
}
|
|
|
|
/**
|
|
* Cache Tribunaux RNCS
|
|
* Metier / Partenaires / Cache
|
|
*/
|
|
if ( $opts->generate == 'RncsTribunaux' ) {
|
|
|
|
$c = new Zend_Config($application->getOptions());
|
|
$db = Zend_Db::factory($c->profil->db->metier);
|
|
|
|
$result = $db->query("SELECT triNumGreffe, triNom, triId, triCode FROM jo.tribunaux WHERE triNumGreffe IS NOT NULL");
|
|
$result->setFetchMode(Zend_Db::FETCH_OBJ);
|
|
$rows = $result->fetchAll();
|
|
|
|
$fp=fopen(APPLICATION_PATH . '/../library/Metier/partenaires/Cache' . DIRECTORY_SEPARATOR . 'Tribunaux.php','w');
|
|
fwrite($fp, "<?php\n");
|
|
fwrite($fp, "return array(\n");
|
|
|
|
if ( count($rows) > 0 ) {
|
|
foreach($rows as $item) {
|
|
fwrite($fp, "\t" . intval($item->triNumGreffe) . " => array(");
|
|
fwrite($fp, "'Id'=>\"" . $item->triId . "\", 'Nom'=>\"".$item->triNom."\", 'Code'=>\"".$item->triCode."\"");
|
|
fwrite($fp, "),\n");
|
|
}
|
|
}
|
|
fwrite($fp, ");\n");
|
|
|
|
}
|
|
|
|
/**
|
|
* Cache Devises Inpi
|
|
* Metier / Partenaires / Cache
|
|
*/
|
|
if ( $opts->generate == 'DevisesInpi' ) {
|
|
|
|
$c = new Zend_Config($application->getOptions());
|
|
$db = Zend_Db::factory($c->profil->db->metier);
|
|
|
|
$result = $db->query("SELECT devInpi, devIso FROM jo.tabDevises WHERE devInpi>0 ORDER BY devInpi ASC");
|
|
$result->setFetchMode(Zend_Db::FETCH_OBJ);
|
|
$rows = $result->fetchAll();
|
|
|
|
$fp=fopen(APPLICATION_PATH . '/../library/Metier/partenaires/Cache' . DIRECTORY_SEPARATOR . 'DevisesInpi.php','w');
|
|
fwrite($fp, "<?php\n");
|
|
fwrite($fp, "return array(\n");
|
|
|
|
if ( count($rows) > 0 ) {
|
|
foreach($rows as $item) {
|
|
fwrite($fp, "\t" . intval($item->devInpi) . " => \"" . $item->devIso . "\",\n");
|
|
}
|
|
}
|
|
fwrite($fp, ");\n");
|
|
|
|
}
|
|
|
|
/**
|
|
* Cache Jugements
|
|
* Metier / Partenaires / Cache
|
|
*/
|
|
if ( $opts->generate == 'Jugements' ) {
|
|
|
|
$c = new Zend_Config($application->getOptions());
|
|
$db = Zend_Db::factory($c->profil->db->metier);
|
|
|
|
$result = $db->query("SELECT codJugement, codEven FROM jo.tabJugeRncs");
|
|
$result->setFetchMode(Zend_Db::FETCH_OBJ);
|
|
$rows = $result->fetchAll();
|
|
|
|
$fp=fopen(APPLICATION_PATH . '/../library/Metier/partenaires/Cache' . DIRECTORY_SEPARATOR . 'Jugements.php','w');
|
|
fwrite($fp, "<?php\n");
|
|
fwrite($fp, "return array(\n");
|
|
|
|
if ( count($rows) > 0 ) {
|
|
foreach($rows as $item) {
|
|
fwrite($fp, "\t" . intval($item->codJugement) . " => " . $item->codEven . ",\n");
|
|
}
|
|
}
|
|
fwrite($fp, ");\n");
|
|
|
|
}
|
|
|
|
/**
|
|
* Cache PaysInpi
|
|
* Metier / Partenaires / Cache
|
|
*/
|
|
if ( $opts->generate == 'PaysInpi' ) {
|
|
|
|
$c = new Zend_Config($application->getOptions());
|
|
$db = Zend_Db::factory($c->profil->db->metier);
|
|
|
|
$result = $db->query("SELECT codePaysInpi, codPays FROM jo.tabPays WHERE codePaysInpi>0 ORDER BY codePaysInpi ASC");
|
|
$result->setFetchMode(Zend_Db::FETCH_OBJ);
|
|
$rows = $result->fetchAll();
|
|
|
|
$fp=fopen(APPLICATION_PATH . '/../library/Metier/partenaires/Cache' . DIRECTORY_SEPARATOR . 'PaysInpi.php','w');
|
|
fwrite($fp, "<?php\n");
|
|
fwrite($fp, "return array(\n");
|
|
|
|
if ( count($rows) > 0 ) {
|
|
foreach($rows as $item) {
|
|
fwrite($fp, "\t" . intval($item->codePaysInpi) . " => \"" . $item->codPays . "\",\n");
|
|
}
|
|
}
|
|
fwrite($fp, ");\n");
|
|
|
|
}
|
|
|
|
/**
|
|
* Cache CodesNaf
|
|
* Metier / Insee / Cache
|
|
*/
|
|
if ( $opts->generate == 'CodesNaf' ) {
|
|
|
|
$c = new Zend_Config($application->getOptions());
|
|
$db = Zend_Db::factory($c->profil->db->metier);
|
|
|
|
$fp=fopen(APPLICATION_PATH . '/../library/Metier/insee/Cache' . DIRECTORY_SEPARATOR . 'CodesNaf.php','w');
|
|
fwrite($fp, "<?php\n");
|
|
fwrite($fp, "return array(\n");
|
|
|
|
|
|
$result = $db->query("SELECT codNaf700 AS naf, libNaf700 AS LibNaf FROM jo.tabNaf4");
|
|
$result->setFetchMode(Zend_Db::FETCH_OBJ);
|
|
$rows = $result->fetchAll();
|
|
|
|
if ( count($rows) > 0 ) {
|
|
foreach($rows as $item) {
|
|
fwrite($fp, "\t'" . $item->naf . "' => \"" . $item->LibNaf . "\",\n");
|
|
}
|
|
}
|
|
|
|
$result = $db->query("SELECT codNaf5 AS naf, libNaf5 AS LibNaf FROM jo.tabNaf5");
|
|
$result->setFetchMode(Zend_Db::FETCH_OBJ);
|
|
$rows = $result->fetchAll();
|
|
|
|
if ( count($rows) > 0 ) {
|
|
foreach($rows as $item) {
|
|
fwrite($fp, "\t'" . $item->naf . "' => \"" . $item->LibNaf. "\",\n");
|
|
}
|
|
}
|
|
|
|
fwrite($fp, ");\n");
|
|
|
|
}
|
|
|
|
/**
|
|
* Cache CodesNace
|
|
* Metier / Insee / Cache
|
|
*/
|
|
if ( $opts->generate == 'CodesNace' ) {
|
|
|
|
$c = new Zend_Config($application->getOptions());
|
|
$db = Zend_Db::factory($c->profil->db->metier);
|
|
|
|
$result = $db->query("SELECT codNaf5 AS naf, libNaf5 AS LibNaf, codNaf1 FROM jo.tabNaf5");
|
|
$result->setFetchMode(Zend_Db::FETCH_OBJ);
|
|
$rows = $result->fetchAll();
|
|
|
|
$fp=fopen(APPLICATION_PATH . '/../library/Metier/insee/Cache' . DIRECTORY_SEPARATOR . 'CodesNace.php','w');
|
|
fwrite($fp, "<?php\n");
|
|
fwrite($fp, "return array(\n");
|
|
|
|
if ( count($rows) > 0 ) {
|
|
foreach($rows as $item) {
|
|
fwrite($fp, "\t'" . $item->naf . "' => \"" . $item->codNaf1 . preg_replace('/^0/','',substr($item->naf,0,4)) . "\",\n");
|
|
}
|
|
}
|
|
fwrite($fp, ");\n");
|
|
|
|
}
|
|
|
|
/**
|
|
* Cache CodesNafa
|
|
* Metier / Insee / Cache
|
|
*/
|
|
if ( $opts->generate == 'CodesNafa' ) {
|
|
|
|
$c = new Zend_Config($application->getOptions());
|
|
$db = Zend_Db::factory($c->profil->db->metier);
|
|
|
|
$result = $db->query("SELECT codNafa AS nafa, libNafa FROM jo.tabNafa");
|
|
$result->setFetchMode(Zend_Db::FETCH_OBJ);
|
|
$rows = $result->fetchAll();
|
|
|
|
$fp=fopen(APPLICATION_PATH . '/../library/Metier/insee/Cache' . DIRECTORY_SEPARATOR . 'CodesNafa.php','w');
|
|
fwrite($fp, "<?php\n");
|
|
fwrite($fp, "return array(\n");
|
|
|
|
if ( count($rows) > 0 ) {
|
|
foreach($rows as $item) {
|
|
fwrite($fp, "\t'" . $item->nafa . "' => \"" . $item->libNafa ."\",\n");
|
|
}
|
|
}
|
|
fwrite($fp, ");\n");
|
|
|
|
}
|
|
|
|
/**
|
|
* Cache CodesFJ
|
|
* Metier / Insee / Cache
|
|
*/
|
|
if ( $opts->generate == 'CodesFJ' ) {
|
|
|
|
$c = new Zend_Config($application->getOptions());
|
|
$db = Zend_Db::factory($c->profil->db->metier);
|
|
|
|
$result = $db->query("SELECT code AS FJ, libelle AS libFJ FROM jo.tabFJur WHERE code>=1000");
|
|
$result->setFetchMode(Zend_Db::FETCH_OBJ);
|
|
$rows = $result->fetchAll();
|
|
|
|
$fp=fopen(APPLICATION_PATH . '/../library/Metier/insee/Cache' . DIRECTORY_SEPARATOR . 'CodesFJ.php','w');
|
|
fwrite($fp, "<?php\n");
|
|
fwrite($fp, "return array(\n");
|
|
|
|
if ( count($rows) > 0 ) {
|
|
foreach($rows as $item) {
|
|
fwrite($fp, "\t" . $item->FJ . " => \"" . str_replace('"','\"',$item->libFJ) ."\",\n");
|
|
}
|
|
}
|
|
fwrite($fp, ");\n");
|
|
|
|
}
|