From 6d32c6c155d5cd9b84e34fc957db163c90b63d75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Denis=20Duli=C3=A7i?= Date: Tue, 6 Sep 2022 00:02:56 +0300 Subject: [PATCH] changed order #2616 #3g3rnd2 --- app/Models/Document/Document.php | 69 +++++++++++++++----------------- 1 file changed, 33 insertions(+), 36 deletions(-) diff --git a/app/Models/Document/Document.php b/app/Models/Document/Document.php index 17c16589d..a9851089a 100644 --- a/app/Models/Document/Document.php +++ b/app/Models/Document/Document.php @@ -488,18 +488,6 @@ class Document extends Model return $actions; } - try { - $actions[] = [ - 'title' => trans('general.show'), - 'icon' => 'visibility', - 'url' => route($prefix . '.show', $this->id), - 'permission' => 'read-' . $group . '-' . $permission_prefix, - 'attributes' => [ - 'id' => 'index-more-actions-show-' . $this->id, - ], - ]; - } catch (\Exception $e) {} - try { if (! $this->reconciled) { $actions[] = [ @@ -526,7 +514,36 @@ class Document extends Model ]; } catch (\Exception $e) {} - if ($this->status != 'cancelled') { + if ((empty($this->transactions->count()) || (! empty($this->transactions->count()) && $this->paid != $this->amount))) { + try { + $actions[] = [ + 'type' => 'button', + 'title' => trans('invoices.add_payment'), + 'icon' => 'request_quote', + 'url' => route('modals.documents.document.transactions.create', $this->id), + 'permission' => 'read-' . $group . '-' . $permission_prefix, + 'attributes' => [ + 'id' => 'index-more-actions-payment-' . $this->id, + '@click' => 'onPayment("' . $this->id . '")', + ], + ]; + } catch (\Exception $e) {} + } else { + try { + $actions[] = [ + 'title' => trans('general.print'), + 'icon' => 'print', + 'url' => route($prefix . '.print', $this->id), + 'permission' => 'read-' . $group . '-' . $permission_prefix, + 'attributes' => [ + 'id' => 'index-more-actions-print-' . $this->id, + 'target' => '_blank', + ], + ]; + } catch (\Exception $e) {} + } + + if (($actions[1]['icon'] != 'print') && ($actions[2]['icon'] != 'print')) { try { $actions[] = [ 'title' => trans('general.print'), @@ -575,7 +592,7 @@ class Document extends Model } catch (\Exception $e) {} try { - if (! empty($this->contact) && $this->contact->email && $this->type == 'invoice') { + if (! empty($this->contact) && $this->contact->email && ($this->type == 'invoice')) { $actions[] = [ 'type' => 'button', 'title' => trans('invoices.send_mail'), @@ -583,8 +600,8 @@ class Document extends Model 'url' => route('modals.'. $prefix . '.emails.create', $this->id), 'permission' => 'read-' . $group . '-' . $permission_prefix, 'attributes' => [ - 'id' => 'index-more-actions-send-email-' . $this->id, - '@click' => 'onEmail("' . route('modals.'. $prefix . '.emails.create', $this->id) . '")', + 'id' => 'index-more-actions-send-email-' . $this->id, + '@click' => 'onEmail("' . route('modals.'. $prefix . '.emails.create', $this->id) . '")', ], ]; } @@ -595,26 +612,6 @@ class Document extends Model 'type' => 'divider', ]; - if ((empty($this->transactions->count()) || (! empty($this->transactions->count()) && $this->paid != $this->amount))) { - try { - $actions[] = [ - 'type' => 'button', - 'title' => trans('invoices.add_payment'), - 'icon' => 'payments', - 'url' => route('modals.documents.document.transactions.create', $this->id), - 'permission' => 'read-' . $group . '-' . $permission_prefix, - 'attributes' => [ - 'id' => 'index-more-actions-payment-' . $this->id, - '@click' => 'onPayment("' . $this->id . '")', - ], - ]; - } catch (\Exception $e) {} - - $actions[] = [ - 'type' => 'divider', - ]; - } - if ($this->status != 'cancelled') { try { $actions[] = [