1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-09 12:42:36 +01:00

Add UI for BlueVine signup

This commit is contained in:
Joshua Dwire 2016-11-03 16:54:33 -04:00
parent 9d4a121662
commit 5713561261
22 changed files with 186883 additions and 71 deletions

View File

@ -75,6 +75,7 @@ class DashboardController extends BaseController
$data = [
'account' => $user->account,
'user' => $user,
'paidToDate' => $paidToDate,
'balances' => $balances,
'averageInvoice' => $averageInvoice,
@ -92,6 +93,26 @@ class DashboardController extends BaseController
'tasks' => $tasks,
];
if(true){
$usdLast12Months = 0;
$paidLast12Months = $dashboardRepo->paidLast12Months( $account, $userId, $viewAll );
foreach ( $paidLast12Months as $item ) {
if ( $item->currency_id == null ) {
$currency = $user->account->currency_id ?: DEFAULT_CURRENCY;
} else {
$currency = $item->currency_id;
}
if ( $currency == CURRENCY_DOLLAR ) {
$usdLast12Months += $item->value;
}
}
$data['usdLast12Months'] = $usdLast12Months;
}
return View::make('dashboard', $data);
}

View File

@ -211,6 +211,33 @@ class DashboardRepository
->get();
}
public function paidLast12Months($account, $userId, $viewAll)
{
$accountId = $account->id;
$select = DB::raw(
'SUM('.DB::getQueryGrammar()->wrap('payments.amount', true).' - '.DB::getQueryGrammar()->wrap('payments.refunded', true).') as value,'
.DB::getQueryGrammar()->wrap('clients.currency_id', true).' as currency_id'
);
$paidLast12Months = DB::table('payments')
->select($select)
->leftJoin('invoices', 'invoices.id', '=', 'payments.invoice_id')
->leftJoin('clients', 'clients.id', '=', 'invoices.client_id')
->where('payments.account_id', '=', $accountId)
->where('clients.is_deleted', '=', false)
->where('invoices.is_deleted', '=', false)
->whereNotIn('payments.payment_status_id', [PAYMENT_STATUS_VOIDED, PAYMENT_STATUS_FAILED]);
if (!$viewAll){
$paidLast12Months->where('invoices.user_id', '=', $userId);
}
$paidLast12Months->where( 'payments.payment_date', '>=', date( 'Y-m-d', strtotime( '-1 year' ) ) );
return $paidLast12Months->groupBy('payments.account_id')
->groupBy(DB::raw('CASE WHEN '.DB::getQueryGrammar()->wrap('clients.currency_id', true).' IS NULL THEN '.($account->currency_id ?: DEFAULT_CURRENCY).' ELSE '.DB::getQueryGrammar()->wrap('clients.currency_id', true).' END'))
->get();
}
public function averages($account, $userId, $viewAll)
{
$accountId = $account->id;

View File

@ -0,0 +1,28 @@
<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class AddBlueVineFields extends Migration {
/**
* Run the migrations.
*
* @return void
*/
public function up() {
Schema::table( 'accounts', function ( $table ) {
$table->enum( 'bluevine_status', array( 'ignored', 'signed_up' ) )->nullable();
} );
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down() {
Schema::table( 'accounts', function ( $table ) {
$table->dropColumn( 'bluevine_status' );
} );
}
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

13367
public/css/built.css vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

10530
public/js/Chart.min.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

9559
public/js/d3.min.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1225,3 +1225,13 @@ div.panel-body div.panel-body {
vertical-align: middle;
margin-left: 16px;
}
/*
* BlueVine Promo
*/
@media (min-width: 900px) {
#bluevineModal .modal-dialog{
width:800px;
}
}

View File

@ -2176,6 +2176,25 @@ $LANG = array(
'modules' => 'Modules',
'financial_year_start' => 'First Month of the Year',
// BlueVine
'bluevine_promo' => 'Get flexible business lines of credit and invoice factoring using BlueVine.',
'bluevine_modal_label' => 'Sign up with BlueVine',
'bluevine_modal_text' => '<h3>Fast funding for your business. No paperwork.</h3>
<ul><li>Flexible business lines of credit and invoice factoring.</li>
<li>Credit lines from $5,000 to $2M. Cash in as fast as 1 day.</li></ul>',
'bluevine_create_account' => 'Create an account',
'quote_types' => 'Get a quote for',
'invoice_factoring' => 'Invoice factoring',
'line_of_credit' => 'Line of credit',
'fico_score' => 'Your FICO score',
'business_inception' => 'Business Inception Date',
'average_bank_balance' => 'Average bank account balance',
'annual_revenue' => 'Annual revenue',
'desired_credit_limit_factoring' => 'Desired invoice factoring limit',
'desired_credit_limit_loc' => 'Desired line of credit limit',
'desired_credit_limit' => 'Desired credit limit',
'bluevine_credit_line_type_required' => 'You must choose at least one',
'bluevine_field_required' => 'This field is required',
);
return $LANG;

View File

@ -194,7 +194,177 @@
@endif
</div>
</div>
@if(!$account->bluevine_status && env('BLUEVINE_PARTNER_UNIQUE_ID'))
<div class="alert alert-info" id="bluevinePromo">
{{ trans('texts.bluevine_promo') }}
<a href="#" onclick="showBlueVineModal()"
class="btn btn-primary btn-sm">{{ trans('texts.learn_more') }}</a>
<a href="#" onclick="hideBlueVineMessage()" class="pull-right">{{ trans('texts.hide') }}</a>
</div>
<div class="modal fade" id="bluevineModal" tabindex="-1" role="dialog" aria-labelledby="bluevineModalLabel"
aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
<h4 class="modal-title"
id="bluevineModalLabel">{{ trans('texts.bluevine_modal_label') }}</h4>
</div>
<div class="modal-body">
{!! Former::open('/bluevine/signup')->id('bluevineSignup') !!}
{!! trans('texts.bluevine_modal_text') !!}
<h3>{!! trans('texts.bluevine_create_account') !!}</h3>
{!! Former::text('name')->id('bluevine_name')->placeholder(trans('texts.name'))->value($user->first_name . ' ' . $user->last_name)->required() !!}
{!! Former::text('email')->id('bluevine_email')->placeholder(trans('texts.email'))->value($user->email)->required() !!}
{!! Former::text('phone')->id('bluevine_phone')->placeholder(trans('texts.phone'))->value(!empty($user->phone) ? $user->phone : '')->required() !!}
{!! Former::number('fico_score')->min(300)->max(850)->placeholder(trans('texts.fico_score'))->required() !!}
{!! Former::text('business_inception')->append('<span class="glyphicon glyphicon-calendar"></span>')->placeholder(trans('texts.business_inception'))->required() !!}
{!! Former::number('annual_revenue')->prepend('$')->append('.00')->placeholder(trans('texts.annual_revenue'))->value(floor($usdLast12Months))->required() !!}
{!! Former::number('average_bank_balance')->prepend('$')->append('.00')->placeholder(trans('texts.average_bank_balance'))->required() !!}
{!! Former::checkboxes('quote_types')
->onchange('bluevineQuoteTypesChanged()')
->required()
->checkboxes([
trans('texts.invoice_factoring') => ['value' => 'invoice_factoring', 'name' => 'quote_type_factoring', 'id'=>'quote_type_factoring'],
trans('texts.line_of_credit') => ['value' => 'line_of_credit', 'name' => 'quote_type_loc', 'id'=>'quote_type_loc'],
]) !!}
{!! Former::number('desired_credit_limit_factoring')
->id('desired_credit_limit_factoring')
->name('desired_credit_limit[invoice_factoring]')
->prepend('$')->append('.00')
->value(5000)
->required()
->placeholder(trans('texts.desired_credit_limit'))
->label(trans('texts.desired_credit_limit_factoring'))!!}
{!! Former::number('desired_credit_limit_loc')
->id('desired_credit_limit_loc')
->name('desired_credit_limit[line_of_credit]')
->prepend('$')->append('.00')
->value(5000)
->required()
->placeholder(trans('texts.desired_credit_limit'))
->label(trans('texts.desired_credit_limit_loc'))!!}
{!! Former::close() !!}
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default"
data-dismiss="modal">{{ trans('texts.cancel') }}</button>
<button type="button" class="btn btn-primary"
onclick="bluevineCreateAccount()">{{ trans('texts.sign_up') }}</button>
</div>
</div>
</div>
</div>
<script type="text/javascript">
function hideBlueVineMessage() {
jQuery('#bluevinePromo').remove();
return false;
}
function showBlueVineModal() {
jQuery('#bluevineModal').modal('show');
return false;
}
function bluevineQuoteTypesChanged() {
if (jQuery('#quote_type_loc').is(':checked')) {
jQuery('#desired_credit_limit_loc').attr('required', 'required').closest('.form-group').show();
} else {
jQuery('#desired_credit_limit_loc').removeAttr('required').closest('.form-group').hide();
}
if (jQuery('#quote_type_factoring').is(':checked')) {
jQuery('#desired_credit_limit_factoring').attr('required', 'required').closest('.form-group').show();
} else {
jQuery('#desired_credit_limit_factoring').removeAttr('required').closest('.form-group').hide();
}
}
bluevineQuoteTypesChanged();
jQuery('#bluevineSignup').on('submit', function (e) {
e.preventDefault();
bluevineCreateAccount();
});
jQuery('#business_inception').datepicker().siblings('.input-group-addon').click(function () {
jQuery('#business_inception').focus();
});
function bluevineCreateAccount() {
var form = $('#bluevineSignup');
var fields = [
'bluevine_name',
'bluevine_email',
'bluevine_phone',
'fico_score',
'business_inception',
'annual_revenue',
'average_bank_balance'
];
var hasError = false;
var requestFactoring = jQuery('#quote_type_factoring').is(':checked');
var requestLoc = jQuery('#quote_type_loc').is(':checked');
var quoteTypeFormGroup = jQuery('#quote_type_factoring').closest('.form-group');
if (!requestFactoring && !requestLoc) {
hasError = true;
if (!quoteTypeFormGroup.hasClass('has-error')) {
quoteTypeFormGroup.addClass('has-error');
quoteTypeFormGroup.children('div').append(
jQuery('<div class="help-block error-help-block">').text("{{ trans('texts.bluevine_credit_line_type_required') }}")
);
}
} else {
quoteTypeFormGroup.removeClass('has-error').find('.error-help-block').remove();
}
if (requestFactoring) {
fields.push('desired_credit_limit_factoring')
}
if (requestLoc) {
fields.push('desired_credit_limit_loc')
}
$.each(fields, function (i, fieldId) {
var field = $('#' + fieldId);
var formGroup = field.closest('.form-group');
if (!field.val()) {
if (!formGroup.hasClass('has-error')) {
formGroup.addClass('has-error');
formGroup.children('div').append(
jQuery('<div class="help-block error-help-block">').text("{{ trans('texts.bluevine_field_required') }}")
);
}
hasError = true;
} else {
formGroup.removeClass('has-error').find('.error-help-block').remove();
;
}
});
if (hasError) {
return;
}
$('#bluevineModal .btn-primary').attr('disabled', 'disabled');
$.post(form.attr('action'), form.serialize(), function (data) {
if (data.success) {
$('#bluevineSignup').hide();
} else {
}
$('#bluevineModal .btn-primary').removeAttr('disabled');
}, 'json');
}
</script>
@endif
<div class="row">
<div class="col-md-4">
<div class="panel panel-default">