Librairies Update
This commit is contained in:
parent
6f8da88cab
commit
f74b432bf3
@ -111,62 +111,77 @@ class Metier_Insee_MInsee extends Metier_Insee_Table
|
||||
if (!empty($nic)) {
|
||||
$nic = str_pad($nic, 5, '0', STR_PAD_LEFT);
|
||||
}
|
||||
if (!Metier_Util_String::valideData($siren, 9, 9,'N')) //Siren non précisé ou incorrect.
|
||||
//Siren non précisé ou incorrect.
|
||||
if (!Metier_Util_String::valideData($siren, 9, 9,'N')) {
|
||||
return $erreur;
|
||||
elseif ($siren*1==0) // Siren vide
|
||||
}
|
||||
// Siren vide
|
||||
elseif (intval($siren) == 0) {
|
||||
return $erreur;
|
||||
else
|
||||
{
|
||||
if (!isset($nic) || trim($nic)=='')
|
||||
{
|
||||
}
|
||||
else {
|
||||
if (!isset($nic) || trim($nic)=='') {
|
||||
$somme = 0;
|
||||
// Traitement IMPAIR
|
||||
for ($i=0; $i<=8; $i+=2) {
|
||||
$somme+= (integer) substr($siren,$i,1);
|
||||
}
|
||||
// Traitement PAIR
|
||||
for ($i=1; $i<=7; $i+=2) {
|
||||
$var_tmp = (string) (2*((integer)substr($siren,$i,1)));
|
||||
$som_tmp = 0;
|
||||
for($j=0; $j<strlen($var_tmp);$j++) {
|
||||
$som_tmp+= (integer)substr($var_tmp,$j,1);
|
||||
}
|
||||
$somme+= $som_tmp;
|
||||
}
|
||||
|
||||
// Le Siren est faux
|
||||
if ((integer) ($somme/10) != ($somme/10)) {
|
||||
// Les siren débutant par 200 sont toujours valides (sirens provisoires de la BDF?!)
|
||||
if (substr($siren,0,3) != '200') {
|
||||
return $erreur;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
// Nic de format incorrect.
|
||||
if (!Metier_Util_String::valideData($nic,1,5,'N')) {
|
||||
return $erreur;
|
||||
}
|
||||
$SIRET = $siren.$nic;
|
||||
if ($siren != 356000000) {
|
||||
$somme=0;
|
||||
for ($i=0; $i<=8; $i+=2) // Traitement IMPAIR
|
||||
$somme+=(integer)substr($siren,$i,1);
|
||||
|
||||
for ($i=1; $i<=7; $i+=2)
|
||||
{ // Traitement PAIR
|
||||
$var_tmp=(string)(2*((integer)substr($siren,$i,1)));
|
||||
$som_tmp=0;
|
||||
for($j=0;$j<strlen($var_tmp);$j++)
|
||||
$som_tmp+=(integer)substr($var_tmp,$j,1);
|
||||
$somme+=$som_tmp;
|
||||
// Traitement PAIR
|
||||
for ($i=0; $i<=12; $i+=2) {
|
||||
$var_tmp = (string) (2*((integer)substr($SIRET,$i,1)));
|
||||
$som_tmp = 0;
|
||||
for($j=0; $j<strlen($var_tmp); $j++) {
|
||||
$som_tmp+= (integer) substr($var_tmp,$j,1);
|
||||
}
|
||||
|
||||
if ((integer)($somme/10)!=($somme/10))
|
||||
{ // Le Siren est faux
|
||||
if (substr($siren,0,3)!='200') // Les siren débutant par 200 sont toujours valides (sirens provisoires de la BDF?!)
|
||||
$somme+= $som_tmp;
|
||||
}
|
||||
// Traitement IMPAIR
|
||||
for ($i=1; $i<=13; $i+=2) {
|
||||
$somme+= (integer) substr($SIRET,$i,1);
|
||||
}
|
||||
// Le Siret est faux
|
||||
if ((integer) ($somme/10) != ($somme/10)) {
|
||||
return $erreur;
|
||||
}
|
||||
} else {
|
||||
if (!Metier_Util_String::valideData($nic,1,5,'N')) // Nic de format incorrect.
|
||||
return $erreur;
|
||||
|
||||
$SIRET=$siren.$nic;
|
||||
if ($siren<>356000000) {
|
||||
$somme=0;
|
||||
for ($i=0; $i<=12; $i+=2)
|
||||
{ // Traitement PAIR
|
||||
$var_tmp=(string)(2*((integer)substr($SIRET,$i,1)));
|
||||
$som_tmp=0;
|
||||
for($j=0;$j<strlen($var_tmp);$j++)
|
||||
$som_tmp+=(integer)substr($var_tmp,$j,1);
|
||||
$somme+=$som_tmp;
|
||||
}
|
||||
for ($i=1; $i<=13; $i+=2) // Traitement IMPAIR
|
||||
$somme+=(integer)substr($SIRET,$i,1);
|
||||
|
||||
if ((integer)($somme/10)!=($somme/10))// Le Siret est faux
|
||||
return $erreur;
|
||||
} else {
|
||||
// Cas particulier du siren de LA POSTE : 356 000 000 00000
|
||||
$somme=14;
|
||||
for ($i=9; $i<=13; $i++)
|
||||
$somme+=(integer)substr($SIRET,$i,1);
|
||||
if ($somme%5!=0) // Le NIC de l'établissement de LA POSTE est faux !
|
||||
$somme = 14;
|
||||
for ($i=9; $i<=13; $i++) {
|
||||
$somme+= (integer)substr($SIRET,$i,1);
|
||||
}
|
||||
// Le NIC de l'établissement de LA POSTE est faux !
|
||||
if ($somme%5 != 0) {
|
||||
return $erreur;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -408,8 +408,8 @@ class Metier_Partenaires_MBilans
|
||||
return $this->Bilans[$typeBilan.$millesime];
|
||||
}
|
||||
|
||||
$clotureDate = new Zend_Date($millesime, 'dd/MM/yyyy');
|
||||
$clotureDateSql = $clotureDate->toString('yyyyMMdd');
|
||||
$clotureDate = DateTime::createFromFormat('d/m/Y', $millesime);
|
||||
$clotureDateSql = $clotureDate->format('Ymd');
|
||||
if ($accesPartenaire) {
|
||||
// On ne veut pas de bilans "Téléchargés" directement sur Internet
|
||||
$strSansBilansWeb=' AND partenaire<>7 ';
|
||||
@ -550,8 +550,8 @@ class Metier_Partenaires_MBilans
|
||||
|| ( ($tabBilan['N15']*1==0 || $tabBilan['N32']*1==0) && $tabBilan['CONSOLIDE']=='S' ) // Réel Simplifié
|
||||
) {
|
||||
|
||||
$cloturePreDate = $clotureDate->subMonth($bilan['dureeExercice']);
|
||||
$cloturePreDateSql = $cloturePreDate->toString('yyyyMM');
|
||||
$cloturePreDate = $clotureDate->sub(new DateInterval('P'.$bilan['dureeExercice'].'M'));
|
||||
$cloturePreDateSql = $cloturePreDate->format('Ym');
|
||||
|
||||
// --- Recherche des infos du bilan précédent
|
||||
$ret = $this->iDb->select('jo.bilans',
|
||||
|
@ -198,6 +198,27 @@ class Metier_Partenaires_MCadastre
|
||||
return $lib;
|
||||
}
|
||||
|
||||
/**
|
||||
* Nature des locaux ou parcelles
|
||||
* @param string $code
|
||||
* @param string $type
|
||||
* @return string
|
||||
*/
|
||||
public function getNatureLabel($code, $type = 'local')
|
||||
{
|
||||
if ($type == 'local') {
|
||||
if (array_key_exists($code, self::$PEV)) {
|
||||
return self::$PEV[$code];
|
||||
}
|
||||
} elseif ($type == 'parcelle') {
|
||||
if (array_key_exists($code, self::$natureParcelles)) {
|
||||
return self::$natureParcelles[$code];
|
||||
}
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Locaux : Propriétés baties
|
||||
* @param string $siren
|
||||
@ -234,7 +255,7 @@ class Metier_Partenaires_MCadastre
|
||||
'pmAdrDep' => trim($loc['CCODEP']),
|
||||
'pmAdrCom' => trim($loc['companyCCOCOM']),
|
||||
'localDroit' => trim($loc['CCODRO']),
|
||||
'localDroitLib' => self::$tabCodeDroit[trim($loc['CCODRO'])],
|
||||
'localDroitLib' => self::$codeDroit[trim($loc['CCODRO'])],
|
||||
'localDep' => trim($loc['CCODEP']),
|
||||
'localCom' => trim($loc['CCOCOM']),
|
||||
'localComLib' => trim($loc['DLICOM']),
|
||||
@ -346,4 +367,110 @@ class Metier_Partenaires_MCadastre
|
||||
|
||||
return $parcelles;
|
||||
}
|
||||
|
||||
/**
|
||||
* List des éléments du patrimoine
|
||||
* @return array
|
||||
*/
|
||||
public function patrimoine()
|
||||
{
|
||||
$locauxSql = "SELECT 'local' AS type, " .
|
||||
"l.CCODRO AS role, " .
|
||||
"l.DNUVOI AS adresseNum, " .
|
||||
"l.DLTNUV AS adresseInd, " .
|
||||
"l.CNAVOI AS adresseType, " .
|
||||
"l.DLIVOI AS adresseLib, " .
|
||||
"l.CCODEP AS departement, " .
|
||||
"l.CCOCOM AS communeCode, " .
|
||||
"l.DLICOM AS communeLib, " .
|
||||
"l.CCOSEC AS section, " .
|
||||
"l.DNUPLA AS planNum, " .
|
||||
"l.CCORIV AS fantoir, " .
|
||||
"l.DNUBAT AS batiment, " .
|
||||
"l.DESC AS ent, " .
|
||||
"l.DNIV AS niveau, " .
|
||||
"(l.DSUPOD0 + l.DSUPOD1 + l.DSUPOD2 + l.DSUPOD3 + l.DSUPOD4 + l.DSUPOD5 + l.DSUPOD7 + l.DSUPOD8 + l.DSUPOD9) AS surfaceTotal, " .
|
||||
"l.CCOAFF0 AS nature0, " .
|
||||
"l.DSUPOD0 AS surface0, " .
|
||||
"l.CCOAFF1 AS nature1, " .
|
||||
"l.DSUPOD1 AS surface1, " .
|
||||
"l.CCOAFF2 AS nature2, " .
|
||||
"l.DSUPOD2 AS surface2, " .
|
||||
"l.CCOAFF3 AS nature3, " .
|
||||
"l.DSUPOD3 AS surface3, " .
|
||||
"l.CCOAFF4 AS nature4, " .
|
||||
"l.DSUPOD4 AS surface4, " .
|
||||
"l.CCOAFF5 AS nature5, " .
|
||||
"l.DSUPOD5 AS surface5, " .
|
||||
"l.CCOAFF6 AS nature6, " .
|
||||
"l.DSUPOD6 AS surface6, " .
|
||||
"l.CCOAFF7 AS nature7, " .
|
||||
"l.DSUPOD7 AS surface7, " .
|
||||
"l.CCOAFF8 AS nature8, " .
|
||||
"l.DSUPOD8 AS surface8, " .
|
||||
"l.CCOAFF9 AS nature9, " .
|
||||
"l.DSUPOD9 AS surface9, " .
|
||||
"l.dateInsert " .
|
||||
"FROM sdv1.cad_perloc l, sdv1.cad_permor e " .
|
||||
"WHERE e.DSIREN='$this->siren' AND e.INTCIF=l.INTCIF AND e.DNUPER=l.DNUPER";
|
||||
|
||||
$parcellesSql = "SELECT 'parcelle' AS type, " .
|
||||
"p.CCODRO AS role, " .
|
||||
"p.DNUVOI AS adresseNum, " .
|
||||
"p.DLTNUV AS adresseInd, " .
|
||||
"p.CNAVOI AS adresseType, " .
|
||||
"p.DLIVOI AS adresseLib ," .
|
||||
"p.CCODEP AS departement, " .
|
||||
"p.CCOCOM AS communeCode, " .
|
||||
"p.DLICOM AS communeLib, " .
|
||||
"p.CCOSEC AS section, " .
|
||||
"p.DNUPLA AS planNum, " .
|
||||
"p.CCORIV AS fantoir, " .
|
||||
"'' AS batiment, " .
|
||||
"'' AS ent, " .
|
||||
"'' AS niveau, " .
|
||||
"p.DCNPAR AS surfaceTotal, " .
|
||||
"p.DSGRPF0 AS nature0, " .
|
||||
"p.DCNSUF0 AS surface0, " .
|
||||
"p.DSGRPF1 AS nature1, " .
|
||||
"p.DCNSUF1 AS surface1, " .
|
||||
"p.DSGRPF2 AS nature2, " .
|
||||
"p.DCNSUF2 AS surface2, " .
|
||||
"p.DSGRPF3 AS nature3, " .
|
||||
"p.DCNSUF3 AS surface3, " .
|
||||
"p.DSGRPF4 AS nature4, " .
|
||||
"p.DCNSUF4 AS surface4, " .
|
||||
"p.DSGRPF5 AS nature5, " .
|
||||
"p.DCNSUF5 AS surface5, " .
|
||||
"p.DSGRPF6 AS nature6, " .
|
||||
"p.DCNSUF6 AS surface6, " .
|
||||
"p.DSGRPF7 AS nature7, " .
|
||||
"p.DCNSUF7 AS surface7, " .
|
||||
"p.DSGRPF8 AS nature8, " .
|
||||
"p.DCNSUF8 AS surface8, " .
|
||||
"p.DSGRPF9 AS nature9, " .
|
||||
"p.DCNSUF9 AS surface9, " .
|
||||
"p.dateInsert " .
|
||||
"FROM sdv1.cad_perpar p, sdv1.cad_permor e " .
|
||||
"WHERE e.DSIREN='$this->siren' AND e.INTCIF=p.INTCIF AND e.DNUPER=p.DNUPER";
|
||||
|
||||
$sql = "SELECT * FROM ( ($locauxSql) UNION ALL ($parcellesSql) ) results";
|
||||
|
||||
$db = Zend_Db_Table::getDefaultAdapter();
|
||||
|
||||
//$results = $this->iDb->query($sql, true);
|
||||
$results = $db->fetchAll($sql, null, Zend_Db::FETCH_ASSOC);
|
||||
|
||||
$list = array();
|
||||
if (count($results) > 0) {
|
||||
foreach ($results as $result) {
|
||||
// Libellé role
|
||||
$result['roleLib'] = self::$codeDroit[trim($result['role'])];
|
||||
$list[] = $result;
|
||||
}
|
||||
}
|
||||
|
||||
return $list;
|
||||
}
|
||||
|
||||
}
|
@ -186,82 +186,90 @@ class Metier_Partenaires_MTva
|
||||
}
|
||||
|
||||
|
||||
/** Test de la validité du siren demandé
|
||||
** @param int SIREN à tester
|
||||
** @param int NIC (facultatif)
|
||||
** @param mixed Message textuel d'erreur à afficher en cas d'erreur ou false
|
||||
** @return mixed true, false ou Message d'erreur passé en paramètre
|
||||
**/
|
||||
private function valideSiren($siren, $nic='', $erreur=false) {
|
||||
|
||||
/** Si le siren est de taille < à 9, on ajoute des 0 significatifs **/
|
||||
switch (strlen($siren)) {
|
||||
case 1: $siren='00000000'.$siren; break;
|
||||
case 2: $siren='0000000'.$siren; break;
|
||||
case 3: $siren='000000'.$siren; break;
|
||||
case 4: $siren='00000'.$siren; break;
|
||||
case 5: $siren='0000'.$siren; break;
|
||||
case 6: $siren='000'.$siren; break;
|
||||
case 7: $siren='00'.$siren; break;
|
||||
case 8: $siren='0'.$siren; break;
|
||||
}
|
||||
|
||||
if (strlen($nic)>0) {
|
||||
switch (strlen($nic)) {
|
||||
case 1: $nic='0000'.$nic; break;
|
||||
case 2: $nic='000'.$nic; break;
|
||||
case 3: $nic='00'.$nic; break;
|
||||
case 4: $nic='0'.$nic; break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!Metier_Util_String::valideData($siren, 9, 9,'N')) //Siren non précisé ou incorrect.
|
||||
return $erreur;
|
||||
elseif ($siren*1==0) // Siren vide
|
||||
return $erreur;
|
||||
else
|
||||
{
|
||||
if (!isset($nic) || trim($nic)=='')
|
||||
/**
|
||||
* Test de la validité du siren demandé
|
||||
* @param int SIREN à tester
|
||||
* @param int NIC (facultatif)
|
||||
* @param mixed Message textuel d'erreur à afficher en cas d'erreur ou false
|
||||
* @return mixed true, false ou Message d'erreur passé en paramètre
|
||||
*/
|
||||
private function valideSiren($siren, $nic='', $erreur=false)
|
||||
{
|
||||
$siren = str_pad($siren, 9, '0', STR_PAD_LEFT);
|
||||
if (!empty($nic)) {
|
||||
$nic = str_pad($nic, 5, '0', STR_PAD_LEFT);
|
||||
}
|
||||
//Siren non précisé ou incorrect.
|
||||
if (!Metier_Util_String::valideData($siren, 9, 9,'N')) {
|
||||
return $erreur;
|
||||
}
|
||||
// Siren vide
|
||||
elseif (intval($siren) == 0) {
|
||||
return $erreur;
|
||||
}
|
||||
else {
|
||||
if (!isset($nic) || trim($nic)=='') {
|
||||
$somme = 0;
|
||||
// Traitement IMPAIR
|
||||
for ($i=0; $i<=8; $i+=2) {
|
||||
$somme+= (integer) substr($siren,$i,1);
|
||||
}
|
||||
// Traitement PAIR
|
||||
for ($i=1; $i<=7; $i+=2) {
|
||||
$var_tmp = (string) (2*((integer)substr($siren,$i,1)));
|
||||
$som_tmp = 0;
|
||||
for($j=0; $j<strlen($var_tmp);$j++) {
|
||||
$som_tmp+= (integer)substr($var_tmp,$j,1);
|
||||
}
|
||||
$somme+= $som_tmp;
|
||||
}
|
||||
|
||||
// Le Siren est faux
|
||||
if ((integer) ($somme/10) != ($somme/10)) {
|
||||
// Les siren débutant par 200 sont toujours valides (sirens provisoires de la BDF?!)
|
||||
if (substr($siren,0,3) != '200') {
|
||||
return $erreur;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
// Nic de format incorrect.
|
||||
if (!Metier_Util_String::valideData($nic,1,5,'N')) {
|
||||
return $erreur;
|
||||
}
|
||||
$SIRET = $siren.$nic;
|
||||
if ($siren != 356000000) {
|
||||
$somme=0;
|
||||
for ($i=0; $i<=8; $i+=2) // Traitement IMPAIR
|
||||
$somme+=(integer)substr($siren,$i,1);
|
||||
|
||||
for ($i=1; $i<=7; $i+=2)
|
||||
{ // Traitement PAIR
|
||||
$var_tmp=(string)(2*((integer)substr($siren,$i,1)));
|
||||
$som_tmp=0;
|
||||
for($j=0;$j<strlen($var_tmp);$j++)
|
||||
$som_tmp+=(integer)substr($var_tmp,$j,1);
|
||||
$somme+=$som_tmp;
|
||||
// Traitement PAIR
|
||||
for ($i=0; $i<=12; $i+=2) {
|
||||
$var_tmp = (string) (2*((integer)substr($SIRET,$i,1)));
|
||||
$som_tmp = 0;
|
||||
for($j=0; $j<strlen($var_tmp); $j++) {
|
||||
$som_tmp+= (integer) substr($var_tmp,$j,1);
|
||||
}
|
||||
|
||||
if ((integer)($somme/10)!=($somme/10))
|
||||
{ // Le Siren est faux
|
||||
if (substr($siren,0,3)!='200') // Les siren débutant par 200 sont toujours valides (sirens provisoires de la BDF?!)
|
||||
$somme+= $som_tmp;
|
||||
}
|
||||
// Traitement IMPAIR
|
||||
for ($i=1; $i<=13; $i+=2) {
|
||||
$somme+= (integer) substr($SIRET,$i,1);
|
||||
}
|
||||
// Le Siret est faux
|
||||
if ((integer) ($somme/10) != ($somme/10)) {
|
||||
return $erreur;
|
||||
}
|
||||
} else {
|
||||
if (!Metier_Util_String::valideData($nic,1,5,'N')) // Nic de format incorrect.
|
||||
return $erreur;
|
||||
|
||||
$SIRET=$siren.$nic;
|
||||
$somme=0;
|
||||
for ($i=0; $i<=12; $i+=2)
|
||||
{ // Traitement PAIR
|
||||
$var_tmp=(string)(2*((integer)substr($SIRET,$i,1)));
|
||||
$som_tmp=0;
|
||||
for($j=0;$j<strlen($var_tmp);$j++)
|
||||
$som_tmp+=(integer)substr($var_tmp,$j,1);
|
||||
$somme+=$som_tmp;
|
||||
// Cas particulier du siren de LA POSTE : 356 000 000 00000
|
||||
$somme = 14;
|
||||
for ($i=9; $i<=13; $i++) {
|
||||
$somme+= (integer)substr($SIRET,$i,1);
|
||||
}
|
||||
for ($i=1; $i<=13; $i+=2) // Traitement IMPAIR
|
||||
$somme+=(integer)substr($SIRET,$i,1);
|
||||
|
||||
if ((integer)($somme/10)!=($somme/10))// Le Siret est faux
|
||||
// Le NIC de l'établissement de LA POSTE est faux !
|
||||
if ($somme%5 != 0) {
|
||||
return $erreur;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
@ -3913,16 +3913,10 @@ function calculIndiScore($siren, $nic=0, $accesDist=false, $cycleClient=2, $mail
|
||||
$EffectifEn = $tabIdentite['Effectif'];
|
||||
$bilanAgeMax = 3 * 12; //Age maximum du dernier bilan en mois
|
||||
if (!empty($tabIdentite['bilanDate']) && intval($tabIdentite['bilanYP'])>0 ) {
|
||||
|
||||
Zend_Date::setOptions(array('extend_month' => true));
|
||||
$dateBilan = new Zend_Date($tabIdentite['bilanDate'], 'yyyyMMdd');
|
||||
$dateNow = new Zend_Date();
|
||||
$difference = $dateNow->sub($dateBilan);
|
||||
$measure = new Zend_Measure_Time($difference->toValue(), Zend_Measure_Time::SECOND);
|
||||
$measure->convertTo(Zend_Measure_Time::MONTH);
|
||||
$nbMonth = $measure->getValue();
|
||||
|
||||
if ( $nbMonth < $bilanAgeMax ) {
|
||||
$dateBilan = DateTime::createFromFormat('Ymd', $tabIdentite['bilanDate']);
|
||||
$dateCompare = new DateTime();
|
||||
$dateCompare->sub(new DateInterval('P'.$bilanAgeMax.'M'));
|
||||
if ($dateBilan > $dateCompare) {
|
||||
$EffectifEn = $tabIdentite['bilanYP'];
|
||||
}
|
||||
}
|
||||
|
@ -3891,16 +3891,10 @@ class SdMetier_Scoring_Base extends SdMetier_Scoring_Vars
|
||||
$EffectifEn = $tabIdentite['Effectif'];
|
||||
$bilanAgeMax = 3 * 12; //Age maximum du dernier bilan en mois
|
||||
if (!empty($tabIdentite['bilanDate']) && intval($tabIdentite['bilanYP'])>0 ) {
|
||||
|
||||
Zend_Date::setOptions(array('extend_month' => true));
|
||||
$dateBilan = new Zend_Date($tabIdentite['bilanDate'], 'yyyyMMdd');
|
||||
$dateNow = new Zend_Date();
|
||||
$difference = $dateNow->sub($dateBilan);
|
||||
$measure = new Zend_Measure_Time($difference->toValue(), Zend_Measure_Time::SECOND);
|
||||
$measure->convertTo(Zend_Measure_Time::MONTH);
|
||||
$nbMonth = $measure->getValue();
|
||||
|
||||
if ( $nbMonth < $bilanAgeMax ) {
|
||||
$dateBilan = DateTime::createFromFormat('Ymd', $tabIdentite['bilanDate']);
|
||||
$dateCompare = new DateTime();
|
||||
$dateCompare->sub(new DateInterval('P'.$bilanAgeMax.'M'));
|
||||
if ($dateBilan > $dateCompare) {
|
||||
$EffectifEn = $tabIdentite['bilanYP'];
|
||||
}
|
||||
}
|
||||
|
@ -430,18 +430,14 @@ class SdMetier_Sfr_Scoring
|
||||
|
||||
public function evaluate($siren)
|
||||
{
|
||||
Zend_Date::setOptions(array('extend_month' => true));
|
||||
|
||||
if ($this->debug) file_put_contents('sfr.log', "SIREN = $siren\n", FILE_APPEND);
|
||||
|
||||
//Set ValContratAge
|
||||
if ( !empty($this->ValContratDate) ) {
|
||||
$dateContrat = new Zend_Date($this->ValContratDate, 'yyyyMMdd');
|
||||
$dateNow = new Zend_Date();
|
||||
$diff = $dateNow->sub($dateContrat);
|
||||
$measure = new Zend_Measure_Time($diff->toValue(), Zend_Measure_Time::SECOND);
|
||||
$measure->convertTo(Zend_Measure_Time::MONTH);
|
||||
$this->ValContratAge = $measure->getValue();
|
||||
$dateContrat = DateTime::createFromFormat('Ymd', $this->ValContratDate);
|
||||
$dateNow = new DateTime();
|
||||
$interval = $dateNow->diff($dateContrat);
|
||||
$this->ValContratAge = $interval->format('%y') * 12 + $interval->format('%m');
|
||||
}
|
||||
|
||||
$classInsee = new Metier_Insee_MInsee();
|
||||
@ -467,16 +463,14 @@ class SdMetier_Sfr_Scoring
|
||||
if ( $result !== null ) {
|
||||
|
||||
//Indiscore - aller chercher scores dans l'historique moins de X mois
|
||||
$dateUpdate = new Zend_Date(substr($result->dateUpdate,0,10), 'yyyy-MM-dd');
|
||||
$dateUpdate = DateTime::createFromFormat('Y-m-d', substr($result->dateUpdate,0,10));
|
||||
$dateNow = new DateTime();
|
||||
$interval = $dateNow->diff($dateUpdate);
|
||||
$diff = $interval->format('%y') * 12 + $interval->format('%m');
|
||||
|
||||
$dateNow = new Zend_Date();
|
||||
$diffUpdate = $dateNow->sub($dateUpdate);
|
||||
$measureUpdate = new Zend_Measure_Time($diffUpdate->toValue(), Zend_Measure_Time::SECOND);
|
||||
$measureUpdate->convertTo(Zend_Measure_Time::MONTH);
|
||||
if ($this->debug) file_put_contents('sfr.log', "INDISCORE DIFF = " . $diff . "\n", FILE_APPEND);
|
||||
|
||||
if ($this->debug) file_put_contents('sfr.log', "INDISCORE DIFF = " . $measureUpdate->getValue() . "\n", FILE_APPEND);
|
||||
|
||||
if ( $measureUpdate->getValue() <= 12 ) {
|
||||
if ( $diff <= 12 ) {
|
||||
$this->ValIndiscore = $result->indiScore20;
|
||||
$this->ValDateCalculIndiscore = $result->indiScoreDate;
|
||||
}
|
||||
@ -488,21 +482,17 @@ class SdMetier_Sfr_Scoring
|
||||
|
||||
if ( !empty($result->dateCrea) && $result->dateCrea!='0000-00-00 00:00:00' ) {
|
||||
|
||||
$dateC = new Zend_Date($result->dateCrea, 'yyyy-MM-dd');
|
||||
$dateNow = new Zend_Date();
|
||||
$difference = $dateNow->sub($dateC);
|
||||
$measure = new Zend_Measure_Time($difference->toValue(), Zend_Measure_Time::SECOND);
|
||||
$measure->convertTo(Zend_Measure_Time::MONTH);
|
||||
$this->ValInseeAge = $measure->getValue();
|
||||
$dateC = DateTime::createFromFormat('Y-m-d', $result->dateCrea);
|
||||
$dateNow = new DateTime();
|
||||
$interval = $dateNow->diff($dateC);
|
||||
$this->ValInseeAge = $interval->format('%y') * 12 + $interval->format('%m');
|
||||
|
||||
} elseif ( !empty($result->dateImmat) && $result->dateImmat!='0000-00-00 00:00:00' ) {
|
||||
|
||||
$dateC = new Zend_Date($result->dateImmat, 'yyyy-MM-dd');
|
||||
$dateNow = new Zend_Date();
|
||||
$difference = $dateNow->sub($dateC);
|
||||
$measure = new Zend_Measure_Time($difference->toValue(), Zend_Measure_Time::SECOND);
|
||||
$measure->convertTo(Zend_Measure_Time::MONTH);
|
||||
$this->ValInseeAge = $measure->getValue();
|
||||
$dateC = DateTime::createFromFormat('Y-m-d', $result->dateImmat);
|
||||
$dateNow = new DateTime();
|
||||
$interval = $dateNow->diff($dateC);
|
||||
$this->ValInseeAge = $interval->format('%y') * 12 + $interval->format('%m');
|
||||
|
||||
}
|
||||
|
||||
@ -536,17 +526,14 @@ class SdMetier_Sfr_Scoring
|
||||
$bilanAgeMax = 3*12; //Age maximum du dernier bilan en mois
|
||||
if (!empty($identite['bilanDate']) && intval($identite['bilanYP'])>0 ) {
|
||||
|
||||
$dateBilan = new Zend_Date($identite['bilanDate'], 'yyyyMMdd');
|
||||
$dateNow = new Zend_Date();
|
||||
$difference = $dateNow->sub($dateBilan);
|
||||
$measure = new Zend_Measure_Time($difference->toValue(), Zend_Measure_Time::SECOND);
|
||||
$measure->convertTo(Zend_Measure_Time::MONTH);
|
||||
$nbMonth = $measure->getValue();
|
||||
|
||||
if ( $nbMonth < $bilanAgeMax ) {
|
||||
$dateBilan = DateTime::createFromFormat('Ymd', $identite['bilanDate']);
|
||||
$dateCompare = new DateTime();
|
||||
$dateCompare->sub(new DateInterval('P'.$bilanAgeMax.'M'));
|
||||
if ($dateBilan > $dateCompare) {
|
||||
$this->ValEffectif = $identite['bilanYP'];
|
||||
}
|
||||
if ($this->debug) file_put_contents('sfr.log', "Bilan : nbMonth = ".$nbMonth."\n", FILE_APPEND);
|
||||
|
||||
if ($this->debug) file_put_contents('sfr.log', "Bilan : ".$dateBilan->format('Ymd')." > ".$dateCompare->format('Ymd')."\n", FILE_APPEND);
|
||||
}
|
||||
if ($this->debug) file_put_contents('sfr.log', "ValEffectif = ".$this->ValEffectif."\n", FILE_APPEND);
|
||||
|
||||
@ -556,27 +543,22 @@ class SdMetier_Sfr_Scoring
|
||||
//Age de l'entreprise en mois
|
||||
if ( !empty($identite['DateCreaEn']) && $identite['DateCreaEn']!='0000-00-00 00:00:00' ) {
|
||||
|
||||
$dateC = new Zend_Date($identite['DateCreaEn'], 'yyyy-MM-dd');
|
||||
$dateNow = new Zend_Date();
|
||||
$difference = $dateNow->sub($dateC);
|
||||
$measure = new Zend_Measure_Time($difference->toValue(), Zend_Measure_Time::SECOND);
|
||||
$measure->convertTo(Zend_Measure_Time::MONTH);
|
||||
$this->ValInseeAge = $measure->getValue();
|
||||
$dateC = DateTime::createFromFormat('Y-m-d', $identite['DateCreaEn']);
|
||||
$dateNow = new DateTime();
|
||||
$interval = $dateNow->diff($dateC);
|
||||
$this->ValInseeAge = $interval->format('%y') * 12 + $interval->format('%m');
|
||||
|
||||
} elseif ( !empty($identite['dateImmat']) && $identite['dateImmat']!='0000-00-00 00:00:00' ) {
|
||||
|
||||
$dateC = new Zend_Date($identite['dateImmat'], 'yyyy-MM-dd');
|
||||
$dateNow = new Zend_Date();
|
||||
$difference = $dateNow->sub($dateC);
|
||||
$measure = new Zend_Measure_Time($difference->toValue(), Zend_Measure_Time::SECOND);
|
||||
$measure->convertTo(Zend_Measure_Time::MONTH);
|
||||
$this->ValInseeAge = $measure->getValue();
|
||||
$dateC = DateTime::createFromFormat('Y-m-d', $identite['dateImmat']);
|
||||
$dateNow = new DateTime();
|
||||
$interval = $dateNow->diff($dateC);
|
||||
$this->ValInseeAge = $interval->format('%y') * 12 + $interval->format('%m');
|
||||
|
||||
}
|
||||
if ($this->debug) file_put_contents('sfr.log', "ValInseeAge = ".$this->ValInseeAge."\n", FILE_APPEND);
|
||||
|
||||
$this->ValSituationJuridique = $identite['SituationJuridique'];
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@ -587,35 +569,30 @@ class SdMetier_Sfr_Scoring
|
||||
//Age de l'entreprise en mois
|
||||
if ( !empty($this->ValDateCrea) && $this->ValDateCrea!='0000-00-00 00:00:00' ) {
|
||||
|
||||
$dateC = new Zend_Date($this->ValDateCrea, 'yyyy-MM-dd');
|
||||
$dateNow = new Zend_Date();
|
||||
$difference = $dateNow->sub($dateC);
|
||||
$measure = new Zend_Measure_Time($difference->toValue(), Zend_Measure_Time::SECOND);
|
||||
$measure->convertTo(Zend_Measure_Time::MONTH);
|
||||
$this->ValInseeAge = $measure->getValue();
|
||||
$dateC = DateTime::createFromFormat('Y-m-d', $this->ValDateCrea);
|
||||
$dateNow = new DateTime();
|
||||
$interval = $dateNow->diff($dateC);
|
||||
$this->ValInseeAge = $interval->format('%y') * 12 + $interval->format('%m');
|
||||
|
||||
} elseif ( !empty($this->ValDateImmat) && $this->ValDateImmat!='0000-00-00 00:00:00' ) {
|
||||
|
||||
$dateC = new Zend_Date($this->ValDateImmat, 'yyyy-MM-dd');
|
||||
$dateNow = new Zend_Date();
|
||||
$difference = $dateNow->sub($dateC);
|
||||
$measure = new Zend_Measure_Time($difference->toValue(), Zend_Measure_Time::SECOND);
|
||||
$measure->convertTo(Zend_Measure_Time::MONTH);
|
||||
$this->ValInseeAge = $measure->getValue();
|
||||
$dateC = DateTime::createFromFormat('Y-m-d', $this->ValDateImmat);
|
||||
$dateNow = new DateTime();
|
||||
$interval = $dateNow->diff($dateC);
|
||||
$this->ValInseeAge = $interval->format('%y') * 12 + $interval->format('%m');
|
||||
|
||||
}
|
||||
if ($this->debug) file_put_contents('sfr.log', "ValInseeAge = ".$this->ValInseeAge."\n", FILE_APPEND);
|
||||
|
||||
//Vérification validité du score
|
||||
$dateNow = new Zend_Date();
|
||||
$dateUpdate = new Zend_Date(substr($this->ValDateUpdate,0,10), 'yyyy-MM-dd');
|
||||
$diffUpdate = $dateNow->sub($dateUpdate);
|
||||
$measureUpdate = new Zend_Measure_Time($diffUpdate->toValue(), Zend_Measure_Time::SECOND);
|
||||
$measureUpdate->convertTo(Zend_Measure_Time::MONTH);
|
||||
$dateUpdate = DateTime::createFromFormat('Y-m-d', substr($this->ValDateUpdate,0,10));
|
||||
$dateNow = new DateTime();
|
||||
$interval = $dateNow->diff($dateUpdate);
|
||||
$diff = $interval->format('%y') * 12 + $interval->format('%m');
|
||||
|
||||
if ($this->debug) file_put_contents('sfr.log', "INDISCORE DIFF = " . $measureUpdate->getValue() . "\n", FILE_APPEND);
|
||||
if ($this->debug) file_put_contents('sfr.log', "INDISCORE DIFF = " . $diff . "\n", FILE_APPEND);
|
||||
|
||||
if ( $measureUpdate->getValue() > 12 ) {
|
||||
if ( $diff > 12 ) {
|
||||
$this->ValIndiscore = null;
|
||||
$this->ValDateCalculIndiscore = null;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user