2013-11-26 13:45:07 +01:00
|
|
|
@extends('header')
|
|
|
|
|
2013-12-08 14:32:49 +01:00
|
|
|
@section('head')
|
|
|
|
@parent
|
|
|
|
|
2015-12-07 14:34:55 +01:00
|
|
|
@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-06-05 21:55:23 +02:00
|
|
|
<script src="{{ asset('pdf.built.js') }}?no_cache={{ NINJA_VERSION }}" type="text/javascript"></script>
|
2016-02-25 11:16:27 +01:00
|
|
|
<script src="{{ asset('js/lightbox.min.js') }}" type="text/javascript"></script>
|
2016-07-21 14:35:23 +02:00
|
|
|
<link href="{{ asset('css/lightbox.css') }}" rel="stylesheet" type="text/css"/>
|
2015-10-25 08:13:06 +01:00
|
|
|
|
|
|
|
<style type="text/css">
|
2016-03-31 11:29:01 +02:00
|
|
|
select.tax-select {
|
|
|
|
width: 50%;
|
|
|
|
float: left;
|
|
|
|
}
|
2016-04-11 12:30:23 +02:00
|
|
|
|
2016-09-25 12:41:38 +02:00
|
|
|
.btn-info:disabled {
|
|
|
|
background-color: #e89259;
|
|
|
|
border-color: #e89259;
|
|
|
|
}
|
|
|
|
|
2016-04-11 12:30:23 +02:00
|
|
|
#scrollable-dropdown-menu .tt-menu {
|
|
|
|
max-height: 150px;
|
|
|
|
overflow-y: auto;
|
|
|
|
overflow-x: hidden;
|
|
|
|
}
|
2016-11-06 12:44:58 +01:00
|
|
|
|
|
|
|
.signature-wrapper .tooltip-inner {
|
|
|
|
width: 600px;
|
|
|
|
max-width: 600px;
|
|
|
|
padding: 20px;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
|
2016-10-18 16:55:07 +02:00
|
|
|
@if ($invoice->id)
|
2014-02-17 00:09:34 +01:00
|
|
|
<ol class="breadcrumb">
|
2016-10-18 16:55:07 +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>
|
|
|
|
<li class="active">{{ $invoice->invoice_number }}</li>
|
|
|
|
@endif
|
|
|
|
{!! $invoice->present()->statusLabel !!}
|
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)
|
2016-03-24 23:15:52 +01:00
|
|
|
->addClass('warn-on-exit main-form')
|
2015-11-09 15:53:18 +01:00
|
|
|
->autocomplete('off')
|
2016-01-31 16:19:47 +01:00
|
|
|
->onsubmit('return onFormSubmit(event)')
|
2015-11-09 15:53:18 +01:00
|
|
|
->rules(array(
|
|
|
|
'client' => 'required',
|
|
|
|
'invoice_number' => 'required',
|
2016-09-21 16:07:01 +02:00
|
|
|
'invoice_date' => 'required',
|
2015-11-09 15:53:18 +01:00
|
|
|
'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
|
|
|
|
2016-01-31 16:19:47 +01: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">
|
2016-09-21 16:07:01 +02:00
|
|
|
<label for="client" class="control-label col-lg-4 col-sm-4"><b>{{ trans('texts.client') }}</b></label>
|
2015-05-08 10:21:29 +02:00
|
|
|
<div class="col-lg-8 col-sm-8">
|
2016-05-05 21:59:33 +02:00
|
|
|
<h4>
|
|
|
|
<span data-bind="text: getClientDisplayName(ko.toJS(client()))"></span>
|
|
|
|
@if ($invoice->client->is_deleted)
|
|
|
|
<div class="label label-danger">{{ trans('texts.deleted') }}</div>
|
|
|
|
@endif
|
|
|
|
</h4>
|
2016-05-15 22:16:08 +02:00
|
|
|
|
2016-04-26 03:53:39 +02:00
|
|
|
@can('view', $invoice->client)
|
|
|
|
@can('edit', $invoice->client)
|
2016-03-16 03:07:11 +01:00
|
|
|
<a id="editClientLink" class="pointer" data-bind="click: $root.showClientForm">{{ trans('texts.edit_client') }}</a> |
|
2016-04-26 03:53:39 +02:00
|
|
|
@endcan
|
2016-03-16 03:07:11 +01:00
|
|
|
{!! 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-15 22:16:08 +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') !!}
|
2013-12-13 10:13:57 +01:00
|
|
|
|
|
|
|
<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>
|
2013-12-13 10:13:57 +01:00
|
|
|
</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 && (contacts()[0].email() || contacts()[0].first_name()), foreach: contacts">
|
2016-03-14 22:37:13 +01:00
|
|
|
<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>
|
2016-05-05 21:59:33 +02:00
|
|
|
@if ( ! $invoice->is_deleted && ! $invoice->client->is_deleted)
|
2016-03-13 18:55:19 +01:00
|
|
|
<span data-bind="visible: !$root.invoice().is_recurring()">
|
|
|
|
<span data-bind="html: $data.view_as_recipient"></span>
|
|
|
|
@if (Utils::isConfirmed())
|
2016-11-04 14:34:15 +01:00
|
|
|
<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="fa fa-info-circle"
|
|
|
|
data-bind="visible: $data.invitation_status, tooltip: {title: $data.invitation_status, html: true},
|
|
|
|
style: {color: $data.info_color}"></span>
|
2016-11-06 12:44:58 +01:00
|
|
|
<span class="signature-wrapper">
|
|
|
|
<span style="vertical-align:text-top;color:#888" class="fa fa-user"
|
|
|
|
data-bind="visible: $data.invitation_signature_svg, tooltip: {title: $data.invitation_signature_svg, html: true}"></span>
|
|
|
|
</span>
|
2016-03-13 18:55:19 +01:00
|
|
|
@endif
|
|
|
|
</span>
|
2016-05-05 21:59:33 +02:00
|
|
|
@endif
|
2015-10-11 16:41:09 +02:00
|
|
|
</div>
|
2013-12-13 10:13:57 +01:00
|
|
|
</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">
|
2013-12-13 10:13:57 +01:00
|
|
|
<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"))
|
2015-08-10 17:48:41 +02:00
|
|
|
->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
|
|
|
|
2016-09-21 16:07:01 +02:00
|
|
|
{!! Former::text('partial')->data_bind("value: partial, valueUpdate: 'afterkeydown'")->onkeyup('onPartialChange()')
|
|
|
|
->addGroupClass('partial')!!}
|
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")
|
2016-01-01 05:59:02 +01:00
|
|
|
->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') !!}
|
2016-01-01 05:59:02 +01:00
|
|
|
{!! 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()">
|
2015-09-10 19:50:09 +02:00
|
|
|
{!! Former::text('invoice_number')
|
|
|
|
->label(trans("texts.{$entityType}_number_short"))
|
2016-07-27 14:46:05 +02:00
|
|
|
->onchange('checkInvoiceNumber()')
|
|
|
|
->addGroupClass('invoice-number')
|
2015-09-10 19:50:09 +02:00
|
|
|
->data_bind("value: invoice_number, valueUpdate: 'afterkeydown'") !!}
|
2016-01-10 11:25:05 +01:00
|
|
|
</span>
|
2016-04-27 02:02:52 +02:00
|
|
|
@if($account->getTokenGatewayId())
|
2015-09-10 19:50:09 +02:00
|
|
|
<span data-bind="visible: is_recurring()" style="display: none">
|
2016-05-15 05:15:22 +02:00
|
|
|
<div data-bind="visible: !(auto_bill() == {{AUTO_BILL_OPT_IN}} && client_enable_auto_bill()) && !(auto_bill() == {{AUTO_BILL_OPT_OUT}} && !client_enable_auto_bill())" style="display: none">
|
2016-05-09 22:29:02 +02:00
|
|
|
{!! Former::select('auto_bill')
|
2016-05-15 05:15:22 +02:00
|
|
|
->data_bind("value: auto_bill, valueUpdate: 'afterkeydown', event:{change:function(){if(auto_bill()==".AUTO_BILL_OPT_IN.")client_enable_auto_bill(0);if(auto_bill()==".AUTO_BILL_OPT_OUT.")client_enable_auto_bill(1)}}")
|
2016-05-09 22:29:02 +02:00
|
|
|
->options([
|
2016-05-15 05:15:22 +02:00
|
|
|
AUTO_BILL_OFF => trans('texts.off'),
|
|
|
|
AUTO_BILL_OPT_IN => trans('texts.opt_in'),
|
|
|
|
AUTO_BILL_OPT_OUT => trans('texts.opt_out'),
|
|
|
|
AUTO_BILL_ALWAYS => trans('texts.always'),
|
2016-05-09 22:29:02 +02:00
|
|
|
]) !!}
|
|
|
|
</div>
|
|
|
|
<input type="hidden" name="client_enable_auto_bill" data-bind="attr: { value: client_enable_auto_bill() }" />
|
2016-05-15 05:15:22 +02:00
|
|
|
<div class="form-group" data-bind="visible: auto_bill() == {{AUTO_BILL_OPT_IN}} && client_enable_auto_bill()">
|
2016-05-09 22:29:02 +02:00
|
|
|
<div class="col-sm-4 control-label">{{trans('texts.auto_bill')}}</div>
|
|
|
|
<div class="col-sm-8" style="padding-top:10px;padding-bottom:9px">
|
|
|
|
{{trans('texts.opted_in')}} - <a href="#" data-bind="click:function(){client_enable_auto_bill(false)}">({{trans('texts.disable')}})</a>
|
|
|
|
</div>
|
|
|
|
</div>
|
2016-05-15 05:15:22 +02:00
|
|
|
<div class="form-group" data-bind="visible: auto_bill() == {{AUTO_BILL_OPT_OUT}} && !client_enable_auto_bill()">
|
2016-05-09 22:29:02 +02:00
|
|
|
<div class="col-sm-4 control-label">{{trans('texts.auto_bill')}}</div>
|
|
|
|
<div class="col-sm-8" style="padding-top:10px;padding-bottom:9px">
|
|
|
|
{{trans('texts.opted_out')}} - <a href="#" data-bind="click:function(){client_enable_auto_bill(true)}">({{trans('texts.enable')}})</a>
|
2016-05-06 19:26:37 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
2015-08-14 14:04:33 +02:00
|
|
|
</span>
|
2016-04-27 02:02:52 +02:00
|
|
|
@endif
|
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
|
|
|
|
2016-01-01 23:37:25 +01:00
|
|
|
@if ($entityType == ENTITY_INVOICE)
|
|
|
|
<div class="form-group" style="margin-bottom: 8px">
|
2016-10-05 16:47:03 +02:00
|
|
|
<div class="col-lg-8 col-sm-8 col-sm-offset-4 smaller" style="padding-top: 10px">
|
2016-01-01 23:37:25 +01:00
|
|
|
@if ($invoice->recurring_invoice)
|
2016-10-05 16:47:03 +02:00
|
|
|
{!! trans('texts.created_by_invoice', ['invoice' => link_to('/invoices/'.$invoice->recurring_invoice->public_id, trans('texts.recurring_invoice'))]) !!}
|
2016-01-01 23:37:25 +01:00
|
|
|
@elseif ($invoice->id)
|
|
|
|
@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
|
|
|
|
@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">
|
2015-08-12 21:16:02 +02:00
|
|
|
<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>
|
2015-05-27 22:20:35 +02:00
|
|
|
<th style="width:100%">{{ $invoiceLabels['description'] }}</th>
|
2016-03-15 21:08:12 +01:00
|
|
|
@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
|
2016-03-15 21:08:12 +01:00
|
|
|
@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-05-29 11:26:02 +02:00
|
|
|
<th style="min-width:{{ $account->enable_second_tax_rate ? 180 : 120 }}px;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() &&
|
|
|
|
$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">
|
2016-07-05 20:49:47 +02:00
|
|
|
<input id="product_key" type="text" data-bind="productTypeahead: product_key, items: $root.products, key: 'product_key', valueUpdate: 'afterkeydown', attr: {name: 'invoice_items[' + $index() + '][product_key]'}" class="form-control invoice-item handled"/>
|
2016-04-11 12:30:23 +02:00
|
|
|
</div>
|
2014-05-22 20:29:29 +02:00
|
|
|
</td>
|
|
|
|
<td>
|
2016-09-18 21:12:09 +02:00
|
|
|
<textarea data-bind="value: notes, valueUpdate: 'afterkeydown', attr: {name: 'invoice_items[' + $index() + '][notes]'}"
|
|
|
|
rows="1" cols="60" style="resize: vertical;height:42px" class="form-control word-wrap"></textarea>
|
2015-10-28 20:22:07 +01:00
|
|
|
<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>
|
2016-03-15 21:08:12 +01:00
|
|
|
@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
|
2016-03-15 21:08:12 +01:00
|
|
|
@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')
|
2016-05-29 11:26:02 +02:00
|
|
|
->addClass($account->enable_second_tax_rate ? 'tax-select' : '')
|
2016-03-31 11:29:01 +02:00
|
|
|
->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">
|
2016-05-29 11:26:02 +02:00
|
|
|
<div data-bind="visible: $root.invoice().account.enable_second_tax_rate == '1'">
|
|
|
|
{!! Former::select('')
|
|
|
|
->addOption('', '')
|
|
|
|
->options($taxRateOptions)
|
|
|
|
->data_bind('value: tax2')
|
|
|
|
->addClass('tax-select')
|
|
|
|
->raw() !!}
|
|
|
|
</div>
|
2016-03-31 11:29:01 +02:00
|
|
|
<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">
|
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() &&
|
2015-08-14 14:04:33 +02:00
|
|
|
$index() < ($parent.invoice_items().length - 1) &&
|
|
|
|
$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"/>
|
2016-03-15 21:08:12 +01:00
|
|
|
<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>
|
2016-04-19 04:35:18 +02:00
|
|
|
@if ($account->hasFeature(FEATURE_DOCUMENTS))
|
2016-06-01 15:49:33 +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">
|
2016-09-18 21:12:09 +02:00
|
|
|
{!! Former::textarea('public_notes')->data_bind("value: public_notes, valueUpdate: 'afterkeydown'")
|
2016-10-30 12:28:01 +01:00
|
|
|
->label(null)->style('width: 500px;')->rows(4) !!}
|
2015-02-28 22:42:47 +01:00
|
|
|
</div>
|
|
|
|
<div role="tabpanel" class="tab-pane" id="terms">
|
2016-09-18 21:12:09 +02:00
|
|
|
{!! Former::textarea('terms')->data_bind("value:terms, placeholder: terms_placeholder, valueUpdate: 'afterkeydown'")
|
2016-10-30 12:28:01 +01:00
|
|
|
->label(false)->style('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">
|
2016-09-18 21:12:09 +02:00
|
|
|
{!! Former::textarea('invoice_footer')->data_bind("value:invoice_footer, placeholder: footer_placeholder, valueUpdate: 'afterkeydown'")
|
2016-10-30 12:28:01 +01:00
|
|
|
->label(false)->style('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>
|
2016-04-19 04:35:18 +02:00
|
|
|
@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">
|
2016-03-24 23:15:52 +01:00
|
|
|
<div id="document-upload">
|
|
|
|
<div class="dropzone">
|
|
|
|
<div data-bind="foreach: documents">
|
2016-05-30 10:51:41 +02:00
|
|
|
<input type="hidden" name="document_ids[]" data-bind="value: public_id"/>
|
2016-03-24 20:13:54 +01:00
|
|
|
</div>
|
2016-03-23 03:23:45 +01:00
|
|
|
</div>
|
2016-03-24 23:15:52 +01:00
|
|
|
@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"/>
|
2016-12-22 12:53:14 +01:00
|
|
|
<td colspan="{{ $account->hide_quantity ? 1 : 2 }}">{{ $account->custom_invoice_label1 ?: trans('texts.adjustment') }}</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"/>
|
2016-12-22 12:53:14 +01:00
|
|
|
<td colspan="{{ $account->hide_quantity ? 1 : 2 }}">{{ $account->custom_invoice_label2 ?: trans('texts.adjustment') }}</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
|
|
|
|
|
2015-08-12 21:16:02 +02:00
|
|
|
<tr style="display:none" data-bind="visible: $root.invoice_item_taxes.show && 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-05-29 11:26:02 +02:00
|
|
|
->addClass($account->enable_second_tax_rate ? 'tax-select' : '')
|
2016-03-31 11:29:01 +02:00
|
|
|
->data_bind('value: tax1')
|
2016-05-15 22:16:08 +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">
|
2016-05-29 11:26:02 +02:00
|
|
|
<div data-bind="visible: $root.invoice().account.enable_second_tax_rate == '1'">
|
2016-03-31 11:29:01 +02:00
|
|
|
{!! Former::select('')
|
|
|
|
->addOption('', '')
|
|
|
|
->options($taxRateOptions)
|
|
|
|
->addClass('tax-select')
|
|
|
|
->data_bind('value: tax2')
|
2016-05-15 22:16:08 +02:00
|
|
|
->raw() !!}
|
2016-05-29 11:26:02 +02:00
|
|
|
</div>
|
2016-03-31 11:29:01 +02:00
|
|
|
<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">
|
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"/>
|
2016-12-22 12:53:14 +01:00
|
|
|
<td colspan="{{ $account->hide_quantity ? 1 : 2 }}">{{ $account->custom_invoice_label1 ?: trans('texts.adjustment') }}</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"/>
|
2016-12-22 12:53:14 +01:00
|
|
|
<td colspan="{{ $account->hide_quantity ? 1 : 2 }}">{{ $account->custom_invoice_label2 ?: trans('texts.adjustment') }}</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> </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') !!}
|
2016-12-04 22:26:38 +01:00
|
|
|
{!! Former::text('public_id')->data_bind('value: public_id') !!}
|
|
|
|
{!! Former::text('is_public')->data_bind('value: is_public') !!}
|
2015-10-28 20:22:07 +01:00
|
|
|
{!! 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>
|
|
|
|
|
2016-04-19 04:35:18 +02:00
|
|
|
@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") !!}
|
2014-10-24 12:48:59 +02:00
|
|
|
@endif
|
2014-02-21 06:26:40 +01:00
|
|
|
|
2016-07-03 15:23:16 +02:00
|
|
|
@if ( $invoice->exists && $invoice->id && ! $invoice->is_recurring)
|
2016-06-01 15:39:07 +02:00
|
|
|
{!! Button::primary(trans('texts.download_pdf'))
|
|
|
|
->withAttributes(['onclick' => 'onDownloadClick()', 'id' => 'downloadPdfButton'])
|
|
|
|
->appendIcon(Icon::create('download-alt')) !!}
|
2016-05-22 17:11:24 +02:00
|
|
|
@endif
|
2016-05-22 18:51:09 +02:00
|
|
|
|
2016-09-20 16:34:13 +02:00
|
|
|
@if (Auth::user()->canCreateOrEdit(ENTITY_INVOICE, $invoice))
|
|
|
|
@if ($invoice->isClientTrashed())
|
|
|
|
<!-- do nothing -->
|
2016-10-10 10:40:04 +02:00
|
|
|
@else
|
|
|
|
@if (!$invoice->is_deleted)
|
2016-12-04 22:51:18 +01:00
|
|
|
@if ($invoice->isSent())
|
2016-12-04 22:26:38 +01:00
|
|
|
{!! Button::success(trans("texts.save_{$entityType}"))->withAttributes(array('id' => 'saveButton', 'onclick' => 'onSaveClick()'))->appendIcon(Icon::create('floppy-disk')) !!}
|
|
|
|
@else
|
2016-12-05 09:32:18 +01:00
|
|
|
{!! Button::normal(trans("texts.save_draft"))->withAttributes(array('id' => 'draftButton', 'onclick' => 'onSaveDraftClick()'))->appendIcon(Icon::create('floppy-disk')) !!}
|
2016-12-04 22:26:38 +01:00
|
|
|
{!! Button::success(trans("texts.mark_sent"))->withAttributes(array('id' => 'saveButton', 'onclick' => 'onMarkSentClick()'))->appendIcon(Icon::create('globe')) !!}
|
|
|
|
@endif
|
2016-10-10 10:40:04 +02:00
|
|
|
{!! Button::info(trans("texts.email_{$entityType}"))->withAttributes(array('id' => 'emailButton', 'onclick' => 'onEmailClick()'))->appendIcon(Icon::create('send')) !!}
|
|
|
|
@if (!$invoice->trashed())
|
|
|
|
@if ($invoice->id)
|
|
|
|
{!! DropdownButton::normal(trans('texts.more_actions'))
|
|
|
|
->withContents($actions)
|
|
|
|
->dropup() !!}
|
|
|
|
@elseif ( ! $invoice->isQuote() && Request::is('*/clone'))
|
|
|
|
{!! Button::normal(trans($invoice->is_recurring ? 'texts.disable_recurring' : 'texts.enable_recurring'))->withAttributes(['id' => 'recurrButton', 'onclick' => 'onRecurrClick()'])->appendIcon(Icon::create('repeat')) !!}
|
|
|
|
@endif
|
|
|
|
@endif
|
|
|
|
@endif
|
|
|
|
@if ($invoice->trashed())
|
|
|
|
{!! Button::primary(trans('texts.restore'))->withAttributes(['onclick' => 'submitBulkAction("restore")'])->appendIcon(Icon::create('cloud-download')) !!}
|
2016-09-20 16:34:13 +02:00
|
|
|
@endif
|
2016-10-10 10:40:04 +02:00
|
|
|
@endif
|
2016-09-20 16:34:13 +02:00
|
|
|
@endif
|
2014-01-15 15:01:24 +01:00
|
|
|
|
2013-11-26 13:45:07 +01:00
|
|
|
</div>
|
2013-11-26 22:45:10 +01:00
|
|
|
<p> </p>
|
2014-10-12 20:11:41 +02:00
|
|
|
|
2016-11-04 14:34:15 +01:00
|
|
|
@if (Auth::user()->account->live_preview)
|
2016-10-30 18:46:52 +01:00
|
|
|
@include('invoices.pdf', ['account' => Auth::user()->account])
|
|
|
|
@else
|
|
|
|
<script type="text/javascript">
|
|
|
|
var invoiceLabels = {!! json_encode($account->getInvoiceLabels()) !!};
|
|
|
|
function refreshPDF() {}
|
|
|
|
</script>
|
|
|
|
@endif
|
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">
|
2016-10-16 15:38:04 +02:00
|
|
|
{!! trans('texts.pro_plan_remove_logo', ['link'=>'<a href="javascript:showUpgradeModal()">' . 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">×</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-15 22:16:08 +02:00
|
|
|
|
2015-10-25 08:49:10 +01:00
|
|
|
</span>
|
2015-04-20 16:34:23 +02:00
|
|
|
|
2016-04-19 04:35:18 +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
|
|
|
|
|
|
|
|
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')
|
2015-12-07 14:34:55 +01:00
|
|
|
->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]'}") !!}
|
2016-04-19 04:35:18 +02:00
|
|
|
@if ($account->hasFeature(FEATURE_CLIENT_PORTAL_PASSWORD) && $account->enable_portal_password)
|
2016-03-05 04:22:54 +01:00
|
|
|
{!! 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
|
|
|
|
|
|
|
</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
|
|
|
|
2015-09-10 19:50:09 +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> </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">×</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>
|
|
|
|
|
2014-02-23 14:53:22 +01:00
|
|
|
<div style="background-color: #fff; padding-left: 16px; padding-right: 16px">
|
2015-03-31 11:38:24 +02:00
|
|
|
{!! isset($recurringHelp) ? $recurringHelp : '' !!}
|
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
|
|
|
|
2016-01-01 05:59: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">×</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">
|
|
|
|
{!! isset($recurringDueDateHelp) ? $recurringDueDateHelp : '' !!}
|
|
|
|
</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
|
|
|
|
2016-01-01 05:59:02 +01:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
2014-01-15 15:01:24 +01:00
|
|
|
|
2016-09-25 12:41:38 +02:00
|
|
|
{!! Former::close() !!}
|
|
|
|
</form>
|
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-15 22:16:08 +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);
|
2016-07-13 11:03:39 +02:00
|
|
|
if (!clientName) {
|
|
|
|
continue;
|
|
|
|
}
|
2015-10-22 20:48:12 +02:00
|
|
|
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' }});
|
2016-05-22 18:51:09 +02:00
|
|
|
model.invoice().start_date_orig(model.invoice().start_date());
|
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))
|
2016-07-14 10:42:10 +02:00
|
|
|
var defaultTax = {!! $defaultTax->toJson() !!};
|
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-08-21 17:25:35 +02:00
|
|
|
@if (isset($expenses) && $expenses)
|
2016-04-11 10:44:53 +02:00
|
|
|
model.expense_currency_id({{ isset($expenseCurrencyId) ? $expenseCurrencyId : 0 }});
|
2016-01-31 14:10:33 +01:00
|
|
|
|
2016-01-10 11:25:05 +01:00
|
|
|
// move the blank invoice line item to the end
|
|
|
|
var blank = model.invoice().invoice_items.pop();
|
2016-08-21 17:25:35 +02:00
|
|
|
var expenses = {!! $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();
|
2016-08-21 17:25:35 +02:00
|
|
|
item.product_key(expense.expense_category ? expense.expense_category.name : '');
|
|
|
|
item.notes(expense.public_notes);
|
2016-03-24 23:15:52 +01:00
|
|
|
item.qty(1);
|
2016-08-21 17:25:35 +02:00
|
|
|
item.expense_public_id(expense.public_id);
|
|
|
|
item.cost(expense.converted_amount);
|
|
|
|
item.tax_rate1(expense.tax_rate1);
|
|
|
|
item.tax_name1(expense.tax_name1);
|
|
|
|
item.tax_rate2(expense.tax_rate2);
|
|
|
|
item.tax_name2(expense.tax_name2);
|
2016-01-10 11:25:05 +01:00
|
|
|
}
|
|
|
|
model.invoice().invoice_items.push(blank);
|
|
|
|
model.invoice().has_expenses(true);
|
2016-08-21 17:25:35 +02:00
|
|
|
@endif
|
2016-01-10 11:25:05 +01:00
|
|
|
|
2015-10-22 20:48:12 +02:00
|
|
|
@endif
|
2016-05-15 22:16:08 +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);
|
2016-10-25 19:27:24 +02:00
|
|
|
onItemChange(true);
|
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
|
|
|
|
2015-09-10 19:50:09 +02: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() {
|
2016-06-01 15:39:07 +02:00
|
|
|
$('#downloadPdfButton').attr('disabled', true);
|
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
|
|
|
|
2015-08-10 17:48:41 +02:00
|
|
|
$('.frequency_id .input-group-addon').click(function() {
|
|
|
|
showLearnMore();
|
|
|
|
});
|
|
|
|
|
2016-01-01 05:59:02 +01:00
|
|
|
$('.recurring_due_date .input-group-addon').click(function() {
|
|
|
|
showRecurringDueDateLearnMore();
|
|
|
|
});
|
|
|
|
|
2015-09-10 19:50:09 +02:00
|
|
|
var fields = ['invoice_date', 'due_date', 'start_date', 'end_date', 'last_sent_date'];
|
2015-08-10 17:48:41 +02:00
|
|
|
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
|
|
|
});
|
2015-08-10 17:48:41 +02:00
|
|
|
})(field);
|
|
|
|
}
|
|
|
|
|
2016-05-10 09:44:26 +02:00
|
|
|
if (model.invoice().client().public_id() || {{ $invoice->id || count($clients) == 0 ? '1' : '0' }}) {
|
2016-07-28 16:09:58 +02:00
|
|
|
// do nothing
|
2016-05-10 09:44:26 +02:00
|
|
|
} 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-15 22:16:08 +02:00
|
|
|
|
2016-04-19 04:35:18 +02:00
|
|
|
@if (Auth::user()->account->hasFeature(FEATURE_DOCUMENTS))
|
2016-03-24 23:15:52 +01:00
|
|
|
$('.main-form').submit(function(){
|
|
|
|
if($('#document-upload .dropzone .fallback input').val())$(this).attr('enctype', 'multipart/form-data')
|
|
|
|
else $(this).removeAttr('enctype')
|
|
|
|
})
|
2016-05-15 22:16:08 +02:00
|
|
|
|
2016-03-23 03:23:45 +01:00
|
|
|
// Initialize document upload
|
2016-05-25 10:59:46 +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', {
|
2016-05-30 12:43:41 +02:00
|
|
|
url:{!! json_encode(url('documents')) !!},
|
2016-05-25 10:59:46 +02:00
|
|
|
params:{
|
|
|
|
_token:"{{ Session::getToken() }}"
|
|
|
|
},
|
|
|
|
acceptedFiles:{!! json_encode(implode(',',\App\Models\Document::$allowedMimes)) !!},
|
|
|
|
addRemoveLinks:true,
|
2016-05-26 18:02:53 +02:00
|
|
|
dictRemoveFileConfirmation:"{{trans('texts.are_you_sure')}}",
|
2016-05-25 10:59:46 +02:00
|
|
|
@foreach(['default_message', 'fallback_message', 'fallback_text', 'file_too_big', 'invalid_file_type', 'response_error', 'cancel_upload', 'cancel_upload_confirmation', 'remove_file'] as $key)
|
|
|
|
"dict{{Utils::toClassCase($key)}}":"{{trans('texts.dropzone_'.$key)}}",
|
|
|
|
@endforeach
|
2016-05-29 17:39:42 +02:00
|
|
|
maxFilesize:{{floatval(MAX_DOCUMENT_SIZE/1000)}},
|
2016-10-25 19:16:29 +02:00
|
|
|
parallelUploads:1,
|
2016-05-25 10:59:46 +02:00
|
|
|
});
|
|
|
|
if(dropzone instanceof Dropzone){
|
|
|
|
dropzone.on("addedfile",handleDocumentAdded);
|
|
|
|
dropzone.on("removedfile",handleDocumentRemoved);
|
|
|
|
dropzone.on("success",handleDocumentUploaded);
|
2016-05-25 21:01:15 +02:00
|
|
|
dropzone.on("canceled",handleDocumentCanceled);
|
2016-05-29 17:42:36 +02:00
|
|
|
dropzone.on("error",handleDocumentError);
|
2016-05-25 10:59:46 +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:18:12 +02:00
|
|
|
url:document.url(),
|
2016-05-25 10:59:46 +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-03-24 20:13:54 +01:00
|
|
|
}
|
2016-03-24 16:33:28 +01:00
|
|
|
}
|
2016-05-25 10:59:46 +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
|
|
|
|
2016-01-01 05:59: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
|
|
|
|
2016-01-01 05:59:02 +01:00
|
|
|
$('#recurring_due_date option').hide();
|
|
|
|
$('#recurring_due_date option.' + optionClass).show();
|
2016-01-11 20:41:02 +01:00
|
|
|
|
2016-01-01 05:59: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
|
|
|
|
2013-11-27 08:38:37 +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) {
|
2016-02-29 10:40:52 +01:00
|
|
|
if ($(event.target).hasClass('handled')) {
|
|
|
|
return;
|
|
|
|
}
|
2016-06-01 15:39:07 +02:00
|
|
|
$('#downloadPdfButton').attr('disabled', true);
|
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);
|
|
|
|
});
|
|
|
|
|
2016-10-30 12:28:01 +01:00
|
|
|
$('textarea.word-wrap').on('keyup focus', function(e) {
|
2016-09-18 21:12:09 +02:00
|
|
|
$(this).height(0).height(this.scrollHeight-18);
|
2015-09-29 20:19:18 +02:00
|
|
|
});
|
2016-09-18 21:12:09 +02:00
|
|
|
|
2013-11-27 08:38:37 +01:00
|
|
|
}
|
|
|
|
|
2013-11-26 13:45:07 +01:00
|
|
|
function createInvoiceModel() {
|
2016-03-24 16:33:28 +01:00
|
|
|
var model = ko.toJS(window.model);
|
|
|
|
if(!model)return;
|
|
|
|
var invoice = model.invoice;
|
2016-04-19 04:35:18 +02:00
|
|
|
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
|
|
|
|
2015-08-10 17:48:41 +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-08-10 17:48:41 +02:00
|
|
|
}
|
|
|
|
|
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())
|
2016-03-22 21:19:55 +01:00
|
|
|
invoice.image = "{{ Form::image_data($account->getLogoRaw(), true) }}";
|
2014-03-18 22:25:54 +01:00
|
|
|
invoice.imageWidth = {{ $account->getLogoWidth() }};
|
|
|
|
invoice.imageHeight = {{ $account->getLogoHeight() }};
|
2013-12-13 10:13:57 +01:00
|
|
|
@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
|
|
|
}
|
|
|
|
|
2016-01-10 15:22:40 +01:00
|
|
|
window.generatedPDF = false;
|
2015-07-21 20:51:56 +02:00
|
|
|
function getPDFString(cb, force) {
|
2015-07-24 16:13:17 +02:00
|
|
|
var invoice = createInvoiceModel();
|
2014-10-12 20:11:41 +02:00
|
|
|
var design = getDesignJavascript();
|
2014-10-24 12:48:59 +02:00
|
|
|
if (!design) return;
|
2015-07-21 20:51:56 +02:00
|
|
|
generatePDF(invoice, design, force, cb);
|
2016-01-10 15:22:40 +01:00
|
|
|
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();
|
2014-10-24 12:48:59 +02:00
|
|
|
if (id == '-1') {
|
|
|
|
showMoreDesigns();
|
2014-10-25 19:32:28 +02:00
|
|
|
model.invoice().invoice_design_id(1);
|
2014-10-24 12:48:59 +02:00
|
|
|
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 : '';
|
2014-10-24 12:48:59 +02:00
|
|
|
}
|
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() {
|
2016-07-28 18:55:23 +02:00
|
|
|
sweetConfirm(function() {
|
2015-09-17 21:01:06 +02:00
|
|
|
model.invoice().terms(model.invoice().default_terms());
|
|
|
|
refreshPDF();
|
2016-07-28 18:55:23 +02:00
|
|
|
});
|
|
|
|
|
2015-09-07 11:07:55 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
function resetFooter() {
|
2016-07-28 18:55:23 +02:00
|
|
|
sweetConfirm(function() {
|
2015-09-17 21:01:06 +02:00
|
|
|
model.invoice().invoice_footer(model.invoice().default_footer());
|
|
|
|
refreshPDF();
|
2016-07-28 18:55:23 +02:00
|
|
|
});
|
2016-07-28 22:08:51 +02:00
|
|
|
|
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();
|
2014-10-24 12:48:59 +02:00
|
|
|
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
|
|
|
}
|
|
|
|
|
2016-09-26 08:54:59 +02:00
|
|
|
function onRecurrClick() {
|
|
|
|
var invoice = model.invoice();
|
|
|
|
if (invoice.is_recurring()) {
|
|
|
|
var recurring = false;
|
|
|
|
var label = "{{ trans('texts.enable_recurring')}}";
|
|
|
|
} else {
|
|
|
|
var recurring = true;
|
|
|
|
var label = "{{ trans('texts.disable_recurring')}}";
|
|
|
|
}
|
|
|
|
invoice.is_recurring(recurring);
|
|
|
|
$('#recurrButton').html(label + "<span class='glyphicon glyphicon-repeat'></span>");
|
|
|
|
}
|
|
|
|
|
2013-11-26 13:45:07 +01:00
|
|
|
function onEmailClick() {
|
2016-01-31 16:19:47 +01:00
|
|
|
if (!NINJA.isRegistered) {
|
2016-07-28 18:55:23 +02:00
|
|
|
swal("{!! trans('texts.registration_required') !!}");
|
2015-10-06 19:55:55 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-07-28 22:08:51 +02:00
|
|
|
var clientId = parseInt($('input[name=client]').val(), 10) || 0;
|
|
|
|
if (clientId == 0 ) {
|
|
|
|
swal("{!! trans('texts.no_client_selected') !!}");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!isContactSelected()) {
|
|
|
|
swal("{!! trans('texts.no_contact_selected') !!}");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-01-31 16:19:47 +01:00
|
|
|
if (!isEmailValid()) {
|
2016-07-28 18:55:23 +02:00
|
|
|
swal("{!! trans('texts.provide_email') !!}");
|
2015-07-07 22:08:16 +02:00
|
|
|
return;
|
2016-09-12 08:44:26 +02:00
|
|
|
}
|
2015-07-07 22:08:16 +02:00
|
|
|
|
2016-07-28 18:55:23 +02:00
|
|
|
sweetConfirm(function() {
|
2016-12-04 23:35:08 +01:00
|
|
|
model.invoice().is_public(true);
|
2016-05-22 19:26:19 +02:00
|
|
|
var accountLanguageId = parseInt({{ $account->language_id ?: '0' }});
|
|
|
|
var clientLanguageId = parseInt(model.invoice().client().language_id()) || 0;
|
2016-05-29 18:32:45 +02:00
|
|
|
var attachPDF = {{ $account->attachPDF() ? 'true' : 'false' }};
|
|
|
|
|
|
|
|
// if they aren't attaching the pdf no need to generate it
|
|
|
|
if ( ! attachPDF) {
|
|
|
|
submitAction('email');
|
2016-05-22 19:26:19 +02:00
|
|
|
// if the client's language is different then we can't use the browser version of the PDF
|
2016-05-29 18:32:45 +02:00
|
|
|
} else if (clientLanguageId && clientLanguageId != accountLanguageId) {
|
2016-05-22 19:26:19 +02:00
|
|
|
submitAction('email');
|
|
|
|
} else {
|
|
|
|
preparePdfData('email');
|
|
|
|
}
|
2016-07-28 18:55:23 +02:00
|
|
|
}, getSendToEmails());
|
2013-11-26 13:45:07 +01:00
|
|
|
}
|
|
|
|
|
2016-12-05 09:11:33 +01:00
|
|
|
function onSaveDraftClick() {
|
|
|
|
model.invoice().is_public(false);
|
2016-12-04 22:26:38 +01:00
|
|
|
onSaveClick();
|
|
|
|
}
|
|
|
|
|
2016-12-05 09:11:33 +01:00
|
|
|
function onMarkSentClick() {
|
2016-05-22 18:51:09 +02:00
|
|
|
if (model.invoice().is_recurring()) {
|
|
|
|
// warn invoice will be emailed when saving new recurring invoice
|
2016-12-05 09:11:33 +01:00
|
|
|
var text = getSendToEmails() + '\n' + "{!! trans("texts.confirm_recurring_timing") !!}";
|
|
|
|
var title = "{!! trans("texts.confirm_recurring_email_$entityType") !!}";
|
|
|
|
sweetConfirm(function() {
|
|
|
|
model.invoice().is_public(true);
|
|
|
|
submitAction('');
|
|
|
|
}, text, title);
|
|
|
|
return;
|
2016-12-05 09:32:18 +01:00
|
|
|
} else {
|
|
|
|
model.invoice().is_public(true);
|
|
|
|
onSaveClick();
|
|
|
|
}
|
2016-12-05 09:11:33 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
function onSaveClick() {
|
|
|
|
if (model.invoice().is_recurring()) {
|
|
|
|
if (model.invoice().start_date() != model.invoice().start_date_orig()) {
|
2016-07-28 18:55:23 +02:00
|
|
|
var text = "{!! trans("texts.original_start_date") !!}: " + model.invoice().start_date_orig() + '\n'
|
|
|
|
+ "{!! trans("texts.new_start_date") !!}: " + model.invoice().start_date();
|
|
|
|
var title = "{!! trans("texts.warn_start_date_changed") !!}";
|
|
|
|
sweetConfirm(function() {
|
|
|
|
submitAction('');
|
|
|
|
}, text, title);
|
2016-05-22 18:51:09 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-07-28 18:55:23 +02:00
|
|
|
@if (!empty($autoBillChangeWarning))
|
|
|
|
var text = "{!! trans('texts.warn_change_auto_bill') !!}";
|
|
|
|
sweetConfirm(function() {
|
|
|
|
submitAction('');
|
|
|
|
}, text);
|
|
|
|
return;
|
|
|
|
@endif
|
|
|
|
|
2016-05-25 11:10:22 +02:00
|
|
|
submitAction('');
|
2016-05-22 18:51:09 +02:00
|
|
|
}
|
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) {
|
2016-01-31 16:19:47 +01:00
|
|
|
$('#action').val(value);
|
|
|
|
$('#submitButton').click();
|
|
|
|
}
|
|
|
|
|
|
|
|
function onFormSubmit(event) {
|
2016-05-25 13:42:20 +02:00
|
|
|
if (window.countUploadingDocuments > 0) {
|
2016-07-28 18:55:23 +02:00
|
|
|
swal("{!! trans('texts.wait_for_upload') !!}");
|
2016-05-25 13:42:20 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2016-10-10 10:40:04 +02:00
|
|
|
@if ($invoice->is_deleted)
|
2016-10-06 12:02:25 +02:00
|
|
|
if ($('#bulk_action').val() != 'restore') {
|
|
|
|
return false;
|
|
|
|
}
|
2016-10-06 10:05:04 +02:00
|
|
|
@endif
|
|
|
|
|
2016-07-27 14:46:05 +02:00
|
|
|
// check invoice number is unique
|
|
|
|
if ($('.invoice-number').hasClass('has-error')) {
|
|
|
|
return false;
|
2016-09-21 16:07:01 +02:00
|
|
|
} else if ($('.partial').hasClass('has-error')) {
|
|
|
|
return false;
|
2016-07-27 14:46:05 +02:00
|
|
|
}
|
|
|
|
|
2016-01-31 16:19:47 +01:00
|
|
|
if (!isSaveValid()) {
|
|
|
|
model.showClientForm();
|
|
|
|
return false;
|
|
|
|
}
|
2016-01-31 14:10:33 +01:00
|
|
|
|
|
|
|
// check currency matches for expenses
|
|
|
|
var expenseCurrencyId = model.expense_currency_id();
|
|
|
|
var clientCurrencyId = model.invoice().client().currency_id() || {{ $account->getCurrencyId() }};
|
2016-01-31 14:21:12 +01:00
|
|
|
if (expenseCurrencyId && expenseCurrencyId != clientCurrencyId) {
|
2016-07-28 18:55:23 +02:00
|
|
|
swal("{!! trans('texts.expense_error_mismatch_currencies') !!}");
|
2016-01-31 16:19:47 +01:00
|
|
|
return false;
|
2016-01-31 14:10:33 +01:00
|
|
|
}
|
|
|
|
|
2016-09-20 16:34:13 +02:00
|
|
|
@if (Auth::user()->canCreateOrEdit(ENTITY_INVOICE, $invoice))
|
2016-09-25 12:41:38 +02:00
|
|
|
if ($('#saveButton').is(':disabled')) {
|
|
|
|
return false;
|
|
|
|
}
|
2016-12-05 09:32:18 +01:00
|
|
|
$('#saveButton, #emailButton, #draftButton').attr('disabled', true);
|
2016-09-25 12:41:38 +02:00
|
|
|
// if save fails ensure user can try again
|
|
|
|
$.post('{{ url($url) }}', $('.main-form').serialize(), function(data) {
|
|
|
|
NINJA.formIsChanged = false;
|
|
|
|
location.href = data;
|
|
|
|
}).fail(function(data) {
|
2016-12-05 09:32:18 +01:00
|
|
|
$('#saveButton, #emailButton, #draftButton').attr('disabled', false);
|
2016-09-25 12:41:38 +02:00
|
|
|
var error = firstJSONError(data.responseJSON) || data.statusText;
|
2016-10-05 12:36:31 +02:00
|
|
|
swal("{!! trans('texts.invoice_save_error') !!}", error);
|
2016-09-25 12:41:38 +02:00
|
|
|
});
|
|
|
|
return false;
|
2016-09-20 16:34:13 +02:00
|
|
|
@else
|
|
|
|
return false;
|
|
|
|
@endif
|
2016-01-31 14:21:12 +01:00
|
|
|
}
|
|
|
|
|
2015-10-28 20:22:07 +01:00
|
|
|
function submitBulkAction(value) {
|
|
|
|
$('#bulk_action').val(value);
|
2016-09-25 12:41:38 +02:00
|
|
|
$('.bulkForm')[0].submit();
|
2015-10-28 20:22:07 +01:00
|
|
|
}
|
|
|
|
|
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
|
|
|
|
2016-07-28 22:08:51 +02:00
|
|
|
function isContactSelected() {
|
|
|
|
var sendTo = false;
|
|
|
|
var client = model.invoice().client();
|
|
|
|
for (var i=0; i<client.contacts().length; i++) {
|
|
|
|
var contact = client.contacts()[i];
|
2016-11-27 14:58:01 +01:00
|
|
|
if (contact.send_invoice()) {
|
|
|
|
return true;
|
2016-07-28 22:08:51 +02:00
|
|
|
}
|
|
|
|
}
|
2016-11-27 14:58:01 +01:00
|
|
|
return false;
|
2016-07-28 22:08:51 +02:00
|
|
|
}
|
|
|
|
|
2014-03-09 22:19:56 +01:00
|
|
|
function isEmailValid() {
|
2015-11-16 20:21:48 +01:00
|
|
|
var isValid = true;
|
2015-10-06 19:55:55 +02:00
|
|
|
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;
|
|
|
|
} else {
|
|
|
|
isValid = false;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2016-07-28 22:08:51 +02:00
|
|
|
return isValid;
|
2014-03-09 22:19:56 +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() {
|
2016-07-28 18:55:23 +02:00
|
|
|
@if (!empty($autoBillChangeWarning))
|
|
|
|
sweetConfirm(function() {
|
|
|
|
window.location = '{{ URL::to('payments/create/' . $invoice->client->public_id . '/' . $invoice->public_id ) }}';
|
|
|
|
}, "{!! trans('texts.warn_change_auto_bill') !!}");
|
|
|
|
@else
|
|
|
|
window.location = '{{ URL::to('payments/create/' . $invoice->client->public_id . '/' . $invoice->public_id ) }}';
|
2016-05-25 17:07:20 +02:00
|
|
|
@endif
|
2015-10-23 13:55:18 +02:00
|
|
|
}
|
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() {
|
2016-07-28 18:55:23 +02:00
|
|
|
sweetConfirm(function() {
|
|
|
|
submitBulkAction('delete');
|
|
|
|
});
|
2013-12-03 18:32:33 +01:00
|
|
|
}
|
|
|
|
|
2013-12-13 10:13:57 +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('');
|
2013-12-13 10:13:57 +01:00
|
|
|
return false;
|
2013-11-26 13:45:07 +01:00
|
|
|
}
|
2013-12-13 10:13:57 +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();
|
2013-12-13 10:13:57 +01:00
|
|
|
model.clientFormComplete();
|
2013-11-26 13:45:07 +01:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-10-25 19:27:24 +02:00
|
|
|
function onItemChange(silent)
|
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
|
|
|
}
|
2016-09-12 08:44:26 +02:00
|
|
|
|
2016-10-25 19:27:24 +02:00
|
|
|
if (!silent) {
|
|
|
|
NINJA.formIsChanged = true;
|
|
|
|
}
|
2013-11-26 13:45:07 +01:00
|
|
|
}
|
|
|
|
|
2016-09-21 16:07:01 +02:00
|
|
|
function onPartialChange()
|
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);
|
2016-01-10 11:25:05 +01:00
|
|
|
|
2016-09-21 16:07:01 +02:00
|
|
|
if (val != oldVal) {
|
|
|
|
if ($('.partial').hasClass('has-error')) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
$('.partial')
|
|
|
|
.addClass('has-error')
|
|
|
|
.find('div')
|
|
|
|
.append('<span class="help-block">{{ trans('texts.partial_value') }}</span>');
|
|
|
|
} else {
|
|
|
|
$('.partial')
|
|
|
|
.removeClass('has-error')
|
|
|
|
.find('span')
|
|
|
|
.hide();
|
2015-06-03 19:55:48 +02:00
|
|
|
}
|
2016-09-21 16:07:01 +02:00
|
|
|
|
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
|
|
|
|
2016-01-01 05:59:02 +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-15 22:16:08 +02:00
|
|
|
|
2016-05-25 13:42:20 +02:00
|
|
|
window.countUploadingDocuments = 0;
|
2016-06-05 21:55:23 +02:00
|
|
|
|
2016-03-23 03:23:45 +01:00
|
|
|
function handleDocumentAdded(file){
|
2016-05-22 21:14:47 +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});
|
2016-05-25 13:42:20 +02:00
|
|
|
window.countUploadingDocuments++;
|
2016-03-23 03:23:45 +01:00
|
|
|
}
|
2016-05-15 22:16:08 +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:02:53 +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-15 22:16:08 +02:00
|
|
|
|
2016-03-23 03:23:45 +01:00
|
|
|
function handleDocumentUploaded(file, response){
|
2016-06-07 20:46:07 +02:00
|
|
|
window.countUploadingDocuments--;
|
2016-03-23 03:23:45 +01:00
|
|
|
file.public_id = response.document.public_id
|
|
|
|
model.invoice().documents()[file.index].update(response.document);
|
2016-06-01 16:32:51 +02:00
|
|
|
@if ($account->invoice_embed_documents)
|
|
|
|
refreshPDF(true);
|
|
|
|
@endif
|
2016-03-24 16:33:28 +01:00
|
|
|
if(response.document.preview_url){
|
|
|
|
dropzone.emit('thumbnail', file, response.document.preview_url);
|
|
|
|
}
|
2016-03-23 03:23:45 +01:00
|
|
|
}
|
2016-05-25 21:01:15 +02:00
|
|
|
|
2016-05-29 17:42:36 +02:00
|
|
|
function handleDocumentCanceled() {
|
|
|
|
window.countUploadingDocuments--;
|
|
|
|
}
|
|
|
|
|
|
|
|
function handleDocumentError() {
|
2016-05-25 21:01:15 +02:00
|
|
|
window.countUploadingDocuments--;
|
|
|
|
}
|
2014-01-01 18:34:37 +01:00
|
|
|
|
2013-11-26 13:45:07 +01:00
|
|
|
</script>
|
2016-04-19 04:35:18 +02:00
|
|
|
@if ($account->hasFeature(FEATURE_DOCUMENTS) && $account->invoice_embed_documents)
|
2016-03-23 23:40:42 +01:00
|
|
|
@foreach ($invoice->documents as $document)
|
2016-03-24 16:33:28 +01:00
|
|
|
@if($document->isPDFEmbeddable())
|
|
|
|
<script src="{{ $document->getVFSJSUrl() }}" type="text/javascript" async></script>
|
|
|
|
@endif
|
2016-03-23 23:40:42 +01:00
|
|
|
@endforeach
|
2016-03-24 23:15:52 +01:00
|
|
|
@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
|