mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-06-23 20:00:33 -04:00
Added additional custom designs
This commit is contained in:
parent
e8437a9bbd
commit
091e3ed1b2
@ -207,7 +207,9 @@ if (! defined('APP_NAME')) {
|
||||
define('EXPENSE_STATUS_PAID', 5);
|
||||
define('EXPENSE_STATUS_UNPAID', 6);
|
||||
|
||||
define('CUSTOM_DESIGN', 11);
|
||||
define('CUSTOM_DESIGN1', 11);
|
||||
define('CUSTOM_DESIGN2', 12);
|
||||
define('CUSTOM_DESIGN3', 13);
|
||||
|
||||
define('FREQUENCY_WEEKLY', 1);
|
||||
define('FREQUENCY_TWO_WEEKS', 2);
|
||||
@ -343,7 +345,6 @@ if (! defined('APP_NAME')) {
|
||||
define('DB_NINJA_2', 'db-ninja-2');
|
||||
|
||||
define('COUNT_FREE_DESIGNS', 4);
|
||||
define('COUNT_FREE_DESIGNS_SELF_HOST', 5); // include the custom design
|
||||
define('PRODUCT_ONE_CLICK_INSTALL', 1);
|
||||
define('PRODUCT_INVOICE_DESIGNS', 2);
|
||||
define('PRODUCT_WHITE_LABEL', 3);
|
||||
|
@ -572,7 +572,11 @@ class AccountController extends BaseController
|
||||
}
|
||||
|
||||
if ($section == ACCOUNT_CUSTOMIZE_DESIGN) {
|
||||
$data['customDesign'] = ($account->custom_design && ! $design) ? $account->custom_design : $design;
|
||||
if ($custom = $account->getCustomDesign(request()->design_id)) {
|
||||
$data['customDesign'] = $custom;
|
||||
} else {
|
||||
$data['customDesign'] = $design;
|
||||
}
|
||||
|
||||
// sample invoice to help determine variables
|
||||
$invoice = Invoice::scope()
|
||||
@ -737,16 +741,21 @@ class AccountController extends BaseController
|
||||
*/
|
||||
private function saveCustomizeDesign()
|
||||
{
|
||||
$designId = intval(Input::get('design_id')) ?: CUSTOM_DESIGN1;
|
||||
$field = 'custom_design' . ($designId - 10);
|
||||
|
||||
if (Auth::user()->account->hasFeature(FEATURE_CUSTOMIZE_INVOICE_DESIGN)) {
|
||||
$account = Auth::user()->account;
|
||||
$account->custom_design = Input::get('custom_design');
|
||||
$account->invoice_design_id = CUSTOM_DESIGN;
|
||||
if (! $account->custom_design1) {
|
||||
$account->invoice_design_id = CUSTOM_DESIGN1;
|
||||
}
|
||||
$account->$field = Input::get('custom_design');
|
||||
$account->save();
|
||||
|
||||
Session::flash('message', trans('texts.updated_settings'));
|
||||
}
|
||||
|
||||
return Redirect::to('settings/'.ACCOUNT_CUSTOMIZE_DESIGN);
|
||||
return Redirect::to('settings/' . ACCOUNT_CUSTOMIZE_DESIGN . '?design_id=' . $designId);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -952,6 +961,7 @@ class AccountController extends BaseController
|
||||
$account->primary_color = Input::get('primary_color');
|
||||
$account->secondary_color = Input::get('secondary_color');
|
||||
$account->invoice_design_id = Input::get('invoice_design_id');
|
||||
$account->quote_design_id = Input::get('quote_design_id');
|
||||
$account->font_size = intval(Input::get('font_size'));
|
||||
$account->page_size = Input::get('page_size');
|
||||
|
||||
|
@ -91,8 +91,8 @@ class ClientPortalController extends BaseController
|
||||
];
|
||||
$invoice->invoice_fonts = $account->getFontsData();
|
||||
|
||||
if ($invoice->invoice_design_id == CUSTOM_DESIGN) {
|
||||
$invoice->invoice_design->javascript = $account->custom_design;
|
||||
if ($design = $account->getCustomDesign($invoice->getDesignId())) {
|
||||
$invoice->invoice_design->javascript = $design;
|
||||
} else {
|
||||
$invoice->invoice_design->javascript = $invoice->invoice_design->pdfmake;
|
||||
}
|
||||
|
@ -251,6 +251,10 @@ class InvoiceApiController extends BaseAPIController
|
||||
$fields['due_date_sql'] = false;
|
||||
}
|
||||
|
||||
if (isset($data['is_quote']) && filter_var($data['is_quote'], FILTER_VALIDATE_BOOLEAN)) {
|
||||
$fields['invoice_design_id'] = $account->quote_design_id;
|
||||
}
|
||||
|
||||
foreach ($fields as $key => $val) {
|
||||
if (! isset($data[$key])) {
|
||||
$data[$key] = $val;
|
||||
|
@ -35,8 +35,7 @@ class InvoiceListener
|
||||
$invoice = $event->invoice;
|
||||
$account = Auth::user()->account;
|
||||
|
||||
if ($invoice->invoice_design_id
|
||||
&& $account->invoice_design_id != $invoice->invoice_design_id) {
|
||||
if ($invoice->invoice_design_id && $account->invoice_design_id != $invoice->invoice_design_id) {
|
||||
$account->invoice_design_id = $invoice->invoice_design_id;
|
||||
$account->save();
|
||||
}
|
||||
|
@ -68,6 +68,7 @@ class Account extends Eloquent
|
||||
'invoice_taxes',
|
||||
'invoice_item_taxes',
|
||||
'invoice_design_id',
|
||||
'quote_design_id',
|
||||
'work_phone',
|
||||
'work_email',
|
||||
'language_id',
|
||||
@ -885,6 +886,7 @@ class Account extends Eloquent
|
||||
} else {
|
||||
if ($entityType == ENTITY_QUOTE) {
|
||||
$invoice->invoice_type_id = INVOICE_TYPE_QUOTE;
|
||||
$invoice->invoice_design_id = $this->quote_design_id;
|
||||
}
|
||||
|
||||
if ($this->hasClientNumberPattern($invoice) && ! $clientId) {
|
||||
|
@ -48,6 +48,7 @@ class Invoice extends EntityModel implements BalanceAffecting
|
||||
'tax_rate2',
|
||||
'private_notes',
|
||||
'last_sent_date',
|
||||
'invoice_design_id',
|
||||
];
|
||||
|
||||
/**
|
||||
@ -593,6 +594,11 @@ class Invoice extends EntityModel implements BalanceAffecting
|
||||
return $this->is_recurring ? trans('texts.recurring') : $this->invoice_number;
|
||||
}
|
||||
|
||||
public function getDesignId()
|
||||
{
|
||||
return $this->isQuote() ? $this->quote_design_id : $this->invoice_design_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
|
@ -83,11 +83,11 @@ class InvoiceDesign extends Eloquent
|
||||
$design->javascript = $design->pdfmake;
|
||||
$design->pdfmake = null;
|
||||
|
||||
if ($design->id == CUSTOM_DESIGN) {
|
||||
if ($account->custom_design) {
|
||||
$design->javascript = $account->custom_design;
|
||||
if (in_array($design->id, [CUSTOM_DESIGN1, CUSTOM_DESIGN2, CUSTOM_DESIGN3])) {
|
||||
if ($javascript = $account->getCustomDesign($design->id)) {
|
||||
$design->javascript = $javascript;
|
||||
} else {
|
||||
$designs->pop();
|
||||
$designs->forget($design->id - 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -292,4 +292,16 @@ trait PresentsInvoice
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function getCustomDesign($designId) {
|
||||
if ($designId == CUSTOM_DESIGN1) {
|
||||
return $this->custom_design1;
|
||||
} elseif ($designId == CUSTOM_DESIGN2) {
|
||||
return $this->custom_design2;
|
||||
} elseif ($designId == CUSTOM_DESIGN3) {
|
||||
return $this->custom_design3;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -147,7 +147,7 @@ class User extends Authenticatable
|
||||
*/
|
||||
public function maxInvoiceDesignId()
|
||||
{
|
||||
return $this->hasFeature(FEATURE_MORE_INVOICE_DESIGNS) ? 11 : (Utils::isNinja() ? COUNT_FREE_DESIGNS : COUNT_FREE_DESIGNS_SELF_HOST);
|
||||
return $this->hasFeature(FEATURE_MORE_INVOICE_DESIGNS) ? 13 : COUNT_FREE_DESIGNS;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -175,4 +175,24 @@ class AccountPresenter extends Presenter
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function customDesigns()
|
||||
{
|
||||
$account = $this->entity;
|
||||
$data = [];
|
||||
|
||||
for ($i=1; $i<=3; $i++) {
|
||||
$label = trans('texts.custom_design' . $i);
|
||||
if (! $account->{'custom_design' . $i}) {
|
||||
$label .= ' - ' . trans('texts.empty');
|
||||
}
|
||||
|
||||
$data[] = [
|
||||
'url' => url('/settings/customize_design?design_id=') . ($i + 10),
|
||||
'label' => $label
|
||||
];
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
|
@ -470,8 +470,6 @@ class InvoiceRepository extends BaseRepository
|
||||
$invoice->po_number = trim($data['po_number']);
|
||||
}
|
||||
|
||||
$invoice->invoice_design_id = isset($data['invoice_design_id']) ? $data['invoice_design_id'] : $account->invoice_design_id;
|
||||
|
||||
// provide backwards compatibility
|
||||
if (isset($data['tax_name']) && isset($data['tax_rate'])) {
|
||||
$data['tax_name1'] = $data['tax_name'];
|
||||
|
@ -171,6 +171,7 @@ class AccountTransformer extends EntityTransformer
|
||||
'invoice_taxes' => (bool) $account->invoice_taxes,
|
||||
'invoice_item_taxes' => (bool) $account->invoice_item_taxes,
|
||||
'invoice_design_id' => (int) $account->invoice_design_id,
|
||||
'quote_design_id' => (int) $account->quote_design_id,
|
||||
'client_view_css' => (string) $account->client_view_css,
|
||||
'work_phone' => $account->work_phone,
|
||||
'work_email' => $account->work_email,
|
||||
|
@ -15,7 +15,7 @@ class AddCustomDesign extends Migration
|
||||
$table->mediumText('custom_design')->nullable();
|
||||
});
|
||||
|
||||
DB::table('invoice_designs')->insert(['id' => CUSTOM_DESIGN, 'name' => 'Custom']);
|
||||
DB::table('invoice_designs')->insert(['id' => CUSTOM_DESIGN1, 'name' => 'Custom']);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -63,6 +63,21 @@ class AddDefaultNoteToClient extends Migration
|
||||
$table->unique(['oauth_user_id', 'oauth_provider_id']);
|
||||
});
|
||||
}
|
||||
|
||||
Schema::table('accounts', function ($table) {
|
||||
$table->unsignedInteger('quote_design_id')->default(1);
|
||||
$table->renameColumn('custom_design', 'custom_design1');
|
||||
$table->mediumText('custom_design2')->nullable();
|
||||
$table->mediumText('custom_design3')->nullable();
|
||||
});
|
||||
|
||||
DB::statement('update accounts
|
||||
set quote_design_id = invoice_design_id');
|
||||
|
||||
DB::statement('update invoice_designs
|
||||
set name = "Custom1"
|
||||
where id = 11
|
||||
and name = "Custom"');
|
||||
}
|
||||
|
||||
/**
|
||||
@ -97,5 +112,12 @@ class AddDefaultNoteToClient extends Migration
|
||||
$table->dropColumn('tax_name2');
|
||||
$table->dropColumn('tax_rate2');
|
||||
});
|
||||
|
||||
Schema::table('accounts', function ($table) {
|
||||
$table->renameColumn('custom_design1', 'custom_design');
|
||||
$table->dropColumn('custom_design2');
|
||||
$table->dropColumn('custom_design3');
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -20,7 +20,7 @@ class InvoiceDesignsSeeder extends Seeder
|
||||
'Playful',
|
||||
'Photo',
|
||||
];
|
||||
|
||||
|
||||
for ($i = 0; $i < count($designs); $i++) {
|
||||
$design = $designs[$i];
|
||||
$fileName = storage_path() . '/templates/' . strtolower($design) . '.js';
|
||||
@ -38,5 +38,15 @@ class InvoiceDesignsSeeder extends Seeder
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for ($i = 1; $i <= 3; $i++) {
|
||||
$name = 'Custom' . $i;
|
||||
if (! InvoiceDesign::whereName($name)->first()) {
|
||||
InvoiceDesign::create([
|
||||
'id' => $i + 10,
|
||||
'name' => $name,
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ class UserTableSeeder extends Seeder
|
||||
'invoice_terms' => $faker->text($faker->numberBetween(50, 300)),
|
||||
'work_phone' => $faker->phoneNumber,
|
||||
'work_email' => $faker->safeEmail,
|
||||
'invoice_design_id' => InvoiceDesign::where('id', '<', CUSTOM_DESIGN)->get()->random()->id,
|
||||
'invoice_design_id' => InvoiceDesign::where('id', '<', CUSTOM_DESIGN1)->get()->random()->id,
|
||||
'header_font_id' => min(Font::all()->random()->id, 17),
|
||||
'body_font_id' => min(Font::all()->random()->id, 17),
|
||||
'primary_color' => $faker->hexcolor,
|
||||
|
File diff suppressed because one or more lines are too long
@ -2254,7 +2254,13 @@ $LANG = array(
|
||||
'expense_link' => 'expense',
|
||||
'resume_task' => 'Resume Task',
|
||||
'resumed_task' => 'Successfully resumed task',
|
||||
|
||||
'quote_design' => 'Quote Design',
|
||||
'default_design' => 'Default Design',
|
||||
'custom_design1' => 'Custom Design 1',
|
||||
'custom_design2' => 'Custom Design 2',
|
||||
'custom_design3' => 'Custom Design 3',
|
||||
'empty' => 'Empty',
|
||||
'select_design' => 'Select Design',
|
||||
);
|
||||
|
||||
return $LANG;
|
||||
|
@ -168,7 +168,6 @@
|
||||
<div class="col-md-6">
|
||||
|
||||
{!! Former::open()->addClass('warn-on-exit') !!}
|
||||
{!! Former::populateField('invoice_design_id', $account->invoice_design_id) !!}
|
||||
|
||||
<div style="display:none">
|
||||
{!! Former::text('custom_design') !!}
|
||||
@ -189,7 +188,12 @@
|
||||
<p> </p>
|
||||
|
||||
<div>
|
||||
{!! Former::select('invoice_design_id')->style('display:inline;width:120px')->fromQuery($invoiceDesigns, 'name', 'id')->onchange('onSelectChange()')->raw() !!}
|
||||
{!! Former::select('invoice_design_id')
|
||||
->placeholder(trans('texts.select_design'))
|
||||
->style('display:inline;width:180px')
|
||||
->fromQuery($invoiceDesigns, 'name', 'id')
|
||||
->onchange('onSelectChange()')
|
||||
->raw() !!}
|
||||
<div class="pull-right">
|
||||
{!! Button::normal(trans('texts.help'))->withAttributes(['onclick' => 'showHelp()'])->appendIcon(Icon::create('question-sign')) !!}
|
||||
{!! Button::normal(trans('texts.cancel'))->asLinkTo(URL::to('/settings/invoice_design'))->appendIcon(Icon::create('remove-circle')) !!}
|
||||
@ -230,7 +234,7 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-default" data-dismiss="modal">{{ trans('texts.close') }}</button>
|
||||
</div>
|
||||
|
@ -118,6 +118,7 @@
|
||||
{!! Former::open()->addClass('warn-on-exit')->onchange('if(!window.loadingFonts)refreshPDF()') !!}
|
||||
|
||||
{!! Former::populateField('invoice_design_id', $account->invoice_design_id) !!}
|
||||
{!! Former::populateField('quote_design_id', $account->quote_design_id) !!}
|
||||
{!! Former::populateField('body_font_id', $account->getBodyFontId()) !!}
|
||||
{!! Former::populateField('header_font_id', $account->getHeaderFontId()) !!}
|
||||
{!! Former::populateField('font_size', $account->font_size) !!}
|
||||
@ -161,14 +162,12 @@
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
|
||||
@if (!Utils::hasFeature(FEATURE_MORE_INVOICE_DESIGNS) || \App\Models\InvoiceDesign::count() == COUNT_FREE_DESIGNS_SELF_HOST)
|
||||
{!! Former::select('invoice_design_id')
|
||||
->fromQuery($invoiceDesigns, 'name', 'id')
|
||||
->addOption(trans('texts.more_designs') . '...', '-1') !!}
|
||||
@else
|
||||
{!! Former::select('invoice_design_id')
|
||||
->fromQuery($invoiceDesigns, 'name', 'id') !!}
|
||||
@endif
|
||||
{!! Former::select('invoice_design_id')
|
||||
->label('default_design')
|
||||
->fromQuery($invoiceDesigns, 'name', 'id') !!}
|
||||
{!! Former::select('quote_design_id')
|
||||
->label('quote_design')
|
||||
->fromQuery($invoiceDesigns, 'name', 'id') !!}
|
||||
{!! Former::select('body_font_id')
|
||||
->fromQuery($invoiceFonts, 'name', 'id') !!}
|
||||
{!! Former::select('header_font_id')
|
||||
@ -287,10 +286,14 @@
|
||||
|
||||
<br/>
|
||||
{!! Former::actions(
|
||||
Button::primary(trans('texts.customize'))
|
||||
->appendIcon(Icon::create('edit'))
|
||||
->asLinkTo(URL::to('/settings/customize_design'))
|
||||
->large(),
|
||||
$account->getCustomDesign(CUSTOM_DESIGN1) ?
|
||||
DropdownButton::primary(trans('texts.customize'))
|
||||
->withContents($account->present()->customDesigns)
|
||||
->large() :
|
||||
Button::primary(trans('texts.customize'))
|
||||
->appendIcon(Icon::create('edit'))
|
||||
->asLinkTo(URL::to('/settings/customize_design') . '?design_id=' . CUSTOM_DESIGN1)
|
||||
->large(),
|
||||
Auth::user()->hasFeature(FEATURE_CUSTOMIZE_INVOICE_DESIGN) ?
|
||||
Button::success(trans('texts.save'))
|
||||
->submit()->large()
|
||||
|
@ -552,7 +552,7 @@
|
||||
{!! Former::text('pdfupload') !!}
|
||||
</div>
|
||||
|
||||
@if (!Utils::hasFeature(FEATURE_MORE_INVOICE_DESIGNS) || \App\Models\InvoiceDesign::count() == COUNT_FREE_DESIGNS_SELF_HOST)
|
||||
@if (!Utils::hasFeature(FEATURE_MORE_INVOICE_DESIGNS))
|
||||
{!! Former::select('invoice_design_id')->style('display:inline;width:150px;background-color:white !important')->raw()->fromQuery($invoiceDesigns, 'name', 'id')->data_bind("value: invoice_design_id")->addOption(trans('texts.more_designs') . '...', '-1') !!}
|
||||
@else
|
||||
{!! Former::select('invoice_design_id')->style('display:inline;width:150px;background-color:white !important')->raw()->fromQuery($invoiceDesigns, 'name', 'id')->data_bind("value: invoice_design_id") !!}
|
||||
|
@ -142,7 +142,7 @@
|
||||
settingsURL = localStorage.getItem('last:settings_page') || settingsURL;
|
||||
}
|
||||
// if they're on the last viewed settings page link to main settings page
|
||||
if ('{{ request()->url() }}' != settingsURL) {
|
||||
if ('{{ request()->fullUrl() }}' != settingsURL) {
|
||||
$('.nav-settings .nav-link').attr("href", settingsURL);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user