<? global $vis_language;

 ?>

    <section class="wrapper">
	<section class="row">
		<div id="vh-drive">
			  <div id="drive-view" class="drive-object">
		<?
		if($drive_info!=-1)
		{?>
      
                <div class="drive-head animated fadeInUp">
				 <div class="drive-items">
                                 
                        </div>
                        <div class="drive-items">
                                   Item 
                        </div>
                        <div class="drive-items">
                                 Name 
                        </div>
                        <div class="drive-items">
                                 Owner 
                        </div>
                        <div class="drive-items">
                                Size 
                        </div>
                        <div class="drive-items">
                                Creation date
                        </div>
                </div>
               		
<?
for($i=0; $i<count($drive_info); $i++){ $flag=0;
$creation_date=$drive_info[$i]['creation_date']+ VIS_TIMEZONE;
$date=date(VIS_DATE_FORMAT,$creation_date); ?>
<div class="drive-body-items">

		<?php if(VIS_STAFF_ID==$drive_info[$i]['owner']){?>
                     
   <a href="javascript:void(0);" data-toggle="ajaxModal" data-modal-arguments="vis_module=selfhelp&vis_operation=confirm_delete_drive&vis_area=1&vis_drive_id=<? echo $drive_info[$i]['drive_id'];?>&vis_drive_owner=<? echo $drive_info[$i]['owner'];?>" title="Delete" class="drive-delete" id="del_<? echo $drive_info[$i]['drive_id'];?>">
						<i class="vh vh-cross"></i>
						</a>
						<?php }?>
						
               <a data-modal-arguments="vis_module=selfhelp&vis_operation=mydrive_details&vis_domain=<? echo $domainurl; ?>&vis_drive_filename=<? echo urlencode($drive_info[$i]['file_name']);?>&vis_drive_name=<? echo $drive_info[$i]['content'];?>&vis_drive_size=<? echo $drive_info[$i]['file_size']; ?>&vis_drive_type=<? echo $drive_info[$i]['file_type']; ?>&vis_drive_content=<? echo $drive_info[$i]['content']; ?>&vis_drive_owner=<? echo urlencode($drive_info[$i]['owner_name']); ?>&vis_drive_date=<? echo urlencode($date);?>" data-toggle="ajaxModal" href="javascript:void(0);">
                        <div class="drive-info ">
							
                                <div class="drive-item">
                                        <?  if($drive_info[$i]['file_type']=='text/plain') { ?>
      <i class="vh vh-file-text text-muted"></i>
      <?}
      else if($drive_info[$i]['file_type']=='image/jpeg') { ?>
        <img src="<?= VIS_PATH_FILES.$drive_info[$i]['content'];?>" alt="<?= VIS_PATH_FILES.$drive_info[$i]['content'];?>" />
      <?}
      else if($drive_info[$i]['file_type']=='application/vnd.ms-excel') { ?>
       <i class="vh vh-file-spreadsheet vh-file-spreadsheet-color"></i>
      <?}
      else if($drive_info[$i]['file_type']=='image/png') { ?>
        <img src="<?= VIS_PATH_FILES.$drive_info[$i]['content'];?>" alt="<?= VIS_PATH_FILES.$drive_info[$i]['content'];?>" />
       <?} 
       else if($drive_info[$i]['file_type']=='application/pdf') { ?>
      <i class="vh vh-file-pdf vh-file-pdf-color"></i>
       <?}
       else if($drive_info[$i]['file_type']=='application/vnd.openxmlformats-officedocument.wordprocessingml.document') { ?>
      <i class="vh vh-file-word vh-file-word-color"></i>
        <?}
        else if($drive_info[$i]['file_type']=='text/csv') { ?>
      <i class="vh vh-file-spreadsheet vh-file-spreadsheet-color"></i>
        <?} 
        else if($drive_info[$i]['file_type']=='message/rfc822') { ?>
      <i class="vh vh-file-text text-muted"></i>
        <?}
         else if(($drive_info[$i]['file_type']=='application/zip') || ($drive_info[$i]['file_type']=='application/octet-stream')) { ?>
      <i class="vh vh-file-zip vh-file-zip-color"></i>
        <?}
        else if($drive_info[$i]['file_type']=='application/vnd.openxmlformats-officedocument.presentationml.presentation') { ?>
      <i class="vh vh-file-presentation vh-file-presentation-color"></i>
        <?} else
        {?>
			<i class="vh vh-file vh-info"></i>
		<?}
        ?>
                                </div>
                                <div class="drive-item-name">
                                        <small>Name</small>
                                       <?= $drive_info[$i]['file_name']?>
                                </div>
                                <div class="drive-item-owner">
                                        <small>Owner</small>
                                        <?=$drive_info[$i]['owner_name']?>
                                </div>
                                <div class="drive-item-size">
                                        <small>Size</small>
                                       <?= $drive_info[$i]['file_size']?>KiB
                                </div>
                                <div class="drive-item-date">
                                        <small>Creation date</small>
                                        <?= $date?>
                                </div>
                        </div>
                </a>
               
        </div>     
<?}?>

<?
if($drive_details[0]['count']>$view_info['page_count']){?>	
			<div id="load_more_activities" onclick="javascript:mydrive_list_load(<?= $page+1;?>);">
			<div style="text-align: center;">
				<span class="link vis-pointer"><?= $vis_language['TXTLOADMORE'];?></span>
			</div>
			</div><? 
	} 
	

		}
		else
		{
			include(VIS_PATH_TEMPLATE.'no_record_yet.php');
}?>	
<script>
	
		$(document).ready(function(){

	if ( $('#view').hasClass( "btn btn-icon active" )==true )
		
		{
			$('.drive-object').addClass('grid-view list-view');
			
		}
		else
	$('.drive-object').addClass('grid-view');
	
		
	
});
	
	 
    function display_drive()
    {
		if($('#search_drive').val())
		{ var tab=$('#tab').val();  
	      
	      if(tab!=3)
			{
				var drive = $('#search_drive').val();
				if(drive.length < 3)
					$("#vis_global_msg_div").visInterface("load_global_message", "<? echo $vis_language['TXTGLOBALSEARCHERROR'];?>");
				else
					$('#drive-view').visExecution('load_module',drive, {'vis_module':'selfhelp', 'vis_operation':'view_drive', 'vis_action':'no_load','criteria':drive});
			}
			else
			{
				
				var drive = $('#search_drive').val();
				if(drive.length < 4)
				$("#vis_global_msg_div").visInterface("load_global_message", "<? echo $vis_language['TXTGOOGLEDRIVESEARCHERROR'];?>");
				else
				$('#drive-view').visExecution('load_module',drive, {'vis_module':'selfhelp', 'vis_operation':'get_file_list','vis_action':'no_load','criteria':drive});	
				
			}
		}
	}
   
   
	
 function mydrive_list_load(page){
	 <?if(isset($operation['vis_tab']) && $operation['vis_tab']==5){?>
		 var tab=5;
		 <?}else if(isset($operation['vis_tab']) && $operation['vis_tab']==4){?>
		 var tab=4;
		 <?}else{?>
			 var tab=1;
			 <?}?>
	 var drive = $('#search_drive').val();
	
	$.post("index.php?vis_module=selfhelp&vis_operation=view_drive&vis_action=load&vis_tmpst="+new Date().getTime(),{'vis_page': page,'criteria': drive,'vis_tab':tab}, function(data) {
		$("#load_more_activities").last().remove();
		$("#drive-view").last().append(data);
		//$("#load_more_activities").before(data);
	});
}
</script>
 <script>
 $('[data-toggle="ajaxModal"]').hover(function() {
    $(this).prev().addClass('active');
},
function() {
    $(this).prev().removeClass('active');
}
);
 </script>

