From 62d31999ed13a65145f3f388a45e68e56c9ec69b Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Sat, 14 Oct 2017 20:55:37 +0300 Subject: [PATCH] Add notes in datatables --- app/Ninja/Datatables/ClientDatatable.php | 3 ++- app/Ninja/Datatables/EntityDatatable.php | 8 ++++++++ app/Ninja/Datatables/ExpenseDatatable.php | 3 ++- app/Ninja/Datatables/InvoiceDatatable.php | 3 ++- app/Ninja/Datatables/PaymentDatatable.php | 3 ++- .../Datatables/RecurringExpenseDatatable.php | 19 ++++++++++--------- app/Ninja/Datatables/VendorDatatable.php | 3 ++- app/Ninja/Repositories/ClientRepository.php | 1 + app/Ninja/Repositories/ExpenseRepository.php | 1 + app/Ninja/Repositories/InvoiceRepository.php | 3 ++- app/Ninja/Repositories/PaymentRepository.php | 1 + .../RecurringExpenseRepository.php | 1 + app/Ninja/Repositories/VendorRepository.php | 3 ++- resources/views/list.blade.php | 1 + 14 files changed, 37 insertions(+), 16 deletions(-) diff --git a/app/Ninja/Datatables/ClientDatatable.php b/app/Ninja/Datatables/ClientDatatable.php index ad20e15bc6..b74eb5fc08 100644 --- a/app/Ninja/Datatables/ClientDatatable.php +++ b/app/Ninja/Datatables/ClientDatatable.php @@ -17,7 +17,8 @@ class ClientDatatable extends EntityDatatable [ 'name', function ($model) { - return link_to("clients/{$model->public_id}", $model->name ?: '')->toHtml(); + $str = link_to("clients/{$model->public_id}", $model->name ?: '')->toHtml(); + return $this->addNote($str, $model->private_notes); }, ], [ diff --git a/app/Ninja/Datatables/EntityDatatable.php b/app/Ninja/Datatables/EntityDatatable.php index 008b1f877d..02fd808457 100644 --- a/app/Ninja/Datatables/EntityDatatable.php +++ b/app/Ninja/Datatables/EntityDatatable.php @@ -90,4 +90,12 @@ class EntityDatatable return $indices; } + + public function addNote($str, $note) { + if (! $note) { + return $str; + } + + return $str . '  '; + } } diff --git a/app/Ninja/Datatables/ExpenseDatatable.php b/app/Ninja/Datatables/ExpenseDatatable.php index c3c344e920..620366c21c 100644 --- a/app/Ninja/Datatables/ExpenseDatatable.php +++ b/app/Ninja/Datatables/ExpenseDatatable.php @@ -52,7 +52,8 @@ class ExpenseDatatable extends EntityDatatable return Utils::fromSqlDate($model->expense_date_sql); } - return link_to("expenses/{$model->public_id}/edit", Utils::fromSqlDate($model->expense_date_sql))->toHtml(); + $str = link_to("expenses/{$model->public_id}/edit", Utils::fromSqlDate($model->expense_date_sql))->toHtml(); + return $this->addNote($str, $model->private_notes); }, ], [ diff --git a/app/Ninja/Datatables/InvoiceDatatable.php b/app/Ninja/Datatables/InvoiceDatatable.php index 9e98b18d38..0f5cf80470 100644 --- a/app/Ninja/Datatables/InvoiceDatatable.php +++ b/app/Ninja/Datatables/InvoiceDatatable.php @@ -24,7 +24,8 @@ class InvoiceDatatable extends EntityDatatable return $model->invoice_number; } - return link_to("{$entityType}s/{$model->public_id}/edit", $model->invoice_number, ['class' => Utils::getEntityRowClass($model)])->toHtml(); + $str = link_to("{$entityType}s/{$model->public_id}/edit", $model->invoice_number, ['class' => Utils::getEntityRowClass($model)])->toHtml(); + return $this->addNote($str, $model->private_notes); }, ], [ diff --git a/app/Ninja/Datatables/PaymentDatatable.php b/app/Ninja/Datatables/PaymentDatatable.php index 17d2605359..435b610f92 100644 --- a/app/Ninja/Datatables/PaymentDatatable.php +++ b/app/Ninja/Datatables/PaymentDatatable.php @@ -46,7 +46,8 @@ class PaymentDatatable extends EntityDatatable [ 'transaction_reference', function ($model) { - return $model->transaction_reference ? e($model->transaction_reference) : ''.trans('texts.manual_entry').''; + $str = $model->transaction_reference ? e($model->transaction_reference) : ''.trans('texts.manual_entry').''; + return $this->addNote($str, $model->private_notes); }, ], [ diff --git a/app/Ninja/Datatables/RecurringExpenseDatatable.php b/app/Ninja/Datatables/RecurringExpenseDatatable.php index 4ecafef474..e8a1311595 100644 --- a/app/Ninja/Datatables/RecurringExpenseDatatable.php +++ b/app/Ninja/Datatables/RecurringExpenseDatatable.php @@ -57,6 +57,16 @@ class RecurringExpenseDatatable extends EntityDatatable }, ], */ + [ + 'frequency', + function ($model) { + $frequency = strtolower($model->frequency); + $frequency = preg_replace('/\s/', '_', $frequency); + + $str = link_to("recurring_expenses/{$model->public_id}/edit", trans('texts.freq_'.$frequency))->toHtml(); + return $this->addNote($str, $model->private_notes); + }, + ], [ 'amount', function ($model) { @@ -91,15 +101,6 @@ class RecurringExpenseDatatable extends EntityDatatable return $model->public_notes != null ? substr($model->public_notes, 0, 100) : ''; }, ], - [ - 'frequency', - function ($model) { - $frequency = strtolower($model->frequency); - $frequency = preg_replace('/\s/', '_', $frequency); - - return link_to("recurring_expenses/{$model->public_id}/edit", trans('texts.freq_'.$frequency))->toHtml(); - }, - ], ]; } diff --git a/app/Ninja/Datatables/VendorDatatable.php b/app/Ninja/Datatables/VendorDatatable.php index 761d12ebcc..df5415df01 100644 --- a/app/Ninja/Datatables/VendorDatatable.php +++ b/app/Ninja/Datatables/VendorDatatable.php @@ -17,7 +17,8 @@ class VendorDatatable extends EntityDatatable [ 'name', function ($model) { - return link_to("vendors/{$model->public_id}", $model->name ?: '')->toHtml(); + $str = link_to("vendors/{$model->public_id}", $model->name ?: '')->toHtml(); + return $this->addNote($str, $model->private_notes); }, ], [ diff --git a/app/Ninja/Repositories/ClientRepository.php b/app/Ninja/Repositories/ClientRepository.php index 8ee2e5a903..316bc89845 100644 --- a/app/Ninja/Repositories/ClientRepository.php +++ b/app/Ninja/Repositories/ClientRepository.php @@ -41,6 +41,7 @@ class ClientRepository extends BaseRepository DB::raw("CONCAT(contacts.first_name, ' ', contacts.last_name) contact"), 'clients.public_id', 'clients.name', + 'clients.private_notes', 'contacts.first_name', 'contacts.last_name', 'clients.balance', diff --git a/app/Ninja/Repositories/ExpenseRepository.php b/app/Ninja/Repositories/ExpenseRepository.php index 867c0af936..dfda1ee70a 100644 --- a/app/Ninja/Repositories/ExpenseRepository.php +++ b/app/Ninja/Repositories/ExpenseRepository.php @@ -81,6 +81,7 @@ class ExpenseRepository extends BaseRepository 'expenses.user_id', 'expenses.tax_rate1', 'expenses.tax_rate2', + 'expenses.private_notes', 'expenses.payment_date', 'expense_categories.name as category', 'expense_categories.user_id as category_user_id', diff --git a/app/Ninja/Repositories/InvoiceRepository.php b/app/Ninja/Repositories/InvoiceRepository.php index 79b618df91..608f9e32b1 100644 --- a/app/Ninja/Repositories/InvoiceRepository.php +++ b/app/Ninja/Repositories/InvoiceRepository.php @@ -89,7 +89,8 @@ class InvoiceRepository extends BaseRepository 'invoices.partial', 'invoices.user_id', 'invoices.is_public', - 'invoices.is_recurring' + 'invoices.is_recurring', + 'invoices.private_notes' ); $this->applyFilters($query, $entityType, ENTITY_INVOICE); diff --git a/app/Ninja/Repositories/PaymentRepository.php b/app/Ninja/Repositories/PaymentRepository.php index 34d6555c89..1cb48cb648 100644 --- a/app/Ninja/Repositories/PaymentRepository.php +++ b/app/Ninja/Repositories/PaymentRepository.php @@ -63,6 +63,7 @@ class PaymentRepository extends BaseRepository 'payments.email', 'payments.routing_number', 'payments.bank_name', + 'payments.private_notes', 'invoices.is_deleted as invoice_is_deleted', 'gateways.name as gateway_name', 'gateways.id as gateway_id', diff --git a/app/Ninja/Repositories/RecurringExpenseRepository.php b/app/Ninja/Repositories/RecurringExpenseRepository.php index 9eb121ed2a..3b5050dfb6 100644 --- a/app/Ninja/Repositories/RecurringExpenseRepository.php +++ b/app/Ninja/Repositories/RecurringExpenseRepository.php @@ -60,6 +60,7 @@ class RecurringExpenseRepository extends BaseRepository 'recurring_expenses.user_id', 'recurring_expenses.tax_rate1', 'recurring_expenses.tax_rate2', + 'recurring_expenses.private_notes', 'frequencies.name as frequency', 'expense_categories.name as category', 'expense_categories.user_id as category_user_id', diff --git a/app/Ninja/Repositories/VendorRepository.php b/app/Ninja/Repositories/VendorRepository.php index 765e9b9f3c..fe44f61ea0 100644 --- a/app/Ninja/Repositories/VendorRepository.php +++ b/app/Ninja/Repositories/VendorRepository.php @@ -44,7 +44,8 @@ class VendorRepository extends BaseRepository 'vendor_contacts.email', 'vendors.deleted_at', 'vendors.is_deleted', - 'vendors.user_id' + 'vendors.user_id', + 'vendors.private_notes' ); $this->applyFilters($query, ENTITY_VENDOR); diff --git a/resources/views/list.blade.php b/resources/views/list.blade.php index 6fc863e2b2..30d6fff9a2 100644 --- a/resources/views/list.blade.php +++ b/resources/views/list.blade.php @@ -210,6 +210,7 @@ }); actionListHandler(); + $('[data-toggle="tooltip"]').tooltip(); } $('.listForm_{{ $entityType }} .archive, .invoice').prop('disabled', true);