Spamworldpro Mini Shell
Spamworldpro


Server : Apache
System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64
User : corals ( 1002)
PHP Version : 7.4.33
Disable Function : exec,passthru,shell_exec,system
Directory :  /home/corals/mcoil.corals.io/resources/views/admin/orders/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/corals/mcoil.corals.io/resources/views/admin/orders/show.blade.php
@extends('layouts.admin.app')
@section('css')
<link href="{{ asset('css/sweetalert2.min.css') }}" rel="stylesheet" type="text/css" />
<link href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.3.0/css/datepicker.css" rel="stylesheet" type="text/css" />
@endsection
@section('content')
<div class="row">
    <div class="col-md-12">
        <section class="content">
        @include('layouts.errors-and-messages')
            <div class="box">
                <div class="box-body">
                    <div class="col-md-12">
                        <h3 class="bold">Customers Details</h3>    
                        <div class="jumbotron">
                            <div class="row">
                                <div class="col-md-4 col-xs-12 col-sm-6 col-lg-4">
                                    <div class="col-md-12 initialsadded">
                                        <div class="kt-widget__media">
                                            <span class="kt-badge kt-badge--username kt-badge--unified-success kt-badge--lg kt-badge--rounded kt-badge--bold">@if(!empty($customer->fname)){{ strtoupper($customer->fname[0].$customer->lname[0]) }}@endif</span>
                                        </div>
                                    </div>
                                </div>
                                <div class="col-md-5 col-xs-12 col-sm-6 col-lg-5">
                                    <div class="container" style="border-bottom:1px solid #ccc">
                                        <h2><a href="{{ route('admin.customers.show', $customer->id) }}">{{$customer->name}}</a></h2>
                                    </div>
                                    <ul class="container details">
                                        <li><p><span class="fa fa-phone one" style="width:50px;"></span>@if($customer->phone){{$customer->phone}}@elseif($orderAddress->phone){{ $orderAddress->phone }}@else{{('n/a')}}@endif</p></li>
                                        <li><p><span class="fa fa-envelope one" style="width:50px;"></span>{{$customer->email}}</p></li>
                                        <li><p><span class="fa fa-calendar one" style="width:50px;"></span>Order Date: {{ date('d/m/Y @ h:i a', strtotime($order['created_at'])) }}</p></li>
                                        @if($order) @if( $order->oil_type_order == 1 )
                                        <li><p><span class="fa fa-truck one" style="width:50px;"></span>Delivery Date: <span class="delivery-date-update">{{ $delivery_date }}</span></p></li>
                                        <li><p><span class="fa fa-user one" style="width:50px;"></span>Driver: {{ $driver->name ?? 'n/a' }}</p></li>
                                        @endif @endif
                                        <li><p><span class="fa fa-bell one" style="width:50px;"></span>Payment Status: <span class="badge font-badge @if($currentStatus->name == 'paid') badge-success @elseif($currentStatus->name == 'pending') badge-warning @elseif($currentStatus->name == 'awaiting payment') badge-awaiting @elseif($currentStatus->name == 'error') badge-danger @else @endif">{{ $currentStatus->name }}</span></p></li>
                                        <li><p><span class="fa fa-eur one" style="width:50px;"></span>Payment Type: <span class="badge font-badge">{{ $order->payment_option }}</span></p></li>
                                        <li><p><span class="fa fa-bell one" style="width:50px;"></span>Order Status: <span class="badge font-badge @if($order->order_status == '1') badge-success @else badge-warning @endif">{{ ($order->order_status == '1')? 'Delivered' : 'Pending'}}</span></span></p></li>
                                    </ul>
                                </div>
                                <div class="col-md-3 col-xs-12 col-sm-12 col-lg-3">
                                    <div class="container margin-top-30">
                                        <div class="btn-margin-top"><button type="button" class="btn btn-primary btn-block btn-with-icon" data-toggle="modal" data-target="#payNowModal" {{ ($currentStatus->name == 'awaiting payment' && $order->payment_option == 'Credit Card') ? '': 'disabled' }}><i class="fa fa-credit-card"></i> Pay Now</button>
                                        <div class="btn-margin-top"><button class="btn btn-warning btn-with-icon btn-block" id="btn_change_delivery_date_modal"><i class="fa fa-calendar"></i> Change Delivery Date</button></div>
                                        @if( $order->oil_type_order == 1 )
                                        <div class="btn-margin-top">
                                            @if($order->driver_id)
                                                <button class="btn btn-purple btn-with-icon btn-block unassign-driver" data-id="{{$order->id}}"><i class="fa fa-user"></i> Unassign Driver</button>
                                            @else
                                                <button class="btn btn-purple btn-with-icon btn-block" id="btn_show_assign_driver_modal"><i class="fa fa-user"></i> Assign Driver</button>
                                            @endif
                                        </div>
                                        @endif
                                        <div class="btn-margin-top"><a href="{{route('admin.orders.invoice.generate', $order['id'])}}" target="_blank" class="btn btn-dark btn-block btn-with-icon"><i class="fa fa-download"></i> Download Invoice</a></div>
                                        <div class="btn-margin-top"><a href="javascript:void(0);" id="btn_show_invoice" class="btn btn-success btn-block btn-with-icon"><i class="fa fa-eye"></i> View Invoice</a></div>
                                        @if($user->hasPermission('update-order'))
                                        <div class="btn-margin-top">
                        	                <form action="{{ route('admin.order.destroy', [$order->id]) }}"  id="remove-from-form" class="form-horizontal">
                        	                    <input type="hidden" name="id" value="{{ $order->id }}">
                        	                    {{ csrf_field() }}
                        	                    <input type="hidden" name="_method" value="delete">
                        	                    <button id="{{ $order->id }}" type="submit" title="Delete" class="btn btn-danger btn-block delete_submit btn-with-icon" {{ ( $currentStatus->name == 'pending' || $currentStatus->name == 'awaiting payment' ) ? '': 'disabled' }}><i class="fa fa-trash"></i> Delete Order</button>
                        	            	</form>
                                        </div>
                                        @else
                                        <div class="btn-margin-top">
                        	                <form action="{{ route('admin.order.destroy', [$order->id]) }}" method="post" id="remove-from-form" class="form-horizontal">
                        	                    <input type="hidden" name="id" value="{{ $order->id }}">
                        	                    {{ csrf_field() }}
                        	                    <input type="hidden" name="_method" value="delete">
                        	                    <button id="{{ $order->id }}" type="submit" title="Delete" class="btn btn-danger btn-block delete_submit btn-with-icon" {{ ( $currentStatus->name == 'pending' || $currentStatus->name == 'awaiting payment' ) ? '': 'disabled' }}><i class="fa fa-trash"></i> Delete Order</button>
                        	            	</form>
                                        </div>
                                        @endif
                                        <div class="btn-margin-top">
                                            <div class="form-group">
                    	                       	<select name="order_status" id="order_status" class="form-control custom-select input-lg">
                    	                    		@if( $orderStatuses )
                    									@foreach( $orderStatuses as $orderStatus )
                    										<option value="{{ $orderStatus->id }}" {{ ( $currentStatus->name == $orderStatus->name ) ? 'selected': '' }}>{{ ucwords($orderStatus->name) }}</option>
                    									@endforeach
                                            		@endif
                	                        	</select>
                    	                       	<select name="payment_option" id="payment_option" class="form-control custom-select input-lg btn-margin-top" {{ ( $currentStatus->name == 'paid' ) ? 'disabled': '' }}>
                    	                       		<option value="Cash" {{ ( $order->payment_option == 'Cash' ) ? 'selected': '' }}>Cash</option>
                    	                       		<option value="Cheque" {{ ( $order->payment_option == 'Cheque' ) ? 'selected': '' }}>Cheque</option>
                    	                       		<option value="Credit Account" {{ ( $order->payment_option == 'Credit Account' ) ? 'selected': '' }}>Credit Account</option>
                    	                       		<option value="Credit Card" {{ ( $order->payment_option == 'Credit Card' ) ? 'selected': '' }}>Credit Card</option>
                    	                       	</select>

                                                <select name="o_status" id="o_status" class="form-control custom-select input-lg btn-margin-top">
                                                    <option value="0" {{ ( $order->order_status == '0' ) ? 'selected': '' }}>Pending</option>
                                                    <option value="1" {{ ( $order->order_status == '1' ) ? 'selected': '' }}>Delivered</option>
                                                </select>
                                        	</div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </section>
    </div>
</div>
<div class="row">
    <div class="col-md-12">
        <section class="content">    
            <div class="box">
                <div class="box-body">
                    <div class="col-md-12">
                        <h3 class="bold">Order <span class="font-black">#{{$order->id}}</span> @if( $order->oil_type_order == '0' )<span class="font-black">|</span> <button class="btn btn-dark" id="btn_add_order_product">+ Add Product</button>@endif</h3>
                        <h4 class="bold order-ref font-black"><div class="delivery-address">Reference Number: {{$order->reference}}</div></h4>
                         @if(!empty($order->delivery_note))
                        <div class="alert alert-primary" role="alert">
                            <h4 class="alert-heading">Customer Notes <a href="javascript:void(0);" class="margin-left-10 edit_customer_notes" title="Edit"><i class="fa fa-pencil font-red"></i></a></h4>
                            <span id="delivery_notes_text">{{$order->delivery_note}}</span>
                        </div>
                        @else
                            <button class="btn btn-dark btn-with-icon edit_customer_notes" ><i class="fa fa-file"></i> Add Customer Notes</button>
                        @endif
                        <table class="table table-striped table-hover table-checkable dataTable table-responsive table-responsive-md responsive" id="order_table">
                            <thead class="thead-dark">
                                <th scope="col" class="all">SKU</th>
                                <th scope="col" class="min-mobile-l">Product</th>
                                <th scope="col" class="min-mobile-l">Quantity</th>
                                <th scope="col" class="min-mobile-l"></th>
                                <th scope="col" class="min-mobile-l">Price</th>
                            </thead>
                            <tbody class="tbl_orders">
                            	@php $initialProductId = ''; $initialProductQty = ''; $itemCount = 1; @endphp
                                @if(!$items->isEmpty())
                                @foreach($items as $item)
                                <tr>
                                    <td class="dtr-control container_order_product_sku">{{ $item->sku }}</td>
                                    <td>
                                    	<div class="container_order_product_name" id="{{ $item->id }}">{{ $item->name }}</div>
                                    	<div class="container_order_product_list" style="display: none;">
                                    		<select name="order_product" id="order_product" class="form-control custom-select" style="width: 200px;">
                                    			<option value="">Select</option>
                                    			@if($order->oil_type_order == '1')
	                                    			@if($products)
	                                    				@foreach($products as $product)
	                                    					<option value="{{ $product->id }}" {{ ( $item->id == $product->id ) ? 'selected': '' }}>{{ $product->name }}</option>
	                                    				@endforeach
	                                    			@endif
	                                    		@else
	                                    			@if($products)
	                                    				@foreach($products as $product)
	                                    					<option value="{{ $product->id }}" @if($product->quantity <= 0) disabled="disabled" @endif {{ ( $item->id == $product->id ) ? 'selected': '' }}>{{ $product->name }}</option>
	                                    				@endforeach
	                                    			@endif
                                    			@endif
                                    		</select>
                                    	</div>
                                    </td>
                                    <td>
                                    		<div class="container_order_product_qty">
                                    	    @if($order->oil_type_order == '1')
                                    	        @if($order->fill_the_tank_status == '1' )
                                    	            @if($order->fill_the_tank_quantity != '' || $order->fill_the_tank_quantity > 0)
                                    	            {{$order->fill_the_tank_quantity}} 
                                    	            @else
                                    	            {{ ('Fill the Tank') }} 
                                    	            @endif
                                    	       @else 
                                    	        {{ $item->pivot->quantity }} 
                                    	       @endif
                                    	
                                    	    @else 
                                    	        {{ $item->pivot->quantity }} 
                                    	    @endif</div>
                                    	<div class="container_order_product_qty_list" style="display: none;">
                                    		@if($order->oil_type_order == '1')
										          <input type="text" name="fill_the_tank_quantity" id="order_product_qty" value="{{$order->fill_the_tank_quantity }}" class="form-control input-lg" style="font-size: 13px;" />
											@else
                                            <select name="order_product_qty" id="order_product_qty" class="form-control custom-select" style="width: 200px;">
                                                <option value="">Select</option>
                                    			@for($qty = 1; $qty <= 10; $qty++)
													<option value="{{ $qty }}" data-qty="{{ $qty }}" {{ ($item->pivot->quantity == $qty) ? 'selected' : '' }}>{{ $qty }}</option>
                                    			@endfor
                                    		</select>
                                    		@endif
                                    	</div>
                                    </td>
                                    <td></td>
                                    <td>
                                    	{{ config('cart.currency_symbol') }}<span class="container_product_price" id="display_price">@if($order->oil_type_order == '1'){{ number_format(($item->price), 2) }}@else{{ number_format(($item->price * $item->pivot->quantity), 2) }}@endif</span>
                                    	<span class="container_product_price" id="price_display" style="display: none;">
                                    	    @if($order->oil_type_order == '1')
                                    	        <input type="text" name="item_price" value="{{ number_format(($item->price), 2) }}" id="item_price" class="form-control input-lg" style="font-size: 13px; width:80px">
                                    	   @else
                                    	        <input type="text" name="item_price" value="{{ number_format(($item->price * $item->pivot->quantity), 2) }}" id="item_price" class="form-control input-lg" style="font-size: 13px; width:80px">
                                    	   @endif    
                                    	</span>
                                    	@if( $currentStatus->name == 'pending' || $currentStatus->name == 'awaiting payment' )
                                    	<span class="container_action_edit_order">
                                    		<a href="javascript:void(0);" class="margin-left-10 edit_order_product" title="Edit"><i class="fa fa-pencil"></i></a> 
                                    		{{-- Remove product option is only for Shop Products --}}
                                    		@if( $order->oil_type_order == 0 )
	                                    		<a href="javascript:void(0);" data-product="{{ $item->id }}" class="margin-left-10 delete_order_product" style="display: {{ ($itemCount == 1) ? 'none': '' }}" title="Delete"><i class="fa fa-trash"></i></a>
                                    		@endif
                                    	</span>
                                    	<span class="container_action_update_order" style="display: none;">
                                    		<a href="javascript:void(0);" data-product="{{ $item->id }}" data-product-qty="{{ $item->pivot->quantity }}" class="margin-left-10 update_order" title="Save"><i class="fa fa-save"></i></a> 
                                    		<a href="javascript:void(0);" class="margin-left-10 cancel_update_order" title="Cancel"><i class="fa fa-times"></i></a>
                                    	</span>
                                    	@endif
                                    </td>
                                </tr>
                                @php $itemCount++; @endphp
                                @endforeach
                                @php $initialProductId = $item->id; $initialProductQty = $item->pivot->quantity; @endphp
                                @endif
                            </tbody>
							@if($order->oil_type_order == 0)
							<tbody class="tbl_add_order_product" style="display: none;">
								{{-- To add a new product to the order --}}
								<tr class="tbl_row_add_order_product">
									<td></td>
									<td>
										<select name="new_order_product" id="new_order_product" class="form-control custom-select" style="width: 200px;">
											@if($products)
												@foreach($products as $product)
													<option value="{{ $product->id }}">{{ $product->name }}</option>
												@endforeach
											@endif
										</select>
									</td>
									<td>
                                        <select name="new_order_product_qty" id="new_order_product_qty" class="form-control custom-select" style="width: 200px;">
                                			@for( $qty=1; $qty<=10; $qty++ )
												<option value="{{ $qty }}">{{ $qty }}</option>
                                			@endfor
                                		</select>
									</td>
									<td>&nbsp;</td>
									<td>
										<span class="container_add_order_product">
											<a href="javascript:void(0);" class="margin-left-10 add_order_product" title="Save"><i class="fa fa-save"></i></a> 
											<a href="javascript:void(0);" class="margin-left-10 cancel_add_order_product" title="Cancel"><i class="fa fa-times"></i></a>
										</span>
									</td>
								</tr>
							</tbody>
							@endif
                            <tbody>
                                <tr>
                                    <td class="border-top-tot bg-white"></td>
                                    <td class="border-top-tot bg-white"></td>
                                    <td class="border-top-tot bg-white"></td>
                                    <td class="text-bold border-top-tot border-left-tot">Subtotal</td>
                                    <td class="text-bold border-top-tot">
                                    	{{ config('cart.currency_symbol') }}<span id="holder_subtotal">{{ $order['total_products'] }}</span>
                                    </td>
                                </tr>
                                <tr>
                                    <td class="bg-white border-top-totw"></td>
                                    <td class="bg-white border-top-totw"></td>
                                    <td class="bg-white border-top-totw"></td>
                                    <td class="text-bold border-left-tot">Vat</td>
                                    <td class="text-bold">
                                    	{{ config('cart.currency_symbol') }}<span id="holder_vat">{{ $order['tax'] }}</span>
                                    </td>
                                </tr>
                                <tr>
                                    <td class="bg-white border-top-totw"></td>
                                    <td class="bg-white border-top-totw"></td>
                                    <td class="bg-white border-top-totw"></td>
                                    <td class="text-bold border-left-tot container_label_update_discount">Discount</td>
                                    <td class="text-bold">
                                    	<span class="container_discount_value">
                                    		{{ config('cart.currency_symbol') }}<span id="holder_discount">{{ $order['discounts'] }}
                                    		<input type="hidden" name="discount_value" id="discount_value" value="{{$order['discounts'] }}">
                                    		</span>
                                    	</span>
                                    	<span class="container_discount_list" style="display: none;">
                                    		<select name="order_discount" id="order_discount" class="form-control custom-select" style="width: 100px;">
                                    			<option value="0">Select</option>
                                    			@if( $discountCoupons )
                                    				@foreach( $discountCoupons as $discountCoupon )
                                    					<option value="{{ $discountCoupon->id }}" {{ ( $order['discount_coupon_code'] == $discountCoupon->coupon_code ) ? 'selected': '' }} {{ in_array($discountCoupon->coupon_code, $appliedDiscounts) ? 'disabled': '' }}>{{ $discountCoupon->coupon_code }}</option>
                                    				@endforeach
                                    			@endif
                                    		</select>
                                    	</span>
                                    	@if( $currentStatus->name == 'pending' || $currentStatus->name == 'awaiting payment' )
                                    	<span class="container_action_edit_discount">
	                                    	<a href="javascript:void(0);" class="margin-left-10 edit_order_discount" title="Edit"><i class="fa fa-pencil"></i></a>
	                                    </span>
                                    	<span class="container_action_update_discount" style="display: none;">
                                    		<a href="javascript:void(0);" class="margin-left-10 update_discount" title="Save"><i class="fa fa-save"></i></a> 
                                    		<a href="javascript:void(0);" class="margin-left-10 cancel_update_discount" title="Cancel"><i class="fa fa-times"></i></a>
                                    	</span>
                                    	@endif
                                    </td>
                                </tr>
                            	<tr>
                                    <td class="bg-white border-top-totw"></td>
                                    <td class="bg-white border-top-totw"></td>
                                    <td class="bg-white border-top-totw"></td>
                                    <td class="text-bold border-top-tot border-left-tot">GRAND TOTAL</td>
                                    <td class="text-bold border-top-tot">
                                    	{{ config('cart.currency_symbol') }}<span id="holder_grand_total">{{ $order['total_paid'] }}</span>
                                    </td>
                                </tr>
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </section>
    </div>
</div>
@if($order)
<div class="row">
    <div class="col-md-12">
        <section class="content">
            <div class="box">
                <div class="box-body">
                    <div class="col-md-12">
                        <h3 class="bold">Delivery Address</h3>
                        @if( $order->oil_type_order == 1 )
                        <h4 class="bold driver-date font-black">
                            <div class="delivery-address">
                                <form action="{{ route('admin.order.sendEmail', [$order->id]) }}"  id="email-form" class="form-horizontal">
                                    <span style="display: {{($order->is_email_sent_customer == 1) ? 'inline-block' : 'none'}}" class="badge font-badge badge-success" id="badge-email"><i class="fa fa-check"></i>  Email Sent</span>
                                
                                    <input type="hidden" name="id" value="{{ $order->id }}">
                                    {{ csrf_field() }}
                                    <button data-id="{{$order->id}}" class="btn btn-dark btn-with-icon btn-send-email"><i class="fa fa-envelope"></i> Email Delivery Details to Customer</button>
                                </form>
                            </div>
                        </h4>
                        @endif
                        <table class="table table-striped table-hover table-checkable dataTable table-responsive table-responsive-md responsive" id="addresses_table">
                            <thead class="thead-dark">
                                <th scope="col" class="all">Address</th>
                                <th scope="col" class="min-tablet-l">Town</th>
                                <th scope="col" class="min-mobile-l">County</th>
                                <th scope="col" class="min-mobile-l">Eircode</th>
                                <th scope="col" class="min-tablet-l">Phone</th>
                            </thead>
                            <tbody>
                            <tr>
                                <td class="dtr-control">
                                	{{ $orderAddress->address_1 ?? '' }} {{ isset( $orderAddress->address_2 ) ? ', ' . $orderAddress->address_2: '' }}
                                </td>
                                <td>{{ $orderAddress->town ?? '' }}</td>
                                <td>{{ $orderAddress->county ?? '' }}</td>
                                <td>{{ $orderAddress->zip ?? '' }}</td>
                                <td>{{ $orderAddress->phone ?? '' }}</td>
                            </tr>
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </section>
    </div>
</div>
@endif
@if ($currentStatus->name == 'awaiting payment' && $order->payment_option == 'Credit Card')
<div id="payNowModal" class="modal fade" role="dialog">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal">&times;</button>
                <h4 class="modal-title"></h4>
            </div>
            <div class="modal-body">
       	        <div class="form-group">
       	            <div id="errorDiv" style="display:none;">
                            <p class="alert alert-error alert-dismissible" id="errorMessage">
                                Error
                            </p>
                        </div>
       	            <form id="frmStripePayment" action="{{ route('admin.order.payment') }}" method="post">
       	                <input type="hidden" value="{{base64_encode($order->id)}}" name="order_id">
       	                <div id="cardpayment" class="card_payment_type">
                            <div class="row">
                                <div class="col-md-6">
                                    <div class="form-group">
                                        <label for="name">Card Holder Name <span class="text-danger">*</span></label>
                                        <input type="text" id="name" name="name" class="form-control input-lg" data-card-details="cardholder-name" />
                                    </div>
                                </div>
                                <div class="col-md-6">
                                    <div class="form-group">
                                        <label for="email">Email Address <span class="text-danger">*</span></label>
                                        <input type="text" id="email" name="email" class="form-control input-lg" readonly value="{{$customer->email}}" />
                                    </div>
                                </div>
                            </div>
                            <div class="row">
                                <div class="col-md-12">
                                    <div class="form-group">
                                        <label for="card-number">Card Number <span class="text-danger">*</span></label>
                                        <input type="text" id="card-number" name="card-number" class="form-control input-lg" data-card-details="card-number" />
                                       
                                    </div>
                                </div>
                            </div>
                            <div class="row">
                                <div class="col-md-6">
                                    <div class="form-group">
                                        <label for="month">Expiry Month / Year <span class="text-danger">*</span></label>
                                        <div class="row">
                                            <div class="col-md-6">
                                                <select name="month" id="month" class="form-control custom-select input-lg">
                                                    <option value="01">01</option>
                                                    <option value="02">02</option>
                                                    <option value="03">03</option>
                                                    <option value="04">04</option>
                                                    <option value="05">05</option>
                                                    <option value="06">06</option>
                                                    <option value="07">07</option>
                                                    <option value="08">08</option>
                                                    <option value="09">09</option>
                                                    <option value="10">10</option>
                                                    <option value="11">11</option>
                                                    <option value="12">12</option>
                                                </select>
                                            </div>
                                            <div class="col-md-6">
                                                <select name="year" id="year" class="form-control custom-select input-lg">
                                                    <option value="20">2020</option>
                                                    <option value="21">2021</option>
                                                    <option value="22">2022</option>
                                                    <option value="23">2023</option>
                                                    <option value="24">2024</option>
                                                    <option value="25">2025</option>
                                                    <option value="26">2026</option>
                                                    <option value="27">2027</option>
                                                    <option value="28">2028</option>
                                                    <option value="29">2029</option>
                                                    <option value="30">2030</option>
                                                    <option value="31">2031</option>
                                                    <option value="32">2032</option>
                                                    <option value="33">2033</option>
                                                    <option value="34">2034</option>
                                                </select>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                                <div class="col-md-6">
                                    <div class="form-group">
                                        <label for="cvc">CVC <span class="text-danger">*</span></label>
                                        <input type="text" name="cvc" id="cvc" class="form-control input-lg cvv-input" data-card-details="security-code">
                                    </div>
                                </div>
                            </div>
                            <div class="row">
                                <div class="col-md-12">
                                    <img class="img-fluid m-1" src="{{ URL::asset('/images/opayo.png') }}" alt="Opayo Secure Payment" />
                                </div>
                            </div>
                        </div>
                        <input type='hidden' name='currency_code' value='EUR'>
                        {{csrf_field()}}
                        <input type="submit" name="pay_now" value="Pay Now" id="submit-btn card_pay_Now" class="btn btn-lg btn-block btn-send" onClick="stripePay(event);" id="card_pay_Now" />
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
@endif
<div id="modal_assign_driver" class="modal fade" role="dialog">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal">&times;</button>
                <h3 class="modal-title bold">Assign a Driver</h3>
            </div>
            <div class="modal-body">
                <div class="row">
                    <div class="col-md-12">
                        <p>Please choose a driver that you want assigned to this order.</p>
                    </div>
                    <div class="col-md-12">
                        <select name="driver_list" id="driver_list" class="form-control custom-select input-lg">
                            <option value="">Select Driver</option>
                        </select>
                    </div>
                    <div class="col-md-6 btn-margin-top"><br>
                        <button type="submit" class="btn btn-lg btn-block btn-success" id="btn_assign_driver">Assign Driver</button>
                    </div>
                    <div class="col-md-6 btn-margin-top"><br>
                        <a href="javascript:void(0);" data-dismiss="modal" class="btn btn-lg btn-block btn-send " data-value="no">Back</a>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<div id="modal_change_ddate" class="modal fade" role="dialog">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal">&times;</button>
                <h3 class="modal-title bold">Change Delivery Date</h3>
            </div>
            <div class="modal-body">
                <div class="row">
                    <div class="col-md-12">
                        <p>Please choose a new delivery date that you want assigned to this order.</p>
                    </div>
                    <div class="col-md-12">
                        <?php 
                        /*$created_date = strtotime($order->delivery_date);
                        $day = date('D', $created_date);
                        if ($day == 'Sat' || $day == 'Fri' || $day == 'Sun') {
                            $delivery_date =  date('Y-m-d', strtotime('next monday', strtotime($order->delivery_date)));
                        } else {
                            $delivery_date = date('Y-m-d', strtotime($order->delivery_date));
                        }*/
                        $delivery_date = date('d-m-Y', strtotime($order->delivery_date));
                        ?>
                        <input type="text" name="delivery_date" id="delivery_date" class="form-control input-lg">
                    </div>
                    <div class="col-md-6 btn-margin-top"><br>
                        <button type="submit" class="btn btn-lg btn-block btn-success" id="btn_update_delivery_date">Change Date</button>
                    </div>
                    <div class="col-md-6 btn-margin-top"><br>
                        <a href="javascript:void(0);" data-dismiss="modal" class="btn btn-lg btn-block btn-send " data-value="no">Back</a>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<div id="modal_show_invoice" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="MyOrders">
    <div class="modal-dialog invoice-modal" role="document">
        <div class="modal-content">
            <div class="modal-header toolbar hidden-print">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
            </div>
    		<div class="modal-body table-responsive-md" id="modal_body_show_invoice"></div>
    	</div>
	</div>
</div>
<div id="cutomer_note_modal_box" class="modal fade" role="dialog">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal">&times;</button>
                <h3 class="modal-title bold">Update Customer Note</h3>
            </div>
            <div class="modal-body">
                <div class="row">
                    <div class="col-md-12">
                        <p>Please edit the customer note below.</p>
                    </div>
                    <div class="col-md-12">
                        <textarea id="disp_customer_note" class="form-control input-lg" name="customer_notes">{{$order->delivery_note}}</textarea>
                    </div>
                    <div class="col-md-6 btn-margin-top"><br>
                        <button type="submit" class="btn btn-lg btn-block btn-success" id="btn_update_customer_note">Change Notes</button>
                    </div>
                    <div class="col-md-6 btn-margin-top"><br>
                        <a href="javascript:void(0);" data-dismiss="modal" class="btn btn-lg btn-block btn-send " data-value="no">Back</a>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
@endsection
@section('js')
<script src="{{ asset('js/sweetalert2.all.min.js') }}"></script>

<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.3.0/js/bootstrap-datepicker.js"></script>
<script src="{{ config('constants.evalon_url') }}/api/v1/js/sagepay.js"></script>

<script type="text/javascript">
function cardValidation () {
    var valid = true;
    var name = $('#name').val();
    var cardNumber = $('#card-number').val();
    var month = $('#month').val();
    var year = $('#year').val();
    var cvc = $('#cvc').val();
    $("#error-message").html("").hide();
    if (name.trim() == "") {
        valid = false;
    }
    if (cardNumber.trim() == "") {
       valid = false;
    }
    if (month.trim() == "") {
        valid = false;
    }
    if (year.trim() == "") {
        valid = false;
    }
    if (cvc.trim() == "") {
        valid = false;
    }
    if (valid == false) {
        $("#error-message").html("All Fields are required").show();
    }
    return valid;
}


function stripePay(e) {
        e.preventDefault();
        var valid = cardValidation();
        if (valid == true) {
            var month = $('#month').val();
            var year = $('#year').val();
            $("#submit-btn").hide();
            $( "#loader" ).css("display", "inline-block");
            var merchant_key = "<?php echo $merchantSessionKey; ?>";
            sagepayOwnForm({ 
            merchantSessionKey: "<?php echo $merchantSessionKey; ?>" })
             .tokeniseCardDetails({
                cardDetails: { 
                            cardholderName: document.querySelector('[data-card-details="cardholder-name"]').value, 
                            cardNumber: document.querySelector('[data-card-details="card-number"]').value,
                            expiryDate: month.trim()+year.trim(), 
                            securityCode: document.querySelector('[data-card-details="security-code"]').value },
                            onTokenised : function(result) { 
                                if (result.success) {
                                    
                                         
                                       
                                        $("#frmStripePayment").append("<input type='hidden' name='card-identifier' value='" + result.cardIdentifier + "' />");
                                         $("#frmStripePayment").append("<input type='hidden' name='merchent_key' value='" + merchant_key + "' />");
                                
                                        $("#frmStripePayment").submit();
                                } 
                                else { 
                                    var x = document.getElementById('errorDiv');
                                    x.style.display = "block";
                                   
                                    document.getElementById("errorMessage").innerHTML = result.errors[0].message;
                                } 
                            } 
                        });
            return false;
        } else {
            alert("Invalid Entries"); return false;
        }
    }
$(function(){
    var day = new Date().getDay();
     var d = new Date();
     if(day == '0' || day == '6'){
        d.setDate(d.getDate() + (1 + 7 - d.getDay()) % 7); 
     }else{
        d.setDate(new Date().getDate());
     }
    $( "#delivery_date" ).datepicker({  autoclose: true, 
        todayHighlight: true,
        daysOfWeekDisabled: [0,6],
        //startDate:d,
        format: 'dd/mm/yyyy',
    }).datepicker("setDate", "{{$delivery_date}}");

    $.fn.DataTable.ext.pager.numbers_length = 5;
    $('#order_status').change(function(e) {
    	var status = $(this).val();
    	var orderId= '{{ $order->id }}';
    	e.preventDefault();
		Swal.fire({
            title: 'Updated!',
	        text: "New status has been assigned.",
            type: 'success',
            showConfirmButton: false,
            timer: 1500
        });
    	$.ajax({
            url:"{{ route('admin.orders.status.update') }}",
            method: "POST",
            data: {
            	"_token": "{{ csrf_token() }}",
            	orderId: orderId,
            	status: status
            },
            success:function(response) {
                setTimeout(function() {
                    window.location.reload();
                }, 1500);
            }
        });
    });
    $('#payment_option').change(function(e) {
    	var orderId= '{{ $order->id }}';
    	var paymentOption = $(this).val()
    	Swal.fire({
            title: 'Updated!',
	        text: "New payment option has been assigned.",
            type: 'success',
            showConfirmButton: false,
            timer: 1500
        });
    	$.ajax({
            url:"{{ route('admin.orders.paymentoption.update') }}",
            method: "POST",
            data: {
            	"_token": "{{ csrf_token() }}",
            	orderId: orderId,
            	paymentOption: paymentOption
            },
            success:function(response) {
	    		setTimeout(function() {
                    window.location.reload();
                }, 1500);
            }
        });
    });
	$('#btn_add_order_product').click(function() {
		$('.tbl_add_order_product').show();
		$('.tbl_row_add_order_product').addClass("bg-yellow-color");
	});
	$('.cancel_add_order_product').click(function() {
		$('.tbl_add_order_product').hide();
		$('.tbl_row_add_order_product').removeClass("bg-yellow-color");
	});
	$('.add_order_product').click(function() {
		var refer = $(this);
		var orderId = '{{ $order->id }}';
		var productId = $('#new_order_product').val();
		var productQty = $('#new_order_product_qty').val();
		$.ajax({
	        url:"{{ route('admin.orders.addproduct') }}",
	        method: "POST",
	        data: {
	        	"_token": "{{ csrf_token() }}",
	        	orderId: orderId,
	        	productId: productId,
	        	productQty: productQty
	        },
	        success:function(response) {
	            if (response.status == 1) {
	            	$('#holder_subtotal').html(response.data.subtotal);
	            	$('#holder_vat').html(response.data.vat);
	            	$('#holder_discount').html(response.data.discount);
	            	$('#holder_grand_total').html(response.data.grandtotal);
	            	var lastRow = $('.tbl_orders tr:last').clone();
	            	$(lastRow).find('.container_order_product_sku').html(response.data.product_sku);
	            	$(lastRow).find('.container_order_product_name').html(response.data.product_name);
	            	$(lastRow).find('.container_order_product_name').attr('id', response.data.product_id);
	            	$(lastRow).find('.container_order_product_qty').html(response.data.product_qty);
	            	$(lastRow).find('.container_product_price').html(response.data.product_price);
	            	$(lastRow).find('.delete_order_product').show();
	            	$(lastRow).find('.delete_order_product').attr('data-product', response.data.product_id);
	            	$(lastRow).find('.update_order').attr('data-product', response.data.product_id);
	            	var newRow = '<tr>' + $(lastRow).html() + '</tr>';
	            	$('.tbl_orders tr:last').after(newRow);
	            	$('.cancel_add_order_product').click();
	            } else {
	            	Swal.fire({
	            	    title: 'Error!',
	            	    text: response.msg,
	            	    type: 'error',
	            	    showConfirmButton: false,
	            	    timer: 3000
	            	});
	            }
	        }
	    });
	});
	$(document).on('click', '.delete_order_product', function(e) {
		var refer = $(this);
		var orderId = '{{ $order->id }}';
		var productId = $(refer).attr('data-product');
		console.log('orderId: '+orderId);
		console.log('productId: '+productId);
		if (orderId != '' && productId != '') {
			e.preventDefault();
			Swal.fire({
                title: 'Are you sure?',
                text: "You won't be able to revert this!",
    	        type: 'warning',
    	        showCancelButton: true,
                confirmButtonColor: '#3085d6',
    	        cancelButtonColor: '#d33',
    	        confirmButtonText: 'Yes, delete it!'
            }).then((result) => {
    	        if (result.value) {
    	            Swal.fire({
                        title: 'Deleted!',
            	        text: "Your product has been deleted.",
            	        type: 'success',
                        showConfirmButton: false,
                        timer: 1500
    	            });
                    $.ajax({
    			        url:"{{ route('admin.orders.deleteorder') }}",
    			        method: "POST",
        		        data: {
        		        	"_token": "{{ csrf_token() }}",
    			        	orderId: orderId,
    			        	productId: productId
        		        },
        		        success:function(response) {
    			            if (response.status == 1) {
        		            	$('#holder_subtotal').html(response.data.subtotal);
        		            	$('#holder_vat').html(response.data.vat);
        		            	$('#holder_discount').html(response.data.discount);
    			            	$('#holder_grand_total').html(response.data.grandtotal);
        		            	$(refer).closest('tr').remove();
        		            }
    			        }
    			    });
                }
            });
		}
	});
	$('.edit_order_discount').click(function() {
		$('.container_discount_value').hide();
		$('.container_discount_list').show();
		$('.container_action_edit_discount').hide();
		$('.container_action_update_discount').show();
		$('.container_label_update_discount').closest('td').addClass("bg-yellow-color");
		$('.container_action_update_discount').closest('td').addClass("bg-yellow-color");
	});
	$('.cancel_update_discount').click(function() {
		$('.container_discount_value').show();
		$('.container_discount_list').hide();
		$('.container_action_edit_discount').show();
		$('.container_action_update_discount').hide();
		$('.container_label_update_discount').closest('td').removeClass("bg-yellow-color");
		$('.container_action_update_discount').closest('td').removeClass("bg-yellow-color");
	});
	$('.update_discount').click(function() {
		var refer = $(this);
		var orderId = '{{ $order->id }}';
		var orderType = '{{ ( $order->oil_type_order == 1 ) ? "oil": "shop" }}';
		var discountId = $('#order_discount').val();
		if (discountId || discountId == '0') {
			$.ajax({
		        url:"{{ route('admin.orders.updatediscount') }}",
		        method: "POST",
		        data: {
		        	"_token": "{{ csrf_token() }}",
		        	orderId: orderId,
		        	orderType: orderType,
		        	discountId: discountId
		        },
		        success:function(response) {
		            if( response.status == 1 ) {
		            	$('#holder_discount').html(response.data.discount);
		            	$('#holder_grand_total').html(response.data.grandtotal);
		            	$(refer).closest('tr').find('.cancel_update_discount').click();
		            } else {
		            	Swal.fire({
		            	    title: 'Error!',
		            	    text: response.msg,
		            	    type: 'error',
		            	    showConfirmButton: false,
		            	    timer: 3000
		            	});
		            }
		        }
		    });
		} else {
			$('.container_discount_value').show();
			$('.container_discount_list').hide();
			$('.container_action_edit_discount').show();
			$('.container_action_update_discount').hide();
			$('.container_label_update_discount').closest('td').removeClass("bg-yellow-color");
		    $('.container_action_update_discount').closest('td').removeClass("bg-yellow-color");
		}
	});
	$(document).on('click', '.edit_order_product', function(){
		var refer = $(this);
		$(refer).closest('tr').find('.container_order_product_name').hide();
		
		$(refer).closest('tr').find('#display_price').hide();
		$(refer).closest('tr').find('#price_display').show();
		
		$(refer).closest('tr').find('.container_order_product_list').show();
		$(refer).closest('tr').find('.container_order_product_list').show();
		$(refer).closest('tr').find('.container_order_product_qty').hide();
		$(refer).closest('tr').find('.container_order_product_qty_list').show();
		$(refer).closest('tr').find('.container_action_edit_order').hide();
		$(refer).closest('tr').find('.container_action_update_order').show();
		var orderType = '{{ ( $order->oil_type_order == 1 ) ? "oil": "shop" }}';
		if (orderType == 'shop') {
			var productId = $(refer).closest('tr').find('.container_order_product_name').attr('id');
			$(refer).closest('tr').find('#order_product').val(productId);
			//var qty = $(refer).closest('tr').find('.container_order_product_qty').html();
			//$(refer).closest('tr').find('#order_product_qty').val(qty);
		}
		$(refer).closest('tr').addClass("bg-yellow-color");
	});
// 	$(document).on('keyup','#order_product_qty',function(){
// 	    var qty = $(this).val();
// 	    var product_id = $('#order_product').val();
// 	    $.ajax({
// 		        url:"{{ route('admin.orders.updateqty') }}",
// 		        method: "POST",
// 		        data: {
// 		        	"_token": "{{ csrf_token() }}",
// 		            qty : qty,
// 		            order_id : "{{ $order->id }}",
// 		        	product_id :product_id
// 		        },
// 		        success:function(data) {
// 		          $('#item_price').val(data);
// 		        }
// 		    });
// 	})
// 	$(document).on('keyup','#item_price',function(){
// 	    var product_id = $('#order_product').val();
// 	    var price = $('#item_price').val();
// 	    $.ajax({
// 		        url:"{{ route('admin.orders.updateprice') }}",
// 		        method: "POST",
// 		        data: {
// 		        	"_token": "{{ csrf_token() }}",
// 		            price : price,
// 		            order_id : "{{ $order->id }}",
// 		        	product_id :product_id
// 		        },
// 		        success:function(data) {
// 		          $('#order_product_qty').val(data);
// 		        }
// 		    });
// 	})
	$(document).on('click', '.cancel_update_order', function(){
		var refer = $(this);
		// Product
		$(refer).closest('tr').find('.container_order_product_name').show();
		$(refer).closest('tr').find('.container_order_product_list').hide();
		// Quantity
		$(refer).closest('tr').find('.container_order_product_qty').show();
		$(refer).closest('tr').find('.container_order_product_qty_list').hide();
		// Action
		$(refer).closest('tr').find('.container_action_edit_order').show();
		$(refer).closest('tr').find('.container_action_update_order').hide();
		$(refer).closest('tr').removeClass("bg-yellow-color");
		$('#display_price').show();
    	$('#price_display').css('display','none');
	});
	$(document).on('click', '.update_order', function() {
	    
		var orderType = '{{ ( $order->oil_type_order == 1 ) ? "oil": "shop" }}';
		if (orderType == 'oil') {
		  
			var initialProductId = $(this).attr('data-product');
			var initialProductQty = $(this).attr('data-product-qty');
			console.log(initialProductId)
			console.log(initialProductQty)
			var orderId = '{{ $order->id }}';
			var refer = $(this);
			var productId = $('#order_product').val();
			var productAttrId = $('#order_product_qty').val();
			var productQty = $('#order_product_qty').val();
			var price = $('#item_price').val();
			if (productId != '' && productAttrId != '') {
			     
			      
				
				    
					$.ajax({
			            url:"{{ route('admin.orders.updateorder') }}",
			            method: "POST",
			            data: {
			            	"_token": "{{ csrf_token() }}",
			            	orderId: orderId,
			            	orderType: orderType,
			            	productId: productId,
			            	productQty: productQty,
			            	productAttrId: productAttrId,
			            	price : price
			            },
			            success:function(response) {
			                
			                if (response.status == 1) {
			                	$('#holder_subtotal').html(response.data.subtotal);
			                	$('#holder_vat').html(response.data.vat);
			                	$('#holder_discount').html(response.data.discount);
			                	$('#holder_grand_total').html(response.data.grandtotal);
			                	
			                	$(refer).closest('tr').find('#display_price').html(response.data.subtotal);
			                	$(refer).closest('tr').find('.container_order_product_name').html(response.data.product_name);
			                	$(refer).closest('tr').find('#display_price').html(response.data.product_price);
			                	$('#display_price').show();
			                	$('#price_display').css('display','none');
		                	    if (productQty == 0) {
		                	        $(refer).closest('tr').find('.container_order_product_qty').html('Fill the Tank');
		                	    } else {
		                	        $(refer).closest('tr').find('.container_order_product_qty').html(productQty);
		                	    }
			                	$(refer).closest('tr').find('.update_order').attr('data-product', response.data.product_id);
			                	$(refer).attr('data-product-qty', productQty);
			                	$(refer).closest('tr').find('.cancel_update_order').click();
			                } else {
			                	Swal.fire({
			                	    title: 'Error!',
			                	    text: response.msg,
			                	    type: 'error',
			                	    showConfirmButton: false,
			                	    timer: 3000
			                	});
			                }
			            }
			        });
				
			} else {
				$('.cancel_update_order').click();
			}
		} else {
			var initialProductId = $(this).attr('data-product');
			var initialProductQty = $(this).attr('data-product-qty');
			var orderId = '{{ $order->id }}';
			var refer = $(this);
			var productId = $(refer).closest('tr').find('#order_product').val();
			var productQty = $(refer).closest('tr').find('#order_product_qty').val();
			var existingProductId = initialProductId;
			if (initialProductId != productId || productQty != initialProductQty) {
				$.ajax({
		            url:"{{ route('admin.orders.updateorder') }}",
		            method: "POST",
		            data: {
		            	"_token": "{{ csrf_token() }}",
		            	orderId: orderId,
		            	orderType: orderType,
		            	productId: productId,
		            	productQty: productQty,
		            	existingProductId: existingProductId
		            },
		            success:function(response) {
		                if (response.status == 1) {
		                	$('#holder_subtotal').html(response.data.subtotal);
		                	$('#holder_vat').html(response.data.vat);
		                	$('#holder_discount').html(response.data.discount);
		                	$('#holder_grand_total').html(response.data.grandtotal);
		                	$(refer).closest('tr').find('.container_order_product_sku').html(response.data.product_sku);
		                	$(refer).closest('tr').find('.container_order_product_name').html(response.data.product_name);
		                	$(refer).closest('tr').find('.container_order_product_name').attr('id', response.data.product_id);
		                	$(refer).closest('tr').find('.container_product_price').html(response.data.product_price);
		                	$(refer).closest('tr').find('.container_order_product_qty').html(productQty);
		                	$(refer).closest('tr').find('.delete_order_product').attr('data-product', response.data.product_id);
		                	$(refer).closest('tr').find('.update_order').attr('data-product', response.data.product_id);
		                	$(refer).attr('data-product-qty', productQty);
		                	$(refer).closest('tr').find('.cancel_update_order').click();
		                } else {
		                	Swal.fire({
		                	    title: 'Error!',
		                	    text: response.msg,
		                	    type: 'error',
		                	    showConfirmButton: false,
		                	    timer: 3000
		                	});
		                }
		            }
		        });
			} else {
				$(this).closest('tr').find('.cancel_update_order').click();
			}
		}
	});
    $('#order_table').DataTable({
		"responsive": true,
		"bPaginate": false,
        "bLengthChange": false,
        "bFilter": false,
        "bInfo": false,
        "bSort": false,
		"order": [[ 0, "desc" ]],
        "bAutoWidth": false,
        "columnDefs": [
            { "orderable": false, "targets": [0, 1, 2, 3, 4] }
        ],
        "aaSorting": [],
        "columnDefs": [
          { "width": "150px", "targets": 3 },
          { "width": "150px", "targets": 4 }
        ]
	});
    $('#addresses_table').DataTable({
		"responsive": true,
		"bPaginate": false,
        "bLengthChange": false,
        "bFilter": false,
        "bInfo": false,
        "bSort": false,
		"order": [[ 0, "desc" ]],
        "bAutoWidth": false,
        "columnDefs": [
            { "orderable": false, "targets": [0, 1, 2, 3] }
        ],"aaSorting": []
	});
    $('.delete_submit').on('click',function(e) {
        var refer = $(this).attr("id");
		var step_remove_url = $(this).closest("#remove-from-form").attr('action');
		e.preventDefault();
		e.stopPropagation();
		if (refer != '') {
			Swal.fire({
                title: 'Are you sure?',
                text: "You won't be able to revert this!",
    	        type: 'warning',
    	        showCancelButton: true,
                confirmButtonColor: '#3085d6',
    	        cancelButtonColor: '#d33',
    	        confirmButtonText: 'Yes, delete it!'
            }).then((result) => {
    	        if (result.value) {
    	            Swal.fire({
                        title: 'Deleted!',
            	        text: "Your order has been deleted.",
            	        type: 'success',
                        showConfirmButton: false,
                        timer: 1500
    	            });
                    $.ajax({
    			        url: step_remove_url,
    			        method: "POST",
        		        data: {
        		        	"_token": "{{ csrf_token() }}",
        		        	"_method": "delete",
    			        	id: refer
        		        },
        		        success:function(response){
    			            setTimeout(function(){
                                window.location.replace("{{url('admin/orders')}}");
                            }, 1500);
    			        }
    			    });
                }
            });
        }
    });
	$('#btn_show_invoice').click(function() {
    	var orderId= '{{ $order->id }}';
    	$.ajax({
            url:"{{ route('admin.orders.invoice.details') }}",
            method: "POST",
            data: {
            	"_token": "{{ csrf_token() }}",
            	orderId: orderId
            },
            success:function(response) {
                $('#modal_body_show_invoice').html(response);
                $("#modal_show_invoice").modal('show');
            }
        });
    });
    $('#btn_show_assign_driver_modal').click(function() {
        var order_id = $(this).attr('data-id');
        $('#popup_order_id').val(order_id);
        $.ajax({
            url:"{{ route('admin.driver.alldriver') }}",
            method: "POST",
            data: {"_token": "{{ csrf_token() }}"},
            success:function(data){
                data = JSON.parse(data);
                $("#driver_list").html(data);
                $("#modal_assign_driver").modal('show');
            }
        });
    });
    $('#btn_assign_driver').click(function(e) {
        var popup_driver_id = $("#driver_list").val();
        var popup_order_id 	= '{{ $order->id }}';
        if(popup_driver_id != ''){
            $('#modal_assign_driver').hide();
            e.preventDefault();
			Swal.fire({
                title: 'Updated!',
    	        text: "A driver has been assigned.",
    	        type: 'success',
                showConfirmButton: false,
                timer: 1500
            });
            $.ajax({
                url:"{{ route('admin.driver.assignorder') }}",
                method: "POST",
                data: {'popup_driver_id':popup_driver_id, 'popup_order_id':popup_order_id ,"_token": "{{ csrf_token() }}"},
                success:function(data){
                    setTimeout(function(){
                        window.location.reload();
                    }, 1500);
                }
            });
        }   
    });
    $('#btn_change_delivery_date_modal').click(function() {
        $("#modal_change_ddate").modal('show');
    });
	$('#btn_update_delivery_date').click(function(e) {
		var refer = $(this);
		var orderId = '{{ $order->id }}';
		var deliveryDate = '{{ $delivery_date }}';
		var updatedDeliveryDate = $('#delivery_date').val();
		if (updatedDeliveryDate != '') {
		    e.preventDefault();
			Swal.fire({
                title: 'Updated!',
    	        text: "A delivery date has been assigned.",
    	        type: 'success',
                showConfirmButton: false,
                timer: 1500
            });
			$.ajax({
		        url:"{{ route('admin.orders.updatedeliverydate') }}",
		        method: "POST",
		        data: {
		        	"_token": "{{ csrf_token() }}",
		        	orderId: orderId,
		        	updatedDeliveryDate: updatedDeliveryDate
		        },
		        success:function(response){
		            if( response.status == 1 ) {
		            	$('#delivery_date').val(response.formated_delivery_date);
		            	$('#container_delivery_date').html(response.formated_delivery_date);
		            	$('.delivery-date-update').html(response.formated_delivery_date);
		            	$("#modal_change_ddate").modal('hide');
		            }
		        }
			});
		}
	});
    $('.btn-send-email').on('click',function(e) {
        var refer = $(this).data("id");
        var step_remove_url = $(this).closest("#email-form").attr('action');
        var obj = $(this);
        e.preventDefault();
        e.stopPropagation();
        if (refer != '') {
            Swal.fire({
                title: 'Are you sure?',
                text: "You want to sent email!!",
                type: 'warning',
                showCancelButton: true,
                confirmButtonColor: '#3085d6',
                cancelButtonColor: '#d33',
                confirmButtonText: 'Yes, Send!'
            }).then((result) => {
                if (result.value) {
                    $(this).attr("disabled",true);
                    $.ajax({
                        url: step_remove_url,
                        method: "POST",
                        data: {
                            "_token": "{{ csrf_token() }}",
                            "_method": "post",
                            id: refer
                        },
                        success:function(response){
                            if (response.status == 1) {
                                $("#badge-email").show();
                                obj.attr("disabled",false);
                                Swal.fire({
                                    title: 'Success!!',
                                    text: response.msg,
                                    type: 'success',
                                    showConfirmButton: false,
                                    timer: 1500
                                });
                            } else {
                                obj.attr("disabled",false);
                                Swal.fire({
                                    title: 'Opps!!',
                                    text: response.msg,
                                    type: 'error',
                                    showConfirmButton: false,
                                    timer: 1500
                                });
                            }
                        }
                    });
                }
            });
        }
    });
    $('#o_status').change(function(e) {
        var status = $(this).val();
        var orderId= '{{ $order->id }}';
        e.preventDefault();
        Swal.fire({
            title: 'Updated!',
            text: "New status has been assigned.",
            type: 'success',
            showConfirmButton: false,
            timer: 1500
        });
        $.ajax({
            url:"{{ route('admin.orders.status.update') }}",
            method: "POST",
            data: {
                "_token": "{{ csrf_token() }}",
                orderId: orderId,
                status: status,
                order_main_status: 1
            },
            success:function(response) {
                setTimeout(function() {
                    window.location.reload();
                }, 1500);
            }
        });
    });

    $('.unassign-driver').on('click',function(e) {
        var id = $(this).data("id");
        var obj = $(this);
        e.preventDefault();
        e.stopPropagation();
        if (id != '') {
            Swal.fire({
                title: 'Are you sure?',
                text: "The driver will be unassigned from this order",
                type: 'warning',
                showCancelButton: true,
                confirmButtonColor: '#3085d6',
                cancelButtonColor: '#d33',
                confirmButtonText: 'Yes!'
            }).then((result) => {
                if (result.value) {
                    $(this).attr("disabled",true);
                    $.ajax({
                        url: "{{route('admin.driver.unassignDriver')}}",
                        method: "POST",
                        data: {
                            "_token": "{{ csrf_token() }}",
                            "_method": "get",
                            id: id
                        },
                        success:function(response){
                            setTimeout(function() {
                                window.location.reload();
                            }, 1500);
                        }
                    });
                }
            });
        }
    });
    $('.edit_customer_notes').click(function(){
     
        $('#cutomer_note_modal_box').modal('show');
    });
    $('#btn_update_customer_note').click(function(){
        var refer = $(this);
        var orderId = '{{ $order->id }}';
        var customer_notes = $('#disp_customer_note').val();
        $.ajax({
            url:"{{ route('admin.orders.updateCustomerNotes') }}",
		        method: "POST",
 		        data: {
		        	"_token": "{{ csrf_token() }}",
		        	orderId: orderId,
		        	customer_notes: customer_notes
 		        },
 		        success:function(response){
                	if( response == 1 ) {
                	$('#delivery_notes_text').text(customer_notes);
                
                	$("#cutomer_note_modal_box").modal('hide');
                	location.reload();
                	}
                }
        });
        
    });
});
</script>
@endsection

Spamworldpro Mini