<?php

/**
 * Default home page view
 *  
 * @author
 * @version
 */

$this->headTitle('ISO');
$this->placeholder('title')->set('Administrace - kategorie');
?>

<h1 class="page_title">ADMINISTRACE</h1>
        <h1 class="group_title">Kategorie</h1>
            <div class="main_inner2">
    			<div class="main_inner">
    			
    				 <div class="left_column">
    	                <div class="left_column_item">
    	                    <?=$this->action('left-menu', 'layout', 'admin', array('leftmenu' => $this->leftmenu)); ?>
    	                </div>
    	            </div>
    	            
    				<div class="main_text_right">
                        <h2 class="section_heading">Kategorie</h2>
                        <div class="button_line">
                            <a href="<?=$this->baseUrl()?>/admin/categoryies/add">PŘIDAT KATEGORII</a>
                            <a href="<?=$this->baseUrl()?>/admin/categoryies/sort">USPOŘÁDAT KATEGORIE</a>
                        </div>

		                    <style type="text/css">
						        div.wrap {
						            float: left;
						            width: 90%;
									border:1px solid #BBBBBB;
									padding: 10px;
									margin-bottom: 20px;
								}
								
								.page-list {
									list-style: none;
									margin: 0;
									padding: 0;
									display: block;
								}
								
								.clear-element {
									clear: both;
								}
								
								.page-item1 > div,
								.page-item2 > div,
								.page-item3 > div,
								.page-item4 > div {
									background: #E6E6D2;
									margin: 3px 0 0 0;
									padding: 3px;
									border: 1px dotted #8F8F7D;
									font-size: 90%;
								}
								
								.page-item3 {font-weight: bold;}
						
								.left {text-align: left;}
								.right {text-align: right;}
								.sort-handle {cursor:move;}
								.helper {border: 2px dashed #68B2EF;}
								.current-nesting {background-color: #C2DBEF;}
								.bold {color: red; font-weight: bold;}
						    </style>
		                    
		                    <script type="text/javascript">
		                    
					        	$(document).ready(function(){
   									$('#tree').NestedSortable(
										{
										accept: 'page-item3',
										opacity: 0.8,
										helperclass: 'helper',
										nestingPxSpace: 20,
										currentNestingClass: 'current-nesting',
										fx:200,
										revert: true,
										autoScroll: false,
										onChange: function(serialized) {
											
												handle = serialized[0].o;
												
												handle.each(function() {
												
													
												
												);
												}
											
											
												$.post("<?=$this->baseUrl()?>/admin/categoryies/ajax-sort", { sort: serialized[0].o } );
											}

										}
									);

 								});		                    
		                    </script>
    

							<?php 
								$tree = $this->data->getMenuTree();
								$info = $this->data->getCellInfo();
								
								function recursive($array, $info) {
					            ?>
					            		<span id="tree" class="page-list">
					            		<?php foreach ($array as $k => $v) : ?>
					            			<div id="ele-<?=$k?>" class="clear-element page-item3 sort-handle left">
					                    		<div><?=$info[$k]['name']?></div>
					            			<?php if (count($v)) : ?>
					            				<?php recursive($v, $info); ?>
					            			<?php endif; ?>
					            			</div>
					            		<?php endforeach; ?>
					            		</span>
					            <?php	
					            	}
                        	?>
                        	
                        	<div class="wrap">
					            <?php recursive($tree, $info);?>
					        </div>
					        
                        
                    </div>
    			
    			</div>
			</div>