Fewo Mail MA, optimation Fewo, view User Fewos
This commit is contained in:
parent
e537e47a82
commit
346a7427a5
30 changed files with 915 additions and 963 deletions
|
|
@ -3,10 +3,11 @@
|
|||
namespace App\Http\Controllers\API;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\BookingDraftItem;
|
||||
use App\Mail\MailSendFeWoService;
|
||||
use App\Models\TravelUser;
|
||||
use App\Models\TravelUserBookingFewo;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use Input;
|
||||
use Validator;
|
||||
|
||||
class FewoController extends Controller
|
||||
|
|
@ -92,9 +93,22 @@ class FewoController extends Controller
|
|||
return response()->json($validator->messages(), $this->errorStatus);
|
||||
|
||||
}
|
||||
|
||||
$travel_user_booking_fewo = TravelUserBookingFewo::create($data['travel_user_booking_fewo']);
|
||||
|
||||
//mail
|
||||
if($travel_user_booking_fewo){
|
||||
$MailEmployee = explode(",", config('mail.mail_fewo_employee'));
|
||||
$EmployeeMailSubject = $travel_user_booking_fewo->getEmployeeMailSubject();
|
||||
$EmployeeMailContent = $travel_user_booking_fewo->getEmployeeMailContent();
|
||||
Mail::to($MailEmployee)->send(new MailSendFeWoService($travel_user_booking_fewo, $EmployeeMailSubject, $EmployeeMailContent));
|
||||
$send_employee_mail = $travel_user_booking_fewo->send_employee_mail;
|
||||
$send_employee_mail[] = ['d' => date('H:i d.m.Y'),
|
||||
'm'=>$MailEmployee,
|
||||
's'=>$EmployeeMailSubject,
|
||||
'c'=>$EmployeeMailContent];
|
||||
$travel_user_booking_fewo->send_employee_mail = $send_employee_mail;
|
||||
$travel_user_booking_fewo->save();
|
||||
}
|
||||
return response()->json(['success' => ['travel_user_booking_fewo_id' => $travel_user_booking_fewo->id, 'crm_url' => route('travel_user_booking_fewo_detail', [$travel_user_booking_fewo->id])]], $this->successStatus);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -52,7 +52,6 @@ class TravelUserBookingFewoController extends Controller
|
|||
$replace_info_text['fewo_user_anrede'] = $travel_user_booking_fewo->getUserSalutation();
|
||||
$replace_info_text['fewo_adresse'] = $travel_user_booking_fewo->getNameAddressLocation(", ");
|
||||
}
|
||||
|
||||
if(!$travel_user_booking_fewo->info_mail_text) {
|
||||
$travel_user_booking_fewo->info_mail_text = CMSContent::getContentBySlug('pdf-vorlage-anreiseinfo-fewo');
|
||||
$travel_user_booking_fewo->info_mail_text = Util::replacePlaceholders($travel_user_booking_fewo->info_mail_text, $replace_info_text);
|
||||
|
|
@ -60,6 +59,7 @@ class TravelUserBookingFewoController extends Controller
|
|||
|
||||
$data = [
|
||||
'travel_user_booking_fewo' => $travel_user_booking_fewo,
|
||||
'send_mail_employee_mail' => config('mail.mail_fewo_employee'),
|
||||
'max_adults' => $max_adults,
|
||||
'max_children' => $max_children,
|
||||
'id' => $id,
|
||||
|
|
@ -112,13 +112,12 @@ class TravelUserBookingFewoController extends Controller
|
|||
$mail_bbc = config('mail.mail_bbc');
|
||||
Mail::to($travel_user_booking_fewo->travel_user->email)->bcc($mail_bbc)->send(new MailSendFeWoInvoice($travel_user_booking_fewo, Input::get('send_mail_user_notice')));
|
||||
$send_user_mail = $travel_user_booking_fewo->send_user_mail;
|
||||
$send_user_mail[] = [date('H:i d.m.Y') => Input::get('send_mail_user_notice')];
|
||||
$send_user_mail[] = [date('H:i d.m.Y') => $travel_user_booking_fewo->travel_user->email." ".Input::get('send_mail_user_notice')];
|
||||
$travel_user_booking_fewo->send_user_mail = $send_user_mail;
|
||||
$travel_user_booking_fewo->save();
|
||||
\Session()->flash('alert-success', __('E-mail wurde an den Mieter versendet.'));
|
||||
\Session()->flash('alert-success', __('E-Mail wurde an den Mieter versendet.'));
|
||||
return redirect(route('travel_user_booking_fewo_detail', [$travel_user_booking_fewo->id]));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if($data['action'] == 'sendInfosMailtoUser') {
|
||||
|
|
@ -127,13 +126,12 @@ class TravelUserBookingFewoController extends Controller
|
|||
$mail_bbc = config('mail.mail_bbc');
|
||||
Mail::to($travel_user_booking_fewo->travel_user->email)->bcc($mail_bbc)->send(new MailSendFeWoInfo($travel_user_booking_fewo));
|
||||
$send_info_mail = $travel_user_booking_fewo->send_info_mail;
|
||||
$send_info_mail[] = [date('H:i d.m.Y') => ''];
|
||||
$send_info_mail[] = [date('H:i d.m.Y') => $travel_user_booking_fewo->travel_user->email];
|
||||
$travel_user_booking_fewo->send_info_mail = $send_info_mail;
|
||||
$travel_user_booking_fewo->save();
|
||||
\Session()->flash('alert-success', __('E-mail wurde an den Mieter versendet.'));
|
||||
\Session()->flash('alert-success', __('E-Mail wurde an den Mieter versendet.'));
|
||||
return redirect(route('travel_user_booking_fewo_detail', [$travel_user_booking_fewo->id]));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if($data['action'] == 'sendMailtoService') {
|
||||
|
|
@ -149,14 +147,28 @@ class TravelUserBookingFewoController extends Controller
|
|||
$travel_user_booking_fewo->send_service_mail = $send_service_mail;
|
||||
$travel_user_booking_fewo->save();
|
||||
|
||||
\Session()->flash('alert-success', __('E-mail wurde an den Dienstleister versendet.'));
|
||||
\Session()->flash('alert-success', __('E-Mail wurde an den Dienstleister versendet.'));
|
||||
return redirect(route('travel_user_booking_fewo_detail', [$travel_user_booking_fewo->id]));
|
||||
}
|
||||
}
|
||||
|
||||
if($data['action'] == 'sendMailtoEmployee') {
|
||||
$travel_user_booking_fewo = TravelUserBookingFewo::findOrFail($id);
|
||||
if($travel_user_booking_fewo){
|
||||
$mails = explode(",", Input::get('send_mail_employee_mail'));
|
||||
Mail::to($mails)->send(new MailSendFeWoService($travel_user_booking_fewo, Input::get('send_mail_employee_subject'), Input::get('send_mail_employee_content')));
|
||||
$send_employee_mail = $travel_user_booking_fewo->send_employee_mail;
|
||||
$send_employee_mail[] = ['d' => date('H:i d.m.Y'),
|
||||
'm'=>Input::get('send_mail_employee_mail'),
|
||||
's'=>Input::get('send_mail_employee_subject'),
|
||||
'c'=>Input::get('send_mail_employee_content')];
|
||||
$travel_user_booking_fewo->send_employee_mail = $send_employee_mail;
|
||||
$travel_user_booking_fewo->save();
|
||||
|
||||
|
||||
|
||||
\Session()->flash('alert-success', __('E-Mail wurde an die Mitarbeiter versendet.'));
|
||||
return redirect(route('travel_user_booking_fewo_detail', [$travel_user_booking_fewo->id]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function delete($id){
|
||||
|
|
@ -188,7 +200,6 @@ class TravelUserBookingFewoController extends Controller
|
|||
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 .= $travel_user_booking_fewo->is_calendar_fewo_direct ? ' <span class="badge badge-pill badge-success"><i class="far fa-check"></i></span>' : ' <span class="badge badge-pill badge-danger"><i class="far fa-times"></i></span>';
|
||||
$back .= $travel_user_booking_fewo->is_calendar_hrs ? ' <span class="badge badge-pill badge-success"><i class="far fa-check"></i></span>' : ' <span class="badge badge-pill badge-danger"><i class="far fa-times"></i></span>';
|
||||
|
|
@ -198,7 +209,6 @@ class TravelUserBookingFewoController extends Controller
|
|||
->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="far fa-trash"></span></a>';
|
||||
})
|
||||
|
|
|
|||
|
|
@ -21,8 +21,6 @@ class TravelUserController extends Controller
|
|||
'step' => $step
|
||||
];
|
||||
return view('travel.user.index', $data);
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function detail($id)
|
||||
|
|
|
|||
|
|
@ -55,6 +55,7 @@ class FewoLodging extends Model
|
|||
'group_id',
|
||||
'type_id',
|
||||
'name',
|
||||
'single_name',
|
||||
'description',
|
||||
'equipment',
|
||||
'adress1',
|
||||
|
|
|
|||
|
|
@ -85,6 +85,7 @@ class TravelUserBookingFewo extends Model
|
|||
'price_deposit' => 'float',
|
||||
'price_service' => 'float',
|
||||
'price_balance' => 'float',
|
||||
'price_extra' => 'float',
|
||||
'price_total' => 'float',
|
||||
'travel_booking_fewo_channel_id' => 'int',
|
||||
'is_calendar_fewo_direct' => 'bool',
|
||||
|
|
@ -94,6 +95,7 @@ class TravelUserBookingFewo extends Model
|
|||
'send_user_mail' => 'array',
|
||||
'send_service_mail' => 'array',
|
||||
'send_info_mail' => 'array',
|
||||
'send_employee_mail' => 'array',
|
||||
];
|
||||
|
||||
protected $dates = [
|
||||
|
|
@ -115,9 +117,11 @@ class TravelUserBookingFewo extends Model
|
|||
'to_date',
|
||||
'daily_prices',
|
||||
'price_travel',
|
||||
'price_balance',
|
||||
'price_extra',
|
||||
'price_travel_total',
|
||||
'price_deposit',
|
||||
'price_service',
|
||||
'price_balance',
|
||||
'price_total',
|
||||
'travel_booking_fewo_channel_id',
|
||||
'notice',
|
||||
|
|
@ -155,6 +159,14 @@ class TravelUserBookingFewo extends Model
|
|||
return "";
|
||||
}
|
||||
|
||||
public function getCheckedBadgeCalendar(){
|
||||
$back = "";
|
||||
$back .= $this->is_calendar_fewo_direct ? ' <span class="badge badge-pill badge-success"><i class="far fa-check"></i></span>' : ' <span class="badge badge-pill badge-danger"><i class="far fa-times"></i></span>';
|
||||
$back .= $this->is_calendar_hrs ? ' <span class="badge badge-pill badge-success"><i class="far fa-check"></i></span>' : ' <span class="badge badge-pill badge-danger"><i class="far fa-times"></i></span>';
|
||||
$back .= $this->is_calendar_stern_tours ? ' <span class="badge badge-pill badge-success"><i class="far fa-check"></i></span>' : ' <span class="badge badge-pill badge-danger"><i class="far fa-times"></i></span>';
|
||||
return $back;
|
||||
}
|
||||
|
||||
|
||||
public function getPersonsAttribute($value)
|
||||
{
|
||||
|
|
@ -259,6 +271,61 @@ class TravelUserBookingFewo extends Model
|
|||
return isset($this->attributes['price_travel']) ? $this->attributes['price_travel'] : 0;
|
||||
}
|
||||
|
||||
//price_extra
|
||||
public function setPriceExtraAttribute($value)
|
||||
{
|
||||
$value = Util::_format_number($value);
|
||||
$this->attributes['price_extra'] = floatval(str_replace(',', '.', $value));
|
||||
}
|
||||
public function getPriceExtraAttribute($value)
|
||||
{
|
||||
if(!$value){ return 0; }
|
||||
return number_format(($this->attributes['price_extra']), 2, ',', '.');
|
||||
}
|
||||
public function getPriceExtraRaw()
|
||||
{
|
||||
return isset($this->attributes['price_extra']) ? $this->attributes['price_extra'] : 0;
|
||||
}
|
||||
|
||||
|
||||
//price_balance
|
||||
public function setPriceBalanceAttribute($value)
|
||||
{
|
||||
$value = Util::_format_number($value);
|
||||
$this->attributes['price_balance'] = floatval(str_replace(',', '.', $value));
|
||||
}
|
||||
public function getPriceBalanceAttribute($value)
|
||||
{
|
||||
if(!$value){ return 0; }
|
||||
return number_format(($this->attributes['price_balance']), 2, ',', '.');
|
||||
}
|
||||
public function getPriceBalanceRaw()
|
||||
{
|
||||
return isset($this->attributes['price_balance']) ? $this->attributes['price_balance'] : 0;
|
||||
}
|
||||
|
||||
|
||||
//price_travel_total
|
||||
public function setPriceTravelTotalAttribute($value)
|
||||
{
|
||||
$value = Util::_format_number($value);
|
||||
$this->attributes['price_travel_total'] = floatval(str_replace(',', '.', $value));
|
||||
}
|
||||
public function getPriceTravelTotalAttribute($value)
|
||||
{
|
||||
if(!$value){
|
||||
$this->attributes['price_travel_total'] = $this->getPriceTravelRaw() + $this->getPriceBalanceRaw() + $this->getPriceExtraRaw();
|
||||
}
|
||||
return number_format(($this->attributes['price_travel_total']), 2, ',', '.');
|
||||
}
|
||||
public function getPriceTravelTotalRaw()
|
||||
{
|
||||
if(!isset($this->attributes['price_travel_total']) || $this->attributes['price_travel_total'] == 0){
|
||||
$this->attributes['price_travel_total'] = $this->getPriceTravelRaw() + $this->getPriceBalanceRaw() + $this->getPriceExtraRaw();
|
||||
}
|
||||
return isset($this->attributes['price_travel_total']) ? $this->attributes['price_travel_total'] : 0;
|
||||
}
|
||||
|
||||
//price_deposit
|
||||
public function setPriceDepositAttribute($value)
|
||||
{
|
||||
|
|
@ -295,21 +362,6 @@ class TravelUserBookingFewo extends Model
|
|||
return isset($this->attributes['price_service']) ? $this->attributes['price_service'] : 0;
|
||||
}
|
||||
|
||||
//price_balance
|
||||
public function setPriceBalanceAttribute($value)
|
||||
{
|
||||
$value = Util::_format_number($value);
|
||||
$this->attributes['price_balance'] = floatval(str_replace(',', '.', $value));
|
||||
}
|
||||
public function getPriceBalanceAttribute($value)
|
||||
{
|
||||
if(!$value){ return 0; }
|
||||
return number_format(($this->attributes['price_balance']), 2, ',', '.');
|
||||
}
|
||||
public function getPriceBalanceRaw()
|
||||
{
|
||||
return isset($this->attributes['price_balance']) ? $this->attributes['price_balance'] : 0;
|
||||
}
|
||||
|
||||
//price_total
|
||||
public function setPriceTotalAttribute($value)
|
||||
|
|
@ -329,35 +381,23 @@ class TravelUserBookingFewo extends Model
|
|||
return isset($this->attributes['price_total']) ? $this->attributes['price_total'] : 0;
|
||||
}
|
||||
|
||||
public function getPriceTotalFirstPay(){
|
||||
if($this->attributes['price_total'] == 0){
|
||||
return 0;
|
||||
}
|
||||
$first_pay = $this->attributes['price_total']/2;
|
||||
return number_format(($first_pay), 2, ',', '.');
|
||||
}
|
||||
public function getPriceTotalSecondPay(){
|
||||
if($this->attributes['price_total'] == 0){
|
||||
return 0;
|
||||
}
|
||||
$first_pay = $this->attributes['price_total']/2;
|
||||
return number_format(($this->attributes['price_total'] - $first_pay), 2, ',', '.');
|
||||
}
|
||||
public function getPriceTravelFirstPay(){
|
||||
public function getPriceTravelTotalFirstPay(){
|
||||
if($this->attributes['price_travel'] == 0){
|
||||
return 0;
|
||||
}
|
||||
$first_pay = $this->attributes['price_travel']/2;
|
||||
$first_pay = ($this->getPriceTravelTotalRaw() + $this->getPriceServiceRaw()) / 2;
|
||||
return number_format(($first_pay), 2, ',', '.');
|
||||
}
|
||||
public function getPriceTravelSecondPay(){
|
||||
public function getPriceTravelTotalSecondPay(){
|
||||
if($this->attributes['price_travel'] == 0){
|
||||
return 0;
|
||||
}
|
||||
$first_pay = $this->attributes['price_travel']/2;
|
||||
return number_format(($this->attributes['price_travel'] - $first_pay + $this->attributes['price_deposit']), 2, ',', '.');
|
||||
$total_pay = ($this->getPriceTravelTotalRaw() + $this->getPriceServiceRaw());
|
||||
$first_pay = $total_pay/2;
|
||||
return number_format(($total_pay - $first_pay + $this->getPriceDepositRaw()), 2, ',', '.');
|
||||
}
|
||||
|
||||
|
||||
public function getBookingDateYear(){
|
||||
return Carbon::parse($this->booking_date)->format('Y');
|
||||
}
|
||||
|
|
@ -487,7 +527,12 @@ class TravelUserBookingFewo extends Model
|
|||
}
|
||||
public function getNameAddressLocation($sep = "\n"){
|
||||
if($this->fewo_lodging){
|
||||
return $this->fewo_lodging->name.$sep.$this->fewo_lodging->adress1." ".$this->fewo_lodging->adress2.", ".$this->fewo_lodging->zip_code." ".$this->fewo_lodging->city;
|
||||
|
||||
$name = trim($this->fewo_lodging->single_name).$sep;
|
||||
$address = trim($this->fewo_lodging->adress1);
|
||||
$address .= $this->fewo_lodging->adress2 ? " ".$this->fewo_lodging->adress2.$sep : ", ";
|
||||
$city = trim($this->fewo_lodging->zip_code)." ".trim($this->fewo_lodging->city);
|
||||
return $name.$address.$city;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
|
@ -517,7 +562,17 @@ class TravelUserBookingFewo extends Model
|
|||
$this->from_date." - ".$this->to_date." ".$this->travel_user->first_name." ".$this->travel_user->last_name;
|
||||
}
|
||||
|
||||
public function getEmployeeMailSubject(){
|
||||
if($this->fewo_lodging){
|
||||
return "CRM Fewo Buchung: ".$this->fewo_lodging->name." | Anreise ".$this->from_date;
|
||||
}
|
||||
return "CRM Fewo Buchung | Anreise ".$this->from_date;
|
||||
}
|
||||
|
||||
|
||||
public function getEmployeeMailContent(){
|
||||
return ($this->travel_user_id ? "Kunde: ".route('travel_user_detail', [$this->travel_user_id])."\n" : "").
|
||||
"Buchung: ".route('travel_user_booking_fewo_detail', [$this->id])."\n".
|
||||
$this->travel_user->first_name." ".$this->travel_user->last_name." | ".$this->from_date." - ".$this->to_date." | ".$this->adults." + ".$this->children." (Erwachsene + Kinder)";
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -143,6 +143,7 @@ class TravelUserBookingFewoRepository extends BaseRepository {
|
|||
//check for data
|
||||
$check_for_reservation = true;
|
||||
$fewo_reservation_id = 0;
|
||||
$model = false;
|
||||
if($id > 0) {
|
||||
$model = TravelUserBookingFewo::findOrFail($id);
|
||||
if($data['from_date'] == $model->from_date && $data['to_date'] == $model->to_date){
|
||||
|
|
@ -178,13 +179,12 @@ class TravelUserBookingFewoRepository extends BaseRepository {
|
|||
'status' => 'required'
|
||||
);
|
||||
|
||||
if($fewo_reservation_id > 0 && $model && Input::get('invoice_number')){
|
||||
$rules['invoice_number'] = 'required|unique:mysql_stern.travel_user_booking_fewos,invoice_number,'.$model->id;
|
||||
}
|
||||
|
||||
$validator = Validator::make(Input::all(), $rules);
|
||||
|
||||
/* $message = 'my custom validation rule message' . $data['from_date'];
|
||||
Validator::extend('my_custom_validation_rule', function ($attribute, $value, $parameters) {
|
||||
//
|
||||
}, $message);
|
||||
*/
|
||||
if ($validator->fails()) {
|
||||
return back()->withInput(Input::all())->withErrors($validator);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue