last 12.21
This commit is contained in:
parent
73e38a006e
commit
3df0e93c2c
14 changed files with 395 additions and 43 deletions
|
|
@ -11,6 +11,7 @@ use App\Models\Status;
|
|||
use App\Services\Util;
|
||||
use App\Models\Booking;
|
||||
use App\Models\TravelAgenda;
|
||||
use App\Models\TravelCompany;
|
||||
use App\Models\ServiceProvider;
|
||||
use Illuminate\Validation\Rules\In;
|
||||
use App\Http\Controllers\Controller;
|
||||
|
|
@ -29,6 +30,8 @@ class ReportController extends Controller
|
|||
{
|
||||
$data = [
|
||||
'filter_lead_status' => Status::get()->pluck('name', 'id')->toArray(),
|
||||
'filter_travel_companies' => TravelCompany::where('active', true)->get()->pluck('name', 'id')->toArray(),
|
||||
|
||||
];
|
||||
return view('admin.report.bookings', $data);
|
||||
}
|
||||
|
|
@ -38,10 +41,24 @@ class ReportController extends Controller
|
|||
$data = [
|
||||
'serviceProviders' => ServiceProvider::all(),
|
||||
'filter_lead_status' => Status::get()->pluck('name', 'id')->toArray(),
|
||||
'filter_travel_companies' => TravelCompany::where('active', true)->get()->pluck('name', 'id')->toArray(),
|
||||
|
||||
];
|
||||
return view('admin.report.service_providers', $data);
|
||||
}
|
||||
|
||||
public function checkBookings()
|
||||
{
|
||||
$data = [
|
||||
'filter_lead_status' => Status::get()->pluck('name', 'id')->toArray(),
|
||||
'filter_travel_companies' => TravelCompany::where('active', true)->get()->pluck('name', 'id')->toArray(),
|
||||
|
||||
];
|
||||
return view('admin.report.check_bookings', $data);
|
||||
}
|
||||
|
||||
//checkBookingsDatatable
|
||||
|
||||
private function prozessBookingSearch()
|
||||
{
|
||||
|
||||
|
|
@ -59,6 +76,10 @@ class ReportController extends Controller
|
|||
$q->whereIn('status_id', Request::get('filter_lead_status_id'));
|
||||
});
|
||||
}
|
||||
if(Request::get('filter_travel_company_id') != ""){
|
||||
$query->whereIn("travel_company_id", Request::get('filter_travel_company_id'));
|
||||
}
|
||||
|
||||
if(Request::get('filter_travel_date_from') != ""){
|
||||
$travel_date_from = Carbon::parse(Request::get('filter_travel_date_from'))->format("Y-m-d");
|
||||
$query->where("start_date", '>=', $travel_date_from);
|
||||
|
|
@ -86,7 +107,9 @@ class ReportController extends Controller
|
|||
|
||||
return \DataTables::eloquent($query)
|
||||
->with('price_total_sum', function() use ($query) {
|
||||
return Util::_number_format($query->sum('price'));
|
||||
$price1 = with(clone $query)->whereNull('canceled')->sum('price');
|
||||
$price2 = with(clone $query)->whereNotNull('canceled')->sum('price_canceled');
|
||||
return Util::_number_format($price1+$price2);
|
||||
})
|
||||
->with('price_total_total_sum', function() use ($query) {
|
||||
return Util::_number_format($query->sum('price_total'));
|
||||
|
|
@ -108,6 +131,9 @@ class ReportController extends Controller
|
|||
->addColumn('customer.fullName', function (Booking $booking) {
|
||||
return $booking->customer->fullName();
|
||||
})
|
||||
->addColumn('price', function (Booking $booking) {
|
||||
return $booking->booking_strono ? $booking->price_canceled : $booking->price;
|
||||
})
|
||||
->addColumn('proceeds', function (Booking $booking) {
|
||||
return $booking->proceeds();
|
||||
})
|
||||
|
|
@ -161,6 +187,7 @@ class ReportController extends Controller
|
|||
->orderColumn('id', 'id $1')
|
||||
->orderColumn('start_date', 'start_date $1')
|
||||
->orderColumn('end_date', 'end_date $1')
|
||||
->orderColumn('price', 'price $1')
|
||||
->orderColumn('booking_date', 'booking_date $1')
|
||||
->orderColumn('customer.fullName', 'customer.firstname $1')
|
||||
->orderColumn('customer.firstname', 'customer.firstname $1')
|
||||
|
|
@ -230,7 +257,7 @@ class ReportController extends Controller
|
|||
$new = true;
|
||||
foreach ($export->service_provider_entries as $service_provider_entry){
|
||||
if($new){
|
||||
$total_price += $export->getPriceRaw();
|
||||
$total_price += $export->isCanceled() ? $export->getPriceCanceledRaw() : $export->getPriceRaw();
|
||||
$total_price_total += $export->getPriceTotalRaw();
|
||||
$total_proceeds += $export->proceeds(true);
|
||||
}
|
||||
|
|
@ -240,7 +267,7 @@ class ReportController extends Controller
|
|||
'Status' => $new ? $export->lead->status->name : "",
|
||||
'Storno' => $new ? $storno_date : "",
|
||||
'MyJack Nr.' => $new ? $export->merlin_order_number : "",
|
||||
'Organisation' => $new ? $export->price : "",
|
||||
'Organisation' => $new ? ($export->isCanceled() ? $export->price_canceled : $export->price) : "",
|
||||
'Reisepreis' => $new ? $export->price_total : "",
|
||||
'Erlös' => $new ? $export->proceeds() : "",
|
||||
'Kunde' => $new ? $export->customer->fullName() : "",
|
||||
|
|
@ -260,13 +287,14 @@ class ReportController extends Controller
|
|||
$new = false;
|
||||
}
|
||||
}else{
|
||||
$total_price += $export->getPriceRaw();
|
||||
$total_price += $export->booking->isCanceled() ? $export->booking->getPriceCanceledRaw() : $export->booking->getPriceRaw();
|
||||
$columns[] = array(
|
||||
'BuchungsID' => $export->id,
|
||||
'Status' => $export->lead->status->name,
|
||||
'Storno' => $storno_date,
|
||||
'MyJack Nr.' => $export->merlin_order_number,
|
||||
'Organisation' => $export->price,
|
||||
'Organisation' => $export->isCanceled() ? $export->price_canceled : $export->price,
|
||||
'Reisepreis' => $export->price_total,
|
||||
'Erlös' => $export->proceeds(),
|
||||
'Kunde' => $export->customer->fullName(),
|
||||
|
|
@ -330,7 +358,11 @@ class ReportController extends Controller
|
|||
});
|
||||
});
|
||||
}
|
||||
|
||||
if(Request::get('filter_travel_company_id') != ""){
|
||||
$query->whereHas('booking', function ($q) {
|
||||
$q->whereIn("travel_company_id", Request::get('filter_travel_company_id'));
|
||||
});
|
||||
}
|
||||
if(Request::get('filter_is_cleared') != ""){
|
||||
$query->where('is_cleared', '=', Request::get('filter_is_cleared'));
|
||||
}
|
||||
|
|
@ -366,8 +398,11 @@ class ReportController extends Controller
|
|||
$price = 0;
|
||||
$isset = [];
|
||||
foreach ($all as $v){
|
||||
$price += in_array($v->booking->lead_id, $isset) ? 0 : $v->booking->getPriceRaw();
|
||||
if(!in_array($v->booking->lead_id, $isset)){
|
||||
$price += $v->booking->isCanceled() ? $v->booking->getPriceCanceledRaw() : $v->booking->getPriceRaw();
|
||||
}
|
||||
$isset[] = $v->booking->lead_id;
|
||||
|
||||
}
|
||||
return Util::_number_format($price);
|
||||
})
|
||||
|
|
@ -409,6 +444,9 @@ class ReportController extends Controller
|
|||
->addColumn('booking.customer.fullName', function (ServiceProviderEntry $serviceProviderEntry) {
|
||||
return $serviceProviderEntry->booking->customer->fullName();
|
||||
})
|
||||
->addColumn('booking.price', function (ServiceProviderEntry $serviceProviderEntry) {
|
||||
return $serviceProviderEntry->booking->booking_strono ? $serviceProviderEntry->booking->price_canceled : $serviceProviderEntry->booking->price;
|
||||
})
|
||||
->addColumn('booking.proceeds', function (ServiceProviderEntry $serviceProviderEntry) {
|
||||
return $serviceProviderEntry->booking->proceeds();
|
||||
})
|
||||
|
|
@ -447,6 +485,7 @@ class ReportController extends Controller
|
|||
}
|
||||
})
|
||||
->orderColumn('booking.id', 'booking.id $1')
|
||||
->orderColumn('booking.price', 'booking.price $1')
|
||||
->orderColumn('booking.start_date', 'booking.start_date $1')
|
||||
->orderColumn('booking.end_date', 'booking.end_date $1')
|
||||
->orderColumn('booking.customer.firstname', 'booking.customer.firstname $1')
|
||||
|
|
@ -513,7 +552,7 @@ class ReportController extends Controller
|
|||
foreach($exports as $export) {
|
||||
$new = in_array($export->booking->id, $isset) ? false : true;
|
||||
if($new){
|
||||
$total_price += $export->booking->getPriceRaw();
|
||||
$total_price += $export->booking->isCanceled() ? $export->booking->getPriceCanceledRaw() : $export->booking->getPriceRaw();
|
||||
$total_price_total += $export->booking->getPriceTotalRaw();
|
||||
$total_proceeds += $export->booking->proceeds(true);
|
||||
}
|
||||
|
|
@ -524,7 +563,7 @@ class ReportController extends Controller
|
|||
'CRM Nr' => $new ? $export->booking->lead_id : "",
|
||||
'Kunde' => $new ? $export->booking->customer->name : "",
|
||||
'Reisedatum' => $new ? $export->booking->getStartDateFormat() : "",
|
||||
'Organisation' => $new ? $export->booking->price : "",
|
||||
'Organisation' => $new ? ($export->booking->isCanceled() ? $export->booking->price_canceled : $export->booking->price) : "",
|
||||
'Gesamtreisepreis' => $new ? $export->booking->price_total : "",
|
||||
'Reiseland' => $new && $export->booking->travel_country ? $export->booking->travel_country->name : "",
|
||||
'Reiseprogramm' => $new && $export->booking->travel_agenda ? $export->booking->travel_agenda->name : "",
|
||||
|
|
@ -622,6 +661,75 @@ class ReportController extends Controller
|
|||
}
|
||||
return Excel::download(new ReportCollectionExport($columns, $headers), $filename.'.xls');
|
||||
}
|
||||
|
||||
public function checkBookingsDatatable()
|
||||
{
|
||||
$query = $this->prozessBookingSearch();
|
||||
return \DataTables::eloquent($query)
|
||||
->addColumn('id', function (Booking $booking) {
|
||||
return '<a data-order="' . $booking->id . '" href="' . route('booking_detail', [$booking->id]) . '" data-id="' . $booking->id . '">' . $booking->id . '</a>';
|
||||
})
|
||||
->addColumn('old_crm', function (Booking $booking) {
|
||||
return '<a data-order="'.$booking->id.'" href="'.make_old_url('booking/'.$booking->id.'/edit').'" data-id="'.$booking->id.'">'.$booking->id.'</a>';
|
||||
})
|
||||
->addColumn('id', function (Booking $booking) {
|
||||
return '<a data-order="' . $booking->id . '" href="' . route('booking_detail', [$booking->id]) . '" data-id="' . $booking->id . '">' . $booking->id . '</a>';
|
||||
})
|
||||
->addColumn('price', function (Booking $booking) {
|
||||
return $booking->price;
|
||||
})
|
||||
->addColumn('service_total', function (Booking $booking) {
|
||||
return $booking->getServiceTotal();
|
||||
})
|
||||
->addColumn('price_total', function (Booking $booking) {
|
||||
return $booking->price_total;
|
||||
})
|
||||
->addColumn('check_total', function (Booking $booking) {
|
||||
$check = $booking->getPriceRaw() + $booking->getServiceTotal(true);
|
||||
return ($booking->getPriceTotalRaw() != $check) ? '<span class="badge badge-danger">'.Util::_number_format($check).'</span>' : "";
|
||||
})
|
||||
->addColumn('price_canceled', function (Booking $booking) {
|
||||
return $booking->isCanceled() ? $booking->price_canceled : "";
|
||||
})
|
||||
|
||||
->addColumn('start_date', function (Booking $booking) {
|
||||
return $booking->getStartDateFormat();
|
||||
})
|
||||
->addColumn('end_date', function (Booking $booking) {
|
||||
return $booking->getEndDateFormat();
|
||||
})
|
||||
->addColumn('booking_date', function (Booking $booking) {
|
||||
return $booking->getBookingDateFormat();
|
||||
})
|
||||
|
||||
->addColumn('lead.status_id', function (Booking $booking) {
|
||||
if($booking->lead && $booking->lead->status_id){
|
||||
$color = $booking->lead->status->color;
|
||||
$icon = "";
|
||||
if($booking->lead->status_id == 14 && $booking->lead->is_rebook){
|
||||
$color = '#94ae59';
|
||||
$icon = '<i class="fa fa-check-circle"></i> ';
|
||||
}
|
||||
if($booking->lead->status_id == 14 && !$booking->lead->is_rebook){
|
||||
$icon = '<i class="fa fa-times-circle"></i> ';
|
||||
}
|
||||
return '<span data-order="'.$booking->lead->status_id.'"><span class="badge badge-dark" style="background-color: '.$color.'">'.$icon.$booking->lead->status->name.'</span></span>';
|
||||
}
|
||||
return '<span data-order="0">-</span>';
|
||||
})
|
||||
->orderColumn('id', 'id $1')
|
||||
->orderColumn('old_crm', 'old_crm $1')
|
||||
->orderColumn('start_date', 'start_date $1')
|
||||
->orderColumn('end_date', 'end_date $1')
|
||||
->orderColumn('price', 'price $1')
|
||||
->orderColumn('booking_date', 'booking_date $1')
|
||||
->orderColumn('customer.firstname', 'customer.firstname $1')
|
||||
->orderColumn('customer.name', 'customer.name $1')
|
||||
//->orderColumn('lead.status_id', 'lead.status_id $1')
|
||||
//->orderColumn('is_cleared', 'is_cleared $1')
|
||||
->rawColumns(['id', 'old_crm', 'check_total', 'lead.status_id'])
|
||||
->make(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue