<?
$infoses='aavod001';
$infotem='vod';
$infotyp='trf';
$infovstup='vod001';
$infovystup='aavod001.pdf';
$infonazev='XPDF - Výpis odečtů';
$infodatum='28032024';
$infoautor='TOPSPIN Solutions - Martin Matoušek';
$infopopis='TIS - Výpis odečtů';

$sirka = 21;
$vyska = 20.3;
if (!($DolniOkraj > 0)) {
  $DolniOkraj = 2;
}
ZacatekSestavy;
NovaStranka();
Pismo('Tahoma', '', 10);
$y = 4;
$spotrebaCelkem = 0;

function HlavickaStranky()
{
  global $infonazev, $orgnazev, $orgic, $orgulicecpopcor, $orgpscmisto, $stranka, $infoses, $infodatum, $sirka, $tfp, $tfpnazev, $alg, $algtxt, $od, $do, $datvyst, $textFromDialog;

  FormatovanyText($infonazev, 0, 1, $sirka, 0.1, 'C');
  //Text('IS TIS - Topspin Solutions',1,1);
  Text($orgnazev, 1, 1.6);
  Text('IČ: ' . $orgic, 1, 2);
  Text($orgulicecpopcor, 1, 2.4);
  Text($orgpscmisto, 1, 2.8);

  Text('Stranka:', 15, 1);
  Text('Identifikace:', 15, 2);
  Text('Verze:', 15, 2.4);
  Text('Datum:', 15, 2.8);

  Text('TFP:     ' . $tfp . ' - ' . $tfpnazev, 6, 2);
  Text($textFromDialog,6,2.4);

  FormatovanyText($stranka, 15, 1, 4, 0.1, 'R');
  FormatovanyText($infoses, 15, 2, 4, 0.1, 'R');
  FormatovanyText($infodatum, 15, 2.4, 4, 0.1, 'R');
  FormatovanyText($datvyst, 15, 2.8, 4, 0.1, 'R');
  VystredenaCara(1, 3);
}

function HlavickaSloupcu()
{
  RamecekKolemStranky(0.5);
  FormatovanyText('Datum odečtu', 1, 3.5, 2, 0.1, 'L');
  FormatovanyText('VS', 3, 3.5, 2, 0.1, 'L');
  FormatovanyText('Č.pop', 6.5, 3.5, 3, 0.1, 'L');
  //FormatovanyText('Stav1'   , 9,   3.5, 2.5,0.1,'R');           
  FormatovanyText('Stav1', 11.5, 3.5, 2.5, 0.1, 'R');
  FormatovanyText('Stav2', 14, 3.5, 2.5, 0.1, 'R');
  FormatovanyText('Spotřeba', 16.5, 3.5, 2.5, 0.1, 'R');
}

function TiskRadku($y, $datvzn, $datumOdectu, $vs, $nazev, $ulicecpopcor, $stav1, $stav2, $spotreba)
{
  global $spotrebaCelkem;

  FormatovanyText($datumOdectu, 1, $y, 2, 0, 'L');
  FormatovanyText($vs, 3, $y, 2, 0, 'L');
  FormatovanyText($ulicecpopcor, 6.5, $y, 3, 0, 'L');
  //FormatovanyText('radek',     9,  $y,2.5,0,'R');              
  FormatovanyText($stav1, 11.5, $y, 2.5, 0, 'R');
  FormatovanyText($stav2, 14, $y, 2.5, 0, 'R');
  FormatovanyText($spotreba, 16.5, $y, 2.5, 0, 'R');

  $spotrebaCelkem += $spotreba;

}


if (!($fr = fopen($tisroot . "/tmp/aavod001.out", "r"))) {
  exit;
}

$buffer = fgets($fr, 4096);
list($segment, $orgnazev, $orgic, $orgulicecpopcor, $orgpscmisto, $orgbanka, $orgucet, $uzivatel, $tfp, $tfpnazev, $datvyst, $od, $do, $alg, $algtxt, $text, $vyrizuje, $spravce, $av8nad, $vyhlaska6, $funkce, $poverenypracovnik, $textFromDialog) = split('[|]', $buffer);

HlavickaStranky();
Pismo('Tahoma', '', 9);
HlavickaSloupcu();

$oldvs = "prvni";
$castkaNaSlozenku = 0;
$ppl = 1;
$y_ppl = 3.5;
$y = 4;

Pismo('Tahoma', '', 9);

$buffer = fgets($fr, 4096);
$oldbuffer = $buffer;

while (!feof($fr)) {

  if ((trim($buffer) != "") and (substr($buffer, 0, 3) == "vod")) {
    list($segment, $datumOdectu, $vs, $objmeno, $misto, $cpop, $stav1, $stav2, $sazba, $sazbaStocne, $stocne, $pronajem, $datumUzavreni, $celkem, $vodne, $spotreba) = split('[|]', $buffer);

    TiskRadku($y, $datumOdectu, $datumOdectu, $vs, $objmeno, $cpop, $stav1, $stav2, $spotreba);
    $y += 0.4;

    if ($y > ($vyska - $DolniOkraj)) {
      $y = 4;
      NovaStranka();
      HlavickaStranky();
      HlavickaSloupcu();
    }
  }

  $buffer = fgets($fr, 4096);

}

$y += 1;
VystredenaCara(1, $y);
$y += 0.4;

Text('Celkem spotřeba:', 13, $y);
FormatovanyText(money2str2($spotrebaCelkem), 13, $y, 6, 0, 'R');

fclose($fr);
KonecSestavy();

?>
