Correction diverse + réimport version pdf
This commit is contained in:
parent
4428e5b75c
commit
1b1bd63090
@ -1,11 +1,5 @@
|
||||
<?php
|
||||
require_once 'infogreffe/constantes.php';
|
||||
require_once 'dbbootstrap.php';
|
||||
setDbConn('sdv1');
|
||||
|
||||
define('PCLZIP_TEMPORARY_DIR', PATH_DATA.'/courrier/');
|
||||
require_once 'lib/odtphp/library/odf.php';
|
||||
$odf = new odf(realpath(dirname(__FILE__).'/modeleLettreGreffe.odt'));
|
||||
$format = 'odt';
|
||||
|
||||
function normaliseVoie($txt)
|
||||
{
|
||||
@ -25,154 +19,404 @@ function normaliseVoie($txt)
|
||||
return strtr($txt, $replace_pairs);
|
||||
}
|
||||
|
||||
$info = new StdClass;
|
||||
$info->ref = $id;
|
||||
$typeCommande = substr($info->ref, 0, 1);
|
||||
$id = substr($info->ref, 1);
|
||||
require_once 'infogreffe/constantes.php';
|
||||
require_once 'dbbootstrap.php';
|
||||
setDbConn('sdv1');
|
||||
|
||||
if ($typeCommande == 'C') {
|
||||
$commande = Doctrine_Query::create()
|
||||
->from('Commandes')
|
||||
->andWhere('idCommande = ?', $id)
|
||||
->andWhere('typeCommande = ?', 'C')
|
||||
->fetchOne();
|
||||
if ($format == 'odt') {
|
||||
|
||||
define('PCLZIP_TEMPORARY_DIR', PATH_DATA.'/courrier/');
|
||||
require_once 'lib/odtphp/library/odf.php';
|
||||
$odf = new odf(realpath(dirname(__FILE__).'/modeleLettreGreffe.odt'));
|
||||
|
||||
$info = new StdClass;
|
||||
$info->ref = $id;
|
||||
$typeCommande = substr($info->ref, 0, 1);
|
||||
$id = substr($info->ref, 1);
|
||||
|
||||
if ($typeCommande == 'C') {
|
||||
$commande = Doctrine_Query::create()
|
||||
->from('Commandes')
|
||||
->andWhere('idCommande = ?', $id)
|
||||
->andWhere('typeCommande = ?', 'C')
|
||||
->fetchOne();
|
||||
|
||||
if (preg_match('/^([0-9]{4}_).*?$/', $commande->refDocument, $matches)) {
|
||||
$typeDocument = 'bilans';
|
||||
} else {
|
||||
$typeDocument = 'actes';
|
||||
}
|
||||
} else if ($typeCommande == 'K') {
|
||||
$commande = Doctrine_Query::create()
|
||||
->from('CommandesKbis')
|
||||
->andWhere('id = ?', $id)
|
||||
->fetchOne();
|
||||
|
||||
$typeDocument = 'kbis';
|
||||
}
|
||||
|
||||
require_once 'scoresws/scoresws.php';
|
||||
// Identite
|
||||
$siren = $commande->siren;
|
||||
$etab = scoresws_identite($siren, $siren, 0);
|
||||
$commune = $etab->codeCommune;
|
||||
$dept = $etab->Dept;
|
||||
$siret = $etab->Siret;
|
||||
$numRC = $etab->NumRC;
|
||||
|
||||
// Adresse du tribunal de commerce
|
||||
$competence = scorews_competences($siret, $siren, $idEntreprise, 'tri', $dept.$commune);
|
||||
$tribunalCode = $competence->Competence->item[0]->Code;
|
||||
$tribunalLib = $competence->Competence->item[0]->Nom;
|
||||
if (preg_match('/(A|B|C|D)/i', $numRC)) {
|
||||
$libTrib = ' RCS '.
|
||||
preg_replace('/(^TC |^TI |^TGIcc |^TMX )/i', '', $tribunalLib);
|
||||
} else if (preg_match('/(P)/i', $numRC)) {
|
||||
$libTrib = ' RSAC '.
|
||||
preg_replace('/(^TC |^TI |^TGIcc |^TMX )/i', '', $tribunalLib);
|
||||
}
|
||||
$info->siren =
|
||||
substr($siren, 0, 3).' '.
|
||||
substr($siren, 3, 3).' '.
|
||||
substr($siren, 6, 3);
|
||||
$info->nom = htmlspecialchars_decode($etab->Nom, ENT_QUOTES);
|
||||
$info->libTrib = $libTrib;
|
||||
$info->adresse = htmlspecialchars_decode($etab->Adresse, ENT_QUOTES).' ';
|
||||
if (empty($etab->Adresse2) == false) {
|
||||
$info->adresse .= $etab->Adresse2.' ';
|
||||
}
|
||||
$info->adresse .= "\n".$etab->CP.' '.$etab->Ville;
|
||||
$info->tribunal = $competence->Competence->item[0];
|
||||
|
||||
// Prix
|
||||
$tarifs = Doctrine_Query::create()
|
||||
->from('CommandesTarifs')
|
||||
->andWhere('codeTribunal = ?', $tribunalCode)
|
||||
->andWhere('type = ?', $typeDocument)
|
||||
->andWhere('annee = ?', date('Y'))
|
||||
->execute();
|
||||
|
||||
if ($tarifs->count() == 0) {
|
||||
echo 'Commande '.$commande->type.$commande->id.' - Pas de tarifs défini pour le tribunal '.
|
||||
$info->tribunal->Nom.' ('.$tribunalCode.')';
|
||||
exit;
|
||||
}
|
||||
$info->prix = number_format($tarifs[0]->prix, 2, ',', ' ');
|
||||
$info->enveloppe = $tarifs[0]->enveloppe;
|
||||
|
||||
// Destinataire
|
||||
$destinataire = "REGISTRE DU COMMERCE - GREFFE\n".
|
||||
normaliseVoie(trim($info->tribunal->Adr))."\n".
|
||||
normaliseVoie($info->tribunal->AdrComp)."\n".
|
||||
$info->tribunal->CP.' '.$info->tribunal->Ville."\n";
|
||||
|
||||
// Type de document demandé (actes ou bilans pour l'instant)
|
||||
// [un Kbis / l'état d'endettement / la copie de jugement de XXX en date du XXX]
|
||||
if ($typeDocument == 'bilans') {
|
||||
preg_match('/^[0-9]{4}_.*?-([0-9]{8}).*?/',
|
||||
$commande->refDocument, $matches);
|
||||
$sujet = 'une copie du bilan au '.
|
||||
substr($matches[1], 6, 2).'/'.
|
||||
substr($matches[1], 4, 2).'/'.
|
||||
substr($matches[1], 0, 4);
|
||||
} else if ($typeDocument == 'actes') {
|
||||
$sujet = 'une copie de l\'acte '.
|
||||
$typeActes['a'.substr($commande->refDocument,0,2)];
|
||||
if (empty($commande->libDocument) == false) {
|
||||
$sujet .= ' ('.$commande->libDocument.')';
|
||||
}
|
||||
$sujet .= ' en date du '.
|
||||
substr($commande->refDocument, 9, 2).'/'.
|
||||
substr($commande->refDocument, 7, 2).'/'.
|
||||
substr($commande->refDocument, 3, 4);
|
||||
} else if ($typeDocument == 'kbis') {
|
||||
$sujet = 'un extrait RCS';
|
||||
}
|
||||
|
||||
// Societe
|
||||
$societe = $info->nom."\n".'( '.$info->siren.$info->libTrib.' )'."\n";
|
||||
$societe .= normaliseVoie(htmlspecialchars_decode($info->adresse, ENT_QUOTES));
|
||||
|
||||
// Piece jointe et montant
|
||||
if ($info->enveloppe) {
|
||||
$montant = 'Ci-joint une enveloppe timbrée ainsi qu\'un '.
|
||||
'chèque d\'un montant de '.$info->prix.
|
||||
' euros en règlement de cette commande.';
|
||||
} else {
|
||||
$montant = 'Ci-joint un chèque d\'un montant de '.$info->prix.
|
||||
' euros en règlement de cette commande.';
|
||||
}
|
||||
|
||||
$path = PATH_DATA.'/courrier/';
|
||||
$file = $siren.'-'.$info->ref.'.odt';
|
||||
|
||||
$odf->setVars('destinataire', $destinataire, true, 'UTF-8');
|
||||
$odf->setVars('date', date('d/m/Y'), true, 'UTF-8');
|
||||
$odf->setVars('ref', $info->ref, true, 'UTF-8');
|
||||
$odf->setVars('sujet', $sujet, true, 'UTF-8');
|
||||
$odf->setVars('societe', $societe, true, 'UTF-8');
|
||||
$odf->setVars('montant', $montant, true, 'UTF-8');
|
||||
$odf->saveToDisk($path.$file);
|
||||
|
||||
if (file_exists($path.$file) == true) {
|
||||
header('Content-Transfer-Encoding: none');
|
||||
header('Content-type: application/vnd.oasis.opendocument.text');
|
||||
header('Content-Length: '.filesize($path.$file));
|
||||
header('Content-MD5: '.base64_encode(md5_file($path.$file)));
|
||||
header('Content-Disposition: attachment, filename="'.$file.'"');
|
||||
header('Cache-Control: private, max-age=0, must-revalidate');
|
||||
header('Pragma: public');
|
||||
ini_set('zlib.output_compression','0');
|
||||
print file_get_contents($path.$file);
|
||||
}
|
||||
|
||||
if (preg_match('/^([0-9]{4}_).*?$/', $commande->refDocument, $matches)) {
|
||||
$typeDocument = 'bilans';
|
||||
} else {
|
||||
$typeDocument = 'actes';
|
||||
}
|
||||
} else if ($typeCommande == 'K') {
|
||||
$commande = Doctrine_Query::create()
|
||||
->from('CommandesKbis')
|
||||
->andWhere('id = ?', $id)
|
||||
->fetchOne();
|
||||
} elseif ($format == 'pdf') {
|
||||
|
||||
$typeDocument = 'kbis';
|
||||
}
|
||||
|
||||
require_once 'scoresws/scoresws.php';
|
||||
// Identite
|
||||
$siren = $commande->siren;
|
||||
$etab = scoresws_identite($siren, $siren, 0);
|
||||
$commune = $etab->codeCommune;
|
||||
$dept = $etab->Dept;
|
||||
$siret = $etab->Siret;
|
||||
$numRC = $etab->NumRC;
|
||||
|
||||
// Adresse du tribunal de commerce
|
||||
$competence = scorews_competences($siret, $siren, $idEntreprise, 'tri', $dept.$commune);
|
||||
$tribunalCode = $competence['Code'];
|
||||
$tribunalLib = $competence['Nom'];
|
||||
if (preg_match('/(A|B|C|D)/i', $numRC)) {
|
||||
$libTrib = ' RCS '.
|
||||
preg_replace('/(^TC |^TI |^TGIcc |^TMX )/i', '', $tribunalLib);
|
||||
} else if (preg_match('/(P)/i', $numRC)) {
|
||||
$libTrib = ' RSAC '.
|
||||
preg_replace('/(^TC |^TI |^TGIcc |^TMX )/i', '', $tribunalLib);
|
||||
}
|
||||
$info->siren =
|
||||
substr($siren, 0, 3).' '.
|
||||
substr($siren, 3, 3).' '.
|
||||
substr($siren, 6, 3);
|
||||
$info->nom = htmlspecialchars_decode($etab->Nom, ENT_QUOTES);
|
||||
$info->libTrib = $libTrib;
|
||||
$info->adresse = htmlspecialchars_decode($etab->Adresse, ENT_QUOTES).' ';
|
||||
if (empty($etab->Adresse2) == false) {
|
||||
$info->adresse .= $etab->Adresse2.' ';
|
||||
}
|
||||
$info->adresse .= "\n".$etab->CP.' '.$etab->Ville;
|
||||
$info->tribunal = $competence;
|
||||
|
||||
// Prix
|
||||
$tarifs = Doctrine_Query::create()
|
||||
->from('CommandesTarifs')
|
||||
->andWhere('codeTribunal = ?', $tribunalCode)
|
||||
->andWhere('type = ?', $typeDocument)
|
||||
->andWhere('annee = ?', date('Y'))
|
||||
->execute();
|
||||
|
||||
if ($tarifs->count() == 0) {
|
||||
echo 'Commande '.$commande->type.$commande->id.' - Pas de tarifs défini pour le tribunal '.
|
||||
$info->tribunal['Nom'].' ('.$tribunalCode.')';
|
||||
exit;
|
||||
}
|
||||
$info->prix = number_format($tarifs[0]->prix, 2, ',', ' ');
|
||||
$info->enveloppe = $tarifs[0]->enveloppe;
|
||||
|
||||
// Destinataire
|
||||
/*
|
||||
$destinataire =
|
||||
strtr($info->tribunal['Nom'],
|
||||
array('TGI' => 'TRIBUNAL DE GRANDE INSTANCE DE',
|
||||
'TI' => 'TRIBUNAL D\'INSTANCE DE',
|
||||
'TC' => 'TRIBUNAL DE COMMERCE DE',
|
||||
'TGIcc' =>
|
||||
'TRIBUNAL DE GRANDE INSTANCE A COMPETENCE COMMERCIALE DE')
|
||||
);
|
||||
$destinataire .= "\n";
|
||||
*/
|
||||
$destinataire = "REGISTRE DU COMMERCE - GREFFE\n".
|
||||
normaliseVoie(trim($info->tribunal['Adr']))."\n".
|
||||
normaliseVoie($info->tribunal['AdrComp'])."\n".
|
||||
$info->tribunal['CP'].' '.$info->tribunal['Ville']."\n";
|
||||
|
||||
// Type de document demandé (actes ou bilans pour l'instant)
|
||||
// [un Kbis / l'état d'endettement / la copie de jugement de XXX en date du XXX]
|
||||
if ($typeDocument == 'bilans') {
|
||||
preg_match('/^[0-9]{4}_.*?-([0-9]{8}).*?/',
|
||||
$commande->refDocument, $matches);
|
||||
$sujet = 'une copie du bilan au '.
|
||||
substr($matches[1], 6, 2).'/'.
|
||||
substr($matches[1], 4, 2).'/'.
|
||||
substr($matches[1], 0, 4);
|
||||
} else if ($typeDocument == 'actes') {
|
||||
$sujet = 'une copie de l\'acte '.
|
||||
$typeActes['a'.substr($commande->refDocument,0,2)];
|
||||
if (empty($commande->libDocument) == false) {
|
||||
$sujet .= ' ('.$commande->libDocument.')';
|
||||
}
|
||||
$sujet .= ' en date du '.
|
||||
substr($commande->refDocument, 9, 2).'/'.
|
||||
substr($commande->refDocument, 7, 2).'/'.
|
||||
substr($commande->refDocument, 3, 4);
|
||||
} else if ($typeDocument == 'kbis') {
|
||||
$sujet = 'un extrait RCS';
|
||||
}
|
||||
|
||||
// Societe
|
||||
$societe = $info->nom."\n".'( '.$info->siren.$info->libTrib.' )'."\n";
|
||||
$societe .= normaliseVoie(htmlspecialchars_decode($info->adresse, ENT_QUOTES));
|
||||
|
||||
// Piece jointe et montant
|
||||
if ($info->enveloppe) {
|
||||
$montant = 'Ci-joint une enveloppe timbrée ainsi qu\'un '.
|
||||
'chèque d\'un montant de '.$info->prix.
|
||||
' euros en règlement de cette commande.';
|
||||
} else {
|
||||
$montant = 'Ci-joint un chèque d\'un montant de '.$info->prix.
|
||||
' euros en règlement de cette commande.';
|
||||
}
|
||||
|
||||
$path = PATH_DATA.'/courrier/';
|
||||
$file = $siren.'-'.$info->ref.'.odt';
|
||||
|
||||
$odf->setVars('destinataire', $destinataire, true, 'UTF-8');
|
||||
$odf->setVars('date', date('d/m/Y'), true, 'UTF-8');
|
||||
$odf->setVars('ref', $info->ref, true, 'UTF-8');
|
||||
$odf->setVars('sujet', $sujet, true, 'UTF-8');
|
||||
$odf->setVars('societe', $societe, true, 'UTF-8');
|
||||
$odf->setVars('montant', $montant, true, 'UTF-8');
|
||||
$odf->saveToDisk($path.$file);
|
||||
|
||||
if (file_exists($path.$file) == true) {
|
||||
header('Content-Transfer-Encoding: none');
|
||||
header('Content-type: application/vnd.oasis.opendocument.text');
|
||||
header('Content-Length: '.filesize($path.$file));
|
||||
header('Content-MD5: '.base64_encode(md5_file($path.$file)));
|
||||
header('Content-Disposition: attachment, filename="'.$file.'"');
|
||||
header('Cache-Control: private, max-age=0, must-revalidate');
|
||||
header('Pragma: public');
|
||||
ini_set('zlib.output_compression','0');
|
||||
print file_get_contents($path.$file);
|
||||
// just require TCPDF instead of FPDF
|
||||
require_once 'lib/tcpdf/tcpdf.php';
|
||||
require_once 'lib/fpdi/fpdi.php';
|
||||
|
||||
class PDF extends FPDI {
|
||||
/**
|
||||
* "Remembers" the template id of the imported page
|
||||
*/
|
||||
var $_tplIdx;
|
||||
|
||||
/**
|
||||
* include a background template for every page
|
||||
*/
|
||||
function Header() {
|
||||
if (is_null($this->_tplIdx)) {
|
||||
$this->setSourceFile(PATH_SITE.'/includes/courrier/modele.pdf');
|
||||
$this->_tplIdx = $this->importPage(1);
|
||||
}
|
||||
$this->useTemplate($this->_tplIdx);
|
||||
}
|
||||
|
||||
function Footer() {}
|
||||
}
|
||||
|
||||
$pdfInfo = new StdClass();
|
||||
$pdfInfo->ref = $id;
|
||||
$typeCommande = substr($pdfInfo->ref, 0, 1);
|
||||
$id = substr($pdfInfo->ref, 1);
|
||||
|
||||
if ( $typeCommande == 'C' ) {
|
||||
|
||||
// => Info Commande
|
||||
$q = Doctrine_Query::create()
|
||||
->from('Commandes')
|
||||
->where('idCommande = ?', $id)
|
||||
->andWhere('typeCommande = ?', 'C');
|
||||
|
||||
$commande = $q->fetchOne();
|
||||
if( preg_match('/^([0-9]{4}_).*?$/', $commande->refDocument, $matches) )
|
||||
{
|
||||
$typeDocument = 'bilans';
|
||||
}
|
||||
else
|
||||
{
|
||||
$typeDocument = 'actes';
|
||||
}
|
||||
|
||||
} elseif ( $typeCommande == 'K'){
|
||||
// => Info Commande
|
||||
$q = Doctrine_Query::create()
|
||||
->from('CommandesKbis')
|
||||
->where('id = ?', $id)
|
||||
->andWhere('type = ?', 'C');
|
||||
|
||||
$commande = $q->fetchOne();
|
||||
$typeDocument = 'kbis';
|
||||
}
|
||||
|
||||
|
||||
// => Identite
|
||||
$siren = $commande->siren;
|
||||
|
||||
$O = $client->getIdentite($siren, '', false);
|
||||
$etab = $O['result'];
|
||||
$codeCommune = $etab['codeCommune'];
|
||||
$dept = $etab['Dept'];
|
||||
$siret = $etab['Siret'];
|
||||
$numRC = $etab['NumRC'];
|
||||
|
||||
//Adresse du tribunal de commerce
|
||||
$O = $client->getListeCompetences($siret, 'tri', $dept.$codeCommune);
|
||||
$competences = $O['result'];
|
||||
$competence = $competences[0];
|
||||
|
||||
$tribunalCode = $competence['Code'];
|
||||
$tribunalLib = $comptence['Nom'];
|
||||
if (preg_match('/(A|B|C|D)/i', $numRC))
|
||||
{
|
||||
$libTrib = ' RCS '.preg_replace('/(^TC |^TI |^TGIcc |^TMX )/i','',$tribunalLib);
|
||||
}
|
||||
elseif (preg_match('/(P)/i', $numRC))
|
||||
{
|
||||
$libTrib = ' RSAC '.preg_replace('/(^TC |^TI |^TGIcc |^TMX )/i','',$tribunalLib);
|
||||
}
|
||||
|
||||
$pdfInfo->siren = substr($siren, 0, 3).' '.
|
||||
substr($siren, 3, 3).' '.
|
||||
substr($siren, 6, 3);
|
||||
$pdfInfo->nom = $etab['Nom'];
|
||||
$pdfInfo->libTrib = $libTrib;
|
||||
$pdfInfo->adresse[] = $etab['Adresse'];
|
||||
$pdfInfo->adresse[] = $etab['Adresse2'];
|
||||
$pdfInfo->adresse[] = $etab['CP'].' '.$etab['Ville'];
|
||||
|
||||
$pdfInfo->tribunal = $competence;
|
||||
|
||||
//Prix
|
||||
$q = Doctrine_Query::create()
|
||||
->from('CommandesTarifs')
|
||||
->where('codeTribunal = ?', $tribunalCode)
|
||||
->andWhere('type = ?', $typeDocument)
|
||||
->andWhere('annee = ?', date('Y'));
|
||||
$tarifs = $q->execute();
|
||||
|
||||
$firephp->log($tarifs->toArray(),'tarifs');
|
||||
|
||||
if($tarifs->count()==0)
|
||||
{
|
||||
echo 'Pas de tarifs défini pour le tribunal '.
|
||||
$pdfInfo->tribunal['Nom'].' ('.$tribunalCode.')';
|
||||
exit;
|
||||
}
|
||||
$firephp->log($tarifs[0]->prix,'prix');
|
||||
$pdfInfo->prix = number_format($tarifs[0]->prix, 2, ',', ' ');
|
||||
$pdfInfo->enveloppe = $tarifs[0]->enveloppe;
|
||||
|
||||
// initiate PDF
|
||||
$pdf = new PDF();
|
||||
/*
|
||||
* Définition des marges
|
||||
* Left, Top et Right
|
||||
* Dimension du logo d'entete :
|
||||
**/
|
||||
$pdf->SetMargins(25, 50, 25);
|
||||
$border = 0;
|
||||
// add a page
|
||||
$pdf->AddPage();
|
||||
$pdf->SetFont("times", "", 10);
|
||||
|
||||
//Position de départ
|
||||
$pdf->SetY(50);
|
||||
|
||||
//Bloc Addresse destinataire
|
||||
$txt = '';
|
||||
$txt.= "REGISTRE DU COMMERCE - GREFFE" . "\n";
|
||||
$txt.= normaliseVoie($pdfInfo->tribunal['Adr']) . "\n";
|
||||
$txt.= normaliseVoie($pdfInfo->tribunal['AdrComp']) . "\n";
|
||||
$txt.= $pdfInfo->tribunal['CP'] . ' ' . $pdfInfo->tribunal['Ville'] . "\n" ;
|
||||
|
||||
$largeur = 80;
|
||||
$positionX = 105;
|
||||
$pdf->MultiCell($largeur, 5, $txt, $border, 'L', 0, 1, $positionX);
|
||||
|
||||
//Bloc Lieu, date
|
||||
$date = date('d/m/Y');
|
||||
$txt = "Rambouillet, le $date";
|
||||
$positionY = $pdf->GetY()+8;
|
||||
$pdf->MultiCell($largeur, 5, $txt, $border, 'L', 0, 1, $positionX, $positionY);
|
||||
|
||||
//Bloc objet
|
||||
$positionY = $pdf->GetY()+5;
|
||||
$pdf->MultiCell(20, 5, "Objet:", $border, 'L', 0, 0, '', $positionY, true);
|
||||
$pdf->MultiCell(0, 5, "Commande de document", $border, 'L', 0, 1, '', '', true);
|
||||
//Bloc ref
|
||||
$pdf->MultiCell(20, 5, "Réf.", $border, 'L', 0, 0, '', '', true);
|
||||
$pdf->MultiCell(0, 5, $pdfInfo->ref, $border, 'L', 0, 1, '', '', true);;
|
||||
//Bloc titre
|
||||
$positionY = $pdf->GetY()+5;
|
||||
$pdf->MultiCell(0, 5, "Madame, Monsieur,", $border, 'L', 0, 1, '', $positionY, true);
|
||||
|
||||
//Type de document demandé (actes ou bilans pour l'instant)
|
||||
//[un Kbis / l'état d'endettement / la copie de jugement de XXX en date du XXX ]
|
||||
$txt = '';
|
||||
if( $typeDocument == 'bilans' )
|
||||
{
|
||||
$txt.= 'une copie du bilan au ';
|
||||
preg_match('/^[0-9]{4}_.*?-([0-9]{8}).*?/', $commande->refDocument, $matches);
|
||||
$txt.= substr($matches[1],6,2).'/'.substr($matches[1],4,2).'/'.substr($matches[1],0,4);
|
||||
}
|
||||
elseif( $typeDocument == 'actes' )
|
||||
{
|
||||
$txt.= 'une copie de l\'acte ';
|
||||
$txt.= $typeActes['a'.substr($commande->refDocument,0,2)];
|
||||
if( !empty($commande->libDocument) ) $txt.= ' ('.$commande->libDocument.')';
|
||||
$txt.= ' en date du '.
|
||||
substr($commande->refDocument,9,2).'/'.
|
||||
substr($commande->refDocument,7,2).'/'.
|
||||
substr($commande->refDocument,3,4);
|
||||
}
|
||||
elseif ($typeDocument == 'kbis' )
|
||||
{
|
||||
$txt.= 'un extrait RCS';
|
||||
}
|
||||
|
||||
$positionY = $pdf->GetY()+2;
|
||||
$pdf->MultiCell(0, 5, "Je vous prie de nous faire parvenir $txt concernant la société:", $border, 'L', 0, 1, '', $positionY, true);
|
||||
|
||||
//Bloc société
|
||||
$txt = '';
|
||||
$txt.= $pdfInfo->nom;
|
||||
$txt.= ' ( ' . $pdfInfo->siren . $pdfInfo->libTrib . ' )' . "\n";
|
||||
foreach($pdfInfo->adresse as $item){
|
||||
if( !empty($item) ){
|
||||
$txt.= normaliseVoie(htmlspecialchars_decode($item, ENT_QUOTES)) . "\n";
|
||||
}
|
||||
}
|
||||
$positionY = $pdf->GetY()+2;
|
||||
$pdf->MultiCell(0, 5, $txt, $border, 'L', 0, 1, '', $positionY, true);
|
||||
|
||||
//Bloc pièce jointe
|
||||
$positionY = $pdf->GetY()+5;
|
||||
if($pdfInfo->enveloppe)
|
||||
{
|
||||
$txt = "Ci joint une enveloppe timbrée ainsi qu'un chèque d'un montant de ".
|
||||
$pdfInfo->prix." euros en règlement de cette commande.";
|
||||
}else{
|
||||
$txt = "Ci joint un chèque d'un montant de ".
|
||||
$pdfInfo->prix." euros en règlement de cette commande.";
|
||||
}
|
||||
|
||||
$pdf->MultiCell(0, 5, $txt, $border, 'L', 0, 1, '', $positionY, true);
|
||||
|
||||
//Bloc intitulé adresse reception
|
||||
$positionY = $pdf->GetY()+2;
|
||||
$pdf->MultiCell(0, 5,
|
||||
"Veuillez nous renvoyer le(s) document(s) par retour à l'adresse suivante:",
|
||||
$border, 'L', 0, 1, '', $positionY, true);
|
||||
|
||||
//Bloc adresse s&d
|
||||
$positionY = '';
|
||||
$pdf->MultiCell(0, 5,
|
||||
"SCORES ET DECISIONS" . "\n" .
|
||||
"19 rue Clairefontaine". "\n" .
|
||||
"78120 RAMBOUILLET" . "\n"
|
||||
, $border, 'L', 0, 1, '', $positionY, true);
|
||||
|
||||
//Bloc formule politesse
|
||||
$positionY = $pdf->GetY()+2;
|
||||
$pdf->MultiCell(0, 5, "Dans l'attente de notre prochain échange, je vous prie de recevoir, Madame, Monsieur, l'expression de nos plus sincères salutations.", $border, 'L', 0, 1, '', $positionY, true);
|
||||
|
||||
$nomFichier = $siren.'-'.$pdfInfo->ref;
|
||||
$file = $nomFichier.'.pdf';
|
||||
$path = PATH_DATA.'/courrier/';
|
||||
$pdf->Output($path.$file, 'F');
|
||||
if(file_exists($path.$file))
|
||||
{
|
||||
$content_type = 'application/pdf';
|
||||
header('Content-Transfer-Encoding: none');
|
||||
header('Content-type: '.$content_type.'');
|
||||
header('Content-Length: '.filesize($path.$file));
|
||||
header('Content-MD5: '.base64_encode(md5_file($path.$file)));
|
||||
header('Content-Disposition: attachment, filename="'.$file.'"');
|
||||
header('Cache-Control: private, max-age=0, must-revalidate');
|
||||
header('Pragma: public');
|
||||
ini_set('zlib.output_compression','0');
|
||||
echo file_get_contents($path.$file);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user