1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-18 09:04:35 +01:00

Added support for selecting invoice design

This commit is contained in:
Hillel Coren 2014-02-19 21:42:57 +02:00
parent af37de4feb
commit 9886487b64
8 changed files with 96 additions and 13 deletions

View File

@ -9,14 +9,9 @@ Most online invoicing sites are expensive. They shouldn't be. The aim of this pr
### Features ### Features
* Core application built using Laravel 4.1 * Core application built using Laravel 4.1
* Invoice PDF generation directly in the browser * Invoice PDF generation directly in the browser
* Tax rates and payment terms
* Integrates with many payment providers * Integrates with many payment providers
* Recurring invoices * Recurring invoices
* Tax rates and payment terms
### Remaining Work
* Home dashboard
* Multiple language support
* Reports
### Steps to setup ### Steps to setup

View File

@ -300,6 +300,7 @@ class AccountController extends \BaseController {
$client->save(); $client->save();
$client->contacts()->save($contact); $client->contacts()->save($contact);
Activity::createClient($client);
} }
$message = Utils::pluralize('Successfully created ? client', $count); $message = Utils::pluralize('Successfully created ? client', $count);

View File

@ -216,6 +216,7 @@ class InvoiceController extends \BaseController {
'sizes' => Size::remember(DEFAULT_QUERY_CACHE)->orderBy('id')->get(), 'sizes' => Size::remember(DEFAULT_QUERY_CACHE)->orderBy('id')->get(),
'paymentTerms' => PaymentTerm::remember(DEFAULT_QUERY_CACHE)->orderBy('num_days')->get(['name', 'num_days']), 'paymentTerms' => PaymentTerm::remember(DEFAULT_QUERY_CACHE)->orderBy('num_days')->get(['name', 'num_days']),
'industries' => Industry::remember(DEFAULT_QUERY_CACHE)->orderBy('id')->get(), 'industries' => Industry::remember(DEFAULT_QUERY_CACHE)->orderBy('id')->get(),
'invoiceDesigns' => InvoiceDesign::remember(DEFAULT_QUERY_CACHE)->orderBy('id')->get(),
'frequencies' => array( 'frequencies' => array(
1 => 'Weekly', 1 => 'Weekly',
2 => 'Two weeks', 2 => 'Two weeks',
@ -268,10 +269,13 @@ class InvoiceController extends \BaseController {
$invoice = $this->invoiceRepo->save($publicId, $invoiceData); $invoice = $this->invoiceRepo->save($publicId, $invoiceData);
$account = Auth::user()->account; $account = Auth::user()->account;
if ($account->invoice_taxes != $input->invoice_taxes || $account->invoice_item_taxes != $input->invoice_item_taxes) if ($account->invoice_taxes != $input->invoice_taxes
|| $account->invoice_item_taxes != $input->invoice_item_taxes
|| $account->invoice_design_id != $input->invoice->invoice_design_id)
{ {
$account->invoice_taxes = $input->invoice_taxes; $account->invoice_taxes = $input->invoice_taxes;
$account->invoice_item_taxes = $input->invoice_item_taxes; $account->invoice_item_taxes = $input->invoice_item_taxes;
$account->invoice_design_id = $input->invoice->invoice_design_id;
$account->save(); $account->save();
} }

View File

@ -0,0 +1,71 @@
<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class AddSupportForInvoiceDesigns extends Migration {
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('invoice_designs', function($table)
{
$table->increments('id');
$table->string('name');
});
DB::table('invoice_designs')->insert(['name' => 'Clean']);
DB::table('invoice_designs')->insert(['name' => 'Bold']);
DB::table('invoice_designs')->insert(['name' => 'Modern']);
Schema::table('invoices', function($table)
{
$table->unsignedInteger('invoice_design_id')->default(1);
});
Schema::table('accounts', function($table)
{
$table->unsignedInteger('invoice_design_id')->default(1);
});
DB::table('invoices')->update(['invoice_design_id' => 1]);
DB::table('accounts')->update(['invoice_design_id' => 1]);
Schema::table('invoices', function($table)
{
$table->foreign('invoice_design_id')->references('id')->on('invoice_designs');
});
Schema::table('accounts', function($table)
{
$table->foreign('invoice_design_id')->references('id')->on('invoice_designs');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('invoices', function($table)
{
$table->dropForeign('invoices_invoice_design_id_foreign');
$table->dropColumn('invoice_design_id');
});
Schema::table('accounts', function($table)
{
$table->dropForeign('accounts_invoice_design_id_foreign');
$table->dropColumn('invoice_design_id');
});
Schema::dropIfExists('invoice_designs');
}
}

View File

@ -0,0 +1,7 @@
<?php
class InvoiceDesign extends Eloquent
{
public $timestamps = false;
protected $softDelete = false;
}

View File

@ -131,6 +131,7 @@ class InvoiceRepository
$invoice->terms = trim($data['terms']); $invoice->terms = trim($data['terms']);
$invoice->public_notes = trim($data['public_notes']); $invoice->public_notes = trim($data['public_notes']);
$invoice->po_number = trim($data['po_number']); $invoice->po_number = trim($data['po_number']);
$invoice->invoice_design_id = $data['invoice_design_id'];
if (isset($data['tax_rate']) && Utils::parseFloat($data['tax_rate']) > 0) if (isset($data['tax_rate']) && Utils::parseFloat($data['tax_rate']) > 0)
{ {

View File

@ -14,9 +14,9 @@
{{ Former::checkbox('notify_viewed')->label('&nbsp;')->text('Email me when an invoice is <b>viewed</b>') }} {{ Former::checkbox('notify_viewed')->label('&nbsp;')->text('Email me when an invoice is <b>viewed</b>') }}
{{ Former::checkbox('notify_paid')->label('&nbsp;')->text('Email me when an invoice is <b>paid</b>') }} {{ Former::checkbox('notify_paid')->label('&nbsp;')->text('Email me when an invoice is <b>paid</b>') }}
{{ Former::legend('Custom messages') }} {{ Former::legend('Custom Messages') }}
{{ Former::textarea('invoice_terms') }} {{ Former::textarea('invoice_terms')->label('Set default invoice terms') }}
{{ Former::textarea('email_footer') }} {{ Former::textarea('email_footer')->label('Set default email signature') }}
{{ Former::actions( Button::lg_primary_submit('Save') ) }} {{ Former::actions( Button::lg_primary_submit('Save') ) }}
{{ Former::close() }} {{ Former::close() }}

View File

@ -207,6 +207,9 @@
</div> </div>
{{ Former::select('invoice_design_id')->label('Design')->style('display:inline;width:100px')->raw()
->fromQuery($invoiceDesigns, 'name', 'id')->data_bind("value: invoice_design_id") }}
{{ Button::normal('Download PDF', array('onclick' => 'onDownloadClick()')) }} {{ Button::normal('Download PDF', array('onclick' => 'onDownloadClick()')) }}
@if (!$invoice || (!$invoice->trashed() && !$invoice->client->trashed())) @if (!$invoice || (!$invoice->trashed() && !$invoice->client->trashed()))
@ -462,7 +465,7 @@
refreshPDF(); refreshPDF();
}); //.trigger('change'); }); //.trigger('change');
$('#terms, #public_notes, #invoice_number, #invoice_date, #due_date, #po_number, #discount, #currency_id').change(function() { $('#terms, #public_notes, #invoice_number, #invoice_date, #due_date, #po_number, #discount, #currency_id, #invoice_design_id').change(function() {
refreshPDF(); refreshPDF();
}); });
@ -947,6 +950,7 @@
self.invoice_items = ko.observableArray(); self.invoice_items = ko.observableArray();
self.amount = ko.observable(0); self.amount = ko.observable(0);
self.balance = ko.observable(0); self.balance = ko.observable(0);
self.invoice_design_id = ko.observable({{ $account->invoice_design_id }});
self.mapping = { self.mapping = {
'client': { 'client': {