903 lines
35 KiB
PHP
903 lines
35 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__ . '/../../library/Scores/autoload_classmap.php',
|
|
__DIR__ . '/../../application/autoload_classmap.php',
|
|
),
|
|
'Zend_Loader_StandardAutoloader' => array(
|
|
'prefixes' => array(
|
|
'Zend' => __DIR__ . '/../../library/Zend',
|
|
'Application' => __DIR__ . '/../../library/Application',
|
|
'Scores' => __DIR__ . '/../../library/Scores',
|
|
'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.",
|
|
'ratios' => "Génére le cache des ratios (configMRatios.php)",
|
|
'type-s' => "Choix du type d'indiScore : scores 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",
|
|
)
|
|
);
|
|
$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;
|
|
}
|
|
|
|
$c = new Zend_Config($application->getOptions());
|
|
Zend_Registry::set('config', $c);
|
|
|
|
require_once 'WsScore/Configure.php';
|
|
$oldconfig = new Configure();
|
|
|
|
require_once 'framework/fwk.php';
|
|
require_once 'framework/common/chiffres.php';
|
|
require_once 'framework/common/dates.php';
|
|
require_once 'framework/mail/sendMail.php';
|
|
require_once 'Metier/insee/classMInsee.php';
|
|
require_once 'Metier/partenaires/classMGreffes.php';
|
|
require_once 'Metier/partenaires/classMBilans.php';
|
|
|
|
if (isset($opts->ratios)){
|
|
if (genereCacheRatios() === true){
|
|
echo "Code Ok.\n";
|
|
}
|
|
}
|
|
|
|
if ( isset($opts->formules) ) {
|
|
|
|
if ( isset($opts->type) && in_array($opts->type, array('scores', 'valo')) ) {
|
|
$type = $opts->type;
|
|
} else {
|
|
$type = 'scores';
|
|
}
|
|
|
|
if (genereCacheIndiscore($opts->formules, $type) === true){
|
|
echo "Code Ok.\n";
|
|
}
|
|
}
|
|
|
|
if ( isset($opts->comments) ) {
|
|
if ( isset($opts->type) && in_array($opts->type, array('scores', 'valo')) ) {
|
|
$type = $opts->type;
|
|
} else {
|
|
$type = 'scores';
|
|
}
|
|
|
|
if (genereCacheCommentaires($opts->comments, $type) === true){
|
|
echo "Code Ok.\n";
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
* Make the static data file cache configMRatios.tmp.php
|
|
* Must be rename as configRatios.php
|
|
*/
|
|
function genereCacheRatios()
|
|
{
|
|
$tabMoy=array();
|
|
$iDb = new WDB("jo");
|
|
|
|
$file = APPLICATION_PATH.'/../library/SdMetier/Scoring/Ratios.php';
|
|
|
|
$fp=fopen($file, 'w');
|
|
fwrite($fp, "<?php\n");
|
|
fwrite($fp, "/** Auto generated class ".date('Y-m-d H:i:s')."*/\n");
|
|
fwrite($fp, "\n");
|
|
fwrite($fp, "require_once 'SdMetier/Scoring/Vars.php';\n");
|
|
fwrite($fp, "\n");
|
|
fwrite($fp, "class SdMetier_Scoring_Ratios extends SdMetier_Scoring_Vars\n");
|
|
fwrite($fp, "{\n");
|
|
fwrite($fp, "\tpublic \$tva=19.6;\n");
|
|
|
|
fwrite($fp, "\tpublic \$tabVariables = array(\n");
|
|
|
|
/* TU */
|
|
$tabTmp = $iDb->select("insee.insee_tabAutres", "`code`, `codeType`, libelleCase, `libelle`, `article`", "zone='TU'", false, MYSQL_ASSOC);
|
|
fwrite($fp, "\t\t'TU'=> array(\n");
|
|
foreach ($tabTmp as $i => $val) {
|
|
fwrite($fp, "\t\t\t'".$val['code']."'=> array(\n");
|
|
fwrite($fp, "\t\t\t\t'lib'=> \"".$val['libelle']."\",\n");
|
|
fwrite($fp, "\t\t\t\t'article'=> \"".str_replace('$', $val['libelle'], $val['article'])."\",\n");
|
|
fwrite($fp, "\t\t\t),\n");
|
|
}
|
|
fwrite($fp, "\t\t),\n");
|
|
|
|
/* REGIMP */
|
|
$tabTmp = $iDb->select("insee.regions", "REGION AS code, 'int' AS type, NCCENR AS libelle", "1", false, MYSQL_ASSOC);
|
|
fwrite($fp, "\t\t'REGIMP'=> array(\n");
|
|
foreach ($tabTmp as $i => $val) {
|
|
fwrite($fp, "\t\t\t'".$val['code']."'=> array(\n");
|
|
fwrite($fp, "\t\t\t\t'lib'=> \"".$val['libelle']."\",\n");
|
|
fwrite($fp, "\t\t\t\t'art'=> \"".$val['libelle']."\",\n");
|
|
fwrite($fp, "\t\t\t),\n");
|
|
}
|
|
fwrite($fp, "\t\t),\n");
|
|
|
|
|
|
/* RPEN */
|
|
fwrite($fp, "\t\t'RPEN'=> array(\n");
|
|
foreach ($tabTmp as $i => $val) {
|
|
fwrite($fp, "\t\t\t'".$val['code']."'=> array(\n");
|
|
fwrite($fp, "\t\t\t\t'lib'=> \"".$val['libelle']."\",\n");
|
|
fwrite($fp, "\t\t\t\t'art'=> \"".$val['libelle']."\",\n");
|
|
fwrite($fp, "\t\t\t),\n");
|
|
}
|
|
fwrite($fp, "\t\t),\n");
|
|
|
|
|
|
/* ZEMET */
|
|
$tabTmp = $iDb->select("insee.insee_tabZemet", "codZEMET AS code, libZEMET AS libelle, article", "1", false, MYSQL_ASSOC);
|
|
fwrite($fp, "\t\t'ZEMET'=> array(\n");
|
|
foreach ($tabTmp as $i => $val) {
|
|
fwrite($fp, "\t\t\t'".$val['code']."'=> array(\n");
|
|
fwrite($fp, "\t\t\t\t'lib'=> \"".$val['libelle']."\",\n");
|
|
if( in_array(strtoupper(substr($val['lib'],0,1)),array('A','E','I','O','U')) ) {
|
|
fwrite($fp, "\t\t\t\t'art'=> \"d'".$val['libelle']."\",\n");
|
|
} else {
|
|
fwrite($fp, "\t\t\t\t'art'=> \"de ".$val['libelle']."\",\n");
|
|
}
|
|
fwrite($fp, "\t\t\t),\n");
|
|
}
|
|
fwrite($fp, "\t\t),\n");
|
|
|
|
/* DEPSIE */
|
|
fwrite($fp, "\t\t'DEPSIE'=> array(\n");
|
|
$tabTmp = $iDb->select("insee.departements", "numdep AS code, libdep AS libelle", "1", false, MYSQL_ASSOC);
|
|
foreach ($tabTmp as $i => $val) {
|
|
fwrite($fp, "\t\t\t'".$val['code']."'=> array(\n");
|
|
fwrite($fp, "\t\t\t\t'lib'=> \"".$val['libelle']."\",\n");
|
|
fwrite($fp, "\t\t\t\t'art'=> \"".$val['libelle']."\",\n");
|
|
fwrite($fp, "\t\t\t),\n");
|
|
}
|
|
fwrite($fp, "\t\t),\n");
|
|
|
|
/* LIEUACT */
|
|
$tabTmp = $iDb->select("insee.insee_tabAutres", "`code`, `codeType`, libelleCase, `libelle`, `article`", "zone='LIEUACT'", false, MYSQL_ASSOC);
|
|
fwrite($fp, "\t\t'LIEUACT'=> array(\n");
|
|
foreach ($tabTmp as $i => $val) {
|
|
fwrite($fp, "\t\t\t'".$val['code']."'=> array(\n");
|
|
fwrite($fp, "\t\t\t\t'lib'=> \"".$val['libelle']."\",\n");
|
|
fwrite($fp, "\t\t\t\t'art'=> \"".preg_replace('/\$1?/', $val['libelle'], $val['article'])."\",\n");
|
|
fwrite($fp, "\t\t\t),\n");
|
|
}
|
|
fwrite($fp, "\t\t),\n");
|
|
|
|
/* ACTISURF */
|
|
$tabTmp = $iDb->select("insee.insee_tabAutres", "`code`, `codeType`, libelleCase, `libelle`, `article`", "zone='ACTISURF'", false, MYSQL_ASSOC);
|
|
fwrite($fp, "\t\t'ACTISURF'=> array(\n");
|
|
foreach ($tabTmp as $i => $val) {
|
|
fwrite($fp, "\t\t\t'".$val['code']."'=> array(\n");
|
|
fwrite($fp, "\t\t\t\t'lib'=> \"".$val['libelle']."\",\n");
|
|
fwrite($fp, "\t\t\t\t'art'=> \"".str_replace('$', $val['libelle'], $val['article'])."\",\n");
|
|
fwrite($fp, "\t\t\t),\n");
|
|
}
|
|
fwrite($fp, "\t\t),\n");
|
|
|
|
/** ACTIVNAT */
|
|
$tabTmp = $iDb->select("insee.insee_tabAutres", "`code`, `codeType`, libelleCase, `libelle`, `article`", "zone='ACTIVNAT'", false, MYSQL_ASSOC);
|
|
fwrite($fp, "\t\t'ACTIVNAT'=> array(\n");
|
|
foreach ($tabTmp as $i => $val) {
|
|
fwrite($fp, "\t\t\t'".$val['code']."'=> array(\n");
|
|
fwrite($fp, "\t\t\t\t'lib'=> \"".$val['libelle']."\",\n");
|
|
fwrite($fp, "\t\t\t\t'art'=> \"".str_replace('$', $val['libelle'], $val['article'])."\",\n");
|
|
fwrite($fp, "\t\t\t),\n");
|
|
}
|
|
fwrite($fp, "\t\t),\n");
|
|
|
|
/* FJUR */
|
|
$tabTmp = $iDb->select("jo.tabFJur", "`code`, `libelle`", "1", false, MYSQL_ASSOC);
|
|
fwrite($fp, "\t\t'FJUR'=> array(\n");
|
|
foreach ($tabTmp as $i => $val) {
|
|
fwrite($fp, "\t\t\t'".$val['code']."'=> array(\n");
|
|
fwrite($fp, "\t\t\t\t'lib'=> \"".str_replace('"','\"',$val['libelle'])."\",\n");
|
|
fwrite($fp, "\t\t\t\t'art'=> \"".str_replace('"','\"',$val['libelle'])."\",\n");
|
|
fwrite($fp, "\t\t\t),\n");
|
|
}
|
|
fwrite($fp, "\t\t),\n");
|
|
|
|
/* FJURINSEE */
|
|
fwrite($fp, "\t\t'FJURINSEE'=> array(\n");
|
|
foreach ($tabTmp as $i => $val) {
|
|
fwrite($fp, "\t\t\t'".$val['code']."'=> array(\n");
|
|
fwrite($fp, "\t\t\t\t'lib'=> \"".str_replace('"','\"',$val['libelle'])."\",\n");
|
|
fwrite($fp, "\t\t\t\t'art'=> \"".str_replace('"','\"',$val['libelle'])."\",\n");
|
|
fwrite($fp, "\t\t\t),\n");
|
|
}
|
|
fwrite($fp, "\t\t),\n");
|
|
|
|
/* FJURRNCS */
|
|
fwrite($fp, "\t\t'FJURRNCS'=> array(\n");
|
|
foreach ($tabTmp as $i => $val) {
|
|
fwrite($fp, "\t\t\t'".$val['code']."'=> array(\n");
|
|
fwrite($fp, "\t\t\t\t'lib'=> \"".str_replace('"','\"',$val['libelle'])."\",\n");
|
|
fwrite($fp, "\t\t\t\t'art'=> \"".str_replace('"','\"',$val['libelle'])."\",\n");
|
|
fwrite($fp, "\t\t\t),\n");
|
|
}
|
|
fwrite($fp, "\t\t),\n");
|
|
|
|
/* APEENT */
|
|
$tabTmp = $iDb->select("jo.tabNaf5", "`codNaf700` AS code, `libNaf700` AS libelle FROM tabNaf4 UNION SELECT `codNaf5` AS code, `libNaf5` AS libelle", "1", false, MYSQL_ASSOC);
|
|
fwrite($fp, "\t\t'APEENT'=> array(\n");
|
|
foreach ($tabTmp as $i => $val) {
|
|
fwrite($fp, "\t\t\t'".$val['code']."'=> array(\n");
|
|
fwrite($fp, "\t\t\t\t'lib'=> \"".$val['libelle']."\",\n");
|
|
fwrite($fp, "\t\t\t\t'art'=> \"".$val['libelle']."\",\n");
|
|
fwrite($fp, "\t\t\t),\n");
|
|
}
|
|
fwrite($fp, "\t\t),\n");
|
|
|
|
/* APEINSEE */
|
|
fwrite($fp, "\t\t'APEINSEE'=> array(\n");
|
|
foreach ($tabTmp as $i => $val) {
|
|
fwrite($fp, "\t\t\t'".$val['code']."'=> array(\n");
|
|
fwrite($fp, "\t\t\t\t'lib'=> \"".$val['libelle']."\",\n");
|
|
fwrite($fp, "\t\t\t\t'art'=> \"".$val['libelle']."\",\n");
|
|
fwrite($fp, "\t\t\t),\n");
|
|
}
|
|
fwrite($fp, "\t\t),\n");
|
|
|
|
/* APERNCS */
|
|
fwrite($fp, "\t\t'APERNCS'=> array(\n");
|
|
foreach ($tabTmp as $i => $val) {
|
|
fwrite($fp, "\t\t\t'".$val['code']."'=> array(\n");
|
|
fwrite($fp, "\t\t\t\t'lib'=> \"".$val['libelle']."\",\n");
|
|
fwrite($fp, "\t\t\t\t'art'=> \"".$val['libelle']."\",\n");
|
|
fwrite($fp, "\t\t\t),\n");
|
|
}
|
|
fwrite($fp, "\t\t),\n");
|
|
|
|
//Fin tabVariables
|
|
fwrite($fp, "\t);\n");
|
|
|
|
/** Taux d'inflation **/
|
|
fwrite($fp, "\tpublic \$tabInfla=array(\n");
|
|
$tabTmp=$iDb->select("sdv1.inflation", "annee, infla", "annee>1990 ORDER BY annee", false, MYSQL_ASSOC);
|
|
foreach ($tabTmp as $tabTmp2) {
|
|
fwrite($fp, "\t\t'".$tabTmp2['annee']."' => ".$tabTmp2['infla'].",\n");
|
|
}
|
|
//Fin tabInfla
|
|
fwrite($fp, "\t);\n");
|
|
|
|
/** Taux de rendement des actions **/
|
|
fwrite($fp, "\tpublic \$tabTxRendObli=array(\n");
|
|
$tabTmp=$iDb->select("sdv1.txRendObli", "annee, txMoinsInfla", "annee>1990 ORDER BY annee ASC", false, MYSQL_ASSOC);
|
|
foreach ($tabTmp as $tabTmp2) {
|
|
fwrite($fp, "\t\t'".$tabTmp2['annee']."' => ".$tabTmp2['txMoinsInfla'].",\n");
|
|
}
|
|
//Fin tabTxRendObli
|
|
fwrite($fp, "\t);\n");
|
|
|
|
fwrite($fp, "\tpublic \$tabFormules=array(\n");
|
|
$tabFormules=$iDb->select('ratios_formules',
|
|
'id, libelle, formule, unite, commentaires, borneMin, borneMax, calcul, deleted',
|
|
'deleted=0');
|
|
foreach ($tabFormules as $i=>$formule) {
|
|
$id=$formule['id']*1;
|
|
fwrite($fp, "\t\t'".$i."' => array(\n");
|
|
|
|
fwrite($fp, "\t\t\t'id' => \"".$id."\",\n");
|
|
fwrite($fp, "\t\t\t'libelle' => \"".trim(str_replace('"','\"',$formule['libelle']))."\",\n");
|
|
fwrite($fp, "\t\t\t'commentaires' => \"".trim(str_replace('"','\"',$formule['commentaires']))."\",\n");
|
|
fwrite($fp, "\t\t\t'unite' => \"".$formule['unite']."\",\n");
|
|
fwrite($fp, "\t\t\t'borneMin' => \"".$formule['borneMin']."\",\n");
|
|
fwrite($fp, "\t\t\t'borneMax' => \"".$formule['borneMax']."\",\n");
|
|
fwrite($fp, "\t\t\t'formule' => \"".$formule['formule']."\",\n");
|
|
fwrite($fp, "\t\t),\n");
|
|
}
|
|
//Fin tabFormules
|
|
fwrite($fp, "\t);\n");
|
|
|
|
fwrite($fp, "\n");
|
|
|
|
fwrite($fp, "\t"."/**" ."\n");
|
|
fwrite($fp, "\t"." * Donne le taux d'inflation pour une année" ."\n");
|
|
fwrite($fp, "\t"." * @param string \$annee" ."\n");
|
|
fwrite($fp, "\t"." */" ."\n");
|
|
fwrite($fp, "\t"."function getInflation(\$annee) {" ."\n");
|
|
fwrite($fp, "\t"." if (isset(\$this->tabInfla[\$annee]))" ."\n");
|
|
fwrite($fp, "\t"." return \$this->tabInfla[\$annee];" ."\n");
|
|
fwrite($fp, "\t"."}" ."\n");
|
|
|
|
fwrite($fp, "\t"."/**" ."\n");
|
|
fwrite($fp, "\t"." * Donne le taux de rendement des actions pour une année donnée" ."\n");
|
|
fwrite($fp, "\t"." * @param string \$annee" ."\n");
|
|
fwrite($fp, "\t"." */" ."\n");
|
|
fwrite($fp, "\t"."function getTxRendement(\$annee) {" ."\n");
|
|
fwrite($fp, "\t"." if (isset(\$this->tabTxRendObli[\$annee]))" ."\n");
|
|
fwrite($fp, "\t"." return \$this->tabTxRendObli[\$annee];" ."\n");
|
|
fwrite($fp, "\t"."}" ."\n");
|
|
|
|
|
|
fwrite($fp, "\t"."/**" ."\n");
|
|
fwrite($fp, "\t"." * calculRatios" ."\n");
|
|
fwrite($fp, "\t"." * @param array \$tabBilans" ."\n");
|
|
fwrite($fp, "\t"." * @param array \$tabIdentite" ."\n");
|
|
fwrite($fp, "\t"." * @param boolean \$accesPartenaire" ."\n");
|
|
fwrite($fp, "\t"." * @return number" ."\n");
|
|
fwrite($fp, "\t"." */" ."\n");
|
|
fwrite($fp, "\t"."function calculRatios(\$tabBilans, \$tabIdentite, \$accesPartenaire) {" ."\n");
|
|
|
|
//$tva - $mBil - $efftr
|
|
|
|
fwrite($fp, "\t"." \$numBil = 0;" ."\n");
|
|
fwrite($fp, "\t"." \$numBilType = array();" ."\n");
|
|
fwrite($fp, "\t"." \$taRatios = array();" ."\n");
|
|
fwrite($fp, "\t"." \$nbRatiosMax = 5;" ."\n");
|
|
fwrite($fp, "\t"." if ( count(\$tabBilans) > 0 ) {" ."\n");
|
|
fwrite($fp, "\t"." foreach (\$tabBilans as \$millesime => \$bil) {" ."\n");
|
|
fwrite($fp, "\t"." \$ref=\$bil['ref'];" ."\n");
|
|
fwrite($fp, "\t"." \$tabTmp = \$mBil->getBilan(substr(\$millesime,-10), substr(\$millesime,0,1), \$ref, \$accesPartenaire, \$nbRatiosMax);"."\n");
|
|
fwrite($fp, "\t"." \$numBilType[substr(\$millesime,0,1)]++;" ."\n");
|
|
fwrite($fp, "\t"." if (substr(\$millesime,0,1)=='S') {" ."\n");
|
|
fwrite($fp, "\t"." if (\$numBilType['S']>\$nbRatiosMax) continue;" ."\n");
|
|
fwrite($fp, "\t"." \$tabTmp2=\$mBil->bilanSimplifie2Normal(\$tabTmp);" ."\n");
|
|
fwrite($fp, "\t"." \$tabBilan[\$numBil]=array_merge(\$tabTmp2, \$tabTmp);" ."\n");
|
|
fwrite($fp, "\t"." } elseif (substr(\$millesime,0,1)=='N') {" ."\n");
|
|
fwrite($fp, "\t"." if (\$numBilType['N']>\$nbRatiosMax) continue;" ."\n");
|
|
fwrite($fp, "\t"." \$tabBilan[\$numBil]=\$tabTmp;" ."\n");
|
|
fwrite($fp, "\t"." } elseif (substr(\$millesime,0,1)=='C') {" ."\n");
|
|
fwrite($fp, "\t"." if (\$numBilType['C']>\$nbRatiosMax) continue;" ."\n");
|
|
fwrite($fp, "\t"." \$tabBilan[\$numBil]=\$tabTmp;" ."\n");
|
|
fwrite($fp, "\t"." } elseif (substr(\$millesime,0,1)=='A') {" ."\n");
|
|
fwrite($fp, "\t"." if (\$numBilType['A']>\$nbRatiosMax) continue;" ."\n");
|
|
fwrite($fp, "\t"." \$tabBilan[\$numBil]=\$tabTmp;" ."\n");
|
|
fwrite($fp, "\t"." } elseif (substr(\$millesime,0,1)=='B') {" ."\n");
|
|
fwrite($fp, "\t"." if (\$numBilType['B']>\$nbRatiosMax) continue;" ."\n");
|
|
fwrite($fp, "\t"." \$tabBilan[$numBil]=\$tabTmp;" ."\n");
|
|
fwrite($fp, "\t"." }" ."\n");
|
|
fwrite($fp, "\t"." unset(\$tabTmp); unset(\$tabTmp2);" ."\n");
|
|
fwrite($fp, "\t"." if (\$numBil>10) break;" ."\n");
|
|
fwrite($fp, "\t"." \$p=\$tabBilan[\$numBil];" ."\n");
|
|
fwrite($fp, "\t"." \$nm=\$p['DUREE_MOIS'];" ."\n");
|
|
fwrite($fp, "\t"." \$nmp=\$p['DUREE_MOIS_PRE'];" ."\n");
|
|
fwrite($fp, "\t"." \$R=array();" ."\n");
|
|
|
|
foreach ($tabFormules as $i=>$formule) {
|
|
$id=$formule['id']*1;
|
|
$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('/([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('/\bR\[(.*)\]/U', '\$R['."\\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', '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.="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.="if (\$R[$id]<$bMin) \$R[$id]=$bMin;";
|
|
}
|
|
if (isset($tabBornes[1]) && trim(@$tabBornes[1])<>'') {
|
|
$bMax=trim($tabBornes[1])*1;
|
|
$formule1.="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.="if (\$R[$id]>$bMax) \$R[$id]=$bMax;";
|
|
}
|
|
$formule2=$formule1;
|
|
|
|
fwrite($fp, "\t\t\t\t".$formule2."\n");
|
|
fwrite($fp, "\t\t\t\t".'if (!isset($R['.$id.'])) $R['.$id.']=\'NS\';'."\n");
|
|
}
|
|
}
|
|
|
|
fwrite($fp, "\n\t\t\t\t".'$tabRatios[$numBil]=$R;'."\n");
|
|
fwrite($fp, "\t\t\t\t".'$numBil++;'."\n");
|
|
fwrite($fp, "\t\t\t".'}'."\n");
|
|
fwrite($fp, "\t\t".'}'."\n\n");
|
|
|
|
foreach($tabMoy as $iRatio=>$tMoy) {
|
|
$irMoy=$tMoy['ratio'];
|
|
$nbExo=$tMoy['nbExo'];
|
|
fwrite($fp, "\t".' for($i=0; $i<$numBil; $i++) {'."\n");
|
|
fwrite($fp, "\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".' }'."\n\n");
|
|
}
|
|
|
|
fwrite($fp, "\t\t".'return $tabRatios;'."\n");
|
|
fwrite($fp, "\t}"."\n");
|
|
|
|
fwrite($fp, '}'."\n");
|
|
fclose ($fp);
|
|
|
|
$strOutput=exec('php -l '.$file, $output);
|
|
if (preg_match('/^No syntax errors detected in /', $strOutput)) {
|
|
return true;
|
|
} else {
|
|
print_r($output);
|
|
return false;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Make the static file cache for indIscore
|
|
* (indiscore.tmp.php, must be rename as indiscore$version.php)
|
|
* @param string $version ex : "_XXX" where XXX is the number version to select the right table in
|
|
* database
|
|
* @param string $type
|
|
* scores : Comments for the score version, valo : Comments for the "valorisation" version
|
|
* @return string
|
|
*/
|
|
function genereCacheIndiscore($version, $type = 'scores')
|
|
{
|
|
$cycleClient = 2;
|
|
|
|
// Chargement des formules de commentaires
|
|
$tabFormulesScore=array();
|
|
|
|
$iDb = new WDB("jo");
|
|
|
|
// Select the right table in database in function of type
|
|
switch ($type) {
|
|
case 'scores':
|
|
$fileIndiscore = APPLICATION_PATH.'/../library/Metier/scores/Variables/indiscore'.$version.'.php';
|
|
$fileIndiscoreTmp = APPLICATION_PATH.'/../library/Metier/scores/Variables/FormulesIndiscore.tmp.php';
|
|
$tableFormu = 'scores_formules_'.$version;
|
|
$tableComment = 'scores_commentaires_'.$version;
|
|
break;
|
|
|
|
case 'valo':
|
|
$fileIndiscore = APPLICATION_PATH.'/../library/Metier/scores/Variables/valo'.$version.'.php';
|
|
$fileIndiscoreTmp = APPLICATION_PATH.'/../library/Metier/scores/Variables/FormulesValo.tmp.php';
|
|
$tableFormu = 'valo_formules_'.$version;
|
|
$tableComment = 'valo_commentaires_'.$version;
|
|
break;
|
|
}
|
|
|
|
//Read comments
|
|
$tabTmp = $iDb->select(
|
|
$tableComment,
|
|
'code, langue, cycle, ligne, commentaire, tri, deleted',
|
|
"deleted=0 AND cycle=$cycleClient AND ligne NOT LIKE '%*%' AND commentaire NOT LIKE '.*%' ORDER BY langue ASC, cycle ASC, code ASC, ligne ASC",
|
|
false, MYSQL_ASSOC);
|
|
|
|
foreach ($tabTmp as $i=>$commentaire) {
|
|
$id=$commentaire['code']*1;
|
|
$cycle=$commentaire['cycle']*1;
|
|
$ligne=$commentaire['ligne']*1;
|
|
$tabCommentaires[$id][$cycle][$ligne]=$commentaire['commentaire'];
|
|
if ($commentaire['tri']) {
|
|
$tabTri[$id]=$commentaire['tri'];
|
|
$tabTriAff[$id]=($commentaire['tri'].'.'.(10000000+(1*$commentaire['code'])))*1;
|
|
}
|
|
}
|
|
|
|
// Read formulas
|
|
$tabTmp = $iDb->select(
|
|
$tableFormu,
|
|
'code, ligne, remarque, operande, ope1, operation, valeur',
|
|
"deleted=0 AND ligne NOT LIKE '%*%' ORDER BY code ASC, ligne ASC",
|
|
false, MYSQL_ASSOC
|
|
);
|
|
|
|
$idPre=$strFormule=false;
|
|
$debugFormule='';
|
|
|
|
$fp2=fopen($fileIndiscoreTmp,'w');
|
|
fwrite($fp2,'<?php'."\n");
|
|
|
|
$ECHANGE=array();
|
|
foreach ($tabTmp as $i=>$formule) {
|
|
|
|
$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('/\$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);
|
|
|
|
debugLog('W', 'Indiscore '.$strFormule.') $C['.$idPre.']='.$C[$idPre], __LINE__, __FILE__, __FUNCTION__, __CLASS__);
|
|
|
|
fwrite($fp2, $remarque."\n");
|
|
fwrite($fp2, $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']);
|
|
/*P[xxx,+n] valeur Projection linéaire du ratio xxx sur n années Valeur du ratio au terme de l'année N +n années
|
|
Pc[xxx,+n] ou Pc[xxx] Valeur du coefficient de corrélation de la régression linéaire Coef de 0 à 1 à transformer en % Pertinence de la corélation pour qu'elle soit bonne le coef doit > 0,75
|
|
Pevol[xxx,n] Valeur du taux de progression au terme des N années Projection linéaire du ratio xxx sur N années Taux de progression entre la valeur du ratio en année N et sa valeur à +n années (même principe que Revol[xxx] pour les ratios)
|
|
*/
|
|
if (preg_match("/(PROJECTAUX|PROJECCOEF|PROJEC)\((.*)\)/Ui", $ope1, $matches))
|
|
{
|
|
$ope1 = $matches[1].'($'.preg_replace('/R\[0+/', 'regR[', $matches[2]).')';
|
|
}
|
|
elseif (preg_match('/^LONG\(([A-Z0-9\_]{1,30})\)$/i', $ope1, $matches))
|
|
{
|
|
// Gestion du mot clef LONG
|
|
$ope1 = preg_replace('/^LONG\(([A-Z0-9\_]{1,30})\)$/i','strlen(\$$1)', $ope1);
|
|
}
|
|
else
|
|
{
|
|
// Gestion du substr
|
|
$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('"'=>"'")));
|
|
$tabFormulesScore[$id][$ligne]['operande']=$operande;
|
|
$tabFormulesScore[$id][$ligne]['ope1']=$ope1;
|
|
$tabFormulesScore[$id][$ligne]['operation']=$operation;
|
|
$tabFormulesScore[$id][$ligne]['valeur']=$valeur;
|
|
|
|
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,6)!='substr' && substr($valeur,0,1)!="'"
|
|
|| !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);
|
|
//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)) {
|
|
//@sendMail('production@scores-decisions.com', 'ylenaour@scores-decisions.com', "Indiscore sur $siren : Debug", print_r($matches, true)."\n");
|
|
$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:
|
|
debugLog('W', 'Indiscore '.$id.' OPERANDE INCONNUE '.$operande, __LINE__, __FILE__, __FUNCTION__, __CLASS__);
|
|
break;
|
|
}
|
|
$idPre=$id;
|
|
|
|
debugLog('W', 'Indiscore '.$id.' '.$strFormule, __LINE__, __FILE__, __FUNCTION__, __CLASS__);
|
|
}
|
|
|
|
/** Gestion de la dernière ligne de commentaire **/
|
|
$debugFormule.=$strFormule.') ) $C['.$idPre.']=true;'."\t";
|
|
$strFormule=preg_replace('/\|(.{1,12})\|/U', '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);
|
|
|
|
debugLog('W', 'Indiscore '.$strFormule.') $C['.$idPre.']='.$C[$idPre], __LINE__, __FILE__, __FUNCTION__, __CLASS__);
|
|
eval ($strFormule.') $C['.$idPre.']=true;');
|
|
//$fp2=fopen('/var/www/html/ws2/indiscore.tmp.php','a');
|
|
fwrite($fp2, $strFormule.') $C['.$idPre.']=true;'."\n");
|
|
|
|
fwrite($fp2, "\n".'$ECHANGE=\''.serialize($ECHANGE)."';"."\n");
|
|
|
|
fwrite($fp2, "\n".'?>'."\n");
|
|
fclose($fp2);
|
|
$debugFormule.='$C['.$idPre.']='.$C[$idPre]."\r\n";
|
|
//echo '</table>';
|
|
|
|
$strOutput=exec('php -l '.$fileIndiscoreTmp, $output);
|
|
if (preg_match('/^No syntax errors detected in /', $strOutput)) {
|
|
echo "Aucune erreur\n";
|
|
} else {
|
|
echo "Erreur : $strOutput\n";
|
|
print_r($output);
|
|
}
|
|
|
|
}
|
|
|
|
/**
|
|
*
|
|
* @param unknown $type
|
|
* @param unknown $version
|
|
* @return boolean
|
|
*/
|
|
function genereCacheCommentaires($version, $type = 'scores')
|
|
{
|
|
$cycleClient = 2;
|
|
|
|
// Select the right table in database in function of type
|
|
switch ($type) {
|
|
case 'scores':
|
|
$fileTmp = APPLICATION_PATH.'/../library/Metier/scores/Variables/CommentsIndiscore'.$version.'.php';
|
|
$tableComments = 'scores_commentaires_'.$version;
|
|
break;
|
|
|
|
case 'valo':
|
|
$fileTmp = APPLICATION_PATH.'/../library/Metier/scores/Variables/CommentsValo'.$version.'s.php';
|
|
$tableComments = 'valo_commentaires_'.$version;
|
|
break;
|
|
}
|
|
|
|
$iDb = new WDB("jo");
|
|
// Read comments text
|
|
$tabTmp = $iDb->select(
|
|
$tableComments,
|
|
'code, langue, cycle, ligne, commentaire, tri, deleted',
|
|
"deleted=0 AND cycle=$cycleClient AND ligne NOT LIKE '%*%' AND commentaire NOT LIKE '.*%' ORDER BY langue ASC, cycle ASC, code ASC, ligne ASC",
|
|
false, MYSQL_ASSOC
|
|
);
|
|
|
|
$strCommentaires = "\$tabCommentaires=array();\n";
|
|
$strTri = "\$tabTri=array();\n";
|
|
$strTriAff = "\$tabTriAff=array();\n";
|
|
|
|
foreach ($tabTmp as $i => $commentaire) {
|
|
$id = $commentaire['code']*1;
|
|
$cycle = $commentaire['cycle']*1;
|
|
$ligne = $commentaire['ligne']*1;
|
|
|
|
$strCommentaires.= "\$tabCommentaires[".$id."][".$cycle."][".$ligne."] = \"".str_replace('"','\"',$commentaire['commentaire'])."\";\n";
|
|
if ($commentaire['tri']) {
|
|
$strTri.= "\$tabTri[".$id."] = ".$commentaire['tri'].";\n";
|
|
$strTriAff.= "\$tabTriAff[".$id."] = ".(($commentaire['tri'].'.'.(10000000+(1*$commentaire['code'])))*1).";\n";
|
|
}
|
|
}
|
|
$fp=fopen($fileTmp, 'w');
|
|
fwrite($fp, '<?php'."\n");
|
|
fwrite($fp, $strCommentaires);
|
|
fwrite($fp, $strTri);
|
|
fwrite($fp, $strTriAff);
|
|
fwrite($fp, "\n");
|
|
fclose($fp);
|
|
|
|
$strOutput = exec('php -l '.$fileTmp, $output);
|
|
if (preg_match('/^No syntax errors detected in /', $strOutput)) {
|
|
//move($configFileTmp, $configFile);
|
|
} else {
|
|
print_r($output);
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|