mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-08 20:22:42 +01:00
Hide draft invoices from the client portal
This commit is contained in:
parent
a0481310a3
commit
ad07599e92
@ -98,7 +98,7 @@ class Invitation extends EntityModel
|
||||
$date = Utils::dateToString($this->$field);
|
||||
$hasValue = true;
|
||||
$parts[] = trans('texts.invitation_status_' . $status) . ': ' . $date;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $hasValue ? implode($parts, '<br/>') : false;
|
||||
@ -123,6 +123,11 @@ class Invitation extends EntityModel
|
||||
$this->save();
|
||||
}
|
||||
|
||||
public function isSent()
|
||||
{
|
||||
return $this->sent_date && $this->sent_date != '0000-00-00 00:00:00';
|
||||
}
|
||||
|
||||
public function markViewed()
|
||||
{
|
||||
$invoice = $this->invoice;
|
||||
|
@ -415,13 +415,30 @@ class Invoice extends EntityModel implements BalanceAffecting
|
||||
*/
|
||||
public function markInvitationsSent($notify = false)
|
||||
{
|
||||
$this->load('invitations');
|
||||
if ( ! $this->relationLoaded('invitations')) {
|
||||
$this->load('invitations');
|
||||
}
|
||||
|
||||
foreach ($this->invitations as $invitation) {
|
||||
$this->markInvitationSent($invitation, false, $notify);
|
||||
}
|
||||
}
|
||||
|
||||
public function areInvitationsSent()
|
||||
{
|
||||
if ( ! $this->relationLoaded('invitations')) {
|
||||
$this->load('invitations');
|
||||
}
|
||||
|
||||
foreach ($this->invitations as $invitation) {
|
||||
if ( ! $invitation->isSent()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $invitation
|
||||
* @param bool $messageId
|
||||
|
@ -79,7 +79,6 @@ class InvoiceService extends BaseService
|
||||
}
|
||||
}
|
||||
|
||||
$wasPublic = $invoice ? $invoice->is_public : false;
|
||||
$invoice = $this->invoiceRepo->save($data, $invoice);
|
||||
|
||||
$client = $invoice->client;
|
||||
@ -111,7 +110,7 @@ class InvoiceService extends BaseService
|
||||
}
|
||||
}
|
||||
|
||||
if ($invoice->is_public && ! $wasPublic) {
|
||||
if ($invoice->is_public && ! $invoice->areInvitationsSent()) {
|
||||
$invoice->markInvitationsSent();
|
||||
}
|
||||
|
||||
|
@ -1274,6 +1274,7 @@
|
||||
}
|
||||
|
||||
sweetConfirm(function() {
|
||||
model.invoice().is_public(true);
|
||||
var accountLanguageId = parseInt({{ $account->language_id ?: '0' }});
|
||||
var clientLanguageId = parseInt(model.invoice().client().language_id()) || 0;
|
||||
var attachPDF = {{ $account->attachPDF() ? 'true' : 'false' }};
|
||||
|
Loading…
Reference in New Issue
Block a user