Déplacement méthode getRatios dans WsEntreprise
This commit is contained in:
parent
4cb8b06ee3
commit
ca1db2a7e7
@ -54,3 +54,5 @@ Type.52 = "RechercheAnnonce"
|
||||
Type.53 = "IndiscoreReturn"
|
||||
Type.54 = "Bilan"
|
||||
Type.55 = "BilanPoste"
|
||||
Type.56 = "RatiosReturn"
|
||||
Type.57 = "RatiosResult"
|
@ -65,25 +65,23 @@ Type.63 = "GeoCodeReturn"
|
||||
Type.64 = "GeoCode"
|
||||
Type.65 = "ListeUtilisateursReturn"
|
||||
Type.66 = "Utilisateur"
|
||||
Type.67 = "RatiosReturn"
|
||||
Type.68 = "RatiosResult"
|
||||
Type.69 = "CommandeEnqueteReturn"
|
||||
Type.70 = "CommandeEnquete"
|
||||
Type.71 = "CommandeAssoReturn"
|
||||
Type.72 = "CommandeAsso"
|
||||
Type.73 = "LogsClientsReturn"
|
||||
Type.74 = "LogsClients"
|
||||
Type.75 = "ListeSurveillancesCsvReturn"
|
||||
Type.76 = "ListeSurveillancesCsv"
|
||||
Type.77 = "RechercheHistoReturn"
|
||||
Type.78 = "RechercheHistoCriteres"
|
||||
Type.79 = "RechercheHistoReponses"
|
||||
Type.80 = "SurveillancesReturn"
|
||||
Type.81 = "SurveillancesResult"
|
||||
Type.82 = "SurveillancesCriteres"
|
||||
Type.83 = "SurveillancesReponses"
|
||||
Type.84 = "ClientReturn"
|
||||
Type.85 = "ModeleUtilisateurReturn"
|
||||
Type.86 = "ModeleUtilisateur"
|
||||
Type.87 = "ListeDroitsReturn"
|
||||
Type.88 = "ListePrefsReturn"
|
||||
Type.67 = "CommandeEnqueteReturn"
|
||||
Type.68 = "CommandeEnquete"
|
||||
Type.69 = "CommandeAssoReturn"
|
||||
Type.70 = "CommandeAsso"
|
||||
Type.71 = "LogsClientsReturn"
|
||||
Type.72 = "LogsClients"
|
||||
Type.73 = "ListeSurveillancesCsvReturn"
|
||||
Type.74 = "ListeSurveillancesCsv"
|
||||
Type.75 = "RechercheHistoReturn"
|
||||
Type.76 = "RechercheHistoCriteres"
|
||||
Type.77 = "RechercheHistoReponses"
|
||||
Type.78 = "SurveillancesReturn"
|
||||
Type.79 = "SurveillancesResult"
|
||||
Type.80 = "SurveillancesCriteres"
|
||||
Type.81 = "SurveillancesReponses"
|
||||
Type.82 = "ClientReturn"
|
||||
Type.83 = "ModeleUtilisateurReturn"
|
||||
Type.84 = "ModeleUtilisateur"
|
||||
Type.85 = "ListeDroitsReturn"
|
||||
Type.86 = "ListePrefsReturn"
|
||||
|
@ -1899,3 +1899,39 @@ class Scores
|
||||
public $NOTETRES; // Tresorerie
|
||||
public $NOTEMEX; // Marge Exploitation
|
||||
}
|
||||
|
||||
class RatiosReturn
|
||||
{
|
||||
/** @var ErrorType */
|
||||
public $error;
|
||||
/** @var RatiosResult */
|
||||
public $result;
|
||||
}
|
||||
|
||||
class RatiosResult
|
||||
{
|
||||
/** @var string */
|
||||
public $Nom;
|
||||
/** @var string */
|
||||
public $NafEnt;
|
||||
/** @var string */
|
||||
public $NafEntLib;
|
||||
/** @var string */
|
||||
public $FJ;
|
||||
/** @var string */
|
||||
public $FJ_lib;
|
||||
/** @var string */
|
||||
public $Siren;
|
||||
/** @var string */
|
||||
public $NbEntNaf;
|
||||
/** @var array */
|
||||
public $BilansInfos;
|
||||
/** @var array */
|
||||
public $RatiosInfos;
|
||||
/** @var array */
|
||||
public $RatiosEntrep;
|
||||
/** @var array */
|
||||
public $RatiosEntrepEvol;
|
||||
/** @var array */
|
||||
public $RatiosSecteur;
|
||||
}
|
||||
|
@ -1011,42 +1011,6 @@ class Utilisateur
|
||||
public $reference;
|
||||
}
|
||||
|
||||
class RatiosReturn
|
||||
{
|
||||
/** @var ErrorType */
|
||||
public $error;
|
||||
/** @var RatiosResult */
|
||||
public $result;
|
||||
}
|
||||
|
||||
class RatiosResult
|
||||
{
|
||||
/** @var string */
|
||||
public $Nom;
|
||||
/** @var string */
|
||||
public $NafEnt;
|
||||
/** @var string */
|
||||
public $NafEntLib;
|
||||
/** @var string */
|
||||
public $FJ;
|
||||
/** @var string */
|
||||
public $FJ_lib;
|
||||
/** @var string */
|
||||
public $Siren;
|
||||
/** @var string */
|
||||
public $NbEntNaf;
|
||||
/** @var array */
|
||||
public $BilansInfos;
|
||||
/** @var array */
|
||||
public $RatiosInfos;
|
||||
/** @var array */
|
||||
public $RatiosEntrep;
|
||||
/** @var array */
|
||||
public $RatiosEntrepEvol;
|
||||
/** @var array */
|
||||
public $RatiosSecteur;
|
||||
}
|
||||
|
||||
class CommandeEnqueteReturn
|
||||
{
|
||||
/** @var ErrorType */
|
||||
|
@ -1834,6 +1834,187 @@ class WsEntreprise extends WsScore
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* getRatios
|
||||
* @param string $siren
|
||||
* @param string $page
|
||||
* @return RatiosReturn
|
||||
*/
|
||||
public function getRatios($siren, $page='ratios')
|
||||
{
|
||||
$this->authenticate();
|
||||
|
||||
//Initialisation
|
||||
$error = new ErrorType();
|
||||
if (empty($page)) $page = 'ratios';
|
||||
$tabRatiosInfos=$tabRatiosSecteurs=$tabBilansR=$tabRatios2=$tabRatiosEvol=array();
|
||||
$tabRet = array();
|
||||
//global $tva, $tabFormules, $mBil, $tabBilan, $efftr;
|
||||
|
||||
debugLog('I',"Liste des Ratios demandée pour $siren",__LINE__,__FILE__, __FUNCTION__, __CLASS__);
|
||||
|
||||
if (strlen($siren)<>9)
|
||||
{
|
||||
debugLog('W', "Siren $siren incorrect", __LINE__, __FILE__, __FUNCTION__, __CLASS__);
|
||||
$error->errnum =102;
|
||||
$error->errmsg = 'Siren inexistant';
|
||||
}
|
||||
elseif ($siren*1==0)
|
||||
{
|
||||
debugLog('W', "Siren $siren inexistant", __LINE__, __FILE__, __FUNCTION__, __CLASS__);
|
||||
$error->errnum =102;
|
||||
$error->errmsg = 'Siren inexistant';
|
||||
}
|
||||
else
|
||||
{
|
||||
debugLog('I',"Liste des Ratios demandée pour $siren avant getIdentiteEntreprise",__LINE__,__FILE__, __FUNCTION__, __CLASS__);
|
||||
$iInsee = new MInsee();
|
||||
$tabIdentite = $iInsee->getIdentiteEntreprise($siren,0,0,false,false);
|
||||
debugLog('I',"Liste des Ratios demandée pour $siren après getIdentiteEntreprise",__LINE__,__FILE__, __FUNCTION__, __CLASS__);
|
||||
$naf=$tabIdentite['NafEnt'];
|
||||
$nafLib=$tabIdentite['NafEntLib'];
|
||||
$efftr=$tabIdentite['Effectif']*1;
|
||||
$fj=$tabIdentite['FJ'];
|
||||
|
||||
$mBil=new MBilans($siren);
|
||||
$tabBilans=$mBil->listeBilans(true);
|
||||
//@sendMail('production@scores-decisions.com', 'ylenaour@scores-decisions.com', "getRatios sur $siren", print_r($tabBilans, true));
|
||||
|
||||
$nbBilans=count($tabBilans);
|
||||
$tabBilan=$tabBil=array();
|
||||
if ($nbBilans>0)
|
||||
$tabRatios=@calculRatios($tabBilans, $tabIdentite, true);
|
||||
|
||||
$nbRatios=count($tabRatios);
|
||||
debugLog('I',"Liste des Ratios demandée pour $siren après calculRatios ($nbRatios)",__LINE__,__FILE__, __FUNCTION__, __CLASS__);
|
||||
|
||||
/** Tableau d'infos sur les formules **/
|
||||
$tabBorneMin=$tabBorneMax=array();
|
||||
foreach ($tabFormules as $formule) {
|
||||
$id=$formule['id']*1;
|
||||
$libelle=$formule['libelle'];
|
||||
$unite=$formule['unite'];
|
||||
$commentaires=$formule['commentaires'];
|
||||
// Utilisation d'un index texte à cause du webservice
|
||||
$tabRatiosInfos['r'.$id]=array(
|
||||
'libelle' => prepareString($formule['libelle']),
|
||||
'unite' => $formule['unite'],
|
||||
//'borneMin' => $formule['borneMin'],
|
||||
//'borneMax' => $formule['borneMax'],
|
||||
'commentaires' => prepareString($formule['commentaires']),
|
||||
);
|
||||
$tabBorneMin[$id]=$formule['borneMin'];
|
||||
$tabBorneMax[$id]=$formule['borneMax'];
|
||||
}
|
||||
|
||||
/** Tableau des années de bilans **/
|
||||
$tabAnnees=array();
|
||||
// Tableau d'infos sur les bilans
|
||||
foreach ($tabRatios as $i=>$R) {
|
||||
$tabBilansR[$i]=array(
|
||||
'dateCloture' => $tabBilan[$i]['DATE_CLOTURE'],
|
||||
'duree' => $tabBilan[$i]['DUREE_MOIS'],
|
||||
'devise' => $tabBilan[$i]['MONNAIE'],
|
||||
'typeBilan' => $tabBilan[$i]['CONSOLIDE'],
|
||||
'unite' => 'U',
|
||||
);
|
||||
if (substr($tabBilan[$i]['DATE_CLOTURE'],0,4)>1900)
|
||||
$tabAnnees[$i]=substr($tabBilan[$i]['DATE_CLOTURE'],0,4);
|
||||
}
|
||||
foreach ($tabRatios as $i=>$R) {
|
||||
// Utilisation d'un index texte à cause du webservice
|
||||
foreach ($R as $Ridx=>$Rmont) {
|
||||
if ($Rmont<>'NS') {
|
||||
if ($tabBorneMin[$Ridx]<>'' && $Rmont<$tabBorneMin[$Ridx])
|
||||
$Rmont='<'.$tabBorneMin[$Ridx];
|
||||
elseif ($tabBorneMax[$Ridx]<>'' && $Rmont>$tabBorneMax[$Ridx])
|
||||
$Rmont='>'.$tabBorneMax[$Ridx];
|
||||
}
|
||||
if (substr($Rmont,0,1)=='N' || substr($Rmont,0,1)=='<' || substr($Rmont,0,1)=='>')
|
||||
$tabRatios2[$i]['r'.$Ridx]=$Rmont;
|
||||
else
|
||||
$tabRatios2[$i]['r'.$Ridx]=round($Rmont,2);
|
||||
|
||||
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=(($R[$Ridx]-$tabRatios[$i+1][$Ridx])*100)/abs($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=(($R[$Ridx]-$tabRatios[$i+2][$Ridx])*100)/abs($tabRatios[$i+2][$Ridx]);
|
||||
else
|
||||
$Rmont='NS';
|
||||
|
||||
if ($Rmont=='NS' || $Rmont<-800 || $Rmont>800)
|
||||
$tabRatiosEvol[$i]['r'.$Ridx]='NS';
|
||||
else
|
||||
$tabRatiosEvol[$i]['r'.$Ridx]=@number_format($Rmont,2,',',' ');
|
||||
// debugLog('I',"Liste des Ratios demandée pour $siren ratio $i, $Ridx=$Rmont",__LINE__,__FILE__, __FUNCTION__, __CLASS__);
|
||||
}
|
||||
}
|
||||
debugLog('I',"Liste des Ratios demandée pour $siren après EVOLUTION",__LINE__,__FILE__, __FUNCTION__, __CLASS__);
|
||||
|
||||
/** Tableau des ratios secteurs */
|
||||
$tabRatiosSecteurs=array();
|
||||
if (strlen($naf)>4) $strNaf=" AND naf5='$naf' ";
|
||||
else $strNaf=" AND naf4='$naf' ";
|
||||
$strAnnees=implode(',', $tabAnnees);
|
||||
if (count($tabAnnees)>0) {
|
||||
$iDb=new WDB('jo');
|
||||
$tabTmp=$iDb->select('ratios_secteurs', 'annee, naf5, naf4, id, (montant/nombre) AS ratio, nombre', "1 $strNaf AND annee IN ($strAnnees) ORDER BY annee DESC, id ASC", true, MYSQL_ASSOC);
|
||||
$nbRatiosSec=0;
|
||||
$anneePre=$tabTmp[0]['annee'];
|
||||
$iAn=0;
|
||||
foreach ($tabTmp as $tabTmp2) {
|
||||
if ($anneePre<>$tabTmp2['annee']) $iAn++;
|
||||
$Ridx=$tabTmp2['id'];
|
||||
if ($tabTmp2['nombre']>$nbRatiosSec) $nbRatiosSec=$tabTmp2['nombre'];
|
||||
if ($tabRatiosInfos['r'.$Ridx]['unite']=='EUR') $montant=round($tabTmp2['ratio']*1000);
|
||||
else $montant=round($tabTmp2['ratio']);
|
||||
|
||||
if ($tabBorneMin[$Ridx]<>'' && $montant<$tabBorneMin[$Ridx])
|
||||
$montant='<'.$tabBorneMin[$Ridx];
|
||||
elseif ($tabBorneMax[$Ridx]<>'' && $montant>$tabBorneMax[$Ridx])
|
||||
$montant='>'.$tabBorneMax[$Ridx];
|
||||
|
||||
if (substr($montant,0,1)=='N' || substr($montant,0,1)=='<' || substr($montant,0,1)=='>')
|
||||
$tabRatiosSecteurs[$iAn]['r'.$Ridx]=$montant;
|
||||
else
|
||||
$tabRatiosSecteurs[$iAn]['r'.$Ridx]=round($montant,2);
|
||||
|
||||
// $tabRatiosSecteurs[$iAn]['r'.$Ridx]=$montant;
|
||||
$anneePre=$tabTmp2['annee'];
|
||||
//$tabRatiosSecteurs=array('titi');
|
||||
}
|
||||
}
|
||||
//$tabRatiosSecteurs=array(count($tabTmp), "1 $strNaf AND annee IN ($strAnnees) ORDER BY annee DESC, id ASC");
|
||||
|
||||
$result = new RatiosResult();
|
||||
$result->Nom = $tabIdentite['Nom'];
|
||||
$result->NafEnt = $tabIdentite['NafEnt'];
|
||||
$result->NafEntLib = $tabIdentite['NafEntLib'];
|
||||
$result->FJ = $fj;
|
||||
$result->FJ_lib = $tabIdentite['FJ_lib'];
|
||||
$result->Siren = $siren;
|
||||
$result->NbEntNaf = $nbRatiosSec;
|
||||
$result->BilansInfos = $tabBilansR;
|
||||
$result->RatiosInfos = $tabRatiosInfos;
|
||||
$result->RatiosEntrep = $tabRatios2;
|
||||
$result->RatiosEntrepEvol = $tabRatiosEvol;
|
||||
$result->RatiosSecteur = $tabRatiosSecteurs;
|
||||
debugLog('I',"Liste des Ratios demandée pour $siren RETURN",__LINE__,__FILE__, __FUNCTION__, __CLASS__);
|
||||
wsLog($page, $siren);
|
||||
$output = new RatiosReturn();
|
||||
$output->error = $error;
|
||||
$output->result = $result;
|
||||
return $output;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Retourne le statut du webservice
|
||||
* @return StatusReturn
|
||||
|
@ -3101,181 +3101,7 @@ class WsInterne extends WsScore
|
||||
return $this->getListeSurveillancesCsv('portefeuille', $login, $idClient);
|
||||
}
|
||||
|
||||
/**
|
||||
* getRatios
|
||||
* @param string $siren
|
||||
* @param string $page
|
||||
* @return RatiosReturn
|
||||
*/
|
||||
public function getRatios($siren, $page='ratios')
|
||||
{
|
||||
$this->authenticate();
|
||||
|
||||
//Initialisation
|
||||
$error = new ErrorType();
|
||||
$tabRatiosInfos=$tabRatiosSecteurs=$tabBilansR=$tabRatios2=$tabRatiosEvol=array();
|
||||
$tabRet = array();
|
||||
//global $tva, $tabFormules, $mBil, $tabBilan, $efftr;
|
||||
|
||||
debugLog('I',"Liste des Ratios demandée pour $siren",__LINE__,__FILE__, __FUNCTION__, __CLASS__);
|
||||
|
||||
if (strlen($siren)<>9)
|
||||
{
|
||||
debugLog('W', "Siren $siren incorrect", __LINE__, __FILE__, __FUNCTION__, __CLASS__);
|
||||
$error->errnum =102;
|
||||
$error->errmsg = 'Siren inexistant';
|
||||
}
|
||||
elseif ($siren*1==0)
|
||||
{
|
||||
debugLog('W', "Siren $siren inexistant", __LINE__, __FILE__, __FUNCTION__, __CLASS__);
|
||||
$error->errnum =102;
|
||||
$error->errmsg = 'Siren inexistant';
|
||||
}
|
||||
else
|
||||
{
|
||||
debugLog('I',"Liste des Ratios demandée pour $siren avant getIdentiteEntreprise",__LINE__,__FILE__, __FUNCTION__, __CLASS__);
|
||||
$iInsee = new MInsee();
|
||||
$tabIdentite = $iInsee->getIdentiteEntreprise($siren,0,0,false,false);
|
||||
debugLog('I',"Liste des Ratios demandée pour $siren après getIdentiteEntreprise",__LINE__,__FILE__, __FUNCTION__, __CLASS__);
|
||||
$naf=$tabIdentite['NafEnt'];
|
||||
$nafLib=$tabIdentite['NafEntLib'];
|
||||
$efftr=$tabIdentite['Effectif']*1;
|
||||
$fj=$tabIdentite['FJ'];
|
||||
|
||||
$mBil=new MBilans($siren);
|
||||
$tabBilans=$mBil->listeBilans(true);
|
||||
//@sendMail('production@scores-decisions.com', 'ylenaour@scores-decisions.com', "getRatios sur $siren", print_r($tabBilans, true));
|
||||
|
||||
$nbBilans=count($tabBilans);
|
||||
$tabBilan=$tabBil=array();
|
||||
if ($nbBilans>0)
|
||||
$tabRatios=@calculRatios($tabBilans, $tabIdentite, true);
|
||||
|
||||
$nbRatios=count($tabRatios);
|
||||
debugLog('I',"Liste des Ratios demandée pour $siren après calculRatios ($nbRatios)",__LINE__,__FILE__, __FUNCTION__, __CLASS__);
|
||||
|
||||
|
||||
/** Tableau d'infos sur les formules **/
|
||||
$tabBorneMin=$tabBorneMax=array();
|
||||
foreach ($tabFormules as $formule) {
|
||||
$id=$formule['id']*1;
|
||||
$libelle=$formule['libelle'];
|
||||
$unite=$formule['unite'];
|
||||
$commentaires=$formule['commentaires'];
|
||||
// Utilisation d'un index texte à cause du webservice
|
||||
$tabRatiosInfos['r'.$id]=array( 'libelle' => prepareString($formule['libelle']),
|
||||
'unite' => $formule['unite'],
|
||||
//'borneMin' => $formule['borneMin'],
|
||||
//'borneMax' => $formule['borneMax'],
|
||||
'commentaires' => prepareString($formule['commentaires']),
|
||||
);
|
||||
$tabBorneMin[$id]=$formule['borneMin'];
|
||||
$tabBorneMax[$id]=$formule['borneMax'];
|
||||
}
|
||||
|
||||
/** Tanleau des années de bilans **/
|
||||
$tabAnnees=array();
|
||||
// Tableau d'infos sur les bilans
|
||||
foreach ($tabRatios as $i=>$R) {
|
||||
$tabBilansR[$i]=array( 'dateCloture' => $tabBilan[$i]['DATE_CLOTURE'],
|
||||
'duree' => $tabBilan[$i]['DUREE_MOIS'],
|
||||
'devise' => $tabBilan[$i]['MONNAIE'],
|
||||
'typeBilan' => $tabBilan[$i]['CONSOLIDE'],
|
||||
'unite' => 'U',
|
||||
);
|
||||
if (substr($tabBilan[$i]['DATE_CLOTURE'],0,4)>1900)
|
||||
$tabAnnees[$i]=substr($tabBilan[$i]['DATE_CLOTURE'],0,4);
|
||||
}
|
||||
foreach ($tabRatios as $i=>$R) {
|
||||
// Utilisation d'un index texte à cause du webservice
|
||||
foreach ($R as $Ridx=>$Rmont) {
|
||||
if ($Rmont<>'NS') {
|
||||
if ($tabBorneMin[$Ridx]<>'' && $Rmont<$tabBorneMin[$Ridx])
|
||||
$Rmont='<'.$tabBorneMin[$Ridx];
|
||||
elseif ($tabBorneMax[$Ridx]<>'' && $Rmont>$tabBorneMax[$Ridx])
|
||||
$Rmont='>'.$tabBorneMax[$Ridx];
|
||||
}
|
||||
if (substr($Rmont,0,1)=='N' || substr($Rmont,0,1)=='<' || substr($Rmont,0,1)=='>')
|
||||
$tabRatios2[$i]['r'.$Ridx]=$Rmont;
|
||||
else
|
||||
$tabRatios2[$i]['r'.$Ridx]=round($Rmont,2);
|
||||
|
||||
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=(($R[$Ridx]-$tabRatios[$i+1][$Ridx])*100)/abs($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=(($R[$Ridx]-$tabRatios[$i+2][$Ridx])*100)/abs($tabRatios[$i+2][$Ridx]);
|
||||
else
|
||||
$Rmont='NS';
|
||||
|
||||
if ($Rmont=='NS' || $Rmont<-800 || $Rmont>800)
|
||||
$tabRatiosEvol[$i]['r'.$Ridx]='NS';
|
||||
else
|
||||
$tabRatiosEvol[$i]['r'.$Ridx]=@number_format($Rmont,2,',',' ');
|
||||
// debugLog('I',"Liste des Ratios demandée pour $siren ratio $i, $Ridx=$Rmont",__LINE__,__FILE__, __FUNCTION__, __CLASS__);
|
||||
}
|
||||
}
|
||||
debugLog('I',"Liste des Ratios demandée pour $siren après EVOLUTION",__LINE__,__FILE__, __FUNCTION__, __CLASS__);
|
||||
|
||||
/** Tableau des ratios secteurs */
|
||||
$tabRatiosSecteurs=array();
|
||||
if (strlen($naf)>4) $strNaf=" AND naf5='$naf' ";
|
||||
else $strNaf=" AND naf4='$naf' ";
|
||||
$strAnnees=implode(',', $tabAnnees);
|
||||
if (count($tabAnnees)>0) {
|
||||
$iDb=new WDB('jo');
|
||||
$tabTmp=$iDb->select('ratios_secteurs', 'annee, naf5, naf4, id, (montant/nombre) AS ratio, nombre', "1 $strNaf AND annee IN ($strAnnees) ORDER BY annee DESC, id ASC", true, MYSQL_ASSOC);
|
||||
$nbRatiosSec=0;
|
||||
$anneePre=$tabTmp[0]['annee'];
|
||||
$iAn=0;
|
||||
foreach ($tabTmp as $tabTmp2) {
|
||||
if ($anneePre<>$tabTmp2['annee']) $iAn++;
|
||||
$Ridx=$tabTmp2['id'];
|
||||
if ($tabTmp2['nombre']>$nbRatiosSec) $nbRatiosSec=$tabTmp2['nombre'];
|
||||
if ($tabRatiosInfos['r'.$Ridx]['unite']=='EUR') $montant=round($tabTmp2['ratio']*1000);
|
||||
else $montant=round($tabTmp2['ratio']);
|
||||
|
||||
if ($tabBorneMin[$Ridx]<>'' && $montant<$tabBorneMin[$Ridx])
|
||||
$montant='<'.$tabBorneMin[$Ridx];
|
||||
elseif ($tabBorneMax[$Ridx]<>'' && $montant>$tabBorneMax[$Ridx])
|
||||
$montant='>'.$tabBorneMax[$Ridx];
|
||||
|
||||
if (substr($montant,0,1)=='N' || substr($montant,0,1)=='<' || substr($montant,0,1)=='>')
|
||||
$tabRatiosSecteurs[$iAn]['r'.$Ridx]=$montant;
|
||||
else
|
||||
$tabRatiosSecteurs[$iAn]['r'.$Ridx]=round($montant,2);
|
||||
|
||||
// $tabRatiosSecteurs[$iAn]['r'.$Ridx]=$montant;
|
||||
$anneePre=$tabTmp2['annee'];
|
||||
//$tabRatiosSecteurs=array('titi');
|
||||
}
|
||||
}
|
||||
//$tabRatiosSecteurs=array(count($tabTmp), "1 $strNaf AND annee IN ($strAnnees) ORDER BY annee DESC, id ASC");
|
||||
|
||||
$result = new RatiosResult();
|
||||
$result->Nom = $tabIdentite['Nom'];
|
||||
$result->NafEnt = $tabIdentite['NafEnt'];
|
||||
$result->NafEntLib = $tabIdentite['NafEntLib'];
|
||||
$result->FJ = $fj;
|
||||
$result->FJ_lib = $tabIdentite['FJ_lib'];
|
||||
$result->Siren = $siren;
|
||||
$result->NbEntNaf = $nbRatiosSec;
|
||||
$result->BilansInfos = $tabBilansR;
|
||||
$result->RatiosInfos = $tabRatiosInfos;
|
||||
$result->RatiosEntrep = $tabRatios2;
|
||||
$result->RatiosEntrepEvol = $tabRatiosEvol;
|
||||
$result->RatiosSecteur = $tabRatiosSecteurs;
|
||||
debugLog('I',"Liste des Ratios demandée pour $siren RETURN",__LINE__,__FILE__, __FUNCTION__, __CLASS__);
|
||||
wsLog($page, $siren);
|
||||
$output = new RatiosReturn();
|
||||
$output->error = $error;
|
||||
$output->result = $result;
|
||||
return $output;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* getSurveillances
|
||||
|
Loading…
x
Reference in New Issue
Block a user