diff --git a/application/controllers/IdentiteController.php b/application/controllers/IdentiteController.php index 1fc84929d..026e01884 100644 --- a/application/controllers/IdentiteController.php +++ b/application/controllers/IdentiteController.php @@ -1619,7 +1619,7 @@ class IdentiteController extends Zend_Controller_Action { //Vérification des permissions $user = new Scores_Utilisateur(); - if( $user->getIdClient()!=1 /*!$user->checkPerm('avisrncs')*/ ){ + if( !$user->checkPerm('avisrncs') ){ $this->forward('perms', 'error'); } @@ -1755,8 +1755,8 @@ class IdentiteController extends Zend_Controller_Action $this->view->assign('Origine', '-'); } - $this->view->assign('Activite', $result->Activite); - $this->view->assign('BodaccActivite', $result->BodaccActivite); + $this->view->assign('Activite', $result->NafCode.' : '.$result->NafLabel); + $this->view->assign('BodaccActivite', $result->Activite); if ( $result->ActiviteDate === null || $result->ActiviteDate == '0000-00-00 00:00:00') { $this->view->assign('ActiviteDate', ''); @@ -1791,4 +1791,365 @@ class IdentiteController extends Zend_Controller_Action } } + /** + * Avis de situation RNCS au format PDF + */ + public function avisrncspdfAction() + { + $this->_helper->layout()->disableLayout(); + $this->_helper->viewRenderer->setNoRender(true); + + //Vérification des permissions + $user = new Scores_Utilisateur(); + if ( !$user->checkPerm('avisrncs') ) { + $this->forward('perms', 'error'); + } + + $request = $this->getRequest(); + + $this->view->assign('siret', $this->siret); + $siren = substr($this->siret, 0, 9); + + $infos = null; + + $ws = new WsScores(); + $result = $ws->getEntrepriseAvisRncs($siren); + Zend_Registry::get('firebug')->info($result); + + if ( $result === false ) { + $this->view->assign('error', true); + } + elseif ( is_string($result) ) { + $this->view->assign('message', $result); + } else { + // --- Variables + $locale = new Zend_Locale('fr_FR'); + + $date = new Zend_Date(); + $AvisDateTxt = $date->toString(Zend_Date::DATE_LONG); + + if ($result->RadiationDate !== null && $result->RadiationDate != '0000-00-00' ) { + $date = new Zend_Date($result->RadiationDate, 'yyyy-MM-dd'); + $RadiationDate = $date->toString('dd/MM/yyyy'); + } + + $Nom = $result->Nom; + $Sigle = $result->Sigle; + $Enseigne = $result->Enseigne; + $NomCommercial = $result->NomCommercial; + $Siren = $result->Siren; + $Tribunal = $result->TribunalLabel; + + $NumGest = $result->NumGest; // 4 ou 2 + 1 lettre + + + if ($result->ImmatDate === null || $result->ImmatDate=='0000-00-00 00:00:00' ) { + $ImmatDate = ''; + } else { + $date = new Zend_Date($result->ImmatDate, 'yyyy-MM-dd'); + $ImmatDate = $date->toString('dd/MM/yyyy'); + } + + $FormeJuridique = $result->FjLabel; + $Capital = number_format($result->Capital, 0, ',', ' ').' '.$result->CapitalDev; + $SiegeAdresse = $result->SiegeAdresseNum . ' ' . + $result->SiegeAdresseVoieType . ' ' . + $result->SiegeAdresseVoieLabel . ' ' . + $result->SiegeAdresseCP . ' ' . + $result->SiegeAdresseVille; + + + if ( $result->CompteArretMois === null ) { + $CompteArretDate = ''; + } else { + $date = new Zend_Date(); + $date->set($result->CompteArretMois, Zend_Date::MONTH, $locale); + $CompteArretDate = $result->CompteArretJour . ' ' . $date->toString(Zend_Date::MONTH_NAME); + } + + if ( $result->ConstitutionDepotDate === null || $result->ConstitutionDepotDate == '0000-00-00 00:00:00') { + $ConstitutionDepotDate = '-'; + } else { + $date = new Zend_Date($result->ConstitutionDepotDate, 'yyyy-MM-dd'); + $ConstitutionDepotDate = $date->toString('dd/MM/yyyy'); + } + + if ( $result->ConstitutionActeDate === null || $result->ConstitutionActeDate == '0000-00-00 00:00:00') { + $ConstitutionActeDate = '-'; + } else { + $date = new Zend_Date($result->ConstitutionActeDate, 'yyyy-MM-dd'); + $ConstitutionActeDate = $date->toString('dd/MM/yyyy'); + } + + $administration = array(); + foreach ($result->Administration->item as $item) { + + $lineP1 = $item->Label; + + if ( $item->CompanyName != '' ) { + $lineP2 = $item->CompanyName; + if ( intval($item->CompanyId) != 0 ) { + $lineP2.= ' ('.$item->CompanyId.')'; + } + } else { + $lineP2 = $item->Civilite . ' ' . $item->Nom . ' ' . $item->Prenom; + if ( $item->NaissanceDate != '' ) { + $lineP2.= ' né le ' . $item->NaissanceDate; + } + if ( $item->NaissanceVille != '' ) { + $lineP2.= ' à ' . $item->NaissanceVille; + } + if ( $item->NaissanceCp!= '' ) { + $lineP2.= ' (' . $item->NaissanceCp . ')'; + } + } + + $administration[] = array( + 'Fct' => $lineP1, + 'Txt' => $lineP2, + ); + } + $Administration = $administration; + + $tabCreation = array( + 'a1' => 'Création', + 'a2' => 'Création suite à déménagement', + 'a3' => 'Achat', + 'a4' => 'Apport', + 'a6' => 'Prise en location gérance', + 'a7' => 'Partage', + 'a8' => 'Reprise', + 'aA' => 'Reprise globale de l\'exploitation agricole', + 'aB' => 'Poursuite de l\'exploitation agricole par le conjoint', + 'aC' => 'Transfert de propriété de l\'exploitation agricole', + 'aD' => 'Apport d\'exploitation(s) agricole(s) individuelle(s)', + 'aE' => 'Reprise d\'exploitation agricole individuelle', + ); + + $OrigineCreaction = $result->Origine; + + if ( ( $OrigineCreaction*1>0 && $OrigineCreaction*1<9 ) + || in_array($OrigineCreaction, array('A', 'B', 'C', 'D', 'E')) ){ + $Origine = $tabCreation['a'.$OrigineCreaction]; + } else { + $Origine = '-'; + } + + $Activite = $result->NafCode.' : '.$result->NafLabel; + $BodaccActivite = $result->Activite; + + if ( $result->ActiviteDate === null || $result->ActiviteDate == '0000-00-00 00:00:00') { + $ActiviteDate = ''; + } else { + $date = new Zend_Date($result->ActiviteDate, 'yyyy-MM-dd'); + $ActiviteDate = $date->toString('dd/MM/yyyy'); + } + + $tabTypeExploitation = array( + 0 => "-", + 1 => "Locataire du fond de commerce", + 2 => "Loueur du fond de commerce", + 3 => "Prestation de personnel", + 10 => "Exploitation directe" + ); + $Exploitation = $tabTypeExploitation[$result->Exploitation]; + + $Evenements = $result->Evenements->item; + + $Depots = $result->Depots->item; + + $Etablissements = $result->Etablissements->item; + + if ( $result->DateMajRCS === null || $result->DateMajRCS == '0000-00-00 00:00:00') { + $DateMajRCS = ''; + } else { + $date = new Zend_Date($result->DateMajRCS, 'yyyy-MM-dd'); + $DateMajRCS = $date->toString('dd/MM/yyyy'); + } + + // --- Création du PDF + $c = Zend_Registry::get('config'); + $filepdf = $c->profil->path->files.'/avisrncs-'.$siren.'.pdf'; + try { + $pdf = new Scores_Pdf_Tcpdf(); + $pdf->SetBackgroundImage('libs/modeles/avisrncs.jpg'); + $pdf->SetProtection(array('modify', 'copy'), '', null, 0, null); + $pdf->SetCreator("Scores & Décisions"); + $pdf->SetAuthor("Scores & Décisions"); + $pdf->SetTitle('Avis de Situation RNCS'); + $pdf->SetSubject('Avis de Situation RNCS'); + + $pdf->SetAutoPageBreak(true, 0); + $pdf->AddPage(); + + $pdf->SetFont('times', '', 12); + $pdf->setColorArray('fill', array(0,0,140)); + $pdf->setColorArray('text', array(255,255,255)); + $pdf->Cell(0, 0, "AVIS DE SITUATION RNCS", 0, 1, 'C', true); + $pdf->Cell(0, 0, "", 0, 1, 'L'); + + $pdf->SetFont('times', '', 10); + $pdf->setColorArray('text', array(0,0,0)); + $pdf->Cell(0, 0, "REGISTRE NATIONAL DU COMMERCES ET DES SOCIETES", 0, 1, 'C'); + $pdf->Cell(0, 0, "", 0, 1, 'L'); + $pdf->Cell(0, 0, "Avis en date du ".$AvisDateTxt, 0, 1, 'C'); + $pdf->Cell(0, 0, "", 0, 1, 'L'); + + $border = array('B' => array('width' => 0.1, 'cap' => 'butt', 'join' => 'miter', 'dash' => 0, 'color' => array(0, 0, 0))); + $pdf->SetFont('times', 'B', 10); + $pdf->Cell(0, 0, "IDENTIFICATION", $border, 1, 'L'); + $pdf->SetFont('times', '', 10); + $pdf->Ln(1); + if ($RadiationDate) { + //@todo : Couleur texte rouge + $pdf->Cell(0, 0, "Cette entreprise est radiée au RNCS.", 0, 1, 'C'); + } + $pdf->Cell(0, 0, "Dénomination sociale : ".$Nom, 0, 1, 'L'); + if( empty($Sigle) ) { + $pdf->Cell(0, 0, "Sigle : -", 0, 1, 'L'); + } else { + $pdf->Cell(0, 0, "Sigle : ".$Sigle, 0, 1, 'L'); + } + if( empty($Enseigne) ) { + $pdf->Cell(0, 0, "Enseigne : -", 0, 1, 'L'); + } else { + $pdf->Cell(0, 0, "Enseigne : ".$Enseigne, 0, 1, 'L'); + } + if( empty($Sigle) ) { + $pdf->Cell(0, 0, "Nom Commercial : -", 0, 1, 'L'); + } else { + $pdf->Cell(0, 0, "Nom Commercial : ".$NomComercial, 0, 1, 'L'); + } + $pdf->Cell(0, 0, "Numéro d'identification : ".$Siren." RCS ".$Tribunal, 0, 1, 'L'); + $pdf->Cell(0, 0, "Numéro de gestion : ".$NumGest, 0, 1, 'L'); + $pdf->Cell(0, 0, "Date d'immatriculation : ".$ImmatDate, 0, 1, 'L'); + if ($RadiationDate) { + $pdf->Cell(0, 0, "", 0, 1, 'L'); + $pdf->Cell(0, 0, "Date de radiation : $RadiationDate", 0, 1, 'L'); + } else { + $pdf->Cell(0, 0, "", 0, 1, 'L'); + + $pdf->SetFont('times', 'B', 10); + $pdf->Cell(0, 0, "RENSEIGNEMENT RELATIF A L'IDENTITE", $border, 1, 'L'); + $pdf->SetFont('times', '', 10); + $pdf->Ln(1); + $pdf->Cell(0, 0, "Forme Juridique : $FormeJuridique", 0, 1, 'L'); + $pdf->Cell(0, 0, "Au capital de : $Capital", 0, 1, 'L'); + $pdf->Cell(0, 0, "Adresse du siège : $SiegeAdresse", 0, 1, 'L'); + $pdf->Cell(0, 0, "Date d’arrêté des comptes : $CompteArretDate", 0, 1, 'L'); + $pdf->Cell(0, 0, "Constitution : $ConstitutionActeDate", 0, 1, 'L'); + $pdf->Cell(0, 0, "Dépôt de l'acte constitutif: $ConstitutionDepotDate", 0, 1, 'L'); + $pdf->Cell(0, 0, "", 0, 1, 'L'); + + $pdf->SetFont('times', 'B', 10); + $pdf->Cell(0, 0, "ADMINISTRATION", $border, 1, 'L'); + $pdf->SetFont('times', '', 10); + $pdf->Ln(1); + foreach ( $Administration as $item ) { + $pdf->Cell(0, 0, $item['Fct']." : ".$item['Txt'], 0, 1, 'L'); + } + $pdf->Cell(0, 0, "", 0, 1, 'L'); + + $pdf->SetFont('times', 'B', 10); + $pdf->Cell(0, 0, "RENSEIGNEMENT RELATIF A L'ACTIVITE", $border, 1, 'L'); + $pdf->SetFont('times', '', 10); + $pdf->Ln(1); + $pdf->Cell(0, 0, "Origine de la société $Origine", 0, 1, 'L'); + $pdf->MultiCell(0, 0, "Activité : $Activite", 0, 'L', 0, 1); + $pdf->MultiCell(0, 0, "Activité déclarée au BODACC : $BodaccActivite", 0, 'L', 0, 1); + $pdf->Cell(0, 0, "Commencement de l'activité : $ActiviteDate", 0, 1, 'L'); + $pdf->Cell(0, 0, "Mode d'exploitation : $Exploitation", 0, 1, 'L'); + $pdf->Cell(0, 0, "", 0, 1, 'L'); + + $pdf->SetFont('times', 'B', 10); + $pdf->Cell(0, 0, "JUGEMENTS RNCS", $border, 1, 'L'); + $pdf->SetFont('times', '', 10); + $pdf->Ln(1); + $pdf->Cell(0, 0, "Evénements :", 0, 1, 'L'); + //$pdf->SetMargins(50, 0); + if (count($Evenements)>0) { + foreach ( $Evenements as $item ) { + $pdf->Cell(0, 0, $item, 0, 1, 'L'); + } + } else { + $pdf->SetX($pdf->GetX() + 20); + $pdf->Cell(0, 0, "Néant.", 0, 1, 'L'); + } + $pdf->Cell(0, 0, "", 0, 1, 'L'); + //$pdf->SetMargins(0, 0); + + $pdf->SetFont('times', 'B', 10); + $pdf->Cell(0, 0, "DEPOT LEGAL", $border, 1, 'L'); + $pdf->SetFont('times', '', 10); + $pdf->Ln(1); + $pdf->Cell(0, 0, "Décisions :", 0, 1, 'L'); + if ( count($Depots)>0 ) { + foreach ( $Depots as $item ) { + $depot = "Acte n°".$item->ActeNum; + if ( $item->ActeDate != '0000-00-00' ) { + $depot.= " du ".substr($item->ActeDate,8,2)."/".substr($item->ActeDate,5,2)."/".substr($item->ActeDate,0,4); + } + $depot.= " - Depot n°".$item->DepotNum." du ".substr($item->DepotDate,8,2)."/".substr($item->DepotDate,5,2)."/".substr($item->DepotDate,0,4); + $pdf->SetX($pdf->GetX() + 20); + $pdf->Cell(0, 0, $depot, 0, 1, 'L'); + $pdf->SetX($pdf->GetX() + 20); + $pdf->Cell(0, 0, $item->ActeTypeLabel, 0, 1, 'L'); + foreach ($item->infos->item as $detail) { + $pdf->SetX($pdf->GetX() + 20); + $pdf->Cell(0, 0, $detail, 0, 1, 'L'); + } + $pdf->Ln(2); + } + $pdf->Ln(1); + $pdf->SetFont('times', 'I', 10); + $pdf->Cell(0, 0, "Liste non exhaustive", 0, 1, 'L'); + } + $pdf->Cell(0, 0, "", 0, 1, 'L'); + + $pdf->SetFont('times', 'B', 10); + $pdf->Cell(0, 0, "AUTRES ETABLISSEMENTS", $border, 1, 'L'); + $pdf->SetFont('times', '', 10); + $pdf->Ln(1); + $pdf->Cell(0, 0, "Liste des établissements actifs :", 0, 1, 'L'); + $pdf->Ln(1); + foreach ( $Etablissements as $etab ) { + $pdf->SetX($pdf->GetX() + 20); + $pdf->Cell(0, 0, $etab, 0, 1, 'L'); + $pdf->Ln(1); + } + } + + $pdf->SetFont('times', '', 10); + $pdf->Cell(0, 0, "", 0, 1, 'L'); + $pdf->Cell(0, 0, "Fin de l'avis de situation", 0, 1, 'C'); + $pdf->Cell(0, 0, "", 0, 1, 'L'); + $cgu = "Informations légales issues des données du Registre National du Commerce et des Sociétés". + "issues de licence 2 dite de distribution RNCS IMR pour Scores & Decisions SAS contractée le 20 novembre 2009\n". + "Scores & Decisions SAS est rediffuseur officiel du RNCS et propose un service privé, distinct du Registre public cité."; + $pdf->SetFont('times', 'I', 8); + $pdf->MultiCell(0, 0, $cgu, 0, 'L', 0, 1); + + + $pdf->Output($filepdf, 'F'); + + } catch(Exception $e) { + echo "Erreur à la création du PDF"; + } + // --- Fin création PDF + $content_type = 'application/pdf'; + if(file_exists($filepdf) && filesize($filepdf)>0) { + header('Content-Transfer-Encoding: none'); + header('Content-type: ' . $content_type.''); + header('Content-Length: ' . filesize($filepdf)); + header('Content-MD5: ' . base64_encode(md5_file($filepdf))); + header('Content-Disposition: filename="' . basename($filepdf) . '"'); + header('Cache-Control: private, max-age=0, must-revalidate'); + header('Pragma: public'); + ini_set('zlib.output_compression', '0'); + echo file_get_contents($filepdf); + } else { + echo "Erreur lors de l'affichage du fichier."; + } + } + } + } \ No newline at end of file diff --git a/application/views/default/scripts/identite/avisrncs.phtml b/application/views/default/scripts/identite/avisrncs.phtml index bbd1025a3..cab405283 100644 --- a/application/views/default/scripts/identite/avisrncs.phtml +++ b/application/views/default/scripts/identite/avisrncs.phtml @@ -69,7 +69,7 @@ div.avisrncs-footer p { margin:0; padding:0; }
=$item['Fct']?> : =$item['Txt']?>
-Origine de la société : =$this->Origine?>
Activité : =$this->Activite?>
diff --git a/application/views/default/scripts/identite/avisrncspdf.phtml b/application/views/default/scripts/identite/avisrncspdf.phtml new file mode 100644 index 000000000..94cef108f --- /dev/null +++ b/application/views/default/scripts/identite/avisrncspdf.phtml @@ -0,0 +1,61 @@ +AutrePage)) {?> +Avis de situtation RNCS édité le =$this->AvisDateTxt?>
+=$this->translate("REGISTRE NATIONAL DU COMMERCES ET DES SOCIETES")?>
+=$this->translate("Avis en date du ")?>=$this->AvisDateTxt?>
+Cette entreprise est radiée au RNCS.
+ + +Dénomination sociale : =$this->Nom?>
+Sigle : =$this->Sigle?>
+Enseigne : =$this->Enseigne?>
+Nom Commercial : =$this->NomComercial?>
+Numéro d'identification : =$this->SirenTexte($this->Siren)?> RCS =$this->Tribunal?>
+Numéro de gestion : =$this->NumGest?>
+Date d'immatriculation : =$this->ImmatDate?>
+ +RadiationDate) {?> +Date de radiation : =$this->RadiationDate?>
+ + + + +AutrePage)) {?> +