1
0
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:
Hillel Coren 2016-12-05 00:35:08 +02:00
parent a0481310a3
commit ad07599e92
4 changed files with 26 additions and 4 deletions

View File

@ -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;

View File

@ -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

View File

@ -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();
}

View File

@ -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' }};