From eaf73077b15e2e466b99697be6ea0dec4b753600 Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Mon, 16 Nov 2015 21:21:48 +0200 Subject: [PATCH] Bug fixes --- app/Models/Invoice.php | 1 + app/Models/OwnedByClientTrait.php | 13 +++++++++++++ resources/views/invoices/edit.blade.php | 22 +++++++++++----------- 3 files changed, 25 insertions(+), 11 deletions(-) create mode 100644 app/Models/OwnedByClientTrait.php diff --git a/app/Models/Invoice.php b/app/Models/Invoice.php index 2655611b8f50..a49f2636fc46 100644 --- a/app/Models/Invoice.php +++ b/app/Models/Invoice.php @@ -15,6 +15,7 @@ use App\Events\QuoteInvitationWasEmailed; class Invoice extends EntityModel implements BalanceAffecting { use PresentableTrait; + use OwnedByClientTrait; use SoftDeletes { SoftDeletes::trashed as parentTrashed; } diff --git a/app/Models/OwnedByClientTrait.php b/app/Models/OwnedByClientTrait.php new file mode 100644 index 000000000000..7f11448324b9 --- /dev/null +++ b/app/Models/OwnedByClientTrait.php @@ -0,0 +1,13 @@ +client) { + return false; + } + + return $this->client->trashed(); + } +} \ No newline at end of file diff --git a/resources/views/invoices/edit.blade.php b/resources/views/invoices/edit.blade.php index e48c42c11b01..7666952780bd 100644 --- a/resources/views/invoices/edit.blade.php +++ b/resources/views/invoices/edit.blade.php @@ -392,19 +392,18 @@ {!! Button::primary(trans('texts.download_pdf'))->withAttributes(array('onclick' => 'onDownloadClick()'))->appendIcon(Icon::create('download-alt')) !!} - @if (!$invoice->trashed()) - + @if ($invoice->isClientTrashed()) + + @elseif ($invoice->trashed()) + {!! Button::success(trans('texts.restore'))->withAttributes(['onclick' => 'submitBulkAction("restore")'])->appendIcon(Icon::create('cloud-download')) !!} + @elseif (!$invoice->trashed()) {!! Button::success(trans("texts.save_{$entityType}"))->withAttributes(array('id' => 'saveButton', 'onclick' => 'onSaveClick()'))->appendIcon(Icon::create('floppy-disk')) !!} {!! Button::info(trans("texts.email_{$entityType}"))->withAttributes(array('id' => 'emailButton', 'onclick' => 'onEmailClick()'))->appendIcon(Icon::create('send')) !!} - @if ($invoice->id) {!! DropdownButton::normal(trans('texts.more_actions')) ->withContents($actions) ->dropup() !!} @endif - - @elseif ($invoice->trashed()) - {!! Button::success(trans('texts.restore'))->withAttributes(['onclick' => 'submitBulkAction("restore")'])->appendIcon(Icon::create('cloud-download')) !!} @endif @@ -1007,16 +1006,17 @@ } function isEmailValid() { - var isValid = false; + var isValid = true; var sendTo = false; var client = model.invoice().client(); for (var i=0; i