![]() 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/ |
@extends('layouts.admin.app') @section('content') <!-- Main content --> <section class="content"> @include('layouts.errors-and-messages') <!-- Default box --> <div class="box"> <div class="box-header"> <div class="row"> <div class="col-md-6"> <h2> <a href="{{ route('admin.customers.show', $customer->id) }}">{{$customer->name}}</a> <br /> <small>{{$customer->email}}</small> <br /> <small>reference: <strong>{{$order->reference}}</strong></small> </h2> </div> <div class="col-md-3 col-md-offset-3"> <h2><a href="{{route('admin.orders.invoice.generate', $order['id'])}}" class="btn btn-primary btn-block">Download Invoice</a></h2> </div> </div> </div> </div> <div class="box"> <div class="box-body"> <h4> <i class="fa fa-shopping-bag"></i> Order Information</h4> <table class="table"> <thead> <tr> <td class="col-md-3">Date</td> <td class="col-md-3">Customer</td> <td class="col-md-3">Payment</td> <td class="col-md-3">Status</td> </tr> </thead> <tbody> <tr> <td>{{ date('M d, Y h:i a', strtotime($order['created_at'])) }}</td> <td><a href="{{ route('admin.customers.show', $customer->id) }}">{{ $customer->name }}</a></td> <td><strong>{{ $order['payment'] }}</strong></td> <td> <div class="form-group"> <select name="order_status_id" id="order_status_id" class="form-control select2"> @foreach($statuses as $status) <option @if($currentStatus->id == $status->id) selected="selected" @endif value="{{ $status->id }}">{{ ucwords($status->name) }}</option> @endforeach </select> </div> </td> </tr> </tbody> <tbody> <tr> <td></td> <td></td> <td class="bg-warning">Subtotal</td> <td class="bg-warning">{{ config('cart.currency_symbol') }}<span id="holder_subtotal">{{ $order['total_products'] }}</span></td> </tr> <tr> <td></td> <td></td> <td class="bg-warning">Vat</td> <td class="bg-warning">{{ config('cart.currency_symbol') }}<span id="holder_vat">{{ $order['tax'] }}</span></td> </tr> <tr> <td></td> <td></td> <td class="bg-warning">Discount</td> <td class="bg-warning">{{ config('cart.currency_symbol') }}<span id="holder_discount">{{ $order['discounts'] }}</span></td> </tr> <tr> <td></td> <td></td> <td class="bg-success text-bold">Order Total</td> <td class="bg-success text-bold">{{ config('cart.currency_symbol') }}<span id="holder_total">{{ $order['total'] }}</span></td> </tr> <tr> <td></td> <td></td> <td></td> <td> <form name="frm_update_quote" id="frm_update_quote"> <input type="hidden" name="order_id" id="order_id" value="{{ $order->id }}" value=""> <input type="hidden" name="product_id" id="product_id" value="" value=""> <input type="hidden" name="product_attr_id" id="product_attr_id" value="" value=""> <input type="hidden" name="product_qty" id="product_qty" value="" value=""> <input type="hidden" name="calculated_subtotal" id="calculated_subtotal" value=""> <input type="hidden" name="calculated_vat" id="calculated_vat" value=""> <input type="hidden" name="calculated_total" id="calculated_total" value=""> <input type="hidden" name="discount_code_id" id="discount_code_id" value=""> <input type="hidden" name="calculated_discount_amount" id="calculated_discount_amount" value=""> <button type="button" class="btn btn-primary" id="btn_update_quote">Update Quote</button> </form> </td> </tr> </tbody> </table> </div> <!-- /.box-body --> </div> @if($order) @if($order->total != $order->total_paid) <p class="alert alert-danger"> Ooops, there is discrepancy in the total amount of the order and the amount paid. <br /> Total order amount: <strong>{{ config('cart.currency') }} {{ $order->total }}</strong> <br> Total amount paid <strong>{{ config('cart.currency') }} {{ $order->total_paid }}</strong> </p> @endif <div class="box"> @if(!$items->isEmpty()) <div class="box-body"> <h4> <i class="fa fa-gift"></i> Items</h4> <table class="table"> <thead> <th class="col-md-2">SKU</th> <th class="col-md-2">Name</th> <th class="col-md-2">Description</th> <th class="col-md-2">Quantity</th> <th class="col-md-2">Price</th> <th class="col-md-2">Action</th> </thead> <tbody> @php $productId = ''; $productQty = ''; @endphp @foreach($items as $item) <tr> @php $productId = $item->id; @endphp @php $productQty = $item->pivot->quantity; @endphp <td>{{ $item->sku }}</td> <td>{{ $item->name }}</td> <td>{!! $item->description !!}</td> <td>{{ $item->pivot->quantity }}</td> <td>{{ config('cart.currency_symbol') }}{{ $item->price }}</td> <td> <button class="btn btn-primary" id="btn_edit_order"><i class="fa fa-pencil"></i></button> </td> </tr> @endforeach </tbody> </table> {{-- To update the order --}} <table class="table" id="table_edit_order" style="display: none;"> <tr> <th class="col-md-3">Product</th> <th class="col-md-3">Quantity</th> <th class="col-md-3">Discount</th> <th class="col-md-3"></th> </tr> <tr> <td> <select name="order_product" id="order_product" style="width: 200px;"> <option value="">Select</option> @if( $products ) @foreach( $products as $product ) <option value="{{ $product->id }}" {{ ( $productId == $product->id ) ? 'selected': '' }}>{{ $product->name }}</option> @endforeach @endif </select> </td> <td> <select name="order_product_qty" id="order_product_qty" style="width: 200px;"> <option value="">Select</option> @if( $initialProductQuantites ) <option value="fill the tank">Fill The Tank</option> @foreach($initialProductQuantites as $product_attributes) <option value="{{ $product_attributes->id }}" data-qty="{{ $product_attributes->value }}" {{ ( $productQty == $product_attributes->value ) ? 'selected' : '' }}>{{ $product_attributes->name . " : " . $product_attributes->value }}</option> @endforeach @endif </select> </td> <td> <select name="order_discount" id="order_discount" style="width: 200px;"> <option value="">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> </td> <td> <button type="button" class="btn btn-primary" id="btn_show_quote">Show Quote</button> </td> </tr> </table> </div> @endif <div class="box-body"> <div class="row"> <div class="col-md-6"> <h4> <i class="fa fa-truck"></i> Courier</h4> <table class="table"> <thead> <th class="col-md-3">Name</th> <th class="col-md-4">Description</th> <th class="col-md-5">Link</th> </thead> <tbody> <tr> <td>{{ $order->courier->name }}</td> <td>{{ $order->courier->description }}</td> <td>{{ $order->courier->url }}</td> </tr> </tbody> </table> </div> <div class="col-md-6"> <h4> <i class="fa fa-map-marker"></i> Address</h4> <table class="table"> <thead> <th>Address 1</th> <th>Address 2</th> <th>City</th> <th>Province</th> <th>Zip</th> </thead> <tbody> <tr> <td>{{ $order->address->address_1 }}</td> <td>{{ $order->address->address_2 }}</td> <td> @if(isset($order->address->city)) {{ $order->address->city }} @endif </td> <td> @if(isset($order->address->province)) {{ $order->address->province }} @endif </td> <td>{{ $order->address->zip }}</td> </tr> </tbody> </table> </div> </div> </div> </div> <!-- /.box --> <div class="box-footer"> <div class="btn-group"> <a href="{{ route('admin.orders.show', $order->id) }}" class="btn btn-default">Back</a> </div> </div> @endif </section> <!-- /.content --> @endsection @section('js') <script type="text/javascript"> $(document).ready(function () { // To edit order $('#btn_edit_order').click(function(){ $('#table_edit_order').show(); }); // Get qty for the selected product $('#order_product').change(function(){ var product_id = $(this).val(); $.ajax({ url:"{{ route('admin.orders.fetch.oilproduct.attributes') }}", method: "POST", data: { "_token": "{{ csrf_token() }}", product_id: product_id }, success:function(response){ $('#order_product_qty').html(response); } }); }); // To show new quote as per the selection $('#btn_show_quote').click(function(){ var productId = $('#order_product').val(); var productQty = $('#order_product_qty').val(); var discountId = $('#order_discount').val(); $.ajax({ url:"{{ route('admin.orders.calculate.new.quote') }}", method: "POST", data: { "_token": "{{ csrf_token() }}", productId: productId, productQty: productQty, discountId: discountId }, success:function(response){ $('#holder_subtotal').html(response.subtotal); $('#holder_vat').html(response.vat); $('#holder_discount').html(response.discount); $('#holder_total').html(response.total); $('#product_id').val(productId); $('#product_attr_id').val($('#order_product_qty').val()); $('#product_qty').val($('#order_product_qty').find(':selected').attr('data-qty')); $('#discount_code_id').val(discountId); $('#calculated_subtotal').val(response.subtotal); $('#calculated_vat').val(response.vat); $('#calculated_discount_amount').val(response.discount); $('#calculated_total').val(response.total); } }); }); // To update quote $('#btn_update_quote').click(function(){ var orderId = $('#order_id').val(); var productId = $('#order_product').val(); var productQty = $('#product_qty').val(); var productAttrId = $('#product_attr_id').val(); var discountId = $('#discount_code_id').val(); var subtotal = $('#calculated_subtotal').val(); var vat = $('#calculated_vat').val(); var discountAmount = $('#calculated_discount_amount').val(); var total = $('#calculated_total').val(); if( productId != '' && subtotal != '' && vat != '' && total != '' ) { $.ajax({ url:"{{ route('admin.orders.update.quote') }}", method: "POST", data: { "_token": "{{ csrf_token() }}", orderId: orderId, productId: productId, productQty: productQty, productAttrId: productAttrId, discountId: discountId, subtotal: subtotal, vat: vat, discountAmount: discountAmount, total: total }, success:function(response){ if( response.status == 1 ) { alert(response.msg); setTimeout(function () { location.reload(true); }, 1000); } else { alert(response.msg); } } }); } else { alert('Please edit the quote first to update it.'); } }); let osElement = $('#order_status_id'); osElement.change(function () { if (+$(this).val() === 1) { $('input[name="total_paid"]').fadeIn(); } else { $('input[name="total_paid"]').fadeOut(); } }); }) </script> @endsection