From b0a67aea50eebba369a9ac30bcb960796e499fcc Mon Sep 17 00:00:00 2001 From: Michael RICOIS Date: Tue, 11 Apr 2017 10:40:53 +0200 Subject: [PATCH] =?UTF-8?q?Suppression=20des=20binaires,=20pr=C3=A9sent=20?= =?UTF-8?q?dans=20le=20projet=20scores/library?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bin/buildCache.php | 391 -------------- bin/buildCodeRatios.php | 1070 --------------------------------------- bin/buildCodeSfr.php | 47 -- bin/buildLog.php | 57 --- bin/loadCodeRatios.php | 632 ----------------------- 5 files changed, 2197 deletions(-) delete mode 100644 bin/buildCache.php delete mode 100644 bin/buildCodeRatios.php delete mode 100644 bin/buildCodeSfr.php delete mode 100644 bin/buildLog.php delete mode 100644 bin/loadCodeRatios.php diff --git a/bin/buildCache.php b/bin/buildCache.php deleted file mode 100644 index 5c69145a..00000000 --- a/bin/buildCache.php +++ /dev/null @@ -1,391 +0,0 @@ - "Aide.", - 'list' => "List item.", - 'generate|g=s' => "Generate the specify cache.", - )); - $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 "\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; -} - -/** - * 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 . '/../vendor/scores/library/src/Metier/Table/BodaccTribunaux.php','w'); - fwrite($fp, "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 . '/../vendor/scores/library/src/Metier/Table/FctDir.php','w'); - fwrite($fp, "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 . '/../vendor/scores/library/src/Metier/Table/Evenements.php','w'); - fwrite($fp, "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 . '/../vendor/scores/library/src/Metier/Table/Devises.php','w'); - fwrite($fp, "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 . '/../vendor/scores/library/src/Metier/Table/RncsTribunaux.php','w'); - fwrite($fp, "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 . '/../vendor/scores/library/src/Metier/Table/DevisesInpi.php','w'); - fwrite($fp, "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 . '/../vendor/scores/library/src/Metier/Table/Jugements.php','w'); - fwrite($fp, "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 . '/../vendor/scores/library/src/Metier/Table/PaysInpi.php','w'); - fwrite($fp, "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 . '/../vendor/scores/library/src/Metier/Table/CodesNaf.php','w'); - fwrite($fp, "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 . '/../vendor/scores/library/src/Metier/Table/CodesNace.php','w'); - fwrite($fp, "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 . '/../vendor/scores/library/src/Metier/Table/CodesNafa.php','w'); - fwrite($fp, "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 . '/../vendor/scores/library/src/Metier/Table/CodesFJ.php','w'); - fwrite($fp, "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 . '/../vendor/scores/library/src/Metier/Table/AffairesTypes.php','w'); - fwrite($fp, "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 . '/../vendor/scores/library/src/Metier/Defaillance/ProcolDelete.php', 'w'); - fwrite($fp, "rowCount() > 0) { - foreach($result as $item) { - fwrite($fp, "\t" . $item->codEven . " => " . $item->affProcol .", //".$item->libEven." \n"); - } - } - fwrite($fp, ");\n"); -} - - diff --git a/bin/buildCodeRatios.php b/bin/buildCodeRatios.php deleted file mode 100644 index e00e25e7..00000000 --- a/bin/buildCodeRatios.php +++ /dev/null @@ -1,1070 +0,0 @@ - "Aide.", - 'ratios' => "Génére la class des ratios (classMRatios.php)", - 'type-s' => "Choix du type d'indiScore : score ou valo", - 'formules-s' => "Génére le code Formules{type}{versions}.php", - 'comments-s' => "Génére le cache des Comments{type}{versions}.php", - 'niveau=s' => "Niveau de commentaire", - 'tabcache' => "Tab in cache", - )); - $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 "\nRatios et Formules\n\n"; - echo $opts->getUsageMessage(); - exit; -} - -// Fichier MRatios -if (isset($opts->ratios)) { - - $configFile = APPLICATION_PATH.'/../vendor/scores/library/src/Metier/Scores/MRatios.php'; - - $fp = fopen($configFile, 'w'); - fwrite($fp, ''R[801]', - 'R01b'=>'Rh[801]', - 'R01c'=>'Rs[801]', - 'R02a'=>'R[802]', - 'R02b'=>'Rh[802]', - 'R02c'=>'Rs[802]', - 'R02d'=>'Rq[802]', - 'R02e'=>'Rt[802]', - 'R03a'=>'R[803]', - 'R03b'=>'Rh[803]', - 'R03c'=>'Rs[803]', - 'R03d'=>'Rq[803]', - 'R03e'=>'Rt[803]', - 'R04a'=>'R[804]', - 'R04b'=>'Rh[804]', - 'R04c'=>'Rs[804]', - 'R04d'=>'Rq[804]', - 'R04e'=>'Rt[804]', - 'R05a'=>'R[805]', - 'R05b'=>'Rh[805]', - 'R05c'=>'Rs[805]', - 'R06a'=>'R[806]', - 'R06b'=>'Rh[806]', - 'R06c'=>'Rs[806]', - 'R06d'=>'Rq[806]', - 'R06e'=>'Rt[806]', - 'R07a'=>'R[807]', - 'R07b'=>'Rh[807]', - 'R07c'=>'Rs[807]', - 'R07d'=>'Rq[807]', - 'R07e'=>'Rt[807]', - 'R08a'=>'R[808]', - 'R08b'=>'Rh[808]', - 'R08c'=>'Rs[808]', - 'R08d'=>'Rq[808]', - 'R08e'=>'Rt[808]', - 'R09a'=>'R[809]', - 'R09b'=>'Rh[809]', - 'R09c'=>'Rs[809]', - 'R09d'=>'Rq[809]', - 'R09e'=>'Rt[809]', - 'R10a'=>'R[810]', - 'R10b'=>'Rh[810]', - 'R10c'=>'Rs[810]', - 'R10d'=>'Rq[810]', - 'R10e'=>'Rt[810]', - 'R11a'=>'R[811]', - 'R11b'=>'Rh[811]', - 'R11c'=>'Rs[811]', - 'R12a'=>'R[812]', - 'R12b'=>'Rh[812]', - 'R12c'=>'Rs[812]', - 'R13a'=>'R[813]', - 'R13b'=>'Rh[813]', - 'R13c'=>'Rs[813]', - 'R13d'=>'Rq[813]', - 'R13e'=>'Rt[813]', - 'R14a'=>'R[814]', - 'R14b'=>'Rh[814]', - 'R14c'=>'Rs[814]', - 'R14d'=>'Rq[814]', - 'R14e'=>'Rt[814]', - 'R15a'=>'R[815]', - 'R15b'=>'Rh[815]', - 'R15c'=>'Rs[815]', - 'R15d'=>'Rq[815]', - 'R15e'=>'Rt[815]', - 'R16a'=>'R[816]', - 'R16b'=>'Rh[816]', - 'R16c'=>'Rs[816]', - 'R16d'=>'Rq[816]', - 'R16e'=>'Rt[816]', - 'R17a'=>'R[817]', - 'R17b'=>'Rh[817]', - 'R17c'=>'Rs[817]', - 'R18a'=>'R[818]', - 'R18b'=>'Rh[818]', - 'R18c'=>'Rs[818]', - 'R18d'=>'Rq[818]', - 'R18e'=>'Rt[818]', - 'R19a'=>'R[819]', - 'R19b'=>'Rh[819]', - 'R19c'=>'Rs[819]', - 'R19d'=>'Rq[819]', - 'R19e'=>'Rt[819]', - 'R20a'=>'R[820]', - 'R20b'=>'Rh[820]', - 'R20c'=>'Rs[820]', - 'R20d'=>'Rq[820]', - 'R20e'=>'Rt[820]', - 'R21a'=>'R[821]', - 'R21b'=>'Rh[821]', - 'R21c'=>'Rs[821]', - 'R21d'=>'Rq[821]', - 'R21e'=>'Rt[821]', - 'R22a'=>'R[822]', - 'R22b'=>'Rh[822]', - 'R22c'=>'Rs[822]', - 'R23a'=>'R[823]', - 'R23b'=>'Rh[823]', - 'R23c'=>'Rs[823]', - 'R24a'=>'R[824]', - 'R24b'=>'Rh[824]', - 'R24c'=>'Rs[824]', - 'R25a'=>'R[825]', - 'R25b'=>'Rh[825]', - 'R25c'=>'Rs[825]', - 'R26a'=>'R[826]', - 'R26b'=>'Rh[826]', - 'R26c'=>'Rs[826]', - 'R26d'=>'Rq[826]', - 'R26e'=>'Rt[826]', - 'R27a'=>'R[827]', - 'R27b'=>'Rh[827]', - 'R27c'=>'Rs[827]', - 'R27d'=>'Rq[827]', - 'R27e'=>'Rt[827]', - 'R28a'=>'R[828]', - 'R28b'=>'Rh[828]', - 'R28c'=>'Rs[828]', - 'R28d'=>'Rq[828]', - 'R28e'=>'Rt[828]', - 'R29a'=>'R[829]', - 'R29b'=>'Rh[829]', - 'R29c'=>'Rs[829]', - 'R29d'=>'Rq[829]', - 'R29e'=>'Rt[829]', - 'R30a'=>'R[830]', - 'R30b'=>'Rh[830]', - 'R30c'=>'Rs[830]', - 'R30d'=>'Rq[830]', - 'R30e'=>'Rt[830]', - 'R31a'=>'R[843]', - 'R31b'=>'Rh[843]', - 'R31c'=>'Rs[843]', - 'R31d'=>'Rq[843]', - 'R31e'=>'Rt[843]', - 'R32a'=>'R[831]', - 'R32b'=>'Rh[831]', - 'R32c'=>'Rs[831]', - 'R33a'=>'R[832]', - 'R33b'=>'Rh[832]', - 'R33c'=>'Rs[832]', - 'R33d'=>'R[845]', - 'R33e'=>'Rh[845]', - 'R33f'=>'Rs[845]', - 'R34a'=>'R[833]', - 'R34b'=>'Rh[833]', - 'R34c'=>'Rs[833]', - 'R34d'=>'R[846]', - 'R34e'=>'Rh[846]', - 'R34f'=>'Rs[846]', - 'R35a'=>'R[834]', - 'R35b'=>'Rh[834]', - 'R35c'=>'Rs[834]', - 'R35d'=>'R[847]', - 'R35e'=>'Rh[847]', - 'R35f'=>'Rs[847]', - 'R36a'=>'R[835]', - 'R36b'=>'Rh[835]', - 'R36c'=>'Rs[835]', - 'R36d'=>'R[849]', - 'R36e'=>'Rh[849]', - 'R36f'=>'Rs[849]', - 'R37a'=>'R[844]', - 'R37b'=>'Rh[844]', - 'R37c'=>'Rs[844]', - 'R37d'=>'R[848]', - 'R37e'=>'Rh[848]', - 'R37f'=>'Rs[848]', - 'R38a'=>'R[836]', - 'R38b'=>'Rh[836]', - 'R38c'=>'Rs[836]', - 'R38d'=>'Rq[836]', - 'R38e'=>'Rt[836]', - 'R39a'=>'R[837]', - 'R39b'=>'Rh[837]', - 'R39c'=>'Rs[837]', - 'R39d'=>'Rq[837]', - 'R39e'=>'Rt[837]', - 'R40a'=>'R[838]', - 'R40b'=>'Rh[838]', - 'R40c'=>'Rs[838]', - 'R40d'=>'Rq[838]', - 'R40e'=>'Rt[838]', - 'R41a'=>'R[842]', - 'R41b'=>'Rh[842]', - 'R41c'=>'Rs[842]', - 'R41d'=>'Rq[842]', - 'R41e'=>'Rt[842]', - 'R42a'=>'R[839]', - 'R42b'=>'Rh[839]', - 'R42c'=>'Rs[839]', - 'R42d'=>'Rq[839]', - 'R42e'=>'Rt[839]', - 'R43a'=>'R[840]', - 'R43b'=>'Rh[840]', - 'R43c'=>'Rs[840]', - 'R43d'=>'Rq[840]', - 'R43e'=>'Rt[840]', - 'R44a'=>'R[841]', - 'R44b'=>'Rh[841]', - 'R44c'=>'Rs[841]', - ); - - public function __construct() - { - } - - /** - * Conversion des zones pour les collectivités - * @param unknown \$codeR - * @param unknown \$zonesDB - * @return array - */ - public function convertZones(\$codeR, \$zonesDB) - { - foreach(\$this->tabZones2Ratios as \$oldR=>\$newR) { - if (preg_match('/(\D+)\[(\d+)\]/Uis', \$newR, \$matches) && \$matches[1]==\$codeR) { - \$iRatio=\$matches[2]; - if (\$codeR=='R') - \$ret[\$iRatio]=\$zonesDB[\$oldR]*1000; - else - \$ret[\$iRatio]=\$zonesDB[\$oldR]; - } - } - return \$ret; - } - - /** - * Donne le taux d'inflation pour une année donnée - * @param unknown \$annee - * @return unknown - */ - public function getInflation(\$annee) - { - \$tabInfla = include __DIR__ . '/Data/Infla.php'; - if ( isset(\$tabInfla[\$annee]) ) { - return \$tabInfla[\$annee]; - } - } - - /** - * Donne le taux de rendement des actions pour une année donnée - * @param unknown \$annee - * @return unknown - */ - public function getTxRendement(\$annee) - { - \$tabTxRendObli = include __DIR__ . '/Data/RendObli.php'; - if ( isset(\$tabTxRendObli[\$annee]) ) { - return \$tabTxRendObli[\$annee]; - } - } - - /** - * Taux de tva - * @param string \$date AAAAMM - * @return double - */ - public function getTxTva(\$date) - { - \$tabTxTva = include __DIR__ . '/Data/Tva.php'; - foreach (\$tabTxTva as \$ym => \$v) { - if (\$ym > \$date) { - break; - } - \$tva = \$v; - } - return \$tva; - } - - /** - * Définit la tranche d'effectif - * @param int \$value - */ - public function setTrancheEffectif(\$value) - { - \$this->efftr = \$value; - } - - /** - * Calcul les ratios - * @param array \$bilans - * Format des bilans à envoyer - * - * Les bilans doivent être envoyés trier - * @return array - */ - public function calcul(\$bilans) - { - \$numBil = 0; - foreach (\$bilans as \$k => \$p) { - - \$millesime = \$p['DATE_CLOTURE']; - \$tva = \$this->getTxTva(substr(\$millesime,0,6)); - - // --- Calcul - " . "\n"); - - fwrite($fp, "\t\t\t" . "\$nm=\$p['DUREE_MOIS'];" ."\n"); - fwrite($fp, "\t\t\t" . "\$nmp=\$p['DUREE_MOIS_PRE'];" ."\n"); - fwrite($fp, "\t\t\t" . "\$R=array();" ."\n"); - - $stmt = $conn->executeQuery("SELECT id, libelle, formule, unite, commentaires, borneMin, - borneMax, calcul, deleted FROM jo.ratios_formules WHERE deleted=0"); - - $tabMoy = array(); - while ($formule = $stmt->fetch(\PDO::FETCH_ASSOC)) { - $id = intval($formule['id']); - $libelle = $formule['libelle']; - $unite = $formule['unite']; - - /** Ratios avec formules à calculer **/ - if ($formule['calcul']) { - $formuleStr = $formule['formule']; - - if (preg_match("/^MOY\(R\[(.*)\],(.*)\)/Ui", $formuleStr, $matches)) { - $tabMoy[$id]=array( - 'ratio'=>$matches[1]*1, - 'nbExo'=>$matches[2]*1, - ); - continue; - } - - // Gestion des variables minuscules de 1 à 8 caractères alphanumériques - $formule1 = preg_replace('/(tva|efftr|nm)/','\$this->$1', $formuleStr); - $formule1 = preg_replace('/([a-z]{1,8})/','\$$1', $formuleStr); - // Gestion des postes du BILAN AX, BX, YP, FL1, etc... - $formule1 = preg_replace('/\b([A-Z]{2,2}[1-9]{0,1})\b/','\$p[\'$1\']', $formule1); - - // Gestion des ratios précédent - $formule1 = preg_replace_callback('/\bR\[(.*)\]/U', function($match) { - return '$R['.intval($match[1]).']'; - }, $formule1); - - // Gestion des valeurs Absolues - $formule1 = preg_replace('/\|(.*)\|/U', 'abs($1)', $formule1); - // Gestion de l'inflation pour l'année du bilan - $formule1 = preg_replace('/\INFLATION/U', '$this->getInflation(substr($millesime,4))', $formule1); - - // Ecriture de la formule - $formule1 = "\$R[$id]=".$formule1.';'; - - /** fonction ou **/ - if (preg_match('/ \$ou (.*)/', $formule1, $matches)) { - $formule1 = preg_replace('/ \$ou (.*)/',';', $formule1); - $alternative = $matches[1]; - $formule1.= "\t" . "if (\$R[$id]==0) { \$R[$id] = $alternative }"; - } - - /** Bornage des résultats en cas de dépassement **/ - if (preg_match('/;BORN\((.*)\)/U', $formule1, $matches)) { - $formule1 = preg_replace('/(;BORN\(.*\))/U','', $formule1); - $tabBornes = explode(':', $matches[1]); - if (trim($tabBornes[0])<>'') { - $bMin = trim($tabBornes[0])*1; - $formule1.= "\t" . "if (\$R[$id]<$bMin) { \$R[$id] = $bMin; }"; - } - if (isset($tabBornes[1]) && trim(@$tabBornes[1])<>'') { - $bMax =trim($tabBornes[1])*1; - $formule1.= "\t" . "if (\$R[$id]>$bMax) { \$R[$id] = $bMax; }"; - } - } - - /** Bornage des résultats en cas de dépassement **/ - if (preg_match('/;LIM\((.*)\)/U', $formule1, $matches)) { - $formule1 = preg_replace('/(;LIM\(.*\))/U','', $formule1); - $bMax = trim($matches[1])*1; - $formule1.= "\t" . "if (\$R[$id]>$bMax) { \$R[$id] = $bMax; }"; - } - $formule2 = $formule1; - - fwrite($fp, "\t\t\t" . $formule2 . "\n"); - fwrite($fp, "\t\t\t" . "if (!isset(\$R[".$id."])) { \$R[".$id."] = 'NS'; }" . "\n\n"); - } - } - - fwrite($fp, "\n"); - fwrite($fp, "\t\t\t" . '$tabRatios[$numBil]=$R;'."\n"); - fwrite($fp, "\t\t\t" . '$numBil++;'."\n"); - fwrite($fp, "\t\t" . "}" ."\n\n"); - - foreach($tabMoy as $iRatio=>$tMoy) { - $irMoy=$tMoy['ratio']; - $nbExo=$tMoy['nbExo']; - fwrite($fp, "\t\t" . "for(\$i=0; \$i<\$numBil; \$i++) {" . "\n"); - fwrite($fp, "\t\t\t" . "\$tabRatios[\$i][".$iRatio."]=(\$tabRatios[\$i][".$irMoy."]"); - for($i=1; $i<$nbExo; $i++) { - fwrite($fp, '+$tabRatios[$i+'.$i.']['.$irMoy.']'); - } - fwrite($fp, ")/".$nbExo.";" . "\n"); - fwrite($fp, "\t\t" . "}" . "\n\n"); - } - - fwrite($fp, "\t\t" . "return \$tabRatios;" . "\n"); - fwrite($fp, "\t" . "}" . "\n"); - fwrite($fp, "}" . "\n"); - fclose ($fp); - - $strOutput=exec('php -l '.$configFile, $output); - if (preg_match('/^No syntax errors detected in /', $strOutput)) { - } else { - print_r($output); - return false; - } - return true; -} - -// --- Formules -if (isset($opts->formules)) { - - if ( isset($opts->type) && in_array($opts->type, array('score', 'valo')) ) { - $type = $opts->type; - } else { - $type = 'score'; - } - - $cycle = 2; - $version = $opts->formules; - - // Select the right table in database in function of type - switch ($type) { - case 'score': - $file = APPLICATION_PATH.'/../vendor/scores/library/src/Metier/Scores/Formule/Score_'.$version.'.php'; - $tableFormu = 'jo.scores_formules_'.$version; - $tableComment = 'jo.scores_commentaires_'.$version; - break; - - case 'valo': - $file = APPLICATION_PATH.'/../vendor/scores/library/src/Metier/Scores/Formule/Valo_'.$version.'.php'; - $tableFormu = 'jo.valo_formules_'.$version; - $tableComment = 'jo.valo_commentaires_'.$version; - break; - } - - // Read comments - $stmt = $conn->executeQuery("SELECT code, langue, cycle, ligne, commentaire, tri, deleted - FROM $tableComment - WHERE deleted=0 AND cycle=$cycle AND ligne NOT LIKE '%*%' AND commentaire NOT LIKE '.*%' - ORDER BY langue ASC, cycle ASC, code ASC, ligne ASC"); - $tabCommentaires = $tabTri = $tabTriAff = array(); - while ($commentaire = $stmt->fetch(\PDO::FETCH_ASSOC)) { - $id = $commentaire['code']*1; - $ligne = $commentaire['ligne']*1; - $tabCommentaires[$id][$ligne] = str_replace('"','\"',$commentaire['commentaire']); - if ($commentaire['tri']) { - //$tabTri[$id] = $commentaire['tri']; - $tabTriAff[$id] = ($commentaire['tri'].'.'.(10000000+(1*$commentaire['code'])))*1; - } - } - - // Read formulas - $stmt = $conn->executeQuery("SELECT code, ligne, remarque, operande, ope1, operation, valeur - FROM $tableFormu - WHERE deleted=0 AND code>1 AND ligne NOT LIKE '%*%' ORDER BY code ASC, ligne ASC"); - $idPre = $strFormule = false; - $debugFormule = ''; - $fp = fopen($file,'w'); - fwrite($fp,'fetch(\PDO::FETCH_ASSOC)) { - $id = $formule['code']*1; - if ($idPre != $id && $idPre != false) { - $debugFormule.= $strFormule.') { $C['.$idPre."]=true; $strAction } \t"; - $strFormule = preg_replace('/\|([A-Z0-9\. \$\[\]]{1,12})\|/Ui', 'abs($1)', $strFormule); - $strFormule = preg_replace('/\$R\[0+/', '$R[', $strFormule); - $strFormule = preg_replace('/\$Ra\[0+/', '$Ra[', $strFormule); - $strFormule = preg_replace('/\$Rap\[0+/', '$Rap[', $strFormule); - $strFormule = preg_replace('/\$Rp\[0+/', '$Rp[', $strFormule); - $strFormule = preg_replace('/\$Rs\[0+/', '$Rs[', $strFormule); - $strFormule = preg_replace('/\$Rsp\[0+/', '$Rsp[', $strFormule); - $strFormule = preg_replace('/\$Revol\[0+/', '$Revol[', $strFormule); - $strFormule = preg_replace('/\$Revolp\[0+/', '$Revolp[', $strFormule); - $strFormule = preg_replace('/\$Revols\[0+/', '$Revols[', $strFormule); - $strFormule = preg_replace('/\$Rdiff\[0+/', '$Rdiff[', $strFormule); - for ($j=2; $j<5; $j++) { - $strFormule = preg_replace('/\$Rp'.$j.'\[0+/', '$Rp'.$j.'[', $strFormule); - $strFormule = preg_replace('/\$Rs'.$j.'\[0+/', '$Rs'.$j.'[', $strFormule); - $strFormule = preg_replace('/\$Rsp'.$j.'\[0+/', '$Rsp'.$j.'[', $strFormule); - $strFormule = preg_replace('/\$Revol'.$j.'\[0+/', '$Revol'.$j.'[', $strFormule); - $strFormule = preg_replace('/\$Revolp'.$j.'\[0+/', '$Revolp'.$j.'[', $strFormule); - } - $strAction = preg_replace('/\|([A-Z0-9\. \$\[\]]{1,12})\|/Ui', 'abs($1)', $strAction); - $strAction = preg_replace('/\$R\[0+/', '$R[', $strAction); - $strAction = preg_replace('/\$Ra\[0+/', '$Ra[', $strAction); - $strAction = preg_replace('/\$Rap\[0+/', '$Rap[', $strAction); - $strAction = preg_replace('/\$Rp\[0+/', '$Rp[', $strAction); - $strAction = preg_replace('/\$Rs\[0+/', '$Rs[', $strAction); - $strAction = preg_replace('/\$Rsp\[0+/', '$Rsp[', $strAction); - $strAction = preg_replace('/\$Revol\[0+/', '$Revol[', $strAction); - $strAction = preg_replace('/\$Revolp\[0+/', '$Revolp[', $strAction); - $strAction = preg_replace('/\$Rdiff\[0+/', '$Rdiff[', $strAction); - - fwrite($fp, $remarque."\n"); - // Remplace "$" par "$this->" - fwrite($fp, str_replace('$', '$this->', $strFormule.') { $C['.$idPre."]=true; $strAction } ")."\n"); - - eval( $strFormule.') { $C['.$idPre."]=true; $strAction } " ); - $debugFormule.= '$C['.$idPre.']='.$C[$idPre]."\r\n"; - $remarque = "// $id-".$formule['ligne'].' : '.$formule['remarque']; - $strAction = ''; - } elseif (!$idPre) { - $remarque = "// $id-".$formule['ligne']; - } else { - $remarque.= ' '.strtr($formule['remarque'],array("\r"=>' ',"\n"=>' ')); - } - $ligne = $formule['ligne']*1; - - $operande = trim(strtr(strtoupper($formule['operande']),array(':'=>''))); - $ope1 = trim($formule['ope1']); - - // PROJECTAUX PROJECCOEF PROJEC - if (preg_match("/(PROJECTAUX|PROJECCOEF|PROJEC)\((.*)\)/Ui", $ope1, $matches)) { - $ope1 = $matches[1].'($'.preg_replace('/R\[0+/', 'regR[', str_replace('+', '', $matches[2])).')'; - } - // Gestion du mot clef LONG - elseif (preg_match('/^LONG\(([A-Z0-9\_]{1,30})\)$/i', $ope1, $matches)) { - $ope1 = preg_replace('/^LONG\(([A-Z0-9\_]{1,30})\)$/i','strlen(\$$1)', $ope1); - } - // Gestion du substr - else { - $ope1 = preg_replace('/([A-Z0-9\_]{1,30})\((.*)\)$/i','substr(\$$1,$2)', $ope1); - } - - $operation = trim($formule['operation']); - if ($operation=='=') $operation='=='; - - $valeur = trim(strtr($formule['valeur'], array('"'=>"'"))); - - if (preg_match("/^MOY\(R(.*),(.*)\)/Ui", $valeur, $matches)) { - $valeur = '( (R'.$matches[1]; - for($iMoy=0; $iMoy<$matches[2]; $iMoy++) { - if ($iMoy == 1) { - $valeur.= '+Rp'.$matches[1]; - } else { - $valeur.= '+Rp'.$iMoy.$matches[1]; - } - } - $valeur.= ')/'.$matches[2].')'; - } - else { - $valeur = preg_replace('/([A-Z\_]{1,30})\((.*)\)$/i','substr(\$$1,$2)', $valeur); - } - - if ( !empty($valeur) && substr($valeur,0,1) != "'" && !preg_match('/\(.*;.*\)/', $valeur) - && substr($valeur,0,6) != 'substr' && !in_array($valeur, array('vrai', 'faux')) ) { - //file_put_contents('test.log', $valeur, FILE_APPEND); - //$valeur = preg_replace('/([A-Z][A-Za-z0-9\_]{1,29}|[A-Za-z0-9]{1,30}\[[0-9]+\])/', '\$$1' , $valeur); - $valeur = preg_replace('/([A-Z][A-Za-z0-9\_]{0,29}|[A-Za-z0-9]{1,30}\[[0-9]+\])/', '\$$1' , $valeur); - //file_put_contents('test.log', " = ".$valeur."\n", FILE_APPEND); - } - - if (preg_match("/^substr|^projec|^strlen|^\||^'/i", $ope1)) { - $ope1deb = ''; - $ope1 = strtr($ope1, array( - '|R[' => '|$R[', - '|Rp[' => '|$Rp[', - '|Rp2[' => '|$Rp2[', - '|Rp3[' => '|$Rp3[', - '|Rs[' => '|$Rs[', - '|Rsp[' => '|$Rsp[', - '|Revol[' => '|$Revol[', - '|Revolp[' => '|$Revolp[', - '|Revols[' => '|$Revols[', - '|Rdiff[' => '|$Rdiff[', - )); - } - else { - $ope1deb = '$'; - $ope1 = strtr($ope1, array( - '/R[' => '/$R[', - '/Rp[' => '/$Rp[', - '/Rp2[' => '/$Rp2[', - '/Rp3[' => '/$Rp3[', - '/Rs[' => '/$Rs[', - '/Rsp[' => '/$Rsp[', - '/Revol[' => '/$Revol[', - '/Revolp[' => '/$Revolp[', - '/Revols[' => '/$Revols[', - '/Rdiff[' => '/$Rdiff[', - )); - } - - //(C[5000100]àC[5000998]) - if (preg_match('/^C\[(.*)\]àC\[(.*)\]$/', $ope1, $matches)) { - // On veut savoir si des commentaires Cxx à Cyy sont chargés - $tabTmp4 = array(); - foreach ($tabTri as $idxC=>$t) { - if ($idxC>=$matches[1] && $idxC<=$matches[2]) - $tabTmp4[]=' isset($C['.$idxC.']) '; - } - $tmpFormule='true'; - if (count($tabTmp4)>0) - $tmpFormule=' ('.implode(' || ', $tabTmp4).') '; - } elseif (preg_match_all('/^\((C\[(.*)\];?)+\)$/', $ope1, $matches)) { - $tabTmp5=explode(';', $matches[1][0]);// C[3255000];C[3260000];C[3265000] - $tabTmp4=array(); - foreach ($tabTmp5 as $t) - $tabTmp4[]=' isset($'.$t.') '; - $tmpFormule='true'; - if (count($tabTmp4)>0 && preg_match('/NON/i',$operande)) - $tmpFormule=' ('.implode(' && ', $tabTmp4).') '; - elseif (count($tabTmp4)>0) - $tmpFormule=' ('.implode(' || ', $tabTmp4).') '; - } elseif (($operation=='==' || $operation=='<>') && preg_match('/\(.*;.*\)/', $valeur)) { - /** Gestion du point-virgule (correspond à un IN dans WHERE sql **/ - $tabTmp3=explode(';', $valeur); - $tabTmp4=array(); - foreach ($tabTmp3 as $i3=>$svaleur) - $tabTmp4[]=$ope1deb.$ope1.$operation.strtr($svaleur,array('('=>'', ')'=>'', ','=>'.')); - if ($operation=='==') $tmpFormule=' ('.implode(' || ', $tabTmp4).') '; - else $tmpFormule=implode(' && ', $tabTmp4); - } elseif ($operande=='ET' && preg_match('/\(.*;.*\)/', $ope1)) { - /** Gestion du point-virgule (correspond à un IN dans WHERE sql **/ - $tabTmp3=explode(';', $ope1); - $tabTmp4=array(); - foreach ($tabTmp3 as $i3=>$ope1val) - $tabTmp4[]=$ope1deb.strtr($ope1val,array('('=>'', ')'=>'', ','=>'.')); - $tmpFormule=' ('.implode(' && ', $tabTmp4).') '; - } elseif (preg_match('/(.*)à(.*)/', $valeur, $matches)) { - /** Gestion du 'à' (correspond à min < xxx < max **/ - $tmpFormule=' ('.$ope1deb.$ope1.' >= '.$matches[1].' && '.$ope1deb.$ope1.' <= '.$matches[2].') '; - } else { - if (!preg_match("/^substr/", $valeur)) { - $valeur = strtr($valeur,array(','=>'.')); - } - if ($operation=='' && $valeur=='') { - $tmpFormule=$ope1deb.$ope1; - } elseif ($operation<>'' && $valeur=='') { - $tmpFormule=$ope1deb.$ope1.$operation."''"; - } elseif (strtoupper($valeur)==strtolower($valeur) && $valeur<>'') { - $tmpFormule=$ope1deb.$ope1.$operation.$valeur; - } elseif (strtolower($valeur)=='vrai') { - $tmpFormule=$ope1deb.$ope1.$operation.'true'; - } elseif (strtolower($valeur)=='faux') { - $tmpFormule=$ope1deb.$ope1.$operation.'false'; - } elseif (strtolower($valeur)=='nmp') { - $tmpFormule=$ope1deb.$ope1.$operation.'$nmp'; - } else { - $tmpFormule=$ope1deb.$ope1.$operation.$valeur; - } - } - - $strParentDeb=$strParentFin=''; - if (preg_match_all('/(\()/',$operande,$matches)) { - $strParentDeb=implode(' ', $matches[1]); - $operande=trim(strtr($operande,array('('=>''))); - } elseif (preg_match_all('/(\))/',$operande,$matches)) { - $strParentFin=implode(' ', $matches[1]); - $operande=trim(strtr($operande,array(')'=>''))); - } - - switch ($operande) { - case 'SI': $strFormule= "if ( $strParentDeb $tmpFormule $strParentFin"; break; - case 'SI NON': $strFormule= "if ( $strParentDeb !($tmpFormule) $strParentFin"; break; - case 'ET': $strFormule.= " && $strParentDeb $tmpFormule $strParentFin"; break; - case 'ET NON': $strFormule.= " && $strParentDeb !($tmpFormule) $strParentFin"; break; - case 'OU': $strFormule.= " || $strParentDeb $tmpFormule $strParentFin"; break; - case 'OU NON': $strFormule.= " || $strParentDeb !($tmpFormule) $strParentFin"; break; - case 'ACTION': $strAction.= str_replace('==','=', " $tmpFormule; "); break; - case 'ECHANGE': $ECHANGE[] = $tmpFormule; break; - default: - echo 'Indiscore '.$id.' OPERANDE INCONNUE '.$operande."\n"; - break; - } - $idPre = $id; - //echo $strFormule."\n"; - } - - // --- Gestion de la dernière ligne de commentaire - $debugFormule.= $strFormule.') ) $C['.$idPre.']=true;'."\t"; - $strFormule = preg_replace('/\|([A-Z0-9\. \$\[\]]{1,12})\|/Ui', 'abs($1)', $strFormule); - $strFormule = preg_replace('/\$R\[0+/', '$R[', $strFormule); - $strFormule = preg_replace('/\$Ra\[0+/', '$Ra[', $strFormule); - $strFormule = preg_replace('/\$Rap\[0+/', '$Rap[', $strFormule); - $strFormule = preg_replace('/\$Rp\[0+/', '$Rp[', $strFormule); - $strFormule = preg_replace('/\$Rs\[0+/', '$Rs[', $strFormule); - $strFormule = preg_replace('/\$Rsp\[0+/', '$Rsp[', $strFormule); - $strFormule = preg_replace('/\$Revol\[0+/', '$Revol[', $strFormule); - $strFormule = preg_replace('/\$Revolp\[0+/', '$Revolp[', $strFormule); - $strFormule = preg_replace('/\$Revols\[0+/', '$Revols[', $strFormule); - $strFormule = preg_replace('/\$Rdiff\[0+/', '$Rdiff[', $strFormule); - for ($j=2;$j<5;$j++) { - $strFormule = preg_replace('/\$Rp'.$j.'\[0+/', '$Rp'.$j.'[', $strFormule); - $strFormule = preg_replace('/\$Rs'.$j.'\[0+/', '$Rs'.$j.'[', $strFormule); - $strFormule = preg_replace('/\$Rsp'.$j.'\[0+/', '$Rsp'.$j.'[', $strFormule); - $strFormule = preg_replace('/\$Revol'.$j.'\[0+/', '$Revol'.$j.'[', $strFormule); - $strFormule = preg_replace('/\$Revolp'.$j.'\[0+/', '$Revolp'.$j.'[', $strFormule); - } - $strAction = preg_replace('/\|([A-Z0-9\. \$\[\]]{1,12})\|/Ui', 'abs($1)', $strAction); - $strAction = preg_replace('/\$R\[0+/', '$R[', $strAction); - $strAction = preg_replace('/\$Ra\[0+/', '$Ra[', $strAction); - $strAction = preg_replace('/\$Rap\[0+/', '$Rap[', $strAction); - $strAction = preg_replace('/\$Rp\[0+/', '$Rp[', $strAction); - $strAction = preg_replace('/\$Rs\[0+/', '$Rs[', $strAction); - $strAction = preg_replace('/\$Rsp\[0+/', '$Rsp[', $strAction); - $strAction = preg_replace('/\$Revol\[0+/', '$Revol[', $strAction); - $strAction = preg_replace('/\$Revolp\[0+/', '$Revolp[', $strAction); - $strAction = preg_replace('/\$Rdiff\[0+/', '$Rdiff[', $strAction); - - eval ($strFormule.') $C['.$idPre.']=true;'); - - // Remplace "$" par "$this->" - fwrite($fp, str_replace('$', '$this->', $strFormule.') $C['.$idPre.']=true;')."\n"); - fwrite($fp, str_replace('$', '$this->', $strFormule.') $C['.$idPre.']=true;')."\n"); - fwrite($fp, "\n".'$ECHANGE=\''.serialize($ECHANGE)."';"."\n"); - fwrite($fp, "\n".'?>'."\n"); - fclose($fp); - $debugFormule.='$C['.$idPre.']='.$C[$idPre]."\r\n"; - - $strOutput=exec('php -l '.$file, $output); - if (preg_match('/^No syntax errors detected in /', $strOutput)) { - echo "Aucune erreur\n"; - } else { - echo "Erreur : $strOutput\n"; - print_r($output); - } -} - -// --- Commentaires -if ( isset($opts->comments) ) { - if ( isset($opts->type) && in_array($opts->type, array('score', 'valo')) ) { - $type = $opts->type; - } else { - $type = 'score'; - } - - $cycle = 2; - if (isset($opts->niveau)) { - $cycle = $opts->niveau; - } - $version = $opts->comments; - - // Select the right table in database in function of type - switch ($type) { - case 'score': - $tableComment = 'jo.scores_commentaires_'.$version; - break; - case 'valo': - $tableComment = 'jo.valo_commentaires_'.$version; - break; - } - $path = APPLICATION_PATH.'/../vendor/scores/library/src/Metier/Scores/Comment'; - - // Read comments text - $stmt = $conn->executeQuery("SELECT code, langue, cycle, ligne, commentaire, tri, deleted - FROM $tableComment - WHERE deleted=0 AND cycle=$cycle AND ligne NOT LIKE '%*%' AND commentaire NOT LIKE '.*%' - ORDER BY langue ASC, cycle ASC, code ASC, ligne ASC"); - $tabCommentaires = $tabTri = $tabTriAff = array(); - while ($commentaire = $stmt->fetch(\PDO::FETCH_ASSOC)) { - $id = $commentaire['code']*1; - $ligne = $commentaire['ligne']*1; - $tabCommentaires[$id][$ligne] = str_replace('"','\"',$commentaire['commentaire']); - if ($commentaire['tri']) { - //$tabTri[$id] = $commentaire['tri']; - $tabTriAff[$id] = ($commentaire['tri'].'.'.(10000000+(1*$commentaire['code'])))*1; - } - } - - // Table Tri Aff - $fp = fopen($path.'/'.ucfirst($type).'Tri'.$version.'N'.$cycle.'.php', 'w'); - fwrite($fp, ' $idVal) { - fwrite($fp, "\t" . $id." => ".$idVal."," . "\n"); - } - fwrite($fp, ");" . "\n"); - fclose($fp); - - // Table commentaires - $fp = fopen($path.'/'.ucfirst($type).'Txt'.$version.'N'.$cycle.'.php', 'w'); - fwrite($fp, ' $idVal) { - fwrite($fp, "\t" . $id." => array(" . "\n"); - foreach ($idVal as $ligne => $ligneVal) { - fwrite($fp, "\t\t" . $ligne." => \"".$ligneVal."\"," . "\n"); - } - fwrite($fp, "\t" . ")," . "\n"); - } - fwrite($fp, ");" . "\n"); - fclose($fp); - - echo "Code généré. \n"; -} - -// --- Gestion des éléments de cache -if ( $opts->tabcache) { - - $pathCache = APPLICATION_PATH . '/../vendor/scores/library/src/Metier/Scores/Data'; - - // Variables - $fp = fopen($pathCache . '/Variables.php','w'); - fwrite($fp, "executeQuery("SELECT code, codeType, libelleCase, libelle, article FROM insee.insee_tabAutres WHERE zone='TU'"); - if ($stmt->rowCount() > 0 ) { - fwrite($fp, "\t'TU' => array(\n"); - while ($item = $stmt->fetch(\PDO::FETCH_OBJ)) { - fwrite($fp, "\t\t'".$item->code."' => array("); - fwrite($fp, "'lib'=>\"" . $item->libelle . "\", 'art'=>\"".str_replace('$', $item->libelle, $item->article)."\""); - fwrite($fp, "),\n"); - } - fwrite($fp, "\t),\n"); - } - - /** REGIMP - RPEN */ - $stmt = $conn->executeQuery("SELECT REGION AS code, 'int' AS type, NCCENR AS libelle FROM insee.regions"); - if ($stmt->rowCount() > 0 ) { - fwrite($fp, "\t'REGIMP' => array(\n"); - while ($item = $stmt->fetch(\PDO::FETCH_OBJ)) { - fwrite($fp, "\t\t'".$item->code."' => array("); - fwrite($fp, "'lib'=>\"" . $item->libelle . "\", 'art'=>\"". $item->libelle ."\""); - fwrite($fp, "),\n"); - } - fwrite($fp, "\t),\n"); - fwrite($fp, "\t'RPEN' => array(\n"); - $stmt->closeCursor(); - while ($item = $stmt->fetch(\PDO::FETCH_OBJ)) { - fwrite($fp, "\t\t'".$item->code."' => array("); - fwrite($fp, "'lib'=>\"" . $item->libelle . "\", 'art'=>\"". $item->libelle ."\""); - fwrite($fp, "),\n"); - } - fwrite($fp, "\t),\n"); - } - - /** ZEMET */ - $stmt = $conn->executeQuery("SELECT codZEMET AS code, libZEMET AS libelle, article FROM insee.insee_tabZemet WHERE anneeZemet='1994'"); - if ($stmt->rowCount() > 0 ) { - fwrite($fp, "\t'ZEMET1994' => array(\n"); - while ($item = $stmt->fetch(\PDO::FETCH_OBJ)) { - if( in_array(strtoupper(substr($item->libelle,0,1)),array('A','E','I','O','U')) ) { - $prefix = "d'"; - } else { - $prefix = "de "; - } - fwrite($fp, "\t\t'".$item->code."' => array("); - fwrite($fp, "'lib'=>\"" . $item->libelle . "\", 'art'=>\"". $prefix . $item->libelle."\""); - fwrite($fp, "),\n"); - } - fwrite($fp, "\t),\n"); - } - $stmt = $conn->executeQuery("SELECT codZEMET AS code, libZEMET AS libelle, article FROM insee.insee_tabZemet WHERE anneeZemet='2010'"); - if ($stmt->rowCount() > 0 ) { - fwrite($fp, "\t'ZEMET2010' => array(\n"); - while ($item = $stmt->fetch(\PDO::FETCH_OBJ)) { - if( in_array(strtoupper(substr($item->libelle,0,1)),array('A','E','I','O','U')) ) { - $prefix = "d'"; - } else { - $prefix = "de "; - } - fwrite($fp, "\t\t'".$item->code."' => array("); - fwrite($fp, "'lib'=>\"" . $item->libelle . "\", 'art'=>\"". $prefix . $item->libelle."\""); - fwrite($fp, "),\n"); - } - fwrite($fp, "\t),\n"); - } - - - /** DEPSIE */ - $stmt = $conn->executeQuery("SELECT numdep AS code, libdep AS libelle FROM insee.departements"); - if ($stmt->rowCount() > 0 ) { - fwrite($fp, "\t'DEPSIE' => array(\n"); - while ($item = $stmt->fetch(\PDO::FETCH_OBJ)) { - fwrite($fp, "\t\t'".$item->code."' => array("); - fwrite($fp, "'lib'=>\"" . $item->libelle . "\", 'art'=>\"". $item->libelle ."\""); - fwrite($fp, "),\n"); - } - fwrite($fp, "\t),\n"); - } - - /** LIEUACT */ - $stmt = $conn->executeQuery("SELECT code, codeType, libelleCase, libelle, article FROM insee.insee_tabAutres WHERE zone='LIEUACT'"); - if ($stmt->rowCount() > 0 ) { - fwrite($fp, "\t'LIEUACT' => array(\n"); - while ($item = $stmt->fetch(\PDO::FETCH_OBJ)) { - fwrite($fp, "\t\t'".$item->code."' => array("); - fwrite($fp, "'lib'=>\"" . $item->libelle . "\", 'art'=>\"". preg_replace('/\$1?/', $item->libelle, $item->article) ."\""); - fwrite($fp, "),\n"); - } - fwrite($fp, "\t),\n"); - } - - /** ACTISURF */ - $stmt = $conn->executeQuery("SELECT code, codeType, libelleCase, libelle, article FROM insee.insee_tabAutres WHERE zone='ACTISURF'"); - if ($stmt->rowCount() > 0 ) { - fwrite($fp, "\t'ACTISURF' => array(\n"); - while ($item = $stmt->fetch(\PDO::FETCH_OBJ)) { - fwrite($fp, "\t\t'".$item->code."' => array("); - fwrite($fp, "'lib'=>\"" . $item->libelle . "\", 'art'=>\"". str_replace('$', $item->libelle, $item->article) ."\""); - fwrite($fp, "),\n"); - } - fwrite($fp, "\t),\n"); - } - - /** ACTIVNAT */ - $stmt = $conn->executeQuery("SELECT code, codeType, libelleCase, libelle, article FROM insee.insee_tabAutres WHERE zone='ACTIVNAT'"); - if ($stmt->rowCount() > 0 ) { - fwrite($fp, "\t'ACTIVNAT' => array(\n"); - while ($item = $stmt->fetch(\PDO::FETCH_OBJ)) { - fwrite($fp, "\t\t'".$item->code."' => array("); - fwrite($fp, "'lib'=>\"" . $item->libelle . "\", 'art'=>\"". str_replace('$', $item->libelle, $item->article) ."\""); - fwrite($fp, "),\n"); - } - fwrite($fp, "\t),\n"); - } - - /** FJUR - FJURINSEE - FJURRNCS*/ - $stmt = $conn->executeQuery("SELECT code, libelle FROM jo.tabFJur"); - if ($stmt->rowCount() > 0 ) { - fwrite($fp, "\t'FJUR' => array(\n"); - while ($item = $stmt->fetch(\PDO::FETCH_OBJ)) { - fwrite($fp, "\t\t'".$item->code."' => array("); - fwrite($fp, "'lib'=>\"" . str_replace('"','\"',$item->libelle) . "\", 'art'=>\"". str_replace('"','\"',$item->libelle) ."\""); - fwrite($fp, "),\n"); - } - fwrite($fp, "\t),\n"); - fwrite($fp, "\t'FJURINSEE' => array(\n"); - while ($item = $stmt->fetch(\PDO::FETCH_OBJ)) { - fwrite($fp, "\t\t'".$item->code."' => array("); - fwrite($fp, "'lib'=>\"" . str_replace('"','\"',$item->libelle) . "\", 'art'=>\"". str_replace('"','\"',$item->libelle) ."\""); - fwrite($fp, "),\n"); - } - fwrite($fp, "\t),\n"); - fwrite($fp, "\t'FJURRNCS' => array(\n"); - while ($item = $stmt->fetch(\PDO::FETCH_OBJ)) { - fwrite($fp, "\t\t'".$item->code."' => array("); - fwrite($fp, "'lib'=>\"" . str_replace('"','\"',$item->libelle) . "\", 'art'=>\"". str_replace('"','\"',$item->libelle) ."\""); - fwrite($fp, "),\n"); - } - fwrite($fp, "\t),\n"); - } - - /** APEENT - APEINSEE - APERNCS */ - $stmt = $conn->executeQuery("SELECT codNaf700 AS code, libNaf700 AS libelle FROM jo.tabNaf4 UNION SELECT codNaf5 AS code, libNaf5 AS libelle FROM jo.tabNaf5"); - if ($stmt->rowCount() > 0 ) { - fwrite($fp, "\t'APEENT' => array(\n"); - while ($item = $stmt->fetch(\PDO::FETCH_OBJ)) { - fwrite($fp, "\t\t'".$item->code."' => array("); - fwrite($fp, "'lib'=>\"" . $item->libelle . "\", 'art'=>\"". $item->libelle ."\""); - fwrite($fp, "),\n"); - } - fwrite($fp, "\t),\n"); - fwrite($fp, "\t'APEINSEE' => array(\n"); - while ($item = $stmt->fetch(\PDO::FETCH_OBJ)) { - fwrite($fp, "\t\t'".$item->code."' => array("); - fwrite($fp, "'lib'=>\"" . $item->libelle . "\", 'art'=>\"". $item->libelle ."\""); - fwrite($fp, "),\n"); - } - fwrite($fp, "\t),\n"); - fwrite($fp, "\t'APERNCS' => array(\n"); - while ($item = $stmt->fetch(\PDO::FETCH_OBJ)) { - fwrite($fp, "\t\t'".$item->code."' => array("); - fwrite($fp, "'lib'=>\"" . $item->libelle . "\", 'art'=>\"". $item->libelle ."\""); - fwrite($fp, "),\n"); - } - fwrite($fp, "\t),\n"); - } - - fwrite($fp, ");\n"); - fclose($fp); - - /** Taux d'inflation **/ - $fp = fopen($pathCache . '/Infla.php','w'); - fwrite($fp, "executeQuery("SELECT annee, infla FROM sdv1.inflation WHERE annee>1990 ORDER BY annee"); - if ($stmt->rowCount() > 0 ) { - while ($item = $stmt->fetch(\PDO::FETCH_OBJ)) { - fwrite($fp, "\t" . $item->annee . " => " . $item->infla . ",\n"); - } - } - - fwrite($fp, ");\n"); - fclose($fp); - - /** Taux de rendement des actions **/ - $fp = fopen($pathCache . '/RendObli.php','w'); - fwrite($fp, "executeQuery("SELECT annee, txMoinsInfla FROM sdv1.txRendObli WHERE annee>1990 ORDER BY annee ASC"); - if ($stmt->rowCount() > 0 ) { - while ($item = $stmt->fetch(\PDO::FETCH_OBJ)) { - fwrite($fp, "\t" . $item->annee . " => " . $item->txMoinsInfla . ",\n"); - } - } - fwrite($fp, ");\n"); - fclose($fp); - - /** Formules **/ - $fp = fopen($pathCache . '/Formules.php','w'); - fwrite($fp, "executeQuery("SELECT id, libelle, formule, unite, commentaires, borneMin, borneMax, calcul, deleted FROM jo.ratios_formules WHERE deleted=0"); - if ($stmt->rowCount() > 0 ) { - $i = 0; - while ($item = $stmt->fetch(\PDO::FETCH_OBJ)) { - fwrite($fp, "\t".$i." => array(\n"); - fwrite($fp, "\t\t'id' => ".intval($item->id).",\n"); - fwrite($fp, "\t\t'libelle' => \"".trim(str_replace('"','\"',$item->libelle))."\",\n"); - fwrite($fp, "\t\t'commentaires' => \"".trim(str_replace('"','\"',$item->commentaires))."\",\n"); - fwrite($fp, "\t\t'unite' => '".$item->unite."',\n"); - fwrite($fp, "\t\t'borneMin' => '".$item->borneMin."',\n"); - fwrite($fp, "\t\t'borneMax' => '".$item->borneMax."',\n"); - fwrite($fp, "\t\t'formule' => '".$item->formule."',\n"); - fwrite($fp, "\t),\n"); - - $i++; - } - } - - fwrite($fp, ");\n"); - fclose($fp); -} diff --git a/bin/buildCodeSfr.php b/bin/buildCodeSfr.php deleted file mode 100644 index cd16d087..00000000 --- a/bin/buildCodeSfr.php +++ /dev/null @@ -1,47 +0,0 @@ - "Aide.", - 'compile-s' => "Génére le cache des règles, sans paramètres (tout), avec paramètres (VORD, VORP, PO)", - 'version=s' => "Version des régles", - )); - $opts->parse(); - $optionsNb = count($opts->getOptions()); -} catch (Zend_Console_Getopt_Exception $e) { - $displayUsage = true; -} - -// --- Aide / Options -if ($optionsNb == 0 || isset($opts->help)) { - $displayUsage = true; -} - -// --- Usage -if ($displayUsage) { - echo "\nRegles SFR\n\n"; - echo $opts->getUsageMessage(); - exit; -} - -$types = array('VORD', 'VORP', 'PO'); - -if ( $opts->compile!='' && in_array($opts->compile, $types) ) { - $types = array($opts->compile); -} - -if ( count($types) > 0 ) { - - foreach ( $types as $type ) { - $ruleSfrM = new Metier_Sfr_Compile($conn); - $ruleSfrM->setVersion($opts->version); - $ruleSfrM->construct($type); - } - -} - - - diff --git a/bin/buildLog.php b/bin/buildLog.php deleted file mode 100644 index e1f5a9cc..00000000 --- a/bin/buildLog.php +++ /dev/null @@ -1,57 +0,0 @@ - "Aide.", - 'log' => "", - )); - $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 "\nLog\n\n"; - echo $opts->getUsageMessage(); - exit; -} - -if ($opts->log) { - $sql = "SELECT * FROM sdv1.logs_item"; - $stmt = $conn->prepare($sql); - $stmt->execute(); - - $outPath = APPLICATION_PATH . '/../vendor/scores/library/src/Scores/Account/Log/List.php'; - $outFile = $outPath . '/Config.php'; - if ($stmt->rowCount() > 0) { - $result = $stmt->fetchAll(\PDO::FETCH_OBJ); - file_put_contents($outFile, "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); - } -} - - - - - - - diff --git a/bin/loadCodeRatios.php b/bin/loadCodeRatios.php deleted file mode 100644 index bb42b86e..00000000 --- a/bin/loadCodeRatios.php +++ /dev/null @@ -1,632 +0,0 @@ - "Aide.", - 'fichier=s' => "Nom du fichier complet : version ", - '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; -} - - - ######################################################### - ##### 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 . '/../vendor/scores/library/src/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 "" . $Erreur . "

\n"; -// -// if ($sql_ctt_query) // si code retour OK -// { -// echo "Création de la table $nomtable ok.
"; -// } -// else -// { -// echo "Création de la table $nomtable échouée.
"; -// } \ No newline at end of file