1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-15 07:33:04 +01:00
invoiceninja/resources/views/invoices/edit.blade.php

1475 lines
67 KiB
PHP
Raw Normal View History

2013-11-26 13:45:07 +01:00
@extends('header')
2013-12-08 14:32:49 +01:00
@section('head')
@parent
@include('money_script')
2016-02-25 11:16:27 +01:00
2016-01-07 08:08:30 +01:00
@foreach ($account->getFontFolders() as $font)
2016-02-25 11:16:27 +01:00
<script src="{{ asset('js/vfs_fonts/'.$font.'.js') }}" type="text/javascript"></script>
2016-01-07 08:08:30 +01:00
@endforeach
2016-01-31 20:36:50 +01:00
<script src="{{ asset('pdf.built.js') }}" type="text/javascript"></script>
2016-02-25 11:16:27 +01:00
<script src="{{ asset('js/lightbox.min.js') }}" type="text/javascript"></script>
<link href="{{ asset('css/lightbox.css') }}" rel="stylesheet" type="text/css"/>
2015-10-25 08:13:06 +01:00
<style type="text/css">
2016-02-25 11:16:27 +01:00
/* the value is auto set so we're removing the bold formatting */
label.control-label[for=invoice_number] {
font-weight: normal !important;
}
2016-05-22 21:17:57 +02:00
select.xtax-select {
2016-03-31 11:29:01 +02:00
width: 50%;
float: left;
}
2016-04-11 12:30:23 +02:00
#scrollable-dropdown-menu .tt-menu {
max-height: 150px;
overflow-y: auto;
overflow-x: hidden;
}
2015-10-25 08:13:06 +01:00
</style>
2013-12-08 14:32:49 +01:00
@stop
2013-11-26 13:45:07 +01:00
@section('content')
2015-11-04 08:48:47 +01:00
@if ($errors->first('invoice_items'))
<div class="alert alert-danger">{{ trans($errors->first('invoice_items')) }}</div>
@endif
2015-10-28 20:22:07 +01:00
@if ($invoice->id)
2014-02-17 00:09:34 +01:00
<ol class="breadcrumb">
2015-10-23 13:55:18 +02:00
@if ($invoice->is_recurring)
<li>{!! link_to('invoices', trans('texts.recurring_invoice')) !!}</li>
@else
<li>{!! link_to(($entityType == ENTITY_QUOTE ? 'quotes' : 'invoices'), trans('texts.' . ($entityType == ENTITY_QUOTE ? 'quotes' : 'invoices'))) !!}</li>
2015-10-15 08:19:41 +02:00
<li class="active">{{ $invoice->invoice_number }}</li>
@endif
2016-01-10 11:25:05 +01:00
</ol>
2014-02-17 00:09:34 +01:00
@endif
2014-01-01 16:23:32 +01:00
2015-11-09 15:53:18 +01:00
{!! Former::open($url)
->method($method)
->addClass('warn-on-exit main-form')
2015-11-09 15:53:18 +01:00
->autocomplete('off')
->onsubmit('return onFormSubmit(event)')
2015-11-09 15:53:18 +01:00
->rules(array(
'client' => 'required',
'invoice_number' => 'required',
'product_key' => 'max:255'
2016-01-10 11:25:05 +01:00
)) !!}
2015-11-09 15:53:18 +01:00
@include('partials.autocomplete_fix')
2015-04-20 16:34:23 +02:00
2014-03-17 19:05:01 +01:00
<input type="submit" style="display:none" name="submitButton" id="submitButton">
2014-01-01 16:23:32 +01:00
<div data-bind="with: invoice">
2015-04-20 16:34:23 +02:00
<div class="panel panel-default">
2016-03-27 17:06:02 +02:00
<div class="panel-body">
2015-04-20 16:34:23 +02:00
<div class="row" style="min-height:195px" onkeypress="formEnterClick(event)">
2014-02-16 23:03:19 +01:00
<div class="col-md-4" id="col_1">
2013-12-31 00:19:17 +01:00
2015-10-25 08:13:06 +01:00
@if ($invoice->id || $data)
2013-12-31 00:19:17 +01:00
<div class="form-group">
2015-11-09 10:50:47 +01:00
<label for="client" class="control-label col-lg-4 col-sm-4">{{ trans('texts.client') }}</label>
2015-05-08 10:21:29 +02:00
<div class="col-lg-8 col-sm-8">
<h4>
<span data-bind="text: getClientDisplayName(ko.toJS(client()))"></span>
@if ($invoice->client->is_deleted)
&nbsp;&nbsp;<div class="label label-danger">{{ trans('texts.deleted') }}</div>
@endif
</h4>
2016-05-22 21:17:57 +02:00
2016-04-26 03:53:39 +02:00
@can('view', $invoice->client)
@can('edit', $invoice->client)
<a id="editClientLink" class="pointer" data-bind="click: $root.showClientForm">{{ trans('texts.edit_client') }}</a> |
2016-04-26 03:53:39 +02:00
@endcan
{!! link_to('/clients/'.$invoice->client->public_id, trans('texts.view_client'), ['target' => '_blank']) !!}
2016-04-26 03:53:39 +02:00
@endcan
2013-12-31 00:19:17 +01:00
</div>
2016-01-10 11:25:05 +01:00
</div>
2013-12-31 00:19:17 +01:00
<div style="display:none">
@endif
2016-05-22 21:17:57 +02:00
2016-03-17 15:11:14 +01:00
{!! Former::select('client')->addOption('', '')->data_bind("dropdown: client")->addClass('client-input')->addGroupClass('client_select closer-row') !!}
<div class="form-group" style="margin-bottom: 8px">
2013-12-15 13:55:50 +01:00
<div class="col-lg-8 col-sm-8 col-lg-offset-4 col-sm-offset-4">
2015-08-11 16:38:36 +02:00
<a id="createClientLink" class="pointer" data-bind="click: $root.showClientForm, html: $root.clientLinkText"></a>
2016-01-10 11:25:05 +01:00
<span data-bind="visible: $root.invoice().client().public_id() > 0" style="display:none">|
2015-05-08 10:21:29 +02:00
<a data-bind="attr: {href: '{{ url('/clients') }}/' + $root.invoice().client().public_id()}" target="_blank">{{ trans('texts.view_client') }}</a>
</span>
</div>
</div>
2015-10-25 08:13:06 +01:00
@if ($invoice->id || $data)
2013-12-31 00:19:17 +01:00
</div>
@endif
2015-10-15 16:14:13 +02:00
<div data-bind="with: client" class="invoice-contact">
2015-04-16 19:12:56 +02:00
<div style="display:none" class="form-group" data-bind="visible: contacts().length > 0 &amp;&amp; (contacts()[0].email() || contacts()[0].first_name()), foreach: contacts">
<div class="col-lg-8 col-lg-offset-4 col-sm-offset-4">
2015-07-21 20:51:56 +02:00
<label class="checkbox" data-bind="attr: {for: $index() + '_check'}" onclick="refreshPDF(true)">
2015-11-06 08:54:29 +01:00
<input type="hidden" value="0" data-bind="attr: {name: 'client[contacts][' + $index() + '][send_invoice]'}">
<input type="checkbox" value="1" data-bind="checked: send_invoice, attr: {id: $index() + '_check', name: 'client[contacts][' + $index() + '][send_invoice]'}">
2016-01-10 11:25:05 +01:00
<span data-bind="html: email.display"></span>
2015-10-11 16:41:09 +02:00
</label>
@if ( ! $invoice->is_deleted && ! $invoice->client->is_deleted)
<span data-bind="visible: !$root.invoice().is_recurring()">
<span data-bind="html: $data.view_as_recipient"></span>&nbsp;&nbsp;
@if (Utils::isConfirmed())
<span style="vertical-align:text-top;color:red" class="fa fa-exclamation-triangle"
data-bind="visible: $data.email_error, tooltip: {title: $data.email_error}"></span>
<span style="vertical-align:text-top" class="glyphicon glyphicon-info-sign"
data-bind="visible: $data.invitation_status, tooltip: {title: $data.invitation_status, html: true},
style: {color: $data.info_color}"></span>
@endif
</span>
@endif
2015-10-11 16:41:09 +02:00
</div>
</div>
</div>
2016-01-10 11:25:05 +01:00
2013-11-26 22:45:10 +01:00
</div>
2013-12-11 21:33:44 +01:00
<div class="col-md-4" id="col_2">
<div data-bind="visible: !is_recurring()">
2015-03-27 06:02:19 +01:00
{!! Former::text('invoice_date')->data_bind("datePicker: invoice_date, valueUpdate: 'afterkeydown'")->label(trans("texts.{$entityType}_date"))
->data_date_format(Session::get(SESSION_DATE_PICKER_FORMAT, DEFAULT_DATE_PICKER_FORMAT))->appendIcon('calendar')->addGroupClass('invoice_date') !!}
2015-09-07 11:07:55 +02:00
{!! Former::text('due_date')->data_bind("datePicker: due_date, valueUpdate: 'afterkeydown'")->label(trans("texts.{$entityType}_due_date"))
->data_date_format(Session::get(SESSION_DATE_PICKER_FORMAT, DEFAULT_DATE_PICKER_FORMAT))->appendIcon('calendar')->addGroupClass('due_date') !!}
2016-01-10 11:25:05 +01:00
2015-06-03 19:55:48 +02:00
{!! Former::text('partial')->data_bind("value: partial, valueUpdate: 'afterkeydown'")->onchange('onPartialChange()')
->rel('tooltip')->data_toggle('tooltip')->data_placement('bottom')->title(trans('texts.partial_value')) !!}
2013-12-10 23:10:43 +01:00
</div>
2015-10-11 16:41:09 +02:00
@if ($entityType == ENTITY_INVOICE)
<div data-bind="visible: is_recurring" style="display: none">
{!! Former::select('frequency_id')->options($frequencies)->data_bind("value: frequency_id")
->appendIcon('question-sign')->addGroupClass('frequency_id')->onchange('onFrequencyChange()') !!}
2015-10-11 16:41:09 +02:00
{!! Former::text('start_date')->data_bind("datePicker: start_date, valueUpdate: 'afterkeydown'")
->data_date_format(Session::get(SESSION_DATE_PICKER_FORMAT, DEFAULT_DATE_PICKER_FORMAT))->appendIcon('calendar')->addGroupClass('start_date') !!}
{!! Former::text('end_date')->data_bind("datePicker: end_date, valueUpdate: 'afterkeydown'")
->data_date_format(Session::get(SESSION_DATE_PICKER_FORMAT, DEFAULT_DATE_PICKER_FORMAT))->appendIcon('calendar')->addGroupClass('end_date') !!}
{!! Former::select('recurring_due_date')->label(trans('texts.due_date'))->options($recurringDueDates)->data_bind("value: recurring_due_date")->appendIcon('question-sign')->addGroupClass('recurring_due_date') !!}
2015-10-11 16:41:09 +02:00
</div>
@endif
2015-10-13 09:11:44 +02:00
@if ($account->showCustomField('custom_invoice_text_label1', $invoice))
2015-10-11 16:41:09 +02:00
{!! Former::text('custom_text_value1')->label($account->custom_invoice_text_label1)->data_bind("value: custom_text_value1, valueUpdate: 'afterkeydown'") !!}
2015-10-18 12:37:04 +02:00
@endif
2013-11-26 22:45:10 +01:00
</div>
2013-12-24 07:22:16 +01:00
2014-02-16 23:03:19 +01:00
<div class="col-md-4" id="col_2">
2015-08-14 14:04:33 +02:00
<span data-bind="visible: !is_recurring()">
{!! Former::text('invoice_number')
->label(trans("texts.{$entityType}_number_short"))
->data_bind("value: invoice_number, valueUpdate: 'afterkeydown'") !!}
2016-01-10 11:25:05 +01:00
</span>
<span data-bind="visible: is_recurring()" style="display: none">
{!! Former::checkbox('auto_bill')
->label(trans('texts.auto_bill'))
->text(trans('texts.enable_with_stripe'))
->data_bind("checked: auto_bill, valueUpdate: 'afterkeydown'") !!}
2015-08-14 14:04:33 +02:00
</span>
2015-03-27 06:02:19 +01:00
{!! Former::text('po_number')->label(trans('texts.po_number_short'))->data_bind("value: po_number, valueUpdate: 'afterkeydown'") !!}
{!! Former::text('discount')->data_bind("value: discount, valueUpdate: 'afterkeydown'")
2014-12-03 23:05:38 +01:00
->addGroupClass('discount-group')->type('number')->min('0')->step('any')->append(
Former::select('is_amount_discount')->addOption(trans('texts.discount_percent'), '0')
->addOption(trans('texts.discount_amount'), '1')->data_bind("value: is_amount_discount")->raw()
2016-01-10 11:25:05 +01:00
) !!}
2015-10-11 16:41:09 +02:00
2015-10-13 09:11:44 +02:00
@if ($account->showCustomField('custom_invoice_text_label2', $invoice))
2015-10-11 16:41:09 +02:00
{!! Former::text('custom_text_value2')->label($account->custom_invoice_text_label2)->data_bind("value: custom_text_value2, valueUpdate: 'afterkeydown'") !!}
@endif
2016-01-11 20:41:02 +01:00
@if ($entityType == ENTITY_INVOICE)
<div class="form-group" style="margin-bottom: 8px">
2016-01-11 20:41:02 +01:00
<div class="col-lg-8 col-sm-8 col-sm-offset-4" style="padding-top: 10px">
@if ($invoice->recurring_invoice)
{!! trans('texts.created_by_invoice', ['invoice' => link_to('/invoices/'.$invoice->recurring_invoice->public_id, trans('texts.recurring_invoice'))]) !!}
@elseif ($invoice->id)
<span class="smaller">
@if (isset($lastSent) && $lastSent)
{!! trans('texts.last_sent_on', ['date' => link_to('/invoices/'.$lastSent->public_id, $invoice->last_sent_date, ['id' => 'lastSent'])]) !!} <br/>
@endif
@if ($invoice->is_recurring && $invoice->getNextSendDate())
{!! trans('texts.next_send_on', ['date' => '<span data-bind="tooltip: {title: \''.$invoice->getPrettySchedule().'\', html: true}">'.$account->formatDate($invoice->getNextSendDate()).
'<span class="glyphicon glyphicon-info-sign" style="padding-left:10px;color:#B1B5BA"></span></span>']) !!}
@if ($invoice->getDueDate())
<br>
{!! trans('texts.next_due_on', ['date' => '<span>'.$account->formatDate($invoice->getDueDate($invoice->getNextSendDate())).'</span>']) !!}
@endif
@endif
</span>
@endif
</div>
</div>
@endif
2013-12-24 07:22:16 +01:00
</div>
2013-11-26 22:45:10 +01:00
</div>
2013-11-26 13:45:07 +01:00
2015-10-25 08:13:06 +01:00
<div class="table-responsive" style="padding-top:4px">
<table class="table invoice-table">
2014-05-22 20:29:29 +02:00
<thead>
<tr>
<th style="min-width:32px;" class="hide-border"></th>
2015-12-13 21:12:54 +01:00
<th style="min-width:160px">{{ $invoiceLabels['item'] }}</th>
<th style="width:100%">{{ $invoiceLabels['description'] }}</th>
@if ($account->showCustomField('custom_invoice_item_label1'))
2016-02-28 12:59:52 +01:00
<th style="min-width:120px">{{ $account->custom_invoice_item_label1 }}</th>
@endif
@if ($account->showCustomField('custom_invoice_item_label2'))
2016-02-28 12:59:52 +01:00
<th style="min-width:120px">{{ $account->custom_invoice_item_label2 }}</th>
@endif
2015-12-10 11:57:51 +01:00
<th style="min-width:120px" data-bind="text: costLabel">{{ $invoiceLabels['unit_cost'] }}</th>
<th style="{{ $account->hide_quantity ? 'display:none' : 'min-width:120px' }}" data-bind="text: qtyLabel">{{ $invoiceLabels['quantity'] }}</th>
2016-06-05 17:47:51 +02:00
<th style="min-width:120px;display:none;" data-bind="visible: $root.invoice_item_taxes.show">{{ trans('texts.tax') }}</th>
2014-05-22 20:29:29 +02:00
<th style="min-width:120px;">{{ trans('texts.line_total') }}</th>
<th style="min-width:32px;" class="hide-border"></th>
</tr>
</thead>
<tbody data-bind="sortable: { data: invoice_items, afterMove: onDragged }">
<tr data-bind="event: { mouseover: showActions, mouseout: hideActions }" class="sortable-row">
<td class="hide-border td-icon">
2015-08-14 14:04:33 +02:00
<i style="display:none" data-bind="visible: actionsVisible() &amp;&amp;
$parent.invoice_items().length > 1" class="fa fa-sort"></i>
2014-05-22 20:29:29 +02:00
</td>
2015-08-14 14:04:33 +02:00
<td>
2016-04-11 12:30:23 +02:00
<div id="scrollable-dropdown-menu">
<input id="product_key" type="text" data-bind="typeahead: product_key, items: $root.products, key: 'product_key', valueUpdate: 'afterkeydown', attr: {name: 'invoice_items[' + $index() + '][product_key]'}" class="form-control invoice-item handled"/>
</div>
2014-05-22 20:29:29 +02:00
</td>
<td>
2016-01-10 11:25:05 +01:00
<textarea data-bind="value: wrapped_notes, valueUpdate: 'afterkeydown', attr: {name: 'invoice_items[' + $index() + '][notes]'}"
2015-10-28 20:22:07 +01:00
rows="1" cols="60" style="resize: vertical" class="form-control word-wrap"></textarea>
<input type="text" data-bind="value: task_public_id, attr: {name: 'invoice_items[' + $index() + '][task_public_id]'}" style="display: none"/>
2016-01-10 11:25:05 +01:00
<input type="text" data-bind="value: expense_public_id, attr: {name: 'invoice_items[' + $index() + '][expense_public_id]'}" style="display: none"/>
2014-05-22 20:29:29 +02:00
</td>
@if ($account->showCustomField('custom_invoice_item_label1'))
2016-02-28 12:59:52 +01:00
<td>
<input data-bind="value: custom_value1, valueUpdate: 'afterkeydown', attr: {name: 'invoice_items[' + $index() + '][custom_value1]'}" class="form-control invoice-item"/>
</td>
@endif
@if ($account->showCustomField('custom_invoice_item_label2'))
2016-02-28 12:59:52 +01:00
<td>
<input data-bind="value: custom_value2, valueUpdate: 'afterkeydown', attr: {name: 'invoice_items[' + $index() + '][custom_value2]'}" class="form-control invoice-item"/>
</td>
@endif
2014-05-22 20:29:29 +02:00
<td>
2016-01-10 11:25:05 +01:00
<input data-bind="value: prettyCost, valueUpdate: 'afterkeydown', attr: {name: 'invoice_items[' + $index() + '][cost]'}"
2015-12-29 08:52:02 +01:00
style="text-align: right" class="form-control invoice-item"/>
2014-05-22 20:29:29 +02:00
</td>
2014-07-20 12:38:42 +02:00
<td style="{{ $account->hide_quantity ? 'display:none' : '' }}">
2016-01-10 11:25:05 +01:00
<input data-bind="value: prettyQty, valueUpdate: 'afterkeydown', attr: {name: 'invoice_items[' + $index() + '][qty]'}"
2015-12-29 08:52:02 +01:00
style="text-align: right" class="form-control invoice-item" name="quantity"/>
2014-05-22 20:29:29 +02:00
</td>
<td style="display:none;" data-bind="visible: $root.invoice_item_taxes.show">
2016-03-27 17:06:02 +02:00
{!! Former::select('')
2016-03-29 16:30:28 +02:00
->addOption('', '')
->options($taxRateOptions)
2016-03-31 11:29:01 +02:00
->data_bind('value: tax1')
->addClass('tax-select')
->raw() !!}
<input type="text" data-bind="value: tax_name1, attr: {name: 'invoice_items[' + $index() + '][tax_name1]'}" style="display:none">
<input type="text" data-bind="value: tax_rate1, attr: {name: 'invoice_items[' + $index() + '][tax_rate1]'}" style="display:none">
<div style="display:none">
{!! Former::select('')
->addOption('', '')
->options($taxRateOptions)
->data_bind('value: tax2')
->addClass('tax-select')
->raw() !!}
<input type="text" data-bind="value: tax_name2, attr: {name: 'invoice_items[' + $index() + '][tax_name2]'}" style="display:none">
<input type="text" data-bind="value: tax_rate2, attr: {name: 'invoice_items[' + $index() + '][tax_rate2]'}" style="display:none">
</div>
2014-05-22 20:29:29 +02:00
</td>
2015-11-04 08:48:47 +01:00
<td style="text-align:right;padding-top:9px !important" nowrap>
2014-05-22 20:29:29 +02:00
<div class="line-total" data-bind="text: totals.total"></div>
</td>
2015-09-20 23:05:02 +02:00
<td style="cursor:pointer" class="hide-border td-icon">
2016-01-10 11:25:05 +01:00
<i style="padding-left:2px" data-bind="click: $parent.removeItem, visible: actionsVisible() &amp;&amp;
2015-08-14 14:04:33 +02:00
$index() < ($parent.invoice_items().length - 1) &amp;&amp;
$parent.invoice_items().length > 1" class="fa fa-minus-circle redlink" title="Remove item"/>
2014-05-22 20:29:29 +02:00
</td>
</tr>
2013-11-26 22:45:10 +01:00
</tbody>
2014-07-20 12:38:42 +02:00
2013-12-31 20:49:54 +01:00
<tfoot>
<tr>
2014-05-22 20:29:29 +02:00
<td class="hide-border"/>
<td class="hide-border" colspan="{{ 2 + ($account->showCustomField('custom_invoice_item_label1') ? 1 : 0) + ($account->showCustomField('custom_invoice_item_label2') ? 1 : 0) }}" rowspan="6" style="vertical-align:top">
2014-05-22 20:29:29 +02:00
<br/>
2015-02-28 22:42:47 +01:00
<div role="tabpanel">
<ul class="nav nav-tabs" role="tablist" style="border: none">
<li role="presentation" class="active"><a href="#notes" aria-controls="notes" role="tab" data-toggle="tab">{{ trans('texts.note_to_client') }}</a></li>
2016-03-31 12:28:22 +02:00
<li role="presentation"><a href="#terms" aria-controls="terms" role="tab" data-toggle="tab">{{ trans("texts.terms") }}</a></li>
<li role="presentation"><a href="#footer" aria-controls="footer" role="tab" data-toggle="tab">{{ trans("texts.footer") }}</a></li>
@if ($account->hasFeature(FEATURE_DOCUMENTS))
2016-06-01 15:50:10 +02:00
<li role="presentation"><a href="#attached-documents" aria-controls="attached-documents" role="tab" data-toggle="tab">
{{ trans("texts.invoice_documents") }}
@if (count($invoice->documents))
({{ count($invoice->documents) }})
@endif
</a></li>
2016-03-23 03:59:20 +01:00
@endif
2015-02-28 22:42:47 +01:00
</ul>
<div class="tab-content">
<div role="tabpanel" class="tab-pane active" id="notes" style="padding-bottom:44px">
2015-03-27 06:02:19 +01:00
{!! Former::textarea('public_notes')->data_bind("value: wrapped_notes, valueUpdate: 'afterkeydown'")
2016-04-13 16:35:36 +02:00
->label(null)->style('resize: none; width: 500px;')->rows(4) !!}
2015-02-28 22:42:47 +01:00
</div>
<div role="tabpanel" class="tab-pane" id="terms">
2015-09-07 11:07:55 +02:00
{!! Former::textarea('terms')->data_bind("value:wrapped_terms, placeholder: terms_placeholder, valueUpdate: 'afterkeydown'")
2016-04-13 16:35:36 +02:00
->label(false)->style('resize: none; width: 500px')->rows(4)
2015-09-07 11:07:55 +02:00
->help('<div class="checkbox">
<label>
2015-10-28 20:22:07 +01:00
<input name="set_default_terms" type="checkbox" style="width: 24px" data-bind="checked: set_default_terms"/>'.trans('texts.save_as_default_terms').'
2015-09-07 11:07:55 +02:00
</label>
2015-11-11 13:17:58 +01:00
<div class="pull-right" data-bind="visible: showResetTerms()">
<a href="#" onclick="return resetTerms()" title="'. trans('texts.reset_terms_help') .'">' . trans("texts.reset_terms") . '</a>
</div>
2015-09-07 11:07:55 +02:00
</div>') !!}
2015-02-28 22:42:47 +01:00
</div>
<div role="tabpanel" class="tab-pane" id="footer">
2015-09-07 11:07:55 +02:00
{!! Former::textarea('invoice_footer')->data_bind("value:wrapped_footer, placeholder: footer_placeholder, valueUpdate: 'afterkeydown'")
2016-04-13 16:35:36 +02:00
->label(false)->style('resize: none; width: 500px')->rows(4)
2015-09-07 11:07:55 +02:00
->help('<div class="checkbox">
<label>
2015-10-28 20:22:07 +01:00
<input name="set_default_footer" type="checkbox" style="width: 24px" data-bind="checked: set_default_footer"/>'.trans('texts.save_as_default_footer').'
2015-09-07 11:07:55 +02:00
</label>
2015-11-11 13:17:58 +01:00
<div class="pull-right" data-bind="visible: showResetFooter()">
<a href="#" onclick="return resetFooter()" title="'. trans('texts.reset_footer_help') .'">' . trans("texts.reset_footer") . '</a>
</div>
2015-09-07 11:07:55 +02:00
</div>') !!}
2015-02-28 22:42:47 +01:00
</div>
@if ($account->hasFeature(FEATURE_DOCUMENTS))
2016-03-23 03:23:45 +01:00
<div role="tabpanel" class="tab-pane" id="attached-documents" style="position:relative;z-index:9">
<div id="document-upload">
<div class="dropzone">
<div class="fallback">
<input name="documents[]" type="file" multiple />
</div>
<div data-bind="foreach: documents">
<div class="fallback-doc">
<a href="#" class="fallback-doc-remove" data-bind="click: $parent.removeDocument"><i class="fa fa-close"></i></a>
<span data-bind="text:name"></span>
<input type="hidden" name="document_ids[]" data-bind="value: public_id"/>
</div>
</div>
2016-03-23 03:23:45 +01:00
</div>
@if ($invoice->hasExpenseDocuments())
<h4>{{trans('texts.documents_from_expenses')}}</h4>
@foreach($invoice->expenses as $expense)
@foreach($expense->documents as $document)
<div>{{$document->name}}</div>
@endforeach
@endforeach
@endif
2016-03-23 03:23:45 +01:00
</div>
</div>
2016-03-23 03:59:20 +01:00
@endif
2015-02-28 22:42:47 +01:00
</div>
</div>
2014-05-22 20:29:29 +02:00
</td>
2015-10-21 13:11:08 +02:00
<td class="hide-border" style="display:none" data-bind="visible: $root.invoice_item_taxes.show"/>
2014-07-20 12:38:42 +02:00
<td colspan="{{ $account->hide_quantity ? 1 : 2 }}">{{ trans('texts.subtotal') }}</td>
2014-01-01 16:23:32 +01:00
<td style="text-align: right"><span data-bind="text: totals.subtotal"/></td>
2014-05-22 20:29:29 +02:00
</tr>
2014-07-20 12:38:42 +02:00
2014-12-03 23:05:38 +01:00
<tr style="display:none" data-bind="visible: discount() != 0">
2014-05-22 20:29:29 +02:00
<td class="hide-border" colspan="3"/>
<td style="display:none" class="hide-border" data-bind="visible: $root.invoice_item_taxes.show"/>
2014-07-20 12:38:42 +02:00
<td colspan="{{ $account->hide_quantity ? 1 : 2 }}">{{ trans('texts.discount') }}</td>
2014-01-01 16:23:32 +01:00
<td style="text-align: right"><span data-bind="text: totals.discounted"/></td>
2014-05-22 20:29:29 +02:00
</tr>
2014-07-20 12:38:42 +02:00
2015-10-13 09:11:44 +02:00
@if ($account->showCustomField('custom_invoice_label1', $invoice) && $account->custom_invoice_taxes1)
2014-07-20 12:38:42 +02:00
<tr>
<td class="hide-border" colspan="3"/>
<td style="display:none" class="hide-border" data-bind="visible: $root.invoice_item_taxes.show"/>
<td colspan="{{ $account->hide_quantity ? 1 : 2 }}">{{ $account->custom_invoice_label1 }}</td>
2015-10-28 20:22:07 +01:00
<td style="text-align: right;padding-right: 28px" colspan="2"><input name="custom_value1" class="form-control" data-bind="value: custom_value1, valueUpdate: 'afterkeydown'"/></td>
2014-07-20 12:38:42 +02:00
</tr>
@endif
2015-10-13 09:11:44 +02:00
@if ($account->showCustomField('custom_invoice_label2', $invoice) && $account->custom_invoice_taxes2)
2014-07-20 12:38:42 +02:00
<tr>
<td class="hide-border" colspan="3"/>
<td style="display:none" class="hide-border" data-bind="visible: $root.invoice_item_taxes.show"/>
<td colspan="{{ $account->hide_quantity ? 1 : 2 }}">{{ $account->custom_invoice_label2 }}</td>
2015-10-28 20:22:07 +01:00
<td style="text-align: right;padding-right: 28px" colspan="2"><input name="custom_value2" class="form-control" data-bind="value: custom_value2, valueUpdate: 'afterkeydown'"/></td>
2014-07-20 12:38:42 +02:00
</tr>
@endif
<tr style="display:none" data-bind="visible: $root.invoice_item_taxes.show &amp;&amp; totals.hasItemTaxes">
<td class="hide-border" colspan="4"/>
@if (!$account->hide_quantity)
<td>{{ trans('texts.tax') }}</td>
@endif
<td style="min-width:120px"><span data-bind="html: totals.itemTaxRates"/></td>
<td style="text-align: right"><span data-bind="html: totals.itemTaxAmounts"/></td>
</tr>
2014-05-22 20:29:29 +02:00
<tr style="display:none" data-bind="visible: $root.invoice_taxes.show">
<td class="hide-border" colspan="3"/>
2016-01-10 11:25:05 +01:00
<td style="display:none" class="hide-border" data-bind="visible: $root.invoice_item_taxes.show"/>
2014-07-20 12:38:42 +02:00
@if (!$account->hide_quantity)
<td>{{ trans('texts.tax') }}</td>
@endif
2015-10-28 20:22:07 +01:00
<td style="min-width:120px">
2016-03-27 17:06:02 +02:00
{!! Former::select('')
2016-04-11 10:48:46 +02:00
->id('taxRateSelect1')
2016-03-29 16:30:28 +02:00
->addOption('', '')
->options($taxRateOptions)
2016-03-31 11:29:01 +02:00
->addClass('tax-select')
->data_bind('value: tax1')
2016-05-22 21:17:57 +02:00
->raw() !!}
2016-03-31 11:29:01 +02:00
<input type="text" name="tax_name1" data-bind="value: tax_name1" style="display:none">
<input type="text" name="tax_rate1" data-bind="value: tax_rate1" style="display:none">
<div style="display:none">
{!! Former::select('')
->addOption('', '')
->options($taxRateOptions)
->addClass('tax-select')
->data_bind('value: tax2')
->raw() !!}
<input type="text" name="tax_name2" data-bind="value: tax_name2" style="display:none">
<input type="text" name="tax_rate2" data-bind="value: tax_rate2" style="display:none">
</div>
2015-10-28 20:22:07 +01:00
</td>
2014-03-10 12:04:15 +01:00
<td style="text-align: right"><span data-bind="text: totals.taxAmount"/></td>
2014-05-22 20:29:29 +02:00
</tr>
2014-07-20 12:38:42 +02:00
2015-10-13 09:11:44 +02:00
@if ($account->showCustomField('custom_invoice_label1', $invoice) && !$account->custom_invoice_taxes1)
2014-07-20 12:38:42 +02:00
<tr>
<td class="hide-border" colspan="3"/>
<td style="display:none" class="hide-border" data-bind="visible: $root.invoice_item_taxes.show"/>
<td colspan="{{ $account->hide_quantity ? 1 : 2 }}">{{ $account->custom_invoice_label1 }}</td>
2015-10-28 20:22:07 +01:00
<td style="text-align: right;padding-right: 28px" colspan="2"><input name="custom_value1" class="form-control" data-bind="value: custom_value1, valueUpdate: 'afterkeydown'"/></td>
2014-07-20 12:38:42 +02:00
</tr>
@endif
2015-10-13 09:11:44 +02:00
@if ($account->showCustomField('custom_invoice_label2', $invoice) && !$account->custom_invoice_taxes2)
2014-07-20 12:38:42 +02:00
<tr>
<td class="hide-border" colspan="3"/>
<td style="display:none" class="hide-border" data-bind="visible: $root.invoice_item_taxes.show"/>
<td colspan="{{ $account->hide_quantity ? 1 : 2 }}">{{ $account->custom_invoice_label2 }}</td>
2015-10-28 20:22:07 +01:00
<td style="text-align: right;padding-right: 28px" colspan="2"><input name="custom_value2" class="form-control" data-bind="value: custom_value2, valueUpdate: 'afterkeydown'"/></td>
2014-07-20 12:38:42 +02:00
</tr>
@endif
@if (!$account->hide_paid_to_date)
<tr>
<td class="hide-border" colspan="3"/>
2015-10-28 20:22:07 +01:00
<td style="display:none" class="hide-border" data-bind="visible: $root.invoice_item_taxes.show"/>
2014-07-20 12:38:42 +02:00
<td colspan="{{ $account->hide_quantity ? 1 : 2 }}">{{ trans('texts.paid_to_date') }}</td>
<td style="text-align: right" data-bind="text: totals.paidToDate"></td>
2015-10-28 20:22:07 +01:00
</tr>
2014-07-20 12:38:42 +02:00
@endif
2016-03-18 13:34:46 +01:00
<tr data-bind="style: { 'font-weight': partial() ? 'normal' : 'bold', 'font-size': partial() ? '1em' : '1.05em' }">
2014-05-22 20:29:29 +02:00
<td class="hide-border" colspan="3"/>
2015-10-28 20:22:07 +01:00
<td class="hide-border" style="display:none" data-bind="visible: $root.invoice_item_taxes.show"/>
2016-03-18 13:34:46 +01:00
<td class="hide-border" data-bind="css: {'hide-border': !partial()}" colspan="{{ $account->hide_quantity ? 1 : 2 }}">{{ $entityType == ENTITY_INVOICE ? $invoiceLabels['balance_due'] : trans('texts.total') }}</td>
<td class="hide-border" data-bind="css: {'hide-border': !partial()}" style="text-align: right"><span data-bind="text: totals.total"></span></td>
</tr>
<tr style="font-size:1.05em; display:none; font-weight:bold" data-bind="visible: partial">
<td class="hide-border" colspan="3"/>
<td class="hide-border" style="display:none" data-bind="visible: $root.invoice_item_taxes.show"/>
<td class="hide-border" colspan="{{ $account->hide_quantity ? 1 : 2 }}">{{ $invoiceLabels['partial_due'] }}</td>
<td class="hide-border" style="text-align: right"><span data-bind="text: totals.partial"></span></td>
2014-05-22 20:29:29 +02:00
</tr>
2014-07-20 12:38:42 +02:00
2014-05-22 20:29:29 +02:00
</tfoot>
2014-07-20 12:38:42 +02:00
2013-11-26 22:45:10 +01:00
</table>
2014-07-16 23:04:56 +02:00
</div>
2015-04-20 16:34:23 +02:00
</div>
</div>
2016-01-10 11:25:05 +01:00
2013-11-26 22:45:10 +01:00
<p>&nbsp;</p>
<div class="form-actions">
2013-12-03 18:32:33 +01:00
2013-12-07 19:45:00 +01:00
<div style="display:none">
2015-03-27 06:02:19 +01:00
{!! Former::populateField('entityType', $entityType) !!}
2015-10-28 20:22:07 +01:00
2015-03-27 06:02:19 +01:00
{!! Former::text('entityType') !!}
{!! Former::text('action') !!}
2015-10-28 20:22:07 +01:00
{!! Former::text('public_id')->data_bind('value: public_id') !!}
{!! Former::text('is_recurring')->data_bind('value: is_recurring') !!}
{!! Former::text('is_quote')->data_bind('value: is_quote') !!}
{!! Former::text('has_tasks')->data_bind('value: has_tasks') !!}
{!! Former::text('data')->data_bind('value: ko.mapping.toJSON(model)') !!}
2016-01-10 11:25:05 +01:00
{!! Former::text('has_expenses')->data_bind('value: has_expenses') !!}
2015-10-28 20:22:07 +01:00
{!! Former::text('pdfupload') !!}
2013-12-07 19:45:00 +01:00
</div>
@if (!Utils::hasFeature(FEATURE_MORE_INVOICE_DESIGNS) || \App\Models\InvoiceDesign::count() == COUNT_FREE_DESIGNS_SELF_HOST)
2015-07-21 20:51:56 +02:00
{!! 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') !!}
2016-01-10 11:25:05 +01:00
@else
2015-07-21 20:51:56 +02:00
{!! 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") !!}
@endif
2014-02-21 06:26:40 +01:00
2016-01-10 11:25:05 +01:00
{!! Button::primary(trans('texts.download_pdf'))->withAttributes(array('onclick' => 'onDownloadClick()'))->appendIcon(Icon::create('download-alt')) !!}
2015-11-16 20:21:48 +01:00
@if ($invoice->isClientTrashed())
<!-- do nothing -->
@elseif ($invoice->trashed())
{!! Button::success(trans('texts.restore'))->withAttributes(['onclick' => 'submitBulkAction("restore")'])->appendIcon(Icon::create('cloud-download')) !!}
@elseif (!$invoice->trashed())
2015-06-04 22:53:58 +02:00
{!! Button::success(trans("texts.save_{$entityType}"))->withAttributes(array('id' => 'saveButton', 'onclick' => 'onSaveClick()'))->appendIcon(Icon::create('floppy-disk')) !!}
2015-08-20 17:09:04 +02:00
{!! Button::info(trans("texts.email_{$entityType}"))->withAttributes(array('id' => 'emailButton', 'onclick' => 'onEmailClick()'))->appendIcon(Icon::create('send')) !!}
@if ($invoice->id)
2015-06-04 22:53:58 +02:00
{!! DropdownButton::normal(trans('texts.more_actions'))
->withContents($actions)
->dropup() !!}
@endif
2014-01-15 15:01:24 +01:00
@endif
2013-11-26 13:45:07 +01:00
</div>
2013-11-26 22:45:10 +01:00
<p>&nbsp;</p>
2014-10-12 20:11:41 +02:00
@include('invoices.pdf', ['account' => Auth::user()->account])
2013-11-26 13:45:07 +01:00
2014-04-25 15:04:57 +02:00
@if (!Auth::user()->account->isPro())
2014-04-23 14:47:44 +02:00
<div style="font-size:larger">
2015-06-10 22:55:23 +02:00
{!! trans('texts.pro_plan.remove_logo', ['link'=>'<a href="#" onclick="showProPlan(\'remove_logo\')">'.trans('texts.pro_plan.remove_logo_link').'</a>']) !!}
2014-04-23 14:47:44 +02:00
</div>
2014-04-03 22:01:03 +02:00
@endif
2013-11-26 13:45:07 +01:00
2013-12-27 10:10:32 +01:00
<div class="modal fade" id="clientModal" tabindex="-1" role="dialog" aria-labelledby="clientModalLabel" aria-hidden="true">
2015-04-20 16:34:23 +02:00
<div class="modal-dialog" data-bind="css: {'large-dialog': $root.showMore}">
<div class="modal-content" style="background-color: #f8f8f8">
2013-11-26 13:45:07 +01:00
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
2014-03-27 13:25:31 +01:00
<h4 class="modal-title" id="clientModalLabel">{{ trans('texts.client') }}</h4>
2013-11-26 13:45:07 +01:00
</div>
2013-12-05 21:25:20 +01:00
2015-04-20 16:34:23 +02:00
<div class="container" style="width: 100%; padding-bottom: 0px !important">
<div class="panel panel-default">
<div class="panel-body">
<div class="row" data-bind="with: client" onkeypress="clientModalEnterClick(event)">
<div style="margin-left:0px;margin-right:0px" data-bind="css: {'col-md-6': $root.showMore}">
2015-10-28 20:22:07 +01:00
{!! Former::hidden('client_public_id')->data_bind("value: public_id, valueUpdate: 'afterkeydown',
attr: {name: 'client[public_id]'}") !!}
{!! Former::text('client[name]')
->data_bind("value: name, valueUpdate: 'afterkeydown', attr { placeholder: name.placeholder }")
->label('client_name') !!}
2015-04-20 16:34:23 +02:00
<span data-bind="visible: $root.showMore">
2016-01-19 14:01:19 +01:00
2015-10-28 20:22:07 +01:00
{!! Former::text('client[id_number]')
->label('id_number')
->data_bind("value: id_number, valueUpdate: 'afterkeydown'") !!}
{!! Former::text('client[vat_number]')
->label('vat_number')
->data_bind("value: vat_number, valueUpdate: 'afterkeydown'") !!}
2016-01-10 11:25:05 +01:00
2015-10-28 20:22:07 +01:00
{!! Former::text('client[website]')
->label('website')
->data_bind("value: website, valueUpdate: 'afterkeydown'") !!}
{!! Former::text('client[work_phone]')
->label('work_phone')
->data_bind("value: work_phone, valueUpdate: 'afterkeydown'") !!}
2016-05-22 21:17:57 +02:00
2015-10-25 08:49:10 +01:00
</span>
2015-04-20 16:34:23 +02:00
@if (Auth::user()->hasFeature(FEATURE_INVOICE_SETTINGS))
2015-10-25 08:49:10 +01:00
@if ($account->custom_client_label1)
2015-10-28 20:22:07 +01:00
{!! Former::text('client[custom_value1]')
->label($account->custom_client_label1)
2015-10-25 08:49:10 +01:00
->data_bind("value: custom_value1, valueUpdate: 'afterkeydown'") !!}
@endif
@if ($account->custom_client_label2)
2015-10-28 20:22:07 +01:00
{!! Former::text('client[custom_value2]')
->label($account->custom_client_label2)
2015-10-25 08:49:10 +01:00
->data_bind("value: custom_value2, valueUpdate: 'afterkeydown'") !!}
@endif
@endif
2015-04-20 16:34:23 +02:00
2015-10-25 08:49:10 +01:00
<span data-bind="visible: $root.showMore">
2015-04-20 16:34:23 +02:00
&nbsp;
2015-10-28 20:22:07 +01:00
{!! Former::text('client[address1]')
->label(trans('texts.address1'))
->data_bind("value: address1, valueUpdate: 'afterkeydown'") !!}
{!! Former::text('client[address2]')
->label(trans('texts.address2'))
->data_bind("value: address2, valueUpdate: 'afterkeydown'") !!}
{!! Former::text('client[city]')
->label(trans('texts.city'))
->data_bind("value: city, valueUpdate: 'afterkeydown'") !!}
{!! Former::text('client[state]')
->label(trans('texts.state'))
->data_bind("value: state, valueUpdate: 'afterkeydown'") !!}
{!! Former::text('client[postal_code]')
->label(trans('texts.postal_code'))
->data_bind("value: postal_code, valueUpdate: 'afterkeydown'") !!}
{!! Former::select('client[country_id]')
->label(trans('texts.country_id'))
->addOption('','')->addGroupClass('country_select')
->fromQuery(Cache::get('countries'), 'name', 'id')->data_bind("dropdown: country_id") !!}
2015-04-20 16:34:23 +02:00
</span>
</div>
<div style="margin-left:0px;margin-right:0px" data-bind="css: {'col-md-6': $root.showMore}">
<div data-bind='template: { foreach: contacts,
beforeRemove: hideContact,
afterAdd: showContact }'>
2015-10-28 20:22:07 +01:00
{!! Former::hidden('public_id')->data_bind("value: public_id, valueUpdate: 'afterkeydown',
attr: {name: 'client[contacts][' + \$index() + '][public_id]'}") !!}
2016-01-10 11:25:05 +01:00
{!! Former::text('first_name')->data_bind("value: first_name, valueUpdate: 'afterkeydown',
2015-10-28 20:22:07 +01:00
attr: {name: 'client[contacts][' + \$index() + '][first_name]'}") !!}
{!! Former::text('last_name')->data_bind("value: last_name, valueUpdate: 'afterkeydown',
attr: {name: 'client[contacts][' + \$index() + '][last_name]'}") !!}
2016-01-10 11:25:05 +01:00
{!! Former::text('email')->data_bind("value: email, valueUpdate: 'afterkeydown',
2015-11-09 12:46:53 +01:00
attr: {name: 'client[contacts][' + \$index() + '][email]', id:'email'+\$index()}")
->addClass('client-email') !!}
2015-10-28 20:22:07 +01:00
{!! Former::text('phone')->data_bind("value: phone, valueUpdate: 'afterkeydown',
attr: {name: 'client[contacts][' + \$index() + '][phone]'}") !!}
@if ($account->hasFeature(FEATURE_CLIENT_PORTAL_PASSWORD) && $account->enable_portal_password)
{!! Former::password('password')->data_bind("value: (typeof password=='function'?password():null)?'-%unchanged%-':'', valueUpdate: 'afterkeydown',
attr: {name: 'client[contacts][' + \$index() + '][password]'}") !!}
@endif
2015-04-20 16:34:23 +02:00
<div class="form-group">
<div class="col-lg-8 col-lg-offset-4">
<span class="redlink bold" data-bind="visible: $parent.contacts().length > 1">
{!! link_to('#', trans('texts.remove_contact').' -', array('data-bind'=>'click: $parent.removeContact')) !!}
2016-01-10 11:25:05 +01:00
</span>
2015-04-20 16:34:23 +02:00
<span data-bind="visible: $index() === ($parent.contacts().length - 1)" class="pull-right greenlink bold">
{!! link_to('#', trans('texts.add_contact').' +', array('data-bind'=>'click: $parent.addContact')) !!}
</span>
</div>
</div>
</div>
2013-12-05 21:25:20 +01:00
2015-10-25 08:49:10 +01:00
<span data-bind="visible: $root.showMore">
2015-04-20 16:34:23 +02:00
&nbsp;
</span>
2015-10-28 20:22:07 +01:00
{!! Former::select('client[currency_id]')->addOption('','')
->placeholder($account->currency ? $account->currency->name : '')
->label(trans('texts.currency_id'))
->data_bind('value: currency_id')
->fromQuery($currencies, 'name', 'id') !!}
2015-04-20 16:34:23 +02:00
<span data-bind="visible: $root.showMore">
2015-10-28 20:22:07 +01:00
{!! Former::select('client[language_id]')->addOption('','')
->placeholder($account->language ? $account->language->name : '')
->label(trans('texts.language_id'))
->data_bind('value: language_id')
2016-01-10 11:25:05 +01:00
->fromQuery($languages, 'name', 'id') !!}
2015-10-28 20:22:07 +01:00
{!! Former::select('client[payment_terms]')->addOption('','')->data_bind('value: payment_terms')
->fromQuery($paymentTerms, 'name', 'num_days')
->label(trans('texts.payment_terms'))
->help(trans('texts.payment_terms_help')) !!}
{!! Former::select('client[size_id]')->addOption('','')->data_bind('value: size_id')
->label(trans('texts.size_id'))
->fromQuery($sizes, 'name', 'id') !!}
{!! Former::select('client[industry_id]')->addOption('','')->data_bind('value: industry_id')
->label(trans('texts.industry_id'))
->fromQuery($industries, 'name', 'id') !!}
{!! Former::textarea('client_private_notes')
->label(trans('texts.private_notes'))
->data_bind("value: private_notes, attr:{ name: 'client[private_notes]'}") !!}
2015-04-20 16:34:23 +02:00
</span>
</div>
</div>
</div>
</div>
</div>
<div class="modal-footer" style="margin-top: 0px; padding-top:0px;">
2015-04-30 19:54:19 +02:00
<span class="error-block" id="emailError" style="display:none;float:left;font-weight:bold">{{ trans('texts.provide_name_or_email') }}</span><span>&nbsp;</span>
2015-04-20 16:34:23 +02:00
<button type="button" class="btn btn-default" data-dismiss="modal">{{ trans('texts.cancel') }}</button>
<button type="button" class="btn btn-default" data-bind="click: $root.showMoreFields, text: $root.showMore() ? '{{ trans('texts.less_fields') }}' : '{{ trans('texts.more_fields') }}'"></button>
2016-01-10 11:25:05 +01:00
<button id="clientDoneButton" type="button" class="btn btn-primary" data-bind="click: $root.clientFormComplete">{{ trans('texts.done') }}</button>
2015-04-20 16:34:23 +02:00
</div>
2016-01-10 11:25:05 +01:00
2015-04-20 16:34:23 +02:00
</div>
</div>
</div>
2013-12-27 10:10:32 +01:00
2014-01-15 15:01:24 +01:00
<div class="modal fade" id="recurringModal" tabindex="-1" role="dialog" aria-labelledby="recurringModalLabel" aria-hidden="true">
<div class="modal-dialog" style="min-width:150px">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
2014-03-27 13:25:31 +01:00
<h4 class="modal-title" id="recurringModalLabel">{{ trans('texts.recurring_invoices') }}</h4>
2014-01-15 15:01:24 +01:00
</div>
<div style="background-color: #fff; padding-left: 16px; padding-right: 16px">
2015-03-31 11:38:24 +02:00
&nbsp; {!! isset($recurringHelp) ? $recurringHelp : '' !!} &nbsp;
2014-01-15 15:01:24 +01:00
</div>
<div class="modal-footer" style="margin-top: 0px">
2014-04-10 21:29:01 +02:00
<button type="button" class="btn btn-primary" data-dismiss="modal">{{ trans('texts.close') }}</button>
2014-01-15 15:01:24 +01:00
</div>
2016-01-10 11:25:05 +01:00
2014-01-15 15:01:24 +01:00
</div>
</div>
</div>
2016-01-11 20:41:02 +01:00
<div class="modal fade" id="recurringDueDateModal" tabindex="-1" role="dialog" aria-labelledby="recurringDueDateModalLabel" aria-hidden="true">
<div class="modal-dialog" style="min-width:150px">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
<h4 class="modal-title" id="recurringDueDateModalLabel">{{ trans('texts.recurring_due_dates') }}</h4>
</div>
<div style="background-color: #fff; padding-left: 16px; padding-right: 16px">
&nbsp; {!! isset($recurringDueDateHelp) ? $recurringDueDateHelp : '' !!} &nbsp;
</div>
<div class="modal-footer" style="margin-top: 0px">
<button type="button" class="btn btn-primary" data-dismiss="modal">{{ trans('texts.close') }}</button>
</div>
2016-01-11 20:41:02 +01:00
</div>
</div>
</div>
2014-01-15 15:01:24 +01:00
2015-03-27 06:02:19 +01:00
{!! Former::close() !!}
2014-01-15 15:01:24 +01:00
2015-10-28 20:22:07 +01:00
{!! Former::open("{$entityType}s/bulk")->addClass('bulkForm') !!}
{!! Former::populateField('bulk_public_id', $invoice->public_id) !!}
<span style="display:none">
{!! Former::text('bulk_public_id') !!}
{!! Former::text('bulk_action') !!}
</span>
{!! Former::close() !!}
2015-04-20 16:34:23 +02:00
</div>
2013-11-26 13:45:07 +01:00
2015-10-22 20:48:12 +02:00
@include('invoices.knockout')
2013-11-26 13:45:07 +01:00
<script type="text/javascript">
2016-03-23 03:23:45 +01:00
Dropzone.autoDiscover = false;
2016-01-10 11:25:05 +01:00
2015-10-22 20:48:12 +02:00
var products = {!! $products !!};
2016-01-10 11:25:05 +01:00
var clients = {!! $clients !!};
2015-10-22 20:48:12 +02:00
var account = {!! Auth::user()->account !!};
2016-03-23 03:23:45 +01:00
var dropzone;
2015-10-22 20:48:12 +02:00
var clientMap = {};
var $clientSelect = $('select#client');
var invoiceDesigns = {!! $invoiceDesigns !!};
2016-01-07 08:08:30 +01:00
var invoiceFonts = {!! $invoiceFonts !!};
2016-05-22 21:17:57 +02:00
2013-11-26 13:45:07 +01:00
$(function() {
2015-10-22 20:48:12 +02:00
// create client dictionary
for (var i=0; i<clients.length; i++) {
var client = clients[i];
var clientName = getClientDisplayName(client);
for (var j=0; j<client.contacts.length; j++) {
var contact = client.contacts[j];
var contactName = getContactDisplayName(contact);
2015-11-06 08:54:29 +01:00
if (contact.is_primary === '1') {
2015-10-22 20:48:12 +02:00
contact.send_invoice = true;
}
if (clientName != contactName) {
2016-01-10 11:25:05 +01:00
$clientSelect.append(new Option(contactName, client.public_id));
2015-10-22 20:48:12 +02:00
}
}
clientMap[client.public_id] = client;
2016-01-10 11:25:05 +01:00
$clientSelect.append(new Option(clientName, client.public_id));
2015-10-22 20:48:12 +02:00
}
@if ($data)
// this means we failed so we'll reload the previous state
window.model = new ViewModel({!! $data !!});
2016-01-10 11:25:05 +01:00
@else
2015-10-22 20:48:12 +02:00
// otherwise create blank model
window.model = new ViewModel();
2015-10-23 13:55:18 +02:00
var invoice = {!! $invoice !!};
ko.mapping.fromJS(invoice, model.invoice().mapping, model.invoice);
2015-10-28 20:22:07 +01:00
model.invoice().is_recurring({{ $invoice->is_recurring ? '1' : '0' }});
2015-10-23 13:55:18 +02:00
@if ($invoice->id)
2015-10-22 20:48:12 +02:00
var invitationContactIds = {!! json_encode($invitationContactIds) !!};
var client = clientMap[invoice.client.public_id];
if (client) { // in case it's deleted
for (var i=0; i<client.contacts.length; i++) {
var contact = client.contacts[i];
contact.send_invoice = invitationContactIds.indexOf(contact.public_id) >= 0;
}
}
model.invoice().addItem(); // add blank item
@else
model.invoice().custom_taxes1({{ $account->custom_invoice_taxes1 ? 'true' : 'false' }});
model.invoice().custom_taxes2({{ $account->custom_invoice_taxes2 ? 'true' : 'false' }});
// set the default account tax rate
2016-03-29 16:30:28 +02:00
@if ($account->invoice_taxes && ! empty($defaultTax))
var defaultTax = {!! $defaultTax !!};
2016-03-31 11:29:01 +02:00
model.invoice().tax_rate1(defaultTax.rate);
model.invoice().tax_name1(defaultTax.name);
2015-10-22 20:48:12 +02:00
@endif
@endif
@if (isset($tasks) && $tasks)
// move the blank invoice line item to the end
var blank = model.invoice().invoice_items.pop();
var tasks = {!! $tasks !!};
2016-01-10 11:25:05 +01:00
2015-10-22 20:48:12 +02:00
for (var i=0; i<tasks.length; i++) {
2015-12-13 21:12:54 +01:00
var task = tasks[i];
2015-10-22 20:48:12 +02:00
var item = model.invoice().addItem();
item.notes(task.description);
item.qty(task.duration);
item.task_public_id(task.publicId);
2015-12-13 21:12:54 +01:00
}
2015-10-22 20:48:12 +02:00
model.invoice().invoice_items.push(blank);
model.invoice().has_tasks(true);
2015-12-13 21:12:54 +01:00
@endif
2016-01-10 11:25:05 +01:00
2016-05-29 15:46:21 +02:00
if(model.invoice().expenses().length && !model.invoice().public_id()){
2016-04-11 10:44:53 +02:00
model.expense_currency_id({{ isset($expenseCurrencyId) ? $expenseCurrencyId : 0 }});
2016-01-10 11:25:05 +01:00
// move the blank invoice line item to the end
var blank = model.invoice().invoice_items.pop();
var expenses = model.invoice().expenses();
2016-01-10 11:25:05 +01:00
for (var i=0; i<expenses.length; i++) {
var expense = expenses[i];
var item = model.invoice().addItem();
item.notes(expense.public_notes());
item.qty(1);
item.expense_public_id(expense.public_id());
item.cost(expense.converted_amount());
2016-01-10 11:25:05 +01:00
}
model.invoice().invoice_items.push(blank);
model.invoice().has_expenses(true);
}
2016-01-10 11:25:05 +01:00
2015-10-22 20:48:12 +02:00
@endif
2016-05-22 21:17:57 +02:00
2015-10-22 20:48:12 +02:00
// display blank instead of '0'
if (!NINJA.parseFloat(model.invoice().discount())) model.invoice().discount('');
if (!NINJA.parseFloat(model.invoice().partial())) model.invoice().partial('');
if (!model.invoice().custom_value1()) model.invoice().custom_value1('');
if (!model.invoice().custom_value2()) model.invoice().custom_value2('');
ko.applyBindings(model);
onItemChange();
2016-01-10 11:25:05 +01:00
2015-10-22 20:48:12 +02:00
2014-03-17 19:05:01 +01:00
$('#country_id').combobox().on('change', function(e) {
2015-09-07 11:07:55 +02:00
var countryId = $('input[name=country_id]').val();
var country = _.findWhere(countries, {id: countryId});
if (country) {
model.invoice().client().country = country;
model.invoice().client().country_id(countryId);
} else {
2014-03-17 19:05:01 +01:00
model.invoice().client().country = false;
model.invoice().client().country_id(0);
}
});
2015-06-03 19:55:48 +02:00
$('[rel=tooltip]').tooltip({'trigger':'manual'});
2013-12-05 21:25:20 +01:00
$('#invoice_date, #due_date, #start_date, #end_date, #last_sent_date').datepicker();
2013-11-28 17:40:13 +01:00
2015-10-23 13:55:18 +02:00
@if ($invoice->client && !$invoice->id)
$('input[name=client]').val({{ $invoice->client->public_id }});
2013-12-29 18:40:11 +01:00
@endif
2016-01-10 11:25:05 +01:00
2013-11-26 13:45:07 +01:00
var $input = $('select#client');
2013-12-31 17:38:49 +01:00
$input.combobox().on('change', function(e) {
2015-12-29 08:52:02 +01:00
var oldId = model.invoice().client().public_id();
var clientId = parseInt($('input[name=client]').val(), 10) || 0;
2016-01-10 11:25:05 +01:00
if (clientId > 0) {
2015-10-22 20:48:12 +02:00
var selected = clientMap[clientId];
model.loadClient(selected);
2016-01-10 11:25:05 +01:00
// we enable searching by contact but the selection must be the client
2015-10-22 20:48:12 +02:00
$('.client-input').val(getClientDisplayName(selected));
// if there's an invoice number pattern we'll apply it now
2015-10-23 14:54:07 +02:00
setInvoiceNumber(selected);
2015-12-29 11:23:50 +01:00
refreshPDF(true);
2015-12-29 08:52:02 +01:00
} else if (oldId) {
2014-01-02 09:27:48 +01:00
model.loadClient($.parseJSON(ko.toJSON(new ClientModel())));
2015-10-22 20:48:12 +02:00
model.invoice().client().country = false;
2015-12-29 11:23:50 +01:00
refreshPDF(true);
2015-10-22 20:48:12 +02:00
}
2014-07-07 08:43:16 +02:00
});
// If no clients exists show the client form when clicking on the client select input
if (clients.length === 0) {
$('.client_select input.form-control').on('click', function() {
model.showClientForm();
});
2016-01-10 11:25:05 +01:00
}
2013-11-26 13:45:07 +01:00
2015-10-22 20:48:12 +02:00
$('#invoice_footer, #terms, #public_notes, #invoice_number, #invoice_date, #due_date, #start_date, #po_number, #discount, #currency_id, #invoice_design_id, #recurring, #is_amount_discount, #partial, #custom_text_value1, #custom_text_value2').change(function() {
2015-12-29 08:52:02 +01:00
setTimeout(function() {
2015-07-21 20:51:56 +02:00
refreshPDF(true);
2014-05-04 11:11:08 +02:00
}, 1);
2013-12-30 21:17:45 +01:00
});
2013-12-24 22:27:36 +01:00
$('.frequency_id .input-group-addon').click(function() {
showLearnMore();
});
$('.recurring_due_date .input-group-addon').click(function() {
showRecurringDueDateLearnMore();
});
var fields = ['invoice_date', 'due_date', 'start_date', 'end_date', 'last_sent_date'];
for (var i=0; i<fields.length; i++) {
var field = fields[i];
(function (_field) {
$('.' + _field + ' .input-group-addon').click(function() {
toggleDatePicker(_field);
2016-01-10 11:25:05 +01:00
});
})(field);
}
if (model.invoice().client().public_id() || {{ $invoice->id || count($clients) == 0 ? '1' : '0' }}) {
$('#invoice_number').focus();
} else {
$('.client_select input.form-control').focus();
}
2016-01-10 11:25:05 +01:00
2013-12-29 00:33:48 +01:00
$('#clientModal').on('shown.bs.modal', function () {
2015-11-02 23:05:28 +01:00
$('#client\\[name\\]').focus();
2013-12-29 00:33:48 +01:00
}).on('hidden.bs.modal', function () {
2013-12-17 14:14:47 +01:00
if (model.clientBackup) {
model.loadClient(model.clientBackup);
2015-07-21 20:51:56 +02:00
refreshPDF(true);
2013-12-17 14:14:47 +01:00
}
2013-11-26 13:45:07 +01:00
})
2016-01-10 11:25:05 +01:00
2014-01-02 18:16:00 +01:00
$('#relatedActions > button:first').click(function() {
2014-01-15 15:01:24 +01:00
onPaymentClick();
2014-01-02 18:16:00 +01:00
});
2013-12-10 23:10:43 +01:00
$('label.radio').addClass('radio-inline');
2016-01-10 11:25:05 +01:00
2015-10-23 13:55:18 +02:00
@if ($invoice->client->id)
2014-01-06 19:03:00 +01:00
$input.trigger('change');
2016-01-10 11:25:05 +01:00
@else
2015-07-21 20:51:56 +02:00
refreshPDF(true);
2014-01-06 19:03:00 +01:00
@endif
2014-01-02 00:12:33 +01:00
var client = model.invoice().client();
2016-01-10 11:25:05 +01:00
setComboboxValue($('.client_select'),
client.public_id(),
client.name.display());
2015-07-12 21:43:45 +02:00
@if (isset($tasks) && $tasks)
NINJA.formIsChanged = true;
@endif
2015-12-29 08:52:02 +01:00
2016-01-10 11:25:05 +01:00
@if (isset($expenses) && $expenses)
NINJA.formIsChanged = true;
@endif
2015-12-29 08:52:02 +01:00
applyComboboxListeners();
2016-05-22 21:17:57 +02:00
@if (Auth::user()->account->hasFeature(FEATURE_DOCUMENTS))
$('.main-form').submit(function(){
if($('#document-upload .dropzone .fallback input').val())$(this).attr('enctype', 'multipart/form-data')
else $(this).removeAttr('enctype')
})
2016-05-22 21:17:57 +02:00
2016-03-23 03:23:45 +01:00
// Initialize document upload
2016-05-25 11:00:37 +02:00
window.dropzone = false;
$('a[data-toggle="tab"]').on('shown.bs.tab', function (e) {
if (window.dropzone) {
return;
}
var target = $(e.target).attr('href') // activated tab
if (target != '#attached-documents') {
return;
}
window.dropzone = new Dropzone('#document-upload .dropzone', {
url:{!! json_encode(url('document')) !!},
params:{
_token:"{{ Session::getToken() }}"
},
acceptedFiles:{!! json_encode(implode(',',\App\Models\Document::$allowedMimes)) !!},
addRemoveLinks:true,
2016-05-26 18:04:43 +02:00
dictRemoveFileConfirmation:"{{trans('texts.are_you_sure')}}",
2016-05-25 15:28:24 +02:00
@foreach(trans('texts.dropzone') as $key=>$text)
"dict{{strval($key)}}":"{{strval($text)}}",
2016-05-25 11:00:37 +02:00
@endforeach
2016-05-29 17:40:01 +02:00
maxFilesize:{{floatval(MAX_DOCUMENT_SIZE/1000)}},
2016-05-25 11:00:37 +02:00
});
if(dropzone instanceof Dropzone){
dropzone.on("addedfile",handleDocumentAdded);
dropzone.on("removedfile",handleDocumentRemoved);
dropzone.on("success",handleDocumentUploaded);
dropzone.on("canceled",handleDocumentCanceled);
2016-05-29 17:43:57 +02:00
dropzone.on("error",handleDocumentError);
2016-05-25 11:00:37 +02:00
for (var i=0; i<model.invoice().documents().length; i++) {
var document = model.invoice().documents()[i];
var mockFile = {
name:document.name(),
size:document.size(),
type:document.type(),
public_id:document.public_id(),
status:Dropzone.SUCCESS,
accepted:true,
2016-05-25 14:19:15 +02:00
url:document.url(),
2016-05-25 11:00:37 +02:00
mock:true,
index:i
};
dropzone.emit('addedfile', mockFile);
dropzone.emit('complete', mockFile);
if(document.preview_url()){
dropzone.emit('thumbnail', mockFile, document.preview_url());
}
else if(document.type()=='jpeg' || document.type()=='png' || document.type()=='svg'){
dropzone.emit('thumbnail', mockFile, document.url());
}
dropzone.files.push(mockFile);
}
}
2016-05-25 11:00:37 +02:00
});
2016-03-23 03:59:20 +01:00
@endif
2016-01-10 11:25:05 +01:00
});
2016-01-11 20:41:02 +01:00
function onFrequencyChange(){
var currentName = $('#frequency_id').find('option:selected').text()
var currentDueDateNumber = $('#recurring_due_date').find('option:selected').attr('data-num');
var optionClass = currentName && currentName.toLowerCase().indexOf('week') > -1 ? 'weekly' : 'monthly';
var replacementOption = $('#recurring_due_date option[data-num=' + currentDueDateNumber + '].' + optionClass);
2016-01-11 20:41:02 +01:00
$('#recurring_due_date option').hide();
$('#recurring_due_date option.' + optionClass).show();
2016-01-11 20:41:02 +01:00
// Switch to an equivalent option
if(replacementOption.length){
replacementOption.attr('selected','selected');
}
else{
$('#recurring_due_date').val('');
}
}
2013-11-26 13:45:07 +01:00
function applyComboboxListeners() {
2015-12-29 20:05:08 +01:00
var selectorStr = '.invoice-table input, .invoice-table textarea';
2015-12-29 08:52:02 +01:00
$(selectorStr).off('change').on('change', function(event) {
if ($(event.target).hasClass('handled')) {
return;
}
2015-12-29 08:52:02 +01:00
onItemChange();
refreshPDF(true);
2013-12-31 10:43:39 +01:00
});
2015-12-29 20:05:08 +01:00
var selectorStr = '.invoice-table select';
$(selectorStr).off('blur').on('blur', function(event) {
onItemChange();
refreshPDF(true);
});
$('textarea').on('keyup focus', function(e) {
2015-05-09 20:25:16 +02:00
while($(this).outerHeight() < this.scrollHeight + parseFloat($(this).css("borderTopWidth")) + parseFloat($(this).css("borderBottomWidth"))) {
$(this).height($(this).height()+1);
};
2015-09-29 20:19:18 +02:00
});
}
2013-11-26 13:45:07 +01:00
function createInvoiceModel() {
var model = ko.toJS(window.model);
if(!model)return;
var invoice = model.invoice;
invoice.features = {
customize_invoice_design:{{ Auth::user()->hasFeature(FEATURE_CUSTOMIZE_INVOICE_DESIGN) ? 'true' : 'false' }},
remove_created_by:{{ Auth::user()->hasFeature(FEATURE_REMOVE_CREATED_BY) ? 'true' : 'false' }},
invoice_settings:{{ Auth::user()->hasFeature(FEATURE_INVOICE_SETTINGS) ? 'true' : 'false' }}
};
2015-11-08 21:34:26 +01:00
invoice.is_quote = {{ $entityType == ENTITY_QUOTE ? 'true' : 'false' }};
2014-12-03 23:05:38 +01:00
invoice.contact = _.findWhere(invoice.client.contacts, {send_invoice: true});
2014-04-13 15:34:58 +02:00
if (invoice.is_recurring) {
2015-12-29 18:49:40 +01:00
invoice.invoice_number = "{{ trans('texts.assigned_when_sent') }}";
2015-10-22 20:48:12 +02:00
if (invoice.start_date) {
invoice.invoice_date = invoice.start_date;
}
}
2015-10-29 15:49:37 +01:00
@if (!$invoice->id)
2015-04-27 14:28:40 +02:00
if (!invoice.terms) {
2015-12-17 09:19:56 +01:00
invoice.terms = account['{{ $entityType }}_terms'];
2015-04-27 14:28:40 +02:00
}
if (!invoice.invoice_footer) {
2015-12-17 09:19:56 +01:00
invoice.invoice_footer = account['invoice_footer'];
2015-04-27 14:28:40 +02:00
}
@endif
2015-02-28 22:42:47 +01:00
2016-01-18 15:09:06 +01:00
@if ($account->hasLogo())
invoice.image = "{{ Form::image_data($account->getLogoRaw(), true) }}";
2014-03-18 22:25:54 +01:00
invoice.imageWidth = {{ $account->getLogoWidth() }};
invoice.imageHeight = {{ $account->getLogoHeight() }};
@endif
2014-02-21 06:26:40 +01:00
2015-12-13 21:12:54 +01:00
//invoiceLabels.item = invoice.has_tasks ? invoiceLabels.date : invoiceLabels.item_orig;
2015-06-10 10:34:20 +02:00
invoiceLabels.quantity = invoice.has_tasks ? invoiceLabels.hours : invoiceLabels.quantity_orig;
2015-12-13 21:12:54 +01:00
invoiceLabels.unit_cost = invoice.has_tasks ? invoiceLabels.rate : invoiceLabels.unit_cost_orig;
2015-06-10 10:34:20 +02:00
2015-04-13 14:49:40 +02:00
return invoice;
2013-11-26 13:45:07 +01:00
}
window.generatedPDF = false;
2015-07-21 20:51:56 +02:00
function getPDFString(cb, force) {
@if (!$account->live_preview)
if (window.generatedPDF) {
return;
}
@endif
2015-07-24 16:13:17 +02:00
var invoice = createInvoiceModel();
2014-10-12 20:11:41 +02:00
var design = getDesignJavascript();
if (!design) return;
2015-07-21 20:51:56 +02:00
generatePDF(invoice, design, force, cb);
window.generatedPDF = true;
2014-03-10 12:04:15 +01:00
}
2014-04-14 13:33:43 +02:00
2014-10-12 20:11:41 +02:00
function getDesignJavascript() {
var id = $('#invoice_design_id').val();
if (id == '-1') {
showMoreDesigns();
2014-10-25 19:32:28 +02:00
model.invoice().invoice_design_id(1);
return invoiceDesigns[0].javascript;
} else {
2015-07-21 20:51:56 +02:00
var design = _.find(invoiceDesigns, function(design){ return design.id == id});
return design ? design.javascript : '';
}
2013-12-07 19:45:00 +01:00
}
2013-11-26 13:45:07 +01:00
2015-09-07 11:07:55 +02:00
function resetTerms() {
2015-09-17 21:01:06 +02:00
if (confirm('{!! trans("texts.are_you_sure") !!}')) {
model.invoice().terms(model.invoice().default_terms());
refreshPDF();
}
2015-09-07 11:07:55 +02:00
return false;
}
function resetFooter() {
2015-09-17 21:01:06 +02:00
if (confirm('{!! trans("texts.are_you_sure") !!}')) {
model.invoice().invoice_footer(model.invoice().default_footer());
refreshPDF();
}
2015-09-07 11:07:55 +02:00
return false;
}
2013-11-26 13:45:07 +01:00
function onDownloadClick() {
2015-06-01 15:06:18 +02:00
trackEvent('/activity', '/download_pdf');
2013-11-26 13:45:07 +01:00
var invoice = createInvoiceModel();
2015-10-23 13:55:18 +02:00
var design = getDesignJavascript();
if (!design) return;
var doc = generatePDF(invoice, design, true);
2015-05-09 20:25:16 +02:00
var type = invoice.is_quote ? '{{ trans('texts.'.ENTITY_QUOTE) }}' : '{{ trans('texts.'.ENTITY_INVOICE) }}';
doc.save(type +'-' + $('#invoice_number').val() + '.pdf');
2013-11-26 13:45:07 +01:00
}
function onEmailClick() {
if (!NINJA.isRegistered) {
alert("{!! trans('texts.registration_required') !!}");
return;
}
if (!isEmailValid()) {
alert("{!! trans('texts.provide_email') !!}");
2015-07-07 22:08:16 +02:00
return;
}
if (confirm('{!! trans("texts.confirm_email_$entityType") !!}' + '\n\n' + getSendToEmails())) {
2015-04-22 23:40:21 +02:00
preparePdfData('email');
2013-11-26 13:45:07 +01:00
}
}
2013-12-11 21:33:44 +01:00
function onSaveClick() {
2015-10-15 16:14:13 +02:00
if (model.invoice().is_recurring() && {{ $invoice ? 'false' : 'true' }}) {
if (confirm("{!! trans("texts.confirm_recurring_email_$entityType") !!}" + '\n\n' + getSendToEmails() + '\n' + "{!! trans("texts.confirm_recurring_timing") !!}")) {
submitAction('');
}
} else {
submitAction('');
}
2014-07-30 09:08:01 +02:00
}
2015-07-07 22:08:16 +02:00
function getSendToEmails() {
var client = model.invoice().client();
var parts = [];
for (var i=0; i<client.contacts().length; i++) {
var contact = client.contacts()[i];
if (contact.send_invoice()) {
parts.push(contact.displayName());
}
2015-12-29 08:52:02 +01:00
}
2015-07-07 22:08:16 +02:00
return parts.join('\n');
}
2015-04-22 23:40:21 +02:00
function preparePdfData(action) {
var invoice = createInvoiceModel();
2015-12-29 08:52:02 +01:00
var design = getDesignJavascript();
2015-04-22 23:40:21 +02:00
if (!design) return;
2016-01-10 11:25:05 +01:00
2015-04-22 23:40:21 +02:00
doc = generatePDF(invoice, design, true);
doc.getDataUrl( function(pdfString){
2015-09-17 21:01:06 +02:00
$('#pdfupload').val(pdfString);
submitAction(action);
});
2015-04-22 23:40:21 +02:00
}
2014-07-30 09:08:01 +02:00
function submitAction(value) {
$('#action').val(value);
$('#submitButton').click();
}
function onFormSubmit(event) {
if (window.countUploadingDocuments > 0) {
return false;
}
if (!isSaveValid()) {
model.showClientForm();
return false;
}
// check currency matches for expenses
var expenseCurrencyId = model.expense_currency_id();
var clientCurrencyId = model.invoice().client().currency_id() || {{ $account->getCurrencyId() }};
if (expenseCurrencyId && expenseCurrencyId != clientCurrencyId) {
alert("{!! trans('texts.expense_error_mismatch_currencies') !!}");
return false;
}
2015-06-03 19:55:48 +02:00
onPartialChange(true);
2016-05-22 21:17:57 +02:00
return true;
}
2015-10-28 20:22:07 +01:00
function submitBulkAction(value) {
$('#bulk_action').val(value);
$('.bulkForm').submit();
}
2014-03-09 22:19:56 +01:00
function isSaveValid() {
var isValid = false;
2014-07-30 09:08:01 +02:00
for (var i=0; i<model.invoice().client().contacts().length; i++) {
var contact = model.invoice().client().contacts()[i];
2015-04-16 19:12:56 +02:00
if (isValidEmailAddress(contact.email()) || contact.first_name()) {
2014-03-09 22:19:56 +01:00
isValid = true;
} else {
isValid = false;
break;
}
}
return isValid;
}
2016-01-10 11:25:05 +01:00
2014-03-09 22:19:56 +01:00
function isEmailValid() {
2015-11-16 20:21:48 +01:00
var isValid = true;
2014-03-09 22:19:56 +01:00
var sendTo = false;
var client = model.invoice().client();
2014-03-09 22:19:56 +01:00
for (var i=0; i<client.contacts().length; i++) {
2015-11-16 20:21:48 +01:00
var contact = client.contacts()[i];
if ( ! contact.send_invoice()) {
continue;
}
2014-03-09 22:19:56 +01:00
if (isValidEmailAddress(contact.email())) {
isValid = true;
2015-11-16 20:21:48 +01:00
sendTo = true;
2014-03-09 22:19:56 +01:00
} else {
isValid = false;
break;
}
}
return (isValid && sendTo)
}
2014-12-07 09:47:58 +01:00
function onMarkClick() {
2015-10-29 15:42:05 +01:00
submitBulkAction('markSent');
2014-12-07 09:47:58 +01:00
}
2013-12-11 21:33:44 +01:00
function onCloneClick() {
2014-07-30 09:08:01 +02:00
submitAction('clone');
2013-12-11 21:33:44 +01:00
}
2014-05-20 23:40:09 +02:00
function onConvertClick() {
2016-01-10 11:25:05 +01:00
submitAction('convert');
2014-05-20 23:40:09 +02:00
}
2015-10-23 13:55:18 +02:00
@if ($invoice->id)
function onPaymentClick() {
window.location = '{{ URL::to('payments/create/' . $invoice->client->public_id . '/' . $invoice->public_id ) }}';
}
2014-01-02 14:21:15 +01:00
2015-10-23 13:55:18 +02:00
function onCreditClick() {
window.location = '{{ URL::to('credits/create/' . $invoice->client->public_id . '/' . $invoice->public_id ) }}';
}
@endif
2016-01-10 11:25:05 +01:00
2013-12-03 18:32:33 +01:00
function onArchiveClick() {
2015-10-28 20:22:07 +01:00
submitBulkAction('archive');
2013-12-03 18:32:33 +01:00
}
function onDeleteClick() {
2015-10-28 20:22:07 +01:00
if (confirm('{!! trans("texts.are_you_sure") !!}')) {
submitBulkAction('delete');
2016-01-10 11:25:05 +01:00
}
2013-12-03 18:32:33 +01:00
}
function formEnterClick(event) {
if (event.keyCode === 13){
if (event.target.type == 'textarea') {
return;
2013-12-11 21:33:44 +01:00
}
2015-10-25 08:13:06 +01:00
event.preventDefault();
2014-01-02 00:12:33 +01:00
2015-10-25 08:13:06 +01:00
@if($invoice->trashed())
return;
@endif
submitAction('');
return false;
2013-11-26 13:45:07 +01:00
}
}
2013-12-05 21:25:20 +01:00
2016-01-10 11:25:05 +01:00
function clientModalEnterClick(event) {
2013-11-26 13:45:07 +01:00
if (event.keyCode === 13){
2016-01-10 11:25:05 +01:00
event.preventDefault();
model.clientFormComplete();
2013-11-26 13:45:07 +01:00
return false;
}
}
2013-12-27 10:10:32 +01:00
function onItemChange()
2013-12-01 13:22:08 +01:00
{
var hasEmpty = false;
2014-01-01 18:34:37 +01:00
for(var i=0; i<model.invoice().invoice_items().length; i++) {
var item = model.invoice().invoice_items()[i];
2013-12-01 13:22:08 +01:00
if (item.isEmpty()) {
hasEmpty = true;
}
}
2013-12-27 10:10:32 +01:00
2013-12-01 13:22:08 +01:00
if (!hasEmpty) {
2014-01-01 18:34:37 +01:00
model.invoice().addItem();
2013-12-01 13:22:08 +01:00
}
2013-11-26 13:45:07 +01:00
}
2015-06-03 19:55:48 +02:00
function onPartialChange(silent)
2015-04-16 19:12:56 +02:00
{
2015-04-16 21:57:12 +02:00
var val = NINJA.parseFloat($('#partial').val());
2015-06-03 19:55:48 +02:00
var oldVal = val;
2015-04-16 21:57:12 +02:00
val = Math.max(Math.min(val, model.invoice().totals.rawTotal()), 0);
2015-06-03 19:55:48 +02:00
model.invoice().partial(val || '');
2016-01-10 11:25:05 +01:00
2015-06-03 19:55:48 +02:00
if (!silent && val != oldVal) {
$('#partial').tooltip('show');
setTimeout(function() {
$('#partial').tooltip('hide');
}, 5000);
}
2015-04-16 19:12:56 +02:00
}
function onRecurringEnabled()
2015-03-02 15:17:33 +01:00
{
if ($('#recurring').prop('checked')) {
2015-08-20 17:09:04 +02:00
$('#emailButton').attr('disabled', true);
2015-04-16 19:12:56 +02:00
model.invoice().partial('');
2015-03-02 15:17:33 +01:00
} else {
2015-08-20 17:09:04 +02:00
$('#emailButton').removeAttr('disabled');
2015-03-02 15:17:33 +01:00
}
}
2015-10-22 20:48:12 +02:00
function showLearnMore() {
2015-10-25 08:13:06 +01:00
$('#recurringModal').modal('show');
2015-10-22 20:48:12 +02:00
}
2014-01-01 18:34:37 +01:00
function showRecurringDueDateLearnMore() {
$('#recurringDueDateModal').modal('show');
}
2015-10-22 20:48:12 +02:00
function setInvoiceNumber(client) {
2015-10-23 14:54:07 +02:00
@if ($invoice->id || !$account->hasClientNumberPattern($invoice))
2015-10-22 20:48:12 +02:00
return;
@endif
2015-10-23 13:55:18 +02:00
var number = '{{ $account->getNumberPattern($invoice) }}';
2015-12-23 12:49:49 +01:00
number = number.replace('{$custom1}', client.custom_value1 ? client.custom_value1 : '');
number = number.replace('{$custom2}', client.custom_value2 ? client.custom_value1 : '');
2015-10-22 20:48:12 +02:00
model.invoice().invoice_number(number);
}
2016-05-22 21:17:57 +02:00
window.countUploadingDocuments = 0;
2016-06-05 17:47:51 +02:00
2016-03-23 03:23:45 +01:00
function handleDocumentAdded(file){
2016-05-22 21:17:57 +02:00
// open document when clicked
if (file.url) {
file.previewElement.addEventListener("click", function() {
window.open(file.url, '_blank');
});
}
2016-03-23 03:23:45 +01:00
if(file.mock)return;
file.index = model.invoice().documents().length;
model.invoice().addDocument({name:file.name, size:file.size, type:file.type});
window.countUploadingDocuments++;
2016-03-23 03:23:45 +01:00
}
2016-05-22 21:17:57 +02:00
2016-03-23 03:23:45 +01:00
function handleDocumentRemoved(file){
model.invoice().removeDocument(file.public_id);
2016-03-23 23:40:42 +01:00
refreshPDF(true);
2016-05-26 18:04:43 +02:00
$.ajax({
url: '{{ '/documents/' }}' + file.public_id,
type: 'DELETE',
success: function(result) {
// Do something with the result
}
});
2016-03-23 03:23:45 +01:00
}
2016-05-22 21:17:57 +02:00
2016-03-23 03:23:45 +01:00
function handleDocumentUploaded(file, response){
file.public_id = response.document.public_id
model.invoice().documents()[file.index].update(response.document);
window.countUploadingDocuments--;
2016-06-01 16:33:16 +02:00
@if ($account->invoice_embed_documents)
refreshPDF(true);
@endif
if(response.document.preview_url){
dropzone.emit('thumbnail', file, response.document.preview_url);
}
2016-03-23 03:23:45 +01:00
}
2016-05-29 17:43:57 +02:00
function handleDocumentCanceled() {
window.countUploadingDocuments--;
}
function handleDocumentError() {
window.countUploadingDocuments--;
}
2014-01-01 18:34:37 +01:00
2013-11-26 13:45:07 +01:00
</script>
@if ($account->hasFeature(FEATURE_DOCUMENTS) && $account->invoice_embed_documents)
2016-03-23 23:40:42 +01:00
@foreach ($invoice->documents as $document)
@if($document->isPDFEmbeddable())
<script src="{{ $document->getVFSJSUrl() }}" type="text/javascript" async></script>
@endif
2016-03-23 23:40:42 +01:00
@endforeach
@foreach ($invoice->expenses as $expense)
@foreach ($expense->documents as $document)
@if($document->isPDFEmbeddable())
<script src="{{ $document->getVFSJSUrl() }}" type="text/javascript" async></script>
@endif
@endforeach
@endforeach
2016-03-23 23:40:42 +01:00
@endif
2013-11-26 13:45:07 +01:00
2015-11-09 10:50:47 +01:00
@stop