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:
Cüneyt Şentürk
2020-08-28 19:24:26 +03:00
824 changed files with 14086 additions and 5612 deletions

View File

@ -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));
}

View File

@ -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,
]);
}
}

View File

@ -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'];

View File

@ -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'));
}

View File

@ -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;
}

View File

@ -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();

View File

@ -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;
}
/**