<?
// Vytiskne seznam nodu na siti a posle na vystup jako PDF

include("../funkce.inc");

open_pgsql();

require('./fpdf.php');
$pdf=new FPDF(P,pt,A4);
$pdf->AddFont('arialn','','arialn.php');
$pdf->AddFont('arialnb','','arialnb.php');
$pdf->AddPage();
$pdf->SetDisplayMode(fullpage);
$pdf->SetLineWidth(1);
$pdf->SetFont('arialnb','',18);
$pdf->Text(17,36,'STARHILL NETWORK - NODES LIST ('.date("d.m.Y").')');
    
$pagenum=0;
function vypis($rodic,$depth) {
  global $pdf, $pagenum;
  $depth++;
  $vysledek=pg_Query("SELECT * FROM node WHERE idp=$rodic ORDER BY name");
  while ($data=pg_Fetch_Array($vysledek)) {
    $pagenum++;
    if($pagenum==28) { $pdf->AddPage(); $pagenum=1;}
    $vysl=pg_Query("SELECT ip FROM node_ip WHERE id=$data[id] ORDER BY ip");
    $ip='';
    while ($dataip=pg_Fetch_Array($vysl)) {
      $aip=explode(".",$dataip[ip]);
      $ip.=$aip[2].'.'.$aip[3].'  ';
    }
    $line=$data[name].' | login: '.$data[p_login].' / '.$data[p_pass];
    $line2='IP: '.$ip.'  | Kanál: '.$data[p_kanal];
    $pdf->SetFont('arialnb','',14); 
    $pdf->Text(17+($depth*10),38+($pagenum*28),$line);
    $pdf->SetFont('arialn','',11); 
    $pdf->Text(17+($depth*10),50+($pagenum*28),$line2);
    $pdf->Line(17+($depth*10), 25+($pagenum*28), 550, 25+($pagenum*28));
    vypis($data[id],$depth);
  }
}

vypis(0,-1);

// posle na tisk do prohlizece
$pdf->Output('shnodes.pdf',I);

?>
