You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

600 lines
34 KiB

@extends('layouts.admin.app')
@section('title', translate('messages.order_report'))
@push('css_or_js')
@endpush
@section('content')
<div class="content container-fluid">
<!-- Page Header -->
<div class="page-header">
<h1 class="page-header-title">
<span class="page-header-icon">
<img src="{{asset('/public/assets/admin/img/report/new/order_report.png')}}" class="w--22" alt="">
</span>
<span>
{{ translate('messages.order_report') }}
</span>
</h1>
</div>
<!-- End Page Header -->
<div class="card mb-20">
<div class="card-body">
<h4 class="">{{ translate('Search Data') }}</h4>
<form method="get">
<div class="row g-3">
<div class="col-sm-6 col-md-3">
<select name="zone_id" class="form-control js-select2-custom"
onchange="set_zone_filter('{{ url()->full() }}',this.value)" id="zone">
<option value="all">{{ translate('messages.All Zones') }}</option>
@foreach (\App\Models\Zone::orderBy('name')->get() as $z)
<option value="{{ $z['id'] }}"
{{ isset($zone) && $zone->id == $z['id'] ? 'selected' : '' }}>
{{ $z['name'] }}
</option>
@endforeach
</select>
</div>
<div class="col-sm-6 col-md-3">
<select name="restaurant_id" onchange="set_restaurant_filter('{{ url()->full() }}',this.value)"
data-placeholder="{{ translate('messages.select') }} {{ translate('messages.restaurant') }}"
class="js-data-example-ajax form-control">
@if (isset($restaurant))
<option value="{{ $restaurant->id }}" selected>{{ $restaurant->name }}</option>
@else
<option value="all" selected>{{ translate('messages.all') }} {{ translate('messages.restaurants') }}</option>
@endif
</select>
</div>
<div class="col-sm-6 col-md-3">
<select name="customer_id" onchange="set_customer_filter('{{ url()->full() }}',this.value)"
data-placeholder="{{ translate('messages.select') }} {{ translate('messages.customer') }}"
class="js-data-example-ajax-2 form-control">
@if (isset($customer))
<option value="{{ $customer->id }}" selected>{{ $customer->f_name . ' ' .$customer->l_name }}</option>
@else
<option value="all" selected>{{ translate('messages.all') }} {{ translate('messages.customers') }}</option>
@endif
</select>
</div>
<div class="col-sm-6 col-md-3">
<select class="form-control" name="filter"
onchange="set_time_filter('{{ url()->full() }}',this.value)">
<option value="all_time" {{ isset($filter) && $filter == 'all_time' ? 'selected' : '' }}>
{{ translate('messages.All Time') }}</option>
<option value="this_year" {{ isset($filter) && $filter == 'this_year' ? 'selected' : '' }}>
{{ translate('messages.This Year') }}</option>
<option value="previous_year"
{{ isset($filter) && $filter == 'previous_year' ? 'selected' : '' }}>
{{ translate('messages.Previous Year') }}</option>
<option value="this_month"
{{ isset($filter) && $filter == 'this_month' ? 'selected' : '' }}>
{{ translate('messages.This Month') }}</option>
<option value="this_week" {{ isset($filter) && $filter == 'this_week' ? 'selected' : '' }}>
{{ translate('messages.This Week') }}</option>
<option value="custom" {{ isset($filter) && $filter == 'custom' ? 'selected' : '' }}>
{{ translate('messages.Custom') }}</option>
</select>
</div>
@if (isset($filter) && $filter == 'custom')
<div class="col-sm-6 col-md-3">
<input type="date" name="from" id="from_date" class="form-control"
placeholder="{{ translate('Start Date') }}"
value={{ isset($from) ? $from : '' }} required>
</div>
<div class="col-sm-6 col-md-3">
<input type="date" name="to" id="to_date" class="form-control"
placeholder="{{ translate('End Date') }}"
value={{ isset($to) ? $to : '' }} required>
</div>
@endif
<div class="col-sm-6 col-md-3 ml-auto">
<button type="submit"
class="btn btn-primary btn-block">{{ translate('Filter') }}</button>
</div>
</div>
</form>
</div>
</div>
<div class="mb-20">
<div class="row g-2">
<div class="col-sm-6 col-lg-4">
<a class="order--card h-100" href="#">
<div class="d-flex justify-content-between align-items-center">
<h6 class="card-subtitle d-flex justify-content-between m-0 align-items-center">
<img src="{{asset('/public/assets/admin/img/order-icons/schedule.png')}}" alt="dashboard" class="oder--card-icon">
<span>{{ translate('Scheduled Orders') }}</span>
</h6>
<span class="card-title" style="--base-clr:#0661CB">
{{ $total_scheduled_count }}
</span>
</div>
</a>
</div>
<div class="col-sm-6 col-lg-4">
<a class="order--card h-100" href="#">
<div class="d-flex justify-content-between align-items-center">
<h6 class="card-subtitle d-flex justify-content-between m-0 align-items-center">
<img src="{{asset('/public/assets/admin/img/order-icons/pending.png')}}" alt="dashboard" class="oder--card-icon">
<span>{{ translate('Pending Orders') }}</span>
</h6>
<span class="card-title" style="--base-clr:#0661CB">
{{ $total_pending_count }}
</span>
</div>
</a>
</div>
<div class="col-sm-6 col-lg-4">
<a class="order--card h-100" href="#">
<div class="d-flex justify-content-between align-items-center">
<h6 class="card-subtitle d-flex justify-content-between m-0 align-items-center">
<img src="{{asset('/public/assets/admin/img/order-icons/accepted.png')}}" alt="dashboard" class="oder--card-icon">
<span>{{ translate('Accepted Orders') }}</span>
</h6>
<span class="card-title" style="--base-clr:#0661CB">
{{ $total_accepted_count }}
</span>
</div>
</a>
</div>
<div class="col-sm-6 col-lg-4">
<a class="order--card h-100" href="#">
<div class="d-flex justify-content-between align-items-center">
<h6 class="card-subtitle d-flex justify-content-between m-0 align-items-center">
<img src="{{asset('/public/assets/admin/img/order-icons/processing.png')}}" alt="dashboard" class="oder--card-icon">
<span>{{ translate('Processing Orders') }}</span>
</h6>
<span class="card-title" style="--base-clr:#00AA6D">
{{ $total_progress_count }}
</span>
</div>
</a>
</div>
<div class="col-sm-6 col-lg-4">
<a class="order--card h-100" href="#">
<div class="d-flex justify-content-between align-items-center">
<h6 class="card-subtitle d-flex justify-content-between m-0 align-items-center">
<img src="{{asset('/public/assets/admin/img/order-icons/on-the-way.png')}}" alt="dashboard" class="oder--card-icon">
<span>{{ translate('Food_On_the_Way') }}</span>
</h6>
<span class="card-title" style="--base-clr:#00AA6D">
{{ $total_on_the_way_count }}
</span>
</div>
</a>
</div>
<div class="col-sm-6 col-lg-4">
<a class="order--card h-100" href="#">
<div class="d-flex justify-content-between align-items-center">
<h6 class="card-subtitle d-flex justify-content-between m-0 align-items-center">
<img src="{{asset('/public/assets/admin/img/order-icons/delivered.png')}}" alt="dashboard" class="oder--card-icon">
<span>{{ translate('Delivered') }}</span>
</h6>
<span class="card-title" style="--base-clr:#00AA6D">
{{$total_delivered_count}}
</span>
</div>
</a>
</div>
<div class="col-sm-6 col-lg-4">
<a class="order--card h-100" href="#">
<div class="d-flex justify-content-between align-items-center">
<h6 class="card-subtitle d-flex justify-content-between m-0 align-items-center">
<img src="{{asset('/public/assets/admin/img/order-icons/canceled.png')}}" alt="dashboard" class="oder--card-icon">
<span>{{ translate('Canceled') }}</span>
</h6>
<span class="card-title" style="--base-clr:#FF7500">
{{ $total_canceled_count }}
</span>
</div>
</a>
</div>
<div class="col-sm-6 col-lg-4">
<a class="order--card h-100" href="#">
<div class="d-flex justify-content-between align-items-center">
<h6 class="card-subtitle d-flex justify-content-between m-0 align-items-center">
<img src="{{asset('/public/assets/admin/img/order-icons/failed.png')}}" alt="dashboard" class="oder--card-icon">
<span>{{ translate('Payment Failed') }}</span>
</h6>
<span class="card-title" style="--base-clr:#FF7500">
{{ $total_failed_count }}
</span>
</div>
</a>
</div>
<div class="col-sm-6 col-lg-4">
<a class="order--card h-100" href="#">
<div class="d-flex justify-content-between align-items-center">
<h6 class="card-subtitle d-flex justify-content-between m-0 align-items-center">
<img src="{{asset('/public/assets/admin/img/order-icons/refunded.png')}}" alt="dashboard" class="oder--card-icon">
<span>{{ translate('Refunded') }}</span>
</h6>
<span class="card-title" style="--base-clr:#FF7500">
{{ $total_refunded_count }}
</span>
</div>
</a>
</div>
</div>
</div>
<!-- End Stats -->
<!-- Card -->
<div class="card mt-3">
<!-- Header -->
<div class="card-header border-0 py-2">
<div class="search--button-wrapper">
<h3 class="card-title">
{{ translate('messages.Total Orders') }} <span
class="badge badge-soft-secondary" id="countItems">{{ $orders->total() }}</span>
</h3>
<form class="search-form">
<!-- Search -->
<div class="input--group input-group input-group-merge input-group-flush">
<input name="search" type="search" class="form-control" value="{{ request()->search ?? null }}" placeholder="{{ translate('Search by Order ID') }}">
<button type="submit" class="btn btn--secondary"><i class="tio-search"></i></button>
</div>
<!-- End Search -->
</form>
<!-- Static Export Button -->
<div class="hs-unfold ml-3">
<a class="js-hs-unfold-invoker btn btn-sm btn-white dropdown-toggle btn export-btn font--sm"
href="javascript:;"
data-hs-unfold-options="{
&quot;target&quot;: &quot;#usersExportDropdown&quot;,
&quot;type&quot;: &quot;css-animation&quot;
}"
data-hs-unfold-target="#usersExportDropdown" data-hs-unfold-invoker="">
<i class="tio-download-to mr-1"></i> {{ translate('export') }}
</a>
<div id="usersExportDropdown"
class="hs-unfold-content dropdown-unfold dropdown-menu dropdown-menu-sm-right hs-unfold-content-initialized hs-unfold-css-animation animated hs-unfold-reverse-y hs-unfold-hidden">
<span class="dropdown-header">{{ translate('download_options') }}</span>
<a id="export-excel" class="dropdown-item"
href="{{ route('admin.report.order-report-export', ['type' => 'excel', request()->getQueryString()]) }}">
<img class="avatar avatar-xss avatar-4by3 mr-2"
src="{{ asset('public/assets/admin/svg/components/excel.svg') }}"
alt="Image Description">
{{ translate('messages.excel') }}
</a>
<a id="export-csv" class="dropdown-item"
href="{{ route('admin.report.order-report-export', ['type' => 'csv', request()->getQueryString()]) }}">
<img class="avatar avatar-xss avatar-4by3 mr-2"
src="{{ asset('public/assets/admin/svg/components/placeholder-csv-format.svg') }}"
alt="Image Description">
.{{ translate('messages.csv') }}
</a>
</div>
</div>
<!-- Static Export Button -->
</div>
</div>
<!-- End Header -->
<!-- Body -->
<div class="card-body p-0">
<div class="table-responsive">
<table class="table table-borderless middle-align __txt-14px">
<thead class="thead-light white--space-false">
<tr>
<th class="border-top border-bottom word-nobreak">{{ translate('messages.sl') }}</th>
<th class="border-top border-bottom word-nobreak">{{ translate('messages.order_id') }}</th>
<th class="border-top border-bottom word-nobreak">{{ translate('messages.restaurant') }}</th>
<th class="border-top border-bottom word-nobreak">{{ translate('messages.customer_name') }}</th>
<th class="border-top border-bottom word-nobreak">{{ translate('messages.total_item_amount') }}</th>
<th class="border-top border-bottom word-nobreak">{{ translate('messages.item_discount') }}</th>
<th class="border-top border-bottom word-nobreak">{{ translate('messages.coupon_discount') }}</th>
<th class="border-top border-bottom word-nobreak">{{ translate('messages.discounted_amount') }}</th>
<th class="border-top border-bottom text-center">{{ translate('messages.tax') }}</th>
<th class="border-top border-bottom word-nobreak">{{ translate('messages.delivery_charge') }}</th>
<th class="border-top border-bottom word-nobreak text-right">{{ translate('messages.order_amount') }}</th>
<th class="border-top border-bottom word-nobreak">{{ translate('messages.amount_received_by') }}</th>
<th class="border-top border-bottom word-nobreak">{{ translate('messages.payment_method') }}</th>
<th class="border-top border-bottom word-nobreak">{{ translate('messages.order_status') }}</th>
<th class="border-top border-bottom text-center">{{ translate('messages.action') }}
</th>
</tr>
</thead>
<tbody id="set-rows">
@foreach ($orders as $key => $order)
<tr class="status-{{ $order['order_status'] }} class-all">
<td class="">
{{ $key + $orders->firstItem() }}
</td>
<td class="table-column-pl-0">
<a
href="{{ route('admin.order.details', ['id' => $order['id']]) }}">{{ $order['id'] }}</a>
</td>
<td class="text-capitalize">
@if($order->restaurant)
{{Str::limit($order->restaurant->name,25,'...')}}
@else
<label class="badge badge-danger">{{ translate('messages.invalid') }}
@endif
</td>
<td>
@if ($order->customer)
<a class="text-body text-capitalize"
href="{{ route('admin.customer.view', [$order['user_id']]) }}">
<strong>{{ $order->customer['f_name'] . ' ' . $order->customer['l_name'] }}</strong>
</a>
@else
<label class="badge badge-danger">{{ translate('messages.invalid') }}
{{ translate('messages.customer') }}
{{ translate('messages.data') }}</label>
@endif
</td>
<td>
<div class="text-right mw--85px">
<div>
{{ \App\CentralLogics\Helpers::number_format_short($order['order_amount']-$order['dm_tips']-$order['total_tax_amount']-$order['delivery_charge']+$order['coupon_discount_amount'] + $order['restaurant_discount_amount']) }}
</div>
@if ($order->payment_status == 'paid')
<strong class="text-success">
{{ translate('messages.paid') }}
</strong>
@else
<strong class="text-danger">
{{ translate('messages.unpaid') }}
</strong>
@endif
</div>
</td>
<td class="text-center mw--85px">
{{ \App\CentralLogics\Helpers::number_format_short($order->details->sum('discount_on_food')) }}
</td>
<td class="text-center mw--85px">
{{ \App\CentralLogics\Helpers::number_format_short($order['coupon_discount_amount']) }}
</td>
<td class="text-center mw--85px">
{{ \App\CentralLogics\Helpers::number_format_short($order['coupon_discount_amount'] + $order['restaurant_discount_amount']) }}
</td>
<td class="text-center mw--85px white-space-nowrap">
{{ \App\CentralLogics\Helpers::number_format_short($order['total_tax_amount']) }}
</td>
<td class="text-center mw--85px">
{{ \App\CentralLogics\Helpers::number_format_short($order['delivery_charge']) }}
</td>
<td>
<div class="text-right mw--85px">
<div>
{{ \App\CentralLogics\Helpers::number_format_short($order['order_amount']) }}
</div>
@if ($order->payment_status == 'paid')
<strong class="text-success">
{{ translate('messages.paid') }}
</strong>
@else
<strong class="text-danger">
{{ translate('messages.unpaid') }}
</strong>
@endif
</div>
</td>
<td class="text-center mw--85px text-capitalize">
{{isset($order->transaction) ? $order->transaction->received_by : translate('messages.not_received_yet')}}
</td>
<td class="text-center mw--85px text-capitalize">
{{ translate(str_replace('_', ' ', $order['payment_method'])) }}
</td>
<td class="text-center mw--85px text-capitalize">
@if($order['order_status']=='pending')
<span class="badge badge-soft-info">
{{translate('messages.pending')}}
</span>
@elseif($order['order_status']=='confirmed')
<span class="badge badge-soft-info">
{{translate('messages.confirmed')}}
</span>
@elseif($order['order_status']=='processing')
<span class="badge badge-soft-warning">
{{translate('messages.processing')}}
</span>
@elseif($order['order_status']=='picked_up')
<span class="badge badge-soft-warning">
{{translate('messages.out_for_delivery')}}
</span>
@elseif($order['order_status']=='delivered')
<span class="badge badge-soft-success">
{{translate('messages.delivered')}}
</span>
@elseif($order['order_status']=='failed')
<span class="badge badge-soft-danger">
{{translate('messages.payment')}} {{translate('messages.failed')}}
</span>
@elseif($order['order_status']=='handover')
<span class="badge badge-soft-danger">
{{translate('messages.handover')}}
</span>
@elseif($order['order_status']=='canceled')
<span class="badge badge-soft-danger">
{{translate('messages.canceled')}}
</span>
@elseif($order['order_status']=='accepted')
<span class="badge badge-soft-danger">
{{translate('messages.accepted')}}
</span>
@else
<span class="badge badge-soft-danger">
{{str_replace('_',' ',$order['order_status'])}}
</span>
@endif
</td>
<td>
<div class="btn--container justify-content-center">
<a class="ml-2 btn btn-sm btn--warning btn-outline-warning action-btn"
href="{{ route('admin.order.details', ['id' => $order['id']]) }}">
<i class="tio-invisible"></i>
</a>
<a class="ml-2 btn btn-sm btn--primary btn-outline-primary action-btn"
href="{{ route('admin.order.generate-invoice', ['id' => $order['id']]) }}">
<i class="tio-print"></i>
</a>
</div>
</td>
</tr>
@endforeach
</tbody>
</table>
</div>
<!-- End Table -->
</div>
<!-- End Body -->
@if (count($orders) !== 0)
<hr>
@endif
<div class="page-area px-4 pb-3">
{!! $orders->links() !!}
</div>
@if (count($orders) === 0)
<div class="empty--data">
<img src="{{ asset('/public/assets/admin/svg/illustrations/sorry.svg') }}" alt="public">
<h5>
{{ translate('no_data_found') }}
</h5>
</div>
@endif
</div>
<!-- End Card -->
</div>
@endsection
@push('script')
@endpush
@push('script_2')
<script src="{{ asset('public/assets/admin') }}/vendor/chart.js/dist/Chart.min.js"></script>
<script src="{{ asset('public/assets/admin') }}/vendor/chartjs-chart-matrix/dist/chartjs-chart-matrix.min.js">
</script>
<script src="{{ asset('public/assets/admin') }}/js/hs.chartjs-matrix.js"></script>
<script>
$(document).on('ready', function() {
$('.js-data-example-ajax').select2({
ajax: {
url: '{{ url('/') }}/admin/restaurant/get-restaurants',
data: function(params) {
return {
q: params.term, // search term
// all:true,
@if (isset($zone))
zone_ids: [{{ $zone->id }}],
@endif
page: params.page
};
},
processResults: function(data) {
return {
results: data
};
},
__port: function(params, success, failure) {
var $request = $.ajax(params);
$request.then(success);
$request.fail(failure);
return $request;
}
}
});
$('.js-data-example-ajax-2').select2({
ajax: {
url: '{{ url('/') }}/admin/customer/select-list',
data: function(params) {
return {
q: params.term, // search term
// all:true,
@if (isset($zone))
zone_ids: [{{ $zone->id }}],
@endif
@if (request('restaurant_id'))
restaurant_id: {{ request('restaurant_id') }},
@endif
page: params.page
};
},
processResults: function(data) {
return {
results: data
};
},
__port: function(params, success, failure) {
var $request = $.ajax(params);
$request.then(success);
$request.fail(failure);
return $request;
}
}
});
});
</script>
<script>
$('#from_date,#to_date').change(function() {
let fr = $('#from_date').val();
let to = $('#to_date').val();
if (fr != '' && to != '') {
if (fr > to) {
$('#from_date').val('');
$('#to_date').val('');
toastr.error('Invalid date range!', Error, {
CloseButton: true,
ProgressBar: true
});
}
}
})
</script>
{{-- <script>
$('#search-form').on('submit', function (e) {
e.preventDefault();
var formData = new FormData(this);
$.ajaxSetup({
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
}
});
$.post({
url: '{{route('admin.report.search_order_report')}}',
data: formData,
cache: false,
contentType: false,
processData: false,
beforeSend: function () {
$('#loading').show();
},
success: function (data) {
$('#set-rows').html(data.view);
$('#countItems').html(data.count);
$('.page-area').hide();
},
complete: function () {
$('#loading').hide();
},
});
});
</script> --}}
@endpush