<?php
echo $this->Html->script(array("jquery.1.7.2.min"));
echo $this->Html->css(array("jquery-ui","cloud"));
echo $this->Html->script(array("jquery-ui.min"));
echo $this->Html->css(array("autoSuggest"));
echo $this->Html->script(array("jquery.autoSuggest"));
echo $this->Html->script(array("jquery.autoSuggest.packed"));
echo $this->Html->script(array("cloud"));

?>
<style>
th:last-child {text-align: right;}
th{border-bottom: 1px solid #ccc;padding-bottom: 10px;}
td{padding: 5px 0;border-bottom: 1px dotted #f0f0f0;}
td:last-child{text-align: right;}
tr:last-child td{border-bottom: 0;}
</style>
<div id="move-modal"></div>
<div class="blocktitle"> Cloud </div>
<div class="tar">
	<a href="#" id="opener" class="btn btn-mini" data-folderid = "<?php echo isset($id) ? $id:0; ?>" >New Folder</a>
    <a href="#" id="move" class="btn btn-mini">Move</a>
    <a href="#" id="delete" class="btn btn-mini">Delete</a>
    <a href="#" id="rename" class="btn btn-mini">Rename</a>
    <a href="#" id="download" class="btn btn-mini">Download</a>
    <!-- <a href="#" id="share" class="btn btn-mini">Share</a> -->
</div>

<div class="w97p pdl10">
	<div style="display:none" id="rename-modal">
      <?php echo $this->Form->create('Cloud',array('action'=>'rename')); ?>
      
            <input type="text" name="filesrename" value=""  class="filesrename">
            <input type="hidden" name="filesid" value=""  class="filesid">
            <input type="hidden" name="parentid" value=""  class="parentid">
            <input type="submit">
     <?php echo $this->Form->end(); ?>
 </div>


<div style="display:none"  id="dialog-share">
<input type="text" name="filesrename" value=""  class="filesrename">
<div class="buttongroup">
    <button class="cancel" type="button">Cancel</button>
    <button data-moveitemid = "" class="move" type="button">share</button>
</div>

 </div>
<div class="breadcrum">

    <?php
   
        if(isset($path_)){
            $count = count($path_);
            $data_ = $this->Cloud->breadcrum($path_);
            $i = 1;
            foreach($data_ as $val_){
               echo $this->Html->link(ucfirst($val_['Cloud']['name']),array('action'=>'folderlist',$val_['Cloud']['id']));

               if($i< $count){
                echo "&nbsp;&raquo&nbsp;";
               }
            $i++;

            }
        }else{
            echo "Foqas";
        }

    ?>

</div>

<hr style="margin-top: 5px;">
<div style="clear:both;"></div>
	<div class="clouds form">
		<?php echo $this->Form->create('Cloud',array('type'=>'file', 'id'=>'formSub','action'=>'add')); ?>
			<div style="margin-bottom: 10px;" class="borb pdb3">
		      	<div class="row-fluid" style="text-align: right;">
		      		<div class="span4 offset6" style="padding-left: 40px;">
						<?php echo $this->Form->input('name',array('type'=>'file','label'=>false));?>
						 <?php echo $this->Form->hidden('rootid',array('type'=>'text','label'=>false,'value'=>$id));?>
		      		</div>
		      		<div class="span2"><input type="submit" name="submit" value="Upload"></div>
		      	</div>
		          <!--<div class="formsubmit" style="margin-top: 5px;" ></div> -->
			</div>
		<div style="margin-top: 0;" id= "folder">
		  <div id='openfolder'></div>
		  <div id="LoadingImage" style="display: none">
		   <?php echo  $this->Html->image('spinner.gif'); ?>
		</div>
		
		<table width="100%" style="text-align: left;">
		 <tr>
		     <th>Name</th>
		     <th>Kind</th>
		     <th>Modified</th>
		 </tr>
		<?php 
		foreach($data as $val):
			$cloud_name = $val['Cloud']['name'];
			if(strlen($cloud_name)>30){
				$cloud_name = trim(substr($val['Cloud']['name'],0,30)).'...';
			}
			?>
            <tr class="selectableColor" data-itemsid= '<?php echo $val['Cloud']['id'] ;?>' data-parentid= '<?php echo $val['Cloud']['parent_id'] ;?>' data-id='<?php echo $val['Cloud']['path'] ;?>' data-name='<?php echo $val['Cloud']['name'] ;?>'>
              <?php 
              if($val['Cloud']['createtype'] == 'directory'):
              	?>
              	<td class="folderOpen"  style="cursor: pointer;" ><?php echo $this->Html->link($this->Html->image('folder_open.png',array('width'=>20,'alt'=> $val['Cloud']['id'],'style'=>'padding-right:10px;')).$cloud_name,array('controller'=> 'clouds','action'=>'folderlist',$val['Cloud']['id']),array('escape'=>false));?></td>
              	<?php 
              else: 
              	?>
             	<td class="folderOpen" style="width: 65%"><?php echo $this->Html->image('file.png',array('width'=>20,'alt'=> $val['Cloud']['id'],'style'=>'padding-right:10px;')).$cloud_name;?></td>
              	<?php 
              endif; 
              ?>
              <td><?php echo $val['Cloud']['createtype']; ?></td>
            <td id='app_<?php echo $val['Cloud']['id']?>'><?php echo $val['Cloud']['modified']; ?></td>
       		</tr>
		<?php endforeach; ?>
		
		 </table>
		
		</div>
		<?php echo $this->Form->end(); ?>
	</div>
</div>