From b55a3226b7ab803f4a725c16f5f59ef3f1fe93c0 Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Mon, 9 Nov 2015 21:24:22 +0200 Subject: [PATCH] Starting on stripejs --- app/Http/Controllers/ClientController.php | 7 +++++++ app/Models/Gateway.php | 5 +++++ app/Ninja/Repositories/NinjaRepository.php | 18 ++++++++++++++++++ app/Services/ClientService.php | 13 +++++++++---- resources/views/clients/edit.blade.php | 14 ++++++++++++++ resources/views/payments/payment.blade.php | 21 +++++++++++++++++---- 6 files changed, 70 insertions(+), 8 deletions(-) create mode 100644 app/Ninja/Repositories/NinjaRepository.php diff --git a/app/Http/Controllers/ClientController.php b/app/Http/Controllers/ClientController.php index c281798ecd7c..124d7bc574d1 100644 --- a/app/Http/Controllers/ClientController.php +++ b/app/Http/Controllers/ClientController.php @@ -13,6 +13,7 @@ use Cache; use App\Models\Activity; use App\Models\Client; +use App\Models\Account; use App\Models\Contact; use App\Models\Invoice; use App\Models\Size; @@ -154,6 +155,12 @@ class ClientController extends BaseController $data = array_merge($data, self::getViewModel()); + if (Auth::user()->account->isNinjaAccount()) { + if ($account = Account::whereId($client->public_id)->first()) { + $data['proPlanPaid'] = $account['pro_plan_paid']; + } + } + return View::make('clients.edit', $data); } diff --git a/app/Models/Gateway.php b/app/Models/Gateway.php index 166c5a4929d6..55fc2056f45c 100644 --- a/app/Models/Gateway.php +++ b/app/Models/Gateway.php @@ -39,6 +39,11 @@ class Gateway extends Eloquent return '/images/gateways/logo_'.$this->provider.'.png'; } + public function isGateway($gatewayId) + { + return $this->id == $gatewayId; + } + public static function getPaymentTypeLinks() { $data = []; foreach (self::$paymentTypes as $type) { diff --git a/app/Ninja/Repositories/NinjaRepository.php b/app/Ninja/Repositories/NinjaRepository.php new file mode 100644 index 000000000000..3f9c1fa4f19e --- /dev/null +++ b/app/Ninja/Repositories/NinjaRepository.php @@ -0,0 +1,18 @@ +first(); + + if (!$account) { + return; + } + + $account->pro_plan_paid = $proPlanPaid; + $account->save(); + } +} diff --git a/app/Services/ClientService.php b/app/Services/ClientService.php index f28e5d25d023..3093df1f3ae6 100644 --- a/app/Services/ClientService.php +++ b/app/Services/ClientService.php @@ -5,16 +5,17 @@ use URL; use Auth; use App\Services\BaseService; use App\Ninja\Repositories\ClientRepository; - +use App\Ninja\Repositories\NinjaRepository; class ClientService extends BaseService { protected $clientRepo; protected $datatableService; - public function __construct(ClientRepository $clientRepo, DatatableService $datatableService) + public function __construct(ClientRepository $clientRepo, DatatableService $datatableService, NinjaRepository $ninjaRepo) { $this->clientRepo = $clientRepo; + $this->ninjaRepo = $ninjaRepo; $this->datatableService = $datatableService; } @@ -25,6 +26,10 @@ class ClientService extends BaseService public function save($data) { + if (Auth::user()->account->isNinjaAccount() && isset($data['pro_plan_paid'])) { + $this->ninjaRepo->updateProPlanPaid($data['public_id'], $data['pro_plan_paid']); + } + return $this->clientRepo->save($data); } @@ -41,7 +46,7 @@ class ClientService extends BaseService [ 'name', function ($model) { - return link_to("clients/{$model->public_id}", $model->name); + return link_to("clients/{$model->public_id}", $model->name ?: ''); } ], [ @@ -53,7 +58,7 @@ class ClientService extends BaseService [ 'email', function ($model) { - return link_to("clients/{$model->public_id}", $model->email); + return link_to("clients/{$model->public_id}", $model->email ?: ''); } ], [ diff --git a/resources/views/clients/edit.blade.php b/resources/views/clients/edit.blade.php index 75a17c7a84a5..72835f170f3d 100644 --- a/resources/views/clients/edit.blade.php +++ b/resources/views/clients/edit.blade.php @@ -130,6 +130,20 @@ ->fromQuery($industries, 'name', 'id') !!} {!! Former::textarea('private_notes') !!} + + @if (isset($proPlanPaid)) + {!! Former::populateField('pro_plan_paid', $proPlanPaid) !!} + {!! Former::text('pro_plan_paid') + ->data_date_format('yyyy-mm-dd') + ->addGroupClass('pro_plan_paid_date') + ->append('') !!} + + @endif + diff --git a/resources/views/payments/payment.blade.php b/resources/views/payments/payment.blade.php index 7db903be5399..17600a449d95 100644 --- a/resources/views/payments/payment.blade.php +++ b/resources/views/payments/payment.blade.php @@ -1,5 +1,14 @@ @extends('public.header') +@section('head') + @parent + + + +@stop + @section('content')