<?php	include "functions.php";
			
		if(!empty($_REQUEST['serija']))
			$serija=$_REQUEST['serija'];
		else
			$serija=1;
		
		setTBLNalog($serija);
		$con = mysql_connect('localhost', 'pcpomoc_potni', 'boroko');
		//$con = mysql_connect('localhost', 'root', '');
		if (!$con){
			echo('Could not connect: ' . mysql_error());
		}
		mysql_select_db("pcpomoc_potni", $con);
		mysql_query("SET NAMES 'utf8'") or die(mysql_error());
		mysql_query("SET lc_time_names = 'sl_SI'") or die(mysql_error());
		$nalog=mysql_query("SELECT * FROM nalog WHERE serija='$serija'") or die(mysql_error);
		$tbl_nalog=mysql_query("SELECT * FROM tbl_nalog WHERE serija='$serija'");
		$tbl_pot=mysql_query("SELECT * FROM tbl_pot");
		$p=mysql_fetch_array($tbl_pot);
		$n=mysql_fetch_array($tbl_nalog);
		$avto=getAvto($n['avto_id']);
		
		
	
		
		echo "<div class='od'><label>Od: </label><span>{$n['datum_od']}</span></div>
		<div class='do'><label>Do: </label><span>{$n['datum_do']}</span></div>
		<div class='znesek'><label>Znesek: </label><span>{$n['znesek']} €</span></div>
		<div class='kilometrina'><label>Kilometrina: </label><span>{$n['kilometrina']} €/km</span></div>
		<div class='avto_id'><label>Skupni znesek: </label><span>{$n['skupna_cena']}</span></div>
		<div class='avto_id'><label>Kilometrov: </label><span>{$n['skupaj_km']}</span></div>
		<div class='avto_id'><label>Kilometrina: </label><span>{$n['kilometrina']}</span></div>
		<div class='avto_id'><label>Avto: </label><span>{$avto['opis']} - {$avto['registracija']}</span></div>
		<div class='avto_id'><label>Potnik: </label><span>{$avto['potnik']}</span></div><br>";
		
		echo "<a href='/scripts/izpisi.php?ser={$serija}' target='_blank'>Rekapitulacija</a><br><br>";
		
		//echo "<a href='#' class='zbrisi'>Zbrisi naloge</a>";
			
		echo "<table class='list no-zebra wide izracunstroskov'>
		<thead>
		<tr><td>Datum</th>
		<td>Pot</th>
		<td>km</th>
		<td>€</th>
		<td>St. izpisa</th>
		<td>#</th><th>
		</th></tr>
		</thead><tbody>";
		
		$id=0;
		while($row = mysql_fetch_array($nalog))
		{	
			$id++;
			echo "<tr>";
			echo "<td>" . $row['datum'] . "</td>";
			echo "<td>" . $row['pot'] . "</td>";
			echo "<td>" . $row['km'] . "</td>";
			echo "<td>" . $row['cena'].  "</td>";
			echo "<td>" . $row['serija'] . "</td>";
			echo "<td>" . $id . "</td>";
			echo "<td style='display:none'>{$row['id']}</td>";
			echo "<td><a href='#' class='uredi'>Uredi</a></td>";
			echo "<td><a href='/scripts/izpisi.php?id={$row['id']}' target='_blank'>Izpiši</a></td>";
			echo "<td><a href='#' class='zbrisi'>Zbriši nalog</a></td>";
			echo "</tr>";
		}
		echo "</tbody></table>";
		echo "<a href='javascript:dodajNalog();'>Dodaj nalog</a><br>
			<div id='dodaj_nalog' style='display:none'>
			<form name='input' autocomplete='off'><input type='txt' id='serija' value='{$serija}' style=display:none>Datum: <input type='text' id='datum' class='datum'> Pot: <input type='text' id='pot'> KM: <input type='text' id='km' size='2'>";
		
		echo "</select><input type='button' class='shraniNalog' value='Shrani'></form></div>";
		
		mysql_close($con);
			
?>