<?php
/**
 * phpaga
 *
 * PDF template: show a table containing a list of projects
 *
 * This file contains the necessary routines to manage expenses.
 *
 * @author Florian Lanthaler <florian@phpaga.net>
 * @version $Id: projects.tpl.php 887 2007-11-05 13:34:10Z florian $
 *
 * 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_projects = $data["show_projects"];
$show_fields = $data["show_fields"];
$search_params = $data["search_params"];
$header = "";

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

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


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

    /* display search parameters */
    $this->ezTable($search_params,
                   array("param" => "",
                         "value" => ""
                       ),
                   utf8_decode(_("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->line(PHPAGA_PDF_BORDER_LEFT,
            822,
            PHPAGA_PDF_DOCWIDTH - PHPAGA_PDF_BORDER_LEFT,
            822);

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

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

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

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

$this->ezTable($show_projects,
               $show_fields,
               utf8_decode(_("Projects")),
               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"))
                   )
    );

    ?>
