<?php namespace App\Http\Controllers;?>
<!DOCTYPE html>
<html>

<head>

    <title>Affiliation/Samuhik Saving and credit coopertaive Society Ltd. </title>
    <?php echo $__env->make('Admin.Parts.MetaCSS', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>
</head>
<?php
$affiliation=session('edit');
?>
<body>

<!--====================================================
                     MAIN NAVBAR
======================================================-->
    <?php echo $__env->make('Admin.Parts.TopHeader', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>

<!--====================================================
                    PAGE CONTENT
======================================================-->
    <div class="page-content d-flex align-items-stretch">

        <!--***** SIDE NAVBAR *****-->
        <?php echo $__env->make('Admin.Parts.LeftNav', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>

        <div class="content-inner form-cont">
            <div class="row">
                <div class="col-md-12">
                    <div class="row">
                        <div class="col-md-6 col-lg-6">
                           <?php if(session('message')): ?>
                        <div class="alert alert-success" role="alert">
                            <?php echo e(session('message')); ?>

                        </div>
        <?php endif; ?>
     
                                         <?php if($errors->any()): ?>
                                           <div class="alert alert-danger" role="alert">
                                            <ul>
                                              <?php $__currentLoopData = $errors->all(); $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $error): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                              <li>
                                                <?php echo e($error); ?>

                                              </li>
                                              <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>

                                            </ul>
                                           </div>
                            
                                           <?php endif; ?> 
                        </div>
                     </div>
                    <div class="card form" id="form1">
                        <div class="card-header">
                            <h3>Affiliation</h3>
                        </div>
                        <br>
                        <?php if(!$affiliation): ?>
                        <form action="admin_affiliation" method="post" enctype="multipart/form-data">
                            <?php else: ?>
                            <form action="<?php echo e(url('admin_affiliation/update',array($affiliation->id))); ?>" method="post" enctype="multipart/form-data">
                            <?php endif; ?>
                            <div class="row">
                                <div class="col-md-12">
                                    <div class="form-group">
                                        <label for="title">Name<i style="color: red">*</i></label>
                                        <input type="text" class="form-control" id="title" placeholder="" name="title" value="<?php if($affiliation) {echo $affiliation->name;}?>" required>
                                        
                                    </div>

                                    <div class="form-group">
                                        <label for="file">Image<i style="color: red">*</i></label>
                                        <input type="file" class="form-control-file" id="" name="image" placeholder="" onchange="readURL(this);" >
                                        <br> 
                                        <br>
                                        <img id="blah" src="#" alt="" height="100px" width="100px" padding="30px" />
                                                <?php if($affiliation): ?>
                                                <img src="img/upload/<?php echo e($affiliation->filename); ?>" height="100px" width="100px" >
                                                <?php endif; ?>
                                    </div>
                                    
                                </div>
                                
                            </div>
                            <input type="hidden" name="_token" value="<?php echo e(csrf_token()); ?>">
                            
                            <button type="reset" class="btn btn-general btn-white">Cancel</button>
                            <button type="submit" class="btn btn-general btn-blue mr-2"><?php if($affiliation){echo "Update";}else {echo "Save";}?></button>
                        </form>
                    </div>

       <div class="card form" id="form1">           
        <div class="row">
          <div class="col-md-12">
            <div class="box">
              <div class="box-header">
                <h3 class="box-title">Data Table</h3>
              </div>
             <!-- /.box-header -->
             <div class="box-body" >
              <table id="example2" class="table table-bordered table-hover">
                <thead>
                  <tr>
                  <th>Name</th>
                  <th >Image</th>
                  <th >Action</th>
                </tr>
                </thead>
                <tbody>
                <?php $__currentLoopData = $save; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $tt): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                <tr class="table-active">
                <td><?php echo e($tt->name); ?></td>
                <td><img src="<?php echo e(url('img/upload/'.$tt->filename)); ?>" style="height: 100px;width: 100px;"></td>
                 <td><a class="btn btn-success"  href="<?php echo e(url('admin_affiliation/edit',array($tt->id))); ?>">Edit</a></td>
                 <td><a class="btn btn-danger"  href="<?php echo e(url('admin_affiliation/delete',array($tt->id))); ?>">Delete</a></td>
                
                </tr>
                </tbody>
               <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
              </table>
            </div>
            <!-- /.box-body -->
            </div>
          </div>
        </div>
    </div>

                  
                
                </div>
            </div>
        </div>
    </div>
<script>
       function readURL(input) {
            if (input.files && input.files[0]) {
                var reader = new FileReader();

                reader.onload = function (e) {
                    $('#blah')
                        .attr('src', e.target.result);
                };

                reader.readAsDataURL(input.files[0]);
            }
        }
</script>
<?php echo $__env->make('Admin.Parts.Js', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>
</body>

</html>
