<!doctype html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
<head>
		<!-- Required meta tags -->
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">

		<!-- Title -->
		<title>Welcome ~ CeqaFoods and Beverages Limited</title>

		<!-- Date Range CSS -->
		<link rel="stylesheet" href="{{asset('vendor/daterange/daterange.css')}}">

		
		<!-- Uploader CSS -->
		<link rel="stylesheet" href="{{asset('vendor/dropzone/dropzone.min.css')}}" />

		<!-- *************
			************ Common Css Files *************
		************ -->
		<!-- Bootstrap css -->
		<link rel="stylesheet" href="{{asset('css/bootstrap.min.css')}}">
		
		<!-- Icomoon Font Icons css -->
		<link rel="stylesheet" href="{{asset('fonts/style.css')}}">

		<!-- Main css -->
		<link rel="stylesheet" href="{{asset('css/main.css')}}">

		<!-- fontAwesome -->
		<link href="{{asset('fontawesome/css/all.css')}}" rel="stylesheet">
        <!-- <meta http-equiv="refresh" content="5"> -->


		<!-- Data Tables -->
		<link rel="stylesheet" href="{{asset('vendor/datatables/dataTables.bs4.css')}}" />
		<link rel="stylesheet" href="{{asset('vendor/datatables/dataTables.bs4-custom.css')}}" />
		<link href="{{asset('vendor/datatables/buttons.bs.css')}}" rel="stylesheet" />

		
		<script src="{{asset('js/ajax.min.js')}}"></script>

		<!-- *************
			************ Vendor Css Files *************
		************ -->
		<!-- Bootstrap Select CSS -->
		<link rel="stylesheet" href="{{asset('vendor/bs-select/bs-select.css')}}" />
		<!-- Mega Menu -->
		<link rel="stylesheet" href="{{asset('vendor/megamenu/css/megamenu.css')}}">
		<!-- Search Filter JS -->
		<link rel="stylesheet" href="{{asset('vendor/search-filter/search-filter.css')}}">
		<link rel="stylesheet" href="{{asset('vendor/search-filter/custom-search-filter.css')}}">
        		<!-- Sweet Alert-->
		<link href="{{asset('vendor/libs/sweetalert2/sweetalert2.min.css')}} " rel="stylesheet" type="text/css" />

	</head>
	<body>

    <style>
        body{
            background-color: #cbd4fe;
        }

    </style>



<!-- Row start -->
<div style="width:100%" id="main">

    <!-- Breadcrumb container start -->
    <div class="breadcrumb-container" style="background-color:#ffffff;">
    <img src="/img/{{$app->app_logo}}" alt="Logo" style="max-height:45px">
    <span>
    <a href="{{route('dispatch-display')}}" class="btn btn-outline-primary"><i class="icon-shopping-cart1"></i> Delivery Orders ({{$deliveryOrders}})</a>
    <a href="{{route('OnlinePNP')}}" class="btn btn-outline-primary"><i class="icon-shopping-cart1"></i> E-shop Orders ({{$pendingCount->count()}})</a>
    <a href="/" class="btn btn-outline-primary"><i class="icon-arrow_back"></i> Back</a>
    </span>

    <span style="float:right; padding:10px" class="text-primary">
        AGENCY ORDERS | {{auth()->user()->branch}} [{{auth()->user()->name}}]
    </span>

    </div>
    <!-- Breadcrumb container end -->

        <div class="col-xl-12 col-lg-12 col-md-12 col-sm-12 col-12">
            <!-- Card start -->
            <div>
                <div class="card-body">

                <!-- Row start -->
                <div class="row gutters">
                    @foreach($pending_orders as $item)
                    <div class="col-xl-4 col-lg-4 col-md-6 col-sm-6 col-12">
                        <figure class="user-card"  style="box-shadow: 2px 2px 2px 1px rgba(0, 0, 0, 0.2);">
                            <b>{{Str::of($item->customer_fname . " " . $item->customer_lname)->upper()}}</b><br>
                            {{@strtoupper($item->delivery_location)}}<br>
                            {{$item->customer_phone}}<br>
                            <br>
                            <figcaption>
                            <div style="width:100%; background-color:#cbd4fe; padding:12px">
                            <span>#{{$item->invoice_number}}
                                <br><span class="badge bg-info">
                                    <?=  \Carbon\Carbon::parse($item->created_at)->diffForHumans() ?>
                                </span>
                            </span>
                            </div>
                            </figcaption>
                            <span>
                                <span class="badge bg-success">
                                    <?php $agency = \DB::table('agencies')->where('agency_code', $item->agency)->first();
                                        echo $agency->agency_name;
                                    ?>
                                </span>
                            </span>

                            {!! empty($item->comment) ? "" : '<hr>'."COMMENT: ".$item->comment !!}

                            <div style="margin-top:10px">
                            <a href="#" id="{{$item ->invoice_number}}" onclick="AcceptOrder(this.id)" class="btn btn-outline-info btn-sm"><i class="icon-check2"></i> Accept</a>
                            
                            <a href="#" class="btn btn-outline-info btn-sm">
                            <?=  count(json_decode($item->agency_orders)) ?> Items
                            </a>
                            <a href="#" id="{{$item ->invoice_number}}" onclick="invoiceNumber(this.id)" class="btn btn-primary btn-sm"> <i class="icon-cancel"></i>Cancel</a>
                            </div>
                        </figure>
                    </div>
                    @endforeach        
        </div>
    </div>
    <!-- Row end -->




<!-- Sweet Alerts js -->
<script src="{{asset('vendor/libs/sweetalert2/sweetalert2.min.js')}}"></script>
    <script>
        function invoiceNumber(id) {
            Swal.fire({
                title: 'Are you sure?',
                text: "Do you want to Decline this order",
                icon: 'warning',
                showCancelButton: true,
                confirmButtonColor: '#3085d6',
                cancelButtonColor: '#d33',
                confirmButtonText: 'Yes, Decline Order!'
                }).then((result) => {
                if (result.isConfirmed) {
                    window.location.href = "/ceqa-dashboard-online-orders/preview-order/cancel/" + id
                    Swal.fire(
                    'Order Cancelled Successfully',
                    'The Order will clear from the Screen',
                    'success'
                    )
                }
                })
        }




        function AcceptOrder(id) {
            Swal.fire({
                title: 'Are you sure?',
                text: "Do you want to Preview this order",
                icon: 'warning',
                showCancelButton: true,
                confirmButtonColor: '#3085d6',
                cancelButtonColor: '#d33',
                confirmButtonText: 'Yes, Preview Order!'
                }).then((result) => {
                if (result.isConfirmed) {
                    window.location.href = "/ceqa-dashboard-online-orders/preview-order/agency-order/" + id
                    Swal.fire(
                    'Order Loading, Please wait',
                    'Order will show soon',
                    'success'
                    )
                }
                })
        }
    </script>


@include('inc.check-internet')



    		<!-- *************
			************ Required JavaScript Files *************
		************* -->
		<!-- Required jQuery first, then Bootstrap Bundle JS -->
		<script src="{{asset('js/jquery.min.js')}}"></script>
		<script src="{{asset('js/bootstrap.bundle.min.js')}}"></script>
		<script src="{{asset('js/modernizr.js')}}"></script>
		<script src="{{asset('js/moment.js')}}"></script>

		<!-- *************
			************ Vendor Js Files *************
		************* -->
		
		<!-- Main Js Required -->
		<script src="{{asset('js/main.js')}}"></script>

	</body>

</html>