
<ol class="breadcrumb">
	<li style="cursor: pointer;" class="breadcrumb-item breadcrumb-folder" data-id=""><?php echo $product_details->slug; ?></li>
	<?php
		foreach ($folder_breadcrumb as $key => $value) {
			$active = '';
			if(COUNT($folder_breadcrumb) == ($key+1)){
				$active = 'active';
			}
	?>
			<li style="cursor: pointer;" class="breadcrumb-item breadcrumb-folder <?php echo $active; ?>" data-id="<?php echo $value->id; ?>"><?php echo $value->folder_name; ?></li>
	<?php
		}
	?>
</ol>
<?php
	if(!empty($documents)){
?>
	<div class="alert alert-success d-none" id="sorting_message" role="alert"></div>
	<div class="d-flex flex-column sortable">

		<?php
			
			foreach ($documents as $key => $item) {
				$countText = "";
				$a = '';
				$b = '';
				$c = '';
				if($item->type == "folder"){
					$a = 'click-folder';
					$b = 'delete-folder';
					$c = 'edit-folder';
				}else{
					$a = 'click-file';
					$b = 'delete-file';
					$c = 'edit-file';

					$item->folder_name = $item->file_name;
				}

				$count_object = array();

				foreach ($count_result as $key1 => $value) {
					if($value->folder_id == $item->id){
						$count_object = $value;
						
					}
				}

				if(isset($count_object->subfolder_count) && $count_object->subfolder_count != 0){
					$countText .= ' Folders: '.$count_object->subfolder_count;
				}

				if(isset($count_object->file_count) && $count_object->file_count != 0){
					$countText .= ' Files: '.$count_object->file_count;
				}

				if(isset($count_object->size_only) && $count_object->size_only != 0){
					$countText .= ' Size: '.$count_object->size;
				}

				$url = base_url().$item->secure_token;

				$icon_url = $this->config->item("admin_assets_folder").'dist/img/'.$item->type.'-icon.webp';

				if($value->type == 'file'){
					$fileExtension = pathinfo($item->folder_name, PATHINFO_EXTENSION);

					if(strtolower($fileExtension) == 'pdf'){
						$icon_url = base_url().'assets/img/icons/pdf.jpg';
					}else if(in_array(strtolower($fileExtension), ['jpg', 'jpeg', 'png', 'gif'])){
						$icon_url = base_url().$item->secure_token;
					}else{
						$icon_url = $this->config->item("admin_assets_folder").'dist/img/'.$item->type.'-icon.webp';
					}
				}

				
	    ?>
	    		<div class='d-flex justify-content-between align-items-center p-2 w-100 <?php echo $item->type; ?>' style='border: 1px solid #ccc;cursor: pointer;' id='<?php echo $item->id; ?>'>
			        <div class='text-left <?php echo $a; ?>' data-id='<?php echo $item->id; ?>'>

			        	<div style="position: relative; display: inline-block;">
				            <img src='<?php echo $icon_url; ?>' class='img-fluid' alt='<?php echo $item->type; ?>' style='width: 30px;'> 
	        				<?php
				            	if($item->has_lock == 1){
				            ?>
				            		<i class="fas fa-lock" style="position: absolute; top: -8px; right: -9px; font-size: 12px;"></i>
				           	<?php
				           		}
				           	?>
				        </div>


			            <span class='ml-2' title="<?php echo $item->folder_name; ?>"><?php echo mb_strimwidth($item->folder_name, 0, 70, "..."); ?></span>
			            
			            <?php
			            	if(isset($countText) && $countText != ""){
			            ?>
			            		<span class='text-muted' style='margin-left: 10px;font-size: 10px;'>(<?php echo trim($countText); ?>)</span>
			            <?php
			            	}
			            ?>
			        </div>
			        <div class='text-muted' style="font-size:10px;">
			            <?php echo $item->created_at; ?>

			           	<button class="btn btn-info btn-sm copyButton" data-url="<?php echo $url; ?>" style="font-size: 10px !important;margin-left: 7px;"><i class="fas fa-copy" style="font-size: 10px;"></i></button>

			            <button type="button" class="btn btn-secondary btn-sm <?php echo $c; ?>" data-folder-name="<?php echo $item->folder_name; ?>" data-has-lock="<?php echo $item->has_lock; ?>" data-id="<?php echo $item->id; ?>" style="font-size: 10px !important;margin-left: 7px;"><i class="fas fa-pencil-alt" style="font-size: 10px;"></i></button>

			            <button type="button" class="btn btn-danger btn-sm <?php echo $b; ?>" data-id="<?php echo $item->id; ?>" style="font-size: 10px !important;margin-left: 7px;"><i class="fas fa-trash-alt" style="font-size: 10px;"></i></button>
			        </div>
			    </div> 
		    <?php
				}
		?>
	</div>

<?php
	}else{
?>
		<div class="d-flex flex-column"><div class='text-center my-3'>No items to display.</div></div>
<?php
	}
?>

