<?php
//<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
//sigurnost:
if (!defined('SIGURICA')) die('Nedozvoljen pristup!');
if ($prava_pristup_sadrzaj!=1) die('Nedozvoljen pristup!');

$id_str=$_GET[id_str];
$id_par=$_REQUEST[id_par];

//naslovi od kategorije i stranice
$sql = "select naslov from b7_kategorija where id_kategorija='$id_kat'";
$rez = mysql_query($sql, $conn);
$row = mysql_fetch_array($rez);
$kategorija_naslov= $row[0];

$sql98="SELECT naslov FROM b7_sadrzaj WHERE id_sadrzaj='$id_str'";	
$rez98=mysql_query($sql98,$conn);
$row98=mysql_fetch_array($rez98);
$stranica_naslov= $row98[0];

//ucitaj parametre za paragraf
//parametri od paragrafa
$sql98="SELECT naslov,opis,prikaznaslov FROM b7_paragraf WHERE id_paragraf='$id_par'";	
$rez98=mysql_query($sql98,$conn);
$row98=mysql_fetch_array($rez98);
$naslov_paragraf=$row98['naslov'];
$opis_paragraf=$row98['opis'];
$prikaznaslov_paragraf=$row98['prikaznaslov'];

$sql98="SELECT tekst FROM b7_paragraf_tekst WHERE id_paragraf='$id_par'";	
$rez98=mysql_query($sql98,$conn);
$row98=mysql_fetch_array($rez98);
$tekst_paragraf=$row98['tekst'];


?>
<div id="main_content">
<h1>Uređivanje paragrafa (sadržaja) <em><?php echo $naslov_paragraf; ?></em> za stranicu <em><?php echo $stranica_naslov; ?></em> u <em><?php echo $rubrika_naslov; ?></em>, kategorija <em><?php echo $kategorija_naslov; ?></em></h1>

<form method="post" action="glavna.php?modul=<?php echo $modul;?>&amp;akcija=update_paragraf_download&amp;id_rub=<?php echo $id_rub;?>&amp;id_kat=<?php echo $id_kat;?>&amp;id_str=<?php echo $id_str;?>&amp;id_par=<?php echo $id_par;?>" enctype="multipart/form-data" onSubmit="return checkrequired(this)">
<input type="hidden" name="q_model" value="7" />
<script type="text/javascript">
$(function() {
	$("#datepicker1").datepicker({ dateFormat: 'dd.mm.yy' });
});
</script>
<input type="hidden" name="q_model" value="7" />
<?php
//kreiraj datum
list($mday,$month,$year) = preg_split("( )",date("d m Y"));
$datum=$mday.'.'.$month.'.'.$year;
?>
<fieldset>
<legend>Unos fajla u download listu:</legend>
<p>
<label><a href="#" class="help" onMouseover="ddrivetip('Datum koji se prikazuje uz vijest na stranicama', 200)"; onMouseout="hideddrivetip()">Datum</a>:</label>
<input tabindex="4" type="text" name="new_datum" maxlength="12" size="12" id="datepicker1" value="<?php echo $datum;?>" /><br />
</p>
<p>
<label><span style="color:#ff0000">*</span><a href="#" class="help" onMouseover="ddrivetip('Naslov fajla', 200)"; onMouseout="hideddrivetip()">Naslov fajla</a>:</label>
<input tabindex="5" type="text" size="40" maxlength="250" name="q_naslov_file" id="requiredNaslov fajla" /><br />
</p>
<p>
<label><a href="#" class="help" onMouseover="ddrivetip('prona&#273;ite file na vašem kompjuteru koji želite uploadati na server.', 300)"; onMouseout="hideddrivetip()">File</a>:</label>
<input tabindex="6" name="new_file" type="file" size="50" /><br />
</p>
</fieldset>
    
<p>
<input tabindex="16" name="posalji" class="submit" type="submit" value="Pošalji" />
</p>
</form>
<?php
$sql = "select naslov,datum_prikaz,dan,opis,velicina,id from b7_paragraf_upload where id_paragraf='$id_par' order by datum_prikaz desc";
    $rez = mysql_query($sql, $conn);
    if ($rez) $num = mysql_num_rows($rez);
    if ($num > 0) {
	?>
    <br />
    <script type="text/javascript">
    $(document).ready(function(){
    //JQuery ready is quicker than onload
    $(".stripeMe tr").mouseover(function() {$(this).addClass("over");}).mouseout(function() {$(this).removeClass("over");});
    $(".stripeMe tr:even").addClass("alt");
    });
    </script>
    <table  class="stripeMe" cellpadding="5" cellspacing="1" border="0">
    <tr>
    <th>Red.br.</th>
    <th>Ime fajla</th>
    <th>Putanja do fajla</th>
    <th>Veličina</th>
    <th>Datum</th>
    <th>Akcija</th>
    </tr>
    <?php
	$cur=1;
	$tekst_novi='';
	while ($num>=$cur) {
		$row99=mysql_fetch_array($rez);	
		$file_name=$row99[0];
		$datum_prikaz=$row99[1];
		$dan=$row99[2];
		$opis=$row99[3];
		$velicina=$row99[4];
		$id_file=$row99[5];
		
		$tekst_novi .= '<tr>' . "\n";
		$tekst_novi .= '<td>'.$cur.'.</td>' . "\n";
		$tekst_novi .= '<td>'.$opis.'</td>' . "\n";
		$tekst_novi .= '<td><a href="../upload/paragraf/'.$file_name.'" target="_blank">'.$parametar_domena.'upload/paragraf/'.$file_name.'</a></td>' . "\n";
		$tekst_novi .= '<td>'.$velicina.'</td>' . "\n";
		$tekst_novi .= '<td>'.$dan.', '.date_format(date_create($datum_prikaz), 'd.m.Y').'</td>' . "\n";
		$tekst_novi .= '<td><a href="glavna.php?modul='.$modul.'&amp;akcija=delete_fajl&amp;id_rub='.$id_rub.'&amp;id_kat='.$id_kat.'&amp;id_str='.$id_str.'&amp;id_par='.$id_par.'&amp;id_file='.$id_file.'" onMouseover="ddrivetip(\'Obriši fajl <b>'.$opis.'</b> iz liste\', 200)"; onMouseout="hideddrivetip()" onclick="return verify()"><em>Obriši fajl</em></a></td>' . "\n";			
		$tekst_novi .= '</tr>' . "\n";
		$cur++;
	}
	echo $tekst_novi;
	?>
    </table>
    <?php
}
?>
<br />
<br />
<?php
if ($kategorija!='0') {
	?>    
	<a class="gray_normal" href="glavna.php?modul=<?php echo $modul; ?>&amp;akcija=display_paragrafi&amp;id_rub=<?php echo $id_rub;?>&amp;id_kat=<?php echo $id_kat;?>&amp;id_str=<?php echo $id_str;?>"><img src="slike/action_back.gif" width="16" height="16" alt="" border="0" /> <b>Povratak!</b></a>
	<?php
	}
?>
<br />
<br />
</div>