
<script type="text/javascript">
	$(document).ready(function(){
		$('#tabs').tabs();
	});
</script>

<div id="content">

	<!--  start page-heading -->
	<div id="page-heading">
		<!--       <h1>Add product</h1> -->
	</div>
	<!-- end page-heading -->
	<table>
	<tr>
	
	<td>
		<table border="0" width="100%" cellpadding="0" cellspacing="0" id="content-table">
		<tr>
			<th rowspan="3" class="sized"><img src="<?php echo base_url(); ?>images/shared/side_shadowleft.jpg" width="20" height="300" alt="" /></th>
			<th class="topleft"></th>
			<td id="tbl-border-top">&nbsp;</td>
			<th class="topright"></th>
			<th rowspan="3" class="sized"><img src="<?php echo base_url(); ?>images/shared/side_shadowright.jpg" width="20" height="300" alt="" /></th>
		</tr>
		<tr>
			<td id="tbl-border-left"></td>
			<td>
			<!--  start content-table-inner ...................................................................... START -->
			<div id="content-table-inner">
			
				<!--  start table-content  -->
				<div id="table-content">
				
				<?php if(  $this->messages->get_message('yellow', false)  /*get_cookie('yellow')/*$this->session->userdata('yellow')*/) { ?>
					<!--  start message-yellow -->
					<div id="message-yellow">
					<table border="0" width="100%" cellpadding="0" cellspacing="0">
					<tr>
						<td class="yellow-left"><!--You have a new message. <a href="">Go to Inbox.</a>--><?php echo $this->messages->get_message('yellow');
						//echo $this->session->userdata('yellow'); echo get_cookie('yellow');
						?></td>
						<td class="yellow-right"><a class="close-yellow"><img src="<?php echo base_url(); ?>images/table/icon_close_yellow.gif"   alt="" /></a></td>
					</tr>
					</table>
					</div>
					<!--  end message-yellow -->
				<?php } ?>	
					
				<?php if(  $this->messages->get_message('red', false)  /*get_cookie('red')/*$this->session->userdata('red')*/) { ?>
					<!--  start message-red -->
					<div id="message-red">
					<table border="0" width="100%" cellpadding="0" cellspacing="0">
					<tr>
						<td class="red-left"><!--Error. <a href="">Please try again.</a>--><?php echo $this->messages->get_message('red');
						//echo $this->session->userdata('red'); echo get_cookie('red')
						?></td>
						<td class="red-right"><a class="close-red"><img src="<?php echo base_url(); ?>images/table/icon_close_red.gif"   alt="" /></a></td>
					</tr>
					</table>
					</div>
					<!--  end message-red -->
				<?php } ?>	
				
				<?php if(  $this->messages->get_message('blue', false)  /*get_cookie('blue')/*$this->session->userdata('blue')*/) { ?>
					<!--  start message-blue -->
					<div id="message-blue">
					<table border="0" width="100%" cellpadding="0" cellspacing="0">
					<tr>
						<td class="blue-left"><!--Welcome back. <a href="">View my account.</a> --><?php echo $this->messages->get_message('blue');
						//echo $this->session->userdata('blue'); echo get_cookie('blue');
						?></td>
						<td class="blue-right"><a class="close-blue"><img src="<?php echo base_url(); ?>images/table/icon_close_blue.gif"   alt="" /></a></td>
					</tr>
					</table>
					</div>
					<!--  end message-blue -->
				<?php } ?>
				
				<?php if(  $this->messages->get_message('green', false)  /*get_cookie('green')/*$this->session->userdata('green')*/) { ?>
					<!--  start message-green -->
					<div id="message-green">
					<table border="0" width="100%" cellpadding="0" cellspacing="0">
					<tr>
						<td class="green-left"><!--Product added sucessfully. <a href="">Add new one.</a>--><?php echo $this->messages->get_message('green');
						//echo $this->session->userdata('green'); echo get_cookie('green');
						?></td>
						<td class="green-right"><a class="close-green"><img src="<?php echo base_url(); ?>images/table/icon_close_green.gif"   alt="" /></a></td>
					</tr>
					</table>
					</div>
					<!--  end message-green -->
				<?php } ?>
				<div >

				
				<script type="text/javascript">
				$(document).ready(function(){
					
					$("#edytujTemplate").dialog({ 
						autoOpen: false,
						width: 600,
						close: function(event, ui) {
							$(".ui-overlay").attr("style", "display:none;");
						},
						buttons:{
							"Anuluj": function(){
								$(this).dialog("close");
								$(".ui-overlay").attr("style","display:none;");
							},
							"Zapisz": function(){
								$(this).find("form input[type=submit]").click();
							}
						}
					});

					$("#edytujTemplateA").dialog({ 
						autoOpen: false,
						width: 600,
						close: function(event, ui) {
							$(".ui-overlay").attr("style", "display:none;");
						},
						buttons:{
							"Anuluj": function(){
								$(this).dialog("close");
								$(".ui-overlay").attr("style","display:none;");
							},
							"Zapisz": function(){
								$(this).find("form input[type=submit]").click();
							}
						}
					});

					$("button.edytujTemplate").live('click', function(){

						$("div#edytujTemplate form input[name=template_id]").attr("value", $(this).attr("id"));
						//alert($(this).attr("id"));
						$("#edytujTemplate form input[name=name]").attr("value", $(this).parents(".template_div").find(".template_name").text());
						$("#edytujTemplate form input[name=desc]").attr("value", $(this).parents(".template_div").find(".template_desc").text());
						$("#edytujTemplate form input[name=folder]").attr("value", $(this).parents(".template_div").find(".template_folder").text());
						$("#edytujTemplate form input[name=old_folder]").attr("value", $(this).parents(".template_div").find(".template_folder").text());
						var enabled = $(this).parents(".template_div").find(".if_enabled").text();
						if(enabled == "Tak") {
							$("#edytujTemplate form input[name=enabled]").attr("checked", true);
						} else {
							$("#edytujTemplate form input[name=enabled]").attr("checked", false);
						}

						$(".ui-overlay").attr("style", "display:block;"); 
						$("#edytujTemplate").dialog("open");
					});

					$("button.edytujTemplateA").live('click', function(){
						$("#edytujTemplateA form input[name=templateA_id]").attr("value", $(this).attr("id"));

						$("#edytujTemplateA form input[name=name]").attr("value", $(this).parents(".templateA_div").find(".templateA_name").text());
						$("#edytujTemplateA form input[name=desc]").attr("value", $(this).parents(".templateA_div").find(".templateA_desc").text());
						$("#edytujTemplateA form input[name=folder]").attr("value", $(this).parents(".templateA_div").find(".templateA_folder").text());
						$("#edytujTemplateA form input[name=old_folder]").attr("value", $(this).parents(".templateA_div").find(".templateA_folder").text());
						var user_id = $(this).parents(".templateA_div").find(".templateA_user_id span.user_id").attr("id");
						//alert(user_id);
						$("#edytujTemplateA form select option").attr("selected", false);
						$("#edytujTemplateA form select option[value="+user_id+"]").attr("selected", true);
						
						$(".ui-overlay").attr("style", "display:block;");
						$("#edytujTemplateA").dialog("open");
					});
				});
				</script>
				
				<div id="edytujTemplate" title="Edycja opisu" >
					<h2><strong>Edytuj opis szablonu</strong></h2>
					<form action="<?php echo base_url(); ?>administrator/editglobaltemplate" method="post" enctype="multipart/form-data">
						<p>Nazwa</p>
						<p><input type="text" name="name" /></p>
						<p>Opis</p>
						<p><input type="text" name="desc" /></p>
						<p>Katalog</p>
						<p><input type="text" name="folder" /></p>
						<p>Zmień zdjęcie</p>
						<p><input type="file" name="photo" /></p>
						<p><label><input type="checkbox" name="enabled" /> Udostepniony dla klientów</label></p>
						<input type="hidden" name="old_folder" />
						<input type="hidden" name="template_id" value="" />
						<input style="display: none;" type="submit" value="Zapisz" />
					</form>
				</div>


				<div id="edytujTemplateA" title="Edycja opisu" >
					<h2><strong>Edytuj opis szablonu</strong></h2>
					<form action="<?php echo base_url(); ?>administrator/editarticletemplate" method="post" enctype="multipart/form-data">
						<p>Nazwa</p>
						<p><input type="text" name="name" /></p>
						<p>Opis</p>
						<p><input type="text" name="desc" /></p>
						<p>Katalog</p>
						<p><input type="text" name="folder" /></p>
						<p>Zmień zdjęcie</p>
						<p><input type="file" name="photo" /></p>
						<p>Wybierz użytkownika</p>
						<p><select name="user_id">
							<option value="0">Wszyscy</option>
							<?php if($users && $users->num_rows() > 0) foreach($users->result() as $user){ ?>
							<option value="<?=$user->ID_users?>"><?=$user->user_login?></option>
							<?php } ?>
						</select></p>
						<input type="hidden" name="old_folder" />
						<input type="hidden" name="templateA_id" />
						<input style="display: none;" type="submit" value="Zapisz" />
					</form>
				</div>

				<div class="ui-tabs ui-widget ui-widget-content ui-corner-all" id="tabs" >
					<ul class="ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all">
                        
                        
                
                        <?php /*?>
						<li class="ui-state-default ui-corner-top ui-tabs-selected ui-state-active"><a href="#szablony-dla-strony">Szablony dla strony</a></li>
						*/?>
						<li class="ui-state-default ui-corner-top ui-tabs-selected ui-state-active"><a href="#szablony-dla-artykulu">Szablony dla artykułu</a></li>
					
					</ul>
					
					<?php /*?>
					<div class="ui-tabs-panel ui-widget-content ui-corner-bottom" id="szablony-dla-strony">
						<form action="<?php echo base_url() ?>administrator/addglobaltemplate" enctype="multipart/form-data" method="post">
							<p>Nazwa</p>
							<p><input type="text" name="name"/></p>
							<p>Opis</p>
							<p><input type="text" name="desc"/></p>
							<p>Katalog</p>
							<p><input type="text" name="folder"/></p>					
							<p>Zdjęcie do podglądu</p>
							<p><input type="file" name="photo"/></p>
							<p><label><input type="checkbox" name="enabled" /> Udostepniony dla klientów</label></p>
							<p><input type="submit" value="Dodaj"/></p>
						</form>
						<br/>
						
						<?php if($templates && $templates->num_rows() > 0) foreach($templates->result() as $t) { ?>
							<div class="template_div">
								<a href="<?=base_url().'pages/application/template/'.$t->global_templates_folder.'/'.$t->global_templates_photo?>"><img src="<?=base_url().'pages/application/template/'.$t->global_templates_folder.'/thumb_'.$t->global_templates_photo?> " /></a>
								<p class="template_name"><?=$t->global_templates_name?></p>
								<p class="template_desc"><?=$t->global_templates_desc?></p>
								<p class="template_folder" style="display: none;"><?=$t->global_templates_folder?></p>
								<p>Udostępniony dla klientów: <span class="if_enabled"><?=$t->global_templates_enabled==1?'Tak':'Nie'?></span></p>
								<button id="<?=$t->ID_global_templates?>" class="edytujTemplate">Edycja opisu</button>
								<br/><br/>
							</div>
						<?php } ?>
					</div>
					<?php */?>
					
					<div class="ui-tabs-panel ui-widget-content ui-corner-bottom" id="szablony-dla-artykulu">
						<form action="<?php echo base_url() ?>administrator/addarticletemplate" enctype="multipart/form-data" method="post">
							<p>Nazwa</p>
							<p><input type="text" name="name" /></p>
							<p>Opis</p>
							<p><input type="text" name="desc" /></p>
							<p>Katalog</p>
							<p><input type="text" name="folder" /></p>
							<p>Nazwa pliku</p>
							<p><input type="text" name="filename" /></p>
							<p>Zdjęcie do podglądu</p>
							<p><input type="file" name="photo" /></p>
							<p>Wybierz użytkownika</p>
							<p><select name="user_id">
								<option value="0">Wszyscy</option>
								<?php if($users && $users->num_rows() > 0) foreach($users->result() as $user){ ?>
								<option value="<?=$user->ID_users?>"><?=$user->user_login?></option>
								<?php } ?>
							</select></p>
							<p><input type="submit" value="Dodaj" /></p>
						</form>
						<br/>
						
						<?php if($article_templates && $article_templates->num_rows() > 0) foreach($article_templates->result() as $at) { ?>
							<div class="templateA_div">
								<a href="<?=base_url().$at->article_templates_folder.''.$at->article_templates_photo?>"><img style="border:#333 solid 1px;" src="<?=base_url().$at->article_templates_folder.'thumb_'.$at->article_templates_photo?>" /></a>
								<p class="templateA_name"><?=$at->article_templates_name?></p>
								<p class="templateA_desc"><?=$at->article_templates_desc?></p>
								<p class="templateA_folder"><?php
									$folder = explode("/", $at->article_templates_folder);
									echo $folder[count($folder)-2];
								?></p>
								<p class="templateA_user_id">Klient: <span class="user_id" id="<?=$at->article_templates_user_id?>"><?=$at->username?></span></p>
								<button id="<?=$at->ID_article_templates?>" class="edytujTemplateA">Edycja opisu</button>
								<br/><br/>
							</div>
						<?php } ?>
					</div>
				</div>
			
			
			
				</div>
				<!--  end product-table................................... --> 
				
				</div>
				
				
				</div>
				<!--  end table-content  -->
				
			
			
			
			<div class="clear"></div>
				<div class="clear"></div>
			
			</div>
			<!--  end content-table-inner ............................................END  -->
			</td>
			<td id="tbl-border-right"></td>
		</tr>
		<tr>
			<th class="sized bottomleft"></th>
			<td id="tbl-border-bottom">&nbsp;</td>
			<th class="sized bottomright"></th>
		</tr>
		</table>
	</td>
	</tr>
	</table>
	<div class="clear">&nbsp;</div>

</div>
<!--  end content -->