Edit / PDF / Mail / ->Leads
This commit is contained in:
parent
5d55e5be3f
commit
66ca252bfa
43 changed files with 2915 additions and 76 deletions
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Models\Lead as ModelsLead;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
|
@ -157,9 +158,12 @@ class Lead extends Model
|
|||
|
||||
if(!$date){
|
||||
$carbon = Carbon::now();
|
||||
$this->next_due_date = $carbon->modify('+ '.$this->status->handling_days.' days')->format("Y-m-d");
|
||||
$this->save();
|
||||
}
|
||||
}else{
|
||||
$carbon = Carbon::parse($date);
|
||||
}
|
||||
$this->next_due_date = $carbon->modify('+ '.$this->status->handling_days.' days')->format("Y-m-d");
|
||||
$this->save();
|
||||
|
||||
}
|
||||
public function customer()
|
||||
{
|
||||
|
|
@ -242,6 +246,83 @@ class Lead extends Model
|
|||
|
||||
public function status_histories()
|
||||
{
|
||||
return $this->hasMany(StatusHistory::class);
|
||||
return $this->hasMany(StatusHistory::class)->orderByDesc('id')->orderByDesc('date');
|
||||
}
|
||||
|
||||
public function lead_files()
|
||||
{
|
||||
//no lead_mail_id
|
||||
return $this->hasMany(LeadFile::class, 'lead_id')->where('lead_mail_id', null);
|
||||
}
|
||||
|
||||
public function lead_mails()
|
||||
{
|
||||
return $this->hasMany(LeadMail::class, 'lead_id', 'id');
|
||||
}
|
||||
|
||||
public function lead_mails_sent_at()
|
||||
{
|
||||
return $this->hasMany(LeadMail::class, 'lead_id')->orderBy('sent_at', 'ASC');
|
||||
}
|
||||
|
||||
public function lead_mail_last()
|
||||
{
|
||||
return $this->hasOne(LeadMail::class, 'lead_id')->latest();
|
||||
}
|
||||
|
||||
public function lead_notices()
|
||||
{
|
||||
return $this->hasMany(LeadNotice::class, 'lead_id')->orderBy('created_at', 'DESC');
|
||||
}
|
||||
|
||||
|
||||
public static function getSfGuardUserArray(){
|
||||
return SfGuardUser::where('is_active', 1)->get()->pluck('fullname', 'id');
|
||||
}
|
||||
|
||||
public static function getTravelCountryArray($emtpy = false){
|
||||
$TravelCountry = TravelCountry::where('active_backend', 1)->orderBy('name')->get()->pluck('name', 'id');
|
||||
return $emtpy ? $TravelCountry->prepend('-', 0) : $TravelCountry;
|
||||
|
||||
}
|
||||
|
||||
public static function getTravelCategoryArray($emtpy = false){
|
||||
$TravelCategory = TravelCategory::orderBy('name')->get()->pluck('name', 'id');
|
||||
return $emtpy ? $TravelCategory->prepend('-', 0) : $TravelCategory;
|
||||
|
||||
}
|
||||
|
||||
public static function getTravelAgendaArray($emtpy = false){
|
||||
$TravelAgenda = TravelAgenda::orderBy('name')->get()->pluck('name', 'id');
|
||||
return $emtpy ? $TravelAgenda->prepend('-', 0) : $TravelAgenda;
|
||||
}
|
||||
|
||||
public static function getStatusArray($emtpy = false){
|
||||
$Status = Status::orderBy('name')->get()->pluck('name', 'id');
|
||||
return $emtpy ? $Status->prepend('-', 0) : $Status;
|
||||
}
|
||||
|
||||
|
||||
public function getStatusBadge($booking = null)
|
||||
{
|
||||
if($this->status_id && $this->status){
|
||||
$color = $this->status->color;
|
||||
$icon = "";
|
||||
if($this->status_id == 14 && $this->is_rebook){
|
||||
$color = '#94ae59';
|
||||
$icon = '<i class="fa fa-check-circle"></i> ';
|
||||
}
|
||||
if($this->status_id == 14 && !$this->is_rebook){
|
||||
$icon = '<i class="fa fa-times-circle"></i> ';
|
||||
}
|
||||
if($this->status_id == 15){
|
||||
$icon = '<i class="fa fa-balance-scale"></i> ';
|
||||
if($booking && $booking->lawyer_date){
|
||||
return '<span data-order="'.$this->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="'.$this->status_id.'"><span class="badge badge-dark" style="background-color: '.$color.'">'.$icon.$this->status->name.'</span></span>';
|
||||
}
|
||||
return '<span data-order="0">-</span>';
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue