2020-02-11 21:57:25 +01:00
|
|
|
<?php
|
|
|
|
namespace App\Services\Quote;
|
|
|
|
|
|
|
|
use App\Models\Quote;
|
|
|
|
|
|
|
|
class QuoteService
|
|
|
|
{
|
|
|
|
protected $quote;
|
|
|
|
|
|
|
|
public function __construct($quote)
|
|
|
|
{
|
|
|
|
$this->quote = $quote;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function createInvitations()
|
|
|
|
{
|
|
|
|
$create_invitation = new CreateInvitations();
|
|
|
|
|
2020-02-14 04:32:22 +01:00
|
|
|
$this->quote = $create_invitation->run($this->quote);
|
2020-02-11 21:57:25 +01:00
|
|
|
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function markApproved()
|
|
|
|
{
|
|
|
|
$mark_approved = new MarkApproved($this->quote->client);
|
|
|
|
|
2020-02-14 04:32:22 +01:00
|
|
|
$this->quote = $mark_approved->run($this->quote);
|
2020-02-11 21:57:25 +01:00
|
|
|
|
|
|
|
if($this->quote->client->getSetting('auto_convert_quote') === true) {
|
|
|
|
$convert_quote = new ConvertQuote($this->quote->client);
|
2020-02-14 04:32:22 +01:00
|
|
|
$this->quote = $convert_quote->run($this->quote);
|
2020-02-11 21:57:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2020-02-15 10:01:15 +01:00
|
|
|
public function getQuotePdf($contact)
|
|
|
|
{
|
|
|
|
$get_invoice_pdf = new GetQuotePdf();
|
|
|
|
|
|
|
|
return $get_invoice_pdf($this->quote, $contact);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function sendEmail($contact)
|
|
|
|
{
|
|
|
|
$send_email = new SendEmail($this->quote);
|
|
|
|
|
|
|
|
return $send_email->run(null, $contact);
|
|
|
|
}
|
|
|
|
|
2020-02-11 21:57:25 +01:00
|
|
|
/**
|
|
|
|
* Applies the invoice number
|
|
|
|
* @return $this InvoiceService object
|
|
|
|
*/
|
|
|
|
public function applyNumber()
|
|
|
|
{
|
|
|
|
$apply_number = new ApplyNumber($this->quote->client);
|
|
|
|
|
2020-02-14 04:32:22 +01:00
|
|
|
$this->quote = $apply_number->run($this->quote);
|
2020-02-11 21:57:25 +01:00
|
|
|
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function markSent()
|
|
|
|
{
|
|
|
|
$mark_sent = new MarkSent($this->quote->client);
|
|
|
|
|
2020-02-14 04:32:22 +01:00
|
|
|
$this->quote = $mark_sent->run($this->quote);
|
2020-02-11 21:57:25 +01:00
|
|
|
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setStatus($status)
|
|
|
|
{
|
|
|
|
$this->quote->status_id = $status;
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Saves the quote
|
|
|
|
* @return Quote|null
|
|
|
|
*/
|
|
|
|
public function save() : ?Quote
|
|
|
|
{
|
|
|
|
$this->quote->save();
|
|
|
|
return $this->quote;
|
|
|
|
}
|
|
|
|
}
|