//require("libs/fc_sessoes.php"); require "libs/classes.class"; require "libs/funcoes.php"; require "libs/form.class"; require 'fpdf151/fpdf.php'; $db = new db(); $db->_DEBUG = 1; $pdf = new FPDF("L", 'mm', "A4"); $pdf->open(); $pdf->AddPage(); $fonte = 'times'; $pdf->SetLeftMargin(5); $pdf->SetAutoPageBreak("on", 2); $pdf->SetFont($fonte, "", 12); $pdf->sety(15); $pdf->SetFont($fonte, "b", 12); $pdf->setx(5); $pdf->ln(); $pdf->SetFont($fonte, "", 14); $pdf->setx(5); $pdf->cell(50, 5, "Controle de Entregas", 0, 1); $pdf->line(5, $pdf->GetY(), 290, $pdf->GetY()); $pdf->ln(10); $pdf->setfont($fonte, "B", "14"); $pdf->cell(0, 5, $_GET["dtvenda"], 0, 1, "C"); $pdf->setfillcolor(235); $pdf->SetFont($fonte, "b", 10); $total = $db->entregas["total"]; $sql = " SELECT fun_nome,count(*) as total\n FROM comandas inner join comandaentrega \n on cet_comid = com_id\n inner join funcionarios on fun_id = cet_funid\n WHERE com_dtcomanda = '" . strformat($_GET["dtvenda"], "dten") . "' group by fun_nome order by fun_nome"; $rs = $db->executa($sql);
$pdf->AliasNbPages(); $pdf->AddPage(); $pdf->image('imagens/files/logo_boleto.png', 10, 2, 17); $pdf->setfont('arial', 'B', 10); $coluna = 30; $pdf->text($coluna, 5, $nomeinst); $pdf->setfont('arial', '', 8); $pdf->text($coluna, 9, $ender); $pdf->text($coluna, 12, $munic . ' - ' . $uf); $pdf->text($coluna, 15, $telef); $pdf->text($coluna, 18, $email); $pdf->text($coluna, 21, $url); $clquery->sql_query("cgm", "z01_nome", "", "z01_numcgm= {$q20_numcgm}"); $clquery->sql_record($clquery->sql); db_fieldsmemory($clquery->result, 0); $pdf->sety(25); $pdf->setfont('arial', 'B', 10); $pdf->multicell(0, 4, 'ISSQN COM RETENÇÃO NA FONTE', 0, "C", 0); $pdf->ln(5); $altura = 6; $pdf->setfont('arial', 'B', 8); $pdf->cell(130, $altura, 'TOMADOR DO SERVIÇO', 1, 0, "C", 0); $pdf->cell(60, $altura, 'DADOS DA PLANILHA', 1, 1, "C", 0); $pdf->setfont('arial', '', 8); $pdf->cell(130, $altura, 'NOME : ' . strtoupper($z01_nome), 1, 0, "L", 0); $pdf->cell(60, $altura, 'CODIGO : ' . db_formatar($planilha, 's', '0', 4, 'e'), 1, 1, "L", 0); $pdf->cell(130, $altura, 'INSCRIÇÃO : ' . $q20_inscr, 1, 0, "L", 0); $pdf->cell(60, $altura, 'COMPETÊNCIA : ' . db_formatar($q20_mes, 's', '0', 2, 'e') . '/' . $q20_ano, 1, 1, "L", 0); $pdf->multicell(190, $altura, 'OBSERVAÇÃO : Os valores registrados nesta planilha somente serão considerados após o pagamento desta guia.', 1, "L", 0); $linha = 65; for ($i = 0; $i < 2; $i++) {
function printFPDF($pdfobj){ require('fpdf/fpdf.php'); $DIRPATH = $_SERVER['SCRIPT_FILENAME']; // remove the file name and append the new directory name if (PHP_OS == "WINNT" || PHP_OS == "WIN32") { $pos1 = strrpos($DIRPATH,'\\'); $DIRPATH= substr($DIRPATH,0,$pos1)."\\pdf\\"; }else{ $pos1 = strrpos($DIRPATH,'/'); $DIRPATH= substr($DIRPATH,0,$pos1)."/pdf/"; } $pdf_FILE_NAME = session_id(). "MapLocator.pdf"; $pdf_FILE_PATH = $DIRPATH. $pdf_FILE_NAME ; $pdf = new FPDF('P', 'pt', array(640,450)); $pdf->AddPage(); $pdf->SetFont('Arial','B',10); $domain = getenv("HTTP_HOST"); //base map $base_url = $pdfobj->BaseUrl; $base_url = str_replace(' and ','&' ,$base_url); if (strpos($base_url,'http://') === false) { //since client sends only relative path a full http url needs to constructed here $base_url = 'http://'. $domain. $base_url; //echo 'here'; } $base_image = createImageForPDF($base_url,$DIRPATH.'base'); $base_image_jpeg = $DIRPATH.'base'.session_id() .'.jpeg'; png2jpg($base_image, $base_image_jpeg, 100); $layerURL = $pdfobj->LayerURL; $layerURL = str_replace(' and ','&' ,$layerURL ); //since client sends only relative path a full http url needs to constructed here $layerURL = 'http://'. $domain. $layerURL; $layer = $pdfobj->Layer; $legendURL = $pdfobj->LegendURL; $legendURL = 'http://'. $domain. $legendURL; $legendURL = str_replace(' and ','&' ,$legendURL ); $image = createImageForPDF($layerURL,$DIRPATH.$layer); $image_jpeg = $DIRPATH.$layer.session_id() .'.jpeg'; png2jpg($image, $image_jpeg, 100); $url = 'http://'. $domain. base_path().'ImageMerge.php?baseimage='.$base_image_jpeg.'&overlayimage='. $image_jpeg; $merged_image_buff = file_get_contents($url); $final_image =$DIRPATH.'merge.jpeg'; $fh = fopen($final_image,"w"); fwrite($fh,$merged_image_buff); fclose($fh); $pdf->Image($final_image,0,30); $image = createImageForPDF($legendURL,$DIRPATH.$layer.'_legend'); $image_jpeg = $DIRPATH.$layer.'_legend'.session_id() .'.jpeg'; png2jpg($image, $image_jpeg, 100); $size = getimagesize($image); $width = $size[0]; $height = $size[1]; $pdf->sety(25); $pdf->Cell(0,0,"Layer Name: ". $pdfobj->LayerName); $top_scale = $pdfobj->TopScale; $bottom_scale = $pdfobj->BottomScale; $pdf->Text(0,430,"Scalebar: "); $pdf->Text(50,430,"| ".$top_scale." |"); $pdf->Text(50,430," _____ "); $pdf->Text(50,440,"| ".$bottom_scale." |"); $pdf->Text(475,445,"Created by Map Locator"); if($width < 100){//show legend on the map/same page $pdf->Image($image_jpeg,640 - $width,30); $pdf->sety(20); $pdf->setX(-75); $pdf->Cell(20,10,"Legend "); }else{//show legend on the next page $pdf->AddPage(); $pdf->Image($image_jpeg,0,30); $pdf->sety(20); $pdf->setX(5); $pdf->Cell(20,10,"Legend "); } $pdf->Output($pdf_FILE_PATH,'F'); $pdf->Close(); return $pdf_FILE_NAME; }