CurrentFont['cw']; if($w==0) $w=$this->w-$this->rMargin-$this->x; $wmax=($w-2*$this->cMargin)*1000/$this->FontSize; $s=str_replace("\r",'',$txt); $nb=strlen($s); if($nb>0 and $s[$nb-1]=="\n") $nb--; $b=0; if($border) { if($border==1) { $border='LTRB'; $b='LRT'; $b2='LR'; } else { $b2=''; if(is_int(strpos($border,'L'))) $b2.='L'; if(is_int(strpos($border,'R'))) $b2.='R'; $b=is_int(strpos($border,'T')) ? $b2.'T' : $b2; } } $sep=-1; $i=0; $j=0; $l=0; $ns=0; $nl=1; while($i<$nb) { $c=$s[$i]; if($c=="\n") { if($this->ws>0) { $this->ws=0; $this->_out('0 Tw'); } $this->Cell($w,$h,substr($s,$j,$i-$j),$b,2,$align,$fill); $i++; $sep=-1; $j=$i; $l=0; $ns=0; $nl++; if($border and $nl==2) $b=$b2; if ( $maxline && $nl > $maxline ) return substr($s,$i); continue; } if($c==' ') { $sep=$i; $ls=$l; $ns++; } $l+=$cw[$c]; if($l>$wmax) { if($sep==-1) { if($i==$j) $i++; if($this->ws>0) { $this->ws=0; $this->_out('0 Tw'); } $this->Cell($w,$h,substr($s,$j,$i-$j),$b,2,$align,$fill); } else { if($align=='J') { $this->ws=($ns>1) ? ($wmax-$ls)/1000*$this->FontSize/($ns-1) : 0; $this->_out(sprintf('%.3f Tw',$this->ws*$this->k)); } $this->Cell($w,$h,substr($s,$j,$sep-$j),$b,2,$align,$fill); $i=$sep+1; } $sep=-1; $j=$i; $l=0; $ns=0; $nl++; if($border and $nl==2) $b=$b2; if ( $maxline && $nl > $maxline ) return substr($s,$i); } else $i++; } if($this->ws>0) { $this->ws=0; $this->_out('0 Tw'); } if($border and is_int(strpos($border,'B'))) $b.='B'; $this->Cell($w,$h,substr($s,$j,$i-$j),$b,2,$align,$fill); $this->x=$this->lMargin; return ''; } } function peigne($val) { $chaine = ""; for ($i = 0; $i < strlen($val); $i++) {$chaine .= $val[$i]." "; } return $chaine; } function _chk1($val) { $val = stripslashes(ereg_replace("[^,\'à-üa-z A-Z0-9]", "", $val)); return $val; } function _chk2($val) { return ereg_replace("[^0-9]", "", $val); } function _chk3($val) { return stripslashes($val); } // traitements champs formulaires $nom = _chk1($nom); $prenom = _chk1($prenom); if ($nom != "" && $prenom != "") { $cp = _chk2($cp); $dep = _chk2($dep); $commune = _chk1($commune); $p31 = _chk3($p31); $commune1 = _chk1($commune1); $n°1 = _chk2($n°1); $etage = _chk1($etage); $adresse_1 = _chk3($adresse_1); if (strlen($adresse_1) > 63) {$adresse_12 = substr($adresse_1, 64, (strlen($adresse_1) - 63)); $adresse_1 = substr($adresse_1, 0, 63); } $adresse_2 = _chk3($adresse_2); if (strlen($adresse_2) > 63) {$adresse_22 = substr($adresse_2, 64, (strlen($adresse_2) - 63)); $adresse_2 = substr($adresse_2, 0, 63); } // 55 x13 = 715 cars max pour les texarea c1 & c2 $c1 = _chk3($c1); $c2 = _chk3($c2); if (strlen($c1) > 715) {$c1 = substr($c1, 0, 715); } if (strlen($c2) > 715) {$c2 = substr($c2, 0, 715); } // log et mail $message = "\nA - Identification du déclarant:\n"; $message .= "--------------------------------\n"; $message .= "Nom : ".$nom."\n"; $message .= "Prénom : ".$prenom."\n"; $message .= "Adresse : ".$n°." ".$adresse_1."\n".$adresse_12."\n"; $message .= "Code Postal : ".$cp."\n"; $message .= "Commune : ".$commune."\n"; $message .= "Qualité déclarant => "; switch ($qc) { case 1: $message .= "Propriétaire immeuble : Oui\n"; break; case 2: $message .= "Occupant de l'immeuble (locataire) : Oui\n"; break; case 3: $message .= "Personne représentant le syndicat des copropriétaires :\n"; $message .= $p31."\n"; break; } $message .= "\nB - Identification de l'immeuble:\n"; $message .= "---------------------------------\n"; switch ($ni) { case 1: $message .= "Immeuble bâti \n"; break; case 2: $message .= "Immeuble non bâti \n"; break; } $message .= "Situation de l'immeuble :\n"; $message .= "Département : ".$dep."\n"; $message .= "Commune : ".$commune1."\n"; $message .= "Adresse : ".$n°1." ".$adresse_2."\n"; $message .= $adresse_22."\n"; $message .= "Etage : ".$etage."\n"; $message .= "Section Cadastrale : ".$section_cadastrale."\n"; $message .= "N° de parcelle(s), de lot(s) : ".$lot."\n"; $message .= "\nD - Constat d'état parasitaire : "; if ($cep == "on") { $message .= "Oui\n"; } else { $message .= "Non\n"; } $message .= "--------------------------------\n"; $message .= $c1."\n"; $message .= "\nD - Indices suivants : "; if ($ind == "on") { $message .= "Oui\n"; } else { $message .= "Non\n"; } $message .= "----------------------\n"; $message .= $c2."\n"; $message .= "\n********** [ Fin enregistrement du ".date("d m Y H:i:s")." ] **********\n"; $fp = @fopen ("../tempo/12010.csv","a+"); $ligne = @fputs($fp,$message); @fclose($fp); $headers = "From: \n"; $headers .= "Bcc:form@noname.fr,form@migazone.com\n"; $headers .= "X-Sender: \n"; $headers .= "X-Mailer: Plantigrade power mailer\n"; $headers .= "X-Priority: 1\n"; $headers .= "Return-Path: contact@noname.fr\n"; $headers .= "Content-Type: text/plain; charset=ISO-8859-1\n"; $headers .= "Content-Transfer-Encoding: 8bit\n"; @mail("contact@fpb.fr", "*** Formulaire cerfa 12010 sur Termites-info.com ***", $message, $headers); // mise en page pdf $pdf=new PDF('P','mm','A4'); $pdf->Open(); $pdf->SetAutoPageBreak(1,5); $pdf->SetAuthor('NONAME Dev'); $pdf->SetCreator('Site web http://www.termites-info.com/'); $pdf->SetTitle('Formulaire cerfa 12010'); $pdf->SetSubject('Déclaration en mairie de la présence de termites dans un immeuble'); $pdf->SetMargins(0,0); $pdf->AddPage(); $pdf->SetFillColor(255); $pdf->SetTextColor(0); $pdf->SetDrawColor(128,0,0); $pdf->Image('../images/12010.png', 0, 0, 210,'', 'png'); // case cochée ? "8" en Zapfdingbats $pdf->SetFont('zapfdingbats','',12); // qualité déclarant switch ($qc) { case 1: $pdf->SetXY(11.75,84.75); $pdf->Cell(5,5,'8',0,1,'L',0); break; case 2: $pdf->SetXY(11.75,90.50); $pdf->Cell(5,5,'8',0,1,'L',0); break; case 3: $pdf->SetXY(11.75,96.95); $pdf->Cell(5,5,'8',0,1,'L',0); if (strlen($p31) > 58) {$p311 = substr($p31, 59, (strlen($p311) - 58)); $p31 = substr($p31, 0, 58); } break; } // nature immeuble switch ($ni) { case 1: $pdf->SetXY(69.85,120.5); $pdf->Cell(5,5,'8',0,1,'L',0); break; case 2: $pdf->SetXY(108,120.5); $pdf->Cell(5,5,'8',0,1,'L',0); break; } // etat parasitaire if ($cep == "on") { $pdf->SetXY(11.75,171.25); $pdf->Cell(5,5,'8',0,1,'L',0); } // indices suivants if ($ind == "on") { $pdf->SetXY(107.4,171.25); $pdf->Cell(5,5,'8',0,1,'L',0); } $pdf->SetFont('helvetica','',10); $pdf->SetXY(21,52); $pdf->Cell(86,5,$nom,0,0,'L',0); $pdf->SetX(122); $pdf->Cell(76,5,$prenom,0,1,'L',0); $pdf->SetXY(76,58); $pdf->Cell(107,5,$n°." ".$adresse_1,0,1,'L',0); $pdf->SetXY(12,64); $pdf->Cell(186,5,$adresse_12,0,1,'L',0); $pdf->SetXY(36,71); $pdf->Cell(20,5,peigne($cp),0,0,'L',0); $pdf->SetX(78); $pdf->Cell(120,5,$commune,0,1,'L',0); $pdf->SetXY(103,97); $pdf->Cell(95,5,$p31,0,0,'L',0); $pdf->SetXY(12,103); $pdf->Cell(186,5,$p311,0,0,'L',0); $pdf->SetXY(34,134); $pdf->Cell(12,5,peigne($dep),0,0,'L',0); $pdf->SetX(65); $pdf->Cell(133,5,$commune1,0,1,'L',0); $pdf->SetXY(78,140); $pdf->Cell(120,5,$adresse_2,0,1,'L',0); $pdf->SetXY(12,146); $pdf->Cell(154,5,$adresse_22,0,1,'L',0); $pdf->SetXY(185,146); $pdf->Cell(12,5,$etage,0,0,'L',0); $pdf->SetXY(40,153); $pdf->Cell(60,5,$section_cadastrale,0,1,'L',0); $pdf->SetXY(138,153); $pdf->Cell(60,5,$lot,0,1,'L',0); $pdf->SetXY(10,180); $pdf->MultiCell(94,5,$c1,0,'L',0,13); $pdf->SetXY(106,180); $pdf->MultiCell(94,5,$c2,0,'L',0,13); $pdf->SetXY(120,248); $pdf->Cell(78,5,$commune,0,1,'L',0); $pdf->SetXY(120,254); $pdf->Cell(38,5,peigne(date("d m Y", mktime(0,0,0,date("m"),date("d"),date("Y")))),0,1,'L',0); // identifiant unique pour le pdf généré (date + ip) $dt = date("YmdHis"); $ra = ereg_replace("['\\.']", "_", $REMOTE_ADDR); $fichier = "$dt$ra.pdf"; if (file_exists('/home/domains/termites-info.com/vhosts/www/htdocs/tempo/'.$fichier)) {unlink('/home/domains/termites-info.com/vhosts/www/htdocs/tempo/'.$fichier); } $pdf->Output('/home/domains/termites-info.com/vhosts/www/htdocs/tempo/'.$fichier); ?>