<?php $__env->startSection('CSS'); ?>
<?php echo HTML::style('WebPro/plugins/bootstrap-fileupload/bootstrap-fileupload.min.css'); ?>

<?php echo HTML::style('WebPro/plugins/dropzone/dropzone.css'); ?>

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


<?php $__env->startSection('Contenido'); ?>
<div class="row">
	<div class="col-md-12">
		<h2><i class="fa fa-video-camera"></i> Video tutoriales </h2>
	</div>
</div>

<div class="row">
	<div class="col-md-12">
		<div class="block-web">
			<div class="header"> <h3 class="content-header"> Agregar recursos descargables </h3> </div>
			<div class="porlets-content">
				<?php echo Form::open(array('route' => array('SysWebVTutorialesModulosVideosRecursosAgregar', $Modulo->id, $Video->id), 'method' => 'post', 'class' => 'form-horizontal row-border', 'id' => 'frmAgregar', 'files' => true, 'target' => 'upload_iframe')); ?>

					<div class="form-group">
						<label class="col-sm-3 control-label"> Título </label>
						<div class="col-sm-9">
							<?php echo Form::text('titulo','',  array('class' => 'form-control', 'placeholder' => '')); ?>

							<span class="text-danger" id="errtitulo"> </span>
						</div>
					</div>
					<div class="form-group">
						<label class="col-sm-3 control-label"> Archivo </label>
						<div class="col-sm-9">
							<?php echo Form::file('ruta', array('class' => '', 'id' => 'ruta')); ?>

							<span class="text-warning" style="display: none;" id="imgruta" class="loading">
								<img src="<?php echo asset('Cargando/hourglass.gif'); ?>" style="width: 32px; height: 32px;"> Espere mientras se carga la imágen
							</span>
							<span class="text-danger" id="errruta"> </span>
						</div>
					</div>
					<div class="bottom">
						<?php echo Form::button('Guardar', array('class' => 'btn btn-primary', 'id' => 'btnAgregar', 'type' => 'submit')); ?>

					</div>
				<?php echo Form::close(); ?>

		</div>
		
	</div>
</div><!--/row end-->
<?php $__env->stopSection(); ?>

<?php $__env->startSection('JS'); ?>
<?php echo HTML::script('WebPro/plugins/ckeditor-new/ckeditor.js'); ?>

<?php echo HTML::script('WebPro/plugins/bootstrap-fileupload/bootstrap-fileupload.min.js'); ?>

<?php echo HTML::script('WebPro/plugins/dropzone/dropzone.min.js'); ?>

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

<?php $__env->startSection('JSOr'); ?>
$("#frmAgregar").submit(function(e){
	e.preventDefault();
	for(instance in CKEDITOR.instances){ CKEDITOR.instances[instance].updateElement(); }
	$("#btnAgregar").prop("disabled", true).html('<i class="fa fa-spinner fa-spin"></i> Cargando');
	var frmAgregar = new FormData(document.getElementById("frmAgregar"));
	if( $("#imagen").val() != "" ){ $("#errruta").html(); $("#imgruta").show(); }
	$.ajax({
		type: "POST",
		url: "<?php echo URL::route('SysWebVTutorialesModulosVideosRecursosAgregar', array($Modulo->id, $Video->id)); ?>",
		data: frmAgregar,
		cache: false,
		contentType: false,
		processData: false,
		dataType: "json",
		success: function(data){
			$("#btnAgregar").prop("disabled", false).html("Guardar");
			$("#imgruta").hide();
			if(data.success){
				new PNotify({ title: "Realizado", text: data.mensaje, type: "success" });
				setTimeout( function(){ window.location.href = "<?php echo URL::route('SysWebVTutorialesModulosVideosRecursos', array($Modulo->id, $Video->id)); ?>"; }, 3000 );
			}
			else{
				if(data.mensaje != ''){ new PNotify({ title: "Error", text: data.mensaje, type: "error" }); }
				$.each(data.errMensajes, function(key, value){ if(value != ''){ $("#err"+key).html(value); } else{ $("#err"+key).html(""); } });
			}
		},
		error: function(jqXHR, textStatus, errorThrown){
			new PNotify({ title: "Error", text: textStatus + " " + errorThrown, type: "error" });
		}
	});
});
<?php $__env->stopSection(); ?>
<?php echo $__env->make('BaseSistemaWeb', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>