mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Working on buy now buttons
This commit is contained in:
parent
401851e212
commit
fa9b0bf78b
@ -827,6 +827,7 @@ class AccountController extends BaseController
|
|||||||
$account->enable_client_portal_dashboard = !!Input::get('enable_client_portal_dashboard');
|
$account->enable_client_portal_dashboard = !!Input::get('enable_client_portal_dashboard');
|
||||||
$account->enable_portal_password = !!Input::get('enable_portal_password');
|
$account->enable_portal_password = !!Input::get('enable_portal_password');
|
||||||
$account->send_portal_password = !!Input::get('send_portal_password');
|
$account->send_portal_password = !!Input::get('send_portal_password');
|
||||||
|
$account->enable_buy_now_buttons = !!Input::get('enable_buy_now_buttons');
|
||||||
|
|
||||||
// Only allowed for pro Invoice Ninja users or white labeled self-hosted users
|
// Only allowed for pro Invoice Ninja users or white labeled self-hosted users
|
||||||
if (Auth::user()->account->hasFeature(FEATURE_CLIENT_PORTAL_CSS)) {
|
if (Auth::user()->account->hasFeature(FEATURE_CLIENT_PORTAL_CSS)) {
|
||||||
|
@ -214,7 +214,7 @@ class OnlinePaymentController extends BaseController
|
|||||||
$account = Account::whereAccountKey(Input::get('account_key'))->first();
|
$account = Account::whereAccountKey(Input::get('account_key'))->first();
|
||||||
$redirectUrl = Input::get('redirect_url', URL::previous());
|
$redirectUrl = Input::get('redirect_url', URL::previous());
|
||||||
|
|
||||||
if ( ! $account) {
|
if ( ! $account || ! $account->enable_buy_now_buttons || ! $account->hasFeature(FEATURE_BUY_NOW_BUTTONS)) {
|
||||||
return redirect()->to("{$redirectUrl}/?error=invalid account");
|
return redirect()->to("{$redirectUrl}/?error=invalid account");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -237,6 +237,7 @@ class OnlinePaymentController extends BaseController
|
|||||||
}
|
}
|
||||||
|
|
||||||
$data = [
|
$data = [
|
||||||
|
'currency_id' => $account->currency_id,
|
||||||
'contact' => Input::all()
|
'contact' => Input::all()
|
||||||
];
|
];
|
||||||
$client = $clientRepo->save($data);
|
$client = $clientRepo->save($data);
|
||||||
|
@ -753,6 +753,7 @@ if (!defined('CONTACT_EMAIL')) {
|
|||||||
define('FEATURE_TASKS', 'tasks');
|
define('FEATURE_TASKS', 'tasks');
|
||||||
define('FEATURE_EXPENSES', 'expenses');
|
define('FEATURE_EXPENSES', 'expenses');
|
||||||
define('FEATURE_REPORTS', 'reports');
|
define('FEATURE_REPORTS', 'reports');
|
||||||
|
define('FEATURE_BUY_NOW_BUTTONS', 'buy_now_buttons');
|
||||||
define('FEATURE_API', 'api');
|
define('FEATURE_API', 'api');
|
||||||
define('FEATURE_CLIENT_PORTAL_PASSWORD', 'client_portal_password');
|
define('FEATURE_CLIENT_PORTAL_PASSWORD', 'client_portal_password');
|
||||||
define('FEATURE_CUSTOM_URL', 'custom_url');
|
define('FEATURE_CUSTOM_URL', 'custom_url');
|
||||||
|
@ -1170,6 +1170,7 @@ class Account extends Eloquent
|
|||||||
case FEATURE_MORE_INVOICE_DESIGNS:
|
case FEATURE_MORE_INVOICE_DESIGNS:
|
||||||
case FEATURE_QUOTES:
|
case FEATURE_QUOTES:
|
||||||
case FEATURE_REPORTS:
|
case FEATURE_REPORTS:
|
||||||
|
case FEATURE_BUY_NOW_BUTTONS:
|
||||||
case FEATURE_API:
|
case FEATURE_API:
|
||||||
case FEATURE_CLIENT_PORTAL_PASSWORD:
|
case FEATURE_CLIENT_PORTAL_PASSWORD:
|
||||||
case FEATURE_CUSTOM_URL:
|
case FEATURE_CUSTOM_URL:
|
||||||
|
@ -282,19 +282,29 @@ class BasePaymentDriver
|
|||||||
|
|
||||||
private function updateClient()
|
private function updateClient()
|
||||||
{
|
{
|
||||||
if ( ! $this->contact()->email && $this->input['email']) {
|
|
||||||
$this->contact()->email = $this->input['email'];
|
|
||||||
$this->contact()->save();
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( ! $this->isGatewayType(GATEWAY_TYPE_CREDIT_CARD)) {
|
if ( ! $this->isGatewayType(GATEWAY_TYPE_CREDIT_CARD)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// update the contact info
|
||||||
|
if ( ! $this->contact()->getFullName()) {
|
||||||
|
$this->contact()->first_name = $this->input['first_name'];
|
||||||
|
$this->contact()->last_name = $this->input['last_name'];
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( ! $this->contact()->email) {
|
||||||
|
$this->contact()->email = $this->input['email'];
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($this->contact()->isDirty()) {
|
||||||
|
$this->contact()->save();
|
||||||
|
}
|
||||||
|
|
||||||
if ( ! $this->accountGateway->show_address || ! $this->accountGateway->update_address) {
|
if ( ! $this->accountGateway->show_address || ! $this->accountGateway->update_address) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// update the address info
|
||||||
$client = $this->client();
|
$client = $this->client();
|
||||||
$client->address1 = trim($this->input['address1']);
|
$client->address1 = trim($this->input['address1']);
|
||||||
$client->address2 = trim($this->input['address2']);
|
$client->address2 = trim($this->input['address2']);
|
||||||
|
@ -202,6 +202,7 @@ class AccountRepository
|
|||||||
['new_user', '/users/create'],
|
['new_user', '/users/create'],
|
||||||
['custom_fields', '/settings/invoice_settings'],
|
['custom_fields', '/settings/invoice_settings'],
|
||||||
['invoice_number', '/settings/invoice_settings'],
|
['invoice_number', '/settings/invoice_settings'],
|
||||||
|
['buy_now_buttons', '/settings/client_portal#buyNow']
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$settings = array_merge(Account::$basicSettings, Account::$advancedSettings);
|
$settings = array_merge(Account::$basicSettings, Account::$advancedSettings);
|
||||||
|
@ -0,0 +1,55 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
|
||||||
|
class AddBuyNowButtons extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::table('accounts', function($table)
|
||||||
|
{
|
||||||
|
$table->boolean('enable_buy_now_buttons')->default(false);
|
||||||
|
$table->dropColumn('invoice_design');
|
||||||
|
});
|
||||||
|
|
||||||
|
Schema::table('datetime_formats', function($table)
|
||||||
|
{
|
||||||
|
$table->dropColumn('label');
|
||||||
|
});
|
||||||
|
|
||||||
|
Schema::table('date_formats', function($table)
|
||||||
|
{
|
||||||
|
$table->dropColumn('label');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::table('accounts', function($table)
|
||||||
|
{
|
||||||
|
$table->dropColumn('enable_buy_now_buttons');
|
||||||
|
$table->text('invoice_design')->nullable();
|
||||||
|
});
|
||||||
|
|
||||||
|
Schema::table('datetime_formats', function($table)
|
||||||
|
{
|
||||||
|
$table->string('label');
|
||||||
|
});
|
||||||
|
|
||||||
|
Schema::table('date_formats', function($table)
|
||||||
|
{
|
||||||
|
$table->string('label');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
@ -2034,7 +2034,10 @@ $LANG = array(
|
|||||||
'form' => 'Form',
|
'form' => 'Form',
|
||||||
'link' => 'Link',
|
'link' => 'Link',
|
||||||
'fields' => 'Fields',
|
'fields' => 'Fields',
|
||||||
|
'dwolla' => 'Dwolla',
|
||||||
'buy_now_buttons_warning' => 'Note: client and invoice records are created even if the transaction isn\'t completed.',
|
'buy_now_buttons_warning' => 'Note: client and invoice records are created even if the transaction isn\'t completed.',
|
||||||
|
'buy_now_buttons_disabled' => 'This feature requires that a product is created and a payment gateway is configured.',
|
||||||
|
'enable_buy_now_buttons_help' => 'Enable support for buy now buttons',
|
||||||
|
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
{!! Former::populateField('client_view_css', $client_view_css) !!}
|
{!! Former::populateField('client_view_css', $client_view_css) !!}
|
||||||
{!! Former::populateField('enable_portal_password', intval($enable_portal_password)) !!}
|
{!! Former::populateField('enable_portal_password', intval($enable_portal_password)) !!}
|
||||||
{!! Former::populateField('send_portal_password', intval($send_portal_password)) !!}
|
{!! Former::populateField('send_portal_password', intval($send_portal_password)) !!}
|
||||||
|
{!! Former::populateField('enable_buy_now_buttons', intval($account->enable_buy_now_buttons)) !!}
|
||||||
|
|
||||||
@if (!Utils::isNinja() && !Auth::user()->account->hasFeature(FEATURE_WHITE_LABEL))
|
@if (!Utils::isNinja() && !Auth::user()->account->hasFeature(FEATURE_WHITE_LABEL))
|
||||||
<div class="alert alert-warning" style="font-size:larger;">
|
<div class="alert alert-warning" style="font-size:larger;">
|
||||||
@ -83,55 +84,73 @@
|
|||||||
<h3 class="panel-title">{!! trans('texts.buy_now_buttons') !!}</h3>
|
<h3 class="panel-title">{!! trans('texts.buy_now_buttons') !!}</h3>
|
||||||
</div>
|
</div>
|
||||||
<div class="panel-body">
|
<div class="panel-body">
|
||||||
<div class="col-md-10 col-md-offset-1">
|
<div class="col-md-10 col-md-offset-1" id="buyNow">
|
||||||
|
|
||||||
{!! Former::select('product')
|
@if (count($gateway_types) && count($products))
|
||||||
->onchange('updateBuyNowButtons()')
|
|
||||||
->addOption('', '')
|
|
||||||
->inlineHelp('buy_now_buttons_warning')
|
|
||||||
->addGroupClass('product-select') !!}
|
|
||||||
|
|
||||||
{!! Former::inline_checkboxes('client_fields')
|
{!! Former::checkbox('enable_buy_now_buttons')
|
||||||
->onchange('updateBuyNowButtons()')
|
->text(trans('texts.enable'))
|
||||||
->checkboxes([
|
->label(' ')
|
||||||
trans('texts.first_name') => ['value' => 'first_name', 'name' => 'first_name'],
|
->help(trans('texts.enable_buy_now_buttons_help')) !!}
|
||||||
trans('texts.last_name') => ['value' => 'last_name', 'name' => 'last_name'],
|
|
||||||
trans('texts.email') => ['value' => 'email', 'name' => 'email'],
|
|
||||||
]) !!}
|
|
||||||
|
|
||||||
{!! Former::inline_radios('landing_page')
|
@if ($account->enable_buy_now_buttons)
|
||||||
->onchange('showPaymentTypes();updateBuyNowButtons();')
|
{!! Former::select('product')
|
||||||
->radios([
|
->onchange('updateBuyNowButtons()')
|
||||||
trans('texts.invoice') => ['value' => 'invoice', 'name' => 'landing_page_type'],
|
->addOption('', '')
|
||||||
trans('texts.payment') => ['value' => 'payment', 'name' => 'landing_page_type'],
|
->inlineHelp('buy_now_buttons_warning')
|
||||||
])->check('invoice') !!}
|
->addGroupClass('product-select') !!}
|
||||||
|
|
||||||
<div id="paymentTypesDiv" style="display:none">
|
{!! Former::checkboxes('client_fields')
|
||||||
{!! Former::select('payment_type')
|
->onchange('updateBuyNowButtons()')
|
||||||
->onchange('updateBuyNowButtons()')
|
->checkboxes([
|
||||||
->options($gateway_types) !!}
|
trans('texts.first_name') => ['value' => 'first_name', 'name' => 'first_name'],
|
||||||
</div>
|
trans('texts.last_name') => ['value' => 'last_name', 'name' => 'last_name'],
|
||||||
|
trans('texts.email') => ['value' => 'email', 'name' => 'email'],
|
||||||
|
]) !!}
|
||||||
|
|
||||||
<p> </p>
|
{!! Former::inline_radios('landing_page')
|
||||||
|
->onchange('showPaymentTypes();updateBuyNowButtons();')
|
||||||
|
->radios([
|
||||||
|
trans('texts.invoice') => ['value' => 'invoice', 'name' => 'landing_page_type'],
|
||||||
|
trans('texts.payment') => ['value' => 'payment', 'name' => 'landing_page_type'],
|
||||||
|
])->check('invoice') !!}
|
||||||
|
|
||||||
<div role="tabpanel">
|
<div id="paymentTypesDiv" style="display:none">
|
||||||
<ul class="nav nav-tabs" role="tablist" style="border: none">
|
{!! Former::select('payment_type')
|
||||||
<li role="presentation" class="active">
|
->onchange('updateBuyNowButtons()')
|
||||||
<a href="#form" aria-controls="form" role="tab" data-toggle="tab">{{ trans('texts.form') }}</a>
|
->options($gateway_types) !!}
|
||||||
</li>
|
</div>
|
||||||
<li role="presentation">
|
|
||||||
<a href="#link" aria-controls="link" role="tab" data-toggle="tab">{{ trans('texts.link') }}</a>
|
<p> </p>
|
||||||
</li>
|
|
||||||
</ul>
|
<div role="tabpanel">
|
||||||
</div>
|
<ul class="nav nav-tabs" role="tablist" style="border: none">
|
||||||
<div class="tab-content">
|
<li role="presentation" class="active">
|
||||||
<div role="tabpanel" class="tab-pane active" id="form">
|
<a href="#form" aria-controls="form" role="tab" data-toggle="tab">{{ trans('texts.form') }}</a>
|
||||||
<textarea id="formTextarea" class="form-control" rows="4" readonly></textarea>
|
</li>
|
||||||
</div>
|
<li role="presentation">
|
||||||
<div role="tabpanel" class="tab-pane" id="link">
|
<a href="#link" aria-controls="link" role="tab" data-toggle="tab">{{ trans('texts.link') }}</a>
|
||||||
<textarea id="linkTextarea" class="form-control" rows="4" readonly></textarea>
|
</li>
|
||||||
</div>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="tab-content">
|
||||||
|
<div role="tabpanel" class="tab-pane active" id="form">
|
||||||
|
<textarea id="formTextarea" class="form-control" rows="4" readonly></textarea>
|
||||||
|
</div>
|
||||||
|
<div role="tabpanel" class="tab-pane" id="link">
|
||||||
|
<textarea id="linkTextarea" class="form-control" rows="4" readonly></textarea>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
@endif
|
||||||
|
|
||||||
|
@else
|
||||||
|
|
||||||
|
<center style="font-size:16px;color:#888888;">
|
||||||
|
{{ trans('texts.buy_now_buttons_disabled') }}
|
||||||
|
</center>
|
||||||
|
|
||||||
|
@endif
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -148,7 +167,6 @@
|
|||||||
->label(trans('texts.custom_css'))
|
->label(trans('texts.custom_css'))
|
||||||
->rows(10)
|
->rows(10)
|
||||||
->raw()
|
->raw()
|
||||||
->autofocus()
|
|
||||||
->maxlength(60000)
|
->maxlength(60000)
|
||||||
->style("min-width:100%;max-width:100%;font-family:'Roboto Mono', 'Lucida Console', Monaco, monospace;font-size:14px;'") !!}
|
->style("min-width:100%;max-width:100%;font-family:'Roboto Mono', 'Lucida Console', Monaco, monospace;font-size:14px;'") !!}
|
||||||
</div>
|
</div>
|
||||||
|
@ -46,7 +46,11 @@
|
|||||||
var $clientSelect = $('select#client');
|
var $clientSelect = $('select#client');
|
||||||
for (var i=0; i<clients.length; i++) {
|
for (var i=0; i<clients.length; i++) {
|
||||||
var client = clients[i];
|
var client = clients[i];
|
||||||
$clientSelect.append(new Option(getClientDisplayName(client), client.public_id));
|
var clientName = getClientDisplayName(client);
|
||||||
|
if (!clientName) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$clientSelect.append(new Option(clientName, client.public_id));
|
||||||
}
|
}
|
||||||
|
|
||||||
if ({{ $clientPublicId ? 'true' : 'false' }}) {
|
if ({{ $clientPublicId ? 'true' : 'false' }}) {
|
||||||
|
@ -257,7 +257,11 @@
|
|||||||
var $clientSelect = $('select#client_id');
|
var $clientSelect = $('select#client_id');
|
||||||
for (var i=0; i<clients.length; i++) {
|
for (var i=0; i<clients.length; i++) {
|
||||||
var client = clients[i];
|
var client = clients[i];
|
||||||
$clientSelect.append(new Option(getClientDisplayName(client), client.public_id));
|
var clientName = getClientDisplayName(client);
|
||||||
|
if (!clientName) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$clientSelect.append(new Option(clientName, client.public_id));
|
||||||
}
|
}
|
||||||
$clientSelect.combobox().change(function() {
|
$clientSelect.combobox().change(function() {
|
||||||
onClientChange();
|
onClientChange();
|
||||||
|
@ -789,6 +789,9 @@
|
|||||||
for (var i=0; i<clients.length; i++) {
|
for (var i=0; i<clients.length; i++) {
|
||||||
var client = clients[i];
|
var client = clients[i];
|
||||||
var clientName = getClientDisplayName(client);
|
var clientName = getClientDisplayName(client);
|
||||||
|
if (!clientName) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
for (var j=0; j<client.contacts.length; j++) {
|
for (var j=0; j<client.contacts.length; j++) {
|
||||||
var contact = client.contacts[j];
|
var contact = client.contacts[j];
|
||||||
var contactName = getContactDisplayName(contact);
|
var contactName = getContactDisplayName(contact);
|
||||||
|
@ -408,7 +408,11 @@
|
|||||||
var $clientSelect = $('select#client');
|
var $clientSelect = $('select#client');
|
||||||
for (var i=0; i<clients.length; i++) {
|
for (var i=0; i<clients.length; i++) {
|
||||||
var client = clients[i];
|
var client = clients[i];
|
||||||
$clientSelect.append(new Option(getClientDisplayName(client), client.public_id));
|
var clientName = getClientDisplayName(client);
|
||||||
|
if (!clientName) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$clientSelect.append(new Option(clientName, client.public_id));
|
||||||
}
|
}
|
||||||
|
|
||||||
if ({{ $clientPublicId ? 'true' : 'false' }}) {
|
if ({{ $clientPublicId ? 'true' : 'false' }}) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user