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

<head>

    <title>Vacancy | Admin | Samuhik Saving & Co-Operative Society Ltd. </title>
    @include('Admin.Parts.MetaCSS')
</head>

<body>

<!--====================================================
                     MAIN NAVBAR
======================================================-->
    @include('Admin.Parts.TopHeader')

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

        <!--***** SIDE NAVBAR *****-->
        @include('Admin.Parts.LeftNav')

        <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">
                           @if (session('info'))
                           <div class="alert alert-success" style="text-transform: capitalize;">
                              {{session('info')}}
                           </div>
                           @endif
                           @php
                               $vacancy=session('avisd');
                           @endphp
                           @if ($errors->any())
                           <div class="alert alert-danger">
                              <ul>
                                 @foreach ($errors->all() as $error)
                                 <li>{{ $error }}</li>
                                 @endforeach
                              </ul>
                           </div>
                           @endif
                        </div>
                     </div>
                    <div class="card form" id="form1">
                        <div class="card-header">
                            <h3>Add Vacancy</h3>
                        </div>
                        <br>
                        @if(!$vacancy)
                        <form action="admin_vacancy" method="post" enctype="multipart/form-data">
                            @else
                            <form action="{{url('admin_vacancy/update',array($vacancy->id))}}" method="post" enctype="multipart/form-data">
                            @endif
                            <div class="row">
                                <div class="col-md-12">
                                    <div class="form-group">
                                        <label for="title">Title<i style="color: red">*</i></label>
                                        <input type="text" class="form-control" id="title" placeholder="Enter Title" name="title" value="<?php if($vacancy) {echo $vacancy->title;}?>" required>
                                        
                                    </div>
                                    
                                    <div class="form-group">
                                        <label for="date">Published Date<i style="color: red">*</i></label>
                                        <input type="date" class="form-control" id="date"  name="pdate" value="<?php if($vacancy) {echo $vacancy->published_date;}?>" required>
                                        
                                    </div>

                                    <div class="form-group">
                                        <label for="date">Deadline<i style="color: red">*</i></label>
                                        <input type="date" class="form-control" id="date"  name="ddate" value="<?php if($vacancy) {echo $vacancy->deadline;}?>" required>
                                        
                                    </div>


                                  <div class="form-group">
                                        <label for="exampleInputFile">File<i style="color: red">*</i> <i style="margin-left: 20px; font-size: 10px;">single file</i></label>
                                        @if(!$vacancy)
                                        <input type="file" class="form-control-file" id="exampleInputFile" name="file" accept=
"application/msword, application/vnd.ms-excel, application/vnd.ms-powerpoint,
text/plain, application/pdf" required>
                                        @else
                                        <input type="file" class="form-control-file" id="exampleInputFile" name="file" accept=
"application/msword, application/vnd.ms-excel, application/vnd.ms-powerpoint,
text/plain, application/pdf" >
                                        <br>
                                        <div class="form-group">
                                          <p>{{ $vacancy->file_name }}</p>
                                            
                                        </div>
                                        @endif
                                       
                                    </div>

                                    <div class="form-group">
                                        <label for="exampleTextarea">Description<i style="color: red">*</i></label>
                                        <textarea class="form-control ckeditor" id="exampleTextarea" rows="3" name="description"><?php if($vacancy) {echo $vacancy->description;}?></textarea>
                                    </div>
                                   
                                    
                                </div>
                                
                            </div>
                            <input type="hidden" name="_token" value="{{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($vacancy){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 width="2%">SN</th>
                
                  <th width="15%">Title</th>
                  <th width="15%">Published Date</th>
                  <th width="15%">Deadline</th>
                  <th width="15%">File Name</th>
                  <th width="22%">Description</th>
                
                  
                  <th width="15%">Action</th>
                </tr>
                </thead>
                <tbody>
     
                  <tbody>
                  
                    <?php
                    echo AdminlogController::table_generator('vacancies',array('title','published_date','deadline','file_name','description'), 'admin_vacancy','Vacancy');?>
  
           
                </tbody>
               
              </table>
            </div>
            <!-- /.box-body -->
            </div>
          </div>
        </div>
    </div>

                  
                
                </div>
            </div>
        </div>
    </div>

@include('Admin.Parts.Js')
</body>

</html>
