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_portal_password = !!Input::get('enable_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
|
||||
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();
|
||||
$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");
|
||||
}
|
||||
|
||||
@ -237,6 +237,7 @@ class OnlinePaymentController extends BaseController
|
||||
}
|
||||
|
||||
$data = [
|
||||
'currency_id' => $account->currency_id,
|
||||
'contact' => Input::all()
|
||||
];
|
||||
$client = $clientRepo->save($data);
|
||||
|
@ -753,6 +753,7 @@ if (!defined('CONTACT_EMAIL')) {
|
||||
define('FEATURE_TASKS', 'tasks');
|
||||
define('FEATURE_EXPENSES', 'expenses');
|
||||
define('FEATURE_REPORTS', 'reports');
|
||||
define('FEATURE_BUY_NOW_BUTTONS', 'buy_now_buttons');
|
||||
define('FEATURE_API', 'api');
|
||||
define('FEATURE_CLIENT_PORTAL_PASSWORD', 'client_portal_password');
|
||||
define('FEATURE_CUSTOM_URL', 'custom_url');
|
||||
|
@ -1170,6 +1170,7 @@ class Account extends Eloquent
|
||||
case FEATURE_MORE_INVOICE_DESIGNS:
|
||||
case FEATURE_QUOTES:
|
||||
case FEATURE_REPORTS:
|
||||
case FEATURE_BUY_NOW_BUTTONS:
|
||||
case FEATURE_API:
|
||||
case FEATURE_CLIENT_PORTAL_PASSWORD:
|
||||
case FEATURE_CUSTOM_URL:
|
||||
|
@ -282,19 +282,29 @@ class BasePaymentDriver
|
||||
|
||||
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)) {
|
||||
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) {
|
||||
return;
|
||||
}
|
||||
|
||||
// update the address info
|
||||
$client = $this->client();
|
||||
$client->address1 = trim($this->input['address1']);
|
||||
$client->address2 = trim($this->input['address2']);
|
||||
|
@ -202,6 +202,7 @@ class AccountRepository
|
||||
['new_user', '/users/create'],
|
||||
['custom_fields', '/settings/invoice_settings'],
|
||||
['invoice_number', '/settings/invoice_settings'],
|
||||
['buy_now_buttons', '/settings/client_portal#buyNow']
|
||||
]);
|
||||
|
||||
$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',
|
||||
'link' => 'Link',
|
||||
'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_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('enable_portal_password', intval($enable_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))
|
||||
<div class="alert alert-warning" style="font-size:larger;">
|
||||
@ -83,15 +84,23 @@
|
||||
<h3 class="panel-title">{!! trans('texts.buy_now_buttons') !!}</h3>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<div class="col-md-10 col-md-offset-1">
|
||||
<div class="col-md-10 col-md-offset-1" id="buyNow">
|
||||
|
||||
@if (count($gateway_types) && count($products))
|
||||
|
||||
{!! Former::checkbox('enable_buy_now_buttons')
|
||||
->text(trans('texts.enable'))
|
||||
->label(' ')
|
||||
->help(trans('texts.enable_buy_now_buttons_help')) !!}
|
||||
|
||||
@if ($account->enable_buy_now_buttons)
|
||||
{!! Former::select('product')
|
||||
->onchange('updateBuyNowButtons()')
|
||||
->addOption('', '')
|
||||
->inlineHelp('buy_now_buttons_warning')
|
||||
->addGroupClass('product-select') !!}
|
||||
|
||||
{!! Former::inline_checkboxes('client_fields')
|
||||
{!! Former::checkboxes('client_fields')
|
||||
->onchange('updateBuyNowButtons()')
|
||||
->checkboxes([
|
||||
trans('texts.first_name') => ['value' => 'first_name', 'name' => 'first_name'],
|
||||
@ -133,6 +142,16 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@endif
|
||||
|
||||
@else
|
||||
|
||||
<center style="font-size:16px;color:#888888;">
|
||||
{{ trans('texts.buy_now_buttons_disabled') }}
|
||||
</center>
|
||||
|
||||
@endif
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -148,7 +167,6 @@
|
||||
->label(trans('texts.custom_css'))
|
||||
->rows(10)
|
||||
->raw()
|
||||
->autofocus()
|
||||
->maxlength(60000)
|
||||
->style("min-width:100%;max-width:100%;font-family:'Roboto Mono', 'Lucida Console', Monaco, monospace;font-size:14px;'") !!}
|
||||
</div>
|
||||
|
@ -46,7 +46,11 @@
|
||||
var $clientSelect = $('select#client');
|
||||
for (var i=0; i<clients.length; 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' }}) {
|
||||
|
@ -257,7 +257,11 @@
|
||||
var $clientSelect = $('select#client_id');
|
||||
for (var i=0; i<clients.length; 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() {
|
||||
onClientChange();
|
||||
|
@ -789,6 +789,9 @@
|
||||
for (var i=0; i<clients.length; i++) {
|
||||
var client = clients[i];
|
||||
var clientName = getClientDisplayName(client);
|
||||
if (!clientName) {
|
||||
continue;
|
||||
}
|
||||
for (var j=0; j<client.contacts.length; j++) {
|
||||
var contact = client.contacts[j];
|
||||
var contactName = getContactDisplayName(contact);
|
||||
|
@ -408,7 +408,11 @@
|
||||
var $clientSelect = $('select#client');
|
||||
for (var i=0; i<clients.length; 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' }}) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user