diff --git a/app/Models/Account.php b/app/Models/Account.php index e50c0d36fcc7..3e415e65dfa6 100644 --- a/app/Models/Account.php +++ b/app/Models/Account.php @@ -332,6 +332,14 @@ class Account extends Eloquent return $this->hasMany('App\Models\Product'); } + /** + * @return \Illuminate\Database\Eloquent\Relations\HasMany + */ + public function defaultDocuments() + { + return $this->hasMany('App\Models\Document')->whereIsDefault(true); + } + /** * @return \Illuminate\Database\Eloquent\Relations\BelongsTo */ diff --git a/app/Models/Document.php b/app/Models/Document.php index f1f83436fbf3..90de300f5b81 100644 --- a/app/Models/Document.php +++ b/app/Models/Document.php @@ -24,6 +24,7 @@ class Document extends EntityModel protected $fillable = [ 'invoice_id', 'expense_id', + 'is_default', ]; /** diff --git a/database/migrations/2017_07_18_124150_add_late_fees.php b/database/migrations/2017_07_18_124150_add_late_fees.php index b5fe0f4be135..51aa1ae096f3 100644 --- a/database/migrations/2017_07_18_124150_add_late_fees.php +++ b/database/migrations/2017_07_18_124150_add_late_fees.php @@ -20,6 +20,10 @@ class AddLateFees extends Migration $table->decimal('late_fee3_amount', 13, 2)->nullable(); $table->decimal('late_fee3_percent', 13, 3)->nullable(); }); + + Schema::table('documents', function ($table) { + $table->boolean('is_default')->default(false)->nullable(); + }); } /** @@ -37,5 +41,9 @@ class AddLateFees extends Migration $table->dropColumn('late_fee3_amount'); $table->dropColumn('late_fee3_percent'); }); + + Schema::table('documents', function ($table) { + $table->dropColumn('is_default'); + }); } } diff --git a/resources/lang/en/texts.php b/resources/lang/en/texts.php index 7541afc8e2b4..15a9c76fbc33 100644 --- a/resources/lang/en/texts.php +++ b/resources/lang/en/texts.php @@ -1043,7 +1043,7 @@ $LANG = array( 'invoice_item_fields' => 'Invoice Item Fields', 'custom_invoice_item_fields_help' => 'Add a field when creating an invoice item and display the label and value on the PDF.', 'recurring_invoice_number' => 'Recurring Number', - 'recurring_invoice_number_prefix_help' => 'Speciy a prefix to be added to the invoice number for recurring invoices. The default value is \'R\'.', + 'recurring_invoice_number_prefix_help' => 'Speciy a prefix to be added to the invoice number for recurring invoices.', // Client Passwords 'enable_portal_password' => 'Password Protect Invoices', @@ -2316,6 +2316,7 @@ $LANG = array( 'downloaded_invoices' => 'An email will be sent with the invoice PDFs', 'downloaded_quotes' => 'An email will be sent with the quote PDFs', 'clone_expense' => 'Clone Expense', + 'default_documents' => 'Default Documents', ); diff --git a/resources/views/accounts/invoice_settings.blade.php b/resources/views/accounts/invoice_settings.blade.php index 2826bd0d60ad..65ec0bc27579 100644 --- a/resources/views/accounts/invoice_settings.blade.php +++ b/resources/views/accounts/invoice_settings.blade.php @@ -328,7 +328,7 @@
-

{!! trans('texts.default_messages') !!}

+

{!! trans('texts.defaults') !!}

@@ -337,6 +337,9 @@
  • {{ trans('texts.invoice_footer') }}
  • {{ trans('texts.quote_terms') }}
  • + @if ($account->hasFeature(FEATURE_DOCUMENTS)) +
  • {{ trans('texts.documents') }}
  • + @endif
    @@ -362,6 +365,30 @@ ->rows(4) !!}
    + @if ($account->hasFeature(FEATURE_DOCUMENTS)) +
    +
    +
    + +
    +
    +
    +
    + +
    +
    +
    +
    +
    +
    +
    + @endif @@ -484,6 +511,8 @@ }); + var defaultDocuments = {!! $account->defaultDocuments()->get() !!}; + $(function() { setQuoteNumberEnabled(); onNumberTypeChange('invoice'); @@ -499,6 +528,9 @@ toggleDatePicker('reset_counter_date'); }); + @if ($account->hasFeature(FEATURE_DOCUMENTS)) + @include('partials.dropzone', ['documentSource' => 'defaultDocuments', 'isDefault' => true]) + @endif }); diff --git a/resources/views/expenses/edit.blade.php b/resources/views/expenses/edit.blade.php index a306c7ed6f66..26a8ac3cdd6d 100644 --- a/resources/views/expenses/edit.blade.php +++ b/resources/views/expenses/edit.blade.php @@ -203,9 +203,11 @@
    -
    -
    - +
    +
    +
    + +
    @@ -254,8 +256,6 @@ {!! Former::close() !!} @if ($account->hasFeature(FEATURE_DOCUMENTS) && $account->invoice_embed_documents)