From 45434cdd188f1b020954073ae4841ade82613f04 Mon Sep 17 00:00:00 2001 From: benoitpotier Date: Tue, 14 Mar 2017 15:55:11 +0100 Subject: [PATCH 01/14] =?UTF-8?q?ne=20remonte=20pas=20les=20bilans=20confi?= =?UTF-8?q?dentiels=20au=20client=20consultant=20la=20page=20Elements=20Fi?= =?UTF-8?q?nanciers=20>=20Synth=C3=A8se?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/Metier/Partenaires/MBilans.php | 3 +- library/WsScore/Entreprise/v0.8/Service.php | 1184 +++++++++---------- 2 files changed, 594 insertions(+), 593 deletions(-) diff --git a/library/Metier/Partenaires/MBilans.php b/library/Metier/Partenaires/MBilans.php index 52a14efe..0d8bbb2e 100644 --- a/library/Metier/Partenaires/MBilans.php +++ b/library/Metier/Partenaires/MBilans.php @@ -349,7 +349,7 @@ class Metier_Partenaires_MBilans * Nombre de bilans maximums retournés * @return array */ - public function listeBilans($accesPartenaire = false, $nbMaxBilans = 0) + public function listeBilans($accesPartenaire = false, $nbMaxBilans = 0, $idClient = 0) { $dateDerDepot = 0; $tabRet = $tabRet2 = $tabRet3 = $tabRet = array(); @@ -358,6 +358,7 @@ class Metier_Partenaires_MBilans if ($this->companyEvenDateStop !== null) { $where.= " AND dateExercice<'".$this->companyEvenDateStop."'"; } + $where.= ($idClient > 0) ? " AND (confidentiel = '".$idClient."' OR confidentiel = 0)" : " AND confidentiel = 0"; $where.= " ORDER BY dateExercice DESC, CASE typeBilan WHEN 'N' THEN 1 WHEN 'S' THEN 2 ELSE 3 END"; if ($nbMaxBilans > 0) { $where.= " LIMIT 0, $nbMaxBilans"; diff --git a/library/WsScore/Entreprise/v0.8/Service.php b/library/WsScore/Entreprise/v0.8/Service.php index 892b5b09..5dd5c106 100644 --- a/library/WsScore/Entreprise/v0.8/Service.php +++ b/library/WsScore/Entreprise/v0.8/Service.php @@ -833,14 +833,14 @@ class Entreprise extends Scores_Ws_Server $countryM = new Application_Model_JoTabPays(); $sql = $countryM->select()->from($countryM, array('codPays3', 'libPays')); $result = $countryM->fetchAll($sql); - } catch (Zend_Db_Adapter_Exception $e) { + } catch (Zend_Db_Adapter_Exception $e) { if ($this->User->idClient==1) { throw new SoapFault('ERR', $e->getMessage()); } else { throw new SoapFault('ERR', "Application error"); - } - } catch (Zend_Exception $e) { - throw new SoapFault('ERR', "Application error"); + } + } catch (Zend_Exception $e) { + throw new SoapFault('ERR', "Application error"); } $tabPays = array(); @@ -849,7 +849,7 @@ class Entreprise extends Scores_Ws_Server $tabPays[$item->codPays3] = $item->libPays; } } - + $tabAct = $tabPar = $tabDir = array(); try @@ -925,8 +925,8 @@ class Entreprise extends Scores_Ws_Server //Participations $liens = $liensM->getParticipations(null, true); - if (count($liens)>0) { - foreach ( $liens as $item ) { + if (count($liens)>0) { + foreach ( $liens as $item ) { $detail = new Lien(); $detail->id = $item->id; $detail->idFiche = $item->idPar; @@ -950,10 +950,10 @@ class Entreprise extends Scores_Ws_Server $detail->Pvote = $item->Pvote; $detail->MajMin = $item->MajMin; - if ($item->dateUpdate=='0000-00-00 00:00:00'){ - $detail->date = substr($item->dateInsert,0,10); - } else { - $detail->date = substr($item->dateUpdate,0,10); + if ($item->dateUpdate=='0000-00-00 00:00:00'){ + $detail->date = substr($item->dateInsert,0,10); + } else { + $detail->date = substr($item->dateUpdate,0,10); } $nbIdNum = 3; @@ -984,14 +984,14 @@ class Entreprise extends Scores_Ws_Server } } $detail->identification = $refs; - - $tabPar[] = $detail; - } + + $tabPar[] = $detail; + } } //Directions $liens = $liensM->getDirections(true); - if (count($liens)>0) { + if (count($liens)>0) { foreach ( $liens as $item ) { $detail = new LienDirection(); $detail->siren = $item->siren; @@ -1003,11 +1003,11 @@ class Entreprise extends Scores_Ws_Server if (!empty($item->civilite)) { $nom.= $item->civilite.'. '; } - if (!empty($item->nom)) { - $nom.= $item->nom.' '; + if (!empty($item->nom)) { + $nom.= $item->nom.' '; } - if (!empty($item->prenom)) { - $nom.= $item->prenom; + if (!empty($item->prenom)) { + $nom.= $item->prenom; } $detail->dirNom = $nom; $detail->dirNaissLieu = $item->naissance_lieu; @@ -1017,10 +1017,10 @@ class Entreprise extends Scores_Ws_Server } } } catch(Exception $e) { - if ($this->User->idClient==1) { - throw new SoapFault('ERR', $e->getMessage()); - } else { - throw new SoapFault('ERR', "Application error"); + if ($this->User->idClient==1) { + throw new SoapFault('ERR', $e->getMessage()); + } else { + throw new SoapFault('ERR', "Application error"); } } @@ -1034,17 +1034,17 @@ class Entreprise extends Scores_Ws_Server return $output; } - /** - * Retourne les liens financiers pour une entreprise. - * @param int $id Identifiant de référence de l'entreprise - * @param string $type Type de lien (actionnaire|participation) - * @return LiensReturn - */ - public function getLiensById($id, $type = null) - { + /** + * Retourne les liens financiers pour une entreprise. + * @param int $id Identifiant de référence de l'entreprise + * @param string $type Type de lien (actionnaire|participation) + * @return LiensReturn + */ + public function getLiensById($id, $type = null) + { $this->authenticate(); - $this->permission('liens'); - + $this->permission('liens'); + try { $countryM = new Application_Model_JoTabPays(); $sql = $countryM->select()->from($countryM, array('codPays3', 'libPays')); @@ -1064,48 +1064,48 @@ class Entreprise extends Scores_Ws_Server foreach ( $result as $item ) { $tabPays[$item->codPays3] = $item->libPays; } - } - - $tabAct = $tabPar = $tabDir = array(); - - try - { + } + + $tabAct = $tabPar = $tabDir = array(); + + try + { $liensM = new Metier_Liens_Base(); - $liensM->setId($id); - - //Actionnaires - $liens = $liensM->getActionnaires(null, true); - if (count($liens)>0) { - foreach ( $liens as $item ) { - $detail = new Lien(); - $detail->id = $item->id; - $detail->idFiche = $item->idAct; + $liensM->setId($id); + + //Actionnaires + $liens = $liensM->getActionnaires(null, true); + if (count($liens)>0) { + foreach ( $liens as $item ) { + $detail = new Lien(); + $detail->id = $item->id; + $detail->idFiche = $item->idAct; $detail->nom = $item->RS; - $detail->sigle = $item->sigle; - - $libPays = ''; - if ($item->adresse_pays!='') { - $libPays = array_key_exists($item->adresse_pays, $tabPays) ? - $tabPays[$item->adresse_pays] : $item->adresse_pays; - } else { - $libPays = $tabPays['FRA']; - } - $detail->pays = $libPays; - - if ($item->PpPm=='PP') { - $detail->nom = $item->civilite.' '.$item->nom.' '.$item->prenom; - } - $detail->siren = str_pad($item->siren, 9, "0", STR_PAD_LEFT); - $detail->PDetention = $item->PDetention; - $detail->Pvote = $item->Pvote; - $detail->MajMin = $item->MajMin; - - if ($item->dateUpdate=='0000-00-00 00:00:00'){ - $detail->date = substr($item->dateInsert,0,10); - } else { - $detail->date = substr($item->dateUpdate,0,10); - } - + $detail->sigle = $item->sigle; + + $libPays = ''; + if ($item->adresse_pays!='') { + $libPays = array_key_exists($item->adresse_pays, $tabPays) ? + $tabPays[$item->adresse_pays] : $item->adresse_pays; + } else { + $libPays = $tabPays['FRA']; + } + $detail->pays = $libPays; + + if ($item->PpPm=='PP') { + $detail->nom = $item->civilite.' '.$item->nom.' '.$item->prenom; + } + $detail->siren = str_pad($item->siren, 9, "0", STR_PAD_LEFT); + $detail->PDetention = $item->PDetention; + $detail->Pvote = $item->Pvote; + $detail->MajMin = $item->MajMin; + + if ($item->dateUpdate=='0000-00-00 00:00:00'){ + $detail->date = substr($item->dateInsert,0,10); + } else { + $detail->date = substr($item->dateUpdate,0,10); + } + $nbIdNum = 3; $refs = array(); $idM = new Application_Model_Sdv1TabIdLocal(); @@ -1133,45 +1133,45 @@ class Entreprise extends Scores_Ws_Server $refs[] = $ref; } } - $detail->identification = $refs; - - $tabAct[] = $detail; - } - } - - //Participations - $liens = $liensM->getParticipations(null, true); - if (count($liens)>0) { - foreach ( $liens as $item ) { - $detail = new Lien(); - $detail->id = $item->id; - $detail->idFiche = $item->idPar; + $detail->identification = $refs; + + $tabAct[] = $detail; + } + } + + //Participations + $liens = $liensM->getParticipations(null, true); + if (count($liens)>0) { + foreach ( $liens as $item ) { + $detail = new Lien(); + $detail->id = $item->id; + $detail->idFiche = $item->idPar; $detail->nom = $item->RS; - $detail->sigle = $item->sigle; - - $libPays = ''; - if ($item->adresse_pays!='') { - $libPays = array_key_exists($item->adresse_pays, $tabPays) ? - $tabPays[$item->adresse_pays] : $item->adresse_pays; - } else { - $libPays = $tabPays['FRA']; - } - $detail->pays = $libPays; - - if ($item->PpPm=='PP') { - $detail->nom = $item->civilite.' '.$item->nom.' '.$item->prenom; - } - $detail->siren = str_pad($item->siren, 9, "0", STR_PAD_LEFT); - $detail->PDetention = $item->PDetention; - $detail->Pvote = $item->Pvote; - $detail->MajMin = $item->MajMin; - - if ($item->dateUpdate=='0000-00-00 00:00:00'){ - $detail->date = substr($item->dateInsert,0,10); - } else { - $detail->date = substr($item->dateUpdate,0,10); - } - + $detail->sigle = $item->sigle; + + $libPays = ''; + if ($item->adresse_pays!='') { + $libPays = array_key_exists($item->adresse_pays, $tabPays) ? + $tabPays[$item->adresse_pays] : $item->adresse_pays; + } else { + $libPays = $tabPays['FRA']; + } + $detail->pays = $libPays; + + if ($item->PpPm=='PP') { + $detail->nom = $item->civilite.' '.$item->nom.' '.$item->prenom; + } + $detail->siren = str_pad($item->siren, 9, "0", STR_PAD_LEFT); + $detail->PDetention = $item->PDetention; + $detail->Pvote = $item->Pvote; + $detail->MajMin = $item->MajMin; + + if ($item->dateUpdate=='0000-00-00 00:00:00'){ + $detail->date = substr($item->dateInsert,0,10); + } else { + $detail->date = substr($item->dateUpdate,0,10); + } + $nbIdNum = 3; $refs = array(); $idM = new Application_Model_Sdv1TabIdLocal(); @@ -1192,62 +1192,62 @@ class Entreprise extends Scores_Ws_Server $ref->type = 0; } } else { - $ref->label = 'Identifiant local'; + $ref->label = 'Identifiant local'; $ref->type = 1; } $refs[] = $ref; } } - $detail->identification = $refs; - - $tabPar[] = $detail; - } - } - - //Directions - $liens = $liensM->getDirections(true); - if (count($liens)>0) { - foreach ( $liens as $item ) { - $detail = new LienDirection(); - $detail->siren = $item->siren; - $detail->nom = $item->raisonSociale; - $detail->fonction = $item->fonction_lib; - $detail->dirRS = $item->dirRS; - - $nom = ''; - if (!empty($item->civilite)) { - $nom.= $item->civilite.'. '; - } - if (!empty($item->nom)) { - $nom.= $item->nom.' '; - } - if (!empty($item->prenom)) { - $nom.= $item->prenom; - } - $detail->dirNom = $nom; - $detail->dirNaissLieu = $item->naissance_lieu; - $detail->dirNaissDate = $item->naissance_date; - - $tabDir[] = $detail; - } - } - } catch(Exception $e) { - if ($this->User->idClient==1) { - throw new SoapFault('ERR', $e->getMessage()); - } else { - throw new SoapFault('ERR', "Application error"); - } - } - - $output = new LiensReturn(); - $output->actionnaires = $tabAct; - $output->participations = $tabPar; + $detail->identification = $refs; + + $tabPar[] = $detail; + } + } + + //Directions + $liens = $liensM->getDirections(true); + if (count($liens)>0) { + foreach ( $liens as $item ) { + $detail = new LienDirection(); + $detail->siren = $item->siren; + $detail->nom = $item->raisonSociale; + $detail->fonction = $item->fonction_lib; + $detail->dirRS = $item->dirRS; + + $nom = ''; + if (!empty($item->civilite)) { + $nom.= $item->civilite.'. '; + } + if (!empty($item->nom)) { + $nom.= $item->nom.' '; + } + if (!empty($item->prenom)) { + $nom.= $item->prenom; + } + $detail->dirNom = $nom; + $detail->dirNaissLieu = $item->naissance_lieu; + $detail->dirNaissDate = $item->naissance_date; + + $tabDir[] = $detail; + } + } + } catch(Exception $e) { + if ($this->User->idClient==1) { + throw new SoapFault('ERR', $e->getMessage()); + } else { + throw new SoapFault('ERR', "Application error"); + } + } + + $output = new LiensReturn(); + $output->actionnaires = $tabAct; + $output->participations = $tabPar; $output->directions = $tabDir; $this->wsLog('liens', '', $id); - - return $output; + + return $output; } /** @@ -1261,17 +1261,17 @@ class Entreprise extends Scores_Ws_Server { $this->authenticate(); $this->permission('liens'); - + $refM = new Application_Model_JoLiensRef(); - try { - $rows = $refM->find($id); - } catch (Zend_Db_Exception $e) { - if ($this->User->idClient!=1) { - throw new SoapFault('ERR', "Application error"); - } else { - throw new SoapFault('ERR', $e->getMessage()); - } + try { + $rows = $refM->find($id); + } catch (Zend_Db_Exception $e) { + if ($this->User->idClient!=1) { + throw new SoapFault('ERR', "Application error"); + } else { + throw new SoapFault('ERR', $e->getMessage()); + } } if ($rows->count()==0) { @@ -1309,10 +1309,10 @@ class Entreprise extends Scores_Ws_Server //@todo : Utiliser le libellé du pays $output->adressePays = $result['adresse_pays']; - if ($result['dateUpdate']=='0000-00-00 00:00:00'){ - $output->date = substr($result['dateInsert'],0,10); - } else { - $output->date = substr($result['dateUpdate'],0,10); + if ($result['dateUpdate']=='0000-00-00 00:00:00'){ + $output->date = substr($result['dateInsert'],0,10); + } else { + $output->date = substr($result['dateUpdate'],0,10); } $refs = array(); @@ -1467,263 +1467,263 @@ class Entreprise extends Scores_Ws_Server return $output; } - /** - * Retourne la liste des annonces légales relative à une entreprise - * - * @todo Revoir cette fonction pour la faire marcher avec les associations - * - * @param string $siren Siren de l'entreprise - * @param integer $filtre 1=BODACC, 2=B.A.L.O, 3=JO Association, 4=Boamp - * @param string $idAnn Identifiant de l'annonce - * @param integer $position - * @param integer $nbRep - * @return AnnoncesReturn - */ - protected function getAnnonces($siren, $filtre = 1, $idAnn = '', $position = 0, $nbRep = 100) - { - $this->authenticate(); - $this->permission('annonces'); - - //Initialisation - if (empty($filtre)) { $filtre = 1; } - if (empty($idAnn)) { $idAnn = ''; } - if (empty($position)) { $position = 0; } - if (empty($nbRep)) { $nbRep = 100; } - - //Valeur max - if($nbRep > 200) { $nbRep = 200; } - - $this->logger->info("Annonces demandées pour $siren ($filtre, $idAnn)"); - - $liste = array(); - - if (strlen($siren)!=9) { - $this->logger->warning( "Siren/Siret $siren incorrect"); - $this->sendError('1010'); - } elseif (intval($siren)==0 && $idAnn=='') { - $this->logger->warning( "Siren $siren ou annonce $idAnn inexistant"); - $this->sendError('1010'); - } - - $iInsee = new Metier_Insee_MInsee(); - /* - if ($siren>100 && $filtre==3) $asso=true; - else { - $asso=false; - $tabIdentite=$this->iInsee->getIdentiteLight($siren); - if ($tabIdentite['FJ']>90 && $tabIdentite['FJ']<94 || - $tabIdentite['FJ']>9000 && $tabIdentite['FJ']<9400) $asso=true; - }*/ - - //@todo : Connaitre le nombre d'annonce - - /* - getAnnoncesBoamp => Avis de marché, Avis d'attribution - getAnnoncesAsso => Rien de particulier - getAnnoncesBalo => Rien de particulier - getAnnoncesLegales => Plusieurs requetes SQL suivant la situation - */ - - if ($idAnn=='') { - $anns=$iInsee->getAnnoncesLegales($siren); - $annsB=$iInsee->getAnnoncesBalo($siren); - $annsA=$iInsee->getAnnoncesAsso($siren); - $annsM=$iInsee->getAnnoncesBoamp($siren, $idAnn); - } elseif ($filtre==1) { - $anns=$iInsee->getAnnoncesLegales($siren, $idAnn); - } elseif ($filtre==2) { - $annsB=$iInsee->getAnnoncesBalo($siren, $idAnn); - } elseif ($filtre==3) { - $annsA=$iInsee->getAnnoncesAsso($siren, $idAnn); - } elseif ($filtre==4) { - $annsM=$iInsee->getAnnoncesBoamp($siren, $idAnn); - } - - if (empty($anns) && empty($annsB) && empty($annsA) && empty($annsM)) - { - $this->logger->warning( "Aucune annonce pour le siren $siren (source=$filtre, id=$idAnn)"); - $error->errnum = 102; - $error->errmsg = 'Siren inexistant B '.$siren.' '.$idAnn; - } - else - { - foreach ($anns as $nb=>$ann) - { - $evens = array(); - foreach ($ann['evenements'] as $tabEven) - { - $even = new AnnonceEvenement(); - $even->CodeEven = $tabEven['CodeEven']; - $even->LibEven = $tabEven['LibEven']; - $evens[] = $even; - } - $annonce = new Annonce(); - $annonce->id = $ann['id']; - $annonce->BodaccCode = $ann['BodaccCode']; - $annonce->BodaccNum = $ann['BodaccNum']; - $annonce->NumAnnonce = $ann['NumAnnonce']; - $annonce->DateParution = $ann['DateParution']; //@todo : date - $annonce->Departement = $ann['Departement']; - $annonce->Tribunal = $ann['Tribunal']; - $annonce->TribunalCode = $ann['TribunalCode']; - $annonce->TribunalSiret = $ann['TribunalSiret']; - $annonce->Rubrique = $ann['Rubrique']; - $annonce->typeAnnonce = $ann['typeAnnonce']; - $annonce->texteRectificatif = $ann['texteRectificatif']; - $annonce->texteAnnonce = $ann['texteAnnonce']; - $annonce->libFJ = $ann['libFJ']; - $annonce->codFJ = $ann['codFJ']; - $annonce->capital = $ann['capital']; - $annonce->capitalDev = $ann['capitalDev']; - - $annonce->raisonSociale = $ann['raisonSociale']; - $annonce->nomCommercial = $ann['nomCommercial']; - $annonce->sigle = $ann['sigle']; - $annonce->adresse = $ann['adresse']; - $annonce->dateEffet = $ann['dateEffet']; //@todo : date - $annonce->dateJugement = $ann['dateJugement']; //@todo : date - $annonce->dateInsertionSD = $ann['dateInsertionSD']; //@todo : date - $annonce->evenements = $evens; - $annonce->Lien_Annonce_Pdf = $ann['Lien_Annonce_Pdf']; - - $liste[] = $annonce; - } - - if (is_array($annsB)) - { - foreach ($annsB as $nb=>$ann) - { - $evens = array(); - foreach ($ann['evenements'] as $tabEven) - { - $even = new AnnonceEvenement(); - $even->CodeEven = $tabEven['CodeEven']; - $even->LibEven = $tabEven['LibEven']; - $evens[] = $even; - } - $annonce = new Annonce(); - $annonce->id = $ann['id']; - $annonce->BodaccCode = $ann['BodaccCode']; - $annonce->BodaccNum = $ann['BodaccNum']; - $annonce->NumAnnonce = $ann['NumAnnonce']; - $annonce->DateParution = $ann['DateParution']; //@todo : date - $annonce->Departement = $ann['Departement']; - $annonce->Tribunal = $ann['Tribunal']; - //$annonce->TribunalCode = $ann['TribunalCode']; - $annonce->TribunalSiret = $ann['TribunalSiret']; - $annonce->Rubrique = $ann['Rubrique']; - $annonce->typeAnnonce = $ann['typeAnnonce']; - $annonce->texteRectificatif = $ann['texteRectificatif']; - $annonce->texteAnnonce = utf8_encode($ann['texteAnnonce']); - //$annonce->libFJ = $ann['libFJ']; - //$annonce->codFJ = $ann['codFJ']; - //$annonce->capital = $ann['capital']; - //$annonce->capitalDev = $ann['capitalDev']; - $annonce->dateEffet = $ann['dateEffet']; //@todo : date - $annonce->dateJugement = $ann['dateJugement']; //@todo : date - $annonce->dateInsertionSD = $ann['dateInsertionSD']; //@todo : date - $annonce->evenements = $evens; - $annonce->Lien_Annonce_Pdf = $ann['Lien_Annonce_Pdf']; - - $liste[] = $annonce; - } - } - - if (is_array($annsA)) - { - foreach ($annsA as $nb=>$ann) - { - $evens = array(); - foreach ($ann['evenements'] as $tabEven) - { - $even = new AnnonceEvenement(); - $even->CodeEven = $tabEven['CodeEven']; - $even->LibEven = $tabEven['LibEven']; - $evens[] = $even; - } - - $annonce = new Annonce(); - $annonce->id = $ann['id']; - $annonce->BodaccCode = $ann['BodaccCode']; - $annonce->BodaccNum = $ann['BodaccNum']; - $annonce->NumAnnonce = $ann['NumAnnonce']; - $annonce->DateParution = $ann['DateParution']; //@todo : date - $annonce->Departement = $ann['Departement']; - $annonce->Tribunal = $ann['Tribunal']; - //$annonce->TribunalCode = $ann['TribunalCode']; - $annonce->TribunalSiret = $ann['TribunalSiret']; - $annonce->Rubrique = $ann['Rubrique']; - $annonce->typeAnnonce = $ann['typeAnnonce']; - $annonce->texteRectificatif = $ann['texteRectificatif']; - $annonce->texteAnnonce = utf8_encode($ann['texteAnnonce']); - //$annonce->libFJ = $ann['libFJ']; - //$annonce->codFJ = $ann['codFJ']; - //$annonce->capital = $ann['capital']; - //$annonce->capitalDev = $ann['capitalDev']; - //@todo : date - $annonce->dateEffet = $ann['dateEffet']; //@todo : date - $annonce->dateJugement = $ann['dateJugement']; //@todo : date - $annonce->dateInsertionSD = $ann['dateInsertionSD']; //@todo : date - $annonce->evenements = $evens; - $annonce->Lien_Annonce_Pdf = $ann['Lien_Annonce_Pdf']; - - $liste[] = $annonce; - } - } - - if (is_array($annsM)) - { - foreach ($annsM as $nb=>$ann) - { - $evens = array(); - foreach ($ann['evenements'] as $tabEven) - { - $even = new AnnonceEvenement(); - $even->CodeEven = $tabEven['CodeEven']; - $even->LibEven = $tabEven['LibEven']; - $evens[] = $even; - } - - $annonce = new Annonce(); - $annonce->id = $ann['id']; - $annonce->BodaccCode = $ann['BodaccCode']; - $annonce->BodaccNum = $ann['BodaccNum']; - $annonce->NumAnnonce = $ann['NumAnnonce']; - $annonce->DateParution = $ann['DateParution']; //@todo : date - $annonce->Departement = $ann['Departement']; - $annonce->Tribunal = $ann['Tribunal']; - //$annonce->TribunalCode = $ann['TribunalCode']; - $annonce->TribunalSiret = $ann['TribunalSiret']; - $annonce->Rubrique = $ann['Rubrique']; - $annonce->typeAnnonce = $ann['typeAnnonce']; - $annonce->texteRectificatif = $ann['texteRectificatif']; - $annonce->texteAnnonce = utf8_encode($ann['texteAnnonce']); - //$annonce->libFJ = $ann['libFJ']; - //$annonce->codFJ = $ann['codFJ']; - //$annonce->capital = $ann['capital']; - //$annonce->capitalDev = $ann['capitalDev']; - $annonce->dateEffet = $ann['dateEffet']; //@todo : date - $annonce->dateJugement = $ann['dateJugement']; //@todo : date - $annonce->dateInsertionSD = $ann['dateInsertionSD']; //@todo : date - $annonce->evenements = $evens; - $annonce->Lien_Annonce_Pdf = $ann['Lien_Annonce_Pdf']; - - $liste[] = $annonce; - } - } - } - - $nbReponses = count($liste); - if ($nbReponses>0){ - //$liste = array_slice($liste, $position, $nbRep); - } - $this->logger->info( "Nb Annonces $filtre retournées pour $siren (source=$filtre, id=$idAnn) = ". count($liste)); - $this->wsLog('annonces',$siren,$filtre.'/'.$idAnn); - - $output = new AnnoncesReturn(); - $output->nbReponses = $nbReponses; - $output->result = $liste; - return $output; + /** + * Retourne la liste des annonces légales relative à une entreprise + * + * @todo Revoir cette fonction pour la faire marcher avec les associations + * + * @param string $siren Siren de l'entreprise + * @param integer $filtre 1=BODACC, 2=B.A.L.O, 3=JO Association, 4=Boamp + * @param string $idAnn Identifiant de l'annonce + * @param integer $position + * @param integer $nbRep + * @return AnnoncesReturn + */ + protected function getAnnonces($siren, $filtre = 1, $idAnn = '', $position = 0, $nbRep = 100) + { + $this->authenticate(); + $this->permission('annonces'); + + //Initialisation + if (empty($filtre)) { $filtre = 1; } + if (empty($idAnn)) { $idAnn = ''; } + if (empty($position)) { $position = 0; } + if (empty($nbRep)) { $nbRep = 100; } + + //Valeur max + if($nbRep > 200) { $nbRep = 200; } + + $this->logger->info("Annonces demandées pour $siren ($filtre, $idAnn)"); + + $liste = array(); + + if (strlen($siren)!=9) { + $this->logger->warning( "Siren/Siret $siren incorrect"); + $this->sendError('1010'); + } elseif (intval($siren)==0 && $idAnn=='') { + $this->logger->warning( "Siren $siren ou annonce $idAnn inexistant"); + $this->sendError('1010'); + } + + $iInsee = new Metier_Insee_MInsee(); + /* + if ($siren>100 && $filtre==3) $asso=true; + else { + $asso=false; + $tabIdentite=$this->iInsee->getIdentiteLight($siren); + if ($tabIdentite['FJ']>90 && $tabIdentite['FJ']<94 || + $tabIdentite['FJ']>9000 && $tabIdentite['FJ']<9400) $asso=true; + }*/ + + //@todo : Connaitre le nombre d'annonce + + /* + getAnnoncesBoamp => Avis de marché, Avis d'attribution + getAnnoncesAsso => Rien de particulier + getAnnoncesBalo => Rien de particulier + getAnnoncesLegales => Plusieurs requetes SQL suivant la situation + */ + + if ($idAnn=='') { + $anns=$iInsee->getAnnoncesLegales($siren); + $annsB=$iInsee->getAnnoncesBalo($siren); + $annsA=$iInsee->getAnnoncesAsso($siren); + $annsM=$iInsee->getAnnoncesBoamp($siren, $idAnn); + } elseif ($filtre==1) { + $anns=$iInsee->getAnnoncesLegales($siren, $idAnn); + } elseif ($filtre==2) { + $annsB=$iInsee->getAnnoncesBalo($siren, $idAnn); + } elseif ($filtre==3) { + $annsA=$iInsee->getAnnoncesAsso($siren, $idAnn); + } elseif ($filtre==4) { + $annsM=$iInsee->getAnnoncesBoamp($siren, $idAnn); + } + + if (empty($anns) && empty($annsB) && empty($annsA) && empty($annsM)) + { + $this->logger->warning( "Aucune annonce pour le siren $siren (source=$filtre, id=$idAnn)"); + $error->errnum = 102; + $error->errmsg = 'Siren inexistant B '.$siren.' '.$idAnn; + } + else + { + foreach ($anns as $nb=>$ann) + { + $evens = array(); + foreach ($ann['evenements'] as $tabEven) + { + $even = new AnnonceEvenement(); + $even->CodeEven = $tabEven['CodeEven']; + $even->LibEven = $tabEven['LibEven']; + $evens[] = $even; + } + $annonce = new Annonce(); + $annonce->id = $ann['id']; + $annonce->BodaccCode = $ann['BodaccCode']; + $annonce->BodaccNum = $ann['BodaccNum']; + $annonce->NumAnnonce = $ann['NumAnnonce']; + $annonce->DateParution = $ann['DateParution']; //@todo : date + $annonce->Departement = $ann['Departement']; + $annonce->Tribunal = $ann['Tribunal']; + $annonce->TribunalCode = $ann['TribunalCode']; + $annonce->TribunalSiret = $ann['TribunalSiret']; + $annonce->Rubrique = $ann['Rubrique']; + $annonce->typeAnnonce = $ann['typeAnnonce']; + $annonce->texteRectificatif = $ann['texteRectificatif']; + $annonce->texteAnnonce = $ann['texteAnnonce']; + $annonce->libFJ = $ann['libFJ']; + $annonce->codFJ = $ann['codFJ']; + $annonce->capital = $ann['capital']; + $annonce->capitalDev = $ann['capitalDev']; + + $annonce->raisonSociale = $ann['raisonSociale']; + $annonce->nomCommercial = $ann['nomCommercial']; + $annonce->sigle = $ann['sigle']; + $annonce->adresse = $ann['adresse']; + $annonce->dateEffet = $ann['dateEffet']; //@todo : date + $annonce->dateJugement = $ann['dateJugement']; //@todo : date + $annonce->dateInsertionSD = $ann['dateInsertionSD']; //@todo : date + $annonce->evenements = $evens; + $annonce->Lien_Annonce_Pdf = $ann['Lien_Annonce_Pdf']; + + $liste[] = $annonce; + } + + if (is_array($annsB)) + { + foreach ($annsB as $nb=>$ann) + { + $evens = array(); + foreach ($ann['evenements'] as $tabEven) + { + $even = new AnnonceEvenement(); + $even->CodeEven = $tabEven['CodeEven']; + $even->LibEven = $tabEven['LibEven']; + $evens[] = $even; + } + $annonce = new Annonce(); + $annonce->id = $ann['id']; + $annonce->BodaccCode = $ann['BodaccCode']; + $annonce->BodaccNum = $ann['BodaccNum']; + $annonce->NumAnnonce = $ann['NumAnnonce']; + $annonce->DateParution = $ann['DateParution']; //@todo : date + $annonce->Departement = $ann['Departement']; + $annonce->Tribunal = $ann['Tribunal']; + //$annonce->TribunalCode = $ann['TribunalCode']; + $annonce->TribunalSiret = $ann['TribunalSiret']; + $annonce->Rubrique = $ann['Rubrique']; + $annonce->typeAnnonce = $ann['typeAnnonce']; + $annonce->texteRectificatif = $ann['texteRectificatif']; + $annonce->texteAnnonce = utf8_encode($ann['texteAnnonce']); + //$annonce->libFJ = $ann['libFJ']; + //$annonce->codFJ = $ann['codFJ']; + //$annonce->capital = $ann['capital']; + //$annonce->capitalDev = $ann['capitalDev']; + $annonce->dateEffet = $ann['dateEffet']; //@todo : date + $annonce->dateJugement = $ann['dateJugement']; //@todo : date + $annonce->dateInsertionSD = $ann['dateInsertionSD']; //@todo : date + $annonce->evenements = $evens; + $annonce->Lien_Annonce_Pdf = $ann['Lien_Annonce_Pdf']; + + $liste[] = $annonce; + } + } + + if (is_array($annsA)) + { + foreach ($annsA as $nb=>$ann) + { + $evens = array(); + foreach ($ann['evenements'] as $tabEven) + { + $even = new AnnonceEvenement(); + $even->CodeEven = $tabEven['CodeEven']; + $even->LibEven = $tabEven['LibEven']; + $evens[] = $even; + } + + $annonce = new Annonce(); + $annonce->id = $ann['id']; + $annonce->BodaccCode = $ann['BodaccCode']; + $annonce->BodaccNum = $ann['BodaccNum']; + $annonce->NumAnnonce = $ann['NumAnnonce']; + $annonce->DateParution = $ann['DateParution']; //@todo : date + $annonce->Departement = $ann['Departement']; + $annonce->Tribunal = $ann['Tribunal']; + //$annonce->TribunalCode = $ann['TribunalCode']; + $annonce->TribunalSiret = $ann['TribunalSiret']; + $annonce->Rubrique = $ann['Rubrique']; + $annonce->typeAnnonce = $ann['typeAnnonce']; + $annonce->texteRectificatif = $ann['texteRectificatif']; + $annonce->texteAnnonce = utf8_encode($ann['texteAnnonce']); + //$annonce->libFJ = $ann['libFJ']; + //$annonce->codFJ = $ann['codFJ']; + //$annonce->capital = $ann['capital']; + //$annonce->capitalDev = $ann['capitalDev']; + //@todo : date + $annonce->dateEffet = $ann['dateEffet']; //@todo : date + $annonce->dateJugement = $ann['dateJugement']; //@todo : date + $annonce->dateInsertionSD = $ann['dateInsertionSD']; //@todo : date + $annonce->evenements = $evens; + $annonce->Lien_Annonce_Pdf = $ann['Lien_Annonce_Pdf']; + + $liste[] = $annonce; + } + } + + if (is_array($annsM)) + { + foreach ($annsM as $nb=>$ann) + { + $evens = array(); + foreach ($ann['evenements'] as $tabEven) + { + $even = new AnnonceEvenement(); + $even->CodeEven = $tabEven['CodeEven']; + $even->LibEven = $tabEven['LibEven']; + $evens[] = $even; + } + + $annonce = new Annonce(); + $annonce->id = $ann['id']; + $annonce->BodaccCode = $ann['BodaccCode']; + $annonce->BodaccNum = $ann['BodaccNum']; + $annonce->NumAnnonce = $ann['NumAnnonce']; + $annonce->DateParution = $ann['DateParution']; //@todo : date + $annonce->Departement = $ann['Departement']; + $annonce->Tribunal = $ann['Tribunal']; + //$annonce->TribunalCode = $ann['TribunalCode']; + $annonce->TribunalSiret = $ann['TribunalSiret']; + $annonce->Rubrique = $ann['Rubrique']; + $annonce->typeAnnonce = $ann['typeAnnonce']; + $annonce->texteRectificatif = $ann['texteRectificatif']; + $annonce->texteAnnonce = utf8_encode($ann['texteAnnonce']); + //$annonce->libFJ = $ann['libFJ']; + //$annonce->codFJ = $ann['codFJ']; + //$annonce->capital = $ann['capital']; + //$annonce->capitalDev = $ann['capitalDev']; + $annonce->dateEffet = $ann['dateEffet']; //@todo : date + $annonce->dateJugement = $ann['dateJugement']; //@todo : date + $annonce->dateInsertionSD = $ann['dateInsertionSD']; //@todo : date + $annonce->evenements = $evens; + $annonce->Lien_Annonce_Pdf = $ann['Lien_Annonce_Pdf']; + + $liste[] = $annonce; + } + } + } + + $nbReponses = count($liste); + if ($nbReponses>0){ + //$liste = array_slice($liste, $position, $nbRep); + } + $this->logger->info( "Nb Annonces $filtre retournées pour $siren (source=$filtre, id=$idAnn) = ". count($liste)); + $this->wsLog('annonces',$siren,$filtre.'/'.$idAnn); + + $output = new AnnoncesReturn(); + $output->nbReponses = $nbReponses; + $output->result = $liste; + return $output; } /** @@ -2050,13 +2050,13 @@ class Entreprise extends Scores_Ws_Server //Add acheteur $identite = $iInsee->getIdentiteLight($siren); - $entite = new AnnonceEntite(); - $entite->siret = $identite['Siret']; - $entite->raisonSociale = $identite['Nom']; - $even = new AnnonceEvenement(); - //$even->CodeEven = ''; - $even->LibEven = 'Acheteur'; - $entite->event = $even; + $entite = new AnnonceEntite(); + $entite->siret = $identite['Siret']; + $entite->raisonSociale = $identite['Nom']; + $even = new AnnonceEvenement(); + //$even->CodeEven = ''; + $even->LibEven = 'Acheteur'; + $entite->event = $even; $entites[] = $entite; //Search titulaire @@ -2490,9 +2490,9 @@ class Entreprise extends Scores_Ws_Server $this->permission('VALORISATION'); //Initialisation - $accesPartenaire = true; - if (APPLICATION_ENV == 'development') { - $accesPartenaire = false; + $accesPartenaire = true; + if (APPLICATION_ENV == 'development') { + $accesPartenaire = false; } if (empty($nic)) { $nic = 0; @@ -2727,20 +2727,20 @@ class Entreprise extends Scores_Ws_Server //Ratios global $tva, $mBil, $efftr, $tabInfla; - require_once 'Metier/Scores/MRatios.php'; + require_once 'Metier/Scores/MRatios.php'; $mBil = new Metier_Partenaires_MBilans(); - $mBil->setSiren($siren); - $tabBilans = $mBil->listeBilans($accesPartenaire, 5); - $nbBilans = count($tabBilans); - $tabBilan = $tabBil = array(); + $mBil->setSiren($siren); + $tabBilans = $mBil->listeBilans($accesPartenaire, 5); + $nbBilans = count($tabBilans); + $tabBilan = $tabBil = array(); if ($nbBilans>0) { - $iInsee = new Metier_Insee_MInsee(); - $tabIdentite = $iInsee->getIdentiteEntreprise($siren,0,0,false,false); - $this->logger->info("Liste des Ratios demandée pour $siren après getIdentiteEntreprise"); - $naf = $tabIdentite['NafEnt']; - $nafLib = $tabIdentite['NafEntLib']; - $efftr = $tabIdentite['Effectif']*1; + $iInsee = new Metier_Insee_MInsee(); + $tabIdentite = $iInsee->getIdentiteEntreprise($siren,0,0,false,false); + $this->logger->info("Liste des Ratios demandée pour $siren après getIdentiteEntreprise"); + $naf = $tabIdentite['NafEnt']; + $nafLib = $tabIdentite['NafEntLib']; + $efftr = $tabIdentite['Effectif']*1; $fj = $tabIdentite['FJ']; $i = 0; foreach ($tabBilans as $millesime => $item) { @@ -2759,141 +2759,141 @@ class Entreprise extends Scores_Ws_Server } $mRatios = new Metier_Scores_MRatios(); $mRatios->setTrancheEffectif($efftr); - $tabRatios = $mRatios->calcul($tabBilan); + $tabRatios = $mRatios->calcul($tabBilan); } - - $nbRatios = count($tabRatios); - $this->logger->info("Liste des Ratios demandée pour $siren après calculRatios ($nbRatios)"); - - $tabAnnees = array(); - if ( $nbRatios > 0 ) { - foreach ( $tabRatios as $i=>$R ) { - //Informations sur le bilan - $bilansInfos = new RatiosBilansInfos(); - $bilansInfos->dateCloture = $tabBilan[$i]['DATE_CLOTURE']; //@todo : date - $bilansInfos->duree = $tabBilan[$i]['DUREE_MOIS']; - $bilansInfos->devise = $tabBilan[$i]['MONNAIE']; - $bilansInfos->typeBilan = $tabBilan[$i]['CONSOLIDE']; - $bilansInfos->unite = 'U'; - if ( substr($tabBilan[$i]['DATE_CLOTURE'],0,4)>1900 ){ - $tabAnnees[$i]=substr($tabBilan[$i]['DATE_CLOTURE'],0,4); - } - - $tabRatiosEntrep = array(); - $tabRatiosEntrepEvol = array(); - 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]; - } - } - - // RatiosEntrep - $ratiosEntrep = new Ratios(); - if (substr($Rmont,0,1)=='N' || substr($Rmont,0,1)=='<' || substr($Rmont,0,1)=='>'){ - $ratiosEntrep->id = 'r'.$Ridx; - $ratiosEntrep->val = $Rmont; - } else { - $ratiosEntrep->id = 'r'.$Ridx; - $ratiosEntrep->val = round($Rmont,2); - } - $tabRatiosEntrep[] = $ratiosEntrep; - - 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'; - } - - // RatiosEntrepEvol - $ratiosEntrepEvol = new Ratios(); - if ($Rmont=='NS' || $Rmont<-800 || $Rmont>800){ - $ratiosEntrepEvol->id = 'r'.$Ridx; - $ratiosEntrepEvol->val = 'NS'; - } else { - $ratiosEntrepEvol->id = 'r'.$Ridx; - $ratiosEntrepEvol->val = number_format($Rmont,2,',',' '); - } - $tabRatiosEntrepEvol[] = $ratiosEntrepEvol; - } - $bilansInfos->RatiosEntrep = $tabRatiosEntrep; - $bilansInfos->RatiosEntrepEvol = $tabRatiosEntrepEvol; - $tabBilansR[] = $bilansInfos; - } - } - $this->logger->info("Liste des Ratios demandée pour $siren après EVOLUTION"); - - // Tableau des ratios secteurs - if (strlen($naf)>4) $strNaf = " AND naf5='$naf' "; - else $strNaf = " AND naf4='$naf' "; - $strAnnees = implode(',', $tabAnnees); - - $tabRatiosSecteurs = array(); - - $tabAnnees = array_unique($tabAnnees); - - if ( count($tabAnnees)>0 ) { - $iDb = new Metier_Util_Db(); - $tabTmp = $iDb->select('jo.ratios_secteurs', - 'annee, naf5, naf4, id, (montant/nombre) AS ratio, nombre', - "1 $strNaf AND annee IN ($strAnnees) ORDER BY annee DESC, id ASC", - false, MYSQL_ASSOC); - - $nbRatiosSec = 0; - foreach($tabAnnees as $annee) { - $ratiosSecteur = new RatiosSecteur(); - $ratiosSecteur->annee = $annee; - foreach ($tabTmp as $tmp) - { - if ($tmp['annee']== $annee) - { - $Ridx = $tmp['id']; - if ($tmp['nombre']>$nbRatiosSec){ - $nbRatiosSec = $tmp['nombre']; - } - - $unite = $tabFormulesInfos[$Ridx]['unite']; - if ($unite=='EUR'){ - $montant = round($tmp['ratio']*1000); - } else { - $montant = round($tmp['ratio']); - } - if ($tabBorneMin[$Ridx]<>'' && $montant<$tabBorneMin[$Ridx]){ - $montant='<'.$tabBorneMin[$Ridx]; - } elseif ($tabBorneMax[$Ridx]<>'' && $montant>$tabBorneMax[$Ridx]){ - $montant='>'.$tabBorneMax[$Ridx]; - } - - $ratiosSecteurListe = new Ratios(); - if (substr($montant,0,1)=='N' || substr($montant,0,1)=='<' || substr($montant,0,1)=='>'){ - $ratiosSecteurListe->id = 'r'.$Ridx; - $ratiosSecteurListe->val = $montant; - } else { - $ratiosSecteurListe->id = 'r'.$Ridx; - $ratiosSecteurListe->val = round($montant,2); - } - $ratiosSecteur->liste[] = $ratiosSecteurListe; - } - } - $tabRatiosSecteurs[] = $ratiosSecteur; - } - } - $output->RatiosBilansInfos = $tabBilansR; - $output->RatiosInfos = $tabRatiosInfos; + $nbRatios = count($tabRatios); + $this->logger->info("Liste des Ratios demandée pour $siren après calculRatios ($nbRatios)"); + + $tabAnnees = array(); + if ( $nbRatios > 0 ) { + foreach ( $tabRatios as $i=>$R ) { + //Informations sur le bilan + $bilansInfos = new RatiosBilansInfos(); + $bilansInfos->dateCloture = $tabBilan[$i]['DATE_CLOTURE']; //@todo : date + $bilansInfos->duree = $tabBilan[$i]['DUREE_MOIS']; + $bilansInfos->devise = $tabBilan[$i]['MONNAIE']; + $bilansInfos->typeBilan = $tabBilan[$i]['CONSOLIDE']; + $bilansInfos->unite = 'U'; + if ( substr($tabBilan[$i]['DATE_CLOTURE'],0,4)>1900 ){ + $tabAnnees[$i]=substr($tabBilan[$i]['DATE_CLOTURE'],0,4); + } + + $tabRatiosEntrep = array(); + $tabRatiosEntrepEvol = array(); + 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]; + } + } + + // RatiosEntrep + $ratiosEntrep = new Ratios(); + if (substr($Rmont,0,1)=='N' || substr($Rmont,0,1)=='<' || substr($Rmont,0,1)=='>'){ + $ratiosEntrep->id = 'r'.$Ridx; + $ratiosEntrep->val = $Rmont; + } else { + $ratiosEntrep->id = 'r'.$Ridx; + $ratiosEntrep->val = round($Rmont,2); + } + $tabRatiosEntrep[] = $ratiosEntrep; + + 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'; + } + + // RatiosEntrepEvol + $ratiosEntrepEvol = new Ratios(); + if ($Rmont=='NS' || $Rmont<-800 || $Rmont>800){ + $ratiosEntrepEvol->id = 'r'.$Ridx; + $ratiosEntrepEvol->val = 'NS'; + } else { + $ratiosEntrepEvol->id = 'r'.$Ridx; + $ratiosEntrepEvol->val = number_format($Rmont,2,',',' '); + } + $tabRatiosEntrepEvol[] = $ratiosEntrepEvol; + } + $bilansInfos->RatiosEntrep = $tabRatiosEntrep; + $bilansInfos->RatiosEntrepEvol = $tabRatiosEntrepEvol; + $tabBilansR[] = $bilansInfos; + } + } + $this->logger->info("Liste des Ratios demandée pour $siren après EVOLUTION"); + + // Tableau des ratios secteurs + if (strlen($naf)>4) $strNaf = " AND naf5='$naf' "; + else $strNaf = " AND naf4='$naf' "; + $strAnnees = implode(',', $tabAnnees); + + $tabRatiosSecteurs = array(); + + $tabAnnees = array_unique($tabAnnees); + + if ( count($tabAnnees)>0 ) { + $iDb = new Metier_Util_Db(); + $tabTmp = $iDb->select('jo.ratios_secteurs', + 'annee, naf5, naf4, id, (montant/nombre) AS ratio, nombre', + "1 $strNaf AND annee IN ($strAnnees) ORDER BY annee DESC, id ASC", + false, MYSQL_ASSOC); + + $nbRatiosSec = 0; + foreach($tabAnnees as $annee) { + $ratiosSecteur = new RatiosSecteur(); + $ratiosSecteur->annee = $annee; + foreach ($tabTmp as $tmp) + { + if ($tmp['annee']== $annee) + { + $Ridx = $tmp['id']; + if ($tmp['nombre']>$nbRatiosSec){ + $nbRatiosSec = $tmp['nombre']; + } + + $unite = $tabFormulesInfos[$Ridx]['unite']; + if ($unite=='EUR'){ + $montant = round($tmp['ratio']*1000); + } else { + $montant = round($tmp['ratio']); + } + if ($tabBorneMin[$Ridx]<>'' && $montant<$tabBorneMin[$Ridx]){ + $montant='<'.$tabBorneMin[$Ridx]; + } elseif ($tabBorneMax[$Ridx]<>'' && $montant>$tabBorneMax[$Ridx]){ + $montant='>'.$tabBorneMax[$Ridx]; + } + + $ratiosSecteurListe = new Ratios(); + if (substr($montant,0,1)=='N' || substr($montant,0,1)=='<' || substr($montant,0,1)=='>'){ + $ratiosSecteurListe->id = 'r'.$Ridx; + $ratiosSecteurListe->val = $montant; + } else { + $ratiosSecteurListe->id = 'r'.$Ridx; + $ratiosSecteurListe->val = round($montant,2); + } + $ratiosSecteur->liste[] = $ratiosSecteurListe; + } + } + $tabRatiosSecteurs[] = $ratiosSecteur; + } + } + + $output->RatiosBilansInfos = $tabBilansR; + $output->RatiosInfos = $tabRatiosInfos; $output->RatiosSecteur = $tabRatiosSecteurs; $this->wsLog('valorisation',$siren); @@ -3893,16 +3893,16 @@ class Entreprise extends Scores_Ws_Server //Si la donnée existe déjà et que la source=score alors il faut mettre à jour l'encours client if ($source == 'score' && $detect[0]['dateSuppr']=='0000-00-00 00:00:00') { - $data = array ( - 'encoursClient' => $encoursClient, + $data = array ( + 'encoursClient' => $encoursClient, ); $result = $iDb->update('jo.surveillances_site', $data, $where, false, 0, true); } elseif ( $detect[0]['dateSuppr']!='0000-00-00 00:00:00') { $data = array ( - 'dateAjout' => date('Y-m-d'), - 'dateSuppr' => '0000-00-00 00:00:00', + 'dateAjout' => date('Y-m-d'), + 'dateSuppr' => '0000-00-00 00:00:00', ); $result = $iDb->update('jo.surveillances_site', $data, $where, false, 0, true); @@ -4272,7 +4272,7 @@ class Entreprise extends Scores_Ws_Server 'devise', 'ID_BILAN_SD', 'DATE_BILAN_SD', - 'TOP_CONFIDENTIEL', + 'TOP_CONFIDENTIEL', ); $resultBilan = new Bilan(); @@ -4317,7 +4317,7 @@ class Entreprise extends Scores_Ws_Server $mBil = new Metier_Partenaires_MBilans(); $mBil->setSiren($siren); - $tabBilans = $mBil->listeBilans(true); + $tabBilans = $mBil->listeBilans(true, 0, $this->User->idClient); foreach($tabBilans as $bilan) { $element = new ListeBilans(); $element->dateProvPartenaire = $bilan['dateProvPartenaire']; //@todo : date @@ -4602,10 +4602,10 @@ class Entreprise extends Scores_Ws_Server $accesPartenaire = false; } - $tabRatiosInfos = $tabRatiosSecteurs = $tabBilansR = array(); - $tabRatios = $tabRatiosEvol = array(); + $tabRatiosInfos = $tabRatiosSecteurs = $tabBilansR = array(); + $tabRatios = $tabRatiosEvol = array(); $tabRet = array(); - + /** * Tableau d'infos sur les formules */ @@ -5312,7 +5312,7 @@ class Entreprise extends Scores_Ws_Server 'sirenAsso', //sirenIn 'nomAsso', 'sirenOrigine', //sirenOut - 'libOrigine', //Origine + 'libOrigine', //Origine 'libImputation', //Programme 'mtSubvention', //Montant )); From 438c98ba01407f25e6f9c6e890469c9a41c97648 Mon Sep 17 00:00:00 2001 From: benoitpotier Date: Fri, 17 Mar 2017 11:59:12 +0100 Subject: [PATCH 02/14] ajout gestion bilan confidentiel --- library/Metier/Partenaires/MBilans.php | 3 +- library/WsScore/Entreprise/v0.8/Service.php | 1 + library/WsScore/Entreprise/v0.8/Types.php | 18 ++- library/WsScore/Saisie/v0.2/Service.php | 116 ++++++++++---------- 4 files changed, 76 insertions(+), 62 deletions(-) diff --git a/library/Metier/Partenaires/MBilans.php b/library/Metier/Partenaires/MBilans.php index 0d8bbb2e..58431d9f 100644 --- a/library/Metier/Partenaires/MBilans.php +++ b/library/Metier/Partenaires/MBilans.php @@ -364,7 +364,7 @@ class Metier_Partenaires_MBilans $where.= " LIMIT 0, $nbMaxBilans"; } - $fields = "typeBilan, dateProvPartenaire, dateExercice, dateExercicePre, dureeExercice, dureeExercicePre, monnaieOrigine, dateInsert, partenaire"; + $fields = "typeBilan, dateProvPartenaire, dateExercice, dateExercicePre, dureeExercice, dureeExercicePre, monnaieOrigine, dateInsert, partenaire, confidentiel"; $listeNb = 0; try { $listeSql = "SELECT $fields FROM jo.bilans WHERE $where"; @@ -392,6 +392,7 @@ class Metier_Partenaires_MBilans 'dureeExercicePre' => $bil['dureeExercicePre'], 'monnaie' => $bil['monnaieOrigine'], 'source' => $bil['partenaire'], + 'confidentiel' => $bil['confidentiel'], ); $tabTri[''.$bil['dateExercice'].'-'.$bil['typeBilan']] = $bil['typeBilan'].$millesime; } diff --git a/library/WsScore/Entreprise/v0.8/Service.php b/library/WsScore/Entreprise/v0.8/Service.php index 5dd5c106..fb5e4608 100644 --- a/library/WsScore/Entreprise/v0.8/Service.php +++ b/library/WsScore/Entreprise/v0.8/Service.php @@ -4330,6 +4330,7 @@ class Entreprise extends Scores_Ws_Server $element->dureeExercicePre = $bilan['dureeExercicePre']; $element->monnaie = $bilan['monnaie']; $element->source = $bilan['source']; + $element->confidentiel = $bilan['confidentiel']; $tabRet[] = $element; } diff --git a/library/WsScore/Entreprise/v0.8/Types.php b/library/WsScore/Entreprise/v0.8/Types.php index 2a5df9db..c394e2a5 100644 --- a/library/WsScore/Entreprise/v0.8/Types.php +++ b/library/WsScore/Entreprise/v0.8/Types.php @@ -269,10 +269,10 @@ class Identite */ public $NbEtab; - /** - * Numéro isin - * @var string - */ + /** + * Numéro isin + * @var string + */ public $Isin; /** @@ -2366,6 +2366,11 @@ class ListeBilans * @var int */ public $source; + + /** Confidentialité du bilan (1 si confidentiel, 0 sinon) + * @var int + */ + public $confidentiel; } class SetSurveillanceReturn @@ -2550,6 +2555,11 @@ class Bilan */ public $SOURCE; + /** Bilan confidentiel ou non + * @var string + */ + public $TOP_CONFIDENTIEL; + /** Tableau de postes du bilan dans le formalisme associé au Type de bilan * @var BilanPoste[] */ diff --git a/library/WsScore/Saisie/v0.2/Service.php b/library/WsScore/Saisie/v0.2/Service.php index 03b1c3ad..258b1980 100644 --- a/library/WsScore/Saisie/v0.2/Service.php +++ b/library/WsScore/Saisie/v0.2/Service.php @@ -73,16 +73,16 @@ class Saisie extends Scores_Ws_Server $tabScores = $tabInfos['score']; //Valider le code Isin - if (strlen(trim($tabIdentite['isin']))) { - $iBourse = new Metier_Partenaires_MBourse(); - if (!$iBourse->isIsin($tabIdentite['isin'])) { - $error->errnum = 1; + if (strlen(trim($tabIdentite['isin']))) { + $iBourse = new Metier_Partenaires_MBourse(); + if (!$iBourse->isIsin($tabIdentite['isin'])) { + $error->errnum = 1; $error->errmsg = 'Code Isin incorrect.'; $output = new SetInfosEntrepReturn(); $output->error = $error; $output->result = $result; - return $output; - } + return $output; + } } // Mise à jour de l'identité @@ -1257,21 +1257,21 @@ class Saisie extends Scores_Ws_Server break; } - $iInsee = new Metier_Insee_MInsee(); + $iInsee = new Metier_Insee_MInsee(); $entrep = $iInsee->getIdentiteLight($siren, $nic); if ( empty($entrep['id']) || intval($entrep['id'])==0 ) { $this->sendError('1020'); } - $data = array( - 'siren' => $siren, - 'nic' => $nic, - 'dateProvPartenaire'=> date('Y').date('m').date('d'), - 'typeTel' => $type, - 'infoTel' => $info, - 'telephone' => $value, - 'actif' => 1, - 'partenaire' => 175, + $data = array( + 'siren' => $siren, + 'nic' => $nic, + 'dateProvPartenaire'=> date('Y').date('m').date('d'), + 'typeTel' => $type, + 'infoTel' => $info, + 'telephone' => $value, + 'actif' => 1, + 'partenaire' => 175, ); if ( $id === null ) { @@ -1386,16 +1386,18 @@ class Saisie extends Scores_Ws_Server * Postes et Information du bilan * @param string $step (normal|nocheck|onlycheck) * Etape + * @param string $confidentiel (0: non|idCient: oui) + * Confidentialité * @return int * @throws SoapFault */ - public function setBilan($siren, $cloture, $type, $data, $step = null) + public function setBilan($siren, $cloture, $type, $data, $step = null, $confidentiel=0) { $this->authenticate(); - // --- Control input value - if ( strlen($siren)!=9 ) { - $this->sendError('1010'); + // --- Control input value + if ( strlen($siren)!=9 ) { + $this->sendError('1010'); } $tabPostes = array(); @@ -1407,8 +1409,8 @@ class Saisie extends Scores_Ws_Server if (!preg_match('/[0-9]{8}/', $data->dateCloture)) { throw new SoapFault('MSG', "Erreur Date de cloture"); } - if ($data->dateCloturePre != 'AAAAMMJJ' && !preg_match('/[0-9]{8}/', $data->dateCloturePre)) { - throw new SoapFault('MSG', "Erreur Date de cloture précédente"); + if ($data->dateCloturePre != 'AAAAMMJJ' && !preg_match('/[0-9]{8}/', $data->dateCloturePre)) { + throw new SoapFault('MSG', "Erreur Date de cloture précédente"); } if ($data->dateCloturePre == 'AAAAMMJJ') { $data->dateCloturePre = 0; @@ -1450,21 +1452,21 @@ class Saisie extends Scores_Ws_Server } // --- Insertion dans la bdd else { - + try { $bilansM = new Application_Model_JoBilans(); $sql = $bilansM->select() ->where('siren=?', $siren) ->where('dateExercice=?', $cloture) - ->where('typeBilan=?', $type); + ->where('typeBilan=?', $type); $row = $bilansM->fetchRow($sql); - } catch (Zend_Db_Exception $e) { - if ($this->User->idClient!=1) { - throw new SoapFault('ERR', "Application error"); - } else { - throw new SoapFault('ERR', $e->getMessage()); - } + } catch (Zend_Db_Exception $e) { + if ($this->User->idClient!=1) { + throw new SoapFault('ERR', "Application error"); + } else { + throw new SoapFault('ERR', $e->getMessage()); + } } $postesDiff = array(); @@ -1485,7 +1487,7 @@ class Saisie extends Scores_Ws_Server 'unite' => $data->unite, 'postes' => $data->postes, 'partenaire' => 1, - 'confidentiel' => 0, + 'confidentiel' => $confidentiel, 'dateInsert' => date('YmdHis'), ); @@ -1532,7 +1534,7 @@ class Saisie extends Scores_Ws_Server 'unite' => $data->unite, 'postes' => $data->postes, 'partenaire' => 1, - 'confidentiel' => 0, + 'confidentiel' => $confidentiel, 'dateInsert' => date('YmdHis'), ); @@ -1555,7 +1557,7 @@ class Saisie extends Scores_Ws_Server // --- Save user $userM = new Application_Model_JoBilansUser(); - try { + try { $userM->insert(array( 'idUtilisateur' => $this->User->id, 'login' => $this->User->login, @@ -1564,13 +1566,13 @@ class Saisie extends Scores_Ws_Server 'typeBilan' => $data->typeBilan, 'dateAction' => date('YmdHis'), 'postesDiff' => implode(';', $postesDiff), - )); - } catch (Zend_Db_Exception $e) { - if ($this->User->idClient!=1) { - throw new SoapFault('ERR', "Application error"); - } else { - throw new SoapFault('ERR', $e->getMessage()); - } + )); + } catch (Zend_Db_Exception $e) { + if ($this->User->idClient!=1) { + throw new SoapFault('ERR', "Application error"); + } else { + throw new SoapFault('ERR', $e->getMessage()); + } } return $id; @@ -1749,8 +1751,8 @@ class Saisie extends Scores_Ws_Server if (strlen(trim($dataRef['isin']))) { $iBourse = new Metier_Partenaires_MBourse(); - if (!$iBourse->isIsin($dataRef['isin'])) { - throw new SoapFault('ERR', 'Code Isin incorrect.'); + if (!$iBourse->isIsin($dataRef['isin'])) { + throw new SoapFault('ERR', 'Code Isin incorrect.'); } } @@ -2345,20 +2347,20 @@ class Saisie extends Scores_Ws_Server } if ($result) return true; } - //Move active participations if TUP and Fusion selected - elseif ($action=='tupfusion') - { - try { - $result = $lienM->update(array('idAct'=>$id, 'idUpdate'=>$this->User->id), - "idAct=$idLien AND actif=1 AND dateSuppr='0000-00-00 00:00:00'"); - } catch (Zend_Db_Exception $e) { - if ($this->User->idClient==1) { - throw new SoapFault('ERR', $e->getMessage()); - } else { - throw new SoapFault('ERR', "Application error"); - } - } - if ($result) return true; + //Move active participations if TUP and Fusion selected + elseif ($action=='tupfusion') + { + try { + $result = $lienM->update(array('idAct'=>$id, 'idUpdate'=>$this->User->id), + "idAct=$idLien AND actif=1 AND dateSuppr='0000-00-00 00:00:00'"); + } catch (Zend_Db_Exception $e) { + if ($this->User->idClient==1) { + throw new SoapFault('ERR', $e->getMessage()); + } else { + throw new SoapFault('ERR', "Application error"); + } + } + if ($result) return true; } return false; @@ -2593,7 +2595,7 @@ class Saisie extends Scores_Ws_Server } return $result; - case 'edit': + case 'edit': $tabRet['idUpdate'] = $userId; try { $result = $dirOp->update($tabRet, $where); From 520bb9fe931d24b5f4048ddc8856da68db63fce6 Mon Sep 17 00:00:00 2001 From: benoitpotier Date: Tue, 21 Mar 2017 09:54:57 +0100 Subject: [PATCH 03/14] correction retour liste bilans confidentiels ou non --- library/Metier/Partenaires/MBilans.php | 9 ++++++++- library/WsScore/Entreprise/v0.7/Service.php | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/library/Metier/Partenaires/MBilans.php b/library/Metier/Partenaires/MBilans.php index 58431d9f..9340e199 100644 --- a/library/Metier/Partenaires/MBilans.php +++ b/library/Metier/Partenaires/MBilans.php @@ -358,7 +358,14 @@ class Metier_Partenaires_MBilans if ($this->companyEvenDateStop !== null) { $where.= " AND dateExercice<'".$this->companyEvenDateStop."'"; } - $where.= ($idClient > 0) ? " AND (confidentiel = '".$idClient."' OR confidentiel = 0)" : " AND confidentiel = 0"; + + // --- Si c'est un client qui consulte, alors il ne peut voir que ses bilans confidentiels ou tous les bilans publiques. + // --- 0 : consultation de l'application (calcul du score ...) + // --- 1 : consultation d'un membre de scores et décisions + if ($idClient > 1) { + $where.= " AND (confidentiel = '".$idClient."' OR confidentiel = 0)"; + } + $where.= " ORDER BY dateExercice DESC, CASE typeBilan WHEN 'N' THEN 1 WHEN 'S' THEN 2 ELSE 3 END"; if ($nbMaxBilans > 0) { $where.= " LIMIT 0, $nbMaxBilans"; diff --git a/library/WsScore/Entreprise/v0.7/Service.php b/library/WsScore/Entreprise/v0.7/Service.php index 18dc2860..dc877220 100644 --- a/library/WsScore/Entreprise/v0.7/Service.php +++ b/library/WsScore/Entreprise/v0.7/Service.php @@ -3335,7 +3335,7 @@ class Entreprise extends Scores_Ws_Server if(!in_array($key, array('SIREN', 'DATE_FRAICHE_BILAN', 'DATE_CLOTURE', 'DATE_CLOTURE_PRE', 'DUREE_MOIS', 'DUREE_MOIS_PRE', 'MONNAIE', 'CONSOLIDE', 'MONNAIE_ORI', - 'MONNAIE_LIV_UNITE', 'SOURCE', 'devise'))){ + 'MONNAIE_LIV_UNITE', 'SOURCE', 'devise', 'TOP_CONFIDENTIEL'))){ $resultPoste = new BilanPoste(); $resultPoste->id = $key; $resultPoste->val = $value; From a292d63f1b05b459d6a69486c995b01d2685b062 Mon Sep 17 00:00:00 2001 From: benoitpotier Date: Tue, 21 Mar 2017 11:56:05 +0100 Subject: [PATCH 04/14] =?UTF-8?q?suppression=20parametre=20confidentiel=20?= =?UTF-8?q?ajout=C3=A9=20dans=20la=20branche?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/WsScore/Saisie/v0.2/Service.php | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/library/WsScore/Saisie/v0.2/Service.php b/library/WsScore/Saisie/v0.2/Service.php index 258b1980..834e8136 100644 --- a/library/WsScore/Saisie/v0.2/Service.php +++ b/library/WsScore/Saisie/v0.2/Service.php @@ -1386,12 +1386,10 @@ class Saisie extends Scores_Ws_Server * Postes et Information du bilan * @param string $step (normal|nocheck|onlycheck) * Etape - * @param string $confidentiel (0: non|idCient: oui) - * Confidentialité * @return int * @throws SoapFault */ - public function setBilan($siren, $cloture, $type, $data, $step = null, $confidentiel=0) + public function setBilan($siren, $cloture, $type, $data, $step = null) { $this->authenticate(); @@ -1487,7 +1485,6 @@ class Saisie extends Scores_Ws_Server 'unite' => $data->unite, 'postes' => $data->postes, 'partenaire' => 1, - 'confidentiel' => $confidentiel, 'dateInsert' => date('YmdHis'), ); @@ -1534,7 +1531,6 @@ class Saisie extends Scores_Ws_Server 'unite' => $data->unite, 'postes' => $data->postes, 'partenaire' => 1, - 'confidentiel' => $confidentiel, 'dateInsert' => date('YmdHis'), ); From b9c59977b0fa405ce594929be012f4e12045a31a Mon Sep 17 00:00:00 2001 From: benoitpotier Date: Tue, 21 Mar 2017 11:59:26 +0100 Subject: [PATCH 05/14] correctif dans la suppression --- library/WsScore/Saisie/v0.2/Service.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/library/WsScore/Saisie/v0.2/Service.php b/library/WsScore/Saisie/v0.2/Service.php index 834e8136..8d28c456 100644 --- a/library/WsScore/Saisie/v0.2/Service.php +++ b/library/WsScore/Saisie/v0.2/Service.php @@ -1485,6 +1485,7 @@ class Saisie extends Scores_Ws_Server 'unite' => $data->unite, 'postes' => $data->postes, 'partenaire' => 1, + 'confidentiel' => 0, 'dateInsert' => date('YmdHis'), ); @@ -1531,6 +1532,7 @@ class Saisie extends Scores_Ws_Server 'unite' => $data->unite, 'postes' => $data->postes, 'partenaire' => 1, + 'confidentiel' => 0, 'dateInsert' => date('YmdHis'), ); From 8b6a1300e44616647d0b3402e83dcaf0b9dc8283 Mon Sep 17 00:00:00 2001 From: benoitpotier Date: Tue, 21 Mar 2017 16:17:48 +0100 Subject: [PATCH 06/14] progress confidentiel --- library/Metier/Partenaires/MBilans.php | 5 +++-- library/WsScore/Entreprise/v0.8/Service.php | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/library/Metier/Partenaires/MBilans.php b/library/Metier/Partenaires/MBilans.php index 9340e199..487f652e 100644 --- a/library/Metier/Partenaires/MBilans.php +++ b/library/Metier/Partenaires/MBilans.php @@ -363,7 +363,7 @@ class Metier_Partenaires_MBilans // --- 0 : consultation de l'application (calcul du score ...) // --- 1 : consultation d'un membre de scores et décisions if ($idClient > 1) { - $where.= " AND (confidentiel = '".$idClient."' OR confidentiel = 0)"; + $where.= " AND (confidentiel_client == '".$idClient."' OR confidentiel = 0)"; } $where.= " ORDER BY dateExercice DESC, CASE typeBilan WHEN 'N' THEN 1 WHEN 'S' THEN 2 ELSE 3 END"; @@ -371,7 +371,7 @@ class Metier_Partenaires_MBilans $where.= " LIMIT 0, $nbMaxBilans"; } - $fields = "typeBilan, dateProvPartenaire, dateExercice, dateExercicePre, dureeExercice, dureeExercicePre, monnaieOrigine, dateInsert, partenaire, confidentiel"; + $fields = "typeBilan, dateProvPartenaire, dateExercice, dateExercicePre, dureeExercice, dureeExercicePre, monnaieOrigine, dateInsert, partenaire, confidentiel, confidentiel_client"; $listeNb = 0; try { $listeSql = "SELECT $fields FROM jo.bilans WHERE $where"; @@ -400,6 +400,7 @@ class Metier_Partenaires_MBilans 'monnaie' => $bil['monnaieOrigine'], 'source' => $bil['partenaire'], 'confidentiel' => $bil['confidentiel'], + 'confidentielClient' => $bil['confidentiel_client'], ); $tabTri[''.$bil['dateExercice'].'-'.$bil['typeBilan']] = $bil['typeBilan'].$millesime; } diff --git a/library/WsScore/Entreprise/v0.8/Service.php b/library/WsScore/Entreprise/v0.8/Service.php index fb5e4608..c4ea7563 100644 --- a/library/WsScore/Entreprise/v0.8/Service.php +++ b/library/WsScore/Entreprise/v0.8/Service.php @@ -4331,6 +4331,7 @@ class Entreprise extends Scores_Ws_Server $element->monnaie = $bilan['monnaie']; $element->source = $bilan['source']; $element->confidentiel = $bilan['confidentiel']; + $element->confidentielClient = $bilan['confidentielClient']; $tabRet[] = $element; } From 19c421633a18b5fb3eb0b13e6443d3dfb0766f63 Mon Sep 17 00:00:00 2001 From: benoitpotier Date: Tue, 21 Mar 2017 16:31:17 +0100 Subject: [PATCH 07/14] =?UTF-8?q?autorisation=20arm=C3=A9nie?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/Metier/Partenaires/MBilans.php | 3 ++- library/WsScore/Entreprise/v0.8/Service.php | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/library/Metier/Partenaires/MBilans.php b/library/Metier/Partenaires/MBilans.php index 487f652e..74fda94c 100644 --- a/library/Metier/Partenaires/MBilans.php +++ b/library/Metier/Partenaires/MBilans.php @@ -362,7 +362,8 @@ class Metier_Partenaires_MBilans // --- Si c'est un client qui consulte, alors il ne peut voir que ses bilans confidentiels ou tous les bilans publiques. // --- 0 : consultation de l'application (calcul du score ...) // --- 1 : consultation d'un membre de scores et décisions - if ($idClient > 1) { + // --- 147 : consultation d'un opérateur de l'arménie + if ($idClient > 1 && $idClient != 147) { $where.= " AND (confidentiel_client == '".$idClient."' OR confidentiel = 0)"; } diff --git a/library/WsScore/Entreprise/v0.8/Service.php b/library/WsScore/Entreprise/v0.8/Service.php index c4ea7563..91c51281 100644 --- a/library/WsScore/Entreprise/v0.8/Service.php +++ b/library/WsScore/Entreprise/v0.8/Service.php @@ -4331,7 +4331,7 @@ class Entreprise extends Scores_Ws_Server $element->monnaie = $bilan['monnaie']; $element->source = $bilan['source']; $element->confidentiel = $bilan['confidentiel']; - $element->confidentielClient = $bilan['confidentielClient']; + $element->confidentielClient = $bilan['confidentielClient']; $tabRet[] = $element; } From ff3e54cb934599c7cd681d3e3ab1bbb268de1a6c Mon Sep 17 00:00:00 2001 From: benoitpotier Date: Thu, 23 Mar 2017 15:57:19 +0100 Subject: [PATCH 08/14] fix bad request sql --- library/Metier/Partenaires/MBilans.php | 2 +- library/WsScore/Entreprise/v0.8/Service.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/library/Metier/Partenaires/MBilans.php b/library/Metier/Partenaires/MBilans.php index 74fda94c..fe6f1254 100644 --- a/library/Metier/Partenaires/MBilans.php +++ b/library/Metier/Partenaires/MBilans.php @@ -364,7 +364,7 @@ class Metier_Partenaires_MBilans // --- 1 : consultation d'un membre de scores et décisions // --- 147 : consultation d'un opérateur de l'arménie if ($idClient > 1 && $idClient != 147) { - $where.= " AND (confidentiel_client == '".$idClient."' OR confidentiel = 0)"; + $where.= " AND (confidentiel_client = ".$idClient." OR confidentiel = 0)"; } $where.= " ORDER BY dateExercice DESC, CASE typeBilan WHEN 'N' THEN 1 WHEN 'S' THEN 2 ELSE 3 END"; diff --git a/library/WsScore/Entreprise/v0.8/Service.php b/library/WsScore/Entreprise/v0.8/Service.php index 91c51281..f3acfa04 100644 --- a/library/WsScore/Entreprise/v0.8/Service.php +++ b/library/WsScore/Entreprise/v0.8/Service.php @@ -4632,7 +4632,7 @@ class Entreprise extends Scores_Ws_Server // Ratios $mBil = new Metier_Partenaires_MBilans(); $mBil->setSiren($siren); - $tabBilans = $mBil->listeBilans($accesPartenaire, 5); + $tabBilans = $mBil->listeBilans($accesPartenaire, 5, $this->User->idClient); $nbBilans = count($tabBilans); $tabBilan = $tabBil = array(); if ($nbBilans > 0) { From e93df1d6d6667527b385ab788911b1a52fc6a537 Mon Sep 17 00:00:00 2001 From: Michael RICOIS Date: Wed, 29 Mar 2017 13:55:53 +0200 Subject: [PATCH 09/14] Petites corrections avec v0.8 --- library/WsScore/Entreprise/v0.7/Service.php | 28 +++++++++++---------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/library/WsScore/Entreprise/v0.7/Service.php b/library/WsScore/Entreprise/v0.7/Service.php index f1a81cdb..26d0845e 100644 --- a/library/WsScore/Entreprise/v0.7/Service.php +++ b/library/WsScore/Entreprise/v0.7/Service.php @@ -591,11 +591,11 @@ class Entreprise extends Scores_Ws_Server $tabAct = array(); foreach ($tabA as $i=>$lien) { $liens = new Actionnaire(); - $liens->Pmin = $lien['PDetention']; - $liens->MajMin = $lien['MajMin']; - $liens->RaisonSociale = $lien['RS']; - $liens->Pays = $lien['adresse_pays']; - $liens->Siren = $lien['siren']; + $liens->Pmin = $lien->PDetention; + $liens->MajMin = $lien->MajMin; + $liens->RaisonSociale = $lien->RS; + $liens->Pays = $lien->adresse_pays; + $liens->Siren = $lien->siren; $liens->Actif = 1; $tabAct[] = $liens; } @@ -631,6 +631,7 @@ class Entreprise extends Scores_Ws_Server /** Y a t il eu des informations relatives à une cession ? **/ $iGreffes = new Metier_Partenaires_MGreffes(); + $tabCes = $iGreffes->getInfosCessions($siren); if ($tabCes) { $identiteProcol->CessionJugeLib = $tabCes['cessJuge']; $identiteProcol->CessionJugeDate = $tabCes['cessDateJuge']; @@ -911,14 +912,15 @@ class Entreprise extends Scores_Ws_Server $annsB=$iInsee->getAnnoncesBalo($siren); $annsA=$iInsee->getAnnoncesAsso($siren); $annsM=$iInsee->getAnnoncesBoamp($siren, $idAnn); - } elseif ($filtre==1) - $anns=$iInsee->getAnnoncesLegales($siren, $idAnn); - elseif ($filtre==2) - $annsB=$iInsee->getAnnoncesBalo($siren, $idAnn); - elseif ($filtre==3) - $annsA=$iInsee->getAnnoncesAsso($siren, $idAnn); - elseif ($filtre==4) - $annsM=$iInsee->getAnnoncesBoamp($siren, $idAnn); + } elseif ($filtre==1) { + $anns=$iInsee->getAnnoncesLegales($siren, $idAnn); + } elseif ($filtre==2) { + $annsB=$iInsee->getAnnoncesBalo($siren, $idAnn); + } elseif ($filtre==3) { + $annsA=$iInsee->getAnnoncesAsso($siren, $idAnn); + } elseif ($filtre==4) { + $annsM=$iInsee->getAnnoncesBoamp($siren, $idAnn); + } if (empty($anns) && empty($annsB) && empty($annsA) && empty($annsM)) { From 4de0c30270072a5acac5cd1b9d2974920f991c33 Mon Sep 17 00:00:00 2001 From: Michael RICOIS Date: Wed, 29 Mar 2017 13:56:15 +0200 Subject: [PATCH 10/14] CS --- library/Metier/Liens/Base.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/library/Metier/Liens/Base.php b/library/Metier/Liens/Base.php index 7b083be5..3b7c2b0f 100755 --- a/library/Metier/Liens/Base.php +++ b/library/Metier/Liens/Base.php @@ -117,17 +117,17 @@ class Metier_Liens_Base ->where('l.idPar = :id')->setParameter('id', $id) ->orderBy('l.PDetention', 'DESC'); - // Actif / Inactif - if (null !== $actif) { - if (false === $actif) { - $qb->andWhere('l.actif = 0'); - } else { - $qb->andWhere('l.actif = 1'); - } + // Actif / Inactif + if (null !== $actif) { + if (false === $actif) { + $qb->andWhere('l.actif = 0'); + } else { + $qb->andWhere('l.actif = 1'); } + } - // Don't display deleted - anomaly - $qb->andWhere("l.dateSuppr = '0000-00-00 00:00:00'"); + // Don't display deleted - anomaly + $qb->andWhere("l.dateSuppr = '0000-00-00 00:00:00'"); $stmt = $qb->execute(); $liens = $stmt->fetchAll(\PDO::FETCH_OBJ); } catch (\Doctrine\DBAL\DBALException $e) { From 66031ac43bd3b53ee8e52ca66d057b18e8ae5966 Mon Sep 17 00:00:00 2001 From: Michael RICOIS Date: Thu, 30 Mar 2017 15:32:55 +0200 Subject: [PATCH 11/14] Remove wse.scores-decisions.com --- public/assets/code/python | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/assets/code/python b/public/assets/code/python index 0619689d..4d5001b1 100644 --- a/public/assets/code/python +++ b/public/assets/code/python @@ -42,7 +42,7 @@ callInfo.inparams callInfo.inparams[0].name u'parameters' callInfo.inparams[0].type -(u'http://wse.scores-decisions.com:8081/service', u'status') +(u'http://hostname/service', u'status') From 4dd354504ef31cb1aaf179e96a377f161050ccea Mon Sep 17 00:00:00 2001 From: Michael RICOIS Date: Thu, 30 Mar 2017 15:40:22 +0200 Subject: [PATCH 12/14] Up log level to NOTICE --- application/Bootstrap.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/application/Bootstrap.php b/application/Bootstrap.php index b4c70d0a..49962c32 100644 --- a/application/Bootstrap.php +++ b/application/Bootstrap.php @@ -208,7 +208,7 @@ class Bootstrap extends Zend_Application_Bootstrap_Bootstrap if (APPLICATION_ENV == 'development') { $level = Logger::DEBUG; } else { - $level = Logger::INFO; + $level = Logger::NOTICE; } $log->pushHandler(new StreamHandler($logFile), $level); $log->pushProcessor(new IntrospectionProcessor()); From b4acea6de5f35ef63e2c9921492912f21d95b48d Mon Sep 17 00:00:00 2001 From: Michael RICOIS Date: Thu, 30 Mar 2017 17:11:36 +0200 Subject: [PATCH 13/14] Traitement HTTPS --- application/controllers/ServiceController.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/application/controllers/ServiceController.php b/application/controllers/ServiceController.php index 78078734..8dd482f7 100644 --- a/application/controllers/ServiceController.php +++ b/application/controllers/ServiceController.php @@ -78,6 +78,7 @@ class ServiceController extends Zend_Controller_Action } else { $pathServiceUrl = 'clients/'.$client.'/v'.$version.'?wsdl'; } + $pathServiceUri = 'clients/'.$client.'/v'.$version; // --- On redéfini le nom du service $serviceClassName = 'Entreprise'; $fichierWsdl = $clientClassName.'-'.$serviceClassName.'-'.$version.'.wsdl'; @@ -92,6 +93,7 @@ class ServiceController extends Zend_Controller_Action } else { $pathServiceUrl = $serviceName.'/v'.$version.'?wsdl'; } + $pathServiceUri = $serviceName.'/v'.$version; $fichierWsdl = $serviceClassName.'-'.$version.'.wsdl'; } @@ -104,6 +106,11 @@ class ServiceController extends Zend_Controller_Action // --- Get hostname - add compatibility with Reverse Proxy $hostName = $request->getHttpHost(); $hostScheme = $request->getScheme(); + $http = new Zend_Controller_Request_Http(); + $proxyScheme = $http->getHeader('X-Forwarded-Proto'); + if ($proxyScheme == 'https') { + $hostScheme = 'https'; + } $fichierWsdl = $hostName . '-' . $hostScheme . '-' . $fichierWsdl; $c = Zend_registry::get('config'); $wsdlPath = $c->profil->path->shared . '/wsdl'; @@ -124,6 +131,10 @@ class ServiceController extends Zend_Controller_Action $wsdl->setBindingStyle(array('style' => 'document')); $wsdl->setClass($serviceClassName); + if ($hostScheme == 'https') { + $wsdl->setUri($hostScheme.'://'.$hostName.'/'.$pathServiceUri); + } + // --- Enregistrement du WSDL dans un fichier if (isset($_GET['wsdl-generate'])) { if (file_exists($wsdlPath . '/' . $fichierWsdl)) { @@ -131,7 +142,6 @@ class ServiceController extends Zend_Controller_Action } $wsdl->dump($wsdlPath . '/' . $fichierWsdl); echo "Le fichier $fichierWsdl a été généré"; - // --- Génération/Fourniture du wsdl } elseif (isset($_GET['wsdl']) && !file_exists($wsdlPath . '/' . $fichierWsdl)) { $wsdl->dump($wsdlPath . '/' . $fichierWsdl); From 2ba274de1d8f020638634530a36d0f7016df3407 Mon Sep 17 00:00:00 2001 From: Michael RICOIS Date: Fri, 31 Mar 2017 12:29:56 +0200 Subject: [PATCH 14/14] Condition positive --- library/WsScore/Saisie/v0.2/Service.php | 30 ++++++++++++------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/library/WsScore/Saisie/v0.2/Service.php b/library/WsScore/Saisie/v0.2/Service.php index 8d28c456..7c7fea3f 100644 --- a/library/WsScore/Saisie/v0.2/Service.php +++ b/library/WsScore/Saisie/v0.2/Service.php @@ -1460,10 +1460,10 @@ class Saisie extends Scores_Ws_Server $row = $bilansM->fetchRow($sql); } catch (Zend_Db_Exception $e) { - if ($this->User->idClient!=1) { - throw new SoapFault('ERR', "Application error"); - } else { + if ($this->User->idClient == 1) { throw new SoapFault('ERR', $e->getMessage()); + } else { + throw new SoapFault('ERR', "Application error"); } } @@ -1493,10 +1493,10 @@ class Saisie extends Scores_Ws_Server try { $id = $bilansM->insert($dataToInsert); } catch (Zend_Db_Exception $e) { - if ($this->User->idClient!=1) { - throw new SoapFault('ERR', "Application error"); - } else { + if ($this->User->idClient == 1) { throw new SoapFault('ERR', $e->getMessage()); + } else { + throw new SoapFault('ERR', "Application error"); } } } @@ -1512,10 +1512,10 @@ class Saisie extends Scores_Ws_Server try { $historiquesM->insert($backupData); } catch (Zend_Db_Exception $e) { - if ($this->User->idClient!=1) { - throw new SoapFault('ERR', "Application error"); - } else { + if ($this->User->idClient == 1) { throw new SoapFault('ERR', $e->getMessage()); + } else { + throw new SoapFault('ERR', "Application error"); } } @@ -1540,10 +1540,10 @@ class Saisie extends Scores_Ws_Server try { $id = $bilansM->update($dataToUpdate, 'id = '.$row->id); } catch (Zend_Db_Exception $e) { - if ($this->User->idClient!=1) { - throw new SoapFault('ERR', "Application error"); - } else { + if ($this->User->idClient == 1) { throw new SoapFault('ERR', $e->getMessage()); + } else { + throw new SoapFault('ERR', "Application error"); } } @@ -1566,10 +1566,10 @@ class Saisie extends Scores_Ws_Server 'postesDiff' => implode(';', $postesDiff), )); } catch (Zend_Db_Exception $e) { - if ($this->User->idClient!=1) { - throw new SoapFault('ERR', "Application error"); - } else { + if ($this->User->idClient == 1) { throw new SoapFault('ERR', $e->getMessage()); + } else { + throw new SoapFault('ERR', "Application error"); } }