migrate to gtea from bistbucket
This commit is contained in:
@@ -0,0 +1,331 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\MultiBranchAddon\App\Http\Controllers;
|
||||
|
||||
use App\Models\Sale;
|
||||
use App\Models\User;
|
||||
use App\Models\Branch;
|
||||
use App\Models\Income;
|
||||
use App\Models\Expense;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
|
||||
class AcnooBranchController extends Controller
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('check.permission:branches.read')->only(['index']);
|
||||
$this->middleware('check.permission:branches.create')->only(['store']);
|
||||
$this->middleware('check.permission:branches.update')->only(['update']);
|
||||
$this->middleware('check.permission:branches.delete')->only(['destroy', 'deleteAll']);
|
||||
}
|
||||
|
||||
public function index(Request $request)
|
||||
{
|
||||
$branches = Branch::where('business_id', auth()->user()->business_id)
|
||||
->when(request('search'), function ($q) use ($request) {
|
||||
$q->where(function ($q) use ($request) {
|
||||
$q->where('name', 'like', '%' . $request->search . '%')
|
||||
->orWhere('phone', 'like', '%' . $request->search . '%')
|
||||
->orWhere('email', 'like', '%' . $request->search . '%')
|
||||
->orWhere('address', 'like', '%' . $request->search . '%');
|
||||
});
|
||||
})
|
||||
->paginate($request->per_page ?? 20)->appends($request->query());
|
||||
|
||||
if ($request->ajax()) {
|
||||
return response()->json([
|
||||
'data' => view('multibranchaddon::branches.datas', compact('branches'))->render()
|
||||
]);
|
||||
}
|
||||
return view('multibranchaddon::branches.index', compact('branches'));
|
||||
}
|
||||
|
||||
public function store(Request $request)
|
||||
{
|
||||
$request->validate([
|
||||
'name' => 'required|string|max:255',
|
||||
'phone' => 'nullable|string|max:20',
|
||||
'email' => 'nullable|email|max:255',
|
||||
'address' => 'nullable|string|max:255',
|
||||
'branchOpeningBalance' => 'nullable|numeric|min:0',
|
||||
'description' => 'nullable|string|max:1000',
|
||||
]);
|
||||
|
||||
DB::beginTransaction();
|
||||
try {
|
||||
$business_id = auth()->user()->business_id;
|
||||
$opening_balance = $request->branchOpeningBalance ?? 0;
|
||||
$has_main_branch = Branch::where('business_id', $business_id)->where('is_main', 1)->exists();
|
||||
|
||||
if (!branch_count() || !$has_main_branch) {
|
||||
manipulateBranchData($business_id);
|
||||
}
|
||||
|
||||
Branch::create($request->except('branchOpeningBalance', 'branchRemainingBalance') + [
|
||||
'branchRemainingBalance' => $opening_balance,
|
||||
'branchOpeningBalance' => $opening_balance,
|
||||
]);
|
||||
|
||||
Cache::forget('branch-count-' . $business_id);
|
||||
|
||||
DB::commit();
|
||||
return response()->json([
|
||||
'message' => __('Branch saved successfully.'),
|
||||
'redirect' => route('multibranch.branches.index')
|
||||
]);
|
||||
} catch (\Exception $e) {
|
||||
DB::rollback();
|
||||
return response()->json(['message' => $e->getMessage()], 500);
|
||||
}
|
||||
}
|
||||
|
||||
public function update(Request $request, string $id)
|
||||
{
|
||||
$request->validate([
|
||||
'name' => 'required|string|max:255',
|
||||
'phone' => 'nullable|string|max:20',
|
||||
'email' => 'nullable|email|max:255',
|
||||
'address' => 'nullable|string|max:255',
|
||||
'branchOpeningBalance' => 'nullable|numeric|min:0',
|
||||
'description' => 'nullable|string|max:1000',
|
||||
]);
|
||||
|
||||
$branch = Branch::findOrFail($id);
|
||||
|
||||
$updateData = $request->except('branchRemainingBalance');
|
||||
|
||||
$requestedOpeningBalance = $request->input('branchOpeningBalance');
|
||||
|
||||
if ($requestedOpeningBalance != $branch->branchOpeningBalance) {
|
||||
if ($branch->branchRemainingBalance === $branch->branchOpeningBalance) {
|
||||
$updateData['branchRemainingBalance'] = $requestedOpeningBalance;
|
||||
} else {
|
||||
return response()->json([
|
||||
'message' => __('You cannot update opening balance because it differs from remaining balance.')
|
||||
], 422);
|
||||
}
|
||||
}
|
||||
|
||||
$branch->update($updateData);
|
||||
|
||||
return response()->json([
|
||||
'message' => __('Branch updated successfully.'),
|
||||
'redirect' => route('multibranch.branches.index')
|
||||
]);
|
||||
}
|
||||
|
||||
public function destroy($id)
|
||||
{
|
||||
$business_id = auth()->user()->business_id;
|
||||
$user = auth()->user();
|
||||
$branch = Branch::where('business_id', $business_id)->findOrFail($id);
|
||||
|
||||
if ($branch->is_main) {
|
||||
return response()->json([
|
||||
'message' => __('You can not delete main branch.')
|
||||
], 406);
|
||||
}
|
||||
|
||||
// Auto exit if this is the active branch
|
||||
if ($user->active_branch_id == $branch->id) {
|
||||
$user->update([
|
||||
'active_branch_id' => null
|
||||
]);
|
||||
}
|
||||
|
||||
User::where('branch_id', $branch->id)->delete();
|
||||
$branch->delete();
|
||||
|
||||
Cache::forget('branch-count-' . $business_id);
|
||||
|
||||
return response()->json([
|
||||
'message' => __('Branch deleted successfully'),
|
||||
'redirect' => route('multibranch.branches.index'),
|
||||
]);
|
||||
}
|
||||
|
||||
public function deleteAll(Request $request)
|
||||
{
|
||||
$business_id = auth()->user()->business_id;
|
||||
|
||||
User::whereIn('branch_id', $request->ids)->delete();
|
||||
Branch::where('business_id', $business_id)->where('is_main', 0)->whereIn('id', $request->ids)->delete();
|
||||
|
||||
Cache::forget('branch-count-' . $business_id);
|
||||
|
||||
return response()->json([
|
||||
'message' => __('Selected branch deleted successfully'),
|
||||
'redirect' => route('multibranch.branches.index'),
|
||||
]);
|
||||
}
|
||||
|
||||
public function overview()
|
||||
{
|
||||
$branches = [];
|
||||
if (moduleCheck('HrmAddon')){
|
||||
$branches = Branch::where('business_id', auth()->user()->business_id)->withCount('employees')->latest()->take(5)->get();
|
||||
}
|
||||
|
||||
$branches_expired_products = Branch::where('business_id', auth()->user()->business_id)->whereHas('expiredStocks')->withCount('expiredStocks')->latest()->take(5)->get();
|
||||
|
||||
return view('multibranchaddon::branches.overview', compact('branches', 'branches_expired_products'));
|
||||
}
|
||||
|
||||
public function branchWiseSales(Request $request)
|
||||
{
|
||||
$year = $request->get('year', date('Y'));
|
||||
|
||||
$branches_sales = Branch::where('business_id', auth()->user()->business_id)
|
||||
->whereHas('sales', function ($q) use ($year) {
|
||||
$q->whereYear('saleDate', $year);
|
||||
})
|
||||
->withSum(['sales as totalAmount' => function ($q) use ($year) {
|
||||
$q->whereYear('saleDate', $year);
|
||||
}], 'totalAmount')
|
||||
->withSum(['sales as paidAmount' => function ($q) use ($year) {
|
||||
$q->whereYear('saleDate', $year);
|
||||
}], 'paidAmount')
|
||||
->withSum(['sales as dueAmount' => function ($q) use ($year) {
|
||||
$q->whereYear('saleDate', $year);
|
||||
}], 'dueAmount')
|
||||
->latest()
|
||||
->take(5)
|
||||
->get();
|
||||
|
||||
$branches_sales->transform(function ($branch) {
|
||||
$branch->sales_sum_total_amount_formatted = currency_format($branch->totalAmount, currency: business_currency());
|
||||
$branch->sales_sum_paid_amount_formatted = currency_format($branch->paidAmount, currency: business_currency());
|
||||
$branch->sales_sum_due_amount_formatted = currency_format($branch->dueAmount, currency: business_currency());
|
||||
return $branch;
|
||||
});
|
||||
|
||||
return response()->json($branches_sales);
|
||||
}
|
||||
|
||||
public function branchWisePurchases(Request $request)
|
||||
{
|
||||
$year = $request->get('year', date('Y'));
|
||||
|
||||
$branches_purchases = Branch::where('business_id', auth()->user()->business_id)
|
||||
->whereHas('purchases', function ($q) use ($year) {
|
||||
$q->whereYear('purchaseDate', $year);
|
||||
})
|
||||
->withSum(['purchases as totalAmount' => function ($q) use ($year) {
|
||||
$q->whereYear('purchaseDate', $year);
|
||||
}], 'totalAmount')
|
||||
->withSum(['purchases as paidAmount' => function ($q) use ($year) {
|
||||
$q->whereYear('purchaseDate', $year);
|
||||
}], 'paidAmount')
|
||||
->withSum(['purchases as dueAmount' => function ($q) use ($year) {
|
||||
$q->whereYear('purchaseDate', $year);
|
||||
}], 'dueAmount')
|
||||
->latest()
|
||||
->take(5)
|
||||
->get();
|
||||
|
||||
$branches_purchases->transform(function ($branch) {
|
||||
$branch->purchases_sum_total_amount_formatted = currency_format($branch->totalAmount, currency: business_currency());
|
||||
$branch->purchases_sum_paid_amount_formatted = currency_format($branch->paidAmount, currency: business_currency());
|
||||
$branch->purchases_sum_due_amount_formatted = currency_format($branch->dueAmount, currency: business_currency());
|
||||
return $branch;
|
||||
});
|
||||
|
||||
return response()->json($branches_purchases);
|
||||
}
|
||||
|
||||
public function incomeExpense(Request $request)
|
||||
{
|
||||
$data['expenses'] = Sale::where('business_id', auth()->user()->business_id)
|
||||
->whereYear('created_at', request('year') ?? date('Y'))
|
||||
->where('lossProfit', '<', 0)
|
||||
->selectRaw('MONTH(created_at) as month_number, MONTHNAME(created_at) as month, SUM(ABS(lossProfit)) as total')
|
||||
->groupBy('month_number', 'month')
|
||||
->orderBy('month_number')
|
||||
->get();
|
||||
|
||||
$data['incomes'] = Sale::where('business_id', auth()->user()->business_id)
|
||||
->whereYear('created_at', request('year') ?? date('Y'))
|
||||
->where('lossProfit', '>=', 0)
|
||||
->selectRaw('MONTH(created_at) as month_number, MONTHNAME(created_at) as month, SUM(ABS(lossProfit)) as total')
|
||||
->groupBy('month_number', 'month')
|
||||
->orderBy('month_number')
|
||||
->get();
|
||||
|
||||
return response()->json($data);
|
||||
}
|
||||
|
||||
public function earningData(Request $request)
|
||||
{
|
||||
$year = $request->year ?? date('Y');
|
||||
|
||||
$businessId = auth()->user()->business_id;
|
||||
|
||||
$profit = Income::where('business_id', $businessId)
|
||||
->whereYear('incomeDate', $year)
|
||||
->sum('amount');
|
||||
|
||||
$loss = Expense::where('business_id', $businessId)
|
||||
->whereYear('expenseDate', $year)
|
||||
->sum('amount');
|
||||
|
||||
// Get the total loss/profit for the month
|
||||
$sale_loss_profit = Sale::where('business_id', $businessId)
|
||||
->whereYear('saleDate', $year)
|
||||
->sum('lossProfit');
|
||||
|
||||
// Update income and expense based on lossProfit value
|
||||
$profit += $sale_loss_profit > 0 ? $sale_loss_profit : 0;
|
||||
$loss += $sale_loss_profit < 0 ? abs($sale_loss_profit) : 0;
|
||||
|
||||
$data = [
|
||||
'profit' => $profit,
|
||||
'loss' => $loss,
|
||||
];
|
||||
|
||||
return response()->json($data);
|
||||
}
|
||||
|
||||
public function status(Request $request, $id)
|
||||
{
|
||||
$branch = Branch::findOrFail($id);
|
||||
$branch->update(['status' => $request->status]);
|
||||
return response()->json(['message' => __('Branch')]);
|
||||
}
|
||||
|
||||
public function switchBranch($id)
|
||||
{
|
||||
if (!auth()->user()->branch_id) {
|
||||
|
||||
$branch = Branch::where('business_id', auth()->user()->business_id)->findOrFail($id);
|
||||
auth()->user()->update([
|
||||
'active_branch_id' => $branch->id
|
||||
]);
|
||||
|
||||
auth()->user()->tokens()->delete();
|
||||
|
||||
return redirect(route('business.dashboard.index'))->with('message', "You've successfully login to " . $branch->name);
|
||||
} else {
|
||||
return redirect(route('business.dashboard.index'))->with('warning', "You're not permitted to login on this branch.");
|
||||
}
|
||||
}
|
||||
|
||||
public function exitBranch($id)
|
||||
{
|
||||
if (auth()->user()->active_branch_id) {
|
||||
|
||||
$branch = Branch::where('business_id', auth()->user()->business_id)->findOrFail($id);
|
||||
auth()->user()->update([
|
||||
'active_branch_id' => null
|
||||
]);
|
||||
|
||||
auth()->user()->tokens()->delete();
|
||||
|
||||
return redirect(route('business.dashboard.index'))->with('message', "You've successfully exit from " . $branch->name);
|
||||
} else {
|
||||
return redirect(route('business.dashboard.index'))->with('warning', "You're not permitted to exit from this branch.");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,173 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\MultiBranchAddon\App\Http\Controllers\Api;
|
||||
|
||||
use App\Models\User;
|
||||
use App\Models\Branch;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
|
||||
class AcnooBranchController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$data = Branch::where('business_id', auth()->user()->business_id)->latest()->get();
|
||||
|
||||
return response()->json([
|
||||
'message' => __('Data fetched successfully.'),
|
||||
'data' => $data,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
$request->validate([
|
||||
'name' => 'required|string|max:255',
|
||||
'phone' => 'nullable|string|max:20',
|
||||
'email' => 'nullable|email|max:255',
|
||||
'address' => 'nullable|string|max:255',
|
||||
'branchOpeningBalance' => 'nullable|numeric|min:0',
|
||||
'description' => 'nullable|string|max:1000',
|
||||
]);
|
||||
|
||||
DB::beginTransaction();
|
||||
try {
|
||||
$opening_balance = $request->branchOpeningBalance ?? 0;
|
||||
$business_id = auth()->user()->business_id;
|
||||
$has_main_branch = Branch::where('business_id', $business_id)->where('is_main', 1)->exists();
|
||||
|
||||
if (!branch_count() || !$has_main_branch) {
|
||||
manipulateBranchData($business_id);
|
||||
}
|
||||
|
||||
Branch::create($request->except('branchOpeningBalance', 'branchRemainingBalance') + [
|
||||
'branchRemainingBalance' => $opening_balance,
|
||||
'branchOpeningBalance' => $opening_balance,
|
||||
]);
|
||||
|
||||
Cache::forget('branch-count-' . $business_id);
|
||||
|
||||
DB::commit();
|
||||
return response()->json([
|
||||
'message' => __('Branch saved successfully.'),
|
||||
]);
|
||||
} catch (\Exception $e) {
|
||||
DB::rollback();
|
||||
return response()->json(['message' => $e->getMessage()], 500);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*/
|
||||
public function update(Request $request, string $id)
|
||||
{
|
||||
$request->validate([
|
||||
'name' => 'required|string|max:255',
|
||||
'phone' => 'nullable|string|max:20',
|
||||
'email' => 'nullable|email|max:255',
|
||||
'address' => 'nullable|string|max:255',
|
||||
'branchOpeningBalance' => 'nullable|numeric|min:0',
|
||||
'description' => 'nullable|string|max:1000',
|
||||
]);
|
||||
|
||||
$branch = Branch::findOrFail($id);
|
||||
$updateData = $request->except('branchRemainingBalance');
|
||||
$requestedOpeningBalance = $request->input('branchOpeningBalance');
|
||||
|
||||
if ($requestedOpeningBalance != $branch->branchOpeningBalance) {
|
||||
if ($branch->branchRemainingBalance === $branch->branchOpeningBalance) {
|
||||
$updateData['branchRemainingBalance'] = $requestedOpeningBalance;
|
||||
} else {
|
||||
return response()->json([
|
||||
'message' => __('You cannot update opening balance because it differs from remaining balance.')
|
||||
], 422);
|
||||
}
|
||||
}
|
||||
|
||||
$branch->update($updateData);
|
||||
|
||||
return response()->json([
|
||||
'message' => __('Branch updated successfully.')
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*/
|
||||
public function destroy(string $id)
|
||||
{
|
||||
$business_id = auth()->user()->business_id;
|
||||
$user = auth()->user();
|
||||
$branch = Branch::where('business_id', $business_id)->findOrFail($id);
|
||||
|
||||
if ($branch->is_main) {
|
||||
return response()->json([
|
||||
'message' => __('You can not delete main branch.')
|
||||
], 406);
|
||||
}
|
||||
|
||||
// Auto exit if this is the active branch
|
||||
if ($user->active_branch_id == $branch->id) {
|
||||
$user->update([
|
||||
'active_branch_id' => null
|
||||
]);
|
||||
}
|
||||
|
||||
User::where('branch_id', $branch->id)->delete();
|
||||
$branch->delete();
|
||||
|
||||
Cache::forget('branch-count-' . $business_id);
|
||||
|
||||
return response()->json([
|
||||
'message' => __('Branch deleted successfully'),
|
||||
'redirect' => route('multibranch.branches.index'),
|
||||
]);
|
||||
}
|
||||
|
||||
public function switchBranch(string $id)
|
||||
{
|
||||
if (!auth()->user()->branch_id) {
|
||||
|
||||
$branch = Branch::where('business_id', auth()->user()->business_id)->findOrFail($id);
|
||||
auth()->user()->update([
|
||||
'active_branch_id' => $branch->id
|
||||
]);
|
||||
|
||||
return response()->json([
|
||||
'message' => "You've successfully login to " . $branch->name,
|
||||
]);
|
||||
} else {
|
||||
return response()->json([
|
||||
'message' => "You're not permitted to login on this branch.",
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
public function exitBranch(string $id)
|
||||
{
|
||||
if (auth()->user()->active_branch_id) {
|
||||
|
||||
$branch = Branch::where('business_id', auth()->user()->business_id)->findOrFail($id);
|
||||
auth()->user()->update([
|
||||
'active_branch_id' => null
|
||||
]);
|
||||
|
||||
return response()->json([
|
||||
'message' => "You've successfully exit from " . $branch->name,
|
||||
]);
|
||||
} else {
|
||||
return response()->json([
|
||||
'message' => "You're not permitted to exit from this branch.",
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
0
Modules/MultiBranchAddon/App/Providers/.gitkeep
Normal file
0
Modules/MultiBranchAddon/App/Providers/.gitkeep
Normal file
@@ -0,0 +1,111 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\MultiBranchAddon\App\Providers;
|
||||
|
||||
use Illuminate\Support\Facades\Blade;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
|
||||
class MultiBranchAddonServiceProvider extends ServiceProvider
|
||||
{
|
||||
protected string $moduleName = 'MultiBranchAddon';
|
||||
|
||||
protected string $moduleNameLower = 'multibranchaddon';
|
||||
|
||||
/**
|
||||
* Boot the application events.
|
||||
*/
|
||||
public function boot(): void
|
||||
{
|
||||
$this->registerCommands();
|
||||
$this->registerCommandSchedules();
|
||||
$this->registerTranslations();
|
||||
$this->registerConfig();
|
||||
$this->registerViews();
|
||||
$this->loadMigrationsFrom(module_path($this->moduleName, 'Database/migrations'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the service provider.
|
||||
*/
|
||||
public function register(): void
|
||||
{
|
||||
$this->app->register(RouteServiceProvider::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register commands in the format of Command::class
|
||||
*/
|
||||
protected function registerCommands(): void
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Register command Schedules.
|
||||
*/
|
||||
protected function registerCommandSchedules(): void
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Register translations.
|
||||
*/
|
||||
public function registerTranslations(): void
|
||||
{
|
||||
$langPath = resource_path('lang/modules/' . $this->moduleNameLower);
|
||||
|
||||
if (is_dir($langPath)) {
|
||||
$this->loadTranslationsFrom($langPath, $this->moduleNameLower);
|
||||
$this->loadJsonTranslationsFrom($langPath);
|
||||
} else {
|
||||
$this->loadTranslationsFrom(module_path($this->moduleName, 'lang'), $this->moduleNameLower);
|
||||
$this->loadJsonTranslationsFrom(module_path($this->moduleName, 'lang'));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Register config.
|
||||
*/
|
||||
protected function registerConfig(): void
|
||||
{
|
||||
$this->publishes([module_path($this->moduleName, 'config/config.php') => config_path($this->moduleNameLower . '.php')], 'config');
|
||||
$this->mergeConfigFrom(module_path($this->moduleName, 'config/config.php'), $this->moduleNameLower);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register views.
|
||||
*/
|
||||
public function registerViews(): void
|
||||
{
|
||||
$viewPath = resource_path('views/modules/' . $this->moduleNameLower);
|
||||
$sourcePath = module_path($this->moduleName, 'resources/views');
|
||||
|
||||
$this->publishes([$sourcePath => $viewPath], ['views', $this->moduleNameLower . '-module-views']);
|
||||
|
||||
$this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower);
|
||||
|
||||
$componentNamespace = str_replace('/', '\\', config('modules.namespace') . '\\' . $this->moduleName . '\\' . config('modules.paths.generator.component-class.path'));
|
||||
Blade::componentNamespace($componentNamespace, $this->moduleNameLower);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the services provided by the provider.
|
||||
*/
|
||||
public function provides(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
private function getPublishableViewPaths(): array
|
||||
{
|
||||
$paths = [];
|
||||
foreach (config('view.paths') as $path) {
|
||||
if (is_dir($path . '/modules/' . $this->moduleNameLower)) {
|
||||
$paths[] = $path . '/modules/' . $this->moduleNameLower;
|
||||
}
|
||||
}
|
||||
|
||||
return $paths;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\MultiBranchAddon\App\Providers;
|
||||
|
||||
use Illuminate\Support\Facades\Route;
|
||||
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
|
||||
|
||||
class RouteServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* The module namespace to assume when generating URLs to actions.
|
||||
*/
|
||||
protected string $moduleNamespace = 'Modules\MultiBranchAddon\App\Http\Controllers';
|
||||
|
||||
/**
|
||||
* Called before routes are registered.
|
||||
*
|
||||
* Register any model bindings or pattern based filters.
|
||||
*/
|
||||
public function boot(): void
|
||||
{
|
||||
parent::boot();
|
||||
}
|
||||
|
||||
/**
|
||||
* Define the routes for the application.
|
||||
*/
|
||||
public function map(): void
|
||||
{
|
||||
$this->mapApiRoutes();
|
||||
|
||||
$this->mapWebRoutes();
|
||||
}
|
||||
|
||||
/**
|
||||
* Define the "web" routes for the application.
|
||||
*
|
||||
* These routes all receive session state, CSRF protection, etc.
|
||||
*/
|
||||
protected function mapWebRoutes(): void
|
||||
{
|
||||
Route::middleware('web')
|
||||
->namespace($this->moduleNamespace)
|
||||
->group(module_path('MultiBranchAddon', '/routes/web.php'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Define the "api" routes for the application.
|
||||
*
|
||||
* These routes are typically stateless.
|
||||
*/
|
||||
protected function mapApiRoutes(): void
|
||||
{
|
||||
Route::prefix('api')
|
||||
->middleware('api')
|
||||
->namespace($this->moduleNamespace)
|
||||
->group(module_path('MultiBranchAddon', '/routes/api.php'));
|
||||
}
|
||||
}
|
||||
0
Modules/MultiBranchAddon/Database/Seeders/.gitkeep
Normal file
0
Modules/MultiBranchAddon/Database/Seeders/.gitkeep
Normal file
31
Modules/MultiBranchAddon/composer.json
Normal file
31
Modules/MultiBranchAddon/composer.json
Normal file
@@ -0,0 +1,31 @@
|
||||
{
|
||||
"name": "nwidart/multibranchaddon",
|
||||
"description": "",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Nicolas Widart",
|
||||
"email": "n.widart@gmail.com"
|
||||
}
|
||||
],
|
||||
"extra": {
|
||||
"laravel": {
|
||||
"providers": [],
|
||||
"aliases": {
|
||||
|
||||
}
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Modules\\MultiBranchAddon\\": "",
|
||||
"Modules\\MultiBranchAddon\\App\\": "app/",
|
||||
"Modules\\MultiBranchAddon\\Database\\Factories\\": "database/factories/",
|
||||
"Modules\\MultiBranchAddon\\Database\\Seeders\\": "database/seeders/"
|
||||
}
|
||||
},
|
||||
"autoload-dev": {
|
||||
"psr-4": {
|
||||
"Modules\\MultiBranchAddon\\Tests\\": "tests/"
|
||||
}
|
||||
}
|
||||
}
|
||||
0
Modules/MultiBranchAddon/config/.gitkeep
Normal file
0
Modules/MultiBranchAddon/config/.gitkeep
Normal file
5
Modules/MultiBranchAddon/config/config.php
Normal file
5
Modules/MultiBranchAddon/config/config.php
Normal file
@@ -0,0 +1,5 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
'name' => 'MultiBranchAddon',
|
||||
];
|
||||
12
Modules/MultiBranchAddon/module.json
Normal file
12
Modules/MultiBranchAddon/module.json
Normal file
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"name": "MultiBranchAddon",
|
||||
"alias": "multibranchaddon",
|
||||
"version": "1.2",
|
||||
"description": "",
|
||||
"keywords": [],
|
||||
"priority": 0,
|
||||
"providers": [
|
||||
"Modules\\MultiBranchAddon\\App\\Providers\\MultiBranchAddonServiceProvider"
|
||||
],
|
||||
"files": []
|
||||
}
|
||||
15
Modules/MultiBranchAddon/package.json
Normal file
15
Modules/MultiBranchAddon/package.json
Normal file
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
"build": "vite build"
|
||||
},
|
||||
"devDependencies": {
|
||||
"axios": "^1.1.2",
|
||||
"laravel-vite-plugin": "^0.7.5",
|
||||
"sass": "^1.69.5",
|
||||
"postcss": "^8.3.7",
|
||||
"vite": "^4.0.0"
|
||||
}
|
||||
}
|
||||
0
Modules/MultiBranchAddon/resources/views/.gitkeep
Normal file
0
Modules/MultiBranchAddon/resources/views/.gitkeep
Normal file
@@ -0,0 +1,52 @@
|
||||
<div class="modal fade common-validation-modal" id="branches-create-modal">
|
||||
<div class="modal-dialog modal-dialog-centered modal-lg">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h1 class="modal-title fs-5">{{ __('Create Branch') }}</h1>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div class="personal-info">
|
||||
<form action="{{ route('multibranch.branches.store') }}" method="post" enctype="multipart/form-data"
|
||||
class="ajaxform_instant_reload">
|
||||
@csrf
|
||||
<div class="row">
|
||||
<div class="col-lg-6 mb-2">
|
||||
<label>{{ __('Name') }}</label>
|
||||
<input type="text" name="name" class="form-control" placeholder="{{ __('Enter name') }}" required>
|
||||
</div>
|
||||
<div class="col-lg-6 mb-2">
|
||||
<label>{{ __('Phone') }}</label>
|
||||
<input type="number" name="phone" class="form-control" placeholder="{{ __('Enter phone') }}">
|
||||
</div>
|
||||
<div class="col-lg-6 mb-2">
|
||||
<label>{{ __('Email') }}</label>
|
||||
<input type="email" name="email" class="form-control" placeholder="{{ __('Enter email') }}">
|
||||
</div>
|
||||
<div class="col-lg-6 mb-2">
|
||||
<label>{{ __('Address') }}</label>
|
||||
<input type="text" name="address" class="form-control" placeholder="{{ __('Enter address') }}">
|
||||
</div>
|
||||
<div class="col-lg-6 mb-2">
|
||||
<label>{{ __('Opening Balance') }}</label>
|
||||
<input type="number" name="branchOpeningBalance" class="form-control" placeholder="{{ __('Enter balance') }}">
|
||||
</div>
|
||||
<div class="col-lg-12">
|
||||
<label>{{__('Description')}}</label>
|
||||
<textarea name="description" class="form-control" placeholder="{{ __('Enter description') }}"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-lg-12">
|
||||
<div class="button-group text-center mt-5">
|
||||
<button type="reset" class="theme-btn border-btn m-2">{{ __('Reset') }}</button>
|
||||
@usercan('branches.create')
|
||||
<button class="theme-btn m-2 submit-btn">{{ __('Save') }}</button>
|
||||
@endusercan
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,123 @@
|
||||
<div class="responsive-table m-0">
|
||||
<table class="table" id="datatable">
|
||||
<thead>
|
||||
<tr>
|
||||
@usercan('branches.delete')
|
||||
<th class="w-60">
|
||||
<div class="d-flex align-items-center gap-3">
|
||||
<input type="checkbox" class="select-all-delete multi-delete">
|
||||
</div>
|
||||
</th>
|
||||
@endusercan
|
||||
<th>{{ __('SL') }}.</th>
|
||||
<th class="text-start">{{ __('Name') }}</th>
|
||||
<th class="text-start">{{ __('Phone') }}</th>
|
||||
<th class="text-start">{{ __('Email') }}</th>
|
||||
<th class="text-start">{{ __('Address') }}</th>
|
||||
<th>{{ __('Status') }}</th>
|
||||
<th>{{ __('Action') }}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach ($branches as $branch)
|
||||
<tr>
|
||||
@usercan('branches.delete')
|
||||
<td class="w-60 checkbox">
|
||||
<input type="checkbox" name="ids[]" class="delete-checkbox-item multi-delete"
|
||||
value="{{ $branch->id }}">
|
||||
</td>
|
||||
@endusercan
|
||||
<td>{{ ($branches->currentPage() - 1) * $branches->perPage() + $loop->iteration }}</td>
|
||||
<td class="text-start">
|
||||
<a href="{{ route('multibranch.switch-branch', $branch->id) }}" class="text-primary fw-bold">
|
||||
{{ $branch->name }}
|
||||
</a>
|
||||
</td>
|
||||
<td class="text-start">{{ $branch->phone }}</td>
|
||||
<td class="text-start">{{ $branch->email }}</td>
|
||||
<td class="text-start">{{ $branch->address }}</td>
|
||||
<td>
|
||||
<label class="switch">
|
||||
<input type="checkbox" {{ $branch->status == 1 ? 'checked' : '' }} class="status"
|
||||
data-url="{{ route('multibranch.branches.status', $branch->id) }}">
|
||||
<span class="slider round"></span>
|
||||
</label>
|
||||
</td>
|
||||
<td class="d-print-none">
|
||||
<div class="dropdown table-action">
|
||||
<button type="button" data-bs-toggle="dropdown">
|
||||
<i class="far fa-ellipsis-v"></i>
|
||||
</button>
|
||||
<ul class="dropdown-menu">
|
||||
<li>
|
||||
@usercan('branches.update')
|
||||
<a href="#branches-edit-modal" data-bs-toggle="modal" class="branches-edit-btn"
|
||||
data-url="{{ route('multibranch.branches.update', $branch->id) }}"
|
||||
data-name="{{ $branch->name }}" data-phone="{{ $branch->phone }}"
|
||||
data-email="{{ $branch->email }}" data-address="{{ $branch->address }}"
|
||||
data-opening-balance="{{ $branch->branchOpeningBalance }}"
|
||||
data-remaining-balance="{{ $branch->branchRemainingBalance }}"
|
||||
data-desc="{{ $branch->description }}">
|
||||
<svg width="18" height="18" viewBox="0 0 18 18" fill="none"
|
||||
xmlns="http://www.w3.org/2000/svg">
|
||||
<path
|
||||
d="M12.1606 3.73679L13.2119 2.68547C13.7925 2.10484 14.7339 2.10484 15.3145 2.68547C15.8951 3.2661 15.8951 4.20748 15.3145 4.78811L14.2632 5.83943M12.1606 3.73679L8.23515 7.66222C7.4512 8.4462 7.05919 8.83815 6.79228 9.31582C6.52535 9.7935 6.2568 10.9214 6 12C7.07857 11.7432 8.2065 11.4746 8.68418 11.2077C9.16185 10.9408 9.5538 10.5488 10.3378 9.76485L14.2632 5.83943M12.1606 3.73679L14.2632 5.83943"
|
||||
stroke="#4B5563" stroke-width="1.2" stroke-linecap="round"
|
||||
stroke-linejoin="round" />
|
||||
<path
|
||||
d="M15.75 9C15.75 12.1819 15.75 13.773 14.7615 14.7615C13.773 15.75 12.1819 15.75 9 15.75C5.81802 15.75 4.22703 15.75 3.23851 14.7615C2.25 13.773 2.25 12.1819 2.25 9C2.25 5.81802 2.25 4.22703 3.23851 3.23851C4.22703 2.25 5.81802 2.25 9 2.25"
|
||||
stroke="#4B5563" stroke-width="1.2" stroke-linecap="round" />
|
||||
</svg>
|
||||
{{ __('Edit') }}
|
||||
</a>
|
||||
@endusercan
|
||||
</li>
|
||||
<li>
|
||||
@usercan('branches.update')
|
||||
<a href="{{ route('multibranch.switch-branch', $branch->id) }}"
|
||||
class="branches-edit-btn">
|
||||
<svg width="18" height="18" viewBox="0 0 18 18" fill="none"
|
||||
xmlns="http://www.w3.org/2000/svg">
|
||||
<path
|
||||
d="M5.99902 5.9018V5.51033C5.99902 4.43153 6.76472 3.50454 7.82411 3.30081L13.0741 2.2912C14.4618 2.02435 15.749 3.08765 15.749 4.50071V13.5C15.749 14.9131 14.4618 15.9763 13.0741 15.7095L7.82411 14.6999C6.76473 14.4962 5.99902 13.5692 5.99902 12.4904V12.0989"
|
||||
stroke="#4B5563" stroke-width="1.25" stroke-linecap="square" />
|
||||
<path d="M9.74899 11.25L11.999 8.99998L9.74899 6.75M11.624 8.99998H2.24902"
|
||||
stroke="#4B5563" stroke-width="1.25" stroke-linecap="square" />
|
||||
</svg>
|
||||
{{ __('Login') }}
|
||||
</a>
|
||||
@endusercan
|
||||
</li>
|
||||
<li>
|
||||
@usercan('branches.delete')
|
||||
<a href="{{ route('multibranch.branches.destroy', $branch->id) }}"
|
||||
class="confirm-action" data-method="DELETE">
|
||||
<svg width="18" height="18" viewBox="0 0 18 18" fill="none"
|
||||
xmlns="http://www.w3.org/2000/svg">
|
||||
<path
|
||||
d="M14.625 4.125L14.1602 11.6438C14.0414 13.5648 13.9821 14.5253 13.5006 15.2159C13.2625 15.5573 12.956 15.8455 12.6005 16.062C11.8816 16.5 10.9192 16.5 8.99452 16.5C7.06734 16.5 6.10372 16.5 5.38429 16.0612C5.0286 15.8443 4.722 15.5556 4.48401 15.2136C4.00266 14.5219 3.94459 13.5601 3.82846 11.6364L3.375 4.125"
|
||||
stroke="#4B5563" stroke-width="1.2" stroke-linecap="round" />
|
||||
<path d="M6.75 8.80078H11.25" stroke="#4B5563" stroke-width="1.2"
|
||||
stroke-linecap="round" />
|
||||
<path d="M7.875 11.7422H10.125" stroke="#4B5563" stroke-width="1.2"
|
||||
stroke-linecap="round" />
|
||||
<path
|
||||
d="M2.25 4.125H15.75M12.0416 4.125L11.5297 3.0688C11.1896 2.3672 11.0195 2.01639 10.7261 1.79761C10.6611 1.74908 10.5922 1.7059 10.5201 1.66852C10.1953 1.5 9.80542 1.5 9.02572 1.5C8.22645 1.5 7.82685 1.5 7.49662 1.67559C7.42343 1.71451 7.35359 1.75943 7.28783 1.80988C6.99109 2.03753 6.82533 2.40116 6.49381 3.12844L6.03955 4.125"
|
||||
stroke="#4B5563" stroke-width="1.2" stroke-linecap="round" />
|
||||
</svg>
|
||||
{{ __('Delete') }}
|
||||
</a>
|
||||
@endusercan
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div class="mt-3">
|
||||
{{ $branches->links('vendor.pagination.bootstrap-5') }}
|
||||
</div>
|
||||
@@ -0,0 +1,54 @@
|
||||
<div class="modal fade common-validation-modal" id="branches-edit-modal">
|
||||
<div class="modal-dialog modal-dialog-centered modal-lg">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h1 class="modal-title fs-5">{{ __('Edit Branch') }}</h1>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div class="personal-info">
|
||||
<form action="" method="post" enctype="multipart/form-data"
|
||||
class="ajaxform_instant_reload branchUpdateForm">
|
||||
@csrf
|
||||
@method('put')
|
||||
<div class="row">
|
||||
<div class="col-lg-6 mb-2">
|
||||
<label>{{ __('Name') }}</label>
|
||||
<input type="text" name="name" id="brnch_name" class="form-control" placeholder="{{ __('Enter name') }}" required>
|
||||
</div>
|
||||
<div class="col-lg-6 mb-2">
|
||||
<label>{{ __('Phone') }}</label>
|
||||
<input type="number" name="phone" id="brnch_phone" class="form-control" placeholder="{{ __('Enter phone') }}">
|
||||
</div>
|
||||
<div class="col-lg-6 mb-2">
|
||||
<label>{{ __('Email') }}</label>
|
||||
<input type="email" name="email" id="brnch_email" class="form-control" placeholder="{{ __('Enter email') }}">
|
||||
</div>
|
||||
<div class="col-lg-6 mb-2">
|
||||
<label>{{ __('Address') }}</label>
|
||||
<input type="text" name="address" id="brnch_address" class="form-control" placeholder="{{ __('Enter address') }}">
|
||||
</div>
|
||||
<div class="col-lg-6 mb-2">
|
||||
<label>{{ __('Opening Balance') }}</label>
|
||||
<input type="number" name="branchOpeningBalance" id="opening_balance" class="form-control" placeholder="{{ __('Enter balance') }}">
|
||||
</div>
|
||||
<div class="col-lg-12">
|
||||
<label>{{__('Description')}}</label>
|
||||
<textarea name="description" id="brnch_desc" class="form-control" placeholder="{{ __('Enter description') }}"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-lg-12">
|
||||
<div class="button-group text-center mt-5">
|
||||
<a href="{{ route('multibranch.branches.index') }}" class="theme-btn border-btn m-2">{{ __('Cancel') }}</a>
|
||||
@usercan('branches.update')
|
||||
<button class="theme-btn m-2 submit-btn">{{ __('Save') }}</button>
|
||||
@endusercan
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,104 @@
|
||||
@extends('layouts.business.master')
|
||||
|
||||
@section('title')
|
||||
{{ __('Branch List') }}
|
||||
@endsection
|
||||
|
||||
@section('main_content')
|
||||
<div class="erp-table-section">
|
||||
<div class="container-fluid">
|
||||
@if (session('error'))
|
||||
<div class="alert alert-dismissible fade show text-center mb-3 text-white gradient-alert" role="alert">
|
||||
<b class="text-light">{{__('Note')}}:</b> {{ session('error') }}
|
||||
<button type="button" class="btn-close btn-close-white" data-bs-dismiss="alert" aria-label="Close"></button>
|
||||
</div>
|
||||
@endif
|
||||
|
||||
<div class="alert-box" id="alertBox">
|
||||
<ul class="alert-list">
|
||||
<li>
|
||||
<svg width="7" height="7" viewBox="0 0 7 7" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M3.50488 6.5957C2.98926 6.5957 2.51838 6.46999 2.09224 6.21857C1.66611 5.96289 1.3252 5.62198 1.06951 5.19584C0.818093 4.76971 0.692383 4.29883 0.692383 3.7832C0.692383 3.26331 0.818093 2.79243 1.06951 2.37056C1.3252 1.94442 1.66611 1.60564 2.09224 1.35422C2.51838 1.09854 2.98926 0.970703 3.50488 0.970703C4.02477 0.970703 4.49565 1.09854 4.91753 1.35422C5.34366 1.60564 5.68244 1.94442 5.93386 2.37056C6.18954 2.79243 6.31738 3.26331 6.31738 3.7832C6.31738 4.29883 6.18954 4.76971 5.93386 5.19584C5.68244 5.62198 5.34366 5.96289 4.91753 6.21857C4.49565 6.46999 4.02477 6.5957 3.50488 6.5957Z" fill="black"/>
|
||||
</svg>
|
||||
{{__('Previously, you didn’t have a branch section. So, when you create your first branch, another branch will be created automatically using your company/business name.')}} <br>
|
||||
<i><span class="fw-bold">{{__('Example')}}:</span> {{__('If your company/business name is')}} <span class="fw-bold">{{__('Acnoo')}},</span> {{__('when you create your first branch, another branch will automatically be created with the name')}} <span class="fw-bold">{{__('Acnoo')}}.</span></i>
|
||||
</li>
|
||||
<li>
|
||||
<svg width="7" height="7" viewBox="0 0 7 7" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M3.50488 6.5957C2.98926 6.5957 2.51838 6.46999 2.09224 6.21857C1.66611 5.96289 1.3252 5.62198 1.06951 5.19584C0.818093 4.76971 0.692383 4.29883 0.692383 3.7832C0.692383 3.26331 0.818093 2.79243 1.06951 2.37056C1.3252 1.94442 1.66611 1.60564 2.09224 1.35422C2.51838 1.09854 2.98926 0.970703 3.50488 0.970703C4.02477 0.970703 4.49565 1.09854 4.91753 1.35422C5.34366 1.60564 5.68244 1.94442 5.93386 2.37056C6.18954 2.79243 6.31738 3.26331 6.31738 3.7832C6.31738 4.29883 6.18954 4.76971 5.93386 5.19584C5.68244 5.62198 5.34366 5.96289 4.91753 6.21857C4.49565 6.46999 4.02477 6.5957 3.50488 6.5957Z" fill="black"/>
|
||||
</svg>
|
||||
{{__('All your previous data will be assigned to the automatically created branch')}} (<span class="fw-bold">{{__('Acnoo')}}</span> {{__('in this example')}}).
|
||||
</li>
|
||||
<li>
|
||||
<svg width="7" height="7" viewBox="0 0 7 7" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M3.50488 6.5957C2.98926 6.5957 2.51838 6.46999 2.09224 6.21857C1.66611 5.96289 1.3252 5.62198 1.06951 5.19584C0.818093 4.76971 0.692383 4.29883 0.692383 3.7832C0.692383 3.26331 0.818093 2.79243 1.06951 2.37056C1.3252 1.94442 1.66611 1.60564 2.09224 1.35422C2.51838 1.09854 2.98926 0.970703 3.50488 0.970703C4.02477 0.970703 4.49565 1.09854 4.91753 1.35422C5.34366 1.60564 5.68244 1.94442 5.93386 2.37056C6.18954 2.79243 6.31738 3.26331 6.31738 3.7832C6.31738 4.29883 6.18954 4.76971 5.93386 5.19584C5.68244 5.62198 5.34366 5.96289 4.91753 6.21857C4.49565 6.46999 4.02477 6.5957 3.50488 6.5957Z" fill="black"/>
|
||||
</svg>
|
||||
{{__('You cannot delete the automatically created branch. This is because if a branch is deleted, it is removed from every section, making it impossible to filter branch data. Therefore, the automatically created branch cannot be deleted.')}}</li>
|
||||
</ul>
|
||||
<span class="alert-close-btn">×</span>
|
||||
</div>
|
||||
|
||||
<div class="card">
|
||||
<div class="card-bodys">
|
||||
<div class="table-header p-16">
|
||||
<h4>{{ __('Branch List') }}</h4>
|
||||
<a type="button" href="#branches-create-modal" data-bs-toggle="modal"
|
||||
class="add-order-btn rounded-2 {{ Route::is('multibranch.branches.create') ? 'active' : '' }}"
|
||||
@usercan('branches.create')
|
||||
class="btn btn-primary"><i class="fas fa-plus-circle me-1"></i>{{ __('Add new Branch') }}</a>
|
||||
@endusercan
|
||||
</div>
|
||||
|
||||
<div class="table-top-form p-16-0">
|
||||
<form action="{{ route('multibranch.branches.index') }}" method="GET" class="filter-form" table="#branches-data">
|
||||
|
||||
<div class="table-top-left d-flex gap-3 margin-l-16">
|
||||
<div class="gpt-up-down-arrow position-relative">
|
||||
<select name="per_page" class="form-control">
|
||||
<option @selected(request('per_page') == 20) value="20">{{ __('Show 20') }}</option>
|
||||
<option @selected(request('per_page') == 50) value="50">{{ __('Show 50') }}</option>
|
||||
<option @selected(request('per_page') == 100) value="100">{{ __('Show 100') }}</option>
|
||||
<option @selected(request('per_page') == 500) value="500">{{ __('Show 500') }}</option>
|
||||
</select>
|
||||
<span></span>
|
||||
</div>
|
||||
<div class="table-search position-relative">
|
||||
<input type="text" name="search" class="form-control" placeholder="{{ __('Search...') }}" value="{{ request('search') }}">
|
||||
<span class="position-absolute">
|
||||
<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M14.582 14.582L18.332 18.332" stroke="#4D4D4D" stroke-width="1.25" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
<path d="M16.668 9.16797C16.668 5.02584 13.3101 1.66797 9.16797 1.66797C5.02584 1.66797 1.66797 5.02584 1.66797 9.16797C1.66797 13.3101 5.02584 16.668 9.16797 16.668C13.3101 16.668 16.668 13.3101 16.668 9.16797Z" stroke="#4D4D4D" stroke-width="1.25" stroke-linejoin="round"/>
|
||||
</svg>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="delete-item delete-show d-none">
|
||||
<div class="delete-item-show">
|
||||
<p class="fw-bold"><span class="selected-count"></span> {{ __('items show') }}</p>
|
||||
<button data-bs-toggle="modal" class="trigger-modal" data-bs-target="#multi-delete-modal" data-url="{{ route('multibranch.branches.delete-all') }}">{{ __('Delete') }}</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="branches-data">
|
||||
@include('multibranchaddon::branches.datas')
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
|
||||
@push('modal')
|
||||
@include('multibranchaddon::component.delete-modal')
|
||||
@include('multibranchaddon::branches.create')
|
||||
@include('multibranchaddon::branches.edit')
|
||||
@endpush
|
||||
|
||||
|
||||
@push('js')
|
||||
<script src="{{ asset('assets/js/custom/custom-alart.js') }}"></script>
|
||||
@endpush
|
||||
@@ -0,0 +1,215 @@
|
||||
@extends('layouts.business.master')
|
||||
|
||||
@section('title')
|
||||
{{ __('Overview') }}
|
||||
@endsection
|
||||
|
||||
@section('main_content')
|
||||
<div class="container-fluid m-h-100">
|
||||
<div class="row gpt-dashboard-chart mb-30">
|
||||
<div class="col-md-12 col-lg-12 col-xl-8">
|
||||
<div class="card new-card dashboard-card border-0 p-0">
|
||||
<div class="dashboard-chart">
|
||||
<h4>{{ __('Revenue Statistic') }}</h4>
|
||||
<div class="gpt-up-down-arrow position-relative">
|
||||
<select class="form-control overview-year">
|
||||
@for ($i = date('Y'); $i >= 2022; $i--)
|
||||
<option @selected($i == date('Y')) value="{{ $i }}">{{ $i }}
|
||||
</option>
|
||||
@endfor
|
||||
</select>
|
||||
<span></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-body pt-0">
|
||||
<div class="d-flex align-items-center justify-content-center gap-3 pb-2">
|
||||
<div class="d-flex align-items-center gap-1">
|
||||
<div class="income-bulet2"></div>
|
||||
<p>{{__('Profit')}}: <strong class="profit-value">0</strong></p>
|
||||
</div>
|
||||
<div class="d-flex align-items-center gap-1">
|
||||
<div class="expense-bulet2"></div>
|
||||
<p>{{__('Loss')}}: <strong class="loss-value">0</strong></p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="content">
|
||||
<canvas id="branchRevenueChart"></canvas>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-12 col-lg-12 col-xl-4">
|
||||
<div class="card new-card dashboard-card border-0 p-0 statement-container">
|
||||
<div class="dashboard-chart">
|
||||
<h4>{{ __('Statement') }}</h4>
|
||||
<div class="gpt-up-down-arrow position-relative">
|
||||
<select class="form-control overview-loss-profit-year">
|
||||
@for ($i = date('Y'); $i >= 2022; $i--)
|
||||
<option @selected($i == date('Y')) value="{{ $i }}">{{ $i }}
|
||||
</option>
|
||||
@endfor
|
||||
</select>
|
||||
<span></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-body pt-0">
|
||||
<div class="profit-loss-content">
|
||||
<canvas id="profitLossChart"></canvas>
|
||||
</div>
|
||||
<div class="d-flex align-items-center justify-content-center gap-3 pb-2 mt-4">
|
||||
<div class="d-flex align-items-center gap-1">
|
||||
<div class="income-bulet"></div>
|
||||
<p>{{__('Income')}}: <strong class="profit">0</strong></p>
|
||||
</div>
|
||||
<div class="d-flex align-items-center gap-1">
|
||||
<div class="expense-bulet"></div>
|
||||
<p>{{__('Expense')}}: <strong class="loss">0</strong></p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row gpt-dashboard-chart mb-30">
|
||||
|
||||
<div class="col-md-12 col-lg-12 col-xl-8">
|
||||
<div class="card new-card dashboard-card border-0 p-0">
|
||||
<div class="dashboard-chart">
|
||||
<h4>{{ __('Branch Wise Sales') }}</h4>
|
||||
<div class="gpt-up-down-arrow position-relative">
|
||||
<select class="form-control branch-wise-sales-year">
|
||||
@for ($i = date('Y'); $i >= 2022; $i--)
|
||||
<option @selected($i == date('Y')) value="{{ $i }}">{{ $i }}
|
||||
</option>
|
||||
@endfor
|
||||
</select>
|
||||
<span></span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="responsive-table branch-overview-table vatlist-body mt-0">
|
||||
<table class="table" id="datatable">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>{{ __('SL') }}.</th>
|
||||
<th>{{ __('Branch') }}</th>
|
||||
<th>{{ __('Total Sales') }}</th>
|
||||
<th>{{ __('Paid') }}</th>
|
||||
<th>{{ __('Due') }}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="sale-data">
|
||||
{{-- Dynamic data come --}}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-md-12 col-lg-12 col-xl-4">
|
||||
<div class="card new-card dashboard-card border-0 statement-container p-0">
|
||||
<div class="dashboard-chart mb-1">
|
||||
<h4>{{ __('Expire Product') }}</h4>
|
||||
</div>
|
||||
<div class="responsive-table branch-overview-table vatlist-body mt-0">
|
||||
<table class="table" id="datatable">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>{{ __('SL') }}.</th>
|
||||
<th>{{ __('Branch') }}</th>
|
||||
<th>{{ __('Qty') }}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="vat-data">
|
||||
@foreach ($branches_expired_products as $branch)
|
||||
<tr>
|
||||
<td>{{ $loop->iteration }}</td>
|
||||
<td>{{ $branch->name }}</td>
|
||||
<td><div class="text-primary">{{ $branch->expired_stocks_count }}</div></td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row gpt-dashboard-chart">
|
||||
<div class="col-md-12 col-lg-12 col-xl-8">
|
||||
<div class="card new-card dashboard-card border-0 p-0">
|
||||
<div class="dashboard-chart">
|
||||
<h4>{{ __('Branch Wise Purchases') }}</h4>
|
||||
<div class="gpt-up-down-arrow position-relative">
|
||||
<select class="form-control batch-wise-purchases-year">
|
||||
@for ($i = date('Y'); $i >= 2022; $i--)
|
||||
<option @selected($i == date('Y')) value="{{ $i }}">{{ $i }}
|
||||
</option>
|
||||
@endfor
|
||||
</select>
|
||||
<span></span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="responsive-table branch-overview-table vatlist-body mt-0">
|
||||
<table class="table" id="datatable">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>{{ __('SL') }}.</th>
|
||||
<th>{{ __('Branch') }}</th>
|
||||
<th>{{ __('Total Purchase') }}</th>
|
||||
<th>{{ __('Paid') }}</th>
|
||||
<th>{{ __('Due') }}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="purchase-data">
|
||||
{{-- Dynamic data --}}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@if(moduleCheck('HrmAddon'))
|
||||
<div class="col-md-12 col-lg-12 col-xl-4">
|
||||
<div class="card new-card dashboard-card statement-container border-0 p-0">
|
||||
<div class="dashboard-chart">
|
||||
<h4>{{ __('Employee Overview') }}</h4>
|
||||
</div>
|
||||
<div class="responsive-table branch-overview-table vatlist-body mt-0">
|
||||
<table class="table" id="datatable">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>{{ __('SL') }}.</th>
|
||||
<th>{{ __('Branch') }}</th>
|
||||
<th>{{ __('Staffs') }}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="vat-data">
|
||||
@foreach ($branches as $branch)
|
||||
<tr>
|
||||
<td>{{ $loop->iteration }}</td>
|
||||
<td>{{ $branch->name }}</td>
|
||||
<td>{{ $branch->employees_count }}</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<input type="hidden" value="{{ route('multibranch.charts.income-expense') }}" id="incomeExpenseRoute">
|
||||
<input type="hidden" value="{{ route('multibranch.charts.sale-purchase') }}" id="salePurchaseChartRoute">
|
||||
<input type="hidden" value="{{ route('multibranch.branch.wise.sales') }}" id="branchWiseSaleRoute">
|
||||
<input type="hidden" value="{{ route('multibranch.branch.wise.purchases') }}" id="branchWisePurchaseRoute">
|
||||
@endsection
|
||||
|
||||
|
||||
@push('js')
|
||||
<script src="{{ asset('assets/js/chart.min.js') }}"></script>
|
||||
<script src="{{ asset('assets/plugins/custom/branch-overview.js') }}"></script>
|
||||
@endpush
|
||||
@@ -0,0 +1,22 @@
|
||||
<div class="modal fade" id="multi-delete-modal" tabindex="-1" aria-labelledby="multi-delete-modal-label" aria-hidden="true">
|
||||
<div class="modal-dialog modal-dialog-centered">
|
||||
<div class="modal-content">
|
||||
<div class="text-end">
|
||||
<button type="button" class="btn-close m-3 mb-0" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||
</div>
|
||||
<div class="modal-body pt-0">
|
||||
<div class="delete-modal">
|
||||
<h5>{{ __('Are You Sure?') }}</h5>
|
||||
<p>{{ __("You want to delete everything!") }}</p>
|
||||
</div>
|
||||
<div class="multiple-button-group">
|
||||
<button class="btn reset-btn" data-bs-dismiss="modal">{{ __('Cancel') }}</button>
|
||||
<form id="dynamic-delete-form" method="POST" class="ajaxform_instant_reload">
|
||||
@csrf
|
||||
<button class="btn theme-btn submit-btn create-all-delete" type="submit">{{ __('Yes, Delete It!') }}</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
0
Modules/MultiBranchAddon/routes/.gitkeep
Normal file
0
Modules/MultiBranchAddon/routes/.gitkeep
Normal file
21
Modules/MultiBranchAddon/routes/api.php
Normal file
21
Modules/MultiBranchAddon/routes/api.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Route;
|
||||
use Modules\MultiBranchAddon\App\Http\Controllers\Api as Multibranch;
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| API Routes
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here is where you can register API routes for your application. These
|
||||
| routes are loaded by the RouteServiceProvider within a group which
|
||||
| is assigned the "api" middleware group. Enjoy building your API!
|
||||
|
|
||||
*/
|
||||
|
||||
Route::middleware(['auth:sanctum'])->prefix('v1')->name('api.')->group(function () {
|
||||
Route::apiResource('branches', Multibranch\AcnooBranchController::class)->except('show');
|
||||
Route::get('/switch-branch/{id}', [Multibranch\AcnooBranchController::class, 'switchBranch']);
|
||||
Route::get('/exit-branch/{id}', [Multibranch\AcnooBranchController::class, 'exitBranch']);
|
||||
});
|
||||
30
Modules/MultiBranchAddon/routes/web.php
Normal file
30
Modules/MultiBranchAddon/routes/web.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Route;
|
||||
use Modules\MultiBranchAddon\App\Http\Controllers as Multibranch;
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Web Routes
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here is where you can register web routes for your application. These
|
||||
| routes are loaded by the RouteServiceProvider within a group which
|
||||
| contains the "web" middleware group. Now create something great!
|
||||
|
|
||||
*/
|
||||
|
||||
Route::group(['as' => 'multibranch.', 'prefix' => 'multibranch', 'middleware' => ['users', 'expired']], function () {
|
||||
Route::resource('branches', Multibranch\AcnooBranchController::class)->except('show');
|
||||
Route::post('branches/filter', [Multibranch\AcnooBranchController::class, 'acnooFilter'])->name('branches.filter');
|
||||
Route::post('branches/delete-all', [Multibranch\AcnooBranchController::class, 'deleteAll'])->name('branches.delete-all');
|
||||
Route::post('branches/status/{id}', [Multibranch\AcnooBranchController::class, 'status'])->name('branches.status');
|
||||
|
||||
Route::get('branches/overview', [Multibranch\AcnooBranchController::class, 'overview'])->name('branches.overview');
|
||||
Route::get('/incomes-expenses', [Multibranch\AcnooBranchController::class, 'incomeExpense'])->name('charts.income-expense');
|
||||
Route::get('/sales-purchases', [Multibranch\AcnooBranchController::class, 'earningData'])->name('charts.sale-purchase');
|
||||
Route::get('/branch-wise-sales', [Multibranch\AcnooBranchController::class, 'branchWiseSales'])->name('branch.wise.sales');
|
||||
Route::get('/branch-wise-purchases', [Multibranch\AcnooBranchController::class, 'branchWisePurchases'])->name('branch.wise.purchases');
|
||||
Route::get('/switch-branch/{id}', [Multibranch\AcnooBranchController::class, 'switchBranch'])->name('switch-branch');
|
||||
Route::get('/exit-branch/{id}', [Multibranch\AcnooBranchController::class, 'exitBranch'])->name('exit-branch');
|
||||
});
|
||||
26
Modules/MultiBranchAddon/vite.config.js
Normal file
26
Modules/MultiBranchAddon/vite.config.js
Normal file
@@ -0,0 +1,26 @@
|
||||
import { defineConfig } from 'vite';
|
||||
import laravel from 'laravel-vite-plugin';
|
||||
|
||||
export default defineConfig({
|
||||
build: {
|
||||
outDir: '../../public/build-multibranchaddon',
|
||||
emptyOutDir: true,
|
||||
manifest: true,
|
||||
},
|
||||
plugins: [
|
||||
laravel({
|
||||
publicDirectory: '../../public',
|
||||
buildDirectory: 'build-multibranchaddon',
|
||||
input: [
|
||||
__dirname + '/resources/assets/sass/app.scss',
|
||||
__dirname + '/resources/assets/js/app.js'
|
||||
],
|
||||
refresh: true,
|
||||
}),
|
||||
],
|
||||
});
|
||||
|
||||
//export const paths = [
|
||||
// 'Modules/$STUDLY_NAME$/resources/assets/sass/app.scss',
|
||||
// 'Modules/$STUDLY_NAME$/resources/assets/js/app.js',
|
||||
//];
|
||||
Reference in New Issue
Block a user