mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-07 21:34:30 -04:00
Enabled setting reminder before/after due date or invoice date
This commit is contained in:
parent
9943c824dd
commit
2ead34fef0
@ -44,7 +44,7 @@ class SendReminders extends Command
|
|||||||
$this->info($account->name . ': ' . count($invoices).' invoices found');
|
$this->info($account->name . ': ' . count($invoices).' invoices found');
|
||||||
|
|
||||||
foreach ($invoices as $invoice) {
|
foreach ($invoices as $invoice) {
|
||||||
if ($reminder = $invoice->getReminder()) {
|
if ($reminder = $account->getInvoiceReminder($invoice)) {
|
||||||
$this->info('Send to ' . $invoice->id);
|
$this->info('Send to ' . $invoice->id);
|
||||||
$this->mailer->sendInvoice($invoice, $reminder);
|
$this->mailer->sendInvoice($invoice, $reminder);
|
||||||
}
|
}
|
||||||
|
@ -450,8 +450,9 @@ class AccountController extends BaseController
|
|||||||
$account->$enableField = Input::get($enableField) ? true : false;
|
$account->$enableField = Input::get($enableField) ? true : false;
|
||||||
|
|
||||||
if ($account->$enableField) {
|
if ($account->$enableField) {
|
||||||
$numDaysField = "num_days_{$type}";
|
$account->{"num_days_{$type}"} = Input::get("num_days_{$type}");
|
||||||
$account->$numDaysField = Input::get($numDaysField);
|
$account->{"field_{$type}"} = Input::get("field_{$type}");
|
||||||
|
$account->{"direction_{$type}"} = Input::get("field_{$type}") == REMINDER_FIELD_INVOICE_DATE ? REMINDER_DIRECTION_AFTER : Input::get("direction_{$type}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -144,7 +144,7 @@ Route::group(['middleware' => 'auth'], function() {
|
|||||||
Route::post('tasks/bulk', 'TaskController@bulk');
|
Route::post('tasks/bulk', 'TaskController@bulk');
|
||||||
|
|
||||||
Route::get('api/recurring_invoices/{client_id?}', array('as'=>'api.recurring_invoices', 'uses'=>'InvoiceController@getRecurringDatatable'));
|
Route::get('api/recurring_invoices/{client_id?}', array('as'=>'api.recurring_invoices', 'uses'=>'InvoiceController@getRecurringDatatable'));
|
||||||
|
|
||||||
Route::get('invoices/invoice_history/{invoice_id}', 'InvoiceController@invoiceHistory');
|
Route::get('invoices/invoice_history/{invoice_id}', 'InvoiceController@invoiceHistory');
|
||||||
Route::get('quotes/quote_history/{invoice_id}', 'InvoiceController@invoiceHistory');
|
Route::get('quotes/quote_history/{invoice_id}', 'InvoiceController@invoiceHistory');
|
||||||
|
|
||||||
@ -490,6 +490,12 @@ if (!defined('CONTACT_EMAIL')) {
|
|||||||
define('REMINDER2', 'reminder2');
|
define('REMINDER2', 'reminder2');
|
||||||
define('REMINDER3', 'reminder3');
|
define('REMINDER3', 'reminder3');
|
||||||
|
|
||||||
|
define('REMINDER_DIRECTION_AFTER', 1);
|
||||||
|
define('REMINDER_DIRECTION_BEFORE', 2);
|
||||||
|
|
||||||
|
define('REMINDER_FIELD_DUE_DATE', 1);
|
||||||
|
define('REMINDER_FIELD_INVOICE_DATE', 2);
|
||||||
|
|
||||||
define('SOCIAL_GOOGLE', 'Google');
|
define('SOCIAL_GOOGLE', 'Google');
|
||||||
define('SOCIAL_FACEBOOK', 'Facebook');
|
define('SOCIAL_FACEBOOK', 'Facebook');
|
||||||
define('SOCIAL_GITHUB', 'GitHub');
|
define('SOCIAL_GITHUB', 'GitHub');
|
||||||
|
@ -768,6 +768,32 @@ class Account extends Eloquent
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getReminderDate($reminder)
|
||||||
|
{
|
||||||
|
if ( ! $this->{"enable_reminder{$reminder}"}) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$numDays = $this->{"num_days_reminder{$reminder}"};
|
||||||
|
$plusMinus = $this->{"direction_reminder{$reminder}"} == REMINDER_DIRECTION_AFTER ? '-' : '+';
|
||||||
|
|
||||||
|
return date('Y-m-d', strtotime("$plusMinus $numDays days"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getInvoiceReminder($invoice)
|
||||||
|
{
|
||||||
|
for ($i=1; $i<=3; $i++) {
|
||||||
|
if ($date = $this->getReminderDate($i)) {
|
||||||
|
$field = $this->{"field_reminder{$i}"} == REMINDER_FIELD_DUE_DATE ? 'due_date' : 'invoice_date';
|
||||||
|
if ($this->$field == $date) {
|
||||||
|
return "reminder{$i}";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public function showTokenCheckbox()
|
public function showTokenCheckbox()
|
||||||
{
|
{
|
||||||
if (!$this->isGatewayConfigured(GATEWAY_STRIPE)) {
|
if (!$this->isGatewayConfigured(GATEWAY_STRIPE)) {
|
||||||
|
@ -595,24 +595,6 @@ class Invoice extends EntityModel implements BalanceAffecting
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getReminder()
|
|
||||||
{
|
|
||||||
for ($i=1; $i<=3; $i++) {
|
|
||||||
$field = "enable_reminder{$i}";
|
|
||||||
if (!$this->account->$field) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
$field = "num_days_reminder{$i}";
|
|
||||||
$date = date('Y-m-d', strtotime("- {$this->account->$field} days"));
|
|
||||||
|
|
||||||
if ($this->due_date == $date) {
|
|
||||||
return "reminder{$i}";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getPDFString()
|
public function getPDFString()
|
||||||
{
|
{
|
||||||
if (!env('PHANTOMJS_CLOUD_KEY')) {
|
if (!env('PHANTOMJS_CLOUD_KEY')) {
|
||||||
|
@ -639,16 +639,15 @@ class InvoiceRepository extends BaseRepository
|
|||||||
public function findNeedingReminding($account)
|
public function findNeedingReminding($account)
|
||||||
{
|
{
|
||||||
$dates = [];
|
$dates = [];
|
||||||
for ($i = 1; $i <= 3; $i++) {
|
|
||||||
$field = "enable_reminder{$i}";
|
for ($i=1; $i<=3; $i++) {
|
||||||
if (!$account->$field) {
|
if ($date = $account->getReminderDate($i)) {
|
||||||
continue;
|
$field = $account->{"field_reminder{$i}"} == REMINDER_FIELD_DUE_DATE ? 'due_date' : 'invoice_date';
|
||||||
|
$dates[] = "$field = '$date'";
|
||||||
}
|
}
|
||||||
$field = "num_days_reminder{$i}";
|
|
||||||
$dates[] = "due_date = '".date('Y-m-d', strtotime("- {$account->$field} days"))."'";
|
|
||||||
}
|
}
|
||||||
$sql = implode(' OR ', $dates);
|
|
||||||
|
|
||||||
|
$sql = implode(' OR ', $dates);
|
||||||
$invoices = Invoice::whereAccountId($account->id)
|
$invoices = Invoice::whereAccountId($account->id)
|
||||||
->where('balance', '>', 0)
|
->where('balance', '>', 0)
|
||||||
->whereRaw('('.$sql.')')
|
->whereRaw('('.$sql.')')
|
||||||
|
@ -0,0 +1,44 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
|
||||||
|
class AddReminderSettings extends Migration {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::table('accounts', function ($table) {
|
||||||
|
$table->smallInteger('direction_reminder1')->default(1);
|
||||||
|
$table->smallInteger('direction_reminder2')->default(1);
|
||||||
|
$table->smallInteger('direction_reminder3')->default(1);
|
||||||
|
|
||||||
|
$table->smallInteger('field_reminder1')->default(1);
|
||||||
|
$table->smallInteger('field_reminder2')->default(1);
|
||||||
|
$table->smallInteger('field_reminder3')->default(1);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::table('accounts', function ($table) {
|
||||||
|
$table->dropColumn('direction_reminder1');
|
||||||
|
$table->dropColumn('direction_reminder2');
|
||||||
|
$table->dropColumn('direction_reminder3');
|
||||||
|
|
||||||
|
$table->dropColumn('field_reminder1');
|
||||||
|
$table->dropColumn('field_reminder2');
|
||||||
|
$table->dropColumn('field_reminder3');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
4
public/css/built.css
vendored
4
public/css/built.css
vendored
@ -3368,6 +3368,10 @@ ul.user-accounts a:hover div.remove {
|
|||||||
width: 350px;
|
width: 350px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.smaller {
|
||||||
|
font-size: .9em;
|
||||||
|
}
|
||||||
|
|
||||||
/* Show selected section in settings nav */
|
/* Show selected section in settings nav */
|
||||||
.list-group-item.selected:before {
|
.list-group-item.selected:before {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
|
4
public/css/style.css
vendored
4
public/css/style.css
vendored
@ -1017,6 +1017,10 @@ ul.user-accounts a:hover div.remove {
|
|||||||
width: 350px;
|
width: 350px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.smaller {
|
||||||
|
font-size: .9em;
|
||||||
|
}
|
||||||
|
|
||||||
/* Show selected section in settings nav */
|
/* Show selected section in settings nav */
|
||||||
.list-group-item.selected:before {
|
.list-group-item.selected:before {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
|
@ -984,4 +984,10 @@ return array(
|
|||||||
'next_invoice_number' => 'The next invoice number is :number.',
|
'next_invoice_number' => 'The next invoice number is :number.',
|
||||||
'next_quote_number' => 'The next quote number is :number.',
|
'next_quote_number' => 'The next quote number is :number.',
|
||||||
|
|
||||||
|
'days_before' => 'days before',
|
||||||
|
'days_after' => 'days after',
|
||||||
|
'field_due_date' => 'due date',
|
||||||
|
'field_invoice_date' => 'invoice date',
|
||||||
|
'schedule' => 'Schedule',
|
||||||
|
|
||||||
);
|
);
|
||||||
|
@ -1,13 +1,34 @@
|
|||||||
<div role="tabpanel" class="tab-pane {{ isset($active) && $active ? 'active' : '' }}" id="{{ $field }}">
|
<div role="tabpanel" class="tab-pane {{ isset($active) && $active ? 'active' : '' }}" id="{{ $field }}">
|
||||||
<div class="panel-body" style="padding-bottom: 0px">
|
<div class="panel-body" style="padding-bottom: 0px">
|
||||||
@if (isset($isReminder) && $isReminder)
|
@if (isset($isReminder) && $isReminder)
|
||||||
<div class="row">
|
|
||||||
|
{!! Former::populateField('enable_' . $field, intval($account->{'enable_' . $field})) !!}
|
||||||
|
|
||||||
|
<div class="row" style="padding-bottom:20px">
|
||||||
<div class="col-md-6">
|
<div class="col-md-6">
|
||||||
{!! Former::checkbox('enable_' . $field)
|
{!! Former::checkbox('enable_' . $field)
|
||||||
->text(trans('texts.enable'))->label('') !!}
|
->text(trans('texts.enable'))->label('') !!}
|
||||||
{!! Former::input('num_days_' . $field)
|
|
||||||
->label(trans('texts.num_days_reminder'))
|
{!! Former::plaintext('schedule')
|
||||||
->addClass('enable-' . $field) !!}
|
->value(
|
||||||
|
Former::input('num_days_' . $field)
|
||||||
|
->addClass('enable-' . $field)
|
||||||
|
->style('float:left;width:20%')
|
||||||
|
->raw() .
|
||||||
|
Former::select('direction_' . $field)
|
||||||
|
->addOption(trans('texts.days_before'), REMINDER_DIRECTION_BEFORE)
|
||||||
|
->addOption(trans('texts.days_after'), REMINDER_DIRECTION_AFTER)
|
||||||
|
->addClass('enable-' . $field)
|
||||||
|
->style('float:left;width:40%')
|
||||||
|
->raw() .
|
||||||
|
'<div id="days_after_'. $field .'" style="float:left;width:40%;display:none;padding-top:8px;padding-left:16px;font-size:16px;">' . trans('texts.days_after') . '</div>' .
|
||||||
|
Former::select('field_' . $field)
|
||||||
|
->addOption(trans('texts.field_due_date'), REMINDER_FIELD_DUE_DATE)
|
||||||
|
->addOption(trans('texts.field_invoice_date'), REMINDER_FIELD_INVOICE_DATE)
|
||||||
|
->addClass('enable-' . $field)
|
||||||
|
->style('float:left;width:40%')
|
||||||
|
->raw()
|
||||||
|
) !!}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@endif
|
@endif
|
||||||
@ -70,10 +91,17 @@
|
|||||||
NINJA.formIsChanged = true;
|
NINJA.formIsChanged = true;
|
||||||
});
|
});
|
||||||
editors['{{ $field }}'] = editor;
|
editors['{{ $field }}'] = editor;
|
||||||
|
|
||||||
|
$('#field_{{ $field }}').change(function() {
|
||||||
|
setDirectionShown('{{ $field }}');
|
||||||
|
})
|
||||||
|
setDirectionShown('{{ $field }}');
|
||||||
|
|
||||||
|
$('.email-subject .input-group-addon').click(function() {
|
||||||
|
$('#templateHelpModal').modal('show');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
$('.email-subject .input-group-addon').click(function() {
|
|
||||||
$('#templateHelpModal').modal('show');
|
|
||||||
});
|
|
||||||
|
|
||||||
</script>
|
</script>
|
@ -33,11 +33,6 @@
|
|||||||
@endforeach
|
@endforeach
|
||||||
@endforeach
|
@endforeach
|
||||||
|
|
||||||
{!! Former::populateField('enable_reminder1', intval($account->enable_reminder1)) !!}
|
|
||||||
{!! Former::populateField('enable_reminder2', intval($account->enable_reminder2)) !!}
|
|
||||||
{!! Former::populateField('enable_reminder3', intval($account->enable_reminder3)) !!}
|
|
||||||
|
|
||||||
|
|
||||||
<div class="panel panel-default">
|
<div class="panel panel-default">
|
||||||
<div class="panel-heading">
|
<div class="panel-heading">
|
||||||
<h3 class="panel-title">{!! trans('texts.email_templates') !!}</h3>
|
<h3 class="panel-title">{!! trans('texts.email_templates') !!}</h3>
|
||||||
@ -188,6 +183,17 @@
|
|||||||
$('.enable-reminder' + id).attr('disabled', !checked)
|
$('.enable-reminder' + id).attr('disabled', !checked)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function setDirectionShown(field) {
|
||||||
|
var val = $('#field_' + field).val();
|
||||||
|
if (val == {{ REMINDER_FIELD_INVOICE_DATE }}) {
|
||||||
|
$('#days_after_' + field).show();
|
||||||
|
$('#direction_' + field).hide();
|
||||||
|
} else {
|
||||||
|
$('#days_after_' + field).hide();
|
||||||
|
$('#direction_' + field).show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function processVariables(str) {
|
function processVariables(str) {
|
||||||
if (!str) {
|
if (!str) {
|
||||||
return '';
|
return '';
|
||||||
|
@ -131,6 +131,7 @@
|
|||||||
@if ($invoice->recurring_invoice)
|
@if ($invoice->recurring_invoice)
|
||||||
{!! trans('texts.created_by_invoice', ['invoice' => link_to('/invoices/'.$invoice->recurring_invoice->public_id, trans('texts.recurring_invoice'))]) !!}
|
{!! trans('texts.created_by_invoice', ['invoice' => link_to('/invoices/'.$invoice->recurring_invoice->public_id, trans('texts.recurring_invoice'))]) !!}
|
||||||
@elseif ($invoice->id)
|
@elseif ($invoice->id)
|
||||||
|
<span class="smaller">
|
||||||
@if (isset($lastSent) && $lastSent)
|
@if (isset($lastSent) && $lastSent)
|
||||||
{!! trans('texts.last_sent_on', ['date' => link_to('/invoices/'.$lastSent->public_id, $invoice->last_sent_date, ['id' => 'lastSent'])]) !!} <br/>
|
{!! trans('texts.last_sent_on', ['date' => link_to('/invoices/'.$lastSent->public_id, $invoice->last_sent_date, ['id' => 'lastSent'])]) !!} <br/>
|
||||||
@endif
|
@endif
|
||||||
@ -138,6 +139,7 @@
|
|||||||
{!! trans('texts.next_send_on', ['date' => '<span data-bind="tooltip: {title: \''.$invoice->getPrettySchedule().'\', html: true}">'.$account->formatDate($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>']) !!}
|
'<span class="glyphicon glyphicon-info-sign" style="padding-left:10px;color:#B1B5BA"></span></span>']) !!}
|
||||||
@endif
|
@endif
|
||||||
|
</span>
|
||||||
@endif
|
@endif
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user