Scoring : Sipmlification class des Ratios
This commit is contained in:
parent
b049cd2671
commit
27548d988a
@ -280,6 +280,24 @@ class MBilans
|
||||
$this->siren = $siren;
|
||||
}
|
||||
|
||||
/**
|
||||
* Défini la date du dernier exercice
|
||||
* @param string $accesPartenaire
|
||||
*/
|
||||
public function listeBilansDepose($accesPartenaire = false)
|
||||
{
|
||||
$result = $this->iDb->select('bodacc_detail', 'Bodacc_Date_Parution, dateEffet, typeEven',
|
||||
"siren='$this->siren' AND Rubrique='comptes' ORDER BY dateEffet DESC",false, MYSQL_ASSOC);
|
||||
$dateDerDepot = 0;
|
||||
if ( count($result) > 0 ) {
|
||||
$dateDerDepot=$classWDate->dateT('Y-m-d','Ymd',$result[0]['dateEffet'])*1;
|
||||
if ($dateDerDepot<>0) {
|
||||
$this->dernierExerciceDepose = $classWDate->dateT('Y-m-d','d/m/Y',$result[0]['dateEffet']);
|
||||
$this->dernierExerciceDeposeLe = $classWDate->dateT('Y-m-d','d/m/Y',$result[0]['Bodacc_Date_Parution']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Liste les bilans disponibles au format numérique (et non PDF image) pour une entreprise
|
||||
* @param boolean $accesPartenaire
|
||||
@ -288,58 +306,37 @@ class MBilans
|
||||
* Nombre de bilans maximums retournés
|
||||
* @return array
|
||||
*/
|
||||
public function listeBilans($accesPartenaire=false, $nbMaxBilans=0)
|
||||
public function listeBilans($accesPartenaire = false, $nbMaxBilans = 0)
|
||||
{
|
||||
$classWDate = new WDate();
|
||||
$dateDerDepot = 0;
|
||||
$tabRet = $tabRet3 = array();
|
||||
$tabRet = $tabRet2 = $tabRet3 = array();
|
||||
|
||||
if ($nbMaxBilans>0) $limit="LIMIT 0, $nbMaxBilans";
|
||||
else $limit='';
|
||||
|
||||
$ret = $this->iDb->select(
|
||||
'bilans',
|
||||
'typeBilan, dateProvPartenaire, dateExercice, dateExercicePre, dureeExercice, dureeExercicePre, monnaieOrigine, dateInsert, partenaire',
|
||||
"siren='$this->siren' ORDER BY dateExercice DESC $limit",false, MYSQL_ASSOC);
|
||||
if ( count($ret)>0 ) {
|
||||
$dateDerExercice=$ret[0]['dateExercice']*1;
|
||||
}
|
||||
|
||||
//@sendMail('production@scores-decisions.com', 'ylenaour@scores-decisions.com', "listeBilans sur $this->siren en base", print_r($ret, true));
|
||||
|
||||
$ret2 = $this->iDb->select(
|
||||
'bodacc_detail',
|
||||
'Bodacc_Date_Parution, dateEffet, typeEven',
|
||||
"siren='$this->siren' AND Rubrique='comptes' ORDER BY dateEffet DESC",false, MYSQL_ASSOC);
|
||||
if ( count($ret2)>0 ) {
|
||||
$dateDerDepot=$classWDate->dateT('Y-m-d','Ymd',$ret2[0]['dateEffet'])*1;
|
||||
if ($dateDerDepot<>0) {
|
||||
$this->dernierExerciceDepose = $classWDate->dateT('Y-m-d','d/m/Y',$ret2[0]['dateEffet']);
|
||||
$this->dernierExerciceDeposeLe = $classWDate->dateT('Y-m-d','d/m/Y',$ret2[0]['Bodacc_Date_Parution']);
|
||||
}
|
||||
}
|
||||
$ret = $this->iDb->select('bilans',
|
||||
'typeBilan, dateProvPartenaire, dateExercice, dateExercicePre, dureeExercice, dureeExercicePre, monnaieOrigine, dateInsert, partenaire',
|
||||
"siren='$this->siren' ORDER BY dateExercice DESC, CASE typeBilan WHEN 'N' THEN 1 WHEN 'S' THEN 2 ELSE 3 END $limit",false, MYSQL_ASSOC);
|
||||
|
||||
if ($accesPartenaire) {
|
||||
$iGreffe = new MGreffes($this->iDb);
|
||||
$tabRet=$tabRet2=$iGreffe->getListeBilans($this->siren);
|
||||
} else {
|
||||
$tabRet=$tabRet2=array();
|
||||
$tabRet = $tabRet2 = $iGreffe->getListeBilans($this->siren);
|
||||
}
|
||||
|
||||
$tabTri=array();
|
||||
$tabTri = array();
|
||||
|
||||
if ( count($tabRet)>0 ) {
|
||||
foreach ($tabRet as $millesime=>$bil) {
|
||||
foreach ($tabRet as $millesime => $bil) {
|
||||
$typeBilan = substr($millesime,0,1);
|
||||
$dateExercice = $classWDate->dateT('d/m/Y','Ymd',substr($millesime,1,10));
|
||||
$tabTri[''.$dateExercice.'-'.$typeBilan]=$millesime;
|
||||
$dateExercice = $classWDate->dateT('d/m/Y','Ymd', substr($millesime,1,10));
|
||||
$tabTri[''.$dateExercice.'-'.$typeBilan] = $millesime;
|
||||
}
|
||||
}
|
||||
|
||||
//@sendMail('production@scores-decisions.com', 'ylenaour@scores-decisions.com', "listeBilans sur $this->siren après accès partenaire", print_r($tabRet2, true));
|
||||
if ( count($ret)>0 ) {
|
||||
foreach ($ret as $i=>$bil) {
|
||||
$millesime=$classWDate->dateT('Ymd','d/m/Y',$bil['dateExercice']);
|
||||
if ( count($ret) > 0 ) {
|
||||
foreach ($ret as $i => $bil) {
|
||||
$millesime = $classWDate->dateT('Ymd','d/m/Y',$bil['dateExercice']);
|
||||
$tabRet[''.$bil['typeBilan'].$millesime] = array(
|
||||
'dateProvPartenaire' => $bil['dateProvPartenaire'],
|
||||
'dateInsert' => strtr($bil['dateInsert'], array(' '=>'',':'=>'','-'=>'')),
|
||||
@ -352,44 +349,37 @@ class MBilans
|
||||
'monnaie' => $bil['monnaieOrigine'],
|
||||
'source' => $bil['partenaire'],
|
||||
);
|
||||
$tabTri[''.$bil['dateExercice'].'-'.$bil['typeBilan']]=$bil['typeBilan'].$millesime;
|
||||
$tabTri[''.$bil['dateExercice'].'-'.$bil['typeBilan']] = $bil['typeBilan'].$millesime;
|
||||
}
|
||||
krsort($tabTri);
|
||||
|
||||
//@sendMail('production@scores-decisions.com', 'ylenaour@scores-decisions.com', "listeBilans sur $this->siren avant le tri", print_r($tabTri, true));
|
||||
|
||||
$exercicePre=$typePre=$tmpPre=false;
|
||||
$exercicePre = $typePre = $tmpPre = false;
|
||||
$refPre='';
|
||||
$strInfos='';
|
||||
foreach ($tabTri as $tmp=>$typeMillesime) {
|
||||
$exercice=substr($tmp,0,8);
|
||||
$type=substr($tmp,9,1);
|
||||
$ref=$tabRet[''.$typeMillesime]['ref'];
|
||||
foreach ($tabTri as $tmp => $typeMillesime) {
|
||||
$exercice = substr($tmp,0,8);
|
||||
$type = substr($tmp,9,1);
|
||||
$ref = $tabRet[''.$typeMillesime]['ref'];
|
||||
if ($exercice==$exercicePre && $type=='N' && $typePre=='S' && $refPre=='') {
|
||||
// Suppression du bilan RN de la liste si Réel Normal et Réel Simplifiés présents en base
|
||||
unset($tabTri[$tmp]);
|
||||
$strInfos.="Suppression de '$tmp'".EOL;
|
||||
}
|
||||
elseif ($exercice==$exercicePre && $type=='N' && $typePre=='S' && $refPre<>'') {
|
||||
// Suppression du bilan RS de la liste si Réel Normal Présent en base et réel simplifié non encore en base
|
||||
if ($tmpPre<>false) {
|
||||
unset($tabTri[$tmpPre]);
|
||||
$strInfos.="Suppression de '$tmpPre'".EOL;
|
||||
}
|
||||
}
|
||||
$exercicePre=$exercice;
|
||||
$typePre=$type;
|
||||
$refPre=@trim($ref);
|
||||
$tmpPre=$tmp;
|
||||
$typePre = $type;
|
||||
$refPre = @trim($ref);
|
||||
$tmpPre = $tmp;
|
||||
}
|
||||
krsort($tabTri);
|
||||
|
||||
//@sendMail('production@scores-decisions.com', 'ylenaour@scores-decisions.com', "listeBilans sur $this->siren après le tri", print_r($tabTri, true).EOL.$strInfos.EOL);
|
||||
$tabRet3=array();
|
||||
foreach ($tabTri as $tmp=>$typeMillesime)
|
||||
$tabRet3[''.$typeMillesime]=$tabRet[''.$typeMillesime];
|
||||
|
||||
//@sendMail('production@scores-decisions.com', 'ylenaour@scores-decisions.com', "listeBilans sur $this->siren après le tri / retour", print_r($tabRet3, true));
|
||||
foreach ($tabTri as $tmp => $typeMillesime) {
|
||||
$tabRet3[''.$typeMillesime] = $tabRet[''.$typeMillesime];
|
||||
}
|
||||
}
|
||||
|
||||
return $tabRet3;
|
||||
@ -417,74 +407,74 @@ class MBilans
|
||||
|
||||
$classWDate = new WDate();
|
||||
$millesimeDB = $classWDate->dateT('d/m/Y', 'Ymd', $millesime);
|
||||
if ($accesPartenaire)
|
||||
{
|
||||
if ($accesPartenaire) {
|
||||
// On ne veut pas de bilans "Téléchargés" directement sur Internet
|
||||
$strSansBilansWeb=' AND partenaire<>7 ';
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$strSansBilansWeb='';
|
||||
}
|
||||
|
||||
$bilan = null;
|
||||
|
||||
$iGreffe = new MGreffes($this->iDb);
|
||||
$ret = $this->iDb->select('bilans',
|
||||
'dateProvPartenaire, dateExercice, dateExercicePre, dureeExercice, dureeExercicePre, monnaie, typeBilan, monnaieOrigine, unite, postes, partenaire, id, confidentiel, dateInsert',
|
||||
"siren='$this->siren' AND typeBilan='$typeBilan' AND dateExercice='$millesimeDB' $strSansBilansWeb", false, MYSQL_ASSOC);
|
||||
if (count($ret)==0 && $accesPartenaire)
|
||||
{
|
||||
if ($refPart=='' || $refPart==0)
|
||||
{
|
||||
$tabTmp = $iGreffe->getListeBilans($this->siren);
|
||||
foreach ($tabTmp as $idx=>$bil)
|
||||
{
|
||||
$typeBil=substr($idx,0,1);
|
||||
$millBil=substr($idx,1,10);
|
||||
if ($typeBil==$typeBilan && $millBil==$millesime)
|
||||
|
||||
if ( $accesPartenaire ) {
|
||||
$iGreffe = new MGreffes($this->iDb);
|
||||
if ( count($ret) == 0 ) {
|
||||
if ($refPart=='' || $refPart==0) {
|
||||
$tabTmp = $iGreffe->getListeBilans($this->siren);
|
||||
foreach ($tabTmp as $idx=>$bil)
|
||||
{
|
||||
$refPart=$bil['ref'];
|
||||
break;
|
||||
$typeBil=substr($idx,0,1);
|
||||
$millBil=substr($idx,1,10);
|
||||
if ($typeBil==$typeBilan && $millBil==$millesime)
|
||||
{
|
||||
$refPart=$bil['ref'];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
$tabBilan = $iGreffe->getBilan($this->siren, $refPart);
|
||||
|
||||
if ($tabBilan)
|
||||
{
|
||||
$strPostes='';
|
||||
foreach ($tabBilan['POSTES'] as $poste=>$valeur) {
|
||||
$strPostes.="$poste=$valeur;";
|
||||
}
|
||||
|
||||
$tabInsert=array(
|
||||
'siren' => $this->siren,
|
||||
'dateProvPartenaire'=> $tabBilan['DATE_FRAICHE_BILAN'],
|
||||
'dateExercice' => $classWDate->dateT('d/m/Y','Ymd',$tabBilan['DATE_CLOTURE']),
|
||||
'dateExercicePre' => $classWDate->dateT('d/m/Y','Ymd',$tabBilan['DATE_CLOTURE_PRE']),
|
||||
'dureeExercice' => $tabBilan['DUREE_MOIS'],
|
||||
'dureeExercicePre' => $tabBilan['DUREE_MOIS_PRE'],
|
||||
'monnaie' => $tabBilan['MONNAIE'],
|
||||
'typeBilan' => $tabBilan['TYPE_BILAN'],
|
||||
'monnaieOrigine' => $tabBilan['MONNAIE_ORI'],
|
||||
'unite' => $tabBilan['MONNAIE_LIV_UNITE'],
|
||||
'postes' => $strPostes,
|
||||
'partenaire' => $tabBilan['SOURCE'],
|
||||
);
|
||||
if (!$this->iDb->insert('bilans', $tabInsert, true)) {
|
||||
$this->iDb->update('bilans', $tabInsert, "siren='$this->siren' AND typeBilan='$typeBilan' AND dateExercice='$millesimeDB'");
|
||||
}
|
||||
|
||||
$ret = $this->iDb->select('bilans', 'dateProvPartenaire, dateExercice, dateExercicePre, dureeExercice, dureeExercicePre, monnaie, typeBilan, monnaieOrigine, unite, postes, partenaire, id, confidentiel, dateInsert', "siren='$this->siren' AND typeBilan='$typeBilan' AND dateExercice='$millesimeDB'", true);
|
||||
if (count($ret) > 0) {
|
||||
$bilan = $ret[0];
|
||||
}
|
||||
}
|
||||
}
|
||||
$tabBilan = $iGreffe->getBilan($this->siren, $refPart);
|
||||
|
||||
if ($tabBilan)
|
||||
{
|
||||
$strPostes='';
|
||||
foreach ($tabBilan['POSTES'] as $poste=>$valeur) {
|
||||
$strPostes.="$poste=$valeur;";
|
||||
}
|
||||
|
||||
$tabInsert=array(
|
||||
'siren' => $this->siren,
|
||||
'dateProvPartenaire'=> $tabBilan['DATE_FRAICHE_BILAN'],
|
||||
'dateExercice' => $classWDate->dateT('d/m/Y','Ymd',$tabBilan['DATE_CLOTURE']),
|
||||
'dateExercicePre' => $classWDate->dateT('d/m/Y','Ymd',$tabBilan['DATE_CLOTURE_PRE']),
|
||||
'dureeExercice' => $tabBilan['DUREE_MOIS'],
|
||||
'dureeExercicePre' => $tabBilan['DUREE_MOIS_PRE'],
|
||||
'monnaie' => $tabBilan['MONNAIE'],
|
||||
'typeBilan' => $tabBilan['TYPE_BILAN'],
|
||||
'monnaieOrigine' => $tabBilan['MONNAIE_ORI'],
|
||||
'unite' => $tabBilan['MONNAIE_LIV_UNITE'],
|
||||
'postes' => $strPostes,
|
||||
'partenaire' => $tabBilan['SOURCE'],
|
||||
);
|
||||
if (!$this->iDb->insert('bilans', $tabInsert, true)) {
|
||||
$this->iDb->update('bilans', $tabInsert, "siren='$this->siren' AND typeBilan='$typeBilan' AND dateExercice='$millesimeDB'");
|
||||
}
|
||||
|
||||
$ret = $this->iDb->select('bilans', 'dateProvPartenaire, dateExercice, dateExercicePre, dureeExercice, dureeExercicePre, monnaie, typeBilan, monnaieOrigine, unite, postes, partenaire, id, confidentiel, dateInsert', "siren='$this->siren' AND typeBilan='$typeBilan' AND dateExercice='$millesimeDB'", true);
|
||||
if (count($ret) > 0) {
|
||||
$bilan = $ret[0];
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$bilan = $ret[0];
|
||||
}
|
||||
|
||||
|
||||
if (count($ret) > 0) {
|
||||
$bilan = $ret[0];
|
||||
}
|
||||
|
||||
$tabBilan = $tabBilanPre = $bilanPre = array();
|
||||
|
||||
if ($bilan !== null)
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -7,7 +7,7 @@ require_once 'Metier/partenaires/classMLiens2.php';
|
||||
require_once 'Metier/scores/classMSolvabilite.php';
|
||||
require_once 'Metier/scores/classMRatios.php';
|
||||
|
||||
define('INDISCORE_DEBUG', false);
|
||||
define('INDISCORE_DEBUG', true);
|
||||
|
||||
/**
|
||||
* Return the history of previous stored IndiScores on the companies
|
||||
@ -484,7 +484,7 @@ function format($matches)
|
||||
global $Rs, $Rsp, $Rsp2, $Rsp3, $Rsp4;
|
||||
global $Revol, $Revolp, $Revolp2, $Revolp3;
|
||||
global $Ra, $Rap, $Rdiff;
|
||||
global $regR, $regRs, $Y, $Yaff, $PROJEC, $PROJECTAUX, $PROJECCOEFF;
|
||||
global $regR, $regRs, $Y, $Yaff, $PROJEC, $PROJECTAUX, $PROJECCOEF;
|
||||
global $tabFormulesRatios, $tabRegX;
|
||||
|
||||
$strRetour='$'.$matches[1];
|
||||
@ -503,30 +503,7 @@ function format($matches)
|
||||
}
|
||||
return formatRatio('', $valeur/$tmpAnnees, strtoupper($tabFormulesRatios[$tmpRatioId]['unite']));
|
||||
} elseif (preg_match('/\{GRAPH\((.*)\)\}/Ui', $strRetour, $matches2)) {
|
||||
//sendMail('production@scores-decisions.com', 'ylenaour@scores-decisions.com', "Indiscore sur $siren : Trace Graph", $strRetour);
|
||||
return $matches[1];
|
||||
} elseif (preg_match("/PROJEC\((R.*),(.*)\)/Ui", $strRetour, $matches2)) {
|
||||
if (preg_match('/Rs/', $matches2[2])) {
|
||||
$valeur = $regRs[6];
|
||||
} else {
|
||||
$valeur = $regR[6];
|
||||
}
|
||||
switch(strtoupper($matches2[1]))
|
||||
{
|
||||
//case 'PROJECCOEF': return formatRatio('', PROJECCOEF($valeur, $matches2[2]), strtoupper($tabFormulesRatios[6]['unite'])); break;
|
||||
case 'PROJEC':
|
||||
require_once 'Metier/Scores/classMProjection.php';
|
||||
$projec = new Projection();
|
||||
$projec->tabRegX = $tabRegX;
|
||||
$result = $projec->calc($valeur, $matches2[2]);
|
||||
$Y = $projec->getY();
|
||||
$Yaff = $projec->getYaff();
|
||||
$PROJECTAUX = $projec->getProjecTaux();
|
||||
$PROECCOEFF = $projec->getProjecCoeff();
|
||||
return formatRatio('', $result, strtoupper($tabFormulesRatios[6]['unite']));
|
||||
break;
|
||||
//case 'PROJECTAUX': return formatRatio('', PROJECTAUX($valeur, $matches2[2]), strtoupper($tabFormulesRatios[6]['unite'])); break;
|
||||
}
|
||||
} elseif (preg_match('/\$\{(\+|!|)(Rp4|Rp3|Rp2|Rp|Rs|Rsp|Rap|Ra|Rdiff|Revolp2|Revolp|Revol|R|regR)\[(\d+)\]\}/Ui', $strRetour, $matches2)) {
|
||||
$tmpRatio=$matches2[2];
|
||||
$tmpRatioId=$matches2[3]*1;
|
||||
@ -581,18 +558,23 @@ function format($matches)
|
||||
return $strRetour.' '.$strUnite;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param unknown $valeur
|
||||
* @param unknown $nbAnnees
|
||||
*/
|
||||
function PROJEC($valeur, $nbAnnees)
|
||||
{
|
||||
global $tabRegX, $Y, $Yaff, $PROECCOEFF, $PROJECTAUX;
|
||||
global $tabRegX, $Y, $Yaff, $PROJECCOEF, $PROJECTAUX;
|
||||
require_once 'Metier/scores/classMProjection.php';
|
||||
$projec = new Projection();
|
||||
$projec->tabRegX = $tabRegX;
|
||||
$result = $projec->calc($valeur, $nbAnnees);
|
||||
if ( $result !== false ) {
|
||||
$Y = $projec->getY();
|
||||
$Y = $projec->getY(); //@todo : ?????
|
||||
$Yaff = $projec->getYaff();
|
||||
$PROJECTAUX = $projec->getProjecTaux();
|
||||
$PROECCOEFF = $projec->getProjecCoeff();
|
||||
$PROJECCOEF = $projec->getProjecCoeff();
|
||||
}
|
||||
}
|
||||
|
||||
@ -959,82 +941,99 @@ function calculIndiScore($siren, $nic=0, $accesDist=false, $cycleClient=2, $mail
|
||||
$DCREN_AA=substr($dateCrea,0,4);
|
||||
$AGE=$classWdate->nbMoisEntre($dateCrea, date('Ymd'));
|
||||
|
||||
$tabBilan = $tabBil = array();
|
||||
/**
|
||||
* Bilan - Liste des bilans
|
||||
*/
|
||||
// --- Liste des bilans
|
||||
$tabBilan = $tabBil = $tabRegX = array();
|
||||
$mBil = new MBilans($siren, $iDb);
|
||||
$tabBilans = $mBil->listeBilans($accesDist);
|
||||
$NBBILAN = count($tabBilans);
|
||||
if ($NBBILAN > 0)
|
||||
{
|
||||
/**
|
||||
* Postes des bilans
|
||||
*/
|
||||
foreach ($tabBilans as $millesime => $item)
|
||||
{
|
||||
if(in_array($item['typeBilan'], array('S', 'N')))
|
||||
{
|
||||
if ($NBBILAN > 0) {
|
||||
|
||||
$BILAN = $BILANp = $BILANp2 = $BILANp3 = $BILANp4 = 0;
|
||||
|
||||
// --- Postes des bilans
|
||||
$i = 0;
|
||||
foreach ($tabBilans as $millesime => $item) {
|
||||
if ($i > 4) {
|
||||
break;
|
||||
}
|
||||
if ( $item['typeBilan'] == 'N' ) {
|
||||
$tabBilan[] = $mBil->getBilan(substr($millesime,-10), substr($millesime,0,1), '');
|
||||
$i++;
|
||||
} elseif ( $item['typeBilan'] == 'S' ) {
|
||||
$tabN = $mBil->getBilan(substr($millesime,-10), substr($millesime,0,1), '');
|
||||
$tabS = $mBil->bilanSimplifie2Normal($tabN);
|
||||
$tabBilan[] = array_merge($tabN, $tabS);
|
||||
$i++;
|
||||
}
|
||||
|
||||
$tabRegX[] = $item['millesime'];
|
||||
|
||||
}
|
||||
|
||||
// Elements provenant des bilans
|
||||
$EFFBILAN=$tabBilan[0]['YP'];
|
||||
$nm=$nbMoisBilCumul=$tabBilan[0]['DUREE_MOIS'];
|
||||
$nmp=$tabBilan[0]['DUREE_MOIS_PRE'];
|
||||
|
||||
$BILANDATE=$tabBilan[0]['DATE_CLOTURE'];
|
||||
$BILANDATEp=$tabBilan[0]['DATE_CLOTURE_PRE'];
|
||||
if ($BILANDATEp==0) $BILANDATEp=$tabBilan[1]['DATE_CLOTURE'];
|
||||
|
||||
$BILAN=$BILANp=$BILANp2=$BILANp3=$BILANp4=0;
|
||||
$BILANANNEE=substr($BILANDATE,0,4)*1;
|
||||
$BILANANNEEp=substr($BILANDATEp,0,4)*1;
|
||||
if ($BILANANNEEp>0) {
|
||||
$BILANp=1;
|
||||
$nbMoisBilDate=$classWdate->nbMoisEntre($BILANDATEp, $BILANDATE);
|
||||
$nbMoisBilCumul+=$nmp;
|
||||
// --- Bilan le plus récent disponible
|
||||
if (isset($tabBilan[0])) {
|
||||
$EFFBILAN = $tabBilan[0]['YP'];
|
||||
$nm = $nbMoisBilCumul = $tabBilan[0]['DUREE_MOIS'];
|
||||
$BILANDATE = $tabBilan[0]['DATE_CLOTURE'];
|
||||
$BILANDATEp = $tabBilan[0]['DATE_CLOTURE_PRE'];
|
||||
if ($BILANDATEp == 0 && isset($tabBilan[1])) {
|
||||
$BILANDATEp = $tabBilan[1]['DATE_CLOTURE'];
|
||||
$BILANANNEEp = substr($BILANDATEp,0,4)*1;
|
||||
}
|
||||
$BILANANNEE = substr($BILANDATE,0,4)*1;
|
||||
$nmp = $tabBilan[0]['DUREE_MOIS_PRE'];
|
||||
if ($BILANANNEEp > 0) {
|
||||
$BILANp = 1;
|
||||
$nbMoisBilDate = $classWdate->nbMoisEntre($BILANDATEp, $BILANDATE);
|
||||
$nbMoisBilCumul += $nmp;
|
||||
}
|
||||
}
|
||||
|
||||
$BILANDATEp2 = $tabBilan[2]['DATE_CLOTURE'];
|
||||
$BILANANNEEp2 = substr($BILANDATEp2,0,4)*1;
|
||||
$nmp2=$tabBilan[2]['DUREE_MOIS'];
|
||||
if ($BILANANNEEp2>0) {
|
||||
$BILANp2=1;
|
||||
$nbMoisBilDate=$classWdate->nbMoisEntre($BILANDATEp2, $BILANDATE);
|
||||
$nbMoisBilCumul+=$nmp2;
|
||||
// --- Elements des 5 bilans les plus récent
|
||||
if (isset($tabBilan[2])) {
|
||||
$BILANDATEp2 = $tabBilan[2]['DATE_CLOTURE'];
|
||||
$BILANANNEEp2 = substr($BILANDATEp2,0,4)*1;
|
||||
$nmp2=$tabBilan[2]['DUREE_MOIS'];
|
||||
if ($BILANANNEEp2 > 0) {
|
||||
$BILANp2 = 1;
|
||||
$nbMoisBilDate = $classWdate->nbMoisEntre($BILANDATEp2, $BILANDATE);
|
||||
$nbMoisBilCumul += $nmp2;
|
||||
}
|
||||
}
|
||||
|
||||
$BILANDATEp3 = $tabBilan[3]['DATE_CLOTURE'];
|
||||
$BILANANNEEp3=substr($BILANDATEp3,0,4)*1;
|
||||
$nmp3=$tabBilan[3]['DUREE_MOIS'];
|
||||
if ($BILANANNEEp3>0) {
|
||||
$BILANp3=1;
|
||||
$nbMoisBilDate=$classWdate->nbMoisEntre($BILANDATEp3, $BILANDATE);
|
||||
$nbMoisBilCumul+=$nmp3;
|
||||
if (isset($tabBilan[3])) {
|
||||
$BILANDATEp3 = $tabBilan[3]['DATE_CLOTURE'];
|
||||
$BILANANNEEp3 = substr($BILANDATEp3,0,4)*1;
|
||||
$nmp3 = $tabBilan[3]['DUREE_MOIS'];
|
||||
if ($BILANANNEEp3 > 0) {
|
||||
$BILANp3 = 1;
|
||||
$nbMoisBilDate = $classWdate->nbMoisEntre($BILANDATEp3, $BILANDATE);
|
||||
$nbMoisBilCumul += $nmp3;
|
||||
}
|
||||
}
|
||||
|
||||
$BILANDATEp4 =$tabBilan[4]['DATE_CLOTURE'];
|
||||
$BILANANNEEp4=substr($BILANDATEp4,0,4)*1;
|
||||
$nmp4=$tabBilan[4]['DUREE_MOIS'];
|
||||
if ($BILANANNEEp4>0) {
|
||||
$BILANp4=1;
|
||||
$nbMoisBilDate=$classWdate->nbMoisEntre($BILANDATEp4, $BILANDATE);
|
||||
//$nbMoisBilCumul+=$nmp4;
|
||||
if (isset($tabBilan[4])) {
|
||||
$BILANDATEp4 = $tabBilan[4]['DATE_CLOTURE'];
|
||||
$BILANANNEEp4 = substr($BILANDATEp4,0,4)*1;
|
||||
$nmp4=$tabBilan[4]['DUREE_MOIS'];
|
||||
if ($BILANANNEEp4 > 0) {
|
||||
$BILANp4 = 1;
|
||||
$nbMoisBilDate = $classWdate->nbMoisEntre($BILANDATEp4, $BILANDATE);
|
||||
//$nbMoisBilCumul+=$nmp4;
|
||||
}
|
||||
}
|
||||
|
||||
// Liste des années de bilans ultérieurs
|
||||
$BILANANNEE1=$BILANANNEE+1;
|
||||
$BILANANNEE2=$BILANANNEE+2;
|
||||
$BILANANNEE3=$BILANANNEE+3;
|
||||
$BILANANNEE4=$BILANANNEE+4;
|
||||
$BILANANNEE5=$BILANANNEE+5;
|
||||
$BILANANNEE1 = $BILANANNEE + 1;
|
||||
$BILANANNEE2 = $BILANANNEE + 2;
|
||||
$BILANANNEE3 = $BILANANNEE + 3;
|
||||
$BILANANNEE4 = $BILANANNEE + 4;
|
||||
$BILANANNEE5 = $BILANANNEE + 5;
|
||||
|
||||
/**
|
||||
* Calcul des ratios
|
||||
*/
|
||||
$tabRatios = calculRatios($tabBilans, $tabIdentite, $accesDist);
|
||||
// --- Calcul des ratios
|
||||
$mRatios = new MRatios();
|
||||
$mRatios->setTrancheEffectif($efftr);
|
||||
$tabRatios = $mRatios->calcul($tabBilan);
|
||||
}
|
||||
$timer['ratios']=microtime(true);
|
||||
|
||||
@ -1042,63 +1041,89 @@ function calculIndiScore($siren, $nic=0, $accesDist=false, $cycleClient=2, $mail
|
||||
$tabAnnees = array();
|
||||
// Tableau d'infos sur les bilans
|
||||
$i2=0;
|
||||
if (count($tabRatios)>0)
|
||||
{
|
||||
foreach ($tabRatios as $i=>$Rtmp)
|
||||
{
|
||||
if (substr($tabBilan[$i]['DATE_CLOTURE'],0,4)>1900){
|
||||
$tabAnnees[$i]=substr($tabBilan[$i]['DATE_CLOTURE'],0,4);
|
||||
if (count($tabRatios)>0) {
|
||||
foreach ($tabRatios as $i => $Ritem) {
|
||||
|
||||
if (substr($tabBilan[$i]['DATE_CLOTURE'],0,4) > 1900){
|
||||
$tabAnnees[$i] = substr($tabBilan[$i]['DATE_CLOTURE'], 0, 4);
|
||||
}
|
||||
|
||||
// Utilisation d'un index texte à cause du webservice
|
||||
foreach ($Rtmp as $Ridx => $Rmont) {
|
||||
if ( ($tabBilan[$i]['CONSOLIDE']=='S' && isset($tabRatios[$i+1]) && ($tabBilan[$i+1]['CONSOLIDE']=='S' || ($tabBilan[$i+1]['CONSOLIDE']=='N' && $tabBilan[$i+1]['DATE_CLOTURE']<>$tabBilan[$i]['DATE_CLOTURE'])))
|
||||
|| ($tabBilan[$i]['CONSOLIDE']=='N' && isset($tabRatios[$i+1]) && ($tabBilan[$i+1]['CONSOLIDE']=='N'||($tabBilan[$i+1]['CONSOLIDE']=='S' && $tabBilan[$i+1]['DATE_CLOTURE']<>$tabBilan[$i]['DATE_CLOTURE']))) ) {
|
||||
foreach ($Ritem as $Ridx => $Rmont) {
|
||||
if ( ($tabBilan[$i]['CONSOLIDE']=='S' && isset($tabRatios[$i+1]) && ($tabBilan[$i+1]['CONSOLIDE']=='S'
|
||||
|| ($tabBilan[$i+1]['CONSOLIDE']=='N' && $tabBilan[$i+1]['DATE_CLOTURE']!=$tabBilan[$i]['DATE_CLOTURE'])))
|
||||
|| ($tabBilan[$i]['CONSOLIDE']=='N' && isset($tabRatios[$i+1]) && ($tabBilan[$i+1]['CONSOLIDE']=='N'
|
||||
|| ($tabBilan[$i+1]['CONSOLIDE']=='S' && $tabBilan[$i+1]['DATE_CLOTURE']!=$tabBilan[$i]['DATE_CLOTURE']))) ) {
|
||||
|
||||
$Rmont=(($tabRatios[$i][$Ridx]-$tabRatios[$i+1][$Ridx])*100)/abs($tabRatios[$i+1][$Ridx]);
|
||||
$Rdiffmont=$tabRatios[$i][$Ridx]-$tabRatios[$i+1][$Ridx];
|
||||
$Rmont = (($tabRatios[$i][$Ridx]-$tabRatios[$i+1][$Ridx])*100)/abs($tabRatios[$i+1][$Ridx]);
|
||||
$Rdiffmont = $tabRatios[$i][$Ridx]-$tabRatios[$i+1][$Ridx];
|
||||
|
||||
} elseif ( ($tabBilan[$i]['CONSOLIDE']=='S'&&isset($tabRatios[$i+1])&&($tabBilan[$i+2]['CONSOLIDE']=='S'||($tabBilan[$i+2]['CONSOLIDE']=='N'&&$tabBilan[$i+2]['DATE_CLOTURE']<>$tabBilan[$i]['DATE_CLOTURE'])))
|
||||
|| ($tabBilan[$i]['CONSOLIDE']=='N'&&isset($tabRatios[$i+1])&&($tabBilan[$i+2]['CONSOLIDE']=='N'||($tabBilan[$i+2]['CONSOLIDE']=='S'&&$tabBilan[$i+2]['DATE_CLOTURE']<>$tabBilan[$i]['DATE_CLOTURE']))) ) {
|
||||
$Rmont=(($tabRatios[$i][$Ridx]-$tabRatios[$i+2][$Ridx])*100)/abs($tabRatios[$i+2][$Ridx]);
|
||||
$Rdiffmont=$tabRatios[$i][$Ridx]-$tabRatios[$i+1][$Ridx];
|
||||
} elseif ( ($tabBilan[$i]['CONSOLIDE']=='S'&&isset($tabRatios[$i+1])&&($tabBilan[$i+2]['CONSOLIDE']=='S'
|
||||
|| ($tabBilan[$i+2]['CONSOLIDE']=='N'&&$tabBilan[$i+2]['DATE_CLOTURE']!=$tabBilan[$i]['DATE_CLOTURE'])))
|
||||
|| ($tabBilan[$i]['CONSOLIDE']=='N'&&isset($tabRatios[$i+1])&&($tabBilan[$i+2]['CONSOLIDE']=='N'
|
||||
|| ($tabBilan[$i+2]['CONSOLIDE']=='S'&&$tabBilan[$i+2]['DATE_CLOTURE']!=$tabBilan[$i]['DATE_CLOTURE']))) ) {
|
||||
|
||||
$Rmont = (($tabRatios[$i][$Ridx]-$tabRatios[$i+2][$Ridx])*100)/abs($tabRatios[$i+2][$Ridx]);
|
||||
$Rdiffmont = $tabRatios[$i][$Ridx]-$tabRatios[$i+1][$Ridx];
|
||||
|
||||
} else {
|
||||
$Rmont='NS';
|
||||
$Rdiffmont='NS';
|
||||
$Rmont = 'NS';
|
||||
$Rdiffmont = 'NS';
|
||||
}
|
||||
$tabRatiosEvol[$i2][$Ridx]=$Rmont;
|
||||
$tabRatiosDiff[$i2][$Ridx]=$Rdiffmont;
|
||||
$tabRatiosEvol[$i2][$Ridx] = $Rmont;
|
||||
$tabRatiosDiff[$i2][$Ridx] = $Rdiffmont;
|
||||
}
|
||||
$tabRatiosNew[$i2]=$tabRatios[$i];
|
||||
$tabRatiosNew[$i2] = $tabRatios[$i];
|
||||
if ($tabBilan[$i]['CONSOLIDE']!='C') $i2++;
|
||||
}
|
||||
|
||||
$R = $tabRatiosNew[0];
|
||||
$Rp = $tabRatiosNew[1];
|
||||
$Rp2= $tabRatiosNew[2]; // Ratios précédents N-2
|
||||
$Rp3= $tabRatiosNew[3]; // Ratios précédents N-2
|
||||
$Rp4= $tabRatiosNew[4]; // Ratios précédents N-4
|
||||
|
||||
$Rdiff = $tabRatiosDiff[0];
|
||||
|
||||
$Revol = $tabRatiosEvol[0];
|
||||
$Revolp = $tabRatiosEvol[1];
|
||||
$Revolp2 = $tabRatiosEvol[2];
|
||||
$Revolp3 = $tabRatiosEvol[3];
|
||||
|
||||
}
|
||||
$timer['anbilans']=microtime(true);
|
||||
|
||||
$R=$tabRatiosNew[0];
|
||||
$Rp=$tabRatiosNew[1];
|
||||
$Rp2=$tabRatiosNew[2]; // Ratios précédents N-2
|
||||
$Rp3=$tabRatiosNew[3]; // Ratios précédents N-2
|
||||
$Rp4=$tabRatiosNew[4]; // Ratios précédents N-4
|
||||
|
||||
$Rdiff=$tabRatiosDiff[0];
|
||||
|
||||
$Revol=$tabRatiosEvol[0];
|
||||
$Revolp=$tabRatiosEvol[1];
|
||||
$Revolp2=$tabRatiosEvol[2];
|
||||
$Revolp3=$tabRatiosEvol[3];
|
||||
|
||||
// Régression linéaire : tableau des années - @todo : Delete global
|
||||
global $tabRegX; // Tableau des années de millesime de bilans
|
||||
// Régression : Ratios
|
||||
$iMax = count($tabRegX);
|
||||
foreach ($tabFormules as $i2 => $Rtmp) {
|
||||
for ( $i = 0 ; $i <= $iMax ; $i++ ) {
|
||||
if ( isset($tabRatios[$i][$Rtmp['id']]) ) {
|
||||
$regR[$Rtmp['id']][]=$tabRatios[$i][$Rtmp['id']];
|
||||
} else {
|
||||
if ( array_key_exists($i, $tabRegX) ) {
|
||||
//unset($tabRegX[$i]);
|
||||
}
|
||||
}
|
||||
if (isset($tabRatiosSecteurs[$i][$Rtmp['id']])) {
|
||||
$regRs[$Rtmp['id']][]=$tabRatiosSecteurs[$i][$Rtmp['id']];
|
||||
}
|
||||
}
|
||||
if ( is_array($regR) && array_key_exists($Rtmp['id'], $regR) ) {
|
||||
$regR[$Rtmp['id']] = array_reverse($regR[$Rtmp['id']]);
|
||||
}
|
||||
|
||||
if ( is_array($regRs) && array_key_exists($Rtmp['id'], $regRs) ) {
|
||||
$regRs[$Rtmp['id']] = array_reverse($regRs[$Rtmp['id']]);
|
||||
}
|
||||
}
|
||||
// On renverse les tableaux 2008, 2007, 2006... en 2006, 2007, 2008
|
||||
$tabRegX = array_reverse($tabRegX);
|
||||
|
||||
|
||||
global $Y, $Yaff; // Tableau des années en paramètres + $nbAnnees Projetées
|
||||
global $PROJECTAUX; // Taux de projection de n à n+$nbAnnees
|
||||
global $PROJECCOEF;
|
||||
|
||||
$tabRegX = array();
|
||||
foreach ($tabBilans as $k => $tabTmp){
|
||||
$tabRegX[] = $tabTmp['millesime'];
|
||||
}
|
||||
$iMax = count($tabRegX);
|
||||
|
||||
$EFFECTIF=$R[24];
|
||||
if ($EFFECTIF*1==0 && $efftr>0) $EFFECTIF=$efftr;
|
||||
|
||||
@ -1124,7 +1149,7 @@ function calculIndiScore($siren, $nic=0, $accesDist=false, $cycleClient=2, $mail
|
||||
"1 $strNaf $strAnnees ORDER BY annee DESC, id ASC",
|
||||
INDISCORE_DEBUG, MYSQL_ASSOC);
|
||||
|
||||
$anneePre=$tabTmp[0]['annee'];
|
||||
$anneePre = $tabTmp[0]['annee'];
|
||||
$iAn=0;
|
||||
foreach ($tabTmp as $tabTmp2) {
|
||||
if ($anneePre<>$tabTmp2['annee']){ $iAn++; }
|
||||
@ -1199,31 +1224,7 @@ function calculIndiScore($siren, $nic=0, $accesDist=false, $cycleClient=2, $mail
|
||||
$timer['ratiosecteur']=microtime(true);
|
||||
}
|
||||
|
||||
// Régression : Ratios
|
||||
foreach ($tabFormules as $i2 => $Rtmp)
|
||||
{
|
||||
for ( $i = 0 ; $i <= $iMax ; $i++ ) {
|
||||
if ( isset($tabRatios[$i][$Rtmp['id']]) ) {
|
||||
$regR[$Rtmp['id']][]=$tabRatios[$i][$Rtmp['id']];
|
||||
} else {
|
||||
if ( array_key_exists($i, $tabRegX) ) {
|
||||
//unset($tabRegX[$i]);
|
||||
}
|
||||
}
|
||||
if (isset($tabRatiosSecteurs[$i][$Rtmp['id']])) {
|
||||
$regRs[$Rtmp['id']][]=$tabRatiosSecteurs[$i][$Rtmp['id']];
|
||||
}
|
||||
}
|
||||
if ( is_array($regR) && array_key_exists($Rtmp['id'], $regR) ) {
|
||||
$regR[$Rtmp['id']] = array_reverse($regR[$Rtmp['id']]);
|
||||
}
|
||||
|
||||
if ( is_array($regRs) && array_key_exists($Rtmp['id'], $regRs) ) {
|
||||
$regRs[$Rtmp['id']] = array_reverse($regRs[$Rtmp['id']]);
|
||||
}
|
||||
}
|
||||
// On renverse les tableaux 2008, 2007, 2006... en 2006, 2007, 2008
|
||||
$tabRegX = array_reverse($tabRegX);
|
||||
|
||||
|
||||
$timer['regression']=microtime(true);
|
||||
|
||||
@ -1994,7 +1995,9 @@ function calculIndiScore($siren, $nic=0, $accesDist=false, $cycleClient=2, $mail
|
||||
$tabBilansA = $mBilA->listeBilans(false,2);
|
||||
$nbBilansA = count($tabBilansA);
|
||||
if ($nbBilansA > 0) {
|
||||
$tabRatiosA = calculRatios($tabBilansA, $tabIdentiteA, $accesDist);
|
||||
$mRatiosA = new MRatios();
|
||||
$mRatiosA->setTrancheEffectif($tabIdentiteA['EffEnTr']);
|
||||
$tabRatiosA = $mRatiosA->calcul($tabBilansA);
|
||||
$SITUACT=$tabRatiosA[0][19];
|
||||
$Ra=$tabRatiosA[0];
|
||||
$Rap=$tabRatiosA[1];
|
||||
@ -3340,7 +3343,7 @@ function calculIndiScore($siren, $nic=0, $accesDist=false, $cycleClient=2, $mail
|
||||
*/
|
||||
// Locaux
|
||||
require_once 'Metier/partenaires/classMCadastre.php';
|
||||
$iCadastre=new MCadastre($iDb);
|
||||
$iCadastre = new MCadastre($iDb);
|
||||
$tabTmp=$iCadastre->getLocaux($siren);
|
||||
if(count($tabTmp)>0 ) {
|
||||
foreach ($tabTmp as $iTmp=>$cad) {
|
||||
@ -3351,7 +3354,7 @@ function calculIndiScore($siren, $nic=0, $accesDist=false, $cycleClient=2, $mail
|
||||
}
|
||||
}
|
||||
// Parcelles
|
||||
$tabTmp=$iCadastre->getParcelles($siren);
|
||||
$tabTmp = $iCadastre->getParcelles($siren);
|
||||
foreach ($tabTmp as $iTmp=>$cad) {
|
||||
$CADTER_NB_TOT++;
|
||||
if ($cad['parcelDroit']=='P') $CADTER_NB_PROP++;
|
||||
@ -3511,9 +3514,6 @@ function calculIndiScore($siren, $nic=0, $accesDist=false, $cycleClient=2, $mail
|
||||
|
||||
$strCommentaire=strtr(preg_replace_callback('/(\{.*\})/U', 'format', $commentaires), array('"'=>'\''));
|
||||
|
||||
//echo "<b>$idx</b>";
|
||||
//eval('echo "'.$strCommentaire.'";');
|
||||
//echo '<br/><br/>';
|
||||
// Gestion de la balise <Dxx> signifiant un espacement obligatoire de xx
|
||||
if (preg_match('/\<D(\d+)\>/Ui', $strCommentaire, $matches)){
|
||||
$strCommentaire=str_repeat('_', $matches[1]).preg_match('/\<D(\d+)\>/', '', $strCommentaire);
|
||||
@ -3561,12 +3561,9 @@ function calculIndiScore($siren, $nic=0, $accesDist=false, $cycleClient=2, $mail
|
||||
$tabCommentairesATrier[$idx]=$strCommentaire;
|
||||
$idxPre=$idx;
|
||||
}
|
||||
// sendMail('production@scores-decisions.com', 'ylenaour@scores-decisions.com', "Indiscore sur $siren : Trace1.$numC = $idx", $commentaires);
|
||||
}
|
||||
}
|
||||
|
||||
//sendMail('production@scores-decisions.com', 'ylenaour@scores-decisions.com', "Indiscore sur $siren : Trace10", 'ici');
|
||||
|
||||
//echo '<hr/>';
|
||||
$tabComment=array();
|
||||
$tableau=false;
|
||||
@ -3649,7 +3646,9 @@ function calculIndiScore($siren, $nic=0, $accesDist=false, $cycleClient=2, $mail
|
||||
'CA_Y='.print_r($CA_Y,true).EOL.EOL.
|
||||
'RCAI_COEF='.$RCAI_COEF.EOL.
|
||||
'RCAI_Y='.print_r($RCAI_Y,true).EOL.
|
||||
"PROJECCOEF=$PROJECCOEF".EOL.
|
||||
"PROJECTAUX=$PROJECTAUX".EOL.
|
||||
"Y=".print_r($Y,true).EOL.
|
||||
"Yaff=".print_r($Yaff,true).EOL.
|
||||
"tabRegX=".print_r($tabRegX,true).EOL.
|
||||
print_r($tabComment, true).EOL.
|
||||
|
@ -2734,7 +2734,6 @@ class Entreprise extends Scores_Ws_Server
|
||||
require_once 'Metier/scores/classMRatios.php';
|
||||
$mBil = new MBilans($siren);
|
||||
$tabBilans = $mBil->listeBilans($accesPartenaire);
|
||||
|
||||
$nbBilans = count($tabBilans);
|
||||
$tabBilan = $tabBil = array();
|
||||
if ($nbBilans>0)
|
||||
@ -2746,13 +2745,26 @@ class Entreprise extends Scores_Ws_Server
|
||||
$nafLib = $tabIdentite['NafEntLib'];
|
||||
$efftr = $tabIdentite['Effectif']*1;
|
||||
$fj = $tabIdentite['FJ'];
|
||||
|
||||
foreach ($tabBilans as $millesime => $item)
|
||||
{
|
||||
$tabBilan[] = $mBil->getBilan(substr($millesime,-10), substr($millesime,0,1), '');
|
||||
}
|
||||
$tabRatios = calculRatios($tabBilans, $tabIdentite, $accesPartenaire);
|
||||
}
|
||||
$i = 0;
|
||||
foreach ($tabBilans as $millesime => $item) {
|
||||
if ($i > 4) {
|
||||
break;
|
||||
}
|
||||
if ( $item['typeBilan'] == 'N' ) {
|
||||
$tabBilan[] = $mBil->getBilan(substr($millesime,-10), substr($millesime,0,1), '');
|
||||
$i++;
|
||||
} elseif ( $item['typeBilan'] == 'S' ) {
|
||||
$tabN = $mBil->getBilan(substr($millesime,-10), substr($millesime,0,1), '');
|
||||
$tabS = $mBil->bilanSimplifie2Normal($tabN);
|
||||
$tabBilan[] = array_merge($tabN, $tabS);
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
$mRatios = new MRatios();
|
||||
$mRatios->setTrancheEffectif($efftr);
|
||||
$tabRatios = $mRatios->calcul($tabBilan);
|
||||
}
|
||||
|
||||
$nbRatios = count($tabRatios);
|
||||
debugLog('I',"Liste des Ratios demandée pour $siren après calculRatios ($nbRatios)",__LINE__,__FILE__, __FUNCTION__, __CLASS__);
|
||||
|
||||
@ -4592,26 +4604,39 @@ class Entreprise extends Scores_Ws_Server
|
||||
}
|
||||
|
||||
//Ratios
|
||||
global $tva, $mBil, $efftr, $tabInfla;
|
||||
require_once 'Metier/scores/classMRatios.php';
|
||||
$mBil = new MBilans($siren);
|
||||
$tabBilans = $mBil->listeBilans($accesPartenaire);
|
||||
$nbBilans = count($tabBilans);
|
||||
$tabBilan = $tabBil = array();
|
||||
if ($nbBilans > 0)
|
||||
{
|
||||
foreach ($tabBilans as $millesime => $item)
|
||||
{
|
||||
$tabBilan[] = $mBil->getBilan(substr($millesime,-10), substr($millesime,0,1), '');
|
||||
}
|
||||
$tabRatios = calculRatios($tabBilans, $tabIdentite, $accesPartenaire);
|
||||
if ($nbBilans > 0) {
|
||||
$i = 0;
|
||||
foreach ($tabBilans as $millesime => $item) {
|
||||
if ( $item['typeBilan'] == 'N' ) {
|
||||
$tabBilan[] = $mBil->getBilan(substr($millesime, -10), substr($millesime, 0, 1));
|
||||
$i++;
|
||||
} elseif ( $item['typeBilan'] == 'S' ) {
|
||||
$tabN = $mBil->getBilan(substr($millesime, -10), substr($millesime, 0, 1));
|
||||
$tabS = $mBil->bilanSimplifie2Normal($tabN);
|
||||
$tabBilan[] = array_merge($tabN, $tabS);
|
||||
$i++;
|
||||
} elseif ( $item['typeBilan'] == 'C' ) {
|
||||
$tabBilan[] = $mBil->getBilan(substr($millesime, -10), substr($millesime, 0, 1));
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
require_once 'Metier/scores/classMRatios.php';
|
||||
$mRatios = new MRatios();
|
||||
$mRatios->setTrancheEffectif($efftr);
|
||||
$tabRatios = $mRatios->calcul($tabBilan);
|
||||
//file_put_contents('debug.log', print_r($tabRatios,1));
|
||||
}
|
||||
|
||||
$nbRatios = count($tabRatios);
|
||||
debugLog('I',"Liste des Ratios demandée pour $siren après calculRatios ($nbRatios)",__LINE__,__FILE__, __FUNCTION__, __CLASS__);
|
||||
|
||||
$tabAnnees = array();
|
||||
if ( $nbRatios > 0 ) {
|
||||
foreach ( $tabRatios as $i=>$R ) {
|
||||
foreach ( $tabRatios as $i => $R ) {
|
||||
//Informations sur le bilan
|
||||
$bilansInfos = new RatiosBilansInfos();
|
||||
$bilansInfos->dateCloture = $tabBilan[$i]['DATE_CLOTURE']; //@todo : date
|
||||
@ -4625,7 +4650,7 @@ class Entreprise extends Scores_Ws_Server
|
||||
|
||||
$tabRatiosEntrep = array();
|
||||
$tabRatiosEntrepEvol = array();
|
||||
foreach ( $R as $Ridx=>$Rmont ) {
|
||||
foreach ( $R as $Ridx => $Rmont ) {
|
||||
if ($Rmont<>'NS') {
|
||||
if ( $tabBorneMin[$Ridx]<>'' && $Rmont<$tabBorneMin[$Ridx] ){
|
||||
$Rmont='<'.$tabBorneMin[$Ridx];
|
||||
@ -4736,8 +4761,6 @@ class Entreprise extends Scores_Ws_Server
|
||||
}
|
||||
}
|
||||
|
||||
//$tabRatiosSecteurs=array(count($tabTmp), "1 $strNaf AND annee IN ($strAnnees) ORDER BY annee DESC, id ASC");
|
||||
|
||||
$output = new RatiosReturn();
|
||||
$output->Nom = $tabIdentite['Nom'];
|
||||
$output->NafEnt = $tabIdentite['NafEnt'];
|
||||
|
@ -50,7 +50,7 @@ try {
|
||||
//Options
|
||||
array(
|
||||
'help|?' => "Aide.",
|
||||
'ratios' => "Génére le cache des ratios (configMRatios.php)",
|
||||
'ratios' => "Génére la class des ratios (classMRatios.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",
|
||||
@ -397,66 +397,80 @@ function genereCacheRatios()
|
||||
$tabMoy=array();
|
||||
$iDb = new WDB("jo");
|
||||
|
||||
$strFonctions ='
|
||||
/** Donne le taux d\'inflation pour une année donnée **/
|
||||
function getInflation($annee) {
|
||||
$tabInfla = include realpath(dirname(__FILE__)) . DIRECTORY_SEPARATOR . \'CacheTabInfla.php\';
|
||||
if (isset($tabInfla[$annee])) return $tabInfla[$annee];
|
||||
}';
|
||||
|
||||
$strFonctions.='
|
||||
/** Donne le taux de rendement des actions pour une année donnée **/
|
||||
function getTxRendement($annee) {
|
||||
$tabTxRendObli = include realpath(dirname(__FILE__)) . DIRECTORY_SEPARATOR . \'CacheTabRendObli.php\';
|
||||
if (isset($tabTxRendObli[$annee])) return $tabTxRendObli[$annee];
|
||||
}';
|
||||
|
||||
$configFile = APPLICATION_PATH.'/../library/Metier/scores/Variables/configMRatios.php';
|
||||
|
||||
$configFile = APPLICATION_PATH.'/../library/Metier/scores/classMRatios.php';
|
||||
|
||||
$fp=fopen($configFile, 'w');
|
||||
fwrite($fp, '<?php'."\n");
|
||||
fwrite($fp, "/** Auto generated class ".date('Y-m-d H:i:s')."*/" . "\n");
|
||||
fwrite($fp, "class MRatios
|
||||
{
|
||||
public \$tva = 20.0;
|
||||
|
||||
public \$efftr = null;
|
||||
|
||||
/**
|
||||
* 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];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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['CONSOLIDE'];
|
||||
|
||||
// --- Utilisation des bilans N ou S uniquement
|
||||
if ( !in_array(substr(\$millesime, 0, 1), array('S', 'N')) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// --- Calcul
|
||||
" . "\n");
|
||||
|
||||
fwrite($fp, '$tva=20.0;' ."\n");
|
||||
fwrite($fp, $strFonctions ."\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");
|
||||
|
||||
fwrite($fp, "\n".'function calculRatios($tabBilans, $tabIdentite, $accesPartenaire) {' ."\n");
|
||||
fwrite($fp, ' global $tva, $mBil, $efftr;' ."\n");
|
||||
fwrite($fp, ' $numBil=0;' ."\n");
|
||||
fwrite($fp, ' $numBilType=array();' ."\n");
|
||||
fwrite($fp, ' $nbRatiosMax = 5;' ."\n");
|
||||
fwrite($fp, ' foreach ($tabBilans as $millesime => $bil) ' ."\n");
|
||||
fwrite($fp, ' {' ."\n");
|
||||
fwrite($fp, ' $tabTmp = $mBil->getBilan(substr($millesime,-10), substr($millesime,0,1), @$bil[\'ref\'], $accesPartenaire);' ."\n");
|
||||
|
||||
fwrite($fp, ' $numBilType[substr($millesime,0,1)]++;' ."\n");
|
||||
fwrite($fp, ' if (substr($millesime,0,1)==\'S\') {' ."\n");
|
||||
fwrite($fp, ' if ($numBilType[\'S\']>$nbRatiosMax) continue;' ."\n");
|
||||
fwrite($fp, ' $tabTmp2=$mBil->bilanSimplifie2Normal($tabTmp);' ."\n");
|
||||
fwrite($fp, ' $tabBilan[$numBil]=array_merge($tabTmp2, $tabTmp);' ."\n");
|
||||
fwrite($fp, ' } elseif (substr($millesime,0,1)==\'N\') {' ."\n");
|
||||
fwrite($fp, ' if ($numBilType[\'N\']>$nbRatiosMax) continue;' ."\n");
|
||||
fwrite($fp, ' $tabBilan[$numBil]=$tabTmp;' ."\n");
|
||||
fwrite($fp, ' } elseif (substr($millesime,0,1)==\'C\') {' ."\n");
|
||||
fwrite($fp, ' if ($numBilType[\'C\']>$nbRatiosMax) continue;' ."\n");
|
||||
fwrite($fp, ' $tabBilan[$numBil]=$tabTmp;' ."\n");
|
||||
fwrite($fp, ' } elseif (substr($millesime,0,1)==\'A\') {' ."\n");
|
||||
fwrite($fp, ' if ($numBilType[\'A\']>$nbRatiosMax) continue;' ."\n");
|
||||
fwrite($fp, ' $tabBilan[$numBil]=$tabTmp;' ."\n");
|
||||
fwrite($fp, ' //return(array());' ."\n");
|
||||
fwrite($fp, ' } elseif (substr($millesime,0,1)==\'B\') {' ."\n");
|
||||
fwrite($fp, ' if ($numBilType[\'B\']>$nbRatiosMax) continue;' ."\n");
|
||||
fwrite($fp, ' $tabBilan[$numBil]=$tabTmp;' ."\n");
|
||||
fwrite($fp, ' //return(array());' ."\n");
|
||||
fwrite($fp, ' }' ."\n");
|
||||
fwrite($fp, ' unset($tabTmp); unset($tabTmp2);' ."\n");
|
||||
fwrite($fp, ' if ($numBil>10) break;' ."\n");
|
||||
fwrite($fp, ' $p=$tabBilan[$numBil];' ."\n");
|
||||
fwrite($fp, ' $nm=$p[\'DUREE_MOIS\'];' ."\n");
|
||||
fwrite($fp, ' $nmp=$p[\'DUREE_MOIS_PRE\'];' ."\n");
|
||||
fwrite($fp, ' $R=array();' ."\n");
|
||||
|
||||
$tabFormules=$iDb->select(
|
||||
$tabFormules = $iDb->select(
|
||||
'ratios_formules',
|
||||
'id, libelle, formule, unite, commentaires, borneMin, borneMax, calcul, deleted',
|
||||
'deleted=0');
|
||||
@ -479,74 +493,78 @@ function getTxRendement($annee) {
|
||||
}
|
||||
|
||||
// Gestion des variables minuscules de 1 à 8 caractères alphanumériques
|
||||
$formule1=preg_replace('/([a-z]{1,8})/','\$$1', $formuleStr);
|
||||
$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);
|
||||
$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) {
|
||||
$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);
|
||||
$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);
|
||||
$formule1 = preg_replace('/\INFLATION/U', '$this->getInflation(substr($millesime,-4))', $formule1);
|
||||
|
||||
// Ecriture de la formule
|
||||
$formule1="\$R[$id]=".$formule1.';';
|
||||
$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";
|
||||
$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]);
|
||||
$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;";
|
||||
$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.="if (\$R[$id]>$bMax) \$R[$id]=$bMax;";
|
||||
$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.="if (\$R[$id]>$bMax) \$R[$id]=$bMax;";
|
||||
$formule1 = preg_replace('/(;LIM\(.*\))/U','', $formule1);
|
||||
$bMax = trim($matches[1])*1;
|
||||
$formule1.= "\t" . "if (\$R[$id]>$bMax) { \$R[$id] = $bMax; }";
|
||||
}
|
||||
$formule2=$formule1;
|
||||
$formule2 = $formule1;
|
||||
|
||||
fwrite($fp, "\t\t".$formule2."\n");
|
||||
fwrite($fp, "\t\t".'if (!isset($R['.$id.'])) $R['.$id.']=\'NS\';'."\n");
|
||||
fwrite($fp, "\t\t\t" . $formule2 . "\n");
|
||||
fwrite($fp, "\t\t\t" . "if (!isset(\$R[".$id."])) { \$R[".$id."] = 'NS'; }" . "\n\n");
|
||||
}
|
||||
}
|
||||
|
||||
fwrite($fp, "\n\t\t".'$tabRatios[$numBil]=$R;'."\n");
|
||||
fwrite($fp, "\t\t".'$numBil++;'."\n");
|
||||
fwrite($fp, "\t".'}'."\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, ' for($i=0; $i<$numBil; $i++) {'."\n");
|
||||
fwrite($fp, ' $tabRatios[$i]['.$iRatio.']=($tabRatios[$i]['.$irMoy.']');
|
||||
for($i=1; $i<$nbExo; $i++)
|
||||
fwrite($fp, '+$tabRatios[$i+'.$i.']['.$irMoy.']');
|
||||
fwrite($fp, ')/'.$nbExo.';');
|
||||
fwrite($fp, ' }'."\n"."\n");
|
||||
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".'return $tabRatios;'."\n");
|
||||
fwrite($fp, '}'."\n");
|
||||
fwrite($fp, "\t\t" . "return \$tabRatios;" . "\n");
|
||||
fwrite($fp, "\t" . "}" . "\n");
|
||||
fwrite($fp, "}" . "\n");
|
||||
fclose ($fp);
|
||||
|
||||
$strOutput=exec('php -l '.$configFile, $output);
|
||||
|
Loading…
Reference in New Issue
Block a user