Merge branch 'master' of github.com:akaunting/akaunting into 2.1-dev
# Conflicts: # app/Http/Controllers/Common/Items.php # resources/views/modules/item/documentation.blade.php # resources/views/modules/item/show.blade.php # resources/views/partials/admin/header.blade.php # resources/views/purchases/bills/show.blade.php # resources/views/purchases/vendors/show.blade.php # resources/views/sales/customers/show.blade.php # resources/views/sales/invoices/show.blade.php # resources/views/wizard/companies/edit.blade.php # resources/views/wizard/currencies/index.blade.php # resources/views/wizard/finish/index.blade.php # resources/views/wizard/taxes/index.blade.php
This commit is contained in:
@ -45,7 +45,7 @@ class Permissions extends ApiController
|
||||
{
|
||||
$permission = $this->dispatch(new CreatePermission($request));
|
||||
|
||||
return $this->response->created(url('api/permissions/' . $permission->id));
|
||||
return $this->response->created(route('api.permissions.show', $permission->id));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -45,7 +45,7 @@ class Roles extends ApiController
|
||||
{
|
||||
$role = $this->dispatch(new CreateRole($request));
|
||||
|
||||
return $this->response->created(url('api/roles/' . $role->id));
|
||||
return $this->response->created(route('api.roles.show', $role->id));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -19,7 +19,7 @@ class Users extends ApiController
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$users = User::with(['companies', 'roles', 'permissions'])->collect();
|
||||
$users = User::with('companies', 'permissions', 'roles')->collect();
|
||||
|
||||
return $this->response->paginator($users, new Transformer());
|
||||
}
|
||||
@ -34,9 +34,9 @@ class Users extends ApiController
|
||||
{
|
||||
// Check if we're querying by id or email
|
||||
if (is_numeric($id)) {
|
||||
$user = User::with(['companies', 'roles', 'permissions'])->find($id);
|
||||
$user = User::with('companies', 'permissions', 'roles')->find($id);
|
||||
} else {
|
||||
$user = User::with(['companies', 'roles', 'permissions'])->where('email', $id)->first();
|
||||
$user = User::with('companies', 'permissions', 'roles')->where('email', $id)->first();
|
||||
}
|
||||
|
||||
return $this->response->item($user, new Transformer());
|
||||
@ -52,7 +52,7 @@ class Users extends ApiController
|
||||
{
|
||||
$user = $this->dispatch(new CreateUser($request));
|
||||
|
||||
return $this->response->created(url('api/users/' . $user->id));
|
||||
return $this->response->created(route('api.users.show', $user->id));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -52,7 +52,7 @@ class Accounts extends ApiController
|
||||
{
|
||||
$account = $this->dispatch(new CreateAccount($request));
|
||||
|
||||
return $this->response->created(url('api/accounts/' . $account->id));
|
||||
return $this->response->created(route('api.accounts.show', $account->id));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -19,7 +19,7 @@ class Reconciliations extends ApiController
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$items = Reconciliation::with(['account'])->collect();
|
||||
$items = Reconciliation::with('account')->collect();
|
||||
|
||||
return $this->response->paginator($items, new Transformer());
|
||||
}
|
||||
@ -45,7 +45,7 @@ class Reconciliations extends ApiController
|
||||
{
|
||||
$reconciliation = $this->dispatch(new CreateReconciliation($request));
|
||||
|
||||
return $this->response->created(url('api/reconciliations/' . $reconciliation->id));
|
||||
return $this->response->created(route('api.reconciliations.show', $reconciliation->id));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -19,7 +19,7 @@ class Transactions extends ApiController
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$transactions = Transaction::with(['account', 'category', 'contact'])->collect(['paid_at'=> 'desc']);
|
||||
$transactions = Transaction::with('account', 'category', 'contact')->collect(['paid_at'=> 'desc']);
|
||||
|
||||
return $this->response->paginator($transactions, new Transformer());
|
||||
}
|
||||
@ -45,7 +45,7 @@ class Transactions extends ApiController
|
||||
{
|
||||
$transaction = $this->dispatch(new CreateTransaction($request));
|
||||
|
||||
return $this->response->created(url('api/transactions/' . $transaction->id));
|
||||
return $this->response->created(route('api.transactions.show', $transaction->id));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -19,9 +19,9 @@ class Transfers extends ApiController
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$transfers = Transfer::with([
|
||||
$transfers = Transfer::with(
|
||||
'expense_transaction', 'expense_transaction.account', 'income_transaction', 'income_transaction.account'
|
||||
])->collect('expense_transaction.paid_at');
|
||||
)->collect('expense_transaction.paid_at');
|
||||
|
||||
$special_key = [
|
||||
'expense_transaction.name' => 'from_account',
|
||||
@ -75,7 +75,7 @@ class Transfers extends ApiController
|
||||
{
|
||||
$transfer = $this->dispatch(new CreateTransfer($request));
|
||||
|
||||
return $this->response->created(url('api/transfers/' . $transfer->id));
|
||||
return $this->response->created(route('api.transfers.show', $transfer->id));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -56,7 +56,7 @@ class Companies extends ApiController
|
||||
{
|
||||
$company = $this->dispatch(new CreateCompany($request));
|
||||
|
||||
return $this->response->created(url('api/companies/' . $company->id));
|
||||
return $this->response->created(route('api.companies.show', $company->id));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -21,9 +21,9 @@ class Contacts extends ApiController
|
||||
public function __construct()
|
||||
{
|
||||
// Add CRUD permission check
|
||||
$this->middleware('permission:create-sales-customers')->only(['create', 'store', 'duplicate', 'import']);
|
||||
$this->middleware('permission:read-sales-customers')->only(['index', 'show', 'edit', 'export']);
|
||||
$this->middleware('permission:update-sales-customers')->only(['update', 'enable', 'disable']);
|
||||
$this->middleware('permission:create-sales-customers')->only('create', 'store', 'duplicate', 'import');
|
||||
$this->middleware('permission:read-sales-customers')->only('index', 'show', 'edit', 'export');
|
||||
$this->middleware('permission:update-sales-customers')->only('update', 'enable', 'disable');
|
||||
$this->middleware('permission:delete-sales-customers')->only('destroy');
|
||||
}
|
||||
|
||||
@ -67,7 +67,7 @@ class Contacts extends ApiController
|
||||
{
|
||||
$contact = $this->dispatch(new CreateContact($request));
|
||||
|
||||
return $this->response->created(url('api/contacts/' . $contact->id));
|
||||
return $this->response->created(route('api.contacts.show', $contact->id));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -22,7 +22,7 @@ class Items extends ApiController
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$items = Item::with(['category', 'tax'])->collect();
|
||||
$items = Item::with('category', 'tax')->collect();
|
||||
|
||||
return $this->response->paginator($items, new Transformer());
|
||||
}
|
||||
@ -35,7 +35,7 @@ class Items extends ApiController
|
||||
*/
|
||||
public function show($id)
|
||||
{
|
||||
$item = Item::with(['category', 'tax'])->find($id);
|
||||
$item = Item::with('category', 'tax')->find($id);
|
||||
|
||||
return $this->response->item($item, new Transformer());
|
||||
}
|
||||
@ -50,7 +50,7 @@ class Items extends ApiController
|
||||
{
|
||||
$item = $this->dispatch(new CreateItem($request));
|
||||
|
||||
return $this->response->created(url('api/items/' . $item->id));
|
||||
return $this->response->created(route('api.items.show', $item->id));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -45,7 +45,7 @@ class Reports extends ApiController
|
||||
{
|
||||
$report = $this->dispatch(new CreateReport($request));
|
||||
|
||||
return $this->response->created(url('api/reports/' . $report->id));
|
||||
return $this->response->created(route('api.reports.show', $report->id));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -19,7 +19,7 @@ class Bills extends ApiController
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$bills = Bill::with(['contact', 'items', 'transactions', 'histories'])->collect(['billed_at'=> 'desc']);
|
||||
$bills = Bill::with('contact', 'histories', 'items', 'transactions')->collect(['billed_at'=> 'desc']);
|
||||
|
||||
return $this->response->paginator($bills, new Transformer());
|
||||
}
|
||||
@ -45,7 +45,7 @@ class Bills extends ApiController
|
||||
{
|
||||
$bill = $this->dispatch(new CreateBill($request));
|
||||
|
||||
return $this->response->created(url('api/bills/' . $bill->id));
|
||||
return $this->response->created(route('api.bills.show', $bill->id));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -19,7 +19,7 @@ class Invoices extends ApiController
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$invoices = Invoice::with(['contact', 'items', 'transactions', 'histories'])->collect(['invoiced_at'=> 'desc']);
|
||||
$invoices = Invoice::with('contact', 'histories', 'items', 'transactions')->collect(['invoiced_at'=> 'desc']);
|
||||
|
||||
return $this->response->paginator($invoices, new Transformer());
|
||||
}
|
||||
@ -52,7 +52,7 @@ class Invoices extends ApiController
|
||||
{
|
||||
$invoice = $this->dispatch(new CreateInvoice($request));
|
||||
|
||||
return $this->response->created(url('api/invoices/' . $invoice->id));
|
||||
return $this->response->created(route('api.invoices.show', $invoice->id));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -45,7 +45,7 @@ class Categories extends ApiController
|
||||
{
|
||||
$category = $this->dispatch(new CreateCategory($request));
|
||||
|
||||
return $this->response->created(url('api/categories/' . $category->id));
|
||||
return $this->response->created(route('api.categories.show', $category->id));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -52,7 +52,7 @@ class Currencies extends ApiController
|
||||
{
|
||||
$currency = $this->dispatch(new CreateCurrency($request));
|
||||
|
||||
return $this->response->created(url('api/currencies/' . $currency->id));
|
||||
return $this->response->created(route('api.currencies.show', $currency->id));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -52,7 +52,7 @@ class Settings extends ApiController
|
||||
{
|
||||
$setting = Setting::create($request->all());
|
||||
|
||||
return $this->response->created(url('api/settings/'.$setting->id));
|
||||
return $this->response->created(route('api.settings.show', $setting->id));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -45,7 +45,7 @@ class Taxes extends ApiController
|
||||
{
|
||||
$tax = $this->dispatch(new CreateTax($request));
|
||||
|
||||
return $this->response->created(url('api/taxes/' . $tax->id));
|
||||
return $this->response->created(route('api.taxes.show', $tax->id));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -89,8 +89,6 @@ class Login extends Controller
|
||||
return response()->json($response);
|
||||
}
|
||||
|
||||
session(['dashboard_id' => $user->dashboards()->enabled()->pluck('id')->first()]);
|
||||
|
||||
$response = [
|
||||
'status' => null,
|
||||
'success' => true,
|
||||
|
@ -3,6 +3,7 @@
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\Abstracts\Http\Controller;
|
||||
use App\Events\Auth\LandingPageShowing;
|
||||
use App\Http\Requests\Auth\User as Request;
|
||||
use App\Jobs\Auth\CreateUser;
|
||||
use App\Jobs\Auth\DeleteUser;
|
||||
@ -16,6 +17,17 @@ class Users extends Controller
|
||||
{
|
||||
use Uploads;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('permission:create-auth-users')->only('create', 'store', 'duplicate', 'import');
|
||||
$this->middleware('permission:read-auth-users')->only('index', 'show', 'export');
|
||||
$this->middleware('permission:update-auth-users')->only('enable', 'disable');
|
||||
$this->middleware('permission:delete-auth-users')->only('destroy');
|
||||
|
||||
$this->middleware('permission:read-auth-users|read-auth-profile')->only('edit');
|
||||
$this->middleware('permission:update-auth-users|update-auth-profile')->only('update');
|
||||
}
|
||||
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
@ -23,7 +35,7 @@ class Users extends Controller
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$users = User::with('roles')->collect();
|
||||
$users = User::with('media', 'roles')->collect();
|
||||
|
||||
return view('auth.users.index', compact('users'));
|
||||
}
|
||||
@ -35,33 +47,20 @@ class Users extends Controller
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
$routes = [
|
||||
'dashboard' => trans_choice('general.dashboards', 1),
|
||||
'items.index' => trans_choice('general.items', 2),
|
||||
'invoices.index' => trans_choice('general.invoices', 2),
|
||||
'revenues.index' => trans_choice('general.revenues', 2),
|
||||
'customers.index' => trans_choice('general.customers', 2),
|
||||
'bills.index' => trans_choice('general.bills', 2),
|
||||
'payments.index' => trans_choice('general.payments', 2),
|
||||
'vendors.index' => trans_choice('general.vendors', 2),
|
||||
'accounts.index' => trans_choice('general.accounts', 2),
|
||||
'transfers.index' => trans_choice('general.transfers', 2),
|
||||
'transactions.index' => trans_choice('general.transactions', 2),
|
||||
'reconciliations.index' => trans_choice('general.reconciliations', 2),
|
||||
'reports.index' => trans_choice('general.reports', 2),
|
||||
'settings.index' => trans_choice('general.settings', 2),
|
||||
'categories.index' => trans_choice('general.categories', 2),
|
||||
'currencies.index' => trans_choice('general.currencies', 2),
|
||||
'taxes.index' => trans_choice('general.taxes', 2),
|
||||
];
|
||||
$u = new \stdClass();
|
||||
$u->landing_pages = [];
|
||||
|
||||
event(new LandingPageShowing($u));
|
||||
|
||||
$landing_pages = $u->landing_pages;
|
||||
|
||||
$roles = Role::all()->reject(function ($r) {
|
||||
return $r->hasPermission('read-client-portal');
|
||||
});
|
||||
|
||||
$companies = user()->companies()->get()->sortBy('name');
|
||||
$companies = user()->companies()->take(10)->get()->sortBy('name')->pluck('name', 'id');
|
||||
|
||||
return view('auth.users.create', compact('roles', 'companies', 'routes'));
|
||||
return view('auth.users.create', compact('roles', 'companies', 'landing_pages'));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -101,25 +100,16 @@ class Users extends Controller
|
||||
*/
|
||||
public function edit(User $user)
|
||||
{
|
||||
$routes = [
|
||||
'dashboard' => trans_choice('general.dashboards', 1),
|
||||
'items.index' => trans_choice('general.items', 2),
|
||||
'invoices.index' => trans_choice('general.invoices', 2),
|
||||
'revenues.index' => trans_choice('general.revenues', 2),
|
||||
'customers.index' => trans_choice('general.customers', 2),
|
||||
'bills.index' => trans_choice('general.bills', 2),
|
||||
'payments.index' => trans_choice('general.payments', 2),
|
||||
'vendors.index' => trans_choice('general.vendors', 2),
|
||||
'accounts.index' => trans_choice('general.accounts', 2),
|
||||
'transfers.index' => trans_choice('general.transfers', 2),
|
||||
'transactions.index' => trans_choice('general.transactions', 2),
|
||||
'reconciliations.index' => trans_choice('general.reconciliations', 2),
|
||||
'reports.index' => trans_choice('general.reports', 2),
|
||||
'settings.index' => trans_choice('general.settings', 2),
|
||||
'categories.index' => trans_choice('general.categories', 2),
|
||||
'currencies.index' => trans_choice('general.currencies', 2),
|
||||
'taxes.index' => trans_choice('general.taxes', 2),
|
||||
];
|
||||
if (user()->cannot('read-auth-users') && ($user->id != user()->id)) {
|
||||
abort(403);
|
||||
}
|
||||
|
||||
$u = new \stdClass();
|
||||
$u->landing_pages = [];
|
||||
|
||||
event(new LandingPageShowing($u));
|
||||
|
||||
$landing_pages = $u->landing_pages;
|
||||
|
||||
if ($user->can('read-client-portal')) {
|
||||
// Show only roles with customer permission
|
||||
@ -133,9 +123,9 @@ class Users extends Controller
|
||||
});
|
||||
}
|
||||
|
||||
$companies = user()->companies()->get()->sortBy('name');
|
||||
$companies = user()->companies()->take(10)->get()->sortBy('name')->pluck('name', 'id');
|
||||
|
||||
return view('auth.users.edit', compact('user', 'companies', 'roles', 'routes'));
|
||||
return view('auth.users.edit', compact('user', 'companies', 'roles', 'landing_pages'));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -148,6 +138,10 @@ class Users extends Controller
|
||||
*/
|
||||
public function update(User $user, Request $request)
|
||||
{
|
||||
if (user()->cannot('update-auth-users') && ($user->id != user()->id)) {
|
||||
abort(403);
|
||||
}
|
||||
|
||||
$response = $this->ajaxDispatch(new UpdateUser($user, $request));
|
||||
|
||||
if ($response['success']) {
|
||||
|
@ -28,7 +28,7 @@ class Transactions extends Controller
|
||||
$request_type = !request()->has('type') ? ['income', 'expense'] : request('type');
|
||||
$categories = Category::enabled()->type($request_type)->orderBy('name')->pluck('name', 'id');
|
||||
|
||||
$transactions = Transaction::with(['account', 'category', 'contact'])->collect(['paid_at'=> 'desc']);
|
||||
$transactions = Transaction::with('account', 'category', 'contact')->collect(['paid_at'=> 'desc']);
|
||||
|
||||
return view('banking.transactions.index', compact('transactions', 'accounts', 'types', 'categories'));
|
||||
}
|
||||
|
@ -24,9 +24,9 @@ class Transfers extends Controller
|
||||
{
|
||||
$data = [];
|
||||
|
||||
$items = Transfer::with([
|
||||
$items = Transfer::with(
|
||||
'expense_transaction', 'expense_transaction.account', 'income_transaction', 'income_transaction.account'
|
||||
])->collect(['expense_transaction.paid_at' => 'desc']);
|
||||
)->collect(['expense_transaction.paid_at' => 'desc']);
|
||||
|
||||
foreach ($items as $item) {
|
||||
$income_transaction = $item->income_transaction;
|
||||
|
@ -4,6 +4,7 @@ namespace App\Http\Controllers\Common;
|
||||
|
||||
use App\Abstracts\Http\Controller;
|
||||
use App\Http\Requests\Common\BulkAction as Request;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class
|
||||
|
||||
@ -34,7 +35,10 @@ BulkActions extends Controller
|
||||
$module = module($group);
|
||||
|
||||
if ($module instanceof \Akaunting\Module\Module) {
|
||||
$bulk_actions = app('Modules\\' . $module->getStudlyName() . '\BulkActions\\' . ucfirst($type));
|
||||
$tmp = explode('.', $type);
|
||||
$file_name = !empty($tmp[1]) ? Str::studly($tmp[0]) . '\\' . Str::studly($tmp[1]) : Str::studly($tmp[0]);
|
||||
|
||||
$bulk_actions = app('Modules\\' . $module->getStudlyName() . '\BulkActions\\' . $file_name);
|
||||
} else {
|
||||
$bulk_actions = app('App\BulkActions\\' . ucfirst($group) . '\\' . ucfirst($type));
|
||||
}
|
||||
|
@ -213,7 +213,7 @@ class Companies extends Controller
|
||||
$old_company_id = session('company_id');
|
||||
|
||||
session(['company_id' => $company->id]);
|
||||
session(['dashboard_id' => $company->dashboards()->pluck('id')->first()]);
|
||||
session(['dashboard_id' => user()->dashboards()->enabled()->pluck('id')->first()]);
|
||||
|
||||
Overrider::load('settings');
|
||||
|
||||
@ -227,4 +227,23 @@ class Companies extends Controller
|
||||
|
||||
return redirect()->route('dashboard');
|
||||
}
|
||||
|
||||
public function autocomplete()
|
||||
{
|
||||
$query = request('query');
|
||||
|
||||
$autocomplete = Company::autocomplete([
|
||||
'name' => $query
|
||||
]);
|
||||
|
||||
$companies = $autocomplete->get()->sortBy('name')->pluck('name', 'id');
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'message' => 'Get all companies.',
|
||||
'errors' => [],
|
||||
'count' => $companies->count(),
|
||||
'data' => ($companies->count()) ? $companies : null,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
@ -24,9 +24,9 @@ class Dashboards extends Controller
|
||||
public function __construct()
|
||||
{
|
||||
// Add CRUD permission check
|
||||
$this->middleware('permission:create-common-dashboards')->only(['create', 'store', 'duplicate', 'import']);
|
||||
$this->middleware('permission:read-common-dashboards')->only(['show']);
|
||||
$this->middleware('permission:update-common-dashboards')->only(['index', 'edit', 'export', 'update', 'enable', 'disable', 'share']);
|
||||
$this->middleware('permission:create-common-dashboards')->only('create', 'store', 'duplicate', 'import');
|
||||
$this->middleware('permission:read-common-dashboards')->only('show');
|
||||
$this->middleware('permission:update-common-dashboards')->only('index', 'edit', 'export', 'update', 'enable', 'disable', 'share');
|
||||
$this->middleware('permission:delete-common-dashboards')->only('destroy');
|
||||
}
|
||||
|
||||
@ -51,12 +51,10 @@ class Dashboards extends Controller
|
||||
{
|
||||
$dashboard_id = $dashboard_id ?? session('dashboard_id');
|
||||
|
||||
if (empty($dashboard_id)) {
|
||||
$dashboard_id = user()->dashboards()->enabled()->pluck('id')->first();
|
||||
}
|
||||
|
||||
if (!empty($dashboard_id)) {
|
||||
$dashboard = Dashboard::find($dashboard_id);
|
||||
} else {
|
||||
$dashboard = user()->dashboards()->enabled()->first();
|
||||
}
|
||||
|
||||
if (empty($dashboard)) {
|
||||
@ -67,8 +65,10 @@ class Dashboards extends Controller
|
||||
]));
|
||||
}
|
||||
|
||||
session(['dashboard_id' => $dashboard->id]);
|
||||
|
||||
$widgets = Widget::where('dashboard_id', $dashboard->id)->orderBy('sort', 'asc')->get()->filter(function ($widget) {
|
||||
return Widgets::canRead($widget->class);
|
||||
return Widgets::canShow($widget->class);
|
||||
});
|
||||
|
||||
$financial_start = $this->getFinancialStart()->format('Y-m-d');
|
||||
@ -215,7 +215,7 @@ class Dashboards extends Controller
|
||||
|
||||
flash($message)->success();
|
||||
|
||||
session(['dashboard_id' => user()->dashboards()->pluck('id')->first()]);
|
||||
session(['dashboard_id' => user()->dashboards()->enabled()->pluck('id')->first()]);
|
||||
} else {
|
||||
$message = $response['message'];
|
||||
|
||||
|
@ -28,7 +28,7 @@ class Items extends Controller
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$items = Item::with(['category', 'tax'])->collect();
|
||||
$items = Item::with('category', 'media')->collect();
|
||||
|
||||
return view('common.items.index', compact('items'));
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ class Reports extends Controller
|
||||
$reports = Report::orderBy('name')->get();
|
||||
|
||||
foreach ($reports as $report) {
|
||||
if (!Utility::canRead($report->class)) {
|
||||
if (!Utility::canShow($report->class)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -56,7 +56,7 @@ class Reports extends Controller
|
||||
*/
|
||||
public function show(Report $report)
|
||||
{
|
||||
if (!Utility::canRead($report->class)) {
|
||||
if (!Utility::canShow($report->class)) {
|
||||
abort(403);
|
||||
}
|
||||
|
||||
@ -203,7 +203,7 @@ class Reports extends Controller
|
||||
*/
|
||||
public function print(Report $report)
|
||||
{
|
||||
if (!Utility::canRead($report->class)) {
|
||||
if (!Utility::canShow($report->class)) {
|
||||
abort(403);
|
||||
}
|
||||
|
||||
@ -218,7 +218,7 @@ class Reports extends Controller
|
||||
*/
|
||||
public function export(Report $report)
|
||||
{
|
||||
if (!Utility::canRead($report->class)) {
|
||||
if (!Utility::canShow($report->class)) {
|
||||
abort(403);
|
||||
}
|
||||
|
||||
@ -263,7 +263,7 @@ class Reports extends Controller
|
||||
public function clear()
|
||||
{
|
||||
Report::all()->each(function ($report) {
|
||||
if (!Utility::canRead($report->class)) {
|
||||
if (!Utility::canShow($report->class)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -64,8 +64,9 @@ class Search extends Controller
|
||||
'href' => route('invoices.show', $invoice->id),
|
||||
];
|
||||
}
|
||||
}/*
|
||||
}
|
||||
|
||||
/*
|
||||
$income_transactions = Transaction::income()->usingSearchString($keyword)->get();
|
||||
|
||||
if ($income_transactions->count()) {
|
||||
@ -78,7 +79,8 @@ class Search extends Controller
|
||||
'href' => url('sales/revenues/' . $transaction->id),
|
||||
];
|
||||
}
|
||||
}*/
|
||||
}
|
||||
*/
|
||||
|
||||
$customers = Contact::customer()->enabled()->usingSearchString($search->keyword)->get();
|
||||
|
||||
@ -107,7 +109,8 @@ class Search extends Controller
|
||||
];
|
||||
}
|
||||
}
|
||||
/*
|
||||
|
||||
/*
|
||||
$payments = Transaction::expense()->usingSearchString($keyword)->get();
|
||||
|
||||
if ($revenues->count()) {
|
||||
@ -120,7 +123,8 @@ class Search extends Controller
|
||||
'href' => url('sales/revenues/' . $revenue->id),
|
||||
];
|
||||
}
|
||||
}*/
|
||||
}
|
||||
*/
|
||||
|
||||
$vendors = Contact::vendor()->enabled()->usingSearchString($search->keyword)->get();
|
||||
|
||||
|
@ -121,10 +121,21 @@ class Uploads extends Controller
|
||||
*/
|
||||
public function destroy($id, Request $request)
|
||||
{
|
||||
$return = back();
|
||||
|
||||
if ($request->has('ajax') && $request->get('ajax')) {
|
||||
$return = [
|
||||
'success' => true,
|
||||
'errors' => false,
|
||||
'message' => '',
|
||||
'redirect' => $request->get('redirect')
|
||||
];
|
||||
}
|
||||
|
||||
try {
|
||||
$media = Media::find($id);
|
||||
} catch (\Exception $e) {
|
||||
return back();
|
||||
return $return;
|
||||
}
|
||||
|
||||
// Get file path
|
||||
@ -133,7 +144,7 @@ class Uploads extends Controller
|
||||
|
||||
flash($message)->warning();
|
||||
|
||||
return back();
|
||||
return $return;
|
||||
}
|
||||
|
||||
$media->delete(); //will not delete files
|
||||
@ -150,7 +161,7 @@ class Uploads extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
return back();
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -39,7 +39,6 @@ class Updates extends Controller
|
||||
$m = new \stdClass();
|
||||
$m->name = $row->getName();
|
||||
$m->alias = $row->get('alias');
|
||||
$m->category = $row->get('category');
|
||||
$m->installed = $row->get('version');
|
||||
$m->latest = $updates[$alias];
|
||||
|
||||
|
@ -16,9 +16,9 @@ class Accounts extends Controller
|
||||
public function __construct()
|
||||
{
|
||||
// Add CRUD permission check
|
||||
$this->middleware('permission:create-banking-accounts')->only(['create', 'store', 'duplicate', 'import']);
|
||||
$this->middleware('permission:read-banking-accounts')->only(['index', 'show', 'edit', 'export']);
|
||||
$this->middleware('permission:update-banking-accounts')->only(['update', 'enable', 'disable']);
|
||||
$this->middleware('permission:create-banking-accounts')->only('create', 'store', 'duplicate', 'import');
|
||||
$this->middleware('permission:read-banking-accounts')->only('index', 'show', 'edit', 'export');
|
||||
$this->middleware('permission:update-banking-accounts')->only('update', 'enable', 'disable');
|
||||
$this->middleware('permission:delete-banking-accounts')->only('destroy');
|
||||
}
|
||||
|
||||
|
@ -22,9 +22,9 @@ class BillTransactions extends Controller
|
||||
public function __construct()
|
||||
{
|
||||
// Add CRUD permission check
|
||||
$this->middleware('permission:create-purchases-bills')->only(['create', 'store', 'duplicate', 'import']);
|
||||
$this->middleware('permission:read-purchases-bills')->only(['index', 'show', 'edit', 'export']);
|
||||
$this->middleware('permission:update-purchases-bills')->only(['update', 'enable', 'disable']);
|
||||
$this->middleware('permission:create-purchases-bills')->only('create', 'store', 'duplicate', 'import');
|
||||
$this->middleware('permission:read-purchases-bills')->only('index', 'show', 'edit', 'export');
|
||||
$this->middleware('permission:update-purchases-bills')->only('update', 'enable', 'disable');
|
||||
$this->middleware('permission:delete-purchases-bills')->only('destroy');
|
||||
}
|
||||
|
||||
@ -67,6 +67,19 @@ class BillTransactions extends Controller
|
||||
'error' => false,
|
||||
'message' => 'null',
|
||||
'html' => $html,
|
||||
'data' => [
|
||||
'title' => trans('general.title.new', ['type' => trans_choice('general.payments', 1)]),
|
||||
'buttons' => [
|
||||
'cancel' => [
|
||||
'text' => trans('general.cancel'),
|
||||
'class' => 'btn-outline-secondary'
|
||||
],
|
||||
'confirm' => [
|
||||
'text' => trans('general.save'),
|
||||
'class' => 'btn-success'
|
||||
]
|
||||
]
|
||||
]
|
||||
]);
|
||||
}
|
||||
|
||||
|
@ -15,9 +15,9 @@ class Categories extends Controller
|
||||
public function __construct()
|
||||
{
|
||||
// Add CRUD permission check
|
||||
$this->middleware('permission:create-settings-categories')->only(['create', 'store', 'duplicate', 'import']);
|
||||
$this->middleware('permission:read-settings-categories')->only(['index', 'show', 'edit', 'export']);
|
||||
$this->middleware('permission:update-settings-categories')->only(['update', 'enable', 'disable']);
|
||||
$this->middleware('permission:create-settings-categories')->only('create', 'store', 'duplicate', 'import');
|
||||
$this->middleware('permission:read-settings-categories')->only('index', 'show', 'edit', 'export');
|
||||
$this->middleware('permission:update-settings-categories')->only('update', 'enable', 'disable');
|
||||
$this->middleware('permission:delete-settings-categories')->only('destroy');
|
||||
}
|
||||
|
||||
|
@ -16,9 +16,9 @@ class Currencies extends Controller
|
||||
public function __construct()
|
||||
{
|
||||
// Add CRUD permission check
|
||||
$this->middleware('permission:create-settings-currencies')->only(['create', 'store', 'duplicate', 'import']);
|
||||
$this->middleware('permission:read-settings-currencies')->only(['index', 'show', 'edit', 'export']);
|
||||
$this->middleware('permission:update-settings-currencies')->only(['update', 'enable', 'disable']);
|
||||
$this->middleware('permission:create-settings-currencies')->only('create', 'store', 'duplicate', 'import');
|
||||
$this->middleware('permission:read-settings-currencies')->only('index', 'show', 'edit', 'export');
|
||||
$this->middleware('permission:update-settings-currencies')->only('update', 'enable', 'disable');
|
||||
$this->middleware('permission:delete-settings-currencies')->only('destroy');
|
||||
}
|
||||
|
||||
|
@ -15,9 +15,9 @@ class Customers extends Controller
|
||||
public function __construct()
|
||||
{
|
||||
// Add CRUD permission check
|
||||
$this->middleware('permission:create-sales-customers')->only(['create', 'store', 'duplicate', 'import']);
|
||||
$this->middleware('permission:read-sales-customers')->only(['index', 'show', 'edit', 'export']);
|
||||
$this->middleware('permission:update-sales-customers')->only(['update', 'enable', 'disable']);
|
||||
$this->middleware('permission:create-sales-customers')->only('create', 'store', 'duplicate', 'import');
|
||||
$this->middleware('permission:read-sales-customers')->only('index', 'show', 'edit', 'export');
|
||||
$this->middleware('permission:update-sales-customers')->only('update', 'enable', 'disable');
|
||||
$this->middleware('permission:delete-sales-customers')->only('destroy');
|
||||
}
|
||||
|
||||
|
@ -12,9 +12,9 @@ class InvoiceTemplates extends Controller
|
||||
public function __construct()
|
||||
{
|
||||
// Add CRUD permission check
|
||||
$this->middleware('permission:create-settings-settings')->only(['create', 'store']);
|
||||
$this->middleware('permission:read-settings-settings')->only(['index', 'edit']);
|
||||
$this->middleware('permission:update-settings-settings')->only(['update', 'enable', 'disable']);
|
||||
$this->middleware('permission:create-settings-settings')->only('create', 'store');
|
||||
$this->middleware('permission:read-settings-settings')->only('index', 'edit');
|
||||
$this->middleware('permission:update-settings-settings')->only('update', 'enable', 'disable');
|
||||
$this->middleware('permission:delete-settings-settings')->only('destroy');
|
||||
}
|
||||
|
||||
|
@ -22,9 +22,9 @@ class InvoiceTransactions extends Controller
|
||||
public function __construct()
|
||||
{
|
||||
// Add CRUD permission check
|
||||
$this->middleware('permission:create-sales-invoices')->only(['create', 'store', 'duplicate', 'import']);
|
||||
$this->middleware('permission:read-sales-invoices')->only(['index', 'show', 'edit', 'export']);
|
||||
$this->middleware('permission:update-sales-invoices')->only(['update', 'enable', 'disable']);
|
||||
$this->middleware('permission:create-sales-invoices')->only('create', 'store', 'duplicate', 'import');
|
||||
$this->middleware('permission:read-sales-invoices')->only('index', 'show', 'edit', 'export');
|
||||
$this->middleware('permission:update-sales-invoices')->only('update', 'enable', 'disable');
|
||||
$this->middleware('permission:delete-sales-invoices')->only('destroy');
|
||||
}
|
||||
|
||||
@ -67,6 +67,24 @@ class InvoiceTransactions extends Controller
|
||||
'error' => false,
|
||||
'message' => 'null',
|
||||
'html' => $html,
|
||||
'data' => [
|
||||
'title' => trans('general.title.new', ['type' => trans_choice('general.payments', 1)]),
|
||||
'buttons' => [
|
||||
'cancel' => [
|
||||
'text' => trans('general.cancel'),
|
||||
'class' => 'btn-outline-secondary'
|
||||
],
|
||||
'payment' => [
|
||||
'text' => trans('invoices.accept_payments'),
|
||||
'class' => 'long-texts',
|
||||
'url' => route('apps.categories.show', 'payment-method')
|
||||
],
|
||||
'confirm' => [
|
||||
'text' => trans('general.save'),
|
||||
'class' => 'btn-success'
|
||||
]
|
||||
]
|
||||
]
|
||||
]);
|
||||
}
|
||||
|
||||
|
@ -17,9 +17,9 @@ class Items extends Controller
|
||||
public function __construct()
|
||||
{
|
||||
// Add CRUD permission check
|
||||
$this->middleware('permission:create-common-items')->only(['create', 'store', 'duplicate', 'import']);
|
||||
$this->middleware('permission:read-common-items')->only(['index', 'show', 'edit', 'export']);
|
||||
$this->middleware('permission:update-common-items')->only(['update', 'enable', 'disable']);
|
||||
$this->middleware('permission:create-common-items')->only('create', 'store', 'duplicate', 'import');
|
||||
$this->middleware('permission:read-common-items')->only('index', 'show', 'edit', 'export');
|
||||
$this->middleware('permission:update-common-items')->only('update', 'enable', 'disable');
|
||||
$this->middleware('permission:delete-common-items')->only('destroy');
|
||||
}
|
||||
|
||||
@ -34,7 +34,7 @@ class Items extends Controller
|
||||
|
||||
$taxes = Tax::enabled()->orderBy('name')->get()->pluck('title', 'id');
|
||||
|
||||
$currency = Currency::where('code', setting('default.currency', 'USD'))->first();
|
||||
$currency = Currency::where('code', setting('default.currency'))->first();
|
||||
|
||||
$html = view('modals.items.create', compact('categories', 'taxes', 'currency'))->render();
|
||||
|
||||
|
@ -14,9 +14,9 @@ class Taxes extends Controller
|
||||
public function __construct()
|
||||
{
|
||||
// Add CRUD permission check
|
||||
$this->middleware('permission:create-settings-taxes')->only(['create', 'store']);
|
||||
$this->middleware('permission:read-settings-taxes')->only(['index', 'edit']);
|
||||
$this->middleware('permission:update-settings-taxes')->only(['update', 'enable', 'disable']);
|
||||
$this->middleware('permission:create-settings-taxes')->only('create', 'store');
|
||||
$this->middleware('permission:read-settings-taxes')->only('index', 'edit');
|
||||
$this->middleware('permission:update-settings-taxes')->only('update', 'enable', 'disable');
|
||||
$this->middleware('permission:delete-settings-taxes')->only('destroy');
|
||||
}
|
||||
|
||||
@ -28,8 +28,10 @@ class Taxes extends Controller
|
||||
public function create()
|
||||
{
|
||||
$types = [
|
||||
'fixed' => trans('taxes.fixed'),
|
||||
'normal' => trans('taxes.normal'),
|
||||
'inclusive' => trans('taxes.inclusive'),
|
||||
'withholding' => trans('taxes.withholding'),
|
||||
'compound' => trans('taxes.compound'),
|
||||
];
|
||||
|
||||
|
@ -15,9 +15,9 @@ class Vendors extends Controller
|
||||
public function __construct()
|
||||
{
|
||||
// Add CRUD permission check
|
||||
$this->middleware('permission:create-purchases-vendors')->only(['create', 'store', 'duplicate', 'import']);
|
||||
$this->middleware('permission:read-purchases-vendors')->only(['index', 'show', 'edit', 'export']);
|
||||
$this->middleware('permission:update-purchases-vendors')->only(['update', 'enable', 'disable']);
|
||||
$this->middleware('permission:create-purchases-vendors')->only('create', 'store', 'duplicate', 'import');
|
||||
$this->middleware('permission:read-purchases-vendors')->only('index', 'show', 'edit', 'export');
|
||||
$this->middleware('permission:update-purchases-vendors')->only('update', 'enable', 'disable');
|
||||
$this->middleware('permission:delete-purchases-vendors')->only('destroy');
|
||||
}
|
||||
|
||||
|
@ -4,7 +4,6 @@ namespace App\Http\Controllers\Modules;
|
||||
|
||||
use App\Abstracts\Http\Controller;
|
||||
use App\Models\Module\Module;
|
||||
use App\Models\Module\ModuleHistory;
|
||||
use App\Traits\Modules;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
@ -18,9 +17,9 @@ class Item extends Controller
|
||||
public function __construct()
|
||||
{
|
||||
// Add CRUD permission check
|
||||
$this->middleware('permission:create-modules-item')->only(['install']);
|
||||
$this->middleware('permission:update-modules-item')->only(['update', 'enable', 'disable']);
|
||||
$this->middleware('permission:delete-modules-item')->only(['uninstall']);
|
||||
$this->middleware('permission:create-modules-item')->only('install');
|
||||
$this->middleware('permission:update-modules-item')->only('update', 'enable', 'disable');
|
||||
$this->middleware('permission:delete-modules-item')->only('uninstall');
|
||||
}
|
||||
|
||||
/**
|
||||
@ -38,7 +37,7 @@ class Item extends Controller
|
||||
$module = $this->getModule($alias);
|
||||
|
||||
if (empty($module)) {
|
||||
return redirect('apps/home')->send();
|
||||
return redirect()->route('apps.home.index')->send();
|
||||
}
|
||||
|
||||
if ($this->moduleExists($alias) && ($model = Module::alias($alias)->first())) {
|
||||
@ -160,6 +159,8 @@ class Item extends Controller
|
||||
$message = trans('modules.installed', ['module' => $json['data']['name']]);
|
||||
|
||||
flash($message)->success();
|
||||
} else {
|
||||
flash($json['message'])->error();
|
||||
}
|
||||
|
||||
return response()->json($json);
|
||||
@ -169,102 +170,45 @@ class Item extends Controller
|
||||
{
|
||||
$json = $this->uninstallModule($alias);
|
||||
|
||||
$module = Module::alias($alias)->first();
|
||||
if ($json['success']) {
|
||||
$message = trans('modules.uninstalled', ['module' => $json['data']['name']]);
|
||||
|
||||
$data = [
|
||||
'company_id' => session('company_id'),
|
||||
'module_id' => $module->id,
|
||||
'category' => $json['data']['category'],
|
||||
'version' => $json['data']['version'],
|
||||
'description' => trans('modules.uninstalled', ['module' => $json['data']['name']]),
|
||||
];
|
||||
flash($message)->success();
|
||||
} else {
|
||||
flash($json['message'])->error();
|
||||
}
|
||||
|
||||
ModuleHistory::create($data);
|
||||
|
||||
$module->delete();
|
||||
|
||||
$message = trans('modules.uninstalled', ['module' => $json['data']['name']]);
|
||||
|
||||
flash($message)->success();
|
||||
|
||||
return redirect('apps/' . $alias)->send();
|
||||
}
|
||||
|
||||
public function update($alias)
|
||||
{
|
||||
$json = $this->updateModule($alias);
|
||||
|
||||
$module = Module::alias($alias)->first();
|
||||
|
||||
$data = [
|
||||
'company_id' => session('company_id'),
|
||||
'module_id' => $module->id,
|
||||
'category' => $json['data']['category'],
|
||||
'version' => $json['data']['version'],
|
||||
'description' => trans_choice('modules.updated', $json['data']['name']),
|
||||
];
|
||||
|
||||
ModuleHistory::create($data);
|
||||
|
||||
$message = trans('modules.updated', ['module' => $json['data']['name']]);
|
||||
|
||||
flash($message)->success();
|
||||
|
||||
return redirect('apps/' . $alias)->send();
|
||||
return redirect()->route('apps.app.show', $alias)->send();
|
||||
}
|
||||
|
||||
public function enable($alias)
|
||||
{
|
||||
$json = $this->enableModule($alias);
|
||||
|
||||
$module = Module::alias($alias)->first();
|
||||
if ($json['success']) {
|
||||
$message = trans('modules.enabled', ['module' => $json['data']['name']]);
|
||||
|
||||
$data = [
|
||||
'company_id' => session('company_id'),
|
||||
'module_id' => $module->id,
|
||||
'category' => $json['data']['category'],
|
||||
'version' => $json['data']['version'],
|
||||
'description' => trans('modules.enabled', ['module' => $json['data']['name']]),
|
||||
];
|
||||
flash($message)->success();
|
||||
} else {
|
||||
flash($json['message'])->error();
|
||||
}
|
||||
|
||||
$module->enabled = 1;
|
||||
|
||||
$module->save();
|
||||
|
||||
ModuleHistory::create($data);
|
||||
|
||||
$message = trans('modules.enabled', ['module' => $json['data']['name']]);
|
||||
|
||||
flash($message)->success();
|
||||
|
||||
return redirect('apps/' . $alias)->send();
|
||||
return redirect()->route('apps.app.show', $alias)->send();
|
||||
}
|
||||
|
||||
public function disable($alias)
|
||||
{
|
||||
$json = $this->disableModule($alias);
|
||||
|
||||
$module = Module::alias($alias)->first();
|
||||
if ($json['success']) {
|
||||
$message = trans('modules.disabled', ['module' => $json['data']['name']]);
|
||||
|
||||
$data = [
|
||||
'company_id' => session('company_id'),
|
||||
'module_id' => $module->id,
|
||||
'category' => $json['data']['category'],
|
||||
'version' => $json['data']['version'],
|
||||
'description' => trans('modules.disabled', ['module' => $json['data']['name']]),
|
||||
];
|
||||
flash($message)->success();
|
||||
} else {
|
||||
flash($json['message'])->error();
|
||||
}
|
||||
|
||||
$module->enabled = 0;
|
||||
|
||||
$module->save();
|
||||
|
||||
ModuleHistory::create($data);
|
||||
|
||||
$message = trans('modules.disabled', ['module' => $json['data']['name']]);
|
||||
|
||||
flash($message)->success();
|
||||
|
||||
return redirect('apps/' . $alias)->send();
|
||||
return redirect()->route('apps.app.show', $alias)->send();
|
||||
}
|
||||
|
||||
public function reviews($alias, Request $request)
|
||||
@ -292,11 +236,11 @@ class Item extends Controller
|
||||
{
|
||||
$documentation = $this->getDocumentation($alias);
|
||||
|
||||
if (empty($documentation)) {
|
||||
return redirect('apps/' . $alias)->send();
|
||||
}
|
||||
$back = route('apps.app.show', $alias);
|
||||
|
||||
$back = 'apps/' . $alias;
|
||||
if (empty($documentation)) {
|
||||
return redirect()->route($back)->send();
|
||||
}
|
||||
|
||||
return view('modules.item.documentation', compact('documentation', 'back'));
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ class Invoices extends Controller
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$invoices = Invoice::with(['contact', 'items', 'payments', 'histories'])
|
||||
$invoices = Invoice::with('contact', 'histories', 'items', 'payments')
|
||||
->accrued()->where('contact_id', user()->contact->id)
|
||||
->collect(['invoice_number'=> 'desc']);
|
||||
|
||||
|
@ -37,7 +37,7 @@ class Bills extends Controller
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$bills = Bill::with(['contact', 'items', 'histories', 'transactions'])->collect(['billed_at'=> 'desc']);
|
||||
$bills = Bill::with('contact', 'transactions')->collect(['billed_at'=> 'desc']);
|
||||
|
||||
$vendors = Contact::vendor()->enabled()->orderBy('name')->pluck('name', 'id');
|
||||
|
||||
@ -83,7 +83,7 @@ class Bills extends Controller
|
||||
$bill->grand_total = money($total, $currency->code)->getAmount();
|
||||
|
||||
if (!empty($bill->paid)) {
|
||||
$bill->grand_total = round($bill->total - $bill->paid, $currency->precision) ;
|
||||
$bill->grand_total = round($bill->total - $bill->paid, $currency->precision);
|
||||
}
|
||||
|
||||
return view('purchases.bills.show', compact('bill', 'accounts', 'currencies', 'currency', 'account_currency_code', 'vendors', 'categories', 'payment_methods', 'date_format'));
|
||||
|
@ -30,7 +30,7 @@ class Payments extends Controller
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$payments = Transaction::expense()->with(['account', 'category', 'contact'])->isNotTransfer()->collect(['paid_at'=> 'desc']);
|
||||
$payments = Transaction::with('account', 'bill', 'category', 'contact')->expense()->isNotTransfer()->collect(['paid_at'=> 'desc']);
|
||||
|
||||
$vendors = Contact::vendor()->enabled()->orderBy('name')->pluck('name', 'id');
|
||||
|
||||
|
@ -28,7 +28,7 @@ class Vendors extends Controller
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$vendors = Contact::vendor()->collect();
|
||||
$vendors = Contact::with('bills.transactions')->vendor()->collect();
|
||||
|
||||
return view('purchases.vendors.index', compact('vendors'));
|
||||
}
|
||||
@ -51,7 +51,7 @@ class Vendors extends Controller
|
||||
$counts = [];
|
||||
|
||||
// Handle bills
|
||||
$bills = Bill::where('contact_id', $vendor->id)->get();
|
||||
$bills = Bill::with('transactions')->where('contact_id', $vendor->id)->get();
|
||||
|
||||
$counts['bills'] = $bills->count();
|
||||
|
||||
@ -78,7 +78,7 @@ class Vendors extends Controller
|
||||
}
|
||||
|
||||
// Handle payments
|
||||
$transactions = Transaction::where('contact_id', $vendor->id)->expense()->get();
|
||||
$transactions = Transaction::with('category')->where('contact_id', $vendor->id)->expense()->get();
|
||||
|
||||
$counts['transactions'] = $transactions->count();
|
||||
|
||||
|
@ -26,7 +26,7 @@ class Customers extends Controller
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$customers = Contact::customer()->collect();
|
||||
$customers = Contact::with('invoices.transactions')->customer()->collect();
|
||||
|
||||
return view('sales.customers.index', compact('customers'));
|
||||
}
|
||||
@ -49,7 +49,7 @@ class Customers extends Controller
|
||||
$counts = [];
|
||||
|
||||
// Handle invoices
|
||||
$invoices = Invoice::where('contact_id', $customer->id)->get();
|
||||
$invoices = Invoice::with('transactions')->where('contact_id', $customer->id)->get();
|
||||
|
||||
$counts['invoices'] = $invoices->count();
|
||||
|
||||
@ -76,7 +76,7 @@ class Customers extends Controller
|
||||
}
|
||||
|
||||
// Handle transactions
|
||||
$transactions = Transaction::where('contact_id', $customer->id)->income()->get();
|
||||
$transactions = Transaction::with('category')->where('contact_id', $customer->id)->income()->get();
|
||||
|
||||
$counts['transactions'] = $transactions->count();
|
||||
|
||||
|
@ -38,7 +38,7 @@ class Invoices extends Controller
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$invoices = Invoice::with(['contact', 'items', 'histories', 'transactions'])->collect(['invoice_number'=> 'desc']);
|
||||
$invoices = Invoice::with('contact', 'transactions')->collect(['invoice_number'=> 'desc']);
|
||||
|
||||
$customers = Contact::customer()->enabled()->orderBy('name')->pluck('name', 'id');
|
||||
|
||||
@ -435,7 +435,7 @@ class Invoices extends Controller
|
||||
$currency = Currency::where('code', $currency_code)->first();
|
||||
|
||||
if (empty($currency)) {
|
||||
$currency = Currency::where('code', setting('default.currency', 'USD'))->first();
|
||||
$currency = Currency::where('code', setting('default.currency'))->first();
|
||||
}
|
||||
|
||||
if ($currency) {
|
||||
|
@ -30,7 +30,7 @@ class Revenues extends Controller
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$revenues = Transaction::income()->with(['account', 'category', 'contact'])->isNotTransfer()->collect(['paid_at'=> 'desc']);
|
||||
$revenues = Transaction::with('account', 'category', 'contact', 'invoice')->income()->isNotTransfer()->collect(['paid_at'=> 'desc']);
|
||||
|
||||
$customers = Contact::customer()->enabled()->orderBy('name')->pluck('name', 'id');
|
||||
|
||||
|
@ -3,20 +3,11 @@
|
||||
namespace App\Http\Controllers\Settings;
|
||||
|
||||
use App\Abstracts\Http\Controller;
|
||||
use App\Models\Setting\Setting;
|
||||
|
||||
class Company extends Controller
|
||||
{
|
||||
public function edit()
|
||||
{
|
||||
$setting = Setting::prefix('company')->get()->transform(function ($s) {
|
||||
$s->key = str_replace('company.', '', $s->key);
|
||||
|
||||
return $s;
|
||||
})->pluck('value', 'key');
|
||||
|
||||
return view('settings.company.edit', compact(
|
||||
'setting'
|
||||
));
|
||||
return view('settings.company.edit');
|
||||
}
|
||||
}
|
||||
|
@ -56,7 +56,15 @@ class Currencies extends Controller
|
||||
$codes[$key] = $key;
|
||||
}
|
||||
|
||||
return view('settings.currencies.create', compact('codes'));
|
||||
$precisions = (object) [
|
||||
0 => 0,
|
||||
1 => 1,
|
||||
2 => 2,
|
||||
3 => 3,
|
||||
4 => 4,
|
||||
];
|
||||
|
||||
return view('settings.currencies.create', compact('codes', 'precisions'));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -114,7 +122,15 @@ class Currencies extends Controller
|
||||
// Set default currency
|
||||
$currency->default_currency = ($currency->code == setting('default.currency')) ? 1 : 0;
|
||||
|
||||
return view('settings.currencies.edit', compact('currency', 'codes'));
|
||||
$precisions = (object) [
|
||||
0 => 0,
|
||||
1 => 1,
|
||||
2 => 2,
|
||||
3 => 3,
|
||||
4 => 4,
|
||||
];
|
||||
|
||||
return view('settings.currencies.edit', compact('currency', 'codes', 'precisions'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -5,7 +5,6 @@ namespace App\Http\Controllers\Settings;
|
||||
use App\Abstracts\Http\Controller;
|
||||
use App\Models\Banking\Account;
|
||||
use App\Models\Setting\Currency;
|
||||
use App\Models\Setting\Setting;
|
||||
use App\Models\Setting\Tax;
|
||||
use App\Utilities\Modules;
|
||||
|
||||
@ -13,12 +12,6 @@ class Defaults extends Controller
|
||||
{
|
||||
public function edit()
|
||||
{
|
||||
$setting = Setting::prefix('default')->get()->transform(function ($s) {
|
||||
$s->key = str_replace('default.', '', $s->key);
|
||||
|
||||
return $s;
|
||||
})->pluck('value', 'key');
|
||||
|
||||
$accounts = Account::enabled()->orderBy('name')->pluck('name', 'id');
|
||||
|
||||
$currencies = Currency::enabled()->orderBy('name')->pluck('name', 'code');
|
||||
@ -28,7 +21,6 @@ class Defaults extends Controller
|
||||
$payment_methods = Modules::getPaymentMethods();
|
||||
|
||||
return view('settings.default.edit', compact(
|
||||
'setting',
|
||||
'accounts',
|
||||
'currencies',
|
||||
'taxes',
|
||||
|
@ -4,8 +4,9 @@ namespace App\Http\Controllers\Settings;
|
||||
|
||||
use App\Abstracts\Http\Controller;
|
||||
use App\Http\Requests\Setting\Setting as Request;
|
||||
use App\Models\Common\Company;
|
||||
use App\Models\Common\EmailTemplate;
|
||||
use App\Models\Setting\Setting;
|
||||
use App\Utilities\Installer;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class Email extends Controller
|
||||
@ -23,20 +24,14 @@ class Email extends Controller
|
||||
}
|
||||
|
||||
// Add CRUD permission check
|
||||
$this->middleware('permission:create-settings-settings')->only(['create', 'store', 'duplicate', 'import']);
|
||||
$this->middleware('permission:read-settings-email')->only(['index', 'show', 'edit', 'export']);
|
||||
$this->middleware('permission:update-settings-settings')->only(['update', 'enable', 'disable']);
|
||||
$this->middleware('permission:create-settings-settings')->only('create', 'store', 'duplicate', 'import');
|
||||
$this->middleware('permission:read-settings-email')->only('index', 'show', 'edit', 'export');
|
||||
$this->middleware('permission:update-settings-settings')->only('update', 'enable', 'disable');
|
||||
$this->middleware('permission:delete-settings-settings')->only('destroy');
|
||||
}
|
||||
|
||||
public function edit()
|
||||
{
|
||||
$setting = Setting::prefix('email')->get()->transform(function ($s) {
|
||||
$s->key = str_replace('email.', '', $s->key);
|
||||
|
||||
return $s;
|
||||
})->pluck('value', 'key');
|
||||
|
||||
$templates = EmailTemplate::all();
|
||||
|
||||
$email_protocols = [
|
||||
@ -47,7 +42,6 @@ class Email extends Controller
|
||||
];
|
||||
|
||||
return view('settings.email.edit', compact(
|
||||
'setting',
|
||||
'templates',
|
||||
'email_protocols'
|
||||
));
|
||||
@ -58,6 +52,8 @@ class Email extends Controller
|
||||
$fields = $request->all();
|
||||
$prefix = $request->get('_prefix', 'email');
|
||||
|
||||
$total_companies = Company::count();
|
||||
|
||||
foreach ($fields as $key => $value) {
|
||||
$real_key = $prefix . '.' . $key;
|
||||
|
||||
@ -72,6 +68,10 @@ class Email extends Controller
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($total_companies == 1) {
|
||||
$this->oneCompany($real_key, $value);
|
||||
}
|
||||
|
||||
setting()->set($real_key, $value);
|
||||
}
|
||||
|
||||
@ -114,4 +114,32 @@ class Email extends Controller
|
||||
unset($fields[$subject_key]);
|
||||
unset($fields[$body_key]);
|
||||
}
|
||||
|
||||
protected function oneCompany($real_key, $value)
|
||||
{
|
||||
if (empty($value)) {
|
||||
return;
|
||||
}
|
||||
|
||||
switch ($real_key) {
|
||||
case 'email.protocol':
|
||||
Installer::updateEnv(['MAIL_MAILER' => '"' . $value . '"']);
|
||||
break;
|
||||
case 'email.smtp_host':
|
||||
Installer::updateEnv(['MAIL_HOST' => '"' . $value . '"']);
|
||||
break;
|
||||
case 'email.smtp_port':
|
||||
Installer::updateEnv(['MAIL_PORT' => '"' . $value . '"']);
|
||||
break;
|
||||
case 'email.smtp_username':
|
||||
Installer::updateEnv(['MAIL_USERNAME' => '"' . $value . '"']);
|
||||
break;
|
||||
case 'email.smtp_password':
|
||||
Installer::updateEnv(['MAIL_PASSWORD' => '"' . $value . '"']);
|
||||
break;
|
||||
case 'email.smtp_encryption':
|
||||
Installer::updateEnv(['MAIL_ENCRYPTION' => '"' . $value . '"']);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3,18 +3,11 @@
|
||||
namespace App\Http\Controllers\Settings;
|
||||
|
||||
use App\Abstracts\Http\Controller;
|
||||
use App\Models\Setting\Setting;
|
||||
|
||||
class Invoice extends Controller
|
||||
{
|
||||
public function edit()
|
||||
{
|
||||
$setting = Setting::prefix('invoice')->get()->transform(function ($s) {
|
||||
$s->key = str_replace('invoice.', '', $s->key);
|
||||
|
||||
return $s;
|
||||
})->pluck('value', 'key');
|
||||
|
||||
$item_names = [
|
||||
'settings.invoice.item' => trans('settings.invoice.item'),
|
||||
'settings.invoice.product' => trans('settings.invoice.product'),
|
||||
@ -43,7 +36,6 @@ class Invoice extends Controller
|
||||
];
|
||||
|
||||
return view('settings.invoice.edit', compact(
|
||||
'setting',
|
||||
'item_names',
|
||||
'price_names',
|
||||
'quantity_names',
|
||||
|
@ -3,7 +3,6 @@
|
||||
namespace App\Http\Controllers\Settings;
|
||||
|
||||
use App\Abstracts\Http\Controller;
|
||||
use App\Models\Setting\Setting;
|
||||
use App\Traits\DateTime;
|
||||
|
||||
class Localisation extends Controller
|
||||
@ -12,12 +11,6 @@ class Localisation extends Controller
|
||||
|
||||
public function edit()
|
||||
{
|
||||
$setting = Setting::prefix('localisation')->get()->transform(function ($s) {
|
||||
$s->key = str_replace('localisation.', '', $s->key);
|
||||
|
||||
return $s;
|
||||
})->pluck('value', 'key');
|
||||
|
||||
$timezones = $this->getTimezones();
|
||||
|
||||
$date_formats = [
|
||||
@ -49,7 +42,6 @@ class Localisation extends Controller
|
||||
];
|
||||
|
||||
return view('settings.localisation.edit', compact(
|
||||
'setting',
|
||||
'timezones',
|
||||
'date_formats',
|
||||
'date_separators',
|
||||
|
@ -3,6 +3,8 @@
|
||||
namespace App\Http\Controllers\Settings;
|
||||
|
||||
use App\Abstracts\Http\Controller;
|
||||
use App\Models\Banking\Account;
|
||||
use App\Models\Setting\Category;
|
||||
use App\Models\Setting\Setting;
|
||||
use App\Utilities\Modules as Utility;
|
||||
use App\Http\Requests\Setting\Module as Request;
|
||||
@ -17,9 +19,9 @@ class Modules extends Controller
|
||||
$alias = request()->segment(1);
|
||||
|
||||
// Add CRUD permission check
|
||||
$this->middleware('permission:create-' . $alias . '-settings')->only(['create', 'store', 'duplicate', 'import']);
|
||||
$this->middleware('permission:read-' . $alias . '-settings')->only(['index', 'show', 'edit', 'export']);
|
||||
$this->middleware('permission:update-' . $alias . '-settings')->only(['update', 'enable', 'disable']);
|
||||
$this->middleware('permission:create-' . $alias . '-settings')->only('create', 'store', 'duplicate', 'import');
|
||||
$this->middleware('permission:read-' . $alias . '-settings')->only('index', 'show', 'edit', 'export');
|
||||
$this->middleware('permission:update-' . $alias . '-settings')->only('update', 'enable', 'disable');
|
||||
$this->middleware('permission:delete-' . $alias . '-settings')->only('destroy');
|
||||
}
|
||||
|
||||
@ -30,6 +32,9 @@ class Modules extends Controller
|
||||
*/
|
||||
public function edit($alias)
|
||||
{
|
||||
$accounts = Account::enabled()->orderBy('name')->pluck('name', 'id');
|
||||
$categories = Category::income()->enabled()->orderBy('name')->pluck('name', 'id');
|
||||
|
||||
$setting = Setting::prefix($alias)->get()->transform(function ($s) use ($alias) {
|
||||
$s->key = str_replace($alias . '.', '', $s->key);
|
||||
return $s;
|
||||
@ -37,7 +42,7 @@ class Modules extends Controller
|
||||
|
||||
$module = module($alias);
|
||||
|
||||
return view('settings.modules.edit', compact('setting', 'module'));
|
||||
return view('settings.modules.edit', compact('setting', 'module', 'accounts', 'categories'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -3,20 +3,11 @@
|
||||
namespace App\Http\Controllers\Settings;
|
||||
|
||||
use App\Abstracts\Http\Controller;
|
||||
use App\Models\Setting\Setting;
|
||||
|
||||
class Schedule extends Controller
|
||||
{
|
||||
public function edit()
|
||||
{
|
||||
$setting = Setting::prefix('schedule')->get()->transform(function ($s) {
|
||||
$s->key = str_replace('schedule.', '', $s->key);
|
||||
|
||||
return $s;
|
||||
})->pluck('value', 'key');
|
||||
|
||||
return view('settings.schedule.edit', compact(
|
||||
'setting'
|
||||
));
|
||||
return view('settings.schedule.edit');
|
||||
}
|
||||
}
|
||||
|
@ -25,6 +25,7 @@ class Taxes extends Controller
|
||||
'fixed' => trans('taxes.fixed'),
|
||||
'normal' => trans('taxes.normal'),
|
||||
'inclusive' => trans('taxes.inclusive'),
|
||||
'withholding' => trans('taxes.withholding'),
|
||||
'compound' => trans('taxes.compound'),
|
||||
];
|
||||
|
||||
@ -52,6 +53,7 @@ class Taxes extends Controller
|
||||
'fixed' => trans('taxes.fixed'),
|
||||
'normal' => trans('taxes.normal'),
|
||||
'inclusive' => trans('taxes.inclusive'),
|
||||
'withholding' => trans('taxes.withholding'),
|
||||
'compound' => trans('taxes.compound'),
|
||||
];
|
||||
|
||||
@ -99,6 +101,7 @@ class Taxes extends Controller
|
||||
'fixed' => trans('taxes.fixed'),
|
||||
'normal' => trans('taxes.normal'),
|
||||
'inclusive' => trans('taxes.inclusive'),
|
||||
'withholding' => trans('taxes.withholding'),
|
||||
'compound' => trans('taxes.compound'),
|
||||
];
|
||||
|
||||
|
@ -18,9 +18,9 @@ class Companies extends Controller
|
||||
public function __construct()
|
||||
{
|
||||
// Add CRUD permission check
|
||||
$this->middleware('permission:create-common-companies')->only(['create', 'store', 'duplicate', 'import']);
|
||||
$this->middleware('permission:read-common-companies')->only(['index', 'show', 'edit', 'export']);
|
||||
$this->middleware('permission:update-common-companies')->only(['update', 'enable', 'disable']);
|
||||
$this->middleware('permission:create-common-companies')->only('create', 'store', 'duplicate', 'import');
|
||||
$this->middleware('permission:read-common-companies')->only('index', 'show', 'edit', 'export');
|
||||
$this->middleware('permission:update-common-companies')->only('update', 'enable', 'disable');
|
||||
$this->middleware('permission:delete-common-companies')->only('destroy');
|
||||
}
|
||||
|
||||
|
@ -18,9 +18,9 @@ class Currencies extends Controller
|
||||
public function __construct()
|
||||
{
|
||||
// Add CRUD permission check
|
||||
$this->middleware('permission:create-settings-currencies')->only(['create', 'store', 'duplicate', 'import']);
|
||||
$this->middleware('permission:read-settings-currencies')->only(['index', 'show', 'edit', 'export']);
|
||||
$this->middleware('permission:update-settings-currencies')->only(['update', 'enable', 'disable']);
|
||||
$this->middleware('permission:create-settings-currencies')->only('create', 'store', 'duplicate', 'import');
|
||||
$this->middleware('permission:read-settings-currencies')->only('index', 'show', 'edit', 'export');
|
||||
$this->middleware('permission:update-settings-currencies')->only('update', 'enable', 'disable');
|
||||
$this->middleware('permission:delete-settings-currencies')->only('destroy');
|
||||
}
|
||||
|
||||
|
@ -15,7 +15,7 @@ class Finish extends Controller
|
||||
public function __construct()
|
||||
{
|
||||
// Add CRUD permission check
|
||||
$this->middleware('permission:read-admin-panel')->only(['index', 'show', 'edit', 'export']);
|
||||
$this->middleware('permission:read-admin-panel')->only('index', 'show', 'edit', 'export');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -17,9 +17,9 @@ class Taxes extends Controller
|
||||
public function __construct()
|
||||
{
|
||||
// Add CRUD permission check
|
||||
$this->middleware('permission:create-settings-taxes')->only(['create', 'store', 'duplicate', 'import']);
|
||||
$this->middleware('permission:read-settings-taxes')->only(['index', 'show', 'edit', 'export']);
|
||||
$this->middleware('permission:update-settings-taxes')->only(['update', 'enable', 'disable']);
|
||||
$this->middleware('permission:create-settings-taxes')->only('create', 'store', 'duplicate', 'import');
|
||||
$this->middleware('permission:read-settings-taxes')->only('index', 'show', 'edit', 'export');
|
||||
$this->middleware('permission:update-settings-taxes')->only('update', 'enable', 'disable');
|
||||
$this->middleware('permission:delete-settings-taxes')->only('destroy');
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user