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; }

:

-

translate("RENSEIGNEMENT RELATIFS A L'ACTIVITE")?>

+

translate("RENSEIGNEMENT RELATIF A L'ACTIVITE")?>

Origine de la société : Origine?>

Activité : 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)) {?> +
+ + +error ) {?> + +
+Erreur +
+ +message ) {?> + + message?> + + + + + +
+
+

Avis de situtation RNCS édité le AvisDateTxt?>

+
+
+ +
+

translate("AVIS DE SITUATION RNCS")?>

+

translate("REGISTRE NATIONAL DU COMMERCES ET DES SOCIETES")?>

+

translate("Avis en date du ")?>AvisDateTxt?>

+
+ +
+
+

translate("IDENTIFICATION")?>

+ +RadiationDate) {?> +

Cette entreprise est radiée au RNCS.

+ + +

Dénomination sociale : Nom?>

+

Sigle : Sigle?>

+

Enseigne : Enseigne?>

+

Nom Commercial : NomComercial?>

+

Numéro d'identification : SirenTexte($this->Siren)?> RCS Tribunal?>

+

Numéro de gestion : NumGest?>

+

Date d'immatriculation : ImmatDate?>

+ +RadiationDate) {?> +

Date de radiation : RadiationDate?>

+ + + + +AutrePage)) {?> +
+ \ No newline at end of file diff --git a/library/Scores/IdentiteEntreprise.php b/library/Scores/IdentiteEntreprise.php index e80603e49..fd25d2f65 100644 --- a/library/Scores/IdentiteEntreprise.php +++ b/library/Scores/IdentiteEntreprise.php @@ -358,8 +358,8 @@ class IdentiteEntreprise { $user = new Scores_Utilisateur(); $data = ''; - if ( intval($this->identite->Siren)!=0 && $user->getIdClient()==1 /*$user->checkPerm('avisrncs')*/ ) { - $data ='Situation au répertoire RNCS'; } diff --git a/library/Scores/Pdf/Fpdi.php b/library/Scores/Pdf/Fpdi.php new file mode 100644 index 000000000..bd1496186 --- /dev/null +++ b/library/Scores/Pdf/Fpdi.php @@ -0,0 +1,30 @@ +_tplIdx)) { + $this->setSourceFile($template); + $this->_tplIdx = $this->importPage(1); + } + $this->useTemplate($this->_tplIdx); + } + + function Footer() + { + // emtpy method body + } +} \ No newline at end of file diff --git a/library/Scores/Pdf/Page.php b/library/Scores/Pdf/Page.php new file mode 100644 index 000000000..08b32b803 --- /dev/null +++ b/library/Scores/Pdf/Page.php @@ -0,0 +1,65 @@ +getFont() ; + $font_size = $this->getFontSize() ; + // initialisation des tableaux + $glyph_array = $char_array = array(); + $total_item_width = 0; + // on converti le texte en tableau et on récupère les codes ASCII + $text_array = str_split($text_line, 1); + foreach($text_array as $character) { + $char_array[] = ord($character); + } + // on récupère ensuite le numéro du glyphe d'après le code ASCII + $glyph_array = $current_font->glyphNumbersForCharacters($char_array) ; + // Zend_Pdf_Font nous permet de récupérer la largeur des glyphes + $text_width = $current_font->widthsForGlyphs($glyph_array); + // on additionne tous les caractères pour obtenir la largeur totale + foreach($text_width as $char_width) { + $total_item_width += $char_width; + } + // petite transformation pour obtenir notre taille en quelque chose d'utilisable + return ($total_item_width / 1000) * $font_size; + } + + /** + * Dessine du texte aligné à droite de $x + */ + public function drawTextAlignRight($text, $x, $y) + { + $width = $this->_getTextWidth($text) ; + // on écrit le texte à la position donnée - la largeur du texte + $this->drawText($text, $x - $width, $y) ; + } + + /** + * Dessine du texte centré sur $x + */ + public function drawTextAlignCenter($text, $x, $y) + { + $width = $this->_getTextWidth($text) ; + // on écrit le texte à la position donnée - la moitié de la largeur du texte + $this->drawText($text, $x - ($width / 2), $y) ; + } + + /** + * + * @param number $bottom + */ + public function heightWithMargin($bottom = 0) + { + $current_font = $this->getFont(); + return $current_font->getLineHeight() + $bottom; + } + + +} \ No newline at end of file diff --git a/library/Scores/Pdf/Tcpdf.php b/library/Scores/Pdf/Tcpdf.php new file mode 100644 index 000000000..3504607ac --- /dev/null +++ b/library/Scores/Pdf/Tcpdf.php @@ -0,0 +1,50 @@ +bgimage = $file; + } + + /** + * (non-PHPdoc) + * @see TCPDF::Header() + */ + public function Header() + { + if ($this->bgimage) { + // get the current page break margin + $bMargin = $this->getBreakMargin(); + // get current auto-page-break mode + $auto_page_break = $this->AutoPageBreak; + // disable auto-page-break + $this->SetAutoPageBreak(false, 0); + // set bacground image + $this->Image($this->bgimage, 0, 0, 210, 297, '', '', '', false, 300, '', false, false, 0); + // restore auto-page-break status + $this->SetAutoPageBreak($auto_page_break, 20); + // set the starting point for the page content + $this->setPageMark(); + } + } + + /** + * (non-PHPdoc) + * @see TCPDF::Footer() + */ + public function Footer() + { + // Position at 15 mm from bottom + $this->SetY(-15); + // Set font + $this->SetFont('helvetica', 'I', 8); + // Page number + $this->Cell(0, 10, 'Page '.$this->getAliasNumPage().'/'.$this->getAliasNbPages(), 0, false, 'C', 0, '', 0, false, 'T', 'M'); + } + + +} \ No newline at end of file diff --git a/public/libs/modeles/avisrncs.jpg b/public/libs/modeles/avisrncs.jpg new file mode 100644 index 000000000..cce00ae3b Binary files /dev/null and b/public/libs/modeles/avisrncs.jpg differ diff --git a/public/libs/modeles/avisrncs.pdf b/public/libs/modeles/avisrncs.pdf new file mode 100644 index 000000000..7a18545a9 Binary files /dev/null and b/public/libs/modeles/avisrncs.pdf differ