Ejemplo n.º 1
0
$titlet = array('total' => '<b>Total</b>');
$pdf->ezText("\n", 10);
$pdf->ezTable($data, $titlef, '', $options);
$pdf->ezText("\n", 10);
$pdf->ezTable($data, $titles, '', $options);
$pdf->ezText("\n", 10);
$pdf->addText(50, 700, 12, "<b>Atendio: </b>\n");
$pdf->addText(100, 700, 12, $emp);
$pdf->addText(50, 680, 12, "<b>Cliente: </b>\n");
$pdf->addText(100, 680, 12, $datos);
//RECUPERANDO DETALLE DE VENTA
$sql = mysql_query("select dv.cantidad,p.nombre,dv.precio,dv.subtotal \n \t\tfrom detalle_venta dv\n \t\tinner join platillos p on p.id_platillo = dv.clave_producto \n \t\twhere folio = '" . $folio . "' ");
while ($row = mysql_fetch_array($sql)) {
    $dat[] = array_merge($row);
}
$optionsdv = array('shadeHeadingCol' => array(0.6, 0.6, 0.5), 'shadeCol' => array(0.9, 0.9, 0.9), 'xOrientation' => 'center', 'width' => 500, 'fontSize' => 10, 'xPos' => 'center', 'cols' => array('cantidad' => array('justification' => 'center'), 'nombre' => array('justification' => 'center'), 'precio' => array('justification' => 'center'), 'subtotal' => array('justification' => 'center')));
$titledv = array('cantidad' => '<b>Cantidad</b>', 'nombre' => '<b>Descripción</b>', 'precio' => '<b>Precio</b>', 'subtotal' => '<b>SubTotal</b>');
$pdf->ezTable($dat, $titledv, '', $optionsdv);
$pdf->ezText("\n", 10);
$pdf->ezTable($data, $titlet, '', $options);
//cabecera del pdf (objeto para todas las páginas)
$all = $pdf->openObject();
$pdf->saveState();
$pdf->addText(200, 790, 12, "<b>Restaurante Familiar </b>\n");
$pdf->addText(230, 770, 12, "<i>!The Mexican Food is the Better! </i>\n");
$pdf->restoreState();
$pdf->closeObject();
$pdf->addObject($all, 'all');
$pdf->ezSetCmMargins(4, 3, 3, 3);
ob_end_clean();
$pdf->ezStream();
Ejemplo n.º 2
0
    /**
     * 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><?

	}
Ejemplo n.º 3
0
function dofreePDF()
{
    global $mosConfig_live_site, $mosConfig_sitename, $mosConfig_offset;
    global $mainframe, $database, $my;
    $id = intval(mosGetParam($_REQUEST, 'id', 1));
    $gid = $my->gid;
    $now = _CURRENT_SERVER_TIME;
    $nullDate = $database->getNullDate();
    // query to check for state and access levels
    $query = "SELECT a.*, cc.name AS category, s.name AS section, s.published AS sec_pub, cc.published AS cat_pub," . "\n  s.access AS sec_access, cc.access AS cat_access, s.id AS sec_id, cc.id as cat_id" . "\n FROM #__content AS a" . "\n LEFT JOIN #__categories AS cc ON cc.id = a.catid" . "\n LEFT JOIN #__sections AS s ON s.id = cc.section AND s.scope = 'content'" . "\n WHERE a.id = " . (int) $id . "\n AND a.state = 1" . "\n AND a.access <= " . (int) $gid . "\n AND ( a.publish_up = " . $database->Quote($nullDate) . " OR a.publish_up <= " . $database->Quote($now) . " )" . "\n AND ( a.publish_down = " . $database->Quote($nullDate) . " OR a.publish_down >= " . $database->Quote($now) . " )";
    $database->setQuery($query);
    $row = NULL;
    if ($database->loadObject($row)) {
        /*
         * check whether category is published
         */
        if (!$row->cat_pub && $row->catid) {
            mosNotAuth();
            return;
        }
        /*
         * check whether section is published
         */
        if (!$row->sec_pub && $row->sectionid) {
            mosNotAuth();
            return;
        }
        /*
         * check whether category access level allows access
         */
        if ($row->cat_access > $gid && $row->catid) {
            mosNotAuth();
            return;
        }
        /*
         * check whether section access level allows access
         */
        if ($row->sec_access > $gid && $row->sectionid) {
            mosNotAuth();
            return;
        }
        include 'includes/class.ezpdf.php';
        $params = new mosParameters($row->attribs);
        $params->def('author', !$mainframe->getCfg('hideAuthor'));
        $params->def('createdate', !$mainframe->getCfg('hideCreateDate'));
        $params->def('modifydate', !$mainframe->getCfg('hideModifyDate'));
        $row->fulltext = pdfCleaner($row->fulltext);
        $row->introtext = pdfCleaner($row->introtext);
        $pdf = new Cezpdf('a4', 'P');
        //A4 Portrait
        $pdf->ezSetCmMargins(2, 1.5, 1, 1);
        $pdf->selectFont('./fonts/Helvetica.afm');
        //choose font
        $all = $pdf->openObject();
        $pdf->saveState();
        $pdf->setStrokeColor(0, 0, 0, 1);
        // footer
        $pdf->addText(250, 822, 6, $mosConfig_sitename);
        $pdf->line(10, 40, 578, 40);
        $pdf->line(10, 818, 578, 818);
        $pdf->addText(30, 34, 6, $mosConfig_live_site);
        $pdf->addText(250, 34, 6, _PDF_POWERED);
        $pdf->addText(450, 34, 6, _PDF_GENERATED . ' ' . date('j F, Y, H:i', time() + $mosConfig_offset * 60 * 60));
        $pdf->restoreState();
        $pdf->closeObject();
        $pdf->addObject($all, 'all');
        $pdf->ezSetDy(30);
        $txt1 = $row->title;
        $pdf->ezText($txt1, 14);
        $txt2 = AuthorDateLine($row, $params);
        $pdf->ezText($txt2, 8);
        $txt3 = $row->introtext . "\n" . $row->fulltext;
        $pdf->ezText($txt3, 10);
        $pdf->ezStream();
    } else {
        mosNotAuth();
        return;
    }
}
Ejemplo n.º 4
0
 /**
  * Creates a PDF document and sends this pricelist to the client
  *
  * Unfortunately, ezpdf does not return anything after printing the
  * document, so there's no way to tell whether it has succeeded.
  * Thus, you should not rely on the return value, except when it is
  * false -- in that case, loading of some data failed.
  * @return  boolean           False on failure, true on supposed success
  */
 function send_as_pdf()
 {
     global $objInit, $_ARRAYLANG;
     if (!$this->load()) {
         return \Message::error($_ARRAYLANG['TXT_SHOP_PRICELIST_ERROR_LOADING']);
     }
     $objPdf = new \Cezpdf('A4');
     $objPdf->setEncryption('', '', array('print'));
     $objPdf->selectFont(\Cx\Core\Core\Controller\Cx::instanciate()->getCodeBaseLibraryPath() . '/ezpdf/fonts/' . $this->font);
     $objPdf->ezSetMargins(0, 0, 0, 0);
     // Reset margins
     $objPdf->setLineStyle(0.5);
     $marginTop = 30;
     $biggerCountTop = $biggerCountBottom = 0;
     $arrHeaderLeft = $arrHeaderRight = $arrFooterLeft = $arrFooterRight = array();
     if ($this->header) {
         // header should be shown
         $arrHeaderLeft = explode("\n", $this->header_left);
         $arrHeaderRight = explode("\n", $this->header_right);
         $countLeft = count($arrHeaderLeft);
         $countRight = count($arrHeaderRight);
         $biggerCountTop = $countLeft > $countRight ? $countLeft : $countRight;
         $marginTop = $biggerCountTop * 14 + 36;
     }
     // Bottom margin
     $marginBottom = 20;
     $arrFooterRight = array();
     if ($this->footer) {
         // footer should be shown
         // Old, obsolete:
         $this->footer_left = str_replace('<--DATE-->', date(ASCMS_DATE_FORMAT_DATE, time()), $this->footer_left);
         $this->footer_right = str_replace('<--DATE-->', date(ASCMS_DATE_FORMAT_DATE, time()), $this->footer_right);
         // New:
         $this->footer_left = str_replace('[DATE]', date(ASCMS_DATE_FORMAT_DATE, time()), $this->footer_left);
         $this->footer_right = str_replace('[DATE]', date(ASCMS_DATE_FORMAT_DATE, time()), $this->footer_right);
         $arrFooterLeft = explode("\n", $this->footer_left);
         $arrFooterRight = explode("\n", $this->footer_right);
         $countLeft = count($arrFooterLeft);
         $countRight = count($arrFooterRight);
         $biggerCountBottom = $countLeft > $countRight ? $countLeft : $countRight;
         $marginBottom = $biggerCountBottom * 20 + 20;
     }
     // Borders
     if ($this->border) {
         $linesForAllPages = $objPdf->openObject();
         $objPdf->saveState();
         $objPdf->setStrokeColor(0, 0, 0, 1);
         $objPdf->rectangle(10, 10, 575.28, 821.89);
         $objPdf->restoreState();
         $objPdf->closeObject();
         $objPdf->addObject($linesForAllPages, 'all');
     }
     // Header
     $headerArray = array();
     $startpointY = 0;
     if ($this->header) {
         $objPdf->ezSetY(830);
         $headerForAllPages = $objPdf->openObject();
         $objPdf->saveState();
         for ($i = 0; $i < $biggerCountTop; ++$i) {
             $headerArray[$i] = array('left' => isset($arrHeaderLeft[$i]) ? $arrHeaderLeft[$i] : '', 'right' => isset($arrHeaderRight[$i]) ? $arrHeaderRight[$i] : '');
         }
         $tempY = $objPdf->ezTable($headerArray, '', '', array('showHeadings' => 0, 'fontSize' => $this->font_size_header, 'shaded' => 0, 'width' => 540, 'showLines' => 0, 'xPos' => 'center', 'xOrientation' => 'center', 'cols' => array('right' => array('justification' => 'right'))));
         $tempY -= 5;
         if ($this->border) {
             $objPdf->setStrokeColor(0, 0, 0);
             $objPdf->line(10, $tempY, 585.28, $tempY);
         }
         $startpointY = $tempY - 5;
         $objPdf->restoreState();
         $objPdf->closeObject();
         $objPdf->addObject($headerForAllPages, 'all');
     }
     // Footer
     $pageNumbersX = $pageNumbersY = $pageNumbersFont = 0;
     if ($this->footer) {
         $footerForAllPages = $objPdf->openObject();
         $objPdf->saveState();
         $tempY = $marginBottom - 5;
         if ($this->border) {
             $objPdf->setStrokeColor(0, 0, 0);
             $objPdf->line(10, $tempY, 585.28, $tempY);
         }
         // length of the longest word
         $longestWord = 0;
         foreach ($arrFooterRight as $line) {
             if ($longestWord < strlen($line)) {
                 $longestWord = strlen($line);
             }
         }
         for ($i = $biggerCountBottom - 1; $i >= 0; --$i) {
             if (empty($arrFooterLeft[$i])) {
                 $arrFooterLeft[$i] = '';
             }
             if (empty($arrFooterRight[$i])) {
                 $arrFooterRight[$i] = '';
             }
             if ($arrFooterLeft[$i] == '<--PAGENUMBER-->' || $arrFooterLeft[$i] == '[PAGENUMBER]') {
                 $pageNumbersX = 65;
                 $pageNumbersY = $tempY - 18 - $i * $this->font_size_footer;
                 $pageNumbersFont = $this->font_size_list;
             } else {
                 $objPdf->addText(25, $tempY - 18 - $i * $this->font_size_footer, $this->font_size_footer, $arrFooterLeft[$i]);
             }
             if ($arrFooterRight[$i] == '<--PAGENUMBER-->' || $arrFooterRight[$i] == '[PAGENUMBER]') {
                 $pageNumbersX = 595.28 - 25;
                 $pageNumbersY = $tempY - 18 - $i * $this->font_size_footer;
                 $pageNumbersFont = $this->font_size_list;
             } else {
                 // Properly align right
                 $width = $objPdf->getTextWidth($this->font_size_footer, $arrFooterRight[$i]);
                 $objPdf->addText(595.28 - $width - 25, $tempY - 18 - $i * $this->font_size_footer, $this->font_size_footer, $arrFooterRight[$i]);
             }
         }
         $objPdf->restoreState();
         $objPdf->closeObject();
         $objPdf->addObject($footerForAllPages, 'all');
     }
     // Page numbers
     if (isset($pageNumbersX)) {
         $objPdf->ezStartPageNumbers($pageNumbersX, $pageNumbersY, $pageNumbersFont, '', $_ARRAYLANG['TXT_SHOP_PRICELIST_FORMAT_PAGENUMBER'], 1);
     }
     // Margins
     $objPdf->ezSetMargins($marginTop, $marginBottom, 30, 30);
     // Product table
     if (isset($startpointY)) {
         $objPdf->ezSetY($startpointY);
     }
     $objInit->backendLangId = $this->lang_id;
     $_ARRAYLANG = $objInit->loadLanguageData('Shop');
     Currency::setActiveCurrencyId($this->currency_id);
     $currency_symbol = Currency::getActiveCurrencySymbol();
     $category_ids = $this->category_ids();
     if ($category_ids == '*') {
         $category_ids = null;
     }
     $count = 1000;
     // Be sensible!
     // Pattern is "%" because all-empty parameters will result in an
     // empty array!
     $arrProduct = Products::getByShopParams($count, 0, null, $category_ids, null, '%', null, null, '`category_id` ASC, `name` ASC');
     $arrCategoryName = ShopCategories::getNameArray();
     $arrOutput = array();
     foreach ($arrProduct as $product_id => $objProduct) {
         $categoryIds = explode(',', $objProduct->category_id());
         $arrCategoryNames = array();
         foreach ($categoryIds as $categoryId) {
             $arrCategoryNames[] = $arrCategoryName[$categoryId];
         }
         //$objProduct = new Product();
         $arrOutput[$product_id] = array('product_name' => self::decode($objProduct->name()), 'category_name' => self::decode(implode(', ', $arrCategoryNames)), 'product_code' => self::decode($objProduct->code()), 'product_id' => self::decode($objProduct->id()), 'price' => ($objProduct->discount_active() ? "S " . Currency::formatPrice($objProduct->discountprice()) : Currency::formatPrice($objProduct->price())) . ' ' . $currency_symbol);
     }
     $objPdf->ezTable($arrOutput, array('product_name' => '<b>' . self::decode($_ARRAYLANG['TXT_SHOP_PRODUCT_NAME']) . '</b>', 'category_name' => '<b>' . self::decode($_ARRAYLANG['TXT_SHOP_CATEGORY_NAME']) . '</b>', 'product_code' => '<b>' . self::decode($_ARRAYLANG['TXT_SHOP_PRODUCT_CODE']) . '</b>', 'product_id' => '<b>' . self::decode($_ARRAYLANG['TXT_ID']) . '</b>', 'price' => '<b>' . self::decode($_ARRAYLANG['TXT_SHOP_PRICE']) . '</b>'), '', array('showHeadings' => 1, 'fontSize' => $this->font_size_list, 'width' => 530, 'innerLineThickness' => 0.5, 'outerLineThickness' => 0.5, 'shaded' => 2, 'shadeCol' => array(hexdec(substr($this->row_color_1, 0, 2)) / 255, hexdec(substr($this->row_color_1, 2, 2)) / 255, hexdec(substr($this->row_color_1, 4, 2)) / 255), 'shadeCol2' => array(hexdec(substr($this->row_color_2, 0, 2)) / 255, hexdec(substr($this->row_color_2, 2, 2)) / 255, hexdec(substr($this->row_color_2, 4, 2)) / 255), 'cols' => array('product_name' => array('width' => 255), 'category_name' => array('width' => 130), 'product_code' => array('width' => 50), 'product_id' => array('width' => 40, 'justification' => 'right'), 'price' => array('width' => 55, 'justification' => 'right'))));
     $objPdf->ezStream();
     // Never reached
     return true;
 }
Ejemplo n.º 5
0
function citeRecords($result, $rowsFound, $query, $queryURL, $showQuery, $showLinks, $rowOffset, $showRows, $previousOffset, $nextOffset, $wrapResults, $citeStyle, $citeOrder, $citeType, $orderBy, $headerMsg, $userID, $viewType)
{
    global $officialDatabaseName;
    // these variables are defined in 'ini.inc.php'
    global $databaseBaseURL;
    global $contentTypeCharset;
    global $pdfPageSize;
    global $client;
    // The array '$transtab_refbase_pdf' contains search & replace patterns for conversion from refbase markup to PDf markup & entities
    global $transtab_refbase_pdf;
    // defined in 'transtab_refbase_pdf.inc.php'
    // Initialize array variables:
    $yearsArray = array();
    $typeTitlesArray = array();
    // Define inline text markup to be used by the 'citeRecord()' function:
    $markupPatternsArray = array("bold-prefix" => "<b>", "bold-suffix" => "</b>", "italic-prefix" => "<i>", "italic-suffix" => "</i>", "underline-prefix" => "<u>", "underline-suffix" => "</u>", "endash" => "¦", "emdash" => "©", "ampersand" => "&", "double-quote" => '"', "double-quote-left" => "ª", "double-quote-right" => "¬", "single-quote" => "'", "single-quote-left" => "®", "single-quote-right" => "¶", "less-than" => "<", "greater-than" => ">", "newline" => "\n");
    // Defines search & replace 'actions' that will be applied upon PDF output to all those refbase fields that are listed
    // in the corresponding 'fields' element:
    $pdfSearchReplaceActionsArray = array(array('fields' => array("title", "publication", "abbrev_journal", "address", "keywords", "abstract", "orig_title", "series_title", "abbrev_series_title", "notes"), 'actions' => $transtab_refbase_pdf));
    // For CLI queries, we'll allow paging thru the result set, i.e. we honour the values of the CLI options '-S|--start' ('$rowOffset')
    // and '-R|--rows' ('$showRows') ('$rowOffset' and '$showRows' are re-assigned in function 'seekInMySQLResultsToOffset()' in 'include.inc.php')
    if (preg_match("/^cli/i", $client)) {
        // if the query originated from a command line client such as the "refbase" CLI client ("cli-refbase-1.0")
        $showMaxRows = $showRows;
    } else {
        $showMaxRows = $rowsFound;
    }
    // otherwise show all rows
    // Setup the basic PDF document structure (PDF functions defined in 'class.ezpdf.php'):
    $pdf = new Cezpdf($pdfPageSize, 'portrait');
    // initialize PDF object
    if (!empty($headerMsg)) {
        // adjust upper page margin if a custom header message was given
        $pageMarginTop = "70";
    } else {
        $pageMarginTop = "50";
    }
    $pdf->ezSetMargins($pageMarginTop, 70, 50, 50);
    // set document margins (top, bottom, left, right)
    // Set fonts:
    $headingFont = 'includes/classes/org/pdf-php/fonts/Helvetica.afm';
    $textBodyFont = 'includes/classes/org/pdf-php/fonts/Times-Roman.afm';
    // Re-map character numbers from the 0->255 range to a named character, i.e. replace an (unused) character for any other PostScript char;
    // see the PDF reference for a list of supported PostScript/PDF character names: <http://www.adobe.com/devnet/pdf/pdf_reference.html>;
    // for the decimal code numbers of the ISO-8859-1 character set, see e.g.: <http://www.ramsch.org/martin/uni/fmi-hp/iso8859-1.html>
    $diff = array(166 => 'endash', 169 => 'emdash', 170 => 'quotedblleft', 172 => 'quotedblright', 174 => 'quoteleft', 182 => 'quoteright');
    // Select a font:
    $pdf->selectFont($textBodyFont, array('encoding' => 'WinAnsiEncoding', 'differences' => $diff));
    $pdf->openHere('Fit');
    // Put a footer (and optionally a header) on all the pages:
    $all = $pdf->openObject();
    // start an independent object; all further writes to a page will actually go into this object, until a 'closeObject()' call is made
    $pdf->saveState();
    $pdf->setStrokeColor(0, 0, 0, 1);
    // set line color
    $pdf->setLineStyle(0.5);
    // set line width
    // - print header line and header message at the specified x/y position:
    if (!empty($headerMsg)) {
        // Remove any colon (":") from end of header message:
        $headerMsg = trimTextPattern($headerMsg, ":", false, true);
        // function 'trimTextPattern()' is defined in 'include.inc.php'
        // Decode any HTML entities:
        // (these may occur in the header message e.g. if the user's preferred display language is not English but German or French, etc)
        $headerMsg = decodeHTML($contentTypeCharset, $headerMsg);
        // function 'decodeHTML()' is defined in 'include.inc.php', and '$contentTypeCharset' is defined in 'ini.inc.php'
        // Convert refbase markup in the header message into appropriate PDF markup & entities:
        $headerMsg = searchReplaceText($transtab_refbase_pdf, $headerMsg, true);
        // function 'searchReplaceText()' is defined in 'include.inc.php'
        if ($pdfPageSize == 'a4') {
            $pdf->line(20, 800, 575, 800);
            $pdf->addText(50, 805, 10, $headerMsg);
        } elseif ($pdfPageSize == 'letter') {
            $pdf->line(20, 750, 592, 750);
            $pdf->addText(50, 755, 10, $headerMsg);
        }
    }
    // - print footer line and footer text at the specified x/y position:
    if ($pdfPageSize == 'a4') {
        $pdf->line(20, 40, 575, 40);
        $pdf->addText(50, 28, 10, $officialDatabaseName . ' ¦ ' . $databaseBaseURL);
        // w.r.t. the endash, see notes at '$markupPatternsArray' and '$diff' above
    } elseif ($pdfPageSize == 'letter') {
        $pdf->line(20, 40, 592, 40);
        $pdf->addText(50, 28, 10, $officialDatabaseName . ' ¦ ' . $databaseBaseURL);
    }
    $pdf->restoreState();
    $pdf->closeObject();
    // close the currently open object; further writes will now go to the current page
    $pdf->addObject($all, 'all');
    // note that object can be told to appear on just odd or even pages by changing 'all' to 'odd' or 'even'
    // Start printing page numbers:
    if ($pdfPageSize == 'a4') {
        $pdf->ezStartPageNumbers(550, 28, 10, '', '', 1);
    } elseif ($pdfPageSize == 'letter') {
        $pdf->ezStartPageNumbers(567, 28, 10, '', '', 1);
    }
    // LOOP OVER EACH RECORD:
    // Fetch one page of results (or less if on the last page)
    // (i.e., upto the limit specified in $showMaxRows) fetch a row into the $row array and ...
    for ($rowCounter = 0; $rowCounter < $showMaxRows && ($row = @mysql_fetch_array($result)); $rowCounter++) {
        foreach ($row as $rowFieldName => $rowFieldValue) {
            // Apply search & replace 'actions' to all fields that are listed in the 'fields' element of the arrays contained in '$pdfSearchReplaceActionsArray':
            foreach ($pdfSearchReplaceActionsArray as $fieldActionsArray) {
                if (in_array($rowFieldName, $fieldActionsArray['fields'])) {
                    $row[$rowFieldName] = searchReplaceText($fieldActionsArray['actions'], $row[$rowFieldName], true);
                }
            }
        }
        // function 'searchReplaceText()' is defined in 'include.inc.php'
        // Order attributes according to the chosen output style & record type:
        $record = citeRecord($row, $citeStyle, $citeType, $markupPatternsArray, false);
        // function 'citeRecord()' is defined in the citation style file given in '$citeStyleFile' (which, in turn, must reside in the 'cite' directory of the refbase root directory), see function 'generateCitations()'
        // Print out the current record:
        if (!empty($record)) {
            // Print any section heading(s):
            if (preg_match("/year|type/i", $citeOrder)) {
                $headingPrefix = "";
                $headingSuffix = "";
                $sectionMarkupPrefix = "<b>";
                $sectionMarkupSuffix = "</b>\n";
                $subSectionMarkupPrefix = "";
                $subSectionMarkupSuffix = "\n";
                if ($citeOrder == "type-year") {
                    $sectionMarkupSuffix .= "\n";
                }
                list($yearsArray, $typeTitlesArray, $sectionHeading) = generateSectionHeading($yearsArray, $typeTitlesArray, $row, $citeOrder, $headingPrefix, $headingSuffix, $sectionMarkupPrefix, $sectionMarkupSuffix, $subSectionMarkupPrefix, $subSectionMarkupSuffix);
                // function 'generateSectionHeading()' is defined in 'cite.inc.php'
                if (!empty($sectionHeading)) {
                    $pdf->selectFont($headingFont, array('encoding' => 'WinAnsiEncoding', 'differences' => $diff));
                    // use Helvetica
                    $pdf->ezText($sectionHeading, '14', array('justification' => 'left'));
                    // create heading using a font size of 14pt
                }
            }
            // If character encoding is not UTF-8 already, convert record text to UTF-8:
            //				if ($contentTypeCharset != "UTF-8")
            //					$record = convertToCharacterEncoding("UTF-8", "IGNORE", $record); // function 'convertToCharacterEncoding()' is defined in 'include.inc.php'
            // NOTE: Export of cited references to PDF does currently only work with a latin1 database but not with UTF-8 (since I don't know how to write Unicode characters to PDF).
            //       As a workaround, we could convert UTF-8 characters to latin1 if possible (and omit any other higher ASCII chars)
            // TODO: While this workaround indeed fixes display issues with higher ASCII chars that have equivalents in the latin1 charset, this will currently swallow higher ASCII
            //       hyphens/dashes such as endashes (which display correctly without this workaround).
            //				if ($contentTypeCharset == "UTF-8")
            //					$record = convertToCharacterEncoding("ISO-8859-1", "TRANSLIT", $record, "UTF-8"); // function 'convertToCharacterEncoding()' is defined in 'include.inc.php'
            // Set paragraph text options:
            $textOptions = array('justification' => 'full');
            // possible array options:
            // 'left'=> number, gap to leave from the left margin
            // 'right'=> number, gap to leave from the right margin
            // 'aleft'=> number, absolute left position (overrides 'left')
            // 'aright'=> number, absolute right position (overrides 'right')
            // 'justification' => 'left','right','center','centre','full'
            //
            // only set one of the next two items (leading overrides spacing)
            // 'leading' => number, defines the total height taken by the line, independent of the font height.
            // 'spacing' => a real number, though usually set to one of 1, 1.5, 2 (line spacing as used in word processing)
            // Write PDF paragraph:
            $pdf->selectFont($textBodyFont, array('encoding' => 'WinAnsiEncoding'));
            // use Times-Roman
            $pdf->ezText($record . "\n", '12', $textOptions);
            // create text block with record text using "Times Roman" and a font size of 12pt
        }
    }
    return $pdf->ezStream();
}
Ejemplo n.º 6
0
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");
}
Ejemplo n.º 7
0
 function b_header(Cezpdf &$pdf, $partner_typ, $partner_id, $orientation = 'portrait', $font_file, $f_size, $logo_file = '')
 {
     $diff = array(196 => 'Adieresis', 228 => 'adieresis', 214 => 'Odieresis', 246 => 'odieresis', 220 => 'Udieresis', 252 => 'udieresis', 223 => 'germandbls');
     $pdf->selectFont('Helvetica', array('encoding' => 'WinAnsiEncoding', 'differences' => $diff));
     $all = $pdf->openObject();
     $pdf->saveState();
     $pdf->setStrokeColor(0, 0, 0, 1);
     if ($orientation == 'portrait') {
         $pdf->ezSetMargins(135, 70, 50, 50);
         if (!isset($_REQUEST['no_logo'])) {
             if ($logo_file == '') {
                 $logo_file = BERLUS_PATH . "/print_css/{$partner_typ}/{$partner_id}" . "_logo.png";
             }
             if (file_exists("{$logo_file}")) {
                 $pdf->addPngFromFile("{$logo_file}", 200, 730, 200, 80);
                 $pdf->line(43, 725, 545, 725);
                 $pdf->line(42, 50, 550, 50);
             }
         } else {
             $logo_file = BERLUS_PATH . "/print_css/{$partner_typ}/{$partner_id}" . "_logo.png";
         }
         $pdf->setLineStyle(0.5);
         $this->footer_info($partner_typ, $partner_id);
         $pdf->addText(43, 718, $f_size, "{$this->header_zeile}");
         $pdf->ezStartPageNumbers(545, 715, $f_size, '', 'Seite {PAGENUM} von {TOTALPAGENUM}', 1);
         $pdf->setLineStyle(0.5);
         if (!isset($_REQUEST['no_logo'])) {
             $pdf->addText($pdf->ez['pageWidth'] / 2, 42, $f_size, "{$this->zeile1}", 0, 'center');
             $pdf->addText($pdf->ez['pageWidth'] / 2, 35, $f_size, "{$this->zeile2}", 0, 'center');
         }
     } else {
         $pdf->ezSetMargins(120, 40, 30, 30);
         $logo_file = BERLUS_PATH . "/print_css/{$partner_typ}/{$partner_id}" . "_logo.png";
         if (file_exists("{$logo_file}")) {
             $pdf->addPngFromFile("{$logo_file}", 320, 505, 200, 80);
         } else {
             $pdf->addText(370, 505, $f_size, "Vorschau / Druckansicht ");
         }
         $pdf->setLineStyle(0.5);
         $this->footer_info($partner_typ, $partner_id);
         $pdf->line(43, 500, 785, 500);
         $pdf->addText(43, 493, $f_size, "{$this->header_zeile}");
         $pdf->ezStartPageNumbers(783, 493, $f_size, '', 'Seite {PAGENUM} von {TOTALPAGENUM}', 1);
         $pdf->setLineStyle(0.5);
         $pdf->line(42, 30, 785, 30);
         $pdf->addText($pdf->ez['pageWidth'] / 2, 23, $f_size, "{$this->zeile1}", 0, 'center');
         $pdf->addText($pdf->ez['pageWidth'] / 2, 16, $f_size, "{$this->zeile2}", 0, 'center');
     }
     $pdf->restoreState();
     $pdf->closeObject();
     $pdf->addObject($all, 'all');
 }
Ejemplo n.º 8
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));
}