@extends('layouts.adminapp')

@section('content')

{{-- Promotion Packages --}}

<div class="card mb-4">
    <div class="card-header">
        <div class="d-flex">
            <div class="mr-auto p-2 align-self-center"><h4>Promotion Packages</h4></div>
            <div class="p-2">              
            <a class="btn btn-primary" href="{{route('PromotionPackage.create')}}"><i class="fa fa-plus"></i> ADD New</a>
            </div>           
        </div>
    </div>
    <div class="card-body">
        <div class="table-responsive">
            <table class="table">
                <thead>
                    <tr>
                        <!--th>SLNO.</th-->
                        <th>Product</th>
                        <th>Service</th> 
                        <th>Qty</th>   
                        <th>Discount Percentage</th>
                        <th>Narration</th>                
                        <th colspan="">Actions</th>
                    </tr>
                </thead>
                <tbody>
                    @foreach($PromotionPackages as $PromotionPackage)
                    <tr>
                        <td>{{$PromotionPackage->product->title}}</td>
                        <td>{{$PromotionPackage->servicetype->title}}</td>
                        <td>{{$PromotionPackage->qty}}</td>
                        <td>{{$PromotionPackage->discount}}</td>
                        <td>{{$PromotionPackage->narration}}</td>                    
                       
                        <td><a href="{{route('PromotionPackage.edit',$PromotionPackage->id)}}" class="btn btn-secondary"><i class="fa fa-edit"></i> Edit</a></td>   
                        <td><form method="POST" action="{{route('PromotionPackage.destroy',$PromotionPackage->id)}}" Id="form-delete-{{$PromotionPackage->id}}">
                            @csrf
                            @method('delete')
                            <button type="button" class="btn btn-danger"  onclick="
                            event.preventDefault();
                            if(confirm('Are you sure delete this'))
                            {
                                document.getElementById('form-delete-{{$PromotionPackage->id}}').submit();
                            }"><i class="fas fa-trash"></i> Delete</button></form>
                        </td>                     
                    </tr>
                    @endforeach
                </tbody>
            </table>
        </div>
    </div>
    <div class="card-footer">
        <div class="d-flex justify-content-end font-weight-bold"><h5>Total:  {{$PromotionPackages->Count()}}</h5></div>        
    </div>
</div>

@endsection
