function upload_file_to_client_pdf($file_to_send) { //Function reads a text file and converts to pdf. global $STMT_TEMP_FILE_PDF; $pdf = new Cezpdf('LETTER'); //pdf creation starts $pdf->ezSetMargins(36, 0, 36, 0); $pdf->selectFont($GLOBALS['fileroot'] . "/library/fonts/Courier.afm"); $pdf->ezSetY($pdf->ez['pageHeight'] - $pdf->ez['topMargin']); $countline = 1; $file = fopen($file_to_send, "r"); //this file contains the text to be converted to pdf. while (!feof($file)) { $OneLine = fgets($file); //one line is read if (stristr($OneLine, "\f") == true && !feof($file)) { $pdf->ezNewPage(); $pdf->ezSetY($pdf->ez['pageHeight'] - $pdf->ez['topMargin']); str_replace("\f", "", $OneLine); } if (stristr($OneLine, 'REMIT TO') == true || stristr($OneLine, 'Visit Date') == true) { //lines are made bold when 'REMIT TO' or 'Visit Date' is there. $pdf->ezText('<b>' . $OneLine . '</b>', 12, array('justification' => 'left', 'leading' => 6)); } else { $pdf->ezText($OneLine, 12, array('justification' => 'left', 'leading' => 6)); } $countline++; } $fh = @fopen($STMT_TEMP_FILE_PDF, 'w'); //stored to a pdf file if ($fh) { fwrite($fh, $pdf->ezOutput()); fclose($fh); } header("Pragma: public"); //this section outputs the pdf file to browser header("Expires: 0"); header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header("Content-Type: application/force-download"); header("Content-Length: " . filesize($STMT_TEMP_FILE_PDF)); header("Content-Disposition: attachment; filename=" . basename($STMT_TEMP_FILE_PDF)); header("Content-Description: File Transfer"); readfile($STMT_TEMP_FILE_PDF); // flush the content to the browser. If you don't do this, the text from the subsequent // output from this script will be in the file instead of sent to the browser. flush(); exit; //added to exit from process properly in order to stop bad html code -ehrlive // sleep one second to ensure there's no follow-on. sleep(1); }
public function ezNewPage() { if ($this->trigger['BeforeNewPage']) { $this->callTrigger($this->trigger['BeforeNewPage']); } parent::ezNewPage(); if ($this->trigger['AfterNewPage']) { $this->callTrigger($this->trigger['AfterNewPage']); } }
function printPDF($p_params) { $pbConfig = new PluginBarcodeConfig(); // create barcodes $ext = 'png'; $type = $p_params['type']; $size = $p_params['size']; $orientation = $p_params['orientation']; $codes = array(); if ($type == 'QRcode') { $codes = $p_params['codes']; } else { if (isset($p_params['code'])) { if (isset($p_params['nb']) and $p_params['nb'] > 1) { $this->create($p_params['code'], $type, $ext); for ($i = 1; $i <= $p_params['nb']; $i++) { $codes[] = $p_params['code']; } } else { if (!$this->create($p_params['code'], $type, $ext)) { Session::addMessageAfterRedirect(__('The generation of some bacodes produced errors.', 'barcode')); } $codes[] = $p_params['code']; } } elseif (isset($p_params['codes'])) { $codes = $p_params['codes']; foreach ($codes as $code) { if ($code != '') { $this->create($code, $type, $ext); } } } else { // TODO : erreur ? // print_r($p_params); return 0; } } // create pdf // x is horizontal axis and y is vertical // x=0 and y=0 in bottom left hand corner $config = $pbConfig->getConfigType($type); require_once GLPI_ROOT . "/plugins/barcode/lib/ezpdf/class.ezpdf.php"; $pdf = new Cezpdf($size, $orientation); $pdf->selectFont(GLPI_ROOT . "/plugins/barcode/lib/ezpdf/fonts/Helvetica.afm"); $pdf->ezStartPageNumbers($pdf->ez['pageWidth'] - 30, 10, 10, 'left', '{PAGENUM} / {TOTALPAGENUM}') . ($width = $config['maxCodeWidth']); $height = $config['maxCodeHeight']; $marginH = $config['marginHorizontal']; $marginV = $config['marginVertical']; $heightimage = $height; if (file_exists(GLPI_PLUGIN_DOC_DIR . '/barcode/logo.png')) { // Add logo to barcode $heightLogomax = 20; $imgSize = getimagesize(GLPI_PLUGIN_DOC_DIR . '/barcode/logo.png'); $logoWidth = $imgSize[0]; $logoHeight = $imgSize[1]; if ($logoHeight > $heightLogomax) { $ratio = 100 * $heightLogomax / $logoHeight; $logoHeight = $heightLogomax; $logoWidth = $logoWidth * ($ratio / 100); } if ($logoWidth > $width) { $ratio = 100 * $width / $logoWidth; $logoWidth = $width; $logoHeight = $logoHeight * ($ratio / 100); } $heightyposText = $height - $logoHeight; $heightimage = $heightyposText; } $first = true; foreach ($codes as $code) { if ($first) { $x = $pdf->ez['leftMargin']; $y = $pdf->ez['pageHeight'] - $pdf->ez['topMargin'] - $height; $first = false; } else { if ($x + $width + $marginH > $pdf->ez['pageWidth']) { // new line $x = $pdf->ez['leftMargin']; if ($y - $height - $marginV < $pdf->ez['bottomMargin']) { // new page $pdf->ezNewPage(); $y = $pdf->ez['pageHeight'] - $pdf->ez['topMargin'] - $height; } else { $y -= $height + $marginV; } } } if ($code != '') { if ($type == 'QRcode') { $imgFile = $code; } else { $imgFile = $this->docsPath . $code . '_' . $type . '.' . $ext; } if (file_exists($imgFile)) { $imgSize = getimagesize($imgFile); $imgWidth = $imgSize[0]; $imgHeight = $imgSize[1]; if ($imgWidth > $width) { $ratio = 100 * $width / $imgWidth; $imgWidth = $width; $imgHeight = $imgHeight * ($ratio / 100); } if ($imgHeight > $heightimage) { $ratio = 100 * $heightimage / $imgHeight; $imgHeight = $heightimage; $imgWidth = $imgWidth * ($ratio / 100); } $image = imagecreatefrompng($imgFile); if ($imgWidth < $width) { $pdf->addImage($image, $x + ($width - $imgWidth) / 2, $y, $imgWidth, $imgHeight); } else { $pdf->addImage($image, $x, $y, $imgWidth, $imgHeight); } if (file_exists(GLPI_PLUGIN_DOC_DIR . '/barcode/logo.png')) { $logoimg = imagecreatefrompng(GLPI_PLUGIN_DOC_DIR . '/barcode/logo.png'); $pdf->addImage($logoimg, $x + ($width - $logoWidth) / 2, $y + $heightyposText, $logoWidth, $logoHeight); } if ($p_params['border']) { $pdf->Rectangle($x, $y, $width, $height); } } } $x += $width + $marginH; $y -= 0; } $file = $pdf->ezOutput(); $pdfFile = $_SESSION['glpiID'] . '_' . $type . '.pdf'; file_put_contents($this->docsPath . $pdfFile, $file); return '/files/_plugins/barcode/' . $pdfFile; }
/** * gera um pdf dos laudos * * @param array $r */ function pdfLaudos($rs){ //error_reporting(E_ALL); set_time_limit(1800); include 'lib/php/classes/class.ezpdf.php'; $pdf = new Cezpdf('a4','portrait'); $pdf -> ezSetMargins(50,70,50,50); $all = $pdf->openObject(); $pdf->saveState(); $pdf->setStrokeColor(0,0,0,1); $pdf->restoreState(); $pdf->closeObject(); $pdf->addObject($all,'all'); $mainFont = './fonts/Courier.afm'; $codeFont = './fonts/Courier.afm'; $pdf->selectFont($mainFont); $n_rows = sizeof($rs); $c = 0; $t=945; $fator = 25; foreach($rs as $id => $r){ $o = new Interpretacao($r["int_id"]); $hos = new Hospital($o->get("hos_id")); $hos_nome = $hos->get("hos_nome"); $con = new Convenio($o->get("con_id")); $con_nome = $con->get("con_nome"); $exa = new Exame($o->get("exa_id")); $exa_nome = $exa->get("exa_nome"); $pdf->ezText($hos_nome,18,array('justification'=>'center')); $pdf->ezText(" ",20,array('justification'=>'left')); $pdf->ezText("PACIENTE : ".$r["int_paciente_prontuario"]." ".$r["int_paciente_nome"],10,array('justification'=>'left')); if ($r["int_paciente_nascimento"] == "0000-00-00") $pdf->ezText("NASCIMENTO : SEXO: ".$r["int_paciente_sexo"],10,array('justification'=>'left')); else $pdf->ezText("NASCIMENTO : ".Formatacao::formatBrData($r["int_paciente_nascimento"])." SEXO: ".$r["int_paciente_sexo"],10,array('justification'=>'left')); $pdf->ezText("CONVÊNIO : ".$con_nome,10,array('justification'=>'left')); $pdf->ezText("EXAME : ".$exa_nome,10,array('justification'=>'left')); $pdf->ezText(" ",20,array('justification'=>'left')); $pdf->ezText(" DATA: ".Formatacao::formatBrDataHoraminSeg($r["int_data_interpretacao"]),10,array('justification'=>'left')); $pdf->ezText("N DO EXAME : ".$r["int_opcional"],10,array('justification'=>'left')); $pdf->ezText("MÉDICO REQUISITANTE : ".$r["int_requisitante"],10,array('justification'=>'left')); $pdf->ezText("EXAME INTERPRETADO POR : 9679 Ernesto Sousa Nunes",10,array('justification'=>'left')); $pdf->ezText("TÉCNICO RX : ".$r["int_tecnico_rx"],10,array('justification'=>'left')); $pdf->ezText(" ",20,array('justification'=>'left')); $pdf->ezText("I N T E R P R E T A Ç Ã O",18,array('justification'=>'center')); $pdf->ezText(" ",20,array('justification'=>'left')); $vet_txt = split("\n",$r["int_texto"]); $pdf->ezText("============================================================================",10,array('justification'=>'left')); $pdf->ezText(" ",8,array('justification'=>'left')); foreach($vet_txt as $linha){ $pdf->ezText(" ".$linha,10,array('justification'=>'left')); } $pdf->ezText(" ",8,array('justification'=>'left')); $pdf->ezText("============================================================================",10,array('justification'=>'left')); $pdf->ezText(" Exame interpretado por: 9676 - Dr. Ernesto Sousa Nunes",10,array('justification'=>'left')); $pdf->addJpegFromFile('ass.jpg',250, 0); $pdf->openHere('Fit'); if ($c+1 < $n_rows) $pdf->ezNewPage(); $c++; $o->informaImpressao(); //$sql = "update laudo set LAU_DATA_EXPORTACAO = now() where LAU_ID = ".$r["LAU_ID"]." LIMIT 1"; //$up = mysql_query($sql, $db) or die(mysql_error()); } $pdfcode = $pdf->Output(); //$pdfcode = str_replace("\n","\n<br>",htmlspecialchars($pdfcode)); //$cont = trim($pdfcode); $fh = fopen("laudos_prontos.pdf", 'w+'); fwrite($fh, $pdfcode); fclose($fh); ?><script language="javascript">document.location.href="laudos_prontos.pdf";</script><? }
function ihr_pdf_einzeln(Cezpdf &$pdf, $p_id) { $this->get_hga_profil_infos($p_id); $this->p_ihr_gk_id; $kk = new kontenrahmen(); $kontenrahmen_id = $kk->get_kontenrahmen('Geldkonto', $this->p_ihr_gk_id); $bb = new buchen(); $kontostand11 = $bb->kontostand_tagesgenau_bis($this->p_ihr_gk_id, "01.01.{$this->p_jahr}"); if (!$kontostand11) { $kontostand11 = $this->get_kontostand_manuell($this->p_ihr_gk_id, $this->p_jahr . "-01-01"); } $kontostand11_a = nummer_punkt2komma_t($kontostand11); $ze = 0; $tab_arr[$ze]['TEXT'] = "I. Anfangsbestand 01.01.{$this->p_jahr}"; $tab_arr[$ze]['SOLL'] = "{$kontostand11_a} € "; $tab_arr[$ze]['IST'] = "{$kontostand11_a} € "; $ze++; $soll_summe_wp = $this->get_soll_betrag_wp(6040, $this->p_wplan_id); $soll_summe_wp_a = nummer_punkt2komma_t($soll_summe_wp); $tab_arr[$ze]['TEXT'] = "II. Soll-Zuführung zur Rücklage laut WP"; $tab_arr[$ze]['SOLL'] = ""; $tab_arr[$ze]['IST'] = "{$soll_summe_wp_a} € "; $ze++; $iii_arr[] = $this->III_tab_anzeigen_pdf($p_id); if (is_array($iii_arr)) { $iii_arr = $iii_arr[0]; for ($a = 0; $a < sizeof($iii_arr); $a++) { $text3 = $iii_arr[$a]['TEXT']; $ist3 = $iii_arr[$a]['IST']; $tab_arr[$ze]['TEXT'] = $text3; $tab_arr[$ze]['IST'] = $ist3; $ze++; } } $soll_endbestand = $kontostand11 + $soll_summe_wp; $soll_endbestand_a = nummer_punkt2komma_t($soll_endbestand); $tab_arr[$ze]['TEXT'] = "IV. Soll-Endbestand 31.12.{$this->p_jahr}"; $tab_arr[$ze]['SOLL'] = ""; $tab_arr[$ze]['IST'] = "{$soll_endbestand_a} € "; $n_jahr = $this->p_jahr + 1; $kontostand11 = $bb->kontostand_tagesgenau_bis($this->p_ihr_gk_id, "01.01.{$n_jahr}"); if (!$kontostand11) { $kontostand11 = $this->get_kontostand_manuell($this->p_ihr_gk_id, $this->p_jahr . "-12-31"); } $kontostand11_a = nummer_punkt2komma_t($kontostand11); $ze++; $tab_arr[$ze]['TEXT'] = "V. Endbestand 31.12.{$this->p_jahr}"; $tab_arr[$ze]['SOLL'] = ""; $tab_arr[$ze]['IST'] = "{$kontostand11_a} € "; $this->footer_zahlungshinweis = $bpdf->zahlungshinweis; $pdf->setColor(0.6, 0.6, 0.6); $pdf->filledRectangle(50, 690, 500, 15); $pdf->setColor(0, 0, 0); $pdf->ezSety(720); // $pdf->ezSetY(650); $datum = date("d.m.Y"); $p = new partners(); $p->get_partner_info($_SESSION['partner_id']); $pdf->ezText("{$p->partner_ort}, den {$datum}", 10, array('justification' => 'right')); $pdf->ezSetY(705); $o = new objekt(); $o->get_objekt_infos($this->p_objekt_id); $pdf->ezText(" <b>Entwicklung der Instandhaltungsrücklage {$this->p_jahr} | OBJEKT: {$o->objekt_kurzname}</b>", 10, array('justification' => 'full')); $pdf->ezSetDy(-15); $pdf->ezStopPageNumbers(); // seitennummerirung beenden $p = new partners(); $p->get_partner_info($_SESSION['partner_id']); $cols = array('TEXT' => "", 'IST' => "IST-BETRAG"); $pdf->ezTable($tab_arr, $cols, "", array('rowGap' => 1.5, 'showLines' => 1, 'showHeadings' => 1, 'shaded' => 1, 'shadeCol' => array(0.9, 0.9, 0.9), 'titleFontSize' => 7, 'fontSize' => 10, 'xPos' => 'left', 'xOrientation' => 'right', 'width' => 500, 'cols' => array('TEXT' => array('justification' => 'left'), 'SOLL' => array('justification' => 'right', 'width' => 100), 'IST' => array('justification' => 'right', 'width' => 100)))); $this->get_hga_profil_infos($p_id); $d = new detail(); $anteile_g = $d->finde_detail_inhalt('OBJEKT', $this->p_objekt_id, 'Gesamtanteile'); $einheiten_arr = $this->einheiten_weg_tabelle_arr($this->p_objekt_id); $anz_einheiten = count($einheiten_arr); $anz_konten = count($tab_arr); $gkkk = new geldkonto_info(); $gkkk->geld_konto_details($this->p_ihr_gk_id); $datum_heute = date("d.m.Y"); $kontostand_aktuell = nummer_punkt2komma_t($bb->kontostand_tagesgenau_bis($this->p_ihr_gk_id, "{$datum_heute}")); for ($a = 0; $a < $anz_einheiten; $a++) { $pdf->ezNewPage(); $e_kn = $einheiten_arr[$a]['EINHEIT_KURZNAME']; $einheit_id = $einheiten_arr[$a]['EINHEIT_ID']; $einheit_anteile = $d->finde_detail_inhalt('EINHEIT', $einheit_id, 'WEG-Anteile'); $pdf->setColor(0.6, 0.6, 0.6); $pdf->filledRectangle(50, 690, 500, 15); $pdf->setColor(0, 0, 0); $pdf->ezSety(720); $pdf->ezText("{$p->partner_ort}, den {$datum}", 10, array('justification' => 'right')); $pdf->ezSetDy(-2); $pdf->ezText("<b> Anteil in der Instandhaltungsrücklage für {$e_kn} | OBJEKT: {$o->objekt_kurzname} {$this->p_jahr}</b>", 10, array('justification' => 'full')); $pdf->ezSetDy(-10); $pdf->ezText("<b>Geldkontobezeichnung:</b> {$gkkk->geldkonto_bez}", 9); $pdf->ezText("<b>Geldinstitut:</b> {$gkkk->kredit_institut}", 9); $pdf->ezText("<b>IBAN:</b> {$gkkk->IBAN1}", 9); $pdf->ezText("<b>BIC:</b> {$gkkk->BIC}", 9); for ($b = 0; $b < $anz_konten; $b++) { $tab_arr_e[$b]['TEXT'] = $tab_arr[$b]['TEXT']; $tab_arr_e[$b]['IST'] = $tab_arr[$b]['IST']; $tab_arr_e[$b]['ANTEIL'] = nummer_punkt2komma_t(nummer_komma2punkt(str_replace('.', '', $tab_arr[$b]['IST'])) / $anteile_g * $einheit_anteile) . " € "; } $pdf->ezSetDy(-15); $cols = array('TEXT' => "", 'IST' => "IST-BETRAG"); $pdf->ezTable($tab_arr, $cols, "", array('rowGap' => 1.5, 'showLines' => 1, 'showHeadings' => 1, 'shaded' => 1, 'shadeCol' => array(0.9, 0.9, 0.9), 'titleFontSize' => 7, 'fontSize' => 10, 'xPos' => 'left', 'xOrientation' => 'right', 'width' => 500, 'cols' => array('TEXT' => array('justification' => 'left'), 'SOLL' => array('justification' => 'right', 'width' => 100), 'IST' => array('justification' => 'right', 'width' => 100)))); $pdf->ezSetDy(-15); $cols = array('TEXT' => "", 'IST' => "IST-BETRAG", 'ANTEIL' => "IHR ANTEIL"); $pdf->ezTable($tab_arr_e, $cols, "", array('rowGap' => 1.5, 'showLines' => 1, 'showHeadings' => 1, 'shaded' => 1, 'shadeCol' => array(0.9, 0.9, 0.9), 'titleFontSize' => 7, 'fontSize' => 10, 'xPos' => 'left', 'xOrientation' => 'right', 'width' => 500, 'cols' => array('TEXT' => array('justification' => 'left'), 'ANTEIL' => array('justification' => 'right', 'width' => 100), 'IST' => array('justification' => 'right', 'width' => 100)))); unset($tab_arr_e); /* WEG LAUTERSTR 2014 */ $pdf->ezSetDy(-15); $cols_laut = array('TXT' => "", 'BETRAG' => ""); $tab_laut[0]['TXT'] = "Kontostand des IHR-Geldkontos vom {$datum_heute}"; $tab_laut[0]['BETRAG'] = "{$kontostand_aktuell} € "; $pdf->ezTable($tab_laut, $cols_laut, "Zusatzinformationen", array('rowGap' => 1.5, 'showLines' => 1, 'showHeadings' => 0, 'shaded' => 1, 'shadeCol' => array(0.9, 0.9, 0.9), 'titleFontSize' => 7, 'fontSize' => 10, 'xPos' => 'left', 'xOrientation' => 'right', 'width' => 500, 'cols' => array('TXXT' => array('justification' => 'left'), 'BETRAG' => array('justification' => 'right', 'width' => 100)))); } }
function mainPdf($itemtype, $tab_id, $save = 0, $saveas = 0) { global $PDF, $DB; $config = new PluginImmobilizationsheetsConfig(); $nb_id = count($tab_id); foreach ($tab_id as $key => $ID) { $itemtable = getTableForItemType($itemtype); $PDF = new Cezpdf(); $PDF->Cezpdf('a4', 'portrait'); $PDF->selectFont(GLPI_ROOT . '/lib/ezpdf/fonts/Helvetica.afm'); $PDF->ezStartPageNumbers(550, 10, 10, 'left', "GLPI PDF export - " . date("Y-m-d H:i:s") . " - " . Toolbox::decodeFromUtf8(__('Items')) . "- {PAGENUM}/{TOTALPAGENUM}"); //items $query = "SELECT *\n FROM `" . $itemtable . "`\n WHERE `id` = '{$ID}'"; $result = $DB->query($query); $number = $DB->numrows($result); if ($number != 0) { while ($data = $DB->fetch_array($result)) { $this->generatePdf($itemtype, $data, $saveas); } } if ($config->getFromDB(1)) { if ($config->fields["use_backup"] != 1) { if ($nb_id != $key + 1) { $PDF->ezNewPage(); } } } } if ($save == 0) { $PDF->ezstream(); } }
function upload_file_to_client_pdf($file_to_send) { //Function reads a HTML file and converts to pdf. global $STMT_TEMP_FILE_PDF; global $srcdir; if ($GLOBALS['statement_appearance'] == '1') { require_once "{$srcdir}/html2pdf/vendor/autoload.php"; $pdf2 = new HTML2PDF($GLOBALS['pdf_layout'], $GLOBALS['pdf_size'], $GLOBALS['pdf_language'], true, 'UTF-8', array($GLOBALS['pdf_left_margin'], $GLOBALS['pdf_top_margin'], $GLOBALS['pdf_right_margin'], $GLOBALS['pdf_bottom_margin']), $_SESSION['language_direction'] == 'rtl' ? true : false); ob_start(); echo readfile($file_to_send, "r"); //this file contains the HTML to be converted to pdf. //echo $file; $content = ob_get_clean(); // Fix a nasty html2pdf bug - it ignores document root! global $web_root, $webserver_root; $i = 0; $wrlen = strlen($web_root); $wsrlen = strlen($webserver_root); while (true) { $i = stripos($content, " src='/", $i + 1); if ($i === false) { break; } if (substr($content, $i + 6, $wrlen) === $web_root && substr($content, $i + 6, $wsrlen) !== $webserver_root) { $content = substr($content, 0, $i + 6) . $webserver_root . substr($content, $i + 6 + $wrlen); } } $pdf2->WriteHTML($content); $temp_filename = $STMT_TEMP_FILE_PDF; $content_pdf = $pdf2->Output($STMT_TEMP_FILE_PDF, 'F'); } else { $pdf = new Cezpdf('LETTER'); //pdf creation starts $pdf->ezSetMargins(45, 9, 36, 10); $pdf->selectFont('Courier'); $pdf->ezSetY($pdf->ez['pageHeight'] - $pdf->ez['topMargin']); $countline = 1; $file = fopen($file_to_send, "r"); //this file contains the text to be converted to pdf. while (!feof($file)) { $OneLine = fgets($file); //one line is read if (stristr($OneLine, "\f") == true && !feof($file)) { $pdf->ezNewPage(); $pdf->ezSetY($pdf->ez['pageHeight'] - $pdf->ez['topMargin']); str_replace("\f", "", $OneLine); } if (stristr($OneLine, 'REMIT TO') == true || stristr($OneLine, 'Visit Date') == true || stristr($OneLine, 'Future Appointments') == true || stristr($OneLine, 'Current') == true) { //lines are made bold when 'REMIT TO' or 'Visit Date' is there. $pdf->ezText('<b>' . $OneLine . '</b>', 12, array('justification' => 'left', 'leading' => 6)); } else { $pdf->ezText($OneLine, 12, array('justification' => 'left', 'leading' => 6)); } $countline++; } $fh = @fopen($STMT_TEMP_FILE_PDF, 'w'); //stored to a pdf file if ($fh) { fwrite($fh, $pdf->ezOutput()); fclose($fh); } } header("Pragma: public"); //this section outputs the pdf file to browser header("Expires: 0"); header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header("Content-Type: application/force-download"); header("Content-Length: " . filesize($STMT_TEMP_FILE_PDF)); header("Content-Disposition: attachment; filename=" . basename($STMT_TEMP_FILE_PDF)); header("Content-Description: File Transfer"); readfile($STMT_TEMP_FILE_PDF); // flush the content to the browser. If you don't do this, the text from the subsequent // output from this script will be in the file instead of sent to the browser. flush(); exit; //added to exit from process properly in order to stop bad html code -ehrlive // sleep one second to ensure there's no follow-on. sleep(1); }
function pdf_einzel_tab(Cezpdf &$pdf, $bk_arr, $label, $kontroll_tab_druck) { $empf = $bk_arr['EMPF']; $empf_kos_typ = $bk_arr['KOS_TYP']; $empf_kos_id = $bk_arr['KOS_ID']; $mieternummer = $bk_arr['EINHEIT_NAME']; $zeitraum = $bk_arr['ZEITRAUM']; $zeitraum_arr = explode('.', $zeitraum); $anzahl_monate = $zeitraum_arr[3] - $zeitraum_arr[1] + 1; $pdf->ergebnis_tab["{$mieternummer} - {$empf}"]['KOS_TYP'] = $empf_kos_typ; $pdf->ergebnis_tab["{$mieternummer} - {$empf}"]['KOS_ID'] = $empf_kos_id; $pdf->ergebnis_tab["{$mieternummer} - {$empf}"]['ZEITRAUM'] = $zeitraum; $pdf->ergebnis_tab["{$mieternummer} - {$empf}"]['ANZ_MONATE'] = $anzahl_monate; $einheit_typ = $bk_arr['EINHEIT_TYP']; $einheit_qm = $bk_arr['EINHEIT_QM']; $QM_G_OBJEKT = nummer_punkt2komma($bk_arr['QM_G_OBJEKT']); $QM_G = nummer_punkt2komma($bk_arr['QM_G']); $QM_G_GEWERBE = nummer_punkt2komma($bk_arr['QM_G_GEWERBE']); $this->bk_profil_infos($_SESSION['profil_id']); $anzahl_zeilen = count($bk_arr) - 10; // WICHTIG 10 felder abschneiden $cols = array('KOSTENART' => "Betriebskostenart", 'G_BETRAG' => "Gesamtkosten umlagefähige Betriebskosten", 'G_HNDL' => "Gesamtkosten haushaltsnahe Dienst- und Handwerkerleistungen", 'G_KEY' => "Wohnfläche / Verteiler- Schlüssel in Mieteinheiten (ME)", 'QM_ME' => "Ihre ME", 'BET_HNDL' => "Anteil für Ihre Wohnung haushaltsnahe Dienst- und Handwerkerleistungen", 'BET_G' => "Beteiligung"); $g_beteiligung = 0.0; $g_beteiligung_hnd = 0.0; for ($b = 0; $b < $anzahl_zeilen; $b++) { $tab[$b]['KOSTENART'] = $bk_arr[$b]['KOSTENART']; $tab[$b]['G_KOS_BEZ'] = $bk_arr[$b]['G_KOS_BEZ']; $tab[$b]['G_BETRAG'] = $bk_arr[$b]['G_BETRAG']; $tab[$b]['ANTEIL'] = $bk_arr[$b]['ANTEIL'] . '%'; $tab[$b]['UMLAGE'] = $bk_arr[$b]['UMLAGE']; $tab[$b]['ME'] = $bk_arr[$b]['ME']; $tab[$b]['G_KEY'] = nummer_punkt2komma($bk_arr[$b]['G_KEY']) . ' ' . $bk_arr[$b]['ME']; $tab[$b]['QM'] = $bk_arr[$b]['QM']; $tab[$b]['QM_ME'] = nummer_punkt2komma($bk_arr[$b]['QM']) . ' ' . $bk_arr[$b]['ME']; $tab[$b]['BET_G'] = $bk_arr[$b]['BET_G']; $tab[$b]['G_HNDL'] = $bk_arr[$b]['G_HNDL']; $tab[$b]['BET_HNDL'] = $bk_arr[$b]['BET_HNDL']; $tab[$b]['GENKEY_ID'] = $bk_arr[$b]['GENKEY_ID']; $g_beteiligung += nummer_komma2punkt($bk_arr[$b]['BET_G']); $g_beteiligung_hndl += nummer_komma2punkt($bk_arr[$b]['BET_HNDL']); } /* Pr�fen ob Kaltwasserkosten worden sind */ $check_kw = $this->check_kw_abrechnung($empf_kos_typ, $empf_kos_id, $this->bk_jahr); if ($check_kw == true) { $kw_summe = $this->summe_kw_abrechnung($empf_kos_typ, $empf_kos_id, $this->bk_jahr); $kw_summe_a = nummer_punkt2komma($kw_summe); // $pdf->ezText("<b>Heiz- und Betriebskostenabrechnung Einheit: $mv->einheit_kurzname</b>",10); $tab[$b + 1]['KOSTENART'] = 'Be- und Entwässerung lt. Kaltwasserabr.'; if ($kw_summe < 0) { $kw_erg_a = 'Nachzahlung'; } else { $kw_erg_a = 'Guthaben'; } $tab[$b + 1]['G_KEY'] = 'n. Verbrauch'; $tab[$b + 1]['BET_G'] = $kw_summe_a; $g_beteiligung += $kw_summe; // die($g_beteiligung); } else { // $pdf->ezText("<b>Betriebskostenabrechnung $this->bk_jahr Einheit: $mv->einheit_kurzname</b>",10); } $b++; $tab[$b + 1]['KOSTENART'] = '<b>Gesamtkosten</b>'; $tab[$b + 1]['BET_G'] = '<b>' . nummer_punkt2komma($g_beteiligung) . '</b>'; $tab[$b + 1]['BET_HNDL'] = '<b>' . nummer_punkt2komma($g_beteiligung_hndl) . '</b>'; $summe_nebenkosten_jahr = 0.0; if ($empf_kos_typ == 'MIETVERTRAG') { $mz = new miete(); $summe_nebenkosten_jahr = $mz->summe_nebenkosten_im_jahr($empf_kos_typ, $empf_kos_id, $this->bk_jahr); $summe_hk_jahr = $mz->summe_nebenkosten_im_jahr($empf_kos_typ, $empf_kos_id, $this->bk_jahr); } else { $summe_nebenkosten_jahr = 0.0; $summe_hk_jahr = '0.00'; } $tab[$b + 2]['KOSTENART'] = '<b>Ihr Vorschuss/Jahr</b>'; $tab[$b + 2]['BET_G'] = '<b>' . nummer_punkt2komma($summe_nebenkosten_jahr) . '</b>'; $ergebnis = $g_beteiligung + $summe_nebenkosten_jahr; // $ergebnis = $summe_nebenkosten_jahr- substr($g_beteiligung,1); if ($ergebnis < 0) { $txt = 'Nachzahlung'; $ergebnis_a = substr($ergebnis, 1); } if ($ergebnis > 0) { $txt = 'Guthaben'; $ergebnis_a = $ergebnis; } if ($ergebnis == null) { $txt = 'Ergebnis'; $ergebnis_a = $ergebnis; } $tab[$b + 3]['KOSTENART'] = "<b>{$txt}</b>"; $tab[$b + 3]['BET_G'] = '<b>' . nummer_punkt2komma($ergebnis_a) . '</b>'; $pdf->ezNewPage(); $pdf->ezStopPageNumbers(); // seitennummerirung beenden /* * $this->wirt_ges_qm = $wirt->g_qm; * $this->wirt_g_qm_gewerbe = $wirt->g_qm_gewerbe; * $this->wirt_g_qm_wohnen = $this->wirt_ges_qm - $this->wirt_g_qm_gewerbe; */ // $cols1 = array('KOSTENART'=>"Betriebskostenart","KOSTEN_GESAMT"=>"Kosten gesamt $QM_G_OBJEKT m²",'KOSTEN_GEWERBE'=>"Gewerbeanteil $QM_G_GEWERBE m²",'KOSTEN_WOHNRAUM'=>"Wohnanteil $QM_G m²"); // $cols1 = array('KOSTENART'=>"Betriebskostenart","KOSTEN_GESAMT"=>"Kosten gesamt $this->wirt_ges_qm_a m²",'KOSTEN_GEWERBE'=>"Gewerbeanteil $this->wirt_g_qm_gewerbe_a m²",'KOSTEN_WOHNRAUM'=>"Wohnanteil $this->wirt_g_qm_wohnen_a m²"); $cols1 = array('KOSTENART' => "Betriebskostenart", "KOSTEN_GESAMT" => "Kosten gesamt", 'KOSTEN_GEWERBE' => "Gewerbeanteil {$this->wirt_g_qm_gewerbe_a} m²", 'KOSTEN_WOHNRAUM' => "Wohnanteil {$this->wirt_g_qm_wohnen_a} m²"); // $i=$pdf->ezStartPageNumbers(545,728,6,'','Seite {PAGENUM} von {TOTALPAGENUM}',1); $p = new partners(); $p->get_partner_info($_SESSION[partner_id]); $pdf->addText(480, 697, 8, "{$p->partner_ort}, {$this->bk_berechnungs_datum_d}"); // $zeitraum = "01.09.2011 - 31.12.2011"; $pdf->ezText('<b>Betriebskostenabrechnung für den Zeitraum: ' . $zeitraum . '</b>', 8); $pdf->ezSetDy(-15); $pdf->ezText("<b>{$this->bk_bezeichnung}</b>", 8); $pdf->ezText("Wirtschaftseinheit: {$this->bk_kos_bez} ", 8); $pdf->ezText('Mieternummer: ' . $mieternummer . " - {$einheit_typ}", 8); $pdf->ezText('Mieter: ' . $empf, 8); $pdf->ezSetDy(-20); /* Ergebnis in die �bersichtstabelle */ $pdf->ergebnis_tab["{$mieternummer} - {$empf}"]['ERGEBNIS'] = $ergebnis; $pdf->ergebnis_tab["{$mieternummer} - {$empf}"]['SUMME_NK'] = $summe_nebenkosten_jahr; $pdf->ezTable($kontroll_tab_druck, $cols1, "Aufteilung Gewerbe- / Wohnfläche", array('showHeadings' => 1, 'shaded' => 1, 'titleFontSize' => 7, 'fontSize' => 7, 'xPos' => 55, 'xOrientation' => 'right', 'width' => 500, 'cols' => array('KOSTENART' => array('justification' => 'left'), 'KOSTEN_GESAMT' => array('justification' => 'right'), 'KOSTEN_GEWERBE' => array('justification' => 'right'), 'KOSTEN_WOHNRAUM' => array('justification' => 'right')))); $pdf->ezSetDy(-20); $pdf->ezTable($tab, $cols, "{$label}", array('showHeadings' => 1, 'shaded' => 1, 'titleFontSize' => 8, 'fontSize' => 7, 'xPos' => 55, 'xOrientation' => 'right', 'width' => 500, 'cols' => array('KOSTENART' => array('justification' => 'left'), 'G_BETRAG' => array('justification' => 'right', 'width' => 60), 'G_HNDL' => array('justification' => 'right', 'width' => 60), 'ANTEIL' => array('justification' => 'right', 'width' => 40), 'UMLAGE' => array('justification' => 'right', 'width' => 45), 'G_KOS_BEZ' => array('justification' => 'right', 'width' => 45), 'G_KEY' => array('justification' => 'right', 'width' => 55), 'QM_ME' => array('justification' => 'right', 'width' => 50), 'BET_G' => array('justification' => 'right', 'width' => 45), 'BET_HNDL' => array('justification' => 'right', 'width' => 65)))); // $pdf->ezStopPageNumbers(1,1,$i); // ENDE BERECHNUNGSSEITEN if ($empf_kos_typ == 'MIETVERTRAG') { $mz = new miete(); $mk = new mietkonto(); $monat = date("m"); $jahr = date("Y"); $ber_datum_arr = explode('-', $this->bk_berechnungs_datum); $ver_datum_arr = explode('-', $this->bk_verrechnungs_datum); $monat_b = $ber_datum_arr[1]; $jahr_b = $ber_datum_arr[0]; $monat_v = $ver_datum_arr[1]; $jahr_v = $ver_datum_arr[0]; $mk->kaltmiete_monatlich_ink_vz($empf_kos_id, $monat_b, $jahr_b); $mk->ausgangs_kaltmiete_a = nummer_punkt2komma($mk->ausgangs_kaltmiete); // $mk->heizkosten_monatlich($empf_kos_id,$monat,$jahr); // $mk->betriebskosten_monatlich($empf_kos_id,$monat,$jahr); // $mk->nebenkosten_monatlich($empf_kos_id,$monat,$jahr); $anp_tab[0]['KOSTENKAT'] = 'Miete kalt'; $anp_tab[0]['AKTUELL'] = "{$mk->ausgangs_kaltmiete_a} €"; $anp_tab[0]['ANPASSUNG'] = '--'; $mk1 = new mietkonto(); $mk1->kaltmiete_monatlich_ink_vz($empf_kos_id, $monat_v, $jahr_v); $mk1->ausgangs_kaltmiete_a = nummer_punkt2komma($mk1->ausgangs_kaltmiete); $anp_tab[0]['NEU'] = "{$mk1->ausgangs_kaltmiete_a} €"; $this->get_anpassung_details($_SESSION['profil_id'], 'Nebenkosten Vorauszahlung'); $anp_datum = date_mysql2german($this->bk_an_anpassung_ab); $mv = new mietvertraege(); $mv->get_mietvertrag_infos_aktuell($empf_kos_id); /* * if($empf_kos_id == '580'){ * echo '<pre>'; * print_r($mv); * die(); * } */ $pdf->addText(480, 697, 8, "{$p->partner_ort}, {$this->bk_berechnungs_datum_d}"); /* Wenn MV aktuell anpassen, wenn ausgezogen nicht */ // if($mv->mietvertrag_aktuell && $summe_nebenkosten_jahr){ if ($empf_kos_typ != 'Leerstand') { // ##########NEU ENERGIEVERBRAUCH GEGEN VORSCHÜSSE################### /* prüfen ob HK Vorschüsse vorhanden */ $mz2 = new miete(); $met = new mietentwicklung(); // $summe_nebenkosten_jahr = $mz->summe_nebenkosten_im_jahr($empf_kos_typ,$empf_kos_id,$this->bk_jahr); $summe_hk_vorschuss = $mz2->summe_heizkosten_im_jahr($empf_kos_typ, $empf_kos_id, $this->bk_jahr); $energiekosten_jahr = $met->get_energieverbrauch(strtoupper($empf_kos_typ), $empf_kos_id, $this->bk_jahr); if ($energiekosten_jahr > 0) { $pdf->ezNewPage(); $pdf->addText(480, 697, 8, "{$p->partner_ort}, {$this->bk_berechnungs_datum_d}"); $pdf->ezText('<b>Energiekostenabrechnung für den Zeitraum: ' . $zeitraum . '</b>', 8); $pdf->ezSetDy(-15); $pdf->ezText("<b>{$this->bk_bezeichnung}</b>", 8); $pdf->ezText("Wirtschaftseinheit: {$this->bk_kos_bez} ", 8); $pdf->ezText('Mieternummer: ' . $mieternummer . " - {$einheit_typ}", 8); $pdf->ezText('Mieter: ' . $empf, 8); $pdf->ezSetDy(-20); $pdf->ezText("{$mv->mv_anrede}", 9); $pdf->ezText("die Abrechnung der Energiekosten für den o.g. Zeitraum stellt sich wie folgt da:", 9); $hk_verbrauch_tab[0]['KOSTENKAT'] = "Ihre Vorauszahlung im Jahr {$this->bk_jahr}"; $hk_verbrauch_tab[0]['BETRAG'] = nummer_punkt2komma_t($summe_hk_vorschuss); /* Heizkostenverbrauch abfragen */ // $energiekosten_jahr = $met->get_energieverbrauch(strtoupper($empf_kos_typ), $empf_kos_id, $this->bk_jahr); $hk_verbrauch_tab[1]['KOSTENKAT'] = "Angefallene Kosten lt. Abrechnung in {$this->bk_jahr}"; $hk_verbrauch_tab[1]['BETRAG'] = nummer_punkt2komma_t($energiekosten_jahr); /* Ergebnis ermittlen */ $ergebnis_energie = $summe_hk_vorschuss - $energiekosten_jahr; if ($ergebnis_energie < 0) { $energie_text = "Ihre Nachzahlung"; } if ($ergebnis_energie > 0) { $energie_text = "Ihr Guthaben"; } if ($ergebnis_energie == 0) { $energie_text = "Saldo"; } $hk_verbrauch_tab[2]['KOSTENKAT'] = "<b>{$energie_text} {$this->bk_jahr}</b>"; $hk_verbrauch_tab[2]['BETRAG'] = "<b>" . nummer_punkt2komma_t($ergebnis_energie) . "</b>"; $pdf->ezSetDy(-20); $cols = array('KOSTENKAT' => "Bezeichnung", "BETRAG" => "Betrag"); $pdf->ezTable($hk_verbrauch_tab, $cols, "", array('showHeadings' => 0, 'shaded' => 1, 'titleFontSize' => 7, 'fontSize' => 8, 'xPos' => 55, 'xOrientation' => 'right', 'width' => 500, 'cols' => array('BETRAG' => array('justification' => 'right', 'width' => 80), 'KOSTENKAT' => array('justification' => 'left')))); $pdf->ezSetDy(-20); $pdf->ezText("Die Energieabrechnung des Abrechnungsunternehmens legen wir dieser Abrechnung bei.", 9); $pdf->ezSetDy(-10); $pdf->ezText("Mit freundlichen Grüßen", 9); $pdf->ezSetDy(-30); $pdf->ezText("Ihre Hausverwaltung", 9); $hk_verbrauch_tab[3]['KOSTENKAT'] = "{$mieternummer} - {$empf} - {$zeitraum}"; $pdf->energie_abr[]["{$mieternummer} - {$empf} - {$zeitraum}"] = $hk_verbrauch_tab; } // #ende wenn energieabrecnung drin } // #ende wenn nicht leerstand // ######################################################################## if ($mv->mietvertrag_aktuell) { /* ANPASSUNGSBLATT */ $pdf->ezNewPage(); $pdf->addText(480, 697, 8, "{$p->partner_ort}, {$this->bk_berechnungs_datum_d}"); $pap = $mv->postanschrift[0]['anschrift']; if (!empty($pap)) { $pdf->ezText("{$pap}", 10); $pap = ''; } else { $pdf->ezText("{$mv->personen_name_string_u}\n{$mv->haus_strasse} {$mv->haus_nr}\n\n{$mv->haus_plz} {$mv->haus_stadt}", 10); } $pdf->ezSetDy(-60); $check_hk = $this->check_hk_abrechnung($empf_kos_typ, $empf_kos_id, $this->bk_jahr); // $check_bk = $this->check_bk_abrechnung($empf_kos_typ,$empf_kos_id,$this->bk_jahr); $bk_summe = $ergebnis; /* Summe aus der Abrechnung */ $hk_summe = $this->summe_hk_abrechnung($empf_kos_typ, $empf_kos_id, $this->bk_jahr); // $bk_summe = $this->summe_bk_abrechnung($empf_kos_typ,$empf_kos_id,$this->bk_jahr); /* NEU */ /* Anpassung Nachzahlung Heizkosten */ /* Wenn Nachzahlung, dann mindestens 50/12+1EUR=5.00 EUR */ if ($hk_summe < 0) { // echo $hk_summe; $hk_monatlich_letzte_vj = $mz->letzte_hk_vorauszahlung($empf_kos_typ, $empf_kos_id, $this->bk_jahr, 'Heizkosten Vorauszahlung'); $hk_monatlich_letzte = $mz->letzte_hk_vorauszahlung($empf_kos_typ, $empf_kos_id, $jahr, 'Heizkosten Vorauszahlung'); $hk_jahr_aktuell = $hk_monatlich_letzte * 12; $hk_diff = $hk_jahr_aktuell - ($hk_summe * -1 + $anzahl_monate * $hk_monatlich_letzte_vj); $hk_anp_betrag_neu = ($hk_summe - 25) / 12; $hk_anp_betrag_neu = intval($hk_anp_betrag_neu - 1); $hk_anp_betrag_neu = substr($hk_anp_betrag_neu, 1); // echo "$hk_summe $hk_vorschuss_neu $hk_anp_betrag_neu"; if ($hk_diff >= 0) { $hk_anp_betrag_neu = '0.00'; } else { $hk_anp_betrag_neu = $hk_diff / 12 * -1; } /* * if($mv->mietvertrag_id=='1573'){ * echo "<br><b>HKSUMME: $hk_summe HKV: $hk_vorschuss_neu ANP:$hk_anp_betrag_neu HKJAHR: $hk_jahr_aktuell|$hk_monatlich_letzte $hk_monatlich_letzte_vj $hk_diff</b>"; * echo "$hk_diff = $hk_jahr_aktuell - (($hk_summe*-1) + ($anzahl_monate*$hk_monatlich_letzte_vj));"; * die(); * } */ } else { /* Guthaben bei HK */ $hk_anp_betrag_neu = ($hk_summe - 50) / 12; $hk_anp_betrag_neu = intval($hk_anp_betrag_neu); if ($hk_anp_betrag_neu < 0) { $hk_anp_betrag_neu = 0.0; } /* Unter 5 Euro nicht anpassen */ if ($hk_anp_betrag_neu > 0.0 && $hk_anp_betrag_neu < 5.0) { $hk_anp_betrag_neu = 0.0; } if ($hk_anp_betrag_neu > 5) { $hk_anp_betrag_neu = -$hk_anp_betrag_neu - 1; } if ($hk_summe == 0 or $summe_hk_jahr == 0) { $hk_anp_betrag_neu = '0.00'; } } // END HK ANPASSUNG /* NEU BK */ /* Anpassung Nachzahlung BK */ /* Summe aus der Abrechnung */ // $bk_summe = $this->summe_bk_abrechnung($empf_kos_typ,$empf_kos_id,$this->bk_jahr); // echo $bk_summe if ($bk_summe < 0) { // echo $hk_summe; $bk_anp_betrag_neu = ($bk_summe - 24) / 12; $bk_anp_betrag_neu = intval($bk_anp_betrag_neu - 1); $bk_anp_betrag_neu = substr($bk_anp_betrag_neu, 1); // echo "$bk_anp_betrag_neu"; // die(); } else { /* Guthaben bei BK */ if ($bk_summe > 24) { $bk_anp_betrag_neu = ($bk_summe - 24) / 12; } else { $bk_anp_betrag_neu = $bk_summe / 12; } $bk_anp_betrag_neu = intval($bk_anp_betrag_neu); if ($bk_anp_betrag_neu < 0) { $bk_anp_betrag_neu = 0.0; } /* Unter 5 Euro nicht anpassen */ if ($bk_anp_betrag_neu > 0.0 && $bk_anp_betrag_neu < 5.0) { $bk_anp_betrag_neu = 0.0; } if ($bk_anp_betrag_neu > 5) { // echo "SANEL $bk_anp_betrag_neu"; $bk_anp_betrag_neu = $bk_anp_betrag_neu - 1; // die("SANEL $bk_anp_betrag_neu"); } } // ENDE BK ANPASSUNGSERMITTLUNG if ($bk_summe == 0 or $summe_nebenkosten_jahr == 0) { $bk_anp_betrag_neu = '0.00'; } if ($mv->mietvertrag_id == '1813') { // ob_clean(); // echo "$bk_summe $ergebnis ANP: $bk_anp_betrag_neu "; // die('SANEL'); } $pdf->ergebnis_tab["{$mieternummer} - {$empf}"]['HK_SUMME'] = nummer_punkt2komma($hk_summe); /* Summe aller Vorauszahlungen im Jahr der Abrechnung */ $summe_hk_jahr = $mz->summe_heizkosten_im_jahr($empf_kos_typ, $empf_kos_id, $this->bk_jahr); $this->get_anpassung_details($_SESSION['profil_id'], 'Heizkosten Vorauszahlung'); $hk_monatlich_bisher_schnitt = $summe_hk_jahr / $anzahl_monate; $hk_monatlich_letzte = $mz->letzte_hk_vorauszahlung($empf_kos_typ, $empf_kos_id, $jahr, 'Heizkosten Vorauszahlung'); // $hk_monatlich_letzte = $mz->letzte_hk_vorauszahlung($empf_kos_typ, $empf_kos_id, $this->bk_jahr, 'Heizkosten Vorauszahlung'); // $x = $hk_monatlich_letzte + $hk_anp_betrag_neu; // die("$x = $hk_monatlich_letzte + $hk_anp_betrag_neu"); // if($empf_kos_id==1){ // die("Schnitt: $hk_monatlich_bisher_schnitt Letzte:$hk_monatlich_letzte HK-Abrechnung: $hk_summe Voraus:$summe_hk_jahr"); // } /* bis hier alles ok */ $hk_monatlich_genau = (-$summe_hk_jahr + $hk_summe) / $anzahl_monate; if ($hk_monatlich_genau < 0) { $hk_monatlich_genau = substr($hk_monatlich_genau, 1); } echo "{$hk_monatlich_genau} = (-{$summe_hk_jahr} + {$hk_summe})/{$anzahl_monate};"; $vorauszahlung_n_jahr = $hk_monatlich_letzte * $anzahl_monate; $festgesetzt_n_jahr = $vorauszahlung_n_jahr - $hk_summe; $hk_vorschuss_neu = $festgesetzt_n_jahr / $anzahl_monate; // $hk_monatlich_letzte = 84.99; $x = $hk_monatlich_letzte + $hk_anp_betrag_neu; // intval($hk_anp_betrag_neu-1) // $hk_anp_betrag_neu = $x- $hk_monatlich_letzte; echo "HK {$hk_summe} {$hk_monatlich_letzte} {$hk_anp_betrag_neu} {$x} {$hk_vorschuss_neu}<br>"; echo "HK ANP: {$hk_anp_betrag_neu}<br><hr>"; // die(); // if($hk_anp_betrag_neu<0){ // $hk_anp_betrag_neu_pos = substr($hk_anp_betrag_neu,1);//positiv // } // echo "$hk_vorschuss_neu $hk_vorschuss_neu_pos"; // die(); // $hk_vorschuss_neu = $hk_monatlich_letzte + $hk_anp_betrag_neu; $hk_vorschuss_neu = $x; // echo "$hk_vorschuss_neu = $hk_monatlich_letzte + $hk_anp_betrag_neu_pos"; // die(); // $hk_anp_betrag = $hk_monatlich_genau - $hk_monatlich_bisher; // $hk_anp_betrag = $hk_monatlich_bisher_schnitt - $hk_monatlich_genau; // $hk_vorschuss_neu = $hk_monatlich_bisher + $hk_anp_betrag; // $hk_vorschuss_neu = $hk_monatlich_letzte + $hk_anp_betrag; $hk_monatlich_bisher_schnitt_a = nummer_punkt2komma($hk_monatlich_bisher_schnitt); $hk_monatlich_bisher_a = nummer_punkt2komma($hk_monatlich_letzte); // if($mv->mietvertrag_id=='1365'){ // die('SANEL'); // } $this->get_genkey_infos($this->bk_an_keyid); if ($this->bk_an_keyid == '1') { $hk_vorschuss_neu = $hk_vorschuss_neu + $this->bk_an_fest_betrag * $einheit_qm; } if ($this->bk_an_keyid == '2') { $hk_vorschuss_neu = $hk_vorschuss_neu + $this->bk_an_fest_betrag; } // $hk_anp_betrag = $hk_vorschuss_neu - $hk_monatlich_bisher; /* Anpassung auf Vollzahlen */ // $hk_vorschuss_neu = intval(substr($hk_vorschuss_neu,0,-2)); // $hk_anp_betrag = $hk_vorschuss_neu - $hk_monatlich_letzte; // die("$hk_anp_betrag = $hk_anp_betrag_neu **** $hk_vorschuss_neu - $hk_monatlich_letzte"); // if($hk_anp_betrag_neu!=0){ // if(($hk_anp_betrag < 5.00) && ($hk_anp_betrag < -5.00)){ // die("if(($hk_anp_betrag_neu > 0 && $hk_anp_betrag < 5.00) && ($hk_anp_betrag_neu < 0 && $hk_anp_betrag < -5.00)){"); // $hk_anp_betrag = 0.00; // $hk_vorschuss_neu =$hk_monatlich_letzte; // die('OK'); // die("$hk_anp_betrag < 5.00) && ($hk_anp_betrag < -5.00)"); // } // } $hk_anp_betrag_a = nummer_punkt2komma($hk_anp_betrag_neu); $hk_vorschuss_neu_a = nummer_punkt2komma($hk_vorschuss_neu); if ($check_hk == true) { $anp_tab[2]['KOSTENKAT'] = 'Heizkosten Vorauszahlung'; $anp_tab[2]['AKTUELL'] = "{$hk_monatlich_bisher_a} €"; $anp_tab[2]['ANPASSUNG'] = "{$hk_anp_betrag_a} €"; $anp_tab[2]['NEU'] = "{$hk_vorschuss_neu_a} €"; $pdf->ergebnis_tab["{$mieternummer} - {$empf}"]['HK_VORSCHUSS_ALT'] = $hk_monatlich_bisher_a; $pdf->ergebnis_tab["{$mieternummer} - {$empf}"]['HK_VORSCHUSS_NEU'] = $hk_vorschuss_neu_a; if ($hk_summe > $hk_monatlich_bisher_schnitt * $anzahl_monate) { die("{$mieternummer} {$empf} - Summe Hk Abrechnung > eingezahlte Summe für HK im Jahr"); } } if ($check_hk == true) { $pdf->ezText("<b>Anpassung der monatlichen Heiz- und Betriebskostenvorauszahlungen ab {$this->bk_verrechnungs_datum_d}</b>", 10); } else { $pdf->ezText("<b>Anpassung der monatlichen Betriebskostenvorauszahlungen ab {$this->bk_verrechnungs_datum_d}</b>", 10); } // $pdf->ezText("Objekt: $mv->haus_strasse $mv->haus_nr, $mv->haus_plz $mv->haus_stadt",12); $pdf->ezText("<b>{$this->bk_bezeichnung}</b>", 10); $pdf->ezText("Wirtschaftseinheit: {$this->bk_kos_bez} Einheit: {$mv->einheit_kurzname}", 10); // $pdf->ezText("Einheit: $mv->einheit_kurzname",12); $pdf->ezSetDy(-10); /* Faltlinie */ $pdf->setLineStyle(0.2); $pdf->line(5, 542, 20, 542); $pdf->ezText("{$anrede}", 10); $pdf->ezText("{$mv->mv_anrede}", 10); // $text_nachzahlung = "aufgrund der Nachzahlungsbetr�ge aus der letzten Betriebskostenabrechnung und der uns bisher bekannten Erhöhungen der Kosten für die Müllentsorgung durch die BSR, die Be- und Entwässerungskosten durch die Berliner Wasserbetriebe und die Erhöhung der Kosten für die Hausreinigung ändern wir die monatlichen Betriebskostenvorauszahlungen auf der Grundlage des § 560 BGB wie nachfolgend aufgeführt ab dem $this->bk_verrechnungs_datum_d."; $text_nachzahlung = "aufgrund der vorliegenden Nebenkostenabrechnung und zu erwartender Kostensteigerungen, erfolgt hiermit eine Änderung der monatlichen Betriebskostenvorauszahlungen auf der Grundlage des § 560 BGB, wie nachfolgend aufgeführt ab dem {$this->bk_verrechnungs_datum_d}."; $text_guthaben_berlin = "aufgrund der uns bisher bekannten Erhöhungen der Kosten für die Müllentsorgung durch die BSR, die Be- und Entwässerungskosten durch die Berliner Wasserbetriebe und die Erhöhung der Kosten für die Hausreinigung, erfolgt hiermit eine Änderung der monatlichen Betriebskostenvorauszahlungen auf der Grundlage des § 560 BGB wie nachfolgend aufgeführt ab dem {$this->bk_verrechnungs_datum_d}."; $text_guthaben = "aufgrund der vorliegenden Nebenkostenabrechnung und zu erwartender Kostensteigerungen, erfolgt hiermit eine Änderung der monatlichen Betriebskostenvorauszahlungen auf der Grundlage des § 560 BGB, wie nachfolgend aufgeführt ab dem {$this->bk_verrechnungs_datum_d}."; if ($txt == 'Nachzahlung') { $pdf->ezText("{$text_nachzahlung}", 10, array('justification' => 'full')); } $alttext = 'aufgrund der Nachzahlungsbeträge aus der letzten Betriebskostenabrechnung ändern wir die monatlichen Betriebskostenvorauszahlungen auf der Grundlage des § 560 Abs. 4 und 5 BGB wie nachfolgend aufgeführt ab dem $this->bk_verrechnungs_datum_d.'; if ($txt == 'Guthaben') { $pdf->ezText("{$text_guthaben}", 10, array('justification' => 'full')); } $pdf->ezSetDy(-15); /* BK NK ANPASSUNG */ $this->get_anpassung_details($_SESSION['profil_id'], 'Nebenkosten Vorauszahlung'); // $vorschuesse_aktuell =$summe_nebenkosten_jahr; $men = new mietentwicklung(); // $vorschuesse_aktuell = $men->nebenkosten_monatlich($empf_kos_id,date("m"),date("Y")); // $vorschuesse_aktuell = $mz->letzte_hk_vorauszahlung($empf_kos_typ, $empf_kos_id, $this->bk_jahr, 'Nebenkosten Vorauszahlung'); $jahr_vorschuss = date("Y"); // OKOKOK2015$vorschuesse_aktuell = $mz->letzte_hk_vorauszahlung($empf_kos_typ, $empf_kos_id, $jahr_vorschuss, 'Nebenkosten Vorauszahlung'); // $vorschuesse_aktuell = $mz->letzte_vorauszahlung_summe($empf_kos_typ, $empf_kos_id, $jahr_vorschuss, 'Nebenkosten Vorauszahlung'); $vorschuesse_aktuell = $mz->letzte_hk_vorauszahlung($empf_kos_typ, $empf_kos_id, $jahr_vorschuss, 'Nebenkosten Vorauszahlung'); /* * if($empf_kos_id=='1585'){ * ob_clean(); * die($vorschuesse_aktuell); * } */ $vorschuesse_neu = $g_beteiligung / $anzahl_monate; $vorschuesse_aktuell_a = nummer_punkt2komma($vorschuesse_aktuell); if ($vorschuesse_neu < 0) { $vorschuesse_neu = substr($vorschuesse_neu, 1); } $this->get_genkey_infos($this->bk_an_keyid); if ($this->bk_an_keyid == '1') { $vorschuesse_neu = $vorschuesse_neu + $this->bk_an_fest_betrag * $einheit_qm; } if ($this->bk_an_keyid == '2') { $vorschuesse_neu = $vorschuesse_neu + $this->bk_an_fest_betrag; } $vorschuesse_neu_a = nummer_punkt2komma($vorschuesse_neu); $anp_betrag = $vorschuesse_neu - $vorschuesse_aktuell; $anp_betrag_a = nummer_punkt2komma($anp_betrag); if ($ergebnis > 0) { $xbk = intval($vorschuesse_aktuell - $bk_anp_betrag_neu); // intval($hk_anp_betrag_neu-1) } else { $xbk = intval($vorschuesse_aktuell + $bk_anp_betrag_neu); // intval($hk_anp_betrag_neu-1) } $bk_anp_betrag_neu = $xbk - $vorschuesse_aktuell; echo "BK: {$vorschuesse_aktuell} {$bk_anp_betrag_neu} {$xbk}<br>"; echo "BK_ANP {$bk_anp_betrag_neu}<br>"; // $anp_betrag_a = nummer_punkt2komma($bk_anp_betrag_neu); // $vorschuesse_neu = $xbk; // $vorschuesse_neu_a =nummer_punkt2komma($vorschuesse_neu); // die(); /* Wenn keine VZ Anteilig gezahlt, BK Anpassen - Nettomieter!!!!!!!!! */ $mkk = new mietkonto(); if ($mkk->check_vz_anteilig($empf_kos_id, $monat, $jahr) == true) { // $vorschuesse_aktuell_a =nummer_punkt2komma(0); // $anp_betrag_a = nummer_punkt2komma(0); $anp_betrag_a = nummer_punkt2komma(intval($anp_betrag)); $vorschuesse_neu = $vorschuesse_aktuell + intval($anp_betrag); $vorschuesse_neu_a = nummer_punkt2komma($vorschuesse_neu); } else { /* Wenn VZ Anteilig gezahlt, keine BK Anpassen - Bruttomieter!!!!!!!!! */ $anp_betrag = 0; $vorschuesse_aktuell = 0; $vorschuesse_neu = 0; $anp_betrag_a = nummer_punkt2komma(0); $vorschuesse_neu_a = nummer_punkt2komma($vorschuesse_aktuell); } $anp_tab[1]['KOSTENKAT'] = 'Betriebskosten Vorauszahlung'; $anp_tab[1]['AKTUELL'] = "{$vorschuesse_aktuell_a} €"; $anp_tab[1]['ANPASSUNG'] = "{$anp_betrag_a} €"; $anp_tab[1]['NEU'] = "{$vorschuesse_neu_a} €"; $pdf->ergebnis_tab["{$mieternummer} - {$empf}"]['VORSCHUSS_ALT'] = "{$vorschuesse_aktuell_a}"; if ($vorschuesse_neu > $vorschuesse_aktuell) { $pdf->ergebnis_tab["{$mieternummer} - {$empf}"]['VORSCHUSS_NEU'] = "<b>{$vorschuesse_neu_a}</b>"; } else { $pdf->ergebnis_tab["{$mieternummer} - {$empf}"]['VORSCHUSS_NEU'] = "{$vorschuesse_neu_a}"; } $anp_tab[3]['KOSTENKAT'] = ''; $anp_tab[3]['AKTUELL'] = ""; $anp_tab[3]['ANPASSUNG'] = ""; $anp_tab[3]['NEU'] = ""; $anp_tab[4]['KOSTENKAT'] = ''; $a_km = nummer_punkt2komma($mk->ausgangs_kaltmiete + $vorschuesse_aktuell + $hk_monatlich_letzte); // $n_km= nummer_punkt2komma($mk->ausgangs_kaltmiete + $vorschuesse_neu + $hk_vorschuss_neu); // if($bk_summe && $check_hk==true){ $n_km = nummer_punkt2komma($mk->ausgangs_kaltmiete + $vorschuesse_neu + $hk_vorschuss_neu); // } // if($check_hk==true && !$bk_summe){ // $n_km= nummer_punkt2komma($mk->ausgangs_kaltmiete + $hk_vorschuss_neu); // } // if($check_hk==false && $bk_summe){ // $n_km= nummer_punkt2komma($mk->ausgangs_kaltmiete + $vorschuesse_neu); // } $anp_tab[4]['AKTUELL'] = "{$a_km} €"; $anp_tab[4]['ANPASSUNG'] = "<b>Neue Miete</b>"; $anp_tab[4]['NEU'] = "<b>{$n_km} €</b>"; $pdf->ergebnis_tab["{$mieternummer} - {$empf}"]['A_MIETE'] = $a_km; $pdf->ergebnis_tab["{$mieternummer} - {$empf}"]['N_MIETE'] = $n_km; $cols = array('KOSTENKAT' => "", "AKTUELL" => "Derzeitige Miete", 'ANPASSUNG' => "Anpassungsbetrag", 'NEU' => "Neue Miete ab {$this->bk_verrechnungs_datum_d}"); $pdf->ezTable($anp_tab, $cols, "", array('showHeadings' => 1, 'shaded' => 1, 'titleFontSize' => 7, 'fontSize' => 7, 'xPos' => 55, 'xOrientation' => 'right', 'width' => 500, 'cols' => array('AKTUELL' => array('justification' => 'right', 'width' => 100), 'ANPASSUNG' => array('justification' => 'right', 'width' => 100), 'NEU' => array('justification' => 'right', 'width' => 100)))); $pdf->ezSetDy(-15); $pdf->ezText("Die Anpassung des Heiz- und Betriebskostenvorschusses hat eine vertragsverändernde Wirkung, bedarf aber nicht Ihrer Zustimmung. Sollte Sie bei Ihrer Bank einen Dauerauftrag eingerichtet haben, bitten wir diesen ändern zu lassen. Bei uns vorliegenden Einzugsermächtigung erfolgt automatisch ab {$this->bk_verrechnungs_datum_d} der Lastschrifteinzug der geänderten Miete. \n\n", 10, array('justification' => 'full')); $pdf->ezSetDy(-15); // $pdf->ezText("$this->footer_zahlungshinweis",10); // $pdf->ezText("$this->footer_zahlungshinweis", 10, array('justification'=>'full')); } /* ENDE ANPASSUNGSBLATT */ /* Anschreiben nur für Mietverträge */ if ($empf_kos_typ == 'MIETVERTRAG') { $mv = new mietvertraege(); $mv->get_mietvertrag_infos_aktuell($empf_kos_id); /* Wenn Mietvertrag aktuell anpassen, sonst nicht (d.h. Mieter wohnt noch in der Einheit) */ // $this->get_anpassung_infos($_SESSION['profil_id']); $this->get_anpassung_details($this->profil_id, 'Nebenkosten Vorauszahlung'); $anp_datum = date_mysql2german($this->bk_an_anpassung_ab); $p = new partners(); $p->get_partner_info($_SESSION[partner_id]); $pdf->ezNewPage(); $pdf->addText(480, 697, 8, "{$p->partner_ort}, {$this->bk_berechnungs_datum_d}"); /* * echo '<pre>'; * print_r($mv); * die(); * * /*Wennn ausgezogen */ $pap = $mv->postanschrift[0]['anschrift']; if (!empty($pap)) { $pdf->ezText("{$pap}", 10); $pap = ''; } else { $pdf->ezText("{$mv->personen_name_string_u}\n{$mv->haus_strasse} {$mv->haus_nr}\n\n{$mv->haus_plz} {$mv->haus_stadt}", 10); } /* * if($mv->mietvertrag_aktuell=='0'){ * $anschrift_xx = $mv->postanschrift[0]['anschrift']; * $pdf->ezText("$anschrift_xx",10); * }else{ * $pdf->ezText("$mv->personen_name_string_u\n$mv->haus_strasse $mv->haus_nr\n\n$mv->haus_plz $mv->haus_stadt",10); * } */ $pdf->ezSetDy(-60); /* Pr�fen ob heizkostenabgerechnet worden sind */ $check_hk = $this->check_hk_abrechnung($empf_kos_typ, $empf_kos_id, $this->bk_jahr); if ($check_hk == true) { $hk_summe = $this->summe_hk_abrechnung($empf_kos_typ, $empf_kos_id, $this->bk_jahr); $hk_summe_a = nummer_punkt2komma($hk_summe); $pdf->ezText("<b>Heiz- und Betriebskostenabrechnung Einheit: {$mv->einheit_kurzname}</b>", 10); $tab_ans[1]['KOSTENART'] = 'Heizkosten/Warmwasser'; if ($hk_summe < 0) { $hk_erg_a = 'Nachzahlung'; } else { $hk_erg_a = 'Guthaben'; } $tab_ans[1]['ERGEBNIS'] = $hk_erg_a; $tab_ans[1]['SUMME'] = $hk_summe_a . ' €'; } else { $pdf->ezText("<b>Betriebskostenabrechnung {$this->bk_jahr} Einheit: {$mv->einheit_kurzname}</b>", 10); } $pdf->ezText("<b>{$this->bk_bezeichnung}</b>", 10); $pdf->ezText("Wirtschaftseinheit: {$this->bk_kos_bez}", 10); // $pdf->ezText("Einheit: $mv->einheit_kurzname",12); $pdf->ezSetDy(-12); /* Faltlinie */ $pdf->setLineStyle(0.2); $pdf->line(5, 542, 20, 542); $pdf->ezText("{$anrede}", 12); $pdf->ezText("{$mv->mv_anrede}", 10); $pdf->ezText("namens und im Auftrag der Eigentümer erhalten Sie nachfolgend die Betriebs- und Heizkostenabrechnung für das Kalenderjahr {$this->bk_jahr} mit entsprechenden Erläuterungen zu den einzelnen Abrechnungspositionen und eventuellen Veränderungen zu vorangegangenen Abrechnungen.\n\n\t\tDaraus ergibt sich für Sie folgendes Ergebnis:", 10, array('justification' => 'full')); $tab_ans[0]['KOSTENART'] = 'Betriebskosten'; if ($ergebnis < 0) { $bk_ergebnis = 'Nachzahlung'; } if ($ergebnis > 0) { $bk_ergebnis = 'Guthaben'; } if ($ergebnis == 0) { $bk_ergebnis = 'Ergebnis'; } /* Wenn kein Bruttomieter */ $mkk = new mietkonto(); if ($mkk->check_vz_anteilig($empf_kos_id, $monat, $jahr) == true) { // die('Sanel'); $tab_ans[0]['ERGEBNIS'] = $bk_ergebnis; $ergebnis_a_a = nummer_punkt2komma($ergebnis); $tab_ans[0]['SUMME'] = $ergebnis_a_a . ' €'; } else { // die($empf_kos_id); $bk_ergebnis = 0.0; $ergebnis_a_a = nummer_punkt2komma(0.0); $tab_ans[0]['SUMME'] = $ergebnis_a_a . ' €'; $ergebnis = 0.0; } // if($summe_nebenkosten_jahr>0){ // $tab_ans[0]['ERGEBNIS'] = $bk_ergebnis; // $ergebnis_a_a = nummer_punkt2komma($ergebnis); // $tab_ans[0]['SUMME'] = $ergebnis_a_a.' €'; // }else{ // $bk_ergebnis = 0.00; // $ergebnis_a_a = nummer_punkt2komma(0.00); // $tab_ans[0][SUMME] = $ergebnis_a_a.' €'; // $ergebnis = 0.00; // } $tab_ans[2][KOSTENART] = ''; $tab_ans[2][ERGEBNIS] = ''; $tab_ans[2][SUMME] = ''; $end_erg = $hk_summe + $ergebnis; if ($end_erg < 0) { $end_erg_ergebnis = 'Nachzahlung'; } if ($end_erg > 0) { $end_erg_ergebnis = 'Guthaben'; } if ($end_erg == 0) { $end_erg_ergebnis = 'Ergebnis'; } $tab_ans[3][KOSTENART] = '<b>Gesamtergebnis</b>'; $tab_ans[3][ERGEBNIS] = "<b>{$end_erg_ergebnis}</b>"; $tab_ans[3][SUMME] = '<b>' . nummer_punkt2komma($end_erg) . ' €' . '</b>'; $pdf->ezSetDy(-8); $cols = array('KOSTENART' => "Betriebskostenart", 'ERGEBNIS' => "Ergebnis", 'SUMME' => "Summe"); $pdf->ezTable($tab_ans, $cols, "", array('showHeadings' => 1, 'shaded' => 1, 'titleFontSize' => 7, 'fontSize' => 7, 'xPos' => 55, 'xOrientation' => 'right', 'width' => 500, 'cols' => array('KOSTENART' => array('justification' => 'left', 'width' => 345), 'ERGEBNIS' => array('justification' => 'left', 'width' => 55), 'SUMME' => array('justification' => 'right', 'width' => 100)))); } $pdf->ezSetDy(-10); $pdf->ezText("Die Abrechnungsunterlagen können nach vorheriger Terminabsprache bei uns im Büro eingesehen werden. Eventuelle Einwände gegen die Abrechnung sind bitte innerhalb eines Jahres nach Zugang der Abrechnung schriftlich bei uns anzuzeigen.", 10, array('justification' => 'full')); $pdf->ezSetDy(-10); $v_monat_arr = explode('-', $this->bk_verrechnungs_datum); $v_monat_name = monat2name($v_monat_arr['1']); $v_jahr = $v_monat_arr['0']; $pdf->ezText("Bei Vorlage einer Einzugsermächtigung wird das Guthaben aus der Abrechnung mit der Miete für den Monat {$v_monat_name} {$v_jahr} verrechnet. Nachzahlungsbeträge werden mit der Zahlung der Miete für den Monat {$v_monat_name} {$v_jahr} mit eingezogen, bitte sorgen Sie für eine ausreichende Kontodeckung bzw. informieren uns unbedingt, falls der Nachzahlungsbetrag nicht per Lastschrift eingezogen werden soll.", 10, array('justification' => 'full')); $pdf->ezSetDy(-10); if (isset($_SESSION[geldkonto_id])) { $g = new geldkonto_info(); $g->geld_konto_details($_SESSION[geldkonto_id]); } else { die("GELDKONTO AUSWÄHLEN"); } // $pdf->ezText("auf das Konto $g->kontonummer bei der $g->kredit_institut, BLZ $g->blz.\n\n",12); $pdf->ezText("Sollte uns keine Einzugsermächtigung vorliegen, bitten wir das Guthaben mit der nächsten Mietzahlung zu\nverrechnen bzw. den Nachzahlungsbetrag unter Angabe Ihrer Mieternummer <b>{$mieternummer}</b> auf das Konto mit der\n<b>IBAN</b> <b>{$g->IBAN1}</b> bei der <b>{$g->kredit_institut}</b> zu überweisen.", 10, array('justification' => 'left')); $pdf->ezSetDy(-10); $pdf->ezText("Bei verzogenen Mietern ist es uns nicht möglich die Nachzahlungsbeträge per Lastschrift einzuziehen, wir bitten hier um Überweisung auf das o.g. Geldkonto.", 10, array('justification' => 'full')); $pdf->ezText("Für die Erstattung eines Guthabens bitten wir Sie uns Ihre aktuelle Kontonummer schriftlich mitzuteilen.", 10); // print_r($g); // die(); $pdf->ezSetDy(-15); // $pdf->ezText("$this->footer_zahlungshinweis",10); /* Anschreiben ENDE */ } else { // $pdf->ezText("KEINE ANPASSUNG",10); } // }
function BuildPDFReport($userid) { $GLOBALS["SartON"] = time(); $q = new mysql(); $sql = "SELECT * FROM quarantine_report_users WHERE userid='{$userid}' and `type`=1 and `enabled`=1"; $ligne = mysql_fetch_array($q->QUERY_SQL($sql, "artica_backup")); if ($ligne["enabled"] == 0) { return; } $params = unserialize(base64_decode($ligne["parameters"])); $days = $params["days"]; $subject = $params["subject"]; $subject = str_replace("{", "", $subject); $subject = str_replace("}", "", $subject); $session = md5($user->password); if ($days < 1) { $days = 2; } $user = new user($userid); while (list($num, $ligne) = each($user->HASH_ALL_MAILS)) { $recipient_sql[] = "mailto='{$ligne}'"; } $date = date('Y-m-d'); $recipients = implode(" OR ", $recipient_sql); $sql = "SELECT mailfrom,zDate,MessageID,DATE_FORMAT(zdate,'%W %D %H:%i') as tdate,subject FROM quarantine\n\tWHERE (zDate>DATE_ADD('{$date}', INTERVAL -{$days} DAY)) AND ({$recipients}) ORDER BY zDate DESC;"; if ($GLOBALS["VERBOSE"]) { echo "{$sql}\n"; } $datepdf = date('Y-m-d'); $results = $q->QUERY_SQL($sql, "artica_backup"); $num_rows = mysql_num_rows($results); if (!$q->ok) { send_email_events("Build SMTP quarantine report failed for {$uid}", "{$sql}\n{$q->mysql_error}", "postfix"); return null; } if ($num_rows == 0) { return; } $pdf = new Cezpdf('a4', 'portrait'); $pdf->ezSetMargins(50, 70, 50, 50); $all = $pdf->openObject(); $pdf->saveState(); //$pdf->setStrokeColor(0,0,0,1); $pdf->line(20, 40, 578, 40); $pdf->line(20, 822, 578, 822); $pdf->addText(50, 34, 6, $date); $pdf->restoreState(); $pdf->closeObject(); $pdf->addObject($all, 'all'); $mainFont = dirname(__FILE__) . "/ressources/fonts/Helvetica.afm"; $codeFont = dirname(__FILE__) . "/ressources/fonts/Courier.afm"; $pdf->selectFont($mainFont); $pdf->ezText("{$user->DisplayName}\n", 30, array('justification' => 'centre')); $pdf->ezText("{$subject}\n", 20, array('justification' => 'centre')); $pdf->ezText("{$date} ({$num_rows} message(s))", 18, array('justification' => 'centre')); $pdf->ezStartPageNumbers(100, 30, 12, "left", "Page {PAGENUM}/{TOTALPAGENUM}"); $pdf->ezNewPage(); $options = array('showLines' => 2, 'showHeadings' => 0, 'shaded' => 2, 'shadeCol' => array(1, 1, 1), 'shadeCol2' => array(0.8, 0.8, 0.8), 'fontSize' => 11, 'textCol' => array(0, 0, 0), 'textCol2' => array(1, 1, 1), 'titleFontSize' => 16, 'titleGap' => 8, 'rowGap' => 5, 'colGap' => 10, 'lineCol' => array(1, 1, 1), 'xPos' => 'left', 'xOrientation' => 'right', 'width' => 500, 'maxWidth' => 500); while ($ligne = @mysql_fetch_array($results, MYSQL_ASSOC)) { $mail_subject = $ligne["subject"]; $from = trim($ligne["mailfrom"]); $zDate = $ligne["tdate"]; $MessageID = $ligne["MessageID"]; if ($from == null) { $from = "unknown"; } $domain = "unknown"; if (preg_match("#(.+?)@(.+)#", $from, $re)) { $domain = $re[2]; } $mail_subject = str_replace("{", "", $mail_subject); $mail_subject = str_replace("}", "", $mail_subject); $uri = "<c:alink:{{$params["URI"]}/user.quarantine.query.php?uid={$user->uid}&session={$session}&mail={$MessageID}>{$mail_subject}</c:alink>"; $data[] = array($zDate, $from, $uri); } $pdf->ezTable($data, $cols, $subject, $options); $pdfcode = $pdf->output(); $fname = "/tmp/" . date('Ymdhi') . "-{$user->mail}-quarantines.pdf"; if ($GLOBALS["VERBOSE"]) { echo "{$pdf->messages}\nbuilding {$fname}\n"; } @unlink($fname); if ($GLOBALS["VERBOSE"]) { echo "Building {$fname}\n"; } $fp = fopen($fname, 'w'); fwrite($fp, $pdfcode); fclose($fp); if (preg_match("#(.+?)@(.+)#", $user->mail, $re)) { $domain = $re[2]; } $PostmasterAdress = "no-reply-quarantine@{$domain}"; $ini = new Bs_IniHandler("/etc/artica-postfix/smtpnotif.conf"); if ($ini->_params["SMTP"]["smtp_sender"] != null) { $PostmasterAdress = $ini->_params["SMTP"]["smtp_sender"]; } if (file_exists('/etc/artica-postfix/settings/Daemons/PostfixPostmaster')) { $PostmasterAdress = trim(@file_get_contents('/etc/artica-postfix/settings/Daemons/PostfixPostmaster')); } $unix = new unix(); $sendmail = $unix->find_program("sendmail"); $mail = new PHPMailer(true); $mail->IsSendmail(); $mail->AddAddress($user->mail, $user->DisplayName); $mail->AddReplyTo($PostmasterAdress, $PostmasterAdress); $mail->From = $PostmasterAdress; $mail->Subject = $subject; $mail->Body = "{$subject}\nSee attached file...\n"; $mail->AddAttachment($fname, basename($fname)); $content = $mail->Send(true); $tmpfile = "/tmp/" . md5(date('Y-m-d H:is') . "-{$user->uid}-msmtp"); file_put_contents($tmpfile, $content); $cmd = "{$sendmail} -bm -t -f {$PostmasterAdress} <{$tmpfile}"; system($cmd); @unlink($tmpfile); @unlink($fname); $SartOff = time(); $time_duration = distanceOfTimeInWords($GLOBALS["SartON"], $SartOff); send_email_events("SMTP quarantine report for {$user->mail} (success) {$num_rows} message(s)", "duration:{$time_duration}\nnothing to say more...", "postfix"); }
function creaPDF($ids, $tmpName, $path, $PATHQR, $tmp = "") { require dirname(dirname(dirname(__FILE__))) . '/f4/configuracion/utils.php'; require dirname(dirname(dirname(__FILE__))) . '/f4/configuracion/importeco.php'; require dirname(dirname(dirname(__FILE__))) . "/gui/QRCode/qr_imgV2.php"; $data = ""; $facturaController = new FacturaController($path); $selloController = new SelloController($path); $empresaController = new EmpresaController($path); $sucursalController = new SucursalController($path); $FWK_PDFFONTS = 'pdf/fonts/'; $FWK_PDFDEFAULTFONT = 'pdf/fonts/Helvetica.afm'; $FWK_PDFCOURIERFONT = 'pdf/fonts/Courier.afm'; // Obtener factura y sus anexos $TIPOSCOMPROBANTEMXP = array(1 => "Factura", 3 => "Nota de Cr.", 2 => "NOTA DE DEBITO"); $idconsulta = ""; $idconsulta = explode(",", trim($ids)); foreach ($idconsulta as $valor) { if (is_null($valor) || $valor == "") { array_pop($idconsulta); } } $contadorTotalPaginas = count($idconsulta); $contadorPagina = 1; // Crea el documento pdf $pdf = new Cezpdf('LETTER', 'portrait'); foreach ($idconsulta as $idfactura) { $data['idfactura'] = $idfactura; $factura = $facturaController->execute('facturaParaPdf', $data); $row_factura = $factura['respuesta']; $info_xtra = json_decode($row_factura["info_xtra"]); $data['idfacefactura'] = $factura['respuesta']['idface_factura']; $data['idempresa'] = $factura['respuesta']['idempresa']; $data['idsello'] = $factura['respuesta']['idsello']; $version = $factura['respuesta']['version']; $addenda = $facturaController->execute('datosAddenda', $data); $row_addenda = $addenda['respuesta']; $empresa = $empresaController->execute('allId', $data); $row_empresa = $empresa['respuesta']; $sello = $selloController->execute('obtenerPorIdsello', $data); $row_sello = $sello['respuesta']; $data['sucursal'] = $sello['respuesta']['sucursal']; $sucursal = $sucursalController->execute('nombreSucIdempresa', $data); $row_sucursal = $sucursal['respuesta']; $xmlArray = xml2array(base64_decode($row_factura['factura'])); $attr = "_attr"; if ($version === "3.2") { $NSP = "cfdi:"; } else { $NSP = ""; } $comprobante = $NSP . "Comprobante"; $emisor = $NSP . "Emisor"; $emisorDomFiscal = $NSP . "DomicilioFiscal"; $emisorExpedidoEn = $NSP . "ExpedidoEn"; $receptor = $NSP . "Receptor"; $domicilio = $NSP . "Domicilio"; $concepto = $NSP . "Conceptos"; $conceptoTag = $NSP . "Concepto"; $impuestos = $NSP . "Impuestos"; $traslado = $NSP . "Traslados"; $trasladoTag = $NSP . "Traslado"; $retencion = $NSP . "Retenciones"; $retencionTag = $NSP . "Retencion"; //INICIALIZACIONES $comprobanteNode = null; $emisorNode = null; $emisordomicilioNode = null; $expedidoNode = null; $receptorNode = null; $receptordomicilioNode = null; $conceptoNode = null; $impuestosNode = null; $trasladoNode = null; $retencionNode = null; // -------------------------------------------------chs -------------------------------------------------------------- $comprobanteNode = $xmlArray[$comprobante . $attr]; $emisorNode = $xmlArray[$comprobante][$emisor . $attr]; $emisordomicilioNode = $xmlArray[$comprobante][$emisor][$emisorDomFiscal . $attr]; $expedidoNode = isset($xmlArray[$comprobante][$emisor][$emisorExpedidoEn . $attr]) ? $xmlArray[$comprobante][$emisor][$emisorExpedidoEn . $attr] : ""; $receptorNode = $xmlArray[$comprobante][$receptor . $attr]; $receptordomicilioNode = $xmlArray[$comprobante][$receptor][$domicilio . $attr]; $conceptos = $xmlArray[$comprobante][$concepto]; $impuestosNode = $xmlArray[$comprobante][$impuestos . $attr]; $traslados = $xmlArray[$comprobante][$impuestos][$traslado]; $retenciones = isset($xmlArray[$comprobante][$impuestos][$retencion][$retencionTag . $attr]) ? $xmlArray[$comprobante][$impuestos][$retencion][$retencionTag . $attr] : ""; $regimenFiscal = $xmlArray[$comprobante][$emisor]["cfdi:RegimenFiscal_attr"]["Regimen"]; // --------------------------------------------------------------------------------------------------------------- //descuentos $desc1 = 0.0; $desc2 = 0.0; //================================================================================================================== $pdf->ezSetMargins(100, 30, 30, 30); $pdf->selectFont($FWK_PDFDEFAULTFONT); $pdf->setLineStyle(0.7, '', '', '', 0); $pdf->openHere('Fit'); if ($row_factura['tipocfd'] == 3) { $pdf->setStrokeColor(255, 0, 0); } if ($row_factura['tipocfd'] == 2) { $pdf->setStrokeColor(0, 255, 0); } // Inicia numeracin de paginas. $pagina = 1; $pdf->ezStartPageNumbers(500, 15, 10, '', '{PAGENUM} de {TOTALPAGENUM}', 1); $primeraPagina = $pdf->currentPage; // i. Agrega el logo de la empresa $pathToLogo = $path == "../" ? "../f4/extensiones/" : ""; $logofile = "logos/f.jpg"; //TENDRA QUE VENIR DE UN PARAMETRO EN LA BD. /*if(isset($row_empresa['rfc']) && !empty($row_empresa['rfc'])) $logofile="logos/".$row_empresa['rfc'].".jpg";*/ if (isset($sucursal["respuesta"]["sucursal"]) && !empty($sucursal["respuesta"]["sucursal"])) { $logofile = "logos/" . strtolower($sucursal["respuesta"]["sucursal"]) . ".jpg"; } error_log($logofile); if ($comprobanteNode['serie'] == "X") { $logofile = "logos/wingu-xpress.jpg"; } $pdf->addJpegFromFile($pathToLogo . $logofile, 30, 705, 140); // i. Agrega la leyenda "cancelada" if ($row_factura['estatus'] == 0) { $pdf->setColor(0.9, 0.9, 0.9); $pdf->addText(180, 200, 65, "<b>CANCELADA</b>", -45); $pdf->setColor(0, 0, 0); } // ------------------------------------------ENCABEZADO ------------------------------------------ //ENCABEZADO DE LA FACTURA $tipoDocto = $row_factura['tipodocumento']; $tipoDocto1 = $row_factura['tipodocumento'] == "FACTURA" ? "FACTURA" : ""; $tipoDocto2 = $row_factura['tipodocumento'] == "NOTA CARGO" ? "FACTURA" : ""; $tipoDocto3 = $row_factura['tipodocumento'] == "NOTA CREDITO" ? "NOTA DE CREDITO" : ""; $emisor = utf8_decode($emisorNode['nombre'] . "\n" . $emisorNode['rfc']) . "\n"; $noInterior = isset($emisordomicilioNode['noInterior']) ? $emisordomicilioNode['noInterior'] : ""; $noExterior = isset($emisordomicilioNode['noExterior']) ? $emisordomicilioNode['noExterior'] : ""; $emisor .= utf8_decode($emisordomicilioNode['calle'] . " {$noExterior}"); $emisor .= utf8_decode($emisordomicilioNode['colonia']); if (isset($emisordomicilioNode['localidad'])) { $emisor .= "\n" . utf8_decode($emisordomicilioNode['localidad']); } if ($emisordomicilioNode['municipio'] != "" && isset($emisordomicilioNode['municipio'])) { $emisor .= "\n" . utf8_decode($emisordomicilioNode['municipio']); } if ($emisordomicilioNode['estado'] != "" && isset($emisordomicilioNode['estado'])) { $emisor .= ", " . utf8_decode($emisordomicilioNode['estado']); } if ($emisordomicilioNode['codigoPostal'] != "" && isset($emisordomicilioNode['codigoPostal'])) { $emisor .= "\nCP " . utf8_decode($emisordomicilioNode['codigoPostal']); } $emisor .= " " . utf8_decode($emisordomicilioNode['pais']); $telefono = isset($row_empresa['telefono']) ? $row_empresa['telefono'] : ""; $emisor .= "\nTel: " . $telefono . "\n"; $mail = isset($row_empresa['mail']) ? $row_empresa['mail'] : ""; $emisor .= "\n" . $mail; $emisor1 = utf8_decode($emisorNode['nombre']); $sucursal = ""; if ($expedidoNode != "") { if (utf8_decode($row_sucursal['sucursal']) == "Q") { $tipoSucursal = utf8_decode('Querétaro'); } else { if (utf8_decode($row_sucursal['sucursal']) == "F") { $tipoSucursal = utf8_decode('5/6'); } else { if (utf8_decode($row_sucursal['sucursal']) == "S") { $tipoSucursal = utf8_decode('Santa Fe'); } } } $sucursal = "Sucursal " . $tipoSucursal . "\n"; if (utf8_decode($row_sucursal['sucursal']) != "S") { $noInteriorExpedido = isset($expedidoNode['noInterior']) ? $expedidoNode['noInterior'] : ""; $sucursal .= utf8_decode($expedidoNode['calle'] . " " . $expedidoNode['noExterior'] . " ") . "\n"; $sucursal .= utf8_decode($expedidoNode['colonia']) . "\n"; $sucursal .= utf8_decode($expedidoNode['municipio']) . ", " . utf8_decode($expedidoNode['estado']) . "\n"; $sucursal .= "CP " . utf8_decode($expedidoNode['codigoPostal']) . " " . utf8_decode($expedidoNode['pais']); } } ////////// i. Nombre del emisor $colNames = array(); $tableData = array(array("dato" => $emisor1)); $colOptions = array("dato" => array('justification' => 'left', 'width' => 200)); $options = array('showLines' => 0, 'showHeadings' => 0, 'shaded' => 0, 'shadeCol' => array(1, 1, 1), 'fontSize' => 9, 'textCol' => array(0, 0, 0), 'rowGap' => 0, 'colGap' => 0, 'xPos' => 200, 'xOrientation' => 'right', 'width' => 200, 'cols' => $colOptions, 'innerLineThickness' => 0.3, 'outerLineThickness' => 0.3); // Dibuja la tabla nombre del emisor $pdf->ezSetY(765); $pdf->ezTable($tableData, $colNames, "", $options); ////////// i. Datos del emisor y de la sucursal $tableData = array(array("emisor" => $emisor, "espacio" => "", "sucursal" => $sucursal)); $colOptions = array("emisor" => array('justification' => 'left', 'width' => 150), "espacio" => array('justification' => 'left', 'width' => 3), "sucursal" => array('justification' => 'left', 'width' => 100)); $options = array('showLines' => 0, 'showHeadings' => 0, 'shaded' => 0, 'shadeCol' => array(1, 1, 1), 'fontSize' => 7, 'textCol' => array(0, 0, 0), 'rowGap' => 0, 'colGap' => 0, 'xPos' => 190, 'xOrientation' => 'right', 'width' => 335, 'cols' => $colOptions, 'innerLineThickness' => 0.3, 'outerLineThickness' => 0.3); // Dibuja la tabla $pdf->ezTable($tableData, "", "", $options); ////////// i. Datos del documento $foliodocto = rellena("0", 6, $comprobanteNode['folio']); $seriedocto = $comprobanteNode['serie']; if (!empty($seriedocto)) { $foliodocto = $seriedocto . "-" . rellena("0", 6, $comprobanteNode['folio']); } $fechastr = $comprobanteNode['fecha']; $fechatok = explode("T", $fechastr); $toksf = explode("-", $fechatok[0]); $fechastr = $toksf[2] . "-" . $toksf[1] . "-" . $toksf[0] . " " . $fechatok[1]; $fechastrcfdi = $row_factura['FechaTimbrado']; $ncert = $comprobanteNode['noCertificado']; $aprob = $row_factura['noCertificadoSAT']; //chs $tableData = array(array("dato" => "<b>" . $tipoDocto1 . $tipoDocto2 . $tipoDocto3 . "</b>"), array("dato" => "<b>" . $foliodocto . "</b>"), array("dato" => "FECHA DE EMISION"), array("dato" => $fechastr), array("dato" => "LUGAR DE EXPEDICION"), array("dato" => utf8_decode($info_xtra->LugarExpedicion)), array("dato" => "FECHA DE CERTIFICACION"), array("dato" => $fechastrcfdi), array("dato" => "No. de Serie del Certificado del Emisor"), array("dato" => $ncert), array("dato" => "No. de Serie del Certificado del SAT"), array("dato" => $aprob), array("dato" => "Folio Fiscal"), array("dato" => $row_factura['uuid'])); $colOptions = array("dato" => array('justification' => 'left', 'width' => 120)); /*JASR*/ $options = array('showLines' => 1, 'showHeadings' => 0, 'shaded' => 2, 'shadeCol' => array(1, 1, 1), 'shadeCol2' => array(0.9, 0.9, 0.9), 'fontSize' => 7, 'textCol' => array(1, 1, 1), 'rowGap' => 2, 'colGap' => 5, 'xPos' => 455, 'xOrientation' => 'right', 'width' => 120, 'cols' => $colOptions, 'innerLineThickness' => 0.3, 'outerLineThickness' => 0.3); // Dibuja la tabla datos del documento $pdf->ezSetDy(70); $pdf->ezTable($tableData, "", "", $options); ////////// i. Datos del cliente $noInterior = isset($receptordomicilioNode['noInterior']) ? utf8_decode($receptordomicilioNode['noInterior']) : ""; $municipio = isset($receptordomicilioNode['municipio']) ? $receptordomicilioNode['municipio'] : ""; $localidadCliente = isset($receptordomicilioNode['localidad']) ? utf8_decode($receptordomicilioNode['localidad']) : ""; $tableData1 = array(array("cliente" => "<b>Cliente</b>"), array("cliente" => utf8_decode($receptorNode['nombre'])), array("cliente" => "RFC: " . utf8_decode($receptorNode['rfc'])), array("cliente" => utf8_decode($receptordomicilioNode['calle']) . " " . utf8_decode($receptordomicilioNode['noExterior']) . " {$noInterior} "), array("cliente" => utf8_decode($receptordomicilioNode['colonia']) . " " . $localidadCliente), array("cliente" => utf8_decode($municipio) . ", " . utf8_decode($receptordomicilioNode['estado']) . " " . utf8_decode($receptordomicilioNode['codigoPostal']) . " \n" . utf8_decode($receptordomicilioNode['pais'])), array("cliente" => utf8_decode("Atención: " . $info_xtra->Receptor->contacto . " Cliente: " . $info_xtra->Receptor->noCliente)), array("cliente" => utf8_decode("Tel: " . $info_xtra->Receptor->telefono))); $formaDePago = isset($comprobanteNode['formaDePago']) ? $comprobanteNode['formaDePago'] : "PAGO EN UNA SOLA EXHIBICION"; $metodoPago = isset($comprobanteNode['metodoDePago']) ? $comprobanteNode['metodoDePago'] : "No Identificado"; $numeroCuentaPago = isset($comprobanteNode['NumCtaPago']) ? $comprobanteNode['NumCtaPago'] : "No Identificado"; $tableData2 = array(array("expedido" => "Expedido en: " . utf8_decode($info_xtra->LugarExpedicion)), array("expedido" => "Forma de Pago: " . utf8_decode($formaDePago)), array("expedido" => "Metodo de Pago: " . utf8_decode($metodoPago)), array("expedido" => "No. de Cuenta: " . utf8_decode($numeroCuentaPago)), array("expedido" => "Condiciones de Pago: " . utf8_decode($comprobanteNode['condicionesDePago'])), array("expedido" => "Regimen Fiscal: " . utf8_decode(preg_replace("/Ii/", "II", ucwords(strtolower($regimenFiscal))))), array("expedido" => "Tipo de Cambio: " . $comprobanteNode['TipoCambio'] . " Moneda: " . $comprobanteNode['Moneda']), array("expedido" => "Elaboro: " . utf8_decode($info_xtra->Vendedor)), array("expedido" => utf8_decode("Póliza: " . $info_xtra->NumeroPoliza . " SAP No: " . $info_xtra->NumeroPedido))); $tableData = array(); $aux = count($tableData1) >= count($tableData2) ? $tableData1 : $tableData2; $cont = 0; foreach ($aux as $arr) { array_push($tableData, array("cliente" => $tableData1[$cont]["cliente"], "expedido" => $tableData2[$cont]["expedido"])); $cont++; } $colNames = array("cliente" => "", "expedido" => ""); $colOptions = array("cliente" => array('justification' => 'left', 'width' => 205), "expedido" => array('justification' => 'left', 'width' => 205)); $options = array('showLines' => 1, 'showHeadings' => 0, 'shaded' => 1, 'shadeCol' => array(0.9, 0.9, 0.9), 'fontSize' => 7, 'textCol' => array(0, 0, 0), 'rowGap' => 2, 'colGap' => 5, 'xPos' => 35, 'xOrientation' => 'right', 'width' => 410, 'cols' => $colOptions, 'innerLineThickness' => 0.3, 'outerLineThickness' => 0.3); $pdf->ezSetDy(125); $pdf->ezTable($tableData, $colNames, "", $options); //encabezado //error_log(print_r($info_xtra,true)); $tableData = array(array("dato" => utf8_decode($info_xtra->Consumo->NotaEncabezado))); $colOptions = array("dato" => array('justification' => 'left', 'width' => 540)); $options = array('showLines' => 1, 'showHeadings' => 0, 'shaded' => 0, 'shadeCol' => array(0.9, 0.9, 0.9), 'fontSize' => 7, 'textCol' => array(0, 0, 0), 'rowGap' => 5, 'colGap' => 5, 'xPos' => 35, 'xOrientation' => 'right', 'width' => 120, 'cols' => $colOptions, 'innerLineThickness' => 0.3, 'outerLineThickness' => 0.3); $pdf->ezSetDy(-10); $pdf->ezTable($tableData, "", "", $options); $actualY = $pdf->y; $pdf->setColor(0, 0, 0); $pdf->filledRectangle(30, $actualY - 30, 540, 18); $pdf->ezSetY($actualY - 15); $pdf->setColor(1, 1, 1); $pdf->ezText("<b>Codigo</b>", 7, array('left' => 25, 'justification' => 'left')); $pdf->ezSetY($actualY - 15); $pdf->ezText("<b>Descripcion</b>", 7, array('left' => 180, 'justification' => 'left')); $pdf->ezSetY($actualY - 15); $pdf->ezText("<b>Cant</b>", 7, array('left' => 361, 'justification' => 'left')); $pdf->ezSetY($actualY - 15); $pdf->ezText("<b>Unidad</b>", 7, array('left' => 398, 'justification' => 'left')); $pdf->ezSetY($actualY - 15); $pdf->ezText("<b>Unitario</b>", 7, array('left' => 445, 'justification' => 'left')); $pdf->ezSetY($actualY - 15); $pdf->ezText("<b>Importe</b>", 7, array('left' => 497, 'justification' => 'left')); ////////// i. Partidas $tableData = array(); $renglones = 0; $rowData = array("codigo" => "", "cantidad" => "", "unidad" => "", "descripcion" => "", "unitario" => "", "importe" => ""); $partidaCnt = 0; $cantidadArrayConceptos = count($conceptos); foreach ($conceptos as $key => $conceptoNode) { if (stristr($key, $attr) && $cantidadArrayConceptos == 2) { $partidaCnt++; $renglones += 2; $currentObj = array(); $descripcion = $conceptoNode['descripcion']; $totalPalabras = strlen($descripcion); $totalCaracteres = 4800; if ($totalPalabras >= $totalCaracteres) { $pagDesc = ceil($totalPalabras / $totalCaracteres); $aux = 1; $array = array(); for ($i = 1; $i <= $pagDesc; $i++) { if ($i == $pagDesc) { $array[] = $totalPalabras; } else { $val = $aux += $totalCaracteres; $array[] = $val; } } $desc = array(); $o = 0; foreach ($array as $valor) { $desc[] = substr($descripcion, $o, $valor); $o += $valor - $o; } $cont = 1; foreach ($desc as $descripcionexp) { $currentObj["codigo"] = $info_xtra->Consumo->partidas[$partidaCnt - 1]->codigo; $currentObj["cantidad"] = number_format(abs(doubleval($conceptoNode['cantidad'])), 2); //$currentObj["unidad"]= (isset($conceptoNode['unidad'])) ? $conceptoNode['unidad'] : "No Aplica"; $currentObj["unidad"] = $conceptoNode['unidad']; //)) ? $conceptoNode['unidad'] : "No Aplica"; $currentObj["descripcion"] = str_replace("__", "\n", utf8_decode($descripcionexp) . "\n" . utf8_decode($info_xtra->Consumo->partidas[$partidaCnt - 1]->nota)); if ($info_xtra->TipoImpresion == "KI2") { $contPartidas = count($info_xtra->Consumo->partidas); for ($i = 1; $i < $contPartidas; $i++) { $currentObj["descripcion"] .= $info_xtra->Consumo->partidas[$i]->codigo . " " . $info_xtra->Consumo->partidas[$i]->cantidad . " " . $info_xtra->Consumo->partidas[$i]->unidad . " " . $info_xtra->Consumo->partidas[$i]->descripcion . " \$" . $info_xtra->Consumo->partidas[$i]->valorUnitario . " \n"; } } $currentObj["unitario"] = number_format($conceptoNode['valorUnitario'], 2); $currentObj["importe"] = number_format(doubleval($conceptoNode['importe']), 2); $for = $cont++; log_action("for:::" . $for); if ($for > 1) { $currentObj["codigo"] = ""; $currentObj["cantidad"] = ""; $currentObj["unidad"] = ""; $currentObj["unitario"] = ""; $currentObj["importe"] = ""; } array_push($tableData, $currentObj); } } else { $currentObj["codigo"] = $info_xtra->Consumo->partidas[$partidaCnt - 1]->codigo; $currentObj["cantidad"] = number_format(abs(doubleval($conceptoNode['cantidad'])), 2); //$currentObj["unidad"]= (isset($conceptoNode['unidad'])) ? $conceptoNode['unidad'] : "No Aplica"; $currentObj["unidad"] = $conceptoNode['unidad']; //)) ? $conceptoNode['unidad'] : "No Aplica"; $currentObj["descripcion"] = str_replace("__", "\n", utf8_decode($descripcion) . "\n" . utf8_decode($info_xtra->Consumo->partidas[$partidaCnt - 1]->nota)); if ($info_xtra->TipoImpresion == "KI2") { $contPartidas = count($info_xtra->Consumo->partidas); for ($i = 1; $i < $contPartidas; $i++) { $currentObj["descripcion"] .= utf8_decode($info_xtra->Consumo->partidas[$i]->codigo . " " . $info_xtra->Consumo->partidas[$i]->cantidad . " " . $info_xtra->Consumo->partidas[$i]->unidad . " " . $info_xtra->Consumo->partidas[$i]->descripcion . " " . $info_xtra->Consumo->partidas[$i]->valorUnitario) . " \n"; } } $currentObj["unitario"] = number_format($conceptoNode['valorUnitario'], 2); $currentObj["importe"] = number_format(doubleval($conceptoNode['importe']), 2); array_push($tableData, $currentObj); } } else { foreach ($conceptoNode as $key1 => $conceptoNode1) { log_action(print_r($key1, TRUE)); if (stristr($key1, $attr)) { $partidaCnt++; $renglones += 2; $currentObj = array(); $currentObj["codigo"] = $info_xtra->Consumo->partidas[$partidaCnt - 1]->codigo; $currentObj["cantidad"] = number_format(abs(doubleval($conceptoNode1['cantidad'])), 2); //$currentObj["unidad"]= (isset($conceptoNode['unidad'])) ? $conceptoNode['unidad'] : "No Aplica"; $currentObj["unidad"] = $conceptoNode1['unidad']; //)) ? $conceptoNode['unidad'] : "No Aplica"; $currentObj["descripcion"] = str_replace("__", "\n", utf8_decode($conceptoNode1['descripcion'] . "\n" . $info_xtra->Consumo->partidas[$partidaCnt - 1]->nota)); if ($info_xtra->TipoImpresion == "KI2") { $contPartidas = count($info_xtra->Consumo->partidas); for ($i = 1; $i < $contPartidas; $i++) { $currentObj["descripcion"] .= $info_xtra->Consumo->partidas[$i]->codigo . " " . $info_xtra->Consumo->partidas[$i]->cantidad . " " . $info_xtra->Consumo->partidas[$i]->unidad . " " . $info_xtra->Consumo->partidas[$i]->descripcion . " \$" . $info_xtra->Consumo->partidas[$i]->valorUnitario . " \n"; } } $currentObj["unitario"] = number_format($conceptoNode1['valorUnitario'], 2); $currentObj["importe"] = number_format(doubleval($conceptoNode1['importe']), 2); array_push($tableData, $currentObj); } } //fin foreach 2 chs 20130705 } } $currentObj = array(); $currentObj["codigo"] = ""; $currentObj["cantidad"] = ""; $currentObj["unidad"] = ""; $currentObj["descripcion"] = str_replace("__", "\n", utf8_decode($row_factura["fnotas"])); $currentObj["unitario"] = ""; $currentObj["importe"] = ""; array_push($tableData, $currentObj); if (isset($row_addenda['cl_fld1'])) { $currentObj = array(); $currentObj["cantidad"] = ""; $currentObj["descripcion"] = $row_addenda['cl_fld1']; if (!empty($row_addenda['cl_fld2'])) { $currentObj["descripcion"] .= "\n" . $row_addenda['cl_fld2']; } if (!empty($row_addenda['cl_fld3'])) { $currentObj["descripcion"] .= "\n" . $row_addenda['cl_fld3']; } if (!empty($row_addenda['cl_fld4'])) { $currentObj["descripcion"] .= "\n" . $row_addenda['cl_fld4']; } if (!empty($row_addenda['cl_fld5'])) { $currentObj["descripcion"] .= "\n" . $row_addenda['cl_fld5']; } if (!empty($row_addenda['cl_fld6'])) { $currentObj["descripcion"] .= "\n" . $row_addenda['cl_fld6']; } if (!empty($row_addenda['cl_fld7'])) { $currentObj["descripcion"] .= "\n" . $row_addenda['cl_fld7']; } if (!empty($row_addenda['cl_fld8'])) { $currentObj["descripcion"] .= "\n" . $row_addenda['cl_fld8']; } if (!empty($row_addenda['cl_fld9'])) { $currentObj["descripcion"] .= "\n" . $row_addenda['cl_fld9']; } if (!empty($row_addenda['cl_fld10'])) { $currentObj["descripcion"] .= "\n" . $row_addenda['cl_fld10']; } if (!empty($row_addenda['cl_fld11'])) { $currentObj["descripcion"] .= "\n" . $row_addenda['cl_fld11']; } if (!empty($row_addenda['cl_fld12'])) { $currentObj["descripcion"] .= "\n" . $row_addenda['cl_fld12']; } $currentObj["unitario"] = ""; $currentObj["importe"] = ""; array_push($tableData, $currentObj); } $currentObj = array(); $currentObj["codigo"] = ""; $currentObj["cantidad"] = ""; $currentObj["unidad"] = ""; $currentObj["descripcion"] = ""; $currentObj["unitario"] = ""; $currentObj["importe"] = ""; if ($info_xtra->TipoImpresion == "KI2") { for ($renglones; $renglones < 10 - count($info_xtra->Consumo->partidas) * 0.95; $renglones++) { array_push($tableData, $currentObj); } } else { if ($renglones < 10) { for ($renglones; $renglones < 10; $renglones++) { array_push($tableData, $currentObj); } } } $colNames = array("codigo" => "", "descripcion" => "", "cantidad" => "", "unidad" => "", "unitario" => "", "importe" => ""); $colOptions = array("codigo" => array('justification' => 'center', 'width' => 70), "descripcion" => array('justification' => 'left', 'width' => 280), "cantidad" => array('justification' => 'center', 'width' => 40), "unidad" => array('justification' => 'left', 'width' => 40), "unitario" => array('justification' => 'right', 'width' => 55), "importe" => array('justification' => 'right', 'width' => 55)); $options = array('showLines' => 1, 'showHeadings' => 1, 'shaded' => 1, 'shadeCol' => array(0.9, 0.9, 0.9), 'fontSize' => 7, 'textCol' => array(0, 0, 0), 'rowGap' => 4, 'colGap' => 5, 'xPos' => 35, 'xOrientation' => 'right', 'width' => 410, 'cols' => $colOptions, 'innerLineThickness' => 0.3, 'outerLineThickness' => 0.3); // Dibuja la tabla partidas $pdf->ezSetDy(11); $pdf->ezTable($tableData, $colNames, "", $options); ////////// i. Cantidad con letra $cadena = covertirNumLetras(number_format($comprobanteNode['total'], 2, ".", '')); if ($comprobanteNode['Moneda'] == "USD") { $cadena = str_replace("M.N.", "USD", $cadena); $cadena = str_replace("PESOS", "DOLARES", $cadena); $cadena = str_replace("PESO", "DOLAR", $cadena); } $tableData = array(array("dato" => "<b>Nota:</b>\n" . utf8_decode($info_xtra->Consumo->notaAlPie)), array("dato" => "<b>Total con letra</b>\n" . trim($cadena))); $colNames = array("dato" => "<b>Cant</b>"); $colOptions = array("dato" => array('justification' => 'left', 'width' => 390)); $options = array('showLines' => 1, 'showHeadings' => 0, 'shaded' => 1, 'shadeCol' => array(0.9, 0.9, 0.9), 'fontSize' => 7, 'textCol' => array(0, 0, 0), 'rowGap' => 2.5, 'colGap' => 5, 'xPos' => 35, 'xOrientation' => 'right', 'width' => 120, 'cols' => $colOptions, 'innerLineThickness' => 0.3, 'outerLineThickness' => 0.3); // Dibuja la tabla cantidad con letra $pdf->ezSetDy(0); $pdf->ezTable($tableData, "", "", $options); ////////// i. Totales $f_importe = "\$" . number_format($comprobanteNode['subTotal'], 2); //$f_iva_T=$conceptoNode['totalImpuestosTrasladados']; $f_total = "\$" . number_format($comprobanteNode['total'], 2); $tableData = array(); $rowData = array("leyenda" => "", "cantidad" => ""); $subtotal = array("dato" => "Subtotal", "valor" => $f_importe); array_push($tableData, $subtotal); foreach ($traslados as $key => $trasladoNode) { if ($key === $trasladoTag . $attr) { $tasaImpuesto = array(); $tasaImpuesto_t = number_format($trasladoNode['tasa'], 0); $tasaImpuesto["dato"] = $trasladoNode['impuesto'] . " " . $tasaImpuesto_t . "%"; $tasaImpuesto["valor"] = "\$" . number_format($trasladoNode['importe'], 2); //array_push($tableData,$tasaImpuesto); } } if (!empty($retenciones)) { foreach ($retenciones as $key => $retencionNode) { if ($key === $retencionTag . $attr) { $tasaImpuesto = array(); $tasaImpuesto_t = number_format($retencionNode['tasa'], 2); $tasaImpuesto["dato"] = "Ret. " . $retencionNode['impuesto']; $tasaImpuesto["valor"] = "\$" . number_format($retencionNode['importe'], 2); //array_push($tableData,$tasaImpuesto); } } } //fin if empty $iva = array("dato" => "<b>IVA</b>", "valor" => "<b>\$ " . number_format($info_xtra->TotalImpuestosTrasladados, 2) . "</b>"); array_push($tableData, $iva); $total = array("dato" => "<b>Total</b>", "valor" => "<b>" . $f_total . "</b>"); array_push($tableData, $total); $colNames = array("dato" => "<b>Cant</b>", "valor" => "Importe"); $colOptions = array("dato" => array('justification' => 'right', 'width' => 55), "valor" => array('justification' => 'right', 'width' => 95)); $options = array('showLines' => 1, 'showHeadings' => 0, 'shaded' => 2, 'shadeCol' => array(1, 1, 1), 'shadeCol2' => array(91, 21, 0), 'fontSize' => 7, 'textCol' => array(0, 0, 0), 'rowGap' => 3, 'colGap' => 5, 'xPos' => 425, 'xOrientation' => 'right', 'width' => 120, 'cols' => $colOptions, 'innerLineThickness' => 0.3, 'outerLineThickness' => 0.3); // Dibuja la tabla totales $pdf->ezSetDy(42.5); $pdf->ezTable($tableData, $colNames, "", $options); $rfce = $row_empresa['rfc']; $rfcr = $receptorNode['rfc']; $total = $comprobanteNode['total']; $uuidsat = $row_factura['uuid']; $cadenaQRCode = sprintf("?re=%s&rr=%s&tt=%s&id=%s", $rfce, $rfcr, $total, $uuidsat); /*QR Code: Para usar qr_imgV2(): qr_imgV2(d,e,s,v,t); d= datos Cadena o datos a ser codificados. e= ECC level Puede ser L,M,Q,H (default M) s= module size Para imagen JPEG:8; para PNG:4 v= version 1-40 8 recomendado. t= image type "J":imagen jpeg, "P" o culaquier otra cosa: imagen PNG */ $img_filename = qr_imgV2($cadenaQRCode, "M", 8, 8, "J", $PATHQR); //v:7-13 8 parece adecuado. //$pdf->addJpegFromFile($img_filename,495,$pdf->y,90); //100 //$pdf->addJpegFromFile($img_filename,32,170,130); //100 $pdf->addJpegFromFile($img_filename, 32, $pdf->y - 140, 130); //100 unlink($img_filename); ////////// i. Sello if ($version === "3.2") { $tableData = array(array("dato" => "<b>Sello Digital del Emisor</b>\n" . $row_factura['sello']), array("dato" => "<b>Sello Digital del SAT</b>\n" . $row_factura['selloSAT'])); } else { $tableData = array(array("dato" => "<b>Sello Digital</b>\n" . $row_factura['sello'])); } $colNames = array("dato" => "<b>Cant</b>"); $colOptions = array("dato" => array('justification' => 'left', 'width' => 400)); $options = array('showLines' => 1, 'showHeadings' => 0, 'shaded' => 0, 'shadeCol' => array(0.8, 0.8, 0.8), 'fontSize' => 7, 'textCol' => array(0, 0, 0), 'rowGap' => 5, 'colGap' => 5, 'xPos' => 175, 'xOrientation' => 'right', 'width' => 120, 'cols' => $colOptions, 'innerLineThickness' => 0.3, 'outerLineThickness' => 0.3); // Dibuja la tabla sello $pdf->ezSetDy(-10); $pdf->ezTable($tableData, $colNames, "", $options); /*$pdf->setColor(91,21,0); $pdf->filledRectangle(30,167,134,151); $pdf->setColor(1,1,1); $pdf->filledRectangle(31,167.5,132.3,149.5);*/ ////////// i. Cadena original $columnaCadena = ""; if ($version === "3.2") { $columnaCadena = sprintf("||1.0|%s|%s|%s|%s||", $row_factura['uuid'], $row_factura['FechaTimbrado'], $row_factura['selloCFD'], $row_factura['noCertificadoSAT']); } else { $columnaCadena = sprintf("%s", $row_factura['cadena']); } $tableData = array(array("dato" => "<b>Cadena original del complemento de certificacion digital del SAT</b>\n" . $columnaCadena), array("dato" => "<b>Folio Fiscal</b>\n" . $row_factura['uuid'])); $colNames = array("dato" => "<b>Cant</b>"); $colOptions = array("dato" => array('justification' => 'left', 'width' => 400)); $options = array('showLines' => 1, 'showHeadings' => 0, 'shaded' => 0, 'shadeCol' => array(0.8, 0.8, 0.8), 'fontSize' => 7, 'textCol' => array(0, 0, 0), 'rowGap' => 5, 'colGap' => 5, 'xPos' => 175, 'xOrientation' => 'right', 'width' => 120, 'cols' => $colOptions, 'innerLineThickness' => 0.3, 'outerLineThickness' => 0.3); // Dibuja la tabla cadena original $pdf->ezSetDy(-5); $pdf->ezTable($tableData, $colNames, "", $options); // Leyendas $pdf->ezSetDy(-12); $leyendas = "ESTE DOCUMENTO ES UNA REPRESENTACION IMPRESA DE UN CFDI.\n"; $pdf->setColor(0.5, 0.5, 0.5); $pdf->ezText($leyendas, 5, array('left' => 50, 'justification' => 'center')); $pdf->setColor(0, 0, 0); $pdf->ezStream(array("filename" => $row_factura['folio'] . "_" . str_replace(" ", "-", $receptorNode['nombre']))); //Necesario para que funcione ezStartPageNumbers //REGRESA PARA PONER ENCABEZADO EN PAGINAS 2 -> if ($contadorPagina != $contadorTotalPaginas) { $pdf->ezNewPage(); $pdf->ezSetDy(-12); } $contadorPagina++; } //fin del foreach para la creacion del objeto pdf //ESCRIBE REPORTE AL ARCHIVO. //================================================================================ $pdfcode = $pdf->output(); error_log($tmpName); if ($tmpName === 2 || !$tmpName) { $tmpName = !$tmpName ? $tmpName : true; } else { exit($pdfcode); } //save the file if ($tmpName) { $nombrePDF = tempnam($tmp . "tmp/", 'face5') . ".pdf"; $nombreToks = explode("/", $nombrePDF); if (count($nombreToks) < 2) { $nombreToks = explode("\\", $nombrePDF); } $lastTok = count($nombreToks) - 1; $nombrePDF = $nombreToks[$lastTok]; $archivoPDF = $tmp . "tmp/" . $nombrePDF; $archivos = array($nombrePDF, $archivoPDF); error_log(print_R($archivos, true)); } else { $nombrePDF = $tipoDocto . "_" . $row_factura['serie'] . $row_factura['folio'] . ".pdf"; //$archivoPDF ="tmp/".$nombrePDF;//chs 20130705 $archivoPDF = $tmp . "tmp/" . $nombrePDF; $archivos = array($nombrePDF, $archivoPDF); error_log(2); ob_flush(); ob_clean(); } global $SITE_ROOT; error_log($archivoPDF); @file_put_contents($SITE_ROOT . "gui/" . $archivoPDF, $pdfcode); /*$fp = fopen($archivoPDF,'w+'); fwrite($fp,$pdfcode); fclose($fp);*/ return $archivos; }
function ezNewPage($insert = 0, $id = 0, $pos = 'after') { parent::ezNewPage($insert, $id, $pos); switch ($this->bg_type) { case 'colour': $this->saveState(); $this->setColor($this->bg_color['r'], $this->bg_color['g'], $this->bg_color['b'], 1); $this->filledRectangle(0, 0, $this->ez['pageWidth'], $this->ez['pageHeight']); $this->restoreState(); break; case 'image': switch ($this->bg_img_type) { case 'jpg': $this->addJpegFromFile($this->bg_img, $this->bg_img_xpos, $this->bg_img_ypos, $this->bg_img_width, $this->bg_img_height); break; case 'png': $this->addPngFromFile($this->bg_img, $this->bg_img_xpos, $this->bg_img_ypos, $this->bg_img_width, $this->bg_img_height); break; } break; case 'none': default: break; } }
function addTable(Cezpdf &$pdf, &$data, $cols = '', $title = '', $options = '') { $pdf->transaction('start'); $pageNumber = $pdf->ezGetCurrentPageNumber(); $pdf->ezTable($data, $cols, $title, $options); if ($pageNumber < $pdf->ezGetCurrentPageNumber()) { $pdf->transaction('rewind'); } else { $pdf->transaction('commit'); return; } $pdf->ezNewPage(); $pageNumber = $pdf->ezGetCurrentPageNumber(); $pdf->ezTable($data, $cols, $title, $options); if ($pageNumber < $pdf->ezGetCurrentPageNumber()) { $pdf->transaction('rewind'); $pdf->ezTable($data, $cols, $title, $options); } $pdf->transaction('commit'); }
function salto_pagina() { $this->pdf->ezNewPage(); }
$li_numrows = $io_sql->num_rows($rs_data); if ($li_numrows>0) { error_reporting(E_ALL); set_time_limit(1800); $io_pdf = new Cezpdf('LETTER','portrait'); // Instancia de la clase PDF $io_pdf->selectFont('../../shared/ezpdf/fonts/Helvetica.afm'); // Seleccionamos el tipo de letra $io_pdf->ezSetCmMargins(5,3,3,3); // Configuración de los margenes en centímetros $io_pdf->ezStartPageNumbers(550,30,10,'','',1); // Insertar el número de página $li_count = 0; while (($row=$io_sql->fetch_row($rs_data)) && $lb_valido) { $li_count++; if ($li_count>1) { $io_pdf->ezNewPage(); } $ls_codpro = $row["cod_pro"]; $ls_nompro = $row["nompro"]; $ls_dirpro = $row["dirpro"]; $ls_telpro = $row["telpro"]; $ls_obssolcot = $row["obssol"]; $ls_fecsolcot = $row["fecsol"]; $ls_mailpro = $row["email"]; $ls_rifpro = $row["rifpro"]; $ls_fecsolcot = $io_funciones->uf_convertirfecmostrar($ls_fecsolcot); $rs_datos = $io_report->uf_load_dt_solicitud_cotizacion($ls_numsolcot,$ls_codpro,$ls_tabla,$ls_table,$ls_campo,&$lb_valido); if ($lb_valido) { $li_totrows = $io_sql->num_rows($rs_datos); if ($li_totrows>0)
function buildpdf() { @mkdir("/usr/share/artica-postfix/PDFs", 666, true); if ($GLOBALS["RCPT_TO"] == null) { echo "No recipient set...\n"; return; } if ($GLOBALS["OU"] == null) { echo "No organization set...\n"; return; } getSommaire(); sql_domain(); $date = date("Y-m-d"); $pdf = new Cezpdf('a4', 'portrait'); echo __FUNCTION__ . " Creating instance done...\n"; $pdf->ezSetMargins(50, 70, 50, 50); $all = $pdf->openObject(); $pdf->saveState(); //$pdf->setStrokeColor(0,0,0,1); $pdf->line(20, 40, 578, 40); $pdf->line(20, 822, 578, 822); $pdf->addText(50, 34, 6, $date); $pdf->restoreState(); $pdf->closeObject(); $pdf->addObject($all, 'all'); $mainFont = dirname(__FILE__) . "/ressources/fonts/Helvetica.afm"; $codeFont = dirname(__FILE__) . "/ressources/fonts/Courier.afm"; $pdf->selectFont($mainFont); $pdf->ezText("{$GLOBALS["OU"]}\n", 30, array('justification' => 'centre')); $pdf->ezText("Messaging report\n", 20, array('justification' => 'centre')); $pdf->ezText("{$date}", 18, array('justification' => 'centre')); $pdf->ezText(count($GLOBALS["OU-USERS"]) . " users", 18, array('justification' => 'centre')); $pdf->ezStartPageNumbers(100, 30, 12, "left", "Page {PAGENUM}/{TOTALPAGENUM}"); $pdf->ezNewPage(); $pdf->ezText("The report:", 28, array('justification' => 'left')); $pdf->ezText(""); $pdf->ezText("The current report is based on " . count($GLOBALS["mydomains"]) . " domains", 12, array('justification' => 'left')); $pdf->ezText("Including " . @implode(", ", $GLOBALS["mydomains"]) . " for the last {$GLOBALS["LAST_DAYS"]} days", 12, array('justification' => 'left')); $sql = "SELECT COUNT(bounce_error) as tcount,bounce_error FROM smtp_logs WHERE {$GLOBALS["SQL_DOMAINS"]} AND time_stamp>DATE_ADD(NOW(), INTERVAL -{$GLOBALS["LAST_DAYS"]} DAY) GROUP BY bounce_error"; $q = new mysql(); $results = $q->QUERY_SQL($sql, "artica_events"); while ($ligne = @mysql_fetch_array($results, MYSQL_ASSOC)) { $data[] = array($ligne["tcount"], $ligne["bounce_error"]); } $pdf->ezText(""); $title = "Global email status during the period"; // 005447 = 0,0.32,0.278 // CCCCCC = 0.8,0.8,0.8 $options = array('showLines' => 2, 'showHeadings' => 0, 'shaded' => 2, 'shadeCol' => array(1, 1, 1), 'shadeCol2' => array(0.8, 0.8, 0.8), 'fontSize' => 11, 'textCol' => array(0, 0, 0), 'textCol2' => array(1, 1, 1), 'titleFontSize' => 16, 'titleGap' => 8, 'rowGap' => 5, 'colGap' => 10, 'lineCol' => array(1, 1, 1), 'xPos' => 'left', 'xOrientation' => 'right', 'width' => 500, 'maxWidth' => 500); $pdf->ezTable($data, $cols, $title, $options); $file = FlowMessages(); $pdf->ezNewPage(); echo __FUNCTION__ . " image {$file}\n"; $pdf->ezImage("/usr/share/artica-postfix/PDFs/graph1.png", 5, 500, "none", 'left', 1); $pdf->ezText(""); $pdf->ezImage("/usr/share/artica-postfix/PDFs/graph2.png", 5, 500, "none", 'left', 1); $pdf->ezNewPage(); //---------------------------------------------------------------------------------------------------------- $sql = "SELECT COUNT( ID ) AS tcount,delivery_user\nFROM smtp_logs\nWHERE {$GLOBALS["SQL_DOMAINS"]}\nAND time_stamp > DATE_ADD( NOW( ) , INTERVAL -{$GLOBALS["LAST_DAYS"]}\nDAY )\nGROUP BY delivery_user ORDER BY tcount DESC LIMIT 0,10 "; $q = new mysql(); $results = $q->QUERY_SQL($sql, "artica_events"); echo $sql; unset($data); $data[] = array("nb", "recipients"); while ($ligne = @mysql_fetch_array($results, MYSQL_ASSOC)) { if ($ligne["delivery_user"] == null) { continue; } $data[] = array($ligne["tcount"], $ligne["delivery_user"]); } $title = "Most active users (recipients) during the period"; $options = array('showLines' => 2, 'showHeadings' => 0, 'shaded' => 2, 'shadeCol' => array(1, 1, 1), 'shadeCol2' => array(0.8, 0.8, 0.8), 'fontSize' => 11, 'textCol' => array(0, 0, 0), 'textCol2' => array(1, 1, 1), 'titleFontSize' => 16, 'titleGap' => 8, 'rowGap' => 5, 'colGap' => 10, 'lineCol' => array(1, 1, 1), 'xPos' => 'left', 'xOrientation' => 'right', 'width' => 500, 'maxWidth' => 500); $pdf->ezTable($data, $cols, $title, $options); //---------------------------------------------------------------------------------------------------------- $pdf->ezText("\n"); //---------------------------------------------------------------------------------------------------------- $sql = "SELECT COUNT( ID ) AS tcount,sender_user\nFROM smtp_logs\nWHERE {$GLOBALS["SQL_OUT_DOMAINS"]}\nAND time_stamp > DATE_ADD( NOW( ) , INTERVAL -{$GLOBALS["LAST_DAYS"]}\nDAY )\nGROUP BY sender_user ORDER BY tcount DESC LIMIT 0,10 "; $q = new mysql(); $results = $q->QUERY_SQL($sql, "artica_events"); echo $sql; unset($data); $data[] = array("nb", "senders"); while ($ligne = @mysql_fetch_array($results, MYSQL_ASSOC)) { if ($ligne["sender_user"] == null) { continue; } $data[] = array($ligne["tcount"], $ligne["sender_user"]); } $title = "Most active users (senders) during the period"; $options = array('showLines' => 2, 'showHeadings' => 0, 'shaded' => 2, 'shadeCol' => array(1, 1, 1), 'shadeCol2' => array(0.8, 0.8, 0.8), 'fontSize' => 11, 'textCol' => array(0, 0, 0), 'textCol2' => array(1, 1, 1), 'titleFontSize' => 16, 'titleGap' => 8, 'rowGap' => 5, 'colGap' => 10, 'lineCol' => array(1, 1, 1), 'xPos' => 'left', 'xOrientation' => 'right', 'width' => 500, 'maxWidth' => 500); $pdf->ezTable($data, $cols, $title, $options); //---------------------------------------------------------------------------------------------------------- $pdf->ezNewPage(); //---------------------------------------------------------------------------------------------------------- $sql = "SELECT COUNT( ID ) AS tcount,sender_user\nFROM smtp_logs\nWHERE {$GLOBALS["SQL_DOMAINS"]}\nAND time_stamp > DATE_ADD( NOW( ) , INTERVAL -{$GLOBALS["LAST_DAYS"]}\nDAY )\nGROUP BY sender_user ORDER BY tcount DESC LIMIT 0,32 "; $q = new mysql(); $results = $q->QUERY_SQL($sql, "artica_events"); echo $sql; unset($data); $data[] = array("nb", "Internet senders"); while ($ligne = @mysql_fetch_array($results, MYSQL_ASSOC)) { if ($ligne["sender_user"] == null) { continue; } $data[] = array($ligne["tcount"], $ligne["sender_user"]); } $title = "Most active sender internet users during the period"; $options = array('showLines' => 2, 'showHeadings' => 0, 'shaded' => 2, 'shadeCol' => array(1, 1, 1), 'shadeCol2' => array(0.8, 0.8, 0.8), 'fontSize' => 10, 'textCol' => array(0, 0, 0), 'textCol2' => array(1, 1, 1), 'titleFontSize' => 16, 'titleGap' => 8, 'rowGap' => 5, 'colGap' => 10, 'lineCol' => array(1, 1, 1), 'xPos' => 'left', 'xOrientation' => 'right', 'width' => 500, 'maxWidth' => 500); $pdf->ezTable($data, $cols, $title, $options); //---------------------------------------------------------------------------------------------------------- $pdf->ezNewPage(); //---------------------------------------------------------------------------------------------------------- $sql = "SELECT COUNT( ID ) AS tcount,delivery_user\nFROM smtp_logs\nWHERE {$GLOBALS["SQL_OUT_DOMAINS"]}\nAND time_stamp > DATE_ADD( NOW( ) , INTERVAL -{$GLOBALS["LAST_DAYS"]}\nDAY )\nGROUP BY delivery_user ORDER BY tcount DESC LIMIT 0,32 "; $q = new mysql(); $results = $q->QUERY_SQL($sql, "artica_events"); echo $sql; unset($data); $data[] = array("nb", "Internet recipients"); while ($ligne = @mysql_fetch_array($results, MYSQL_ASSOC)) { if ($ligne["delivery_user"] == null) { continue; } $data[] = array($ligne["tcount"], $ligne["delivery_user"]); } $title = "Most active internet recipients during the period"; $options = array('showLines' => 2, 'showHeadings' => 0, 'shaded' => 2, 'shadeCol' => array(1, 1, 1), 'shadeCol2' => array(0.8, 0.8, 0.8), 'fontSize' => 10, 'textCol' => array(0, 0, 0), 'textCol2' => array(1, 1, 1), 'titleFontSize' => 16, 'titleGap' => 8, 'rowGap' => 5, 'colGap' => 10, 'lineCol' => array(1, 1, 1), 'xPos' => 'left', 'xOrientation' => 'right', 'width' => 500, 'maxWidth' => 500); $pdf->ezTable($data, $cols, $title, $options); //---------------------------------------------------------------------------------------------------------- $pdf->ezNewPage(); //----------------------------------------------------------------------------------------------------------; $pdf->ezText("Per users report", 28, array('justification' => 'center')); $pdf->ezText(""); $pdf->ezText(count($GLOBALS["OU-USERS"]) . " users detailed report", 18, array('justification' => 'center')); //---------------------------------------------------------------------------------------------------------- $pdf->ezNewPage(); //----------------------------------------------------------------------------------------------------------; while (list($uid) = each($GLOBALS["OU-USERS"])) { $u = new user($uid); $displayname = $u->DisplayName; echo "Generate report for {$u->uid}\n"; $pdf->ezText("{$displayname}", 22, array('justification' => 'left')); $pdf->ezText(""); $pdf->ezText("The current report is based on " . count($u->HASH_ALL_MAILS) . " email addresses", 10, array('justification' => 'left')); $pdf->ezText("Including " . @implode(", ", $u->HASH_ALL_MAILS) . " mails", 10, array('justification' => 'left')); $pdf->ezText("\n"); FlowMessages_users($uid, $u->HASH_ALL_MAILS); if (is_file("/usr/share/artica-postfix/PDFs/{$uid}-inbound.png")) { $pdf->ezImage("/usr/share/artica-postfix/PDFs/{$uid}-inbound.png", 5, 500, "none", 'left', 1); $pdf->ezText(""); } if (is_file("/usr/share/artica-postfix/PDFs/{$uid}-outbound.png")) { $pdf->ezImage("/usr/share/artica-postfix/PDFs/{$uid}-outbound.png", 5, 500, "none", 'left', 1); $pdf->ezText(""); } if (is_array($GLOBALS[$uid]["RECEIVE"])) { $title = "Most Internet senders for {$displayname} during the period"; $options = array('showLines' => 2, 'showHeadings' => 0, 'shaded' => 2, 'shadeCol' => array(1, 1, 1), 'shadeCol2' => array(0.8, 0.8, 0.8), 'fontSize' => 11, 'textCol' => array(0, 0, 0), 'textCol2' => array(1, 1, 1), 'titleFontSize' => 16, 'titleGap' => 8, 'rowGap' => 5, 'colGap' => 10, 'lineCol' => array(1, 1, 1), 'xPos' => 'left', 'xOrientation' => 'right', 'width' => 500, 'maxWidth' => 500); $pdf->ezTable($GLOBALS[$uid]["RECEIVE"], $cols, $title, $options); } if (is_array($GLOBALS[$uid]["SENT"])) { $title = "Most Internet recipients for {$displayname} during the period"; $options = array('showLines' => 2, 'showHeadings' => 0, 'shaded' => 2, 'shadeCol' => array(1, 1, 1), 'shadeCol2' => array(0.8, 0.8, 0.8), 'fontSize' => 11, 'textCol' => array(0, 0, 0), 'textCol2' => array(1, 1, 1), 'titleFontSize' => 16, 'titleGap' => 8, 'rowGap' => 5, 'colGap' => 10, 'lineCol' => array(1, 1, 1), 'xPos' => 'left', 'xOrientation' => 'right', 'width' => 500, 'maxWidth' => 500); $pdf->ezTable($GLOBALS[$uid]["SENT"], $cols, $title, $options); } $pdf->ezNewPage(); } $pdfcode = $pdf->output(); $fname = "/usr/share/artica-postfix/PDFs/report-director-{$GLOBALS["OU"]}.pdf"; if ($GLOBALS["VERBOSE"]) { echo "{$pdf->messages}\nbuilding {$fname}\n"; } @unlink($fname); if ($GLOBALS["VERBOSE"]) { echo "Building {$fname}\n"; } $fp = fopen($fname, 'w'); fwrite($fp, $pdfcode); fclose($fp); $users = new usersMenus(); send_email_events("[ARTICA]: ({$users->hostname}) {$GLOBALS["OU"]}:: weekly report sended to {$GLOBALS["RCPT_TO"]}", "", "mailbox", date('Y-m-d H:i:s'), array($fname), $GLOBALS["RCPT_TO"]); if ($GLOBALS["VERBOSE"]) { echo "Sending mail\n"; } SendMailNotif("you will find in attached file the weekly report of your {$users->hostname} mail server", "[ARTICA]: ({$users->hostname}) {$GLOBALS["OU"]}:: weekly messaging report", null, $GLOBALS["RCPT_TO"], $GLOBALS["VERBOSE"], array($fname)); }
function ezNewPage($debug = false) { parent::ezNewPage(); if (!$this->set_pageNumbering) { $template = $this->converter->newSmarty(); $parser = new PDFParser(); $parser->parse($template->fetch('pagenumbering.tpl'), $this->font_dir, $this); } $this->set_pageNumbering = true; }
} $pos -= PRODUCT_TABLE_BOTTOM_MARGIN; if ($wrapped_str) { change_color(PRODUCT_LISTING_BKGD_COLOR); $pdf->filledRectangle(LEFT_MARGIN, $pos - PRODUCT_TABLE_ROW_HEIGHT, PRODUCT_TABLE_HEADER_WIDTH, PRODUCT_TABLE_ROW_HEIGHT); $pos = $pos - PRODUCT_TABLE_ROW_HEIGHT + PRODUCT_TABLE_BOTTOM_MARGIN; change_color(GENERAL_FONT_COLOR); $pdf->addText($reset_x, $pos, PRODUCT_ATTRIBUTES_FONT_SIZE, $wrapped_str); $pos -= PRODUCT_TABLE_BOTTOM_MARGIN; } } } // order runs over one page! if ($pos <= 260) { //Now add a new page $pdf->ezNewPage(); //Add footer text $pdf->ezSetY(45); $pdf->ezText(FOOTER_TEXT, 9, array('justification' => 'center')); //Add some lines to make things look a bit neater! //Add Footer Line $pdf->setStrokeColor(0, 0, 0); $pdf->setLineStyle(0.5); $pdf->line(30, 50, 565, 50); //Add line to split for totals $pdf->setStrokeColor(0, 0, 0); $pdf->setLineStyle(0.5); $pdf->line(30, 240, 565, 240); //Add line to top of products table $pdf->setStrokeColor(0, 0, 0); $pdf->setLineStyle(0.5);
public function pdfObservations($result) { global $loggedUser, $dateformat, $instDir, $objObservation, $objObserver, $objInstrument, $objLocation, $objPresentations, $objObject, $objFilter, $objEyepiece, $objLens; $result = $this->sortResult($result); $pdf = new Cezpdf('a4', 'portrait'); $pdf->ezStartPageNumbers(300, 30, 10); $pdf->selectFont($instDir . 'lib/fonts/Helvetica.afm'); $pdf->ezText(utf8_decode(html_entity_decode($_GET['pdfTitle'])) . "\n"); $i = 0; while (list($key, $value) = each($result)) { if ($i++ > 0) { $pdf->ezNewPage(); } $obs = $objObservation->getAllInfoDsObservation($value['observationid']); $object = $objObject->getAllInfoDsObject($obs['objectname']); if ($loggedUser && $objObserver->getObserverProperty($loggedUser, 'UT')) { $date = sscanf($obs["date"], "%4d%2d%2d"); } else { $date = sscanf($obs["localdate"], "%4d%2d%2d"); } if ($obs['seeing'] > -1) { $seeing = true; } else { $seeing = false; } $formattedDate = date($dateformat, mktime(0, 0, 0, $date[1], $date[2], $date[0])); $temp = array("Name" => html_entity_decode(LangPDFMessage1) . " : " . $obs['objectname'], "altname" => html_entity_decode(LangPDFMessage2) . " : " . $object["altname"], "type" => $GLOBALS[$object['type']] . html_entity_decode(LangPDFMessage12) . $GLOBALS[$object['con']], "visibility" => $obs['visibility'] ? html_entity_decode(LangViewObservationField22) . " : " . $GLOBALS['Visibility' . $obs['visibility']] : '', "seeing" => $seeing ? LangViewObservationField6 . " : " . $GLOBALS['Seeing' . $obs['seeing']] : '', "limmag" => $obs['limmag'] ? LangViewObservationField7 . " : " . $obs['limmag'] : '', "filter" => $obs['filterid'] ? LangViewObservationField31 . " : " . $objFilter->getFilterPropertyFromId($obs['filterid'], 'name') : '', "eyepiece" => $obs['eyepieceid'] ? LangViewObservationField30 . " : " . $objEyepiece->getEyepiecePropertyFromId($obs['eyepieceid'], 'name') : '', "lens" => $obs['lensid'] ? LangViewObservationField32 . " : " . $objLens->getLensPropertyFromId($obs['lensid'], 'name') : '', "observer" => html_entity_decode(LangPDFMessage13) . $objObserver->getObserverProperty($obs['observerid'], 'firstname') . " " . $objObserver->getObserverProperty($obs['observerid'], 'name') . html_entity_decode(LangPDFMessage14) . $formattedDate, "instrument" => html_entity_decode(LangPDFMessage11) . " : " . $objInstrument->getInstrumentPropertyFromId($obs['instrumentid'], 'name'), "location" => html_entity_decode(LangPDFMessage10) . " : " . $objLocation->getLocationPropertyFromId($obs['locationid'], 'name'), "description" => $objPresentations->br2nl(html_entity_decode($obs['description'])), "desc" => html_entity_decode(LangPDFMessage15)); $obs1[] = $temp; $nm = $obs['objectname']; if ($object["altname"]) { $nm = $nm . " (" . $object["altname"] . ")"; } $pdf->ezText($nm, "14"); $tmp = array(array("type" => $temp["type"])); $pdf->ezTable($tmp, array("type" => utf8_decode(html_entity_decode(LangPDFMessage5))), "", array("width" => "500", "showHeadings" => "0", "showLines" => "0", "shaded" => "0")); $tmp = array(array("location" => $temp["location"], "instrument" => $temp["instrument"])); $pdf->ezTable($tmp, array("location" => utf8_decode(html_entity_decode(LangPDFMessage1)), "instrument" => utf8_decode(html_entity_decode(LangPDFMessage2))), "", array("width" => "500", "showHeadings" => "0", "showLines" => "0", "shaded" => "0")); $tmp = array(array("eyepiece" => $temp["eyepiece"])); if ($obs['eyepieceid']) { $pdf->ezTable($tmp, array("eyepiece" => "test"), "", array("width" => "500", "showHeadings" => "0", "showLines" => "0", "shaded" => "0")); } $tmp = array(array("filter" => $temp["filter"])); if ($obs['filterid']) { $pdf->ezTable($tmp, array("filter" => "test"), "", array("width" => "500", "showHeadings" => "0", "showLines" => "0", "shaded" => "0")); } $tmp = array(array("lens" => $temp["lens"])); if ($obs['lensid']) { $pdf->ezTable($tmp, array("lens" => "test"), "", array("width" => "500", "showHeadings" => "0", "showLines" => "0", "shaded" => "0")); } $tmp = array(array("seeing" => $temp["seeing"])); if ($seeing) { $pdf->ezTable($tmp, array("seeing" => "test"), "", array("width" => "500", "showHeadings" => "0", "showLines" => "0", "shaded" => "0")); } $tmp = array(array("limmag" => $temp["limmag"])); if ($obs['limmag']) { $pdf->ezTable($tmp, array("limmag" => "test"), "", array("width" => "500", "showHeadings" => "0", "showLines" => "0", "shaded" => "0")); } $tmp = array(array("visibility" => $temp["visibility"])); if ($obs['visibility']) { $pdf->ezTable($tmp, array("visibility" => "test"), "", array("width" => "500", "showHeadings" => "0", "showLines" => "0", "shaded" => "0")); } $tmp = array(array("observer" => $temp["observer"])); $pdf->ezTable($tmp, array("observer" => utf8_decode(html_entity_decode(LangPDFMessage1))), "", array("width" => "500", "showHeadings" => "0", "showLines" => "0", "shaded" => "0")); $pdf->ezText(utf8_decode(LangPDFMessage15), "12"); $pdf->ezText(""); $tmp = array(array("description" => $temp["description"])); $pdf->ezTable($tmp, array("description" => utf8_decode(html_entity_decode(LangPDFMessage1))), "", array("width" => "500", "showHeadings" => "0", "showLines" => "0", "shaded" => "0")); if ($objObservation->getDsObservationProperty($value['observationid'], 'hasDrawing')) { $pdf->ezText(""); $pdf->ezImage($instDir . "deepsky/drawings/" . $value['observationid'] . ".jpg", 0, 500, "none", "left"); } $pdf->ezText(""); } $pdf->ezStream(); }
function saldenliste_mv_pdf($monat, $jahr) { ob_clean(); // ausgabepuffer leeren /* PDF AUSGABE */ //include_once ('pdfclass/class.ezpdf.php'); $pdf = new Cezpdf('a4', 'portrait'); $pdf->selectFont('Helvetica.afm'); $pdf->ezSetCmMargins(4.5, 0, 0, 0); /* Kopfzeile */ $pdf->addJpegFromFile('includes/logos/logo_hv_sw.jpg', 220, 750, 175, 100); $pdf->setLineStyle(0.5); $pdf->addText(86, 743, 6, "BERLUS HAUSVERWALTUNG * Fontanestr. 1 * 14193 Berlin * Inhaber Wolfgang Wehrheim * Telefon: 89784477 * Fax: 89784479 * Email: info@berlus.de"); $pdf->line(42, 750, 550, 750); /* Footer */ $pdf->line(42, 50, 550, 50); $pdf->addText(170, 42, 6, "BERLUS HAUSVERWALTUNG * Fontanestr. 1 * 14193 Berlin * Inhaber Wolfgang Wehrheim"); $pdf->addText(150, 35, 6, "Bankverbindung: Dresdner Bank Berlin * BLZ: 100 800 00 * Konto-Nr.: 05 804 000 00 * Steuernummer: 24/582/61188"); $pdf->addInfo('Title', "Saldenliste {$objekt_name} {$monatname} {$jahr}"); $pdf->addInfo('Author', $_SESSION[username]); $pdf->ezStartPageNumbers(550, 755, 7, '', "Seite {PAGENUM} von {TOTALPAGENUM}"); // echo "Monatsbericht Mieter - Monatsbericht Kostenkonten<br>"; // echo "<h3>Aktuelle Mieterstatistik mit ausgezogene Mieter<br></h3>"; $s = new statistik(); $jahr = $_REQUEST[jahr]; if (empty($jahr)) { $jahr = date("Y"); } else { if (strlen($jahr) < 4) { $jahr = date("Y"); } } // $jahr_monat = date("Y-m"); // $jahr = date("Y"); $monat = $_REQUEST[monat]; if (empty($monat)) { $monat = date("m"); } else { if (strlen($monat) < 2) { $monat = '0' . $monat; } } // $monat = '04'; $jahr_monat = $jahr . '-' . $monat; // $jahr_vormonat = mktime(0, 0, 0, date("m")-1, date("d"), date("Y")); // $jahr_vormonat = date("Y-m",$jahr_vormonat); $bg = new berlussimo_global(); $link = "?daten=mietvertrag_raus&mietvertrag_raus=saldenliste"; $bg->objekt_auswahl_liste($link); $bg->monate_jahres_links($jahr, $link); if (isset($_SESSION['objekt_id'])) { $objekt_id = $_SESSION['objekt_id']; $einheit_info = new einheit(); $o = new objekt(); $objekt_name = $o->get_objekt_name($objekt_id); $monatname = monat2name($monat); $pdf->addText(70, 755, 10, "Saldenliste {$objekt_name} {$monatname} {$jahr}"); $pdf->ezSetDy(25); $pdf->ezSetCmMargins(3, 3, 3, 3); $text_options = array(left => 0, justification => 'left'); $pdf->ezText("<b>Einheit</b>", 8, $text_options); $pdf->ezSetDy(9); $text_options = array(left => 100, justification => 'left'); $pdf->ezText("<b>Mieter</b>", 8, $text_options); $pdf->ezSetDy(9); $text_options = array(left => 270, justification => 'left'); $pdf->ezText("<b>Einzug</b>", 8, $text_options); $pdf->ezSetDy(9); $text_options = array(left => 320, justification => 'left'); $pdf->ezText("<b>Auszug</b>", 8, $text_options); $pdf->ezSetDy(9); $text_options = array(right => 0, justification => 'right'); $pdf->ezText("<b>SALDO EUR</b>", 8, $text_options); /* Aktuell bzw. gewünschten Monat berechnen */ $ob = new objekt(); $einheiten_array = $ob->einheiten_objekt_arr($objekt_id); // $einheiten_array = $s->vermietete_monat_jahr($jahr_monat,$objekt_id, ''); /* * echo "<pre>"; * print_r($einheiten_array); * echo "<h1> EINHEITEN: $anzahl_aktuell</h1>"; * $mv_array = $einheit_info->get_mietvertrag_ids('7'); * print_r($mv_array); */ $summe_sv = 0; $summe_mieten = 0; $summe_umlagen = 0; $summe_akt_gsoll = 0; $summe_g_zahlungen = 0; $summe_saldo_neu = 0; $anzahl_aktuell = count($einheiten_array); $miete = new miete(); $zeilen_pro_seite = 60; $aktuelle_zeile = 0; for ($i = 0; $i < $anzahl_aktuell; $i++) { $mv_array = $einheit_info->get_mietvertraege_bis("" . $einheiten_array[$i]['EINHEIT_ID'] . "", $jahr, $monat); $mv_anzahl = count($mv_array); if (is_array($mv_array)) { for ($b = 0; $b < $mv_anzahl; $b++) { $mv_id = $mv_array[$b]['MIETVERTRAG_ID']; $mk = new mietkonto(); $mieter_ids = $mk->get_personen_ids_mietvertrag($mv_id); for ($a = 0; $a < count($mieter_ids); $a++) { $mieter_daten_arr[] = $mk->get_person_infos($mieter_ids[$a][PERSON_MIETVERTRAG_PERSON_ID]); } // $miete->mietkonto_berechnung_monatsgenau($mv_id, $jahr, $monat); $end_saldoo = $miete->saldo_berechnen_monatsgenau($mv_id, $monat, $jahr); $zeile = $zeile + 1; $einheit_kurzname = $einheiten_array[$i]['EINHEIT_KURZNAME']; $vn = RTRIM(LTRIM($mieter_daten_arr['0']['0']['PERSON_VORNAME'])); $nn = RTRIM(LTRIM($mieter_daten_arr['0']['0']['PERSON_NACHNAME'])); $akt_gesamt_soll = $miete->saldo_vormonat_stand + $miete->sollmiete_warm; $this->get_mietvertrag_infos_aktuell($mv_id); $l_tag_akt_monat = letzter_tag_im_monat($monat, $jahr); $l_datum = "{$jahr}-{$monat}-{$l_tag_akt_monat}"; if ($this->mietvertrag_bis == '0000-00-00' or $this->mietvertrag_bis > $l_datum) { $mv_bis = 'aktuell'; } else { $mv_bis = date_mysql2german($this->mietvertrag_bis); } $mv_von = date_mysql2german($this->mietvertrag_von); $end_saldoo = nummer_punkt2komma($end_saldoo); if ($mv_bis == 'aktuell') { // echo "$zeile. $einheit_kurzname $nn $vn SALDO NEU: $end_saldoo <br>"; $pdf->ezSetCmMargins(3, 3, 3, 3); $text_options = array(left => 0, justification => 'left'); $pdf->ezText("{$einheit_kurzname}", 8, $text_options); $pdf->ezSetDy(9); $text_options = array(left => 100, justification => 'left'); $pdf->ezText("{$nn} {$vn}", 8, $text_options); $pdf->ezSetDy(9); $text_options = array(left => 270, justification => 'left'); $pdf->ezText("{$mv_von}", 8, $text_options); $pdf->ezSetDy(9); $text_options = array(left => 320, justification => 'left'); $pdf->ezText("", 8, $text_options); $pdf->ezSetDy(9); $text_options = array(right => 0, justification => 'right'); $pdf->ezText("{$end_saldoo}", 8, $text_options); $aktuelle_zeile++; } else { // echo "<b>$zeile. $einheit_kurzname $nn $vn SALDO NEU: $end_saldoo € BEENDET AM :$mv_bis €</b><br>"; $pdf->ezSetCmMargins(3, 3, 3, 3); $text_options = array(left => 0, justification => 'left'); $pdf->ezText("{$einheit_kurzname}", 8, $text_options); $pdf->ezSetDy(9); $text_options = array(left => 100, justification => 'left'); $pdf->ezText("{$nn} {$vn}", 8, $text_options); $pdf->ezSetDy(9); $text_options = array(left => 270, justification => 'left'); $pdf->ezText("{$mv_von}", 8, $text_options); $pdf->ezSetDy(9); $text_options = array(left => 320, justification => 'left'); $pdf->ezText("{$mv_bis}", 8, $text_options); $pdf->ezSetDy(9); $text_options = array(right => 0, justification => 'right'); $pdf->ezText("{$end_saldoo}", 8, $text_options); $aktuelle_zeile++; } if ($zeilen_pro_seite == $aktuelle_zeile) { $pdf->ezNewPage(); /* Kopfzeile */ $pdf->addJpegFromFile('includes/logos/logo_hv_sw.jpg', 220, 750, 175, 100); $pdf->setLineStyle(0.5); $pdf->addText(86, 743, 6, "BERLUS HAUSVERWALTUNG * Fontanestr. 1 * 14193 Berlin * Inhaber Wolfgang Wehrheim * Telefon: 89784477 * Fax: 89784479 * Email: info@berlus.de"); $pdf->line(42, 750, 550, 750); /* Footer */ $pdf->line(42, 50, 550, 50); $pdf->addText(170, 42, 6, "BERLUS HAUSVERWALTUNG * Fontanestr. 1 * 14193 Berlin * Inhaber Wolfgang Wehrheim"); $pdf->addText(150, 35, 6, "Bankverbindung: Dresdner Bank Berlin * BLZ: 100 800 00 * Konto-Nr.: 05 804 000 00 * Steuernummer: 24/582/61188"); $pdf->addInfo('Title', "Saldenliste {$objekt_name} {$monatname} {$jahr}"); $pdf->addText(70, 755, 10, "Saldenliste {$objekt_name} {$monatname} {$jahr}"); $pdf->ezStartPageNumbers(550, 755, 7, '', "Seite {PAGENUM} von {TOTALPAGENUM}"); /* Überschriftzeile */ $pdf->ezSetDy(-18); $pdf->ezSetCmMargins(3, 3, 3, 3); $text_options = array(left => 0, justification => 'left'); $pdf->ezText("<b>Einheit</b>", 8, $text_options); $pdf->ezSetDy(9); $text_options = array(left => 100, justification => 'left'); $pdf->ezText("<b>Mieter</b>", 8, $text_options); $pdf->ezSetDy(9); $text_options = array(left => 270, justification => 'left'); $pdf->ezText("<b>Einzug</b>", 8, $text_options); $pdf->ezSetDy(9); $text_options = array(left => 320, justification => 'left'); $pdf->ezText("<b>Auszug</b>", 8, $text_options); $pdf->ezSetDy(9); $text_options = array(right => 0, justification => 'right'); $pdf->ezText("<b>SALDO EUR</b>", 8, $text_options); $aktuelle_zeile = 0; } unset($mieter_daten_arr); unset($nn); unset($vn); } // end if is_array mv_ids } } // hinweis_ausgeben("Saldenliste mit Vormieter für $objekt_name wurde erstellt<br>"); ob_clean(); // ausgabepuffer leeren $pdf->ezStopPageNumbers(); $pdf->ezStream(); /* Falls kein Objekt ausgewählt */ } else { echo "Objekt auswählen"; } }
function berechnung_anzeigen($leerstand_arr, $vermietete_arr, $monat, $jahr) { echo '<pre>'; // print_r($vermietete_arr); $anzahl_vermietete = count($vermietete_arr); $mv = new mietvertrag(); $m = new mietkonto(); $haeuser = array(); $gsollmiete_vermietet = 0; for ($a = 0; $a < $anzahl_vermietete; $a++) { $einheit_id = $vermietete_arr[$a]['EINHEIT_ID']; $haus_str = $vermietete_arr[$a]['HAUS_STRASSE']; $haus_nr = $vermietete_arr[$a]['HAUS_NUMMER']; $haus_str_nr = $haus_str . ' ' . $haus_nr; if (!in_array($haus_str_nr, $haeuser)) { $haeuser[] = $haus_str_nr; } $mv->get_mietvertrag_infos_aktuell($einheit_id); $summe_f_monatlich = $m->summe_forderung_monatlich($mv->mietvertrag_id, $monat, $jahr); $gsollmiete_vermietet = $gsollmiete_vermietet + $summe_f_monatlich; } $anzahl_leer = count($leerstand_arr); $gsollmiete_leer = 0; for ($b = 0; $b < $anzahl_leer; $b++) { $einheit_id = $leerstand_arr[$b]['EINHEIT_ID']; $haus_str = $leerstand_arr[$b]['HAUS_STRASSE']; $haus_nr = $leerstand_arr[$b]['HAUS_NUMMER']; $haus_str_nr = $haus_str . ' ' . $haus_nr; if (!in_array($haus_str_nr, $haeuser)) { $haeuser[] = $haus_str_nr; } $sollmiete_leer = $this->get_sollmiete_leerstand($einheit_id); $gsollmiete_leer = $gsollmiete_leer + $sollmiete_leer; } // print_r($haeuser); $g_summe = $gsollmiete_vermietet + $gsollmiete_leer; $g_summe_a = nummer_punkt2komma($g_summe); $gsollmiete_vermietet_a = nummer_punkt2komma($gsollmiete_vermietet); $gsollmiete_leer_a = nummer_punkt2komma($gsollmiete_leer); $v_geb = $g_summe / 100 * 5; $brutto_vgeb = $v_geb * 1.19; $mwst_eur = $v_geb / 100 * 19; $mwst_eur = nummer_punkt2komma($mwst_eur); $brutto_vgeb_a = nummer_punkt2komma($brutto_vgeb); $v_geb_a = nummer_punkt2komma($v_geb); if (!isset($_REQUEST['pdf'])) { echo "{$gsollmiete_vermietet_a} € GESAMT SOLL VERMIETET<br>"; echo "{$gsollmiete_leer_a} € GESAMT SOLL LEER<br>"; echo " {$g_summe_a} € GESAMT SOLL<br>"; echo " {$v_geb_a} € NETTO VERWALTERGEBÜHR 5%<br>"; echo " <b>{$brutto_vgeb_a} € INKL. 19% MWST VERWALTERGEBÜHR 5%</b><hr>"; } else { /* PDF AUSGABE */ ob_clean(); // ausgabepuffer leeren header("Content-type: application/pdf"); // wird von MSIE ignoriert //include_once ('pdfclass/class.ezpdf.php'); $pdf = new Cezpdf('a4', 'portrait'); $pdf->ezSetCmMargins(4.5, 1, 1, 1); $berlus_schrift = 'pdfclass/fonts/Times-Roman.afm'; $text_schrift = 'pdfclass/fonts/Arial.afm'; $pdf->addJpegFromFile('includes/logos/logo_hv_sw.jpg', 220, 750, 175, 100); // $pdf->addJpgFromFile('pdfclass/logo_262_150_sw1.jpg', 300, 500, 250, 150); $pdf->setLineStyle(0.5); $pdf->selectFont($berlus_schrift); $pdf->addText(42, 743, 6, "BERLUS HAUSVERWALTUNG - Fontanestr. 1 - 14193 Berlin"); $pdf->line(42, 750, 550, 750); $monatsname = monat2name($monat); $pdf->addText(42, 720, 12, "Berechnungsbogen für die Verwaltergebühr {$monatsname} {$jahr}"); $pdf->addText(42, 650, 10, "Gesamtsoll aus vermieteten Einheiten"); $pdf->addText(300, 650, 10, "{$gsollmiete_vermietet_a} €"); $pdf->addText(42, 635, 10, "Gesamtsoll aus leerstehenden Einheiten"); $pdf->addText(300, 635, 10, "{$gsollmiete_leer_a} €"); $pdf->setLineStyle(0.5); $pdf->line(42, 630, 350, 630); $pdf->addText(42, 620, 10, "<b>Gesamtsoll"); $pdf->addText(300, 620, 10, "{$g_summe_a} €</b>"); $pdf->addText(42, 595, 10, "5% Verwaltergebühr"); $pdf->addText(300, 595, 10, "{$v_geb_a} €"); $pdf->addText(42, 585, 10, "+ 19% MWSt"); $pdf->addText(300, 585, 10, "{$mwst_eur} €"); $pdf->setLineStyle(0.5); $pdf->line(42, 580, 350, 580); $pdf->addText(42, 570, 10, "<b>Verwaltergebühr brutto"); $pdf->addText(300, 570, 10, "{$brutto_vgeb_a} €</b>"); /* Häuser */ $pdf->addText(42, 480, 10, "In diese Berechnung wurden folgende Häuser einbezogen:"); $text_xpos = 460; for ($c = 0; $c < count($haeuser); $c++) { $haus = $haeuser[$c]; $pdf->addText(42, $text_xpos, 10, "<b>{$haus}</b>"); $text_xpos = $text_xpos - 10; if ($text_xpos == 100) { $pdf->ezNewPage(); $text_xpos = 650; $pdf->ezSetCmMargins(4.5, 1, 1, 1); $berlus_schrift = 'pdfclass/fonts/Times-Roman.afm'; $text_schrift = 'pdfclass/fonts/Arial.afm'; $pdf->addJpegFromFile('includes/logos/logo_hv_sw.jpg', 220, 750, 175, 100); // $pdf->addJpgFromFile('pdfclass/logo_262_150_sw.jpg', 450, 780, 100, 42); $pdf->setLineStyle(0.5); $pdf->selectFont($berlus_schrift); $pdf->addText(42, 743, 6, "BERLUS HAUSVERWALTUNG - Fontanestr. 1 - 14193 Berlin"); $pdf->line(42, 750, 550, 750); $pdf->addText(42, 720, 12, "Berechnungsbogen für die Verwaltergebühr {$monat}/{$jahr}"); } } $pdf->ezStream(); } }