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(

View file

@ -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();
}

View file

@ -1,86 +0,0 @@
<?php
namespace App\Http\Controllers\CMS;
use App\Http\Controllers\Controller;
use App\Models\CMSContent;
use App\Models\TravelCountry;
use App\Models\TravelNationality;
use Request;
use Validator;
class CMSContentCountryController extends Controller
{
/*
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->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']]));
}
}

View file

@ -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) {

View file

@ -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 '<a href="javascript:void(0)" class="btn icon-btn btn-sm btn-primary email-template-action"
data-url="'.route('customer_mail_ajax').'" data-id="'.$emailTemplate->id.'" data-action="load_email_template"
title="Vorlage laden" data-placement="left" rel="tooltip"><span class="ion ion-ios-arrow-dropup"></span></a>';
})
->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);

View file

@ -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) {

View file

@ -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 '<a data-order="'.$booking->lead_id.'" href="'.make_old_url('leads/'.$booking->lead_id.'/edit').'" data-id="'.$booking->lead_id.'">'.$booking->lead_id.'</a>';
})
->addColumn('participant_firstname', function (Booking $booking) {
/*->addColumn('participant_firstname', function (Booking $booking) {
return '<a data-order="'.$booking->participant_firstname.'" href="'.make_old_url('customer/'.$booking->customer_id.'/edit').'" data-id="'.$booking->customer_id.'">'.$booking->participant_firstname.'</a>';
})
->addColumn('participant_name', function (Booking $booking) {
return '<a data-order="'.$booking->participant_name.'" href="'.make_old_url('customer/'.$booking->customer_id.'/edit').'" data-id="'.$booking->customer_id.'">'.$booking->participant_name.'</a>';
})
})*/
->addColumn('id', function (Booking $booking) {
return '<a data-order="'.$booking->id.'" href="'.make_old_url('booking/'.$booking->id.'/edit').'" data-id="'.$booking->id.'">'.$booking->id.'</a>';
})

View file

@ -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{

View file

@ -0,0 +1,75 @@
<?php
namespace App\Http\Controllers\Settings;
use App\Http\Controllers\Controller;
use App\Models\EmailTemplate;
use Request;
class EmailTemplateController extends Controller
{
public function __construct()
{
$this->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();
}
}

View file

@ -0,0 +1,55 @@
<?php
namespace App\Http\Controllers\Settings;
use App\Http\Controllers\Controller;
use App\Models\Insurance;
use App\Services\Util;
use Request;
class InsuranceController extends Controller
{
public function __construct()
{
$this->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();
}
}

View file

@ -0,0 +1,57 @@
<?php
namespace App\Http\Controllers\Settings;
use App\Http\Controllers\Controller;
use App\Models\ServiceProvider;
use App\Services\Util;
use Request;
class ServiceProviderController extends Controller
{
public function __construct()
{
$this->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();
}
}

View file

@ -0,0 +1,58 @@
<?php
namespace App\Http\Controllers\Settings;
use App\Http\Controllers\Controller;
use App\Models\TravelCompany;
use App\Services\Util;
use Request;
class TravelCompanyController extends Controller
{
public function __construct()
{
$this->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();
}
}

View file

@ -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();
}
}

View file

@ -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,

View file

@ -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 "";
}
}

View file

@ -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',
];
/*
*
* <ul class="tabscontrol flatlist clearfix" id="tabscontrol">
<li class="tab"><a href="#customer" class="active"><?php echo __('Kunde') ?></a></li>
<?php if ($booking->relatedExists('Application')): ?>
<li class="tab"><a href="#application" class="active"><?php echo __('Reiseanmeldung') ?></a></li>
<?php endif; ?>
<?php if ($booking->relatedExists('Confirmation')): ?>
<li class="tab"><a href="#confirmation" class="active"><?php echo __('Reisebestätigung') ?></a></li>
<?php endif; ?>
<?php if ($booking->relatedExists('Invoice')): ?>
<li class="tab"><a href="#invoice" class="active"><?php echo __('Rechnung') ?></a></li>
<?php endif; ?>
<?php if ($booking->relatedExists('Storno')): ?>
<li class="tab"><a href="#storno" class="active"><?php echo __('Storno') ?></a></li>
<?php endif; ?>
<?php if ($booking->relatedExists('TravelInsurance')): ?>
<li class="tab"><a href="#travelinsurance" class="active"><?php echo __('Versicherung') ?></a></li>
<?php endif; ?>
<?php if ($booking->relatedExists('InsuranceCertificate')): ?>
<li class="tab"><a href="#insurance" class="active"><?php echo __('Sicherungsschein') ?></a></li>
<?php endif; ?>
<?php if ($booking->relatedExists('Voucher')): ?>
<li class="tab"><a href="#voucher" class="active"><?php echo __('Voucher') ?></a></li>
<?php endif; ?>
<?php if ($booking->relatedExists('Coupon')): ?>
<li class="tab"><a href="#coupon" class="active"><?php echo __('Gutscheine') ?></a></li>
<?php endif; ?>
*/
/*public function branch()
{
@ -535,15 +510,69 @@ class Booking extends Model
public function getPriceAttribute()
{
// 2 = decimal places | '.' = decimal seperator | ',' = thousand seperator
return number_format(($this->attributes['price']), 2, ',', '.');
return Util::_number_format($this->attributes['price']);
}
public function getPriceRaw()
{
return $this->attributes['price'];
}
public function getPriceCanceledAttribute()
{
return Util::_number_format($this->attributes['price_canceled']);
}
public function getPriceCanceledRaw()
{
return $this->attributes['price_canceled'];
}
public function getPriceTotalAttribute()
{
return Util::_number_format($this->attributes['price_total']);
}
public function getPriceTotalRaw()
{
return $this->attributes['price_total'];
}
public function getCanceledAttribute()
{
return Util::_number_format($this->attributes['canceled']);
}
public function getCanceledRaw()
{
return $this->attributes['canceled'];
}
public function getPriceBalanceAttribute()
{
return Util::_number_format($this->attributes['price_balance']);
}
public function getPriceBalanceRaw()
{
return $this->attributes['price_balance'];
}
public function getDepositTotalAttribute()
{
return Util::_number_format($this->attributes['deposit_total']);
}
public function getDepositTotalRaw()
{
return $this->attributes['deposit_total'];
}
public function getFinalPaymentAttribute()
{
return Util::_number_format($this->attributes['final_payment']);
}
public function getFinalPaymentRaw()
{
return $this->attributes['final_payment'];
}
public function findBeforeDraftItemRelation($reid)
{
$before = false;
@ -585,56 +614,48 @@ class Booking extends Model
return Carbon::parse($this->attributes['booking_date'])->format(\Util::formatDateDB());
}
//erlös #getRevenueFactor
public function proceedsRaw(){
$total = 0;
foreach ($this->service_provider_entries as $entry)
{
$total += $entry->amount / $entry->factor;
}
return $this->attributes['price'] - $total;
public function getFinalPaymentDateFormat(){
if(!$this->attributes['final_payment_date']){ return ""; }
return Carbon::parse($this->attributes['final_payment_date'])->format(\Util::formatDateDB());
}
public function isCanceled(){
return ($this->attributes['canceled'] > 0);
}
//erlös #getRevenueFactor
public function proceeds(){
$proceeds = $this->attributes['price']
// - $this->getServiceTotal()
// - $this->getServiceFee()
- $this->getServiceProviderEntriesAmountFactorTotal();
return number_format(($proceeds), 2, ',', '.');
public function proceeds($raw = false){
$proceeds = $this->attributes['price'] - $this->attributes['price_balance'] - $this->getServiceProviderPaymentsFactorTotal(true);
return $raw ? $proceeds : Util::_number_format($proceeds);
}
public function getServiceProviderEntriesAmountFactorTotal()
public function getServiceTotal($raw = false)
{
$total = 0;
foreach ($this->service_provider_entries as $entry)
{
foreach ($this->booking_service_items as $booking_service_item){
$total += $booking_service_item->getServicePriceRaw();
}
return $raw ? $total : Util::_number_format($total);
}
public function getServiceProviderPaymentsFactorTotal($raw = false)
{
$total = 0;
foreach ($this->service_provider_entries as $entry){
$total += $entry->amount / $entry->factor;
}
return $total;
return $raw ? $total : Util::_number_format($total);
}
public function getServiceProviderPaymentsTotalRaw()
public function getServiceProviderPaymentsTotal($raw = false)
{
$total = 0;
foreach ($this->service_provider_entries as $entry)
{
foreach ($this->service_provider_entries as $entry){
$total += $entry->amount;
}
return $total;
}
public function getServiceProviderPaymentsTotal()
{
$total = 0;
foreach ($this->service_provider_entries as $entry)
{
$total += $entry->amount;
}
return number_format(($total), 2, ',', '.');
return $raw ? $total : Util::_number_format($total);
}
public function getKontoNumber(){

View file

@ -6,6 +6,7 @@
namespace App\Models;
use App\Services\Util;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Model;
@ -81,4 +82,14 @@ class BookingServiceItem extends Model
{
return $this->belongsTo(TravelCompany::class);
}
public function getServicePriceAttribute()
{
return Util::_number_format($this->attributes['service_price']);
}
public function getServicePriceRaw()
{
return $this->attributes['service_price'];
}
}

View file

@ -0,0 +1,39 @@
<?php
/**
* Created by Reliese Model.
*/
namespace App\Models;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Model;
/**
* Class EmailTemplate
*
* @property int $id
* @property string $subject
* @property string $message
* @property bool $active
* @property Carbon $created_at
* @property Carbon $updated_at
*
* @package App\Models
*/
class EmailTemplate extends Model
{
protected $connection = 'mysql';
protected $table = 'email_templates';
protected $casts = [
'active' => 'bool'
];
protected $fillable = [
'subject',
'message',
'active'
];
}

42
app/Models/Insurance.php Normal file
View file

@ -0,0 +1,42 @@
<?php
/**
* Created by Reliese Model.
*/
namespace App\Models;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Model;
/**
* Class Insurance
*
* @property int $id
* @property string $name
* @property string $name_full
* @property string $contact_emails
* @property bool $active
* @property Carbon $created_at
* @property Carbon $updated_at
*
* @package App\Models
*/
class Insurance extends Model
{
protected $connection = 'mysql';
protected $table = 'insurances';
protected $casts = [
'active' => 'bool',
'contact_emails' => 'array'
];
protected $fillable = [
'name',
'contact_emails',
'active'
];
}

View file

@ -33,14 +33,23 @@ class ServiceProvider extends Model
protected $table = 'service_provider';
public $timestamps = false;
public static $types = [
'payment' => 'payment',
'discount' => 'discount',
];
protected $casts = [
'dollar' => 'bool'
];
'dollar' => 'bool',
'active' => 'bool',
'contact_emails' => 'array'
];
protected $fillable = [
'name',
'dollar',
'type'
'type',
'contact_emails',
'active'
];
public function service_provider_entries()

View file

@ -6,6 +6,7 @@
namespace App\Models;
use App\Services\Util;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Database\Eloquent\Model;
@ -44,15 +45,19 @@ class TravelCompany extends Model
protected $casts = [
'percentage' => 'float',
'is_allowed_edit_commission' => 'bool',
'is_inhouse' => 'bool'
];
'is_inhouse' => 'bool',
'active' => 'bool',
'contact_emails' => 'array'
];
protected $fillable = [
'name',
'percentage',
'is_allowed_edit_commission',
'is_inhouse'
];
'is_inhouse',
'contact_emails',
'active'
];
public function bookings()
{
@ -63,4 +68,19 @@ class TravelCompany extends Model
{
return $this->hasMany(BookingServiceItem::class);
}
public function setPercentageAttribute($value)
{
$this->attributes['percentage'] = Util::_clean_float($value);
}
public function getPercentageAttribute()
{
return Util::_number_format($this->attributes['percentage']);
}
public function getPercentageRaw()
{
return isset($this->attributes['percentage']) ? $this->attributes['percentage'] : 0;
}
}

View file

@ -118,13 +118,6 @@ class TravelCountry extends Model
}
}
public function getContactEmailsStr($glue=PHP_EOL){
if(isset($this->contact_emails)){
return implode($glue, $this->contact_emails);
}
return "";
}
public function getContactLandsArray(){
$ret = [];
if($this->contact_lands){

View file

@ -9,6 +9,7 @@ use App\Models\Booking;
use App\Models\CMSContent;
use App\Models\CustomerFile;
use App\Models\CustomerMail;
use App\Services\Placeholder;
use App\Services\Util;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Support\Facades\Mail;
@ -54,6 +55,7 @@ class CustomerMailRepository extends BaseRepository {
foreach ($customer_files as $file) {
$file->customer_id = $booking->customer_id;
$file->customer_mail_id = $customer_mail->id;
$file->identifier = 'mail';
$file->save();
}
@ -86,6 +88,7 @@ class CustomerMailRepository extends BaseRepository {
foreach ($customer_files as $file) {
$file->customer_id = $booking->customer_id;
$file->customer_mail_id = $customer_mail->id;
$file->identifier = 'mail';
$file->save();
}
}
@ -170,26 +173,8 @@ class CustomerMailRepository extends BaseRepository {
}
private function prepareContent($booking, $content){
$first_name = $booking->customer->firstname;
$last_name = $booking->customer->name;
$title = $booking->customer->title;
$country = $booking->travel_country_id ? $booking->travel_country->name : "-";
$program = $booking->travelagenda_id ? $booking->travel_agenda->name : "-";
$salutation = $booking->customer->salutation->name;
$start_date = $booking->getStartDateFormat();
$end_date = $booking->getEndDateFormat();
$booking_date = $booking->getBookingDateFormat();
$airline = $booking->airline ? $booking->airline->name_full : '-';
$dear = $booking->customer->salutation_id == 1 ? 'geehrter' : 'geehrte';
$search = ['#geehrte/r#', '#Anrede#', '#Titel#', '#Vorname#', '#Nachname#', '#Reiseland#', '#Programm#', '#Anreisedatum#', '#Abreisedatum#', '#Buchungsdatum#', '#Airline#'];
$replace = [$dear, $salutation, $title, $first_name, $last_name, $country, $program, $start_date, $end_date, $booking_date, $airline];
$content = str_replace($search, $replace, $content);
$content = Placeholder::replaceBooking($booking, $content);
return $content;
}
private static function prepareContactMails($value){
@ -236,6 +221,7 @@ class CustomerMailRepository extends BaseRepository {
$value->recipient = "";
$value->cc = "";
$value->bcc = "";
$value->lead_title_id = "";
/*Ansicht*/
if ($data['action'] === "show-customer-mail") {
if (isset($data['customer_mail_id']) && $customer_mail = CustomerMail::find($data['customer_mail_id'])) {
@ -255,6 +241,8 @@ class CustomerMailRepository extends BaseRepository {
$value->id = $customer_mail->booking_id;
$value->booking = $booking;
$value->show = 'single';
$value->lead_title_id = " - (".$value->booking->lead_id.")";
$tmp = [];
$tmp['email'] = $customer_mail->email ? $customer_mail->email : "";
@ -288,21 +276,21 @@ class CustomerMailRepository extends BaseRepository {
if ($data['action'] === "new-customer-mail") {
$value->id = "";
$value->draft = false;
$lead_id = "-";
$value->lead_title_id = "-";
//singel
if (isset($data['booking_id']) && $booking = Booking::find($data['booking_id'])) {
$value->id = $data['booking_id'];
$value->booking = $booking;
$value->show = 'single';
$value->draft = true;
$lead_id = " - (".$value->booking->lead_id.")";
$value->lead_title_id = " - (".$value->booking->lead_id.")";
}else{
//multi
$value->show = 'multi';
}
$value->customers = $data['customers'];
$value->subject = $lead_id ;
$value->subject = $value->lead_title_id;
$value->message = CMSContent::getContentBySlug('mailvorlage');
$value->s_placeholder = "Betreff der E-Mail";
$value->m_placeholder = "Nachricht der E-Mail";
@ -333,6 +321,7 @@ class CustomerMailRepository extends BaseRepository {
$value->booking = $booking;
$value->message = "";
$value->subject = "";
$value->lead_title_id = " - (".$value->booking->lead_id.")";
$value->s_placeholder = "Betreff des Kunden";
$value->m_placeholder = "Nachricht des Kunden";
if(isset($data['customer_mail_id']) && $customer_mail = CustomerMail::find($data['customer_mail_id'])){

View file

@ -100,6 +100,16 @@ class FileRepository extends BaseRepository {
], 200);
}
public function delete(){
if($this->model){
if(Storage::disk($this->disk)->exists( $this->model->dir.$this->model->filename )){
Storage::disk($this->disk)->delete($this->model->dir.$this->model->filename);
}
$this->model->delete();
return true;
}
return false;
}
private function makeFilename(){
$originalNameWithoutExt = substr($this->originalName, 0, strlen($this->originalName) - strlen($this->extension) - 1);
$this->filename = Util::sanitize($originalNameWithoutExt, true, false, true);

View file

@ -112,6 +112,10 @@ class HTMLHelper
}
public static function getActiveIcon($active){
return $active ? '<span class="badge badge-pill badge-success"><i class="fa fa-check"></i></span>' : '<span class="badge badge-pill badge-danger"><i class="fa fa-times"></i></span>';
}
public static function getRolesOptions($id = 0){
$ret = "";
foreach (self::$roles as $role_id => $value){

View file

@ -0,0 +1,68 @@
<?php
namespace App\Services;
use App\Models\Booking;
class Placeholder
{
public static $booking = [
'dear' => '#geehrte/r#',
'salutation' => '#Anrede#',
'title' => '#Titel#',
'first_name' => '#Vorname#',
'last_name' => '#Nachname#',
'country' => '#Reiseland#',
'program' => '#Programm#',
'start_date' => '#Anreisedatum#',
'end_date' => '#Abreisedatum#',
'booking_date' => '#Buchungsdatum#',
'airline' => '#Airline#'
];
public static function getBookingQuill(){
$ret = "";
foreach (self::$booking as $key => $value) {
$value = str_replace('#', '', $value);
$ret .= "{id: '".$value."', label: '".$value."'},"."\n";
}
return $ret;
}
public static function getBookingOptions(){
$ret = "";
foreach (self::$booking as $key => $value) {
$value = str_replace('#', '', $value);
$ret .= '<option value="'.$value.'">'.$value.'</option>'."\n";
}
return $ret;
}
public static function replaceBooking(Booking $booking, $content)
{
$dear = $booking->customer->salutation_id == 1 ? 'geehrter' : 'geehrte';
$first_name = $booking->customer->firstname;
$last_name = $booking->customer->name;
$title = $booking->customer->title;
$country = $booking->travel_country_id ? $booking->travel_country->name : "-";
$program = $booking->travelagenda_id ? $booking->travel_agenda->name : "-";
$salutation = $booking->customer->salutation->name;
$start_date = $booking->getStartDateFormat();
$end_date = $booking->getEndDateFormat();
$booking_date = $booking->getBookingDateFormat();
$airline = $booking->airline ? $booking->airline->name_full : '-';
$search = [];
$replace = [];
foreach (self::$booking as $key => $value) {
$search[] = $value;
$replace[] = ${$key};
}
$content = str_replace($search, $replace, $content);
$content = preg_replace('/<placeholder.*?>(.*?)<\/placeholder>/', '$1', $content);
$content = preg_replace('/<span contenteditable="false">(.*?)<\/span>/', '$1', $content);
return $content;
}
}

View file

@ -64,13 +64,6 @@ class Util
}
return "";
}
public function getContactEmailsStr($glue=PHP_EOL){
if(isset($this->contact_emails)){
return implode($glue, $this->contact_emails);
}
return "";
}
public static function _clean_float($value){
$groups = explode(".", preg_replace("/[^0-9.-]/", "", str_replace(',', '.', $value)));