This commit is contained in:
Kevin Adametz 2020-05-06 15:52:59 +02:00
parent 68b9d1ff88
commit b9c26d06d0
75 changed files with 2143 additions and 818 deletions

View file

@ -43,7 +43,7 @@ class ReportController extends Controller
private function prozessBookingSearch()
{
$query = Booking::with( 'customer', 'lead', 'service_provider_entries', 'service_provider_entries.service_provider');
$query = Booking::with( 'customer', 'lead', 'service_provider_entries', 'service_provider_entries.service_provider')->select('booking.*');
if(Request::get('filter_travel_date_from') != ""){
$travel_date_from = Carbon::parse(Request::get('filter_travel_date_from'))->format("Y-m-d");
@ -74,6 +74,9 @@ class ReportController extends Controller
->with('price_total_sum', function() use ($query) {
return Util::_number_format($query->sum('price'));
})
->with('price_total_total_sum', function() use ($query) {
return Util::_number_format($query->sum('price_total'));
})
->with('proceed_total_sum', function() use ($query) {
if($query->count() > 200){
return 'max 200 ';
@ -81,7 +84,7 @@ class ReportController extends Controller
$all = $query->get();
$proceeds = 0;
foreach ($all as $v){
$proceeds += $v->proceedsRaw();
$proceeds += $v->proceeds(true);
}
return Util::_number_format($proceeds);
})
@ -116,8 +119,7 @@ class ReportController extends Controller
return $ret === "" ? "-" : $ret;
})
->addColumn('lead.status_id', function (Booking $booking) {
//umbuchen
if($booking->lead->status_id){
if($booking->lead && $booking->lead->status_id){
$color = $booking->lead->status->color;
$icon = "";
if($booking->lead->status_id == 14 && $booking->lead->is_rebook){
@ -166,6 +168,7 @@ class ReportController extends Controller
'BuchungsID',
'Status',
'MyJack Nr.',
'Organisation',
'Reisepreis',
'Erlös',
'Kunde',
@ -182,6 +185,7 @@ class ReportController extends Controller
'abgeschlossen',
);
$total_price = 0;
$total_price_total = 0;
$total_proceeds = 0;
$total_amount_final = 0;
@ -191,14 +195,16 @@ class ReportController extends Controller
foreach ($export->service_provider_entries as $service_provider_entry){
if($new){
$total_price += $export->getPriceRaw();
$total_proceeds += $export->proceedsRaw();
$total_price_total += $export->getPriceTotalRaw();
$total_proceeds += $export->proceeds(true);
}
$total_amount_final += $service_provider_entry->getAmountFinalEurRaw();
$columns[] = array(
'BuchungsID' => $new ? $export->id : "",
'Status' => $new ? $export->lead->status->name : "",
'MyJack Nr.' => $new ? $export->merlin_order_number : "",
'Reisepreis' => $new ? $export->price : "",
'Organisation' => $new ? $export->price : "",
'Reisepreis' => $new ? $export->price_total : "",
'Erlös' => $new ? $export->proceeds() : "",
'Kunde' => $new ? $export->customer->fullName() : "",
'Reisedatum' => $new ? $export->getStartDateFormat() : "",
@ -222,7 +228,8 @@ class ReportController extends Controller
'BuchungsID' => $export->id,
'Status' => $export->lead->status->name,
'MyJack Nr.' => $export->merlin_order_number,
'Reisepreis' => $export->price,
'Organisation' => $export->price,
'Reisepreis' => $export->price_total,
'Erlös' => $export->proceeds(),
'Kunde' => $export->customer->fullName(),
'Reisedatum' => $export->getStartDateFormat(),
@ -244,7 +251,8 @@ class ReportController extends Controller
'BuchungsID' => "Total",
'Status' => "",
'MyJack Nr.' => "",
'Reisepreis' => Util::_number_format($total_price),
'Organisation' => Util::_number_format($total_price),
'Reisepreis' => Util::_number_format($total_price_total),
'Erlös' => Util::_number_format($total_proceeds),
'Kunde' => "",
'Reisedatum' => "",
@ -266,7 +274,7 @@ class ReportController extends Controller
private function prozessProvidersSearch(){
$query = ServiceProviderEntry::with('booking', 'service_provider', 'booking.customer');
$query = ServiceProviderEntry::with('booking', 'service_provider', 'booking.customer')->select('service_provider_entry.*');
if(Request::get('filter_is_cleared') != ""){
$query->where('is_cleared', '=', Request::get('filter_is_cleared'));
}
@ -299,11 +307,24 @@ class ReportController extends Controller
if($query->count() > 200){
return 'max 200 ';
}
$all = $query->get();
$price = 0;
$isset = [];
foreach ($all as $v){
$price += in_array($v->booking->lead_id, $isset) ? 0 : $v->booking->getPriceRaw();
$isset[] = $v->booking->lead_id;
}
return Util::_number_format($price);
})
->with('price_total_total_sum', function() use ($query) {
if($query->count() > 200){
return 'max 200 ';
}
$all = $query->get();
$price = 0;
$isset = [];
foreach ($all as $v){
$price += in_array($v->booking->lead_id, $isset) ? 0 : $v->booking->getPriceRaw();
$price += in_array($v->booking->lead_id, $isset) ? 0 : $v->booking->getPriceTotalRaw();
$isset[] = $v->booking->lead_id;
}
return Util::_number_format($price);
@ -316,14 +337,14 @@ class ReportController extends Controller
$proceeds = 0;
$isset = [];
foreach ($all as $v){
$proceeds += in_array($v->booking->lead_id, $isset) ? 0 : $v->booking->proceedsRaw();
$proceeds += in_array($v->booking->lead_id, $isset) ? 0 : $v->booking->proceeds(true);
$isset[] = $v->booking->lead_id;
}
return Util::_number_format($proceeds);
/*$all = $query->get();
$proceeds = 0;
foreach ($all as $v){
$proceeds += $v->proceedsRaw();
$proceeds += $v->proceeds(true);
}
return Util::_number_format($proceeds);*/
})
@ -384,6 +405,7 @@ class ReportController extends Controller
'CRM Nr',
'Kunde',
'Reisedatum',
'Organisation',
'Gesamtreisepreis',
'Reiseland',
'Reiseprogramm',
@ -397,13 +419,15 @@ class ReportController extends Controller
);
$isset = [];
$total_price = 0;
$total_price_total = 0;
$total_amount_final = 0;
$total_proceeds = 0;
foreach($exports as $export) {
$new = in_array($export->booking->lead_id, $isset) ? false : true;
if($new){
$total_price += $export->booking->getPriceRaw();
$total_proceeds += $export->booking->proceedsRaw();
$total_price_total += $export->booking->getPriceTotalRaw();
$total_proceeds += $export->booking->proceeds(true);
}
$total_amount_final += $export->getAmountFinalEurRaw();
$columns[] = array(
@ -412,7 +436,8 @@ class ReportController extends Controller
'CRM Nr' => $new ? $export->booking->lead_id : "",
'Kunde' => $new ? $export->booking->customer->name : "",
'Reisedatum' => $new ? $export->booking->getStartDateFormat() : "",
'Gesamtreisepreis' => $new ? $export->booking->price : "",
'Organisation' => $new ? $export->booking->price : "",
'Gesamtreisepreis' => $new ? $export->booking->price_total : "",
'Reiseland' => $new ? $export->booking->travel_country->name : "",
'Reiseprogramm' => $new ? $export->booking->travel_agenda->name : "",
'Reiseteilnehmer' => $new ? $export->booking->pax : "",
@ -431,7 +456,8 @@ class ReportController extends Controller
'CRM Nr' => "",
'Kunde' =>"",
'Reisedatum' => "",
'Gesamtreisepreis' => Util::_number_format($total_price),
'Organisation' => Util::_number_format($total_price),
'Gesamtreisepreis' => Util::_number_format($total_price_total),
'Reiseland' => "",
'Reiseprogramm' => "",
'Reiseteilnehmer' => "",
@ -466,7 +492,7 @@ class ReportController extends Controller
foreach($exports as $export) {
$new = in_array($export->booking->lead_id, $isset) ? false : true;
if($new) {
$payments_total += $export->booking->getServiceProviderPaymentsTotalRaw();
$payments_total += $export->booking->getServiceProviderPaymentsTotal(true);
}
$total_amount_final += $export->getAmountFinalEurRaw();
$columns[] = array(