<?php $__env->startSection('css'); ?>
<?php echo HTML::style('//cdn.datatables.net/1.10.11/css/jquery.dataTables.min.css'); ?>

<?php echo HTML::style('css/back/panel.css'); ?>

<?php echo HTML::style('css/back/dataTable.css'); ?>

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

<?php $__env->startSection('body'); ?>
<?php echo HTML::script('js/back/custom.js'); ?>

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

<?php $__env->startSection('content'); ?>
<h3>Editar Proyecto: <span style="color: #0069ad"><?php echo e($proj->getTitle()); ?></span></h3>
<hr>
<div class="col-md-12">
   <h4>Datos Nuevos</h4>
   <?php echo Form::open(array('route'=>'panel/social/project/editPost', 'method'=>'POST', 'files'=>true)); ?>

   <div class="row">
      <?php echo Form::hidden('id', $proj->getId()); ?>

      <div class="col-md-4">
         <div class="form-group">
            <?php echo Form::label('year', 'Año', ['class' => 'control-label'] ); ?>

            <?php echo Form::number('year', $proj->getYear(), ['class' => 'form-control']); ?>

         </div>
      </div>
      <div class="col-md-4">
         <div class="form-group">
            <?php echo Form::label('category', 'Categoría', ['class' => 'control-label'] ); ?>

            <?php echo Form::select('category', $catList ,$proj->getIdProjectCategory()->getId(), ['class' => 'form-control', 'placeholder' => 'Seleccione una...'] ); ?>

            <?php echo Form::hidden('active', $proj->getActive()); ?>

         </div>
      </div>
      <div class="col-md-4">
         <div class="form-group">
            <label class="control-label" for="active">Visibilidad en la web</label>
            <br>
            <div class="btn-group" data-toggle="buttons">
               <?php if( $proj->getActive() ): ?>
               <label class="btn btn-primary active">
                  <input type="radio" name="active" id="option1" autocomplete="off" checked value="1"> Activo
               </label>
               <label class="btn btn-primary">
                  <input type="radio" name="active" id="option2" autocomplete="off" value="0"> Inactivo
               </label>
               <?php else: ?>
               <label class="btn btn-primary">
                  <input type="radio" name="active" id="option1" autocomplete="off"  value="1"> Activo
               </label>
               <label class="btn btn-primary active">
                  <input type="radio" name="active" id="option2" autocomplete="off" checked value="0"> Inactivo
               </label>
               <?php endif; ?>
            </div>
            <span data-toggle="tooltip" data-placement="top" title="Active su proyecto aquí.">
               <i class="fa fa-question-circle" style="font-size: 20px; vertical-align: middle;"></i>
            </span>
            
         </div>
      </div>
   </div>
   <div class="form-group">
      <?php echo Form::label('title', 'Nombre', ['class' => 'control-label'] ); ?>

      <?php echo Form::text('title', $proj->getTitle(), ['class' => 'form-control']); ?>

   </div>
   <div class="form-group">
      <?php echo Form::label('alias', 'Alias', ['class' => 'control-label'] ); ?>

      <?php echo Form::text('alias', $proj->getAlias(), ['class' => 'form-control','readonly']); ?>

   </div>
   <br>
   <div class="form-group">
      <?php echo Form::label('description', 'Descripción', ['class' => 'control-label'] ); ?>

      <?php echo Form::textarea('description', $proj->getDescription(), ['class' => 'form-control ckeditor'] ); ?>

   </div>
   <hr>
   <div class="form-group">

      <div class="row">
         <div class="col-md-6">
            <?php echo Form::label('fundersTable', 'Búsqueda de Financiadores', ['class' => 'control-label'] ); ?>

            <table class="table hover order-column compact" id="fundersTable">
               <thead>
                  <tr>
                     <td>
                        Seleccione
                     </td>
                     <td>
                        Nombre
                     </td>
                     <td>
                        Imagen
                     </td>
                  </tr>
               </thead>
               <tbody>
                  <?php foreach($funderList as $funder): ?>
                  <tr>
                     <td>
                        <?php if( $funderCheckedIdCollection->has($funder->getId()) ): ?>
                        <?php echo Form::checkbox('funders[]', $funder->getId(), true ,['class' => 'checkFunder']); ?>

                        <?php else: ?>
                        <?php echo Form::checkbox('funders[]', $funder->getId(), false ,['class' => 'checkFunder']); ?>

                        <?php endif; ?>
                     </td>
                     <td>
                        <?php echo e($funder->getName()); ?>

                     </td>
                     <td>
                        <?php if( $funder->getImage() ): ?>
                        <img class="image-for-viewer" title="Click para ver imagen a tamaño original" data-toggle="tooltip" data-placement="top" style="max-height: 25px;" class="img-responsive" src="<?php echo e(asset($funder->getImage())); ?>">
                        <?php else: ?>
                        Sin foto
                        <?php endif; ?>
                     </td>
                  </tr>
                  <?php endforeach; ?>
               </tbody>
            </table>
         </div>
         <div class="col-md-6">
            <?php echo Form::label('locationsTable', 'Búsqueda de Financiadores', ['class' => 'control-label'] ); ?>

            <table class="table hover order-column compact" id="locationsTable">
               <thead>
                  <tr>
                     <td>
                        Seleccione
                     </td>
                     <td>
                        Nombre
                     </td>
                     <td>
                        Imagen
                     </td>
                  </tr>
               </thead>
               <tbody>
                  <?php foreach($locList as $loc): ?>
                  <tr>
                     <td>
                        <?php if( $locationCheckedIdCollection->has($loc->getId()) ): ?>
                        <?php echo Form::checkbox('locations[]', $loc->getId(), true ,['class' => 'checkLocation']); ?>

                        <?php else: ?>
                        <?php echo Form::checkbox('locations[]', $loc->getId(), false ,['class' => 'checkLocation']); ?>

                        <?php endif; ?>
                     </td>
                     <td>
                        <?php echo e($loc->getName()); ?>

                     </td>
                     <td>
                        <?php if( $loc->getImage() ): ?>
                        <img class="image-for-viewer" title="Click para ver imagen a tamaño original" data-toggle="tooltip" data-placement="top" style="max-height: 25px;" class="img-responsive" src="<?php echo e(asset($loc->getImage())); ?>">
                        <?php else: ?>
                        Sin foto
                        <?php endif; ?>
                     </td>
                  </tr>
                  <?php endforeach; ?>
               </tbody>
            </table>
         </div>
      </div>
   </div>
   <hr>
   <div class="form-group">
      <div class="row">
         <div class="col-md-6">
            <?php echo Form::label('fundersSelected', 'Financiadores seleccionados', ['class' => 'control-label'] ); ?>

            <div id="fundersSelected"></div>
         </div>
         <div class="col-md-6">
            <?php echo Form::label('locationsSelected', 'Lugares seleccionados', ['class' => 'control-label'] ); ?>

            <div id="locationsSelected"></div>
         </div>
      </div>
   </div>
   <hr>
   <div class="row">
      <div class="col-md-6">
         <div class="form-group">
            <?php echo Form::label('overallObjective', 'Objectivo General', ['class' => 'control-label'] ); ?>

            <?php echo Form::textarea('overallObjective', $proj->getOverallObjective(), ['class' => 'form-control ckeditor'] ); ?>

         </div>
      </div>
      <div class="col-md-6">
         <div class="form-group">
            <?php echo Form::label('specificObjective', 'Objectivo Específico', ['class' => 'control-label'] ); ?>

            <?php echo Form::textarea('specificObjective', $proj->getSpecificObjective(), ['class' => 'form-control ckeditor'] ); ?>

         </div>
      </div>
   </div>
   <hr>
   <div class="form-group">
      <?php echo Form::label('result', 'Resultados', ['class' => 'control-label'] ); ?>

      <?php echo Form::textarea('result', $proj->getResult(), ['class' => 'form-control ckeditor'] ); ?>

   </div>
   <?php echo Form::submit('Guardar',['class' => 'btn btn-default']); ?>

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

</div>
<?php $__env->stopSection(); ?>
<?php $__env->startSection('scripts'); ?>
<?php echo Minify::javascript('/js/back/form.js')->withFullUrl(); ?>

<style>
   .dataTables_filter{
      float: left !important;
   }
</style>
<script src="//cdn.ckeditor.com/4.5.7/basic/ckeditor.js"></script>
<?php echo HTML::script('//cdn.datatables.net/1.10.11/js/jquery.dataTables.min.js'); ?>

<script>

function fillFieldsFromDataTables() {
   var text = printTableChecked(funderTable);
   $("#fundersSelected").html(text);
   var text = printTableChecked(locationTable);
   $("#locationsSelected").html(text);
}

function printTableChecked(table) {
   text = "";
   $("input:checked", table.fnGetNodes()).each(function () {
      text += '<i class="fa fa-check"></i> ' + $.trim($(this).parent().siblings(0).html()) + ' <br> ';
   });
   return text;
}

$("form input:checkbox").click(function () {
   if ($(this).hasClass('checkFunder')) {
      var text = printTableChecked(funderTable);
      $("#fundersSelected").html(text);
   }
   if ($(this).hasClass('checkLocation')) {
      var text = printTableChecked(locationTable);
      $("#locationsSelected").html(text);
   }
   return null;
});

$(document).ready(function () {
   funderTable = $('#fundersTable').dataTable({
      "scrollY": "200px",
      "scrollCollapse": true,
      "paging": false,
      "bFilter": false,
      "language": {
         "url": "//cdn.datatables.net/plug-ins/1.10.9/i18n/Spanish.json",
         "searchPlaceholder": "Financiadores..."
      },
      "columns": [
         {"width": "1%", "bSortable": false},
         {"bSortable": false},
         {"bSortable": false}
      ]
   });
   locationTable = $('#locationsTable').dataTable({
      "scrollY": "200px",
      "scrollCollapse": true,
      "paging": false,
      "bFilter": false,
      "language": {
         "url": "//cdn.datatables.net/plug-ins/1.10.9/i18n/Spanish.json",
         "searchPlaceholder": "Lugares..."
      },
      "columns": [
         {"width": "1%", "bSortable": false},
         {"bSortable": false},
         {"bSortable": false}
      ]
   });
   fillFieldsFromDataTables();
});
</script>
<?php $__env->stopSection(); ?>
<?php echo $__env->make('layouts.backBase', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>