@extends('layouts.appmin')

@section('tajuk')
Senarai Untuk Dibawa ke Mesyuarat
@endsection


@section('breadcrumb')
    <ul class="breadcrumbs mb-3">
      <li class="nav-home">
        <a href="#">
          <i class="icon-home"></i>
        </a>
      </li>
      <li class="separator">
        <i class="icon-arrow-right"></i>
      </li>
      <li class="nav-item">
        <a href="#">Penjaja</a>
      </li>
      <li class="separator">
        <i class="icon-arrow-right"></i>
      </li>
      <li class="nav-item">
        <a href="#">Untuk Dibawa ke Mesyuarat</a>
      </li>
    </ul>
@endsection

@section('content')                    

    <form action="{{route('pt.cetak-lampiran-b')}}" method="post" id="form_pertama">
        @csrf
        <input type="hidden" name="mesyuarat_id" value="{{$mesyuarat->id}}">
    <div class="row">
        <div class="col-md-12">
            <div class="card">
                <div class="card-header">
                    <h4 class="card-title">Mesyuarat Jawatankuasa Kesihatan dan Pelesenan (Bilangan {{$mesyuarat->bil_mesyuarat}}/{{$mesyuarat?->tahun}})</h4>
                </div>
                <div class="card-body">
                    <div class="row">
                        <div class="col-sm-12 col-md-6">
                            <p>Tarikh : {{$mesyuarat->dt_mesyuarat}}</p>
                            <p>Bilangan Permohonan : {{$mesyuarat->lesen_penjajas->count()}}</p>
                        </div>
                    </div>
                    <!-- Button trigger modal -->
                    <button type="button" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#exampleModal">
                        Tambah Permohonan
                    </button>
                    <input type="submit" id="lampiran_b" class="btn btn-primary" value="Lampiran B">
                    <input type="submit" id="sahkan_senarai" class="btn btn-primary" value="Sahkan Senarai">
                </div>
            </div>
        </div>
    </div>
    </form>
    <div class="row">
        <div class="col-md-12">
            <div class="row">                
                <div class="col-md-12">
                    <div class="card">
                        <div class="card-header">
                            <h4 class="card-title">Akan Dibawa ke Mesyuarat (Bilangan {{$mesyuarat?->bil_mesyuarat}}/{{$mesyuarat?->tahun}})</h4>
                        </div>
                        <div class="card-body">
                            <div class="table-responsive">
                                <table id="senarai2" class="display table table-striped table-hover" >
                                    <thead>
                                        <tr>
                                            <th style="width: 10px">#</th>
                                            <th>Tarikh<br>Arahan</th>
                                            <th>No Fail<br />[No Akaun Permohonan]</th>
                                            <th>Maklumat Perniagaan</th>
                                            <th>By Law<br />Kod Lesen</th>
                                            <th width="300px">Kadar</th>
                                            <th>&nbsp;</th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        <?php $i = 0; ?>
                                        @if(!is_null($mesyuarat?->lesen_penjajas))
                                            @foreach($mesyuarat?->lesen_penjajas as $senarai)
                                            <?php $i++; ?>
                                            <tr class="align-middle text-sm">
                                                <td><?php echo $i; ?></td>
                                                <td>{{$senarai->ulasanPegawai[0]->dt_pengarah_ulas}}</td>
                                                    <td>{{$senarai->no_fail_lesen}}
                                                        <br />[{{$senarai->no_akaun_lesen}}]</td>
                                                <td>{{stripslashes($senarai->user->name)}}<br>
                                                    <small>[{{$senarai->syarikat->name}}]<br />
                                                    ({{$senarai->jenis_penjaja->jenis}})<br />
                                                    {{$senarai->kawasan->nama}}</small></td>
                                                <td>{{$senarai->pivot->by_law}}<br />{{$senarai->pivot->kodlesen}}</td>
                                                <td>
                                                    <div class="row">
                                                        <div class="col-6"><strong>Lesen: </strong><br />RM{{$senarai->pivot->kadar_lesen}}
                                                        </div>
                                                        <div class="col-6"><strong>Sampah: </strong><br />RM{{$senarai->pivot->kadar_sampah}}
                                                        </div>
                                                    </div>
                                                    <div class="row">
                                                        <div class="col-6"><strong>Sewa Petak: </strong><br />RM{{$senarai->pivot->kadar_sewa_petak}}
                                                        </div>
                                                        <div class="col-6"><strong>Patil: </strong><br />RM{{$senarai->pivot->kadar_patil}}
                                                        </div>
                                                    </div>
                                                </td>
                                                <td><a href="{{route('pt.buang-dari-mesyuarat', [$senarai->id, $mesyuarat->id])}}"><i class="fa fa-times" aria-hidden="true"></i></a></td>
                                            </tr>
                                            @endforeach
                                        @endif
                                    </tbody>
                                </table>                      
                            </div>              
                        </div>              
                    </div>                                                  
                </div> <!-- /.col -->    
            </div>
        </div>               
    </div> <!--end::Row-->
<!-- Modal -->
<div class="modal fade" id="exampleModal" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
  <div class="modal-dialog modal-lg">
    <div class="modal-content">
        <form action="{{route('pt.simpan-senarai-bawa-mesyuarat')}}" method="post">
            @csrf
            <input type="hidden" name="mesyuarat_id" value="{{$mesyuarat->id}}">
            <div class="modal-header">
                <h1 class="modal-title fs-5" id="exampleModalLabel">Modal title</h1>
                <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
            </div>
            <div class="modal-body">
                <div class="row">
                    <div class="col-sm-12">
                        <p>Tarikh : {{$mesyuarat->dt_mesyuarat}}</p>
                    </div>
                    <div class="col-sm-12">
                        <div class="form-group">
                            <label for="bylaw">By-Law Lesen</label>
                            <input type="text" class="form-control" name="bylaw" id="bylaw" value="Undang-undang Kecil Penjaja(MBIP)2020">
                        </div>
                    </div>
                    <div class="col-sm-12">
                        <div class="form-group">
                            <label for="kodlesen">Kod Lesen</label>
                            <input type="text" class="form-control" id="kodlesen" name="kodlesen" value="71408">
                        </div>
                    </div>
                </div>
                <div class="row">
                    <div class="col-6">
                        <div class="form-group">
                            <label for="kadar_lesen">Lesen</label>
                            <div class="input-group mb-0">
                                <span class="input-group-text">RM</span>
                                <input
                                type="text" name="kadar_lesen" id="kadar_lesen" 
                                class="form-control"
                                aria-label="Kadar Lesen" value="60.00"
                                />
                            </div>
                        </div>
                    </div>
                    <div class="col-6">
                        <div class="form-group">
                            <label for="kadar_sampah">Sampah</label>
                            <div class="input-group mb-0">
                                <span class="input-group-text">RM</span>
                                <input
                                type="text" id="sampah"  name="kadar_sampah"
                                class="form-control"
                                aria-label="Kadar Sampah" value="60.00"
                                />
                            </div>
                        </div>
                    </div>
                </div>
                <div class="row">
                    <div class="col-6">
                        <div class="form-group">
                            <label for="kadar_sewa_petak">Sewa Petak</label>
                            <div class="input-group mb-0">
                                <span class="input-group-text">RM</span>
                                <input
                                type="text" id="kadar_sewa_petak" name="kadar_sewa_petak"
                                class="form-control"
                                aria-label="Kadar Sewa Petak" value="60.00"
                                />
                            </div>
                        </div>
                    </div>
                    <div class="col-6">
                        <div class="form-group">
                            <label for="kadar_patil">
                                Patil
                            </label>
                            <div class="input-group mb-0">
                                <span class="input-group-text">RM</span>
                                <input
                                type="text" id="kadar_patil" name="kadar_patil"
                                class="form-control"
                                aria-label="Kadar Patil" value="8.50"
                                />
                            </div>
                        </div>
                    </div>
                </div>
                <div class="row">
                    <div class="col-6">
                        <div class="form-group">
                            <label for="patil">
                                Jumlah
                            </label>
                            <div class="input-group mb-0">
                                <span class="input-group-text">RM</span>
                                <input
                                type="text"
                                class="form-control"
                                aria-label="Kadar Lesen" value="188.50"
                                />
                            </div>
                        </div>
                    </div>
                </div>
                <div class="row">
                    
                    <div class="col-md-12">
                        <div class="card">
                            <div class="card-header">
                                <h4 class="card-title">Belum Dibawa ke Mesyuarat</h4>
                            </div>
                            <div class="card-body">
                                <div class="table-responsive">
                                    <table id="senarai3" class="display table table-striped table-hover" >
                                        <thead>
                                            <tr>
                                                <th style="width: 10px">#</th>
                                                <th>Tarikh<br>Mohon</th>
                                                <th>Pemohon<br />Perniagaan</th>
                                                <th>Jenis Penjaja<br>Kawasan</th>
                                                <th>No Fail<br />No Akaun Permohonan</th>
                                            </tr>
                                        </thead>
                                        <tbody>
                                            <?php $i = 0; ?>
                                            @foreach($senarais as $senarai)
                                            <?php $i++; ?>
                                            <tr class="align-middle text-sm table-warning">
                                                <td><input type="checkbox" name="tambah_mesyuarat[]" value="{{$senarai->id}}"></td>
                                                <td>{{$senarai->tarikhmohon}}</td>
                                                <td>{{stripslashes($senarai->user->name)}}<br>
                                                    <small>[{{$senarai->syarikat->name}}]</small></td>
                                                <td>({{$senarai->jenis}})<br />{{$senarai->kawasan->nama}}</td>
                                                    <td>{{$senarai->no_fail_lesen}}
                                                        <br />[{{$senarai->no_akaun_permohonan}}]</td>
                                            </tr>
                                            @endforeach
                                        </tbody>
                                    </table>                      
                                </div>              
                            </div>              
                        </div>                                                  
                    </div> <!-- /.col -->    
                </div>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
                <button type="submit" class="btn btn-primary">Simpan</button>
            </div>
        </form>
    </div>
  </div>
</div>

@endsection
@section('js')
<script>
$(document).ready(function () {
    $('#senarai').DataTable({
        responsive: true
    });

    $('#lampiran_b').click(function(){
        $('#form_pertama').attr('action', '{{route('pt.cetak-lampiran-b')}}');
    });

    $('#sahkan_senarai').click(function(){
        $('#form_pertama').attr('action', '{{route('pt.sahkan-senarai')}}');
    });
});

</script>
@endsection