$bills->where('deleted', '0'); $bills->where('paid', '0'); foreach ($unpaidaccounts->items as $key => $ua) { $bills->where('id', $ua->bill_id, true, $key != 0); } $bills->order_by('date', 'asc'); if (count($unpaidaccounts->items)) { $bills->get(); } $total = 0; foreach ($bills->items as $bill) { $total += $bill->splitcost; } ## ------------------------------------------------------------------------ $pendaccounts = new Accounts_Collection(); $pendaccounts->where('paid', '1'); $pendaccounts->where('confirmed', '0'); $pendaccounts->where('deleted', '0'); $pendaccounts->where('user_id', Auth::user()->id); $pendaccounts->get(); $pendbills = new Bills_Collection(); $pendbills->where('deleted', '0'); foreach ($pendaccounts->items as $key => $pa) { $pendbills->where('id', $pa->bill_id, true, $key != 0); } $pendbills->order_by('date', 'asc'); if (count($pendaccounts->items)) { $pendbills->get(); } ## ------------------------------------------------------------------------ $paidbills = new Bills_Collection();
<?php # controllers/deletebill.php # Logic Auth::kickout_non_admin('/'); $bill = new Bill(); $bill->load(Route::param('id')); $bill->delete(); $accounts = new Accounts_Collection(); $accounts->where('bill_id', $bill->id); $accounts->get(); foreach ($accounts->items as $account) { $account->delete(); } # Redirect URL::redirect('/admin');