diff --git a/app/controllers/InvoiceController.php b/app/controllers/InvoiceController.php index 0d3742e1a833..da4b361d1be8 100755 --- a/app/controllers/InvoiceController.php +++ b/app/controllers/InvoiceController.php @@ -64,7 +64,12 @@ class InvoiceController extends \BaseController { //$accountId = Auth::user()->account_id; $search = Input::get('sSearch'); $invitationKey = Session::get('invitation_key'); - $invitation = Invitation::where('invitation_key', '=', $invitationKey)->firstOrFail(); + $invitation = Invitation::where('invitation_key', '=', $invitationKey)->first(); + + if (!$invitation || $invitation->is_deleted) + { + return []; + } $invoice = $invitation->invoice; diff --git a/app/controllers/PaymentController.php b/app/controllers/PaymentController.php index c59aa61d79b6..21d16340f80b 100755 --- a/app/controllers/PaymentController.php +++ b/app/controllers/PaymentController.php @@ -77,7 +77,12 @@ class PaymentController extends \BaseController { $search = Input::get('sSearch'); $invitationKey = Session::get('invitation_key'); - $invitation = Invitation::where('invitation_key', '=', $invitationKey)->with('contact.client')->firstOrFail(); + $invitation = Invitation::where('invitation_key', '=', $invitationKey)->with('contact.client')->first(); + + if (!$invitation) + { + return []; + } $invoice = $invitation->invoice; @@ -86,10 +91,10 @@ class PaymentController extends \BaseController return []; } - $payments = $this->paymentRepo->find($invitation->contact->client->public_id, Input::get('sSearch')); + $payments = $this->paymentRepo->findForContact($invitation->contact->id, Input::get('sSearch')); return Datatable::query($payments) - ->addColumn('invoice_number', function($model) { return $model->invoice_number; }) + ->addColumn('invoice_number', function($model) { return $model->invitation_key ? link_to('/view/' . $model->invitation_key, $model->invoice_number) : $model->invoice_number; }) ->addColumn('transaction_reference', function($model) { return $model->transaction_reference ? $model->transaction_reference : 'Manual entry'; }) ->addColumn('payment_type', function($model) { return $model->payment_type ? $model->payment_type : ($model->account_gateway_id ? 'Online payment' : ''); }) ->addColumn('amount', function($model) { return Utils::formatMoney($model->amount, $model->currency_id); }) diff --git a/app/controllers/QuoteController.php b/app/controllers/QuoteController.php index 66e8d1f1830e..e7634429db17 100644 --- a/app/controllers/QuoteController.php +++ b/app/controllers/QuoteController.php @@ -72,7 +72,12 @@ class QuoteController extends \BaseController { { $search = Input::get('sSearch'); $invitationKey = Session::get('invitation_key'); - $invitation = Invitation::where('invitation_key', '=', $invitationKey)->firstOrFail(); + $invitation = Invitation::where('invitation_key', '=', $invitationKey)->first(); + + if (!$invitation || $invitation->is_deleted) + { + return []; + } $invoice = $invitation->invoice; diff --git a/app/ninja/repositories/PaymentRepository.php b/app/ninja/repositories/PaymentRepository.php index 31126b13c868..39563106ade8 100755 --- a/app/ninja/repositories/PaymentRepository.php +++ b/app/ninja/repositories/PaymentRepository.php @@ -8,8 +8,8 @@ use Utils; class PaymentRepository { - public function find($clientPublicId = null, $filter = null) - { + public function find($clientPublicId = null, $filter = null) + { $query = \DB::table('payments') ->join('clients', 'clients.id', '=','payments.client_id') ->join('invoices', 'invoices.id', '=','payments.invoice_id') @@ -39,7 +39,37 @@ class PaymentRepository } return $query; - } + } + + public function findForContact($contactId = null, $filter = null) + { + $query = \DB::table('payments') + ->join('clients', 'clients.id', '=','payments.client_id') + ->join('invoices', 'invoices.id', '=','payments.invoice_id') + ->join('contacts', 'contacts.client_id', '=', 'clients.id') + ->leftJoin('invitations', function($join) + { + $join->on('invitations.invoice_id', '=', 'invoices.id') + ->on('invitations.contact_id', '=', 'contacts.id'); + }) + ->leftJoin('payment_types', 'payment_types.id', '=', 'payments.payment_type_id') + ->where('payments.account_id', '=', \Auth::user()->account_id) + ->where('clients.is_deleted', '=', false) + ->where('payments.is_deleted', '=', false) + ->where('invitations.deleted_at', '=', null) + ->where('contacts.id', '=', $contactId) + ->select('invitations.invitation_key', 'payments.public_id', 'payments.transaction_reference', 'clients.name as client_name', 'clients.public_id as client_public_id', 'payments.amount', 'payments.payment_date', 'invoices.public_id as invoice_public_id', 'invoices.invoice_number', 'clients.currency_id', 'contacts.first_name', 'contacts.last_name', 'contacts.email', 'payment_types.name as payment_type', 'payments.account_gateway_id'); + + if ($filter) + { + $query->where(function($query) use ($filter) + { + $query->where('clients.name', 'like', '%'.$filter.'%'); + }); + } + + return $query; + } public function getErrors($input) { diff --git a/app/routes.php b/app/routes.php index ad470fd641d9..f8b70dcb2777 100755 --- a/app/routes.php +++ b/app/routes.php @@ -1,5 +1,6 @@ id === 1) } */ - diff --git a/app/views/master.blade.php b/app/views/master.blade.php index ca92bcfde0e2..e04a38d9c7c6 100755 --- a/app/views/master.blade.php +++ b/app/views/master.blade.php @@ -45,6 +45,7 @@ /* Set the defaults for DataTables initialisation */ $.extend( true, $.fn.dataTable.defaults, { + "bSortClasses": false, "sDom": "t<'row-fluid'<'span6'i><'span6'p>>", "sPaginationType": "bootstrap", "bInfo": true, diff --git a/app/views/payments/payment.blade.php b/app/views/payments/payment.blade.php index a992a97f3920..98a04302b6e5 100755 --- a/app/views/payments/payment.blade.php +++ b/app/views/payments/payment.blade.php @@ -66,7 +66,7 @@
- {{ trans('texts.payment_title') }} + {{ otrans('texts.payment_title') }}
@@ -113,10 +113,10 @@
- {{ trans('texts.payment_footer1') }} + {{ otrans('texts.payment_footer1') }}
- {{ trans('texts.payment_footer2') }} + {{ otrans('texts.payment_footer2') }}
@@ -141,7 +141,7 @@
- {{ trans('texts.balance_due') . ' ' . Utils::formatMoney($amount, $currencyId) }} +  
@@ -189,7 +189,7 @@ {{ Former::text('cvv') }}
-
{{ trans('texts.payment_cvv') }}
+
{{ otrans('texts.payment_cvv') }}
diff --git a/app/views/public_list.blade.php b/app/views/public_list.blade.php index 3456eaafc4b6..16949de93513 100755 --- a/app/views/public_list.blade.php +++ b/app/views/public_list.blade.php @@ -1,7 +1,7 @@ @extends('public.header') @section('content') - + diff --git a/public/built.css b/public/built.css index aa31b5844d5a..d1892fa083b3 100644 --- a/public/built.css +++ b/public/built.css @@ -2882,8 +2882,9 @@ border-bottom: 1px solid #dfe0e1; table.dataTable.no-footer { border-bottom: none; } -.table-striped>tbody>tr:nth-child(odd)>td, .table-striped>tbody>tr:nth-child(odd)>th { -background-color: #fff; +.table-striped>tbody>tr:nth-child(odd)>td, +.table-striped>tbody>tr:nth-child(odd)>th { +background-color: #FDFDFD; } table.table thead .sorting_asc { background: url('css/../images/sort_asc.png') no-repeat 90% 50%; @@ -3117,12 +3118,6 @@ border-top-left-radius: 3px; /* hide table sorting indicators */ table.table thead .sorting { background: url('') no-repeat center right; } -table.dataTable tr.odd td.sorting_1 { background-color: white; } -table.dataTable tr.odd td.sorting_2 { background-color: white; } -table.dataTable tr.odd td.sorting_3 { background-color: white; } -table.dataTable tr.even td.sorting_1 { background-color: white; } -table.dataTable tr.even td.sorting_2 { background-color: white; } -table.dataTable tr.even td.sorting_3 { background-color: white; } diff --git a/public/css/style.css b/public/css/style.css index f5f8ff08fb3d..79f1cdc56a8a 100755 --- a/public/css/style.css +++ b/public/css/style.css @@ -82,8 +82,9 @@ border-bottom: 1px solid #dfe0e1; table.dataTable.no-footer { border-bottom: none; } -.table-striped>tbody>tr:nth-child(odd)>td, .table-striped>tbody>tr:nth-child(odd)>th { -background-color: #fff; +.table-striped>tbody>tr:nth-child(odd)>td, +.table-striped>tbody>tr:nth-child(odd)>th { +background-color: #FDFDFD; } table.table thead .sorting_asc { background: url('../images/sort_asc.png') no-repeat 90% 50%; @@ -317,12 +318,6 @@ border-top-left-radius: 3px; /* hide table sorting indicators */ table.table thead .sorting { background: url('') no-repeat center right; } -table.dataTable tr.odd td.sorting_1 { background-color: white; } -table.dataTable tr.odd td.sorting_2 { background-color: white; } -table.dataTable tr.odd td.sorting_3 { background-color: white; } -table.dataTable tr.even td.sorting_1 { background-color: white; } -table.dataTable tr.even td.sorting_2 { background-color: white; } -table.dataTable tr.even td.sorting_3 { background-color: white; }