Fewo Mails / Booking Country Services
This commit is contained in:
parent
b9c26d06d0
commit
48a6eb2282
154 changed files with 7761 additions and 1643 deletions
|
|
@ -273,7 +273,6 @@ class ReportController extends Controller
|
|||
|
||||
private function prozessProvidersSearch(){
|
||||
|
||||
|
||||
$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'));
|
||||
|
|
@ -293,8 +292,6 @@ class ReportController extends Controller
|
|||
$q->where("start_date", '<=', $travel_date_to);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
return $query;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -55,9 +55,15 @@ class BookingController extends Controller
|
|||
{
|
||||
// \Session()->flash('alert-save', '1');
|
||||
|
||||
|
||||
$data = Request::all();
|
||||
if($id == "new") {
|
||||
|
||||
if($data['action'] === 'update_booking'){
|
||||
$booking = $this->bookingRepo->updateBooking($id, $data);
|
||||
\Session()->flash('alert-save', '1');
|
||||
return redirect(route('booking_detail', [$booking->id])."#collapseBookingBooking");
|
||||
}
|
||||
|
||||
if($id === "new") {
|
||||
$booking = new Booking();
|
||||
}else{
|
||||
$booking = Booking::findOrFail($id);
|
||||
|
|
@ -244,6 +250,27 @@ class BookingController extends Controller
|
|||
}
|
||||
|
||||
|
||||
public function delete($id, $del="booking"){
|
||||
|
||||
if($del === 'booking') {
|
||||
//$model = Booking::findOrFail($id);
|
||||
//$model->delete();
|
||||
\Session()->flash('alert-success', __('Buchung gelöscht sowie die Reservierung im Sterntrous Kalender'));
|
||||
}
|
||||
if($del === 'booking_file'){
|
||||
$booking_file = BookingFile::findOrFail($id);
|
||||
$booking = $booking_file->booking;
|
||||
$fileRepo = new BookingFileRepository($booking_file);
|
||||
$fileRepo->_set('disk', 'booking');
|
||||
$fileRepo->delete();
|
||||
$booking_file->delete();
|
||||
\Session()->flash('alert-success', 'Datei gelöscht');
|
||||
return redirect(route('booking_detail', [$booking->id]));
|
||||
}
|
||||
return redirect(route('requests'));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -12,8 +12,12 @@ use Validator;
|
|||
class CMSContentController extends Controller
|
||||
{
|
||||
|
||||
protected $identifier_content;
|
||||
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->identifier_content = 'general';
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -21,7 +25,8 @@ class CMSContentController extends Controller
|
|||
public function index()
|
||||
{
|
||||
$data = [
|
||||
'contents' => CMSContent::all()->sortByDesc('id')
|
||||
'contents' => CMSContent::where('identifier', '=', $this->identifier_content)->get()->sortByDesc('id'),
|
||||
'identifier_content' => $this->identifier_content,
|
||||
];
|
||||
return view('cms.content.all.index', $data);
|
||||
}
|
||||
|
|
@ -30,18 +35,17 @@ class CMSContentController extends Controller
|
|||
public function store()
|
||||
{
|
||||
$data = Request::all();
|
||||
|
||||
if(Request::ajax()) {
|
||||
//upload file
|
||||
if($data['file']){
|
||||
$cmsFileRepo = new CMSFileRepository(new CMSContent());
|
||||
$cmsFileRepo->_set('data', $data);
|
||||
$cmsFileRepo->_set('disk', 'public');
|
||||
$cmsFileRepo->_set('dir', '/cms_files/'.date('Y/m').'/');
|
||||
$cmsFileRepo->_set('identifier', 'cms_file');
|
||||
return $cmsFileRepo->uploadFile(Request::all());
|
||||
}
|
||||
return response()->json(['response' => $data, 'html'=>""]);
|
||||
|
||||
}
|
||||
$rules = array(
|
||||
'name' => 'required',
|
||||
|
|
@ -68,6 +72,10 @@ class CMSContentController extends Controller
|
|||
|
||||
}
|
||||
\Session()->flash('alert-save', '1');
|
||||
if(isset($data['back'])){
|
||||
return redirect($data['back']);
|
||||
|
||||
}
|
||||
return redirect(route('cms_content_all'));
|
||||
}
|
||||
|
||||
|
|
@ -78,9 +86,11 @@ class CMSContentController extends Controller
|
|||
$data = Request::all();
|
||||
$returnHTML = "";
|
||||
if(isset($data['model']) && isset($data['id']) ){
|
||||
if($data['model'] == 'content'){
|
||||
if($data['id'] == "new"){
|
||||
if($data['model'] === 'content'){
|
||||
if($data['id'] === "new"){
|
||||
$value = new CMSContent();
|
||||
$value->identifier = $data['identifier'];
|
||||
$value->field = isset($data['field']) ? $data['field'] : null;
|
||||
}else {
|
||||
$value = CMSContent::find($data['id']);
|
||||
}
|
||||
|
|
@ -93,19 +103,16 @@ class CMSContentController extends Controller
|
|||
|
||||
//public
|
||||
|
||||
|
||||
public function delete($id){
|
||||
$content = CMSContent::findOrFail($id);
|
||||
if($content->isFile()){
|
||||
$content->deleteFile();
|
||||
}
|
||||
$content->delete();
|
||||
$m = \App\Models\Sym\CmsContent::find($id);
|
||||
$m->delete();
|
||||
\Session()->flash('alert-success', __('Content gelöscht'));
|
||||
return redirect(route('cms_content_all'));
|
||||
return back(); //redirect(route('cms_content_all'));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
383
app/Http/Controllers/CustomerFewoMailController.php
Executable file
383
app/Http/Controllers/CustomerFewoMailController.php
Executable file
|
|
@ -0,0 +1,383 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\CustomerFewoFile;
|
||||
use App\Models\CustomerFewoMail;
|
||||
use App\Models\EmailTemplate;
|
||||
use App\Models\TravelUserBookingFewo;
|
||||
use App\Models\TravelUserBookingFile;
|
||||
use App\Repositories\BookingFewoFileRepository;
|
||||
use App\Repositories\CustomerFewoFileRepository;
|
||||
use App\Repositories\CustomerFewoMailRepository;
|
||||
use App\Services\Util;
|
||||
use Carbon;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Illuminate\Support\Facades\URL;
|
||||
use Request;
|
||||
use Response;
|
||||
|
||||
class CustomerFewoMailController extends Controller
|
||||
{
|
||||
|
||||
protected $customerMailRepo;
|
||||
|
||||
public function __construct(CustomerFewoMailRepository $customerMailRepo)
|
||||
{
|
||||
$this->middleware('admin');
|
||||
$this->customerMailRepo = $customerMailRepo;
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
$data = [
|
||||
|
||||
];
|
||||
return view('customer.mail.index', $data);
|
||||
}
|
||||
|
||||
public function detail($id)
|
||||
{
|
||||
if($id === "new") {
|
||||
$customer_mail = new CustomerFewoMail();
|
||||
$id = 'new';
|
||||
|
||||
}else{
|
||||
$customer_mail = CustomerFewoMail::findOrFail($id);
|
||||
$id = $customer_mail->id;
|
||||
}
|
||||
|
||||
|
||||
$data = [
|
||||
'customer_mail' => $customer_mail,
|
||||
'id' => $id,
|
||||
'back' => URL::previous(),
|
||||
];
|
||||
return view('customer.mail.detail', $data);
|
||||
|
||||
}
|
||||
|
||||
public function store($id, $action=false)
|
||||
{
|
||||
$data = Request::all();
|
||||
$customer_mail = CustomerFewoMail::findOrFail($id);
|
||||
|
||||
if($action === 'move-mail'){
|
||||
$data['subdir'] = isset($data['subdir']) && $data['subdir'] ? $data['subdir'] : null;
|
||||
$customer_mail->dir = $data['dir'];
|
||||
$customer_mail->subdir = $data['subdir'];
|
||||
$customer_mail->save();
|
||||
|
||||
}
|
||||
return back();
|
||||
}
|
||||
|
||||
public function delete($id){
|
||||
$customer_mail = CustomerFewoMail::find($id);
|
||||
$customer_mail->dir = 12;
|
||||
$customer_mail->subdir = 0;
|
||||
$customer_mail->save();
|
||||
|
||||
\Session()->flash('alert-success', __('Mail gelöscht'));
|
||||
return back();
|
||||
}
|
||||
|
||||
|
||||
public function loadModal(){
|
||||
$data = Request::all();
|
||||
$ret = "";
|
||||
if(Request::ajax()) {
|
||||
if ($data['action'] === "new-customer-mail" || $data['action'] === "reply-customer-mail" || $data['action'] === "show-customer-mail" || $data['action'] === "edit-customer-mail"){
|
||||
$data['customers'] = [];
|
||||
if ($data['action'] === "new-customer-mail" && isset($data['travel_user_booking_fewo_id']) && $TravelUserBookingFewo = TravelUserBookingFewo::find($data['travel_user_booking_fewo_id'])) {
|
||||
$tmp = [];
|
||||
$tmp['email'] = $TravelUserBookingFewo->travel_user ? $TravelUserBookingFewo->travel_user->email : "";
|
||||
$tmp['name'] = $TravelUserBookingFewo->travel_user ? $TravelUserBookingFewo->travel_user->first_name . " " . $TravelUserBookingFewo->travel_user->last_name . " | " : "- | ";
|
||||
$tmp['name'] .= $TravelUserBookingFewo->fewo_lodging_id ? $TravelUserBookingFewo->fewo_lodging->name . " | " : "- | ";
|
||||
$data['customers'][$TravelUserBookingFewo->id] = $tmp;
|
||||
}
|
||||
$ret = CustomerFewoMailRepository::loadModal($data);
|
||||
}
|
||||
|
||||
if($data['action'] === "modal-upload-booking-file") {
|
||||
$ret = view("travel.user.booking.upload_modal", compact('data'))->render();
|
||||
}
|
||||
|
||||
if($data['action'] === "upload-booking-file"){
|
||||
if($data['travel_user_booking_fewo_id']){
|
||||
$bookingFileRepo = new BookingFewoFileRepository(new TravelUserBookingFile());
|
||||
$bookingFileRepo->_set('disk', 'booking_fewo');
|
||||
$bookingFileRepo->_set('travel_user_booking_fewo_id', $data['travel_user_booking_fewo_id']);
|
||||
$bookingFileRepo->_set('dir', '/files/'.date('Y/m').'/');
|
||||
$bookingFileRepo->_set('identifier', 'booking');
|
||||
return $bookingFileRepo->uploadFile(Request::all());
|
||||
}
|
||||
}
|
||||
}
|
||||
return response()->json(['response' => $data, 'html'=>$ret]);
|
||||
}
|
||||
|
||||
|
||||
public function sendMail(CustomerFewoMailRepository $customerFewoMailRepository){
|
||||
$data = Request::all();
|
||||
$customerFewoMailRepository->sendAndStore($data);
|
||||
if($data['action'] == 'draft'){
|
||||
\Session()->flash('alert-success', "Entwurf gespeichert!");
|
||||
}else{
|
||||
\Session()->flash('alert-success', "Mail gesendet!");
|
||||
}
|
||||
return back();
|
||||
}
|
||||
|
||||
public function replyMail(CustomerFewoMailRepository $customerFewoMailRepository){
|
||||
$data = Request::all();
|
||||
$customerFewoMailRepository->replyStore($data);
|
||||
\Session()->flash('alert-success', "Mail gespeichert!");
|
||||
return back();
|
||||
}
|
||||
|
||||
/*public function getCustomerFewoMails()
|
||||
{
|
||||
$query = CustomerFewoMail::with('booking')->with('customer')->select('customer_mails.*');
|
||||
|
||||
return \DataTables::eloquent($query)
|
||||
->addColumn('action_edit', function (CustomerFewoMail $customer_mail) {
|
||||
return '<a href="'.route('customer_mail_detail', [$customer_mail->id]).'" class="btn icon-btn btn-sm btn-primary"><span class="fa fa-edit"></span></a>';
|
||||
})
|
||||
->addColumn('id', function (CustomerFewoMail $customer_mail) {
|
||||
return '<a data-order="'.$customer_mail->id.'" href="'.route('customer_mail_detail', [$customer_mail->id]).'" data-id="'.$customer_mail->id.'">'.$customer_mail->id.'</a>';
|
||||
})
|
||||
->addColumn('booking', function (CustomerFewoMail $customer_mail) {
|
||||
$out = $customer_mail->booking->travel_country_id ? $customer_mail->booking->travel_country->name." | " : "- | ";
|
||||
$out .= $customer_mail->booking->travelagenda_id ? $customer_mail->booking->travel_agenda->name."" : "-";
|
||||
return $out;
|
||||
})
|
||||
->addColumn('travel_user_booking_fewo_id', function (CustomerFewoMail $customer_mail) {
|
||||
return '<a data-order="'.$customer_mail->travel_user_booking_fewo_id.'" href="'.route('booking_detail', [$customer_mail->travel_user_booking_fewo_id]).'">'.$customer_mail->travel_user_booking_fewo_id.'</a>';
|
||||
})
|
||||
->addColumn('customer_id', function (CustomerFewoMail $customer_mail) {
|
||||
return '<a data-order="'.$customer_mail->customer_id.'" href="'.route('customer_detail', [$customer_mail->customer_id]).'">'.$customer_mail->customer_id.'</a>';
|
||||
})
|
||||
->addColumn('send', function (CustomerFewoMail $customer_mail) {
|
||||
return $customer_mail->send ? '<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>';
|
||||
})
|
||||
->orderColumn('id', 'id $1')
|
||||
->orderColumn('travel_user_booking_fewo_id', 'travel_user_booking_fewo_id $1')
|
||||
->orderColumn('customer_id', 'customer_id $1')
|
||||
->orderColumn('send', 'send $1')
|
||||
|
||||
->filterColumn('id', function($query, $keyword) {
|
||||
if($keyword != ""){
|
||||
$query->where('id', 'LIKE', '%'.$keyword.'%');
|
||||
}
|
||||
})
|
||||
->filterColumn('customer_id', function($query, $keyword) {
|
||||
if($keyword != ""){
|
||||
$query->where('customer_id', 'LIKE', '%'.$keyword.'%');
|
||||
}
|
||||
})
|
||||
->filterColumn('travel_user_booking_fewo_id', function($query, $keyword) {
|
||||
if($keyword != ""){
|
||||
$query->where('travel_user_booking_fewo_id', 'LIKE', '%'.$keyword.'%');
|
||||
}
|
||||
})
|
||||
->rawColumns(['action_edit', 'send', 'customer_id', 'travel_user_booking_fewo_id', 'id'])
|
||||
->make(true);
|
||||
}*/
|
||||
|
||||
public function getEmailTemplates()
|
||||
{
|
||||
$query = EmailTemplate::with('email_template_dir')->select('email_templates.*')->where('active', '=', true);
|
||||
|
||||
if(Request::get('filter_email_templates_directory') != ""){
|
||||
$query->where('email_template_dir_id', '=', Request::get('filter_email_templates_directory'));
|
||||
}
|
||||
|
||||
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>';
|
||||
})
|
||||
->addColumn('email_template_dir.name', function (EmailTemplate $emailTemplate) {
|
||||
return $emailTemplate->email_template_dir ? '<span class="badge badge-default" style="background-color: '.$emailTemplate->email_template_dir->color.'">'.$emailTemplate->email_template_dir->name.'</span>' : ' ';
|
||||
})
|
||||
->orderColumn('id', 'id $1')
|
||||
->orderColumn('subject', 'subject $1')
|
||||
->orderColumn('name', 'name $1')
|
||||
->orderColumn('email_template_dir.name', 'email_template_dir.name $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('name', 'LIKE', '%'.$keyword.'%');
|
||||
$query->OrWhere('subject', 'LIKE', '%'.$keyword.'%');
|
||||
$query->OrWhere('message', 'LIKE', '%'.$keyword.'%');
|
||||
}
|
||||
})
|
||||
->rawColumns(['action', 'email_template_dir.name'])
|
||||
->make(true);
|
||||
}
|
||||
|
||||
|
||||
public function uploadAttachment($id){
|
||||
|
||||
$fileRepo = new CustomerFewoFileRepository(new CustomerFewoFile());
|
||||
if($id === 'tmp'){
|
||||
$fileRepo->_set('disk', 'travel_user');
|
||||
$fileRepo->_set('dir', '/attachment/'.date('Y/m').'/');
|
||||
$fileRepo->_set('travel_user_id', NULL);
|
||||
$fileRepo->_set('customer_fewo_mail_id', NULL);
|
||||
$fileRepo->_set('identifier', 'tmp');
|
||||
return $fileRepo->uploadFile(Request::all());
|
||||
}
|
||||
|
||||
return Response::json([
|
||||
'error' => true,
|
||||
'code' => 200
|
||||
], 200);
|
||||
}
|
||||
|
||||
public function ajax(){
|
||||
$data = Request::all();
|
||||
$ret = "";
|
||||
$status = false;
|
||||
if(Request::ajax()){
|
||||
if($data['action'] === 'toggle_important'){
|
||||
$customer_mail = CustomerFewoMail::find($data['id']);
|
||||
$customer_mail->important = ($customer_mail->important ? false : true);
|
||||
$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 = CustomerFewoFile::find($data['id']);
|
||||
$fileRepo = new CustomerFewoFileRepository($customer_file);
|
||||
$fileRepo->_set('disk', 'travel_user');
|
||||
$ret = $fileRepo->delete();
|
||||
$status = 'success';
|
||||
}
|
||||
|
||||
if($data['action'] === 'add_attachment'){
|
||||
$arrContextOptions=array(
|
||||
"ssl"=>array(
|
||||
"verify_peer"=>false,
|
||||
"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 CustomerFewoFileRepository(new CustomerFewoFile());
|
||||
$fileRepo->_set('disk', 'travel_user');
|
||||
$fileRepo->_set('dir', '/attachment/'.date('Y/m').'/');
|
||||
$fileRepo->_set('travel_user_id', NULL);
|
||||
$fileRepo->_set('customer_fewo_mail_id', NULL);
|
||||
$fileRepo->_set('identifier', 'tmp');
|
||||
$fileRepo->_set('originalName', $data['name']);
|
||||
$fileRepo->_set('mine', $mine);
|
||||
$fileRepo->_set('extension', $extension);
|
||||
return $fileRepo->storeFile($contents);
|
||||
}
|
||||
}
|
||||
return response()->json(['response' => $data, 'html'=>$ret, 'status'=>$status]);
|
||||
}
|
||||
|
||||
private function getSearchRequests()
|
||||
{
|
||||
if (!Request::get('travel_user_booking_fewo_id')) {
|
||||
return false;
|
||||
}
|
||||
$query = CustomerFewoMail::where('travel_user_booking_fewo_id', '=', Request::get('travel_user_booking_fewo_id'));
|
||||
if (Request::get('customer_mail_dir') == 11) { //draft
|
||||
$query->where('draft', '=', true)->where('dir', '!=', 12);
|
||||
}else{
|
||||
$query->where('dir', '=', Request::get('customer_mail_dir')); //with('lead'
|
||||
}
|
||||
if (Request::get('customer_mail_subdir')) {
|
||||
$query->where('subdir', '=', Request::get('customer_mail_subdir'));
|
||||
}
|
||||
return $query;
|
||||
}
|
||||
|
||||
public function getRequests(){
|
||||
|
||||
$query = $this->getSearchRequests();
|
||||
return \DataTables::eloquent($query)
|
||||
->addColumn('checkbox', function (CustomerFewoMail $customer_mail) {
|
||||
return '<div class="message-checkbox mr-1">
|
||||
<label class="custom-control custom-checkbox">
|
||||
<input type="checkbox" class="custom-control-input">
|
||||
<span class="custom-control-label"></span>
|
||||
</label>
|
||||
</div>';
|
||||
})
|
||||
->addColumn('important', function (CustomerFewoMail $customer_mail) {
|
||||
$icon = ($customer_mail->important ? 'ion-md-star' : 'ion-md-star-outline');
|
||||
return '<a href="javascript:void(0)" class="ion '.$icon.' d-block text-secondary text-big mr-3 customer-mail-ajax-action"
|
||||
data-url="'.route('customer_fewo_mail_ajax').'" data-id="'.$customer_mail->id.'" data-important="'.$customer_mail->important.'" data-action="toggle_important"></a>';
|
||||
})
|
||||
->addColumn('subject', function (CustomerFewoMail $customer_mail) {
|
||||
|
||||
$icon = $customer_mail->reply_id ? 'ion-ios-redo' : 'ion-ios-mail';
|
||||
$badge = $customer_mail->is_answer ? 'badge-next' : 'badge-secondary';
|
||||
$badge = $customer_mail->draft ? 'badge-default' : $badge;
|
||||
$to_icon = $customer_mail->draft ? '<i class="ion ion-ios-warning" style="opacity: 0.7"></i>' : '';
|
||||
$action = $customer_mail->draft ? 'edit-customer-mail' : 'show-customer-mail';
|
||||
$id = $customer_mail->draft ? $customer_mail->id : 'new';
|
||||
$url = $customer_mail->draft ? route('customer_fewo_mail_send_mail') : '';
|
||||
|
||||
return '<a href="javascript:void(0)" class="badge '.$badge.'" data-toggle="modal"
|
||||
data-target="#modals-load-content" data-id="'.$id.'" data-model="CustomerFewoMail"
|
||||
data-action="'.$action.'" data-url="'.$url.'" data-redirect="back"
|
||||
data-customer_mail_id="'.$customer_mail->id.'" data-route="'.route('customer_fewo_modal_load').'">
|
||||
'.$to_icon.'<i class="ion '.$icon.' ui-w-30 text-center" style="opacity: 0.7"></i>'.$customer_mail->subject.'
|
||||
'.($customer_mail->customer_fewo_files->count() ? ' <i class="ion ion-md-attach"> <span class="badge badge-primary indicator">'.$customer_mail->customer_fewo_files->count().'</span></i>' : '');
|
||||
|
||||
})
|
||||
->addColumn('date', function (CustomerFewoMail $customer_mail) {
|
||||
if($customer_mail->send){
|
||||
return '<span class="badge badge-success" style="background-color: #94ae59"><i class="fa fa-check-circle"></i> '.$customer_mail->sent_at.'</span>';
|
||||
}
|
||||
return '<span class="badge badge-default"><i class="fa fa-times-circle"></i> '.$customer_mail->sent_at.'</span>';
|
||||
})
|
||||
->addColumn('action', function (CustomerFewoMail $customer_mail) {
|
||||
$ret = '';
|
||||
if(!$customer_mail->draft){
|
||||
$ret = '<a href="javascript:void(0)" class="btn btn-xs btn-secondary" data-toggle="modal"
|
||||
data-target="#modals-load-content" data-id="reply-send" data-model="customerMail" data-action="new-customer-mail"
|
||||
data-url="'.route('customer_fewo_mail_send_mail').'" data-redirect="back" data-customer_mail_id="'.$customer_mail->id.'"
|
||||
data-travel_user_booking_fewo_id="'.$customer_mail->travel_user_booking_fewo_id.'" data-route="'.route('customer_fewo_modal_load').'" data-customer_mail_dir="'.$customer_mail->dir.'" data-customer_subdir="'.$customer_mail->subdir.'">
|
||||
<span title="Antwort auf E-Mail senden" data-placement="left" rel="tooltip"><i class="ion ion-ios-redo"></i> <i class="ion ion-md-mail-open"></i></span>
|
||||
</a>
|
||||
|
||||
<a href="javascript:void(0)" class="btn btn-xs btn-default" data-toggle="modal"
|
||||
data-target="#modals-load-content" data-id="reply-save" data-model="customerMail" data-action="reply-customer-mail"
|
||||
data-url="'.route('customer_fewo_mail_reply_mail').'" data-redirect="back" data-customer_mail_id="'.$customer_mail->id.'"
|
||||
data-travel_user_booking_fewo_id="'.$customer_mail->travel_user_booking_fewo_id.'" data-route="'.route('customer_fewo_modal_load').'" data-customer_mail_dir="'.$customer_mail->dir.'" data-customer_mail_subdir="'.$customer_mail->subdir.'">
|
||||
<span title="Antwort auf E-Mail speichern" data-placement="left" rel="tooltip"><i class="ion ion-ios-redo"></i> <i class="ion ion-md-mail-unread"></i></span>
|
||||
</a>
|
||||
';
|
||||
}
|
||||
$ret .= '<a href="'.route('customer_fewo_mail_delete', [$customer_mail->id]).'" class="btn btn-xs btn-default text-danger" onclick="return confirm(\'In den Papierkorb verschieben?\');"><i class="ion ion-md-trash"></i></a>';
|
||||
return '<div style="white-space: nowrap;">'.$ret.'</div>';
|
||||
})
|
||||
|
||||
->orderColumn('date', 'sent_at $1')
|
||||
->orderColumn('subject', 'subject $1')
|
||||
->orderColumn('important', 'important $1')
|
||||
->rawColumns(['checkbox', 'important', 'subject', 'date', 'action'])
|
||||
->make(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -3,6 +3,7 @@
|
|||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Customer;
|
||||
use App\Models\CustomerFewoMail;
|
||||
use App\Models\CustomerFile;
|
||||
use App\Models\CustomerMail;
|
||||
use App\Models\EmailTemplate;
|
||||
|
|
@ -39,13 +40,10 @@ class CustomerMailController extends Controller
|
|||
if($id === "new") {
|
||||
$customer_mail = new CustomerMail();
|
||||
$id = 'new';
|
||||
|
||||
}else{
|
||||
$customer_mail = CustomerMail::findOrFail($id);
|
||||
$id = $customer_mail->id;
|
||||
}
|
||||
|
||||
|
||||
$data = [
|
||||
'customer_mail' => $customer_mail,
|
||||
'id' => $id,
|
||||
|
|
@ -58,23 +56,29 @@ class CustomerMailController extends Controller
|
|||
public function store($id, $action=false)
|
||||
{
|
||||
$data = Request::all();
|
||||
$customer_mail = CustomerMail::findOrFail($id);
|
||||
|
||||
if($action === 'move-mail'){
|
||||
$data['travel_country_id'] = isset($data['travel_country_id']) && $data['travel_country_id'] ? $data['travel_country_id'] : null;
|
||||
$customer_mail = CustomerMail::findOrFail($id);
|
||||
$data['subdir'] = isset($data['subdir']) && $data['subdir'] ? $data['subdir'] : null;
|
||||
$customer_mail->dir = $data['dir'];
|
||||
$customer_mail->travel_country_id = $data['travel_country_id'];
|
||||
$customer_mail->subdir = $data['subdir'];
|
||||
$customer_mail->save();
|
||||
|
||||
}
|
||||
if($action === 'move-mail-fewo'){
|
||||
$customer_mail = CustomerFewoMail::findOrFail($id);
|
||||
$data['subdir'] = isset($data['subdir']) && $data['subdir'] ? $data['subdir'] : null;
|
||||
$customer_mail->dir = $data['dir'];
|
||||
$customer_mail->subdir = $data['subdir'];
|
||||
$customer_mail->save();
|
||||
}
|
||||
return back();
|
||||
}
|
||||
|
||||
public function delete($id){
|
||||
$customer_mail = CustomerMail::find($id);
|
||||
$customer_mail->dir = 12;
|
||||
$customer_mail->travel_country_id = null;
|
||||
$customer_mail->draft = false;
|
||||
$customer_mail->subdir = 0;
|
||||
$customer_mail->save();
|
||||
|
||||
\Session()->flash('alert-success', __('Mail gelöscht'));
|
||||
|
|
@ -186,7 +190,11 @@ class CustomerMailController extends Controller
|
|||
|
||||
public function getEmailTemplates()
|
||||
{
|
||||
$query = EmailTemplate::where('active', '=', true);
|
||||
$query = EmailTemplate::with('email_template_dir')->select('email_templates.*')->where('active', '=', true);
|
||||
|
||||
if(Request::get('filter_email_templates_directory') != ""){
|
||||
$query->where('email_template_dir_id', '=', Request::get('filter_email_templates_directory'));
|
||||
}
|
||||
|
||||
return \DataTables::eloquent($query)
|
||||
->addColumn('action', function (EmailTemplate $emailTemplate) {
|
||||
|
|
@ -194,8 +202,12 @@ class CustomerMailController extends Controller
|
|||
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>';
|
||||
})
|
||||
->addColumn('email_template_dir.name', function (EmailTemplate $emailTemplate) {
|
||||
return $emailTemplate->email_template_dir ? '<span class="badge badge-default" style="background-color: '.$emailTemplate->email_template_dir->color.'">'.$emailTemplate->email_template_dir->name.'</span>' : ' ';
|
||||
})
|
||||
->orderColumn('id', 'id $1')
|
||||
->orderColumn('subject', 'subject $1')
|
||||
->orderColumn('email_template_dir.name', 'email_template_dir.name $1')
|
||||
->orderColumn('message', 'message $1')
|
||||
->filterColumn('id', function($query, $keyword) {
|
||||
if($keyword != ""){
|
||||
|
|
@ -204,17 +216,16 @@ class CustomerMailController extends Controller
|
|||
})
|
||||
->filterColumn('subject', function($query, $keyword) {
|
||||
if($keyword != ""){
|
||||
$query->where('subject', 'LIKE', '%'.$keyword.'%');
|
||||
$query->where('name', 'LIKE', '%'.$keyword.'%');
|
||||
$query->OrWhere('subject', 'LIKE', '%'.$keyword.'%');
|
||||
$query->OrWhere('message', 'LIKE', '%'.$keyword.'%');
|
||||
|
||||
}
|
||||
})
|
||||
->rawColumns(['action'])
|
||||
->rawColumns(['action', 'email_template_dir.name'])
|
||||
->make(true);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function uploadAttachment($id){
|
||||
|
||||
$fileRepo = new CustomerFileRepository(new CustomerFile());
|
||||
|
|
@ -290,13 +301,13 @@ class CustomerMailController extends Controller
|
|||
}
|
||||
$query = CustomerMail::where('booking_id', '=', Request::get('booking_id'));
|
||||
if (Request::get('customer_mail_dir') == 11) { //draft
|
||||
$query->where('draft', '=', true);
|
||||
$query->where('draft', '=', true)->where('dir', '!=', 12);
|
||||
}else{
|
||||
$query->where('dir', '=', Request::get('customer_mail_dir')); //with('lead'
|
||||
|
||||
}
|
||||
if (Request::get('customer_mail_country')) {
|
||||
$query->where('travel_country_id', '=', Request::get('customer_mail_country'));
|
||||
if (Request::get('customer_mail_subdir')) {
|
||||
$query->where('subdir', '=', Request::get('customer_mail_subdir'));
|
||||
}
|
||||
return $query;
|
||||
}
|
||||
|
|
@ -348,14 +359,14 @@ class CustomerMailController extends Controller
|
|||
$ret = '<a href="javascript:void(0)" class="btn btn-xs btn-secondary" data-toggle="modal"
|
||||
data-target="#modals-load-content" data-id="reply-send" data-model="customerMail" data-action="new-customer-mail"
|
||||
data-url="'.route('customer_mail_send_mail').'" data-redirect="back" data-customer_mail_id="'.$customer_mail->id.'"
|
||||
data-booking_id="'.$customer_mail->booking_id.'" data-route="'.route('booking_modal_load').'" data-customer_mail_dir="'.$customer_mail->dir.'" data-customer_mail_country="'.$customer_mail->travel_country_id.'">
|
||||
data-booking_id="'.$customer_mail->booking_id.'" data-route="'.route('booking_modal_load').'" data-customer_mail_dir="'.$customer_mail->dir.'" data-customer_mail_subdir="'.$customer_mail->subdir.'">
|
||||
<span title="Antwort auf E-Mail senden" data-placement="left" rel="tooltip"><i class="ion ion-ios-redo"></i> <i class="ion ion-md-mail-open"></i></span>
|
||||
</a>
|
||||
|
||||
<a href="javascript:void(0)" class="btn btn-xs btn-default" data-toggle="modal"
|
||||
data-target="#modals-load-content" data-id="reply-save" data-model="customerMail" data-action="reply-customer-mail"
|
||||
data-url="'.route('customer_mail_reply_mail').'" data-redirect="back" data-customer_mail_id="'.$customer_mail->id.'"
|
||||
data-booking_id="'.$customer_mail->booking_id.'" data-route="'.route('booking_modal_load').'" data-customer_mail_dir="'.$customer_mail->dir.'" data-customer_mail_country="'.$customer_mail->travel_country_id.'">
|
||||
data-booking_id="'.$customer_mail->booking_id.'" data-route="'.route('booking_modal_load').'" data-customer_mail_dir="'.$customer_mail->dir.'" data-customer_mail_subdir="'.$customer_mail->subdir.'">
|
||||
<span title="Antwort auf E-Mail speichern" data-placement="left" rel="tooltip"><i class="ion ion-ios-redo"></i> <i class="ion ion-md-mail-unread"></i></span>
|
||||
</a>
|
||||
';
|
||||
|
|
@ -375,7 +386,7 @@ class CustomerMailController extends Controller
|
|||
/*->filterColumn('subject', function($query, $keyword) {
|
||||
if($keyword != ""){
|
||||
$query->whereRaw("subject LIKE ?", '%'.$keyword.'%');
|
||||
|
||||
|
||||
}
|
||||
})*/
|
||||
->orderColumn('date', 'sent_at $1')
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ namespace App\Http\Controllers;
|
|||
use App\Models\Draft;
|
||||
use App\Models\DraftItem;
|
||||
use App\Models\DraftType;
|
||||
use Request;
|
||||
|
||||
class DraftController extends Controller
|
||||
{
|
||||
|
|
@ -28,7 +29,7 @@ class DraftController extends Controller
|
|||
|
||||
public function detail($id)
|
||||
{
|
||||
if($id == "new") {
|
||||
if($id === "new") {
|
||||
$draft = new Draft();
|
||||
$draft->active = true;
|
||||
$id = 'new';
|
||||
|
|
@ -48,7 +49,7 @@ class DraftController extends Controller
|
|||
public function store($id)
|
||||
{
|
||||
$data = Request::all();
|
||||
if($id == "new") {
|
||||
if($id === "new") {
|
||||
$draft = new Draft();
|
||||
}else{
|
||||
$draft = Draft::findOrFail($id);
|
||||
|
|
@ -145,7 +146,7 @@ class DraftController extends Controller
|
|||
public function typeUpdate(){
|
||||
|
||||
$data = Request::all();
|
||||
if($data['id'] == "new"){
|
||||
if($data['id'] === "new"){
|
||||
$draft_type = DraftType::create([
|
||||
'name' => $data['name'],
|
||||
'active' => isset($data['active']) ? true : false,
|
||||
|
|
@ -158,8 +159,6 @@ class DraftController extends Controller
|
|||
$draft_type->active = isset($data['active']) ? true : false;
|
||||
$draft_type->color = $data['color'];
|
||||
$draft_type->pos = $data['pos'];
|
||||
|
||||
|
||||
$draft_type->save();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -27,6 +27,11 @@ class FileController extends Controller
|
|||
$filename = $file->original_name;
|
||||
$path = $file->getPath();
|
||||
}
|
||||
if ($disk === 'travel_user'){
|
||||
$file = \App\Models\CustomerFewoFile::findOrFail($id);
|
||||
$filename = $file->original_name;
|
||||
$path = $file->getPath();
|
||||
}
|
||||
|
||||
if ($disk === 'booking'){
|
||||
$file = \App\Models\BookingFile::findOrFail($id);
|
||||
|
|
@ -34,6 +39,18 @@ class FileController extends Controller
|
|||
$path = $file->getPath();
|
||||
}
|
||||
|
||||
if ($disk === 'general'){
|
||||
$file = \App\Models\GeneralFile::findOrFail($id);
|
||||
$filename = $file->original_name;
|
||||
$path = $file->getPath();
|
||||
}
|
||||
|
||||
if ($disk === 'booking_fewo'){
|
||||
$file = \App\Models\TravelUserBookingFile::findOrFail($id);
|
||||
$filename = $file->original_name;
|
||||
$path = $file->getPath();
|
||||
}
|
||||
|
||||
if ($disk === 'cms_file'){
|
||||
$file = \App\Models\CMSContent::findOrFail($id);
|
||||
$filename = $file->name;
|
||||
|
|
|
|||
70
app/Http/Controllers/ModalController.php
Normal file
70
app/Http/Controllers/ModalController.php
Normal file
|
|
@ -0,0 +1,70 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\GeneralFile;
|
||||
use App\Models\TravelCountry;
|
||||
use App\Models\TravelCountryService;
|
||||
use App\Repositories\GeneralFileRepository;
|
||||
use Request;
|
||||
|
||||
class ModalController extends Controller
|
||||
{
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('auth');
|
||||
}
|
||||
|
||||
public function load(){
|
||||
$data = Request::all();
|
||||
$ret = "";
|
||||
$status = false;
|
||||
if(Request::ajax()){
|
||||
|
||||
if($data['action'] === "upload-travel_country-file"){
|
||||
if($value = TravelCountry::find($data['id'])){
|
||||
$generalFileRepo = new GeneralFileRepository(new GeneralFile());
|
||||
$generalFileRepo->_set('disk', 'general');
|
||||
$generalFileRepo->_set('travel_country_id', $data['id']);
|
||||
$generalFileRepo->_set('dir', '/'.date('Y/m').'/');
|
||||
$generalFileRepo->_set('identifier', 'travel_country');
|
||||
$generalFileRepo->_set('redirect', $data['back']);
|
||||
|
||||
return $generalFileRepo->uploadFile(Request::all());
|
||||
}
|
||||
}
|
||||
if($data['action'] === 'modal-upload-travel_country-file'){
|
||||
$data['action'] = 'upload-travel_country-file';
|
||||
$ret = view("admin.modal.upload", compact('data'))->render();
|
||||
}
|
||||
|
||||
if($data['action'] === 'modal-travel_country-services'){
|
||||
if($data['id'] === 'new'){
|
||||
$value = new TravelCountryService();
|
||||
$value->active = true;
|
||||
}else{
|
||||
$value = TravelCountryService::find($data['id']);
|
||||
}
|
||||
$ret = view("admin.modal.country-service", compact('data', 'value'))->render();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
return response()->json(['response' => $data, 'html'=>$ret, 'status'=>$status]);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/* <button type="button" class="btn btn-sm btn-primary" data-toggle="modal"
|
||||
data-target="#modals-load-content"
|
||||
data-id="{{ $value->id }}"
|
||||
data-model="emailTemplate"
|
||||
data-action="modal-email-template"
|
||||
data-url=""
|
||||
data-redirect="back"
|
||||
data-route="{{ route('modal_load') }}"><span class="fa fa-edit"></span></button>*/
|
||||
|
|
@ -9,6 +9,7 @@ use App\Models\Status;
|
|||
use App\Models\Sym\TravelCountry;
|
||||
use App\Models\TravelAgenda;
|
||||
use App\Models\TravelCompany;
|
||||
use App\Models\TravelCountryService;
|
||||
use App\Repositories\CustomerMailRepository;
|
||||
use Carbon\Carbon;
|
||||
use Request;
|
||||
|
|
@ -79,7 +80,7 @@ class RequestController extends Controller
|
|||
*/
|
||||
private function getSearchRequests(){
|
||||
|
||||
$query = Booking::with('lead')->with('customer')->with('customer_mails')->select('booking.*')->where('lead_id', '!=', NULL);
|
||||
$query = Booking::with('lead')->with('customer')->with('customer_mails')->with('customer_mails')->select('booking.*')->where('lead_id', '!=', NULL);
|
||||
|
||||
if(Request::get('full_firstname_search') != ""){
|
||||
$query->whereHas('customer', function ($q) {
|
||||
|
|
@ -225,9 +226,33 @@ class RequestController extends Controller
|
|||
|
||||
public function getAjaxRequests(){
|
||||
|
||||
$query = $this->getSearchRequests();
|
||||
$ret = $query->get()->pluck('travelagenda_id', 'id')->unique()->toArray();
|
||||
return TravelAgenda::whereIn('id', $ret)->get()->pluck('name', 'id');
|
||||
$data = Request::all();
|
||||
|
||||
if(Request::ajax()) {
|
||||
if(isset($data['action']) && $data['action'] === "get_popover_booking_services") {
|
||||
$booking = Booking::findOrFail($data['booking_id']);
|
||||
$ret = "";
|
||||
|
||||
foreach($booking->travel_country->getContactLandsModels() as $TravelCountry){
|
||||
if($TravelCountry->stern_travel_country){
|
||||
foreach($TravelCountry->stern_travel_country->travel_country_services as $travel_country_service){
|
||||
$ret .= \App\Models\BookingCountryService::getStatus($travel_country_service->id, $booking->id) ?
|
||||
'<span class="badge badge-pill badge-success"><i class="fa fa-check"></i> '.$travel_country_service->name.'</span>' :
|
||||
'<span class="badge badge-pill badge-danger""><i class="fa fa-times"></i> '.$travel_country_service->name.'</span>';
|
||||
$ret .= '<br>';
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
if($ret === ""){
|
||||
return 'keine Leistungen definiert';
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
$query = $this->getSearchRequests();
|
||||
$ret = $query->get()->pluck('travelagenda_id', 'id')->unique()->toArray();
|
||||
return TravelAgenda::whereIn('id', $ret)->get()->pluck('name', 'id');
|
||||
}
|
||||
}
|
||||
|
||||
public function loadModal(){
|
||||
|
|
@ -290,8 +315,13 @@ class RequestController extends Controller
|
|||
return $booking->getEndDateFormat();
|
||||
})
|
||||
->addColumn('travel_documents', function (Booking $booking) {
|
||||
return $booking->travel_documents ? ' <span data-order="1" class="badge badge-pill badge-success"><i class="fa fa-check"></i></span>' : '<span data-order="0" class="badge badge-pill badge-danger"><i class="fa fa-times"></i></span>';
|
||||
return $booking->travel_documents ? '<span data-order="1" class="badge badge-pill badge-success" title="Reiseunterlagen" data-placement="top" rel="tooltip"><i class="fa fa-check"></i></span>' : '<span data-order="0" class="badge badge-pill badge-danger" title="Reiseunterlagen" data-placement="top" rel="tooltip"><i class="fa fa-times"></i></span>';
|
||||
})
|
||||
->addColumn('booking_country_services', function (Booking $booking) {
|
||||
return $booking->hasBookingCountryServicesUnchecked() ? '<span data-order="1" class="badge badge-pill badge-success" data-booking_id="'.$booking->id.'" data-placement="top" data-toggle="popover" title="Reise-, Agenturleistungen"><i class="fa fa-check"></i></span>' :
|
||||
'<span data-order="0" class="badge badge-pill badge-danger" data-booking_id="'.$booking->id.'" data-placement="top" data-toggle="popover" title="Reise-, Agenturleistungen"><i class="fa fa-times"></i></span>';
|
||||
})
|
||||
|
||||
->addColumn('sf_guard_user_id', function (Booking $booking) {
|
||||
return '<span data-order="'.($booking->sf_guard_user_id ? $booking->sf_guard_user_id : 0).'">'.($booking->sf_guard_user_id? $booking->sf_guard_user->first_name." ".$booking->sf_guard_user->last_name : "-").'</span>';
|
||||
})
|
||||
|
|
@ -312,7 +342,6 @@ class RequestController extends Controller
|
|||
if($booking->lawyer_date){
|
||||
return '<span data-order="'.$booking->lead->status_id.'"><span class="badge badge-dark" style="background-color: '.$color.'">'.$icon.$booking->lawyer_date->format('d.m.Y').'</span></span>';
|
||||
}
|
||||
|
||||
}
|
||||
return '<span data-order="'.$booking->lead->status_id.'"><span class="badge badge-dark" style="background-color: '.$color.'">'.$icon.$booking->lead->status->name.'</span></span>';
|
||||
}
|
||||
|
|
@ -348,7 +377,7 @@ class RequestController extends Controller
|
|||
return '<span data-order="'.$booking->refund_date.'"><span class="badge badge-'.$booking->getRefundColor().'">'.$booking->getRefundTypeList().'</span></span>';
|
||||
})
|
||||
->addColumn('hold', function (Booking $booking) {
|
||||
return $booking->hold ? ' <span data-order="1" class="badge badge-pill badge-success"><i class="fa fa-check"></i></span>' : '<span data-order="0" class="badge badge-pill badge-danger"><i class="fa fa-times"></i></span>';
|
||||
return $booking->hold ? ' <span data-order="1" class="badge badge-pill badge-success" title="Hold" data-placement="top" rel="tooltip"><i class="fa fa-check"></i></span>' : '<span data-order="0" class="badge badge-pill badge-danger" title="Hold" data-placement="top" rel="tooltip"><i class="fa fa-times"></i></span>';
|
||||
})
|
||||
->addColumn('xx_tkt', function (Booking $booking) {
|
||||
return '<span data-order="'.$booking->xx_tkt_date.'"><span class="badge badge-'.$booking->getXxTktColor().'">'.$booking->getXxTktTypeList().'</span></span>';
|
||||
|
|
@ -391,8 +420,8 @@ class RequestController extends Controller
|
|||
->orderColumn('airline_id', 'airline_id $1')
|
||||
->orderColumn('hold', 'hold $1')
|
||||
->orderColumn('xx_tkt', 'xx_tkt_date $1')
|
||||
->orderColumn('travel_documents', 'travel_documents $1')
|
||||
->rawColumns(['action_lead_edit', 'lead_id', 'participant_firstname', 'participant_name', 'action_booking_edit', 'travel_country_id', 'travelagenda_id', 'travel_company_id', 'sf_guard_user_id', 'lead.status_id', 'last_customer_email', 'id', 'travel_documents', 'paying_out', 'paying_out_status', 'airline_id', 'refund', 'hold', 'xx_tkt'])
|
||||
//->orderColumn('travel_documents', 'travel_documents $1')
|
||||
->rawColumns(['action_lead_edit', 'lead_id', 'participant_firstname', 'participant_name', 'action_booking_edit', 'travel_country_id', 'travelagenda_id', 'travel_company_id', 'sf_guard_user_id', 'lead.status_id', 'last_customer_email', 'id', 'travel_documents', 'booking_country_services', 'paying_out', 'paying_out_status', 'airline_id', 'refund', 'hold', 'xx_tkt'])
|
||||
->make(true);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,75 +0,0 @@
|
|||
<?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();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
143
app/Http/Controllers/Settings/EmailsController.php
Executable file
143
app/Http/Controllers/Settings/EmailsController.php
Executable file
|
|
@ -0,0 +1,143 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Settings;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
|
||||
use App\Models\CMSContent;
|
||||
use App\Models\EmailTemplate;
|
||||
use App\Models\EmailTemplateDir;
|
||||
use App\Services\Booking;
|
||||
use App\Services\BookingFewo;
|
||||
use App\Services\Util;
|
||||
use Request;
|
||||
|
||||
class EmailsController extends Controller
|
||||
{
|
||||
|
||||
protected $identifier_booking_file;
|
||||
protected $identifier_fewo_file;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->identifier_booking_file = 'booking-email-file';
|
||||
$this->identifier_fewo_file = 'fewo-email-file';
|
||||
$this->middleware('admin');
|
||||
}
|
||||
|
||||
|
||||
public function index($step = false)
|
||||
{
|
||||
|
||||
$data = [
|
||||
'email_template' => EmailTemplate::all(),
|
||||
'email_template_dirs' => EmailTemplateDir::all(),
|
||||
'booking_email_files' => CMSContent::where('identifier', '=', $this->identifier_booking_file)->get()->sortByDesc('pos'),
|
||||
'customer_mail_dirs' => Booking::getCustomerMailDirs(),
|
||||
'identifier_booking_file' => $this->identifier_booking_file,
|
||||
'identifier_fewo_file' => $this->identifier_fewo_file,
|
||||
'fewo_email_files' => CMSContent::where('identifier', '=', $this->identifier_fewo_file)->get()->sortByDesc('pos'),
|
||||
'customer_fewo_mail_dirs' => BookingFewo::getCustomerMailDirs(),
|
||||
'step' => $step
|
||||
|
||||
];
|
||||
return view('settings.emails.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']);
|
||||
|
||||
}
|
||||
$directories = EmailTemplateDir::where('active', '=', true)->get();
|
||||
$ret = view("settings.emails.modal", compact('value', 'directories'))->render();
|
||||
}
|
||||
}
|
||||
return response()->json(['response' => $data, 'html'=>$ret]);
|
||||
}
|
||||
|
||||
public function update(){
|
||||
|
||||
$data = Request::all();
|
||||
$data['active'] = isset($data['active']) ? true : false;
|
||||
$data['step'] = isset($data['step']) ? $data['step'] : false;
|
||||
|
||||
if($data['action'] === 'email_template'){
|
||||
if($data['id'] === "new" || $data['id'] == 0){
|
||||
$model = EmailTemplate::create($data);
|
||||
}else{
|
||||
$model = EmailTemplate::find($data['id']);
|
||||
$model->fill($data);
|
||||
$model->save();
|
||||
}
|
||||
}
|
||||
if($data['action'] === 'email_template_dir') {
|
||||
if($data['id'] === "new"){
|
||||
EmailTemplateDir::create($data);
|
||||
}else{
|
||||
$model = EmailTemplateDir::find($data['id']);
|
||||
$model->fill($data);
|
||||
$model->save();
|
||||
}
|
||||
}
|
||||
|
||||
if($data['action'] === 'customer_mail_dirs') {
|
||||
$data['object'] = [
|
||||
'icon' => $data['icon'],
|
||||
'model' => $data['model'],
|
||||
'emails' => isset($data['emails']) ? Util::_explodeLines($data['emails']) : null,
|
||||
];
|
||||
|
||||
$pos = $data['pos'];
|
||||
if($pos > 9){
|
||||
\Session()->flash('alert-error', 'max 9 Ordner für E-Mail Ablage');
|
||||
return redirect(route('admin_settings_emails', [$data['step']]));
|
||||
}
|
||||
if($data['id'] === "new"){
|
||||
//check ist pos
|
||||
if(CMSContent::where('identifier', '=', $data['identifier'])->where('pos', '=', $pos)->count()){
|
||||
\Session()->flash('alert-error', 'Die ID '.$pos.' existiert schon');
|
||||
return redirect(route('admin_settings_emails', [$data['step']]));
|
||||
}
|
||||
CMSContent::create($data);
|
||||
//store in cms old Datebase
|
||||
\App\Models\Sym\CmsContent::create($data);
|
||||
}else{
|
||||
$model = CMSContent::find($data['id']);
|
||||
if($model->pos != $pos && CMSContent::where('identifier', '=', $data['identifier'])->where('pos', '=', $pos)->count()){
|
||||
\Session()->flash('alert-error', 'Die ID '.$pos.' existiert schon');
|
||||
return redirect(route('admin_settings_emails', [$data['step']]));
|
||||
}
|
||||
$model->fill($data);
|
||||
$model->save();
|
||||
|
||||
$m = \App\Models\Sym\CmsContent::find($data['id']);
|
||||
$m->fill($data);
|
||||
$m->save();
|
||||
}
|
||||
}
|
||||
|
||||
\Session()->flash('alert-save', '1');
|
||||
return redirect(route('admin_settings_emails', [$data['step']]));
|
||||
}
|
||||
|
||||
public function delete($id){
|
||||
|
||||
$model = EmailTemplate::findOrFail($id);
|
||||
$model->delete();
|
||||
\Session()->flash('alert-success', 'Eintrag gelöscht');
|
||||
return redirect()->back();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -4,9 +4,14 @@ namespace App\Http\Controllers\Settings;
|
|||
|
||||
use App\Http\Controllers\Controller;
|
||||
|
||||
use App\Models\GeneralFile;
|
||||
use App\Models\TravelCountry;
|
||||
use App\Models\TravelCountryService;
|
||||
use App\Models\TravelNationality;
|
||||
use App\Repositories\CustomerFileRepository;
|
||||
use App\Repositories\GeneralFileRepository;
|
||||
use App\Services\Util;
|
||||
use IqContent\LaravelFilemanager\Lfm;
|
||||
use Request;
|
||||
|
||||
class TravelCountryController extends Controller
|
||||
|
|
@ -48,27 +53,45 @@ class TravelCountryController extends Controller
|
|||
'id' => $id,
|
||||
'step' => $step,
|
||||
'travel_nationalities' => TravelNationality::where('active', true)->get(),
|
||||
'lfm_helper' => app(Lfm::class),
|
||||
|
||||
];
|
||||
return view('settings.travel_country.detail', $data);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function update($id)
|
||||
{
|
||||
|
||||
$data = Request::all();
|
||||
|
||||
if(isset($data['update-action'])){
|
||||
if($data['update-action'] === 'save-travel-county-service'){
|
||||
$data['active'] = true;//isset($data['active']) ? true : false;
|
||||
$travel_country = TravelCountry::findOrFail($id);
|
||||
$data['travel_country_id'] = $travel_country->id;
|
||||
$data['crm_travel_country_id'] = $travel_country->crm_id;
|
||||
if($data['travel_county_service_id'] === 'new'){
|
||||
$model = TravelCountryService::create($data);
|
||||
}else{
|
||||
$model = TravelCountryService::find($data['travel_county_service_id']);
|
||||
$model->fill($data);
|
||||
$model->save();
|
||||
}
|
||||
\Session()->flash('alert-save', '1');
|
||||
return redirect($data['back']);
|
||||
}
|
||||
}
|
||||
|
||||
$data['contact_emails'] = isset($data['contact_emails']) ? Util::_explodeLines($data['contact_emails']) : null;
|
||||
if(!isset($data['contact_lands'])){
|
||||
$data['contact_lands'] = null;
|
||||
}
|
||||
$data['action'] = isset($data['action']) ? $data['action'] : false;
|
||||
/*
|
||||
* $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);
|
||||
|
|
@ -82,41 +105,64 @@ class TravelCountryController extends Controller
|
|||
$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();
|
||||
}
|
||||
|
||||
$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]));
|
||||
return redirect(route('admin_settings_travel_country_detail', [$model->id, $data['action']]));
|
||||
}
|
||||
|
||||
|
||||
public function delete($id){
|
||||
$model = TravelCountry::findOrFail($id);
|
||||
if( $model->travel_nationality_requirements){
|
||||
foreach($model->travel_nationality_requirements as $travel_nationality_requirement){
|
||||
$travel_nationality_requirement->delete();
|
||||
public function delete($id, $del="travel_country"){
|
||||
|
||||
if($del === 'travel_country'){
|
||||
$model = TravelCountry::findOrFail($id);
|
||||
if($model->travel_nationality_requirements){
|
||||
foreach($model->travel_nationality_requirements as $travel_nationality_requirement){
|
||||
$travel_nationality_requirement->delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
$tc = \App\Models\Sym\TravelCountry::find($model->crm_id);
|
||||
if($tc){
|
||||
$tc->delete();
|
||||
$tc = \App\Models\Sym\TravelCountry::find($model->crm_id);
|
||||
if($tc){
|
||||
$tc->delete();
|
||||
}
|
||||
$model->delete();
|
||||
\Session()->flash('alert-success', 'Eintrag gelöscht');
|
||||
return redirect()->back();
|
||||
}
|
||||
|
||||
if($del === 'general_file'){
|
||||
$general_file = GeneralFile::findOrFail($id);
|
||||
$travel_country = $general_file->travel_country;
|
||||
$fileRepo = new GeneralFileRepository($general_file);
|
||||
$fileRepo->_set('disk', 'general');
|
||||
$fileRepo->delete();
|
||||
$general_file->delete();
|
||||
\Session()->flash('alert-success', 'Datei gelöscht');
|
||||
return redirect(route('admin_settings_travel_country_detail', [$travel_country->id, 'data']));
|
||||
|
||||
}
|
||||
if($del === 'country_service'){
|
||||
$travel_country_service = TravelCountryService::findOrFail($id);
|
||||
$travel_country = $travel_country_service->travel_country;
|
||||
//check as entry
|
||||
if($travel_country_service->booking_country_services->count() > 0){
|
||||
\Session()->flash('alert-error', 'Die Leistung kann nicht gelöscht werden, diese hat Einträge bei den Buchungen');
|
||||
return redirect(route('admin_settings_travel_country_detail', [$travel_country->id, 'services']));
|
||||
}
|
||||
$travel_country_service->delete();
|
||||
\Session()->flash('alert-success', 'Eintrag gelöscht');
|
||||
return redirect(route('admin_settings_travel_country_detail', [$travel_country->id, 'services']));
|
||||
|
||||
}
|
||||
|
||||
$model->delete();
|
||||
\Session()->flash('alert-success', 'Eintrag gelöscht');
|
||||
return redirect()->back();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -7,8 +7,12 @@ use App\Mail\MailSendFeWoInvoice;
|
|||
use App\Mail\MailSendFeWoService;
|
||||
use App\Mail\MailSendFeWoInfo;
|
||||
use App\Models\CMSContent;
|
||||
use App\Models\FewoLodging;
|
||||
use App\Models\FewoReservation;
|
||||
use App\Models\TravelBookingFewoChannel;
|
||||
use App\Models\TravelUserBookingFewo;
|
||||
use App\Models\TravelUserBookingFile;
|
||||
use App\Repositories\BookingFewoFileRepository;
|
||||
use App\Repositories\TravelUserBookingFewoRepository;
|
||||
use App\Services\Util;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
|
|
@ -23,12 +27,16 @@ class TravelUserBookingFewoController extends Controller
|
|||
$this->middleware('admin');
|
||||
$this->userBookingFewoRepo = $userBookingFewoRepo;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function index($step = false)
|
||||
{
|
||||
$data = [
|
||||
'step' => $step
|
||||
'step' => $step,
|
||||
'filter_fewo_options' => FewoLodging::get()->pluck('name', 'id'),
|
||||
'filter_channel_options' => TravelBookingFewoChannel::get()->pluck('name', 'id'),
|
||||
];
|
||||
return view('travel.user.booking.index', $data);
|
||||
|
||||
|
|
@ -41,13 +49,13 @@ class TravelUserBookingFewoController extends Controller
|
|||
|
||||
$replace_info_text = [];
|
||||
|
||||
if($id == "new") {
|
||||
if($id === "new") {
|
||||
$travel_user_booking_fewo = new TravelUserBookingFewo();
|
||||
$id = 'new';
|
||||
}else{
|
||||
$travel_user_booking_fewo = TravelUserBookingFewo::findOrFail($id);
|
||||
$max_adults = isset($travel_user_booking_fewo->fewo_lodging->maximum_adults) ? $travel_user_booking_fewo->fewo_lodging->maximum_adults : 10;
|
||||
$max_children = isset($travel_user_booking_fewo->fewo_lodging->maximum_childs) ? $travel_user_booking_fewo->fewo_lodging->maximum_childs : 10;;
|
||||
$max_adults = $travel_user_booking_fewo->fewo_lodging->maximum_adults ? $travel_user_booking_fewo->fewo_lodging->maximum_adults : 10;
|
||||
$max_children = $travel_user_booking_fewo->fewo_lodging->maximum_childs ? $travel_user_booking_fewo->fewo_lodging->maximum_childs : 10;;
|
||||
$id = $travel_user_booking_fewo->id;
|
||||
$replace_info_text['fewo_user_anrede'] = $travel_user_booking_fewo->getUserSalutation();
|
||||
$replace_info_text['fewo_adresse'] = $travel_user_booking_fewo->getNameAddressLocation(", ");
|
||||
|
|
@ -171,58 +179,87 @@ class TravelUserBookingFewoController extends Controller
|
|||
}
|
||||
}
|
||||
|
||||
public function delete($id){
|
||||
$model = TravelUserBookingFewo::findOrFail($id);
|
||||
$FewoReservations = FewoReservation::where('lodging_id', $model->fewo_lodging_id)->where('from_date', $model->getFromDateRaw())->where('to_date', $model->getToDateRaw())->get();
|
||||
foreach ($FewoReservations as $FewoReservation){
|
||||
$FewoReservation->delete();
|
||||
public function delete($id, $del="travel_user_booking_fewo"){
|
||||
|
||||
if($del === 'travel_user_booking_fewo') {
|
||||
$model = TravelUserBookingFewo::findOrFail($id);
|
||||
$FewoReservations = FewoReservation::where('lodging_id', $model->fewo_lodging_id)->where('from_date', $model->getFromDateRaw())->where('to_date', $model->getToDateRaw())->get();
|
||||
foreach ($FewoReservations as $FewoReservation) {
|
||||
$FewoReservation->delete();
|
||||
}
|
||||
$model->delete();
|
||||
\Session()->flash('alert-success', __('Buchung gelöscht sowie die Reservierung im Sterntrous Kalender'));
|
||||
}
|
||||
if($del === 'booking_fewo_files'){
|
||||
$booking_fewo_file = TravelUserBookingFile::findOrFail($id);
|
||||
$travel_user_booking_fewo = $booking_fewo_file->travel_user_booking_fewo;
|
||||
$fileRepo = new BookingFewoFileRepository($booking_fewo_file);
|
||||
$fileRepo->_set('disk', 'booking_fewo');
|
||||
$fileRepo->delete();
|
||||
$booking_fewo_file->delete();
|
||||
\Session()->flash('alert-success', 'Datei gelöscht');
|
||||
return redirect(route('travel_user_booking_fewo_detail', [$travel_user_booking_fewo->id]));
|
||||
}
|
||||
$model->delete();
|
||||
\Session()->flash('alert-success', __('Buchung gelöscht sowie die Reservierung im Sterntrous Kalender'));
|
||||
return redirect(route('travel_user_booking_fewos'));
|
||||
}
|
||||
|
||||
private function prozessTravelUserBookingFewosSearch(){
|
||||
|
||||
$query = TravelUserBookingFewo::with('travel_booking_fewo_channel')->with('fewo_lodging')
|
||||
->select('travel_user_booking_fewos.*')
|
||||
->where('deleted_at', '=', null);
|
||||
|
||||
if(Request::get('option_fewo_id') != ""){
|
||||
$query->where('fewo_lodging_id', '=', Request::get('option_fewo_id'));
|
||||
}
|
||||
if(Request::get('option_channel_id') != ""){
|
||||
$query->where('travel_booking_fewo_channel_id', '=', Request::get('option_channel_id'));
|
||||
}
|
||||
return $query;
|
||||
}
|
||||
|
||||
public function getTravelUserBookingFewos()
|
||||
{
|
||||
//confirmation_code_remider is delete 2
|
||||
$query = TravelUserBookingFewo::where('deleted_at', '=', null);
|
||||
|
||||
$query = $this->prozessTravelUserBookingFewosSearch();
|
||||
|
||||
return \DataTables::eloquent($query)
|
||||
->addColumn('action_edit', function (TravelUserBookingFewo $travel_user_booking_fewo) {
|
||||
return '<a data-order="'.$travel_user_booking_fewo->id.'" href="' . route('travel_user_booking_fewo_detail', [$travel_user_booking_fewo->id]) . '" class="btn icon-btn btn-sm btn-primary"><span class="fa fa-edit"></span></a>';
|
||||
})
|
||||
->addColumn('fewo_lodging', function (TravelUserBookingFewo $travel_user_booking_fewo) {
|
||||
//return '<a href="' . route('travel_user_booking_fewo_detail', [$travel_user_booking_fewo->fewo_lodging_id]) . '">'.$travel_user_booking_fewo->fewo_lodging->name.'</a>';
|
||||
return $travel_user_booking_fewo->fewo_lodging->name;
|
||||
})
|
||||
->addColumn('travel_user', function (TravelUserBookingFewo $travel_user_booking_fewo) {
|
||||
return '<a href="' . route('travel_user_detail', [$travel_user_booking_fewo->travel_user_id]) . '">'.$travel_user_booking_fewo->travel_user->first_name.' '.$travel_user_booking_fewo->travel_user->last_name.'</a>';
|
||||
})
|
||||
->addColumn('is_calendar', function (TravelUserBookingFewo $travel_user_booking_fewo) {
|
||||
$back = "";
|
||||
$back = "<div class='no-break'>";
|
||||
$back .= get_active_badge($travel_user_booking_fewo->is_calendar_fewo_direct, "FEWO Direkt")." ";
|
||||
$back .= get_active_badge($travel_user_booking_fewo->is_calendar_hrs, "HRS")." ";
|
||||
$back .= get_active_badge($travel_user_booking_fewo->is_calendar_stern_tours, "STERN TOURS");
|
||||
$back .= "</div>";
|
||||
return $back;
|
||||
})
|
||||
->addColumn('is_mail', function (TravelUserBookingFewo $travel_user_booking_fewo) {
|
||||
$back = "";
|
||||
$back = "<div class='no-break'>";
|
||||
$back .= get_active_badge($travel_user_booking_fewo->isSendUserMail(), "Mietbestätigung")." ";
|
||||
$back .= get_active_badge($travel_user_booking_fewo->isSendInfoMail(), "Anrreiseinfo")." ";
|
||||
$back .= get_active_badge($travel_user_booking_fewo->isSendServiceMail(), "Dienstleister Mail");
|
||||
$back .= "</div>";
|
||||
return $back;
|
||||
})
|
||||
->addColumn('status_name', function (TravelUserBookingFewo $travel_user_booking_fewo) {
|
||||
return $travel_user_booking_fewo->getStatuesName();
|
||||
})
|
||||
->addColumn('action_delete', function (TravelUserBookingFewo $travel_user_booking_fewo) {
|
||||
return '<a href="' . route('travel_user_booking_fewo_delete', [$travel_user_booking_fewo->id]) . '" class="btn icon-btn btn-sm btn-danger" onclick="return confirm(\''.__('Really delete entry?').'\');"><span class="fa fa-trash"></span></a>';
|
||||
})
|
||||
->rawColumns(['action_edit', 'fewo_lodging', 'travel_user', 'is_calendar', 'is_mail', 'action_delete'])
|
||||
->filterColumn('fewo_lodging.name', function ($query, $keyword) {
|
||||
if ($keyword != "") {
|
||||
$query->whereHas('travel_user', function ($q) use ($keyword) {
|
||||
$q->where("first_name", 'LIKE', '%' . $keyword . '%')
|
||||
->orWhere('last_name', 'LIKE', '%' . $keyword . '%');
|
||||
});
|
||||
}
|
||||
})
|
||||
->rawColumns(['action_edit', 'travel_user', 'is_calendar', 'is_mail', 'action_delete'])
|
||||
->make(true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -47,4 +47,12 @@ class Airline extends Model
|
|||
|
||||
protected $casts = ['contact_emails' => 'array'];
|
||||
|
||||
public static function getAsNameIdArray($empty = true){
|
||||
$ret = Airline::get()->pluck('name', 'id')->toArray();
|
||||
if($empty){
|
||||
$first = [null => "-"];
|
||||
return $first + $ret;
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -287,11 +287,12 @@ class Booking extends Model
|
|||
2 => 'erledigt',
|
||||
];
|
||||
|
||||
public static $hold_types = [
|
||||
0 => '-',
|
||||
1 => 'eingetragen',
|
||||
];
|
||||
|
||||
public static $customer_mail_dirs = [
|
||||
0 => ['name' => 'Reisender', 'icon'=>'ion-ios-filing'],
|
||||
1 => ['name' => 'Agentur', 'icon'=>'ion-ios-folder-open'],
|
||||
2 => ['name' => 'Flug', 'icon'=>'ion-ios-airplane'],
|
||||
3 => ['name' => 'Versicherung', 'icon'=>'ion-ios-help-buoy'],
|
||||
11 => ['name' => 'Entwürfe', 'icon'=>'ion-md-create'],
|
||||
12 => ['name' => 'Papierkorb', 'icon'=>'ion-md-trash'],
|
||||
];
|
||||
|
|
@ -473,6 +474,23 @@ class Booking extends Model
|
|||
return $this->hasMany(BookingFile::class);
|
||||
}
|
||||
|
||||
public function booking_country_services()
|
||||
{
|
||||
return $this->hasMany(BookingCountryService::class, 'booking_id');
|
||||
}
|
||||
|
||||
public function booking_country_services_checked()
|
||||
{
|
||||
return $this->hasMany(BookingCountryService::class, 'booking_id')->where('status', '=', 0);
|
||||
}
|
||||
|
||||
public function hasBookingCountryServicesUnchecked(){
|
||||
if(!$this->booking_country_services->count() || $this->booking_country_services_checked->count() ||
|
||||
($this->booking_country_services->count() !== TravelCountryService::where('crm_travel_country_id', '=', $this->travel_country_id)->count())){
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public function calculate_price_total()
|
||||
{
|
||||
|
|
@ -740,13 +758,13 @@ class Booking extends Model
|
|||
return isset($this->xx_tkt_colors[$this->xx_tkt]) ? $this->xx_tkt_colors[$this->xx_tkt] : '-';
|
||||
}
|
||||
|
||||
public function countCustomerMailsBy($dir, $country=false){
|
||||
public function countCustomerMailsBy($dir, $subdir=false){
|
||||
|
||||
if($dir === 11){
|
||||
return $this->customer_mails->where('draft', true)->count();
|
||||
return $this->customer_mails->where('draft', true)->where('dir', '!=', 12)->count();
|
||||
}
|
||||
if($country){
|
||||
return $this->customer_mails->where('dir', $dir)->where('travel_country_id', $country)->count();
|
||||
if($subdir){
|
||||
return $this->customer_mails->where('dir', $dir)->where('subdir', $subdir)->count();
|
||||
}
|
||||
return $this->customer_mails->where('dir', $dir)->count();
|
||||
}
|
||||
|
|
|
|||
75
app/Models/BookingCountryService.php
Normal file
75
app/Models/BookingCountryService.php
Normal file
|
|
@ -0,0 +1,75 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Created by Reliese Model.
|
||||
*/
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
/**
|
||||
* Class BookingCountryService
|
||||
*
|
||||
* @property int $id
|
||||
* @property int $travel_country_service_id
|
||||
* @property int $booking_id
|
||||
* @property Carbon $created_at
|
||||
* @property Carbon $updated_at
|
||||
* @property Booking $booking
|
||||
* @property TravelCountryService $travel_country_service
|
||||
* @package App\Models
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\BookingCountryService newModelQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\BookingCountryService newQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\BookingCountryService query()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\BookingCountryService whereBookingId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\BookingCountryService whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\BookingCountryService whereId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\BookingCountryService whereTravelCountryServiceId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\BookingCountryService whereUpdatedAt($value)
|
||||
* @mixin \Eloquent
|
||||
*/
|
||||
class BookingCountryService extends Model
|
||||
{
|
||||
protected $connection = 'mysql';
|
||||
|
||||
protected $table = 'booking_country_services';
|
||||
|
||||
protected $casts = [
|
||||
'travel_country_service_id' => 'int',
|
||||
'booking_id' => 'int',
|
||||
'status' => 'int'
|
||||
];
|
||||
|
||||
protected $fillable = [
|
||||
'travel_country_service_id',
|
||||
'booking_id',
|
||||
'status'
|
||||
];
|
||||
|
||||
protected $status_type = [
|
||||
0 => 'offen',
|
||||
1 => 'erledigt',
|
||||
];
|
||||
|
||||
public function booking()
|
||||
{
|
||||
return $this->belongsTo(Booking::class);
|
||||
}
|
||||
|
||||
public function travel_country_service()
|
||||
{
|
||||
return $this->belongsTo(TravelCountryService::class);
|
||||
}
|
||||
|
||||
public static function getStatus($travel_country_service_id, $booking_id){
|
||||
$booking_country_service = BookingCountryService::where('travel_country_service_id', '=', $travel_country_service_id)
|
||||
->where('booking_id', '=', $booking_id)->first();
|
||||
|
||||
if($booking_country_service){
|
||||
return $booking_country_service->status;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
|
@ -50,13 +50,6 @@ class BookingFile extends Model
|
|||
'size' => 'int'
|
||||
];
|
||||
|
||||
public static $icon_ext = [
|
||||
'default' => 'fa fa-file',
|
||||
'pdf'=> 'fa fa-file-pdf',
|
||||
'jpg'=> 'fa fa-file-image',
|
||||
'png'=> 'fa fa-file-image',
|
||||
];
|
||||
|
||||
protected $fillable = [
|
||||
'booking_id',
|
||||
'identifier',
|
||||
|
|
@ -68,6 +61,13 @@ class BookingFile extends Model
|
|||
'size'
|
||||
];
|
||||
|
||||
public static $icon_ext = [
|
||||
'default' => 'fa fa-file',
|
||||
'pdf'=> 'fa fa-file-pdf',
|
||||
'jpg'=> 'fa fa-file-image',
|
||||
'png'=> 'fa fa-file-image',
|
||||
];
|
||||
|
||||
public function booking()
|
||||
{
|
||||
return $this->belongsTo(Booking::class);
|
||||
|
|
|
|||
|
|
@ -32,6 +32,12 @@ use Illuminate\Database\Eloquent\Model;
|
|||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CMSContent newModelQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CMSContent newQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CMSContent query()
|
||||
* @property string|null $identifier
|
||||
* @property array|null $object
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CMSContent whereIdentifier($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CMSContent whereObject($value)
|
||||
* @property int|null $pos
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CMSContent wherePos($value)
|
||||
*/
|
||||
class CMSContent extends Model
|
||||
{
|
||||
|
|
@ -59,7 +65,12 @@ class CMSContent extends Model
|
|||
protected $table = 'c_m_s_contents';
|
||||
|
||||
protected $fillable = [
|
||||
'name', 'slug', 'field', 'text', 'full_text', 'integer', 'decimal',
|
||||
'name', 'slug', 'identifier', 'field', 'text', 'full_text', 'object', 'integer', 'decimal', 'pos',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'object' => 'array',
|
||||
'pos' => 'int'
|
||||
];
|
||||
|
||||
public function sluggable()
|
||||
|
|
@ -107,11 +118,14 @@ class CMSContent extends Model
|
|||
return $this->full_text;
|
||||
break;
|
||||
case 'file':
|
||||
return \GuzzleHttp\json_decode($this->full_text);
|
||||
// return \GuzzleHttp\json_decode($this->full_text);
|
||||
return $this->object;
|
||||
break;
|
||||
case 'array':
|
||||
return $this->object;
|
||||
break;
|
||||
case 'integer':
|
||||
return $this->integer;
|
||||
|
||||
break;
|
||||
case 'decimal':
|
||||
return $this->decimal;
|
||||
|
|
@ -122,13 +136,21 @@ class CMSContent extends Model
|
|||
|
||||
//FILE ------------------------
|
||||
public function isFile(){
|
||||
return $this->field === 'file' ? true : false;
|
||||
return $this->id > 0 && $this->field === 'file' ? true : false;
|
||||
}
|
||||
/*'identifier', 'filename', 'dir', 'original_name', 'ext', 'mine', 'size'*/
|
||||
public function getFileContent($key= false){
|
||||
if($key && $this->isFile()){
|
||||
$file = \GuzzleHttp\json_decode($this->full_text);
|
||||
return isset($file->{$key}) ? $file->{$key} : false;
|
||||
// $file = \GuzzleHttp\json_decode($this->full_text);
|
||||
return isset($this->object[$key]) ? $this->object[$key] : false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function getArrayContent($key= false){
|
||||
if($key && $this->field === 'array'){
|
||||
// $file = \GuzzleHttp\json_decode($this->full_text);
|
||||
return isset($this->object[$key]) ? $this->object[$key] : false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
@ -209,7 +231,10 @@ class CMSContent extends Model
|
|||
return $CMSContent->full_text;
|
||||
break;
|
||||
case 'file':
|
||||
return \GuzzleHttp\json_decode($CMSContent->full_text);
|
||||
return $CMSContent->object; //\GuzzleHttp\json_decode($CMSContent->full_text);
|
||||
break;
|
||||
case 'array':
|
||||
return $CMSContent->object; //\GuzzleHttp\json_decode($CMSContent->full_text);
|
||||
break;
|
||||
case 'integer':
|
||||
return $CMSContent->integer;
|
||||
|
|
|
|||
115
app/Models/CustomerFewoFile.php
Normal file
115
app/Models/CustomerFewoFile.php
Normal file
|
|
@ -0,0 +1,115 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Created by Reliese Model.
|
||||
*/
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
/**
|
||||
* Class CustomerFewoFile
|
||||
*
|
||||
* @property int $id
|
||||
* @property int $travel_user_id
|
||||
* @property int $customer_fewo_mail_id
|
||||
* @property string $identifier
|
||||
* @property string $filename
|
||||
* @property string $dir
|
||||
* @property string $original_name
|
||||
* @property string $ext
|
||||
* @property string $mine
|
||||
* @property int $size
|
||||
* @property Carbon $created_at
|
||||
* @property Carbon $updated_at
|
||||
* @property CustomerFewoMail $customer_fewo_mail
|
||||
* @property TravelUser $travel_user
|
||||
* @package App\Models
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerFewoFile newModelQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerFewoFile newQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerFewoFile query()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerFewoFile whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerFewoFile whereCustomerFewoMailId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerFewoFile whereDir($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerFewoFile whereExt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerFewoFile whereFilename($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerFewoFile whereId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerFewoFile whereIdentifier($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerFewoFile whereMine($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerFewoFile whereOriginalName($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerFewoFile whereSize($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerFewoFile whereTravelUserId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerFewoFile whereUpdatedAt($value)
|
||||
* @mixin \Eloquent
|
||||
*/
|
||||
class CustomerFewoFile extends Model
|
||||
{
|
||||
protected $connection = 'mysql_stern';
|
||||
|
||||
protected $table = 'customer_fewo_files';
|
||||
|
||||
protected $casts = [
|
||||
'travel_user_id' => 'int',
|
||||
'customer_fewo_mail_id' => 'int',
|
||||
'size' => 'int'
|
||||
];
|
||||
|
||||
protected $fillable = [
|
||||
'travel_user_id',
|
||||
'customer_fewo_mail_id',
|
||||
'identifier',
|
||||
'filename',
|
||||
'dir',
|
||||
'original_name',
|
||||
'ext',
|
||||
'mine',
|
||||
'size'
|
||||
];
|
||||
|
||||
public static $icon_ext = [
|
||||
'default' => 'fa fa-file',
|
||||
'pdf'=> 'fa fa-file-pdf',
|
||||
'jpg'=> 'fa fa-file-image',
|
||||
'png'=> 'fa fa-file-image',
|
||||
];
|
||||
|
||||
public function customer_fewo_mail()
|
||||
{
|
||||
return $this->belongsTo(CustomerFewoMail::class);
|
||||
}
|
||||
|
||||
public function travel_user()
|
||||
{
|
||||
return $this->belongsTo(TravelUser::class);
|
||||
}
|
||||
|
||||
public function getIconExt(){
|
||||
return isset(self::$icon_ext[$this->ext]) ? self::$icon_ext[$this->ext] : self::$icon_ext['default'];
|
||||
}
|
||||
|
||||
public function getURL($do=false){
|
||||
return route('storage_file', [$this->id, 'travel_user', $do]);
|
||||
}
|
||||
|
||||
public function getPath(){
|
||||
return \Storage::disk('travel_user')->path($this->dir.$this->filename);
|
||||
|
||||
}
|
||||
|
||||
public function formatBytes($precision = 2)
|
||||
{
|
||||
$size = $this->size;
|
||||
|
||||
if ($size > 0) {
|
||||
$size = (int) $size;
|
||||
$base = log($size) / log(1024);
|
||||
$suffixes = array(' bytes', ' KB', ' MB', ' GB', ' TB');
|
||||
|
||||
return round(pow(1024, $base - floor($base)), $precision) . $suffixes[floor($base)];
|
||||
} else {
|
||||
return $size;
|
||||
}
|
||||
}
|
||||
}
|
||||
189
app/Models/CustomerFewoMail.php
Normal file
189
app/Models/CustomerFewoMail.php
Normal file
|
|
@ -0,0 +1,189 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Created by Reliese Model.
|
||||
*/
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
/**
|
||||
* Class CustomerFewoMail
|
||||
*
|
||||
* @property int $id
|
||||
* @property int $travel_user_booking_fewo_id
|
||||
* @property int $travel_user_id
|
||||
* @property bool $is_answer
|
||||
* @property int $reply_id
|
||||
* @property string $email
|
||||
* @property string $recipient
|
||||
* @property string $cc
|
||||
* @property string $bcc
|
||||
* @property string $subject
|
||||
* @property string $message
|
||||
* @property int $dir
|
||||
* @property int $subdir
|
||||
* @property bool $draft
|
||||
* @property bool $important
|
||||
* @property bool $send
|
||||
* @property bool $fail
|
||||
* @property string $error
|
||||
* @property Carbon $sent_at
|
||||
* @property Carbon $scheduled_at
|
||||
* @property Carbon $delivered_at
|
||||
* @property Carbon $created_at
|
||||
* @property Carbon $updated_at
|
||||
* @property CustomerFewoMail $customer_fewo_mail
|
||||
* @property TravelUserBookingFewo $travel_user_booking_fewo
|
||||
* @property TravelUser $travel_user
|
||||
* @property Collection|CustomerFewoFile[] $customer_fewo_files
|
||||
* @property Collection|CustomerFewoMail[] $customer_fewo_mails
|
||||
* @package App\Models
|
||||
* @property-read int|null $customer_fewo_files_count
|
||||
* @property-read int|null $customer_fewo_mails_count
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerFewoMail newModelQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerFewoMail newQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerFewoMail query()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerFewoMail whereBcc($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerFewoMail whereCc($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerFewoMail whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerFewoMail whereDeliveredAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerFewoMail whereDir($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerFewoMail whereDraft($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerFewoMail whereEmail($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerFewoMail whereError($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerFewoMail whereFail($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerFewoMail whereId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerFewoMail whereImportant($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerFewoMail whereIsAnswer($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerFewoMail whereMessage($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerFewoMail whereRecipient($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerFewoMail whereReplyId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerFewoMail whereScheduledAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerFewoMail whereSend($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerFewoMail whereSentAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerFewoMail whereSubdir($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerFewoMail whereSubject($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerFewoMail whereTravelUserBookingFewoId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerFewoMail whereTravelUserId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerFewoMail whereUpdatedAt($value)
|
||||
* @mixin \Eloquent
|
||||
* @property-read \App\Models\TravelUserBookingFewo $booking
|
||||
* @property-read \App\Models\TravelUser $customer
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\CustomerFewoFile[] $customer_files
|
||||
* @property-read int|null $customer_files_count
|
||||
* @property-read \App\Models\CustomerFewoMail|null $customer_mail
|
||||
*/
|
||||
class CustomerFewoMail extends Model
|
||||
{
|
||||
protected $connection = 'mysql_stern';
|
||||
|
||||
protected $table = 'customer_fewo_mails';
|
||||
|
||||
protected $casts = [
|
||||
'travel_user_booking_fewo_id' => 'int',
|
||||
'travel_user_id' => 'int',
|
||||
'is_answer' => 'bool',
|
||||
'reply_id' => 'int',
|
||||
'dir' => 'int',
|
||||
'subdir' => 'int',
|
||||
'draft' => 'bool',
|
||||
'important' => 'bool',
|
||||
'send' => 'bool',
|
||||
'fail' => 'bool',
|
||||
'recipient' => 'array',
|
||||
'cc' => 'array',
|
||||
'bcc' => 'array'
|
||||
];
|
||||
|
||||
protected $dates = [
|
||||
'sent_at',
|
||||
'scheduled_at',
|
||||
'delivered_at'
|
||||
];
|
||||
|
||||
protected $fillable = [
|
||||
'travel_user_booking_fewo_id',
|
||||
'travel_user_id',
|
||||
'is_answer',
|
||||
'reply_id',
|
||||
'email',
|
||||
'recipient',
|
||||
'cc',
|
||||
'bcc',
|
||||
'subject',
|
||||
'message',
|
||||
'dir',
|
||||
'subdir',
|
||||
'draft',
|
||||
'important',
|
||||
'send',
|
||||
'fail',
|
||||
'error',
|
||||
'sent_at',
|
||||
'scheduled_at',
|
||||
'delivered_at'
|
||||
];
|
||||
|
||||
public function customer_fewo_mail()
|
||||
{
|
||||
return $this->belongsTo(CustomerFewoMail::class, 'reply_id');
|
||||
}
|
||||
|
||||
public function customer_mail()
|
||||
{
|
||||
return $this->belongsTo(CustomerFewoMail::class, 'reply_id');
|
||||
}
|
||||
|
||||
public function travel_user_booking_fewo()
|
||||
{
|
||||
return $this->belongsTo(TravelUserBookingFewo::class);
|
||||
}
|
||||
|
||||
public function booking()
|
||||
{
|
||||
return $this->belongsTo(TravelUserBookingFewo::class);
|
||||
}
|
||||
|
||||
public function travel_user()
|
||||
{
|
||||
return $this->belongsTo(TravelUser::class);
|
||||
}
|
||||
|
||||
public function customer()
|
||||
{
|
||||
return $this->belongsTo(TravelUser::class, 'travel_user_id');
|
||||
}
|
||||
|
||||
public function customer_fewo_files()
|
||||
{
|
||||
return $this->hasMany(CustomerFewoFile::class);
|
||||
}
|
||||
|
||||
public function customer_files()
|
||||
{
|
||||
return $this->hasMany(CustomerFewoFile::class, 'customer_fewo_mail_id');
|
||||
}
|
||||
|
||||
public function customer_fewo_mails()
|
||||
{
|
||||
return $this->hasMany(CustomerFewoMail::class, 'reply_id');
|
||||
}
|
||||
|
||||
public function getSentAtRaw(){
|
||||
return $this->attributes['sent_at'];
|
||||
}
|
||||
|
||||
public function getSentAtAttribute(){
|
||||
if(!$this->attributes['sent_at']){ return ""; }
|
||||
return Carbon::parse($this->attributes['sent_at'])->format(\Util::formatDateTimeDB());
|
||||
}
|
||||
|
||||
public function getCreatedAtAttribute(){
|
||||
if(!$this->attributes['created_at']){ return ""; }
|
||||
return Carbon::parse($this->attributes['created_at'])->format(\Util::formatDateTimeDB());
|
||||
}
|
||||
}
|
||||
|
|
@ -58,12 +58,6 @@ class CustomerFile extends Model
|
|||
'size' => 'int'
|
||||
];
|
||||
|
||||
public static $icon_ext = [
|
||||
'default' => 'fa fa-file',
|
||||
'pdf'=> 'fa fa-file-pdf',
|
||||
'jpg'=> 'fa fa-file-image',
|
||||
'png'=> 'fa fa-file-image',
|
||||
];
|
||||
protected $fillable = [
|
||||
'customer_id',
|
||||
'customer_mail_id',
|
||||
|
|
@ -76,6 +70,13 @@ class CustomerFile extends Model
|
|||
'size'
|
||||
];
|
||||
|
||||
public static $icon_ext = [
|
||||
'default' => 'fa fa-file',
|
||||
'pdf'=> 'fa fa-file-pdf',
|
||||
'jpg'=> 'fa fa-file-image',
|
||||
'png'=> 'fa fa-file-image',
|
||||
];
|
||||
|
||||
public function customer()
|
||||
{
|
||||
return $this->belongsTo(Customer::class);
|
||||
|
|
|
|||
|
|
@ -75,6 +75,8 @@ use Illuminate\Database\Eloquent\Model;
|
|||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerMail whereTravelCountryId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerMail whereUpdatedAt($value)
|
||||
* @mixin \Eloquent
|
||||
* @property int|null $subdir
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerMail whereSubdir($value)
|
||||
*/
|
||||
class CustomerMail extends Model
|
||||
{
|
||||
|
|
@ -96,7 +98,8 @@ class CustomerMail extends Model
|
|||
'is_answer' => 'bool',
|
||||
'reply_id' => 'int',
|
||||
'dir' => 'int',
|
||||
'travel_country_id' => 'int',
|
||||
'subdir' => 'int',
|
||||
'travel_country_id' => 'int',
|
||||
'draft' => 'bool',
|
||||
'important' => 'bool',
|
||||
'send' => 'bool',
|
||||
|
|
@ -125,7 +128,8 @@ class CustomerMail extends Model
|
|||
'subject',
|
||||
'message',
|
||||
'dir',
|
||||
'travel_country_id',
|
||||
'subdir',
|
||||
'travel_country_id',
|
||||
'draft',
|
||||
'important',
|
||||
'send',
|
||||
|
|
|
|||
|
|
@ -11,29 +11,49 @@ use Illuminate\Database\Eloquent\Model;
|
|||
|
||||
/**
|
||||
* Class EmailTemplate
|
||||
*
|
||||
*
|
||||
* @property int $id
|
||||
* @property int $email_template_dir_id
|
||||
* @property string $subject
|
||||
* @property string $message
|
||||
* @property bool $active
|
||||
* @property Carbon $created_at
|
||||
* @property Carbon $updated_at
|
||||
*
|
||||
* @property EmailTemplateDir $email_template_dir
|
||||
* @package App\Models
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\EmailTemplate newModelQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\EmailTemplate newQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\EmailTemplate query()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\EmailTemplate whereActive($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\EmailTemplate whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\EmailTemplate whereEmailTemplateDirId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\EmailTemplate whereId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\EmailTemplate whereMessage($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\EmailTemplate whereSubject($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\EmailTemplate whereUpdatedAt($value)
|
||||
* @mixin \Eloquent
|
||||
* @property string $name
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\EmailTemplate whereName($value)
|
||||
*/
|
||||
class EmailTemplate extends Model
|
||||
{
|
||||
protected $connection = 'mysql';
|
||||
|
||||
protected $table = 'email_templates';
|
||||
protected $table = 'email_templates';
|
||||
|
||||
protected $casts = [
|
||||
'email_template_dir_id' => 'int',
|
||||
'active' => 'bool'
|
||||
];
|
||||
|
||||
protected $fillable = [
|
||||
'email_template_dir_id',
|
||||
'name',
|
||||
'subject',
|
||||
'message',
|
||||
'active'
|
||||
];
|
||||
|
||||
public function email_template_dir()
|
||||
{
|
||||
return $this->belongsTo(EmailTemplateDir::class);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
58
app/Models/EmailTemplateDir.php
Normal file
58
app/Models/EmailTemplateDir.php
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Created by Reliese Model.
|
||||
*/
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
/**
|
||||
* Class EmailTemplateDir
|
||||
*
|
||||
* @property int $id
|
||||
* @property string $name
|
||||
* @property string $color
|
||||
* @property bool $active
|
||||
* @property int $pos
|
||||
* @property Carbon $created_at
|
||||
* @property Carbon $updated_at
|
||||
* @property Collection|EmailTemplate[] $email_templates
|
||||
* @package App\Models
|
||||
* @property-read int|null $email_templates_count
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\EmailTemplateDir newModelQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\EmailTemplateDir newQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\EmailTemplateDir query()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\EmailTemplateDir whereActive($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\EmailTemplateDir whereColor($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\EmailTemplateDir whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\EmailTemplateDir whereId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\EmailTemplateDir whereName($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\EmailTemplateDir wherePos($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\EmailTemplateDir whereUpdatedAt($value)
|
||||
* @mixin \Eloquent
|
||||
*/
|
||||
class EmailTemplateDir extends Model
|
||||
{
|
||||
protected $table = 'email_template_dirs';
|
||||
|
||||
protected $casts = [
|
||||
'active' => 'bool',
|
||||
'pos' => 'int'
|
||||
];
|
||||
|
||||
protected $fillable = [
|
||||
'name',
|
||||
'color',
|
||||
'active',
|
||||
'pos'
|
||||
];
|
||||
|
||||
public function email_templates()
|
||||
{
|
||||
return $this->hasMany(EmailTemplate::class);
|
||||
}
|
||||
}
|
||||
106
app/Models/GeneralFile.php
Normal file
106
app/Models/GeneralFile.php
Normal file
|
|
@ -0,0 +1,106 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Created by Reliese Model.
|
||||
*/
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
/**
|
||||
* Class GeneralFile
|
||||
*
|
||||
* @property int $id
|
||||
* @property int $travel_country_id
|
||||
* @property string $identifier
|
||||
* @property string $filename
|
||||
* @property string $dir
|
||||
* @property string $original_name
|
||||
* @property string $ext
|
||||
* @property string $mine
|
||||
* @property int $size
|
||||
* @property Carbon $created_at
|
||||
* @property Carbon $updated_at
|
||||
* @property TravelCountry $travel_country
|
||||
* @package App\Models
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\GeneralFile newModelQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\GeneralFile newQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\GeneralFile query()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\GeneralFile whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\GeneralFile whereDir($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\GeneralFile whereExt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\GeneralFile whereFilename($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\GeneralFile whereId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\GeneralFile whereIdentifier($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\GeneralFile whereMine($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\GeneralFile whereOriginalName($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\GeneralFile whereSize($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\GeneralFile whereTravelCountryId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\GeneralFile whereUpdatedAt($value)
|
||||
* @mixin \Eloquent
|
||||
*/
|
||||
class GeneralFile extends Model
|
||||
{
|
||||
protected $connection = 'mysql';
|
||||
|
||||
protected $table = 'general_files';
|
||||
|
||||
protected $casts = [
|
||||
'travel_country_id' => 'int',
|
||||
'size' => 'int'
|
||||
];
|
||||
|
||||
protected $fillable = [
|
||||
'travel_country_id',
|
||||
'identifier',
|
||||
'filename',
|
||||
'dir',
|
||||
'original_name',
|
||||
'ext',
|
||||
'mine',
|
||||
'size'
|
||||
];
|
||||
|
||||
public static $icon_ext = [
|
||||
'default' => 'fa fa-file',
|
||||
'pdf'=> 'fa fa-file-pdf',
|
||||
'jpg'=> 'fa fa-file-image',
|
||||
'png'=> 'fa fa-file-image',
|
||||
];
|
||||
|
||||
|
||||
public function travel_country()
|
||||
{
|
||||
return $this->belongsTo(TravelCountry::class, 'travel_country_id');
|
||||
}
|
||||
|
||||
public function getIconExt(){
|
||||
return isset(self::$icon_ext[$this->ext]) ? self::$icon_ext[$this->ext] : self::$icon_ext['default'];
|
||||
}
|
||||
|
||||
public function getURL($do=false){
|
||||
return route('storage_file', [$this->id, 'general', $do]);
|
||||
}
|
||||
|
||||
public function getPath(){
|
||||
return \Storage::disk('general')->path($this->dir.$this->filename);
|
||||
|
||||
}
|
||||
|
||||
public function formatBytes($precision = 2)
|
||||
{
|
||||
$size = $this->size;
|
||||
|
||||
if ($size > 0) {
|
||||
$size = (int) $size;
|
||||
$base = log($size) / log(1024);
|
||||
$suffixes = array(' bytes', ' KB', ' MB', ' GB', ' TB');
|
||||
|
||||
return round(pow(1024, $base - floor($base)), $precision) . $suffixes[floor($base)];
|
||||
} else {
|
||||
return $size;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -11,7 +11,7 @@ use Illuminate\Database\Eloquent\Model;
|
|||
|
||||
/**
|
||||
* Class Insurance
|
||||
*
|
||||
*
|
||||
* @property int $id
|
||||
* @property string $name
|
||||
* @property string $name_full
|
||||
|
|
@ -19,8 +19,17 @@ use Illuminate\Database\Eloquent\Model;
|
|||
* @property bool $active
|
||||
* @property Carbon $created_at
|
||||
* @property Carbon $updated_at
|
||||
*
|
||||
* @package App\Models
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Insurance newModelQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Insurance newQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Insurance query()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Insurance whereActive($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Insurance whereContactEmails($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Insurance whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Insurance whereId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Insurance whereName($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Insurance whereUpdatedAt($value)
|
||||
* @mixin \Eloquent
|
||||
*/
|
||||
class Insurance extends Model
|
||||
{
|
||||
|
|
|
|||
|
|
@ -27,6 +27,10 @@ use Illuminate\Database\Eloquent\Model;
|
|||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ServiceProvider whereName($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ServiceProvider whereType($value)
|
||||
* @mixin \Eloquent
|
||||
* @property array|null $contact_emails
|
||||
* @property bool|null $active
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ServiceProvider whereActive($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ServiceProvider whereContactEmails($value)
|
||||
*/
|
||||
class ServiceProvider extends Model
|
||||
{
|
||||
|
|
|
|||
|
|
@ -34,6 +34,12 @@ use Illuminate\Database\Eloquent\Model;
|
|||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Sym\CmsContent whereUpdatedAt($value)
|
||||
* @mixin \Eloquent
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Sym\CmsContent findSimilarSlugs($attribute, $config, $slug)
|
||||
* @property string|null $identifier
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Sym\CmsContent whereIdentifier($value)
|
||||
* @property array|null $object
|
||||
* @property int|null $pos
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Sym\CmsContent whereObject($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Sym\CmsContent wherePos($value)
|
||||
*/
|
||||
class CmsContent extends Model
|
||||
{
|
||||
|
|
@ -45,7 +51,12 @@ class CmsContent extends Model
|
|||
protected $table = 'cms_contents';
|
||||
|
||||
protected $fillable = [
|
||||
'name', 'slug', 'field', 'text', 'full_text', 'integer', 'decimal',
|
||||
'name', 'slug', 'identifier', 'field', 'text', 'full_text', 'object', 'integer', 'decimal', 'pos',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'object' => 'array',
|
||||
'pos' => 'int'
|
||||
];
|
||||
|
||||
public $timestamps = false;
|
||||
|
|
|
|||
|
|
@ -3,7 +3,9 @@
|
|||
namespace App\Models\Sym;
|
||||
|
||||
use App\Models\Booking;
|
||||
use App\Models\GeneralFile;
|
||||
use App\Models\Lead;
|
||||
use App\Models\TravelCountryService;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
|
||||
|
|
@ -40,6 +42,13 @@ use Illuminate\Database\Eloquent\Model;
|
|||
* @property-read int|null $bookings_count
|
||||
* @property array|null $contact_emails
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Sym\TravelCountry whereContactEmails($value)
|
||||
* @property array|null $mail_dirs
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Sym\TravelCountry whereMailDirs($value)
|
||||
* @property string|null $mail_dir_name
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Sym\TravelCountry whereMailDirName($value)
|
||||
* @property-read \App\Models\TravelCountry|null $stern_travel_country
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\TravelCountryService[] $travel_country_services
|
||||
* @property-read int|null $travel_country_services_count
|
||||
*/
|
||||
class TravelCountry extends Model
|
||||
{
|
||||
|
|
@ -53,6 +62,8 @@ class TravelCountry extends Model
|
|||
'is_customer_country',
|
||||
'active_backend',
|
||||
'contact_lands',
|
||||
'mail_dir_name',
|
||||
'mail_dirs',
|
||||
'contact_headline',
|
||||
'contact_text_1',
|
||||
'contact_text_2',
|
||||
|
|
@ -63,7 +74,7 @@ class TravelCountry extends Model
|
|||
|
||||
];
|
||||
|
||||
protected $casts = ['contact_lands' => 'array', 'contact_emails' => 'array'];
|
||||
protected $casts = ['contact_lands' => 'array', 'mail_dirs'=>'array', 'contact_emails' => 'array'];
|
||||
|
||||
public $timestamps = false;
|
||||
|
||||
|
|
@ -77,6 +88,16 @@ class TravelCountry extends Model
|
|||
return $this->hasMany(Booking::class, 'travel_country_id', 'id');
|
||||
}
|
||||
|
||||
public function stern_travel_country()
|
||||
{
|
||||
return $this->hasOne(\App\Models\TravelCountry::class, 'crm_id', 'id');
|
||||
}
|
||||
|
||||
public function travel_country_services()
|
||||
{
|
||||
return $this->hasMany(TravelCountryService::class, 'crm_travel_country_id', 'id')->orderBy('pos', 'DESC');
|
||||
}
|
||||
|
||||
public function getCountryLands(){
|
||||
$ret = [];
|
||||
if($this->contact_lands){
|
||||
|
|
@ -90,4 +111,22 @@ class TravelCountry extends Model
|
|||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
public function getMailDirs($id){
|
||||
return isset($this->mail_dirs[$id]) ? $this->mail_dirs[$id] : [];
|
||||
}
|
||||
|
||||
public function getContactLandsModels(){
|
||||
$ret = [];
|
||||
if($this->contact_lands){
|
||||
foreach ($this->contact_lands as $travel_country_id){
|
||||
if($travel_country = TravelCountry::find($travel_country_id)){
|
||||
$ret[$travel_country->id] = $travel_country;
|
||||
}
|
||||
}
|
||||
}else{
|
||||
$ret[$this->id] = $this;
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,6 +34,8 @@ use Illuminate\Database\Eloquent\Model;
|
|||
* @mixin \Eloquent
|
||||
* @property int|null $active
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelCompany whereActive($value)
|
||||
* @property array|null $contact_emails
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelCompany whereContactEmails($value)
|
||||
*/
|
||||
class TravelCompany extends Model
|
||||
{
|
||||
|
|
|
|||
|
|
@ -60,6 +60,15 @@ use Illuminate\Support\Str;
|
|||
* @property-read int|null $travel_nationality_requirements_count
|
||||
* @property array|null $contact_emails
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelCountry whereContactEmails($value)
|
||||
* @property array|null $mail_dirs
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelCountry whereMailDirs($value)
|
||||
* @property string $mail_dir_name
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelCountry whereMailDirName($value)
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\GeneralFile[] $general_files
|
||||
* @property-read int|null $general_files_count
|
||||
* @property-read \App\Models\Sym\TravelCountry|null $crm_travel_country
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\TravelCountryService[] $travel_country_services
|
||||
* @property-read int|null $travel_country_services_count
|
||||
*/
|
||||
class TravelCountry extends Model
|
||||
{
|
||||
|
|
@ -68,7 +77,6 @@ class TravelCountry extends Model
|
|||
|
||||
protected $table = 'travel_country';
|
||||
|
||||
|
||||
protected $fillable = [
|
||||
'name',
|
||||
'slug',
|
||||
|
|
@ -76,6 +84,8 @@ class TravelCountry extends Model
|
|||
'text_before',
|
||||
'text_after',
|
||||
'contact_lands',
|
||||
'mail_dir_name',
|
||||
'mail_dirs',
|
||||
'contact_headline',
|
||||
'contact_text_1',
|
||||
'contact_text_2',
|
||||
|
|
@ -90,7 +100,7 @@ class TravelCountry extends Model
|
|||
|
||||
];
|
||||
|
||||
protected $casts = ['contact_lands' => 'array', 'contact_emails' => 'array'];
|
||||
protected $casts = ['contact_lands' => 'array', 'mail_dirs' => 'array', 'contact_emails' => 'array'];
|
||||
|
||||
|
||||
public $timestamps = false;
|
||||
|
|
@ -105,11 +115,26 @@ class TravelCountry extends Model
|
|||
return $this->belongsTo('App\Models\Page', 'feedback_page_id', 'id');
|
||||
}
|
||||
|
||||
public function crm_travel_country()
|
||||
{
|
||||
return $this->belongsTo(\App\Models\Sym\TravelCountry::class, 'crm_id', 'id');
|
||||
}
|
||||
|
||||
public function travel_nationality_requirements()
|
||||
{
|
||||
return $this->hasMany('App\Models\TravelNationalityRequirement', 'travel_country_id', 'id');
|
||||
}
|
||||
|
||||
public function general_files()
|
||||
{
|
||||
return $this->hasMany(GeneralFile::class, 'travel_country_id', 'id');
|
||||
}
|
||||
|
||||
public function travel_country_services()
|
||||
{
|
||||
return $this->hasMany(TravelCountryService::class, 'travel_country_id', 'id')->orderBy('pos', 'DESC');
|
||||
}
|
||||
|
||||
public function setSlugAttribute( $value ) {
|
||||
if(!isset($value) || $value == ""){
|
||||
$this->attributes['slug'] = Str::slug(pre_slug($this->name), '-');
|
||||
|
|
@ -131,6 +156,23 @@ class TravelCountry extends Model
|
|||
return $ret;
|
||||
}
|
||||
|
||||
public function getMailDirs($id){
|
||||
return isset($this->mail_dirs[$id]) ? $this->mail_dirs[$id] : [];
|
||||
}
|
||||
|
||||
public function getContactLandsModels(){
|
||||
$ret = [];
|
||||
if($this->contact_lands){
|
||||
foreach ($this->contact_lands as $travel_country_id){
|
||||
if($travel_country = TravelCountry::where('crm_id', $contact_land_id)->first()){
|
||||
$ret[$travel_country->id] = $travel_country;
|
||||
}
|
||||
}
|
||||
}else{
|
||||
$ret[$this->id] = $this;
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
public function getNationalityRequirement($travel_nationality_id){
|
||||
|
||||
$model = TravelNationalityRequirement::where('travel_country_id', $this->id)->where('travel_nationality_id', $travel_nationality_id)->first();
|
||||
|
|
|
|||
85
app/Models/TravelCountryService.php
Normal file
85
app/Models/TravelCountryService.php
Normal file
|
|
@ -0,0 +1,85 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Created by Reliese Model.
|
||||
*/
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
/**
|
||||
* Class TravelCountryService
|
||||
*
|
||||
* @property int $id
|
||||
* @property int $travel_country_id
|
||||
* @property int $crm_travel_country
|
||||
* @property string $name
|
||||
* @property string $description
|
||||
* @property bool $active
|
||||
* @property Carbon $created_at
|
||||
* @property Carbon $updated_at
|
||||
* @property TravelCountry $travel_country
|
||||
* @property Collection|BookingCountryService[] $booking_country_services
|
||||
* @package App\Models
|
||||
* @property int|null $crm_travel_country_id
|
||||
* @property int|null $pos
|
||||
* @property-read int|null $booking_country_services_count
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelCountryService newModelQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelCountryService newQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelCountryService query()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelCountryService whereActive($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelCountryService whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelCountryService whereCrmTravelCountryId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelCountryService whereDescription($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelCountryService whereId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelCountryService whereName($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelCountryService wherePos($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelCountryService whereTravelCountryId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelCountryService whereUpdatedAt($value)
|
||||
* @mixin \Eloquent
|
||||
*/
|
||||
class TravelCountryService extends Model
|
||||
{
|
||||
protected $connection = 'mysql';
|
||||
|
||||
protected $table = 'travel_country_services';
|
||||
|
||||
protected $casts = [
|
||||
'travel_country_id' => 'int',
|
||||
'crm_travel_country_id' => 'int',
|
||||
'pos' => 'int',
|
||||
'active' => 'bool'
|
||||
];
|
||||
|
||||
protected $fillable = [
|
||||
'travel_country_id',
|
||||
'crm_travel_country_id',
|
||||
'name',
|
||||
'description',
|
||||
'pos',
|
||||
'active'
|
||||
];
|
||||
|
||||
protected $status_type = [
|
||||
0 => 'offen',
|
||||
1 => 'erledigt',
|
||||
];
|
||||
|
||||
public function travel_country()
|
||||
{
|
||||
return $this->belongsTo(TravelCountry::class, 'travel_country_id');
|
||||
}
|
||||
|
||||
public function crm_travel_country()
|
||||
{
|
||||
return $this->belongsTo(\App\Models\Sym\TravelCountry::class);
|
||||
}
|
||||
|
||||
public function booking_country_services()
|
||||
{
|
||||
return $this->hasMany(BookingCountryService::class);
|
||||
}
|
||||
}
|
||||
|
|
@ -131,4 +131,8 @@ class TravelUser extends Model
|
|||
public function setBirthdayAttribute( $value ) {
|
||||
$this->attributes['birthday'] = isset($value) ? (new Carbon($value))->format('Y-m-d') : NULL;
|
||||
}
|
||||
|
||||
public function getSalutation(){
|
||||
return $this->salutation_id == 1 ? 'Herr' : 'Frau';
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -98,6 +98,14 @@ use App\Services\Util;
|
|||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelUserBookingFewo whereUpdatedAt($value)
|
||||
* @property string|null $last_change_at
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelUserBookingFewo whereLastChangeAt($value)
|
||||
* @property-read \App\Models\CustomerFewoMail|null $customer_fewo_mail_last
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\CustomerFewoMail[] $customer_fewo_mails
|
||||
* @property-read int|null $customer_fewo_mails_count
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\CustomerFewoMail[] $customer_fewo_mails_sent_at
|
||||
* @property-read int|null $customer_fewo_mails_sent_at_count
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\TravelUserBookingFile[] $booking_files
|
||||
* @property-read int|null $booking_files_count
|
||||
* @property-read \App\Models\TravelUser $customer
|
||||
*/
|
||||
class TravelUserBookingFewo extends Model
|
||||
{
|
||||
|
|
@ -182,6 +190,11 @@ class TravelUserBookingFewo extends Model
|
|||
'status_text'
|
||||
];
|
||||
|
||||
public static $customer_mail_dirs = [
|
||||
11 => ['name' => 'Entwürfe', 'icon'=>'ion-md-create'],
|
||||
12 => ['name' => 'Papierkorb', 'icon'=>'ion-md-trash'],
|
||||
];
|
||||
|
||||
public function fewo_lodging()
|
||||
{
|
||||
return $this->belongsTo(\App\Models\FewoLodging::class);
|
||||
|
|
@ -202,6 +215,31 @@ class TravelUserBookingFewo extends Model
|
|||
return $this->belongsTo(\App\Models\TravelUser::class);
|
||||
}
|
||||
|
||||
public function customer()
|
||||
{
|
||||
return $this->belongsTo(\App\Models\TravelUser::class, 'travel_user_id');
|
||||
}
|
||||
|
||||
public function booking_files()
|
||||
{
|
||||
return $this->hasMany(TravelUserBookingFile::class, 'travel_user_booking_fewo_id');
|
||||
}
|
||||
|
||||
public function customer_fewo_mails()
|
||||
{
|
||||
return $this->hasMany(CustomerFewoMail::class, 'travel_user_booking_fewo_id', 'id');
|
||||
}
|
||||
|
||||
public function customer_fewo_mails_sent_at()
|
||||
{
|
||||
return $this->hasMany(CustomerFewoMail::class, 'travel_user_booking_fewo_id')->orderBy('sent_at', 'ASC');
|
||||
}
|
||||
|
||||
public function customer_fewo_mail_last()
|
||||
{
|
||||
return $this->hasOne(CustomerFewoMail::class, 'travel_user_booking_fewo_id')->latest();
|
||||
}
|
||||
|
||||
public function getStatuesName(){
|
||||
if(isset(self::$statues[$this->status])){
|
||||
return self::$statues[$this->status];
|
||||
|
|
@ -693,6 +731,16 @@ class TravelUserBookingFewo extends Model
|
|||
return false;
|
||||
}
|
||||
|
||||
public function countCustomerMailsBy($dir, $subdir=false){
|
||||
if($dir === 11){
|
||||
return $this->customer_fewo_mails->where('draft', true)->where('dir', '!=', 12)->count();
|
||||
}
|
||||
if($subdir){
|
||||
return $this->customer_fewo_mails->where('dir', $dir)->where('subdir', $subdir)->count();
|
||||
}
|
||||
return $this->customer_fewo_mails->where('dir', $dir)->count();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
106
app/Models/TravelUserBookingFile.php
Normal file
106
app/Models/TravelUserBookingFile.php
Normal file
|
|
@ -0,0 +1,106 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Created by Reliese Model.
|
||||
*/
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
/**
|
||||
* Class TravelUserBookingFile
|
||||
*
|
||||
* @property int $id
|
||||
* @property int $travel_user_booking_fewos
|
||||
* @property string $identifier
|
||||
* @property string $filename
|
||||
* @property string $dir
|
||||
* @property string $original_name
|
||||
* @property string $ext
|
||||
* @property string $mine
|
||||
* @property int $size
|
||||
* @property Carbon $created_at
|
||||
* @property Carbon $updated_at
|
||||
* @property TravelUserBookingFewo $travel_user_booking_fewo
|
||||
* @package App\Models
|
||||
* @property int|null $travel_user_booking_fewo_id
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelUserBookingFile newModelQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelUserBookingFile newQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelUserBookingFile query()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelUserBookingFile whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelUserBookingFile whereDir($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelUserBookingFile whereExt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelUserBookingFile whereFilename($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelUserBookingFile whereId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelUserBookingFile whereIdentifier($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelUserBookingFile whereMine($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelUserBookingFile whereOriginalName($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelUserBookingFile whereSize($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelUserBookingFile whereTravelUserBookingFewoId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelUserBookingFile whereUpdatedAt($value)
|
||||
* @mixin \Eloquent
|
||||
*/
|
||||
class TravelUserBookingFile extends Model
|
||||
{
|
||||
protected $connection = 'mysql_stern';
|
||||
|
||||
protected $table = 'travel_user_booking_files';
|
||||
|
||||
protected $casts = [
|
||||
'travel_user_booking_fewo_id' => 'int',
|
||||
'size' => 'int'
|
||||
];
|
||||
|
||||
protected $fillable = [
|
||||
'travel_user_booking_fewo_id',
|
||||
'identifier',
|
||||
'filename',
|
||||
'dir',
|
||||
'original_name',
|
||||
'ext',
|
||||
'mine',
|
||||
'size'
|
||||
];
|
||||
|
||||
public static $icon_ext = [
|
||||
'default' => 'fa fa-file',
|
||||
'pdf'=> 'fa fa-file-pdf',
|
||||
'jpg'=> 'fa fa-file-image',
|
||||
'png'=> 'fa fa-file-image',
|
||||
];
|
||||
|
||||
public function travel_user_booking_fewo()
|
||||
{
|
||||
return $this->belongsTo(TravelUserBookingFewo::class, 'travel_user_booking_fewo_id');
|
||||
}
|
||||
|
||||
public function getIconExt(){
|
||||
return isset(self::$icon_ext[$this->ext]) ? self::$icon_ext[$this->ext] : self::$icon_ext['default'];
|
||||
}
|
||||
|
||||
public function getURL($do=false){
|
||||
return route('storage_file', [$this->id, 'booking_fewo', $do]);
|
||||
}
|
||||
|
||||
public function getPath(){
|
||||
return \Storage::disk('booking_fewo')->path($this->dir.$this->filename);
|
||||
|
||||
}
|
||||
|
||||
public function formatBytes($precision = 2)
|
||||
{
|
||||
$size = $this->size;
|
||||
|
||||
if ($size > 0) {
|
||||
$size = (int) $size;
|
||||
$base = log($size) / log(1024);
|
||||
$suffixes = array(' bytes', ' KB', ' MB', ' GB', ' TB');
|
||||
|
||||
return round(pow(1024, $base - floor($base)), $precision) . $suffixes[floor($base)];
|
||||
} else {
|
||||
return $size;
|
||||
}
|
||||
}
|
||||
}
|
||||
53
app/Repositories/BookingFewoFileRepository.php
Normal file
53
app/Repositories/BookingFewoFileRepository.php
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
<?php
|
||||
|
||||
namespace App\Repositories;
|
||||
|
||||
use App\Models\BookingFile;
|
||||
use App\Models\TravelUserBookingFile;
|
||||
use Response;
|
||||
|
||||
class BookingFewoFileRepository extends FileRepository {
|
||||
|
||||
|
||||
|
||||
protected $booking_fewo_file;
|
||||
protected $travel_user_booking_fewo_id;
|
||||
protected $identifier;
|
||||
|
||||
|
||||
public function __construct(TravelUserBookingFile $model){
|
||||
parent::__construct();
|
||||
$this->model = $model;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function save(){
|
||||
$this->booking_fewo_file = TravelUserBookingFile::create([
|
||||
'travel_user_booking_fewo_id' => $this->travel_user_booking_fewo_id,
|
||||
'identifier' => $this->identifier,
|
||||
'filename' => $this->allowed_filename,
|
||||
'dir' => $this->dir,
|
||||
'original_name' => $this->originalName,
|
||||
'ext' => $this->extension,
|
||||
'mine' => $this->mine,
|
||||
'size' => $this->size
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
public function response(){
|
||||
return Response::json([
|
||||
'error' => false,
|
||||
'filename' => $this->allowed_filename,
|
||||
'file_id' =>$this->booking_fewo_file->id,
|
||||
'file_data' => $this->extension,
|
||||
'file_icon' => $this->booking_fewo_file->getIconExt(),
|
||||
'file_format_bytes' => $this->booking_fewo_file->formatBytes(),
|
||||
'file_url' => $this->booking_fewo_file->getURL(),
|
||||
'redirect' => '',
|
||||
'code' => 200
|
||||
], 200);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -4,6 +4,7 @@ namespace App\Repositories;
|
|||
|
||||
|
||||
use App\Models\Booking;
|
||||
use App\Models\BookingCountryService;
|
||||
|
||||
class BookingRepository extends BaseRepository {
|
||||
|
||||
|
|
@ -18,4 +19,55 @@ class BookingRepository extends BaseRepository {
|
|||
return $this->model;
|
||||
}
|
||||
|
||||
public function updateBooking($id, $data){
|
||||
|
||||
$this->model = Booking::findOrFail($id);
|
||||
|
||||
$fill = [
|
||||
'paying_out' => $data['paying_out'],
|
||||
'paying_out_status' => $data['paying_out_status'],
|
||||
'airline_id' => $data['airline_id'],
|
||||
'refund' => $data['refund'],
|
||||
'refund_date' => _reformat_date($data['refund_date']),
|
||||
'lawyer_date' => _reformat_date($data['lawyer_date']),
|
||||
'hold' => $data['hold'],
|
||||
'xx_tkt' => $data['xx_tkt'],
|
||||
'xx_tkt_date' => _reformat_date($data['xx_tkt_date']),
|
||||
'filekey' => $data['filekey'],
|
||||
'is_rail_fly' => isset($data['is_rail_fly']) ? true : false,
|
||||
'notice' => $data['notice'],
|
||||
];
|
||||
|
||||
$this->model->fill($fill);
|
||||
$this->model->save();
|
||||
|
||||
if(isset($data['country_service'])){
|
||||
$this->updateCountryService($data['country_service']);
|
||||
}
|
||||
|
||||
return $this->model;
|
||||
}
|
||||
|
||||
public function updateCountryService($country_services){
|
||||
|
||||
foreach ($country_services as $country_service_id=>$val){
|
||||
$booking_country_service = BookingCountryService::where('travel_country_service_id', '=', $country_service_id)
|
||||
->where('booking_id', '=', $this->model->id)->first();
|
||||
|
||||
if(!$booking_country_service){
|
||||
$booking_country_service = BookingCountryService::create([
|
||||
'travel_country_service_id' => $country_service_id,
|
||||
'booking_id' => $this->model->id,
|
||||
'status' => $val
|
||||
]);
|
||||
}else{
|
||||
$booking_country_service->fill([
|
||||
'status' => $val
|
||||
]);
|
||||
$booking_country_service->save();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -8,7 +8,7 @@ use Response;
|
|||
class CMSFileRepository extends FileRepository {
|
||||
|
||||
protected $identifier;
|
||||
|
||||
protected $data;
|
||||
|
||||
public function __construct($model){
|
||||
parent::__construct();
|
||||
|
|
@ -28,7 +28,8 @@ class CMSFileRepository extends FileRepository {
|
|||
$data = [
|
||||
"name" => $this->originalName,
|
||||
"field" => "file",
|
||||
"full_text" => \GuzzleHttp\json_encode($file_data),
|
||||
"identifier" => $this->data['identifier'],
|
||||
"object" => $file_data, //\GuzzleHttp\json_encode($file_data),
|
||||
];
|
||||
$this->model = CMSContent::create($data);
|
||||
//store in cms old Datebase
|
||||
|
|
|
|||
55
app/Repositories/CustomerFewoFileRepository.php
Normal file
55
app/Repositories/CustomerFewoFileRepository.php
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
<?php
|
||||
|
||||
namespace App\Repositories;
|
||||
|
||||
use App\Models\CustomerFewoFile;
|
||||
use Response;
|
||||
|
||||
class CustomerFewoFileRepository extends FileRepository {
|
||||
|
||||
|
||||
|
||||
protected $customer_file;
|
||||
protected $travel_user_id;
|
||||
protected $customer_fewo_mail_id;
|
||||
protected $identifier;
|
||||
|
||||
|
||||
public function __construct(CustomerFewoFile $model){
|
||||
parent::__construct();
|
||||
$this->model = $model;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function save(){
|
||||
$this->customer_file = CustomerFewoFile::create([
|
||||
'travel_user_id' => $this->travel_user_id,
|
||||
'customer_fewo_mail_id' => $this->customer_fewo_mail_id,
|
||||
'identifier' => $this->identifier,
|
||||
'filename' => $this->allowed_filename,
|
||||
'dir' => $this->dir,
|
||||
'original_name' => $this->originalName,
|
||||
'ext' => $this->extension,
|
||||
'mine' => $this->mine,
|
||||
'size' => $this->size
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
public function response(){
|
||||
return Response::json([
|
||||
'error' => false,
|
||||
'original_name' => $this->originalName,
|
||||
'filename' => $this->allowed_filename,
|
||||
'file_id' =>$this->customer_file->id,
|
||||
'file_data' => $this->extension,
|
||||
'file_icon' => $this->customer_file->getIconExt(),
|
||||
'file_format_bytes' => $this->customer_file->formatBytes(),
|
||||
'file_url' => $this->customer_file->getURL(),
|
||||
'redirect' => '',
|
||||
'code' => 200
|
||||
], 200);
|
||||
}
|
||||
|
||||
}
|
||||
340
app/Repositories/CustomerFewoMailRepository.php
Normal file
340
app/Repositories/CustomerFewoMailRepository.php
Normal file
|
|
@ -0,0 +1,340 @@
|
|||
<?php
|
||||
|
||||
namespace App\Repositories;
|
||||
|
||||
|
||||
use App\Mail\MailSendInfo;
|
||||
use App\Models\CMSContent;
|
||||
use App\Models\CustomerFewoFile;
|
||||
use App\Models\CustomerFewoMail;
|
||||
use App\Models\EmailTemplate;
|
||||
use App\Models\TravelUserBookingFewo;
|
||||
use App\Services\Placeholder;
|
||||
use App\Services\Util;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
|
||||
|
||||
class CustomerFewoMailRepository extends BaseRepository {
|
||||
|
||||
|
||||
public function __construct(CustomerFewoMail $model)
|
||||
{
|
||||
$this->model = $model;
|
||||
}
|
||||
|
||||
public function update($data)
|
||||
{
|
||||
return $this->model;
|
||||
}
|
||||
|
||||
public function sendAndStore($data){
|
||||
//send or draft
|
||||
//$data['action']
|
||||
if(isset($data['send_mail_to']) && is_array($data['send_mail_to'])) {
|
||||
//has Attachments
|
||||
$customer_files = [];
|
||||
if(isset($data['message_attachment_id']) && is_array($data['message_attachment_id'])){
|
||||
foreach ($data['message_attachment_id'] as $message_attachment_id){
|
||||
if($CustomerFile = CustomerFewoFile::find($message_attachment_id)){
|
||||
$customer_files[] = $CustomerFile;
|
||||
}
|
||||
}
|
||||
}
|
||||
foreach ($data['send_mail_to'] as $booking_fewo_id => $on) {
|
||||
$booking_fewo = TravelUserBookingFewo::find($booking_fewo_id);
|
||||
if ($booking_fewo->travel_user) {
|
||||
$data['draft'] = (isset($data['action']) && $data['action'] === 'draft' ? true : false);
|
||||
if(!$data['draft']){
|
||||
$data['message'] = $this->prepareContent($booking_fewo, $data['message']);
|
||||
$data['subject'] = $this->prepareContent($booking_fewo, $data['subject']);
|
||||
}
|
||||
$reply_id = isset($data['customer_mail_id']) ? $data['customer_mail_id'] : NULL;
|
||||
$email = isset($data['send_mail_to_mail'][$booking_fewo_id]) ? $data['send_mail_to_mail'][$booking_fewo_id] : $booking_fewo->travel_user->email;
|
||||
$customer_mail = $this->store($booking_fewo, $data, $email, false, $reply_id);
|
||||
foreach ($customer_files as $file) {
|
||||
$file->travel_user_id = $booking_fewo->travel_user_id;
|
||||
$file->customer_fewo_mail_id = $customer_mail->id;
|
||||
$file->identifier = 'mail';
|
||||
$file->save();
|
||||
}
|
||||
|
||||
if(isset($data['action']) && $data['action'] === 'send'){ //not at draft
|
||||
$this->sendMail($customer_mail);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function replyStore($data){
|
||||
if(isset($data['travel_user_booking_fewo_id']) && $booking_fewo = TravelUserBookingFewo::find($data['travel_user_booking_fewo_id'])) {
|
||||
//has Attachments
|
||||
$customer_files = [];
|
||||
if(isset($data['message_attachment_id']) && is_array($data['message_attachment_id'])){
|
||||
foreach ($data['message_attachment_id'] as $message_attachment_id){
|
||||
if($CustomerFile = CustomerFewoFile::find($message_attachment_id)){
|
||||
$customer_files[] = $CustomerFile;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($booking_fewo->travel_user) {
|
||||
$data['draft'] = (isset($data['action']) && $data['action'] === 'draft' ? true : false);
|
||||
$mail_from = isset($data['mail_from']) ? $data['mail_from'] : $booking_fewo->travel_user->email;
|
||||
$sent_at = isset($data['sent_at']) ? \Carbon::parse(str_replace("- ", "", $data['sent_at'])) : now();
|
||||
$reply_id = isset($data['customer_mail_id']) ? $data['customer_mail_id'] : NULL;
|
||||
$customer_mail = $this->store($booking_fewo, $data, $mail_from, true, $reply_id, $sent_at);
|
||||
foreach ($customer_files as $file) {
|
||||
$file->travel_user_id = $booking_fewo->travel_user_id;
|
||||
$file->customer_fewo_mail_id = $customer_mail->id;
|
||||
$file->identifier = 'mail';
|
||||
$file->save();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public function store($booking_fewo, $data, $mail_from, $is_answer = false, $reply_id = NULL, $sent_at=false){
|
||||
|
||||
if(isset($data['save_customer_mail_id'])){
|
||||
$customer_mail = CustomerFewoMail::find($data['save_customer_mail_id']);
|
||||
$customer_mail->fill([
|
||||
'travel_user_booking_fewo_id' => $booking_fewo->id,
|
||||
'travel_user_id' => $booking_fewo->travel_user_id,
|
||||
'is_answer' => $is_answer,
|
||||
'reply_id' => $reply_id,
|
||||
'email' => $mail_from,
|
||||
'recipient' => isset($data['recipient']) ? Util::_explodeLines($data['recipient']) : null,
|
||||
'cc' => isset($data['cc']) ? Util::_explodeLines($data['cc']) : null,
|
||||
'bcc' => isset($data['bcc']) ? Util::_explodeLines($data['bcc']) : null,
|
||||
'subject' => $data['subject'],
|
||||
'message' => $data['message'],
|
||||
'dir' => isset($data['dir']) ? $data['dir'] : 0,
|
||||
'subdir' => isset($data['subdir']) ? $data['subdir'] : 0,
|
||||
'draft' => $data['draft'],
|
||||
'sent_at' => $sent_at ? $sent_at : now(),
|
||||
])->save();
|
||||
}else{
|
||||
$customer_mail = CustomerFewoMail::create([
|
||||
'travel_user_booking_fewo_id' => $booking_fewo->id,
|
||||
'travel_user_id' => $booking_fewo->travel_user_id,
|
||||
'is_answer' => $is_answer,
|
||||
'reply_id' => $reply_id,
|
||||
'email' => $mail_from,
|
||||
'recipient' => isset($data['recipient']) ? Util::_explodeLines($data['recipient']) : null,
|
||||
'cc' => isset($data['cc']) ? Util::_explodeLines($data['cc']) : null,
|
||||
'bcc' => isset($data['bcc']) ? Util::_explodeLines($data['bcc']) : null,
|
||||
'subject' => $data['subject'],
|
||||
'message' => $data['message'],
|
||||
'dir' => isset($data['dir']) ? $data['dir'] : 0,
|
||||
'subdir' => isset($data['subdir']) ? $data['subdir'] : 0,
|
||||
'draft' => $data['draft'],
|
||||
'sent_at' => $sent_at ? $sent_at : now(),
|
||||
]);
|
||||
}
|
||||
|
||||
return $customer_mail;
|
||||
}
|
||||
|
||||
private function sendMail($customer_mail){
|
||||
$to_mails = [];
|
||||
if(strpos($customer_mail->email, ',')){
|
||||
$to_mails = array_map('trim', explode(',', $customer_mail->email));
|
||||
}else{
|
||||
$to_mails[] = $customer_mail->email;
|
||||
}
|
||||
if($customer_mail->recipient){
|
||||
$to_mails = array_merge($to_mails, $customer_mail->recipient);
|
||||
}
|
||||
$customer_files = $customer_mail->customer_files;
|
||||
try {
|
||||
//
|
||||
Mail::to($to_mails)
|
||||
->cc($customer_mail->cc ?: [])
|
||||
->bcc($customer_mail->bcc ?: [])
|
||||
->send(new MailSendInfo($customer_mail->subject, $customer_mail->message, $customer_files));
|
||||
}
|
||||
catch(\Exception $e){
|
||||
// Never reached
|
||||
$customer_mail->fail = true;
|
||||
$customer_mail->error = $e->getMessage();
|
||||
$customer_mail->save();
|
||||
return false;
|
||||
}
|
||||
$customer_mail->send = true;
|
||||
$customer_mail->sent_at = now();
|
||||
$customer_mail->save();
|
||||
return true;
|
||||
}
|
||||
|
||||
private function prepareContent($booking_fewo, $content){
|
||||
$content = Placeholder::replaceBookingFewo($booking_fewo, $content);
|
||||
return $content;
|
||||
}
|
||||
|
||||
private static function prepareContactMails($value){
|
||||
if(isset($value->customers)){ //&& $value->customer_mail_dir !== NULL
|
||||
$first_mail = "";
|
||||
if($value->customer_mail_dir < 10){ // && $value->customer_mail_subdir > 0
|
||||
$customer_mail_dir = \App\Services\BookingFewo::getCustomerMailDir($value->customer_mail_dir);
|
||||
$contact_emails = \App\Services\BookingFewo::getCustomerMailEmails($customer_mail_dir, $value->customer_mail_subdir);
|
||||
if($value->customer_mail_dir == 0){
|
||||
$value->recipient = Util::_implodeLines($contact_emails);
|
||||
return $value;
|
||||
}else{
|
||||
if($contact_emails && count($contact_emails) > 0) {
|
||||
$first_mail = array_shift($contact_emails);
|
||||
if (count($contact_emails) > 0) {
|
||||
$value->recipient = Util::_implodeLines($contact_emails);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
foreach ($value->customers as $key=>$val){
|
||||
$val['email'] = $first_mail;
|
||||
$value->customers[$key] = $val;
|
||||
}
|
||||
|
||||
}
|
||||
return $value;
|
||||
}
|
||||
|
||||
public static function loadModal($data)
|
||||
{
|
||||
$value = new Collection();
|
||||
$value->title = "";
|
||||
$value->subtitle = "";
|
||||
$value->url = "";
|
||||
$value->recipient = "";
|
||||
$value->cc = "";
|
||||
$value->bcc = "";
|
||||
$value->lead_title_id = "";
|
||||
$value->filter_email_templates_directories = EmailTemplate::join('email_template_dirs', 'email_template_dir_id', '=', 'email_template_dirs.id')->get()->pluck('name', 'id')->unique()->toArray();
|
||||
|
||||
/*Ansicht*/
|
||||
if ($data['action'] === "show-customer-mail") {
|
||||
if (isset($data['customer_mail_id']) && $customer_mail = CustomerFewoMail::find($data['customer_mail_id'])) {
|
||||
$value->url = $data['url'];
|
||||
$value->title = "E-Mail Ansicht";
|
||||
return view("travel.user.booking.mail.modal-show-mail", compact('data', 'value', 'customer_mail'))->render();
|
||||
}
|
||||
}
|
||||
/* neue Mail */
|
||||
if ($data['action'] === "edit-customer-mail") {
|
||||
$value->id = $data['id']; //
|
||||
$customer_mail = CustomerFewoMail::find($value->id);
|
||||
$booking = $customer_mail->travel_user_booking_fewo;
|
||||
$value->customer_files = $customer_mail->customer_files;
|
||||
$value->save_customer_mail_id = $customer_mail->id;
|
||||
$value->draft = true;
|
||||
$value->id = $customer_mail->travel_user_booking_fewo_id;
|
||||
$value->booking = $booking;
|
||||
$value->show = 'single';
|
||||
$value->lead_title_id = " - (".$value->booking->invoice_number.")";
|
||||
|
||||
|
||||
$tmp = [];
|
||||
$tmp['email'] = $booking->travel_user ? $booking->travel_user->email : "";
|
||||
$tmp['name'] = $booking->travel_user ? $booking->travel_user->first_name . " " . $booking->travel_user->last_name . " | " : "- | ";
|
||||
$tmp['name'] .= $booking->fewo_lodging_id ? $booking->fewo_lodging->name . " | " : "- | ";
|
||||
$data['customers'][$booking->id] = $tmp;
|
||||
$value->customers = $data['customers'];
|
||||
$value->subject = $customer_mail->subject;
|
||||
$value->message = $customer_mail->message;
|
||||
$value->recipient = Util::_implodeLines($customer_mail->recipient);
|
||||
$value->cc = Util::_implodeLines($customer_mail->cc);
|
||||
$value->bcc = Util::_implodeLines($customer_mail->bcc);
|
||||
|
||||
$value->title = "E-Mail- Nachricht an Kunden senden";
|
||||
$value->subtitle = "Dem Kunden wird eine E-Mail zugesendet.";
|
||||
if($customer_mail->reply_id){
|
||||
$value->title = "E-Mail Antwort an Kunden senden";
|
||||
$value->subtitle = "Dem Kunden wird eine E-Mail zugesendet, die im System als Antwort gespeichert wird.";
|
||||
$value->customer_mail = $customer_mail;
|
||||
}
|
||||
$value->s_placeholder = "Betreff der E-Mail";
|
||||
$value->m_placeholder = "Nachricht der E-Mail";
|
||||
$value->url = $data['url'];
|
||||
$value->customer_mail_dir = $customer_mail->dir ? $customer_mail->dir : 0;
|
||||
$value->customer_mail_subdir = $customer_mail->subdir ? $customer_mail->subdir : 0;
|
||||
|
||||
return view("travel.user.booking.mail.modal-new-mail", compact('data', 'value'))->render();
|
||||
|
||||
}
|
||||
/* neue Mail */
|
||||
if ($data['action'] === "new-customer-mail") {
|
||||
$value->id = "";
|
||||
$value->draft = false;
|
||||
$value->lead_title_id = "-";
|
||||
//singel
|
||||
if (isset($data['travel_user_booking_fewo_id']) && $booking_fewo = TravelUserBookingFewo::find($data['travel_user_booking_fewo_id'])) {
|
||||
$value->id = $data['travel_user_booking_fewo_id'];
|
||||
$value->booking = $booking_fewo;
|
||||
$value->show = 'single';
|
||||
$value->draft = true;
|
||||
$value->lead_title_id = " - (".$value->booking->invoice_number.")";
|
||||
|
||||
}else{
|
||||
//multi
|
||||
$value->show = 'multi';
|
||||
}
|
||||
$value->customers = $data['customers'];
|
||||
$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";
|
||||
if(isset($data['customer_mail_id']) && $customer_mail = CustomerFewoMail::find($data['customer_mail_id'])){
|
||||
$value->subject = "Re: ".Util::_first_replace($customer_mail->subject);
|
||||
$value->customer_mail = $customer_mail;
|
||||
}
|
||||
|
||||
$value->title = "E-Mail- Nachricht an Kunden senden";
|
||||
$value->subtitle = "Dem Kunden wird eine E-Mail zugesendet.";
|
||||
if($data['id'] === 'reply-send'){
|
||||
$value->title = "E-Mail Antwort an Kunden senden";
|
||||
$value->subtitle = "Dem Kunden wird eine E-Mail zugesendet, die im System als Antwort gespeichert wird.";
|
||||
}
|
||||
$value->url = $data['url'];
|
||||
$value->customer_mail_dir = isset($data['customer_mail_dir']) ? $data['customer_mail_dir'] : 0;
|
||||
$value->customer_mail_subdir = isset($data['customer_mail_subdir']) ? $data['customer_mail_subdir'] : 0;
|
||||
|
||||
$value = self::prepareContactMails($value);
|
||||
return view("travel.user.booking.mail.modal-new-mail", compact('data', 'value'))->render();
|
||||
|
||||
}
|
||||
/*Antwort speichern*/
|
||||
if ($data['action'] === "reply-customer-mail") {
|
||||
if (isset($data['travel_user_booking_fewo_id']) && $booking_fewo = TravelUserBookingFewo::find($data['travel_user_booking_fewo_id'])) {
|
||||
$value->id = $data['travel_user_booking_fewo_id'];
|
||||
$value->draft = false;
|
||||
$value->booking = $booking_fewo;
|
||||
$value->message = "";
|
||||
$value->subject = "";
|
||||
$value->lead_title_id = " - (".$value->booking->invoice_number.")";
|
||||
$value->s_placeholder = "Betreff des Kunden";
|
||||
$value->m_placeholder = "Nachricht des Kunden";
|
||||
if(isset($data['customer_mail_id']) && $customer_mail = CustomerFewoMail::find($data['customer_mail_id'])){
|
||||
$value->subject = "Re: ".Util::_first_replace($customer_mail->subject);
|
||||
$value->customer_mail = $customer_mail;
|
||||
}
|
||||
$value->title = "E-Mail Antwort speichern";
|
||||
$value->subtitle = "Die E-Mail wird im System gespeichert.";
|
||||
if($data['id'] === 'reply-save'){
|
||||
$value->subtitle = "Die E-Mail wird im System als Antwort gespeichert.";
|
||||
|
||||
}
|
||||
$value->url = $data['url'];
|
||||
$value->show = 'reply';
|
||||
$value->customer_mail_dir = isset($data['customer_mail_dir']) ? $data['customer_mail_dir'] : 0;
|
||||
$value->customer_mail_subdir = isset($data['customer_mail_subdir']) ? $data['customer_mail_subdir'] : 0;
|
||||
|
||||
$value = self::prepareContactMails($value);
|
||||
return view("travel.user.booking.mail.modal-new-mail", compact('data', 'value'))->render();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -9,6 +9,7 @@ use App\Models\Booking;
|
|||
use App\Models\CMSContent;
|
||||
use App\Models\CustomerFile;
|
||||
use App\Models\CustomerMail;
|
||||
use App\Models\EmailTemplate;
|
||||
use App\Services\Placeholder;
|
||||
use App\Services\Util;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
|
|
@ -98,7 +99,6 @@ class CustomerMailRepository extends BaseRepository {
|
|||
|
||||
public function store($booking, $data, $mail_from, $is_answer = false, $reply_id = NULL, $sent_at=false){
|
||||
|
||||
$data['travel_country_id'] = isset($data['travel_country_id']) && $data['travel_country_id']>0 ? $data['travel_country_id'] : NULL;
|
||||
if(isset($data['save_customer_mail_id'])){
|
||||
$customer_mail = CustomerMail::find($data['save_customer_mail_id']);
|
||||
$customer_mail->fill([
|
||||
|
|
@ -114,7 +114,7 @@ class CustomerMailRepository extends BaseRepository {
|
|||
'subject' => $data['subject'],
|
||||
'message' => $data['message'],
|
||||
'dir' => isset($data['dir']) ? $data['dir'] : 0,
|
||||
'travel_country_id' => $data['travel_country_id'],
|
||||
'subdir' => isset($data['subdir']) ? $data['subdir'] : 0,
|
||||
'draft' => $data['draft'],
|
||||
'sent_at' => $sent_at ? $sent_at : now(),
|
||||
])->save();
|
||||
|
|
@ -132,7 +132,7 @@ class CustomerMailRepository extends BaseRepository {
|
|||
'subject' => $data['subject'],
|
||||
'message' => $data['message'],
|
||||
'dir' => isset($data['dir']) ? $data['dir'] : 0,
|
||||
'travel_country_id' => $data['travel_country_id'],
|
||||
'subdir' => isset($data['subdir']) ? $data['subdir'] : 0,
|
||||
'draft' => $data['draft'],
|
||||
'sent_at' => $sent_at ? $sent_at : now(),
|
||||
]);
|
||||
|
|
@ -178,36 +178,29 @@ class CustomerMailRepository extends BaseRepository {
|
|||
}
|
||||
|
||||
private static function prepareContactMails($value){
|
||||
|
||||
if(isset($value->customers) && $value->customer_mail_dir > 0){
|
||||
if(isset($value->customers)){ //&& $value->customer_mail_dir !== NULL
|
||||
$first_mail = "";
|
||||
if($value->customer_mail_dir == 1 && $value->customer_mail_country > 0){
|
||||
//Agentur / Land
|
||||
$travel_country = \App\Models\Sym\TravelCountry::find($value->customer_mail_country);
|
||||
if($travel_country && $travel_country->contact_emails && count($travel_country->contact_emails) > 0){
|
||||
$contact_emails = $travel_country->contact_emails;
|
||||
$first_mail = array_shift($contact_emails);
|
||||
if(count($contact_emails) > 0){
|
||||
if($value->customer_mail_dir < 10){ // && $value->customer_mail_subdir > 0
|
||||
$customer_mail_dir = \App\Services\Booking::getCustomerMailDir($value->customer_mail_dir);
|
||||
$contact_emails = \App\Services\Booking::getCustomerMailEmails($customer_mail_dir, $value->customer_mail_subdir);
|
||||
if($value->customer_mail_dir == 0){
|
||||
$value->recipient = Util::_implodeLines($contact_emails);
|
||||
return $value;
|
||||
}else{
|
||||
if($contact_emails && count($contact_emails) > 0) {
|
||||
$first_mail = array_shift($contact_emails);
|
||||
if (count($contact_emails) > 0) {
|
||||
$value->recipient = Util::_implodeLines($contact_emails);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if($value->customer_mail_dir == 2){
|
||||
//Airline
|
||||
$airline = Airline::whereName('Xemail')->first();
|
||||
if($airline && $airline->contact_emails && count($airline->contact_emails) > 0){
|
||||
$contact_emails = $airline->contact_emails;
|
||||
$first_mail = array_shift($contact_emails);
|
||||
if(count($contact_emails) > 0){
|
||||
$value->recipient = Util::_implodeLines($contact_emails);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
foreach ($value->customers as $key=>$val){
|
||||
$val['email'] = $first_mail;
|
||||
$value->customers[$key] = $val;
|
||||
}
|
||||
|
||||
}
|
||||
return $value;
|
||||
}
|
||||
|
|
@ -222,6 +215,8 @@ class CustomerMailRepository extends BaseRepository {
|
|||
$value->cc = "";
|
||||
$value->bcc = "";
|
||||
$value->lead_title_id = "";
|
||||
$value->filter_email_templates_directories = EmailTemplate::join('email_template_dirs', 'email_template_dir_id', '=', 'email_template_dirs.id')->get()->pluck('name', 'id')->unique()->toArray();
|
||||
|
||||
/*Ansicht*/
|
||||
if ($data['action'] === "show-customer-mail") {
|
||||
if (isset($data['customer_mail_id']) && $customer_mail = CustomerMail::find($data['customer_mail_id'])) {
|
||||
|
|
@ -262,12 +257,14 @@ class CustomerMailRepository extends BaseRepository {
|
|||
if($customer_mail->reply_id){
|
||||
$value->title = "E-Mail Antwort an Kunden senden";
|
||||
$value->subtitle = "Dem Kunden wird eine E-Mail zugesendet, die im System als Antwort gespeichert wird.";
|
||||
$value->customer_mail = $customer_mail;
|
||||
|
||||
}
|
||||
$value->s_placeholder = "Betreff der E-Mail";
|
||||
$value->m_placeholder = "Nachricht der E-Mail";
|
||||
$value->url = $data['url'];
|
||||
$value->customer_mail_dir = $customer_mail->dir ? $customer_mail->dir : 0;
|
||||
$value->customer_mail_country = $customer_mail->travel_country_id ? $customer_mail->travel_country_id : 0;
|
||||
$value->customer_mail_subdir = $customer_mail->subdir ? $customer_mail->subdir : 0;
|
||||
|
||||
return view("customer.mail.modal-new-mail", compact('data', 'value'))->render();
|
||||
|
||||
|
|
@ -307,7 +304,7 @@ class CustomerMailRepository extends BaseRepository {
|
|||
}
|
||||
$value->url = $data['url'];
|
||||
$value->customer_mail_dir = isset($data['customer_mail_dir']) ? $data['customer_mail_dir'] : 0;
|
||||
$value->customer_mail_country = isset($data['customer_mail_country']) ? $data['customer_mail_country'] : 0;
|
||||
$value->customer_mail_subdir = isset($data['customer_mail_subdir']) ? $data['customer_mail_subdir'] : 0;
|
||||
|
||||
$value = self::prepareContactMails($value);
|
||||
return view("customer.mail.modal-new-mail", compact('data', 'value'))->render();
|
||||
|
|
@ -337,7 +334,7 @@ class CustomerMailRepository extends BaseRepository {
|
|||
$value->url = $data['url'];
|
||||
$value->show = 'reply';
|
||||
$value->customer_mail_dir = isset($data['customer_mail_dir']) ? $data['customer_mail_dir'] : 0;
|
||||
$value->customer_mail_country = isset($data['customer_mail_country']) ? $data['customer_mail_country'] : 0;
|
||||
$value->customer_mail_subdir = isset($data['customer_mail_subdir']) ? $data['customer_mail_subdir'] : 0;
|
||||
|
||||
$value = self::prepareContactMails($value);
|
||||
return view("customer.mail.modal-new-mail", compact('data', 'value'))->render();
|
||||
|
|
|
|||
|
|
@ -23,6 +23,8 @@ class FileRepository extends BaseRepository {
|
|||
protected $mine;
|
||||
protected $size;
|
||||
|
||||
protected $redirect;
|
||||
|
||||
|
||||
public function __construct(){
|
||||
|
||||
|
|
@ -95,7 +97,7 @@ class FileRepository extends BaseRepository {
|
|||
'file_data' => $this->extension,
|
||||
'mine' => $this->mine,
|
||||
'size' => $this->size,
|
||||
'redirect' => '',
|
||||
'redirect' => $this->redirect,
|
||||
'code' => 200
|
||||
], 200);
|
||||
}
|
||||
|
|
|
|||
51
app/Repositories/GeneralFileRepository.php
Normal file
51
app/Repositories/GeneralFileRepository.php
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
<?php
|
||||
|
||||
namespace App\Repositories;
|
||||
|
||||
use App\Models\GeneralFile;
|
||||
use Response;
|
||||
|
||||
class GeneralFileRepository extends FileRepository {
|
||||
|
||||
|
||||
|
||||
protected $general_file;
|
||||
protected $travel_country_id;
|
||||
protected $identifier;
|
||||
|
||||
|
||||
public function __construct(GeneralFile $model){
|
||||
parent::__construct();
|
||||
$this->model = $model;
|
||||
}
|
||||
|
||||
|
||||
public function save(){
|
||||
$this->general_file = GeneralFile::create([
|
||||
'travel_country_id' => $this->travel_country_id,
|
||||
'identifier' => $this->identifier,
|
||||
'filename' => $this->allowed_filename,
|
||||
'dir' => $this->dir,
|
||||
'original_name' => $this->originalName,
|
||||
'ext' => $this->extension,
|
||||
'mine' => $this->mine,
|
||||
'size' => $this->size
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
public function response(){
|
||||
return Response::json([
|
||||
'error' => false,
|
||||
'filename' => $this->allowed_filename,
|
||||
'file_id' =>$this->general_file->id,
|
||||
'file_data' => $this->extension,
|
||||
'file_icon' => $this->general_file->getIconExt(),
|
||||
'file_format_bytes' => $this->general_file->formatBytes(),
|
||||
'file_url' => $this->general_file->getURL(),
|
||||
'redirect' => $this->redirect,
|
||||
'code' => 200
|
||||
], 200);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -57,11 +57,9 @@ class TravelUserBookingFewoRepository extends BaseRepository {
|
|||
];
|
||||
$pdf = PDF::loadView('pdf.invoice_fewo', $data);
|
||||
$pdf->setPaper('A4', 'portrait');
|
||||
|
||||
$path =$model->getInvoicePath();
|
||||
$filename = $model->getInvoiceFileName();
|
||||
$pdf->save($path.$filename);
|
||||
|
||||
return $path.$filename;
|
||||
//return $pdf->stream('invoice.pdf');
|
||||
}
|
||||
|
|
|
|||
80
app/Services/Booking.php
Normal file
80
app/Services/Booking.php
Normal file
|
|
@ -0,0 +1,80 @@
|
|||
<?php
|
||||
namespace App\Services;
|
||||
|
||||
use App\Models\Airline;
|
||||
use App\Models\CMSContent;
|
||||
use App\Models\Insurance;
|
||||
use App\Models\TravelCompany;
|
||||
|
||||
class Booking
|
||||
{
|
||||
public static function contentFiles(){
|
||||
$booking_email_files = CMSContent::where('identifier', '=', 'booking-email-file')->get()->sortByDesc('pos')->pluck('slug', 'id');
|
||||
return $booking_email_files;
|
||||
}
|
||||
|
||||
|
||||
public static function getCustomerMailDirs(){
|
||||
$customer_mail_dirs = CMSContent::where('identifier', '=', 'customer-mail-dirs')->get()->sortBy('pos');
|
||||
return $customer_mail_dirs;
|
||||
}
|
||||
|
||||
|
||||
public static function getCustomerMailDir($id){
|
||||
return CMSContent::where('identifier', '=', 'customer-mail-dirs')->where('pos', '=', $id)->first();
|
||||
}
|
||||
|
||||
public static function getCustomerMailName($customer_mail_dir, $mail_dir_id){
|
||||
|
||||
switch ($customer_mail_dir->getArrayContent('model')){
|
||||
case 'TravelCountry':
|
||||
$model = \App\Models\Sym\TravelCountry::find($mail_dir_id);
|
||||
break;
|
||||
case 'Airline':
|
||||
$model = Airline::find($mail_dir_id);
|
||||
break;
|
||||
case 'Insurance':
|
||||
$model = Insurance::find($mail_dir_id);
|
||||
break;
|
||||
case 'TravelCompany':
|
||||
$model = TravelCompany::find($mail_dir_id);
|
||||
break;
|
||||
default:
|
||||
return '';
|
||||
}
|
||||
|
||||
if($model){
|
||||
if($customer_mail_dir->getArrayContent('model') === 'TravelCountry'){
|
||||
return $model->mail_dir_name;
|
||||
}
|
||||
return $model->name;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
public static function getCustomerMailEmails($customer_mail_dir, $mail_dir_id){
|
||||
|
||||
switch ($customer_mail_dir->getArrayContent('model')){
|
||||
case 'TravelCountry':
|
||||
$model = \App\Models\Sym\TravelCountry::find($mail_dir_id);
|
||||
break;
|
||||
case 'Airline':
|
||||
$model = Airline::find($mail_dir_id);
|
||||
break;
|
||||
case 'Insurance':
|
||||
$model = Insurance::find($mail_dir_id);
|
||||
break;
|
||||
case 'TravelCompany':
|
||||
$model = TravelCompany::find($mail_dir_id);
|
||||
break;
|
||||
default:
|
||||
//direkt from CMSContent
|
||||
return $customer_mail_dir->getArrayContent('emails');
|
||||
}
|
||||
|
||||
if($model){
|
||||
return $model->contact_emails;
|
||||
}
|
||||
return [];
|
||||
}
|
||||
}
|
||||
79
app/Services/BookingFewo.php
Normal file
79
app/Services/BookingFewo.php
Normal file
|
|
@ -0,0 +1,79 @@
|
|||
<?php
|
||||
namespace App\Services;
|
||||
|
||||
use App\Models\Airline;
|
||||
use App\Models\CMSContent;
|
||||
use App\Models\Insurance;
|
||||
use App\Models\TravelCompany;
|
||||
|
||||
class BookingFewo
|
||||
{
|
||||
public static function contentFiles(){
|
||||
$booking_email_files = CMSContent::where('identifier', '=', 'fewo-email-file')->get()->sortByDesc('pos')->pluck('slug', 'id');
|
||||
return $booking_email_files;
|
||||
}
|
||||
|
||||
public static function getCustomerMailDirs(){
|
||||
$customer_mail_dirs = CMSContent::where('identifier', '=', 'customer-fewo-mail-dirs')->get()->sortBy('pos');
|
||||
return $customer_mail_dirs;
|
||||
}
|
||||
|
||||
|
||||
public static function getCustomerMailDir($id){
|
||||
return CMSContent::where('identifier', '=', 'customer-fewo-mail-dirs')->where('pos', '=', $id)->first();
|
||||
}
|
||||
|
||||
public static function getCustomerMailName($customer_mail_dir, $mail_dir_id){
|
||||
|
||||
switch ($customer_mail_dir->getArrayContent('model')){
|
||||
case 'TravelCountry':
|
||||
$model = \App\Models\Sym\TravelCountry::find($mail_dir_id);
|
||||
break;
|
||||
case 'Airline':
|
||||
$model = Airline::find($mail_dir_id);
|
||||
break;
|
||||
case 'Insurance':
|
||||
$model = Insurance::find($mail_dir_id);
|
||||
break;
|
||||
case 'TravelCompany':
|
||||
$model = TravelCompany::find($mail_dir_id);
|
||||
break;
|
||||
default:
|
||||
return '';
|
||||
}
|
||||
|
||||
if($model){
|
||||
if($customer_mail_dir->getArrayContent('model') === 'TravelCountry'){
|
||||
return $model->mail_dir_name;
|
||||
}
|
||||
return $model->name;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
public static function getCustomerMailEmails($customer_mail_dir, $mail_dir_id){
|
||||
|
||||
switch ($customer_mail_dir->getArrayContent('model')){
|
||||
case 'TravelCountry':
|
||||
$model = \App\Models\Sym\TravelCountry::find($mail_dir_id);
|
||||
break;
|
||||
case 'Airline':
|
||||
$model = Airline::find($mail_dir_id);
|
||||
break;
|
||||
case 'Insurance':
|
||||
$model = Insurance::find($mail_dir_id);
|
||||
break;
|
||||
case 'TravelCompany':
|
||||
$model = TravelCompany::find($mail_dir_id);
|
||||
break;
|
||||
default:
|
||||
//direkt from CMSContent
|
||||
return $customer_mail_dir->getArrayContent('emails');
|
||||
}
|
||||
|
||||
if($model){
|
||||
return $model->contact_emails;
|
||||
}
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
|
@ -1,15 +1,17 @@
|
|||
<?php
|
||||
namespace App\Services;
|
||||
|
||||
use App\Models\Airline;
|
||||
use App\Models\CMSAuthor;
|
||||
use App\Models\CMSContent;
|
||||
use App\Models\Country;
|
||||
use App\Models\Draft;
|
||||
use App\Models\DraftType;
|
||||
use App\Models\FewoLodging;
|
||||
use App\Models\IndustrySector;
|
||||
use App\Models\Interest;
|
||||
use App\Models\Insurance;
|
||||
use App\Models\TravelBookingFewoChannel;
|
||||
use App\Models\TravelClass;
|
||||
use App\Models\TravelCompany;
|
||||
use App\Models\TravelCountry;
|
||||
use App\Models\TravelGuide;
|
||||
use App\Models\TravelNationality;
|
||||
|
|
@ -250,9 +252,14 @@ class HTMLHelper
|
|||
return $ret;
|
||||
}
|
||||
|
||||
public static function getTravelUserOptions($id = false, $order = "ASC"){
|
||||
public static function getTravelUserOptions($id = false, $order = "ASC", $empty=false){
|
||||
$options = TravelUser::orderBy('id', $order)->get();
|
||||
|
||||
$ret = '';
|
||||
if($empty){
|
||||
$ret = '<option value="">Bitte wählen</option>\n';
|
||||
}
|
||||
|
||||
foreach ($options as $option){
|
||||
$attr = ($option->id === $id) ? 'selected="selected"' : '';
|
||||
$ret .= '<option value="'.$option->id.'" '.$attr.'>'.$option->first_name.' '.$option->last_name.' | '.$option->email.' ('.$option->id.')</option>\n';
|
||||
|
|
@ -260,6 +267,33 @@ class HTMLHelper
|
|||
return $ret;
|
||||
}
|
||||
|
||||
public static function getCustomerMailDirsOptions(CMSContent $customer_mail_dir, $checked = []){
|
||||
//$checked = [];
|
||||
$model = $customer_mail_dir->getArrayContent('model');
|
||||
switch ($model){
|
||||
case 'TravelCountry':
|
||||
$options = \App\Models\Sym\TravelCountry::where('active_backend',1)->get();
|
||||
break;
|
||||
case 'Airline':
|
||||
$options = Airline::where('name_full', 'like', '%Xemail%')->get();
|
||||
break;
|
||||
case 'Insurance':
|
||||
$options = Insurance::where('active',1)->get();
|
||||
break;
|
||||
case 'TravelCompany':
|
||||
$options = TravelCompany::where('active',1)->get();
|
||||
break;
|
||||
default:
|
||||
return '';
|
||||
}
|
||||
$ret = '';
|
||||
foreach ($options as $option){
|
||||
$attr = (in_array($option->id, $checked)) ? 'selected="selected"' : '';
|
||||
$ret .= '<option value="'.$option->id.'" '.$attr.'>'.$option->name.'</option>\n';
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
public static function getFewoLodgingOptions($id = false){
|
||||
$options = FewoLodging::all();
|
||||
$ret = '';
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
namespace App\Services;
|
||||
|
||||
use App\Models\Booking;
|
||||
use App\Models\TravelUserBookingFewo;
|
||||
|
||||
class Placeholder
|
||||
{
|
||||
|
|
@ -63,6 +64,32 @@ class Placeholder
|
|||
return $content;
|
||||
}
|
||||
|
||||
public static function replaceBookingFewo(TravelUserBookingFewo $booking_fewo, $content)
|
||||
{
|
||||
$dear = $booking_fewo->travel_user->salutation_id == 1 ? 'geehrter' : 'geehrte';
|
||||
$first_name = $booking_fewo->travel_user->first_name;
|
||||
$last_name = $booking_fewo->travel_user->last_name;
|
||||
$title = $booking_fewo->travel_user->title;
|
||||
$country = "";
|
||||
$program = $booking_fewo->fewo_lodging_id ? $booking_fewo->fewo_lodging->name : "-";
|
||||
$salutation = $booking_fewo->travel_user->salutation_id == 1 ? 'Herr' : 'Frau';
|
||||
$start_date = $booking_fewo->from_date;
|
||||
$end_date = $booking_fewo->to_date;
|
||||
$booking_date = $booking_fewo->booking_date;
|
||||
$airline = "";
|
||||
$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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -33,6 +33,13 @@ class Util
|
|||
return \Carbon::parse($date)->format(\Util::formatDateDB());
|
||||
}
|
||||
|
||||
public static function _reformat_date($date, $to = 'date'){
|
||||
if($to === 'datetime'){
|
||||
return \Carbon::parse($date)->format('Y-m-d - H:i');
|
||||
}
|
||||
return \Carbon::parse($date)->format('Y-m-d');
|
||||
}
|
||||
|
||||
public static function _format_number($value){
|
||||
return preg_replace("/[^0-9,]/", "", $value);
|
||||
|
||||
|
|
@ -62,7 +69,7 @@ class Util
|
|||
if(is_array($value)){
|
||||
return implode($glue, $value);
|
||||
}
|
||||
return "";
|
||||
return $value;
|
||||
}
|
||||
public static function _clean_float($value){
|
||||
|
||||
|
|
@ -191,5 +198,21 @@ class Util
|
|||
return isset($mime_types[$mine]) ? $mime_types[$mine] : "";
|
||||
}
|
||||
|
||||
public static function getURLasContent($url, $base=false){
|
||||
$arrContextOptions=array(
|
||||
"ssl"=>array(
|
||||
"verify_peer"=>false,
|
||||
"verify_peer_name"=>false,
|
||||
),
|
||||
);
|
||||
$content = file_get_contents($url, false, stream_context_create($arrContextOptions));
|
||||
if($base){
|
||||
$type = pathinfo($url, PATHINFO_EXTENSION);
|
||||
$base64Data = base64_encode($content);
|
||||
return 'data:image/' . $type . ';base64,' . $base64Data;
|
||||
}
|
||||
return $content;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -20,10 +20,16 @@ if (! function_exists('make_v2_url')) {
|
|||
if (! function_exists('_format_date')) {
|
||||
function _format_date($date, $to = 'date')
|
||||
{
|
||||
return \App\Services\Util::_format_date($date, $to);
|
||||
return $date ? \App\Services\Util::_format_date($date, $to) : null;
|
||||
}
|
||||
}
|
||||
|
||||
if (! function_exists('_reformat_date')) {
|
||||
function _reformat_date($date, $to = 'date')
|
||||
{
|
||||
return $date ? \App\Services\Util::_reformat_date($date, $to) : null;
|
||||
}
|
||||
}
|
||||
|
||||
if (! function_exists('array_to_json')) {
|
||||
function array_to_json($value)
|
||||
|
|
@ -32,7 +38,6 @@ if (! function_exists('array_to_json')) {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
if (! function_exists('last_array_element')) {
|
||||
function last_array_element($value)
|
||||
{
|
||||
|
|
@ -86,4 +91,14 @@ if (! function_exists('get_file_last_time')) {
|
|||
}
|
||||
return date("Ymd-i", time());
|
||||
}
|
||||
}
|
||||
|
||||
if (! function_exists('my_count')) {
|
||||
function my_count($value)
|
||||
{
|
||||
if ($value && is_array($value)) {
|
||||
return count($value);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue