Enable recurring for a cloned invoice

This commit is contained in:
Hillel Coren 2016-09-26 09:54:59 +03:00
parent 394cb1ad7e
commit 078527443f
4 changed files with 72 additions and 47 deletions

View File

@ -272,7 +272,6 @@ class InvoiceController extends BaseController
$recurringDueDateHelp = ''; $recurringDueDateHelp = '';
$recurringDueDates = []; $recurringDueDates = [];
if ($invoice->is_recurring) {
foreach (preg_split("/((\r?\n)|(\r\n?))/", trans('texts.recurring_help')) as $line) { foreach (preg_split("/((\r?\n)|(\r\n?))/", trans('texts.recurring_help')) as $line) {
$parts = explode('=>', $line); $parts = explode('=>', $line);
if (count($parts) > 1) { if (count($parts) > 1) {
@ -329,7 +328,6 @@ class InvoiceController extends BaseController
$recurringDueDates[$str] = ['value' => "1998-02-$dayStr", 'data-num' => $day, 'class' => 'weekly']; $recurringDueDates[$str] = ['value' => "1998-02-$dayStr", 'data-num' => $day, 'class' => 'weekly'];
} }
} }
}
// Tax rate $options // Tax rate $options
$account = Auth::user()->account; $account = Auth::user()->account;

View File

@ -58,7 +58,17 @@ class RecurringInvoiceDatatable extends EntityDatatable
function ($model) { function ($model) {
return Auth::user()->can('editByOwner', [ENTITY_INVOICE, $model->user_id]); return Auth::user()->can('editByOwner', [ENTITY_INVOICE, $model->user_id]);
} }
] ],
[
trans("texts.clone_invoice"),
function ($model) {
return URL::to("invoices/{$model->public_id}/clone");
},
function ($model) {
return Auth::user()->can('create', ENTITY_INVOICE);
}
],
]; ];
} }

View File

@ -2139,6 +2139,8 @@ $LANG = array(
'restore_product' => 'Restore Product', 'restore_product' => 'Restore Product',
'blank' => 'Blank', 'blank' => 'Blank',
'invoice_error' => 'There was an error saving your invoice.', 'invoice_error' => 'There was an error saving your invoice.',
'enable_recurring' => 'Enable Recurring',
'disable_recurring' => 'Disable Recurring',
); );

View File

@ -550,6 +550,8 @@
{!! DropdownButton::normal(trans('texts.more_actions')) {!! DropdownButton::normal(trans('texts.more_actions'))
->withContents($actions) ->withContents($actions)
->dropup() !!} ->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 @endif
@endif @endif
@ -1212,6 +1214,19 @@
doc.save(type +'-' + $('#invoice_number').val() + '.pdf'); doc.save(type +'-' + $('#invoice_number').val() + '.pdf');
} }
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>");
}
function onEmailClick() { function onEmailClick() {
if (!NINJA.isRegistered) { if (!NINJA.isRegistered) {
swal("{!! trans('texts.registration_required') !!}"); swal("{!! trans('texts.registration_required') !!}");