

<?php $__env->startSection('page-title', 'Multimedia'); ?>

<?php $__env->startSection('content'); ?>
	<section class="page-header">
		<div class="page-header__bg" style="background-image: url(<?php echo e(asset('assets/images/header.jpg')); ?>);"></div>
		<div class="container">
			<h2><?php echo e($category); ?> </h2>
			<ul class="thm-breadcrumb list-unstyled">
				<li class="text-white"><a href="<?php echo e(url('/')); ?>">Inicio</a></li>
			</ul>
		</div>
	</section>

<?php if(Auth::user()): ?>
	<div class="row">
		<div class="container py-2">
			<div class="col text-right">
				<a href="<?php echo e(route('multimedia.create')); ?>" class="thm-btn">
				<i class="fas fa-plus"></i>  
				Registrar Multimedia
				</a>
			</div>
		</div>
	</div>
<?php endif; ?>


<div class="blog-page">
  <div class="container">
    <div class="row">
	<?php if(count($multimedia)): ?>
		<?php foreach($multimedia as $resource): ?>               
				

		<div class="col-sm-12 col-md-6 col-lg-4 <?php echo e($resource->status ?: 'despublicado'); ?>">
			<div class="blog-card">
				<div class="blog-card__image">
				<div class="blog-card__date"><?php echo e(date('d M', strtotime($resource->publish_up))); ?></div><!-- /.blog-card__date -->
				<?php 
					$sep = explode(' ', $resource->embed);
					$width = explode('"',$sep[1]); 
					echo str_replace($sep[1], 'width="100%"', $resource->embed);
				?>
				</div>
				<div class="blog-card__content">
				<div class="blog-card__meta">
				</div>
				<h3>
					<a href="#">
						<?php echo e(str_limit($resource->title, $limit = 50, $end = '...')); ?>

					</a>
				</h3> 
				<p>
					<?php echo $resource->description; ?>

				</p>
				</div>

				<?php if(Auth::user()): ?>
					<div class="card-action teal darken-1">
				
						<div class="">
							<a onclick="trash('<?php echo e($resource->id); ?>','<?php echo e($resource->title); ?>')" class="pull-right btn-floating waves-effect waves-light btn-small red">
								<i class="fa fa-trash" aria-hidden="true"></i>
							</a>
							<a href="<?php echo e(route('multimedia.edit',$resource->id)); ?>" class="pull-right btn-floating waves-effect waves-light btn-small blue">
								<i class="fa fa-edit" aria-hidden="true"></i>
							</a>   
						<?php if($resource->status): ?>
							<a onclick="statusChange('<?php echo e($resource->id); ?>','<?php echo e($resource->status); ?>','<?php echo e($resource->title); ?>')" class="pull-right btn-floating waves-effect waves-light btn-small green tooltipped" data-position="bottom" data-delay="50" data-tooltip="Este registro está PUBLICADO">
								<i class="fa fa-eye" aria-hidden="true"></i>
							</a>   	
						<?php else: ?> 
							<a onclick="statusChange('<?php echo e($resource->id); ?>','<?php echo e($resource->status); ?>','<?php echo e($resource->title); ?>')" class="pull-right btn-floating waves-effect waves-light btn-small green tooltipped" data-position="bottom" data-delay="50" data-tooltip="Este registro está DESPUBLICADO">
								<i class="fa fa-eye-slash" aria-hidden="true"></i>
							</a>   	
						<?php endif; ?>  				           
						</div>
					</div>
				<?php endif; ?>	

			</div>
		</div>

		<?php endforeach; ?>
	<?php else: ?>
		<?php echo $__env->make('partials.noData', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>
	<?php endif; ?>
	    
    </div>
  </div>
</div>


	<?php  $paginates=$multimedia;  ?>
	<div class="container list-unstyled d-flex justify-content-center py-4">
		<?php echo e($paginates->links()); ?>

	</div>

<?php $__env->stopSection(); ?>
<?php $__env->startSection('scripts'); ?>

<script>
function trash(id,title){ 
    var ident = id;
    swal({
     text: 'Esta seguro de realizar esta Acción?',
     title: 'Si procede <span class="btn btn-danger">'+title+'</span> será eliminado!',
     type: 'warning',
     showCancelButton: true,
     confirmButtonColor: '#DD6B55',
     confirmButtonText: 'Eliminar!',
     cancelButtonText: 'Cancelar', 
     closeOnConfirm: false,
     closeOnCancel: false,
     html: true

   },
   function(isConfirm){
       if (isConfirm) { 
       //	console.log(id+'-'+title)
           $.ajax({
               url: '<?php echo e(url('/multimedia/delete')); ?>' + '/' + id, 
               type: "GET",  
               dataType: "JSON", 
               headers: {
                'X-CSRF-TOKEN': $('meta[title="token"]').attr('content')
            },
            success: function (res) {
                console.log(res);
            },
            error: function(res){
                console.log("Error :" + res );
            }
               }); 
               swal(title+' eliminado!', 'Este registro fue eliminado.', 'success');
               window.location.reload(true);

       }else {
           swal('Cancelado!', 'Este registro NO fue eliminado.', 'error');
       }
   });
}
</script>
<script>
function statusChange(id,status,title){
   $.ajax({
       url: '<?php echo e(url('/multimedia/statusChange')); ?>' + '/' + id + '/' + status,
       type: 'GET', 
       headers: {
           'X-CSRF-TOKEN': $('meta[title="token"]').attr('content')
       },
       dataType: "JSON",
       success: function (res) {
           console.log(res);
            if(res.now){
                swal(title+', modificado!', 'este registro está publicado.', 'success');
                window.location.reload(true);
            }else{
                swal(title+', modificado!', 'este registro está despublicado.', 'warning');
                window.location.reload(true);
            }
       },
       error: function(res){
           console.log("Error :" + res );
       }
   }); 
}
</script>

<?php $__env->stopSection(); ?>

<?php echo $__env->make('layouts.web', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>