mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-08 12:12:48 +01:00
Improve new company process #460
This commit is contained in:
parent
a6e546bcdc
commit
3061209ea7
@ -288,7 +288,6 @@ if (! defined('APP_NAME')) {
|
||||
|
||||
define('REQUESTED_PRO_PLAN', 'REQUESTED_PRO_PLAN');
|
||||
define('DEMO_ACCOUNT_ID', 'DEMO_ACCOUNT_ID');
|
||||
define('PREV_USER_ID', 'PREV_USER_ID');
|
||||
define('NINJA_ACCOUNT_KEY', 'zg4ylmzDkdkPOT8yoKQw9LTWaoZJx79h');
|
||||
define('NINJA_LICENSE_ACCOUNT_KEY', 'AsFmBAeLXF0IKf7tmi0eiyZfmWW9hxMT');
|
||||
define('NINJA_GATEWAY_ID', GATEWAY_STRIPE);
|
||||
|
@ -123,17 +123,16 @@ class AccountController extends BaseController
|
||||
{
|
||||
$user = false;
|
||||
$guestKey = Input::get('guest_key'); // local storage key to login until registered
|
||||
$prevUserId = Session::pull(PREV_USER_ID); // last user id used to link to new account
|
||||
|
||||
if (Auth::check()) {
|
||||
return Redirect::to('invoices/create');
|
||||
}
|
||||
|
||||
if (! Utils::isNinja() && (Account::count() > 0 && ! $prevUserId)) {
|
||||
if (! Utils::isNinja() && Account::count() > 0) {
|
||||
return Redirect::to('/login');
|
||||
}
|
||||
|
||||
if ($guestKey && ! $prevUserId) {
|
||||
if ($guestKey) {
|
||||
$user = User::where('password', '=', $guestKey)->first();
|
||||
|
||||
if ($user && $user->registered) {
|
||||
@ -144,11 +143,6 @@ class AccountController extends BaseController
|
||||
if (! $user) {
|
||||
$account = $this->accountRepo->create();
|
||||
$user = $account->users()->first();
|
||||
|
||||
if ($prevUserId) {
|
||||
$users = $this->accountRepo->associateAccounts($user->id, $prevUserId);
|
||||
Session::put(SESSION_USER_ACCOUNTS, $users);
|
||||
}
|
||||
}
|
||||
|
||||
Auth::login($user, true);
|
||||
@ -1234,7 +1228,7 @@ class AccountController extends BaseController
|
||||
public function checkEmail()
|
||||
{
|
||||
$email = User::withTrashed()->where('email', '=', Input::get('email'))
|
||||
->where('id', '<>', Auth::user()->id)
|
||||
->where('id', '<>', Auth::user()->registered ? 0 : Auth::user()->id)
|
||||
->first();
|
||||
|
||||
if ($email) {
|
||||
@ -1249,36 +1243,58 @@ class AccountController extends BaseController
|
||||
*/
|
||||
public function submitSignup()
|
||||
{
|
||||
$user = Auth::user();
|
||||
$account = $user->account;
|
||||
|
||||
$rules = [
|
||||
'new_first_name' => 'required',
|
||||
'new_last_name' => 'required',
|
||||
'new_password' => 'required|min:6',
|
||||
'new_email' => 'email|required|unique:users,email,'.Auth::user()->id.',id',
|
||||
'new_email' => 'email|required|unique:users,email',
|
||||
];
|
||||
|
||||
if (! $user->registered) {
|
||||
$rules['new_email'] .= ',' . Auth::user()->id . ',id';
|
||||
}
|
||||
|
||||
$validator = Validator::make(Input::all(), $rules);
|
||||
|
||||
if ($validator->fails()) {
|
||||
return '';
|
||||
}
|
||||
|
||||
/** @var \App\Models\User $user */
|
||||
$user = Auth::user();
|
||||
$user->first_name = trim(Input::get('new_first_name'));
|
||||
$user->last_name = trim(Input::get('new_last_name'));
|
||||
$user->email = trim(strtolower(Input::get('new_email')));
|
||||
$user->username = $user->email;
|
||||
$user->password = bcrypt(trim(Input::get('new_password')));
|
||||
$user->registered = true;
|
||||
$user->save();
|
||||
$firstName = trim(Input::get('new_first_name'));
|
||||
$lastName = trim(Input::get('new_last_name'));
|
||||
$email = trim(strtolower(Input::get('new_email')));
|
||||
$password = trim(Input::get('new_password'));
|
||||
|
||||
$user->account->startTrial(PLAN_PRO);
|
||||
if ($user->registered) {
|
||||
$newAccount = $this->accountRepo->create($firstName, $lastName, $email, $password, $account->company);
|
||||
$newUser = $newAccount->users()->first();
|
||||
$users = $this->accountRepo->associateAccounts($user->id, $newUser->id);
|
||||
|
||||
if (Input::get('go_pro') == 'true') {
|
||||
Session::set(REQUESTED_PRO_PLAN, true);
|
||||
Session::flash('message', trans('texts.created_new_company'));
|
||||
Session::put(SESSION_USER_ACCOUNTS, $users);
|
||||
Auth::loginUsingId($newUser->id);
|
||||
|
||||
return RESULT_SUCCESS;
|
||||
} else {
|
||||
$user->first_name = $firstName;
|
||||
$user->last_name = $lastName;
|
||||
$user->email = $email;
|
||||
$user->username = $user->email;
|
||||
$user->password = bcrypt($password);
|
||||
$user->registered = true;
|
||||
$user->save();
|
||||
|
||||
$user->account->startTrial(PLAN_PRO);
|
||||
|
||||
if (Input::get('go_pro') == 'true') {
|
||||
Session::set(REQUESTED_PRO_PLAN, true);
|
||||
}
|
||||
|
||||
return "{$user->first_name} {$user->last_name}";
|
||||
}
|
||||
|
||||
return "{$user->first_name} {$user->last_name}";
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -65,12 +65,6 @@ class HomeController extends BaseController
|
||||
*/
|
||||
public function invoiceNow()
|
||||
{
|
||||
if (Auth::check() && Input::get('new_company')) {
|
||||
Session::put(PREV_USER_ID, Auth::user()->id);
|
||||
Auth::user()->clearSession();
|
||||
Auth::logout();
|
||||
}
|
||||
|
||||
// Track the referral/campaign code
|
||||
if (Input::has('rc')) {
|
||||
Session::set(SESSION_REFERRAL_CODE, Input::get('rc'));
|
||||
|
@ -27,15 +27,17 @@ use Validator;
|
||||
|
||||
class AccountRepository
|
||||
{
|
||||
public function create($firstName = '', $lastName = '', $email = '', $password = '')
|
||||
public function create($firstName = '', $lastName = '', $email = '', $password = '', $company = false)
|
||||
{
|
||||
$company = new Company();
|
||||
$company->utm_source = Input::get('utm_source');
|
||||
$company->utm_medium = Input::get('utm_medium');
|
||||
$company->utm_campaign = Input::get('utm_campaign');
|
||||
$company->utm_term = Input::get('utm_term');
|
||||
$company->utm_content = Input::get('utm_content');
|
||||
$company->save();
|
||||
if (! $company) {
|
||||
$company = new Company();
|
||||
$company->utm_source = Input::get('utm_source');
|
||||
$company->utm_medium = Input::get('utm_medium');
|
||||
$company->utm_campaign = Input::get('utm_campaign');
|
||||
$company->utm_term = Input::get('utm_term');
|
||||
$company->utm_content = Input::get('utm_content');
|
||||
$company->save();
|
||||
}
|
||||
|
||||
$account = new Account();
|
||||
$account->ip = Request::getClientIp();
|
||||
@ -617,61 +619,7 @@ class AccountRepository
|
||||
|
||||
$record->save();
|
||||
|
||||
$users = $this->getUserAccounts($record);
|
||||
|
||||
// Pick the primary user
|
||||
foreach ($users as $user) {
|
||||
if (! $user->public_id) {
|
||||
$useAsPrimary = false;
|
||||
if (empty($primaryUser)) {
|
||||
$useAsPrimary = true;
|
||||
}
|
||||
|
||||
$planDetails = $user->account->getPlanDetails(false, false);
|
||||
$planLevel = 0;
|
||||
|
||||
if ($planDetails) {
|
||||
$planLevel = 1;
|
||||
if ($planDetails['plan'] == PLAN_ENTERPRISE) {
|
||||
$planLevel = 2;
|
||||
}
|
||||
|
||||
if (! $useAsPrimary && (
|
||||
$planLevel > $primaryUserPlanLevel
|
||||
|| ($planLevel == $primaryUserPlanLevel && $planDetails['expires'] > $primaryUserPlanExpires)
|
||||
)) {
|
||||
$useAsPrimary = true;
|
||||
}
|
||||
}
|
||||
|
||||
if ($useAsPrimary) {
|
||||
$primaryUser = $user;
|
||||
$primaryUserPlanLevel = $planLevel;
|
||||
if ($planDetails) {
|
||||
$primaryUserPlanExpires = $planDetails['expires'];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Merge other companies into the primary user's company
|
||||
if (! empty($primaryUser)) {
|
||||
foreach ($users as $user) {
|
||||
if ($user == $primaryUser || $user->public_id) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($user->account->company_id != $primaryUser->account->company_id) {
|
||||
foreach ($user->account->company->accounts as $account) {
|
||||
$account->company_id = $primaryUser->account->company_id;
|
||||
$account->save();
|
||||
}
|
||||
$user->account->company->forceDelete();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $users;
|
||||
return $this->loadAccounts($userId1);
|
||||
}
|
||||
|
||||
public function unlinkAccount($account)
|
||||
|
@ -2368,7 +2368,7 @@ $LANG = array(
|
||||
|
||||
// New Client Portal styling
|
||||
'invoice_from' => 'Invoices From:',
|
||||
'email_alias_message' => 'Note: we require each user to have a unique email address.<br/>Consider using an alias. ie, email+label@example.com',
|
||||
'email_alias_message' => 'We require each company to have a unique email address.<br/>Consider using an alias. ie, email+label@example.com',
|
||||
'full_name' => 'Full Name',
|
||||
'month_year' => 'MONTH/YEAR',
|
||||
'valid_thru' => 'Valid\nthru',
|
||||
@ -2435,6 +2435,7 @@ $LANG = array(
|
||||
'reset_counter_help' => 'Automatically reset the invoice and quote counters.',
|
||||
'auto_bill_failed' => 'Auto-billing for invoice :invoice_number failed',
|
||||
'online_payment_discount' => 'Online Payment Discount',
|
||||
'created_new_company' => 'Successfully created new company',
|
||||
|
||||
);
|
||||
|
||||
|
@ -4,115 +4,9 @@
|
||||
@section('head')
|
||||
|
||||
<link href="{{ asset('css/built.css') }}?no_cache={{ NINJA_VERSION }}" rel="stylesheet" type="text/css"/>
|
||||
<style type="text/css">
|
||||
@if (Auth::check() && Auth::user()->dark_mode)
|
||||
body {
|
||||
background: #000 !important;
|
||||
color: white !important;
|
||||
}
|
||||
|
||||
.panel-body {
|
||||
background: #272822 !important;
|
||||
/*background: #e6e6e6 !important;*/
|
||||
}
|
||||
|
||||
.panel-default {
|
||||
border-color: #444;
|
||||
}
|
||||
@endif
|
||||
|
||||
</style>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
@if (!Auth::check() || !Auth::user()->registered)
|
||||
function validateSignUp(showError)
|
||||
{
|
||||
var isFormValid = true;
|
||||
$(['first_name','last_name','email','password']).each(function(i, field) {
|
||||
var $input = $('form.signUpForm #new_'+field),
|
||||
val = $.trim($input.val());
|
||||
var isValid = val && val.length >= (field == 'password' ? 6 : 1);
|
||||
if (isValid && field == 'email') {
|
||||
isValid = isValidEmailAddress(val);
|
||||
}
|
||||
if (isValid) {
|
||||
$input.closest('div.form-group').removeClass('has-error').addClass('has-success');
|
||||
} else {
|
||||
isFormValid = false;
|
||||
$input.closest('div.form-group').removeClass('has-success');
|
||||
if (showError) {
|
||||
$input.closest('div.form-group').addClass('has-error');
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if (!$('#terms_checkbox').is(':checked')) {
|
||||
isFormValid = false;
|
||||
}
|
||||
|
||||
$('#saveSignUpButton').prop('disabled', !isFormValid);
|
||||
|
||||
return isFormValid;
|
||||
}
|
||||
|
||||
function validateServerSignUp()
|
||||
{
|
||||
if (!validateSignUp(true)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$('#signUpDiv, #signUpFooter').hide();
|
||||
$('#working').show();
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: '{{ URL::to('signup/validate') }}',
|
||||
data: 'email=' + $('form.signUpForm #new_email').val(),
|
||||
success: function(result) {
|
||||
if (result == 'available') {
|
||||
submitSignUp();
|
||||
} else {
|
||||
$('#errorTaken').show();
|
||||
$('form.signUpForm #new_email').closest('div.form-group').removeClass('has-success').addClass('has-error');
|
||||
$('#signUpDiv, #signUpFooter').show();
|
||||
$('#working').hide();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function submitSignUp() {
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: '{{ URL::to('signup/submit') }}',
|
||||
data: 'new_email=' + encodeURIComponent($('form.signUpForm #new_email').val()) +
|
||||
'&new_password=' + encodeURIComponent($('form.signUpForm #new_password').val()) +
|
||||
'&new_first_name=' + encodeURIComponent($('form.signUpForm #new_first_name').val()) +
|
||||
'&new_last_name=' + encodeURIComponent($('form.signUpForm #new_last_name').val()) +
|
||||
'&go_pro=' + $('#go_pro').val(),
|
||||
success: function(result) {
|
||||
if (result) {
|
||||
handleSignedUp();
|
||||
NINJA.isRegistered = true;
|
||||
$('#signUpButton').hide();
|
||||
$('#myAccountButton').html(result);
|
||||
}
|
||||
$('#signUpSuccessDiv, #signUpFooter, #closeSignUpButton').show();
|
||||
$('#working, #saveSignUpButton').hide();
|
||||
}
|
||||
});
|
||||
}
|
||||
@endif
|
||||
|
||||
function handleSignedUp() {
|
||||
if (isStorageSupported()) {
|
||||
localStorage.setItem('guest_key', '');
|
||||
}
|
||||
fbq('track', 'CompleteRegistration');
|
||||
trackEvent('/account', '/signed_up');
|
||||
}
|
||||
|
||||
function checkForEnter(event)
|
||||
{
|
||||
if (event.keyCode === 13){
|
||||
@ -135,14 +29,6 @@
|
||||
}
|
||||
}
|
||||
|
||||
function showSignUp() {
|
||||
$('#signUpModal').modal('show');
|
||||
}
|
||||
|
||||
function hideSignUp() {
|
||||
$('#signUpModal').modal('hide');
|
||||
}
|
||||
|
||||
function hideMessage() {
|
||||
$('.alert-info').fadeOut();
|
||||
$.get('/hide_message', function(response) {
|
||||
@ -150,15 +36,6 @@
|
||||
});
|
||||
}
|
||||
|
||||
function setSignupEnabled(enabled) {
|
||||
$('.signup-form input[type=text]').prop('disabled', !enabled);
|
||||
if (enabled) {
|
||||
$('.signup-form a.btn').removeClass('disabled');
|
||||
} else {
|
||||
$('.signup-form a.btn').addClass('disabled');
|
||||
}
|
||||
}
|
||||
|
||||
window.loadedSearchData = false;
|
||||
function onSearchBlur() {
|
||||
$('#search').typeahead('val', '');
|
||||
@ -241,32 +118,10 @@
|
||||
|
||||
if (isStorageSupported()) {
|
||||
@if (Auth::check() && !Auth::user()->registered)
|
||||
localStorage.setItem('guest_key', '{{ Auth::user()->password }}');
|
||||
localStorage.setItem('guest_key', '{{ Auth::user()->password }}');
|
||||
@endif
|
||||
}
|
||||
|
||||
@if (!Auth::check() || !Auth::user()->registered)
|
||||
validateSignUp();
|
||||
|
||||
$('#signUpModal').on('shown.bs.modal', function () {
|
||||
trackEvent('/account', '/view_sign_up');
|
||||
$(['first_name','last_name','email','password']).each(function(i, field) {
|
||||
var $input = $('form.signUpForm #new_'+field);
|
||||
if (!$input.val()) {
|
||||
$input.focus();
|
||||
return false;
|
||||
}
|
||||
});
|
||||
})
|
||||
@endif
|
||||
|
||||
@if (Auth::check() && !Utils::isNinja() && !Auth::user()->registered)
|
||||
$('#closeSignUpButton').hide();
|
||||
showSignUp();
|
||||
@elseif(Session::get('sign_up') || Input::get('sign_up'))
|
||||
showSignUp();
|
||||
@endif
|
||||
|
||||
$('ul.navbar-settings, ul.navbar-search').hover(function () {
|
||||
if ($('.user-accounts').css('display') == 'block') {
|
||||
$('.user-accounts').dropdown('toggle');
|
||||
@ -279,14 +134,6 @@
|
||||
$('#{{ Input::get('focus') }}').focus();
|
||||
@endif
|
||||
|
||||
// Ensure terms is checked for sign up form
|
||||
@if (Auth::check() && !Auth::user()->registered)
|
||||
setSignupEnabled(false);
|
||||
$("#terms_checkbox").change(function() {
|
||||
setSignupEnabled(this.checked);
|
||||
});
|
||||
@endif
|
||||
|
||||
// Focus the search input if the user clicks forward slash
|
||||
$('#search').focusin(onSearchFocus);
|
||||
$('#search').blur(onSearchBlur);
|
||||
@ -453,7 +300,7 @@
|
||||
@if (count(session(SESSION_USER_ACCOUNTS)) > 1)
|
||||
<li>{!! link_to('/manage_companies', trans('texts.manage_companies')) !!}</li>
|
||||
@elseif (!session(SESSION_USER_ACCOUNTS) || count(session(SESSION_USER_ACCOUNTS)) < 5)
|
||||
<li>{!! link_to('/invoice_now?new_company=true&sign_up=true', trans('texts.add_company')) !!}</li>
|
||||
<li>{!! link_to('#', trans('texts.add_company'), ['onclick' => 'showSignUp()']) !!}</li>
|
||||
@endif
|
||||
@endif
|
||||
<li>{!! link_to('#', trans('texts.logout'), array('onclick'=>'logout()')) !!}</li>
|
||||
@ -625,150 +472,7 @@
|
||||
</div>
|
||||
|
||||
@include('partials.contact_us')
|
||||
|
||||
@if (!Auth::check() || !Auth::user()->registered)
|
||||
<div class="modal fade" id="signUpModal" tabindex="-1" role="dialog" aria-labelledby="signUpModalLabel" 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">×</button>
|
||||
<h4 class="modal-title" id="myModalLabel">{{ trans('texts.sign_up') }}</h4>
|
||||
</div>
|
||||
|
||||
<div style="background-color: #fff; padding-right:20px" id="signUpDiv" onkeyup="validateSignUp()" onclick="validateSignUp()" onkeydown="checkForEnter(event)">
|
||||
<br/>
|
||||
|
||||
{!! Former::open('signup/submit')->addClass('signUpForm')->autocomplete('on') !!}
|
||||
|
||||
@if (Auth::check())
|
||||
{!! Former::populateField('new_first_name', Auth::user()->first_name) !!}
|
||||
{!! Former::populateField('new_last_name', Auth::user()->last_name) !!}
|
||||
{!! Former::populateField('new_email', Auth::user()->email) !!}
|
||||
@endif
|
||||
|
||||
<div style="display:none">
|
||||
{!! Former::text('path')->value(Request::path()) !!}
|
||||
{!! Former::text('go_pro') !!}
|
||||
</div>
|
||||
|
||||
|
||||
<div class="row signup-form">
|
||||
<div class="col-md-11 col-md-offset-1">
|
||||
{!! Former::checkbox('terms_checkbox')
|
||||
->label(' ')
|
||||
->value(1)
|
||||
->text(trans('texts.agree_to_terms', ['terms' => '<a href="'.Utils::getTermsLink().'" target="_blank">'.trans('texts.terms_of_service').'</a>']))
|
||||
->raw() !!}
|
||||
<br/>
|
||||
</div>
|
||||
@if (Utils::isOAuthEnabled())
|
||||
<div class="col-md-4 col-md-offset-1">
|
||||
<h4>{{ trans('texts.sign_up_using') }}</h4><br/>
|
||||
@foreach (App\Services\AuthService::$providers as $provider)
|
||||
<a href="{{ URL::to('auth/' . $provider) }}" class="btn btn-primary btn-block"
|
||||
id="{{ strtolower($provider) }}LoginButton">
|
||||
<i class="fa fa-{{ strtolower($provider) }}"></i>
|
||||
{{ $provider }}
|
||||
</a>
|
||||
@endforeach
|
||||
</div>
|
||||
<div class="col-md-1">
|
||||
<div style="border-right:thin solid #CCCCCC;height:110px;width:8px;margin-bottom:10px;"></div>
|
||||
{{ trans('texts.or') }}
|
||||
<div style="border-right:thin solid #CCCCCC;height:110px;width:8px;margin-top:10px;"></div>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
@else
|
||||
<div class="col-md-12">
|
||||
@endif
|
||||
{{ Former::setOption('TwitterBootstrap3.labelWidths.large', 1) }}
|
||||
{{ Former::setOption('TwitterBootstrap3.labelWidths.small', 1) }}
|
||||
|
||||
{!! Former::text('new_first_name')
|
||||
->placeholder(trans('texts.first_name'))
|
||||
->autocomplete('given-name')
|
||||
->label(' ') !!}
|
||||
{!! Former::text('new_last_name')
|
||||
->placeholder(trans('texts.last_name'))
|
||||
->autocomplete('family-name')
|
||||
->label(' ') !!}
|
||||
{!! Former::text('new_email')
|
||||
->placeholder(trans('texts.email'))
|
||||
->autocomplete('email')
|
||||
->label(' ') !!}
|
||||
{!! Former::password('new_password')
|
||||
->placeholder(trans('texts.password'))
|
||||
->label(' ') !!}
|
||||
|
||||
{{ Former::setOption('TwitterBootstrap3.labelWidths.large', 4) }}
|
||||
{{ Former::setOption('TwitterBootstrap3.labelWidths.small', 4) }}
|
||||
</div>
|
||||
|
||||
<div class="col-md-11 col-md-offset-1">
|
||||
@if (Auth::user()->account->hasMultipleAccounts())
|
||||
<div style="padding-top:20px;padding-bottom:10px;">{!! trans('texts.email_alias_message') !!}</div>
|
||||
@elseif (Utils::isNinja())
|
||||
<div style="padding-top:20px;padding-bottom:10px;">{{ trans('texts.trial_message') }}</div>
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{!! Former::close() !!}
|
||||
|
||||
|
||||
|
||||
<center><div id="errorTaken" style="display:none"> <br/>{{ trans('texts.email_taken') }}</div></center>
|
||||
<br/>
|
||||
|
||||
</div>
|
||||
|
||||
<div style="padding-left:40px;padding-right:40px;display:none;min-height:130px" id="working">
|
||||
<h3>{{ trans('texts.working') }}...</h3>
|
||||
<div class="progress progress-striped active">
|
||||
<div class="progress-bar" role="progressbar" aria-valuenow="100" aria-valuemin="0" aria-valuemax="100" style="width: 100%"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div style="background-color: #fff; padding-right:20px;padding-left:20px; display:none" id="signUpSuccessDiv">
|
||||
<br/>
|
||||
<h3>{{ trans('texts.success') }}</h3>
|
||||
@if (Utils::isNinja())
|
||||
{{ trans('texts.success_message') }}
|
||||
@endif
|
||||
<br/>
|
||||
</div>
|
||||
|
||||
<div class="modal-footer" id="signUpFooter" style="margin-top: 0px">
|
||||
<button type="button" class="btn btn-default" id="closeSignUpButton" data-dismiss="modal">{{ trans('texts.close') }} <i class="glyphicon glyphicon-remove-circle"></i></button>
|
||||
<button type="button" class="btn btn-primary" id="saveSignUpButton" onclick="validateServerSignUp()" disabled>{{ trans('texts.save') }} <i class="glyphicon glyphicon-floppy-disk"></i></button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="modal fade" id="logoutModal" tabindex="-1" role="dialog" aria-labelledby="logoutModalLabel" 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">×</button>
|
||||
<h4 class="modal-title" id="myModalLabel">{{ trans('texts.logout') }}</h4>
|
||||
</div>
|
||||
|
||||
<div class="container">
|
||||
<h3>{{ trans('texts.are_you_sure') }}</h3>
|
||||
<p>{{ trans('texts.erase_data') }}</p>
|
||||
</div>
|
||||
|
||||
<div class="modal-footer" id="signUpFooter">
|
||||
<button type="button" class="btn btn-default" data-dismiss="modal">{{ trans('texts.cancel') }}</button>
|
||||
<button type="button" class="btn btn-danger" onclick="logout(true)">{{ trans('texts.logout') }}</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endif
|
||||
|
||||
@include('partials.sign_up')
|
||||
@include('partials.keyboard_shortcuts')
|
||||
|
||||
</div>
|
||||
|
295
resources/views/partials/sign_up.blade.php
Normal file
295
resources/views/partials/sign_up.blade.php
Normal file
@ -0,0 +1,295 @@
|
||||
<script type="text/javascript">
|
||||
|
||||
$(function() {
|
||||
|
||||
validateSignUp();
|
||||
|
||||
$('#signUpModal').on('shown.bs.modal', function () {
|
||||
trackEvent('/account', '/view_sign_up');
|
||||
$(['first_name','last_name','email','password']).each(function(i, field) {
|
||||
var $input = $('form.signUpForm #new_'+field);
|
||||
if (!$input.val()) {
|
||||
$input.focus();
|
||||
return false;
|
||||
}
|
||||
});
|
||||
})
|
||||
|
||||
@if (Auth::check() && !Utils::isNinja() && ! Auth::user()->registered)
|
||||
$('#closeSignUpButton').hide();
|
||||
showSignUp();
|
||||
@elseif(Session::get('sign_up') || Input::get('sign_up'))
|
||||
showSignUp();
|
||||
@endif
|
||||
|
||||
// Ensure terms is checked for sign up form
|
||||
@if (Auth::check() && ! Auth::user()->registered)
|
||||
setSignupEnabled(false);
|
||||
$("#terms_checkbox").change(function() {
|
||||
setSignupEnabled(this.checked);
|
||||
});
|
||||
@endif
|
||||
|
||||
});
|
||||
|
||||
|
||||
function showSignUp() {
|
||||
$('#signUpModal').modal('show');
|
||||
}
|
||||
|
||||
function hideSignUp() {
|
||||
$('#signUpModal').modal('hide');
|
||||
}
|
||||
|
||||
function setSignupEnabled(enabled) {
|
||||
$('.signup-form input[type=text]').prop('disabled', !enabled);
|
||||
$('.signup-form input[type=password]').prop('disabled', !enabled);
|
||||
if (enabled) {
|
||||
$('.signup-form a.btn').removeClass('disabled');
|
||||
} else {
|
||||
$('.signup-form a.btn').addClass('disabled');
|
||||
}
|
||||
}
|
||||
|
||||
function validateSignUp(showError)
|
||||
{
|
||||
var isFormValid = true;
|
||||
$(['first_name','last_name','email','password']).each(function(i, field) {
|
||||
var $input = $('form.signUpForm #new_'+field),
|
||||
val = $.trim($input.val());
|
||||
var isValid = val && val.length >= (field == 'password' ? 6 : 1);
|
||||
if (isValid && field == 'email') {
|
||||
isValid = isValidEmailAddress(val);
|
||||
}
|
||||
if (isValid) {
|
||||
$input.closest('div.form-group').removeClass('has-error').addClass('has-success');
|
||||
} else {
|
||||
isFormValid = false;
|
||||
$input.closest('div.form-group').removeClass('has-success');
|
||||
if (showError) {
|
||||
$input.closest('div.form-group').addClass('has-error');
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@if (! Auth::user()->registered)
|
||||
if (!$('#terms_checkbox').is(':checked')) {
|
||||
isFormValid = false;
|
||||
}
|
||||
@endif
|
||||
|
||||
$('#saveSignUpButton').prop('disabled', !isFormValid);
|
||||
|
||||
return isFormValid;
|
||||
}
|
||||
|
||||
function validateServerSignUp()
|
||||
{
|
||||
if (!validateSignUp(true)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$('#signUpDiv, #signUpFooter').hide();
|
||||
$('#working').show();
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: '{{ URL::to('signup/validate') }}',
|
||||
data: 'email=' + $('form.signUpForm #new_email').val(),
|
||||
success: function(result) {
|
||||
if (result == 'available') {
|
||||
submitSignUp();
|
||||
} else {
|
||||
$('#errorTaken').show();
|
||||
$('form.signUpForm #new_email').closest('div.form-group').removeClass('has-success').addClass('has-error');
|
||||
$('#signUpDiv, #signUpFooter').show();
|
||||
$('#working').hide();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function submitSignUp() {
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: '{{ URL::to('signup/submit') }}',
|
||||
data: 'new_email=' + encodeURIComponent($('form.signUpForm #new_email').val()) +
|
||||
'&new_password=' + encodeURIComponent($('form.signUpForm #new_password').val()) +
|
||||
'&new_first_name=' + encodeURIComponent($('form.signUpForm #new_first_name').val()) +
|
||||
'&new_last_name=' + encodeURIComponent($('form.signUpForm #new_last_name').val()) +
|
||||
'&go_pro=' + $('#go_pro').val(),
|
||||
success: function(result) {
|
||||
if (result) {
|
||||
@if (Auth::user()->registered)
|
||||
hideSignUp();
|
||||
NINJA.formIsChanged = false;
|
||||
location.reload();
|
||||
@else
|
||||
handleSignedUp();
|
||||
NINJA.isRegistered = true;
|
||||
$('#signUpButton').hide();
|
||||
$('#myAccountButton').html(result);
|
||||
$('#signUpSuccessDiv, #signUpFooter, #closeSignUpButton').show();
|
||||
$('#working, #saveSignUpButton').hide();
|
||||
@endif
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function handleSignedUp() {
|
||||
if (isStorageSupported()) {
|
||||
localStorage.setItem('guest_key', '');
|
||||
}
|
||||
fbq('track', 'CompleteRegistration');
|
||||
trackEvent('/account', '/signed_up');
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<div class="modal fade" id="signUpModal" tabindex="-1" role="dialog" aria-labelledby="signUpModalLabel" 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">×</button>
|
||||
<h4 class="modal-title" id="myModalLabel">{{ Auth::user()->registered ? trans('texts.add_company') : trans('texts.sign_up') }}</h4>
|
||||
</div>
|
||||
|
||||
<div class="container" style="width: 100%; padding-bottom: 0px !important">
|
||||
<div class="panel panel-default" style="margin-bottom: 2px">
|
||||
<div class="panel-body">
|
||||
|
||||
<div id="signUpDiv" onkeyup="validateSignUp()" onclick="validateSignUp()" onkeydown="checkForEnter(event)">
|
||||
{!! Former::open('signup/submit')->addClass('signUpForm')->autocomplete('on') !!}
|
||||
|
||||
@if (Auth::check() && ! Auth::user()->registered)
|
||||
{!! Former::populateField('new_first_name', Auth::user()->first_name) !!}
|
||||
{!! Former::populateField('new_last_name', Auth::user()->last_name) !!}
|
||||
{!! Former::populateField('new_email', Auth::user()->email) !!}
|
||||
@endif
|
||||
|
||||
<div style="display:none">
|
||||
{!! Former::text('path')->value(Request::path()) !!}
|
||||
{!! Former::text('go_pro') !!}
|
||||
</div>
|
||||
|
||||
<div class="row signup-form">
|
||||
@if (! Auth::user()->registered)
|
||||
<div class="col-md-12">
|
||||
{!! Former::checkbox('terms_checkbox')
|
||||
->label(' ')
|
||||
->value(1)
|
||||
->text(trans('texts.agree_to_terms', ['terms' => '<a href="'.Utils::getTermsLink().'" target="_blank">'.trans('texts.terms_of_service').'</a>']))
|
||||
->raw() !!}
|
||||
<br/>
|
||||
</div>
|
||||
<br/> <br/>
|
||||
@endif
|
||||
@if (Utils::isOAuthEnabled() && ! Auth::user()->registered)
|
||||
<div class="col-md-5">
|
||||
@foreach (App\Services\AuthService::$providers as $provider)
|
||||
<a href="{{ URL::to('auth/' . $provider) }}" class="btn btn-primary btn-block"
|
||||
style="padding-top:10px;padding-bottom:10px;margin-top:10px;margin-bottom:10px"
|
||||
id="{{ strtolower($provider) }}LoginButton">
|
||||
<i class="fa fa-{{ strtolower($provider) }}"></i>
|
||||
{{ $provider }}
|
||||
</a>
|
||||
@endforeach
|
||||
</div>
|
||||
<div class="col-md-1">
|
||||
<div style="border-right:thin solid #CCCCCC;height:90px;width:8px;margin-bottom:10px;"></div>
|
||||
{{ trans('texts.or') }}
|
||||
<div style="border-right:thin solid #CCCCCC;height:90px;width:8px;margin-top:10px;"></div>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
@else
|
||||
<div class="col-md-12">
|
||||
@endif
|
||||
{{ Former::setOption('TwitterBootstrap3.labelWidths.large', 0) }}
|
||||
{{ Former::setOption('TwitterBootstrap3.labelWidths.small', 0) }}
|
||||
|
||||
{!! Former::text('new_first_name')
|
||||
->placeholder(trans('texts.first_name'))
|
||||
->autocomplete('given-name')
|
||||
->label(' ') !!}
|
||||
{!! Former::text('new_last_name')
|
||||
->placeholder(trans('texts.last_name'))
|
||||
->autocomplete('family-name')
|
||||
->label(' ') !!}
|
||||
{!! Former::text('new_email')
|
||||
->placeholder(trans('texts.email'))
|
||||
->autocomplete('email')
|
||||
->label(' ') !!}
|
||||
{!! Former::password('new_password')
|
||||
->placeholder(trans('texts.password'))
|
||||
->label(' ') !!}
|
||||
|
||||
{{ Former::setOption('TwitterBootstrap3.labelWidths.large', 4) }}
|
||||
{{ Former::setOption('TwitterBootstrap3.labelWidths.small', 4) }}
|
||||
</div>
|
||||
|
||||
<center><div id="errorTaken" style="display:none"> <br/><b>{{ trans('texts.email_taken') }}<b></div></center>
|
||||
|
||||
<div class="col-md-12">
|
||||
@if (Auth::user()->registered)
|
||||
<div style="padding-top:20px;padding-bottom:10px;">{!! trans('texts.email_alias_message') !!}</div>
|
||||
@elseif (Utils::isNinja())
|
||||
<div style="padding-top:20px;padding-bottom:10px;">{{ trans('texts.trial_message') }}</div>
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{!! Former::close() !!}
|
||||
|
||||
</div>
|
||||
|
||||
<div style="padding-left:40px;padding-right:40px;display:none;min-height:130px" id="working">
|
||||
<h3>{{ trans('texts.working') }}...</h3>
|
||||
<div class="progress progress-striped active">
|
||||
<div class="progress-bar" role="progressbar" aria-valuenow="100" aria-valuemin="0" aria-valuemax="100" style="width: 100%"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div style="background-color: #fff; padding-right:20px;padding-left:20px; display:none" id="signUpSuccessDiv">
|
||||
<br/>
|
||||
<h3>{{ trans('texts.success') }}</h3>
|
||||
<br/>
|
||||
@if (Utils::isNinja())
|
||||
{{ trans('texts.success_message') }}
|
||||
@endif
|
||||
<br/>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="modal-footer" id="signUpFooter" style="margin-top: 0px;padding-right:0px">
|
||||
<button type="button" class="btn btn-default" id="closeSignUpButton" data-dismiss="modal">{{ trans('texts.close') }} <i class="glyphicon glyphicon-remove-circle"></i></button>
|
||||
<button type="button" class="btn btn-primary" id="saveSignUpButton" onclick="validateServerSignUp()" disabled>{{ trans('texts.save') }} <i class="glyphicon glyphicon-floppy-disk"></i></button>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="modal fade" id="logoutModal" tabindex="-1" role="dialog" aria-labelledby="logoutModalLabel" 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">×</button>
|
||||
<h4 class="modal-title" id="myModalLabel">{{ trans('texts.logout') }}</h4>
|
||||
</div>
|
||||
|
||||
<div class="container">
|
||||
<h3>{{ trans('texts.are_you_sure') }}</h3>
|
||||
<p>{{ trans('texts.erase_data') }}</p>
|
||||
</div>
|
||||
|
||||
<div class="modal-footer" id="signUpFooter">
|
||||
<button type="button" class="btn btn-default" data-dismiss="modal">{{ trans('texts.cancel') }}</button>
|
||||
<button type="button" class="btn btn-danger" onclick="logout(true)">{{ trans('texts.logout') }}</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
@ -5,7 +5,7 @@
|
||||
|
||||
<center>
|
||||
@if (!session(SESSION_USER_ACCOUNTS) || count(session(SESSION_USER_ACCOUNTS)) < 5)
|
||||
{!! Button::success(trans('texts.add_company'))->asLinkTo(url('/invoice_now?new_company=true&sign_up=true')) !!}
|
||||
{!! Button::success(trans('texts.add_company'))->withAttributes(['onclick' => 'showSignUp()']) !!}
|
||||
@endif
|
||||
</center>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user