From b9c26d06d00c57b66cade1c5115a368844e746b7 Mon Sep 17 00:00:00 2001 From: Kevin Adametz Date: Wed, 6 May 2020 15:52:59 +0200 Subject: [PATCH] Mails --- .idea/workspace.xml | 182 +++++++------ .phpstorm.meta.php | 2 +- _ide_helper.php | 2 +- _ide_helper_models.php | 3 + .../Controllers/Admin/ReportController.php | 58 +++-- app/Http/Controllers/BookingController.php | 1 - .../CMS/CMSContentCountryController.php | 86 ------- app/Http/Controllers/CustomerController.php | 2 +- .../Controllers/CustomerMailController.php | 53 +++- app/Http/Controllers/LeadController.php | 2 +- app/Http/Controllers/RequestController.php | 17 +- .../Settings/AirlineController.php | 10 +- .../Settings/EmailTemplateController.php | 75 ++++++ .../Settings/InsuranceController.php | 55 ++++ .../Settings/ServiceProviderController.php | 57 +++++ .../Settings/TravelCompanyController.php | 58 +++++ .../Settings/TravelCountryController.php | 89 ++++--- .../Settings/TravelNationalityController.php | 2 +- app/Models/Airline.php | 6 - app/Models/Booking.php | 153 ++++++----- app/Models/BookingServiceItem.php | 11 + app/Models/EmailTemplate.php | 39 +++ app/Models/Insurance.php | 42 +++ app/Models/ServiceProvider.php | 15 +- app/Models/TravelCompany.php | 28 +- app/Models/TravelCountry.php | 7 - app/Repositories/CustomerMailRepository.php | 33 +-- app/Repositories/FileRepository.php | 10 + app/Services/HTMLHelper.php | 4 + app/Services/Placeholder.php | 68 +++++ app/Services/Util.php | 7 - config/permissions.php | 18 +- ...2018_10_29_202123_create_booking_table.php | 1 + ..._29_154619_create_travel_company_table.php | 5 +- ...4_160054_create_service_provider_table.php | 2 + ...0_04_23_144804_create_insurances_table.php | 35 +++ ...23_144838_create_email_templates_table.php | 34 +++ public/css/application.css | 26 ++ public/js/custom.js | 8 +- .../views/admin/report/bookings.blade.php | 4 + .../admin/report/service_providers.blade.php | 4 + .../views/booking/_detail_mails.blade.php | 2 - .../views/booking/_detail_price.blade.php | 120 ++++++++- resources/views/booking/detail.blade.php | 6 +- .../cms/content/country/detail.blade.php | 210 --------------- .../mail/modal-new-booking-files.blade.php | 12 +- .../customer/mail/modal-new-mail.blade.php | 105 +++++++- resources/views/layouts/application.blade.php | 4 +- .../layouts/includes/layout-sidenav.blade.php | 71 +++--- resources/views/request/index.blade.php | 5 +- .../settings/_travel_country/detail.blade.php | 116 +++++++++ .../_travel_country}/index.blade.php | 42 +-- .../views/settings/airline/index.blade.php | 6 +- .../settings/email_template/index.blade.php | 64 +++++ .../settings/email_template/modal.blade.php | 95 +++++++ .../views/settings/insurance/index.blade.php | 112 ++++++++ .../views/settings/keywords/index.blade.php | 10 +- .../settings/service_provider/index.blade.php | 123 +++++++++ .../settings/travel_agenda/index.blade.php | 9 +- .../settings/travel_company/index.blade.php | 145 +++++++++++ .../settings/travel_country/detail.blade.php | 240 ++++++++++++------ .../settings/travel_country/index.blade.php | 41 +-- .../travel_nationality/index.blade.php | 18 +- routes/web.php | 91 ++++--- ...5e99b543e42254.12049207_reiseanmeldung.pdf | Bin 0 -> 100150 bytes ...99b544a84a15.70270514_reisebestätigung.pdf | Bin 0 -> 99873 bytes ...b85.31250574_gutschein2022588047711038.pdf | Bin 0 -> 132866 bytes ...4.96026058_sicherungsscheinnachsis651r.pdf | Bin 0 -> 584904 bytes .../04/5e99b54ba91d07.08332553_ust111.pdf | Bin 0 -> 7008 bytes ...5e99b57f1c31f0.70883767_reiseanmeldung.pdf | Bin 0 -> 100150 bytes ...5e99b580163fe3.60366976_reiseanmeldung.pdf | Bin 0 -> 100150 bytes .../2020/04/5ea838f251e0d0.53693491_8.jpg | Bin 0 -> 275529 bytes ...2698_muscat-sultan-qaboos-moschee-h1_k.jpg | Bin 0 -> 5416550 bytes ...ea85937d5bf78.04249430_jdatlastoollogo.png | Bin 0 -> 9548 bytes ...8975_muscat-sultan-qaboos-moschee-h1_k.jpg | Bin 0 -> 5416550 bytes 75 files changed, 2143 insertions(+), 818 deletions(-) delete mode 100755 app/Http/Controllers/CMS/CMSContentCountryController.php create mode 100755 app/Http/Controllers/Settings/EmailTemplateController.php create mode 100755 app/Http/Controllers/Settings/InsuranceController.php create mode 100755 app/Http/Controllers/Settings/ServiceProviderController.php create mode 100755 app/Http/Controllers/Settings/TravelCompanyController.php create mode 100644 app/Models/EmailTemplate.php create mode 100644 app/Models/Insurance.php create mode 100644 app/Services/Placeholder.php create mode 100644 database/migrations/2020_04_23_144804_create_insurances_table.php create mode 100644 database/migrations/2020_04_23_144838_create_email_templates_table.php delete mode 100755 resources/views/cms/content/country/detail.blade.php create mode 100755 resources/views/settings/_travel_country/detail.blade.php rename resources/views/{cms/content/country => settings/_travel_country}/index.blade.php (75%) create mode 100755 resources/views/settings/email_template/index.blade.php create mode 100755 resources/views/settings/email_template/modal.blade.php create mode 100755 resources/views/settings/insurance/index.blade.php create mode 100755 resources/views/settings/service_provider/index.blade.php create mode 100755 resources/views/settings/travel_company/index.blade.php create mode 100644 storage/app/customer/attachment/2020/04/5e99b543e42254.12049207_reiseanmeldung.pdf create mode 100644 storage/app/customer/attachment/2020/04/5e99b544a84a15.70270514_reisebestätigung.pdf create mode 100644 storage/app/customer/attachment/2020/04/5e99b546a93b85.31250574_gutschein2022588047711038.pdf create mode 100644 storage/app/customer/attachment/2020/04/5e99b5497293f4.96026058_sicherungsscheinnachsis651r.pdf create mode 100644 storage/app/customer/attachment/2020/04/5e99b54ba91d07.08332553_ust111.pdf create mode 100644 storage/app/customer/attachment/2020/04/5e99b57f1c31f0.70883767_reiseanmeldung.pdf create mode 100644 storage/app/customer/attachment/2020/04/5e99b580163fe3.60366976_reiseanmeldung.pdf create mode 100644 storage/app/customer/attachment/2020/04/5ea838f251e0d0.53693491_8.jpg create mode 100644 storage/app/customer/attachment/2020/04/5ea8590b019148.46292698_muscat-sultan-qaboos-moschee-h1_k.jpg create mode 100644 storage/app/customer/attachment/2020/04/5ea85937d5bf78.04249430_jdatlastoollogo.png create mode 100644 storage/app/customer/attachment/2020/04/5ea859563f7df6.49508975_muscat-sultan-qaboos-moschee-h1_k.jpg diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 3fb632e..c4711f0 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -2,10 +2,15 @@ - - - - + + + + + + + + + @@ -25,71 +30,50 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + - - + + + - + + + + - - + + - + - + + - + + + @@ -139,15 +123,24 @@ + + + + - - + + + - - + + + + + + - - - - - + + + + + + - @@ -743,6 +737,27 @@ + + + + + + + + + + + + + + + + + + + + + @@ -793,15 +808,31 @@ - + - + + + + + + + + + + + + + + + + + @@ -816,18 +847,19 @@ - - + + - + + - + - + diff --git a/.phpstorm.meta.php b/.phpstorm.meta.php index 7234018..a3bfc43 100644 --- a/.phpstorm.meta.php +++ b/.phpstorm.meta.php @@ -5,7 +5,7 @@ namespace PHPSTORM_META { /** * PhpStorm Meta file, to provide autocomplete information for PhpStorm - * Generated on 2020-04-16 17:05:54. + * Generated on 2020-04-23 10:42:35. * * @author Barry vd. Heuvel * @see https://github.com/barryvdh/laravel-ide-helper diff --git a/_ide_helper.php b/_ide_helper.php index 287984a..e33edb2 100644 --- a/_ide_helper.php +++ b/_ide_helper.php @@ -3,7 +3,7 @@ /** * A helper file for Laravel 5, to provide autocomplete information to your IDE - * Generated for Laravel 6.18.5 on 2020-04-16 17:05:52. + * Generated for Laravel 6.18.5 on 2020-04-23 10:42:32. * * This file should not be included in your code, only analyzed by your IDE! * diff --git a/_ide_helper_models.php b/_ide_helper_models.php index 20ce48e..d0e2c01 100644 --- a/_ide_helper_models.php +++ b/_ide_helper_models.php @@ -456,6 +456,8 @@ namespace App\Models{ * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Booking whereOriginStartDate($value) * @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\BookingFile[] $booking_files * @property-read int|null $booking_files_count + * @property float|null $price_balance + * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Booking wherePriceBalance($value) */ class Booking extends \Eloquent {} } @@ -3272,6 +3274,7 @@ namespace App\Models{ * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\BookingFile whereOriginalName($value) * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\BookingFile whereSize($value) * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\BookingFile whereUpdatedAt($value) + * @mixin \Eloquent */ class BookingFile extends \Eloquent {} } diff --git a/app/Http/Controllers/Admin/ReportController.php b/app/Http/Controllers/Admin/ReportController.php index b59c371..9a2b6cc 100755 --- a/app/Http/Controllers/Admin/ReportController.php +++ b/app/Http/Controllers/Admin/ReportController.php @@ -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( diff --git a/app/Http/Controllers/BookingController.php b/app/Http/Controllers/BookingController.php index bdcb310..2a672d4 100755 --- a/app/Http/Controllers/BookingController.php +++ b/app/Http/Controllers/BookingController.php @@ -203,7 +203,6 @@ class BookingController extends Controller $ret = CustomerMailRepository::loadModal($data); } - if($data['action'] === "modal-upload-booking-file") { $ret = view("booking.upload_modal", compact('data'))->render(); } diff --git a/app/Http/Controllers/CMS/CMSContentCountryController.php b/app/Http/Controllers/CMS/CMSContentCountryController.php deleted file mode 100755 index 9c79464..0000000 --- a/app/Http/Controllers/CMS/CMSContentCountryController.php +++ /dev/null @@ -1,86 +0,0 @@ -middleware('admin'); - - } - - public function index($step = false) - { - $data = [ - 'travel_countries' => TravelCountry::all(), - ]; - return view('cms.content.country.index', $data); - } - - public function detail($id, $step = false) - { - $model = TravelCountry::findOrFail($id); - $id = $model->id; - - $data = [ - 'model' => $model, - 'id' => $id, - 'step' => $step, - 'travel_nationalities' => TravelNationality::where('active', true)->get(), - ]; - return view('cms.content.country.detail', $data); - } - - - - public function store($id) - { - - $data = Request::all(); - if(isset($data['contact_emails'])){ - $data['contact_emails'] = explode('#', str_replace(array("\r\n", "\r", "\n"),"#",$data['contact_emails'])); - }else{ - $data['contact_emails'] = null; - } - if(!isset($data['contact_lands'])){ - $data['contact_lands'] = null; - } - $model = TravelCountry::findOrFail($id); - $model->fill($data); - $model->save(); - - //travel_nationality_requirement - if (isset($data['travel_nationality_requirement'])) { - foreach ($data['travel_nationality_requirement'] as $travel_nationality_id => $text) { - $model->setNationalityRequirement($travel_nationality_id, $text); - } - } - - //TODO for this time - if ($data['action'] == 'contact') { - //we need an update in the old CRM v1 system DB - $tc = \App\Models\Sym\TravelCountry::findOrFail($model->crm_id); - $tc->fill($data); - $tc->save(); - } - \Session()->flash('alert-save', '1'); - return redirect(route('cms_content_country_detail', [$model->id, $data['action']])); - } - -} diff --git a/app/Http/Controllers/CustomerController.php b/app/Http/Controllers/CustomerController.php index a9ad289..0d06912 100755 --- a/app/Http/Controllers/CustomerController.php +++ b/app/Http/Controllers/CustomerController.php @@ -62,7 +62,7 @@ class CustomerController extends Controller public function getCustomers() { - $query = Customer::with('salutation'); + $query = Customer::with('salutation')->select('customer.*'); return \DataTables::eloquent($query) ->addColumn('action_edit', function (Customer $customer) { diff --git a/app/Http/Controllers/CustomerMailController.php b/app/Http/Controllers/CustomerMailController.php index 15c00e0..5747072 100755 --- a/app/Http/Controllers/CustomerMailController.php +++ b/app/Http/Controllers/CustomerMailController.php @@ -5,6 +5,7 @@ namespace App\Http\Controllers; use App\Models\Customer; use App\Models\CustomerFile; use App\Models\CustomerMail; +use App\Models\EmailTemplate; use App\Repositories\CustomerMailRepository; use App\Repositories\CustomerFileRepository; use App\Services\Util; @@ -136,7 +137,7 @@ class CustomerMailController extends Controller public function getCustomerMails() { - $query = CustomerMail::with('booking')->with('customer'); + $query = CustomerMail::with('booking')->with('customer')->select('customer_mails.*'); return \DataTables::eloquent($query) ->addColumn('action_edit', function (CustomerMail $customer_mail) { @@ -183,6 +184,37 @@ class CustomerMailController extends Controller ->make(true); } + public function getEmailTemplates() + { + $query = EmailTemplate::where('active', '=', true); + + return \DataTables::eloquent($query) + ->addColumn('action', function (EmailTemplate $emailTemplate) { + return ''; + }) + ->orderColumn('id', 'id $1') + ->orderColumn('subject', 'subject $1') + ->orderColumn('message', 'message $1') + ->filterColumn('id', function($query, $keyword) { + if($keyword != ""){ + $query->where('id', 'LIKE', '%'.$keyword.'%'); + } + }) + ->filterColumn('subject', function($query, $keyword) { + if($keyword != ""){ + $query->where('subject', 'LIKE', '%'.$keyword.'%'); + $query->OrWhere('message', 'LIKE', '%'.$keyword.'%'); + + } + }) + ->rawColumns(['action']) + ->make(true); + } + + + public function uploadAttachment($id){ $fileRepo = new CustomerFileRepository(new CustomerFile()); @@ -212,6 +244,20 @@ class CustomerMailController extends Controller $customer_mail->save(); $status = 'success'; } + if($data['action'] === 'load_email_template'){ + $email_template = EmailTemplate::find($data['id']); + $ret = $email_template->message; + $data['subject'] = $email_template->subject; + $status = 'success'; + } + if($data['action'] === 'delete_mail_attachment'){ + $customer_file = CustomerFile::find($data['id']); + $fileRepo = new CustomerFileRepository($customer_file); + $fileRepo->_set('disk', 'customer'); + $ret = $fileRepo->delete(); + $status = 'success'; + } + if($data['action'] === 'add_attachment'){ $arrContextOptions=array( "ssl"=>array( @@ -219,10 +265,7 @@ class CustomerMailController extends Controller "verify_peer_name"=>false, ), ); - $contents = file_get_contents($data['target'], false, stream_context_create($arrContextOptions)); - - $mine = Util::getMimeFromHeader($http_response_header); $extension = Util::getExtensionFromMime($mine); $fileRepo = new CustomerFileRepository(new CustomerFile()); @@ -234,7 +277,6 @@ class CustomerMailController extends Controller $fileRepo->_set('originalName', $data['name']); $fileRepo->_set('mine', $mine); $fileRepo->_set('extension', $extension); - return $fileRepo->storeFile($contents); } } @@ -246,7 +288,6 @@ class CustomerMailController extends Controller if (!Request::get('booking_id')) { return false; } - $query = CustomerMail::where('booking_id', '=', Request::get('booking_id')); if (Request::get('customer_mail_dir') == 11) { //draft $query->where('draft', '=', true); diff --git a/app/Http/Controllers/LeadController.php b/app/Http/Controllers/LeadController.php index f5808d1..444ecfd 100755 --- a/app/Http/Controllers/LeadController.php +++ b/app/Http/Controllers/LeadController.php @@ -62,7 +62,7 @@ class LeadController extends Controller public function getLeads() { - $query = Lead::with('customer')->with('sf_guard_user')->with('status'); + $query = Lead::with('customer')->with('sf_guard_user')->with('status')->select('lead.*'); return \DataTables::eloquent($query) ->addColumn('action_edit', function (Lead $lead) { diff --git a/app/Http/Controllers/RequestController.php b/app/Http/Controllers/RequestController.php index e5a5865..1cf3944 100755 --- a/app/Http/Controllers/RequestController.php +++ b/app/Http/Controllers/RequestController.php @@ -79,16 +79,17 @@ class RequestController extends Controller */ private function getSearchRequests(){ - $query = Booking::with('lead')->with('customer_mails')->where('lead_id', '!=', NULL); + $query = Booking::with('lead')->with('customer')->with('customer_mails')->select('booking.*')->where('lead_id', '!=', NULL); if(Request::get('full_firstname_search') != ""){ - $query->where('participant_firstname', 'LIKE', '%'.Request::get('full_firstname_search').'%'); - } - + $query->whereHas('customer', function ($q) { + $q->where('firstname', 'LIKE', '%'.Request::get('full_firstname_search').'%'); + }); } if(Request::get('full_lastname_search') != ""){ - $query->where('participant_name', 'LIKE', '%'.Request::get('full_lastname_search').'%'); + $query->whereHas('customer', function ($q) { + $q->where('name', 'LIKE', '%'.Request::get('full_lastname_search').'%'); + }); } - if(Request::get('travel_option_country_id') != ""){ $country_ids = TravelCountry::where('contact_lands', 'LIKE', '%"'.Request::get('travel_option_country_id').'"%')->get()->pluck('id'); $country_ids[] = Request::get('travel_option_country_id'); @@ -261,12 +262,12 @@ class RequestController extends Controller ->addColumn('lead_id', function (Booking $booking) { return ''.$booking->lead_id.''; }) - ->addColumn('participant_firstname', function (Booking $booking) { + /*->addColumn('participant_firstname', function (Booking $booking) { return ''.$booking->participant_firstname.''; }) ->addColumn('participant_name', function (Booking $booking) { return ''.$booking->participant_name.''; - }) + })*/ ->addColumn('id', function (Booking $booking) { return ''.$booking->id.''; }) diff --git a/app/Http/Controllers/Settings/AirlineController.php b/app/Http/Controllers/Settings/AirlineController.php index 2b13734..de94c03 100755 --- a/app/Http/Controllers/Settings/AirlineController.php +++ b/app/Http/Controllers/Settings/AirlineController.php @@ -6,6 +6,7 @@ use App\Http\Controllers\Controller; use App\Models\Airline; use App\Models\Booking; +use App\Services\Util; use Request; class AirlineController extends Controller @@ -28,11 +29,10 @@ class AirlineController extends Controller public function update(){ $data = Request::all(); - if(isset($data['contact_emails'])){ - $data['contact_emails'] = explode('#', str_replace(array("\r\n", "\r", "\n"),"#",$data['contact_emails'])); - }else{ - $data['contact_emails'] = null; - } + + + $data['contact_emails'] = isset($data['contact_emails']) ? Util::_explodeLines($data['contact_emails']) : null; + if($data['id'] === "new"){ $model = Airline::create($data); }else{ diff --git a/app/Http/Controllers/Settings/EmailTemplateController.php b/app/Http/Controllers/Settings/EmailTemplateController.php new file mode 100755 index 0000000..15392b9 --- /dev/null +++ b/app/Http/Controllers/Settings/EmailTemplateController.php @@ -0,0 +1,75 @@ +middleware('admin'); + } + + + public function index($step = false) + { + $data = [ + 'email_template' => EmailTemplate::all(), + ]; + return view('settings.email_template.index', $data); + } + + public function load(){ + $data = Request::all(); + $ret = ""; + if(Request::ajax()) { + + if($data['action'] === "modal-email-template") { + if($data['id'] === 'new'){ + $value = new EmailTemplate(); + $value->id = 0; + $value->active = 1; + + }else{ + $value = EmailTemplate::find($data['id']); + + } + $ret = view("settings.email_template.modal", compact('value'))->render(); + } + } + return response()->json(['response' => $data, 'html'=>$ret]); + } + + public function update(){ + + $data = Request::all(); + $data['active'] = isset($data['active']) ? true : false; + + if($data['id'] === "new" || $data['id'] == 0){ + $model = EmailTemplate::create($data); + }else{ + $model = EmailTemplate::find($data['id']); + $model->fill($data); + $model->save(); + } + + \Session()->flash('alert-save', '1'); + return redirect(route('admin_settings_email_template')); + } + + public function delete($id){ + + $model = EmailTemplate::findOrFail($id); + $model->delete(); + \Session()->flash('alert-success', 'Eintrag gelöscht'); + return redirect()->back(); + + } + +} + + diff --git a/app/Http/Controllers/Settings/InsuranceController.php b/app/Http/Controllers/Settings/InsuranceController.php new file mode 100755 index 0000000..6fe168b --- /dev/null +++ b/app/Http/Controllers/Settings/InsuranceController.php @@ -0,0 +1,55 @@ +middleware('admin'); + } + + public function index($step = false) + { + $data = [ + 'insurance' => Insurance::all(), + ]; + return view('settings.insurance.index', $data); + } + + + public function update(){ + + $data = Request::all(); + $data['contact_emails'] = isset($data['contact_emails']) ? Util::_explodeLines($data['contact_emails']) : null; + $data['active'] = isset($data['active']) ? true : false; + + if($data['id'] === "new"){ + $model = Insurance::create($data); + }else{ + $model = Insurance::find($data['id']); + $model->fill($data); + $model->save(); + } + + \Session()->flash('alert-save', '1'); + return redirect(route('admin_settings_insurance')); + } + + public function delete($id){ + $model = Insurance::findOrFail($id); + $model->delete(); + \Session()->flash('alert-success', 'Eintrag gelöscht'); + return redirect()->back(); + + } + +} + + diff --git a/app/Http/Controllers/Settings/ServiceProviderController.php b/app/Http/Controllers/Settings/ServiceProviderController.php new file mode 100755 index 0000000..350060f --- /dev/null +++ b/app/Http/Controllers/Settings/ServiceProviderController.php @@ -0,0 +1,57 @@ +middleware('admin'); + } + + public function index($step = false) + { + $data = [ + 'service_provider' => ServiceProvider::all(), + ]; + return view('settings.service_provider.index', $data); + } + + + public function update(){ + + $data = Request::all(); + $data['contact_emails'] = isset($data['contact_emails']) ? Util::_explodeLines($data['contact_emails']) : null; + $data['active'] = isset($data['active']) ? true : false; + + if($data['id'] === "new"){ + $model = ServiceProvider::create($data); + }else{ + $model = ServiceProvider::find($data['id']); + $model->fill($data); + $model->save(); + } + + \Session()->flash('alert-save', '1'); + return redirect(route('admin_settings_service_provider')); + } + + public function delete($id){ + + abort(404, 'Noch keine Funktion'); + $model = ServiceProvider::findOrFail($id); + $model->delete(); + \Session()->flash('alert-success', 'Eintrag gelöscht'); + return redirect()->back(); + + } + +} + + diff --git a/app/Http/Controllers/Settings/TravelCompanyController.php b/app/Http/Controllers/Settings/TravelCompanyController.php new file mode 100755 index 0000000..856514a --- /dev/null +++ b/app/Http/Controllers/Settings/TravelCompanyController.php @@ -0,0 +1,58 @@ +middleware('admin'); + } + + public function index($step = false) + { + $data = [ + 'travel_company' => TravelCompany::all(), + ]; + return view('settings.travel_company.index', $data); + } + + + public function update(){ + + $data = Request::all(); + $data['contact_emails'] = isset($data['contact_emails']) ? Util::_explodeLines($data['contact_emails']) : null; + $data['active'] = isset($data['active']) ? true : false; + $data['is_allowed_edit_commission'] = isset($data['is_allowed_edit_commission']) ? true : false; + $data['is_inhouse'] = isset($data['is_inhouse']) ? true : false; + if($data['id'] === "new"){ + $model = TravelCompany::create($data); + }else{ + $model = TravelCompany::find($data['id']); + $model->fill($data); + $model->save(); + } + + \Session()->flash('alert-save', '1'); + return redirect(route('admin_settings_travel_company')); + } + + public function delete($id){ + + abort(404, 'Noch keine Funktion'); + $model = TravelCompany::findOrFail($id); + $model->delete(); + \Session()->flash('alert-success', 'Eintrag gelöscht'); + return redirect()->back(); + + } + +} + + diff --git a/app/Http/Controllers/Settings/TravelCountryController.php b/app/Http/Controllers/Settings/TravelCountryController.php index 4012fef..fee0bd8 100755 --- a/app/Http/Controllers/Settings/TravelCountryController.php +++ b/app/Http/Controllers/Settings/TravelCountryController.php @@ -6,13 +6,21 @@ use App\Http\Controllers\Controller; use App\Models\TravelCountry; use App\Models\TravelNationality; +use App\Services\Util; use Request; class TravelCountryController extends Controller { + + + /* + * Create a new controller instance. + * + * @return void + */ public function __construct() { - $this->middleware('admin'); + $this->middleware('admin'); } @@ -24,9 +32,9 @@ class TravelCountryController extends Controller return view('settings.travel_country.index', $data); } - public function detail($id) + public function detail($id, $step = false) { - if($id == "new") { + if($id === "new") { $model = new TravelCountry(); $id = 'new'; $model->active_backend = 1; @@ -34,9 +42,11 @@ class TravelCountryController extends Controller $model = TravelCountry::findOrFail($id); $id = $model->id; } + $data = [ 'model' => $model, 'id' => $id, + 'step' => $step, 'travel_nationalities' => TravelNationality::where('active', true)->get(), ]; return view('settings.travel_country.detail', $data); @@ -44,45 +54,53 @@ class TravelCountryController extends Controller - public function store(){ + public function update($id) + { - $data = Request::all(); - $data['is_customer_country'] = isset($data['is_customer_country']) ? true : false; + $data = Request::all(); + $data['contact_emails'] = isset($data['contact_emails']) ? Util::_explodeLines($data['contact_emails']) : null; + if(!isset($data['contact_lands'])){ + $data['contact_lands'] = null; + } + /* + * $data['is_customer_country'] = isset($data['is_customer_country']) ? true : false; $data['active_frontend'] = isset($data['active_frontend']) ? true : false; $data['active_backend'] = isset($data['active_backend']) ? true : false; + */ + if($id === "new"){ + $data['crm_id'] = 0; + $model = TravelCountry::create($data); + }else{ + $model = TravelCountry::find($id); + $model->fill($data); + $model->save(); + } - if($data['id'] == "new"){ - $data['crm_id'] = 0; - $model = TravelCountry::create($data); - }else{ - $model = TravelCountry::find($data['id']); - $model->fill($data); - $model->save(); - } + //travel_nationality_requirement + if (isset($data['travel_nationality_requirement'])) { + foreach ($data['travel_nationality_requirement'] as $travel_nationality_id => $text) { + $model->setNationalityRequirement($travel_nationality_id, $text); + } + } - //travel_nationality_requirement - if(isset($data['travel_nationality_requirement'])){ - foreach ($data['travel_nationality_requirement'] as $travel_nationality_id => $text){ - $model->setNationalityRequirement($travel_nationality_id, $text); - } - } + //TODO for this time + if ($data['action'] === 'contact') { + //we need an update in the old CRM v1 system DB + $tc = \App\Models\Sym\TravelCountry::findOrFail($model->crm_id); + if(!$tc){ + $tc = \App\Models\Sym\TravelCountry::create($data); + $model->crm_id = $tc->id; + $model->save(); + }else{ + $tc->fill($data); + $tc->save(); + } - //TODO for this time - //we need an update in the old CRM v1 system DB - $tc = \App\Models\Sym\TravelCountry::find($model->crm_id); - if(!$tc){ - $tc = \App\Models\Sym\TravelCountry::create($data); - $model->crm_id = $tc->id; - $model->save(); - }else{ - $tc->fill($data); - $tc->save(); - } + } + \Session()->flash('alert-save', '1'); + return redirect(route('admin_settings_travel_country_detail', [$model->id])); + } - \Session()->flash('alert-save', '1'); - return redirect(route('admin_settings_travel_country_detail', [$model->id])); - - } public function delete($id){ $model = TravelCountry::findOrFail($id); @@ -100,7 +118,6 @@ class TravelCountryController extends Controller \Session()->flash('alert-success', 'Eintrag gelöscht'); return redirect()->back(); } - } diff --git a/app/Http/Controllers/Settings/TravelNationalityController.php b/app/Http/Controllers/Settings/TravelNationalityController.php index f126047..bb63e32 100755 --- a/app/Http/Controllers/Settings/TravelNationalityController.php +++ b/app/Http/Controllers/Settings/TravelNationalityController.php @@ -28,7 +28,7 @@ class TravelNationalityController extends Controller public function update(){ $data = Request::all(); - if($data['id'] == "new"){ + if($data['id'] === "new"){ $model = TravelNationality::create([ 'name' => $data['name'], 'active' => isset($data['active']) ? true : false, diff --git a/app/Models/Airline.php b/app/Models/Airline.php index 4f0fd54..06953bb 100644 --- a/app/Models/Airline.php +++ b/app/Models/Airline.php @@ -47,10 +47,4 @@ class Airline extends Model protected $casts = ['contact_emails' => 'array']; - public function getContactEmailsStr($glue=PHP_EOL){ - if($this->contact_emails){ - return implode($glue, $this->contact_emails); - } - return ""; - } } diff --git a/app/Models/Booking.php b/app/Models/Booking.php index bda2ce9..1cf78b5 100644 --- a/app/Models/Booking.php +++ b/app/Models/Booking.php @@ -6,6 +6,7 @@ namespace App\Models; +use App\Services\Util; use Carbon\Carbon; use Illuminate\Database\Eloquent\Collection; use Illuminate\Database\Eloquent\Model; @@ -160,6 +161,8 @@ use Illuminate\Database\Eloquent\Model; * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Booking whereOriginStartDate($value) * @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\BookingFile[] $booking_files * @property-read int|null $booking_files_count + * @property float|null $price_balance + * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Booking wherePriceBalance($value) */ class Booking extends Model { @@ -236,7 +239,9 @@ class Booking extends Model 'travel_company_id', 'travel_documents', 'price', + 'price_canceled', 'price_total', + 'price_balance', 'deposit_total', 'final_payment', 'final_payment_date', @@ -317,36 +322,6 @@ class Booking extends Model 2 => 'success', ]; - /* - * - *