Skip to content

Instantly share code, notes, and snippets.

@fprochazka
Created July 30, 2010 08:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fprochazka/500173 to your computer and use it in GitHub Desktop.
Save fprochazka/500173 to your computer and use it in GitHub Desktop.
<?php
public function handleGenerujSestavu($rok, $mesic)
{
require_once(LIBS_DIR . '/tcpdf/config/lang/eng.php');
$nadpis = "Rekapitulace Zelené Nafty ".$this->getMonth((int)$mesic)." {$rok}";
//$sestava = new tcPdf('P', 'mm', 'A4', true, 'UTF-8', false);
$sestava = new tcPdf(PDF_PAGE_ORIENTATION, PDF_UNIT, 'A4', true);
$sestava->SetCreator(PDF_CREATOR);
$sestava->SetAuthor("ZelenaNafta");
$sestava->SetTitle($nadpis);
//set margins
$sestava->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
// $sestava->SetHeaderMargin(PDF_MARGIN_HEADER);
$sestava->SetFooterMargin(PDF_MARGIN_FOOTER);
$sestava->setPrintHeader(false);
// $sestava->setPrintFooter(false);
//set some language-dependent strings
$sestava->setLanguageArray($l);
//initialize document
$sestava->AliasNbPages();
// add a page
$sestava->AddPage();
// set font
$sestava->SetFont('FreeSerif', '', 13);
$template = $this->template('layouts/vychozi_sestava_zelena_nafta.phtml');
if( $mesic==12 ){
$konec_mesice = mktime(0,0,0,1,1,$rok+1);
} else {
$konec_mesice = mktime(0,0,0,$mesic+1,1,$rok);
}
$template->data = (array)dibi::query("SELECT a.[spz] , a.[typ] , a.[cislo_stroje], ",
"SUM(DISTINCT c.[litry]) AS [litry], 0 AS [rv], 0 AS [ostatni]",
"FROM [auta] AS a",
"INNER JOIN [cinnost_auta] AS c USING ( [id_auto] )",
"WHERE c.[datum] >=%i", mktime(0,0,0,$mesic,1,$rok)," AND c.[datum] <%i", $konec_mesice,
"GROUP BY c.id_auto")->fetchAll();
$template->nadpis = $nadpis;
$template->uplatne_celkem = 0;
$template->ostatni_celkem = 0;
$template->litry_celkem = 0;
$sestava->writeHtml( $template->__toString(), 2 );
$sestava->output('Zelena_Nafta_'.$rok.'.'.$mesic.'.pdf', True);
$this->terminate();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment