<?php
/**
 * phpaga
 *
 * PDF template: show a table containing a list of operations
 *
 * This file contains the necessary routines to manage expenses.
 *
 * @author Florian Lanthaler <florian@phpaga.net>
 * @version $Id: operations.tpl.php 595 2005-08-21 00:19:53Z worf $
 *
 * Copyright (c) 2003, Florian Lanthaler <florian@phpaga.net>
 *
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are
 * met:
 *
 *    * Redistributions of source code must retain the above copyright
 *      notice, this list of conditions and the following disclaimer.
 *
 *    * Redistributions in binary form must reproduce the above copyright
 *      notice, this list of conditions and the following disclaimer in
 *      the documentation and/or other materials provided with the
 *      distribution.
 *
 *    * Neither the name of Florian Lanthaler nor the names of his
 *      contributors may be used to endorse or promote products derived
 *      from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
 * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
 * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

$show_operations = $data["show_operations"];
$show_fields = $data["show_fields"];
$search_params = $data["search_params"];
$title = $data["title"];
$header = "";


#$this->setColor(0.5,0.5,0.5, 1);

if ($data["insert_page"])
    $this->ezNewPage();

$setnum = $this->ezStartPageNumbers(PHPAGA_PDF_DOCWIDTH - PHPAGA_PDF_BORDER_LEFT,
                                      20,
                                      PHPAGA_PDF_FONT_SIZE_SMALL,
                                      'left',
                                      '{PAGENUM} / {TOTALPAGENUM}',
                                      1);


#$this->setColor(0,0,0, 1);

if (isset($search_params) && is_array($search_params)
    && (count($search_params) > 0))
{

    /* display search parameters */
    $this->ezTable($search_params,
                   array("param" => "",
                         "value" => ""
                       ),
                   _("Search parameters"),
                   array('fontSize' => PHPAGA_PDF_FONT_SIZE_SMALL,
                         'titleFontSize' => PHPAGA_PDF_FONT_SIZE_NORMAL,
                         'xPos' => 'center',
                         'xOrientation' => 'center',
                         'maxWidth' => PHPAGA_PDF_DOCWIDTH - 2 * PHPAGA_PDF_BORDER_LEFT,
                         'shaded' => 0,
                         'lineCol' => array(0.5, 0.5, 0.5),
                         'outerLineThickness' => 0.5,
                         'innerLineThickness' => 0.3,
                         'showHeadings' => 0,
                         'showLines' => 0
                       )
        );

    $this->ezSetDy(-25);

}

/* add a header to all following pages */
$header = $this->openObject();
$this->saveState();

$this->setStrokeColor(0.5,0.5,0.5, 1);
$this->setLineStyle(0.5);
$this->setColor(0.5,0.5,0.5, 1);

$this->line(PHPAGA_PDF_BORDER_LEFT,
            822,
            PHPAGA_PDF_DOCWIDTH - PHPAGA_PDF_BORDER_LEFT,
            822);

$this->line(PHPAGA_PDF_BORDER_LEFT,
            30,
            PHPAGA_PDF_DOCWIDTH - PHPAGA_PDF_BORDER_LEFT,
            30);

$this->addText(PHPAGA_PDF_BORDER_LEFT,
               20,
               PHPAGA_PDF_FONT_SIZE_SMALL,
               sprintf(_("Printed: %s"), date("Y-m-d H:i:s")));

$this->setStrokeColor(0,0,0, 1);
$this->setColor(0,0,0, 1);

#$this->addText(50,34,6,'');
$this->restoreState();
$this->closeObject();
$this->addObject($header, 'all');



$this->ezSetMargins(50,
                    40,
                    PHPAGA_PDF_BORDER_LEFT,
                    PHPAGA_PDF_BORDER_RIGHT);

$this->ezTable($show_operations,
               $show_fields,
               $title,
               array('fontSize' => PHPAGA_PDF_FONT_SIZE_SMALL,
                     'titleFontSize' => PHPAGA_PDF_FONT_SIZE_HEADER,
                     'xPos' => 'center',
                     'xOrientation' => 'center',
                     'maxWidth' => PHPAGA_PDF_DOCWIDTH - 2 * PHPAGA_PDF_BORDER_LEFT,
                     'shaded' => 2,
                     'shadeCol' => array(0.9, 0.9, 0.9),
                     'shadeCol2' => array(0.95, 0.95, 0.99),
                     'lineCol' => array(0.5, 0.5, 0.5),
                     'outerLineThickness' => 0.5,
                     'innerLineThickness' => 0.3,
                     'cols' => array("duration" => array("justification" => "right"))));

$this->ezStopPageNumbers(1, 1, $setnum);

?>