Mails, Strono, filter

This commit is contained in:
Kevin Adametz 2020-03-26 09:48:19 +01:00
parent f53f17f9c1
commit 62e84637b6
99 changed files with 2409 additions and 474 deletions

View file

@ -142,15 +142,20 @@ class Booking extends Model
'price_total' => 'float',
'deposit_total' => 'float',
'final_payment' => 'float',
'travelagenda_id' => 'int'
];
'travelagenda_id' => 'int',
'paying_out' => 'int',
'refund' => 'int',
'xx_tkt' => 'int',
];
protected $dates = [
'booking_date',
'start_date',
'end_date',
'participant_birthdate',
'final_payment_date'
'final_payment_date',
'refund_date'
];
protected $fillable = [
@ -184,9 +189,69 @@ class Booking extends Model
'deposit_total',
'final_payment',
'final_payment_date',
'travelagenda_id'
'travelagenda_id',
'paying_out',
'paying_out_status',
'refund',
'refund_date',
'xx_tkt',
'xx_tkt_date',
];
public static $paying_out_types = [
0 => '-',
1 => 'Gutschein',
2 => 'Auszahlung',
3 => 'Umbuchung',
4 => 'AZ + GS',
5 => 'AZ o. FP',
];
public static $refund_types = [
0 => '-',
1 => 'eingereicht',
2 => 'erledigt',
];
public static $xx_tkt_types = [
0 => '-',
1 => 'offen',
2 => 'erledigt',
];
public static $paying_out_status_types = [
0 => '-',
1 => 'offen',
2 => 'erledigt',
];
protected $paying_out_colors = [
0 => '',
1 => 'info',
2 => 'dark',
3 => 'warning',
4 => 'warning',
5 => 'warning',
];
protected $refund_colors = [
0 => '',
1 => 'warning',
2 => 'success',
];
protected $xx_tkt_colors = [
0 => '',
1 => 'danger',
2 => 'success',
];
protected $paying_out_status_colors = [
0 => '',
1 => 'danger',
2 => 'success',
];
/*public function branch()
{
return $this->belongsTo(Branch::class);
@ -297,6 +362,17 @@ class Booking extends Model
{
return $this->hasMany(ServiceProviderEntry::class);
}
public function customer_mails()
{
return $this->hasMany(CustomerMail::class, 'booking_id', 'id');
}
public function customer_mails_sent_at()
{
return $this->hasMany(CustomerMail::class, 'booking_id')->orderBy('sent_at', 'ASC');
}
/*
public function travel_insurances()
{
@ -437,4 +513,57 @@ class Booking extends Model
return $this->ev_number;
}
public function getPayingOutType(){
return isset(self::$paying_out_types[$this->paying_out]) ? self::$paying_out_types[$this->paying_out] : '-';
}
public function getPayingOutStatusType(){
return isset(self::$paying_out_status_types[$this->paying_out_status]) ? self::$paying_out_status_types[$this->paying_out_status] : '-';
}
public function getRefundType(){
return isset(self::$refund_types[$this->refund]) ? self::$refund_types[$this->refund] : '-';
}
public function getXxTktType(){
return isset(self::$xx_tkt_types[$this->xx_tkt]) ? self::$xx_tkt_types[$this->xx_tkt] : '-';
}
public function getXxTktTypeList(){
if(isset(self::$xx_tkt_types[$this->xx_tkt])){
if($this->xx_tkt == 1 && $this->xx_tkt_date){
return Carbon::parse($this->xx_tkt_date)->format('d.m.Y');
}
return self::$xx_tkt_types[$this->xx_tkt];
}
return "-";
}
public function getRefundTypeList(){
if(isset(self::$refund_types[$this->refund])){
if($this->refund == 1 && $this->refund_date){
return Carbon::parse($this->refund_date)->format('d.m.Y');
}
return self::$refund_types[$this->refund];
}
return "-";
}
public function getPayingOutColor(){
return isset($this->paying_out_colors[$this->paying_out]) ? $this->paying_out_colors[$this->paying_out] : '';
}
public function getPayingOutStatusColor(){
return isset($this->paying_out_status_colors[$this->paying_out_status]) ? $this->paying_out_status_colors[$this->paying_out_status] : '';
}
public function getRefundColor(){
return isset($this->refund_colors[$this->refund]) ? $this->refund_colors[$this->refund] : '-';
}
public function getXxTktColor(){
return isset($this->xx_tkt_colors[$this->xx_tkt]) ? $this->xx_tkt_colors[$this->xx_tkt] : '-';
}
}

View file

@ -72,7 +72,8 @@ class Coupon extends Model
'issue_date',
'valid_date',
'is_redeemed',
'redeem_date'
'redeem_date',
'text'
];
public function booking()

106
app/Models/CustomerFile.php Normal file
View file

@ -0,0 +1,106 @@
<?php
/**
* Created by Reliese Model.
*/
namespace App\Models;
use Carbon\Carbon;
use Reliese\Database\Eloquent\Model;
/**
* Class CustomerFile
*
* @property int $id
* @property int $customer_id
* @property int $customer_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 Customer $customer
* @property CustomerMail $customer_mail
*
* @package App\Models
*/
class CustomerFile extends Model
{
protected $connection = 'mysql';
protected $table = 'customer_files';
protected $casts = [
'customer_id' => 'int',
'customer_mail_id' => 'int',
'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',
'identifier',
'filename',
'dir',
'original_name',
'ext',
'mine',
'size'
];
public function customer()
{
return $this->belongsTo(Customer::class);
}
public function customer_mail()
{
return $this->belongsTo(CustomerMail::class);
}
public function user()
{
return $this->belongsTo(User::class);
}
public function getIconExt(){
return isset(self::$icon_ext[$this->ext]) ? self::$icon_ext[$this->ext] : self::$icon_ext['default'];
}
public function getURL(){
return route('storage_file', [$this->id, 'customer']);
}
public function getPath(){
return \Storage::disk('customer')->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;
}
}
}

View file

@ -7,15 +7,19 @@
namespace App\Models;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Collection;
use Reliese\Database\Eloquent\Model;
/**
* Class CustomerMail
*
*
* @property int $id
* @property int $booking_id
* @property int $customer_id
* @property int $lead_id
* @property bool $is_answer
* @property int $reply_id
* @property string $email
* @property string $subject
* @property string $message
* @property bool $send
@ -26,28 +30,15 @@ use Reliese\Database\Eloquent\Model;
* @property Carbon $delivered_at
* @property Carbon $created_at
* @property Carbon $updated_at
*
* @property Booking $booking
* @property Customer $customer
* @property CustomerMail $customer_mail
* @property Lead $lead
* @property Collection|CustomerFile[] $customer_files
* @property Collection|CustomerMail[] $customer_mails
*
* @package App\Models
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerMail newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerMail newQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerMail query()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerMail whereBookingId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerMail whereCreatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerMail whereCustomerId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerMail whereDeliveredAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerMail whereError($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerMail whereFail($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerMail whereId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerMail whereLeadId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerMail whereMessage($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerMail whereScheduledAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerMail whereSend($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerMail whereSentAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerMail whereSubject($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CustomerMail whereUpdatedAt($value)
* @mixin \Eloquent
*/
class CustomerMail extends Model
{
@ -57,6 +48,8 @@ class CustomerMail extends Model
'booking_id' => 'int',
'customer_id' => 'int',
'lead_id' => 'int',
'is_answer' => 'bool',
'reply_id' => 'int',
'send' => 'bool',
'fail' => 'bool'
];
@ -71,7 +64,9 @@ class CustomerMail extends Model
'booking_id',
'customer_id',
'lead_id',
'email',
'is_answer',
'reply_id',
'email',
'subject',
'message',
'send',
@ -92,11 +87,27 @@ class CustomerMail extends Model
return $this->belongsTo(Customer::class);
}
public function customer_mail()
{
return $this->belongsTo(CustomerMail::class, 'reply_id');
}
public function lead()
{
return $this->belongsTo(Lead::class);
}
public function customer_files()
{
return $this->hasMany(CustomerFile::class);
}
public function customer_mails()
{
return $this->hasMany(CustomerMail::class, 'reply_id');
}
public function getSentAtAttribute(){
if(!$this->attributes['sent_at']){ return ""; }
return Carbon::parse($this->attributes['sent_at'])->format(\Util::formatDateTimeDB());

View file

@ -105,7 +105,8 @@ class Lead extends Model
'travelagenda_id' => 'int',
'sf_guard_user_id' => 'int',
'is_closed' => 'bool',
'initialcontacttype_id' => 'int',
'is_rebook' => 'bool',
'initialcontacttype_id' => 'int',
'searchengine_id' => 'int',
'status_id' => 'int',
'website_id' => 'int',
@ -134,6 +135,7 @@ class Lead extends Model
'remarks',
'sf_guard_user_id',
'is_closed',
'is_rebook',
'initialcontacttype_id',
'searchengine_id',
'searchengine_keywords',

View file

@ -1,25 +1,26 @@
<?php
/**
* Created by Reliese Model.
*/
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Collection;
use Reliese\Database\Eloquent\Model;
/**
* App\Models\Status
*
* Class Status
*
* @property int $id
* @property string $name
* @property int $handling_days
* @property string|null $color
* @property-read \App\Models\Status $status
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Status whereColor($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Status whereHandlingDays($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Status whereId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Status whereName($value)
* @mixin \Eloquent
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Status newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Status newQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Status query()
* @property string $color
*
* @property Collection|Lead[] $leads
* @property Collection|StatusHistory[] $status_histories
*
* @package App\Models
*/
class Status extends Model
{
@ -27,8 +28,25 @@ class Status extends Model
protected $table = 'status';
public function status()
{
return $this->belongsTo('App\Models\Status', 'status_id', 'id');
}
public $timestamps = false;
protected $casts = [
'handling_days' => 'int'
];
protected $fillable = [
'name',
'handling_days',
'color'
];
public function leads()
{
return $this->hasMany(Lead::class);
}
/*public function status_histories()
{
return $this->hasMany(StatusHistory::class);
}*/
}