diff --git a/app/Abstracts/Http/Controller.php b/app/Abstracts/Http/Controller.php index f366929d5..d1f7dce54 100644 --- a/app/Abstracts/Http/Controller.php +++ b/app/Abstracts/Http/Controller.php @@ -2,6 +2,7 @@ namespace App\Abstracts\Http; +use App\Abstracts\Http\Response; use App\Traits\Jobs; use App\Traits\Relationships; use Illuminate\Database\Eloquent\Collection; @@ -99,4 +100,25 @@ abstract class Controller extends BaseController return new LengthAwarePaginator($items->forPage($page, $perPage), $items->count(), $perPage, $page, $options); } + + /** + * Generate a response based on request type like HTML, JSON, or anything else. + * + * @param string $view + * @param array $data + * + * @return \Illuminate\Http\Response + */ + public function response($view, $data = []) + { + $class_name = str_replace('Controllers', 'Responses', (new \ReflectionClass($this))->getName()); + + if (class_exists($class_name)) { + $response = new $class_name($view, $data); + } else { + $response = new class($view, $data) extends Response {}; + } + + return $response; + } } diff --git a/app/Abstracts/Http/Response.php b/app/Abstracts/Http/Response.php new file mode 100644 index 000000000..75a3dac50 --- /dev/null +++ b/app/Abstracts/Http/Response.php @@ -0,0 +1,55 @@ +view = $view; + $this->data = $data; + } + + public function toJson() + { + return response()->json([ + 'success' => true, + 'error' => false, + 'data' => Arr::first($this->data), + 'message' => '', + ]); + } + + public function toHtml() + { + return view($this->view, $this->data); + } + + public function toResponse($request) + { + foreach ($this->accepts as $accept) { + $request_method = 'expects' . Str::studly($accept); + $response_method = 'to' . Str::studly($accept); + + if (!method_exists($request, $request_method) || !method_exists($this, $response_method)) { + continue; + } + + if ($request->{$request_method}()) { + return $this->{$response_method}(); + } + } + + return $this->toHtml(); + } +} diff --git a/app/Abstracts/Model.php b/app/Abstracts/Model.php index f2fd309ea..460de969c 100644 --- a/app/Abstracts/Model.php +++ b/app/Abstracts/Model.php @@ -70,9 +70,16 @@ abstract class Model extends Eloquent $request = request(); $search = $request->get('search'); + + $query->usingSearchString($search)->sortable($sort); + + if ($request->expectsJson()) { + return $query->get(); + } + $limit = $request->get('limit', setting('default.list_limit', '25')); - return $query->usingSearchString($search)->sortable($sort)->paginate($limit); + return $query->paginate($limit); } /** diff --git a/app/Console/Stubs/Modules/component.stub b/app/Console/Stubs/Modules/component.stub new file mode 100644 index 000000000..916f91861 --- /dev/null +++ b/app/Console/Stubs/Modules/component.stub @@ -0,0 +1,28 @@ +response('$ALIAS$::index'); } /** * Show the form for creating a new resource. + * * @return Response */ public function create() @@ -29,6 +30,7 @@ class $CLASS$ extends Controller /** * Store a newly created resource in storage. + * * @param Request $request * @return Response */ @@ -39,6 +41,7 @@ class $CLASS$ extends Controller /** * Show the specified resource. + * * @param int $id * @return Response */ @@ -49,6 +52,7 @@ class $CLASS$ extends Controller /** * Show the form for editing the specified resource. + * * @param int $id * @return Response */ @@ -59,6 +63,7 @@ class $CLASS$ extends Controller /** * Update the specified resource in storage. + * * @param Request $request * @param int $id * @return Response @@ -70,6 +75,7 @@ class $CLASS$ extends Controller /** * Remove the specified resource from storage. + * * @param int $id * @return Response */ diff --git a/app/Console/Stubs/Modules/scaffold/provider.stub b/app/Console/Stubs/Modules/scaffold/provider.stub index 2e5fe8c62..d0b076d68 100644 --- a/app/Console/Stubs/Modules/scaffold/provider.stub +++ b/app/Console/Stubs/Modules/scaffold/provider.stub @@ -2,6 +2,7 @@ namespace $NAMESPACE$; +use Illuminate\Support\Facades\Blade; use Illuminate\Support\ServiceProvider as Provider; class $NAME$ extends Provider @@ -14,6 +15,7 @@ class $NAME$ extends Provider public function boot() { $this->loadViews(); + $this->loadViewComponents(); $this->loadTranslations(); $this->loadMigrations(); //$this->loadConfig(); @@ -39,6 +41,16 @@ class $NAME$ extends Provider $this->loadViewsFrom(__DIR__ . '/../Resources/views', '$ALIAS$'); } + /** + * Load view components. + * + * @return void + */ + public function loadViewComponents() + { + Blade::componentNamespace('$COMPONENT_NAMESPACE$', '$ALIAS$'); + } + /** * Load translations. * diff --git a/app/Http/Controllers/Auth/Permissions.php b/app/Http/Controllers/Auth/Permissions.php index 5fadd7f0a..555435dbb 100644 --- a/app/Http/Controllers/Auth/Permissions.php +++ b/app/Http/Controllers/Auth/Permissions.php @@ -20,7 +20,7 @@ class Permissions extends Controller { $permissions = Permission::collect(); - return view('auth.permissions.index', compact('permissions')); + return $this->response('auth.permissions.index', compact('permissions')); } /** diff --git a/app/Http/Controllers/Auth/Roles.php b/app/Http/Controllers/Auth/Roles.php index 53a74b561..ab4e042f5 100644 --- a/app/Http/Controllers/Auth/Roles.php +++ b/app/Http/Controllers/Auth/Roles.php @@ -21,7 +21,7 @@ class Roles extends Controller { $roles = Role::collect(); - return view('auth.roles.index', compact('roles')); + return $this->response('auth.roles.index', compact('roles')); } /** diff --git a/app/Http/Controllers/Auth/Users.php b/app/Http/Controllers/Auth/Users.php index c43aac6e7..6221d20b1 100644 --- a/app/Http/Controllers/Auth/Users.php +++ b/app/Http/Controllers/Auth/Users.php @@ -37,7 +37,7 @@ class Users extends Controller { $users = User::with('media', 'roles')->collect(); - return view('auth.users.index', compact('users')); + return $this->response('auth.users.index', compact('users')); } /** @@ -58,7 +58,7 @@ class Users extends Controller return $r->hasPermission('read-client-portal'); }); - $companies = user()->companies()->take(10)->get()->sortBy('name')->pluck('name', 'id'); + $companies = user()->companies()->take(setting('default.select_limit'))->get()->sortBy('name')->pluck('name', 'id'); return view('auth.users.create', compact('roles', 'companies', 'landing_pages')); } @@ -123,7 +123,7 @@ class Users extends Controller }); } - $companies = user()->companies()->take(10)->get()->sortBy('name')->pluck('name', 'id'); + $companies = user()->companies()->take(setting('default.select_limit'))->get()->sortBy('name')->pluck('name', 'id'); return view('auth.users.edit', compact('user', 'companies', 'roles', 'landing_pages')); } diff --git a/app/Http/Controllers/Banking/Accounts.php b/app/Http/Controllers/Banking/Accounts.php index 08e9f89e4..0683c4e59 100644 --- a/app/Http/Controllers/Banking/Accounts.php +++ b/app/Http/Controllers/Banking/Accounts.php @@ -21,7 +21,7 @@ class Accounts extends Controller { $accounts = Account::collect(); - return view('banking.accounts.index', compact('accounts')); + return $this->response('banking.accounts.index', compact('accounts')); } /** diff --git a/app/Http/Controllers/Banking/Reconciliations.php b/app/Http/Controllers/Banking/Reconciliations.php index a904a8380..ab9ec5f38 100644 --- a/app/Http/Controllers/Banking/Reconciliations.php +++ b/app/Http/Controllers/Banking/Reconciliations.php @@ -26,7 +26,7 @@ class Reconciliations extends Controller $accounts = collect(Account::enabled()->orderBy('name')->pluck('name', 'id')); - return view('banking.reconciliations.index', compact('reconciliations', 'accounts')); + return $this->response('banking.reconciliations.index', compact('reconciliations', 'accounts')); } /** diff --git a/app/Http/Controllers/Banking/Transactions.php b/app/Http/Controllers/Banking/Transactions.php index 7cfeded9c..0daceef6a 100644 --- a/app/Http/Controllers/Banking/Transactions.php +++ b/app/Http/Controllers/Banking/Transactions.php @@ -22,7 +22,7 @@ class Transactions extends Controller { $accounts = Account::enabled()->orderBy('name')->pluck('name', 'id'); - $types = collect(['expense' => 'Expense', 'income' => 'Income']) + $types = collect(['expense' => trans_choice('general.expenses', 1), 'income' => trans_choice('general.incomes', 1)]) ->prepend(trans('general.all_type', ['type' => trans_choice('general.types', 2)]), ''); $request_type = !request()->has('type') ? ['income', 'expense'] : request('type'); @@ -30,7 +30,7 @@ class Transactions extends Controller $transactions = Transaction::with('account', 'category', 'contact')->collect(['paid_at'=> 'desc']); - return view('banking.transactions.index', compact('transactions', 'accounts', 'types', 'categories')); + return $this->response('banking.transactions.index', compact('transactions', 'accounts', 'types', 'categories')); } /** diff --git a/app/Http/Controllers/Banking/Transfers.php b/app/Http/Controllers/Banking/Transfers.php index 64e7b7a71..b9febd0fd 100644 --- a/app/Http/Controllers/Banking/Transfers.php +++ b/app/Http/Controllers/Banking/Transfers.php @@ -52,10 +52,10 @@ class Transfers extends Controller ]; } - $special_key = array( + $special_key = [ 'expense_transaction.name' => 'from_account', 'income_transaction.name' => 'to_account', - ); + ]; $request = request(); @@ -77,12 +77,12 @@ class Transfers extends Controller array_multisort($sort_order, $sort_type, $data); } - $transfers = $this->paginate($data); + $transfers = $request->expectsJson() ? $data : $this->paginate($data); $accounts = collect(Account::enabled()->orderBy('name')->pluck('name', 'id')) ->prepend(trans('general.all_type', ['type' => trans_choice('general.accounts', 2)]), ''); - return view('banking.transfers.index', compact('transfers', 'accounts')); + return $this->response('banking.transfers.index', compact('transfers', 'accounts')); } /** diff --git a/app/Http/Controllers/Common/BulkActions.php b/app/Http/Controllers/Common/BulkActions.php index e84694553..ef43531a8 100644 --- a/app/Http/Controllers/Common/BulkActions.php +++ b/app/Http/Controllers/Common/BulkActions.php @@ -6,9 +6,7 @@ use App\Abstracts\Http\Controller; use App\Http\Requests\Common\BulkAction as Request; use Illuminate\Support\Str; -class - -BulkActions extends Controller +class BulkActions extends Controller { /** diff --git a/app/Http/Controllers/Common/Companies.php b/app/Http/Controllers/Common/Companies.php index 2cd575a18..3876b7574 100644 --- a/app/Http/Controllers/Common/Companies.php +++ b/app/Http/Controllers/Common/Companies.php @@ -26,7 +26,7 @@ class Companies extends Controller { $companies = Company::collect(); - return view('common.companies.index', compact('companies')); + return $this->response('common.companies.index', compact('companies')); } /** diff --git a/app/Http/Controllers/Common/Dashboards.php b/app/Http/Controllers/Common/Dashboards.php index 633e87057..40bff6827 100644 --- a/app/Http/Controllers/Common/Dashboards.php +++ b/app/Http/Controllers/Common/Dashboards.php @@ -40,7 +40,7 @@ class Dashboards extends Controller { $dashboards = user()->dashboards()->collect(); - return view('common.dashboards.index', compact('dashboards')); + return $this->response('common.dashboards.index', compact('dashboards')); } /** diff --git a/app/Http/Controllers/Common/Items.php b/app/Http/Controllers/Common/Items.php index 58214e3ea..7c03a71eb 100644 --- a/app/Http/Controllers/Common/Items.php +++ b/app/Http/Controllers/Common/Items.php @@ -30,7 +30,7 @@ class Items extends Controller { $items = Item::with('category', 'media')->collect(); - return view('common.items.index', compact('items')); + return $this->response('common.items.index', compact('items')); } /** @@ -50,7 +50,7 @@ class Items extends Controller */ public function create() { - $categories = Category::item()->enabled()->orderBy('name')->pluck('name', 'id'); + $categories = Category::item()->enabled()->orderBy('name')->take(setting('default.select_limit'))->pluck('name', 'id'); $taxes = Tax::enabled()->orderBy('name')->get()->pluck('title', 'id'); @@ -129,7 +129,7 @@ class Items extends Controller */ public function edit(Item $item) { - $categories = Category::item()->enabled()->orderBy('name')->pluck('name', 'id'); + $categories = Category::item()->enabled()->orderBy('name')->take(setting('default.select_limit'))->pluck('name', 'id'); $taxes = Tax::enabled()->orderBy('name')->get()->pluck('title', 'id'); diff --git a/app/Http/Controllers/Common/Reports.php b/app/Http/Controllers/Common/Reports.php index 93a5fcbf5..d846e96a8 100644 --- a/app/Http/Controllers/Common/Reports.php +++ b/app/Http/Controllers/Common/Reports.php @@ -45,7 +45,7 @@ class Reports extends Controller $categories[$class->getCategory()][] = $report; } - return view('common.reports.index', compact('categories', 'totals', 'icons')); + return $this->response('common.reports.index', compact('categories', 'totals', 'icons')); } /** diff --git a/app/Http/Controllers/Modals/Items.php b/app/Http/Controllers/Modals/Items.php index 0c5f50f46..23cac8104 100644 --- a/app/Http/Controllers/Modals/Items.php +++ b/app/Http/Controllers/Modals/Items.php @@ -30,7 +30,7 @@ class Items extends Controller */ public function create(IRequest $request) { - $categories = Category::item()->enabled()->orderBy('name')->pluck('name', 'id'); + $categories = Category::item()->enabled()->orderBy('name')->take(setting('default.select_limit'))->pluck('name', 'id'); $taxes = Tax::enabled()->orderBy('name')->get()->pluck('title', 'id'); diff --git a/app/Http/Controllers/Modules/Home.php b/app/Http/Controllers/Modules/Home.php index 4465cf47f..358f0c4ca 100644 --- a/app/Http/Controllers/Modules/Home.php +++ b/app/Http/Controllers/Modules/Home.php @@ -29,6 +29,6 @@ class Home extends Controller $free = $this->getFreeModules($data); $installed = Module::all()->pluck('enabled', 'alias')->toArray(); - return view('modules.home.index', compact('pre_sale', 'paid', 'new', 'free', 'installed')); + return $this->response('modules.home.index', compact('pre_sale', 'paid', 'new', 'free', 'installed')); } } diff --git a/app/Http/Controllers/Modules/My.php b/app/Http/Controllers/Modules/My.php index cf043fb6b..ded71f548 100644 --- a/app/Http/Controllers/Modules/My.php +++ b/app/Http/Controllers/Modules/My.php @@ -21,6 +21,6 @@ class My extends Controller $modules = $this->getInstalledModules(); $installed = Module::where('company_id', '=', session('company_id'))->pluck('enabled', 'alias')->toArray(); - return view('modules.my.index', compact('purchased', 'modules', 'installed')); + return $this->response('modules.my.index', compact('purchased', 'modules', 'installed')); } } diff --git a/app/Http/Controllers/Portal/Invoices.php b/app/Http/Controllers/Portal/Invoices.php index dc10e2a0f..e25e8c862 100644 --- a/app/Http/Controllers/Portal/Invoices.php +++ b/app/Http/Controllers/Portal/Invoices.php @@ -32,7 +32,7 @@ class Invoices extends Controller $statuses = $this->getInvoiceStatuses(); - return view('portal.invoices.index', compact('invoices', 'categories', 'statuses')); + return $this->response('portal.invoices.index', compact('invoices', 'categories', 'statuses')); } /** diff --git a/app/Http/Controllers/Portal/Payments.php b/app/Http/Controllers/Portal/Payments.php index 5357a2e74..82eefc662 100644 --- a/app/Http/Controllers/Portal/Payments.php +++ b/app/Http/Controllers/Portal/Payments.php @@ -20,7 +20,7 @@ class Payments extends Controller $payment_methods = Modules::getPaymentMethods('all'); - return view('portal.payments.index', compact('payments', 'payment_methods')); + return $this->response('portal.payments.index', compact('payments', 'payment_methods')); } /** diff --git a/app/Http/Controllers/Purchases/Bills.php b/app/Http/Controllers/Purchases/Bills.php index 0f2f8120b..4fef9896c 100644 --- a/app/Http/Controllers/Purchases/Bills.php +++ b/app/Http/Controllers/Purchases/Bills.php @@ -39,13 +39,7 @@ class Bills extends Controller { $bills = Bill::with('contact', 'transactions')->collect(['billed_at'=> 'desc']); - $vendors = Contact::vendor()->enabled()->orderBy('name')->pluck('name', 'id'); - - $categories = Category::expense()->enabled()->orderBy('name')->pluck('name', 'id'); - - $statuses = $this->getBillStatuses(); - - return view('purchases.bills.index', compact('bills', 'vendors', 'categories', 'statuses')); + return $this->response('purchases.bills.index', compact('bills')); } /** @@ -96,7 +90,7 @@ class Bills extends Controller */ public function create() { - $vendors = Contact::vendor()->enabled()->orderBy('name')->pluck('name', 'id'); + $vendors = Contact::vendor()->enabled()->orderBy('name')->take(setting('default.select_limit'))->pluck('name', 'id'); $currencies = Currency::enabled()->orderBy('name')->pluck('name', 'code')->toArray(); @@ -106,7 +100,7 @@ class Bills extends Controller $taxes = Tax::enabled()->orderBy('name')->get(); - $categories = Category::expense()->enabled()->orderBy('name')->pluck('name', 'id'); + $categories = Category::expense()->enabled()->orderBy('name')->take(setting('default.select_limit'))->pluck('name', 'id'); $number = $this->getNextBillNumber(); @@ -192,7 +186,7 @@ class Bills extends Controller */ public function edit(Bill $bill) { - $vendors = Contact::vendor()->enabled()->orderBy('name')->pluck('name', 'id'); + $vendors = Contact::vendor()->enabled()->orderBy('name')->take(setting('default.select_limit'))->pluck('name', 'id'); $currencies = Currency::enabled()->orderBy('name')->pluck('name', 'code')->toArray(); @@ -202,7 +196,7 @@ class Bills extends Controller $taxes = Tax::enabled()->orderBy('name')->get(); - $categories = Category::expense()->enabled()->orderBy('name')->pluck('name', 'id'); + $categories = Category::expense()->enabled()->orderBy('name')->take(setting('default.select_limit'))->pluck('name', 'id'); return view('purchases.bills.edit', compact('bill', 'vendors', 'currencies', 'currency', 'items', 'taxes', 'categories')); } diff --git a/app/Http/Controllers/Purchases/Payments.php b/app/Http/Controllers/Purchases/Payments.php index e49d77f85..83b10c9e8 100644 --- a/app/Http/Controllers/Purchases/Payments.php +++ b/app/Http/Controllers/Purchases/Payments.php @@ -32,13 +32,7 @@ class Payments extends Controller { $payments = Transaction::with('account', 'bill', 'category', 'contact')->expense()->isNotTransfer()->collect(['paid_at'=> 'desc']); - $vendors = Contact::vendor()->enabled()->orderBy('name')->pluck('name', 'id'); - - $categories = Category::expense()->enabled()->orderBy('name')->pluck('name', 'id'); - - $accounts = Account::enabled()->orderBy('name')->pluck('name', 'id'); - - return view('purchases.payments.index', compact('payments', 'vendors', 'categories', 'accounts')); + return $this->response('purchases.payments.index', compact('payments')); } /** @@ -66,9 +60,9 @@ class Payments extends Controller $currency = Currency::where('code', $account_currency_code)->first(); - $vendors = Contact::vendor()->enabled()->orderBy('name')->pluck('name', 'id'); + $vendors = Contact::vendor()->enabled()->orderBy('name')->take(setting('default.select_limit'))->pluck('name', 'id'); - $categories = Category::expense()->enabled()->orderBy('name')->pluck('name', 'id'); + $categories = Category::expense()->enabled()->orderBy('name')->take(setting('default.select_limit'))->pluck('name', 'id'); $payment_methods = Modules::getPaymentMethods(); @@ -154,9 +148,9 @@ class Payments extends Controller $currency = Currency::where('code', $payment->currency_code)->first(); - $vendors = Contact::vendor()->enabled()->orderBy('name')->pluck('name', 'id'); + $vendors = Contact::vendor()->enabled()->orderBy('name')->take(setting('default.select_limit'))->pluck('name', 'id'); - $categories = Category::expense()->enabled()->orderBy('name')->pluck('name', 'id'); + $categories = Category::expense()->enabled()->orderBy('name')->take(setting('default.select_limit'))->pluck('name', 'id'); $payment_methods = Modules::getPaymentMethods(); diff --git a/app/Http/Controllers/Purchases/Vendors.php b/app/Http/Controllers/Purchases/Vendors.php index 39aaf9df4..766c315ce 100644 --- a/app/Http/Controllers/Purchases/Vendors.php +++ b/app/Http/Controllers/Purchases/Vendors.php @@ -30,7 +30,7 @@ class Vendors extends Controller { $vendors = Contact::with('bills.transactions')->vendor()->collect(); - return view('purchases.vendors.index', compact('vendors')); + return $this->response('purchases.vendors.index', compact('vendors')); } /** diff --git a/app/Http/Controllers/Sales/Customers.php b/app/Http/Controllers/Sales/Customers.php index af77ce983..179ac68e1 100644 --- a/app/Http/Controllers/Sales/Customers.php +++ b/app/Http/Controllers/Sales/Customers.php @@ -28,7 +28,7 @@ class Customers extends Controller { $customers = Contact::with('invoices.transactions')->customer()->collect(); - return view('sales.customers.index', compact('customers')); + return $this->response('sales.customers.index', compact('customers')); } /** diff --git a/app/Http/Controllers/Sales/Invoices.php b/app/Http/Controllers/Sales/Invoices.php index 059f3e16e..252759165 100644 --- a/app/Http/Controllers/Sales/Invoices.php +++ b/app/Http/Controllers/Sales/Invoices.php @@ -40,13 +40,7 @@ class Invoices extends Controller { $invoices = Invoice::with('contact', 'transactions')->collect(['invoice_number'=> 'desc']); - $customers = Contact::customer()->enabled()->orderBy('name')->pluck('name', 'id'); - - $categories = Category::income()->enabled()->orderBy('name')->pluck('name', 'id'); - - $statuses = $this->getInvoiceStatuses(); - - return view('sales.invoices.index', compact('invoices', 'customers', 'categories', 'statuses')); + return $this->response('sales.invoices.index', compact('invoices')); } /** @@ -99,7 +93,7 @@ class Invoices extends Controller */ public function create() { - $customers = Contact::customer()->enabled()->orderBy('name')->pluck('name', 'id'); + $customers = Contact::customer()->enabled()->orderBy('name')->take(setting('default.select_limit'))->pluck('name', 'id'); $currencies = Currency::enabled()->orderBy('name')->pluck('name', 'code')->toArray(); @@ -109,7 +103,7 @@ class Invoices extends Controller $taxes = Tax::enabled()->orderBy('name')->get(); - $categories = Category::income()->enabled()->orderBy('name')->pluck('name', 'id'); + $categories = Category::income()->enabled()->orderBy('name')->take(setting('default.select_limit'))->pluck('name', 'id'); $number = $this->getNextInvoiceNumber(); @@ -195,7 +189,7 @@ class Invoices extends Controller */ public function edit(Invoice $invoice) { - $customers = Contact::customer()->enabled()->orderBy('name')->pluck('name', 'id'); + $customers = Contact::customer()->enabled()->orderBy('name')->take(setting('default.select_limit'))->pluck('name', 'id'); $currencies = Currency::enabled()->orderBy('name')->pluck('name', 'code')->toArray(); @@ -205,7 +199,7 @@ class Invoices extends Controller $taxes = Tax::enabled()->orderBy('name')->get(); - $categories = Category::income()->enabled()->orderBy('name')->pluck('name', 'id'); + $categories = Category::income()->enabled()->orderBy('name')->take(setting('default.select_limit'))->pluck('name', 'id'); return view('sales.invoices.edit', compact('invoice', 'customers', 'currencies', 'currency', 'items', 'taxes', 'categories')); } diff --git a/app/Http/Controllers/Sales/Revenues.php b/app/Http/Controllers/Sales/Revenues.php index 14212e8f2..d13d54a9d 100644 --- a/app/Http/Controllers/Sales/Revenues.php +++ b/app/Http/Controllers/Sales/Revenues.php @@ -32,13 +32,7 @@ class Revenues extends Controller { $revenues = Transaction::with('account', 'category', 'contact', 'invoice')->income()->isNotTransfer()->collect(['paid_at'=> 'desc']); - $customers = Contact::customer()->enabled()->orderBy('name')->pluck('name', 'id'); - - $categories = Category::income()->enabled()->orderBy('name')->pluck('name', 'id'); - - $accounts = Account::enabled()->orderBy('name')->pluck('name', 'id'); - - return view('sales.revenues.index', compact('revenues', 'customers', 'categories', 'accounts')); + return $this->response('sales.revenues.index', compact('revenues')); } /** @@ -66,9 +60,9 @@ class Revenues extends Controller $currency = Currency::where('code', $account_currency_code)->first(); - $customers = Contact::customer()->enabled()->orderBy('name')->pluck('name', 'id'); + $customers = Contact::customer()->enabled()->orderBy('name')->take(setting('default.select_limit'))->pluck('name', 'id'); - $categories = Category::income()->enabled()->orderBy('name')->pluck('name', 'id'); + $categories = Category::income()->enabled()->orderBy('name')->take(setting('default.select_limit'))->pluck('name', 'id'); $payment_methods = Modules::getPaymentMethods(); @@ -154,9 +148,9 @@ class Revenues extends Controller $currency = Currency::where('code', $revenue->currency_code)->first(); - $customers = Contact::customer()->enabled()->orderBy('name')->pluck('name', 'id'); + $customers = Contact::customer()->enabled()->orderBy('name')->take(setting('default.select_limit'))->pluck('name', 'id'); - $categories = Category::income()->enabled()->orderBy('name')->pluck('name', 'id'); + $categories = Category::income()->enabled()->orderBy('name')->take(setting('default.select_limit'))->pluck('name', 'id'); $payment_methods = Modules::getPaymentMethods(); diff --git a/app/Http/Controllers/Settings/Categories.php b/app/Http/Controllers/Settings/Categories.php index 9a37b0298..b37a1132c 100644 --- a/app/Http/Controllers/Settings/Categories.php +++ b/app/Http/Controllers/Settings/Categories.php @@ -30,7 +30,7 @@ class Categories extends Controller 'other' => trans_choice('general.others', 1), ]); - return view('settings.categories.index', compact('categories', 'types', 'transfer_id')); + return $this->response('settings.categories.index', compact('categories', 'types', 'transfer_id')); } /** diff --git a/app/Http/Controllers/Settings/Currencies.php b/app/Http/Controllers/Settings/Currencies.php index 080d11e3f..de310271e 100644 --- a/app/Http/Controllers/Settings/Currencies.php +++ b/app/Http/Controllers/Settings/Currencies.php @@ -21,7 +21,7 @@ class Currencies extends Controller { $currencies = Currency::collect(); - return view('settings.currencies.index', compact('currencies')); + return $this->response('settings.currencies.index', compact('currencies')); } /** diff --git a/app/Http/Controllers/Settings/Defaults.php b/app/Http/Controllers/Settings/Defaults.php index 6be3afb9e..ea1fd0f65 100644 --- a/app/Http/Controllers/Settings/Defaults.php +++ b/app/Http/Controllers/Settings/Defaults.php @@ -4,6 +4,7 @@ namespace App\Http\Controllers\Settings; use App\Abstracts\Http\Controller; use App\Models\Banking\Account; +use App\Models\Setting\Category; use App\Models\Setting\Currency; use App\Models\Setting\Tax; use App\Utilities\Modules; @@ -16,6 +17,9 @@ class Defaults extends Controller $currencies = Currency::enabled()->orderBy('name')->pluck('name', 'code'); + $sales_categories = Category::income()->enabled()->orderBy('name')->take(setting('default.select_limit'))->pluck('name', 'id'); + $purchases_categories = Category::expense()->enabled()->orderBy('name')->take(setting('default.select_limit'))->pluck('name', 'id'); + $taxes = Tax::enabled()->orderBy('name')->get()->pluck('title', 'id'); $payment_methods = Modules::getPaymentMethods(); @@ -23,6 +27,8 @@ class Defaults extends Controller return view('settings.default.edit', compact( 'accounts', 'currencies', + 'sales_categories', + 'purchases_categories', 'taxes', 'payment_methods' )); diff --git a/app/Http/Controllers/Settings/Settings.php b/app/Http/Controllers/Settings/Settings.php index 75b4e6c5e..90364505e 100644 --- a/app/Http/Controllers/Settings/Settings.php +++ b/app/Http/Controllers/Settings/Settings.php @@ -63,7 +63,7 @@ class Settings extends Controller $settings[$alias] = $setting; } - return view('settings.settings.index', ['modules' => $settings]); + return $this->response('settings.settings.index', ['modules' => $settings]); } /** diff --git a/app/Http/Controllers/Settings/Taxes.php b/app/Http/Controllers/Settings/Taxes.php index d7b75c974..500e32587 100644 --- a/app/Http/Controllers/Settings/Taxes.php +++ b/app/Http/Controllers/Settings/Taxes.php @@ -29,7 +29,7 @@ class Taxes extends Controller 'compound' => trans('taxes.compound'), ]; - return view('settings.taxes.index', compact('taxes', 'types')); + return $this->response('settings.taxes.index', compact('taxes', 'types')); } /** diff --git a/app/Http/Responses/Common/Items.php b/app/Http/Responses/Common/Items.php new file mode 100644 index 000000000..6437e644b --- /dev/null +++ b/app/Http/Responses/Common/Items.php @@ -0,0 +1,10 @@ +updateCompanies(); + Artisan::call('migrate', ['--force' => true]); } + protected function updateCompanies() + { + $company_id = session('company_id'); + + $companies = Company::cursor(); + + foreach ($companies as $company) { + session(['company_id' => $company->id]); + + $this->updateSettings($company); + } + + setting()->forgetAll(); + + session(['company_id' => $company_id]); + + Overrider::load('settings'); + } + + public function updateSettings($company) + { + $income_category = Category::income()->enabled()->first(); + $expense_category = Category::expense()->enabled()->first(); + + // Set the active company settings + setting()->setExtraColumns(['company_id' => $company->id]); + setting()->forgetAll(); + setting()->load(true); + + setting()->set(['default.income_category' => setting('default.income_category', $income_category->id)]); + setting()->set(['default.expense_category' => setting('default.expense_category', $expense_category->id)]); + + setting()->save(); + } } diff --git a/app/Models/Common/Company.php b/app/Models/Common/Company.php index e8cff5716..b4c061d20 100644 --- a/app/Models/Common/Company.php +++ b/app/Models/Common/Company.php @@ -275,9 +275,16 @@ class Company extends Eloquent $request = request(); $search = $request->get('search'); + + $query = user()->companies()->usingSearchString($search)->sortable($sort); + + if ($request->expectsJson()) { + return $query->get(); + } + $limit = $request->get('limit', setting('default.list_limit', '25')); - return user()->companies()->usingSearchString($search)->sortable($sort)->paginate($limit); + return $query->paginate($limit); } /** diff --git a/app/Models/Purchase/BillTotal.php b/app/Models/Purchase/BillTotal.php index de6a531f5..1ee33301a 100644 --- a/app/Models/Purchase/BillTotal.php +++ b/app/Models/Purchase/BillTotal.php @@ -31,6 +31,11 @@ class BillTotal extends Model return $this->belongsTo('App\Models\Purchase\Bill'); } + public function scopeCode($query, $code) + { + return $query->where('code', '=', $code); + } + /** * Convert amount to double. * diff --git a/app/Models/Sale/InvoiceTotal.php b/app/Models/Sale/InvoiceTotal.php index c04fa59c1..d619506cc 100644 --- a/app/Models/Sale/InvoiceTotal.php +++ b/app/Models/Sale/InvoiceTotal.php @@ -31,6 +31,11 @@ class InvoiceTotal extends Model return $this->belongsTo('App\Models\Sale\Invoice'); } + public function scopeCode($query, $code) + { + return $query->where('code', '=', $code); + } + /** * Convert amount to double. * diff --git a/app/Providers/Form.php b/app/Providers/Form.php index 69395ae74..24d19c34b 100644 --- a/app/Providers/Form.php +++ b/app/Providers/Form.php @@ -59,6 +59,10 @@ class Form extends Provider 'name', 'text', 'icon', 'values', 'selected' => null, 'attributes' => ['required' => 'required'], 'col' => 'col-md-6', 'group_class' => null ]); + Facade::component('multiSelectRemoteAddNewGroup', 'partials.form.multi_select_remote_add_new_group', [ + 'name', 'text', 'icon', 'values', 'selected' => null, 'attributes' => ['required' => 'required', 'path' => ''], 'col' => 'col-md-6', 'group_class' => null + ]); + Facade::component('selectGroup', 'partials.form.select_group', [ 'name', 'text', 'icon', 'values', 'selected' => null, 'attributes' => ['required' => 'required'], 'col' => 'col-md-6', 'group_class' => null ]); @@ -79,6 +83,10 @@ class Form extends Provider 'name', 'text', 'icon', 'values', 'selected' => null, 'attributes' => ['required' => 'required'], 'col' => 'col-md-6', 'group_class' => null ]); + Facade::component('selectRemoteAddNewGroup', 'partials.form.select_remote_add_new_group', [ + 'name', 'text', 'icon', 'values', 'selected' => null, 'attributes' => ['required' => 'required', 'path' => ''], 'col' => 'col-md-6', 'group_class' => null + ]); + Facade::component('textareaGroup', 'partials.form.textarea_group', [ 'name', 'text', 'icon', 'value' => null, 'attributes' => ['rows' => '3'], 'col' => 'col-md-12', 'group_class' => null ]); diff --git a/app/View/Components/SearchString.php b/app/View/Components/SearchString.php new file mode 100644 index 000000000..d7f615cad --- /dev/null +++ b/app/View/Components/SearchString.php @@ -0,0 +1,196 @@ +model = $model; + } + + /** + * Get the view / contents that represent the component. + * + * @return \Illuminate\Contracts\View\View|string + */ + public function render() + { + $searc_string = config('search-string'); + + $this->filters = []; + + if (!empty($searc_string[$this->model])) { + $columns = $searc_string[$this->model]['columns']; + + foreach ($columns as $column => $options) { + // This column skip for filter + if (!empty($options['searchable'])) { + continue; + } + + if (!is_array($options)) { + $column = $options; + } + + if (!$this->isFilter($column, $options)) { + continue; + } + + $this->filters[] = [ + 'key' => $this->getFilterKey($column, $options), + 'value' => $this->getFilterName($column), + 'type' => $this->getFilterType($options), + 'url' => $this->getFilterUrl($column, $options), + 'values' => $this->getFilterValues($column, $options), + ]; + } + } + + return view('components.search-string'); + } + + protected function isFilter($column, $options) + { + $filter = true; + + if (empty($this->getFilterUrl($column, $options)) && (!isset($options['date']) && !isset($options['boolean']))) { + $filter = false; + } + + return $filter; + } + + protected function getFilterKey($column, $options) + { + if (isset($options['relationship'])) { + $column .= '.id'; + } + + return $column; + } + + protected function getFilterName($column) + { + if (strpos($column, '_id') !== false) { + $column = str_replace('_id', '', $column); + } else if (strpos($column, '_code') !== false) { + $column = str_replace('_code', '', $column); + } + + $plural = Str::plural($column, 2); + + if (trans_choice('general.' . $plural, 1) !== 'general.' . $plural) { + return trans_choice('general.' . $plural, 1); + } elseif (trans_choice('search_string.columns.' . $plural, 1) !== 'search_string.columns.' . $plural) { + return trans_choice('search_string.columns.' . $plural, 1); + } + + $name = trans('general.' . $column); + + if ($name == 'general.' . $column) { + $name = trans('search_string.columns.' . $column); + } + + return $name; + } + + protected function getFilterType($options) + { + $type = 'select'; + + if (isset($options['boolean'])) { + $type = 'boolean'; + } + + if (isset($options['date'])) { + $type = 'date'; + } + + return $type; + } + + protected function getFilterUrl($column, $options) + { + $url = ''; + + if (isset($options['boolean']) || isset($options['date'])) { + return $url; + } + + if (!empty($options['route'])) { + if (is_array($options['route'])) { + $url = route($options['route'][0], $options['route'][1]); + } else { + $url = route($options['route']); + } + } else { + if (strpos($this->model, 'Modules') !== false) { + $module_class = explode('\\', $this->model); + + $url .= Str::slug($module_class[1], '-') . '::'; + } + + if (strpos($column, '_id') !== false) { + $column = str_replace('_id', '', $column); + } + + $plural = Str::plural($column, 2); + + try { + $url = route($url . $plural . '.index'); + } catch (\Exception $e) { + $url = ''; + } + } + + return $url; + } + + protected function getFilterValues($column, $options) + { + $values = []; + + if (isset($options['boolean'])) { + $values = [ + [ + 'key' => 0, + 'value' => trans('general.no'), + ], + [ + 'key' => 1, + 'value' => trans('general.yes'), + ], + ]; + } else if ($search = request()->get('search', false)) { + $fields = explode(' ', $search); + + foreach ($fields as $field) { + if (strpos($field, ':') === false) { + continue; + } + + $filters = explode(':', $field); + + if ($filters[0] != $column) { + continue; + } + } + } + + return $values; + } +} diff --git a/config/module.php b/config/module.php index 28ca352c9..ba4a9338a 100644 --- a/config/module.php +++ b/config/module.php @@ -111,7 +111,7 @@ return [ 'resource' => ['path' => 'Http/Resources', 'generate' => false], 'asset' => ['path' => 'Resources/assets', 'generate' => false], 'lang' => ['path' => 'Resources/lang/en-GB', 'generate' => true], - 'views' => ['path' => 'Resources/views', 'generate' => true], + 'view' => ['path' => 'Resources/views', 'generate' => true], 'test' => ['path' => 'Tests', 'generate' => false], 'repository' => ['path' => 'Repositories', 'generate' => false], 'event' => ['path' => 'Events', 'generate' => false], @@ -122,6 +122,7 @@ return [ 'email' => ['path' => 'Emails', 'generate' => false], 'notification' => ['path' => 'Notifications', 'generate' => false], 'route' => ['path' => 'Routes', 'generate' => true], + 'component' => ['path' => 'View/Components', 'generate' => false], ], ], diff --git a/config/search-string.php b/config/search-string.php index 355e1a988..c8895694f 100644 --- a/config/search-string.php +++ b/config/search-string.php @@ -69,7 +69,9 @@ return [ 'number' => ['searchable' => true], 'bank_name' => ['searchable' => true], 'bank_address' => ['searchable' => true], - 'currency' => ['relationship' => true], + 'currency_code' => [ + 'route' => 'currencies.index' + ], 'enabled' => ['boolean' => true], ], ], @@ -87,16 +89,24 @@ return [ App\Models\Banking\Transaction::class => [ 'columns' => [ 'type', - 'account_id', + 'account_id' => [ + 'route' => 'accounts.index' + ], 'paid_at' => ['date' => true], 'amount', - 'currency_code', + 'currency_code' => [ + 'route' => 'currencies.index' + ], 'document_id', - 'contact_id', + 'contact_id' => [ + 'route' => 'customers.index' + ], 'description' => ['searchable' => true], 'payment_method', 'reference', - 'category_id', + 'category_id' => [ + 'route' => 'categories.index' + ], 'parent_id', ], ], @@ -120,8 +130,10 @@ return [ 'name' => ['searchable' => true], 'description' => ['searchable' => true], 'enabled' => ['boolean' => true], - 'category_id' => ['key' => 'category_id'], - 'sale_price', + 'category_id' => [ + 'route' => ['categories.index', 'search=type:item'] + ], + 'sales_price', 'purchase_price', ], ], @@ -135,7 +147,9 @@ return [ 'phone' => ['searchable' => true], 'address' => ['searchable' => true], 'website' => ['searchable' => true], - 'currency_code', + 'currency_code' => [ + 'route' => 'currencies.index' + ], 'reference', 'user_id', 'enabled' => ['boolean' => true], @@ -150,14 +164,20 @@ return [ 'billed_at' => ['date' => true], 'due_at' => ['date' => true], 'amount', - 'currency_code', - 'contact_id', + 'currency_code' => [ + 'route' => 'currencies.index' + ], + 'contact_id' => [ + 'route' => 'vendors.index' + ], 'contact_name' => ['searchable' => true], 'contact_email' => ['searchable' => true], 'contact_tax_number', 'contact_phone' => ['searchable' => true], 'contact_address' => ['searchable' => true], - 'category_id', + 'category_id' => [ + 'route' => 'categories.index' + ], 'parent_id', ], ], @@ -170,14 +190,20 @@ return [ 'invoiced_at' => ['date' => true], 'due_at' => ['date' => true], 'amount', - 'currency_code', - 'contact_id', + 'currency_code' => [ + 'route' => 'currencies.index' + ], + 'contact_id' => [ + 'route' => 'customer.index' + ], 'contact_name' => ['searchable' => true], 'contact_email' => ['searchable' => true], 'contact_tax_number', 'contact_phone' => ['searchable' => true], 'contact_address' => ['searchable' => true], - 'category_id', + 'category_id' => [ + 'route' => 'categories.index' + ], 'parent_id', ], ], diff --git a/config/setting.php b/config/setting.php index 8f0ce3c14..eb59a6b44 100644 --- a/config/setting.php +++ b/config/setting.php @@ -120,6 +120,7 @@ return [ 'locale' => env('SETTING_FALLBACK_DEFAULT_LOCALE', 'en-GB'), 'list_limit' => env('SETTING_FALLBACK_DEFAULT_LIST_LIMIT', '25'), 'payment_method' => env('SETTING_FALLBACK_DEFAULT_PAYMENT_METHOD', 'offline-payments.cash.1'), + 'select_limit' => env('SETTING_FALLBACK_DEFAULT_SELECT_LIMIT', '10'), ], 'email' => [ 'protocol' => env('SETTING_FALLBACK_EMAIL_PROTOCOL', 'mail'), diff --git a/database/seeds/Categories.php b/database/seeds/Categories.php index c74833575..a46874f73 100644 --- a/database/seeds/Categories.php +++ b/database/seeds/Categories.php @@ -64,8 +64,26 @@ class Categories extends Seeder ], ]; + $income_category = $expense_category = false; + foreach ($rows as $row) { - Category::create($row); + $category = Category::create($row); + + switch ($category->type) { + case 'income': + if (empty($income_category)) { + $income_category = $category; + } + break; + case 'expense': + if (empty($expense_category)) { + $expense_category = $category; + } + break; + } } + + setting()->set('default.income_category', $income_category->id); + setting()->set('default.expense_category', $expense_category->id); } } diff --git a/public/css/custom.css b/public/css/custom.css index daf4d6f16..6421a2500 100644 --- a/public/css/custom.css +++ b/public/css/custom.css @@ -846,3 +846,9 @@ table .align-items-center td span.badge { border: 1px solid #3c3f72; } /*--lightbox Finish--*/ + +/*-- Search string & BulkAction Start --*/ +#app > .card > .card-header { + min-height: 88px; +} +/*-- Search string & BulkAction Finish --*/ \ No newline at end of file diff --git a/public/vendor/js-cookie/js.cookie.js b/public/vendor/js-cookie/js.cookie.js index 9a0945ed8..98f13c735 100644 --- a/public/vendor/js-cookie/js.cookie.js +++ b/public/vendor/js-cookie/js.cookie.js @@ -7,19 +7,26 @@ */ ;(function (factory) { var registeredInModuleLoader = false; + if (typeof define === 'function' && define.amd) { define(factory); + registeredInModuleLoader = true; } + if (typeof exports === 'object') { module.exports = factory(); + registeredInModuleLoader = true; } + if (!registeredInModuleLoader) { var OldCookies = window.Cookies; var api = window.Cookies = factory(); + api.noConflict = function () { window.Cookies = OldCookies; + return api; }; } @@ -27,24 +34,27 @@ function extend () { var i = 0; var result = {}; + for (; i < arguments.length; i++) { var attributes = arguments[ i ]; + for (var key in attributes) { result[key] = attributes[key]; } } + return result; } function init (converter) { function api (key, value, attributes) { var result; + if (typeof document === 'undefined') { return; } // Write - if (arguments.length > 1) { attributes = extend({ path: '/' @@ -52,7 +62,9 @@ if (typeof attributes.expires === 'number') { var expires = new Date(); + expires.setMilliseconds(expires.getMilliseconds() + attributes.expires * 864e+5); + attributes.expires = expires; } @@ -61,6 +73,7 @@ try { result = JSON.stringify(value); + if (/^[\{\[]/.test(result)) { value = result; } @@ -83,17 +96,20 @@ if (!attributes[attributeName]) { continue; } + stringifiedAttributes += '; ' + attributeName; + if (attributes[attributeName] === true) { continue; } + stringifiedAttributes += '=' + attributes[attributeName]; } + return (document.cookie = key + '=' + value + stringifiedAttributes); } // Read - if (!key) { result = {}; } @@ -115,6 +131,7 @@ try { var name = parts[0].replace(rdecode, decodeURIComponent); + cookie = converter.read ? converter.read(cookie, name) : converter(cookie, name) || cookie.replace(rdecode, decodeURIComponent); @@ -140,14 +157,17 @@ } api.set = api; + api.get = function (key) { return api.call(api, key); }; + api.getJSON = function () { return api.apply({ json: true }, [].slice.call(arguments)); }; + api.defaults = {}; api.remove = function (key, attributes) { diff --git a/resources/assets/js/components/AkauntingSearch.vue b/resources/assets/js/components/AkauntingSearch.vue index 639849c4a..cdbe637ea 100644 --- a/resources/assets/js/components/AkauntingSearch.vue +++ b/resources/assets/js/components/AkauntingSearch.vue @@ -1,175 +1,681 @@ - - + + diff --git a/resources/assets/js/components/AkauntingSelect.vue b/resources/assets/js/components/AkauntingSelect.vue index 2fc2bdd26..3ce97ac95 100644 --- a/resources/assets/js/components/AkauntingSelect.vue +++ b/resources/assets/js/components/AkauntingSelect.vue @@ -1,7 +1,5 @@ @@ -808,31 +139,42 @@ export default { default: '', description: "Selectbox label text" }, + placeholder: { type: String, default: '', description: "Selectbox input placeholder text" }, + formClasses: { type: Array, default: null, description: "Selectbox input class name" }, + formError: { type: String, default: null, description: "Selectbox input error message" }, + + icon: { + type: String, + description: "Prepend icon (left)" + }, + name: { type: String, default: null, description: "Selectbox attribute name" }, + value: { type: [String, Number, Array, Object], default: '', description: "Selectbox selected value" }, + options: null, option_sortable: { @@ -847,11 +189,6 @@ export default { description: "Selectbox selected model" }, - icon: { - type: String, - description: "Prepend icon (left)" - }, - addNew: { type: Object, default: function () { @@ -873,21 +210,25 @@ export default { default: false, description: "Selectbox option group status" }, + multiple: { type: Boolean, default: false, description: "Multible feature status" }, + readonly: { type: Boolean, default: false, description: "Selectbox disabled status" }, + disabled: { type: Boolean, default: false, description: "Selectbox disabled status" }, + collapse: { type: Boolean, default: false, @@ -899,6 +240,7 @@ export default { default: 'No Data', description: "Selectbox empty options message" }, + noMatchingDataText: { type: String, default: 'No Matchign Data', @@ -914,72 +256,76 @@ export default { path: this.addNew.path, type: this.addNew.type, // modal, inline field: this.addNew.field, - buttons: this.addNew.buttons + buttons: this.addNew.buttons, }, - add_new_text: this.addNew.text, - new_text: this.addNew.new_text, - selectOptions: this.options, - real_model: this.model, add_new_html: '', - form: {}, - new_options: false, - couunt: 1, + + selected: this.model, + + sort_options: [], + new_options: {}, } }, created() { - /* - if (this.group != true && Object.keys(this.options).length) { - let sortable = []; - let option_sortable = this.option_sortable; - - for (var option_key in this.options) { - sortable.push({ - 'key' : option_key, - 'value': this.options[option_key] + // Option set sort_option data + if (!Array.isArray(this.options)) { + for (const [key, value] of Object.entries(this.options)) { + this.sort_options.push({ + key: key, + value: value }); } - - if (option_sortable == 'value') { - sortable.sort(function(a, b) { - var sortableA = a[option_sortable].toUpperCase(); - var sortableB = b[option_sortable].toUpperCase(); - - let comparison = 0; - - if (sortableA > sortableB) { - comparison = 1; - } else if (sortableA < sortableB) { - comparison = -1; - } - - return comparison; + } else { + this.options.forEach(function (option, index) { + this.sort_options.push({ + index: index, + key: option.id, + value: (option.title) ? option.title : (option.display_name) ? option.display_name : option.name }); - } - - this.options = sortable; + }, this); } - */ + }, - this.new_options = {}; + computed: { + sortOptions() { + this.sort_options.sort(function (a, b) { + var nameA = a.value.toUpperCase(); // ignore upper and lowercase + var nameB = b.value.toUpperCase(); // ignore upper and lowercase + + if (nameA < nameB) { + return -1; + } + + if (nameA > nameB) { + return 1; + } + + // names must be equal + return 0; + }); + + return this.sort_options; + }, }, mounted() { - this.real_model = this.value; + // Check Here.. + this.selected = this.value; if (this.model.length) { if (eval(this.model) !== undefined) { - this.real_model = eval(this.model); + this.selected = eval(this.model); } else { - this.real_model = this.model; + this.selected = this.model; } } - if (this.multiple && !this.real_model.length) { - this.real_model = []; + if (this.multiple && !this.selected.length) { + this.selected = []; } - this.$emit('interface', this.real_model); + this.$emit('interface', this.selected); setTimeout(function() { this.change(); @@ -988,30 +334,29 @@ export default { methods: { change() { - if (typeof(this.real_model) === 'object' && typeof(this.real_model.type) !== 'undefined') { - return false; - } + this.$emit('interface', this.selected); - this.$emit('interface', this.real_model); - this.$emit('change', this.real_model); + this.$emit('change', this.selected); + }, - //this.$children[0].$children[0].$emit('keydown.native.tab'); - //this.$children[0].$children[0].handleMenuEnter(); + visibleChange(event) { + this.$emit('visible-change', event); + }, - this.$children[0].$children[0].visible = false; + removeTag(event) { + this.$emit('remove-tag', event); + }, - /* - this.$children[0].$children[0].setSoftFocus(); - if (this.$children[0].$children[0].visible) return; + clear(event) { + this.$emit('clear', event); + }, - let option = {}; + blur(event) { + this.$emit('blur', event); + }, - option.value = this.real_model; - - this.$children[0].$children[0].$nextTick(() => { - this.$children[0].$children[0].scrollToOption(option); - }); - */ + focus(event) { + this.$emit('focus', event); }, async onAddItem() { @@ -1022,11 +367,11 @@ export default { var value = this.$children[0].$children[0].$refs.input.value; } - if (this.add_new.type == 'inline') { - if (value === '') { - return false; - } + if (value === '') { + return false; + } + if (this.add_new.type == 'inline') { await this.addInline(value); } else { await this.onModal(value); @@ -1129,17 +474,17 @@ export default { this.form.loading = false; if (response.data.success) { - if (!Object.keys(this.options).length) { - this.selectOptions = {}; - } + this.sort_options.push({ + key: response.data.data[this.add_new.field.key].toString(), + value: response.data.data[this.add_new.field.value], + }); - this.selectOptions[response.data.data[this.add_new.field.key]] = response.data.data[this.add_new.field.value]; this.new_options[response.data.data[this.add_new.field.key]] = response.data.data[this.add_new.field.value]; if (this.multiple) { - this.real_model.push(response.data.data[this.add_new.field.key].toString()); + this.selected.push(response.data.data[this.add_new.field.key].toString()); } else { - this.real_model = response.data.data[this.add_new.field.key].toString(); + this.selected = response.data.data[this.add_new.field.key].toString(); } this.add_new.show = false; @@ -1179,63 +524,6 @@ export default { }, }, - - watch: { - options: function (options) { - // update options - this.selectOptions = options; - - if (Object.keys(this.new_options).length) { - if (!Object.keys(this.options).length) { - this.selectOptions = {}; - } - - for (let [key, value] of Object.entries(this.new_options)) { - if (!this.selectOptions[key]) { - this.selectOptions[key] = value; - } - } - } - }, - - real_model: function (value) { - if (this.multiple) { - return; - } - - if (this.real_model != value) { - this.change(); - } - - let e = $.Event('keyup'); - e.keyCode= 9; // tab - $('#' + this.name).trigger(e); - - let event = new window.KeyboardEvent('keydown', { keyCode: 9 }); // Tab key - - window.dispatchEvent(event); - }, - - value: function (value) { - if (this.multiple) { - this.real_model = value; - } else { - this.real_model = value.toString(); - } - - this.change(); - }, - - model: function (value) { - if (this.multiple) { - this.real_model = value; - } else { - this.real_model = value.toString(); - } - - this.change(); - } - }, } @@ -1248,6 +536,10 @@ export default { padding: 10px 0 0 !important; } + .el-select-dropdown__empty.loading { + padding: 10px 0 !important; + } + .el-select__footer { text-align: center; border-top: 1px solid #dee2e6; @@ -1283,4 +575,8 @@ export default { margin-right: 35px; position: relative; } + + .badge.badge-pill.badge-success { + border-radius: 0.375rem; + } diff --git a/resources/assets/js/components/AkauntingSelectRemote.vue b/resources/assets/js/components/AkauntingSelectRemote.vue index e600a6b6c..1a6cd9473 100644 --- a/resources/assets/js/components/AkauntingSelectRemote.vue +++ b/resources/assets/js/components/AkauntingSelectRemote.vue @@ -1,8 +1,5 @@ - - {{ label }} - {{ new_text }} + + {{ option.value }} + {{ addNew.new_text }} {{ label }} - {{ new_text }} + {{ addNew.new_text }} - +
- {{ add_new_text }} + {{ addNew.text }}
+ - -
-

- {{ noMatchingDataText }} -

-
    - -
-
+ -
-

- {{ noDataText }} -

-
    - -
-
+ {{ addNew.new_text }} - - - - {{ label }} - {{ new_text }} - - - - - {{ label }} - {{ new_text }} - - - - -
- - - {{ add_new_text }} - -
-
-
- - -
-

- {{ noMatchingDataText }} -

-
    - -
-
- -
-

- {{ noDataText }} -

-
    - -
-
- - - - - {{ label }} - {{ new_text }} - - - - - {{ label }} - {{ new_text }} - - - - -
- - - {{ add_new_text }} - -
-
-
- - -
-

- {{ noMatchingDataText }} -

-
    - -
-
- -
-

- {{ noDataText }} -

-
    - -
-
- - - - - {{ label }} - {{ new_text }} - - - - - {{ label }} - {{ new_text }} - - - - -
- - - {{ add_new_text }} - -
-
-
- - -
-

- {{ noMatchingDataText }} -

-
    - -
-
- -
-

- {{ noDataText }} -

-
    - -
-
- - - - - {{ label }} - {{ new_text }} - - - - - {{ label }} - {{ new_text }} - - - - -
- - - {{ add_new_text }} - -
-
-
- - - - + - {{ new_text }} - -
-

- {{ loadingText }} -

-
+ :loading="loading" + > -
-

- {{ noMatchingDataText }} -

-
    - -
-
+
+

+ {{ noMatchingDataText }} +

-
-

- {{ noDataText }} -

-
    - -
-
+
    + +
+
- + +
- - {{ option.name }} - {{ new_text }} - - - - - {{ label }} - {{ new_text }} - - - - -
- - - {{ add_new_text }} - -
-
- {{ new_text }} + + + {{ addNew.new_text }} + + @@ -535,42 +234,54 @@ export default { default: null, description: "Selectbox label text" }, + placeholder: { type: String, default: '', description: "Selectbox input placeholder text" }, + formClasses: { type: Array, default: null, description: "Selectbox input class name" }, + formError: { type: String, default: null, description: "Selectbox input error message" }, + + icon: { + type: String, + description: "Prepend icon (left)" + }, + name: { type: String, default: null, description: "Selectbox attribute name" }, + value: { - type: [String, Number, Array], + type: [String, Number, Array, Object], default: '', description: "Selectbox selected value" }, + options: null, - model: { - type: [String, Number], - default: null, - description: "Selectbox selected model" + option_sortable: { + type: String, + default: 'value', + description: "Option Sortable type (key|value)" }, - icon: { - type: String, - description: "Prepend icon (left)" + model: { + type: [String, Number, Array, Object], + default: '', + description: "Selectbox selected model" }, addNew: { @@ -589,26 +300,30 @@ export default { description: "Selectbox Add New Item Feature" }, - group: { + group: { type: Boolean, default: false, description: "Selectbox option group status" }, + multiple: { type: Boolean, default: false, description: "Multible feature status" }, + readonly: { type: Boolean, default: false, description: "Selectbox disabled status" }, + disabled: { type: Boolean, default: false, description: "Selectbox disabled status" }, + collapse: { type: Boolean, default: false, @@ -620,11 +335,13 @@ export default { default: 'Loading...', description: "Selectbox loading message" }, + noDataText: { type: String, default: 'No Data', description: "Selectbox empty options message" }, + noMatchingDataText: { type: String, default: 'No Matchign Data', @@ -636,11 +353,6 @@ export default { default: null, description: "Selectbox remote action path" }, - remoteType: { - type: String, - default: 'invoice', - description: "Ger remote item type." - }, currencyCode: { type: String, default: 'USD', @@ -650,56 +362,120 @@ export default { data() { return { - list: [], add_new: { text: this.addNew.text, show: false, path: this.addNew.path, type: this.addNew.type, // modal, inline field: this.addNew.field, - buttons: this.addNew.buttons + buttons: this.addNew.buttons, }, - add_new_text: this.addNew.text, - new_text: this.addNew.new_text, - selectOptions: this.options, - real_model: this.model, add_new_html: '', - form: {}, + + selected: this.model, + + sort_options: [], + new_options: {}, loading: false, - new_options: false, } }, created() { - this.new_options = {}; + this.setSortOptions(); + }, + + computed: { + sortOptions() { + this.sort_options.sort(function (a, b) { + var nameA = a.value.toUpperCase(); // ignore upper and lowercase + var nameB = b.value.toUpperCase(); // ignore upper and lowercase + + if (nameA < nameB) { + return -1; + } + + if (nameA > nameB) { + return 1; + } + + // names must be equal + return 0; + }); + + return this.sort_options; + }, }, mounted() { - if (this.multiple) { - if (!this.value.length) { - this.real_model = []; + // Check Here.. + this.selected = this.value; + + if (this.model.length) { + if (eval(this.model) !== undefined) { + this.selected = eval(this.model); } else { - let pre_value = []; - - this.value.forEach(item => { - pre_value.push(item.toString()); - }); - - this.real_model = pre_value; + this.selected = this.model; } - - } else { - this.real_model = this.value; } - this.$emit('interface', this.real_model); + if (this.multiple && !this.selected.length) { + this.selected = []; + } + + this.$emit('interface', this.selected); setTimeout(function() { - //this.change(); for invoice item + this.change(); }.bind(this), 800); }, methods: { + setSortOptions() { + // Option set sort_option data + if (!Array.isArray(this.options)) { + for (const [key, value] of Object.entries(this.options)) { + this.sort_options.push({ + key: key, + value: value + }); + } + } else { + this.options.forEach(function (option, index) { + this.sort_options.push({ + index: index, + key: option.id, + value: (option.title) ? option.title : (option.display_name) ? option.display_name : option.name + }); + }, this); + } + }, + + change() { + this.$emit('interface', this.selected); + + this.$emit('change', this.selected); + }, + + visibleChange(event) { + this.$emit('visible-change', event); + }, + + removeTag(event) { + this.$emit('remove-tag', event); + }, + + clear(event) { + this.$emit('clear', event); + }, + + blur(event) { + this.$emit('blur', event); + }, + + focus(event) { + this.$emit('focus', event); + }, + remoteMethod(query) { if (document.getElementById('form-select-' + this.name)) { document.getElementById('form-select-' + this.name).getElementsByTagName("input")[0].readOnly = false; @@ -708,18 +484,23 @@ export default { if (query !== '') { this.loading = true; - if (!this.remoteAction) { - this.remoteAction = url + '/common/items/autocomplete'; + let path = this.remoteAction; + + if (!path) { + path = url + '/common/items/autocomplete'; } + if (path.search('/?') !== -1) { + path += '?search=' + query; + } else { + path += '&search=' + query; + } + + path += '¤cy_code=' + this.currencyCode; + window.axios({ method: 'GET', - url: this.remoteAction, - params: { - type: this.remoteType, - query: query, - currency_code: this.currencyCode, - }, + url: path, headers: { 'X-CSRF-TOKEN': window.Laravel.csrfToken, 'X-Requested-With': 'XMLHttpRequest', @@ -730,9 +511,18 @@ export default { this.loading = false; if (response.data.data) { - this.selectOptions = response.data.data; + let data = response.data.data; + + this.sort_options = []; + + data.forEach(function (option) { + this.sort_options.push({ + key: option.id.toString(), + value: (option.title) ? option.title : (option.display_name) ? option.display_name : option.name + }); + }, this); } else { - this.selectOptions = []; + this.sortOptions = []; } }) .catch(e => { @@ -741,42 +531,10 @@ export default { // always executed }); } else { - this.selectOptions = this.options; + this.setSortOptions(); } }, - change() { - if (typeof(this.real_model) === 'object' && !Array.isArray(this.real_model)) { - return false; - } - - if (Array.isArray(this.real_model) && !this.real_model.length) { - return false; - } - - this.$emit('interface', this.real_model); - this.$emit('change', this.real_model); - - if (Array.isArray(this.selectOptions)) { - this.selectOptions.forEach(item => { - if (item.id == this.real_model) { - this.$emit('label', item.name); - this.$emit('option', item); - - return true; - } - }); - } - }, - - onPressEnter() { - alert('Press Enter'); - }, - - OnPressTab() { - alert('Press Tab'); - }, - async onAddItem() { // Get Select Input value if (this.title) { @@ -785,11 +543,11 @@ export default { var value = this.$children[0].$children[0].$refs.input.value; } - if (value === '') { - return false; - } - if (this.add_new.type == 'inline') { + if (value === '') { + return false; + } + await this.addInline(value); } else { await this.onModal(value); @@ -926,14 +684,18 @@ export default { this.form.loading = false; if (response.data.success) { - if (!Object.keys(this.options).length) { - this.selectOptions = []; - } + this.sort_options.push({ + key: response.data.data[this.add_new.field.key].toString(), + value: response.data.data[this.add_new.field.value], + }); - this.selectOptions.push(response.data.data); - //this.selectOptions[response.data.data[this.add_new.field.key]] = response.data.data[this.add_new.field.value]; this.new_options[response.data.data[this.add_new.field.key]] = response.data.data[this.add_new.field.value]; - this.real_model = response.data.data[this.add_new.field.key];//.toString(); + + if (this.multiple) { + this.selected.push(response.data.data[this.add_new.field.key].toString()); + } else { + this.selected = response.data.data[this.add_new.field.key].toString(); + } this.add_new.show = false; @@ -962,7 +724,7 @@ export default { this.add_new.show = false; this.add_new.html = null; this.add_new_html = null; - + let documentClasses = document.body.classList; documentClasses.remove("modal-open"); @@ -972,68 +734,6 @@ export default { }, }, - - watch: { - options: function (options) { - // update options - this.selectOptions = options; - - if (Object.keys(this.new_options).length) { - if (!Object.keys(this.options).length) { - this.selectOptions = []; - } - - Object.values(this.new_options).forEach(item => { - this.selectOptions.push(item); - }); - } - }, - - real_model: function (value) { - if (this.multiple) { - return; - } - - if (this.real_model != value) { - this.change(); - } - - let e = $.Event('keyup'); - e.keyCode= 9; // tab - $('#' + this.name).trigger(e); - - let event = new window.KeyboardEvent('keydown', { keyCode: 9 }); // Tab key - - window.dispatchEvent(event); - }, - - value: function (value) { - if (this.multiple) { - if (Array.isArray(this.real_model) && !this.real_model.length) { - this.real_model = value; - } else { - let pre_value = []; - - value.forEach(item => { - pre_value.push(item.toString()); - }); - - this.real_model = pre_value; - } - } else { - //this.real_model = value.toString(); - this.real_model = value; - } - }, - - model: function (value) { - if (this.multiple) { - this.real_model = value; - } else { - this.real_model = value; - } - } - }, } @@ -1046,10 +746,6 @@ export default { padding: 10px 0 0 !important; } - .el-select-dropdown__empty.loading { - padding: 10px 0 !important; - } - .el-select__footer { text-align: center; border-top: 1px solid #dee2e6; @@ -1085,4 +781,8 @@ export default { margin-right: 35px; position: relative; } + + .badge.badge-pill.badge-success { + border-radius: 0.375rem; + } diff --git a/resources/assets/js/views/auth/roles.js b/resources/assets/js/views/auth/roles.js index 41bd92bd8..09da7f69a 100644 --- a/resources/assets/js/views/auth/roles.js +++ b/resources/assets/js/views/auth/roles.js @@ -26,7 +26,7 @@ const app = new Vue({ ], mounted() { - if (!this.form.permissions.length) { + if (typeof this.form.permissions !== 'undefined' && !this.form.permissions.length) { this.form.permissions = []; } }, diff --git a/resources/lang/en-GB/general.php b/resources/lang/en-GB/general.php index 7c3426789..6d6a1a153 100644 --- a/resources/lang/en-GB/general.php +++ b/resources/lang/en-GB/general.php @@ -105,6 +105,7 @@ return [ 'to' => 'To', 'print' => 'Print', 'search' => 'Search', + 'search_text' => 'Search for this text', 'search_placeholder' => 'Type to search..', 'filter' => 'Filter', 'help' => 'Help', @@ -152,6 +153,8 @@ return [ 'no_matching_data' => 'No matching data', 'clear_cache' => 'Clear Cache', 'go_to_dashboard' => 'Go to dashboard', + 'is' => 'is', + 'isnot' => 'is not', 'card' => [ 'name' => 'Name on Card', @@ -181,6 +184,11 @@ return [ 'no_file_selected' => 'No file selected...', ], + 'placeholder' => [ + 'search' => 'Type to search..', + 'search_and_filter' => 'Search or filter results..', + ], + 'date_range' => [ 'today' => 'Today', 'yesterday' => 'Yesterday', diff --git a/resources/lang/en-GB/search_string.php b/resources/lang/en-GB/search_string.php new file mode 100644 index 000000000..c80e57706 --- /dev/null +++ b/resources/lang/en-GB/search_string.php @@ -0,0 +1,9 @@ + [ + 'last_logged_in_at' => 'Last Login', + ], + +]; diff --git a/resources/lang/en-GB/settings.php b/resources/lang/en-GB/settings.php index 394c2910d..3e47ce44d 100644 --- a/resources/lang/en-GB/settings.php +++ b/resources/lang/en-GB/settings.php @@ -68,6 +68,8 @@ return [ 'description' => 'Default account, currency, language of your company', 'list_limit' => 'Records Per Page', 'use_gravatar' => 'Use Gravatar', + 'income_category' => 'Income Category', + 'expense_category' => 'Expense Category', ], 'email' => [ diff --git a/resources/views/auth/permissions/index.blade.php b/resources/views/auth/permissions/index.blade.php index 54d53b2e0..381594d41 100644 --- a/resources/views/auth/permissions/index.blade.php +++ b/resources/views/auth/permissions/index.blade.php @@ -18,10 +18,7 @@ 'class' => 'mb-0' ]) !!}
- +
{{ Form::bulkActionRowGroup('general.permissions', $bulk_actions, ['group' => 'auth', 'type' => 'permissions']) }} diff --git a/resources/views/auth/roles/index.blade.php b/resources/views/auth/roles/index.blade.php index a24fcabd3..992b7ff9e 100644 --- a/resources/views/auth/roles/index.blade.php +++ b/resources/views/auth/roles/index.blade.php @@ -18,10 +18,7 @@ 'class' => 'mb-0' ]) !!}
- +
{{ Form::bulkActionRowGroup('general.roles', $bulk_actions, ['group' => 'auth', 'type' => 'roles']) }} diff --git a/resources/views/auth/users/create.blade.php b/resources/views/auth/users/create.blade.php index cffa741ab..9e37092f9 100644 --- a/resources/views/auth/users/create.blade.php +++ b/resources/views/auth/users/create.blade.php @@ -48,7 +48,7 @@ @endif @can('read-common-companies') - {{ Form::multiSelectRemoteGroup('companies', trans_choice('general.companies', 2), 'user', $companies, [], ['required' => 'required', 'remote_action' => route('companies.autocomplete'), 'remote_type' => 'company']) }} + {{ Form::multiSelectRemoteGroup('companies', trans_choice('general.companies', 2), 'user', $companies, [], ['required' => 'required', 'remote_action' => route('companies.index')]) }} @endcan @can('read-auth-roles') diff --git a/resources/views/auth/users/edit.blade.php b/resources/views/auth/users/edit.blade.php index 29c02178f..3012d3831 100644 --- a/resources/views/auth/users/edit.blade.php +++ b/resources/views/auth/users/edit.blade.php @@ -49,7 +49,7 @@ @endif @can('read-common-companies') - {{ Form::multiSelectRemoteGroup('companies', trans_choice('general.companies', 2), 'user', $companies, $user->company_ids, ['required' => 'required', 'disabled' => (in_array('customer', $user->roles()->pluck('name')->toArray())) ? 'true' : 'false', 'remote_action' => route('companies.autocomplete'), 'remote_type' => 'company']) }} + {{ Form::multiSelectRemoteGroup('companies', trans_choice('general.companies', 2), 'user', $companies, $user->company_ids, ['required' => 'required', 'disabled' => (in_array('customer', $user->roles()->pluck('name')->toArray())) ? 'true' : 'false', 'remote_action' => route('companies.index')]) }} @endcan @can('read-auth-roles') diff --git a/resources/views/auth/users/index.blade.php b/resources/views/auth/users/index.blade.php index 69e5cd50f..b8b958cca 100644 --- a/resources/views/auth/users/index.blade.php +++ b/resources/views/auth/users/index.blade.php @@ -11,21 +11,12 @@ @section('content')
- {!! Form::open([ - 'method' => 'GET', - 'route' => 'users.index', - 'role' => 'form', - 'class' => 'mb-0' - ]) !!} +
- +
{{ Form::bulkActionRowGroup('general.users', $bulk_actions, ['group' => 'auth', 'type' => 'users']) }} - {!! Form::close() !!}
diff --git a/resources/views/banking/accounts/index.blade.php b/resources/views/banking/accounts/index.blade.php index 888ff8cc7..24df6f215 100644 --- a/resources/views/banking/accounts/index.blade.php +++ b/resources/views/banking/accounts/index.blade.php @@ -18,10 +18,7 @@ 'class' => 'mb-0' ]) !!}
- +
{{ Form::bulkActionRowGroup('general.accounts', $bulk_actions, ['group' => 'banking', 'type' => 'accounts']) }} diff --git a/resources/views/banking/reconciliations/index.blade.php b/resources/views/banking/reconciliations/index.blade.php index 2c0a9b255..237fbaf17 100644 --- a/resources/views/banking/reconciliations/index.blade.php +++ b/resources/views/banking/reconciliations/index.blade.php @@ -9,7 +9,7 @@ @endsection @section('content') - @if ($reconciliations->count()) + @if ($reconciliations->count() || request()->get('search', false))
{!! Form::open([ @@ -19,10 +19,7 @@ 'class' => 'mb-0' ]) !!}
- +
{{ Form::bulkActionRowGroup('general.reconciliations', $bulk_actions, ['group' => 'banking', 'type' => 'reconciliations']) }} diff --git a/resources/views/banking/transactions/index.blade.php b/resources/views/banking/transactions/index.blade.php index 58d9a3a95..6b16ba24a 100644 --- a/resources/views/banking/transactions/index.blade.php +++ b/resources/views/banking/transactions/index.blade.php @@ -22,10 +22,7 @@ 'role' => 'form', 'class' => 'mb-0' ]) !!} - + {!! Form::close() !!}
diff --git a/resources/views/banking/transfers/index.blade.php b/resources/views/banking/transfers/index.blade.php index f2f3b08f0..6c4a63031 100644 --- a/resources/views/banking/transfers/index.blade.php +++ b/resources/views/banking/transfers/index.blade.php @@ -11,7 +11,7 @@ @endsection @section('content') - @if ($transfers->count()) + @if ($transfers->count() || request()->get('search', false))
{!! Form::open([ @@ -21,10 +21,7 @@ 'class' => 'mb-0' ]) !!}
- +
{{ Form::bulkActionRowGroup('general.transfers', $bulk_actions, ['group' => 'banking', 'type' => 'transfers']) }} diff --git a/resources/views/common/companies/index.blade.php b/resources/views/common/companies/index.blade.php index b4de518d9..40049bbe9 100644 --- a/resources/views/common/companies/index.blade.php +++ b/resources/views/common/companies/index.blade.php @@ -18,10 +18,7 @@ 'class' => 'mb-0' ]) !!}
- +
{{ Form::bulkActionRowGroup('general.companies', $bulk_actions, ['group' => 'common', 'type' => 'companies']) }} diff --git a/resources/views/common/dashboards/index.blade.php b/resources/views/common/dashboards/index.blade.php index 06cc6964a..a7536c528 100644 --- a/resources/views/common/dashboards/index.blade.php +++ b/resources/views/common/dashboards/index.blade.php @@ -18,10 +18,7 @@ 'class' => 'mb-0' ]) !!}
- +
{{ Form::bulkActionRowGroup('general.dashboards', $bulk_actions, ['group' => 'common', 'type' => 'dashboards']) }} diff --git a/resources/views/common/items/edit.blade.php b/resources/views/common/items/edit.blade.php index e41c742ae..5c2676b28 100644 --- a/resources/views/common/items/edit.blade.php +++ b/resources/views/common/items/edit.blade.php @@ -28,7 +28,7 @@ {{ Form::textGroup('purchase_price', trans('items.purchase_price'), 'money-bill-wave-alt') }} - {{ Form::selectAddNewGroup('category_id', trans_choice('general.categories', 1), 'folder', $categories, $item->category_id, ['path' => route('modals.categories.create') . '?type=item']) }} + {{ Form::selectRemoteAddNewGroup('category_id', trans_choice('general.categories', 1), 'folder', $categories, $item->category_id, ['path' => route('modals.categories.create') . '?type=item', 'remote_action' => route('categories.index'). '?type=item']) }} {{ Form::fileGroup('picture', trans_choice('general.pictures', 1)) }} diff --git a/resources/views/common/items/index.blade.php b/resources/views/common/items/index.blade.php index 6a7170a7f..edd35a1ff 100644 --- a/resources/views/common/items/index.blade.php +++ b/resources/views/common/items/index.blade.php @@ -11,7 +11,7 @@ @endsection @section('content') - @if ($items->count()) + @if ($items->count() || request()->get('search', false))
{!! Form::open([ @@ -21,10 +21,7 @@ 'class' => 'mb-0' ]) !!}
- +
{{ Form::bulkActionRowGroup('general.items', $bulk_actions, ['group' => 'common', 'type' => 'items']) }} diff --git a/resources/views/components/search-string.blade.php b/resources/views/components/search-string.blade.php new file mode 100644 index 000000000..eadab11df --- /dev/null +++ b/resources/views/components/search-string.blade.php @@ -0,0 +1,22 @@ + diff --git a/resources/views/modals/items/create.blade.php b/resources/views/modals/items/create.blade.php index 64f64fa16..53a16e9a5 100644 --- a/resources/views/modals/items/create.blade.php +++ b/resources/views/modals/items/create.blade.php @@ -18,7 +18,7 @@ {{ Form::textGroup('purchase_price', trans('items.purchase_price'), 'money-bill-wave-alt') }} - {{ Form::selectGroup('category_id', trans_choice('general.categories', 1), 'folder', $categories, null) }} + {{ Form::selectRemoteGroup('category_id', trans_choice('general.categories', 1), 'folder', $categories, null, ['remote_action' => route('categories.index'). '?type=item']) }} {!! Form::hidden('enabled', '1', []) !!}
diff --git a/resources/views/partials/form/multi_select_remote_add_new_group.blade.php b/resources/views/partials/form/multi_select_remote_add_new_group.blade.php new file mode 100644 index 000000000..6bb4ebe1c --- /dev/null +++ b/resources/views/partials/form/multi_select_remote_add_new_group.blade.php @@ -0,0 +1,97 @@ +@stack($name . '_input_start') + + + +@stack($name . '_input_end') diff --git a/resources/views/partials/form/multi_select_remote_group.blade.php b/resources/views/partials/form/multi_select_remote_group.blade.php index 699dcb591..3af3c8772 100644 --- a/resources/views/partials/form/multi_select_remote_group.blade.php +++ b/resources/views/partials/form/multi_select_remote_group.blade.php @@ -62,9 +62,8 @@ @endif remote-action="{{ $attributes['remote_action'] }}" - remote-type="{{ $attributes['remote_type'] }}" - @if (!empty($attributes['currecny_code'])) + @if (!empty($attributes['currecny_code'])) currency-code="{{ $attributes['currecny_code'] }}" @endif diff --git a/resources/views/partials/form/select_remote_add_new_group.blade.php b/resources/views/partials/form/select_remote_add_new_group.blade.php new file mode 100644 index 000000000..f0f02af21 --- /dev/null +++ b/resources/views/partials/form/select_remote_add_new_group.blade.php @@ -0,0 +1,91 @@ +@stack($name . '_input_start') + + + +@stack($name . '_input_end') diff --git a/resources/views/partials/form/select_remote_group.blade.php b/resources/views/partials/form/select_remote_group.blade.php index b234abc2a..cc3c4c14a 100644 --- a/resources/views/partials/form/select_remote_group.blade.php +++ b/resources/views/partials/form/select_remote_group.blade.php @@ -3,6 +3,8 @@
- {{ Form::selectAddNewGroup('contact_id', trans_choice('general.vendors', 1), 'user', $vendors, config('general.vendors'), ['required' => 'required', 'path' => route('modals.vendors.create'), 'change' => 'onChangeContact']) }} + {{ Form::selectRemoteAddNewGroup('contact_id', trans_choice('general.vendors', 1), 'user', $vendors, setting('default.contact'), ['required' => 'required', 'change' => 'onChangeContact', 'path' => route('modals.vendors.create'), 'remote_action' => route('vendors.index')]) }} {{ Form::selectAddNewGroup('currency_code', trans_choice('general.currencies', 1), 'exchange-alt', $currencies, setting('default.currency'), ['required' => 'required', 'model' => 'form.currency_code', 'path' => route('modals.currencies.create'), 'field' => ['key' => 'code', 'value' => 'name'], 'change' => 'onChangeCurrency']) }} @@ -194,7 +194,7 @@ {{ Form::textareaGroup('notes', trans_choice('general.notes', 2)) }} - {{ Form::selectAddNewGroup('category_id', trans_choice('general.categories', 1), 'folder', $categories, setting('default.category'), ['required' => 'required', 'path' => route('modals.categories.create') . '?type=expense']) }} + {{ Form::selectRemoteAddNewGroup('category_id', trans_choice('general.categories', 1), 'folder', $categories, setting('default.expense_category'), ['required' => 'required', 'path' => route('modals.categories.create') . '?type=expense', 'remote_action' => route('categories.index'). '?type=expense']) }} {{ Form::recurring('create') }} diff --git a/resources/views/purchases/bills/edit.blade.php b/resources/views/purchases/bills/edit.blade.php index 4f0218830..05fa03797 100644 --- a/resources/views/purchases/bills/edit.blade.php +++ b/resources/views/purchases/bills/edit.blade.php @@ -18,7 +18,7 @@
- {{ Form::selectAddNewGroup('contact_id', trans_choice('general.vendors', 1), 'user', $vendors, $bill->contact_id, ['required' => 'required', 'path' => route('modals.vendors.create'), 'change' => 'onChangeContact']) }} + {{ Form::selectRemoteAddNewGroup('contact_id', trans_choice('general.vendors', 1), 'user', $vendors, $bill->contact_id, ['required' => 'required', 'change' => 'onChangeContact', 'path' => route('modals.vendors.create'), 'remote_action' => route('vendors.index')]) }} {{ Form::selectAddNewGroup('currency_code', trans_choice('general.currencies', 1), 'exchange-alt', $currencies, $bill->currency_code, ['required' => 'required', 'model' => 'form.currency_code', 'path' => route('modals.currencies.create'), 'field' => ['key' => 'code', 'value' => 'name'], 'change' => 'onChangeCurrency']) }} @@ -195,7 +195,7 @@ {{ Form::textareaGroup('notes', trans_choice('general.notes', 2)) }} - {{ Form::selectAddNewGroup('category_id', trans_choice('general.categories', 1), 'folder', $categories, $bill->category_id, ['required' => 'required', 'path' => route('modals.categories.create') . '?type=expense']) }} + {{ Form::selectRemoteAddNewGroup('category_id', trans_choice('general.categories', 1), 'folder', $categories, $bill->category_id, ['required' => 'required', 'path' => route('modals.categories.create') . '?type=expense', 'remote_action' => route('categories.index'). '?type=expense']) }} {{ Form::recurring('edit', $bill) }} diff --git a/resources/views/purchases/bills/index.blade.php b/resources/views/purchases/bills/index.blade.php index 97f715f75..5747935cc 100644 --- a/resources/views/purchases/bills/index.blade.php +++ b/resources/views/purchases/bills/index.blade.php @@ -11,7 +11,7 @@ @endsection @section('content') - @if ($bills->count()) + @if ($bills->count() || request()->get('search', false))
{!! Form::open([ @@ -21,10 +21,7 @@ 'class' => 'mb-0' ]) !!}
- +
{{ Form::bulkActionRowGroup('general.bills', $bulk_actions, ['group' => 'purchases', 'type' => 'bills']) }} @@ -67,7 +64,7 @@