mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
These routines fix #477
This commit is contained in:
parent
fc0ad622eb
commit
116e19ec06
@ -124,17 +124,24 @@ class AccountController extends Controller
|
||||
*/
|
||||
public function destroy(ARI $repository, Account $account)
|
||||
{
|
||||
$type = $account->accountType->type;
|
||||
$typeName = config('firefly.shortNamesByFullName.' . $type);
|
||||
$name = $account->name;
|
||||
$moveTo = $repository->find(intval(Input::get('move_account_before_delete')));
|
||||
$type = $account->accountType->type;
|
||||
$typeName = config('firefly.shortNamesByFullName.' . $type);
|
||||
$name = $account->name;
|
||||
$accountId = $account->id;
|
||||
$moveTo = $repository->find(intval(Input::get('move_account_before_delete')));
|
||||
|
||||
$repository->destroy($account, $moveTo);
|
||||
|
||||
Session::flash('success', strval(trans('firefly.' . $typeName . '_deleted', ['name' => $name])));
|
||||
Preferences::mark();
|
||||
|
||||
return redirect(session('accounts.delete.url'));
|
||||
$uri = session('accounts.delete.url');
|
||||
if (!(strpos($uri, sprintf('accounts/show/%s', $accountId)) === false)) {
|
||||
// uri would point back to account
|
||||
$uri = route('accounts.index', [$typeName]);
|
||||
}
|
||||
|
||||
return redirect($uri);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -236,11 +243,11 @@ class AccountController extends Controller
|
||||
$subTitle = $account->name;
|
||||
$range = Preferences::get('viewRange', '1M')->data;
|
||||
|
||||
$start = session('start', Navigation::startOfPeriod(new Carbon, $range));
|
||||
$end = session('end', Navigation::endOfPeriod(new Carbon, $range));
|
||||
$page = intval(Input::get('page')) === 0 ? 1 : intval(Input::get('page'));
|
||||
$pageSize = intval(Preferences::get('transactionPageSize', 50)->data);
|
||||
$chartUri = route('chart.account.single', [$account->id]);
|
||||
$start = session('start', Navigation::startOfPeriod(new Carbon, $range));
|
||||
$end = session('end', Navigation::endOfPeriod(new Carbon, $range));
|
||||
$page = intval(Input::get('page')) === 0 ? 1 : intval(Input::get('page'));
|
||||
$pageSize = intval(Preferences::get('transactionPageSize', 50)->data);
|
||||
$chartUri = route('chart.account.single', [$account->id]);
|
||||
// grab those journals:
|
||||
$collector->setAccounts(new Collection([$account]))->setRange($start, $end)->setLimit($pageSize)->setPage($page);
|
||||
$journals = $collector->getPaginatedJournals();
|
||||
|
@ -99,13 +99,20 @@ class BillController extends Controller
|
||||
*/
|
||||
public function destroy(BillRepositoryInterface $repository, Bill $bill)
|
||||
{
|
||||
$name = $bill->name;
|
||||
$name = $bill->name;
|
||||
$billId = $bill->id;
|
||||
$repository->destroy($bill);
|
||||
|
||||
Session::flash('success', strval(trans('firefly.deleted_bill', ['name' => $name])));
|
||||
Preferences::mark();
|
||||
|
||||
return redirect(session('bills.delete.url'));
|
||||
$uri = session('bills.delete.url');
|
||||
if (!(strpos($uri, sprintf('bills/show/%s', $billId)) === false)) {
|
||||
// uri would point back to bill
|
||||
$uri = route('bills.index');
|
||||
}
|
||||
|
||||
return redirect($uri);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -134,15 +134,21 @@ class BudgetController extends Controller
|
||||
public function destroy(Budget $budget, BudgetRepositoryInterface $repository)
|
||||
{
|
||||
|
||||
$name = $budget->name;
|
||||
$name = $budget->name;
|
||||
$budgetId = $budget->id;
|
||||
$repository->destroy($budget);
|
||||
|
||||
|
||||
Session::flash('success', strval(trans('firefly.deleted_budget', ['name' => e($name)])));
|
||||
Preferences::mark();
|
||||
|
||||
$uri = session('budgets.delete.url');
|
||||
if (!(strpos($uri, sprintf('budgets/show/%s', $budgetId)) === false)) {
|
||||
// uri would point back to budget
|
||||
$uri = route('budgets.index');
|
||||
}
|
||||
|
||||
return redirect(session('budgets.delete.url'));
|
||||
return redirect($uri);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -98,13 +98,20 @@ class CategoryController extends Controller
|
||||
public function destroy(CRI $repository, Category $category)
|
||||
{
|
||||
|
||||
$name = $category->name;
|
||||
$name = $category->name;
|
||||
$categoryId = $category->id;
|
||||
$repository->destroy($category);
|
||||
|
||||
Session::flash('success', strval(trans('firefly.deleted_category', ['name' => e($name)])));
|
||||
Preferences::mark();
|
||||
|
||||
return redirect(session('categories.delete.url'));
|
||||
$uri = session('categories.delete.url');
|
||||
if (!(strpos($uri, sprintf('categories/show/%s', $categoryId)) === false)) {
|
||||
// uri would point back to category
|
||||
$uri = route('categories.index');
|
||||
}
|
||||
|
||||
return redirect($uri);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -150,13 +150,18 @@ class PiggyBankController extends Controller
|
||||
*/
|
||||
public function destroy(PiggyBankRepositoryInterface $repository, PiggyBank $piggyBank)
|
||||
{
|
||||
|
||||
|
||||
Session::flash('success', strval(trans('firefly.deleted_piggy_bank', ['name' => e($piggyBank->name)])));
|
||||
Preferences::mark();
|
||||
$piggyBankId = $piggyBank->id;
|
||||
$repository->destroy($piggyBank);
|
||||
|
||||
return redirect(session('piggy-banks.delete.url'));
|
||||
$uri = session('piggy-banks.delete.url');
|
||||
if (!(strpos($uri, sprintf('piggy-banks/show/%s', $piggyBankId)) === false)) {
|
||||
// uri would point back to piggy bank
|
||||
$uri = route('piggy-banks.index');
|
||||
}
|
||||
|
||||
return redirect($uri);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -260,6 +265,7 @@ class PiggyBankController extends Controller
|
||||
$repository->setOrder(intval($id), ($order + 1));
|
||||
}
|
||||
}
|
||||
|
||||
return Response::json(['result' => 'ok']);
|
||||
}
|
||||
|
||||
|
@ -153,16 +153,21 @@ class SingleController extends Controller
|
||||
if ($this->isOpeningBalance($transactionJournal)) {
|
||||
return $this->redirectToAccount($transactionJournal);
|
||||
}
|
||||
|
||||
$type = TransactionJournal::transactionTypeStr($transactionJournal);
|
||||
$journalId = $transactionJournal->id;
|
||||
$type = TransactionJournal::transactionTypeStr($transactionJournal);
|
||||
Session::flash('success', strval(trans('firefly.deleted_' . strtolower($type), ['description' => e($transactionJournal->description)])));
|
||||
|
||||
$repository->delete($transactionJournal);
|
||||
|
||||
Preferences::mark();
|
||||
|
||||
// redirect to previous URL:
|
||||
return redirect(session('transactions.delete.url'));
|
||||
$uri = session('transactions.delete.url');
|
||||
if (!(strpos($uri, sprintf('transactions/show/%s', $journalId)) === false)) {
|
||||
// uri would point back to transaction
|
||||
$uri = route('transactions.index', [strtolower($type)]);
|
||||
}
|
||||
|
||||
return redirect($uri);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user