<script type="text/javascript">

var ablak = false;

jQuery(document).ready(function($){
	
	$('a.fancy').fancybox({
		'onComplete': function(){
			ablak = true;
		},
		'onClosed': function(){
			ablak = false;
		}
	});
	
	$('#teljesrenderdoboz').dialog({
		autoOpen: false,
		modal: true,
		width: 560
	});
	
	
	// teljes render adatai
	$('.inditas').click(function(){
		ablak = true;
		
		//populate the dialog
		var con = $('#teljesrenderform');
		var rendid = $(this).attr('render_id');
		$('#renderid', con).val(rendid);
		
		//open the dialog
		$('#teljesrenderdoboz').dialog('open');
		$('div.ui-dialog-titlebar').css({'display': 'none'});
		$('div..ui-widget-content').css({'background': 'none'});
		$('div..ui-widget-content').css({'border': 'none'});
		$('div..ui-icon').css({'background': 'none'});
		
		return false;
	});
	
	
	$('.bezargomb').click(function(){
		$('#teljesrenderdoboz').dialog('close');
		ablak = false;
		return false;
	});
	
	$('#kupon').mask('9999************', {
		placeholder: '_ '
	});
	
//	alert("vége");
});

function frissites(){
	if(!ablak)
		window.location.href='';
	else
		setTimeout("frissites()", 60000);
}

function betolt(){
	setTimeout("frissites()", 60000);
}


function rendercheck(){
	var okupon = document.getElementById('kupon');
	var error ="";
	
	/* Ellenőrzések */
	
	if( okupon.disabled == "" && okupon.value == "" ){
		error += "<?=lang('render_hianyzokupon')?>";
		okupon.style.background = '#F9D3D3';
	}else{
		okupon.style.background = '';
	}
	
	
	if( error != ""  ){
		alert(error);
	}else{
		var feltolt = document.getElementById('teljesrenderform');
		feltolt.submit();
	}
}

function ablakbe(){
	ablak = true;
}

function ablakki(){
	ablak = false;
}

</script>

<style>
#kupon{
	background: url('/public/img/forum/stilus/inputbox.gif');
	color: #310000;
	width: 162px;
	height: 24px;
	padding: 5px;
}
</style>

<div style="display: none;" id="teljesrenderdoboz">
	<div class="forumpopuptop"></div>
	<div class="forumpopup">
		<?if(hun()):?>
		<?=$this->mpages->get_row(598)->page_body?>
		<?else:?>
		<?=$this->mpages->get_row(599)->page_body?>
		<?endif;?>
		<strong><?=lang('render_kupon')?>:</strong>
		<form action="/render/submit2" method="post" id="teljesrenderform">
		<input type="hidden" name="renderid" id="renderid" value="" />
		<input type="text" name='kupon' id='kupon' value='' />
		
		<div style="text-align: right;">
		<input type="button" value="OK" onclick="rendercheck()" class="ngomb" style="width: 120px; background: url('/public/img/forum/stilus/button_normal.png');" />
		<button class="bezargomb megsem" style="width: 120px; background: url('/public/img/forum/stilus/button_grey.png');">
			<?=lang('forum_megsem')?>
		</button>
		</div>
		</form>
	</div>
	<div class="forumpopupbottom"></div>
</div>


<style>
	span.nyomogomb{
		border: 1px solid #848484;
		font-weight: bold;
		margin-right: 15px;
		padding: 1px 5px;
	}
</style>

<?
	$user = $this->phpsession->get('fuser');
	$feltolto = $this->phpsession->get('feltolto');
?>

<h1><?=lang('forum_renderekkepek')?></h1>

<div>
	
	<div style="margin-top: 10px;">
		<?if($renderek):?>
		<?$allapotok = lang('render_allapotok')?>
		
		<div class="temaktop"></div>
		<div class="renderek">
		
		<?foreach($renderek as $render):?>
		<div class="renderkeret" style="background: url('/public/img/forum/stilus/box_render.png') no-repeat; background-position: 23px 3px; margin-bottom: 10px;">
			<table>
			<tr>
				<td style="width: 10px;">
					<?if($render->allapot == "1"):?>
						<img src="/public/img/forum/stilus/render_status_corner_done.png" />
					<?elseif($render->allapot == "2"):?>
						<img src="/public/img/forum/stilus/render_status_corner_in_progress.gif" />
					<?elseif($render->allapot == "4"):?>
						<img src="/public/img/forum/stilus/render_status_corner_waiting.png" />
					<?else:?>
						<img src="/public/img/forum/stilus/render_status_corner_error.png" />
					<?endif;?>
					<?if($render->teszt == "2"):?>
						<?if(hun()):?>
						<img src="/public/img/forum/stilus/render_type_corner_full.png" />
						<?else:?>
						<img src="/public/img/forum/stilus/render_type_corner_full_ENG.png" />
						<?endif;?>
					<?else:?>
						<?if(hun()):?>
						<img src="/public/img/forum/stilus/render_type_corner_test.png" />
						<?else:?>
						<img src="/public/img/forum/stilus/render_type_corner_test_ENG.png" />
						<?endif;?>
					<?endif;?>
				</td>
				<td valign="top" style="padding-top: 8px;">
					<?if($render->allapot == "1"):?>
						<a href="/<?=$render->keszkep?>" class="fancy">
						<?
							$fajlnev = basename($render->keszkep);
							$mappak = substr( $render->keszkep,0,(-1*(strlen($fajlnev))) );
							$elokep = $mappak."elo_".$fajlnev;
						?>
						<?if( file_exists($elokep) ):?>
							<img src="/<?=$elokep?>" />
						<?else:?>
							<img src="/<?=$render->keszkep?>" style="width: 200px; height: 150px;" />
						<?endif;?>
						</a>
					<?else:?>
						<a href="/<?=$render->kiskep?>" class="fancy">
						<img src="/<?=$render->kiskep?>" style="width: 200px; height: 150px;" />
						</a>
					<?endif;?>
				</td>
				<td valign="top" style="padding-top: 5px;">
					<span style="font-size: 1.1em; font-weight: bold;">
						<?=$render->render_name?><?if($_SESSION['default']['fuser']['user_id'] == "1044"):?>, id: <?=$render->guid?><?endif;?>
					</span>
					<span style="color: #bbb;">
					<table style="width: 325px; margin-right: 10px;" cellspacing="0" border="0">
					<tr>
						<td><?=lang('forum_feltoltve')?>:</td>
						<td align="right"><?=date('Y-m-d H:i', $render->datum)?></td>
					</tr>
					<tr>
						<td><?=lang('forum_renderallapot')?>:</td>
						<td align="right"><?=$allapotok[$render->allapot]?></td>
					</tr>
					<tr>
						<td><?=lang('forum_renderido')?>:</td>
						<td align="right">
						<?if($render->allapot == "1" && is_numeric($render->kezdet) && is_numeric($render->vege) ):?>
							<?
								if( $render->vege < 102778887 )
									$mp = $render->vege;
								else
									$mp = $render->vege - $render->kezdet;
								$mp3 = $mp;
								$mp2 = "";
								
								if($mp > (60*60*24)){
									$x = round($mp/(60*60*24));
									if($x>1)
										$mp2 .= " ".$x.' '.lang('forum_nap');
									else
										$mp2 .= " ".$x.' '.lang('forum_nap1');
									$mp -= round($mp/(60*60*24))*(60*60*24);
								}
								if($mp > (60*60)){
									$x = round($mp/(60*60));
									if($x > 1)
										$mp2 .= " ".$x.' '.lang('forum_ora');
									else
										$mp2 .= " ".$x.' '.lang('forum_ora1');
									$mp -= round($mp/(60*60))*(60*60);
								}
								if($mp > (60)){
									$x = round($mp/(60));
									if($x > 1)
										$mp2 .= " ".$x.' '.lang('forum_perc');
									else
										$mp2 .= " ".$x.' '.lang('forum_perc1');
									$mp -= (60);
								}elseif( $mp3 <= (60) && $mp2 == "" )
									$mp2 .= ' 1 '.lang('forum_perc1');
								
								if(hun())
									$masodperc = " mp";
								else
									$masodperc = " s";
								
								if( $render->vege < 102778887 )
									print $mp2;
								else
									print ($render->vege - $render->kezdet).$masodperc;//$mp2;
							?>
						<?else:?>
							-
						<?endif;?>
						</td>
					</tr>
					<tr>
						<td><?=lang('forum_rendertipus')?>:</td>
						<td align="right">-</td>
					</tr>
					<tr>
						<td><?=lang('forum_kepmeret')?>:</td>
						<td align="right"><?=$render->kepmeret?></td>
					</tr>
					<tr>
						<td><?=lang('forum_fajlmeret')?>:</td>
						<td align="right">
						<?if( $render->keszkep != "" && $render->allapot == "1" ):?>
							<?
							$meret = filesize($render->keszkep);
							if($meret < 1024*1024) $keszkepmeret = ceil($meret/1024).' KB';
							else $keszkepmeret = round($meret/(1024*1024),1).' MB';
							?>
							<?=$keszkepmeret?>
						<?else:?>-
						<?endif;?>
						</td>
					</tr>
					</table>
					</span>
				</td>
				<td valign="bottom">
					 <?if($render->allapot == "1"):?>
					 	<?
					 		$ertek = '_500.bmp';
					 /*		$adatok = json_decode($render->infok, true);
					 		if( isset($adatok['v1']) && $adatok['v1'] > 0 ){
					 			$ertek = "_".$adatok['v1'].".bmp";
					 		}*/
					 		$db = 0;
							$kepekxx = '/home/vendeg/render/eredmeny/';
							$handle = opendir($kepekxx);
							while($file = readdir($handle)){
								if( substr($file,0,36) == $render->guid ){
									$db++;
								}
							}
							
					 	 ?>
					 	<?if( $db == 5):?>
					 	<div class="rendergomb" style="background: url('/public/img/forum/stilus/buttons_big_edit.png');" onclick="window.location.href='/render/valaszt/1/<?=$render->guid?>'">
					 	<?=lang('render_beallitasok')?>
					 	</div>
					 	<?endif;?>
					 
						<?if($render->teszt == "1"):?>
							<div class="rendergomb <?if(KUPONKERES === true):?>inditas<?endif;?>" style="background: url('/public/img/forum/stilus/buttons_big_start.png');" render_id="<?=$render->render_id?>" onclick="<?if(KUPONKERES === true):?>rendercheckaa()<?else:?>window.location.href='/render/submit2/<?=$render->render_id?>'<?endif;?>">
							<?if(KUPONKERES === true && hun()):?>Fizető mód<?else:?><?=lang('forum_teljri')?><?endif;?>
							</div>
						<?endif;?>
						<?if( !$feltolto && (!is_numeric($render->forumgal_id) || $render->forumgal_id == "0") ):?>
						<div class="rendergomb" style="background: url('/public/img/forum/stilus/buttons_big_move.png');" onclick="window.location.href='/forum/rendercopy/<?=$render->guid?>'">
							<?=lang('forum_masolgal')?>
						</div>
						<?endif;?>
						<div class="rendergomb" style="background: url('/public/img/forum/stilus/buttons_big_download.png');" onclick="window.location.href='/forum/renderletolt/<?=$render->render_id?>'">
							<?=lang('download')?>
						</div>
						<div class="rendergomb" style="background: url('/public/img/forum/stilus/buttons_big_delete.png');" onclick="javascript:delQue('forum/delrender/<?=$render->render_id?>','<?=lang('forum_torlesmegerosites')?>')">
							<?=lang('forum_torles')?>
						</div>
					<?elseif(substr($render->allapot,0,1) == "3" || $render->allapot == "0" || $render->datum < (time()-(60*60*24*7)) ):?>
						<div class="rendergomb" style="background: url('/public/img/forum/stilus/buttons_big_delete.png');" onclick="javascript:delQue('render/delrenderforum/<?=$render->render_id?>','<?=lang('forum_torlesmegerosites')?>')">
							<?=lang('forum_torles')?>
						</div>
					<?else:?>
						
					<?endif;?>
				</td>
			</tr>
			</table>
		</div>
		<?endforeach;?>
		
		</div>
		<div class="temakbottom"></div>
		<?endif;?>
		
	</div>
	
</div>

<script type="text/javascript">
	function delQue(uri, strQue){
		if(confirm(strQue))
			window.location.href="/" + uri;
	}
</script>