mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-07 18:54:30 -04:00
Starting on stripejs
This commit is contained in:
parent
02aa10e41d
commit
b55a3226b7
@ -13,6 +13,7 @@ use Cache;
|
|||||||
|
|
||||||
use App\Models\Activity;
|
use App\Models\Activity;
|
||||||
use App\Models\Client;
|
use App\Models\Client;
|
||||||
|
use App\Models\Account;
|
||||||
use App\Models\Contact;
|
use App\Models\Contact;
|
||||||
use App\Models\Invoice;
|
use App\Models\Invoice;
|
||||||
use App\Models\Size;
|
use App\Models\Size;
|
||||||
@ -154,6 +155,12 @@ class ClientController extends BaseController
|
|||||||
|
|
||||||
$data = array_merge($data, self::getViewModel());
|
$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);
|
return View::make('clients.edit', $data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,6 +39,11 @@ class Gateway extends Eloquent
|
|||||||
return '/images/gateways/logo_'.$this->provider.'.png';
|
return '/images/gateways/logo_'.$this->provider.'.png';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function isGateway($gatewayId)
|
||||||
|
{
|
||||||
|
return $this->id == $gatewayId;
|
||||||
|
}
|
||||||
|
|
||||||
public static function getPaymentTypeLinks() {
|
public static function getPaymentTypeLinks() {
|
||||||
$data = [];
|
$data = [];
|
||||||
foreach (self::$paymentTypes as $type) {
|
foreach (self::$paymentTypes as $type) {
|
||||||
|
18
app/Ninja/Repositories/NinjaRepository.php
Normal file
18
app/Ninja/Repositories/NinjaRepository.php
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
<?php namespace App\Ninja\Repositories;
|
||||||
|
|
||||||
|
use App\Models\Account;
|
||||||
|
|
||||||
|
class NinjaRepository
|
||||||
|
{
|
||||||
|
public function updateProPlanPaid($clientPublicId, $proPlanPaid)
|
||||||
|
{
|
||||||
|
$account = Account::whereId($clientPublicId)->first();
|
||||||
|
|
||||||
|
if (!$account) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$account->pro_plan_paid = $proPlanPaid;
|
||||||
|
$account->save();
|
||||||
|
}
|
||||||
|
}
|
@ -5,16 +5,17 @@ use URL;
|
|||||||
use Auth;
|
use Auth;
|
||||||
use App\Services\BaseService;
|
use App\Services\BaseService;
|
||||||
use App\Ninja\Repositories\ClientRepository;
|
use App\Ninja\Repositories\ClientRepository;
|
||||||
|
use App\Ninja\Repositories\NinjaRepository;
|
||||||
|
|
||||||
class ClientService extends BaseService
|
class ClientService extends BaseService
|
||||||
{
|
{
|
||||||
protected $clientRepo;
|
protected $clientRepo;
|
||||||
protected $datatableService;
|
protected $datatableService;
|
||||||
|
|
||||||
public function __construct(ClientRepository $clientRepo, DatatableService $datatableService)
|
public function __construct(ClientRepository $clientRepo, DatatableService $datatableService, NinjaRepository $ninjaRepo)
|
||||||
{
|
{
|
||||||
$this->clientRepo = $clientRepo;
|
$this->clientRepo = $clientRepo;
|
||||||
|
$this->ninjaRepo = $ninjaRepo;
|
||||||
$this->datatableService = $datatableService;
|
$this->datatableService = $datatableService;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -25,6 +26,10 @@ class ClientService extends BaseService
|
|||||||
|
|
||||||
public function save($data)
|
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);
|
return $this->clientRepo->save($data);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -41,7 +46,7 @@ class ClientService extends BaseService
|
|||||||
[
|
[
|
||||||
'name',
|
'name',
|
||||||
function ($model) {
|
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',
|
'email',
|
||||||
function ($model) {
|
function ($model) {
|
||||||
return link_to("clients/{$model->public_id}", $model->email);
|
return link_to("clients/{$model->public_id}", $model->email ?: '');
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
|
@ -130,6 +130,20 @@
|
|||||||
->fromQuery($industries, 'name', 'id') !!}
|
->fromQuery($industries, 'name', 'id') !!}
|
||||||
{!! Former::textarea('private_notes') !!}
|
{!! 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('<i class="glyphicon glyphicon-calendar"></i>') !!}
|
||||||
|
<script type="text/javascript">
|
||||||
|
$(function() {
|
||||||
|
$('#pro_plan_paid').datepicker();
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
@endif
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -1,5 +1,14 @@
|
|||||||
@extends('public.header')
|
@extends('public.header')
|
||||||
|
|
||||||
|
@section('head')
|
||||||
|
@parent
|
||||||
|
|
||||||
|
<!--
|
||||||
|
<script type="text/javascript" src="https://js.stripe.com/v2/"></script>
|
||||||
|
-->
|
||||||
|
|
||||||
|
@stop
|
||||||
|
|
||||||
@section('content')
|
@section('content')
|
||||||
|
|
||||||
<style type="text/css">
|
<style type="text/css">
|
||||||
@ -270,22 +279,25 @@ header h3 em {
|
|||||||
<h3>{{ trans('texts.billing_method') }}</h3>
|
<h3>{{ trans('texts.billing_method') }}</h3>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-9">
|
<div class="col-md-9">
|
||||||
{!! Former::text('card_number')
|
{!! Former::text($gateway->isGateway(GATEWAY_STRIPE) ? 'card_number' : 'card_number')
|
||||||
->placeholder(trans('texts.card_number'))
|
->placeholder(trans('texts.card_number'))
|
||||||
->autocomplete('cc-number')
|
->autocomplete('cc-number')
|
||||||
|
->data_stripe('number')
|
||||||
->label('') !!}
|
->label('') !!}
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-3">
|
<div class="col-md-3">
|
||||||
{!! Former::text('cvv')
|
{!! Former::text($gateway->isGateway(GATEWAY_STRIPE) ? 'cvv' : 'cvv')
|
||||||
->placeholder(trans('texts.cvv'))
|
->placeholder(trans('texts.cvv'))
|
||||||
->autocomplete('off')
|
->autocomplete('off')
|
||||||
|
->data_stripe('cvc')
|
||||||
->label('') !!}
|
->label('') !!}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-6">
|
<div class="col-md-6">
|
||||||
{!! Former::select('expiration_month')
|
{!! Former::select($gateway->isGateway(GATEWAY_STRIPE) ? 'expiration_month' : 'expiration_month')
|
||||||
->autocomplete('cc-exp-month')
|
->autocomplete('cc-exp-month')
|
||||||
|
->data_stripe('exp-month')
|
||||||
->placeholder(trans('texts.expiration_month'))
|
->placeholder(trans('texts.expiration_month'))
|
||||||
->addOption('01 - January', '1')
|
->addOption('01 - January', '1')
|
||||||
->addOption('02 - February', '2')
|
->addOption('02 - February', '2')
|
||||||
@ -302,8 +314,9 @@ header h3 em {
|
|||||||
!!}
|
!!}
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-6">
|
<div class="col-md-6">
|
||||||
{!! Former::select('expiration_year')
|
{!! Former::select($gateway->isGateway(GATEWAY_STRIPE) ? 'expiration_year' : 'expiration_year')
|
||||||
->autocomplete('cc-exp-year')
|
->autocomplete('cc-exp-year')
|
||||||
|
->data_stripe('exp-year')
|
||||||
->placeholder(trans('texts.expiration_year'))
|
->placeholder(trans('texts.expiration_year'))
|
||||||
->addOption('2015', '2015')
|
->addOption('2015', '2015')
|
||||||
->addOption('2016', '2016')
|
->addOption('2016', '2016')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user