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:
.github/workflows
.gitignore.htaccessapp
Abstracts
BulkActions
Banking
Console
Commands
BillReminder.phpFinishUpdate.phpInstall.phpInstallRefresh.phpInvoiceReminder.phpRecurringCheck.phpUninstallModule.phpUpdateAll.php
Stubs
Modules
Events
Auth
Install
Module
Report
Sale
Exports
Http
Controllers
Api
Auth
Banking
Common
Purchases
Sales
Settings
Auth
Banking
Common
Install
Modals
Accounts.phpBillTransactions.phpCategories.phpCurrencies.phpCustomers.phpInvoiceTemplates.phpInvoiceTransactions.phpItems.phpTaxes.phpVendors.php
Modules
Portal
Purchases
Sales
Settings
Company.phpCurrencies.phpDefaults.phpEmail.phpInvoice.phpLocalisation.phpModules.phpSchedule.phpTaxes.php
Wizard
Middleware
Requests
Purchase
ViewComposers
Jobs
Auth
CreatePermission.phpCreateRole.phpCreateUser.phpDeletePermission.phpDeleteRole.phpDeleteUser.phpUpdatePermission.phpUpdateRole.phpUpdateUser.php
Banking
CreateAccount.phpCreateDocumentTransaction.phpCreateReconciliation.phpCreateTransaction.phpCreateTransfer.phpDeleteAccount.phpDeleteReconciliation.phpDeleteTransaction.phpDeleteTransfer.phpUpdateAccount.phpUpdateReconciliation.phpUpdateTransaction.phpUpdateTransfer.php
Common
CreateCompany.phpCreateContact.phpCreateDashboard.phpCreateItem.phpCreateReport.phpDeleteCompany.phpDeleteContact.phpDeleteDashboard.phpDeleteItem.phpDeleteReport.phpUpdateCompany.phpUpdateContact.phpUpdateDashboard.phpUpdateItem.phpUpdateReport.php
Purchase
CancelBill.phpCreateBill.phpCreateBillItem.phpCreateBillItemsAndTotals.phpDeleteBill.phpDuplicateBill.phpUpdateBill.php
Sale
CancelInvoice.phpCreateInvoice.phpCreateInvoiceItem.phpCreateInvoiceItemsAndTotals.phpDeleteInvoice.phpDuplicateInvoice.phpUpdateInvoice.php
Setting
Listeners
Auth
Menu
Module
Update
Models
Auth
Banking
Common
Module
Setting
Notifications
Providers
Reports
Traits
Utilities
Widgets
bootstrap
composer.jsoncomposer.lockconfig
database
factories
migrations
seeds
modules
OfflinePayments
PaypalStandard
overrides
akaunting
symfony
process
public/css
resources
assets
js
lang
ar-SA
bg-BG
bn-BD
accounts.phpauth.phpbills.phpbulk_actions.phpdemo.phpemail_templates.phperrors.phpfooter.phpgeneral.phpheader.phpimport.phpinstall.phpmodules.phptaxes.php
cs-CZ
da-DK
accounts.phpauth.phpbills.phpdemo.phpemail_templates.phpgeneral.phpinstall.phpmessages.phpmodules.phpreconciliations.phpsettings.phptaxes.phpwidgets.php
de-DE
el-GR
auth.phpbills.phpbulk_actions.phpcompanies.phpcustomers.phpmaintenance.phpmodules.phppagination.phppasswords.phpreports.phpsettings.phptaxes.phpvalidation.php
en-GB
en-US
es-AR
accounts.phpauth.phpbills.phpbulk_actions.phpcompanies.phpcurrencies.phpcustomers.phpdashboards.phpdemo.phpemail_templates.phperrors.phpfooter.phpgeneral.phpheader.phpimport.phpinstall.phpinvoices.phpitems.phpmaintenance.phpmessages.phpmodules.phpnotifications.phppagination.phppasswords.phpreconciliations.phprecurring.phpreports.phpsettings.phptaxes.phptransfers.phpupdates.phpvalidation.phpwidgets.php
es-CO
es-ES
es-MX
et-EE
accounts.phpauth.phpbills.phpbulk_actions.phpcompanies.phpcurrencies.phpcustomers.phpfooter.phpimport.phpitems.phprecurring.phptransfers.php
fi-FI
fr-FR
auth.phpbills.phpbulk_actions.phpcompanies.phpcustomers.phpdashboard.phpdashboards.phpdemo.phpemail_templates.phperrors.phpgeneral.phpheader.phpinstall.phpinvoices.phpitems.phpmaintenance.phpmessages.phpmodules.phppagination.phppasswords.phpreconciliations.phpreports.phpsettings.phptaxes.phpvalidation.phpwidgets.php
he-IL
hi-IN
hr-HR
hu-HU
accounts.phpcurrencies.phperrors.phpfooter.phpimport.phpitems.phpnotifications.phprecurring.phptransfers.phpupdates.phpwidgets.php
id-ID
is-IS
auth.phpbills.phpbulk_actions.phpcompanies.phpcustomers.phpdashboard.phpdashboards.phpdemo.phpemail_templates.phperrors.phpgeneral.phpinstall.phpinvoices.phpmaintenance.phpmessages.phpmodules.phppagination.phppasswords.phpreconciliations.phpreports.phpsettings.phptaxes.phpvalidation.phpwidgets.php
it-IT
ja-JP
ka-GE
auth.phpcompanies.phpcustomers.phpdemo.phpemail_templates.phpheader.phpitems.phpmaintenance.phppagination.phpvalidation.php
ko-KR
lt-LT
mk-MK
ms-MY
nb-NO
ne-NP
accounts.phpauth.phpbills.phpbulk_actions.phpcompanies.phpcurrencies.phpcustomers.phpdashboards.phpdemo.phpemail_templates.phperrors.phpfooter.phpgeneral.phpheader.phpimport.phpinstall.phpinvoices.phpitems.phpmaintenance.phpmessages.phpmodules.phpnotifications.phppagination.phppasswords.phpreconciliations.phprecurring.phpreports.phpsettings.phptaxes.phptransfers.phpupdates.phpvalidation.phpwidgets.php
nl-NL
bills.phpbulk_actions.phpemail_templates.phperrors.phpgeneral.phpinstall.phpinvoices.phpmaintenance.phpmessages.phpmodules.phppagination.phppasswords.phpreconciliations.phpreports.phpsettings.phptaxes.phpvalidation.phpwidgets.php
pl-PL
accounts.phpcurrencies.phpcustomers.phpfooter.phpheader.phpitems.phpmaintenance.phpnotifications.phptransfers.phpupdates.php
pt-BR
pt-PT
auth.phpbills.phpbulk_actions.phpcompanies.phpcustomers.phpemail_templates.phperrors.phpgeneral.phpimport.phpinstall.phpinvoices.phpmaintenance.phpmessages.phpmodules.phpnotifications.phppagination.phppasswords.phpreconciliations.phpsettings.phptaxes.phpvalidation.phpwidgets.php
ro-RO
ru-RU
sk-SK
sl-SI
accounts.phpcurrencies.phpfooter.phpimport.phpitems.phpnotifications.phprecurring.phptransfers.phpupdates.php
sq-AL
sr-CS
accounts.phpauth.phpbills.phpcompanies.phpcurrencies.phpcustomers.phpdashboards.phpdemo.phperrors.phpfooter.phpimport.phpitems.phppagination.phptransfers.phpupdates.phpwidgets.php
sr-SP
accounts.phpauth.phpbills.phpcurrencies.phpfooter.phpheader.phpimport.phpitems.phpnotifications.phprecurring.phptransfers.phpupdates.php
sv-SE
th-TH
tr-TR
uk-UA
ur-PK
uz-UZ
auth.phpcompanies.phpcustomers.phpdashboards.phpdemo.phperrors.phpmaintenance.phpmodules.phppagination.phpreports.phpwidgets.php
vi-VN
zh-CN
bills.phpbulk_actions.phpinstall.phpinvoices.phpmessages.phpmodules.phppasswords.phpsettings.phpvalidation.php
zh-TW
auth.phpbills.phpbulk_actions.phpcompanies.phpcustomers.phpdashboards.phpdemo.phpemail_templates.phperrors.phpgeneral.phpheader.phpinstall.phpinvoices.phpitems.phpmaintenance.phpmessages.phpmodules.phppagination.phppasswords.phpreconciliations.phpreports.phpsettings.phptaxes.phpvalidation.phpwidgets.php
views
auth
banking
accounts
reconciliations
transactions
transfers
common
reports
install
updates
layouts
modals
accounts
bills
invoices
settings
modules
partials
admin
content.blade.phphead.blade.phpheader.blade.phpnavbar.blade.phppagination.blade.phpsuggestions.blade.php
auth
form
checkbox_group.blade.phpdate_group.blade.phpdate_time_group.blade.phpinvoice_text.blade.phpmoney_group.blade.phpmulti_select_add_new_group.blade.phpmulti_select_group.blade.phpmulti_select_remote_group.blade.phpselect_add_new_group.blade.phpselect_group.blade.phpselect_group_add_new_group.blade.phpselect_group_group.blade.phpselect_remote_group.blade.phptext_editor_group.blade.phptime_group.blade.php
media
modules
portal
print
reports
signed
widgets
wizard
portal
invoices
purchases
reports
profit_loss
tax_summary
sales
customers
invoices
revenues
settings
company
currencies
default
email
invoice
localisation
modules
schedule
widgets
wizard
routes
tests/Feature
39
.github/workflows/translations.yml
vendored
Normal file
39
.github/workflows/translations.yml
vendored
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
name: Translations
|
||||||
|
|
||||||
|
on:
|
||||||
|
schedule:
|
||||||
|
- cron: '0 0 * * *'
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
sync:
|
||||||
|
name: Sync
|
||||||
|
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- name: Sync with Crowdin
|
||||||
|
uses: crowdin/github-action@master
|
||||||
|
with:
|
||||||
|
upload_sources: true
|
||||||
|
upload_translations: true
|
||||||
|
download_translations: true
|
||||||
|
skip_untranslated_files: true
|
||||||
|
|
||||||
|
source: 'resources/lang/en-GB/*.php'
|
||||||
|
translation: 'resources/lang/%locale%/%original_file_name%'
|
||||||
|
|
||||||
|
localization_branch_name: 'translations'
|
||||||
|
commit_message: 'new crowdin translations'
|
||||||
|
pull_request_title: 'New Crowdin translations'
|
||||||
|
pull_request_body: 'https://crowdin.com/project/akaunting'
|
||||||
|
pull_request_labels: 'Translation'
|
||||||
|
|
||||||
|
project_id: ${{ secrets.CROWDIN_CORE_ID }}
|
||||||
|
token: ${{ secrets.CROWDIN_PERSONAL_TOKEN }}
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
2
.gitignore
vendored
2
.gitignore
vendored
@@ -78,6 +78,7 @@ fabric.properties
|
|||||||
/storage/*.key
|
/storage/*.key
|
||||||
/vendor
|
/vendor
|
||||||
/.idea
|
/.idea
|
||||||
|
/.history
|
||||||
/.vscode
|
/.vscode
|
||||||
/.vagrant
|
/.vagrant
|
||||||
Homestead.json
|
Homestead.json
|
||||||
@@ -87,6 +88,7 @@ npm-debug.log
|
|||||||
.env.example
|
.env.example
|
||||||
robots.txt
|
robots.txt
|
||||||
_ide_helper.php
|
_ide_helper.php
|
||||||
|
_ide_helper_models.php
|
||||||
.phpstorm.meta.php
|
.phpstorm.meta.php
|
||||||
/storage/debugbar/*
|
/storage/debugbar/*
|
||||||
.phpunit.result.cache
|
.phpunit.result.cache
|
||||||
|
11
.htaccess
11
.htaccess
@@ -13,8 +13,15 @@
|
|||||||
|
|
||||||
# Prevent Direct Access to Protected Files
|
# Prevent Direct Access to Protected Files
|
||||||
<FilesMatch "(?i)(^artisan$|\.env|\.log)">
|
<FilesMatch "(?i)(^artisan$|\.env|\.log)">
|
||||||
Order deny,allow
|
# Apache 2.2 syntax
|
||||||
Deny from all
|
<IfModule !mod_authz_core.c>
|
||||||
|
Order deny,allow
|
||||||
|
Deny from all
|
||||||
|
</IfModule>
|
||||||
|
# Apache 2.4 syntax
|
||||||
|
<IfModule mod_authz_core.c>
|
||||||
|
Require all denied
|
||||||
|
</IfModule>
|
||||||
</FilesMatch>
|
</FilesMatch>
|
||||||
|
|
||||||
# Prevent Direct Access To Protected Folders
|
# Prevent Direct Access To Protected Folders
|
||||||
|
76
app/Abstracts/Commands/Module.php
Normal file
76
app/Abstracts/Commands/Module.php
Normal file
@@ -0,0 +1,76 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Abstracts\Commands;
|
||||||
|
|
||||||
|
use App\Models\Module\Module as Model;
|
||||||
|
use App\Models\Module\ModuleHistory as ModelHistory;
|
||||||
|
use Illuminate\Console\Command;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
use Symfony\Component\Console\Input\InputArgument;
|
||||||
|
|
||||||
|
abstract class Module extends Command
|
||||||
|
{
|
||||||
|
protected function prepare()
|
||||||
|
{
|
||||||
|
$this->alias = Str::kebab($this->argument('alias'));
|
||||||
|
$this->company_id = $this->argument('company');
|
||||||
|
$this->locale = $this->argument('locale');
|
||||||
|
|
||||||
|
$this->module = module($this->alias);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function changeRuntime()
|
||||||
|
{
|
||||||
|
$this->old_company_id = session('company_id');
|
||||||
|
|
||||||
|
session(['company_id' => $this->company_id]);
|
||||||
|
|
||||||
|
app()->setLocale($this->locale);
|
||||||
|
|
||||||
|
// Disable model cache
|
||||||
|
config(['laravel-model-caching.enabled' => false]);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function revertRuntime()
|
||||||
|
{
|
||||||
|
session()->forget('company_id');
|
||||||
|
|
||||||
|
if (!empty($this->old_company_id)) {
|
||||||
|
session(['company_id' => $this->old_company_id]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getModel()
|
||||||
|
{
|
||||||
|
$this->model = Model::companyId($this->company_id)->alias($this->alias)->first();
|
||||||
|
|
||||||
|
return $this->model;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function createHistory($action)
|
||||||
|
{
|
||||||
|
if (empty($this->model)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ModelHistory::create([
|
||||||
|
'company_id' => $this->company_id,
|
||||||
|
'module_id' => $this->model->id,
|
||||||
|
'version' => $this->module->get('version'),
|
||||||
|
'description' => trans('modules.' . $action, ['module' => $this->alias]),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the console command arguments.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
protected function getArguments()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
['alias', InputArgument::REQUIRED, 'Module alias.'],
|
||||||
|
['company', InputArgument::REQUIRED, 'Company ID.'],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
@@ -3,8 +3,8 @@
|
|||||||
namespace App\Abstracts;
|
namespace App\Abstracts;
|
||||||
|
|
||||||
use App\Abstracts\Model;
|
use App\Abstracts\Model;
|
||||||
use App\Models\Banking\Transaction;
|
use App\Events\Sale\InvoicePaidCalculated;
|
||||||
use App\Models\Setting\Currency;
|
use App\Models\Setting\Tax;
|
||||||
use App\Traits\Currencies;
|
use App\Traits\Currencies;
|
||||||
use App\Traits\DateTime;
|
use App\Traits\DateTime;
|
||||||
use App\Traits\Media;
|
use App\Traits\Media;
|
||||||
@@ -65,10 +65,10 @@ abstract class DocumentModel extends Model
|
|||||||
{
|
{
|
||||||
$percent = 0;
|
$percent = 0;
|
||||||
|
|
||||||
$discount = $this->totals()->where('code', 'discount')->value('amount');
|
$discount = $this->totals->where('code', 'discount')->makeHidden('title')->pluck('amount')->first();
|
||||||
|
|
||||||
if ($discount) {
|
if ($discount) {
|
||||||
$sub_total = $this->totals()->where('code', 'sub_total')->value('amount');
|
$sub_total = $this->totals->where('code', 'sub_total')->makeHidden('title')->pluck('amount')->first();
|
||||||
|
|
||||||
$percent = number_format((($discount * 100) / $sub_total), 0);
|
$percent = number_format((($discount * 100) / $sub_total), 0);
|
||||||
}
|
}
|
||||||
@@ -90,28 +90,16 @@ abstract class DocumentModel extends Model
|
|||||||
$paid = 0;
|
$paid = 0;
|
||||||
$reconciled = $reconciled_amount = 0;
|
$reconciled = $reconciled_amount = 0;
|
||||||
|
|
||||||
|
$code = $this->currency_code;
|
||||||
|
$rate = config('money.' . $code . '.rate');
|
||||||
|
$precision = config('money.' . $code . '.precision');
|
||||||
|
|
||||||
if ($this->transactions->count()) {
|
if ($this->transactions->count()) {
|
||||||
$currencies = Currency::enabled()->pluck('rate', 'code')->toArray();
|
|
||||||
|
|
||||||
foreach ($this->transactions as $item) {
|
foreach ($this->transactions as $item) {
|
||||||
if ($this->currency_code == $item->currency_code) {
|
$amount = $item->amount;
|
||||||
$amount = (double) $item->amount;
|
|
||||||
} else {
|
|
||||||
$default_model = new Transaction();
|
|
||||||
$default_model->default_currency_code = $this->currency_code;
|
|
||||||
$default_model->amount = $item->amount;
|
|
||||||
$default_model->currency_code = $item->currency_code;
|
|
||||||
$default_model->currency_rate = $currencies[$item->currency_code];
|
|
||||||
|
|
||||||
$default_amount = (double) $default_model->getAmountConvertedToDefault();
|
if ($code != $item->currency_code) {
|
||||||
|
$amount = $this->convertBetween($amount, $item->currency_code, $item->currency_rate, $code, $rate);
|
||||||
$convert_model = new Transaction();
|
|
||||||
$convert_model->default_currency_code = $item->currency_code;
|
|
||||||
$convert_model->amount = $default_amount;
|
|
||||||
$convert_model->currency_code = $this->currency_code;
|
|
||||||
$convert_model->currency_rate = $currencies[$this->currency_code];
|
|
||||||
|
|
||||||
$amount = (double) $convert_model->getAmountConvertedFromDefault();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$paid += $amount;
|
$paid += $amount;
|
||||||
@@ -122,13 +110,19 @@ abstract class DocumentModel extends Model
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->amount == $reconciled_amount) {
|
if (bccomp(round($this->amount, $precision), round($reconciled_amount, $precision), $precision) === 0) {
|
||||||
$reconciled = 1;
|
$reconciled = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->setAttribute('reconciled', $reconciled);
|
$this->setAttribute('reconciled', $reconciled);
|
||||||
|
|
||||||
return $paid;
|
// TODO: find a cleaner way compatible with observer pattern
|
||||||
|
$invoice = clone $this;
|
||||||
|
$invoice->paid_amount = $paid;
|
||||||
|
|
||||||
|
event(new InvoicePaidCalculated($invoice));
|
||||||
|
|
||||||
|
return round($invoice->paid_amount, $precision);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Get the status label.
|
* Get the status label.
|
||||||
@@ -171,8 +165,14 @@ abstract class DocumentModel extends Model
|
|||||||
{
|
{
|
||||||
$amount = $this->amount;
|
$amount = $this->amount;
|
||||||
|
|
||||||
$this->totals()->where('code', 'tax')->each(function ($tax) use(&$amount) {
|
$this->totals->where('code', 'tax')->each(function ($total) use(&$amount) {
|
||||||
$amount -= $tax->amount;
|
$tax = Tax::name($total->name)->first();
|
||||||
|
|
||||||
|
if (!empty($tax) && ($tax->type == 'withholding')) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$amount -= $total->amount;
|
||||||
});
|
});
|
||||||
|
|
||||||
return $amount;
|
return $amount;
|
||||||
|
@@ -44,16 +44,20 @@ abstract class Controller extends BaseController
|
|||||||
|
|
||||||
$controller = '';
|
$controller = '';
|
||||||
|
|
||||||
|
// Add module
|
||||||
|
if (isset($arr[3]) && isset($arr[4])) {
|
||||||
|
if (strtolower($arr[4]) == 'modules') {
|
||||||
|
$controller .= Str::kebab($arr[3]) . '-';
|
||||||
|
} elseif (isset($arr[5]) && (strtolower($arr[5]) == 'modules')) {
|
||||||
|
$controller .= Str::kebab($arr[4]) . '-';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Add folder
|
// Add folder
|
||||||
if (strtolower($arr[1]) != 'controllers') {
|
if (strtolower($arr[1]) != 'controllers') {
|
||||||
$controller .= Str::kebab($arr[1]) . '-';
|
$controller .= Str::kebab($arr[1]) . '-';
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add module
|
|
||||||
if (isset($arr[3]) && isset($arr[4]) && (strtolower($arr[4]) == 'modules')) {
|
|
||||||
$controller .= Str::kebab($arr[3]) . '-';
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add file
|
// Add file
|
||||||
$controller .= Str::kebab($arr[0]);
|
$controller .= Str::kebab($arr[0]);
|
||||||
|
|
||||||
@@ -63,10 +67,15 @@ abstract class Controller extends BaseController
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// App\Http\Controllers\FooBar -->> foo-bar
|
||||||
|
// App\Http\Controllers\FooBar\Main -->> foo-bar-main
|
||||||
|
// Modules\Blog\Http\Controllers\Posts -->> blog-posts
|
||||||
|
// Modules\Blog\Http\Controllers\Portal\Posts -->> blog-portal-posts
|
||||||
|
|
||||||
// Add CRUD permission check
|
// Add CRUD permission check
|
||||||
$this->middleware('permission:create-' . $controller)->only(['create', 'store', 'duplicate', 'import']);
|
$this->middleware('permission:create-' . $controller)->only('create', 'store', 'duplicate', 'import');
|
||||||
$this->middleware('permission:read-' . $controller)->only(['index', 'show', 'edit', 'export']);
|
$this->middleware('permission:read-' . $controller)->only('index', 'show', 'edit', 'export');
|
||||||
$this->middleware('permission:update-' . $controller)->only(['update', 'enable', 'disable']);
|
$this->middleware('permission:update-' . $controller)->only('update', 'enable', 'disable');
|
||||||
$this->middleware('permission:delete-' . $controller)->only('destroy');
|
$this->middleware('permission:delete-' . $controller)->only('destroy');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -160,6 +160,7 @@ abstract class PaymentController extends BaseController
|
|||||||
public function dispatchPaidEvent($invoice, $request)
|
public function dispatchPaidEvent($invoice, $request)
|
||||||
{
|
{
|
||||||
$request['company_id'] = $invoice->company_id;
|
$request['company_id'] = $invoice->company_id;
|
||||||
|
$request['account_id'] = setting($this->alias . '.account_id', setting('default.account'));
|
||||||
$request['amount'] = $invoice->amount;
|
$request['amount'] = $invoice->amount;
|
||||||
$request['payment_method'] = $this->alias;
|
$request['payment_method'] = $this->alias;
|
||||||
$request['reference'] = $this->getReference($invoice);
|
$request['reference'] = $this->getReference($invoice);
|
||||||
|
@@ -18,6 +18,10 @@ abstract class Model extends Eloquent
|
|||||||
|
|
||||||
protected $dates = ['deleted_at'];
|
protected $dates = ['deleted_at'];
|
||||||
|
|
||||||
|
protected $casts = [
|
||||||
|
'enabled' => 'boolean',
|
||||||
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The "booting" method of the model.
|
* The "booting" method of the model.
|
||||||
*
|
*
|
||||||
|
@@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
namespace App\Abstracts;
|
namespace App\Abstracts;
|
||||||
|
|
||||||
|
use App\Events\Report\DataLoaded;
|
||||||
|
use App\Events\Report\DataLoading;
|
||||||
use App\Events\Report\FilterApplying;
|
use App\Events\Report\FilterApplying;
|
||||||
use App\Events\Report\FilterShowing;
|
use App\Events\Report\FilterShowing;
|
||||||
use App\Events\Report\GroupApplying;
|
use App\Events\Report\GroupApplying;
|
||||||
@@ -47,11 +49,6 @@ abstract class Report
|
|||||||
|
|
||||||
public $loaded = false;
|
public $loaded = false;
|
||||||
|
|
||||||
public $indents = [
|
|
||||||
'table_header' => '0px',
|
|
||||||
'table_rows' => '24px',
|
|
||||||
];
|
|
||||||
|
|
||||||
public $chart = [
|
public $chart = [
|
||||||
'line' => [
|
'line' => [
|
||||||
'width' => '0',
|
'width' => '0',
|
||||||
@@ -97,12 +94,21 @@ abstract class Report
|
|||||||
$this->setDates();
|
$this->setDates();
|
||||||
$this->setFilters();
|
$this->setFilters();
|
||||||
$this->setRows();
|
$this->setRows();
|
||||||
$this->setData();
|
$this->loadData();
|
||||||
$this->setColumnWidth();
|
$this->setColumnWidth();
|
||||||
|
|
||||||
$this->loaded = true;
|
$this->loaded = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function loadData()
|
||||||
|
{
|
||||||
|
event(new DataLoading($this));
|
||||||
|
|
||||||
|
$this->setData();
|
||||||
|
|
||||||
|
event(new DataLoaded($this));
|
||||||
|
}
|
||||||
|
|
||||||
public function getDefaultName()
|
public function getDefaultName()
|
||||||
{
|
{
|
||||||
if (!empty($this->default_name)) {
|
if (!empty($this->default_name)) {
|
||||||
@@ -147,17 +153,17 @@ abstract class Report
|
|||||||
{
|
{
|
||||||
$chart = new Chartjs();
|
$chart = new Chartjs();
|
||||||
|
|
||||||
if (empty($this->model->settings->chart)) {
|
if (!$type = $this->getSetting('chart')) {
|
||||||
return $chart;
|
return $chart;
|
||||||
}
|
}
|
||||||
|
|
||||||
$config = $this->chart[$this->model->settings->chart];
|
$config = $this->chart[$type];
|
||||||
|
|
||||||
$default_options = $this->getLineChartOptions();
|
$default_options = $this->getLineChartOptions();
|
||||||
|
|
||||||
$options = array_merge($default_options, (array) $config['options']);
|
$options = array_merge($default_options, (array) $config['options']);
|
||||||
|
|
||||||
$chart->type($this->model->settings->chart)
|
$chart->type($type)
|
||||||
->width((int) $config['width'])
|
->width((int) $config['width'])
|
||||||
->height((int) $config['height'])
|
->height((int) $config['height'])
|
||||||
->options($options)
|
->options($options)
|
||||||
@@ -204,13 +210,13 @@ abstract class Report
|
|||||||
|
|
||||||
public function setColumnWidth()
|
public function setColumnWidth()
|
||||||
{
|
{
|
||||||
if (empty($this->model->settings->period)) {
|
if (!$period = $this->getSetting('period')) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$width = '';
|
$width = '';
|
||||||
|
|
||||||
switch ($this->model->settings->period) {
|
switch ($period) {
|
||||||
case 'quarterly':
|
case 'quarterly':
|
||||||
$width = 'col-sm-2';
|
$width = 'col-sm-2';
|
||||||
break;
|
break;
|
||||||
@@ -258,16 +264,16 @@ abstract class Report
|
|||||||
|
|
||||||
public function setDates()
|
public function setDates()
|
||||||
{
|
{
|
||||||
if (empty($this->model->settings->period)) {
|
if (!$period = $this->getSetting('period')) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$function = 'sub' . ucfirst(str_replace('ly', '', $this->model->settings->period));
|
$function = 'sub' . ucfirst(str_replace('ly', '', $period));
|
||||||
|
|
||||||
$start = $this->getFinancialStart()->copy()->$function();
|
$start = $this->getFinancialStart()->copy()->$function();
|
||||||
|
|
||||||
for ($j = 1; $j <= 12; $j++) {
|
for ($j = 1; $j <= 12; $j++) {
|
||||||
switch ($this->model->settings->period) {
|
switch ($period) {
|
||||||
case 'yearly':
|
case 'yearly':
|
||||||
$start->addYear();
|
$start->addYear();
|
||||||
|
|
||||||
@@ -337,7 +343,7 @@ abstract class Report
|
|||||||
|
|
||||||
$date = $this->getFormattedDate(Date::parse($item->$date_field));
|
$date = $this->getFormattedDate(Date::parse($item->$date_field));
|
||||||
|
|
||||||
$id_field = $this->model->settings->group . '_id';
|
$id_field = $this->getSetting('group') . '_id';
|
||||||
|
|
||||||
if (
|
if (
|
||||||
!isset($this->row_values[$table][$item->$id_field])
|
!isset($this->row_values[$table][$item->$id_field])
|
||||||
@@ -379,7 +385,7 @@ abstract class Report
|
|||||||
|
|
||||||
public function getFormattedDate($date)
|
public function getFormattedDate($date)
|
||||||
{
|
{
|
||||||
switch ($this->model->settings->period) {
|
switch ($this->getSetting('period')) {
|
||||||
case 'yearly':
|
case 'yearly':
|
||||||
$i = $date->copy()->format($this->getYearlyDateFormat());
|
$i = $date->copy()->format($this->getYearlyDateFormat());
|
||||||
break;
|
break;
|
||||||
@@ -416,6 +422,11 @@ abstract class Report
|
|||||||
return $print_url;
|
return $print_url;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getSetting($name, $default = '')
|
||||||
|
{
|
||||||
|
return $this->model->settings->$name ?? $default;
|
||||||
|
}
|
||||||
|
|
||||||
public function getFields()
|
public function getFields()
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
|
@@ -11,14 +11,14 @@ class Reconciliations extends BulkAction
|
|||||||
public $model = Reconciliation::class;
|
public $model = Reconciliation::class;
|
||||||
|
|
||||||
public $actions = [
|
public $actions = [
|
||||||
'enable' => [
|
'reconcile' => [
|
||||||
'name' => 'general.enable',
|
'name' => 'reconciliations.reconcile',
|
||||||
'message' => 'bulk_actions.message.enable',
|
'message' => 'bulk_actions.message.reconcile',
|
||||||
'permission' => 'update-banking-reconciliations',
|
'permission' => 'update-banking-reconciliations',
|
||||||
],
|
],
|
||||||
'disable' => [
|
'unreconcile' => [
|
||||||
'name' => 'general.disable',
|
'name' => 'reconciliations.unreconcile',
|
||||||
'message' => 'bulk_actions.message.disable',
|
'message' => 'bulk_actions.message.unreconcile',
|
||||||
'permission' => 'update-banking-reconciliations',
|
'permission' => 'update-banking-reconciliations',
|
||||||
],
|
],
|
||||||
'delete' => [
|
'delete' => [
|
||||||
@@ -28,37 +28,41 @@ class Reconciliations extends BulkAction
|
|||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
public function enable($request)
|
public function reconcile($request)
|
||||||
{
|
{
|
||||||
$reconciliations = $this->getSelectedRecords($request);
|
$reconciliations = $this->getSelectedRecords($request);
|
||||||
|
|
||||||
foreach ($reconciliations as $reconciliation) {
|
foreach ($reconciliations as $reconciliation) {
|
||||||
$reconciliation->enabled = 1;
|
\DB::transaction(function () use ($reconciliation) {
|
||||||
$reconciliation->save();
|
$reconciliation->reconciled = 1;
|
||||||
|
$reconciliation->save();
|
||||||
|
|
||||||
Transaction::where('account_id', $reconciliation->account_id)
|
Transaction::where('account_id', $reconciliation->account_id)
|
||||||
->reconciled()
|
->isNotReconciled()
|
||||||
->whereBetween('paid_at', [$reconciliation->started_at, $reconciliation->ended_at])->each(function ($item) {
|
->whereBetween('paid_at', [$reconciliation->started_at, $reconciliation->ended_at])->each(function ($item) {
|
||||||
$item->reconciled = 1;
|
$item->reconciled = 1;
|
||||||
$item->save();
|
$item->save();
|
||||||
});
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function disable($request)
|
public function unreconcile($request)
|
||||||
{
|
{
|
||||||
$reconciliations = $this->getSelectedRecords($request);
|
$reconciliations = $this->getSelectedRecords($request);
|
||||||
|
|
||||||
foreach ($reconciliations as $reconciliation) {
|
foreach ($reconciliations as $reconciliation) {
|
||||||
$reconciliation->enabled = 0;
|
\DB::transaction(function () use ($reconciliation) {
|
||||||
$reconciliation->save();
|
$reconciliation->reconciled = 0;
|
||||||
|
$reconciliation->save();
|
||||||
|
|
||||||
Transaction::where('account_id', $reconciliation->account_id)
|
Transaction::where('account_id', $reconciliation->account_id)
|
||||||
->reconciled()
|
->isReconciled()
|
||||||
->whereBetween('paid_at', [$reconciliation->started_at, $reconciliation->ended_at])->each(function ($item) {
|
->whereBetween('paid_at', [$reconciliation->started_at, $reconciliation->ended_at])->each(function ($item) {
|
||||||
$item->reconciled = 0;
|
$item->reconciled = 0;
|
||||||
$item->save();
|
$item->save();
|
||||||
});
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -67,14 +71,16 @@ class Reconciliations extends BulkAction
|
|||||||
$reconciliations = $this->getSelectedRecords($request);
|
$reconciliations = $this->getSelectedRecords($request);
|
||||||
|
|
||||||
foreach ($reconciliations as $reconciliation) {
|
foreach ($reconciliations as $reconciliation) {
|
||||||
$reconciliation->delete();
|
\DB::transaction(function () use ($reconciliation) {
|
||||||
|
$reconciliation->delete();
|
||||||
|
|
||||||
Transaction::where('account_id', $reconciliation->account_id)
|
Transaction::where('account_id', $reconciliation->account_id)
|
||||||
->reconciled()
|
->isReconciled()
|
||||||
->whereBetween('paid_at', [$reconciliation->started_at, $reconciliation->ended_at])->each(function ($item) {
|
->whereBetween('paid_at', [$reconciliation->started_at, $reconciliation->ended_at])->each(function ($item) {
|
||||||
$item->reconciled = 0;
|
$item->reconciled = 0;
|
||||||
$item->save();
|
$item->save();
|
||||||
});
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -78,8 +78,13 @@ class BillReminder extends Command
|
|||||||
$bills = Bill::with('contact')->accrued()->notPaid()->due($date)->cursor();
|
$bills = Bill::with('contact')->accrued()->notPaid()->due($date)->cursor();
|
||||||
|
|
||||||
foreach ($bills as $bill) {
|
foreach ($bills as $bill) {
|
||||||
event(new BillReminded($bill));
|
try {
|
||||||
|
event(new BillReminded($bill));
|
||||||
|
} catch (\Exception | \Throwable | \Swift_RfcComplianceException | \Illuminate\Database\QueryException $e) {
|
||||||
|
$this->error($e->getMessage());
|
||||||
|
|
||||||
|
logger('Bill reminder:: ' . $e->getMessage());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -43,6 +43,8 @@ class FinishUpdate extends Command
|
|||||||
// Check if file mirror was successful
|
// Check if file mirror was successful
|
||||||
$version = ($alias == 'core') ? version('short') : module($alias)->get('version');
|
$version = ($alias == 'core') ? version('short') : module($alias)->get('version');
|
||||||
if ($version != $new) {
|
if ($version != $new) {
|
||||||
|
logger($alias . ' update failed:: file version > ' . $version . ' -vs- ' . 'request version > ' . $new);
|
||||||
|
|
||||||
throw new \Exception(trans('modules.errors.finish', ['module' => $alias]));
|
throw new \Exception(trans('modules.errors.finish', ['module' => $alias]));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -15,6 +15,7 @@ class Install extends Command
|
|||||||
const OPT_DB_NAME = 'db-name';
|
const OPT_DB_NAME = 'db-name';
|
||||||
const OPT_DB_USERNAME = 'db-username';
|
const OPT_DB_USERNAME = 'db-username';
|
||||||
const OPT_DB_PASSWORD = 'db-password';
|
const OPT_DB_PASSWORD = 'db-password';
|
||||||
|
const OPT_DB_PREFIX = 'db-prefix';
|
||||||
const OPT_COMPANY_NAME = 'company-name';
|
const OPT_COMPANY_NAME = 'company-name';
|
||||||
const OPT_COMPANY_EMAIL = 'company-email';
|
const OPT_COMPANY_EMAIL = 'company-email';
|
||||||
const OPT_ADMIN_EMAIL = 'admin-email';
|
const OPT_ADMIN_EMAIL = 'admin-email';
|
||||||
@@ -33,6 +34,7 @@ class Install extends Command
|
|||||||
{--db-name= : Name of the database}
|
{--db-name= : Name of the database}
|
||||||
{--db-username=root : Username to use to access the database}
|
{--db-username=root : Username to use to access the database}
|
||||||
{--db-password= : Password to use to access the database}
|
{--db-password= : Password to use to access the database}
|
||||||
|
{--db-prefix= : Table name prefix}
|
||||||
{--company-name=My Company : Name of the company}
|
{--company-name=My Company : Name of the company}
|
||||||
{--company-email=my@company.com : Email of the company}
|
{--company-email=my@company.com : Email of the company}
|
||||||
{--admin-email= : Admin user email}
|
{--admin-email= : Admin user email}
|
||||||
@@ -55,7 +57,7 @@ class Install extends Command
|
|||||||
public function handle()
|
public function handle()
|
||||||
{
|
{
|
||||||
if (($missing_options = $this->getMissingOptions()) && $this->option(self::OPT_NO_INTERACTION)) {
|
if (($missing_options = $this->getMissingOptions()) && $this->option(self::OPT_NO_INTERACTION)) {
|
||||||
$this->line('❌ Some options are missing and --no-interaction is present. Please run the following command for more informations :');
|
$this->line('❌ Some options are missing and --no-interaction is present. Please run the following command for more information :');
|
||||||
$this->line('❌ php artisan help install');
|
$this->line('❌ php artisan help install');
|
||||||
$this->line('❌ Missing options are : ' . implode(', ', $missing_options));
|
$this->line('❌ Missing options are : ' . implode(', ', $missing_options));
|
||||||
|
|
||||||
@@ -102,12 +104,15 @@ class Install extends Command
|
|||||||
'OPT_DB_NAME',
|
'OPT_DB_NAME',
|
||||||
'OPT_DB_USERNAME',
|
'OPT_DB_USERNAME',
|
||||||
'OPT_DB_PASSWORD',
|
'OPT_DB_PASSWORD',
|
||||||
|
'OPT_DB_PREFIX',
|
||||||
'OPT_COMPANY_NAME',
|
'OPT_COMPANY_NAME',
|
||||||
'OPT_COMPANY_EMAIL',
|
'OPT_COMPANY_EMAIL',
|
||||||
'OPT_ADMIN_EMAIL',
|
'OPT_ADMIN_EMAIL',
|
||||||
'OPT_ADMIN_PASSWORD',
|
'OPT_ADMIN_PASSWORD'
|
||||||
];
|
];
|
||||||
|
|
||||||
|
$allowed_empty = ['db_password', 'db_prefix'];
|
||||||
|
|
||||||
foreach ($contants as $const) {
|
foreach ($contants as $const) {
|
||||||
$option = constant("self::$const");
|
$option = constant("self::$const");
|
||||||
|
|
||||||
@@ -115,14 +120,15 @@ class Install extends Command
|
|||||||
|
|
||||||
$this->$property = $this->option($option);
|
$this->$property = $this->option($option);
|
||||||
|
|
||||||
if (empty($this->$property)) {
|
if (!empty($this->$property)) {
|
||||||
// Allow empty password
|
continue;
|
||||||
if ($property == 'db_password') {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
$missing_options[] = $option;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (in_array($property, $allowed_empty)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$missing_options[] = $option;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $missing_options;
|
return $missing_options;
|
||||||
@@ -177,10 +183,11 @@ class Install extends Command
|
|||||||
$this->db_name = $this->option(self::OPT_DB_NAME);
|
$this->db_name = $this->option(self::OPT_DB_NAME);
|
||||||
$this->db_username = $this->option(self::OPT_DB_USERNAME);
|
$this->db_username = $this->option(self::OPT_DB_USERNAME);
|
||||||
$this->db_password = $this->option(self::OPT_DB_PASSWORD);
|
$this->db_password = $this->option(self::OPT_DB_PASSWORD);
|
||||||
|
$this->db_prefix = $this->option(self::OPT_DB_PREFIX);
|
||||||
|
|
||||||
$this->line('Connecting to database ' . $this->db_name . '@' . $this->db_host . ':' . $this->db_port);
|
$this->line('Connecting to database ' . $this->db_name . '@' . $this->db_host . ':' . $this->db_port);
|
||||||
|
|
||||||
if (!Installer::createDbTables($this->db_host, $this->db_port, $this->db_name, $this->db_username, $this->db_password)) {
|
if (!Installer::createDbTables($this->db_host, $this->db_port, $this->db_name, $this->db_username, $this->db_password, $this->db_prefix)) {
|
||||||
$this->error('Error: Could not connect to the database! Please, make sure the details are correct.');
|
$this->error('Error: Could not connect to the database! Please, make sure the details are correct.');
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
58
app/Console/Commands/InstallRefresh.php
Normal file
58
app/Console/Commands/InstallRefresh.php
Normal file
@@ -0,0 +1,58 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Console\Commands;
|
||||||
|
|
||||||
|
use App\Models\Auth\User;
|
||||||
|
use App\Models\Common\Company;
|
||||||
|
use Illuminate\Console\Command;
|
||||||
|
|
||||||
|
class InstallRefresh extends Command
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The name and signature of the console command.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $signature = 'install:refresh {--admin-password=123456}';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The console command description.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $description = 'Allows to refresh Akaunting installation directly through CLI';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute the console command.
|
||||||
|
*
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function handle()
|
||||||
|
{
|
||||||
|
$user = User::first();
|
||||||
|
$company = Company::first();
|
||||||
|
|
||||||
|
$this->info('Resetting migrations');
|
||||||
|
$this->callSilent('migrate:reset', [
|
||||||
|
'--force' => true,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$this->info('Installing Akaunting');
|
||||||
|
$this->callSilent('install', [
|
||||||
|
'--db-host' => env('DB_HOST'),
|
||||||
|
'--db-port' => env('DB_PORT'),
|
||||||
|
'--db-name' => env('DB_DATABASE'),
|
||||||
|
'--db-username' => env('DB_USERNAME'),
|
||||||
|
'--db-password' => env('DB_PASSWORD'),
|
||||||
|
'--db-prefix' => env('DB_PREFIX'),
|
||||||
|
'--company-name' => $company->name,
|
||||||
|
'--company-email' => $company->email,
|
||||||
|
'--admin-email' => $user->email,
|
||||||
|
'--admin-password' => $this->option('admin-password'),
|
||||||
|
'--locale' => $company->locale,
|
||||||
|
'--no-interaction' => true,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$this->info('Installation refreshed');
|
||||||
|
}
|
||||||
|
}
|
@@ -78,7 +78,13 @@ class InvoiceReminder extends Command
|
|||||||
$invoices = Invoice::with('contact')->accrued()->notPaid()->due($date)->cursor();
|
$invoices = Invoice::with('contact')->accrued()->notPaid()->due($date)->cursor();
|
||||||
|
|
||||||
foreach ($invoices as $invoice) {
|
foreach ($invoices as $invoice) {
|
||||||
event(new InvoiceReminded($invoice));
|
try {
|
||||||
|
event(new InvoiceReminded($invoice));
|
||||||
|
} catch (\Exception | \Throwable | \Swift_RfcComplianceException | \Illuminate\Database\QueryException $e) {
|
||||||
|
$this->error($e->getMessage());
|
||||||
|
|
||||||
|
logger('Invoice reminder:: ' . $e->getMessage());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -145,8 +145,15 @@ class RecurringCheck extends Command
|
|||||||
|
|
||||||
$model->cloneable_relations = ['items', 'totals'];
|
$model->cloneable_relations = ['items', 'totals'];
|
||||||
|
|
||||||
// Create new record
|
try {
|
||||||
$clone = $model->duplicate();
|
$clone = $model->duplicate();
|
||||||
|
} catch (\Exception | \Throwable | \Swift_RfcComplianceException | \Illuminate\Database\QueryException $e) {
|
||||||
|
$this->error($e->getMessage());
|
||||||
|
|
||||||
|
logger('Recurring check:: ' . $e->getMessage());
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// Set original model id
|
// Set original model id
|
||||||
$clone->parent_id = $model->id;
|
$clone->parent_id = $model->id;
|
||||||
|
54
app/Console/Commands/UninstallModule.php
Normal file
54
app/Console/Commands/UninstallModule.php
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Console\Commands;
|
||||||
|
|
||||||
|
use App\Abstracts\Commands\Module as Command;
|
||||||
|
use App\Events\Module\Uninstalled;
|
||||||
|
|
||||||
|
class UninstallModule extends Command
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The name and signature of the console command.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $signature = 'module:uninstall {alias} {company} {locale=en-GB}';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The console command description.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $description = 'Uninstall the specified module.';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute the console command.
|
||||||
|
*
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function handle()
|
||||||
|
{
|
||||||
|
$this->prepare();
|
||||||
|
|
||||||
|
if (!$this->getModel()) {
|
||||||
|
$this->info("Module [{$this->alias}] not found.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->changeRuntime();
|
||||||
|
|
||||||
|
// Delete db
|
||||||
|
$this->model->delete();
|
||||||
|
|
||||||
|
$this->createHistory('uninstalled');
|
||||||
|
|
||||||
|
event(new Uninstalled($this->alias, $this->company_id));
|
||||||
|
|
||||||
|
// Delete files
|
||||||
|
$this->module->delete();
|
||||||
|
|
||||||
|
$this->revertRuntime();
|
||||||
|
|
||||||
|
$this->info("Module [{$this->alias}] uninstalled.");
|
||||||
|
}
|
||||||
|
}
|
@@ -61,7 +61,7 @@ class UpdateAll extends Command
|
|||||||
|
|
||||||
$command = "update {$alias} {$company_id}";
|
$command = "update {$alias} {$company_id}";
|
||||||
|
|
||||||
if (true !== $result = Console::run($command, true)) {
|
if (true !== $result = Console::run($command)) {
|
||||||
$message = !empty($result) ? $result : trans('modules.errors.finish', ['module' => $alias]);
|
$message = !empty($result) ? $result : trans('modules.errors.finish', ['module' => $alias]);
|
||||||
|
|
||||||
$this->error($message);
|
$this->error($message);
|
||||||
|
@@ -2,7 +2,6 @@
|
|||||||
"alias": "$ALIAS$",
|
"alias": "$ALIAS$",
|
||||||
"icon": "fa fa-cog",
|
"icon": "fa fa-cog",
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"category": "accounting",
|
|
||||||
"active": 1,
|
"active": 1,
|
||||||
"providers": [
|
"providers": [
|
||||||
"$MODULE_NAMESPACE$\\$STUDLY_NAME$\\Providers\\Event",
|
"$MODULE_NAMESPACE$\\$STUDLY_NAME$\\Providers\\Event",
|
||||||
|
@@ -4,6 +4,7 @@ namespace $MODULE_NAMESPACE$\$STUDLY_NAME$\Listeners;
|
|||||||
|
|
||||||
use App\Events\Module\Installed as Event;
|
use App\Events\Module\Installed as Event;
|
||||||
use App\Traits\Permissions;
|
use App\Traits\Permissions;
|
||||||
|
use Artisan;
|
||||||
|
|
||||||
class FinishInstallation
|
class FinishInstallation
|
||||||
{
|
{
|
||||||
@@ -24,6 +25,8 @@ class FinishInstallation
|
|||||||
}
|
}
|
||||||
|
|
||||||
$this->updatePermissions();
|
$this->updatePermissions();
|
||||||
|
|
||||||
|
//$this->callSeeds();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function updatePermissions()
|
protected function updatePermissions()
|
||||||
@@ -33,4 +36,12 @@ class FinishInstallation
|
|||||||
$this->alias . '-main' => 'c,r,u,d',
|
$this->alias . '-main' => 'c,r,u,d',
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function callSeeds()
|
||||||
|
{
|
||||||
|
Artisan::call('company:seed', [
|
||||||
|
'company' => session('company_id'),
|
||||||
|
'--class' => 'Modules\$STUDLY_NAME$\Database\Seeds\$STUDLY_NAME$DatabaseSeeder',
|
||||||
|
]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -10,8 +10,8 @@
|
|||||||
"production": "cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --no-progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js"
|
"production": "cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --no-progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"cross-env": "^5.1.4",
|
"cross-env": "^5.2.1",
|
||||||
"laravel-mix": "^4.0.7",
|
"laravel-mix": "^4.1.4",
|
||||||
"laravel-mix-merge-manifest": "^0.1.2"
|
"laravel-mix-merge-manifest": "^0.1.2"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -3,18 +3,28 @@
|
|||||||
namespace $MODULE_NAMESPACE$\$STUDLY_NAME$\Providers;
|
namespace $MODULE_NAMESPACE$\$STUDLY_NAME$\Providers;
|
||||||
|
|
||||||
use Illuminate\Foundation\Support\Providers\EventServiceProvider as Provider;
|
use Illuminate\Foundation\Support\Providers\EventServiceProvider as Provider;
|
||||||
use $MODULE_NAMESPACE$\$STUDLY_NAME$\Listeners\FinishInstallation;
|
|
||||||
|
|
||||||
class Event extends Provider
|
class Event extends Provider
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* The event listener mappings for the module.
|
* Determine if events and listeners should be automatically discovered.
|
||||||
*
|
*
|
||||||
* @var array
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected $listen = [
|
public function shouldDiscoverEvents()
|
||||||
\App\Events\Module\Installed::class => [
|
{
|
||||||
FinishInstallation::class,
|
return true;
|
||||||
],
|
}
|
||||||
];
|
|
||||||
|
/**
|
||||||
|
* Get the listener directories that should be used to discover events.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
protected function discoverEventsWithin()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
__DIR__ . '/../Listeners',
|
||||||
|
];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -2,9 +2,9 @@
|
|||||||
|
|
||||||
namespace $NAMESPACE$;
|
namespace $NAMESPACE$;
|
||||||
|
|
||||||
use Illuminate\Http\Resources\Json\Resource;
|
use Illuminate\Http\Resources\Json\JsonResource;
|
||||||
|
|
||||||
class $CLASS$ extends Resource
|
class $CLASS$ extends JsonResource
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Transform the resource into an array.
|
* Transform the resource into an array.
|
||||||
|
22
app/Events/Auth/LandingPageShowing.php
Normal file
22
app/Events/Auth/LandingPageShowing.php
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Events\Auth;
|
||||||
|
|
||||||
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
|
||||||
|
class LandingPageShowing
|
||||||
|
{
|
||||||
|
use SerializesModels;
|
||||||
|
|
||||||
|
public $user;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new event instance.
|
||||||
|
*
|
||||||
|
* @param $user
|
||||||
|
*/
|
||||||
|
public function __construct($user)
|
||||||
|
{
|
||||||
|
$this->user = $user;
|
||||||
|
}
|
||||||
|
}
|
22
app/Events/Install/UpdateCacheCleared.php
Normal file
22
app/Events/Install/UpdateCacheCleared.php
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Events\Install;
|
||||||
|
|
||||||
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
|
||||||
|
class UpdateCacheCleared
|
||||||
|
{
|
||||||
|
use SerializesModels;
|
||||||
|
|
||||||
|
public $company_id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new event instance.
|
||||||
|
*
|
||||||
|
* @param $company_id
|
||||||
|
*/
|
||||||
|
public function __construct($company_id)
|
||||||
|
{
|
||||||
|
$this->company_id = $company_id;
|
||||||
|
}
|
||||||
|
}
|
@@ -4,7 +4,7 @@ namespace App\Events\Module;
|
|||||||
|
|
||||||
use Illuminate\Queue\SerializesModels;
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
|
||||||
class Deleted
|
class Copied
|
||||||
{
|
{
|
||||||
use SerializesModels;
|
use SerializesModels;
|
||||||
|
|
26
app/Events/Module/Uninstalled.php
Normal file
26
app/Events/Module/Uninstalled.php
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Events\Module;
|
||||||
|
|
||||||
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
|
||||||
|
class Uninstalled
|
||||||
|
{
|
||||||
|
use SerializesModels;
|
||||||
|
|
||||||
|
public $alias;
|
||||||
|
|
||||||
|
public $company_id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new event instance.
|
||||||
|
*
|
||||||
|
* @param $alias
|
||||||
|
* @param $company_id
|
||||||
|
*/
|
||||||
|
public function __construct($alias, $company_id)
|
||||||
|
{
|
||||||
|
$this->alias = $alias;
|
||||||
|
$this->company_id = $company_id;
|
||||||
|
}
|
||||||
|
}
|
22
app/Events/Report/DataLoaded.php
Normal file
22
app/Events/Report/DataLoaded.php
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Events\Report;
|
||||||
|
|
||||||
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
|
||||||
|
class DataLoaded
|
||||||
|
{
|
||||||
|
use SerializesModels;
|
||||||
|
|
||||||
|
public $class;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new event instance.
|
||||||
|
*
|
||||||
|
* @param $class
|
||||||
|
*/
|
||||||
|
public function __construct($class)
|
||||||
|
{
|
||||||
|
$this->class = $class;
|
||||||
|
}
|
||||||
|
}
|
22
app/Events/Report/DataLoading.php
Normal file
22
app/Events/Report/DataLoading.php
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Events\Report;
|
||||||
|
|
||||||
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
|
||||||
|
class DataLoading
|
||||||
|
{
|
||||||
|
use SerializesModels;
|
||||||
|
|
||||||
|
public $class;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new event instance.
|
||||||
|
*
|
||||||
|
* @param $class
|
||||||
|
*/
|
||||||
|
public function __construct($class)
|
||||||
|
{
|
||||||
|
$this->class = $class;
|
||||||
|
}
|
||||||
|
}
|
22
app/Events/Sale/InvoicePaidCalculated.php
Normal file
22
app/Events/Sale/InvoicePaidCalculated.php
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Events\Sale;
|
||||||
|
|
||||||
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
|
||||||
|
class InvoicePaidCalculated
|
||||||
|
{
|
||||||
|
use SerializesModels;
|
||||||
|
|
||||||
|
public $invoice;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new event instance.
|
||||||
|
*
|
||||||
|
* @param $invoice
|
||||||
|
*/
|
||||||
|
public function __construct($invoice)
|
||||||
|
{
|
||||||
|
$this->invoice = $invoice;
|
||||||
|
}
|
||||||
|
}
|
@@ -9,7 +9,7 @@ class Transactions extends Export
|
|||||||
{
|
{
|
||||||
public function collection()
|
public function collection()
|
||||||
{
|
{
|
||||||
$model = Model::with(['account', 'bill', 'category', 'contact', 'invoice'])->usingSearchString(request('search'));
|
$model = Model::with('account', 'bill', 'category', 'contact', 'invoice')->usingSearchString(request('search'));
|
||||||
|
|
||||||
if (!empty($this->ids)) {
|
if (!empty($this->ids)) {
|
||||||
$model->whereIn('id', (array) $this->ids);
|
$model->whereIn('id', (array) $this->ids);
|
||||||
|
@@ -9,7 +9,7 @@ class Items extends Export
|
|||||||
{
|
{
|
||||||
public function collection()
|
public function collection()
|
||||||
{
|
{
|
||||||
$model = Model::with(['category', 'tax'])->usingSearchString(request('search'));
|
$model = Model::with('category', 'tax')->usingSearchString(request('search'));
|
||||||
|
|
||||||
if (!empty($this->ids)) {
|
if (!empty($this->ids)) {
|
||||||
$model->whereIn('id', (array) $this->ids);
|
$model->whereIn('id', (array) $this->ids);
|
||||||
|
@@ -9,7 +9,7 @@ class Payments extends Export
|
|||||||
{
|
{
|
||||||
public function collection()
|
public function collection()
|
||||||
{
|
{
|
||||||
$model = Model::with(['account', 'bill', 'category', 'contact'])->expense()->usingSearchString(request('search'));
|
$model = Model::with('account', 'bill', 'category', 'contact')->expense()->usingSearchString(request('search'));
|
||||||
|
|
||||||
if (!empty($this->ids)) {
|
if (!empty($this->ids)) {
|
||||||
$model->whereIn('id', (array) $this->ids);
|
$model->whereIn('id', (array) $this->ids);
|
||||||
|
@@ -9,7 +9,7 @@ class BillHistories extends Export
|
|||||||
{
|
{
|
||||||
public function collection()
|
public function collection()
|
||||||
{
|
{
|
||||||
$model = Model::with(['bill'])->usingSearchString(request('search'));
|
$model = Model::with('bill')->usingSearchString(request('search'));
|
||||||
|
|
||||||
if (!empty($this->ids)) {
|
if (!empty($this->ids)) {
|
||||||
$model->whereIn('bill_id', (array) $this->ids);
|
$model->whereIn('bill_id', (array) $this->ids);
|
||||||
|
@@ -9,7 +9,7 @@ class BillItemTaxes extends Export
|
|||||||
{
|
{
|
||||||
public function collection()
|
public function collection()
|
||||||
{
|
{
|
||||||
$model = Model::with(['bill', 'item', 'tax'])->usingSearchString(request('search'));
|
$model = Model::with('bill', 'item', 'tax')->usingSearchString(request('search'));
|
||||||
|
|
||||||
if (!empty($this->ids)) {
|
if (!empty($this->ids)) {
|
||||||
$model->whereIn('bill_id', (array) $this->ids);
|
$model->whereIn('bill_id', (array) $this->ids);
|
||||||
|
@@ -9,7 +9,7 @@ class BillItems extends Export
|
|||||||
{
|
{
|
||||||
public function collection()
|
public function collection()
|
||||||
{
|
{
|
||||||
$model = Model::with(['bill', 'item'])->usingSearchString(request('search'));
|
$model = Model::with('bill', 'item')->usingSearchString(request('search'));
|
||||||
|
|
||||||
if (!empty($this->ids)) {
|
if (!empty($this->ids)) {
|
||||||
$model->whereIn('bill_id', (array) $this->ids);
|
$model->whereIn('bill_id', (array) $this->ids);
|
||||||
|
@@ -9,7 +9,7 @@ class BillTotals extends Export
|
|||||||
{
|
{
|
||||||
public function collection()
|
public function collection()
|
||||||
{
|
{
|
||||||
$model = Model::with(['bill'])->usingSearchString(request('search'));
|
$model = Model::with('bill')->usingSearchString(request('search'));
|
||||||
|
|
||||||
if (!empty($this->ids)) {
|
if (!empty($this->ids)) {
|
||||||
$model->whereIn('bill_id', (array) $this->ids);
|
$model->whereIn('bill_id', (array) $this->ids);
|
||||||
|
@@ -9,7 +9,7 @@ class BillTransactions extends Export
|
|||||||
{
|
{
|
||||||
public function collection()
|
public function collection()
|
||||||
{
|
{
|
||||||
$model = Model::with(['account', 'category', 'contact', 'bill'])->expense()->isDocument()->usingSearchString(request('search'));
|
$model = Model::with('account', 'category', 'contact', 'bill')->expense()->isDocument()->usingSearchString(request('search'));
|
||||||
|
|
||||||
if (!empty($this->ids)) {
|
if (!empty($this->ids)) {
|
||||||
$model->whereIn('document_id', (array) $this->ids);
|
$model->whereIn('document_id', (array) $this->ids);
|
||||||
|
@@ -9,7 +9,7 @@ class Bills extends Export
|
|||||||
{
|
{
|
||||||
public function collection()
|
public function collection()
|
||||||
{
|
{
|
||||||
$model = Model::with(['category'])->usingSearchString(request('search'));
|
$model = Model::with('category')->usingSearchString(request('search'));
|
||||||
|
|
||||||
if (!empty($this->ids)) {
|
if (!empty($this->ids)) {
|
||||||
$model->whereIn('id', (array) $this->ids);
|
$model->whereIn('id', (array) $this->ids);
|
||||||
|
@@ -9,7 +9,7 @@ class Revenues extends Export
|
|||||||
{
|
{
|
||||||
public function collection()
|
public function collection()
|
||||||
{
|
{
|
||||||
$model = Model::with(['account', 'category', 'contact', 'invoice'])->income()->usingSearchString(request('search'));
|
$model = Model::with('account', 'category', 'contact', 'invoice')->income()->usingSearchString(request('search'));
|
||||||
|
|
||||||
if (!empty($this->ids)) {
|
if (!empty($this->ids)) {
|
||||||
$model->whereIn('id', (array) $this->ids);
|
$model->whereIn('id', (array) $this->ids);
|
||||||
|
@@ -9,7 +9,7 @@ class InvoiceHistories extends Export
|
|||||||
{
|
{
|
||||||
public function collection()
|
public function collection()
|
||||||
{
|
{
|
||||||
$model = Model::with(['invoice'])->usingSearchString(request('search'));
|
$model = Model::with('invoice')->usingSearchString(request('search'));
|
||||||
|
|
||||||
if (!empty($this->ids)) {
|
if (!empty($this->ids)) {
|
||||||
$model->whereIn('invoice_id', (array) $this->ids);
|
$model->whereIn('invoice_id', (array) $this->ids);
|
||||||
|
@@ -9,7 +9,7 @@ class InvoiceItemTaxes extends Export
|
|||||||
{
|
{
|
||||||
public function collection()
|
public function collection()
|
||||||
{
|
{
|
||||||
$model = Model::with(['invoice', 'item', 'tax'])->usingSearchString(request('search'));
|
$model = Model::with('invoice', 'item', 'tax')->usingSearchString(request('search'));
|
||||||
|
|
||||||
if (!empty($this->ids)) {
|
if (!empty($this->ids)) {
|
||||||
$model->whereIn('invoice_id', (array) $this->ids);
|
$model->whereIn('invoice_id', (array) $this->ids);
|
||||||
|
@@ -9,7 +9,7 @@ class InvoiceItems extends Export
|
|||||||
{
|
{
|
||||||
public function collection()
|
public function collection()
|
||||||
{
|
{
|
||||||
$model = Model::with(['invoice', 'item'])->usingSearchString(request('search'));
|
$model = Model::with('invoice', 'item')->usingSearchString(request('search'));
|
||||||
|
|
||||||
if (!empty($this->ids)) {
|
if (!empty($this->ids)) {
|
||||||
$model->whereIn('invoice_id', (array) $this->ids);
|
$model->whereIn('invoice_id', (array) $this->ids);
|
||||||
|
@@ -9,7 +9,7 @@ class InvoiceTotals extends Export
|
|||||||
{
|
{
|
||||||
public function collection()
|
public function collection()
|
||||||
{
|
{
|
||||||
$model = Model::with(['invoice'])->usingSearchString(request('search'));
|
$model = Model::with('invoice')->usingSearchString(request('search'));
|
||||||
|
|
||||||
if (!empty($this->ids)) {
|
if (!empty($this->ids)) {
|
||||||
$model->whereIn('invoice_id', (array) $this->ids);
|
$model->whereIn('invoice_id', (array) $this->ids);
|
||||||
|
@@ -9,7 +9,7 @@ class InvoiceTransactions extends Export
|
|||||||
{
|
{
|
||||||
public function collection()
|
public function collection()
|
||||||
{
|
{
|
||||||
$model = Model::with(['account', 'category', 'contact', 'invoice'])->income()->isDocument()->usingSearchString(request('search'));
|
$model = Model::with('account', 'category', 'contact', 'invoice')->income()->isDocument()->usingSearchString(request('search'));
|
||||||
|
|
||||||
if (!empty($this->ids)) {
|
if (!empty($this->ids)) {
|
||||||
$model->whereIn('document_id', (array) $this->ids);
|
$model->whereIn('document_id', (array) $this->ids);
|
||||||
|
@@ -9,7 +9,7 @@ class Invoices extends Export
|
|||||||
{
|
{
|
||||||
public function collection()
|
public function collection()
|
||||||
{
|
{
|
||||||
$model = Model::with(['category'])->usingSearchString(request('search'));
|
$model = Model::with('category')->usingSearchString(request('search'));
|
||||||
|
|
||||||
if (!empty($this->ids)) {
|
if (!empty($this->ids)) {
|
||||||
$model->whereIn('id', (array) $this->ids);
|
$model->whereIn('id', (array) $this->ids);
|
||||||
|
@@ -45,7 +45,7 @@ class Permissions extends ApiController
|
|||||||
{
|
{
|
||||||
$permission = $this->dispatch(new CreatePermission($request));
|
$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));
|
$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()
|
public function index()
|
||||||
{
|
{
|
||||||
$users = User::with(['companies', 'roles', 'permissions'])->collect();
|
$users = User::with('companies', 'permissions', 'roles')->collect();
|
||||||
|
|
||||||
return $this->response->paginator($users, new Transformer());
|
return $this->response->paginator($users, new Transformer());
|
||||||
}
|
}
|
||||||
@@ -34,9 +34,9 @@ class Users extends ApiController
|
|||||||
{
|
{
|
||||||
// Check if we're querying by id or email
|
// Check if we're querying by id or email
|
||||||
if (is_numeric($id)) {
|
if (is_numeric($id)) {
|
||||||
$user = User::with(['companies', 'roles', 'permissions'])->find($id);
|
$user = User::with('companies', 'permissions', 'roles')->find($id);
|
||||||
} else {
|
} 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());
|
return $this->response->item($user, new Transformer());
|
||||||
@@ -52,7 +52,7 @@ class Users extends ApiController
|
|||||||
{
|
{
|
||||||
$user = $this->dispatch(new CreateUser($request));
|
$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));
|
$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()
|
public function index()
|
||||||
{
|
{
|
||||||
$items = Reconciliation::with(['account'])->collect();
|
$items = Reconciliation::with('account')->collect();
|
||||||
|
|
||||||
return $this->response->paginator($items, new Transformer());
|
return $this->response->paginator($items, new Transformer());
|
||||||
}
|
}
|
||||||
@@ -45,7 +45,7 @@ class Reconciliations extends ApiController
|
|||||||
{
|
{
|
||||||
$reconciliation = $this->dispatch(new CreateReconciliation($request));
|
$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()
|
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());
|
return $this->response->paginator($transactions, new Transformer());
|
||||||
}
|
}
|
||||||
@@ -45,7 +45,7 @@ class Transactions extends ApiController
|
|||||||
{
|
{
|
||||||
$transaction = $this->dispatch(new CreateTransaction($request));
|
$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()
|
public function index()
|
||||||
{
|
{
|
||||||
$transfers = Transfer::with([
|
$transfers = Transfer::with(
|
||||||
'expense_transaction', 'expense_transaction.account', 'income_transaction', 'income_transaction.account'
|
'expense_transaction', 'expense_transaction.account', 'income_transaction', 'income_transaction.account'
|
||||||
])->collect('expense_transaction.paid_at');
|
)->collect('expense_transaction.paid_at');
|
||||||
|
|
||||||
$special_key = [
|
$special_key = [
|
||||||
'expense_transaction.name' => 'from_account',
|
'expense_transaction.name' => 'from_account',
|
||||||
@@ -75,7 +75,7 @@ class Transfers extends ApiController
|
|||||||
{
|
{
|
||||||
$transfer = $this->dispatch(new CreateTransfer($request));
|
$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));
|
$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()
|
public function __construct()
|
||||||
{
|
{
|
||||||
// Add CRUD permission check
|
// Add CRUD permission check
|
||||||
$this->middleware('permission:create-sales-customers')->only(['create', 'store', 'duplicate', 'import']);
|
$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:read-sales-customers')->only('index', 'show', 'edit', 'export');
|
||||||
$this->middleware('permission:update-sales-customers')->only(['update', 'enable', 'disable']);
|
$this->middleware('permission:update-sales-customers')->only('update', 'enable', 'disable');
|
||||||
$this->middleware('permission:delete-sales-customers')->only('destroy');
|
$this->middleware('permission:delete-sales-customers')->only('destroy');
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -67,7 +67,7 @@ class Contacts extends ApiController
|
|||||||
{
|
{
|
||||||
$contact = $this->dispatch(new CreateContact($request));
|
$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()
|
public function index()
|
||||||
{
|
{
|
||||||
$items = Item::with(['category', 'tax'])->collect();
|
$items = Item::with('category', 'tax')->collect();
|
||||||
|
|
||||||
return $this->response->paginator($items, new Transformer());
|
return $this->response->paginator($items, new Transformer());
|
||||||
}
|
}
|
||||||
@@ -35,7 +35,7 @@ class Items extends ApiController
|
|||||||
*/
|
*/
|
||||||
public function show($id)
|
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());
|
return $this->response->item($item, new Transformer());
|
||||||
}
|
}
|
||||||
@@ -50,7 +50,7 @@ class Items extends ApiController
|
|||||||
{
|
{
|
||||||
$item = $this->dispatch(new CreateItem($request));
|
$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));
|
$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()
|
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());
|
return $this->response->paginator($bills, new Transformer());
|
||||||
}
|
}
|
||||||
@@ -45,7 +45,7 @@ class Bills extends ApiController
|
|||||||
{
|
{
|
||||||
$bill = $this->dispatch(new CreateBill($request));
|
$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()
|
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());
|
return $this->response->paginator($invoices, new Transformer());
|
||||||
}
|
}
|
||||||
@@ -52,7 +52,7 @@ class Invoices extends ApiController
|
|||||||
{
|
{
|
||||||
$invoice = $this->dispatch(new CreateInvoice($request));
|
$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));
|
$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));
|
$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());
|
$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));
|
$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);
|
return response()->json($response);
|
||||||
}
|
}
|
||||||
|
|
||||||
session(['dashboard_id' => $user->dashboards()->enabled()->pluck('id')->first()]);
|
|
||||||
|
|
||||||
$response = [
|
$response = [
|
||||||
'status' => null,
|
'status' => null,
|
||||||
'success' => true,
|
'success' => true,
|
||||||
|
@@ -3,6 +3,7 @@
|
|||||||
namespace App\Http\Controllers\Auth;
|
namespace App\Http\Controllers\Auth;
|
||||||
|
|
||||||
use App\Abstracts\Http\Controller;
|
use App\Abstracts\Http\Controller;
|
||||||
|
use App\Events\Auth\LandingPageShowing;
|
||||||
use App\Http\Requests\Auth\User as Request;
|
use App\Http\Requests\Auth\User as Request;
|
||||||
use App\Jobs\Auth\CreateUser;
|
use App\Jobs\Auth\CreateUser;
|
||||||
use App\Jobs\Auth\DeleteUser;
|
use App\Jobs\Auth\DeleteUser;
|
||||||
@@ -16,6 +17,17 @@ class Users extends Controller
|
|||||||
{
|
{
|
||||||
use Uploads;
|
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.
|
* Display a listing of the resource.
|
||||||
*
|
*
|
||||||
@@ -23,7 +35,7 @@ class Users extends Controller
|
|||||||
*/
|
*/
|
||||||
public function index()
|
public function index()
|
||||||
{
|
{
|
||||||
$users = User::with('roles')->collect();
|
$users = User::with('media', 'roles')->collect();
|
||||||
|
|
||||||
return view('auth.users.index', compact('users'));
|
return view('auth.users.index', compact('users'));
|
||||||
}
|
}
|
||||||
@@ -35,33 +47,20 @@ class Users extends Controller
|
|||||||
*/
|
*/
|
||||||
public function create()
|
public function create()
|
||||||
{
|
{
|
||||||
$routes = [
|
$u = new \stdClass();
|
||||||
'dashboard' => trans_choice('general.dashboards', 1),
|
$u->landing_pages = [];
|
||||||
'items.index' => trans_choice('general.items', 2),
|
|
||||||
'invoices.index' => trans_choice('general.invoices', 2),
|
event(new LandingPageShowing($u));
|
||||||
'revenues.index' => trans_choice('general.revenues', 2),
|
|
||||||
'customers.index' => trans_choice('general.customers', 2),
|
$landing_pages = $u->landing_pages;
|
||||||
'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),
|
|
||||||
];
|
|
||||||
|
|
||||||
$roles = Role::all()->reject(function ($r) {
|
$roles = Role::all()->reject(function ($r) {
|
||||||
return $r->hasPermission('read-client-portal');
|
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)
|
public function edit(User $user)
|
||||||
{
|
{
|
||||||
$routes = [
|
if (user()->cannot('read-auth-users') && ($user->id != user()->id)) {
|
||||||
'dashboard' => trans_choice('general.dashboards', 1),
|
abort(403);
|
||||||
'items.index' => trans_choice('general.items', 2),
|
}
|
||||||
'invoices.index' => trans_choice('general.invoices', 2),
|
|
||||||
'revenues.index' => trans_choice('general.revenues', 2),
|
$u = new \stdClass();
|
||||||
'customers.index' => trans_choice('general.customers', 2),
|
$u->landing_pages = [];
|
||||||
'bills.index' => trans_choice('general.bills', 2),
|
|
||||||
'payments.index' => trans_choice('general.payments', 2),
|
event(new LandingPageShowing($u));
|
||||||
'vendors.index' => trans_choice('general.vendors', 2),
|
|
||||||
'accounts.index' => trans_choice('general.accounts', 2),
|
$landing_pages = $u->landing_pages;
|
||||||
'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->can('read-client-portal')) {
|
if ($user->can('read-client-portal')) {
|
||||||
// Show only roles with customer permission
|
// 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)
|
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));
|
$response = $this->ajaxDispatch(new UpdateUser($user, $request));
|
||||||
|
|
||||||
if ($response['success']) {
|
if ($response['success']) {
|
||||||
|
@@ -28,7 +28,7 @@ class Transactions extends Controller
|
|||||||
$request_type = !request()->has('type') ? ['income', 'expense'] : request('type');
|
$request_type = !request()->has('type') ? ['income', 'expense'] : request('type');
|
||||||
$categories = Category::enabled()->type($request_type)->orderBy('name')->pluck('name', 'id');
|
$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'));
|
return view('banking.transactions.index', compact('transactions', 'accounts', 'types', 'categories'));
|
||||||
}
|
}
|
||||||
|
@@ -24,9 +24,9 @@ class Transfers extends Controller
|
|||||||
{
|
{
|
||||||
$data = [];
|
$data = [];
|
||||||
|
|
||||||
$items = Transfer::with([
|
$items = Transfer::with(
|
||||||
'expense_transaction', 'expense_transaction.account', 'income_transaction', 'income_transaction.account'
|
'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) {
|
foreach ($items as $item) {
|
||||||
$income_transaction = $item->income_transaction;
|
$income_transaction = $item->income_transaction;
|
||||||
|
@@ -4,6 +4,7 @@ namespace App\Http\Controllers\Common;
|
|||||||
|
|
||||||
use App\Abstracts\Http\Controller;
|
use App\Abstracts\Http\Controller;
|
||||||
use App\Http\Requests\Common\BulkAction as Request;
|
use App\Http\Requests\Common\BulkAction as Request;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
class
|
class
|
||||||
|
|
||||||
@@ -34,7 +35,10 @@ BulkActions extends Controller
|
|||||||
$module = module($group);
|
$module = module($group);
|
||||||
|
|
||||||
if ($module instanceof \Akaunting\Module\Module) {
|
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 {
|
} else {
|
||||||
$bulk_actions = app('App\BulkActions\\' . ucfirst($group) . '\\' . ucfirst($type));
|
$bulk_actions = app('App\BulkActions\\' . ucfirst($group) . '\\' . ucfirst($type));
|
||||||
}
|
}
|
||||||
|
@@ -213,7 +213,7 @@ class Companies extends Controller
|
|||||||
$old_company_id = session('company_id');
|
$old_company_id = session('company_id');
|
||||||
|
|
||||||
session(['company_id' => $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');
|
Overrider::load('settings');
|
||||||
|
|
||||||
@@ -227,4 +227,23 @@ class Companies extends Controller
|
|||||||
|
|
||||||
return redirect()->route('dashboard');
|
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()
|
public function __construct()
|
||||||
{
|
{
|
||||||
// Add CRUD permission check
|
// Add CRUD permission check
|
||||||
$this->middleware('permission:create-common-dashboards')->only(['create', 'store', 'duplicate', 'import']);
|
$this->middleware('permission:create-common-dashboards')->only('create', 'store', 'duplicate', 'import');
|
||||||
$this->middleware('permission:read-common-dashboards')->only(['show']);
|
$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:update-common-dashboards')->only('index', 'edit', 'export', 'update', 'enable', 'disable', 'share');
|
||||||
$this->middleware('permission:delete-common-dashboards')->only('destroy');
|
$this->middleware('permission:delete-common-dashboards')->only('destroy');
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -51,12 +51,10 @@ class Dashboards extends Controller
|
|||||||
{
|
{
|
||||||
$dashboard_id = $dashboard_id ?? session('dashboard_id');
|
$dashboard_id = $dashboard_id ?? session('dashboard_id');
|
||||||
|
|
||||||
if (empty($dashboard_id)) {
|
|
||||||
$dashboard_id = user()->dashboards()->enabled()->pluck('id')->first();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!empty($dashboard_id)) {
|
if (!empty($dashboard_id)) {
|
||||||
$dashboard = Dashboard::find($dashboard_id);
|
$dashboard = Dashboard::find($dashboard_id);
|
||||||
|
} else {
|
||||||
|
$dashboard = user()->dashboards()->enabled()->first();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (empty($dashboard)) {
|
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) {
|
$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');
|
$financial_start = $this->getFinancialStart()->format('Y-m-d');
|
||||||
@@ -215,7 +215,7 @@ class Dashboards extends Controller
|
|||||||
|
|
||||||
flash($message)->success();
|
flash($message)->success();
|
||||||
|
|
||||||
session(['dashboard_id' => user()->dashboards()->pluck('id')->first()]);
|
session(['dashboard_id' => user()->dashboards()->enabled()->pluck('id')->first()]);
|
||||||
} else {
|
} else {
|
||||||
$message = $response['message'];
|
$message = $response['message'];
|
||||||
|
|
||||||
|
@@ -28,7 +28,7 @@ class Items extends Controller
|
|||||||
*/
|
*/
|
||||||
public function index()
|
public function index()
|
||||||
{
|
{
|
||||||
$items = Item::with(['category', 'tax'])->collect();
|
$items = Item::with('category', 'media')->collect();
|
||||||
|
|
||||||
return view('common.items.index', compact('items'));
|
return view('common.items.index', compact('items'));
|
||||||
}
|
}
|
||||||
|
@@ -25,7 +25,7 @@ class Reports extends Controller
|
|||||||
$reports = Report::orderBy('name')->get();
|
$reports = Report::orderBy('name')->get();
|
||||||
|
|
||||||
foreach ($reports as $report) {
|
foreach ($reports as $report) {
|
||||||
if (!Utility::canRead($report->class)) {
|
if (!Utility::canShow($report->class)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -56,7 +56,7 @@ class Reports extends Controller
|
|||||||
*/
|
*/
|
||||||
public function show(Report $report)
|
public function show(Report $report)
|
||||||
{
|
{
|
||||||
if (!Utility::canRead($report->class)) {
|
if (!Utility::canShow($report->class)) {
|
||||||
abort(403);
|
abort(403);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -203,7 +203,7 @@ class Reports extends Controller
|
|||||||
*/
|
*/
|
||||||
public function print(Report $report)
|
public function print(Report $report)
|
||||||
{
|
{
|
||||||
if (!Utility::canRead($report->class)) {
|
if (!Utility::canShow($report->class)) {
|
||||||
abort(403);
|
abort(403);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -218,7 +218,7 @@ class Reports extends Controller
|
|||||||
*/
|
*/
|
||||||
public function export(Report $report)
|
public function export(Report $report)
|
||||||
{
|
{
|
||||||
if (!Utility::canRead($report->class)) {
|
if (!Utility::canShow($report->class)) {
|
||||||
abort(403);
|
abort(403);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -263,7 +263,7 @@ class Reports extends Controller
|
|||||||
public function clear()
|
public function clear()
|
||||||
{
|
{
|
||||||
Report::all()->each(function ($report) {
|
Report::all()->each(function ($report) {
|
||||||
if (!Utility::canRead($report->class)) {
|
if (!Utility::canShow($report->class)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -64,8 +64,9 @@ class Search extends Controller
|
|||||||
'href' => route('invoices.show', $invoice->id),
|
'href' => route('invoices.show', $invoice->id),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}/*
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
$income_transactions = Transaction::income()->usingSearchString($keyword)->get();
|
$income_transactions = Transaction::income()->usingSearchString($keyword)->get();
|
||||||
|
|
||||||
if ($income_transactions->count()) {
|
if ($income_transactions->count()) {
|
||||||
@@ -78,7 +79,8 @@ class Search extends Controller
|
|||||||
'href' => url('sales/revenues/' . $transaction->id),
|
'href' => url('sales/revenues/' . $transaction->id),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}*/
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
$customers = Contact::customer()->enabled()->usingSearchString($search->keyword)->get();
|
$customers = Contact::customer()->enabled()->usingSearchString($search->keyword)->get();
|
||||||
|
|
||||||
@@ -107,7 +109,8 @@ class Search extends Controller
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
|
/*
|
||||||
$payments = Transaction::expense()->usingSearchString($keyword)->get();
|
$payments = Transaction::expense()->usingSearchString($keyword)->get();
|
||||||
|
|
||||||
if ($revenues->count()) {
|
if ($revenues->count()) {
|
||||||
@@ -120,7 +123,8 @@ class Search extends Controller
|
|||||||
'href' => url('sales/revenues/' . $revenue->id),
|
'href' => url('sales/revenues/' . $revenue->id),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}*/
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
$vendors = Contact::vendor()->enabled()->usingSearchString($search->keyword)->get();
|
$vendors = Contact::vendor()->enabled()->usingSearchString($search->keyword)->get();
|
||||||
|
|
||||||
|
@@ -121,10 +121,21 @@ class Uploads extends Controller
|
|||||||
*/
|
*/
|
||||||
public function destroy($id, Request $request)
|
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 {
|
try {
|
||||||
$media = Media::find($id);
|
$media = Media::find($id);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
return back();
|
return $return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get file path
|
// Get file path
|
||||||
@@ -133,7 +144,7 @@ class Uploads extends Controller
|
|||||||
|
|
||||||
flash($message)->warning();
|
flash($message)->warning();
|
||||||
|
|
||||||
return back();
|
return $return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$media->delete(); //will not delete files
|
$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 = new \stdClass();
|
||||||
$m->name = $row->getName();
|
$m->name = $row->getName();
|
||||||
$m->alias = $row->get('alias');
|
$m->alias = $row->get('alias');
|
||||||
$m->category = $row->get('category');
|
|
||||||
$m->installed = $row->get('version');
|
$m->installed = $row->get('version');
|
||||||
$m->latest = $updates[$alias];
|
$m->latest = $updates[$alias];
|
||||||
|
|
||||||
|
@@ -16,9 +16,9 @@ class Accounts extends Controller
|
|||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
// Add CRUD permission check
|
// Add CRUD permission check
|
||||||
$this->middleware('permission:create-banking-accounts')->only(['create', 'store', 'duplicate', 'import']);
|
$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:read-banking-accounts')->only('index', 'show', 'edit', 'export');
|
||||||
$this->middleware('permission:update-banking-accounts')->only(['update', 'enable', 'disable']);
|
$this->middleware('permission:update-banking-accounts')->only('update', 'enable', 'disable');
|
||||||
$this->middleware('permission:delete-banking-accounts')->only('destroy');
|
$this->middleware('permission:delete-banking-accounts')->only('destroy');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -22,9 +22,9 @@ class BillTransactions extends Controller
|
|||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
// Add CRUD permission check
|
// Add CRUD permission check
|
||||||
$this->middleware('permission:create-purchases-bills')->only(['create', 'store', 'duplicate', 'import']);
|
$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:read-purchases-bills')->only('index', 'show', 'edit', 'export');
|
||||||
$this->middleware('permission:update-purchases-bills')->only(['update', 'enable', 'disable']);
|
$this->middleware('permission:update-purchases-bills')->only('update', 'enable', 'disable');
|
||||||
$this->middleware('permission:delete-purchases-bills')->only('destroy');
|
$this->middleware('permission:delete-purchases-bills')->only('destroy');
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -67,6 +67,19 @@ class BillTransactions extends Controller
|
|||||||
'error' => false,
|
'error' => false,
|
||||||
'message' => 'null',
|
'message' => 'null',
|
||||||
'html' => $html,
|
'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()
|
public function __construct()
|
||||||
{
|
{
|
||||||
// Add CRUD permission check
|
// Add CRUD permission check
|
||||||
$this->middleware('permission:create-settings-categories')->only(['create', 'store', 'duplicate', 'import']);
|
$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:read-settings-categories')->only('index', 'show', 'edit', 'export');
|
||||||
$this->middleware('permission:update-settings-categories')->only(['update', 'enable', 'disable']);
|
$this->middleware('permission:update-settings-categories')->only('update', 'enable', 'disable');
|
||||||
$this->middleware('permission:delete-settings-categories')->only('destroy');
|
$this->middleware('permission:delete-settings-categories')->only('destroy');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -16,9 +16,9 @@ class Currencies extends Controller
|
|||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
// Add CRUD permission check
|
// Add CRUD permission check
|
||||||
$this->middleware('permission:create-settings-currencies')->only(['create', 'store', 'duplicate', 'import']);
|
$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:read-settings-currencies')->only('index', 'show', 'edit', 'export');
|
||||||
$this->middleware('permission:update-settings-currencies')->only(['update', 'enable', 'disable']);
|
$this->middleware('permission:update-settings-currencies')->only('update', 'enable', 'disable');
|
||||||
$this->middleware('permission:delete-settings-currencies')->only('destroy');
|
$this->middleware('permission:delete-settings-currencies')->only('destroy');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -15,9 +15,9 @@ class Customers extends Controller
|
|||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
// Add CRUD permission check
|
// Add CRUD permission check
|
||||||
$this->middleware('permission:create-sales-customers')->only(['create', 'store', 'duplicate', 'import']);
|
$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:read-sales-customers')->only('index', 'show', 'edit', 'export');
|
||||||
$this->middleware('permission:update-sales-customers')->only(['update', 'enable', 'disable']);
|
$this->middleware('permission:update-sales-customers')->only('update', 'enable', 'disable');
|
||||||
$this->middleware('permission:delete-sales-customers')->only('destroy');
|
$this->middleware('permission:delete-sales-customers')->only('destroy');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -12,9 +12,9 @@ class InvoiceTemplates extends Controller
|
|||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
// Add CRUD permission check
|
// Add CRUD permission check
|
||||||
$this->middleware('permission:create-settings-settings')->only(['create', 'store']);
|
$this->middleware('permission:create-settings-settings')->only('create', 'store');
|
||||||
$this->middleware('permission:read-settings-settings')->only(['index', 'edit']);
|
$this->middleware('permission:read-settings-settings')->only('index', 'edit');
|
||||||
$this->middleware('permission:update-settings-settings')->only(['update', 'enable', 'disable']);
|
$this->middleware('permission:update-settings-settings')->only('update', 'enable', 'disable');
|
||||||
$this->middleware('permission:delete-settings-settings')->only('destroy');
|
$this->middleware('permission:delete-settings-settings')->only('destroy');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -22,9 +22,9 @@ class InvoiceTransactions extends Controller
|
|||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
// Add CRUD permission check
|
// Add CRUD permission check
|
||||||
$this->middleware('permission:create-sales-invoices')->only(['create', 'store', 'duplicate', 'import']);
|
$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:read-sales-invoices')->only('index', 'show', 'edit', 'export');
|
||||||
$this->middleware('permission:update-sales-invoices')->only(['update', 'enable', 'disable']);
|
$this->middleware('permission:update-sales-invoices')->only('update', 'enable', 'disable');
|
||||||
$this->middleware('permission:delete-sales-invoices')->only('destroy');
|
$this->middleware('permission:delete-sales-invoices')->only('destroy');
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -67,6 +67,24 @@ class InvoiceTransactions extends Controller
|
|||||||
'error' => false,
|
'error' => false,
|
||||||
'message' => 'null',
|
'message' => 'null',
|
||||||
'html' => $html,
|
'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()
|
public function __construct()
|
||||||
{
|
{
|
||||||
// Add CRUD permission check
|
// Add CRUD permission check
|
||||||
$this->middleware('permission:create-common-items')->only(['create', 'store', 'duplicate', 'import']);
|
$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:read-common-items')->only('index', 'show', 'edit', 'export');
|
||||||
$this->middleware('permission:update-common-items')->only(['update', 'enable', 'disable']);
|
$this->middleware('permission:update-common-items')->only('update', 'enable', 'disable');
|
||||||
$this->middleware('permission:delete-common-items')->only('destroy');
|
$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');
|
$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();
|
$html = view('modals.items.create', compact('categories', 'taxes', 'currency'))->render();
|
||||||
|
|
||||||
|
@@ -14,9 +14,9 @@ class Taxes extends Controller
|
|||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
// Add CRUD permission check
|
// Add CRUD permission check
|
||||||
$this->middleware('permission:create-settings-taxes')->only(['create', 'store']);
|
$this->middleware('permission:create-settings-taxes')->only('create', 'store');
|
||||||
$this->middleware('permission:read-settings-taxes')->only(['index', 'edit']);
|
$this->middleware('permission:read-settings-taxes')->only('index', 'edit');
|
||||||
$this->middleware('permission:update-settings-taxes')->only(['update', 'enable', 'disable']);
|
$this->middleware('permission:update-settings-taxes')->only('update', 'enable', 'disable');
|
||||||
$this->middleware('permission:delete-settings-taxes')->only('destroy');
|
$this->middleware('permission:delete-settings-taxes')->only('destroy');
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -28,8 +28,10 @@ class Taxes extends Controller
|
|||||||
public function create()
|
public function create()
|
||||||
{
|
{
|
||||||
$types = [
|
$types = [
|
||||||
|
'fixed' => trans('taxes.fixed'),
|
||||||
'normal' => trans('taxes.normal'),
|
'normal' => trans('taxes.normal'),
|
||||||
'inclusive' => trans('taxes.inclusive'),
|
'inclusive' => trans('taxes.inclusive'),
|
||||||
|
'withholding' => trans('taxes.withholding'),
|
||||||
'compound' => trans('taxes.compound'),
|
'compound' => trans('taxes.compound'),
|
||||||
];
|
];
|
||||||
|
|
||||||
|
@@ -15,9 +15,9 @@ class Vendors extends Controller
|
|||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
// Add CRUD permission check
|
// Add CRUD permission check
|
||||||
$this->middleware('permission:create-purchases-vendors')->only(['create', 'store', 'duplicate', 'import']);
|
$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:read-purchases-vendors')->only('index', 'show', 'edit', 'export');
|
||||||
$this->middleware('permission:update-purchases-vendors')->only(['update', 'enable', 'disable']);
|
$this->middleware('permission:update-purchases-vendors')->only('update', 'enable', 'disable');
|
||||||
$this->middleware('permission:delete-purchases-vendors')->only('destroy');
|
$this->middleware('permission:delete-purchases-vendors')->only('destroy');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -4,7 +4,6 @@ namespace App\Http\Controllers\Modules;
|
|||||||
|
|
||||||
use App\Abstracts\Http\Controller;
|
use App\Abstracts\Http\Controller;
|
||||||
use App\Models\Module\Module;
|
use App\Models\Module\Module;
|
||||||
use App\Models\Module\ModuleHistory;
|
|
||||||
use App\Traits\Modules;
|
use App\Traits\Modules;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
@@ -18,9 +17,9 @@ class Item extends Controller
|
|||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
// Add CRUD permission check
|
// Add CRUD permission check
|
||||||
$this->middleware('permission:create-modules-item')->only(['install']);
|
$this->middleware('permission:create-modules-item')->only('install');
|
||||||
$this->middleware('permission:update-modules-item')->only(['update', 'enable', 'disable']);
|
$this->middleware('permission:update-modules-item')->only('update', 'enable', 'disable');
|
||||||
$this->middleware('permission:delete-modules-item')->only(['uninstall']);
|
$this->middleware('permission:delete-modules-item')->only('uninstall');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -38,7 +37,7 @@ class Item extends Controller
|
|||||||
$module = $this->getModule($alias);
|
$module = $this->getModule($alias);
|
||||||
|
|
||||||
if (empty($module)) {
|
if (empty($module)) {
|
||||||
return redirect('apps/home')->send();
|
return redirect()->route('apps.home.index')->send();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->moduleExists($alias) && ($model = Module::alias($alias)->first())) {
|
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']]);
|
$message = trans('modules.installed', ['module' => $json['data']['name']]);
|
||||||
|
|
||||||
flash($message)->success();
|
flash($message)->success();
|
||||||
|
} else {
|
||||||
|
flash($json['message'])->error();
|
||||||
}
|
}
|
||||||
|
|
||||||
return response()->json($json);
|
return response()->json($json);
|
||||||
@@ -169,102 +170,45 @@ class Item extends Controller
|
|||||||
{
|
{
|
||||||
$json = $this->uninstallModule($alias);
|
$json = $this->uninstallModule($alias);
|
||||||
|
|
||||||
$module = Module::alias($alias)->first();
|
if ($json['success']) {
|
||||||
|
$message = trans('modules.uninstalled', ['module' => $json['data']['name']]);
|
||||||
|
|
||||||
$data = [
|
flash($message)->success();
|
||||||
'company_id' => session('company_id'),
|
} else {
|
||||||
'module_id' => $module->id,
|
flash($json['message'])->error();
|
||||||
'category' => $json['data']['category'],
|
}
|
||||||
'version' => $json['data']['version'],
|
|
||||||
'description' => trans('modules.uninstalled', ['module' => $json['data']['name']]),
|
|
||||||
];
|
|
||||||
|
|
||||||
ModuleHistory::create($data);
|
return redirect()->route('apps.app.show', $alias)->send();
|
||||||
|
|
||||||
$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();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function enable($alias)
|
public function enable($alias)
|
||||||
{
|
{
|
||||||
$json = $this->enableModule($alias);
|
$json = $this->enableModule($alias);
|
||||||
|
|
||||||
$module = Module::alias($alias)->first();
|
if ($json['success']) {
|
||||||
|
$message = trans('modules.enabled', ['module' => $json['data']['name']]);
|
||||||
|
|
||||||
$data = [
|
flash($message)->success();
|
||||||
'company_id' => session('company_id'),
|
} else {
|
||||||
'module_id' => $module->id,
|
flash($json['message'])->error();
|
||||||
'category' => $json['data']['category'],
|
}
|
||||||
'version' => $json['data']['version'],
|
|
||||||
'description' => trans('modules.enabled', ['module' => $json['data']['name']]),
|
|
||||||
];
|
|
||||||
|
|
||||||
$module->enabled = 1;
|
return redirect()->route('apps.app.show', $alias)->send();
|
||||||
|
|
||||||
$module->save();
|
|
||||||
|
|
||||||
ModuleHistory::create($data);
|
|
||||||
|
|
||||||
$message = trans('modules.enabled', ['module' => $json['data']['name']]);
|
|
||||||
|
|
||||||
flash($message)->success();
|
|
||||||
|
|
||||||
return redirect('apps/' . $alias)->send();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function disable($alias)
|
public function disable($alias)
|
||||||
{
|
{
|
||||||
$json = $this->disableModule($alias);
|
$json = $this->disableModule($alias);
|
||||||
|
|
||||||
$module = Module::alias($alias)->first();
|
if ($json['success']) {
|
||||||
|
$message = trans('modules.disabled', ['module' => $json['data']['name']]);
|
||||||
|
|
||||||
$data = [
|
flash($message)->success();
|
||||||
'company_id' => session('company_id'),
|
} else {
|
||||||
'module_id' => $module->id,
|
flash($json['message'])->error();
|
||||||
'category' => $json['data']['category'],
|
}
|
||||||
'version' => $json['data']['version'],
|
|
||||||
'description' => trans('modules.disabled', ['module' => $json['data']['name']]),
|
|
||||||
];
|
|
||||||
|
|
||||||
$module->enabled = 0;
|
return redirect()->route('apps.app.show', $alias)->send();
|
||||||
|
|
||||||
$module->save();
|
|
||||||
|
|
||||||
ModuleHistory::create($data);
|
|
||||||
|
|
||||||
$message = trans('modules.disabled', ['module' => $json['data']['name']]);
|
|
||||||
|
|
||||||
flash($message)->success();
|
|
||||||
|
|
||||||
return redirect('apps/' . $alias)->send();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function reviews($alias, Request $request)
|
public function reviews($alias, Request $request)
|
||||||
@@ -292,11 +236,11 @@ class Item extends Controller
|
|||||||
{
|
{
|
||||||
$documentation = $this->getDocumentation($alias);
|
$documentation = $this->getDocumentation($alias);
|
||||||
|
|
||||||
if (empty($documentation)) {
|
$back = route('apps.app.show', $alias);
|
||||||
return redirect('apps/' . $alias)->send();
|
|
||||||
}
|
|
||||||
|
|
||||||
$back = 'apps/' . $alias;
|
if (empty($documentation)) {
|
||||||
|
return redirect()->route($back)->send();
|
||||||
|
}
|
||||||
|
|
||||||
return view('modules.item.documentation', compact('documentation', 'back'));
|
return view('modules.item.documentation', compact('documentation', 'back'));
|
||||||
}
|
}
|
||||||
|
@@ -23,7 +23,7 @@ class Invoices extends Controller
|
|||||||
*/
|
*/
|
||||||
public function index()
|
public function index()
|
||||||
{
|
{
|
||||||
$invoices = Invoice::with(['contact', 'items', 'payments', 'histories'])
|
$invoices = Invoice::with('contact', 'histories', 'items', 'payments')
|
||||||
->accrued()->where('contact_id', user()->contact->id)
|
->accrued()->where('contact_id', user()->contact->id)
|
||||||
->collect(['invoice_number'=> 'desc']);
|
->collect(['invoice_number'=> 'desc']);
|
||||||
|
|
||||||
|
@@ -37,7 +37,7 @@ class Bills extends Controller
|
|||||||
*/
|
*/
|
||||||
public function index()
|
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');
|
$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();
|
$bill->grand_total = money($total, $currency->code)->getAmount();
|
||||||
|
|
||||||
if (!empty($bill->paid)) {
|
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'));
|
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()
|
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');
|
$vendors = Contact::vendor()->enabled()->orderBy('name')->pluck('name', 'id');
|
||||||
|
|
||||||
|
@@ -28,7 +28,7 @@ class Vendors extends Controller
|
|||||||
*/
|
*/
|
||||||
public function index()
|
public function index()
|
||||||
{
|
{
|
||||||
$vendors = Contact::vendor()->collect();
|
$vendors = Contact::with('bills.transactions')->vendor()->collect();
|
||||||
|
|
||||||
return view('purchases.vendors.index', compact('vendors'));
|
return view('purchases.vendors.index', compact('vendors'));
|
||||||
}
|
}
|
||||||
@@ -51,7 +51,7 @@ class Vendors extends Controller
|
|||||||
$counts = [];
|
$counts = [];
|
||||||
|
|
||||||
// Handle bills
|
// Handle bills
|
||||||
$bills = Bill::where('contact_id', $vendor->id)->get();
|
$bills = Bill::with('transactions')->where('contact_id', $vendor->id)->get();
|
||||||
|
|
||||||
$counts['bills'] = $bills->count();
|
$counts['bills'] = $bills->count();
|
||||||
|
|
||||||
@@ -78,7 +78,7 @@ class Vendors extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Handle payments
|
// 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();
|
$counts['transactions'] = $transactions->count();
|
||||||
|
|
||||||
|
@@ -26,7 +26,7 @@ class Customers extends Controller
|
|||||||
*/
|
*/
|
||||||
public function index()
|
public function index()
|
||||||
{
|
{
|
||||||
$customers = Contact::customer()->collect();
|
$customers = Contact::with('invoices.transactions')->customer()->collect();
|
||||||
|
|
||||||
return view('sales.customers.index', compact('customers'));
|
return view('sales.customers.index', compact('customers'));
|
||||||
}
|
}
|
||||||
@@ -49,7 +49,7 @@ class Customers extends Controller
|
|||||||
$counts = [];
|
$counts = [];
|
||||||
|
|
||||||
// Handle invoices
|
// Handle invoices
|
||||||
$invoices = Invoice::where('contact_id', $customer->id)->get();
|
$invoices = Invoice::with('transactions')->where('contact_id', $customer->id)->get();
|
||||||
|
|
||||||
$counts['invoices'] = $invoices->count();
|
$counts['invoices'] = $invoices->count();
|
||||||
|
|
||||||
@@ -76,7 +76,7 @@ class Customers extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Handle transactions
|
// 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();
|
$counts['transactions'] = $transactions->count();
|
||||||
|
|
||||||
|
@@ -38,7 +38,7 @@ class Invoices extends Controller
|
|||||||
*/
|
*/
|
||||||
public function index()
|
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');
|
$customers = Contact::customer()->enabled()->orderBy('name')->pluck('name', 'id');
|
||||||
|
|
||||||
@@ -435,7 +435,7 @@ class Invoices extends Controller
|
|||||||
$currency = Currency::where('code', $currency_code)->first();
|
$currency = Currency::where('code', $currency_code)->first();
|
||||||
|
|
||||||
if (empty($currency)) {
|
if (empty($currency)) {
|
||||||
$currency = Currency::where('code', setting('default.currency', 'USD'))->first();
|
$currency = Currency::where('code', setting('default.currency'))->first();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($currency) {
|
if ($currency) {
|
||||||
|
@@ -30,7 +30,7 @@ class Revenues extends Controller
|
|||||||
*/
|
*/
|
||||||
public function index()
|
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');
|
$customers = Contact::customer()->enabled()->orderBy('name')->pluck('name', 'id');
|
||||||
|
|
||||||
|
@@ -3,20 +3,11 @@
|
|||||||
namespace App\Http\Controllers\Settings;
|
namespace App\Http\Controllers\Settings;
|
||||||
|
|
||||||
use App\Abstracts\Http\Controller;
|
use App\Abstracts\Http\Controller;
|
||||||
use App\Models\Setting\Setting;
|
|
||||||
|
|
||||||
class Company extends Controller
|
class Company extends Controller
|
||||||
{
|
{
|
||||||
public function edit()
|
public function edit()
|
||||||
{
|
{
|
||||||
$setting = Setting::prefix('company')->get()->transform(function ($s) {
|
return view('settings.company.edit');
|
||||||
$s->key = str_replace('company.', '', $s->key);
|
|
||||||
|
|
||||||
return $s;
|
|
||||||
})->pluck('value', 'key');
|
|
||||||
|
|
||||||
return view('settings.company.edit', compact(
|
|
||||||
'setting'
|
|
||||||
));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -56,7 +56,15 @@ class Currencies extends Controller
|
|||||||
$codes[$key] = $key;
|
$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
|
// Set default currency
|
||||||
$currency->default_currency = ($currency->code == setting('default.currency')) ? 1 : 0;
|
$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\Abstracts\Http\Controller;
|
||||||
use App\Models\Banking\Account;
|
use App\Models\Banking\Account;
|
||||||
use App\Models\Setting\Currency;
|
use App\Models\Setting\Currency;
|
||||||
use App\Models\Setting\Setting;
|
|
||||||
use App\Models\Setting\Tax;
|
use App\Models\Setting\Tax;
|
||||||
use App\Utilities\Modules;
|
use App\Utilities\Modules;
|
||||||
|
|
||||||
@@ -13,12 +12,6 @@ class Defaults extends Controller
|
|||||||
{
|
{
|
||||||
public function edit()
|
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');
|
$accounts = Account::enabled()->orderBy('name')->pluck('name', 'id');
|
||||||
|
|
||||||
$currencies = Currency::enabled()->orderBy('name')->pluck('name', 'code');
|
$currencies = Currency::enabled()->orderBy('name')->pluck('name', 'code');
|
||||||
@@ -28,7 +21,6 @@ class Defaults extends Controller
|
|||||||
$payment_methods = Modules::getPaymentMethods();
|
$payment_methods = Modules::getPaymentMethods();
|
||||||
|
|
||||||
return view('settings.default.edit', compact(
|
return view('settings.default.edit', compact(
|
||||||
'setting',
|
|
||||||
'accounts',
|
'accounts',
|
||||||
'currencies',
|
'currencies',
|
||||||
'taxes',
|
'taxes',
|
||||||
|
@@ -4,8 +4,9 @@ namespace App\Http\Controllers\Settings;
|
|||||||
|
|
||||||
use App\Abstracts\Http\Controller;
|
use App\Abstracts\Http\Controller;
|
||||||
use App\Http\Requests\Setting\Setting as Request;
|
use App\Http\Requests\Setting\Setting as Request;
|
||||||
|
use App\Models\Common\Company;
|
||||||
use App\Models\Common\EmailTemplate;
|
use App\Models\Common\EmailTemplate;
|
||||||
use App\Models\Setting\Setting;
|
use App\Utilities\Installer;
|
||||||
use Illuminate\Support\Str;
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
class Email extends Controller
|
class Email extends Controller
|
||||||
@@ -23,20 +24,14 @@ class Email extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Add CRUD permission check
|
// Add CRUD permission check
|
||||||
$this->middleware('permission:create-settings-settings')->only(['create', 'store', 'duplicate', 'import']);
|
$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:read-settings-email')->only('index', 'show', 'edit', 'export');
|
||||||
$this->middleware('permission:update-settings-settings')->only(['update', 'enable', 'disable']);
|
$this->middleware('permission:update-settings-settings')->only('update', 'enable', 'disable');
|
||||||
$this->middleware('permission:delete-settings-settings')->only('destroy');
|
$this->middleware('permission:delete-settings-settings')->only('destroy');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function edit()
|
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();
|
$templates = EmailTemplate::all();
|
||||||
|
|
||||||
$email_protocols = [
|
$email_protocols = [
|
||||||
@@ -47,7 +42,6 @@ class Email extends Controller
|
|||||||
];
|
];
|
||||||
|
|
||||||
return view('settings.email.edit', compact(
|
return view('settings.email.edit', compact(
|
||||||
'setting',
|
|
||||||
'templates',
|
'templates',
|
||||||
'email_protocols'
|
'email_protocols'
|
||||||
));
|
));
|
||||||
@@ -58,6 +52,8 @@ class Email extends Controller
|
|||||||
$fields = $request->all();
|
$fields = $request->all();
|
||||||
$prefix = $request->get('_prefix', 'email');
|
$prefix = $request->get('_prefix', 'email');
|
||||||
|
|
||||||
|
$total_companies = Company::count();
|
||||||
|
|
||||||
foreach ($fields as $key => $value) {
|
foreach ($fields as $key => $value) {
|
||||||
$real_key = $prefix . '.' . $key;
|
$real_key = $prefix . '.' . $key;
|
||||||
|
|
||||||
@@ -72,6 +68,10 @@ class Email extends Controller
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($total_companies == 1) {
|
||||||
|
$this->oneCompany($real_key, $value);
|
||||||
|
}
|
||||||
|
|
||||||
setting()->set($real_key, $value);
|
setting()->set($real_key, $value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -114,4 +114,32 @@ class Email extends Controller
|
|||||||
unset($fields[$subject_key]);
|
unset($fields[$subject_key]);
|
||||||
unset($fields[$body_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;
|
namespace App\Http\Controllers\Settings;
|
||||||
|
|
||||||
use App\Abstracts\Http\Controller;
|
use App\Abstracts\Http\Controller;
|
||||||
use App\Models\Setting\Setting;
|
|
||||||
|
|
||||||
class Invoice extends Controller
|
class Invoice extends Controller
|
||||||
{
|
{
|
||||||
public function edit()
|
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 = [
|
$item_names = [
|
||||||
'settings.invoice.item' => trans('settings.invoice.item'),
|
'settings.invoice.item' => trans('settings.invoice.item'),
|
||||||
'settings.invoice.product' => trans('settings.invoice.product'),
|
'settings.invoice.product' => trans('settings.invoice.product'),
|
||||||
@@ -43,7 +36,6 @@ class Invoice extends Controller
|
|||||||
];
|
];
|
||||||
|
|
||||||
return view('settings.invoice.edit', compact(
|
return view('settings.invoice.edit', compact(
|
||||||
'setting',
|
|
||||||
'item_names',
|
'item_names',
|
||||||
'price_names',
|
'price_names',
|
||||||
'quantity_names',
|
'quantity_names',
|
||||||
|
@@ -3,7 +3,6 @@
|
|||||||
namespace App\Http\Controllers\Settings;
|
namespace App\Http\Controllers\Settings;
|
||||||
|
|
||||||
use App\Abstracts\Http\Controller;
|
use App\Abstracts\Http\Controller;
|
||||||
use App\Models\Setting\Setting;
|
|
||||||
use App\Traits\DateTime;
|
use App\Traits\DateTime;
|
||||||
|
|
||||||
class Localisation extends Controller
|
class Localisation extends Controller
|
||||||
@@ -12,12 +11,6 @@ class Localisation extends Controller
|
|||||||
|
|
||||||
public function edit()
|
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();
|
$timezones = $this->getTimezones();
|
||||||
|
|
||||||
$date_formats = [
|
$date_formats = [
|
||||||
@@ -49,7 +42,6 @@ class Localisation extends Controller
|
|||||||
];
|
];
|
||||||
|
|
||||||
return view('settings.localisation.edit', compact(
|
return view('settings.localisation.edit', compact(
|
||||||
'setting',
|
|
||||||
'timezones',
|
'timezones',
|
||||||
'date_formats',
|
'date_formats',
|
||||||
'date_separators',
|
'date_separators',
|
||||||
|
@@ -3,6 +3,8 @@
|
|||||||
namespace App\Http\Controllers\Settings;
|
namespace App\Http\Controllers\Settings;
|
||||||
|
|
||||||
use App\Abstracts\Http\Controller;
|
use App\Abstracts\Http\Controller;
|
||||||
|
use App\Models\Banking\Account;
|
||||||
|
use App\Models\Setting\Category;
|
||||||
use App\Models\Setting\Setting;
|
use App\Models\Setting\Setting;
|
||||||
use App\Utilities\Modules as Utility;
|
use App\Utilities\Modules as Utility;
|
||||||
use App\Http\Requests\Setting\Module as Request;
|
use App\Http\Requests\Setting\Module as Request;
|
||||||
@@ -17,9 +19,9 @@ class Modules extends Controller
|
|||||||
$alias = request()->segment(1);
|
$alias = request()->segment(1);
|
||||||
|
|
||||||
// Add CRUD permission check
|
// Add CRUD permission check
|
||||||
$this->middleware('permission:create-' . $alias . '-settings')->only(['create', 'store', 'duplicate', 'import']);
|
$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:read-' . $alias . '-settings')->only('index', 'show', 'edit', 'export');
|
||||||
$this->middleware('permission:update-' . $alias . '-settings')->only(['update', 'enable', 'disable']);
|
$this->middleware('permission:update-' . $alias . '-settings')->only('update', 'enable', 'disable');
|
||||||
$this->middleware('permission:delete-' . $alias . '-settings')->only('destroy');
|
$this->middleware('permission:delete-' . $alias . '-settings')->only('destroy');
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -30,6 +32,9 @@ class Modules extends Controller
|
|||||||
*/
|
*/
|
||||||
public function edit($alias)
|
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) {
|
$setting = Setting::prefix($alias)->get()->transform(function ($s) use ($alias) {
|
||||||
$s->key = str_replace($alias . '.', '', $s->key);
|
$s->key = str_replace($alias . '.', '', $s->key);
|
||||||
return $s;
|
return $s;
|
||||||
@@ -37,7 +42,7 @@ class Modules extends Controller
|
|||||||
|
|
||||||
$module = module($alias);
|
$module = module($alias);
|
||||||
|
|
||||||
return view('settings.modules.edit', compact('setting', 'module'));
|
return view('settings.modules.edit', compact('setting', 'module', 'accounts', 'categories'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user