Fewo/ PDFs / Mails v3
This commit is contained in:
parent
7abfe3f700
commit
e537e47a82
44 changed files with 2112 additions and 527 deletions
|
|
@ -112,4 +112,27 @@ class CMSContent extends Model
|
|||
}
|
||||
|
||||
|
||||
public static function getContentBySlug($slug){
|
||||
$CMSContent = CMSContent::whereSlug(trim($slug))->first();
|
||||
if($CMSContent){
|
||||
switch ($CMSContent->field){
|
||||
case 'text':
|
||||
return $CMSContent->text;
|
||||
break;
|
||||
case 'full_text':
|
||||
return $CMSContent->full_text;
|
||||
break;
|
||||
case 'integer':
|
||||
return $CMSContent->integer;
|
||||
|
||||
break;
|
||||
case 'decimal':
|
||||
return $CMSContent->decimal;
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,8 +9,8 @@ namespace App\Models;
|
|||
|
||||
use Carbon;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Util;
|
||||
|
||||
use Storage;
|
||||
use App\Services\Util;
|
||||
/**
|
||||
* Class TravelUserBookingFewo
|
||||
*
|
||||
|
|
@ -90,7 +90,10 @@ class TravelUserBookingFewo extends Model
|
|||
'is_calendar_fewo_direct' => 'bool',
|
||||
'is_calendar_hrs' => 'bool',
|
||||
'is_calendar_stern_tours' => 'bool',
|
||||
'status' => 'int'
|
||||
'status' => 'int',
|
||||
'send_user_mail' => 'array',
|
||||
'send_service_mail' => 'array',
|
||||
'send_info_mail' => 'array',
|
||||
];
|
||||
|
||||
protected $dates = [
|
||||
|
|
@ -326,10 +329,6 @@ class TravelUserBookingFewo extends Model
|
|||
return isset($this->attributes['price_total']) ? $this->attributes['price_total'] : 0;
|
||||
}
|
||||
|
||||
public function getBookingDateYear(){
|
||||
return Carbon::parse($this->booking_date)->format('Y');
|
||||
}
|
||||
|
||||
public function getPriceTotalFirstPay(){
|
||||
if($this->attributes['price_total'] == 0){
|
||||
return 0;
|
||||
|
|
@ -358,6 +357,125 @@ class TravelUserBookingFewo extends Model
|
|||
$first_pay = $this->attributes['price_travel']/2;
|
||||
return number_format(($this->attributes['price_travel'] - $first_pay + $this->attributes['price_deposit']), 2, ',', '.');
|
||||
}
|
||||
|
||||
public function getBookingDateYear(){
|
||||
return Carbon::parse($this->booking_date)->format('Y');
|
||||
}
|
||||
|
||||
//get Invoice Name / Paths / ...
|
||||
public function getInvoiceFileName(){
|
||||
if($this->invoice_number) {
|
||||
return Util::sanitize($this->invoice_number).".pdf";
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function getInvoicePath(){
|
||||
$dir = $this->getBookingDateYear()."/";
|
||||
if(!Storage::disk('fewo_invoices')->exists( $dir )){
|
||||
Storage::disk('fewo_invoices')->makeDirectory($dir); //creates directory
|
||||
}
|
||||
$path = Storage::disk('fewo_invoices')->getAdapter()->getPathPrefix();
|
||||
return $path.$dir;
|
||||
}
|
||||
|
||||
public function isInvoice(){
|
||||
if($this->invoice_number){
|
||||
$dir = $this->getBookingDateYear()."/";
|
||||
$filename = $this->getInvoiceFileName();
|
||||
if(Storage::disk('fewo_invoices')->exists( $dir.$filename )){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function getInvoicePathFile(){
|
||||
$dir = $this->getBookingDateYear()."/";
|
||||
$filename = $this->getInvoiceFileName();
|
||||
if(Storage::disk('fewo_invoices')->exists( $dir.$filename )){
|
||||
return Storage::disk('fewo_invoices')->path($dir.$filename);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function getInvoiceUrlFile(){
|
||||
$dir = $this->getBookingDateYear()."/";
|
||||
$filename = $this->getInvoiceFileName();
|
||||
if(Storage::disk('fewo_invoices')->exists( $dir.$filename )){
|
||||
return Storage::disk('fewo_invoices')->url($dir.$filename);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function getInvoiceLastModified(){
|
||||
$dir = $this->getBookingDateYear()."/";
|
||||
$filename = $this->getInvoiceFileName();
|
||||
if(Storage::disk('fewo_invoices')->exists( $dir.$filename )){
|
||||
return Carbon::createFromTimestamp(Storage::disk('fewo_invoices')->lastModified($dir.$filename))->format("H:i d.m.Y");
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//get TravelInfos Name / Paths / ...
|
||||
public function getTravelInfoFileName(){
|
||||
if($this->invoice_number) {
|
||||
return "Anreiseinfo-".Util::sanitize($this->invoice_number).".pdf";
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function getTravelInfoPath(){
|
||||
$dir = $this->getBookingDateYear()."/";
|
||||
if(!Storage::disk('fewo_infos')->exists( $dir )){
|
||||
Storage::disk('fewo_infos')->makeDirectory($dir); //creates directory
|
||||
}
|
||||
$path = Storage::disk('fewo_infos')->getAdapter()->getPathPrefix();
|
||||
return $path.$dir;
|
||||
}
|
||||
|
||||
public function isTravelInfo(){
|
||||
if($this->invoice_number){
|
||||
$dir = $this->getBookingDateYear()."/";
|
||||
$filename = $this->getTravelInfoFileName();
|
||||
if(Storage::disk('fewo_infos')->exists( $dir.$filename )){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function getTravelInfoPathFile(){
|
||||
$dir = $this->getBookingDateYear()."/";
|
||||
$filename = $this->getTravelInfoFileName();
|
||||
if(Storage::disk('fewo_infos')->exists( $dir.$filename )){
|
||||
return Storage::disk('fewo_infos')->path($dir.$filename);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function getTravelInfoUrlFile(){
|
||||
$dir = $this->getBookingDateYear()."/";
|
||||
$filename = $this->getTravelInfoFileName();
|
||||
if(Storage::disk('fewo_infos')->exists( $dir.$filename )){
|
||||
return Storage::disk('fewo_infos')->url($dir.$filename);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function getTravelInfoLastModified(){
|
||||
$dir = $this->getBookingDateYear()."/";
|
||||
$filename = $this->getTravelInfoFileName();
|
||||
if(Storage::disk('fewo_infos')->exists( $dir.$filename )){
|
||||
return Carbon::createFromTimestamp(Storage::disk('fewo_infos')->lastModified($dir.$filename))->format("H:i d.m.Y");
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
//get strings
|
||||
public function getBookingUserAddress(){
|
||||
if($this->travel_user){
|
||||
$company = $this->travel_user->company ? $this->travel_user->company ."\n" : "";
|
||||
|
|
@ -367,12 +485,39 @@ class TravelUserBookingFewo extends Model
|
|||
}
|
||||
return "";
|
||||
}
|
||||
public function getNameAddressLocation(){
|
||||
public function getNameAddressLocation($sep = "\n"){
|
||||
if($this->fewo_lodging){
|
||||
return $this->fewo_lodging->name."\n".$this->fewo_lodging->adress1." ".$this->fewo_lodging->adress2.", ".$this->fewo_lodging->zip_code." ".$this->fewo_lodging->city;
|
||||
return $this->fewo_lodging->name.$sep.$this->fewo_lodging->adress1." ".$this->fewo_lodging->adress2.", ".$this->fewo_lodging->zip_code." ".$this->fewo_lodging->city;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
public function getUserSalutation(){
|
||||
|
||||
$salutation = __('Dear customer');
|
||||
if($this->travel_user){
|
||||
if($this->travel_user->salutation_id == 1){
|
||||
$salutation = __('Dear Sir')." ".$this->travel_user->last_name;
|
||||
}else{
|
||||
$salutation = __('Dear Mrs')." ".$this->travel_user->last_name;
|
||||
}
|
||||
}
|
||||
return $salutation;
|
||||
}
|
||||
|
||||
public function getServiceMailSubject(){
|
||||
if($this->fewo_lodging){
|
||||
return "Neue Anmietung ".$this->fewo_lodging->name." mit Anreise ".$this->from_date;
|
||||
}
|
||||
return "Neue Anmietung Anreise ".$this->from_date;
|
||||
}
|
||||
|
||||
public function getServiceMailContent(){
|
||||
return $this->adults." + ".$this->children." (Erwachsene + Kinder)\n".
|
||||
$this->from_date." - ".$this->to_date." ".$this->travel_user->first_name." ".$this->travel_user->last_name;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue