Report Strono-Date, Booking+Fewo Notice, Custom Mail opti

This commit is contained in:
Kevin Adametz 2021-04-23 14:55:48 +02:00
parent 644ec93c53
commit 5d55e5be3f
35 changed files with 581 additions and 41 deletions

View file

@ -43,7 +43,7 @@ class ReportController extends Controller
private function prozessBookingSearch()
{
$query = Booking::with( 'customer', 'lead', 'service_provider_entries', 'service_provider_entries.service_provider')->select('booking.*');
$query = Booking::with( 'customer', 'lead', 'booking_strono','service_provider_entries', 'service_provider_entries.service_provider')->select('booking.*');
if(Request::get('filter_travel_date_from') != ""){
$travel_date_from = Carbon::parse(Request::get('filter_travel_date_from'))->format("Y-m-d");
@ -106,6 +106,9 @@ class ReportController extends Controller
->addColumn('booking_date', function (Booking $booking) {
return $booking->getBookingDateFormat();
})
->addColumn('booking_strono_date', function (Booking $booking) {
return $booking->booking_strono ? $booking->booking_strono->storno_date->format("d.m.Y") : "";
})
->addColumn('service_provider.names', function (Booking $booking) {
$ret = "";
if($booking->service_provider_entries){
@ -154,7 +157,6 @@ class ReportController extends Controller
public function bookingsExport(){
$query = $this->prozessBookingSearch();
$order = explode(",", Request::get('order'));
@ -183,6 +185,7 @@ class ReportController extends Controller
$headers = array(
'BuchungsID',
'Status',
'Storno',
'MyJack Nr.',
'Organisation',
'Reisepreis',
@ -206,6 +209,7 @@ class ReportController extends Controller
$total_amount_final = 0;
foreach($exports as $export) {
$storno_date = $export->booking_strono ? $export->booking_strono->storno_date->format("d.m.Y") : "";
if($export->service_provider_entries->count()){
$new = true;
foreach ($export->service_provider_entries as $service_provider_entry){
@ -218,6 +222,7 @@ class ReportController extends Controller
$columns[] = array(
'BuchungsID' => $new ? $export->id : "",
'Status' => $new ? $export->lead->status->name : "",
'Storno' => $new ? $storno_date : "",
'MyJack Nr.' => $new ? $export->merlin_order_number : "",
'Organisation' => $new ? $export->price : "",
'Reisepreis' => $new ? $export->price_total : "",
@ -243,6 +248,7 @@ class ReportController extends Controller
$columns[] = array(
'BuchungsID' => $export->id,
'Status' => $export->lead->status->name,
'Storno' => $storno_date,
'MyJack Nr.' => $export->merlin_order_number,
'Organisation' => $export->price,
'Reisepreis' => $export->price_total,
@ -266,6 +272,7 @@ class ReportController extends Controller
$columns[] = array(
'BuchungsID' => "Total",
'Status' => "",
'Storno' => "",
'MyJack Nr.' => "",
'Organisation' => Util::_number_format($total_price),
'Reisepreis' => Util::_number_format($total_price_total),

View file

@ -2,15 +2,16 @@
namespace App\Http\Controllers;
use App\Models\Booking;
use App\Models\BookingDraftItem;
use App\Models\BookingFile;
use App\Models\Customer;
use App\Repositories\BookingFileRepository;
use App\Repositories\BookingRepository;
use App\Repositories\CustomerMailRepository;
use App\Repositories\DraftRepository;
use Request;
use App\Models\Booking;
use App\Models\Customer;
use App\Models\BookingFile;
use App\Models\BookingNotice;
use App\Models\BookingDraftItem;
use App\Repositories\DraftRepository;
use App\Repositories\BookingRepository;
use App\Repositories\BookingFileRepository;
use App\Repositories\CustomerMailRepository;
class BookingController extends Controller
{
@ -63,7 +64,12 @@ class BookingController extends Controller
\Session()->flash('alert-save', '1');
return redirect(route('booking_detail', [$booking->id])."#collapseBookingNotice");
}
if($data['action'] === 'edit_notice'){
$booking = $this->bookingRepo->updateNotice($id, $data);
\Session()->flash('alert-save', '1');
return redirect(route('booking_detail', [$booking->id])."#collapseBookingNotice");
}
if($data['action'] === 'update_booking'){
$booking = $this->bookingRepo->updateBooking($id, $data);
\Session()->flash('alert-save', '1');
@ -220,6 +226,11 @@ class BookingController extends Controller
$ret = view("booking.upload_modal", compact('data'))->render();
}
if($data['action'] === "edit_notice") {
$value = BookingNotice::findOrFail($data['id']);
$ret = view("booking.edit_notice_modal", compact('data', 'value'))->render();
}
if($data['action'] === "upload-booking-file"){
if($data['booking_id']){
$bookingFileRepo = new BookingFileRepository(new BookingFile());
@ -274,6 +285,14 @@ class BookingController extends Controller
\Session()->flash('alert-success', 'Datei gelöscht');
return redirect(route('booking_detail', [$booking->id]));
}
if($del === 'booking_notice'){
$booking_notice = BookingNotice::findOrFail($id);
$booking = $booking_notice->booking;
$booking_notice->delete();
\Session()->flash('alert-success', 'Notiz gelöscht');
return redirect(route('booking_detail', [$booking->id]));
}
if($del === 'passolution_file'){
$booking = Booking::findOrFail($id);
$booking->resyncPassolutionPDF();

View file

@ -4,6 +4,7 @@ namespace App\Http\Controllers;
use App\Models\BookingNotice;
use App\Models\SfGuardUser;
use App\Models\TravelUserBookingFewoNotice;
use App\User;
use Auth;
use Carbon\Carbon;
@ -42,10 +43,12 @@ class HomeController extends Controller
return redirect('login');
}
$last_booking_notices = BookingNotice::orderBy('created_at', 'DESC')->limit(10)->get();
$last_booking_notices = BookingNotice::orderBy('edit_at', 'DESC')->orderBy('created_at', 'DESC')->limit(10)->get();
$last_booking_fewo_notices = TravelUserBookingFewoNotice::orderBy('edit_at', 'DESC')->orderBy('created_at', 'DESC')->limit(10)->get();
$data = [
'user' => Auth::user(),
'last_booking_notices' => $last_booking_notices,
'last_booking_fewo_notices' => $last_booking_fewo_notices
];
return view('home', $data);
}

View file

@ -384,8 +384,6 @@ class RequestController extends Controller
'<span data-order="0" class="badge badge-pill badge-danger"><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>';
})

View file

@ -11,6 +11,7 @@ use App\Models\FewoLodging;
use App\Models\FewoReservation;
use App\Models\TravelBookingFewoChannel;
use App\Models\TravelUserBookingFewo;
use App\Models\TravelUserBookingFewoNotice;
use App\Models\TravelUserBookingFile;
use App\Repositories\BookingFewoFileRepository;
use App\Repositories\TravelUserBookingFewoRepository;
@ -82,6 +83,18 @@ class TravelUserBookingFewoController extends Controller
public function store($id)
{
$data = Request::all();
if($data['action'] === 'save_notice'){
$travel_user_booking_fewo = $this->userBookingFewoRepo->updateNotice($id, $data);
\Session()->flash('alert-save', '1');
return redirect(route('travel_user_booking_fewo_detail', [$travel_user_booking_fewo->id])."#collapseBookingNotice");
}
if($data['action'] === 'edit_notice'){
$travel_user_booking_fewo = $this->userBookingFewoRepo->updateNotice($id, $data);
\Session()->flash('alert-save', '1');
return redirect(route('travel_user_booking_fewo_detail', [$travel_user_booking_fewo->id])."#collapseBookingNotice");
}
if($data['action'] === 'saveAll'){
return $this->userBookingFewoRepo->update($id, $data);
}
@ -183,6 +196,19 @@ class TravelUserBookingFewoController extends Controller
}
}
public function loadModal(){
$data = Request::all();
$ret = "";
if(Request::ajax()) {
if($data['action'] === "edit_notice") {
$value = TravelUserBookingFewoNotice::findOrFail($data['id']);
$ret = view("travel.user.booking.edit_notice_modal", compact('data', 'value'))->render();
}
}
return response()->json(['response' => $data, 'html'=>$ret]);
}
public function delete($id, $del="travel_user_booking_fewo"){
if($del === 'travel_user_booking_fewo') {
@ -206,6 +232,14 @@ class TravelUserBookingFewoController extends Controller
\Session()->flash('alert-success', __('Buchung gelöscht sowie die Reservierung im Sterntrous Kalender'));
}
if($del === 'booking_fewo_notices'){
$booking_fewo_notice = TravelUserBookingFewoNotice::findOrFail($id);
$travel_user_booking_fewo = $booking_fewo_notice->travel_user_booking_fewo;
$booking_fewo_notice->delete();
\Session()->flash('alert-success', 'Notiz gelöscht');
return redirect(route('travel_user_booking_fewo_detail', [$travel_user_booking_fewo->id]));
}
if($del === 'booking_fewo_files'){
$booking_fewo_file = TravelUserBookingFile::findOrFail($id);

View file

View file

@ -176,6 +176,13 @@ use Illuminate\Database\Eloquent\Model;
* @property-read int|null $booking_provider_services_count
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\BookingProviderService[] $booking_provider_services_checked
* @property-read int|null $booking_provider_services_checked_count
* @property bool|null $comfort
* @property int|null $nationality_id
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\BookingNotice[] $booking_notices
* @property-read int|null $booking_notices_count
* @property-read \App\Models\TravelNationality|null $travel_nationality
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Booking whereComfort($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Booking whereNationalityId($value)
*/
class Booking extends Model
{
@ -529,6 +536,11 @@ class Booking extends Model
return $this->hasMany(BookingNotice::class, 'booking_id')->orderBy('created_at', 'DESC');
}
public function booking_strono()
{
return $this->hasOne(BookingStorno::class);
}
public function hasBookingServicesUnchecked(){
$country_services = true;
$provider_services = true;

View file

@ -12,7 +12,7 @@ use Illuminate\Database\Eloquent\Model;
/**
* Class BookingNotice
*
*
* @property int $id
* @property int $booking_id
* @property int $from_user_id
@ -20,13 +20,28 @@ use Illuminate\Database\Eloquent\Model;
* @property string $message
* @property bool $show
* @property bool $important
* @property Carbon $edit_at
* @property Carbon $created_at
* @property Carbon $updated_at
*
* @property Booking $booking
* @property User $user
*
* @package App\Models
* @property-read \App\User $from_user
* @property-read \App\User|null $to_user
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\BookingNotice newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\BookingNotice newQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\BookingNotice query()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\BookingNotice whereBookingId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\BookingNotice whereCreatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\BookingNotice whereEditAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\BookingNotice whereFromUserId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\BookingNotice whereId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\BookingNotice whereImportant($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\BookingNotice whereMessage($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\BookingNotice whereShow($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\BookingNotice whereToUserId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\BookingNotice whereUpdatedAt($value)
* @mixin \Eloquent
*/
class BookingNotice extends Model
{
@ -40,13 +55,18 @@ class BookingNotice extends Model
'important' => 'bool'
];
protected $dates = [
'edit_at',
];
protected $fillable = [
'booking_id',
'from_user_id',
'to_user_id',
'message',
'show',
'important'
'important',
'edit_at'
];
public function booking()

View file

@ -36,6 +36,8 @@ use Illuminate\Database\Eloquent\Model;
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\BookingStorno whereTotal($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\BookingStorno whereUpdatedAt($value)
* @mixin \Eloquent
* @property \Illuminate\Support\Carbon|null $storno_print
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\BookingStorno whereStornoPrint($value)
*/
class BookingStorno extends Model
{
@ -49,7 +51,8 @@ class BookingStorno extends Model
];
protected $dates = [
'storno_date'
'storno_date',
'storno_print'
];
protected $fillable = [
@ -57,6 +60,7 @@ class BookingStorno extends Model
'total',
'storno',
'storno_date',
'storno_print',
'binary_data',
'done'
];

View file

@ -81,6 +81,8 @@ use Illuminate\Database\Eloquent\Model;
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerFewoMail whereDeletedAt($value)
* @method static \Illuminate\Database\Query\Builder|\App\Models\CustomerFewoMail withTrashed()
* @method static \Illuminate\Database\Query\Builder|\App\Models\CustomerFewoMail withoutTrashed()
* @property array|null $forward
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerFewoMail whereForward($value)
*/
class CustomerFewoMail extends Model
{

View file

@ -77,6 +77,8 @@ use Illuminate\Database\Eloquent\Model;
* @mixin \Eloquent
* @property int|null $subdir
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerMail whereSubdir($value)
* @property array|null $forward
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerMail whereForward($value)
*/
class CustomerMail extends Model
{

View file

@ -33,6 +33,9 @@ use Illuminate\Database\Eloquent\Model;
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Participant whereParticipantName($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Participant whereParticipantSalutationId($value)
* @mixin \Eloquent
* @property int|null $nationality_id
* @property-read \App\Models\TravelNationality|null $travel_nationality
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Participant whereNationalityId($value)
*/
class Participant extends Model
{

View file

@ -53,6 +53,7 @@ use Illuminate\Database\Eloquent\Model;
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\SfGuardUser newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\SfGuardUser newQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\SfGuardUser query()
* @property-read \App\User|null $user
*/
class SfGuardUser extends Model
{

View file

@ -49,6 +49,8 @@ use Illuminate\Database\Eloquent\Model;
* @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
* @property string|null $destco
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Sym\TravelCountry whereDestco($value)
*/
class TravelCountry extends Model
{

View file

@ -69,6 +69,8 @@ use Illuminate\Support\Str;
* @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
* @property string|null $destco
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelCountry whereDestco($value)
*/
class TravelCountry extends Model
{

View file

@ -17,6 +17,8 @@ use Illuminate\Database\Eloquent\Model;
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelNationality newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelNationality newQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelNationality query()
* @property string|null $nat
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\TravelNationality whereNat($value)
*/
class TravelNationality extends Model
{

View file

@ -251,6 +251,11 @@ class TravelUserBookingFewo extends Model
return $this->hasOne(CustomerFewoMail::class, 'travel_user_booking_fewo_id')->latest();
}
public function booking_fewo_notices()
{
return $this->hasMany(TravelUserBookingFewoNotice::class, 'travel_user_booking_fewo_id')->orderBy('created_at', 'DESC');
}
public function getStatuesName(){
if(isset(self::$statues[$this->status])){
return self::$statues[$this->status];

View file

@ -0,0 +1,92 @@
<?php
/**
* Created by Reliese Model.
*/
namespace App\Models;
use App\User;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Model;
/**
* Class TravelUserBookingFewoNotice
*
* @property int $id
* @property int $travel_user_booking_fewo_id
* @property int $from_user_id
* @property int $to_user_id
* @property string $message
* @property bool $show
* @property bool $important
* @property Carbon $edit_at
* @property Carbon $created_at
* @property Carbon $updated_at
*
* @property TravelUserBookingFewo $travel_user_booking_fewo
*
* @package App\Models
*/
class TravelUserBookingFewoNotice extends Model
{
protected $connection = 'mysql_stern';
protected $table = 'travel_user_booking_fewo_notices';
protected $casts = [
'travel_user_booking_fewo_id' => 'int',
'from_user_id' => 'int',
'to_user_id' => 'int',
'show' => 'bool',
'important' => 'bool'
];
protected $dates = [
'edit_at'
];
protected $fillable = [
'travel_user_booking_fewo_id',
'from_user_id',
'to_user_id',
'message',
'show',
'important',
'edit_at'
];
public function travel_user_booking_fewo()
{
return $this->belongsTo(TravelUserBookingFewo::class);
}
public function to_user()
{
return $this->belongsTo(User::class, 'to_user_id');
}
public function from_user()
{
return $this->belongsTo(User::class, 'from_user_id');
}
public function getName(){
if($this->from_user){
if($this->from_user->sf_guard_user){
return $this->from_user->sf_guard_user->first_name." ".$this->from_user->sf_guard_user->last_name;
}else{
$this->from_user->name;
}
}
}
public function getSmallerMessage($max = 500){
$ret = substr($this->message, 0, $max);
if(strlen($this->message) > 500){
$ret .= " ...";
}
return $ret;
}
}

View file

@ -27,13 +27,22 @@ class BookingRepository extends BaseRepository {
public function updateNotice($id, $data){
$this->model = Booking::findOrFail($id);
BookingNotice::create([
'booking_id' => $this->model->id,
'from_user_id' => Auth::user()->id,
'to_user_id' => isset($this->model->sf_guard_user->user_id) ? $this->model->sf_guard_user->user_id : null,
'message' => isset($data['booking_notice']) ? $data['booking_notice'] : "",
]
);
if($data['action'] === 'edit_notice' && isset($data['notice_id'])){
$BookingNotice = BookingNotice::findOrFail($data['notice_id']);
$BookingNotice->message = isset($data['booking_notice']) ? $data['booking_notice'] : "";
$BookingNotice->edit_at = now();
$BookingNotice->save();
}else{
//save_notice
BookingNotice::create([
'booking_id' => $this->model->id,
'from_user_id' => Auth::user()->id,
'to_user_id' => isset($this->model->sf_guard_user->user_id) ? $this->model->sf_guard_user->user_id : null,
'message' => isset($data['booking_notice']) ? $data['booking_notice'] : "",
]
);
}
return $this->model;
}

View file

@ -11,6 +11,7 @@ use App\Models\TravelClass;
use App\Models\TravelProgram;
use App\Models\TravelProgramDraft;
use App\Models\TravelUserBookingFewo;
use App\Models\TravelUserBookingFewoNotice;
use App\Services\Util;
use PDF;
use Carbon\Carbon;
@ -26,6 +27,26 @@ class TravelUserBookingFewoRepository extends BaseRepository {
$this->model = $model;
}
public function updateNotice($id, $data){
$model = TravelUserBookingFewo::findOrFail($id);
if($data['action'] === 'edit_notice' && isset($data['notice_id'])){
$BookingNotice = TravelUserBookingFewoNotice::findOrFail($data['notice_id']);
$BookingNotice->message = isset($data['booking_fewo_notice']) ? $data['booking_fewo_notice'] : "";
$BookingNotice->edit_at = now();
$BookingNotice->save();
}else{
//save_notice
TravelUserBookingFewoNotice::create([
'travel_user_booking_fewo_id' => $model->id,
'from_user_id' => \Auth::user()->id,
'message' => isset($data['booking_fewo_notice']) ? $data['booking_fewo_notice'] : "",
]
);
}
return $model;
}
public function createTravelInfoPDF($id, $travel_info_user_text){
@ -252,7 +273,6 @@ class TravelUserBookingFewoRepository extends BaseRepository {
return redirect(route('travel_user_booking_fewo_detail', [$model->id]));
}
private function calculatePriceNew(TravelUserBookingFewo $travel_user_booking_fewo){
$FewoSeasons = FewoSeason::where('from_date', '<', $travel_user_booking_fewo->getToDateRaw())

View file

@ -77,6 +77,7 @@ use Illuminate\Foundation\Auth\User as Authenticatable;
* @property-read int|null $notifications_count
* @property-read int|null $tokens_count
* @property-read int|null $user_update_email_count
* @property-read \App\Models\SfGuardUser|null $sf_guard_user
*/
class User extends Authenticatable
{
@ -84,6 +85,7 @@ class User extends Authenticatable
use SoftDeletes;
protected $connection = 'mysql';
protected $permissionData = [];