mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-06-06 00:54:35 -04:00
Prevent invoicing tasks/expenses with archived clients
This commit is contained in:
parent
0b7621bd7d
commit
8a874ba602
@ -18,6 +18,7 @@ use Auth;
|
|||||||
use Cache;
|
use Cache;
|
||||||
use Input;
|
use Input;
|
||||||
use Redirect;
|
use Redirect;
|
||||||
|
use Request;
|
||||||
use Session;
|
use Session;
|
||||||
use URL;
|
use URL;
|
||||||
use Utils;
|
use Utils;
|
||||||
@ -223,6 +224,7 @@ class ExpenseController extends BaseController
|
|||||||
{
|
{
|
||||||
$action = Input::get('action');
|
$action = Input::get('action');
|
||||||
$ids = Input::get('public_id') ? Input::get('public_id') : Input::get('ids');
|
$ids = Input::get('public_id') ? Input::get('public_id') : Input::get('ids');
|
||||||
|
$referer = Request::server('HTTP_REFERER');
|
||||||
|
|
||||||
switch ($action) {
|
switch ($action) {
|
||||||
case 'invoice':
|
case 'invoice':
|
||||||
@ -234,27 +236,25 @@ class ExpenseController extends BaseController
|
|||||||
// Validate that either all expenses do not have a client or if there is a client, it is the same client
|
// Validate that either all expenses do not have a client or if there is a client, it is the same client
|
||||||
foreach ($expenses as $expense) {
|
foreach ($expenses as $expense) {
|
||||||
if ($expense->client) {
|
if ($expense->client) {
|
||||||
|
if ($expense->client->trashed()) {
|
||||||
|
return redirect($referer)->withError(trans('texts.client_must_be_active'));
|
||||||
|
}
|
||||||
|
|
||||||
if (! $clientPublicId) {
|
if (! $clientPublicId) {
|
||||||
$clientPublicId = $expense->client->public_id;
|
$clientPublicId = $expense->client->public_id;
|
||||||
} elseif ($clientPublicId != $expense->client->public_id) {
|
} elseif ($clientPublicId != $expense->client->public_id) {
|
||||||
Session::flash('error', trans('texts.expense_error_multiple_clients'));
|
return redirect($referer)->withError(trans('texts.expense_error_multiple_clients'));
|
||||||
|
|
||||||
return Redirect::to('expenses');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! $currencyId) {
|
if (! $currencyId) {
|
||||||
$currencyId = $expense->invoice_currency_id;
|
$currencyId = $expense->invoice_currency_id;
|
||||||
} elseif ($currencyId != $expense->invoice_currency_id && $expense->invoice_currency_id) {
|
} elseif ($currencyId != $expense->invoice_currency_id && $expense->invoice_currency_id) {
|
||||||
Session::flash('error', trans('texts.expense_error_multiple_currencies'));
|
return redirect($referer)->withError(trans('texts.expense_error_multiple_currencies'));
|
||||||
|
|
||||||
return Redirect::to('expenses');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($expense->invoice_id) {
|
if ($expense->invoice_id) {
|
||||||
Session::flash('error', trans('texts.expense_error_invoiced'));
|
return redirect($referer)->withError(trans('texts.expense_error_invoiced'));
|
||||||
|
|
||||||
return Redirect::to('expenses');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,6 +16,7 @@ use Auth;
|
|||||||
use DropdownButton;
|
use DropdownButton;
|
||||||
use Input;
|
use Input;
|
||||||
use Redirect;
|
use Redirect;
|
||||||
|
use Request;
|
||||||
use Session;
|
use Session;
|
||||||
use URL;
|
use URL;
|
||||||
use Utils;
|
use Utils;
|
||||||
@ -260,6 +261,7 @@ class TaskController extends BaseController
|
|||||||
{
|
{
|
||||||
$action = Input::get('action');
|
$action = Input::get('action');
|
||||||
$ids = Input::get('public_id') ?: (Input::get('id') ?: Input::get('ids'));
|
$ids = Input::get('public_id') ?: (Input::get('id') ?: Input::get('ids'));
|
||||||
|
$referer = Request::server('HTTP_REFERER');
|
||||||
|
|
||||||
if (in_array($action, ['resume', 'stop'])) {
|
if (in_array($action, ['resume', 'stop'])) {
|
||||||
$this->taskRepo->save($ids, ['action' => $action]);
|
$this->taskRepo->save($ids, ['action' => $action]);
|
||||||
@ -273,23 +275,21 @@ class TaskController extends BaseController
|
|||||||
$lastProjectId = false;
|
$lastProjectId = false;
|
||||||
foreach ($tasks as $task) {
|
foreach ($tasks as $task) {
|
||||||
if ($task->client) {
|
if ($task->client) {
|
||||||
|
if ($task->client->trashed()) {
|
||||||
|
return redirect($referer)->withError(trans('texts.client_must_be_active'));
|
||||||
|
}
|
||||||
|
|
||||||
if (! $clientPublicId) {
|
if (! $clientPublicId) {
|
||||||
$clientPublicId = $task->client->public_id;
|
$clientPublicId = $task->client->public_id;
|
||||||
} elseif ($clientPublicId != $task->client->public_id) {
|
} elseif ($clientPublicId != $task->client->public_id) {
|
||||||
Session::flash('error', trans('texts.task_error_multiple_clients'));
|
return redirect($referer)->withError(trans('texts.task_error_multiple_clients'));
|
||||||
|
|
||||||
return Redirect::to('tasks');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($task->is_running) {
|
if ($task->is_running) {
|
||||||
Session::flash('error', trans('texts.task_error_running'));
|
return redirect($referer)->withError(trans('texts.task_error_running'));
|
||||||
|
|
||||||
return Redirect::to('tasks');
|
|
||||||
} elseif ($task->invoice_id) {
|
} elseif ($task->invoice_id) {
|
||||||
Session::flash('error', trans('texts.task_error_invoiced'));
|
return redirect($referer)->withError(trans('texts.task_error_invoiced'));
|
||||||
|
|
||||||
return Redirect::to('tasks');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$account = Auth::user()->account;
|
$account = Auth::user()->account;
|
||||||
|
@ -2785,6 +2785,7 @@ $LANG = array(
|
|||||||
'auto_archive_quote_help' => 'Automatically archive quotes when they are converted.',
|
'auto_archive_quote_help' => 'Automatically archive quotes when they are converted.',
|
||||||
'invoice_workflow' => 'Invoice Workflow',
|
'invoice_workflow' => 'Invoice Workflow',
|
||||||
'quote_workflow' => 'Quote Workflow',
|
'quote_workflow' => 'Quote Workflow',
|
||||||
|
'client_must_be_active' => 'Error: the client must be active',
|
||||||
|
|
||||||
);
|
);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user